Skip to content

state: Process the top-level message in a dedicated function - #1736

Merged
chfast merged 1 commit into
masterfrom
state/top-level-new-account
Sep 24, 2026
Merged

chfast merged 1 commit into
masterfrom
state/top-level-new-account

Conversation

@chfast

@chfast chfast commented Sep 23, 2026

Copy link
Copy Markdown
Member

Move the processing of the transaction's top-level message out of transition() into process_top_level(). It applies the EIP-7702 authorizations (their refund now travels in the call result's gas refund), resolves the recipient's delegation, charges the NEW_ACCOUNT state-gas of a recipient the call creates, and makes the call, refilling that state-gas if the call fails.

The NEW_ACCOUNT charge is a pre-execution charge (EIP-8037), so it moves here from Host::call(), which no longer handles the transaction's state-gas. This prepares EIP-2780 (#1733): its additional pre-execution charges must revert the applied authorizations when they run out of gas, which Host::call() cannot do.

No behavior change.

🤖 Generated with Claude Code

@codspeed

codspeed Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will regress 2 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

⚡ 41 improved benchmarks
❌ 2 regressed benchmarks
✅ 856 untouched benchmarks

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
❌ baseline/analyse/main/sha1_shifts 11.2 µs 11.5 µs -2.64%
❌ test_calldatasize[fork_Osaka-blockchain_test-zero_data_False-calldata_size_1024-benchmark-gas-value_1M] 17.2 ms 17.4 ms -1.38%
⚡ test_ext_account_query_warm[fork_Osaka-blockchain_test-initial_storage_False-initial_balance_True-empty_code_True-opcode_DELEGATECALL-benchmark-gas-value_1M] 13.6 ms 13.1 ms +3.39%
⚡ test_ext_account_query_warm[fork_Osaka-blockchain_test-initial_storage_True-initial_balance_False-empty_code_True-opcode_DELEGATECALL-benchmark-gas-value_1M] 13.5 ms 13.1 ms +3.35%
⚡ test_ext_account_query_warm[fork_Osaka-blockchain_test-initial_storage_False-initial_balance_False-empty_code_True-opcode_DELEGATECALL-benchmark-gas-value_1M] 13.5 ms 13.1 ms +3.29%
⚡ test_ext_account_query_warm[fork_Osaka-blockchain_test-initial_storage_True-initial_balance_True-empty_code_True-opcode_DELEGATECALL-benchmark-gas-value_1M] 13.5 ms 13.1 ms +3.27%
⚡ test_ext_account_query_warm[fork_Osaka-blockchain_test-initial_storage_False-initial_balance_True-empty_code_True-opcode_CALLCODE-benchmark-gas-value_1M] 14 ms 13.6 ms +3.18%
⚡ test_ext_account_query_warm[fork_Osaka-blockchain_test-initial_storage_True-initial_balance_True-empty_code_True-opcode_CALLCODE-benchmark-gas-value_1M] 14.1 ms 13.6 ms +3.13%
⚡ test_ext_account_query_warm[fork_Osaka-blockchain_test-initial_storage_True-initial_balance_False-empty_code_True-opcode_CALLCODE-benchmark-gas-value_1M] 14 ms 13.6 ms +3.11%
⚡ test_ext_account_query_warm[fork_Osaka-blockchain_test-initial_storage_False-initial_balance_False-empty_code_True-opcode_CALLCODE-benchmark-gas-value_1M] 14 ms 13.6 ms +3.09%
⚡ test_ext_account_query_warm[fork_Osaka-blockchain_test-initial_storage_True-initial_balance_False-empty_code_True-opcode_STATICCALL-benchmark-gas-value_1M] 16.3 ms 15.9 ms +2.73%
⚡ test_ext_account_query_warm[fork_Osaka-blockchain_test-initial_storage_False-initial_balance_False-empty_code_True-opcode_STATICCALL-benchmark-gas-value_1M] 16.3 ms 15.8 ms +2.72%
⚡ test_ext_account_query_warm[fork_Osaka-blockchain_test-initial_storage_True-initial_balance_True-empty_code_True-opcode_STATICCALL-benchmark-gas-value_1M] 16.3 ms 15.9 ms +2.68%
⚡ test_ext_account_query_warm[fork_Osaka-blockchain_test-initial_storage_False-initial_balance_True-empty_code_True-opcode_STATICCALL-benchmark-gas-value_1M] 16.4 ms 15.9 ms +2.68%
⚡ test_identity_fixed_size[fork_Osaka-blockchain_test-size_0-benchmark-gas-value_1M] 16.4 ms 16 ms +2.61%
⚡ test_ext_account_query_warm[fork_Osaka-blockchain_test-initial_storage_True-initial_balance_False-empty_code_True-opcode_CALL-benchmark-gas-value_1M] 16.8 ms 16.4 ms +2.6%
⚡ test_ext_account_query_warm[fork_Osaka-blockchain_test-initial_storage_False-initial_balance_False-empty_code_True-opcode_CALL-benchmark-gas-value_1M] 16.7 ms 16.3 ms +2.58%
⚡ test_ext_account_query_warm[fork_Osaka-blockchain_test-initial_storage_False-initial_balance_True-empty_code_True-opcode_CALL-benchmark-gas-value_1M] 16.8 ms 16.4 ms +2.57%
⚡ test_ext_account_query_warm[fork_Osaka-blockchain_test-initial_storage_True-initial_balance_True-empty_code_True-opcode_CALL-benchmark-gas-value_1M] 16.8 ms 16.4 ms +2.52%
⚡ test_identity_fixed_size[fork_Osaka-blockchain_test-size_32-benchmark-gas-value_1M] 16.6 ms 16.2 ms +2.52%
... ... ... ... ...

ℹ️ Only the first 20 benchmarks are displayed. Go to the app to view all benchmarks.

Tip

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


Comparing state/top-level-new-account (d89c800) with master (1671d6d)

Open in CodSpeed

@codecov

codecov Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.98%. Comparing base (1671d6d) to head (d89c800).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1736   +/-   ##
=======================================
  Coverage   97.98%   97.98%           
=======================================
  Files         183      183           
  Lines       16851    16856    +5     
  Branches     3856     3856           
=======================================
+ Hits        16511    16516    +5     
  Misses        250      250           
  Partials       90       90           
Flag Coverage Δ
eest-develop 81.77% <90.00%> (+0.04%) ⬆️
eest-develop-gmp 25.88% <90.00%> (+0.03%) ⬆️
eest-legacy 17.11% <76.66%> (+0.03%) ⬆️
eest-libsecp256k1 28.08% <90.00%> (+0.03%) ⬆️
eest-stable 81.77% <90.00%> (+0.04%) ⬆️
evmone-unittests 94.41% <100.00%> (+<0.01%) ⬆️

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

Components Coverage Δ
core 95.95% <100.00%> (+<0.01%) ⬆️
tooling 94.29% <ø> (ø)
tests 99.81% <ø> (ø)
Files with missing lines Coverage Δ
test/state/host.cpp 99.13% <100.00%> (-0.05%) ⬇️
test/state/host.hpp 100.00% <ø> (ø)
test/state/state.cpp 98.66% <100.00%> (+0.06%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The refactor preserves behavior, with no unresolved issues identified.

Review effort: Balanced
Findings: None

What changed in this PR

Refactors top-level transaction processing into process_top_level() without changing behavior.

Changes:

  • Centralizes authorization, delegation, state-gas charging, and execution.
  • Removes top-level state-gas handling from Host::call().
  • Exposes Host::account_exists() for preparation checks.
File Description
test/​state/​state.cpp Adds and integrates top-level message processing.
test/​state/​host.hpp Makes account_exists() publicly accessible.
test/​state/​host.cpp Removes top-level state-gas handling from Host::call().

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@chfast
chfast force-pushed the state/top-level-new-account branch 4 times, most recently from b7ce811 to 6d664f8 Compare September 24, 2026 10:52
@chfast
chfast requested a balanced review from Copilot September 24, 2026 10:56

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

The critical duplicate delegation refund must be corrected before approval.

Get a fresh assessment by requesting another Copilot review.

Review effort: Balanced
Findings: 1 High severity

Open (1)

Comment thread test/state/state.cpp Outdated
The NEW_ACCOUNT state-gas of the account a transaction creates is a
pre-execution charge (EIP-8037). EIP-2780 adds more such charges: the
ones of the EIP-7702 authorizations and the delegation target access.
Running out of gas for any of them must revert the applied
authorizations, which Host::call() cannot do. Move this charge and its
refill from Host::call() to the new process_top_level(), which also
applies the authorizations and resolves the recipient's delegation.
Their refund is carried in the call result. No behavior change.
@chfast
chfast force-pushed the state/top-level-new-account branch from 42324ca to d89c800 Compare September 24, 2026 11:17
@chfast
chfast merged commit d9e925a into master Sep 24, 2026
26 of 28 checks passed
@chfast
chfast deleted the state/top-level-new-account branch September 24, 2026 11:32
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.

2 participants