-
Notifications
You must be signed in to change notification settings - Fork 398
Add support for EIP-7702 #323
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
Add support for EIP-7702 #323
Conversation
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 seems that there is several special cases that might not be handled correctly in this implementation:
- Delegation Chain Protection: EIP-7702 specifies that clients must retrieve only the first code and stop following delegation chains to prevent infinite loops.
- Delegation to a Precompile: EIP-7702 specifies that when a precompile address is the target of delegation, the retrieved code should be considered empty.
- Opcodes
CODESIZE
andCODECOPY
should follows delegation, can you add tests for that?
See discussions above.
This seems to be correctly implemented. In case of delegating to precompile:
So this seems fine.
Right now from my review it looks correct. CODESIZE and CODECOPY returns in all cases the runtime code ( But nevertheless as @librelois has said, it'll always be better to have some more test cases! |
Addressed in 3134553 |
Added a comprehensive test suite in f5cc851 and currently investigating the failing tests. |
EIP-7702 states: "When multiple tuples from the same authority are present, set the code using the address in the last valid occurrence." It is my understanding that, when multiple authorizations from the same authorities are present in a list, for them to be valid they must have increasing nonces. I updated the corresponding test to reflect this in cc32e59 |
You tested EXTCODECOPY and EXTCODESIZE, but I didn’t find tests for the corresponding behavior of CODECOPY and CODESIZE. It’s very important to test all affected opcodes. |
I did some research and it seems that geth increment the nonce for every valid tuple. So, if there is two authorizations for the same authority, the nonce must increase twice. |
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 now, great work!
* feat: ✨ add pectra config * feat: ⬆️ upgrade ethereum crate * feat: ✨ add Authorization type * feat: ✨ add EIP-7702 delegation logic to EVM * feat: ✨ add EIP-7702 initialization and gas costs * refactor: ♻️ lint and fmt * style: 🎨 fmt * feat: ✨ upgrade ethereum * fix: ⬆️ upgrade rust toolchain * refactor: 🔥 remove Authorization type from evm_core * fix: 🐛 fix CODESIZE and CODECOPY behavior according to EIP-7702 * test: ✅ test opcodes impacted by EIP-7702 * test: ✅ merge test files * perf: ⚡ avoid fetching code unnecessarily * refactor: ⬆️ upgrade ethereum * test: ✅ test delegation chains * fix: 🐛 zero address delegation clears code * refactor: 🔒 do not silence exit errors * test: ✅ add comprehensive test suite for EIP-7702 * test: ✅ update assumptions on multiple autorizations from the same authority * fix: 🐛 add authority to accessed_addresses * test: ✅ correct gas expectations in test * test: ✅ correct gas calculations in test * refactor: 🚨 lint * fix: 🐛 verify the code of authority is empty or already delegated * fix: 🐛 fix nonce edge case * test: ✅ fix assertion in test * test: ✅ fix gas exhaustion test * test: ✅ test CODESIZE and CODECOPY ops * docs: 🔥 remove comments * test: ✅ update test expectations
Description
Adds EIP-7702 support.