Skip to content
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
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ alloy = { version = "1.0.25", default-features = false, features = [
] }

revm = { version = "27.1", default-features = false }
revm-inspectors = { version = "0.27.1", optional = true }
revm-inspectors = { version = "0.27.3", optional = true }

dashmap = { version = "6.1.0", optional = true }
tracing = { version = "0.1.41", optional = true }
Expand Down 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
36 changes: 36 additions & 0 deletions src/db/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,42 @@ 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
///
/// `DbConnect` is blanket implemented for clonable [`Database`] types by
/// simply cloning the database instance. This allows already-instantiated DBs
/// to be used as connectors, however, if the [`Database`] uses a shared
/// resource like a file or network connection, care should be taken to ensure
/// that the implementation does not share uintended state between EVM
/// instances.
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