Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

return 0 for getDelegateRewards if voter didn't vote in the screening stage #132

Merged
merged 1 commit into from
Oct 13, 2023

Conversation

MikeHathaway
Copy link
Collaborator

@MikeHathaway MikeHathaway commented Sep 15, 2023

Description of change

High level

  • return 0 for getDelegateRewards if voter didn't vote in the screening stage

Description of bug or vulnerability and solution

Copy link
Contributor

@grandizzy grandizzy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this check be done inside _getDelegateReward function so to be applied for all scenarios where it is called?

@@ -1099,6 +1099,8 @@ contract GrantFund is IGrantFund, Storage, ReentrancyGuard {
DistributionPeriod storage currentDistribution = _distributions[distributionId_];
VoterInfo storage voter = _voterInfo[distributionId_][voter_];

if (voter.screeningVotesCast == 0) return 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I personally prefer using

if (voter.screeningVotesCast != 0) {
  rewards_ = 
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although I'm not opinionated about this change, it's a pattern we have been following in the contracts repo and therefore I agree with @grandizzy .

@MikeHathaway
Copy link
Collaborator Author

shouldn't this check be done inside _getDelegateReward function so to be applied for all scenarios where it is called?

Did it this way for a couple of reasons - this would be the minimal amount of changes, and also, the claim approach should revert instead of returning 0, so we would have to create branching logic to handle claim vs get calls to _getDelegateReward

@grandizzy
Copy link
Contributor

shouldn't this check be done inside _getDelegateReward function so to be applied for all scenarios where it is called?

Did it this way for a couple of reasons - this would be the minimal amount of changes, and also, the claim approach should revert instead of returning 0, so we would have to create branching logic to handle claim vs get calls to _getDelegateReward

makes sense, thanks

Copy link
Contributor

@EdNoepel EdNoepel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@ith-harvey ith-harvey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@prateek105 prateek105 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@EdNoepel EdNoepel merged commit 545ec42 into main Oct 13, 2023
3 checks passed
@EdNoepel EdNoepel deleted the get-dr branch October 13, 2023 14:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants