Skip to content

Commit 5347cb8

Browse files
committed
wip: split evm
1 parent 6213c9f commit 5347cb8

22 files changed

+3144
-2532
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ concurrent-db = ["dep:dashmap"]
8686

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

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

9191
secp256k1 = ["revm/secp256k1"]
9292
c-kzg = ["revm/c-kzg"]

src/db/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ pub mod sync;
44

55
/// Database abstraction traits.
66
mod traits;
7-
pub use traits::{ArcUpgradeError, CachingDb, StateAcc, TryCachingDb, TryStateAcc};
7+
pub use traits::{ArcUpgradeError, CachingDb, DbConnect, StateAcc, TryCachingDb, TryStateAcc};
88

99
/// Cache-on-write database. A memory cache that caches only on write, not on
1010
/// read. Intended to wrap some other caching database.

src/db/traits.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,40 @@ use revm::{
55
};
66
use std::{collections::BTreeMap, convert::Infallible, sync::Arc};
77

8+
/// Trait for types that can be used to connect to a database.
9+
///
10+
/// Connectors should contain configuration information like filesystem paths.
11+
/// They are intended to enable parallel instantiation of multiple EVMs in
12+
/// multiple threads sharing some database configuration
13+
///
14+
/// The lifetime on this trait allows the resulting DB to borrow from the
15+
/// connector. E.g. the connector may contain some `Db` and the resulting Db may
16+
/// contain `&Db`. This allows for (e.g.) shared caches between DBs on multiple
17+
/// threads.
18+
pub trait DbConnect: Sync {
19+
/// The database type returned when connecting.
20+
type Database: Database;
21+
22+
/// The error type returned when connecting to the database.
23+
type Error: core::error::Error;
24+
25+
/// Connect to the database.
26+
fn connect(&self) -> Result<Self::Database, Self::Error>;
27+
}
28+
29+
impl<Db> DbConnect for Db
30+
where
31+
Db: Database + Clone + Sync,
32+
{
33+
type Database = Self;
34+
35+
type Error = Infallible;
36+
37+
fn connect(&self) -> Result<Self::Database, Self::Error> {
38+
Ok(self.clone())
39+
}
40+
}
41+
842
/// Abstraction trait covering types that accumulate state changes into a
943
/// [`BundleState`]. The prime example of this is [`State`]. These types are
1044
/// use to accumulate state changes during the execution of a sequence of

src/driver/bundle.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::{helpers::Ctx, states::EvmBundleDriverErrored, EvmNeedsTx};
1+
use crate::{helpers::Ctx, EvmBundleDriverErrored, EvmNeedsTx};
22
use revm::{
33
context::result::EVMError, inspector::NoOpInspector, Database, DatabaseCommit, Inspector,
44
};

0 commit comments

Comments
 (0)