Repository navigation
Conversation
Only code consisting of exactly 0xef0100 followed by an address is a delegation designator. Previously any code starting with 0xef0100 was treated as delegated because get_delegate_address() loaded only the first 23 bytes of the code. Load one more byte so that longer code is seen as longer, and make is_code_delegated() check the exact size. Such code cannot be deployed after London (EIP-3541) so this does not affect mainnet, but it can exist in arbitrary pre-states. The statetest_loader check for designators of invalid size is now unreachable, because such code is rejected by the EIP-3541 rule.
Contributor
Merging this PR will degrade performance by 1.53%
Warning Please fix the performance issues or acknowledge them on CodSpeed. Performance Changes
Tip Investigate this regression by commenting Comparing |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1822 +/- ##
=======================================
Coverage 98.23% 98.23%
=======================================
Files 186 186
Lines 17192 17214 +22
Branches 3963 3970 +7
=======================================
+ Hits 16888 16910 +22
Misses 235 235
Partials 69 69
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Only code consisting of exactly
0xef0100 || address(23 bytes) is an EIP-7702 delegation designator. evmone treated any code starting with0xef0100as delegated, becauseget_delegate_address()loaded only the first 23 bytes of the code andis_code_delegated()checked only the prefix. Longer code with this prefix was then executed as the delegate's code instead of failing on the0xefinstruction. In release builds the assert on the designator size is gone, so nothing caught it.get_delegate_address()now loads one byte more than the designator size, so longer code is seen as longer, andis_code_delegated()checks the exact size. This keeps a singlecopy_code()per call target, unlike checkingget_code_size()first, which adds a host call to every CALL.Such code cannot be deployed after London (EIP-3541), so mainnet is not affected, but it can be present in arbitrary pre-states. The issue was reported in an audit of the ZisK Ethereum guest program (ziskethone), which carries the same fix as a patch to evmone.
The
validate_state()check for designators of invalid size became unreachable, because such code is now rejected by the EIP-3541 rule, so it is removed and its test updated.