Skip to content

Commit

Permalink
fix: revme
Browse files Browse the repository at this point in the history
  • Loading branch information
Wodann committed Jun 24, 2024
1 parent 2881cdf commit cd9c906
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
20 changes: 12 additions & 8 deletions bins/revme/src/cmd/evmrunner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use revm::{
db::BenchmarkDB,
inspector_handle_register,
inspectors::TracerEip3155,
primitives::{Address, Bytecode, TxKind},
Evm,
primitives::{address, Address, Bytecode, TxKind},
Database, Evm,
};
use std::io::Error as IoError;
use std::path::PathBuf;
Expand Down Expand Up @@ -61,6 +61,8 @@ pub struct Cmd {
impl Cmd {
/// Run statetest command.
pub fn run(&self) -> Result<(), Errors> {
const CALLER: Address = address!("0000000000000000000000000000000000000001");

let bytecode_str: Cow<'_, str> = if let Some(path) = &self.path {
// check if path exists.
if !path.exists() {
Expand All @@ -75,19 +77,21 @@ impl Cmd {
let input = hex::decode(self.input.trim())
.map_err(|_| Errors::InvalidInput)?
.into();

let mut db = BenchmarkDB::new_bytecode(Bytecode::new_raw(bytecode.into()));

let nonce = db.basic(CALLER).unwrap().map_or(0, |account| account.nonce);

// BenchmarkDB is dummy state that implements Database trait.
// the bytecode is deployed at zero address.
let mut evm = Evm::builder()
.with_db(BenchmarkDB::new_bytecode(Bytecode::new_raw(
bytecode.into(),
)))
.with_db(db)
.modify_tx_env(|tx| {
// execution globals block hash/gas_limit/coinbase/timestamp..
tx.caller = "0x0000000000000000000000000000000000000001"
.parse()
.unwrap();
tx.caller = CALLER;
tx.transact_to = TxKind::Call(Address::ZERO);
tx.data = input;
tx.nonce = nonce;
})
.build();

Expand Down
2 changes: 2 additions & 0 deletions bins/revme/src/cmd/statetest/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,8 @@ pub fn execute_test_suite(
.get(test.indexes.data)
.unwrap()
.clone();

env.tx.nonce = u64::try_from(unit.transaction.nonce).unwrap();
env.tx.value = unit.transaction.value[test.indexes.value];

env.tx.access_list = unit
Expand Down

0 comments on commit cd9c906

Please sign in to comment.