foundry-rs / foundry

Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.
https://getfoundry.sh
Apache License 2.0
8.1k stars 1.67k forks source link

Always fail to verify smart contract after upgrading foundry. #5110

Closed Santiago0412 closed 1 year ago

Santiago0412 commented 1 year ago

Component

Forge

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

What version of Foundry are you on?

forge 0.2.0 (03aa926 2023-06-05T09:38:42.448503000Z)

What command(s) is the bug in?

forge create --rpc-url "https://matic-mumbai.chainstacklabs.com" \ --constructor-args "AAAA" "AA" "https://gateway.pinata.cloud/ipfs/ ... --verify \ src/AAAA.sol:AAAA

Operating System

macOS (Apple Silicon)

Describe the bug

Try to deploy my smart contract, always fail to verify the contract after running foundry up. before that everything works fine. here is the log I got:

[⠢] Compiling...
No files changed, compilation skipped
Deployer: 0x540b47fc7957bd6C16d5BDF41bed97B9f8b33C13
Deployed to: 0xa7D86a510bE9E3C4BAC144A92C83853d7146369b
Transaction hash: 0x53b8cdc00f9bee488cbf9705b655f710a8873d1e0b79c0bd8670a80f8a9f866b
Starting contract verification...
Waiting for etherscan to detect contract deployment...
Start verifying contract `0xa7d86a510be9e3c4bac144a92c83853d7146369b` deployed on mumbai

Submitting verification for [src/AxeLandNFTToken1.sol:AxeLandNFTToken1] "0xa7D86a510bE9E3C4BAC144A92C83853d7146369b".

Submitting verification for [src/AxeLandNFTToken1.sol:AxeLandNFTToken1] "0xa7D86a510bE9E3C4BAC144A92C83853d7146369b".

Submitting verification for [src/AxeLandNFTToken1.sol:AxeLandNFTToken1] "0xa7D86a510bE9E3C4BAC144A92C83853d7146369b".
Submitted contract for verification:
    Response: `OK`
    GUID: `q3gtjhgqaqkyrvxmrrz1sq9bvqcpemyxa23cvcfevmvmgy9xug`
    URL:
        https://mumbai.polygonscan.com/address/0xa7d86a510be9e3c4bac144a92c83853d7146369b
Contract verification status:
Response: `NOTOK`
Details: `Pending in queue`
Contract verification status:
Response: `NOTOK`
Details: `Fail - Unable to verify`
Contract failed to verify.
Evalir commented 1 year ago

Hmm this shouldn't be the case—I'll give it a look cc @mattsse

jonathanpwang commented 1 year ago

I second this being an issue. But in my case it doesn't verify on etherscan even when I upload the whole flattened file, so I don't exactly know what's going on.

On a related note, if I have more advanced compiler settings (optimizer true, constantOptimizer false), will forge create --verify still be able to send etherscan the correct compiler settings?

jonathanpwang commented 1 year ago

Update: here is a concrete contract which failed to verify no matter what I did using foundry --version nightly. After doing foundryup --commit 8bbde620ab39246f3c89700a19dfe6f347e99f4f the verify worked fine.

https://goerli.etherscan.io/address/0x24623e2c87bdf420204e21a75a5b6921950872b8#code

BowTiedPickle commented 1 year ago

I experienced the same verification issue on forge 0.2.0 (08a629a 2023-06-03T00:04:22.625130135Z), but was not able to validate the workaround from @jonathanpwang due to running into the foundry config error: Unknown evm version: paris for settingevm_version`` when trying to run at the foundry version specified above.

Response I got on the nightly commit was this:

Start verification for (1) contracts
Start verifying contract `0xa519457b3d3734a6ca54e3b8be7f408ac87feb0b` deployed on goerli

Submitting verification for [src/Preseller.sol:Preseller] "0xa519457b3d3734a6CA54e3B8be7f408ac87feB0B".
Submitted contract for verification:
        Response: `OK`
        GUID: `kmewdcmqcmrduuqhcfipyffqrspxhkh19vrzxfdpqza8tpznc1`
        URL:
        https://goerli.etherscan.io/address/0xa519457b3d3734a6ca54e3b8be7f408ac87feb0b
Contract verification status:
Response: `NOTOK`
Details: `Pending in queue`
Contract verification status:
Response: `NOTOK`
Details: `Fail - Unable to verify. Please check if the correct constructor argument was entered.`
Contract failed to verify.
quangkeu95 commented 1 year ago

I experienced the same issue on forge 0.2.0 (08a629a 2023-06-03T00:04:22.625130135Z), both with verification and with using foundry-zksync. Any workaround?

Santiago0412 commented 1 year ago

foundryup --commit 8bbde620ab39246f3c89700a19dfe6f347e99f4f

I trid this but still fail.

Evalir commented 1 year ago

Hmm right now it's impossible to test on goerli to reproduce, but I can't reproduce the mumbai issues and Sepolia and other testnets (L2s) work properly—this might be an API issue with mumbai and ZKSync.

gakonst commented 1 year ago

We're on it folks - pls send us repros if possible.

mergd commented 1 year ago

Tried deploying to Sepolia with a private repo, and tried Goerli with this repo of mine. Both failed to verify with Details: Fail - Unable to verify. Please check if the correct constructor argument was entered. being the culprit here.

https://github.com/mergd/6551-gift-cards

x48115 commented 1 year ago

I was able to resolve this by using foundryup --commit 577e8b8d. From my testing it seems that any contract that uses constructor arguments can no longer be verified. I believe this is a regression. To reproduce the issue, attempt to deploy and verify any contract with constructor args.

Evalir commented 1 year ago

Hey all, a fix is on the way with https://github.com/gakonst/ethers-rs/pull/2468 — we'll let you know when this is upstreamed to foundry!

0xPublicGoods commented 1 year ago

Thanks Team! Just ran into a similar issue on my first time ever verifying a contract from @Patricks course, herewith my repo if you'd like to take a look, https://github.com/0xPublicGoods/Foundry-FundMe-F23, it also happens to be a constructor argument issue

Start verification for (1) contracts
Start verifying contract `0x98d67f24558f78588386c5372f5a023b19b735a1` deployed on sepolia

Submitting verification for [src/FundMe.sol:FundMe] "0x98D67f24558F78588386c5372F5A023B19b735a1".

Submitting verification for [src/FundMe.sol:FundMe] "0x98D67f24558F78588386c5372F5A023B19b735a1".

Submitting verification for [src/FundMe.sol:FundMe] "0x98D67f24558F78588386c5372F5A023B19b735a1".

Submitting verification for [src/FundMe.sol:FundMe] "0x98D67f24558F78588386c5372F5A023B19b735a1".
Submitted contract for verification:
        Response: `OK`
        GUID: `tk4ia76s1qgfv8kv2fdsme11jvfmuxfwzycxlvxp7n1bwgycpr`
        URL:
        https://sepolia.etherscan.io/address/0x98d67f24558f78588386c5372f5a023b19b735a1
Contract verification status:
Response: `NOTOK`
Details: `Pending in queue`
Contract verification status:
Response: `NOTOK`
Details: `Fail - Unable to verify. Please check if the correct constructor argument was entered.`
Contract failed to verify.
rpedroni commented 1 year ago

Replicating this on my end also (and going a bit crazy thinking I had bad constructor args). I'm seeing the problem with any contract that has constructor args.

forge 0.2.0 (08a629a 2023-06-03T00:14:26.563741000Z)

Command ran

forge verify-contract 0xdC4E3E75F444f4A83C02740fc0014c1D6F05570F SingleTokenPortfolio --constructor-args 00000000000000000000000094106ca9c7e567109a1d39413052887d1f412183000000000000000000000000ae78736cd615f374d3085123a210448e74fc639300000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000746a52880000000000000000000000000000000000000000000000000000000000000000190000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001f526f636b6574706f6f6c2045544820506f7274666f6c696f20536861726573000000000000000000000000000000000000000000000000000000000000000007724554482d505300000000000000000000000000000000000000000000000000 --chain-id mainnet --watch

With output

Contract verification status:
Response: `NOTOK`
Details: `Fail - Unable to verify. Please check if the correct constructor argument was entered.`
Contract failed to verify.
kuncle commented 1 year ago

gakonst/ethers-rs#2468

Any update? and how to build forge with special ethers version? Thanks

Evalir commented 1 year ago

@kuncle we recently released a patched foundry version—could you try doing foundryup and trying verification?

kuncle commented 1 year ago

@kuncle we recently released a patched foundry version—could you try doing foundryup and trying verification?

Thanks. But still got same error "expected value at line 1 column 1" after done foundryup.

.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-1a1d6532c4da2105e871054208d606192ed695f9) foundryup: downloading latest forge, cast, anvil, and chisel ########################################################################################################################################## 100.0% foundryup: downloading manpages ########################################################################################################################################## 100.0% foundryup: installed - forge 0.2.0 (1a1d653 2023-06-14T00:06:18.409597000Z) foundryup: installed - cast 0.2.0 (1a1d653 2023-06-14T00:06:18.409597000Z) foundryup: installed - anvil 0.1.0 (1a1d653 2023-06-14T00:06:29.034672000Z) foundryup: installed - chisel 0.1.1 (1a1d653 2023-06-14T00:06:29.176105000Z) foundryup: done!

Verify ERROR: Start verifying contract xxx deployed on goerli Error: expected value at line 1 column 1

rpedroni commented 1 year ago

@Evalir Can confirm latest foundryup: installed - forge 0.2.0 (1a1d653 2023-06-14T00:06:18.409597000Z) worked for me, thanks!

Evalir commented 1 year ago

@kuncle are you sure your error is this one? it seems like a different thing. Could you file another issue with your specific trouble and a minimal repro?

Episqol commented 1 year ago

Hello everyone, yesterday I ran into the same problem with the deployment on sepolia and binance testnet

I went through the broadcast reports and found one embarrassing moment Here is a list of arguments for the deployment from my last attempt (unable to verify), after large values in uint256 for some reason there is an abbreviated spelling (we can see it in the console logs from verbosity).

"arguments": [
        "1686830400 \u001b[2;49;39m[1.686e9]\u001b[0m",
        "1697407200 \u001b[2;49;39m[1.697e9]\u001b[0m",
        "1697507200 \u001b[2;49;39m[1.697e9]\u001b[0m",
        "10000 \u001b[2;49;39m[1e4]\u001b[0m",
        "225"
      ]

Could it be that the same values (with an appendage on the right) are passed as arguments for verification?

Here are the same arguments, but from the previous version of the contract, which I deployed with successful verification a few weeks ago

"arguments": [
        "1686830400",
        "1697407200",
        "1697507200",
        "10000",
        "225"
      ]
rpedroni commented 1 year ago

@Episqol issued this here #5150 (mostly unrelated since verification doesn't work despite this styling error occurring or not)

Evalir commented 1 year ago

Alright, will do a bit of issue management here—as this has received a few people that might have had their issue solved with the latest foundry releases, I will close this. We'll handle the separate deserialization issue here: https://github.com/foundry-rs/foundry/issues/4865 and @episqol we'll file a new issue

ThomasHeim11 commented 1 year ago

foundryup resolved my issue.

deed3e commented 10 months ago

forge 0.2.0 (https://github.com/foundry-rs/foundry/commit/8bbde620ab39246f3c89700a19dfe6f347e99f4f 2023-11-03T09:29:47.566294Z) So, i don't verify that cmd: forge script script/Test.s.sol:Test --fork-url https://data-seed-prebsc-2-s2.binance.org:8545/ --broadcast --etherscan-api-key 34UZWJC71ISRNKG45K8RR759KUFCBSYRJP -vv --via-ir --verify image