request: forge script
build with full artifacts for vm.getDeployedCode
to work
#7732
Labels
T-feature
Type: feature
Component
Forge
Describe the feature you would like
Background:
forge test
andforge script
behavior differenceforge script
is implemented such that it targets a specific contract with:forge test
is implemented such that it compiles the whole project with:Note that
get_sources_to_compile
was modified in #7572 to resolve #7569Now I am facing the same kind of issue as in the above
force test
fix, but inforge script
: thevm.getCode
andvm.getDeployedCode
cheatcodes only allow you to load artifacts from the current build.This
forge test
approach allows you to load a contract-bytecode of a contract that isn't imported directly in the script, to then dovm.etch
and execute the contract. This is very important, since it allows conflicting solidity versions to interoperate, and it avoids large bytecodes (if importing and deploying withoutvm.etch
there is a lot of overhead). In the OP-Stack we are using foundry-scripts to perform large deployments, and now also L2 genesis-state creation, and this functionality offorge test
we would really like to have inforge script
also.What I have tried
When using
unchecked_cheatcode_artifacts = true
, to access deployments of older builds, there is no automated dependency resolution (if there are multiple solidity versions of build output), and arbitrary stale artifact reading isn't great either.When importing the solidity files that I am calling
vm.getDeployedCode
for, the solidity version conflicts arise, preventing me from compiling at all.When using absolute paths (instead of the
name.sol:name
syntax) to the artifacts invm.getDeployedCode
, the checks for artifacts are still the same, and compiler output is not consistent even if it worked.What I am looking for is to make
vm.getDeployedCode
to work the same inforge script
asforge test
. If this is behind a flag that's fine, e.g.--full-scope
or something to build the whole project.Implementation
Forge test compiler invocation:
foundry/crates/forge/bin/cmd/test/mod.rs
Line 249 in 844caa8
Forge script compiler invocation:
foundry/crates/script/src/build.rs
Line 152 in 844caa8
I think that by pulling in the
ProjectCompiler
(optionally, if there is a difference in speed), creating a full build output with all artifacts, and then proceeding with the same artifact-filtering to identify the script-contract to execute, we can run the script with expectedvm.getCode
andvm.getDeployedCode
behavior.Additional context
No response
The text was updated successfully, but these errors were encountered: