Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: init4tech/trevm
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.18.0
Choose a base ref
...
head repository: init4tech/trevm
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: main
Choose a head ref

Commits on Jan 7, 2025

  1. v0.18.0 (#72)

    Evalir authored Jan 7, 2025
    Copy the full SHA
    c4cc25a View commit details

Commits on Jan 8, 2025

  1. chore: move Block impl for ZenithCallBundle to trevm (#73)

    As we moved out these types to zenith-types, we need to move this type impl here.
    
    Closes ENG-728
    Evalir authored Jan 8, 2025
    Copy the full SHA
    f771d1d View commit details

Commits on Jan 27, 2025

  1. fix: small docs improvements (#74)

    * fix: small docs improvements
    
    * fix: grammar
    anna-carroll authored Jan 27, 2025
    Copy the full SHA
    e86f6c2 View commit details
  2. v0.19.0 - revm 0.19.0

    prestwich committed Jan 27, 2025
    Copy the full SHA
    7b63461 View commit details

Commits on Jan 31, 2025

  1. feat: impl tx for transactionrequest (#75)

    * feat: impl tx for transactionrequest
    
    * feat: block overrides
    
    * feat: apply block and state overrides
    
    * chore: bump version
    prestwich authored Jan 31, 2025
    Copy the full SHA
    f5f7fcc View commit details
  2. Copy the full SHA
    a29c7f9 View commit details

Commits on Feb 4, 2025

  1. feat: estimation (#77)

    * feat: estimation
    
    * fix: use a max
    
    * feat: shortcut for estimate_tx_gas
    
    * fix: callee_account
    
    * fix: callee_account
    
    * nit: gas allowance
    
    * lint: clippy
    
    * doc: fixlink
    
    * nit: remove
    
    * chore: doc algorithm
    
    * refactor: clean up and add a macro
    
    * nit: search
    
    * refactor: search range
    
    * docs: add one
    
    * refactor: more cleaning
    
    * nit: add more comments
    
    * feat: blanket impl Block, Tx, Cfg for Fn() types
    
    * chore: bump version
    
    * refactor: use maybeuninit to save a tiny amount of resources
    
    * nits: clean up some naming
    prestwich authored Feb 4, 2025
    Copy the full SHA
    74cb161 View commit details

Commits on Feb 5, 2025

  1. Copy the full SHA
    19d8bca View commit details

Commits on Feb 20, 2025

  1. fix: gas estimation for simple transfers (#78)

    * fix: gas estimation for simple transfers
    
    * fix: concurrent state link
    
    * Update evm.rs
    
    Co-authored-by: evalir <e@evalir.xyz>
    
    * Update evm.rs
    
    Co-authored-by: evalir <e@evalir.xyz>
    
    * fix: calu
    
    ---------
    
    Co-authored-by: evalir <e@evalir.xyz>
    prestwich and Evalir authored Feb 20, 2025
    Copy the full SHA
    ea840af View commit details
  2. Always set randao in alloy block filler (#79)

    * fix: always set prevrandao
    
    * chore: bump version and note
    prestwich authored Feb 20, 2025
    Copy the full SHA
    9085282 View commit details

Commits on Feb 23, 2025

  1. Copy the full SHA
    96605c9 View commit details

Commits on Feb 24, 2025

  1. Allowance interface tweaks (#80)

    * feat: more allowance features
    
    * chore: version and readme
    
    * fix: clean up no-default and all-features
    
    * fix: docs
    
    * feat: cap gas on tx
    
    * fix: estimation midpoint
    
    * fix: estimation result
    
    * feat: misc tracing
    prestwich authored Feb 24, 2025
    Copy the full SHA
    591208c View commit details
  2. fix: optional tracing

    prestwich committed Feb 24, 2025
    Copy the full SHA
    57fbf51 View commit details

Commits on Feb 26, 2025

  1. feat(ci): feature checks (#82)

    * feat(ci): feature checks
    
    Closes ENG-833. Adds feature checks to the CI.
    
    * chore: use actions-homed action
    
    * chore: repushing don't mind me
    Evalir authored Feb 26, 2025
    Copy the full SHA
    26459ff View commit details
  2. chore: bump alloy and zenith deps (#83)

    * chore: bump alloy and zenith deps
    
    * fix: in test too
    prestwich authored Feb 26, 2025
    Copy the full SHA
    4b8add3 View commit details

Commits on Feb 27, 2025

  1. Trim commit bounds (#84)

    * refactor: remove DatabaseCommit bounds wherever possible
    
    * nit: import
    prestwich authored Feb 27, 2025
    Copy the full SHA
    f83eed9 View commit details
  2. feat: traits for things that behave like State (#85)

    * feat: traits for things that behave like State
    
    * chore: version
    
    * doc: add note
    prestwich authored Feb 27, 2025
    Copy the full SHA
    21f33a7 View commit details

Commits on Mar 4, 2025

  1. Copy the full SHA
    ad3965b View commit details
  2. feat: child db for concurrent state (#87)

    * fix: restore commit bounds to drivers
    
    * feat: child db for concurrent state
    
    * tests: write em
    
    * test: even more stuff
    
    * chore: bump version
    
    * chore: lints and doclinks
    prestwich authored Mar 4, 2025
    Copy the full SHA
    121563a View commit details
  3. fix: Unswap block overrides methods (#88)

    * fix: why were these swapped?
    
    * chore: bump version
    prestwich authored Mar 4, 2025
    Copy the full SHA
    747c725 View commit details

Commits on Mar 11, 2025

  1. Copy the full SHA
    905b947 View commit details

Commits on Mar 17, 2025

  1. Copy the full SHA
    2b4e88e View commit details

Commits on Mar 18, 2025

  1. refactor: trevm_try (#92)

    prestwich authored Mar 18, 2025
    Copy the full SHA
    b58a5b4 View commit details

Commits on Mar 27, 2025

  1. Dep: update revm to 20 (#94)

    * wip
    
    * wip
    
    * wip
    
    * fixing
    
    * chore: fix doctests
    
    * fix: doclinks
    
    * lint: clippy
    
    * chore: depend on stable
    
    * nit:
    
    * docs: slight cleanup
    
    * chore: update example
    
    * chore: fix examples
    
    * nit: remove note
    
    * chore: clean up syscalls
    
    * docs: slight cleanup
    
    * Update src/builder.rs
    
    Co-authored-by: evalir <e@evalir.xyz>
    
    ---------
    
    Co-authored-by: evalir <e@evalir.xyz>
    prestwich and Evalir authored Mar 27, 2025
    Copy the full SHA
    11f6ab9 View commit details
  2. fix: remove wildcard

    prestwich committed Mar 27, 2025
    Copy the full SHA
    6928dcb View commit details
  3. feat: cow (#93)

    * feat: cow
    
    * lint: clippy
    
    * chore: update for revm@20
    
    * fix: doclinks
    
    * fix: copyright notice
    prestwich authored Mar 27, 2025
    Copy the full SHA
    247e156 View commit details
  4. fix: remove dbgs

    prestwich committed Mar 27, 2025
    Copy the full SHA
    67050c7 View commit details
  5. Set chain id in simulation fillers (#95)

    * fix: set chain id in gas estimation and call
    
    * fix: import
    
    * chore: version
    prestwich authored Mar 27, 2025
    Copy the full SHA
    f82e063 View commit details
  6. feat: disable nonce checks

    prestwich committed Mar 27, 2025
    Copy the full SHA
    3366506 View commit details
  7. fix: add inspector bounds and always inspect (#96)

    * fix: add inspector bounds and always inspect
    
    * chore: version bump
    
    * fix: doclink
    prestwich authored Mar 27, 2025
    Copy the full SHA
    9a79e24 View commit details

Commits on Apr 3, 2025

  1. feature: utility inspectors (#98)

    * feat: a couple utility inspectors
    
    * feat: inspector stack
    
    * lint: clippy
    
    * feat: stack vs layered
    
    * fix: allow instantiating layered
    
    * fix: trace syscalls and change fail values
    
    * lint: clippy
    
    * chore: better docs
    prestwich authored Apr 3, 2025
    Copy the full SHA
    293eaef View commit details

Commits on Apr 4, 2025

  1. Copy the full SHA
    f7252a1 View commit details
  2. fix: db in driver traits again (#100)

    * fix: db in driver traits again
    
    * chore: clippy
    
    * chore: bump version to 0.20.6
    prestwich authored Apr 4, 2025
    Copy the full SHA
    15aff7a View commit details

Commits on Apr 6, 2025

  1. 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
    prestwich authored Apr 6, 2025
    Copy the full SHA
    e1a5fa7 View commit details

Commits on Apr 10, 2025

  1. feat: cachingdb traits (#102)

    * feat: cachingdb traits
    
    * chore: bump version
    
    * lint: clippy
    prestwich authored Apr 10, 2025
    Copy the full SHA
    7840c2a View commit details
  2. feat: extend and extend_ref (#103)

    * feat: extend and extend_ref
    
    * lint: clippy
    
    * lint: fmt
    prestwich authored Apr 10, 2025
    Copy the full SHA
    5fcdf50 View commit details

Commits on Apr 14, 2025

  1. Copy the full SHA
    3dba391 View commit details
Showing with 4,378 additions and 1,359 deletions.
  1. +2 −3 .github/workflows/rust-ci.yml
  2. +41 −0 CONTRIBUTING.md
  3. +17 −21 Cargo.toml
  4. +15 −0 README.md
  5. +19 −14 examples/basic_transact.rs
  6. +14 −12 examples/{fork_ref_transact.rs.bak → fork_ref_transact.rs}
  7. +63 −0 src/builder.rs
  8. +30 −29 src/connect.rs
  9. +289 −0 src/db/cow/mod.rs
  10. +9 −41 src/db/mod.rs
  11. +4 −4 src/db/{ → sync}/builder.rs
  12. +20 −6 src/db/{cache_state.rs → sync/cache.rs}
  13. +1 −0 src/db/sync/child.rs
  14. +25 −0 src/db/sync/error.rs
  15. +37 −0 src/db/sync/mod.rs
  16. +229 −104 src/db/{sync_state.rs → sync/state.rs}
  17. +272 −0 src/db/traits.rs
  18. +110 −109 src/driver/alloy.rs
  19. +16 −17 src/driver/block.rs
  20. +14 −14 src/driver/bundle.rs
  21. +17 −13 src/driver/chain.rs
  22. +293 −0 src/est.rs
  23. +1,169 −279 src/evm.rs
  24. +12 −7 src/ext.rs
  25. +182 −107 src/fill/alloy.rs
  26. +125 −0 src/fill/fillers.rs
  27. +4 −56 src/fill/mod.rs
  28. +1 −1 src/fill/noop.rs
  29. +105 −21 src/fill/traits.rs
  30. +0 −81 src/fill/zenith.rs
  31. +18 −0 src/helpers.rs
  32. +145 −0 src/inspectors/layer.rs
  33. +38 −0 src/inspectors/mod.rs
  34. +154 −0 src/inspectors/set.rs
  35. +220 −0 src/inspectors/spanning.rs
  36. +155 −0 src/inspectors/timeout.rs
  37. +18 −50 src/journal/coder.rs
  38. +12 −8 src/journal/index.rs
  39. +4 −4 src/journal/mod.rs
  40. +76 −74 src/lib.rs
  41. +8 −4 src/lifecycle/output.rs
  42. +1 −1 src/lifecycle/postflight.rs
  43. +3 −3 src/lifecycle/receipt.rs
  44. +30 −0 src/macros.rs
  45. +35 −132 src/states.rs
  46. +26 −19 src/system/eip2935.rs
  47. +14 −8 src/system/eip4788.rs
  48. +16 −11 src/system/eip4895.rs
  49. +11 −7 src/system/eip6110.rs
  50. +17 −14 src/system/eip7002.rs
  51. +19 −15 src/system/eip7251.rs
  52. +20 −17 src/system/fill.rs
  53. +56 −23 src/system/mod.rs
  54. +147 −30 src/test_utils.rs
5 changes: 2 additions & 3 deletions .github/workflows/rust-ci.yml
Original file line number Diff line number Diff line change
@@ -5,10 +5,9 @@ on:
push:
branches: [main]
pull_request:

env:
CARGO_TERM_COLOR: always

jobs:
rust-base:
uses: init4tech/actions/.github/workflows/rust-base.yml@main
rust-library-base:
uses: init4tech/actions/.github/workflows/rust-library-base.yml@main
41 changes: 41 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Contributing to Trevm

:balloon: Thanks for your help improving the project! We are so happy to have
you!

## Conduct

This repo adheres to the [Rust Code of Conduct][coc]. This describes
the _minimum_ behavior expected from all contributors. Failure to maintain civil
behavior will result in a ban.

[coc]: https://www.rust-lang.org/policies/code-of-conduct

## Pull Requests

Before making a large change, it is usually a good idea to first open an issue
describing the change to solicit feedback and guidance. This will increase the
likelihood of the PR getting merged.

When opening a PR **please select the "Allow Edits From Maintainers" option**.
We maintain code quality and style standards, and require commit signing. This
option allows us to make small changes to your PR to bring it in line with
these standards. It helps us get your PR in faster, and with less work from you.

## Development Basics

Before submitting a PR we recommend you run the following commands to ensure
your code is properly formatted and passes all tests:

```sh
cargo +nightly fmt --all
cargo clippy --all-features
cargo test --all-features
cargo test --no-default-features
```

### Contributions Related to Spelling, Grammar, and other trivial changes

At this time, we will not be accepting contributions that only fix spelling or
grammatical errors in documentation, code or
elsewhere.
38 changes: 17 additions & 21 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "trevm"
version = "0.17.0"
rust-version = "1.82.0"
version = "0.20.10"
rust-version = "1.83.0"
edition = "2021"
authors = ["init4"]
homepage = "https://github.com/init4tech/trevm"
@@ -27,27 +27,23 @@ option-if-let-else = "warn"
redundant-clone = "warn"

[dependencies]
alloy-rlp = { version = "0.3.10", default-features = false, features = ["std"]}
alloy = { version = "0.12.6", default-features = false, features = ["consensus", "rpc-types-mev", "eips", "k256", "std", "rlp", "sol-types"] }

alloy-primitives = { version = "0.8.11", default-features = false, features = ["std"]}
alloy-sol-types = { version = "0.8.11", default-features = false, features = ["std"]}

alloy = { version = "=0.7.3", default-features = false, features = ["consensus", "rpc-types-mev", "eips", "k256", "std"] }

revm = { version = "18.0.0", default-features = false, features = ["std"] }

zenith-types = { version = "0.11" }
revm = { version = "20.0.0", default-features = false }

dashmap = { version = "6.1.0", optional = true }
tracing = { version = "0.1.41", optional = true}
thiserror = "2.0.11"

[dev-dependencies]
alloy-rlp = { version = "0.3", default-features = false }
revm = { version = "18.0.0", features = [
"test-utils",
revm = { version = "20.0.0", features = [
"serde-json",
"std",
"alloydb",
] }
trevm = { path = ".", features = ["test-utils"] }

alloy = { version = "0.12.6", features = ["providers"]}

# misc
eyre = "0.6"
@@ -57,17 +53,23 @@ tokio = { version = "1.39", features = ["macros", "rt-multi-thread"] }

[features]
default = [
"call",
"concurrent-db",
"estimate_gas",
"revm/std",
"revm/c-kzg",
"revm/blst",
"revm/portable",
"revm/secp256k1",
]

call = ["optional_eip3607", "optional_no_base_fee"]

concurrent-db = ["dep:dashmap"]

test-utils = ["revm/test-utils", "revm/std", "revm/serde-json", "revm/alloydb"]
estimate_gas = ["optional_eip3607", "optional_no_base_fee", "dep:tracing"]

test-utils = ["revm/std", "revm/serde-json", "revm/alloydb"]

secp256k1 = ["revm/secp256k1"]
c-kzg = ["revm/c-kzg"]
@@ -80,23 +82,17 @@ dev = [
"optional_balance_check",
"optional_block_gas_limit",
"optional_eip3607",
"optional_gas_refund",
"optional_no_base_fee",
"optional_beneficiary_reward",
]

memory_limit = ["revm/memory_limit"]
optional_balance_check = ["revm/optional_balance_check"]
optional_beneficiary_reward = ["revm/optional_beneficiary_reward"]
optional_block_gas_limit = ["revm/optional_block_gas_limit"]
optional_eip3607 = ["revm/optional_eip3607"]
optional_gas_refund = ["revm/optional_gas_refund"]
optional_no_base_fee = ["revm/optional_no_base_fee"]
full_env_cfg = [
"optional_balance_check",
"optional_block_gas_limit",
"optional_eip3607",
"optional_gas_refund",
"optional_no_base_fee",
"optional_beneficiary_reward",
]
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -28,6 +28,21 @@ Trevm is useful for:
- searchers
- any other transaction simulation usecase

## Note on Trevm Versioning

Trevm generally uses [semantic versioning](https://semver.org/). While pre-1.0,
we also strive to indicate the MAJOR version of revm in the MINOR version of
trevm. For example, trevm `0.19.x` SHOULD BE compatible with revm `19.x.x`. In
general, we will try to maintain compatibility with the latest revm version,
and will not backport trevm fixes to older trevm or revm versions. It is
generally not advised to use old revm versions, as the EVM is a living spec.

In order to maintain this relationship (that trevm MINOR == revm MAJOR) we will
sometimes make breaking changes in patch versions. This is technically semver
compliant pre-1.0, but will cause build breakage downstream for users of those
features. We will take care to document breaking changes in patch releases
via github release notes.

## Limitations

Trevm is a work in progress and is not feature complete. In particular, trevm
33 changes: 19 additions & 14 deletions examples/basic_transact.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
//! Simple TREVM example that demonstrates how to execute a transaction on a contract.
//! It simply loads the contract bytecode and executes a transaction.
use revm::context::TransactTo;
use trevm::{
revm::{
inspector_handle_register,
inspectors::TracerEip3155,
primitives::{hex, AccountInfo, Address, Bytecode, TransactTo, U256},
EvmBuilder, InMemoryDB,
bytecode::Bytecode,
database::InMemoryDB,
inspector::inspectors::TracerEip3155,
primitives::{hex, Address, U256},
state::AccountInfo,
},
trevm_aliases, NoopBlock, NoopCfg, TrevmBuilder, Tx,
};
@@ -27,18 +29,18 @@ const CALLER_ADDR: Address = Address::with_last_byte(1);
struct SampleTx;

impl Tx for SampleTx {
fn fill_tx_env(&self, tx_env: &mut revm::primitives::TxEnv) {
fn fill_tx_env(&self, tx_env: &mut revm::context::TxEnv) {
tx_env.caller = CALLER_ADDR;
tx_env.transact_to = TransactTo::Call(CONTRACT_ADDR);
tx_env.kind = TransactTo::Call(CONTRACT_ADDR);
tx_env.data = hex::decode(PROGRAM_INPUT).unwrap().into();
}
}

// Produce aliases for the Trevm type
trevm_aliases!(TracerEip3155, InMemoryDB);

fn main() {
let mut db = revm::InMemoryDB::default();
fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut db = revm::database::InMemoryDB::default();

let bytecode = Bytecode::new_raw(hex::decode(CONTRACT_BYTECODE).unwrap().into());
let acc_info = AccountInfo::new(U256::ZERO, 1, bytecode.hash_slow(), bytecode);
@@ -47,18 +49,19 @@ fn main() {
db.insert_contract(&mut acc_info.clone());
db.insert_account_info(CONTRACT_ADDR, acc_info);

let evm = EvmBuilder::default()
let insp = TracerEip3155::new(Box::new(std::io::stdout()));

let trevm = TrevmBuilder::new()
.with_db(db)
.with_external_context(TracerEip3155::new(Box::new(std::io::stdout())))
.append_handler_register(inspector_handle_register)
.build_trevm()
.with_insp(insp)
.build_trevm()?
.fill_cfg(&NoopCfg)
.fill_block(&NoopBlock);

let account = evm.read_account_ref(CONTRACT_ADDR).unwrap();
let account = trevm.read_account_ref(CONTRACT_ADDR).unwrap();
println!("account: {account:?}");

let evm = evm.fill_tx(&SampleTx).run();
let evm = trevm.fill_tx(&SampleTx).run();

match evm {
Ok(res) => {
@@ -69,4 +72,6 @@ fn main() {
println!("Execution error: {e:?}");
}
};

Ok(())
}
26 changes: 14 additions & 12 deletions examples/fork_ref_transact.rs.bak → examples/fork_ref_transact.rs
Original file line number Diff line number Diff line change
@@ -3,14 +3,16 @@
//! This example is currently disabled while waiting for revm @ 14.0.4
use alloy::{eips::BlockId, providers::ProviderBuilder};
use alloy_primitives::{address, Address, TxKind, U256};
use alloy_sol_types::{sol, SolCall};
use alloy::{
eips::BlockId,
primitives::{address, Address, TxKind, U256},
providers::ProviderBuilder,
sol,
sol_types::SolCall,
};
use revm::{context::TxEnv, database::WrapDatabaseAsync};
use trevm::{
revm::{
db::{AlloyDB, CacheDB},
Evm,
},
revm::database::{AlloyDB, CacheDB},
NoopBlock, NoopCfg, TrevmBuilder, Tx,
};

@@ -22,10 +24,10 @@ sol! {
struct GetReservesFiller;

impl Tx for GetReservesFiller {
fn fill_tx_env(&self, tx_env: &mut revm::primitives::TxEnv) {
fn fill_tx_env(&self, tx_env: &mut TxEnv) {
tx_env.caller = Address::with_last_byte(0);
// ETH/USDT pair on Uniswap V2
tx_env.transact_to = TxKind::Call(POOL_ADDRESS);
tx_env.kind = TxKind::Call(POOL_ADDRESS);
// calldata formed via alloy's abi encoder
tx_env.data = getReservesCall::new(()).abi_encode().into();
// transaction value in wei
@@ -55,15 +57,15 @@ async fn main() -> eyre::Result<()> {
// =========================================================== //

// initialize new AlloyDB
let alloydb = AlloyDB::new(client, BlockId::default()).unwrap();
let alloydb = WrapDatabaseAsync::new(AlloyDB::new(client, BlockId::default())).unwrap();

// initialise empty in-memory-db
let cache_db = CacheDB::new(alloydb);

// initialise an empty (default) EVM
let evm = Evm::builder()
let evm = TrevmBuilder::new()
.with_db(cache_db)
.build_trevm()
.build_trevm()?
.fill_cfg(&NoopCfg)
.fill_block(&NoopBlock)
.fill_tx(&GetReservesFiller)
63 changes: 63 additions & 0 deletions src/builder.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
use crate::{evm::Trevm, helpers::Ctx, states::EvmNeedsCfg};
use revm::{
database::in_memory_db::InMemoryDB, inspector::NoOpInspector, primitives::hardfork::SpecId,
Database, Inspector, MainBuilder,
};

/// Error that can occur when building a Trevm instance.
#[derive(Debug, Clone, thiserror::Error)]
#[non_exhaustive]
pub enum TrevmBuilderError {
/// Database not set.
#[error("Database not set")]
DatabaseNotSet,
}

/// A builder for [`Trevm`] that allows configuring the EVM.
#[derive(Debug, Clone)]
pub struct TrevmBuilder<Db, Insp> {
pub(crate) db: Option<Db>,
pub(crate) insp: Insp,
pub(crate) spec: SpecId,
}

impl TrevmBuilder<InMemoryDB, NoOpInspector> {
/// Create a new builder with the default database and inspector.
#[allow(clippy::new_without_default)] // default would make bad devex :(
pub const fn new() -> Self {
Self { db: None, insp: NoOpInspector, spec: SpecId::PRAGUE }
}
}

impl<Db, Insp> TrevmBuilder<Db, Insp> {
/// Set the database for the EVM.
pub fn with_db<Odb>(self, db: Odb) -> TrevmBuilder<Odb, Insp>
where
Db: Database,
{
TrevmBuilder { db: Some(db), insp: self.insp, spec: self.spec }
}

/// Set the inspector for the EVM.
pub fn with_insp<OInsp>(self, insp: OInsp) -> TrevmBuilder<Db, OInsp> {
TrevmBuilder { db: self.db, insp, spec: self.spec }
}

/// Set the spec id for the EVM.
pub const fn with_spec_id(mut self, spec: SpecId) -> Self {
self.spec = spec;
self
}

/// Build the Trevm instance.
pub fn build_trevm(self) -> Result<EvmNeedsCfg<Db, Insp>, TrevmBuilderError>
where
Db: Database,
Insp: Inspector<Ctx<Db>>,
{
let db = self.db.ok_or(TrevmBuilderError::DatabaseNotSet)?;
let ctx = Ctx::new(db, self.spec);
let evm = ctx.build_mainnet_with_inspector(self.insp);
Ok(Trevm::from(evm))
}
}
Loading