From 8f82d05d29811e4829effffce13d9224a48fb6c0 Mon Sep 17 00:00:00 2001 From: Valerii Reutov Date: Wed, 13 Nov 2024 15:55:10 +0200 Subject: [PATCH] feat: improved system displays implementation --- crates/iota-core/src/authority.rs | 74 +++++ .../authority/authority_per_epoch_store.rs | 6 +- crates/iota-core/src/generate_format.rs | 5 +- .../iota-system/sources/iota_system.move | 45 +-- .../sources/iota_system_state_inner.move | 237 ++++++++++----- .../iota-system/sources/system_display.move | 100 +++++++ .../packages_compiled/iota-system | Bin 43700 -> 45355 bytes crates/iota-framework/published_api.txt | 33 ++- crates/iota-genesis-builder/src/lib.rs | 3 +- .../transaction_block_kind/end_of_epoch.rs | 1 + .../src/iota_transaction.rs | 38 ++- crates/iota-json-rpc/src/coin_api.rs | 3 - crates/iota-protocol-config/src/lib.rs | 35 ++- ...tocol_config__test__Mainnet_version_2.snap | 272 +++++++++++++++++ ...tocol_config__test__Testnet_version_2.snap | 272 +++++++++++++++++ ...iota_protocol_config__test__version_2.snap | 280 ++++++++++++++++++ .../iota-types/src/iota_sdk2_conversions.rs | 1 + .../iota_system_state_inner_v1.rs | 2 - .../iota_system_state_inner_v2.rs | 276 +++++++++++++++++ .../iota-types/src/iota_system_state/mod.rs | 47 ++- crates/iota-types/src/transaction.rs | 50 ++++ .../iota-adapter/src/execution_engine.rs | 72 ++++- 22 files changed, 1722 insertions(+), 130 deletions(-) create mode 100644 crates/iota-framework/packages/iota-system/sources/system_display.move create mode 100644 crates/iota-protocol-config/src/snapshots/iota_protocol_config__test__Mainnet_version_2.snap create mode 100644 crates/iota-protocol-config/src/snapshots/iota_protocol_config__test__Testnet_version_2.snap create mode 100644 crates/iota-protocol-config/src/snapshots/iota_protocol_config__test__version_2.snap create mode 100644 crates/iota-types/src/iota_system_state/iota_system_state_inner_v2.rs diff --git a/crates/iota-core/src/authority.rs b/crates/iota-core/src/authority.rs index ea62b573629..433966c099b 100644 --- a/crates/iota-core/src/authority.rs +++ b/crates/iota-core/src/authority.rs @@ -54,6 +54,7 @@ use iota_types::committee::CommitteeTrait; use iota_types::{ IOTA_SYSTEM_ADDRESS, TypeTag, authenticator_state::get_authenticator_state, + balance::Balance, base_types::*, committee::{Committee, EpochId, ProtocolVersion}, crypto::{AuthoritySignInfo, AuthoritySignature, RandomnessRound, Signer, default_hash}, @@ -71,6 +72,8 @@ use iota_types::{ execution_status::ExecutionStatus, fp_ensure, gas::{GasCostSummary, IotaGasStatus}, + gas_coin::GAS, + governance::StakedIota, inner_temporary_store::{ InnerTemporaryStore, ObjectMap, PackageStoreWithFallback, TemporaryModuleResolver, TxCoins, WrittenObjects, @@ -100,6 +103,7 @@ use iota_types::{ BackingPackageStore, BackingStore, ObjectKey, ObjectOrTombstone, ObjectStore, WriteKind, }, supported_protocol_versions::{ProtocolConfig, SupportedProtocolVersions}, + timelock::{timelock::TimeLock, timelocked_staked_iota::TimelockedStakedIota}, transaction::*, }; use itertools::Itertools; @@ -4490,6 +4494,73 @@ impl AuthorityState { Some(tx) } + #[instrument(level = "debug", skip_all)] + fn create_system_display_txs( + &self, + epoch_store: &Arc, + ) -> Option { + let txs = [ + self.create_staked_iota_display_tx_v1(epoch_store), + self.create_staked_timelocked_iota_display_tx_v1(epoch_store), + self.create_timelocked_iota_display_tx_v1(epoch_store), + ] + .iter() + .filter_map(|f| f.clone()) + .collect::>(); + + if txs.is_empty() { + return None; + } + + info!("Creating system display transactions"); + Some(EndOfEpochTransactionKind::system_display(txs)) + } + + #[instrument(level = "debug", skip_all)] + fn create_staked_iota_display_tx_v1( + &self, + epoch_store: &Arc, + ) -> Option { + let tag = StakedIota::type_(); + + if epoch_store.is_system_display_object_created(tag, 1) { + return None; + } + + info!("Creating `StakedIota` system display v1 transaction"); + Some(SystemDisplayTransactionKind::StakedIotaV1) + } + + #[instrument(level = "debug", skip_all)] + fn create_staked_timelocked_iota_display_tx_v1( + &self, + epoch_store: &Arc, + ) -> Option { + let tag = TimelockedStakedIota::type_(); + + if epoch_store.is_system_display_object_created(tag, 1) { + return None; + } + + info!("Creating `TimelockedStakedIota` system display v1 transaction"); + Some(SystemDisplayTransactionKind::TimelockedStakedIotaV1) + } + + #[instrument(level = "debug", skip_all)] + fn create_timelocked_iota_display_tx_v1( + &self, + epoch_store: &Arc, + ) -> Option { + let tag = TimeLock::::type_(Balance::type_(GAS::type_().into()).into()); + + if epoch_store.is_system_display_object_created(tag, 1) { + return None; + } + + info!("Creating `TimeLock>` system display v1 transaction"); + Some(SystemDisplayTransactionKind::TimelockedIotaV1) + } + /// Creates and execute the advance epoch transaction to effects without /// committing it to the database. The effects of the change epoch tx /// are only written to the database after a certified checkpoint has been @@ -4525,6 +4596,9 @@ impl AuthorityState { if let Some(tx) = self.init_bridge_committee_tx(epoch_store) { txns.push(tx); } + if let Some(tx) = self.create_system_display_txs(epoch_store) { + txns.push(tx); + } let next_epoch = epoch_store.epoch() + 1; diff --git a/crates/iota-core/src/authority/authority_per_epoch_store.rs b/crates/iota-core/src/authority/authority_per_epoch_store.rs index f5468bf9032..6aa963eb5c8 100644 --- a/crates/iota-core/src/authority/authority_per_epoch_store.rs +++ b/crates/iota-core/src/authority/authority_per_epoch_store.rs @@ -42,8 +42,8 @@ use iota_types::{ error::{IotaError, IotaResult}, executable_transaction::{TrustedExecutableTransaction, VerifiedExecutableTransaction}, iota_system_state::{ - display_object_key, epoch_start_iota_system_state::{EpochStartSystemState, EpochStartSystemStateTrait}, + system_display_object_key, }, message_envelope::TrustedEnvelope, messages_checkpoint::{ @@ -961,8 +961,8 @@ impl AuthorityPerEpochStore { self.epoch_start_configuration.bridge_committee_initiated() } - pub fn system_display_object_created(&self, ty: StructTag, version: u16) -> bool { - let key = display_object_key(ty); + pub fn is_system_display_object_created(&self, tag: StructTag, version: u16) -> bool { + let key = system_display_object_key(tag); let object_version = self .epoch_start_configuration diff --git a/crates/iota-core/src/generate_format.rs b/crates/iota-core/src/generate_format.rs index 1f0ff6e1ee5..07ce5e9057f 100644 --- a/crates/iota-core/src/generate_format.rs +++ b/crates/iota-core/src/generate_format.rs @@ -33,8 +33,8 @@ use iota_types::{ signature::GenericSignature, storage::DeleteKind, transaction::{ - Argument, CallArg, Command, EndOfEpochTransactionKind, ObjectArg, TransactionExpiration, - TransactionKind, + Argument, CallArg, Command, EndOfEpochTransactionKind, ObjectArg, + SystemDisplayTransactionKind, TransactionExpiration, TransactionKind, }, utils::DEFAULT_ADDRESS_SEED, }; @@ -172,6 +172,7 @@ fn get_registry() -> Result { tracer.trace_type::(&samples)?; tracer.trace_type::(&samples)?; tracer.trace_type::(&samples)?; + tracer.trace_type::(&samples)?; tracer.trace_type::(&samples)?; tracer.trace_type::(&samples)?; diff --git a/crates/iota-framework/packages/iota-system/sources/iota_system.move b/crates/iota-framework/packages/iota-system/sources/iota_system.move index 8c7103a94b6..b125488a991 100644 --- a/crates/iota-framework/packages/iota-system/sources/iota_system.move +++ b/crates/iota-framework/packages/iota-system/sources/iota_system.move @@ -51,7 +51,7 @@ module iota_system::iota_system { use iota::dynamic_field; use iota::vec_map::VecMap; - use iota_system::iota_system_state_inner::{Self, SystemParametersV1, IotaSystemStateV1}; + use iota_system::iota_system_state_inner::{Self, SystemParametersV1, IotaSystemStateV1, IotaSystemStateV2}; use iota_system::staking_pool::{PoolTokenExchangeRate, StakedIota}; use iota_system::validator::ValidatorV1; use iota_system::validator_cap::UnverifiedValidatorOperationCap; @@ -507,7 +507,7 @@ module iota_system::iota_system { self.load_system_state().iota_system_admin_cap() } - /// Create an empty `Display` object with `IotaSystemAdminCap`. + /// Create an empty system `Display` object with `IotaSystemAdminCap`. public(package) fun new_system_display( wrapper: &mut IotaSystemState, ctx: &mut TxContext, @@ -516,7 +516,7 @@ module iota_system::iota_system { self.new_system_display(ctx) } - /// Create a new `Display` object with a set of fields using `IotaSystemAdminCap`. + /// Create a new system `Display` object with a set of fields using `IotaSystemAdminCap`. public(package) fun new_system_display_with_fields( wrapper: &mut IotaSystemState, fields: vector, @@ -527,31 +527,31 @@ module iota_system::iota_system { self.new_system_display_with_fields(fields, values, ctx) } - /// Insert a display object. - public(package) fun insert_display_object( + /// Insert a system display object. + public(package) fun insert_system_display_object( wrapper: &mut IotaSystemState, display: Display, ) { let self = wrapper.load_system_state_mut(); - self.insert_display_object(display); + self.insert_system_display_object(display); } - /// Borrow an immutable display object. - public(package) fun borrow_display_object(wrapper: &mut IotaSystemState): &Display { + /// Borrow an immutable system display object. + public(package) fun borrow_system_display_object(wrapper: &mut IotaSystemState): &Display { let self = wrapper.load_system_state(); - self.borrow_display_object() + self.borrow_system_display_object() } - /// Borrow a mutable display object. - public(package) fun borrow_display_object_mut(wrapper: &mut IotaSystemState): &mut Display { + /// Borrow a mutable system display object. + public(package) fun borrow_system_display_object_mut(wrapper: &mut IotaSystemState): &mut Display { let self = wrapper.load_system_state_mut(); - self.borrow_display_object_mut() + self.borrow_system_display_object_mut() } - /// Returns true if the related display object exists. - public(package) fun contains_display_object(wrapper: &mut IotaSystemState): bool { + /// Returns true if the related system display object exists. + public(package) fun contains_system_display_object(wrapper: &mut IotaSystemState): bool { let self = wrapper.load_system_state(); - self.contains_display_object() + self.contains_system_display_object() } #[allow(unused_function)] @@ -597,16 +597,23 @@ module iota_system::iota_system { storage_rebate } - fun load_system_state(self: &mut IotaSystemState): &IotaSystemStateV1 { + fun load_system_state(self: &mut IotaSystemState): &IotaSystemStateV2 { load_inner_maybe_upgrade(self) } - fun load_system_state_mut(self: &mut IotaSystemState): &mut IotaSystemStateV1 { + fun load_system_state_mut(self: &mut IotaSystemState): &mut IotaSystemStateV2 { load_inner_maybe_upgrade(self) } - fun load_inner_maybe_upgrade(self: &mut IotaSystemState): &mut IotaSystemStateV1 { - let inner: &mut IotaSystemStateV1 = dynamic_field::borrow_mut( + fun load_inner_maybe_upgrade(self: &mut IotaSystemState): &mut IotaSystemStateV2 { + if (self.version == 1) { + let v1: IotaSystemStateV1 = dynamic_field::remove(&mut self.id, self.version); + let v2 = v1.v1_to_v2(); + self.version = 2; + dynamic_field::add(&mut self.id, self.version, v2); + }; + + let inner: &mut IotaSystemStateV2 = dynamic_field::borrow_mut( &mut self.id, self.version ); diff --git a/crates/iota-framework/packages/iota-system/sources/iota_system_state_inner.move b/crates/iota-framework/packages/iota-system/sources/iota_system_state_inner.move index f092e1ba699..68baf6c068d 100644 --- a/crates/iota-framework/packages/iota-system/sources/iota_system_state_inner.move +++ b/crates/iota-framework/packages/iota-system/sources/iota_system_state_inner.move @@ -108,6 +108,57 @@ module iota_system::iota_system_state_inner { /// Unix timestamp of the current epoch start epoch_start_timestamp_ms: u64, + /// Any extra fields that's not defined statically. + extra_fields: Bag, + } + + /// The top-level object containing all information of the Iota system. + public struct IotaSystemStateV2 has store { + /// The current epoch ID, starting from 0. + epoch: u64, + /// The current protocol version, starting from 1. + protocol_version: u64, + /// The current version of the system state data structure type. + /// This is always the same as IotaSystemState.version. Keeping a copy here so that + /// we know what version it is by inspecting IotaSystemStateV2 as well. + system_state_version: u64, + /// The IOTA's TreasuryCap. + iota_treasury_cap: IotaTreasuryCap, + /// Contains all information about the validators. + validators: ValidatorSetV1, + /// The storage fund. + storage_fund: StorageFundV1, + /// A list of system config parameters. + parameters: SystemParametersV1, + /// A capability allows to perform privileged IOTA system operations. + iota_system_admin_cap: IotaSystemAdminCap, + /// The reference gas price for the current epoch. + reference_gas_price: u64, + /// A map storing the records of validator reporting each other. + /// There is an entry in the map for each validator that has been reported + /// at least once. The entry VecSet contains all the validators that reported + /// them. If a validator has never been reported they don't have an entry in this map. + /// This map persists across epoch: a peer continues being in a reported state until the + /// reporter doesn't explicitly remove their report. + /// Note that in case we want to support validator address change in future, + /// the reports should be based on validator ids + validator_report_records: VecMap>, + + /// Whether the system is running in a downgraded safe mode due to a non-recoverable bug. + /// This is set whenever we failed to execute advance_epoch, and ended up executing advance_epoch_safe_mode. + /// It can be reset once we are able to successfully execute advance_epoch. + /// The rest of the fields starting with `safe_mode_` are accmulated during safe mode + /// when advance_epoch_safe_mode is executed. They will eventually be processed once we + /// are out of safe mode. + safe_mode: bool, + safe_mode_storage_charges: Balance, + safe_mode_computation_rewards: Balance, + safe_mode_storage_rebates: u64, + safe_mode_non_refundable_storage_fee: u64, + + /// Unix timestamp of the current epoch start + epoch_start_timestamp_ms: u64, + /// A map contains the system display object IDs stored in the extra fields. system_display_objects: VecMap, @@ -178,7 +229,6 @@ module iota_system::iota_system_state_inner { safe_mode_storage_rebates: 0, safe_mode_non_refundable_storage_fee: 0, epoch_start_timestamp_ms, - system_display_objects: vec_map::empty(), extra_fields: bag::new(ctx), }; system_state @@ -207,6 +257,49 @@ module iota_system::iota_system_state_inner { } } + public(package) fun v1_to_v2(self: IotaSystemStateV1): IotaSystemStateV2 { + let IotaSystemStateV1 { + epoch, + protocol_version, + system_state_version: _, + iota_treasury_cap, + validators, + storage_fund, + parameters, + iota_system_admin_cap, + reference_gas_price, + validator_report_records, + safe_mode, + safe_mode_storage_charges, + safe_mode_computation_rewards, + safe_mode_storage_rebates, + safe_mode_non_refundable_storage_fee, + epoch_start_timestamp_ms, + extra_fields, + } = self; + + IotaSystemStateV2 { + epoch, + protocol_version, + system_state_version: 2, + iota_treasury_cap, + validators, + storage_fund, + parameters, + iota_system_admin_cap, + reference_gas_price, + validator_report_records, + safe_mode, + safe_mode_storage_charges, + safe_mode_computation_rewards, + safe_mode_storage_rebates, + safe_mode_non_refundable_storage_fee, + epoch_start_timestamp_ms, + system_display_objects: vec_map::empty(), + extra_fields, + } + } + // ==== public(package) functions ==== /// Can be called by anyone who wishes to become a validator candidate and starts accuring delegated @@ -216,7 +309,7 @@ module iota_system::iota_system_state_inner { /// Note: `proof_of_possession` MUST be a valid signature using iota_address and authority_pubkey_bytes. /// To produce a valid PoP, run [fn test_proof_of_possession]. public(package) fun request_add_validator_candidate( - self: &mut IotaSystemStateV1, + self: &mut IotaSystemStateV2, authority_pubkey_bytes: vector, network_pubkey_bytes: vector, protocol_pubkey_bytes: vector, @@ -256,7 +349,7 @@ module iota_system::iota_system_state_inner { /// Called by a validator candidate to remove themselves from the candidacy. After this call /// their staking pool becomes deactivate. public(package) fun request_remove_validator_candidate( - self: &mut IotaSystemStateV1, + self: &mut IotaSystemStateV2, ctx: &mut TxContext, ) { self.validators.request_remove_validator_candidate(ctx); @@ -267,7 +360,7 @@ module iota_system::iota_system_state_inner { /// stake the validator has doesn't meet the min threshold, or if the number of new validators for the next /// epoch has already reached the maximum. public(package) fun request_add_validator( - self: &mut IotaSystemStateV1, + self: &mut IotaSystemStateV2, ctx: &TxContext, ) { assert!( @@ -284,7 +377,7 @@ module iota_system::iota_system_state_inner { /// At the end of the epoch, the `validator` object will be returned to the iota_address /// of the validator. public(package) fun request_remove_validator( - self: &mut IotaSystemStateV1, + self: &mut IotaSystemStateV2, ctx: &TxContext, ) { // Only check min validator condition if the current number of validators satisfy the constraint. @@ -303,7 +396,7 @@ module iota_system::iota_system_state_inner { /// A validator can call this function to submit a new gas price quote, to be /// used for the reference gas price calculation at the end of the epoch. public(package) fun request_set_gas_price( - self: &mut IotaSystemStateV1, + self: &mut IotaSystemStateV2, cap: &UnverifiedValidatorOperationCap, new_gas_price: u64, ) { @@ -316,7 +409,7 @@ module iota_system::iota_system_state_inner { /// This function is used to set new gas price for candidate validators public(package) fun set_candidate_validator_gas_price( - self: &mut IotaSystemStateV1, + self: &mut IotaSystemStateV2, cap: &UnverifiedValidatorOperationCap, new_gas_price: u64, ) { @@ -329,7 +422,7 @@ module iota_system::iota_system_state_inner { /// A validator can call this function to set a new commission rate, updated at the end of /// the epoch. public(package) fun request_set_commission_rate( - self: &mut IotaSystemStateV1, + self: &mut IotaSystemStateV2, new_commission_rate: u64, ctx: &TxContext, ) { @@ -341,7 +434,7 @@ module iota_system::iota_system_state_inner { /// This function is used to set new commission rate for candidate validators public(package) fun set_candidate_validator_commission_rate( - self: &mut IotaSystemStateV1, + self: &mut IotaSystemStateV2, new_commission_rate: u64, ctx: &TxContext, ) { @@ -351,7 +444,7 @@ module iota_system::iota_system_state_inner { /// Add stake to a validator's staking pool. public(package) fun request_add_stake( - self: &mut IotaSystemStateV1, + self: &mut IotaSystemStateV2, stake: Coin, validator_address: address, ctx: &mut TxContext, @@ -365,7 +458,7 @@ module iota_system::iota_system_state_inner { /// Add stake to a validator's staking pool using multiple coins. public(package) fun request_add_stake_mul_coin( - self: &mut IotaSystemStateV1, + self: &mut IotaSystemStateV2, stakes: vector>, stake_amount: option::Option, validator_address: address, @@ -377,7 +470,7 @@ module iota_system::iota_system_state_inner { /// Withdraw some portion of a stake from a validator's staking pool. public(package) fun request_withdraw_stake( - self: &mut IotaSystemStateV1, + self: &mut IotaSystemStateV2, staked_iota: StakedIota, ctx: &TxContext, ) : Balance { @@ -391,7 +484,7 @@ module iota_system::iota_system_state_inner { /// 3. the cap object is still valid. /// This function is idempotent. public(package) fun report_validator( - self: &mut IotaSystemStateV1, + self: &mut IotaSystemStateV2, cap: &UnverifiedValidatorOperationCap, reportee_addr: address, ) { @@ -408,7 +501,7 @@ module iota_system::iota_system_state_inner { /// 2. the sender has not previously reported the `reportee_addr`, or /// 3. the cap is not valid public(package) fun undo_report_validator( - self: &mut IotaSystemStateV1, + self: &mut IotaSystemStateV2, cap: &UnverifiedValidatorOperationCap, reportee_addr: address, ) { @@ -450,17 +543,17 @@ module iota_system::iota_system_state_inner { } } - /// Create an empty `Display` object with `IotaSystemAdminCap`. + /// Create an empty system `Display` object with `IotaSystemAdminCap`. public(package) fun new_system_display( - self: &IotaSystemStateV1, + self: &IotaSystemStateV2, ctx: &mut TxContext, ): Display { display::system_new(&self.iota_system_admin_cap, ctx) } - /// Create a new `Display` object with a set of fields using `IotaSystemAdminCap`. + /// Create a new system `Display` object with a set of fields using `IotaSystemAdminCap`. public(package) fun new_system_display_with_fields( - self: &IotaSystemStateV1, + self: &IotaSystemStateV2, fields: vector, values: vector, ctx: &mut TxContext, @@ -468,13 +561,13 @@ module iota_system::iota_system_state_inner { display::system_new_with_fields(&self.iota_system_admin_cap, fields, values, ctx) } - /// Insert a display object. - public(package) fun insert_display_object( - self: &mut IotaSystemStateV1, + /// Insert a system display object. + public(package) fun insert_system_display_object( + self: &mut IotaSystemStateV2, display: Display, ) { // Get a display object unique key. - let key = display_object_key(); + let key = system_display_object_key(); let display_id = *display.id(); // Store the display object. @@ -482,10 +575,10 @@ module iota_system::iota_system_state_inner { self.extra_fields.add(display_id, display); } - /// Borrow an immutable display object. - public(package) fun borrow_display_object(self: &IotaSystemStateV1): &Display { + /// Borrow an immutable system display object. + public(package) fun borrow_system_display_object(self: &IotaSystemStateV2): &Display { // Get a display object unique key. - let key = display_object_key(); + let key = system_display_object_key(); // Get the id. let display_id = *self.system_display_objects.get(&key); @@ -494,10 +587,10 @@ module iota_system::iota_system_state_inner { self.extra_fields.borrow(display_id) } - /// Borrow a mutable display object. - public(package) fun borrow_display_object_mut(self: &mut IotaSystemStateV1): &mut Display { + /// Borrow a mutable system display object. + public(package) fun borrow_system_display_object_mut(self: &mut IotaSystemStateV2): &mut Display { // Get a display object unique key. - let key = display_object_key(); + let key = system_display_object_key(); // Get the id. let display_id = *self.system_display_objects.get(&key); @@ -506,10 +599,10 @@ module iota_system::iota_system_state_inner { self.extra_fields.borrow_mut(display_id) } - /// Returns true if the related display object exists. - public(package) fun contains_display_object(self: &IotaSystemStateV1): bool { + /// Returns true if the related system display object exists. + public(package) fun contains_system_display_object(self: &IotaSystemStateV2): bool { // Get a display object unique key. - let key = display_object_key(); + let key = system_display_object_key(); // Check if the related display object exists. self.system_display_objects.contains(&key) @@ -517,7 +610,7 @@ module iota_system::iota_system_state_inner { /// Return a fully qualified type name with the original package IDs /// that is used as a display object key. - fun display_object_key(): String { + fun system_display_object_key(): String { string::from_ascii(std::type_name::get_with_original_ids().into_string()) } @@ -526,7 +619,7 @@ module iota_system::iota_system_state_inner { /// Create a new `UnverifiedValidatorOperationCap`, transfer it to the /// validator and registers it. The original object is thus revoked. public(package) fun rotate_operation_cap( - self: &mut IotaSystemStateV1, + self: &mut IotaSystemStateV2, ctx: &mut TxContext, ) { let validator = self.validators.get_validator_mut_with_ctx_including_candidates(ctx); @@ -535,7 +628,7 @@ module iota_system::iota_system_state_inner { /// Update a validator's name. public(package) fun update_validator_name( - self: &mut IotaSystemStateV1, + self: &mut IotaSystemStateV2, name: vector, ctx: &TxContext, ) { @@ -546,7 +639,7 @@ module iota_system::iota_system_state_inner { /// Update a validator's description public(package) fun update_validator_description( - self: &mut IotaSystemStateV1, + self: &mut IotaSystemStateV2, description: vector, ctx: &TxContext, ) { @@ -556,7 +649,7 @@ module iota_system::iota_system_state_inner { /// Update a validator's image url public(package) fun update_validator_image_url( - self: &mut IotaSystemStateV1, + self: &mut IotaSystemStateV2, image_url: vector, ctx: &TxContext, ) { @@ -566,7 +659,7 @@ module iota_system::iota_system_state_inner { /// Update a validator's project url public(package) fun update_validator_project_url( - self: &mut IotaSystemStateV1, + self: &mut IotaSystemStateV2, project_url: vector, ctx: &TxContext, ) { @@ -577,7 +670,7 @@ module iota_system::iota_system_state_inner { /// Update a validator's network address. /// The change will only take effects starting from the next epoch. public(package) fun update_validator_next_epoch_network_address( - self: &mut IotaSystemStateV1, + self: &mut IotaSystemStateV2, network_address: vector, ctx: &TxContext, ) { @@ -589,7 +682,7 @@ module iota_system::iota_system_state_inner { /// Update candidate validator's network address. public(package) fun update_candidate_validator_network_address( - self: &mut IotaSystemStateV1, + self: &mut IotaSystemStateV2, network_address: vector, ctx: &TxContext, ) { @@ -600,7 +693,7 @@ module iota_system::iota_system_state_inner { /// Update a validator's p2p address. /// The change will only take effects starting from the next epoch. public(package) fun update_validator_next_epoch_p2p_address( - self: &mut IotaSystemStateV1, + self: &mut IotaSystemStateV2, p2p_address: vector, ctx: &TxContext, ) { @@ -612,7 +705,7 @@ module iota_system::iota_system_state_inner { /// Update candidate validator's p2p address. public(package) fun update_candidate_validator_p2p_address( - self: &mut IotaSystemStateV1, + self: &mut IotaSystemStateV2, p2p_address: vector, ctx: &TxContext, ) { @@ -623,7 +716,7 @@ module iota_system::iota_system_state_inner { /// Update a validator's primary address. /// The change will only take effects starting from the next epoch. public(package) fun update_validator_next_epoch_primary_address( - self: &mut IotaSystemStateV1, + self: &mut IotaSystemStateV2, primary_address: vector, ctx: &TxContext, ) { @@ -633,7 +726,7 @@ module iota_system::iota_system_state_inner { /// Update candidate validator's primary address. public(package) fun update_candidate_validator_primary_address( - self: &mut IotaSystemStateV1, + self: &mut IotaSystemStateV2, primary_address: vector, ctx: &TxContext, ) { @@ -644,7 +737,7 @@ module iota_system::iota_system_state_inner { /// Update a validator's public key of authority key and proof of possession. /// The change will only take effects starting from the next epoch. public(package) fun update_validator_next_epoch_authority_pubkey( - self: &mut IotaSystemStateV1, + self: &mut IotaSystemStateV2, authority_pubkey: vector, proof_of_possession: vector, ctx: &TxContext, @@ -657,7 +750,7 @@ module iota_system::iota_system_state_inner { /// Update candidate validator's public key of authority key and proof of possession. public(package) fun update_candidate_validator_authority_pubkey( - self: &mut IotaSystemStateV1, + self: &mut IotaSystemStateV2, authority_pubkey: vector, proof_of_possession: vector, ctx: &TxContext, @@ -669,7 +762,7 @@ module iota_system::iota_system_state_inner { /// Update a validator's public key of protocol key. /// The change will only take effects starting from the next epoch. public(package) fun update_validator_next_epoch_protocol_pubkey( - self: &mut IotaSystemStateV1, + self: &mut IotaSystemStateV2, protocol_pubkey: vector, ctx: &TxContext, ) { @@ -681,7 +774,7 @@ module iota_system::iota_system_state_inner { /// Update candidate validator's public key of protocol key. public(package) fun update_candidate_validator_protocol_pubkey( - self: &mut IotaSystemStateV1, + self: &mut IotaSystemStateV2, protocol_pubkey: vector, ctx: &TxContext, ) { @@ -692,7 +785,7 @@ module iota_system::iota_system_state_inner { /// Update a validator's public key of network key. /// The change will only take effects starting from the next epoch. public(package) fun update_validator_next_epoch_network_pubkey( - self: &mut IotaSystemStateV1, + self: &mut IotaSystemStateV2, network_pubkey: vector, ctx: &TxContext, ) { @@ -704,7 +797,7 @@ module iota_system::iota_system_state_inner { /// Update candidate validator's public key of network key. public(package) fun update_candidate_validator_network_pubkey( - self: &mut IotaSystemStateV1, + self: &mut IotaSystemStateV2, network_pubkey: vector, ctx: &TxContext, ) { @@ -723,7 +816,7 @@ module iota_system::iota_system_state_inner { /// 5. Burn any leftover rewards. /// 6. Update all validators. public(package) fun advance_epoch( - self: &mut IotaSystemStateV1, + self: &mut IotaSystemStateV2, new_epoch: u64, next_protocol_version: u64, validator_target_reward: u64, @@ -852,19 +945,19 @@ module iota_system::iota_system_state_inner { /// Return the current epoch number. Useful for applications that need a coarse-grained concept of time, /// since epochs are ever-increasing and epoch changes are intended to happen every 24 hours. - public(package) fun epoch(self: &IotaSystemStateV1): u64 { + public(package) fun epoch(self: &IotaSystemStateV2): u64 { self.epoch } - public(package) fun protocol_version(self: &IotaSystemStateV1): u64 { + public(package) fun protocol_version(self: &IotaSystemStateV2): u64 { self.protocol_version } - public(package) fun system_state_version(self: &IotaSystemStateV1): u64 { + public(package) fun system_state_version(self: &IotaSystemStateV2): u64 { self.system_state_version } - public(package) fun iota_system_admin_cap(self: &IotaSystemStateV1): &IotaSystemAdminCap { + public(package) fun iota_system_admin_cap(self: &IotaSystemStateV2): &IotaSystemAdminCap { &self.iota_system_admin_cap } @@ -875,19 +968,19 @@ module iota_system::iota_system_state_inner { } /// Returns unix timestamp of the start of current epoch - public(package) fun epoch_start_timestamp_ms(self: &IotaSystemStateV1): u64 { + public(package) fun epoch_start_timestamp_ms(self: &IotaSystemStateV2): u64 { self.epoch_start_timestamp_ms } /// Returns the total amount staked with `validator_addr`. /// Aborts if `validator_addr` is not an active validator. - public(package) fun validator_stake_amount(self: &IotaSystemStateV1, validator_addr: address): u64 { + public(package) fun validator_stake_amount(self: &IotaSystemStateV2, validator_addr: address): u64 { self.validators.validator_total_stake_amount(validator_addr) } /// Returns the voting power for `validator_addr`. /// Aborts if `validator_addr` is not an active validator. - public(package) fun active_validator_voting_powers(self: &IotaSystemStateV1): VecMap { + public(package) fun active_validator_voting_powers(self: &IotaSystemStateV2): VecMap { let mut active_validators = active_validator_addresses(self); let mut voting_powers = vec_map::empty(); while (!vector::is_empty(&active_validators)) { @@ -900,24 +993,24 @@ module iota_system::iota_system_state_inner { /// Returns the staking pool id of a given validator. /// Aborts if `validator_addr` is not an active validator. - public(package) fun validator_staking_pool_id(self: &IotaSystemStateV1, validator_addr: address): ID { + public(package) fun validator_staking_pool_id(self: &IotaSystemStateV2, validator_addr: address): ID { self.validators.validator_staking_pool_id(validator_addr) } /// Returns reference to the staking pool mappings that map pool ids to active validator addresses - public(package) fun validator_staking_pool_mappings(self: &IotaSystemStateV1): &Table { + public(package) fun validator_staking_pool_mappings(self: &IotaSystemStateV2): &Table { self.validators.staking_pool_mappings() } /// Returns the total iota supply. - public(package) fun get_total_iota_supply(self: &IotaSystemStateV1): u64 { + public(package) fun get_total_iota_supply(self: &IotaSystemStateV2): u64 { self.iota_treasury_cap.total_supply() } /// Returns all the validators who are currently reporting `addr` - public(package) fun get_reporters_of(self: &IotaSystemStateV1, addr: address): VecSet
{ + public(package) fun get_reporters_of(self: &IotaSystemStateV2, addr: address): VecSet
{ if (self.validator_report_records.contains(&addr)) { self.validator_report_records[&addr] @@ -926,23 +1019,23 @@ module iota_system::iota_system_state_inner { } } - public(package) fun get_storage_fund_total_balance(self: &IotaSystemStateV1): u64 { + public(package) fun get_storage_fund_total_balance(self: &IotaSystemStateV2): u64 { self.storage_fund.total_balance() } - public(package) fun get_storage_fund_object_rebates(self: &IotaSystemStateV1): u64 { + public(package) fun get_storage_fund_object_rebates(self: &IotaSystemStateV2): u64 { self.storage_fund.total_object_storage_rebates() } public(package) fun pool_exchange_rates( - self: &mut IotaSystemStateV1, + self: &mut IotaSystemStateV2, pool_id: &ID ): &Table { let validators = &mut self.validators; validators.pool_exchange_rates(pool_id) } - public(package) fun active_validator_addresses(self: &IotaSystemStateV1): vector
{ + public(package) fun active_validator_addresses(self: &IotaSystemStateV2): vector
{ let validator_set = &self.validators; validator_set.active_validator_addresses() } @@ -972,36 +1065,36 @@ module iota_system::iota_system_state_inner { #[test_only] /// Return the current validator set - public(package) fun validators(self: &IotaSystemStateV1): &ValidatorSetV1 { + public(package) fun validators(self: &IotaSystemStateV2): &ValidatorSetV1 { &self.validators } #[test_only] /// Return the currently active validator by address - public(package) fun active_validator_by_address(self: &IotaSystemStateV1, validator_address: address): &ValidatorV1 { + public(package) fun active_validator_by_address(self: &IotaSystemStateV2, validator_address: address): &ValidatorV1 { self.validators().get_active_validator_ref(validator_address) } #[test_only] /// Return the currently pending validator by address - public(package) fun pending_validator_by_address(self: &IotaSystemStateV1, validator_address: address): &ValidatorV1 { + public(package) fun pending_validator_by_address(self: &IotaSystemStateV2, validator_address: address): &ValidatorV1 { self.validators().get_pending_validator_ref(validator_address) } #[test_only] /// Return the currently candidate validator by address - public(package) fun candidate_validator_by_address(self: &IotaSystemStateV1, validator_address: address): &ValidatorV1 { + public(package) fun candidate_validator_by_address(self: &IotaSystemStateV2, validator_address: address): &ValidatorV1 { validators(self).get_candidate_validator_ref(validator_address) } #[test_only] - public(package) fun set_epoch_for_testing(self: &mut IotaSystemStateV1, epoch_num: u64) { + public(package) fun set_epoch_for_testing(self: &mut IotaSystemStateV2, epoch_num: u64) { self.epoch = epoch_num } #[test_only] public(package) fun request_add_validator_for_testing( - self: &mut IotaSystemStateV1, + self: &mut IotaSystemStateV2, min_joining_stake_for_testing: u64, ctx: &TxContext, ) { @@ -1018,7 +1111,7 @@ module iota_system::iota_system_state_inner { // in the process. #[test_only] public(package) fun request_add_validator_candidate_for_testing( - self: &mut IotaSystemStateV1, + self: &mut IotaSystemStateV2, pubkey_bytes: vector, network_pubkey_bytes: vector, protocol_pubkey_bytes: vector, diff --git a/crates/iota-framework/packages/iota-system/sources/system_display.move b/crates/iota-framework/packages/iota-system/sources/system_display.move new file mode 100644 index 00000000000..96d00965a6d --- /dev/null +++ b/crates/iota-framework/packages/iota-system/sources/system_display.move @@ -0,0 +1,100 @@ +// Copyright (c) 2024 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +module iota_system::system_display { + + use std::string; + + use iota::balance::Balance; + use iota::iota::IOTA; + use iota::timelock::TimeLock; + + use iota_system::iota_system::IotaSystemState; + use iota_system::staking_pool::StakedIota; + use iota_system::timelocked_staking::TimelockedStakedIota; + + #[allow(unused_function)] + /// Create a `Display` object for the `StakedIota` type. + fun create_staked_iota_display_v1( + iota_system: &mut IotaSystemState, + ctx: &mut TxContext, + ) { + // A display object content. + let keys = vector[ + string::utf8(b"principal"), + string::utf8(b"stake_activation_epoch"), + ]; + + let values = vector[ + string::utf8(b"{principal}"), + string::utf8(b"{stake_activation_epoch}"), + ]; + + // Create a display object. + let mut display = iota_system.new_system_display_with_fields(keys, values, ctx); + + // Commit the display object to apply changes. + display.update_version(); + + // Store the display object. + iota_system.insert_system_display_object(display); + } + + #[allow(unused_function)] + /// Create a `Display` object for the `TimelockedStakedIota` type. + fun create_timelocked_staked_iota_display_v1( + iota_system: &mut IotaSystemState, + ctx: &mut TxContext, + ) { + // A display object content. + let keys = vector[ + string::utf8(b"principal"), + string::utf8(b"stake_activation_epoch"), + string::utf8(b"expiration_timestamp_ms"), + string::utf8(b"label"), + ]; + + let values = vector[ + string::utf8(b"{staked_iota.principal}"), + string::utf8(b"{staked_iota.stake_activation_epoch}"), + string::utf8(b"{expiration_timestamp_ms}"), + string::utf8(b"{label}"), + ]; + + // Create a display object. + let mut display = iota_system.new_system_display_with_fields(keys, values, ctx); + + // Commit the display object to apply changes. + display.update_version(); + + // Store the display object. + iota_system.insert_system_display_object(display); + } + + #[allow(unused_function)] + /// Create a `Display` object for the `TimeLock>` type. + fun create_timelocked_iota_display_v1( + iota_system: &mut IotaSystemState, + ctx: &mut TxContext, + ) { + // A display object content. + let keys = vector[ + string::utf8(b"locked"), + string::utf8(b"expiration_timestamp_ms"), + ]; + + let values = vector[ + string::utf8(b"{locked}"), + string::utf8(b"{expiration_timestamp_ms}"), + ]; + + // Create a display object. + let mut display = iota_system.new_system_display_with_fields>>(keys, values, ctx); + + // Commit the display object to apply changes. + display.update_version(); + + // Store the display object. + iota_system.insert_system_display_object(display); + } +} diff --git a/crates/iota-framework/packages_compiled/iota-system b/crates/iota-framework/packages_compiled/iota-system index 9441eaaaf92c1a30285eb1b25104b5416bc220e7..78c9afff440ea27a2ddb33f3eb58653f7dc37ecf 100644 GIT binary patch delta 7251 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 inner, - #[cfg(msim)] _ => { - // Types other than V1 used in simtests do not need to be validated. + // Types other than V1 and used in simtests do not need to be validated. return; } }; diff --git a/crates/iota-graphql-rpc/src/types/transaction_block_kind/end_of_epoch.rs b/crates/iota-graphql-rpc/src/types/transaction_block_kind/end_of_epoch.rs index 45df35c47bd..89fe92df60f 100644 --- a/crates/iota-graphql-rpc/src/types/transaction_block_kind/end_of_epoch.rs +++ b/crates/iota-graphql-rpc/src/types/transaction_block_kind/end_of_epoch.rs @@ -287,6 +287,7 @@ impl EndOfEpochTransactionKind { checkpoint_viewed_at, }) } + N::SystemDisplay(_) => todo!(), } } } diff --git a/crates/iota-json-rpc-types/src/iota_transaction.rs b/crates/iota-json-rpc-types/src/iota_transaction.rs index 23e4cdfc8c0..42b1da949ec 100644 --- a/crates/iota-json-rpc-types/src/iota_transaction.rs +++ b/crates/iota-json-rpc-types/src/iota_transaction.rs @@ -37,7 +37,8 @@ use iota_types::{ transaction::{ Argument, CallArg, ChangeEpoch, Command, EndOfEpochTransactionKind, GenesisObject, InputObjectKind, ObjectArg, ProgrammableMoveCall, ProgrammableTransaction, - SenderSignedData, TransactionData, TransactionDataAPI, TransactionKind, + SenderSignedData, SystemDisplayTransactionKind, TransactionData, TransactionDataAPI, + TransactionKind, }, }; use move_binary_format::CompiledModule; @@ -528,6 +529,11 @@ impl IotaTransactionBlockKind { ) => IotaEndOfEpochTransactionKind::BridgeCommitteeUpdate( bridge_shared_version, ), + EndOfEpochTransactionKind::SystemDisplay(vec) => { + IotaEndOfEpochTransactionKind::SystemDisplay( + vec.into_iter().map(|t| t.into()).collect(), + ) + } }) .collect(), }) @@ -612,6 +618,11 @@ impl IotaTransactionBlockKind { EndOfEpochTransactionKind::BridgeCommitteeInit(seq) => { IotaEndOfEpochTransactionKind::BridgeCommitteeUpdate(seq) } + EndOfEpochTransactionKind::SystemDisplay(vec) => { + IotaEndOfEpochTransactionKind::SystemDisplay( + vec.into_iter().map(|t| t.into()).collect(), + ) + } }) .collect(), }) @@ -1607,6 +1618,30 @@ pub struct IotaEndOfEpochTransaction { pub transactions: Vec, } +#[serde_as] +#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, PartialEq, Eq)] +pub enum IotaSystemDisplayTransactionKind { + StakedIotaV1, + TimelockedStakedIotaV1, + TimelockedIotaV1, +} + +impl From for IotaSystemDisplayTransactionKind { + fn from(input: SystemDisplayTransactionKind) -> Self { + match input { + SystemDisplayTransactionKind::StakedIotaV1 => { + IotaSystemDisplayTransactionKind::StakedIotaV1 + } + SystemDisplayTransactionKind::TimelockedStakedIotaV1 => { + IotaSystemDisplayTransactionKind::TimelockedStakedIotaV1 + } + SystemDisplayTransactionKind::TimelockedIotaV1 => { + IotaSystemDisplayTransactionKind::TimelockedIotaV1 + } + } + } +} + #[serde_as] #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, PartialEq, Eq)] pub enum IotaEndOfEpochTransactionKind { @@ -1615,6 +1650,7 @@ pub enum IotaEndOfEpochTransactionKind { AuthenticatorStateExpire(IotaAuthenticatorStateExpire), BridgeStateCreate(CheckpointDigest), BridgeCommitteeUpdate(SequenceNumber), + SystemDisplay(Vec), } #[serde_as] diff --git a/crates/iota-json-rpc/src/coin_api.rs b/crates/iota-json-rpc/src/coin_api.rs index f201f714a98..90d9a114c45 100644 --- a/crates/iota-json-rpc/src/coin_api.rs +++ b/crates/iota-json-rpc/src/coin_api.rs @@ -1438,9 +1438,6 @@ mod tests { safe_mode_storage_rebates: Default::default(), safe_mode_non_refundable_storage_fee: Default::default(), epoch_start_timestamp_ms: Default::default(), - system_display_objects: VecMap { - contents: Default::default(), - }, extra_fields: Default::default(), } } diff --git a/crates/iota-protocol-config/src/lib.rs b/crates/iota-protocol-config/src/lib.rs index 3ca28d34e66..e5b4a9b70b0 100644 --- a/crates/iota-protocol-config/src/lib.rs +++ b/crates/iota-protocol-config/src/lib.rs @@ -16,7 +16,7 @@ use tracing::{info, warn}; /// The minimum and maximum protocol versions supported by this build. const MIN_PROTOCOL_VERSION: u64 = 1; -pub const MAX_PROTOCOL_VERSION: u64 = 1; +pub const MAX_PROTOCOL_VERSION: u64 = 2; // Record history of protocol version allocations here: // @@ -180,6 +180,18 @@ struct FeatureFlags { // This flag is used to provide the correct MoveVM configuration for clients. #[serde(skip_serializing_if = "is_true")] rethrow_serialization_type_layout_errors: bool, + + // Enable the `StakedIota` display object V1. + #[serde(skip_serializing_if = "is_false")] + enable_staked_iota_display_v1: bool, + + // Enable the `TimelockedStakedIota` display object V1. + #[serde(skip_serializing_if = "is_false")] + enable_timelocked_staked_iota_display_v1: bool, + + // Enable the `Timelock>` display object V1. + #[serde(skip_serializing_if = "is_false")] + enable_timelocked_iota_display_v1: bool, } fn is_true(b: &bool) -> bool { @@ -1050,6 +1062,18 @@ impl ProtocolConfig { pub fn rethrow_serialization_type_layout_errors(&self) -> bool { self.feature_flags.rethrow_serialization_type_layout_errors } + + pub fn enable_staked_iota_display_v1(&self) -> bool { + self.feature_flags.enable_staked_iota_display_v1 + } + + pub fn enable_timelocked_staked_iota_display_v1(&self) -> bool { + self.feature_flags.enable_timelocked_staked_iota_display_v1 + } + + pub fn enable_timelocked_iota_display_v1(&self) -> bool { + self.feature_flags.enable_timelocked_iota_display_v1 + } } #[cfg(not(msim))] @@ -1630,13 +1654,16 @@ impl ProtocolConfig { } // Ignore this check for the fake versions for - // `test_choose_next_system_packages`. TODO: remove the never_loop - // attribute when the version 2 is added. - #[allow(clippy::never_loop)] + // `test_choose_next_system_packages`. #[cfg(not(msim))] for cur in 2..=version.0 { match cur { 1 => unreachable!(), + 2 => { + cfg.feature_flags.enable_staked_iota_display_v1 = true; + cfg.feature_flags.enable_timelocked_staked_iota_display_v1 = true; + cfg.feature_flags.enable_timelocked_iota_display_v1 = true; + } // Use this template when making changes: // diff --git a/crates/iota-protocol-config/src/snapshots/iota_protocol_config__test__Mainnet_version_2.snap b/crates/iota-protocol-config/src/snapshots/iota_protocol_config__test__Mainnet_version_2.snap new file mode 100644 index 00000000000..4f800ce47dd --- /dev/null +++ b/crates/iota-protocol-config/src/snapshots/iota_protocol_config__test__Mainnet_version_2.snap @@ -0,0 +1,272 @@ +--- +source: crates/iota-protocol-config/src/lib.rs +expression: "ProtocolConfig::get_for_version(cur, *chain_id)" +--- +version: 2 +feature_flags: + consensus_transaction_ordering: ByGasPrice + per_object_congestion_control_mode: TotalTxCount + zklogin_max_epoch_upper_bound_delta: 30 + enable_staked_iota_display_v1: true + enable_timelocked_staked_iota_display_v1: true + enable_timelocked_iota_display_v1: true +max_tx_size_bytes: 131072 +max_input_objects: 2048 +max_size_written_objects: 5000000 +max_size_written_objects_system_tx: 50000000 +max_serialized_tx_effects_size_bytes: 524288 +max_serialized_tx_effects_size_bytes_system_tx: 8388608 +max_gas_payment_objects: 256 +max_modules_in_publish: 64 +max_package_dependencies: 32 +max_arguments: 512 +max_type_arguments: 16 +max_type_argument_depth: 16 +max_pure_argument_size: 16384 +max_programmable_tx_commands: 1024 +move_binary_format_version: 7 +min_move_binary_format_version: 6 +binary_module_handles: 100 +binary_struct_handles: 300 +binary_function_handles: 1500 +binary_function_instantiations: 750 +binary_signatures: 1000 +binary_constant_pool: 4000 +binary_identifiers: 10000 +binary_address_identifiers: 100 +binary_struct_defs: 200 +binary_struct_def_instantiations: 100 +binary_function_defs: 1000 +binary_field_handles: 500 +binary_field_instantiations: 250 +binary_friend_decls: 100 +max_move_object_size: 256000 +max_move_package_size: 102400 +max_publish_or_upgrade_per_ptb: 5 +max_tx_gas: 50000000000 +max_gas_price: 100000 +max_gas_computation_bucket: 5000000 +gas_rounding_step: 1000 +max_loop_depth: 5 +max_generic_instantiation_length: 32 +max_function_parameters: 128 +max_basic_blocks: 1024 +max_value_stack_size: 1024 +max_type_nodes: 256 +max_push_size: 10000 +max_struct_definitions: 200 +max_function_definitions: 1000 +max_fields_in_struct: 32 +max_dependency_depth: 100 +max_num_event_emit: 1024 +max_num_new_move_object_ids: 2048 +max_num_new_move_object_ids_system_tx: 32768 +max_num_deleted_move_object_ids: 2048 +max_num_deleted_move_object_ids_system_tx: 32768 +max_num_transferred_move_object_ids: 2048 +max_num_transferred_move_object_ids_system_tx: 32768 +max_event_emit_size: 256000 +max_event_emit_size_total: 65536000 +max_move_vector_len: 262144 +max_move_identifier_len: 128 +max_move_value_depth: 128 +max_back_edges_per_function: 10000 +max_back_edges_per_module: 10000 +max_verifier_meter_ticks_per_function: 16000000 +max_meter_ticks_per_module: 16000000 +max_meter_ticks_per_package: 16000000 +object_runtime_max_num_cached_objects: 1000 +object_runtime_max_num_cached_objects_system_tx: 16000 +object_runtime_max_num_store_entries: 1000 +object_runtime_max_num_store_entries_system_tx: 16000 +base_tx_cost_fixed: 1000 +package_publish_cost_fixed: 1000 +base_tx_cost_per_byte: 0 +package_publish_cost_per_byte: 80 +obj_access_cost_read_per_byte: 15 +obj_access_cost_mutate_per_byte: 40 +obj_access_cost_delete_per_byte: 40 +obj_access_cost_verify_per_byte: 200 +gas_model_version: 1 +obj_data_cost_refundable: 100 +obj_metadata_cost_non_refundable: 50 +storage_rebate_rate: 10000 +reward_slashing_rate: 10000 +storage_gas_price: 76 +validator_target_reward: 767000000000000 +max_transactions_per_checkpoint: 10000 +max_checkpoint_size_bytes: 31457280 +buffer_stake_for_protocol_upgrade_bps: 5000 +address_from_bytes_cost_base: 52 +address_to_u256_cost_base: 52 +address_from_u256_cost_base: 52 +config_read_setting_impl_cost_base: 100 +config_read_setting_impl_cost_per_byte: 40 +dynamic_field_hash_type_and_key_cost_base: 100 +dynamic_field_hash_type_and_key_type_cost_per_byte: 2 +dynamic_field_hash_type_and_key_value_cost_per_byte: 2 +dynamic_field_hash_type_and_key_type_tag_cost_per_byte: 2 +dynamic_field_add_child_object_cost_base: 100 +dynamic_field_add_child_object_type_cost_per_byte: 10 +dynamic_field_add_child_object_value_cost_per_byte: 10 +dynamic_field_add_child_object_struct_tag_cost_per_byte: 10 +dynamic_field_borrow_child_object_cost_base: 100 +dynamic_field_borrow_child_object_child_ref_cost_per_byte: 10 +dynamic_field_borrow_child_object_type_cost_per_byte: 10 +dynamic_field_remove_child_object_cost_base: 100 +dynamic_field_remove_child_object_child_cost_per_byte: 2 +dynamic_field_remove_child_object_type_cost_per_byte: 2 +dynamic_field_has_child_object_cost_base: 100 +dynamic_field_has_child_object_with_ty_cost_base: 100 +dynamic_field_has_child_object_with_ty_type_cost_per_byte: 2 +dynamic_field_has_child_object_with_ty_type_tag_cost_per_byte: 2 +event_emit_cost_base: 52 +event_emit_value_size_derivation_cost_per_byte: 2 +event_emit_tag_size_derivation_cost_per_byte: 5 +event_emit_output_cost_per_byte: 10 +object_borrow_uid_cost_base: 52 +object_delete_impl_cost_base: 52 +object_record_new_uid_cost_base: 52 +transfer_transfer_internal_cost_base: 52 +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 +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 +validator_validate_metadata_cost_base: 52 +validator_validate_metadata_data_cost_per_byte: 2 +crypto_invalid_arguments_cost: 100 +bls12381_bls12381_min_sig_verify_cost_base: 52 +bls12381_bls12381_min_sig_verify_msg_cost_per_byte: 2 +bls12381_bls12381_min_sig_verify_msg_cost_per_block: 2 +bls12381_bls12381_min_pk_verify_cost_base: 52 +bls12381_bls12381_min_pk_verify_msg_cost_per_byte: 2 +bls12381_bls12381_min_pk_verify_msg_cost_per_block: 2 +ecdsa_k1_ecrecover_keccak256_cost_base: 52 +ecdsa_k1_ecrecover_keccak256_msg_cost_per_byte: 2 +ecdsa_k1_ecrecover_keccak256_msg_cost_per_block: 2 +ecdsa_k1_ecrecover_sha256_cost_base: 52 +ecdsa_k1_ecrecover_sha256_msg_cost_per_byte: 2 +ecdsa_k1_ecrecover_sha256_msg_cost_per_block: 2 +ecdsa_k1_decompress_pubkey_cost_base: 52 +ecdsa_k1_secp256k1_verify_keccak256_cost_base: 52 +ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_byte: 2 +ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_block: 2 +ecdsa_k1_secp256k1_verify_sha256_cost_base: 52 +ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_byte: 2 +ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_block: 2 +ecdsa_r1_ecrecover_keccak256_cost_base: 52 +ecdsa_r1_ecrecover_keccak256_msg_cost_per_byte: 2 +ecdsa_r1_ecrecover_keccak256_msg_cost_per_block: 2 +ecdsa_r1_ecrecover_sha256_cost_base: 52 +ecdsa_r1_ecrecover_sha256_msg_cost_per_byte: 2 +ecdsa_r1_ecrecover_sha256_msg_cost_per_block: 2 +ecdsa_r1_secp256r1_verify_keccak256_cost_base: 52 +ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_byte: 2 +ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_block: 2 +ecdsa_r1_secp256r1_verify_sha256_cost_base: 52 +ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_byte: 2 +ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_block: 2 +ecvrf_ecvrf_verify_cost_base: 52 +ecvrf_ecvrf_verify_alpha_string_cost_per_byte: 2 +ecvrf_ecvrf_verify_alpha_string_cost_per_block: 2 +ed25519_ed25519_verify_cost_base: 52 +ed25519_ed25519_verify_msg_cost_per_byte: 2 +ed25519_ed25519_verify_msg_cost_per_block: 2 +groth16_prepare_verifying_key_bls12381_cost_base: 52 +groth16_prepare_verifying_key_bn254_cost_base: 52 +groth16_verify_groth16_proof_internal_bls12381_cost_base: 52 +groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input: 2 +groth16_verify_groth16_proof_internal_bn254_cost_base: 52 +groth16_verify_groth16_proof_internal_bn254_cost_per_public_input: 2 +groth16_verify_groth16_proof_internal_public_input_cost_per_byte: 2 +hash_blake2b256_cost_base: 52 +hash_blake2b256_data_cost_per_byte: 2 +hash_blake2b256_data_cost_per_block: 2 +hash_keccak256_cost_base: 52 +hash_keccak256_data_cost_per_byte: 2 +hash_keccak256_data_cost_per_block: 2 +group_ops_bls12381_decode_scalar_cost: 52 +group_ops_bls12381_decode_g1_cost: 52 +group_ops_bls12381_decode_g2_cost: 52 +group_ops_bls12381_decode_gt_cost: 52 +group_ops_bls12381_scalar_add_cost: 52 +group_ops_bls12381_g1_add_cost: 52 +group_ops_bls12381_g2_add_cost: 52 +group_ops_bls12381_gt_add_cost: 52 +group_ops_bls12381_scalar_sub_cost: 52 +group_ops_bls12381_g1_sub_cost: 52 +group_ops_bls12381_g2_sub_cost: 52 +group_ops_bls12381_gt_sub_cost: 52 +group_ops_bls12381_scalar_mul_cost: 52 +group_ops_bls12381_g1_mul_cost: 52 +group_ops_bls12381_g2_mul_cost: 52 +group_ops_bls12381_gt_mul_cost: 52 +group_ops_bls12381_scalar_div_cost: 52 +group_ops_bls12381_g1_div_cost: 52 +group_ops_bls12381_g2_div_cost: 52 +group_ops_bls12381_gt_div_cost: 52 +group_ops_bls12381_g1_hash_to_base_cost: 52 +group_ops_bls12381_g2_hash_to_base_cost: 52 +group_ops_bls12381_g1_hash_to_cost_per_byte: 2 +group_ops_bls12381_g2_hash_to_cost_per_byte: 2 +group_ops_bls12381_g1_msm_base_cost: 52 +group_ops_bls12381_g2_msm_base_cost: 52 +group_ops_bls12381_g1_msm_base_cost_per_input: 52 +group_ops_bls12381_g2_msm_base_cost_per_input: 52 +group_ops_bls12381_msm_max_len: 32 +group_ops_bls12381_pairing_cost: 52 +hmac_hmac_sha3_256_cost_base: 52 +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: 1 +consensus_bad_nodes_stake_threshold: 20 +max_jwk_votes_per_validator_per_epoch: 240 +max_age_of_jwk_in_epochs: 1 +random_beacon_reduction_allowed_delta: 800 +random_beacon_reduction_lower_bound: 1000 +random_beacon_dkg_timeout_round: 3000 +random_beacon_min_round_interval_ms: 500 +random_beacon_dkg_version: 1 +consensus_max_transaction_size_bytes: 262144 +consensus_max_transactions_in_block_bytes: 524288 +consensus_max_num_transactions_in_block: 512 +max_deferral_rounds_for_congestion_control: 10 +min_checkpoint_interval_ms: 200 +checkpoint_summary_version_specific_data: 1 +max_soft_bundle_size: 5 +bridge_should_try_to_finalize_committee: false +max_accumulated_txn_cost_per_object_in_mysticeti_commit: 10 diff --git a/crates/iota-protocol-config/src/snapshots/iota_protocol_config__test__Testnet_version_2.snap b/crates/iota-protocol-config/src/snapshots/iota_protocol_config__test__Testnet_version_2.snap new file mode 100644 index 00000000000..9446a6cdf19 --- /dev/null +++ b/crates/iota-protocol-config/src/snapshots/iota_protocol_config__test__Testnet_version_2.snap @@ -0,0 +1,272 @@ +--- +source: crates/iota-protocol-config/src/lib.rs +expression: "ProtocolConfig::get_for_version(cur, *chain_id)" +--- +version: 2 +feature_flags: + consensus_transaction_ordering: ByGasPrice + per_object_congestion_control_mode: TotalTxCount + zklogin_max_epoch_upper_bound_delta: 30 + enable_staked_iota_display_v1: true + enable_timelocked_staked_iota_display_v1: true + enable_timelocked_iota_display_v1: true +max_tx_size_bytes: 131072 +max_input_objects: 2048 +max_size_written_objects: 5000000 +max_size_written_objects_system_tx: 50000000 +max_serialized_tx_effects_size_bytes: 524288 +max_serialized_tx_effects_size_bytes_system_tx: 8388608 +max_gas_payment_objects: 256 +max_modules_in_publish: 64 +max_package_dependencies: 32 +max_arguments: 512 +max_type_arguments: 16 +max_type_argument_depth: 16 +max_pure_argument_size: 16384 +max_programmable_tx_commands: 1024 +move_binary_format_version: 7 +min_move_binary_format_version: 6 +binary_module_handles: 100 +binary_struct_handles: 300 +binary_function_handles: 1500 +binary_function_instantiations: 750 +binary_signatures: 1000 +binary_constant_pool: 4000 +binary_identifiers: 10000 +binary_address_identifiers: 100 +binary_struct_defs: 200 +binary_struct_def_instantiations: 100 +binary_function_defs: 1000 +binary_field_handles: 500 +binary_field_instantiations: 250 +binary_friend_decls: 100 +max_move_object_size: 256000 +max_move_package_size: 102400 +max_publish_or_upgrade_per_ptb: 5 +max_tx_gas: 50000000000 +max_gas_price: 100000 +max_gas_computation_bucket: 5000000 +gas_rounding_step: 1000 +max_loop_depth: 5 +max_generic_instantiation_length: 32 +max_function_parameters: 128 +max_basic_blocks: 1024 +max_value_stack_size: 1024 +max_type_nodes: 256 +max_push_size: 10000 +max_struct_definitions: 200 +max_function_definitions: 1000 +max_fields_in_struct: 32 +max_dependency_depth: 100 +max_num_event_emit: 1024 +max_num_new_move_object_ids: 2048 +max_num_new_move_object_ids_system_tx: 32768 +max_num_deleted_move_object_ids: 2048 +max_num_deleted_move_object_ids_system_tx: 32768 +max_num_transferred_move_object_ids: 2048 +max_num_transferred_move_object_ids_system_tx: 32768 +max_event_emit_size: 256000 +max_event_emit_size_total: 65536000 +max_move_vector_len: 262144 +max_move_identifier_len: 128 +max_move_value_depth: 128 +max_back_edges_per_function: 10000 +max_back_edges_per_module: 10000 +max_verifier_meter_ticks_per_function: 16000000 +max_meter_ticks_per_module: 16000000 +max_meter_ticks_per_package: 16000000 +object_runtime_max_num_cached_objects: 1000 +object_runtime_max_num_cached_objects_system_tx: 16000 +object_runtime_max_num_store_entries: 1000 +object_runtime_max_num_store_entries_system_tx: 16000 +base_tx_cost_fixed: 1000 +package_publish_cost_fixed: 1000 +base_tx_cost_per_byte: 0 +package_publish_cost_per_byte: 80 +obj_access_cost_read_per_byte: 15 +obj_access_cost_mutate_per_byte: 40 +obj_access_cost_delete_per_byte: 40 +obj_access_cost_verify_per_byte: 200 +gas_model_version: 1 +obj_data_cost_refundable: 100 +obj_metadata_cost_non_refundable: 50 +storage_rebate_rate: 10000 +reward_slashing_rate: 10000 +storage_gas_price: 76 +validator_target_reward: 767000000000000 +max_transactions_per_checkpoint: 10000 +max_checkpoint_size_bytes: 31457280 +buffer_stake_for_protocol_upgrade_bps: 5000 +address_from_bytes_cost_base: 52 +address_to_u256_cost_base: 52 +address_from_u256_cost_base: 52 +config_read_setting_impl_cost_base: 100 +config_read_setting_impl_cost_per_byte: 40 +dynamic_field_hash_type_and_key_cost_base: 100 +dynamic_field_hash_type_and_key_type_cost_per_byte: 2 +dynamic_field_hash_type_and_key_value_cost_per_byte: 2 +dynamic_field_hash_type_and_key_type_tag_cost_per_byte: 2 +dynamic_field_add_child_object_cost_base: 100 +dynamic_field_add_child_object_type_cost_per_byte: 10 +dynamic_field_add_child_object_value_cost_per_byte: 10 +dynamic_field_add_child_object_struct_tag_cost_per_byte: 10 +dynamic_field_borrow_child_object_cost_base: 100 +dynamic_field_borrow_child_object_child_ref_cost_per_byte: 10 +dynamic_field_borrow_child_object_type_cost_per_byte: 10 +dynamic_field_remove_child_object_cost_base: 100 +dynamic_field_remove_child_object_child_cost_per_byte: 2 +dynamic_field_remove_child_object_type_cost_per_byte: 2 +dynamic_field_has_child_object_cost_base: 100 +dynamic_field_has_child_object_with_ty_cost_base: 100 +dynamic_field_has_child_object_with_ty_type_cost_per_byte: 2 +dynamic_field_has_child_object_with_ty_type_tag_cost_per_byte: 2 +event_emit_cost_base: 52 +event_emit_value_size_derivation_cost_per_byte: 2 +event_emit_tag_size_derivation_cost_per_byte: 5 +event_emit_output_cost_per_byte: 10 +object_borrow_uid_cost_base: 52 +object_delete_impl_cost_base: 52 +object_record_new_uid_cost_base: 52 +transfer_transfer_internal_cost_base: 52 +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 +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 +validator_validate_metadata_cost_base: 52 +validator_validate_metadata_data_cost_per_byte: 2 +crypto_invalid_arguments_cost: 100 +bls12381_bls12381_min_sig_verify_cost_base: 52 +bls12381_bls12381_min_sig_verify_msg_cost_per_byte: 2 +bls12381_bls12381_min_sig_verify_msg_cost_per_block: 2 +bls12381_bls12381_min_pk_verify_cost_base: 52 +bls12381_bls12381_min_pk_verify_msg_cost_per_byte: 2 +bls12381_bls12381_min_pk_verify_msg_cost_per_block: 2 +ecdsa_k1_ecrecover_keccak256_cost_base: 52 +ecdsa_k1_ecrecover_keccak256_msg_cost_per_byte: 2 +ecdsa_k1_ecrecover_keccak256_msg_cost_per_block: 2 +ecdsa_k1_ecrecover_sha256_cost_base: 52 +ecdsa_k1_ecrecover_sha256_msg_cost_per_byte: 2 +ecdsa_k1_ecrecover_sha256_msg_cost_per_block: 2 +ecdsa_k1_decompress_pubkey_cost_base: 52 +ecdsa_k1_secp256k1_verify_keccak256_cost_base: 52 +ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_byte: 2 +ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_block: 2 +ecdsa_k1_secp256k1_verify_sha256_cost_base: 52 +ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_byte: 2 +ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_block: 2 +ecdsa_r1_ecrecover_keccak256_cost_base: 52 +ecdsa_r1_ecrecover_keccak256_msg_cost_per_byte: 2 +ecdsa_r1_ecrecover_keccak256_msg_cost_per_block: 2 +ecdsa_r1_ecrecover_sha256_cost_base: 52 +ecdsa_r1_ecrecover_sha256_msg_cost_per_byte: 2 +ecdsa_r1_ecrecover_sha256_msg_cost_per_block: 2 +ecdsa_r1_secp256r1_verify_keccak256_cost_base: 52 +ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_byte: 2 +ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_block: 2 +ecdsa_r1_secp256r1_verify_sha256_cost_base: 52 +ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_byte: 2 +ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_block: 2 +ecvrf_ecvrf_verify_cost_base: 52 +ecvrf_ecvrf_verify_alpha_string_cost_per_byte: 2 +ecvrf_ecvrf_verify_alpha_string_cost_per_block: 2 +ed25519_ed25519_verify_cost_base: 52 +ed25519_ed25519_verify_msg_cost_per_byte: 2 +ed25519_ed25519_verify_msg_cost_per_block: 2 +groth16_prepare_verifying_key_bls12381_cost_base: 52 +groth16_prepare_verifying_key_bn254_cost_base: 52 +groth16_verify_groth16_proof_internal_bls12381_cost_base: 52 +groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input: 2 +groth16_verify_groth16_proof_internal_bn254_cost_base: 52 +groth16_verify_groth16_proof_internal_bn254_cost_per_public_input: 2 +groth16_verify_groth16_proof_internal_public_input_cost_per_byte: 2 +hash_blake2b256_cost_base: 52 +hash_blake2b256_data_cost_per_byte: 2 +hash_blake2b256_data_cost_per_block: 2 +hash_keccak256_cost_base: 52 +hash_keccak256_data_cost_per_byte: 2 +hash_keccak256_data_cost_per_block: 2 +group_ops_bls12381_decode_scalar_cost: 52 +group_ops_bls12381_decode_g1_cost: 52 +group_ops_bls12381_decode_g2_cost: 52 +group_ops_bls12381_decode_gt_cost: 52 +group_ops_bls12381_scalar_add_cost: 52 +group_ops_bls12381_g1_add_cost: 52 +group_ops_bls12381_g2_add_cost: 52 +group_ops_bls12381_gt_add_cost: 52 +group_ops_bls12381_scalar_sub_cost: 52 +group_ops_bls12381_g1_sub_cost: 52 +group_ops_bls12381_g2_sub_cost: 52 +group_ops_bls12381_gt_sub_cost: 52 +group_ops_bls12381_scalar_mul_cost: 52 +group_ops_bls12381_g1_mul_cost: 52 +group_ops_bls12381_g2_mul_cost: 52 +group_ops_bls12381_gt_mul_cost: 52 +group_ops_bls12381_scalar_div_cost: 52 +group_ops_bls12381_g1_div_cost: 52 +group_ops_bls12381_g2_div_cost: 52 +group_ops_bls12381_gt_div_cost: 52 +group_ops_bls12381_g1_hash_to_base_cost: 52 +group_ops_bls12381_g2_hash_to_base_cost: 52 +group_ops_bls12381_g1_hash_to_cost_per_byte: 2 +group_ops_bls12381_g2_hash_to_cost_per_byte: 2 +group_ops_bls12381_g1_msm_base_cost: 52 +group_ops_bls12381_g2_msm_base_cost: 52 +group_ops_bls12381_g1_msm_base_cost_per_input: 52 +group_ops_bls12381_g2_msm_base_cost_per_input: 52 +group_ops_bls12381_msm_max_len: 32 +group_ops_bls12381_pairing_cost: 52 +hmac_hmac_sha3_256_cost_base: 52 +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: 1 +consensus_bad_nodes_stake_threshold: 20 +max_jwk_votes_per_validator_per_epoch: 240 +max_age_of_jwk_in_epochs: 1 +random_beacon_reduction_allowed_delta: 800 +random_beacon_reduction_lower_bound: 1000 +random_beacon_dkg_timeout_round: 3000 +random_beacon_min_round_interval_ms: 500 +random_beacon_dkg_version: 1 +consensus_max_transaction_size_bytes: 262144 +consensus_max_transactions_in_block_bytes: 524288 +consensus_max_num_transactions_in_block: 512 +max_deferral_rounds_for_congestion_control: 10 +min_checkpoint_interval_ms: 200 +checkpoint_summary_version_specific_data: 1 +max_soft_bundle_size: 5 +bridge_should_try_to_finalize_committee: true +max_accumulated_txn_cost_per_object_in_mysticeti_commit: 10 diff --git a/crates/iota-protocol-config/src/snapshots/iota_protocol_config__test__version_2.snap b/crates/iota-protocol-config/src/snapshots/iota_protocol_config__test__version_2.snap new file mode 100644 index 00000000000..a9cb62bf643 --- /dev/null +++ b/crates/iota-protocol-config/src/snapshots/iota_protocol_config__test__version_2.snap @@ -0,0 +1,280 @@ +--- +source: crates/iota-protocol-config/src/lib.rs +expression: "ProtocolConfig::get_for_version(cur, *chain_id)" +--- +version: 2 +feature_flags: + consensus_transaction_ordering: ByGasPrice + enable_poseidon: true + enable_group_ops_native_function_msm: true + per_object_congestion_control_mode: TotalTxCount + zklogin_max_epoch_upper_bound_delta: 30 + enable_vdf: true + passkey_auth: true + enable_staked_iota_display_v1: true + enable_timelocked_staked_iota_display_v1: true + enable_timelocked_iota_display_v1: true +max_tx_size_bytes: 131072 +max_input_objects: 2048 +max_size_written_objects: 5000000 +max_size_written_objects_system_tx: 50000000 +max_serialized_tx_effects_size_bytes: 524288 +max_serialized_tx_effects_size_bytes_system_tx: 8388608 +max_gas_payment_objects: 256 +max_modules_in_publish: 64 +max_package_dependencies: 32 +max_arguments: 512 +max_type_arguments: 16 +max_type_argument_depth: 16 +max_pure_argument_size: 16384 +max_programmable_tx_commands: 1024 +move_binary_format_version: 7 +min_move_binary_format_version: 6 +binary_module_handles: 100 +binary_struct_handles: 300 +binary_function_handles: 1500 +binary_function_instantiations: 750 +binary_signatures: 1000 +binary_constant_pool: 4000 +binary_identifiers: 10000 +binary_address_identifiers: 100 +binary_struct_defs: 200 +binary_struct_def_instantiations: 100 +binary_function_defs: 1000 +binary_field_handles: 500 +binary_field_instantiations: 250 +binary_friend_decls: 100 +max_move_object_size: 256000 +max_move_package_size: 102400 +max_publish_or_upgrade_per_ptb: 5 +max_tx_gas: 50000000000 +max_gas_price: 100000 +max_gas_computation_bucket: 5000000 +gas_rounding_step: 1000 +max_loop_depth: 5 +max_generic_instantiation_length: 32 +max_function_parameters: 128 +max_basic_blocks: 1024 +max_value_stack_size: 1024 +max_type_nodes: 256 +max_push_size: 10000 +max_struct_definitions: 200 +max_function_definitions: 1000 +max_fields_in_struct: 32 +max_dependency_depth: 100 +max_num_event_emit: 1024 +max_num_new_move_object_ids: 2048 +max_num_new_move_object_ids_system_tx: 32768 +max_num_deleted_move_object_ids: 2048 +max_num_deleted_move_object_ids_system_tx: 32768 +max_num_transferred_move_object_ids: 2048 +max_num_transferred_move_object_ids_system_tx: 32768 +max_event_emit_size: 256000 +max_event_emit_size_total: 65536000 +max_move_vector_len: 262144 +max_move_identifier_len: 128 +max_move_value_depth: 128 +max_back_edges_per_function: 10000 +max_back_edges_per_module: 10000 +max_verifier_meter_ticks_per_function: 16000000 +max_meter_ticks_per_module: 16000000 +max_meter_ticks_per_package: 16000000 +object_runtime_max_num_cached_objects: 1000 +object_runtime_max_num_cached_objects_system_tx: 16000 +object_runtime_max_num_store_entries: 1000 +object_runtime_max_num_store_entries_system_tx: 16000 +base_tx_cost_fixed: 1000 +package_publish_cost_fixed: 1000 +base_tx_cost_per_byte: 0 +package_publish_cost_per_byte: 80 +obj_access_cost_read_per_byte: 15 +obj_access_cost_mutate_per_byte: 40 +obj_access_cost_delete_per_byte: 40 +obj_access_cost_verify_per_byte: 200 +gas_model_version: 1 +obj_data_cost_refundable: 100 +obj_metadata_cost_non_refundable: 50 +storage_rebate_rate: 10000 +reward_slashing_rate: 10000 +storage_gas_price: 76 +validator_target_reward: 767000000000000 +max_transactions_per_checkpoint: 10000 +max_checkpoint_size_bytes: 31457280 +buffer_stake_for_protocol_upgrade_bps: 5000 +address_from_bytes_cost_base: 52 +address_to_u256_cost_base: 52 +address_from_u256_cost_base: 52 +config_read_setting_impl_cost_base: 100 +config_read_setting_impl_cost_per_byte: 40 +dynamic_field_hash_type_and_key_cost_base: 100 +dynamic_field_hash_type_and_key_type_cost_per_byte: 2 +dynamic_field_hash_type_and_key_value_cost_per_byte: 2 +dynamic_field_hash_type_and_key_type_tag_cost_per_byte: 2 +dynamic_field_add_child_object_cost_base: 100 +dynamic_field_add_child_object_type_cost_per_byte: 10 +dynamic_field_add_child_object_value_cost_per_byte: 10 +dynamic_field_add_child_object_struct_tag_cost_per_byte: 10 +dynamic_field_borrow_child_object_cost_base: 100 +dynamic_field_borrow_child_object_child_ref_cost_per_byte: 10 +dynamic_field_borrow_child_object_type_cost_per_byte: 10 +dynamic_field_remove_child_object_cost_base: 100 +dynamic_field_remove_child_object_child_cost_per_byte: 2 +dynamic_field_remove_child_object_type_cost_per_byte: 2 +dynamic_field_has_child_object_cost_base: 100 +dynamic_field_has_child_object_with_ty_cost_base: 100 +dynamic_field_has_child_object_with_ty_type_cost_per_byte: 2 +dynamic_field_has_child_object_with_ty_type_tag_cost_per_byte: 2 +event_emit_cost_base: 52 +event_emit_value_size_derivation_cost_per_byte: 2 +event_emit_tag_size_derivation_cost_per_byte: 5 +event_emit_output_cost_per_byte: 10 +object_borrow_uid_cost_base: 52 +object_delete_impl_cost_base: 52 +object_record_new_uid_cost_base: 52 +transfer_transfer_internal_cost_base: 52 +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 +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 +validator_validate_metadata_cost_base: 52 +validator_validate_metadata_data_cost_per_byte: 2 +crypto_invalid_arguments_cost: 100 +bls12381_bls12381_min_sig_verify_cost_base: 52 +bls12381_bls12381_min_sig_verify_msg_cost_per_byte: 2 +bls12381_bls12381_min_sig_verify_msg_cost_per_block: 2 +bls12381_bls12381_min_pk_verify_cost_base: 52 +bls12381_bls12381_min_pk_verify_msg_cost_per_byte: 2 +bls12381_bls12381_min_pk_verify_msg_cost_per_block: 2 +ecdsa_k1_ecrecover_keccak256_cost_base: 52 +ecdsa_k1_ecrecover_keccak256_msg_cost_per_byte: 2 +ecdsa_k1_ecrecover_keccak256_msg_cost_per_block: 2 +ecdsa_k1_ecrecover_sha256_cost_base: 52 +ecdsa_k1_ecrecover_sha256_msg_cost_per_byte: 2 +ecdsa_k1_ecrecover_sha256_msg_cost_per_block: 2 +ecdsa_k1_decompress_pubkey_cost_base: 52 +ecdsa_k1_secp256k1_verify_keccak256_cost_base: 52 +ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_byte: 2 +ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_block: 2 +ecdsa_k1_secp256k1_verify_sha256_cost_base: 52 +ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_byte: 2 +ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_block: 2 +ecdsa_r1_ecrecover_keccak256_cost_base: 52 +ecdsa_r1_ecrecover_keccak256_msg_cost_per_byte: 2 +ecdsa_r1_ecrecover_keccak256_msg_cost_per_block: 2 +ecdsa_r1_ecrecover_sha256_cost_base: 52 +ecdsa_r1_ecrecover_sha256_msg_cost_per_byte: 2 +ecdsa_r1_ecrecover_sha256_msg_cost_per_block: 2 +ecdsa_r1_secp256r1_verify_keccak256_cost_base: 52 +ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_byte: 2 +ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_block: 2 +ecdsa_r1_secp256r1_verify_sha256_cost_base: 52 +ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_byte: 2 +ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_block: 2 +ecvrf_ecvrf_verify_cost_base: 52 +ecvrf_ecvrf_verify_alpha_string_cost_per_byte: 2 +ecvrf_ecvrf_verify_alpha_string_cost_per_block: 2 +ed25519_ed25519_verify_cost_base: 52 +ed25519_ed25519_verify_msg_cost_per_byte: 2 +ed25519_ed25519_verify_msg_cost_per_block: 2 +groth16_prepare_verifying_key_bls12381_cost_base: 52 +groth16_prepare_verifying_key_bn254_cost_base: 52 +groth16_verify_groth16_proof_internal_bls12381_cost_base: 52 +groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input: 2 +groth16_verify_groth16_proof_internal_bn254_cost_base: 52 +groth16_verify_groth16_proof_internal_bn254_cost_per_public_input: 2 +groth16_verify_groth16_proof_internal_public_input_cost_per_byte: 2 +hash_blake2b256_cost_base: 52 +hash_blake2b256_data_cost_per_byte: 2 +hash_blake2b256_data_cost_per_block: 2 +hash_keccak256_cost_base: 52 +hash_keccak256_data_cost_per_byte: 2 +hash_keccak256_data_cost_per_block: 2 +poseidon_bn254_cost_base: 260 +poseidon_bn254_cost_per_block: 10 +group_ops_bls12381_decode_scalar_cost: 52 +group_ops_bls12381_decode_g1_cost: 52 +group_ops_bls12381_decode_g2_cost: 52 +group_ops_bls12381_decode_gt_cost: 52 +group_ops_bls12381_scalar_add_cost: 52 +group_ops_bls12381_g1_add_cost: 52 +group_ops_bls12381_g2_add_cost: 52 +group_ops_bls12381_gt_add_cost: 52 +group_ops_bls12381_scalar_sub_cost: 52 +group_ops_bls12381_g1_sub_cost: 52 +group_ops_bls12381_g2_sub_cost: 52 +group_ops_bls12381_gt_sub_cost: 52 +group_ops_bls12381_scalar_mul_cost: 52 +group_ops_bls12381_g1_mul_cost: 52 +group_ops_bls12381_g2_mul_cost: 52 +group_ops_bls12381_gt_mul_cost: 52 +group_ops_bls12381_scalar_div_cost: 52 +group_ops_bls12381_g1_div_cost: 52 +group_ops_bls12381_g2_div_cost: 52 +group_ops_bls12381_gt_div_cost: 52 +group_ops_bls12381_g1_hash_to_base_cost: 52 +group_ops_bls12381_g2_hash_to_base_cost: 52 +group_ops_bls12381_g1_hash_to_cost_per_byte: 2 +group_ops_bls12381_g2_hash_to_cost_per_byte: 2 +group_ops_bls12381_g1_msm_base_cost: 52 +group_ops_bls12381_g2_msm_base_cost: 52 +group_ops_bls12381_g1_msm_base_cost_per_input: 52 +group_ops_bls12381_g2_msm_base_cost_per_input: 52 +group_ops_bls12381_msm_max_len: 32 +group_ops_bls12381_pairing_cost: 52 +hmac_hmac_sha3_256_cost_base: 52 +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 +vdf_verify_vdf_cost: 1500 +vdf_hash_to_input_cost: 100 +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: 1 +consensus_bad_nodes_stake_threshold: 20 +max_jwk_votes_per_validator_per_epoch: 240 +max_age_of_jwk_in_epochs: 1 +random_beacon_reduction_allowed_delta: 800 +random_beacon_reduction_lower_bound: 1000 +random_beacon_dkg_timeout_round: 3000 +random_beacon_min_round_interval_ms: 500 +random_beacon_dkg_version: 1 +consensus_max_transaction_size_bytes: 262144 +consensus_max_transactions_in_block_bytes: 524288 +consensus_max_num_transactions_in_block: 512 +max_deferral_rounds_for_congestion_control: 10 +min_checkpoint_interval_ms: 200 +checkpoint_summary_version_specific_data: 1 +max_soft_bundle_size: 5 +bridge_should_try_to_finalize_committee: true +max_accumulated_txn_cost_per_object_in_mysticeti_commit: 10 diff --git a/crates/iota-types/src/iota_sdk2_conversions.rs b/crates/iota-types/src/iota_sdk2_conversions.rs index 4ca1631cc76..36190a8feae 100644 --- a/crates/iota-types/src/iota_sdk2_conversions.rs +++ b/crates/iota-types/src/iota_sdk2_conversions.rs @@ -534,6 +534,7 @@ impl From for EndOfEpochTransacti bridge_object_version: sequence_number.value(), } } + crate::transaction::EndOfEpochTransactionKind::SystemDisplay(_) => todo!(), } } } diff --git a/crates/iota-types/src/iota_system_state/iota_system_state_inner_v1.rs b/crates/iota-types/src/iota_system_state/iota_system_state_inner_v1.rs index 5191be6c45e..f4797f3f4e2 100644 --- a/crates/iota-types/src/iota_system_state/iota_system_state_inner_v1.rs +++ b/crates/iota-types/src/iota_system_state/iota_system_state_inner_v1.rs @@ -454,7 +454,6 @@ pub struct IotaSystemStateV1 { pub safe_mode_storage_rebates: u64, pub safe_mode_non_refundable_storage_fee: u64, pub epoch_start_timestamp_ms: u64, - pub system_display_objects: VecMap, pub extra_fields: Bag, // TODO: Use getters instead of all pub. } @@ -632,7 +631,6 @@ impl IotaSystemStateTrait for IotaSystemStateV1 { safe_mode_storage_rebates, safe_mode_non_refundable_storage_fee, epoch_start_timestamp_ms, - system_display_objects: _, extra_fields: _, } = self; IotaSystemStateSummary { diff --git a/crates/iota-types/src/iota_system_state/iota_system_state_inner_v2.rs b/crates/iota-types/src/iota_system_state/iota_system_state_inner_v2.rs new file mode 100644 index 00000000000..e0b416645b8 --- /dev/null +++ b/crates/iota-types/src/iota_system_state/iota_system_state_inner_v2.rs @@ -0,0 +1,276 @@ +// Copyright (c) Mysten Labs, Inc. +// Modifications Copyright (c) 2024 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +use anyhow::Result; +use serde::{Deserialize, Serialize}; + +use super::{ + AdvanceEpochParams, IotaSystemStateTrait, + epoch_start_iota_system_state::EpochStartValidatorInfoV1, + get_validators_from_table_vec, + iota_system_state_inner_v1::{StorageFundV1, SystemParametersV1, ValidatorSetV1, ValidatorV1}, + iota_system_state_summary::{IotaSystemStateSummary, IotaValidatorSummary}, +}; +use crate::{ + balance::Balance, + base_types::IotaAddress, + collection_types::{Bag, Table, TableVec, VecMap, VecSet}, + committee::{CommitteeWithNetworkMetadata, NetworkMetadata}, + error::IotaError, + gas_coin::IotaTreasuryCap, + id::ID, + iota_system_state::epoch_start_iota_system_state::EpochStartSystemState, + storage::ObjectStore, + system_admin_cap::IotaSystemAdminCap, +}; + +/// Rust version of the Move iota_system::iota_system::IotaSystemStateV2 type +#[derive(Debug, Serialize, Deserialize, Clone, Eq, PartialEq)] +pub struct IotaSystemStateV2 { + pub epoch: u64, + pub protocol_version: u64, + pub system_state_version: u64, + pub iota_treasury_cap: IotaTreasuryCap, + pub validators: ValidatorSetV1, + pub storage_fund: StorageFundV1, + pub parameters: SystemParametersV1, + pub iota_system_admin_cap: IotaSystemAdminCap, + pub reference_gas_price: u64, + pub validator_report_records: VecMap>, + pub safe_mode: bool, + pub safe_mode_storage_charges: Balance, + pub safe_mode_computation_rewards: Balance, + pub safe_mode_storage_rebates: u64, + pub safe_mode_non_refundable_storage_fee: u64, + pub epoch_start_timestamp_ms: u64, + pub system_display_objects: VecMap, + pub extra_fields: Bag, + // TODO: Use getters instead of all pub. +} + +impl IotaSystemStateTrait for IotaSystemStateV2 { + fn epoch(&self) -> u64 { + self.epoch + } + + fn reference_gas_price(&self) -> u64 { + self.reference_gas_price + } + + fn protocol_version(&self) -> u64 { + self.protocol_version + } + + fn system_state_version(&self) -> u64 { + self.system_state_version + } + + fn epoch_start_timestamp_ms(&self) -> u64 { + self.epoch_start_timestamp_ms + } + + fn epoch_duration_ms(&self) -> u64 { + self.parameters.epoch_duration_ms + } + + fn safe_mode(&self) -> bool { + self.safe_mode + } + + fn advance_epoch_safe_mode(&mut self, params: &AdvanceEpochParams) { + self.epoch = params.epoch; + self.safe_mode = true; + self.safe_mode_storage_charges + .deposit_for_safe_mode(params.storage_charge); + self.safe_mode_storage_rebates += params.storage_rebate; + self.safe_mode_computation_rewards + .deposit_for_safe_mode(params.computation_charge); + self.safe_mode_non_refundable_storage_fee += params.non_refundable_storage_fee; + self.epoch_start_timestamp_ms = params.epoch_start_timestamp_ms; + self.protocol_version = params.next_protocol_version.as_u64(); + } + + fn get_current_epoch_committee(&self) -> CommitteeWithNetworkMetadata { + let validators = self + .validators + .active_validators + .iter() + .map(|validator| { + let verified_metadata = validator.verified_metadata(); + let name = verified_metadata.iota_pubkey_bytes(); + ( + name, + (validator.voting_power, NetworkMetadata { + network_address: verified_metadata.net_address.clone(), + primary_address: verified_metadata.primary_address.clone(), + }), + ) + }) + .collect(); + CommitteeWithNetworkMetadata::new(self.epoch, validators) + } + + fn get_pending_active_validators( + &self, + object_store: &S, + ) -> Result, IotaError> { + let table_id = self.validators.pending_active_validators.contents.id; + let table_size = self.validators.pending_active_validators.contents.size; + let validators: Vec = + get_validators_from_table_vec(&object_store, table_id, table_size)?; + Ok(validators + .into_iter() + .map(|v| v.into_iota_validator_summary()) + .collect()) + } + + fn into_epoch_start_state(self) -> EpochStartSystemState { + EpochStartSystemState::new_v1( + self.epoch, + self.protocol_version, + self.reference_gas_price, + self.safe_mode, + self.epoch_start_timestamp_ms, + self.parameters.epoch_duration_ms, + self.validators + .active_validators + .iter() + .map(|validator| { + let metadata = validator.verified_metadata(); + EpochStartValidatorInfoV1 { + iota_address: metadata.iota_address, + authority_pubkey: metadata.authority_pubkey.clone(), + network_pubkey: metadata.network_pubkey.clone(), + protocol_pubkey: metadata.protocol_pubkey.clone(), + iota_net_address: metadata.net_address.clone(), + p2p_address: metadata.p2p_address.clone(), + primary_address: metadata.primary_address.clone(), + voting_power: validator.voting_power, + hostname: metadata.name.clone(), + } + }) + .collect(), + ) + } + + fn into_iota_system_state_summary(self) -> IotaSystemStateSummary { + // If you are making any changes to IotaSystemStateV2 or any of its dependent + // types before mainnet, please also update IotaSystemStateSummary and + // its corresponding TS type. Post-mainnet, we will need to introduce a + // new version. + let Self { + epoch, + protocol_version, + system_state_version, + iota_treasury_cap, + validators: + ValidatorSetV1 { + total_stake, + active_validators, + pending_active_validators: + TableVec { + contents: + Table { + id: pending_active_validators_id, + size: pending_active_validators_size, + }, + }, + pending_removals, + staking_pool_mappings: + Table { + id: staking_pool_mappings_id, + size: staking_pool_mappings_size, + }, + inactive_validators: + Table { + id: inactive_pools_id, + size: inactive_pools_size, + }, + validator_candidates: + Table { + id: validator_candidates_id, + size: validator_candidates_size, + }, + at_risk_validators: + VecMap { + contents: at_risk_validators, + }, + extra_fields: _, + }, + storage_fund, + parameters: + SystemParametersV1 { + epoch_duration_ms, + min_validator_count, + max_validator_count, + min_validator_joining_stake, + validator_low_stake_threshold, + validator_very_low_stake_threshold, + validator_low_stake_grace_period, + extra_fields: _, + }, + iota_system_admin_cap: _, + reference_gas_price, + validator_report_records: + VecMap { + contents: validator_report_records, + }, + safe_mode, + safe_mode_storage_charges, + safe_mode_computation_rewards, + safe_mode_storage_rebates, + safe_mode_non_refundable_storage_fee, + epoch_start_timestamp_ms, + system_display_objects: _, + extra_fields: _, + } = self; + IotaSystemStateSummary { + epoch, + protocol_version, + system_state_version, + iota_total_supply: iota_treasury_cap.total_supply().value, + iota_treasury_cap_id: iota_treasury_cap.id().to_owned(), + storage_fund_total_object_storage_rebates: storage_fund + .total_object_storage_rebates + .value(), + storage_fund_non_refundable_balance: storage_fund.non_refundable_balance.value(), + reference_gas_price, + safe_mode, + safe_mode_storage_charges: safe_mode_storage_charges.value(), + safe_mode_computation_rewards: safe_mode_computation_rewards.value(), + safe_mode_storage_rebates, + safe_mode_non_refundable_storage_fee, + epoch_start_timestamp_ms, + epoch_duration_ms, + total_stake, + active_validators: active_validators + .into_iter() + .map(|v| v.into_iota_validator_summary()) + .collect(), + pending_active_validators_id, + pending_active_validators_size, + pending_removals, + staking_pool_mappings_id, + staking_pool_mappings_size, + inactive_pools_id, + inactive_pools_size, + validator_candidates_id, + validator_candidates_size, + at_risk_validators: at_risk_validators + .into_iter() + .map(|e| (e.key, e.value)) + .collect(), + validator_report_records: validator_report_records + .into_iter() + .map(|e| (e.key, e.value.contents)) + .collect(), + min_validator_count, + max_validator_count, + min_validator_joining_stake, + validator_low_stake_threshold, + validator_very_low_stake_threshold, + validator_low_stake_grace_period, + } + } +} diff --git a/crates/iota-types/src/iota_system_state/mod.rs b/crates/iota-types/src/iota_system_state/mod.rs index 89b0ac84888..f6e894ea44e 100644 --- a/crates/iota-types/src/iota_system_state/mod.rs +++ b/crates/iota-types/src/iota_system_state/mod.rs @@ -12,6 +12,7 @@ use serde::{Deserialize, Serialize, de::DeserializeOwned}; use self::{ iota_system_state_inner_v1::{IotaSystemStateV1, ValidatorV1}, + iota_system_state_inner_v2::IotaSystemStateV2, iota_system_state_summary::{IotaSystemStateSummary, IotaValidatorSummary}, }; use crate::{ @@ -30,6 +31,7 @@ use crate::{ pub mod epoch_start_iota_system_state; pub mod iota_system_state_inner_v1; +pub mod iota_system_state_inner_v2; pub mod iota_system_state_summary; #[cfg(msim)] @@ -46,6 +48,13 @@ pub const IOTA_SYSTEM_MODULE_NAME: &IdentStr = ident_str!("iota_system"); pub const ADVANCE_EPOCH_FUNCTION_NAME: &IdentStr = ident_str!("advance_epoch"); pub const ADVANCE_EPOCH_SAFE_MODE_FUNCTION_NAME: &IdentStr = ident_str!("advance_epoch_safe_mode"); +pub const IOTA_SYSTEM_DISPLAY_MODULE_NAME: &IdentStr = ident_str!("system_display"); +pub const CREATE_STAKED_IOTA_DISPLAY_V1: &IdentStr = ident_str!("create_staked_iota_display_v1"); +pub const CREATE_TIMELOCKED_STAKED_IOTA_DISPLAY_V1: &IdentStr = + ident_str!("create_timelocked_staked_iota_display_v1"); +pub const CREATE_TIMELOCKED_IOTA_DISPLAY_V1: &IdentStr = + ident_str!("create_timelocked_iota_display_v1"); + #[cfg(msim)] pub const IOTA_SYSTEM_STATE_SIM_TEST_V1: u64 = 18446744073709551605; // u64::MAX - 10 #[cfg(msim)] @@ -103,6 +112,13 @@ impl IotaSystemStateWrapper { protocol_config, ); } + 2 => { + Self::advance_epoch_safe_mode_impl::( + move_object, + params, + protocol_config, + ); + } #[cfg(msim)] IOTA_SYSTEM_STATE_SIM_TEST_V1 => { Self::advance_epoch_safe_mode_impl::( @@ -191,6 +207,7 @@ pub trait IotaSystemStateTrait { #[enum_dispatch(IotaSystemStateTrait)] pub enum IotaSystemState { V1(IotaSystemStateV1), + V2(IotaSystemStateV2), #[cfg(msim)] SimTestV1(SimTestIotaSystemStateV1), #[cfg(msim)] @@ -212,11 +229,8 @@ impl IotaSystemState { pub fn into_genesis_version_for_tooling(self) -> IotaSystemStateInnerGenesis { match self { IotaSystemState::V1(inner) => inner, - #[cfg(msim)] - _ => { - // Types other than V1 used in simtests should be unreachable - unreachable!() - } + // Types other than V1 and used in simtests should be unreachable + _ => unreachable!(), } } @@ -260,6 +274,18 @@ pub fn get_iota_system_state(object_store: &dyn ObjectStore) -> Result { + let result: IotaSystemStateV2 = + get_dynamic_field_from_store(object_store, id, &wrapper.version).map_err( + |err| { + IotaError::DynamicFieldRead(format!( + "Failed to load iota system state inner object with ID {:?} and version {:?}: {:?}", + id, wrapper.version, err + )) + }, + )?; + Ok(IotaSystemState::V2(result)) + } #[cfg(msim)] IOTA_SYSTEM_STATE_SIM_TEST_V1 => { let result: SimTestIotaSystemStateV1 = @@ -400,12 +426,13 @@ pub fn get_system_display_objects( let system_state = get_iota_system_state(object_store)?; match system_state { - IotaSystemState::V1(inner) => inner + IotaSystemState::V1(_) => Ok(HashMap::new()), + IotaSystemState::V2(inner) => inner .system_display_objects .contents .into_iter() .map(|entry| { - let display_object_id = entry.value.bytes; + let display_object_id = entry.value; let display_object: DisplayObject = get_dynamic_field_from_store( object_store, @@ -427,11 +454,11 @@ pub fn get_system_display_objects( } /// Get a system display object unique key. -/// * ty - is a type for which a display object is created. -pub fn display_object_key(ty: StructTag) -> String { +/// * tag - is a tag of a type for which the display object is created. +pub fn system_display_object_key(tag: StructTag) -> String { let with_prefix = false; - ty.to_canonical_string(with_prefix) + tag.to_canonical_string(with_prefix) } #[derive(Debug, Serialize, Deserialize, Clone, Eq, PartialEq, Default)] diff --git a/crates/iota-types/src/transaction.rs b/crates/iota-types/src/transaction.rs index f8ff33452b3..daf7e3bd43f 100644 --- a/crates/iota-types/src/transaction.rs +++ b/crates/iota-types/src/transaction.rs @@ -292,6 +292,14 @@ pub enum TransactionKind { // .. more transaction types go here } +/// SystemDisplayTransactionKind +#[derive(Debug, PartialEq, Eq, Hash, Clone, Serialize, Deserialize, IntoStaticStr)] +pub enum SystemDisplayTransactionKind { + StakedIotaV1, + TimelockedStakedIotaV1, + TimelockedIotaV1, +} + /// EndOfEpochTransactionKind #[derive(Debug, PartialEq, Eq, Hash, Clone, Serialize, Deserialize, IntoStaticStr)] pub enum EndOfEpochTransactionKind { @@ -300,6 +308,7 @@ pub enum EndOfEpochTransactionKind { AuthenticatorStateExpire(AuthenticatorStateExpire), BridgeStateCreate(ChainIdentifier), BridgeCommitteeInit(SequenceNumber), + SystemDisplay(Vec), } impl EndOfEpochTransactionKind { @@ -347,6 +356,10 @@ impl EndOfEpochTransactionKind { Self::BridgeCommitteeInit(bridge_shared_version) } + pub fn system_display(txs: Vec) -> Self { + Self::SystemDisplay(txs) + } + fn input_objects(&self) -> Vec { match self { Self::ChangeEpoch(_) => { @@ -377,6 +390,13 @@ impl EndOfEpochTransactionKind { mutable: true, }, ], + Self::SystemDisplay(_) => { + vec![InputObjectKind::SharedMoveObject { + id: IOTA_SYSTEM_STATE_OBJECT_ID, + initial_shared_version: IOTA_SYSTEM_STATE_OBJECT_SHARED_VERSION, + mutable: true, + }] + } } } @@ -406,6 +426,9 @@ impl EndOfEpochTransactionKind { ] .into_iter(), ), + Self::SystemDisplay(_) => { + Either::Left(vec![SharedInputObject::IOTA_SYSTEM_OBJ].into_iter()) + } } } @@ -438,6 +461,33 @@ impl EndOfEpochTransactionKind { )); } } + Self::SystemDisplay(txs) => { + for tx in txs { + match tx { + SystemDisplayTransactionKind::StakedIotaV1 => { + if !config.enable_staked_iota_display_v1() { + return Err(UserInputError::Unsupported( + "`StakedIota` display is not enabled".to_string(), + )); + } + } + SystemDisplayTransactionKind::TimelockedStakedIotaV1 => { + if !config.enable_timelocked_staked_iota_display_v1() { + return Err(UserInputError::Unsupported( + "`TimelockedStakedIota` display is not enabled".to_string(), + )); + } + } + SystemDisplayTransactionKind::TimelockedIotaV1 => { + if !config.enable_timelocked_iota_display_v1() { + return Err(UserInputError::Unsupported( + "`TimeLock>` display is not enabled".to_string(), + )); + } + } + } + } + } } Ok(()) } diff --git a/iota-execution/latest/iota-adapter/src/execution_engine.rs b/iota-execution/latest/iota-adapter/src/execution_engine.rs index 26353e36d0a..0cdfb2650e3 100644 --- a/iota-execution/latest/iota-adapter/src/execution_engine.rs +++ b/iota-execution/latest/iota-adapter/src/execution_engine.rs @@ -16,7 +16,7 @@ mod checked { use iota_types::{ BRIDGE_ADDRESS, IOTA_AUTHENTICATOR_STATE_OBJECT_ID, IOTA_BRIDGE_OBJECT_ID, IOTA_FRAMEWORK_ADDRESS, IOTA_FRAMEWORK_PACKAGE_ID, IOTA_RANDOMNESS_STATE_OBJECT_ID, - IOTA_SYSTEM_PACKAGE_ID, + IOTA_SYSTEM_ADDRESS, IOTA_SYSTEM_PACKAGE_ID, authenticator_state::{ AUTHENTICATOR_STATE_CREATE_FUNCTION_NAME, AUTHENTICATOR_STATE_EXPIRE_JWKS_FUNCTION_NAME, AUTHENTICATOR_STATE_MODULE_NAME, @@ -46,7 +46,9 @@ mod checked { id::UID, inner_temporary_store::InnerTemporaryStore, iota_system_state::{ - ADVANCE_EPOCH_FUNCTION_NAME, AdvanceEpochParams, IOTA_SYSTEM_MODULE_NAME, + ADVANCE_EPOCH_FUNCTION_NAME, AdvanceEpochParams, CREATE_STAKED_IOTA_DISPLAY_V1, + CREATE_TIMELOCKED_IOTA_DISPLAY_V1, CREATE_TIMELOCKED_STAKED_IOTA_DISPLAY_V1, + IOTA_SYSTEM_DISPLAY_MODULE_NAME, IOTA_SYSTEM_MODULE_NAME, }, messages_checkpoint::CheckpointTimestamp, metrics::LimitsMetrics, @@ -57,7 +59,8 @@ mod checked { transaction::{ Argument, AuthenticatorStateExpire, AuthenticatorStateUpdateV1, CallArg, ChangeEpoch, CheckedInputObjects, Command, EndOfEpochTransactionKind, GenesisTransaction, ObjectArg, - ProgrammableTransaction, RandomnessStateUpdate, TransactionKind, + ProgrammableTransaction, RandomnessStateUpdate, SystemDisplayTransactionKind, + TransactionKind, }, }; use move_binary_format::CompiledModule; @@ -696,6 +699,9 @@ mod checked { assert!(protocol_config.should_try_to_finalize_bridge_committee()); builder = setup_bridge_committee_update(builder, bridge_shared_version) } + EndOfEpochTransactionKind::SystemDisplay(txs) => { + builder = setup_system_display_objects(builder, protocol_config, txs) + } } } unreachable!( @@ -1232,4 +1238,64 @@ mod checked { pt, ) } + + /// Configures a `ProgrammableTransactionBuilder` to update the system + /// display objects. + fn setup_system_display_objects( + mut builder: ProgrammableTransactionBuilder, + protocol_config: &ProtocolConfig, + txs: Vec, + ) -> ProgrammableTransactionBuilder { + for tx in txs { + match tx { + SystemDisplayTransactionKind::StakedIotaV1 => { + assert!(protocol_config.enable_staked_iota_display_v1()); + + let system_state = builder + .obj(ObjectArg::IOTA_SYSTEM_MUT) + .expect("Unable to create System State object arg!"); + + builder.programmable_move_call( + IOTA_SYSTEM_ADDRESS.into(), + IOTA_SYSTEM_DISPLAY_MODULE_NAME.to_owned(), + CREATE_STAKED_IOTA_DISPLAY_V1.to_owned(), + vec![], + vec![system_state], + ); + } + SystemDisplayTransactionKind::TimelockedStakedIotaV1 => { + assert!(protocol_config.enable_timelocked_staked_iota_display_v1()); + + let system_state = builder + .obj(ObjectArg::IOTA_SYSTEM_MUT) + .expect("Unable to create System State object arg!"); + + builder.programmable_move_call( + IOTA_SYSTEM_ADDRESS.into(), + IOTA_SYSTEM_DISPLAY_MODULE_NAME.to_owned(), + CREATE_TIMELOCKED_STAKED_IOTA_DISPLAY_V1.to_owned(), + vec![], + vec![system_state], + ); + } + SystemDisplayTransactionKind::TimelockedIotaV1 => { + assert!(protocol_config.enable_timelocked_iota_display_v1()); + + let system_state = builder + .obj(ObjectArg::IOTA_SYSTEM_MUT) + .expect("Unable to create System State object arg!"); + + builder.programmable_move_call( + IOTA_SYSTEM_ADDRESS.into(), + IOTA_SYSTEM_DISPLAY_MODULE_NAME.to_owned(), + CREATE_TIMELOCKED_IOTA_DISPLAY_V1.to_owned(), + vec![], + vec![system_state], + ); + } + } + } + + builder + } }