-
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.
[cli] Implement upgrade compatibility checks client side (#19562)
## Description Introduce client side upgrade compatibility checking, allowing users to check before TX submission if an upgrade will be successful. Improves the output of errors by relying on the move-binary-format crates checks to list the issues with the error to the user that are found. ## Test plan manually tested see comment below --- ## Release notes - [ ] Protocol: - [ ] Nodes (Validators and Full nodes): - [ ] Indexer: - [ ] JSON-RPC: - [ ] GraphQL: - [x] CLI: User will see a different error when an upgrade error is thrown which includes the details of each error. - [ ] Rust SDK: - [ ] REST API:
- Loading branch information
1 parent
2c1b6e2
commit f23da66
Showing
23 changed files
with
929 additions
and
13 deletions.
There are no files selected for viewing
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
6 changes: 6 additions & 0 deletions
6
crates/sui/src/unit_tests/fixtures/upgrade_errors/all_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" |
95 changes: 95 additions & 0 deletions
95
crates/sui/src/unit_tests/fixtures/upgrade_errors/all_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,95 @@ | ||
// Copyright (c) Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
/// Module: UpgradeErrors | ||
|
||
#[allow(unused_field)] | ||
module upgrades::upgrades { | ||
// struct missing | ||
public struct StructToBeRemoved { | ||
b: u64 | ||
} | ||
|
||
// struct ability mismatch (add) | ||
public struct StructAbilityMismatchAdd {} | ||
|
||
// struct ability mismatch (remove) | ||
public struct StructAbilityMismatchRemove has copy {} | ||
|
||
// struct ability mismatch (change) | ||
public struct StructAbilityMismatchChange has copy {} | ||
|
||
// struct type param mismatch | ||
public struct StructTypeParamMismatch<S, T> { a: S } | ||
|
||
// struct field mismatch (add) | ||
public struct StructFieldMismatchAdd { | ||
a: u64, | ||
b: u64 | ||
} | ||
|
||
// struct field mismatch (remove) | ||
public struct StructFieldMismatchRemove { | ||
a: u64, | ||
b: u64 | ||
} | ||
|
||
// struct field mismatch (change) | ||
public struct StructFieldMismatchChange { | ||
a: u64, | ||
b: u64 | ||
} | ||
|
||
// enum missing | ||
public enum EnumToBeRemoved { | ||
A, | ||
B | ||
} | ||
|
||
// enum ability mismatch (add) | ||
public enum EnumAbilityMismatchAdd { | ||
A, | ||
} | ||
|
||
// enum ability mismatch (remove) | ||
public enum EnumAbilityMismatchRemove has copy { | ||
A, | ||
} | ||
|
||
// enum ability mismatch (change) | ||
public enum EnumAbilityMismatchChange has copy { | ||
A, | ||
} | ||
|
||
// enum new variant | ||
public enum EnumNewVariant { | ||
A, | ||
B, | ||
C | ||
} | ||
|
||
// enum variant missing | ||
public enum EnumVariantMissing { | ||
A, | ||
B, | ||
} | ||
|
||
// function missing public | ||
public fun function_to_have_public_removed() {} | ||
|
||
// function missing friend | ||
public(package) fun function_to_have_friend_removed() {} | ||
|
||
// function missing entry | ||
|
||
|
||
// function signature mismatch (add) | ||
public fun function_add_arg() {} | ||
|
||
// function signature mismatch (remove) | ||
public fun function_remove_arg(a: u64) {} | ||
|
||
// function signature mismatch (change) | ||
public fun function_change_arg(a: u64) {} | ||
} | ||
|
6 changes: 6 additions & 0 deletions
6
crates/sui/src/unit_tests/fixtures/upgrade_errors/all_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" |
89 changes: 89 additions & 0 deletions
89
crates/sui/src/unit_tests/fixtures/upgrade_errors/all_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,89 @@ | ||
// Copyright (c) Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
/// Module: UpgradeErrors | ||
|
||
#[allow(unused_field)] | ||
module upgrades::upgrades { | ||
// struct missing | ||
// public struct StructToBeRemoved {} | ||
|
||
// struct ability mismatch (add) | ||
public struct StructAbilityMismatchAdd has copy {} // added the copy ability where none existed | ||
|
||
// struct field mismatch (remove) | ||
public struct StructAbilityMismatchRemove {} // removed the copy ability | ||
|
||
// struct field mismatch (change) | ||
public struct StructAbilityMismatchChange has drop {} // changed from drop to copy | ||
|
||
// struct type param mismatch | ||
public struct StructTypeParamMismatch<T> { a: T } // changed S to T | ||
|
||
// struct field mismatch (add) | ||
public struct StructFieldMismatchAdd { | ||
a: u64, | ||
b: u64, | ||
c: u64, // added | ||
} | ||
|
||
// struct field mismatch (remove) | ||
public struct StructFieldMismatchRemove { | ||
a: u64, | ||
// removed b: u64 | ||
} | ||
|
||
// struct field mismatch (change) | ||
public struct StructFieldMismatchChange { | ||
a: u64, | ||
b: u8 // changed b from u64 to u8 | ||
} | ||
|
||
// enum missing | ||
// public enum EnumToBeRemoved {} | ||
|
||
// enum ability mismatch (add) | ||
public enum EnumAbilityMismatchAdd has copy { | ||
A, | ||
} | ||
|
||
// enum ability mismatch (remove) | ||
public enum EnumAbilityMismatchRemove { | ||
A, | ||
} | ||
|
||
// enum ability mismatch (change) | ||
public enum EnumAbilityMismatchChange has drop { | ||
A, | ||
} | ||
|
||
// enum new variant | ||
public enum EnumNewVariant { | ||
A, | ||
B, | ||
C, | ||
D // new variant | ||
} | ||
|
||
// enum variant missing | ||
public enum EnumVariantMissing { | ||
A, | ||
// remove B, | ||
} | ||
|
||
// function missing public | ||
fun function_to_have_public_removed() {} | ||
|
||
// function missing friend | ||
fun function_to_have_friend_removed() {} | ||
|
||
// function missing entry | ||
|
||
// function signature mismatch (add) | ||
public fun function_add_arg(a: u64) {} | ||
|
||
// function signature mismatch (remove) | ||
public fun function_remove_arg() {} | ||
|
||
// function signature mismatch (change) | ||
public fun function_change_arg(a: u8) {} // now has u8 instead of u64 | ||
} |
6 changes: 6 additions & 0 deletions
6
crates/sui/src/unit_tests/fixtures/upgrade_errors/entry_linking_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" |
10 changes: 10 additions & 0 deletions
10
...es/sui/src/unit_tests/fixtures/upgrade_errors/entry_linking_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,10 @@ | ||
// Copyright (c) Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
/// Module: UpgradeErrors | ||
|
||
#[allow(unused_field)] | ||
module upgrades::upgrades { | ||
entry fun entry_to_be_removed() {} | ||
} | ||
|
6 changes: 6 additions & 0 deletions
6
crates/sui/src/unit_tests/fixtures/upgrade_errors/entry_linking_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" |
9 changes: 9 additions & 0 deletions
9
...es/sui/src/unit_tests/fixtures/upgrade_errors/entry_linking_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,9 @@ | ||
// Copyright (c) Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
/// Module: UpgradeErrors | ||
|
||
#[allow(unused_field)] | ||
module upgrades::upgrades { | ||
fun entry_to_be_removed() {} | ||
} |
6 changes: 6 additions & 0 deletions
6
crates/sui/src/unit_tests/fixtures/upgrade_errors/friend_linking_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" |
15 changes: 15 additions & 0 deletions
15
...s/sui/src/unit_tests/fixtures/upgrade_errors/friend_linking_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,15 @@ | ||
// Copyright (c) Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
/// Module: UpgradeErrors | ||
|
||
#[allow(unused_field)] | ||
module upgrades::upgrades { | ||
fun call_friend() { | ||
upgrades::upgrades_friend::friend_to_be_dropped(); | ||
} | ||
} | ||
|
||
module upgrades::upgrades_friend { | ||
public(package) fun friend_to_be_dropped() {} | ||
} |
6 changes: 6 additions & 0 deletions
6
crates/sui/src/unit_tests/fixtures/upgrade_errors/friend_linking_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" |
12 changes: 12 additions & 0 deletions
12
...s/sui/src/unit_tests/fixtures/upgrade_errors/friend_linking_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,12 @@ | ||
// Copyright (c) Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
/// Module: UpgradeErrors | ||
|
||
#[allow(unused_field)] | ||
module upgrades::upgrades { | ||
fun call_friend() {} | ||
} | ||
|
||
|
||
module upgrades::upgrades_friend {} |
6 changes: 6 additions & 0 deletions
6
crates/sui/src/unit_tests/fixtures/upgrade_errors/struct_missing_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" |
13 changes: 13 additions & 0 deletions
13
...s/sui/src/unit_tests/fixtures/upgrade_errors/struct_missing_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,13 @@ | ||
// Copyright (c) Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
/// Module: UpgradeErrors | ||
|
||
#[allow(unused_field)] | ||
module upgrades::upgrades { | ||
// struct missing | ||
public struct StructToBeRemoved { | ||
b: u64 | ||
} | ||
} | ||
|
Oops, something went wrong.