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

refactor(l1,l2,levm): add evm cli arg instead of flag #1861

Draft
wants to merge 22 commits into
base: main
Choose a base branch
from

Conversation

fborello-lambda
Copy link
Contributor

Starts from scratch PR #1706
Motivation

The feature flag is somewhat cumbersome, it's easier to build a single binary and then choose the EVM implementation via the CLI.

Description

  • Add the CLI arg → Removes the levm/revm feature flag.
    • Create the EVM enum to handle the evms.
    • Create a Blockchain struct in order to keep track of the EVM selected and make use of it throughout the code.

Closes #issue_number

@fborello-lambda fborello-lambda added levm Lambda EVM implementation L1 labels Jan 31, 2025
@fborello-lambda fborello-lambda self-assigned this Jan 31, 2025
Copy link

github-actions bot commented Jan 31, 2025

| File                                                                    | Lines | Diff |
+-------------------------------------------------------------------------+-------+------+
| /home/runner/work/ethrex/ethrex/cmd/ef_tests/levm/runner/revm_runner.rs | 463   | +3   |
+-------------------------------------------------------------------------+-------+------+
| /home/runner/work/ethrex/ethrex/cmd/ethrex/cli.rs                       | 142   | +10  |
+-------------------------------------------------------------------------+-------+------+
| /home/runner/work/ethrex/ethrex/cmd/ethrex/ethrex.rs                    | 412   | +15  |
+-------------------------------------------------------------------------+-------+------+
| /home/runner/work/ethrex/ethrex/crates/blockchain/payload.rs            | 642   | -4   |
+-------------------------------------------------------------------------+-------+------+
| /home/runner/work/ethrex/ethrex/crates/common/types/block.rs            | 649   | +1   |
+-------------------------------------------------------------------------+-------+------+
| /home/runner/work/ethrex/ethrex/crates/vm/db.rs                         | 175   | +33  |
+-------------------------------------------------------------------------+-------+------+
| /home/runner/work/ethrex/ethrex/crates/vm/errors.rs                     | 117   | -2   |
+-------------------------------------------------------------------------+-------+------+
| /home/runner/work/ethrex/ethrex/crates/vm/evm_backends/levm.rs          | 255   | +255 |
+-------------------------------------------------------------------------+-------+------+
| /home/runner/work/ethrex/ethrex/crates/vm/evm_backends/mod.rs           | 20    | +20  |
+-------------------------------------------------------------------------+-------+------+
| /home/runner/work/ethrex/ethrex/crates/vm/evm_backends/revm.rs          | 398   | +398 |
+-------------------------------------------------------------------------+-------+------+
| /home/runner/work/ethrex/ethrex/crates/vm/execution_db.rs               | 229   | +2   |
+-------------------------------------------------------------------------+-------+------+
| /home/runner/work/ethrex/ethrex/crates/vm/vm.rs                         | 227   | -630 |
+-------------------------------------------------------------------------+-------+------+

Total lines added: +737
Total lines removed: 636
Total lines changed: 1373

Copy link

github-actions bot commented Feb 5, 2025

Benchmark Results Comparison

PR Results

Benchmark Results: Factorial

Command Mean [ms] Min [ms] Max [ms] Relative
revm_Factorial 242.5 ± 1.5 240.2 245.5 1.00
levm_Factorial 901.0 ± 8.9 890.9 921.4 3.72 ± 0.04

Benchmark Results: Factorial - Recursive

Command Mean [s] Min [s] Max [s] Relative
revm_FactorialRecursive 1.444 ± 0.109 1.333 1.642 1.00
levm_FactorialRecursive 15.581 ± 0.030 15.531 15.621 10.79 ± 0.82

Benchmark Results: Fibonacci

Command Mean [ms] Min [ms] Max [ms] Relative
revm_Fibonacci 211.3 ± 1.0 210.4 213.8 1.00
levm_Fibonacci 899.7 ± 9.8 882.7 910.8 4.26 ± 0.05

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.4 2.09 ± 0.02

Benchmark Results: BubbleSort

Command Mean [s] Min [s] Max [s] Relative
revm_BubbleSort 3.224 ± 0.024 3.197 3.280 1.00
levm_BubbleSort 6.059 ± 0.035 6.027 6.123 1.88 ± 0.02

Benchmark Results: ERC20 - Transfer

Command Mean [ms] Min [ms] Max [ms] Relative
revm_ERC20Transfer 249.9 ± 1.3 247.5 251.5 1.00
levm_ERC20Transfer 534.9 ± 2.8 531.8 539.8 2.14 ± 0.02

Benchmark Results: ERC20 - Mint

Command Mean [ms] Min [ms] Max [ms] Relative
revm_ERC20Mint 141.7 ± 0.8 140.5 143.0 1.00
levm_ERC20Mint 346.4 ± 2.0 343.6 348.7 2.44 ± 0.02

Benchmark Results: ERC20 - Approval

Command Mean [s] Min [s] Max [s] Relative
revm_ERC20Approval 1.058 ± 0.020 1.042 1.111 1.00
levm_ERC20Approval 2.021 ± 0.009 2.008 2.039 1.91 ± 0.04

Main Results

Benchmark Results: Factorial

Command Mean [ms] Min [ms] Max [ms] Relative
revm_Factorial 240.4 ± 2.3 238.0 243.9 1.00
levm_Factorial 898.7 ± 9.6 888.3 911.6 3.74 ± 0.05

Benchmark Results: Factorial - Recursive

Command Mean [s] Min [s] Max [s] Relative
revm_FactorialRecursive 1.407 ± 0.085 1.329 1.583 1.00
levm_FactorialRecursive 15.614 ± 0.020 15.576 15.645 11.10 ± 0.67

Benchmark Results: Fibonacci

Command Mean [ms] Min [ms] Max [ms] Relative
revm_Fibonacci 216.3 ± 24.2 207.8 285.2 1.00
levm_Fibonacci 900.2 ± 19.9 883.6 951.9 4.16 ± 0.48

Benchmark Results: ManyHashes

Command Mean [ms] Min [ms] Max [ms] Relative
revm_ManyHashes 9.1 ± 0.6 8.7 10.5 1.00
levm_ManyHashes 18.4 ± 0.1 18.2 18.6 2.03 ± 0.12

Benchmark Results: BubbleSort

Command Mean [s] Min [s] Max [s] Relative
revm_BubbleSort 3.191 ± 0.015 3.164 3.217 1.00
levm_BubbleSort 6.126 ± 0.029 6.085 6.158 1.92 ± 0.01

Benchmark Results: ERC20 - Transfer

Command Mean [ms] Min [ms] Max [ms] Relative
revm_ERC20Transfer 248.0 ± 1.0 246.0 249.4 1.00
levm_ERC20Transfer 535.1 ± 2.8 530.9 539.4 2.16 ± 0.01

Benchmark Results: ERC20 - Mint

Command Mean [ms] Min [ms] Max [ms] Relative
revm_ERC20Mint 141.9 ± 0.7 141.0 143.1 1.00
levm_ERC20Mint 347.8 ± 2.3 345.0 351.4 2.45 ± 0.02

Benchmark Results: ERC20 - Approval

Command Mean [s] Min [s] Max [s] Relative
revm_ERC20Approval 1.041 ± 0.004 1.036 1.048 1.00
levm_ERC20Approval 2.021 ± 0.013 1.998 2.044 1.94 ± 0.01

let receipts = execute_block(block, &mut state)?;
let account_updates = ethrex_vm::get_state_transitions(&mut state);
(receipts, account_updates)
match EVM_BACKEND.get() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

this should be abstracted away some some code inside vm crate.

@@ -20,7 +20,7 @@ use ethrex_l2_sdk::{
eth_client::{eth_sender::Overrides, BlockByNumber, EthClient, WrappedTransaction},
};
use ethrex_storage::{error::StoreError, Store};
use ethrex_vm::{evm_state, execute_block, get_state_transitions};
use ethrex_vm::{db::evm_state, evm_backends::revm::execute_block, get_state_transitions};
Copy link
Collaborator

Choose a reason for hiding this comment

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

there should be nothing referencing revm or levm outside vm crate, besides the enum

@@ -0,0 +1,316 @@
use crate::db::StoreWrapper;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would rename the folder to backends. Or just have vm/revm and vm/levm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
L1 levm Lambda EVM implementation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants