OpenZeppelin / OpenZeppelin/openzeppelin-upgrades
Validation functions fail if contract has constructor args
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 658
- Forks
- 286
- PR merge metrics
- No merged PRs in 30d
Description
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with validateImplementation and validateUpgrade, then trace their deployment-data handling into src/utils/deploy-impl.ts, as shown in the stack trace. Reproduce the validation using a contract with a constructor argument, with and without constructorArgs, and confirm validation succeeds without requiring deployment arguments.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- blockchain
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 72/100