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: frame ctx inside Evm #2044

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
144 changes: 6 additions & 138 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 9 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,21 @@ members = [
"crates/handler",

# variants
"crates/optimism",
# "crates/optimism",
"crates/inspector",

# utility
"crates/statetest-types",

# examples
"examples/block_traces",
"examples/cheatcode_inspector",
"examples/contract_deployment",
"examples/database_components",
"examples/uniswap_get_reserves",
"examples/uniswap_v2_usdc_swap",
"examples/erc20_gas",
#"examples/custom_opcodes",
# "examples/block_traces",
# "examples/cheatcode_inspector",
# "examples/contract_deployment",
# "examples/database_components",
# "examples/uniswap_get_reserves",
# "examples/uniswap_v2_usdc_swap",
# "examples/erc20_gas",
# "examples/custom_opcodes",
]
resolver = "2"
default-members = ["crates/revm"]
Expand Down
7 changes: 4 additions & 3 deletions bins/revme/src/cmd/bench/analysis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use database::{BenchmarkDB, BENCH_CALLER, BENCH_TARGET};
use revm::{
bytecode::Bytecode,
primitives::{bytes, hex, Bytes, TxKind},
Context, ExecuteEvm,
Context, ExecuteEvm, MainBuilder, MainContext,
};

const BYTES: &str = include_str!("analysis.hex");
Expand All @@ -13,15 +13,16 @@ pub fn run() {
let bytecode = Bytecode::new_raw(Bytes::from(hex::decode(BYTES).unwrap()));

// BenchmarkDB is dummy state that implements Database trait.
let mut context = Context::builder()
let mut context = Context::mainnet()
.with_db(BenchmarkDB::new_bytecode(bytecode))
.modify_tx_chained(|tx| {
// Execution globals block hash/gas_limit/coinbase/timestamp..
tx.caller = BENCH_CALLER;
tx.kind = TxKind::Call(BENCH_TARGET);
//evm.env.tx.data = Bytes::from(hex::decode("30627b7c").unwrap());
tx.data = bytes!("8035F0CE");
});
})
.build_mainnet();

let time = Instant::now();
let _ = context.exec_previous();
Expand Down
17 changes: 10 additions & 7 deletions bins/revme/src/cmd/bench/burntpix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use revm::{
database_interface::EmptyDB,
primitives::{hex, keccak256, Address, Bytes, TxKind, B256, U256},
state::{AccountInfo, Bytecode},
transact_main, Context,
transact_main, Context, MainBuilder, MainContext,
};

use std::fs::File;
Expand All @@ -36,12 +36,15 @@ pub fn run() {

let db = init_db();

let mut context = Context::builder().with_db(db).modify_tx_chained(|tx| {
tx.caller = BENCH_CALLER;
tx.kind = TxKind::Call(BURNTPIX_MAIN_ADDRESS);
tx.data = run_call_data.clone().into();
tx.gas_limit = u64::MAX;
});
let mut context = Context::mainnet()
.with_db(db)
.modify_tx_chained(|tx| {
tx.caller = BENCH_CALLER;
tx.kind = TxKind::Call(BURNTPIX_MAIN_ADDRESS);
tx.data = run_call_data.clone().into();
tx.gas_limit = u64::MAX;
})
.build_mainnet();

let started = Instant::now();
let tx_result = transact_main(&mut context).unwrap().result;
Expand Down
9 changes: 5 additions & 4 deletions bins/revme/src/cmd/bench/snailtracer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,21 @@ use database::{BenchmarkDB, BENCH_CALLER, BENCH_TARGET};
use revm::{
bytecode::Bytecode,
primitives::{bytes, hex, Bytes, TxKind},
transact_main, Context,
Context, ExecuteEvm, MainBuilder, MainContext,
};

pub fn simple_example(bytecode: Bytecode) {
let mut context = Context::builder()
let mut evm = Context::mainnet()
.with_db(BenchmarkDB::new_bytecode(bytecode.clone()))
.modify_tx_chained(|tx| {
// Execution globals block hash/gas_limit/coinbase/timestamp..
tx.caller = BENCH_CALLER;
tx.kind = TxKind::Call(BENCH_TARGET);
tx.data = bytes!("30627b7c");
tx.gas_limit = 1_000_000_000;
});
let _ = transact_main(&mut context).unwrap();
})
.build_mainnet();
let _ = evm.exec_previous().unwrap();
}

pub fn run() {
Expand Down
16 changes: 10 additions & 6 deletions bins/revme/src/cmd/bench/transfer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,27 @@ use database::{BenchmarkDB, BENCH_CALLER, BENCH_TARGET};
use revm::{
bytecode::Bytecode,
primitives::{TxKind, U256},
Context, ExecuteEvm,
Context, ExecuteEvm, MainBuilder, MainContext,
};

pub fn run() {
let mut context = Context::builder()
let time = Instant::now();
let mut evm = Context::mainnet()
.with_db(BenchmarkDB::new_bytecode(Bytecode::new()))
.modify_tx_chained(|tx| {
// Execution globals block hash/gas_limit/coinbase/timestamp..
tx.caller = BENCH_CALLER;
tx.kind = TxKind::Call(BENCH_TARGET);
tx.value = U256::from(10);
});
})
.build_mainnet();
println!("Init: {:?}", time.elapsed());

let time = Instant::now();
let _ = context.exec_previous();
println!("First init: {:?}", time.elapsed());
let _ = evm.exec_previous();
println!("First run: {:?}", time.elapsed());

let time = Instant::now();
let _ = context.exec_previous();
let _ = evm.exec_previous();
println!("Run: {:?}", time.elapsed());
}
Loading
Loading