Skip to content

evmone: Require exact size of EIP-7702 delegation designator - #1822

Open
chfast wants to merge 1 commit into
masterfrom
delegation-exact-size
Open

chfast wants to merge 1 commit into
masterfrom
delegation-exact-size

Conversation

@chfast

@chfast chfast commented Nov 18, 2026

Copy link
Copy Markdown
Member

Only code consisting of exactly 0xef0100 || address (23 bytes) is an EIP-7702 delegation designator. evmone treated any code starting with 0xef0100 as delegated, because get_delegate_address() loaded only the first 23 bytes of the code and is_code_delegated() checked only the prefix. Longer code with this prefix was then executed as the delegate's code instead of failing on the 0xef instruction. 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, and is_code_delegated() checks the exact size. This keeps a single copy_code() per call target, unlike checking get_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.

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.
@codspeed

codspeed Bot commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will degrade performance by 1.53%

❌ 2 regressed benchmarks
✅ 897 untouched benchmarks

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
❌ baseline/analyse/main/structarray_alloc 5.3 µs 5.4 µs -2.05%
❌ baseline/analyse/main/sha1_shifts 10.9 µs 11 µs -1.01%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing delegation-exact-size (ccc24c8) with master (0a50c91)

Open in CodSpeed

@codecov

codecov Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.23%. Comparing base (6fb712f) to head (ccc24c8).
⚠️ Report is 3 commits behind head on master.

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           
Flag Coverage Δ
eest-develop-gmp 26.72% <12.50%> (-0.03%) ⬇️
eest-legacy 17.19% <4.16%> (-0.02%) ⬇️
eest-libsecp256k1 28.69% <12.50%> (-0.03%) ⬇️
eest-stable 83.78% <100.00%> (+0.03%) ⬆️
evmone-unittests 93.94% <100.00%> (+<0.01%) ⬆️
riscv64 94.81% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
core 96.60% <100.00%> (-0.01%) ⬇️
tooling 94.88% <ø> (+0.01%) ⬆️
tests 99.80% <100.00%> (+<0.01%) ⬆️
Files with missing lines Coverage Δ
lib/evmone/delegation.cpp 100.00% <100.00%> (ø)
lib/evmone/delegation.hpp 100.00% <100.00%> (ø)
test/state/state.cpp 99.78% <100.00%> (ø)
test/unittests/evm_calls_test.cpp 99.81% <100.00%> (+<0.01%) ⬆️
test/unittests/statetest_loader_test.cpp 100.00% <100.00%> (ø)
test/utils/statetest_loader.cpp 92.50% <ø> (-0.11%) ⬇️

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant