Skip to content

evm: Require the exact size for the EIP-7702 delegation designator - #1713

Open
zexoverz wants to merge 2 commits into
ipsilon:masterfrom
zexoverz:1494-delegation-length
Open

zexoverz wants to merge 2 commits into
ipsilon:masterfrom
zexoverz:1494-delegation-length

Conversation

@zexoverz

Copy link
Copy Markdown
Contributor

is_code_delegated() only checked for the 0xef0100 prefix, and get_delegate_address() copied a 23 byte window, so code longer than the designator was treated as a delegation and code shorter than it produced a partial delegate address. Both now require exactly 23 bytes, and the address lookup reads one byte past the designator so a longer code is caught without a separate code size call. The state test loader keeps its "invalid size" message by checking the magic on its own.

New evm fixture tests cover the 3, 22, 23 and 24 byte cases on the CALL path. They live in their own file because the state_transition fixture validates the prestate and rejects those codes up front, which is the right behaviour for fixtures.

Fixes #1494

@zexoverz
zexoverz force-pushed the 1494-delegation-length branch from 4c88235 to 01b5950 Compare September 21, 2026 07:11
@codspeed

codspeed Bot commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will regress 4 benchmarks

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 13 improved benchmarks
❌ 4 regressed benchmarks
✅ 882 untouched benchmarks

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
❌ test_push[fork_Osaka-blockchain_test-opcode_PUSH12-benchmark-gas-value_1M] 28.9 ms 32.2 ms -10.32%
❌ test_push[fork_Osaka-blockchain_test-opcode_PUSH9-benchmark-gas-value_1M] 24.4 ms 27 ms -9.74%
❌ test_block_context_ops[fork_Osaka-blockchain_test-opcode_COINBASE-benchmark-gas-value_1M] 23.4 ms 23.7 ms -1.46%
❌ test_block_context_ops[fork_Osaka-blockchain_test-opcode_TIMESTAMP-benchmark-gas-value_1M] 18.1 ms 18.3 ms -1.31%
⚡ test_push[fork_Osaka-blockchain_test-opcode_PUSH4-benchmark-gas-value_1M] 12.3 ms 10.8 ms +13.67%
⚡ test_gas_op[fork_Osaka-blockchain_test-benchmark-gas-value_1M] 12.8 ms 12.3 ms +4.11%
⚡ baseline/analyse/main/sha1_divs 12.7 µs 12.3 µs +3.25%
⚡ test_dup[fork_Osaka-blockchain_test-opcode_DUP16-benchmark-gas-value_1M] 9.9 ms 9.7 ms +1.91%
⚡ test_dup[fork_Osaka-blockchain_test-opcode_DUP9-benchmark-gas-value_1M] 9.9 ms 9.7 ms +1.82%
⚡ test_dup[fork_Osaka-blockchain_test-opcode_DUP3-benchmark-gas-value_1M] 9.9 ms 9.7 ms +1.71%
⚡ test_dup[fork_Osaka-blockchain_test-opcode_DUP15-benchmark-gas-value_1M] 9.9 ms 9.7 ms +1.63%
⚡ test_dup[fork_Osaka-blockchain_test-opcode_DUP13-benchmark-gas-value_1M] 9.9 ms 9.7 ms +1.61%
⚡ test_msize[fork_Osaka-blockchain_test-mem_size_0-benchmark-gas-value_1M] 13.8 ms 13.6 ms +1.47%
⚡ test_dup[fork_Osaka-blockchain_test-opcode_DUP5-benchmark-gas-value_1M] 9.8 ms 9.7 ms +1.27%
⚡ test_dup[fork_Osaka-blockchain_test-opcode_DUP2-benchmark-gas-value_1M] 9.9 ms 9.8 ms +1.05%
⚡ test_pc_op[fork_Osaka-blockchain_test-benchmark-gas-value_1M] 14.4 ms 14.2 ms +1.03%
⚡ test_block_context_ops[fork_Osaka-blockchain_test-opcode_NUMBER-benchmark-gas-value_1M] 18.3 ms 18.1 ms +1.02%

Tip

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


Comparing zexoverz:1494-delegation-length (bf88b7c) with master (e675712)

Open in CodSpeed

The designator is 0xef0100 followed by the delegate address, 23 bytes.
is_code_delegated() only checked the prefix, and get_delegate_address()
copied a 23-byte window so longer code looked like a delegation and
shorter code yielded a partial address. Check the size in both, reading
one byte past the designator so a longer code is detected without an
extra host call. The state test loader keeps its size diagnostic by
checking the magic separately.

Fixes ipsilon#1494
@zexoverz
zexoverz force-pushed the 1494-delegation-length branch from 01b5950 to bf88b7c Compare October 20, 2026 16:08
@zexoverz

Copy link
Copy Markdown
Contributor Author

Rebased this and #1715, #1738, #1739 on master. The clang-latest-sanitizers, clang-tidy and fuzzing jobs never start for fork PRs, so they'd need a rerun from your side.

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.

Core EIP-7702 delegation parser accepts non-23-byte designators

1 participant