From 47ad6fd50f6498fc37b230f2693ab1b8ce6d0c1c Mon Sep 17 00:00:00 2001 From: Dario Russi <113150618+dariorussi@users.noreply.github.com> Date: Sat, 5 Oct 2024 12:04:45 -0500 Subject: [PATCH] snapshot'ing around --- .../docs/sui-framework/tx_context.md | 279 +++++++++++++- .../packages_compiled/sui-framework | Bin 66920 -> 67353 bytes crates/sui-framework/published_api.txt | 27 ++ crates/sui-open-rpc/spec/openrpc.json | 3 +- ...ocol_config__test__Mainnet_version_66.snap | 330 +++++++++++++++++ ...ocol_config__test__Testnet_version_66.snap | 330 +++++++++++++++++ ...sui_protocol_config__test__version_66.snap | 340 ++++++++++++++++++ ...ests__genesis_config_snapshot_matches.snap | 3 +- ..._populated_genesis_snapshot_matches-2.snap | 31 +- 9 files changed, 1317 insertions(+), 26 deletions(-) create mode 100644 crates/sui-protocol-config/src/snapshots/sui_protocol_config__test__Mainnet_version_66.snap create mode 100644 crates/sui-protocol-config/src/snapshots/sui_protocol_config__test__Testnet_version_66.snap create mode 100644 crates/sui-protocol-config/src/snapshots/sui_protocol_config__test__version_66.snap diff --git a/crates/sui-framework/docs/sui-framework/tx_context.md b/crates/sui-framework/docs/sui-framework/tx_context.md index 380f047c58eeb..d8d3a9d5bf835 100644 --- a/crates/sui-framework/docs/sui-framework/tx_context.md +++ b/crates/sui-framework/docs/sui-framework/tx_context.md @@ -5,16 +5,27 @@ title: Module `0x2::tx_context` - [Struct `TxContext`](#0x2_tx_context_TxContext) +- [Constants](#@Constants_0) - [Function `sender`](#0x2_tx_context_sender) - [Function `digest`](#0x2_tx_context_digest) - [Function `epoch`](#0x2_tx_context_epoch) - [Function `epoch_timestamp_ms`](#0x2_tx_context_epoch_timestamp_ms) +- [Function `sponsor`](#0x2_tx_context_sponsor) - [Function `fresh_object_address`](#0x2_tx_context_fresh_object_address) +- [Function `increment_ids_created`](#0x2_tx_context_increment_ids_created) - [Function `ids_created`](#0x2_tx_context_ids_created) - [Function `derive_id`](#0x2_tx_context_derive_id) +- [Function `native_sender`](#0x2_tx_context_native_sender) +- [Function `native_digest`](#0x2_tx_context_native_digest) +- [Function `native_epoch`](#0x2_tx_context_native_epoch) +- [Function `native_epoch_timestamp_ms`](#0x2_tx_context_native_epoch_timestamp_ms) +- [Function `native_sponsor`](#0x2_tx_context_native_sponsor) +- [Function `native_ids_created`](#0x2_tx_context_native_ids_created) +- [Function `native_inc_ids_created`](#0x2_tx_context_native_inc_ids_created) -
+use 0x1::option;
+
@@ -73,6 +84,29 @@ the VM and passed in to the entrypoint of the transaction as &mut <
+
+
+## Constants
+
+
+
+
+
+
+const EUnsupportedFunction: u64 = 2;
+
+
+
+
+
+
+
+
+const NATIVE_CONTEXT: bool = false;
+
+
+
+
## Function `sender`
@@ -91,7 +125,11 @@ transaction
public fun sender(self: &TxContext): address {
- self.sender
+ if (NATIVE_CONTEXT) {
+ self.native_sender()
+ } else {
+ self.sender
+ }
}
@@ -117,7 +155,11 @@ Please do not use as a source of randomness.
public fun digest(self: &TxContext): &vector<u8> {
- &self.tx_hash
+ if (NATIVE_CONTEXT) {
+ self.native_digest()
+ } else {
+ &self.tx_hash
+ }
}
@@ -142,7 +184,11 @@ Return the current epoch
public fun epoch(self: &TxContext): u64 {
- self.epoch
+ if (NATIVE_CONTEXT) {
+ self.native_epoch()
+ } else {
+ self.epoch
+ }
}
@@ -167,7 +213,36 @@ Return the epoch start time as a unix timestamp in milliseconds.
public fun epoch_timestamp_ms(self: &TxContext): u64 {
- self.epoch_timestamp_ms
+ if (NATIVE_CONTEXT) {
+ self.native_epoch_timestamp_ms()
+ } else {
+ self.epoch_timestamp_ms
+ }
+}
+
+
+
+
+
+
+
+
+## Function `sponsor`
+
+
+
+public fun sponsor(self: &tx_context::TxContext): option::Option<address>
+
+
+
+
+
+Implementation
+
+
+public fun sponsor(self: &TxContext): Option<address> {
+ assert!(NATIVE_CONTEXT, EUnsupportedFunction);
+ self.native_sponsor()
}
@@ -194,15 +269,43 @@ In other words, the generated address is a globally unique object ID.
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;
+ let ids_created = ctx.ids_created();
+ let id = derive_id(*ctx.digest(), ids_created);
+ ctx.increment_ids_created();
id
}
+
+
+
+
+## Function `increment_ids_created`
+
+
+
+fun increment_ids_created(self: &mut tx_context::TxContext)
+
+
+
+
+
+Implementation
+
+
+fun increment_ids_created(self: &mut TxContext) {
+ if (NATIVE_CONTEXT) {
+ self.native_inc_ids_created()
+ } else {
+ self.ids_created = self.ids_created + 1
+ }
+}
+
+
+
+
@@ -223,7 +326,11 @@ Hidden for now, but may expose later
fun ids_created(self: &TxContext): u64 {
- self.ids_created
+ if (NATIVE_CONTEXT) {
+ self.native_ids_created()
+ } else {
+ self.ids_created
+ }
}
@@ -252,4 +359,158 @@ Native function for deriving an ID via hash(tx_hash || ids_created)
+
+
+
+
+## Function `native_sender`
+
+
+
+fun native_sender(self: &tx_context::TxContext): address
+
+
+
+
+
+Implementation
+
+
+native fun native_sender(self: &TxContext): address;
+
+
+
+
+
+
+
+
+## Function `native_digest`
+
+
+
+fun native_digest(self: &tx_context::TxContext): &vector<u8>
+
+
+
+
+
+Implementation
+
+
+native fun native_digest(self: &TxContext): &vector<u8>;
+
+
+
+
+
+
+
+
+## Function `native_epoch`
+
+
+
+fun native_epoch(self: &tx_context::TxContext): u64
+
+
+
+
+
+Implementation
+
+
+native fun native_epoch(self: &TxContext): u64;
+
+
+
+
+
+
+
+
+## Function `native_epoch_timestamp_ms`
+
+
+
+fun native_epoch_timestamp_ms(self: &tx_context::TxContext): u64
+
+
+
+
+
+Implementation
+
+
+native fun native_epoch_timestamp_ms(self: &TxContext): u64;
+
+
+
+
+
+
+
+
+## Function `native_sponsor`
+
+
+
+fun native_sponsor(self: &tx_context::TxContext): option::Option<address>
+
+
+
+
+
+Implementation
+
+
+native fun native_sponsor(self: &TxContext): Option<address>;
+
+
+
+
+
+
+
+
+## Function `native_ids_created`
+
+
+
+fun native_ids_created(self: &tx_context::TxContext): u64
+
+
+
+
+
+Implementation
+
+
+native fun native_ids_created(self: &TxContext): u64;
+
+
+
+
+
+
+
+
+## Function `native_inc_ids_created`
+
+
+
+fun native_inc_ids_created(self: &mut tx_context::TxContext)
+
+
+
+
+
+Implementation
+
+
+native fun native_inc_ids_created(self: &mut TxContext);
+
+
+
+
diff --git a/crates/sui-framework/packages_compiled/sui-framework b/crates/sui-framework/packages_compiled/sui-framework
index 343cb0eaea7cef905a76e8d4903ad910f624e0e8..308cf36622d1e2174132ac93bdf30a9c6c6b31d6 100644
GIT binary patch
delta 665
zcmZuvJBt)S5U#3z&Gutv=bSqb6fx4sM9hsZ(ZtkY*==-!omqAU6N60z!N9-`#Lyq$
zaUhrYGyDS@9vo(Zsnxr4vVjfNT~*)rRaZYQ-^ow!<@u@Ke9@n8T{#T^7D1A&IwDWab#&)Qi
zMPIW&8{#6gv!Qtv>qYY-_Jbdzxa#IFZypBq&@7oSTdwM5e>5Tobxy8R?fie``*^=y
z#C1Nh`c>EV-CB3M_H-W;X!hCdG(6h=d~;`m2qNR7?+2+;RhFbs!iaP&=nY8ipqzMA
z*1;4i&lf-}19Br~8JjSMJBSz(*D^QCXfG3om}hL0YKlE58Pt|*3S}Ii!F#-KpxuiV
z79NzwQ(CZcRA#&vl$u*fpG4;@Q=BMNurQUC=32XP;-HYnWH|WOR6aH(D}Of~CgZnH
U?{C>0n`aAbIa~4dTR8jk7u-5z4gdfE
delta 285
zcmXw!u}%Xq42JFBiSI7CqX!CzfdPq$2jBrJHsYG|HZbP-_K9(>(Onl+SMOkPQIfOQNskliJtlM<7zywH+&jCc(48B
zo9-QfY9bI-#6^w74!Lr9XE`mzo{6