-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
//! Check mainnet blocks using [OnDiskStorage] | ||
//! For help, run: `cargo run --example run_on_mdbx -- --help` | ||
|
||
#![allow(missing_docs)] | ||
|
||
use std::{ | ||
fs::File, | ||
io::{BufReader, Error}, | ||
}; | ||
|
||
use alloy_rpc_types::Block; | ||
use clap::Parser; | ||
use pevm::{chain::PevmEthereum, OnDiskStorage, StorageWrapper}; | ||
use revm::db::CacheDB; | ||
|
||
#[path = "../tests/common/mod.rs"] | ||
pub mod common; | ||
|
||
/// Check mainnet blocks using [OnDiskStorage] | ||
#[derive(Parser, Debug)] | ||
#[clap(name = "run_on_mdbx")] | ||
struct Args { | ||
/// Path to MDBX dir | ||
#[clap(long, value_name = "DIR")] | ||
mdbx: String, | ||
/// Path to block.json file | ||
#[clap(long, value_name = "FILE")] | ||
block: String, | ||
} | ||
|
||
fn main() -> Result<(), Error> { | ||
let args = Args::parse(); | ||
|
||
let block: Block = { | ||
let file = File::open(args.block)?; | ||
serde_json::from_reader(BufReader::new(file))? | ||
}; | ||
|
||
let on_disk_storage = OnDiskStorage::open(args.mdbx).map_err(Error::other)?; | ||
let wrapped_storage = StorageWrapper(&on_disk_storage); | ||
let db = CacheDB::new(&wrapped_storage); | ||
|
||
let chain = PevmEthereum::mainnet(); | ||
common::test_execute_alloy(&db, &chain, block, true); | ||
|
||
Ok(()) | ||
} |