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 = 139;
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)]
419pub struct ProtocolVersion(u64);
420
421impl ProtocolVersion {
422 pub const MIN: Self = Self(MIN_PROTOCOL_VERSION);
427
428 pub const MAX: Self = Self(MAX_PROTOCOL_VERSION);
429
430 #[cfg(not(msim))]
431 pub const MAX_ALLOWED: Self = Self::MAX;
432
433 #[cfg(msim)]
435 pub const MAX_ALLOWED: Self = Self(MAX_PROTOCOL_VERSION + 1);
436
437 pub fn new(v: u64) -> Self {
438 Self(v)
439 }
440
441 pub const fn as_u64(&self) -> u64 {
442 self.0
443 }
444
445 pub fn max() -> Self {
448 Self::MAX
449 }
450
451 pub fn prev(self) -> Self {
452 Self(self.0.checked_sub(1).unwrap())
453 }
454}
455
456impl From<u64> for ProtocolVersion {
457 fn from(v: u64) -> Self {
458 Self::new(v)
459 }
460}
461
462impl std::ops::Sub<u64> for ProtocolVersion {
463 type Output = Self;
464 fn sub(self, rhs: u64) -> Self::Output {
465 Self::new(self.0 - rhs)
466 }
467}
468
469impl std::ops::Add<u64> for ProtocolVersion {
470 type Output = Self;
471 fn add(self, rhs: u64) -> Self::Output {
472 Self::new(self.0 + rhs)
473 }
474}
475
476#[derive(
477 Clone, Serialize, Deserialize, Debug, Default, PartialEq, Copy, PartialOrd, Ord, Eq, ValueEnum,
478)]
479pub enum Chain {
480 Mainnet,
481 Testnet,
482 #[default]
483 Unknown,
484}
485
486impl Chain {
487 pub fn as_str(self) -> &'static str {
488 match self {
489 Chain::Mainnet => "mainnet",
490 Chain::Testnet => "testnet",
491 Chain::Unknown => "unknown",
492 }
493 }
494}
495
496pub struct Error(pub String);
497
498#[derive(Default, Clone, Serialize, Deserialize, Debug, ProtocolConfigFeatureFlagsGetters)]
501struct FeatureFlags {
502 #[serde(skip_serializing_if = "is_false")]
505 package_upgrades: bool,
506 #[serde(skip_serializing_if = "is_false")]
509 commit_root_state_digest: bool,
510 #[serde(skip_serializing_if = "is_false")]
512 advance_epoch_start_time_in_safe_mode: bool,
513 #[serde(skip_serializing_if = "is_false")]
516 loaded_child_objects_fixed: bool,
517 #[serde(skip_serializing_if = "is_false")]
520 missing_type_is_compatibility_error: bool,
521 #[serde(skip_serializing_if = "is_false")]
524 scoring_decision_with_validity_cutoff: bool,
525
526 #[serde(skip_serializing_if = "is_false")]
529 consensus_order_end_of_epoch_last: bool,
530
531 #[serde(skip_serializing_if = "is_false")]
535 consensus_slim_block_propagation: bool,
536
537 #[serde(skip_serializing_if = "is_false")]
539 disallow_adding_abilities_on_upgrade: bool,
540 #[serde(skip_serializing_if = "is_false")]
542 disable_invariant_violation_check_in_swap_loc: bool,
543 #[serde(skip_serializing_if = "is_false")]
546 advance_to_highest_supported_protocol_version: bool,
547 #[serde(skip_serializing_if = "is_false")]
549 ban_entry_init: bool,
550 #[serde(skip_serializing_if = "is_false")]
552 package_digest_hash_module: bool,
553 #[serde(skip_serializing_if = "is_false")]
555 disallow_change_struct_type_params_on_upgrade: bool,
556 #[serde(skip_serializing_if = "is_false")]
558 no_extraneous_module_bytes: bool,
559 #[serde(skip_serializing_if = "is_false")]
561 narwhal_versioned_metadata: bool,
562
563 #[serde(skip_serializing_if = "is_false")]
565 zklogin_auth: bool,
566 #[serde(skip_serializing_if = "is_zero")]
569 zklogin_circuit_mode: u64,
570 #[serde(skip_serializing_if = "ConsensusTransactionOrdering::is_none")]
572 consensus_transaction_ordering: ConsensusTransactionOrdering,
573
574 #[serde(skip_serializing_if = "is_false")]
582 simplified_unwrap_then_delete: bool,
583 #[serde(skip_serializing_if = "is_false")]
585 upgraded_multisig_supported: bool,
586 #[serde(skip_serializing_if = "is_false")]
588 txn_base_cost_as_multiplier: bool,
589
590 #[serde(skip_serializing_if = "is_false")]
592 shared_object_deletion: bool,
593
594 #[serde(skip_serializing_if = "is_false")]
596 narwhal_new_leader_election_schedule: bool,
597
598 #[serde(skip_serializing_if = "is_empty")]
600 zklogin_supported_providers: BTreeSet<String>,
601
602 #[serde(skip_serializing_if = "is_false")]
604 loaded_child_object_format: bool,
605
606 #[serde(skip_serializing_if = "is_false")]
607 #[skip_protocol_config_accessor]
608 enable_jwk_consensus_updates: bool,
609
610 #[serde(skip_serializing_if = "is_false")]
611 #[skip_protocol_config_accessor]
612 end_of_epoch_transaction_supported: bool,
613
614 #[serde(skip_serializing_if = "is_false")]
617 simple_conservation_checks: bool,
618
619 #[serde(skip_serializing_if = "is_false")]
621 loaded_child_object_format_type: bool,
622
623 #[serde(skip_serializing_if = "is_false")]
625 receive_objects: bool,
626
627 #[serde(skip_serializing_if = "is_false")]
629 consensus_checkpoint_signature_key_includes_digest: bool,
630
631 #[serde(skip_serializing_if = "is_false")]
633 random_beacon: bool,
634
635 #[serde(skip_serializing_if = "is_false")]
637 #[skip_protocol_config_accessor]
638 bridge: bool,
639
640 #[serde(skip_serializing_if = "is_false")]
641 enable_effects_v2: bool,
642
643 #[serde(skip_serializing_if = "is_false")]
645 narwhal_certificate_v2: bool,
646
647 #[serde(skip_serializing_if = "is_false")]
649 verify_legacy_zklogin_address: bool,
650
651 #[serde(skip_serializing_if = "is_false")]
653 throughput_aware_consensus_submission: bool,
654
655 #[serde(skip_serializing_if = "is_false")]
657 recompute_has_public_transfer_in_execution: bool,
658
659 #[serde(skip_serializing_if = "is_false")]
661 accept_zklogin_in_multisig: bool,
662
663 #[serde(skip_serializing_if = "is_false")]
665 accept_passkey_in_multisig: bool,
666
667 #[serde(skip_serializing_if = "is_false")]
669 validate_zklogin_public_identifier: bool,
670
671 #[serde(skip_serializing_if = "is_false")]
674 include_consensus_digest_in_prologue: bool,
675
676 #[serde(skip_serializing_if = "is_false")]
678 hardened_otw_check: bool,
679
680 #[serde(skip_serializing_if = "is_false")]
682 allow_receiving_object_id: bool,
683
684 #[serde(skip_serializing_if = "is_false")]
686 enable_poseidon: bool,
687
688 #[serde(skip_serializing_if = "is_false")]
690 enable_coin_deny_list: bool,
691
692 #[serde(skip_serializing_if = "is_false")]
694 enable_group_ops_native_functions: bool,
695
696 #[serde(skip_serializing_if = "is_false")]
698 enable_group_ops_native_function_msm: bool,
699
700 #[serde(skip_serializing_if = "is_false")]
702 enable_ristretto255_group_ops: bool,
703
704 #[serde(skip_serializing_if = "is_false")]
706 enable_verify_bulletproofs_ristretto255: bool,
707
708 #[serde(skip_serializing_if = "is_false")]
710 enable_nitro_attestation: bool,
711
712 #[serde(skip_serializing_if = "is_false")]
714 enable_nitro_attestation_upgraded_parsing: bool,
715
716 #[serde(skip_serializing_if = "is_false")]
718 enable_nitro_attestation_all_nonzero_pcrs_parsing: bool,
719
720 #[serde(skip_serializing_if = "is_false")]
722 enable_nitro_attestation_always_include_required_pcrs_parsing: bool,
723
724 #[serde(skip_serializing_if = "is_false")]
726 reject_mutable_random_on_entry_functions: bool,
727
728 #[serde(skip_serializing_if = "PerObjectCongestionControlMode::is_none")]
730 per_object_congestion_control_mode: PerObjectCongestionControlMode,
731
732 #[serde(skip_serializing_if = "ConsensusChoice::is_narwhal")]
734 consensus_choice: ConsensusChoice,
735
736 #[serde(skip_serializing_if = "ConsensusNetwork::is_anemo")]
738 consensus_network: ConsensusNetwork,
739
740 #[serde(skip_serializing_if = "is_false")]
742 correct_gas_payment_limit_check: bool,
743
744 #[serde(skip_serializing_if = "Option::is_none")]
746 zklogin_max_epoch_upper_bound_delta: Option<u64>,
747
748 #[serde(skip_serializing_if = "is_false")]
750 mysticeti_leader_scoring_and_schedule: bool,
751
752 #[serde(skip_serializing_if = "is_false")]
754 reshare_at_same_initial_version: bool,
755
756 #[serde(skip_serializing_if = "is_false")]
758 resolve_abort_locations_to_package_id: bool,
759
760 #[serde(skip_serializing_if = "is_false")]
764 mysticeti_use_committed_subdag_digest: bool,
765
766 #[serde(skip_serializing_if = "is_false")]
768 enable_vdf: bool,
769
770 #[serde(skip_serializing_if = "is_false")]
774 record_consensus_determined_version_assignments_in_prologue: bool,
775 #[serde(skip_serializing_if = "is_false")]
778 record_consensus_determined_version_assignments_in_prologue_v2: bool,
779
780 #[serde(skip_serializing_if = "is_false")]
782 fresh_vm_on_framework_upgrade: bool,
783
784 #[serde(skip_serializing_if = "is_false")]
792 prepend_prologue_tx_in_consensus_commit_in_checkpoints: bool,
793
794 #[serde(skip_serializing_if = "Option::is_none")]
796 mysticeti_num_leaders_per_round: Option<usize>,
797
798 #[serde(skip_serializing_if = "is_false")]
800 soft_bundle: bool,
801
802 #[serde(skip_serializing_if = "is_false")]
804 enable_coin_deny_list_v2: bool,
805
806 #[serde(skip_serializing_if = "is_false")]
808 passkey_auth: bool,
809
810 #[serde(skip_serializing_if = "is_false")]
812 authority_capabilities_v2: bool,
813
814 #[serde(skip_serializing_if = "is_false")]
816 rethrow_serialization_type_layout_errors: bool,
817
818 #[serde(skip_serializing_if = "is_false")]
820 consensus_distributed_vote_scoring_strategy: bool,
821
822 #[serde(skip_serializing_if = "is_false")]
824 consensus_round_prober: bool,
825
826 #[serde(skip_serializing_if = "is_false")]
828 validate_identifier_inputs: bool,
829
830 #[serde(skip_serializing_if = "is_false")]
832 disallow_self_identifier: bool,
833
834 #[serde(skip_serializing_if = "is_false")]
836 mysticeti_fastpath: bool,
837
838 #[serde(skip_serializing_if = "is_false")]
842 disable_preconsensus_locking: bool,
843
844 #[serde(skip_serializing_if = "is_false")]
846 relocate_event_module: bool,
847
848 #[serde(skip_serializing_if = "is_false")]
850 uncompressed_g1_group_elements: bool,
851
852 #[serde(skip_serializing_if = "is_false")]
853 disallow_new_modules_in_deps_only_packages: bool,
854
855 #[serde(skip_serializing_if = "is_false")]
857 consensus_smart_ancestor_selection: bool,
858
859 #[serde(skip_serializing_if = "is_false")]
861 consensus_round_prober_probe_accepted_rounds: bool,
862
863 #[serde(skip_serializing_if = "is_false")]
865 native_charging_v2: bool,
866
867 #[serde(skip_serializing_if = "is_false")]
870 #[skip_protocol_config_accessor]
871 consensus_linearize_subdag_v2: bool,
872
873 #[serde(skip_serializing_if = "is_false")]
875 convert_type_argument_error: bool,
876
877 #[serde(skip_serializing_if = "is_false")]
879 variant_nodes: bool,
880
881 #[serde(skip_serializing_if = "is_false")]
883 consensus_zstd_compression: bool,
884
885 #[serde(skip_serializing_if = "is_false")]
887 minimize_child_object_mutations: bool,
888
889 #[serde(skip_serializing_if = "is_false")]
892 record_additional_state_digest_in_prologue: bool,
893
894 #[serde(skip_serializing_if = "is_false")]
896 move_native_context: bool,
897
898 #[serde(skip_serializing_if = "is_false")]
901 #[skip_protocol_config_accessor]
902 consensus_median_based_commit_timestamp: bool,
903
904 #[serde(skip_serializing_if = "is_false")]
907 normalize_ptb_arguments: bool,
908
909 #[serde(skip_serializing_if = "is_false")]
911 consensus_batched_block_sync: bool,
912
913 #[serde(skip_serializing_if = "is_false")]
915 enforce_checkpoint_timestamp_monotonicity: bool,
916
917 #[serde(skip_serializing_if = "is_false")]
919 max_ptb_value_size_v2: bool,
920
921 #[serde(skip_serializing_if = "is_false")]
923 resolve_type_input_ids_to_defining_id: bool,
924
925 #[serde(skip_serializing_if = "is_false")]
927 enable_party_transfer: bool,
928
929 #[serde(skip_serializing_if = "is_false")]
931 allow_unbounded_system_objects: bool,
932
933 #[serde(skip_serializing_if = "is_false")]
935 type_tags_in_object_runtime: bool,
936
937 #[serde(skip_serializing_if = "is_false")]
939 enable_accumulators: bool,
940
941 #[serde(skip_serializing_if = "is_false")]
943 #[skip_protocol_config_accessor]
944 enable_coin_reservation_obj_refs: bool,
945
946 #[serde(skip_serializing_if = "is_false")]
949 create_root_accumulator_object: bool,
950
951 #[serde(skip_serializing_if = "is_false")]
953 #[skip_protocol_config_accessor]
954 enable_authenticated_event_streams: bool,
955
956 #[serde(skip_serializing_if = "is_false")]
958 enable_address_balance_gas_payments: bool,
959
960 #[serde(skip_serializing_if = "is_false")]
962 address_balance_gas_check_rgp_at_signing: bool,
963
964 #[serde(skip_serializing_if = "is_false")]
965 address_balance_gas_reject_gas_coin_arg: bool,
966
967 #[serde(skip_serializing_if = "is_false")]
969 enable_multi_epoch_transaction_expiration: bool,
970
971 #[serde(skip_serializing_if = "is_false")]
973 relax_valid_during_for_owned_inputs: bool,
974
975 #[serde(skip_serializing_if = "is_false")]
977 enable_ptb_execution_v2: bool,
978
979 #[serde(skip_serializing_if = "is_false")]
981 better_adapter_type_resolution_errors: bool,
982
983 #[serde(skip_serializing_if = "is_false")]
985 record_time_estimate_processed: bool,
986
987 #[serde(skip_serializing_if = "is_false")]
989 dependency_linkage_error: bool,
990
991 #[serde(skip_serializing_if = "is_false")]
993 additional_multisig_checks: bool,
994
995 #[serde(skip_serializing_if = "is_false")]
997 ignore_execution_time_observations_after_certs_closed: bool,
998
999 #[serde(skip_serializing_if = "is_false")]
1003 debug_fatal_on_move_invariant_violation: bool,
1004
1005 #[serde(skip_serializing_if = "is_false")]
1008 allow_private_accumulator_entrypoints: bool,
1009
1010 #[serde(skip_serializing_if = "is_false")]
1013 additional_consensus_digest_indirect_state: bool,
1014
1015 #[serde(skip_serializing_if = "is_false")]
1017 check_for_init_during_upgrade: bool,
1018
1019 #[serde(skip_serializing_if = "is_false")]
1021 enable_init_on_upgrade: bool,
1022
1023 #[serde(skip_serializing_if = "is_false")]
1025 enable_order_independent_upgrade_init_linkage: bool,
1026
1027 #[serde(skip_serializing_if = "is_false")]
1030 harden_linkage_consistency: bool,
1031
1032 #[serde(skip_serializing_if = "is_false")]
1034 per_command_shared_object_transfer_rules: bool,
1035
1036 #[serde(skip_serializing_if = "is_false")]
1038 validate_ptb_argument_indices: bool,
1039
1040 #[serde(skip_serializing_if = "is_false")]
1042 include_checkpoint_artifacts_digest_in_summary: bool,
1043
1044 #[serde(skip_serializing_if = "is_false")]
1046 use_mfp_txns_in_load_initial_object_debts: bool,
1047
1048 #[serde(skip_serializing_if = "is_false")]
1050 cancel_for_failed_dkg_early: bool,
1051
1052 #[serde(skip_serializing_if = "is_false")]
1054 always_advance_dkg_to_resolution: bool,
1055
1056 #[serde(skip_serializing_if = "is_false")]
1058 enable_coin_registry: bool,
1059
1060 #[serde(skip_serializing_if = "is_false")]
1062 abstract_size_in_object_runtime: bool,
1063
1064 #[serde(skip_serializing_if = "is_false")]
1066 object_runtime_charge_cache_load_gas: bool,
1067
1068 #[serde(skip_serializing_if = "is_false")]
1070 additional_borrow_checks: bool,
1071
1072 #[serde(skip_serializing_if = "is_false")]
1074 use_new_commit_handler: bool,
1075
1076 #[serde(skip_serializing_if = "is_false")]
1078 better_loader_errors: bool,
1079
1080 #[serde(skip_serializing_if = "is_false")]
1082 generate_df_type_layouts: bool,
1083
1084 #[serde(skip_serializing_if = "is_false")]
1086 allow_references_in_ptbs: bool,
1087
1088 #[serde(skip_serializing_if = "is_false")]
1095 framework_tx_context_mut_restrictions: bool,
1096
1097 #[serde(skip_serializing_if = "is_false")]
1099 include_function_signatures_in_instantiation_limits: bool,
1100
1101 #[serde(skip_serializing_if = "is_false")]
1106 ptb_tx_context_restrictions: bool,
1107
1108 #[serde(skip_serializing_if = "is_false")]
1110 enable_display_registry: bool,
1111
1112 #[serde(skip_serializing_if = "is_false")]
1114 private_generics_verifier_v2: bool,
1115
1116 #[serde(skip_serializing_if = "is_false")]
1118 deprecate_global_storage_ops_during_deserialization: bool,
1119
1120 #[serde(skip_serializing_if = "is_false")]
1123 enable_non_exclusive_writes: bool,
1124
1125 #[serde(skip_serializing_if = "is_false")]
1127 deprecate_global_storage_ops: bool,
1128
1129 #[serde(skip_serializing_if = "is_false")]
1131 normalize_depth_formula: bool,
1132
1133 #[serde(skip_serializing_if = "is_false")]
1136 charge_ld_const_abstract_size: bool,
1137
1138 #[serde(skip_serializing_if = "is_false")]
1140 consensus_skip_gced_accept_votes: bool,
1141
1142 #[serde(skip_serializing_if = "is_false")]
1145 include_cancelled_randomness_txns_in_prologue: bool,
1146
1147 #[serde(skip_serializing_if = "is_false")]
1149 #[skip_protocol_config_accessor]
1150 address_aliases: bool,
1151
1152 #[serde(skip_serializing_if = "is_false")]
1154 create_forwarding_address_registry: bool,
1155
1156 #[serde(skip_serializing_if = "is_false")]
1158 enable_forwarding_addresses: bool,
1159
1160 #[serde(skip_serializing_if = "is_false")]
1163 fix_checkpoint_signature_mapping: bool,
1164
1165 #[serde(skip_serializing_if = "is_false")]
1167 enable_object_funds_withdraw: bool,
1168
1169 #[serde(skip_serializing_if = "is_false")]
1172 record_net_unsettled_object_withdraws: bool,
1173
1174 #[serde(skip_serializing_if = "is_false")]
1176 consensus_skip_gced_blocks_in_direct_finalization: bool,
1177
1178 #[serde(skip_serializing_if = "is_false")]
1180 gas_rounding_halve_digits: bool,
1181
1182 #[serde(skip_serializing_if = "is_false")]
1184 flexible_tx_context_positions: bool,
1185
1186 #[serde(skip_serializing_if = "is_false")]
1188 disable_entry_point_signature_check: bool,
1189
1190 #[serde(skip_serializing_if = "is_false")]
1192 convert_withdrawal_compatibility_ptb_arguments: bool,
1193
1194 #[serde(skip_serializing_if = "is_false")]
1196 restrict_hot_or_not_entry_functions: bool,
1197
1198 #[serde(skip_serializing_if = "is_false")]
1200 split_checkpoints_in_consensus_handler: bool,
1201
1202 #[serde(skip_serializing_if = "is_false")]
1204 consensus_always_accept_system_transactions: bool,
1205
1206 #[serde(skip_serializing_if = "is_false")]
1208 validator_metadata_verify_v2: bool,
1209
1210 #[serde(skip_serializing_if = "is_false")]
1213 defer_unpaid_amplification: bool,
1214
1215 #[serde(skip_serializing_if = "is_false")]
1218 defer_owned_object_double_spend: bool,
1219
1220 #[serde(skip_serializing_if = "is_false")]
1223 allowed_proposers: bool,
1224
1225 #[serde(skip_serializing_if = "is_false")]
1226 randomize_checkpoint_tx_limit_in_tests: bool,
1227
1228 #[serde(skip_serializing_if = "is_false")]
1230 gasless_transaction_drop_safety: bool,
1231
1232 #[serde(skip_serializing_if = "is_false")]
1235 merge_randomness_into_checkpoint: bool,
1236
1237 #[serde(skip_serializing_if = "is_false")]
1239 use_coin_party_owner: bool,
1240
1241 #[serde(skip_serializing_if = "is_false")]
1242 enable_gasless: bool,
1243
1244 #[serde(skip_serializing_if = "is_false")]
1245 gasless_verify_remaining_balance: bool,
1246
1247 #[serde(skip_serializing_if = "is_false")]
1248 disallow_jump_orphans: bool,
1249
1250 #[serde(skip_serializing_if = "is_false")]
1252 early_return_receive_object_mismatched_type: bool,
1253
1254 #[serde(skip_serializing_if = "is_false")]
1259 timestamp_based_epoch_close: bool,
1260
1261 #[serde(skip_serializing_if = "is_false")]
1264 limit_groth16_pvk_inputs: bool,
1265
1266 #[serde(skip_serializing_if = "is_false")]
1271 enforce_address_balance_change_invariant: bool,
1272
1273 #[serde(skip_serializing_if = "is_false")]
1275 share_transaction_deny_config_in_consensus: bool,
1276
1277 #[serde(skip_serializing_if = "is_false")]
1279 granular_post_execution_checks: bool,
1280
1281 #[serde(skip_serializing_if = "is_false")]
1283 early_exit_on_iffw: bool,
1284
1285 #[serde(skip_serializing_if = "is_false")]
1287 enable_unified_linkage: bool,
1288
1289 #[serde(skip_serializing_if = "is_false")]
1292 #[skip_protocol_config_accessor]
1293 enable_allowances: bool,
1294
1295 #[serde(skip_serializing_if = "is_false")]
1297 fix_ptb_generated_reads: bool,
1298
1299 #[serde(skip_serializing_if = "is_false")]
1300 check_object_funds_withdraw_in_execution: bool,
1301 #[serde(skip_serializing_if = "is_false")]
1303 memory_safety_invariant_check_v2: bool,
1304
1305 #[serde(skip_serializing_if = "is_false")]
1307 disable_effects_tx_dependencies: bool,
1308
1309 #[serde(skip_serializing_if = "is_false")]
1313 merge_colliding_deferrals: bool,
1314}
1315
1316fn is_false(b: &bool) -> bool {
1317 !b
1318}
1319
1320fn is_empty(b: &BTreeSet<String>) -> bool {
1321 b.is_empty()
1322}
1323
1324fn is_zero(val: &u64) -> bool {
1325 *val == 0
1326}
1327
1328#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1330pub enum ConsensusTransactionOrdering {
1331 #[default]
1333 None,
1334 ByGasPrice,
1336}
1337
1338impl ConsensusTransactionOrdering {
1339 pub fn is_none(&self) -> bool {
1340 matches!(self, ConsensusTransactionOrdering::None)
1341 }
1342}
1343
1344#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1345pub struct ExecutionTimeEstimateParams {
1346 pub target_utilization: u64,
1348 pub allowed_txn_cost_overage_burst_limit_us: u64,
1352
1353 pub randomness_scalar: u64,
1356
1357 pub max_estimate_us: u64,
1359
1360 pub stored_observations_num_included_checkpoints: u64,
1363
1364 pub stored_observations_limit: u64,
1366
1367 #[serde(skip_serializing_if = "is_zero")]
1370 pub stake_weighted_median_threshold: u64,
1371
1372 #[serde(skip_serializing_if = "is_false")]
1376 pub default_none_duration_for_new_keys: bool,
1377
1378 #[serde(skip_serializing_if = "Option::is_none")]
1380 pub observations_chunk_size: Option<u64>,
1381}
1382
1383#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1385pub enum PerObjectCongestionControlMode {
1386 #[default]
1387 None, TotalGasBudget, TotalTxCount, TotalGasBudgetWithCap, ExecutionTimeEstimate(ExecutionTimeEstimateParams), }
1393
1394impl PerObjectCongestionControlMode {
1395 pub fn is_none(&self) -> bool {
1396 matches!(self, PerObjectCongestionControlMode::None)
1397 }
1398}
1399
1400#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1402pub enum ConsensusChoice {
1403 #[default]
1404 Narwhal,
1405 SwapEachEpoch,
1406 Mysticeti,
1407}
1408
1409impl ConsensusChoice {
1410 pub fn is_narwhal(&self) -> bool {
1411 matches!(self, ConsensusChoice::Narwhal)
1412 }
1413}
1414
1415#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1417pub enum ConsensusNetwork {
1418 #[default]
1419 Anemo,
1420 Tonic,
1421}
1422
1423impl ConsensusNetwork {
1424 pub fn is_anemo(&self) -> bool {
1425 matches!(self, ConsensusNetwork::Anemo)
1426 }
1427}
1428
1429#[skip_serializing_none]
1461#[derive(Clone, Serialize, Debug, ProtocolConfigAccessors, ProtocolConfigOverride)]
1462pub struct ProtocolConfig {
1463 pub version: ProtocolVersion,
1464
1465 #[serde(skip)]
1470 chain: Chain,
1471
1472 feature_flags: FeatureFlags,
1473
1474 max_tx_size_bytes: Option<u64>,
1477
1478 max_input_objects: Option<u64>,
1480
1481 max_size_written_objects: Option<u64>,
1485 max_size_written_objects_system_tx: Option<u64>,
1488
1489 max_serialized_tx_effects_size_bytes: Option<u64>,
1491
1492 max_serialized_tx_effects_size_bytes_system_tx: Option<u64>,
1494
1495 max_gas_payment_objects: Option<u32>,
1497
1498 max_modules_in_publish: Option<u32>,
1500
1501 max_package_dependencies: Option<u32>,
1503
1504 max_arguments: Option<u32>,
1507
1508 max_type_arguments: Option<u32>,
1510
1511 max_type_argument_depth: Option<u32>,
1513
1514 max_pure_argument_size: Option<u32>,
1516
1517 max_programmable_tx_commands: Option<u32>,
1519
1520 move_binary_format_version: Option<u32>,
1523 min_move_binary_format_version: Option<u32>,
1524
1525 binary_module_handles: Option<u16>,
1527 binary_struct_handles: Option<u16>,
1528 binary_function_handles: Option<u16>,
1529 binary_function_instantiations: Option<u16>,
1530 binary_signatures: Option<u16>,
1531 binary_constant_pool: Option<u16>,
1532 binary_identifiers: Option<u16>,
1533 binary_address_identifiers: Option<u16>,
1534 binary_struct_defs: Option<u16>,
1535 binary_struct_def_instantiations: Option<u16>,
1536 binary_function_defs: Option<u16>,
1537 binary_field_handles: Option<u16>,
1538 binary_field_instantiations: Option<u16>,
1539 binary_friend_decls: Option<u16>,
1540 binary_enum_defs: Option<u16>,
1541 binary_enum_def_instantiations: Option<u16>,
1542 binary_variant_handles: Option<u16>,
1543 binary_variant_instantiation_handles: Option<u16>,
1544
1545 max_move_object_size: Option<u64>,
1547
1548 max_move_package_size: Option<u64>,
1551
1552 max_publish_or_upgrade_per_ptb: Option<u64>,
1554
1555 max_tx_gas: Option<u64>,
1557
1558 max_gas_price: Option<u64>,
1560
1561 max_gas_price_rgp_factor_for_aborted_transactions: Option<u64>,
1564
1565 max_gas_computation_bucket: Option<u64>,
1567
1568 gas_rounding_step: Option<u64>,
1570
1571 max_loop_depth: Option<u64>,
1573
1574 max_generic_instantiation_length: Option<u64>,
1576
1577 max_function_parameters: Option<u64>,
1579
1580 max_basic_blocks: Option<u64>,
1582
1583 max_value_stack_size: Option<u64>,
1585
1586 max_type_nodes: Option<u64>,
1588
1589 max_generic_instantiation_type_nodes_per_function: Option<u64>,
1591
1592 max_generic_instantiation_type_nodes_per_module: Option<u64>,
1594
1595 max_accumulator_type_nodes: Option<u64>,
1597
1598 max_push_size: Option<u64>,
1600
1601 max_struct_definitions: Option<u64>,
1603
1604 max_function_definitions: Option<u64>,
1606
1607 max_fields_in_struct: Option<u64>,
1609
1610 max_dependency_depth: Option<u64>,
1612
1613 max_num_event_emit: Option<u64>,
1615
1616 max_num_new_move_object_ids: Option<u64>,
1618
1619 max_num_new_move_object_ids_system_tx: Option<u64>,
1621
1622 max_num_deleted_move_object_ids: Option<u64>,
1624
1625 max_num_deleted_move_object_ids_system_tx: Option<u64>,
1627
1628 max_num_transferred_move_object_ids: Option<u64>,
1630
1631 max_num_transferred_move_object_ids_system_tx: Option<u64>,
1633
1634 max_event_emit_size: Option<u64>,
1636
1637 max_event_emit_size_total: Option<u64>,
1639
1640 max_move_vector_len: Option<u64>,
1642
1643 max_move_identifier_len: Option<u64>,
1645
1646 max_move_value_depth: Option<u64>,
1648
1649 package_arena_size_in_bytes: Option<u64>,
1652
1653 max_move_enum_variants: Option<u64>,
1655
1656 max_back_edges_per_function: Option<u64>,
1658
1659 max_back_edges_per_module: Option<u64>,
1661
1662 max_verifier_meter_ticks_per_function: Option<u64>,
1664
1665 max_meter_ticks_per_module: Option<u64>,
1667
1668 max_meter_ticks_per_package: Option<u64>,
1670
1671 object_runtime_max_num_cached_objects: Option<u64>,
1675
1676 object_runtime_max_num_cached_objects_system_tx: Option<u64>,
1678
1679 object_runtime_max_num_store_entries: Option<u64>,
1681
1682 object_runtime_max_num_store_entries_system_tx: Option<u64>,
1684
1685 base_tx_cost_fixed: Option<u64>,
1688
1689 package_publish_cost_fixed: Option<u64>,
1692
1693 base_tx_cost_per_byte: Option<u64>,
1696
1697 package_publish_cost_per_byte: Option<u64>,
1699
1700 obj_access_cost_read_per_byte: Option<u64>,
1702
1703 obj_access_cost_mutate_per_byte: Option<u64>,
1705
1706 obj_access_cost_delete_per_byte: Option<u64>,
1708
1709 obj_access_cost_verify_per_byte: Option<u64>,
1719
1720 max_type_to_layout_nodes: Option<u64>,
1722
1723 max_ptb_value_size: Option<u64>,
1725
1726 gas_model_version: Option<u64>,
1729
1730 obj_data_cost_refundable: Option<u64>,
1733
1734 obj_metadata_cost_non_refundable: Option<u64>,
1738
1739 storage_rebate_rate: Option<u64>,
1745
1746 storage_fund_reinvest_rate: Option<u64>,
1749
1750 reward_slashing_rate: Option<u64>,
1753
1754 storage_gas_price: Option<u64>,
1756
1757 accumulator_object_storage_cost: Option<u64>,
1759
1760 max_transactions_per_checkpoint: Option<u64>,
1765
1766 max_checkpoint_size_bytes: Option<u64>,
1770
1771 buffer_stake_for_protocol_upgrade_bps: Option<u64>,
1776
1777 address_from_bytes_cost_base: Option<u64>,
1782 address_to_u256_cost_base: Option<u64>,
1784 address_from_u256_cost_base: Option<u64>,
1786
1787 config_read_setting_impl_cost_base: Option<u64>,
1792 config_read_setting_impl_cost_per_byte: Option<u64>,
1793
1794 package_original_package_id_impl_cost_base: Option<u64>,
1795 package_original_package_id_impl_cost_per_byte: Option<u64>,
1796
1797 dynamic_field_hash_type_and_key_cost_base: Option<u64>,
1800 dynamic_field_hash_type_and_key_type_cost_per_byte: Option<u64>,
1801 dynamic_field_hash_type_and_key_value_cost_per_byte: Option<u64>,
1802 dynamic_field_hash_type_and_key_type_tag_cost_per_byte: Option<u64>,
1803 dynamic_field_add_child_object_cost_base: Option<u64>,
1805 dynamic_field_add_child_object_type_cost_per_byte: Option<u64>,
1806 dynamic_field_add_child_object_value_cost_per_byte: Option<u64>,
1807 dynamic_field_add_child_object_struct_tag_cost_per_byte: Option<u64>,
1808 dynamic_field_borrow_child_object_cost_base: Option<u64>,
1810 dynamic_field_borrow_child_object_child_ref_cost_per_byte: Option<u64>,
1811 dynamic_field_borrow_child_object_type_cost_per_byte: Option<u64>,
1812 dynamic_field_remove_child_object_cost_base: Option<u64>,
1814 dynamic_field_remove_child_object_child_cost_per_byte: Option<u64>,
1815 dynamic_field_remove_child_object_type_cost_per_byte: Option<u64>,
1816 dynamic_field_has_child_object_cost_base: Option<u64>,
1818 dynamic_field_has_child_object_with_ty_cost_base: Option<u64>,
1820 dynamic_field_has_child_object_with_ty_type_cost_per_byte: Option<u64>,
1821 dynamic_field_has_child_object_with_ty_type_tag_cost_per_byte: Option<u64>,
1822
1823 scratch_add_cost_base: Option<u64>,
1826 scratch_read_cost_base: Option<u64>,
1828 scratch_read_value_cost: Option<u64>,
1829 scratch_remove_cost_base: Option<u64>,
1831 scratch_exists_cost_base: Option<u64>,
1833 scratch_exists_with_type_cost_base: Option<u64>,
1835 scratch_exists_with_type_type_cost: Option<u64>,
1836 max_scratch_pad_size: Option<u64>,
1838
1839 event_emit_cost_base: Option<u64>,
1842 event_emit_value_size_derivation_cost_per_byte: Option<u64>,
1843 event_emit_tag_size_derivation_cost_per_byte: Option<u64>,
1844 event_emit_output_cost_per_byte: Option<u64>,
1845 event_emit_auth_stream_cost: Option<u64>,
1846
1847 reserve_object_funds_for_withdrawal_cost_base: Option<u64>,
1850 reserve_object_funds_for_withdrawal_cold_read_cost: Option<u64>,
1852
1853 object_borrow_uid_cost_base: Option<u64>,
1856 object_delete_impl_cost_base: Option<u64>,
1858 object_record_new_uid_cost_base: Option<u64>,
1860 object_record_new_uid_from_hash_cost_base: Option<u64>,
1863
1864 transfer_transfer_internal_cost_base: Option<u64>,
1867 transfer_party_transfer_internal_cost_base: Option<u64>,
1869 transfer_freeze_object_cost_base: Option<u64>,
1871 transfer_share_object_cost_base: Option<u64>,
1873 transfer_receive_object_cost_base: Option<u64>,
1876 transfer_receive_object_cost_per_byte: Option<u64>,
1877 transfer_receive_object_type_cost_per_byte: Option<u64>,
1878
1879 tx_context_derive_id_cost_base: Option<u64>,
1882 tx_context_fresh_id_cost_base: Option<u64>,
1883 tx_context_sender_cost_base: Option<u64>,
1884 tx_context_epoch_cost_base: Option<u64>,
1885 tx_context_epoch_timestamp_ms_cost_base: Option<u64>,
1886 tx_context_sponsor_cost_base: Option<u64>,
1887 tx_context_rgp_cost_base: Option<u64>,
1888 tx_context_gas_price_cost_base: Option<u64>,
1889 tx_context_gas_budget_cost_base: Option<u64>,
1890 tx_context_ids_created_cost_base: Option<u64>,
1891 tx_context_replace_cost_base: Option<u64>,
1892
1893 types_is_one_time_witness_cost_base: Option<u64>,
1896 types_is_one_time_witness_type_tag_cost_per_byte: Option<u64>,
1897 types_is_one_time_witness_type_cost_per_byte: Option<u64>,
1898
1899 validator_validate_metadata_cost_base: Option<u64>,
1902 validator_validate_metadata_data_cost_per_byte: Option<u64>,
1903
1904 crypto_invalid_arguments_cost: Option<u64>,
1906 bls12381_bls12381_min_sig_verify_cost_base: Option<u64>,
1908 bls12381_bls12381_min_sig_verify_msg_cost_per_byte: Option<u64>,
1909 bls12381_bls12381_min_sig_verify_msg_cost_per_block: Option<u64>,
1910
1911 bls12381_bls12381_min_pk_verify_cost_base: Option<u64>,
1913 bls12381_bls12381_min_pk_verify_msg_cost_per_byte: Option<u64>,
1914 bls12381_bls12381_min_pk_verify_msg_cost_per_block: Option<u64>,
1915
1916 ecdsa_k1_ecrecover_keccak256_cost_base: Option<u64>,
1918 ecdsa_k1_ecrecover_keccak256_msg_cost_per_byte: Option<u64>,
1919 ecdsa_k1_ecrecover_keccak256_msg_cost_per_block: Option<u64>,
1920 ecdsa_k1_ecrecover_sha256_cost_base: Option<u64>,
1921 ecdsa_k1_ecrecover_sha256_msg_cost_per_byte: Option<u64>,
1922 ecdsa_k1_ecrecover_sha256_msg_cost_per_block: Option<u64>,
1923
1924 ecdsa_k1_decompress_pubkey_cost_base: Option<u64>,
1926
1927 ecdsa_k1_secp256k1_verify_keccak256_cost_base: Option<u64>,
1929 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_byte: Option<u64>,
1930 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_block: Option<u64>,
1931 ecdsa_k1_secp256k1_verify_sha256_cost_base: Option<u64>,
1932 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_byte: Option<u64>,
1933 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_block: Option<u64>,
1934
1935 ecdsa_r1_ecrecover_keccak256_cost_base: Option<u64>,
1937 ecdsa_r1_ecrecover_keccak256_msg_cost_per_byte: Option<u64>,
1938 ecdsa_r1_ecrecover_keccak256_msg_cost_per_block: Option<u64>,
1939 ecdsa_r1_ecrecover_sha256_cost_base: Option<u64>,
1940 ecdsa_r1_ecrecover_sha256_msg_cost_per_byte: Option<u64>,
1941 ecdsa_r1_ecrecover_sha256_msg_cost_per_block: Option<u64>,
1942
1943 ecdsa_r1_secp256r1_verify_keccak256_cost_base: Option<u64>,
1945 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_byte: Option<u64>,
1946 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_block: Option<u64>,
1947 ecdsa_r1_secp256r1_verify_sha256_cost_base: Option<u64>,
1948 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_byte: Option<u64>,
1949 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_block: Option<u64>,
1950
1951 ecvrf_ecvrf_verify_cost_base: Option<u64>,
1953 ecvrf_ecvrf_verify_alpha_string_cost_per_byte: Option<u64>,
1954 ecvrf_ecvrf_verify_alpha_string_cost_per_block: Option<u64>,
1955
1956 ed25519_ed25519_verify_cost_base: Option<u64>,
1958 ed25519_ed25519_verify_msg_cost_per_byte: Option<u64>,
1959 ed25519_ed25519_verify_msg_cost_per_block: Option<u64>,
1960
1961 groth16_prepare_verifying_key_bls12381_cost_base: Option<u64>,
1963 groth16_prepare_verifying_key_bn254_cost_base: Option<u64>,
1964
1965 groth16_verify_groth16_proof_internal_bls12381_cost_base: Option<u64>,
1967 groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input: Option<u64>,
1968 groth16_verify_groth16_proof_internal_bn254_cost_base: Option<u64>,
1969 groth16_verify_groth16_proof_internal_bn254_cost_per_public_input: Option<u64>,
1970 groth16_verify_groth16_proof_internal_public_input_cost_per_byte: Option<u64>,
1971
1972 hash_blake2b256_cost_base: Option<u64>,
1974 hash_blake2b256_data_cost_per_byte: Option<u64>,
1975 hash_blake2b256_data_cost_per_block: Option<u64>,
1976
1977 hash_keccak256_cost_base: Option<u64>,
1979 hash_keccak256_data_cost_per_byte: Option<u64>,
1980 hash_keccak256_data_cost_per_block: Option<u64>,
1981
1982 poseidon_bn254_cost_base: Option<u64>,
1984 poseidon_bn254_cost_per_block: Option<u64>,
1985
1986 group_ops_bls12381_decode_scalar_cost: Option<u64>,
1988 group_ops_bls12381_decode_g1_cost: Option<u64>,
1989 group_ops_bls12381_decode_g2_cost: Option<u64>,
1990 group_ops_bls12381_decode_gt_cost: Option<u64>,
1991 group_ops_bls12381_scalar_add_cost: Option<u64>,
1992 group_ops_bls12381_g1_add_cost: Option<u64>,
1993 group_ops_bls12381_g2_add_cost: Option<u64>,
1994 group_ops_bls12381_gt_add_cost: Option<u64>,
1995 group_ops_bls12381_scalar_sub_cost: Option<u64>,
1996 group_ops_bls12381_g1_sub_cost: Option<u64>,
1997 group_ops_bls12381_g2_sub_cost: Option<u64>,
1998 group_ops_bls12381_gt_sub_cost: Option<u64>,
1999 group_ops_bls12381_scalar_mul_cost: Option<u64>,
2000 group_ops_bls12381_g1_mul_cost: Option<u64>,
2001 group_ops_bls12381_g2_mul_cost: Option<u64>,
2002 group_ops_bls12381_gt_mul_cost: Option<u64>,
2003 group_ops_bls12381_scalar_div_cost: Option<u64>,
2004 group_ops_bls12381_g1_div_cost: Option<u64>,
2005 group_ops_bls12381_g2_div_cost: Option<u64>,
2006 group_ops_bls12381_gt_div_cost: Option<u64>,
2007 group_ops_bls12381_g1_hash_to_base_cost: Option<u64>,
2008 group_ops_bls12381_g2_hash_to_base_cost: Option<u64>,
2009 group_ops_bls12381_g1_hash_to_cost_per_byte: Option<u64>,
2010 group_ops_bls12381_g2_hash_to_cost_per_byte: Option<u64>,
2011 group_ops_bls12381_g1_msm_base_cost: Option<u64>,
2012 group_ops_bls12381_g2_msm_base_cost: Option<u64>,
2013 group_ops_bls12381_g1_msm_base_cost_per_input: Option<u64>,
2014 group_ops_bls12381_g2_msm_base_cost_per_input: Option<u64>,
2015 group_ops_bls12381_msm_max_len: Option<u32>,
2016 group_ops_bls12381_pairing_cost: Option<u64>,
2017 group_ops_bls12381_g1_to_uncompressed_g1_cost: Option<u64>,
2018 group_ops_bls12381_uncompressed_g1_to_g1_cost: Option<u64>,
2019 group_ops_bls12381_uncompressed_g1_sum_base_cost: Option<u64>,
2020 group_ops_bls12381_uncompressed_g1_sum_cost_per_term: Option<u64>,
2021 group_ops_bls12381_uncompressed_g1_sum_max_terms: Option<u64>,
2022
2023 group_ops_ristretto_decode_scalar_cost: Option<u64>,
2024 group_ops_ristretto_decode_point_cost: Option<u64>,
2025 group_ops_ristretto_scalar_add_cost: Option<u64>,
2026 group_ops_ristretto_point_add_cost: Option<u64>,
2027 group_ops_ristretto_scalar_sub_cost: Option<u64>,
2028 group_ops_ristretto_point_sub_cost: Option<u64>,
2029 group_ops_ristretto_scalar_mul_cost: Option<u64>,
2030 group_ops_ristretto_point_mul_cost: Option<u64>,
2031 group_ops_ristretto_scalar_div_cost: Option<u64>,
2032 group_ops_ristretto_point_div_cost: Option<u64>,
2033
2034 verify_bulletproofs_ristretto255_base_cost: Option<u64>,
2035 verify_bulletproofs_ristretto255_cost_per_bit_and_commitment: Option<u64>,
2036 max_bulletproofs_total_bits: Option<u64>,
2039
2040 hmac_hmac_sha3_256_cost_base: Option<u64>,
2042 hmac_hmac_sha3_256_input_cost_per_byte: Option<u64>,
2043 hmac_hmac_sha3_256_input_cost_per_block: Option<u64>,
2044
2045 check_zklogin_id_cost_base: Option<u64>,
2047 check_zklogin_issuer_cost_base: Option<u64>,
2049
2050 vdf_verify_vdf_cost: Option<u64>,
2051 vdf_hash_to_input_cost: Option<u64>,
2052
2053 nitro_attestation_parse_base_cost: Option<u64>,
2055 nitro_attestation_parse_cost_per_byte: Option<u64>,
2056 nitro_attestation_verify_base_cost: Option<u64>,
2057 nitro_attestation_verify_cost_per_cert: Option<u64>,
2058
2059 bcs_per_byte_serialized_cost: Option<u64>,
2061 bcs_legacy_min_output_size_cost: Option<u64>,
2062 bcs_failure_cost: Option<u64>,
2063
2064 hash_sha2_256_base_cost: Option<u64>,
2065 hash_sha2_256_per_byte_cost: Option<u64>,
2066 hash_sha2_256_legacy_min_input_len_cost: Option<u64>,
2067 hash_sha3_256_base_cost: Option<u64>,
2068 hash_sha3_256_per_byte_cost: Option<u64>,
2069 hash_sha3_256_legacy_min_input_len_cost: Option<u64>,
2070 type_name_get_base_cost: Option<u64>,
2071 type_name_get_per_byte_cost: Option<u64>,
2072 type_name_id_base_cost: Option<u64>,
2073
2074 string_check_utf8_base_cost: Option<u64>,
2075 string_check_utf8_per_byte_cost: Option<u64>,
2076 string_is_char_boundary_base_cost: Option<u64>,
2077 string_sub_string_base_cost: Option<u64>,
2078 string_sub_string_per_byte_cost: Option<u64>,
2079 string_index_of_base_cost: Option<u64>,
2080 string_index_of_per_byte_pattern_cost: Option<u64>,
2081 string_index_of_per_byte_searched_cost: Option<u64>,
2082
2083 vector_empty_base_cost: Option<u64>,
2084 vector_length_base_cost: Option<u64>,
2085 vector_push_back_base_cost: Option<u64>,
2086 vector_push_back_legacy_per_abstract_memory_unit_cost: Option<u64>,
2087 vector_borrow_base_cost: Option<u64>,
2088 vector_pop_back_base_cost: Option<u64>,
2089 vector_destroy_empty_base_cost: Option<u64>,
2090 vector_swap_base_cost: Option<u64>,
2091 debug_print_base_cost: Option<u64>,
2092 debug_print_stack_trace_base_cost: Option<u64>,
2093
2094 #[custom_setter]
2104 execution_version: Option<u64>,
2105
2106 consensus_bad_nodes_stake_threshold: Option<u64>,
2110
2111 max_jwk_votes_per_validator_per_epoch: Option<u64>,
2112 max_age_of_jwk_in_epochs: Option<u64>,
2116
2117 random_beacon_reduction_allowed_delta: Option<u16>,
2121
2122 random_beacon_reduction_lower_bound: Option<u32>,
2125
2126 random_beacon_dkg_timeout_round: Option<u32>,
2129
2130 random_beacon_min_round_interval_ms: Option<u64>,
2132
2133 random_beacon_dkg_version: Option<u64>,
2136
2137 consensus_max_transaction_size_bytes: Option<u64>,
2140 consensus_max_transactions_in_block_bytes: Option<u64>,
2142 consensus_max_num_transactions_in_block: Option<u64>,
2144
2145 consensus_voting_rounds: Option<u32>,
2147
2148 max_accumulated_txn_cost_per_object_in_narwhal_commit: Option<u64>,
2150
2151 max_deferral_rounds_for_congestion_control: Option<u64>,
2154
2155 epoch_close_deadline_ms: Option<u64>,
2160
2161 max_txn_cost_overage_per_object_in_commit: Option<u64>,
2163
2164 allowed_txn_cost_overage_burst_per_object_in_commit: Option<u64>,
2166
2167 min_checkpoint_interval_ms: Option<u64>,
2169
2170 checkpoint_summary_version_specific_data: Option<u64>,
2172
2173 max_soft_bundle_size: Option<u64>,
2175
2176 bridge_should_try_to_finalize_committee: Option<bool>,
2180
2181 max_accumulated_txn_cost_per_object_in_mysticeti_commit: Option<u64>,
2187
2188 max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit: Option<u64>,
2191
2192 consensus_gc_depth: Option<u32>,
2195
2196 gas_budget_based_txn_cost_cap_factor: Option<u64>,
2198
2199 gas_budget_based_txn_cost_absolute_cap_commit_count: Option<u64>,
2201
2202 sip_45_consensus_amplification_threshold: Option<u64>,
2205
2206 use_object_per_epoch_marker_table_v2: Option<bool>,
2209
2210 consensus_commit_rate_estimation_window_size: Option<u32>,
2212
2213 #[serde(skip_serializing_if = "Vec::is_empty")]
2217 aliased_addresses: Vec<AliasedAddress>,
2218
2219 translation_per_command_base_charge: Option<u64>,
2222
2223 translation_per_input_base_charge: Option<u64>,
2226
2227 translation_pure_input_per_byte_charge: Option<u64>,
2229
2230 translation_per_type_node_charge: Option<u64>,
2234
2235 translation_per_reference_node_charge: Option<u64>,
2238
2239 translation_per_linkage_entry_charge: Option<u64>,
2242
2243 max_updates_per_settlement_txn: Option<u32>,
2245
2246 gasless_max_computation_units: Option<u64>,
2248
2249 gasless_allowed_token_types: Option<Vec<(String, u64)>>,
2251
2252 gasless_max_unused_inputs: Option<u64>,
2256
2257 gasless_max_pure_input_bytes: Option<u64>,
2260
2261 gasless_max_tps: Option<u64>,
2263
2264 #[serde(skip_serializing_if = "Option::is_none")]
2265 #[skip_accessor]
2266 include_special_package_amendments: Option<Arc<Amendments>>,
2267
2268 gasless_max_tx_size_bytes: Option<u64>,
2271
2272 translation_per_live_reference_charge: Option<u64>,
2275
2276 max_ptb_live_references: Option<u64>,
2279
2280 max_ptb_returned_references: Option<u64>,
2283
2284 max_ptb_total_returned_references: Option<u64>,
2287}
2288
2289#[derive(Clone, Serialize, Deserialize, Debug)]
2291pub struct AliasedAddress {
2292 pub original: [u8; 32],
2294 pub aliased: [u8; 32],
2296 pub allowed_tx_digests: Vec<[u8; 32]>,
2298}
2299
2300impl ProtocolConfig {
2302 pub fn chain(&self) -> Chain {
2304 self.chain
2305 }
2306
2307 pub fn check_package_upgrades_supported(&self) -> Result<(), Error> {
2320 if self.feature_flags.package_upgrades {
2321 Ok(())
2322 } else {
2323 Err(Error(format!(
2324 "package upgrades are not supported at {:?}",
2325 self.version
2326 )))
2327 }
2328 }
2329
2330 pub fn zklogin_supported_providers(&self) -> &BTreeSet<String> {
2331 &self.feature_flags.zklogin_supported_providers
2332 }
2333
2334 pub fn zklogin_circuit_mode(&self) -> u64 {
2337 self.feature_flags.zklogin_circuit_mode
2338 }
2339
2340 pub fn consensus_transaction_ordering(&self) -> ConsensusTransactionOrdering {
2341 self.feature_flags.consensus_transaction_ordering
2342 }
2343
2344 pub fn enable_jwk_consensus_updates(&self) -> bool {
2345 let ret = self.feature_flags.enable_jwk_consensus_updates;
2346 if ret {
2347 assert!(self.feature_flags.end_of_epoch_transaction_supported);
2349 }
2350 ret
2351 }
2352
2353 pub fn end_of_epoch_transaction_supported(&self) -> bool {
2354 let ret = self.feature_flags.end_of_epoch_transaction_supported;
2355 if !ret {
2356 assert!(!self.feature_flags.enable_jwk_consensus_updates);
2358 }
2359 ret
2360 }
2361
2362 pub fn dkg_version(&self) -> u64 {
2363 self.random_beacon_dkg_version.unwrap_or(1)
2365 }
2366
2367 pub fn bridge(&self) -> bool {
2368 let ret = self.feature_flags.bridge;
2369 if ret {
2370 assert!(self.feature_flags.end_of_epoch_transaction_supported);
2372 }
2373 ret
2374 }
2375
2376 pub fn should_try_to_finalize_bridge_committee(&self) -> bool {
2377 if !self.bridge() {
2378 return false;
2379 }
2380 self.bridge_should_try_to_finalize_committee.unwrap_or(true)
2382 }
2383
2384 pub fn zklogin_max_epoch_upper_bound_delta(&self) -> Option<u64> {
2385 self.feature_flags.zklogin_max_epoch_upper_bound_delta
2386 }
2387
2388 pub fn enable_allowances(&self) -> bool {
2389 self.feature_flags.enable_allowances && self.enable_accumulators()
2390 }
2391
2392 pub fn enable_coin_reservation_obj_refs(&self) -> bool {
2393 self.new_vm_enabled() && self.feature_flags.enable_coin_reservation_obj_refs
2394 }
2395
2396 pub fn enable_authenticated_event_streams(&self) -> bool {
2397 self.feature_flags.enable_authenticated_event_streams && self.enable_accumulators()
2398 }
2399
2400 pub fn per_object_congestion_control_mode(&self) -> PerObjectCongestionControlMode {
2401 self.feature_flags.per_object_congestion_control_mode
2402 }
2403
2404 pub fn consensus_choice(&self) -> ConsensusChoice {
2405 self.feature_flags.consensus_choice
2406 }
2407
2408 pub fn consensus_network(&self) -> ConsensusNetwork {
2409 self.feature_flags.consensus_network
2410 }
2411
2412 pub fn mysticeti_num_leaders_per_round(&self) -> Option<usize> {
2413 self.feature_flags.mysticeti_num_leaders_per_round
2414 }
2415
2416 pub fn max_transaction_size_bytes(&self) -> u64 {
2417 self.consensus_max_transaction_size_bytes
2419 .unwrap_or(256 * 1024)
2420 }
2421
2422 pub fn max_transactions_in_block_bytes(&self) -> u64 {
2423 if cfg!(msim) {
2424 256 * 1024
2425 } else {
2426 self.consensus_max_transactions_in_block_bytes
2427 .unwrap_or(512 * 1024)
2428 }
2429 }
2430
2431 pub fn max_num_transactions_in_block(&self) -> u64 {
2432 if cfg!(msim) {
2433 8
2434 } else {
2435 self.consensus_max_num_transactions_in_block.unwrap_or(512)
2436 }
2437 }
2438
2439 pub fn gc_depth(&self) -> u32 {
2440 self.consensus_gc_depth.unwrap_or(0)
2441 }
2442
2443 pub fn consensus_linearize_subdag_v2(&self) -> bool {
2444 let res = self.feature_flags.consensus_linearize_subdag_v2;
2445 assert!(
2446 !res || self.gc_depth() > 0,
2447 "The consensus linearize sub dag V2 requires GC to be enabled"
2448 );
2449 res
2450 }
2451
2452 pub fn consensus_median_based_commit_timestamp(&self) -> bool {
2453 let res = self.feature_flags.consensus_median_based_commit_timestamp;
2454 assert!(
2455 !res || self.gc_depth() > 0,
2456 "The consensus median based commit timestamp requires GC to be enabled"
2457 );
2458 res
2459 }
2460
2461 pub fn get_consensus_commit_rate_estimation_window_size(&self) -> u32 {
2462 self.consensus_commit_rate_estimation_window_size
2463 .unwrap_or(0)
2464 }
2465
2466 pub fn consensus_num_requested_prior_commits_at_startup(&self) -> u32 {
2467 let window_size = self.get_consensus_commit_rate_estimation_window_size();
2471 assert!(window_size == 0 || self.record_additional_state_digest_in_prologue());
2473 window_size
2474 }
2475
2476 pub fn address_aliases(&self) -> bool {
2477 let address_aliases = self.feature_flags.address_aliases;
2478 assert!(
2479 !address_aliases || self.mysticeti_fastpath(),
2480 "Address aliases requires Mysticeti fastpath to be enabled"
2481 );
2482 if address_aliases {
2483 assert!(
2484 self.feature_flags.disable_preconsensus_locking,
2485 "Address aliases requires CertifiedTransaction to be disabled"
2486 );
2487 }
2488 address_aliases
2489 }
2490
2491 pub fn new_vm_enabled(&self) -> bool {
2492 self.execution_version.is_some_and(|v| v >= 4)
2493 }
2494
2495 pub fn gasless_allowed_token_types(&self) -> &[(String, u64)] {
2496 debug_assert!(self.gasless_allowed_token_types.is_some());
2497 self.gasless_allowed_token_types.as_deref().unwrap_or(&[])
2498 }
2499
2500 pub fn get_gasless_max_unused_inputs(&self) -> u64 {
2501 self.gasless_max_unused_inputs.unwrap_or(u64::MAX)
2502 }
2503
2504 pub fn get_gasless_max_pure_input_bytes(&self) -> u64 {
2505 self.gasless_max_pure_input_bytes.unwrap_or(u64::MAX)
2506 }
2507
2508 pub fn get_gasless_max_tx_size_bytes(&self) -> u64 {
2509 self.gasless_max_tx_size_bytes.unwrap_or(u64::MAX)
2510 }
2511
2512 pub fn include_special_package_amendments_as_option(&self) -> &Option<Arc<Amendments>> {
2513 &self.include_special_package_amendments
2514 }
2515}
2516
2517static POISON_VERSION_METHODS: AtomicBool = AtomicBool::new(false);
2518
2519impl ProtocolConfig {
2521 pub fn get_for_version(version: ProtocolVersion, chain: Chain) -> Self {
2523 assert!(
2525 version >= ProtocolVersion::MIN,
2526 "Network protocol version is {:?}, but the minimum supported version by the binary is {:?}. Please upgrade the binary.",
2527 version,
2528 ProtocolVersion::MIN.0,
2529 );
2530 assert!(
2531 version <= ProtocolVersion::MAX_ALLOWED,
2532 "Network protocol version is {:?}, but the maximum supported version by the binary is {:?}. Please upgrade the binary.",
2533 version,
2534 ProtocolVersion::MAX_ALLOWED.0,
2535 );
2536
2537 let mut ret = Self::get_for_version_impl(version, chain);
2538 ret.version = version;
2539 ret.chain = chain;
2540
2541 ret = Self::apply_config_override(version, ret);
2542
2543 if std::env::var("SUI_PROTOCOL_CONFIG_OVERRIDE_ENABLE").is_ok() {
2544 warn!(
2545 "overriding ProtocolConfig settings with custom settings; this may break non-local networks"
2546 );
2547 let overrides: ProtocolConfigOptional =
2548 serde_env::from_env_with_prefix("SUI_PROTOCOL_CONFIG_OVERRIDE")
2549 .expect("failed to parse ProtocolConfig override env variables");
2550 overrides.apply_to(&mut ret);
2551 }
2552
2553 ret
2554 }
2555
2556 pub fn get_for_version_if_supported(version: ProtocolVersion, chain: Chain) -> Option<Self> {
2559 if version.0 >= ProtocolVersion::MIN.0 && version.0 <= ProtocolVersion::MAX_ALLOWED.0 {
2560 let mut ret = Self::get_for_version_impl(version, chain);
2561 ret.version = version;
2562 ret.chain = chain;
2563 ret = Self::apply_config_override(version, ret);
2564 Some(ret)
2565 } else {
2566 None
2567 }
2568 }
2569
2570 pub fn poison_get_for_min_version() {
2571 POISON_VERSION_METHODS.store(true, Ordering::Relaxed);
2572 }
2573
2574 fn load_poison_get_for_min_version() -> bool {
2575 POISON_VERSION_METHODS.load(Ordering::Relaxed)
2576 }
2577
2578 pub fn get_for_min_version() -> Self {
2581 if Self::load_poison_get_for_min_version() {
2582 panic!("get_for_min_version called on validator");
2583 }
2584 ProtocolConfig::get_for_version(ProtocolVersion::MIN, Chain::Unknown)
2585 }
2586
2587 #[allow(non_snake_case)]
2597 pub fn get_for_max_version_UNSAFE() -> Self {
2598 if Self::load_poison_get_for_min_version() {
2599 panic!("get_for_max_version_UNSAFE called on validator");
2600 }
2601 ProtocolConfig::get_for_version(ProtocolVersion::MAX, Chain::Unknown)
2602 }
2603
2604 fn get_for_version_impl(version: ProtocolVersion, chain: Chain) -> Self {
2605 #[cfg(msim)]
2606 {
2607 if version == ProtocolVersion::MAX_ALLOWED {
2609 let mut config = Self::get_for_version_impl(version - 1, Chain::Unknown);
2610 config.base_tx_cost_fixed = Some(config.base_tx_cost_fixed() + 1000);
2611 return config;
2612 }
2613 }
2614
2615 let mut cfg = Self {
2618 version,
2620 chain,
2621
2622 feature_flags: Default::default(),
2624
2625 max_tx_size_bytes: Some(128 * 1024),
2626 max_input_objects: Some(2048),
2628 max_serialized_tx_effects_size_bytes: Some(512 * 1024),
2629 max_serialized_tx_effects_size_bytes_system_tx: Some(512 * 1024 * 16),
2630 max_gas_payment_objects: Some(256),
2631 max_modules_in_publish: Some(128),
2632 max_package_dependencies: None,
2633 max_arguments: Some(512),
2634 max_type_arguments: Some(16),
2635 max_type_argument_depth: Some(16),
2636 max_pure_argument_size: Some(16 * 1024),
2637 max_programmable_tx_commands: Some(1024),
2638 move_binary_format_version: Some(6),
2639 min_move_binary_format_version: None,
2640 binary_module_handles: None,
2641 binary_struct_handles: None,
2642 binary_function_handles: None,
2643 binary_function_instantiations: None,
2644 binary_signatures: None,
2645 binary_constant_pool: None,
2646 binary_identifiers: None,
2647 binary_address_identifiers: None,
2648 binary_struct_defs: None,
2649 binary_struct_def_instantiations: None,
2650 binary_function_defs: None,
2651 binary_field_handles: None,
2652 binary_field_instantiations: None,
2653 binary_friend_decls: None,
2654 binary_enum_defs: None,
2655 binary_enum_def_instantiations: None,
2656 binary_variant_handles: None,
2657 binary_variant_instantiation_handles: None,
2658 max_move_object_size: Some(250 * 1024),
2659 max_move_package_size: Some(100 * 1024),
2660 max_publish_or_upgrade_per_ptb: None,
2661 max_tx_gas: Some(10_000_000_000),
2662 max_gas_price: Some(100_000),
2663 max_gas_price_rgp_factor_for_aborted_transactions: None,
2664 max_gas_computation_bucket: Some(5_000_000),
2665 max_loop_depth: Some(5),
2666 max_generic_instantiation_length: Some(32),
2667 max_function_parameters: Some(128),
2668 max_basic_blocks: Some(1024),
2669 max_value_stack_size: Some(1024),
2670 max_type_nodes: Some(256),
2671 max_generic_instantiation_type_nodes_per_function: None,
2672 max_generic_instantiation_type_nodes_per_module: None,
2673 max_accumulator_type_nodes: None,
2674 max_push_size: Some(10000),
2675 max_struct_definitions: Some(200),
2676 max_function_definitions: Some(1000),
2677 max_fields_in_struct: Some(32),
2678 max_dependency_depth: Some(100),
2679 max_num_event_emit: Some(256),
2680 max_num_new_move_object_ids: Some(2048),
2681 max_num_new_move_object_ids_system_tx: Some(2048 * 16),
2682 max_num_deleted_move_object_ids: Some(2048),
2683 max_num_deleted_move_object_ids_system_tx: Some(2048 * 16),
2684 max_num_transferred_move_object_ids: Some(2048),
2685 max_num_transferred_move_object_ids_system_tx: Some(2048 * 16),
2686 max_event_emit_size: Some(250 * 1024),
2687 max_move_vector_len: Some(256 * 1024),
2688 max_type_to_layout_nodes: None,
2689 max_ptb_value_size: None,
2690
2691 max_back_edges_per_function: Some(10_000),
2692 max_back_edges_per_module: Some(10_000),
2693 max_verifier_meter_ticks_per_function: Some(6_000_000),
2694 max_meter_ticks_per_module: Some(6_000_000),
2695 max_meter_ticks_per_package: None,
2696
2697 object_runtime_max_num_cached_objects: Some(1000),
2698 object_runtime_max_num_cached_objects_system_tx: Some(1000 * 16),
2699 object_runtime_max_num_store_entries: Some(1000),
2700 object_runtime_max_num_store_entries_system_tx: Some(1000 * 16),
2701 base_tx_cost_fixed: Some(110_000),
2702 package_publish_cost_fixed: Some(1_000),
2703 base_tx_cost_per_byte: Some(0),
2704 package_publish_cost_per_byte: Some(80),
2705 obj_access_cost_read_per_byte: Some(15),
2706 obj_access_cost_mutate_per_byte: Some(40),
2707 obj_access_cost_delete_per_byte: Some(40),
2708 obj_access_cost_verify_per_byte: Some(200),
2709 obj_data_cost_refundable: Some(100),
2710 obj_metadata_cost_non_refundable: Some(50),
2711 gas_model_version: Some(1),
2712 storage_rebate_rate: Some(9900),
2713 storage_fund_reinvest_rate: Some(500),
2714 reward_slashing_rate: Some(5000),
2715 storage_gas_price: Some(1),
2716 accumulator_object_storage_cost: None,
2717 max_transactions_per_checkpoint: Some(10_000),
2718 max_checkpoint_size_bytes: Some(30 * 1024 * 1024),
2719
2720 buffer_stake_for_protocol_upgrade_bps: Some(0),
2723
2724 address_from_bytes_cost_base: Some(52),
2728 address_to_u256_cost_base: Some(52),
2730 address_from_u256_cost_base: Some(52),
2732
2733 config_read_setting_impl_cost_base: None,
2736 config_read_setting_impl_cost_per_byte: None,
2737
2738 package_original_package_id_impl_cost_base: None,
2739 package_original_package_id_impl_cost_per_byte: None,
2740
2741 dynamic_field_hash_type_and_key_cost_base: Some(100),
2744 dynamic_field_hash_type_and_key_type_cost_per_byte: Some(2),
2745 dynamic_field_hash_type_and_key_value_cost_per_byte: Some(2),
2746 dynamic_field_hash_type_and_key_type_tag_cost_per_byte: Some(2),
2747 dynamic_field_add_child_object_cost_base: Some(100),
2749 dynamic_field_add_child_object_type_cost_per_byte: Some(10),
2750 dynamic_field_add_child_object_value_cost_per_byte: Some(10),
2751 dynamic_field_add_child_object_struct_tag_cost_per_byte: Some(10),
2752 dynamic_field_borrow_child_object_cost_base: Some(100),
2754 dynamic_field_borrow_child_object_child_ref_cost_per_byte: Some(10),
2755 dynamic_field_borrow_child_object_type_cost_per_byte: Some(10),
2756 dynamic_field_remove_child_object_cost_base: Some(100),
2758 dynamic_field_remove_child_object_child_cost_per_byte: Some(2),
2759 dynamic_field_remove_child_object_type_cost_per_byte: Some(2),
2760 dynamic_field_has_child_object_cost_base: Some(100),
2762 dynamic_field_has_child_object_with_ty_cost_base: Some(100),
2764 dynamic_field_has_child_object_with_ty_type_cost_per_byte: Some(2),
2765 dynamic_field_has_child_object_with_ty_type_tag_cost_per_byte: Some(2),
2766
2767 scratch_add_cost_base: None,
2769 scratch_read_cost_base: None,
2770 scratch_read_value_cost: None,
2771 scratch_remove_cost_base: None,
2772 scratch_exists_cost_base: None,
2773 scratch_exists_with_type_cost_base: None,
2774 scratch_exists_with_type_type_cost: None,
2775 max_scratch_pad_size: None,
2776
2777 event_emit_cost_base: Some(52),
2780 event_emit_value_size_derivation_cost_per_byte: Some(2),
2781 event_emit_tag_size_derivation_cost_per_byte: Some(5),
2782 event_emit_output_cost_per_byte: Some(10),
2783 event_emit_auth_stream_cost: None,
2784
2785 reserve_object_funds_for_withdrawal_cost_base: None,
2787 reserve_object_funds_for_withdrawal_cold_read_cost: None,
2788
2789 object_borrow_uid_cost_base: Some(52),
2792 object_delete_impl_cost_base: Some(52),
2794 object_record_new_uid_cost_base: Some(52),
2796 object_record_new_uid_from_hash_cost_base: None,
2799
2800 transfer_transfer_internal_cost_base: Some(52),
2803 transfer_party_transfer_internal_cost_base: None,
2805 transfer_freeze_object_cost_base: Some(52),
2807 transfer_share_object_cost_base: Some(52),
2809 transfer_receive_object_cost_base: None,
2810 transfer_receive_object_type_cost_per_byte: None,
2811 transfer_receive_object_cost_per_byte: None,
2812
2813 tx_context_derive_id_cost_base: Some(52),
2816 tx_context_fresh_id_cost_base: None,
2817 tx_context_sender_cost_base: None,
2818 tx_context_epoch_cost_base: None,
2819 tx_context_epoch_timestamp_ms_cost_base: None,
2820 tx_context_sponsor_cost_base: None,
2821 tx_context_rgp_cost_base: None,
2822 tx_context_gas_price_cost_base: None,
2823 tx_context_gas_budget_cost_base: None,
2824 tx_context_ids_created_cost_base: None,
2825 tx_context_replace_cost_base: None,
2826
2827 types_is_one_time_witness_cost_base: Some(52),
2830 types_is_one_time_witness_type_tag_cost_per_byte: Some(2),
2831 types_is_one_time_witness_type_cost_per_byte: Some(2),
2832
2833 validator_validate_metadata_cost_base: Some(52),
2836 validator_validate_metadata_data_cost_per_byte: Some(2),
2837
2838 crypto_invalid_arguments_cost: Some(100),
2840 bls12381_bls12381_min_sig_verify_cost_base: Some(52),
2842 bls12381_bls12381_min_sig_verify_msg_cost_per_byte: Some(2),
2843 bls12381_bls12381_min_sig_verify_msg_cost_per_block: Some(2),
2844
2845 bls12381_bls12381_min_pk_verify_cost_base: Some(52),
2847 bls12381_bls12381_min_pk_verify_msg_cost_per_byte: Some(2),
2848 bls12381_bls12381_min_pk_verify_msg_cost_per_block: Some(2),
2849
2850 ecdsa_k1_ecrecover_keccak256_cost_base: Some(52),
2852 ecdsa_k1_ecrecover_keccak256_msg_cost_per_byte: Some(2),
2853 ecdsa_k1_ecrecover_keccak256_msg_cost_per_block: Some(2),
2854 ecdsa_k1_ecrecover_sha256_cost_base: Some(52),
2855 ecdsa_k1_ecrecover_sha256_msg_cost_per_byte: Some(2),
2856 ecdsa_k1_ecrecover_sha256_msg_cost_per_block: Some(2),
2857
2858 ecdsa_k1_decompress_pubkey_cost_base: Some(52),
2860
2861 ecdsa_k1_secp256k1_verify_keccak256_cost_base: Some(52),
2863 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_byte: Some(2),
2864 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_block: Some(2),
2865 ecdsa_k1_secp256k1_verify_sha256_cost_base: Some(52),
2866 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_byte: Some(2),
2867 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_block: Some(2),
2868
2869 ecdsa_r1_ecrecover_keccak256_cost_base: Some(52),
2871 ecdsa_r1_ecrecover_keccak256_msg_cost_per_byte: Some(2),
2872 ecdsa_r1_ecrecover_keccak256_msg_cost_per_block: Some(2),
2873 ecdsa_r1_ecrecover_sha256_cost_base: Some(52),
2874 ecdsa_r1_ecrecover_sha256_msg_cost_per_byte: Some(2),
2875 ecdsa_r1_ecrecover_sha256_msg_cost_per_block: Some(2),
2876
2877 ecdsa_r1_secp256r1_verify_keccak256_cost_base: Some(52),
2879 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_byte: Some(2),
2880 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_block: Some(2),
2881 ecdsa_r1_secp256r1_verify_sha256_cost_base: Some(52),
2882 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_byte: Some(2),
2883 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_block: Some(2),
2884
2885 ecvrf_ecvrf_verify_cost_base: Some(52),
2887 ecvrf_ecvrf_verify_alpha_string_cost_per_byte: Some(2),
2888 ecvrf_ecvrf_verify_alpha_string_cost_per_block: Some(2),
2889
2890 ed25519_ed25519_verify_cost_base: Some(52),
2892 ed25519_ed25519_verify_msg_cost_per_byte: Some(2),
2893 ed25519_ed25519_verify_msg_cost_per_block: Some(2),
2894
2895 groth16_prepare_verifying_key_bls12381_cost_base: Some(52),
2897 groth16_prepare_verifying_key_bn254_cost_base: Some(52),
2898
2899 groth16_verify_groth16_proof_internal_bls12381_cost_base: Some(52),
2901 groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input: Some(2),
2902 groth16_verify_groth16_proof_internal_bn254_cost_base: Some(52),
2903 groth16_verify_groth16_proof_internal_bn254_cost_per_public_input: Some(2),
2904 groth16_verify_groth16_proof_internal_public_input_cost_per_byte: Some(2),
2905
2906 hash_blake2b256_cost_base: Some(52),
2908 hash_blake2b256_data_cost_per_byte: Some(2),
2909 hash_blake2b256_data_cost_per_block: Some(2),
2910
2911 hash_keccak256_cost_base: Some(52),
2913 hash_keccak256_data_cost_per_byte: Some(2),
2914 hash_keccak256_data_cost_per_block: Some(2),
2915
2916 poseidon_bn254_cost_base: None,
2917 poseidon_bn254_cost_per_block: None,
2918
2919 hmac_hmac_sha3_256_cost_base: Some(52),
2921 hmac_hmac_sha3_256_input_cost_per_byte: Some(2),
2922 hmac_hmac_sha3_256_input_cost_per_block: Some(2),
2923
2924 group_ops_bls12381_decode_scalar_cost: None,
2926 group_ops_bls12381_decode_g1_cost: None,
2927 group_ops_bls12381_decode_g2_cost: None,
2928 group_ops_bls12381_decode_gt_cost: None,
2929 group_ops_bls12381_scalar_add_cost: None,
2930 group_ops_bls12381_g1_add_cost: None,
2931 group_ops_bls12381_g2_add_cost: None,
2932 group_ops_bls12381_gt_add_cost: None,
2933 group_ops_bls12381_scalar_sub_cost: None,
2934 group_ops_bls12381_g1_sub_cost: None,
2935 group_ops_bls12381_g2_sub_cost: None,
2936 group_ops_bls12381_gt_sub_cost: None,
2937 group_ops_bls12381_scalar_mul_cost: None,
2938 group_ops_bls12381_g1_mul_cost: None,
2939 group_ops_bls12381_g2_mul_cost: None,
2940 group_ops_bls12381_gt_mul_cost: None,
2941 group_ops_bls12381_scalar_div_cost: None,
2942 group_ops_bls12381_g1_div_cost: None,
2943 group_ops_bls12381_g2_div_cost: None,
2944 group_ops_bls12381_gt_div_cost: None,
2945 group_ops_bls12381_g1_hash_to_base_cost: None,
2946 group_ops_bls12381_g2_hash_to_base_cost: None,
2947 group_ops_bls12381_g1_hash_to_cost_per_byte: None,
2948 group_ops_bls12381_g2_hash_to_cost_per_byte: None,
2949 group_ops_bls12381_g1_msm_base_cost: None,
2950 group_ops_bls12381_g2_msm_base_cost: None,
2951 group_ops_bls12381_g1_msm_base_cost_per_input: None,
2952 group_ops_bls12381_g2_msm_base_cost_per_input: None,
2953 group_ops_bls12381_msm_max_len: None,
2954 group_ops_bls12381_pairing_cost: None,
2955 group_ops_bls12381_g1_to_uncompressed_g1_cost: None,
2956 group_ops_bls12381_uncompressed_g1_to_g1_cost: None,
2957 group_ops_bls12381_uncompressed_g1_sum_base_cost: None,
2958 group_ops_bls12381_uncompressed_g1_sum_cost_per_term: None,
2959 group_ops_bls12381_uncompressed_g1_sum_max_terms: None,
2960
2961 group_ops_ristretto_decode_scalar_cost: None,
2962 group_ops_ristretto_decode_point_cost: None,
2963 group_ops_ristretto_scalar_add_cost: None,
2964 group_ops_ristretto_point_add_cost: None,
2965 group_ops_ristretto_scalar_sub_cost: None,
2966 group_ops_ristretto_point_sub_cost: None,
2967 group_ops_ristretto_scalar_mul_cost: None,
2968 group_ops_ristretto_point_mul_cost: None,
2969 group_ops_ristretto_scalar_div_cost: None,
2970 group_ops_ristretto_point_div_cost: None,
2971
2972 verify_bulletproofs_ristretto255_base_cost: None,
2973 verify_bulletproofs_ristretto255_cost_per_bit_and_commitment: None,
2974 max_bulletproofs_total_bits: None,
2975
2976 check_zklogin_id_cost_base: None,
2978 check_zklogin_issuer_cost_base: None,
2980
2981 vdf_verify_vdf_cost: None,
2982 vdf_hash_to_input_cost: None,
2983
2984 nitro_attestation_parse_base_cost: None,
2986 nitro_attestation_parse_cost_per_byte: None,
2987 nitro_attestation_verify_base_cost: None,
2988 nitro_attestation_verify_cost_per_cert: None,
2989
2990 bcs_per_byte_serialized_cost: None,
2991 bcs_legacy_min_output_size_cost: None,
2992 bcs_failure_cost: None,
2993 hash_sha2_256_base_cost: None,
2994 hash_sha2_256_per_byte_cost: None,
2995 hash_sha2_256_legacy_min_input_len_cost: None,
2996 hash_sha3_256_base_cost: None,
2997 hash_sha3_256_per_byte_cost: None,
2998 hash_sha3_256_legacy_min_input_len_cost: None,
2999 type_name_get_base_cost: None,
3000 type_name_get_per_byte_cost: None,
3001 type_name_id_base_cost: None,
3002 string_check_utf8_base_cost: None,
3003 string_check_utf8_per_byte_cost: None,
3004 string_is_char_boundary_base_cost: None,
3005 string_sub_string_base_cost: None,
3006 string_sub_string_per_byte_cost: None,
3007 string_index_of_base_cost: None,
3008 string_index_of_per_byte_pattern_cost: None,
3009 string_index_of_per_byte_searched_cost: None,
3010 vector_empty_base_cost: None,
3011 vector_length_base_cost: None,
3012 vector_push_back_base_cost: None,
3013 vector_push_back_legacy_per_abstract_memory_unit_cost: None,
3014 vector_borrow_base_cost: None,
3015 vector_pop_back_base_cost: None,
3016 vector_destroy_empty_base_cost: None,
3017 vector_swap_base_cost: None,
3018 debug_print_base_cost: None,
3019 debug_print_stack_trace_base_cost: None,
3020
3021 max_size_written_objects: None,
3022 max_size_written_objects_system_tx: None,
3023
3024 max_move_identifier_len: None,
3031 max_move_value_depth: None,
3032 package_arena_size_in_bytes: None,
3033 max_move_enum_variants: None,
3034
3035 gas_rounding_step: None,
3036
3037 execution_version: None,
3038
3039 max_event_emit_size_total: None,
3040
3041 consensus_bad_nodes_stake_threshold: None,
3042
3043 max_jwk_votes_per_validator_per_epoch: None,
3044
3045 max_age_of_jwk_in_epochs: None,
3046
3047 random_beacon_reduction_allowed_delta: None,
3048
3049 random_beacon_reduction_lower_bound: None,
3050
3051 random_beacon_dkg_timeout_round: None,
3052
3053 random_beacon_min_round_interval_ms: None,
3054
3055 random_beacon_dkg_version: None,
3056
3057 consensus_max_transaction_size_bytes: None,
3058
3059 consensus_max_transactions_in_block_bytes: None,
3060
3061 consensus_max_num_transactions_in_block: None,
3062
3063 consensus_voting_rounds: None,
3064
3065 max_accumulated_txn_cost_per_object_in_narwhal_commit: None,
3066
3067 max_deferral_rounds_for_congestion_control: None,
3068
3069 epoch_close_deadline_ms: None,
3070
3071 max_txn_cost_overage_per_object_in_commit: None,
3072
3073 allowed_txn_cost_overage_burst_per_object_in_commit: None,
3074
3075 min_checkpoint_interval_ms: None,
3076
3077 checkpoint_summary_version_specific_data: None,
3078
3079 max_soft_bundle_size: None,
3080
3081 bridge_should_try_to_finalize_committee: None,
3082
3083 max_accumulated_txn_cost_per_object_in_mysticeti_commit: None,
3084
3085 max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit: None,
3086
3087 consensus_gc_depth: None,
3088
3089 gas_budget_based_txn_cost_cap_factor: None,
3090
3091 gas_budget_based_txn_cost_absolute_cap_commit_count: None,
3092
3093 sip_45_consensus_amplification_threshold: None,
3094
3095 use_object_per_epoch_marker_table_v2: None,
3096
3097 consensus_commit_rate_estimation_window_size: None,
3098
3099 aliased_addresses: vec![],
3100
3101 translation_per_command_base_charge: None,
3102 translation_per_input_base_charge: None,
3103 translation_pure_input_per_byte_charge: None,
3104 translation_per_type_node_charge: None,
3105 translation_per_reference_node_charge: None,
3106 translation_per_linkage_entry_charge: None,
3107 translation_per_live_reference_charge: None,
3108 max_ptb_live_references: None,
3109 max_ptb_returned_references: None,
3110 max_ptb_total_returned_references: None,
3111
3112 max_updates_per_settlement_txn: None,
3113
3114 gasless_max_computation_units: None,
3115 gasless_allowed_token_types: None,
3116 gasless_max_unused_inputs: None,
3117 gasless_max_pure_input_bytes: None,
3118 gasless_max_tps: None,
3119 include_special_package_amendments: None,
3120 gasless_max_tx_size_bytes: None,
3121 };
3124 for cur in 2..=version.0 {
3125 match cur {
3126 1 => unreachable!(),
3127 2 => {
3128 cfg.feature_flags.advance_epoch_start_time_in_safe_mode = true;
3129 }
3130 3 => {
3131 cfg.gas_model_version = Some(2);
3133 cfg.max_tx_gas = Some(50_000_000_000);
3135 cfg.base_tx_cost_fixed = Some(2_000);
3137 cfg.storage_gas_price = Some(76);
3139 cfg.feature_flags.loaded_child_objects_fixed = true;
3140 cfg.max_size_written_objects = Some(5 * 1000 * 1000);
3143 cfg.max_size_written_objects_system_tx = Some(50 * 1000 * 1000);
3146 cfg.feature_flags.package_upgrades = true;
3147 }
3148 4 => {
3153 cfg.reward_slashing_rate = Some(10000);
3155 cfg.gas_model_version = Some(3);
3157 }
3158 5 => {
3159 cfg.feature_flags.missing_type_is_compatibility_error = true;
3160 cfg.gas_model_version = Some(4);
3161 cfg.feature_flags.scoring_decision_with_validity_cutoff = true;
3162 }
3166 6 => {
3167 cfg.gas_model_version = Some(5);
3168 cfg.buffer_stake_for_protocol_upgrade_bps = Some(5000);
3169 cfg.feature_flags.consensus_order_end_of_epoch_last = true;
3170 }
3171 7 => {
3172 cfg.feature_flags.disallow_adding_abilities_on_upgrade = true;
3173 cfg.feature_flags
3174 .disable_invariant_violation_check_in_swap_loc = true;
3175 cfg.feature_flags.ban_entry_init = true;
3176 cfg.feature_flags.package_digest_hash_module = true;
3177 }
3178 8 => {
3179 cfg.feature_flags
3180 .disallow_change_struct_type_params_on_upgrade = true;
3181 }
3182 9 => {
3183 cfg.max_move_identifier_len = Some(128);
3185 cfg.feature_flags.no_extraneous_module_bytes = true;
3186 cfg.feature_flags
3187 .advance_to_highest_supported_protocol_version = true;
3188 }
3189 10 => {
3190 cfg.max_verifier_meter_ticks_per_function = Some(16_000_000);
3191 cfg.max_meter_ticks_per_module = Some(16_000_000);
3192 }
3193 11 => {
3194 cfg.max_move_value_depth = Some(128);
3195 }
3196 12 => {
3197 cfg.feature_flags.narwhal_versioned_metadata = true;
3198 if chain != Chain::Mainnet {
3199 cfg.feature_flags.commit_root_state_digest = true;
3200 }
3201
3202 if chain != Chain::Mainnet && chain != Chain::Testnet {
3203 cfg.feature_flags.zklogin_auth = true;
3204 }
3205 }
3206 13 => {}
3207 14 => {
3208 cfg.gas_rounding_step = Some(1_000);
3209 cfg.gas_model_version = Some(6);
3210 }
3211 15 => {
3212 cfg.feature_flags.consensus_transaction_ordering =
3213 ConsensusTransactionOrdering::ByGasPrice;
3214 }
3215 16 => {
3216 cfg.feature_flags.simplified_unwrap_then_delete = true;
3217 }
3218 17 => {
3219 cfg.feature_flags.upgraded_multisig_supported = true;
3220 }
3221 18 => {
3222 cfg.execution_version = Some(1);
3223 cfg.feature_flags.txn_base_cost_as_multiplier = true;
3232 cfg.base_tx_cost_fixed = Some(1_000);
3234 }
3235 19 => {
3236 cfg.max_num_event_emit = Some(1024);
3237 cfg.max_event_emit_size_total = Some(
3240 256 * 250 * 1024, );
3242 }
3243 20 => {
3244 cfg.feature_flags.commit_root_state_digest = true;
3245
3246 if chain != Chain::Mainnet {
3247 cfg.feature_flags.narwhal_new_leader_election_schedule = true;
3248 cfg.consensus_bad_nodes_stake_threshold = Some(20);
3249 }
3250 }
3251
3252 21 => {
3253 if chain != Chain::Mainnet {
3254 cfg.feature_flags.zklogin_supported_providers = BTreeSet::from([
3255 "Google".to_string(),
3256 "Facebook".to_string(),
3257 "Twitch".to_string(),
3258 ]);
3259 }
3260 }
3261 22 => {
3262 cfg.feature_flags.loaded_child_object_format = true;
3263 }
3264 23 => {
3265 cfg.feature_flags.loaded_child_object_format_type = true;
3266 cfg.feature_flags.narwhal_new_leader_election_schedule = true;
3267 cfg.consensus_bad_nodes_stake_threshold = Some(20);
3273 }
3274 24 => {
3275 cfg.feature_flags.simple_conservation_checks = true;
3276 cfg.max_publish_or_upgrade_per_ptb = Some(5);
3277
3278 cfg.feature_flags.end_of_epoch_transaction_supported = true;
3279
3280 if chain != Chain::Mainnet {
3281 cfg.feature_flags.enable_jwk_consensus_updates = true;
3282 cfg.max_jwk_votes_per_validator_per_epoch = Some(240);
3284 cfg.max_age_of_jwk_in_epochs = Some(1);
3285 }
3286 }
3287 25 => {
3288 cfg.feature_flags.zklogin_supported_providers = BTreeSet::from([
3290 "Google".to_string(),
3291 "Facebook".to_string(),
3292 "Twitch".to_string(),
3293 ]);
3294 cfg.feature_flags.zklogin_auth = true;
3295
3296 cfg.feature_flags.enable_jwk_consensus_updates = true;
3298 cfg.max_jwk_votes_per_validator_per_epoch = Some(240);
3299 cfg.max_age_of_jwk_in_epochs = Some(1);
3300 }
3301 26 => {
3302 cfg.gas_model_version = Some(7);
3303 if chain != Chain::Mainnet && chain != Chain::Testnet {
3305 cfg.transfer_receive_object_cost_base = Some(52);
3306 cfg.feature_flags.receive_objects = true;
3307 }
3308 }
3309 27 => {
3310 cfg.gas_model_version = Some(8);
3311 }
3312 28 => {
3313 cfg.check_zklogin_id_cost_base = Some(200);
3315 cfg.check_zklogin_issuer_cost_base = Some(200);
3317
3318 if chain != Chain::Mainnet && chain != Chain::Testnet {
3320 cfg.feature_flags.enable_effects_v2 = true;
3321 }
3322 }
3323 29 => {
3324 cfg.feature_flags.verify_legacy_zklogin_address = true;
3325 }
3326 30 => {
3327 if chain != Chain::Mainnet {
3329 cfg.feature_flags.narwhal_certificate_v2 = true;
3330 }
3331
3332 cfg.random_beacon_reduction_allowed_delta = Some(800);
3333 if chain != Chain::Mainnet {
3335 cfg.feature_flags.enable_effects_v2 = true;
3336 }
3337
3338 cfg.feature_flags.zklogin_supported_providers = BTreeSet::default();
3342
3343 cfg.feature_flags.recompute_has_public_transfer_in_execution = true;
3344 }
3345 31 => {
3346 cfg.execution_version = Some(2);
3347 if chain != Chain::Mainnet && chain != Chain::Testnet {
3349 cfg.feature_flags.shared_object_deletion = true;
3350 }
3351 }
3352 32 => {
3353 if chain != Chain::Mainnet {
3355 cfg.feature_flags.accept_zklogin_in_multisig = true;
3356 }
3357 if chain != Chain::Mainnet {
3359 cfg.transfer_receive_object_cost_base = Some(52);
3360 cfg.feature_flags.receive_objects = true;
3361 }
3362 if chain != Chain::Mainnet && chain != Chain::Testnet {
3364 cfg.feature_flags.random_beacon = true;
3365 cfg.random_beacon_reduction_lower_bound = Some(1600);
3366 cfg.random_beacon_dkg_timeout_round = Some(3000);
3367 cfg.random_beacon_min_round_interval_ms = Some(150);
3368 }
3369 if chain != Chain::Testnet && chain != Chain::Mainnet {
3371 cfg.feature_flags.include_consensus_digest_in_prologue = true;
3372 }
3373
3374 cfg.feature_flags.narwhal_certificate_v2 = true;
3376 }
3377 33 => {
3378 cfg.feature_flags.hardened_otw_check = true;
3379 cfg.feature_flags.allow_receiving_object_id = true;
3380
3381 cfg.transfer_receive_object_cost_base = Some(52);
3383 cfg.feature_flags.receive_objects = true;
3384
3385 if chain != Chain::Mainnet {
3387 cfg.feature_flags.shared_object_deletion = true;
3388 }
3389
3390 cfg.feature_flags.enable_effects_v2 = true;
3391 }
3392 34 => {}
3393 35 => {
3394 if chain != Chain::Mainnet && chain != Chain::Testnet {
3396 cfg.feature_flags.enable_poseidon = true;
3397 cfg.poseidon_bn254_cost_base = Some(260);
3398 cfg.poseidon_bn254_cost_per_block = Some(10);
3399 }
3400
3401 cfg.feature_flags.enable_coin_deny_list = true;
3402 }
3403 36 => {
3404 if chain != Chain::Mainnet && chain != Chain::Testnet {
3406 cfg.feature_flags.enable_group_ops_native_functions = true;
3407 cfg.feature_flags.enable_group_ops_native_function_msm = true;
3408 cfg.group_ops_bls12381_decode_scalar_cost = Some(52);
3410 cfg.group_ops_bls12381_decode_g1_cost = Some(52);
3411 cfg.group_ops_bls12381_decode_g2_cost = Some(52);
3412 cfg.group_ops_bls12381_decode_gt_cost = Some(52);
3413 cfg.group_ops_bls12381_scalar_add_cost = Some(52);
3414 cfg.group_ops_bls12381_g1_add_cost = Some(52);
3415 cfg.group_ops_bls12381_g2_add_cost = Some(52);
3416 cfg.group_ops_bls12381_gt_add_cost = Some(52);
3417 cfg.group_ops_bls12381_scalar_sub_cost = Some(52);
3418 cfg.group_ops_bls12381_g1_sub_cost = Some(52);
3419 cfg.group_ops_bls12381_g2_sub_cost = Some(52);
3420 cfg.group_ops_bls12381_gt_sub_cost = Some(52);
3421 cfg.group_ops_bls12381_scalar_mul_cost = Some(52);
3422 cfg.group_ops_bls12381_g1_mul_cost = Some(52);
3423 cfg.group_ops_bls12381_g2_mul_cost = Some(52);
3424 cfg.group_ops_bls12381_gt_mul_cost = Some(52);
3425 cfg.group_ops_bls12381_scalar_div_cost = Some(52);
3426 cfg.group_ops_bls12381_g1_div_cost = Some(52);
3427 cfg.group_ops_bls12381_g2_div_cost = Some(52);
3428 cfg.group_ops_bls12381_gt_div_cost = Some(52);
3429 cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(52);
3430 cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(52);
3431 cfg.group_ops_bls12381_g1_hash_to_cost_per_byte = Some(2);
3432 cfg.group_ops_bls12381_g2_hash_to_cost_per_byte = Some(2);
3433 cfg.group_ops_bls12381_g1_msm_base_cost = Some(52);
3434 cfg.group_ops_bls12381_g2_msm_base_cost = Some(52);
3435 cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(52);
3436 cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(52);
3437 cfg.group_ops_bls12381_msm_max_len = Some(32);
3438 cfg.group_ops_bls12381_pairing_cost = Some(52);
3439 }
3440 cfg.feature_flags.shared_object_deletion = true;
3442
3443 cfg.consensus_max_transaction_size_bytes = Some(256 * 1024); cfg.consensus_max_transactions_in_block_bytes = Some(6 * 1_024 * 1024);
3445 }
3447 37 => {
3448 cfg.feature_flags.reject_mutable_random_on_entry_functions = true;
3449
3450 if chain != Chain::Mainnet {
3452 cfg.feature_flags.include_consensus_digest_in_prologue = true;
3453 }
3454 }
3455 38 => {
3456 cfg.binary_module_handles = Some(100);
3457 cfg.binary_struct_handles = Some(300);
3458 cfg.binary_function_handles = Some(1500);
3459 cfg.binary_function_instantiations = Some(750);
3460 cfg.binary_signatures = Some(1000);
3461 cfg.binary_constant_pool = Some(4000);
3465 cfg.binary_identifiers = Some(10000);
3466 cfg.binary_address_identifiers = Some(100);
3467 cfg.binary_struct_defs = Some(200);
3468 cfg.binary_struct_def_instantiations = Some(100);
3469 cfg.binary_function_defs = Some(1000);
3470 cfg.binary_field_handles = Some(500);
3471 cfg.binary_field_instantiations = Some(250);
3472 cfg.binary_friend_decls = Some(100);
3473 cfg.max_package_dependencies = Some(32);
3475 cfg.max_modules_in_publish = Some(64);
3476 cfg.execution_version = Some(3);
3478 }
3479 39 => {
3480 }
3482 40 => {}
3483 41 => {
3484 cfg.feature_flags.enable_group_ops_native_functions = true;
3486 cfg.group_ops_bls12381_decode_scalar_cost = Some(52);
3488 cfg.group_ops_bls12381_decode_g1_cost = Some(52);
3489 cfg.group_ops_bls12381_decode_g2_cost = Some(52);
3490 cfg.group_ops_bls12381_decode_gt_cost = Some(52);
3491 cfg.group_ops_bls12381_scalar_add_cost = Some(52);
3492 cfg.group_ops_bls12381_g1_add_cost = Some(52);
3493 cfg.group_ops_bls12381_g2_add_cost = Some(52);
3494 cfg.group_ops_bls12381_gt_add_cost = Some(52);
3495 cfg.group_ops_bls12381_scalar_sub_cost = Some(52);
3496 cfg.group_ops_bls12381_g1_sub_cost = Some(52);
3497 cfg.group_ops_bls12381_g2_sub_cost = Some(52);
3498 cfg.group_ops_bls12381_gt_sub_cost = Some(52);
3499 cfg.group_ops_bls12381_scalar_mul_cost = Some(52);
3500 cfg.group_ops_bls12381_g1_mul_cost = Some(52);
3501 cfg.group_ops_bls12381_g2_mul_cost = Some(52);
3502 cfg.group_ops_bls12381_gt_mul_cost = Some(52);
3503 cfg.group_ops_bls12381_scalar_div_cost = Some(52);
3504 cfg.group_ops_bls12381_g1_div_cost = Some(52);
3505 cfg.group_ops_bls12381_g2_div_cost = Some(52);
3506 cfg.group_ops_bls12381_gt_div_cost = Some(52);
3507 cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(52);
3508 cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(52);
3509 cfg.group_ops_bls12381_g1_hash_to_cost_per_byte = Some(2);
3510 cfg.group_ops_bls12381_g2_hash_to_cost_per_byte = Some(2);
3511 cfg.group_ops_bls12381_g1_msm_base_cost = Some(52);
3512 cfg.group_ops_bls12381_g2_msm_base_cost = Some(52);
3513 cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(52);
3514 cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(52);
3515 cfg.group_ops_bls12381_msm_max_len = Some(32);
3516 cfg.group_ops_bls12381_pairing_cost = Some(52);
3517 }
3518 42 => {}
3519 43 => {
3520 cfg.feature_flags.zklogin_max_epoch_upper_bound_delta = Some(30);
3521 cfg.max_meter_ticks_per_package = Some(16_000_000);
3522 }
3523 44 => {
3524 cfg.feature_flags.include_consensus_digest_in_prologue = true;
3526 if chain != Chain::Mainnet {
3528 cfg.feature_flags.consensus_choice = ConsensusChoice::SwapEachEpoch;
3529 }
3530 }
3531 45 => {
3532 if chain != Chain::Testnet && chain != Chain::Mainnet {
3534 cfg.feature_flags.consensus_network = ConsensusNetwork::Tonic;
3535 }
3536
3537 if chain != Chain::Mainnet {
3538 cfg.feature_flags.mysticeti_leader_scoring_and_schedule = true;
3540 }
3541 cfg.min_move_binary_format_version = Some(6);
3542 cfg.feature_flags.accept_zklogin_in_multisig = true;
3543
3544 if chain != Chain::Mainnet && chain != Chain::Testnet {
3548 cfg.feature_flags.bridge = true;
3549 }
3550 }
3551 46 => {
3552 if chain != Chain::Mainnet {
3554 cfg.feature_flags.bridge = true;
3555 }
3556
3557 cfg.feature_flags.reshare_at_same_initial_version = true;
3559 }
3560 47 => {}
3561 48 => {
3562 cfg.feature_flags.consensus_network = ConsensusNetwork::Tonic;
3564
3565 cfg.feature_flags.resolve_abort_locations_to_package_id = true;
3567
3568 if chain != Chain::Mainnet {
3570 cfg.feature_flags.random_beacon = true;
3571 cfg.random_beacon_reduction_lower_bound = Some(1600);
3572 cfg.random_beacon_dkg_timeout_round = Some(3000);
3573 cfg.random_beacon_min_round_interval_ms = Some(200);
3574 }
3575
3576 cfg.feature_flags.mysticeti_use_committed_subdag_digest = true;
3578 }
3579 49 => {
3580 if chain != Chain::Testnet && chain != Chain::Mainnet {
3581 cfg.move_binary_format_version = Some(7);
3582 }
3583
3584 if chain != Chain::Mainnet && chain != Chain::Testnet {
3586 cfg.feature_flags.enable_vdf = true;
3587 cfg.vdf_verify_vdf_cost = Some(1500);
3590 cfg.vdf_hash_to_input_cost = Some(100);
3591 }
3592
3593 if chain != Chain::Testnet && chain != Chain::Mainnet {
3595 cfg.feature_flags
3596 .record_consensus_determined_version_assignments_in_prologue = true;
3597 }
3598
3599 if chain != Chain::Mainnet {
3601 cfg.feature_flags.consensus_choice = ConsensusChoice::Mysticeti;
3602 }
3603
3604 cfg.feature_flags.fresh_vm_on_framework_upgrade = true;
3606 }
3607 50 => {
3608 if chain != Chain::Mainnet {
3610 cfg.checkpoint_summary_version_specific_data = Some(1);
3611 cfg.min_checkpoint_interval_ms = Some(200);
3612 }
3613
3614 if chain != Chain::Testnet && chain != Chain::Mainnet {
3616 cfg.feature_flags
3617 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = true;
3618 }
3619
3620 cfg.feature_flags.mysticeti_num_leaders_per_round = Some(1);
3621
3622 cfg.max_deferral_rounds_for_congestion_control = Some(10);
3624 }
3625 51 => {
3626 cfg.random_beacon_dkg_version = Some(1);
3627
3628 if chain != Chain::Testnet && chain != Chain::Mainnet {
3629 cfg.feature_flags.enable_coin_deny_list_v2 = true;
3630 }
3631 }
3632 52 => {
3633 if chain != Chain::Mainnet {
3634 cfg.feature_flags.soft_bundle = true;
3635 cfg.max_soft_bundle_size = Some(5);
3636 }
3637
3638 cfg.config_read_setting_impl_cost_base = Some(100);
3639 cfg.config_read_setting_impl_cost_per_byte = Some(40);
3640
3641 if chain != Chain::Testnet && chain != Chain::Mainnet {
3643 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(100);
3644 cfg.feature_flags.per_object_congestion_control_mode =
3645 PerObjectCongestionControlMode::TotalTxCount;
3646 }
3647
3648 cfg.feature_flags.consensus_choice = ConsensusChoice::Mysticeti;
3650
3651 cfg.feature_flags.mysticeti_leader_scoring_and_schedule = true;
3653
3654 cfg.checkpoint_summary_version_specific_data = Some(1);
3656 cfg.min_checkpoint_interval_ms = Some(200);
3657
3658 if chain != Chain::Mainnet {
3660 cfg.feature_flags
3661 .record_consensus_determined_version_assignments_in_prologue = true;
3662 cfg.feature_flags
3663 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = true;
3664 }
3665 if chain != Chain::Mainnet {
3667 cfg.move_binary_format_version = Some(7);
3668 }
3669
3670 if chain != Chain::Testnet && chain != Chain::Mainnet {
3671 cfg.feature_flags.passkey_auth = true;
3672 }
3673 cfg.feature_flags.enable_coin_deny_list_v2 = true;
3674 }
3675 53 => {
3676 cfg.bridge_should_try_to_finalize_committee = Some(chain != Chain::Mainnet);
3678
3679 cfg.feature_flags
3681 .record_consensus_determined_version_assignments_in_prologue = true;
3682 cfg.feature_flags
3683 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = true;
3684
3685 if chain == Chain::Unknown {
3686 cfg.feature_flags.authority_capabilities_v2 = true;
3687 }
3688
3689 if chain != Chain::Mainnet {
3691 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(100);
3692 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(10);
3693 cfg.feature_flags.per_object_congestion_control_mode =
3694 PerObjectCongestionControlMode::TotalTxCount;
3695 }
3696
3697 cfg.bcs_per_byte_serialized_cost = Some(2);
3699 cfg.bcs_legacy_min_output_size_cost = Some(1);
3700 cfg.bcs_failure_cost = Some(52);
3701 cfg.debug_print_base_cost = Some(52);
3702 cfg.debug_print_stack_trace_base_cost = Some(52);
3703 cfg.hash_sha2_256_base_cost = Some(52);
3704 cfg.hash_sha2_256_per_byte_cost = Some(2);
3705 cfg.hash_sha2_256_legacy_min_input_len_cost = Some(1);
3706 cfg.hash_sha3_256_base_cost = Some(52);
3707 cfg.hash_sha3_256_per_byte_cost = Some(2);
3708 cfg.hash_sha3_256_legacy_min_input_len_cost = Some(1);
3709 cfg.type_name_get_base_cost = Some(52);
3710 cfg.type_name_get_per_byte_cost = Some(2);
3711 cfg.string_check_utf8_base_cost = Some(52);
3712 cfg.string_check_utf8_per_byte_cost = Some(2);
3713 cfg.string_is_char_boundary_base_cost = Some(52);
3714 cfg.string_sub_string_base_cost = Some(52);
3715 cfg.string_sub_string_per_byte_cost = Some(2);
3716 cfg.string_index_of_base_cost = Some(52);
3717 cfg.string_index_of_per_byte_pattern_cost = Some(2);
3718 cfg.string_index_of_per_byte_searched_cost = Some(2);
3719 cfg.vector_empty_base_cost = Some(52);
3720 cfg.vector_length_base_cost = Some(52);
3721 cfg.vector_push_back_base_cost = Some(52);
3722 cfg.vector_push_back_legacy_per_abstract_memory_unit_cost = Some(2);
3723 cfg.vector_borrow_base_cost = Some(52);
3724 cfg.vector_pop_back_base_cost = Some(52);
3725 cfg.vector_destroy_empty_base_cost = Some(52);
3726 cfg.vector_swap_base_cost = Some(52);
3727 }
3728 54 => {
3729 cfg.feature_flags.random_beacon = true;
3731 cfg.random_beacon_reduction_lower_bound = Some(1000);
3732 cfg.random_beacon_dkg_timeout_round = Some(3000);
3733 cfg.random_beacon_min_round_interval_ms = Some(500);
3734
3735 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(100);
3737 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(10);
3738 cfg.feature_flags.per_object_congestion_control_mode =
3739 PerObjectCongestionControlMode::TotalTxCount;
3740
3741 cfg.feature_flags.soft_bundle = true;
3743 cfg.max_soft_bundle_size = Some(5);
3744 }
3745 55 => {
3746 cfg.move_binary_format_version = Some(7);
3748
3749 cfg.consensus_max_transactions_in_block_bytes = Some(512 * 1024);
3751 cfg.consensus_max_num_transactions_in_block = Some(512);
3754
3755 cfg.feature_flags.rethrow_serialization_type_layout_errors = true;
3756 }
3757 56 => {
3758 if chain == Chain::Mainnet {
3759 cfg.feature_flags.bridge = true;
3760 }
3761 }
3762 57 => {
3763 cfg.random_beacon_reduction_lower_bound = Some(800);
3765 }
3766 58 => {
3767 if chain == Chain::Mainnet {
3768 cfg.bridge_should_try_to_finalize_committee = Some(true);
3769 }
3770
3771 if chain != Chain::Mainnet && chain != Chain::Testnet {
3772 cfg.feature_flags
3774 .consensus_distributed_vote_scoring_strategy = true;
3775 }
3776 }
3777 59 => {
3778 cfg.feature_flags.consensus_round_prober = true;
3780 }
3781 60 => {
3782 cfg.max_type_to_layout_nodes = Some(512);
3783 cfg.feature_flags.validate_identifier_inputs = true;
3784 }
3785 61 => {
3786 if chain != Chain::Mainnet {
3787 cfg.feature_flags
3789 .consensus_distributed_vote_scoring_strategy = true;
3790 }
3791 cfg.random_beacon_reduction_lower_bound = Some(700);
3793
3794 if chain != Chain::Mainnet && chain != Chain::Testnet {
3795 cfg.feature_flags.mysticeti_fastpath = true;
3797 }
3798 }
3799 62 => {
3800 cfg.feature_flags.relocate_event_module = true;
3801 }
3802 63 => {
3803 cfg.feature_flags.per_object_congestion_control_mode =
3804 PerObjectCongestionControlMode::TotalGasBudgetWithCap;
3805 cfg.gas_budget_based_txn_cost_cap_factor = Some(400_000);
3806 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(18_500_000);
3807 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(240_000_000);
3808 }
3809 64 => {
3810 cfg.feature_flags.per_object_congestion_control_mode =
3811 PerObjectCongestionControlMode::TotalTxCount;
3812 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(40);
3813 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(3);
3814 }
3815 65 => {
3816 cfg.feature_flags
3818 .consensus_distributed_vote_scoring_strategy = true;
3819 }
3820 66 => {
3821 if chain == Chain::Mainnet {
3822 cfg.feature_flags
3824 .consensus_distributed_vote_scoring_strategy = false;
3825 }
3826 }
3827 67 => {
3828 cfg.feature_flags
3830 .consensus_distributed_vote_scoring_strategy = true;
3831 }
3832 68 => {
3833 cfg.group_ops_bls12381_g1_to_uncompressed_g1_cost = Some(26);
3834 cfg.group_ops_bls12381_uncompressed_g1_to_g1_cost = Some(52);
3835 cfg.group_ops_bls12381_uncompressed_g1_sum_base_cost = Some(26);
3836 cfg.group_ops_bls12381_uncompressed_g1_sum_cost_per_term = Some(13);
3837 cfg.group_ops_bls12381_uncompressed_g1_sum_max_terms = Some(2000);
3838
3839 if chain != Chain::Mainnet && chain != Chain::Testnet {
3840 cfg.feature_flags.uncompressed_g1_group_elements = true;
3841 }
3842
3843 cfg.feature_flags.per_object_congestion_control_mode =
3844 PerObjectCongestionControlMode::TotalGasBudgetWithCap;
3845 cfg.gas_budget_based_txn_cost_cap_factor = Some(400_000);
3846 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(18_500_000);
3847 cfg.max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit =
3848 Some(3_700_000); cfg.max_txn_cost_overage_per_object_in_commit = Some(u64::MAX);
3850 cfg.gas_budget_based_txn_cost_absolute_cap_commit_count = Some(50);
3851
3852 cfg.random_beacon_reduction_lower_bound = Some(500);
3854
3855 cfg.feature_flags.disallow_new_modules_in_deps_only_packages = true;
3856 }
3857 69 => {
3858 cfg.consensus_voting_rounds = Some(40);
3860
3861 if chain != Chain::Mainnet && chain != Chain::Testnet {
3862 cfg.feature_flags.consensus_smart_ancestor_selection = true;
3864 }
3865
3866 if chain != Chain::Mainnet {
3867 cfg.feature_flags.uncompressed_g1_group_elements = true;
3868 }
3869 }
3870 70 => {
3871 if chain != Chain::Mainnet {
3872 cfg.feature_flags.consensus_smart_ancestor_selection = true;
3874 cfg.feature_flags
3876 .consensus_round_prober_probe_accepted_rounds = true;
3877 }
3878
3879 cfg.poseidon_bn254_cost_per_block = Some(388);
3880
3881 cfg.gas_model_version = Some(9);
3882 cfg.feature_flags.native_charging_v2 = true;
3883 cfg.bls12381_bls12381_min_sig_verify_cost_base = Some(44064);
3884 cfg.bls12381_bls12381_min_pk_verify_cost_base = Some(49282);
3885 cfg.ecdsa_k1_secp256k1_verify_keccak256_cost_base = Some(1470);
3886 cfg.ecdsa_k1_secp256k1_verify_sha256_cost_base = Some(1470);
3887 cfg.ecdsa_r1_secp256r1_verify_sha256_cost_base = Some(4225);
3888 cfg.ecdsa_r1_secp256r1_verify_keccak256_cost_base = Some(4225);
3889 cfg.ecvrf_ecvrf_verify_cost_base = Some(4848);
3890 cfg.ed25519_ed25519_verify_cost_base = Some(1802);
3891
3892 cfg.ecdsa_r1_ecrecover_keccak256_cost_base = Some(1173);
3894 cfg.ecdsa_r1_ecrecover_sha256_cost_base = Some(1173);
3895 cfg.ecdsa_k1_ecrecover_keccak256_cost_base = Some(500);
3896 cfg.ecdsa_k1_ecrecover_sha256_cost_base = Some(500);
3897
3898 cfg.groth16_prepare_verifying_key_bls12381_cost_base = Some(53838);
3899 cfg.groth16_prepare_verifying_key_bn254_cost_base = Some(82010);
3900 cfg.groth16_verify_groth16_proof_internal_bls12381_cost_base = Some(72090);
3901 cfg.groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input =
3902 Some(8213);
3903 cfg.groth16_verify_groth16_proof_internal_bn254_cost_base = Some(115502);
3904 cfg.groth16_verify_groth16_proof_internal_bn254_cost_per_public_input =
3905 Some(9484);
3906
3907 cfg.hash_keccak256_cost_base = Some(10);
3908 cfg.hash_blake2b256_cost_base = Some(10);
3909
3910 cfg.group_ops_bls12381_decode_scalar_cost = Some(7);
3912 cfg.group_ops_bls12381_decode_g1_cost = Some(2848);
3913 cfg.group_ops_bls12381_decode_g2_cost = Some(3770);
3914 cfg.group_ops_bls12381_decode_gt_cost = Some(3068);
3915
3916 cfg.group_ops_bls12381_scalar_add_cost = Some(10);
3917 cfg.group_ops_bls12381_g1_add_cost = Some(1556);
3918 cfg.group_ops_bls12381_g2_add_cost = Some(3048);
3919 cfg.group_ops_bls12381_gt_add_cost = Some(188);
3920
3921 cfg.group_ops_bls12381_scalar_sub_cost = Some(10);
3922 cfg.group_ops_bls12381_g1_sub_cost = Some(1550);
3923 cfg.group_ops_bls12381_g2_sub_cost = Some(3019);
3924 cfg.group_ops_bls12381_gt_sub_cost = Some(497);
3925
3926 cfg.group_ops_bls12381_scalar_mul_cost = Some(11);
3927 cfg.group_ops_bls12381_g1_mul_cost = Some(4842);
3928 cfg.group_ops_bls12381_g2_mul_cost = Some(9108);
3929 cfg.group_ops_bls12381_gt_mul_cost = Some(27490);
3930
3931 cfg.group_ops_bls12381_scalar_div_cost = Some(91);
3932 cfg.group_ops_bls12381_g1_div_cost = Some(5091);
3933 cfg.group_ops_bls12381_g2_div_cost = Some(9206);
3934 cfg.group_ops_bls12381_gt_div_cost = Some(27804);
3935
3936 cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(2962);
3937 cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(8688);
3938
3939 cfg.group_ops_bls12381_g1_msm_base_cost = Some(62648);
3940 cfg.group_ops_bls12381_g2_msm_base_cost = Some(131192);
3941 cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(1333);
3942 cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(3216);
3943
3944 cfg.group_ops_bls12381_uncompressed_g1_to_g1_cost = Some(677);
3945 cfg.group_ops_bls12381_g1_to_uncompressed_g1_cost = Some(2099);
3946 cfg.group_ops_bls12381_uncompressed_g1_sum_base_cost = Some(77);
3947 cfg.group_ops_bls12381_uncompressed_g1_sum_cost_per_term = Some(26);
3948
3949 cfg.group_ops_bls12381_pairing_cost = Some(26897);
3950 cfg.group_ops_bls12381_uncompressed_g1_sum_max_terms = Some(1200);
3951
3952 cfg.validator_validate_metadata_cost_base = Some(20000);
3953 }
3954 71 => {
3955 cfg.sip_45_consensus_amplification_threshold = Some(5);
3956
3957 cfg.allowed_txn_cost_overage_burst_per_object_in_commit = Some(185_000_000);
3959 }
3960 72 => {
3961 cfg.feature_flags.convert_type_argument_error = true;
3962
3963 cfg.max_tx_gas = Some(50_000_000_000_000);
3966 cfg.max_gas_price = Some(50_000_000_000);
3968
3969 cfg.feature_flags.variant_nodes = true;
3970 }
3971 73 => {
3972 cfg.use_object_per_epoch_marker_table_v2 = Some(true);
3974
3975 if chain != Chain::Mainnet && chain != Chain::Testnet {
3976 cfg.consensus_gc_depth = Some(60);
3979 }
3980
3981 if chain != Chain::Mainnet {
3982 cfg.feature_flags.consensus_zstd_compression = true;
3984 }
3985
3986 cfg.feature_flags.consensus_smart_ancestor_selection = true;
3988 cfg.feature_flags
3990 .consensus_round_prober_probe_accepted_rounds = true;
3991
3992 cfg.feature_flags.per_object_congestion_control_mode =
3994 PerObjectCongestionControlMode::TotalGasBudgetWithCap;
3995 cfg.gas_budget_based_txn_cost_cap_factor = Some(400_000);
3996 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(37_000_000);
3997 cfg.max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit =
3998 Some(7_400_000); cfg.max_txn_cost_overage_per_object_in_commit = Some(u64::MAX);
4000 cfg.gas_budget_based_txn_cost_absolute_cap_commit_count = Some(50);
4001 cfg.allowed_txn_cost_overage_burst_per_object_in_commit = Some(370_000_000);
4002 }
4003 74 => {
4004 if chain != Chain::Mainnet && chain != Chain::Testnet {
4006 cfg.feature_flags.enable_nitro_attestation = true;
4007 }
4008 cfg.nitro_attestation_parse_base_cost = Some(53 * 50);
4009 cfg.nitro_attestation_parse_cost_per_byte = Some(50);
4010 cfg.nitro_attestation_verify_base_cost = Some(49632 * 50);
4011 cfg.nitro_attestation_verify_cost_per_cert = Some(52369 * 50);
4012
4013 cfg.feature_flags.consensus_zstd_compression = true;
4015
4016 if chain != Chain::Mainnet && chain != Chain::Testnet {
4017 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
4018 }
4019 }
4020 75 => {
4021 if chain != Chain::Mainnet {
4022 cfg.feature_flags.passkey_auth = true;
4023 }
4024 }
4025 76 => {
4026 if chain != Chain::Mainnet && chain != Chain::Testnet {
4027 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
4028 cfg.consensus_commit_rate_estimation_window_size = Some(10);
4029 }
4030 cfg.feature_flags.minimize_child_object_mutations = true;
4031
4032 if chain != Chain::Mainnet {
4033 cfg.feature_flags.accept_passkey_in_multisig = true;
4034 }
4035 }
4036 77 => {
4037 cfg.feature_flags.uncompressed_g1_group_elements = true;
4038
4039 if chain != Chain::Mainnet {
4040 cfg.consensus_gc_depth = Some(60);
4041 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
4042 }
4043 }
4044 78 => {
4045 cfg.feature_flags.move_native_context = true;
4046 cfg.tx_context_fresh_id_cost_base = Some(52);
4047 cfg.tx_context_sender_cost_base = Some(30);
4048 cfg.tx_context_epoch_cost_base = Some(30);
4049 cfg.tx_context_epoch_timestamp_ms_cost_base = Some(30);
4050 cfg.tx_context_sponsor_cost_base = Some(30);
4051 cfg.tx_context_gas_price_cost_base = Some(30);
4052 cfg.tx_context_gas_budget_cost_base = Some(30);
4053 cfg.tx_context_ids_created_cost_base = Some(30);
4054 cfg.tx_context_replace_cost_base = Some(30);
4055 cfg.gas_model_version = Some(10);
4056
4057 if chain != Chain::Mainnet {
4058 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
4059 cfg.consensus_commit_rate_estimation_window_size = Some(10);
4060
4061 cfg.feature_flags.per_object_congestion_control_mode =
4063 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4064 ExecutionTimeEstimateParams {
4065 target_utilization: 30,
4066 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4068 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4070 stored_observations_limit: u64::MAX,
4071 stake_weighted_median_threshold: 0,
4072 default_none_duration_for_new_keys: false,
4073 observations_chunk_size: None,
4074 },
4075 );
4076 }
4077 }
4078 79 => {
4079 if chain != Chain::Mainnet {
4080 cfg.feature_flags.consensus_median_based_commit_timestamp = true;
4081
4082 cfg.consensus_bad_nodes_stake_threshold = Some(30);
4085
4086 cfg.feature_flags.consensus_batched_block_sync = true;
4087
4088 cfg.feature_flags.enable_nitro_attestation = true
4090 }
4091 cfg.feature_flags.normalize_ptb_arguments = true;
4092
4093 cfg.consensus_gc_depth = Some(60);
4094 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
4095 }
4096 80 => {
4097 cfg.max_ptb_value_size = Some(1024 * 1024);
4098 }
4099 81 => {
4100 cfg.feature_flags.consensus_median_based_commit_timestamp = true;
4101 cfg.feature_flags.enforce_checkpoint_timestamp_monotonicity = true;
4102 cfg.consensus_bad_nodes_stake_threshold = Some(30)
4103 }
4104 82 => {
4105 cfg.feature_flags.max_ptb_value_size_v2 = true;
4106 }
4107 83 => {
4108 if chain == Chain::Mainnet {
4109 let aliased: [u8; 32] = Hex::decode(
4111 "0x0b2da327ba6a4cacbe75dddd50e6e8bbf81d6496e92d66af9154c61c77f7332f",
4112 )
4113 .unwrap()
4114 .try_into()
4115 .unwrap();
4116
4117 cfg.aliased_addresses.push(AliasedAddress {
4119 original: Hex::decode("0xcd8962dad278d8b50fa0f9eb0186bfa4cbdecc6d59377214c88d0286a0ac9562").unwrap().try_into().unwrap(),
4120 aliased,
4121 allowed_tx_digests: vec![
4122 Base58::decode("B2eGLFoMHgj93Ni8dAJBfqGzo8EWSTLBesZzhEpTPA4").unwrap().try_into().unwrap(),
4123 ],
4124 });
4125
4126 cfg.aliased_addresses.push(AliasedAddress {
4127 original: Hex::decode("0xe28b50cef1d633ea43d3296a3f6b67ff0312a5f1a99f0af753c85b8b5de8ff06").unwrap().try_into().unwrap(),
4128 aliased,
4129 allowed_tx_digests: vec![
4130 Base58::decode("J4QqSAgp7VrQtQpMy5wDX4QGsCSEZu3U5KuDAkbESAge").unwrap().try_into().unwrap(),
4131 ],
4132 });
4133 }
4134
4135 if chain != Chain::Mainnet {
4138 cfg.feature_flags.resolve_type_input_ids_to_defining_id = true;
4139 cfg.transfer_party_transfer_internal_cost_base = Some(52);
4140
4141 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
4143 cfg.consensus_commit_rate_estimation_window_size = Some(10);
4144 cfg.feature_flags.per_object_congestion_control_mode =
4145 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4146 ExecutionTimeEstimateParams {
4147 target_utilization: 30,
4148 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4150 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4152 stored_observations_limit: u64::MAX,
4153 stake_weighted_median_threshold: 0,
4154 default_none_duration_for_new_keys: false,
4155 observations_chunk_size: None,
4156 },
4157 );
4158
4159 cfg.feature_flags.consensus_batched_block_sync = true;
4161
4162 cfg.feature_flags.enable_nitro_attestation_upgraded_parsing = true;
4165 cfg.feature_flags.enable_nitro_attestation = true;
4166 }
4167 }
4168 84 => {
4169 if chain == Chain::Mainnet {
4170 cfg.feature_flags.resolve_type_input_ids_to_defining_id = true;
4171 cfg.transfer_party_transfer_internal_cost_base = Some(52);
4172
4173 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
4175 cfg.consensus_commit_rate_estimation_window_size = Some(10);
4176 cfg.feature_flags.per_object_congestion_control_mode =
4177 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4178 ExecutionTimeEstimateParams {
4179 target_utilization: 30,
4180 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4182 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4184 stored_observations_limit: u64::MAX,
4185 stake_weighted_median_threshold: 0,
4186 default_none_duration_for_new_keys: false,
4187 observations_chunk_size: None,
4188 },
4189 );
4190
4191 cfg.feature_flags.consensus_batched_block_sync = true;
4193
4194 cfg.feature_flags.enable_nitro_attestation_upgraded_parsing = true;
4197 cfg.feature_flags.enable_nitro_attestation = true;
4198 }
4199
4200 cfg.feature_flags.per_object_congestion_control_mode =
4202 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4203 ExecutionTimeEstimateParams {
4204 target_utilization: 30,
4205 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4207 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4209 stored_observations_limit: 20,
4210 stake_weighted_median_threshold: 0,
4211 default_none_duration_for_new_keys: false,
4212 observations_chunk_size: None,
4213 },
4214 );
4215 cfg.feature_flags.allow_unbounded_system_objects = true;
4216 }
4217 85 => {
4218 if chain != Chain::Mainnet && chain != Chain::Testnet {
4219 cfg.feature_flags.enable_party_transfer = true;
4220 }
4221
4222 cfg.feature_flags
4223 .record_consensus_determined_version_assignments_in_prologue_v2 = true;
4224 cfg.feature_flags.disallow_self_identifier = true;
4225 cfg.feature_flags.per_object_congestion_control_mode =
4226 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4227 ExecutionTimeEstimateParams {
4228 target_utilization: 50,
4229 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4231 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4233 stored_observations_limit: 20,
4234 stake_weighted_median_threshold: 0,
4235 default_none_duration_for_new_keys: false,
4236 observations_chunk_size: None,
4237 },
4238 );
4239 }
4240 86 => {
4241 cfg.feature_flags.type_tags_in_object_runtime = true;
4242 cfg.max_move_enum_variants = Some(move_core_types::VARIANT_COUNT_MAX);
4243
4244 cfg.feature_flags.per_object_congestion_control_mode =
4246 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4247 ExecutionTimeEstimateParams {
4248 target_utilization: 50,
4249 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4251 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4253 stored_observations_limit: 20,
4254 stake_weighted_median_threshold: 3334,
4255 default_none_duration_for_new_keys: false,
4256 observations_chunk_size: None,
4257 },
4258 );
4259 if chain != Chain::Mainnet {
4261 cfg.feature_flags.enable_party_transfer = true;
4262 }
4263 }
4264 87 => {
4265 if chain == Chain::Mainnet {
4266 cfg.feature_flags.record_time_estimate_processed = true;
4267 }
4268 cfg.feature_flags.better_adapter_type_resolution_errors = true;
4269 }
4270 88 => {
4271 cfg.feature_flags.record_time_estimate_processed = true;
4272 cfg.tx_context_rgp_cost_base = Some(30);
4273 cfg.feature_flags
4274 .ignore_execution_time_observations_after_certs_closed = true;
4275
4276 cfg.feature_flags.per_object_congestion_control_mode =
4279 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4280 ExecutionTimeEstimateParams {
4281 target_utilization: 50,
4282 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4284 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4286 stored_observations_limit: 20,
4287 stake_weighted_median_threshold: 3334,
4288 default_none_duration_for_new_keys: true,
4289 observations_chunk_size: None,
4290 },
4291 );
4292 }
4293 89 => {
4294 cfg.feature_flags.dependency_linkage_error = true;
4295 cfg.feature_flags.additional_multisig_checks = true;
4296 }
4297 90 => {
4298 cfg.max_gas_price_rgp_factor_for_aborted_transactions = Some(100);
4300 cfg.feature_flags.debug_fatal_on_move_invariant_violation = true;
4301 cfg.feature_flags.additional_consensus_digest_indirect_state = true;
4302 cfg.feature_flags.accept_passkey_in_multisig = true;
4303 cfg.feature_flags.passkey_auth = true;
4304 cfg.feature_flags.check_for_init_during_upgrade = true;
4305
4306 if chain != Chain::Mainnet {
4308 cfg.feature_flags.mysticeti_fastpath = true;
4309 }
4310 }
4311 91 => {
4312 cfg.feature_flags.per_command_shared_object_transfer_rules = true;
4313 }
4314 92 => {
4315 cfg.feature_flags.per_command_shared_object_transfer_rules = false;
4316 }
4317 93 => {
4318 cfg.feature_flags
4319 .consensus_checkpoint_signature_key_includes_digest = true;
4320 }
4321 94 => {
4322 cfg.feature_flags.per_object_congestion_control_mode =
4324 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4325 ExecutionTimeEstimateParams {
4326 target_utilization: 50,
4327 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4329 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4331 stored_observations_limit: 18,
4332 stake_weighted_median_threshold: 3334,
4333 default_none_duration_for_new_keys: true,
4334 observations_chunk_size: None,
4335 },
4336 );
4337
4338 cfg.feature_flags.enable_party_transfer = true;
4340 }
4341 95 => {
4342 cfg.type_name_id_base_cost = Some(52);
4343
4344 cfg.max_transactions_per_checkpoint = Some(20_000);
4346 }
4347 96 => {
4348 if chain != Chain::Mainnet && chain != Chain::Testnet {
4350 cfg.feature_flags
4351 .include_checkpoint_artifacts_digest_in_summary = true;
4352 }
4353 cfg.feature_flags.correct_gas_payment_limit_check = true;
4354 cfg.feature_flags.authority_capabilities_v2 = true;
4355 cfg.feature_flags.use_mfp_txns_in_load_initial_object_debts = true;
4356 cfg.feature_flags.cancel_for_failed_dkg_early = true;
4357 cfg.feature_flags.enable_coin_registry = true;
4358
4359 cfg.feature_flags.mysticeti_fastpath = true;
4361 }
4362 97 => {
4363 cfg.feature_flags.additional_borrow_checks = true;
4364 }
4365 98 => {
4366 cfg.event_emit_auth_stream_cost = Some(52);
4367 cfg.feature_flags.better_loader_errors = true;
4368 cfg.feature_flags.generate_df_type_layouts = true;
4369 }
4370 99 => {
4371 cfg.feature_flags.use_new_commit_handler = true;
4372 }
4373 100 => {
4374 cfg.feature_flags.private_generics_verifier_v2 = true;
4375 }
4376 101 => {
4377 cfg.feature_flags.create_root_accumulator_object = true;
4378 cfg.max_updates_per_settlement_txn = Some(100);
4379 if chain != Chain::Mainnet {
4380 cfg.feature_flags.enable_poseidon = true;
4381 }
4382 }
4383 102 => {
4384 cfg.feature_flags.per_object_congestion_control_mode =
4388 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4389 ExecutionTimeEstimateParams {
4390 target_utilization: 50,
4391 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4393 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4395 stored_observations_limit: 180,
4396 stake_weighted_median_threshold: 3334,
4397 default_none_duration_for_new_keys: true,
4398 observations_chunk_size: Some(18),
4399 },
4400 );
4401 cfg.feature_flags.deprecate_global_storage_ops = true;
4402 }
4403 103 => {}
4404 104 => {
4405 cfg.translation_per_command_base_charge = Some(1);
4406 cfg.translation_per_input_base_charge = Some(1);
4407 cfg.translation_pure_input_per_byte_charge = Some(1);
4408 cfg.translation_per_type_node_charge = Some(1);
4409 cfg.translation_per_reference_node_charge = Some(1);
4410 cfg.translation_per_linkage_entry_charge = Some(10);
4411 cfg.gas_model_version = Some(11);
4412 cfg.feature_flags.abstract_size_in_object_runtime = true;
4413 cfg.feature_flags.object_runtime_charge_cache_load_gas = true;
4414 cfg.dynamic_field_hash_type_and_key_cost_base = Some(52);
4415 cfg.dynamic_field_add_child_object_cost_base = Some(52);
4416 cfg.dynamic_field_add_child_object_value_cost_per_byte = Some(1);
4417 cfg.dynamic_field_borrow_child_object_cost_base = Some(52);
4418 cfg.dynamic_field_borrow_child_object_child_ref_cost_per_byte = Some(1);
4419 cfg.dynamic_field_remove_child_object_cost_base = Some(52);
4420 cfg.dynamic_field_remove_child_object_child_cost_per_byte = Some(1);
4421 cfg.dynamic_field_has_child_object_cost_base = Some(52);
4422 cfg.dynamic_field_has_child_object_with_ty_cost_base = Some(52);
4423 cfg.feature_flags.enable_ptb_execution_v2 = true;
4424
4425 cfg.poseidon_bn254_cost_base = Some(260);
4426
4427 cfg.feature_flags.consensus_skip_gced_accept_votes = true;
4428
4429 if chain != Chain::Mainnet {
4430 cfg.feature_flags
4431 .enable_nitro_attestation_all_nonzero_pcrs_parsing = true;
4432 }
4433
4434 cfg.feature_flags
4435 .include_cancelled_randomness_txns_in_prologue = true;
4436 }
4437 105 => {
4438 cfg.feature_flags.enable_multi_epoch_transaction_expiration = true;
4439 cfg.feature_flags.disable_preconsensus_locking = true;
4440
4441 if chain != Chain::Mainnet {
4442 cfg.feature_flags
4443 .enable_nitro_attestation_always_include_required_pcrs_parsing = true;
4444 }
4445 }
4446 106 => {
4447 cfg.accumulator_object_storage_cost = Some(7600);
4449
4450 if chain != Chain::Mainnet && chain != Chain::Testnet {
4451 cfg.feature_flags.enable_accumulators = true;
4452 cfg.feature_flags.enable_address_balance_gas_payments = true;
4453 cfg.feature_flags.enable_authenticated_event_streams = true;
4454 cfg.feature_flags.enable_object_funds_withdraw = true;
4455 }
4456 }
4457 107 => {
4458 cfg.feature_flags
4459 .consensus_skip_gced_blocks_in_direct_finalization = true;
4460
4461 if in_integration_test() {
4463 cfg.consensus_gc_depth = Some(6);
4464 cfg.consensus_max_num_transactions_in_block = Some(8);
4465 }
4466 }
4467 108 => {
4468 cfg.feature_flags.gas_rounding_halve_digits = true;
4469 cfg.feature_flags.flexible_tx_context_positions = true;
4470 cfg.feature_flags.disable_entry_point_signature_check = true;
4471
4472 if chain != Chain::Mainnet {
4473 cfg.feature_flags.address_aliases = true;
4474
4475 cfg.feature_flags.enable_accumulators = true;
4476 cfg.feature_flags.enable_address_balance_gas_payments = true;
4477 }
4478
4479 cfg.feature_flags.enable_poseidon = true;
4480 }
4481 109 => {
4482 cfg.binary_variant_handles = Some(1024);
4483 cfg.binary_variant_instantiation_handles = Some(1024);
4484 cfg.feature_flags.restrict_hot_or_not_entry_functions = true;
4485 }
4486 110 => {
4487 cfg.feature_flags
4488 .enable_nitro_attestation_all_nonzero_pcrs_parsing = true;
4489 cfg.feature_flags
4490 .enable_nitro_attestation_always_include_required_pcrs_parsing = true;
4491 if chain != Chain::Mainnet && chain != Chain::Testnet {
4492 cfg.feature_flags.split_checkpoints_in_consensus_handler = true;
4493 }
4494 cfg.feature_flags.validate_zklogin_public_identifier = true;
4495 cfg.feature_flags.fix_checkpoint_signature_mapping = true;
4496 cfg.feature_flags
4497 .consensus_always_accept_system_transactions = true;
4498 if chain != Chain::Mainnet {
4499 cfg.feature_flags.enable_object_funds_withdraw = true;
4500 }
4501 }
4502 111 => {
4503 cfg.feature_flags.validator_metadata_verify_v2 = true;
4504 }
4505 112 => {
4506 cfg.group_ops_ristretto_decode_scalar_cost = Some(7);
4507 cfg.group_ops_ristretto_decode_point_cost = Some(200);
4508 cfg.group_ops_ristretto_scalar_add_cost = Some(10);
4509 cfg.group_ops_ristretto_point_add_cost = Some(500);
4510 cfg.group_ops_ristretto_scalar_sub_cost = Some(10);
4511 cfg.group_ops_ristretto_point_sub_cost = Some(500);
4512 cfg.group_ops_ristretto_scalar_mul_cost = Some(11);
4513 cfg.group_ops_ristretto_point_mul_cost = Some(1200);
4514 cfg.group_ops_ristretto_scalar_div_cost = Some(151);
4515 cfg.group_ops_ristretto_point_div_cost = Some(2500);
4516
4517 if chain != Chain::Mainnet && chain != Chain::Testnet {
4518 cfg.feature_flags.enable_ristretto255_group_ops = true;
4519 }
4520 }
4521 113 => {
4522 cfg.feature_flags.address_balance_gas_check_rgp_at_signing = true;
4523 if chain != Chain::Mainnet && chain != Chain::Testnet {
4524 cfg.feature_flags.defer_unpaid_amplification = true;
4525 }
4526 }
4527 114 => {
4528 cfg.feature_flags.randomize_checkpoint_tx_limit_in_tests = true;
4529 cfg.feature_flags.address_balance_gas_reject_gas_coin_arg = true;
4530 if chain != Chain::Mainnet {
4531 cfg.feature_flags.split_checkpoints_in_consensus_handler = true;
4532 cfg.feature_flags.enable_authenticated_event_streams = true;
4533 cfg.feature_flags
4534 .include_checkpoint_artifacts_digest_in_summary = true;
4535 }
4536 }
4537 115 => {
4538 cfg.feature_flags.normalize_depth_formula = true;
4539 }
4540 116 => {
4541 cfg.feature_flags.gasless_transaction_drop_safety = true;
4542 cfg.feature_flags.address_aliases = true;
4543 cfg.feature_flags.relax_valid_during_for_owned_inputs = true;
4544 cfg.feature_flags.defer_unpaid_amplification = false;
4546 cfg.feature_flags.enable_display_registry = true;
4547 }
4548 117 => {}
4549 118 => {
4550 cfg.feature_flags.use_coin_party_owner = true;
4551 }
4552 119 => {
4553 cfg.execution_version = Some(4);
4555 cfg.feature_flags.address_balance_gas_reject_gas_coin_arg = false;
4556 cfg.feature_flags.merge_randomness_into_checkpoint = true;
4557 if chain != Chain::Mainnet {
4558 cfg.feature_flags.enable_gasless = true;
4559 cfg.gasless_max_computation_units = Some(50_000);
4560 cfg.gasless_allowed_token_types = Some(vec![]);
4561 cfg.feature_flags.enable_coin_reservation_obj_refs = true;
4562 cfg.feature_flags
4563 .convert_withdrawal_compatibility_ptb_arguments = true;
4564 }
4565 cfg.gasless_max_unused_inputs = Some(1);
4566 cfg.gasless_max_pure_input_bytes = Some(32);
4567 if chain == Chain::Testnet {
4568 cfg.gasless_allowed_token_types = Some(vec![(TESTNET_USDC.to_string(), 0)]);
4569 }
4570 cfg.transfer_receive_object_cost_per_byte = Some(1);
4571 cfg.transfer_receive_object_type_cost_per_byte = Some(2);
4572 }
4573 120 => {
4574 cfg.feature_flags.disallow_jump_orphans = true;
4575 }
4576 121 => {
4577 if chain != Chain::Mainnet {
4579 cfg.feature_flags.defer_unpaid_amplification = true;
4580 cfg.gasless_max_tps = Some(50);
4581 }
4582 cfg.feature_flags
4583 .early_return_receive_object_mismatched_type = true;
4584 }
4585 122 => {
4586 cfg.feature_flags.defer_unpaid_amplification = true;
4588 cfg.verify_bulletproofs_ristretto255_base_cost = Some(30000);
4590 cfg.verify_bulletproofs_ristretto255_cost_per_bit_and_commitment = Some(6500);
4591 if chain != Chain::Mainnet && chain != Chain::Testnet {
4592 cfg.feature_flags.enable_verify_bulletproofs_ristretto255 = true;
4593 }
4594 cfg.feature_flags.gasless_verify_remaining_balance = true;
4595 cfg.include_special_package_amendments = match chain {
4596 Chain::Mainnet => Some(MAINNET_LINKAGE_AMENDMENTS.clone()),
4597 Chain::Testnet => Some(TESTNET_LINKAGE_AMENDMENTS.clone()),
4598 Chain::Unknown => None,
4599 };
4600 cfg.gasless_max_tx_size_bytes = Some(16 * 1024);
4601 cfg.gasless_max_tps = Some(300);
4602 cfg.gasless_max_computation_units = Some(5_000);
4603 }
4604 123 => {
4605 cfg.gas_model_version = Some(13);
4606 }
4607 124 => {
4608 if chain != Chain::Mainnet && chain != Chain::Testnet {
4609 cfg.feature_flags.timestamp_based_epoch_close = true;
4610 }
4611 cfg.gas_model_version = Some(14);
4612 cfg.feature_flags.limit_groth16_pvk_inputs = true;
4613
4614 cfg.feature_flags.enable_accumulators = true;
4620 cfg.feature_flags.enable_address_balance_gas_payments = true;
4621 cfg.feature_flags.enable_authenticated_event_streams = true;
4622 cfg.feature_flags.enable_coin_reservation_obj_refs = true;
4623 cfg.feature_flags.enable_object_funds_withdraw = true;
4624 cfg.feature_flags
4625 .convert_withdrawal_compatibility_ptb_arguments = true;
4626 cfg.feature_flags.split_checkpoints_in_consensus_handler = true;
4627 cfg.feature_flags
4628 .include_checkpoint_artifacts_digest_in_summary = true;
4629 cfg.feature_flags.enable_gasless = true;
4630
4631 if chain == Chain::Mainnet {
4636 cfg.gasless_allowed_token_types = Some(vec![
4637 (MAINNET_USDC.to_string(), 10_000),
4638 (MAINNET_USDSUI.to_string(), 10_000),
4639 (MAINNET_SUI_USDE.to_string(), 10_000),
4640 (MAINNET_USDY.to_string(), 10_000),
4641 (MAINNET_FDUSD.to_string(), 10_000),
4642 (MAINNET_AUSD.to_string(), 10_000),
4643 (MAINNET_USDB.to_string(), 10_000),
4644 ]);
4645 }
4646 }
4647 125 => {
4648 cfg.feature_flags.granular_post_execution_checks = true;
4649 if chain != Chain::Mainnet {
4650 cfg.feature_flags.timestamp_based_epoch_close = true;
4651 }
4652 }
4653 126 => {
4654 cfg.feature_flags.early_exit_on_iffw = true;
4655 }
4656 127 => {
4657 cfg.feature_flags.always_advance_dkg_to_resolution = true;
4658
4659 cfg.verify_bulletproofs_ristretto255_base_cost = Some(23866);
4660 cfg.verify_bulletproofs_ristretto255_cost_per_bit_and_commitment = Some(1324);
4661 cfg.group_ops_ristretto_decode_scalar_cost = Some(5);
4662 cfg.group_ops_ristretto_decode_point_cost = Some(216);
4663 cfg.group_ops_ristretto_scalar_add_cost = Some(2);
4664 cfg.group_ops_ristretto_point_add_cost = Some(8);
4665 cfg.group_ops_ristretto_scalar_sub_cost = Some(2);
4666 cfg.group_ops_ristretto_point_sub_cost = Some(8);
4667 cfg.group_ops_ristretto_scalar_mul_cost = Some(5);
4668 cfg.group_ops_ristretto_point_mul_cost = Some(1763);
4669 cfg.group_ops_ristretto_scalar_div_cost = Some(557);
4670 cfg.group_ops_ristretto_point_div_cost = Some(2244);
4671
4672 if chain != Chain::Mainnet {
4673 cfg.feature_flags.enable_ristretto255_group_ops = true;
4674 cfg.feature_flags.enable_verify_bulletproofs_ristretto255 = true;
4675 }
4676
4677 cfg.feature_flags.timestamp_based_epoch_close = true;
4678 }
4679 128 => {
4680 cfg.max_generic_instantiation_type_nodes_per_function = Some(10_000);
4681 cfg.max_generic_instantiation_type_nodes_per_module = Some(500_000);
4682 cfg.binary_enum_defs = Some(200);
4683 cfg.binary_enum_def_instantiations = Some(100);
4684 }
4685 129 => {
4686 cfg.feature_flags.enable_unified_linkage = true;
4687 }
4688 130 => {
4689 cfg.feature_flags.record_net_unsettled_object_withdraws = true;
4690 cfg.feature_flags.enable_init_on_upgrade = true;
4691 cfg.epoch_close_deadline_ms = Some(120_000);
4692 cfg.scratch_add_cost_base = Some(13);
4693 cfg.scratch_read_cost_base = Some(13);
4694 cfg.scratch_read_value_cost = Some(1);
4695 cfg.scratch_remove_cost_base = Some(13);
4696 cfg.scratch_exists_cost_base = Some(13);
4697 cfg.scratch_exists_with_type_cost_base = Some(13);
4698 cfg.scratch_exists_with_type_type_cost = Some(1);
4699 let max_commands = cfg.max_programmable_tx_commands() as u64;
4700 cfg.max_scratch_pad_size = Some(16 * max_commands);
4701 if chain != Chain::Mainnet && chain != Chain::Testnet {
4703 cfg.feature_flags.zklogin_circuit_mode = 1;
4704 }
4705 }
4706 131 => {
4707 cfg.feature_flags.share_transaction_deny_config_in_consensus = true;
4708 cfg.feature_flags.framework_tx_context_mut_restrictions = true;
4709 }
4710 132 => {
4711 if chain != Chain::Mainnet && chain != Chain::Testnet {
4712 cfg.feature_flags.defer_owned_object_double_spend = true;
4713 cfg.feature_flags.create_forwarding_address_registry = true;
4714 }
4715 cfg.object_record_new_uid_from_hash_cost_base = Some(1);
4716 cfg.feature_flags
4717 .enable_order_independent_upgrade_init_linkage = true;
4718 }
4719 133 => {
4720 cfg.feature_flags
4721 .include_function_signatures_in_instantiation_limits = true;
4722 cfg.max_accumulator_type_nodes = Some(16);
4723 }
4724 134 => {
4725 if chain != Chain::Mainnet {
4732 cfg.package_original_package_id_impl_cost_base = Some(52);
4733 let package_read_cost_per_byte = cfg.obj_access_cost_read_per_byte();
4734 cfg.package_original_package_id_impl_cost_per_byte =
4735 Some(package_read_cost_per_byte);
4736
4737 cfg.consensus_max_transactions_in_block_bytes = Some(288 * 1024);
4738 cfg.consensus_max_num_transactions_in_block = Some(128);
4739 }
4740
4741 if chain == Chain::Mainnet {
4742 cfg.feature_flags.defer_unpaid_amplification = false;
4743 }
4744 }
4745 135 => {
4746 cfg.package_original_package_id_impl_cost_base = Some(52);
4749 let package_read_cost_per_byte = cfg.obj_access_cost_read_per_byte();
4750 cfg.package_original_package_id_impl_cost_per_byte =
4751 Some(package_read_cost_per_byte);
4752
4753 cfg.consensus_max_transactions_in_block_bytes = Some(288 * 1024);
4754 cfg.consensus_max_num_transactions_in_block = Some(128);
4755
4756 cfg.feature_flags.defer_unpaid_amplification = false;
4757 }
4758 136 => {
4759 cfg.feature_flags.ptb_tx_context_restrictions = true;
4760
4761 cfg.translation_per_live_reference_charge = Some(1);
4762 cfg.max_ptb_live_references = Some(64);
4763 cfg.max_ptb_returned_references = Some(16);
4764 cfg.max_ptb_total_returned_references = Some(256);
4765
4766 if chain != Chain::Mainnet && chain != Chain::Testnet {
4767 cfg.feature_flags.allowed_proposers = true;
4768 }
4769 cfg.feature_flags.harden_linkage_consistency = true;
4770
4771 cfg.package_arena_size_in_bytes = Some(10_000_000);
4772 }
4773 137 => {
4774 cfg.verify_bulletproofs_ristretto255_cost_per_bit_and_commitment = Some(621);
4775 cfg.max_bulletproofs_total_bits = Some(1024);
4776
4777 if chain != Chain::Mainnet {
4778 cfg.feature_flags.enable_allowances = true;
4779 }
4780 cfg.feature_flags.fix_ptb_generated_reads = true;
4781 cfg.feature_flags.charge_ld_const_abstract_size = true;
4782 if chain != Chain::Mainnet && chain != Chain::Testnet {
4783 cfg.feature_flags.check_object_funds_withdraw_in_execution = true;
4784 }
4785 cfg.reserve_object_funds_for_withdrawal_cost_base = Some(52);
4786 cfg.reserve_object_funds_for_withdrawal_cold_read_cost = Some(184);
4789
4790 cfg.feature_flags.allowed_proposers = true;
4791
4792 cfg.feature_flags.validate_ptb_argument_indices = true;
4793 cfg.feature_flags.memory_safety_invariant_check_v2 = true;
4794 }
4795 138 => {
4796 cfg.gas_model_version = Some(15);
4797 cfg.feature_flags.enable_allowances = true;
4798 if chain != Chain::Mainnet {
4799 cfg.feature_flags.check_object_funds_withdraw_in_execution = true;
4800 cfg.feature_flags.disable_effects_tx_dependencies = true;
4801 }
4802 cfg.feature_flags.merge_colliding_deferrals = true;
4803 }
4804 139 => {
4805 if chain != Chain::Mainnet && chain != Chain::Testnet {
4806 cfg.feature_flags.enable_forwarding_addresses = true;
4807 }
4808 }
4809 _ => panic!("unsupported version {:?}", version),
4820 }
4821 }
4822
4823 cfg
4824 }
4825
4826 pub fn apply_seeded_test_overrides(&mut self, seed: &[u8; 32]) {
4827 if !self.feature_flags.randomize_checkpoint_tx_limit_in_tests
4828 || !self.feature_flags.split_checkpoints_in_consensus_handler
4829 {
4830 return;
4831 }
4832
4833 if !mysten_common::in_test_configuration() {
4834 return;
4835 }
4836
4837 use rand::{Rng, SeedableRng, rngs::StdRng};
4838 let mut rng = StdRng::from_seed(*seed);
4839 let max_txns = rng.gen_range(10..=100u64);
4840 info!("seeded test override: max_transactions_per_checkpoint = {max_txns}");
4841 self.max_transactions_per_checkpoint = Some(max_txns);
4842 }
4843
4844 pub fn verifier_config(&self, signing_limits: Option<(usize, usize, usize)>) -> VerifierConfig {
4850 let (
4851 max_back_edges_per_function,
4852 max_back_edges_per_module,
4853 sanity_check_with_regex_reference_safety,
4854 ) = if let Some((
4855 max_back_edges_per_function,
4856 max_back_edges_per_module,
4857 sanity_check_with_regex_reference_safety,
4858 )) = signing_limits
4859 {
4860 (
4861 Some(max_back_edges_per_function),
4862 Some(max_back_edges_per_module),
4863 Some(sanity_check_with_regex_reference_safety),
4864 )
4865 } else {
4866 (None, None, None)
4867 };
4868
4869 let additional_borrow_checks = if signing_limits.is_some() {
4870 true
4872 } else {
4873 self.additional_borrow_checks()
4874 };
4875 let deprecate_global_storage_ops = if signing_limits.is_some() {
4876 true
4878 } else {
4879 self.deprecate_global_storage_ops()
4880 };
4881
4882 VerifierConfig {
4883 max_loop_depth: Some(self.max_loop_depth() as usize),
4884 max_generic_instantiation_length: Some(self.max_generic_instantiation_length() as usize),
4885 max_function_parameters: Some(self.max_function_parameters() as usize),
4886 max_basic_blocks: Some(self.max_basic_blocks() as usize),
4887 max_value_stack_size: self.max_value_stack_size() as usize,
4888 max_type_nodes: Some(self.max_type_nodes() as usize),
4889 max_generic_instantiation_type_nodes_per_function: self
4890 .max_generic_instantiation_type_nodes_per_function_as_option()
4891 .map(|v| v as usize),
4892 max_generic_instantiation_type_nodes_per_module: self
4893 .max_generic_instantiation_type_nodes_per_module_as_option()
4894 .map(|v| v as usize),
4895 include_function_signatures_in_instantiation_limits: self
4896 .include_function_signatures_in_instantiation_limits(),
4897 max_push_size: Some(self.max_push_size() as usize),
4898 max_dependency_depth: Some(self.max_dependency_depth() as usize),
4899 max_fields_in_struct: Some(self.max_fields_in_struct() as usize),
4900 max_function_definitions: Some(self.max_function_definitions() as usize),
4901 max_data_definitions: Some(self.max_struct_definitions() as usize),
4902 max_constant_vector_len: Some(self.max_move_vector_len()),
4903 max_back_edges_per_function,
4904 max_back_edges_per_module,
4905 max_basic_blocks_in_script: None,
4906 max_identifier_len: self.max_move_identifier_len_as_option(), disallow_self_identifier: self.feature_flags.disallow_self_identifier,
4908 allow_receiving_object_id: self.allow_receiving_object_id(),
4909 reject_mutable_random_on_entry_functions: self
4910 .reject_mutable_random_on_entry_functions(),
4911 bytecode_version: self.move_binary_format_version(),
4912 max_variants_in_enum: self.max_move_enum_variants_as_option(),
4913 additional_borrow_checks,
4914 better_loader_errors: self.better_loader_errors(),
4915 private_generics_verifier_v2: self.private_generics_verifier_v2(),
4916 sanity_check_with_regex_reference_safety: sanity_check_with_regex_reference_safety
4917 .map(|limit| limit as u128),
4918 deprecate_global_storage_ops,
4919 disable_entry_point_signature_check: self.disable_entry_point_signature_check(),
4920 switch_to_regex_reference_safety: false,
4921 framework_tx_context_mut_restrictions: self.framework_tx_context_mut_restrictions(),
4922 disallow_jump_orphans: self.disallow_jump_orphans(),
4923 }
4924 }
4925
4926 pub fn binary_config(
4927 &self,
4928 override_deprecate_global_storage_ops_during_deserialization: Option<bool>,
4929 ) -> BinaryConfig {
4930 let deprecate_global_storage_ops =
4931 override_deprecate_global_storage_ops_during_deserialization
4932 .unwrap_or_else(|| self.deprecate_global_storage_ops());
4933 BinaryConfig::new(
4934 self.move_binary_format_version(),
4935 self.min_move_binary_format_version_as_option()
4936 .unwrap_or(VERSION_1),
4937 self.no_extraneous_module_bytes(),
4938 deprecate_global_storage_ops,
4939 TableConfig {
4940 module_handles: self.binary_module_handles_as_option().unwrap_or(u16::MAX),
4941 datatype_handles: self.binary_struct_handles_as_option().unwrap_or(u16::MAX),
4942 function_handles: self.binary_function_handles_as_option().unwrap_or(u16::MAX),
4943 function_instantiations: self
4944 .binary_function_instantiations_as_option()
4945 .unwrap_or(u16::MAX),
4946 signatures: self.binary_signatures_as_option().unwrap_or(u16::MAX),
4947 constant_pool: self.binary_constant_pool_as_option().unwrap_or(u16::MAX),
4948 identifiers: self.binary_identifiers_as_option().unwrap_or(u16::MAX),
4949 address_identifiers: self
4950 .binary_address_identifiers_as_option()
4951 .unwrap_or(u16::MAX),
4952 struct_defs: self.binary_struct_defs_as_option().unwrap_or(u16::MAX),
4953 struct_def_instantiations: self
4954 .binary_struct_def_instantiations_as_option()
4955 .unwrap_or(u16::MAX),
4956 function_defs: self.binary_function_defs_as_option().unwrap_or(u16::MAX),
4957 field_handles: self.binary_field_handles_as_option().unwrap_or(u16::MAX),
4958 field_instantiations: self
4959 .binary_field_instantiations_as_option()
4960 .unwrap_or(u16::MAX),
4961 friend_decls: self.binary_friend_decls_as_option().unwrap_or(u16::MAX),
4962 enum_defs: self.binary_enum_defs_as_option().unwrap_or(u16::MAX),
4963 enum_def_instantiations: self
4964 .binary_enum_def_instantiations_as_option()
4965 .unwrap_or(u16::MAX),
4966 variant_handles: self.binary_variant_handles_as_option().unwrap_or(u16::MAX),
4967 variant_instantiation_handles: self
4968 .binary_variant_instantiation_handles_as_option()
4969 .unwrap_or(u16::MAX),
4970 },
4971 )
4972 }
4973
4974 pub fn apply_overrides_for_testing(
4978 override_fn: impl Fn(ProtocolVersion, Self) -> Self + Send + Sync + 'static,
4979 ) -> OverrideGuard {
4980 let mut cur = CONFIG_OVERRIDE.lock().unwrap();
4981 assert!(cur.is_none(), "config override already present");
4982 *cur = Some(Box::new(override_fn));
4983 OverrideGuard
4984 }
4985
4986 fn apply_config_override(version: ProtocolVersion, mut ret: Self) -> Self {
4987 if let Some(override_fn) = CONFIG_OVERRIDE.lock().unwrap().as_ref() {
4988 warn!(
4989 "overriding ProtocolConfig settings with custom settings (you should not see this log outside of tests)"
4990 );
4991 ret = override_fn(version, ret);
4992 }
4993 ret
4994 }
4995}
4996
4997impl ProtocolConfig {
5001 pub fn set_execution_version_for_testing(&mut self, val: u64) {
5005 let current = self.execution_version.unwrap_or(0);
5006 assert!(
5007 val >= current,
5008 "cannot downgrade execution_version from {current} to {val}: running an old \
5009 executor against a newer protocol config/framework is unsupported. To test \
5010 frozen executor behavior, start from the last protocol version of that executor \
5011 instead, so genesis loads the matching framework snapshot (see \
5012 test_address_balance_gas_v3_accumulator_sign)."
5013 );
5014 self.execution_version = Some(val);
5015 }
5016
5017 pub fn set_zklogin_circuit_mode_for_testing(&mut self, val: u64) {
5020 self.feature_flags.zklogin_circuit_mode = val
5021 }
5022
5023 pub fn set_per_object_congestion_control_mode_for_testing(
5024 &mut self,
5025 val: PerObjectCongestionControlMode,
5026 ) {
5027 self.feature_flags.per_object_congestion_control_mode = val;
5028 }
5029
5030 pub fn set_consensus_choice_for_testing(&mut self, val: ConsensusChoice) {
5031 self.feature_flags.consensus_choice = val;
5032 }
5033
5034 pub fn set_consensus_network_for_testing(&mut self, val: ConsensusNetwork) {
5035 self.feature_flags.consensus_network = val;
5036 }
5037
5038 pub fn set_zklogin_max_epoch_upper_bound_delta_for_testing(&mut self, val: Option<u64>) {
5039 self.feature_flags.zklogin_max_epoch_upper_bound_delta = val
5040 }
5041
5042 pub fn set_mysticeti_num_leaders_per_round_for_testing(&mut self, val: Option<usize>) {
5043 self.feature_flags.mysticeti_num_leaders_per_round = val;
5044 }
5045
5046 pub fn disable_accumulators_for_testing(&mut self) {
5047 self.feature_flags.enable_accumulators = false;
5048 self.feature_flags.enable_address_balance_gas_payments = false;
5049 }
5050
5051 pub fn enable_coin_reservation_for_testing(&mut self) {
5052 self.feature_flags.enable_coin_reservation_obj_refs = true;
5053 self.feature_flags
5054 .convert_withdrawal_compatibility_ptb_arguments = true;
5055 self.execution_version = Some(self.execution_version.map_or(4, |v| v.max(4)));
5058 }
5059
5060 pub fn disable_coin_reservation_for_testing(&mut self) {
5061 self.feature_flags.enable_coin_reservation_obj_refs = false;
5062 self.feature_flags
5063 .convert_withdrawal_compatibility_ptb_arguments = false;
5064 }
5065
5066 pub fn enable_address_balance_gas_payments_for_testing(&mut self) {
5067 self.feature_flags.enable_accumulators = true;
5068 self.feature_flags.allow_private_accumulator_entrypoints = true;
5069 self.feature_flags.enable_address_balance_gas_payments = true;
5070 self.feature_flags.address_balance_gas_check_rgp_at_signing = true;
5071 self.feature_flags.address_balance_gas_reject_gas_coin_arg = false;
5072 self.execution_version = Some(self.execution_version.map_or(4, |v| v.max(4)))
5073 }
5074
5075 pub fn enable_gasless_for_testing(&mut self) {
5076 self.enable_address_balance_gas_payments_for_testing();
5077 self.feature_flags.enable_gasless = true;
5078 self.feature_flags.gasless_verify_remaining_balance = true;
5079 self.gasless_max_computation_units = Some(5_000);
5080 self.gasless_allowed_token_types = Some(vec![]);
5081 self.gasless_max_tps = Some(1000);
5082 self.gasless_max_tx_size_bytes = Some(16 * 1024);
5083 }
5084
5085 pub fn disable_gasless_for_testing(&mut self) {
5086 self.feature_flags.enable_gasless = false;
5087 self.gasless_max_computation_units = None;
5088 self.gasless_allowed_token_types = None;
5089 }
5090
5091 pub fn enable_authenticated_event_streams_for_testing(&mut self) {
5092 self.feature_flags.enable_accumulators = true;
5093 self.feature_flags.enable_authenticated_event_streams = true;
5094 self.feature_flags
5095 .include_checkpoint_artifacts_digest_in_summary = true;
5096 self.feature_flags.split_checkpoints_in_consensus_handler = true;
5097 }
5098}
5099
5100type OverrideFn = dyn Fn(ProtocolVersion, ProtocolConfig) -> ProtocolConfig + Send + Sync;
5101
5102static CONFIG_OVERRIDE: Mutex<Option<Box<OverrideFn>>> = Mutex::new(None);
5103
5104#[must_use]
5105pub struct OverrideGuard;
5106
5107impl Drop for OverrideGuard {
5108 fn drop(&mut self) {
5109 info!("restoring override fn");
5110 *CONFIG_OVERRIDE.lock().unwrap() = None;
5111 }
5112}
5113
5114#[derive(PartialEq, Eq)]
5117pub enum LimitThresholdCrossed {
5118 None,
5119 Soft(u128, u128),
5120 Hard(u128, u128),
5121}
5122
5123pub fn check_limit_in_range<T: Into<V>, U: Into<V>, V: PartialOrd + Into<u128>>(
5126 x: T,
5127 soft_limit: U,
5128 hard_limit: V,
5129) -> LimitThresholdCrossed {
5130 let x: V = x.into();
5131 let soft_limit: V = soft_limit.into();
5132
5133 debug_assert!(soft_limit <= hard_limit);
5134
5135 if x >= hard_limit {
5138 LimitThresholdCrossed::Hard(x.into(), hard_limit.into())
5139 } else if x < soft_limit {
5140 LimitThresholdCrossed::None
5141 } else {
5142 LimitThresholdCrossed::Soft(x.into(), soft_limit.into())
5143 }
5144}
5145
5146#[macro_export]
5147macro_rules! check_limit {
5148 ($x:expr, $hard:expr) => {
5149 check_limit!($x, $hard, $hard)
5150 };
5151 ($x:expr, $soft:expr, $hard:expr) => {
5152 check_limit_in_range($x as u64, $soft, $hard)
5153 };
5154}
5155
5156#[macro_export]
5160macro_rules! check_limit_by_meter {
5161 ($is_metered:expr, $x:expr, $metered_limit:expr, $unmetered_hard_limit:expr, $metric:expr) => {{
5162 let (h, metered_str) = if $is_metered {
5164 ($metered_limit, "metered")
5165 } else {
5166 ($unmetered_hard_limit, "unmetered")
5168 };
5169 use sui_protocol_config::check_limit_in_range;
5170 let result = check_limit_in_range($x as u64, $metered_limit, h);
5171 match result {
5172 LimitThresholdCrossed::None => {}
5173 LimitThresholdCrossed::Soft(_, _) => {
5174 $metric.with_label_values(&[metered_str, "soft"]).inc();
5175 }
5176 LimitThresholdCrossed::Hard(_, _) => {
5177 $metric.with_label_values(&[metered_str, "hard"]).inc();
5178 }
5179 };
5180 result
5181 }};
5182}
5183
5184pub type Amendments = BTreeMap<AccountAddress, BTreeMap<AccountAddress, AccountAddress>>;
5187
5188static MAINNET_LINKAGE_AMENDMENTS: LazyLock<Arc<Amendments>> =
5189 LazyLock::new(|| parse_amendments(include_str!("mainnet_amendments.json")));
5190
5191static TESTNET_LINKAGE_AMENDMENTS: LazyLock<Arc<Amendments>> =
5192 LazyLock::new(|| parse_amendments(include_str!("testnet_amendments.json")));
5193
5194fn parse_amendments(json: &str) -> Arc<Amendments> {
5195 #[derive(serde::Deserialize)]
5196 struct AmendmentEntry {
5197 root: String,
5198 deps: Vec<DepEntry>,
5199 }
5200
5201 #[derive(serde::Deserialize)]
5202 struct DepEntry {
5203 original_id: String,
5204 version_id: String,
5205 }
5206
5207 let entries: Vec<AmendmentEntry> =
5208 serde_json::from_str(json).expect("Failed to parse amendments JSON");
5209 let mut amendments = BTreeMap::new();
5210 for entry in entries {
5211 let root_id = AccountAddress::from_hex_literal(&entry.root).unwrap();
5212 let mut dep_ids = BTreeMap::new();
5213 for dep in entry.deps {
5214 let orig_id = AccountAddress::from_hex_literal(&dep.original_id).unwrap();
5215 let upgraded_id = AccountAddress::from_hex_literal(&dep.version_id).unwrap();
5216 assert!(
5217 dep_ids.insert(orig_id, upgraded_id).is_none(),
5218 "Duplicate original ID in amendments table"
5219 );
5220 }
5221 assert!(
5222 amendments.insert(root_id, dep_ids).is_none(),
5223 "Duplicate root ID in amendments table"
5224 );
5225 }
5226 Arc::new(amendments)
5227}
5228
5229#[cfg(all(test, not(msim)))]
5230mod test {
5231 use insta::assert_yaml_snapshot;
5232
5233 use super::*;
5234
5235 #[test]
5236 fn snapshot_tests() {
5237 println!("\n============================================================================");
5238 println!("! !");
5239 println!("! IMPORTANT: never update snapshots from this test. only add new versions! !");
5240 println!("! !");
5241 println!("============================================================================\n");
5242 for chain_id in &[Chain::Unknown, Chain::Mainnet, Chain::Testnet] {
5243 let chain_str = match chain_id {
5247 Chain::Unknown => "".to_string(),
5248 _ => format!("{:?}_", chain_id),
5249 };
5250 for i in MIN_PROTOCOL_VERSION..=MAX_PROTOCOL_VERSION {
5251 let cur = ProtocolVersion::new(i);
5252 assert_yaml_snapshot!(
5253 format!("{}version_{}", chain_str, cur.as_u64()),
5254 ProtocolConfig::get_for_version(cur, *chain_id)
5255 );
5256 }
5257 }
5258 }
5259
5260 #[test]
5261 fn test_getters() {
5262 let prot: ProtocolConfig =
5263 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5264 assert_eq!(
5265 prot.max_arguments(),
5266 prot.max_arguments_as_option().unwrap()
5267 );
5268 }
5269
5270 #[test]
5271 fn test_setters() {
5272 let mut prot: ProtocolConfig =
5273 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5274 prot.set_max_arguments_for_testing(123);
5275 assert_eq!(prot.max_arguments(), 123);
5276
5277 prot.set_max_arguments_from_str_for_testing("321".to_string());
5278 assert_eq!(prot.max_arguments(), 321);
5279
5280 prot.disable_max_arguments_for_testing();
5281 assert_eq!(prot.max_arguments_as_option(), None);
5282
5283 prot.set_attr_for_testing("max_arguments".to_string(), "456".to_string());
5284 assert_eq!(prot.max_arguments(), 456);
5285 }
5286
5287 #[test]
5288 fn test_execution_version_setter_allows_upgrade() {
5289 let mut prot = ProtocolConfig::get_for_max_version_UNSAFE();
5290 let current = prot.execution_version();
5291 prot.set_execution_version_for_testing(current);
5292 prot.set_execution_version_for_testing(current + 1);
5293 assert_eq!(prot.execution_version(), current + 1);
5294 }
5295
5296 #[test]
5297 #[should_panic(expected = "cannot downgrade execution_version")]
5298 fn test_execution_version_setter_panics_on_downgrade() {
5299 let mut prot = ProtocolConfig::get_for_max_version_UNSAFE();
5300 let current = prot.execution_version();
5301 prot.set_execution_version_for_testing(current - 1);
5302 }
5303
5304 #[test]
5305 fn test_feature_flag_setter_by_string() {
5306 let mut prot: ProtocolConfig =
5307 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5308 assert!(!prot.zklogin_auth());
5309 prot.set_feature_flag_for_testing("zklogin_auth".to_string(), true);
5310 assert!(prot.zklogin_auth());
5311 prot.set_feature_flag_for_testing("zklogin_auth".to_string(), false);
5312 assert!(!prot.zklogin_auth());
5313 }
5314
5315 #[test]
5316 #[should_panic(expected = "unknown feature flag")]
5317 fn test_feature_flag_setter_unknown_flag() {
5318 let mut prot: ProtocolConfig =
5319 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5320 prot.set_feature_flag_for_testing("some random string".to_string(), true);
5321 }
5322
5323 #[test]
5324 fn test_get_for_version_if_supported_applies_test_overrides() {
5325 let before =
5326 ProtocolConfig::get_for_version_if_supported(ProtocolVersion::new(1), Chain::Unknown)
5327 .unwrap();
5328
5329 assert!(!before.enable_coin_reservation_obj_refs());
5330
5331 let _guard = ProtocolConfig::apply_overrides_for_testing(|_, mut cfg| {
5332 cfg.enable_coin_reservation_for_testing();
5333 cfg
5334 });
5335
5336 let after =
5337 ProtocolConfig::get_for_version_if_supported(ProtocolVersion::new(1), Chain::Unknown)
5338 .unwrap();
5339
5340 assert!(after.enable_coin_reservation_obj_refs());
5341 }
5342
5343 #[test]
5344 #[should_panic(expected = "unsupported version")]
5345 fn max_version_test() {
5346 let _ = ProtocolConfig::get_for_version_impl(
5349 ProtocolVersion::new(MAX_PROTOCOL_VERSION + 1),
5350 Chain::Unknown,
5351 );
5352 }
5353
5354 #[test]
5355 fn lookup_by_string_test() {
5356 let prot: ProtocolConfig =
5357 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5358 assert!(prot.lookup_attr("some random string".to_string()).is_none());
5360
5361 assert!(
5362 prot.lookup_attr("max_arguments".to_string())
5363 == Some(ProtocolConfigValue::u32(prot.max_arguments())),
5364 );
5365
5366 assert!(
5368 prot.lookup_attr("max_move_identifier_len".to_string())
5369 .is_none()
5370 );
5371
5372 let prot: ProtocolConfig =
5374 ProtocolConfig::get_for_version(ProtocolVersion::new(9), Chain::Unknown);
5375 assert!(
5376 prot.lookup_attr("max_move_identifier_len".to_string())
5377 == Some(ProtocolConfigValue::u64(prot.max_move_identifier_len()))
5378 );
5379
5380 let prot: ProtocolConfig =
5381 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5382 assert!(
5384 prot.attr_map()
5385 .get("max_move_identifier_len")
5386 .unwrap()
5387 .is_none()
5388 );
5389 assert!(
5391 prot.attr_map().get("max_arguments").unwrap()
5392 == &Some(ProtocolConfigValue::u32(prot.max_arguments()))
5393 );
5394
5395 let prot: ProtocolConfig =
5397 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5398 assert!(
5400 prot.feature_flags
5401 .lookup_attr("some random string".to_owned())
5402 .is_none()
5403 );
5404 assert!(
5405 !prot
5406 .feature_flags
5407 .attr_map()
5408 .contains_key("some random string")
5409 );
5410
5411 assert!(
5413 prot.feature_flags
5414 .lookup_attr("package_upgrades".to_owned())
5415 == Some(false)
5416 );
5417 assert!(
5418 prot.feature_flags
5419 .attr_map()
5420 .get("package_upgrades")
5421 .unwrap()
5422 == &false
5423 );
5424 let prot: ProtocolConfig =
5425 ProtocolConfig::get_for_version(ProtocolVersion::new(4), Chain::Unknown);
5426 assert!(
5428 prot.feature_flags
5429 .lookup_attr("package_upgrades".to_owned())
5430 == Some(true)
5431 );
5432 assert!(
5433 prot.feature_flags
5434 .attr_map()
5435 .get("package_upgrades")
5436 .unwrap()
5437 == &true
5438 );
5439 }
5440
5441 #[test]
5442 fn limit_range_fn_test() {
5443 let low = 100u32;
5444 let high = 10000u64;
5445
5446 assert!(check_limit!(1u8, low, high) == LimitThresholdCrossed::None);
5447 assert!(matches!(
5448 check_limit!(255u16, low, high),
5449 LimitThresholdCrossed::Soft(255u128, 100)
5450 ));
5451 assert!(matches!(
5457 check_limit!(2550000u64, low, high),
5458 LimitThresholdCrossed::Hard(2550000, 10000)
5459 ));
5460
5461 assert!(matches!(
5462 check_limit!(2550000u64, high, high),
5463 LimitThresholdCrossed::Hard(2550000, 10000)
5464 ));
5465
5466 assert!(matches!(
5467 check_limit!(1u8, high),
5468 LimitThresholdCrossed::None
5469 ));
5470
5471 assert!(check_limit!(255u16, high) == LimitThresholdCrossed::None);
5472
5473 assert!(matches!(
5474 check_limit!(2550000u64, high),
5475 LimitThresholdCrossed::Hard(2550000, 10000)
5476 ));
5477 }
5478
5479 #[test]
5480 fn linkage_amendments_load() {
5481 let mainnet = LazyLock::force(&MAINNET_LINKAGE_AMENDMENTS);
5482 let testnet = LazyLock::force(&TESTNET_LINKAGE_AMENDMENTS);
5483 assert!(!mainnet.is_empty(), "mainnet amendments must not be empty");
5484 assert!(!testnet.is_empty(), "testnet amendments must not be empty");
5485 }
5486
5487 #[test]
5488 fn render_scalar_fields_use_precision_safe_encoding() {
5489 use mysten_common::rpc_format::Unmetered;
5490
5491 let config = ProtocolConfig::get_for_max_version_UNSAFE();
5492 let rendered = config
5493 .render::<serde_json::Value>(&mut Unmetered)
5494 .expect("render should succeed");
5495
5496 let max_args = rendered
5497 .get("max_arguments")
5498 .expect("max_arguments set at max version");
5499 assert!(
5500 max_args.is_number(),
5501 "u32 should render as number, got {max_args:?}",
5502 );
5503
5504 let max_tx_size = rendered
5505 .get("max_tx_size_bytes")
5506 .expect("max_tx_size_bytes set at max version");
5507 assert!(
5508 max_tx_size.is_string(),
5509 "u64 should render as string, got {max_tx_size:?}",
5510 );
5511 }
5512
5513 #[test]
5514 fn render_includes_non_scalar_gasless_allowlist_as_json() {
5515 use mysten_common::rpc_format::Unmetered;
5516 use serde_json::json;
5517
5518 let mut config = ProtocolConfig::get_for_max_version_UNSAFE();
5519 config.set_gasless_allowed_token_types_for_testing(vec![
5520 ("0xa::usdc::USDC".to_string(), 10_000),
5521 ("0xb::usdt::USDT".to_string(), 0),
5522 ]);
5523
5524 let rendered = config
5525 .render::<serde_json::Value>(&mut Unmetered)
5526 .expect("render should succeed under Unmetered budget");
5527 let allowlist = rendered
5528 .get("gasless_allowed_token_types")
5529 .expect("entry should be present after the testing setter");
5530
5531 assert_eq!(
5534 allowlist,
5535 &json!([["0xa::usdc::USDC", "10000"], ["0xb::usdt::USDT", "0"],]),
5536 );
5537 }
5538
5539 #[test]
5540 fn render_targets_prost_value_for_grpc() {
5541 use mysten_common::rpc_format::Unmetered;
5542 use prost_types::value::Kind;
5543
5544 let mut config = ProtocolConfig::get_for_max_version_UNSAFE();
5545 config.set_gasless_allowed_token_types_for_testing(vec![(
5546 "0xa::usdc::USDC".to_string(),
5547 10_000,
5548 )]);
5549
5550 let rendered = config
5551 .render::<prost_types::Value>(&mut Unmetered)
5552 .expect("render to prost Value should succeed");
5553 let allowlist = rendered
5554 .get("gasless_allowed_token_types")
5555 .expect("entry should be present after the testing setter");
5556
5557 let Some(Kind::ListValue(outer)) = &allowlist.kind else {
5559 panic!(
5560 "expected ListValue at the top level, got {:?}",
5561 allowlist.kind
5562 );
5563 };
5564 assert_eq!(outer.values.len(), 1, "one allowlisted entry");
5565 let Some(Kind::ListValue(entry)) = &outer.values[0].kind else {
5566 panic!("expected each entry to be a ListValue");
5567 };
5568 assert_eq!(entry.values.len(), 2, "entry has (coin_type, amount)");
5569
5570 let Some(Kind::StringValue(coin_type)) = &entry.values[0].kind else {
5571 panic!("expected coin_type as StringValue");
5572 };
5573 assert_eq!(coin_type, "0xa::usdc::USDC");
5574
5575 let Some(Kind::StringValue(amount)) = &entry.values[1].kind else {
5577 panic!(
5578 "expected minimum_transfer_amount as StringValue (precision-safe u64); got {:?}",
5579 entry.values[1].kind,
5580 );
5581 };
5582 assert_eq!(amount, "10000");
5583 }
5584
5585 #[test]
5586 fn render_emits_null_for_unset_protocol_versions() {
5587 use mysten_common::rpc_format::Unmetered;
5588
5589 let config = ProtocolConfig::get_for_version(1.into(), Chain::Unknown);
5590 let rendered = config
5591 .render::<serde_json::Value>(&mut Unmetered)
5592 .expect("render should succeed");
5593 let entry = rendered
5597 .get("gasless_allowed_token_types")
5598 .expect("key should be present for every protocol version");
5599 assert!(
5600 entry.is_null(),
5601 "value should be null for pre-feature protocol version, got {entry:?}",
5602 );
5603 }
5604}