-
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
fix: better artifacts management for getCode
#7685
Conversation
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.
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
.with_cheats_config(CheatsConfig::new( | ||
&config, | ||
evm_opts.clone(), | ||
Some(artifact_ids), | ||
None, | ||
None, | ||
)) |
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.
I see, this makes cheatsconfig redundant here
crates/forge/src/multi_runner.rs
Outdated
/// Additional cheatcode inspector related settings derived from the `Config` | ||
pub cheats_config: Option<CheatsConfig>, | ||
/// Project config. | ||
pub config: Config, |
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.
should this also be an Arc?
Co-authored-by: DaniPopes <[email protected]>
Motivation
Follow-up to #7661 extending usage of
ContractsByArtifact
Closes #4876
Solution
Rewrite
getCode
logic to directly use compilation artifacts instead of reading them from filesystem. This makes it possible to usegetCode
in tests which were compiled without writing artifacts (which is happening in coverage for example).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 singleknown_contracts
object is incorrect and might result in invalidgetCode
output 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 #4049 but not resolves in full because
getCode
will now only work for linked contracts which only depend on subset of test contract libraries.