Skip to content
Merged
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
14 changes: 14 additions & 0 deletions crates/evm/traces/src/identifier/local.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use super::{AddressIdentity, TraceIdentifier};
use alloy_dyn_abi::JsonAbiExt;
use alloy_json_abi::JsonAbi;
use alloy_primitives::Address;
use foundry_common::contracts::{bytecode_diff_score, ContractsByArtifact};
Expand Down Expand Up @@ -53,6 +54,19 @@ impl<'a> LocalTraceIdentifier<'a> {
};

if let Some(bytecode) = contract_bytecode {
let mut current_bytecode = current_bytecode;
if is_creation && current_bytecode.len() > bytecode.len() {
// Try to decode ctor args with contract abi.
if let Some(constructor) = contract.abi.constructor() {
let constructor_args = &current_bytecode[bytecode.len()..];
if constructor.abi_decode_input(constructor_args, false).is_ok() {
// If we can decode args with current abi then remove args from
// code to compare.
current_bytecode = &current_bytecode[..bytecode.len()]
Comment on lines +61 to +65
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this does assume that the metadata setting / output is the same for both cases but I think that is fair

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, there's a diff score computed next

   let score = bytecode_diff_score(bytecode, current_bytecode);

which should catch this

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@klkvr can you pls confirm above before merging? thank you!

}
}
}

let score = bytecode_diff_score(bytecode, current_bytecode);
if score == 0.0 {
trace!(target: "evm::traces", "found exact match");
Expand Down
Loading