-
-
Notifications
You must be signed in to change notification settings - Fork 805
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
Zero pad from calldata #1605
Zero pad from calldata #1605
Conversation
Run against ETH2.0 deposit contract |
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.
Brilliant usages of calldatacopy, this makes very happy. :) The gas savings will be insane for anybody that uses bytes.
The semantics of calldatacopy is that copying data from past-the-end writes zero bytes to memory. So we can avoid the loop, making the code more gas-efficient and easier to reason about.
(no longer needed with calldatacopy zeroer)
maxlen was confusingly named. maxlen referred to the static size of the entire packed log. instead, the maxlen of the current item should be passed to zero_pad.
It's a red herring. byte arrays should always be padded to the runtime length and not maxlen.
Callers should make this optimization
4516222
to
1971b22
Compare
I ran the eth2.0 tests and they passed, although I'm not sure that's a great indicator because they also pass under master and 0.1.0b12. |
@charles-cooper @fubuloubu I think this can be merged? |
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.
Are some test cases missing in our test suite, or does this refactor not implement a logical change?
Only replaces existing plumbing, with better pipes ;) |
What I did
Increase clarity and efficiency of zero-padder. Currently overlaps with #1611 - fixes #1599, #1610. See the discussion in those issues as well as #1603 (comment).
How I did it
CALLDATACOPY writes zero bytes into memory when the location in calldata is >= calldatasize.
How to verify it
Description for the changelog
Cute Animal Picture