-
Notifications
You must be signed in to change notification settings - Fork 16
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
refactor: decouple Foundry project layout and build system #572
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.
Overall LGTM. Just some small suggestions and questions
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 only checked the js/ts changes. LGTM.
Goal
Decouple the Solidity test runner from the project layout and build system and enable support for functionality that depends on compilation artifacts in the JS runner. Decoupling the project layout and build system is not only important to remove the dependence on Foundry’s format, but also to give flexibility to iterate on Hardhat's build system.
Background
The Solidity test runner needs access to Solidity compilation artifacts for the following functionality:
getCode
andgetDeployedCode
cheatcodes.getCode
andgetDeployedCode
are currently no-op when Solidity tests are executed through from JS.Solution
This PR brings the following changes:
getCode
andgetDeployedCode
cheatcodes as a fallback behavior (rarely used)Alternatives considered
An alternative approach to achieve the same goal would be to provide a callback to EDR from JS that EDR can call to query artifacts. This approach was tested in a spike, but it was discarded, because there are several places in the Foundry codebase where the Rust code will iterate over all the artifacts which will be very slow if that involves fetching all the artifacts from JS.
In the future, once the new Hardhat build system has stabilized, we could move file loading over to Rust to address potential performance problems from passing a large amount of data through the ffi.
Notes
I tried to minimize changes to interfaces to make this PR easy to review. The
MultiContractRunner
is especially a candidate for future refactoring after this change.I manually benchmarked performance and found no regression.