-
Notifications
You must be signed in to change notification settings - Fork 202
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
refactor(contracts): specify gas cost in SemaphoreVerifier precompile calls #883
Conversation
refactor(contracts): specify gas cost in SemaphoreVerifier precompile calls
🚨 Report Summary
For more details view the full report in OpenZeppelin Code Inspector |
@chancehudson @cedoor Based on EVM code reference (https://www.evm.codes/precompiled), 0x07 For the 0x08 This change is very EVM implementation-specific, but as EVM iterates I believe the gas cost will likely only decrease and not increase, so specifying the max gas cost to use should be fine. |
On a side note, I have this experimenting code here: Even if I pass in invalid input parameters to But I am not sure if this is hardhat node implementation specific or is part of the specification, so erring on the defensive side. |
@jimmychu0807 Thanks for this PR, it looks like the best solution to me.
I'm not sure about this. I'd like to know what @chancehudson thinks about it. Also a review from @0xDatapunk and @thogiti would be great! |
Thanks 0xDatapunk for the review. @chancehudson @thogiti if you have time these few days could you take a look at this PR. The code change is just 3 lines, changing from |
I'd recommend sending ~20% extra gas with each call - I've seen other similar cases that did this. The sent gas will simply be refunded so it should not change the final price of the transaction. Hardcoding gas numbers like this is very brittle so safety measures should be taken. The calculated gas numbers look correct though. This change should include a note to dependent packages too noting the risk here. If a contract is deployed as immutable it's possible it gets permanently and unavoidably broken in the future by changes to precompile pricing. |
This makes sense to me. Should add some extra gas as buffer. |
Increased gas cost with safety buffer of 33.3%, just want to reserve a bit wider margin. Gas report generated by |
Looks good. Please add more detailed documentation on these changes. Please make sure to update the fixed gas costs numbers for any future updates. |
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 like it's ready to be merged!
Thanks @jimmychu0807 🙏🏽
thank you @chancehudson @thogiti @0xDatapunk for the input! |
Description
Close #871
Other Info
Original gas usage:
With this PR (last updated 2024-10-31):
Checklist
yarn format
andyarn lint
without getting any errors