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
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
43 changes: 29 additions & 14 deletions crates/evm/traces/src/identifier/etherscan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ impl TraceIdentifier for EtherscanIdentifier {
return Vec::new()
}

let mut identities = Vec::new();
let mut fetcher = EtherscanFetcher::new(
self.client.clone(),
Duration::from_secs(1),
Expand All @@ -112,28 +113,42 @@ impl TraceIdentifier for EtherscanIdentifier {
);

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

let fut = fetcher
.map(|(address, metadata)| {
if let Some(metadata) = self.contracts.get(addr) {
let label = metadata.contract_name.clone();
let abi = metadata.abi().ok().map(Cow::Owned);
self.contracts.insert(address, metadata);

AddressIdentity {
address,
identities.push(AddressIdentity {
address: *addr,
label: Some(label.clone()),
contract: Some(label),
abi,
artifact_id: None,
}
})
.collect();
});
} else {
fetcher.push(*addr);
}
}

let fetched_identities = RuntimeOrHandle::new().block_on(
fetcher
.map(|(address, metadata)| {
let label = metadata.contract_name.clone();
let abi = metadata.abi().ok().map(Cow::Owned);
self.contracts.insert(address, metadata);

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

RuntimeOrHandle::new().block_on(fut)
identities.extend(fetched_identities);
identities
}
}

Expand Down
Loading