diff --git a/crates/sui-framework/docs/sui/tx_context.md b/crates/sui-framework/docs/sui/tx_context.md index 6d0ee6c248f3f..def86c98fd503 100644 --- a/crates/sui-framework/docs/sui/tx_context.md +++ b/crates/sui-framework/docs/sui/tx_context.md @@ -6,15 +6,27 @@ title: Module `sui::tx_context` - [Struct `TxContext`](#sui_tx_context_TxContext) - [Function `sender`](#sui_tx_context_sender) +- [Function `native_sender`](#sui_tx_context_native_sender) - [Function `digest`](#sui_tx_context_digest) - [Function `epoch`](#sui_tx_context_epoch) +- [Function `native_epoch`](#sui_tx_context_native_epoch) - [Function `epoch_timestamp_ms`](#sui_tx_context_epoch_timestamp_ms) +- [Function `native_epoch_timestamp_ms`](#sui_tx_context_native_epoch_timestamp_ms) +- [Function `sponsor`](#sui_tx_context_sponsor) - [Function `fresh_object_address`](#sui_tx_context_fresh_object_address) +- [Function `fresh_id`](#sui_tx_context_fresh_id) - [Function `ids_created`](#sui_tx_context_ids_created) +- [Function `native_ids_created`](#sui_tx_context_native_ids_created) +- [Function `native_gas_price`](#sui_tx_context_native_gas_price) +- [Function `native_gas_budget`](#sui_tx_context_native_gas_budget) +- [Function `option_sponsor`](#sui_tx_context_option_sponsor) +- [Function `native_sponsor`](#sui_tx_context_native_sponsor) - [Function `derive_id`](#sui_tx_context_derive_id) -
+
use std::option;
+use std::vector;
+
@@ -81,7 +93,7 @@ Return the address of the user that signed the current transaction -
public fun sender(self: &sui::tx_context::TxContext): address
+
public fun sender(_self: &sui::tx_context::TxContext): address
 
@@ -90,13 +102,35 @@ transaction Implementation -
public fun sender(self: &TxContext): address {
-    self.sender
+
public fun sender(_self: &TxContext): address {
+    native_sender()
 }
 
+ + + + +## Function `native_sender` + + + +
fun native_sender(): address
+
+ + + +
+Implementation + + +
native fun native_sender(): address;
+
+ + +
@@ -132,7 +166,7 @@ Please do not use as a source of randomness. Return the current epoch -
public fun epoch(self: &sui::tx_context::TxContext): u64
+
public fun epoch(_self: &sui::tx_context::TxContext): u64
 
@@ -141,13 +175,35 @@ Return the current epoch Implementation -
public fun epoch(self: &TxContext): u64 {
-    self.epoch
+
public fun epoch(_self: &TxContext): u64 {
+    native_epoch()
 }
 
+ + + + +## Function `native_epoch` + + + +
fun native_epoch(): u64
+
+ + + +
+Implementation + + +
native fun native_epoch(): u64;
+
+ + +
@@ -157,7 +213,54 @@ Return the current epoch Return the epoch start time as a unix timestamp in milliseconds. -
public fun epoch_timestamp_ms(self: &sui::tx_context::TxContext): u64
+
public fun epoch_timestamp_ms(_self: &sui::tx_context::TxContext): u64
+
+ + + +
+Implementation + + +
public fun epoch_timestamp_ms(_self: &TxContext): u64 {
+    native_epoch_timestamp_ms()
+}
+
+ + + +
+ + + +## Function `native_epoch_timestamp_ms` + + + +
fun native_epoch_timestamp_ms(): u64
+
+ + + +
+Implementation + + +
native fun native_epoch_timestamp_ms(): u64;
+
+ + + +
+ + + +## Function `sponsor` + +Return the adress of the transaction sponsor or None if there was no sponsor. + + +
public fun sponsor(_self: &sui::tx_context::TxContext): std::option::Option<address>
 
@@ -166,8 +269,8 @@ Return the epoch start time as a unix timestamp in milliseconds. Implementation -
public fun epoch_timestamp_ms(self: &TxContext): u64 {
-    self.epoch_timestamp_ms
+
public fun sponsor(_self: &TxContext): Option<address> {
+    option_sponsor()
 }
 
@@ -184,7 +287,7 @@ occur as the address for a user. In other words, the generated address is a globally unique object ID. -
public fun fresh_object_address(ctx: &mut sui::tx_context::TxContext): address
+
public fun fresh_object_address(_ctx: &mut sui::tx_context::TxContext): address
 
@@ -193,16 +296,35 @@ In other words, the generated address is a globally unique object ID. Implementation -
public fun fresh_object_address(ctx: &mut TxContext): address {
-    let ids_created = ctx.ids_created;
-    let id = derive_id(*&ctx.tx_hash, ids_created);
-    ctx.ids_created = ids_created + 1;
-    id
+
public fun fresh_object_address(_ctx: &mut TxContext): address {
+    fresh_id()
 }
 
+ + + + +## Function `fresh_id` + + + +
fun fresh_id(): address
+
+ + + +
+Implementation + + +
native fun fresh_id(): address;
+
+ + +
@@ -213,7 +335,7 @@ Return the number of id's created by the current transaction. Hidden for now, but may expose later -
fun ids_created(self: &sui::tx_context::TxContext): u64
+
fun ids_created(_self: &sui::tx_context::TxContext): u64
 
@@ -222,13 +344,130 @@ Hidden for now, but may expose later Implementation -
fun ids_created(self: &TxContext): u64 {
-    self.ids_created
+
fun ids_created(_self: &TxContext): u64 {
+    native_ids_created()
 }
 
+ + + + +## Function `native_ids_created` + + + +
fun native_ids_created(): u64
+
+ + + +
+Implementation + + +
native fun native_ids_created(): u64;
+
+ + + +
+ + + +## Function `native_gas_price` + + + +
fun native_gas_price(): u64
+
+ + + +
+Implementation + + +
native fun native_gas_price(): u64;
+
+ + + +
+ + + +## Function `native_gas_budget` + + + +
fun native_gas_budget(): u64
+
+ + + +
+Implementation + + +
native fun native_gas_budget(): u64;
+
+ + + +
+ + + +## Function `option_sponsor` + + + +
fun option_sponsor(): std::option::Option<address>
+
+ + + +
+Implementation + + +
fun option_sponsor(): Option<address> {
+    let sponsor = native_sponsor();
+    if (sponsor.length() == 0) {
+        option::none()
+    } else {
+        option::some(sponsor[0])
+    }
+}
+
+ + + +
+ + + +## Function `native_sponsor` + + + +
fun native_sponsor(): vector<address>
+
+ + + +
+Implementation + + +
native fun native_sponsor(): vector<address>;
+
+ + +
diff --git a/crates/sui-framework/packages_compiled/sui-framework b/crates/sui-framework/packages_compiled/sui-framework index 2ff5694239ff8..f1f800832acf9 100644 Binary files a/crates/sui-framework/packages_compiled/sui-framework and b/crates/sui-framework/packages_compiled/sui-framework differ diff --git a/crates/sui-framework/published_api.txt b/crates/sui-framework/published_api.txt index 383546c067f34..b1e7c2e45c6ec 100644 --- a/crates/sui-framework/published_api.txt +++ b/crates/sui-framework/published_api.txt @@ -1126,21 +1126,51 @@ TxContext sender public fun 0x2::tx_context +native_sender + fun + 0x2::tx_context digest public fun 0x2::tx_context epoch public fun 0x2::tx_context +native_epoch + fun + 0x2::tx_context epoch_timestamp_ms public fun 0x2::tx_context +native_epoch_timestamp_ms + fun + 0x2::tx_context +sponsor + public fun + 0x2::tx_context fresh_object_address public fun 0x2::tx_context +fresh_id + fun + 0x2::tx_context ids_created fun 0x2::tx_context +native_ids_created + fun + 0x2::tx_context +native_gas_price + fun + 0x2::tx_context +native_gas_budget + fun + 0x2::tx_context +option_sponsor + fun + 0x2::tx_context +native_sponsor + fun + 0x2::tx_context derive_id fun 0x2::tx_context diff --git a/crates/sui-open-rpc/spec/openrpc.json b/crates/sui-open-rpc/spec/openrpc.json index 9f5d5ceb090c6..2b4acfa4037bc 100644 --- a/crates/sui-open-rpc/spec/openrpc.json +++ b/crates/sui-open-rpc/spec/openrpc.json @@ -1336,6 +1336,7 @@ "loaded_child_objects_fixed": true, "minimize_child_object_mutations": false, "missing_type_is_compatibility_error": true, + "move_native_context": false, "mysticeti_fastpath": false, "mysticeti_leader_scoring_and_schedule": false, "mysticeti_use_committed_subdag_digest": false, @@ -1948,6 +1949,15 @@ "tx_context_derive_id_cost_base": { "u64": "52" }, + "tx_context_epoch_cost_base": null, + "tx_context_epoch_timestamp_ms_cost_base": null, + "tx_context_fresh_id_cost_base": null, + "tx_context_gas_budget_cost_base": null, + "tx_context_gas_price_cost_base": null, + "tx_context_ids_created_cost_base": null, + "tx_context_replace_cost_base": null, + "tx_context_sender_cost_base": null, + "tx_context_sponsor_cost_base": null, "type_name_get_base_cost": null, "type_name_get_per_byte_cost": null, "types_is_one_time_witness_cost_base": { diff --git a/crates/sui-protocol-config/src/snapshots/sui_protocol_config__test__Mainnet_version_76.snap b/crates/sui-protocol-config/src/snapshots/sui_protocol_config__test__Mainnet_version_76.snap index ab37b2a9a5b6d..b537fbea4d449 100644 --- a/crates/sui-protocol-config/src/snapshots/sui_protocol_config__test__Mainnet_version_76.snap +++ b/crates/sui-protocol-config/src/snapshots/sui_protocol_config__test__Mainnet_version_76.snap @@ -72,6 +72,7 @@ feature_flags: variant_nodes: true consensus_zstd_compression: true minimize_child_object_mutations: true + move_native_context: true max_tx_size_bytes: 131072 max_input_objects: 2048 max_size_written_objects: 5000000 @@ -195,6 +196,15 @@ transfer_freeze_object_cost_base: 52 transfer_share_object_cost_base: 52 transfer_receive_object_cost_base: 52 tx_context_derive_id_cost_base: 52 +tx_context_fresh_id_cost_base: 52 +tx_context_sender_cost_base: 30 +tx_context_epoch_cost_base: 30 +tx_context_epoch_timestamp_ms_cost_base: 30 +tx_context_sponsor_cost_base: 30 +tx_context_gas_price_cost_base: 30 +tx_context_gas_budget_cost_base: 30 +tx_context_ids_created_cost_base: 30 +tx_context_replace_cost_base: 30 types_is_one_time_witness_cost_base: 52 types_is_one_time_witness_type_tag_cost_per_byte: 2 types_is_one_time_witness_type_cost_per_byte: 2 diff --git a/crates/sui-protocol-config/src/snapshots/sui_protocol_config__test__Testnet_version_76.snap b/crates/sui-protocol-config/src/snapshots/sui_protocol_config__test__Testnet_version_76.snap index 1bcada476883d..548c6f58fc255 100644 --- a/crates/sui-protocol-config/src/snapshots/sui_protocol_config__test__Testnet_version_76.snap +++ b/crates/sui-protocol-config/src/snapshots/sui_protocol_config__test__Testnet_version_76.snap @@ -1,7 +1,6 @@ --- source: crates/sui-protocol-config/src/lib.rs expression: "ProtocolConfig::get_for_version(cur, *chain_id)" -snapshot_kind: text --- version: 76 feature_flags: @@ -77,6 +76,7 @@ feature_flags: variant_nodes: true consensus_zstd_compression: true minimize_child_object_mutations: true + move_native_context: true max_tx_size_bytes: 131072 max_input_objects: 2048 max_size_written_objects: 5000000 @@ -200,6 +200,15 @@ transfer_freeze_object_cost_base: 52 transfer_share_object_cost_base: 52 transfer_receive_object_cost_base: 52 tx_context_derive_id_cost_base: 52 +tx_context_fresh_id_cost_base: 52 +tx_context_sender_cost_base: 30 +tx_context_epoch_cost_base: 30 +tx_context_epoch_timestamp_ms_cost_base: 30 +tx_context_sponsor_cost_base: 30 +tx_context_gas_price_cost_base: 30 +tx_context_gas_budget_cost_base: 30 +tx_context_ids_created_cost_base: 30 +tx_context_replace_cost_base: 30 types_is_one_time_witness_cost_base: 52 types_is_one_time_witness_type_tag_cost_per_byte: 2 types_is_one_time_witness_type_cost_per_byte: 2 diff --git a/crates/sui-protocol-config/src/snapshots/sui_protocol_config__test__version_76.snap b/crates/sui-protocol-config/src/snapshots/sui_protocol_config__test__version_76.snap index e2309268d0825..12669651afea2 100644 --- a/crates/sui-protocol-config/src/snapshots/sui_protocol_config__test__version_76.snap +++ b/crates/sui-protocol-config/src/snapshots/sui_protocol_config__test__version_76.snap @@ -1,7 +1,6 @@ --- source: crates/sui-protocol-config/src/lib.rs expression: "ProtocolConfig::get_for_version(cur, *chain_id)" -snapshot_kind: text --- version: 76 feature_flags: @@ -84,6 +83,7 @@ feature_flags: consensus_zstd_compression: true minimize_child_object_mutations: true record_additional_state_digest_in_prologue: true + move_native_context: true max_tx_size_bytes: 131072 max_input_objects: 2048 max_size_written_objects: 5000000 @@ -207,6 +207,15 @@ transfer_freeze_object_cost_base: 52 transfer_share_object_cost_base: 52 transfer_receive_object_cost_base: 52 tx_context_derive_id_cost_base: 52 +tx_context_fresh_id_cost_base: 52 +tx_context_sender_cost_base: 30 +tx_context_epoch_cost_base: 30 +tx_context_epoch_timestamp_ms_cost_base: 30 +tx_context_sponsor_cost_base: 30 +tx_context_gas_price_cost_base: 30 +tx_context_gas_budget_cost_base: 30 +tx_context_ids_created_cost_base: 30 +tx_context_replace_cost_base: 30 types_is_one_time_witness_cost_base: 52 types_is_one_time_witness_type_tag_cost_per_byte: 2 types_is_one_time_witness_type_cost_per_byte: 2 diff --git a/crates/sui-swarm-config/tests/snapshots/snapshot_tests__populated_genesis_snapshot_matches-2.snap b/crates/sui-swarm-config/tests/snapshots/snapshot_tests__populated_genesis_snapshot_matches-2.snap index 2e494f01cdb9a..0a936e5f62e27 100644 --- a/crates/sui-swarm-config/tests/snapshots/snapshot_tests__populated_genesis_snapshot_matches-2.snap +++ b/crates/sui-swarm-config/tests/snapshots/snapshot_tests__populated_genesis_snapshot_matches-2.snap @@ -240,13 +240,13 @@ validators: next_epoch_worker_address: ~ extra_fields: id: - id: "0x63c951f50d71f7fa58e90fee1820ed27a15f47602cbc0640d58c5675d9cc93cf" + id: "0xc79dff7ec5aa1231a64f92bdc8a0327aceb1e925459833003cc6ff0f7873d459" size: 0 voting_power: 10000 - operation_cap_id: "0x99a1cb0cfa940302fd08144dec6460b0225cf8ba438081ac32fcd00389092c4d" + operation_cap_id: "0x9b8e68f6b18b19601ecdec42dc8cf72f3c3d1fb964183ebfcf18bafece7fca0f" gas_price: 1000 staking_pool: - id: "0x430f34db68b99ed1c4a02d009f6423b35dd2ce2bb5015c02df4a3ab8fd671a6f" + id: "0x2aeda98fe221915899f30089c2c1bf69c7bf32191514f42e3249c7e4c43fc50e" activation_epoch: 0 deactivation_epoch: ~ sui_balance: 20000000000000000 @@ -254,14 +254,14 @@ validators: value: 0 pool_token_balance: 20000000000000000 exchange_rates: - id: "0x68047818ec2262573e5a7241853b364559e84d2b7a93973853c3f52c46e6103d" + id: "0x78c735966f66630a76f52ec40c3cc61f87caed2b06c03edb18314c78cca80a0f" size: 1 pending_stake: 0 pending_total_sui_withdraw: 0 pending_pool_token_withdraw: 0 extra_fields: id: - id: "0x1203f7e9fb0a1503d530013ab3e1df797ed34e6e72d457caea9a250ed64e9b12" + id: "0x161c75aec428b012bcb7461c79f96a77565a75601537712c5f65bb286fcd5c19" size: 0 commission_rate: 200 next_epoch_stake: 20000000000000000 @@ -269,27 +269,27 @@ validators: next_epoch_commission_rate: 200 extra_fields: id: - id: "0xa208610c482bbf00d12ecb7ed113e3ec6cead7d292b5ddba487c67ae343b7420" + id: "0x754c4e43c88f05da020c2684259fe07df00b03ec3985b46504cc2b0f9f563c91" size: 0 pending_active_validators: contents: - id: "0x4ce4f20ae616257e491b61ed95f256062baf815b92181cd2028436bc9ffaedf6" + id: "0xfeea7ae4e456bd0cb32ec9210523cba4ae276434bfddf640fbcc6adfdda06cb7" size: 0 pending_removals: [] staking_pool_mappings: - id: "0xc226eef39a3c111c373bb4dd3871640d8ce2f9adca35da36d1363a707eda918b" + id: "0x10277ee2571a73f0492b0c4ada018b47b5127a166a477e3f6396938f4f177a3a" size: 1 inactive_validators: - id: "0xb7cf484096138508283d7e305874cd6e73eccca33d9ac2a8abbe33f8c854c11c" + id: "0xd4c4d87111bfcf8a4baabf6a4cb326c57e107f0a4f041ef44268f273ea69c9ff" size: 0 validator_candidates: - id: "0x05d9257a640e27a15f19b4e8aef7f892c2a66924e30c4af57153e3240cee33de" + id: "0x2920ee8971e55a78f30dc470d521ac943fa484b1d847e2c16d14a9de75a7250d" size: 0 at_risk_validators: contents: [] extra_fields: id: - id: "0xf91d9dc9849f07f3f38732aa9c40a9b0bb83a68a9b6324f8d59e66bc2dec76e0" + id: "0x43a8fade182ca5e738251c846dcc861a1a18d78dda872d8d6cb52551d8aa6daa" size: 0 storage_fund: total_object_storage_rebates: @@ -306,7 +306,7 @@ parameters: validator_low_stake_grace_period: 7 extra_fields: id: - id: "0xb86c133b102926c433bc95f2cb054c956e0a80567a3b39b9a9163520e725b1a8" + id: "0xb7bb2b297dbb3877b64f7cdcf19c73fb6eb6ca09ac278a0eb4c310bdd5f65459" size: 0 reference_gas_price: 1000 validator_report_records: @@ -320,7 +320,7 @@ stake_subsidy: stake_subsidy_decrease_rate: 1000 extra_fields: id: - id: "0x311ae5223405603a7741ce24339390240c2a97c70d785f5116e4316520920156" + id: "0x82e43c2dc972d4677e076e9d7ac1baf7404b805ccc720ae3e74c5245c195efa0" size: 0 safe_mode: false safe_mode_storage_rewards: @@ -332,5 +332,5 @@ safe_mode_non_refundable_storage_fee: 0 epoch_start_timestamp_ms: 10 extra_fields: id: - id: "0xfe0661290995d4a00c6d2775d900c03b5dc67ba1294f823b2c8d6f29b0a677f2" + id: "0x0e0506a9f5c68cac7e65b0112a8070c5d72e3253e817cb74c55211a553f6b5ca" size: 0