Skip to content

Commit

Permalink
feat: move to tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kien-rise committed Aug 8, 2024
1 parent bdc0491 commit f60e474
Show file tree
Hide file tree
Showing 10 changed files with 224 additions and 281 deletions.
6 changes: 4 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,14 @@ revm = { git = "https://github.com/risechain/revm", rev = "7b42abb672deacde9e053
alloy-provider = "0.2.1"
alloy-transport = "0.2.1"
alloy-transport-http = "0.2.1"
libmdbx = "0.5.0"
reqwest = "0.12.5"
tokio = { version = "1.39.2", features = ["rt-multi-thread"] }

[dev-dependencies]
# MDBX Storage dependencies
libmdbx = "0.5.0"
bincode = "1.3.3"

[dev-dependencies]
clap = { version = "4.5.13", features = ["derive", "env"] }
criterion = "0.5.1"
rand = "0.8.5"
Expand Down
32 changes: 27 additions & 5 deletions benches/mainnet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,28 +25,50 @@ pub fn criterion_benchmark(c: &mut Criterion) {
// with many dependencies.
.min(NonZeroUsize::new(8).unwrap());

common::for_each_block_from_disk(|block, storage| {
common::for_each_block_from_disk(|block, in_memory_storage, on_disk_storage| {
let mut group = c.benchmark_group(format!(
"Block {}({} txs, {} gas)",
block.header.number.unwrap(),
block.transactions.len(),
block.header.gas_used
));
group.bench_function("Sequential", |b| {
group.bench_function("Sequential (in memory)", |b| {
b.iter(|| {
pevm::execute(
black_box(&storage),
black_box(&in_memory_storage),
black_box(&chain),
black_box(block.clone()),
black_box(concurrency_level),
black_box(true),
)
})
});
group.bench_function("Parallel", |b| {
group.bench_function("Parallel (in memory)", |b| {
b.iter(|| {
pevm::execute(
black_box(&storage),
black_box(&in_memory_storage),
black_box(&chain),
black_box(block.clone()),
black_box(concurrency_level),
black_box(false),
)
})
});
group.bench_function("Sequential (in memory)", |b| {
b.iter(|| {
pevm::execute(
black_box(&on_disk_storage),
black_box(&chain),
black_box(block.clone()),
black_box(concurrency_level),
black_box(true),
)
})
});
group.bench_function("Parallel (in memory)", |b| {
b.iter(|| {
pevm::execute(
black_box(&on_disk_storage),
black_box(&chain),
black_box(block.clone()),
black_box(concurrency_level),
Expand Down
47 changes: 0 additions & 47 deletions examples/run_on_mdbx.rs

This file was deleted.

150 changes: 0 additions & 150 deletions examples/to_mdbx.rs

This file was deleted.

4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,8 @@ mod primitives;
mod scheduler;
mod storage;
pub use storage::{
AccountBasic, Bytecodes, EvmAccount, EvmCode, InMemoryStorage, OnDiskStorage, RpcStorage,
Storage, StorageWrapper,
create_db_dir, remove_db_dir, AccountBasic, Bytecodes, EvmAccount, EvmCode, InMemoryStorage,
OnDiskStorage, RpcStorage, Storage, StorageWrapper,
};
mod vm;
pub use vm::{ExecutionError, PevmTxExecutionResult};
Expand Down
4 changes: 1 addition & 3 deletions src/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,9 @@ pub struct EvmAccount {
/// The account's basic information.
pub basic: AccountBasic,
/// The optional code hash of the account.
#[serde(skip_serializing_if = "Option::is_none")]
pub code_hash: Option<B256>,
/// The account's optional code
// TODO: Box this to reduce [EvmAccount]'s stack size?
#[serde(skip_serializing_if = "Option::is_none")]
pub code: Option<EvmCode>,
/// The account's storage.
pub storage: AHashMap<U256, U256>,
Expand Down Expand Up @@ -232,6 +230,6 @@ impl<'a, S: Storage> DatabaseRef for StorageWrapper<'a, S> {
mod in_memory;
pub use in_memory::InMemoryStorage;
mod on_disk;
pub use on_disk::OnDiskStorage;
pub use on_disk::{create_db_dir, remove_db_dir, OnDiskStorage};
mod rpc;
pub use rpc::RpcStorage;
Loading

0 comments on commit f60e474

Please sign in to comment.