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

multiple issues with verification on blockscout since version nightly-87bc53fc6c874bd4c92d97ed180b949e3a36d78c #4909

Closed
2 tasks done
oveddan opened this issue May 9, 2023 · 12 comments
Labels
T-bug Type: bug

Comments

@oveddan
Copy link

oveddan commented May 9, 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 (43974b0 2023-05-09T00:17:51.920839000Z)

What command(s) is the bug in?

forge create

Operating System

macOS (Apple Silicon)

Describe the bug

When running forge create with the --verify flag and a --verifier-url on a custom chain, I get an error:
ETHERSCAN_API_KEY must be set, even if I have set the flag --etherscan-api-key or set ETHERSCAN_API_KEY as an environment variable.

If I add the --verify flag with a known chain that uses blockscout, I get an error on verification:

"Received error response: status=0,message=Contract source code not verified, result=None"

Deploying to Scroll Alpha

I believe scroll alpha's rpc url is a known chain. When deploying WETH contract to the scroll alpha chain and verifying it:

on latest nightly version:

forge create --rpc-url https://alpha-rpc.scroll.io/l2 \
  --legacy \
  --private-key $PRIVATE_KEY \
  --etherscan-api-key abc \
  --verifier-url https://blockscout.scroll.io/api? \
  --verify \
  src/WETH10.sol:WETH10

This is the output:

Deployer: 0xf69fEc6d858c77e969509843852178bd24CAd2B6
Deployed to: 0x0ef82DaB14798E63F1B99479Ba689e3f6A6fEb6C
Transaction hash: 0xe56b35386af9f9e63d544c08f3bcafddaa9dd9e95b3bebdefafc2789bc9abdcb
Starting contract verification...
Waiting for etherscan to detect contract deployment...
Start verifying contract `0x0ef82dab14798e63f1b99479ba689e3f6a6feb6c` deployed on scroll-alpha-testnet
Error:
Received error response: status=0,message=Contract source code not verified, result=None

If I go back to version nightly-94777647f6ea5d34572a1b15c9b57e35b8c77b41 the issue goes away:

foundryup --version nightly-94777647f6ea5d34572a1b15c9b57e35b8c77b41

forge create --rpc-url https://alpha-rpc.scroll.io/l2 \
  --legacy \
  --private-key $PRIVATE_KEY \
  --etherscan-api-key abc \
  --verifier-url https://blockscout.scroll.io/api? \
  --verify \
  src/WETH9.sol:WETH9

Output:

Deployer: 0xf69fEc6d858c77e969509843852178bd24CAd2B6
Deployed to: 0x97eb05B8db496B12244BCcf17CF377d00a99b67a
Transaction hash: 0xde25493333138d7a9d63c54a7cc2e583636e71cb02b4bfd66504d01620f36fa0
Starting contract verification...
Waiting for etherscan to detect contract deployment...
Start verifying contract `0x97eb05b8db496b12244bccf17cf377d00a99b67a` deployed on 534353

Submitting verification for [src/WETH9.sol:WETH9] "0x97eb05B8db496B12244BCcf17CF377d00a99b67a".
Submitted contract for verification:
	Response: `OK`
	GUID: `97eb05b8db496b12244bccf17cf377d00a99b67a645a9371`
	URL:
        https://blockscout.scroll.io/api?/address/0x97eb05b8db496b12244bccf17cf377d00a99b67a
Contract verification status:
Response: `OK`
Details: `Unknown UID`

Deploying on a custom L2 chain and verifying on blockscout

When running on a custom l2 chain that I believe forge doesn't recognize, with the latest version I always get the error.

Here is the command I run:

ETHERSCAN_API_KEY=abc forge create --rpc-url {{ my rpc url }} \
  --chain-id {{ my chain id }} \
  --private-key $PRIVATE_KEY \
  --etherscan-api-key asdfasdf \
  --verifier-url {{my blockscout verifier url}} \
  --verify \
  src/WETH9.sol:WETH9 

I always get an error on verification:

Start verifying contract `0x961b527b5e298569dbd7b1d90630cc515eb17a4a` deployed on {{ my custom chain id }}
Error: 
ETHERSCAN_API_KEY must be set

If I roll back to version nightly-94777647f6ea5d34572a1b15c9b57e35b8c77b41

The command works successfully and my contract is verified.

@oveddan oveddan added the T-bug Type: bug label May 9, 2023
@gakonst gakonst added this to Foundry May 9, 2023
@github-project-automation github-project-automation bot moved this to Todo in Foundry May 9, 2023
@iainnash
Copy link
Contributor

iainnash commented May 9, 2023

After some light digging:
ethers-rs does a preverify check to ensure the contract is not already verified
It expects Contract source code not verified as the start of the result object for non-verified contracts.

However, the blockscout response is:

{
  "message": "Contract source code not verified",
  "result": null,
  "status": "0"
}

and this is in the message field not the result field.

There may be further issues.

@e00dan
Copy link

e00dan commented May 19, 2023

I confirm this issue. We're having exactly the same problem. Rolling back to nightly-94777647f6ea5d34572a1b15c9b57e35b8c77b41 fixes the problem.

@mattsse
Copy link
Member

mattsse commented May 19, 2023

@Evalir perhaps this is due to Evm versions or perhaps even something earlier
ptal

@iainnash
Copy link
Contributor

iainnash commented May 19, 2023 via email

@Evalir
Copy link
Member

Evalir commented May 19, 2023

ack on this—will give it a closer look. The "good" binary is from quite a while ago so it could be a combination of things—I'd expect this to be a result of changes to the upstream APIs too

@Evalir
Copy link
Member

Evalir commented May 22, 2023

Hey hey @oveddan & @iainnash — just wanted to let you know that we're fixing the rough edges we found, and I managed to reproduce your scroll deployment issue & patch it. As soon as ethers is bumped and merged into foundry this should be fixed. relevant pr: gakonst/ethers-rs#2426 (cc @gakonst )

For the "Deploying on a custom L2 chain and verifying on blockscout" issue, I could not reproduce. What custom L2 are y'all using? Is there any chance you could provide some minimal repro example/command I could just run and hunt down? This one seems much easier than the blockscout issue we were having, just need something to work with.

Also, note that for recent nightlies you must have your EVM version set as london—it will fail otherwise as higher EVM specs right now are only available on ethereum mainnet/testnets.

@kahuang
Copy link

kahuang commented May 30, 2023

@Evalir I have a public devnet that you can use here: https://app.conduit.xyz/published/view/initial-maroon-gull-l2q9o5k7zz

The standard dev accounts have infinite eth. Example command I'm running that runs into an issue:

% forge verify-contract 0xdc64a140aa3e981100a9beca4e685f962f0cf6c9 ./src/Counter.sol:Counter --chain-id 901 --verifier-url https://explorerl2-initial-maroon-gull-l2q9o5k7zz.t.conduit.xyz/api --verifier blockscout""

Counter.sol is just the bundled contract from forge init.

@Evalir
Copy link
Member

Evalir commented Jun 1, 2023

awesome, thanks for that @kahuang. I've hunted down what seemed to be the last issue on blockscout-etherscan verification: gakonst/ethers-rs#2453

I've tested deploying quite a few contracts and verifying them across different chains including yours—but I can't seem to verify any contracts on your instance. The same contract with solc and evm version combo that works when verified on other chains doesn't work on yours. More accurately, it throws this error:

{ status: "1", message: "OK", result: "Unknown UID" }

I think it might be that the instance is not configured properly—there are also some other features broken (search, for example). Is it possible for you to check? Happy to follow up as soon as you do.

Also, note that you must not use a solidity version above 0.8.18, nor an evm version higher than london—verification won't work otherwise as your chain doesn't support these. I recommend setting these on your foundry.toml.

@Evalir
Copy link
Member

Evalir commented Jun 7, 2023

Should be fixed with the fixes on ethers. gakonst/ethers-rs#2453 & gakonst/ethers-rs#2426

@Evalir Evalir closed this as completed Jun 7, 2023
@github-project-automation github-project-automation bot moved this from Todo to Done in Foundry Jun 7, 2023
@hunter-bera
Copy link

@oveddan Could you try putting --etherscan-api-key after --verify, otherwise the options will be omitted by verify command

@Hugo0
Copy link

Hugo0 commented May 11, 2024

Still have this issue :(

@silvercondor
Copy link

silvercondor commented Jun 18, 2024

any fix for this? facing the same issue

using a workaround which is to forge create followed by forge verify-contract

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

9 participants