-
Notifications
You must be signed in to change notification settings - Fork 22
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
Make the splits weights uint256 #345
Conversation
9704298
to
4facd52
Compare
e87a334
to
24b2f22
Compare
24b2f22
to
30be8e4
Compare
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.
looks good.
require(weight != 0, "Splits receiver weight is zero"); | ||
if (weight > _TOTAL_SPLITS_WEIGHT) weight = _TOTAL_SPLITS_WEIGHT + 1; |
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.
Okay, just to verify if I understood this correctly.
weight = _TOTAL_SPLITS_WEIGHT + 1;
This is a gas optimization. You want to operate with unchecked
and still have a the potential overflow protection. Therefore you check if the weight
is greater than the _TOTAL_SPLITS_WEIGHT
.
You add +1
to ensure it will revert later with totalWeight <= _TOTAL_SPLITS_WEIGHT
an additional require
would be more expensive.
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.
Yes, exactly 👍
This makes the API simpler and more sane, it requires less effort and gas to parse and validate the calldata.