-
Notifications
You must be signed in to change notification settings - Fork 589
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: separate initial checks (#486)
* wip separate initial checks * tests passing, consolidate some checks * test * feat: add transfer test * temp * Update crates/interpreter/src/gas/calc.rs * / Initial gas that is deducted from the transaction gas limit. * fmt
- Loading branch information
Showing
12 changed files
with
493 additions
and
367 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 |
---|---|---|
|
@@ -15,3 +15,6 @@ name = "analysis" | |
|
||
[[bin]] | ||
name = "snailtracer" | ||
|
||
[[bin]] | ||
name = "transfer" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
use revm::{ | ||
db::BenchmarkDB, | ||
primitives::{Bytecode, TransactTo, U256}, | ||
}; | ||
use std::time::{Duration, Instant}; | ||
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())); | ||
|
||
// Microbenchmark | ||
let bench_options = microbench::Options::default().time(Duration::from_secs(1)); | ||
|
||
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); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/// Interpreter stack limit | ||
pub const STACK_LIMIT: u64 = 1024; | ||
/// EVM call stack limit | ||
pub const CALL_STACK_LIMIT: u64 = 1024; | ||
|
||
/// EIP-170: Contract code size limit | ||
/// By default limit is 0x6000 (~25kb) | ||
pub const MAX_CODE_SIZE: usize = 0x6000; | ||
|
||
/// EIP-3860: Limit and meter initcode | ||
/// | ||
/// Limit of maximum initcode size is 2 * MAX_CODE_SIZE | ||
pub const MAX_INITCODE_SIZE: usize = 2 * MAX_CODE_SIZE; |
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
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
Oops, something went wrong.