sudo dfx canister install hello_rs --argument='(1)' -m=reinstall
Reinstalling code for canister hello_rs, with canister_id ryjl3-tyaaa-aaaaa-aaaba-cai
The invocation to the wallet call forward method failed with the error: An error happened during the call: 5: Canister ryjl3-tyaaa-aaaaa-aaaba-cai trapped explicitly: Custom("No more values to deserialize")
sudo dfx canister install hello_rs -m=reinstall
Reinstalling code for canister hello_rs, with canister_id ryjl3-tyaaa-aaaaa-aaaba-cai
The invocation to the wallet call forward method failed with the error: An error happened during the call: 5: Canister ryjl3-tyaaa-aaaaa-aaaba-cai trapped explicitly: Custom("No more values to deserialize")
I believe I need to clarify the canister lifecycle a bit.
The first time you install canister code, the init function is called.
If you decide to wipe out the old version of your canister and replace it with new code (by specifying --mode=reinstall option of the dfx canister install command), the init function is called after the new code is installed.
If you upgrade your canister, the init function is not called. The system first calls canister_pre_upgrade function on the old version of the canister and then calls canister_post_upgrade on the new version.
This means that if you don’t specify upgrade hooks that use stable memory and upgrade the canister, all the state is lost. In case of something static mut TOKEN: Option<VotingToken> = None;, TOKEN becomes None again.
So my guess is that you upgraded your canister after the first installation without any upgrade hooks. This wiped away the initialized state, leading to this error. Re-installing the canister should fix the issue.
Interesting behavior: when dfx.json has two canisters to deploy, init() IS called.
Most likely, in this case a new canister was created, which triggered the (1) case in the lifecycle above.