So I have got further with the tutorial for creating and deploying an upgradeable contract. As per the tutorial (https://docs.zeppelinos.org/docs/upgrading.html) I have managed to deploy the initial contract, add the new increment function and all looks good. However when I try and add a new state variable and initialization function (initializeT) then I get the following errors when trying to access the variable from the truffle console:
truffle(development)> mc = await MyContract.at('0x66eB4e0368B726d4737fFaa9a3d16AE225F06493')
undefined
truffle(development)> mc.s()
'hitchiker'
truffle(development)> (await mc.x()).toString()
'44'
truffle(development)> (await mc.t()).toString()
Error: Invalid number of parameters for "t". Got 0 expected 2!
The contract was upgraded as follows:
rick@archlinux ~/dev/zos npx zos update MyContract --init initializeT --args 99
Using session with network development, sender address 0xED609586F5bE1ADc8d3f9f5a7cEA8Dab45a42A53, timeout 600 seconds
Upgrading proxy to logic contract 0x3203620c4aF995FB247C001885708ebf77E45d45 and initializing by calling initializeT with:
_t (uint256): “99”
Upgrading proxy at 0x66eB4e0368B726d4737fFaa9a3d16AE225F06493 and calling initializeT with:
I followed the tutorial and am getting the same error as you Error: Invalid number of parameters for "t". Got 0 expected 2! when calling (await mc.t()).toString()
Interesting… is it a coincidence that the method signature shown, 't(uint256, sttring)' is similar to the initial implementation of the initialize function in the first deployment of the contract?
FYI - my versions:
zos: 2.2.3
truffle: 5.0.18
ganache: 6.3.0
I retried successfully with an earlier version of truffle and ganache-cli npx zos --version 2.2.3 npx truffle version Truffle v5.0.2 (core: 5.0.2) npx ganache-cli Ganache CLI v6.3.0 (ganache-core: 2.4.0)
Hi @abcoathup@spalladino, thanks for following up with this… I will also try a different version of truffle.
Would this be a case of removing any existing truffle via ‘npm uninstall’ and then doing an ‘npm install truffle@5.0.0’?
Can I ask what the implications of this issue are? Does it mean that the upgradeability would not work if we were to inadvertently use an older version of truffle with zos?
To change versions of truffle it is just npm uninstall truffle and npm install truffle@5.0.4
I restarted the tutorial (deleted contents of MyContract.sol, deleted zos.dev...json and the build directory) and didn’t run into any issues. The tutorial currently states to use truffle@5.0.4. I also used ganache-cli 6.3.0.
The implications of something like this is that if you ever experienced an issue with a smart contract whilst testing an upgrade (either locally or on a testnet) then you could report on the forum to get a solution. Once you had a solution (which could be as simple as use a specific version) you could then retest locally and on testnets before upgrading on mainnet.
Just to confirm I can also see that this is not an issue if I use an older version of truffle (5.0.0 in my case)… so something in a recent truffle update seems to have broken things…
Hey @roy.batty, thanks for reporting this! I've managed to reproduce this in a sample project without zOS at all. It would seem that the version of truffle that breaks this is 5.0.13 (.12 worked fine for me). I've filed this issue to report it, feel free to add any further info there.
This only seems to affect the ABI of the compiled artifact, not the bytecode nor the AST. So the contracts you are deploying or upgrading should be unaffected. This should only impact your client code, since when you try to call the contract, the truffle-contract object will have an incorrect ABI registered.