Skip to content
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

Vm.getCode can't find the artifact file: No matching artifact found #7745

Closed
arshan-ritual opened this issue Apr 20, 2024 · 17 comments
Closed
Labels
T-bug Type: bug

Comments

@arshan-ritual
Copy link

Ever since upgrading foundry today, all of my scripts that depended on vm.getCode are now failing.

foundryup Output


.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx

 ╔═╗ ╔═╗ ╦ ╦ ╔╗╔ ╔╦╗ ╦═╗ ╦ ╦         Portable and modular toolkit
 ╠╣  ║ ║ ║ ║ ║║║  ║║ ╠╦╝ ╚╦╝    for Ethereum Application Development
 ╚   ╚═╝ ╚═╝ ╝╚╝ ═╩╝ ╩╚═  ╩                 written in Rust.

.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx

Repo       : https://github.com/foundry-rs/
Book       : https://book.getfoundry.sh/
Chat       : https://t.me/foundry_rs/
Support    : https://t.me/foundry_support/
Contribute : https://github.com/orgs/foundry-rs/projects/2/

.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx

foundryup: installing foundry (version nightly, tag nightly)
foundryup: downloading latest forge, cast, anvil, and chisel
############################################################################################################ 100.0%
foundryup: downloading manpages
############################################################################################################ 100.0%
foundryup: installed - forge 0.2.0 (844caa8 2024-04-20T00:16:40.844544000Z)
foundryup: installed - cast 0.2.0 (844caa8 2024-04-20T00:16:40.855337000Z)
foundryup: installed - anvil 0.2.0 (844caa8 2024-04-20T00:16:40.869255000Z)
foundryup: installed - chisel 0.2.0 (844caa8 2024-04-20T00:16:40.915894000Z)
foundryup: done!

Old foundry version

I can't tell what my older version was unfortunately.

@DaniPopes DaniPopes transferred this issue from foundry-rs/book Apr 20, 2024
@arshan-ritual
Copy link
Author

relative path to artifact works, but inputs of format SolidityFile.sol:ContractName don't work.

@DaniPopes DaniPopes added the T-bug Type: bug label Apr 20, 2024
@DaniPopes
Copy link
Member

cc @klkvr

@klkvr
Copy link
Member

klkvr commented Apr 20, 2024

Likely resolved by #7738, @arshan-ritual could you please try running foundryup tomorrow and check if issue persists? or foundryup -b master now

@arshan-ritual
Copy link
Author

Yes, will do.

@klkvr
Copy link
Member

klkvr commented Apr 22, 2024

@arshan-ritual does it work for you on latest nightly?

@DaniPopes
Copy link
Member

Assuming this works now. Please feel free to re-open if that's not the case.

@github-project-automation github-project-automation bot moved this from Todo to Done in Foundry Book Apr 23, 2024
@0xMySt1c
Copy link

0xMySt1c commented May 10, 2024

still having issues with this using the latest nightly as of 5/10

@klkvr
Copy link
Member

klkvr commented May 10, 2024

@0xMySt1c are you using getCode for contracts under src/?

@0xMySt1c
Copy link

0xMySt1c commented May 10, 2024

@klkvr using a custom dir set in foundry.toml
double checked and the artifacts are definitely there
the weird thing is that when the same setup function is called from a different profile it appears to work with no problem.
there are different profiles and test suite for gas and unit/integration test.

@klkvr
Copy link
Member

klkvr commented May 10, 2024

what are the differences between profiles?

No matching artifact means that it is not found in the artifacts which were recompiled. when running script, foundry only compiles everything under src/ and the script itself, so if your contract is not in this set, you might get this error

@klkvr
Copy link
Member

klkvr commented May 10, 2024

using a custom dir set in foundry.toml

you mean something like src = "contracts" in foundry.toml and vm.getCode("contracts/...") is failing?

@0xMySt1c
Copy link

the only difference is that one of the profiles is gas optimized. i haven't tried a path because this setup code is called in both profiles.

@0xMySt1c
Copy link

using a custom dir set in foundry.toml

you mean something like src = "contracts" in foundry.toml and vm.getCode("contracts/...") is failing?

no using the format "Contract.sol:Contract"

@0xMySt1c
Copy link

confirming that a path works. my current workaround will be to determine the path using the profile

@klkvr
Copy link
Member

klkvr commented May 10, 2024

sorry what do you mean by "path" here? are two profiles operating on different src dirs?

@0xMySt1c
Copy link

getCode("out/artifacts/Contract.sol/Contract.json") works
getCode("Contract.sol:Contract") fails

@klkvr
Copy link
Member

klkvr commented May 14, 2024

can you confirm that getCode("Contract.sol:Contract") works on one profile, but fails on another? If so, could you please share what are the differenceses between profiles?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-bug Type: bug
Projects
No open projects
Status: Done
Development

No branches or pull requests

4 participants