forked from MystenLabs/sui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[move-2024] Add migration support for globally qualifying names (Myst…
…enLabs#16632) ## Description In legacy move, we allowed three-place names to use an address in the first position, even if there was also a module in scope with that name. Move 2024's resolution rules now require `::` proceeding that name to do this. This updates migration to support. Also, this moves writing the edition flag to the `Move.toml` file _after_ successful migration, so that we aren't updating the it in the error case. ## Test Plan New tests plus more local testing against the sui framework code. --- If your changes are not user-facing and do not break anything, you can skip the following section. Otherwise, please briefly describe what has changed under the Release Notes section. ### Type of Change (Check all that apply) - [ ] protocol change - [ ] user-visible impact - [ ] breaking change for a client SDKs - [ ] breaking change for FNs (FN binary must upgrade) - [ ] breaking change for validators or node operators (must upgrade binaries) - [ ] breaking change for on-chain data layout - [ ] necessitate either a data wipe or data migration ### Release notes
- Loading branch information
Showing
23 changed files
with
262 additions
and
29 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
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
13 changes: 13 additions & 0 deletions
13
external-crates/move/crates/move-cli/tests/build_tests/migration_paths/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,13 @@ | ||
|
||
# TOML FILE | ||
|
||
[package] | ||
name = "migration" | ||
|
||
# this is a comment | ||
[addresses] | ||
migration = "0x3" | ||
std = "0x1" | ||
|
||
[dependencies] | ||
MoveStdlib = { local = "../../../../move-stdlib" } |
14 changes: 14 additions & 0 deletions
14
external-crates/move/crates/move-cli/tests/build_tests/migration_paths/Move.toml.expected
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,14 @@ | ||
|
||
# TOML FILE | ||
|
||
[package] | ||
name = "migration" | ||
edition = "2024.beta" | ||
|
||
# this is a comment | ||
[addresses] | ||
migration = "0x3" | ||
std = "0x1" | ||
|
||
[dependencies] | ||
MoveStdlib = { local = "../../../../move-stdlib" } |
47 changes: 47 additions & 0 deletions
47
external-crates/move/crates/move-cli/tests/build_tests/migration_paths/args.exp
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,47 @@ | ||
Command `migrate`: | ||
Package toml does not specify an edition. As of 2024, Move requires all packages to define a language edition. | ||
|
||
Please select one of the following editions: | ||
|
||
1) 2024.beta | ||
2) legacy | ||
|
||
Selection (default=1): | ||
|
||
Would you like the Move compiler to migrate your code to Move 2024? (Y/n) | ||
Generated changes . . . | ||
INCLUDING DEPENDENCY MoveStdlib | ||
BUILDING migration | ||
|
||
The following changes will be made. | ||
============================================================ | ||
|
||
--- sources/other.move | ||
+++ sources/other.move | ||
@@ -4,1 +4,1 @@ | ||
- public fun t() { migration::migration::t() } | ||
+ public fun t() { ::migration::migration::t() } | ||
--- tests/test0.move | ||
+++ tests/test0.move | ||
@@ -6,1 +6,1 @@ | ||
- #[expected_failure(abort_code = migration::validate::ErrorCode)] | ||
+ #[expected_failure(abort_code = ::migration::validate::ErrorCode)] | ||
|
||
|
||
============================================================ | ||
Apply changes? (Y/n) | ||
Updating "sources/other.move" . . . | ||
Updating "tests/test0.move" . . . | ||
|
||
Changes complete | ||
Wrote patchfile out to: ./migration.patch | ||
|
||
Recorded edition in 'Move.toml' | ||
External Command `diff -r -s sources migration_sources`: | ||
Files sources/migration.move and migration_sources/migration.move are identical | ||
Files sources/other.move and migration_sources/other.move are identical | ||
Files sources/validate.move and migration_sources/validate.move are identical | ||
External Command `diff -r -s tests migration_tests`: | ||
Files tests/test0.move and migration_tests/test0.move are identical | ||
External Command `diff -s Move.toml Move.toml.expected`: | ||
Files Move.toml and Move.toml.expected are identical |
4 changes: 4 additions & 0 deletions
4
external-crates/move/crates/move-cli/tests/build_tests/migration_paths/args.txt
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,4 @@ | ||
migrate | ||
> diff -r -s sources migration_sources | ||
> diff -r -s tests migration_tests | ||
> diff -s Move.toml Move.toml.expected |
5 changes: 5 additions & 0 deletions
5
...s/move/crates/move-cli/tests/build_tests/migration_paths/migration_sources/migration.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 @@ | ||
module migration::migration { | ||
|
||
public fun t() { abort migration::validate::make_error_code() } | ||
|
||
} |
5 changes: 5 additions & 0 deletions
5
...rates/move/crates/move-cli/tests/build_tests/migration_paths/migration_sources/other.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 @@ | ||
module migration::other { | ||
use migration::migration; | ||
|
||
public fun t() { ::migration::migration::t() } | ||
} |
7 changes: 7 additions & 0 deletions
7
...es/move/crates/move-cli/tests/build_tests/migration_paths/migration_sources/validate.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,7 @@ | ||
module migration::validate { | ||
|
||
const ErrorCode: u64= 0; | ||
|
||
public fun make_error_code(): u64 { ErrorCode } | ||
|
||
} |
10 changes: 10 additions & 0 deletions
10
...-crates/move/crates/move-cli/tests/build_tests/migration_paths/migration_tests/test0.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 @@ | ||
#[test_only] | ||
module migration::migration_tests { | ||
use migration::migration; | ||
|
||
#[test] | ||
#[expected_failure(abort_code = ::migration::validate::ErrorCode)] | ||
fun test_t() { | ||
migration::t() | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
...rnal-crates/move/crates/move-cli/tests/build_tests/migration_paths/sources/migration.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 @@ | ||
module migration::migration { | ||
|
||
public fun t() { abort migration::validate::make_error_code() } | ||
|
||
} |
5 changes: 5 additions & 0 deletions
5
external-crates/move/crates/move-cli/tests/build_tests/migration_paths/sources/other.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 @@ | ||
module migration::other { | ||
use migration::migration; | ||
|
||
public fun t() { migration::migration::t() } | ||
} |
7 changes: 7 additions & 0 deletions
7
external-crates/move/crates/move-cli/tests/build_tests/migration_paths/sources/validate.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,7 @@ | ||
module migration::validate { | ||
|
||
const ErrorCode: u64= 0; | ||
|
||
public fun make_error_code(): u64 { ErrorCode } | ||
|
||
} |
10 changes: 10 additions & 0 deletions
10
external-crates/move/crates/move-cli/tests/build_tests/migration_paths/tests/test0.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 @@ | ||
#[test_only] | ||
module migration::migration_tests { | ||
use migration::migration; | ||
|
||
#[test] | ||
#[expected_failure(abort_code = migration::validate::ErrorCode)] | ||
fun test_t() { | ||
migration::t() | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
.../move/crates/move-cli/tests/build_tests/migration_with_blocking_errors/Move.toml.expected
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 @@ | ||
|
||
# TOML FILE | ||
|
||
[package] | ||
name = "A" | ||
|
||
# this is a comment | ||
[addresses] | ||
A = "0x1" | ||
std = "0x1" | ||
|
||
[dependencies] | ||
MoveStdlib = { local = "../../../../move-stdlib" } |
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
1 change: 1 addition & 0 deletions
1
...nal-crates/move/crates/move-cli/tests/build_tests/migration_with_blocking_errors/args.txt
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 |
---|---|---|
@@ -1 +1,2 @@ | ||
migrate | ||
> diff -s Move.toml Move.toml.expected |
9 changes: 9 additions & 0 deletions
9
...s/move/crates/move-cli/tests/build_tests/migration_with_blocking_errors/sources/mod1.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 @@ | ||
module A::mod1 { | ||
use A::mod0; | ||
|
||
public fun t0(x: u64): u64 { | ||
mod0::mod0::f(); | ||
x | ||
} | ||
|
||
} |
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
Oops, something went wrong.