[#103] common: Disallow downgrading contracts
All checks were successful
DCO action / DCO (pull_request) Successful in 37s
Tests / Tests (1.21) (pull_request) Successful in 1m11s
Tests / Tests (1.22) (pull_request) Successful in 1m11s

`PrevVersion` marks suitable version that we can upgrade from.
However, we can have multiple minor versions, so, currently an upgrade
from v0.19.3 to v0.19.1 is possible. Prevent this with an additional
check.

Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
Evgenii Stratonikov 2024-08-19 11:52:01 +03:00
parent 82e04b6c32
commit ba7329c3a7

View file

@ -32,7 +32,7 @@ func CheckVersion(from int) {
if from < PrevVersion { if from < PrevVersion {
panic(ErrVersionMismatch + ": expected >=" + std.Itoa(PrevVersion, 10)) panic(ErrVersionMismatch + ": expected >=" + std.Itoa(PrevVersion, 10))
} }
if from == Version { if Version <= from {
panic(ErrAlreadyUpdated + ": " + std.Itoa(Version, 10)) panic(ErrAlreadyUpdated + ": " + std.Itoa(Version, 10))
} }
} }