Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Expand Up @@ -86,7 +86,7 @@ concurrent-db = ["dep:dashmap"]

estimate_gas = ["optional_eip3607", "optional_no_base_fee", "dep:tracing"]

test-utils = ["revm/std", "revm/serde-json", "revm/alloydb"]
test-utils = ["revm/std", "revm/serde-json", "revm/alloydb", "alloy/signers", "alloy/signer-local"]

secp256k1 = ["revm/secp256k1"]
c-kzg = ["revm/c-kzg"]
Expand Down
2 changes: 1 addition & 1 deletion src/db/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pub mod sync;

/// Database abstraction traits.
mod traits;
pub use traits::{ArcUpgradeError, CachingDb, StateAcc, TryCachingDb, TryStateAcc};
pub use traits::{ArcUpgradeError, CachingDb, DbConnect, StateAcc, TryCachingDb, TryStateAcc};

/// Cache-on-write database. A memory cache that caches only on write, not on
/// read. Intended to wrap some other caching database.
Expand Down
34 changes: 34 additions & 0 deletions src/db/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,40 @@ use revm::{
};
use std::{collections::BTreeMap, convert::Infallible, sync::Arc};

/// Trait for types that can be used to connect to a database.
///
/// Connectors should contain configuration information like filesystem paths.
/// They are intended to enable parallel instantiation of multiple EVMs in
/// multiple threads sharing some database configuration
///
/// The lifetime on this trait allows the resulting DB to borrow from the
/// connector. E.g. the connector may contain some `Db` and the resulting Db may
/// contain `&Db`. This allows for (e.g.) shared caches between DBs on multiple
/// threads.
pub trait DbConnect: Sync {
/// The database type returned when connecting.
type Database: Database;

/// The error type returned when connecting to the database.
type Error: core::error::Error;

/// Connect to the database.
fn connect(&self) -> Result<Self::Database, Self::Error>;
}

impl<Db> DbConnect for Db
where
Db: Database + Clone + Sync,
{
type Database = Self;

type Error = Infallible;

fn connect(&self) -> Result<Self::Database, Self::Error> {
Ok(self.clone())
}
}

/// Abstraction trait covering types that accumulate state changes into a
/// [`BundleState`]. The prime example of this is [`State`]. These types are
/// use to accumulate state changes during the execution of a sequence of
Expand Down
2 changes: 1 addition & 1 deletion src/driver/bundle.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::{helpers::Ctx, states::EvmBundleDriverErrored, EvmNeedsTx};
use crate::{helpers::Ctx, EvmBundleDriverErrored, EvmNeedsTx};
use revm::{
context::result::EVMError, inspector::NoOpInspector, Database, DatabaseCommit, Inspector,
};
Expand Down
Loading
Loading