fix: better artifacts management for getCode#7685
Merged
Merged
Conversation
mattsse
approved these changes
Apr 16, 2024
mattsse
left a comment
Member
There was a problem hiding this comment.
This also separates known_contracts per each test contract. This is needed because different test contracts might be linked with different libraries, thus having a single known_contracts object is incorrect and might result in invalid getCode output or identifiers failing to identify contracts.
I see, this makes sense
This introduces overhead of cloning compiler output for each running test which shouldn't affect performance much I believe.
this should be ok.
removing the cheatsconfig also makes sense to me
reasonable, I think artifact mgmt is a lot better now,
pending @DaniPopes
Comment on lines
-325
to
-331
| .with_cheats_config(CheatsConfig::new( | ||
| &config, | ||
| evm_opts.clone(), | ||
| Some(artifact_ids), | ||
| None, | ||
| None, | ||
| )) |
Member
There was a problem hiding this comment.
I see, this makes cheatsconfig redundant here
| /// Additional cheatcode inspector related settings derived from the `Config` | ||
| pub cheats_config: Option<CheatsConfig>, | ||
| /// Project config. | ||
| pub config: Config, |
DaniPopes
approved these changes
Apr 16, 2024
Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com>
This was referenced Apr 26, 2024
This file contains hidden or 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
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
Follow-up to #7661 extending usage of
ContractsByArtifactCloses #4876
Solution
Rewrite
getCodelogic to directly use compilation artifacts instead of reading them from filesystem. This makes it possible to usegetCodein tests which were compiled without writing artifacts (which is happening in coverage for example).This also separates
known_contractsper each test contract. This is needed because different test contracts might be linked with different libraries, thus having a singleknown_contractsobject is incorrect and might result in invalidgetCodeoutput or identifiers failing to identify contracts. This introduces overhead of cloning compiler output for each running test which shouldn't affect performance much I believe.Related to #1161 and foundry-rs/book#1361 but not resolves in full because
getCodewill now only work for linked contracts which only depend on subset of test contract libraries.