-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: EvmBuilder and External Contexts (#888)
* rename main Evm structs, introduce wip external type * tests * Split evm and external context * continue previous commit * wip inspector handle register * add few more handlers for frame and host * Add instruction handle * add instruction handler registration and Inspector wrap * Rm Spec generic, more handlers, start factory * move towards the builder, allow EVM modify * wip on EvmBuilder and modify functionality * EvmBuilder with stages wip * Add wip stages for builer * make handle register simple function, add raw instruction table, split external data from registers * wip on simple builder functions and handler registry * Examples and cleanup * fix lifetime and fmt * Add more handlers, deduct caller, validate tx agains state * All handlers counted, started on docs, some cleanup * renaming and docs * Support all Inspector functionality with Handler * Handler restructured. Documentation added * more docs on registers * integrate builder, fmt, move optimism l1block * add utility builder stage functions * add precompiles, fix bugs with journal spec * spec to generic, optimism build * fix optimism test * fuck macros * clippy and fmt * fix trace block example * ci fixes * Flatten builder stages to generic and handler stage * EvmBuilder doc and refactor fn access * ignore rust code in book * make revme compile, will refactor this in future * Rename handles to Pre/Post Execution and ExecutionLoop * fix optimism clippy * small rename * FrameData and docs * check links mdbook * comments and cleanup * comment * Add initialize interepreter to first frame * clippy * clippy2
- Loading branch information
Showing
60 changed files
with
3,742 additions
and
2,254 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,39 +1,33 @@ | ||
use revm::{ | ||
db::BenchmarkDB, | ||
primitives::{Bytecode, TransactTo, U256}, | ||
Evm, | ||
}; | ||
use std::time::{Duration, Instant}; | ||
use std::time::Duration; | ||
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.database(BenchmarkDB::new_bytecode(Bytecode::new())); | ||
let mut evm = Evm::builder() | ||
.with_db(BenchmarkDB::new_bytecode(Bytecode::new())) | ||
.modify_tx_env(|tx| { | ||
// execution globals block hash/gas_limit/coinbase/timestamp.. | ||
tx.caller = "0x0000000000000000000000000000000000000001" | ||
.parse() | ||
.unwrap(); | ||
tx.value = U256::from(10); | ||
tx.transact_to = TransactTo::Call( | ||
"0x0000000000000000000000000000000000000000" | ||
.parse() | ||
.unwrap(), | ||
); | ||
}) | ||
.build(); | ||
|
||
// Microbenchmark | ||
let bench_options = microbench::Options::default().time(Duration::from_secs(1)); | ||
let bench_options = microbench::Options::default().time(Duration::from_secs(3)); | ||
|
||
microbench::bench(&bench_options, "Simple value transfer", || { | ||
let _ = evm.transact().unwrap(); | ||
}); | ||
|
||
let time = Instant::now(); | ||
for _ in 0..10000 { | ||
let _ = evm.transact().unwrap(); | ||
} | ||
let elapsed = time.elapsed(); | ||
println!("10k runs in {:?}", elapsed.as_nanos() / 10_000); | ||
} |
Oops, something went wrong.