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: restructuring Part6 transaction crate #1814

Merged
merged 37 commits into from
Oct 8, 2024

Conversation

rakita
Copy link
Member

@rakita rakita commented Oct 1, 2024

Introduction of Transaction trait and revm-transaction crate.

pub trait Transaction {
    /// An error that occurs when validating a transaction.
    type TransactionError: TransactionError;
    /// Transaction type.
    type TransactionType: Into<TransactionType>;
    /// Access list type.
    type AccessList: AccessListTrait;

    type Legacy: LegacyTx;
    type Eip2930: Eip2930Tx<AccessList = Self::AccessList>;
    type Eip1559: Eip1559Tx<AccessList = Self::AccessList>;
    type Eip4844: Eip4844Tx<AccessList = Self::AccessList>;
    type Eip7702: Eip7702Tx<AccessList = Self::AccessList>;

    /// Transaction type. Depending on this field other functions should be called.
    /// If transaction is Legacy, then `legacy()` should be called.
    fn tx_type(&self) -> Self::TransactionType;

    /// Legacy transaction.
    fn legacy(&self) -> &Self::Legacy {
        unimplemented!("legacy tx not supported")
    }

    /// EIP-2930 transaction.
    fn eip2930(&self) -> &Self::Eip2930 {
        unimplemented!("Eip2930 tx not supported")
    }

    /// EIP-1559 transaction.
    fn eip1559(&self) -> &Self::Eip1559 {
        unimplemented!("Eip1559 tx not supported")
    }

    /// EIP-4844 transaction.
    fn eip4844(&self) -> &Self::Eip4844 {
        unimplemented!("Eip4844 tx not supported")
    }

    /// EIP-7702 transaction.
    fn eip7702(&self) -> &Self::Eip7702 {
        unimplemented!("Eip7702 tx not supported")
    }

    ...
}
  • This trait is implemented on previous TxEnv struct, and only field that was added was tx_type.
  • Validation of transaction field is moved from Env to validation functions.
  • AccessList and AuthorizationList are modelled as associated types traits. In follow up PR eip-* types will be moved inside the project when the default context gets extracted.
  • Optimism crate is a good example to see how a new transaction type is added TxDeposit.

cargo depgraph --no-default-features --workspace-only --exclude example-block-traces,example-contract-deployment,example-database-components,example-database-ref,example-uniswap-get-reserves,example-uniswap-v2-usdc-swap | dot -Tpng > graph.png
Graph generated by the command above:

image

Copy link
Contributor

github-actions bot commented Oct 2, 2024

Valgrind Results:

==4531== Cachegrind, a cache and branch-prediction profiler
==4531== Copyright (C) 2002-2017, and GNU GPL'd, by Nicholas Nethercote et al.
==4531== Using Valgrind-3.18.1 and LibVEX; rerun with -h for copyright info
==4531== Command: target/release/revme bench snailtracer
==4531== 
--4531-- warning: L3 cache found, using its data for the LL simulation.
Running snailtracer example!
elapsed: 1.845851615s
==4531== 
==4531== I   refs:      429,384,219
==4531== I1  misses:          4,604
==4531== LLi misses:          4,189
==4531== I1  miss rate:        0.00%
==4531== LLi miss rate:        0.00%
==4531== 
==4531== D   refs:      205,676,599  (133,130,367 rd   + 72,546,232 wr)
==4531== D1  misses:        347,773  (    204,768 rd   +    143,005 wr)
==4531== LLd misses:        142,546  (      7,355 rd   +    135,191 wr)
==4531== D1  miss rate:         0.2% (        0.2%     +        0.2%  )
==4531== LLd miss rate:         0.1% (        0.0%     +        0.2%  )
==4531== 
==4531== LL refs:           352,377  (    209,372 rd   +    143,005 wr)
==4531== LL misses:         146,735  (     11,544 rd   +    135,191 wr)
==4531== LL miss rate:          0.0% (        0.0%     +        0.2%  )

@rakita rakita marked this pull request as ready for review October 8, 2024 14:35
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.

1 participant