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

bug(forge script): Multi chain deployment script verify second chain always failed #9357

Closed
2 tasks done
andrew54068 opened this issue Nov 20, 2024 · 3 comments
Closed
2 tasks done
Labels
Cmd-forge-script Command: forge script T-bug Type: bug T-to-investigate Type: to investigate T-to-reproduce Type: requires reproduction

Comments

@andrew54068
Copy link

andrew54068 commented Nov 20, 2024

Component

Forge

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

  • Foundry
  • Foundryup

What version of Foundry are you on?

forge 0.2.0 (896794a 2024-11-10T00:22:42.580055000Z)

What command(s) is the bug in?

forge script

Operating System

macOS (Apple Silicon)

Describe the bug

I'm using ledger to deploy to multi-chain and verify, the first one will be verified successfully but the second one will always failed.
I'm sure it's not an issue with the Ledger, as it also happens with the private key.

forge script ./script/Deploy.s.sol:Deploy \
--slow \
--multi \
--broadcast \
--ledger \
--mnemonic-indexes ${MNEMONIC_INDEX} \
--verify \
-vvvv
Submitting verification for [src/xxx.sol:xxx] 0x....
Submitted contract for verification:
        Response: `OK`
        GUID: `...jbuqj...`
        URL: https://etherscan.io/address/0x...eb62d474...
Contract verification status:
Response: `NOTOK`
Details: `Pending in queue`
Warning: Verification is still pending... (7 tries remaining)
Contract verification status:
Response: `OK`
Details: `Pass - Verified`
Contract successfully verified
All (1) contracts were verified!
##
Start verification for (1) contracts
Start verifying contract `0x...eb62d474...` deployed on bsc

Submitting verification for [src/xxx.sol:xxx] 0x.....
Error: Encountered an error verifying this contract:
Response: `NOTOK`
Details:
                        `Invalid API Key (#err2)|bsc11`

so I have to use this commend one by one

forge verify-contract \
<contract_address> \
src/x.sol:x \
--chain bsc \
--etherscan-api-key $BASESCAN_API_KEY

And this will succeed, so it means my api key is correct.

This is my foundry.toml

[profile.default]
via_ir = true
src = "src"
out = "out"
libs = ["lib"]

[rpc_endpoints]
mainnet = "${ETHERUM_RPC_URL}"
bsc = "${BSC_RPC_URL}"
base = "${BASE_RPC_URL}"

[etherscan]
mainnet = { key = "${ETHERSCAN_API_KEY}", chain = "mainnet" }
bsc = { key = "${BSCSCAN_API_KEY}", chain = "bsc" }
base = { key = "${BASESCAN_API_KEY}", chain = "base" }

Not sure where do I do wrong. or did I miss some flag here?

@andrew54068 andrew54068 added T-bug Type: bug T-needs-triage Type: this issue needs to be labelled labels Nov 20, 2024
@github-project-automation github-project-automation bot moved this to Todo in Foundry Nov 20, 2024
@andrew54068 andrew54068 changed the title Multi chain deployment script verify second always failed issues Multi chain deployment script verify second chain always failed issues Nov 20, 2024
@andrew54068 andrew54068 changed the title Multi chain deployment script verify second chain always failed issues Multi chain deployment script verify second chain always failed Nov 20, 2024
@grandizzy
Copy link
Collaborator

@andrew54068 are the forks selected within deploy script using cheatcodes?
Side note you can drop the --etherscan-api-key from single commands and use only

forge verify-contract \
<contract_address> \
src/x.sol:x \
--chain bsc 

thank you!

@zerosnacks zerosnacks added T-to-reproduce Type: requires reproduction T-to-investigate Type: to investigate Cmd-forge-script Command: forge script and removed T-needs-triage Type: this issue needs to be labelled labels Nov 20, 2024
@zerosnacks zerosnacks changed the title Multi chain deployment script verify second chain always failed bug(forge script): Multi chain deployment script verify second chain always failed Nov 20, 2024
@grandizzy
Copy link
Collaborator

bump @andrew54068 could you please provide sorce code sample to replicate the issue. Thank you!

@grandizzy
Copy link
Collaborator

grandizzy commented Nov 22, 2024

Confirmed is not working with the version you posted because is missing #9311, here's a test with latest version, deploying on sepolia and base-sepolia chains with config

[rpc_endpoints]
sepolia = "${SEPOLIA_URL}"
base-sepolia = "${BASE_SEPOLIA_URL}"

[etherscan]
sepolia = { key = "${SEPOLIA_KEY}" }
base-sepolia = { key = "${BASE_SEPOLIA_KEY}" }

using a script as

contract CounterScript is Script {
    function run() public {
        vm.createSelectFork("sepolia");
        vm.startBroadcast();
        new Counter();
        vm.stopBroadcast();

        vm.createSelectFork("base-sepolia");
        vm.startBroadcast();
        new Counter();
        vm.stopBroadcast();
    }
}

and issuing

forge script script/Counter.s.sol --slow --multi --broadcast --private-key $KEY --verify

image

Please reopen if still an issue for you. Thank you!

@grandizzy grandizzy closed this as not planned Won't fix, can't repro, duplicate, stale Nov 22, 2024
@github-project-automation github-project-automation bot moved this from Todo to Done in Foundry Nov 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Cmd-forge-script Command: forge script T-bug Type: bug T-to-investigate Type: to investigate T-to-reproduce Type: requires reproduction
Projects
Archived in project
Development

No branches or pull requests

3 participants