Closed blmalone closed 2 weeks ago
@yash-atreya Is this something that's possible right now or is this a feature request?
@zerosnacks @yash-atreya bumping this 🙏🏻
Hi @blmalone
I don't think it is currently supported but should be easy to add, happy to accept a PR for this
Should be added in (or split out into a utility file to prevent code duplication)
Is this something you would like to work on?
Hey @yash-atreya just confirming you are working on this? If so that would be a big help for us! 🙏
Also just to confirm the issue here: I see https://book.getfoundry.sh/reference/config/etherscan says that we should be able to use:
[etherscan]
unknown_chain = { key = "ABCDEFG", url = "<etherscan api url for this chain>" }
to handle a case like this. @blmalone did this not work, and the scope of this issue is to make sure forge verify-bytecode
picks that up? Or is native support for blockscout needed for another reason?
When I change my foundry.toml
to look like this:
[etherscan]
unknown_chain = { key = "", url = "https://explorer.mode.network/" }
and then I run the command:
forge verify-bytecode 0xC0d3c0d3c0D3c0d3C0D3c0D3C0d3C0D3C0D30010 L2StandardBridge --rpc-url https://mainnet.mode.network/ --json
I get the following error:
Response result is unexpectedly empty: status=1, message=OK
AFAIK, you can use https://explorer.mode.network/
like you can the Etherscan api e.g.
This isn't working for me, does the forge verify-bytecode
command know about the etherscan property in the foundry.toml?
Hey @yash-atreya just confirming you are working on this? If so that would be a big help for us! 🙏
@mds1 Yash will be out until the 27th so I re-assigned this to me given the priority, I previously assigned it to him as he is most familiar with this code. I'm aiming to get a PR up before tomorrow EOD.
Hey @blmalone. I recall having some verification issues with blockscout when I was using a foundry.toml
config. There were two non trivial things that might have been fixed since then, but that could help your case:
So that would look like this in your case:
[etherscan]
mode = { key = "GM", url = "https://explorer.mode.network/api?" }
Was able to narrow down the error of Response result is unexpectedly empty: status=1, message=OK
to
etherscan.contract_creation_data(args.address).await?
This is presumably because 0xC0d3c0d3c0D3c0d3C0D3c0D3C0d3C0D3C0D30010
is a special system contract initiated at Genesis that has no matching transaction hash and deployer address and is therefore not handled properly.
It might be possible to add a specific workaround for this edge case for you, open to suggestions.
Related code: https://github.com/foundry-rs/block-explorers/blob/d44051a4e5fd4a522739b3c2be6df6aeebca849b/crates/block-explorers/src/contract.rs#L454-L489 + https://github.com/foundry-rs/block-explorers/blob/d44051a4e5fd4a522739b3c2be6df6aeebca849b/crates/block-explorers/src/errors.rs#L29-L30
The message returned by Blockscout is "{\"message\":\"OK\",\"result\":[],\"status\":\"1\"}"
with RUST_LOG=trace ETHERSCAN_API_KEY="A" forge verify-bytecode 0xC0d3c0d3c0D3c0d3C0D3c0D3C0d3C0D3C0D30010 L2StandardBridge --rpc-url "https://mainnet.mode.network"
https://github.com/foundry-rs/foundry/pull/8510 is a draft PR that implements --verifier-url
/ --verifier (etherscan, sourcify, blockscout, oklink)
support to forge verify-bytecode
which should make it easier to pass alternative verifiers by CLI which I do think is a strict improvement but does not resolve your issue.
@zerosnacks Thanks for looking into this.
This is presumably because 0xC0d3c0d3c0D3c0d3C0D3c0D3C0d3C0D3C0D30010 is a special system contract initiated at Genesis that has no matching transaction hash and deployer address and is therefore not handled properly.
It might be possible to add a specific workaround for this edge case for you, open to suggestions.
Good point, this is a predeploy contract and it's runtime code is set at genesis so there won't be a creation transaction.
On a related note, the fix for the following issue actually checks for a creation transaction in order to determine the constructor args: https://github.com/foundry-rs/foundry/issues/8545.
Supporting predeploy contracts would be super helpful for us and our ongoing work with delivering the Superchain at Op Labs.
Does having an additional flag that tells the forge vb
command to only check either the runtime or init code provide a workaround that makes sense here? i.e. default to checking both init and runtime code but if a user says for example: forge vb ... ... --ignore initcode
then only the runtime code will be checked.
Component
Forge
Have you ensured that all of these are up to date?
What version of Foundry are you on?
forge 0.2.0 (e903484 2024-07-19T00:18:41.070490000Z)
What command(s) is the bug in?
forge verify-bytecode
Operating System
macOS (Apple Silicon)
Describe the bug
This is very important for Op Labs to get working.
I want to do bytecode verification on networks that don't have Etherscan setup. e.g. https://metalscan.io/ https://explorer.mode.network/
They seem to have BlockScout explorers and as far as I understand blockscout has made their api etherscan compatible i.e. https://docs.blockscout.com/for-users/api/rpc-endpoints
e.g.
Is this something I can configure with foundry?