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

fix(traces): Etherscan traces are only resolved for first instance of test run #7675

Merged

Conversation

zerosnacks
Copy link
Member

@zerosnacks zerosnacks commented Apr 15, 2024

Motivation

Closes #7558

Currently the resolved Etherscan traces are only applied to the first occurrence of an address due to the resolved addresses not being captured and returned, see:

for (addr, _) in addresses {
if !self.contracts.contains_key(addr) {
fetcher.push(*addr);
}
}

Solution

Reproducible by running minimal repro: https://github.com/zerosnacks/foundry-repro-7558

Implementation is largely pragmatic, emphasis on minimal changes - open to feedback

@zerosnacks zerosnacks changed the title fix(forge): Etherscan traces are only resolved for first instance of test run fix(traces): Etherscan traces are only resolved for first instance of test run Apr 15, 2024
@zerosnacks zerosnacks marked this pull request as ready for review April 15, 2024 21:03
Copy link
Member

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

smol suggestion

Comment on lines 123 to 138
let resolved = resolved
.into_iter()
.map(|addr| {
let metadata = self.contracts.get(&addr).unwrap();
let label = metadata.contract_name.clone();
let abi = metadata.abi().ok().map(Cow::Owned);

AddressIdentity {
address: addr,
label: Some(label.clone()),
contract: Some(label),
abi,
artifact_id: None,
}
})
.collect::<Vec<AddressIdentity<'_>>>();
Copy link
Member

Choose a reason for hiding this comment

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

this can be done in the for loop above?

so that we track AddressIdentity in resolved?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point, updated

@mattsse mattsse added the T-bug Type: bug label Apr 15, 2024
@mattsse mattsse merged commit 1535a69 into master Apr 16, 2024
19 checks passed
@mattsse mattsse deleted the zerosnacks/fix-etherscan-traces-only-resolved-first-run branch April 16, 2024 10:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-bug Type: bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Etherscan traces are only resolved for first instance of test run
2 participants