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: integrate new revm #7

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open

feat: integrate new revm #7

wants to merge 13 commits into from

Conversation

klkvr
Copy link
Member

@klkvr klkvr commented Jan 30, 2025

Motivation

Solution

PR Checklist

  • Added Tests
  • Added Documentation
  • Breaking changes

@klkvr klkvr requested a review from mattsse as a code owner January 30, 2025 19:24
@klkvr klkvr force-pushed the klkvr/new-revm branch 2 times, most recently from 804e592 to 1fa969d Compare January 30, 2025 20:04
@klkvr klkvr changed the base branch from main to klkvr/readme January 30, 2025 20:04
Comment on lines +112 to +113
// Explicitly set nonce to 0 so revm does not do any nonce checks
nonce: 0,
Copy link
Member

Choose a reason for hiding this comment

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

is 0 now equivalent to None?

Copy link
Member Author

Choose a reason for hiding this comment

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

it's not, we now have CfgEnv::disable_nonce_check for it

Copy link
Member

Choose a reason for hiding this comment

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

Did we want to ask Dragan to bring back optional nonces?

Copy link
Member

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

I like this a lot,

smol suggestion

Comment on lines +7 to +11
/// Abstraction over transaction validation error.
pub trait InvalidTxError: Error + Send + Sync + 'static {
/// Returns whether the error cause by transaction having a nonce lower than expected.
fn is_nonce_too_low(&self) -> bool;
}
Copy link
Member

Choose a reason for hiding this comment

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

as mentioned, I like this a lot, we can extend these as we see fit, the alternative would be an enum with variants we know exist that the network specific enum should wrap, but imo a trait like this is more convenient

}
}

impl<DBError, TxError> EvmError for EVMError<DBError, TxError>
Copy link
Member

Choose a reason for hiding this comment

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

ideally this should only need one error

#[derive(Debug)]
pub enum EthEvm<DB: Database, I> {
/// Simple EVM implementation.
Simple(EthEvmContext<DB>),
Copy link
Member

Choose a reason for hiding this comment

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

maybe?
bacuse raw evm execution?

Suggested change
Simple(EthEvmContext<DB>),
Raw(EthEvmContext<DB>),

impl<DB: Database, I> Deref for EthEvm<DB, I> {
type Target = EthEvmContext<DB>;

fn deref(&self) -> &Self::Target {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
fn deref(&self) -> &Self::Target {
#[inline]
fn deref(&self) -> &Self::Target {

Comment on lines +154 to +155
let prev_block_env = self.block.clone();
let prev_cfg_env = self.cfg.clone();
Copy link
Member

Choose a reason for hiding this comment

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

These clones are OK? I would love if we didn't need them?

Comment on lines +56 to +57
#[cfg(feature = "op")]
impl InvalidTxError for revm_optimism::OpTransactionError {
Copy link
Member

Choose a reason for hiding this comment

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

Sad that we need this, but I get it

Comment on lines +30 to +36
/// Error type returned by EVM. Contains either errors related to invalid transactions or
/// internal irrecoverable execution errors.
type Error: EvmError;
/// Halt reason. Enum over all possible reasons for halting the execution. When execution halts,
/// it means that transaction is valid, however, it's execution was interrupted (e.g because of
/// running out of gas or overflowing stack).
type HaltReason: HaltReasonTrait + Send + Sync;
Copy link
Member

Choose a reason for hiding this comment

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

Should we not exposing these 2 generics, pick a concrete type for each, and have an Other(String) variant, if we want to simplify this trait a bit?

Copy link
Member

Choose a reason for hiding this comment

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

this isn't sufficient because we need to handle errors and halts differently.
e.g. in gas estimation and when converting the proper rpc error message

Comment on lines +112 to +113
// Explicitly set nonce to 0 so revm does not do any nonce checks
nonce: 0,
Copy link
Member

Choose a reason for hiding this comment

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

Did we want to ask Dragan to bring back optional nonces?

@klkvr klkvr deleted the branch main February 1, 2025 00:12
@klkvr klkvr closed this Feb 1, 2025
@klkvr klkvr reopened this Feb 1, 2025
@klkvr klkvr changed the base branch from klkvr/readme to main February 1, 2025 00:14
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.

3 participants