// Copyright (c) Mysten Labs, Inc. // SPDX-License-Identifier: Apache-2.0 use std::{ collections::{BTreeMap, BTreeSet}, sync::{ Arc, LazyLock, atomic::{AtomicBool, Ordering}, }, }; use std::sync::Mutex; use clap::*; use fastcrypto::encoding::{Base58, Encoding, Hex}; use move_binary_format::{ binary_config::{BinaryConfig, BinaryFormatLimitsProfile, TableConfig}, file_format_common::*, }; use move_core_types::account_address::AccountAddress; use move_vm_config::verifier::VerifierConfig; use mysten_common::in_integration_test; use serde::{Deserialize, Serialize}; use serde_with::skip_serializing_none; use sui_protocol_config_macros::{ ProtocolConfigAccessors, ProtocolConfigFeatureFlagsGetters, ProtocolConfigOverride, }; use tracing::{info, warn}; pub mod reachability; // Re-exported so that `assert_reachable_gated!` expands without requiring callers to depend on // the antithesis sdk or mysten-common directly. #[doc(hidden)] pub use antithesis_sdk::linkme; #[doc(hidden)] pub use mysten_common::assert_reachable_simtest; /// The minimum and maximum protocol versions supported by this build. const MIN_PROTOCOL_VERSION: u64 = 1; const MAX_PROTOCOL_VERSION: u64 = 145; const TESTNET_USDC: &str = "0xa1ec7fc00a6f40db9693ad1415d0c193ad3906494428cf252621037bd7117e29::usdc::USDC"; const MAINNET_USDC: &str = "0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC"; const MAINNET_USDSUI: &str = "0x44f838219cf67b058f3b37907b655f226153c18e33dfcd0da559a844fea9b1c1::usdsui::USDSUI"; const MAINNET_SUI_USDE: &str = "0x41d587e5336f1c86cad50d38a7136db99333bb9bda91cea4ba69115defeb1402::sui_usde::SUI_USDE"; const MAINNET_USDY: &str = "0x960b531667636f39e85867775f52f6b1f220a058c4de786905bdf761e06a56bb::usdy::USDY"; const MAINNET_FDUSD: &str = "0xf16e6b723f242ec745dfd7634ad072c42d5c1d9ac9d62a39c381303eaa57693a::fdusd::FDUSD"; const MAINNET_AUSD: &str = "0x2053d08c1e2bd02791056171aab0fd12bd7cd7efad2ab8f6b9c8902f14df2ff2::ausd::AUSD"; const MAINNET_USDB: &str = "0xe14726c336e81b32328e92afc37345d159f5b550b09fa92bd43640cfdd0a0cfd::usdb::USDB"; // Record history of protocol version allocations here: // // Version 1: Original version. // Version 2: Framework changes, including advancing epoch_start_time in safemode. // Version 3: gas model v2, including all sui conservation fixes. Fix for loaded child object // changes, enable package upgrades, add limits on `max_size_written_objects`, // `max_size_written_objects_system_tx` // Version 4: New reward slashing rate. Framework changes to skip stake susbidy when the epoch // length is short. // Version 5: Package upgrade compatibility error fix. New gas cost table. New scoring decision // mechanism that includes up to f scoring authorities. // Version 6: Change to how bytes are charged in the gas meter, increase buffer stake to 0.5f // Version 7: Disallow adding new abilities to types during package upgrades, // disable_invariant_violation_check_in_swap_loc, // disable init functions becoming entry, // hash module bytes individually before computing package digest. // Version 8: Disallow changing abilities and type constraints for type parameters in structs // during upgrades. // Version 9: Limit the length of Move identifiers to 128. // Disallow extraneous module bytes, // advance_to_highest_supported_protocol_version, // Version 10:increase bytecode verifier `max_verifier_meter_ticks_per_function` and // `max_meter_ticks_per_module` limits each from 6_000_000 to 16_000_000. sui-system // framework changes. // Version 11: Introduce `std::type_name::get_with_original_ids` to the system frameworks. Bound max depth of values within the VM. // Version 12: Changes to deepbook in framework to add API for querying marketplace. // Change NW Batch to use versioned metadata field. // Changes to sui-system package to add PTB-friendly unstake function, and minor cleanup. // Version 13: System package change deprecating `0xdee9::clob` and `0xdee9::custodian`, replaced by // `0xdee9::clob_v2` and `0xdee9::custodian_v2`. // Version 14: Introduce a config variable to allow charging of computation to be either // bucket base or rounding up. The presence of `gas_rounding_step` (or `None`) // decides whether rounding is applied or not. // Version 15: Add reordering of user transactions by gas price after consensus. // Add `sui::table_vec::drop` to the framework via a system package upgrade. // Version 16: Enabled simplified_unwrap_then_delete feature flag, which allows the execution engine // to no longer consult the object store when generating unwrapped_then_deleted in the // effects; this also allows us to stop including wrapped tombstones in accumulator. // Add self-matching prevention for deepbook. // Version 17: Enable upgraded multisig support. // Version 18: Introduce execution layer versioning, preserve all existing behaviour in v0. // Gas minimum charges moved to be a multiplier over the reference gas price. In this // protocol version the multiplier is the same as the lowest bucket of computation // such that the minimum transaction cost is the same as the minimum computation // bucket. // Add a feature flag to indicate the changes semantics of `base_tx_cost_fixed`. // Version 19: Changes to sui-system package to enable liquid staking. // Add limit for total size of events. // Increase limit for number of events emitted to 1024. // Version 20: Enables the flag `narwhal_new_leader_election_schedule` for the new narwhal leader // schedule algorithm for enhanced fault tolerance and sets the bad node stake threshold // value. Both values are set for all the environments except mainnet. // Version 21: ZKLogin known providers. // Version 22: Child object format change. // Version 23: Enabling the flag `narwhal_new_leader_election_schedule` for the new narwhal leader // schedule algorithm for enhanced fault tolerance and sets the bad node stake threshold // value for mainnet. // Version 24: Re-enable simple gas conservation checks. // Package publish/upgrade number in a single transaction limited. // JWK / authenticator state flags. // Version 25: Add sui::table_vec::swap and sui::table_vec::swap_remove to system packages. // Version 26: New gas model version. // Add support for receiving objects off of other objects in devnet only. // Version 28: Add sui::zklogin::verify_zklogin_id and related functions to sui framework. // Enable transaction effects v2 in devnet. // Version 29: Add verify_legacy_zklogin_address flag to sui framework, this add ability to verify // transactions from a legacy zklogin address. // Version 30: Enable Narwhal CertificateV2 // Add support for random beacon. // Enable transaction effects v2 in testnet. // Deprecate supported oauth providers from protocol config and rely on node config // instead. // In execution, has_public_transfer is recomputed when loading the object. // Add support for shared obj deletion and receiving objects off of other objects in devnet only. // Version 31: Add support for shared object deletion in devnet only. // Add support for getting object ID referenced by receiving object in sui framework. // Create new execution layer version, and preserve previous behavior in v1. // Update semantics of `sui::transfer::receive` and add `sui::transfer::public_receive`. // Version 32: Add delete functions for VerifiedID and VerifiedIssuer. // Add sui::token module to sui framework. // Enable transfer to object in testnet. // Enable Narwhal CertificateV2 on mainnet // Make critbit tree and order getters public in deepbook. // Version 33: Add support for `receiving_object_id` function in framework // Hardened OTW check. // Enable transfer-to-object in mainnet. // Enable shared object deletion in testnet. // Enable effects v2 in mainnet. // Version 34: Framework changes for random beacon. // Version 35: Add poseidon hash function. // Enable coin deny list. // Version 36: Enable group operations native functions in devnet. // Enable shared object deletion in mainnet. // Set the consensus accepted transaction size and the included transactions size in the proposed block. // Version 37: Reject entry functions with mutable Random. // Version 38: Introduce limits for binary tables size. // Version 39: Allow skipped epochs for randomness updates. // Extra version to fix `test_upgrade_compatibility` simtest. // Version 40: // Version 41: Enable group operations native functions in testnet and mainnet (without msm). // Version 42: Migrate sui framework and related code to Move 2024 // Version 43: Introduce the upper bound delta config for a zklogin signature's max epoch. // Introduce an explicit parameter for the tick limit per package (previously this was // represented by the parameter for the tick limit per module). // Version 44: Enable consensus fork detection on mainnet. // Switch between Narwhal and Mysticeti consensus in tests, devnet and testnet. // Version 45: Use tonic networking for Mysticeti consensus. // Set min Move binary format version to 6. // Enable transactions to be signed with zkLogin inside multisig signature. // Add native bridge. // Enable native bridge in devnet // Enable Leader Scoring & Schedule Change for Mysticeti consensus on testnet. // Version 46: Enable native bridge in testnet // Enable resharing at the same initial shared version. // Version 47: Deepbook changes (framework update) // Version 48: Use tonic networking for Mysticeti. // Resolve Move abort locations to the package id instead of the runtime module ID. // Enable random beacon in testnet. // Use new VM when verifying framework packages. // Version 49: Enable Move enums on devnet. // Enable VDF in devnet // Enable consensus commit prologue V3 in devnet. // Run Mysticeti consensus by default. // Version 50: Add update_node_url to native bridge, // New Move stdlib integer modules // Enable checkpoint batching in testnet. // Prepose consensus commit prologue in checkpoints. // Set number of leaders per round for Mysticeti commits. // Version 51: Switch to DKG V1. // Enable deny list v2 on devnet. // Version 52: Emit `CommitteeMemberUrlUpdateEvent` when updating bridge node url. // std::config native functions. // Modified sui-system package to enable withdrawal of stake before it becomes active. // Enable soft bundle in devnet and testnet. // Core macro visibility in sui core framework. // Enable checkpoint batching in mainnet. // Enable Mysticeti on mainnet. // Enable Leader Scoring & Schedule Change for Mysticeti consensus on mainnet. // Turn on count based shared object congestion control in devnet. // Enable consensus commit prologue V3 in testnet. // Enable enums on testnet. // Add support for passkey in devnet. // Enable deny list v2 on testnet and mainnet. // Version 53: Add feature flag to decide whether to attempt to finalize bridge committee // Enable consensus commit prologue V3 on testnet. // Turn on shared object congestion control in testnet. // Update stdlib natives costs // Version 54: Enable random beacon on mainnet. // Enable soft bundle on mainnet. // Version 55: Enable enums on mainnet. // Rethrow serialization type layout errors instead of converting them. // Version 56: Enable bridge on mainnet. // Note: do not use version 56 for any new features. // Version 57: Reduce minimum number of random beacon shares. // Version 58: Optimize boolean binops // Finalize bridge committee on mainnet. // Switch to distributed vote scoring in consensus in devnet // Version 59: Enable round prober in consensus. // Version 60: Validation of public inputs for Groth16 verification. // Enable configuration of maximum number of type nodes in a type layout. // Version 61: Switch to distributed vote scoring in consensus in testnet // Further reduce minimum number of random beacon shares. // Add feature flag for Mysticeti fastpath. // Version 62: Makes the event's sending module package upgrade-aware. // Version 63: Enable gas based congestion control in consensus commit. // Version 64: Revert congestion control change. // Version 65: Enable distributed vote scoring in mainnet. // Version 66: Revert distributed vote scoring in mainnet. // Framework fix for fungible staking book-keeping. // Version 67: Re-enable distributed vote scoring in mainnet. // Version 68: Add G1Uncompressed group to group ops. // Update to Move stdlib. // Enable gas based congestion control with overage. // Further reduce minimum number of random beacon shares. // Disallow adding new modules in `deps-only` packages. // Version 69: Sets number of rounds allowed for fastpath voting in consensus. // Enable smart ancestor selection in devnet. // Enable G1Uncompressed group in testnet. // Version 70: Enable smart ancestor selection in testnet. // Enable probing for accepted rounds in round prober in testnet // Add new gas model version to update charging of native functions. // Add std::uq64_64 module to Move stdlib. // Improve gas/wall time efficiency of some Move stdlib vector functions // Version 71: [SIP-45] Enable consensus amplification. // Version 72: Fix issue where `convert_type_argument_error` wasn't being used in all cases. // Max gas budget moved to 50_000 SUI // Max gas price moved to 50 SUI // Variants as type nodes. // Version 73: Enable new marker table version. // Enable consensus garbage collection and new commit rule for devnet. // Enable zstd compression for consensus tonic network in testnet. // Enable smart ancestor selection in mainnet. // Enable probing for accepted rounds in round prober in mainnet // Version 74: Enable load_nitro_attestation move function in sui framework in devnet. // Enable all gas costs for load_nitro_attestation. // Enable zstd compression for consensus tonic network in mainnet. // Enable the new commit rule for devnet. // Version 75: Enable passkey auth in testnet. // Version 76: Deprecate Deepbook V2 order placement and deposit. // Removes unnecessary child object mutations // Enable passkey auth in multisig for testnet. // Version 77: Enable uncompressed point group ops on mainnet. // Enable consensus garbage collection for testnet // Enable the new consensus commit rule for testnet. // Version 78: Make `TxContext` Move API native // Enable execution time estimate mode for congestion control on testnet. // Version 79: Enable median based commit timestamp in consensus on testnet. // Increase threshold for bad nodes that won't be considered leaders in consensus in testnet // Enable load_nitro_attestation move function in sui framework in testnet. // Enable consensus garbage collection for mainnet // Enable the new consensus commit rule for mainnet. // Version 80: Bound size of values created in the adapter. // Version 81: Enable median based commit timestamp in consensus on mainnet. // Enforce checkpoint timestamps are non-decreasing for testnet and mainnet. // Increase threshold for bad nodes that won't be considered leaders in consensus in mainnet // Version 82: Relax bounding of size of values created in the adapter. // Version 83: Resolve `TypeInput` IDs to defining ID when converting to `TypeTag`s in the adapter. // Enable execution time estimate mode for congestion control on mainnet. // Enable nitro attestation upgraded parsing and mainnet. // Version 84: Limit number of stored execution time observations between epochs. // Version 85: Enable party transfer in devnet. // Version 86: Use type tags in the object runtime and adapter instead of `Type`s. // Make variant count limit explicit in protocol config. // Enable party transfer in testnet. // Version 87: Enable better type resolution errors in the adapter. // Version 88: Update `sui-system` package to use `calculate_rewards` function. // Define the cost for the native Move function `rgp`. // Ignore execution time observations after validator stops accepting certs. // Version 89: Add additional signature checks // Add additional linkage checks // Version 90: Standard library improvements. // Enable `debug_fatal` on Move invariant violations. // Enable passkey and passkey inside multisig for mainnet. // Version 91: Minor changes in Sui Framework. Include CheckpointDigest in consensus dedup key for checkpoint signatures (V2). // Version 92: Disable checking shared object transfer restrictions per command = false // Version 93: Enable CheckpointDigest in consensus dedup key for checkpoint signatures. // Version 94: Decrease stored observations limit by 10% to stay within system object size limit. // Enable party transfer on mainnet. // Version 95: Change type name id base cost to 52, increase max transactions per checkpoint to 20000. // Version 96: Enable authority capabilities v2. // Fix bug where MFP transaction shared inputs' debts were not loaded // Create Coin Registry object // Enable checkpoint artifacts digest in devnet. // Version 97: Enable additional borrow checks // Version 98: Add authenticated event streams support via emit_authenticated function. // Add better error messages to the loader. // Version 99: Enable new commit handler. // Version 100: Framework update // Version 101: Framework update // Set max updates per settlement txn to 100. // Version 103: Framework update: internal Coin methods // Version 104: Framework update: CoinRegistry follow up for Coin methods // Enable all non-zero PCRs parsing for nitro attestation native function in Devnet and Testnet. // Version 105: Framework update: address aliases // Enable multi-epoch transaction expiration. // Enable always include required PCRs (0-4 & 8) parsing even if they are zeros for // nitro attestation native function in Devnet and Testnet. // Version 106: Framework update: accumulator storage fund calculations // Enable address balances on devnet // Version 108: Enable new digit based gas rounding. // Support TxContext in all parameter positions. // Disable entry point signature check. // Enable address aliases on testnet. // Enable poseidon_bn254 on mainnet. // Version 109: Update where we set bounds for some binary tables to be a bit more idiomatic. // Version 110: Enable parsing on all nonzero custom pcrs in nitro attestation parsing native // function on mainnet. // split_checkpoints_in_consensus_handler in devnet // Enable additional validation on zkLogin public identifier. // Version 111: Validator metadata // Version 112: Enable Ristretto255 in devnet. // Version 113: Validate gas price >= RGP at signing for address balance gas payments. // Version 114: Gate seeded test overrides for checkpoint tx limit behind feature flag. // Version 115: Gasless transaction drop safety. // Enable address aliases on mainnet. // Relax ValidDuring requirement for transactions with owned inputs. // Version 116: Enable Display Registry. // Disable defer_unpaid_amplification (debugging). // Version 117: Update Sui System metadata handling. // Version 118: Adds `transfer_migration_cap` to display registry // Version 119: Enable the new VM. // Version 120: Disallow unused jump tables // Version 121: Re-enable defer_unpaid_amplification (devnet + testnet). // Version 122: Framework update: vector::empty is deprecated. // Enable bulletproofs verification on devnet. // Enable defer_unpaid_amplification on mainnet. // Version 123: Gas accounting refresh (gas_model v13). // Version 124: Add timestamp_based_epoch_close feature flag and enable in tests. // Fix native call double-pop in gas meter stack height tracking (gas_model v14). // Limit public inputs in groth16::prepare_verifying_key. // Enable address balances, free tier (gasless), and coin reservations on mainnet. // Enables enable_accumulators, enable_address_balance_gas_payments, // enable_authenticated_event_streams, enable_coin_reservation_obj_refs, // enable_object_funds_withdraw, convert_withdrawal_compatibility_ptb_arguments, // split_checkpoints_in_consensus_handler, include_checkpoint_artifacts_digest_in_summary, // and enable_gasless on mainnet to bring it in line with testnet. // Configure mainnet gasless allowlist with stablecoin types and $0.01 minimum // transfer per stable. // Version 125: Enable granular_post_execution_checks. // Enable timestamp_based_epoch_close on testnet. // Version 126: Enable early_exit_on_iffw (gates the gas-underflow fix // shipped to mainnet out-of-band in #26816). // Version 127: Enable always_advance_dkg_to_resolution. // Update gas prices for range proofs and ristretto group operations. // Enable Ristretto255 group operations and bulletproofs verification on testnet. // Enable init functions for newly introduced modules during package upgrade. // Enable timestamp_based_epoch_close on mainnet. // Version 128: Make some additional bounds to binary tables explicit. // Version 129: Add `insert_before` and `insert_after` to `sui::linked_table` // Enable unified linkage in PTBs // Version 130: Record unsettled object-funds withdraws using per-account net amounts // from transaction effects instead of running-max withdraw amounts. // Add the `sui::scratch` per-transaction ephemeral store and its native costs. // Enable zklogin v2 verify (with v1 fallback) for devnet only. // Add an epoch close deadline failsafe for deferred transactions. // Version 131: Enable sharing transaction deny configs between validators via consensus. // Enable tx_context_restrictions_verifier: reject system-package // function signatures with `&mut TxContext` + any `&mut _` return // that have no non-`TxContext` `&mut U` parameter. // Version 132: Enable defer_owned_object_double_spend on devnet. // Add the `object::record_new_uid_from_hash` native and its cost, tracking the // root version of hash-derived UIDs (`new_uid_from_hash`). // Create the ForwardingAddressRegistry system object on devnet. // Make upgrade-init linkage checks independent of PTB command order. // Version 133: Include function signatures in type-node limits. // Bound type nodes in accumulators. // Version 134: Add `package::original_package_id` and its native costs. // Reduce the consensus block transaction count and payload limits. // (Both gated to non-mainnet chains.) // Disable defer_unpaid_amplification on mainnet. // Version 135: Apply the v134 config changes on mainnet. // Disable defer_unpaid_amplification everywhere. // Version 136: Enable ptb_tx_context_restrictions: `TxContext` may appear in a // PTB Move call signature at most once mutably or any number of // times immutably (never by value), and never in return position. // Enable allowed_proposers on devnet. // Add limits for references used by programmable transactions. // Add additional linkage invariant hardening/invariant checks in PTBs. // Add package_arena_size_in_bytes. // Version 137: Lower the per-bit cost of bulletproofs range proof verification, and raise the // bound on batch size * range bits from 512 to 1024. // Enable allowances on devnet and testnet. // Enable fix_ptb_generated_reads. // Charge `LdConst` for the abstract value size of the constant instead of its // serialized byte length. // Enable check_object_funds_withdraw_in_execution on devnet and charge for reads. // Enable allowed_proposers on testnet and mainnet. // Validate PTB indices at signing time. // Enable memory_safety_invariant_check_v2. // Version 138: Enable BumpOnly // Enable check_object_funds_withdraw_in_execution on testnet. // Disable effects transaction dependencies on testnet. // Enable allowances on mainnet. // Merge colliding deferred-transaction entries in the consensus handler // instead of overwriting (which stranded the displaced transactions). // Reduce the non-refundable storage fee from 1% to 0.01% on mainnet. // Version 139: Enable forwarding addresses on devnet. // Enable ML-DSA-65 account signatures on devnet. // Reduce the non-refundable storage fee from 1% to 0.01%. // Allow random beacon DKG to complete after its timeout on devnet and testnet. // Charge package inputs 1% of the per-byte object read cost. // Version 140: Add native vector bulk operations (keep_range, copy_range, replace_range // and reverse) and their gas costs. // Shuffle the block order within each round of a consensus commit on devnet. // Disable the ID leak verifier. // Enable check_object_funds_withdraw_in_execution on mainnet. // Disable effects transaction dependencies on mainnet. // Add the staggered-submission duplication signal thresholds. // Version 141: Refine the transaction effects size estimate. // Limit the number of accumulator events per transaction. // Version 142: Abort with EInvalidVerifyingKey in groth16::verify_groth16_proof when the // prepared verifying key length does not match the number of public inputs. // Add `sui::clock::borrow`, which references the Clock without a Clock input. // Add the `object::is_shared_input_impl` native and its cost. // Reject an overflowing x-coordinate in `secp256r1_ecrecover`. // Configure explicit Move binary format encoding limits. // Enable defer_owned_object_double_spend on all networks. // Version 143: Add and enable a new execution version. // Charge bcs::to_bytes for the size of its input. // Charge vector::copy_range for the size of its copied range. // Simplify Nitro attestation header validation. // Disable forwarding addresses on devnet. // Charge a MIST-denominated amount for publish and upgrade commands before execution. // Enable ML-DSA-65 account signatures on testnet. // Version 144: Enable timestamp-based transaction expiration on devnet. // Enable the staggered-submission signal on all networks. Double its window, // which doubles its excess floor to 1,200 copies and makes the exit dwell ten // windows. Add a minimum number of user transactions per consensus commit, // duplicates included, that it requires. // Version 145: Reject secp256r1 public keys in the SEC1 compact encoding. #[derive(Copy, Clone, Debug, Hash, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)] pub struct ProtocolVersion(u64); impl ProtocolVersion { // The minimum and maximum protocol version supported by this binary. Counterintuitively, this constant may // change over time as support for old protocol versions is removed from the source. This // ensures that when a new network (such as a testnet) is created, its genesis committee will // use a protocol version that is actually supported by the binary. pub const MIN: Self = Self(MIN_PROTOCOL_VERSION); pub const MAX: Self = Self(MAX_PROTOCOL_VERSION); #[cfg(not(msim))] pub const MAX_ALLOWED: Self = Self::MAX; // We create one additional "fake" version in simulator builds so that we can test upgrades. #[cfg(msim)] pub const MAX_ALLOWED: Self = Self(MAX_PROTOCOL_VERSION + 1); pub fn new(v: u64) -> Self { Self(v) } pub const fn as_u64(&self) -> u64 { self.0 } // For serde deserialization - we don't define a Default impl because there isn't a single // universally appropriate default value. pub fn max() -> Self { Self::MAX } pub fn prev(self) -> Self { Self(self.0.checked_sub(1).unwrap()) } } impl From for ProtocolVersion { fn from(v: u64) -> Self { Self::new(v) } } impl std::ops::Sub for ProtocolVersion { type Output = Self; fn sub(self, rhs: u64) -> Self::Output { Self::new(self.0 - rhs) } } impl std::ops::Add for ProtocolVersion { type Output = Self; fn add(self, rhs: u64) -> Self::Output { Self::new(self.0 + rhs) } } #[derive( Clone, Serialize, Deserialize, Debug, Default, PartialEq, Copy, PartialOrd, Ord, Eq, ValueEnum, )] pub enum Chain { Mainnet, Testnet, #[default] Unknown, } impl Chain { pub fn as_str(self) -> &'static str { match self { Chain::Mainnet => "mainnet", Chain::Testnet => "testnet", Chain::Unknown => "unknown", } } } /// Fetch the maximum value of a protocol config across all chains and versions. pub fn max_across_protocol(f: impl Fn(&ProtocolConfig) -> Option) -> Option { let mut max = None; let mut version = ProtocolVersion::MIN; while version <= ProtocolVersion::MAX { max = max.max(f(&ProtocolConfig::get_for_version(version, Chain::Unknown))); max = max.max(f(&ProtocolConfig::get_for_version(version, Chain::Mainnet))); max = max.max(f(&ProtocolConfig::get_for_version(version, Chain::Testnet))); version = version + 1; } max } pub struct Error(pub String); // TODO: There are quite a few non boolean values in the feature flags. We should move them out. /// Records on/off feature flags that may vary at each protocol version. #[derive(Default, Clone, Serialize, Deserialize, Debug, ProtocolConfigFeatureFlagsGetters)] struct FeatureFlags { // Add feature flags here, e.g.: // new_protocol_feature: bool, #[serde(skip_serializing_if = "is_false")] package_upgrades: bool, // If true, validators will commit to the root state digest // in end of epoch checkpoint proposals #[serde(skip_serializing_if = "is_false")] commit_root_state_digest: bool, // Pass epoch start time to advance_epoch safe mode function. #[serde(skip_serializing_if = "is_false")] advance_epoch_start_time_in_safe_mode: bool, // If true, apply the fix to correctly capturing loaded child object versions in execution's // object runtime. #[serde(skip_serializing_if = "is_false")] loaded_child_objects_fixed: bool, // If true, treat missing types in the upgraded modules when creating an upgraded package as a // compatibility error. #[serde(skip_serializing_if = "is_false")] missing_type_is_compatibility_error: bool, // If true, then the scoring decision mechanism will not get disabled when we do have more than // f low scoring authorities, but it will simply flag as low scoring only up to f authorities. #[serde(skip_serializing_if = "is_false")] scoring_decision_with_validity_cutoff: bool, // DEPRECATED: this was an ephemeral feature flag only used by consensus handler, which has now // been deployed everywhere. #[serde(skip_serializing_if = "is_false")] consensus_order_end_of_epoch_last: bool, // If true, validators emit slim (ancestor-compressed) blocks on the consensus block // subscription stream, framed in a block envelope. Gates the wire framing on both // ends of the stream. #[serde(skip_serializing_if = "is_false")] consensus_slim_block_propagation: bool, // Disallow adding abilities to types during package upgrades. #[serde(skip_serializing_if = "is_false")] disallow_adding_abilities_on_upgrade: bool, // Disables unnecessary invariant check in the Move VM when swapping the value out of a local #[serde(skip_serializing_if = "is_false")] disable_invariant_violation_check_in_swap_loc: bool, // advance to highest supported protocol version at epoch change, instead of the next consecutive // protocol version. #[serde(skip_serializing_if = "is_false")] advance_to_highest_supported_protocol_version: bool, // If true, disallow entry modifiers on entry functions #[serde(skip_serializing_if = "is_false")] ban_entry_init: bool, // If true, hash module bytes individually when calculating package digests for upgrades #[serde(skip_serializing_if = "is_false")] package_digest_hash_module: bool, // If true, disallow changing struct type parameters during package upgrades #[serde(skip_serializing_if = "is_false")] disallow_change_struct_type_params_on_upgrade: bool, // If true, checks no extra bytes in a compiled module #[serde(skip_serializing_if = "is_false")] no_extraneous_module_bytes: bool, // If true, then use the versioned metadata format in narwhal entities. #[serde(skip_serializing_if = "is_false")] narwhal_versioned_metadata: bool, // Enable zklogin auth #[serde(skip_serializing_if = "is_false")] zklogin_auth: bool, // zkLogin circuit verify mode: 0 = accept v1 circuit proofs only, 1 = try the v2 // circuit first and fall back to v1 (migration phase), 2 = accept v2 circuit proofs only. #[serde(skip_serializing_if = "is_zero")] zklogin_circuit_mode: u64, // How we order transactions coming out of consensus before sending to execution. #[serde(skip_serializing_if = "ConsensusTransactionOrdering::is_none")] consensus_transaction_ordering: ConsensusTransactionOrdering, // Previously, the unwrapped_then_deleted field in TransactionEffects makes a distinction between // whether an object has existed in the store previously (i.e. whether there is a tombstone). // Such dependency makes effects generation inefficient, and requires us to include wrapped // tombstone in state root hash. // To prepare for effects V2, with this flag set to true, we simplify the definition of // unwrapped_then_deleted to always include unwrapped then deleted objects, // regardless of their previous state in the store. #[serde(skip_serializing_if = "is_false")] simplified_unwrap_then_delete: bool, // Enable upgraded multisig support #[serde(skip_serializing_if = "is_false")] upgraded_multisig_supported: bool, // If true minimum txn charge is a multiplier of the gas price #[serde(skip_serializing_if = "is_false")] txn_base_cost_as_multiplier: bool, // If true, the ability to delete shared objects is in effect #[serde(skip_serializing_if = "is_false")] shared_object_deletion: bool, // If true, then the new algorithm for the leader election schedule will be used #[serde(skip_serializing_if = "is_false")] narwhal_new_leader_election_schedule: bool, // A list of supported OIDC providers that can be used for zklogin. #[serde(skip_serializing_if = "is_empty")] zklogin_supported_providers: BTreeSet, // If true, use the new child object format #[serde(skip_serializing_if = "is_false")] loaded_child_object_format: bool, #[serde(skip_serializing_if = "is_false")] #[skip_protocol_config_accessor] enable_jwk_consensus_updates: bool, #[serde(skip_serializing_if = "is_false")] #[skip_protocol_config_accessor] end_of_epoch_transaction_supported: bool, // Perform simple conservation checks keeping into account out of gas scenarios // while charging for storage. #[serde(skip_serializing_if = "is_false")] simple_conservation_checks: bool, // If true, use the new child object format type logging #[serde(skip_serializing_if = "is_false")] loaded_child_object_format_type: bool, // Enable receiving sent objects #[serde(skip_serializing_if = "is_false")] receive_objects: bool, // If true, include CheckpointDigest in consensus dedup key for checkpoint signatures (V2). #[serde(skip_serializing_if = "is_false")] consensus_checkpoint_signature_key_includes_digest: bool, // Enable random beacon protocol #[serde(skip_serializing_if = "is_false")] random_beacon: bool, // Enable bridge protocol #[serde(skip_serializing_if = "is_false")] #[skip_protocol_config_accessor] bridge: bool, #[serde(skip_serializing_if = "is_false")] enable_effects_v2: bool, // If true, then use CertificateV2 in narwhal. #[serde(skip_serializing_if = "is_false")] narwhal_certificate_v2: bool, // If true, allow verify with legacy zklogin address #[serde(skip_serializing_if = "is_false")] verify_legacy_zklogin_address: bool, // Enable throughput aware consensus submission #[serde(skip_serializing_if = "is_false")] throughput_aware_consensus_submission: bool, // If true, recompute has_public_transfer from the type instead of what is stored in the object #[serde(skip_serializing_if = "is_false")] recompute_has_public_transfer_in_execution: bool, // If true, multisig containing zkLogin sig is accepted. #[serde(skip_serializing_if = "is_false")] accept_zklogin_in_multisig: bool, // If true, multisig containing passkey sig is accepted. #[serde(skip_serializing_if = "is_false")] accept_passkey_in_multisig: bool, // If true, additional zkLogin public identifier structure is validated. #[serde(skip_serializing_if = "is_false")] validate_zklogin_public_identifier: bool, // If true, consensus prologue transaction also includes the consensus output digest. // It can be used to detect consensus output folk. #[serde(skip_serializing_if = "is_false")] include_consensus_digest_in_prologue: bool, // If true, use the hardened OTW check #[serde(skip_serializing_if = "is_false")] hardened_otw_check: bool, // If true allow calling receiving_object_id function #[serde(skip_serializing_if = "is_false")] allow_receiving_object_id: bool, // Enable the poseidon hash function #[serde(skip_serializing_if = "is_false")] enable_poseidon: bool, // If true, enable the coin deny list. #[serde(skip_serializing_if = "is_false")] enable_coin_deny_list: bool, // Enable native functions for group operations. #[serde(skip_serializing_if = "is_false")] enable_group_ops_native_functions: bool, // Enable native function for msm. #[serde(skip_serializing_if = "is_false")] enable_group_ops_native_function_msm: bool, // Enable group operations for Ristretto255 #[serde(skip_serializing_if = "is_false")] enable_ristretto255_group_ops: bool, // Enable native functions for group operations. #[serde(skip_serializing_if = "is_false")] enable_verify_bulletproofs_ristretto255: bool, // Enable nitro attestation. #[serde(skip_serializing_if = "is_false")] enable_nitro_attestation: bool, // Enable upgraded parsing of nitro attestation that interprets pcrs as a map. #[serde(skip_serializing_if = "is_false")] enable_nitro_attestation_upgraded_parsing: bool, // Enable upgraded parsing of nitro attestation containing all nonzero PCRs. #[serde(skip_serializing_if = "is_false")] enable_nitro_attestation_all_nonzero_pcrs_parsing: bool, // Enable upgraded parsing of nitro attestation to always include required PCRs, even when all zeros. #[serde(skip_serializing_if = "is_false")] enable_nitro_attestation_always_include_required_pcrs_parsing: bool, // Require an empty unprotected header and validate the protected header's exact shape. // Reject trailing CBOR bytes and indefinite-length byte strings. #[serde(skip_serializing_if = "is_false")] simplify_nitro_header_validation: bool, // Reject functions with mutable Random. #[serde(skip_serializing_if = "is_false")] reject_mutable_random_on_entry_functions: bool, // Controls the behavior of per object congestion control in consensus handler. #[serde(skip_serializing_if = "PerObjectCongestionControlMode::is_none")] per_object_congestion_control_mode: PerObjectCongestionControlMode, // The consensus protocol to be used for the epoch. #[serde(skip_serializing_if = "ConsensusChoice::is_narwhal")] consensus_choice: ConsensusChoice, // Consensus network to use. #[serde(skip_serializing_if = "ConsensusNetwork::is_anemo")] consensus_network: ConsensusNetwork, // If true, use the correct (<=) comparison for max_gas_payment_objects instead of (<) #[serde(skip_serializing_if = "is_false")] correct_gas_payment_limit_check: bool, // Set the upper bound allowed for max_epoch in zklogin signature. #[serde(skip_serializing_if = "Option::is_none")] zklogin_max_epoch_upper_bound_delta: Option, // Controls leader scoring & schedule change in Mysticeti consensus. #[serde(skip_serializing_if = "is_false")] mysticeti_leader_scoring_and_schedule: bool, // Enable resharing of shared objects using the same initial shared version #[serde(skip_serializing_if = "is_false")] reshare_at_same_initial_version: bool, // Resolve Move abort locations to the package id instead of the runtime module ID. #[serde(skip_serializing_if = "is_false")] resolve_abort_locations_to_package_id: bool, // Enables the use of the Mysticeti committed sub dag digest to the `ConsensusCommitInfo` in checkpoints. // When disabled the default digest is used instead. It's important to have this guarded behind // a flag as it will lead to checkpoint forks. #[serde(skip_serializing_if = "is_false")] mysticeti_use_committed_subdag_digest: bool, // Enable VDF #[serde(skip_serializing_if = "is_false")] enable_vdf: bool, // Controls whether consensus handler should record consensus determined shared object version // assignments in consensus commit prologue transaction. // The purpose of doing this is to enable replaying transaction without transaction effects. #[serde(skip_serializing_if = "is_false")] record_consensus_determined_version_assignments_in_prologue: bool, // V2 also records initial shared versions for consensus objects. // Deprecated: must always be set to `true`. #[serde(skip_serializing_if = "is_false")] record_consensus_determined_version_assignments_in_prologue_v2: bool, // Run verification of framework upgrades using a new/fresh VM. #[serde(skip_serializing_if = "is_false")] fresh_vm_on_framework_upgrade: bool, // When set to true, the consensus commit prologue transaction will be placed first // in a consensus commit in checkpoints. // If a checkpoint contains multiple consensus commit, say [cm1][cm2]. The each commit's // consensus commit prologue will be the first transaction in each segment: // [ccp1, rest cm1][ccp2, rest cm2] // The reason to prepose the prologue transaction is to provide information for transaction // cancellation. #[serde(skip_serializing_if = "is_false")] prepend_prologue_tx_in_consensus_commit_in_checkpoints: bool, // Set number of leaders per round for Mysticeti commits. #[serde(skip_serializing_if = "Option::is_none")] mysticeti_num_leaders_per_round: Option, // Enable Soft Bundle (SIP-19). #[serde(skip_serializing_if = "is_false")] soft_bundle: bool, // If true, enable the coin deny list V2. #[serde(skip_serializing_if = "is_false")] enable_coin_deny_list_v2: bool, // Enable passkey auth (SIP-9) #[serde(skip_serializing_if = "is_false")] passkey_auth: bool, // Enable ML-DSA-65 (FIPS 204) account signatures, standalone and as // multisig members. #[serde(skip_serializing_if = "is_false")] mldsa65_auth: bool, // Reject an overflowing x-coordinate r + n in `secp256r1_ecrecover` instead of wrapping it. #[serde(skip_serializing_if = "is_false")] secp256r1_ecrecover_checks_x_below_p: bool, // Reject secp256r1 public keys in the SEC1 compact encoding (prefix 0x05) in signatures and // in `ecdsa_r1::secp256r1_verify`. #[serde(skip_serializing_if = "is_false")] secp256r1_strict_public_keys: bool, // Use the refined transaction effects size estimate. #[serde(skip_serializing_if = "is_false")] complete_effects_size_estimate: bool, // Use AuthorityCapabilitiesV2 #[serde(skip_serializing_if = "is_false")] authority_capabilities_v2: bool, // Rethrow type layout errors during serialization instead of trying to convert them. #[serde(skip_serializing_if = "is_false")] rethrow_serialization_type_layout_errors: bool, // Use distributed vote leader scoring strategy in consensus. #[serde(skip_serializing_if = "is_false")] consensus_distributed_vote_scoring_strategy: bool, // Probe rounds received by peers from every authority. #[serde(skip_serializing_if = "is_false")] consensus_round_prober: bool, // Validate identifier inputs separately #[serde(skip_serializing_if = "is_false")] validate_identifier_inputs: bool, // Disallow self identifier #[serde(skip_serializing_if = "is_false")] disallow_self_identifier: bool, // Enables Mysticeti fastpath. #[serde(skip_serializing_if = "is_false")] mysticeti_fastpath: bool, // If true, disable pre-consensus locking for owned objects. // All transactions go through consensus, and owned object conflict detection // happens post-consensus via lock acquisition. #[serde(skip_serializing_if = "is_false")] disable_preconsensus_locking: bool, // Makes the event's sending module version-aware. #[serde(skip_serializing_if = "is_false")] relocate_event_module: bool, // Enable uncompressed group elements in BLS123-81 G1 #[serde(skip_serializing_if = "is_false")] uncompressed_g1_group_elements: bool, #[serde(skip_serializing_if = "is_false")] disallow_new_modules_in_deps_only_packages: bool, // Use smart ancestor selection in consensus. #[serde(skip_serializing_if = "is_false")] consensus_smart_ancestor_selection: bool, // Probe accepted rounds in round prober. #[serde(skip_serializing_if = "is_false")] consensus_round_prober_probe_accepted_rounds: bool, // Enable v2 native charging for natives. #[serde(skip_serializing_if = "is_false")] native_charging_v2: bool, // Enables the new logic for collecting the subdag in the consensus linearizer. The new logic does not stop the recursion at the highest // committed round for each authority, but allows to commit uncommitted blocks up to gc round (excluded) for that authority. #[serde(skip_serializing_if = "is_false")] #[skip_protocol_config_accessor] consensus_linearize_subdag_v2: bool, // Properly convert certain type argument errors in the execution layer. #[serde(skip_serializing_if = "is_false")] convert_type_argument_error: bool, // Variants count as nodes #[serde(skip_serializing_if = "is_false")] variant_nodes: bool, // If true, enable zstd compression for consensus tonic network. #[serde(skip_serializing_if = "is_false")] consensus_zstd_compression: bool, // If true, enables the optimizations for child object mutations, removing unnecessary mutations #[serde(skip_serializing_if = "is_false")] minimize_child_object_mutations: bool, // If true, record the additional state digest in the consensus commit prologue. // Deprecated: must always be set to `true`. #[serde(skip_serializing_if = "is_false")] record_additional_state_digest_in_prologue: bool, // If true, enable `TxContext` Move API to go native. #[serde(skip_serializing_if = "is_false")] move_native_context: bool, // If true, then it (1) will not enforce monotonicity checks for a block's ancestors and (2) calculates the commit's timestamp based on the // weighted by stake median timestamp of the leader's ancestors. #[serde(skip_serializing_if = "is_false")] #[skip_protocol_config_accessor] consensus_median_based_commit_timestamp: bool, // If true, enables the normalization of PTB arguments but does not yet enable splatting // `Result`s of length not equal to 1 #[serde(skip_serializing_if = "is_false")] normalize_ptb_arguments: bool, // If true, enabled batched block sync in consensus. #[serde(skip_serializing_if = "is_false")] consensus_batched_block_sync: bool, // If true, enforces checkpoint timestamps are non-decreasing. #[serde(skip_serializing_if = "is_false")] enforce_checkpoint_timestamp_monotonicity: bool, // If true, enables better errors and bounds for max ptb values #[serde(skip_serializing_if = "is_false")] max_ptb_value_size_v2: bool, // If true, resolves all type input ids to be defining ID based in the adapter #[serde(skip_serializing_if = "is_false")] resolve_type_input_ids_to_defining_id: bool, // Enable native function for party transfer #[serde(skip_serializing_if = "is_false")] enable_party_transfer: bool, // Allow objects created or mutated in system transactions to exceed the max object size limit. #[serde(skip_serializing_if = "is_false")] allow_unbounded_system_objects: bool, // Signifies the cut-over of using type tags instead of `Type`s in the object runtime. #[serde(skip_serializing_if = "is_false")] type_tags_in_object_runtime: bool, // Enable accumulators #[serde(skip_serializing_if = "is_false")] enable_accumulators: bool, // Enable coin reservation #[serde(skip_serializing_if = "is_false")] #[skip_protocol_config_accessor] enable_coin_reservation_obj_refs: bool, // If true, create the root accumulator object in the change epoch transaction. // This must be enabled and shipped before `enable_accumulators` is set to true. #[serde(skip_serializing_if = "is_false")] create_root_accumulator_object: bool, // Enable authenticated event streams #[serde(skip_serializing_if = "is_false")] #[skip_protocol_config_accessor] enable_authenticated_event_streams: bool, // Enable address balance gas payments #[serde(skip_serializing_if = "is_false")] enable_address_balance_gas_payments: bool, // Validate gas price >= RGP at signing for address balance gas payments #[serde(skip_serializing_if = "is_false")] address_balance_gas_check_rgp_at_signing: bool, #[serde(skip_serializing_if = "is_false")] address_balance_gas_reject_gas_coin_arg: bool, // Enable multi-epoch transaction expiration (max 1 epoch difference) #[serde(skip_serializing_if = "is_false")] enable_multi_epoch_transaction_expiration: bool, // Relax ValidDuring expiration requirement for transactions with owned inputs #[serde(skip_serializing_if = "is_false")] relax_valid_during_for_owned_inputs: bool, // Enable statically type checked ptb execution #[serde(skip_serializing_if = "is_false")] enable_ptb_execution_v2: bool, // Provide better type resolution errors in the adapter. #[serde(skip_serializing_if = "is_false")] better_adapter_type_resolution_errors: bool, // If true, record the time estimate processed in the consensus commit prologue. #[serde(skip_serializing_if = "is_false")] record_time_estimate_processed: bool, // If true enable additional linkage checks. #[serde(skip_serializing_if = "is_false")] dependency_linkage_error: bool, // If true enable additional multisig checks. #[serde(skip_serializing_if = "is_false")] additional_multisig_checks: bool, // If true, ignore execution time observations after certs are closed. #[serde(skip_serializing_if = "is_false")] ignore_execution_time_observations_after_certs_closed: bool, // If true use `debug_fatal` to report invariant violations. // `debug_fatal` panics in debug builds and breaks tests/behavior based on older // protocol versions (see make_vec_non_existent_type_v71.move) #[serde(skip_serializing_if = "is_false")] debug_fatal_on_move_invariant_violation: bool, // DO NOT ENABLE THIS FOR PRODUCTION NETWORKS. used for testing only. // Allow private accumulator entrypoints #[serde(skip_serializing_if = "is_false")] allow_private_accumulator_entrypoints: bool, // If true, include indirect state in the additional consensus digest. // Deprecated: must always be set to `true`. #[serde(skip_serializing_if = "is_false")] additional_consensus_digest_indirect_state: bool, // Check for `init` for new modules to a package on upgrade. #[serde(skip_serializing_if = "is_false")] check_for_init_during_upgrade: bool, // If true, run `init` for newly introduced modules during package upgrade. #[serde(skip_serializing_if = "is_false")] enable_init_on_upgrade: bool, // If true, analyze upgrade-init linkage after all other PTB linkage constraints. #[serde(skip_serializing_if = "is_false")] enable_order_independent_upgrade_init_linkage: bool, // If true, adds additional hardening and checks to upgrade-init linkage entries, and adds // additional linkage invariant checks around linkage. #[serde(skip_serializing_if = "is_false")] harden_linkage_consistency: bool, // Check shared object transfer restrictions per command. #[serde(skip_serializing_if = "is_false")] per_command_shared_object_transfer_rules: bool, // Validate PTB input and result indices before signing. #[serde(skip_serializing_if = "is_false")] validate_ptb_argument_indices: bool, // Enable including checkpoint artifacts digest in the summary. #[serde(skip_serializing_if = "is_false")] include_checkpoint_artifacts_digest_in_summary: bool, // If true, use MFP txns in load initial object debts. #[serde(skip_serializing_if = "is_false")] use_mfp_txns_in_load_initial_object_debts: bool, // If true, cancel randomness-using txns when DKG has failed *before* doing other congestion checks. #[serde(skip_serializing_if = "is_false")] cancel_for_failed_dkg_early: bool, // If true, keep advancing the DKG state machine while DKG is pending. #[serde(skip_serializing_if = "is_false")] always_advance_dkg_to_resolution: bool, // If true, keep DKG pending after its timeout so that it can complete later in the epoch. #[serde(skip_serializing_if = "is_false")] allow_dkg_completion_after_timeout: bool, // Enable coin registry protocol #[serde(skip_serializing_if = "is_false")] enable_coin_registry: bool, // Use abstract size in the object runtime instead the legacy value size. #[serde(skip_serializing_if = "is_false")] abstract_size_in_object_runtime: bool, // If true charge for loads into the cache (i.e., fetches from storage) in the object runtime. #[serde(skip_serializing_if = "is_false")] object_runtime_charge_cache_load_gas: bool, // If true, perform additional borrow checks #[serde(skip_serializing_if = "is_false")] additional_borrow_checks: bool, // If true, use the new commit handler. #[serde(skip_serializing_if = "is_false")] use_new_commit_handler: bool, // If true return a better error message when we encounter a loader error. #[serde(skip_serializing_if = "is_false")] better_loader_errors: bool, // If true generate layouts for dynamic fields #[serde(skip_serializing_if = "is_false")] generate_df_type_layouts: bool, // If true, allow Move functions called in PTBs to return references #[serde(skip_serializing_if = "is_false")] allow_references_in_ptbs: bool, // If true, the tx_context_restrictions_verifier pass runs at Move module // publish time and rejects system-package signatures with `&mut TxContext` // + any `&mut _` return that have no non-`TxContext` `&mut U` parameter. // User packages are exempt: they can express the same shape through // generic instantiation, so PTB arity and auto-injection checks are the // safety mechanism there. #[serde(skip_serializing_if = "is_false")] framework_tx_context_mut_restrictions: bool, // Count function and local signatures towards type-node budgets. #[serde(skip_serializing_if = "is_false")] include_function_signatures_in_instantiation_limits: bool, // If true, the static PTB verifier restricts `TxContext` in Move call // signatures: it may appear at most once as `&mut TxContext`, or any // number of times as `&TxContext`, never by value, and never in return // position (it can never become a PTB result). #[serde(skip_serializing_if = "is_false")] ptb_tx_context_restrictions: bool, // Enable display registry protocol #[serde(skip_serializing_if = "is_false")] enable_display_registry: bool, // If true, enable private generics verifier v2 #[serde(skip_serializing_if = "is_false")] private_generics_verifier_v2: bool, // If true, deprecate global storage ops during Move module deserialization #[serde(skip_serializing_if = "is_false")] deprecate_global_storage_ops_during_deserialization: bool, // If true, enable non-exclusive writes for user transactions. // DO NOT ENABLE outside of the transaction test runner. #[serde(skip_serializing_if = "is_false")] enable_non_exclusive_writes: bool, // If true, deprecate global storage ops everywhere. #[serde(skip_serializing_if = "is_false")] deprecate_global_storage_ops: bool, // If true, normalize depth formula to not be empty for zero depth. #[serde(skip_serializing_if = "is_false")] normalize_depth_formula: bool, // If true, `LdConst` charges for the abstract value size of the constant instead of its // serialized byte length. #[serde(skip_serializing_if = "is_false")] charge_ld_const_abstract_size: bool, // If true, skip GC'ed accept votes in CommitFinalizer. #[serde(skip_serializing_if = "is_false")] consensus_skip_gced_accept_votes: bool, // If true, include cancelled randomness txns in the consensus commit prologue. // Deprecated: must always be set to `true`. #[serde(skip_serializing_if = "is_false")] include_cancelled_randomness_txns_in_prologue: bool, // Enables address aliases. #[serde(skip_serializing_if = "is_false")] #[skip_protocol_config_accessor] address_aliases: bool, // If true, create the forwarding address registry object in the change epoch transaction. #[serde(skip_serializing_if = "is_false")] create_forwarding_address_registry: bool, // If true, resolve forwarding addresses through the forwarding address registry. #[serde(skip_serializing_if = "is_false")] enable_forwarding_addresses: bool, // Corrects signature-to-signer mapping in CheckpointContentsV2. // Deprecated: must always be set to `true`. #[serde(skip_serializing_if = "is_false")] fix_checkpoint_signature_mapping: bool, // If true, enable object funds withdraw. #[serde(skip_serializing_if = "is_false")] enable_object_funds_withdraw: bool, // If true, unsettled object-funds withdraws are recorded using per-account net // amounts from transaction effects, instead of running-max withdraw amounts. #[serde(skip_serializing_if = "is_false")] record_net_unsettled_object_withdraws: bool, // If true, skip GC'ed blocks in direct finalization. #[serde(skip_serializing_if = "is_false")] consensus_skip_gced_blocks_in_direct_finalization: bool, // If true, uses a new rounding mechanism for gas calculations, replacing the step-based one #[serde(skip_serializing_if = "is_false")] gas_rounding_halve_digits: bool, // If true, enable tx contexts in all argument positions #[serde(skip_serializing_if = "is_false")] flexible_tx_context_positions: bool, // If true, disable entry point signature check. #[serde(skip_serializing_if = "is_false")] disable_entry_point_signature_check: bool, // If true, convert withdrawal compatibility PTB arguments to coins at the start of the PTB. #[serde(skip_serializing_if = "is_false")] convert_withdrawal_compatibility_ptb_arguments: bool, // If true, additional restrictions for hot or not entry functions are enforced. #[serde(skip_serializing_if = "is_false")] restrict_hot_or_not_entry_functions: bool, // If true, split checkpoints in consensus handler. #[serde(skip_serializing_if = "is_false")] split_checkpoints_in_consensus_handler: bool, // If true, always accept committed system transactions. #[serde(skip_serializing_if = "is_false")] consensus_always_accept_system_transactions: bool, // If true perform consistent verification of metadata #[serde(skip_serializing_if = "is_false")] validator_metadata_verify_v2: bool, // If true, defer transactions with unpaid consensus amplification // (where duplicate count exceeds gas_price / RGP + 1) #[serde(skip_serializing_if = "is_false")] defer_unpaid_amplification: bool, // If true, defer transactions that won an owned object lock when other transactions // in the same commit attempted to lock the same object (double-spend attempt). #[serde(skip_serializing_if = "is_false")] defer_owned_object_double_spend: bool, // If true, `TransactionExpiration::Validity` is accepted, allowing a transaction to // restrict which validators may propose it in consensus. #[serde(skip_serializing_if = "is_false")] allowed_proposers: bool, // If true, validators turn on staggered submission when commits show too many // duplicate copies of transactions without allowed proposers and enough user // transactions overall, duplicates included. Requires `allowed_proposers`. This flag coordinates // the rollout across validators. // `NodeConfig::enable_staggered_submission_signal` lets an operator disable it on // one node. Staggering runs only when both are enabled. #[serde(skip_serializing_if = "is_false")] #[skip_protocol_config_accessor] staggered_submission_signal: bool, #[serde(skip_serializing_if = "is_false")] randomize_checkpoint_tx_limit_in_tests: bool, // If true, mark the gas coin as uninitialized in drop safety when there is no gas coin. #[serde(skip_serializing_if = "is_false")] gasless_transaction_drop_safety: bool, // When split-checkpoints enabled, merge randomness and non-randomness schedulables together. // Deprecated: must always be set to `true`. #[serde(skip_serializing_if = "is_false")] merge_randomness_into_checkpoint: bool, // If true, use coin party owner information. #[serde(skip_serializing_if = "is_false")] use_coin_party_owner: bool, #[serde(skip_serializing_if = "is_false")] enable_gasless: bool, #[serde(skip_serializing_if = "is_false")] gasless_verify_remaining_balance: bool, #[serde(skip_serializing_if = "is_false")] disallow_jump_orphans: bool, // If true, return early on type mismatch in receive_object. #[serde(skip_serializing_if = "is_false")] early_return_receive_object_mismatched_type: bool, // If true, use consensus commit timestamps to determine epoch close instead of EndOfPublish voting. // Each validator transitions from AcceptAllCerts to RejectAllCerts when the consensus commit // timestamp exceeds the reconfiguration timestamp. EndOfPublish quorum still works as a // fallback for manual epoch close. #[serde(skip_serializing_if = "is_false")] timestamp_based_epoch_close: bool, // If true, groth16::prepare_verifying_key checks that the verifying key has no more than // MAX_PUBLIC_INPUTS public inputs. #[serde(skip_serializing_if = "is_false")] limit_groth16_pvk_inputs: bool, // If true, groth16::verify_groth16_proof checks that the prepared verifying key has the // length implied by the number of public inputs, and aborts with EInvalidVerifyingKey if it // does not. #[serde(skip_serializing_if = "is_false")] check_groth16_pvk_length: bool, // If true, the funds-accumulator address-balance change invariant // (`TemporaryStore::check_address_balance_changes`) is enforced as a consensus check — // violations abort the tx via the conservation-recovery flow. When false, the check still // runs but a violation panics so unexpected violations surface during rollout. #[serde(skip_serializing_if = "is_false")] enforce_address_balance_change_invariant: bool, // If true, validators may broadcast `UpdateTransactionDenyConfig` consensus messages. #[serde(skip_serializing_if = "is_false")] share_transaction_deny_config_in_consensus: bool, // Enables more granular post-execution checks. #[serde(skip_serializing_if = "is_false")] granular_post_execution_checks: bool, // If true, exit early for IFWW transactions. #[serde(skip_serializing_if = "is_false")] early_exit_on_iffw: bool, // If true enable unified linkage #[serde(skip_serializing_if = "is_false")] enable_unified_linkage: bool, // Charge a MIST-denominated amount for Publish and Upgrade commands before execution. #[serde(skip_serializing_if = "is_false")] package_publish_charge: bool, // Enable allowance-sourced funds withdrawals (`WithdrawFrom::SenderAllowance`). // Requires `enable_accumulators`. #[serde(skip_serializing_if = "is_false")] #[skip_protocol_config_accessor] enable_allowances: bool, // Fixes last-use scoping and live-reference metering for generated `Read` PTB arguments. #[serde(skip_serializing_if = "is_false")] fix_ptb_generated_reads: bool, #[serde(skip_serializing_if = "is_false")] check_object_funds_withdraw_in_execution: bool, // If true, use the bitset implementation for PTB memory safety invariant check. #[serde(skip_serializing_if = "is_false")] memory_safety_invariant_check_v2: bool, // Keep the effects wire representation, but stop collecting transaction dependencies. #[serde(skip_serializing_if = "is_false")] disable_effects_tx_dependencies: bool, // If true, a deferred-transaction key collision in the consensus commit handler // merges the colliding entries instead of overwriting the existing one, which // silently dropped the displaced (finalized) transactions. #[serde(skip_serializing_if = "is_false")] merge_colliding_deferrals: bool, // If true, consensus orders the blocks of each committed sub-dag within a round by a hash // seeded from the leader block's digest, instead of by authority index. Rounds stay in // ascending order, and transactions within a block keep their relative order. #[serde(skip_serializing_if = "is_false")] shuffle_consensus_commit_blocks: bool, // If true, skip the Sui ID leak verifier, allowing an existing `UID` to be used as an objects // id. #[serde(skip_serializing_if = "is_false")] disable_id_leak_verifier: bool, // If true, `min_timestamp` and `max_timestamp` in `ValidDuring` and `Validity` expirations // are accepted. Validators reject a transaction before its `min_timestamp` by their local // clocks, and a transaction scheduled by a commit after its `max_timestamp` fails with // `TransactionExpired`. #[serde(skip_serializing_if = "is_false")] enable_timestamp_transaction_expiration: bool, } fn is_false(b: &bool) -> bool { !b } fn is_empty(b: &BTreeSet) -> bool { b.is_empty() } fn is_zero(val: &u64) -> bool { *val == 0 } /// Ordering mechanism for transactions in one Narwhal consensus output. #[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)] pub enum ConsensusTransactionOrdering { /// No ordering. Transactions are processed in the order they appear in the consensus output. #[default] None, /// Order transactions by gas price, highest first. ByGasPrice, } impl ConsensusTransactionOrdering { pub fn is_none(&self) -> bool { matches!(self, ConsensusTransactionOrdering::None) } } #[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)] pub struct ExecutionTimeEstimateParams { // Targeted per-object utilization as an integer percentage (1-100). pub target_utilization: u64, // Schedule up to this much extra work (in microseconds) per object, // but don't allow more than a single transaction to exceed this // burst limit. pub allowed_txn_cost_overage_burst_limit_us: u64, // For separate budget for randomness-using tx, the above limits are // used with this integer-percentage scaling factor (1-100). pub randomness_scalar: u64, // Absolute maximum allowed transaction duration estimate (in microseconds). pub max_estimate_us: u64, // Number of the final checkpoints in an epoch whose observations should be // stored for use in the next epoch. pub stored_observations_num_included_checkpoints: u64, // Absolute limit on the number of saved observations at end of epoch. pub stored_observations_limit: u64, // Requires observations from at least this amount of stake in order to use // observation-based execution time estimates instead of the default. #[serde(skip_serializing_if = "is_zero")] pub stake_weighted_median_threshold: u64, // For backwards compatibility with old behavior we use a zero default duration when adding // new execution time observation keys and a zero generation when loading stored observations. // This can be removed once set to "true" on mainnet. #[serde(skip_serializing_if = "is_false")] pub default_none_duration_for_new_keys: bool, // Number of observations per chunk. When None, chunking is disabled. #[serde(skip_serializing_if = "Option::is_none")] pub observations_chunk_size: Option, } // The config for per object congestion control in consensus handler. #[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)] pub enum PerObjectCongestionControlMode { #[default] None, // Deprecated. TotalGasBudget, // Deprecated. TotalTxCount, // Deprecated. TotalGasBudgetWithCap, // Deprecated. ExecutionTimeEstimate(ExecutionTimeEstimateParams), // Use execution time estimate as execution cost. } impl PerObjectCongestionControlMode { pub fn is_none(&self) -> bool { matches!(self, PerObjectCongestionControlMode::None) } } // Configuration options for consensus algorithm. #[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)] pub enum ConsensusChoice { #[default] Narwhal, SwapEachEpoch, Mysticeti, } impl ConsensusChoice { pub fn is_narwhal(&self) -> bool { matches!(self, ConsensusChoice::Narwhal) } } // Configuration options for consensus network. #[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)] pub enum ConsensusNetwork { #[default] Anemo, Tonic, } impl ConsensusNetwork { pub fn is_anemo(&self) -> bool { matches!(self, ConsensusNetwork::Anemo) } } /// Constants that change the behavior of the protocol. /// /// The value of each constant here must be fixed for a given protocol version. To change the value /// of a constant, advance the protocol version, and add support for it in `get_for_version` under /// the new version number. /// (below). /// /// To add a new field to this struct, use the following procedure: /// - Advance the protocol version. /// - Add the field as a private `Option` to the struct. /// - Initialize the field to `None` in prior protocol versions. /// - Initialize the field to `Some(val)` for your new protocol version. /// - Add a public getter that simply unwraps the field. /// - Two public getters of the form `field(&self) -> field_type` /// and `field_as_option(&self) -> Option` will be automatically generated for you. /// Example for a field: `new_constant: Option` /// ```rust,ignore /// pub fn new_constant(&self) -> u64 { /// self.new_constant.expect(Self::CONSTANT_ERR_MSG) /// } /// pub fn new_constant_as_option(&self) -> Option { /// self.new_constant.expect(Self::CONSTANT_ERR_MSG) /// } /// ``` /// With `pub fn new_constant(&self) -> u64`, if the constant is accessed in a protocol version /// in which it is not defined, the validator will crash. (Crashing is necessary because /// this type of error would almost always result in forking if not prevented here). /// If you don't want the validator to crash, you can use the /// `pub fn new_constant_as_option(&self) -> Option` getter, which will /// return `None` if the field is not defined at that version. /// - If you want a customized getter, you can add a method in the impl. #[skip_serializing_none] #[derive(Clone, Serialize, Debug, ProtocolConfigAccessors, ProtocolConfigOverride)] pub struct ProtocolConfig { pub version: ProtocolVersion, /// The chain this config was instantiated for. Unlike the other fields, this is not a /// versioned protocol constant: it identifies the network rather than describing protocol /// behavior, so it is intentionally excluded from serialization (and from the config /// snapshots) and is populated directly from the chain passed to `get_for_version`. #[serde(skip)] chain: Chain, feature_flags: FeatureFlags, // ==== Transaction input limits ==== /// Maximum serialized size of a transaction (in bytes). max_tx_size_bytes: Option, /// Maximum number of input objects to a transaction. Enforced by the transaction input checker max_input_objects: Option, /// Max size of objects a transaction can write to disk after completion. Enforce by the Sui adapter. /// This is the sum of the serialized size of all objects written to disk. /// The max size of individual objects on the other hand is `max_move_object_size`. max_size_written_objects: Option, /// Max size of objects a system transaction can write to disk after completion. Enforce by the Sui adapter. /// Similar to `max_size_written_objects` but for system transactions. max_size_written_objects_system_tx: Option, /// Maximum size of serialized transaction effects. max_serialized_tx_effects_size_bytes: Option, /// Maximum size of serialized transaction effects for system transactions. max_serialized_tx_effects_size_bytes_system_tx: Option, /// Maximum number of gas payment objects for a transaction. max_gas_payment_objects: Option, /// Maximum number of modules in a Publish transaction. max_modules_in_publish: Option, /// Maximum number of transitive dependencies in a package when publishing. max_package_dependencies: Option, /// Maximum number of arguments in a move call or a ProgrammableTransaction's /// TransferObjects command. max_arguments: Option, /// Maximum number of total type arguments, computed recursively. max_type_arguments: Option, /// Maximum depth of an individual type argument. max_type_argument_depth: Option, /// Maximum size of a Pure CallArg. max_pure_argument_size: Option, /// Maximum number of Commands in a ProgrammableTransaction. max_programmable_tx_commands: Option, // ==== Move VM, Move bytecode verifier, and execution limits === /// Maximum Move bytecode version the VM understands. All older versions are accepted. move_binary_format_version: Option, min_move_binary_format_version: Option, /// Configuration controlling binary tables size. binary_module_handles: Option, binary_struct_handles: Option, binary_function_handles: Option, binary_function_instantiations: Option, binary_signatures: Option, binary_constant_pool: Option, binary_identifiers: Option, binary_address_identifiers: Option, binary_struct_defs: Option, binary_struct_def_instantiations: Option, binary_function_defs: Option, binary_field_handles: Option, binary_field_instantiations: Option, binary_friend_decls: Option, binary_enum_defs: Option, binary_enum_def_instantiations: Option, binary_variant_handles: Option, binary_variant_instantiation_handles: Option, /// Move binary format limits profile. #[skip_accessor] binary_format_limits_profile: Option, /// Maximum size of the `contents` part of an object, in bytes. Enforced by the Sui adapter when effects are produced. max_move_object_size: Option, // TODO: Option 500 KB exceeds the max computation gas cost /// Maximum size of a Move package object, in bytes. Enforced by the Sui adapter at the end of a publish transaction. max_move_package_size: Option, /// Max number of publish or upgrade commands allowed in a programmable transaction block. max_publish_or_upgrade_per_ptb: Option, /// Maximum gas budget in MIST that a transaction can use. max_tx_gas: Option, /// Maximum amount of the proposed gas price in MIST (defined in the transaction). max_gas_price: Option, /// For aborted txns, we cap the gas price at a factor of RGP. This lowers risk of setting higher priority gas price /// if there's a chance the txn will abort. max_gas_price_rgp_factor_for_aborted_transactions: Option, /// The max computation bucket for gas. This is the max that can be charged for computation. max_gas_computation_bucket: Option, // Define the value used to round up computation gas charges gas_rounding_step: Option, /// Maximum number of nested loops. Enforced by the Move bytecode verifier. max_loop_depth: Option, /// Maximum number of type arguments that can be bound to generic type parameters. Enforced by the Move bytecode verifier. max_generic_instantiation_length: Option, /// Maximum number of parameters that a Move function can have. Enforced by the Move bytecode verifier. max_function_parameters: Option, /// Maximum number of basic blocks that a Move function can have. Enforced by the Move bytecode verifier. max_basic_blocks: Option, /// Maximum stack size value. Enforced by the Move bytecode verifier. max_value_stack_size: Option, /// Maximum number of "type nodes", a metric for how big a SignatureToken will be when expanded into a fully qualified type. Enforced by the Move bytecode verifier. max_type_nodes: Option, /// Maximum number of "type nodes" that can be instantiated in a single function. max_generic_instantiation_type_nodes_per_function: Option, /// Maximum number of "type nodes" that can be instantiated in a module. max_generic_instantiation_type_nodes_per_module: Option, /// Maximum number of "type nodes" allowed in an accumulator. max_accumulator_type_nodes: Option, /// Maximum number of push instructions in one function. Enforced by the Move bytecode verifier. max_push_size: Option, /// Maximum number of struct definitions in a module. Enforced by the Move bytecode verifier. max_struct_definitions: Option, /// Maximum number of function definitions in a module. Enforced by the Move bytecode verifier. max_function_definitions: Option, /// Maximum number of fields allowed in a struct definition. Enforced by the Move bytecode verifier. max_fields_in_struct: Option, /// Maximum dependency depth. Enforced by the Move linker when loading dependent modules. max_dependency_depth: Option, /// Maximum number of Move events that a single transaction can emit. Enforced by the VM during execution. max_num_event_emit: Option, /// Maximum number of accumulator events that a single transaction can emit. Enforced by the /// adapter during execution. Each emitted event counts, before events on the same accumulator /// are merged. There is no limit when unset. max_num_accumulator_events: Option, /// Maximum number of new IDs that a single transaction can create. Enforced by the VM during execution. max_num_new_move_object_ids: Option, /// Maximum number of new IDs that a single system transaction can create. Enforced by the VM during execution. max_num_new_move_object_ids_system_tx: Option, /// Maximum number of IDs that a single transaction can delete. Enforced by the VM during execution. max_num_deleted_move_object_ids: Option, /// Maximum number of IDs that a single system transaction can delete. Enforced by the VM during execution. max_num_deleted_move_object_ids_system_tx: Option, /// Maximum number of IDs that a single transaction can transfer. Enforced by the VM during execution. max_num_transferred_move_object_ids: Option, /// Maximum number of IDs that a single system transaction can transfer. Enforced by the VM during execution. max_num_transferred_move_object_ids_system_tx: Option, /// Maximum size of a Move user event. Enforced by the VM during execution. max_event_emit_size: Option, /// Maximum size of a Move user event. Enforced by the VM during execution. max_event_emit_size_total: Option, /// Maximum length of a vector in Move. Enforced by the VM during execution, and for constants, by the verifier. max_move_vector_len: Option, /// Maximum length of an `Identifier` in Move. Enforced by the bytecode verifier at signing. max_move_identifier_len: Option, /// Maximum depth of a Move value within the VM. max_move_value_depth: Option, /// Maximum number of bytes a single package's arena may allocate when the package is loaded /// into the VM. If unset, the VM uses its built-in default. package_arena_size_in_bytes: Option, /// Maximum number of variants in an enum. Enforced by the bytecode verifier at signing. max_move_enum_variants: Option, /// Maximum number of back edges in Move function. Enforced by the bytecode verifier at signing. max_back_edges_per_function: Option, /// Maximum number of back edges in Move module. Enforced by the bytecode verifier at signing. max_back_edges_per_module: Option, /// Maximum number of meter `ticks` spent verifying a Move function. Enforced by the bytecode verifier at signing. max_verifier_meter_ticks_per_function: Option, /// Maximum number of meter `ticks` spent verifying a Move module. Enforced by the bytecode verifier at signing. max_meter_ticks_per_module: Option, /// Maximum number of meter `ticks` spent verifying a Move package. Enforced by the bytecode verifier at signing. max_meter_ticks_per_package: Option, // === Object runtime internal operation limits ==== // These affect dynamic fields /// Maximum number of cached objects in the object runtime ObjectStore. Enforced by object runtime during execution object_runtime_max_num_cached_objects: Option, /// Maximum number of cached objects in the object runtime ObjectStore in system transaction. Enforced by object runtime during execution object_runtime_max_num_cached_objects_system_tx: Option, /// Maximum total abstract size of child values loaded from storage in a transaction. object_runtime_max_loaded_child_value_size: Option, /// Maximum number of stored objects accessed by object runtime ObjectStore. Enforced by object runtime during execution object_runtime_max_num_store_entries: Option, /// Maximum number of stored objects accessed by object runtime ObjectStore in system transaction. Enforced by object runtime during execution object_runtime_max_num_store_entries_system_tx: Option, // === Execution gas costs ==== /// Base cost for any Sui transaction base_tx_cost_fixed: Option, /// Additional cost for a transaction that publishes a package /// i.e., the base cost of such a transaction is base_tx_cost_fixed + package_publish_cost_fixed package_publish_cost_fixed: Option, /// Cost per byte of a Move call transaction /// i.e., the cost of such a transaction is base_cost + (base_tx_cost_per_byte * size) base_tx_cost_per_byte: Option, /// Cost per byte for a transaction that publishes a package package_publish_cost_per_byte: Option, /// MIST charged per publish or upgrade command. package_publish_charge_fixed: Option, /// MIST charged per module of a publish or upgrade command. package_publish_charge_per_module: Option, /// MIST charged per dependency of a publish or upgrade command. package_publish_charge_per_dependency: Option, // Per-byte cost of reading an object during transaction execution obj_access_cost_read_per_byte: Option, // Cost per KiB (1,024 bytes) of reading a non-system package input. When unset, packages are // charged `obj_access_cost_read_per_byte` like other input objects. obj_access_cost_read_per_package_kb: Option, // Per-byte cost of writing an object during transaction execution obj_access_cost_mutate_per_byte: Option, // Per-byte cost of deleting an object during transaction execution obj_access_cost_delete_per_byte: Option, /// Per-byte cost charged for each input object to a transaction. /// Meant to approximate the cost of checking locks for each object // TODO: Option tx digest map obj_access_cost_verify_per_byte: Option, // Maximal nodes which are allowed when converting to a type layout. max_type_to_layout_nodes: Option, // Maximal size in bytes that a PTB value can be max_ptb_value_size: Option, // === Gas version. gas model === /// Gas model version, what code we are using to charge gas gas_model_version: Option, // === Storage gas costs === /// Per-byte cost of storing an object in the Sui global object store. Some of this cost may be refundable if the object is later freed obj_data_cost_refundable: Option, // Per-byte cost of storing an object in the Sui transaction log (e.g., in CertifiedTransactionEffects) // This depends on the size of various fields including the effects // TODO: Option, // === Tokenomics === // TODO: Option, /// 5% of the storage fund's share of rewards are reinvested into the storage fund. /// In basis point. storage_fund_reinvest_rate: Option, /// The share of rewards that will be slashed and redistributed is 50%. /// In basis point. reward_slashing_rate: Option, /// Unit gas price, Mist per internal gas unit. storage_gas_price: Option, /// Per-object storage cost for accumulator objects, used during end-of-epoch accounting. accumulator_object_storage_cost: Option, // === Core Protocol === /// Max number of transactions per checkpoint. /// Note that this is a protocol constant and not a config as validators must have this set to /// the same value, otherwise they *will* fork. max_transactions_per_checkpoint: Option, /// Max size of a checkpoint in bytes. /// Note that this is a protocol constant and not a config as validators must have this set to /// the same value, otherwise they *will* fork. max_checkpoint_size_bytes: Option, /// A protocol upgrade always requires 2f+1 stake to agree. We support a buffer of additional /// stake (as a fraction of f, expressed in basis points) that is required before an upgrade /// can happen automatically. 10000bps would indicate that complete unanimity is required (all /// 3f+1 must vote), while 0bps would indicate that 2f+1 is sufficient. buffer_stake_for_protocol_upgrade_bps: Option, // === Native Function Costs === // `address` module // Cost params for the Move native function `address::from_bytes(bytes: vector)` address_from_bytes_cost_base: Option, // Cost params for the Move native function `address::to_u256(address): u256` address_to_u256_cost_base: Option, // Cost params for the Move native function `address::from_u256(u256): address` address_from_u256_cost_base: Option, // `config` module // Cost params for the Move native function `read_setting_impl(config: address, name: address, current_epoch: u64): Option` config_read_setting_impl_cost_base: Option, config_read_setting_impl_cost_per_byte: Option, package_original_package_id_impl_cost_base: Option, package_original_package_id_impl_cost_per_byte: Option, // `dynamic_field` module // Cost params for the Move native function `hash_type_and_key(parent: address, k: K): address` dynamic_field_hash_type_and_key_cost_base: Option, dynamic_field_hash_type_and_key_type_cost_per_byte: Option, dynamic_field_hash_type_and_key_value_cost_per_byte: Option, dynamic_field_hash_type_and_key_type_tag_cost_per_byte: Option, // Cost params for the Move native function `add_child_object(parent: address, child: Child)` dynamic_field_add_child_object_cost_base: Option, dynamic_field_add_child_object_type_cost_per_byte: Option, dynamic_field_add_child_object_value_cost_per_byte: Option, dynamic_field_add_child_object_struct_tag_cost_per_byte: Option, // Cost params for the Move native function `borrow_child_object_mut(parent: &mut UID, id: address): &mut Child` dynamic_field_borrow_child_object_cost_base: Option, dynamic_field_borrow_child_object_child_ref_cost_per_byte: Option, dynamic_field_borrow_child_object_type_cost_per_byte: Option, // Cost params for the Move native function `remove_child_object(parent: address, id: address): Child` dynamic_field_remove_child_object_cost_base: Option, dynamic_field_remove_child_object_child_cost_per_byte: Option, dynamic_field_remove_child_object_type_cost_per_byte: Option, // Cost params for the Move native function `has_child_object(parent: address, id: address): bool` dynamic_field_has_child_object_cost_base: Option, // Cost params for the Move native function `has_child_object_with_ty(parent: address, id: address): bool` dynamic_field_has_child_object_with_ty_cost_base: Option, dynamic_field_has_child_object_with_ty_type_cost_per_byte: Option, dynamic_field_has_child_object_with_ty_type_tag_cost_per_byte: Option, // `scratch` module // Cost params for the Move native function `add_impl(key: address, value: V)` scratch_add_cost_base: Option, // Cost params for the Move native function `read_impl(key: address): V` scratch_read_cost_base: Option, scratch_read_value_cost: Option, // Cost params for the Move native function `remove_impl(key: address): V` scratch_remove_cost_base: Option, // Cost params for the Move native function `exists_impl(key: address): bool` scratch_exists_cost_base: Option, // Cost params for the Move native function `exists_with_type_impl(key: address): bool` scratch_exists_with_type_cost_base: Option, scratch_exists_with_type_type_cost: Option, // Maximum number of entries in the per-transaction `sui::scratch` store. max_scratch_pad_size: Option, // `event` module // Cost params for the Move native function `event::emit(event: T)` event_emit_cost_base: Option, event_emit_value_size_derivation_cost_per_byte: Option, event_emit_tag_size_derivation_cost_per_byte: Option, event_emit_output_cost_per_byte: Option, event_emit_auth_stream_cost: Option, // `funds_accumulator` module // Base cost for reserving object funds for withdrawal. reserve_object_funds_for_withdrawal_cost_base: Option, // Cost of loading an object's settled balance on the first withdrawal for an owner and type. reserve_object_funds_for_withdrawal_cold_read_cost: Option, // `object` module // Cost params for the Move native function `borrow_uid(obj: &T): &UID` object_borrow_uid_cost_base: Option, // Cost params for the Move native function `delete_impl(id: address)` object_delete_impl_cost_base: Option, // Cost params for the Move native function `record_new_uid(id: address)` object_record_new_uid_cost_base: Option, // Cost params for the Move native function // `record_new_uid_from_hash(parent: address, bytes: address)` object_record_new_uid_from_hash_cost_base: Option, // Cost params for the Move native function `is_shared_input_impl(id: address): bool` object_is_shared_input_cost_base: Option, // Transfer // Cost params for the Move native function `transfer_impl(obj: T, recipient: address)` transfer_transfer_internal_cost_base: Option, // Cost params for the Move native function `party_transfer_impl(obj: T, party_members: vector
)` transfer_party_transfer_internal_cost_base: Option, // Cost params for the Move native function `freeze_object(obj: T)` transfer_freeze_object_cost_base: Option, // Cost params for the Move native function `share_object(obj: T)` transfer_share_object_cost_base: Option, // Cost params for the Move native function // `receive_object(p: &mut UID, recv: ReceivingT)` transfer_receive_object_cost_base: Option, transfer_receive_object_cost_per_byte: Option, transfer_receive_object_type_cost_per_byte: Option, // TxContext // Cost params for the Move native function `transfer_impl(obj: T, recipient: address)` tx_context_derive_id_cost_base: Option, tx_context_fresh_id_cost_base: Option, tx_context_sender_cost_base: Option, tx_context_epoch_cost_base: Option, tx_context_epoch_timestamp_ms_cost_base: Option, tx_context_sponsor_cost_base: Option, tx_context_rgp_cost_base: Option, tx_context_gas_price_cost_base: Option, tx_context_gas_budget_cost_base: Option, tx_context_ids_created_cost_base: Option, tx_context_replace_cost_base: Option, // `clock` module // Cost params for the Move native function `native_borrow(): &Clock` clock_borrow_cost_base: Option, // Types // Cost params for the Move native function `is_one_time_witness(_: &T): bool` types_is_one_time_witness_cost_base: Option, types_is_one_time_witness_type_tag_cost_per_byte: Option, types_is_one_time_witness_type_cost_per_byte: Option, // Validator // Cost params for the Move native function `validate_metadata_bcs(metadata: vector)` validator_validate_metadata_cost_base: Option, validator_validate_metadata_data_cost_per_byte: Option, // Crypto natives crypto_invalid_arguments_cost: Option, // bls12381::bls12381_min_sig_verify bls12381_bls12381_min_sig_verify_cost_base: Option, bls12381_bls12381_min_sig_verify_msg_cost_per_byte: Option, bls12381_bls12381_min_sig_verify_msg_cost_per_block: Option, // bls12381::bls12381_min_pk_verify bls12381_bls12381_min_pk_verify_cost_base: Option, bls12381_bls12381_min_pk_verify_msg_cost_per_byte: Option, bls12381_bls12381_min_pk_verify_msg_cost_per_block: Option, // ecdsa_k1::ecrecover ecdsa_k1_ecrecover_keccak256_cost_base: Option, ecdsa_k1_ecrecover_keccak256_msg_cost_per_byte: Option, ecdsa_k1_ecrecover_keccak256_msg_cost_per_block: Option, ecdsa_k1_ecrecover_sha256_cost_base: Option, ecdsa_k1_ecrecover_sha256_msg_cost_per_byte: Option, ecdsa_k1_ecrecover_sha256_msg_cost_per_block: Option, // ecdsa_k1::decompress_pubkey ecdsa_k1_decompress_pubkey_cost_base: Option, // ecdsa_k1::secp256k1_verify ecdsa_k1_secp256k1_verify_keccak256_cost_base: Option, ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_byte: Option, ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_block: Option, ecdsa_k1_secp256k1_verify_sha256_cost_base: Option, ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_byte: Option, ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_block: Option, // ecdsa_r1::ecrecover ecdsa_r1_ecrecover_keccak256_cost_base: Option, ecdsa_r1_ecrecover_keccak256_msg_cost_per_byte: Option, ecdsa_r1_ecrecover_keccak256_msg_cost_per_block: Option, ecdsa_r1_ecrecover_sha256_cost_base: Option, ecdsa_r1_ecrecover_sha256_msg_cost_per_byte: Option, ecdsa_r1_ecrecover_sha256_msg_cost_per_block: Option, // ecdsa_r1::secp256k1_verify ecdsa_r1_secp256r1_verify_keccak256_cost_base: Option, ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_byte: Option, ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_block: Option, ecdsa_r1_secp256r1_verify_sha256_cost_base: Option, ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_byte: Option, ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_block: Option, // ecvrf::verify ecvrf_ecvrf_verify_cost_base: Option, ecvrf_ecvrf_verify_alpha_string_cost_per_byte: Option, ecvrf_ecvrf_verify_alpha_string_cost_per_block: Option, // ed25519 ed25519_ed25519_verify_cost_base: Option, ed25519_ed25519_verify_msg_cost_per_byte: Option, ed25519_ed25519_verify_msg_cost_per_block: Option, // groth16::prepare_verifying_key groth16_prepare_verifying_key_bls12381_cost_base: Option, groth16_prepare_verifying_key_bn254_cost_base: Option, // groth16::verify_groth16_proof_internal groth16_verify_groth16_proof_internal_bls12381_cost_base: Option, groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input: Option, groth16_verify_groth16_proof_internal_bn254_cost_base: Option, groth16_verify_groth16_proof_internal_bn254_cost_per_public_input: Option, groth16_verify_groth16_proof_internal_public_input_cost_per_byte: Option, // hash::blake2b256 hash_blake2b256_cost_base: Option, hash_blake2b256_data_cost_per_byte: Option, hash_blake2b256_data_cost_per_block: Option, // hash::keccak256 hash_keccak256_cost_base: Option, hash_keccak256_data_cost_per_byte: Option, hash_keccak256_data_cost_per_block: Option, // poseidon::poseidon_bn254 poseidon_bn254_cost_base: Option, poseidon_bn254_cost_per_block: Option, // group_ops group_ops_bls12381_decode_scalar_cost: Option, group_ops_bls12381_decode_g1_cost: Option, group_ops_bls12381_decode_g2_cost: Option, group_ops_bls12381_decode_gt_cost: Option, group_ops_bls12381_scalar_add_cost: Option, group_ops_bls12381_g1_add_cost: Option, group_ops_bls12381_g2_add_cost: Option, group_ops_bls12381_gt_add_cost: Option, group_ops_bls12381_scalar_sub_cost: Option, group_ops_bls12381_g1_sub_cost: Option, group_ops_bls12381_g2_sub_cost: Option, group_ops_bls12381_gt_sub_cost: Option, group_ops_bls12381_scalar_mul_cost: Option, group_ops_bls12381_g1_mul_cost: Option, group_ops_bls12381_g2_mul_cost: Option, group_ops_bls12381_gt_mul_cost: Option, group_ops_bls12381_scalar_div_cost: Option, group_ops_bls12381_g1_div_cost: Option, group_ops_bls12381_g2_div_cost: Option, group_ops_bls12381_gt_div_cost: Option, group_ops_bls12381_g1_hash_to_base_cost: Option, group_ops_bls12381_g2_hash_to_base_cost: Option, group_ops_bls12381_g1_hash_to_cost_per_byte: Option, group_ops_bls12381_g2_hash_to_cost_per_byte: Option, group_ops_bls12381_g1_msm_base_cost: Option, group_ops_bls12381_g2_msm_base_cost: Option, group_ops_bls12381_g1_msm_base_cost_per_input: Option, group_ops_bls12381_g2_msm_base_cost_per_input: Option, group_ops_bls12381_msm_max_len: Option, group_ops_bls12381_pairing_cost: Option, group_ops_bls12381_g1_to_uncompressed_g1_cost: Option, group_ops_bls12381_uncompressed_g1_to_g1_cost: Option, group_ops_bls12381_uncompressed_g1_sum_base_cost: Option, group_ops_bls12381_uncompressed_g1_sum_cost_per_term: Option, group_ops_bls12381_uncompressed_g1_sum_max_terms: Option, group_ops_ristretto_decode_scalar_cost: Option, group_ops_ristretto_decode_point_cost: Option, group_ops_ristretto_scalar_add_cost: Option, group_ops_ristretto_point_add_cost: Option, group_ops_ristretto_scalar_sub_cost: Option, group_ops_ristretto_point_sub_cost: Option, group_ops_ristretto_scalar_mul_cost: Option, group_ops_ristretto_point_mul_cost: Option, group_ops_ristretto_scalar_div_cost: Option, group_ops_ristretto_point_div_cost: Option, verify_bulletproofs_ristretto255_base_cost: Option, verify_bulletproofs_ristretto255_cost_per_bit_and_commitment: Option, // Upper bound on batch size * range in bits for a bulletproofs range proof. Defaults to 512 // when unset. max_bulletproofs_total_bits: Option, // hmac::hmac_sha3_256 hmac_hmac_sha3_256_cost_base: Option, hmac_hmac_sha3_256_input_cost_per_byte: Option, hmac_hmac_sha3_256_input_cost_per_block: Option, // zklogin::check_zklogin_id check_zklogin_id_cost_base: Option, // zklogin::check_zklogin_issuer check_zklogin_issuer_cost_base: Option, vdf_verify_vdf_cost: Option, vdf_hash_to_input_cost: Option, // nitro_attestation::load_nitro_attestation nitro_attestation_parse_base_cost: Option, nitro_attestation_parse_cost_per_byte: Option, nitro_attestation_verify_base_cost: Option, nitro_attestation_verify_cost_per_cert: Option, // Native layout cost multiplier in the layout cost formula. layout_node_cost: Option, // Layout size threshold above which the large-layout surcharge applies. layout_node_cost_large_layout_threshold: Option, // Stdlib costs bcs_per_input_abstract_unit_cost: Option, bcs_per_byte_serialized_cost: Option, bcs_legacy_min_output_size_cost: Option, bcs_failure_cost: Option, hash_sha2_256_base_cost: Option, hash_sha2_256_per_byte_cost: Option, hash_sha2_256_legacy_min_input_len_cost: Option, hash_sha3_256_base_cost: Option, hash_sha3_256_per_byte_cost: Option, hash_sha3_256_legacy_min_input_len_cost: Option, type_name_get_base_cost: Option, type_name_get_per_byte_cost: Option, type_name_id_base_cost: Option, string_check_utf8_base_cost: Option, string_check_utf8_per_byte_cost: Option, string_is_char_boundary_base_cost: Option, string_sub_string_base_cost: Option, string_sub_string_per_byte_cost: Option, string_index_of_base_cost: Option, string_index_of_per_byte_pattern_cost: Option, string_index_of_per_byte_searched_cost: Option, vector_empty_base_cost: Option, vector_length_base_cost: Option, vector_push_back_base_cost: Option, vector_push_back_legacy_per_abstract_memory_unit_cost: Option, vector_borrow_base_cost: Option, vector_pop_back_base_cost: Option, vector_destroy_empty_base_cost: Option, vector_swap_base_cost: Option, vector_reverse_base_cost: Option, vector_reverse_per_elem_cost: Option, vector_keep_range_base_cost: Option, vector_keep_range_per_dropped_elem_cost: Option, vector_keep_range_per_moved_elem_cost: Option, vector_copy_range_base_cost: Option, vector_copy_range_per_abstract_memory_unit_cost: Option, vector_replace_range_base_cost: Option, vector_replace_range_per_elem_cost: Option, debug_print_base_cost: Option, debug_print_stack_trace_base_cost: Option, // ==== Ephemeral (consensus only) params deleted ==== // // Const params for consensus scoring decision // The scaling factor property for the MED outlier detection // scoring_decision_mad_divisor: Option, // The cutoff value for the MED outlier detection // scoring_decision_cutoff_value: Option, /// === Execution Version === // custom_setter: see `set_execution_version_for_testing`, which forbids downgrades. #[custom_setter] execution_version: Option, // Dictates the threshold (percentage of stake) that is used to calculate the "bad" nodes to be // swapped when creating the consensus schedule. The values should be of the range [0 - 33]. Anything // above 33 (f) will not be allowed. consensus_bad_nodes_stake_threshold: Option, max_jwk_votes_per_validator_per_epoch: Option, // The maximum age of a JWK in epochs before it is removed from the AuthenticatorState object. // Applied at the end of an epoch as a delta from the new epoch value, so setting this to 1 // will cause the new epoch to start with JWKs from the previous epoch still valid. max_age_of_jwk_in_epochs: Option, // === random beacon === /// Maximum allowed precision loss when reducing voting weights for the random beacon /// protocol. random_beacon_reduction_allowed_delta: Option, /// Minimum number of shares below which voting weights will not be reduced for the /// random beacon protocol. random_beacon_reduction_lower_bound: Option, /// Consensus Round after which DKG should be aborted and randomness disabled for /// the epoch, if it hasn't already completed. random_beacon_dkg_timeout_round: Option, /// Minimum interval between consecutive rounds of generated randomness. random_beacon_min_round_interval_ms: Option, /// Version of the random beacon DKG protocol. /// 0 was deprecated (and currently not supported), 1 is the default version. random_beacon_dkg_version: Option, /// The maximum serialised transaction size (in bytes) accepted by consensus. That should be bigger than the /// `max_tx_size_bytes` with some additional headroom. consensus_max_transaction_size_bytes: Option, /// The maximum size of transactions included in a consensus block. consensus_max_transactions_in_block_bytes: Option, /// The maximum number of transactions included in a consensus block. consensus_max_num_transactions_in_block: Option, /// The maximum number of rounds where transaction voting is allowed. consensus_voting_rounds: Option, /// DEPRECATED. Do not use. max_accumulated_txn_cost_per_object_in_narwhal_commit: Option, /// The max number of consensus rounds a transaction can be deferred due to shared object congestion. /// Transactions will be cancelled after this many rounds. max_deferral_rounds_for_congestion_control: Option, /// Time after the scheduled epoch end (`next_reconfiguration_timestamp_ms`) at which epoch /// close stops waiting for deferred transactions to drain: the epoch is closed even if /// deferred transactions remain unscheduled. They are abandoned and can be resubmitted in the /// next epoch. When unset, epoch close waits indefinitely. epoch_close_deadline_ms: Option, /// DEPRECATED. Do not use. max_txn_cost_overage_per_object_in_commit: Option, /// DEPRECATED. Do not use. allowed_txn_cost_overage_burst_per_object_in_commit: Option, /// Minimum interval of commit timestamps between consecutive checkpoints. min_checkpoint_interval_ms: Option, /// Version number to use for version_specific_data in `CheckpointSummary`. checkpoint_summary_version_specific_data: Option, /// The max number of transactions that can be included in a single Soft Bundle. max_soft_bundle_size: Option, /// Whether to try to form bridge committee // Note: this is not a feature flag because we want to distinguish between // `None` and `Some(false)`, as committee was already finalized on Testnet. bridge_should_try_to_finalize_committee: Option, /// The max accumulated txn execution cost per object in a mysticeti. Transactions /// in a commit will be deferred once their touch shared objects hit this limit, /// unless the selected congestion control mode allows overage. /// This config plays the same role as `max_accumulated_txn_cost_per_object_in_narwhal_commit` /// but for mysticeti commits due to that mysticeti has higher commit rate. max_accumulated_txn_cost_per_object_in_mysticeti_commit: Option, /// As above, but separate per-commit budget for transactions that use randomness. /// If not configured, uses the setting for `max_accumulated_txn_cost_per_object_in_mysticeti_commit`. max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit: Option, /// Configures the garbage collection depth for consensus. When is unset or `0` then the garbage collection /// is disabled. consensus_gc_depth: Option, /// DEPRECATED. Do not use. gas_budget_based_txn_cost_cap_factor: Option, /// DEPRECATED. Do not use. gas_budget_based_txn_cost_absolute_cap_commit_count: Option, /// SIP-45: K in the formula `amplification_factor = max(0, gas_price / reference_gas_price - K)`. /// This is the threshold for activating consensus amplification. sip_45_consensus_amplification_threshold: Option, /// Number of recent commits the staggered-submission signal looks at. It compares /// excess copies of transactions without allowed proposers to unique user transactions. staggered_submission_signal_window_commits: Option, /// Excess copies per commit that the signal requires before it turns on. The signal /// compares the window's total with this value times /// `staggered_submission_signal_window_commits`, so a window that is not full yet /// must reach the same total. staggered_submission_signal_min_excess_copies_per_commit: Option, /// User transactions per consensus commit, duplicates included, that the signal /// requires. The signal compares the window's total with this value times /// `staggered_submission_signal_window_commits`, so a window that is not full yet /// must reach the same total. Below that total the signal does not escalate, and a /// commit counts towards the exit dwell. staggered_submission_signal_min_consensus_user_transactions_per_commit: Option, /// Number of consecutive commits before the signal drops to a lower band. Each of /// these commits must have a ratio below the band's exit ratio, or a window total /// below `staggered_submission_signal_min_consensus_user_transactions_per_commit` times /// `staggered_submission_signal_window_commits`. The two conditions can alternate. staggered_submission_signal_exit_dwell_commits: Option, /// Ratios to enter and exit each band, in basis points (bps) of the window's unique /// user transactions. Band 1 delays submissions up to 1.6s and band 2 up to 4.8s. staggered_submission_signal_band1_enter_ratio_bps: Option, staggered_submission_signal_band1_exit_ratio_bps: Option, staggered_submission_signal_band2_enter_ratio_bps: Option, staggered_submission_signal_band2_exit_ratio_bps: Option, /// DEPRECATED: this was an ephemeral feature flag only used in per-epoch tables, which has now /// been deployed everywhere. use_object_per_epoch_marker_table_v2: Option, /// The number of commits to consider when computing a deterministic commit rate. consensus_commit_rate_estimation_window_size: Option, /// A list of effective AliasedAddress. /// For each pair, `aliased` is allowed to act as `original` for any of the transaction digests /// listed in `tx_digests` #[serde(skip_serializing_if = "Vec::is_empty")] aliased_addresses: Vec, /// The base charge for each command in a programmable transaction. This is a fixed cost to /// account for the overhead of processing each command. translation_per_command_base_charge: Option, /// The base charge for each input in a programmable transaction regardless of if it is used or /// not, or a pure/object/funds withdrawal input. translation_per_input_base_charge: Option, /// The base charge for each byte of pure input in a programmable transaction. translation_pure_input_per_byte_charge: Option, /// The multiplier for the number of type nodes when charging for type loading. /// This is multiplied by the number of type nodes to get the total cost. /// This should be a small number to avoid excessive gas costs for loading types. translation_per_type_node_charge: Option, /// The multiplier for the number of type references when charging for type checking and reference /// checking. translation_per_reference_node_charge: Option, /// The multiplier for each linkage entry when charging for linkage tables that we have /// created. translation_per_linkage_entry_charge: Option, /// The maximum number of updates per settlement transaction. max_updates_per_settlement_txn: Option, /// Maximum computation units allowed for a gasless transaction. gasless_max_computation_units: Option, /// Allowed token types for gasless transactions, with minimum transfer sizes per token. gasless_allowed_token_types: Option>, /// Maximum number of unused Pure inputs allowed in a gasless transaction. /// Object and FundsWithdrawal inputs must always be used. /// When None, there is no limit (effectively unlimited). gasless_max_unused_inputs: Option, /// Maximum size in bytes of each Pure input in a gasless transaction. /// When None, there is no limit (effectively unlimited). gasless_max_pure_input_bytes: Option, /// Max tps for gasless transactions. Unlimited when unset, zero when set to zero. gasless_max_tps: Option, #[serde(skip_serializing_if = "Option::is_none")] #[skip_accessor] include_special_package_amendments: Option>, /// Maximum serialized size in bytes of a gasless transaction (SenderSignedData). /// Bounds the persistent storage impact of each admitted gasless transaction. gasless_max_tx_size_bytes: Option, /// The multiplier for each live reference charging per-command. Only used when /// `allow_references_in_ptbs` is enabled. translation_per_live_reference_charge: Option, /// The maximum number of live references while checking a command. Only used when /// `allow_references_in_ptbs` is enabled. max_ptb_live_references: Option, /// The maximum number of references returned by a command. Only used when /// `allow_references_in_ptbs` is enabled. max_ptb_returned_references: Option, /// The maximum number of references returned over the course of the transaction. Only used /// when `allow_references_in_ptbs` is enabled. max_ptb_total_returned_references: Option, } /// An aliased address. #[derive(Clone, Serialize, Deserialize, Debug)] pub struct AliasedAddress { /// The original address. pub original: [u8; 32], /// An aliased address which is allowed to act as the original address. pub aliased: [u8; 32], /// A list of transaction digests for which the aliasing is allowed to be in effect. pub allowed_tx_digests: Vec<[u8; 32]>, } // feature flags impl ProtocolConfig { /// The chain this config was instantiated for (see the `chain` field). pub fn chain(&self) -> Chain { self.chain } // Add checks for feature flag support here, e.g.: // pub fn check_new_protocol_feature_supported(&self) -> Result<(), Error> { // if self.feature_flags.new_protocol_feature_supported { // Ok(()) // } else { // Err(Error(format!( // "new_protocol_feature is not supported at {:?}", // self.version // ))) // } // } pub fn check_package_upgrades_supported(&self) -> Result<(), Error> { if self.feature_flags.package_upgrades { Ok(()) } else { Err(Error(format!( "package upgrades are not supported at {:?}", self.version ))) } } pub fn zklogin_supported_providers(&self) -> &BTreeSet { &self.feature_flags.zklogin_supported_providers } /// zkLogin circuit verify mode: 0 = v1 circuit only, 1 = v2 circuit with /// fallback to v1, 2 = v2 circuit only. pub fn zklogin_circuit_mode(&self) -> u64 { self.feature_flags.zklogin_circuit_mode } pub fn consensus_transaction_ordering(&self) -> ConsensusTransactionOrdering { self.feature_flags.consensus_transaction_ordering } pub fn enable_jwk_consensus_updates(&self) -> bool { let ret = self.feature_flags.enable_jwk_consensus_updates; if ret { // jwk updates required end-of-epoch transactions assert!(self.feature_flags.end_of_epoch_transaction_supported); } ret } pub fn staggered_submission_signal(&self) -> bool { let ret = self.feature_flags.staggered_submission_signal; if ret { // The signal staggers transactions without allowed proposers. That // distinction only exists when allowed_proposers is enabled. assert!(self.feature_flags.allowed_proposers); } ret } pub fn end_of_epoch_transaction_supported(&self) -> bool { let ret = self.feature_flags.end_of_epoch_transaction_supported; if !ret { // jwk updates required end-of-epoch transactions assert!(!self.feature_flags.enable_jwk_consensus_updates); } ret } pub fn dkg_version(&self) -> u64 { // Version 0 was deprecated and removed, the default is 1 if not set. self.random_beacon_dkg_version.unwrap_or(1) } pub fn bridge(&self) -> bool { let ret = self.feature_flags.bridge; if ret { // bridge required end-of-epoch transactions assert!(self.feature_flags.end_of_epoch_transaction_supported); } ret } pub fn should_try_to_finalize_bridge_committee(&self) -> bool { if !self.bridge() { return false; } // In the older protocol version, always try to finalize the committee. self.bridge_should_try_to_finalize_committee.unwrap_or(true) } pub fn zklogin_max_epoch_upper_bound_delta(&self) -> Option { self.feature_flags.zklogin_max_epoch_upper_bound_delta } pub fn enable_allowances(&self) -> bool { self.feature_flags.enable_allowances && self.enable_accumulators() } pub fn enable_coin_reservation_obj_refs(&self) -> bool { self.new_vm_enabled() && self.feature_flags.enable_coin_reservation_obj_refs } pub fn enable_authenticated_event_streams(&self) -> bool { self.feature_flags.enable_authenticated_event_streams && self.enable_accumulators() } pub fn per_object_congestion_control_mode(&self) -> PerObjectCongestionControlMode { self.feature_flags.per_object_congestion_control_mode } pub fn consensus_choice(&self) -> ConsensusChoice { self.feature_flags.consensus_choice } pub fn consensus_network(&self) -> ConsensusNetwork { self.feature_flags.consensus_network } pub fn mysticeti_num_leaders_per_round(&self) -> Option { self.feature_flags.mysticeti_num_leaders_per_round } pub fn max_transaction_size_bytes(&self) -> u64 { // Provide a default value if protocol config version is too low. self.consensus_max_transaction_size_bytes .unwrap_or(256 * 1024) } pub fn max_transactions_in_block_bytes(&self) -> u64 { if cfg!(msim) { 256 * 1024 } else { self.consensus_max_transactions_in_block_bytes .unwrap_or(512 * 1024) } } pub fn max_num_transactions_in_block(&self) -> u64 { if cfg!(msim) { 8 } else { self.consensus_max_num_transactions_in_block.unwrap_or(512) } } pub fn gc_depth(&self) -> u32 { self.consensus_gc_depth.unwrap_or(0) } pub fn consensus_linearize_subdag_v2(&self) -> bool { let res = self.feature_flags.consensus_linearize_subdag_v2; assert!( !res || self.gc_depth() > 0, "The consensus linearize sub dag V2 requires GC to be enabled" ); res } pub fn consensus_median_based_commit_timestamp(&self) -> bool { let res = self.feature_flags.consensus_median_based_commit_timestamp; assert!( !res || self.gc_depth() > 0, "The consensus median based commit timestamp requires GC to be enabled" ); res } pub fn get_consensus_commit_rate_estimation_window_size(&self) -> u32 { self.consensus_commit_rate_estimation_window_size .unwrap_or(0) } pub fn consensus_num_requested_prior_commits_at_startup(&self) -> u32 { // Currently there is only one parameter driving this value. If there are multiple // things computed from prior consensus commits, this function must return the max // of all of them. let window_size = self.get_consensus_commit_rate_estimation_window_size(); // Ensure we are not using past commits without recording a state digest in the prologue. assert!(window_size == 0 || self.record_additional_state_digest_in_prologue()); window_size } pub fn address_aliases(&self) -> bool { let address_aliases = self.feature_flags.address_aliases; assert!( !address_aliases || self.mysticeti_fastpath(), "Address aliases requires Mysticeti fastpath to be enabled" ); if address_aliases { assert!( self.feature_flags.disable_preconsensus_locking, "Address aliases requires CertifiedTransaction to be disabled" ); } address_aliases } pub fn new_vm_enabled(&self) -> bool { self.execution_version.is_some_and(|v| v >= 4) } pub fn gasless_allowed_token_types(&self) -> &[(String, u64)] { debug_assert!(self.gasless_allowed_token_types.is_some()); self.gasless_allowed_token_types.as_deref().unwrap_or(&[]) } pub fn get_gasless_max_unused_inputs(&self) -> u64 { self.gasless_max_unused_inputs.unwrap_or(u64::MAX) } pub fn get_gasless_max_pure_input_bytes(&self) -> u64 { self.gasless_max_pure_input_bytes.unwrap_or(u64::MAX) } pub fn get_gasless_max_tx_size_bytes(&self) -> u64 { self.gasless_max_tx_size_bytes.unwrap_or(u64::MAX) } pub fn include_special_package_amendments_as_option(&self) -> &Option> { &self.include_special_package_amendments } } static POISON_VERSION_METHODS: AtomicBool = AtomicBool::new(false); // Instantiations for each protocol version. impl ProtocolConfig { /// Get the value ProtocolConfig that are in effect during the given protocol version. pub fn get_for_version(version: ProtocolVersion, chain: Chain) -> Self { // ProtocolVersion can be deserialized so we need to check it here as well. assert!( version >= ProtocolVersion::MIN, "Network protocol version is {:?}, but the minimum supported version by the binary is {:?}. Please upgrade the binary.", version, ProtocolVersion::MIN.0, ); assert!( version <= ProtocolVersion::MAX_ALLOWED, "Network protocol version is {:?}, but the maximum supported version by the binary is {:?}. Please upgrade the binary.", version, ProtocolVersion::MAX_ALLOWED.0, ); let mut ret = Self::get_for_version_impl(version, chain); ret.version = version; ret.chain = chain; ret = Self::apply_config_override(version, ret); if std::env::var("SUI_PROTOCOL_CONFIG_OVERRIDE_ENABLE").is_ok() { warn!( "overriding ProtocolConfig settings with custom settings; this may break non-local networks" ); let overrides: ProtocolConfigOptional = serde_env::from_env_with_prefix("SUI_PROTOCOL_CONFIG_OVERRIDE") .expect("failed to parse ProtocolConfig override env variables"); overrides.apply_to(&mut ret); } ret } /// Get the value ProtocolConfig that are in effect during the given protocol version. /// Or none if the version is not supported. pub fn get_for_version_if_supported(version: ProtocolVersion, chain: Chain) -> Option { if version.0 >= ProtocolVersion::MIN.0 && version.0 <= ProtocolVersion::MAX_ALLOWED.0 { let mut ret = Self::get_for_version_impl(version, chain); ret.version = version; ret.chain = chain; ret = Self::apply_config_override(version, ret); Some(ret) } else { None } } pub fn poison_get_for_min_version() { POISON_VERSION_METHODS.store(true, Ordering::Relaxed); } fn load_poison_get_for_min_version() -> bool { POISON_VERSION_METHODS.load(Ordering::Relaxed) } /// Convenience to get the constants at the current minimum supported version. /// Mainly used by client code that may not yet be protocol-version aware. pub fn get_for_min_version() -> Self { if Self::load_poison_get_for_min_version() { panic!("get_for_min_version called on validator"); } ProtocolConfig::get_for_version(ProtocolVersion::MIN, Chain::Unknown) } /// CAREFUL! - You probably want to use `get_for_version` instead. /// /// Convenience to get the constants at the current maximum supported version. /// Mainly used by genesis. Note well that this function uses the max version /// supported locally by the node, which is not necessarily the current version /// of the network. ALSO, this function disregards chain specific config (by /// using Chain::Unknown), thereby potentially returning a protocol config that /// is incorrect for some feature flags. Definitely safe for testing and for /// protocol version 11 and prior. #[allow(non_snake_case)] pub fn get_for_max_version_UNSAFE() -> Self { if Self::load_poison_get_for_min_version() { panic!("get_for_max_version_UNSAFE called on validator"); } ProtocolConfig::get_for_version(ProtocolVersion::MAX, Chain::Unknown) } fn get_for_version_impl(version: ProtocolVersion, chain: Chain) -> Self { #[cfg(msim)] { // populate the fake simulator version # with a different base tx cost. if version == ProtocolVersion::MAX_ALLOWED { let mut config = Self::get_for_version_impl(version - 1, Chain::Unknown); config.base_tx_cost_fixed = Some(config.base_tx_cost_fixed() + 1000); return config; } } // IMPORTANT: Never modify the value of any constant for a pre-existing protocol version. // To change the values here you must create a new protocol version with the new values! let mut cfg = Self { // will be overwritten before being returned version, chain, // All flags are disabled in V1 feature_flags: Default::default(), max_tx_size_bytes: Some(128 * 1024), // We need this number to be at least 100x less than `max_serialized_tx_effects_size_bytes`otherwise effects can be huge max_input_objects: Some(2048), max_serialized_tx_effects_size_bytes: Some(512 * 1024), max_serialized_tx_effects_size_bytes_system_tx: Some(512 * 1024 * 16), max_gas_payment_objects: Some(256), max_modules_in_publish: Some(128), max_package_dependencies: None, max_arguments: Some(512), max_type_arguments: Some(16), max_type_argument_depth: Some(16), max_pure_argument_size: Some(16 * 1024), max_programmable_tx_commands: Some(1024), move_binary_format_version: Some(6), min_move_binary_format_version: None, binary_module_handles: None, binary_struct_handles: None, binary_function_handles: None, binary_function_instantiations: None, binary_signatures: None, binary_constant_pool: None, binary_identifiers: None, binary_address_identifiers: None, binary_struct_defs: None, binary_struct_def_instantiations: None, binary_function_defs: None, binary_field_handles: None, binary_field_instantiations: None, binary_friend_decls: None, binary_enum_defs: None, binary_enum_def_instantiations: None, binary_variant_handles: None, binary_variant_instantiation_handles: None, binary_format_limits_profile: None, max_move_object_size: Some(250 * 1024), max_move_package_size: Some(100 * 1024), max_publish_or_upgrade_per_ptb: None, max_tx_gas: Some(10_000_000_000), max_gas_price: Some(100_000), max_gas_price_rgp_factor_for_aborted_transactions: None, max_gas_computation_bucket: Some(5_000_000), max_loop_depth: Some(5), max_generic_instantiation_length: Some(32), max_function_parameters: Some(128), max_basic_blocks: Some(1024), max_value_stack_size: Some(1024), max_type_nodes: Some(256), max_generic_instantiation_type_nodes_per_function: None, max_generic_instantiation_type_nodes_per_module: None, max_accumulator_type_nodes: None, max_push_size: Some(10000), max_struct_definitions: Some(200), max_function_definitions: Some(1000), max_fields_in_struct: Some(32), max_dependency_depth: Some(100), max_num_event_emit: Some(256), max_num_accumulator_events: None, max_num_new_move_object_ids: Some(2048), max_num_new_move_object_ids_system_tx: Some(2048 * 16), max_num_deleted_move_object_ids: Some(2048), max_num_deleted_move_object_ids_system_tx: Some(2048 * 16), max_num_transferred_move_object_ids: Some(2048), max_num_transferred_move_object_ids_system_tx: Some(2048 * 16), max_event_emit_size: Some(250 * 1024), max_move_vector_len: Some(256 * 1024), max_type_to_layout_nodes: None, max_ptb_value_size: None, max_back_edges_per_function: Some(10_000), max_back_edges_per_module: Some(10_000), max_verifier_meter_ticks_per_function: Some(6_000_000), max_meter_ticks_per_module: Some(6_000_000), max_meter_ticks_per_package: None, object_runtime_max_num_cached_objects: Some(1000), object_runtime_max_num_cached_objects_system_tx: Some(1000 * 16), object_runtime_max_loaded_child_value_size: None, object_runtime_max_num_store_entries: Some(1000), object_runtime_max_num_store_entries_system_tx: Some(1000 * 16), base_tx_cost_fixed: Some(110_000), package_publish_cost_fixed: Some(1_000), base_tx_cost_per_byte: Some(0), package_publish_cost_per_byte: Some(80), package_publish_charge_fixed: None, package_publish_charge_per_module: None, package_publish_charge_per_dependency: None, obj_access_cost_read_per_byte: Some(15), obj_access_cost_read_per_package_kb: None, obj_access_cost_mutate_per_byte: Some(40), obj_access_cost_delete_per_byte: Some(40), obj_access_cost_verify_per_byte: Some(200), obj_data_cost_refundable: Some(100), obj_metadata_cost_non_refundable: Some(50), gas_model_version: Some(1), storage_rebate_rate: Some(9900), storage_fund_reinvest_rate: Some(500), reward_slashing_rate: Some(5000), storage_gas_price: Some(1), accumulator_object_storage_cost: None, max_transactions_per_checkpoint: Some(10_000), max_checkpoint_size_bytes: Some(30 * 1024 * 1024), // For now, perform upgrades with a bare quorum of validators. // MUSTFIX: This number should be increased to at least 2000 (20%) for mainnet. buffer_stake_for_protocol_upgrade_bps: Some(0), // === Native Function Costs === // `address` module // Cost params for the Move native function `address::from_bytes(bytes: vector)` address_from_bytes_cost_base: Some(52), // Cost params for the Move native function `address::to_u256(address): u256` address_to_u256_cost_base: Some(52), // Cost params for the Move native function `address::from_u256(u256): address` address_from_u256_cost_base: Some(52), // `config` module // Cost params for the Move native function `read_setting_impl`` config_read_setting_impl_cost_base: None, config_read_setting_impl_cost_per_byte: None, package_original_package_id_impl_cost_base: None, package_original_package_id_impl_cost_per_byte: None, // `dynamic_field` module // Cost params for the Move native function `hash_type_and_key(parent: address, k: K): address` dynamic_field_hash_type_and_key_cost_base: Some(100), dynamic_field_hash_type_and_key_type_cost_per_byte: Some(2), dynamic_field_hash_type_and_key_value_cost_per_byte: Some(2), dynamic_field_hash_type_and_key_type_tag_cost_per_byte: Some(2), // Cost params for the Move native function `add_child_object(parent: address, child: Child)` dynamic_field_add_child_object_cost_base: Some(100), dynamic_field_add_child_object_type_cost_per_byte: Some(10), dynamic_field_add_child_object_value_cost_per_byte: Some(10), dynamic_field_add_child_object_struct_tag_cost_per_byte: Some(10), // Cost params for the Move native function `borrow_child_object_mut(parent: &mut UID, id: address): &mut Child` dynamic_field_borrow_child_object_cost_base: Some(100), dynamic_field_borrow_child_object_child_ref_cost_per_byte: Some(10), dynamic_field_borrow_child_object_type_cost_per_byte: Some(10), // Cost params for the Move native function `remove_child_object(parent: address, id: address): Child` dynamic_field_remove_child_object_cost_base: Some(100), dynamic_field_remove_child_object_child_cost_per_byte: Some(2), dynamic_field_remove_child_object_type_cost_per_byte: Some(2), // Cost params for the Move native function `has_child_object(parent: address, id: address): bool` dynamic_field_has_child_object_cost_base: Some(100), // Cost params for the Move native function `has_child_object_with_ty(parent: address, id: address): bool` dynamic_field_has_child_object_with_ty_cost_base: Some(100), dynamic_field_has_child_object_with_ty_type_cost_per_byte: Some(2), dynamic_field_has_child_object_with_ty_type_tag_cost_per_byte: Some(2), // `scratch` module: introduced in protocol version 130 scratch_add_cost_base: None, scratch_read_cost_base: None, scratch_read_value_cost: None, scratch_remove_cost_base: None, scratch_exists_cost_base: None, scratch_exists_with_type_cost_base: None, scratch_exists_with_type_type_cost: None, max_scratch_pad_size: None, // `event` module // Cost params for the Move native function `event::emit(event: T)` event_emit_cost_base: Some(52), event_emit_value_size_derivation_cost_per_byte: Some(2), event_emit_tag_size_derivation_cost_per_byte: Some(5), event_emit_output_cost_per_byte: Some(10), event_emit_auth_stream_cost: None, // `funds_accumulator` module: introduced in protocol version 137. reserve_object_funds_for_withdrawal_cost_base: None, reserve_object_funds_for_withdrawal_cold_read_cost: None, // `object` module // Cost params for the Move native function `borrow_uid(obj: &T): &UID` object_borrow_uid_cost_base: Some(52), // Cost params for the Move native function `delete_impl(id: address)` object_delete_impl_cost_base: Some(52), // Cost params for the Move native function `record_new_uid(id: address)` object_record_new_uid_cost_base: Some(52), // Cost params for the Move native function // `record_new_uid_from_hash(parent: address, bytes: address)`. Introduced in v131. object_record_new_uid_from_hash_cost_base: None, // Cost params for the Move native function `is_shared_input_impl(id: address): bool`. // Introduced in v142. object_is_shared_input_cost_base: None, // `transfer` module // Cost params for the Move native function `transfer_impl(obj: T, recipient: address)` transfer_transfer_internal_cost_base: Some(52), // Cost params for the Move native function `party_transfer_impl(obj: T, party_members: vector
)` transfer_party_transfer_internal_cost_base: None, // Cost params for the Move native function `freeze_object(obj: T)` transfer_freeze_object_cost_base: Some(52), // Cost params for the Move native function `share_object(obj: T)` transfer_share_object_cost_base: Some(52), transfer_receive_object_cost_base: None, transfer_receive_object_type_cost_per_byte: None, transfer_receive_object_cost_per_byte: None, // `tx_context` module // Cost params for the Move native function `transfer_impl(obj: T, recipient: address)` tx_context_derive_id_cost_base: Some(52), tx_context_fresh_id_cost_base: None, tx_context_sender_cost_base: None, tx_context_epoch_cost_base: None, tx_context_epoch_timestamp_ms_cost_base: None, tx_context_sponsor_cost_base: None, tx_context_rgp_cost_base: None, tx_context_gas_price_cost_base: None, tx_context_gas_budget_cost_base: None, tx_context_ids_created_cost_base: None, tx_context_replace_cost_base: None, // `clock` module clock_borrow_cost_base: None, // `types` module // Cost params for the Move native function `is_one_time_witness(_: &T): bool` types_is_one_time_witness_cost_base: Some(52), types_is_one_time_witness_type_tag_cost_per_byte: Some(2), types_is_one_time_witness_type_cost_per_byte: Some(2), // `validator` module // Cost params for the Move native function `validate_metadata_bcs(metadata: vector)` validator_validate_metadata_cost_base: Some(52), validator_validate_metadata_data_cost_per_byte: Some(2), // Crypto crypto_invalid_arguments_cost: Some(100), // bls12381::bls12381_min_pk_verify bls12381_bls12381_min_sig_verify_cost_base: Some(52), bls12381_bls12381_min_sig_verify_msg_cost_per_byte: Some(2), bls12381_bls12381_min_sig_verify_msg_cost_per_block: Some(2), // bls12381::bls12381_min_pk_verify bls12381_bls12381_min_pk_verify_cost_base: Some(52), bls12381_bls12381_min_pk_verify_msg_cost_per_byte: Some(2), bls12381_bls12381_min_pk_verify_msg_cost_per_block: Some(2), // ecdsa_k1::ecrecover ecdsa_k1_ecrecover_keccak256_cost_base: Some(52), ecdsa_k1_ecrecover_keccak256_msg_cost_per_byte: Some(2), ecdsa_k1_ecrecover_keccak256_msg_cost_per_block: Some(2), ecdsa_k1_ecrecover_sha256_cost_base: Some(52), ecdsa_k1_ecrecover_sha256_msg_cost_per_byte: Some(2), ecdsa_k1_ecrecover_sha256_msg_cost_per_block: Some(2), // ecdsa_k1::decompress_pubkey ecdsa_k1_decompress_pubkey_cost_base: Some(52), // ecdsa_k1::secp256k1_verify ecdsa_k1_secp256k1_verify_keccak256_cost_base: Some(52), ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_byte: Some(2), ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_block: Some(2), ecdsa_k1_secp256k1_verify_sha256_cost_base: Some(52), ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_byte: Some(2), ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_block: Some(2), // ecdsa_r1::ecrecover ecdsa_r1_ecrecover_keccak256_cost_base: Some(52), ecdsa_r1_ecrecover_keccak256_msg_cost_per_byte: Some(2), ecdsa_r1_ecrecover_keccak256_msg_cost_per_block: Some(2), ecdsa_r1_ecrecover_sha256_cost_base: Some(52), ecdsa_r1_ecrecover_sha256_msg_cost_per_byte: Some(2), ecdsa_r1_ecrecover_sha256_msg_cost_per_block: Some(2), // ecdsa_r1::secp256k1_verify ecdsa_r1_secp256r1_verify_keccak256_cost_base: Some(52), ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_byte: Some(2), ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_block: Some(2), ecdsa_r1_secp256r1_verify_sha256_cost_base: Some(52), ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_byte: Some(2), ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_block: Some(2), // ecvrf::verify ecvrf_ecvrf_verify_cost_base: Some(52), ecvrf_ecvrf_verify_alpha_string_cost_per_byte: Some(2), ecvrf_ecvrf_verify_alpha_string_cost_per_block: Some(2), // ed25519 ed25519_ed25519_verify_cost_base: Some(52), ed25519_ed25519_verify_msg_cost_per_byte: Some(2), ed25519_ed25519_verify_msg_cost_per_block: Some(2), // groth16::prepare_verifying_key groth16_prepare_verifying_key_bls12381_cost_base: Some(52), groth16_prepare_verifying_key_bn254_cost_base: Some(52), // groth16::verify_groth16_proof_internal groth16_verify_groth16_proof_internal_bls12381_cost_base: Some(52), groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input: Some(2), groth16_verify_groth16_proof_internal_bn254_cost_base: Some(52), groth16_verify_groth16_proof_internal_bn254_cost_per_public_input: Some(2), groth16_verify_groth16_proof_internal_public_input_cost_per_byte: Some(2), // hash::blake2b256 hash_blake2b256_cost_base: Some(52), hash_blake2b256_data_cost_per_byte: Some(2), hash_blake2b256_data_cost_per_block: Some(2), // hash::keccak256 hash_keccak256_cost_base: Some(52), hash_keccak256_data_cost_per_byte: Some(2), hash_keccak256_data_cost_per_block: Some(2), poseidon_bn254_cost_base: None, poseidon_bn254_cost_per_block: None, // hmac::hmac_sha3_256 hmac_hmac_sha3_256_cost_base: Some(52), hmac_hmac_sha3_256_input_cost_per_byte: Some(2), hmac_hmac_sha3_256_input_cost_per_block: Some(2), // group ops group_ops_bls12381_decode_scalar_cost: None, group_ops_bls12381_decode_g1_cost: None, group_ops_bls12381_decode_g2_cost: None, group_ops_bls12381_decode_gt_cost: None, group_ops_bls12381_scalar_add_cost: None, group_ops_bls12381_g1_add_cost: None, group_ops_bls12381_g2_add_cost: None, group_ops_bls12381_gt_add_cost: None, group_ops_bls12381_scalar_sub_cost: None, group_ops_bls12381_g1_sub_cost: None, group_ops_bls12381_g2_sub_cost: None, group_ops_bls12381_gt_sub_cost: None, group_ops_bls12381_scalar_mul_cost: None, group_ops_bls12381_g1_mul_cost: None, group_ops_bls12381_g2_mul_cost: None, group_ops_bls12381_gt_mul_cost: None, group_ops_bls12381_scalar_div_cost: None, group_ops_bls12381_g1_div_cost: None, group_ops_bls12381_g2_div_cost: None, group_ops_bls12381_gt_div_cost: None, group_ops_bls12381_g1_hash_to_base_cost: None, group_ops_bls12381_g2_hash_to_base_cost: None, group_ops_bls12381_g1_hash_to_cost_per_byte: None, group_ops_bls12381_g2_hash_to_cost_per_byte: None, group_ops_bls12381_g1_msm_base_cost: None, group_ops_bls12381_g2_msm_base_cost: None, group_ops_bls12381_g1_msm_base_cost_per_input: None, group_ops_bls12381_g2_msm_base_cost_per_input: None, group_ops_bls12381_msm_max_len: None, group_ops_bls12381_pairing_cost: None, group_ops_bls12381_g1_to_uncompressed_g1_cost: None, group_ops_bls12381_uncompressed_g1_to_g1_cost: None, group_ops_bls12381_uncompressed_g1_sum_base_cost: None, group_ops_bls12381_uncompressed_g1_sum_cost_per_term: None, group_ops_bls12381_uncompressed_g1_sum_max_terms: None, group_ops_ristretto_decode_scalar_cost: None, group_ops_ristretto_decode_point_cost: None, group_ops_ristretto_scalar_add_cost: None, group_ops_ristretto_point_add_cost: None, group_ops_ristretto_scalar_sub_cost: None, group_ops_ristretto_point_sub_cost: None, group_ops_ristretto_scalar_mul_cost: None, group_ops_ristretto_point_mul_cost: None, group_ops_ristretto_scalar_div_cost: None, group_ops_ristretto_point_div_cost: None, verify_bulletproofs_ristretto255_base_cost: None, verify_bulletproofs_ristretto255_cost_per_bit_and_commitment: None, max_bulletproofs_total_bits: None, // zklogin::check_zklogin_id check_zklogin_id_cost_base: None, // zklogin::check_zklogin_issuer check_zklogin_issuer_cost_base: None, vdf_verify_vdf_cost: None, vdf_hash_to_input_cost: None, // nitro_attestation::verify_nitro_attestation nitro_attestation_parse_base_cost: None, nitro_attestation_parse_cost_per_byte: None, nitro_attestation_verify_base_cost: None, nitro_attestation_verify_cost_per_cert: None, layout_node_cost: None, layout_node_cost_large_layout_threshold: None, bcs_per_input_abstract_unit_cost: None, bcs_per_byte_serialized_cost: None, bcs_legacy_min_output_size_cost: None, bcs_failure_cost: None, hash_sha2_256_base_cost: None, hash_sha2_256_per_byte_cost: None, hash_sha2_256_legacy_min_input_len_cost: None, hash_sha3_256_base_cost: None, hash_sha3_256_per_byte_cost: None, hash_sha3_256_legacy_min_input_len_cost: None, type_name_get_base_cost: None, type_name_get_per_byte_cost: None, type_name_id_base_cost: None, string_check_utf8_base_cost: None, string_check_utf8_per_byte_cost: None, string_is_char_boundary_base_cost: None, string_sub_string_base_cost: None, string_sub_string_per_byte_cost: None, string_index_of_base_cost: None, string_index_of_per_byte_pattern_cost: None, string_index_of_per_byte_searched_cost: None, vector_empty_base_cost: None, vector_length_base_cost: None, vector_push_back_base_cost: None, vector_push_back_legacy_per_abstract_memory_unit_cost: None, vector_borrow_base_cost: None, vector_pop_back_base_cost: None, vector_destroy_empty_base_cost: None, vector_swap_base_cost: None, vector_reverse_base_cost: None, vector_reverse_per_elem_cost: None, vector_keep_range_base_cost: None, vector_keep_range_per_dropped_elem_cost: None, vector_keep_range_per_moved_elem_cost: None, vector_copy_range_base_cost: None, vector_copy_range_per_abstract_memory_unit_cost: None, vector_replace_range_base_cost: None, vector_replace_range_per_elem_cost: None, debug_print_base_cost: None, debug_print_stack_trace_base_cost: None, max_size_written_objects: None, max_size_written_objects_system_tx: None, // ==== Ephemeral (consensus only) params deleted ==== // Const params for consensus scoring decision // scoring_decision_mad_divisor: None, // scoring_decision_cutoff_value: None, // Limits the length of a Move identifier max_move_identifier_len: None, max_move_value_depth: None, package_arena_size_in_bytes: None, max_move_enum_variants: None, gas_rounding_step: None, execution_version: None, max_event_emit_size_total: None, consensus_bad_nodes_stake_threshold: None, max_jwk_votes_per_validator_per_epoch: None, max_age_of_jwk_in_epochs: None, random_beacon_reduction_allowed_delta: None, random_beacon_reduction_lower_bound: None, random_beacon_dkg_timeout_round: None, random_beacon_min_round_interval_ms: None, random_beacon_dkg_version: None, consensus_max_transaction_size_bytes: None, consensus_max_transactions_in_block_bytes: None, consensus_max_num_transactions_in_block: None, consensus_voting_rounds: None, max_accumulated_txn_cost_per_object_in_narwhal_commit: None, max_deferral_rounds_for_congestion_control: None, epoch_close_deadline_ms: None, max_txn_cost_overage_per_object_in_commit: None, allowed_txn_cost_overage_burst_per_object_in_commit: None, min_checkpoint_interval_ms: None, checkpoint_summary_version_specific_data: None, max_soft_bundle_size: None, bridge_should_try_to_finalize_committee: None, max_accumulated_txn_cost_per_object_in_mysticeti_commit: None, max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit: None, consensus_gc_depth: None, gas_budget_based_txn_cost_cap_factor: None, gas_budget_based_txn_cost_absolute_cap_commit_count: None, sip_45_consensus_amplification_threshold: None, staggered_submission_signal_window_commits: None, staggered_submission_signal_min_excess_copies_per_commit: None, staggered_submission_signal_min_consensus_user_transactions_per_commit: None, staggered_submission_signal_exit_dwell_commits: None, staggered_submission_signal_band1_enter_ratio_bps: None, staggered_submission_signal_band1_exit_ratio_bps: None, staggered_submission_signal_band2_enter_ratio_bps: None, staggered_submission_signal_band2_exit_ratio_bps: None, use_object_per_epoch_marker_table_v2: None, consensus_commit_rate_estimation_window_size: None, aliased_addresses: vec![], translation_per_command_base_charge: None, translation_per_input_base_charge: None, translation_pure_input_per_byte_charge: None, translation_per_type_node_charge: None, translation_per_reference_node_charge: None, translation_per_linkage_entry_charge: None, translation_per_live_reference_charge: None, max_ptb_live_references: None, max_ptb_returned_references: None, max_ptb_total_returned_references: None, max_updates_per_settlement_txn: None, gasless_max_computation_units: None, gasless_allowed_token_types: None, gasless_max_unused_inputs: None, gasless_max_pure_input_bytes: None, gasless_max_tps: None, include_special_package_amendments: None, gasless_max_tx_size_bytes: None, // When adding a new constant, set it to None in the earliest version, like this: // new_constant: None, }; for cur in 2..=version.0 { match cur { 1 => unreachable!(), 2 => { cfg.feature_flags.advance_epoch_start_time_in_safe_mode = true; } 3 => { // changes for gas model cfg.gas_model_version = Some(2); // max gas budget is in MIST and an absolute value 50SUI cfg.max_tx_gas = Some(50_000_000_000); // min gas budget is in MIST and an absolute value 2000MIST or 0.000002SUI cfg.base_tx_cost_fixed = Some(2_000); // storage gas price multiplier cfg.storage_gas_price = Some(76); cfg.feature_flags.loaded_child_objects_fixed = true; // max size of written objects during a TXn // this is a sum of all objects written during a TXn cfg.max_size_written_objects = Some(5 * 1000 * 1000); // max size of written objects during a system TXn to allow for larger writes // akin to `max_size_written_objects` but for system TXns cfg.max_size_written_objects_system_tx = Some(50 * 1000 * 1000); cfg.feature_flags.package_upgrades = true; } // This is the first protocol version currently possible. // Mainnet starts with version 4. Previous versions are pre mainnet and have // all been wiped out. // Every other chain is after version 4. 4 => { // Change reward slashing rate to 100%. cfg.reward_slashing_rate = Some(10000); // protect old and new lookup for object version cfg.gas_model_version = Some(3); } 5 => { cfg.feature_flags.missing_type_is_compatibility_error = true; cfg.gas_model_version = Some(4); cfg.feature_flags.scoring_decision_with_validity_cutoff = true; // ==== Ephemeral (consensus only) params deleted ==== // cfg.scoring_decision_mad_divisor = Some(2.3); // cfg.scoring_decision_cutoff_value = Some(2.5); } 6 => { cfg.gas_model_version = Some(5); cfg.buffer_stake_for_protocol_upgrade_bps = Some(5000); cfg.feature_flags.consensus_order_end_of_epoch_last = true; } 7 => { cfg.feature_flags.disallow_adding_abilities_on_upgrade = true; cfg.feature_flags .disable_invariant_violation_check_in_swap_loc = true; cfg.feature_flags.ban_entry_init = true; cfg.feature_flags.package_digest_hash_module = true; } 8 => { cfg.feature_flags .disallow_change_struct_type_params_on_upgrade = true; } 9 => { // Limits the length of a Move identifier cfg.max_move_identifier_len = Some(128); cfg.feature_flags.no_extraneous_module_bytes = true; cfg.feature_flags .advance_to_highest_supported_protocol_version = true; } 10 => { cfg.max_verifier_meter_ticks_per_function = Some(16_000_000); cfg.max_meter_ticks_per_module = Some(16_000_000); } 11 => { cfg.max_move_value_depth = Some(128); } 12 => { cfg.feature_flags.narwhal_versioned_metadata = true; if chain != Chain::Mainnet { cfg.feature_flags.commit_root_state_digest = true; } if chain != Chain::Mainnet && chain != Chain::Testnet { cfg.feature_flags.zklogin_auth = true; } } 13 => {} 14 => { cfg.gas_rounding_step = Some(1_000); cfg.gas_model_version = Some(6); } 15 => { cfg.feature_flags.consensus_transaction_ordering = ConsensusTransactionOrdering::ByGasPrice; } 16 => { cfg.feature_flags.simplified_unwrap_then_delete = true; } 17 => { cfg.feature_flags.upgraded_multisig_supported = true; } 18 => { cfg.execution_version = Some(1); // Following flags are implied by this execution version. Once support for earlier // protocol versions is dropped, these flags can be removed: // cfg.feature_flags.package_upgrades = true; // cfg.feature_flags.disallow_adding_abilities_on_upgrade = true; // cfg.feature_flags.disallow_change_struct_type_params_on_upgrade = true; // cfg.feature_flags.loaded_child_objects_fixed = true; // cfg.feature_flags.ban_entry_init = true; // cfg.feature_flags.pack_digest_hash_modules = true; cfg.feature_flags.txn_base_cost_as_multiplier = true; // this is a multiplier of the gas price cfg.base_tx_cost_fixed = Some(1_000); } 19 => { cfg.max_num_event_emit = Some(1024); // We maintain the same total size limit for events, but increase the number of // events that can be emitted. cfg.max_event_emit_size_total = Some( 256 /* former event count limit */ * 250 * 1024, /* size limit per event */ ); } 20 => { cfg.feature_flags.commit_root_state_digest = true; if chain != Chain::Mainnet { cfg.feature_flags.narwhal_new_leader_election_schedule = true; cfg.consensus_bad_nodes_stake_threshold = Some(20); } } 21 => { if chain != Chain::Mainnet { cfg.feature_flags.zklogin_supported_providers = BTreeSet::from([ "Google".to_string(), "Facebook".to_string(), "Twitch".to_string(), ]); } } 22 => { cfg.feature_flags.loaded_child_object_format = true; } 23 => { cfg.feature_flags.loaded_child_object_format_type = true; cfg.feature_flags.narwhal_new_leader_election_schedule = true; // Taking a baby step approach, we consider only 20% by stake as bad nodes so we // have a 80% by stake of nodes participating in the leader committee. That allow // us for more redundancy in case we have validators under performing - since the // responsibility is shared amongst more nodes. We can increase that once we do have // higher confidence. cfg.consensus_bad_nodes_stake_threshold = Some(20); } 24 => { cfg.feature_flags.simple_conservation_checks = true; cfg.max_publish_or_upgrade_per_ptb = Some(5); cfg.feature_flags.end_of_epoch_transaction_supported = true; if chain != Chain::Mainnet { cfg.feature_flags.enable_jwk_consensus_updates = true; // Max of 10 votes per hour cfg.max_jwk_votes_per_validator_per_epoch = Some(240); cfg.max_age_of_jwk_in_epochs = Some(1); } } 25 => { // Enable zkLogin for all providers in all networks. cfg.feature_flags.zklogin_supported_providers = BTreeSet::from([ "Google".to_string(), "Facebook".to_string(), "Twitch".to_string(), ]); cfg.feature_flags.zklogin_auth = true; // Enable jwk consensus updates cfg.feature_flags.enable_jwk_consensus_updates = true; cfg.max_jwk_votes_per_validator_per_epoch = Some(240); cfg.max_age_of_jwk_in_epochs = Some(1); } 26 => { cfg.gas_model_version = Some(7); // Only enable receiving objects in devnet if chain != Chain::Mainnet && chain != Chain::Testnet { cfg.transfer_receive_object_cost_base = Some(52); cfg.feature_flags.receive_objects = true; } } 27 => { cfg.gas_model_version = Some(8); } 28 => { // zklogin::check_zklogin_id cfg.check_zklogin_id_cost_base = Some(200); // zklogin::check_zklogin_issuer cfg.check_zklogin_issuer_cost_base = Some(200); // Only enable effects v2 on devnet. if chain != Chain::Mainnet && chain != Chain::Testnet { cfg.feature_flags.enable_effects_v2 = true; } } 29 => { cfg.feature_flags.verify_legacy_zklogin_address = true; } 30 => { // Only enable nw certificate v2 on testnet. if chain != Chain::Mainnet { cfg.feature_flags.narwhal_certificate_v2 = true; } cfg.random_beacon_reduction_allowed_delta = Some(800); // Only enable effects v2 on devnet and testnet. if chain != Chain::Mainnet { cfg.feature_flags.enable_effects_v2 = true; } // zklogin_supported_providers config is deprecated, zklogin // signature verifier will use the fetched jwk map to determine // whether the provider is supported based on node config. cfg.feature_flags.zklogin_supported_providers = BTreeSet::default(); cfg.feature_flags.recompute_has_public_transfer_in_execution = true; } 31 => { cfg.execution_version = Some(2); // Only enable shared object deletion on devnet if chain != Chain::Mainnet && chain != Chain::Testnet { cfg.feature_flags.shared_object_deletion = true; } } 32 => { // enable zklogin in multisig in devnet and testnet if chain != Chain::Mainnet { cfg.feature_flags.accept_zklogin_in_multisig = true; } // enable receiving objects in devnet and testnet if chain != Chain::Mainnet { cfg.transfer_receive_object_cost_base = Some(52); cfg.feature_flags.receive_objects = true; } // Only enable random beacon on devnet if chain != Chain::Mainnet && chain != Chain::Testnet { cfg.feature_flags.random_beacon = true; cfg.random_beacon_reduction_lower_bound = Some(1600); cfg.random_beacon_dkg_timeout_round = Some(3000); cfg.random_beacon_min_round_interval_ms = Some(150); } // Only enable consensus digest in consensus commit prologue in devnet. if chain != Chain::Testnet && chain != Chain::Mainnet { cfg.feature_flags.include_consensus_digest_in_prologue = true; } // enable nw cert v2 on mainnet cfg.feature_flags.narwhal_certificate_v2 = true; } 33 => { cfg.feature_flags.hardened_otw_check = true; cfg.feature_flags.allow_receiving_object_id = true; // Enable transfer-to-object in mainnet cfg.transfer_receive_object_cost_base = Some(52); cfg.feature_flags.receive_objects = true; // Enable shared object deletion in testnet and devnet if chain != Chain::Mainnet { cfg.feature_flags.shared_object_deletion = true; } cfg.feature_flags.enable_effects_v2 = true; } 34 => {} 35 => { // Add costs for poseidon::poseidon_bn254 if chain != Chain::Mainnet && chain != Chain::Testnet { cfg.feature_flags.enable_poseidon = true; cfg.poseidon_bn254_cost_base = Some(260); cfg.poseidon_bn254_cost_per_block = Some(10); } cfg.feature_flags.enable_coin_deny_list = true; } 36 => { // Only enable group ops on devnet if chain != Chain::Mainnet && chain != Chain::Testnet { cfg.feature_flags.enable_group_ops_native_functions = true; cfg.feature_flags.enable_group_ops_native_function_msm = true; // Next values are arbitrary in a similar way as the other crypto native functions. cfg.group_ops_bls12381_decode_scalar_cost = Some(52); cfg.group_ops_bls12381_decode_g1_cost = Some(52); cfg.group_ops_bls12381_decode_g2_cost = Some(52); cfg.group_ops_bls12381_decode_gt_cost = Some(52); cfg.group_ops_bls12381_scalar_add_cost = Some(52); cfg.group_ops_bls12381_g1_add_cost = Some(52); cfg.group_ops_bls12381_g2_add_cost = Some(52); cfg.group_ops_bls12381_gt_add_cost = Some(52); cfg.group_ops_bls12381_scalar_sub_cost = Some(52); cfg.group_ops_bls12381_g1_sub_cost = Some(52); cfg.group_ops_bls12381_g2_sub_cost = Some(52); cfg.group_ops_bls12381_gt_sub_cost = Some(52); cfg.group_ops_bls12381_scalar_mul_cost = Some(52); cfg.group_ops_bls12381_g1_mul_cost = Some(52); cfg.group_ops_bls12381_g2_mul_cost = Some(52); cfg.group_ops_bls12381_gt_mul_cost = Some(52); cfg.group_ops_bls12381_scalar_div_cost = Some(52); cfg.group_ops_bls12381_g1_div_cost = Some(52); cfg.group_ops_bls12381_g2_div_cost = Some(52); cfg.group_ops_bls12381_gt_div_cost = Some(52); cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(52); cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(52); cfg.group_ops_bls12381_g1_hash_to_cost_per_byte = Some(2); cfg.group_ops_bls12381_g2_hash_to_cost_per_byte = Some(2); cfg.group_ops_bls12381_g1_msm_base_cost = Some(52); cfg.group_ops_bls12381_g2_msm_base_cost = Some(52); cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(52); cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(52); cfg.group_ops_bls12381_msm_max_len = Some(32); cfg.group_ops_bls12381_pairing_cost = Some(52); } // Enable shared object deletion on all networks. cfg.feature_flags.shared_object_deletion = true; cfg.consensus_max_transaction_size_bytes = Some(256 * 1024); // 256KB cfg.consensus_max_transactions_in_block_bytes = Some(6 * 1_024 * 1024); // 6 MB } 37 => { cfg.feature_flags.reject_mutable_random_on_entry_functions = true; // Enable consensus digest in consensus commit prologue in testnet and devnet. if chain != Chain::Mainnet { cfg.feature_flags.include_consensus_digest_in_prologue = true; } } 38 => { cfg.binary_module_handles = Some(100); cfg.binary_struct_handles = Some(300); cfg.binary_function_handles = Some(1500); cfg.binary_function_instantiations = Some(750); cfg.binary_signatures = Some(1000); // constants and identifiers are proportional to the binary size, // and they vastly depend on the code, so we are leaving them // reasonably high cfg.binary_constant_pool = Some(4000); cfg.binary_identifiers = Some(10000); cfg.binary_address_identifiers = Some(100); cfg.binary_struct_defs = Some(200); cfg.binary_struct_def_instantiations = Some(100); cfg.binary_function_defs = Some(1000); cfg.binary_field_handles = Some(500); cfg.binary_field_instantiations = Some(250); cfg.binary_friend_decls = Some(100); // reduce dependencies maximum cfg.max_package_dependencies = Some(32); cfg.max_modules_in_publish = Some(64); // bump execution version cfg.execution_version = Some(3); } 39 => { // It is important that we keep this protocol version blank due to an issue with random.move. } 40 => {} 41 => { // Enable group ops and all networks (but not msm) cfg.feature_flags.enable_group_ops_native_functions = true; // Next values are arbitrary in a similar way as the other crypto native functions. cfg.group_ops_bls12381_decode_scalar_cost = Some(52); cfg.group_ops_bls12381_decode_g1_cost = Some(52); cfg.group_ops_bls12381_decode_g2_cost = Some(52); cfg.group_ops_bls12381_decode_gt_cost = Some(52); cfg.group_ops_bls12381_scalar_add_cost = Some(52); cfg.group_ops_bls12381_g1_add_cost = Some(52); cfg.group_ops_bls12381_g2_add_cost = Some(52); cfg.group_ops_bls12381_gt_add_cost = Some(52); cfg.group_ops_bls12381_scalar_sub_cost = Some(52); cfg.group_ops_bls12381_g1_sub_cost = Some(52); cfg.group_ops_bls12381_g2_sub_cost = Some(52); cfg.group_ops_bls12381_gt_sub_cost = Some(52); cfg.group_ops_bls12381_scalar_mul_cost = Some(52); cfg.group_ops_bls12381_g1_mul_cost = Some(52); cfg.group_ops_bls12381_g2_mul_cost = Some(52); cfg.group_ops_bls12381_gt_mul_cost = Some(52); cfg.group_ops_bls12381_scalar_div_cost = Some(52); cfg.group_ops_bls12381_g1_div_cost = Some(52); cfg.group_ops_bls12381_g2_div_cost = Some(52); cfg.group_ops_bls12381_gt_div_cost = Some(52); cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(52); cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(52); cfg.group_ops_bls12381_g1_hash_to_cost_per_byte = Some(2); cfg.group_ops_bls12381_g2_hash_to_cost_per_byte = Some(2); cfg.group_ops_bls12381_g1_msm_base_cost = Some(52); cfg.group_ops_bls12381_g2_msm_base_cost = Some(52); cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(52); cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(52); cfg.group_ops_bls12381_msm_max_len = Some(32); cfg.group_ops_bls12381_pairing_cost = Some(52); } 42 => {} 43 => { cfg.feature_flags.zklogin_max_epoch_upper_bound_delta = Some(30); cfg.max_meter_ticks_per_package = Some(16_000_000); } 44 => { // Enable consensus digest in consensus commit prologue on all networks.. cfg.feature_flags.include_consensus_digest_in_prologue = true; // Switch between Narwhal and Mysticeti per epoch in tests, devnet and testnet. if chain != Chain::Mainnet { cfg.feature_flags.consensus_choice = ConsensusChoice::SwapEachEpoch; } } 45 => { // Use tonic networking for consensus, in tests and devnet. if chain != Chain::Testnet && chain != Chain::Mainnet { cfg.feature_flags.consensus_network = ConsensusNetwork::Tonic; } if chain != Chain::Mainnet { // Enable leader scoring & schedule change on testnet for mysticeti. cfg.feature_flags.mysticeti_leader_scoring_and_schedule = true; } cfg.min_move_binary_format_version = Some(6); cfg.feature_flags.accept_zklogin_in_multisig = true; // Also bumps framework snapshot to fix binop issue. // enable bridge in devnet if chain != Chain::Mainnet && chain != Chain::Testnet { cfg.feature_flags.bridge = true; } } 46 => { // enable bridge in devnet and testnet if chain != Chain::Mainnet { cfg.feature_flags.bridge = true; } // Enable resharing at same initial version cfg.feature_flags.reshare_at_same_initial_version = true; } 47 => {} 48 => { // Use tonic networking for Mysticeti. cfg.feature_flags.consensus_network = ConsensusNetwork::Tonic; // Enable resolving abort code IDs to package ID instead of runtime module ID cfg.feature_flags.resolve_abort_locations_to_package_id = true; // Enable random beacon on testnet. if chain != Chain::Mainnet { cfg.feature_flags.random_beacon = true; cfg.random_beacon_reduction_lower_bound = Some(1600); cfg.random_beacon_dkg_timeout_round = Some(3000); cfg.random_beacon_min_round_interval_ms = Some(200); } // Enable the committed sub dag digest inclusion on the commit output cfg.feature_flags.mysticeti_use_committed_subdag_digest = true; } 49 => { if chain != Chain::Testnet && chain != Chain::Mainnet { cfg.move_binary_format_version = Some(7); } // enable vdf in devnet if chain != Chain::Mainnet && chain != Chain::Testnet { cfg.feature_flags.enable_vdf = true; // Set to 30x and 2x the cost of a signature verification for now. This // should be updated along with other native crypto functions. cfg.vdf_verify_vdf_cost = Some(1500); cfg.vdf_hash_to_input_cost = Some(100); } // Only enable consensus commit prologue V3 in devnet. if chain != Chain::Testnet && chain != Chain::Mainnet { cfg.feature_flags .record_consensus_determined_version_assignments_in_prologue = true; } // Run Mysticeti consensus in testnet. if chain != Chain::Mainnet { cfg.feature_flags.consensus_choice = ConsensusChoice::Mysticeti; } // Run Move verification on framework upgrades in its own VM cfg.feature_flags.fresh_vm_on_framework_upgrade = true; } 50 => { // Enable checkpoint batching in testnet. if chain != Chain::Mainnet { cfg.checkpoint_summary_version_specific_data = Some(1); cfg.min_checkpoint_interval_ms = Some(200); } // Only enable prepose consensus commit prologue in checkpoints in devnet. if chain != Chain::Testnet && chain != Chain::Mainnet { cfg.feature_flags .prepend_prologue_tx_in_consensus_commit_in_checkpoints = true; } cfg.feature_flags.mysticeti_num_leaders_per_round = Some(1); // Set max transaction deferral to 10 consensus rounds. cfg.max_deferral_rounds_for_congestion_control = Some(10); } 51 => { cfg.random_beacon_dkg_version = Some(1); if chain != Chain::Testnet && chain != Chain::Mainnet { cfg.feature_flags.enable_coin_deny_list_v2 = true; } } 52 => { if chain != Chain::Mainnet { cfg.feature_flags.soft_bundle = true; cfg.max_soft_bundle_size = Some(5); } cfg.config_read_setting_impl_cost_base = Some(100); cfg.config_read_setting_impl_cost_per_byte = Some(40); // Turn on shared object congestion control in devnet. if chain != Chain::Testnet && chain != Chain::Mainnet { cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(100); cfg.feature_flags.per_object_congestion_control_mode = PerObjectCongestionControlMode::TotalTxCount; } // Enable Mysticeti on mainnet. cfg.feature_flags.consensus_choice = ConsensusChoice::Mysticeti; // Enable leader scoring & schedule change on mainnet for mysticeti. cfg.feature_flags.mysticeti_leader_scoring_and_schedule = true; // Enable checkpoint batching on mainnet. cfg.checkpoint_summary_version_specific_data = Some(1); cfg.min_checkpoint_interval_ms = Some(200); // Enable consensus commit prologue V3 in testnet. if chain != Chain::Mainnet { cfg.feature_flags .record_consensus_determined_version_assignments_in_prologue = true; cfg.feature_flags .prepend_prologue_tx_in_consensus_commit_in_checkpoints = true; } // Turn on enums in testnet and devnet if chain != Chain::Mainnet { cfg.move_binary_format_version = Some(7); } if chain != Chain::Testnet && chain != Chain::Mainnet { cfg.feature_flags.passkey_auth = true; } cfg.feature_flags.enable_coin_deny_list_v2 = true; } 53 => { // Do not allow bridge committee to finalize on mainnet. cfg.bridge_should_try_to_finalize_committee = Some(chain != Chain::Mainnet); // Enable consensus commit prologue V3 on mainnet. cfg.feature_flags .record_consensus_determined_version_assignments_in_prologue = true; cfg.feature_flags .prepend_prologue_tx_in_consensus_commit_in_checkpoints = true; if chain == Chain::Unknown { cfg.feature_flags.authority_capabilities_v2 = true; } // Turns on shared object congestion control on testnet. if chain != Chain::Mainnet { cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(100); cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(10); cfg.feature_flags.per_object_congestion_control_mode = PerObjectCongestionControlMode::TotalTxCount; } // Adjust stdlib gas costs cfg.bcs_per_byte_serialized_cost = Some(2); cfg.bcs_legacy_min_output_size_cost = Some(1); cfg.bcs_failure_cost = Some(52); cfg.debug_print_base_cost = Some(52); cfg.debug_print_stack_trace_base_cost = Some(52); cfg.hash_sha2_256_base_cost = Some(52); cfg.hash_sha2_256_per_byte_cost = Some(2); cfg.hash_sha2_256_legacy_min_input_len_cost = Some(1); cfg.hash_sha3_256_base_cost = Some(52); cfg.hash_sha3_256_per_byte_cost = Some(2); cfg.hash_sha3_256_legacy_min_input_len_cost = Some(1); cfg.type_name_get_base_cost = Some(52); cfg.type_name_get_per_byte_cost = Some(2); cfg.string_check_utf8_base_cost = Some(52); cfg.string_check_utf8_per_byte_cost = Some(2); cfg.string_is_char_boundary_base_cost = Some(52); cfg.string_sub_string_base_cost = Some(52); cfg.string_sub_string_per_byte_cost = Some(2); cfg.string_index_of_base_cost = Some(52); cfg.string_index_of_per_byte_pattern_cost = Some(2); cfg.string_index_of_per_byte_searched_cost = Some(2); cfg.vector_empty_base_cost = Some(52); cfg.vector_length_base_cost = Some(52); cfg.vector_push_back_base_cost = Some(52); cfg.vector_push_back_legacy_per_abstract_memory_unit_cost = Some(2); cfg.vector_borrow_base_cost = Some(52); cfg.vector_pop_back_base_cost = Some(52); cfg.vector_destroy_empty_base_cost = Some(52); cfg.vector_swap_base_cost = Some(52); } 54 => { // Enable random beacon on mainnet. cfg.feature_flags.random_beacon = true; cfg.random_beacon_reduction_lower_bound = Some(1000); cfg.random_beacon_dkg_timeout_round = Some(3000); cfg.random_beacon_min_round_interval_ms = Some(500); // Turns on shared object congestion control on mainnet. cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(100); cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(10); cfg.feature_flags.per_object_congestion_control_mode = PerObjectCongestionControlMode::TotalTxCount; // Enable soft bundle on mainnet. cfg.feature_flags.soft_bundle = true; cfg.max_soft_bundle_size = Some(5); } 55 => { // Turn on enums mainnet cfg.move_binary_format_version = Some(7); // Assume 1KB per transaction and 500 transactions per block. cfg.consensus_max_transactions_in_block_bytes = Some(512 * 1024); // Assume 20_000 TPS * 5% max stake per validator / (minimum) 4 blocks per round = 250 transactions per block maximum // Using a higher limit that is 512, to account for bursty traffic and system transactions. cfg.consensus_max_num_transactions_in_block = Some(512); cfg.feature_flags.rethrow_serialization_type_layout_errors = true; } 56 => { if chain == Chain::Mainnet { cfg.feature_flags.bridge = true; } } 57 => { // Reduce minimum number of random beacon shares. cfg.random_beacon_reduction_lower_bound = Some(800); } 58 => { if chain == Chain::Mainnet { cfg.bridge_should_try_to_finalize_committee = Some(true); } if chain != Chain::Mainnet && chain != Chain::Testnet { // Enable distributed vote scoring for devnet cfg.feature_flags .consensus_distributed_vote_scoring_strategy = true; } } 59 => { // Enable round prober in consensus. cfg.feature_flags.consensus_round_prober = true; } 60 => { cfg.max_type_to_layout_nodes = Some(512); cfg.feature_flags.validate_identifier_inputs = true; } 61 => { if chain != Chain::Mainnet { // Enable distributed vote scoring for testnet cfg.feature_flags .consensus_distributed_vote_scoring_strategy = true; } // Further reduce minimum number of random beacon shares. cfg.random_beacon_reduction_lower_bound = Some(700); if chain != Chain::Mainnet && chain != Chain::Testnet { // Enable Mysticeti fastpath for devnet cfg.feature_flags.mysticeti_fastpath = true; } } 62 => { cfg.feature_flags.relocate_event_module = true; } 63 => { cfg.feature_flags.per_object_congestion_control_mode = PerObjectCongestionControlMode::TotalGasBudgetWithCap; cfg.gas_budget_based_txn_cost_cap_factor = Some(400_000); cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(18_500_000); cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(240_000_000); } 64 => { cfg.feature_flags.per_object_congestion_control_mode = PerObjectCongestionControlMode::TotalTxCount; cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(40); cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(3); } 65 => { // Enable distributed vote scoring for mainnet cfg.feature_flags .consensus_distributed_vote_scoring_strategy = true; } 66 => { if chain == Chain::Mainnet { // Revert the distributed vote scoring for mainnet (for one protocol upgrade) cfg.feature_flags .consensus_distributed_vote_scoring_strategy = false; } } 67 => { // Enable it once again. cfg.feature_flags .consensus_distributed_vote_scoring_strategy = true; } 68 => { cfg.group_ops_bls12381_g1_to_uncompressed_g1_cost = Some(26); cfg.group_ops_bls12381_uncompressed_g1_to_g1_cost = Some(52); cfg.group_ops_bls12381_uncompressed_g1_sum_base_cost = Some(26); cfg.group_ops_bls12381_uncompressed_g1_sum_cost_per_term = Some(13); cfg.group_ops_bls12381_uncompressed_g1_sum_max_terms = Some(2000); if chain != Chain::Mainnet && chain != Chain::Testnet { cfg.feature_flags.uncompressed_g1_group_elements = true; } cfg.feature_flags.per_object_congestion_control_mode = PerObjectCongestionControlMode::TotalGasBudgetWithCap; cfg.gas_budget_based_txn_cost_cap_factor = Some(400_000); cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(18_500_000); cfg.max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit = Some(3_700_000); // 20% of above cfg.max_txn_cost_overage_per_object_in_commit = Some(u64::MAX); cfg.gas_budget_based_txn_cost_absolute_cap_commit_count = Some(50); // Further reduce minimum number of random beacon shares. cfg.random_beacon_reduction_lower_bound = Some(500); cfg.feature_flags.disallow_new_modules_in_deps_only_packages = true; } 69 => { // Sets number of rounds allowed for fastpath voting in consensus. cfg.consensus_voting_rounds = Some(40); if chain != Chain::Mainnet && chain != Chain::Testnet { // Enable smart ancestor selection for devnet cfg.feature_flags.consensus_smart_ancestor_selection = true; } if chain != Chain::Mainnet { cfg.feature_flags.uncompressed_g1_group_elements = true; } } 70 => { if chain != Chain::Mainnet { // Enable smart ancestor selection for testnet cfg.feature_flags.consensus_smart_ancestor_selection = true; // Enable probing for accepted rounds in round prober for testnet cfg.feature_flags .consensus_round_prober_probe_accepted_rounds = true; } cfg.poseidon_bn254_cost_per_block = Some(388); cfg.gas_model_version = Some(9); cfg.feature_flags.native_charging_v2 = true; cfg.bls12381_bls12381_min_sig_verify_cost_base = Some(44064); cfg.bls12381_bls12381_min_pk_verify_cost_base = Some(49282); cfg.ecdsa_k1_secp256k1_verify_keccak256_cost_base = Some(1470); cfg.ecdsa_k1_secp256k1_verify_sha256_cost_base = Some(1470); cfg.ecdsa_r1_secp256r1_verify_sha256_cost_base = Some(4225); cfg.ecdsa_r1_secp256r1_verify_keccak256_cost_base = Some(4225); cfg.ecvrf_ecvrf_verify_cost_base = Some(4848); cfg.ed25519_ed25519_verify_cost_base = Some(1802); // Manually changed to be "under cost" cfg.ecdsa_r1_ecrecover_keccak256_cost_base = Some(1173); cfg.ecdsa_r1_ecrecover_sha256_cost_base = Some(1173); cfg.ecdsa_k1_ecrecover_keccak256_cost_base = Some(500); cfg.ecdsa_k1_ecrecover_sha256_cost_base = Some(500); cfg.groth16_prepare_verifying_key_bls12381_cost_base = Some(53838); cfg.groth16_prepare_verifying_key_bn254_cost_base = Some(82010); cfg.groth16_verify_groth16_proof_internal_bls12381_cost_base = Some(72090); cfg.groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input = Some(8213); cfg.groth16_verify_groth16_proof_internal_bn254_cost_base = Some(115502); cfg.groth16_verify_groth16_proof_internal_bn254_cost_per_public_input = Some(9484); cfg.hash_keccak256_cost_base = Some(10); cfg.hash_blake2b256_cost_base = Some(10); // group ops cfg.group_ops_bls12381_decode_scalar_cost = Some(7); cfg.group_ops_bls12381_decode_g1_cost = Some(2848); cfg.group_ops_bls12381_decode_g2_cost = Some(3770); cfg.group_ops_bls12381_decode_gt_cost = Some(3068); cfg.group_ops_bls12381_scalar_add_cost = Some(10); cfg.group_ops_bls12381_g1_add_cost = Some(1556); cfg.group_ops_bls12381_g2_add_cost = Some(3048); cfg.group_ops_bls12381_gt_add_cost = Some(188); cfg.group_ops_bls12381_scalar_sub_cost = Some(10); cfg.group_ops_bls12381_g1_sub_cost = Some(1550); cfg.group_ops_bls12381_g2_sub_cost = Some(3019); cfg.group_ops_bls12381_gt_sub_cost = Some(497); cfg.group_ops_bls12381_scalar_mul_cost = Some(11); cfg.group_ops_bls12381_g1_mul_cost = Some(4842); cfg.group_ops_bls12381_g2_mul_cost = Some(9108); cfg.group_ops_bls12381_gt_mul_cost = Some(27490); cfg.group_ops_bls12381_scalar_div_cost = Some(91); cfg.group_ops_bls12381_g1_div_cost = Some(5091); cfg.group_ops_bls12381_g2_div_cost = Some(9206); cfg.group_ops_bls12381_gt_div_cost = Some(27804); cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(2962); cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(8688); cfg.group_ops_bls12381_g1_msm_base_cost = Some(62648); cfg.group_ops_bls12381_g2_msm_base_cost = Some(131192); cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(1333); cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(3216); cfg.group_ops_bls12381_uncompressed_g1_to_g1_cost = Some(677); cfg.group_ops_bls12381_g1_to_uncompressed_g1_cost = Some(2099); cfg.group_ops_bls12381_uncompressed_g1_sum_base_cost = Some(77); cfg.group_ops_bls12381_uncompressed_g1_sum_cost_per_term = Some(26); cfg.group_ops_bls12381_pairing_cost = Some(26897); cfg.group_ops_bls12381_uncompressed_g1_sum_max_terms = Some(1200); cfg.validator_validate_metadata_cost_base = Some(20000); } 71 => { cfg.sip_45_consensus_amplification_threshold = Some(5); // Enable bursts for congestion control. (10x the per-commit budget) cfg.allowed_txn_cost_overage_burst_per_object_in_commit = Some(185_000_000); } 72 => { cfg.feature_flags.convert_type_argument_error = true; // Invariant: max_gas_price * base_tx_cost_fixed <= max_tx_gas // max gas budget is in MIST and an absolute value 50_000 SUI cfg.max_tx_gas = Some(50_000_000_000_000); // max gas price is in MIST and an absolute value 50 SUI cfg.max_gas_price = Some(50_000_000_000); cfg.feature_flags.variant_nodes = true; } 73 => { // Enable new marker table version. cfg.use_object_per_epoch_marker_table_v2 = Some(true); if chain != Chain::Mainnet && chain != Chain::Testnet { // Assuming a round rate of max 15/sec, then using a gc depth of 60 allow blocks within a window of ~4 seconds // to be included before be considered garbage collected. cfg.consensus_gc_depth = Some(60); } if chain != Chain::Mainnet { // Enable zstd compression for consensus in testnet cfg.feature_flags.consensus_zstd_compression = true; } // Enable smart ancestor selection for mainnet cfg.feature_flags.consensus_smart_ancestor_selection = true; // Enable probing for accepted rounds in round prober for mainnet cfg.feature_flags .consensus_round_prober_probe_accepted_rounds = true; // Increase congestion control budget. cfg.feature_flags.per_object_congestion_control_mode = PerObjectCongestionControlMode::TotalGasBudgetWithCap; cfg.gas_budget_based_txn_cost_cap_factor = Some(400_000); cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(37_000_000); cfg.max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit = Some(7_400_000); // 20% of above cfg.max_txn_cost_overage_per_object_in_commit = Some(u64::MAX); cfg.gas_budget_based_txn_cost_absolute_cap_commit_count = Some(50); cfg.allowed_txn_cost_overage_burst_per_object_in_commit = Some(370_000_000); } 74 => { // Enable nitro attestation verify native move function for devnet if chain != Chain::Mainnet && chain != Chain::Testnet { cfg.feature_flags.enable_nitro_attestation = true; } cfg.nitro_attestation_parse_base_cost = Some(53 * 50); cfg.nitro_attestation_parse_cost_per_byte = Some(50); cfg.nitro_attestation_verify_base_cost = Some(49632 * 50); cfg.nitro_attestation_verify_cost_per_cert = Some(52369 * 50); // Enable zstd compression for consensus in mainnet cfg.feature_flags.consensus_zstd_compression = true; if chain != Chain::Mainnet && chain != Chain::Testnet { cfg.feature_flags.consensus_linearize_subdag_v2 = true; } } 75 => { if chain != Chain::Mainnet { cfg.feature_flags.passkey_auth = true; } } 76 => { if chain != Chain::Mainnet && chain != Chain::Testnet { cfg.feature_flags.record_additional_state_digest_in_prologue = true; cfg.consensus_commit_rate_estimation_window_size = Some(10); } cfg.feature_flags.minimize_child_object_mutations = true; if chain != Chain::Mainnet { cfg.feature_flags.accept_passkey_in_multisig = true; } } 77 => { cfg.feature_flags.uncompressed_g1_group_elements = true; if chain != Chain::Mainnet { cfg.consensus_gc_depth = Some(60); cfg.feature_flags.consensus_linearize_subdag_v2 = true; } } 78 => { cfg.feature_flags.move_native_context = true; cfg.tx_context_fresh_id_cost_base = Some(52); cfg.tx_context_sender_cost_base = Some(30); cfg.tx_context_epoch_cost_base = Some(30); cfg.tx_context_epoch_timestamp_ms_cost_base = Some(30); cfg.tx_context_sponsor_cost_base = Some(30); cfg.tx_context_gas_price_cost_base = Some(30); cfg.tx_context_gas_budget_cost_base = Some(30); cfg.tx_context_ids_created_cost_base = Some(30); cfg.tx_context_replace_cost_base = Some(30); cfg.gas_model_version = Some(10); if chain != Chain::Mainnet { cfg.feature_flags.record_additional_state_digest_in_prologue = true; cfg.consensus_commit_rate_estimation_window_size = Some(10); // Enable execution time estimate mode for congestion control on testnet. cfg.feature_flags.per_object_congestion_control_mode = PerObjectCongestionControlMode::ExecutionTimeEstimate( ExecutionTimeEstimateParams { target_utilization: 30, allowed_txn_cost_overage_burst_limit_us: 100_000, // 100 ms randomness_scalar: 20, max_estimate_us: 1_500_000, // 1.5s stored_observations_num_included_checkpoints: 10, stored_observations_limit: u64::MAX, stake_weighted_median_threshold: 0, default_none_duration_for_new_keys: false, observations_chunk_size: None, }, ); } } 79 => { if chain != Chain::Mainnet { cfg.feature_flags.consensus_median_based_commit_timestamp = true; // Increase threshold for bad nodes that won't be considered // leaders in consensus in testnet cfg.consensus_bad_nodes_stake_threshold = Some(30); cfg.feature_flags.consensus_batched_block_sync = true; // Enable verify nitro attestation in testnet. cfg.feature_flags.enable_nitro_attestation = true } cfg.feature_flags.normalize_ptb_arguments = true; cfg.consensus_gc_depth = Some(60); cfg.feature_flags.consensus_linearize_subdag_v2 = true; } 80 => { cfg.max_ptb_value_size = Some(1024 * 1024); } 81 => { cfg.feature_flags.consensus_median_based_commit_timestamp = true; cfg.feature_flags.enforce_checkpoint_timestamp_monotonicity = true; cfg.consensus_bad_nodes_stake_threshold = Some(30) } 82 => { cfg.feature_flags.max_ptb_value_size_v2 = true; } 83 => { if chain == Chain::Mainnet { // The address that will sign the recovery transaction. let aliased: [u8; 32] = Hex::decode( "0x0b2da327ba6a4cacbe75dddd50e6e8bbf81d6496e92d66af9154c61c77f7332f", ) .unwrap() .try_into() .unwrap(); // Allow aliasing for the two addresses that contain stolen funds. cfg.aliased_addresses.push(AliasedAddress { original: Hex::decode("0xcd8962dad278d8b50fa0f9eb0186bfa4cbdecc6d59377214c88d0286a0ac9562").unwrap().try_into().unwrap(), aliased, allowed_tx_digests: vec![ Base58::decode("B2eGLFoMHgj93Ni8dAJBfqGzo8EWSTLBesZzhEpTPA4").unwrap().try_into().unwrap(), ], }); cfg.aliased_addresses.push(AliasedAddress { original: Hex::decode("0xe28b50cef1d633ea43d3296a3f6b67ff0312a5f1a99f0af753c85b8b5de8ff06").unwrap().try_into().unwrap(), aliased, allowed_tx_digests: vec![ Base58::decode("J4QqSAgp7VrQtQpMy5wDX4QGsCSEZu3U5KuDAkbESAge").unwrap().try_into().unwrap(), ], }); } // These features had to be deferred to v84 for mainnet in order to ship the recovery protocol // upgrade as a patch to 1.48 if chain != Chain::Mainnet { cfg.feature_flags.resolve_type_input_ids_to_defining_id = true; cfg.transfer_party_transfer_internal_cost_base = Some(52); // Enable execution time estimate mode for congestion control on mainnet. cfg.feature_flags.record_additional_state_digest_in_prologue = true; cfg.consensus_commit_rate_estimation_window_size = Some(10); cfg.feature_flags.per_object_congestion_control_mode = PerObjectCongestionControlMode::ExecutionTimeEstimate( ExecutionTimeEstimateParams { target_utilization: 30, allowed_txn_cost_overage_burst_limit_us: 100_000, // 100 ms randomness_scalar: 20, max_estimate_us: 1_500_000, // 1.5s stored_observations_num_included_checkpoints: 10, stored_observations_limit: u64::MAX, stake_weighted_median_threshold: 0, default_none_duration_for_new_keys: false, observations_chunk_size: None, }, ); // Enable the new depth-first block sync logic. cfg.feature_flags.consensus_batched_block_sync = true; // Enable nitro attestation upgraded parsing logic and enable the // native function on mainnet. cfg.feature_flags.enable_nitro_attestation_upgraded_parsing = true; cfg.feature_flags.enable_nitro_attestation = true; } } 84 => { if chain == Chain::Mainnet { cfg.feature_flags.resolve_type_input_ids_to_defining_id = true; cfg.transfer_party_transfer_internal_cost_base = Some(52); // Enable execution time estimate mode for congestion control on mainnet. cfg.feature_flags.record_additional_state_digest_in_prologue = true; cfg.consensus_commit_rate_estimation_window_size = Some(10); cfg.feature_flags.per_object_congestion_control_mode = PerObjectCongestionControlMode::ExecutionTimeEstimate( ExecutionTimeEstimateParams { target_utilization: 30, allowed_txn_cost_overage_burst_limit_us: 100_000, // 100 ms randomness_scalar: 20, max_estimate_us: 1_500_000, // 1.5s stored_observations_num_included_checkpoints: 10, stored_observations_limit: u64::MAX, stake_weighted_median_threshold: 0, default_none_duration_for_new_keys: false, observations_chunk_size: None, }, ); // Enable the new depth-first block sync logic. cfg.feature_flags.consensus_batched_block_sync = true; // Enable nitro attestation upgraded parsing logic and enable the // native function on mainnet. cfg.feature_flags.enable_nitro_attestation_upgraded_parsing = true; cfg.feature_flags.enable_nitro_attestation = true; } // Limit the number of stored execution time observations at end of epoch. cfg.feature_flags.per_object_congestion_control_mode = PerObjectCongestionControlMode::ExecutionTimeEstimate( ExecutionTimeEstimateParams { target_utilization: 30, allowed_txn_cost_overage_burst_limit_us: 100_000, // 100 ms randomness_scalar: 20, max_estimate_us: 1_500_000, // 1.5s stored_observations_num_included_checkpoints: 10, stored_observations_limit: 20, stake_weighted_median_threshold: 0, default_none_duration_for_new_keys: false, observations_chunk_size: None, }, ); cfg.feature_flags.allow_unbounded_system_objects = true; } 85 => { if chain != Chain::Mainnet && chain != Chain::Testnet { cfg.feature_flags.enable_party_transfer = true; } cfg.feature_flags .record_consensus_determined_version_assignments_in_prologue_v2 = true; cfg.feature_flags.disallow_self_identifier = true; cfg.feature_flags.per_object_congestion_control_mode = PerObjectCongestionControlMode::ExecutionTimeEstimate( ExecutionTimeEstimateParams { target_utilization: 50, allowed_txn_cost_overage_burst_limit_us: 500_000, // 500 ms randomness_scalar: 20, max_estimate_us: 1_500_000, // 1.5s stored_observations_num_included_checkpoints: 10, stored_observations_limit: 20, stake_weighted_median_threshold: 0, default_none_duration_for_new_keys: false, observations_chunk_size: None, }, ); } 86 => { cfg.feature_flags.type_tags_in_object_runtime = true; cfg.max_move_enum_variants = Some(move_core_types::VARIANT_COUNT_MAX); // Set a stake_weighted_median_threshold for congestion control. cfg.feature_flags.per_object_congestion_control_mode = PerObjectCongestionControlMode::ExecutionTimeEstimate( ExecutionTimeEstimateParams { target_utilization: 50, allowed_txn_cost_overage_burst_limit_us: 500_000, // 500 ms randomness_scalar: 20, max_estimate_us: 1_500_000, // 1.5s stored_observations_num_included_checkpoints: 10, stored_observations_limit: 20, stake_weighted_median_threshold: 3334, default_none_duration_for_new_keys: false, observations_chunk_size: None, }, ); // Enable party transfer for testnet. if chain != Chain::Mainnet { cfg.feature_flags.enable_party_transfer = true; } } 87 => { if chain == Chain::Mainnet { cfg.feature_flags.record_time_estimate_processed = true; } cfg.feature_flags.better_adapter_type_resolution_errors = true; } 88 => { cfg.feature_flags.record_time_estimate_processed = true; cfg.tx_context_rgp_cost_base = Some(30); cfg.feature_flags .ignore_execution_time_observations_after_certs_closed = true; // Disable backwards compatible behavior in execution time estimator for // new protocol version. cfg.feature_flags.per_object_congestion_control_mode = PerObjectCongestionControlMode::ExecutionTimeEstimate( ExecutionTimeEstimateParams { target_utilization: 50, allowed_txn_cost_overage_burst_limit_us: 500_000, // 500 ms randomness_scalar: 20, max_estimate_us: 1_500_000, // 1.5s stored_observations_num_included_checkpoints: 10, stored_observations_limit: 20, stake_weighted_median_threshold: 3334, default_none_duration_for_new_keys: true, observations_chunk_size: None, }, ); } 89 => { cfg.feature_flags.dependency_linkage_error = true; cfg.feature_flags.additional_multisig_checks = true; } 90 => { // 100x RGP cfg.max_gas_price_rgp_factor_for_aborted_transactions = Some(100); cfg.feature_flags.debug_fatal_on_move_invariant_violation = true; cfg.feature_flags.additional_consensus_digest_indirect_state = true; cfg.feature_flags.accept_passkey_in_multisig = true; cfg.feature_flags.passkey_auth = true; cfg.feature_flags.check_for_init_during_upgrade = true; // Enable Mysticeti fastpath handlers on testnet. if chain != Chain::Mainnet { cfg.feature_flags.mysticeti_fastpath = true; } } 91 => { cfg.feature_flags.per_command_shared_object_transfer_rules = true; } 92 => { cfg.feature_flags.per_command_shared_object_transfer_rules = false; } 93 => { cfg.feature_flags .consensus_checkpoint_signature_key_includes_digest = true; } 94 => { // Decrease stored observations limit 20->18 to stay within system object size limit. cfg.feature_flags.per_object_congestion_control_mode = PerObjectCongestionControlMode::ExecutionTimeEstimate( ExecutionTimeEstimateParams { target_utilization: 50, allowed_txn_cost_overage_burst_limit_us: 500_000, // 500 ms randomness_scalar: 20, max_estimate_us: 1_500_000, // 1.5s stored_observations_num_included_checkpoints: 10, stored_observations_limit: 18, stake_weighted_median_threshold: 3334, default_none_duration_for_new_keys: true, observations_chunk_size: None, }, ); // Enable party transfer on mainnet. cfg.feature_flags.enable_party_transfer = true; } 95 => { cfg.type_name_id_base_cost = Some(52); // Reduce the frequency of checkpoint splitting under high TPS. cfg.max_transactions_per_checkpoint = Some(20_000); } 96 => { // Enable artifacts digest in devnet. if chain != Chain::Mainnet && chain != Chain::Testnet { cfg.feature_flags .include_checkpoint_artifacts_digest_in_summary = true; } cfg.feature_flags.correct_gas_payment_limit_check = true; cfg.feature_flags.authority_capabilities_v2 = true; cfg.feature_flags.use_mfp_txns_in_load_initial_object_debts = true; cfg.feature_flags.cancel_for_failed_dkg_early = true; cfg.feature_flags.enable_coin_registry = true; // Enable Mysticeti fastpath handlers on mainnet. cfg.feature_flags.mysticeti_fastpath = true; } 97 => { cfg.feature_flags.additional_borrow_checks = true; } 98 => { cfg.event_emit_auth_stream_cost = Some(52); cfg.feature_flags.better_loader_errors = true; cfg.feature_flags.generate_df_type_layouts = true; } 99 => { cfg.feature_flags.use_new_commit_handler = true; } 100 => { cfg.feature_flags.private_generics_verifier_v2 = true; } 101 => { cfg.feature_flags.create_root_accumulator_object = true; cfg.max_updates_per_settlement_txn = Some(100); if chain != Chain::Mainnet { cfg.feature_flags.enable_poseidon = true; } } 102 => { // Enable execution time observation chunking and increase limit to 180. // max_move_object_size is 250 KB, we've experientially determined that fits ~ 18 estimates // so if we have 10 chunks, that's 2.5MB, < 8MB max_serialized_tx_effects_size_bytes_system_tx cfg.feature_flags.per_object_congestion_control_mode = PerObjectCongestionControlMode::ExecutionTimeEstimate( ExecutionTimeEstimateParams { target_utilization: 50, allowed_txn_cost_overage_burst_limit_us: 500_000, // 500 ms randomness_scalar: 20, max_estimate_us: 1_500_000, // 1.5s stored_observations_num_included_checkpoints: 10, stored_observations_limit: 180, stake_weighted_median_threshold: 3334, default_none_duration_for_new_keys: true, observations_chunk_size: Some(18), }, ); cfg.feature_flags.deprecate_global_storage_ops = true; } 103 => {} 104 => { cfg.translation_per_command_base_charge = Some(1); cfg.translation_per_input_base_charge = Some(1); cfg.translation_pure_input_per_byte_charge = Some(1); cfg.translation_per_type_node_charge = Some(1); cfg.translation_per_reference_node_charge = Some(1); cfg.translation_per_linkage_entry_charge = Some(10); cfg.gas_model_version = Some(11); cfg.feature_flags.abstract_size_in_object_runtime = true; cfg.feature_flags.object_runtime_charge_cache_load_gas = true; cfg.dynamic_field_hash_type_and_key_cost_base = Some(52); cfg.dynamic_field_add_child_object_cost_base = Some(52); cfg.dynamic_field_add_child_object_value_cost_per_byte = Some(1); cfg.dynamic_field_borrow_child_object_cost_base = Some(52); cfg.dynamic_field_borrow_child_object_child_ref_cost_per_byte = Some(1); cfg.dynamic_field_remove_child_object_cost_base = Some(52); cfg.dynamic_field_remove_child_object_child_cost_per_byte = Some(1); cfg.dynamic_field_has_child_object_cost_base = Some(52); cfg.dynamic_field_has_child_object_with_ty_cost_base = Some(52); cfg.feature_flags.enable_ptb_execution_v2 = true; cfg.poseidon_bn254_cost_base = Some(260); cfg.feature_flags.consensus_skip_gced_accept_votes = true; if chain != Chain::Mainnet { cfg.feature_flags .enable_nitro_attestation_all_nonzero_pcrs_parsing = true; } cfg.feature_flags .include_cancelled_randomness_txns_in_prologue = true; } 105 => { cfg.feature_flags.enable_multi_epoch_transaction_expiration = true; cfg.feature_flags.disable_preconsensus_locking = true; if chain != Chain::Mainnet { cfg.feature_flags .enable_nitro_attestation_always_include_required_pcrs_parsing = true; } } 106 => { // est. 100 bytes per object * 76 (storage_gas_price) cfg.accumulator_object_storage_cost = Some(7600); if chain != Chain::Mainnet && chain != Chain::Testnet { cfg.feature_flags.enable_accumulators = true; cfg.feature_flags.enable_address_balance_gas_payments = true; cfg.feature_flags.enable_authenticated_event_streams = true; cfg.feature_flags.enable_object_funds_withdraw = true; } } 107 => { cfg.feature_flags .consensus_skip_gced_blocks_in_direct_finalization = true; // Trigger edge cases more often in integration tests. if in_integration_test() { cfg.consensus_gc_depth = Some(6); cfg.consensus_max_num_transactions_in_block = Some(8); } } 108 => { cfg.feature_flags.gas_rounding_halve_digits = true; cfg.feature_flags.flexible_tx_context_positions = true; cfg.feature_flags.disable_entry_point_signature_check = true; if chain != Chain::Mainnet { cfg.feature_flags.address_aliases = true; cfg.feature_flags.enable_accumulators = true; cfg.feature_flags.enable_address_balance_gas_payments = true; } cfg.feature_flags.enable_poseidon = true; } 109 => { cfg.binary_variant_handles = Some(1024); cfg.binary_variant_instantiation_handles = Some(1024); cfg.feature_flags.restrict_hot_or_not_entry_functions = true; } 110 => { cfg.feature_flags .enable_nitro_attestation_all_nonzero_pcrs_parsing = true; cfg.feature_flags .enable_nitro_attestation_always_include_required_pcrs_parsing = true; if chain != Chain::Mainnet && chain != Chain::Testnet { cfg.feature_flags.split_checkpoints_in_consensus_handler = true; } cfg.feature_flags.validate_zklogin_public_identifier = true; cfg.feature_flags.fix_checkpoint_signature_mapping = true; cfg.feature_flags .consensus_always_accept_system_transactions = true; if chain != Chain::Mainnet { cfg.feature_flags.enable_object_funds_withdraw = true; } } 111 => { cfg.feature_flags.validator_metadata_verify_v2 = true; } 112 => { cfg.group_ops_ristretto_decode_scalar_cost = Some(7); cfg.group_ops_ristretto_decode_point_cost = Some(200); cfg.group_ops_ristretto_scalar_add_cost = Some(10); cfg.group_ops_ristretto_point_add_cost = Some(500); cfg.group_ops_ristretto_scalar_sub_cost = Some(10); cfg.group_ops_ristretto_point_sub_cost = Some(500); cfg.group_ops_ristretto_scalar_mul_cost = Some(11); cfg.group_ops_ristretto_point_mul_cost = Some(1200); cfg.group_ops_ristretto_scalar_div_cost = Some(151); cfg.group_ops_ristretto_point_div_cost = Some(2500); if chain != Chain::Mainnet && chain != Chain::Testnet { cfg.feature_flags.enable_ristretto255_group_ops = true; } } 113 => { cfg.feature_flags.address_balance_gas_check_rgp_at_signing = true; if chain != Chain::Mainnet && chain != Chain::Testnet { cfg.feature_flags.defer_unpaid_amplification = true; } } 114 => { cfg.feature_flags.randomize_checkpoint_tx_limit_in_tests = true; cfg.feature_flags.address_balance_gas_reject_gas_coin_arg = true; if chain != Chain::Mainnet { cfg.feature_flags.split_checkpoints_in_consensus_handler = true; cfg.feature_flags.enable_authenticated_event_streams = true; cfg.feature_flags .include_checkpoint_artifacts_digest_in_summary = true; } } 115 => { cfg.feature_flags.normalize_depth_formula = true; } 116 => { cfg.feature_flags.gasless_transaction_drop_safety = true; cfg.feature_flags.address_aliases = true; cfg.feature_flags.relax_valid_during_for_owned_inputs = true; // Disabled while debugging cfg.feature_flags.defer_unpaid_amplification = false; cfg.feature_flags.enable_display_registry = true; } 117 => {} 118 => { cfg.feature_flags.use_coin_party_owner = true; } 119 => { // Enable new VM. cfg.execution_version = Some(4); cfg.feature_flags.address_balance_gas_reject_gas_coin_arg = false; cfg.feature_flags.merge_randomness_into_checkpoint = true; if chain != Chain::Mainnet { cfg.feature_flags.enable_gasless = true; cfg.gasless_max_computation_units = Some(50_000); cfg.gasless_allowed_token_types = Some(vec![]); cfg.feature_flags.enable_coin_reservation_obj_refs = true; cfg.feature_flags .convert_withdrawal_compatibility_ptb_arguments = true; } cfg.gasless_max_unused_inputs = Some(1); cfg.gasless_max_pure_input_bytes = Some(32); if chain == Chain::Testnet { cfg.gasless_allowed_token_types = Some(vec![(TESTNET_USDC.to_string(), 0)]); } cfg.transfer_receive_object_cost_per_byte = Some(1); cfg.transfer_receive_object_type_cost_per_byte = Some(2); } 120 => { cfg.feature_flags.disallow_jump_orphans = true; } 121 => { // Re-enable unpaid amplification deferral protection (testnet + devnet) if chain != Chain::Mainnet { cfg.feature_flags.defer_unpaid_amplification = true; cfg.gasless_max_tps = Some(50); } cfg.feature_flags .early_return_receive_object_mismatched_type = true; } 122 => { // Enable unpaid amplification deferral on mainnet cfg.feature_flags.defer_unpaid_amplification = true; // Enable bulletproofs range proofs on devnet cfg.verify_bulletproofs_ristretto255_base_cost = Some(30000); cfg.verify_bulletproofs_ristretto255_cost_per_bit_and_commitment = Some(6500); if chain != Chain::Mainnet && chain != Chain::Testnet { cfg.feature_flags.enable_verify_bulletproofs_ristretto255 = true; } cfg.feature_flags.gasless_verify_remaining_balance = true; cfg.include_special_package_amendments = match chain { Chain::Mainnet => Some(MAINNET_LINKAGE_AMENDMENTS.clone()), Chain::Testnet => Some(TESTNET_LINKAGE_AMENDMENTS.clone()), Chain::Unknown => None, }; cfg.gasless_max_tx_size_bytes = Some(16 * 1024); cfg.gasless_max_tps = Some(300); cfg.gasless_max_computation_units = Some(5_000); } 123 => { cfg.gas_model_version = Some(13); } 124 => { if chain != Chain::Mainnet && chain != Chain::Testnet { cfg.feature_flags.timestamp_based_epoch_close = true; } cfg.gas_model_version = Some(14); cfg.feature_flags.limit_groth16_pvk_inputs = true; // Bring mainnet in line with testnet: enable address balances, the // gasless "free tier", coin reservations, and the rest of the // accumulator/withdraw stack. These are all already enabled on // testnet and devnet, so setting them unconditionally is a no-op // there. cfg.feature_flags.enable_accumulators = true; cfg.feature_flags.enable_address_balance_gas_payments = true; cfg.feature_flags.enable_authenticated_event_streams = true; cfg.feature_flags.enable_coin_reservation_obj_refs = true; cfg.feature_flags.enable_object_funds_withdraw = true; cfg.feature_flags .convert_withdrawal_compatibility_ptb_arguments = true; cfg.feature_flags.split_checkpoints_in_consensus_handler = true; cfg.feature_flags .include_checkpoint_artifacts_digest_in_summary = true; cfg.feature_flags.enable_gasless = true; // Set the mainnet allow-list. Testnet already has its USDC entry // from v119, so only set this on mainnet to avoid clobbering the // testnet value. $0.01 minimum transfer per stable; all listed // tokens have 6 decimals. if chain == Chain::Mainnet { cfg.gasless_allowed_token_types = Some(vec![ (MAINNET_USDC.to_string(), 10_000), (MAINNET_USDSUI.to_string(), 10_000), (MAINNET_SUI_USDE.to_string(), 10_000), (MAINNET_USDY.to_string(), 10_000), (MAINNET_FDUSD.to_string(), 10_000), (MAINNET_AUSD.to_string(), 10_000), (MAINNET_USDB.to_string(), 10_000), ]); } } 125 => { cfg.feature_flags.granular_post_execution_checks = true; if chain != Chain::Mainnet { cfg.feature_flags.timestamp_based_epoch_close = true; } } 126 => { cfg.feature_flags.early_exit_on_iffw = true; } 127 => { cfg.feature_flags.always_advance_dkg_to_resolution = true; cfg.verify_bulletproofs_ristretto255_base_cost = Some(23866); cfg.verify_bulletproofs_ristretto255_cost_per_bit_and_commitment = Some(1324); cfg.group_ops_ristretto_decode_scalar_cost = Some(5); cfg.group_ops_ristretto_decode_point_cost = Some(216); cfg.group_ops_ristretto_scalar_add_cost = Some(2); cfg.group_ops_ristretto_point_add_cost = Some(8); cfg.group_ops_ristretto_scalar_sub_cost = Some(2); cfg.group_ops_ristretto_point_sub_cost = Some(8); cfg.group_ops_ristretto_scalar_mul_cost = Some(5); cfg.group_ops_ristretto_point_mul_cost = Some(1763); cfg.group_ops_ristretto_scalar_div_cost = Some(557); cfg.group_ops_ristretto_point_div_cost = Some(2244); if chain != Chain::Mainnet { cfg.feature_flags.enable_ristretto255_group_ops = true; cfg.feature_flags.enable_verify_bulletproofs_ristretto255 = true; } cfg.feature_flags.timestamp_based_epoch_close = true; } 128 => { cfg.max_generic_instantiation_type_nodes_per_function = Some(10_000); cfg.max_generic_instantiation_type_nodes_per_module = Some(500_000); cfg.binary_enum_defs = Some(200); cfg.binary_enum_def_instantiations = Some(100); } 129 => { cfg.feature_flags.enable_unified_linkage = true; } 130 => { cfg.feature_flags.record_net_unsettled_object_withdraws = true; cfg.feature_flags.enable_init_on_upgrade = true; cfg.epoch_close_deadline_ms = Some(120_000); cfg.scratch_add_cost_base = Some(13); cfg.scratch_read_cost_base = Some(13); cfg.scratch_read_value_cost = Some(1); cfg.scratch_remove_cost_base = Some(13); cfg.scratch_exists_cost_base = Some(13); cfg.scratch_exists_with_type_cost_base = Some(13); cfg.scratch_exists_with_type_type_cost = Some(1); let max_commands = cfg.max_programmable_tx_commands() as u64; cfg.max_scratch_pad_size = Some(16 * max_commands); // Verify with the v2 then v1 for devnet. if chain != Chain::Mainnet && chain != Chain::Testnet { cfg.feature_flags.zklogin_circuit_mode = 1; } } 131 => { cfg.feature_flags.share_transaction_deny_config_in_consensus = true; cfg.feature_flags.framework_tx_context_mut_restrictions = true; } 132 => { if chain != Chain::Mainnet && chain != Chain::Testnet { cfg.feature_flags.defer_owned_object_double_spend = true; cfg.feature_flags.create_forwarding_address_registry = true; } cfg.object_record_new_uid_from_hash_cost_base = Some(1); cfg.feature_flags .enable_order_independent_upgrade_init_linkage = true; } 133 => { cfg.feature_flags .include_function_signatures_in_instantiation_limits = true; cfg.max_accumulator_type_nodes = Some(16); } 134 => { // v134 was released to testnet with this content before the 1.77 // branch backfilled its own v134 to disable defer_unpaid_amplification // on mainnet. To keep (v134, Mainnet) identical across the 1.77 and // 1.78 branches, the original v134 content is gated off mainnet here // (it applies to mainnet in v135 instead), and mainnet's v134 carries // only the deferral disable. if chain != Chain::Mainnet { cfg.package_original_package_id_impl_cost_base = Some(52); let package_read_cost_per_byte = cfg.obj_access_cost_read_per_byte(); cfg.package_original_package_id_impl_cost_per_byte = Some(package_read_cost_per_byte); cfg.consensus_max_transactions_in_block_bytes = Some(288 * 1024); cfg.consensus_max_num_transactions_in_block = Some(128); } if chain == Chain::Mainnet { cfg.feature_flags.defer_unpaid_amplification = false; } } 135 => { // Apply the original v134 content on mainnet (no-op re-assignment on // chains that already applied it in v134). cfg.package_original_package_id_impl_cost_base = Some(52); let package_read_cost_per_byte = cfg.obj_access_cost_read_per_byte(); cfg.package_original_package_id_impl_cost_per_byte = Some(package_read_cost_per_byte); cfg.consensus_max_transactions_in_block_bytes = Some(288 * 1024); cfg.consensus_max_num_transactions_in_block = Some(128); cfg.feature_flags.defer_unpaid_amplification = false; } 136 => { cfg.feature_flags.ptb_tx_context_restrictions = true; cfg.translation_per_live_reference_charge = Some(1); cfg.max_ptb_live_references = Some(64); cfg.max_ptb_returned_references = Some(16); cfg.max_ptb_total_returned_references = Some(256); if chain != Chain::Mainnet && chain != Chain::Testnet { cfg.feature_flags.allowed_proposers = true; } cfg.feature_flags.harden_linkage_consistency = true; cfg.package_arena_size_in_bytes = Some(10_000_000); } 137 => { cfg.verify_bulletproofs_ristretto255_cost_per_bit_and_commitment = Some(621); cfg.max_bulletproofs_total_bits = Some(1024); if chain != Chain::Mainnet { cfg.feature_flags.enable_allowances = true; } cfg.feature_flags.fix_ptb_generated_reads = true; cfg.feature_flags.charge_ld_const_abstract_size = true; if chain != Chain::Mainnet && chain != Chain::Testnet { cfg.feature_flags.check_object_funds_withdraw_in_execution = true; } cfg.reserve_object_funds_for_withdrawal_cost_base = Some(52); // Equivalent to the fixed portion of a dynamic-field lookup (52 + 52) plus // loading the 80-byte accumulator field contents at one gas unit per byte. cfg.reserve_object_funds_for_withdrawal_cold_read_cost = Some(184); cfg.feature_flags.allowed_proposers = true; cfg.feature_flags.validate_ptb_argument_indices = true; cfg.feature_flags.memory_safety_invariant_check_v2 = true; } 138 => { cfg.gas_model_version = Some(15); cfg.feature_flags.enable_allowances = true; if chain != Chain::Mainnet { cfg.feature_flags.check_object_funds_withdraw_in_execution = true; cfg.feature_flags.disable_effects_tx_dependencies = true; } cfg.feature_flags.merge_colliding_deferrals = true; // Testnet already runs version 138, so it gets this change in version 139. if chain == Chain::Mainnet { cfg.storage_rebate_rate = Some(9999); } } 139 => { if chain != Chain::Mainnet && chain != Chain::Testnet { cfg.feature_flags.enable_forwarding_addresses = true; cfg.feature_flags.mldsa65_auth = true; } cfg.storage_rebate_rate = Some(9999); if chain != Chain::Mainnet { cfg.feature_flags.allow_dkg_completion_after_timeout = true; } // Validators cache packages, so reading one costs far less than reading an object. cfg.obj_access_cost_read_per_package_kb = Some(154); } 140 => { // Signal thresholds are set on every chain. They take effect only // where `staggered_submission_signal` is enabled. cfg.staggered_submission_signal_window_commits = Some(300); cfg.staggered_submission_signal_min_excess_copies_per_commit = Some(2); cfg.staggered_submission_signal_exit_dwell_commits = Some(6000); cfg.staggered_submission_signal_band1_enter_ratio_bps = Some(1000); cfg.staggered_submission_signal_band1_exit_ratio_bps = Some(500); cfg.staggered_submission_signal_band2_enter_ratio_bps = Some(5000); cfg.staggered_submission_signal_band2_exit_ratio_bps = Some(2500); cfg.vector_reverse_base_cost = Some(52); cfg.vector_reverse_per_elem_cost = Some(8); cfg.vector_keep_range_base_cost = Some(52); cfg.vector_keep_range_per_dropped_elem_cost = Some(1); cfg.vector_keep_range_per_moved_elem_cost = Some(8); cfg.vector_copy_range_base_cost = Some(52); cfg.vector_replace_range_base_cost = Some(52); cfg.vector_replace_range_per_elem_cost = Some(8); if chain != Chain::Mainnet && chain != Chain::Testnet { cfg.feature_flags.shuffle_consensus_commit_blocks = true; } cfg.feature_flags.allow_references_in_ptbs = true; cfg.feature_flags.disable_id_leak_verifier = true; cfg.feature_flags.check_object_funds_withdraw_in_execution = true; cfg.feature_flags.disable_effects_tx_dependencies = true; } 141 => { cfg.feature_flags.complete_effects_size_estimate = true; cfg.max_num_accumulator_events = Some(1024); } 142 => { cfg.clock_borrow_cost_base = Some(52); cfg.feature_flags.check_groth16_pvk_length = true; cfg.object_is_shared_input_cost_base = Some(52); cfg.feature_flags.secp256r1_ecrecover_checks_x_below_p = true; cfg.binary_format_limits_profile = Some(BinaryFormatLimitsProfile::V1); cfg.feature_flags.defer_owned_object_double_spend = true; } 143 => { cfg.execution_version = Some(5); cfg.package_arena_size_in_bytes = Some(20_000_000); cfg.feature_flags.simplify_nitro_header_validation = true; cfg.feature_flags.enable_forwarding_addresses = false; cfg.feature_flags.package_publish_charge = true; cfg.package_publish_charge_fixed = Some(1_000_000_000); cfg.package_publish_charge_per_module = Some(10_000_000); cfg.package_publish_charge_per_dependency = Some(10_000_000); if chain != Chain::Mainnet { cfg.feature_flags.mldsa65_auth = true; } cfg.layout_node_cost = Some(16); cfg.layout_node_cost_large_layout_threshold = Some(64); cfg.bcs_per_input_abstract_unit_cost = Some(20); cfg.vector_copy_range_per_abstract_memory_unit_cost = Some(1); } 144 => { if chain != Chain::Mainnet && chain != Chain::Testnet { cfg.feature_flags.enable_timestamp_transaction_expiration = true; } cfg.object_runtime_max_loaded_child_value_size = Some(5_000_000); cfg.feature_flags.staggered_submission_signal = true; // Staggering should turn on only at peak load. Mainnet commits about // 15 times per second. There the window covers about 40 seconds and // the floor is about 15,000 user transactions per second, duplicates // included. // Under load mainnet commits about 10 to 13 times per second. There // the window covers 46 to 60 seconds and the floor is about 10,000 // to 13,000 user transactions per second. // Mainnet traffic from 2026-11-04 to 2026-11-19 would have turned // the signal on 32 times, with a median of once per day. With the // same floor and the previous window of 300 commits, bursts of a // few seconds would have turned it on 83 times. cfg.staggered_submission_signal_window_commits = Some(600); cfg.staggered_submission_signal_min_consensus_user_transactions_per_commit = Some(1000); if chain == Chain::Testnet { // Testnet carries about one user transaction per commit and almost no // duplicates, so it never meets the floor above. From 2026-11-04 // to 2026-11-19 no testnet window averaged more than 3 user transactions // per commit. This floor lets a load test that submits // duplicates turn the signal on. cfg.staggered_submission_signal_min_consensus_user_transactions_per_commit = Some(5); } } 145 => { cfg.feature_flags.secp256r1_strict_public_keys = true; } // Use this template when making changes: // // // modify an existing constant. // move_binary_format_version: Some(7), // // // Add a new constant (which is set to None in prior versions). // new_constant: Some(new_value), // // // Remove a constant (ensure that it is never accessed during this version). // max_move_object_size: None, _ => panic!("unsupported version {:?}", version), } } cfg } pub fn apply_seeded_test_overrides(&mut self, seed: &[u8; 32]) { if !self.feature_flags.randomize_checkpoint_tx_limit_in_tests || !self.feature_flags.split_checkpoints_in_consensus_handler { return; } if !mysten_common::in_test_configuration() { return; } use rand::{Rng, SeedableRng, rngs::StdRng}; let mut rng = StdRng::from_seed(*seed); let max_txns = rng.gen_range(10..=100u64); info!("seeded test override: max_transactions_per_checkpoint = {max_txns}"); self.max_transactions_per_checkpoint = Some(max_txns); } // Extract the bytecode verifier config from this protocol config. // If used during signing, `signing_limits` should be set. // The third limit configures`sanity_check_with_regex_reference_safety`, // which runs the new regex-based reference safety check to check that it is strictly more // permissive than the current implementation. pub fn verifier_config(&self, signing_limits: Option<(usize, usize, usize)>) -> VerifierConfig { let ( max_back_edges_per_function, max_back_edges_per_module, sanity_check_with_regex_reference_safety, ) = if let Some(( max_back_edges_per_function, max_back_edges_per_module, sanity_check_with_regex_reference_safety, )) = signing_limits { ( Some(max_back_edges_per_function), Some(max_back_edges_per_module), Some(sanity_check_with_regex_reference_safety), ) } else { (None, None, None) }; let additional_borrow_checks = if signing_limits.is_some() { // always turn on additional borrow checks during signing true } else { self.additional_borrow_checks() }; let deprecate_global_storage_ops = if signing_limits.is_some() { // always turn on additional vector borrow checks during signing true } else { self.deprecate_global_storage_ops() }; VerifierConfig { max_loop_depth: Some(self.max_loop_depth() as usize), max_generic_instantiation_length: Some(self.max_generic_instantiation_length() as usize), max_function_parameters: Some(self.max_function_parameters() as usize), max_basic_blocks: Some(self.max_basic_blocks() as usize), max_value_stack_size: self.max_value_stack_size() as usize, max_type_nodes: Some(self.max_type_nodes() as usize), max_generic_instantiation_type_nodes_per_function: self .max_generic_instantiation_type_nodes_per_function_as_option() .map(|v| v as usize), max_generic_instantiation_type_nodes_per_module: self .max_generic_instantiation_type_nodes_per_module_as_option() .map(|v| v as usize), include_function_signatures_in_instantiation_limits: self .include_function_signatures_in_instantiation_limits(), max_push_size: Some(self.max_push_size() as usize), max_dependency_depth: Some(self.max_dependency_depth() as usize), max_fields_in_struct: Some(self.max_fields_in_struct() as usize), max_function_definitions: Some(self.max_function_definitions() as usize), max_data_definitions: Some(self.max_struct_definitions() as usize), max_constant_vector_len: Some(self.max_move_vector_len()), max_back_edges_per_function, max_back_edges_per_module, max_basic_blocks_in_script: None, max_identifier_len: self.max_move_identifier_len_as_option(), // Before protocol version 9, there was no limit disallow_self_identifier: self.feature_flags.disallow_self_identifier, allow_receiving_object_id: self.allow_receiving_object_id(), reject_mutable_random_on_entry_functions: self .reject_mutable_random_on_entry_functions(), bytecode_version: self.move_binary_format_version(), max_variants_in_enum: self.max_move_enum_variants_as_option(), additional_borrow_checks, better_loader_errors: self.better_loader_errors(), private_generics_verifier_v2: self.private_generics_verifier_v2(), sanity_check_with_regex_reference_safety: sanity_check_with_regex_reference_safety .map(|limit| limit as u128), deprecate_global_storage_ops, disable_entry_point_signature_check: self.disable_entry_point_signature_check(), disable_id_leak_verifier: self.disable_id_leak_verifier(), switch_to_regex_reference_safety: false, framework_tx_context_mut_restrictions: self.framework_tx_context_mut_restrictions(), disallow_jump_orphans: self.disallow_jump_orphans(), } } pub fn binary_config( &self, override_deprecate_global_storage_ops_during_deserialization: Option, ) -> BinaryConfig { let deprecate_global_storage_ops = override_deprecate_global_storage_ops_during_deserialization .unwrap_or_else(|| self.deprecate_global_storage_ops()); BinaryConfig::new( self.move_binary_format_version(), self.min_move_binary_format_version_as_option() .unwrap_or(VERSION_1), self.no_extraneous_module_bytes(), deprecate_global_storage_ops, TableConfig { module_handles: self.binary_module_handles_as_option().unwrap_or(u16::MAX), datatype_handles: self.binary_struct_handles_as_option().unwrap_or(u16::MAX), function_handles: self.binary_function_handles_as_option().unwrap_or(u16::MAX), function_instantiations: self .binary_function_instantiations_as_option() .unwrap_or(u16::MAX), signatures: self.binary_signatures_as_option().unwrap_or(u16::MAX), constant_pool: self.binary_constant_pool_as_option().unwrap_or(u16::MAX), identifiers: self.binary_identifiers_as_option().unwrap_or(u16::MAX), address_identifiers: self .binary_address_identifiers_as_option() .unwrap_or(u16::MAX), struct_defs: self.binary_struct_defs_as_option().unwrap_or(u16::MAX), struct_def_instantiations: self .binary_struct_def_instantiations_as_option() .unwrap_or(u16::MAX), function_defs: self.binary_function_defs_as_option().unwrap_or(u16::MAX), field_handles: self.binary_field_handles_as_option().unwrap_or(u16::MAX), field_instantiations: self .binary_field_instantiations_as_option() .unwrap_or(u16::MAX), friend_decls: self.binary_friend_decls_as_option().unwrap_or(u16::MAX), enum_defs: self.binary_enum_defs_as_option().unwrap_or(u16::MAX), enum_def_instantiations: self .binary_enum_def_instantiations_as_option() .unwrap_or(u16::MAX), variant_handles: self.binary_variant_handles_as_option().unwrap_or(u16::MAX), variant_instantiation_handles: self .binary_variant_instantiation_handles_as_option() .unwrap_or(u16::MAX), }, self.binary_format_limits(), ) } pub fn binary_format_limits( &self, ) -> &'static move_binary_format::binary_config::BinaryFormatLimits { self.binary_format_limits_profile .unwrap_or(BinaryFormatLimitsProfile::LEGACY) .limits() } /// Override one or more settings in the config, for testing. /// This must be called at the beginning of the test, before get_for_(min|max)_version is /// called, since those functions cache their return value. pub fn apply_overrides_for_testing( override_fn: impl Fn(ProtocolVersion, Self) -> Self + Send + Sync + 'static, ) -> OverrideGuard { let mut cur = CONFIG_OVERRIDE.lock().unwrap(); assert!(cur.is_none(), "config override already present"); *cur = Some(Box::new(override_fn)); OverrideGuard } /// Install a base override that applies before the override from `apply_overrides_for_testing`, /// so that one can replace values set here. Base overrides stack and apply in the order they /// were installed. Each is removed when its guard is dropped. #[cfg(feature = "testing")] pub fn apply_base_overrides_for_testing( override_fn: impl Fn(ProtocolVersion, Self) -> Self + Send + Sync + 'static, ) -> BaseOverrideGuard { info!("installing base ProtocolConfig override for testing"); let override_fn: Arc = Arc::new(override_fn); BASE_CONFIG_OVERRIDES .lock() .unwrap() .push(override_fn.clone()); BaseOverrideGuard { override_fn } } fn apply_config_override(version: ProtocolVersion, mut ret: Self) -> Self { // Copy the list so that the lock is not held while the closures run. #[cfg(feature = "testing")] { let fns = BASE_CONFIG_OVERRIDES.lock().unwrap().clone(); for override_fn in fns { ret = override_fn(version, ret); } } if let Some(override_fn) = CONFIG_OVERRIDE.lock().unwrap().as_ref() { warn!( "overriding ProtocolConfig settings with custom settings (you should not see this log outside of tests)" ); ret = override_fn(version, ret); } ret } } // Setters for tests. // This is only needed for feature_flags. Please suffix each setter with `_for_testing`. // Non-feature_flags should already have test setters defined through macros. impl ProtocolConfig { // Hand-written (the field is marked #[custom_setter]) to forbid downgrades: an executor // older than the config's protocol version can't link the frameworks of later versions — // its natives tables are frozen. Upgrades are allowed for replay's executor override. pub fn set_execution_version_for_testing(&mut self, val: u64) { let current = self.execution_version.unwrap_or(0); assert!( val >= current, "cannot downgrade execution_version from {current} to {val}: running an old \ executor against a newer protocol config/framework is unsupported. To test \ frozen executor behavior, start from the last protocol version of that executor \ instead, so genesis loads the matching framework snapshot (see \ test_address_balance_gas_v3_accumulator_sign)." ); self.execution_version = Some(val); } // Not generated by the feature-flags derive because zklogin_circuit_mode is a u64 // flag (the macro only generates setters for bool flags). pub fn set_zklogin_circuit_mode_for_testing(&mut self, val: u64) { self.feature_flags.zklogin_circuit_mode = val } pub fn set_per_object_congestion_control_mode_for_testing( &mut self, val: PerObjectCongestionControlMode, ) { self.feature_flags.per_object_congestion_control_mode = val; } pub fn set_consensus_choice_for_testing(&mut self, val: ConsensusChoice) { self.feature_flags.consensus_choice = val; } pub fn set_consensus_network_for_testing(&mut self, val: ConsensusNetwork) { self.feature_flags.consensus_network = val; } pub fn set_zklogin_max_epoch_upper_bound_delta_for_testing(&mut self, val: Option) { self.feature_flags.zklogin_max_epoch_upper_bound_delta = val } pub fn set_mysticeti_num_leaders_per_round_for_testing(&mut self, val: Option) { self.feature_flags.mysticeti_num_leaders_per_round = val; } pub fn disable_accumulators_for_testing(&mut self) { self.feature_flags.enable_accumulators = false; self.feature_flags.enable_address_balance_gas_payments = false; } pub fn enable_coin_reservation_for_testing(&mut self) { self.feature_flags.enable_coin_reservation_obj_refs = true; self.feature_flags .convert_withdrawal_compatibility_ptb_arguments = true; // Ensure execution_version >= 4 so new_vm_enabled() returns true, // which is required for enable_coin_reservation_obj_refs() to return true. self.execution_version = Some(self.execution_version.map_or(4, |v| v.max(4))); } pub fn disable_coin_reservation_for_testing(&mut self) { self.feature_flags.enable_coin_reservation_obj_refs = false; self.feature_flags .convert_withdrawal_compatibility_ptb_arguments = false; } pub fn enable_address_balance_gas_payments_for_testing(&mut self) { self.feature_flags.enable_accumulators = true; self.feature_flags.allow_private_accumulator_entrypoints = true; self.feature_flags.enable_address_balance_gas_payments = true; self.feature_flags.address_balance_gas_check_rgp_at_signing = true; self.feature_flags.address_balance_gas_reject_gas_coin_arg = false; self.execution_version = Some(self.execution_version.map_or(4, |v| v.max(4))) } pub fn enable_gasless_for_testing(&mut self) { self.enable_address_balance_gas_payments_for_testing(); self.feature_flags.enable_gasless = true; self.feature_flags.gasless_verify_remaining_balance = true; self.gasless_max_computation_units = Some(5_000); self.gasless_allowed_token_types = Some(vec![]); self.gasless_max_tps = Some(1000); self.gasless_max_tx_size_bytes = Some(16 * 1024); } pub fn disable_gasless_for_testing(&mut self) { self.feature_flags.enable_gasless = false; self.gasless_max_computation_units = None; self.gasless_allowed_token_types = None; } pub fn enable_authenticated_event_streams_for_testing(&mut self) { self.feature_flags.enable_accumulators = true; self.feature_flags.enable_authenticated_event_streams = true; self.feature_flags .include_checkpoint_artifacts_digest_in_summary = true; self.feature_flags.split_checkpoints_in_consensus_handler = true; } } type OverrideFn = dyn Fn(ProtocolVersion, ProtocolConfig) -> ProtocolConfig + Send + Sync; static CONFIG_OVERRIDE: Mutex>> = Mutex::new(None); #[must_use] pub struct OverrideGuard; impl Drop for OverrideGuard { fn drop(&mut self) { info!("restoring override fn"); *CONFIG_OVERRIDE.lock().unwrap() = None; } } #[cfg(feature = "testing")] static BASE_CONFIG_OVERRIDES: Mutex>> = Mutex::new(Vec::new()); #[cfg(feature = "testing")] #[must_use] pub struct BaseOverrideGuard { override_fn: Arc, } #[cfg(feature = "testing")] impl Drop for BaseOverrideGuard { fn drop(&mut self) { BASE_CONFIG_OVERRIDES .lock() .unwrap() .retain(|f| !Arc::ptr_eq(f, &self.override_fn)); } } /// Defines which limit got crossed. /// The value which crossed the limit and value of the limit crossed are embedded #[derive(PartialEq, Eq)] pub enum LimitThresholdCrossed { None, Soft(u128, u128), Hard(u128, u128), } /// Convenience function for comparing limit ranges /// V::MAX must be at >= U::MAX and T::MAX pub fn check_limit_in_range, U: Into, V: PartialOrd + Into>( x: T, soft_limit: U, hard_limit: V, ) -> LimitThresholdCrossed { let x: V = x.into(); let soft_limit: V = soft_limit.into(); debug_assert!(soft_limit <= hard_limit); // It is important to preserve this comparison order because if soft_limit == hard_limit // we want LimitThresholdCrossed::Hard if x >= hard_limit { LimitThresholdCrossed::Hard(x.into(), hard_limit.into()) } else if x < soft_limit { LimitThresholdCrossed::None } else { LimitThresholdCrossed::Soft(x.into(), soft_limit.into()) } } #[macro_export] macro_rules! assert_set { ($protocol_config:expr, $($flag:ident),+ $(,)?) => {{ let protocol_config = $protocol_config; $( assert!( protocol_config.$flag(), "protocol config flag `{}` must be set", stringify!($flag), ); )+ }}; } #[macro_export] macro_rules! check_limit { ($x:expr, $hard:expr) => { check_limit!($x, $hard, $hard) }; ($x:expr, $soft:expr, $hard:expr) => { check_limit_in_range($x as u64, $soft, $hard) }; } /// Used to check which limits were crossed if the TX is metered (not system tx) /// Args are: is_metered, value_to_check, metered_limit, unmetered_limit /// metered_limit is always less than or equal to unmetered_hard_limit #[macro_export] macro_rules! check_limit_by_meter { ($is_metered:expr, $x:expr, $metered_limit:expr, $unmetered_hard_limit:expr, $metric:expr) => {{ // If this is metered, we use the metered_limit limit as the upper bound let (h, metered_str) = if $is_metered { ($metered_limit, "metered") } else { // Unmetered gets more headroom ($unmetered_hard_limit, "unmetered") }; use sui_protocol_config::check_limit_in_range; let result = check_limit_in_range($x as u64, $metered_limit, h); match result { LimitThresholdCrossed::None => {} LimitThresholdCrossed::Soft(_, _) => { $metric.with_label_values(&[metered_str, "soft"]).inc(); } LimitThresholdCrossed::Hard(_, _) => { $metric.with_label_values(&[metered_str, "hard"]).inc(); } }; result }}; } // Amendments tables pub type Amendments = BTreeMap>; static MAINNET_LINKAGE_AMENDMENTS: LazyLock> = LazyLock::new(|| parse_amendments(include_str!("mainnet_amendments.json"))); static TESTNET_LINKAGE_AMENDMENTS: LazyLock> = LazyLock::new(|| parse_amendments(include_str!("testnet_amendments.json"))); fn parse_amendments(json: &str) -> Arc { #[derive(serde::Deserialize)] struct AmendmentEntry { root: String, deps: Vec, } #[derive(serde::Deserialize)] struct DepEntry { original_id: String, version_id: String, } let entries: Vec = serde_json::from_str(json).expect("Failed to parse amendments JSON"); let mut amendments = BTreeMap::new(); for entry in entries { let root_id = AccountAddress::from_hex_literal(&entry.root).unwrap(); let mut dep_ids = BTreeMap::new(); for dep in entry.deps { let orig_id = AccountAddress::from_hex_literal(&dep.original_id).unwrap(); let upgraded_id = AccountAddress::from_hex_literal(&dep.version_id).unwrap(); assert!( dep_ids.insert(orig_id, upgraded_id).is_none(), "Duplicate original ID in amendments table" ); } assert!( amendments.insert(root_id, dep_ids).is_none(), "Duplicate root ID in amendments table" ); } Arc::new(amendments) } #[cfg(all(test, not(msim)))] mod test { use insta::assert_yaml_snapshot; use super::*; #[test] fn snapshot_tests() { println!("\n============================================================================"); println!("! !"); println!("! IMPORTANT: never update snapshots from this test. only add new versions! !"); println!("! !"); println!("============================================================================\n"); for chain_id in &[Chain::Unknown, Chain::Mainnet, Chain::Testnet] { // make Chain::Unknown snapshots compatible with pre-chain-id snapshots so that we // don't break the release-time compatibility tests. Once Chain Id configs have been // released everywhere, we can remove this and only test Mainnet and Testnet let chain_str = match chain_id { Chain::Unknown => "".to_string(), _ => format!("{:?}_", chain_id), }; for i in MIN_PROTOCOL_VERSION..=MAX_PROTOCOL_VERSION { let cur = ProtocolVersion::new(i); assert_yaml_snapshot!( format!("{}version_{}", chain_str, cur.as_u64()), ProtocolConfig::get_for_version(cur, *chain_id) ); } } } #[test] fn binary_format_limits_profile_matches_protocol_version() { let v141 = ProtocolConfig::get_for_version(ProtocolVersion::new(141), Chain::Unknown); assert_eq!( v141.binary_format_limits(), BinaryFormatLimitsProfile::LEGACY.limits() ); let v142 = ProtocolConfig::get_for_version(ProtocolVersion::new(142), Chain::Unknown); assert_eq!( v142.binary_format_limits(), BinaryFormatLimitsProfile::V1.limits() ); } #[test] fn test_getters() { let prot: ProtocolConfig = ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown); assert_eq!( prot.max_arguments(), prot.max_arguments_as_option().unwrap() ); } #[test] fn vector_bulk_native_gas_costs_start_at_version_140() { for chain in [Chain::Unknown, Chain::Mainnet, Chain::Testnet] { let before = ProtocolConfig::get_for_version(ProtocolVersion::new(139), chain); assert_eq!(before.vector_reverse_base_cost_as_option(), None); assert_eq!(before.vector_reverse_per_elem_cost_as_option(), None); assert_eq!(before.vector_keep_range_base_cost_as_option(), None); assert_eq!( before.vector_keep_range_per_dropped_elem_cost_as_option(), None ); assert_eq!( before.vector_keep_range_per_moved_elem_cost_as_option(), None ); assert_eq!(before.vector_copy_range_base_cost_as_option(), None); assert_eq!(before.vector_replace_range_base_cost_as_option(), None); assert_eq!(before.vector_replace_range_per_elem_cost_as_option(), None); let active = ProtocolConfig::get_for_version(ProtocolVersion::new(140), chain); assert_eq!(active.vector_reverse_base_cost_as_option(), Some(52)); assert_eq!(active.vector_reverse_per_elem_cost_as_option(), Some(8)); assert_eq!(active.vector_keep_range_base_cost_as_option(), Some(52)); assert_eq!( active.vector_keep_range_per_dropped_elem_cost_as_option(), Some(1) ); assert_eq!( active.vector_keep_range_per_moved_elem_cost_as_option(), Some(8) ); assert_eq!(active.vector_copy_range_base_cost_as_option(), Some(52)); assert_eq!(active.vector_replace_range_base_cost_as_option(), Some(52)); assert_eq!( active.vector_replace_range_per_elem_cost_as_option(), Some(8) ); } } #[test] fn test_setters() { let mut prot: ProtocolConfig = ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown); prot.set_max_arguments_for_testing(123); assert_eq!(prot.max_arguments(), 123); prot.set_max_arguments_from_str_for_testing("321".to_string()); assert_eq!(prot.max_arguments(), 321); prot.disable_max_arguments_for_testing(); assert_eq!(prot.max_arguments_as_option(), None); prot.set_attr_for_testing("max_arguments".to_string(), "456".to_string()); assert_eq!(prot.max_arguments(), 456); } #[test] fn test_execution_version_setter_allows_upgrade() { let mut prot = ProtocolConfig::get_for_max_version_UNSAFE(); let current = prot.execution_version(); prot.set_execution_version_for_testing(current); prot.set_execution_version_for_testing(current + 1); assert_eq!(prot.execution_version(), current + 1); } #[test] #[should_panic(expected = "cannot downgrade execution_version")] fn test_execution_version_setter_panics_on_downgrade() { let mut prot = ProtocolConfig::get_for_max_version_UNSAFE(); let current = prot.execution_version(); prot.set_execution_version_for_testing(current - 1); } #[test] fn test_feature_flag_setter_by_string() { let mut prot: ProtocolConfig = ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown); assert!(!prot.zklogin_auth()); prot.set_feature_flag_for_testing("zklogin_auth".to_string(), true); assert!(prot.zklogin_auth()); prot.set_feature_flag_for_testing("zklogin_auth".to_string(), false); assert!(!prot.zklogin_auth()); } #[test] #[should_panic(expected = "unknown feature flag")] fn test_feature_flag_setter_unknown_flag() { let mut prot: ProtocolConfig = ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown); prot.set_feature_flag_for_testing("some random string".to_string(), true); } #[test] fn test_get_for_version_if_supported_applies_test_overrides() { let before = ProtocolConfig::get_for_version_if_supported(ProtocolVersion::new(1), Chain::Unknown) .unwrap(); assert!(!before.enable_coin_reservation_obj_refs()); let _guard = ProtocolConfig::apply_overrides_for_testing(|_, mut cfg| { cfg.enable_coin_reservation_for_testing(); cfg }); let after = ProtocolConfig::get_for_version_if_supported(ProtocolVersion::new(1), Chain::Unknown) .unwrap(); assert!(after.enable_coin_reservation_obj_refs()); } #[test] #[should_panic(expected = "unsupported version")] fn max_version_test() { // When this does not panic, version higher than MAX_PROTOCOL_VERSION exists. // To fix, bump MAX_PROTOCOL_VERSION or disable this check for the version. let _ = ProtocolConfig::get_for_version_impl( ProtocolVersion::new(MAX_PROTOCOL_VERSION + 1), Chain::Unknown, ); } #[test] fn lookup_by_string_test() { let prot: ProtocolConfig = ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown); // Does not exist assert!(prot.lookup_attr("some random string".to_string()).is_none()); assert!( prot.lookup_attr("max_arguments".to_string()) == Some(ProtocolConfigValue::u32(prot.max_arguments())), ); // We didnt have this in version 1 assert!( prot.lookup_attr("max_move_identifier_len".to_string()) .is_none() ); // But we did in version 9 let prot: ProtocolConfig = ProtocolConfig::get_for_version(ProtocolVersion::new(9), Chain::Unknown); assert!( prot.lookup_attr("max_move_identifier_len".to_string()) == Some(ProtocolConfigValue::u64(prot.max_move_identifier_len())) ); let prot: ProtocolConfig = ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown); // We didnt have this in version 1 assert!( prot.attr_map() .get("max_move_identifier_len") .unwrap() .is_none() ); // We had this in version 1 assert!( prot.attr_map().get("max_arguments").unwrap() == &Some(ProtocolConfigValue::u32(prot.max_arguments())) ); // Check feature flags let prot: ProtocolConfig = ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown); // Does not exist assert!( prot.feature_flags .lookup_attr("some random string".to_owned()) .is_none() ); assert!( !prot .feature_flags .attr_map() .contains_key("some random string") ); // Was false in v1 assert!( prot.feature_flags .lookup_attr("package_upgrades".to_owned()) == Some(false) ); assert!( prot.feature_flags .attr_map() .get("package_upgrades") .unwrap() == &false ); let prot: ProtocolConfig = ProtocolConfig::get_for_version(ProtocolVersion::new(4), Chain::Unknown); // Was true from v3 and up assert!( prot.feature_flags .lookup_attr("package_upgrades".to_owned()) == Some(true) ); assert!( prot.feature_flags .attr_map() .get("package_upgrades") .unwrap() == &true ); } #[test] fn limit_range_fn_test() { let low = 100u32; let high = 10000u64; assert!(check_limit!(1u8, low, high) == LimitThresholdCrossed::None); assert!(matches!( check_limit!(255u16, low, high), LimitThresholdCrossed::Soft(255u128, 100) )); // This wont compile because lossy //assert!(check_limit!(100000000u128, low, high) == LimitThresholdCrossed::None); // This wont compile because lossy //assert!(check_limit!(100000000usize, low, high) == LimitThresholdCrossed::None); assert!(matches!( check_limit!(2550000u64, low, high), LimitThresholdCrossed::Hard(2550000, 10000) )); assert!(matches!( check_limit!(2550000u64, high, high), LimitThresholdCrossed::Hard(2550000, 10000) )); assert!(matches!( check_limit!(1u8, high), LimitThresholdCrossed::None )); assert!(check_limit!(255u16, high) == LimitThresholdCrossed::None); assert!(matches!( check_limit!(2550000u64, high), LimitThresholdCrossed::Hard(2550000, 10000) )); } #[test] fn linkage_amendments_load() { let mainnet = LazyLock::force(&MAINNET_LINKAGE_AMENDMENTS); let testnet = LazyLock::force(&TESTNET_LINKAGE_AMENDMENTS); assert!(!mainnet.is_empty(), "mainnet amendments must not be empty"); assert!(!testnet.is_empty(), "testnet amendments must not be empty"); } #[test] fn render_scalar_fields_use_precision_safe_encoding() { use mysten_common::rpc_format::Unmetered; let config = ProtocolConfig::get_for_max_version_UNSAFE(); let rendered = config .render::(&mut Unmetered) .expect("render should succeed"); let max_args = rendered .get("max_arguments") .expect("max_arguments set at max version"); assert!( max_args.is_number(), "u32 should render as number, got {max_args:?}", ); let max_tx_size = rendered .get("max_tx_size_bytes") .expect("max_tx_size_bytes set at max version"); assert!( max_tx_size.is_string(), "u64 should render as string, got {max_tx_size:?}", ); } #[test] fn render_includes_non_scalar_gasless_allowlist_as_json() { use mysten_common::rpc_format::Unmetered; use serde_json::json; let mut config = ProtocolConfig::get_for_max_version_UNSAFE(); config.set_gasless_allowed_token_types_for_testing(vec![ ("0xa::usdc::USDC".to_string(), 10_000), ("0xb::usdt::USDT".to_string(), 0), ]); let rendered = config .render::(&mut Unmetered) .expect("render should succeed under Unmetered budget"); let allowlist = rendered .get("gasless_allowed_token_types") .expect("entry should be present after the testing setter"); // u64 values render as strings to preserve JS precision; the tuple becomes a 2-element // JSON array. assert_eq!( allowlist, &json!([["0xa::usdc::USDC", "10000"], ["0xb::usdt::USDT", "0"],]), ); } #[test] fn render_targets_prost_value_for_grpc() { use mysten_common::rpc_format::Unmetered; use prost_types::value::Kind; let mut config = ProtocolConfig::get_for_max_version_UNSAFE(); config.set_gasless_allowed_token_types_for_testing(vec![( "0xa::usdc::USDC".to_string(), 10_000, )]); let rendered = config .render::(&mut Unmetered) .expect("render to prost Value should succeed"); let allowlist = rendered .get("gasless_allowed_token_types") .expect("entry should be present after the testing setter"); // Outer ListValue with one inner ListValue carrying [coin_type_string, amount_string]. let Some(Kind::ListValue(outer)) = &allowlist.kind else { panic!( "expected ListValue at the top level, got {:?}", allowlist.kind ); }; assert_eq!(outer.values.len(), 1, "one allowlisted entry"); let Some(Kind::ListValue(entry)) = &outer.values[0].kind else { panic!("expected each entry to be a ListValue"); }; assert_eq!(entry.values.len(), 2, "entry has (coin_type, amount)"); let Some(Kind::StringValue(coin_type)) = &entry.values[0].kind else { panic!("expected coin_type as StringValue"); }; assert_eq!(coin_type, "0xa::usdc::USDC"); // u64 amount renders as a string, not a NumberValue — this is the precision-safe path. let Some(Kind::StringValue(amount)) = &entry.values[1].kind else { panic!( "expected minimum_transfer_amount as StringValue (precision-safe u64); got {:?}", entry.values[1].kind, ); }; assert_eq!(amount, "10000"); } #[test] fn render_emits_null_for_unset_protocol_versions() { use mysten_common::rpc_format::Unmetered; let config = ProtocolConfig::get_for_version(1.into(), Chain::Unknown); let rendered = config .render::(&mut Unmetered) .expect("render should succeed"); // The gasless allowlist key is present in every version's keyset, but renders as JSON // `null` for versions that predate the feature. This keeps the keyset stable across // protocol versions so clients can distinguish "unknown key" from "present but unset". let entry = rendered .get("gasless_allowed_token_types") .expect("key should be present for every protocol version"); assert!( entry.is_null(), "value should be null for pre-feature protocol version, got {entry:?}", ); } }