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

LEVM, L1: Design EVM trait to standardize the vm's crate interface #1661

Closed
ilitteri opened this issue Jan 8, 2025 · 0 comments · Fixed by #1949
Closed

LEVM, L1: Design EVM trait to standardize the vm's crate interface #1661

ilitteri opened this issue Jan 8, 2025 · 0 comments · Fixed by #1949
Assignees
Labels
L1 Ethereum client levm Lambda EVM implementation

Comments

@ilitteri
Copy link
Contributor

ilitteri commented Jan 8, 2025

Abstract

Define a trait EVM in crates/vm/vm.rs with methods execute_block, execute_tx, get_state_transitions

Motivation

Spec

Trait EVM

pub trait EVM {
    /// The error type for this trait's error. `EvmError` is the default, but it could be modified if needed.
    type Error = EvmError;

    /// Output for `execute_block`. The default is `(Vec<Receipt>, Vec<AccountUpdate>)`, but it could be modified if needed.
    type BlockExecutionOutput = (Vec<Receipt>, Vec<AccountUpdate>);

    /// Input for `execute_tx`. This must be defined by the implementor. It may vary depending on the backend EVM.
    type TransactionExecutionInput;

    /// Output for `execute_tx`. This must be defined by the implementor. It may vary depending on the backend EVM.
    type TransactionExecutionResult;

    /// Input for `get_state_transitions`. This must be defined by the implementor. It may vary depending on the backend EVM.
    type GetStateTransitionsInput;

    /// Executes every transaction of a block returning a list of their receipts executed and a list of accounts that were updated in the execution.
    fn execute_block(block: &Block, state: &mut EvmState) -> Result<Self::BlockExecutionOutput, Self::Error>;

    /// Executes a transaction returning its execution result. It may vary depending on the EVM used.
    fn execute_tx(input: Self::TransactionExecutionInput) -> Restult<Self::TransactionExecutionResult, Self::Error>;

    fn get_state_transitions(input: Self::GetStateTransitionsInput) -> Vec<AccountUpdate>;
}
@ilitteri ilitteri added levm Lambda EVM implementation L1 Ethereum client refactor labels Jan 8, 2025
@ilitteri ilitteri changed the title LEVM, L1: Define EVM trait to standardize the vm's crate interface LEVM, L1: Design EVM trait to standardize the vm's crate interface Jan 8, 2025
@ilitteri ilitteri self-assigned this Jan 9, 2025
@ilitteri ilitteri assigned fborello-lambda and unassigned ilitteri Feb 3, 2025
github-merge-queue bot pushed a commit that referenced this issue Feb 7, 2025
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 &rarr; 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.

- The next step consists of abstracting the logic with a `trait` as
#1661 describes

---------

Co-authored-by: Tomas Fabrizio Orsi <[email protected]>
github-merge-queue bot pushed a commit that referenced this issue 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
JereSalo pushed a commit that referenced this issue Feb 28, 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
L1 Ethereum client levm Lambda EVM implementation
Projects
Status: Done
2 participants