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 max_freeze_list_address_reads: Option<u64>,
1817
1818 object_runtime_max_num_store_entries: Option<u64>,
1820
1821 object_runtime_max_num_store_entries_system_tx: Option<u64>,
1823
1824 base_tx_cost_fixed: Option<u64>,
1827
1828 package_publish_cost_fixed: Option<u64>,
1831
1832 base_tx_cost_per_byte: Option<u64>,
1835
1836 package_publish_cost_per_byte: Option<u64>,
1838
1839 package_publish_charge_fixed: Option<u64>,
1841
1842 package_publish_charge_per_module: Option<u64>,
1844
1845 package_publish_charge_per_dependency: Option<u64>,
1847
1848 obj_access_cost_read_per_byte: Option<u64>,
1850
1851 obj_access_cost_read_per_package_kb: Option<u64>,
1854
1855 obj_access_cost_mutate_per_byte: Option<u64>,
1857
1858 obj_access_cost_delete_per_byte: Option<u64>,
1860
1861 obj_access_cost_verify_per_byte: Option<u64>,
1871
1872 max_type_to_layout_nodes: Option<u64>,
1874
1875 max_ptb_value_size: Option<u64>,
1877
1878 gas_model_version: Option<u64>,
1881
1882 obj_data_cost_refundable: Option<u64>,
1885
1886 obj_metadata_cost_non_refundable: Option<u64>,
1890
1891 storage_rebate_rate: Option<u64>,
1897
1898 storage_fund_reinvest_rate: Option<u64>,
1901
1902 reward_slashing_rate: Option<u64>,
1905
1906 storage_gas_price: Option<u64>,
1908
1909 accumulator_object_storage_cost: Option<u64>,
1911
1912 max_transactions_per_checkpoint: Option<u64>,
1917
1918 max_checkpoint_size_bytes: Option<u64>,
1922
1923 buffer_stake_for_protocol_upgrade_bps: Option<u64>,
1928
1929 address_from_bytes_cost_base: Option<u64>,
1934 address_to_u256_cost_base: Option<u64>,
1936 address_from_u256_cost_base: Option<u64>,
1938
1939 config_read_setting_impl_cost_base: Option<u64>,
1944 config_read_setting_impl_cost_per_byte: Option<u64>,
1945
1946 package_original_package_id_impl_cost_base: Option<u64>,
1947 package_original_package_id_impl_cost_per_byte: Option<u64>,
1948
1949 dynamic_field_hash_type_and_key_cost_base: Option<u64>,
1952 dynamic_field_hash_type_and_key_type_cost_per_byte: Option<u64>,
1953 dynamic_field_hash_type_and_key_value_cost_per_byte: Option<u64>,
1954 dynamic_field_hash_type_and_key_type_tag_cost_per_byte: Option<u64>,
1955 dynamic_field_add_child_object_cost_base: Option<u64>,
1957 dynamic_field_add_child_object_type_cost_per_byte: Option<u64>,
1958 dynamic_field_add_child_object_value_cost_per_byte: Option<u64>,
1959 dynamic_field_add_child_object_struct_tag_cost_per_byte: Option<u64>,
1960 dynamic_field_borrow_child_object_cost_base: Option<u64>,
1962 dynamic_field_borrow_child_object_child_ref_cost_per_byte: Option<u64>,
1963 dynamic_field_borrow_child_object_type_cost_per_byte: Option<u64>,
1964 dynamic_field_remove_child_object_cost_base: Option<u64>,
1966 dynamic_field_remove_child_object_child_cost_per_byte: Option<u64>,
1967 dynamic_field_remove_child_object_type_cost_per_byte: Option<u64>,
1968 dynamic_field_has_child_object_cost_base: Option<u64>,
1970 dynamic_field_has_child_object_with_ty_cost_base: Option<u64>,
1972 dynamic_field_has_child_object_with_ty_type_cost_per_byte: Option<u64>,
1973 dynamic_field_has_child_object_with_ty_type_tag_cost_per_byte: Option<u64>,
1974
1975 scratch_add_cost_base: Option<u64>,
1978 scratch_read_cost_base: Option<u64>,
1980 scratch_read_value_cost: Option<u64>,
1981 scratch_remove_cost_base: Option<u64>,
1983 scratch_exists_cost_base: Option<u64>,
1985 scratch_exists_with_type_cost_base: Option<u64>,
1987 scratch_exists_with_type_type_cost: Option<u64>,
1988 max_scratch_pad_size: Option<u64>,
1990
1991 event_emit_cost_base: Option<u64>,
1994 event_emit_value_size_derivation_cost_per_byte: Option<u64>,
1995 event_emit_tag_size_derivation_cost_per_byte: Option<u64>,
1996 event_emit_output_cost_per_byte: Option<u64>,
1997 event_emit_auth_stream_cost: Option<u64>,
1998
1999 reserve_object_funds_for_withdrawal_cost_base: Option<u64>,
2002 reserve_object_funds_for_withdrawal_cold_read_cost: Option<u64>,
2004
2005 object_borrow_uid_cost_base: Option<u64>,
2008 object_delete_impl_cost_base: Option<u64>,
2010 object_record_new_uid_cost_base: Option<u64>,
2012 object_record_new_uid_from_hash_cost_base: Option<u64>,
2015 object_is_shared_input_cost_base: Option<u64>,
2017
2018 transfer_transfer_internal_cost_base: Option<u64>,
2021 transfer_party_transfer_internal_cost_base: Option<u64>,
2023 transfer_freeze_object_cost_base: Option<u64>,
2025 transfer_share_object_cost_base: Option<u64>,
2027 transfer_receive_object_cost_base: Option<u64>,
2030 transfer_receive_object_cost_per_byte: Option<u64>,
2031 transfer_receive_object_type_cost_per_byte: Option<u64>,
2032
2033 tx_context_derive_id_cost_base: Option<u64>,
2036 tx_context_fresh_id_cost_base: Option<u64>,
2037 tx_context_sender_cost_base: Option<u64>,
2038 tx_context_epoch_cost_base: Option<u64>,
2039 tx_context_epoch_timestamp_ms_cost_base: Option<u64>,
2040 tx_context_sponsor_cost_base: Option<u64>,
2041 tx_context_rgp_cost_base: Option<u64>,
2042 tx_context_gas_price_cost_base: Option<u64>,
2043 tx_context_gas_budget_cost_base: Option<u64>,
2044 tx_context_ids_created_cost_base: Option<u64>,
2045 tx_context_replace_cost_base: Option<u64>,
2046
2047 clock_borrow_cost_base: Option<u64>,
2050
2051 types_is_one_time_witness_cost_base: Option<u64>,
2054 types_is_one_time_witness_type_tag_cost_per_byte: Option<u64>,
2055 types_is_one_time_witness_type_cost_per_byte: Option<u64>,
2056
2057 validator_validate_metadata_cost_base: Option<u64>,
2060 validator_validate_metadata_data_cost_per_byte: Option<u64>,
2061
2062 crypto_invalid_arguments_cost: Option<u64>,
2064 bls12381_bls12381_min_sig_verify_cost_base: Option<u64>,
2066 bls12381_bls12381_min_sig_verify_msg_cost_per_byte: Option<u64>,
2067 bls12381_bls12381_min_sig_verify_msg_cost_per_block: Option<u64>,
2068
2069 bls12381_bls12381_min_pk_verify_cost_base: Option<u64>,
2071 bls12381_bls12381_min_pk_verify_msg_cost_per_byte: Option<u64>,
2072 bls12381_bls12381_min_pk_verify_msg_cost_per_block: Option<u64>,
2073
2074 ecdsa_k1_ecrecover_keccak256_cost_base: Option<u64>,
2076 ecdsa_k1_ecrecover_keccak256_msg_cost_per_byte: Option<u64>,
2077 ecdsa_k1_ecrecover_keccak256_msg_cost_per_block: Option<u64>,
2078 ecdsa_k1_ecrecover_sha256_cost_base: Option<u64>,
2079 ecdsa_k1_ecrecover_sha256_msg_cost_per_byte: Option<u64>,
2080 ecdsa_k1_ecrecover_sha256_msg_cost_per_block: Option<u64>,
2081
2082 ecdsa_k1_decompress_pubkey_cost_base: Option<u64>,
2084
2085 ecdsa_k1_secp256k1_verify_keccak256_cost_base: Option<u64>,
2087 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_byte: Option<u64>,
2088 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_block: Option<u64>,
2089 ecdsa_k1_secp256k1_verify_sha256_cost_base: Option<u64>,
2090 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_byte: Option<u64>,
2091 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_block: Option<u64>,
2092
2093 ecdsa_r1_ecrecover_keccak256_cost_base: Option<u64>,
2095 ecdsa_r1_ecrecover_keccak256_msg_cost_per_byte: Option<u64>,
2096 ecdsa_r1_ecrecover_keccak256_msg_cost_per_block: Option<u64>,
2097 ecdsa_r1_ecrecover_sha256_cost_base: Option<u64>,
2098 ecdsa_r1_ecrecover_sha256_msg_cost_per_byte: Option<u64>,
2099 ecdsa_r1_ecrecover_sha256_msg_cost_per_block: Option<u64>,
2100
2101 ecdsa_r1_secp256r1_verify_keccak256_cost_base: Option<u64>,
2103 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_byte: Option<u64>,
2104 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_block: Option<u64>,
2105 ecdsa_r1_secp256r1_verify_sha256_cost_base: Option<u64>,
2106 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_byte: Option<u64>,
2107 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_block: Option<u64>,
2108
2109 ecvrf_ecvrf_verify_cost_base: Option<u64>,
2111 ecvrf_ecvrf_verify_alpha_string_cost_per_byte: Option<u64>,
2112 ecvrf_ecvrf_verify_alpha_string_cost_per_block: Option<u64>,
2113
2114 ed25519_ed25519_verify_cost_base: Option<u64>,
2116 ed25519_ed25519_verify_msg_cost_per_byte: Option<u64>,
2117 ed25519_ed25519_verify_msg_cost_per_block: Option<u64>,
2118
2119 groth16_prepare_verifying_key_bls12381_cost_base: Option<u64>,
2121 groth16_prepare_verifying_key_bn254_cost_base: Option<u64>,
2122
2123 groth16_verify_groth16_proof_internal_bls12381_cost_base: Option<u64>,
2125 groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input: Option<u64>,
2126 groth16_verify_groth16_proof_internal_bn254_cost_base: Option<u64>,
2127 groth16_verify_groth16_proof_internal_bn254_cost_per_public_input: Option<u64>,
2128 groth16_verify_groth16_proof_internal_public_input_cost_per_byte: Option<u64>,
2129
2130 hash_blake2b256_cost_base: Option<u64>,
2132 hash_blake2b256_data_cost_per_byte: Option<u64>,
2133 hash_blake2b256_data_cost_per_block: Option<u64>,
2134
2135 hash_keccak256_cost_base: Option<u64>,
2137 hash_keccak256_data_cost_per_byte: Option<u64>,
2138 hash_keccak256_data_cost_per_block: Option<u64>,
2139
2140 poseidon_bn254_cost_base: Option<u64>,
2142 poseidon_bn254_cost_per_block: Option<u64>,
2143
2144 group_ops_bls12381_decode_scalar_cost: Option<u64>,
2146 group_ops_bls12381_decode_g1_cost: Option<u64>,
2147 group_ops_bls12381_decode_g2_cost: Option<u64>,
2148 group_ops_bls12381_decode_gt_cost: Option<u64>,
2149 group_ops_bls12381_scalar_add_cost: Option<u64>,
2150 group_ops_bls12381_g1_add_cost: Option<u64>,
2151 group_ops_bls12381_g2_add_cost: Option<u64>,
2152 group_ops_bls12381_gt_add_cost: Option<u64>,
2153 group_ops_bls12381_scalar_sub_cost: Option<u64>,
2154 group_ops_bls12381_g1_sub_cost: Option<u64>,
2155 group_ops_bls12381_g2_sub_cost: Option<u64>,
2156 group_ops_bls12381_gt_sub_cost: Option<u64>,
2157 group_ops_bls12381_scalar_mul_cost: Option<u64>,
2158 group_ops_bls12381_g1_mul_cost: Option<u64>,
2159 group_ops_bls12381_g2_mul_cost: Option<u64>,
2160 group_ops_bls12381_gt_mul_cost: Option<u64>,
2161 group_ops_bls12381_scalar_div_cost: Option<u64>,
2162 group_ops_bls12381_g1_div_cost: Option<u64>,
2163 group_ops_bls12381_g2_div_cost: Option<u64>,
2164 group_ops_bls12381_gt_div_cost: Option<u64>,
2165 group_ops_bls12381_g1_hash_to_base_cost: Option<u64>,
2166 group_ops_bls12381_g2_hash_to_base_cost: Option<u64>,
2167 group_ops_bls12381_g1_hash_to_cost_per_byte: Option<u64>,
2168 group_ops_bls12381_g2_hash_to_cost_per_byte: Option<u64>,
2169 group_ops_bls12381_g1_msm_base_cost: Option<u64>,
2170 group_ops_bls12381_g2_msm_base_cost: Option<u64>,
2171 group_ops_bls12381_g1_msm_base_cost_per_input: Option<u64>,
2172 group_ops_bls12381_g2_msm_base_cost_per_input: Option<u64>,
2173 group_ops_bls12381_msm_max_len: Option<u32>,
2174 group_ops_bls12381_pairing_cost: Option<u64>,
2175 group_ops_bls12381_g1_to_uncompressed_g1_cost: Option<u64>,
2176 group_ops_bls12381_uncompressed_g1_to_g1_cost: Option<u64>,
2177 group_ops_bls12381_uncompressed_g1_sum_base_cost: Option<u64>,
2178 group_ops_bls12381_uncompressed_g1_sum_cost_per_term: Option<u64>,
2179 group_ops_bls12381_uncompressed_g1_sum_max_terms: Option<u64>,
2180
2181 group_ops_ristretto_decode_scalar_cost: Option<u64>,
2182 group_ops_ristretto_decode_point_cost: Option<u64>,
2183 group_ops_ristretto_scalar_add_cost: Option<u64>,
2184 group_ops_ristretto_point_add_cost: Option<u64>,
2185 group_ops_ristretto_scalar_sub_cost: Option<u64>,
2186 group_ops_ristretto_point_sub_cost: Option<u64>,
2187 group_ops_ristretto_scalar_mul_cost: Option<u64>,
2188 group_ops_ristretto_point_mul_cost: Option<u64>,
2189 group_ops_ristretto_scalar_div_cost: Option<u64>,
2190 group_ops_ristretto_point_div_cost: Option<u64>,
2191
2192 verify_bulletproofs_ristretto255_base_cost: Option<u64>,
2193 verify_bulletproofs_ristretto255_cost_per_bit_and_commitment: Option<u64>,
2194 max_bulletproofs_total_bits: Option<u64>,
2197
2198 hmac_hmac_sha3_256_cost_base: Option<u64>,
2200 hmac_hmac_sha3_256_input_cost_per_byte: Option<u64>,
2201 hmac_hmac_sha3_256_input_cost_per_block: Option<u64>,
2202
2203 check_zklogin_id_cost_base: Option<u64>,
2205 check_zklogin_issuer_cost_base: Option<u64>,
2207
2208 vdf_verify_vdf_cost: Option<u64>,
2209 vdf_hash_to_input_cost: Option<u64>,
2210
2211 nitro_attestation_parse_base_cost: Option<u64>,
2213 nitro_attestation_parse_cost_per_byte: Option<u64>,
2214 nitro_attestation_verify_base_cost: Option<u64>,
2215 nitro_attestation_verify_cost_per_cert: Option<u64>,
2216
2217 layout_node_cost: Option<u64>,
2219 layout_node_cost_large_layout_threshold: Option<u64>,
2221
2222 bcs_per_input_abstract_unit_cost: Option<u64>,
2224 bcs_per_byte_serialized_cost: Option<u64>,
2225 bcs_legacy_min_output_size_cost: Option<u64>,
2226 bcs_failure_cost: Option<u64>,
2227
2228 hash_sha2_256_base_cost: Option<u64>,
2229 hash_sha2_256_per_byte_cost: Option<u64>,
2230 hash_sha2_256_legacy_min_input_len_cost: Option<u64>,
2231 hash_sha3_256_base_cost: Option<u64>,
2232 hash_sha3_256_per_byte_cost: Option<u64>,
2233 hash_sha3_256_legacy_min_input_len_cost: Option<u64>,
2234 type_name_get_base_cost: Option<u64>,
2235 type_name_get_per_byte_cost: Option<u64>,
2236 type_name_id_base_cost: Option<u64>,
2237
2238 string_check_utf8_base_cost: Option<u64>,
2239 string_check_utf8_per_byte_cost: Option<u64>,
2240 string_is_char_boundary_base_cost: Option<u64>,
2241 string_sub_string_base_cost: Option<u64>,
2242 string_sub_string_per_byte_cost: Option<u64>,
2243 string_index_of_base_cost: Option<u64>,
2244 string_index_of_per_byte_pattern_cost: Option<u64>,
2245 string_index_of_per_byte_searched_cost: Option<u64>,
2246
2247 vector_empty_base_cost: Option<u64>,
2248 vector_length_base_cost: Option<u64>,
2249 vector_push_back_base_cost: Option<u64>,
2250 vector_push_back_legacy_per_abstract_memory_unit_cost: Option<u64>,
2251 vector_borrow_base_cost: Option<u64>,
2252 vector_pop_back_base_cost: Option<u64>,
2253 vector_destroy_empty_base_cost: Option<u64>,
2254 vector_swap_base_cost: Option<u64>,
2255 vector_reverse_base_cost: Option<u64>,
2256 vector_reverse_per_elem_cost: Option<u64>,
2257 vector_keep_range_base_cost: Option<u64>,
2258 vector_keep_range_per_dropped_elem_cost: Option<u64>,
2259 vector_keep_range_per_moved_elem_cost: Option<u64>,
2260 vector_copy_range_base_cost: Option<u64>,
2261 vector_copy_range_per_abstract_memory_unit_cost: Option<u64>,
2262 vector_replace_range_base_cost: Option<u64>,
2263 vector_replace_range_per_elem_cost: Option<u64>,
2264 debug_print_base_cost: Option<u64>,
2265 debug_print_stack_trace_base_cost: Option<u64>,
2266
2267 #[custom_setter]
2277 execution_version: Option<u64>,
2278
2279 consensus_bad_nodes_stake_threshold: Option<u64>,
2283
2284 max_jwk_votes_per_validator_per_epoch: Option<u64>,
2285 max_age_of_jwk_in_epochs: Option<u64>,
2289
2290 random_beacon_reduction_allowed_delta: Option<u16>,
2294
2295 random_beacon_reduction_lower_bound: Option<u32>,
2298
2299 random_beacon_dkg_timeout_round: Option<u32>,
2302
2303 random_beacon_min_round_interval_ms: Option<u64>,
2305
2306 random_beacon_dkg_version: Option<u64>,
2309
2310 consensus_max_transaction_size_bytes: Option<u64>,
2313 consensus_max_transactions_in_block_bytes: Option<u64>,
2315 consensus_max_num_transactions_in_block: Option<u64>,
2317
2318 consensus_voting_rounds: Option<u32>,
2320
2321 max_accumulated_txn_cost_per_object_in_narwhal_commit: Option<u64>,
2323
2324 max_deferral_rounds_for_congestion_control: Option<u64>,
2327
2328 epoch_close_deadline_ms: Option<u64>,
2333
2334 max_txn_cost_overage_per_object_in_commit: Option<u64>,
2336
2337 allowed_txn_cost_overage_burst_per_object_in_commit: Option<u64>,
2339
2340 min_checkpoint_interval_ms: Option<u64>,
2342
2343 checkpoint_summary_version_specific_data: Option<u64>,
2345
2346 max_soft_bundle_size: Option<u64>,
2348
2349 bridge_should_try_to_finalize_committee: Option<bool>,
2353
2354 max_accumulated_txn_cost_per_object_in_mysticeti_commit: Option<u64>,
2360
2361 max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit: Option<u64>,
2364
2365 consensus_gc_depth: Option<u32>,
2368
2369 gas_budget_based_txn_cost_cap_factor: Option<u64>,
2371
2372 gas_budget_based_txn_cost_absolute_cap_commit_count: Option<u64>,
2374
2375 sip_45_consensus_amplification_threshold: Option<u64>,
2378
2379 staggered_submission_signal_window_commits: Option<u64>,
2382 staggered_submission_signal_min_excess_copies_per_commit: Option<u64>,
2387 staggered_submission_signal_min_consensus_user_transactions_per_commit: Option<u64>,
2393 staggered_submission_signal_exit_dwell_commits: Option<u64>,
2398 staggered_submission_signal_band1_enter_ratio_bps: Option<u64>,
2401 staggered_submission_signal_band1_exit_ratio_bps: Option<u64>,
2402 staggered_submission_signal_band2_enter_ratio_bps: Option<u64>,
2403 staggered_submission_signal_band2_exit_ratio_bps: Option<u64>,
2404
2405 use_object_per_epoch_marker_table_v2: Option<bool>,
2408
2409 consensus_commit_rate_estimation_window_size: Option<u32>,
2411
2412 #[serde(skip_serializing_if = "Vec::is_empty")]
2416 aliased_addresses: Vec<AliasedAddress>,
2417
2418 translation_per_command_base_charge: Option<u64>,
2421
2422 translation_per_input_base_charge: Option<u64>,
2425
2426 translation_pure_input_per_byte_charge: Option<u64>,
2428
2429 translation_per_type_node_charge: Option<u64>,
2433
2434 translation_per_reference_node_charge: Option<u64>,
2437
2438 translation_per_linkage_entry_charge: Option<u64>,
2441
2442 max_updates_per_settlement_txn: Option<u32>,
2444
2445 gasless_max_computation_units: Option<u64>,
2447
2448 gasless_allowed_token_types: Option<Vec<(String, u64)>>,
2450
2451 gasless_max_unused_inputs: Option<u64>,
2455
2456 gasless_max_pure_input_bytes: Option<u64>,
2459
2460 gasless_max_tps: Option<u64>,
2462
2463 #[serde(skip_serializing_if = "Option::is_none")]
2464 #[skip_accessor]
2465 include_special_package_amendments: Option<Arc<Amendments>>,
2466
2467 gasless_max_tx_size_bytes: Option<u64>,
2470
2471 translation_per_live_reference_charge: Option<u64>,
2474
2475 max_ptb_live_references: Option<u64>,
2478
2479 max_ptb_returned_references: Option<u64>,
2482
2483 max_ptb_total_returned_references: Option<u64>,
2486}
2487
2488#[derive(Clone, Serialize, Deserialize, Debug)]
2490pub struct AliasedAddress {
2491 pub original: [u8; 32],
2493 pub aliased: [u8; 32],
2495 pub allowed_tx_digests: Vec<[u8; 32]>,
2497}
2498
2499impl ProtocolConfig {
2501 pub fn chain(&self) -> Chain {
2503 self.chain
2504 }
2505
2506 pub fn check_package_upgrades_supported(&self) -> Result<(), Error> {
2519 if self.feature_flags.package_upgrades {
2520 Ok(())
2521 } else {
2522 Err(Error(format!(
2523 "package upgrades are not supported at {:?}",
2524 self.version
2525 )))
2526 }
2527 }
2528
2529 pub fn zklogin_supported_providers(&self) -> &BTreeSet<String> {
2530 &self.feature_flags.zklogin_supported_providers
2531 }
2532
2533 pub fn zklogin_circuit_mode(&self) -> u64 {
2536 self.feature_flags.zklogin_circuit_mode
2537 }
2538
2539 pub fn consensus_transaction_ordering(&self) -> ConsensusTransactionOrdering {
2540 self.feature_flags.consensus_transaction_ordering
2541 }
2542
2543 pub fn enable_jwk_consensus_updates(&self) -> bool {
2544 let ret = self.feature_flags.enable_jwk_consensus_updates;
2545 if ret {
2546 assert!(self.feature_flags.end_of_epoch_transaction_supported);
2548 }
2549 ret
2550 }
2551
2552 pub fn staggered_submission_signal(&self) -> bool {
2553 let ret = self.feature_flags.staggered_submission_signal;
2554 if ret {
2555 assert!(self.feature_flags.allowed_proposers);
2558 }
2559 ret
2560 }
2561
2562 pub fn end_of_epoch_transaction_supported(&self) -> bool {
2563 let ret = self.feature_flags.end_of_epoch_transaction_supported;
2564 if !ret {
2565 assert!(!self.feature_flags.enable_jwk_consensus_updates);
2567 }
2568 ret
2569 }
2570
2571 pub fn dkg_version(&self) -> u64 {
2572 self.random_beacon_dkg_version.unwrap_or(1)
2574 }
2575
2576 pub fn bridge(&self) -> bool {
2577 let ret = self.feature_flags.bridge;
2578 if ret {
2579 assert!(self.feature_flags.end_of_epoch_transaction_supported);
2581 }
2582 ret
2583 }
2584
2585 pub fn should_try_to_finalize_bridge_committee(&self) -> bool {
2586 if !self.bridge() {
2587 return false;
2588 }
2589 self.bridge_should_try_to_finalize_committee.unwrap_or(true)
2591 }
2592
2593 pub fn zklogin_max_epoch_upper_bound_delta(&self) -> Option<u64> {
2594 self.feature_flags.zklogin_max_epoch_upper_bound_delta
2595 }
2596
2597 pub fn enable_allowances(&self) -> bool {
2598 self.feature_flags.enable_allowances && self.enable_accumulators()
2599 }
2600
2601 pub fn enable_coin_reservation_obj_refs(&self) -> bool {
2602 self.new_vm_enabled() && self.feature_flags.enable_coin_reservation_obj_refs
2603 }
2604
2605 pub fn enable_authenticated_event_streams(&self) -> bool {
2606 self.feature_flags.enable_authenticated_event_streams && self.enable_accumulators()
2607 }
2608
2609 pub fn per_object_congestion_control_mode(&self) -> PerObjectCongestionControlMode {
2610 self.feature_flags.per_object_congestion_control_mode
2611 }
2612
2613 pub fn consensus_choice(&self) -> ConsensusChoice {
2614 self.feature_flags.consensus_choice
2615 }
2616
2617 pub fn consensus_network(&self) -> ConsensusNetwork {
2618 self.feature_flags.consensus_network
2619 }
2620
2621 pub fn mysticeti_num_leaders_per_round(&self) -> Option<usize> {
2622 self.feature_flags.mysticeti_num_leaders_per_round
2623 }
2624
2625 pub fn max_transaction_size_bytes(&self) -> u64 {
2626 self.consensus_max_transaction_size_bytes
2628 .unwrap_or(256 * 1024)
2629 }
2630
2631 pub fn max_transactions_in_block_bytes(&self) -> u64 {
2632 if cfg!(msim) {
2633 256 * 1024
2634 } else {
2635 self.consensus_max_transactions_in_block_bytes
2636 .unwrap_or(512 * 1024)
2637 }
2638 }
2639
2640 pub fn max_num_transactions_in_block(&self) -> u64 {
2641 if cfg!(msim) {
2642 8
2643 } else {
2644 self.consensus_max_num_transactions_in_block.unwrap_or(512)
2645 }
2646 }
2647
2648 pub fn gc_depth(&self) -> u32 {
2649 self.consensus_gc_depth.unwrap_or(0)
2650 }
2651
2652 pub fn consensus_linearize_subdag_v2(&self) -> bool {
2653 let res = self.feature_flags.consensus_linearize_subdag_v2;
2654 assert!(
2655 !res || self.gc_depth() > 0,
2656 "The consensus linearize sub dag V2 requires GC to be enabled"
2657 );
2658 res
2659 }
2660
2661 pub fn consensus_median_based_commit_timestamp(&self) -> bool {
2662 let res = self.feature_flags.consensus_median_based_commit_timestamp;
2663 assert!(
2664 !res || self.gc_depth() > 0,
2665 "The consensus median based commit timestamp requires GC to be enabled"
2666 );
2667 res
2668 }
2669
2670 pub fn get_consensus_commit_rate_estimation_window_size(&self) -> u32 {
2671 self.consensus_commit_rate_estimation_window_size
2672 .unwrap_or(0)
2673 }
2674
2675 pub fn consensus_num_requested_prior_commits_at_startup(&self) -> u32 {
2676 let window_size = self.get_consensus_commit_rate_estimation_window_size();
2680 assert!(window_size == 0 || self.record_additional_state_digest_in_prologue());
2682 window_size
2683 }
2684
2685 pub fn address_aliases(&self) -> bool {
2686 let address_aliases = self.feature_flags.address_aliases;
2687 assert!(
2688 !address_aliases || self.mysticeti_fastpath(),
2689 "Address aliases requires Mysticeti fastpath to be enabled"
2690 );
2691 if address_aliases {
2692 assert!(
2693 self.feature_flags.disable_preconsensus_locking,
2694 "Address aliases requires CertifiedTransaction to be disabled"
2695 );
2696 }
2697 address_aliases
2698 }
2699
2700 pub fn new_vm_enabled(&self) -> bool {
2701 self.execution_version.is_some_and(|v| v >= 4)
2702 }
2703
2704 pub fn gasless_allowed_token_types(&self) -> &[(String, u64)] {
2705 debug_assert!(self.gasless_allowed_token_types.is_some());
2706 self.gasless_allowed_token_types.as_deref().unwrap_or(&[])
2707 }
2708
2709 pub fn get_gasless_max_unused_inputs(&self) -> u64 {
2710 self.gasless_max_unused_inputs.unwrap_or(u64::MAX)
2711 }
2712
2713 pub fn get_gasless_max_pure_input_bytes(&self) -> u64 {
2714 self.gasless_max_pure_input_bytes.unwrap_or(u64::MAX)
2715 }
2716
2717 pub fn get_gasless_max_tx_size_bytes(&self) -> u64 {
2718 self.gasless_max_tx_size_bytes.unwrap_or(u64::MAX)
2719 }
2720
2721 pub fn include_special_package_amendments_as_option(&self) -> &Option<Arc<Amendments>> {
2722 &self.include_special_package_amendments
2723 }
2724}
2725
2726static POISON_VERSION_METHODS: AtomicBool = AtomicBool::new(false);
2727
2728impl ProtocolConfig {
2730 pub fn get_for_version(version: ProtocolVersion, chain: Chain) -> Self {
2732 assert!(
2734 version >= ProtocolVersion::MIN,
2735 "Network protocol version is {:?}, but the minimum supported version by the binary is {:?}. Please upgrade the binary.",
2736 version,
2737 ProtocolVersion::MIN.0,
2738 );
2739 assert!(
2740 version <= ProtocolVersion::MAX_ALLOWED,
2741 "Network protocol version is {:?}, but the maximum supported version by the binary is {:?}. Please upgrade the binary.",
2742 version,
2743 ProtocolVersion::MAX_ALLOWED.0,
2744 );
2745
2746 let mut ret = Self::get_for_version_impl(version, chain);
2747 ret.version = version;
2748 ret.chain = chain;
2749
2750 ret = Self::apply_config_override(version, ret);
2751
2752 if std::env::var("SUI_PROTOCOL_CONFIG_OVERRIDE_ENABLE").is_ok() {
2753 warn!(
2754 "overriding ProtocolConfig settings with custom settings; this may break non-local networks"
2755 );
2756 let overrides: ProtocolConfigOptional =
2757 serde_env::from_env_with_prefix("SUI_PROTOCOL_CONFIG_OVERRIDE")
2758 .expect("failed to parse ProtocolConfig override env variables");
2759 overrides.apply_to(&mut ret);
2760 }
2761
2762 ret
2763 }
2764
2765 pub fn get_for_version_if_supported(version: ProtocolVersion, chain: Chain) -> Option<Self> {
2768 if version.0 >= ProtocolVersion::MIN.0 && version.0 <= ProtocolVersion::MAX_ALLOWED.0 {
2769 let mut ret = Self::get_for_version_impl(version, chain);
2770 ret.version = version;
2771 ret.chain = chain;
2772 ret = Self::apply_config_override(version, ret);
2773 Some(ret)
2774 } else {
2775 None
2776 }
2777 }
2778
2779 pub fn poison_get_for_min_version() {
2780 POISON_VERSION_METHODS.store(true, Ordering::Relaxed);
2781 }
2782
2783 fn load_poison_get_for_min_version() -> bool {
2784 POISON_VERSION_METHODS.load(Ordering::Relaxed)
2785 }
2786
2787 pub fn get_for_min_version() -> Self {
2790 if Self::load_poison_get_for_min_version() {
2791 panic!("get_for_min_version called on validator");
2792 }
2793 ProtocolConfig::get_for_version(ProtocolVersion::MIN, Chain::Unknown)
2794 }
2795
2796 #[allow(non_snake_case)]
2806 pub fn get_for_max_version_UNSAFE() -> Self {
2807 if Self::load_poison_get_for_min_version() {
2808 panic!("get_for_max_version_UNSAFE called on validator");
2809 }
2810 ProtocolConfig::get_for_version(ProtocolVersion::MAX, Chain::Unknown)
2811 }
2812
2813 fn get_for_version_impl(version: ProtocolVersion, chain: Chain) -> Self {
2814 #[cfg(msim)]
2815 {
2816 if version == ProtocolVersion::MAX_ALLOWED {
2818 let mut config = Self::get_for_version_impl(version - 1, Chain::Unknown);
2819 config.base_tx_cost_fixed = Some(config.base_tx_cost_fixed() + 1000);
2820 return config;
2821 }
2822 }
2823
2824 let mut cfg = Self {
2827 version,
2829 chain,
2830
2831 feature_flags: Default::default(),
2833
2834 max_tx_size_bytes: Some(128 * 1024),
2835 max_input_objects: Some(2048),
2837 max_serialized_tx_effects_size_bytes: Some(512 * 1024),
2838 max_serialized_tx_effects_size_bytes_system_tx: Some(512 * 1024 * 16),
2839 max_gas_payment_objects: Some(256),
2840 max_modules_in_publish: Some(128),
2841 max_package_dependencies: None,
2842 max_arguments: Some(512),
2843 max_type_arguments: Some(16),
2844 max_type_argument_depth: Some(16),
2845 max_pure_argument_size: Some(16 * 1024),
2846 max_programmable_tx_commands: Some(1024),
2847 move_binary_format_version: Some(6),
2848 min_move_binary_format_version: None,
2849 binary_module_handles: None,
2850 binary_struct_handles: None,
2851 binary_function_handles: None,
2852 binary_function_instantiations: None,
2853 binary_signatures: None,
2854 binary_constant_pool: None,
2855 binary_identifiers: None,
2856 binary_address_identifiers: None,
2857 binary_struct_defs: None,
2858 binary_struct_def_instantiations: None,
2859 binary_function_defs: None,
2860 binary_field_handles: None,
2861 binary_field_instantiations: None,
2862 binary_friend_decls: None,
2863 binary_enum_defs: None,
2864 binary_enum_def_instantiations: None,
2865 binary_variant_handles: None,
2866 binary_variant_instantiation_handles: None,
2867 binary_format_limits_profile: None,
2868 max_move_object_size: Some(250 * 1024),
2869 max_move_package_size: Some(100 * 1024),
2870 max_publish_or_upgrade_per_ptb: None,
2871 max_tx_gas: Some(10_000_000_000),
2872 max_gas_price: Some(100_000),
2873 max_gas_price_rgp_factor_for_aborted_transactions: None,
2874 max_gas_computation_bucket: Some(5_000_000),
2875 max_loop_depth: Some(5),
2876 max_generic_instantiation_length: Some(32),
2877 max_function_parameters: Some(128),
2878 max_basic_blocks: Some(1024),
2879 max_value_stack_size: Some(1024),
2880 max_type_nodes: Some(256),
2881 max_generic_instantiation_type_nodes_per_function: None,
2882 max_generic_instantiation_type_nodes_per_module: None,
2883 max_accumulator_type_nodes: None,
2884 max_push_size: Some(10000),
2885 max_struct_definitions: Some(200),
2886 max_function_definitions: Some(1000),
2887 max_fields_in_struct: Some(32),
2888 max_dependency_depth: Some(100),
2889 max_num_event_emit: Some(256),
2890 max_num_accumulator_events: None,
2891 max_num_new_move_object_ids: Some(2048),
2892 max_num_new_move_object_ids_system_tx: Some(2048 * 16),
2893 max_num_deleted_move_object_ids: Some(2048),
2894 max_num_deleted_move_object_ids_system_tx: Some(2048 * 16),
2895 max_num_transferred_move_object_ids: Some(2048),
2896 max_num_transferred_move_object_ids_system_tx: Some(2048 * 16),
2897 max_event_emit_size: Some(250 * 1024),
2898 max_move_vector_len: Some(256 * 1024),
2899 max_type_to_layout_nodes: None,
2900 max_ptb_value_size: None,
2901
2902 max_back_edges_per_function: Some(10_000),
2903 max_back_edges_per_module: Some(10_000),
2904 max_verifier_meter_ticks_per_function: Some(6_000_000),
2905 max_meter_ticks_per_module: Some(6_000_000),
2906 max_meter_ticks_per_package: None,
2907
2908 object_runtime_max_num_cached_objects: Some(1000),
2909 object_runtime_max_num_cached_objects_system_tx: Some(1000 * 16),
2910 object_runtime_max_loaded_child_value_size: None,
2911 max_freeze_list_address_reads: None,
2912 object_runtime_max_num_store_entries: Some(1000),
2913 object_runtime_max_num_store_entries_system_tx: Some(1000 * 16),
2914 base_tx_cost_fixed: Some(110_000),
2915 package_publish_cost_fixed: Some(1_000),
2916 base_tx_cost_per_byte: Some(0),
2917 package_publish_cost_per_byte: Some(80),
2918 package_publish_charge_fixed: None,
2919 package_publish_charge_per_module: None,
2920 package_publish_charge_per_dependency: None,
2921 obj_access_cost_read_per_byte: Some(15),
2922 obj_access_cost_read_per_package_kb: None,
2923 obj_access_cost_mutate_per_byte: Some(40),
2924 obj_access_cost_delete_per_byte: Some(40),
2925 obj_access_cost_verify_per_byte: Some(200),
2926 obj_data_cost_refundable: Some(100),
2927 obj_metadata_cost_non_refundable: Some(50),
2928 gas_model_version: Some(1),
2929 storage_rebate_rate: Some(9900),
2930 storage_fund_reinvest_rate: Some(500),
2931 reward_slashing_rate: Some(5000),
2932 storage_gas_price: Some(1),
2933 accumulator_object_storage_cost: None,
2934 max_transactions_per_checkpoint: Some(10_000),
2935 max_checkpoint_size_bytes: Some(30 * 1024 * 1024),
2936
2937 buffer_stake_for_protocol_upgrade_bps: Some(0),
2940
2941 address_from_bytes_cost_base: Some(52),
2945 address_to_u256_cost_base: Some(52),
2947 address_from_u256_cost_base: Some(52),
2949
2950 config_read_setting_impl_cost_base: None,
2953 config_read_setting_impl_cost_per_byte: None,
2954
2955 package_original_package_id_impl_cost_base: None,
2956 package_original_package_id_impl_cost_per_byte: None,
2957
2958 dynamic_field_hash_type_and_key_cost_base: Some(100),
2961 dynamic_field_hash_type_and_key_type_cost_per_byte: Some(2),
2962 dynamic_field_hash_type_and_key_value_cost_per_byte: Some(2),
2963 dynamic_field_hash_type_and_key_type_tag_cost_per_byte: Some(2),
2964 dynamic_field_add_child_object_cost_base: Some(100),
2966 dynamic_field_add_child_object_type_cost_per_byte: Some(10),
2967 dynamic_field_add_child_object_value_cost_per_byte: Some(10),
2968 dynamic_field_add_child_object_struct_tag_cost_per_byte: Some(10),
2969 dynamic_field_borrow_child_object_cost_base: Some(100),
2971 dynamic_field_borrow_child_object_child_ref_cost_per_byte: Some(10),
2972 dynamic_field_borrow_child_object_type_cost_per_byte: Some(10),
2973 dynamic_field_remove_child_object_cost_base: Some(100),
2975 dynamic_field_remove_child_object_child_cost_per_byte: Some(2),
2976 dynamic_field_remove_child_object_type_cost_per_byte: Some(2),
2977 dynamic_field_has_child_object_cost_base: Some(100),
2979 dynamic_field_has_child_object_with_ty_cost_base: Some(100),
2981 dynamic_field_has_child_object_with_ty_type_cost_per_byte: Some(2),
2982 dynamic_field_has_child_object_with_ty_type_tag_cost_per_byte: Some(2),
2983
2984 scratch_add_cost_base: None,
2986 scratch_read_cost_base: None,
2987 scratch_read_value_cost: None,
2988 scratch_remove_cost_base: None,
2989 scratch_exists_cost_base: None,
2990 scratch_exists_with_type_cost_base: None,
2991 scratch_exists_with_type_type_cost: None,
2992 max_scratch_pad_size: None,
2993
2994 event_emit_cost_base: Some(52),
2997 event_emit_value_size_derivation_cost_per_byte: Some(2),
2998 event_emit_tag_size_derivation_cost_per_byte: Some(5),
2999 event_emit_output_cost_per_byte: Some(10),
3000 event_emit_auth_stream_cost: None,
3001
3002 reserve_object_funds_for_withdrawal_cost_base: None,
3004 reserve_object_funds_for_withdrawal_cold_read_cost: None,
3005
3006 object_borrow_uid_cost_base: Some(52),
3009 object_delete_impl_cost_base: Some(52),
3011 object_record_new_uid_cost_base: Some(52),
3013 object_record_new_uid_from_hash_cost_base: None,
3016 object_is_shared_input_cost_base: None,
3019
3020 transfer_transfer_internal_cost_base: Some(52),
3023 transfer_party_transfer_internal_cost_base: None,
3025 transfer_freeze_object_cost_base: Some(52),
3027 transfer_share_object_cost_base: Some(52),
3029 transfer_receive_object_cost_base: None,
3030 transfer_receive_object_type_cost_per_byte: None,
3031 transfer_receive_object_cost_per_byte: None,
3032
3033 tx_context_derive_id_cost_base: Some(52),
3036 tx_context_fresh_id_cost_base: None,
3037 tx_context_sender_cost_base: None,
3038 tx_context_epoch_cost_base: None,
3039 tx_context_epoch_timestamp_ms_cost_base: None,
3040 tx_context_sponsor_cost_base: None,
3041 tx_context_rgp_cost_base: None,
3042 tx_context_gas_price_cost_base: None,
3043 tx_context_gas_budget_cost_base: None,
3044 tx_context_ids_created_cost_base: None,
3045 tx_context_replace_cost_base: None,
3046
3047 clock_borrow_cost_base: None,
3049
3050 types_is_one_time_witness_cost_base: Some(52),
3053 types_is_one_time_witness_type_tag_cost_per_byte: Some(2),
3054 types_is_one_time_witness_type_cost_per_byte: Some(2),
3055
3056 validator_validate_metadata_cost_base: Some(52),
3059 validator_validate_metadata_data_cost_per_byte: Some(2),
3060
3061 crypto_invalid_arguments_cost: Some(100),
3063 bls12381_bls12381_min_sig_verify_cost_base: Some(52),
3065 bls12381_bls12381_min_sig_verify_msg_cost_per_byte: Some(2),
3066 bls12381_bls12381_min_sig_verify_msg_cost_per_block: Some(2),
3067
3068 bls12381_bls12381_min_pk_verify_cost_base: Some(52),
3070 bls12381_bls12381_min_pk_verify_msg_cost_per_byte: Some(2),
3071 bls12381_bls12381_min_pk_verify_msg_cost_per_block: Some(2),
3072
3073 ecdsa_k1_ecrecover_keccak256_cost_base: Some(52),
3075 ecdsa_k1_ecrecover_keccak256_msg_cost_per_byte: Some(2),
3076 ecdsa_k1_ecrecover_keccak256_msg_cost_per_block: Some(2),
3077 ecdsa_k1_ecrecover_sha256_cost_base: Some(52),
3078 ecdsa_k1_ecrecover_sha256_msg_cost_per_byte: Some(2),
3079 ecdsa_k1_ecrecover_sha256_msg_cost_per_block: Some(2),
3080
3081 ecdsa_k1_decompress_pubkey_cost_base: Some(52),
3083
3084 ecdsa_k1_secp256k1_verify_keccak256_cost_base: Some(52),
3086 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_byte: Some(2),
3087 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_block: Some(2),
3088 ecdsa_k1_secp256k1_verify_sha256_cost_base: Some(52),
3089 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_byte: Some(2),
3090 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_block: Some(2),
3091
3092 ecdsa_r1_ecrecover_keccak256_cost_base: Some(52),
3094 ecdsa_r1_ecrecover_keccak256_msg_cost_per_byte: Some(2),
3095 ecdsa_r1_ecrecover_keccak256_msg_cost_per_block: Some(2),
3096 ecdsa_r1_ecrecover_sha256_cost_base: Some(52),
3097 ecdsa_r1_ecrecover_sha256_msg_cost_per_byte: Some(2),
3098 ecdsa_r1_ecrecover_sha256_msg_cost_per_block: Some(2),
3099
3100 ecdsa_r1_secp256r1_verify_keccak256_cost_base: Some(52),
3102 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_byte: Some(2),
3103 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_block: Some(2),
3104 ecdsa_r1_secp256r1_verify_sha256_cost_base: Some(52),
3105 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_byte: Some(2),
3106 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_block: Some(2),
3107
3108 ecvrf_ecvrf_verify_cost_base: Some(52),
3110 ecvrf_ecvrf_verify_alpha_string_cost_per_byte: Some(2),
3111 ecvrf_ecvrf_verify_alpha_string_cost_per_block: Some(2),
3112
3113 ed25519_ed25519_verify_cost_base: Some(52),
3115 ed25519_ed25519_verify_msg_cost_per_byte: Some(2),
3116 ed25519_ed25519_verify_msg_cost_per_block: Some(2),
3117
3118 groth16_prepare_verifying_key_bls12381_cost_base: Some(52),
3120 groth16_prepare_verifying_key_bn254_cost_base: Some(52),
3121
3122 groth16_verify_groth16_proof_internal_bls12381_cost_base: Some(52),
3124 groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input: Some(2),
3125 groth16_verify_groth16_proof_internal_bn254_cost_base: Some(52),
3126 groth16_verify_groth16_proof_internal_bn254_cost_per_public_input: Some(2),
3127 groth16_verify_groth16_proof_internal_public_input_cost_per_byte: Some(2),
3128
3129 hash_blake2b256_cost_base: Some(52),
3131 hash_blake2b256_data_cost_per_byte: Some(2),
3132 hash_blake2b256_data_cost_per_block: Some(2),
3133
3134 hash_keccak256_cost_base: Some(52),
3136 hash_keccak256_data_cost_per_byte: Some(2),
3137 hash_keccak256_data_cost_per_block: Some(2),
3138
3139 poseidon_bn254_cost_base: None,
3140 poseidon_bn254_cost_per_block: None,
3141
3142 hmac_hmac_sha3_256_cost_base: Some(52),
3144 hmac_hmac_sha3_256_input_cost_per_byte: Some(2),
3145 hmac_hmac_sha3_256_input_cost_per_block: Some(2),
3146
3147 group_ops_bls12381_decode_scalar_cost: None,
3149 group_ops_bls12381_decode_g1_cost: None,
3150 group_ops_bls12381_decode_g2_cost: None,
3151 group_ops_bls12381_decode_gt_cost: None,
3152 group_ops_bls12381_scalar_add_cost: None,
3153 group_ops_bls12381_g1_add_cost: None,
3154 group_ops_bls12381_g2_add_cost: None,
3155 group_ops_bls12381_gt_add_cost: None,
3156 group_ops_bls12381_scalar_sub_cost: None,
3157 group_ops_bls12381_g1_sub_cost: None,
3158 group_ops_bls12381_g2_sub_cost: None,
3159 group_ops_bls12381_gt_sub_cost: None,
3160 group_ops_bls12381_scalar_mul_cost: None,
3161 group_ops_bls12381_g1_mul_cost: None,
3162 group_ops_bls12381_g2_mul_cost: None,
3163 group_ops_bls12381_gt_mul_cost: None,
3164 group_ops_bls12381_scalar_div_cost: None,
3165 group_ops_bls12381_g1_div_cost: None,
3166 group_ops_bls12381_g2_div_cost: None,
3167 group_ops_bls12381_gt_div_cost: None,
3168 group_ops_bls12381_g1_hash_to_base_cost: None,
3169 group_ops_bls12381_g2_hash_to_base_cost: None,
3170 group_ops_bls12381_g1_hash_to_cost_per_byte: None,
3171 group_ops_bls12381_g2_hash_to_cost_per_byte: None,
3172 group_ops_bls12381_g1_msm_base_cost: None,
3173 group_ops_bls12381_g2_msm_base_cost: None,
3174 group_ops_bls12381_g1_msm_base_cost_per_input: None,
3175 group_ops_bls12381_g2_msm_base_cost_per_input: None,
3176 group_ops_bls12381_msm_max_len: None,
3177 group_ops_bls12381_pairing_cost: None,
3178 group_ops_bls12381_g1_to_uncompressed_g1_cost: None,
3179 group_ops_bls12381_uncompressed_g1_to_g1_cost: None,
3180 group_ops_bls12381_uncompressed_g1_sum_base_cost: None,
3181 group_ops_bls12381_uncompressed_g1_sum_cost_per_term: None,
3182 group_ops_bls12381_uncompressed_g1_sum_max_terms: None,
3183
3184 group_ops_ristretto_decode_scalar_cost: None,
3185 group_ops_ristretto_decode_point_cost: None,
3186 group_ops_ristretto_scalar_add_cost: None,
3187 group_ops_ristretto_point_add_cost: None,
3188 group_ops_ristretto_scalar_sub_cost: None,
3189 group_ops_ristretto_point_sub_cost: None,
3190 group_ops_ristretto_scalar_mul_cost: None,
3191 group_ops_ristretto_point_mul_cost: None,
3192 group_ops_ristretto_scalar_div_cost: None,
3193 group_ops_ristretto_point_div_cost: None,
3194
3195 verify_bulletproofs_ristretto255_base_cost: None,
3196 verify_bulletproofs_ristretto255_cost_per_bit_and_commitment: None,
3197 max_bulletproofs_total_bits: None,
3198
3199 check_zklogin_id_cost_base: None,
3201 check_zklogin_issuer_cost_base: None,
3203
3204 vdf_verify_vdf_cost: None,
3205 vdf_hash_to_input_cost: None,
3206
3207 nitro_attestation_parse_base_cost: None,
3209 nitro_attestation_parse_cost_per_byte: None,
3210 nitro_attestation_verify_base_cost: None,
3211 nitro_attestation_verify_cost_per_cert: None,
3212
3213 layout_node_cost: None,
3214 layout_node_cost_large_layout_threshold: None,
3215 bcs_per_input_abstract_unit_cost: None,
3216 bcs_per_byte_serialized_cost: None,
3217 bcs_legacy_min_output_size_cost: None,
3218 bcs_failure_cost: None,
3219 hash_sha2_256_base_cost: None,
3220 hash_sha2_256_per_byte_cost: None,
3221 hash_sha2_256_legacy_min_input_len_cost: None,
3222 hash_sha3_256_base_cost: None,
3223 hash_sha3_256_per_byte_cost: None,
3224 hash_sha3_256_legacy_min_input_len_cost: None,
3225 type_name_get_base_cost: None,
3226 type_name_get_per_byte_cost: None,
3227 type_name_id_base_cost: None,
3228 string_check_utf8_base_cost: None,
3229 string_check_utf8_per_byte_cost: None,
3230 string_is_char_boundary_base_cost: None,
3231 string_sub_string_base_cost: None,
3232 string_sub_string_per_byte_cost: None,
3233 string_index_of_base_cost: None,
3234 string_index_of_per_byte_pattern_cost: None,
3235 string_index_of_per_byte_searched_cost: None,
3236 vector_empty_base_cost: None,
3237 vector_length_base_cost: None,
3238 vector_push_back_base_cost: None,
3239 vector_push_back_legacy_per_abstract_memory_unit_cost: None,
3240 vector_borrow_base_cost: None,
3241 vector_pop_back_base_cost: None,
3242 vector_destroy_empty_base_cost: None,
3243 vector_swap_base_cost: None,
3244 vector_reverse_base_cost: None,
3245 vector_reverse_per_elem_cost: None,
3246 vector_keep_range_base_cost: None,
3247 vector_keep_range_per_dropped_elem_cost: None,
3248 vector_keep_range_per_moved_elem_cost: None,
3249 vector_copy_range_base_cost: None,
3250 vector_copy_range_per_abstract_memory_unit_cost: None,
3251 vector_replace_range_base_cost: None,
3252 vector_replace_range_per_elem_cost: None,
3253 debug_print_base_cost: None,
3254 debug_print_stack_trace_base_cost: None,
3255
3256 max_size_written_objects: None,
3257 max_size_written_objects_system_tx: None,
3258
3259 max_move_identifier_len: None,
3266 max_move_value_depth: None,
3267 package_arena_size_in_bytes: None,
3268 max_move_enum_variants: None,
3269
3270 gas_rounding_step: None,
3271
3272 execution_version: None,
3273
3274 max_event_emit_size_total: None,
3275
3276 consensus_bad_nodes_stake_threshold: None,
3277
3278 max_jwk_votes_per_validator_per_epoch: None,
3279
3280 max_age_of_jwk_in_epochs: None,
3281
3282 random_beacon_reduction_allowed_delta: None,
3283
3284 random_beacon_reduction_lower_bound: None,
3285
3286 random_beacon_dkg_timeout_round: None,
3287
3288 random_beacon_min_round_interval_ms: None,
3289
3290 random_beacon_dkg_version: None,
3291
3292 consensus_max_transaction_size_bytes: None,
3293
3294 consensus_max_transactions_in_block_bytes: None,
3295
3296 consensus_max_num_transactions_in_block: None,
3297
3298 consensus_voting_rounds: None,
3299
3300 max_accumulated_txn_cost_per_object_in_narwhal_commit: None,
3301
3302 max_deferral_rounds_for_congestion_control: None,
3303
3304 epoch_close_deadline_ms: None,
3305
3306 max_txn_cost_overage_per_object_in_commit: None,
3307
3308 allowed_txn_cost_overage_burst_per_object_in_commit: None,
3309
3310 min_checkpoint_interval_ms: None,
3311
3312 checkpoint_summary_version_specific_data: None,
3313
3314 max_soft_bundle_size: None,
3315
3316 bridge_should_try_to_finalize_committee: None,
3317
3318 max_accumulated_txn_cost_per_object_in_mysticeti_commit: None,
3319
3320 max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit: None,
3321
3322 consensus_gc_depth: None,
3323
3324 gas_budget_based_txn_cost_cap_factor: None,
3325
3326 gas_budget_based_txn_cost_absolute_cap_commit_count: None,
3327
3328 sip_45_consensus_amplification_threshold: None,
3329 staggered_submission_signal_window_commits: None,
3330 staggered_submission_signal_min_excess_copies_per_commit: None,
3331 staggered_submission_signal_min_consensus_user_transactions_per_commit: None,
3332 staggered_submission_signal_exit_dwell_commits: None,
3333 staggered_submission_signal_band1_enter_ratio_bps: None,
3334 staggered_submission_signal_band1_exit_ratio_bps: None,
3335 staggered_submission_signal_band2_enter_ratio_bps: None,
3336 staggered_submission_signal_band2_exit_ratio_bps: None,
3337
3338 use_object_per_epoch_marker_table_v2: None,
3339
3340 consensus_commit_rate_estimation_window_size: None,
3341
3342 aliased_addresses: vec![],
3343
3344 translation_per_command_base_charge: None,
3345 translation_per_input_base_charge: None,
3346 translation_pure_input_per_byte_charge: None,
3347 translation_per_type_node_charge: None,
3348 translation_per_reference_node_charge: None,
3349 translation_per_linkage_entry_charge: None,
3350 translation_per_live_reference_charge: None,
3351 max_ptb_live_references: None,
3352 max_ptb_returned_references: None,
3353 max_ptb_total_returned_references: None,
3354
3355 max_updates_per_settlement_txn: None,
3356
3357 gasless_max_computation_units: None,
3358 gasless_allowed_token_types: None,
3359 gasless_max_unused_inputs: None,
3360 gasless_max_pure_input_bytes: None,
3361 gasless_max_tps: None,
3362 include_special_package_amendments: None,
3363 gasless_max_tx_size_bytes: None,
3364 };
3367 for cur in 2..=version.0 {
3368 match cur {
3369 1 => unreachable!(),
3370 2 => {
3371 cfg.feature_flags.advance_epoch_start_time_in_safe_mode = true;
3372 }
3373 3 => {
3374 cfg.gas_model_version = Some(2);
3376 cfg.max_tx_gas = Some(50_000_000_000);
3378 cfg.base_tx_cost_fixed = Some(2_000);
3380 cfg.storage_gas_price = Some(76);
3382 cfg.feature_flags.loaded_child_objects_fixed = true;
3383 cfg.max_size_written_objects = Some(5 * 1000 * 1000);
3386 cfg.max_size_written_objects_system_tx = Some(50 * 1000 * 1000);
3389 cfg.feature_flags.package_upgrades = true;
3390 }
3391 4 => {
3396 cfg.reward_slashing_rate = Some(10000);
3398 cfg.gas_model_version = Some(3);
3400 }
3401 5 => {
3402 cfg.feature_flags.missing_type_is_compatibility_error = true;
3403 cfg.gas_model_version = Some(4);
3404 cfg.feature_flags.scoring_decision_with_validity_cutoff = true;
3405 }
3409 6 => {
3410 cfg.gas_model_version = Some(5);
3411 cfg.buffer_stake_for_protocol_upgrade_bps = Some(5000);
3412 cfg.feature_flags.consensus_order_end_of_epoch_last = true;
3413 }
3414 7 => {
3415 cfg.feature_flags.disallow_adding_abilities_on_upgrade = true;
3416 cfg.feature_flags
3417 .disable_invariant_violation_check_in_swap_loc = true;
3418 cfg.feature_flags.ban_entry_init = true;
3419 cfg.feature_flags.package_digest_hash_module = true;
3420 }
3421 8 => {
3422 cfg.feature_flags
3423 .disallow_change_struct_type_params_on_upgrade = true;
3424 }
3425 9 => {
3426 cfg.max_move_identifier_len = Some(128);
3428 cfg.feature_flags.no_extraneous_module_bytes = true;
3429 cfg.feature_flags
3430 .advance_to_highest_supported_protocol_version = true;
3431 }
3432 10 => {
3433 cfg.max_verifier_meter_ticks_per_function = Some(16_000_000);
3434 cfg.max_meter_ticks_per_module = Some(16_000_000);
3435 }
3436 11 => {
3437 cfg.max_move_value_depth = Some(128);
3438 }
3439 12 => {
3440 cfg.feature_flags.narwhal_versioned_metadata = true;
3441 if chain != Chain::Mainnet {
3442 cfg.feature_flags.commit_root_state_digest = true;
3443 }
3444
3445 if chain != Chain::Mainnet && chain != Chain::Testnet {
3446 cfg.feature_flags.zklogin_auth = true;
3447 }
3448 }
3449 13 => {}
3450 14 => {
3451 cfg.gas_rounding_step = Some(1_000);
3452 cfg.gas_model_version = Some(6);
3453 }
3454 15 => {
3455 cfg.feature_flags.consensus_transaction_ordering =
3456 ConsensusTransactionOrdering::ByGasPrice;
3457 }
3458 16 => {
3459 cfg.feature_flags.simplified_unwrap_then_delete = true;
3460 }
3461 17 => {
3462 cfg.feature_flags.upgraded_multisig_supported = true;
3463 }
3464 18 => {
3465 cfg.execution_version = Some(1);
3466 cfg.feature_flags.txn_base_cost_as_multiplier = true;
3475 cfg.base_tx_cost_fixed = Some(1_000);
3477 }
3478 19 => {
3479 cfg.max_num_event_emit = Some(1024);
3480 cfg.max_event_emit_size_total = Some(
3483 256 * 250 * 1024, );
3485 }
3486 20 => {
3487 cfg.feature_flags.commit_root_state_digest = true;
3488
3489 if chain != Chain::Mainnet {
3490 cfg.feature_flags.narwhal_new_leader_election_schedule = true;
3491 cfg.consensus_bad_nodes_stake_threshold = Some(20);
3492 }
3493 }
3494
3495 21 => {
3496 if chain != Chain::Mainnet {
3497 cfg.feature_flags.zklogin_supported_providers = BTreeSet::from([
3498 "Google".to_string(),
3499 "Facebook".to_string(),
3500 "Twitch".to_string(),
3501 ]);
3502 }
3503 }
3504 22 => {
3505 cfg.feature_flags.loaded_child_object_format = true;
3506 }
3507 23 => {
3508 cfg.feature_flags.loaded_child_object_format_type = true;
3509 cfg.feature_flags.narwhal_new_leader_election_schedule = true;
3510 cfg.consensus_bad_nodes_stake_threshold = Some(20);
3516 }
3517 24 => {
3518 cfg.feature_flags.simple_conservation_checks = true;
3519 cfg.max_publish_or_upgrade_per_ptb = Some(5);
3520
3521 cfg.feature_flags.end_of_epoch_transaction_supported = true;
3522
3523 if chain != Chain::Mainnet {
3524 cfg.feature_flags.enable_jwk_consensus_updates = true;
3525 cfg.max_jwk_votes_per_validator_per_epoch = Some(240);
3527 cfg.max_age_of_jwk_in_epochs = Some(1);
3528 }
3529 }
3530 25 => {
3531 cfg.feature_flags.zklogin_supported_providers = BTreeSet::from([
3533 "Google".to_string(),
3534 "Facebook".to_string(),
3535 "Twitch".to_string(),
3536 ]);
3537 cfg.feature_flags.zklogin_auth = true;
3538
3539 cfg.feature_flags.enable_jwk_consensus_updates = true;
3541 cfg.max_jwk_votes_per_validator_per_epoch = Some(240);
3542 cfg.max_age_of_jwk_in_epochs = Some(1);
3543 }
3544 26 => {
3545 cfg.gas_model_version = Some(7);
3546 if chain != Chain::Mainnet && chain != Chain::Testnet {
3548 cfg.transfer_receive_object_cost_base = Some(52);
3549 cfg.feature_flags.receive_objects = true;
3550 }
3551 }
3552 27 => {
3553 cfg.gas_model_version = Some(8);
3554 }
3555 28 => {
3556 cfg.check_zklogin_id_cost_base = Some(200);
3558 cfg.check_zklogin_issuer_cost_base = Some(200);
3560
3561 if chain != Chain::Mainnet && chain != Chain::Testnet {
3563 cfg.feature_flags.enable_effects_v2 = true;
3564 }
3565 }
3566 29 => {
3567 cfg.feature_flags.verify_legacy_zklogin_address = true;
3568 }
3569 30 => {
3570 if chain != Chain::Mainnet {
3572 cfg.feature_flags.narwhal_certificate_v2 = true;
3573 }
3574
3575 cfg.random_beacon_reduction_allowed_delta = Some(800);
3576 if chain != Chain::Mainnet {
3578 cfg.feature_flags.enable_effects_v2 = true;
3579 }
3580
3581 cfg.feature_flags.zklogin_supported_providers = BTreeSet::default();
3585
3586 cfg.feature_flags.recompute_has_public_transfer_in_execution = true;
3587 }
3588 31 => {
3589 cfg.execution_version = Some(2);
3590 if chain != Chain::Mainnet && chain != Chain::Testnet {
3592 cfg.feature_flags.shared_object_deletion = true;
3593 }
3594 }
3595 32 => {
3596 if chain != Chain::Mainnet {
3598 cfg.feature_flags.accept_zklogin_in_multisig = true;
3599 }
3600 if chain != Chain::Mainnet {
3602 cfg.transfer_receive_object_cost_base = Some(52);
3603 cfg.feature_flags.receive_objects = true;
3604 }
3605 if chain != Chain::Mainnet && chain != Chain::Testnet {
3607 cfg.feature_flags.random_beacon = true;
3608 cfg.random_beacon_reduction_lower_bound = Some(1600);
3609 cfg.random_beacon_dkg_timeout_round = Some(3000);
3610 cfg.random_beacon_min_round_interval_ms = Some(150);
3611 }
3612 if chain != Chain::Testnet && chain != Chain::Mainnet {
3614 cfg.feature_flags.include_consensus_digest_in_prologue = true;
3615 }
3616
3617 cfg.feature_flags.narwhal_certificate_v2 = true;
3619 }
3620 33 => {
3621 cfg.feature_flags.hardened_otw_check = true;
3622 cfg.feature_flags.allow_receiving_object_id = true;
3623
3624 cfg.transfer_receive_object_cost_base = Some(52);
3626 cfg.feature_flags.receive_objects = true;
3627
3628 if chain != Chain::Mainnet {
3630 cfg.feature_flags.shared_object_deletion = true;
3631 }
3632
3633 cfg.feature_flags.enable_effects_v2 = true;
3634 }
3635 34 => {}
3636 35 => {
3637 if chain != Chain::Mainnet && chain != Chain::Testnet {
3639 cfg.feature_flags.enable_poseidon = true;
3640 cfg.poseidon_bn254_cost_base = Some(260);
3641 cfg.poseidon_bn254_cost_per_block = Some(10);
3642 }
3643
3644 cfg.feature_flags.enable_coin_deny_list = true;
3645 }
3646 36 => {
3647 if chain != Chain::Mainnet && chain != Chain::Testnet {
3649 cfg.feature_flags.enable_group_ops_native_functions = true;
3650 cfg.feature_flags.enable_group_ops_native_function_msm = true;
3651 cfg.group_ops_bls12381_decode_scalar_cost = Some(52);
3653 cfg.group_ops_bls12381_decode_g1_cost = Some(52);
3654 cfg.group_ops_bls12381_decode_g2_cost = Some(52);
3655 cfg.group_ops_bls12381_decode_gt_cost = Some(52);
3656 cfg.group_ops_bls12381_scalar_add_cost = Some(52);
3657 cfg.group_ops_bls12381_g1_add_cost = Some(52);
3658 cfg.group_ops_bls12381_g2_add_cost = Some(52);
3659 cfg.group_ops_bls12381_gt_add_cost = Some(52);
3660 cfg.group_ops_bls12381_scalar_sub_cost = Some(52);
3661 cfg.group_ops_bls12381_g1_sub_cost = Some(52);
3662 cfg.group_ops_bls12381_g2_sub_cost = Some(52);
3663 cfg.group_ops_bls12381_gt_sub_cost = Some(52);
3664 cfg.group_ops_bls12381_scalar_mul_cost = Some(52);
3665 cfg.group_ops_bls12381_g1_mul_cost = Some(52);
3666 cfg.group_ops_bls12381_g2_mul_cost = Some(52);
3667 cfg.group_ops_bls12381_gt_mul_cost = Some(52);
3668 cfg.group_ops_bls12381_scalar_div_cost = Some(52);
3669 cfg.group_ops_bls12381_g1_div_cost = Some(52);
3670 cfg.group_ops_bls12381_g2_div_cost = Some(52);
3671 cfg.group_ops_bls12381_gt_div_cost = Some(52);
3672 cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(52);
3673 cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(52);
3674 cfg.group_ops_bls12381_g1_hash_to_cost_per_byte = Some(2);
3675 cfg.group_ops_bls12381_g2_hash_to_cost_per_byte = Some(2);
3676 cfg.group_ops_bls12381_g1_msm_base_cost = Some(52);
3677 cfg.group_ops_bls12381_g2_msm_base_cost = Some(52);
3678 cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(52);
3679 cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(52);
3680 cfg.group_ops_bls12381_msm_max_len = Some(32);
3681 cfg.group_ops_bls12381_pairing_cost = Some(52);
3682 }
3683 cfg.feature_flags.shared_object_deletion = true;
3685
3686 cfg.consensus_max_transaction_size_bytes = Some(256 * 1024); cfg.consensus_max_transactions_in_block_bytes = Some(6 * 1_024 * 1024);
3688 }
3690 37 => {
3691 cfg.feature_flags.reject_mutable_random_on_entry_functions = true;
3692
3693 if chain != Chain::Mainnet {
3695 cfg.feature_flags.include_consensus_digest_in_prologue = true;
3696 }
3697 }
3698 38 => {
3699 cfg.binary_module_handles = Some(100);
3700 cfg.binary_struct_handles = Some(300);
3701 cfg.binary_function_handles = Some(1500);
3702 cfg.binary_function_instantiations = Some(750);
3703 cfg.binary_signatures = Some(1000);
3704 cfg.binary_constant_pool = Some(4000);
3708 cfg.binary_identifiers = Some(10000);
3709 cfg.binary_address_identifiers = Some(100);
3710 cfg.binary_struct_defs = Some(200);
3711 cfg.binary_struct_def_instantiations = Some(100);
3712 cfg.binary_function_defs = Some(1000);
3713 cfg.binary_field_handles = Some(500);
3714 cfg.binary_field_instantiations = Some(250);
3715 cfg.binary_friend_decls = Some(100);
3716 cfg.max_package_dependencies = Some(32);
3718 cfg.max_modules_in_publish = Some(64);
3719 cfg.execution_version = Some(3);
3721 }
3722 39 => {
3723 }
3725 40 => {}
3726 41 => {
3727 cfg.feature_flags.enable_group_ops_native_functions = true;
3729 cfg.group_ops_bls12381_decode_scalar_cost = Some(52);
3731 cfg.group_ops_bls12381_decode_g1_cost = Some(52);
3732 cfg.group_ops_bls12381_decode_g2_cost = Some(52);
3733 cfg.group_ops_bls12381_decode_gt_cost = Some(52);
3734 cfg.group_ops_bls12381_scalar_add_cost = Some(52);
3735 cfg.group_ops_bls12381_g1_add_cost = Some(52);
3736 cfg.group_ops_bls12381_g2_add_cost = Some(52);
3737 cfg.group_ops_bls12381_gt_add_cost = Some(52);
3738 cfg.group_ops_bls12381_scalar_sub_cost = Some(52);
3739 cfg.group_ops_bls12381_g1_sub_cost = Some(52);
3740 cfg.group_ops_bls12381_g2_sub_cost = Some(52);
3741 cfg.group_ops_bls12381_gt_sub_cost = Some(52);
3742 cfg.group_ops_bls12381_scalar_mul_cost = Some(52);
3743 cfg.group_ops_bls12381_g1_mul_cost = Some(52);
3744 cfg.group_ops_bls12381_g2_mul_cost = Some(52);
3745 cfg.group_ops_bls12381_gt_mul_cost = Some(52);
3746 cfg.group_ops_bls12381_scalar_div_cost = Some(52);
3747 cfg.group_ops_bls12381_g1_div_cost = Some(52);
3748 cfg.group_ops_bls12381_g2_div_cost = Some(52);
3749 cfg.group_ops_bls12381_gt_div_cost = Some(52);
3750 cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(52);
3751 cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(52);
3752 cfg.group_ops_bls12381_g1_hash_to_cost_per_byte = Some(2);
3753 cfg.group_ops_bls12381_g2_hash_to_cost_per_byte = Some(2);
3754 cfg.group_ops_bls12381_g1_msm_base_cost = Some(52);
3755 cfg.group_ops_bls12381_g2_msm_base_cost = Some(52);
3756 cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(52);
3757 cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(52);
3758 cfg.group_ops_bls12381_msm_max_len = Some(32);
3759 cfg.group_ops_bls12381_pairing_cost = Some(52);
3760 }
3761 42 => {}
3762 43 => {
3763 cfg.feature_flags.zklogin_max_epoch_upper_bound_delta = Some(30);
3764 cfg.max_meter_ticks_per_package = Some(16_000_000);
3765 }
3766 44 => {
3767 cfg.feature_flags.include_consensus_digest_in_prologue = true;
3769 if chain != Chain::Mainnet {
3771 cfg.feature_flags.consensus_choice = ConsensusChoice::SwapEachEpoch;
3772 }
3773 }
3774 45 => {
3775 if chain != Chain::Testnet && chain != Chain::Mainnet {
3777 cfg.feature_flags.consensus_network = ConsensusNetwork::Tonic;
3778 }
3779
3780 if chain != Chain::Mainnet {
3781 cfg.feature_flags.mysticeti_leader_scoring_and_schedule = true;
3783 }
3784 cfg.min_move_binary_format_version = Some(6);
3785 cfg.feature_flags.accept_zklogin_in_multisig = true;
3786
3787 if chain != Chain::Mainnet && chain != Chain::Testnet {
3791 cfg.feature_flags.bridge = true;
3792 }
3793 }
3794 46 => {
3795 if chain != Chain::Mainnet {
3797 cfg.feature_flags.bridge = true;
3798 }
3799
3800 cfg.feature_flags.reshare_at_same_initial_version = true;
3802 }
3803 47 => {}
3804 48 => {
3805 cfg.feature_flags.consensus_network = ConsensusNetwork::Tonic;
3807
3808 cfg.feature_flags.resolve_abort_locations_to_package_id = true;
3810
3811 if chain != Chain::Mainnet {
3813 cfg.feature_flags.random_beacon = true;
3814 cfg.random_beacon_reduction_lower_bound = Some(1600);
3815 cfg.random_beacon_dkg_timeout_round = Some(3000);
3816 cfg.random_beacon_min_round_interval_ms = Some(200);
3817 }
3818
3819 cfg.feature_flags.mysticeti_use_committed_subdag_digest = true;
3821 }
3822 49 => {
3823 if chain != Chain::Testnet && chain != Chain::Mainnet {
3824 cfg.move_binary_format_version = Some(7);
3825 }
3826
3827 if chain != Chain::Mainnet && chain != Chain::Testnet {
3829 cfg.feature_flags.enable_vdf = true;
3830 cfg.vdf_verify_vdf_cost = Some(1500);
3833 cfg.vdf_hash_to_input_cost = Some(100);
3834 }
3835
3836 if chain != Chain::Testnet && chain != Chain::Mainnet {
3838 cfg.feature_flags
3839 .record_consensus_determined_version_assignments_in_prologue = true;
3840 }
3841
3842 if chain != Chain::Mainnet {
3844 cfg.feature_flags.consensus_choice = ConsensusChoice::Mysticeti;
3845 }
3846
3847 cfg.feature_flags.fresh_vm_on_framework_upgrade = true;
3849 }
3850 50 => {
3851 if chain != Chain::Mainnet {
3853 cfg.checkpoint_summary_version_specific_data = Some(1);
3854 cfg.min_checkpoint_interval_ms = Some(200);
3855 }
3856
3857 if chain != Chain::Testnet && chain != Chain::Mainnet {
3859 cfg.feature_flags
3860 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = true;
3861 }
3862
3863 cfg.feature_flags.mysticeti_num_leaders_per_round = Some(1);
3864
3865 cfg.max_deferral_rounds_for_congestion_control = Some(10);
3867 }
3868 51 => {
3869 cfg.random_beacon_dkg_version = Some(1);
3870
3871 if chain != Chain::Testnet && chain != Chain::Mainnet {
3872 cfg.feature_flags.enable_coin_deny_list_v2 = true;
3873 }
3874 }
3875 52 => {
3876 if chain != Chain::Mainnet {
3877 cfg.feature_flags.soft_bundle = true;
3878 cfg.max_soft_bundle_size = Some(5);
3879 }
3880
3881 cfg.config_read_setting_impl_cost_base = Some(100);
3882 cfg.config_read_setting_impl_cost_per_byte = Some(40);
3883
3884 if chain != Chain::Testnet && chain != Chain::Mainnet {
3886 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(100);
3887 cfg.feature_flags.per_object_congestion_control_mode =
3888 PerObjectCongestionControlMode::TotalTxCount;
3889 }
3890
3891 cfg.feature_flags.consensus_choice = ConsensusChoice::Mysticeti;
3893
3894 cfg.feature_flags.mysticeti_leader_scoring_and_schedule = true;
3896
3897 cfg.checkpoint_summary_version_specific_data = Some(1);
3899 cfg.min_checkpoint_interval_ms = Some(200);
3900
3901 if chain != Chain::Mainnet {
3903 cfg.feature_flags
3904 .record_consensus_determined_version_assignments_in_prologue = true;
3905 cfg.feature_flags
3906 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = true;
3907 }
3908 if chain != Chain::Mainnet {
3910 cfg.move_binary_format_version = Some(7);
3911 }
3912
3913 if chain != Chain::Testnet && chain != Chain::Mainnet {
3914 cfg.feature_flags.passkey_auth = true;
3915 }
3916 cfg.feature_flags.enable_coin_deny_list_v2 = true;
3917 }
3918 53 => {
3919 cfg.bridge_should_try_to_finalize_committee = Some(chain != Chain::Mainnet);
3921
3922 cfg.feature_flags
3924 .record_consensus_determined_version_assignments_in_prologue = true;
3925 cfg.feature_flags
3926 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = true;
3927
3928 if chain == Chain::Unknown {
3929 cfg.feature_flags.authority_capabilities_v2 = true;
3930 }
3931
3932 if chain != Chain::Mainnet {
3934 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(100);
3935 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(10);
3936 cfg.feature_flags.per_object_congestion_control_mode =
3937 PerObjectCongestionControlMode::TotalTxCount;
3938 }
3939
3940 cfg.bcs_per_byte_serialized_cost = Some(2);
3942 cfg.bcs_legacy_min_output_size_cost = Some(1);
3943 cfg.bcs_failure_cost = Some(52);
3944 cfg.debug_print_base_cost = Some(52);
3945 cfg.debug_print_stack_trace_base_cost = Some(52);
3946 cfg.hash_sha2_256_base_cost = Some(52);
3947 cfg.hash_sha2_256_per_byte_cost = Some(2);
3948 cfg.hash_sha2_256_legacy_min_input_len_cost = Some(1);
3949 cfg.hash_sha3_256_base_cost = Some(52);
3950 cfg.hash_sha3_256_per_byte_cost = Some(2);
3951 cfg.hash_sha3_256_legacy_min_input_len_cost = Some(1);
3952 cfg.type_name_get_base_cost = Some(52);
3953 cfg.type_name_get_per_byte_cost = Some(2);
3954 cfg.string_check_utf8_base_cost = Some(52);
3955 cfg.string_check_utf8_per_byte_cost = Some(2);
3956 cfg.string_is_char_boundary_base_cost = Some(52);
3957 cfg.string_sub_string_base_cost = Some(52);
3958 cfg.string_sub_string_per_byte_cost = Some(2);
3959 cfg.string_index_of_base_cost = Some(52);
3960 cfg.string_index_of_per_byte_pattern_cost = Some(2);
3961 cfg.string_index_of_per_byte_searched_cost = Some(2);
3962 cfg.vector_empty_base_cost = Some(52);
3963 cfg.vector_length_base_cost = Some(52);
3964 cfg.vector_push_back_base_cost = Some(52);
3965 cfg.vector_push_back_legacy_per_abstract_memory_unit_cost = Some(2);
3966 cfg.vector_borrow_base_cost = Some(52);
3967 cfg.vector_pop_back_base_cost = Some(52);
3968 cfg.vector_destroy_empty_base_cost = Some(52);
3969 cfg.vector_swap_base_cost = Some(52);
3970 }
3971 54 => {
3972 cfg.feature_flags.random_beacon = true;
3974 cfg.random_beacon_reduction_lower_bound = Some(1000);
3975 cfg.random_beacon_dkg_timeout_round = Some(3000);
3976 cfg.random_beacon_min_round_interval_ms = Some(500);
3977
3978 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(100);
3980 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(10);
3981 cfg.feature_flags.per_object_congestion_control_mode =
3982 PerObjectCongestionControlMode::TotalTxCount;
3983
3984 cfg.feature_flags.soft_bundle = true;
3986 cfg.max_soft_bundle_size = Some(5);
3987 }
3988 55 => {
3989 cfg.move_binary_format_version = Some(7);
3991
3992 cfg.consensus_max_transactions_in_block_bytes = Some(512 * 1024);
3994 cfg.consensus_max_num_transactions_in_block = Some(512);
3997
3998 cfg.feature_flags.rethrow_serialization_type_layout_errors = true;
3999 }
4000 56 => {
4001 if chain == Chain::Mainnet {
4002 cfg.feature_flags.bridge = true;
4003 }
4004 }
4005 57 => {
4006 cfg.random_beacon_reduction_lower_bound = Some(800);
4008 }
4009 58 => {
4010 if chain == Chain::Mainnet {
4011 cfg.bridge_should_try_to_finalize_committee = Some(true);
4012 }
4013
4014 if chain != Chain::Mainnet && chain != Chain::Testnet {
4015 cfg.feature_flags
4017 .consensus_distributed_vote_scoring_strategy = true;
4018 }
4019 }
4020 59 => {
4021 cfg.feature_flags.consensus_round_prober = true;
4023 }
4024 60 => {
4025 cfg.max_type_to_layout_nodes = Some(512);
4026 cfg.feature_flags.validate_identifier_inputs = true;
4027 }
4028 61 => {
4029 if chain != Chain::Mainnet {
4030 cfg.feature_flags
4032 .consensus_distributed_vote_scoring_strategy = true;
4033 }
4034 cfg.random_beacon_reduction_lower_bound = Some(700);
4036
4037 if chain != Chain::Mainnet && chain != Chain::Testnet {
4038 cfg.feature_flags.mysticeti_fastpath = true;
4040 }
4041 }
4042 62 => {
4043 cfg.feature_flags.relocate_event_module = true;
4044 }
4045 63 => {
4046 cfg.feature_flags.per_object_congestion_control_mode =
4047 PerObjectCongestionControlMode::TotalGasBudgetWithCap;
4048 cfg.gas_budget_based_txn_cost_cap_factor = Some(400_000);
4049 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(18_500_000);
4050 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(240_000_000);
4051 }
4052 64 => {
4053 cfg.feature_flags.per_object_congestion_control_mode =
4054 PerObjectCongestionControlMode::TotalTxCount;
4055 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(40);
4056 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(3);
4057 }
4058 65 => {
4059 cfg.feature_flags
4061 .consensus_distributed_vote_scoring_strategy = true;
4062 }
4063 66 => {
4064 if chain == Chain::Mainnet {
4065 cfg.feature_flags
4067 .consensus_distributed_vote_scoring_strategy = false;
4068 }
4069 }
4070 67 => {
4071 cfg.feature_flags
4073 .consensus_distributed_vote_scoring_strategy = true;
4074 }
4075 68 => {
4076 cfg.group_ops_bls12381_g1_to_uncompressed_g1_cost = Some(26);
4077 cfg.group_ops_bls12381_uncompressed_g1_to_g1_cost = Some(52);
4078 cfg.group_ops_bls12381_uncompressed_g1_sum_base_cost = Some(26);
4079 cfg.group_ops_bls12381_uncompressed_g1_sum_cost_per_term = Some(13);
4080 cfg.group_ops_bls12381_uncompressed_g1_sum_max_terms = Some(2000);
4081
4082 if chain != Chain::Mainnet && chain != Chain::Testnet {
4083 cfg.feature_flags.uncompressed_g1_group_elements = true;
4084 }
4085
4086 cfg.feature_flags.per_object_congestion_control_mode =
4087 PerObjectCongestionControlMode::TotalGasBudgetWithCap;
4088 cfg.gas_budget_based_txn_cost_cap_factor = Some(400_000);
4089 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(18_500_000);
4090 cfg.max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit =
4091 Some(3_700_000); cfg.max_txn_cost_overage_per_object_in_commit = Some(u64::MAX);
4093 cfg.gas_budget_based_txn_cost_absolute_cap_commit_count = Some(50);
4094
4095 cfg.random_beacon_reduction_lower_bound = Some(500);
4097
4098 cfg.feature_flags.disallow_new_modules_in_deps_only_packages = true;
4099 }
4100 69 => {
4101 cfg.consensus_voting_rounds = Some(40);
4103
4104 if chain != Chain::Mainnet && chain != Chain::Testnet {
4105 cfg.feature_flags.consensus_smart_ancestor_selection = true;
4107 }
4108
4109 if chain != Chain::Mainnet {
4110 cfg.feature_flags.uncompressed_g1_group_elements = true;
4111 }
4112 }
4113 70 => {
4114 if chain != Chain::Mainnet {
4115 cfg.feature_flags.consensus_smart_ancestor_selection = true;
4117 cfg.feature_flags
4119 .consensus_round_prober_probe_accepted_rounds = true;
4120 }
4121
4122 cfg.poseidon_bn254_cost_per_block = Some(388);
4123
4124 cfg.gas_model_version = Some(9);
4125 cfg.feature_flags.native_charging_v2 = true;
4126 cfg.bls12381_bls12381_min_sig_verify_cost_base = Some(44064);
4127 cfg.bls12381_bls12381_min_pk_verify_cost_base = Some(49282);
4128 cfg.ecdsa_k1_secp256k1_verify_keccak256_cost_base = Some(1470);
4129 cfg.ecdsa_k1_secp256k1_verify_sha256_cost_base = Some(1470);
4130 cfg.ecdsa_r1_secp256r1_verify_sha256_cost_base = Some(4225);
4131 cfg.ecdsa_r1_secp256r1_verify_keccak256_cost_base = Some(4225);
4132 cfg.ecvrf_ecvrf_verify_cost_base = Some(4848);
4133 cfg.ed25519_ed25519_verify_cost_base = Some(1802);
4134
4135 cfg.ecdsa_r1_ecrecover_keccak256_cost_base = Some(1173);
4137 cfg.ecdsa_r1_ecrecover_sha256_cost_base = Some(1173);
4138 cfg.ecdsa_k1_ecrecover_keccak256_cost_base = Some(500);
4139 cfg.ecdsa_k1_ecrecover_sha256_cost_base = Some(500);
4140
4141 cfg.groth16_prepare_verifying_key_bls12381_cost_base = Some(53838);
4142 cfg.groth16_prepare_verifying_key_bn254_cost_base = Some(82010);
4143 cfg.groth16_verify_groth16_proof_internal_bls12381_cost_base = Some(72090);
4144 cfg.groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input =
4145 Some(8213);
4146 cfg.groth16_verify_groth16_proof_internal_bn254_cost_base = Some(115502);
4147 cfg.groth16_verify_groth16_proof_internal_bn254_cost_per_public_input =
4148 Some(9484);
4149
4150 cfg.hash_keccak256_cost_base = Some(10);
4151 cfg.hash_blake2b256_cost_base = Some(10);
4152
4153 cfg.group_ops_bls12381_decode_scalar_cost = Some(7);
4155 cfg.group_ops_bls12381_decode_g1_cost = Some(2848);
4156 cfg.group_ops_bls12381_decode_g2_cost = Some(3770);
4157 cfg.group_ops_bls12381_decode_gt_cost = Some(3068);
4158
4159 cfg.group_ops_bls12381_scalar_add_cost = Some(10);
4160 cfg.group_ops_bls12381_g1_add_cost = Some(1556);
4161 cfg.group_ops_bls12381_g2_add_cost = Some(3048);
4162 cfg.group_ops_bls12381_gt_add_cost = Some(188);
4163
4164 cfg.group_ops_bls12381_scalar_sub_cost = Some(10);
4165 cfg.group_ops_bls12381_g1_sub_cost = Some(1550);
4166 cfg.group_ops_bls12381_g2_sub_cost = Some(3019);
4167 cfg.group_ops_bls12381_gt_sub_cost = Some(497);
4168
4169 cfg.group_ops_bls12381_scalar_mul_cost = Some(11);
4170 cfg.group_ops_bls12381_g1_mul_cost = Some(4842);
4171 cfg.group_ops_bls12381_g2_mul_cost = Some(9108);
4172 cfg.group_ops_bls12381_gt_mul_cost = Some(27490);
4173
4174 cfg.group_ops_bls12381_scalar_div_cost = Some(91);
4175 cfg.group_ops_bls12381_g1_div_cost = Some(5091);
4176 cfg.group_ops_bls12381_g2_div_cost = Some(9206);
4177 cfg.group_ops_bls12381_gt_div_cost = Some(27804);
4178
4179 cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(2962);
4180 cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(8688);
4181
4182 cfg.group_ops_bls12381_g1_msm_base_cost = Some(62648);
4183 cfg.group_ops_bls12381_g2_msm_base_cost = Some(131192);
4184 cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(1333);
4185 cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(3216);
4186
4187 cfg.group_ops_bls12381_uncompressed_g1_to_g1_cost = Some(677);
4188 cfg.group_ops_bls12381_g1_to_uncompressed_g1_cost = Some(2099);
4189 cfg.group_ops_bls12381_uncompressed_g1_sum_base_cost = Some(77);
4190 cfg.group_ops_bls12381_uncompressed_g1_sum_cost_per_term = Some(26);
4191
4192 cfg.group_ops_bls12381_pairing_cost = Some(26897);
4193 cfg.group_ops_bls12381_uncompressed_g1_sum_max_terms = Some(1200);
4194
4195 cfg.validator_validate_metadata_cost_base = Some(20000);
4196 }
4197 71 => {
4198 cfg.sip_45_consensus_amplification_threshold = Some(5);
4199
4200 cfg.allowed_txn_cost_overage_burst_per_object_in_commit = Some(185_000_000);
4202 }
4203 72 => {
4204 cfg.feature_flags.convert_type_argument_error = true;
4205
4206 cfg.max_tx_gas = Some(50_000_000_000_000);
4209 cfg.max_gas_price = Some(50_000_000_000);
4211
4212 cfg.feature_flags.variant_nodes = true;
4213 }
4214 73 => {
4215 cfg.use_object_per_epoch_marker_table_v2 = Some(true);
4217
4218 if chain != Chain::Mainnet && chain != Chain::Testnet {
4219 cfg.consensus_gc_depth = Some(60);
4222 }
4223
4224 if chain != Chain::Mainnet {
4225 cfg.feature_flags.consensus_zstd_compression = true;
4227 }
4228
4229 cfg.feature_flags.consensus_smart_ancestor_selection = true;
4231 cfg.feature_flags
4233 .consensus_round_prober_probe_accepted_rounds = true;
4234
4235 cfg.feature_flags.per_object_congestion_control_mode =
4237 PerObjectCongestionControlMode::TotalGasBudgetWithCap;
4238 cfg.gas_budget_based_txn_cost_cap_factor = Some(400_000);
4239 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(37_000_000);
4240 cfg.max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit =
4241 Some(7_400_000); cfg.max_txn_cost_overage_per_object_in_commit = Some(u64::MAX);
4243 cfg.gas_budget_based_txn_cost_absolute_cap_commit_count = Some(50);
4244 cfg.allowed_txn_cost_overage_burst_per_object_in_commit = Some(370_000_000);
4245 }
4246 74 => {
4247 if chain != Chain::Mainnet && chain != Chain::Testnet {
4249 cfg.feature_flags.enable_nitro_attestation = true;
4250 }
4251 cfg.nitro_attestation_parse_base_cost = Some(53 * 50);
4252 cfg.nitro_attestation_parse_cost_per_byte = Some(50);
4253 cfg.nitro_attestation_verify_base_cost = Some(49632 * 50);
4254 cfg.nitro_attestation_verify_cost_per_cert = Some(52369 * 50);
4255
4256 cfg.feature_flags.consensus_zstd_compression = true;
4258
4259 if chain != Chain::Mainnet && chain != Chain::Testnet {
4260 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
4261 }
4262 }
4263 75 => {
4264 if chain != Chain::Mainnet {
4265 cfg.feature_flags.passkey_auth = true;
4266 }
4267 }
4268 76 => {
4269 if chain != Chain::Mainnet && chain != Chain::Testnet {
4270 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
4271 cfg.consensus_commit_rate_estimation_window_size = Some(10);
4272 }
4273 cfg.feature_flags.minimize_child_object_mutations = true;
4274
4275 if chain != Chain::Mainnet {
4276 cfg.feature_flags.accept_passkey_in_multisig = true;
4277 }
4278 }
4279 77 => {
4280 cfg.feature_flags.uncompressed_g1_group_elements = true;
4281
4282 if chain != Chain::Mainnet {
4283 cfg.consensus_gc_depth = Some(60);
4284 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
4285 }
4286 }
4287 78 => {
4288 cfg.feature_flags.move_native_context = true;
4289 cfg.tx_context_fresh_id_cost_base = Some(52);
4290 cfg.tx_context_sender_cost_base = Some(30);
4291 cfg.tx_context_epoch_cost_base = Some(30);
4292 cfg.tx_context_epoch_timestamp_ms_cost_base = Some(30);
4293 cfg.tx_context_sponsor_cost_base = Some(30);
4294 cfg.tx_context_gas_price_cost_base = Some(30);
4295 cfg.tx_context_gas_budget_cost_base = Some(30);
4296 cfg.tx_context_ids_created_cost_base = Some(30);
4297 cfg.tx_context_replace_cost_base = Some(30);
4298 cfg.gas_model_version = Some(10);
4299
4300 if chain != Chain::Mainnet {
4301 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
4302 cfg.consensus_commit_rate_estimation_window_size = Some(10);
4303
4304 cfg.feature_flags.per_object_congestion_control_mode =
4306 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4307 ExecutionTimeEstimateParams {
4308 target_utilization: 30,
4309 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4311 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4313 stored_observations_limit: u64::MAX,
4314 stake_weighted_median_threshold: 0,
4315 default_none_duration_for_new_keys: false,
4316 observations_chunk_size: None,
4317 },
4318 );
4319 }
4320 }
4321 79 => {
4322 if chain != Chain::Mainnet {
4323 cfg.feature_flags.consensus_median_based_commit_timestamp = true;
4324
4325 cfg.consensus_bad_nodes_stake_threshold = Some(30);
4328
4329 cfg.feature_flags.consensus_batched_block_sync = true;
4330
4331 cfg.feature_flags.enable_nitro_attestation = true
4333 }
4334 cfg.feature_flags.normalize_ptb_arguments = true;
4335
4336 cfg.consensus_gc_depth = Some(60);
4337 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
4338 }
4339 80 => {
4340 cfg.max_ptb_value_size = Some(1024 * 1024);
4341 }
4342 81 => {
4343 cfg.feature_flags.consensus_median_based_commit_timestamp = true;
4344 cfg.feature_flags.enforce_checkpoint_timestamp_monotonicity = true;
4345 cfg.consensus_bad_nodes_stake_threshold = Some(30)
4346 }
4347 82 => {
4348 cfg.feature_flags.max_ptb_value_size_v2 = true;
4349 }
4350 83 => {
4351 if chain == Chain::Mainnet {
4352 let aliased: [u8; 32] = Hex::decode(
4354 "0x0b2da327ba6a4cacbe75dddd50e6e8bbf81d6496e92d66af9154c61c77f7332f",
4355 )
4356 .unwrap()
4357 .try_into()
4358 .unwrap();
4359
4360 cfg.aliased_addresses.push(AliasedAddress {
4362 original: Hex::decode("0xcd8962dad278d8b50fa0f9eb0186bfa4cbdecc6d59377214c88d0286a0ac9562").unwrap().try_into().unwrap(),
4363 aliased,
4364 allowed_tx_digests: vec![
4365 Base58::decode("B2eGLFoMHgj93Ni8dAJBfqGzo8EWSTLBesZzhEpTPA4").unwrap().try_into().unwrap(),
4366 ],
4367 });
4368
4369 cfg.aliased_addresses.push(AliasedAddress {
4370 original: Hex::decode("0xe28b50cef1d633ea43d3296a3f6b67ff0312a5f1a99f0af753c85b8b5de8ff06").unwrap().try_into().unwrap(),
4371 aliased,
4372 allowed_tx_digests: vec![
4373 Base58::decode("J4QqSAgp7VrQtQpMy5wDX4QGsCSEZu3U5KuDAkbESAge").unwrap().try_into().unwrap(),
4374 ],
4375 });
4376 }
4377
4378 if chain != Chain::Mainnet {
4381 cfg.feature_flags.resolve_type_input_ids_to_defining_id = true;
4382 cfg.transfer_party_transfer_internal_cost_base = Some(52);
4383
4384 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
4386 cfg.consensus_commit_rate_estimation_window_size = Some(10);
4387 cfg.feature_flags.per_object_congestion_control_mode =
4388 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4389 ExecutionTimeEstimateParams {
4390 target_utilization: 30,
4391 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4393 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4395 stored_observations_limit: u64::MAX,
4396 stake_weighted_median_threshold: 0,
4397 default_none_duration_for_new_keys: false,
4398 observations_chunk_size: None,
4399 },
4400 );
4401
4402 cfg.feature_flags.consensus_batched_block_sync = true;
4404
4405 cfg.feature_flags.enable_nitro_attestation_upgraded_parsing = true;
4408 cfg.feature_flags.enable_nitro_attestation = true;
4409 }
4410 }
4411 84 => {
4412 if chain == Chain::Mainnet {
4413 cfg.feature_flags.resolve_type_input_ids_to_defining_id = true;
4414 cfg.transfer_party_transfer_internal_cost_base = Some(52);
4415
4416 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
4418 cfg.consensus_commit_rate_estimation_window_size = Some(10);
4419 cfg.feature_flags.per_object_congestion_control_mode =
4420 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4421 ExecutionTimeEstimateParams {
4422 target_utilization: 30,
4423 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4425 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4427 stored_observations_limit: u64::MAX,
4428 stake_weighted_median_threshold: 0,
4429 default_none_duration_for_new_keys: false,
4430 observations_chunk_size: None,
4431 },
4432 );
4433
4434 cfg.feature_flags.consensus_batched_block_sync = true;
4436
4437 cfg.feature_flags.enable_nitro_attestation_upgraded_parsing = true;
4440 cfg.feature_flags.enable_nitro_attestation = true;
4441 }
4442
4443 cfg.feature_flags.per_object_congestion_control_mode =
4445 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4446 ExecutionTimeEstimateParams {
4447 target_utilization: 30,
4448 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4450 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4452 stored_observations_limit: 20,
4453 stake_weighted_median_threshold: 0,
4454 default_none_duration_for_new_keys: false,
4455 observations_chunk_size: None,
4456 },
4457 );
4458 cfg.feature_flags.allow_unbounded_system_objects = true;
4459 }
4460 85 => {
4461 if chain != Chain::Mainnet && chain != Chain::Testnet {
4462 cfg.feature_flags.enable_party_transfer = true;
4463 }
4464
4465 cfg.feature_flags
4466 .record_consensus_determined_version_assignments_in_prologue_v2 = true;
4467 cfg.feature_flags.disallow_self_identifier = true;
4468 cfg.feature_flags.per_object_congestion_control_mode =
4469 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4470 ExecutionTimeEstimateParams {
4471 target_utilization: 50,
4472 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4474 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4476 stored_observations_limit: 20,
4477 stake_weighted_median_threshold: 0,
4478 default_none_duration_for_new_keys: false,
4479 observations_chunk_size: None,
4480 },
4481 );
4482 }
4483 86 => {
4484 cfg.feature_flags.type_tags_in_object_runtime = true;
4485 cfg.max_move_enum_variants = Some(move_core_types::VARIANT_COUNT_MAX);
4486
4487 cfg.feature_flags.per_object_congestion_control_mode =
4489 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4490 ExecutionTimeEstimateParams {
4491 target_utilization: 50,
4492 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4494 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4496 stored_observations_limit: 20,
4497 stake_weighted_median_threshold: 3334,
4498 default_none_duration_for_new_keys: false,
4499 observations_chunk_size: None,
4500 },
4501 );
4502 if chain != Chain::Mainnet {
4504 cfg.feature_flags.enable_party_transfer = true;
4505 }
4506 }
4507 87 => {
4508 if chain == Chain::Mainnet {
4509 cfg.feature_flags.record_time_estimate_processed = true;
4510 }
4511 cfg.feature_flags.better_adapter_type_resolution_errors = true;
4512 }
4513 88 => {
4514 cfg.feature_flags.record_time_estimate_processed = true;
4515 cfg.tx_context_rgp_cost_base = Some(30);
4516 cfg.feature_flags
4517 .ignore_execution_time_observations_after_certs_closed = true;
4518
4519 cfg.feature_flags.per_object_congestion_control_mode =
4522 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4523 ExecutionTimeEstimateParams {
4524 target_utilization: 50,
4525 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4527 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4529 stored_observations_limit: 20,
4530 stake_weighted_median_threshold: 3334,
4531 default_none_duration_for_new_keys: true,
4532 observations_chunk_size: None,
4533 },
4534 );
4535 }
4536 89 => {
4537 cfg.feature_flags.dependency_linkage_error = true;
4538 cfg.feature_flags.additional_multisig_checks = true;
4539 }
4540 90 => {
4541 cfg.max_gas_price_rgp_factor_for_aborted_transactions = Some(100);
4543 cfg.feature_flags.debug_fatal_on_move_invariant_violation = true;
4544 cfg.feature_flags.additional_consensus_digest_indirect_state = true;
4545 cfg.feature_flags.accept_passkey_in_multisig = true;
4546 cfg.feature_flags.passkey_auth = true;
4547 cfg.feature_flags.check_for_init_during_upgrade = true;
4548
4549 if chain != Chain::Mainnet {
4551 cfg.feature_flags.mysticeti_fastpath = true;
4552 }
4553 }
4554 91 => {
4555 cfg.feature_flags.per_command_shared_object_transfer_rules = true;
4556 }
4557 92 => {
4558 cfg.feature_flags.per_command_shared_object_transfer_rules = false;
4559 }
4560 93 => {
4561 cfg.feature_flags
4562 .consensus_checkpoint_signature_key_includes_digest = true;
4563 }
4564 94 => {
4565 cfg.feature_flags.per_object_congestion_control_mode =
4567 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4568 ExecutionTimeEstimateParams {
4569 target_utilization: 50,
4570 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4572 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4574 stored_observations_limit: 18,
4575 stake_weighted_median_threshold: 3334,
4576 default_none_duration_for_new_keys: true,
4577 observations_chunk_size: None,
4578 },
4579 );
4580
4581 cfg.feature_flags.enable_party_transfer = true;
4583 }
4584 95 => {
4585 cfg.type_name_id_base_cost = Some(52);
4586
4587 cfg.max_transactions_per_checkpoint = Some(20_000);
4589 }
4590 96 => {
4591 if chain != Chain::Mainnet && chain != Chain::Testnet {
4593 cfg.feature_flags
4594 .include_checkpoint_artifacts_digest_in_summary = true;
4595 }
4596 cfg.feature_flags.correct_gas_payment_limit_check = true;
4597 cfg.feature_flags.authority_capabilities_v2 = true;
4598 cfg.feature_flags.use_mfp_txns_in_load_initial_object_debts = true;
4599 cfg.feature_flags.cancel_for_failed_dkg_early = true;
4600 cfg.feature_flags.enable_coin_registry = true;
4601
4602 cfg.feature_flags.mysticeti_fastpath = true;
4604 }
4605 97 => {
4606 cfg.feature_flags.additional_borrow_checks = true;
4607 }
4608 98 => {
4609 cfg.event_emit_auth_stream_cost = Some(52);
4610 cfg.feature_flags.better_loader_errors = true;
4611 cfg.feature_flags.generate_df_type_layouts = true;
4612 }
4613 99 => {
4614 cfg.feature_flags.use_new_commit_handler = true;
4615 }
4616 100 => {
4617 cfg.feature_flags.private_generics_verifier_v2 = true;
4618 }
4619 101 => {
4620 cfg.feature_flags.create_root_accumulator_object = true;
4621 cfg.max_updates_per_settlement_txn = Some(100);
4622 if chain != Chain::Mainnet {
4623 cfg.feature_flags.enable_poseidon = true;
4624 }
4625 }
4626 102 => {
4627 cfg.feature_flags.per_object_congestion_control_mode =
4631 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4632 ExecutionTimeEstimateParams {
4633 target_utilization: 50,
4634 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4636 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4638 stored_observations_limit: 180,
4639 stake_weighted_median_threshold: 3334,
4640 default_none_duration_for_new_keys: true,
4641 observations_chunk_size: Some(18),
4642 },
4643 );
4644 cfg.feature_flags.deprecate_global_storage_ops = true;
4645 }
4646 103 => {}
4647 104 => {
4648 cfg.translation_per_command_base_charge = Some(1);
4649 cfg.translation_per_input_base_charge = Some(1);
4650 cfg.translation_pure_input_per_byte_charge = Some(1);
4651 cfg.translation_per_type_node_charge = Some(1);
4652 cfg.translation_per_reference_node_charge = Some(1);
4653 cfg.translation_per_linkage_entry_charge = Some(10);
4654 cfg.gas_model_version = Some(11);
4655 cfg.feature_flags.abstract_size_in_object_runtime = true;
4656 cfg.feature_flags.object_runtime_charge_cache_load_gas = true;
4657 cfg.dynamic_field_hash_type_and_key_cost_base = Some(52);
4658 cfg.dynamic_field_add_child_object_cost_base = Some(52);
4659 cfg.dynamic_field_add_child_object_value_cost_per_byte = Some(1);
4660 cfg.dynamic_field_borrow_child_object_cost_base = Some(52);
4661 cfg.dynamic_field_borrow_child_object_child_ref_cost_per_byte = Some(1);
4662 cfg.dynamic_field_remove_child_object_cost_base = Some(52);
4663 cfg.dynamic_field_remove_child_object_child_cost_per_byte = Some(1);
4664 cfg.dynamic_field_has_child_object_cost_base = Some(52);
4665 cfg.dynamic_field_has_child_object_with_ty_cost_base = Some(52);
4666 cfg.feature_flags.enable_ptb_execution_v2 = true;
4667
4668 cfg.poseidon_bn254_cost_base = Some(260);
4669
4670 cfg.feature_flags.consensus_skip_gced_accept_votes = true;
4671
4672 if chain != Chain::Mainnet {
4673 cfg.feature_flags
4674 .enable_nitro_attestation_all_nonzero_pcrs_parsing = true;
4675 }
4676
4677 cfg.feature_flags
4678 .include_cancelled_randomness_txns_in_prologue = true;
4679 }
4680 105 => {
4681 cfg.feature_flags.enable_multi_epoch_transaction_expiration = true;
4682 cfg.feature_flags.disable_preconsensus_locking = true;
4683
4684 if chain != Chain::Mainnet {
4685 cfg.feature_flags
4686 .enable_nitro_attestation_always_include_required_pcrs_parsing = true;
4687 }
4688 }
4689 106 => {
4690 cfg.accumulator_object_storage_cost = Some(7600);
4692
4693 if chain != Chain::Mainnet && chain != Chain::Testnet {
4694 cfg.feature_flags.enable_accumulators = true;
4695 cfg.feature_flags.enable_address_balance_gas_payments = true;
4696 cfg.feature_flags.enable_authenticated_event_streams = true;
4697 cfg.feature_flags.enable_object_funds_withdraw = true;
4698 }
4699 }
4700 107 => {
4701 cfg.feature_flags
4702 .consensus_skip_gced_blocks_in_direct_finalization = true;
4703
4704 if in_integration_test() {
4706 cfg.consensus_gc_depth = Some(6);
4707 cfg.consensus_max_num_transactions_in_block = Some(8);
4708 }
4709 }
4710 108 => {
4711 cfg.feature_flags.gas_rounding_halve_digits = true;
4712 cfg.feature_flags.flexible_tx_context_positions = true;
4713 cfg.feature_flags.disable_entry_point_signature_check = true;
4714
4715 if chain != Chain::Mainnet {
4716 cfg.feature_flags.address_aliases = true;
4717
4718 cfg.feature_flags.enable_accumulators = true;
4719 cfg.feature_flags.enable_address_balance_gas_payments = true;
4720 }
4721
4722 cfg.feature_flags.enable_poseidon = true;
4723 }
4724 109 => {
4725 cfg.binary_variant_handles = Some(1024);
4726 cfg.binary_variant_instantiation_handles = Some(1024);
4727 cfg.feature_flags.restrict_hot_or_not_entry_functions = true;
4728 }
4729 110 => {
4730 cfg.feature_flags
4731 .enable_nitro_attestation_all_nonzero_pcrs_parsing = true;
4732 cfg.feature_flags
4733 .enable_nitro_attestation_always_include_required_pcrs_parsing = true;
4734 if chain != Chain::Mainnet && chain != Chain::Testnet {
4735 cfg.feature_flags.split_checkpoints_in_consensus_handler = true;
4736 }
4737 cfg.feature_flags.validate_zklogin_public_identifier = true;
4738 cfg.feature_flags.fix_checkpoint_signature_mapping = true;
4739 cfg.feature_flags
4740 .consensus_always_accept_system_transactions = true;
4741 if chain != Chain::Mainnet {
4742 cfg.feature_flags.enable_object_funds_withdraw = true;
4743 }
4744 }
4745 111 => {
4746 cfg.feature_flags.validator_metadata_verify_v2 = true;
4747 }
4748 112 => {
4749 cfg.group_ops_ristretto_decode_scalar_cost = Some(7);
4750 cfg.group_ops_ristretto_decode_point_cost = Some(200);
4751 cfg.group_ops_ristretto_scalar_add_cost = Some(10);
4752 cfg.group_ops_ristretto_point_add_cost = Some(500);
4753 cfg.group_ops_ristretto_scalar_sub_cost = Some(10);
4754 cfg.group_ops_ristretto_point_sub_cost = Some(500);
4755 cfg.group_ops_ristretto_scalar_mul_cost = Some(11);
4756 cfg.group_ops_ristretto_point_mul_cost = Some(1200);
4757 cfg.group_ops_ristretto_scalar_div_cost = Some(151);
4758 cfg.group_ops_ristretto_point_div_cost = Some(2500);
4759
4760 if chain != Chain::Mainnet && chain != Chain::Testnet {
4761 cfg.feature_flags.enable_ristretto255_group_ops = true;
4762 }
4763 }
4764 113 => {
4765 cfg.feature_flags.address_balance_gas_check_rgp_at_signing = true;
4766 if chain != Chain::Mainnet && chain != Chain::Testnet {
4767 cfg.feature_flags.defer_unpaid_amplification = true;
4768 }
4769 }
4770 114 => {
4771 cfg.feature_flags.randomize_checkpoint_tx_limit_in_tests = true;
4772 cfg.feature_flags.address_balance_gas_reject_gas_coin_arg = true;
4773 if chain != Chain::Mainnet {
4774 cfg.feature_flags.split_checkpoints_in_consensus_handler = true;
4775 cfg.feature_flags.enable_authenticated_event_streams = true;
4776 cfg.feature_flags
4777 .include_checkpoint_artifacts_digest_in_summary = true;
4778 }
4779 }
4780 115 => {
4781 cfg.feature_flags.normalize_depth_formula = true;
4782 }
4783 116 => {
4784 cfg.feature_flags.gasless_transaction_drop_safety = true;
4785 cfg.feature_flags.address_aliases = true;
4786 cfg.feature_flags.relax_valid_during_for_owned_inputs = true;
4787 cfg.feature_flags.defer_unpaid_amplification = false;
4789 cfg.feature_flags.enable_display_registry = true;
4790 }
4791 117 => {}
4792 118 => {
4793 cfg.feature_flags.use_coin_party_owner = true;
4794 }
4795 119 => {
4796 cfg.execution_version = Some(4);
4798 cfg.feature_flags.address_balance_gas_reject_gas_coin_arg = false;
4799 cfg.feature_flags.merge_randomness_into_checkpoint = true;
4800 if chain != Chain::Mainnet {
4801 cfg.feature_flags.enable_gasless = true;
4802 cfg.gasless_max_computation_units = Some(50_000);
4803 cfg.gasless_allowed_token_types = Some(vec![]);
4804 cfg.feature_flags.enable_coin_reservation_obj_refs = true;
4805 cfg.feature_flags
4806 .convert_withdrawal_compatibility_ptb_arguments = true;
4807 }
4808 cfg.gasless_max_unused_inputs = Some(1);
4809 cfg.gasless_max_pure_input_bytes = Some(32);
4810 if chain == Chain::Testnet {
4811 cfg.gasless_allowed_token_types = Some(vec![(TESTNET_USDC.to_string(), 0)]);
4812 }
4813 cfg.transfer_receive_object_cost_per_byte = Some(1);
4814 cfg.transfer_receive_object_type_cost_per_byte = Some(2);
4815 }
4816 120 => {
4817 cfg.feature_flags.disallow_jump_orphans = true;
4818 }
4819 121 => {
4820 if chain != Chain::Mainnet {
4822 cfg.feature_flags.defer_unpaid_amplification = true;
4823 cfg.gasless_max_tps = Some(50);
4824 }
4825 cfg.feature_flags
4826 .early_return_receive_object_mismatched_type = true;
4827 }
4828 122 => {
4829 cfg.feature_flags.defer_unpaid_amplification = true;
4831 cfg.verify_bulletproofs_ristretto255_base_cost = Some(30000);
4833 cfg.verify_bulletproofs_ristretto255_cost_per_bit_and_commitment = Some(6500);
4834 if chain != Chain::Mainnet && chain != Chain::Testnet {
4835 cfg.feature_flags.enable_verify_bulletproofs_ristretto255 = true;
4836 }
4837 cfg.feature_flags.gasless_verify_remaining_balance = true;
4838 cfg.include_special_package_amendments = match chain {
4839 Chain::Mainnet => Some(MAINNET_LINKAGE_AMENDMENTS.clone()),
4840 Chain::Testnet => Some(TESTNET_LINKAGE_AMENDMENTS.clone()),
4841 Chain::Unknown => None,
4842 };
4843 cfg.gasless_max_tx_size_bytes = Some(16 * 1024);
4844 cfg.gasless_max_tps = Some(300);
4845 cfg.gasless_max_computation_units = Some(5_000);
4846 }
4847 123 => {
4848 cfg.gas_model_version = Some(13);
4849 }
4850 124 => {
4851 if chain != Chain::Mainnet && chain != Chain::Testnet {
4852 cfg.feature_flags.timestamp_based_epoch_close = true;
4853 }
4854 cfg.gas_model_version = Some(14);
4855 cfg.feature_flags.limit_groth16_pvk_inputs = true;
4856
4857 cfg.feature_flags.enable_accumulators = true;
4863 cfg.feature_flags.enable_address_balance_gas_payments = true;
4864 cfg.feature_flags.enable_authenticated_event_streams = true;
4865 cfg.feature_flags.enable_coin_reservation_obj_refs = true;
4866 cfg.feature_flags.enable_object_funds_withdraw = true;
4867 cfg.feature_flags
4868 .convert_withdrawal_compatibility_ptb_arguments = true;
4869 cfg.feature_flags.split_checkpoints_in_consensus_handler = true;
4870 cfg.feature_flags
4871 .include_checkpoint_artifacts_digest_in_summary = true;
4872 cfg.feature_flags.enable_gasless = true;
4873
4874 if chain == Chain::Mainnet {
4879 cfg.gasless_allowed_token_types = Some(vec![
4880 (MAINNET_USDC.to_string(), 10_000),
4881 (MAINNET_USDSUI.to_string(), 10_000),
4882 (MAINNET_SUI_USDE.to_string(), 10_000),
4883 (MAINNET_USDY.to_string(), 10_000),
4884 (MAINNET_FDUSD.to_string(), 10_000),
4885 (MAINNET_AUSD.to_string(), 10_000),
4886 (MAINNET_USDB.to_string(), 10_000),
4887 ]);
4888 }
4889 }
4890 125 => {
4891 cfg.feature_flags.granular_post_execution_checks = true;
4892 if chain != Chain::Mainnet {
4893 cfg.feature_flags.timestamp_based_epoch_close = true;
4894 }
4895 }
4896 126 => {
4897 cfg.feature_flags.early_exit_on_iffw = true;
4898 }
4899 127 => {
4900 cfg.feature_flags.always_advance_dkg_to_resolution = true;
4901
4902 cfg.verify_bulletproofs_ristretto255_base_cost = Some(23866);
4903 cfg.verify_bulletproofs_ristretto255_cost_per_bit_and_commitment = Some(1324);
4904 cfg.group_ops_ristretto_decode_scalar_cost = Some(5);
4905 cfg.group_ops_ristretto_decode_point_cost = Some(216);
4906 cfg.group_ops_ristretto_scalar_add_cost = Some(2);
4907 cfg.group_ops_ristretto_point_add_cost = Some(8);
4908 cfg.group_ops_ristretto_scalar_sub_cost = Some(2);
4909 cfg.group_ops_ristretto_point_sub_cost = Some(8);
4910 cfg.group_ops_ristretto_scalar_mul_cost = Some(5);
4911 cfg.group_ops_ristretto_point_mul_cost = Some(1763);
4912 cfg.group_ops_ristretto_scalar_div_cost = Some(557);
4913 cfg.group_ops_ristretto_point_div_cost = Some(2244);
4914
4915 if chain != Chain::Mainnet {
4916 cfg.feature_flags.enable_ristretto255_group_ops = true;
4917 cfg.feature_flags.enable_verify_bulletproofs_ristretto255 = true;
4918 }
4919
4920 cfg.feature_flags.timestamp_based_epoch_close = true;
4921 }
4922 128 => {
4923 cfg.max_generic_instantiation_type_nodes_per_function = Some(10_000);
4924 cfg.max_generic_instantiation_type_nodes_per_module = Some(500_000);
4925 cfg.binary_enum_defs = Some(200);
4926 cfg.binary_enum_def_instantiations = Some(100);
4927 }
4928 129 => {
4929 cfg.feature_flags.enable_unified_linkage = true;
4930 }
4931 130 => {
4932 cfg.feature_flags.record_net_unsettled_object_withdraws = true;
4933 cfg.feature_flags.enable_init_on_upgrade = true;
4934 cfg.epoch_close_deadline_ms = Some(120_000);
4935 cfg.scratch_add_cost_base = Some(13);
4936 cfg.scratch_read_cost_base = Some(13);
4937 cfg.scratch_read_value_cost = Some(1);
4938 cfg.scratch_remove_cost_base = Some(13);
4939 cfg.scratch_exists_cost_base = Some(13);
4940 cfg.scratch_exists_with_type_cost_base = Some(13);
4941 cfg.scratch_exists_with_type_type_cost = Some(1);
4942 let max_commands = cfg.max_programmable_tx_commands() as u64;
4943 cfg.max_scratch_pad_size = Some(16 * max_commands);
4944 if chain != Chain::Mainnet && chain != Chain::Testnet {
4946 cfg.feature_flags.zklogin_circuit_mode = 1;
4947 }
4948 }
4949 131 => {
4950 cfg.feature_flags.share_transaction_deny_config_in_consensus = true;
4951 cfg.feature_flags.framework_tx_context_mut_restrictions = true;
4952 }
4953 132 => {
4954 if chain != Chain::Mainnet && chain != Chain::Testnet {
4955 cfg.feature_flags.defer_owned_object_double_spend = true;
4956 cfg.feature_flags.create_forwarding_address_registry = true;
4957 }
4958 cfg.object_record_new_uid_from_hash_cost_base = Some(1);
4959 cfg.feature_flags
4960 .enable_order_independent_upgrade_init_linkage = true;
4961 }
4962 133 => {
4963 cfg.feature_flags
4964 .include_function_signatures_in_instantiation_limits = true;
4965 cfg.max_accumulator_type_nodes = Some(16);
4966 }
4967 134 => {
4968 if chain != Chain::Mainnet {
4975 cfg.package_original_package_id_impl_cost_base = Some(52);
4976 let package_read_cost_per_byte = cfg.obj_access_cost_read_per_byte();
4977 cfg.package_original_package_id_impl_cost_per_byte =
4978 Some(package_read_cost_per_byte);
4979
4980 cfg.consensus_max_transactions_in_block_bytes = Some(288 * 1024);
4981 cfg.consensus_max_num_transactions_in_block = Some(128);
4982 }
4983
4984 if chain == Chain::Mainnet {
4985 cfg.feature_flags.defer_unpaid_amplification = false;
4986 }
4987 }
4988 135 => {
4989 cfg.package_original_package_id_impl_cost_base = Some(52);
4992 let package_read_cost_per_byte = cfg.obj_access_cost_read_per_byte();
4993 cfg.package_original_package_id_impl_cost_per_byte =
4994 Some(package_read_cost_per_byte);
4995
4996 cfg.consensus_max_transactions_in_block_bytes = Some(288 * 1024);
4997 cfg.consensus_max_num_transactions_in_block = Some(128);
4998
4999 cfg.feature_flags.defer_unpaid_amplification = false;
5000 }
5001 136 => {
5002 cfg.feature_flags.ptb_tx_context_restrictions = true;
5003
5004 cfg.translation_per_live_reference_charge = Some(1);
5005 cfg.max_ptb_live_references = Some(64);
5006 cfg.max_ptb_returned_references = Some(16);
5007 cfg.max_ptb_total_returned_references = Some(256);
5008
5009 if chain != Chain::Mainnet && chain != Chain::Testnet {
5010 cfg.feature_flags.allowed_proposers = true;
5011 }
5012 cfg.feature_flags.harden_linkage_consistency = true;
5013
5014 cfg.package_arena_size_in_bytes = Some(10_000_000);
5015 }
5016 137 => {
5017 cfg.verify_bulletproofs_ristretto255_cost_per_bit_and_commitment = Some(621);
5018 cfg.max_bulletproofs_total_bits = Some(1024);
5019
5020 if chain != Chain::Mainnet {
5021 cfg.feature_flags.enable_allowances = true;
5022 }
5023 cfg.feature_flags.fix_ptb_generated_reads = true;
5024 cfg.feature_flags.charge_ld_const_abstract_size = true;
5025 if chain != Chain::Mainnet && chain != Chain::Testnet {
5026 cfg.feature_flags.check_object_funds_withdraw_in_execution = true;
5027 }
5028 cfg.reserve_object_funds_for_withdrawal_cost_base = Some(52);
5029 cfg.reserve_object_funds_for_withdrawal_cold_read_cost = Some(184);
5032
5033 cfg.feature_flags.allowed_proposers = true;
5034
5035 cfg.feature_flags.validate_ptb_argument_indices = true;
5036 cfg.feature_flags.memory_safety_invariant_check_v2 = true;
5037 }
5038 138 => {
5039 cfg.gas_model_version = Some(15);
5040 cfg.feature_flags.enable_allowances = true;
5041 if chain != Chain::Mainnet {
5042 cfg.feature_flags.check_object_funds_withdraw_in_execution = true;
5043 cfg.feature_flags.disable_effects_tx_dependencies = true;
5044 }
5045 cfg.feature_flags.merge_colliding_deferrals = true;
5046 if chain == Chain::Mainnet {
5048 cfg.storage_rebate_rate = Some(9999);
5049 }
5050 }
5051 139 => {
5052 if chain != Chain::Mainnet && chain != Chain::Testnet {
5053 cfg.feature_flags.enable_forwarding_addresses = true;
5054 cfg.feature_flags.mldsa65_auth = true;
5055 }
5056 cfg.storage_rebate_rate = Some(9999);
5057 if chain != Chain::Mainnet {
5058 cfg.feature_flags.allow_dkg_completion_after_timeout = true;
5059 }
5060 cfg.obj_access_cost_read_per_package_kb = Some(154);
5062 }
5063 140 => {
5064 cfg.staggered_submission_signal_window_commits = Some(300);
5067 cfg.staggered_submission_signal_min_excess_copies_per_commit = Some(2);
5068 cfg.staggered_submission_signal_exit_dwell_commits = Some(6000);
5069 cfg.staggered_submission_signal_band1_enter_ratio_bps = Some(1000);
5070 cfg.staggered_submission_signal_band1_exit_ratio_bps = Some(500);
5071 cfg.staggered_submission_signal_band2_enter_ratio_bps = Some(5000);
5072 cfg.staggered_submission_signal_band2_exit_ratio_bps = Some(2500);
5073
5074 cfg.vector_reverse_base_cost = Some(52);
5075 cfg.vector_reverse_per_elem_cost = Some(8);
5076 cfg.vector_keep_range_base_cost = Some(52);
5077 cfg.vector_keep_range_per_dropped_elem_cost = Some(1);
5078 cfg.vector_keep_range_per_moved_elem_cost = Some(8);
5079 cfg.vector_copy_range_base_cost = Some(52);
5080 cfg.vector_replace_range_base_cost = Some(52);
5081 cfg.vector_replace_range_per_elem_cost = Some(8);
5082
5083 if chain != Chain::Mainnet && chain != Chain::Testnet {
5084 cfg.feature_flags.shuffle_consensus_commit_blocks = true;
5085 }
5086
5087 cfg.feature_flags.allow_references_in_ptbs = true;
5088 cfg.feature_flags.disable_id_leak_verifier = true;
5089 cfg.feature_flags.check_object_funds_withdraw_in_execution = true;
5090 cfg.feature_flags.disable_effects_tx_dependencies = true;
5091 }
5092 141 => {
5093 cfg.feature_flags.complete_effects_size_estimate = true;
5094 cfg.max_num_accumulator_events = Some(1024);
5095 }
5096 142 => {
5097 cfg.clock_borrow_cost_base = Some(52);
5098 cfg.feature_flags.check_groth16_pvk_length = true;
5099 cfg.object_is_shared_input_cost_base = Some(52);
5100 cfg.feature_flags.secp256r1_ecrecover_checks_x_below_p = true;
5101 cfg.binary_format_limits_profile = Some(BinaryFormatLimitsProfile::V1);
5102 cfg.feature_flags.defer_owned_object_double_spend = true;
5103 }
5104 143 => {
5105 cfg.execution_version = Some(5);
5106 cfg.package_arena_size_in_bytes = Some(20_000_000);
5107 cfg.feature_flags.simplify_nitro_header_validation = true;
5108 cfg.feature_flags.enable_forwarding_addresses = false;
5109 cfg.feature_flags.package_publish_charge = true;
5110 cfg.package_publish_charge_fixed = Some(1_000_000_000);
5111 cfg.package_publish_charge_per_module = Some(10_000_000);
5112 cfg.package_publish_charge_per_dependency = Some(10_000_000);
5113 if chain != Chain::Mainnet {
5114 cfg.feature_flags.mldsa65_auth = true;
5115 }
5116 cfg.layout_node_cost = Some(16);
5117 cfg.layout_node_cost_large_layout_threshold = Some(64);
5118 cfg.bcs_per_input_abstract_unit_cost = Some(20);
5119 cfg.vector_copy_range_per_abstract_memory_unit_cost = Some(1);
5120 }
5121 144 => {
5122 if chain != Chain::Mainnet && chain != Chain::Testnet {
5123 cfg.feature_flags.enable_timestamp_transaction_expiration = true;
5124 }
5125 cfg.object_runtime_max_loaded_child_value_size = Some(5_000_000);
5126
5127 cfg.feature_flags.staggered_submission_signal = true;
5128 cfg.staggered_submission_signal_window_commits = Some(600);
5140 cfg.staggered_submission_signal_min_consensus_user_transactions_per_commit =
5141 Some(1000);
5142 if chain == Chain::Testnet {
5143 cfg.staggered_submission_signal_min_consensus_user_transactions_per_commit = Some(5);
5149 }
5150 }
5151 145 => {
5152 cfg.feature_flags.secp256r1_strict_public_keys = true;
5153 cfg.feature_flags.create_freeze_list = true;
5154 cfg.feature_flags.enable_coin_regulation = true;
5155 cfg.max_freeze_list_address_reads = Some(10_000);
5156 }
5157 _ => panic!("unsupported version {:?}", version),
5168 }
5169 }
5170
5171 cfg
5172 }
5173
5174 pub fn apply_seeded_test_overrides(&mut self, seed: &[u8; 32]) {
5175 if !self.feature_flags.randomize_checkpoint_tx_limit_in_tests
5176 || !self.feature_flags.split_checkpoints_in_consensus_handler
5177 {
5178 return;
5179 }
5180
5181 if !mysten_common::in_test_configuration() {
5182 return;
5183 }
5184
5185 use rand::{Rng, SeedableRng, rngs::StdRng};
5186 let mut rng = StdRng::from_seed(*seed);
5187 let max_txns = rng.gen_range(10..=100u64);
5188 info!("seeded test override: max_transactions_per_checkpoint = {max_txns}");
5189 self.max_transactions_per_checkpoint = Some(max_txns);
5190 }
5191
5192 pub fn verifier_config(&self, signing_limits: Option<(usize, usize, usize)>) -> VerifierConfig {
5198 let (
5199 max_back_edges_per_function,
5200 max_back_edges_per_module,
5201 sanity_check_with_regex_reference_safety,
5202 ) = if let Some((
5203 max_back_edges_per_function,
5204 max_back_edges_per_module,
5205 sanity_check_with_regex_reference_safety,
5206 )) = signing_limits
5207 {
5208 (
5209 Some(max_back_edges_per_function),
5210 Some(max_back_edges_per_module),
5211 Some(sanity_check_with_regex_reference_safety),
5212 )
5213 } else {
5214 (None, None, None)
5215 };
5216
5217 let additional_borrow_checks = if signing_limits.is_some() {
5218 true
5220 } else {
5221 self.additional_borrow_checks()
5222 };
5223 let deprecate_global_storage_ops = if signing_limits.is_some() {
5224 true
5226 } else {
5227 self.deprecate_global_storage_ops()
5228 };
5229
5230 VerifierConfig {
5231 max_loop_depth: Some(self.max_loop_depth() as usize),
5232 max_generic_instantiation_length: Some(self.max_generic_instantiation_length() as usize),
5233 max_function_parameters: Some(self.max_function_parameters() as usize),
5234 max_basic_blocks: Some(self.max_basic_blocks() as usize),
5235 max_value_stack_size: self.max_value_stack_size() as usize,
5236 max_type_nodes: Some(self.max_type_nodes() as usize),
5237 max_generic_instantiation_type_nodes_per_function: self
5238 .max_generic_instantiation_type_nodes_per_function_as_option()
5239 .map(|v| v as usize),
5240 max_generic_instantiation_type_nodes_per_module: self
5241 .max_generic_instantiation_type_nodes_per_module_as_option()
5242 .map(|v| v as usize),
5243 include_function_signatures_in_instantiation_limits: self
5244 .include_function_signatures_in_instantiation_limits(),
5245 max_push_size: Some(self.max_push_size() as usize),
5246 max_dependency_depth: Some(self.max_dependency_depth() as usize),
5247 max_fields_in_struct: Some(self.max_fields_in_struct() as usize),
5248 max_function_definitions: Some(self.max_function_definitions() as usize),
5249 max_data_definitions: Some(self.max_struct_definitions() as usize),
5250 max_constant_vector_len: Some(self.max_move_vector_len()),
5251 max_back_edges_per_function,
5252 max_back_edges_per_module,
5253 max_basic_blocks_in_script: None,
5254 max_identifier_len: self.max_move_identifier_len_as_option(), disallow_self_identifier: self.feature_flags.disallow_self_identifier,
5256 allow_receiving_object_id: self.allow_receiving_object_id(),
5257 reject_mutable_random_on_entry_functions: self
5258 .reject_mutable_random_on_entry_functions(),
5259 bytecode_version: self.move_binary_format_version(),
5260 max_variants_in_enum: self.max_move_enum_variants_as_option(),
5261 additional_borrow_checks,
5262 better_loader_errors: self.better_loader_errors(),
5263 private_generics_verifier_v2: self.private_generics_verifier_v2(),
5264 sanity_check_with_regex_reference_safety: sanity_check_with_regex_reference_safety
5265 .map(|limit| limit as u128),
5266 deprecate_global_storage_ops,
5267 disable_entry_point_signature_check: self.disable_entry_point_signature_check(),
5268 disable_id_leak_verifier: self.disable_id_leak_verifier(),
5269 switch_to_regex_reference_safety: false,
5270 framework_tx_context_mut_restrictions: self.framework_tx_context_mut_restrictions(),
5271 disallow_jump_orphans: self.disallow_jump_orphans(),
5272 }
5273 }
5274
5275 pub fn binary_config(
5276 &self,
5277 override_deprecate_global_storage_ops_during_deserialization: Option<bool>,
5278 ) -> BinaryConfig {
5279 let deprecate_global_storage_ops =
5280 override_deprecate_global_storage_ops_during_deserialization
5281 .unwrap_or_else(|| self.deprecate_global_storage_ops());
5282 BinaryConfig::new(
5283 self.move_binary_format_version(),
5284 self.min_move_binary_format_version_as_option()
5285 .unwrap_or(VERSION_1),
5286 self.no_extraneous_module_bytes(),
5287 deprecate_global_storage_ops,
5288 TableConfig {
5289 module_handles: self.binary_module_handles_as_option().unwrap_or(u16::MAX),
5290 datatype_handles: self.binary_struct_handles_as_option().unwrap_or(u16::MAX),
5291 function_handles: self.binary_function_handles_as_option().unwrap_or(u16::MAX),
5292 function_instantiations: self
5293 .binary_function_instantiations_as_option()
5294 .unwrap_or(u16::MAX),
5295 signatures: self.binary_signatures_as_option().unwrap_or(u16::MAX),
5296 constant_pool: self.binary_constant_pool_as_option().unwrap_or(u16::MAX),
5297 identifiers: self.binary_identifiers_as_option().unwrap_or(u16::MAX),
5298 address_identifiers: self
5299 .binary_address_identifiers_as_option()
5300 .unwrap_or(u16::MAX),
5301 struct_defs: self.binary_struct_defs_as_option().unwrap_or(u16::MAX),
5302 struct_def_instantiations: self
5303 .binary_struct_def_instantiations_as_option()
5304 .unwrap_or(u16::MAX),
5305 function_defs: self.binary_function_defs_as_option().unwrap_or(u16::MAX),
5306 field_handles: self.binary_field_handles_as_option().unwrap_or(u16::MAX),
5307 field_instantiations: self
5308 .binary_field_instantiations_as_option()
5309 .unwrap_or(u16::MAX),
5310 friend_decls: self.binary_friend_decls_as_option().unwrap_or(u16::MAX),
5311 enum_defs: self.binary_enum_defs_as_option().unwrap_or(u16::MAX),
5312 enum_def_instantiations: self
5313 .binary_enum_def_instantiations_as_option()
5314 .unwrap_or(u16::MAX),
5315 variant_handles: self.binary_variant_handles_as_option().unwrap_or(u16::MAX),
5316 variant_instantiation_handles: self
5317 .binary_variant_instantiation_handles_as_option()
5318 .unwrap_or(u16::MAX),
5319 },
5320 self.binary_format_limits(),
5321 )
5322 }
5323
5324 pub fn binary_format_limits(
5325 &self,
5326 ) -> &'static move_binary_format::binary_config::BinaryFormatLimits {
5327 self.binary_format_limits_profile
5328 .unwrap_or(BinaryFormatLimitsProfile::LEGACY)
5329 .limits()
5330 }
5331
5332 pub fn apply_overrides_for_testing(
5336 override_fn: impl Fn(ProtocolVersion, Self) -> Self + Send + Sync + 'static,
5337 ) -> OverrideGuard {
5338 let mut cur = CONFIG_OVERRIDE.lock().unwrap();
5339 assert!(cur.is_none(), "config override already present");
5340 *cur = Some(Box::new(override_fn));
5341 OverrideGuard
5342 }
5343
5344 #[cfg(feature = "testing")]
5348 pub fn apply_base_overrides_for_testing(
5349 override_fn: impl Fn(ProtocolVersion, Self) -> Self + Send + Sync + 'static,
5350 ) -> BaseOverrideGuard {
5351 info!("installing base ProtocolConfig override for testing");
5352 let override_fn: Arc<OverrideFn> = Arc::new(override_fn);
5353 BASE_CONFIG_OVERRIDES
5354 .lock()
5355 .unwrap()
5356 .push(override_fn.clone());
5357 BaseOverrideGuard { override_fn }
5358 }
5359
5360 fn apply_config_override(version: ProtocolVersion, mut ret: Self) -> Self {
5361 #[cfg(feature = "testing")]
5363 {
5364 let fns = BASE_CONFIG_OVERRIDES.lock().unwrap().clone();
5365 for override_fn in fns {
5366 ret = override_fn(version, ret);
5367 }
5368 }
5369 if let Some(override_fn) = CONFIG_OVERRIDE.lock().unwrap().as_ref() {
5370 warn!(
5371 "overriding ProtocolConfig settings with custom settings (you should not see this log outside of tests)"
5372 );
5373 ret = override_fn(version, ret);
5374 }
5375 ret
5376 }
5377}
5378
5379impl ProtocolConfig {
5383 pub fn set_execution_version_for_testing(&mut self, val: u64) {
5387 let current = self.execution_version.unwrap_or(0);
5388 assert!(
5389 val >= current,
5390 "cannot downgrade execution_version from {current} to {val}: running an old \
5391 executor against a newer protocol config/framework is unsupported. To test \
5392 frozen executor behavior, start from the last protocol version of that executor \
5393 instead, so genesis loads the matching framework snapshot (see \
5394 test_address_balance_gas_v3_accumulator_sign)."
5395 );
5396 self.execution_version = Some(val);
5397 }
5398
5399 pub fn set_zklogin_circuit_mode_for_testing(&mut self, val: u64) {
5402 self.feature_flags.zklogin_circuit_mode = val
5403 }
5404
5405 pub fn set_per_object_congestion_control_mode_for_testing(
5406 &mut self,
5407 val: PerObjectCongestionControlMode,
5408 ) {
5409 self.feature_flags.per_object_congestion_control_mode = val;
5410 }
5411
5412 pub fn set_consensus_choice_for_testing(&mut self, val: ConsensusChoice) {
5413 self.feature_flags.consensus_choice = val;
5414 }
5415
5416 pub fn set_consensus_network_for_testing(&mut self, val: ConsensusNetwork) {
5417 self.feature_flags.consensus_network = val;
5418 }
5419
5420 pub fn set_zklogin_max_epoch_upper_bound_delta_for_testing(&mut self, val: Option<u64>) {
5421 self.feature_flags.zklogin_max_epoch_upper_bound_delta = val
5422 }
5423
5424 pub fn set_mysticeti_num_leaders_per_round_for_testing(&mut self, val: Option<usize>) {
5425 self.feature_flags.mysticeti_num_leaders_per_round = val;
5426 }
5427
5428 pub fn disable_accumulators_for_testing(&mut self) {
5429 self.feature_flags.enable_accumulators = false;
5430 self.feature_flags.enable_address_balance_gas_payments = false;
5431 }
5432
5433 pub fn enable_coin_reservation_for_testing(&mut self) {
5434 self.feature_flags.enable_coin_reservation_obj_refs = true;
5435 self.feature_flags
5436 .convert_withdrawal_compatibility_ptb_arguments = true;
5437 self.execution_version = Some(self.execution_version.map_or(4, |v| v.max(4)));
5440 }
5441
5442 pub fn disable_coin_reservation_for_testing(&mut self) {
5443 self.feature_flags.enable_coin_reservation_obj_refs = false;
5444 self.feature_flags
5445 .convert_withdrawal_compatibility_ptb_arguments = false;
5446 }
5447
5448 pub fn enable_address_balance_gas_payments_for_testing(&mut self) {
5449 self.feature_flags.enable_accumulators = true;
5450 self.feature_flags.allow_private_accumulator_entrypoints = true;
5451 self.feature_flags.enable_address_balance_gas_payments = true;
5452 self.feature_flags.address_balance_gas_check_rgp_at_signing = true;
5453 self.feature_flags.address_balance_gas_reject_gas_coin_arg = false;
5454 self.execution_version = Some(self.execution_version.map_or(4, |v| v.max(4)))
5455 }
5456
5457 pub fn enable_gasless_for_testing(&mut self) {
5458 self.enable_address_balance_gas_payments_for_testing();
5459 self.feature_flags.enable_gasless = true;
5460 self.feature_flags.gasless_verify_remaining_balance = true;
5461 self.gasless_max_computation_units = Some(5_000);
5462 self.gasless_allowed_token_types = Some(vec![]);
5463 self.gasless_max_tps = Some(1000);
5464 self.gasless_max_tx_size_bytes = Some(16 * 1024);
5465 }
5466
5467 pub fn disable_gasless_for_testing(&mut self) {
5468 self.feature_flags.enable_gasless = false;
5469 self.gasless_max_computation_units = None;
5470 self.gasless_allowed_token_types = None;
5471 }
5472
5473 pub fn enable_authenticated_event_streams_for_testing(&mut self) {
5474 self.feature_flags.enable_accumulators = true;
5475 self.feature_flags.enable_authenticated_event_streams = true;
5476 self.feature_flags
5477 .include_checkpoint_artifacts_digest_in_summary = true;
5478 self.feature_flags.split_checkpoints_in_consensus_handler = true;
5479 }
5480}
5481
5482type OverrideFn = dyn Fn(ProtocolVersion, ProtocolConfig) -> ProtocolConfig + Send + Sync;
5483
5484static CONFIG_OVERRIDE: Mutex<Option<Box<OverrideFn>>> = Mutex::new(None);
5485
5486#[must_use]
5487pub struct OverrideGuard;
5488
5489impl Drop for OverrideGuard {
5490 fn drop(&mut self) {
5491 info!("restoring override fn");
5492 *CONFIG_OVERRIDE.lock().unwrap() = None;
5493 }
5494}
5495
5496#[cfg(feature = "testing")]
5497static BASE_CONFIG_OVERRIDES: Mutex<Vec<Arc<OverrideFn>>> = Mutex::new(Vec::new());
5498
5499#[cfg(feature = "testing")]
5500#[must_use]
5501pub struct BaseOverrideGuard {
5502 override_fn: Arc<OverrideFn>,
5503}
5504
5505#[cfg(feature = "testing")]
5506impl Drop for BaseOverrideGuard {
5507 fn drop(&mut self) {
5508 BASE_CONFIG_OVERRIDES
5509 .lock()
5510 .unwrap()
5511 .retain(|f| !Arc::ptr_eq(f, &self.override_fn));
5512 }
5513}
5514
5515#[derive(PartialEq, Eq)]
5518pub enum LimitThresholdCrossed {
5519 None,
5520 Soft(u128, u128),
5521 Hard(u128, u128),
5522}
5523
5524pub fn check_limit_in_range<T: Into<V>, U: Into<V>, V: PartialOrd + Into<u128>>(
5527 x: T,
5528 soft_limit: U,
5529 hard_limit: V,
5530) -> LimitThresholdCrossed {
5531 let x: V = x.into();
5532 let soft_limit: V = soft_limit.into();
5533
5534 debug_assert!(soft_limit <= hard_limit);
5535
5536 if x >= hard_limit {
5539 LimitThresholdCrossed::Hard(x.into(), hard_limit.into())
5540 } else if x < soft_limit {
5541 LimitThresholdCrossed::None
5542 } else {
5543 LimitThresholdCrossed::Soft(x.into(), soft_limit.into())
5544 }
5545}
5546
5547#[macro_export]
5548macro_rules! assert_set {
5549 ($protocol_config:expr, $($flag:ident),+ $(,)?) => {{
5550 let protocol_config = $protocol_config;
5551 $(
5552 assert!(
5553 protocol_config.$flag(),
5554 "protocol config flag `{}` must be set",
5555 stringify!($flag),
5556 );
5557 )+
5558 }};
5559}
5560
5561#[macro_export]
5562macro_rules! check_limit {
5563 ($x:expr, $hard:expr) => {
5564 check_limit!($x, $hard, $hard)
5565 };
5566 ($x:expr, $soft:expr, $hard:expr) => {
5567 check_limit_in_range($x as u64, $soft, $hard)
5568 };
5569}
5570
5571#[macro_export]
5575macro_rules! check_limit_by_meter {
5576 ($is_metered:expr, $x:expr, $metered_limit:expr, $unmetered_hard_limit:expr, $metric:expr) => {{
5577 let (h, metered_str) = if $is_metered {
5579 ($metered_limit, "metered")
5580 } else {
5581 ($unmetered_hard_limit, "unmetered")
5583 };
5584 use sui_protocol_config::check_limit_in_range;
5585 let result = check_limit_in_range($x as u64, $metered_limit, h);
5586 match result {
5587 LimitThresholdCrossed::None => {}
5588 LimitThresholdCrossed::Soft(_, _) => {
5589 $metric.with_label_values(&[metered_str, "soft"]).inc();
5590 }
5591 LimitThresholdCrossed::Hard(_, _) => {
5592 $metric.with_label_values(&[metered_str, "hard"]).inc();
5593 }
5594 };
5595 result
5596 }};
5597}
5598
5599pub type Amendments = BTreeMap<AccountAddress, BTreeMap<AccountAddress, AccountAddress>>;
5602
5603static MAINNET_LINKAGE_AMENDMENTS: LazyLock<Arc<Amendments>> =
5604 LazyLock::new(|| parse_amendments(include_str!("mainnet_amendments.json")));
5605
5606static TESTNET_LINKAGE_AMENDMENTS: LazyLock<Arc<Amendments>> =
5607 LazyLock::new(|| parse_amendments(include_str!("testnet_amendments.json")));
5608
5609fn parse_amendments(json: &str) -> Arc<Amendments> {
5610 #[derive(serde::Deserialize)]
5611 struct AmendmentEntry {
5612 root: String,
5613 deps: Vec<DepEntry>,
5614 }
5615
5616 #[derive(serde::Deserialize)]
5617 struct DepEntry {
5618 original_id: String,
5619 version_id: String,
5620 }
5621
5622 let entries: Vec<AmendmentEntry> =
5623 serde_json::from_str(json).expect("Failed to parse amendments JSON");
5624 let mut amendments = BTreeMap::new();
5625 for entry in entries {
5626 let root_id = AccountAddress::from_hex_literal(&entry.root).unwrap();
5627 let mut dep_ids = BTreeMap::new();
5628 for dep in entry.deps {
5629 let orig_id = AccountAddress::from_hex_literal(&dep.original_id).unwrap();
5630 let upgraded_id = AccountAddress::from_hex_literal(&dep.version_id).unwrap();
5631 assert!(
5632 dep_ids.insert(orig_id, upgraded_id).is_none(),
5633 "Duplicate original ID in amendments table"
5634 );
5635 }
5636 assert!(
5637 amendments.insert(root_id, dep_ids).is_none(),
5638 "Duplicate root ID in amendments table"
5639 );
5640 }
5641 Arc::new(amendments)
5642}
5643
5644#[cfg(all(test, not(msim)))]
5645mod test {
5646 use insta::assert_yaml_snapshot;
5647
5648 use super::*;
5649
5650 #[test]
5651 fn snapshot_tests() {
5652 println!("\n============================================================================");
5653 println!("! !");
5654 println!("! IMPORTANT: never update snapshots from this test. only add new versions! !");
5655 println!("! !");
5656 println!("============================================================================\n");
5657 for chain_id in &[Chain::Unknown, Chain::Mainnet, Chain::Testnet] {
5658 let chain_str = match chain_id {
5662 Chain::Unknown => "".to_string(),
5663 _ => format!("{:?}_", chain_id),
5664 };
5665 for i in MIN_PROTOCOL_VERSION..=MAX_PROTOCOL_VERSION {
5666 let cur = ProtocolVersion::new(i);
5667 assert_yaml_snapshot!(
5668 format!("{}version_{}", chain_str, cur.as_u64()),
5669 ProtocolConfig::get_for_version(cur, *chain_id)
5670 );
5671 }
5672 }
5673 }
5674
5675 #[test]
5676 fn binary_format_limits_profile_matches_protocol_version() {
5677 let v141 = ProtocolConfig::get_for_version(ProtocolVersion::new(141), Chain::Unknown);
5678 assert_eq!(
5679 v141.binary_format_limits(),
5680 BinaryFormatLimitsProfile::LEGACY.limits()
5681 );
5682
5683 let v142 = ProtocolConfig::get_for_version(ProtocolVersion::new(142), Chain::Unknown);
5684 assert_eq!(
5685 v142.binary_format_limits(),
5686 BinaryFormatLimitsProfile::V1.limits()
5687 );
5688 }
5689
5690 #[test]
5691 fn test_getters() {
5692 let prot: ProtocolConfig =
5693 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5694 assert_eq!(
5695 prot.max_arguments(),
5696 prot.max_arguments_as_option().unwrap()
5697 );
5698 }
5699
5700 #[test]
5701 fn vector_bulk_native_gas_costs_start_at_version_140() {
5702 for chain in [Chain::Unknown, Chain::Mainnet, Chain::Testnet] {
5703 let before = ProtocolConfig::get_for_version(ProtocolVersion::new(139), chain);
5704 assert_eq!(before.vector_reverse_base_cost_as_option(), None);
5705 assert_eq!(before.vector_reverse_per_elem_cost_as_option(), None);
5706 assert_eq!(before.vector_keep_range_base_cost_as_option(), None);
5707 assert_eq!(
5708 before.vector_keep_range_per_dropped_elem_cost_as_option(),
5709 None
5710 );
5711 assert_eq!(
5712 before.vector_keep_range_per_moved_elem_cost_as_option(),
5713 None
5714 );
5715 assert_eq!(before.vector_copy_range_base_cost_as_option(), None);
5716 assert_eq!(before.vector_replace_range_base_cost_as_option(), None);
5717 assert_eq!(before.vector_replace_range_per_elem_cost_as_option(), None);
5718
5719 let active = ProtocolConfig::get_for_version(ProtocolVersion::new(140), chain);
5720 assert_eq!(active.vector_reverse_base_cost_as_option(), Some(52));
5721 assert_eq!(active.vector_reverse_per_elem_cost_as_option(), Some(8));
5722 assert_eq!(active.vector_keep_range_base_cost_as_option(), Some(52));
5723 assert_eq!(
5724 active.vector_keep_range_per_dropped_elem_cost_as_option(),
5725 Some(1)
5726 );
5727 assert_eq!(
5728 active.vector_keep_range_per_moved_elem_cost_as_option(),
5729 Some(8)
5730 );
5731 assert_eq!(active.vector_copy_range_base_cost_as_option(), Some(52));
5732 assert_eq!(active.vector_replace_range_base_cost_as_option(), Some(52));
5733 assert_eq!(
5734 active.vector_replace_range_per_elem_cost_as_option(),
5735 Some(8)
5736 );
5737 }
5738 }
5739
5740 #[test]
5741 fn test_setters() {
5742 let mut prot: ProtocolConfig =
5743 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5744 prot.set_max_arguments_for_testing(123);
5745 assert_eq!(prot.max_arguments(), 123);
5746
5747 prot.set_max_arguments_from_str_for_testing("321".to_string());
5748 assert_eq!(prot.max_arguments(), 321);
5749
5750 prot.disable_max_arguments_for_testing();
5751 assert_eq!(prot.max_arguments_as_option(), None);
5752
5753 prot.set_attr_for_testing("max_arguments".to_string(), "456".to_string());
5754 assert_eq!(prot.max_arguments(), 456);
5755 }
5756
5757 #[test]
5758 fn test_execution_version_setter_allows_upgrade() {
5759 let mut prot = ProtocolConfig::get_for_max_version_UNSAFE();
5760 let current = prot.execution_version();
5761 prot.set_execution_version_for_testing(current);
5762 prot.set_execution_version_for_testing(current + 1);
5763 assert_eq!(prot.execution_version(), current + 1);
5764 }
5765
5766 #[test]
5767 #[should_panic(expected = "cannot downgrade execution_version")]
5768 fn test_execution_version_setter_panics_on_downgrade() {
5769 let mut prot = ProtocolConfig::get_for_max_version_UNSAFE();
5770 let current = prot.execution_version();
5771 prot.set_execution_version_for_testing(current - 1);
5772 }
5773
5774 #[test]
5775 fn test_feature_flag_setter_by_string() {
5776 let mut prot: ProtocolConfig =
5777 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5778 assert!(!prot.zklogin_auth());
5779 prot.set_feature_flag_for_testing("zklogin_auth".to_string(), true);
5780 assert!(prot.zklogin_auth());
5781 prot.set_feature_flag_for_testing("zklogin_auth".to_string(), false);
5782 assert!(!prot.zklogin_auth());
5783 }
5784
5785 #[test]
5786 #[should_panic(expected = "unknown feature flag")]
5787 fn test_feature_flag_setter_unknown_flag() {
5788 let mut prot: ProtocolConfig =
5789 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5790 prot.set_feature_flag_for_testing("some random string".to_string(), true);
5791 }
5792
5793 #[test]
5794 fn test_get_for_version_if_supported_applies_test_overrides() {
5795 let before =
5796 ProtocolConfig::get_for_version_if_supported(ProtocolVersion::new(1), Chain::Unknown)
5797 .unwrap();
5798
5799 assert!(!before.enable_coin_reservation_obj_refs());
5800
5801 let _guard = ProtocolConfig::apply_overrides_for_testing(|_, mut cfg| {
5802 cfg.enable_coin_reservation_for_testing();
5803 cfg
5804 });
5805
5806 let after =
5807 ProtocolConfig::get_for_version_if_supported(ProtocolVersion::new(1), Chain::Unknown)
5808 .unwrap();
5809
5810 assert!(after.enable_coin_reservation_obj_refs());
5811 }
5812
5813 #[test]
5814 #[should_panic(expected = "unsupported version")]
5815 fn max_version_test() {
5816 let _ = ProtocolConfig::get_for_version_impl(
5819 ProtocolVersion::new(MAX_PROTOCOL_VERSION + 1),
5820 Chain::Unknown,
5821 );
5822 }
5823
5824 #[test]
5825 fn lookup_by_string_test() {
5826 let prot: ProtocolConfig =
5827 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5828 assert!(prot.lookup_attr("some random string".to_string()).is_none());
5830
5831 assert!(
5832 prot.lookup_attr("max_arguments".to_string())
5833 == Some(ProtocolConfigValue::u32(prot.max_arguments())),
5834 );
5835
5836 assert!(
5838 prot.lookup_attr("max_move_identifier_len".to_string())
5839 .is_none()
5840 );
5841
5842 let prot: ProtocolConfig =
5844 ProtocolConfig::get_for_version(ProtocolVersion::new(9), Chain::Unknown);
5845 assert!(
5846 prot.lookup_attr("max_move_identifier_len".to_string())
5847 == Some(ProtocolConfigValue::u64(prot.max_move_identifier_len()))
5848 );
5849
5850 let prot: ProtocolConfig =
5851 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5852 assert!(
5854 prot.attr_map()
5855 .get("max_move_identifier_len")
5856 .unwrap()
5857 .is_none()
5858 );
5859 assert!(
5861 prot.attr_map().get("max_arguments").unwrap()
5862 == &Some(ProtocolConfigValue::u32(prot.max_arguments()))
5863 );
5864
5865 let prot: ProtocolConfig =
5867 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5868 assert!(
5870 prot.feature_flags
5871 .lookup_attr("some random string".to_owned())
5872 .is_none()
5873 );
5874 assert!(
5875 !prot
5876 .feature_flags
5877 .attr_map()
5878 .contains_key("some random string")
5879 );
5880
5881 assert!(
5883 prot.feature_flags
5884 .lookup_attr("package_upgrades".to_owned())
5885 == Some(false)
5886 );
5887 assert!(
5888 prot.feature_flags
5889 .attr_map()
5890 .get("package_upgrades")
5891 .unwrap()
5892 == &false
5893 );
5894 let prot: ProtocolConfig =
5895 ProtocolConfig::get_for_version(ProtocolVersion::new(4), Chain::Unknown);
5896 assert!(
5898 prot.feature_flags
5899 .lookup_attr("package_upgrades".to_owned())
5900 == Some(true)
5901 );
5902 assert!(
5903 prot.feature_flags
5904 .attr_map()
5905 .get("package_upgrades")
5906 .unwrap()
5907 == &true
5908 );
5909 }
5910
5911 #[test]
5912 fn limit_range_fn_test() {
5913 let low = 100u32;
5914 let high = 10000u64;
5915
5916 assert!(check_limit!(1u8, low, high) == LimitThresholdCrossed::None);
5917 assert!(matches!(
5918 check_limit!(255u16, low, high),
5919 LimitThresholdCrossed::Soft(255u128, 100)
5920 ));
5921 assert!(matches!(
5927 check_limit!(2550000u64, low, high),
5928 LimitThresholdCrossed::Hard(2550000, 10000)
5929 ));
5930
5931 assert!(matches!(
5932 check_limit!(2550000u64, high, high),
5933 LimitThresholdCrossed::Hard(2550000, 10000)
5934 ));
5935
5936 assert!(matches!(
5937 check_limit!(1u8, high),
5938 LimitThresholdCrossed::None
5939 ));
5940
5941 assert!(check_limit!(255u16, high) == LimitThresholdCrossed::None);
5942
5943 assert!(matches!(
5944 check_limit!(2550000u64, high),
5945 LimitThresholdCrossed::Hard(2550000, 10000)
5946 ));
5947 }
5948
5949 #[test]
5950 fn linkage_amendments_load() {
5951 let mainnet = LazyLock::force(&MAINNET_LINKAGE_AMENDMENTS);
5952 let testnet = LazyLock::force(&TESTNET_LINKAGE_AMENDMENTS);
5953 assert!(!mainnet.is_empty(), "mainnet amendments must not be empty");
5954 assert!(!testnet.is_empty(), "testnet amendments must not be empty");
5955 }
5956
5957 #[test]
5958 fn render_scalar_fields_use_precision_safe_encoding() {
5959 use mysten_common::rpc_format::Unmetered;
5960
5961 let config = ProtocolConfig::get_for_max_version_UNSAFE();
5962 let rendered = config
5963 .render::<serde_json::Value>(&mut Unmetered)
5964 .expect("render should succeed");
5965
5966 let max_args = rendered
5967 .get("max_arguments")
5968 .expect("max_arguments set at max version");
5969 assert!(
5970 max_args.is_number(),
5971 "u32 should render as number, got {max_args:?}",
5972 );
5973
5974 let max_tx_size = rendered
5975 .get("max_tx_size_bytes")
5976 .expect("max_tx_size_bytes set at max version");
5977 assert!(
5978 max_tx_size.is_string(),
5979 "u64 should render as string, got {max_tx_size:?}",
5980 );
5981 }
5982
5983 #[test]
5984 fn render_includes_non_scalar_gasless_allowlist_as_json() {
5985 use mysten_common::rpc_format::Unmetered;
5986 use serde_json::json;
5987
5988 let mut config = ProtocolConfig::get_for_max_version_UNSAFE();
5989 config.set_gasless_allowed_token_types_for_testing(vec![
5990 ("0xa::usdc::USDC".to_string(), 10_000),
5991 ("0xb::usdt::USDT".to_string(), 0),
5992 ]);
5993
5994 let rendered = config
5995 .render::<serde_json::Value>(&mut Unmetered)
5996 .expect("render should succeed under Unmetered budget");
5997 let allowlist = rendered
5998 .get("gasless_allowed_token_types")
5999 .expect("entry should be present after the testing setter");
6000
6001 assert_eq!(
6004 allowlist,
6005 &json!([["0xa::usdc::USDC", "10000"], ["0xb::usdt::USDT", "0"],]),
6006 );
6007 }
6008
6009 #[test]
6010 fn render_targets_prost_value_for_grpc() {
6011 use mysten_common::rpc_format::Unmetered;
6012 use prost_types::value::Kind;
6013
6014 let mut config = ProtocolConfig::get_for_max_version_UNSAFE();
6015 config.set_gasless_allowed_token_types_for_testing(vec![(
6016 "0xa::usdc::USDC".to_string(),
6017 10_000,
6018 )]);
6019
6020 let rendered = config
6021 .render::<prost_types::Value>(&mut Unmetered)
6022 .expect("render to prost Value should succeed");
6023 let allowlist = rendered
6024 .get("gasless_allowed_token_types")
6025 .expect("entry should be present after the testing setter");
6026
6027 let Some(Kind::ListValue(outer)) = &allowlist.kind else {
6029 panic!(
6030 "expected ListValue at the top level, got {:?}",
6031 allowlist.kind
6032 );
6033 };
6034 assert_eq!(outer.values.len(), 1, "one allowlisted entry");
6035 let Some(Kind::ListValue(entry)) = &outer.values[0].kind else {
6036 panic!("expected each entry to be a ListValue");
6037 };
6038 assert_eq!(entry.values.len(), 2, "entry has (coin_type, amount)");
6039
6040 let Some(Kind::StringValue(coin_type)) = &entry.values[0].kind else {
6041 panic!("expected coin_type as StringValue");
6042 };
6043 assert_eq!(coin_type, "0xa::usdc::USDC");
6044
6045 let Some(Kind::StringValue(amount)) = &entry.values[1].kind else {
6047 panic!(
6048 "expected minimum_transfer_amount as StringValue (precision-safe u64); got {:?}",
6049 entry.values[1].kind,
6050 );
6051 };
6052 assert_eq!(amount, "10000");
6053 }
6054
6055 #[test]
6056 fn render_emits_null_for_unset_protocol_versions() {
6057 use mysten_common::rpc_format::Unmetered;
6058
6059 let config = ProtocolConfig::get_for_version(1.into(), Chain::Unknown);
6060 let rendered = config
6061 .render::<serde_json::Value>(&mut Unmetered)
6062 .expect("render should succeed");
6063 let entry = rendered
6067 .get("gasless_allowed_token_types")
6068 .expect("key should be present for every protocol version");
6069 assert!(
6070 entry.is_null(),
6071 "value should be null for pre-feature protocol version, got {entry:?}",
6072 );
6073 }
6074}