Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Add change reward threshold in live contract. Closes #80 #81
Add change reward threshold in live contract. Closes #80 #81
Changes from 1 commit
6427653
cb1b59b
94fc92f
69aea2c
4e94211
6a8bd2b
aef6647
4038dd6
0c25798
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it safe to skip the check
!participantIsReadyForTransfer(participant)
? I understand thatoldBalance <= minBalanceForTransfer
costs less gas thanparticipantIsReadyForTransfer
, which is a good optimisation.I am struggling to understand if this is correct, though.
Situations to consider:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the min balance for transfer is increased
readyForTransfer
structure, and not removed. I think that's ok. They won't be added twice either (their old balance can't be below the threshold if they were already above it, and they are in the array of readyToTransfer participants)If the min balance for transfer is decreased
readyForTransfer
, and not be removed (this code path doesn't exist)oldbalance <= minBalanceForTransfer
is false (they were already above the previous higher threshold)!participantIsReadyForTransfer(..)
(they are already in the array)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll need to think about this a bit.
In the meantime, what do you think about adding tests for the different situations you described above? This would ensure that the implementation handles them exactly as it should.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great idea!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all covered in passing tests now, no contract changes necessary
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This means that we will pay rewards to these participants on the next payout cycle even though they don't meet the new threshold requirement.
I don't have a strong opinion about whether this is ok or not; I am happy to follow your decision.
I think it's worth adding a code comment to explain that this behaviour is intentional.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment is there in tests, to me that's good enough - if one would change the logic, this test would start failing. Wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can fix this if it becomes a problem