Skip to content

chore: fix trevm aliases to use noop by default #101

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

Merged
merged 3 commits into from
Apr 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "trevm"
version = "0.20.6"
version = "0.20.7"
rust-version = "1.83.0"
edition = "2021"
authors = ["init4"]
Expand Down
8 changes: 4 additions & 4 deletions src/driver/alloy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ where
fn run_bundle(
&mut self,
trevm: crate::EvmNeedsTx<Db, Insp>,
) -> DriveBundleResult<Db, Insp, Self> {
) -> DriveBundleResult<Self, Db, Insp> {
// Check if the block we're in is valid for this bundle. Both must match
trevm_ensure!(
trevm.inner().block.number == self.bundle.block_number,
Expand Down Expand Up @@ -403,7 +403,7 @@ where
fn run_bundle(
&mut self,
trevm: crate::EvmNeedsTx<Db, Insp>,
) -> DriveBundleResult<Db, Insp, Self> {
) -> DriveBundleResult<Self, Db, Insp> {
{
// Check if the block we're in is valid for this bundle. Both must match
trevm_ensure!(
Expand Down Expand Up @@ -547,7 +547,7 @@ where
fn run_bundle(
&mut self,
trevm: crate::EvmNeedsTx<Db, Insp>,
) -> DriveBundleResult<Db, Insp, Self> {
) -> DriveBundleResult<Self, Db, Insp> {
// Check if the block we're in is valid for this bundle. Both must match
trevm_ensure!(
trevm.inner().block.number == self.block_number,
Expand Down Expand Up @@ -638,7 +638,7 @@ where
fn run_bundle(
&mut self,
trevm: crate::EvmNeedsTx<Db, Insp>,
) -> DriveBundleResult<Db, Insp, Self> {
) -> DriveBundleResult<Self, Db, Insp> {
// Check if the block we're in is valid for this bundle. Both must match
trevm_ensure!(
trevm.inner().block.number == self.block_number,
Expand Down
16 changes: 9 additions & 7 deletions src/driver/block.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
use crate::{helpers::Ctx, Block, EvmBlockDriverErrored, EvmNeedsBlock, EvmNeedsTx};
use revm::{context::result::EVMError, Database, DatabaseCommit, Inspector};
use revm::{
context::result::EVMError, inspector::NoOpInspector, Database, DatabaseCommit, Inspector,
};

/// The result of running transactions for a block driver.
pub type RunTxResult<Db, Insp, T> =
Result<EvmNeedsTx<Db, Insp>, EvmBlockDriverErrored<Db, Insp, T>>;
pub type RunTxResult<T, Db, Insp> =
Result<EvmNeedsTx<Db, Insp>, EvmBlockDriverErrored<T, Db, Insp>>;

/// The result of driving a block to completion.
pub type DriveBlockResult<Db, Insp, T> =
Result<EvmNeedsBlock<Db, Insp>, EvmBlockDriverErrored<Db, Insp, T>>;
pub type DriveBlockResult<T, Db, Insp> =
Result<EvmNeedsBlock<Db, Insp>, EvmBlockDriverErrored<T, Db, Insp>>;

/// Driver for a single trevm block. This trait allows a type to specify the
/// entire lifecycle of a trevm block, from opening the block to driving the
/// trevm to completion.
pub trait BlockDriver<Db, Insp>
pub trait BlockDriver<Db, Insp = NoOpInspector>
where
Db: Database + DatabaseCommit,
Insp: Inspector<Ctx<Db>>,
Expand All @@ -27,7 +29,7 @@ where
fn block(&self) -> &Self::Block;

/// Run the transactions for the block.
fn run_txns(&mut self, trevm: EvmNeedsTx<Db, Insp>) -> RunTxResult<Db, Insp, Self>;
fn run_txns(&mut self, trevm: EvmNeedsTx<Db, Insp>) -> RunTxResult<Self, Db, Insp>;
/// Run post
fn post_block(&mut self, trevm: &EvmNeedsBlock<Db, Insp>) -> Result<(), Self::Error>;
}
12 changes: 7 additions & 5 deletions src/driver/bundle.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
use crate::{helpers::Ctx, states::EvmBundleDriverErrored, EvmNeedsTx};
use revm::{context::result::EVMError, Database, DatabaseCommit, Inspector};
use revm::{
context::result::EVMError, inspector::NoOpInspector, Database, DatabaseCommit, Inspector,
};

/// The result of driving a bundle to completion.
pub type DriveBundleResult<Db, Insp, T> =
Result<EvmNeedsTx<Db, Insp>, EvmBundleDriverErrored<Db, Insp, T>>;
pub type DriveBundleResult<T, Db, Insp> =
Result<EvmNeedsTx<Db, Insp>, EvmBundleDriverErrored<T, Db, Insp>>;

/// Driver for a bundle of transactions. This trait allows a type to specify the
/// entire lifecycle of a bundle, simulating the entire list of transactions.
pub trait BundleDriver<Db, Insp>
pub trait BundleDriver<Db, Insp = NoOpInspector>
where
Db: Database + DatabaseCommit,
Insp: Inspector<Ctx<Db>>,
Expand All @@ -16,7 +18,7 @@ where
type Error: core::error::Error + From<EVMError<Db::Error>>;

/// Run the transactions contained in the bundle.
fn run_bundle(&mut self, trevm: EvmNeedsTx<Db, Insp>) -> DriveBundleResult<Db, Insp, Self>;
fn run_bundle(&mut self, trevm: EvmNeedsTx<Db, Insp>) -> DriveBundleResult<Self, Db, Insp>;

/// Run post
fn post_bundle(&mut self, trevm: &EvmNeedsTx<Db, Insp>) -> Result<(), Self::Error>;
Expand Down
9 changes: 5 additions & 4 deletions src/driver/chain.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
use crate::{helpers::Ctx, BlockDriver, EvmChainDriverErrored, EvmNeedsBlock};
use revm::{
context::result::EVMError, primitives::hardfork::SpecId, Database, DatabaseCommit, Inspector,
context::result::EVMError, inspector::NoOpInspector, primitives::hardfork::SpecId, Database,
DatabaseCommit, Inspector,
};

/// The result of driving a chain to completion.
pub type DriveChainResult<Db, Insp, D> =
Result<EvmNeedsBlock<Db, Insp>, EvmChainDriverErrored<Db, Insp, D>>;
pub type DriveChainResult<D, Db, Insp> =
Result<EvmNeedsBlock<Db, Insp>, EvmChainDriverErrored<D, Db, Insp>>;

/// Driver for a chain of blocks.
pub trait ChainDriver<Db, Insp>
pub trait ChainDriver<Db, Insp = NoOpInspector>
where
Db: Database + DatabaseCommit,
Insp: Inspector<Ctx<Db>>,
Expand Down
6 changes: 3 additions & 3 deletions src/evm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -975,7 +975,7 @@ where
{
/// Open a block, apply some logic, and return the EVM ready for the next
/// block.
pub fn drive_block<D>(self, driver: &mut D) -> DriveBlockResult<Db, Insp, D>
pub fn drive_block<D>(self, driver: &mut D) -> DriveBlockResult<D, Db, Insp>
where
D: BlockDriver<Db, Insp>,
Db: DatabaseCommit,
Expand All @@ -996,7 +996,7 @@ where
/// # Panics
///
/// If the driver contains no blocks.
pub fn drive_chain<D>(self, driver: &mut D) -> DriveChainResult<Db, Insp, D>
pub fn drive_chain<D>(self, driver: &mut D) -> DriveChainResult<D, Db, Insp>
where
D: ChainDriver<Db, Insp>,
Db: DatabaseCommit,
Expand Down Expand Up @@ -1182,7 +1182,7 @@ where

/// Drive a bundle to completion, apply some post-bundle logic, and return the
/// EVM ready for the next bundle or tx.
pub fn drive_bundle<D>(self, driver: &mut D) -> DriveBundleResult<Db, Insp, D>
pub fn drive_bundle<D>(self, driver: &mut D) -> DriveBundleResult<D, Db, Insp>
where
D: BundleDriver<Db, Insp>,
Db: DatabaseCommit,
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
//! # use revm::{database::in_memory_db::InMemoryDB, inspector::NoOpInspector};
//! # use trevm::{TrevmBuilder, EvmErrored, Cfg, BlockDriver};
//! # use alloy::primitives::B256;
//! # fn t<C: Cfg, D: BlockDriver<NoOpInspector>>(cfg: &C, mut driver: D)
//! # fn t<C: Cfg, D: BlockDriver<InMemoryDB, NoOpInspector>>(cfg: &C, mut driver: D)
//! # -> Result<(), Box<dyn std::error::Error>> {
//! let trevm = TrevmBuilder::new()
//! .with_db(InMemoryDB::default())
Expand Down
20 changes: 10 additions & 10 deletions src/states.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::{driver::BundleDriver, BlockDriver, ChainDriver, Trevm};
use revm::{context::result::EVMError, Database};
use revm::{context::result::EVMError, inspector::NoOpInspector, Database};
use sealed::*;

/// A [`Trevm`] that requires a [`Cfg`].
Expand All @@ -8,7 +8,7 @@ use sealed::*;
/// - [`EvmNeedsCfg::fill_cfg`]
///
/// [`Cfg`]: crate::Cfg
pub type EvmNeedsCfg<Db, Insp> = Trevm<Db, Insp, NeedsCfg>;
pub type EvmNeedsCfg<Db, Insp = NoOpInspector> = Trevm<Db, Insp, NeedsCfg>;

/// A [`Trevm`] that requires a [`Block`] and contains no
/// outputs. This EVM has not yet executed any transactions or state changes.
Expand All @@ -19,7 +19,7 @@ pub type EvmNeedsCfg<Db, Insp> = Trevm<Db, Insp, NeedsCfg>;
/// - [`EvmNeedsBlock::drive_chain`]
///
/// [`Block`]: crate::Block
pub type EvmNeedsBlock<Db, Insp> = Trevm<Db, Insp, NeedsBlock>;
pub type EvmNeedsBlock<Db, Insp = NoOpInspector> = Trevm<Db, Insp, NeedsBlock>;

/// A [`Trevm`] that requires a [`Tx`].
///
Expand All @@ -29,46 +29,46 @@ pub type EvmNeedsBlock<Db, Insp> = Trevm<Db, Insp, NeedsBlock>;
/// - [`EvmNeedsTx::finish`]
///
/// [`Tx`]: crate::Tx
pub type EvmNeedsTx<Db, Insp> = Trevm<Db, Insp, NeedsTx>;
pub type EvmNeedsTx<Db, Insp = NoOpInspector> = Trevm<Db, Insp, NeedsTx>;

/// A [`Trevm`] that is ready to execute a transaction.
///
/// The transaction may be executed with [`EvmReady::run`] or cleared
/// with [`EvmReady::clear_tx`]
pub type EvmReady<Db, Insp> = Trevm<Db, Insp, Ready>;
pub type EvmReady<Db, Insp = NoOpInspector> = Trevm<Db, Insp, Ready>;

/// A [`Trevm`] that run a transaction, and contains the resulting execution
/// details and state.
///
/// Expected continuations include:
/// - [`EvmTransacted::reject`]
/// - [`EvmTransacted::accept`]
pub type EvmTransacted<Db, Insp> = Trevm<Db, Insp, TransactedState>;
pub type EvmTransacted<Db, Insp = NoOpInspector> = Trevm<Db, Insp, TransactedState>;

/// A [`Trevm`] that encountered an error during transaction execution.
///
/// Expected continuations include:
/// - [`EvmErrored::discard_error`]
/// - [`EvmErrored::into_error`]
pub type EvmErrored<Db, Insp, E = EVMError<<Db as Database>::Error>> =
pub type EvmErrored<Db, Insp = NoOpInspector, E = EVMError<<Db as Database>::Error>> =
Trevm<Db, Insp, ErroredState<E>>;

/// A [`Trevm`] that encountered an error during [`BlockDriver`] execution.
///
/// This is an [`EvmErrored`] parameterized with the driver's error type.
pub type EvmBlockDriverErrored<Db, Insp, T> =
pub type EvmBlockDriverErrored<T, Db, Insp = NoOpInspector> =
EvmErrored<Db, Insp, <T as BlockDriver<Db, Insp>>::Error>;

/// A [`Trevm`] that encountered an error during [`ChainDriver`] execution.
///
/// This is an [`EvmErrored`] parameterized with the driver's error type.
pub type EvmChainDriverErrored<Db, Insp, T> =
pub type EvmChainDriverErrored<T, Db, Insp = NoOpInspector> =
EvmErrored<Db, Insp, <T as ChainDriver<Db, Insp>>::Error>;

/// A [`Trevm`] that encountered an error during [`BundleDriver`] execution.
///
/// This is an [`EvmErrored`] parameterized with the driver's error type.
pub type EvmBundleDriverErrored<Db, Insp, T> =
pub type EvmBundleDriverErrored<T, Db, Insp = NoOpInspector> =
EvmErrored<Db, Insp, <T as BundleDriver<Db, Insp>>::Error>;

#[allow(unnameable_types, dead_code, unreachable_pub)]
Expand Down