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] Remove unnecessary code (MystenLabs#11087)
## Description - Remove unnecessary checks in interpreter ## Test Plan - Added tests --- If your changes are not user-facing and not a breaking change, you can skip the following section. Otherwise, please indicate what changed, and then add to the Release Notes section as highlighted during the release process. ### Type of Change (Check all that apply) - [ ] 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
15 changed files
with
227 additions
and
18 deletions.
There are no files selected for viewing
14 changes: 14 additions & 0 deletions
14
...s/sui-adapter-transactional-tests/tests/runtime_behavior/versioned_check_swap_loc_new.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,14 @@ | ||
processed 4 tasks | ||
|
||
task 1 'publish'. lines 8-42: | ||
created: object(1,0) | ||
mutated: object(0,0) | ||
gas summary: computation_cost: 1000000, storage_cost: 4491600, storage_rebate: 0, non_refundable_storage_fee: 0 | ||
|
||
task 2 'run'. lines 44-44: | ||
mutated: object(0,0) | ||
gas summary: computation_cost: 1000000, storage_cost: 988000, storage_rebate: 978120, non_refundable_storage_fee: 9880 | ||
|
||
task 3 'run'. lines 46-46: | ||
mutated: object(0,0) | ||
gas summary: computation_cost: 1000000, storage_cost: 988000, storage_rebate: 978120, non_refundable_storage_fee: 9880 |
46 changes: 46 additions & 0 deletions
46
.../sui-adapter-transactional-tests/tests/runtime_behavior/versioned_check_swap_loc_new.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,46 @@ | ||
// Copyright (c) Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
// test old behavior of invariant violation | ||
|
||
//# init --addresses test=0x0 | ||
|
||
//# publish | ||
module test::m { | ||
public fun t1(cond: bool) { | ||
let x: vector<u64>; | ||
let r: &vector<u64>; | ||
if (cond) { | ||
x = vector[]; | ||
r = &x; | ||
// use r in ways to disable optimizations or moving | ||
id_ref(r); | ||
id_ref(copy r); | ||
}; | ||
x = vector[]; | ||
// use x in ways to disable optimizations or moving | ||
id(x); | ||
id(x); | ||
return | ||
} | ||
|
||
public fun t2(cond: bool) { | ||
let x: vector<u64> = vector[]; | ||
let r: &vector<u64>; | ||
if (cond) { | ||
r = &x; | ||
// use r in ways to disable optimizations or moving | ||
id_ref(r); | ||
id_ref(copy r); | ||
}; | ||
_ = move x; | ||
return | ||
} | ||
|
||
fun id<T>(x: T): T { x } | ||
fun id_ref<T>(x: &T): &T { x } | ||
} | ||
|
||
//# run test::m::t1 --args true | ||
|
||
//# run test::m::t2 --args true |
14 changes: 14 additions & 0 deletions
14
...s/sui-adapter-transactional-tests/tests/runtime_behavior/versioned_check_swap_loc_old.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,14 @@ | ||
processed 4 tasks | ||
|
||
task 1 'publish'. lines 8-42: | ||
created: object(1,0) | ||
mutated: object(0,0) | ||
gas summary: computation_cost: 1000000, storage_cost: 4491600, storage_rebate: 0, non_refundable_storage_fee: 0 | ||
|
||
task 2 'run'. lines 44-44: | ||
Error: Transaction Effects Status: MOVE VM INVARIANT VIOLATION. | ||
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: VMInvariantViolation, source: Some(VMError { major_status: UNKNOWN_INVARIANT_VIOLATION_ERROR, sub_status: None, message: Some("moving container with dangling references"), exec_state: Some(ExecutionState { stack_trace: [] }), location: Module(ModuleId { address: test, name: Identifier("m") }), indices: [], offsets: [(FunctionDefinitionIndex(0), 13)] }), command: Some(0) } } | ||
|
||
task 3 'run'. lines 46-46: | ||
Error: Transaction Effects Status: MOVE VM INVARIANT VIOLATION. | ||
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: VMInvariantViolation, source: Some(VMError { major_status: UNKNOWN_INVARIANT_VIOLATION_ERROR, sub_status: None, message: Some("moving container with dangling references"), exec_state: Some(ExecutionState { stack_trace: [] }), location: Module(ModuleId { address: test, name: Identifier("m") }), indices: [], offsets: [(FunctionDefinitionIndex(1), 12)] }), command: Some(0) } } |
46 changes: 46 additions & 0 deletions
46
.../sui-adapter-transactional-tests/tests/runtime_behavior/versioned_check_swap_loc_old.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,46 @@ | ||
// Copyright (c) Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
// test old behavior of invariant violation | ||
|
||
//# init --protocol_version 6 --addresses test=0x0 | ||
|
||
//# publish | ||
module test::m { | ||
public fun t1(cond: bool) { | ||
let x: vector<u64>; | ||
let r: &vector<u64>; | ||
if (cond) { | ||
x = vector[]; | ||
r = &x; | ||
// use r in ways to disable optimizations or moving | ||
id_ref(r); | ||
id_ref(copy r); | ||
}; | ||
x = vector[]; | ||
// use x in ways to disable optimizations or moving | ||
id(x); | ||
id(x); | ||
return | ||
} | ||
|
||
public fun t2(cond: bool) { | ||
let x: vector<u64> = vector[]; | ||
let r: &vector<u64>; | ||
if (cond) { | ||
r = &x; | ||
// use r in ways to disable optimizations or moving | ||
id_ref(r); | ||
id_ref(copy r); | ||
}; | ||
_ = move x; | ||
return | ||
} | ||
|
||
fun id<T>(x: T): T { x } | ||
fun id_ref<T>(x: &T): &T { x } | ||
} | ||
|
||
//# run test::m::t1 --args true | ||
|
||
//# run test::m::t2 --args true |
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
1 change: 1 addition & 0 deletions
1
...rates/move/move-vm/transactional-tests/tests/instructions/inaccessible_borrowed_local.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 @@ | ||
processed 2 tasks |
27 changes: 27 additions & 0 deletions
27
...ates/move/move-vm/transactional-tests/tests/instructions/inaccessible_borrowed_local.mvir
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,27 @@ | ||
//# run | ||
main() { | ||
let x: vector<u64>; | ||
let r: &vector<u64>; | ||
label start: | ||
jump_if_false (true) end; | ||
label if_true: | ||
x = vec_pack_0<u64>(); | ||
r = &x; | ||
label end: | ||
x = vec_pack_0<u64>(); | ||
return; | ||
} | ||
|
||
//# run | ||
main() { | ||
let x: vector<u64>; | ||
let r: &vector<u64>; | ||
label start: | ||
x = vec_pack_0<u64>(); | ||
jump_if_false (true) end; | ||
label if_true: | ||
r = &x; | ||
label end: | ||
_ = move(x); | ||
return; | ||
} |
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