Skip to content

Commit e1a5fa7

Browse files
authored
chore: fix trevm aliases to use noop by default (#101)
* chore: fix trevm aliases to use noop by default * fix: default to noop in driver traits * refactor: reorder generics in aliases
1 parent 15aff7a commit e1a5fa7

File tree

8 files changed

+40
-35
lines changed

8 files changed

+40
-35
lines changed

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "trevm"
3-
version = "0.20.6"
3+
version = "0.20.7"
44
rust-version = "1.83.0"
55
edition = "2021"
66
authors = ["init4"]

src/driver/alloy.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ where
266266
fn run_bundle(
267267
&mut self,
268268
trevm: crate::EvmNeedsTx<Db, Insp>,
269-
) -> DriveBundleResult<Db, Insp, Self> {
269+
) -> DriveBundleResult<Self, Db, Insp> {
270270
// Check if the block we're in is valid for this bundle. Both must match
271271
trevm_ensure!(
272272
trevm.inner().block.number == self.bundle.block_number,
@@ -403,7 +403,7 @@ where
403403
fn run_bundle(
404404
&mut self,
405405
trevm: crate::EvmNeedsTx<Db, Insp>,
406-
) -> DriveBundleResult<Db, Insp, Self> {
406+
) -> DriveBundleResult<Self, Db, Insp> {
407407
{
408408
// Check if the block we're in is valid for this bundle. Both must match
409409
trevm_ensure!(
@@ -547,7 +547,7 @@ where
547547
fn run_bundle(
548548
&mut self,
549549
trevm: crate::EvmNeedsTx<Db, Insp>,
550-
) -> DriveBundleResult<Db, Insp, Self> {
550+
) -> DriveBundleResult<Self, Db, Insp> {
551551
// Check if the block we're in is valid for this bundle. Both must match
552552
trevm_ensure!(
553553
trevm.inner().block.number == self.block_number,
@@ -638,7 +638,7 @@ where
638638
fn run_bundle(
639639
&mut self,
640640
trevm: crate::EvmNeedsTx<Db, Insp>,
641-
) -> DriveBundleResult<Db, Insp, Self> {
641+
) -> DriveBundleResult<Self, Db, Insp> {
642642
// Check if the block we're in is valid for this bundle. Both must match
643643
trevm_ensure!(
644644
trevm.inner().block.number == self.block_number,

src/driver/block.rs

+9-7
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
use crate::{helpers::Ctx, Block, EvmBlockDriverErrored, EvmNeedsBlock, EvmNeedsTx};
2-
use revm::{context::result::EVMError, Database, DatabaseCommit, Inspector};
2+
use revm::{
3+
context::result::EVMError, inspector::NoOpInspector, Database, DatabaseCommit, Inspector,
4+
};
35

46
/// The result of running transactions for a block driver.
5-
pub type RunTxResult<Db, Insp, T> =
6-
Result<EvmNeedsTx<Db, Insp>, EvmBlockDriverErrored<Db, Insp, T>>;
7+
pub type RunTxResult<T, Db, Insp> =
8+
Result<EvmNeedsTx<Db, Insp>, EvmBlockDriverErrored<T, Db, Insp>>;
79

810
/// The result of driving a block to completion.
9-
pub type DriveBlockResult<Db, Insp, T> =
10-
Result<EvmNeedsBlock<Db, Insp>, EvmBlockDriverErrored<Db, Insp, T>>;
11+
pub type DriveBlockResult<T, Db, Insp> =
12+
Result<EvmNeedsBlock<Db, Insp>, EvmBlockDriverErrored<T, Db, Insp>>;
1113

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

2931
/// Run the transactions for the block.
30-
fn run_txns(&mut self, trevm: EvmNeedsTx<Db, Insp>) -> RunTxResult<Db, Insp, Self>;
32+
fn run_txns(&mut self, trevm: EvmNeedsTx<Db, Insp>) -> RunTxResult<Self, Db, Insp>;
3133
/// Run post
3234
fn post_block(&mut self, trevm: &EvmNeedsBlock<Db, Insp>) -> Result<(), Self::Error>;
3335
}

src/driver/bundle.rs

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
use crate::{helpers::Ctx, states::EvmBundleDriverErrored, EvmNeedsTx};
2-
use revm::{context::result::EVMError, Database, DatabaseCommit, Inspector};
2+
use revm::{
3+
context::result::EVMError, inspector::NoOpInspector, Database, DatabaseCommit, Inspector,
4+
};
35

46
/// The result of driving a bundle to completion.
5-
pub type DriveBundleResult<Db, Insp, T> =
6-
Result<EvmNeedsTx<Db, Insp>, EvmBundleDriverErrored<Db, Insp, T>>;
7+
pub type DriveBundleResult<T, Db, Insp> =
8+
Result<EvmNeedsTx<Db, Insp>, EvmBundleDriverErrored<T, Db, Insp>>;
79

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

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

2123
/// Run post
2224
fn post_bundle(&mut self, trevm: &EvmNeedsTx<Db, Insp>) -> Result<(), Self::Error>;

src/driver/chain.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
use crate::{helpers::Ctx, BlockDriver, EvmChainDriverErrored, EvmNeedsBlock};
22
use revm::{
3-
context::result::EVMError, primitives::hardfork::SpecId, Database, DatabaseCommit, Inspector,
3+
context::result::EVMError, inspector::NoOpInspector, primitives::hardfork::SpecId, Database,
4+
DatabaseCommit, Inspector,
45
};
56

67
/// The result of driving a chain to completion.
7-
pub type DriveChainResult<Db, Insp, D> =
8-
Result<EvmNeedsBlock<Db, Insp>, EvmChainDriverErrored<Db, Insp, D>>;
8+
pub type DriveChainResult<D, Db, Insp> =
9+
Result<EvmNeedsBlock<Db, Insp>, EvmChainDriverErrored<D, Db, Insp>>;
910

1011
/// Driver for a chain of blocks.
11-
pub trait ChainDriver<Db, Insp>
12+
pub trait ChainDriver<Db, Insp = NoOpInspector>
1213
where
1314
Db: Database + DatabaseCommit,
1415
Insp: Inspector<Ctx<Db>>,

src/evm.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -975,7 +975,7 @@ where
975975
{
976976
/// Open a block, apply some logic, and return the EVM ready for the next
977977
/// block.
978-
pub fn drive_block<D>(self, driver: &mut D) -> DriveBlockResult<Db, Insp, D>
978+
pub fn drive_block<D>(self, driver: &mut D) -> DriveBlockResult<D, Db, Insp>
979979
where
980980
D: BlockDriver<Db, Insp>,
981981
Db: DatabaseCommit,
@@ -996,7 +996,7 @@ where
996996
/// # Panics
997997
///
998998
/// If the driver contains no blocks.
999-
pub fn drive_chain<D>(self, driver: &mut D) -> DriveChainResult<Db, Insp, D>
999+
pub fn drive_chain<D>(self, driver: &mut D) -> DriveChainResult<D, Db, Insp>
10001000
where
10011001
D: ChainDriver<Db, Insp>,
10021002
Db: DatabaseCommit,
@@ -1182,7 +1182,7 @@ where
11821182

11831183
/// Drive a bundle to completion, apply some post-bundle logic, and return the
11841184
/// EVM ready for the next bundle or tx.
1185-
pub fn drive_bundle<D>(self, driver: &mut D) -> DriveBundleResult<Db, Insp, D>
1185+
pub fn drive_bundle<D>(self, driver: &mut D) -> DriveBundleResult<D, Db, Insp>
11861186
where
11871187
D: BundleDriver<Db, Insp>,
11881188
Db: DatabaseCommit,

src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@
118118
//! # use revm::{database::in_memory_db::InMemoryDB, inspector::NoOpInspector};
119119
//! # use trevm::{TrevmBuilder, EvmErrored, Cfg, BlockDriver};
120120
//! # use alloy::primitives::B256;
121-
//! # fn t<C: Cfg, D: BlockDriver<NoOpInspector>>(cfg: &C, mut driver: D)
121+
//! # fn t<C: Cfg, D: BlockDriver<InMemoryDB, NoOpInspector>>(cfg: &C, mut driver: D)
122122
//! # -> Result<(), Box<dyn std::error::Error>> {
123123
//! let trevm = TrevmBuilder::new()
124124
//! .with_db(InMemoryDB::default())

src/states.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::{driver::BundleDriver, BlockDriver, ChainDriver, Trevm};
2-
use revm::{context::result::EVMError, Database};
2+
use revm::{context::result::EVMError, inspector::NoOpInspector, Database};
33
use sealed::*;
44

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

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

2424
/// A [`Trevm`] that requires a [`Tx`].
2525
///
@@ -29,46 +29,46 @@ pub type EvmNeedsBlock<Db, Insp> = Trevm<Db, Insp, NeedsBlock>;
2929
/// - [`EvmNeedsTx::finish`]
3030
///
3131
/// [`Tx`]: crate::Tx
32-
pub type EvmNeedsTx<Db, Insp> = Trevm<Db, Insp, NeedsTx>;
32+
pub type EvmNeedsTx<Db, Insp = NoOpInspector> = Trevm<Db, Insp, NeedsTx>;
3333

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

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

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

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

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

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

7474
#[allow(unnameable_types, dead_code, unreachable_pub)]

0 commit comments

Comments
 (0)