-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
feat: smarter verification #7937
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DaniPopes
reviewed
May 17, 2024
mattsse
approved these changes
May 17, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great, pending @DaniPopes nits
DaniPopes
approved these changes
May 22, 2024
crates/common/src/contracts.rs
Outdated
/// references and immutables. | ||
pub fn find_by_deployed_code_exact(&self, code: &[u8]) -> Option<ArtifactWithContractRef> { | ||
self.iter().find(|(_, contract)| { | ||
let Some(ref deployed_bytecode) = contract.deployed_bytecode else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pls use & in the expression instead of ref in the pattern where possible
eth_feeHistory bug should go away with #7934 |
klkvr
added a commit
that referenced
this pull request
May 24, 2024
* fix: smarter verification * version build regex * rm println * fix tests * clippy * review fixes * fmt * ref -> &
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
There is no need in requiring contract name/path in
forge verify-contract
. For example, hardhat does not require that.Solution
This PR introduces smarter way of identifying contracts by deployed code which respects immutable/link references and targets exact bytecode match (
ContractsByArtifact::find_by_deployed_code_exact
). I believe this could be useful for stuff unrelated to verification as current diff score method is not really great.Also, this PR makes
contract: ContractInfo
parameter onVerifyArgs
optional, thus allowing to do justforge verify-contract <address>
. The artifact to use is determined by matching local bytecode throughfind_by_deployed_code_exact
.I've also changed flow to not rely on cache (except for determining version by looking at recent artifacts). We now trigger compiler directly if we need to get cached abi or metadata and it just uses cache if it's available instead of throwing a error when run on a project without cache.
In combination with
--guess-constructor-args
it now allows users to verify deployments of arbitrary project contracts much easier by just doingforge verify-contract <address> --guess-constructor-args
Next steps could probably be identifying libraries used when linking contract automatically as well.