Skip to content
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

feat(levm): trait EVM #1897

Closed
wants to merge 17 commits into from
Closed

feat(levm): trait EVM #1897

wants to merge 17 commits into from

Conversation

fborello-lambda
Copy link
Contributor

@fborello-lambda fborello-lambda commented Feb 7, 2025

Motivation

We had repeated code and multiple entry-points for some functions. Isolating revm and levm with a trait would make the code cleaner. At least it should be easier to define boundaries inside the code.

Description

Closes #1661

@fborello-lambda fborello-lambda added the levm Lambda EVM implementation label Feb 7, 2025
@fborello-lambda fborello-lambda self-assigned this Feb 7, 2025
Copy link

github-actions bot commented Feb 7, 2025

| File                                                                     | Lines | Diff |
+--------------------------------------------------------------------------+-------+------+
| /home/runner/work/ethrex/ethrex/cmd/ef_tests/state/runner/levm_runner.rs | 360   | -58  |
+--------------------------------------------------------------------------+-------+------+
| /home/runner/work/ethrex/ethrex/cmd/ef_tests/state/runner/revm_runner.rs | 519   | +3   |
+--------------------------------------------------------------------------+-------+------+
| /home/runner/work/ethrex/ethrex/crates/blockchain/blockchain.rs          | 178   | -4   |
+--------------------------------------------------------------------------+-------+------+
| /home/runner/work/ethrex/ethrex/crates/blockchain/payload.rs             | 527   | -135 |
+--------------------------------------------------------------------------+-------+------+
| /home/runner/work/ethrex/ethrex/crates/l2/proposer/l1_committer.rs       | 371   | +1   |
+--------------------------------------------------------------------------+-------+------+
| /home/runner/work/ethrex/ethrex/crates/vm/backends/levm.rs               | 444   | +141 |
+--------------------------------------------------------------------------+-------+------+
| /home/runner/work/ethrex/ethrex/crates/vm/backends/mod.rs                | 231   | +210 |
+--------------------------------------------------------------------------+-------+------+
| /home/runner/work/ethrex/ethrex/crates/vm/backends/revm.rs               | 648   | +167 |
+--------------------------------------------------------------------------+-------+------+
| /home/runner/work/ethrex/ethrex/crates/vm/execution_db.rs                | 230   | +1   |
+--------------------------------------------------------------------------+-------+------+
| /home/runner/work/ethrex/ethrex/crates/vm/levm/src/vm.rs                 | 426   | +7   |
+--------------------------------------------------------------------------+-------+------+
| /home/runner/work/ethrex/ethrex/crates/vm/vm.rs                          | 132   | -97  |
+--------------------------------------------------------------------------+-------+------+

Total lines added: +530
Total lines removed: 294
Total lines changed: 824

@fborello-lambda fborello-lambda changed the title feat(levm): EVM trait feat(levm): trait EVM Feb 10, 2025
Copy link

github-actions bot commented Feb 12, 2025

Summary: 13671/16775 (81.50%)
Prague: 2373/2373 (100.00%)
Cancun: 3579/3579 (100.00%)
Shanghai: 204/221 (92.31%)
Paris: 62/62 (100.00%)
London: 39/39 (100.00%)
Berlin: 2/35 (5.71%)
Istanbul: 34/35 (97.14%)
Constantinople: 1617/2406 (67.21%)
Petersburg: 2094/2400 (87.25%)
Byzantium: 2006/2330 (86.09%)
Homestead: 645/1324 (48.72%)
Frontier: 161/742 (21.70%)
SpuriousDragon: 443/579 (76.51%)
Tangerine: 412/650 (63.38%)

Copy link

github-actions bot commented Feb 12, 2025

Benchmark Results Comparison

PR Results

Benchmark Results: Factorial

Command Mean [ms] Min [ms] Max [ms] Relative
revm_Factorial 241.8 ± 8.3 237.8 265.4 1.00
levm_Factorial 908.1 ± 11.1 897.2 931.1 3.75 ± 0.14

Benchmark Results: Factorial - Recursive

Command Mean [s] Min [s] Max [s] Relative
revm_FactorialRecursive 1.530 ± 0.082 1.397 1.646 1.00
levm_FactorialRecursive 15.670 ± 0.036 15.625 15.724 10.24 ± 0.55

Benchmark Results: Fibonacci

Command Mean [ms] Min [ms] Max [ms] Relative
revm_Fibonacci 213.5 ± 6.7 210.5 232.4 1.00
levm_Fibonacci 909.0 ± 25.0 896.3 978.9 4.26 ± 0.18

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 18.1 ± 0.1 17.9 18.3 2.09 ± 0.02

Benchmark Results: BubbleSort

Command Mean [s] Min [s] Max [s] Relative
revm_BubbleSort 3.290 ± 0.017 3.266 3.317 1.00
levm_BubbleSort 6.119 ± 0.034 6.077 6.161 1.86 ± 0.01

Benchmark Results: ERC20 - Transfer

Command Mean [ms] Min [ms] Max [ms] Relative
revm_ERC20Transfer 250.9 ± 1.3 248.9 252.7 1.00
levm_ERC20Transfer 543.5 ± 2.3 539.5 547.5 2.17 ± 0.01

Benchmark Results: ERC20 - Mint

Command Mean [ms] Min [ms] Max [ms] Relative
revm_ERC20Mint 143.2 ± 1.1 141.1 145.6 1.00
levm_ERC20Mint 357.7 ± 10.6 351.1 387.4 2.50 ± 0.08

Benchmark Results: ERC20 - Approval

Command Mean [s] Min [s] Max [s] Relative
revm_ERC20Approval 1.049 ± 0.005 1.043 1.062 1.00
levm_ERC20Approval 2.050 ± 0.041 2.025 2.165 1.95 ± 0.04

Main Results

Benchmark Results: Factorial

Command Mean [ms] Min [ms] Max [ms] Relative
revm_Factorial 237.6 ± 0.4 237.0 238.3 1.00
levm_Factorial 906.6 ± 8.9 896.3 923.9 3.82 ± 0.04

Benchmark Results: Factorial - Recursive

Command Mean [s] Min [s] Max [s] Relative
revm_FactorialRecursive 1.473 ± 0.059 1.386 1.557 1.00
levm_FactorialRecursive 15.660 ± 0.034 15.602 15.708 10.63 ± 0.42

Benchmark Results: Fibonacci

Command Mean [ms] Min [ms] Max [ms] Relative
revm_Fibonacci 209.5 ± 1.3 206.3 210.5 1.00
levm_Fibonacci 901.7 ± 16.7 889.4 943.6 4.30 ± 0.08

Benchmark Results: ManyHashes

Command Mean [ms] Min [ms] Max [ms] Relative
revm_ManyHashes 8.5 ± 0.1 8.3 8.7 1.00
levm_ManyHashes 18.2 ± 0.3 17.8 18.9 2.14 ± 0.05

Benchmark Results: BubbleSort

Command Mean [s] Min [s] Max [s] Relative
revm_BubbleSort 3.268 ± 0.017 3.249 3.300 1.00
levm_BubbleSort 6.112 ± 0.038 6.073 6.184 1.87 ± 0.02

Benchmark Results: ERC20 - Transfer

Command Mean [ms] Min [ms] Max [ms] Relative
revm_ERC20Transfer 253.6 ± 1.7 250.8 255.4 1.00
levm_ERC20Transfer 541.2 ± 5.7 526.6 546.5 2.13 ± 0.03

Benchmark Results: ERC20 - Mint

Command Mean [ms] Min [ms] Max [ms] Relative
revm_ERC20Mint 143.3 ± 3.3 140.9 149.9 1.00
levm_ERC20Mint 355.2 ± 5.4 350.3 369.7 2.48 ± 0.07

Benchmark Results: ERC20 - Approval

Command Mean [s] Min [s] Max [s] Relative
revm_ERC20Approval 1.043 ± 0.005 1.036 1.052 1.00
levm_ERC20Approval 2.032 ± 0.006 2.024 2.043 1.95 ± 0.01

Copy link

github-actions bot commented Feb 12, 2025

EF Tests Comparison

Test Name MAIN PR DIFF
Summary: 14807/16775 (88.27%) 14737/16775 (87.85%) ⬇️️ -70
Prague: 2373/2373 (100.00%) 2373/2373 (100.00%) ➖️
Cancun: 3579/3579 (100.00%) 3579/3579 (100.00%) ➖️
Shanghai: 221/221 (100.00%) 204/221 (92.31%) ⬇️️ -17
Paris: 62/62 (100.00%) 62/62 (100.00%) ➖️
London: 39/39 (100.00%) 39/39 (100.00%) ➖️
Berlin: 35/35 (100.00%) 35/35 (100.00%) ➖️
Istanbul: 34/35 (97.14%) 34/35 (97.14%) ➖️
Constantinople: 1780/2406 (73.98%) 1752/2406 (72.82%) ⬇️️ -28
Petersburg: 2345/2400 (97.71%) 2318/2400 (96.58%) ⬇️️ -27
Byzantium: 2244/2330 (96.31%) 2216/2330 (95.11%) ⬇️️ -28
Homestead: 868/1324 (65.56%) 883/1324 (66.69%) ⬆️ 15
Frontier: 335/742 (45.15%) 346/742 (46.63%) ⬆️ 11
SpuriousDragon: 484/579 (83.59%) 476/579 (82.21%) ⬇️️ -8
Tangerine: 408/650 (62.77%) 420/650 (64.62%) ⬆️ 12

@fborello-lambda fborello-lambda marked this pull request as ready for review February 13, 2025 14:30
@fborello-lambda fborello-lambda requested a review from a team as a code owner February 13, 2025 14:30
Copy link
Collaborator

@mpaulucci mpaulucci left a comment

Choose a reason for hiding this comment

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

LGTM as a first iteration

github-merge-queue bot pushed a commit that referenced this pull request Feb 13, 2025
- The latest `rzup` binary removed the `extension` argument.
  - Now it uses `install` and `default` to set the desired version.
- I've also removed the sp1's elf file, discussed
[here](#1897 (comment)).
@fborello-lambda
Copy link
Contributor Author

fborello-lambda commented Feb 17, 2025

Closed in favor of #1949

@fborello-lambda fborello-lambda deleted the levm/evm_trait branch February 17, 2025 12:50
github-merge-queue bot pushed a commit that referenced this pull request Feb 20, 2025
Alternative to #1897
**Motivation**

When doing the `EVM` trait in #1897, i've ended up needing an enum to
wrap the structs that implement such trait. This approach ended up being
quite complex, and the raw use of an enum was discussed.

**Description**
- Implement an `enum` as unique entrypoint for the crate `ethrex-vm`.

Closes #1661
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.

LEVM, L1: Design EVM trait to standardize the vm's crate interface
4 participants