1use std::{
5 collections::{BTreeMap, BTreeSet},
6 sync::{
7 Arc, LazyLock,
8 atomic::{AtomicBool, Ordering},
9 },
10};
11
12use std::sync::Mutex;
13
14use clap::*;
15use fastcrypto::encoding::{Base58, Encoding, Hex};
16use move_binary_format::{
17 binary_config::{BinaryConfig, BinaryFormatLimitsProfile, TableConfig},
18 file_format_common::*,
19};
20use move_core_types::account_address::AccountAddress;
21use move_vm_config::verifier::VerifierConfig;
22use mysten_common::in_integration_test;
23use serde::{Deserialize, Serialize};
24use serde_with::skip_serializing_none;
25use sui_protocol_config_macros::{
26 ProtocolConfigAccessors, ProtocolConfigFeatureFlagsGetters, ProtocolConfigOverride,
27};
28use tracing::{info, warn};
29
30pub mod reachability;
31
32#[doc(hidden)]
35pub use antithesis_sdk::linkme;
36#[doc(hidden)]
37pub use mysten_common::assert_reachable_simtest;
38
39const MIN_PROTOCOL_VERSION: u64 = 1;
41const MAX_PROTOCOL_VERSION: u64 = 145;
42
43const TESTNET_USDC: &str =
44 "0xa1ec7fc00a6f40db9693ad1415d0c193ad3906494428cf252621037bd7117e29::usdc::USDC";
45
46const MAINNET_USDC: &str =
47 "0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC";
48const MAINNET_USDSUI: &str =
49 "0x44f838219cf67b058f3b37907b655f226153c18e33dfcd0da559a844fea9b1c1::usdsui::USDSUI";
50const MAINNET_SUI_USDE: &str =
51 "0x41d587e5336f1c86cad50d38a7136db99333bb9bda91cea4ba69115defeb1402::sui_usde::SUI_USDE";
52const MAINNET_USDY: &str =
53 "0x960b531667636f39e85867775f52f6b1f220a058c4de786905bdf761e06a56bb::usdy::USDY";
54const MAINNET_FDUSD: &str =
55 "0xf16e6b723f242ec745dfd7634ad072c42d5c1d9ac9d62a39c381303eaa57693a::fdusd::FDUSD";
56const MAINNET_AUSD: &str =
57 "0x2053d08c1e2bd02791056171aab0fd12bd7cd7efad2ab8f6b9c8902f14df2ff2::ausd::AUSD";
58const MAINNET_USDB: &str =
59 "0xe14726c336e81b32328e92afc37345d159f5b550b09fa92bd43640cfdd0a0cfd::usdb::USDB";
60
61#[derive(Copy, Clone, Debug, Hash, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)]
455pub struct ProtocolVersion(u64);
456
457impl ProtocolVersion {
458 pub const MIN: Self = Self(MIN_PROTOCOL_VERSION);
463
464 pub const MAX: Self = Self(MAX_PROTOCOL_VERSION);
465
466 #[cfg(not(msim))]
467 pub const MAX_ALLOWED: Self = Self::MAX;
468
469 #[cfg(msim)]
471 pub const MAX_ALLOWED: Self = Self(MAX_PROTOCOL_VERSION + 1);
472
473 pub fn new(v: u64) -> Self {
474 Self(v)
475 }
476
477 pub const fn as_u64(&self) -> u64 {
478 self.0
479 }
480
481 pub fn max() -> Self {
484 Self::MAX
485 }
486
487 pub fn prev(self) -> Self {
488 Self(self.0.checked_sub(1).unwrap())
489 }
490}
491
492impl From<u64> for ProtocolVersion {
493 fn from(v: u64) -> Self {
494 Self::new(v)
495 }
496}
497
498impl std::ops::Sub<u64> for ProtocolVersion {
499 type Output = Self;
500 fn sub(self, rhs: u64) -> Self::Output {
501 Self::new(self.0 - rhs)
502 }
503}
504
505impl std::ops::Add<u64> for ProtocolVersion {
506 type Output = Self;
507 fn add(self, rhs: u64) -> Self::Output {
508 Self::new(self.0 + rhs)
509 }
510}
511
512#[derive(
513 Clone, Serialize, Deserialize, Debug, Default, PartialEq, Copy, PartialOrd, Ord, Eq, ValueEnum,
514)]
515pub enum Chain {
516 Mainnet,
517 Testnet,
518 #[default]
519 Unknown,
520}
521
522impl Chain {
523 pub fn as_str(self) -> &'static str {
524 match self {
525 Chain::Mainnet => "mainnet",
526 Chain::Testnet => "testnet",
527 Chain::Unknown => "unknown",
528 }
529 }
530}
531
532pub fn max_across_protocol<T: Ord>(f: impl Fn(&ProtocolConfig) -> Option<T>) -> Option<T> {
534 let mut max = None;
535 let mut version = ProtocolVersion::MIN;
536 while version <= ProtocolVersion::MAX {
537 max = max.max(f(&ProtocolConfig::get_for_version(version, Chain::Unknown)));
538 max = max.max(f(&ProtocolConfig::get_for_version(version, Chain::Mainnet)));
539 max = max.max(f(&ProtocolConfig::get_for_version(version, Chain::Testnet)));
540 version = version + 1;
541 }
542 max
543}
544
545pub struct Error(pub String);
546
547#[derive(Default, Clone, Serialize, Deserialize, Debug, ProtocolConfigFeatureFlagsGetters)]
550struct FeatureFlags {
551 #[serde(skip_serializing_if = "is_false")]
554 package_upgrades: bool,
555 #[serde(skip_serializing_if = "is_false")]
558 commit_root_state_digest: bool,
559 #[serde(skip_serializing_if = "is_false")]
561 advance_epoch_start_time_in_safe_mode: bool,
562 #[serde(skip_serializing_if = "is_false")]
565 loaded_child_objects_fixed: bool,
566 #[serde(skip_serializing_if = "is_false")]
569 missing_type_is_compatibility_error: bool,
570 #[serde(skip_serializing_if = "is_false")]
573 scoring_decision_with_validity_cutoff: bool,
574
575 #[serde(skip_serializing_if = "is_false")]
578 consensus_order_end_of_epoch_last: bool,
579
580 #[serde(skip_serializing_if = "is_false")]
584 consensus_slim_block_propagation: bool,
585
586 #[serde(skip_serializing_if = "is_false")]
588 disallow_adding_abilities_on_upgrade: bool,
589 #[serde(skip_serializing_if = "is_false")]
591 disable_invariant_violation_check_in_swap_loc: bool,
592 #[serde(skip_serializing_if = "is_false")]
595 advance_to_highest_supported_protocol_version: bool,
596 #[serde(skip_serializing_if = "is_false")]
598 ban_entry_init: bool,
599 #[serde(skip_serializing_if = "is_false")]
601 package_digest_hash_module: bool,
602 #[serde(skip_serializing_if = "is_false")]
604 disallow_change_struct_type_params_on_upgrade: bool,
605 #[serde(skip_serializing_if = "is_false")]
607 no_extraneous_module_bytes: bool,
608 #[serde(skip_serializing_if = "is_false")]
610 narwhal_versioned_metadata: bool,
611
612 #[serde(skip_serializing_if = "is_false")]
614 zklogin_auth: bool,
615 #[serde(skip_serializing_if = "is_zero")]
618 zklogin_circuit_mode: u64,
619 #[serde(skip_serializing_if = "ConsensusTransactionOrdering::is_none")]
621 consensus_transaction_ordering: ConsensusTransactionOrdering,
622
623 #[serde(skip_serializing_if = "is_false")]
631 simplified_unwrap_then_delete: bool,
632 #[serde(skip_serializing_if = "is_false")]
634 upgraded_multisig_supported: bool,
635 #[serde(skip_serializing_if = "is_false")]
637 txn_base_cost_as_multiplier: bool,
638
639 #[serde(skip_serializing_if = "is_false")]
641 shared_object_deletion: bool,
642
643 #[serde(skip_serializing_if = "is_false")]
645 narwhal_new_leader_election_schedule: bool,
646
647 #[serde(skip_serializing_if = "is_empty")]
649 zklogin_supported_providers: BTreeSet<String>,
650
651 #[serde(skip_serializing_if = "is_false")]
653 loaded_child_object_format: bool,
654
655 #[serde(skip_serializing_if = "is_false")]
656 #[skip_protocol_config_accessor]
657 enable_jwk_consensus_updates: bool,
658
659 #[serde(skip_serializing_if = "is_false")]
660 #[skip_protocol_config_accessor]
661 end_of_epoch_transaction_supported: bool,
662
663 #[serde(skip_serializing_if = "is_false")]
666 simple_conservation_checks: bool,
667
668 #[serde(skip_serializing_if = "is_false")]
670 loaded_child_object_format_type: bool,
671
672 #[serde(skip_serializing_if = "is_false")]
674 receive_objects: bool,
675
676 #[serde(skip_serializing_if = "is_false")]
678 consensus_checkpoint_signature_key_includes_digest: bool,
679
680 #[serde(skip_serializing_if = "is_false")]
682 random_beacon: bool,
683
684 #[serde(skip_serializing_if = "is_false")]
686 #[skip_protocol_config_accessor]
687 bridge: bool,
688
689 #[serde(skip_serializing_if = "is_false")]
690 enable_effects_v2: bool,
691
692 #[serde(skip_serializing_if = "is_false")]
694 narwhal_certificate_v2: bool,
695
696 #[serde(skip_serializing_if = "is_false")]
698 verify_legacy_zklogin_address: bool,
699
700 #[serde(skip_serializing_if = "is_false")]
702 throughput_aware_consensus_submission: bool,
703
704 #[serde(skip_serializing_if = "is_false")]
706 recompute_has_public_transfer_in_execution: bool,
707
708 #[serde(skip_serializing_if = "is_false")]
710 accept_zklogin_in_multisig: bool,
711
712 #[serde(skip_serializing_if = "is_false")]
714 accept_passkey_in_multisig: bool,
715
716 #[serde(skip_serializing_if = "is_false")]
718 validate_zklogin_public_identifier: bool,
719
720 #[serde(skip_serializing_if = "is_false")]
723 include_consensus_digest_in_prologue: bool,
724
725 #[serde(skip_serializing_if = "is_false")]
727 hardened_otw_check: bool,
728
729 #[serde(skip_serializing_if = "is_false")]
731 allow_receiving_object_id: bool,
732
733 #[serde(skip_serializing_if = "is_false")]
735 enable_poseidon: bool,
736
737 #[serde(skip_serializing_if = "is_false")]
739 enable_coin_deny_list: bool,
740
741 #[serde(skip_serializing_if = "is_false")]
743 enable_group_ops_native_functions: bool,
744
745 #[serde(skip_serializing_if = "is_false")]
747 enable_group_ops_native_function_msm: bool,
748
749 #[serde(skip_serializing_if = "is_false")]
751 enable_ristretto255_group_ops: bool,
752
753 #[serde(skip_serializing_if = "is_false")]
755 enable_verify_bulletproofs_ristretto255: bool,
756
757 #[serde(skip_serializing_if = "is_false")]
759 enable_nitro_attestation: bool,
760
761 #[serde(skip_serializing_if = "is_false")]
763 enable_nitro_attestation_upgraded_parsing: bool,
764
765 #[serde(skip_serializing_if = "is_false")]
767 enable_nitro_attestation_all_nonzero_pcrs_parsing: bool,
768
769 #[serde(skip_serializing_if = "is_false")]
771 enable_nitro_attestation_always_include_required_pcrs_parsing: bool,
772
773 #[serde(skip_serializing_if = "is_false")]
776 simplify_nitro_header_validation: bool,
777
778 #[serde(skip_serializing_if = "is_false")]
780 reject_mutable_random_on_entry_functions: bool,
781
782 #[serde(skip_serializing_if = "PerObjectCongestionControlMode::is_none")]
784 per_object_congestion_control_mode: PerObjectCongestionControlMode,
785
786 #[serde(skip_serializing_if = "ConsensusChoice::is_narwhal")]
788 consensus_choice: ConsensusChoice,
789
790 #[serde(skip_serializing_if = "ConsensusNetwork::is_anemo")]
792 consensus_network: ConsensusNetwork,
793
794 #[serde(skip_serializing_if = "is_false")]
796 correct_gas_payment_limit_check: bool,
797
798 #[serde(skip_serializing_if = "Option::is_none")]
800 zklogin_max_epoch_upper_bound_delta: Option<u64>,
801
802 #[serde(skip_serializing_if = "is_false")]
804 mysticeti_leader_scoring_and_schedule: bool,
805
806 #[serde(skip_serializing_if = "is_false")]
808 reshare_at_same_initial_version: bool,
809
810 #[serde(skip_serializing_if = "is_false")]
812 resolve_abort_locations_to_package_id: bool,
813
814 #[serde(skip_serializing_if = "is_false")]
818 mysticeti_use_committed_subdag_digest: bool,
819
820 #[serde(skip_serializing_if = "is_false")]
822 enable_vdf: bool,
823
824 #[serde(skip_serializing_if = "is_false")]
828 record_consensus_determined_version_assignments_in_prologue: bool,
829 #[serde(skip_serializing_if = "is_false")]
832 record_consensus_determined_version_assignments_in_prologue_v2: bool,
833
834 #[serde(skip_serializing_if = "is_false")]
836 fresh_vm_on_framework_upgrade: bool,
837
838 #[serde(skip_serializing_if = "is_false")]
846 prepend_prologue_tx_in_consensus_commit_in_checkpoints: bool,
847
848 #[serde(skip_serializing_if = "Option::is_none")]
850 mysticeti_num_leaders_per_round: Option<usize>,
851
852 #[serde(skip_serializing_if = "is_false")]
854 soft_bundle: bool,
855
856 #[serde(skip_serializing_if = "is_false")]
858 enable_coin_deny_list_v2: bool,
859
860 #[serde(skip_serializing_if = "is_false")]
862 passkey_auth: bool,
863
864 #[serde(skip_serializing_if = "is_false")]
867 mldsa65_auth: bool,
868
869 #[serde(skip_serializing_if = "is_false")]
871 secp256r1_ecrecover_checks_x_below_p: bool,
872
873 #[serde(skip_serializing_if = "is_false")]
876 secp256r1_strict_public_keys: bool,
877
878 #[serde(skip_serializing_if = "is_false")]
880 complete_effects_size_estimate: bool,
881
882 #[serde(skip_serializing_if = "is_false")]
884 authority_capabilities_v2: bool,
885
886 #[serde(skip_serializing_if = "is_false")]
888 rethrow_serialization_type_layout_errors: bool,
889
890 #[serde(skip_serializing_if = "is_false")]
892 consensus_distributed_vote_scoring_strategy: bool,
893
894 #[serde(skip_serializing_if = "is_false")]
896 consensus_round_prober: bool,
897
898 #[serde(skip_serializing_if = "is_false")]
900 validate_identifier_inputs: bool,
901
902 #[serde(skip_serializing_if = "is_false")]
904 disallow_self_identifier: bool,
905
906 #[serde(skip_serializing_if = "is_false")]
908 mysticeti_fastpath: bool,
909
910 #[serde(skip_serializing_if = "is_false")]
914 disable_preconsensus_locking: bool,
915
916 #[serde(skip_serializing_if = "is_false")]
918 relocate_event_module: bool,
919
920 #[serde(skip_serializing_if = "is_false")]
922 uncompressed_g1_group_elements: bool,
923
924 #[serde(skip_serializing_if = "is_false")]
925 disallow_new_modules_in_deps_only_packages: bool,
926
927 #[serde(skip_serializing_if = "is_false")]
929 consensus_smart_ancestor_selection: bool,
930
931 #[serde(skip_serializing_if = "is_false")]
933 consensus_round_prober_probe_accepted_rounds: bool,
934
935 #[serde(skip_serializing_if = "is_false")]
937 native_charging_v2: bool,
938
939 #[serde(skip_serializing_if = "is_false")]
942 #[skip_protocol_config_accessor]
943 consensus_linearize_subdag_v2: bool,
944
945 #[serde(skip_serializing_if = "is_false")]
947 convert_type_argument_error: bool,
948
949 #[serde(skip_serializing_if = "is_false")]
951 variant_nodes: bool,
952
953 #[serde(skip_serializing_if = "is_false")]
955 consensus_zstd_compression: bool,
956
957 #[serde(skip_serializing_if = "is_false")]
959 minimize_child_object_mutations: bool,
960
961 #[serde(skip_serializing_if = "is_false")]
964 record_additional_state_digest_in_prologue: bool,
965
966 #[serde(skip_serializing_if = "is_false")]
968 move_native_context: bool,
969
970 #[serde(skip_serializing_if = "is_false")]
973 #[skip_protocol_config_accessor]
974 consensus_median_based_commit_timestamp: bool,
975
976 #[serde(skip_serializing_if = "is_false")]
979 normalize_ptb_arguments: bool,
980
981 #[serde(skip_serializing_if = "is_false")]
983 consensus_batched_block_sync: bool,
984
985 #[serde(skip_serializing_if = "is_false")]
987 enforce_checkpoint_timestamp_monotonicity: bool,
988
989 #[serde(skip_serializing_if = "is_false")]
991 max_ptb_value_size_v2: bool,
992
993 #[serde(skip_serializing_if = "is_false")]
995 resolve_type_input_ids_to_defining_id: bool,
996
997 #[serde(skip_serializing_if = "is_false")]
999 enable_party_transfer: bool,
1000
1001 #[serde(skip_serializing_if = "is_false")]
1003 allow_unbounded_system_objects: bool,
1004
1005 #[serde(skip_serializing_if = "is_false")]
1007 type_tags_in_object_runtime: bool,
1008
1009 #[serde(skip_serializing_if = "is_false")]
1011 enable_accumulators: bool,
1012
1013 #[serde(skip_serializing_if = "is_false")]
1015 #[skip_protocol_config_accessor]
1016 enable_coin_reservation_obj_refs: bool,
1017
1018 #[serde(skip_serializing_if = "is_false")]
1021 create_root_accumulator_object: bool,
1022
1023 #[serde(skip_serializing_if = "is_false")]
1025 #[skip_protocol_config_accessor]
1026 enable_authenticated_event_streams: bool,
1027
1028 #[serde(skip_serializing_if = "is_false")]
1030 enable_address_balance_gas_payments: bool,
1031
1032 #[serde(skip_serializing_if = "is_false")]
1034 address_balance_gas_check_rgp_at_signing: bool,
1035
1036 #[serde(skip_serializing_if = "is_false")]
1037 address_balance_gas_reject_gas_coin_arg: bool,
1038
1039 #[serde(skip_serializing_if = "is_false")]
1041 enable_multi_epoch_transaction_expiration: bool,
1042
1043 #[serde(skip_serializing_if = "is_false")]
1045 relax_valid_during_for_owned_inputs: bool,
1046
1047 #[serde(skip_serializing_if = "is_false")]
1049 enable_ptb_execution_v2: bool,
1050
1051 #[serde(skip_serializing_if = "is_false")]
1053 better_adapter_type_resolution_errors: bool,
1054
1055 #[serde(skip_serializing_if = "is_false")]
1057 record_time_estimate_processed: bool,
1058
1059 #[serde(skip_serializing_if = "is_false")]
1061 dependency_linkage_error: bool,
1062
1063 #[serde(skip_serializing_if = "is_false")]
1065 additional_multisig_checks: bool,
1066
1067 #[serde(skip_serializing_if = "is_false")]
1069 ignore_execution_time_observations_after_certs_closed: bool,
1070
1071 #[serde(skip_serializing_if = "is_false")]
1075 debug_fatal_on_move_invariant_violation: bool,
1076
1077 #[serde(skip_serializing_if = "is_false")]
1080 allow_private_accumulator_entrypoints: bool,
1081
1082 #[serde(skip_serializing_if = "is_false")]
1085 additional_consensus_digest_indirect_state: bool,
1086
1087 #[serde(skip_serializing_if = "is_false")]
1089 check_for_init_during_upgrade: bool,
1090
1091 #[serde(skip_serializing_if = "is_false")]
1093 enable_init_on_upgrade: bool,
1094
1095 #[serde(skip_serializing_if = "is_false")]
1097 enable_order_independent_upgrade_init_linkage: bool,
1098
1099 #[serde(skip_serializing_if = "is_false")]
1102 harden_linkage_consistency: bool,
1103
1104 #[serde(skip_serializing_if = "is_false")]
1106 per_command_shared_object_transfer_rules: bool,
1107
1108 #[serde(skip_serializing_if = "is_false")]
1110 validate_ptb_argument_indices: bool,
1111
1112 #[serde(skip_serializing_if = "is_false")]
1114 include_checkpoint_artifacts_digest_in_summary: bool,
1115
1116 #[serde(skip_serializing_if = "is_false")]
1118 use_mfp_txns_in_load_initial_object_debts: bool,
1119
1120 #[serde(skip_serializing_if = "is_false")]
1122 cancel_for_failed_dkg_early: bool,
1123
1124 #[serde(skip_serializing_if = "is_false")]
1126 always_advance_dkg_to_resolution: bool,
1127
1128 #[serde(skip_serializing_if = "is_false")]
1130 allow_dkg_completion_after_timeout: bool,
1131
1132 #[serde(skip_serializing_if = "is_false")]
1134 enable_coin_registry: bool,
1135
1136 #[serde(skip_serializing_if = "is_false")]
1138 abstract_size_in_object_runtime: bool,
1139
1140 #[serde(skip_serializing_if = "is_false")]
1142 object_runtime_charge_cache_load_gas: bool,
1143
1144 #[serde(skip_serializing_if = "is_false")]
1146 additional_borrow_checks: bool,
1147
1148 #[serde(skip_serializing_if = "is_false")]
1150 use_new_commit_handler: bool,
1151
1152 #[serde(skip_serializing_if = "is_false")]
1154 better_loader_errors: bool,
1155
1156 #[serde(skip_serializing_if = "is_false")]
1158 generate_df_type_layouts: bool,
1159
1160 #[serde(skip_serializing_if = "is_false")]
1162 allow_references_in_ptbs: bool,
1163
1164 #[serde(skip_serializing_if = "is_false")]
1171 framework_tx_context_mut_restrictions: bool,
1172
1173 #[serde(skip_serializing_if = "is_false")]
1175 include_function_signatures_in_instantiation_limits: bool,
1176
1177 #[serde(skip_serializing_if = "is_false")]
1182 ptb_tx_context_restrictions: bool,
1183
1184 #[serde(skip_serializing_if = "is_false")]
1186 enable_display_registry: bool,
1187
1188 #[serde(skip_serializing_if = "is_false")]
1190 private_generics_verifier_v2: bool,
1191
1192 #[serde(skip_serializing_if = "is_false")]
1194 deprecate_global_storage_ops_during_deserialization: bool,
1195
1196 #[serde(skip_serializing_if = "is_false")]
1199 enable_non_exclusive_writes: bool,
1200
1201 #[serde(skip_serializing_if = "is_false")]
1203 deprecate_global_storage_ops: bool,
1204
1205 #[serde(skip_serializing_if = "is_false")]
1207 normalize_depth_formula: bool,
1208
1209 #[serde(skip_serializing_if = "is_false")]
1212 charge_ld_const_abstract_size: bool,
1213
1214 #[serde(skip_serializing_if = "is_false")]
1216 consensus_skip_gced_accept_votes: bool,
1217
1218 #[serde(skip_serializing_if = "is_false")]
1221 include_cancelled_randomness_txns_in_prologue: bool,
1222
1223 #[serde(skip_serializing_if = "is_false")]
1225 #[skip_protocol_config_accessor]
1226 address_aliases: bool,
1227
1228 #[serde(skip_serializing_if = "is_false")]
1230 create_forwarding_address_registry: bool,
1231
1232 #[serde(skip_serializing_if = "is_false")]
1234 enable_forwarding_addresses: bool,
1235
1236 #[serde(skip_serializing_if = "is_false")]
1239 fix_checkpoint_signature_mapping: bool,
1240
1241 #[serde(skip_serializing_if = "is_false")]
1243 enable_object_funds_withdraw: bool,
1244
1245 #[serde(skip_serializing_if = "is_false")]
1248 record_net_unsettled_object_withdraws: bool,
1249
1250 #[serde(skip_serializing_if = "is_false")]
1252 consensus_skip_gced_blocks_in_direct_finalization: bool,
1253
1254 #[serde(skip_serializing_if = "is_false")]
1256 gas_rounding_halve_digits: bool,
1257
1258 #[serde(skip_serializing_if = "is_false")]
1260 flexible_tx_context_positions: bool,
1261
1262 #[serde(skip_serializing_if = "is_false")]
1264 disable_entry_point_signature_check: bool,
1265
1266 #[serde(skip_serializing_if = "is_false")]
1268 convert_withdrawal_compatibility_ptb_arguments: bool,
1269
1270 #[serde(skip_serializing_if = "is_false")]
1272 restrict_hot_or_not_entry_functions: bool,
1273
1274 #[serde(skip_serializing_if = "is_false")]
1276 split_checkpoints_in_consensus_handler: bool,
1277
1278 #[serde(skip_serializing_if = "is_false")]
1280 consensus_always_accept_system_transactions: bool,
1281
1282 #[serde(skip_serializing_if = "is_false")]
1284 validator_metadata_verify_v2: bool,
1285
1286 #[serde(skip_serializing_if = "is_false")]
1289 defer_unpaid_amplification: bool,
1290
1291 #[serde(skip_serializing_if = "is_false")]
1294 defer_owned_object_double_spend: bool,
1295
1296 #[serde(skip_serializing_if = "is_false")]
1299 allowed_proposers: bool,
1300
1301 #[serde(skip_serializing_if = "is_false")]
1308 #[skip_protocol_config_accessor]
1309 staggered_submission_signal: bool,
1310
1311 #[serde(skip_serializing_if = "is_false")]
1312 randomize_checkpoint_tx_limit_in_tests: bool,
1313
1314 #[serde(skip_serializing_if = "is_false")]
1316 gasless_transaction_drop_safety: bool,
1317
1318 #[serde(skip_serializing_if = "is_false")]
1321 merge_randomness_into_checkpoint: bool,
1322
1323 #[serde(skip_serializing_if = "is_false")]
1325 use_coin_party_owner: bool,
1326
1327 #[serde(skip_serializing_if = "is_false")]
1328 enable_gasless: bool,
1329
1330 #[serde(skip_serializing_if = "is_false")]
1331 gasless_verify_remaining_balance: bool,
1332
1333 #[serde(skip_serializing_if = "is_false")]
1334 disallow_jump_orphans: bool,
1335
1336 #[serde(skip_serializing_if = "is_false")]
1338 early_return_receive_object_mismatched_type: bool,
1339
1340 #[serde(skip_serializing_if = "is_false")]
1345 timestamp_based_epoch_close: bool,
1346
1347 #[serde(skip_serializing_if = "is_false")]
1350 limit_groth16_pvk_inputs: bool,
1351
1352 #[serde(skip_serializing_if = "is_false")]
1356 check_groth16_pvk_length: bool,
1357
1358 #[serde(skip_serializing_if = "is_false")]
1363 enforce_address_balance_change_invariant: bool,
1364
1365 #[serde(skip_serializing_if = "is_false")]
1367 share_transaction_deny_config_in_consensus: bool,
1368
1369 #[serde(skip_serializing_if = "is_false")]
1371 granular_post_execution_checks: bool,
1372
1373 #[serde(skip_serializing_if = "is_false")]
1375 early_exit_on_iffw: bool,
1376
1377 #[serde(skip_serializing_if = "is_false")]
1379 enable_unified_linkage: bool,
1380
1381 #[serde(skip_serializing_if = "is_false")]
1383 package_publish_charge: bool,
1384
1385 #[serde(skip_serializing_if = "is_false")]
1388 #[skip_protocol_config_accessor]
1389 enable_allowances: bool,
1390
1391 #[serde(skip_serializing_if = "is_false")]
1393 fix_ptb_generated_reads: bool,
1394
1395 #[serde(skip_serializing_if = "is_false")]
1396 check_object_funds_withdraw_in_execution: bool,
1397 #[serde(skip_serializing_if = "is_false")]
1399 memory_safety_invariant_check_v2: bool,
1400
1401 #[serde(skip_serializing_if = "is_false")]
1403 disable_effects_tx_dependencies: bool,
1404
1405 #[serde(skip_serializing_if = "is_false")]
1409 merge_colliding_deferrals: bool,
1410
1411 #[serde(skip_serializing_if = "is_false")]
1415 shuffle_consensus_commit_blocks: bool,
1416
1417 #[serde(skip_serializing_if = "is_false")]
1420 disable_id_leak_verifier: bool,
1421
1422 #[serde(skip_serializing_if = "is_false")]
1427 enable_timestamp_transaction_expiration: bool,
1428
1429 #[serde(skip_serializing_if = "is_false")]
1431 create_freeze_list: bool,
1432
1433 #[serde(skip_serializing_if = "is_false")]
1436 enable_coin_regulation: bool,
1437}
1438
1439fn is_false(b: &bool) -> bool {
1440 !b
1441}
1442
1443fn is_empty(b: &BTreeSet<String>) -> bool {
1444 b.is_empty()
1445}
1446
1447fn is_zero(val: &u64) -> bool {
1448 *val == 0
1449}
1450
1451#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1453pub enum ConsensusTransactionOrdering {
1454 #[default]
1456 None,
1457 ByGasPrice,
1459}
1460
1461impl ConsensusTransactionOrdering {
1462 pub fn is_none(&self) -> bool {
1463 matches!(self, ConsensusTransactionOrdering::None)
1464 }
1465}
1466
1467#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1468pub struct ExecutionTimeEstimateParams {
1469 pub target_utilization: u64,
1471 pub allowed_txn_cost_overage_burst_limit_us: u64,
1475
1476 pub randomness_scalar: u64,
1479
1480 pub max_estimate_us: u64,
1482
1483 pub stored_observations_num_included_checkpoints: u64,
1486
1487 pub stored_observations_limit: u64,
1489
1490 #[serde(skip_serializing_if = "is_zero")]
1493 pub stake_weighted_median_threshold: u64,
1494
1495 #[serde(skip_serializing_if = "is_false")]
1499 pub default_none_duration_for_new_keys: bool,
1500
1501 #[serde(skip_serializing_if = "Option::is_none")]
1503 pub observations_chunk_size: Option<u64>,
1504}
1505
1506#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1508pub enum PerObjectCongestionControlMode {
1509 #[default]
1510 None, TotalGasBudget, TotalTxCount, TotalGasBudgetWithCap, ExecutionTimeEstimate(ExecutionTimeEstimateParams), }
1516
1517impl PerObjectCongestionControlMode {
1518 pub fn is_none(&self) -> bool {
1519 matches!(self, PerObjectCongestionControlMode::None)
1520 }
1521}
1522
1523#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1525pub enum ConsensusChoice {
1526 #[default]
1527 Narwhal,
1528 SwapEachEpoch,
1529 Mysticeti,
1530}
1531
1532impl ConsensusChoice {
1533 pub fn is_narwhal(&self) -> bool {
1534 matches!(self, ConsensusChoice::Narwhal)
1535 }
1536}
1537
1538#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1540pub enum ConsensusNetwork {
1541 #[default]
1542 Anemo,
1543 Tonic,
1544}
1545
1546impl ConsensusNetwork {
1547 pub fn is_anemo(&self) -> bool {
1548 matches!(self, ConsensusNetwork::Anemo)
1549 }
1550}
1551
1552#[skip_serializing_none]
1584#[derive(Clone, Serialize, Debug, ProtocolConfigAccessors, ProtocolConfigOverride)]
1585pub struct ProtocolConfig {
1586 pub version: ProtocolVersion,
1587
1588 #[serde(skip)]
1593 chain: Chain,
1594
1595 feature_flags: FeatureFlags,
1596
1597 max_tx_size_bytes: Option<u64>,
1600
1601 max_input_objects: Option<u64>,
1603
1604 max_size_written_objects: Option<u64>,
1608 max_size_written_objects_system_tx: Option<u64>,
1611
1612 max_serialized_tx_effects_size_bytes: Option<u64>,
1614
1615 max_serialized_tx_effects_size_bytes_system_tx: Option<u64>,
1617
1618 max_gas_payment_objects: Option<u32>,
1620
1621 max_modules_in_publish: Option<u32>,
1623
1624 max_package_dependencies: Option<u32>,
1626
1627 max_arguments: Option<u32>,
1630
1631 max_type_arguments: Option<u32>,
1633
1634 max_type_argument_depth: Option<u32>,
1636
1637 max_pure_argument_size: Option<u32>,
1639
1640 max_programmable_tx_commands: Option<u32>,
1642
1643 move_binary_format_version: Option<u32>,
1646 min_move_binary_format_version: Option<u32>,
1647
1648 binary_module_handles: Option<u16>,
1650 binary_struct_handles: Option<u16>,
1651 binary_function_handles: Option<u16>,
1652 binary_function_instantiations: Option<u16>,
1653 binary_signatures: Option<u16>,
1654 binary_constant_pool: Option<u16>,
1655 binary_identifiers: Option<u16>,
1656 binary_address_identifiers: Option<u16>,
1657 binary_struct_defs: Option<u16>,
1658 binary_struct_def_instantiations: Option<u16>,
1659 binary_function_defs: Option<u16>,
1660 binary_field_handles: Option<u16>,
1661 binary_field_instantiations: Option<u16>,
1662 binary_friend_decls: Option<u16>,
1663 binary_enum_defs: Option<u16>,
1664 binary_enum_def_instantiations: Option<u16>,
1665 binary_variant_handles: Option<u16>,
1666 binary_variant_instantiation_handles: Option<u16>,
1667
1668 #[skip_accessor]
1670 binary_format_limits_profile: Option<BinaryFormatLimitsProfile>,
1671
1672 max_move_object_size: Option<u64>,
1674
1675 max_move_package_size: Option<u64>,
1678
1679 max_publish_or_upgrade_per_ptb: Option<u64>,
1681
1682 max_tx_gas: Option<u64>,
1684
1685 max_gas_price: Option<u64>,
1687
1688 max_gas_price_rgp_factor_for_aborted_transactions: Option<u64>,
1691
1692 max_gas_computation_bucket: Option<u64>,
1694
1695 gas_rounding_step: Option<u64>,
1697
1698 max_loop_depth: Option<u64>,
1700
1701 max_generic_instantiation_length: Option<u64>,
1703
1704 max_function_parameters: Option<u64>,
1706
1707 max_basic_blocks: Option<u64>,
1709
1710 max_value_stack_size: Option<u64>,
1712
1713 max_type_nodes: Option<u64>,
1715
1716 max_generic_instantiation_type_nodes_per_function: Option<u64>,
1718
1719 max_generic_instantiation_type_nodes_per_module: Option<u64>,
1721
1722 max_accumulator_type_nodes: Option<u64>,
1724
1725 max_push_size: Option<u64>,
1727
1728 max_struct_definitions: Option<u64>,
1730
1731 max_function_definitions: Option<u64>,
1733
1734 max_fields_in_struct: Option<u64>,
1736
1737 max_dependency_depth: Option<u64>,
1739
1740 max_num_event_emit: Option<u64>,
1742
1743 max_num_accumulator_events: Option<u64>,
1747
1748 max_num_new_move_object_ids: Option<u64>,
1750
1751 max_num_new_move_object_ids_system_tx: Option<u64>,
1753
1754 max_num_deleted_move_object_ids: Option<u64>,
1756
1757 max_num_deleted_move_object_ids_system_tx: Option<u64>,
1759
1760 max_num_transferred_move_object_ids: Option<u64>,
1762
1763 max_num_transferred_move_object_ids_system_tx: Option<u64>,
1765
1766 max_event_emit_size: Option<u64>,
1768
1769 max_event_emit_size_total: Option<u64>,
1771
1772 max_move_vector_len: Option<u64>,
1774
1775 max_move_identifier_len: Option<u64>,
1777
1778 max_move_value_depth: Option<u64>,
1780
1781 package_arena_size_in_bytes: Option<u64>,
1784
1785 max_move_enum_variants: Option<u64>,
1787
1788 max_back_edges_per_function: Option<u64>,
1790
1791 max_back_edges_per_module: Option<u64>,
1793
1794 max_verifier_meter_ticks_per_function: Option<u64>,
1796
1797 max_meter_ticks_per_module: Option<u64>,
1799
1800 max_meter_ticks_per_package: Option<u64>,
1802
1803 object_runtime_max_num_cached_objects: Option<u64>,
1807
1808 object_runtime_max_num_cached_objects_system_tx: Option<u64>,
1810
1811 object_runtime_max_loaded_child_value_size: Option<u64>,
1813
1814 object_runtime_max_num_store_entries: Option<u64>,
1816
1817 object_runtime_max_num_store_entries_system_tx: Option<u64>,
1819
1820 base_tx_cost_fixed: Option<u64>,
1823
1824 package_publish_cost_fixed: Option<u64>,
1827
1828 base_tx_cost_per_byte: Option<u64>,
1831
1832 package_publish_cost_per_byte: Option<u64>,
1834
1835 package_publish_charge_fixed: Option<u64>,
1837
1838 package_publish_charge_per_module: Option<u64>,
1840
1841 package_publish_charge_per_dependency: Option<u64>,
1843
1844 obj_access_cost_read_per_byte: Option<u64>,
1846
1847 obj_access_cost_read_per_package_kb: Option<u64>,
1850
1851 obj_access_cost_mutate_per_byte: Option<u64>,
1853
1854 obj_access_cost_delete_per_byte: Option<u64>,
1856
1857 obj_access_cost_verify_per_byte: Option<u64>,
1867
1868 max_type_to_layout_nodes: Option<u64>,
1870
1871 max_ptb_value_size: Option<u64>,
1873
1874 gas_model_version: Option<u64>,
1877
1878 obj_data_cost_refundable: Option<u64>,
1881
1882 obj_metadata_cost_non_refundable: Option<u64>,
1886
1887 storage_rebate_rate: Option<u64>,
1893
1894 storage_fund_reinvest_rate: Option<u64>,
1897
1898 reward_slashing_rate: Option<u64>,
1901
1902 storage_gas_price: Option<u64>,
1904
1905 accumulator_object_storage_cost: Option<u64>,
1907
1908 max_transactions_per_checkpoint: Option<u64>,
1913
1914 max_checkpoint_size_bytes: Option<u64>,
1918
1919 buffer_stake_for_protocol_upgrade_bps: Option<u64>,
1924
1925 address_from_bytes_cost_base: Option<u64>,
1930 address_to_u256_cost_base: Option<u64>,
1932 address_from_u256_cost_base: Option<u64>,
1934
1935 config_read_setting_impl_cost_base: Option<u64>,
1940 config_read_setting_impl_cost_per_byte: Option<u64>,
1941
1942 package_original_package_id_impl_cost_base: Option<u64>,
1943 package_original_package_id_impl_cost_per_byte: Option<u64>,
1944
1945 dynamic_field_hash_type_and_key_cost_base: Option<u64>,
1948 dynamic_field_hash_type_and_key_type_cost_per_byte: Option<u64>,
1949 dynamic_field_hash_type_and_key_value_cost_per_byte: Option<u64>,
1950 dynamic_field_hash_type_and_key_type_tag_cost_per_byte: Option<u64>,
1951 dynamic_field_add_child_object_cost_base: Option<u64>,
1953 dynamic_field_add_child_object_type_cost_per_byte: Option<u64>,
1954 dynamic_field_add_child_object_value_cost_per_byte: Option<u64>,
1955 dynamic_field_add_child_object_struct_tag_cost_per_byte: Option<u64>,
1956 dynamic_field_borrow_child_object_cost_base: Option<u64>,
1958 dynamic_field_borrow_child_object_child_ref_cost_per_byte: Option<u64>,
1959 dynamic_field_borrow_child_object_type_cost_per_byte: Option<u64>,
1960 dynamic_field_remove_child_object_cost_base: Option<u64>,
1962 dynamic_field_remove_child_object_child_cost_per_byte: Option<u64>,
1963 dynamic_field_remove_child_object_type_cost_per_byte: Option<u64>,
1964 dynamic_field_has_child_object_cost_base: Option<u64>,
1966 dynamic_field_has_child_object_with_ty_cost_base: Option<u64>,
1968 dynamic_field_has_child_object_with_ty_type_cost_per_byte: Option<u64>,
1969 dynamic_field_has_child_object_with_ty_type_tag_cost_per_byte: Option<u64>,
1970
1971 scratch_add_cost_base: Option<u64>,
1974 scratch_read_cost_base: Option<u64>,
1976 scratch_read_value_cost: Option<u64>,
1977 scratch_remove_cost_base: Option<u64>,
1979 scratch_exists_cost_base: Option<u64>,
1981 scratch_exists_with_type_cost_base: Option<u64>,
1983 scratch_exists_with_type_type_cost: Option<u64>,
1984 max_scratch_pad_size: Option<u64>,
1986
1987 event_emit_cost_base: Option<u64>,
1990 event_emit_value_size_derivation_cost_per_byte: Option<u64>,
1991 event_emit_tag_size_derivation_cost_per_byte: Option<u64>,
1992 event_emit_output_cost_per_byte: Option<u64>,
1993 event_emit_auth_stream_cost: Option<u64>,
1994
1995 reserve_object_funds_for_withdrawal_cost_base: Option<u64>,
1998 reserve_object_funds_for_withdrawal_cold_read_cost: Option<u64>,
2000
2001 object_borrow_uid_cost_base: Option<u64>,
2004 object_delete_impl_cost_base: Option<u64>,
2006 object_record_new_uid_cost_base: Option<u64>,
2008 object_record_new_uid_from_hash_cost_base: Option<u64>,
2011 object_is_shared_input_cost_base: Option<u64>,
2013
2014 transfer_transfer_internal_cost_base: Option<u64>,
2017 transfer_party_transfer_internal_cost_base: Option<u64>,
2019 transfer_freeze_object_cost_base: Option<u64>,
2021 transfer_share_object_cost_base: Option<u64>,
2023 transfer_receive_object_cost_base: Option<u64>,
2026 transfer_receive_object_cost_per_byte: Option<u64>,
2027 transfer_receive_object_type_cost_per_byte: Option<u64>,
2028
2029 tx_context_derive_id_cost_base: Option<u64>,
2032 tx_context_fresh_id_cost_base: Option<u64>,
2033 tx_context_sender_cost_base: Option<u64>,
2034 tx_context_epoch_cost_base: Option<u64>,
2035 tx_context_epoch_timestamp_ms_cost_base: Option<u64>,
2036 tx_context_sponsor_cost_base: Option<u64>,
2037 tx_context_rgp_cost_base: Option<u64>,
2038 tx_context_gas_price_cost_base: Option<u64>,
2039 tx_context_gas_budget_cost_base: Option<u64>,
2040 tx_context_ids_created_cost_base: Option<u64>,
2041 tx_context_replace_cost_base: Option<u64>,
2042
2043 clock_borrow_cost_base: Option<u64>,
2046
2047 types_is_one_time_witness_cost_base: Option<u64>,
2050 types_is_one_time_witness_type_tag_cost_per_byte: Option<u64>,
2051 types_is_one_time_witness_type_cost_per_byte: Option<u64>,
2052
2053 validator_validate_metadata_cost_base: Option<u64>,
2056 validator_validate_metadata_data_cost_per_byte: Option<u64>,
2057
2058 crypto_invalid_arguments_cost: Option<u64>,
2060 bls12381_bls12381_min_sig_verify_cost_base: Option<u64>,
2062 bls12381_bls12381_min_sig_verify_msg_cost_per_byte: Option<u64>,
2063 bls12381_bls12381_min_sig_verify_msg_cost_per_block: Option<u64>,
2064
2065 bls12381_bls12381_min_pk_verify_cost_base: Option<u64>,
2067 bls12381_bls12381_min_pk_verify_msg_cost_per_byte: Option<u64>,
2068 bls12381_bls12381_min_pk_verify_msg_cost_per_block: Option<u64>,
2069
2070 ecdsa_k1_ecrecover_keccak256_cost_base: Option<u64>,
2072 ecdsa_k1_ecrecover_keccak256_msg_cost_per_byte: Option<u64>,
2073 ecdsa_k1_ecrecover_keccak256_msg_cost_per_block: Option<u64>,
2074 ecdsa_k1_ecrecover_sha256_cost_base: Option<u64>,
2075 ecdsa_k1_ecrecover_sha256_msg_cost_per_byte: Option<u64>,
2076 ecdsa_k1_ecrecover_sha256_msg_cost_per_block: Option<u64>,
2077
2078 ecdsa_k1_decompress_pubkey_cost_base: Option<u64>,
2080
2081 ecdsa_k1_secp256k1_verify_keccak256_cost_base: Option<u64>,
2083 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_byte: Option<u64>,
2084 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_block: Option<u64>,
2085 ecdsa_k1_secp256k1_verify_sha256_cost_base: Option<u64>,
2086 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_byte: Option<u64>,
2087 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_block: Option<u64>,
2088
2089 ecdsa_r1_ecrecover_keccak256_cost_base: Option<u64>,
2091 ecdsa_r1_ecrecover_keccak256_msg_cost_per_byte: Option<u64>,
2092 ecdsa_r1_ecrecover_keccak256_msg_cost_per_block: Option<u64>,
2093 ecdsa_r1_ecrecover_sha256_cost_base: Option<u64>,
2094 ecdsa_r1_ecrecover_sha256_msg_cost_per_byte: Option<u64>,
2095 ecdsa_r1_ecrecover_sha256_msg_cost_per_block: Option<u64>,
2096
2097 ecdsa_r1_secp256r1_verify_keccak256_cost_base: Option<u64>,
2099 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_byte: Option<u64>,
2100 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_block: Option<u64>,
2101 ecdsa_r1_secp256r1_verify_sha256_cost_base: Option<u64>,
2102 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_byte: Option<u64>,
2103 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_block: Option<u64>,
2104
2105 ecvrf_ecvrf_verify_cost_base: Option<u64>,
2107 ecvrf_ecvrf_verify_alpha_string_cost_per_byte: Option<u64>,
2108 ecvrf_ecvrf_verify_alpha_string_cost_per_block: Option<u64>,
2109
2110 ed25519_ed25519_verify_cost_base: Option<u64>,
2112 ed25519_ed25519_verify_msg_cost_per_byte: Option<u64>,
2113 ed25519_ed25519_verify_msg_cost_per_block: Option<u64>,
2114
2115 groth16_prepare_verifying_key_bls12381_cost_base: Option<u64>,
2117 groth16_prepare_verifying_key_bn254_cost_base: Option<u64>,
2118
2119 groth16_verify_groth16_proof_internal_bls12381_cost_base: Option<u64>,
2121 groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input: Option<u64>,
2122 groth16_verify_groth16_proof_internal_bn254_cost_base: Option<u64>,
2123 groth16_verify_groth16_proof_internal_bn254_cost_per_public_input: Option<u64>,
2124 groth16_verify_groth16_proof_internal_public_input_cost_per_byte: Option<u64>,
2125
2126 hash_blake2b256_cost_base: Option<u64>,
2128 hash_blake2b256_data_cost_per_byte: Option<u64>,
2129 hash_blake2b256_data_cost_per_block: Option<u64>,
2130
2131 hash_keccak256_cost_base: Option<u64>,
2133 hash_keccak256_data_cost_per_byte: Option<u64>,
2134 hash_keccak256_data_cost_per_block: Option<u64>,
2135
2136 poseidon_bn254_cost_base: Option<u64>,
2138 poseidon_bn254_cost_per_block: Option<u64>,
2139
2140 group_ops_bls12381_decode_scalar_cost: Option<u64>,
2142 group_ops_bls12381_decode_g1_cost: Option<u64>,
2143 group_ops_bls12381_decode_g2_cost: Option<u64>,
2144 group_ops_bls12381_decode_gt_cost: Option<u64>,
2145 group_ops_bls12381_scalar_add_cost: Option<u64>,
2146 group_ops_bls12381_g1_add_cost: Option<u64>,
2147 group_ops_bls12381_g2_add_cost: Option<u64>,
2148 group_ops_bls12381_gt_add_cost: Option<u64>,
2149 group_ops_bls12381_scalar_sub_cost: Option<u64>,
2150 group_ops_bls12381_g1_sub_cost: Option<u64>,
2151 group_ops_bls12381_g2_sub_cost: Option<u64>,
2152 group_ops_bls12381_gt_sub_cost: Option<u64>,
2153 group_ops_bls12381_scalar_mul_cost: Option<u64>,
2154 group_ops_bls12381_g1_mul_cost: Option<u64>,
2155 group_ops_bls12381_g2_mul_cost: Option<u64>,
2156 group_ops_bls12381_gt_mul_cost: Option<u64>,
2157 group_ops_bls12381_scalar_div_cost: Option<u64>,
2158 group_ops_bls12381_g1_div_cost: Option<u64>,
2159 group_ops_bls12381_g2_div_cost: Option<u64>,
2160 group_ops_bls12381_gt_div_cost: Option<u64>,
2161 group_ops_bls12381_g1_hash_to_base_cost: Option<u64>,
2162 group_ops_bls12381_g2_hash_to_base_cost: Option<u64>,
2163 group_ops_bls12381_g1_hash_to_cost_per_byte: Option<u64>,
2164 group_ops_bls12381_g2_hash_to_cost_per_byte: Option<u64>,
2165 group_ops_bls12381_g1_msm_base_cost: Option<u64>,
2166 group_ops_bls12381_g2_msm_base_cost: Option<u64>,
2167 group_ops_bls12381_g1_msm_base_cost_per_input: Option<u64>,
2168 group_ops_bls12381_g2_msm_base_cost_per_input: Option<u64>,
2169 group_ops_bls12381_msm_max_len: Option<u32>,
2170 group_ops_bls12381_pairing_cost: Option<u64>,
2171 group_ops_bls12381_g1_to_uncompressed_g1_cost: Option<u64>,
2172 group_ops_bls12381_uncompressed_g1_to_g1_cost: Option<u64>,
2173 group_ops_bls12381_uncompressed_g1_sum_base_cost: Option<u64>,
2174 group_ops_bls12381_uncompressed_g1_sum_cost_per_term: Option<u64>,
2175 group_ops_bls12381_uncompressed_g1_sum_max_terms: Option<u64>,
2176
2177 group_ops_ristretto_decode_scalar_cost: Option<u64>,
2178 group_ops_ristretto_decode_point_cost: Option<u64>,
2179 group_ops_ristretto_scalar_add_cost: Option<u64>,
2180 group_ops_ristretto_point_add_cost: Option<u64>,
2181 group_ops_ristretto_scalar_sub_cost: Option<u64>,
2182 group_ops_ristretto_point_sub_cost: Option<u64>,
2183 group_ops_ristretto_scalar_mul_cost: Option<u64>,
2184 group_ops_ristretto_point_mul_cost: Option<u64>,
2185 group_ops_ristretto_scalar_div_cost: Option<u64>,
2186 group_ops_ristretto_point_div_cost: Option<u64>,
2187
2188 verify_bulletproofs_ristretto255_base_cost: Option<u64>,
2189 verify_bulletproofs_ristretto255_cost_per_bit_and_commitment: Option<u64>,
2190 max_bulletproofs_total_bits: Option<u64>,
2193
2194 hmac_hmac_sha3_256_cost_base: Option<u64>,
2196 hmac_hmac_sha3_256_input_cost_per_byte: Option<u64>,
2197 hmac_hmac_sha3_256_input_cost_per_block: Option<u64>,
2198
2199 check_zklogin_id_cost_base: Option<u64>,
2201 check_zklogin_issuer_cost_base: Option<u64>,
2203
2204 vdf_verify_vdf_cost: Option<u64>,
2205 vdf_hash_to_input_cost: Option<u64>,
2206
2207 nitro_attestation_parse_base_cost: Option<u64>,
2209 nitro_attestation_parse_cost_per_byte: Option<u64>,
2210 nitro_attestation_verify_base_cost: Option<u64>,
2211 nitro_attestation_verify_cost_per_cert: Option<u64>,
2212
2213 layout_node_cost: Option<u64>,
2215 layout_node_cost_large_layout_threshold: Option<u64>,
2217
2218 bcs_per_input_abstract_unit_cost: Option<u64>,
2220 bcs_per_byte_serialized_cost: Option<u64>,
2221 bcs_legacy_min_output_size_cost: Option<u64>,
2222 bcs_failure_cost: Option<u64>,
2223
2224 hash_sha2_256_base_cost: Option<u64>,
2225 hash_sha2_256_per_byte_cost: Option<u64>,
2226 hash_sha2_256_legacy_min_input_len_cost: Option<u64>,
2227 hash_sha3_256_base_cost: Option<u64>,
2228 hash_sha3_256_per_byte_cost: Option<u64>,
2229 hash_sha3_256_legacy_min_input_len_cost: Option<u64>,
2230 type_name_get_base_cost: Option<u64>,
2231 type_name_get_per_byte_cost: Option<u64>,
2232 type_name_id_base_cost: Option<u64>,
2233
2234 string_check_utf8_base_cost: Option<u64>,
2235 string_check_utf8_per_byte_cost: Option<u64>,
2236 string_is_char_boundary_base_cost: Option<u64>,
2237 string_sub_string_base_cost: Option<u64>,
2238 string_sub_string_per_byte_cost: Option<u64>,
2239 string_index_of_base_cost: Option<u64>,
2240 string_index_of_per_byte_pattern_cost: Option<u64>,
2241 string_index_of_per_byte_searched_cost: Option<u64>,
2242
2243 vector_empty_base_cost: Option<u64>,
2244 vector_length_base_cost: Option<u64>,
2245 vector_push_back_base_cost: Option<u64>,
2246 vector_push_back_legacy_per_abstract_memory_unit_cost: Option<u64>,
2247 vector_borrow_base_cost: Option<u64>,
2248 vector_pop_back_base_cost: Option<u64>,
2249 vector_destroy_empty_base_cost: Option<u64>,
2250 vector_swap_base_cost: Option<u64>,
2251 vector_reverse_base_cost: Option<u64>,
2252 vector_reverse_per_elem_cost: Option<u64>,
2253 vector_keep_range_base_cost: Option<u64>,
2254 vector_keep_range_per_dropped_elem_cost: Option<u64>,
2255 vector_keep_range_per_moved_elem_cost: Option<u64>,
2256 vector_copy_range_base_cost: Option<u64>,
2257 vector_copy_range_per_abstract_memory_unit_cost: Option<u64>,
2258 vector_replace_range_base_cost: Option<u64>,
2259 vector_replace_range_per_elem_cost: Option<u64>,
2260 debug_print_base_cost: Option<u64>,
2261 debug_print_stack_trace_base_cost: Option<u64>,
2262
2263 #[custom_setter]
2273 execution_version: Option<u64>,
2274
2275 consensus_bad_nodes_stake_threshold: Option<u64>,
2279
2280 max_jwk_votes_per_validator_per_epoch: Option<u64>,
2281 max_age_of_jwk_in_epochs: Option<u64>,
2285
2286 random_beacon_reduction_allowed_delta: Option<u16>,
2290
2291 random_beacon_reduction_lower_bound: Option<u32>,
2294
2295 random_beacon_dkg_timeout_round: Option<u32>,
2298
2299 random_beacon_min_round_interval_ms: Option<u64>,
2301
2302 random_beacon_dkg_version: Option<u64>,
2305
2306 consensus_max_transaction_size_bytes: Option<u64>,
2309 consensus_max_transactions_in_block_bytes: Option<u64>,
2311 consensus_max_num_transactions_in_block: Option<u64>,
2313
2314 consensus_voting_rounds: Option<u32>,
2316
2317 max_accumulated_txn_cost_per_object_in_narwhal_commit: Option<u64>,
2319
2320 max_deferral_rounds_for_congestion_control: Option<u64>,
2323
2324 epoch_close_deadline_ms: Option<u64>,
2329
2330 max_txn_cost_overage_per_object_in_commit: Option<u64>,
2332
2333 allowed_txn_cost_overage_burst_per_object_in_commit: Option<u64>,
2335
2336 min_checkpoint_interval_ms: Option<u64>,
2338
2339 checkpoint_summary_version_specific_data: Option<u64>,
2341
2342 max_soft_bundle_size: Option<u64>,
2344
2345 bridge_should_try_to_finalize_committee: Option<bool>,
2349
2350 max_accumulated_txn_cost_per_object_in_mysticeti_commit: Option<u64>,
2356
2357 max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit: Option<u64>,
2360
2361 consensus_gc_depth: Option<u32>,
2364
2365 gas_budget_based_txn_cost_cap_factor: Option<u64>,
2367
2368 gas_budget_based_txn_cost_absolute_cap_commit_count: Option<u64>,
2370
2371 sip_45_consensus_amplification_threshold: Option<u64>,
2374
2375 staggered_submission_signal_window_commits: Option<u64>,
2378 staggered_submission_signal_min_excess_copies_per_commit: Option<u64>,
2383 staggered_submission_signal_min_consensus_user_transactions_per_commit: Option<u64>,
2389 staggered_submission_signal_exit_dwell_commits: Option<u64>,
2394 staggered_submission_signal_band1_enter_ratio_bps: Option<u64>,
2397 staggered_submission_signal_band1_exit_ratio_bps: Option<u64>,
2398 staggered_submission_signal_band2_enter_ratio_bps: Option<u64>,
2399 staggered_submission_signal_band2_exit_ratio_bps: Option<u64>,
2400
2401 use_object_per_epoch_marker_table_v2: Option<bool>,
2404
2405 consensus_commit_rate_estimation_window_size: Option<u32>,
2407
2408 #[serde(skip_serializing_if = "Vec::is_empty")]
2412 aliased_addresses: Vec<AliasedAddress>,
2413
2414 translation_per_command_base_charge: Option<u64>,
2417
2418 translation_per_input_base_charge: Option<u64>,
2421
2422 translation_pure_input_per_byte_charge: Option<u64>,
2424
2425 translation_per_type_node_charge: Option<u64>,
2429
2430 translation_per_reference_node_charge: Option<u64>,
2433
2434 translation_per_linkage_entry_charge: Option<u64>,
2437
2438 max_updates_per_settlement_txn: Option<u32>,
2440
2441 gasless_max_computation_units: Option<u64>,
2443
2444 gasless_allowed_token_types: Option<Vec<(String, u64)>>,
2446
2447 gasless_max_unused_inputs: Option<u64>,
2451
2452 gasless_max_pure_input_bytes: Option<u64>,
2455
2456 gasless_max_tps: Option<u64>,
2458
2459 #[serde(skip_serializing_if = "Option::is_none")]
2460 #[skip_accessor]
2461 include_special_package_amendments: Option<Arc<Amendments>>,
2462
2463 gasless_max_tx_size_bytes: Option<u64>,
2466
2467 translation_per_live_reference_charge: Option<u64>,
2470
2471 max_ptb_live_references: Option<u64>,
2474
2475 max_ptb_returned_references: Option<u64>,
2478
2479 max_ptb_total_returned_references: Option<u64>,
2482}
2483
2484#[derive(Clone, Serialize, Deserialize, Debug)]
2486pub struct AliasedAddress {
2487 pub original: [u8; 32],
2489 pub aliased: [u8; 32],
2491 pub allowed_tx_digests: Vec<[u8; 32]>,
2493}
2494
2495impl ProtocolConfig {
2497 pub fn chain(&self) -> Chain {
2499 self.chain
2500 }
2501
2502 pub fn check_package_upgrades_supported(&self) -> Result<(), Error> {
2515 if self.feature_flags.package_upgrades {
2516 Ok(())
2517 } else {
2518 Err(Error(format!(
2519 "package upgrades are not supported at {:?}",
2520 self.version
2521 )))
2522 }
2523 }
2524
2525 pub fn zklogin_supported_providers(&self) -> &BTreeSet<String> {
2526 &self.feature_flags.zklogin_supported_providers
2527 }
2528
2529 pub fn zklogin_circuit_mode(&self) -> u64 {
2532 self.feature_flags.zklogin_circuit_mode
2533 }
2534
2535 pub fn consensus_transaction_ordering(&self) -> ConsensusTransactionOrdering {
2536 self.feature_flags.consensus_transaction_ordering
2537 }
2538
2539 pub fn enable_jwk_consensus_updates(&self) -> bool {
2540 let ret = self.feature_flags.enable_jwk_consensus_updates;
2541 if ret {
2542 assert!(self.feature_flags.end_of_epoch_transaction_supported);
2544 }
2545 ret
2546 }
2547
2548 pub fn staggered_submission_signal(&self) -> bool {
2549 let ret = self.feature_flags.staggered_submission_signal;
2550 if ret {
2551 assert!(self.feature_flags.allowed_proposers);
2554 }
2555 ret
2556 }
2557
2558 pub fn end_of_epoch_transaction_supported(&self) -> bool {
2559 let ret = self.feature_flags.end_of_epoch_transaction_supported;
2560 if !ret {
2561 assert!(!self.feature_flags.enable_jwk_consensus_updates);
2563 }
2564 ret
2565 }
2566
2567 pub fn dkg_version(&self) -> u64 {
2568 self.random_beacon_dkg_version.unwrap_or(1)
2570 }
2571
2572 pub fn bridge(&self) -> bool {
2573 let ret = self.feature_flags.bridge;
2574 if ret {
2575 assert!(self.feature_flags.end_of_epoch_transaction_supported);
2577 }
2578 ret
2579 }
2580
2581 pub fn should_try_to_finalize_bridge_committee(&self) -> bool {
2582 if !self.bridge() {
2583 return false;
2584 }
2585 self.bridge_should_try_to_finalize_committee.unwrap_or(true)
2587 }
2588
2589 pub fn zklogin_max_epoch_upper_bound_delta(&self) -> Option<u64> {
2590 self.feature_flags.zklogin_max_epoch_upper_bound_delta
2591 }
2592
2593 pub fn enable_allowances(&self) -> bool {
2594 self.feature_flags.enable_allowances && self.enable_accumulators()
2595 }
2596
2597 pub fn enable_coin_reservation_obj_refs(&self) -> bool {
2598 self.new_vm_enabled() && self.feature_flags.enable_coin_reservation_obj_refs
2599 }
2600
2601 pub fn enable_authenticated_event_streams(&self) -> bool {
2602 self.feature_flags.enable_authenticated_event_streams && self.enable_accumulators()
2603 }
2604
2605 pub fn per_object_congestion_control_mode(&self) -> PerObjectCongestionControlMode {
2606 self.feature_flags.per_object_congestion_control_mode
2607 }
2608
2609 pub fn consensus_choice(&self) -> ConsensusChoice {
2610 self.feature_flags.consensus_choice
2611 }
2612
2613 pub fn consensus_network(&self) -> ConsensusNetwork {
2614 self.feature_flags.consensus_network
2615 }
2616
2617 pub fn mysticeti_num_leaders_per_round(&self) -> Option<usize> {
2618 self.feature_flags.mysticeti_num_leaders_per_round
2619 }
2620
2621 pub fn max_transaction_size_bytes(&self) -> u64 {
2622 self.consensus_max_transaction_size_bytes
2624 .unwrap_or(256 * 1024)
2625 }
2626
2627 pub fn max_transactions_in_block_bytes(&self) -> u64 {
2628 if cfg!(msim) {
2629 256 * 1024
2630 } else {
2631 self.consensus_max_transactions_in_block_bytes
2632 .unwrap_or(512 * 1024)
2633 }
2634 }
2635
2636 pub fn max_num_transactions_in_block(&self) -> u64 {
2637 if cfg!(msim) {
2638 8
2639 } else {
2640 self.consensus_max_num_transactions_in_block.unwrap_or(512)
2641 }
2642 }
2643
2644 pub fn gc_depth(&self) -> u32 {
2645 self.consensus_gc_depth.unwrap_or(0)
2646 }
2647
2648 pub fn consensus_linearize_subdag_v2(&self) -> bool {
2649 let res = self.feature_flags.consensus_linearize_subdag_v2;
2650 assert!(
2651 !res || self.gc_depth() > 0,
2652 "The consensus linearize sub dag V2 requires GC to be enabled"
2653 );
2654 res
2655 }
2656
2657 pub fn consensus_median_based_commit_timestamp(&self) -> bool {
2658 let res = self.feature_flags.consensus_median_based_commit_timestamp;
2659 assert!(
2660 !res || self.gc_depth() > 0,
2661 "The consensus median based commit timestamp requires GC to be enabled"
2662 );
2663 res
2664 }
2665
2666 pub fn get_consensus_commit_rate_estimation_window_size(&self) -> u32 {
2667 self.consensus_commit_rate_estimation_window_size
2668 .unwrap_or(0)
2669 }
2670
2671 pub fn consensus_num_requested_prior_commits_at_startup(&self) -> u32 {
2672 let window_size = self.get_consensus_commit_rate_estimation_window_size();
2676 assert!(window_size == 0 || self.record_additional_state_digest_in_prologue());
2678 window_size
2679 }
2680
2681 pub fn address_aliases(&self) -> bool {
2682 let address_aliases = self.feature_flags.address_aliases;
2683 assert!(
2684 !address_aliases || self.mysticeti_fastpath(),
2685 "Address aliases requires Mysticeti fastpath to be enabled"
2686 );
2687 if address_aliases {
2688 assert!(
2689 self.feature_flags.disable_preconsensus_locking,
2690 "Address aliases requires CertifiedTransaction to be disabled"
2691 );
2692 }
2693 address_aliases
2694 }
2695
2696 pub fn new_vm_enabled(&self) -> bool {
2697 self.execution_version.is_some_and(|v| v >= 4)
2698 }
2699
2700 pub fn gasless_allowed_token_types(&self) -> &[(String, u64)] {
2701 debug_assert!(self.gasless_allowed_token_types.is_some());
2702 self.gasless_allowed_token_types.as_deref().unwrap_or(&[])
2703 }
2704
2705 pub fn get_gasless_max_unused_inputs(&self) -> u64 {
2706 self.gasless_max_unused_inputs.unwrap_or(u64::MAX)
2707 }
2708
2709 pub fn get_gasless_max_pure_input_bytes(&self) -> u64 {
2710 self.gasless_max_pure_input_bytes.unwrap_or(u64::MAX)
2711 }
2712
2713 pub fn get_gasless_max_tx_size_bytes(&self) -> u64 {
2714 self.gasless_max_tx_size_bytes.unwrap_or(u64::MAX)
2715 }
2716
2717 pub fn include_special_package_amendments_as_option(&self) -> &Option<Arc<Amendments>> {
2718 &self.include_special_package_amendments
2719 }
2720}
2721
2722static POISON_VERSION_METHODS: AtomicBool = AtomicBool::new(false);
2723
2724impl ProtocolConfig {
2726 pub fn get_for_version(version: ProtocolVersion, chain: Chain) -> Self {
2728 assert!(
2730 version >= ProtocolVersion::MIN,
2731 "Network protocol version is {:?}, but the minimum supported version by the binary is {:?}. Please upgrade the binary.",
2732 version,
2733 ProtocolVersion::MIN.0,
2734 );
2735 assert!(
2736 version <= ProtocolVersion::MAX_ALLOWED,
2737 "Network protocol version is {:?}, but the maximum supported version by the binary is {:?}. Please upgrade the binary.",
2738 version,
2739 ProtocolVersion::MAX_ALLOWED.0,
2740 );
2741
2742 let mut ret = Self::get_for_version_impl(version, chain);
2743 ret.version = version;
2744 ret.chain = chain;
2745
2746 ret = Self::apply_config_override(version, ret);
2747
2748 if std::env::var("SUI_PROTOCOL_CONFIG_OVERRIDE_ENABLE").is_ok() {
2749 warn!(
2750 "overriding ProtocolConfig settings with custom settings; this may break non-local networks"
2751 );
2752 let overrides: ProtocolConfigOptional =
2753 serde_env::from_env_with_prefix("SUI_PROTOCOL_CONFIG_OVERRIDE")
2754 .expect("failed to parse ProtocolConfig override env variables");
2755 overrides.apply_to(&mut ret);
2756 }
2757
2758 ret
2759 }
2760
2761 pub fn get_for_version_if_supported(version: ProtocolVersion, chain: Chain) -> Option<Self> {
2764 if version.0 >= ProtocolVersion::MIN.0 && version.0 <= ProtocolVersion::MAX_ALLOWED.0 {
2765 let mut ret = Self::get_for_version_impl(version, chain);
2766 ret.version = version;
2767 ret.chain = chain;
2768 ret = Self::apply_config_override(version, ret);
2769 Some(ret)
2770 } else {
2771 None
2772 }
2773 }
2774
2775 pub fn poison_get_for_min_version() {
2776 POISON_VERSION_METHODS.store(true, Ordering::Relaxed);
2777 }
2778
2779 fn load_poison_get_for_min_version() -> bool {
2780 POISON_VERSION_METHODS.load(Ordering::Relaxed)
2781 }
2782
2783 pub fn get_for_min_version() -> Self {
2786 if Self::load_poison_get_for_min_version() {
2787 panic!("get_for_min_version called on validator");
2788 }
2789 ProtocolConfig::get_for_version(ProtocolVersion::MIN, Chain::Unknown)
2790 }
2791
2792 #[allow(non_snake_case)]
2802 pub fn get_for_max_version_UNSAFE() -> Self {
2803 if Self::load_poison_get_for_min_version() {
2804 panic!("get_for_max_version_UNSAFE called on validator");
2805 }
2806 ProtocolConfig::get_for_version(ProtocolVersion::MAX, Chain::Unknown)
2807 }
2808
2809 fn get_for_version_impl(version: ProtocolVersion, chain: Chain) -> Self {
2810 #[cfg(msim)]
2811 {
2812 if version == ProtocolVersion::MAX_ALLOWED {
2814 let mut config = Self::get_for_version_impl(version - 1, Chain::Unknown);
2815 config.base_tx_cost_fixed = Some(config.base_tx_cost_fixed() + 1000);
2816 return config;
2817 }
2818 }
2819
2820 let mut cfg = Self {
2823 version,
2825 chain,
2826
2827 feature_flags: Default::default(),
2829
2830 max_tx_size_bytes: Some(128 * 1024),
2831 max_input_objects: Some(2048),
2833 max_serialized_tx_effects_size_bytes: Some(512 * 1024),
2834 max_serialized_tx_effects_size_bytes_system_tx: Some(512 * 1024 * 16),
2835 max_gas_payment_objects: Some(256),
2836 max_modules_in_publish: Some(128),
2837 max_package_dependencies: None,
2838 max_arguments: Some(512),
2839 max_type_arguments: Some(16),
2840 max_type_argument_depth: Some(16),
2841 max_pure_argument_size: Some(16 * 1024),
2842 max_programmable_tx_commands: Some(1024),
2843 move_binary_format_version: Some(6),
2844 min_move_binary_format_version: None,
2845 binary_module_handles: None,
2846 binary_struct_handles: None,
2847 binary_function_handles: None,
2848 binary_function_instantiations: None,
2849 binary_signatures: None,
2850 binary_constant_pool: None,
2851 binary_identifiers: None,
2852 binary_address_identifiers: None,
2853 binary_struct_defs: None,
2854 binary_struct_def_instantiations: None,
2855 binary_function_defs: None,
2856 binary_field_handles: None,
2857 binary_field_instantiations: None,
2858 binary_friend_decls: None,
2859 binary_enum_defs: None,
2860 binary_enum_def_instantiations: None,
2861 binary_variant_handles: None,
2862 binary_variant_instantiation_handles: None,
2863 binary_format_limits_profile: None,
2864 max_move_object_size: Some(250 * 1024),
2865 max_move_package_size: Some(100 * 1024),
2866 max_publish_or_upgrade_per_ptb: None,
2867 max_tx_gas: Some(10_000_000_000),
2868 max_gas_price: Some(100_000),
2869 max_gas_price_rgp_factor_for_aborted_transactions: None,
2870 max_gas_computation_bucket: Some(5_000_000),
2871 max_loop_depth: Some(5),
2872 max_generic_instantiation_length: Some(32),
2873 max_function_parameters: Some(128),
2874 max_basic_blocks: Some(1024),
2875 max_value_stack_size: Some(1024),
2876 max_type_nodes: Some(256),
2877 max_generic_instantiation_type_nodes_per_function: None,
2878 max_generic_instantiation_type_nodes_per_module: None,
2879 max_accumulator_type_nodes: None,
2880 max_push_size: Some(10000),
2881 max_struct_definitions: Some(200),
2882 max_function_definitions: Some(1000),
2883 max_fields_in_struct: Some(32),
2884 max_dependency_depth: Some(100),
2885 max_num_event_emit: Some(256),
2886 max_num_accumulator_events: None,
2887 max_num_new_move_object_ids: Some(2048),
2888 max_num_new_move_object_ids_system_tx: Some(2048 * 16),
2889 max_num_deleted_move_object_ids: Some(2048),
2890 max_num_deleted_move_object_ids_system_tx: Some(2048 * 16),
2891 max_num_transferred_move_object_ids: Some(2048),
2892 max_num_transferred_move_object_ids_system_tx: Some(2048 * 16),
2893 max_event_emit_size: Some(250 * 1024),
2894 max_move_vector_len: Some(256 * 1024),
2895 max_type_to_layout_nodes: None,
2896 max_ptb_value_size: None,
2897
2898 max_back_edges_per_function: Some(10_000),
2899 max_back_edges_per_module: Some(10_000),
2900 max_verifier_meter_ticks_per_function: Some(6_000_000),
2901 max_meter_ticks_per_module: Some(6_000_000),
2902 max_meter_ticks_per_package: None,
2903
2904 object_runtime_max_num_cached_objects: Some(1000),
2905 object_runtime_max_num_cached_objects_system_tx: Some(1000 * 16),
2906 object_runtime_max_loaded_child_value_size: None,
2907 object_runtime_max_num_store_entries: Some(1000),
2908 object_runtime_max_num_store_entries_system_tx: Some(1000 * 16),
2909 base_tx_cost_fixed: Some(110_000),
2910 package_publish_cost_fixed: Some(1_000),
2911 base_tx_cost_per_byte: Some(0),
2912 package_publish_cost_per_byte: Some(80),
2913 package_publish_charge_fixed: None,
2914 package_publish_charge_per_module: None,
2915 package_publish_charge_per_dependency: None,
2916 obj_access_cost_read_per_byte: Some(15),
2917 obj_access_cost_read_per_package_kb: None,
2918 obj_access_cost_mutate_per_byte: Some(40),
2919 obj_access_cost_delete_per_byte: Some(40),
2920 obj_access_cost_verify_per_byte: Some(200),
2921 obj_data_cost_refundable: Some(100),
2922 obj_metadata_cost_non_refundable: Some(50),
2923 gas_model_version: Some(1),
2924 storage_rebate_rate: Some(9900),
2925 storage_fund_reinvest_rate: Some(500),
2926 reward_slashing_rate: Some(5000),
2927 storage_gas_price: Some(1),
2928 accumulator_object_storage_cost: None,
2929 max_transactions_per_checkpoint: Some(10_000),
2930 max_checkpoint_size_bytes: Some(30 * 1024 * 1024),
2931
2932 buffer_stake_for_protocol_upgrade_bps: Some(0),
2935
2936 address_from_bytes_cost_base: Some(52),
2940 address_to_u256_cost_base: Some(52),
2942 address_from_u256_cost_base: Some(52),
2944
2945 config_read_setting_impl_cost_base: None,
2948 config_read_setting_impl_cost_per_byte: None,
2949
2950 package_original_package_id_impl_cost_base: None,
2951 package_original_package_id_impl_cost_per_byte: None,
2952
2953 dynamic_field_hash_type_and_key_cost_base: Some(100),
2956 dynamic_field_hash_type_and_key_type_cost_per_byte: Some(2),
2957 dynamic_field_hash_type_and_key_value_cost_per_byte: Some(2),
2958 dynamic_field_hash_type_and_key_type_tag_cost_per_byte: Some(2),
2959 dynamic_field_add_child_object_cost_base: Some(100),
2961 dynamic_field_add_child_object_type_cost_per_byte: Some(10),
2962 dynamic_field_add_child_object_value_cost_per_byte: Some(10),
2963 dynamic_field_add_child_object_struct_tag_cost_per_byte: Some(10),
2964 dynamic_field_borrow_child_object_cost_base: Some(100),
2966 dynamic_field_borrow_child_object_child_ref_cost_per_byte: Some(10),
2967 dynamic_field_borrow_child_object_type_cost_per_byte: Some(10),
2968 dynamic_field_remove_child_object_cost_base: Some(100),
2970 dynamic_field_remove_child_object_child_cost_per_byte: Some(2),
2971 dynamic_field_remove_child_object_type_cost_per_byte: Some(2),
2972 dynamic_field_has_child_object_cost_base: Some(100),
2974 dynamic_field_has_child_object_with_ty_cost_base: Some(100),
2976 dynamic_field_has_child_object_with_ty_type_cost_per_byte: Some(2),
2977 dynamic_field_has_child_object_with_ty_type_tag_cost_per_byte: Some(2),
2978
2979 scratch_add_cost_base: None,
2981 scratch_read_cost_base: None,
2982 scratch_read_value_cost: None,
2983 scratch_remove_cost_base: None,
2984 scratch_exists_cost_base: None,
2985 scratch_exists_with_type_cost_base: None,
2986 scratch_exists_with_type_type_cost: None,
2987 max_scratch_pad_size: None,
2988
2989 event_emit_cost_base: Some(52),
2992 event_emit_value_size_derivation_cost_per_byte: Some(2),
2993 event_emit_tag_size_derivation_cost_per_byte: Some(5),
2994 event_emit_output_cost_per_byte: Some(10),
2995 event_emit_auth_stream_cost: None,
2996
2997 reserve_object_funds_for_withdrawal_cost_base: None,
2999 reserve_object_funds_for_withdrawal_cold_read_cost: None,
3000
3001 object_borrow_uid_cost_base: Some(52),
3004 object_delete_impl_cost_base: Some(52),
3006 object_record_new_uid_cost_base: Some(52),
3008 object_record_new_uid_from_hash_cost_base: None,
3011 object_is_shared_input_cost_base: None,
3014
3015 transfer_transfer_internal_cost_base: Some(52),
3018 transfer_party_transfer_internal_cost_base: None,
3020 transfer_freeze_object_cost_base: Some(52),
3022 transfer_share_object_cost_base: Some(52),
3024 transfer_receive_object_cost_base: None,
3025 transfer_receive_object_type_cost_per_byte: None,
3026 transfer_receive_object_cost_per_byte: None,
3027
3028 tx_context_derive_id_cost_base: Some(52),
3031 tx_context_fresh_id_cost_base: None,
3032 tx_context_sender_cost_base: None,
3033 tx_context_epoch_cost_base: None,
3034 tx_context_epoch_timestamp_ms_cost_base: None,
3035 tx_context_sponsor_cost_base: None,
3036 tx_context_rgp_cost_base: None,
3037 tx_context_gas_price_cost_base: None,
3038 tx_context_gas_budget_cost_base: None,
3039 tx_context_ids_created_cost_base: None,
3040 tx_context_replace_cost_base: None,
3041
3042 clock_borrow_cost_base: None,
3044
3045 types_is_one_time_witness_cost_base: Some(52),
3048 types_is_one_time_witness_type_tag_cost_per_byte: Some(2),
3049 types_is_one_time_witness_type_cost_per_byte: Some(2),
3050
3051 validator_validate_metadata_cost_base: Some(52),
3054 validator_validate_metadata_data_cost_per_byte: Some(2),
3055
3056 crypto_invalid_arguments_cost: Some(100),
3058 bls12381_bls12381_min_sig_verify_cost_base: Some(52),
3060 bls12381_bls12381_min_sig_verify_msg_cost_per_byte: Some(2),
3061 bls12381_bls12381_min_sig_verify_msg_cost_per_block: Some(2),
3062
3063 bls12381_bls12381_min_pk_verify_cost_base: Some(52),
3065 bls12381_bls12381_min_pk_verify_msg_cost_per_byte: Some(2),
3066 bls12381_bls12381_min_pk_verify_msg_cost_per_block: Some(2),
3067
3068 ecdsa_k1_ecrecover_keccak256_cost_base: Some(52),
3070 ecdsa_k1_ecrecover_keccak256_msg_cost_per_byte: Some(2),
3071 ecdsa_k1_ecrecover_keccak256_msg_cost_per_block: Some(2),
3072 ecdsa_k1_ecrecover_sha256_cost_base: Some(52),
3073 ecdsa_k1_ecrecover_sha256_msg_cost_per_byte: Some(2),
3074 ecdsa_k1_ecrecover_sha256_msg_cost_per_block: Some(2),
3075
3076 ecdsa_k1_decompress_pubkey_cost_base: Some(52),
3078
3079 ecdsa_k1_secp256k1_verify_keccak256_cost_base: Some(52),
3081 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_byte: Some(2),
3082 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_block: Some(2),
3083 ecdsa_k1_secp256k1_verify_sha256_cost_base: Some(52),
3084 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_byte: Some(2),
3085 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_block: Some(2),
3086
3087 ecdsa_r1_ecrecover_keccak256_cost_base: Some(52),
3089 ecdsa_r1_ecrecover_keccak256_msg_cost_per_byte: Some(2),
3090 ecdsa_r1_ecrecover_keccak256_msg_cost_per_block: Some(2),
3091 ecdsa_r1_ecrecover_sha256_cost_base: Some(52),
3092 ecdsa_r1_ecrecover_sha256_msg_cost_per_byte: Some(2),
3093 ecdsa_r1_ecrecover_sha256_msg_cost_per_block: Some(2),
3094
3095 ecdsa_r1_secp256r1_verify_keccak256_cost_base: Some(52),
3097 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_byte: Some(2),
3098 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_block: Some(2),
3099 ecdsa_r1_secp256r1_verify_sha256_cost_base: Some(52),
3100 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_byte: Some(2),
3101 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_block: Some(2),
3102
3103 ecvrf_ecvrf_verify_cost_base: Some(52),
3105 ecvrf_ecvrf_verify_alpha_string_cost_per_byte: Some(2),
3106 ecvrf_ecvrf_verify_alpha_string_cost_per_block: Some(2),
3107
3108 ed25519_ed25519_verify_cost_base: Some(52),
3110 ed25519_ed25519_verify_msg_cost_per_byte: Some(2),
3111 ed25519_ed25519_verify_msg_cost_per_block: Some(2),
3112
3113 groth16_prepare_verifying_key_bls12381_cost_base: Some(52),
3115 groth16_prepare_verifying_key_bn254_cost_base: Some(52),
3116
3117 groth16_verify_groth16_proof_internal_bls12381_cost_base: Some(52),
3119 groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input: Some(2),
3120 groth16_verify_groth16_proof_internal_bn254_cost_base: Some(52),
3121 groth16_verify_groth16_proof_internal_bn254_cost_per_public_input: Some(2),
3122 groth16_verify_groth16_proof_internal_public_input_cost_per_byte: Some(2),
3123
3124 hash_blake2b256_cost_base: Some(52),
3126 hash_blake2b256_data_cost_per_byte: Some(2),
3127 hash_blake2b256_data_cost_per_block: Some(2),
3128
3129 hash_keccak256_cost_base: Some(52),
3131 hash_keccak256_data_cost_per_byte: Some(2),
3132 hash_keccak256_data_cost_per_block: Some(2),
3133
3134 poseidon_bn254_cost_base: None,
3135 poseidon_bn254_cost_per_block: None,
3136
3137 hmac_hmac_sha3_256_cost_base: Some(52),
3139 hmac_hmac_sha3_256_input_cost_per_byte: Some(2),
3140 hmac_hmac_sha3_256_input_cost_per_block: Some(2),
3141
3142 group_ops_bls12381_decode_scalar_cost: None,
3144 group_ops_bls12381_decode_g1_cost: None,
3145 group_ops_bls12381_decode_g2_cost: None,
3146 group_ops_bls12381_decode_gt_cost: None,
3147 group_ops_bls12381_scalar_add_cost: None,
3148 group_ops_bls12381_g1_add_cost: None,
3149 group_ops_bls12381_g2_add_cost: None,
3150 group_ops_bls12381_gt_add_cost: None,
3151 group_ops_bls12381_scalar_sub_cost: None,
3152 group_ops_bls12381_g1_sub_cost: None,
3153 group_ops_bls12381_g2_sub_cost: None,
3154 group_ops_bls12381_gt_sub_cost: None,
3155 group_ops_bls12381_scalar_mul_cost: None,
3156 group_ops_bls12381_g1_mul_cost: None,
3157 group_ops_bls12381_g2_mul_cost: None,
3158 group_ops_bls12381_gt_mul_cost: None,
3159 group_ops_bls12381_scalar_div_cost: None,
3160 group_ops_bls12381_g1_div_cost: None,
3161 group_ops_bls12381_g2_div_cost: None,
3162 group_ops_bls12381_gt_div_cost: None,
3163 group_ops_bls12381_g1_hash_to_base_cost: None,
3164 group_ops_bls12381_g2_hash_to_base_cost: None,
3165 group_ops_bls12381_g1_hash_to_cost_per_byte: None,
3166 group_ops_bls12381_g2_hash_to_cost_per_byte: None,
3167 group_ops_bls12381_g1_msm_base_cost: None,
3168 group_ops_bls12381_g2_msm_base_cost: None,
3169 group_ops_bls12381_g1_msm_base_cost_per_input: None,
3170 group_ops_bls12381_g2_msm_base_cost_per_input: None,
3171 group_ops_bls12381_msm_max_len: None,
3172 group_ops_bls12381_pairing_cost: None,
3173 group_ops_bls12381_g1_to_uncompressed_g1_cost: None,
3174 group_ops_bls12381_uncompressed_g1_to_g1_cost: None,
3175 group_ops_bls12381_uncompressed_g1_sum_base_cost: None,
3176 group_ops_bls12381_uncompressed_g1_sum_cost_per_term: None,
3177 group_ops_bls12381_uncompressed_g1_sum_max_terms: None,
3178
3179 group_ops_ristretto_decode_scalar_cost: None,
3180 group_ops_ristretto_decode_point_cost: None,
3181 group_ops_ristretto_scalar_add_cost: None,
3182 group_ops_ristretto_point_add_cost: None,
3183 group_ops_ristretto_scalar_sub_cost: None,
3184 group_ops_ristretto_point_sub_cost: None,
3185 group_ops_ristretto_scalar_mul_cost: None,
3186 group_ops_ristretto_point_mul_cost: None,
3187 group_ops_ristretto_scalar_div_cost: None,
3188 group_ops_ristretto_point_div_cost: None,
3189
3190 verify_bulletproofs_ristretto255_base_cost: None,
3191 verify_bulletproofs_ristretto255_cost_per_bit_and_commitment: None,
3192 max_bulletproofs_total_bits: None,
3193
3194 check_zklogin_id_cost_base: None,
3196 check_zklogin_issuer_cost_base: None,
3198
3199 vdf_verify_vdf_cost: None,
3200 vdf_hash_to_input_cost: None,
3201
3202 nitro_attestation_parse_base_cost: None,
3204 nitro_attestation_parse_cost_per_byte: None,
3205 nitro_attestation_verify_base_cost: None,
3206 nitro_attestation_verify_cost_per_cert: None,
3207
3208 layout_node_cost: None,
3209 layout_node_cost_large_layout_threshold: None,
3210 bcs_per_input_abstract_unit_cost: None,
3211 bcs_per_byte_serialized_cost: None,
3212 bcs_legacy_min_output_size_cost: None,
3213 bcs_failure_cost: None,
3214 hash_sha2_256_base_cost: None,
3215 hash_sha2_256_per_byte_cost: None,
3216 hash_sha2_256_legacy_min_input_len_cost: None,
3217 hash_sha3_256_base_cost: None,
3218 hash_sha3_256_per_byte_cost: None,
3219 hash_sha3_256_legacy_min_input_len_cost: None,
3220 type_name_get_base_cost: None,
3221 type_name_get_per_byte_cost: None,
3222 type_name_id_base_cost: None,
3223 string_check_utf8_base_cost: None,
3224 string_check_utf8_per_byte_cost: None,
3225 string_is_char_boundary_base_cost: None,
3226 string_sub_string_base_cost: None,
3227 string_sub_string_per_byte_cost: None,
3228 string_index_of_base_cost: None,
3229 string_index_of_per_byte_pattern_cost: None,
3230 string_index_of_per_byte_searched_cost: None,
3231 vector_empty_base_cost: None,
3232 vector_length_base_cost: None,
3233 vector_push_back_base_cost: None,
3234 vector_push_back_legacy_per_abstract_memory_unit_cost: None,
3235 vector_borrow_base_cost: None,
3236 vector_pop_back_base_cost: None,
3237 vector_destroy_empty_base_cost: None,
3238 vector_swap_base_cost: None,
3239 vector_reverse_base_cost: None,
3240 vector_reverse_per_elem_cost: None,
3241 vector_keep_range_base_cost: None,
3242 vector_keep_range_per_dropped_elem_cost: None,
3243 vector_keep_range_per_moved_elem_cost: None,
3244 vector_copy_range_base_cost: None,
3245 vector_copy_range_per_abstract_memory_unit_cost: None,
3246 vector_replace_range_base_cost: None,
3247 vector_replace_range_per_elem_cost: None,
3248 debug_print_base_cost: None,
3249 debug_print_stack_trace_base_cost: None,
3250
3251 max_size_written_objects: None,
3252 max_size_written_objects_system_tx: None,
3253
3254 max_move_identifier_len: None,
3261 max_move_value_depth: None,
3262 package_arena_size_in_bytes: None,
3263 max_move_enum_variants: None,
3264
3265 gas_rounding_step: None,
3266
3267 execution_version: None,
3268
3269 max_event_emit_size_total: None,
3270
3271 consensus_bad_nodes_stake_threshold: None,
3272
3273 max_jwk_votes_per_validator_per_epoch: None,
3274
3275 max_age_of_jwk_in_epochs: None,
3276
3277 random_beacon_reduction_allowed_delta: None,
3278
3279 random_beacon_reduction_lower_bound: None,
3280
3281 random_beacon_dkg_timeout_round: None,
3282
3283 random_beacon_min_round_interval_ms: None,
3284
3285 random_beacon_dkg_version: None,
3286
3287 consensus_max_transaction_size_bytes: None,
3288
3289 consensus_max_transactions_in_block_bytes: None,
3290
3291 consensus_max_num_transactions_in_block: None,
3292
3293 consensus_voting_rounds: None,
3294
3295 max_accumulated_txn_cost_per_object_in_narwhal_commit: None,
3296
3297 max_deferral_rounds_for_congestion_control: None,
3298
3299 epoch_close_deadline_ms: None,
3300
3301 max_txn_cost_overage_per_object_in_commit: None,
3302
3303 allowed_txn_cost_overage_burst_per_object_in_commit: None,
3304
3305 min_checkpoint_interval_ms: None,
3306
3307 checkpoint_summary_version_specific_data: None,
3308
3309 max_soft_bundle_size: None,
3310
3311 bridge_should_try_to_finalize_committee: None,
3312
3313 max_accumulated_txn_cost_per_object_in_mysticeti_commit: None,
3314
3315 max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit: None,
3316
3317 consensus_gc_depth: None,
3318
3319 gas_budget_based_txn_cost_cap_factor: None,
3320
3321 gas_budget_based_txn_cost_absolute_cap_commit_count: None,
3322
3323 sip_45_consensus_amplification_threshold: None,
3324 staggered_submission_signal_window_commits: None,
3325 staggered_submission_signal_min_excess_copies_per_commit: None,
3326 staggered_submission_signal_min_consensus_user_transactions_per_commit: None,
3327 staggered_submission_signal_exit_dwell_commits: None,
3328 staggered_submission_signal_band1_enter_ratio_bps: None,
3329 staggered_submission_signal_band1_exit_ratio_bps: None,
3330 staggered_submission_signal_band2_enter_ratio_bps: None,
3331 staggered_submission_signal_band2_exit_ratio_bps: None,
3332
3333 use_object_per_epoch_marker_table_v2: None,
3334
3335 consensus_commit_rate_estimation_window_size: None,
3336
3337 aliased_addresses: vec![],
3338
3339 translation_per_command_base_charge: None,
3340 translation_per_input_base_charge: None,
3341 translation_pure_input_per_byte_charge: None,
3342 translation_per_type_node_charge: None,
3343 translation_per_reference_node_charge: None,
3344 translation_per_linkage_entry_charge: None,
3345 translation_per_live_reference_charge: None,
3346 max_ptb_live_references: None,
3347 max_ptb_returned_references: None,
3348 max_ptb_total_returned_references: None,
3349
3350 max_updates_per_settlement_txn: None,
3351
3352 gasless_max_computation_units: None,
3353 gasless_allowed_token_types: None,
3354 gasless_max_unused_inputs: None,
3355 gasless_max_pure_input_bytes: None,
3356 gasless_max_tps: None,
3357 include_special_package_amendments: None,
3358 gasless_max_tx_size_bytes: None,
3359 };
3362 for cur in 2..=version.0 {
3363 match cur {
3364 1 => unreachable!(),
3365 2 => {
3366 cfg.feature_flags.advance_epoch_start_time_in_safe_mode = true;
3367 }
3368 3 => {
3369 cfg.gas_model_version = Some(2);
3371 cfg.max_tx_gas = Some(50_000_000_000);
3373 cfg.base_tx_cost_fixed = Some(2_000);
3375 cfg.storage_gas_price = Some(76);
3377 cfg.feature_flags.loaded_child_objects_fixed = true;
3378 cfg.max_size_written_objects = Some(5 * 1000 * 1000);
3381 cfg.max_size_written_objects_system_tx = Some(50 * 1000 * 1000);
3384 cfg.feature_flags.package_upgrades = true;
3385 }
3386 4 => {
3391 cfg.reward_slashing_rate = Some(10000);
3393 cfg.gas_model_version = Some(3);
3395 }
3396 5 => {
3397 cfg.feature_flags.missing_type_is_compatibility_error = true;
3398 cfg.gas_model_version = Some(4);
3399 cfg.feature_flags.scoring_decision_with_validity_cutoff = true;
3400 }
3404 6 => {
3405 cfg.gas_model_version = Some(5);
3406 cfg.buffer_stake_for_protocol_upgrade_bps = Some(5000);
3407 cfg.feature_flags.consensus_order_end_of_epoch_last = true;
3408 }
3409 7 => {
3410 cfg.feature_flags.disallow_adding_abilities_on_upgrade = true;
3411 cfg.feature_flags
3412 .disable_invariant_violation_check_in_swap_loc = true;
3413 cfg.feature_flags.ban_entry_init = true;
3414 cfg.feature_flags.package_digest_hash_module = true;
3415 }
3416 8 => {
3417 cfg.feature_flags
3418 .disallow_change_struct_type_params_on_upgrade = true;
3419 }
3420 9 => {
3421 cfg.max_move_identifier_len = Some(128);
3423 cfg.feature_flags.no_extraneous_module_bytes = true;
3424 cfg.feature_flags
3425 .advance_to_highest_supported_protocol_version = true;
3426 }
3427 10 => {
3428 cfg.max_verifier_meter_ticks_per_function = Some(16_000_000);
3429 cfg.max_meter_ticks_per_module = Some(16_000_000);
3430 }
3431 11 => {
3432 cfg.max_move_value_depth = Some(128);
3433 }
3434 12 => {
3435 cfg.feature_flags.narwhal_versioned_metadata = true;
3436 if chain != Chain::Mainnet {
3437 cfg.feature_flags.commit_root_state_digest = true;
3438 }
3439
3440 if chain != Chain::Mainnet && chain != Chain::Testnet {
3441 cfg.feature_flags.zklogin_auth = true;
3442 }
3443 }
3444 13 => {}
3445 14 => {
3446 cfg.gas_rounding_step = Some(1_000);
3447 cfg.gas_model_version = Some(6);
3448 }
3449 15 => {
3450 cfg.feature_flags.consensus_transaction_ordering =
3451 ConsensusTransactionOrdering::ByGasPrice;
3452 }
3453 16 => {
3454 cfg.feature_flags.simplified_unwrap_then_delete = true;
3455 }
3456 17 => {
3457 cfg.feature_flags.upgraded_multisig_supported = true;
3458 }
3459 18 => {
3460 cfg.execution_version = Some(1);
3461 cfg.feature_flags.txn_base_cost_as_multiplier = true;
3470 cfg.base_tx_cost_fixed = Some(1_000);
3472 }
3473 19 => {
3474 cfg.max_num_event_emit = Some(1024);
3475 cfg.max_event_emit_size_total = Some(
3478 256 * 250 * 1024, );
3480 }
3481 20 => {
3482 cfg.feature_flags.commit_root_state_digest = true;
3483
3484 if chain != Chain::Mainnet {
3485 cfg.feature_flags.narwhal_new_leader_election_schedule = true;
3486 cfg.consensus_bad_nodes_stake_threshold = Some(20);
3487 }
3488 }
3489
3490 21 => {
3491 if chain != Chain::Mainnet {
3492 cfg.feature_flags.zklogin_supported_providers = BTreeSet::from([
3493 "Google".to_string(),
3494 "Facebook".to_string(),
3495 "Twitch".to_string(),
3496 ]);
3497 }
3498 }
3499 22 => {
3500 cfg.feature_flags.loaded_child_object_format = true;
3501 }
3502 23 => {
3503 cfg.feature_flags.loaded_child_object_format_type = true;
3504 cfg.feature_flags.narwhal_new_leader_election_schedule = true;
3505 cfg.consensus_bad_nodes_stake_threshold = Some(20);
3511 }
3512 24 => {
3513 cfg.feature_flags.simple_conservation_checks = true;
3514 cfg.max_publish_or_upgrade_per_ptb = Some(5);
3515
3516 cfg.feature_flags.end_of_epoch_transaction_supported = true;
3517
3518 if chain != Chain::Mainnet {
3519 cfg.feature_flags.enable_jwk_consensus_updates = true;
3520 cfg.max_jwk_votes_per_validator_per_epoch = Some(240);
3522 cfg.max_age_of_jwk_in_epochs = Some(1);
3523 }
3524 }
3525 25 => {
3526 cfg.feature_flags.zklogin_supported_providers = BTreeSet::from([
3528 "Google".to_string(),
3529 "Facebook".to_string(),
3530 "Twitch".to_string(),
3531 ]);
3532 cfg.feature_flags.zklogin_auth = true;
3533
3534 cfg.feature_flags.enable_jwk_consensus_updates = true;
3536 cfg.max_jwk_votes_per_validator_per_epoch = Some(240);
3537 cfg.max_age_of_jwk_in_epochs = Some(1);
3538 }
3539 26 => {
3540 cfg.gas_model_version = Some(7);
3541 if chain != Chain::Mainnet && chain != Chain::Testnet {
3543 cfg.transfer_receive_object_cost_base = Some(52);
3544 cfg.feature_flags.receive_objects = true;
3545 }
3546 }
3547 27 => {
3548 cfg.gas_model_version = Some(8);
3549 }
3550 28 => {
3551 cfg.check_zklogin_id_cost_base = Some(200);
3553 cfg.check_zklogin_issuer_cost_base = Some(200);
3555
3556 if chain != Chain::Mainnet && chain != Chain::Testnet {
3558 cfg.feature_flags.enable_effects_v2 = true;
3559 }
3560 }
3561 29 => {
3562 cfg.feature_flags.verify_legacy_zklogin_address = true;
3563 }
3564 30 => {
3565 if chain != Chain::Mainnet {
3567 cfg.feature_flags.narwhal_certificate_v2 = true;
3568 }
3569
3570 cfg.random_beacon_reduction_allowed_delta = Some(800);
3571 if chain != Chain::Mainnet {
3573 cfg.feature_flags.enable_effects_v2 = true;
3574 }
3575
3576 cfg.feature_flags.zklogin_supported_providers = BTreeSet::default();
3580
3581 cfg.feature_flags.recompute_has_public_transfer_in_execution = true;
3582 }
3583 31 => {
3584 cfg.execution_version = Some(2);
3585 if chain != Chain::Mainnet && chain != Chain::Testnet {
3587 cfg.feature_flags.shared_object_deletion = true;
3588 }
3589 }
3590 32 => {
3591 if chain != Chain::Mainnet {
3593 cfg.feature_flags.accept_zklogin_in_multisig = true;
3594 }
3595 if chain != Chain::Mainnet {
3597 cfg.transfer_receive_object_cost_base = Some(52);
3598 cfg.feature_flags.receive_objects = true;
3599 }
3600 if chain != Chain::Mainnet && chain != Chain::Testnet {
3602 cfg.feature_flags.random_beacon = true;
3603 cfg.random_beacon_reduction_lower_bound = Some(1600);
3604 cfg.random_beacon_dkg_timeout_round = Some(3000);
3605 cfg.random_beacon_min_round_interval_ms = Some(150);
3606 }
3607 if chain != Chain::Testnet && chain != Chain::Mainnet {
3609 cfg.feature_flags.include_consensus_digest_in_prologue = true;
3610 }
3611
3612 cfg.feature_flags.narwhal_certificate_v2 = true;
3614 }
3615 33 => {
3616 cfg.feature_flags.hardened_otw_check = true;
3617 cfg.feature_flags.allow_receiving_object_id = true;
3618
3619 cfg.transfer_receive_object_cost_base = Some(52);
3621 cfg.feature_flags.receive_objects = true;
3622
3623 if chain != Chain::Mainnet {
3625 cfg.feature_flags.shared_object_deletion = true;
3626 }
3627
3628 cfg.feature_flags.enable_effects_v2 = true;
3629 }
3630 34 => {}
3631 35 => {
3632 if chain != Chain::Mainnet && chain != Chain::Testnet {
3634 cfg.feature_flags.enable_poseidon = true;
3635 cfg.poseidon_bn254_cost_base = Some(260);
3636 cfg.poseidon_bn254_cost_per_block = Some(10);
3637 }
3638
3639 cfg.feature_flags.enable_coin_deny_list = true;
3640 }
3641 36 => {
3642 if chain != Chain::Mainnet && chain != Chain::Testnet {
3644 cfg.feature_flags.enable_group_ops_native_functions = true;
3645 cfg.feature_flags.enable_group_ops_native_function_msm = true;
3646 cfg.group_ops_bls12381_decode_scalar_cost = Some(52);
3648 cfg.group_ops_bls12381_decode_g1_cost = Some(52);
3649 cfg.group_ops_bls12381_decode_g2_cost = Some(52);
3650 cfg.group_ops_bls12381_decode_gt_cost = Some(52);
3651 cfg.group_ops_bls12381_scalar_add_cost = Some(52);
3652 cfg.group_ops_bls12381_g1_add_cost = Some(52);
3653 cfg.group_ops_bls12381_g2_add_cost = Some(52);
3654 cfg.group_ops_bls12381_gt_add_cost = Some(52);
3655 cfg.group_ops_bls12381_scalar_sub_cost = Some(52);
3656 cfg.group_ops_bls12381_g1_sub_cost = Some(52);
3657 cfg.group_ops_bls12381_g2_sub_cost = Some(52);
3658 cfg.group_ops_bls12381_gt_sub_cost = Some(52);
3659 cfg.group_ops_bls12381_scalar_mul_cost = Some(52);
3660 cfg.group_ops_bls12381_g1_mul_cost = Some(52);
3661 cfg.group_ops_bls12381_g2_mul_cost = Some(52);
3662 cfg.group_ops_bls12381_gt_mul_cost = Some(52);
3663 cfg.group_ops_bls12381_scalar_div_cost = Some(52);
3664 cfg.group_ops_bls12381_g1_div_cost = Some(52);
3665 cfg.group_ops_bls12381_g2_div_cost = Some(52);
3666 cfg.group_ops_bls12381_gt_div_cost = Some(52);
3667 cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(52);
3668 cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(52);
3669 cfg.group_ops_bls12381_g1_hash_to_cost_per_byte = Some(2);
3670 cfg.group_ops_bls12381_g2_hash_to_cost_per_byte = Some(2);
3671 cfg.group_ops_bls12381_g1_msm_base_cost = Some(52);
3672 cfg.group_ops_bls12381_g2_msm_base_cost = Some(52);
3673 cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(52);
3674 cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(52);
3675 cfg.group_ops_bls12381_msm_max_len = Some(32);
3676 cfg.group_ops_bls12381_pairing_cost = Some(52);
3677 }
3678 cfg.feature_flags.shared_object_deletion = true;
3680
3681 cfg.consensus_max_transaction_size_bytes = Some(256 * 1024); cfg.consensus_max_transactions_in_block_bytes = Some(6 * 1_024 * 1024);
3683 }
3685 37 => {
3686 cfg.feature_flags.reject_mutable_random_on_entry_functions = true;
3687
3688 if chain != Chain::Mainnet {
3690 cfg.feature_flags.include_consensus_digest_in_prologue = true;
3691 }
3692 }
3693 38 => {
3694 cfg.binary_module_handles = Some(100);
3695 cfg.binary_struct_handles = Some(300);
3696 cfg.binary_function_handles = Some(1500);
3697 cfg.binary_function_instantiations = Some(750);
3698 cfg.binary_signatures = Some(1000);
3699 cfg.binary_constant_pool = Some(4000);
3703 cfg.binary_identifiers = Some(10000);
3704 cfg.binary_address_identifiers = Some(100);
3705 cfg.binary_struct_defs = Some(200);
3706 cfg.binary_struct_def_instantiations = Some(100);
3707 cfg.binary_function_defs = Some(1000);
3708 cfg.binary_field_handles = Some(500);
3709 cfg.binary_field_instantiations = Some(250);
3710 cfg.binary_friend_decls = Some(100);
3711 cfg.max_package_dependencies = Some(32);
3713 cfg.max_modules_in_publish = Some(64);
3714 cfg.execution_version = Some(3);
3716 }
3717 39 => {
3718 }
3720 40 => {}
3721 41 => {
3722 cfg.feature_flags.enable_group_ops_native_functions = true;
3724 cfg.group_ops_bls12381_decode_scalar_cost = Some(52);
3726 cfg.group_ops_bls12381_decode_g1_cost = Some(52);
3727 cfg.group_ops_bls12381_decode_g2_cost = Some(52);
3728 cfg.group_ops_bls12381_decode_gt_cost = Some(52);
3729 cfg.group_ops_bls12381_scalar_add_cost = Some(52);
3730 cfg.group_ops_bls12381_g1_add_cost = Some(52);
3731 cfg.group_ops_bls12381_g2_add_cost = Some(52);
3732 cfg.group_ops_bls12381_gt_add_cost = Some(52);
3733 cfg.group_ops_bls12381_scalar_sub_cost = Some(52);
3734 cfg.group_ops_bls12381_g1_sub_cost = Some(52);
3735 cfg.group_ops_bls12381_g2_sub_cost = Some(52);
3736 cfg.group_ops_bls12381_gt_sub_cost = Some(52);
3737 cfg.group_ops_bls12381_scalar_mul_cost = Some(52);
3738 cfg.group_ops_bls12381_g1_mul_cost = Some(52);
3739 cfg.group_ops_bls12381_g2_mul_cost = Some(52);
3740 cfg.group_ops_bls12381_gt_mul_cost = Some(52);
3741 cfg.group_ops_bls12381_scalar_div_cost = Some(52);
3742 cfg.group_ops_bls12381_g1_div_cost = Some(52);
3743 cfg.group_ops_bls12381_g2_div_cost = Some(52);
3744 cfg.group_ops_bls12381_gt_div_cost = Some(52);
3745 cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(52);
3746 cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(52);
3747 cfg.group_ops_bls12381_g1_hash_to_cost_per_byte = Some(2);
3748 cfg.group_ops_bls12381_g2_hash_to_cost_per_byte = Some(2);
3749 cfg.group_ops_bls12381_g1_msm_base_cost = Some(52);
3750 cfg.group_ops_bls12381_g2_msm_base_cost = Some(52);
3751 cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(52);
3752 cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(52);
3753 cfg.group_ops_bls12381_msm_max_len = Some(32);
3754 cfg.group_ops_bls12381_pairing_cost = Some(52);
3755 }
3756 42 => {}
3757 43 => {
3758 cfg.feature_flags.zklogin_max_epoch_upper_bound_delta = Some(30);
3759 cfg.max_meter_ticks_per_package = Some(16_000_000);
3760 }
3761 44 => {
3762 cfg.feature_flags.include_consensus_digest_in_prologue = true;
3764 if chain != Chain::Mainnet {
3766 cfg.feature_flags.consensus_choice = ConsensusChoice::SwapEachEpoch;
3767 }
3768 }
3769 45 => {
3770 if chain != Chain::Testnet && chain != Chain::Mainnet {
3772 cfg.feature_flags.consensus_network = ConsensusNetwork::Tonic;
3773 }
3774
3775 if chain != Chain::Mainnet {
3776 cfg.feature_flags.mysticeti_leader_scoring_and_schedule = true;
3778 }
3779 cfg.min_move_binary_format_version = Some(6);
3780 cfg.feature_flags.accept_zklogin_in_multisig = true;
3781
3782 if chain != Chain::Mainnet && chain != Chain::Testnet {
3786 cfg.feature_flags.bridge = true;
3787 }
3788 }
3789 46 => {
3790 if chain != Chain::Mainnet {
3792 cfg.feature_flags.bridge = true;
3793 }
3794
3795 cfg.feature_flags.reshare_at_same_initial_version = true;
3797 }
3798 47 => {}
3799 48 => {
3800 cfg.feature_flags.consensus_network = ConsensusNetwork::Tonic;
3802
3803 cfg.feature_flags.resolve_abort_locations_to_package_id = true;
3805
3806 if chain != Chain::Mainnet {
3808 cfg.feature_flags.random_beacon = true;
3809 cfg.random_beacon_reduction_lower_bound = Some(1600);
3810 cfg.random_beacon_dkg_timeout_round = Some(3000);
3811 cfg.random_beacon_min_round_interval_ms = Some(200);
3812 }
3813
3814 cfg.feature_flags.mysticeti_use_committed_subdag_digest = true;
3816 }
3817 49 => {
3818 if chain != Chain::Testnet && chain != Chain::Mainnet {
3819 cfg.move_binary_format_version = Some(7);
3820 }
3821
3822 if chain != Chain::Mainnet && chain != Chain::Testnet {
3824 cfg.feature_flags.enable_vdf = true;
3825 cfg.vdf_verify_vdf_cost = Some(1500);
3828 cfg.vdf_hash_to_input_cost = Some(100);
3829 }
3830
3831 if chain != Chain::Testnet && chain != Chain::Mainnet {
3833 cfg.feature_flags
3834 .record_consensus_determined_version_assignments_in_prologue = true;
3835 }
3836
3837 if chain != Chain::Mainnet {
3839 cfg.feature_flags.consensus_choice = ConsensusChoice::Mysticeti;
3840 }
3841
3842 cfg.feature_flags.fresh_vm_on_framework_upgrade = true;
3844 }
3845 50 => {
3846 if chain != Chain::Mainnet {
3848 cfg.checkpoint_summary_version_specific_data = Some(1);
3849 cfg.min_checkpoint_interval_ms = Some(200);
3850 }
3851
3852 if chain != Chain::Testnet && chain != Chain::Mainnet {
3854 cfg.feature_flags
3855 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = true;
3856 }
3857
3858 cfg.feature_flags.mysticeti_num_leaders_per_round = Some(1);
3859
3860 cfg.max_deferral_rounds_for_congestion_control = Some(10);
3862 }
3863 51 => {
3864 cfg.random_beacon_dkg_version = Some(1);
3865
3866 if chain != Chain::Testnet && chain != Chain::Mainnet {
3867 cfg.feature_flags.enable_coin_deny_list_v2 = true;
3868 }
3869 }
3870 52 => {
3871 if chain != Chain::Mainnet {
3872 cfg.feature_flags.soft_bundle = true;
3873 cfg.max_soft_bundle_size = Some(5);
3874 }
3875
3876 cfg.config_read_setting_impl_cost_base = Some(100);
3877 cfg.config_read_setting_impl_cost_per_byte = Some(40);
3878
3879 if chain != Chain::Testnet && chain != Chain::Mainnet {
3881 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(100);
3882 cfg.feature_flags.per_object_congestion_control_mode =
3883 PerObjectCongestionControlMode::TotalTxCount;
3884 }
3885
3886 cfg.feature_flags.consensus_choice = ConsensusChoice::Mysticeti;
3888
3889 cfg.feature_flags.mysticeti_leader_scoring_and_schedule = true;
3891
3892 cfg.checkpoint_summary_version_specific_data = Some(1);
3894 cfg.min_checkpoint_interval_ms = Some(200);
3895
3896 if chain != Chain::Mainnet {
3898 cfg.feature_flags
3899 .record_consensus_determined_version_assignments_in_prologue = true;
3900 cfg.feature_flags
3901 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = true;
3902 }
3903 if chain != Chain::Mainnet {
3905 cfg.move_binary_format_version = Some(7);
3906 }
3907
3908 if chain != Chain::Testnet && chain != Chain::Mainnet {
3909 cfg.feature_flags.passkey_auth = true;
3910 }
3911 cfg.feature_flags.enable_coin_deny_list_v2 = true;
3912 }
3913 53 => {
3914 cfg.bridge_should_try_to_finalize_committee = Some(chain != Chain::Mainnet);
3916
3917 cfg.feature_flags
3919 .record_consensus_determined_version_assignments_in_prologue = true;
3920 cfg.feature_flags
3921 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = true;
3922
3923 if chain == Chain::Unknown {
3924 cfg.feature_flags.authority_capabilities_v2 = true;
3925 }
3926
3927 if chain != Chain::Mainnet {
3929 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(100);
3930 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(10);
3931 cfg.feature_flags.per_object_congestion_control_mode =
3932 PerObjectCongestionControlMode::TotalTxCount;
3933 }
3934
3935 cfg.bcs_per_byte_serialized_cost = Some(2);
3937 cfg.bcs_legacy_min_output_size_cost = Some(1);
3938 cfg.bcs_failure_cost = Some(52);
3939 cfg.debug_print_base_cost = Some(52);
3940 cfg.debug_print_stack_trace_base_cost = Some(52);
3941 cfg.hash_sha2_256_base_cost = Some(52);
3942 cfg.hash_sha2_256_per_byte_cost = Some(2);
3943 cfg.hash_sha2_256_legacy_min_input_len_cost = Some(1);
3944 cfg.hash_sha3_256_base_cost = Some(52);
3945 cfg.hash_sha3_256_per_byte_cost = Some(2);
3946 cfg.hash_sha3_256_legacy_min_input_len_cost = Some(1);
3947 cfg.type_name_get_base_cost = Some(52);
3948 cfg.type_name_get_per_byte_cost = Some(2);
3949 cfg.string_check_utf8_base_cost = Some(52);
3950 cfg.string_check_utf8_per_byte_cost = Some(2);
3951 cfg.string_is_char_boundary_base_cost = Some(52);
3952 cfg.string_sub_string_base_cost = Some(52);
3953 cfg.string_sub_string_per_byte_cost = Some(2);
3954 cfg.string_index_of_base_cost = Some(52);
3955 cfg.string_index_of_per_byte_pattern_cost = Some(2);
3956 cfg.string_index_of_per_byte_searched_cost = Some(2);
3957 cfg.vector_empty_base_cost = Some(52);
3958 cfg.vector_length_base_cost = Some(52);
3959 cfg.vector_push_back_base_cost = Some(52);
3960 cfg.vector_push_back_legacy_per_abstract_memory_unit_cost = Some(2);
3961 cfg.vector_borrow_base_cost = Some(52);
3962 cfg.vector_pop_back_base_cost = Some(52);
3963 cfg.vector_destroy_empty_base_cost = Some(52);
3964 cfg.vector_swap_base_cost = Some(52);
3965 }
3966 54 => {
3967 cfg.feature_flags.random_beacon = true;
3969 cfg.random_beacon_reduction_lower_bound = Some(1000);
3970 cfg.random_beacon_dkg_timeout_round = Some(3000);
3971 cfg.random_beacon_min_round_interval_ms = Some(500);
3972
3973 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(100);
3975 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(10);
3976 cfg.feature_flags.per_object_congestion_control_mode =
3977 PerObjectCongestionControlMode::TotalTxCount;
3978
3979 cfg.feature_flags.soft_bundle = true;
3981 cfg.max_soft_bundle_size = Some(5);
3982 }
3983 55 => {
3984 cfg.move_binary_format_version = Some(7);
3986
3987 cfg.consensus_max_transactions_in_block_bytes = Some(512 * 1024);
3989 cfg.consensus_max_num_transactions_in_block = Some(512);
3992
3993 cfg.feature_flags.rethrow_serialization_type_layout_errors = true;
3994 }
3995 56 => {
3996 if chain == Chain::Mainnet {
3997 cfg.feature_flags.bridge = true;
3998 }
3999 }
4000 57 => {
4001 cfg.random_beacon_reduction_lower_bound = Some(800);
4003 }
4004 58 => {
4005 if chain == Chain::Mainnet {
4006 cfg.bridge_should_try_to_finalize_committee = Some(true);
4007 }
4008
4009 if chain != Chain::Mainnet && chain != Chain::Testnet {
4010 cfg.feature_flags
4012 .consensus_distributed_vote_scoring_strategy = true;
4013 }
4014 }
4015 59 => {
4016 cfg.feature_flags.consensus_round_prober = true;
4018 }
4019 60 => {
4020 cfg.max_type_to_layout_nodes = Some(512);
4021 cfg.feature_flags.validate_identifier_inputs = true;
4022 }
4023 61 => {
4024 if chain != Chain::Mainnet {
4025 cfg.feature_flags
4027 .consensus_distributed_vote_scoring_strategy = true;
4028 }
4029 cfg.random_beacon_reduction_lower_bound = Some(700);
4031
4032 if chain != Chain::Mainnet && chain != Chain::Testnet {
4033 cfg.feature_flags.mysticeti_fastpath = true;
4035 }
4036 }
4037 62 => {
4038 cfg.feature_flags.relocate_event_module = true;
4039 }
4040 63 => {
4041 cfg.feature_flags.per_object_congestion_control_mode =
4042 PerObjectCongestionControlMode::TotalGasBudgetWithCap;
4043 cfg.gas_budget_based_txn_cost_cap_factor = Some(400_000);
4044 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(18_500_000);
4045 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(240_000_000);
4046 }
4047 64 => {
4048 cfg.feature_flags.per_object_congestion_control_mode =
4049 PerObjectCongestionControlMode::TotalTxCount;
4050 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(40);
4051 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(3);
4052 }
4053 65 => {
4054 cfg.feature_flags
4056 .consensus_distributed_vote_scoring_strategy = true;
4057 }
4058 66 => {
4059 if chain == Chain::Mainnet {
4060 cfg.feature_flags
4062 .consensus_distributed_vote_scoring_strategy = false;
4063 }
4064 }
4065 67 => {
4066 cfg.feature_flags
4068 .consensus_distributed_vote_scoring_strategy = true;
4069 }
4070 68 => {
4071 cfg.group_ops_bls12381_g1_to_uncompressed_g1_cost = Some(26);
4072 cfg.group_ops_bls12381_uncompressed_g1_to_g1_cost = Some(52);
4073 cfg.group_ops_bls12381_uncompressed_g1_sum_base_cost = Some(26);
4074 cfg.group_ops_bls12381_uncompressed_g1_sum_cost_per_term = Some(13);
4075 cfg.group_ops_bls12381_uncompressed_g1_sum_max_terms = Some(2000);
4076
4077 if chain != Chain::Mainnet && chain != Chain::Testnet {
4078 cfg.feature_flags.uncompressed_g1_group_elements = true;
4079 }
4080
4081 cfg.feature_flags.per_object_congestion_control_mode =
4082 PerObjectCongestionControlMode::TotalGasBudgetWithCap;
4083 cfg.gas_budget_based_txn_cost_cap_factor = Some(400_000);
4084 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(18_500_000);
4085 cfg.max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit =
4086 Some(3_700_000); cfg.max_txn_cost_overage_per_object_in_commit = Some(u64::MAX);
4088 cfg.gas_budget_based_txn_cost_absolute_cap_commit_count = Some(50);
4089
4090 cfg.random_beacon_reduction_lower_bound = Some(500);
4092
4093 cfg.feature_flags.disallow_new_modules_in_deps_only_packages = true;
4094 }
4095 69 => {
4096 cfg.consensus_voting_rounds = Some(40);
4098
4099 if chain != Chain::Mainnet && chain != Chain::Testnet {
4100 cfg.feature_flags.consensus_smart_ancestor_selection = true;
4102 }
4103
4104 if chain != Chain::Mainnet {
4105 cfg.feature_flags.uncompressed_g1_group_elements = true;
4106 }
4107 }
4108 70 => {
4109 if chain != Chain::Mainnet {
4110 cfg.feature_flags.consensus_smart_ancestor_selection = true;
4112 cfg.feature_flags
4114 .consensus_round_prober_probe_accepted_rounds = true;
4115 }
4116
4117 cfg.poseidon_bn254_cost_per_block = Some(388);
4118
4119 cfg.gas_model_version = Some(9);
4120 cfg.feature_flags.native_charging_v2 = true;
4121 cfg.bls12381_bls12381_min_sig_verify_cost_base = Some(44064);
4122 cfg.bls12381_bls12381_min_pk_verify_cost_base = Some(49282);
4123 cfg.ecdsa_k1_secp256k1_verify_keccak256_cost_base = Some(1470);
4124 cfg.ecdsa_k1_secp256k1_verify_sha256_cost_base = Some(1470);
4125 cfg.ecdsa_r1_secp256r1_verify_sha256_cost_base = Some(4225);
4126 cfg.ecdsa_r1_secp256r1_verify_keccak256_cost_base = Some(4225);
4127 cfg.ecvrf_ecvrf_verify_cost_base = Some(4848);
4128 cfg.ed25519_ed25519_verify_cost_base = Some(1802);
4129
4130 cfg.ecdsa_r1_ecrecover_keccak256_cost_base = Some(1173);
4132 cfg.ecdsa_r1_ecrecover_sha256_cost_base = Some(1173);
4133 cfg.ecdsa_k1_ecrecover_keccak256_cost_base = Some(500);
4134 cfg.ecdsa_k1_ecrecover_sha256_cost_base = Some(500);
4135
4136 cfg.groth16_prepare_verifying_key_bls12381_cost_base = Some(53838);
4137 cfg.groth16_prepare_verifying_key_bn254_cost_base = Some(82010);
4138 cfg.groth16_verify_groth16_proof_internal_bls12381_cost_base = Some(72090);
4139 cfg.groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input =
4140 Some(8213);
4141 cfg.groth16_verify_groth16_proof_internal_bn254_cost_base = Some(115502);
4142 cfg.groth16_verify_groth16_proof_internal_bn254_cost_per_public_input =
4143 Some(9484);
4144
4145 cfg.hash_keccak256_cost_base = Some(10);
4146 cfg.hash_blake2b256_cost_base = Some(10);
4147
4148 cfg.group_ops_bls12381_decode_scalar_cost = Some(7);
4150 cfg.group_ops_bls12381_decode_g1_cost = Some(2848);
4151 cfg.group_ops_bls12381_decode_g2_cost = Some(3770);
4152 cfg.group_ops_bls12381_decode_gt_cost = Some(3068);
4153
4154 cfg.group_ops_bls12381_scalar_add_cost = Some(10);
4155 cfg.group_ops_bls12381_g1_add_cost = Some(1556);
4156 cfg.group_ops_bls12381_g2_add_cost = Some(3048);
4157 cfg.group_ops_bls12381_gt_add_cost = Some(188);
4158
4159 cfg.group_ops_bls12381_scalar_sub_cost = Some(10);
4160 cfg.group_ops_bls12381_g1_sub_cost = Some(1550);
4161 cfg.group_ops_bls12381_g2_sub_cost = Some(3019);
4162 cfg.group_ops_bls12381_gt_sub_cost = Some(497);
4163
4164 cfg.group_ops_bls12381_scalar_mul_cost = Some(11);
4165 cfg.group_ops_bls12381_g1_mul_cost = Some(4842);
4166 cfg.group_ops_bls12381_g2_mul_cost = Some(9108);
4167 cfg.group_ops_bls12381_gt_mul_cost = Some(27490);
4168
4169 cfg.group_ops_bls12381_scalar_div_cost = Some(91);
4170 cfg.group_ops_bls12381_g1_div_cost = Some(5091);
4171 cfg.group_ops_bls12381_g2_div_cost = Some(9206);
4172 cfg.group_ops_bls12381_gt_div_cost = Some(27804);
4173
4174 cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(2962);
4175 cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(8688);
4176
4177 cfg.group_ops_bls12381_g1_msm_base_cost = Some(62648);
4178 cfg.group_ops_bls12381_g2_msm_base_cost = Some(131192);
4179 cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(1333);
4180 cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(3216);
4181
4182 cfg.group_ops_bls12381_uncompressed_g1_to_g1_cost = Some(677);
4183 cfg.group_ops_bls12381_g1_to_uncompressed_g1_cost = Some(2099);
4184 cfg.group_ops_bls12381_uncompressed_g1_sum_base_cost = Some(77);
4185 cfg.group_ops_bls12381_uncompressed_g1_sum_cost_per_term = Some(26);
4186
4187 cfg.group_ops_bls12381_pairing_cost = Some(26897);
4188 cfg.group_ops_bls12381_uncompressed_g1_sum_max_terms = Some(1200);
4189
4190 cfg.validator_validate_metadata_cost_base = Some(20000);
4191 }
4192 71 => {
4193 cfg.sip_45_consensus_amplification_threshold = Some(5);
4194
4195 cfg.allowed_txn_cost_overage_burst_per_object_in_commit = Some(185_000_000);
4197 }
4198 72 => {
4199 cfg.feature_flags.convert_type_argument_error = true;
4200
4201 cfg.max_tx_gas = Some(50_000_000_000_000);
4204 cfg.max_gas_price = Some(50_000_000_000);
4206
4207 cfg.feature_flags.variant_nodes = true;
4208 }
4209 73 => {
4210 cfg.use_object_per_epoch_marker_table_v2 = Some(true);
4212
4213 if chain != Chain::Mainnet && chain != Chain::Testnet {
4214 cfg.consensus_gc_depth = Some(60);
4217 }
4218
4219 if chain != Chain::Mainnet {
4220 cfg.feature_flags.consensus_zstd_compression = true;
4222 }
4223
4224 cfg.feature_flags.consensus_smart_ancestor_selection = true;
4226 cfg.feature_flags
4228 .consensus_round_prober_probe_accepted_rounds = true;
4229
4230 cfg.feature_flags.per_object_congestion_control_mode =
4232 PerObjectCongestionControlMode::TotalGasBudgetWithCap;
4233 cfg.gas_budget_based_txn_cost_cap_factor = Some(400_000);
4234 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(37_000_000);
4235 cfg.max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit =
4236 Some(7_400_000); cfg.max_txn_cost_overage_per_object_in_commit = Some(u64::MAX);
4238 cfg.gas_budget_based_txn_cost_absolute_cap_commit_count = Some(50);
4239 cfg.allowed_txn_cost_overage_burst_per_object_in_commit = Some(370_000_000);
4240 }
4241 74 => {
4242 if chain != Chain::Mainnet && chain != Chain::Testnet {
4244 cfg.feature_flags.enable_nitro_attestation = true;
4245 }
4246 cfg.nitro_attestation_parse_base_cost = Some(53 * 50);
4247 cfg.nitro_attestation_parse_cost_per_byte = Some(50);
4248 cfg.nitro_attestation_verify_base_cost = Some(49632 * 50);
4249 cfg.nitro_attestation_verify_cost_per_cert = Some(52369 * 50);
4250
4251 cfg.feature_flags.consensus_zstd_compression = true;
4253
4254 if chain != Chain::Mainnet && chain != Chain::Testnet {
4255 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
4256 }
4257 }
4258 75 => {
4259 if chain != Chain::Mainnet {
4260 cfg.feature_flags.passkey_auth = true;
4261 }
4262 }
4263 76 => {
4264 if chain != Chain::Mainnet && chain != Chain::Testnet {
4265 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
4266 cfg.consensus_commit_rate_estimation_window_size = Some(10);
4267 }
4268 cfg.feature_flags.minimize_child_object_mutations = true;
4269
4270 if chain != Chain::Mainnet {
4271 cfg.feature_flags.accept_passkey_in_multisig = true;
4272 }
4273 }
4274 77 => {
4275 cfg.feature_flags.uncompressed_g1_group_elements = true;
4276
4277 if chain != Chain::Mainnet {
4278 cfg.consensus_gc_depth = Some(60);
4279 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
4280 }
4281 }
4282 78 => {
4283 cfg.feature_flags.move_native_context = true;
4284 cfg.tx_context_fresh_id_cost_base = Some(52);
4285 cfg.tx_context_sender_cost_base = Some(30);
4286 cfg.tx_context_epoch_cost_base = Some(30);
4287 cfg.tx_context_epoch_timestamp_ms_cost_base = Some(30);
4288 cfg.tx_context_sponsor_cost_base = Some(30);
4289 cfg.tx_context_gas_price_cost_base = Some(30);
4290 cfg.tx_context_gas_budget_cost_base = Some(30);
4291 cfg.tx_context_ids_created_cost_base = Some(30);
4292 cfg.tx_context_replace_cost_base = Some(30);
4293 cfg.gas_model_version = Some(10);
4294
4295 if chain != Chain::Mainnet {
4296 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
4297 cfg.consensus_commit_rate_estimation_window_size = Some(10);
4298
4299 cfg.feature_flags.per_object_congestion_control_mode =
4301 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4302 ExecutionTimeEstimateParams {
4303 target_utilization: 30,
4304 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4306 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4308 stored_observations_limit: u64::MAX,
4309 stake_weighted_median_threshold: 0,
4310 default_none_duration_for_new_keys: false,
4311 observations_chunk_size: None,
4312 },
4313 );
4314 }
4315 }
4316 79 => {
4317 if chain != Chain::Mainnet {
4318 cfg.feature_flags.consensus_median_based_commit_timestamp = true;
4319
4320 cfg.consensus_bad_nodes_stake_threshold = Some(30);
4323
4324 cfg.feature_flags.consensus_batched_block_sync = true;
4325
4326 cfg.feature_flags.enable_nitro_attestation = true
4328 }
4329 cfg.feature_flags.normalize_ptb_arguments = true;
4330
4331 cfg.consensus_gc_depth = Some(60);
4332 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
4333 }
4334 80 => {
4335 cfg.max_ptb_value_size = Some(1024 * 1024);
4336 }
4337 81 => {
4338 cfg.feature_flags.consensus_median_based_commit_timestamp = true;
4339 cfg.feature_flags.enforce_checkpoint_timestamp_monotonicity = true;
4340 cfg.consensus_bad_nodes_stake_threshold = Some(30)
4341 }
4342 82 => {
4343 cfg.feature_flags.max_ptb_value_size_v2 = true;
4344 }
4345 83 => {
4346 if chain == Chain::Mainnet {
4347 let aliased: [u8; 32] = Hex::decode(
4349 "0x0b2da327ba6a4cacbe75dddd50e6e8bbf81d6496e92d66af9154c61c77f7332f",
4350 )
4351 .unwrap()
4352 .try_into()
4353 .unwrap();
4354
4355 cfg.aliased_addresses.push(AliasedAddress {
4357 original: Hex::decode("0xcd8962dad278d8b50fa0f9eb0186bfa4cbdecc6d59377214c88d0286a0ac9562").unwrap().try_into().unwrap(),
4358 aliased,
4359 allowed_tx_digests: vec![
4360 Base58::decode("B2eGLFoMHgj93Ni8dAJBfqGzo8EWSTLBesZzhEpTPA4").unwrap().try_into().unwrap(),
4361 ],
4362 });
4363
4364 cfg.aliased_addresses.push(AliasedAddress {
4365 original: Hex::decode("0xe28b50cef1d633ea43d3296a3f6b67ff0312a5f1a99f0af753c85b8b5de8ff06").unwrap().try_into().unwrap(),
4366 aliased,
4367 allowed_tx_digests: vec![
4368 Base58::decode("J4QqSAgp7VrQtQpMy5wDX4QGsCSEZu3U5KuDAkbESAge").unwrap().try_into().unwrap(),
4369 ],
4370 });
4371 }
4372
4373 if chain != Chain::Mainnet {
4376 cfg.feature_flags.resolve_type_input_ids_to_defining_id = true;
4377 cfg.transfer_party_transfer_internal_cost_base = Some(52);
4378
4379 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
4381 cfg.consensus_commit_rate_estimation_window_size = Some(10);
4382 cfg.feature_flags.per_object_congestion_control_mode =
4383 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4384 ExecutionTimeEstimateParams {
4385 target_utilization: 30,
4386 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4388 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4390 stored_observations_limit: u64::MAX,
4391 stake_weighted_median_threshold: 0,
4392 default_none_duration_for_new_keys: false,
4393 observations_chunk_size: None,
4394 },
4395 );
4396
4397 cfg.feature_flags.consensus_batched_block_sync = true;
4399
4400 cfg.feature_flags.enable_nitro_attestation_upgraded_parsing = true;
4403 cfg.feature_flags.enable_nitro_attestation = true;
4404 }
4405 }
4406 84 => {
4407 if chain == Chain::Mainnet {
4408 cfg.feature_flags.resolve_type_input_ids_to_defining_id = true;
4409 cfg.transfer_party_transfer_internal_cost_base = Some(52);
4410
4411 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
4413 cfg.consensus_commit_rate_estimation_window_size = Some(10);
4414 cfg.feature_flags.per_object_congestion_control_mode =
4415 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4416 ExecutionTimeEstimateParams {
4417 target_utilization: 30,
4418 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4420 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4422 stored_observations_limit: u64::MAX,
4423 stake_weighted_median_threshold: 0,
4424 default_none_duration_for_new_keys: false,
4425 observations_chunk_size: None,
4426 },
4427 );
4428
4429 cfg.feature_flags.consensus_batched_block_sync = true;
4431
4432 cfg.feature_flags.enable_nitro_attestation_upgraded_parsing = true;
4435 cfg.feature_flags.enable_nitro_attestation = true;
4436 }
4437
4438 cfg.feature_flags.per_object_congestion_control_mode =
4440 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4441 ExecutionTimeEstimateParams {
4442 target_utilization: 30,
4443 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4445 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4447 stored_observations_limit: 20,
4448 stake_weighted_median_threshold: 0,
4449 default_none_duration_for_new_keys: false,
4450 observations_chunk_size: None,
4451 },
4452 );
4453 cfg.feature_flags.allow_unbounded_system_objects = true;
4454 }
4455 85 => {
4456 if chain != Chain::Mainnet && chain != Chain::Testnet {
4457 cfg.feature_flags.enable_party_transfer = true;
4458 }
4459
4460 cfg.feature_flags
4461 .record_consensus_determined_version_assignments_in_prologue_v2 = true;
4462 cfg.feature_flags.disallow_self_identifier = true;
4463 cfg.feature_flags.per_object_congestion_control_mode =
4464 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4465 ExecutionTimeEstimateParams {
4466 target_utilization: 50,
4467 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4469 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4471 stored_observations_limit: 20,
4472 stake_weighted_median_threshold: 0,
4473 default_none_duration_for_new_keys: false,
4474 observations_chunk_size: None,
4475 },
4476 );
4477 }
4478 86 => {
4479 cfg.feature_flags.type_tags_in_object_runtime = true;
4480 cfg.max_move_enum_variants = Some(move_core_types::VARIANT_COUNT_MAX);
4481
4482 cfg.feature_flags.per_object_congestion_control_mode =
4484 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4485 ExecutionTimeEstimateParams {
4486 target_utilization: 50,
4487 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4489 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4491 stored_observations_limit: 20,
4492 stake_weighted_median_threshold: 3334,
4493 default_none_duration_for_new_keys: false,
4494 observations_chunk_size: None,
4495 },
4496 );
4497 if chain != Chain::Mainnet {
4499 cfg.feature_flags.enable_party_transfer = true;
4500 }
4501 }
4502 87 => {
4503 if chain == Chain::Mainnet {
4504 cfg.feature_flags.record_time_estimate_processed = true;
4505 }
4506 cfg.feature_flags.better_adapter_type_resolution_errors = true;
4507 }
4508 88 => {
4509 cfg.feature_flags.record_time_estimate_processed = true;
4510 cfg.tx_context_rgp_cost_base = Some(30);
4511 cfg.feature_flags
4512 .ignore_execution_time_observations_after_certs_closed = true;
4513
4514 cfg.feature_flags.per_object_congestion_control_mode =
4517 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4518 ExecutionTimeEstimateParams {
4519 target_utilization: 50,
4520 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4522 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4524 stored_observations_limit: 20,
4525 stake_weighted_median_threshold: 3334,
4526 default_none_duration_for_new_keys: true,
4527 observations_chunk_size: None,
4528 },
4529 );
4530 }
4531 89 => {
4532 cfg.feature_flags.dependency_linkage_error = true;
4533 cfg.feature_flags.additional_multisig_checks = true;
4534 }
4535 90 => {
4536 cfg.max_gas_price_rgp_factor_for_aborted_transactions = Some(100);
4538 cfg.feature_flags.debug_fatal_on_move_invariant_violation = true;
4539 cfg.feature_flags.additional_consensus_digest_indirect_state = true;
4540 cfg.feature_flags.accept_passkey_in_multisig = true;
4541 cfg.feature_flags.passkey_auth = true;
4542 cfg.feature_flags.check_for_init_during_upgrade = true;
4543
4544 if chain != Chain::Mainnet {
4546 cfg.feature_flags.mysticeti_fastpath = true;
4547 }
4548 }
4549 91 => {
4550 cfg.feature_flags.per_command_shared_object_transfer_rules = true;
4551 }
4552 92 => {
4553 cfg.feature_flags.per_command_shared_object_transfer_rules = false;
4554 }
4555 93 => {
4556 cfg.feature_flags
4557 .consensus_checkpoint_signature_key_includes_digest = true;
4558 }
4559 94 => {
4560 cfg.feature_flags.per_object_congestion_control_mode =
4562 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4563 ExecutionTimeEstimateParams {
4564 target_utilization: 50,
4565 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4567 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4569 stored_observations_limit: 18,
4570 stake_weighted_median_threshold: 3334,
4571 default_none_duration_for_new_keys: true,
4572 observations_chunk_size: None,
4573 },
4574 );
4575
4576 cfg.feature_flags.enable_party_transfer = true;
4578 }
4579 95 => {
4580 cfg.type_name_id_base_cost = Some(52);
4581
4582 cfg.max_transactions_per_checkpoint = Some(20_000);
4584 }
4585 96 => {
4586 if chain != Chain::Mainnet && chain != Chain::Testnet {
4588 cfg.feature_flags
4589 .include_checkpoint_artifacts_digest_in_summary = true;
4590 }
4591 cfg.feature_flags.correct_gas_payment_limit_check = true;
4592 cfg.feature_flags.authority_capabilities_v2 = true;
4593 cfg.feature_flags.use_mfp_txns_in_load_initial_object_debts = true;
4594 cfg.feature_flags.cancel_for_failed_dkg_early = true;
4595 cfg.feature_flags.enable_coin_registry = true;
4596
4597 cfg.feature_flags.mysticeti_fastpath = true;
4599 }
4600 97 => {
4601 cfg.feature_flags.additional_borrow_checks = true;
4602 }
4603 98 => {
4604 cfg.event_emit_auth_stream_cost = Some(52);
4605 cfg.feature_flags.better_loader_errors = true;
4606 cfg.feature_flags.generate_df_type_layouts = true;
4607 }
4608 99 => {
4609 cfg.feature_flags.use_new_commit_handler = true;
4610 }
4611 100 => {
4612 cfg.feature_flags.private_generics_verifier_v2 = true;
4613 }
4614 101 => {
4615 cfg.feature_flags.create_root_accumulator_object = true;
4616 cfg.max_updates_per_settlement_txn = Some(100);
4617 if chain != Chain::Mainnet {
4618 cfg.feature_flags.enable_poseidon = true;
4619 }
4620 }
4621 102 => {
4622 cfg.feature_flags.per_object_congestion_control_mode =
4626 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4627 ExecutionTimeEstimateParams {
4628 target_utilization: 50,
4629 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4631 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4633 stored_observations_limit: 180,
4634 stake_weighted_median_threshold: 3334,
4635 default_none_duration_for_new_keys: true,
4636 observations_chunk_size: Some(18),
4637 },
4638 );
4639 cfg.feature_flags.deprecate_global_storage_ops = true;
4640 }
4641 103 => {}
4642 104 => {
4643 cfg.translation_per_command_base_charge = Some(1);
4644 cfg.translation_per_input_base_charge = Some(1);
4645 cfg.translation_pure_input_per_byte_charge = Some(1);
4646 cfg.translation_per_type_node_charge = Some(1);
4647 cfg.translation_per_reference_node_charge = Some(1);
4648 cfg.translation_per_linkage_entry_charge = Some(10);
4649 cfg.gas_model_version = Some(11);
4650 cfg.feature_flags.abstract_size_in_object_runtime = true;
4651 cfg.feature_flags.object_runtime_charge_cache_load_gas = true;
4652 cfg.dynamic_field_hash_type_and_key_cost_base = Some(52);
4653 cfg.dynamic_field_add_child_object_cost_base = Some(52);
4654 cfg.dynamic_field_add_child_object_value_cost_per_byte = Some(1);
4655 cfg.dynamic_field_borrow_child_object_cost_base = Some(52);
4656 cfg.dynamic_field_borrow_child_object_child_ref_cost_per_byte = Some(1);
4657 cfg.dynamic_field_remove_child_object_cost_base = Some(52);
4658 cfg.dynamic_field_remove_child_object_child_cost_per_byte = Some(1);
4659 cfg.dynamic_field_has_child_object_cost_base = Some(52);
4660 cfg.dynamic_field_has_child_object_with_ty_cost_base = Some(52);
4661 cfg.feature_flags.enable_ptb_execution_v2 = true;
4662
4663 cfg.poseidon_bn254_cost_base = Some(260);
4664
4665 cfg.feature_flags.consensus_skip_gced_accept_votes = true;
4666
4667 if chain != Chain::Mainnet {
4668 cfg.feature_flags
4669 .enable_nitro_attestation_all_nonzero_pcrs_parsing = true;
4670 }
4671
4672 cfg.feature_flags
4673 .include_cancelled_randomness_txns_in_prologue = true;
4674 }
4675 105 => {
4676 cfg.feature_flags.enable_multi_epoch_transaction_expiration = true;
4677 cfg.feature_flags.disable_preconsensus_locking = true;
4678
4679 if chain != Chain::Mainnet {
4680 cfg.feature_flags
4681 .enable_nitro_attestation_always_include_required_pcrs_parsing = true;
4682 }
4683 }
4684 106 => {
4685 cfg.accumulator_object_storage_cost = Some(7600);
4687
4688 if chain != Chain::Mainnet && chain != Chain::Testnet {
4689 cfg.feature_flags.enable_accumulators = true;
4690 cfg.feature_flags.enable_address_balance_gas_payments = true;
4691 cfg.feature_flags.enable_authenticated_event_streams = true;
4692 cfg.feature_flags.enable_object_funds_withdraw = true;
4693 }
4694 }
4695 107 => {
4696 cfg.feature_flags
4697 .consensus_skip_gced_blocks_in_direct_finalization = true;
4698
4699 if in_integration_test() {
4701 cfg.consensus_gc_depth = Some(6);
4702 cfg.consensus_max_num_transactions_in_block = Some(8);
4703 }
4704 }
4705 108 => {
4706 cfg.feature_flags.gas_rounding_halve_digits = true;
4707 cfg.feature_flags.flexible_tx_context_positions = true;
4708 cfg.feature_flags.disable_entry_point_signature_check = true;
4709
4710 if chain != Chain::Mainnet {
4711 cfg.feature_flags.address_aliases = true;
4712
4713 cfg.feature_flags.enable_accumulators = true;
4714 cfg.feature_flags.enable_address_balance_gas_payments = true;
4715 }
4716
4717 cfg.feature_flags.enable_poseidon = true;
4718 }
4719 109 => {
4720 cfg.binary_variant_handles = Some(1024);
4721 cfg.binary_variant_instantiation_handles = Some(1024);
4722 cfg.feature_flags.restrict_hot_or_not_entry_functions = true;
4723 }
4724 110 => {
4725 cfg.feature_flags
4726 .enable_nitro_attestation_all_nonzero_pcrs_parsing = true;
4727 cfg.feature_flags
4728 .enable_nitro_attestation_always_include_required_pcrs_parsing = true;
4729 if chain != Chain::Mainnet && chain != Chain::Testnet {
4730 cfg.feature_flags.split_checkpoints_in_consensus_handler = true;
4731 }
4732 cfg.feature_flags.validate_zklogin_public_identifier = true;
4733 cfg.feature_flags.fix_checkpoint_signature_mapping = true;
4734 cfg.feature_flags
4735 .consensus_always_accept_system_transactions = true;
4736 if chain != Chain::Mainnet {
4737 cfg.feature_flags.enable_object_funds_withdraw = true;
4738 }
4739 }
4740 111 => {
4741 cfg.feature_flags.validator_metadata_verify_v2 = true;
4742 }
4743 112 => {
4744 cfg.group_ops_ristretto_decode_scalar_cost = Some(7);
4745 cfg.group_ops_ristretto_decode_point_cost = Some(200);
4746 cfg.group_ops_ristretto_scalar_add_cost = Some(10);
4747 cfg.group_ops_ristretto_point_add_cost = Some(500);
4748 cfg.group_ops_ristretto_scalar_sub_cost = Some(10);
4749 cfg.group_ops_ristretto_point_sub_cost = Some(500);
4750 cfg.group_ops_ristretto_scalar_mul_cost = Some(11);
4751 cfg.group_ops_ristretto_point_mul_cost = Some(1200);
4752 cfg.group_ops_ristretto_scalar_div_cost = Some(151);
4753 cfg.group_ops_ristretto_point_div_cost = Some(2500);
4754
4755 if chain != Chain::Mainnet && chain != Chain::Testnet {
4756 cfg.feature_flags.enable_ristretto255_group_ops = true;
4757 }
4758 }
4759 113 => {
4760 cfg.feature_flags.address_balance_gas_check_rgp_at_signing = true;
4761 if chain != Chain::Mainnet && chain != Chain::Testnet {
4762 cfg.feature_flags.defer_unpaid_amplification = true;
4763 }
4764 }
4765 114 => {
4766 cfg.feature_flags.randomize_checkpoint_tx_limit_in_tests = true;
4767 cfg.feature_flags.address_balance_gas_reject_gas_coin_arg = true;
4768 if chain != Chain::Mainnet {
4769 cfg.feature_flags.split_checkpoints_in_consensus_handler = true;
4770 cfg.feature_flags.enable_authenticated_event_streams = true;
4771 cfg.feature_flags
4772 .include_checkpoint_artifacts_digest_in_summary = true;
4773 }
4774 }
4775 115 => {
4776 cfg.feature_flags.normalize_depth_formula = true;
4777 }
4778 116 => {
4779 cfg.feature_flags.gasless_transaction_drop_safety = true;
4780 cfg.feature_flags.address_aliases = true;
4781 cfg.feature_flags.relax_valid_during_for_owned_inputs = true;
4782 cfg.feature_flags.defer_unpaid_amplification = false;
4784 cfg.feature_flags.enable_display_registry = true;
4785 }
4786 117 => {}
4787 118 => {
4788 cfg.feature_flags.use_coin_party_owner = true;
4789 }
4790 119 => {
4791 cfg.execution_version = Some(4);
4793 cfg.feature_flags.address_balance_gas_reject_gas_coin_arg = false;
4794 cfg.feature_flags.merge_randomness_into_checkpoint = true;
4795 if chain != Chain::Mainnet {
4796 cfg.feature_flags.enable_gasless = true;
4797 cfg.gasless_max_computation_units = Some(50_000);
4798 cfg.gasless_allowed_token_types = Some(vec![]);
4799 cfg.feature_flags.enable_coin_reservation_obj_refs = true;
4800 cfg.feature_flags
4801 .convert_withdrawal_compatibility_ptb_arguments = true;
4802 }
4803 cfg.gasless_max_unused_inputs = Some(1);
4804 cfg.gasless_max_pure_input_bytes = Some(32);
4805 if chain == Chain::Testnet {
4806 cfg.gasless_allowed_token_types = Some(vec![(TESTNET_USDC.to_string(), 0)]);
4807 }
4808 cfg.transfer_receive_object_cost_per_byte = Some(1);
4809 cfg.transfer_receive_object_type_cost_per_byte = Some(2);
4810 }
4811 120 => {
4812 cfg.feature_flags.disallow_jump_orphans = true;
4813 }
4814 121 => {
4815 if chain != Chain::Mainnet {
4817 cfg.feature_flags.defer_unpaid_amplification = true;
4818 cfg.gasless_max_tps = Some(50);
4819 }
4820 cfg.feature_flags
4821 .early_return_receive_object_mismatched_type = true;
4822 }
4823 122 => {
4824 cfg.feature_flags.defer_unpaid_amplification = true;
4826 cfg.verify_bulletproofs_ristretto255_base_cost = Some(30000);
4828 cfg.verify_bulletproofs_ristretto255_cost_per_bit_and_commitment = Some(6500);
4829 if chain != Chain::Mainnet && chain != Chain::Testnet {
4830 cfg.feature_flags.enable_verify_bulletproofs_ristretto255 = true;
4831 }
4832 cfg.feature_flags.gasless_verify_remaining_balance = true;
4833 cfg.include_special_package_amendments = match chain {
4834 Chain::Mainnet => Some(MAINNET_LINKAGE_AMENDMENTS.clone()),
4835 Chain::Testnet => Some(TESTNET_LINKAGE_AMENDMENTS.clone()),
4836 Chain::Unknown => None,
4837 };
4838 cfg.gasless_max_tx_size_bytes = Some(16 * 1024);
4839 cfg.gasless_max_tps = Some(300);
4840 cfg.gasless_max_computation_units = Some(5_000);
4841 }
4842 123 => {
4843 cfg.gas_model_version = Some(13);
4844 }
4845 124 => {
4846 if chain != Chain::Mainnet && chain != Chain::Testnet {
4847 cfg.feature_flags.timestamp_based_epoch_close = true;
4848 }
4849 cfg.gas_model_version = Some(14);
4850 cfg.feature_flags.limit_groth16_pvk_inputs = true;
4851
4852 cfg.feature_flags.enable_accumulators = true;
4858 cfg.feature_flags.enable_address_balance_gas_payments = true;
4859 cfg.feature_flags.enable_authenticated_event_streams = true;
4860 cfg.feature_flags.enable_coin_reservation_obj_refs = true;
4861 cfg.feature_flags.enable_object_funds_withdraw = true;
4862 cfg.feature_flags
4863 .convert_withdrawal_compatibility_ptb_arguments = true;
4864 cfg.feature_flags.split_checkpoints_in_consensus_handler = true;
4865 cfg.feature_flags
4866 .include_checkpoint_artifacts_digest_in_summary = true;
4867 cfg.feature_flags.enable_gasless = true;
4868
4869 if chain == Chain::Mainnet {
4874 cfg.gasless_allowed_token_types = Some(vec![
4875 (MAINNET_USDC.to_string(), 10_000),
4876 (MAINNET_USDSUI.to_string(), 10_000),
4877 (MAINNET_SUI_USDE.to_string(), 10_000),
4878 (MAINNET_USDY.to_string(), 10_000),
4879 (MAINNET_FDUSD.to_string(), 10_000),
4880 (MAINNET_AUSD.to_string(), 10_000),
4881 (MAINNET_USDB.to_string(), 10_000),
4882 ]);
4883 }
4884 }
4885 125 => {
4886 cfg.feature_flags.granular_post_execution_checks = true;
4887 if chain != Chain::Mainnet {
4888 cfg.feature_flags.timestamp_based_epoch_close = true;
4889 }
4890 }
4891 126 => {
4892 cfg.feature_flags.early_exit_on_iffw = true;
4893 }
4894 127 => {
4895 cfg.feature_flags.always_advance_dkg_to_resolution = true;
4896
4897 cfg.verify_bulletproofs_ristretto255_base_cost = Some(23866);
4898 cfg.verify_bulletproofs_ristretto255_cost_per_bit_and_commitment = Some(1324);
4899 cfg.group_ops_ristretto_decode_scalar_cost = Some(5);
4900 cfg.group_ops_ristretto_decode_point_cost = Some(216);
4901 cfg.group_ops_ristretto_scalar_add_cost = Some(2);
4902 cfg.group_ops_ristretto_point_add_cost = Some(8);
4903 cfg.group_ops_ristretto_scalar_sub_cost = Some(2);
4904 cfg.group_ops_ristretto_point_sub_cost = Some(8);
4905 cfg.group_ops_ristretto_scalar_mul_cost = Some(5);
4906 cfg.group_ops_ristretto_point_mul_cost = Some(1763);
4907 cfg.group_ops_ristretto_scalar_div_cost = Some(557);
4908 cfg.group_ops_ristretto_point_div_cost = Some(2244);
4909
4910 if chain != Chain::Mainnet {
4911 cfg.feature_flags.enable_ristretto255_group_ops = true;
4912 cfg.feature_flags.enable_verify_bulletproofs_ristretto255 = true;
4913 }
4914
4915 cfg.feature_flags.timestamp_based_epoch_close = true;
4916 }
4917 128 => {
4918 cfg.max_generic_instantiation_type_nodes_per_function = Some(10_000);
4919 cfg.max_generic_instantiation_type_nodes_per_module = Some(500_000);
4920 cfg.binary_enum_defs = Some(200);
4921 cfg.binary_enum_def_instantiations = Some(100);
4922 }
4923 129 => {
4924 cfg.feature_flags.enable_unified_linkage = true;
4925 }
4926 130 => {
4927 cfg.feature_flags.record_net_unsettled_object_withdraws = true;
4928 cfg.feature_flags.enable_init_on_upgrade = true;
4929 cfg.epoch_close_deadline_ms = Some(120_000);
4930 cfg.scratch_add_cost_base = Some(13);
4931 cfg.scratch_read_cost_base = Some(13);
4932 cfg.scratch_read_value_cost = Some(1);
4933 cfg.scratch_remove_cost_base = Some(13);
4934 cfg.scratch_exists_cost_base = Some(13);
4935 cfg.scratch_exists_with_type_cost_base = Some(13);
4936 cfg.scratch_exists_with_type_type_cost = Some(1);
4937 let max_commands = cfg.max_programmable_tx_commands() as u64;
4938 cfg.max_scratch_pad_size = Some(16 * max_commands);
4939 if chain != Chain::Mainnet && chain != Chain::Testnet {
4941 cfg.feature_flags.zklogin_circuit_mode = 1;
4942 }
4943 }
4944 131 => {
4945 cfg.feature_flags.share_transaction_deny_config_in_consensus = true;
4946 cfg.feature_flags.framework_tx_context_mut_restrictions = true;
4947 }
4948 132 => {
4949 if chain != Chain::Mainnet && chain != Chain::Testnet {
4950 cfg.feature_flags.defer_owned_object_double_spend = true;
4951 cfg.feature_flags.create_forwarding_address_registry = true;
4952 }
4953 cfg.object_record_new_uid_from_hash_cost_base = Some(1);
4954 cfg.feature_flags
4955 .enable_order_independent_upgrade_init_linkage = true;
4956 }
4957 133 => {
4958 cfg.feature_flags
4959 .include_function_signatures_in_instantiation_limits = true;
4960 cfg.max_accumulator_type_nodes = Some(16);
4961 }
4962 134 => {
4963 if chain != Chain::Mainnet {
4970 cfg.package_original_package_id_impl_cost_base = Some(52);
4971 let package_read_cost_per_byte = cfg.obj_access_cost_read_per_byte();
4972 cfg.package_original_package_id_impl_cost_per_byte =
4973 Some(package_read_cost_per_byte);
4974
4975 cfg.consensus_max_transactions_in_block_bytes = Some(288 * 1024);
4976 cfg.consensus_max_num_transactions_in_block = Some(128);
4977 }
4978
4979 if chain == Chain::Mainnet {
4980 cfg.feature_flags.defer_unpaid_amplification = false;
4981 }
4982 }
4983 135 => {
4984 cfg.package_original_package_id_impl_cost_base = Some(52);
4987 let package_read_cost_per_byte = cfg.obj_access_cost_read_per_byte();
4988 cfg.package_original_package_id_impl_cost_per_byte =
4989 Some(package_read_cost_per_byte);
4990
4991 cfg.consensus_max_transactions_in_block_bytes = Some(288 * 1024);
4992 cfg.consensus_max_num_transactions_in_block = Some(128);
4993
4994 cfg.feature_flags.defer_unpaid_amplification = false;
4995 }
4996 136 => {
4997 cfg.feature_flags.ptb_tx_context_restrictions = true;
4998
4999 cfg.translation_per_live_reference_charge = Some(1);
5000 cfg.max_ptb_live_references = Some(64);
5001 cfg.max_ptb_returned_references = Some(16);
5002 cfg.max_ptb_total_returned_references = Some(256);
5003
5004 if chain != Chain::Mainnet && chain != Chain::Testnet {
5005 cfg.feature_flags.allowed_proposers = true;
5006 }
5007 cfg.feature_flags.harden_linkage_consistency = true;
5008
5009 cfg.package_arena_size_in_bytes = Some(10_000_000);
5010 }
5011 137 => {
5012 cfg.verify_bulletproofs_ristretto255_cost_per_bit_and_commitment = Some(621);
5013 cfg.max_bulletproofs_total_bits = Some(1024);
5014
5015 if chain != Chain::Mainnet {
5016 cfg.feature_flags.enable_allowances = true;
5017 }
5018 cfg.feature_flags.fix_ptb_generated_reads = true;
5019 cfg.feature_flags.charge_ld_const_abstract_size = true;
5020 if chain != Chain::Mainnet && chain != Chain::Testnet {
5021 cfg.feature_flags.check_object_funds_withdraw_in_execution = true;
5022 }
5023 cfg.reserve_object_funds_for_withdrawal_cost_base = Some(52);
5024 cfg.reserve_object_funds_for_withdrawal_cold_read_cost = Some(184);
5027
5028 cfg.feature_flags.allowed_proposers = true;
5029
5030 cfg.feature_flags.validate_ptb_argument_indices = true;
5031 cfg.feature_flags.memory_safety_invariant_check_v2 = true;
5032 }
5033 138 => {
5034 cfg.gas_model_version = Some(15);
5035 cfg.feature_flags.enable_allowances = true;
5036 if chain != Chain::Mainnet {
5037 cfg.feature_flags.check_object_funds_withdraw_in_execution = true;
5038 cfg.feature_flags.disable_effects_tx_dependencies = true;
5039 }
5040 cfg.feature_flags.merge_colliding_deferrals = true;
5041 if chain == Chain::Mainnet {
5043 cfg.storage_rebate_rate = Some(9999);
5044 }
5045 }
5046 139 => {
5047 if chain != Chain::Mainnet && chain != Chain::Testnet {
5048 cfg.feature_flags.enable_forwarding_addresses = true;
5049 cfg.feature_flags.mldsa65_auth = true;
5050 }
5051 cfg.storage_rebate_rate = Some(9999);
5052 if chain != Chain::Mainnet {
5053 cfg.feature_flags.allow_dkg_completion_after_timeout = true;
5054 }
5055 cfg.obj_access_cost_read_per_package_kb = Some(154);
5057 }
5058 140 => {
5059 cfg.staggered_submission_signal_window_commits = Some(300);
5062 cfg.staggered_submission_signal_min_excess_copies_per_commit = Some(2);
5063 cfg.staggered_submission_signal_exit_dwell_commits = Some(6000);
5064 cfg.staggered_submission_signal_band1_enter_ratio_bps = Some(1000);
5065 cfg.staggered_submission_signal_band1_exit_ratio_bps = Some(500);
5066 cfg.staggered_submission_signal_band2_enter_ratio_bps = Some(5000);
5067 cfg.staggered_submission_signal_band2_exit_ratio_bps = Some(2500);
5068
5069 cfg.vector_reverse_base_cost = Some(52);
5070 cfg.vector_reverse_per_elem_cost = Some(8);
5071 cfg.vector_keep_range_base_cost = Some(52);
5072 cfg.vector_keep_range_per_dropped_elem_cost = Some(1);
5073 cfg.vector_keep_range_per_moved_elem_cost = Some(8);
5074 cfg.vector_copy_range_base_cost = Some(52);
5075 cfg.vector_replace_range_base_cost = Some(52);
5076 cfg.vector_replace_range_per_elem_cost = Some(8);
5077
5078 if chain != Chain::Mainnet && chain != Chain::Testnet {
5079 cfg.feature_flags.shuffle_consensus_commit_blocks = true;
5080 }
5081
5082 cfg.feature_flags.allow_references_in_ptbs = true;
5083 cfg.feature_flags.disable_id_leak_verifier = true;
5084 cfg.feature_flags.check_object_funds_withdraw_in_execution = true;
5085 cfg.feature_flags.disable_effects_tx_dependencies = true;
5086 }
5087 141 => {
5088 cfg.feature_flags.complete_effects_size_estimate = true;
5089 cfg.max_num_accumulator_events = Some(1024);
5090 }
5091 142 => {
5092 cfg.clock_borrow_cost_base = Some(52);
5093 cfg.feature_flags.check_groth16_pvk_length = true;
5094 cfg.object_is_shared_input_cost_base = Some(52);
5095 cfg.feature_flags.secp256r1_ecrecover_checks_x_below_p = true;
5096 cfg.binary_format_limits_profile = Some(BinaryFormatLimitsProfile::V1);
5097 cfg.feature_flags.defer_owned_object_double_spend = true;
5098 }
5099 143 => {
5100 cfg.execution_version = Some(5);
5101 cfg.package_arena_size_in_bytes = Some(20_000_000);
5102 cfg.feature_flags.simplify_nitro_header_validation = true;
5103 cfg.feature_flags.enable_forwarding_addresses = false;
5104 cfg.feature_flags.package_publish_charge = true;
5105 cfg.package_publish_charge_fixed = Some(1_000_000_000);
5106 cfg.package_publish_charge_per_module = Some(10_000_000);
5107 cfg.package_publish_charge_per_dependency = Some(10_000_000);
5108 if chain != Chain::Mainnet {
5109 cfg.feature_flags.mldsa65_auth = true;
5110 }
5111 cfg.layout_node_cost = Some(16);
5112 cfg.layout_node_cost_large_layout_threshold = Some(64);
5113 cfg.bcs_per_input_abstract_unit_cost = Some(20);
5114 cfg.vector_copy_range_per_abstract_memory_unit_cost = Some(1);
5115 }
5116 144 => {
5117 if chain != Chain::Mainnet && chain != Chain::Testnet {
5118 cfg.feature_flags.enable_timestamp_transaction_expiration = true;
5119 }
5120 cfg.object_runtime_max_loaded_child_value_size = Some(5_000_000);
5121
5122 cfg.feature_flags.staggered_submission_signal = true;
5123 cfg.staggered_submission_signal_window_commits = Some(600);
5135 cfg.staggered_submission_signal_min_consensus_user_transactions_per_commit =
5136 Some(1000);
5137 if chain == Chain::Testnet {
5138 cfg.staggered_submission_signal_min_consensus_user_transactions_per_commit = Some(5);
5144 }
5145 }
5146 145 => {
5147 cfg.feature_flags.secp256r1_strict_public_keys = true;
5148 cfg.feature_flags.create_freeze_list = true;
5149 cfg.feature_flags.enable_coin_regulation = true;
5150 }
5151 _ => panic!("unsupported version {:?}", version),
5162 }
5163 }
5164
5165 cfg
5166 }
5167
5168 pub fn apply_seeded_test_overrides(&mut self, seed: &[u8; 32]) {
5169 if !self.feature_flags.randomize_checkpoint_tx_limit_in_tests
5170 || !self.feature_flags.split_checkpoints_in_consensus_handler
5171 {
5172 return;
5173 }
5174
5175 if !mysten_common::in_test_configuration() {
5176 return;
5177 }
5178
5179 use rand::{Rng, SeedableRng, rngs::StdRng};
5180 let mut rng = StdRng::from_seed(*seed);
5181 let max_txns = rng.gen_range(10..=100u64);
5182 info!("seeded test override: max_transactions_per_checkpoint = {max_txns}");
5183 self.max_transactions_per_checkpoint = Some(max_txns);
5184 }
5185
5186 pub fn verifier_config(&self, signing_limits: Option<(usize, usize, usize)>) -> VerifierConfig {
5192 let (
5193 max_back_edges_per_function,
5194 max_back_edges_per_module,
5195 sanity_check_with_regex_reference_safety,
5196 ) = if let Some((
5197 max_back_edges_per_function,
5198 max_back_edges_per_module,
5199 sanity_check_with_regex_reference_safety,
5200 )) = signing_limits
5201 {
5202 (
5203 Some(max_back_edges_per_function),
5204 Some(max_back_edges_per_module),
5205 Some(sanity_check_with_regex_reference_safety),
5206 )
5207 } else {
5208 (None, None, None)
5209 };
5210
5211 let additional_borrow_checks = if signing_limits.is_some() {
5212 true
5214 } else {
5215 self.additional_borrow_checks()
5216 };
5217 let deprecate_global_storage_ops = if signing_limits.is_some() {
5218 true
5220 } else {
5221 self.deprecate_global_storage_ops()
5222 };
5223
5224 VerifierConfig {
5225 max_loop_depth: Some(self.max_loop_depth() as usize),
5226 max_generic_instantiation_length: Some(self.max_generic_instantiation_length() as usize),
5227 max_function_parameters: Some(self.max_function_parameters() as usize),
5228 max_basic_blocks: Some(self.max_basic_blocks() as usize),
5229 max_value_stack_size: self.max_value_stack_size() as usize,
5230 max_type_nodes: Some(self.max_type_nodes() as usize),
5231 max_generic_instantiation_type_nodes_per_function: self
5232 .max_generic_instantiation_type_nodes_per_function_as_option()
5233 .map(|v| v as usize),
5234 max_generic_instantiation_type_nodes_per_module: self
5235 .max_generic_instantiation_type_nodes_per_module_as_option()
5236 .map(|v| v as usize),
5237 include_function_signatures_in_instantiation_limits: self
5238 .include_function_signatures_in_instantiation_limits(),
5239 max_push_size: Some(self.max_push_size() as usize),
5240 max_dependency_depth: Some(self.max_dependency_depth() as usize),
5241 max_fields_in_struct: Some(self.max_fields_in_struct() as usize),
5242 max_function_definitions: Some(self.max_function_definitions() as usize),
5243 max_data_definitions: Some(self.max_struct_definitions() as usize),
5244 max_constant_vector_len: Some(self.max_move_vector_len()),
5245 max_back_edges_per_function,
5246 max_back_edges_per_module,
5247 max_basic_blocks_in_script: None,
5248 max_identifier_len: self.max_move_identifier_len_as_option(), disallow_self_identifier: self.feature_flags.disallow_self_identifier,
5250 allow_receiving_object_id: self.allow_receiving_object_id(),
5251 reject_mutable_random_on_entry_functions: self
5252 .reject_mutable_random_on_entry_functions(),
5253 bytecode_version: self.move_binary_format_version(),
5254 max_variants_in_enum: self.max_move_enum_variants_as_option(),
5255 additional_borrow_checks,
5256 better_loader_errors: self.better_loader_errors(),
5257 private_generics_verifier_v2: self.private_generics_verifier_v2(),
5258 sanity_check_with_regex_reference_safety: sanity_check_with_regex_reference_safety
5259 .map(|limit| limit as u128),
5260 deprecate_global_storage_ops,
5261 disable_entry_point_signature_check: self.disable_entry_point_signature_check(),
5262 disable_id_leak_verifier: self.disable_id_leak_verifier(),
5263 switch_to_regex_reference_safety: false,
5264 framework_tx_context_mut_restrictions: self.framework_tx_context_mut_restrictions(),
5265 disallow_jump_orphans: self.disallow_jump_orphans(),
5266 }
5267 }
5268
5269 pub fn binary_config(
5270 &self,
5271 override_deprecate_global_storage_ops_during_deserialization: Option<bool>,
5272 ) -> BinaryConfig {
5273 let deprecate_global_storage_ops =
5274 override_deprecate_global_storage_ops_during_deserialization
5275 .unwrap_or_else(|| self.deprecate_global_storage_ops());
5276 BinaryConfig::new(
5277 self.move_binary_format_version(),
5278 self.min_move_binary_format_version_as_option()
5279 .unwrap_or(VERSION_1),
5280 self.no_extraneous_module_bytes(),
5281 deprecate_global_storage_ops,
5282 TableConfig {
5283 module_handles: self.binary_module_handles_as_option().unwrap_or(u16::MAX),
5284 datatype_handles: self.binary_struct_handles_as_option().unwrap_or(u16::MAX),
5285 function_handles: self.binary_function_handles_as_option().unwrap_or(u16::MAX),
5286 function_instantiations: self
5287 .binary_function_instantiations_as_option()
5288 .unwrap_or(u16::MAX),
5289 signatures: self.binary_signatures_as_option().unwrap_or(u16::MAX),
5290 constant_pool: self.binary_constant_pool_as_option().unwrap_or(u16::MAX),
5291 identifiers: self.binary_identifiers_as_option().unwrap_or(u16::MAX),
5292 address_identifiers: self
5293 .binary_address_identifiers_as_option()
5294 .unwrap_or(u16::MAX),
5295 struct_defs: self.binary_struct_defs_as_option().unwrap_or(u16::MAX),
5296 struct_def_instantiations: self
5297 .binary_struct_def_instantiations_as_option()
5298 .unwrap_or(u16::MAX),
5299 function_defs: self.binary_function_defs_as_option().unwrap_or(u16::MAX),
5300 field_handles: self.binary_field_handles_as_option().unwrap_or(u16::MAX),
5301 field_instantiations: self
5302 .binary_field_instantiations_as_option()
5303 .unwrap_or(u16::MAX),
5304 friend_decls: self.binary_friend_decls_as_option().unwrap_or(u16::MAX),
5305 enum_defs: self.binary_enum_defs_as_option().unwrap_or(u16::MAX),
5306 enum_def_instantiations: self
5307 .binary_enum_def_instantiations_as_option()
5308 .unwrap_or(u16::MAX),
5309 variant_handles: self.binary_variant_handles_as_option().unwrap_or(u16::MAX),
5310 variant_instantiation_handles: self
5311 .binary_variant_instantiation_handles_as_option()
5312 .unwrap_or(u16::MAX),
5313 },
5314 self.binary_format_limits(),
5315 )
5316 }
5317
5318 pub fn binary_format_limits(
5319 &self,
5320 ) -> &'static move_binary_format::binary_config::BinaryFormatLimits {
5321 self.binary_format_limits_profile
5322 .unwrap_or(BinaryFormatLimitsProfile::LEGACY)
5323 .limits()
5324 }
5325
5326 pub fn apply_overrides_for_testing(
5330 override_fn: impl Fn(ProtocolVersion, Self) -> Self + Send + Sync + 'static,
5331 ) -> OverrideGuard {
5332 let mut cur = CONFIG_OVERRIDE.lock().unwrap();
5333 assert!(cur.is_none(), "config override already present");
5334 *cur = Some(Box::new(override_fn));
5335 OverrideGuard
5336 }
5337
5338 #[cfg(feature = "testing")]
5342 pub fn apply_base_overrides_for_testing(
5343 override_fn: impl Fn(ProtocolVersion, Self) -> Self + Send + Sync + 'static,
5344 ) -> BaseOverrideGuard {
5345 info!("installing base ProtocolConfig override for testing");
5346 let override_fn: Arc<OverrideFn> = Arc::new(override_fn);
5347 BASE_CONFIG_OVERRIDES
5348 .lock()
5349 .unwrap()
5350 .push(override_fn.clone());
5351 BaseOverrideGuard { override_fn }
5352 }
5353
5354 fn apply_config_override(version: ProtocolVersion, mut ret: Self) -> Self {
5355 #[cfg(feature = "testing")]
5357 {
5358 let fns = BASE_CONFIG_OVERRIDES.lock().unwrap().clone();
5359 for override_fn in fns {
5360 ret = override_fn(version, ret);
5361 }
5362 }
5363 if let Some(override_fn) = CONFIG_OVERRIDE.lock().unwrap().as_ref() {
5364 warn!(
5365 "overriding ProtocolConfig settings with custom settings (you should not see this log outside of tests)"
5366 );
5367 ret = override_fn(version, ret);
5368 }
5369 ret
5370 }
5371}
5372
5373impl ProtocolConfig {
5377 pub fn set_execution_version_for_testing(&mut self, val: u64) {
5381 let current = self.execution_version.unwrap_or(0);
5382 assert!(
5383 val >= current,
5384 "cannot downgrade execution_version from {current} to {val}: running an old \
5385 executor against a newer protocol config/framework is unsupported. To test \
5386 frozen executor behavior, start from the last protocol version of that executor \
5387 instead, so genesis loads the matching framework snapshot (see \
5388 test_address_balance_gas_v3_accumulator_sign)."
5389 );
5390 self.execution_version = Some(val);
5391 }
5392
5393 pub fn set_zklogin_circuit_mode_for_testing(&mut self, val: u64) {
5396 self.feature_flags.zklogin_circuit_mode = val
5397 }
5398
5399 pub fn set_per_object_congestion_control_mode_for_testing(
5400 &mut self,
5401 val: PerObjectCongestionControlMode,
5402 ) {
5403 self.feature_flags.per_object_congestion_control_mode = val;
5404 }
5405
5406 pub fn set_consensus_choice_for_testing(&mut self, val: ConsensusChoice) {
5407 self.feature_flags.consensus_choice = val;
5408 }
5409
5410 pub fn set_consensus_network_for_testing(&mut self, val: ConsensusNetwork) {
5411 self.feature_flags.consensus_network = val;
5412 }
5413
5414 pub fn set_zklogin_max_epoch_upper_bound_delta_for_testing(&mut self, val: Option<u64>) {
5415 self.feature_flags.zklogin_max_epoch_upper_bound_delta = val
5416 }
5417
5418 pub fn set_mysticeti_num_leaders_per_round_for_testing(&mut self, val: Option<usize>) {
5419 self.feature_flags.mysticeti_num_leaders_per_round = val;
5420 }
5421
5422 pub fn disable_accumulators_for_testing(&mut self) {
5423 self.feature_flags.enable_accumulators = false;
5424 self.feature_flags.enable_address_balance_gas_payments = false;
5425 }
5426
5427 pub fn enable_coin_reservation_for_testing(&mut self) {
5428 self.feature_flags.enable_coin_reservation_obj_refs = true;
5429 self.feature_flags
5430 .convert_withdrawal_compatibility_ptb_arguments = true;
5431 self.execution_version = Some(self.execution_version.map_or(4, |v| v.max(4)));
5434 }
5435
5436 pub fn disable_coin_reservation_for_testing(&mut self) {
5437 self.feature_flags.enable_coin_reservation_obj_refs = false;
5438 self.feature_flags
5439 .convert_withdrawal_compatibility_ptb_arguments = false;
5440 }
5441
5442 pub fn enable_address_balance_gas_payments_for_testing(&mut self) {
5443 self.feature_flags.enable_accumulators = true;
5444 self.feature_flags.allow_private_accumulator_entrypoints = true;
5445 self.feature_flags.enable_address_balance_gas_payments = true;
5446 self.feature_flags.address_balance_gas_check_rgp_at_signing = true;
5447 self.feature_flags.address_balance_gas_reject_gas_coin_arg = false;
5448 self.execution_version = Some(self.execution_version.map_or(4, |v| v.max(4)))
5449 }
5450
5451 pub fn enable_gasless_for_testing(&mut self) {
5452 self.enable_address_balance_gas_payments_for_testing();
5453 self.feature_flags.enable_gasless = true;
5454 self.feature_flags.gasless_verify_remaining_balance = true;
5455 self.gasless_max_computation_units = Some(5_000);
5456 self.gasless_allowed_token_types = Some(vec![]);
5457 self.gasless_max_tps = Some(1000);
5458 self.gasless_max_tx_size_bytes = Some(16 * 1024);
5459 }
5460
5461 pub fn disable_gasless_for_testing(&mut self) {
5462 self.feature_flags.enable_gasless = false;
5463 self.gasless_max_computation_units = None;
5464 self.gasless_allowed_token_types = None;
5465 }
5466
5467 pub fn enable_authenticated_event_streams_for_testing(&mut self) {
5468 self.feature_flags.enable_accumulators = true;
5469 self.feature_flags.enable_authenticated_event_streams = true;
5470 self.feature_flags
5471 .include_checkpoint_artifacts_digest_in_summary = true;
5472 self.feature_flags.split_checkpoints_in_consensus_handler = true;
5473 }
5474}
5475
5476type OverrideFn = dyn Fn(ProtocolVersion, ProtocolConfig) -> ProtocolConfig + Send + Sync;
5477
5478static CONFIG_OVERRIDE: Mutex<Option<Box<OverrideFn>>> = Mutex::new(None);
5479
5480#[must_use]
5481pub struct OverrideGuard;
5482
5483impl Drop for OverrideGuard {
5484 fn drop(&mut self) {
5485 info!("restoring override fn");
5486 *CONFIG_OVERRIDE.lock().unwrap() = None;
5487 }
5488}
5489
5490#[cfg(feature = "testing")]
5491static BASE_CONFIG_OVERRIDES: Mutex<Vec<Arc<OverrideFn>>> = Mutex::new(Vec::new());
5492
5493#[cfg(feature = "testing")]
5494#[must_use]
5495pub struct BaseOverrideGuard {
5496 override_fn: Arc<OverrideFn>,
5497}
5498
5499#[cfg(feature = "testing")]
5500impl Drop for BaseOverrideGuard {
5501 fn drop(&mut self) {
5502 BASE_CONFIG_OVERRIDES
5503 .lock()
5504 .unwrap()
5505 .retain(|f| !Arc::ptr_eq(f, &self.override_fn));
5506 }
5507}
5508
5509#[derive(PartialEq, Eq)]
5512pub enum LimitThresholdCrossed {
5513 None,
5514 Soft(u128, u128),
5515 Hard(u128, u128),
5516}
5517
5518pub fn check_limit_in_range<T: Into<V>, U: Into<V>, V: PartialOrd + Into<u128>>(
5521 x: T,
5522 soft_limit: U,
5523 hard_limit: V,
5524) -> LimitThresholdCrossed {
5525 let x: V = x.into();
5526 let soft_limit: V = soft_limit.into();
5527
5528 debug_assert!(soft_limit <= hard_limit);
5529
5530 if x >= hard_limit {
5533 LimitThresholdCrossed::Hard(x.into(), hard_limit.into())
5534 } else if x < soft_limit {
5535 LimitThresholdCrossed::None
5536 } else {
5537 LimitThresholdCrossed::Soft(x.into(), soft_limit.into())
5538 }
5539}
5540
5541#[macro_export]
5542macro_rules! assert_set {
5543 ($protocol_config:expr, $($flag:ident),+ $(,)?) => {{
5544 let protocol_config = $protocol_config;
5545 $(
5546 assert!(
5547 protocol_config.$flag(),
5548 "protocol config flag `{}` must be set",
5549 stringify!($flag),
5550 );
5551 )+
5552 }};
5553}
5554
5555#[macro_export]
5556macro_rules! check_limit {
5557 ($x:expr, $hard:expr) => {
5558 check_limit!($x, $hard, $hard)
5559 };
5560 ($x:expr, $soft:expr, $hard:expr) => {
5561 check_limit_in_range($x as u64, $soft, $hard)
5562 };
5563}
5564
5565#[macro_export]
5569macro_rules! check_limit_by_meter {
5570 ($is_metered:expr, $x:expr, $metered_limit:expr, $unmetered_hard_limit:expr, $metric:expr) => {{
5571 let (h, metered_str) = if $is_metered {
5573 ($metered_limit, "metered")
5574 } else {
5575 ($unmetered_hard_limit, "unmetered")
5577 };
5578 use sui_protocol_config::check_limit_in_range;
5579 let result = check_limit_in_range($x as u64, $metered_limit, h);
5580 match result {
5581 LimitThresholdCrossed::None => {}
5582 LimitThresholdCrossed::Soft(_, _) => {
5583 $metric.with_label_values(&[metered_str, "soft"]).inc();
5584 }
5585 LimitThresholdCrossed::Hard(_, _) => {
5586 $metric.with_label_values(&[metered_str, "hard"]).inc();
5587 }
5588 };
5589 result
5590 }};
5591}
5592
5593pub type Amendments = BTreeMap<AccountAddress, BTreeMap<AccountAddress, AccountAddress>>;
5596
5597static MAINNET_LINKAGE_AMENDMENTS: LazyLock<Arc<Amendments>> =
5598 LazyLock::new(|| parse_amendments(include_str!("mainnet_amendments.json")));
5599
5600static TESTNET_LINKAGE_AMENDMENTS: LazyLock<Arc<Amendments>> =
5601 LazyLock::new(|| parse_amendments(include_str!("testnet_amendments.json")));
5602
5603fn parse_amendments(json: &str) -> Arc<Amendments> {
5604 #[derive(serde::Deserialize)]
5605 struct AmendmentEntry {
5606 root: String,
5607 deps: Vec<DepEntry>,
5608 }
5609
5610 #[derive(serde::Deserialize)]
5611 struct DepEntry {
5612 original_id: String,
5613 version_id: String,
5614 }
5615
5616 let entries: Vec<AmendmentEntry> =
5617 serde_json::from_str(json).expect("Failed to parse amendments JSON");
5618 let mut amendments = BTreeMap::new();
5619 for entry in entries {
5620 let root_id = AccountAddress::from_hex_literal(&entry.root).unwrap();
5621 let mut dep_ids = BTreeMap::new();
5622 for dep in entry.deps {
5623 let orig_id = AccountAddress::from_hex_literal(&dep.original_id).unwrap();
5624 let upgraded_id = AccountAddress::from_hex_literal(&dep.version_id).unwrap();
5625 assert!(
5626 dep_ids.insert(orig_id, upgraded_id).is_none(),
5627 "Duplicate original ID in amendments table"
5628 );
5629 }
5630 assert!(
5631 amendments.insert(root_id, dep_ids).is_none(),
5632 "Duplicate root ID in amendments table"
5633 );
5634 }
5635 Arc::new(amendments)
5636}
5637
5638#[cfg(all(test, not(msim)))]
5639mod test {
5640 use insta::assert_yaml_snapshot;
5641
5642 use super::*;
5643
5644 #[test]
5645 fn snapshot_tests() {
5646 println!("\n============================================================================");
5647 println!("! !");
5648 println!("! IMPORTANT: never update snapshots from this test. only add new versions! !");
5649 println!("! !");
5650 println!("============================================================================\n");
5651 for chain_id in &[Chain::Unknown, Chain::Mainnet, Chain::Testnet] {
5652 let chain_str = match chain_id {
5656 Chain::Unknown => "".to_string(),
5657 _ => format!("{:?}_", chain_id),
5658 };
5659 for i in MIN_PROTOCOL_VERSION..=MAX_PROTOCOL_VERSION {
5660 let cur = ProtocolVersion::new(i);
5661 assert_yaml_snapshot!(
5662 format!("{}version_{}", chain_str, cur.as_u64()),
5663 ProtocolConfig::get_for_version(cur, *chain_id)
5664 );
5665 }
5666 }
5667 }
5668
5669 #[test]
5670 fn binary_format_limits_profile_matches_protocol_version() {
5671 let v141 = ProtocolConfig::get_for_version(ProtocolVersion::new(141), Chain::Unknown);
5672 assert_eq!(
5673 v141.binary_format_limits(),
5674 BinaryFormatLimitsProfile::LEGACY.limits()
5675 );
5676
5677 let v142 = ProtocolConfig::get_for_version(ProtocolVersion::new(142), Chain::Unknown);
5678 assert_eq!(
5679 v142.binary_format_limits(),
5680 BinaryFormatLimitsProfile::V1.limits()
5681 );
5682 }
5683
5684 #[test]
5685 fn test_getters() {
5686 let prot: ProtocolConfig =
5687 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5688 assert_eq!(
5689 prot.max_arguments(),
5690 prot.max_arguments_as_option().unwrap()
5691 );
5692 }
5693
5694 #[test]
5695 fn vector_bulk_native_gas_costs_start_at_version_140() {
5696 for chain in [Chain::Unknown, Chain::Mainnet, Chain::Testnet] {
5697 let before = ProtocolConfig::get_for_version(ProtocolVersion::new(139), chain);
5698 assert_eq!(before.vector_reverse_base_cost_as_option(), None);
5699 assert_eq!(before.vector_reverse_per_elem_cost_as_option(), None);
5700 assert_eq!(before.vector_keep_range_base_cost_as_option(), None);
5701 assert_eq!(
5702 before.vector_keep_range_per_dropped_elem_cost_as_option(),
5703 None
5704 );
5705 assert_eq!(
5706 before.vector_keep_range_per_moved_elem_cost_as_option(),
5707 None
5708 );
5709 assert_eq!(before.vector_copy_range_base_cost_as_option(), None);
5710 assert_eq!(before.vector_replace_range_base_cost_as_option(), None);
5711 assert_eq!(before.vector_replace_range_per_elem_cost_as_option(), None);
5712
5713 let active = ProtocolConfig::get_for_version(ProtocolVersion::new(140), chain);
5714 assert_eq!(active.vector_reverse_base_cost_as_option(), Some(52));
5715 assert_eq!(active.vector_reverse_per_elem_cost_as_option(), Some(8));
5716 assert_eq!(active.vector_keep_range_base_cost_as_option(), Some(52));
5717 assert_eq!(
5718 active.vector_keep_range_per_dropped_elem_cost_as_option(),
5719 Some(1)
5720 );
5721 assert_eq!(
5722 active.vector_keep_range_per_moved_elem_cost_as_option(),
5723 Some(8)
5724 );
5725 assert_eq!(active.vector_copy_range_base_cost_as_option(), Some(52));
5726 assert_eq!(active.vector_replace_range_base_cost_as_option(), Some(52));
5727 assert_eq!(
5728 active.vector_replace_range_per_elem_cost_as_option(),
5729 Some(8)
5730 );
5731 }
5732 }
5733
5734 #[test]
5735 fn test_setters() {
5736 let mut prot: ProtocolConfig =
5737 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5738 prot.set_max_arguments_for_testing(123);
5739 assert_eq!(prot.max_arguments(), 123);
5740
5741 prot.set_max_arguments_from_str_for_testing("321".to_string());
5742 assert_eq!(prot.max_arguments(), 321);
5743
5744 prot.disable_max_arguments_for_testing();
5745 assert_eq!(prot.max_arguments_as_option(), None);
5746
5747 prot.set_attr_for_testing("max_arguments".to_string(), "456".to_string());
5748 assert_eq!(prot.max_arguments(), 456);
5749 }
5750
5751 #[test]
5752 fn test_execution_version_setter_allows_upgrade() {
5753 let mut prot = ProtocolConfig::get_for_max_version_UNSAFE();
5754 let current = prot.execution_version();
5755 prot.set_execution_version_for_testing(current);
5756 prot.set_execution_version_for_testing(current + 1);
5757 assert_eq!(prot.execution_version(), current + 1);
5758 }
5759
5760 #[test]
5761 #[should_panic(expected = "cannot downgrade execution_version")]
5762 fn test_execution_version_setter_panics_on_downgrade() {
5763 let mut prot = ProtocolConfig::get_for_max_version_UNSAFE();
5764 let current = prot.execution_version();
5765 prot.set_execution_version_for_testing(current - 1);
5766 }
5767
5768 #[test]
5769 fn test_feature_flag_setter_by_string() {
5770 let mut prot: ProtocolConfig =
5771 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5772 assert!(!prot.zklogin_auth());
5773 prot.set_feature_flag_for_testing("zklogin_auth".to_string(), true);
5774 assert!(prot.zklogin_auth());
5775 prot.set_feature_flag_for_testing("zklogin_auth".to_string(), false);
5776 assert!(!prot.zklogin_auth());
5777 }
5778
5779 #[test]
5780 #[should_panic(expected = "unknown feature flag")]
5781 fn test_feature_flag_setter_unknown_flag() {
5782 let mut prot: ProtocolConfig =
5783 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5784 prot.set_feature_flag_for_testing("some random string".to_string(), true);
5785 }
5786
5787 #[test]
5788 fn test_get_for_version_if_supported_applies_test_overrides() {
5789 let before =
5790 ProtocolConfig::get_for_version_if_supported(ProtocolVersion::new(1), Chain::Unknown)
5791 .unwrap();
5792
5793 assert!(!before.enable_coin_reservation_obj_refs());
5794
5795 let _guard = ProtocolConfig::apply_overrides_for_testing(|_, mut cfg| {
5796 cfg.enable_coin_reservation_for_testing();
5797 cfg
5798 });
5799
5800 let after =
5801 ProtocolConfig::get_for_version_if_supported(ProtocolVersion::new(1), Chain::Unknown)
5802 .unwrap();
5803
5804 assert!(after.enable_coin_reservation_obj_refs());
5805 }
5806
5807 #[test]
5808 #[should_panic(expected = "unsupported version")]
5809 fn max_version_test() {
5810 let _ = ProtocolConfig::get_for_version_impl(
5813 ProtocolVersion::new(MAX_PROTOCOL_VERSION + 1),
5814 Chain::Unknown,
5815 );
5816 }
5817
5818 #[test]
5819 fn lookup_by_string_test() {
5820 let prot: ProtocolConfig =
5821 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5822 assert!(prot.lookup_attr("some random string".to_string()).is_none());
5824
5825 assert!(
5826 prot.lookup_attr("max_arguments".to_string())
5827 == Some(ProtocolConfigValue::u32(prot.max_arguments())),
5828 );
5829
5830 assert!(
5832 prot.lookup_attr("max_move_identifier_len".to_string())
5833 .is_none()
5834 );
5835
5836 let prot: ProtocolConfig =
5838 ProtocolConfig::get_for_version(ProtocolVersion::new(9), Chain::Unknown);
5839 assert!(
5840 prot.lookup_attr("max_move_identifier_len".to_string())
5841 == Some(ProtocolConfigValue::u64(prot.max_move_identifier_len()))
5842 );
5843
5844 let prot: ProtocolConfig =
5845 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5846 assert!(
5848 prot.attr_map()
5849 .get("max_move_identifier_len")
5850 .unwrap()
5851 .is_none()
5852 );
5853 assert!(
5855 prot.attr_map().get("max_arguments").unwrap()
5856 == &Some(ProtocolConfigValue::u32(prot.max_arguments()))
5857 );
5858
5859 let prot: ProtocolConfig =
5861 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5862 assert!(
5864 prot.feature_flags
5865 .lookup_attr("some random string".to_owned())
5866 .is_none()
5867 );
5868 assert!(
5869 !prot
5870 .feature_flags
5871 .attr_map()
5872 .contains_key("some random string")
5873 );
5874
5875 assert!(
5877 prot.feature_flags
5878 .lookup_attr("package_upgrades".to_owned())
5879 == Some(false)
5880 );
5881 assert!(
5882 prot.feature_flags
5883 .attr_map()
5884 .get("package_upgrades")
5885 .unwrap()
5886 == &false
5887 );
5888 let prot: ProtocolConfig =
5889 ProtocolConfig::get_for_version(ProtocolVersion::new(4), Chain::Unknown);
5890 assert!(
5892 prot.feature_flags
5893 .lookup_attr("package_upgrades".to_owned())
5894 == Some(true)
5895 );
5896 assert!(
5897 prot.feature_flags
5898 .attr_map()
5899 .get("package_upgrades")
5900 .unwrap()
5901 == &true
5902 );
5903 }
5904
5905 #[test]
5906 fn limit_range_fn_test() {
5907 let low = 100u32;
5908 let high = 10000u64;
5909
5910 assert!(check_limit!(1u8, low, high) == LimitThresholdCrossed::None);
5911 assert!(matches!(
5912 check_limit!(255u16, low, high),
5913 LimitThresholdCrossed::Soft(255u128, 100)
5914 ));
5915 assert!(matches!(
5921 check_limit!(2550000u64, low, high),
5922 LimitThresholdCrossed::Hard(2550000, 10000)
5923 ));
5924
5925 assert!(matches!(
5926 check_limit!(2550000u64, high, high),
5927 LimitThresholdCrossed::Hard(2550000, 10000)
5928 ));
5929
5930 assert!(matches!(
5931 check_limit!(1u8, high),
5932 LimitThresholdCrossed::None
5933 ));
5934
5935 assert!(check_limit!(255u16, high) == LimitThresholdCrossed::None);
5936
5937 assert!(matches!(
5938 check_limit!(2550000u64, high),
5939 LimitThresholdCrossed::Hard(2550000, 10000)
5940 ));
5941 }
5942
5943 #[test]
5944 fn linkage_amendments_load() {
5945 let mainnet = LazyLock::force(&MAINNET_LINKAGE_AMENDMENTS);
5946 let testnet = LazyLock::force(&TESTNET_LINKAGE_AMENDMENTS);
5947 assert!(!mainnet.is_empty(), "mainnet amendments must not be empty");
5948 assert!(!testnet.is_empty(), "testnet amendments must not be empty");
5949 }
5950
5951 #[test]
5952 fn render_scalar_fields_use_precision_safe_encoding() {
5953 use mysten_common::rpc_format::Unmetered;
5954
5955 let config = ProtocolConfig::get_for_max_version_UNSAFE();
5956 let rendered = config
5957 .render::<serde_json::Value>(&mut Unmetered)
5958 .expect("render should succeed");
5959
5960 let max_args = rendered
5961 .get("max_arguments")
5962 .expect("max_arguments set at max version");
5963 assert!(
5964 max_args.is_number(),
5965 "u32 should render as number, got {max_args:?}",
5966 );
5967
5968 let max_tx_size = rendered
5969 .get("max_tx_size_bytes")
5970 .expect("max_tx_size_bytes set at max version");
5971 assert!(
5972 max_tx_size.is_string(),
5973 "u64 should render as string, got {max_tx_size:?}",
5974 );
5975 }
5976
5977 #[test]
5978 fn render_includes_non_scalar_gasless_allowlist_as_json() {
5979 use mysten_common::rpc_format::Unmetered;
5980 use serde_json::json;
5981
5982 let mut config = ProtocolConfig::get_for_max_version_UNSAFE();
5983 config.set_gasless_allowed_token_types_for_testing(vec![
5984 ("0xa::usdc::USDC".to_string(), 10_000),
5985 ("0xb::usdt::USDT".to_string(), 0),
5986 ]);
5987
5988 let rendered = config
5989 .render::<serde_json::Value>(&mut Unmetered)
5990 .expect("render should succeed under Unmetered budget");
5991 let allowlist = rendered
5992 .get("gasless_allowed_token_types")
5993 .expect("entry should be present after the testing setter");
5994
5995 assert_eq!(
5998 allowlist,
5999 &json!([["0xa::usdc::USDC", "10000"], ["0xb::usdt::USDT", "0"],]),
6000 );
6001 }
6002
6003 #[test]
6004 fn render_targets_prost_value_for_grpc() {
6005 use mysten_common::rpc_format::Unmetered;
6006 use prost_types::value::Kind;
6007
6008 let mut config = ProtocolConfig::get_for_max_version_UNSAFE();
6009 config.set_gasless_allowed_token_types_for_testing(vec![(
6010 "0xa::usdc::USDC".to_string(),
6011 10_000,
6012 )]);
6013
6014 let rendered = config
6015 .render::<prost_types::Value>(&mut Unmetered)
6016 .expect("render to prost Value should succeed");
6017 let allowlist = rendered
6018 .get("gasless_allowed_token_types")
6019 .expect("entry should be present after the testing setter");
6020
6021 let Some(Kind::ListValue(outer)) = &allowlist.kind else {
6023 panic!(
6024 "expected ListValue at the top level, got {:?}",
6025 allowlist.kind
6026 );
6027 };
6028 assert_eq!(outer.values.len(), 1, "one allowlisted entry");
6029 let Some(Kind::ListValue(entry)) = &outer.values[0].kind else {
6030 panic!("expected each entry to be a ListValue");
6031 };
6032 assert_eq!(entry.values.len(), 2, "entry has (coin_type, amount)");
6033
6034 let Some(Kind::StringValue(coin_type)) = &entry.values[0].kind else {
6035 panic!("expected coin_type as StringValue");
6036 };
6037 assert_eq!(coin_type, "0xa::usdc::USDC");
6038
6039 let Some(Kind::StringValue(amount)) = &entry.values[1].kind else {
6041 panic!(
6042 "expected minimum_transfer_amount as StringValue (precision-safe u64); got {:?}",
6043 entry.values[1].kind,
6044 );
6045 };
6046 assert_eq!(amount, "10000");
6047 }
6048
6049 #[test]
6050 fn render_emits_null_for_unset_protocol_versions() {
6051 use mysten_common::rpc_format::Unmetered;
6052
6053 let config = ProtocolConfig::get_for_version(1.into(), Chain::Unknown);
6054 let rendered = config
6055 .render::<serde_json::Value>(&mut Unmetered)
6056 .expect("render should succeed");
6057 let entry = rendered
6061 .get("gasless_allowed_token_types")
6062 .expect("key should be present for every protocol version");
6063 assert!(
6064 entry.is_null(),
6065 "value should be null for pre-feature protocol version, got {entry:?}",
6066 );
6067 }
6068}