Skip to content

Commit

Permalink
[move] Copy Sui's Move stdlib into external-crates. Bump the default …
Browse files Browse the repository at this point in the history
…package version to 2024 beta. (MystenLabs#18827)

## Description 

- Copied Sui's stdlib over to external-crates
- Changed the default edition for package-less files in the compiler to
2024 beta.

## Test plan 

- Ran tests, updated where necessary

---

## 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.

- [ ] Protocol: 
- [ ] Nodes (Validators and Full nodes): 
- [ ] Indexer: 
- [ ] JSON-RPC: 
- [ ] GraphQL: 
- [ ] CLI: 
- [ ] Rust SDK:
- [ ] REST API:
  • Loading branch information
tnowacki authored Jul 28, 2024
1 parent 2501733 commit eb55624
Show file tree
Hide file tree
Showing 256 changed files with 18,603 additions and 4,224 deletions.
2 changes: 1 addition & 1 deletion bridge/move/tokens/btc/Move.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[package]
name = "BridgedBTC"
version = "0.0.1"
edition = "legacy"

[dependencies]
MoveStdlib = { local = "../../../../crates/sui-framework/packages/move-stdlib" }
Sui = { local = "../../../../crates/sui-framework/packages/sui-framework" }

[addresses]
bridged_btc = "0x0"

2 changes: 1 addition & 1 deletion bridge/move/tokens/eth/Move.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[package]
name = "BridgedETH"
version = "0.0.1"
edition = "legacy"

[dependencies]
MoveStdlib = { local = "../../../../crates/sui-framework/packages/move-stdlib" }
Sui = { local = "../../../../crates/sui-framework/packages/sui-framework" }

[addresses]
bridged_eth = "0x0"

2 changes: 1 addition & 1 deletion bridge/move/tokens/mock/ka/Move.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[package]
name = "BridgedKa"
version = "0.0.1"
edition = "legacy"

[dependencies]
MoveStdlib = { local = "../../../../../crates/sui-framework/packages/move-stdlib" }
Sui = { local = "../../../../../crates/sui-framework/packages/sui-framework" }

[addresses]
bridged_ka = "0x0"

2 changes: 1 addition & 1 deletion bridge/move/tokens/usdc/Move.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[package]
name = "BridgedUSDC"
version = "0.0.1"
edition = "legacy"

[dependencies]
MoveStdlib = { local = "../../../../crates/sui-framework/packages/move-stdlib" }
Sui = { local = "../../../../crates/sui-framework/packages/sui-framework" }

[addresses]
bridged_usdc = "0x0"

2 changes: 1 addition & 1 deletion bridge/move/tokens/usdt/Move.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[package]
name = "BridgedUSDT"
version = "0.0.1"
edition = "legacy"

[dependencies]
MoveStdlib = { local = "../../../../crates/sui-framework/packages/move-stdlib" }
Sui = { local = "../../../../crates/sui-framework/packages/sui-framework" }

[addresses]
bridged_usdt = "0x0"

Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ task 6, lines 68-70:
//# run Test::M1::emit_event_with_size --args 200000 --gas-budget 100000000000000 --summarize
events: 1
mutated: 1
gas summary: computation_cost: 1393000000, storage_cost: 988000, storage_rebate: 978120, non_refundable_storage_fee: 9880
gas summary: computation_cost: 1394000000, storage_cost: 988000, storage_rebate: 978120, non_refundable_storage_fee: 9880

task 7, lines 71-73:
//# run Test::M1::emit_event_with_size --args 256000 --gas-budget 100000000000000 --summarize
events: 1
mutated: 1
gas summary: computation_cost: 1814000000, storage_cost: 988000, storage_rebate: 978120, non_refundable_storage_fee: 9880
gas summary: computation_cost: 1815000000, storage_cost: 988000, storage_rebate: 978120, non_refundable_storage_fee: 9880

task 8, lines 74-76:
//# run Test::M1::emit_event_with_size --args 256001 --gas-budget 100000000000000 --summarize
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ task 3, lines 82-84:
//# run Test::M1::transfer_object_with_size --args 255999 --sender A --gas-budget 100000000000000
created: object(3,0)
mutated: object(0,0)
gas summary: computation_cost: 1863000000, storage_cost: 1947553200, storage_rebate: 978120, non_refundable_storage_fee: 9880
gas summary: computation_cost: 1864000000, storage_cost: 1947553200, storage_rebate: 978120, non_refundable_storage_fee: 9880

task 4, line 85:
//# run Test::M1::transfer_object_with_size --args 256000 --sender A --gas-budget 100000000000000
created: object(4,0)
mutated: object(0,0)
gas summary: computation_cost: 1863000000, storage_cost: 1947560800, storage_rebate: 978120, non_refundable_storage_fee: 9880
gas summary: computation_cost: 1864000000, storage_cost: 1947560800, storage_rebate: 978120, non_refundable_storage_fee: 9880
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ async fn test_manage_package_update() {
.read_to_string(&mut lock_file_contents)
.expect("Error reading Move.lock file");

let expected = expect![[r#"
let expected = expect![[r##"
# @generated by Move, please check-in and do not edit manually.
[move]
Expand All @@ -56,7 +56,7 @@ async fn test_manage_package_update() {
[move.toolchain-version]
compiler-version = "0.0.1"
edition = "legacy"
edition = "2024.beta"
flavor = "sui"
[env]
Expand All @@ -66,6 +66,6 @@ async fn test_manage_package_update() {
original-published-id = "0x000000000000000000000000000000000000000000000000000000000000000a"
latest-published-id = "0x000000000000000000000000000000000000000000000000000000000000000b"
published-version = "5"
"#]];
"##]];
expected.assert_eq(lock_file_contents.as_str());
}
5 changes: 4 additions & 1 deletion crates/sui-move/src/unit_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,10 @@ pub fn run_move_unit_tests(
report_stacktrace_on_abort: true,
..config
},
sui_move_natives::all_natives(/* silent */ false),
sui_move_natives::all_natives(
/* silent */ false,
&ProtocolConfig::get_for_max_version_UNSAFE(),
),
Some(initial_cost_schedule_for_unit_tests()),
compute_coverage,
&mut std::io::stdout(),
Expand Down
31 changes: 30 additions & 1 deletion crates/sui-open-rpc/spec/openrpc.json
Original file line number Diff line number Diff line change
Expand Up @@ -1368,6 +1368,9 @@
"base_tx_cost_per_byte": {
"u64": "0"
},
"bcs_failure_cost": null,
"bcs_legacy_min_output_size_cost": null,
"bcs_per_byte_serialized_cost": null,
"binary_address_identifiers": null,
"binary_constant_pool": null,
"binary_enum_def_instantiations": null,
Expand Down Expand Up @@ -1419,6 +1422,8 @@
"crypto_invalid_arguments_cost": {
"u64": "100"
},
"debug_print_base_cost": null,
"debug_print_stack_trace_base_cost": null,
"dynamic_field_add_child_object_cost_base": {
"u64": "100"
},
Expand Down Expand Up @@ -1652,6 +1657,12 @@
"hash_keccak256_data_cost_per_byte": {
"u64": "2"
},
"hash_sha2_256_base_cost": null,
"hash_sha2_256_legacy_min_input_len_cost": null,
"hash_sha2_256_per_byte_cost": null,
"hash_sha3_256_base_cost": null,
"hash_sha3_256_legacy_min_input_len_cost": null,
"hash_sha3_256_per_byte_cost": null,
"hmac_hmac_sha3_256_cost_base": {
"u64": "52"
},
Expand Down Expand Up @@ -1875,6 +1886,14 @@
"storage_rebate_rate": {
"u64": "9900"
},
"string_check_utf8_base_cost": null,
"string_check_utf8_per_byte_cost": null,
"string_index_of_base_cost": null,
"string_index_of_per_byte_pattern_cost": null,
"string_index_of_per_byte_searched_cost": null,
"string_is_char_boundary_base_cost": null,
"string_sub_string_base_cost": null,
"string_sub_string_per_byte_cost": null,
"transfer_freeze_object_cost_base": {
"u64": "52"
},
Expand All @@ -1888,6 +1907,8 @@
"tx_context_derive_id_cost_base": {
"u64": "52"
},
"type_name_get_base_cost": null,
"type_name_get_per_byte_cost": null,
"types_is_one_time_witness_cost_base": {
"u64": "52"
},
Expand All @@ -1904,7 +1925,15 @@
"u64": "2"
},
"vdf_hash_to_input_cost": null,
"vdf_verify_vdf_cost": null
"vdf_verify_vdf_cost": null,
"vector_borrow_base_cost": null,
"vector_destroy_empty_base_cost": null,
"vector_empty_base_cost": null,
"vector_length_base_cost": null,
"vector_pop_back_base_cost": null,
"vector_push_back_base_cost": null,
"vector_push_back_legacy_per_abstract_memory_unit_cost": null,
"vector_swap_base_cost": null
}
}
}
Expand Down
96 changes: 96 additions & 0 deletions crates/sui-protocol-config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ const MAX_PROTOCOL_VERSION: u64 = 53;
// Version 53: Add feature flag to decide whether to attempt to finalize bridge committee
// Enable consensus commit prologue V3 on testnet.
// Turn on shared object congestion control in testnet.
// Update stdlib natives costs

#[derive(Copy, Clone, Debug, Hash, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)]
pub struct ProtocolVersion(u64);
Expand Down Expand Up @@ -1101,6 +1102,40 @@ pub struct ProtocolConfig {
vdf_verify_vdf_cost: Option<u64>,
vdf_hash_to_input_cost: Option<u64>,

// Stdlib costs
bcs_per_byte_serialized_cost: Option<u64>,
bcs_legacy_min_output_size_cost: Option<u64>,
bcs_failure_cost: Option<u64>,

hash_sha2_256_base_cost: Option<u64>,
hash_sha2_256_per_byte_cost: Option<u64>,
hash_sha2_256_legacy_min_input_len_cost: Option<u64>,
hash_sha3_256_base_cost: Option<u64>,
hash_sha3_256_per_byte_cost: Option<u64>,
hash_sha3_256_legacy_min_input_len_cost: Option<u64>,
type_name_get_base_cost: Option<u64>,
type_name_get_per_byte_cost: Option<u64>,

string_check_utf8_base_cost: Option<u64>,
string_check_utf8_per_byte_cost: Option<u64>,
string_is_char_boundary_base_cost: Option<u64>,
string_sub_string_base_cost: Option<u64>,
string_sub_string_per_byte_cost: Option<u64>,
string_index_of_base_cost: Option<u64>,
string_index_of_per_byte_pattern_cost: Option<u64>,
string_index_of_per_byte_searched_cost: Option<u64>,

vector_empty_base_cost: Option<u64>,
vector_length_base_cost: Option<u64>,
vector_push_back_base_cost: Option<u64>,
vector_push_back_legacy_per_abstract_memory_unit_cost: Option<u64>,
vector_borrow_base_cost: Option<u64>,
vector_pop_back_base_cost: Option<u64>,
vector_destroy_empty_base_cost: Option<u64>,
vector_swap_base_cost: Option<u64>,
debug_print_base_cost: Option<u64>,
debug_print_stack_trace_base_cost: Option<u64>,

// ==== Ephemeral (consensus only) params deleted ====
//
// Const params for consensus scoring decision
Expand Down Expand Up @@ -1909,6 +1944,36 @@ impl ProtocolConfig {
vdf_verify_vdf_cost: None,
vdf_hash_to_input_cost: None,

bcs_per_byte_serialized_cost: None,
bcs_legacy_min_output_size_cost: None,
bcs_failure_cost: None,
hash_sha2_256_base_cost: None,
hash_sha2_256_per_byte_cost: None,
hash_sha2_256_legacy_min_input_len_cost: None,
hash_sha3_256_base_cost: None,
hash_sha3_256_per_byte_cost: None,
hash_sha3_256_legacy_min_input_len_cost: None,
type_name_get_base_cost: None,
type_name_get_per_byte_cost: None,
string_check_utf8_base_cost: None,
string_check_utf8_per_byte_cost: None,
string_is_char_boundary_base_cost: None,
string_sub_string_base_cost: None,
string_sub_string_per_byte_cost: None,
string_index_of_base_cost: None,
string_index_of_per_byte_pattern_cost: None,
string_index_of_per_byte_searched_cost: None,
vector_empty_base_cost: None,
vector_length_base_cost: None,
vector_push_back_base_cost: None,
vector_push_back_legacy_per_abstract_memory_unit_cost: None,
vector_borrow_base_cost: None,
vector_pop_back_base_cost: None,
vector_destroy_empty_base_cost: None,
vector_swap_base_cost: None,
debug_print_base_cost: None,
debug_print_stack_trace_base_cost: None,

max_size_written_objects: None,
max_size_written_objects_system_tx: None,

Expand Down Expand Up @@ -2536,6 +2601,37 @@ impl ProtocolConfig {
cfg.feature_flags.per_object_congestion_control_mode =
PerObjectCongestionControlMode::TotalTxCount;
}

// Adjust stdlib gas costs
cfg.bcs_per_byte_serialized_cost = Some(2);
cfg.bcs_legacy_min_output_size_cost = Some(1);
cfg.bcs_failure_cost = Some(52);
cfg.debug_print_base_cost = Some(52);
cfg.debug_print_stack_trace_base_cost = Some(52);
cfg.hash_sha2_256_base_cost = Some(52);
cfg.hash_sha2_256_per_byte_cost = Some(2);
cfg.hash_sha2_256_legacy_min_input_len_cost = Some(1);
cfg.hash_sha3_256_base_cost = Some(52);
cfg.hash_sha3_256_per_byte_cost = Some(2);
cfg.hash_sha3_256_legacy_min_input_len_cost = Some(1);
cfg.type_name_get_base_cost = Some(52);
cfg.type_name_get_per_byte_cost = Some(2);
cfg.string_check_utf8_base_cost = Some(52);
cfg.string_check_utf8_per_byte_cost = Some(2);
cfg.string_is_char_boundary_base_cost = Some(52);
cfg.string_sub_string_base_cost = Some(52);
cfg.string_sub_string_per_byte_cost = Some(2);
cfg.string_index_of_base_cost = Some(52);
cfg.string_index_of_per_byte_pattern_cost = Some(2);
cfg.string_index_of_per_byte_searched_cost = Some(2);
cfg.vector_empty_base_cost = Some(52);
cfg.vector_length_base_cost = Some(52);
cfg.vector_push_back_base_cost = Some(52);
cfg.vector_push_back_legacy_per_abstract_memory_unit_cost = Some(2);
cfg.vector_borrow_base_cost = Some(52);
cfg.vector_pop_back_base_cost = Some(52);
cfg.vector_destroy_empty_base_cost = Some(52);
cfg.vector_swap_base_cost = Some(52);
}
// Use this template when making changes:
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,35 @@ hmac_hmac_sha3_256_input_cost_per_byte: 2
hmac_hmac_sha3_256_input_cost_per_block: 2
check_zklogin_id_cost_base: 200
check_zklogin_issuer_cost_base: 200
bcs_per_byte_serialized_cost: 2
bcs_legacy_min_output_size_cost: 1
bcs_failure_cost: 52
hash_sha2_256_base_cost: 52
hash_sha2_256_per_byte_cost: 2
hash_sha2_256_legacy_min_input_len_cost: 1
hash_sha3_256_base_cost: 52
hash_sha3_256_per_byte_cost: 2
hash_sha3_256_legacy_min_input_len_cost: 1
type_name_get_base_cost: 52
type_name_get_per_byte_cost: 2
string_check_utf8_base_cost: 52
string_check_utf8_per_byte_cost: 2
string_is_char_boundary_base_cost: 52
string_sub_string_base_cost: 52
string_sub_string_per_byte_cost: 2
string_index_of_base_cost: 52
string_index_of_per_byte_pattern_cost: 2
string_index_of_per_byte_searched_cost: 2
vector_empty_base_cost: 52
vector_length_base_cost: 52
vector_push_back_base_cost: 52
vector_push_back_legacy_per_abstract_memory_unit_cost: 2
vector_borrow_base_cost: 52
vector_pop_back_base_cost: 52
vector_destroy_empty_base_cost: 52
vector_swap_base_cost: 52
debug_print_base_cost: 52
debug_print_stack_trace_base_cost: 52
execution_version: 3
consensus_bad_nodes_stake_threshold: 20
max_jwk_votes_per_validator_per_epoch: 240
Expand Down
Loading

0 comments on commit eb55624

Please sign in to comment.