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

Conversation

klkvr
Copy link
Member

@klkvr klkvr commented Apr 18, 2024

Motivation

Closes #7702

Solution

Exclude artifacts with present but empty bytecode from ContractsByArtifact. Such contracts are usually abstract contracts or interfaces. Also adds additional safety check to VerifyArgs

@klkvr klkvr changed the title fix: exclude empty artifacts from ContractsByArtifact fix: exclude empty artifacts from ContractsByArtifact Apr 18, 2024
@@ -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

@@ -45,6 +45,13 @@ impl ContractsByArtifact {
let bytecode = artifact.bytecode.and_then(|b| b.into_bytes())?;
let deployed_bytecode =
artifact.deployed_bytecode.and_then(|b| b.into_bytes())?;

if 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.

nit: add small comment on what empty bytecode means, just like the pr description

@onbjerg onbjerg added the T-debt Type: code debt label Apr 18, 2024
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.

lgtm

@klkvr
Copy link
Member Author

klkvr commented Apr 18, 2024

ah it actually seems that we depend on known_contracts to contain ABIs of interfaces and abstract contracts for targetInterfaces in invariant tests, looking into fix for this

@klkvr
Copy link
Member Author

klkvr commented Apr 18, 2024

instead of excluding them we now keep both bytecodes as Options thus we still have info about abstract contracts and interfaces but bytecode is either None or correct non-empty bytes

@klkvr klkvr requested review from mattsse, DaniPopes and onbjerg April 18, 2024 19:17
@klkvr klkvr merged commit 79dd88c into master Apr 18, 2024
19 checks passed
@klkvr klkvr deleted the klkvr/fix-verification branch April 18, 2024 22:11
klkvr added a commit that referenced this pull request Apr 20, 2024
* fix: exclude empty artifacts from ContractsByArtifact

* additional check

* fmt

* doc

* use Option for bytecodes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-debt Type: code debt
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Contract verification fails using forge script with recent version of forge.
4 participants