dfinity / sdk

IC SDK: a Software Development Kit for creating and managing canister smart contracts on the ICP blockchain.
https://internetcomputer.org/developers
Apache License 2.0
173 stars 84 forks source link

(Future Issue) Missing stable compatibility warning for Motoko upgrades #3886

Closed luc-blaeser closed 2 months ago

luc-blaeser commented 2 months ago

Update: Probably not yet an issue. But this will become relevant with enhanced orthogonal persistence, cf. https://github.com/dfinity/motoko/pull/4602

dfx does not yet report warning from the Motoko stable compatibility check, only errors. As a consequence, in the future, users will not get a warning e.g. when a Motoko program upgrade drops a stable variable.

See also https://forum.dfinity.org/t/stable-variables-persistence/34039. I am not sure whether the user already tested EOP.

I tried the following with Motoko's enhanced orthogonal persistence:

  1. First Motoko program version:

    actor { 
    stable var x = 1; 
    }

    dfx deploy

  2. Second Motoko program version:

    actor { }

    dfx deploy

I expected to see this happen: A warning message that stable variable x will be dropped and state potentially lost.

Such a message is returned by moc --stable-compatible on stderr.

Instead, this happened: Upgrade without warning. Accidental loss of data.

Meta

dfx --version: 0.22.0

luc-blaeser commented 2 months ago

It seems that this is not an issue but only some change relevant for EOP. Not sure how the https://forum.dfinity.org/t/stable-variables-persistence/34039 was produced in practice.