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

✨ ERC20Votes #1127

Merged
merged 41 commits into from
Oct 17, 2024
Merged

✨ ERC20Votes #1127

merged 41 commits into from
Oct 17, 2024

Conversation

Vectorized
Copy link
Owner

@Vectorized Vectorized commented Oct 13, 2024

Description

Ready for review

Checklist

Ensure you completed all of the steps below before submitting your pull request:

  • Ran forge fmt?
  • Ran forge test?

Pull requests with an incomplete checklist will be thrown out.

@Vectorized
Copy link
Owner Author

@atarpara Help me review.

I'm only 90% confident.

Copy link
Collaborator

@atarpara atarpara left a 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())))
Copy link
Collaborator

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()`.
Copy link
Collaborator

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

Copy link
Owner Author

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()`.
Copy link
Collaborator

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

}
h := m
}
if h {
Copy link
Collaborator

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)) }`

@Vectorized Vectorized merged commit 13e7f22 into main Oct 17, 2024
11 checks passed
@Vectorized Vectorized deleted the erc20votes branch October 17, 2024 03:22
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.

2 participants