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.
Bound Move vector length & update move ptr (MystenLabs#8897)
## Description Updates move ptr and bounds the length of a vector in Move ## Test Plan Adapter transactional 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) - [x] 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 - [x] necessitate either a data wipe or data migration ### Release notes Move vectors are now limited to `262144` length
- Loading branch information
Showing
12 changed files
with
191 additions
and
121 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
Large diffs are not rendered by default.
Oops, something went wrong.
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
18 changes: 18 additions & 0 deletions
18
crates/sui-adapter-transactional-tests/tests/size_limits/vector_len_limits.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,18 @@ | ||
processed 6 tasks | ||
|
||
task 1 'publish'. lines 8-30: | ||
created: object(104) | ||
written: object(103) | ||
|
||
task 2 'run'. lines 31-33: | ||
written: object(105) | ||
|
||
task 3 'run'. lines 34-36: | ||
written: object(106) | ||
|
||
task 4 'run'. lines 37-39: | ||
written: object(107) | ||
|
||
task 5 'run'. lines 40-40: | ||
Error: Transaction Effects Status: Move Primitive Runtime Error. Location: Test::M1::push_n_items (function index 0) at offset 11. Arithmetic error, stack overflow, max value depth, etc. | ||
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: MovePrimitiveRuntimeError(Some(MoveLocation { module: ModuleId { address: Test, name: Identifier("M1") }, function: 0, instruction: 11, function_name: Some("push_n_items") })), source: Some(VMError { major_status: VECTOR_OPERATION_ERROR, sub_status: Some(4), message: Some("vector size limit is 262144"), exec_state: Some(ExecutionState { stack_trace: [] }), location: Module(ModuleId { address: Test, name: Identifier("M1") }), indices: [], offsets: [(FunctionDefinitionIndex(0), 11)] }), command: Some(0) } } |
40 changes: 40 additions & 0 deletions
40
crates/sui-adapter-transactional-tests/tests/size_limits/vector_len_limits.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,40 @@ | ||
// Copyright (c) Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
// Test limts on length of vectors | ||
|
||
//# init --addresses Test=0x0 | ||
|
||
//# publish | ||
|
||
/// Test vector length limits enforced | ||
module Test::M1 { | ||
use std::vector; | ||
|
||
public entry fun push_n_items(n: u64) { | ||
let v: vector<u64> = vector::empty(); | ||
let i = 0; | ||
while (i < n) { | ||
vector::push_back(&mut v, i); | ||
i = i + 1; | ||
}; | ||
i = 0; | ||
while (i < n) { | ||
let _ = vector::pop_back(&mut v); | ||
i = i + 1; | ||
}; | ||
vector::destroy_empty(v); | ||
} | ||
} | ||
|
||
// push below ven len limit should succeed | ||
//# run Test::M1::push_n_items --args 1 | ||
|
||
// push below vec len limit should succeed | ||
//# run Test::M1::push_n_items --args 256 | ||
|
||
// run at vec len limit should succeed | ||
//# run Test::M1::push_n_items --args 262144 | ||
|
||
// run above vec len limit should fail | ||
//# run Test::M1::push_n_items --args 262145 |
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
Oops, something went wrong.