Skip to content

Commit

Permalink
chore: bump revm (foundry-rs#5698)
Browse files Browse the repository at this point in the history
* chore: bump revm

* chore: fix breaking changes

* feat: add coverage test

* chore: clippy

* chore: switch revm to latest main

* Revert "Revert "feat(evm): Use latest revm main commit (foundry-rs#5669)" (foundry-rs#5695)"

This reverts commit f8a07c3.

* re-add coverage test

* fmt

* chore: clippy

* chore: fix test

* chore: fix test

* chore: remove unused/unnecessary stuff
  • Loading branch information
Evalir authored and mikelodder7 committed Sep 12, 2023
1 parent b48bfae commit 8f25e69
Show file tree
Hide file tree
Showing 24 changed files with 134 additions and 144 deletions.
85 changes: 56 additions & 29 deletions Cargo.lock

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

23 changes: 12 additions & 11 deletions crates/anvil/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -781,18 +781,19 @@ impl NodeConfig {
/// *Note*: only memory based backend for now
pub(crate) async fn setup(&mut self) -> mem::Backend {
// configure the revm environment

let mut cfg = CfgEnv::default();
cfg.spec_id = self.get_hardfork().into();
cfg.chain_id = rU256::from(self.get_chain_id());
cfg.limit_contract_code_size = self.code_size_limit;
// EIP-3607 rejects transactions from senders with deployed code.
// If EIP-3607 is enabled it can cause issues during fuzz/invariant tests if the
// caller is a contract. So we disable the check by default.
cfg.disable_eip3607 = true;
cfg.disable_block_gas_limit = self.disable_block_gas_limit;

let mut env = revm::primitives::Env {
cfg: CfgEnv {
spec_id: self.get_hardfork().into(),
chain_id: rU256::from(self.get_chain_id()),
limit_contract_code_size: self.code_size_limit,
// EIP-3607 rejects transactions from senders with deployed code.
// If EIP-3607 is enabled it can cause issues during fuzz/invariant tests if the
// caller is a contract. So we disable the check by default.
disable_eip3607: true,
disable_block_gas_limit: self.disable_block_gas_limit,
..Default::default()
},
cfg,
block: BlockEnv {
gas_limit: self.gas_limit.into(),
basefee: self.get_base_fee().into(),
Expand Down
21 changes: 6 additions & 15 deletions crates/anvil/src/eth/backend/mem/inspector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,23 +53,17 @@ impl<DB: Database> revm::Inspector<DB> for Inspector {
&mut self,
interp: &mut Interpreter,
data: &mut EVMData<'_, DB>,
is_static: bool,
) -> InstructionResult {
call_inspectors!([&mut self.tracer], |inspector| {
inspector.initialize_interp(interp, data, is_static);
inspector.initialize_interp(interp, data);
});
InstructionResult::Continue
}

#[inline]
fn step(
&mut self,
interp: &mut Interpreter,
data: &mut EVMData<'_, DB>,
is_static: bool,
) -> InstructionResult {
fn step(&mut self, interp: &mut Interpreter, data: &mut EVMData<'_, DB>) -> InstructionResult {
call_inspectors!([&mut self.tracer], |inspector| {
inspector.step(interp, data, is_static);
inspector.step(interp, data);
});
InstructionResult::Continue
}
Expand All @@ -92,11 +86,10 @@ impl<DB: Database> revm::Inspector<DB> for Inspector {
&mut self,
interp: &mut Interpreter,
data: &mut EVMData<'_, DB>,
is_static: bool,
eval: InstructionResult,
) -> InstructionResult {
call_inspectors!([&mut self.tracer], |inspector| {
inspector.step_end(interp, data, is_static, eval);
inspector.step_end(interp, data, eval);
});
eval
}
Expand All @@ -106,10 +99,9 @@ impl<DB: Database> revm::Inspector<DB> for Inspector {
&mut self,
data: &mut EVMData<'_, DB>,
call: &mut CallInputs,
is_static: bool,
) -> (InstructionResult, Gas, Bytes) {
call_inspectors!([&mut self.tracer, Some(&mut self.log_collector)], |inspector| {
inspector.call(data, call, is_static);
inspector.call(data, call);
});

(InstructionResult::Continue, Gas::new(call.gas_limit), Bytes::new())
Expand All @@ -123,10 +115,9 @@ impl<DB: Database> revm::Inspector<DB> for Inspector {
remaining_gas: Gas,
ret: InstructionResult,
out: Bytes,
is_static: bool,
) -> (InstructionResult, Gas, Bytes) {
call_inspectors!([&mut self.tracer], |inspector| {
inspector.call_end(data, inputs, remaining_gas, ret, out.clone(), is_static);
inspector.call_end(data, inputs, remaining_gas, ret, out.clone());
});
(ret, remaining_gas, out)
}
Expand Down
8 changes: 7 additions & 1 deletion crates/anvil/src/eth/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,9 @@ pub enum InvalidTransactionError {
/// Thrown when a legacy tx was signed for a different chain
#[error("Incompatible EIP-155 transaction, signed for another chain")]
IncompatibleEIP155,
/// Thrown when an access list is used before the berlin hard fork.
#[error("Access lists are not supported before the Berlin hardfork")]
AccessListNotSupported,
}

impl From<revm::primitives::InvalidTransaction> for InvalidTransactionError {
Expand All @@ -203,7 +206,7 @@ impl From<revm::primitives::InvalidTransaction> for InvalidTransactionError {
})
}
InvalidTransaction::RejectCallerWithCode => InvalidTransactionError::SenderNoEOA,
InvalidTransaction::LackOfFundForGasLimit { .. } => {
InvalidTransaction::LackOfFundForMaxFee { .. } => {
InvalidTransactionError::InsufficientFunds
}
InvalidTransaction::OverflowPaymentInTransaction => {
Expand All @@ -217,6 +220,9 @@ impl From<revm::primitives::InvalidTransaction> for InvalidTransactionError {
}
InvalidTransaction::NonceTooHigh { .. } => InvalidTransactionError::NonceTooHigh,
InvalidTransaction::NonceTooLow { .. } => InvalidTransactionError::NonceTooLow,
InvalidTransaction::AccessListNotSupported => {
InvalidTransactionError::AccessListNotSupported
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/anvil/src/genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ impl From<GenesisAccount> for AccountInfo {
AccountInfo {
balance: balance.into(),
nonce: nonce.unwrap_or_default(),
code_hash: code.as_ref().map(|code| code.hash).unwrap_or(KECCAK_EMPTY),
code_hash: code.as_ref().map(|code| code.hash_slow()).unwrap_or(KECCAK_EMPTY),
code,
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/evm/src/executor/backend/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1099,7 +1099,7 @@ impl DatabaseExt for Backend {
// prevent issues in the new journalstate, e.g. assumptions that accounts are loaded
// if the account is not touched, we reload it, if it's touched we clone it
for (addr, acc) in journaled_state.state.iter() {
if acc.is_touched {
if acc.is_touched() {
merge_journaled_state_data(
b160_to_h160(*addr),
journaled_state,
Expand Down
Loading

0 comments on commit 8f25e69

Please sign in to comment.