-
Notifications
You must be signed in to change notification settings - Fork 11.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
handle additive and deponly upgrades for upgrade errors
- Loading branch information
1 parent
721c02f
commit d2a0931
Showing
21 changed files
with
1,134 additions
and
306 deletions.
There are no files selected for viewing
6 changes: 6 additions & 0 deletions
6
crates/sui/src/unit_tests/fixtures/upgrade_errors/additive_errors_v1/Move.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[package] | ||
name = "upgrades" | ||
edition = "2024.beta" # edition = "legacy" to use legacy (pre-2024) Move | ||
|
||
[addresses] | ||
upgrades = "0x0" |
30 changes: 30 additions & 0 deletions
30
.../sui/src/unit_tests/fixtures/upgrade_errors/additive_errors_v1/sources/UpgradeErrors.move
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Copyright (c) Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
module upgrades::upgrades { | ||
|
||
public struct StructToChange { | ||
new_field: u64 // change to u32 | ||
} | ||
|
||
public struct StructToRemove { | ||
new_field: u64 | ||
} | ||
|
||
public enum EnumToChange { | ||
A, // change to B | ||
} | ||
|
||
public enum EnumToRemove { | ||
A | ||
} | ||
|
||
// no public on functions | ||
fun function_to_change(): u64 { // change to u32 return | ||
0 | ||
} | ||
|
||
fun function_to_remove(): u64 { | ||
0 | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
crates/sui/src/unit_tests/fixtures/upgrade_errors/additive_errors_v2/Move.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[package] | ||
name = "upgrades" | ||
edition = "2024.beta" # edition = "legacy" to use legacy (pre-2024) Move | ||
|
||
[addresses] | ||
upgrades = "0x0" |
23 changes: 23 additions & 0 deletions
23
.../sui/src/unit_tests/fixtures/upgrade_errors/additive_errors_v2/sources/UpgradeErrors.move
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Copyright (c) Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
module upgrades::upgrades { | ||
|
||
public struct StructToChange { | ||
new_field: u32 // changed to u32 | ||
} | ||
|
||
// public struct StructToRemove {} | ||
|
||
public enum EnumToChange { | ||
B, // changed to B | ||
} | ||
|
||
// public enum EnumToRemove {} | ||
|
||
fun function_to_change(): u32 { // changed to u32 | ||
0 | ||
} | ||
|
||
// fun function_to_remove(): u64 {} | ||
} |
6 changes: 6 additions & 0 deletions
6
crates/sui/src/unit_tests/fixtures/upgrade_errors/deponly_errors_v1/Move.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[package] | ||
name = "upgrades" | ||
edition = "2024.beta" # edition = "legacy" to use legacy (pre-2024) Move | ||
|
||
[addresses] | ||
upgrades = "0x0" |
5 changes: 5 additions & 0 deletions
5
...s/sui/src/unit_tests/fixtures/upgrade_errors/deponly_errors_v1/sources/UpgradeErrors.move
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// Copyright (c) Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
module upgrades::upgrades { | ||
} |
6 changes: 6 additions & 0 deletions
6
crates/sui/src/unit_tests/fixtures/upgrade_errors/deponly_errors_v2/Move.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[package] | ||
name = "upgrades" | ||
edition = "2024.beta" # edition = "legacy" to use legacy (pre-2024) Move | ||
|
||
[addresses] | ||
upgrades = "0x0" |
21 changes: 21 additions & 0 deletions
21
...s/sui/src/unit_tests/fixtures/upgrade_errors/deponly_errors_v2/sources/UpgradeErrors.move
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Copyright (c) Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
module upgrades::upgrades { | ||
|
||
// created new struct | ||
public struct NewStruct { | ||
new_field: u64 | ||
} | ||
|
||
// created new enum | ||
public enum NewEnum { | ||
A, | ||
} | ||
|
||
// created new function | ||
fun new_function(): u64 { | ||
0 | ||
} | ||
|
||
} |
53 changes: 53 additions & 0 deletions
53
...it_tests/snapshots/sui__upgrade_compatibility__upgrade_compatibility_tests__additive.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
--- | ||
source: crates/sui/src/unit_tests/upgrade_compatibility_tests.rs | ||
expression: normalize_path(err.to_string()) | ||
--- | ||
error[Compatibility E01008]: missing declaration | ||
┌─ /fixtures/upgrade_errors/additive_errors_v2/sources/UpgradeErrors.move:4:18 | ||
│ | ||
4 │ module upgrades::upgrades { | ||
│ ^^^^^^^^ enum 'EnumToRemove' is missing | ||
│ | ||
= enums cannot be removed or changed during an 'additive' or 'dependency only' upgrade. | ||
= add missing enum 'EnumToRemove' back to the module 'upgrades'. | ||
|
||
error[Compatibility E01008]: missing declaration | ||
┌─ /fixtures/upgrade_errors/additive_errors_v2/sources/UpgradeErrors.move:4:18 | ||
│ | ||
4 │ module upgrades::upgrades { | ||
│ ^^^^^^^^ function 'function_to_remove' is missing | ||
│ | ||
= functions cannot be removed or changed during an 'additive' or 'dependency only' upgrade. | ||
= add missing function 'function_to_remove' back to the module 'upgrades'. | ||
|
||
error[Compatibility E01008]: missing declaration | ||
┌─ /fixtures/upgrade_errors/additive_errors_v2/sources/UpgradeErrors.move:4:18 | ||
│ | ||
4 │ module upgrades::upgrades { | ||
│ ^^^^^^^^ struct 'StructToRemove' is missing | ||
│ | ||
= structs cannot be removed or changed during an 'additive' or 'dependency only' upgrade. | ||
= add missing struct 'StructToRemove' back to the module 'upgrades'. | ||
|
||
error[Compatibility E01002]: type mismatch | ||
┌─ /fixtures/upgrade_errors/additive_errors_v2/sources/UpgradeErrors.move:7:9 | ||
│ | ||
6 │ public struct StructToChange { | ||
│ -------------- Struct definition | ||
7 │ new_field: u32 // changed to u32 | ||
│ ^^^^^^^^^ Mismatched field type 'u32', expected 'u64'. | ||
│ | ||
= Structs cannot be removed or changed during an 'additive' or 'dependency only' upgrade. | ||
= Restore the original struct's field for struct 'StructToChange' including the ordering. | ||
|
||
error[Compatibility E03001]: function signature mismatch | ||
┌─ /fixtures/upgrade_errors/additive_errors_v2/sources/UpgradeErrors.move:18:31 | ||
│ | ||
18 │ fun function_to_change(): u32 { // changed to u32 | ||
│ ^^^ Unexpected return type 'u32', expected 'u64' | ||
│ | ||
= Functions cannot be removed or changed during an 'additive' or 'dependency only' upgrade. | ||
= Restore the original function's return type for function 'function_to_change'. | ||
|
||
|
||
Upgrade failed, this package requires changes to be compatible with the existing package. Its upgrade policy is set to 'additive'. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
...nit_tests/snapshots/sui__upgrade_compatibility__upgrade_compatibility_tests__deponly.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
--- | ||
source: crates/sui/src/unit_tests/upgrade_compatibility_tests.rs | ||
expression: normalize_path(err.to_string()) | ||
--- | ||
error[Compatibility E01002]: type mismatch | ||
┌─ /fixtures/upgrade_errors/deponly_errors_v2/sources/UpgradeErrors.move:4:18 | ||
│ | ||
4 │ module upgrades::upgrades { | ||
│ ^^^^^^^^ New unexpected struct 'NewStruct'. | ||
│ | ||
= Structs are part of a module's public interface and cannot be removed or changed during an upgrade. | ||
= Restore the original struct 'NewStruct' including the ordering. | ||
|
||
error[Compatibility E02001]: variant mismatch | ||
┌─ /fixtures/upgrade_errors/deponly_errors_v2/sources/UpgradeErrors.move:4:18 | ||
│ | ||
4 │ module upgrades::upgrades { | ||
│ ^^^^^^^^ New unexpected enum 'NewEnum'. | ||
│ | ||
= Enums are part of a module's public interface and cannot be changed during an upgrade. | ||
= Restore the original enum 'NewEnum' including the ordering. | ||
|
||
error[Compatibility E03001]: function signature mismatch | ||
┌─ /fixtures/upgrade_errors/deponly_errors_v2/sources/UpgradeErrors.move:4:18 | ||
│ | ||
4 │ module upgrades::upgrades { | ||
│ ^^^^^^^^ New unexpected function 'new_function'. | ||
│ | ||
= Functions are part of a module's public interface and cannot be changed during an upgrade. | ||
= Restore the original function 'new_function' including the ordering. | ||
|
||
|
||
Upgrade failed, this package requires changes to be compatible with the existing package. Its upgrade policy is set to 'dependency only'. |
Oops, something went wrong.