Implicit actions do not run in non-interactive mode for deploy
Non-interactive usage of oz deploy with --kind upgradeable fails (with --kind regular it works as expected).
For instance (with v2.8) from CLI in a terminal…
Non-interactive version fails:
npx oz init ? Welcome to the OpenZeppelin SDK! Choose a name for your project test ? Initial project version 1.0.0 Project initialized. Write a new contract in the contracts folder and run ‘openzeppelin deploy’ to deploy it. % npx openzeppelin deploy Box --kind upgradeable --no-interactive --network development ✓ Compiled contracts with solc 0.5.17 (commit.d19bba13) Contract Box not found in this project
Interactive version works as expected: % npx oz init ? Welcome to the OpenZeppelin SDK! Choose a name for your project test ? Initial project version 1.0.0 Project initialized. Write a new contract in the contracts folder and run ‘openzeppelin deploy’ to deploy it. % npx oz deploy ✓ Compiled contracts with solc 0.5.17 (commit.d19bba13) ? Choose the kind of deployment upgradeable ? Pick a network development ? Pick a contract to deploy Box ✓ Added contract Box ✓ Contract Box deployed All implementations have been deployed ? Call a function to initialize the instance after creating it? Yes ? Select which function store(newValue: uint256) ? newValue: uint256: 1 ✓ Setting everything up to create contract instances ✓ Instance created at 0x26b4AFb60d6C903165150C6F0AA14F8016bE4aec 0x26b4AFb60d6C903165150C6F0AA14F8016bE4aec
Interestingly, if I do oz init, then the interactive deploy then the non-interactive way in a consecutive sequence then the non-interactive option works
% npx oz init ? Welcome to the OpenZeppelin SDK! Choose a name for your project test ? Initial project version 1.0.0 Project initialized. Write a new contract in the contracts folder and run ‘openzeppelin deploy’ to deploy it. % npx oz deploy ✓ Compiled contracts with solc 0.5.17 (commit.d19bba13) ? Choose the kind of deployment upgradeable ? Pick a network development ? Pick a contract to deploy Box ✓ Added contract Box ✓ Contract Box deployed All implementations have been deployed ? Call a function to initialize the instance after creating it? Yes ? Select which function store(newValue: uint256) ? newValue: uint256: 1 ✓ Setting everything up to create contract instances ✓ Instance created at 0xFC628dd79137395F3C9744e33b1c5DE554D94882 0xFC628dd79137395F3C9744e33b1c5DE554D94882 % npx oz deploy Box --kind upgradeable --no-interactive --network development Nothing to compile, all contracts are up to date. ✓ Instance created at 0x5f8e26fAcC23FA4cbd87b8d9Dbbd33D5047abDE1 0x5f8e26fAcC23FA4cbd87b8d9Dbbd33D5047abDE1
Hi @dannesbitt! I’m sorry that you had this issue.
We have been able to reproduce this issue by following these steps: Attempt to deploy Box contract as upgradeable non-interactive
$ npx openzeppelin deploy Box --kind upgradeable --no-interactive --network development
✓ Compiled contracts with solc 0.5.17 (commit.d19bba13)
Contract Box not found in this project
Thanks so much for reporting it! The project owner will review and triage this issue during the next week. In the meantime, you can try the following workaround: First deploy the contract as upgradeable interactively
$ npx oz deploy
Nothing to compile, all contracts are up to date.
? Choose the kind of deployment upgradeable
? Pick a network development
? Pick a contract to deploy Box
✓ Added contract Box
✓ Contract Box deployed
All implementations have been deployed
? Call a function to initialize the instance after creating it? No
✓ Setting everything up to create contract instances
✓ Instance created at 0x6eD79Aa1c71FD7BdBC515EfdA3Bd4e26394435cC
To upgrade this instance run 'oz upgrade'
0x6eD79Aa1c71FD7BdBC515EfdA3Bd4e26394435cC
Hi, this issue is due to a side effect of non-interactive mode: there are some implicit actions in create that are skipped for backwards compatibility reasons, including add in this case. Before an upgradeable deploy the contract must be added to the project, and this is generally done automatically, except when in non-interactive mode.
This should be considered a bug in deploy, though, and should be fixed.
As a workaround, you can run oz add Box followed by oz push -n development prior to running oz deploy.
Hi @frangio , thanks for reviewing this. Unfortunately I don't think the proposed work around of using add followed by deploy is functional with non-interactive deploy usage e.g:
% npx oz init
? Welcome to the OpenZeppelin SDK! Choose a name for your project test
? Initial project version 1.0.0
Project initialized. Write a new contract in the contracts folder and run 'openzeppelin deploy' to deploy it.
% npx oz add Box
✓ Compiled contracts with solc 0.5.17 (commit.d19bba13)
✓ Added contract Box
% npx oz deploy Box --kind upgradeable --no-interactive --network development
Nothing to compile, all contracts are up to date.
Contract Box is not deployed to dev-1585864725285.
You're right, apologies. There's another implicit commands that has to run, oz push.
npx oz add Box
npx oz push -n development
npx oz deploy Box -k upgradeable -n development
I've edited the previous comment to add this command.
Coming from https://github.com/OpenZeppelin/openzeppelin-sdk/issues/1526:
Yes, confirming in my case that adding an initializer function does not help for initial deployment (but works for the following). In production it's not an issue, but I used it in test scripts resetting the project and network often.
Nice to see this treated as a bug, will wait for a fix.
Maybe I missed that in docs (sorry if yes), but I don't remember if those details are somewhere documented, particularly that
- an initializer function must exist (interactively it is optional)
- deploy command runs it implicitly
- deploy accepts extra args after contract name to run the initializer.
If it is missed, would be good to have it documented. Thanks!
Those are great points, thank you! Will let you all know as soon as I have an ETA for this.