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

chore(evm): use method instead of get_create_address util #6738

Merged
merged 1 commit into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
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
Loading