-
Notifications
You must be signed in to change notification settings - Fork 11.7k
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
Gas loop optimization in MerkleProof.sol
#5036
base: master
Are you sure you want to change the base?
Conversation
|
MerkleProof.sol
(#5028)MerkleProof.sol
(#5028)
@CarsonCase reverted back the |
Gas difference:
|
MerkleProof.sol
(#5028)MerkleProof.sol
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 does look good to me but I am not sure if the tradeoff makes sense.
From the gas benchmarks we can see --via-ir
is even worse in the case of memory. For the calldata
one I see no difference, which is consistent with how --via-ir
works as it can assume that calldata never changes, thus it can be taken out of the loop.
At the moment, seems like we're largely affecting projects using --via-ir
but improving performance for those who don't, and I don't have an opinion yet 🤔
Not opposed to closing this yet, but I'd like to hear @Amxx take, perhaps he has more clarity on why via IR is getting worse results
Closes #5028 by caching the length of the proof to prevent an unnecessary DUP call (3 gas per iteration)
PR Checklist
npx changeset add
)