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

Can't Verify Contracts in Either Sepolia or Moonbase Alpha/Moonbeam because of Failed to deserialize response #5741

Closed
2 tasks done
albertov19 opened this issue Aug 29, 2023 · 4 comments
Labels
T-bug Type: bug

Comments

@albertov19
Copy link
Contributor

albertov19 commented Aug 29, 2023

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 (bff4ed9 2023-08-29T00:16:15.395348141Z)

What command(s) is the bug in?

forge verify-contract

Operating System

Linux

Describe the bug

I have a very simple contract that I was able to verify with the Hardhat Etherscan plugin. Consequently I was going to try verifying it with Foundry in Moonbase Alpha and I ran into the following error:

forge verify-contract --chain-id 1287 \
--verifier etherscan \
--verifier-url https://api-moonbase.moonscan.io/api \
0x06F789662F6a776BF1C551409985311b52C41a32 \
--constructor-args 0x0000000000000000000000000000000000000000000000000000000000000014 \
src/Number.sol:Number \
--etherscan-api-key MY_API_KEY

Start verifying contract `0x06f789662f6a776bf1c551409985311b52c41a32` deployed on moonbase
2023-08-29T12:31:35.427671Z ERROR etherscan: Failed to deserialize response: expected value at line 1 column 1 res="<!DOCTYPE html><html lang=\"en-US\"><head><title>Just a moment...</title><meta http-equiv=\"Content-Type\" content=\"t
..... A LOT OF THINGS .......
Xzgw7a3gr5MEPQlJTp3M0-1693312295-0-gaNycGzNCrs\" + window._cf_chl_opt.cOgUHash);cpo.onload = function() {history.replaceState(null, null, ogU);};}document.getElementsByTagName('head')[0].appendChild(cpo);}());</script></body></html>"
Error: 
expected value at line 1 column 1

Then I was thinking this could be an issue with Etherscan's Moonbase Alpha API. Soooo, I went to test the same thing against Sepolia (changing API Key, endpoint, chain id, etc) and the same error message there as well. I know some of my inputs are not mandatory but I was just trying different things.

The basic contract I was trying to verify is this one:

// SPDX-License-Identifier: MIT
pragma solidity =0.8.0;

contract Number {
    uint public number;

    constructor (uint _input) {
        number = _input;
    }

    function setNumberTest(uint _input) public {
        number = _input;
    }
}

Thanks for looking into it

@albertov19 albertov19 added the T-bug Type: bug label Aug 29, 2023
@gakonst gakonst added this to Foundry Aug 29, 2023
@github-project-automation github-project-automation bot moved this to Todo in Foundry Aug 29, 2023
@Evalir
Copy link
Member

Evalir commented Aug 29, 2023

gotcha—from the output i believe this might be a divergence in the moonbase and sepolia API—could you please repost this on #5251 ? we're trying to consolidate verification failures to a few issues. Thanks for reporting and the repro!

@Evalir Evalir closed this as completed Aug 29, 2023
@github-project-automation github-project-automation bot moved this from Todo to Done in Foundry Aug 29, 2023
@Enigmatic331
Copy link

Enigmatic331 commented Aug 29, 2023

PS: Team Etherscan here. When we profiled the API call from Foundry, it was something akin to https://api-moonbase.moonscan.io/api/?apikey=teehee&module=contract&action=getabi&address=0x75417d9ad3b1c1fb1ac409f5817dcc9e3df6a90e - (note the additional / behind ?) - This would trip some of our CF rule checks.

If we can get the calls to be https://api-moonbase.moonscan.io/api?apikey=teehee&module=contract&action=getabi&address=0x75417d9ad3b1c1fb1ac409f5817dcc9e3df6a90e instead it should work.

I "think" if we try --verifier-url https://api-moonbase.moonscan.io/api? it'd work.

@Evalir
Copy link
Member

Evalir commented Aug 29, 2023

thank you for chiming in @Enigmatic331 ! yep this will prob cause problems, will investigate.

@albertov19
Copy link
Contributor Author

Hey to echo what @Enigmatic331 stated. I tried the same as before with the extra ?:

forge verify-contract --chain-id 1287 \
--verifier etherscan \
--verifier-url https://api-moonbase.moonscan.io/api? \
0x06F789662F6a776BF1C551409985311b52C41a32 \
--constructor-args 0x0000000000000000000000000000000000000000000000000000000000000014 \
src/Number.sol:Number \
--etherscan-api-key MY_API_KEY

And got the right message:

Start verifying contract `0x31e7facdcf9308bdf3d8bf83b1c63ddb72727012` deployed on moonbeam

Submitting verification for [src/UniversalRouter.sol:UniversalRouter] "0x31e7faCDCf9308BDf3d8Bf83b1C63Ddb72727012".
Submitted contract for verification:
        Response: `OK`
        GUID: `idnrnjgxycrccfxiyfclixxkwm2wbrrxwk76iipjavg41s6zuq`
        URL:
        https://moonbeam.moonscan.io/address/0x31e7facdcf9308bdf3d8bf83b1c63ddb72727012\

Unfortunately it failed with just Fail - Unable to verify but that is a separate story.

@Evalir I'll move the post to the Issue you suggested. Thanks for looking into it

tsite added a commit to tsite/foundry that referenced this issue Oct 22, 2023
Etherscan verification for non-mainnet chains requires a question
mark at the end of the verifier url in order to prevent a forward slash
from being added to the url which trips a cloudflare rule on requests
from ec2 boxes.

Verification on both Goerli and Sepolia both fails without this
character present.

Hardhat-verify does not add the extra forward slash to the verifier url
and has no issues verifying contracts on etherscan.

Fixes foundry-rs#4865, foundry-rs#5251, foundry-rs#5741
mattsse pushed a commit that referenced this issue Oct 22, 2023
* fix `forge verify-contract` etherscan cloudflare bug

Etherscan verification for non-mainnet chains requires a question
mark at the end of the verifier url in order to prevent a forward slash
from being added to the url which trips a cloudflare rule on requests
from ec2 boxes.

Verification on both Goerli and Sepolia both fails without this
character present.

Hardhat-verify does not add the extra forward slash to the verifier url
and has no issues verifying contracts on etherscan.

Fixes #4865, #5251, #5741

* run cargo +nightly fmt -- --check

* check if the api url already ends with ?

Also apply the fix to --verifier-url urls
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-bug Type: bug
Projects
Archived in project
Development

No branches or pull requests

3 participants