chore: use available created_address fn (#5957)

This commit is contained in:
Matthias Seitz
2024-01-06 13:26:11 +01:00
committed by GitHub
parent 11dfe56624
commit 8910f76ab4
3 changed files with 10 additions and 25 deletions

View File

@@ -8,7 +8,6 @@ use crate::tracing::{
builtins::{register_builtins, PrecompileList},
},
types::CallKind,
utils::get_create_address,
};
use alloy_primitives::{Address, Bytes, B256, U256};
use boa_engine::{Context, JsError, JsObject, JsResult, JsValue, Source};
@@ -449,7 +448,7 @@ where
let _ = data.journaled_state.load_account(inputs.caller, data.db);
let nonce = data.journaled_state.account(inputs.caller).info.nonce;
let address = get_create_address(inputs, nonce);
let address = inputs.created_address(nonce);
self.push_call(
address,
inputs.init_code.clone(),

View File

@@ -1,6 +1,10 @@
use self::parity::stack_push_count;
use crate::tracing::{
types::{CallKind, LogCallOrder},
utils::get_create_address,
arena::PushTraceKind,
types::{
CallKind, CallTraceNode, LogCallOrder, RecordedMemory, StorageChange, StorageChangeReason,
},
utils::gas_used,
};
use alloy_primitives::{Address, Bytes, Log, B256, U256};
pub use arena::CallTraceArena;
@@ -22,12 +26,6 @@ mod fourbyte;
mod opcount;
pub mod types;
mod utils;
use self::parity::stack_push_count;
use crate::tracing::{
arena::PushTraceKind,
types::{CallTraceNode, RecordedMemory, StorageChange, StorageChangeReason},
utils::gas_used,
};
pub use builder::{
geth::{self, GethTraceBuilder},
parity::{self, ParityTraceBuilder},
@@ -502,7 +500,7 @@ where
let nonce = data.journaled_state.account(inputs.caller).info.nonce;
self.start_trace_on_call(
data,
get_create_address(inputs, nonce),
inputs.created_address(nonce),
inputs.init_code.clone(),
inputs.value,
inputs.scheme.into(),

View File

@@ -1,10 +1,9 @@
//! Util functions for revm related ops
use alloy_primitives::{hex, Address, Bytes, B256};
use alloy_primitives::{hex, Bytes};
use alloy_sol_types::{ContractError, GenericRevertReason};
use revm::{
interpreter::CreateInputs,
primitives::{CreateScheme, SpecId, KECCAK_EMPTY},
primitives::{SpecId, KECCAK_EMPTY},
DatabaseRef,
};
@@ -27,17 +26,6 @@ pub(crate) fn gas_used(spec: SpecId, spent: u64, refunded: u64) -> u64 {
spent - (refunded).min(spent / refund_quotient)
}
/// Get the address of a contract creation
#[inline]
pub(crate) 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.clone())
}
}
}
/// Loads the code for the given account from the account itself or the database
///
/// Returns None if the code hash is the KECCAK_EMPTY hash