Skip to content

Commit

Permalink
revm v1.9 bytecode hash (#2677)
Browse files Browse the repository at this point in the history
* revm v1.9: bytecode hash

* update storage test json file

Co-authored-by: Matthias Seitz <[email protected]>
  • Loading branch information
rakita and mattsse authored Aug 9, 2022
1 parent af94ad1 commit 50fbe82
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 11 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

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

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,6 @@ debug = 0
#ethers-signers = { path = "../ethers-rs/ethers-signers" }
#ethers-etherscan = { path = "../ethers-rs/ethers-etherscan" }
#ethers-solc = { path = "../ethers-rs/ethers-solc" }

#[patch.crates-io]
#revm = { path = "../../revm/crates/revm" }
1 change: 1 addition & 0 deletions anvil/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,7 @@ impl NodeConfig {
cfg: CfgEnv {
spec_id: self.get_hardfork().into(),
chain_id: self.get_chain_id().into(),
limit_contract_code_size: usize::MAX,
..Default::default()
},
block: BlockEnv {
Expand Down
2 changes: 1 addition & 1 deletion evm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ once_cell = "1.13"
# EVM
bytes = "1.1.0"
hashbrown = { version = "0.12", features = ["serde"] }
revm = { version = "1.8", default-features = false, features = ["std", "k256", "with-serde", "memory_limit"] }
revm = { version = "1.9", default-features = false, features = ["std", "k256", "with-serde", "memory_limit"] }

# Fuzzer
proptest = "1.0.0"
Expand Down
1 change: 1 addition & 0 deletions evm/src/executor/fork/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ where
cfg: CfgEnv {
chain_id: override_chain_id.unwrap_or(rpc_chain_id.as_u64()).into(),
memory_limit,
limit_contract_code_size: usize::MAX,
..Default::default()
},
block: BlockEnv {
Expand Down
6 changes: 2 additions & 4 deletions evm/src/executor/inspector/cheatcodes/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ use crate::abi::HEVMCalls;
use bytes::Bytes;
use ethers::{
abi::{self, AbiEncode, RawLog, Token, Tokenizable, Tokenize},
types::{Address, H256, U256},
utils::keccak256,
types::{Address, U256},
};
use revm::{Bytecode, Database, EVMData};

Expand Down Expand Up @@ -171,11 +170,10 @@ pub fn apply<DB: Database>(
}
HEVMCalls::Etch(inner) => {
let code = inner.1.clone();
let hash = H256::from_slice(&keccak256(&code));

// TODO: Does this increase gas usage?
data.subroutine.load_account(inner.0, data.db);
data.subroutine.set_code(inner.0, Bytecode::new_raw(code.0).to_checked(), hash);
data.subroutine.set_code(inner.0, Bytecode::new_raw(code.0).to_checked());
Ok(Bytes::new())
}
HEVMCalls::Deal(inner) => {
Expand Down
3 changes: 1 addition & 2 deletions evm/src/executor/inspector/cheatcodes/expect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,7 @@ pub fn apply<DB: Database>(
.unwrap_or(true)
{
let code = Bytecode::new_raw(Bytes::from_static(&[0u8])).to_checked();
let code_hash = code.hash();
data.subroutine.set_code(inner.0, code, code_hash);
data.subroutine.set_code(inner.0, code);
}
state.mocked_calls.entry(inner.0).or_default().insert(
MockCallDataContext { calldata: inner.1.to_vec().into(), value: None },
Expand Down
2 changes: 2 additions & 0 deletions evm/src/executor/opts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,9 @@ impl EvmOpts {
chain_id: self.env.chain_id.unwrap_or(foundry_common::DEV_CHAIN_ID).into(),
spec_id: SpecId::LONDON,
perf_all_precompiles_have_balance: false,
limit_contract_code_size: usize::MAX,
memory_limit: self.memory_limit,
..Default::default()
},
tx: TxEnv {
gas_price: self.env.gas_price.unwrap_or_default().into(),
Expand Down
2 changes: 1 addition & 1 deletion evm/test-data/storage.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"meta":{"cfg_env":{"chain_id":"0x1","spec_id":"LATEST","perf_all_precompiles_have_balance":false,"memory_limit":4294967295},"block_env":{"number":"0xdc42b8","coinbase":"0x0000000000000000000000000000000000000000","timestamp":"0x1","difficulty":"0x0","basefee":"0x0","gas_limit":"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"},"hosts":["mainnet.infura.io"]},"accounts":{"0x63091244180ae240c87d1f528f5f269134cb07b3":{"balance":"0x0","code_hash":"0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470","code":null,"nonce":0}},"storage":{"0x63091244180ae240c87d1f528f5f269134cb07b3":{"0x0":"0x0","0x1":"0x0","0x2":"0x0","0x3":"0x0","0x4":"0x0","0x5":"0x0","0x6":"0x0","0x7":"0x0","0x8":"0x0","0x9":"0x0"}},"block_hashes":{}}
{"meta":{"cfg_env":{"chain_id":"0x1","spec_id":"LATEST","perf_all_precompiles_have_balance":false,"memory_limit":4294967295, "perf_analyse_created_bytecodes":true, "limit_contract_code_size": 24576},"block_env":{"number":"0xdc42b8","coinbase":"0x0000000000000000000000000000000000000000","timestamp":"0x1","difficulty":"0x0","basefee":"0x0","gas_limit":"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"},"hosts":["mainnet.infura.io"]},"accounts":{"0x63091244180ae240c87d1f528f5f269134cb07b3":{"balance":"0x0","code_hash":"0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470","code":null,"nonce":0}},"storage":{"0x63091244180ae240c87d1f528f5f269134cb07b3":{"0x0":"0x0","0x1":"0x0","0x2":"0x0","0x3":"0x0","0x4":"0x0","0x5":"0x0","0x6":"0x0","0x7":"0x0","0x8":"0x0","0x9":"0x0"}},"block_hashes":{}}
2 changes: 1 addition & 1 deletion ui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ eyre = "0.6.5"
hex = "0.4.3"
ethers = { git = "https://github.com/gakonst/ethers-rs" }
forge = { path = "../forge" }
revm = { version = "1.8", features = ["std", "k256", "with-serde"] }
revm = { version = "1.9", features = ["std", "k256", "with-serde"] }

0 comments on commit 50fbe82

Please sign in to comment.