-
Notifications
You must be signed in to change notification settings - Fork 11.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[sui-adapter] Resolve Move abort locations to package ID instead of r…
…untime ID (#17884) ## Description Updates Move aborts so that the address in the abort location uses the package ID as opposed to the runtime module ID. Basically, before if you had a package `P` with a module `M` ```move module P::M { public fun aborter() { abort 0 } } ``` published at `0xA` for version 1, `0xB` for version 2, and `0xC` for version 3, then before this change ``` 0xA::aborter().location.address == 0xA 0xB::aborter().location.address == 0xA 0xC::aborter().location.address = 0xA ``` After this change ``` 0xA::aborter().location.address == 0xA 0xB::aborter().location.address == 0xB 0xC::aborter().location.address == 0xC ``` The only meaningful changes are in `sui-execution/latest/sui-adapter/src/error.rs` the other changes are just plumbing/protocol config updates and tests. ## Test plan Added tests to make sure existing behavior is preserved, and that new behavior works as expected. --- ## Release notes Check each box that your changes affect. If none of the boxes relate to your changes, release notes aren't required. For each box you select, include information after the relevant heading that describes the impact of your changes that a user might notice and any actions they must take to implement updates. - [X] Protocol: Added new protocol version (47) and enabled resolving Move abort locations to their package ID instead of runtime ID. - [ ] Nodes (Validators and Full nodes): - [ ] Indexer: - [ ] JSON-RPC: - [ ] GraphQL: - [ ] CLI: - [ ] Rust SDK:
- Loading branch information
Showing
11 changed files
with
207 additions
and
21 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
crates/sui-adapter-transactional-tests/tests/upgrade/abort_code_resolution.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,31 @@ | ||
processed 7 tasks | ||
|
||
init: | ||
A: object(0,0) | ||
|
||
task 1 'publish'. lines 6-11: | ||
created: object(1,0), object(1,1) | ||
mutated: object(0,0) | ||
gas summary: computation_cost: 1000000, storage_cost: 5084400, storage_rebate: 0, non_refundable_storage_fee: 0 | ||
|
||
task 2 'upgrade'. lines 14-19: | ||
created: object(2,0) | ||
mutated: object(0,0), object(1,1) | ||
gas summary: computation_cost: 1000000, storage_cost: 5084400, storage_rebate: 2595780, non_refundable_storage_fee: 26220 | ||
|
||
task 3 'upgrade'. lines 21-26: | ||
created: object(3,0) | ||
mutated: object(0,0), object(1,1) | ||
gas summary: computation_cost: 1000000, storage_cost: 5084400, storage_rebate: 2595780, non_refundable_storage_fee: 26220 | ||
|
||
task 4 'run'. lines 28-30: | ||
Error: Transaction Effects Status: Move Runtime Abort. Location: Test1::M1::f1 (function index 0) at offset 1, Abort Code: 0 | ||
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: MoveAbort(MoveLocation { module: ModuleId { address: Test1, name: Identifier("M1") }, function: 0, instruction: 1, function_name: Some("f1") }, 0), source: Some(VMError { major_status: ABORTED, sub_status: Some(0), message: Some("Test1::M1::f1 at offset 1"), exec_state: None, location: Module(ModuleId { address: Test1, name: Identifier("M1") }), indices: [], offsets: [(FunctionDefinitionIndex(0), 1)] }), command: Some(0) } } | ||
|
||
task 5 'run'. lines 31-33: | ||
Error: Transaction Effects Status: Move Runtime Abort. Location: Test2::M1::f1 (function index 0) at offset 1, Abort Code: 0 | ||
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: MoveAbort(MoveLocation { module: ModuleId { address: Test2, name: Identifier("M1") }, function: 0, instruction: 1, function_name: Some("f1") }, 0), source: Some(VMError { major_status: ABORTED, sub_status: Some(0), message: Some("Test1::M1::f1 at offset 1"), exec_state: None, location: Module(ModuleId { address: Test1, name: Identifier("M1") }), indices: [], offsets: [(FunctionDefinitionIndex(0), 1)] }), command: Some(0) } } | ||
|
||
task 6 'run'. lines 34-34: | ||
Error: Transaction Effects Status: Move Runtime Abort. Location: Test3::M1::f1 (function index 0) at offset 1, Abort Code: 0 | ||
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: MoveAbort(MoveLocation { module: ModuleId { address: Test3, name: Identifier("M1") }, function: 0, instruction: 1, function_name: Some("f1") }, 0), source: Some(VMError { major_status: ABORTED, sub_status: Some(0), message: Some("Test1::M1::f1 at offset 1"), exec_state: None, location: Module(ModuleId { address: Test1, name: Identifier("M1") }), indices: [], offsets: [(FunctionDefinitionIndex(0), 1)] }), command: Some(0) } } |
34 changes: 34 additions & 0 deletions
34
crates/sui-adapter-transactional-tests/tests/upgrade/abort_code_resolution.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,34 @@ | ||
// Copyright (c) Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
//# init --addresses Test1=0x0 Test2=0x0 Test3=0x0 --accounts A | ||
|
||
//# publish --upgradeable --sender A | ||
module Test1::M1 { | ||
public fun f1() { | ||
abort 0 | ||
} | ||
} | ||
|
||
|
||
//# upgrade --package Test1 --upgrade-capability 1,1 --sender A | ||
module Test2::M1 { | ||
public fun f1() { | ||
abort 0 | ||
} | ||
} | ||
|
||
//# upgrade --package Test2 --upgrade-capability 1,1 --sender A | ||
module Test3::M1 { | ||
public fun f1() { | ||
abort 0 | ||
} | ||
} | ||
|
||
//# run Test1::M1::f1 | ||
|
||
// Location will show up as Test2::M1::f1 since the runtime module ID is resolved to the upgraded version | ||
//# run Test2::M1::f1 | ||
|
||
// Location will show up as Test3::M1::f1 as the runtime module ID is resolved to the upgraded version | ||
//# run Test3::M1::f1 |
31 changes: 31 additions & 0 deletions
31
crates/sui-adapter-transactional-tests/tests/upgrade/abort_code_resolution_v46.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,31 @@ | ||
processed 7 tasks | ||
|
||
init: | ||
A: object(0,0) | ||
|
||
task 1 'publish'. lines 6-11: | ||
created: object(1,0), object(1,1) | ||
mutated: object(0,0) | ||
gas summary: computation_cost: 1000000, storage_cost: 5084400, storage_rebate: 0, non_refundable_storage_fee: 0 | ||
|
||
task 2 'upgrade'. lines 14-19: | ||
created: object(2,0) | ||
mutated: object(0,0), object(1,1) | ||
gas summary: computation_cost: 1000000, storage_cost: 5084400, storage_rebate: 2595780, non_refundable_storage_fee: 26220 | ||
|
||
task 3 'upgrade'. lines 21-26: | ||
created: object(3,0) | ||
mutated: object(0,0), object(1,1) | ||
gas summary: computation_cost: 1000000, storage_cost: 5084400, storage_rebate: 2595780, non_refundable_storage_fee: 26220 | ||
|
||
task 4 'run'. lines 28-30: | ||
Error: Transaction Effects Status: Move Runtime Abort. Location: Test1::M1::f1 (function index 0) at offset 1, Abort Code: 0 | ||
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: MoveAbort(MoveLocation { module: ModuleId { address: Test1, name: Identifier("M1") }, function: 0, instruction: 1, function_name: Some("f1") }, 0), source: Some(VMError { major_status: ABORTED, sub_status: Some(0), message: Some("Test1::M1::f1 at offset 1"), exec_state: None, location: Module(ModuleId { address: Test1, name: Identifier("M1") }), indices: [], offsets: [(FunctionDefinitionIndex(0), 1)] }), command: Some(0) } } | ||
|
||
task 5 'run'. lines 31-33: | ||
Error: Transaction Effects Status: Move Runtime Abort. Location: Test1::M1::f1 (function index 0) at offset 1, Abort Code: 0 | ||
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: MoveAbort(MoveLocation { module: ModuleId { address: Test1, name: Identifier("M1") }, function: 0, instruction: 1, function_name: Some("f1") }, 0), source: Some(VMError { major_status: ABORTED, sub_status: Some(0), message: Some("Test1::M1::f1 at offset 1"), exec_state: None, location: Module(ModuleId { address: Test1, name: Identifier("M1") }), indices: [], offsets: [(FunctionDefinitionIndex(0), 1)] }), command: Some(0) } } | ||
|
||
task 6 'run'. lines 34-34: | ||
Error: Transaction Effects Status: Move Runtime Abort. Location: Test1::M1::f1 (function index 0) at offset 1, Abort Code: 0 | ||
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: MoveAbort(MoveLocation { module: ModuleId { address: Test1, name: Identifier("M1") }, function: 0, instruction: 1, function_name: Some("f1") }, 0), source: Some(VMError { major_status: ABORTED, sub_status: Some(0), message: Some("Test1::M1::f1 at offset 1"), exec_state: None, location: Module(ModuleId { address: Test1, name: Identifier("M1") }), indices: [], offsets: [(FunctionDefinitionIndex(0), 1)] }), command: Some(0) } } |
34 changes: 34 additions & 0 deletions
34
crates/sui-adapter-transactional-tests/tests/upgrade/abort_code_resolution_v46.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,34 @@ | ||
// Copyright (c) Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
//# init --addresses Test1=0x0 Test2=0x0 Test3=0x0 --accounts A --protocol-version 46 | ||
|
||
//# publish --upgradeable --sender A | ||
module Test1::M1 { | ||
public fun f1() { | ||
abort 0 | ||
} | ||
} | ||
|
||
|
||
//# upgrade --package Test1 --upgrade-capability 1,1 --sender A | ||
module Test2::M1 { | ||
public fun f1() { | ||
abort 0 | ||
} | ||
} | ||
|
||
//# upgrade --package Test2 --upgrade-capability 1,1 --sender A | ||
module Test3::M1 { | ||
public fun f1() { | ||
abort 0 | ||
} | ||
} | ||
|
||
//# run Test1::M1::f1 | ||
|
||
// Location will show up as Test1::M1::f1 since the module ID is not resolved to the upgraded version | ||
//# run Test2::M1::f1 | ||
|
||
// Location will show up as Test1::M1::f1 since the module ID is not resolved to the upgraded version | ||
//# run Test3::M1::f1 |
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
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
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