Skip to content

Commit

Permalink
[move] bump Move version
Browse files Browse the repository at this point in the history
- Add new limits
- Bring in bug fix in verifier
- Bring in improved disassembler
  • Loading branch information
sblackshear committed Jan 4, 2023
1 parent 73a6f1f commit 2d3f2d4
Show file tree
Hide file tree
Showing 10 changed files with 206 additions and 164 deletions.
76 changes: 38 additions & 38 deletions Cargo.lock

Large diffs are not rendered by default.

40 changes: 20 additions & 20 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -104,26 +104,26 @@ opt-level = 1
tokio = "1.22.0"

# Move dependencies
move-binary-format = { git = "https://github.com/move-language/move", rev = "265e8792ff2935db8246ddb308b36b893d507851" }
move-bytecode-utils = { git = "https://github.com/move-language/move", rev = "265e8792ff2935db8246ddb308b36b893d507851" }
move-bytecode-verifier = { git = "https://github.com/move-language/move", rev = "265e8792ff2935db8246ddb308b36b893d507851" }
move-cli = { git = "https://github.com/move-language/move", rev = "265e8792ff2935db8246ddb308b36b893d507851" }
move-compiler = { git = "https://github.com/move-language/move", rev = "265e8792ff2935db8246ddb308b36b893d507851" }
move-core-types = { git = "https://github.com/move-language/move", rev = "265e8792ff2935db8246ddb308b36b893d507851", features = ["address20"] }
move-disassembler = { git = "https://github.com/move-language/move", rev = "265e8792ff2935db8246ddb308b36b893d507851" }
move-package = { git = "https://github.com/move-language/move", rev = "265e8792ff2935db8246ddb308b36b893d507851" }
move-stdlib = { git = "https://github.com/move-language/move", rev = "265e8792ff2935db8246ddb308b36b893d507851" }
move-vm-runtime = { git = "https://github.com/move-language/move", rev = "265e8792ff2935db8246ddb308b36b893d507851" }
move-unit-test = { git = "https://github.com/move-language/move", rev = "265e8792ff2935db8246ddb308b36b893d507851" }
move-vm-test-utils = { git = "https://github.com/move-language/move", rev = "265e8792ff2935db8246ddb308b36b893d507851" }
move-vm-types = { git = "https://github.com/move-language/move", rev = "265e8792ff2935db8246ddb308b36b893d507851" }
move-command-line-common = { git = "https://github.com/move-language/move", rev = "265e8792ff2935db8246ddb308b36b893d507851" }
move-transactional-test-runner = { git = "https://github.com/move-language/move", rev = "265e8792ff2935db8246ddb308b36b893d507851" }
move-ir-types = { git = "https://github.com/move-language/move", rev = "265e8792ff2935db8246ddb308b36b893d507851" }
move-prover = { git = "https://github.com/move-language/move", rev = "265e8792ff2935db8246ddb308b36b893d507851" }
move-prover-boogie-backend = { git = "https://github.com/move-language/move", rev = "265e8792ff2935db8246ddb308b36b893d507851" }
move-stackless-bytecode = { git = "https://github.com/move-language/move", rev = "265e8792ff2935db8246ddb308b36b893d507851" }
move-symbol-pool = { git = "https://github.com/move-language/move", rev = "265e8792ff2935db8246ddb308b36b893d507851" }
move-binary-format = { git = "https://github.com/move-language/move", rev = "a8e95cbae69564d8928c9873b8acfabc50e642cf" }
move-bytecode-utils = { git = "https://github.com/move-language/move", rev = "a8e95cbae69564d8928c9873b8acfabc50e642cf" }
move-bytecode-verifier = { git = "https://github.com/move-language/move", rev = "a8e95cbae69564d8928c9873b8acfabc50e642cf" }
move-cli = { git = "https://github.com/move-language/move", rev = "a8e95cbae69564d8928c9873b8acfabc50e642cf" }
move-compiler = { git = "https://github.com/move-language/move", rev = "a8e95cbae69564d8928c9873b8acfabc50e642cf" }
move-core-types = { git = "https://github.com/move-language/move", rev = "a8e95cbae69564d8928c9873b8acfabc50e642cf", features = ["address20"] }
move-disassembler = { git = "https://github.com/move-language/move", rev = "a8e95cbae69564d8928c9873b8acfabc50e642cf" }
move-package = { git = "https://github.com/move-language/move", rev = "a8e95cbae69564d8928c9873b8acfabc50e642cf" }
move-stdlib = { git = "https://github.com/move-language/move", rev = "a8e95cbae69564d8928c9873b8acfabc50e642cf" }
move-vm-runtime = { git = "https://github.com/move-language/move", rev = "a8e95cbae69564d8928c9873b8acfabc50e642cf" }
move-unit-test = { git = "https://github.com/move-language/move", rev = "a8e95cbae69564d8928c9873b8acfabc50e642cf" }
move-vm-test-utils = { git = "https://github.com/move-language/move", rev = "a8e95cbae69564d8928c9873b8acfabc50e642cf" }
move-vm-types = { git = "https://github.com/move-language/move", rev = "a8e95cbae69564d8928c9873b8acfabc50e642cf" }
move-command-line-common = { git = "https://github.com/move-language/move", rev = "a8e95cbae69564d8928c9873b8acfabc50e642cf" }
move-transactional-test-runner = { git = "https://github.com/move-language/move", rev = "a8e95cbae69564d8928c9873b8acfabc50e642cf" }
move-ir-types = { git = "https://github.com/move-language/move", rev = "a8e95cbae69564d8928c9873b8acfabc50e642cf" }
move-prover = { git = "https://github.com/move-language/move", rev = "a8e95cbae69564d8928c9873b8acfabc50e642cf" }
move-prover-boogie-backend = { git = "https://github.com/move-language/move", rev = "a8e95cbae69564d8928c9873b8acfabc50e642cf" }
move-stackless-bytecode = { git = "https://github.com/move-language/move", rev = "a8e95cbae69564d8928c9873b8acfabc50e642cf" }
move-symbol-pool = { git = "https://github.com/move-language/move", rev = "a8e95cbae69564d8928c9873b8acfabc50e642cf" }

fastcrypto = { git = "https://github.com/MystenLabs/fastcrypto", rev = "f64e36ceed674ccd46938cfd9645a2d32a923656" }
fastcrypto-zkp = { git = "https://github.com/MystenLabs/fastcrypto", rev = "f64e36ceed674ccd46938cfd9645a2d32a923656", package = "fastcrypto-zkp" }
Expand Down
5 changes: 4 additions & 1 deletion crates/sui-adapter/src/adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,10 @@ pub fn new_move_vm(natives: NativeFunctionTable) -> Result<MoveVM, SuiError> {
max_value_stack_size: MAX_VALUE_STACK_SIZE,
max_type_nodes: Some(MAX_TYPE_NODES),
max_push_size: Some(MAX_PUSH_SIZE),
max_dependency_depth: MAX_DEPENDENCY_DEPTH,
max_dependency_depth: Some(MAX_DEPENDENCY_DEPTH),
max_fields_in_struct: Some(MAX_FIELDS_IN_STRUCT),
max_function_definitions: Some(MAX_FUNCTION_DEFINITIONS),
max_struct_definitions: Some(MAX_STRUCT_DEFINITIONS),
},
max_binary_format_version: MOVE_BINARY_FORMAT_VERSION,
paranoid_type_checks: false,
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ expression: bytecode_calib
---
// Move bytecode v6
module 2.bytecode_calibration_tests {
use 0000000000000000000000000000000000000001::unit_test;


struct ObjectWithU64Field has drop, store {
f0: u64
}
Expand Down Expand Up @@ -2362,7 +2365,7 @@ B4:
unit_test_poison() {
B0:
0: LdU64(0)
1: Call[87](create_signers_for_testing(u64): vector<signer>)
1: Call unit_test::create_signers_for_testing(u64): vector<signer>
2: Pop
3: Ret
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ expression: natives_calib
---
// Move bytecode v6
module 2.natives_calibration_tests {
use 0000000000000000000000000000000000000001::unit_test;
use 0000000000000000000000000000000000000002::event;
use 0000000000000000000000000000000000000002::object;
use 0000000000000000000000000000000000000002::test_scenario;
use 0000000000000000000000000000000000000002::tx_context;


struct ObjectWithID has store, key {
id: UID
}
Expand All @@ -14,7 +21,7 @@ struct StructSimple has copy, drop, store {
public calibrate_emit(obj: StructSimple) {
B0:
0: MoveLoc[0](obj: StructSimple)
1: Call[0](emit<StructSimple>(StructSimple))
1: Call event::emit<StructSimple>(StructSimple)
2: Ret
}
public calibrate_emit_nop(obj: StructSimple) {
Expand All @@ -38,7 +45,7 @@ B2:
B3:
7: LdFalse
8: Pack[1](StructSimple)
9: Call[0](calibrate_emit(StructSimple))
9: Call calibrate_emit(StructSimple)
10: MoveLoc[0](trials: u64)
11: LdU64(1)
12: Sub
Expand All @@ -62,7 +69,7 @@ B2:
B3:
7: LdFalse
8: Pack[1](StructSimple)
9: Call[1](calibrate_emit_nop(StructSimple))
9: Call calibrate_emit_nop(StructSimple)
10: MoveLoc[0](trials: u64)
11: LdU64(1)
12: Sub
Expand All @@ -85,7 +92,7 @@ B2:
6: Branch(7)
B3:
7: LdConst[1](Vector(U8): [20, 58, 152, 93, 167, 79, 226, 37, 178, 4, 92, 23, 45, 107, 211, 144, 189, 133, 95, 8, 110])
8: Call[14](calibrate_address_from_bytes(vector<u8>))
8: Call object::calibrate_address_from_bytes(vector<u8>)
9: MoveLoc[0](trials: u64)
10: LdU64(1)
11: Sub
Expand All @@ -108,7 +115,7 @@ B2:
6: Branch(7)
B3:
7: LdConst[1](Vector(U8): [20, 58, 152, 93, 167, 79, 226, 37, 178, 4, 92, 23, 45, 107, 211, 144, 189, 133, 95, 8, 110])
8: Call[15](calibrate_address_from_bytes_nop(vector<u8>))
8: Call object::calibrate_address_from_bytes_nop(vector<u8>)
9: MoveLoc[0](trials: u64)
10: LdU64(1)
11: Sub
Expand All @@ -126,7 +133,7 @@ B0:
0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0])
1: StLoc[3](trials: u64)
2: LdConst[2](Address: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
3: Call[16](begin(address): Scenario)
3: Call test_scenario::begin(address): Scenario
4: StLoc[2](scenario_val: Scenario)
5: MutBorrowLoc[2](scenario_val: Scenario)
6: StLoc[1](scenario: &mut Scenario)
Expand All @@ -139,15 +146,15 @@ B2:
11: Branch(12)
B3:
12: CopyLoc[1](scenario: &mut Scenario)
13: Call[17](ctx(&mut Scenario): &mut TxContext)
14: Call[18](new(&mut TxContext): UID)
13: Call test_scenario::ctx(&mut Scenario): &mut TxContext
14: Call object::new(&mut TxContext): UID
15: Pack[0](ObjectWithID)
16: StLoc[0](obj: ObjectWithID)
17: ImmBorrowLoc[0](obj: ObjectWithID)
18: Call[1](calibrate_borrow_uid<ObjectWithID>(&ObjectWithID))
18: Call object::calibrate_borrow_uid<ObjectWithID>(&ObjectWithID)
19: MoveLoc[0](obj: ObjectWithID)
20: Unpack[0](ObjectWithID)
21: Call[20](delete(UID))
21: Call object::delete(UID)
22: MoveLoc[3](trials: u64)
23: LdU64(1)
24: Sub
Expand All @@ -157,7 +164,7 @@ B4:
27: MoveLoc[1](scenario: &mut Scenario)
28: Pop
29: MoveLoc[2](scenario_val: Scenario)
30: Call[21](end(Scenario): TransactionEffects)
30: Call test_scenario::end(Scenario): TransactionEffects
31: Pop
32: Ret
}
Expand All @@ -170,7 +177,7 @@ B0:
0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0])
1: StLoc[3](trials: u64)
2: LdConst[2](Address: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
3: Call[16](begin(address): Scenario)
3: Call test_scenario::begin(address): Scenario
4: StLoc[2](scenario_val: Scenario)
5: MutBorrowLoc[2](scenario_val: Scenario)
6: StLoc[1](scenario: &mut Scenario)
Expand All @@ -183,17 +190,17 @@ B2:
11: Branch(12)
B3:
12: CopyLoc[1](scenario: &mut Scenario)
13: Call[17](ctx(&mut Scenario): &mut TxContext)
14: Call[18](new(&mut TxContext): UID)
13: Call test_scenario::ctx(&mut Scenario): &mut TxContext
14: Call object::new(&mut TxContext): UID
15: Pack[0](ObjectWithID)
16: StLoc[0](obj: ObjectWithID)
17: ImmBorrowLoc[0](obj: ObjectWithID)
18: Call[1](calibrate_borrow_uid<ObjectWithID>(&ObjectWithID))
18: Call object::calibrate_borrow_uid<ObjectWithID>(&ObjectWithID)
19: ImmBorrowLoc[0](obj: ObjectWithID)
20: Pop
21: MoveLoc[0](obj: ObjectWithID)
22: Unpack[0](ObjectWithID)
23: Call[20](delete(UID))
23: Call object::delete(UID)
24: MoveLoc[3](trials: u64)
25: LdU64(1)
26: Sub
Expand All @@ -203,7 +210,7 @@ B4:
29: MoveLoc[1](scenario: &mut Scenario)
30: Pop
31: MoveLoc[2](scenario_val: Scenario)
32: Call[21](end(Scenario): TransactionEffects)
32: Call test_scenario::end(Scenario): TransactionEffects
33: Pop
34: Ret
}
Expand Down Expand Up @@ -266,7 +273,7 @@ B2:
B3:
7: LdConst[3](Vector(U8): [32, 58, 152, 93, 167, 79, 226, 37, 178, 4, 92, 23, 45, 107, 211, 144, 189, 133, 95, 8, 110, 62, 157, 82, 91, 70, 191, 226, 69, 17, 67, 21, 50])
8: LdU64(0)
9: Call[22](calibrate_derive_id(vector<u8>, u64))
9: Call tx_context::calibrate_derive_id(vector<u8>, u64)
10: MoveLoc[0](trials: u64)
11: LdU64(1)
12: Sub
Expand All @@ -290,7 +297,7 @@ B2:
B3:
7: LdConst[3](Vector(U8): [32, 58, 152, 93, 167, 79, 226, 37, 178, 4, 92, 23, 45, 107, 211, 144, 189, 133, 95, 8, 110, 62, 157, 82, 91, 70, 191, 226, 69, 17, 67, 21, 50])
8: LdU64(0)
9: Call[23](calibrate_derive_id_nop(vector<u8>, u64))
9: Call tx_context::calibrate_derive_id_nop(vector<u8>, u64)
10: MoveLoc[0](trials: u64)
11: LdU64(1)
12: Sub
Expand All @@ -302,7 +309,7 @@ B4:
unit_test_poison() {
B0:
0: LdU64(0)
1: Call[24](create_signers_for_testing(u64): vector<signer>)
1: Call unit_test::create_signers_for_testing(u64): vector<signer>
2: Pop
3: Ret
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ expression: common_costs_estimate
"storage_rebate": 0
},
"Publish": {
"computation_cost": 7471,
"storage_cost": 10672,
"computation_cost": 7484,
"storage_cost": 10690,
"storage_rebate": 0
},
"SharedCounterAssertValue": {
Expand Down
22 changes: 21 additions & 1 deletion crates/sui-framework/deps/move-stdlib/sources/vector.move
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ module std::vector {
}

/// Return true if `e` is in the vector `v`.
/// Otherwise, returns false.
public fun contains<Element>(v: &vector<Element>, e: &Element): bool {
let i = 0;
let len = length(v);
Expand Down Expand Up @@ -148,6 +149,26 @@ module std::vector {
pragma intrinsic = true;
}

/// Insert `e` at position `i` in the vector `v`.
/// If `i` is in bounds, this shifts the old `v[i]` and all subsequent elements to the right.
/// If `i == length(v)`, this adds `e` to the end of the vector.
/// This is O(n) and preserves ordering of elements in the vector.
/// Aborts if `i > length(v)`
public fun insert<Element>(v: &mut vector<Element>, e: Element, i: u64) {
let len = length(v);
// i too big abort
if (i > len) abort EINDEX_OUT_OF_BOUNDS;

push_back(v, e);
while (i < len) {
swap(v, i, len);
i = i + 1
}
}
spec insert {
pragma intrinsic = true;
}

/// Swap the `i`th element of the vector `v` with the last element and then pop the vector.
/// This is O(1), but does not preserve ordering of elements in the vector.
/// Aborts if `i` is out of bounds.
Expand Down Expand Up @@ -196,5 +217,4 @@ module std::vector {
v1[i..len(v1)] == v2[i + 1..len(v2)]
}
}

}
17 changes: 13 additions & 4 deletions crates/sui-protocol-constants/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,23 @@ pub const MAX_BASIC_BLOCKS: usize = 1024;
/// Maximum stack size value. Enforced by the Move bytecode verifier.
pub const MAX_VALUE_STACK_SIZE: usize = 1024;

/// Maximum number of type nodes. Enforced by the Move bytecode verifier.
/// Maximum number of "type nodes", a metric for how big a SignatureToken will be when expanded into a fully qualified type. Enforced by the Move bytecode verifier.
pub const MAX_TYPE_NODES: usize = 256;

/// Maximum number of pushes in one function. Enforced by the Move bytecode verifier.
/// Maximum number of push instructions in one function. Enforced by the Move bytecode verifier.
pub const MAX_PUSH_SIZE: usize = 10000;

/// Maximum dependency depth. Enforced by the Move bytecode verifier.
pub const MAX_DEPENDENCY_DEPTH: u64 = 100;
/// Maximum number of struct definitions in a module. Enforced by the Move bytecode verifier.
pub const MAX_STRUCT_DEFINITIONS: usize = 200;

/// Maximum number of function definitions in a module. Enforced by the Move bytecode verifier.
pub const MAX_FUNCTION_DEFINITIONS: usize = 1000;

/// Maximum number of fields allowed in a struct definition. Enforced by the Move bytecode verifier.
pub const MAX_FIELDS_IN_STRUCT: usize = 32;

/// Maximum dependency depth. Enforced by the Move linker when loading dependent modules.
pub const MAX_DEPENDENCY_DEPTH: usize = 100;

/// Maximum number of events that a single Move function can emit. Enforced by the Sui adapter during execution.
// TODO: is this per Move function, or per transaction? And if per-function, can't I get around the limit by calling
Expand Down
Loading

0 comments on commit 2d3f2d4

Please sign in to comment.