-
Notifications
You must be signed in to change notification settings - Fork 345
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
✨ ERC20Votes #1127
✨ ERC20Votes #1127
Conversation
@atarpara Help me review. I'm only 90% confident. |
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.
LGTM!
sstore(checkpointSlot, or(or(key, shl(48, n)), shl(96, newValue))) | ||
break | ||
} | ||
sstore(checkpointSlot, or(or(key, shl(48, n)), shl(96, address()))) |
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.
Awesome. It's very interesting see how did you manage 2**256-1
range.
} | ||
newValue := add(oldValue, amount) | ||
if iszero(lt(newValue, oldValue)) { break } | ||
mstore(0x00, 0x9dbbeb75) // `ERC5805CheckpointValueOverflow()`. |
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.
It's unreachable condition or path bcz totalSupply()
never exceeds type(uint256).max
value
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 is incase someone overrides the voting units function to return a multiple of balance
if iszero(isAdd) { | ||
newValue := sub(oldValue, amount) | ||
if iszero(gt(newValue, oldValue)) { break } | ||
mstore(0x00, 0x5915f686) // `ERC5805CheckpointValueUnderflow()`. |
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.
It's unreachable condition or path bcz totalSupply()
never exceeds type(uint256).max
value
src/tokens/ERC20Votes.sol
Outdated
} | ||
h := m | ||
} | ||
if h { |
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.
It should be converted into branch less to save gas
and codesize
let checkpointSlot := add(sub(h, 1), lengthSlot)
result := mul(iszero(iszero(h)), shr(96, sload(checkpointSlot))
if eq(result, address()) { result := sload(not(checkpointSlot)) }`
Description
Ready for review
Checklist
Ensure you completed all of the steps below before submitting your pull request:
forge fmt
?forge test
?Pull requests with an incomplete checklist will be thrown out.