Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add transfer bench #485

Closed
wants to merge 1 commit into from
Closed
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
3 changes: 3 additions & 0 deletions bins/revm-test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,6 @@ name = "analysis"

[[bin]]
name = "snailtracer"

[[bin]]
name = "transfer"
37 changes: 37 additions & 0 deletions bins/revm-test/src/bin/transfer.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
use std::time::Duration;
use revm::{
db::BenchmarkDB,
primitives::{Bytecode, TransactTo, U256},
};
extern crate alloc;

fn main() {
// BenchmarkDB is dummy state that implements Database trait.
let mut evm = revm::new();

// execution globals block hash/gas_limit/coinbase/timestamp..
evm.env.tx.caller = "0x0000000000000000000000000000000000000001"
.parse()
.unwrap();
evm.env.tx.value = U256::from(10);
evm.env.tx.transact_to = TransactTo::Call(
"0x0000000000000000000000000000000000000000"
.parse()
.unwrap(),
);
//evm.env.tx.data = Bytes::from(hex::decode("30627b7c").unwrap());
evm.env.cfg.perf_all_precompiles_have_balance = true;

evm.database(BenchmarkDB::new_bytecode(Bytecode::new()));

// Microbenchmark
let bench_options = microbench::Options::default().time(Duration::from_secs(1));

microbench::bench(
&bench_options,
"Simple value transfer",
|| {
let _ = evm.transact().unwrap();
},
);
}
8 changes: 8 additions & 0 deletions crates/revm/src/db/in_memory_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,14 @@ impl Database for BenchmarkDB {
code_hash: self.1,
}));
}
if address == B160::from(1) {
return Ok(Some(AccountInfo {
nonce: 0,
balance: U256::from(10000000),
code: None,
code_hash: KECCAK_EMPTY,
}));
}
Ok(None)
}

Expand Down