Confuses the constructor arguments with the complete bytecode
DAC-Philantrop opened this issue · comments
When I try to verify a contract without any constructor arguments, the plugin fetches constructor args that seem to simply be the whole contract bytecode. I tried overriding the constructor args like this:
truffle run verify MintPass@0xE090B2bD0D01DE558E50Add55e5542Bd978c667a --forceConstructorArgs string:"" --network goerli
Then he notices the constructor args that I have provided as '0x' which is nice, but then he goes on to still fetch constructor arguments, once again getting back the full bytecode.
Steps To Reproduce
I made a minimalistic repo to reproduce this.
It should be sufficient to simply deploy a contract without constructor args and then verifiying it, at least in my experience.
Environment information
- Operating System: Windows 11
- Truffle v5.4.33 (core: 5.4.33)
- Solidity - 0.8.11 (solc-js)
- Node v16.1.0
Debug output
output without overriding constructor args:
truffle run verify Reproducer@0x89e51c4442E6f79757305937dC89217CbEB0a0Ca --network ropsten --debug
DEBUG logging is turned ON
Running truffle-plugin-verify v0.5.21
Retrieving network's chain ID
Verifying Reproducer@0x89e51c4442E6f79757305937dC89217CbEB0a0Ca
Reading artifact file at C:\Users\thoms\vs-repos\rand-telgram\build\contracts\Reproducer.json
Custom address 0x89e51c4442E6f79757305937dC89217CbEB0a0Ca specified
Retrieving constructor parameters from https://api-ropsten.etherscan.io/api?apiKey=XXX&module=account&action=txlist&address=0x89e51c4442E6f79757305937dC89217CbEB0a0Ca&page=1&sort=asc&offset=1
Constructor parameters retrieved: 0x5b6000819050919050565b6099816088565b811460a357600080fd5b5056fea2646970667358221220519fd7456765bcb1ca2eaf6de521e701bbe97192d579397e4204148548ea600564736f6c63430008040033
Sending verify request with POST arguments:
{
"apikey": "xxx",
"module": "contract",
"action": "verifysourcecode",
"contractaddress": "0x89e51c4442E6f79757305937dC89217CbEB0a0Ca",
"sourceCode": "{\"language\":\"Solidity\",\"sources\":{\"/contracts/easy.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\r\\npragma solidity ^0.8.4;\\r\\n\\r\\n\\r\\ncontract Reproducer {\\r\\n uint256 x;\\r\\n constructor() {\\r\\n x = 1;\\r\\n }\\r\\n\\r\\n function setX(uint256 _x) public {\\r\\n x = _x;\\r\\n }\\r\\n}\"}},\"settings\":{\"remappings\":[],\"optimizer\":{\"enabled\":true,\"runs\":200},\"evmVersion\":\"istanbul\",\"libraries\":{}}}",
"codeformat": "solidity-standard-json-input",
"contractname": "/contracts/easy.sol:Reproducer",
"compilerversion": "v0.8.4+commit.c7e474f2",
"constructorArguements": "5b6000819050919050565b6099816088565b811460a357600080fd5b5056fea2646970667358221220519fd7456765bcb1ca2eaf6de521e701bbe97192d579397e4204148548ea600564736f6c63430008040033"
}Invalid constructor arguments provided. Please verify that they are in ABI-encoded format
Failed to verify 1 contract(s): Reproducer@0x89e51c4442E6f79757305937dC89217CbEB0a0Ca
output with overriding constructor args:
DEBUG logging is turned ON
Running truffle-plugin-verify v0.5.21
Retrieving network's chain ID
Force custructor args provided: 0x
Verifying Reproducer@0x89e51c4442E6f79757305937dC89217CbEB0a0Ca
Reading artifact file at C:\Users\thoms\vs-repos\rand-telgram\build\contracts\Reproducer.json
Custom address 0x89e51c4442E6f79757305937dC89217CbEB0a0Ca specified
Retrieving constructor parameters from https://api-ropsten.etherscan.io/api?apiKey=XXX&module=account&action=txlist&address=0x89e51c4442E6f79757305937dC89217CbEB0a0Ca&page=1&sort=asc&offset=1
Constructor parameters retrieved: 0x5b6000819050919050565b6099816088565b811460a357600080fd5b5056fea2646970667358221220519fd7456765bcb1ca2eaf6de521e701bbe97192d579397e4204148548ea600564736f6c63430008040033
Sending verify request with POST arguments:
{
"apikey": "xxx",
"module": "contract",
"action": "verifysourcecode",
"contractaddress": "0x89e51c4442E6f79757305937dC89217CbEB0a0Ca",
"sourceCode": "{\"language\":\"Solidity\",\"sources\":{\"/contracts/easy.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\r\\npragma solidity ^0.8.4;\\r\\n\\r\\n\\r\\ncontract Reproducer {\\r\\n uint256 x;\\r\\n constructor() {\\r\\n x = 1;\\r\\n }\\r\\n\\r\\n function setX(uint256 _x) public {\\r\\n x = _x;\\r\\n }\\r\\n}\"}},\"settings\":{\"remappings\":[],\"optimizer\":{\"enabled\":true,\"runs\":200},\"evmVersion\":\"istanbul\",\"libraries\":{}}}",
"codeformat": "solidity-standard-json-input",
"contractname": "/contracts/easy.sol:Reproducer",
"compilerversion": "v0.8.4+commit.c7e474f2",
"constructorArguements": "5b6000819050919050565b6099816088565b811460a357600080fd5b5056fea2646970667358221220519fd7456765bcb1ca2eaf6de521e701bbe97192d579397e4204148548ea600564736f6c63430008040033"
}
Invalid constructor arguments provided. Please verify that they are in ABI-encoded format
Failed to verify 1 contract(s): Reproducer@0x89e51c4442E6f79757305937dC89217CbEB0a0Ca```
When I add some random constructor Argument to the contract, it works as intended
Thanks for the bug report! I've just published v0.5.24 that should fix the issue.