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(interpreter): Unify instruction fn signature #283

Merged
merged 6 commits into from
Dec 9, 2022
Merged
Show file tree
Hide file tree
Changes from 5 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
49 changes: 29 additions & 20 deletions Cargo.lock

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

7 changes: 2 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,10 @@ members = [
default-members = ["crates/revm"]

[profile.release]
# debug = true
debug = true
rakita marked this conversation as resolved.
Show resolved Hide resolved
lto = true
codegen-units = 1

[profile.ethtests]
inherits = "test"
opt-level = 3

[patch.crates-io]
ruint = { git = "https://github.com/recmo/uint" }
opt-level = 3
1 change: 1 addition & 0 deletions bins/revm-test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ edition = "2021"
bytes = "1.1"
hex = "0.4"
revm = { path = "../../crates/revm", version = "2.3.1" }
microbench = "0.5"

[[bin]]
name = "analysis"
Expand Down
1 change: 0 additions & 1 deletion bins/revm-test/src/bin/analysis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use std::time::Instant;

use bytes::Bytes;
use revm::{db::BenchmarkDB, Bytecode, TransactTo};

extern crate alloc;

fn main() {
Expand Down
21 changes: 6 additions & 15 deletions bins/revm-test/src/bin/snailtracer.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::time::Instant;
use std::time::Duration;

use bytes::Bytes;
use revm::{db::BenchmarkDB, Bytecode, TransactTo};
Expand All @@ -23,21 +23,12 @@ pub fn simple_example() {
);
evm.env.tx.data = Bytes::from(hex::decode("30627b7c").unwrap());

let mut elapsed = std::time::Duration::ZERO;
let mut times = Vec::new();
for _ in 0..30 {
let timer = Instant::now();
// Microbenchmark
let bench_options = microbench::Options::default().time(Duration::from_secs(3));

microbench::bench(&bench_options, "Snailtracer benchmark", || {
rakita marked this conversation as resolved.
Show resolved Hide resolved
let (_, _) = evm.transact();
rakita marked this conversation as resolved.
Show resolved Hide resolved
let i = timer.elapsed();
times.push(i);
elapsed += i;
}
println!("elapsed: {:?}", elapsed / 30);
let mut times = times[5..].to_vec();
times.sort();
for (i, time) in times.iter().rev().enumerate() {
println!("{i}: {time:?}");
}
});
}

fn main() {
Expand Down
3 changes: 1 addition & 2 deletions bins/revme/src/statetest/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,7 @@ pub fn execute_test_suit(path: &Path, elapsed: &Arc<Mutex<Duration>>) -> Result<
let db = evm.db().unwrap();
println!("{path:?} UNIT_TEST:{name}\n");
println!(
"failed reason: {:?} {:?} UNIT_TEST:{}\n gas:{:?} ({:?} refunded)",
exit_reason, path, name, gas_used, gas_refunded,
"failed reason: {exit_reason:?} {path:?} UNIT_TEST:{name}\n gas:{gas_used:?} ({gas_refunded:?} refunded)",
);
println!("\nApplied state:{db:?}\n");
println!("\nStateroot: {state_root:?}\n");
Expand Down
2 changes: 1 addition & 1 deletion crates/revm/src/bits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ mod serialize {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
match *self {
Self::InvalidHex { character, index } => {
write!(fmt, "invalid hex character: {}, at {}", character, index)
write!(fmt, "invalid hex character: {character}, at {index}")
}
}
}
Expand Down
1 change: 1 addition & 0 deletions crates/revm/src/db/web3db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ impl Database for Web3DB {
}

fn block_hash(&mut self, number: U256) -> Result<B256, Self::Error> {
// saturate usize
if number > U256::from(u64::MAX) {
return Ok(KECCAK_EMPTY);
}
Expand Down
1 change: 0 additions & 1 deletion crates/revm/src/evm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ use revm_precompiles::Precompiles;
/// want to update anything on it. It enabled `transact_ref` and `inspect_ref` functions
/// * Database+DatabaseCommit allow directly committing changes of transaction. it enabled `transact_commit`
/// and `inspect_commit`

#[derive(Clone)]
pub struct EVM<DB> {
pub env: Env,
Expand Down
Loading