Skip to content

Conversation

@fedacking
Copy link
Contributor

Motivation

There were multiple functions implementing the eip4844 helper function fake_exponential. These functions should be unified to a single U256 implementation that properly takes into account the possible overflow.

Description

  • Removed fake_exponential function in LEVM crate
  • Removed fake_exponential_checked function in block.rs
  • Changed fake_exponential function signature to be U256
  • Changed base_fee_per_blob_gas to be U256 where is it used
  • Added a test for the 400M limit where the function still operates

**Motivation**

Currently, we have 3 differential fake_exponential functions that are a helper for the 4844 eip https://eips.ethereum.org/EIPS/eip-4844#helpers. These functions may silently overflow, causing bugs if the excess_blog_gas grows.

**Changes**

- Unified into a single fake_exponential function (the levm implementation)
- The node panics if the output exceeds the u64 limit for the base_fee_per_blob_gas
@github-actions
Copy link

github-actions bot commented Oct 29, 2025

Lines of code report

Total lines added: 41
Total lines removed: 32
Total lines changed: 73

Detailed view
+------------------------------------------------+-------+------+
| File                                           | Lines | Diff |
+------------------------------------------------+-------+------+
| ethrex/crates/common/serde_utils.rs            | 633   | +22  |
+------------------------------------------------+-------+------+
| ethrex/crates/common/types/block.rs            | 878   | +8   |
+------------------------------------------------+-------+------+
| ethrex/crates/l2/sequencer/l1_committer.rs     | 1063  | -1   |
+------------------------------------------------+-------+------+
| ethrex/crates/networking/rpc/eth/fee_market.rs | 231   | +2   |
+------------------------------------------------+-------+------+
| ethrex/crates/vm/levm/src/errors.rs            | 234   | +5   |
+------------------------------------------------+-------+------+
| ethrex/crates/vm/levm/src/gas_cost.rs          | 830   | -31  |
+------------------------------------------------+-------+------+
| ethrex/crates/vm/levm/src/utils.rs             | 503   | +4   |
+------------------------------------------------+-------+------+

@github-actions
Copy link

github-actions bot commented Oct 29, 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.769 ± 0.011 4.755 4.789 1.04 ± 0.00
main_levm_BubbleSort 4.634 ± 0.013 4.611 4.655 1.01 ± 0.00
pr_revm_BubbleSort 4.766 ± 0.024 4.731 4.795 1.04 ± 0.01
pr_levm_BubbleSort 4.604 ± 0.006 4.594 4.611 1.00

Benchmark Results: ERC20Approval

Command Mean [s] Min [s] Max [s] Relative
main_revm_ERC20Approval 1.555 ± 0.012 1.543 1.580 1.00
main_levm_ERC20Approval 1.680 ± 0.045 1.657 1.807 1.08 ± 0.03
pr_revm_ERC20Approval 1.568 ± 0.010 1.557 1.588 1.01 ± 0.01
pr_levm_ERC20Approval 1.670 ± 0.010 1.660 1.694 1.07 ± 0.01

Benchmark Results: ERC20Mint

Command Mean [ms] Min [ms] Max [ms] Relative
main_revm_ERC20Mint 188.3 ± 1.0 187.0 189.8 1.00 ± 0.01
main_levm_ERC20Mint 206.0 ± 0.7 204.8 207.0 1.10 ± 0.01
pr_revm_ERC20Mint 187.8 ± 1.6 185.4 190.5 1.00
pr_levm_ERC20Mint 206.3 ± 0.8 205.5 207.8 1.10 ± 0.01

Benchmark Results: ERC20Transfer

Command Mean [ms] Min [ms] Max [ms] Relative
main_revm_ERC20Transfer 357.5 ± 2.7 354.2 363.6 1.00
main_levm_ERC20Transfer 395.5 ± 3.7 391.0 404.0 1.11 ± 0.01
pr_revm_ERC20Transfer 358.8 ± 2.4 356.7 361.8 1.00 ± 0.01
pr_levm_ERC20Transfer 394.5 ± 2.2 391.5 397.8 1.10 ± 0.01

Benchmark Results: Factorial

Command Mean [ms] Min [ms] Max [ms] Relative
main_revm_Factorial 243.9 ± 0.9 242.5 245.3 1.01 ± 0.00
main_levm_Factorial 284.8 ± 18.5 278.0 337.5 1.18 ± 0.08
pr_revm_Factorial 241.6 ± 0.7 240.9 243.1 1.00
pr_levm_Factorial 280.2 ± 0.8 278.9 281.6 1.16 ± 0.00

Benchmark Results: FactorialRecursive

Command Mean [s] Min [s] Max [s] Relative
main_revm_FactorialRecursive 1.686 ± 0.035 1.593 1.726 1.00
main_levm_FactorialRecursive 8.659 ± 0.048 8.598 8.735 5.14 ± 0.11
pr_revm_FactorialRecursive 1.691 ± 0.025 1.654 1.727 1.00 ± 0.03
pr_levm_FactorialRecursive 8.661 ± 0.075 8.537 8.781 5.14 ± 0.11

Benchmark Results: Fibonacci

Command Mean [ms] Min [ms] Max [ms] Relative
main_revm_Fibonacci 215.8 ± 0.7 214.7 216.9 1.00
main_levm_Fibonacci 260.4 ± 5.7 254.4 268.8 1.21 ± 0.03
pr_revm_Fibonacci 216.8 ± 1.9 214.7 221.7 1.00 ± 0.01
pr_levm_Fibonacci 261.4 ± 3.5 257.1 268.1 1.21 ± 0.02

Benchmark Results: FibonacciRecursive

Command Mean [ms] Min [ms] Max [ms] Relative
main_revm_FibonacciRecursive 879.9 ± 7.1 868.9 893.2 1.12 ± 0.01
main_levm_FibonacciRecursive 782.7 ± 4.5 776.5 789.8 1.00
pr_revm_FibonacciRecursive 875.0 ± 11.5 861.0 902.3 1.12 ± 0.02
pr_levm_FibonacciRecursive 787.1 ± 6.1 779.2 799.6 1.01 ± 0.01

Benchmark Results: ManyHashes

Command Mean [ms] Min [ms] Max [ms] Relative
main_revm_ManyHashes 12.7 ± 0.1 12.5 12.9 1.01 ± 0.01
main_levm_ManyHashes 13.8 ± 0.1 13.7 14.0 1.10 ± 0.01
pr_revm_ManyHashes 12.5 ± 0.1 12.5 12.8 1.00
pr_levm_ManyHashes 13.8 ± 0.1 13.7 14.0 1.10 ± 0.01

Benchmark Results: MstoreBench

Command Mean [ms] Min [ms] Max [ms] Relative
main_revm_MstoreBench 269.4 ± 3.1 266.5 275.2 1.06 ± 0.01
main_levm_MstoreBench 254.3 ± 1.3 252.5 256.3 1.00
pr_revm_MstoreBench 269.3 ± 3.1 266.6 275.2 1.06 ± 0.01
pr_levm_MstoreBench 256.5 ± 4.2 252.8 266.8 1.01 ± 0.02

Benchmark Results: Push

Command Mean [ms] Min [ms] Max [ms] Relative
main_revm_Push 299.8 ± 1.8 297.5 303.2 1.00
main_levm_Push 307.8 ± 1.4 306.4 310.3 1.03 ± 0.01
pr_revm_Push 300.4 ± 1.1 298.8 302.2 1.00 ± 0.01
pr_levm_Push 309.5 ± 8.9 304.0 334.2 1.03 ± 0.03

Benchmark Results: SstoreBench_no_opt

Command Mean [ms] Min [ms] Max [ms] Relative
main_revm_SstoreBench_no_opt 223.7 ± 7.6 219.7 243.0 2.49 ± 0.09
main_levm_SstoreBench_no_opt 89.9 ± 1.1 88.3 91.0 1.00
pr_revm_SstoreBench_no_opt 220.8 ± 1.6 219.9 225.2 2.46 ± 0.03
pr_levm_SstoreBench_no_opt 91.2 ± 2.2 88.5 95.3 1.01 ± 0.03

@fedacking fedacking marked this pull request as ready for review October 31, 2025 13:38
@fedacking fedacking requested a review from a team as a code owner October 31, 2025 13:38
Copy link
Contributor

@ElFantasma ElFantasma left a comment

Choose a reason for hiding this comment

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

LGTM

@fedacking fedacking enabled auto-merge November 3, 2025 19:29
@fedacking fedacking added this pull request to the merge queue Nov 3, 2025
Merged via the queue into main with commit 5b1c859 Nov 3, 2025
51 checks passed
@fedacking fedacking deleted the unifiy-fake-exponential branch November 3, 2025 20:28
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.

5 participants