foundry icon indicating copy to clipboard operation
foundry copied to clipboard

bug(forge script): contract created by constructor fails to be verified

Open zhangninghai opened this issue 2 years ago • 6 comments

Component

Forge

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

  • [X] Foundry
  • [X] Foundryup

What version of Foundry are you on?

forge 0.2.0 (f9ca6ec 2023-10-09T00:31:35.276575000Z)

What command(s) is the bug in?

forge script script/proxy2.s.sol:CounterScript --rpc-url $HOLESKY_RPC_URL --broadcast --verify -vvvv

Operating System

macOS (Apple Silicon)

Describe the bug

截屏2023-10-11 13 58 57 截屏2023-10-11 13 33 26

Submitted contract for verification: Response: OK GUID: r2guhchw9zuqmd77wngnkbdfn6719m9esaemenrzmprhetwkat URL: https://holesky.etherscan.io/address/0xd2cee67865574f35d794f3093c3ff0d2f16b8c1b Contract verification status: Response: NOTOK Details: Pending in queue Contract verification status: Response: NOTOK Details: Fail - Unable to verify. Compiled contract deployment bytecode does NOT match the transaction deployment bytecode. Contract failed to verify.

Inherit the contract, the contract created inside the constructor failed to verify

zhangninghai avatar Oct 11 '23 06:10 zhangninghai

For future reference and additional details:

OP is correct that this is an issue

  • https://holesky.etherscan.io/address/0x70c6e67b14e0daa3cb2e629bb42e351d113e4799 (Proxy, correct)
  • https://holesky.etherscan.io/address/0x59ce128f9dadd7337bfe06a779b3dd777d565b89 (Counter, correct)
  • https://holesky.etherscan.io/address/0x8b6b1a8d6998d40400c982ded20ce04382c4e5f5#code (ProxyAdmin, fails to verify), deploys ProxyAdmin in the constructor: https://holesky.etherscan.io/address/0x70c6e67b14e0daa3cb2e629bb42e351d113e4799#internaltx
    /**
     * @dev Initializes an upgradeable proxy managed by an instance of a {ProxyAdmin} with an `initialOwner`,
     * backed by the implementation at `_logic`, and optionally initialized with `_data` as explained in
     * {ERC1967Proxy-constructor}.
     */
    constructor(address _logic, address initialOwner, bytes memory _data) payable ERC1967Proxy(_logic, _data) {
        _admin = address(new ProxyAdmin(initialOwner));
        // Set the storage value and emit an event for ERC-1967 compatibility
        ERC1967Utils.changeAdmin(_proxyAdmin());
    }

Log:

ONCHAIN EXECUTION COMPLETE & SUCCESSFUL.
##
Start verification for (3) contracts
Start verifying contract `0x59CE128F9daDD7337BFE06a779B3DD777D565b89` deployed on holesky

Submitting verification for [src/Counter.sol:Counter] 0x59CE128F9daDD7337BFE06a779B3DD777D565b89.
Submitted contract for verification:
	Response: `OK`
	GUID: `v8b6p19gcxbef9vfifyxbywcv5st9fztgj2p4jhqs6ntbe1nmn`
	URL: https://holesky.etherscan.io/address/0x59ce128f9dadd7337bfe06a779b3dd777d565b89
Contract verification status:
Response: `NOTOK`
Details: `Pending in queue`
Contract verification status:
Response: `OK`
Details: `Pass - Verified`
Contract successfully verified
Start verifying contract `0x70C6E67b14e0daA3cB2e629bB42e351d113E4799` deployed on holesky

Submitting verification for [src/Counter.sol:Proxy] 0x70C6E67b14e0daA3cB2e629bB42e351d113E4799.
Submitted contract for verification:
	Response: `OK`
	GUID: `mpxpzxcybk8g7xyhxx7gbzna5va32g457mjbwhk5d5yygkygmj`
	URL: https://holesky.etherscan.io/address/0x70c6e67b14e0daa3cb2e629bb42e351d113e4799
Contract verification status:
Response: `NOTOK`
Details: `Pending in queue`
Contract verification status:
Response: `OK`
Details: `Pass - Verified`
Contract successfully verified
Start verifying contract `0x8b6B1A8d6998d40400C982dED20CE04382c4E5F5` deployed on holesky

Submitting verification for [lib/openzeppelin-contracts/contracts/proxy/transparent/ProxyAdmin.sol:ProxyAdmin] 0x8b6B1A8d6998d40400C982dED20CE04382c4E5F5.
Submitted contract for verification:
	Response: `OK`
	GUID: `gwgglm2niwm9xvg4akdwmfl33vspjkxughqaps1xazzghw72sc`
	URL: https://holesky.etherscan.io/address/0x8b6b1a8d6998d40400c982ded20ce04382c4e5f5
Contract verification status:
Response: `NOTOK`
Details: `Pending in queue`
Contract verification status:
Response: `NOTOK`
Details: `Fail - Unable to verify. Compiled contract deployment bytecode does NOT match the transaction deployment bytecode.`
Contract failed to verify.

zerosnacks avatar Jul 04 '24 12:07 zerosnacks

@zerosnacks I have the same problem, but with a slight difference: ProxyAdmin verification fails and this leads to the fact that all deployed contracts after ProxyAdmin cannot be verified.

StackOverflowExcept1on avatar Jul 07 '24 19:07 StackOverflowExcept1on

Is this only happening on holesky? I was able to manually verify 0x8b6b1a8d6998d40400c982ded20ce04382c4e5f5 by submitting json input bundle to etherscan, however, the verification through forge verify-contract 0x8b6b1a8d6998d40400c982ded20ce04382c4e5f5 --constructor-args '0000000000000000000000001804c8ab1f12e6bbf3894d4083f33e07309d1f38' didn't work, though arguments are correct

I was also able to successfuly verify such deployment on sepolia

klkvr avatar Jul 10 '24 23:07 klkvr

@klkvr I'm using this: https://github.com/OpenZeppelin/openzeppelin-foundry-upgrades

StackOverflowExcept1on avatar Jul 10 '24 23:07 StackOverflowExcept1on

so it seems that this is indeed an Etherscan bug. I was only able to reproduce this on Holesky. Verification is failing during both script execution and if trying to verify manually through forge verify-contract

however, if you run forge verify-contract --show-standard-json-input and submit printed input manually, verification succeeds

klkvr avatar Jul 10 '24 23:07 klkvr

Previously have some issue on Holesky, but now it is fixed. Can you please try again and let us know if it's still happening?

Thanks

homeyong avatar Aug 14 '24 09:08 homeyong

Confirming this is no longer an issue on Holesky, marking ticket as resolved.

zerosnacks avatar Nov 04 '24 11:11 zerosnacks