-
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
Improper Ordering of Contract Verification API Keys (Env vars vs foundry.toml) #7699
Comments
I think this could be workarounded by using a
|
Sure, but I have |
Setting an ENV value always does this this is standard |
Ok, but it doesn't make any sense intuitively. Why should a global API key value override network-specific configured ones? |
ENV is supposed to take precedence over CLI. ENV is not stored on the heap, nor is there a global variable in the data section pointing to it. The environment is stored entirely on the stack and is a part of the initial process stack that is set up before the program starts running. Ergo, it takes precedence. |
After thinking on this some more the issue is not so much about environment preference ordering. It's more that specifying a global etherscan api key doesn't make sense when doing a multichain deploy. Really what should happen is this parameter is either ignored or an error is thrown. |
I argued against even having this as a setting for foundry.toml, it breaks across chains just like you stated. The latest release has support for defining What we have here is an overload of concerns. It is best to load such settings on a per-deploy basis. env vars are granular controls, each fully orthogonal to other env vars. grouping them by environments does not scale, and the "grouping" of such settings will result in a combinatorial explosion of config nested settings, which makes managing deploys very brittle. Personally, if I am doing a production main net deployment, I create a clean env with a modified config that is specific to that deployment. It contains no test files or other unneeded files for the purposes of deployment |
Ok can close this if need to work around with a different environment configuration. |
Component
Forge
Have you ensured that all of these are up to date?
What version of Foundry are you on?
forge 0.2.0 (440ec52 2024-04-11T00:22:09.585245000Z)
What command(s) is the bug in?
forge script --verify
Operating System
macOS (Apple Silicon)
Describe the bug
I have this defined in my
foundry.toml
:However, if
ETHERSCAN_API_KEY
is defined in the environment then it will override all the other chains and produce "invalid API key" when verifying contracts. The ordering on this should be reversed where it will look for this explicit definition for each chain insidefoundry.toml
and only fall back toETHERSCAN_API_KEY
if they do not exist.The text was updated successfully, but these errors were encountered: