Skip to content

feat(l1): implement debug_intermediateRoots endpoint#6703

Draft
azteca1998 wants to merge 4 commits into
mainfrom
feat/debug-intermediate-roots
Draft

feat(l1): implement debug_intermediateRoots endpoint#6703
azteca1998 wants to merge 4 commits into
mainfrom
feat/debug-intermediate-roots

Conversation

@azteca1998
Copy link
Copy Markdown
Contributor

Summary

  • Implement debug_intermediateRoots RPC endpoint that returns the intermediate state root after each transaction in a block
  • Adds GeneralizedDatabase::peek_state_transitions() — a non-destructive read of cumulative state transitions
  • Adds Evm::execute_tx_by_index() for single-transaction execution without tracing
  • Adds Blockchain::compute_intermediate_roots() with timeout support
  • For each tx: re-executes the block progressively, computes cumulative account updates, then applies them to a fresh state trie from the parent root

Closes part of #6572

Compute the intermediate state root after each transaction in a block.
Uses a non-destructive peek at cumulative state transitions to build
AccountUpdates, then applies them to a fresh trie opened from the
parent state root for each transaction.

Changes across layers:
- levm: add GeneralizedDatabase::peek_state_transitions (read-only)
- vm: add Evm::execute_tx_by_index for single-tx execution
- blockchain: add Blockchain::compute_intermediate_roots with timeout
- rpc: add IntermediateRootsRequest handler
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 21, 2026

⚠️ Known Issues — intentionally skipped tests

Source: docs/known_issues.md

Known Issues

Tests intentionally excluded from CI. Source of truth for the Known
Issues
section the L1 workflow appends to each ef-tests job summary
and posts as a sticky PR comment.

EF Tests — Stateless coverage narrowed to EIP-8025 optional-proofs

make -C tooling/ef_tests/blockchain test calls test-stateless-zkevm
instead of test-stateless. The zkevm@v0.3.3 fixtures are filled against
bal@v5.6.1, out of sync with current bal spec; the broad target trips ~549
fixtures. Re-broaden once the zkevm bundle is regenerated.

Why and resolution path

PR #6527 broadened
test-stateless to extract the entire for_amsterdam/ tree from the
zkevm bundle and run all of it under --features stateless; combined with
this branch's bal-devnet-7 semantics that scope produces ~549
GasUsedMismatch / ReceiptsRootMismatch /
BlockAccessListHashMismatch failures.

test-stateless-zkevm filters cargo to the eip8025_optional_proofs
suite, which still validates the stateless harness without the bal-version
mismatch.

Re-broaden by switching test: back to test-stateless in
tooling/ef_tests/blockchain/Makefile once the zkevm bundle is regenerated
against the current bal spec.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 21, 2026

Lines of code report

Total lines added: 226
Total lines removed: 0
Total lines changed: 226

Detailed view
+----------------------------------------------------------+-------+------+
| File                                                     | Lines | Diff |
+----------------------------------------------------------+-------+------+
| ethrex/crates/blockchain/tracing.rs                      | 279   | +38  |
+----------------------------------------------------------+-------+------+
| ethrex/crates/networking/rpc/debug/intermediate_roots.rs | 95    | +95  |
+----------------------------------------------------------+-------+------+
| ethrex/crates/networking/rpc/debug/mod.rs                | 5     | +1   |
+----------------------------------------------------------+-------+------+
| ethrex/crates/networking/rpc/rpc.rs                      | 1303  | +2   |
+----------------------------------------------------------+-------+------+
| ethrex/crates/vm/levm/src/db/gen_db.rs                   | 630   | +69  |
+----------------------------------------------------------+-------+------+
| ethrex/crates/vm/tracing.rs                              | 111   | +21  |
+----------------------------------------------------------+-------+------+

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 21, 2026

Benchmark Results Comparison

No significant difference was registered for any benchmark run.

Detailed Results

Benchmark Results: BubbleSort

Command Mean [s] Min [s] Max [s] Relative
main_revm_BubbleSort 2.935 ± 0.019 2.915 2.966 1.05 ± 0.01
main_levm_BubbleSort 2.802 ± 0.014 2.780 2.825 1.00 ± 0.01
pr_revm_BubbleSort 2.962 ± 0.031 2.908 3.028 1.06 ± 0.01
pr_levm_BubbleSort 2.801 ± 0.022 2.777 2.850 1.00

Benchmark Results: ERC20Approval

Command Mean [ms] Min [ms] Max [ms] Relative
main_revm_ERC20Approval 984.2 ± 7.5 972.8 996.2 1.01 ± 0.01
main_levm_ERC20Approval 1059.2 ± 10.3 1048.2 1083.9 1.09 ± 0.01
pr_revm_ERC20Approval 973.1 ± 9.4 962.9 996.2 1.00
pr_levm_ERC20Approval 1059.6 ± 18.3 1044.2 1099.1 1.09 ± 0.02

Benchmark Results: ERC20Mint

Command Mean [ms] Min [ms] Max [ms] Relative
main_revm_ERC20Mint 132.4 ± 1.3 130.3 135.0 1.00
main_levm_ERC20Mint 162.6 ± 2.0 160.7 166.2 1.23 ± 0.02
pr_revm_ERC20Mint 133.4 ± 1.0 132.0 134.9 1.01 ± 0.01
pr_levm_ERC20Mint 159.9 ± 2.3 158.7 166.4 1.21 ± 0.02

Benchmark Results: ERC20Transfer

Command Mean [ms] Min [ms] Max [ms] Relative
main_revm_ERC20Transfer 232.1 ± 2.5 229.3 236.9 1.00
main_levm_ERC20Transfer 266.3 ± 2.1 263.9 270.1 1.15 ± 0.02
pr_revm_ERC20Transfer 233.0 ± 4.2 228.9 243.7 1.00 ± 0.02
pr_levm_ERC20Transfer 265.4 ± 3.7 261.8 274.3 1.14 ± 0.02

Benchmark Results: Factorial

Command Mean [ms] Min [ms] Max [ms] Relative
main_revm_Factorial 222.9 ± 1.0 221.9 224.9 1.00
main_levm_Factorial 270.5 ± 1.4 267.1 272.2 1.21 ± 0.01
pr_revm_Factorial 228.2 ± 12.2 223.0 262.5 1.02 ± 0.05
pr_levm_Factorial 272.1 ± 2.2 270.1 277.4 1.22 ± 0.01

Benchmark Results: FactorialRecursive

Command Mean [s] Min [s] Max [s] Relative
main_revm_FactorialRecursive 1.680 ± 0.044 1.586 1.731 1.06 ± 0.03
main_levm_FactorialRecursive 1.588 ± 0.016 1.570 1.612 1.00 ± 0.01
pr_revm_FactorialRecursive 1.683 ± 0.046 1.590 1.734 1.06 ± 0.03
pr_levm_FactorialRecursive 1.583 ± 0.009 1.572 1.602 1.00

Benchmark Results: Fibonacci

Command Mean [ms] Min [ms] Max [ms] Relative
main_revm_Fibonacci 200.4 ± 1.0 198.0 201.7 1.00
main_levm_Fibonacci 253.0 ± 2.3 249.5 258.4 1.26 ± 0.01
pr_revm_Fibonacci 202.6 ± 0.4 201.9 203.4 1.01 ± 0.01
pr_levm_Fibonacci 254.7 ± 4.5 250.7 262.3 1.27 ± 0.02

Benchmark Results: FibonacciRecursive

Command Mean [ms] Min [ms] Max [ms] Relative
main_revm_FibonacciRecursive 899.8 ± 7.4 884.4 909.0 1.25 ± 0.01
main_levm_FibonacciRecursive 720.6 ± 4.3 715.1 727.4 1.00
pr_revm_FibonacciRecursive 903.9 ± 9.2 883.9 916.6 1.25 ± 0.01
pr_levm_FibonacciRecursive 724.9 ± 5.4 717.8 737.2 1.01 ± 0.01

Benchmark Results: ManyHashes

Command Mean [ms] Min [ms] Max [ms] Relative
main_revm_ManyHashes 8.4 ± 0.2 8.2 8.8 1.01 ± 0.02
main_levm_ManyHashes 9.8 ± 0.1 9.7 9.9 1.18 ± 0.01
pr_revm_ManyHashes 8.3 ± 0.1 8.2 8.4 1.00
pr_levm_ManyHashes 9.9 ± 0.1 9.7 10.0 1.19 ± 0.01

Benchmark Results: MstoreBench

Command Mean [ms] Min [ms] Max [ms] Relative
main_revm_MstoreBench 256.5 ± 6.5 251.6 269.7 1.09 ± 0.03
main_levm_MstoreBench 234.5 ± 1.4 232.4 236.5 1.00
pr_revm_MstoreBench 260.1 ± 3.0 256.4 265.3 1.11 ± 0.01
pr_levm_MstoreBench 237.0 ± 3.4 233.5 244.6 1.01 ± 0.02

Benchmark Results: Push

Command Mean [ms] Min [ms] Max [ms] Relative
main_revm_Push 285.8 ± 1.1 284.3 288.0 1.00
main_levm_Push 288.8 ± 2.3 286.2 293.4 1.01 ± 0.01
pr_revm_Push 286.7 ± 1.4 285.2 288.6 1.00 ± 0.01
pr_levm_Push 288.4 ± 1.3 286.7 290.4 1.01 ± 0.01

Benchmark Results: SstoreBench_no_opt

Command Mean [ms] Min [ms] Max [ms] Relative
main_revm_SstoreBench_no_opt 166.7 ± 6.4 161.3 181.7 1.64 ± 0.06
main_levm_SstoreBench_no_opt 101.6 ± 0.6 101.0 102.6 1.00
pr_revm_SstoreBench_no_opt 165.2 ± 2.7 160.7 168.7 1.63 ± 0.03
pr_levm_SstoreBench_no_opt 102.6 ± 3.7 99.8 110.9 1.01 ± 0.04

Execute a block with one transfer, then query intermediateRoots.
Assert the response contains one state root per transaction.
@azteca1998 azteca1998 changed the title feat(rpc): implement debug_intermediateRoots endpoint feat(l1): implement debug_intermediateRoots endpoint May 21, 2026
@github-actions github-actions Bot added the L1 Ethereum client label May 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

L1 Ethereum client

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

1 participant