Skip to content

Conversation

@iovoid
Copy link
Contributor

@iovoid iovoid commented Oct 31, 2025

Motivation

Currently to get a storage we are:

  • getting the block header to obtain the state root
  • getting the account to get the storage root
  • reading the value

The first step isn't needed because the state root is the same through the block, and the second isn't needed because since we're using a path-based DB we can directly get the value (without even using the trie, if the FKVs are computed).

Description

We make the VM database ask by state_root instead of block hash (skipping step 1), and we skip reading the account storage root when the FlatKeyValues are computed for it.

@github-actions github-actions bot added L1 Ethereum client performance Block execution throughput and performance in general labels Oct 31, 2025
@github-actions
Copy link

github-actions bot commented Oct 31, 2025

Lines of code report

Total lines added: 112
Total lines removed: 26
Total lines changed: 138

Detailed view
+---------------------------------------------------------------+-------+------+
| File                                                          | Lines | Diff |
+---------------------------------------------------------------+-------+------+
| ethrex/crates/blockchain/blockchain.rs                        | 1305  | +10  |
+---------------------------------------------------------------+-------+------+
| ethrex/crates/blockchain/payload.rs                           | 676   | +4   |
+---------------------------------------------------------------+-------+------+
| ethrex/crates/blockchain/tracing.rs                           | 130   | +4   |
+---------------------------------------------------------------+-------+------+
| ethrex/crates/blockchain/vm.rs                                | 104   | +3   |
+---------------------------------------------------------------+-------+------+
| ethrex/crates/l2/based/block_fetcher.rs                       | 508   | +9   |
+---------------------------------------------------------------+-------+------+
| ethrex/crates/l2/sequencer/l1_committer.rs                    | 1064  | +5   |
+---------------------------------------------------------------+-------+------+
| ethrex/crates/networking/rpc/eth/account.rs                   | 261   | -1   |
+---------------------------------------------------------------+-------+------+
| ethrex/crates/storage/api.rs                                  | 246   | +3   |
+---------------------------------------------------------------+-------+------+
| ethrex/crates/storage/store.rs                                | 1521  | +8   |
+---------------------------------------------------------------+-------+------+
| ethrex/crates/storage/store_db/rocksdb.rs                     | 1594  | +54  |
+---------------------------------------------------------------+-------+------+
| ethrex/crates/storage/trie_db/rocksdb.rs                      | 194   | -13  |
+---------------------------------------------------------------+-------+------+
| ethrex/crates/storage/trie_db/rocksdb_locked.rs               | 75    | -10  |
+---------------------------------------------------------------+-------+------+
| ethrex/crates/vm/levm/bench/revm_comparison/src/levm_bench.rs | 88    | +4   |
+---------------------------------------------------------------+-------+------+
| ethrex/crates/vm/levm/runner/src/main.rs                      | 277   | +5   |
+---------------------------------------------------------------+-------+------+
| ethrex/tooling/ef_tests/blockchain/test_runner.rs             | 337   | -1   |
+---------------------------------------------------------------+-------+------+
| ethrex/tooling/ef_tests/state/utils.rs                        | 60    | -1   |
+---------------------------------------------------------------+-------+------+
| ethrex/tooling/ef_tests/state_v2/src/modules/utils.rs         | 47    | +3   |
+---------------------------------------------------------------+-------+------+

@github-actions
Copy link

github-actions bot commented Oct 31, 2025

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 4.742 ± 0.014 4.718 4.759 1.04 ± 0.00
main_levm_BubbleSort 4.560 ± 0.015 4.535 4.580 1.00
pr_revm_BubbleSort 4.724 ± 0.011 4.714 4.741 1.04 ± 0.00
pr_levm_BubbleSort 4.652 ± 0.288 4.541 5.469 1.02 ± 0.06

Benchmark Results: ERC20Approval

Command Mean [s] Min [s] Max [s] Relative
main_revm_ERC20Approval 1.565 ± 0.021 1.549 1.616 1.00 ± 0.01
main_levm_ERC20Approval 1.663 ± 0.011 1.653 1.682 1.07 ± 0.01
pr_revm_ERC20Approval 1.559 ± 0.008 1.552 1.578 1.00
pr_levm_ERC20Approval 1.663 ± 0.005 1.655 1.670 1.07 ± 0.01

Benchmark Results: ERC20Mint

Command Mean [ms] Min [ms] Max [ms] Relative
main_revm_ERC20Mint 185.9 ± 0.5 185.3 186.6 1.00
main_levm_ERC20Mint 205.7 ± 1.2 203.1 207.1 1.11 ± 0.01
pr_revm_ERC20Mint 186.4 ± 0.4 185.7 187.0 1.00 ± 0.00
pr_levm_ERC20Mint 205.7 ± 1.9 203.2 208.3 1.11 ± 0.01

Benchmark Results: ERC20Transfer

Command Mean [ms] Min [ms] Max [ms] Relative
main_revm_ERC20Transfer 352.4 ± 2.4 350.5 359.0 1.00
main_levm_ERC20Transfer 393.8 ± 3.3 389.2 400.4 1.12 ± 0.01
pr_revm_ERC20Transfer 353.0 ± 1.2 351.8 355.5 1.00 ± 0.01
pr_levm_ERC20Transfer 394.7 ± 1.3 393.0 397.6 1.12 ± 0.01

Benchmark Results: Factorial

Command Mean [ms] Min [ms] Max [ms] Relative
main_revm_Factorial 234.0 ± 2.2 232.3 238.8 1.00
main_levm_Factorial 275.6 ± 1.6 273.9 279.4 1.18 ± 0.01
pr_revm_Factorial 234.5 ± 1.7 232.8 237.8 1.00 ± 0.01
pr_levm_Factorial 276.4 ± 0.9 275.5 277.5 1.18 ± 0.01

Benchmark Results: FactorialRecursive

Command Mean [s] Min [s] Max [s] Relative
main_revm_FactorialRecursive 1.668 ± 0.051 1.529 1.705 1.00
main_levm_FactorialRecursive 8.582 ± 0.044 8.513 8.643 5.14 ± 0.16
pr_revm_FactorialRecursive 1.679 ± 0.039 1.598 1.731 1.01 ± 0.04
pr_levm_FactorialRecursive 8.566 ± 0.041 8.492 8.636 5.13 ± 0.16

Benchmark Results: Fibonacci

Command Mean [ms] Min [ms] Max [ms] Relative
main_revm_Fibonacci 206.9 ± 1.0 205.8 208.7 1.00 ± 0.01
main_levm_Fibonacci 258.0 ± 7.5 252.1 274.1 1.25 ± 0.04
pr_revm_Fibonacci 206.6 ± 0.5 205.6 207.2 1.00
pr_levm_Fibonacci 258.9 ± 3.6 252.0 263.2 1.25 ± 0.02

Benchmark Results: FibonacciRecursive

Command Mean [ms] Min [ms] Max [ms] Relative
main_revm_FibonacciRecursive 880.4 ± 7.2 871.4 891.6 1.14 ± 0.01
main_levm_FibonacciRecursive 775.1 ± 6.7 766.9 789.6 1.00
pr_revm_FibonacciRecursive 879.1 ± 9.2 871.1 903.4 1.13 ± 0.02
pr_levm_FibonacciRecursive 780.4 ± 6.9 769.9 791.7 1.01 ± 0.01

Benchmark Results: ManyHashes

Command Mean [ms] Min [ms] Max [ms] Relative
main_revm_ManyHashes 12.5 ± 0.1 12.4 12.6 1.00
main_levm_ManyHashes 13.7 ± 0.1 13.6 13.9 1.09 ± 0.01
pr_revm_ManyHashes 12.5 ± 0.1 12.5 12.7 1.00 ± 0.01
pr_levm_ManyHashes 13.7 ± 0.1 13.6 13.7 1.09 ± 0.01

Benchmark Results: MstoreBench

Command Mean [ms] Min [ms] Max [ms] Relative
main_revm_MstoreBench 268.8 ± 3.7 264.7 274.0 1.06 ± 0.02
main_levm_MstoreBench 254.4 ± 3.4 251.3 261.7 1.00
pr_revm_MstoreBench 273.1 ± 10.4 263.9 295.8 1.07 ± 0.04
pr_levm_MstoreBench 255.8 ± 5.4 251.1 270.4 1.01 ± 0.03

Benchmark Results: Push

Command Mean [ms] Min [ms] Max [ms] Relative
main_revm_Push 295.8 ± 2.7 292.1 301.3 1.00
main_levm_Push 305.0 ± 2.4 303.3 311.1 1.03 ± 0.01
pr_revm_Push 319.4 ± 80.5 293.1 548.6 1.08 ± 0.27
pr_levm_Push 307.7 ± 3.8 305.4 318.4 1.04 ± 0.02

Benchmark Results: SstoreBench_no_opt

Command Mean [ms] Min [ms] Max [ms] Relative
main_revm_SstoreBench_no_opt 220.2 ± 1.8 218.4 223.0 2.64 ± 0.05
main_levm_SstoreBench_no_opt 85.9 ± 3.4 83.2 94.9 1.03 ± 0.05
pr_revm_SstoreBench_no_opt 218.8 ± 0.5 218.2 219.7 2.62 ± 0.05
pr_levm_SstoreBench_no_opt 83.5 ± 1.6 81.0 85.6 1.00

@iovoid iovoid marked this pull request as ready for review October 31, 2025 21:08
@iovoid iovoid requested a review from a team as a code owner October 31, 2025 21:08
@ethrex-project-sync ethrex-project-sync bot moved this to In Review in ethrex_l1 Oct 31, 2025
@github-actions
Copy link

github-actions bot commented Oct 31, 2025

Benchmark Block Execution Results Comparison Against Main

Command Mean [s] Min [s] Max [s] Relative
base 135.477 ± 0.223 135.056 135.755 1.00 ± 0.00
head 135.414 ± 0.223 134.929 135.786 1.00

@jrchatruc jrchatruc enabled auto-merge November 3, 2025 17:53
@jrchatruc jrchatruc added this pull request to the merge queue Nov 3, 2025
Merged via the queue into main with commit 1130d27 Nov 3, 2025
54 checks passed
@jrchatruc jrchatruc deleted the avoid_opening_trie branch November 3, 2025 18:52
@github-project-automation github-project-automation bot moved this from Todo to Done in ethrex_performance Nov 3, 2025
@github-project-automation github-project-automation bot moved this from In Review to Done in ethrex_l1 Nov 3, 2025
xqft pushed a commit that referenced this pull request Nov 11, 2025
**Motivation**

Currently to get a storage we are:

* getting the block header to obtain the state root
* getting the account to get the storage root
* reading the value

The first step isn't needed because the state root is the same through
the block, and the second isn't needed because since we're using a
path-based DB we can directly get the value (without even using the
trie, if the FKVs are computed).

**Description**

We make the VM database ask by state_root instead of block hash
(skipping step 1), and we skip reading the account storage root when the
FlatKeyValues are computed for it.

---------

Co-authored-by: Ivan Litteri <[email protected]>
Co-authored-by: Javier Chatruc <[email protected]>
Co-authored-by: Javier Rodríguez Chatruc <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

L1 Ethereum client performance Block execution throughput and performance in general

Projects

Status: Done
Archived in project

Development

Successfully merging this pull request may close these issues.

6 participants