Skip to content

refactor(levm): use ethrex account types #2614

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 68 commits into from

Conversation

JereSalo
Copy link
Contributor

@JereSalo JereSalo commented Apr 25, 2025

Motivation

  • Stop using the Account and AccountInfo types defined in LEVM and start using the ones defined in the L1 client.

Description

  • Now we use the structs of the L1 client but they are different from the ones that we used so I had to make changes:

    • get_account_info is now get_account because we also need the code of the account and AccountInfo has the code_hash only.
    • Now that we don't have StorageSlot that had the current_value and original_value of a storage slot (original_value being the value pre-tx) I had to make some changes to logic and store those original values at the beginning of the transaction into an auxiliary HashMap. The solution was the simplest just to make it work but I want to see if I can improve that in a reasonable way so that we don't clone all the storage at the beginning of the transaction, which, if we had a big cache, would be expensive.
  • Added new function get_original_storage()

Closes #issue_number

JereSalo and others added 13 commits April 24, 2025 10:05
**Motivation**

<!-- Why does this pull request exist? What are its goals? -->
- stop popping callframe in finalize execution

**Description**

<!-- A clear and concise general description of the changes this PR
introduces -->

<!-- Link to issues: Resolves #111, Resolves #222 -->

Closes #issue_number
@JereSalo JereSalo added the levm Lambda EVM implementation label Apr 25, 2025
@JereSalo JereSalo self-assigned this Apr 25, 2025
Copy link

github-actions bot commented Apr 25, 2025

Lines of code report

Total lines added: 45
Total lines removed: 52
Total lines changed: 97

Detailed view
+----------------------------------------------------------+-------+------+
| File                                                     | Lines | Diff |
+----------------------------------------------------------+-------+------+
| ethrex/cmd/ef_tests/state/runner/mod.rs                  | 226   | -4   |
+----------------------------------------------------------+-------+------+
| ethrex/cmd/ef_tests/state/runner/revm_runner.rs          | 505   | -9   |
+----------------------------------------------------------+-------+------+
| ethrex/crates/common/types/account.rs                    | 198   | +32  |
+----------------------------------------------------------+-------+------+
| ethrex/crates/l2/prover/bench/src/rpc/db.rs              | 488   | +1   |
+----------------------------------------------------------+-------+------+
| ethrex/crates/vm/backends/levm/db.rs                     | 174   | -6   |
+----------------------------------------------------------+-------+------+
| ethrex/crates/vm/backends/levm/mod.rs                    | 617   | -10  |
+----------------------------------------------------------+-------+------+
| ethrex/crates/vm/levm/src/call_frame.rs                  | 128   | +2   |
+----------------------------------------------------------+-------+------+
| ethrex/crates/vm/levm/src/db/cache.rs                    | 28    | -1   |
+----------------------------------------------------------+-------+------+
| ethrex/crates/vm/levm/src/db/gen_db.rs                   | 194   | -15  |
+----------------------------------------------------------+-------+------+
| ethrex/crates/vm/levm/src/db/mod.rs                      | 18    | +2   |
+----------------------------------------------------------+-------+------+
| ethrex/crates/vm/levm/src/gas_cost.rs                    | 1131  | +1   |
+----------------------------------------------------------+-------+------+
| ethrex/crates/vm/levm/src/hooks/default_hook.rs          | 264   | +2   |
+----------------------------------------------------------+-------+------+
| ethrex/crates/vm/levm/src/hooks/l2_hook.rs               | 194   | +2   |
+----------------------------------------------------------+-------+------+
| ethrex/crates/vm/levm/src/lib.rs                         | 16    | -2   |
+----------------------------------------------------------+-------+------+
| ethrex/crates/vm/levm/src/opcode_handlers/environment.rs | 315   | -3   |
+----------------------------------------------------------+-------+------+
| ethrex/crates/vm/levm/src/opcode_handlers/system.rs      | 842   | +2   |
+----------------------------------------------------------+-------+------+
| ethrex/crates/vm/levm/src/utils.rs                       | 426   | +1   |
+----------------------------------------------------------+-------+------+
| ethrex/crates/vm/levm/src/vm.rs                          | 392   | -2   |
+----------------------------------------------------------+-------+------+

Base automatically changed from levm/cache_rollback to main April 25, 2025 22:10
Copy link

github-actions bot commented Apr 25, 2025

Benchmark Results Comparison

PR Results

Benchmark Results: Factorial

Command Mean [ms] Min [ms] Max [ms] Relative
revm_Factorial 238.4 ± 1.6 237.4 242.5 1.00
levm_Factorial 885.0 ± 11.7 874.9 915.3 3.71 ± 0.05

Benchmark Results: Factorial - Recursive

Command Mean [s] Min [s] Max [s] Relative
revm_FactorialRecursive 1.558 ± 0.082 1.416 1.643 1.00
levm_FactorialRecursive 13.423 ± 0.247 13.101 13.734 8.61 ± 0.48

Benchmark Results: Fibonacci

Command Mean [ms] Min [ms] Max [ms] Relative
revm_Fibonacci 249.8 ± 23.6 221.8 288.7 1.00
levm_Fibonacci 881.5 ± 8.4 870.7 894.0 3.53 ± 0.33

Benchmark Results: ManyHashes

Command Mean [ms] Min [ms] Max [ms] Relative
revm_ManyHashes 8.7 ± 0.1 8.6 8.8 1.00
levm_ManyHashes 17.4 ± 0.1 17.2 17.5 2.00 ± 0.02

Benchmark Results: BubbleSort

Command Mean [s] Min [s] Max [s] Relative
revm_BubbleSort 3.233 ± 0.018 3.209 3.268 1.00
levm_BubbleSort 8.415 ± 0.190 8.266 8.925 2.60 ± 0.06

Benchmark Results: ERC20 - Transfer

Command Mean [ms] Min [ms] Max [ms] Relative
revm_ERC20Transfer 252.3 ± 2.0 250.3 255.9 1.00
levm_ERC20Transfer 595.4 ± 4.2 591.4 605.9 2.36 ± 0.02

Benchmark Results: ERC20 - Mint

Command Mean [ms] Min [ms] Max [ms] Relative
revm_ERC20Mint 153.2 ± 18.3 143.0 198.2 1.00
levm_ERC20Mint 402.2 ± 4.3 395.5 407.8 2.63 ± 0.32

Benchmark Results: ERC20 - Approval

Command Mean [s] Min [s] Max [s] Relative
revm_ERC20Approval 1.049 ± 0.012 1.038 1.078 1.00
levm_ERC20Approval 2.130 ± 0.011 2.107 2.144 2.03 ± 0.03

Main Results

Benchmark Results: Factorial

Command Mean [ms] Min [ms] Max [ms] Relative
revm_Factorial 233.8 ± 1.8 232.5 238.8 1.00
levm_Factorial 886.6 ± 4.8 882.4 897.7 3.79 ± 0.04

Benchmark Results: Factorial - Recursive

Command Mean [s] Min [s] Max [s] Relative
revm_FactorialRecursive 1.407 ± 0.097 1.311 1.564 1.00
levm_FactorialRecursive 14.119 ± 0.175 13.893 14.282 10.03 ± 0.70

Benchmark Results: Fibonacci

Command Mean [ms] Min [ms] Max [ms] Relative
revm_Fibonacci 215.0 ± 2.8 209.2 217.4 1.00
levm_Fibonacci 902.5 ± 68.5 876.6 1097.2 4.20 ± 0.32

Benchmark Results: ManyHashes

Command Mean [ms] Min [ms] Max [ms] Relative
revm_ManyHashes 8.7 ± 0.0 8.6 8.7 1.00
levm_ManyHashes 17.6 ± 0.1 17.4 17.8 2.03 ± 0.02

Benchmark Results: BubbleSort

Command Mean [s] Min [s] Max [s] Relative
revm_BubbleSort 3.220 ± 0.016 3.209 3.264 1.00
levm_BubbleSort 11.213 ± 0.119 11.009 11.335 3.48 ± 0.04

Benchmark Results: ERC20 - Transfer

Command Mean [ms] Min [ms] Max [ms] Relative
revm_ERC20Transfer 249.1 ± 0.7 247.9 249.9 1.00
levm_ERC20Transfer 574.6 ± 1.8 571.4 577.3 2.31 ± 0.01

Benchmark Results: ERC20 - Mint

Command Mean [ms] Min [ms] Max [ms] Relative
revm_ERC20Mint 141.7 ± 0.6 141.2 143.1 1.00
levm_ERC20Mint 384.9 ± 2.3 381.7 390.6 2.72 ± 0.02

Benchmark Results: ERC20 - Approval

Command Mean [s] Min [s] Max [s] Relative
revm_ERC20Approval 1.042 ± 0.009 1.034 1.059 1.00
levm_ERC20Approval 2.104 ± 0.016 2.084 2.122 2.02 ± 0.02

Copy link

github-actions bot commented Apr 25, 2025

EF Tests Comparison

Test Name MAIN PR DIFF
Summary: 32881/38385 (85.66%) 32725/38385 (85.25%) ⬇️️ -156
Prague: 5202/5202 (100.00%) 5202/5202 (100.00%) ➖️
Cancun: 7608/7608 (100.00%) 7608/7608 (100.00%) ➖️
Shanghai: 3214/3214 (100.00%) 3214/3214 (100.00%) ➖️
Paris: 2886/2886 (100.00%) 2886/2886 (100.00%) ➖️
London: 2898/2915 (99.42%) 2870/2915 (98.46%) ⬇️️ -28
Berlin: 215/2755 (7.80%) 215/2755 (7.80%) ➖️
Istanbul: 238/2709 (8.79%) 238/2709 (8.79%) ➖️
Petersburg: 2512/2564 (97.97%) 2490/2564 (97.11%) ⬇️️ -22
Constantinople: 2334/2428 (96.13%) 2312/2428 (95.22%) ⬇️️ -22
Byzantium: 2444/2492 (98.07%) 2429/2492 (97.47%) ⬇️️ -15
SpuriousDragon: 580/598 (96.99%) 567/598 (94.82%) ⬇️️ -13
Tangerine: 592/669 (88.49%) 570/669 (85.20%) ⬇️️ -22
Homestead: 1373/1465 (93.72%) 1354/1465 (92.42%) ⬇️️ -19
Frontier: 785/880 (89.20%) 770/880 (87.50%) ⬇️️ -15

@JereSalo
Copy link
Contributor Author

Closing this PR because there are a lot of unrelated commits. Replaced it with #2629

@JereSalo JereSalo closed this Apr 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
levm Lambda EVM implementation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants