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

Verifying diamonds with hardhat etherscan-verify results in error #188

Closed
rayanoncyber opened this issue Sep 12, 2021 · 4 comments
Closed

Comments

@rayanoncyber
Copy link

When using etherscan-verify to verify a Diamond contract, the following error gets thrown for the facet

Error: types/values length mismatch (count={"types":2,"values":1}, value={"types":[{"components":[{"internalType":"address","name":"facetAddress","type":"address"},{"internalType":"enum IDiamondCut.FacetCutAction","name":"action","type":"uint8"},{"internalType":"bytes4[]","name":"functionSelectors","type":"bytes4[]"}],"internalType":"struct IDiamondCut.FacetCut[]","name":"_diamondCut","type":"tuple[]"},{"components":[{"internalType":"address","name":"owner","type":"address"}],"internalType":"struct Diamond.DiamondArgs","name":"_args","type":"tuple"}],"values":["0xB812f503607Ee2259E9607Cb5E5836B550ac6492"]}, code=INVALID_ARGUMENT, version=abi/5.4.1) at Logger.makeError (/Users/rayan/Documents/Cyber/Tech/factory/packages/contracts/node_modules/hardhat-deploy/node_modules/@ethersproject/logger/src.ts/index.ts:225:28) at Logger.throwError (/Users/rayan/Documents/Cyber/Tech/factory/packages/contracts/node_modules/hardhat-deploy/node_modules/@ethersproject/logger/src.ts/index.ts:237:20) at AbiCoder.encode (/Users/rayan/Documents/Cyber/Tech/factory/packages/contracts/node_modules/hardhat-deploy/node_modules/@ethersproject/abi/src.ts/abi-coder.ts:102:20) at submit (/Users/rayan/Documents/Cyber/Tech/factory/packages/contracts/node_modules/hardhat-deploy/src/etherscan.ts:308:12) at processTicksAndRejections (internal/process/task_queues.js:97:5) at async Object.submitSources (/Users/rayan/Documents/Cyber/Tech/factory/packages/contracts/node_modules/hardhat-deploy/src/etherscan.ts:425:5) at async SimpleTaskDefinition.action (/Users/rayan/Documents/Cyber/Tech/factory/packages/contracts/node_modules/hardhat-deploy/src/index.ts:774:5) at async Environment._runTaskDefinition (/Users/rayan/Documents/Cyber/Tech/factory/packages/contracts/node_modules/hardhat/src/internal/core/runtime-environment.ts:217:14) at async Environment.run (/Users/rayan/Documents/Cyber/Tech/factory/packages/contracts/node_modules/hardhat/src/internal/core/runtime-environment.ts:129:14) at async main (/Users/rayan/Documents/Cyber/Tech/factory/packages/contracts/node_modules/hardhat/src/internal/cli/cli.ts:197:5) { reason: 'types/values length mismatch', code: 'INVALID_ARGUMENT', count: { types: 2, values: 1 }, value: { types: [ [Object], [Object] ], values: [ '0xB812f503607Ee2259E9607Cb5E5836B550ac6492' ] } }

@wighawag
Copy link
Owner

If you have a repo, that would help

But at least put the command you use and give the full console output

Thanks

@rayanoncyber
Copy link
Author

rayanoncyber commented Sep 12, 2021

You can find the repo I'm trying to verify here (https://github.com/oncyberio/factory/tree/verification/packages/contracts), I've taken out the deployment script for the first contract as I'm only trying to deploy & verify the second.

I run hardhat etherscan-verify --network rinkeby

`

hardhat etherscan-verify --network rinkeby

verifying CyberDestinationUtilityFactoryFacet (0x0d84BF4A82DC7771c09c37BAcF5B7DD6a37d50Ae) ...
waiting for result...
Failed to verify contract CyberDestinationUtilityFactoryFacet: NOTOK, Fail - Unable to verify
{
"apikey": "XXXXXX",
"module": "contract",
"action": "verifysourcecode",
"contractaddress": "0x0d84BF4A82DC7771c09c37BAcF5B7DD6a37d50Ae",
"sourceCode": "...",
"codeformat": "solidity-standard-json-input",
"contractname": "contracts/DestinationUtility/CyberDestinationUtilityFactoryFacet.sol:CyberDestinationUtilityFactoryFacet",
"compilerversion": "v0.8.7+commit.e28d00a7",
"licenseType": 3
}
Etherscan sometime fails to verify when only metadata sources are given. See ethereum/solidity#9573. You can add the option --solc-input to try with full solc-input sources. This will include all contract source in the etherscan result, even the one not relevant to the contract being verified
already verified: Diamantaire (0xB812f503607Ee2259E9607Cb5E5836B550ac6492), skipping.
verifying DiamondCyberDestinationUtilityFactory (0xd068bcf331ABA7B2aB91779C179C1288205887Df) ...
An unexpected error occurred:

Error: types/values length mismatch (count={"types":2,"values":1}, value={"types":[{"components":[{"internalType":"address","name":"facetAddress","type":"address"},{"internalType":"enum IDiamondCut.FacetCutAction","name":"action","type":"uint8"},{"internalType":"bytes4[]","name":"functionSelectors","type":"bytes4[]"}],"internalType":"struct IDiamondCut.FacetCut[]","name":"_diamondCut","type":"tuple[]"},{"components":[{"internalType":"address","name":"owner","type":"address"}],"internalType":"struct Diamond.DiamondArgs","name":"_args","type":"tuple"}],"values":["0xB812f503607Ee2259E9607Cb5E5836B550ac6492"]}, code=INVALID_ARGUMENT, version=abi/5.4.1)
at Logger.makeError (/Users/rayan/Documents/Cyber/Tech/factory/packages/contracts/node_modules/hardhat-deploy/node_modules/@ethersproject/logger/src.ts/index.ts:225:28)
at Logger.throwError (/Users/rayan/Documents/Cyber/Tech/factory/packages/contracts/node_modules/hardhat-deploy/node_modules/@ethersproject/logger/src.ts/index.ts:237:20)
at AbiCoder.encode (/Users/rayan/Documents/Cyber/Tech/factory/packages/contracts/node_modules/hardhat-deploy/node_modules/@ethersproject/abi/src.ts/abi-coder.ts:102:20)
at submit (/Users/rayan/Documents/Cyber/Tech/factory/packages/contracts/node_modules/hardhat-deploy/src/etherscan.ts:308:12)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async Object.submitSources (/Users/rayan/Documents/Cyber/Tech/factory/packages/contracts/node_modules/hardhat-deploy/src/etherscan.ts:425:5)
at async SimpleTaskDefinition.action (/Users/rayan/Documents/Cyber/Tech/factory/packages/contracts/node_modules/hardhat-deploy/src/index.ts:774:5)
at async Environment._runTaskDefinition (/Users/rayan/Documents/Cyber/Tech/factory/packages/contracts/node_modules/hardhat/src/internal/core/runtime-environment.ts:217:14)
at async Environment.run (/Users/rayan/Documents/Cyber/Tech/factory/packages/contracts/node_modules/hardhat/src/internal/core/runtime-environment.ts:129:14)
at async main (/Users/rayan/Documents/Cyber/Tech/factory/packages/contracts/node_modules/hardhat/src/internal/cli/cli.ts:197:5) {
reason: 'types/values length mismatch',
code: 'INVALID_ARGUMENT',
count: { types: 2, values: 1 },
value: {
types: [ [Object], [Object] ],
values: [ '0xB812f503607Ee2259E9607Cb5E5836B550ac6492' ]
}
}
`

@wighawag
Copy link
Owner

wighawag commented Sep 12, 2021

SO there seems to be 2 different issues
CyberDestinationUtilityFactoryFacet is failing to verify. this could be due to an etherscan bug.

As for the error thrown it is due to the number of arguments in the deployment file not matching the number of arguments the constructor expect.

see https://github.com/oncyberio/factory/blob/65b0ba1be56bc079f61d911b5f78b494143f2cb3/packages/contracts/deployments/rinkeby/DiamondCyberDestinationFactory.json#L5-L43

it expect 2 argument but only 1 was saved here : https://github.com/oncyberio/factory/blob/65b0ba1be56bc079f61d911b5f78b494143f2cb3/packages/contracts/deployments/rinkeby/DiamondCyberDestinationFactory.json#L887

@wighawag
Copy link
Owner

wighawag commented Oct 3, 2021

should be fixed in newer version. for existing deployment you can replace the args field with the following:

"args": [
    [
        {
            "facetAddress": "0x35d80a53f7be635f75152221d4d71cd4dcb07e5c",
            "action": 0,
            "functionSelectors": [
                "0x1f931c1c"
            ]
        },
        {
            "facetAddress": "0xc1bbdf9f8c0b6ae0b4d35e9a778080b691a72a3e",
            "action": 0,
            "functionSelectors": [
                "0xadfca15e",
                "0x7a0ed627",
                "0xcdffacc6",
                "0x52ef6b2c",
                "0x01ffc9a7"
            ]
        },
        {
            "facetAddress": "0xcfEe10af6C7A91863c2bbDbCCA3bCB5064A447BE",
            "action": 0,
            "functionSelectors": [
                "0xf2fde38b",
                "0x8da5cb5b"
            ]
        }
    ],
    {
        "owner": "<the original owner>"
    }
],

@wighawag wighawag closed this as completed Oct 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants