foundry icon indicating copy to clipboard operation
foundry copied to clipboard

Obscure error messaging when running script with --verify

Open 0xPhaze opened this issue 2 years ago • 8 comments

Component

Forge

Have you ensured that all of these are up to date?

  • [X] Foundry
  • [X] Foundryup

What version of Foundry are you on?

forge 0.2.0 (359dd77 2022-09-15T00:04:51.833948Z)

What command(s) is the bug in?

forge script

Operating System

macOS (Apple Silicon)

Describe the bug

I was getting this weird error message. image

It took me a while to pin it down to using forge script --verify while broadcasting, but not generating any transactions. Removing the --verify allowed me to see the message: "no transactions generated"

0xPhaze avatar Sep 16 '22 22:09 0xPhaze

looks like the linking step is the root cause for this, are you using only libraries that are in the project or something at a specific address?

mattsse avatar Sep 16 '22 22:09 mattsse

I'm not using any libraries with public functions. I'm working with already deployed contracts in my script, forking from mumbai. The --verify might have been misleading, because now, after running it again it gets stuck with or without.

0xPhaze avatar Sep 16 '22 22:09 0xPhaze

do you have the libraries = [] key set in your config

https://book.getfoundry.sh/reference/config/solidity-compiler#libraries

mattsse avatar Sep 16 '22 22:09 mattsse

That did the trick for me, thank you very much. It was previously just not present in the config.

0xPhaze avatar Sep 16 '22 23:09 0xPhaze

I'll keep this open to improve the error message(s)

mattsse avatar Sep 16 '22 23:09 mattsse

Interestingly it appeared again. I played around a bit again and removed the --verify and it then worked (but without verifying the contracts of course).

0xPhaze avatar Sep 16 '22 23:09 0xPhaze

hmm, will try to reproduce this,

is this public by any chance?

mattsse avatar Sep 16 '22 23:09 mattsse

Yes, here: https://github.com/0xPhaze/gang-war/tree/198462993ade7cd4f578904da363454edb2a8e33 It seems to be reproducible on anvil

forge script deploy --rpc-url "http://127.0.0.1:8545" --private-key 0x83631fd2da5250fa4f9dd8c1057f6e53126de6dd9274b9aefbcc3eae3ada6a5f -vvv --ffi --broadcast

Though because of the setup scripts, it will think it has successfully deployed and you'll have to run rm -rf deployments/31337 to delete the stored deployments and "reset" it.

Edit: can just prepend US_RESET=true forge script... to not have to delete it every time. If I take out the --rpc-url then I get the same message "Code should have been linked before."

0xPhaze avatar Sep 16 '22 23:09 0xPhaze

Following up here. This seems to occur when I add more functions (or any code). If I delete some code, I can deploy without an error (and I'm pretty sure it does not have anything to do with "linking", unless I misunderstand that word). Could this then simply be when the max code size is reached? Did the error messages get messed up?

Edit: Perhaps ignore what I just wrote there (noticed that I was on an older version that didn't display the message). Just want to mention that this is still very much a real issue and currently is entirely hindering me from deploying in a specific repository. Got a friend to reproduce and he is able to run the scripts without any issues. For me the problem persists, even after re-installing foundry, cleaning, changing the config...

0xPhaze avatar Sep 22 '22 18:09 0xPhaze

Fixed in gakonst/ethers-rs#1743

0xPhaze avatar Sep 28 '22 09:09 0xPhaze