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, TableConfig},
18 file_format_common::VERSION_1,
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 = 140;
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)]
431pub struct ProtocolVersion(u64);
432
433impl ProtocolVersion {
434 pub const MIN: Self = Self(MIN_PROTOCOL_VERSION);
439
440 pub const MAX: Self = Self(MAX_PROTOCOL_VERSION);
441
442 #[cfg(not(msim))]
443 pub const MAX_ALLOWED: Self = Self::MAX;
444
445 #[cfg(msim)]
447 pub const MAX_ALLOWED: Self = Self(MAX_PROTOCOL_VERSION + 1);
448
449 pub fn new(v: u64) -> Self {
450 Self(v)
451 }
452
453 pub const fn as_u64(&self) -> u64 {
454 self.0
455 }
456
457 pub fn max() -> Self {
460 Self::MAX
461 }
462
463 pub fn prev(self) -> Self {
464 Self(self.0.checked_sub(1).unwrap())
465 }
466}
467
468impl From<u64> for ProtocolVersion {
469 fn from(v: u64) -> Self {
470 Self::new(v)
471 }
472}
473
474impl std::ops::Sub<u64> for ProtocolVersion {
475 type Output = Self;
476 fn sub(self, rhs: u64) -> Self::Output {
477 Self::new(self.0 - rhs)
478 }
479}
480
481impl std::ops::Add<u64> for ProtocolVersion {
482 type Output = Self;
483 fn add(self, rhs: u64) -> Self::Output {
484 Self::new(self.0 + rhs)
485 }
486}
487
488#[derive(
489 Clone, Serialize, Deserialize, Debug, Default, PartialEq, Copy, PartialOrd, Ord, Eq, ValueEnum,
490)]
491pub enum Chain {
492 Mainnet,
493 Testnet,
494 #[default]
495 Unknown,
496}
497
498impl Chain {
499 pub fn as_str(self) -> &'static str {
500 match self {
501 Chain::Mainnet => "mainnet",
502 Chain::Testnet => "testnet",
503 Chain::Unknown => "unknown",
504 }
505 }
506}
507
508pub struct Error(pub String);
509
510#[derive(Default, Clone, Serialize, Deserialize, Debug, ProtocolConfigFeatureFlagsGetters)]
513struct FeatureFlags {
514 #[serde(skip_serializing_if = "is_false")]
517 package_upgrades: bool,
518 #[serde(skip_serializing_if = "is_false")]
521 commit_root_state_digest: bool,
522 #[serde(skip_serializing_if = "is_false")]
524 advance_epoch_start_time_in_safe_mode: bool,
525 #[serde(skip_serializing_if = "is_false")]
528 loaded_child_objects_fixed: bool,
529 #[serde(skip_serializing_if = "is_false")]
532 missing_type_is_compatibility_error: bool,
533 #[serde(skip_serializing_if = "is_false")]
536 scoring_decision_with_validity_cutoff: bool,
537
538 #[serde(skip_serializing_if = "is_false")]
541 consensus_order_end_of_epoch_last: bool,
542
543 #[serde(skip_serializing_if = "is_false")]
547 consensus_slim_block_propagation: bool,
548
549 #[serde(skip_serializing_if = "is_false")]
551 disallow_adding_abilities_on_upgrade: bool,
552 #[serde(skip_serializing_if = "is_false")]
554 disable_invariant_violation_check_in_swap_loc: bool,
555 #[serde(skip_serializing_if = "is_false")]
558 advance_to_highest_supported_protocol_version: bool,
559 #[serde(skip_serializing_if = "is_false")]
561 ban_entry_init: bool,
562 #[serde(skip_serializing_if = "is_false")]
564 package_digest_hash_module: bool,
565 #[serde(skip_serializing_if = "is_false")]
567 disallow_change_struct_type_params_on_upgrade: bool,
568 #[serde(skip_serializing_if = "is_false")]
570 no_extraneous_module_bytes: bool,
571 #[serde(skip_serializing_if = "is_false")]
573 narwhal_versioned_metadata: bool,
574
575 #[serde(skip_serializing_if = "is_false")]
577 zklogin_auth: bool,
578 #[serde(skip_serializing_if = "is_zero")]
581 zklogin_circuit_mode: u64,
582 #[serde(skip_serializing_if = "ConsensusTransactionOrdering::is_none")]
584 consensus_transaction_ordering: ConsensusTransactionOrdering,
585
586 #[serde(skip_serializing_if = "is_false")]
594 simplified_unwrap_then_delete: bool,
595 #[serde(skip_serializing_if = "is_false")]
597 upgraded_multisig_supported: bool,
598 #[serde(skip_serializing_if = "is_false")]
600 txn_base_cost_as_multiplier: bool,
601
602 #[serde(skip_serializing_if = "is_false")]
604 shared_object_deletion: bool,
605
606 #[serde(skip_serializing_if = "is_false")]
608 narwhal_new_leader_election_schedule: bool,
609
610 #[serde(skip_serializing_if = "is_empty")]
612 zklogin_supported_providers: BTreeSet<String>,
613
614 #[serde(skip_serializing_if = "is_false")]
616 loaded_child_object_format: bool,
617
618 #[serde(skip_serializing_if = "is_false")]
619 #[skip_protocol_config_accessor]
620 enable_jwk_consensus_updates: bool,
621
622 #[serde(skip_serializing_if = "is_false")]
623 #[skip_protocol_config_accessor]
624 end_of_epoch_transaction_supported: bool,
625
626 #[serde(skip_serializing_if = "is_false")]
629 simple_conservation_checks: bool,
630
631 #[serde(skip_serializing_if = "is_false")]
633 loaded_child_object_format_type: bool,
634
635 #[serde(skip_serializing_if = "is_false")]
637 receive_objects: bool,
638
639 #[serde(skip_serializing_if = "is_false")]
641 consensus_checkpoint_signature_key_includes_digest: bool,
642
643 #[serde(skip_serializing_if = "is_false")]
645 random_beacon: bool,
646
647 #[serde(skip_serializing_if = "is_false")]
649 #[skip_protocol_config_accessor]
650 bridge: bool,
651
652 #[serde(skip_serializing_if = "is_false")]
653 enable_effects_v2: bool,
654
655 #[serde(skip_serializing_if = "is_false")]
657 narwhal_certificate_v2: bool,
658
659 #[serde(skip_serializing_if = "is_false")]
661 verify_legacy_zklogin_address: bool,
662
663 #[serde(skip_serializing_if = "is_false")]
665 throughput_aware_consensus_submission: bool,
666
667 #[serde(skip_serializing_if = "is_false")]
669 recompute_has_public_transfer_in_execution: bool,
670
671 #[serde(skip_serializing_if = "is_false")]
673 accept_zklogin_in_multisig: bool,
674
675 #[serde(skip_serializing_if = "is_false")]
677 accept_passkey_in_multisig: bool,
678
679 #[serde(skip_serializing_if = "is_false")]
681 validate_zklogin_public_identifier: bool,
682
683 #[serde(skip_serializing_if = "is_false")]
686 include_consensus_digest_in_prologue: bool,
687
688 #[serde(skip_serializing_if = "is_false")]
690 hardened_otw_check: bool,
691
692 #[serde(skip_serializing_if = "is_false")]
694 allow_receiving_object_id: bool,
695
696 #[serde(skip_serializing_if = "is_false")]
698 enable_poseidon: bool,
699
700 #[serde(skip_serializing_if = "is_false")]
702 enable_coin_deny_list: bool,
703
704 #[serde(skip_serializing_if = "is_false")]
706 enable_group_ops_native_functions: bool,
707
708 #[serde(skip_serializing_if = "is_false")]
710 enable_group_ops_native_function_msm: bool,
711
712 #[serde(skip_serializing_if = "is_false")]
714 enable_ristretto255_group_ops: bool,
715
716 #[serde(skip_serializing_if = "is_false")]
718 enable_verify_bulletproofs_ristretto255: bool,
719
720 #[serde(skip_serializing_if = "is_false")]
722 enable_nitro_attestation: bool,
723
724 #[serde(skip_serializing_if = "is_false")]
726 enable_nitro_attestation_upgraded_parsing: bool,
727
728 #[serde(skip_serializing_if = "is_false")]
730 enable_nitro_attestation_all_nonzero_pcrs_parsing: bool,
731
732 #[serde(skip_serializing_if = "is_false")]
734 enable_nitro_attestation_always_include_required_pcrs_parsing: bool,
735
736 #[serde(skip_serializing_if = "is_false")]
738 reject_mutable_random_on_entry_functions: bool,
739
740 #[serde(skip_serializing_if = "PerObjectCongestionControlMode::is_none")]
742 per_object_congestion_control_mode: PerObjectCongestionControlMode,
743
744 #[serde(skip_serializing_if = "ConsensusChoice::is_narwhal")]
746 consensus_choice: ConsensusChoice,
747
748 #[serde(skip_serializing_if = "ConsensusNetwork::is_anemo")]
750 consensus_network: ConsensusNetwork,
751
752 #[serde(skip_serializing_if = "is_false")]
754 correct_gas_payment_limit_check: bool,
755
756 #[serde(skip_serializing_if = "Option::is_none")]
758 zklogin_max_epoch_upper_bound_delta: Option<u64>,
759
760 #[serde(skip_serializing_if = "is_false")]
762 mysticeti_leader_scoring_and_schedule: bool,
763
764 #[serde(skip_serializing_if = "is_false")]
766 reshare_at_same_initial_version: bool,
767
768 #[serde(skip_serializing_if = "is_false")]
770 resolve_abort_locations_to_package_id: bool,
771
772 #[serde(skip_serializing_if = "is_false")]
776 mysticeti_use_committed_subdag_digest: bool,
777
778 #[serde(skip_serializing_if = "is_false")]
780 enable_vdf: bool,
781
782 #[serde(skip_serializing_if = "is_false")]
786 record_consensus_determined_version_assignments_in_prologue: bool,
787 #[serde(skip_serializing_if = "is_false")]
790 record_consensus_determined_version_assignments_in_prologue_v2: bool,
791
792 #[serde(skip_serializing_if = "is_false")]
794 fresh_vm_on_framework_upgrade: bool,
795
796 #[serde(skip_serializing_if = "is_false")]
804 prepend_prologue_tx_in_consensus_commit_in_checkpoints: bool,
805
806 #[serde(skip_serializing_if = "Option::is_none")]
808 mysticeti_num_leaders_per_round: Option<usize>,
809
810 #[serde(skip_serializing_if = "is_false")]
812 soft_bundle: bool,
813
814 #[serde(skip_serializing_if = "is_false")]
816 enable_coin_deny_list_v2: bool,
817
818 #[serde(skip_serializing_if = "is_false")]
820 passkey_auth: bool,
821
822 #[serde(skip_serializing_if = "is_false")]
825 mldsa65_auth: bool,
826
827 #[serde(skip_serializing_if = "is_false")]
829 authority_capabilities_v2: bool,
830
831 #[serde(skip_serializing_if = "is_false")]
833 rethrow_serialization_type_layout_errors: bool,
834
835 #[serde(skip_serializing_if = "is_false")]
837 consensus_distributed_vote_scoring_strategy: bool,
838
839 #[serde(skip_serializing_if = "is_false")]
841 consensus_round_prober: bool,
842
843 #[serde(skip_serializing_if = "is_false")]
845 validate_identifier_inputs: bool,
846
847 #[serde(skip_serializing_if = "is_false")]
849 disallow_self_identifier: bool,
850
851 #[serde(skip_serializing_if = "is_false")]
853 mysticeti_fastpath: bool,
854
855 #[serde(skip_serializing_if = "is_false")]
859 disable_preconsensus_locking: bool,
860
861 #[serde(skip_serializing_if = "is_false")]
863 relocate_event_module: bool,
864
865 #[serde(skip_serializing_if = "is_false")]
867 uncompressed_g1_group_elements: bool,
868
869 #[serde(skip_serializing_if = "is_false")]
870 disallow_new_modules_in_deps_only_packages: bool,
871
872 #[serde(skip_serializing_if = "is_false")]
874 consensus_smart_ancestor_selection: bool,
875
876 #[serde(skip_serializing_if = "is_false")]
878 consensus_round_prober_probe_accepted_rounds: bool,
879
880 #[serde(skip_serializing_if = "is_false")]
882 native_charging_v2: bool,
883
884 #[serde(skip_serializing_if = "is_false")]
887 #[skip_protocol_config_accessor]
888 consensus_linearize_subdag_v2: bool,
889
890 #[serde(skip_serializing_if = "is_false")]
892 convert_type_argument_error: bool,
893
894 #[serde(skip_serializing_if = "is_false")]
896 variant_nodes: bool,
897
898 #[serde(skip_serializing_if = "is_false")]
900 consensus_zstd_compression: bool,
901
902 #[serde(skip_serializing_if = "is_false")]
904 minimize_child_object_mutations: bool,
905
906 #[serde(skip_serializing_if = "is_false")]
909 record_additional_state_digest_in_prologue: bool,
910
911 #[serde(skip_serializing_if = "is_false")]
913 move_native_context: bool,
914
915 #[serde(skip_serializing_if = "is_false")]
918 #[skip_protocol_config_accessor]
919 consensus_median_based_commit_timestamp: bool,
920
921 #[serde(skip_serializing_if = "is_false")]
924 normalize_ptb_arguments: bool,
925
926 #[serde(skip_serializing_if = "is_false")]
928 consensus_batched_block_sync: bool,
929
930 #[serde(skip_serializing_if = "is_false")]
932 enforce_checkpoint_timestamp_monotonicity: bool,
933
934 #[serde(skip_serializing_if = "is_false")]
936 max_ptb_value_size_v2: bool,
937
938 #[serde(skip_serializing_if = "is_false")]
940 resolve_type_input_ids_to_defining_id: bool,
941
942 #[serde(skip_serializing_if = "is_false")]
944 enable_party_transfer: bool,
945
946 #[serde(skip_serializing_if = "is_false")]
948 allow_unbounded_system_objects: bool,
949
950 #[serde(skip_serializing_if = "is_false")]
952 type_tags_in_object_runtime: bool,
953
954 #[serde(skip_serializing_if = "is_false")]
956 enable_accumulators: bool,
957
958 #[serde(skip_serializing_if = "is_false")]
960 #[skip_protocol_config_accessor]
961 enable_coin_reservation_obj_refs: bool,
962
963 #[serde(skip_serializing_if = "is_false")]
966 create_root_accumulator_object: bool,
967
968 #[serde(skip_serializing_if = "is_false")]
970 #[skip_protocol_config_accessor]
971 enable_authenticated_event_streams: bool,
972
973 #[serde(skip_serializing_if = "is_false")]
975 enable_address_balance_gas_payments: bool,
976
977 #[serde(skip_serializing_if = "is_false")]
979 address_balance_gas_check_rgp_at_signing: bool,
980
981 #[serde(skip_serializing_if = "is_false")]
982 address_balance_gas_reject_gas_coin_arg: bool,
983
984 #[serde(skip_serializing_if = "is_false")]
986 enable_multi_epoch_transaction_expiration: bool,
987
988 #[serde(skip_serializing_if = "is_false")]
990 relax_valid_during_for_owned_inputs: bool,
991
992 #[serde(skip_serializing_if = "is_false")]
994 enable_ptb_execution_v2: bool,
995
996 #[serde(skip_serializing_if = "is_false")]
998 better_adapter_type_resolution_errors: bool,
999
1000 #[serde(skip_serializing_if = "is_false")]
1002 record_time_estimate_processed: bool,
1003
1004 #[serde(skip_serializing_if = "is_false")]
1006 dependency_linkage_error: bool,
1007
1008 #[serde(skip_serializing_if = "is_false")]
1010 additional_multisig_checks: bool,
1011
1012 #[serde(skip_serializing_if = "is_false")]
1014 ignore_execution_time_observations_after_certs_closed: bool,
1015
1016 #[serde(skip_serializing_if = "is_false")]
1020 debug_fatal_on_move_invariant_violation: bool,
1021
1022 #[serde(skip_serializing_if = "is_false")]
1025 allow_private_accumulator_entrypoints: bool,
1026
1027 #[serde(skip_serializing_if = "is_false")]
1030 additional_consensus_digest_indirect_state: bool,
1031
1032 #[serde(skip_serializing_if = "is_false")]
1034 check_for_init_during_upgrade: bool,
1035
1036 #[serde(skip_serializing_if = "is_false")]
1038 enable_init_on_upgrade: bool,
1039
1040 #[serde(skip_serializing_if = "is_false")]
1042 enable_order_independent_upgrade_init_linkage: bool,
1043
1044 #[serde(skip_serializing_if = "is_false")]
1047 harden_linkage_consistency: bool,
1048
1049 #[serde(skip_serializing_if = "is_false")]
1051 per_command_shared_object_transfer_rules: bool,
1052
1053 #[serde(skip_serializing_if = "is_false")]
1055 validate_ptb_argument_indices: bool,
1056
1057 #[serde(skip_serializing_if = "is_false")]
1059 include_checkpoint_artifacts_digest_in_summary: bool,
1060
1061 #[serde(skip_serializing_if = "is_false")]
1063 use_mfp_txns_in_load_initial_object_debts: bool,
1064
1065 #[serde(skip_serializing_if = "is_false")]
1067 cancel_for_failed_dkg_early: bool,
1068
1069 #[serde(skip_serializing_if = "is_false")]
1071 always_advance_dkg_to_resolution: bool,
1072
1073 #[serde(skip_serializing_if = "is_false")]
1075 allow_dkg_completion_after_timeout: bool,
1076
1077 #[serde(skip_serializing_if = "is_false")]
1079 enable_coin_registry: bool,
1080
1081 #[serde(skip_serializing_if = "is_false")]
1083 abstract_size_in_object_runtime: bool,
1084
1085 #[serde(skip_serializing_if = "is_false")]
1087 object_runtime_charge_cache_load_gas: bool,
1088
1089 #[serde(skip_serializing_if = "is_false")]
1091 additional_borrow_checks: bool,
1092
1093 #[serde(skip_serializing_if = "is_false")]
1095 use_new_commit_handler: bool,
1096
1097 #[serde(skip_serializing_if = "is_false")]
1099 better_loader_errors: bool,
1100
1101 #[serde(skip_serializing_if = "is_false")]
1103 generate_df_type_layouts: bool,
1104
1105 #[serde(skip_serializing_if = "is_false")]
1107 allow_references_in_ptbs: bool,
1108
1109 #[serde(skip_serializing_if = "is_false")]
1116 framework_tx_context_mut_restrictions: bool,
1117
1118 #[serde(skip_serializing_if = "is_false")]
1120 include_function_signatures_in_instantiation_limits: bool,
1121
1122 #[serde(skip_serializing_if = "is_false")]
1127 ptb_tx_context_restrictions: bool,
1128
1129 #[serde(skip_serializing_if = "is_false")]
1131 enable_display_registry: bool,
1132
1133 #[serde(skip_serializing_if = "is_false")]
1135 private_generics_verifier_v2: bool,
1136
1137 #[serde(skip_serializing_if = "is_false")]
1139 deprecate_global_storage_ops_during_deserialization: bool,
1140
1141 #[serde(skip_serializing_if = "is_false")]
1144 enable_non_exclusive_writes: bool,
1145
1146 #[serde(skip_serializing_if = "is_false")]
1148 deprecate_global_storage_ops: bool,
1149
1150 #[serde(skip_serializing_if = "is_false")]
1152 normalize_depth_formula: bool,
1153
1154 #[serde(skip_serializing_if = "is_false")]
1157 charge_ld_const_abstract_size: bool,
1158
1159 #[serde(skip_serializing_if = "is_false")]
1161 consensus_skip_gced_accept_votes: bool,
1162
1163 #[serde(skip_serializing_if = "is_false")]
1166 include_cancelled_randomness_txns_in_prologue: bool,
1167
1168 #[serde(skip_serializing_if = "is_false")]
1170 #[skip_protocol_config_accessor]
1171 address_aliases: bool,
1172
1173 #[serde(skip_serializing_if = "is_false")]
1175 create_forwarding_address_registry: bool,
1176
1177 #[serde(skip_serializing_if = "is_false")]
1179 enable_forwarding_addresses: bool,
1180
1181 #[serde(skip_serializing_if = "is_false")]
1184 fix_checkpoint_signature_mapping: bool,
1185
1186 #[serde(skip_serializing_if = "is_false")]
1188 enable_object_funds_withdraw: bool,
1189
1190 #[serde(skip_serializing_if = "is_false")]
1193 record_net_unsettled_object_withdraws: bool,
1194
1195 #[serde(skip_serializing_if = "is_false")]
1197 consensus_skip_gced_blocks_in_direct_finalization: bool,
1198
1199 #[serde(skip_serializing_if = "is_false")]
1201 gas_rounding_halve_digits: bool,
1202
1203 #[serde(skip_serializing_if = "is_false")]
1205 flexible_tx_context_positions: bool,
1206
1207 #[serde(skip_serializing_if = "is_false")]
1209 disable_entry_point_signature_check: bool,
1210
1211 #[serde(skip_serializing_if = "is_false")]
1213 convert_withdrawal_compatibility_ptb_arguments: bool,
1214
1215 #[serde(skip_serializing_if = "is_false")]
1217 restrict_hot_or_not_entry_functions: bool,
1218
1219 #[serde(skip_serializing_if = "is_false")]
1221 split_checkpoints_in_consensus_handler: bool,
1222
1223 #[serde(skip_serializing_if = "is_false")]
1225 consensus_always_accept_system_transactions: bool,
1226
1227 #[serde(skip_serializing_if = "is_false")]
1229 validator_metadata_verify_v2: bool,
1230
1231 #[serde(skip_serializing_if = "is_false")]
1234 defer_unpaid_amplification: bool,
1235
1236 #[serde(skip_serializing_if = "is_false")]
1239 defer_owned_object_double_spend: bool,
1240
1241 #[serde(skip_serializing_if = "is_false")]
1244 allowed_proposers: bool,
1245
1246 #[serde(skip_serializing_if = "is_false")]
1252 #[skip_protocol_config_accessor]
1253 staggered_submission_signal: bool,
1254
1255 #[serde(skip_serializing_if = "is_false")]
1256 randomize_checkpoint_tx_limit_in_tests: bool,
1257
1258 #[serde(skip_serializing_if = "is_false")]
1260 gasless_transaction_drop_safety: bool,
1261
1262 #[serde(skip_serializing_if = "is_false")]
1265 merge_randomness_into_checkpoint: bool,
1266
1267 #[serde(skip_serializing_if = "is_false")]
1269 use_coin_party_owner: bool,
1270
1271 #[serde(skip_serializing_if = "is_false")]
1272 enable_gasless: bool,
1273
1274 #[serde(skip_serializing_if = "is_false")]
1275 gasless_verify_remaining_balance: bool,
1276
1277 #[serde(skip_serializing_if = "is_false")]
1278 disallow_jump_orphans: bool,
1279
1280 #[serde(skip_serializing_if = "is_false")]
1282 early_return_receive_object_mismatched_type: bool,
1283
1284 #[serde(skip_serializing_if = "is_false")]
1289 timestamp_based_epoch_close: bool,
1290
1291 #[serde(skip_serializing_if = "is_false")]
1294 limit_groth16_pvk_inputs: bool,
1295
1296 #[serde(skip_serializing_if = "is_false")]
1301 enforce_address_balance_change_invariant: bool,
1302
1303 #[serde(skip_serializing_if = "is_false")]
1305 share_transaction_deny_config_in_consensus: bool,
1306
1307 #[serde(skip_serializing_if = "is_false")]
1309 granular_post_execution_checks: bool,
1310
1311 #[serde(skip_serializing_if = "is_false")]
1313 early_exit_on_iffw: bool,
1314
1315 #[serde(skip_serializing_if = "is_false")]
1317 enable_unified_linkage: bool,
1318
1319 #[serde(skip_serializing_if = "is_false")]
1322 #[skip_protocol_config_accessor]
1323 enable_allowances: bool,
1324
1325 #[serde(skip_serializing_if = "is_false")]
1327 fix_ptb_generated_reads: bool,
1328
1329 #[serde(skip_serializing_if = "is_false")]
1330 check_object_funds_withdraw_in_execution: bool,
1331 #[serde(skip_serializing_if = "is_false")]
1333 memory_safety_invariant_check_v2: bool,
1334
1335 #[serde(skip_serializing_if = "is_false")]
1337 disable_effects_tx_dependencies: bool,
1338
1339 #[serde(skip_serializing_if = "is_false")]
1343 merge_colliding_deferrals: bool,
1344
1345 #[serde(skip_serializing_if = "is_false")]
1349 shuffle_consensus_commit_blocks: bool,
1350
1351 #[serde(skip_serializing_if = "is_false")]
1354 disable_id_leak_verifier: bool,
1355}
1356
1357fn is_false(b: &bool) -> bool {
1358 !b
1359}
1360
1361fn is_empty(b: &BTreeSet<String>) -> bool {
1362 b.is_empty()
1363}
1364
1365fn is_zero(val: &u64) -> bool {
1366 *val == 0
1367}
1368
1369#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1371pub enum ConsensusTransactionOrdering {
1372 #[default]
1374 None,
1375 ByGasPrice,
1377}
1378
1379impl ConsensusTransactionOrdering {
1380 pub fn is_none(&self) -> bool {
1381 matches!(self, ConsensusTransactionOrdering::None)
1382 }
1383}
1384
1385#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1386pub struct ExecutionTimeEstimateParams {
1387 pub target_utilization: u64,
1389 pub allowed_txn_cost_overage_burst_limit_us: u64,
1393
1394 pub randomness_scalar: u64,
1397
1398 pub max_estimate_us: u64,
1400
1401 pub stored_observations_num_included_checkpoints: u64,
1404
1405 pub stored_observations_limit: u64,
1407
1408 #[serde(skip_serializing_if = "is_zero")]
1411 pub stake_weighted_median_threshold: u64,
1412
1413 #[serde(skip_serializing_if = "is_false")]
1417 pub default_none_duration_for_new_keys: bool,
1418
1419 #[serde(skip_serializing_if = "Option::is_none")]
1421 pub observations_chunk_size: Option<u64>,
1422}
1423
1424#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1426pub enum PerObjectCongestionControlMode {
1427 #[default]
1428 None, TotalGasBudget, TotalTxCount, TotalGasBudgetWithCap, ExecutionTimeEstimate(ExecutionTimeEstimateParams), }
1434
1435impl PerObjectCongestionControlMode {
1436 pub fn is_none(&self) -> bool {
1437 matches!(self, PerObjectCongestionControlMode::None)
1438 }
1439}
1440
1441#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1443pub enum ConsensusChoice {
1444 #[default]
1445 Narwhal,
1446 SwapEachEpoch,
1447 Mysticeti,
1448}
1449
1450impl ConsensusChoice {
1451 pub fn is_narwhal(&self) -> bool {
1452 matches!(self, ConsensusChoice::Narwhal)
1453 }
1454}
1455
1456#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1458pub enum ConsensusNetwork {
1459 #[default]
1460 Anemo,
1461 Tonic,
1462}
1463
1464impl ConsensusNetwork {
1465 pub fn is_anemo(&self) -> bool {
1466 matches!(self, ConsensusNetwork::Anemo)
1467 }
1468}
1469
1470#[skip_serializing_none]
1502#[derive(Clone, Serialize, Debug, ProtocolConfigAccessors, ProtocolConfigOverride)]
1503pub struct ProtocolConfig {
1504 pub version: ProtocolVersion,
1505
1506 #[serde(skip)]
1511 chain: Chain,
1512
1513 feature_flags: FeatureFlags,
1514
1515 max_tx_size_bytes: Option<u64>,
1518
1519 max_input_objects: Option<u64>,
1521
1522 max_size_written_objects: Option<u64>,
1526 max_size_written_objects_system_tx: Option<u64>,
1529
1530 max_serialized_tx_effects_size_bytes: Option<u64>,
1532
1533 max_serialized_tx_effects_size_bytes_system_tx: Option<u64>,
1535
1536 max_gas_payment_objects: Option<u32>,
1538
1539 max_modules_in_publish: Option<u32>,
1541
1542 max_package_dependencies: Option<u32>,
1544
1545 max_arguments: Option<u32>,
1548
1549 max_type_arguments: Option<u32>,
1551
1552 max_type_argument_depth: Option<u32>,
1554
1555 max_pure_argument_size: Option<u32>,
1557
1558 max_programmable_tx_commands: Option<u32>,
1560
1561 move_binary_format_version: Option<u32>,
1564 min_move_binary_format_version: Option<u32>,
1565
1566 binary_module_handles: Option<u16>,
1568 binary_struct_handles: Option<u16>,
1569 binary_function_handles: Option<u16>,
1570 binary_function_instantiations: Option<u16>,
1571 binary_signatures: Option<u16>,
1572 binary_constant_pool: Option<u16>,
1573 binary_identifiers: Option<u16>,
1574 binary_address_identifiers: Option<u16>,
1575 binary_struct_defs: Option<u16>,
1576 binary_struct_def_instantiations: Option<u16>,
1577 binary_function_defs: Option<u16>,
1578 binary_field_handles: Option<u16>,
1579 binary_field_instantiations: Option<u16>,
1580 binary_friend_decls: Option<u16>,
1581 binary_enum_defs: Option<u16>,
1582 binary_enum_def_instantiations: Option<u16>,
1583 binary_variant_handles: Option<u16>,
1584 binary_variant_instantiation_handles: Option<u16>,
1585
1586 max_move_object_size: Option<u64>,
1588
1589 max_move_package_size: Option<u64>,
1592
1593 max_publish_or_upgrade_per_ptb: Option<u64>,
1595
1596 max_tx_gas: Option<u64>,
1598
1599 max_gas_price: Option<u64>,
1601
1602 max_gas_price_rgp_factor_for_aborted_transactions: Option<u64>,
1605
1606 max_gas_computation_bucket: Option<u64>,
1608
1609 gas_rounding_step: Option<u64>,
1611
1612 max_loop_depth: Option<u64>,
1614
1615 max_generic_instantiation_length: Option<u64>,
1617
1618 max_function_parameters: Option<u64>,
1620
1621 max_basic_blocks: Option<u64>,
1623
1624 max_value_stack_size: Option<u64>,
1626
1627 max_type_nodes: Option<u64>,
1629
1630 max_generic_instantiation_type_nodes_per_function: Option<u64>,
1632
1633 max_generic_instantiation_type_nodes_per_module: Option<u64>,
1635
1636 max_accumulator_type_nodes: Option<u64>,
1638
1639 max_push_size: Option<u64>,
1641
1642 max_struct_definitions: Option<u64>,
1644
1645 max_function_definitions: Option<u64>,
1647
1648 max_fields_in_struct: Option<u64>,
1650
1651 max_dependency_depth: Option<u64>,
1653
1654 max_num_event_emit: Option<u64>,
1656
1657 max_num_new_move_object_ids: Option<u64>,
1659
1660 max_num_new_move_object_ids_system_tx: Option<u64>,
1662
1663 max_num_deleted_move_object_ids: Option<u64>,
1665
1666 max_num_deleted_move_object_ids_system_tx: Option<u64>,
1668
1669 max_num_transferred_move_object_ids: Option<u64>,
1671
1672 max_num_transferred_move_object_ids_system_tx: Option<u64>,
1674
1675 max_event_emit_size: Option<u64>,
1677
1678 max_event_emit_size_total: Option<u64>,
1680
1681 max_move_vector_len: Option<u64>,
1683
1684 max_move_identifier_len: Option<u64>,
1686
1687 max_move_value_depth: Option<u64>,
1689
1690 package_arena_size_in_bytes: Option<u64>,
1693
1694 max_move_enum_variants: Option<u64>,
1696
1697 max_back_edges_per_function: Option<u64>,
1699
1700 max_back_edges_per_module: Option<u64>,
1702
1703 max_verifier_meter_ticks_per_function: Option<u64>,
1705
1706 max_meter_ticks_per_module: Option<u64>,
1708
1709 max_meter_ticks_per_package: Option<u64>,
1711
1712 object_runtime_max_num_cached_objects: Option<u64>,
1716
1717 object_runtime_max_num_cached_objects_system_tx: Option<u64>,
1719
1720 object_runtime_max_num_store_entries: Option<u64>,
1722
1723 object_runtime_max_num_store_entries_system_tx: Option<u64>,
1725
1726 base_tx_cost_fixed: Option<u64>,
1729
1730 package_publish_cost_fixed: Option<u64>,
1733
1734 base_tx_cost_per_byte: Option<u64>,
1737
1738 package_publish_cost_per_byte: Option<u64>,
1740
1741 obj_access_cost_read_per_byte: Option<u64>,
1743
1744 obj_access_cost_read_per_package_kb: Option<u64>,
1747
1748 obj_access_cost_mutate_per_byte: Option<u64>,
1750
1751 obj_access_cost_delete_per_byte: Option<u64>,
1753
1754 obj_access_cost_verify_per_byte: Option<u64>,
1764
1765 max_type_to_layout_nodes: Option<u64>,
1767
1768 max_ptb_value_size: Option<u64>,
1770
1771 gas_model_version: Option<u64>,
1774
1775 obj_data_cost_refundable: Option<u64>,
1778
1779 obj_metadata_cost_non_refundable: Option<u64>,
1783
1784 storage_rebate_rate: Option<u64>,
1790
1791 storage_fund_reinvest_rate: Option<u64>,
1794
1795 reward_slashing_rate: Option<u64>,
1798
1799 storage_gas_price: Option<u64>,
1801
1802 accumulator_object_storage_cost: Option<u64>,
1804
1805 max_transactions_per_checkpoint: Option<u64>,
1810
1811 max_checkpoint_size_bytes: Option<u64>,
1815
1816 buffer_stake_for_protocol_upgrade_bps: Option<u64>,
1821
1822 address_from_bytes_cost_base: Option<u64>,
1827 address_to_u256_cost_base: Option<u64>,
1829 address_from_u256_cost_base: Option<u64>,
1831
1832 config_read_setting_impl_cost_base: Option<u64>,
1837 config_read_setting_impl_cost_per_byte: Option<u64>,
1838
1839 package_original_package_id_impl_cost_base: Option<u64>,
1840 package_original_package_id_impl_cost_per_byte: Option<u64>,
1841
1842 dynamic_field_hash_type_and_key_cost_base: Option<u64>,
1845 dynamic_field_hash_type_and_key_type_cost_per_byte: Option<u64>,
1846 dynamic_field_hash_type_and_key_value_cost_per_byte: Option<u64>,
1847 dynamic_field_hash_type_and_key_type_tag_cost_per_byte: Option<u64>,
1848 dynamic_field_add_child_object_cost_base: Option<u64>,
1850 dynamic_field_add_child_object_type_cost_per_byte: Option<u64>,
1851 dynamic_field_add_child_object_value_cost_per_byte: Option<u64>,
1852 dynamic_field_add_child_object_struct_tag_cost_per_byte: Option<u64>,
1853 dynamic_field_borrow_child_object_cost_base: Option<u64>,
1855 dynamic_field_borrow_child_object_child_ref_cost_per_byte: Option<u64>,
1856 dynamic_field_borrow_child_object_type_cost_per_byte: Option<u64>,
1857 dynamic_field_remove_child_object_cost_base: Option<u64>,
1859 dynamic_field_remove_child_object_child_cost_per_byte: Option<u64>,
1860 dynamic_field_remove_child_object_type_cost_per_byte: Option<u64>,
1861 dynamic_field_has_child_object_cost_base: Option<u64>,
1863 dynamic_field_has_child_object_with_ty_cost_base: Option<u64>,
1865 dynamic_field_has_child_object_with_ty_type_cost_per_byte: Option<u64>,
1866 dynamic_field_has_child_object_with_ty_type_tag_cost_per_byte: Option<u64>,
1867
1868 scratch_add_cost_base: Option<u64>,
1871 scratch_read_cost_base: Option<u64>,
1873 scratch_read_value_cost: Option<u64>,
1874 scratch_remove_cost_base: Option<u64>,
1876 scratch_exists_cost_base: Option<u64>,
1878 scratch_exists_with_type_cost_base: Option<u64>,
1880 scratch_exists_with_type_type_cost: Option<u64>,
1881 max_scratch_pad_size: Option<u64>,
1883
1884 event_emit_cost_base: Option<u64>,
1887 event_emit_value_size_derivation_cost_per_byte: Option<u64>,
1888 event_emit_tag_size_derivation_cost_per_byte: Option<u64>,
1889 event_emit_output_cost_per_byte: Option<u64>,
1890 event_emit_auth_stream_cost: Option<u64>,
1891
1892 reserve_object_funds_for_withdrawal_cost_base: Option<u64>,
1895 reserve_object_funds_for_withdrawal_cold_read_cost: Option<u64>,
1897
1898 object_borrow_uid_cost_base: Option<u64>,
1901 object_delete_impl_cost_base: Option<u64>,
1903 object_record_new_uid_cost_base: Option<u64>,
1905 object_record_new_uid_from_hash_cost_base: Option<u64>,
1908
1909 transfer_transfer_internal_cost_base: Option<u64>,
1912 transfer_party_transfer_internal_cost_base: Option<u64>,
1914 transfer_freeze_object_cost_base: Option<u64>,
1916 transfer_share_object_cost_base: Option<u64>,
1918 transfer_receive_object_cost_base: Option<u64>,
1921 transfer_receive_object_cost_per_byte: Option<u64>,
1922 transfer_receive_object_type_cost_per_byte: Option<u64>,
1923
1924 tx_context_derive_id_cost_base: Option<u64>,
1927 tx_context_fresh_id_cost_base: Option<u64>,
1928 tx_context_sender_cost_base: Option<u64>,
1929 tx_context_epoch_cost_base: Option<u64>,
1930 tx_context_epoch_timestamp_ms_cost_base: Option<u64>,
1931 tx_context_sponsor_cost_base: Option<u64>,
1932 tx_context_rgp_cost_base: Option<u64>,
1933 tx_context_gas_price_cost_base: Option<u64>,
1934 tx_context_gas_budget_cost_base: Option<u64>,
1935 tx_context_ids_created_cost_base: Option<u64>,
1936 tx_context_replace_cost_base: Option<u64>,
1937
1938 types_is_one_time_witness_cost_base: Option<u64>,
1941 types_is_one_time_witness_type_tag_cost_per_byte: Option<u64>,
1942 types_is_one_time_witness_type_cost_per_byte: Option<u64>,
1943
1944 validator_validate_metadata_cost_base: Option<u64>,
1947 validator_validate_metadata_data_cost_per_byte: Option<u64>,
1948
1949 crypto_invalid_arguments_cost: Option<u64>,
1951 bls12381_bls12381_min_sig_verify_cost_base: Option<u64>,
1953 bls12381_bls12381_min_sig_verify_msg_cost_per_byte: Option<u64>,
1954 bls12381_bls12381_min_sig_verify_msg_cost_per_block: Option<u64>,
1955
1956 bls12381_bls12381_min_pk_verify_cost_base: Option<u64>,
1958 bls12381_bls12381_min_pk_verify_msg_cost_per_byte: Option<u64>,
1959 bls12381_bls12381_min_pk_verify_msg_cost_per_block: Option<u64>,
1960
1961 ecdsa_k1_ecrecover_keccak256_cost_base: Option<u64>,
1963 ecdsa_k1_ecrecover_keccak256_msg_cost_per_byte: Option<u64>,
1964 ecdsa_k1_ecrecover_keccak256_msg_cost_per_block: Option<u64>,
1965 ecdsa_k1_ecrecover_sha256_cost_base: Option<u64>,
1966 ecdsa_k1_ecrecover_sha256_msg_cost_per_byte: Option<u64>,
1967 ecdsa_k1_ecrecover_sha256_msg_cost_per_block: Option<u64>,
1968
1969 ecdsa_k1_decompress_pubkey_cost_base: Option<u64>,
1971
1972 ecdsa_k1_secp256k1_verify_keccak256_cost_base: Option<u64>,
1974 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_byte: Option<u64>,
1975 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_block: Option<u64>,
1976 ecdsa_k1_secp256k1_verify_sha256_cost_base: Option<u64>,
1977 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_byte: Option<u64>,
1978 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_block: Option<u64>,
1979
1980 ecdsa_r1_ecrecover_keccak256_cost_base: Option<u64>,
1982 ecdsa_r1_ecrecover_keccak256_msg_cost_per_byte: Option<u64>,
1983 ecdsa_r1_ecrecover_keccak256_msg_cost_per_block: Option<u64>,
1984 ecdsa_r1_ecrecover_sha256_cost_base: Option<u64>,
1985 ecdsa_r1_ecrecover_sha256_msg_cost_per_byte: Option<u64>,
1986 ecdsa_r1_ecrecover_sha256_msg_cost_per_block: Option<u64>,
1987
1988 ecdsa_r1_secp256r1_verify_keccak256_cost_base: Option<u64>,
1990 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_byte: Option<u64>,
1991 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_block: Option<u64>,
1992 ecdsa_r1_secp256r1_verify_sha256_cost_base: Option<u64>,
1993 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_byte: Option<u64>,
1994 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_block: Option<u64>,
1995
1996 ecvrf_ecvrf_verify_cost_base: Option<u64>,
1998 ecvrf_ecvrf_verify_alpha_string_cost_per_byte: Option<u64>,
1999 ecvrf_ecvrf_verify_alpha_string_cost_per_block: Option<u64>,
2000
2001 ed25519_ed25519_verify_cost_base: Option<u64>,
2003 ed25519_ed25519_verify_msg_cost_per_byte: Option<u64>,
2004 ed25519_ed25519_verify_msg_cost_per_block: Option<u64>,
2005
2006 groth16_prepare_verifying_key_bls12381_cost_base: Option<u64>,
2008 groth16_prepare_verifying_key_bn254_cost_base: Option<u64>,
2009
2010 groth16_verify_groth16_proof_internal_bls12381_cost_base: Option<u64>,
2012 groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input: Option<u64>,
2013 groth16_verify_groth16_proof_internal_bn254_cost_base: Option<u64>,
2014 groth16_verify_groth16_proof_internal_bn254_cost_per_public_input: Option<u64>,
2015 groth16_verify_groth16_proof_internal_public_input_cost_per_byte: Option<u64>,
2016
2017 hash_blake2b256_cost_base: Option<u64>,
2019 hash_blake2b256_data_cost_per_byte: Option<u64>,
2020 hash_blake2b256_data_cost_per_block: Option<u64>,
2021
2022 hash_keccak256_cost_base: Option<u64>,
2024 hash_keccak256_data_cost_per_byte: Option<u64>,
2025 hash_keccak256_data_cost_per_block: Option<u64>,
2026
2027 poseidon_bn254_cost_base: Option<u64>,
2029 poseidon_bn254_cost_per_block: Option<u64>,
2030
2031 group_ops_bls12381_decode_scalar_cost: Option<u64>,
2033 group_ops_bls12381_decode_g1_cost: Option<u64>,
2034 group_ops_bls12381_decode_g2_cost: Option<u64>,
2035 group_ops_bls12381_decode_gt_cost: Option<u64>,
2036 group_ops_bls12381_scalar_add_cost: Option<u64>,
2037 group_ops_bls12381_g1_add_cost: Option<u64>,
2038 group_ops_bls12381_g2_add_cost: Option<u64>,
2039 group_ops_bls12381_gt_add_cost: Option<u64>,
2040 group_ops_bls12381_scalar_sub_cost: Option<u64>,
2041 group_ops_bls12381_g1_sub_cost: Option<u64>,
2042 group_ops_bls12381_g2_sub_cost: Option<u64>,
2043 group_ops_bls12381_gt_sub_cost: Option<u64>,
2044 group_ops_bls12381_scalar_mul_cost: Option<u64>,
2045 group_ops_bls12381_g1_mul_cost: Option<u64>,
2046 group_ops_bls12381_g2_mul_cost: Option<u64>,
2047 group_ops_bls12381_gt_mul_cost: Option<u64>,
2048 group_ops_bls12381_scalar_div_cost: Option<u64>,
2049 group_ops_bls12381_g1_div_cost: Option<u64>,
2050 group_ops_bls12381_g2_div_cost: Option<u64>,
2051 group_ops_bls12381_gt_div_cost: Option<u64>,
2052 group_ops_bls12381_g1_hash_to_base_cost: Option<u64>,
2053 group_ops_bls12381_g2_hash_to_base_cost: Option<u64>,
2054 group_ops_bls12381_g1_hash_to_cost_per_byte: Option<u64>,
2055 group_ops_bls12381_g2_hash_to_cost_per_byte: Option<u64>,
2056 group_ops_bls12381_g1_msm_base_cost: Option<u64>,
2057 group_ops_bls12381_g2_msm_base_cost: Option<u64>,
2058 group_ops_bls12381_g1_msm_base_cost_per_input: Option<u64>,
2059 group_ops_bls12381_g2_msm_base_cost_per_input: Option<u64>,
2060 group_ops_bls12381_msm_max_len: Option<u32>,
2061 group_ops_bls12381_pairing_cost: Option<u64>,
2062 group_ops_bls12381_g1_to_uncompressed_g1_cost: Option<u64>,
2063 group_ops_bls12381_uncompressed_g1_to_g1_cost: Option<u64>,
2064 group_ops_bls12381_uncompressed_g1_sum_base_cost: Option<u64>,
2065 group_ops_bls12381_uncompressed_g1_sum_cost_per_term: Option<u64>,
2066 group_ops_bls12381_uncompressed_g1_sum_max_terms: Option<u64>,
2067
2068 group_ops_ristretto_decode_scalar_cost: Option<u64>,
2069 group_ops_ristretto_decode_point_cost: Option<u64>,
2070 group_ops_ristretto_scalar_add_cost: Option<u64>,
2071 group_ops_ristretto_point_add_cost: Option<u64>,
2072 group_ops_ristretto_scalar_sub_cost: Option<u64>,
2073 group_ops_ristretto_point_sub_cost: Option<u64>,
2074 group_ops_ristretto_scalar_mul_cost: Option<u64>,
2075 group_ops_ristretto_point_mul_cost: Option<u64>,
2076 group_ops_ristretto_scalar_div_cost: Option<u64>,
2077 group_ops_ristretto_point_div_cost: Option<u64>,
2078
2079 verify_bulletproofs_ristretto255_base_cost: Option<u64>,
2080 verify_bulletproofs_ristretto255_cost_per_bit_and_commitment: Option<u64>,
2081 max_bulletproofs_total_bits: Option<u64>,
2084
2085 hmac_hmac_sha3_256_cost_base: Option<u64>,
2087 hmac_hmac_sha3_256_input_cost_per_byte: Option<u64>,
2088 hmac_hmac_sha3_256_input_cost_per_block: Option<u64>,
2089
2090 check_zklogin_id_cost_base: Option<u64>,
2092 check_zklogin_issuer_cost_base: Option<u64>,
2094
2095 vdf_verify_vdf_cost: Option<u64>,
2096 vdf_hash_to_input_cost: Option<u64>,
2097
2098 nitro_attestation_parse_base_cost: Option<u64>,
2100 nitro_attestation_parse_cost_per_byte: Option<u64>,
2101 nitro_attestation_verify_base_cost: Option<u64>,
2102 nitro_attestation_verify_cost_per_cert: Option<u64>,
2103
2104 bcs_per_byte_serialized_cost: Option<u64>,
2106 bcs_legacy_min_output_size_cost: Option<u64>,
2107 bcs_failure_cost: Option<u64>,
2108
2109 hash_sha2_256_base_cost: Option<u64>,
2110 hash_sha2_256_per_byte_cost: Option<u64>,
2111 hash_sha2_256_legacy_min_input_len_cost: Option<u64>,
2112 hash_sha3_256_base_cost: Option<u64>,
2113 hash_sha3_256_per_byte_cost: Option<u64>,
2114 hash_sha3_256_legacy_min_input_len_cost: Option<u64>,
2115 type_name_get_base_cost: Option<u64>,
2116 type_name_get_per_byte_cost: Option<u64>,
2117 type_name_id_base_cost: Option<u64>,
2118
2119 string_check_utf8_base_cost: Option<u64>,
2120 string_check_utf8_per_byte_cost: Option<u64>,
2121 string_is_char_boundary_base_cost: Option<u64>,
2122 string_sub_string_base_cost: Option<u64>,
2123 string_sub_string_per_byte_cost: Option<u64>,
2124 string_index_of_base_cost: Option<u64>,
2125 string_index_of_per_byte_pattern_cost: Option<u64>,
2126 string_index_of_per_byte_searched_cost: Option<u64>,
2127
2128 vector_empty_base_cost: Option<u64>,
2129 vector_length_base_cost: Option<u64>,
2130 vector_push_back_base_cost: Option<u64>,
2131 vector_push_back_legacy_per_abstract_memory_unit_cost: Option<u64>,
2132 vector_borrow_base_cost: Option<u64>,
2133 vector_pop_back_base_cost: Option<u64>,
2134 vector_destroy_empty_base_cost: Option<u64>,
2135 vector_swap_base_cost: Option<u64>,
2136 vector_reverse_base_cost: Option<u64>,
2137 vector_reverse_per_elem_cost: Option<u64>,
2138 vector_keep_range_base_cost: Option<u64>,
2139 vector_keep_range_per_dropped_elem_cost: Option<u64>,
2140 vector_keep_range_per_moved_elem_cost: Option<u64>,
2141 vector_copy_range_base_cost: Option<u64>,
2142 vector_replace_range_base_cost: Option<u64>,
2143 vector_replace_range_per_elem_cost: Option<u64>,
2144 debug_print_base_cost: Option<u64>,
2145 debug_print_stack_trace_base_cost: Option<u64>,
2146
2147 #[custom_setter]
2157 execution_version: Option<u64>,
2158
2159 consensus_bad_nodes_stake_threshold: Option<u64>,
2163
2164 max_jwk_votes_per_validator_per_epoch: Option<u64>,
2165 max_age_of_jwk_in_epochs: Option<u64>,
2169
2170 random_beacon_reduction_allowed_delta: Option<u16>,
2174
2175 random_beacon_reduction_lower_bound: Option<u32>,
2178
2179 random_beacon_dkg_timeout_round: Option<u32>,
2182
2183 random_beacon_min_round_interval_ms: Option<u64>,
2185
2186 random_beacon_dkg_version: Option<u64>,
2189
2190 consensus_max_transaction_size_bytes: Option<u64>,
2193 consensus_max_transactions_in_block_bytes: Option<u64>,
2195 consensus_max_num_transactions_in_block: Option<u64>,
2197
2198 consensus_voting_rounds: Option<u32>,
2200
2201 max_accumulated_txn_cost_per_object_in_narwhal_commit: Option<u64>,
2203
2204 max_deferral_rounds_for_congestion_control: Option<u64>,
2207
2208 epoch_close_deadline_ms: Option<u64>,
2213
2214 max_txn_cost_overage_per_object_in_commit: Option<u64>,
2216
2217 allowed_txn_cost_overage_burst_per_object_in_commit: Option<u64>,
2219
2220 min_checkpoint_interval_ms: Option<u64>,
2222
2223 checkpoint_summary_version_specific_data: Option<u64>,
2225
2226 max_soft_bundle_size: Option<u64>,
2228
2229 bridge_should_try_to_finalize_committee: Option<bool>,
2233
2234 max_accumulated_txn_cost_per_object_in_mysticeti_commit: Option<u64>,
2240
2241 max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit: Option<u64>,
2244
2245 consensus_gc_depth: Option<u32>,
2248
2249 gas_budget_based_txn_cost_cap_factor: Option<u64>,
2251
2252 gas_budget_based_txn_cost_absolute_cap_commit_count: Option<u64>,
2254
2255 sip_45_consensus_amplification_threshold: Option<u64>,
2258
2259 staggered_submission_signal_window_commits: Option<u64>,
2262 staggered_submission_signal_min_excess_copies_per_commit: Option<u64>,
2264 staggered_submission_signal_exit_dwell_commits: Option<u64>,
2267 staggered_submission_signal_band1_enter_ratio_bps: Option<u64>,
2270 staggered_submission_signal_band1_exit_ratio_bps: Option<u64>,
2271 staggered_submission_signal_band2_enter_ratio_bps: Option<u64>,
2272 staggered_submission_signal_band2_exit_ratio_bps: Option<u64>,
2273
2274 use_object_per_epoch_marker_table_v2: Option<bool>,
2277
2278 consensus_commit_rate_estimation_window_size: Option<u32>,
2280
2281 #[serde(skip_serializing_if = "Vec::is_empty")]
2285 aliased_addresses: Vec<AliasedAddress>,
2286
2287 translation_per_command_base_charge: Option<u64>,
2290
2291 translation_per_input_base_charge: Option<u64>,
2294
2295 translation_pure_input_per_byte_charge: Option<u64>,
2297
2298 translation_per_type_node_charge: Option<u64>,
2302
2303 translation_per_reference_node_charge: Option<u64>,
2306
2307 translation_per_linkage_entry_charge: Option<u64>,
2310
2311 max_updates_per_settlement_txn: Option<u32>,
2313
2314 gasless_max_computation_units: Option<u64>,
2316
2317 gasless_allowed_token_types: Option<Vec<(String, u64)>>,
2319
2320 gasless_max_unused_inputs: Option<u64>,
2324
2325 gasless_max_pure_input_bytes: Option<u64>,
2328
2329 gasless_max_tps: Option<u64>,
2331
2332 #[serde(skip_serializing_if = "Option::is_none")]
2333 #[skip_accessor]
2334 include_special_package_amendments: Option<Arc<Amendments>>,
2335
2336 gasless_max_tx_size_bytes: Option<u64>,
2339
2340 translation_per_live_reference_charge: Option<u64>,
2343
2344 max_ptb_live_references: Option<u64>,
2347
2348 max_ptb_returned_references: Option<u64>,
2351
2352 max_ptb_total_returned_references: Option<u64>,
2355}
2356
2357#[derive(Clone, Serialize, Deserialize, Debug)]
2359pub struct AliasedAddress {
2360 pub original: [u8; 32],
2362 pub aliased: [u8; 32],
2364 pub allowed_tx_digests: Vec<[u8; 32]>,
2366}
2367
2368impl ProtocolConfig {
2370 pub fn chain(&self) -> Chain {
2372 self.chain
2373 }
2374
2375 pub fn check_package_upgrades_supported(&self) -> Result<(), Error> {
2388 if self.feature_flags.package_upgrades {
2389 Ok(())
2390 } else {
2391 Err(Error(format!(
2392 "package upgrades are not supported at {:?}",
2393 self.version
2394 )))
2395 }
2396 }
2397
2398 pub fn zklogin_supported_providers(&self) -> &BTreeSet<String> {
2399 &self.feature_flags.zklogin_supported_providers
2400 }
2401
2402 pub fn zklogin_circuit_mode(&self) -> u64 {
2405 self.feature_flags.zklogin_circuit_mode
2406 }
2407
2408 pub fn consensus_transaction_ordering(&self) -> ConsensusTransactionOrdering {
2409 self.feature_flags.consensus_transaction_ordering
2410 }
2411
2412 pub fn enable_jwk_consensus_updates(&self) -> bool {
2413 let ret = self.feature_flags.enable_jwk_consensus_updates;
2414 if ret {
2415 assert!(self.feature_flags.end_of_epoch_transaction_supported);
2417 }
2418 ret
2419 }
2420
2421 pub fn staggered_submission_signal(&self) -> bool {
2422 let ret = self.feature_flags.staggered_submission_signal;
2423 if ret {
2424 assert!(self.feature_flags.allowed_proposers);
2427 }
2428 ret
2429 }
2430
2431 pub fn end_of_epoch_transaction_supported(&self) -> bool {
2432 let ret = self.feature_flags.end_of_epoch_transaction_supported;
2433 if !ret {
2434 assert!(!self.feature_flags.enable_jwk_consensus_updates);
2436 }
2437 ret
2438 }
2439
2440 pub fn dkg_version(&self) -> u64 {
2441 self.random_beacon_dkg_version.unwrap_or(1)
2443 }
2444
2445 pub fn bridge(&self) -> bool {
2446 let ret = self.feature_flags.bridge;
2447 if ret {
2448 assert!(self.feature_flags.end_of_epoch_transaction_supported);
2450 }
2451 ret
2452 }
2453
2454 pub fn should_try_to_finalize_bridge_committee(&self) -> bool {
2455 if !self.bridge() {
2456 return false;
2457 }
2458 self.bridge_should_try_to_finalize_committee.unwrap_or(true)
2460 }
2461
2462 pub fn zklogin_max_epoch_upper_bound_delta(&self) -> Option<u64> {
2463 self.feature_flags.zklogin_max_epoch_upper_bound_delta
2464 }
2465
2466 pub fn enable_allowances(&self) -> bool {
2467 self.feature_flags.enable_allowances && self.enable_accumulators()
2468 }
2469
2470 pub fn enable_coin_reservation_obj_refs(&self) -> bool {
2471 self.new_vm_enabled() && self.feature_flags.enable_coin_reservation_obj_refs
2472 }
2473
2474 pub fn enable_authenticated_event_streams(&self) -> bool {
2475 self.feature_flags.enable_authenticated_event_streams && self.enable_accumulators()
2476 }
2477
2478 pub fn per_object_congestion_control_mode(&self) -> PerObjectCongestionControlMode {
2479 self.feature_flags.per_object_congestion_control_mode
2480 }
2481
2482 pub fn consensus_choice(&self) -> ConsensusChoice {
2483 self.feature_flags.consensus_choice
2484 }
2485
2486 pub fn consensus_network(&self) -> ConsensusNetwork {
2487 self.feature_flags.consensus_network
2488 }
2489
2490 pub fn mysticeti_num_leaders_per_round(&self) -> Option<usize> {
2491 self.feature_flags.mysticeti_num_leaders_per_round
2492 }
2493
2494 pub fn max_transaction_size_bytes(&self) -> u64 {
2495 self.consensus_max_transaction_size_bytes
2497 .unwrap_or(256 * 1024)
2498 }
2499
2500 pub fn max_transactions_in_block_bytes(&self) -> u64 {
2501 if cfg!(msim) {
2502 256 * 1024
2503 } else {
2504 self.consensus_max_transactions_in_block_bytes
2505 .unwrap_or(512 * 1024)
2506 }
2507 }
2508
2509 pub fn max_num_transactions_in_block(&self) -> u64 {
2510 if cfg!(msim) {
2511 8
2512 } else {
2513 self.consensus_max_num_transactions_in_block.unwrap_or(512)
2514 }
2515 }
2516
2517 pub fn gc_depth(&self) -> u32 {
2518 self.consensus_gc_depth.unwrap_or(0)
2519 }
2520
2521 pub fn consensus_linearize_subdag_v2(&self) -> bool {
2522 let res = self.feature_flags.consensus_linearize_subdag_v2;
2523 assert!(
2524 !res || self.gc_depth() > 0,
2525 "The consensus linearize sub dag V2 requires GC to be enabled"
2526 );
2527 res
2528 }
2529
2530 pub fn consensus_median_based_commit_timestamp(&self) -> bool {
2531 let res = self.feature_flags.consensus_median_based_commit_timestamp;
2532 assert!(
2533 !res || self.gc_depth() > 0,
2534 "The consensus median based commit timestamp requires GC to be enabled"
2535 );
2536 res
2537 }
2538
2539 pub fn get_consensus_commit_rate_estimation_window_size(&self) -> u32 {
2540 self.consensus_commit_rate_estimation_window_size
2541 .unwrap_or(0)
2542 }
2543
2544 pub fn consensus_num_requested_prior_commits_at_startup(&self) -> u32 {
2545 let window_size = self.get_consensus_commit_rate_estimation_window_size();
2549 assert!(window_size == 0 || self.record_additional_state_digest_in_prologue());
2551 window_size
2552 }
2553
2554 pub fn address_aliases(&self) -> bool {
2555 let address_aliases = self.feature_flags.address_aliases;
2556 assert!(
2557 !address_aliases || self.mysticeti_fastpath(),
2558 "Address aliases requires Mysticeti fastpath to be enabled"
2559 );
2560 if address_aliases {
2561 assert!(
2562 self.feature_flags.disable_preconsensus_locking,
2563 "Address aliases requires CertifiedTransaction to be disabled"
2564 );
2565 }
2566 address_aliases
2567 }
2568
2569 pub fn new_vm_enabled(&self) -> bool {
2570 self.execution_version.is_some_and(|v| v >= 4)
2571 }
2572
2573 pub fn gasless_allowed_token_types(&self) -> &[(String, u64)] {
2574 debug_assert!(self.gasless_allowed_token_types.is_some());
2575 self.gasless_allowed_token_types.as_deref().unwrap_or(&[])
2576 }
2577
2578 pub fn get_gasless_max_unused_inputs(&self) -> u64 {
2579 self.gasless_max_unused_inputs.unwrap_or(u64::MAX)
2580 }
2581
2582 pub fn get_gasless_max_pure_input_bytes(&self) -> u64 {
2583 self.gasless_max_pure_input_bytes.unwrap_or(u64::MAX)
2584 }
2585
2586 pub fn get_gasless_max_tx_size_bytes(&self) -> u64 {
2587 self.gasless_max_tx_size_bytes.unwrap_or(u64::MAX)
2588 }
2589
2590 pub fn include_special_package_amendments_as_option(&self) -> &Option<Arc<Amendments>> {
2591 &self.include_special_package_amendments
2592 }
2593}
2594
2595static POISON_VERSION_METHODS: AtomicBool = AtomicBool::new(false);
2596
2597impl ProtocolConfig {
2599 pub fn get_for_version(version: ProtocolVersion, chain: Chain) -> Self {
2601 assert!(
2603 version >= ProtocolVersion::MIN,
2604 "Network protocol version is {:?}, but the minimum supported version by the binary is {:?}. Please upgrade the binary.",
2605 version,
2606 ProtocolVersion::MIN.0,
2607 );
2608 assert!(
2609 version <= ProtocolVersion::MAX_ALLOWED,
2610 "Network protocol version is {:?}, but the maximum supported version by the binary is {:?}. Please upgrade the binary.",
2611 version,
2612 ProtocolVersion::MAX_ALLOWED.0,
2613 );
2614
2615 let mut ret = Self::get_for_version_impl(version, chain);
2616 ret.version = version;
2617 ret.chain = chain;
2618
2619 ret = Self::apply_config_override(version, ret);
2620
2621 if std::env::var("SUI_PROTOCOL_CONFIG_OVERRIDE_ENABLE").is_ok() {
2622 warn!(
2623 "overriding ProtocolConfig settings with custom settings; this may break non-local networks"
2624 );
2625 let overrides: ProtocolConfigOptional =
2626 serde_env::from_env_with_prefix("SUI_PROTOCOL_CONFIG_OVERRIDE")
2627 .expect("failed to parse ProtocolConfig override env variables");
2628 overrides.apply_to(&mut ret);
2629 }
2630
2631 ret
2632 }
2633
2634 pub fn get_for_version_if_supported(version: ProtocolVersion, chain: Chain) -> Option<Self> {
2637 if version.0 >= ProtocolVersion::MIN.0 && version.0 <= ProtocolVersion::MAX_ALLOWED.0 {
2638 let mut ret = Self::get_for_version_impl(version, chain);
2639 ret.version = version;
2640 ret.chain = chain;
2641 ret = Self::apply_config_override(version, ret);
2642 Some(ret)
2643 } else {
2644 None
2645 }
2646 }
2647
2648 pub fn poison_get_for_min_version() {
2649 POISON_VERSION_METHODS.store(true, Ordering::Relaxed);
2650 }
2651
2652 fn load_poison_get_for_min_version() -> bool {
2653 POISON_VERSION_METHODS.load(Ordering::Relaxed)
2654 }
2655
2656 pub fn get_for_min_version() -> Self {
2659 if Self::load_poison_get_for_min_version() {
2660 panic!("get_for_min_version called on validator");
2661 }
2662 ProtocolConfig::get_for_version(ProtocolVersion::MIN, Chain::Unknown)
2663 }
2664
2665 #[allow(non_snake_case)]
2675 pub fn get_for_max_version_UNSAFE() -> Self {
2676 if Self::load_poison_get_for_min_version() {
2677 panic!("get_for_max_version_UNSAFE called on validator");
2678 }
2679 ProtocolConfig::get_for_version(ProtocolVersion::MAX, Chain::Unknown)
2680 }
2681
2682 fn get_for_version_impl(version: ProtocolVersion, chain: Chain) -> Self {
2683 #[cfg(msim)]
2684 {
2685 if version == ProtocolVersion::MAX_ALLOWED {
2687 let mut config = Self::get_for_version_impl(version - 1, Chain::Unknown);
2688 config.base_tx_cost_fixed = Some(config.base_tx_cost_fixed() + 1000);
2689 return config;
2690 }
2691 }
2692
2693 let mut cfg = Self {
2696 version,
2698 chain,
2699
2700 feature_flags: Default::default(),
2702
2703 max_tx_size_bytes: Some(128 * 1024),
2704 max_input_objects: Some(2048),
2706 max_serialized_tx_effects_size_bytes: Some(512 * 1024),
2707 max_serialized_tx_effects_size_bytes_system_tx: Some(512 * 1024 * 16),
2708 max_gas_payment_objects: Some(256),
2709 max_modules_in_publish: Some(128),
2710 max_package_dependencies: None,
2711 max_arguments: Some(512),
2712 max_type_arguments: Some(16),
2713 max_type_argument_depth: Some(16),
2714 max_pure_argument_size: Some(16 * 1024),
2715 max_programmable_tx_commands: Some(1024),
2716 move_binary_format_version: Some(6),
2717 min_move_binary_format_version: None,
2718 binary_module_handles: None,
2719 binary_struct_handles: None,
2720 binary_function_handles: None,
2721 binary_function_instantiations: None,
2722 binary_signatures: None,
2723 binary_constant_pool: None,
2724 binary_identifiers: None,
2725 binary_address_identifiers: None,
2726 binary_struct_defs: None,
2727 binary_struct_def_instantiations: None,
2728 binary_function_defs: None,
2729 binary_field_handles: None,
2730 binary_field_instantiations: None,
2731 binary_friend_decls: None,
2732 binary_enum_defs: None,
2733 binary_enum_def_instantiations: None,
2734 binary_variant_handles: None,
2735 binary_variant_instantiation_handles: None,
2736 max_move_object_size: Some(250 * 1024),
2737 max_move_package_size: Some(100 * 1024),
2738 max_publish_or_upgrade_per_ptb: None,
2739 max_tx_gas: Some(10_000_000_000),
2740 max_gas_price: Some(100_000),
2741 max_gas_price_rgp_factor_for_aborted_transactions: None,
2742 max_gas_computation_bucket: Some(5_000_000),
2743 max_loop_depth: Some(5),
2744 max_generic_instantiation_length: Some(32),
2745 max_function_parameters: Some(128),
2746 max_basic_blocks: Some(1024),
2747 max_value_stack_size: Some(1024),
2748 max_type_nodes: Some(256),
2749 max_generic_instantiation_type_nodes_per_function: None,
2750 max_generic_instantiation_type_nodes_per_module: None,
2751 max_accumulator_type_nodes: None,
2752 max_push_size: Some(10000),
2753 max_struct_definitions: Some(200),
2754 max_function_definitions: Some(1000),
2755 max_fields_in_struct: Some(32),
2756 max_dependency_depth: Some(100),
2757 max_num_event_emit: Some(256),
2758 max_num_new_move_object_ids: Some(2048),
2759 max_num_new_move_object_ids_system_tx: Some(2048 * 16),
2760 max_num_deleted_move_object_ids: Some(2048),
2761 max_num_deleted_move_object_ids_system_tx: Some(2048 * 16),
2762 max_num_transferred_move_object_ids: Some(2048),
2763 max_num_transferred_move_object_ids_system_tx: Some(2048 * 16),
2764 max_event_emit_size: Some(250 * 1024),
2765 max_move_vector_len: Some(256 * 1024),
2766 max_type_to_layout_nodes: None,
2767 max_ptb_value_size: None,
2768
2769 max_back_edges_per_function: Some(10_000),
2770 max_back_edges_per_module: Some(10_000),
2771 max_verifier_meter_ticks_per_function: Some(6_000_000),
2772 max_meter_ticks_per_module: Some(6_000_000),
2773 max_meter_ticks_per_package: None,
2774
2775 object_runtime_max_num_cached_objects: Some(1000),
2776 object_runtime_max_num_cached_objects_system_tx: Some(1000 * 16),
2777 object_runtime_max_num_store_entries: Some(1000),
2778 object_runtime_max_num_store_entries_system_tx: Some(1000 * 16),
2779 base_tx_cost_fixed: Some(110_000),
2780 package_publish_cost_fixed: Some(1_000),
2781 base_tx_cost_per_byte: Some(0),
2782 package_publish_cost_per_byte: Some(80),
2783 obj_access_cost_read_per_byte: Some(15),
2784 obj_access_cost_read_per_package_kb: None,
2785 obj_access_cost_mutate_per_byte: Some(40),
2786 obj_access_cost_delete_per_byte: Some(40),
2787 obj_access_cost_verify_per_byte: Some(200),
2788 obj_data_cost_refundable: Some(100),
2789 obj_metadata_cost_non_refundable: Some(50),
2790 gas_model_version: Some(1),
2791 storage_rebate_rate: Some(9900),
2792 storage_fund_reinvest_rate: Some(500),
2793 reward_slashing_rate: Some(5000),
2794 storage_gas_price: Some(1),
2795 accumulator_object_storage_cost: None,
2796 max_transactions_per_checkpoint: Some(10_000),
2797 max_checkpoint_size_bytes: Some(30 * 1024 * 1024),
2798
2799 buffer_stake_for_protocol_upgrade_bps: Some(0),
2802
2803 address_from_bytes_cost_base: Some(52),
2807 address_to_u256_cost_base: Some(52),
2809 address_from_u256_cost_base: Some(52),
2811
2812 config_read_setting_impl_cost_base: None,
2815 config_read_setting_impl_cost_per_byte: None,
2816
2817 package_original_package_id_impl_cost_base: None,
2818 package_original_package_id_impl_cost_per_byte: None,
2819
2820 dynamic_field_hash_type_and_key_cost_base: Some(100),
2823 dynamic_field_hash_type_and_key_type_cost_per_byte: Some(2),
2824 dynamic_field_hash_type_and_key_value_cost_per_byte: Some(2),
2825 dynamic_field_hash_type_and_key_type_tag_cost_per_byte: Some(2),
2826 dynamic_field_add_child_object_cost_base: Some(100),
2828 dynamic_field_add_child_object_type_cost_per_byte: Some(10),
2829 dynamic_field_add_child_object_value_cost_per_byte: Some(10),
2830 dynamic_field_add_child_object_struct_tag_cost_per_byte: Some(10),
2831 dynamic_field_borrow_child_object_cost_base: Some(100),
2833 dynamic_field_borrow_child_object_child_ref_cost_per_byte: Some(10),
2834 dynamic_field_borrow_child_object_type_cost_per_byte: Some(10),
2835 dynamic_field_remove_child_object_cost_base: Some(100),
2837 dynamic_field_remove_child_object_child_cost_per_byte: Some(2),
2838 dynamic_field_remove_child_object_type_cost_per_byte: Some(2),
2839 dynamic_field_has_child_object_cost_base: Some(100),
2841 dynamic_field_has_child_object_with_ty_cost_base: Some(100),
2843 dynamic_field_has_child_object_with_ty_type_cost_per_byte: Some(2),
2844 dynamic_field_has_child_object_with_ty_type_tag_cost_per_byte: Some(2),
2845
2846 scratch_add_cost_base: None,
2848 scratch_read_cost_base: None,
2849 scratch_read_value_cost: None,
2850 scratch_remove_cost_base: None,
2851 scratch_exists_cost_base: None,
2852 scratch_exists_with_type_cost_base: None,
2853 scratch_exists_with_type_type_cost: None,
2854 max_scratch_pad_size: None,
2855
2856 event_emit_cost_base: Some(52),
2859 event_emit_value_size_derivation_cost_per_byte: Some(2),
2860 event_emit_tag_size_derivation_cost_per_byte: Some(5),
2861 event_emit_output_cost_per_byte: Some(10),
2862 event_emit_auth_stream_cost: None,
2863
2864 reserve_object_funds_for_withdrawal_cost_base: None,
2866 reserve_object_funds_for_withdrawal_cold_read_cost: None,
2867
2868 object_borrow_uid_cost_base: Some(52),
2871 object_delete_impl_cost_base: Some(52),
2873 object_record_new_uid_cost_base: Some(52),
2875 object_record_new_uid_from_hash_cost_base: None,
2878
2879 transfer_transfer_internal_cost_base: Some(52),
2882 transfer_party_transfer_internal_cost_base: None,
2884 transfer_freeze_object_cost_base: Some(52),
2886 transfer_share_object_cost_base: Some(52),
2888 transfer_receive_object_cost_base: None,
2889 transfer_receive_object_type_cost_per_byte: None,
2890 transfer_receive_object_cost_per_byte: None,
2891
2892 tx_context_derive_id_cost_base: Some(52),
2895 tx_context_fresh_id_cost_base: None,
2896 tx_context_sender_cost_base: None,
2897 tx_context_epoch_cost_base: None,
2898 tx_context_epoch_timestamp_ms_cost_base: None,
2899 tx_context_sponsor_cost_base: None,
2900 tx_context_rgp_cost_base: None,
2901 tx_context_gas_price_cost_base: None,
2902 tx_context_gas_budget_cost_base: None,
2903 tx_context_ids_created_cost_base: None,
2904 tx_context_replace_cost_base: None,
2905
2906 types_is_one_time_witness_cost_base: Some(52),
2909 types_is_one_time_witness_type_tag_cost_per_byte: Some(2),
2910 types_is_one_time_witness_type_cost_per_byte: Some(2),
2911
2912 validator_validate_metadata_cost_base: Some(52),
2915 validator_validate_metadata_data_cost_per_byte: Some(2),
2916
2917 crypto_invalid_arguments_cost: Some(100),
2919 bls12381_bls12381_min_sig_verify_cost_base: Some(52),
2921 bls12381_bls12381_min_sig_verify_msg_cost_per_byte: Some(2),
2922 bls12381_bls12381_min_sig_verify_msg_cost_per_block: Some(2),
2923
2924 bls12381_bls12381_min_pk_verify_cost_base: Some(52),
2926 bls12381_bls12381_min_pk_verify_msg_cost_per_byte: Some(2),
2927 bls12381_bls12381_min_pk_verify_msg_cost_per_block: Some(2),
2928
2929 ecdsa_k1_ecrecover_keccak256_cost_base: Some(52),
2931 ecdsa_k1_ecrecover_keccak256_msg_cost_per_byte: Some(2),
2932 ecdsa_k1_ecrecover_keccak256_msg_cost_per_block: Some(2),
2933 ecdsa_k1_ecrecover_sha256_cost_base: Some(52),
2934 ecdsa_k1_ecrecover_sha256_msg_cost_per_byte: Some(2),
2935 ecdsa_k1_ecrecover_sha256_msg_cost_per_block: Some(2),
2936
2937 ecdsa_k1_decompress_pubkey_cost_base: Some(52),
2939
2940 ecdsa_k1_secp256k1_verify_keccak256_cost_base: Some(52),
2942 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_byte: Some(2),
2943 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_block: Some(2),
2944 ecdsa_k1_secp256k1_verify_sha256_cost_base: Some(52),
2945 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_byte: Some(2),
2946 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_block: Some(2),
2947
2948 ecdsa_r1_ecrecover_keccak256_cost_base: Some(52),
2950 ecdsa_r1_ecrecover_keccak256_msg_cost_per_byte: Some(2),
2951 ecdsa_r1_ecrecover_keccak256_msg_cost_per_block: Some(2),
2952 ecdsa_r1_ecrecover_sha256_cost_base: Some(52),
2953 ecdsa_r1_ecrecover_sha256_msg_cost_per_byte: Some(2),
2954 ecdsa_r1_ecrecover_sha256_msg_cost_per_block: Some(2),
2955
2956 ecdsa_r1_secp256r1_verify_keccak256_cost_base: Some(52),
2958 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_byte: Some(2),
2959 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_block: Some(2),
2960 ecdsa_r1_secp256r1_verify_sha256_cost_base: Some(52),
2961 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_byte: Some(2),
2962 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_block: Some(2),
2963
2964 ecvrf_ecvrf_verify_cost_base: Some(52),
2966 ecvrf_ecvrf_verify_alpha_string_cost_per_byte: Some(2),
2967 ecvrf_ecvrf_verify_alpha_string_cost_per_block: Some(2),
2968
2969 ed25519_ed25519_verify_cost_base: Some(52),
2971 ed25519_ed25519_verify_msg_cost_per_byte: Some(2),
2972 ed25519_ed25519_verify_msg_cost_per_block: Some(2),
2973
2974 groth16_prepare_verifying_key_bls12381_cost_base: Some(52),
2976 groth16_prepare_verifying_key_bn254_cost_base: Some(52),
2977
2978 groth16_verify_groth16_proof_internal_bls12381_cost_base: Some(52),
2980 groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input: Some(2),
2981 groth16_verify_groth16_proof_internal_bn254_cost_base: Some(52),
2982 groth16_verify_groth16_proof_internal_bn254_cost_per_public_input: Some(2),
2983 groth16_verify_groth16_proof_internal_public_input_cost_per_byte: Some(2),
2984
2985 hash_blake2b256_cost_base: Some(52),
2987 hash_blake2b256_data_cost_per_byte: Some(2),
2988 hash_blake2b256_data_cost_per_block: Some(2),
2989
2990 hash_keccak256_cost_base: Some(52),
2992 hash_keccak256_data_cost_per_byte: Some(2),
2993 hash_keccak256_data_cost_per_block: Some(2),
2994
2995 poseidon_bn254_cost_base: None,
2996 poseidon_bn254_cost_per_block: None,
2997
2998 hmac_hmac_sha3_256_cost_base: Some(52),
3000 hmac_hmac_sha3_256_input_cost_per_byte: Some(2),
3001 hmac_hmac_sha3_256_input_cost_per_block: Some(2),
3002
3003 group_ops_bls12381_decode_scalar_cost: None,
3005 group_ops_bls12381_decode_g1_cost: None,
3006 group_ops_bls12381_decode_g2_cost: None,
3007 group_ops_bls12381_decode_gt_cost: None,
3008 group_ops_bls12381_scalar_add_cost: None,
3009 group_ops_bls12381_g1_add_cost: None,
3010 group_ops_bls12381_g2_add_cost: None,
3011 group_ops_bls12381_gt_add_cost: None,
3012 group_ops_bls12381_scalar_sub_cost: None,
3013 group_ops_bls12381_g1_sub_cost: None,
3014 group_ops_bls12381_g2_sub_cost: None,
3015 group_ops_bls12381_gt_sub_cost: None,
3016 group_ops_bls12381_scalar_mul_cost: None,
3017 group_ops_bls12381_g1_mul_cost: None,
3018 group_ops_bls12381_g2_mul_cost: None,
3019 group_ops_bls12381_gt_mul_cost: None,
3020 group_ops_bls12381_scalar_div_cost: None,
3021 group_ops_bls12381_g1_div_cost: None,
3022 group_ops_bls12381_g2_div_cost: None,
3023 group_ops_bls12381_gt_div_cost: None,
3024 group_ops_bls12381_g1_hash_to_base_cost: None,
3025 group_ops_bls12381_g2_hash_to_base_cost: None,
3026 group_ops_bls12381_g1_hash_to_cost_per_byte: None,
3027 group_ops_bls12381_g2_hash_to_cost_per_byte: None,
3028 group_ops_bls12381_g1_msm_base_cost: None,
3029 group_ops_bls12381_g2_msm_base_cost: None,
3030 group_ops_bls12381_g1_msm_base_cost_per_input: None,
3031 group_ops_bls12381_g2_msm_base_cost_per_input: None,
3032 group_ops_bls12381_msm_max_len: None,
3033 group_ops_bls12381_pairing_cost: None,
3034 group_ops_bls12381_g1_to_uncompressed_g1_cost: None,
3035 group_ops_bls12381_uncompressed_g1_to_g1_cost: None,
3036 group_ops_bls12381_uncompressed_g1_sum_base_cost: None,
3037 group_ops_bls12381_uncompressed_g1_sum_cost_per_term: None,
3038 group_ops_bls12381_uncompressed_g1_sum_max_terms: None,
3039
3040 group_ops_ristretto_decode_scalar_cost: None,
3041 group_ops_ristretto_decode_point_cost: None,
3042 group_ops_ristretto_scalar_add_cost: None,
3043 group_ops_ristretto_point_add_cost: None,
3044 group_ops_ristretto_scalar_sub_cost: None,
3045 group_ops_ristretto_point_sub_cost: None,
3046 group_ops_ristretto_scalar_mul_cost: None,
3047 group_ops_ristretto_point_mul_cost: None,
3048 group_ops_ristretto_scalar_div_cost: None,
3049 group_ops_ristretto_point_div_cost: None,
3050
3051 verify_bulletproofs_ristretto255_base_cost: None,
3052 verify_bulletproofs_ristretto255_cost_per_bit_and_commitment: None,
3053 max_bulletproofs_total_bits: None,
3054
3055 check_zklogin_id_cost_base: None,
3057 check_zklogin_issuer_cost_base: None,
3059
3060 vdf_verify_vdf_cost: None,
3061 vdf_hash_to_input_cost: None,
3062
3063 nitro_attestation_parse_base_cost: None,
3065 nitro_attestation_parse_cost_per_byte: None,
3066 nitro_attestation_verify_base_cost: None,
3067 nitro_attestation_verify_cost_per_cert: None,
3068
3069 bcs_per_byte_serialized_cost: None,
3070 bcs_legacy_min_output_size_cost: None,
3071 bcs_failure_cost: None,
3072 hash_sha2_256_base_cost: None,
3073 hash_sha2_256_per_byte_cost: None,
3074 hash_sha2_256_legacy_min_input_len_cost: None,
3075 hash_sha3_256_base_cost: None,
3076 hash_sha3_256_per_byte_cost: None,
3077 hash_sha3_256_legacy_min_input_len_cost: None,
3078 type_name_get_base_cost: None,
3079 type_name_get_per_byte_cost: None,
3080 type_name_id_base_cost: None,
3081 string_check_utf8_base_cost: None,
3082 string_check_utf8_per_byte_cost: None,
3083 string_is_char_boundary_base_cost: None,
3084 string_sub_string_base_cost: None,
3085 string_sub_string_per_byte_cost: None,
3086 string_index_of_base_cost: None,
3087 string_index_of_per_byte_pattern_cost: None,
3088 string_index_of_per_byte_searched_cost: None,
3089 vector_empty_base_cost: None,
3090 vector_length_base_cost: None,
3091 vector_push_back_base_cost: None,
3092 vector_push_back_legacy_per_abstract_memory_unit_cost: None,
3093 vector_borrow_base_cost: None,
3094 vector_pop_back_base_cost: None,
3095 vector_destroy_empty_base_cost: None,
3096 vector_swap_base_cost: None,
3097 vector_reverse_base_cost: None,
3098 vector_reverse_per_elem_cost: None,
3099 vector_keep_range_base_cost: None,
3100 vector_keep_range_per_dropped_elem_cost: None,
3101 vector_keep_range_per_moved_elem_cost: None,
3102 vector_copy_range_base_cost: None,
3103 vector_replace_range_base_cost: None,
3104 vector_replace_range_per_elem_cost: None,
3105 debug_print_base_cost: None,
3106 debug_print_stack_trace_base_cost: None,
3107
3108 max_size_written_objects: None,
3109 max_size_written_objects_system_tx: None,
3110
3111 max_move_identifier_len: None,
3118 max_move_value_depth: None,
3119 package_arena_size_in_bytes: None,
3120 max_move_enum_variants: None,
3121
3122 gas_rounding_step: None,
3123
3124 execution_version: None,
3125
3126 max_event_emit_size_total: None,
3127
3128 consensus_bad_nodes_stake_threshold: None,
3129
3130 max_jwk_votes_per_validator_per_epoch: None,
3131
3132 max_age_of_jwk_in_epochs: None,
3133
3134 random_beacon_reduction_allowed_delta: None,
3135
3136 random_beacon_reduction_lower_bound: None,
3137
3138 random_beacon_dkg_timeout_round: None,
3139
3140 random_beacon_min_round_interval_ms: None,
3141
3142 random_beacon_dkg_version: None,
3143
3144 consensus_max_transaction_size_bytes: None,
3145
3146 consensus_max_transactions_in_block_bytes: None,
3147
3148 consensus_max_num_transactions_in_block: None,
3149
3150 consensus_voting_rounds: None,
3151
3152 max_accumulated_txn_cost_per_object_in_narwhal_commit: None,
3153
3154 max_deferral_rounds_for_congestion_control: None,
3155
3156 epoch_close_deadline_ms: None,
3157
3158 max_txn_cost_overage_per_object_in_commit: None,
3159
3160 allowed_txn_cost_overage_burst_per_object_in_commit: None,
3161
3162 min_checkpoint_interval_ms: None,
3163
3164 checkpoint_summary_version_specific_data: None,
3165
3166 max_soft_bundle_size: None,
3167
3168 bridge_should_try_to_finalize_committee: None,
3169
3170 max_accumulated_txn_cost_per_object_in_mysticeti_commit: None,
3171
3172 max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit: None,
3173
3174 consensus_gc_depth: None,
3175
3176 gas_budget_based_txn_cost_cap_factor: None,
3177
3178 gas_budget_based_txn_cost_absolute_cap_commit_count: None,
3179
3180 sip_45_consensus_amplification_threshold: None,
3181 staggered_submission_signal_window_commits: None,
3182 staggered_submission_signal_min_excess_copies_per_commit: None,
3183 staggered_submission_signal_exit_dwell_commits: None,
3184 staggered_submission_signal_band1_enter_ratio_bps: None,
3185 staggered_submission_signal_band1_exit_ratio_bps: None,
3186 staggered_submission_signal_band2_enter_ratio_bps: None,
3187 staggered_submission_signal_band2_exit_ratio_bps: None,
3188
3189 use_object_per_epoch_marker_table_v2: None,
3190
3191 consensus_commit_rate_estimation_window_size: None,
3192
3193 aliased_addresses: vec![],
3194
3195 translation_per_command_base_charge: None,
3196 translation_per_input_base_charge: None,
3197 translation_pure_input_per_byte_charge: None,
3198 translation_per_type_node_charge: None,
3199 translation_per_reference_node_charge: None,
3200 translation_per_linkage_entry_charge: None,
3201 translation_per_live_reference_charge: None,
3202 max_ptb_live_references: None,
3203 max_ptb_returned_references: None,
3204 max_ptb_total_returned_references: None,
3205
3206 max_updates_per_settlement_txn: None,
3207
3208 gasless_max_computation_units: None,
3209 gasless_allowed_token_types: None,
3210 gasless_max_unused_inputs: None,
3211 gasless_max_pure_input_bytes: None,
3212 gasless_max_tps: None,
3213 include_special_package_amendments: None,
3214 gasless_max_tx_size_bytes: None,
3215 };
3218 for cur in 2..=version.0 {
3219 match cur {
3220 1 => unreachable!(),
3221 2 => {
3222 cfg.feature_flags.advance_epoch_start_time_in_safe_mode = true;
3223 }
3224 3 => {
3225 cfg.gas_model_version = Some(2);
3227 cfg.max_tx_gas = Some(50_000_000_000);
3229 cfg.base_tx_cost_fixed = Some(2_000);
3231 cfg.storage_gas_price = Some(76);
3233 cfg.feature_flags.loaded_child_objects_fixed = true;
3234 cfg.max_size_written_objects = Some(5 * 1000 * 1000);
3237 cfg.max_size_written_objects_system_tx = Some(50 * 1000 * 1000);
3240 cfg.feature_flags.package_upgrades = true;
3241 }
3242 4 => {
3247 cfg.reward_slashing_rate = Some(10000);
3249 cfg.gas_model_version = Some(3);
3251 }
3252 5 => {
3253 cfg.feature_flags.missing_type_is_compatibility_error = true;
3254 cfg.gas_model_version = Some(4);
3255 cfg.feature_flags.scoring_decision_with_validity_cutoff = true;
3256 }
3260 6 => {
3261 cfg.gas_model_version = Some(5);
3262 cfg.buffer_stake_for_protocol_upgrade_bps = Some(5000);
3263 cfg.feature_flags.consensus_order_end_of_epoch_last = true;
3264 }
3265 7 => {
3266 cfg.feature_flags.disallow_adding_abilities_on_upgrade = true;
3267 cfg.feature_flags
3268 .disable_invariant_violation_check_in_swap_loc = true;
3269 cfg.feature_flags.ban_entry_init = true;
3270 cfg.feature_flags.package_digest_hash_module = true;
3271 }
3272 8 => {
3273 cfg.feature_flags
3274 .disallow_change_struct_type_params_on_upgrade = true;
3275 }
3276 9 => {
3277 cfg.max_move_identifier_len = Some(128);
3279 cfg.feature_flags.no_extraneous_module_bytes = true;
3280 cfg.feature_flags
3281 .advance_to_highest_supported_protocol_version = true;
3282 }
3283 10 => {
3284 cfg.max_verifier_meter_ticks_per_function = Some(16_000_000);
3285 cfg.max_meter_ticks_per_module = Some(16_000_000);
3286 }
3287 11 => {
3288 cfg.max_move_value_depth = Some(128);
3289 }
3290 12 => {
3291 cfg.feature_flags.narwhal_versioned_metadata = true;
3292 if chain != Chain::Mainnet {
3293 cfg.feature_flags.commit_root_state_digest = true;
3294 }
3295
3296 if chain != Chain::Mainnet && chain != Chain::Testnet {
3297 cfg.feature_flags.zklogin_auth = true;
3298 }
3299 }
3300 13 => {}
3301 14 => {
3302 cfg.gas_rounding_step = Some(1_000);
3303 cfg.gas_model_version = Some(6);
3304 }
3305 15 => {
3306 cfg.feature_flags.consensus_transaction_ordering =
3307 ConsensusTransactionOrdering::ByGasPrice;
3308 }
3309 16 => {
3310 cfg.feature_flags.simplified_unwrap_then_delete = true;
3311 }
3312 17 => {
3313 cfg.feature_flags.upgraded_multisig_supported = true;
3314 }
3315 18 => {
3316 cfg.execution_version = Some(1);
3317 cfg.feature_flags.txn_base_cost_as_multiplier = true;
3326 cfg.base_tx_cost_fixed = Some(1_000);
3328 }
3329 19 => {
3330 cfg.max_num_event_emit = Some(1024);
3331 cfg.max_event_emit_size_total = Some(
3334 256 * 250 * 1024, );
3336 }
3337 20 => {
3338 cfg.feature_flags.commit_root_state_digest = true;
3339
3340 if chain != Chain::Mainnet {
3341 cfg.feature_flags.narwhal_new_leader_election_schedule = true;
3342 cfg.consensus_bad_nodes_stake_threshold = Some(20);
3343 }
3344 }
3345
3346 21 => {
3347 if chain != Chain::Mainnet {
3348 cfg.feature_flags.zklogin_supported_providers = BTreeSet::from([
3349 "Google".to_string(),
3350 "Facebook".to_string(),
3351 "Twitch".to_string(),
3352 ]);
3353 }
3354 }
3355 22 => {
3356 cfg.feature_flags.loaded_child_object_format = true;
3357 }
3358 23 => {
3359 cfg.feature_flags.loaded_child_object_format_type = true;
3360 cfg.feature_flags.narwhal_new_leader_election_schedule = true;
3361 cfg.consensus_bad_nodes_stake_threshold = Some(20);
3367 }
3368 24 => {
3369 cfg.feature_flags.simple_conservation_checks = true;
3370 cfg.max_publish_or_upgrade_per_ptb = Some(5);
3371
3372 cfg.feature_flags.end_of_epoch_transaction_supported = true;
3373
3374 if chain != Chain::Mainnet {
3375 cfg.feature_flags.enable_jwk_consensus_updates = true;
3376 cfg.max_jwk_votes_per_validator_per_epoch = Some(240);
3378 cfg.max_age_of_jwk_in_epochs = Some(1);
3379 }
3380 }
3381 25 => {
3382 cfg.feature_flags.zklogin_supported_providers = BTreeSet::from([
3384 "Google".to_string(),
3385 "Facebook".to_string(),
3386 "Twitch".to_string(),
3387 ]);
3388 cfg.feature_flags.zklogin_auth = true;
3389
3390 cfg.feature_flags.enable_jwk_consensus_updates = true;
3392 cfg.max_jwk_votes_per_validator_per_epoch = Some(240);
3393 cfg.max_age_of_jwk_in_epochs = Some(1);
3394 }
3395 26 => {
3396 cfg.gas_model_version = Some(7);
3397 if chain != Chain::Mainnet && chain != Chain::Testnet {
3399 cfg.transfer_receive_object_cost_base = Some(52);
3400 cfg.feature_flags.receive_objects = true;
3401 }
3402 }
3403 27 => {
3404 cfg.gas_model_version = Some(8);
3405 }
3406 28 => {
3407 cfg.check_zklogin_id_cost_base = Some(200);
3409 cfg.check_zklogin_issuer_cost_base = Some(200);
3411
3412 if chain != Chain::Mainnet && chain != Chain::Testnet {
3414 cfg.feature_flags.enable_effects_v2 = true;
3415 }
3416 }
3417 29 => {
3418 cfg.feature_flags.verify_legacy_zklogin_address = true;
3419 }
3420 30 => {
3421 if chain != Chain::Mainnet {
3423 cfg.feature_flags.narwhal_certificate_v2 = true;
3424 }
3425
3426 cfg.random_beacon_reduction_allowed_delta = Some(800);
3427 if chain != Chain::Mainnet {
3429 cfg.feature_flags.enable_effects_v2 = true;
3430 }
3431
3432 cfg.feature_flags.zklogin_supported_providers = BTreeSet::default();
3436
3437 cfg.feature_flags.recompute_has_public_transfer_in_execution = true;
3438 }
3439 31 => {
3440 cfg.execution_version = Some(2);
3441 if chain != Chain::Mainnet && chain != Chain::Testnet {
3443 cfg.feature_flags.shared_object_deletion = true;
3444 }
3445 }
3446 32 => {
3447 if chain != Chain::Mainnet {
3449 cfg.feature_flags.accept_zklogin_in_multisig = true;
3450 }
3451 if chain != Chain::Mainnet {
3453 cfg.transfer_receive_object_cost_base = Some(52);
3454 cfg.feature_flags.receive_objects = true;
3455 }
3456 if chain != Chain::Mainnet && chain != Chain::Testnet {
3458 cfg.feature_flags.random_beacon = true;
3459 cfg.random_beacon_reduction_lower_bound = Some(1600);
3460 cfg.random_beacon_dkg_timeout_round = Some(3000);
3461 cfg.random_beacon_min_round_interval_ms = Some(150);
3462 }
3463 if chain != Chain::Testnet && chain != Chain::Mainnet {
3465 cfg.feature_flags.include_consensus_digest_in_prologue = true;
3466 }
3467
3468 cfg.feature_flags.narwhal_certificate_v2 = true;
3470 }
3471 33 => {
3472 cfg.feature_flags.hardened_otw_check = true;
3473 cfg.feature_flags.allow_receiving_object_id = true;
3474
3475 cfg.transfer_receive_object_cost_base = Some(52);
3477 cfg.feature_flags.receive_objects = true;
3478
3479 if chain != Chain::Mainnet {
3481 cfg.feature_flags.shared_object_deletion = true;
3482 }
3483
3484 cfg.feature_flags.enable_effects_v2 = true;
3485 }
3486 34 => {}
3487 35 => {
3488 if chain != Chain::Mainnet && chain != Chain::Testnet {
3490 cfg.feature_flags.enable_poseidon = true;
3491 cfg.poseidon_bn254_cost_base = Some(260);
3492 cfg.poseidon_bn254_cost_per_block = Some(10);
3493 }
3494
3495 cfg.feature_flags.enable_coin_deny_list = true;
3496 }
3497 36 => {
3498 if chain != Chain::Mainnet && chain != Chain::Testnet {
3500 cfg.feature_flags.enable_group_ops_native_functions = true;
3501 cfg.feature_flags.enable_group_ops_native_function_msm = true;
3502 cfg.group_ops_bls12381_decode_scalar_cost = Some(52);
3504 cfg.group_ops_bls12381_decode_g1_cost = Some(52);
3505 cfg.group_ops_bls12381_decode_g2_cost = Some(52);
3506 cfg.group_ops_bls12381_decode_gt_cost = Some(52);
3507 cfg.group_ops_bls12381_scalar_add_cost = Some(52);
3508 cfg.group_ops_bls12381_g1_add_cost = Some(52);
3509 cfg.group_ops_bls12381_g2_add_cost = Some(52);
3510 cfg.group_ops_bls12381_gt_add_cost = Some(52);
3511 cfg.group_ops_bls12381_scalar_sub_cost = Some(52);
3512 cfg.group_ops_bls12381_g1_sub_cost = Some(52);
3513 cfg.group_ops_bls12381_g2_sub_cost = Some(52);
3514 cfg.group_ops_bls12381_gt_sub_cost = Some(52);
3515 cfg.group_ops_bls12381_scalar_mul_cost = Some(52);
3516 cfg.group_ops_bls12381_g1_mul_cost = Some(52);
3517 cfg.group_ops_bls12381_g2_mul_cost = Some(52);
3518 cfg.group_ops_bls12381_gt_mul_cost = Some(52);
3519 cfg.group_ops_bls12381_scalar_div_cost = Some(52);
3520 cfg.group_ops_bls12381_g1_div_cost = Some(52);
3521 cfg.group_ops_bls12381_g2_div_cost = Some(52);
3522 cfg.group_ops_bls12381_gt_div_cost = Some(52);
3523 cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(52);
3524 cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(52);
3525 cfg.group_ops_bls12381_g1_hash_to_cost_per_byte = Some(2);
3526 cfg.group_ops_bls12381_g2_hash_to_cost_per_byte = Some(2);
3527 cfg.group_ops_bls12381_g1_msm_base_cost = Some(52);
3528 cfg.group_ops_bls12381_g2_msm_base_cost = Some(52);
3529 cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(52);
3530 cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(52);
3531 cfg.group_ops_bls12381_msm_max_len = Some(32);
3532 cfg.group_ops_bls12381_pairing_cost = Some(52);
3533 }
3534 cfg.feature_flags.shared_object_deletion = true;
3536
3537 cfg.consensus_max_transaction_size_bytes = Some(256 * 1024); cfg.consensus_max_transactions_in_block_bytes = Some(6 * 1_024 * 1024);
3539 }
3541 37 => {
3542 cfg.feature_flags.reject_mutable_random_on_entry_functions = true;
3543
3544 if chain != Chain::Mainnet {
3546 cfg.feature_flags.include_consensus_digest_in_prologue = true;
3547 }
3548 }
3549 38 => {
3550 cfg.binary_module_handles = Some(100);
3551 cfg.binary_struct_handles = Some(300);
3552 cfg.binary_function_handles = Some(1500);
3553 cfg.binary_function_instantiations = Some(750);
3554 cfg.binary_signatures = Some(1000);
3555 cfg.binary_constant_pool = Some(4000);
3559 cfg.binary_identifiers = Some(10000);
3560 cfg.binary_address_identifiers = Some(100);
3561 cfg.binary_struct_defs = Some(200);
3562 cfg.binary_struct_def_instantiations = Some(100);
3563 cfg.binary_function_defs = Some(1000);
3564 cfg.binary_field_handles = Some(500);
3565 cfg.binary_field_instantiations = Some(250);
3566 cfg.binary_friend_decls = Some(100);
3567 cfg.max_package_dependencies = Some(32);
3569 cfg.max_modules_in_publish = Some(64);
3570 cfg.execution_version = Some(3);
3572 }
3573 39 => {
3574 }
3576 40 => {}
3577 41 => {
3578 cfg.feature_flags.enable_group_ops_native_functions = true;
3580 cfg.group_ops_bls12381_decode_scalar_cost = Some(52);
3582 cfg.group_ops_bls12381_decode_g1_cost = Some(52);
3583 cfg.group_ops_bls12381_decode_g2_cost = Some(52);
3584 cfg.group_ops_bls12381_decode_gt_cost = Some(52);
3585 cfg.group_ops_bls12381_scalar_add_cost = Some(52);
3586 cfg.group_ops_bls12381_g1_add_cost = Some(52);
3587 cfg.group_ops_bls12381_g2_add_cost = Some(52);
3588 cfg.group_ops_bls12381_gt_add_cost = Some(52);
3589 cfg.group_ops_bls12381_scalar_sub_cost = Some(52);
3590 cfg.group_ops_bls12381_g1_sub_cost = Some(52);
3591 cfg.group_ops_bls12381_g2_sub_cost = Some(52);
3592 cfg.group_ops_bls12381_gt_sub_cost = Some(52);
3593 cfg.group_ops_bls12381_scalar_mul_cost = Some(52);
3594 cfg.group_ops_bls12381_g1_mul_cost = Some(52);
3595 cfg.group_ops_bls12381_g2_mul_cost = Some(52);
3596 cfg.group_ops_bls12381_gt_mul_cost = Some(52);
3597 cfg.group_ops_bls12381_scalar_div_cost = Some(52);
3598 cfg.group_ops_bls12381_g1_div_cost = Some(52);
3599 cfg.group_ops_bls12381_g2_div_cost = Some(52);
3600 cfg.group_ops_bls12381_gt_div_cost = Some(52);
3601 cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(52);
3602 cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(52);
3603 cfg.group_ops_bls12381_g1_hash_to_cost_per_byte = Some(2);
3604 cfg.group_ops_bls12381_g2_hash_to_cost_per_byte = Some(2);
3605 cfg.group_ops_bls12381_g1_msm_base_cost = Some(52);
3606 cfg.group_ops_bls12381_g2_msm_base_cost = Some(52);
3607 cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(52);
3608 cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(52);
3609 cfg.group_ops_bls12381_msm_max_len = Some(32);
3610 cfg.group_ops_bls12381_pairing_cost = Some(52);
3611 }
3612 42 => {}
3613 43 => {
3614 cfg.feature_flags.zklogin_max_epoch_upper_bound_delta = Some(30);
3615 cfg.max_meter_ticks_per_package = Some(16_000_000);
3616 }
3617 44 => {
3618 cfg.feature_flags.include_consensus_digest_in_prologue = true;
3620 if chain != Chain::Mainnet {
3622 cfg.feature_flags.consensus_choice = ConsensusChoice::SwapEachEpoch;
3623 }
3624 }
3625 45 => {
3626 if chain != Chain::Testnet && chain != Chain::Mainnet {
3628 cfg.feature_flags.consensus_network = ConsensusNetwork::Tonic;
3629 }
3630
3631 if chain != Chain::Mainnet {
3632 cfg.feature_flags.mysticeti_leader_scoring_and_schedule = true;
3634 }
3635 cfg.min_move_binary_format_version = Some(6);
3636 cfg.feature_flags.accept_zklogin_in_multisig = true;
3637
3638 if chain != Chain::Mainnet && chain != Chain::Testnet {
3642 cfg.feature_flags.bridge = true;
3643 }
3644 }
3645 46 => {
3646 if chain != Chain::Mainnet {
3648 cfg.feature_flags.bridge = true;
3649 }
3650
3651 cfg.feature_flags.reshare_at_same_initial_version = true;
3653 }
3654 47 => {}
3655 48 => {
3656 cfg.feature_flags.consensus_network = ConsensusNetwork::Tonic;
3658
3659 cfg.feature_flags.resolve_abort_locations_to_package_id = true;
3661
3662 if chain != Chain::Mainnet {
3664 cfg.feature_flags.random_beacon = true;
3665 cfg.random_beacon_reduction_lower_bound = Some(1600);
3666 cfg.random_beacon_dkg_timeout_round = Some(3000);
3667 cfg.random_beacon_min_round_interval_ms = Some(200);
3668 }
3669
3670 cfg.feature_flags.mysticeti_use_committed_subdag_digest = true;
3672 }
3673 49 => {
3674 if chain != Chain::Testnet && chain != Chain::Mainnet {
3675 cfg.move_binary_format_version = Some(7);
3676 }
3677
3678 if chain != Chain::Mainnet && chain != Chain::Testnet {
3680 cfg.feature_flags.enable_vdf = true;
3681 cfg.vdf_verify_vdf_cost = Some(1500);
3684 cfg.vdf_hash_to_input_cost = Some(100);
3685 }
3686
3687 if chain != Chain::Testnet && chain != Chain::Mainnet {
3689 cfg.feature_flags
3690 .record_consensus_determined_version_assignments_in_prologue = true;
3691 }
3692
3693 if chain != Chain::Mainnet {
3695 cfg.feature_flags.consensus_choice = ConsensusChoice::Mysticeti;
3696 }
3697
3698 cfg.feature_flags.fresh_vm_on_framework_upgrade = true;
3700 }
3701 50 => {
3702 if chain != Chain::Mainnet {
3704 cfg.checkpoint_summary_version_specific_data = Some(1);
3705 cfg.min_checkpoint_interval_ms = Some(200);
3706 }
3707
3708 if chain != Chain::Testnet && chain != Chain::Mainnet {
3710 cfg.feature_flags
3711 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = true;
3712 }
3713
3714 cfg.feature_flags.mysticeti_num_leaders_per_round = Some(1);
3715
3716 cfg.max_deferral_rounds_for_congestion_control = Some(10);
3718 }
3719 51 => {
3720 cfg.random_beacon_dkg_version = Some(1);
3721
3722 if chain != Chain::Testnet && chain != Chain::Mainnet {
3723 cfg.feature_flags.enable_coin_deny_list_v2 = true;
3724 }
3725 }
3726 52 => {
3727 if chain != Chain::Mainnet {
3728 cfg.feature_flags.soft_bundle = true;
3729 cfg.max_soft_bundle_size = Some(5);
3730 }
3731
3732 cfg.config_read_setting_impl_cost_base = Some(100);
3733 cfg.config_read_setting_impl_cost_per_byte = Some(40);
3734
3735 if chain != Chain::Testnet && chain != Chain::Mainnet {
3737 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(100);
3738 cfg.feature_flags.per_object_congestion_control_mode =
3739 PerObjectCongestionControlMode::TotalTxCount;
3740 }
3741
3742 cfg.feature_flags.consensus_choice = ConsensusChoice::Mysticeti;
3744
3745 cfg.feature_flags.mysticeti_leader_scoring_and_schedule = true;
3747
3748 cfg.checkpoint_summary_version_specific_data = Some(1);
3750 cfg.min_checkpoint_interval_ms = Some(200);
3751
3752 if chain != Chain::Mainnet {
3754 cfg.feature_flags
3755 .record_consensus_determined_version_assignments_in_prologue = true;
3756 cfg.feature_flags
3757 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = true;
3758 }
3759 if chain != Chain::Mainnet {
3761 cfg.move_binary_format_version = Some(7);
3762 }
3763
3764 if chain != Chain::Testnet && chain != Chain::Mainnet {
3765 cfg.feature_flags.passkey_auth = true;
3766 }
3767 cfg.feature_flags.enable_coin_deny_list_v2 = true;
3768 }
3769 53 => {
3770 cfg.bridge_should_try_to_finalize_committee = Some(chain != Chain::Mainnet);
3772
3773 cfg.feature_flags
3775 .record_consensus_determined_version_assignments_in_prologue = true;
3776 cfg.feature_flags
3777 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = true;
3778
3779 if chain == Chain::Unknown {
3780 cfg.feature_flags.authority_capabilities_v2 = true;
3781 }
3782
3783 if chain != Chain::Mainnet {
3785 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(100);
3786 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(10);
3787 cfg.feature_flags.per_object_congestion_control_mode =
3788 PerObjectCongestionControlMode::TotalTxCount;
3789 }
3790
3791 cfg.bcs_per_byte_serialized_cost = Some(2);
3793 cfg.bcs_legacy_min_output_size_cost = Some(1);
3794 cfg.bcs_failure_cost = Some(52);
3795 cfg.debug_print_base_cost = Some(52);
3796 cfg.debug_print_stack_trace_base_cost = Some(52);
3797 cfg.hash_sha2_256_base_cost = Some(52);
3798 cfg.hash_sha2_256_per_byte_cost = Some(2);
3799 cfg.hash_sha2_256_legacy_min_input_len_cost = Some(1);
3800 cfg.hash_sha3_256_base_cost = Some(52);
3801 cfg.hash_sha3_256_per_byte_cost = Some(2);
3802 cfg.hash_sha3_256_legacy_min_input_len_cost = Some(1);
3803 cfg.type_name_get_base_cost = Some(52);
3804 cfg.type_name_get_per_byte_cost = Some(2);
3805 cfg.string_check_utf8_base_cost = Some(52);
3806 cfg.string_check_utf8_per_byte_cost = Some(2);
3807 cfg.string_is_char_boundary_base_cost = Some(52);
3808 cfg.string_sub_string_base_cost = Some(52);
3809 cfg.string_sub_string_per_byte_cost = Some(2);
3810 cfg.string_index_of_base_cost = Some(52);
3811 cfg.string_index_of_per_byte_pattern_cost = Some(2);
3812 cfg.string_index_of_per_byte_searched_cost = Some(2);
3813 cfg.vector_empty_base_cost = Some(52);
3814 cfg.vector_length_base_cost = Some(52);
3815 cfg.vector_push_back_base_cost = Some(52);
3816 cfg.vector_push_back_legacy_per_abstract_memory_unit_cost = Some(2);
3817 cfg.vector_borrow_base_cost = Some(52);
3818 cfg.vector_pop_back_base_cost = Some(52);
3819 cfg.vector_destroy_empty_base_cost = Some(52);
3820 cfg.vector_swap_base_cost = Some(52);
3821 }
3822 54 => {
3823 cfg.feature_flags.random_beacon = true;
3825 cfg.random_beacon_reduction_lower_bound = Some(1000);
3826 cfg.random_beacon_dkg_timeout_round = Some(3000);
3827 cfg.random_beacon_min_round_interval_ms = Some(500);
3828
3829 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(100);
3831 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(10);
3832 cfg.feature_flags.per_object_congestion_control_mode =
3833 PerObjectCongestionControlMode::TotalTxCount;
3834
3835 cfg.feature_flags.soft_bundle = true;
3837 cfg.max_soft_bundle_size = Some(5);
3838 }
3839 55 => {
3840 cfg.move_binary_format_version = Some(7);
3842
3843 cfg.consensus_max_transactions_in_block_bytes = Some(512 * 1024);
3845 cfg.consensus_max_num_transactions_in_block = Some(512);
3848
3849 cfg.feature_flags.rethrow_serialization_type_layout_errors = true;
3850 }
3851 56 => {
3852 if chain == Chain::Mainnet {
3853 cfg.feature_flags.bridge = true;
3854 }
3855 }
3856 57 => {
3857 cfg.random_beacon_reduction_lower_bound = Some(800);
3859 }
3860 58 => {
3861 if chain == Chain::Mainnet {
3862 cfg.bridge_should_try_to_finalize_committee = Some(true);
3863 }
3864
3865 if chain != Chain::Mainnet && chain != Chain::Testnet {
3866 cfg.feature_flags
3868 .consensus_distributed_vote_scoring_strategy = true;
3869 }
3870 }
3871 59 => {
3872 cfg.feature_flags.consensus_round_prober = true;
3874 }
3875 60 => {
3876 cfg.max_type_to_layout_nodes = Some(512);
3877 cfg.feature_flags.validate_identifier_inputs = true;
3878 }
3879 61 => {
3880 if chain != Chain::Mainnet {
3881 cfg.feature_flags
3883 .consensus_distributed_vote_scoring_strategy = true;
3884 }
3885 cfg.random_beacon_reduction_lower_bound = Some(700);
3887
3888 if chain != Chain::Mainnet && chain != Chain::Testnet {
3889 cfg.feature_flags.mysticeti_fastpath = true;
3891 }
3892 }
3893 62 => {
3894 cfg.feature_flags.relocate_event_module = true;
3895 }
3896 63 => {
3897 cfg.feature_flags.per_object_congestion_control_mode =
3898 PerObjectCongestionControlMode::TotalGasBudgetWithCap;
3899 cfg.gas_budget_based_txn_cost_cap_factor = Some(400_000);
3900 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(18_500_000);
3901 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(240_000_000);
3902 }
3903 64 => {
3904 cfg.feature_flags.per_object_congestion_control_mode =
3905 PerObjectCongestionControlMode::TotalTxCount;
3906 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(40);
3907 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(3);
3908 }
3909 65 => {
3910 cfg.feature_flags
3912 .consensus_distributed_vote_scoring_strategy = true;
3913 }
3914 66 => {
3915 if chain == Chain::Mainnet {
3916 cfg.feature_flags
3918 .consensus_distributed_vote_scoring_strategy = false;
3919 }
3920 }
3921 67 => {
3922 cfg.feature_flags
3924 .consensus_distributed_vote_scoring_strategy = true;
3925 }
3926 68 => {
3927 cfg.group_ops_bls12381_g1_to_uncompressed_g1_cost = Some(26);
3928 cfg.group_ops_bls12381_uncompressed_g1_to_g1_cost = Some(52);
3929 cfg.group_ops_bls12381_uncompressed_g1_sum_base_cost = Some(26);
3930 cfg.group_ops_bls12381_uncompressed_g1_sum_cost_per_term = Some(13);
3931 cfg.group_ops_bls12381_uncompressed_g1_sum_max_terms = Some(2000);
3932
3933 if chain != Chain::Mainnet && chain != Chain::Testnet {
3934 cfg.feature_flags.uncompressed_g1_group_elements = true;
3935 }
3936
3937 cfg.feature_flags.per_object_congestion_control_mode =
3938 PerObjectCongestionControlMode::TotalGasBudgetWithCap;
3939 cfg.gas_budget_based_txn_cost_cap_factor = Some(400_000);
3940 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(18_500_000);
3941 cfg.max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit =
3942 Some(3_700_000); cfg.max_txn_cost_overage_per_object_in_commit = Some(u64::MAX);
3944 cfg.gas_budget_based_txn_cost_absolute_cap_commit_count = Some(50);
3945
3946 cfg.random_beacon_reduction_lower_bound = Some(500);
3948
3949 cfg.feature_flags.disallow_new_modules_in_deps_only_packages = true;
3950 }
3951 69 => {
3952 cfg.consensus_voting_rounds = Some(40);
3954
3955 if chain != Chain::Mainnet && chain != Chain::Testnet {
3956 cfg.feature_flags.consensus_smart_ancestor_selection = true;
3958 }
3959
3960 if chain != Chain::Mainnet {
3961 cfg.feature_flags.uncompressed_g1_group_elements = true;
3962 }
3963 }
3964 70 => {
3965 if chain != Chain::Mainnet {
3966 cfg.feature_flags.consensus_smart_ancestor_selection = true;
3968 cfg.feature_flags
3970 .consensus_round_prober_probe_accepted_rounds = true;
3971 }
3972
3973 cfg.poseidon_bn254_cost_per_block = Some(388);
3974
3975 cfg.gas_model_version = Some(9);
3976 cfg.feature_flags.native_charging_v2 = true;
3977 cfg.bls12381_bls12381_min_sig_verify_cost_base = Some(44064);
3978 cfg.bls12381_bls12381_min_pk_verify_cost_base = Some(49282);
3979 cfg.ecdsa_k1_secp256k1_verify_keccak256_cost_base = Some(1470);
3980 cfg.ecdsa_k1_secp256k1_verify_sha256_cost_base = Some(1470);
3981 cfg.ecdsa_r1_secp256r1_verify_sha256_cost_base = Some(4225);
3982 cfg.ecdsa_r1_secp256r1_verify_keccak256_cost_base = Some(4225);
3983 cfg.ecvrf_ecvrf_verify_cost_base = Some(4848);
3984 cfg.ed25519_ed25519_verify_cost_base = Some(1802);
3985
3986 cfg.ecdsa_r1_ecrecover_keccak256_cost_base = Some(1173);
3988 cfg.ecdsa_r1_ecrecover_sha256_cost_base = Some(1173);
3989 cfg.ecdsa_k1_ecrecover_keccak256_cost_base = Some(500);
3990 cfg.ecdsa_k1_ecrecover_sha256_cost_base = Some(500);
3991
3992 cfg.groth16_prepare_verifying_key_bls12381_cost_base = Some(53838);
3993 cfg.groth16_prepare_verifying_key_bn254_cost_base = Some(82010);
3994 cfg.groth16_verify_groth16_proof_internal_bls12381_cost_base = Some(72090);
3995 cfg.groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input =
3996 Some(8213);
3997 cfg.groth16_verify_groth16_proof_internal_bn254_cost_base = Some(115502);
3998 cfg.groth16_verify_groth16_proof_internal_bn254_cost_per_public_input =
3999 Some(9484);
4000
4001 cfg.hash_keccak256_cost_base = Some(10);
4002 cfg.hash_blake2b256_cost_base = Some(10);
4003
4004 cfg.group_ops_bls12381_decode_scalar_cost = Some(7);
4006 cfg.group_ops_bls12381_decode_g1_cost = Some(2848);
4007 cfg.group_ops_bls12381_decode_g2_cost = Some(3770);
4008 cfg.group_ops_bls12381_decode_gt_cost = Some(3068);
4009
4010 cfg.group_ops_bls12381_scalar_add_cost = Some(10);
4011 cfg.group_ops_bls12381_g1_add_cost = Some(1556);
4012 cfg.group_ops_bls12381_g2_add_cost = Some(3048);
4013 cfg.group_ops_bls12381_gt_add_cost = Some(188);
4014
4015 cfg.group_ops_bls12381_scalar_sub_cost = Some(10);
4016 cfg.group_ops_bls12381_g1_sub_cost = Some(1550);
4017 cfg.group_ops_bls12381_g2_sub_cost = Some(3019);
4018 cfg.group_ops_bls12381_gt_sub_cost = Some(497);
4019
4020 cfg.group_ops_bls12381_scalar_mul_cost = Some(11);
4021 cfg.group_ops_bls12381_g1_mul_cost = Some(4842);
4022 cfg.group_ops_bls12381_g2_mul_cost = Some(9108);
4023 cfg.group_ops_bls12381_gt_mul_cost = Some(27490);
4024
4025 cfg.group_ops_bls12381_scalar_div_cost = Some(91);
4026 cfg.group_ops_bls12381_g1_div_cost = Some(5091);
4027 cfg.group_ops_bls12381_g2_div_cost = Some(9206);
4028 cfg.group_ops_bls12381_gt_div_cost = Some(27804);
4029
4030 cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(2962);
4031 cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(8688);
4032
4033 cfg.group_ops_bls12381_g1_msm_base_cost = Some(62648);
4034 cfg.group_ops_bls12381_g2_msm_base_cost = Some(131192);
4035 cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(1333);
4036 cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(3216);
4037
4038 cfg.group_ops_bls12381_uncompressed_g1_to_g1_cost = Some(677);
4039 cfg.group_ops_bls12381_g1_to_uncompressed_g1_cost = Some(2099);
4040 cfg.group_ops_bls12381_uncompressed_g1_sum_base_cost = Some(77);
4041 cfg.group_ops_bls12381_uncompressed_g1_sum_cost_per_term = Some(26);
4042
4043 cfg.group_ops_bls12381_pairing_cost = Some(26897);
4044 cfg.group_ops_bls12381_uncompressed_g1_sum_max_terms = Some(1200);
4045
4046 cfg.validator_validate_metadata_cost_base = Some(20000);
4047 }
4048 71 => {
4049 cfg.sip_45_consensus_amplification_threshold = Some(5);
4050
4051 cfg.allowed_txn_cost_overage_burst_per_object_in_commit = Some(185_000_000);
4053 }
4054 72 => {
4055 cfg.feature_flags.convert_type_argument_error = true;
4056
4057 cfg.max_tx_gas = Some(50_000_000_000_000);
4060 cfg.max_gas_price = Some(50_000_000_000);
4062
4063 cfg.feature_flags.variant_nodes = true;
4064 }
4065 73 => {
4066 cfg.use_object_per_epoch_marker_table_v2 = Some(true);
4068
4069 if chain != Chain::Mainnet && chain != Chain::Testnet {
4070 cfg.consensus_gc_depth = Some(60);
4073 }
4074
4075 if chain != Chain::Mainnet {
4076 cfg.feature_flags.consensus_zstd_compression = true;
4078 }
4079
4080 cfg.feature_flags.consensus_smart_ancestor_selection = true;
4082 cfg.feature_flags
4084 .consensus_round_prober_probe_accepted_rounds = true;
4085
4086 cfg.feature_flags.per_object_congestion_control_mode =
4088 PerObjectCongestionControlMode::TotalGasBudgetWithCap;
4089 cfg.gas_budget_based_txn_cost_cap_factor = Some(400_000);
4090 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(37_000_000);
4091 cfg.max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit =
4092 Some(7_400_000); cfg.max_txn_cost_overage_per_object_in_commit = Some(u64::MAX);
4094 cfg.gas_budget_based_txn_cost_absolute_cap_commit_count = Some(50);
4095 cfg.allowed_txn_cost_overage_burst_per_object_in_commit = Some(370_000_000);
4096 }
4097 74 => {
4098 if chain != Chain::Mainnet && chain != Chain::Testnet {
4100 cfg.feature_flags.enable_nitro_attestation = true;
4101 }
4102 cfg.nitro_attestation_parse_base_cost = Some(53 * 50);
4103 cfg.nitro_attestation_parse_cost_per_byte = Some(50);
4104 cfg.nitro_attestation_verify_base_cost = Some(49632 * 50);
4105 cfg.nitro_attestation_verify_cost_per_cert = Some(52369 * 50);
4106
4107 cfg.feature_flags.consensus_zstd_compression = true;
4109
4110 if chain != Chain::Mainnet && chain != Chain::Testnet {
4111 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
4112 }
4113 }
4114 75 => {
4115 if chain != Chain::Mainnet {
4116 cfg.feature_flags.passkey_auth = true;
4117 }
4118 }
4119 76 => {
4120 if chain != Chain::Mainnet && chain != Chain::Testnet {
4121 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
4122 cfg.consensus_commit_rate_estimation_window_size = Some(10);
4123 }
4124 cfg.feature_flags.minimize_child_object_mutations = true;
4125
4126 if chain != Chain::Mainnet {
4127 cfg.feature_flags.accept_passkey_in_multisig = true;
4128 }
4129 }
4130 77 => {
4131 cfg.feature_flags.uncompressed_g1_group_elements = true;
4132
4133 if chain != Chain::Mainnet {
4134 cfg.consensus_gc_depth = Some(60);
4135 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
4136 }
4137 }
4138 78 => {
4139 cfg.feature_flags.move_native_context = true;
4140 cfg.tx_context_fresh_id_cost_base = Some(52);
4141 cfg.tx_context_sender_cost_base = Some(30);
4142 cfg.tx_context_epoch_cost_base = Some(30);
4143 cfg.tx_context_epoch_timestamp_ms_cost_base = Some(30);
4144 cfg.tx_context_sponsor_cost_base = Some(30);
4145 cfg.tx_context_gas_price_cost_base = Some(30);
4146 cfg.tx_context_gas_budget_cost_base = Some(30);
4147 cfg.tx_context_ids_created_cost_base = Some(30);
4148 cfg.tx_context_replace_cost_base = Some(30);
4149 cfg.gas_model_version = Some(10);
4150
4151 if chain != Chain::Mainnet {
4152 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
4153 cfg.consensus_commit_rate_estimation_window_size = Some(10);
4154
4155 cfg.feature_flags.per_object_congestion_control_mode =
4157 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4158 ExecutionTimeEstimateParams {
4159 target_utilization: 30,
4160 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4162 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4164 stored_observations_limit: u64::MAX,
4165 stake_weighted_median_threshold: 0,
4166 default_none_duration_for_new_keys: false,
4167 observations_chunk_size: None,
4168 },
4169 );
4170 }
4171 }
4172 79 => {
4173 if chain != Chain::Mainnet {
4174 cfg.feature_flags.consensus_median_based_commit_timestamp = true;
4175
4176 cfg.consensus_bad_nodes_stake_threshold = Some(30);
4179
4180 cfg.feature_flags.consensus_batched_block_sync = true;
4181
4182 cfg.feature_flags.enable_nitro_attestation = true
4184 }
4185 cfg.feature_flags.normalize_ptb_arguments = true;
4186
4187 cfg.consensus_gc_depth = Some(60);
4188 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
4189 }
4190 80 => {
4191 cfg.max_ptb_value_size = Some(1024 * 1024);
4192 }
4193 81 => {
4194 cfg.feature_flags.consensus_median_based_commit_timestamp = true;
4195 cfg.feature_flags.enforce_checkpoint_timestamp_monotonicity = true;
4196 cfg.consensus_bad_nodes_stake_threshold = Some(30)
4197 }
4198 82 => {
4199 cfg.feature_flags.max_ptb_value_size_v2 = true;
4200 }
4201 83 => {
4202 if chain == Chain::Mainnet {
4203 let aliased: [u8; 32] = Hex::decode(
4205 "0x0b2da327ba6a4cacbe75dddd50e6e8bbf81d6496e92d66af9154c61c77f7332f",
4206 )
4207 .unwrap()
4208 .try_into()
4209 .unwrap();
4210
4211 cfg.aliased_addresses.push(AliasedAddress {
4213 original: Hex::decode("0xcd8962dad278d8b50fa0f9eb0186bfa4cbdecc6d59377214c88d0286a0ac9562").unwrap().try_into().unwrap(),
4214 aliased,
4215 allowed_tx_digests: vec![
4216 Base58::decode("B2eGLFoMHgj93Ni8dAJBfqGzo8EWSTLBesZzhEpTPA4").unwrap().try_into().unwrap(),
4217 ],
4218 });
4219
4220 cfg.aliased_addresses.push(AliasedAddress {
4221 original: Hex::decode("0xe28b50cef1d633ea43d3296a3f6b67ff0312a5f1a99f0af753c85b8b5de8ff06").unwrap().try_into().unwrap(),
4222 aliased,
4223 allowed_tx_digests: vec![
4224 Base58::decode("J4QqSAgp7VrQtQpMy5wDX4QGsCSEZu3U5KuDAkbESAge").unwrap().try_into().unwrap(),
4225 ],
4226 });
4227 }
4228
4229 if chain != Chain::Mainnet {
4232 cfg.feature_flags.resolve_type_input_ids_to_defining_id = true;
4233 cfg.transfer_party_transfer_internal_cost_base = Some(52);
4234
4235 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
4237 cfg.consensus_commit_rate_estimation_window_size = Some(10);
4238 cfg.feature_flags.per_object_congestion_control_mode =
4239 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4240 ExecutionTimeEstimateParams {
4241 target_utilization: 30,
4242 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4244 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4246 stored_observations_limit: u64::MAX,
4247 stake_weighted_median_threshold: 0,
4248 default_none_duration_for_new_keys: false,
4249 observations_chunk_size: None,
4250 },
4251 );
4252
4253 cfg.feature_flags.consensus_batched_block_sync = true;
4255
4256 cfg.feature_flags.enable_nitro_attestation_upgraded_parsing = true;
4259 cfg.feature_flags.enable_nitro_attestation = true;
4260 }
4261 }
4262 84 => {
4263 if chain == Chain::Mainnet {
4264 cfg.feature_flags.resolve_type_input_ids_to_defining_id = true;
4265 cfg.transfer_party_transfer_internal_cost_base = Some(52);
4266
4267 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
4269 cfg.consensus_commit_rate_estimation_window_size = Some(10);
4270 cfg.feature_flags.per_object_congestion_control_mode =
4271 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4272 ExecutionTimeEstimateParams {
4273 target_utilization: 30,
4274 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4276 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4278 stored_observations_limit: u64::MAX,
4279 stake_weighted_median_threshold: 0,
4280 default_none_duration_for_new_keys: false,
4281 observations_chunk_size: None,
4282 },
4283 );
4284
4285 cfg.feature_flags.consensus_batched_block_sync = true;
4287
4288 cfg.feature_flags.enable_nitro_attestation_upgraded_parsing = true;
4291 cfg.feature_flags.enable_nitro_attestation = true;
4292 }
4293
4294 cfg.feature_flags.per_object_congestion_control_mode =
4296 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4297 ExecutionTimeEstimateParams {
4298 target_utilization: 30,
4299 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4301 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4303 stored_observations_limit: 20,
4304 stake_weighted_median_threshold: 0,
4305 default_none_duration_for_new_keys: false,
4306 observations_chunk_size: None,
4307 },
4308 );
4309 cfg.feature_flags.allow_unbounded_system_objects = true;
4310 }
4311 85 => {
4312 if chain != Chain::Mainnet && chain != Chain::Testnet {
4313 cfg.feature_flags.enable_party_transfer = true;
4314 }
4315
4316 cfg.feature_flags
4317 .record_consensus_determined_version_assignments_in_prologue_v2 = true;
4318 cfg.feature_flags.disallow_self_identifier = true;
4319 cfg.feature_flags.per_object_congestion_control_mode =
4320 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4321 ExecutionTimeEstimateParams {
4322 target_utilization: 50,
4323 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4325 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4327 stored_observations_limit: 20,
4328 stake_weighted_median_threshold: 0,
4329 default_none_duration_for_new_keys: false,
4330 observations_chunk_size: None,
4331 },
4332 );
4333 }
4334 86 => {
4335 cfg.feature_flags.type_tags_in_object_runtime = true;
4336 cfg.max_move_enum_variants = Some(move_core_types::VARIANT_COUNT_MAX);
4337
4338 cfg.feature_flags.per_object_congestion_control_mode =
4340 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4341 ExecutionTimeEstimateParams {
4342 target_utilization: 50,
4343 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4345 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4347 stored_observations_limit: 20,
4348 stake_weighted_median_threshold: 3334,
4349 default_none_duration_for_new_keys: false,
4350 observations_chunk_size: None,
4351 },
4352 );
4353 if chain != Chain::Mainnet {
4355 cfg.feature_flags.enable_party_transfer = true;
4356 }
4357 }
4358 87 => {
4359 if chain == Chain::Mainnet {
4360 cfg.feature_flags.record_time_estimate_processed = true;
4361 }
4362 cfg.feature_flags.better_adapter_type_resolution_errors = true;
4363 }
4364 88 => {
4365 cfg.feature_flags.record_time_estimate_processed = true;
4366 cfg.tx_context_rgp_cost_base = Some(30);
4367 cfg.feature_flags
4368 .ignore_execution_time_observations_after_certs_closed = true;
4369
4370 cfg.feature_flags.per_object_congestion_control_mode =
4373 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4374 ExecutionTimeEstimateParams {
4375 target_utilization: 50,
4376 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4378 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4380 stored_observations_limit: 20,
4381 stake_weighted_median_threshold: 3334,
4382 default_none_duration_for_new_keys: true,
4383 observations_chunk_size: None,
4384 },
4385 );
4386 }
4387 89 => {
4388 cfg.feature_flags.dependency_linkage_error = true;
4389 cfg.feature_flags.additional_multisig_checks = true;
4390 }
4391 90 => {
4392 cfg.max_gas_price_rgp_factor_for_aborted_transactions = Some(100);
4394 cfg.feature_flags.debug_fatal_on_move_invariant_violation = true;
4395 cfg.feature_flags.additional_consensus_digest_indirect_state = true;
4396 cfg.feature_flags.accept_passkey_in_multisig = true;
4397 cfg.feature_flags.passkey_auth = true;
4398 cfg.feature_flags.check_for_init_during_upgrade = true;
4399
4400 if chain != Chain::Mainnet {
4402 cfg.feature_flags.mysticeti_fastpath = true;
4403 }
4404 }
4405 91 => {
4406 cfg.feature_flags.per_command_shared_object_transfer_rules = true;
4407 }
4408 92 => {
4409 cfg.feature_flags.per_command_shared_object_transfer_rules = false;
4410 }
4411 93 => {
4412 cfg.feature_flags
4413 .consensus_checkpoint_signature_key_includes_digest = true;
4414 }
4415 94 => {
4416 cfg.feature_flags.per_object_congestion_control_mode =
4418 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4419 ExecutionTimeEstimateParams {
4420 target_utilization: 50,
4421 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4423 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4425 stored_observations_limit: 18,
4426 stake_weighted_median_threshold: 3334,
4427 default_none_duration_for_new_keys: true,
4428 observations_chunk_size: None,
4429 },
4430 );
4431
4432 cfg.feature_flags.enable_party_transfer = true;
4434 }
4435 95 => {
4436 cfg.type_name_id_base_cost = Some(52);
4437
4438 cfg.max_transactions_per_checkpoint = Some(20_000);
4440 }
4441 96 => {
4442 if chain != Chain::Mainnet && chain != Chain::Testnet {
4444 cfg.feature_flags
4445 .include_checkpoint_artifacts_digest_in_summary = true;
4446 }
4447 cfg.feature_flags.correct_gas_payment_limit_check = true;
4448 cfg.feature_flags.authority_capabilities_v2 = true;
4449 cfg.feature_flags.use_mfp_txns_in_load_initial_object_debts = true;
4450 cfg.feature_flags.cancel_for_failed_dkg_early = true;
4451 cfg.feature_flags.enable_coin_registry = true;
4452
4453 cfg.feature_flags.mysticeti_fastpath = true;
4455 }
4456 97 => {
4457 cfg.feature_flags.additional_borrow_checks = true;
4458 }
4459 98 => {
4460 cfg.event_emit_auth_stream_cost = Some(52);
4461 cfg.feature_flags.better_loader_errors = true;
4462 cfg.feature_flags.generate_df_type_layouts = true;
4463 }
4464 99 => {
4465 cfg.feature_flags.use_new_commit_handler = true;
4466 }
4467 100 => {
4468 cfg.feature_flags.private_generics_verifier_v2 = true;
4469 }
4470 101 => {
4471 cfg.feature_flags.create_root_accumulator_object = true;
4472 cfg.max_updates_per_settlement_txn = Some(100);
4473 if chain != Chain::Mainnet {
4474 cfg.feature_flags.enable_poseidon = true;
4475 }
4476 }
4477 102 => {
4478 cfg.feature_flags.per_object_congestion_control_mode =
4482 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4483 ExecutionTimeEstimateParams {
4484 target_utilization: 50,
4485 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4487 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4489 stored_observations_limit: 180,
4490 stake_weighted_median_threshold: 3334,
4491 default_none_duration_for_new_keys: true,
4492 observations_chunk_size: Some(18),
4493 },
4494 );
4495 cfg.feature_flags.deprecate_global_storage_ops = true;
4496 }
4497 103 => {}
4498 104 => {
4499 cfg.translation_per_command_base_charge = Some(1);
4500 cfg.translation_per_input_base_charge = Some(1);
4501 cfg.translation_pure_input_per_byte_charge = Some(1);
4502 cfg.translation_per_type_node_charge = Some(1);
4503 cfg.translation_per_reference_node_charge = Some(1);
4504 cfg.translation_per_linkage_entry_charge = Some(10);
4505 cfg.gas_model_version = Some(11);
4506 cfg.feature_flags.abstract_size_in_object_runtime = true;
4507 cfg.feature_flags.object_runtime_charge_cache_load_gas = true;
4508 cfg.dynamic_field_hash_type_and_key_cost_base = Some(52);
4509 cfg.dynamic_field_add_child_object_cost_base = Some(52);
4510 cfg.dynamic_field_add_child_object_value_cost_per_byte = Some(1);
4511 cfg.dynamic_field_borrow_child_object_cost_base = Some(52);
4512 cfg.dynamic_field_borrow_child_object_child_ref_cost_per_byte = Some(1);
4513 cfg.dynamic_field_remove_child_object_cost_base = Some(52);
4514 cfg.dynamic_field_remove_child_object_child_cost_per_byte = Some(1);
4515 cfg.dynamic_field_has_child_object_cost_base = Some(52);
4516 cfg.dynamic_field_has_child_object_with_ty_cost_base = Some(52);
4517 cfg.feature_flags.enable_ptb_execution_v2 = true;
4518
4519 cfg.poseidon_bn254_cost_base = Some(260);
4520
4521 cfg.feature_flags.consensus_skip_gced_accept_votes = true;
4522
4523 if chain != Chain::Mainnet {
4524 cfg.feature_flags
4525 .enable_nitro_attestation_all_nonzero_pcrs_parsing = true;
4526 }
4527
4528 cfg.feature_flags
4529 .include_cancelled_randomness_txns_in_prologue = true;
4530 }
4531 105 => {
4532 cfg.feature_flags.enable_multi_epoch_transaction_expiration = true;
4533 cfg.feature_flags.disable_preconsensus_locking = true;
4534
4535 if chain != Chain::Mainnet {
4536 cfg.feature_flags
4537 .enable_nitro_attestation_always_include_required_pcrs_parsing = true;
4538 }
4539 }
4540 106 => {
4541 cfg.accumulator_object_storage_cost = Some(7600);
4543
4544 if chain != Chain::Mainnet && chain != Chain::Testnet {
4545 cfg.feature_flags.enable_accumulators = true;
4546 cfg.feature_flags.enable_address_balance_gas_payments = true;
4547 cfg.feature_flags.enable_authenticated_event_streams = true;
4548 cfg.feature_flags.enable_object_funds_withdraw = true;
4549 }
4550 }
4551 107 => {
4552 cfg.feature_flags
4553 .consensus_skip_gced_blocks_in_direct_finalization = true;
4554
4555 if in_integration_test() {
4557 cfg.consensus_gc_depth = Some(6);
4558 cfg.consensus_max_num_transactions_in_block = Some(8);
4559 }
4560 }
4561 108 => {
4562 cfg.feature_flags.gas_rounding_halve_digits = true;
4563 cfg.feature_flags.flexible_tx_context_positions = true;
4564 cfg.feature_flags.disable_entry_point_signature_check = true;
4565
4566 if chain != Chain::Mainnet {
4567 cfg.feature_flags.address_aliases = true;
4568
4569 cfg.feature_flags.enable_accumulators = true;
4570 cfg.feature_flags.enable_address_balance_gas_payments = true;
4571 }
4572
4573 cfg.feature_flags.enable_poseidon = true;
4574 }
4575 109 => {
4576 cfg.binary_variant_handles = Some(1024);
4577 cfg.binary_variant_instantiation_handles = Some(1024);
4578 cfg.feature_flags.restrict_hot_or_not_entry_functions = true;
4579 }
4580 110 => {
4581 cfg.feature_flags
4582 .enable_nitro_attestation_all_nonzero_pcrs_parsing = true;
4583 cfg.feature_flags
4584 .enable_nitro_attestation_always_include_required_pcrs_parsing = true;
4585 if chain != Chain::Mainnet && chain != Chain::Testnet {
4586 cfg.feature_flags.split_checkpoints_in_consensus_handler = true;
4587 }
4588 cfg.feature_flags.validate_zklogin_public_identifier = true;
4589 cfg.feature_flags.fix_checkpoint_signature_mapping = true;
4590 cfg.feature_flags
4591 .consensus_always_accept_system_transactions = true;
4592 if chain != Chain::Mainnet {
4593 cfg.feature_flags.enable_object_funds_withdraw = true;
4594 }
4595 }
4596 111 => {
4597 cfg.feature_flags.validator_metadata_verify_v2 = true;
4598 }
4599 112 => {
4600 cfg.group_ops_ristretto_decode_scalar_cost = Some(7);
4601 cfg.group_ops_ristretto_decode_point_cost = Some(200);
4602 cfg.group_ops_ristretto_scalar_add_cost = Some(10);
4603 cfg.group_ops_ristretto_point_add_cost = Some(500);
4604 cfg.group_ops_ristretto_scalar_sub_cost = Some(10);
4605 cfg.group_ops_ristretto_point_sub_cost = Some(500);
4606 cfg.group_ops_ristretto_scalar_mul_cost = Some(11);
4607 cfg.group_ops_ristretto_point_mul_cost = Some(1200);
4608 cfg.group_ops_ristretto_scalar_div_cost = Some(151);
4609 cfg.group_ops_ristretto_point_div_cost = Some(2500);
4610
4611 if chain != Chain::Mainnet && chain != Chain::Testnet {
4612 cfg.feature_flags.enable_ristretto255_group_ops = true;
4613 }
4614 }
4615 113 => {
4616 cfg.feature_flags.address_balance_gas_check_rgp_at_signing = true;
4617 if chain != Chain::Mainnet && chain != Chain::Testnet {
4618 cfg.feature_flags.defer_unpaid_amplification = true;
4619 }
4620 }
4621 114 => {
4622 cfg.feature_flags.randomize_checkpoint_tx_limit_in_tests = true;
4623 cfg.feature_flags.address_balance_gas_reject_gas_coin_arg = true;
4624 if chain != Chain::Mainnet {
4625 cfg.feature_flags.split_checkpoints_in_consensus_handler = true;
4626 cfg.feature_flags.enable_authenticated_event_streams = true;
4627 cfg.feature_flags
4628 .include_checkpoint_artifacts_digest_in_summary = true;
4629 }
4630 }
4631 115 => {
4632 cfg.feature_flags.normalize_depth_formula = true;
4633 }
4634 116 => {
4635 cfg.feature_flags.gasless_transaction_drop_safety = true;
4636 cfg.feature_flags.address_aliases = true;
4637 cfg.feature_flags.relax_valid_during_for_owned_inputs = true;
4638 cfg.feature_flags.defer_unpaid_amplification = false;
4640 cfg.feature_flags.enable_display_registry = true;
4641 }
4642 117 => {}
4643 118 => {
4644 cfg.feature_flags.use_coin_party_owner = true;
4645 }
4646 119 => {
4647 cfg.execution_version = Some(4);
4649 cfg.feature_flags.address_balance_gas_reject_gas_coin_arg = false;
4650 cfg.feature_flags.merge_randomness_into_checkpoint = true;
4651 if chain != Chain::Mainnet {
4652 cfg.feature_flags.enable_gasless = true;
4653 cfg.gasless_max_computation_units = Some(50_000);
4654 cfg.gasless_allowed_token_types = Some(vec![]);
4655 cfg.feature_flags.enable_coin_reservation_obj_refs = true;
4656 cfg.feature_flags
4657 .convert_withdrawal_compatibility_ptb_arguments = true;
4658 }
4659 cfg.gasless_max_unused_inputs = Some(1);
4660 cfg.gasless_max_pure_input_bytes = Some(32);
4661 if chain == Chain::Testnet {
4662 cfg.gasless_allowed_token_types = Some(vec![(TESTNET_USDC.to_string(), 0)]);
4663 }
4664 cfg.transfer_receive_object_cost_per_byte = Some(1);
4665 cfg.transfer_receive_object_type_cost_per_byte = Some(2);
4666 }
4667 120 => {
4668 cfg.feature_flags.disallow_jump_orphans = true;
4669 }
4670 121 => {
4671 if chain != Chain::Mainnet {
4673 cfg.feature_flags.defer_unpaid_amplification = true;
4674 cfg.gasless_max_tps = Some(50);
4675 }
4676 cfg.feature_flags
4677 .early_return_receive_object_mismatched_type = true;
4678 }
4679 122 => {
4680 cfg.feature_flags.defer_unpaid_amplification = true;
4682 cfg.verify_bulletproofs_ristretto255_base_cost = Some(30000);
4684 cfg.verify_bulletproofs_ristretto255_cost_per_bit_and_commitment = Some(6500);
4685 if chain != Chain::Mainnet && chain != Chain::Testnet {
4686 cfg.feature_flags.enable_verify_bulletproofs_ristretto255 = true;
4687 }
4688 cfg.feature_flags.gasless_verify_remaining_balance = true;
4689 cfg.include_special_package_amendments = match chain {
4690 Chain::Mainnet => Some(MAINNET_LINKAGE_AMENDMENTS.clone()),
4691 Chain::Testnet => Some(TESTNET_LINKAGE_AMENDMENTS.clone()),
4692 Chain::Unknown => None,
4693 };
4694 cfg.gasless_max_tx_size_bytes = Some(16 * 1024);
4695 cfg.gasless_max_tps = Some(300);
4696 cfg.gasless_max_computation_units = Some(5_000);
4697 }
4698 123 => {
4699 cfg.gas_model_version = Some(13);
4700 }
4701 124 => {
4702 if chain != Chain::Mainnet && chain != Chain::Testnet {
4703 cfg.feature_flags.timestamp_based_epoch_close = true;
4704 }
4705 cfg.gas_model_version = Some(14);
4706 cfg.feature_flags.limit_groth16_pvk_inputs = true;
4707
4708 cfg.feature_flags.enable_accumulators = true;
4714 cfg.feature_flags.enable_address_balance_gas_payments = true;
4715 cfg.feature_flags.enable_authenticated_event_streams = true;
4716 cfg.feature_flags.enable_coin_reservation_obj_refs = true;
4717 cfg.feature_flags.enable_object_funds_withdraw = true;
4718 cfg.feature_flags
4719 .convert_withdrawal_compatibility_ptb_arguments = true;
4720 cfg.feature_flags.split_checkpoints_in_consensus_handler = true;
4721 cfg.feature_flags
4722 .include_checkpoint_artifacts_digest_in_summary = true;
4723 cfg.feature_flags.enable_gasless = true;
4724
4725 if chain == Chain::Mainnet {
4730 cfg.gasless_allowed_token_types = Some(vec![
4731 (MAINNET_USDC.to_string(), 10_000),
4732 (MAINNET_USDSUI.to_string(), 10_000),
4733 (MAINNET_SUI_USDE.to_string(), 10_000),
4734 (MAINNET_USDY.to_string(), 10_000),
4735 (MAINNET_FDUSD.to_string(), 10_000),
4736 (MAINNET_AUSD.to_string(), 10_000),
4737 (MAINNET_USDB.to_string(), 10_000),
4738 ]);
4739 }
4740 }
4741 125 => {
4742 cfg.feature_flags.granular_post_execution_checks = true;
4743 if chain != Chain::Mainnet {
4744 cfg.feature_flags.timestamp_based_epoch_close = true;
4745 }
4746 }
4747 126 => {
4748 cfg.feature_flags.early_exit_on_iffw = true;
4749 }
4750 127 => {
4751 cfg.feature_flags.always_advance_dkg_to_resolution = true;
4752
4753 cfg.verify_bulletproofs_ristretto255_base_cost = Some(23866);
4754 cfg.verify_bulletproofs_ristretto255_cost_per_bit_and_commitment = Some(1324);
4755 cfg.group_ops_ristretto_decode_scalar_cost = Some(5);
4756 cfg.group_ops_ristretto_decode_point_cost = Some(216);
4757 cfg.group_ops_ristretto_scalar_add_cost = Some(2);
4758 cfg.group_ops_ristretto_point_add_cost = Some(8);
4759 cfg.group_ops_ristretto_scalar_sub_cost = Some(2);
4760 cfg.group_ops_ristretto_point_sub_cost = Some(8);
4761 cfg.group_ops_ristretto_scalar_mul_cost = Some(5);
4762 cfg.group_ops_ristretto_point_mul_cost = Some(1763);
4763 cfg.group_ops_ristretto_scalar_div_cost = Some(557);
4764 cfg.group_ops_ristretto_point_div_cost = Some(2244);
4765
4766 if chain != Chain::Mainnet {
4767 cfg.feature_flags.enable_ristretto255_group_ops = true;
4768 cfg.feature_flags.enable_verify_bulletproofs_ristretto255 = true;
4769 }
4770
4771 cfg.feature_flags.timestamp_based_epoch_close = true;
4772 }
4773 128 => {
4774 cfg.max_generic_instantiation_type_nodes_per_function = Some(10_000);
4775 cfg.max_generic_instantiation_type_nodes_per_module = Some(500_000);
4776 cfg.binary_enum_defs = Some(200);
4777 cfg.binary_enum_def_instantiations = Some(100);
4778 }
4779 129 => {
4780 cfg.feature_flags.enable_unified_linkage = true;
4781 }
4782 130 => {
4783 cfg.feature_flags.record_net_unsettled_object_withdraws = true;
4784 cfg.feature_flags.enable_init_on_upgrade = true;
4785 cfg.epoch_close_deadline_ms = Some(120_000);
4786 cfg.scratch_add_cost_base = Some(13);
4787 cfg.scratch_read_cost_base = Some(13);
4788 cfg.scratch_read_value_cost = Some(1);
4789 cfg.scratch_remove_cost_base = Some(13);
4790 cfg.scratch_exists_cost_base = Some(13);
4791 cfg.scratch_exists_with_type_cost_base = Some(13);
4792 cfg.scratch_exists_with_type_type_cost = Some(1);
4793 let max_commands = cfg.max_programmable_tx_commands() as u64;
4794 cfg.max_scratch_pad_size = Some(16 * max_commands);
4795 if chain != Chain::Mainnet && chain != Chain::Testnet {
4797 cfg.feature_flags.zklogin_circuit_mode = 1;
4798 }
4799 }
4800 131 => {
4801 cfg.feature_flags.share_transaction_deny_config_in_consensus = true;
4802 cfg.feature_flags.framework_tx_context_mut_restrictions = true;
4803 }
4804 132 => {
4805 if chain != Chain::Mainnet && chain != Chain::Testnet {
4806 cfg.feature_flags.defer_owned_object_double_spend = true;
4807 cfg.feature_flags.create_forwarding_address_registry = true;
4808 }
4809 cfg.object_record_new_uid_from_hash_cost_base = Some(1);
4810 cfg.feature_flags
4811 .enable_order_independent_upgrade_init_linkage = true;
4812 }
4813 133 => {
4814 cfg.feature_flags
4815 .include_function_signatures_in_instantiation_limits = true;
4816 cfg.max_accumulator_type_nodes = Some(16);
4817 }
4818 134 => {
4819 if chain != Chain::Mainnet {
4826 cfg.package_original_package_id_impl_cost_base = Some(52);
4827 let package_read_cost_per_byte = cfg.obj_access_cost_read_per_byte();
4828 cfg.package_original_package_id_impl_cost_per_byte =
4829 Some(package_read_cost_per_byte);
4830
4831 cfg.consensus_max_transactions_in_block_bytes = Some(288 * 1024);
4832 cfg.consensus_max_num_transactions_in_block = Some(128);
4833 }
4834
4835 if chain == Chain::Mainnet {
4836 cfg.feature_flags.defer_unpaid_amplification = false;
4837 }
4838 }
4839 135 => {
4840 cfg.package_original_package_id_impl_cost_base = Some(52);
4843 let package_read_cost_per_byte = cfg.obj_access_cost_read_per_byte();
4844 cfg.package_original_package_id_impl_cost_per_byte =
4845 Some(package_read_cost_per_byte);
4846
4847 cfg.consensus_max_transactions_in_block_bytes = Some(288 * 1024);
4848 cfg.consensus_max_num_transactions_in_block = Some(128);
4849
4850 cfg.feature_flags.defer_unpaid_amplification = false;
4851 }
4852 136 => {
4853 cfg.feature_flags.ptb_tx_context_restrictions = true;
4854
4855 cfg.translation_per_live_reference_charge = Some(1);
4856 cfg.max_ptb_live_references = Some(64);
4857 cfg.max_ptb_returned_references = Some(16);
4858 cfg.max_ptb_total_returned_references = Some(256);
4859
4860 if chain != Chain::Mainnet && chain != Chain::Testnet {
4861 cfg.feature_flags.allowed_proposers = true;
4862 }
4863 cfg.feature_flags.harden_linkage_consistency = true;
4864
4865 cfg.package_arena_size_in_bytes = Some(10_000_000);
4866 }
4867 137 => {
4868 cfg.verify_bulletproofs_ristretto255_cost_per_bit_and_commitment = Some(621);
4869 cfg.max_bulletproofs_total_bits = Some(1024);
4870
4871 if chain != Chain::Mainnet {
4872 cfg.feature_flags.enable_allowances = true;
4873 }
4874 cfg.feature_flags.fix_ptb_generated_reads = true;
4875 cfg.feature_flags.charge_ld_const_abstract_size = true;
4876 if chain != Chain::Mainnet && chain != Chain::Testnet {
4877 cfg.feature_flags.check_object_funds_withdraw_in_execution = true;
4878 }
4879 cfg.reserve_object_funds_for_withdrawal_cost_base = Some(52);
4880 cfg.reserve_object_funds_for_withdrawal_cold_read_cost = Some(184);
4883
4884 cfg.feature_flags.allowed_proposers = true;
4885
4886 cfg.feature_flags.validate_ptb_argument_indices = true;
4887 cfg.feature_flags.memory_safety_invariant_check_v2 = true;
4888 }
4889 138 => {
4890 cfg.gas_model_version = Some(15);
4891 cfg.feature_flags.enable_allowances = true;
4892 if chain != Chain::Mainnet {
4893 cfg.feature_flags.check_object_funds_withdraw_in_execution = true;
4894 cfg.feature_flags.disable_effects_tx_dependencies = true;
4895 }
4896 cfg.feature_flags.merge_colliding_deferrals = true;
4897 if chain == Chain::Mainnet {
4899 cfg.storage_rebate_rate = Some(9999);
4900 }
4901 }
4902 139 => {
4903 if chain != Chain::Mainnet && chain != Chain::Testnet {
4904 cfg.feature_flags.enable_forwarding_addresses = true;
4905 cfg.feature_flags.mldsa65_auth = true;
4906 }
4907 cfg.storage_rebate_rate = Some(9999);
4908 if chain != Chain::Mainnet {
4909 cfg.feature_flags.allow_dkg_completion_after_timeout = true;
4910 }
4911 cfg.obj_access_cost_read_per_package_kb = Some(154);
4913 }
4914 140 => {
4915 cfg.staggered_submission_signal_window_commits = Some(300);
4918 cfg.staggered_submission_signal_min_excess_copies_per_commit = Some(2);
4919 cfg.staggered_submission_signal_exit_dwell_commits = Some(6000);
4920 cfg.staggered_submission_signal_band1_enter_ratio_bps = Some(1000);
4921 cfg.staggered_submission_signal_band1_exit_ratio_bps = Some(500);
4922 cfg.staggered_submission_signal_band2_enter_ratio_bps = Some(5000);
4923 cfg.staggered_submission_signal_band2_exit_ratio_bps = Some(2500);
4924
4925 cfg.vector_reverse_base_cost = Some(52);
4926 cfg.vector_reverse_per_elem_cost = Some(8);
4927 cfg.vector_keep_range_base_cost = Some(52);
4928 cfg.vector_keep_range_per_dropped_elem_cost = Some(1);
4929 cfg.vector_keep_range_per_moved_elem_cost = Some(8);
4930 cfg.vector_copy_range_base_cost = Some(52);
4931 cfg.vector_replace_range_base_cost = Some(52);
4932 cfg.vector_replace_range_per_elem_cost = Some(8);
4933
4934 if chain != Chain::Mainnet && chain != Chain::Testnet {
4935 cfg.feature_flags.shuffle_consensus_commit_blocks = true;
4936 }
4937
4938 cfg.feature_flags.allow_references_in_ptbs = true;
4939 cfg.feature_flags.disable_id_leak_verifier = true;
4940 cfg.feature_flags.check_object_funds_withdraw_in_execution = true;
4941 cfg.feature_flags.disable_effects_tx_dependencies = true;
4942 }
4943 _ => panic!("unsupported version {:?}", version),
4954 }
4955 }
4956
4957 cfg
4958 }
4959
4960 pub fn apply_seeded_test_overrides(&mut self, seed: &[u8; 32]) {
4961 if !self.feature_flags.randomize_checkpoint_tx_limit_in_tests
4962 || !self.feature_flags.split_checkpoints_in_consensus_handler
4963 {
4964 return;
4965 }
4966
4967 if !mysten_common::in_test_configuration() {
4968 return;
4969 }
4970
4971 use rand::{Rng, SeedableRng, rngs::StdRng};
4972 let mut rng = StdRng::from_seed(*seed);
4973 let max_txns = rng.gen_range(10..=100u64);
4974 info!("seeded test override: max_transactions_per_checkpoint = {max_txns}");
4975 self.max_transactions_per_checkpoint = Some(max_txns);
4976 }
4977
4978 pub fn verifier_config(&self, signing_limits: Option<(usize, usize, usize)>) -> VerifierConfig {
4984 let (
4985 max_back_edges_per_function,
4986 max_back_edges_per_module,
4987 sanity_check_with_regex_reference_safety,
4988 ) = if let Some((
4989 max_back_edges_per_function,
4990 max_back_edges_per_module,
4991 sanity_check_with_regex_reference_safety,
4992 )) = signing_limits
4993 {
4994 (
4995 Some(max_back_edges_per_function),
4996 Some(max_back_edges_per_module),
4997 Some(sanity_check_with_regex_reference_safety),
4998 )
4999 } else {
5000 (None, None, None)
5001 };
5002
5003 let additional_borrow_checks = if signing_limits.is_some() {
5004 true
5006 } else {
5007 self.additional_borrow_checks()
5008 };
5009 let deprecate_global_storage_ops = if signing_limits.is_some() {
5010 true
5012 } else {
5013 self.deprecate_global_storage_ops()
5014 };
5015
5016 VerifierConfig {
5017 max_loop_depth: Some(self.max_loop_depth() as usize),
5018 max_generic_instantiation_length: Some(self.max_generic_instantiation_length() as usize),
5019 max_function_parameters: Some(self.max_function_parameters() as usize),
5020 max_basic_blocks: Some(self.max_basic_blocks() as usize),
5021 max_value_stack_size: self.max_value_stack_size() as usize,
5022 max_type_nodes: Some(self.max_type_nodes() as usize),
5023 max_generic_instantiation_type_nodes_per_function: self
5024 .max_generic_instantiation_type_nodes_per_function_as_option()
5025 .map(|v| v as usize),
5026 max_generic_instantiation_type_nodes_per_module: self
5027 .max_generic_instantiation_type_nodes_per_module_as_option()
5028 .map(|v| v as usize),
5029 include_function_signatures_in_instantiation_limits: self
5030 .include_function_signatures_in_instantiation_limits(),
5031 max_push_size: Some(self.max_push_size() as usize),
5032 max_dependency_depth: Some(self.max_dependency_depth() as usize),
5033 max_fields_in_struct: Some(self.max_fields_in_struct() as usize),
5034 max_function_definitions: Some(self.max_function_definitions() as usize),
5035 max_data_definitions: Some(self.max_struct_definitions() as usize),
5036 max_constant_vector_len: Some(self.max_move_vector_len()),
5037 max_back_edges_per_function,
5038 max_back_edges_per_module,
5039 max_basic_blocks_in_script: None,
5040 max_identifier_len: self.max_move_identifier_len_as_option(), disallow_self_identifier: self.feature_flags.disallow_self_identifier,
5042 allow_receiving_object_id: self.allow_receiving_object_id(),
5043 reject_mutable_random_on_entry_functions: self
5044 .reject_mutable_random_on_entry_functions(),
5045 bytecode_version: self.move_binary_format_version(),
5046 max_variants_in_enum: self.max_move_enum_variants_as_option(),
5047 additional_borrow_checks,
5048 better_loader_errors: self.better_loader_errors(),
5049 private_generics_verifier_v2: self.private_generics_verifier_v2(),
5050 sanity_check_with_regex_reference_safety: sanity_check_with_regex_reference_safety
5051 .map(|limit| limit as u128),
5052 deprecate_global_storage_ops,
5053 disable_entry_point_signature_check: self.disable_entry_point_signature_check(),
5054 disable_id_leak_verifier: self.disable_id_leak_verifier(),
5055 switch_to_regex_reference_safety: false,
5056 framework_tx_context_mut_restrictions: self.framework_tx_context_mut_restrictions(),
5057 disallow_jump_orphans: self.disallow_jump_orphans(),
5058 }
5059 }
5060
5061 pub fn binary_config(
5062 &self,
5063 override_deprecate_global_storage_ops_during_deserialization: Option<bool>,
5064 ) -> BinaryConfig {
5065 let deprecate_global_storage_ops =
5066 override_deprecate_global_storage_ops_during_deserialization
5067 .unwrap_or_else(|| self.deprecate_global_storage_ops());
5068 BinaryConfig::new(
5069 self.move_binary_format_version(),
5070 self.min_move_binary_format_version_as_option()
5071 .unwrap_or(VERSION_1),
5072 self.no_extraneous_module_bytes(),
5073 deprecate_global_storage_ops,
5074 TableConfig {
5075 module_handles: self.binary_module_handles_as_option().unwrap_or(u16::MAX),
5076 datatype_handles: self.binary_struct_handles_as_option().unwrap_or(u16::MAX),
5077 function_handles: self.binary_function_handles_as_option().unwrap_or(u16::MAX),
5078 function_instantiations: self
5079 .binary_function_instantiations_as_option()
5080 .unwrap_or(u16::MAX),
5081 signatures: self.binary_signatures_as_option().unwrap_or(u16::MAX),
5082 constant_pool: self.binary_constant_pool_as_option().unwrap_or(u16::MAX),
5083 identifiers: self.binary_identifiers_as_option().unwrap_or(u16::MAX),
5084 address_identifiers: self
5085 .binary_address_identifiers_as_option()
5086 .unwrap_or(u16::MAX),
5087 struct_defs: self.binary_struct_defs_as_option().unwrap_or(u16::MAX),
5088 struct_def_instantiations: self
5089 .binary_struct_def_instantiations_as_option()
5090 .unwrap_or(u16::MAX),
5091 function_defs: self.binary_function_defs_as_option().unwrap_or(u16::MAX),
5092 field_handles: self.binary_field_handles_as_option().unwrap_or(u16::MAX),
5093 field_instantiations: self
5094 .binary_field_instantiations_as_option()
5095 .unwrap_or(u16::MAX),
5096 friend_decls: self.binary_friend_decls_as_option().unwrap_or(u16::MAX),
5097 enum_defs: self.binary_enum_defs_as_option().unwrap_or(u16::MAX),
5098 enum_def_instantiations: self
5099 .binary_enum_def_instantiations_as_option()
5100 .unwrap_or(u16::MAX),
5101 variant_handles: self.binary_variant_handles_as_option().unwrap_or(u16::MAX),
5102 variant_instantiation_handles: self
5103 .binary_variant_instantiation_handles_as_option()
5104 .unwrap_or(u16::MAX),
5105 },
5106 )
5107 }
5108
5109 pub fn apply_overrides_for_testing(
5113 override_fn: impl Fn(ProtocolVersion, Self) -> Self + Send + Sync + 'static,
5114 ) -> OverrideGuard {
5115 let mut cur = CONFIG_OVERRIDE.lock().unwrap();
5116 assert!(cur.is_none(), "config override already present");
5117 *cur = Some(Box::new(override_fn));
5118 OverrideGuard
5119 }
5120
5121 fn apply_config_override(version: ProtocolVersion, mut ret: Self) -> Self {
5122 if let Some(override_fn) = CONFIG_OVERRIDE.lock().unwrap().as_ref() {
5123 warn!(
5124 "overriding ProtocolConfig settings with custom settings (you should not see this log outside of tests)"
5125 );
5126 ret = override_fn(version, ret);
5127 }
5128 ret
5129 }
5130}
5131
5132impl ProtocolConfig {
5136 pub fn set_execution_version_for_testing(&mut self, val: u64) {
5140 let current = self.execution_version.unwrap_or(0);
5141 assert!(
5142 val >= current,
5143 "cannot downgrade execution_version from {current} to {val}: running an old \
5144 executor against a newer protocol config/framework is unsupported. To test \
5145 frozen executor behavior, start from the last protocol version of that executor \
5146 instead, so genesis loads the matching framework snapshot (see \
5147 test_address_balance_gas_v3_accumulator_sign)."
5148 );
5149 self.execution_version = Some(val);
5150 }
5151
5152 pub fn set_zklogin_circuit_mode_for_testing(&mut self, val: u64) {
5155 self.feature_flags.zklogin_circuit_mode = val
5156 }
5157
5158 pub fn set_per_object_congestion_control_mode_for_testing(
5159 &mut self,
5160 val: PerObjectCongestionControlMode,
5161 ) {
5162 self.feature_flags.per_object_congestion_control_mode = val;
5163 }
5164
5165 pub fn set_consensus_choice_for_testing(&mut self, val: ConsensusChoice) {
5166 self.feature_flags.consensus_choice = val;
5167 }
5168
5169 pub fn set_consensus_network_for_testing(&mut self, val: ConsensusNetwork) {
5170 self.feature_flags.consensus_network = val;
5171 }
5172
5173 pub fn set_zklogin_max_epoch_upper_bound_delta_for_testing(&mut self, val: Option<u64>) {
5174 self.feature_flags.zklogin_max_epoch_upper_bound_delta = val
5175 }
5176
5177 pub fn set_mysticeti_num_leaders_per_round_for_testing(&mut self, val: Option<usize>) {
5178 self.feature_flags.mysticeti_num_leaders_per_round = val;
5179 }
5180
5181 pub fn disable_accumulators_for_testing(&mut self) {
5182 self.feature_flags.enable_accumulators = false;
5183 self.feature_flags.enable_address_balance_gas_payments = false;
5184 }
5185
5186 pub fn enable_coin_reservation_for_testing(&mut self) {
5187 self.feature_flags.enable_coin_reservation_obj_refs = true;
5188 self.feature_flags
5189 .convert_withdrawal_compatibility_ptb_arguments = true;
5190 self.execution_version = Some(self.execution_version.map_or(4, |v| v.max(4)));
5193 }
5194
5195 pub fn disable_coin_reservation_for_testing(&mut self) {
5196 self.feature_flags.enable_coin_reservation_obj_refs = false;
5197 self.feature_flags
5198 .convert_withdrawal_compatibility_ptb_arguments = false;
5199 }
5200
5201 pub fn enable_address_balance_gas_payments_for_testing(&mut self) {
5202 self.feature_flags.enable_accumulators = true;
5203 self.feature_flags.allow_private_accumulator_entrypoints = true;
5204 self.feature_flags.enable_address_balance_gas_payments = true;
5205 self.feature_flags.address_balance_gas_check_rgp_at_signing = true;
5206 self.feature_flags.address_balance_gas_reject_gas_coin_arg = false;
5207 self.execution_version = Some(self.execution_version.map_or(4, |v| v.max(4)))
5208 }
5209
5210 pub fn enable_gasless_for_testing(&mut self) {
5211 self.enable_address_balance_gas_payments_for_testing();
5212 self.feature_flags.enable_gasless = true;
5213 self.feature_flags.gasless_verify_remaining_balance = true;
5214 self.gasless_max_computation_units = Some(5_000);
5215 self.gasless_allowed_token_types = Some(vec![]);
5216 self.gasless_max_tps = Some(1000);
5217 self.gasless_max_tx_size_bytes = Some(16 * 1024);
5218 }
5219
5220 pub fn disable_gasless_for_testing(&mut self) {
5221 self.feature_flags.enable_gasless = false;
5222 self.gasless_max_computation_units = None;
5223 self.gasless_allowed_token_types = None;
5224 }
5225
5226 pub fn enable_authenticated_event_streams_for_testing(&mut self) {
5227 self.feature_flags.enable_accumulators = true;
5228 self.feature_flags.enable_authenticated_event_streams = true;
5229 self.feature_flags
5230 .include_checkpoint_artifacts_digest_in_summary = true;
5231 self.feature_flags.split_checkpoints_in_consensus_handler = true;
5232 }
5233}
5234
5235type OverrideFn = dyn Fn(ProtocolVersion, ProtocolConfig) -> ProtocolConfig + Send + Sync;
5236
5237static CONFIG_OVERRIDE: Mutex<Option<Box<OverrideFn>>> = Mutex::new(None);
5238
5239#[must_use]
5240pub struct OverrideGuard;
5241
5242impl Drop for OverrideGuard {
5243 fn drop(&mut self) {
5244 info!("restoring override fn");
5245 *CONFIG_OVERRIDE.lock().unwrap() = None;
5246 }
5247}
5248
5249#[derive(PartialEq, Eq)]
5252pub enum LimitThresholdCrossed {
5253 None,
5254 Soft(u128, u128),
5255 Hard(u128, u128),
5256}
5257
5258pub fn check_limit_in_range<T: Into<V>, U: Into<V>, V: PartialOrd + Into<u128>>(
5261 x: T,
5262 soft_limit: U,
5263 hard_limit: V,
5264) -> LimitThresholdCrossed {
5265 let x: V = x.into();
5266 let soft_limit: V = soft_limit.into();
5267
5268 debug_assert!(soft_limit <= hard_limit);
5269
5270 if x >= hard_limit {
5273 LimitThresholdCrossed::Hard(x.into(), hard_limit.into())
5274 } else if x < soft_limit {
5275 LimitThresholdCrossed::None
5276 } else {
5277 LimitThresholdCrossed::Soft(x.into(), soft_limit.into())
5278 }
5279}
5280
5281#[macro_export]
5282macro_rules! check_limit {
5283 ($x:expr, $hard:expr) => {
5284 check_limit!($x, $hard, $hard)
5285 };
5286 ($x:expr, $soft:expr, $hard:expr) => {
5287 check_limit_in_range($x as u64, $soft, $hard)
5288 };
5289}
5290
5291#[macro_export]
5295macro_rules! check_limit_by_meter {
5296 ($is_metered:expr, $x:expr, $metered_limit:expr, $unmetered_hard_limit:expr, $metric:expr) => {{
5297 let (h, metered_str) = if $is_metered {
5299 ($metered_limit, "metered")
5300 } else {
5301 ($unmetered_hard_limit, "unmetered")
5303 };
5304 use sui_protocol_config::check_limit_in_range;
5305 let result = check_limit_in_range($x as u64, $metered_limit, h);
5306 match result {
5307 LimitThresholdCrossed::None => {}
5308 LimitThresholdCrossed::Soft(_, _) => {
5309 $metric.with_label_values(&[metered_str, "soft"]).inc();
5310 }
5311 LimitThresholdCrossed::Hard(_, _) => {
5312 $metric.with_label_values(&[metered_str, "hard"]).inc();
5313 }
5314 };
5315 result
5316 }};
5317}
5318
5319pub type Amendments = BTreeMap<AccountAddress, BTreeMap<AccountAddress, AccountAddress>>;
5322
5323static MAINNET_LINKAGE_AMENDMENTS: LazyLock<Arc<Amendments>> =
5324 LazyLock::new(|| parse_amendments(include_str!("mainnet_amendments.json")));
5325
5326static TESTNET_LINKAGE_AMENDMENTS: LazyLock<Arc<Amendments>> =
5327 LazyLock::new(|| parse_amendments(include_str!("testnet_amendments.json")));
5328
5329fn parse_amendments(json: &str) -> Arc<Amendments> {
5330 #[derive(serde::Deserialize)]
5331 struct AmendmentEntry {
5332 root: String,
5333 deps: Vec<DepEntry>,
5334 }
5335
5336 #[derive(serde::Deserialize)]
5337 struct DepEntry {
5338 original_id: String,
5339 version_id: String,
5340 }
5341
5342 let entries: Vec<AmendmentEntry> =
5343 serde_json::from_str(json).expect("Failed to parse amendments JSON");
5344 let mut amendments = BTreeMap::new();
5345 for entry in entries {
5346 let root_id = AccountAddress::from_hex_literal(&entry.root).unwrap();
5347 let mut dep_ids = BTreeMap::new();
5348 for dep in entry.deps {
5349 let orig_id = AccountAddress::from_hex_literal(&dep.original_id).unwrap();
5350 let upgraded_id = AccountAddress::from_hex_literal(&dep.version_id).unwrap();
5351 assert!(
5352 dep_ids.insert(orig_id, upgraded_id).is_none(),
5353 "Duplicate original ID in amendments table"
5354 );
5355 }
5356 assert!(
5357 amendments.insert(root_id, dep_ids).is_none(),
5358 "Duplicate root ID in amendments table"
5359 );
5360 }
5361 Arc::new(amendments)
5362}
5363
5364#[cfg(all(test, not(msim)))]
5365mod test {
5366 use insta::assert_yaml_snapshot;
5367
5368 use super::*;
5369
5370 #[test]
5371 fn snapshot_tests() {
5372 println!("\n============================================================================");
5373 println!("! !");
5374 println!("! IMPORTANT: never update snapshots from this test. only add new versions! !");
5375 println!("! !");
5376 println!("============================================================================\n");
5377 for chain_id in &[Chain::Unknown, Chain::Mainnet, Chain::Testnet] {
5378 let chain_str = match chain_id {
5382 Chain::Unknown => "".to_string(),
5383 _ => format!("{:?}_", chain_id),
5384 };
5385 for i in MIN_PROTOCOL_VERSION..=MAX_PROTOCOL_VERSION {
5386 let cur = ProtocolVersion::new(i);
5387 assert_yaml_snapshot!(
5388 format!("{}version_{}", chain_str, cur.as_u64()),
5389 ProtocolConfig::get_for_version(cur, *chain_id)
5390 );
5391 }
5392 }
5393 }
5394
5395 #[test]
5396 fn test_getters() {
5397 let prot: ProtocolConfig =
5398 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5399 assert_eq!(
5400 prot.max_arguments(),
5401 prot.max_arguments_as_option().unwrap()
5402 );
5403 }
5404
5405 #[test]
5406 fn vector_bulk_native_gas_costs_start_at_version_140() {
5407 for chain in [Chain::Unknown, Chain::Mainnet, Chain::Testnet] {
5408 let before = ProtocolConfig::get_for_version(ProtocolVersion::new(139), chain);
5409 assert_eq!(before.vector_reverse_base_cost_as_option(), None);
5410 assert_eq!(before.vector_reverse_per_elem_cost_as_option(), None);
5411 assert_eq!(before.vector_keep_range_base_cost_as_option(), None);
5412 assert_eq!(
5413 before.vector_keep_range_per_dropped_elem_cost_as_option(),
5414 None
5415 );
5416 assert_eq!(
5417 before.vector_keep_range_per_moved_elem_cost_as_option(),
5418 None
5419 );
5420 assert_eq!(before.vector_copy_range_base_cost_as_option(), None);
5421 assert_eq!(before.vector_replace_range_base_cost_as_option(), None);
5422 assert_eq!(before.vector_replace_range_per_elem_cost_as_option(), None);
5423
5424 let active = ProtocolConfig::get_for_version(ProtocolVersion::new(140), chain);
5425 assert_eq!(active.vector_reverse_base_cost_as_option(), Some(52));
5426 assert_eq!(active.vector_reverse_per_elem_cost_as_option(), Some(8));
5427 assert_eq!(active.vector_keep_range_base_cost_as_option(), Some(52));
5428 assert_eq!(
5429 active.vector_keep_range_per_dropped_elem_cost_as_option(),
5430 Some(1)
5431 );
5432 assert_eq!(
5433 active.vector_keep_range_per_moved_elem_cost_as_option(),
5434 Some(8)
5435 );
5436 assert_eq!(active.vector_copy_range_base_cost_as_option(), Some(52));
5437 assert_eq!(active.vector_replace_range_base_cost_as_option(), Some(52));
5438 assert_eq!(
5439 active.vector_replace_range_per_elem_cost_as_option(),
5440 Some(8)
5441 );
5442 }
5443 }
5444
5445 #[test]
5446 fn test_setters() {
5447 let mut prot: ProtocolConfig =
5448 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5449 prot.set_max_arguments_for_testing(123);
5450 assert_eq!(prot.max_arguments(), 123);
5451
5452 prot.set_max_arguments_from_str_for_testing("321".to_string());
5453 assert_eq!(prot.max_arguments(), 321);
5454
5455 prot.disable_max_arguments_for_testing();
5456 assert_eq!(prot.max_arguments_as_option(), None);
5457
5458 prot.set_attr_for_testing("max_arguments".to_string(), "456".to_string());
5459 assert_eq!(prot.max_arguments(), 456);
5460 }
5461
5462 #[test]
5463 fn test_execution_version_setter_allows_upgrade() {
5464 let mut prot = ProtocolConfig::get_for_max_version_UNSAFE();
5465 let current = prot.execution_version();
5466 prot.set_execution_version_for_testing(current);
5467 prot.set_execution_version_for_testing(current + 1);
5468 assert_eq!(prot.execution_version(), current + 1);
5469 }
5470
5471 #[test]
5472 #[should_panic(expected = "cannot downgrade execution_version")]
5473 fn test_execution_version_setter_panics_on_downgrade() {
5474 let mut prot = ProtocolConfig::get_for_max_version_UNSAFE();
5475 let current = prot.execution_version();
5476 prot.set_execution_version_for_testing(current - 1);
5477 }
5478
5479 #[test]
5480 fn test_feature_flag_setter_by_string() {
5481 let mut prot: ProtocolConfig =
5482 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5483 assert!(!prot.zklogin_auth());
5484 prot.set_feature_flag_for_testing("zklogin_auth".to_string(), true);
5485 assert!(prot.zklogin_auth());
5486 prot.set_feature_flag_for_testing("zklogin_auth".to_string(), false);
5487 assert!(!prot.zklogin_auth());
5488 }
5489
5490 #[test]
5491 #[should_panic(expected = "unknown feature flag")]
5492 fn test_feature_flag_setter_unknown_flag() {
5493 let mut prot: ProtocolConfig =
5494 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5495 prot.set_feature_flag_for_testing("some random string".to_string(), true);
5496 }
5497
5498 #[test]
5499 fn test_get_for_version_if_supported_applies_test_overrides() {
5500 let before =
5501 ProtocolConfig::get_for_version_if_supported(ProtocolVersion::new(1), Chain::Unknown)
5502 .unwrap();
5503
5504 assert!(!before.enable_coin_reservation_obj_refs());
5505
5506 let _guard = ProtocolConfig::apply_overrides_for_testing(|_, mut cfg| {
5507 cfg.enable_coin_reservation_for_testing();
5508 cfg
5509 });
5510
5511 let after =
5512 ProtocolConfig::get_for_version_if_supported(ProtocolVersion::new(1), Chain::Unknown)
5513 .unwrap();
5514
5515 assert!(after.enable_coin_reservation_obj_refs());
5516 }
5517
5518 #[test]
5519 #[should_panic(expected = "unsupported version")]
5520 fn max_version_test() {
5521 let _ = ProtocolConfig::get_for_version_impl(
5524 ProtocolVersion::new(MAX_PROTOCOL_VERSION + 1),
5525 Chain::Unknown,
5526 );
5527 }
5528
5529 #[test]
5530 fn lookup_by_string_test() {
5531 let prot: ProtocolConfig =
5532 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5533 assert!(prot.lookup_attr("some random string".to_string()).is_none());
5535
5536 assert!(
5537 prot.lookup_attr("max_arguments".to_string())
5538 == Some(ProtocolConfigValue::u32(prot.max_arguments())),
5539 );
5540
5541 assert!(
5543 prot.lookup_attr("max_move_identifier_len".to_string())
5544 .is_none()
5545 );
5546
5547 let prot: ProtocolConfig =
5549 ProtocolConfig::get_for_version(ProtocolVersion::new(9), Chain::Unknown);
5550 assert!(
5551 prot.lookup_attr("max_move_identifier_len".to_string())
5552 == Some(ProtocolConfigValue::u64(prot.max_move_identifier_len()))
5553 );
5554
5555 let prot: ProtocolConfig =
5556 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5557 assert!(
5559 prot.attr_map()
5560 .get("max_move_identifier_len")
5561 .unwrap()
5562 .is_none()
5563 );
5564 assert!(
5566 prot.attr_map().get("max_arguments").unwrap()
5567 == &Some(ProtocolConfigValue::u32(prot.max_arguments()))
5568 );
5569
5570 let prot: ProtocolConfig =
5572 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5573 assert!(
5575 prot.feature_flags
5576 .lookup_attr("some random string".to_owned())
5577 .is_none()
5578 );
5579 assert!(
5580 !prot
5581 .feature_flags
5582 .attr_map()
5583 .contains_key("some random string")
5584 );
5585
5586 assert!(
5588 prot.feature_flags
5589 .lookup_attr("package_upgrades".to_owned())
5590 == Some(false)
5591 );
5592 assert!(
5593 prot.feature_flags
5594 .attr_map()
5595 .get("package_upgrades")
5596 .unwrap()
5597 == &false
5598 );
5599 let prot: ProtocolConfig =
5600 ProtocolConfig::get_for_version(ProtocolVersion::new(4), Chain::Unknown);
5601 assert!(
5603 prot.feature_flags
5604 .lookup_attr("package_upgrades".to_owned())
5605 == Some(true)
5606 );
5607 assert!(
5608 prot.feature_flags
5609 .attr_map()
5610 .get("package_upgrades")
5611 .unwrap()
5612 == &true
5613 );
5614 }
5615
5616 #[test]
5617 fn limit_range_fn_test() {
5618 let low = 100u32;
5619 let high = 10000u64;
5620
5621 assert!(check_limit!(1u8, low, high) == LimitThresholdCrossed::None);
5622 assert!(matches!(
5623 check_limit!(255u16, low, high),
5624 LimitThresholdCrossed::Soft(255u128, 100)
5625 ));
5626 assert!(matches!(
5632 check_limit!(2550000u64, low, high),
5633 LimitThresholdCrossed::Hard(2550000, 10000)
5634 ));
5635
5636 assert!(matches!(
5637 check_limit!(2550000u64, high, high),
5638 LimitThresholdCrossed::Hard(2550000, 10000)
5639 ));
5640
5641 assert!(matches!(
5642 check_limit!(1u8, high),
5643 LimitThresholdCrossed::None
5644 ));
5645
5646 assert!(check_limit!(255u16, high) == LimitThresholdCrossed::None);
5647
5648 assert!(matches!(
5649 check_limit!(2550000u64, high),
5650 LimitThresholdCrossed::Hard(2550000, 10000)
5651 ));
5652 }
5653
5654 #[test]
5655 fn linkage_amendments_load() {
5656 let mainnet = LazyLock::force(&MAINNET_LINKAGE_AMENDMENTS);
5657 let testnet = LazyLock::force(&TESTNET_LINKAGE_AMENDMENTS);
5658 assert!(!mainnet.is_empty(), "mainnet amendments must not be empty");
5659 assert!(!testnet.is_empty(), "testnet amendments must not be empty");
5660 }
5661
5662 #[test]
5663 fn render_scalar_fields_use_precision_safe_encoding() {
5664 use mysten_common::rpc_format::Unmetered;
5665
5666 let config = ProtocolConfig::get_for_max_version_UNSAFE();
5667 let rendered = config
5668 .render::<serde_json::Value>(&mut Unmetered)
5669 .expect("render should succeed");
5670
5671 let max_args = rendered
5672 .get("max_arguments")
5673 .expect("max_arguments set at max version");
5674 assert!(
5675 max_args.is_number(),
5676 "u32 should render as number, got {max_args:?}",
5677 );
5678
5679 let max_tx_size = rendered
5680 .get("max_tx_size_bytes")
5681 .expect("max_tx_size_bytes set at max version");
5682 assert!(
5683 max_tx_size.is_string(),
5684 "u64 should render as string, got {max_tx_size:?}",
5685 );
5686 }
5687
5688 #[test]
5689 fn render_includes_non_scalar_gasless_allowlist_as_json() {
5690 use mysten_common::rpc_format::Unmetered;
5691 use serde_json::json;
5692
5693 let mut config = ProtocolConfig::get_for_max_version_UNSAFE();
5694 config.set_gasless_allowed_token_types_for_testing(vec![
5695 ("0xa::usdc::USDC".to_string(), 10_000),
5696 ("0xb::usdt::USDT".to_string(), 0),
5697 ]);
5698
5699 let rendered = config
5700 .render::<serde_json::Value>(&mut Unmetered)
5701 .expect("render should succeed under Unmetered budget");
5702 let allowlist = rendered
5703 .get("gasless_allowed_token_types")
5704 .expect("entry should be present after the testing setter");
5705
5706 assert_eq!(
5709 allowlist,
5710 &json!([["0xa::usdc::USDC", "10000"], ["0xb::usdt::USDT", "0"],]),
5711 );
5712 }
5713
5714 #[test]
5715 fn render_targets_prost_value_for_grpc() {
5716 use mysten_common::rpc_format::Unmetered;
5717 use prost_types::value::Kind;
5718
5719 let mut config = ProtocolConfig::get_for_max_version_UNSAFE();
5720 config.set_gasless_allowed_token_types_for_testing(vec![(
5721 "0xa::usdc::USDC".to_string(),
5722 10_000,
5723 )]);
5724
5725 let rendered = config
5726 .render::<prost_types::Value>(&mut Unmetered)
5727 .expect("render to prost Value should succeed");
5728 let allowlist = rendered
5729 .get("gasless_allowed_token_types")
5730 .expect("entry should be present after the testing setter");
5731
5732 let Some(Kind::ListValue(outer)) = &allowlist.kind else {
5734 panic!(
5735 "expected ListValue at the top level, got {:?}",
5736 allowlist.kind
5737 );
5738 };
5739 assert_eq!(outer.values.len(), 1, "one allowlisted entry");
5740 let Some(Kind::ListValue(entry)) = &outer.values[0].kind else {
5741 panic!("expected each entry to be a ListValue");
5742 };
5743 assert_eq!(entry.values.len(), 2, "entry has (coin_type, amount)");
5744
5745 let Some(Kind::StringValue(coin_type)) = &entry.values[0].kind else {
5746 panic!("expected coin_type as StringValue");
5747 };
5748 assert_eq!(coin_type, "0xa::usdc::USDC");
5749
5750 let Some(Kind::StringValue(amount)) = &entry.values[1].kind else {
5752 panic!(
5753 "expected minimum_transfer_amount as StringValue (precision-safe u64); got {:?}",
5754 entry.values[1].kind,
5755 );
5756 };
5757 assert_eq!(amount, "10000");
5758 }
5759
5760 #[test]
5761 fn render_emits_null_for_unset_protocol_versions() {
5762 use mysten_common::rpc_format::Unmetered;
5763
5764 let config = ProtocolConfig::get_for_version(1.into(), Chain::Unknown);
5765 let rendered = config
5766 .render::<serde_json::Value>(&mut Unmetered)
5767 .expect("render should succeed");
5768 let entry = rendered
5772 .get("gasless_allowed_token_types")
5773 .expect("key should be present for every protocol version");
5774 assert!(
5775 entry.is_null(),
5776 "value should be null for pre-feature protocol version, got {entry:?}",
5777 );
5778 }
5779}