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: exclude empty artifacts from ContractsByArtifact #7713

Merged
merged 5 commits into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
6 changes: 6 additions & 0 deletions crates/common/src/contracts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ impl ContractsByArtifact {
let bytecode = artifact.bytecode.and_then(|b| b.into_bytes())?;
let deployed_bytecode =
artifact.deployed_bytecode.and_then(|b| b.into_bytes())?;

// Exclude artifacts with present but empty bytecode. Such artifacts are usually
// interfaces and abstract contracts.
if bytecode.is_empty() || deployed_bytecode.is_empty() {
return None;
}
let abi = artifact.abi?;

Some((id, ContractData { name, abi, bytecode, deployed_bytecode }))
Expand Down
4 changes: 4 additions & 0 deletions crates/script/src/verify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ impl VerifyBundle {
libraries: &[String],
) -> Option<VerifyArgs> {
for (artifact, contract) in self.known_contracts.iter() {
// Avoid comparing to empty bytecode.
if contract.bytecode.is_empty() {
Copy link
Member

Choose a reason for hiding this comment

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

we don't need this check if we add the check in ContractsByArtifact i think?

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah, but I've seen this bug before so would like to keep this as impact of this bug is pretty high and it's pretty easy to miss while working with artifacts

Copy link
Member Author

@klkvr klkvr Apr 18, 2024

Choose a reason for hiding this comment

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

also I think this would've been caught by verification tests which are disabled rn

cc @mattsse

continue;
}
// If it's a CREATE2, the tx.data comes with a 32-byte salt in the beginning
// of the transaction
if data.split_at(create2_offset).1.starts_with(&contract.bytecode) {
Expand Down
Loading