Skip to content

Commit

Permalink
chore(evm): use method instead of get_create_address util (#6738)
Browse files Browse the repository at this point in the history
  • Loading branch information
DaniPopes authored Jan 9, 2024
1 parent 0792dc7 commit b51a3f2
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 14 deletions.
3 changes: 1 addition & 2 deletions crates/cheatcodes/src/inspector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ use foundry_common::{evm::Breakpoints, provider::alloy::RpcUrl, types::ToEthers}
use foundry_evm_core::{
backend::{DatabaseError, DatabaseExt, RevertDiagnostic},
constants::{CHEATCODE_ADDRESS, DEFAULT_CREATE2_DEPLOYER, HARDHAT_CONSOLE_ADDRESS, MAGIC_SKIP},
utils::get_create_address,
};
use itertools::Itertools;
use revm::{
Expand Down Expand Up @@ -258,7 +257,7 @@ impl Cheatcodes {
.get(&inputs.caller)
.map(|acc| acc.info.nonce)
.unwrap_or_default();
let created_address = get_create_address(inputs, old_nonce);
let created_address = inputs.created_address(old_nonce);

if data.journaled_state.depth > 1 && !data.db.has_cheatcode_access(inputs.caller) {
// we only grant cheat code access for new contracts if the caller also has
Expand Down
10 changes: 0 additions & 10 deletions crates/evm/core/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,16 +268,6 @@ pub fn configure_tx_env(env: &mut revm::primitives::Env, tx: &Transaction) {
env.tx.transact_to = tx.to.map(TransactTo::Call).unwrap_or_else(TransactTo::create)
}

/// Get the address of a contract creation
pub fn get_create_address(call: &CreateInputs, nonce: u64) -> Address {
match call.scheme {
CreateScheme::Create => call.caller.create(nonce),
CreateScheme::Create2 { salt } => {
call.caller.create2_from_code(B256::from(salt), &call.init_code)
}
}
}

/// Get the gas used, accounting for refunds
pub fn gas_used(spec: SpecId, spent: u64, refunded: u64) -> u64 {
let refund_quotient = if SpecId::enabled(spec, SpecId::LONDON) { 5 } else { 2 };
Expand Down
4 changes: 2 additions & 2 deletions crates/evm/evm/src/inspectors/debugger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use foundry_evm_core::{
backend::DatabaseExt,
constants::CHEATCODE_ADDRESS,
debug::{DebugArena, DebugNode, DebugStep, Instruction},
utils::{gas_used, get_create_address, CallKind},
utils::{gas_used, CallKind},
};
use revm::{
interpreter::{
Expand Down Expand Up @@ -133,7 +133,7 @@ impl<DB: DatabaseExt> Inspector<DB> for Debugger {
let nonce = data.journaled_state.account(call.caller).info.nonce;
self.enter(
data.journaled_state.depth() as usize,
get_create_address(call, nonce),
call.created_address(nonce),
CallKind::Create,
);

Expand Down

0 comments on commit b51a3f2

Please sign in to comment.