Skip to content

Conversation

@azteca1998
Copy link
Contributor

Motivation

Our implementation of BLOBBASEFEE is slow when compared to any other client.

Description

The BLOBBASEFEE value should not change between runs with the same block header and environment, therefore it can be cached and reused.

@github-actions github-actions bot added levm Lambda EVM implementation performance Block execution throughput and performance in general labels Nov 12, 2025
@azteca1998 azteca1998 marked this pull request as ready for review November 12, 2025 12:40
@azteca1998 azteca1998 requested a review from a team as a code owner November 12, 2025 12:40
@github-actions
Copy link

Lines of code report

Total lines added: 9
Total lines removed: 0
Total lines changed: 9

Detailed view
+----------------------------------------------------+-------+------+
| File                                               | Lines | Diff |
+----------------------------------------------------+-------+------+
| ethrex/crates/vm/levm/src/opcode_handlers/block.rs | 124   | +7   |
+----------------------------------------------------+-------+------+
| ethrex/crates/vm/levm/src/vm.rs                    | 457   | +2   |
+----------------------------------------------------+-------+------+

@github-actions
Copy link

github-actions bot commented Nov 12, 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 2.940 ± 0.010 2.927 2.962 1.00
main_levm_BubbleSort 3.084 ± 0.022 3.056 3.120 1.05 ± 0.01
pr_revm_BubbleSort 3.030 ± 0.015 3.009 3.063 1.03 ± 0.01
pr_levm_BubbleSort 3.153 ± 0.105 3.080 3.381 1.07 ± 0.04

Benchmark Results: ERC20Approval

Command Mean [ms] Min [ms] Max [ms] Relative
main_revm_ERC20Approval 976.6 ± 12.1 966.0 1008.9 1.00
main_levm_ERC20Approval 1087.1 ± 2.9 1082.2 1091.3 1.11 ± 0.01
pr_revm_ERC20Approval 1000.8 ± 15.6 980.4 1035.1 1.02 ± 0.02
pr_levm_ERC20Approval 1105.5 ± 21.3 1082.4 1149.3 1.13 ± 0.03

Benchmark Results: ERC20Mint

Command Mean [ms] Min [ms] Max [ms] Relative
main_revm_ERC20Mint 130.8 ± 2.1 129.0 136.3 1.00
main_levm_ERC20Mint 163.9 ± 1.0 162.5 165.2 1.25 ± 0.02
pr_revm_ERC20Mint 134.9 ± 1.5 133.5 136.8 1.03 ± 0.02
pr_levm_ERC20Mint 164.5 ± 1.9 162.1 167.4 1.26 ± 0.03

Benchmark Results: ERC20Transfer

Command Mean [ms] Min [ms] Max [ms] Relative
main_revm_ERC20Transfer 228.3 ± 1.4 226.0 231.1 1.00
main_levm_ERC20Transfer 278.0 ± 1.5 276.3 281.1 1.22 ± 0.01
pr_revm_ERC20Transfer 236.1 ± 1.7 234.1 240.4 1.03 ± 0.01
pr_levm_ERC20Transfer 280.1 ± 3.2 275.6 285.3 1.23 ± 0.02

Benchmark Results: Factorial

Command Mean [ms] Min [ms] Max [ms] Relative
main_revm_Factorial 227.2 ± 4.3 224.7 239.0 1.01 ± 0.03
main_levm_Factorial 263.5 ± 1.4 261.0 265.4 1.17 ± 0.02
pr_revm_Factorial 226.0 ± 4.4 221.8 237.7 1.00
pr_levm_Factorial 261.6 ± 1.2 260.5 264.6 1.16 ± 0.02

Benchmark Results: FactorialRecursive

Command Mean [s] Min [s] Max [s] Relative
main_revm_FactorialRecursive 1.677 ± 0.022 1.653 1.713 1.00
main_levm_FactorialRecursive 8.379 ± 0.039 8.313 8.429 5.00 ± 0.07
pr_revm_FactorialRecursive 1.692 ± 0.024 1.629 1.710 1.01 ± 0.02
pr_levm_FactorialRecursive 8.504 ± 0.051 8.433 8.579 5.07 ± 0.07

Benchmark Results: Fibonacci

Command Mean [ms] Min [ms] Max [ms] Relative
main_revm_Fibonacci 205.6 ± 0.9 204.1 207.4 1.01 ± 0.01
main_levm_Fibonacci 262.4 ± 3.1 259.6 269.8 1.29 ± 0.02
pr_revm_Fibonacci 204.1 ± 2.5 200.2 210.4 1.00
pr_levm_Fibonacci 260.2 ± 4.8 251.1 266.4 1.27 ± 0.03

Benchmark Results: FibonacciRecursive

Command Mean [ms] Min [ms] Max [ms] Relative
main_revm_FibonacciRecursive 900.2 ± 6.8 888.6 914.9 1.17 ± 0.02
main_levm_FibonacciRecursive 766.9 ± 10.6 755.3 787.4 1.00 ± 0.02
pr_revm_FibonacciRecursive 874.6 ± 12.4 863.3 904.5 1.14 ± 0.02
pr_levm_FibonacciRecursive 766.8 ± 8.4 758.7 784.4 1.00

Benchmark Results: ManyHashes

Command Mean [ms] Min [ms] Max [ms] Relative
main_revm_ManyHashes 8.6 ± 0.1 8.5 8.7 1.02 ± 0.01
main_levm_ManyHashes 9.2 ± 0.1 9.1 9.4 1.10 ± 0.01
pr_revm_ManyHashes 8.4 ± 0.1 8.3 8.5 1.00
pr_levm_ManyHashes 9.4 ± 0.2 9.2 9.8 1.12 ± 0.02

Benchmark Results: MstoreBench

Command Mean [ms] Min [ms] Max [ms] Relative
main_revm_MstoreBench 256.5 ± 3.7 252.3 262.2 1.05 ± 0.02
main_levm_MstoreBench 243.2 ± 1.4 240.6 245.4 1.00
pr_revm_MstoreBench 253.3 ± 3.5 251.0 262.7 1.04 ± 0.02
pr_levm_MstoreBench 244.7 ± 2.9 240.6 250.1 1.01 ± 0.01

Benchmark Results: Push

Command Mean [ms] Min [ms] Max [ms] Relative
main_revm_Push 288.5 ± 1.6 287.0 292.6 1.00 ± 0.01
main_levm_Push 301.8 ± 1.2 300.1 303.5 1.05 ± 0.01
pr_revm_Push 287.8 ± 2.8 285.5 295.5 1.00
pr_levm_Push 301.5 ± 1.4 299.8 304.8 1.05 ± 0.01

Benchmark Results: SstoreBench_no_opt

Command Mean [ms] Min [ms] Max [ms] Relative
main_revm_SstoreBench_no_opt 166.8 ± 5.0 160.4 172.9 1.86 ± 0.06
main_levm_SstoreBench_no_opt 89.6 ± 1.3 88.4 91.8 1.00
pr_revm_SstoreBench_no_opt 166.8 ± 4.6 160.7 172.6 1.86 ± 0.06
pr_levm_SstoreBench_no_opt 91.3 ± 3.2 88.4 97.8 1.02 ± 0.04

@github-actions
Copy link

Benchmark Block Execution Results Comparison Against Main

Command Mean [s] Min [s] Max [s] Relative
base 61.662 ± 0.858 60.131 62.795 1.03 ± 0.01
head 60.061 ± 0.242 59.585 60.376 1.00

Copy link
Collaborator

@Arkenan Arkenan left a comment

Choose a reason for hiding this comment

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

Nice catch. Left one optional comment.


let blob_base_fee =
get_base_fee_per_blob_gas(self.env.block_excess_blob_gas, &self.env.config)?;
let blob_base_fee = match self.blob_base_fee.get() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: is this not a bit clearer if we use OnceCell::get_or_init?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Does not work because it can't handle errors. The get_or_try_init method is nightly-only.

Copy link
Contributor

Choose a reason for hiding this comment

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

Not as much a nit, is needing the blob_base_fee uncommon enough to not just init it with the block, rather than using a OnceCell?
Besides, we already have a &mut self here, so we could just use an option in any case.

Copy link
Contributor

@SDartayet SDartayet left a comment

Choose a reason for hiding this comment

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

LGTM!

@github-project-automation github-project-automation bot moved this to In Review in ethrex_l1 Nov 12, 2025
Copy link
Contributor

@Oppen Oppen left a comment

Choose a reason for hiding this comment

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

Ok in principle, before or after merge I'd like to discuss what I commented on. Can be handled later in a separate PR.

@azteca1998 azteca1998 added this pull request to the merge queue Nov 12, 2025
Merged via the queue into main with commit b31c7a4 Nov 12, 2025
58 checks passed
@azteca1998 azteca1998 deleted the fix-blobbasefee-perf branch November 12, 2025 14:46
@github-project-automation github-project-automation bot moved this from In Review to Done in ethrex_l1 Nov 12, 2025
@github-project-automation github-project-automation bot moved this from Todo to Done in ethrex_performance Nov 12, 2025
github-merge-queue bot pushed a commit that referenced this pull request Nov 14, 2025
**Motivation**

Currently in prepare_execution we are, for each transaction, calculating
the blob base fee which is consistent across the block.

**Description**

This was already cached for `BLOBBASEFEE` in #5288, but it could be
unified across all users by making part of the Environment.

---------

Co-authored-by: Tomás Grüner <[email protected]>
lakshya-sky pushed a commit to lakshya-sky/ethrex that referenced this pull request Nov 17, 2025
…aclass#5328)

**Motivation**

Currently in prepare_execution we are, for each transaction, calculating
the blob base fee which is consistent across the block.

**Description**

This was already cached for `BLOBBASEFEE` in lambdaclass#5288, but it could be
unified across all users by making part of the Environment.

---------

Co-authored-by: Tomás Grüner <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

levm Lambda EVM implementation performance Block execution throughput and performance in general

Projects

Status: Done
Archived in project

Development

Successfully merging this pull request may close these issues.

5 participants