openzeppelin-upgrades icon indicating copy to clipboard operation
openzeppelin-upgrades copied to clipboard

Validation functions fail if contract has constructor args

Open ericglau opened this issue 3 years ago • 1 comments

If an implementation contract has a constructor that requirements arguments, running validateImplementation or validateUpgrade to validate that contract causes an error like the following:

Error: types/values length mismatch (count={"types":1,"values":0}, value={"types":[{"name":"forwarder","type":"address","indexed":null,"components":null,"arrayLength":null,"arrayChildren":null,"baseType":"address","_isParamType":true}],"values":[]}, code=INVALID_ARGUMENT, version=abi/5.7.0)
    at Logger.makeError (/myproject/node_modules/@ethersproject/logger/src.ts/index.ts:269:28)
    at Logger.throwError (/myproject/node_modules/@ethersproject/logger/src.ts/index.ts:281:20)
    at AbiCoder.encode (/myproject/node_modules/@ethersproject/abi/src.ts/abi-coder.ts:101:20)
    at Interface._encodeParams (/myproject/node_modules/@ethersproject/abi/src.ts/interface.ts:323:31)
    at Interface.encodeDeploy (/myproject/node_modules/@ethersproject/abi/src.ts/interface.ts:327:21)
    at getDeployData (/myproject/node_modules/@openzeppelin/hardhat-upgrades/src/utils/deploy-impl.ts:49:45)
    at Proxy.validateImplementation (/myproject/node_modules/@openzeppelin/hardhat-upgrades/src/validate-implementation.ts:15:24)
    at main (/myproject/scripts/validate.js:12:3) {
  reason: 'types/values length mismatch',
  code: 'INVALID_ARGUMENT',
  count: { types: 1, values: 0 },
  value: { types: [ [ParamType] ], values: [] }
}

A workaround is to provide the constructorArgs option when running the validate function: e.g. {constructorArgs: ['myArg']}

But this should be fixed to not require args when performing only validations.

ericglau avatar Sep 13 '22 13:09 ericglau

Related to https://github.com/OpenZeppelin/openzeppelin-upgrades/issues/647

frangio avatar Sep 13 '22 14:09 frangio