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)]
420pub struct ProtocolVersion(u64);
421
422impl ProtocolVersion {
423 pub const MIN: Self = Self(MIN_PROTOCOL_VERSION);
428
429 pub const MAX: Self = Self(MAX_PROTOCOL_VERSION);
430
431 #[cfg(not(msim))]
432 pub const MAX_ALLOWED: Self = Self::MAX;
433
434 #[cfg(msim)]
436 pub const MAX_ALLOWED: Self = Self(MAX_PROTOCOL_VERSION + 1);
437
438 pub fn new(v: u64) -> Self {
439 Self(v)
440 }
441
442 pub const fn as_u64(&self) -> u64 {
443 self.0
444 }
445
446 pub fn max() -> Self {
449 Self::MAX
450 }
451
452 pub fn prev(self) -> Self {
453 Self(self.0.checked_sub(1).unwrap())
454 }
455}
456
457impl From<u64> for ProtocolVersion {
458 fn from(v: u64) -> Self {
459 Self::new(v)
460 }
461}
462
463impl std::ops::Sub<u64> for ProtocolVersion {
464 type Output = Self;
465 fn sub(self, rhs: u64) -> Self::Output {
466 Self::new(self.0 - rhs)
467 }
468}
469
470impl std::ops::Add<u64> for ProtocolVersion {
471 type Output = Self;
472 fn add(self, rhs: u64) -> Self::Output {
473 Self::new(self.0 + rhs)
474 }
475}
476
477#[derive(
478 Clone, Serialize, Deserialize, Debug, Default, PartialEq, Copy, PartialOrd, Ord, Eq, ValueEnum,
479)]
480pub enum Chain {
481 Mainnet,
482 Testnet,
483 #[default]
484 Unknown,
485}
486
487impl Chain {
488 pub fn as_str(self) -> &'static str {
489 match self {
490 Chain::Mainnet => "mainnet",
491 Chain::Testnet => "testnet",
492 Chain::Unknown => "unknown",
493 }
494 }
495}
496
497pub struct Error(pub String);
498
499#[derive(Default, Clone, Serialize, Deserialize, Debug, ProtocolConfigFeatureFlagsGetters)]
502struct FeatureFlags {
503 #[serde(skip_serializing_if = "is_false")]
506 package_upgrades: bool,
507 #[serde(skip_serializing_if = "is_false")]
510 commit_root_state_digest: bool,
511 #[serde(skip_serializing_if = "is_false")]
513 advance_epoch_start_time_in_safe_mode: bool,
514 #[serde(skip_serializing_if = "is_false")]
517 loaded_child_objects_fixed: bool,
518 #[serde(skip_serializing_if = "is_false")]
521 missing_type_is_compatibility_error: bool,
522 #[serde(skip_serializing_if = "is_false")]
525 scoring_decision_with_validity_cutoff: bool,
526
527 #[serde(skip_serializing_if = "is_false")]
530 consensus_order_end_of_epoch_last: bool,
531
532 #[serde(skip_serializing_if = "is_false")]
536 consensus_slim_block_propagation: bool,
537
538 #[serde(skip_serializing_if = "is_false")]
540 disallow_adding_abilities_on_upgrade: bool,
541 #[serde(skip_serializing_if = "is_false")]
543 disable_invariant_violation_check_in_swap_loc: bool,
544 #[serde(skip_serializing_if = "is_false")]
547 advance_to_highest_supported_protocol_version: bool,
548 #[serde(skip_serializing_if = "is_false")]
550 ban_entry_init: bool,
551 #[serde(skip_serializing_if = "is_false")]
553 package_digest_hash_module: bool,
554 #[serde(skip_serializing_if = "is_false")]
556 disallow_change_struct_type_params_on_upgrade: bool,
557 #[serde(skip_serializing_if = "is_false")]
559 no_extraneous_module_bytes: bool,
560 #[serde(skip_serializing_if = "is_false")]
562 narwhal_versioned_metadata: bool,
563
564 #[serde(skip_serializing_if = "is_false")]
566 zklogin_auth: bool,
567 #[serde(skip_serializing_if = "is_zero")]
570 zklogin_circuit_mode: u64,
571 #[serde(skip_serializing_if = "ConsensusTransactionOrdering::is_none")]
573 consensus_transaction_ordering: ConsensusTransactionOrdering,
574
575 #[serde(skip_serializing_if = "is_false")]
583 simplified_unwrap_then_delete: bool,
584 #[serde(skip_serializing_if = "is_false")]
586 upgraded_multisig_supported: bool,
587 #[serde(skip_serializing_if = "is_false")]
589 txn_base_cost_as_multiplier: bool,
590
591 #[serde(skip_serializing_if = "is_false")]
593 shared_object_deletion: bool,
594
595 #[serde(skip_serializing_if = "is_false")]
597 narwhal_new_leader_election_schedule: bool,
598
599 #[serde(skip_serializing_if = "is_empty")]
601 zklogin_supported_providers: BTreeSet<String>,
602
603 #[serde(skip_serializing_if = "is_false")]
605 loaded_child_object_format: bool,
606
607 #[serde(skip_serializing_if = "is_false")]
608 #[skip_protocol_config_accessor]
609 enable_jwk_consensus_updates: bool,
610
611 #[serde(skip_serializing_if = "is_false")]
612 #[skip_protocol_config_accessor]
613 end_of_epoch_transaction_supported: bool,
614
615 #[serde(skip_serializing_if = "is_false")]
618 simple_conservation_checks: bool,
619
620 #[serde(skip_serializing_if = "is_false")]
622 loaded_child_object_format_type: bool,
623
624 #[serde(skip_serializing_if = "is_false")]
626 receive_objects: bool,
627
628 #[serde(skip_serializing_if = "is_false")]
630 consensus_checkpoint_signature_key_includes_digest: bool,
631
632 #[serde(skip_serializing_if = "is_false")]
634 random_beacon: bool,
635
636 #[serde(skip_serializing_if = "is_false")]
638 #[skip_protocol_config_accessor]
639 bridge: bool,
640
641 #[serde(skip_serializing_if = "is_false")]
642 enable_effects_v2: bool,
643
644 #[serde(skip_serializing_if = "is_false")]
646 narwhal_certificate_v2: bool,
647
648 #[serde(skip_serializing_if = "is_false")]
650 verify_legacy_zklogin_address: bool,
651
652 #[serde(skip_serializing_if = "is_false")]
654 throughput_aware_consensus_submission: bool,
655
656 #[serde(skip_serializing_if = "is_false")]
658 recompute_has_public_transfer_in_execution: bool,
659
660 #[serde(skip_serializing_if = "is_false")]
662 accept_zklogin_in_multisig: bool,
663
664 #[serde(skip_serializing_if = "is_false")]
666 accept_passkey_in_multisig: bool,
667
668 #[serde(skip_serializing_if = "is_false")]
670 validate_zklogin_public_identifier: bool,
671
672 #[serde(skip_serializing_if = "is_false")]
675 include_consensus_digest_in_prologue: bool,
676
677 #[serde(skip_serializing_if = "is_false")]
679 hardened_otw_check: bool,
680
681 #[serde(skip_serializing_if = "is_false")]
683 allow_receiving_object_id: bool,
684
685 #[serde(skip_serializing_if = "is_false")]
687 enable_poseidon: bool,
688
689 #[serde(skip_serializing_if = "is_false")]
691 enable_coin_deny_list: bool,
692
693 #[serde(skip_serializing_if = "is_false")]
695 enable_group_ops_native_functions: bool,
696
697 #[serde(skip_serializing_if = "is_false")]
699 enable_group_ops_native_function_msm: bool,
700
701 #[serde(skip_serializing_if = "is_false")]
703 enable_ristretto255_group_ops: bool,
704
705 #[serde(skip_serializing_if = "is_false")]
707 enable_verify_bulletproofs_ristretto255: bool,
708
709 #[serde(skip_serializing_if = "is_false")]
711 enable_nitro_attestation: bool,
712
713 #[serde(skip_serializing_if = "is_false")]
715 enable_nitro_attestation_upgraded_parsing: bool,
716
717 #[serde(skip_serializing_if = "is_false")]
719 enable_nitro_attestation_all_nonzero_pcrs_parsing: bool,
720
721 #[serde(skip_serializing_if = "is_false")]
723 enable_nitro_attestation_always_include_required_pcrs_parsing: bool,
724
725 #[serde(skip_serializing_if = "is_false")]
727 reject_mutable_random_on_entry_functions: bool,
728
729 #[serde(skip_serializing_if = "PerObjectCongestionControlMode::is_none")]
731 per_object_congestion_control_mode: PerObjectCongestionControlMode,
732
733 #[serde(skip_serializing_if = "ConsensusChoice::is_narwhal")]
735 consensus_choice: ConsensusChoice,
736
737 #[serde(skip_serializing_if = "ConsensusNetwork::is_anemo")]
739 consensus_network: ConsensusNetwork,
740
741 #[serde(skip_serializing_if = "is_false")]
743 correct_gas_payment_limit_check: bool,
744
745 #[serde(skip_serializing_if = "Option::is_none")]
747 zklogin_max_epoch_upper_bound_delta: Option<u64>,
748
749 #[serde(skip_serializing_if = "is_false")]
751 mysticeti_leader_scoring_and_schedule: bool,
752
753 #[serde(skip_serializing_if = "is_false")]
755 reshare_at_same_initial_version: bool,
756
757 #[serde(skip_serializing_if = "is_false")]
759 resolve_abort_locations_to_package_id: bool,
760
761 #[serde(skip_serializing_if = "is_false")]
765 mysticeti_use_committed_subdag_digest: bool,
766
767 #[serde(skip_serializing_if = "is_false")]
769 enable_vdf: bool,
770
771 #[serde(skip_serializing_if = "is_false")]
775 record_consensus_determined_version_assignments_in_prologue: bool,
776 #[serde(skip_serializing_if = "is_false")]
779 record_consensus_determined_version_assignments_in_prologue_v2: bool,
780
781 #[serde(skip_serializing_if = "is_false")]
783 fresh_vm_on_framework_upgrade: bool,
784
785 #[serde(skip_serializing_if = "is_false")]
793 prepend_prologue_tx_in_consensus_commit_in_checkpoints: bool,
794
795 #[serde(skip_serializing_if = "Option::is_none")]
797 mysticeti_num_leaders_per_round: Option<usize>,
798
799 #[serde(skip_serializing_if = "is_false")]
801 soft_bundle: bool,
802
803 #[serde(skip_serializing_if = "is_false")]
805 enable_coin_deny_list_v2: bool,
806
807 #[serde(skip_serializing_if = "is_false")]
809 passkey_auth: bool,
810
811 #[serde(skip_serializing_if = "is_false")]
813 authority_capabilities_v2: bool,
814
815 #[serde(skip_serializing_if = "is_false")]
817 rethrow_serialization_type_layout_errors: bool,
818
819 #[serde(skip_serializing_if = "is_false")]
821 consensus_distributed_vote_scoring_strategy: bool,
822
823 #[serde(skip_serializing_if = "is_false")]
825 consensus_round_prober: bool,
826
827 #[serde(skip_serializing_if = "is_false")]
829 validate_identifier_inputs: bool,
830
831 #[serde(skip_serializing_if = "is_false")]
833 disallow_self_identifier: bool,
834
835 #[serde(skip_serializing_if = "is_false")]
837 mysticeti_fastpath: bool,
838
839 #[serde(skip_serializing_if = "is_false")]
843 disable_preconsensus_locking: bool,
844
845 #[serde(skip_serializing_if = "is_false")]
847 relocate_event_module: bool,
848
849 #[serde(skip_serializing_if = "is_false")]
851 uncompressed_g1_group_elements: bool,
852
853 #[serde(skip_serializing_if = "is_false")]
854 disallow_new_modules_in_deps_only_packages: bool,
855
856 #[serde(skip_serializing_if = "is_false")]
858 consensus_smart_ancestor_selection: bool,
859
860 #[serde(skip_serializing_if = "is_false")]
862 consensus_round_prober_probe_accepted_rounds: bool,
863
864 #[serde(skip_serializing_if = "is_false")]
866 native_charging_v2: bool,
867
868 #[serde(skip_serializing_if = "is_false")]
871 #[skip_protocol_config_accessor]
872 consensus_linearize_subdag_v2: bool,
873
874 #[serde(skip_serializing_if = "is_false")]
876 convert_type_argument_error: bool,
877
878 #[serde(skip_serializing_if = "is_false")]
880 variant_nodes: bool,
881
882 #[serde(skip_serializing_if = "is_false")]
884 consensus_zstd_compression: bool,
885
886 #[serde(skip_serializing_if = "is_false")]
888 minimize_child_object_mutations: bool,
889
890 #[serde(skip_serializing_if = "is_false")]
893 record_additional_state_digest_in_prologue: bool,
894
895 #[serde(skip_serializing_if = "is_false")]
897 move_native_context: bool,
898
899 #[serde(skip_serializing_if = "is_false")]
902 #[skip_protocol_config_accessor]
903 consensus_median_based_commit_timestamp: bool,
904
905 #[serde(skip_serializing_if = "is_false")]
908 normalize_ptb_arguments: bool,
909
910 #[serde(skip_serializing_if = "is_false")]
912 consensus_batched_block_sync: bool,
913
914 #[serde(skip_serializing_if = "is_false")]
916 enforce_checkpoint_timestamp_monotonicity: bool,
917
918 #[serde(skip_serializing_if = "is_false")]
920 max_ptb_value_size_v2: bool,
921
922 #[serde(skip_serializing_if = "is_false")]
924 resolve_type_input_ids_to_defining_id: bool,
925
926 #[serde(skip_serializing_if = "is_false")]
928 enable_party_transfer: bool,
929
930 #[serde(skip_serializing_if = "is_false")]
932 allow_unbounded_system_objects: bool,
933
934 #[serde(skip_serializing_if = "is_false")]
936 type_tags_in_object_runtime: bool,
937
938 #[serde(skip_serializing_if = "is_false")]
940 enable_accumulators: bool,
941
942 #[serde(skip_serializing_if = "is_false")]
944 #[skip_protocol_config_accessor]
945 enable_coin_reservation_obj_refs: bool,
946
947 #[serde(skip_serializing_if = "is_false")]
950 create_root_accumulator_object: bool,
951
952 #[serde(skip_serializing_if = "is_false")]
954 #[skip_protocol_config_accessor]
955 enable_authenticated_event_streams: bool,
956
957 #[serde(skip_serializing_if = "is_false")]
959 enable_address_balance_gas_payments: bool,
960
961 #[serde(skip_serializing_if = "is_false")]
963 address_balance_gas_check_rgp_at_signing: bool,
964
965 #[serde(skip_serializing_if = "is_false")]
966 address_balance_gas_reject_gas_coin_arg: bool,
967
968 #[serde(skip_serializing_if = "is_false")]
970 enable_multi_epoch_transaction_expiration: bool,
971
972 #[serde(skip_serializing_if = "is_false")]
974 relax_valid_during_for_owned_inputs: bool,
975
976 #[serde(skip_serializing_if = "is_false")]
978 enable_ptb_execution_v2: bool,
979
980 #[serde(skip_serializing_if = "is_false")]
982 better_adapter_type_resolution_errors: bool,
983
984 #[serde(skip_serializing_if = "is_false")]
986 record_time_estimate_processed: bool,
987
988 #[serde(skip_serializing_if = "is_false")]
990 dependency_linkage_error: bool,
991
992 #[serde(skip_serializing_if = "is_false")]
994 additional_multisig_checks: bool,
995
996 #[serde(skip_serializing_if = "is_false")]
998 ignore_execution_time_observations_after_certs_closed: bool,
999
1000 #[serde(skip_serializing_if = "is_false")]
1004 debug_fatal_on_move_invariant_violation: bool,
1005
1006 #[serde(skip_serializing_if = "is_false")]
1009 allow_private_accumulator_entrypoints: bool,
1010
1011 #[serde(skip_serializing_if = "is_false")]
1014 additional_consensus_digest_indirect_state: bool,
1015
1016 #[serde(skip_serializing_if = "is_false")]
1018 check_for_init_during_upgrade: bool,
1019
1020 #[serde(skip_serializing_if = "is_false")]
1022 enable_init_on_upgrade: bool,
1023
1024 #[serde(skip_serializing_if = "is_false")]
1026 enable_order_independent_upgrade_init_linkage: bool,
1027
1028 #[serde(skip_serializing_if = "is_false")]
1031 harden_linkage_consistency: bool,
1032
1033 #[serde(skip_serializing_if = "is_false")]
1035 per_command_shared_object_transfer_rules: bool,
1036
1037 #[serde(skip_serializing_if = "is_false")]
1039 validate_ptb_argument_indices: bool,
1040
1041 #[serde(skip_serializing_if = "is_false")]
1043 include_checkpoint_artifacts_digest_in_summary: bool,
1044
1045 #[serde(skip_serializing_if = "is_false")]
1047 use_mfp_txns_in_load_initial_object_debts: bool,
1048
1049 #[serde(skip_serializing_if = "is_false")]
1051 cancel_for_failed_dkg_early: bool,
1052
1053 #[serde(skip_serializing_if = "is_false")]
1055 always_advance_dkg_to_resolution: bool,
1056
1057 #[serde(skip_serializing_if = "is_false")]
1059 enable_coin_registry: bool,
1060
1061 #[serde(skip_serializing_if = "is_false")]
1063 abstract_size_in_object_runtime: bool,
1064
1065 #[serde(skip_serializing_if = "is_false")]
1067 object_runtime_charge_cache_load_gas: bool,
1068
1069 #[serde(skip_serializing_if = "is_false")]
1071 additional_borrow_checks: bool,
1072
1073 #[serde(skip_serializing_if = "is_false")]
1075 use_new_commit_handler: bool,
1076
1077 #[serde(skip_serializing_if = "is_false")]
1079 better_loader_errors: bool,
1080
1081 #[serde(skip_serializing_if = "is_false")]
1083 generate_df_type_layouts: bool,
1084
1085 #[serde(skip_serializing_if = "is_false")]
1087 allow_references_in_ptbs: bool,
1088
1089 #[serde(skip_serializing_if = "is_false")]
1096 framework_tx_context_mut_restrictions: bool,
1097
1098 #[serde(skip_serializing_if = "is_false")]
1100 include_function_signatures_in_instantiation_limits: bool,
1101
1102 #[serde(skip_serializing_if = "is_false")]
1107 ptb_tx_context_restrictions: bool,
1108
1109 #[serde(skip_serializing_if = "is_false")]
1111 enable_display_registry: bool,
1112
1113 #[serde(skip_serializing_if = "is_false")]
1115 private_generics_verifier_v2: bool,
1116
1117 #[serde(skip_serializing_if = "is_false")]
1119 deprecate_global_storage_ops_during_deserialization: bool,
1120
1121 #[serde(skip_serializing_if = "is_false")]
1124 enable_non_exclusive_writes: bool,
1125
1126 #[serde(skip_serializing_if = "is_false")]
1128 deprecate_global_storage_ops: bool,
1129
1130 #[serde(skip_serializing_if = "is_false")]
1132 normalize_depth_formula: bool,
1133
1134 #[serde(skip_serializing_if = "is_false")]
1137 charge_ld_const_abstract_size: bool,
1138
1139 #[serde(skip_serializing_if = "is_false")]
1141 consensus_skip_gced_accept_votes: bool,
1142
1143 #[serde(skip_serializing_if = "is_false")]
1146 include_cancelled_randomness_txns_in_prologue: bool,
1147
1148 #[serde(skip_serializing_if = "is_false")]
1150 #[skip_protocol_config_accessor]
1151 address_aliases: bool,
1152
1153 #[serde(skip_serializing_if = "is_false")]
1155 create_forwarding_address_registry: bool,
1156
1157 #[serde(skip_serializing_if = "is_false")]
1159 enable_forwarding_addresses: bool,
1160
1161 #[serde(skip_serializing_if = "is_false")]
1164 fix_checkpoint_signature_mapping: bool,
1165
1166 #[serde(skip_serializing_if = "is_false")]
1168 enable_object_funds_withdraw: bool,
1169
1170 #[serde(skip_serializing_if = "is_false")]
1173 record_net_unsettled_object_withdraws: bool,
1174
1175 #[serde(skip_serializing_if = "is_false")]
1177 consensus_skip_gced_blocks_in_direct_finalization: bool,
1178
1179 #[serde(skip_serializing_if = "is_false")]
1181 gas_rounding_halve_digits: bool,
1182
1183 #[serde(skip_serializing_if = "is_false")]
1185 flexible_tx_context_positions: bool,
1186
1187 #[serde(skip_serializing_if = "is_false")]
1189 disable_entry_point_signature_check: bool,
1190
1191 #[serde(skip_serializing_if = "is_false")]
1193 convert_withdrawal_compatibility_ptb_arguments: bool,
1194
1195 #[serde(skip_serializing_if = "is_false")]
1197 restrict_hot_or_not_entry_functions: bool,
1198
1199 #[serde(skip_serializing_if = "is_false")]
1201 split_checkpoints_in_consensus_handler: bool,
1202
1203 #[serde(skip_serializing_if = "is_false")]
1205 consensus_always_accept_system_transactions: bool,
1206
1207 #[serde(skip_serializing_if = "is_false")]
1209 validator_metadata_verify_v2: bool,
1210
1211 #[serde(skip_serializing_if = "is_false")]
1214 defer_unpaid_amplification: bool,
1215
1216 #[serde(skip_serializing_if = "is_false")]
1219 defer_owned_object_double_spend: bool,
1220
1221 #[serde(skip_serializing_if = "is_false")]
1224 allowed_proposers: bool,
1225
1226 #[serde(skip_serializing_if = "is_false")]
1227 randomize_checkpoint_tx_limit_in_tests: bool,
1228
1229 #[serde(skip_serializing_if = "is_false")]
1231 gasless_transaction_drop_safety: bool,
1232
1233 #[serde(skip_serializing_if = "is_false")]
1236 merge_randomness_into_checkpoint: bool,
1237
1238 #[serde(skip_serializing_if = "is_false")]
1240 use_coin_party_owner: bool,
1241
1242 #[serde(skip_serializing_if = "is_false")]
1243 enable_gasless: bool,
1244
1245 #[serde(skip_serializing_if = "is_false")]
1246 gasless_verify_remaining_balance: bool,
1247
1248 #[serde(skip_serializing_if = "is_false")]
1249 disallow_jump_orphans: bool,
1250
1251 #[serde(skip_serializing_if = "is_false")]
1253 early_return_receive_object_mismatched_type: bool,
1254
1255 #[serde(skip_serializing_if = "is_false")]
1260 timestamp_based_epoch_close: bool,
1261
1262 #[serde(skip_serializing_if = "is_false")]
1265 limit_groth16_pvk_inputs: bool,
1266
1267 #[serde(skip_serializing_if = "is_false")]
1272 enforce_address_balance_change_invariant: bool,
1273
1274 #[serde(skip_serializing_if = "is_false")]
1276 share_transaction_deny_config_in_consensus: bool,
1277
1278 #[serde(skip_serializing_if = "is_false")]
1280 granular_post_execution_checks: bool,
1281
1282 #[serde(skip_serializing_if = "is_false")]
1284 early_exit_on_iffw: bool,
1285
1286 #[serde(skip_serializing_if = "is_false")]
1288 enable_unified_linkage: bool,
1289
1290 #[serde(skip_serializing_if = "is_false")]
1293 #[skip_protocol_config_accessor]
1294 enable_allowances: bool,
1295
1296 #[serde(skip_serializing_if = "is_false")]
1298 fix_ptb_generated_reads: bool,
1299
1300 #[serde(skip_serializing_if = "is_false")]
1301 check_object_funds_withdraw_in_execution: bool,
1302 #[serde(skip_serializing_if = "is_false")]
1304 memory_safety_invariant_check_v2: bool,
1305
1306 #[serde(skip_serializing_if = "is_false")]
1308 disable_effects_tx_dependencies: bool,
1309
1310 #[serde(skip_serializing_if = "is_false")]
1314 merge_colliding_deferrals: bool,
1315}
1316
1317fn is_false(b: &bool) -> bool {
1318 !b
1319}
1320
1321fn is_empty(b: &BTreeSet<String>) -> bool {
1322 b.is_empty()
1323}
1324
1325fn is_zero(val: &u64) -> bool {
1326 *val == 0
1327}
1328
1329#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1331pub enum ConsensusTransactionOrdering {
1332 #[default]
1334 None,
1335 ByGasPrice,
1337}
1338
1339impl ConsensusTransactionOrdering {
1340 pub fn is_none(&self) -> bool {
1341 matches!(self, ConsensusTransactionOrdering::None)
1342 }
1343}
1344
1345#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1346pub struct ExecutionTimeEstimateParams {
1347 pub target_utilization: u64,
1349 pub allowed_txn_cost_overage_burst_limit_us: u64,
1353
1354 pub randomness_scalar: u64,
1357
1358 pub max_estimate_us: u64,
1360
1361 pub stored_observations_num_included_checkpoints: u64,
1364
1365 pub stored_observations_limit: u64,
1367
1368 #[serde(skip_serializing_if = "is_zero")]
1371 pub stake_weighted_median_threshold: u64,
1372
1373 #[serde(skip_serializing_if = "is_false")]
1377 pub default_none_duration_for_new_keys: bool,
1378
1379 #[serde(skip_serializing_if = "Option::is_none")]
1381 pub observations_chunk_size: Option<u64>,
1382}
1383
1384#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1386pub enum PerObjectCongestionControlMode {
1387 #[default]
1388 None, TotalGasBudget, TotalTxCount, TotalGasBudgetWithCap, ExecutionTimeEstimate(ExecutionTimeEstimateParams), }
1394
1395impl PerObjectCongestionControlMode {
1396 pub fn is_none(&self) -> bool {
1397 matches!(self, PerObjectCongestionControlMode::None)
1398 }
1399}
1400
1401#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1403pub enum ConsensusChoice {
1404 #[default]
1405 Narwhal,
1406 SwapEachEpoch,
1407 Mysticeti,
1408}
1409
1410impl ConsensusChoice {
1411 pub fn is_narwhal(&self) -> bool {
1412 matches!(self, ConsensusChoice::Narwhal)
1413 }
1414}
1415
1416#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1418pub enum ConsensusNetwork {
1419 #[default]
1420 Anemo,
1421 Tonic,
1422}
1423
1424impl ConsensusNetwork {
1425 pub fn is_anemo(&self) -> bool {
1426 matches!(self, ConsensusNetwork::Anemo)
1427 }
1428}
1429
1430#[skip_serializing_none]
1462#[derive(Clone, Serialize, Debug, ProtocolConfigAccessors, ProtocolConfigOverride)]
1463pub struct ProtocolConfig {
1464 pub version: ProtocolVersion,
1465
1466 #[serde(skip)]
1471 chain: Chain,
1472
1473 feature_flags: FeatureFlags,
1474
1475 max_tx_size_bytes: Option<u64>,
1478
1479 max_input_objects: Option<u64>,
1481
1482 max_size_written_objects: Option<u64>,
1486 max_size_written_objects_system_tx: Option<u64>,
1489
1490 max_serialized_tx_effects_size_bytes: Option<u64>,
1492
1493 max_serialized_tx_effects_size_bytes_system_tx: Option<u64>,
1495
1496 max_gas_payment_objects: Option<u32>,
1498
1499 max_modules_in_publish: Option<u32>,
1501
1502 max_package_dependencies: Option<u32>,
1504
1505 max_arguments: Option<u32>,
1508
1509 max_type_arguments: Option<u32>,
1511
1512 max_type_argument_depth: Option<u32>,
1514
1515 max_pure_argument_size: Option<u32>,
1517
1518 max_programmable_tx_commands: Option<u32>,
1520
1521 move_binary_format_version: Option<u32>,
1524 min_move_binary_format_version: Option<u32>,
1525
1526 binary_module_handles: Option<u16>,
1528 binary_struct_handles: Option<u16>,
1529 binary_function_handles: Option<u16>,
1530 binary_function_instantiations: Option<u16>,
1531 binary_signatures: Option<u16>,
1532 binary_constant_pool: Option<u16>,
1533 binary_identifiers: Option<u16>,
1534 binary_address_identifiers: Option<u16>,
1535 binary_struct_defs: Option<u16>,
1536 binary_struct_def_instantiations: Option<u16>,
1537 binary_function_defs: Option<u16>,
1538 binary_field_handles: Option<u16>,
1539 binary_field_instantiations: Option<u16>,
1540 binary_friend_decls: Option<u16>,
1541 binary_enum_defs: Option<u16>,
1542 binary_enum_def_instantiations: Option<u16>,
1543 binary_variant_handles: Option<u16>,
1544 binary_variant_instantiation_handles: Option<u16>,
1545
1546 max_move_object_size: Option<u64>,
1548
1549 max_move_package_size: Option<u64>,
1552
1553 max_publish_or_upgrade_per_ptb: Option<u64>,
1555
1556 max_tx_gas: Option<u64>,
1558
1559 max_gas_price: Option<u64>,
1561
1562 max_gas_price_rgp_factor_for_aborted_transactions: Option<u64>,
1565
1566 max_gas_computation_bucket: Option<u64>,
1568
1569 gas_rounding_step: Option<u64>,
1571
1572 max_loop_depth: Option<u64>,
1574
1575 max_generic_instantiation_length: Option<u64>,
1577
1578 max_function_parameters: Option<u64>,
1580
1581 max_basic_blocks: Option<u64>,
1583
1584 max_value_stack_size: Option<u64>,
1586
1587 max_type_nodes: Option<u64>,
1589
1590 max_generic_instantiation_type_nodes_per_function: Option<u64>,
1592
1593 max_generic_instantiation_type_nodes_per_module: Option<u64>,
1595
1596 max_accumulator_type_nodes: Option<u64>,
1598
1599 max_push_size: Option<u64>,
1601
1602 max_struct_definitions: Option<u64>,
1604
1605 max_function_definitions: Option<u64>,
1607
1608 max_fields_in_struct: Option<u64>,
1610
1611 max_dependency_depth: Option<u64>,
1613
1614 max_num_event_emit: Option<u64>,
1616
1617 max_num_new_move_object_ids: Option<u64>,
1619
1620 max_num_new_move_object_ids_system_tx: Option<u64>,
1622
1623 max_num_deleted_move_object_ids: Option<u64>,
1625
1626 max_num_deleted_move_object_ids_system_tx: Option<u64>,
1628
1629 max_num_transferred_move_object_ids: Option<u64>,
1631
1632 max_num_transferred_move_object_ids_system_tx: Option<u64>,
1634
1635 max_event_emit_size: Option<u64>,
1637
1638 max_event_emit_size_total: Option<u64>,
1640
1641 max_move_vector_len: Option<u64>,
1643
1644 max_move_identifier_len: Option<u64>,
1646
1647 max_move_value_depth: Option<u64>,
1649
1650 package_arena_size_in_bytes: Option<u64>,
1653
1654 max_move_enum_variants: Option<u64>,
1656
1657 max_back_edges_per_function: Option<u64>,
1659
1660 max_back_edges_per_module: Option<u64>,
1662
1663 max_verifier_meter_ticks_per_function: Option<u64>,
1665
1666 max_meter_ticks_per_module: Option<u64>,
1668
1669 max_meter_ticks_per_package: Option<u64>,
1671
1672 object_runtime_max_num_cached_objects: Option<u64>,
1676
1677 object_runtime_max_num_cached_objects_system_tx: Option<u64>,
1679
1680 object_runtime_max_num_store_entries: Option<u64>,
1682
1683 object_runtime_max_num_store_entries_system_tx: Option<u64>,
1685
1686 base_tx_cost_fixed: Option<u64>,
1689
1690 package_publish_cost_fixed: Option<u64>,
1693
1694 base_tx_cost_per_byte: Option<u64>,
1697
1698 package_publish_cost_per_byte: Option<u64>,
1700
1701 obj_access_cost_read_per_byte: Option<u64>,
1703
1704 obj_access_cost_mutate_per_byte: Option<u64>,
1706
1707 obj_access_cost_delete_per_byte: Option<u64>,
1709
1710 obj_access_cost_verify_per_byte: Option<u64>,
1720
1721 max_type_to_layout_nodes: Option<u64>,
1723
1724 max_ptb_value_size: Option<u64>,
1726
1727 gas_model_version: Option<u64>,
1730
1731 obj_data_cost_refundable: Option<u64>,
1734
1735 obj_metadata_cost_non_refundable: Option<u64>,
1739
1740 storage_rebate_rate: Option<u64>,
1746
1747 storage_fund_reinvest_rate: Option<u64>,
1750
1751 reward_slashing_rate: Option<u64>,
1754
1755 storage_gas_price: Option<u64>,
1757
1758 accumulator_object_storage_cost: Option<u64>,
1760
1761 max_transactions_per_checkpoint: Option<u64>,
1766
1767 max_checkpoint_size_bytes: Option<u64>,
1771
1772 buffer_stake_for_protocol_upgrade_bps: Option<u64>,
1777
1778 address_from_bytes_cost_base: Option<u64>,
1783 address_to_u256_cost_base: Option<u64>,
1785 address_from_u256_cost_base: Option<u64>,
1787
1788 config_read_setting_impl_cost_base: Option<u64>,
1793 config_read_setting_impl_cost_per_byte: Option<u64>,
1794
1795 package_original_package_id_impl_cost_base: Option<u64>,
1796 package_original_package_id_impl_cost_per_byte: Option<u64>,
1797
1798 dynamic_field_hash_type_and_key_cost_base: Option<u64>,
1801 dynamic_field_hash_type_and_key_type_cost_per_byte: Option<u64>,
1802 dynamic_field_hash_type_and_key_value_cost_per_byte: Option<u64>,
1803 dynamic_field_hash_type_and_key_type_tag_cost_per_byte: Option<u64>,
1804 dynamic_field_add_child_object_cost_base: Option<u64>,
1806 dynamic_field_add_child_object_type_cost_per_byte: Option<u64>,
1807 dynamic_field_add_child_object_value_cost_per_byte: Option<u64>,
1808 dynamic_field_add_child_object_struct_tag_cost_per_byte: Option<u64>,
1809 dynamic_field_borrow_child_object_cost_base: Option<u64>,
1811 dynamic_field_borrow_child_object_child_ref_cost_per_byte: Option<u64>,
1812 dynamic_field_borrow_child_object_type_cost_per_byte: Option<u64>,
1813 dynamic_field_remove_child_object_cost_base: Option<u64>,
1815 dynamic_field_remove_child_object_child_cost_per_byte: Option<u64>,
1816 dynamic_field_remove_child_object_type_cost_per_byte: Option<u64>,
1817 dynamic_field_has_child_object_cost_base: Option<u64>,
1819 dynamic_field_has_child_object_with_ty_cost_base: Option<u64>,
1821 dynamic_field_has_child_object_with_ty_type_cost_per_byte: Option<u64>,
1822 dynamic_field_has_child_object_with_ty_type_tag_cost_per_byte: Option<u64>,
1823
1824 scratch_add_cost_base: Option<u64>,
1827 scratch_read_cost_base: Option<u64>,
1829 scratch_read_value_cost: Option<u64>,
1830 scratch_remove_cost_base: Option<u64>,
1832 scratch_exists_cost_base: Option<u64>,
1834 scratch_exists_with_type_cost_base: Option<u64>,
1836 scratch_exists_with_type_type_cost: Option<u64>,
1837 max_scratch_pad_size: Option<u64>,
1839
1840 event_emit_cost_base: Option<u64>,
1843 event_emit_value_size_derivation_cost_per_byte: Option<u64>,
1844 event_emit_tag_size_derivation_cost_per_byte: Option<u64>,
1845 event_emit_output_cost_per_byte: Option<u64>,
1846 event_emit_auth_stream_cost: Option<u64>,
1847
1848 reserve_object_funds_for_withdrawal_cost_base: Option<u64>,
1851 reserve_object_funds_for_withdrawal_cold_read_cost: Option<u64>,
1853
1854 object_borrow_uid_cost_base: Option<u64>,
1857 object_delete_impl_cost_base: Option<u64>,
1859 object_record_new_uid_cost_base: Option<u64>,
1861 object_record_new_uid_from_hash_cost_base: Option<u64>,
1864
1865 transfer_transfer_internal_cost_base: Option<u64>,
1868 transfer_party_transfer_internal_cost_base: Option<u64>,
1870 transfer_freeze_object_cost_base: Option<u64>,
1872 transfer_share_object_cost_base: Option<u64>,
1874 transfer_receive_object_cost_base: Option<u64>,
1877 transfer_receive_object_cost_per_byte: Option<u64>,
1878 transfer_receive_object_type_cost_per_byte: Option<u64>,
1879
1880 tx_context_derive_id_cost_base: Option<u64>,
1883 tx_context_fresh_id_cost_base: Option<u64>,
1884 tx_context_sender_cost_base: Option<u64>,
1885 tx_context_epoch_cost_base: Option<u64>,
1886 tx_context_epoch_timestamp_ms_cost_base: Option<u64>,
1887 tx_context_sponsor_cost_base: Option<u64>,
1888 tx_context_rgp_cost_base: Option<u64>,
1889 tx_context_gas_price_cost_base: Option<u64>,
1890 tx_context_gas_budget_cost_base: Option<u64>,
1891 tx_context_ids_created_cost_base: Option<u64>,
1892 tx_context_replace_cost_base: Option<u64>,
1893
1894 types_is_one_time_witness_cost_base: Option<u64>,
1897 types_is_one_time_witness_type_tag_cost_per_byte: Option<u64>,
1898 types_is_one_time_witness_type_cost_per_byte: Option<u64>,
1899
1900 validator_validate_metadata_cost_base: Option<u64>,
1903 validator_validate_metadata_data_cost_per_byte: Option<u64>,
1904
1905 crypto_invalid_arguments_cost: Option<u64>,
1907 bls12381_bls12381_min_sig_verify_cost_base: Option<u64>,
1909 bls12381_bls12381_min_sig_verify_msg_cost_per_byte: Option<u64>,
1910 bls12381_bls12381_min_sig_verify_msg_cost_per_block: Option<u64>,
1911
1912 bls12381_bls12381_min_pk_verify_cost_base: Option<u64>,
1914 bls12381_bls12381_min_pk_verify_msg_cost_per_byte: Option<u64>,
1915 bls12381_bls12381_min_pk_verify_msg_cost_per_block: Option<u64>,
1916
1917 ecdsa_k1_ecrecover_keccak256_cost_base: Option<u64>,
1919 ecdsa_k1_ecrecover_keccak256_msg_cost_per_byte: Option<u64>,
1920 ecdsa_k1_ecrecover_keccak256_msg_cost_per_block: Option<u64>,
1921 ecdsa_k1_ecrecover_sha256_cost_base: Option<u64>,
1922 ecdsa_k1_ecrecover_sha256_msg_cost_per_byte: Option<u64>,
1923 ecdsa_k1_ecrecover_sha256_msg_cost_per_block: Option<u64>,
1924
1925 ecdsa_k1_decompress_pubkey_cost_base: Option<u64>,
1927
1928 ecdsa_k1_secp256k1_verify_keccak256_cost_base: Option<u64>,
1930 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_byte: Option<u64>,
1931 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_block: Option<u64>,
1932 ecdsa_k1_secp256k1_verify_sha256_cost_base: Option<u64>,
1933 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_byte: Option<u64>,
1934 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_block: Option<u64>,
1935
1936 ecdsa_r1_ecrecover_keccak256_cost_base: Option<u64>,
1938 ecdsa_r1_ecrecover_keccak256_msg_cost_per_byte: Option<u64>,
1939 ecdsa_r1_ecrecover_keccak256_msg_cost_per_block: Option<u64>,
1940 ecdsa_r1_ecrecover_sha256_cost_base: Option<u64>,
1941 ecdsa_r1_ecrecover_sha256_msg_cost_per_byte: Option<u64>,
1942 ecdsa_r1_ecrecover_sha256_msg_cost_per_block: Option<u64>,
1943
1944 ecdsa_r1_secp256r1_verify_keccak256_cost_base: Option<u64>,
1946 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_byte: Option<u64>,
1947 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_block: Option<u64>,
1948 ecdsa_r1_secp256r1_verify_sha256_cost_base: Option<u64>,
1949 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_byte: Option<u64>,
1950 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_block: Option<u64>,
1951
1952 ecvrf_ecvrf_verify_cost_base: Option<u64>,
1954 ecvrf_ecvrf_verify_alpha_string_cost_per_byte: Option<u64>,
1955 ecvrf_ecvrf_verify_alpha_string_cost_per_block: Option<u64>,
1956
1957 ed25519_ed25519_verify_cost_base: Option<u64>,
1959 ed25519_ed25519_verify_msg_cost_per_byte: Option<u64>,
1960 ed25519_ed25519_verify_msg_cost_per_block: Option<u64>,
1961
1962 groth16_prepare_verifying_key_bls12381_cost_base: Option<u64>,
1964 groth16_prepare_verifying_key_bn254_cost_base: Option<u64>,
1965
1966 groth16_verify_groth16_proof_internal_bls12381_cost_base: Option<u64>,
1968 groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input: Option<u64>,
1969 groth16_verify_groth16_proof_internal_bn254_cost_base: Option<u64>,
1970 groth16_verify_groth16_proof_internal_bn254_cost_per_public_input: Option<u64>,
1971 groth16_verify_groth16_proof_internal_public_input_cost_per_byte: Option<u64>,
1972
1973 hash_blake2b256_cost_base: Option<u64>,
1975 hash_blake2b256_data_cost_per_byte: Option<u64>,
1976 hash_blake2b256_data_cost_per_block: Option<u64>,
1977
1978 hash_keccak256_cost_base: Option<u64>,
1980 hash_keccak256_data_cost_per_byte: Option<u64>,
1981 hash_keccak256_data_cost_per_block: Option<u64>,
1982
1983 poseidon_bn254_cost_base: Option<u64>,
1985 poseidon_bn254_cost_per_block: Option<u64>,
1986
1987 group_ops_bls12381_decode_scalar_cost: Option<u64>,
1989 group_ops_bls12381_decode_g1_cost: Option<u64>,
1990 group_ops_bls12381_decode_g2_cost: Option<u64>,
1991 group_ops_bls12381_decode_gt_cost: Option<u64>,
1992 group_ops_bls12381_scalar_add_cost: Option<u64>,
1993 group_ops_bls12381_g1_add_cost: Option<u64>,
1994 group_ops_bls12381_g2_add_cost: Option<u64>,
1995 group_ops_bls12381_gt_add_cost: Option<u64>,
1996 group_ops_bls12381_scalar_sub_cost: Option<u64>,
1997 group_ops_bls12381_g1_sub_cost: Option<u64>,
1998 group_ops_bls12381_g2_sub_cost: Option<u64>,
1999 group_ops_bls12381_gt_sub_cost: Option<u64>,
2000 group_ops_bls12381_scalar_mul_cost: Option<u64>,
2001 group_ops_bls12381_g1_mul_cost: Option<u64>,
2002 group_ops_bls12381_g2_mul_cost: Option<u64>,
2003 group_ops_bls12381_gt_mul_cost: Option<u64>,
2004 group_ops_bls12381_scalar_div_cost: Option<u64>,
2005 group_ops_bls12381_g1_div_cost: Option<u64>,
2006 group_ops_bls12381_g2_div_cost: Option<u64>,
2007 group_ops_bls12381_gt_div_cost: Option<u64>,
2008 group_ops_bls12381_g1_hash_to_base_cost: Option<u64>,
2009 group_ops_bls12381_g2_hash_to_base_cost: Option<u64>,
2010 group_ops_bls12381_g1_hash_to_cost_per_byte: Option<u64>,
2011 group_ops_bls12381_g2_hash_to_cost_per_byte: Option<u64>,
2012 group_ops_bls12381_g1_msm_base_cost: Option<u64>,
2013 group_ops_bls12381_g2_msm_base_cost: Option<u64>,
2014 group_ops_bls12381_g1_msm_base_cost_per_input: Option<u64>,
2015 group_ops_bls12381_g2_msm_base_cost_per_input: Option<u64>,
2016 group_ops_bls12381_msm_max_len: Option<u32>,
2017 group_ops_bls12381_pairing_cost: Option<u64>,
2018 group_ops_bls12381_g1_to_uncompressed_g1_cost: Option<u64>,
2019 group_ops_bls12381_uncompressed_g1_to_g1_cost: Option<u64>,
2020 group_ops_bls12381_uncompressed_g1_sum_base_cost: Option<u64>,
2021 group_ops_bls12381_uncompressed_g1_sum_cost_per_term: Option<u64>,
2022 group_ops_bls12381_uncompressed_g1_sum_max_terms: Option<u64>,
2023
2024 group_ops_ristretto_decode_scalar_cost: Option<u64>,
2025 group_ops_ristretto_decode_point_cost: Option<u64>,
2026 group_ops_ristretto_scalar_add_cost: Option<u64>,
2027 group_ops_ristretto_point_add_cost: Option<u64>,
2028 group_ops_ristretto_scalar_sub_cost: Option<u64>,
2029 group_ops_ristretto_point_sub_cost: Option<u64>,
2030 group_ops_ristretto_scalar_mul_cost: Option<u64>,
2031 group_ops_ristretto_point_mul_cost: Option<u64>,
2032 group_ops_ristretto_scalar_div_cost: Option<u64>,
2033 group_ops_ristretto_point_div_cost: Option<u64>,
2034
2035 verify_bulletproofs_ristretto255_base_cost: Option<u64>,
2036 verify_bulletproofs_ristretto255_cost_per_bit_and_commitment: Option<u64>,
2037 max_bulletproofs_total_bits: Option<u64>,
2040
2041 hmac_hmac_sha3_256_cost_base: Option<u64>,
2043 hmac_hmac_sha3_256_input_cost_per_byte: Option<u64>,
2044 hmac_hmac_sha3_256_input_cost_per_block: Option<u64>,
2045
2046 check_zklogin_id_cost_base: Option<u64>,
2048 check_zklogin_issuer_cost_base: Option<u64>,
2050
2051 vdf_verify_vdf_cost: Option<u64>,
2052 vdf_hash_to_input_cost: Option<u64>,
2053
2054 nitro_attestation_parse_base_cost: Option<u64>,
2056 nitro_attestation_parse_cost_per_byte: Option<u64>,
2057 nitro_attestation_verify_base_cost: Option<u64>,
2058 nitro_attestation_verify_cost_per_cert: Option<u64>,
2059
2060 bcs_per_byte_serialized_cost: Option<u64>,
2062 bcs_legacy_min_output_size_cost: Option<u64>,
2063 bcs_failure_cost: Option<u64>,
2064
2065 hash_sha2_256_base_cost: Option<u64>,
2066 hash_sha2_256_per_byte_cost: Option<u64>,
2067 hash_sha2_256_legacy_min_input_len_cost: Option<u64>,
2068 hash_sha3_256_base_cost: Option<u64>,
2069 hash_sha3_256_per_byte_cost: Option<u64>,
2070 hash_sha3_256_legacy_min_input_len_cost: Option<u64>,
2071 type_name_get_base_cost: Option<u64>,
2072 type_name_get_per_byte_cost: Option<u64>,
2073 type_name_id_base_cost: Option<u64>,
2074
2075 string_check_utf8_base_cost: Option<u64>,
2076 string_check_utf8_per_byte_cost: Option<u64>,
2077 string_is_char_boundary_base_cost: Option<u64>,
2078 string_sub_string_base_cost: Option<u64>,
2079 string_sub_string_per_byte_cost: Option<u64>,
2080 string_index_of_base_cost: Option<u64>,
2081 string_index_of_per_byte_pattern_cost: Option<u64>,
2082 string_index_of_per_byte_searched_cost: Option<u64>,
2083
2084 vector_empty_base_cost: Option<u64>,
2085 vector_length_base_cost: Option<u64>,
2086 vector_push_back_base_cost: Option<u64>,
2087 vector_push_back_legacy_per_abstract_memory_unit_cost: Option<u64>,
2088 vector_borrow_base_cost: Option<u64>,
2089 vector_pop_back_base_cost: Option<u64>,
2090 vector_destroy_empty_base_cost: Option<u64>,
2091 vector_swap_base_cost: Option<u64>,
2092 debug_print_base_cost: Option<u64>,
2093 debug_print_stack_trace_base_cost: Option<u64>,
2094
2095 #[custom_setter]
2105 execution_version: Option<u64>,
2106
2107 consensus_bad_nodes_stake_threshold: Option<u64>,
2111
2112 max_jwk_votes_per_validator_per_epoch: Option<u64>,
2113 max_age_of_jwk_in_epochs: Option<u64>,
2117
2118 random_beacon_reduction_allowed_delta: Option<u16>,
2122
2123 random_beacon_reduction_lower_bound: Option<u32>,
2126
2127 random_beacon_dkg_timeout_round: Option<u32>,
2130
2131 random_beacon_min_round_interval_ms: Option<u64>,
2133
2134 random_beacon_dkg_version: Option<u64>,
2137
2138 consensus_max_transaction_size_bytes: Option<u64>,
2141 consensus_max_transactions_in_block_bytes: Option<u64>,
2143 consensus_max_num_transactions_in_block: Option<u64>,
2145
2146 consensus_voting_rounds: Option<u32>,
2148
2149 max_accumulated_txn_cost_per_object_in_narwhal_commit: Option<u64>,
2151
2152 max_deferral_rounds_for_congestion_control: Option<u64>,
2155
2156 epoch_close_deadline_ms: Option<u64>,
2161
2162 max_txn_cost_overage_per_object_in_commit: Option<u64>,
2164
2165 allowed_txn_cost_overage_burst_per_object_in_commit: Option<u64>,
2167
2168 min_checkpoint_interval_ms: Option<u64>,
2170
2171 checkpoint_summary_version_specific_data: Option<u64>,
2173
2174 max_soft_bundle_size: Option<u64>,
2176
2177 bridge_should_try_to_finalize_committee: Option<bool>,
2181
2182 max_accumulated_txn_cost_per_object_in_mysticeti_commit: Option<u64>,
2188
2189 max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit: Option<u64>,
2192
2193 consensus_gc_depth: Option<u32>,
2196
2197 gas_budget_based_txn_cost_cap_factor: Option<u64>,
2199
2200 gas_budget_based_txn_cost_absolute_cap_commit_count: Option<u64>,
2202
2203 sip_45_consensus_amplification_threshold: Option<u64>,
2206
2207 use_object_per_epoch_marker_table_v2: Option<bool>,
2210
2211 consensus_commit_rate_estimation_window_size: Option<u32>,
2213
2214 #[serde(skip_serializing_if = "Vec::is_empty")]
2218 aliased_addresses: Vec<AliasedAddress>,
2219
2220 translation_per_command_base_charge: Option<u64>,
2223
2224 translation_per_input_base_charge: Option<u64>,
2227
2228 translation_pure_input_per_byte_charge: Option<u64>,
2230
2231 translation_per_type_node_charge: Option<u64>,
2235
2236 translation_per_reference_node_charge: Option<u64>,
2239
2240 translation_per_linkage_entry_charge: Option<u64>,
2243
2244 max_updates_per_settlement_txn: Option<u32>,
2246
2247 gasless_max_computation_units: Option<u64>,
2249
2250 gasless_allowed_token_types: Option<Vec<(String, u64)>>,
2252
2253 gasless_max_unused_inputs: Option<u64>,
2257
2258 gasless_max_pure_input_bytes: Option<u64>,
2261
2262 gasless_max_tps: Option<u64>,
2264
2265 #[serde(skip_serializing_if = "Option::is_none")]
2266 #[skip_accessor]
2267 include_special_package_amendments: Option<Arc<Amendments>>,
2268
2269 gasless_max_tx_size_bytes: Option<u64>,
2272
2273 translation_per_live_reference_charge: Option<u64>,
2276
2277 max_ptb_live_references: Option<u64>,
2280
2281 max_ptb_returned_references: Option<u64>,
2284
2285 max_ptb_total_returned_references: Option<u64>,
2288}
2289
2290#[derive(Clone, Serialize, Deserialize, Debug)]
2292pub struct AliasedAddress {
2293 pub original: [u8; 32],
2295 pub aliased: [u8; 32],
2297 pub allowed_tx_digests: Vec<[u8; 32]>,
2299}
2300
2301impl ProtocolConfig {
2303 pub fn chain(&self) -> Chain {
2305 self.chain
2306 }
2307
2308 pub fn check_package_upgrades_supported(&self) -> Result<(), Error> {
2321 if self.feature_flags.package_upgrades {
2322 Ok(())
2323 } else {
2324 Err(Error(format!(
2325 "package upgrades are not supported at {:?}",
2326 self.version
2327 )))
2328 }
2329 }
2330
2331 pub fn zklogin_supported_providers(&self) -> &BTreeSet<String> {
2332 &self.feature_flags.zklogin_supported_providers
2333 }
2334
2335 pub fn zklogin_circuit_mode(&self) -> u64 {
2338 self.feature_flags.zklogin_circuit_mode
2339 }
2340
2341 pub fn consensus_transaction_ordering(&self) -> ConsensusTransactionOrdering {
2342 self.feature_flags.consensus_transaction_ordering
2343 }
2344
2345 pub fn enable_jwk_consensus_updates(&self) -> bool {
2346 let ret = self.feature_flags.enable_jwk_consensus_updates;
2347 if ret {
2348 assert!(self.feature_flags.end_of_epoch_transaction_supported);
2350 }
2351 ret
2352 }
2353
2354 pub fn end_of_epoch_transaction_supported(&self) -> bool {
2355 let ret = self.feature_flags.end_of_epoch_transaction_supported;
2356 if !ret {
2357 assert!(!self.feature_flags.enable_jwk_consensus_updates);
2359 }
2360 ret
2361 }
2362
2363 pub fn dkg_version(&self) -> u64 {
2364 self.random_beacon_dkg_version.unwrap_or(1)
2366 }
2367
2368 pub fn bridge(&self) -> bool {
2369 let ret = self.feature_flags.bridge;
2370 if ret {
2371 assert!(self.feature_flags.end_of_epoch_transaction_supported);
2373 }
2374 ret
2375 }
2376
2377 pub fn should_try_to_finalize_bridge_committee(&self) -> bool {
2378 if !self.bridge() {
2379 return false;
2380 }
2381 self.bridge_should_try_to_finalize_committee.unwrap_or(true)
2383 }
2384
2385 pub fn zklogin_max_epoch_upper_bound_delta(&self) -> Option<u64> {
2386 self.feature_flags.zklogin_max_epoch_upper_bound_delta
2387 }
2388
2389 pub fn enable_allowances(&self) -> bool {
2390 self.feature_flags.enable_allowances && self.enable_accumulators()
2391 }
2392
2393 pub fn enable_coin_reservation_obj_refs(&self) -> bool {
2394 self.new_vm_enabled() && self.feature_flags.enable_coin_reservation_obj_refs
2395 }
2396
2397 pub fn enable_authenticated_event_streams(&self) -> bool {
2398 self.feature_flags.enable_authenticated_event_streams && self.enable_accumulators()
2399 }
2400
2401 pub fn per_object_congestion_control_mode(&self) -> PerObjectCongestionControlMode {
2402 self.feature_flags.per_object_congestion_control_mode
2403 }
2404
2405 pub fn consensus_choice(&self) -> ConsensusChoice {
2406 self.feature_flags.consensus_choice
2407 }
2408
2409 pub fn consensus_network(&self) -> ConsensusNetwork {
2410 self.feature_flags.consensus_network
2411 }
2412
2413 pub fn mysticeti_num_leaders_per_round(&self) -> Option<usize> {
2414 self.feature_flags.mysticeti_num_leaders_per_round
2415 }
2416
2417 pub fn max_transaction_size_bytes(&self) -> u64 {
2418 self.consensus_max_transaction_size_bytes
2420 .unwrap_or(256 * 1024)
2421 }
2422
2423 pub fn max_transactions_in_block_bytes(&self) -> u64 {
2424 if cfg!(msim) {
2425 256 * 1024
2426 } else {
2427 self.consensus_max_transactions_in_block_bytes
2428 .unwrap_or(512 * 1024)
2429 }
2430 }
2431
2432 pub fn max_num_transactions_in_block(&self) -> u64 {
2433 if cfg!(msim) {
2434 8
2435 } else {
2436 self.consensus_max_num_transactions_in_block.unwrap_or(512)
2437 }
2438 }
2439
2440 pub fn gc_depth(&self) -> u32 {
2441 self.consensus_gc_depth.unwrap_or(0)
2442 }
2443
2444 pub fn consensus_linearize_subdag_v2(&self) -> bool {
2445 let res = self.feature_flags.consensus_linearize_subdag_v2;
2446 assert!(
2447 !res || self.gc_depth() > 0,
2448 "The consensus linearize sub dag V2 requires GC to be enabled"
2449 );
2450 res
2451 }
2452
2453 pub fn consensus_median_based_commit_timestamp(&self) -> bool {
2454 let res = self.feature_flags.consensus_median_based_commit_timestamp;
2455 assert!(
2456 !res || self.gc_depth() > 0,
2457 "The consensus median based commit timestamp requires GC to be enabled"
2458 );
2459 res
2460 }
2461
2462 pub fn get_consensus_commit_rate_estimation_window_size(&self) -> u32 {
2463 self.consensus_commit_rate_estimation_window_size
2464 .unwrap_or(0)
2465 }
2466
2467 pub fn consensus_num_requested_prior_commits_at_startup(&self) -> u32 {
2468 let window_size = self.get_consensus_commit_rate_estimation_window_size();
2472 assert!(window_size == 0 || self.record_additional_state_digest_in_prologue());
2474 window_size
2475 }
2476
2477 pub fn address_aliases(&self) -> bool {
2478 let address_aliases = self.feature_flags.address_aliases;
2479 assert!(
2480 !address_aliases || self.mysticeti_fastpath(),
2481 "Address aliases requires Mysticeti fastpath to be enabled"
2482 );
2483 if address_aliases {
2484 assert!(
2485 self.feature_flags.disable_preconsensus_locking,
2486 "Address aliases requires CertifiedTransaction to be disabled"
2487 );
2488 }
2489 address_aliases
2490 }
2491
2492 pub fn new_vm_enabled(&self) -> bool {
2493 self.execution_version.is_some_and(|v| v >= 4)
2494 }
2495
2496 pub fn gasless_allowed_token_types(&self) -> &[(String, u64)] {
2497 debug_assert!(self.gasless_allowed_token_types.is_some());
2498 self.gasless_allowed_token_types.as_deref().unwrap_or(&[])
2499 }
2500
2501 pub fn get_gasless_max_unused_inputs(&self) -> u64 {
2502 self.gasless_max_unused_inputs.unwrap_or(u64::MAX)
2503 }
2504
2505 pub fn get_gasless_max_pure_input_bytes(&self) -> u64 {
2506 self.gasless_max_pure_input_bytes.unwrap_or(u64::MAX)
2507 }
2508
2509 pub fn get_gasless_max_tx_size_bytes(&self) -> u64 {
2510 self.gasless_max_tx_size_bytes.unwrap_or(u64::MAX)
2511 }
2512
2513 pub fn include_special_package_amendments_as_option(&self) -> &Option<Arc<Amendments>> {
2514 &self.include_special_package_amendments
2515 }
2516}
2517
2518static POISON_VERSION_METHODS: AtomicBool = AtomicBool::new(false);
2519
2520impl ProtocolConfig {
2522 pub fn get_for_version(version: ProtocolVersion, chain: Chain) -> Self {
2524 assert!(
2526 version >= ProtocolVersion::MIN,
2527 "Network protocol version is {:?}, but the minimum supported version by the binary is {:?}. Please upgrade the binary.",
2528 version,
2529 ProtocolVersion::MIN.0,
2530 );
2531 assert!(
2532 version <= ProtocolVersion::MAX_ALLOWED,
2533 "Network protocol version is {:?}, but the maximum supported version by the binary is {:?}. Please upgrade the binary.",
2534 version,
2535 ProtocolVersion::MAX_ALLOWED.0,
2536 );
2537
2538 let mut ret = Self::get_for_version_impl(version, chain);
2539 ret.version = version;
2540 ret.chain = chain;
2541
2542 ret = Self::apply_config_override(version, ret);
2543
2544 if std::env::var("SUI_PROTOCOL_CONFIG_OVERRIDE_ENABLE").is_ok() {
2545 warn!(
2546 "overriding ProtocolConfig settings with custom settings; this may break non-local networks"
2547 );
2548 let overrides: ProtocolConfigOptional =
2549 serde_env::from_env_with_prefix("SUI_PROTOCOL_CONFIG_OVERRIDE")
2550 .expect("failed to parse ProtocolConfig override env variables");
2551 overrides.apply_to(&mut ret);
2552 }
2553
2554 ret
2555 }
2556
2557 pub fn get_for_version_if_supported(version: ProtocolVersion, chain: Chain) -> Option<Self> {
2560 if version.0 >= ProtocolVersion::MIN.0 && version.0 <= ProtocolVersion::MAX_ALLOWED.0 {
2561 let mut ret = Self::get_for_version_impl(version, chain);
2562 ret.version = version;
2563 ret.chain = chain;
2564 ret = Self::apply_config_override(version, ret);
2565 Some(ret)
2566 } else {
2567 None
2568 }
2569 }
2570
2571 pub fn poison_get_for_min_version() {
2572 POISON_VERSION_METHODS.store(true, Ordering::Relaxed);
2573 }
2574
2575 fn load_poison_get_for_min_version() -> bool {
2576 POISON_VERSION_METHODS.load(Ordering::Relaxed)
2577 }
2578
2579 pub fn get_for_min_version() -> Self {
2582 if Self::load_poison_get_for_min_version() {
2583 panic!("get_for_min_version called on validator");
2584 }
2585 ProtocolConfig::get_for_version(ProtocolVersion::MIN, Chain::Unknown)
2586 }
2587
2588 #[allow(non_snake_case)]
2598 pub fn get_for_max_version_UNSAFE() -> Self {
2599 if Self::load_poison_get_for_min_version() {
2600 panic!("get_for_max_version_UNSAFE called on validator");
2601 }
2602 ProtocolConfig::get_for_version(ProtocolVersion::MAX, Chain::Unknown)
2603 }
2604
2605 fn get_for_version_impl(version: ProtocolVersion, chain: Chain) -> Self {
2606 #[cfg(msim)]
2607 {
2608 if version == ProtocolVersion::MAX_ALLOWED {
2610 let mut config = Self::get_for_version_impl(version - 1, Chain::Unknown);
2611 config.base_tx_cost_fixed = Some(config.base_tx_cost_fixed() + 1000);
2612 return config;
2613 }
2614 }
2615
2616 let mut cfg = Self {
2619 version,
2621 chain,
2622
2623 feature_flags: Default::default(),
2625
2626 max_tx_size_bytes: Some(128 * 1024),
2627 max_input_objects: Some(2048),
2629 max_serialized_tx_effects_size_bytes: Some(512 * 1024),
2630 max_serialized_tx_effects_size_bytes_system_tx: Some(512 * 1024 * 16),
2631 max_gas_payment_objects: Some(256),
2632 max_modules_in_publish: Some(128),
2633 max_package_dependencies: None,
2634 max_arguments: Some(512),
2635 max_type_arguments: Some(16),
2636 max_type_argument_depth: Some(16),
2637 max_pure_argument_size: Some(16 * 1024),
2638 max_programmable_tx_commands: Some(1024),
2639 move_binary_format_version: Some(6),
2640 min_move_binary_format_version: None,
2641 binary_module_handles: None,
2642 binary_struct_handles: None,
2643 binary_function_handles: None,
2644 binary_function_instantiations: None,
2645 binary_signatures: None,
2646 binary_constant_pool: None,
2647 binary_identifiers: None,
2648 binary_address_identifiers: None,
2649 binary_struct_defs: None,
2650 binary_struct_def_instantiations: None,
2651 binary_function_defs: None,
2652 binary_field_handles: None,
2653 binary_field_instantiations: None,
2654 binary_friend_decls: None,
2655 binary_enum_defs: None,
2656 binary_enum_def_instantiations: None,
2657 binary_variant_handles: None,
2658 binary_variant_instantiation_handles: None,
2659 max_move_object_size: Some(250 * 1024),
2660 max_move_package_size: Some(100 * 1024),
2661 max_publish_or_upgrade_per_ptb: None,
2662 max_tx_gas: Some(10_000_000_000),
2663 max_gas_price: Some(100_000),
2664 max_gas_price_rgp_factor_for_aborted_transactions: None,
2665 max_gas_computation_bucket: Some(5_000_000),
2666 max_loop_depth: Some(5),
2667 max_generic_instantiation_length: Some(32),
2668 max_function_parameters: Some(128),
2669 max_basic_blocks: Some(1024),
2670 max_value_stack_size: Some(1024),
2671 max_type_nodes: Some(256),
2672 max_generic_instantiation_type_nodes_per_function: None,
2673 max_generic_instantiation_type_nodes_per_module: None,
2674 max_accumulator_type_nodes: None,
2675 max_push_size: Some(10000),
2676 max_struct_definitions: Some(200),
2677 max_function_definitions: Some(1000),
2678 max_fields_in_struct: Some(32),
2679 max_dependency_depth: Some(100),
2680 max_num_event_emit: Some(256),
2681 max_num_new_move_object_ids: Some(2048),
2682 max_num_new_move_object_ids_system_tx: Some(2048 * 16),
2683 max_num_deleted_move_object_ids: Some(2048),
2684 max_num_deleted_move_object_ids_system_tx: Some(2048 * 16),
2685 max_num_transferred_move_object_ids: Some(2048),
2686 max_num_transferred_move_object_ids_system_tx: Some(2048 * 16),
2687 max_event_emit_size: Some(250 * 1024),
2688 max_move_vector_len: Some(256 * 1024),
2689 max_type_to_layout_nodes: None,
2690 max_ptb_value_size: None,
2691
2692 max_back_edges_per_function: Some(10_000),
2693 max_back_edges_per_module: Some(10_000),
2694 max_verifier_meter_ticks_per_function: Some(6_000_000),
2695 max_meter_ticks_per_module: Some(6_000_000),
2696 max_meter_ticks_per_package: None,
2697
2698 object_runtime_max_num_cached_objects: Some(1000),
2699 object_runtime_max_num_cached_objects_system_tx: Some(1000 * 16),
2700 object_runtime_max_num_store_entries: Some(1000),
2701 object_runtime_max_num_store_entries_system_tx: Some(1000 * 16),
2702 base_tx_cost_fixed: Some(110_000),
2703 package_publish_cost_fixed: Some(1_000),
2704 base_tx_cost_per_byte: Some(0),
2705 package_publish_cost_per_byte: Some(80),
2706 obj_access_cost_read_per_byte: Some(15),
2707 obj_access_cost_mutate_per_byte: Some(40),
2708 obj_access_cost_delete_per_byte: Some(40),
2709 obj_access_cost_verify_per_byte: Some(200),
2710 obj_data_cost_refundable: Some(100),
2711 obj_metadata_cost_non_refundable: Some(50),
2712 gas_model_version: Some(1),
2713 storage_rebate_rate: Some(9900),
2714 storage_fund_reinvest_rate: Some(500),
2715 reward_slashing_rate: Some(5000),
2716 storage_gas_price: Some(1),
2717 accumulator_object_storage_cost: None,
2718 max_transactions_per_checkpoint: Some(10_000),
2719 max_checkpoint_size_bytes: Some(30 * 1024 * 1024),
2720
2721 buffer_stake_for_protocol_upgrade_bps: Some(0),
2724
2725 address_from_bytes_cost_base: Some(52),
2729 address_to_u256_cost_base: Some(52),
2731 address_from_u256_cost_base: Some(52),
2733
2734 config_read_setting_impl_cost_base: None,
2737 config_read_setting_impl_cost_per_byte: None,
2738
2739 package_original_package_id_impl_cost_base: None,
2740 package_original_package_id_impl_cost_per_byte: None,
2741
2742 dynamic_field_hash_type_and_key_cost_base: Some(100),
2745 dynamic_field_hash_type_and_key_type_cost_per_byte: Some(2),
2746 dynamic_field_hash_type_and_key_value_cost_per_byte: Some(2),
2747 dynamic_field_hash_type_and_key_type_tag_cost_per_byte: Some(2),
2748 dynamic_field_add_child_object_cost_base: Some(100),
2750 dynamic_field_add_child_object_type_cost_per_byte: Some(10),
2751 dynamic_field_add_child_object_value_cost_per_byte: Some(10),
2752 dynamic_field_add_child_object_struct_tag_cost_per_byte: Some(10),
2753 dynamic_field_borrow_child_object_cost_base: Some(100),
2755 dynamic_field_borrow_child_object_child_ref_cost_per_byte: Some(10),
2756 dynamic_field_borrow_child_object_type_cost_per_byte: Some(10),
2757 dynamic_field_remove_child_object_cost_base: Some(100),
2759 dynamic_field_remove_child_object_child_cost_per_byte: Some(2),
2760 dynamic_field_remove_child_object_type_cost_per_byte: Some(2),
2761 dynamic_field_has_child_object_cost_base: Some(100),
2763 dynamic_field_has_child_object_with_ty_cost_base: Some(100),
2765 dynamic_field_has_child_object_with_ty_type_cost_per_byte: Some(2),
2766 dynamic_field_has_child_object_with_ty_type_tag_cost_per_byte: Some(2),
2767
2768 scratch_add_cost_base: None,
2770 scratch_read_cost_base: None,
2771 scratch_read_value_cost: None,
2772 scratch_remove_cost_base: None,
2773 scratch_exists_cost_base: None,
2774 scratch_exists_with_type_cost_base: None,
2775 scratch_exists_with_type_type_cost: None,
2776 max_scratch_pad_size: None,
2777
2778 event_emit_cost_base: Some(52),
2781 event_emit_value_size_derivation_cost_per_byte: Some(2),
2782 event_emit_tag_size_derivation_cost_per_byte: Some(5),
2783 event_emit_output_cost_per_byte: Some(10),
2784 event_emit_auth_stream_cost: None,
2785
2786 reserve_object_funds_for_withdrawal_cost_base: None,
2788 reserve_object_funds_for_withdrawal_cold_read_cost: None,
2789
2790 object_borrow_uid_cost_base: Some(52),
2793 object_delete_impl_cost_base: Some(52),
2795 object_record_new_uid_cost_base: Some(52),
2797 object_record_new_uid_from_hash_cost_base: None,
2800
2801 transfer_transfer_internal_cost_base: Some(52),
2804 transfer_party_transfer_internal_cost_base: None,
2806 transfer_freeze_object_cost_base: Some(52),
2808 transfer_share_object_cost_base: Some(52),
2810 transfer_receive_object_cost_base: None,
2811 transfer_receive_object_type_cost_per_byte: None,
2812 transfer_receive_object_cost_per_byte: None,
2813
2814 tx_context_derive_id_cost_base: Some(52),
2817 tx_context_fresh_id_cost_base: None,
2818 tx_context_sender_cost_base: None,
2819 tx_context_epoch_cost_base: None,
2820 tx_context_epoch_timestamp_ms_cost_base: None,
2821 tx_context_sponsor_cost_base: None,
2822 tx_context_rgp_cost_base: None,
2823 tx_context_gas_price_cost_base: None,
2824 tx_context_gas_budget_cost_base: None,
2825 tx_context_ids_created_cost_base: None,
2826 tx_context_replace_cost_base: None,
2827
2828 types_is_one_time_witness_cost_base: Some(52),
2831 types_is_one_time_witness_type_tag_cost_per_byte: Some(2),
2832 types_is_one_time_witness_type_cost_per_byte: Some(2),
2833
2834 validator_validate_metadata_cost_base: Some(52),
2837 validator_validate_metadata_data_cost_per_byte: Some(2),
2838
2839 crypto_invalid_arguments_cost: Some(100),
2841 bls12381_bls12381_min_sig_verify_cost_base: Some(52),
2843 bls12381_bls12381_min_sig_verify_msg_cost_per_byte: Some(2),
2844 bls12381_bls12381_min_sig_verify_msg_cost_per_block: Some(2),
2845
2846 bls12381_bls12381_min_pk_verify_cost_base: Some(52),
2848 bls12381_bls12381_min_pk_verify_msg_cost_per_byte: Some(2),
2849 bls12381_bls12381_min_pk_verify_msg_cost_per_block: Some(2),
2850
2851 ecdsa_k1_ecrecover_keccak256_cost_base: Some(52),
2853 ecdsa_k1_ecrecover_keccak256_msg_cost_per_byte: Some(2),
2854 ecdsa_k1_ecrecover_keccak256_msg_cost_per_block: Some(2),
2855 ecdsa_k1_ecrecover_sha256_cost_base: Some(52),
2856 ecdsa_k1_ecrecover_sha256_msg_cost_per_byte: Some(2),
2857 ecdsa_k1_ecrecover_sha256_msg_cost_per_block: Some(2),
2858
2859 ecdsa_k1_decompress_pubkey_cost_base: Some(52),
2861
2862 ecdsa_k1_secp256k1_verify_keccak256_cost_base: Some(52),
2864 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_byte: Some(2),
2865 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_block: Some(2),
2866 ecdsa_k1_secp256k1_verify_sha256_cost_base: Some(52),
2867 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_byte: Some(2),
2868 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_block: Some(2),
2869
2870 ecdsa_r1_ecrecover_keccak256_cost_base: Some(52),
2872 ecdsa_r1_ecrecover_keccak256_msg_cost_per_byte: Some(2),
2873 ecdsa_r1_ecrecover_keccak256_msg_cost_per_block: Some(2),
2874 ecdsa_r1_ecrecover_sha256_cost_base: Some(52),
2875 ecdsa_r1_ecrecover_sha256_msg_cost_per_byte: Some(2),
2876 ecdsa_r1_ecrecover_sha256_msg_cost_per_block: Some(2),
2877
2878 ecdsa_r1_secp256r1_verify_keccak256_cost_base: Some(52),
2880 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_byte: Some(2),
2881 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_block: Some(2),
2882 ecdsa_r1_secp256r1_verify_sha256_cost_base: Some(52),
2883 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_byte: Some(2),
2884 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_block: Some(2),
2885
2886 ecvrf_ecvrf_verify_cost_base: Some(52),
2888 ecvrf_ecvrf_verify_alpha_string_cost_per_byte: Some(2),
2889 ecvrf_ecvrf_verify_alpha_string_cost_per_block: Some(2),
2890
2891 ed25519_ed25519_verify_cost_base: Some(52),
2893 ed25519_ed25519_verify_msg_cost_per_byte: Some(2),
2894 ed25519_ed25519_verify_msg_cost_per_block: Some(2),
2895
2896 groth16_prepare_verifying_key_bls12381_cost_base: Some(52),
2898 groth16_prepare_verifying_key_bn254_cost_base: Some(52),
2899
2900 groth16_verify_groth16_proof_internal_bls12381_cost_base: Some(52),
2902 groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input: Some(2),
2903 groth16_verify_groth16_proof_internal_bn254_cost_base: Some(52),
2904 groth16_verify_groth16_proof_internal_bn254_cost_per_public_input: Some(2),
2905 groth16_verify_groth16_proof_internal_public_input_cost_per_byte: Some(2),
2906
2907 hash_blake2b256_cost_base: Some(52),
2909 hash_blake2b256_data_cost_per_byte: Some(2),
2910 hash_blake2b256_data_cost_per_block: Some(2),
2911
2912 hash_keccak256_cost_base: Some(52),
2914 hash_keccak256_data_cost_per_byte: Some(2),
2915 hash_keccak256_data_cost_per_block: Some(2),
2916
2917 poseidon_bn254_cost_base: None,
2918 poseidon_bn254_cost_per_block: None,
2919
2920 hmac_hmac_sha3_256_cost_base: Some(52),
2922 hmac_hmac_sha3_256_input_cost_per_byte: Some(2),
2923 hmac_hmac_sha3_256_input_cost_per_block: Some(2),
2924
2925 group_ops_bls12381_decode_scalar_cost: None,
2927 group_ops_bls12381_decode_g1_cost: None,
2928 group_ops_bls12381_decode_g2_cost: None,
2929 group_ops_bls12381_decode_gt_cost: None,
2930 group_ops_bls12381_scalar_add_cost: None,
2931 group_ops_bls12381_g1_add_cost: None,
2932 group_ops_bls12381_g2_add_cost: None,
2933 group_ops_bls12381_gt_add_cost: None,
2934 group_ops_bls12381_scalar_sub_cost: None,
2935 group_ops_bls12381_g1_sub_cost: None,
2936 group_ops_bls12381_g2_sub_cost: None,
2937 group_ops_bls12381_gt_sub_cost: None,
2938 group_ops_bls12381_scalar_mul_cost: None,
2939 group_ops_bls12381_g1_mul_cost: None,
2940 group_ops_bls12381_g2_mul_cost: None,
2941 group_ops_bls12381_gt_mul_cost: None,
2942 group_ops_bls12381_scalar_div_cost: None,
2943 group_ops_bls12381_g1_div_cost: None,
2944 group_ops_bls12381_g2_div_cost: None,
2945 group_ops_bls12381_gt_div_cost: None,
2946 group_ops_bls12381_g1_hash_to_base_cost: None,
2947 group_ops_bls12381_g2_hash_to_base_cost: None,
2948 group_ops_bls12381_g1_hash_to_cost_per_byte: None,
2949 group_ops_bls12381_g2_hash_to_cost_per_byte: None,
2950 group_ops_bls12381_g1_msm_base_cost: None,
2951 group_ops_bls12381_g2_msm_base_cost: None,
2952 group_ops_bls12381_g1_msm_base_cost_per_input: None,
2953 group_ops_bls12381_g2_msm_base_cost_per_input: None,
2954 group_ops_bls12381_msm_max_len: None,
2955 group_ops_bls12381_pairing_cost: None,
2956 group_ops_bls12381_g1_to_uncompressed_g1_cost: None,
2957 group_ops_bls12381_uncompressed_g1_to_g1_cost: None,
2958 group_ops_bls12381_uncompressed_g1_sum_base_cost: None,
2959 group_ops_bls12381_uncompressed_g1_sum_cost_per_term: None,
2960 group_ops_bls12381_uncompressed_g1_sum_max_terms: None,
2961
2962 group_ops_ristretto_decode_scalar_cost: None,
2963 group_ops_ristretto_decode_point_cost: None,
2964 group_ops_ristretto_scalar_add_cost: None,
2965 group_ops_ristretto_point_add_cost: None,
2966 group_ops_ristretto_scalar_sub_cost: None,
2967 group_ops_ristretto_point_sub_cost: None,
2968 group_ops_ristretto_scalar_mul_cost: None,
2969 group_ops_ristretto_point_mul_cost: None,
2970 group_ops_ristretto_scalar_div_cost: None,
2971 group_ops_ristretto_point_div_cost: None,
2972
2973 verify_bulletproofs_ristretto255_base_cost: None,
2974 verify_bulletproofs_ristretto255_cost_per_bit_and_commitment: None,
2975 max_bulletproofs_total_bits: None,
2976
2977 check_zklogin_id_cost_base: None,
2979 check_zklogin_issuer_cost_base: None,
2981
2982 vdf_verify_vdf_cost: None,
2983 vdf_hash_to_input_cost: None,
2984
2985 nitro_attestation_parse_base_cost: None,
2987 nitro_attestation_parse_cost_per_byte: None,
2988 nitro_attestation_verify_base_cost: None,
2989 nitro_attestation_verify_cost_per_cert: None,
2990
2991 bcs_per_byte_serialized_cost: None,
2992 bcs_legacy_min_output_size_cost: None,
2993 bcs_failure_cost: None,
2994 hash_sha2_256_base_cost: None,
2995 hash_sha2_256_per_byte_cost: None,
2996 hash_sha2_256_legacy_min_input_len_cost: None,
2997 hash_sha3_256_base_cost: None,
2998 hash_sha3_256_per_byte_cost: None,
2999 hash_sha3_256_legacy_min_input_len_cost: None,
3000 type_name_get_base_cost: None,
3001 type_name_get_per_byte_cost: None,
3002 type_name_id_base_cost: None,
3003 string_check_utf8_base_cost: None,
3004 string_check_utf8_per_byte_cost: None,
3005 string_is_char_boundary_base_cost: None,
3006 string_sub_string_base_cost: None,
3007 string_sub_string_per_byte_cost: None,
3008 string_index_of_base_cost: None,
3009 string_index_of_per_byte_pattern_cost: None,
3010 string_index_of_per_byte_searched_cost: None,
3011 vector_empty_base_cost: None,
3012 vector_length_base_cost: None,
3013 vector_push_back_base_cost: None,
3014 vector_push_back_legacy_per_abstract_memory_unit_cost: None,
3015 vector_borrow_base_cost: None,
3016 vector_pop_back_base_cost: None,
3017 vector_destroy_empty_base_cost: None,
3018 vector_swap_base_cost: None,
3019 debug_print_base_cost: None,
3020 debug_print_stack_trace_base_cost: None,
3021
3022 max_size_written_objects: None,
3023 max_size_written_objects_system_tx: None,
3024
3025 max_move_identifier_len: None,
3032 max_move_value_depth: None,
3033 package_arena_size_in_bytes: None,
3034 max_move_enum_variants: None,
3035
3036 gas_rounding_step: None,
3037
3038 execution_version: None,
3039
3040 max_event_emit_size_total: None,
3041
3042 consensus_bad_nodes_stake_threshold: None,
3043
3044 max_jwk_votes_per_validator_per_epoch: None,
3045
3046 max_age_of_jwk_in_epochs: None,
3047
3048 random_beacon_reduction_allowed_delta: None,
3049
3050 random_beacon_reduction_lower_bound: None,
3051
3052 random_beacon_dkg_timeout_round: None,
3053
3054 random_beacon_min_round_interval_ms: None,
3055
3056 random_beacon_dkg_version: None,
3057
3058 consensus_max_transaction_size_bytes: None,
3059
3060 consensus_max_transactions_in_block_bytes: None,
3061
3062 consensus_max_num_transactions_in_block: None,
3063
3064 consensus_voting_rounds: None,
3065
3066 max_accumulated_txn_cost_per_object_in_narwhal_commit: None,
3067
3068 max_deferral_rounds_for_congestion_control: None,
3069
3070 epoch_close_deadline_ms: None,
3071
3072 max_txn_cost_overage_per_object_in_commit: None,
3073
3074 allowed_txn_cost_overage_burst_per_object_in_commit: None,
3075
3076 min_checkpoint_interval_ms: None,
3077
3078 checkpoint_summary_version_specific_data: None,
3079
3080 max_soft_bundle_size: None,
3081
3082 bridge_should_try_to_finalize_committee: None,
3083
3084 max_accumulated_txn_cost_per_object_in_mysticeti_commit: None,
3085
3086 max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit: None,
3087
3088 consensus_gc_depth: None,
3089
3090 gas_budget_based_txn_cost_cap_factor: None,
3091
3092 gas_budget_based_txn_cost_absolute_cap_commit_count: None,
3093
3094 sip_45_consensus_amplification_threshold: None,
3095
3096 use_object_per_epoch_marker_table_v2: None,
3097
3098 consensus_commit_rate_estimation_window_size: None,
3099
3100 aliased_addresses: vec![],
3101
3102 translation_per_command_base_charge: None,
3103 translation_per_input_base_charge: None,
3104 translation_pure_input_per_byte_charge: None,
3105 translation_per_type_node_charge: None,
3106 translation_per_reference_node_charge: None,
3107 translation_per_linkage_entry_charge: None,
3108 translation_per_live_reference_charge: None,
3109 max_ptb_live_references: None,
3110 max_ptb_returned_references: None,
3111 max_ptb_total_returned_references: None,
3112
3113 max_updates_per_settlement_txn: None,
3114
3115 gasless_max_computation_units: None,
3116 gasless_allowed_token_types: None,
3117 gasless_max_unused_inputs: None,
3118 gasless_max_pure_input_bytes: None,
3119 gasless_max_tps: None,
3120 include_special_package_amendments: None,
3121 gasless_max_tx_size_bytes: None,
3122 };
3125 for cur in 2..=version.0 {
3126 match cur {
3127 1 => unreachable!(),
3128 2 => {
3129 cfg.feature_flags.advance_epoch_start_time_in_safe_mode = true;
3130 }
3131 3 => {
3132 cfg.gas_model_version = Some(2);
3134 cfg.max_tx_gas = Some(50_000_000_000);
3136 cfg.base_tx_cost_fixed = Some(2_000);
3138 cfg.storage_gas_price = Some(76);
3140 cfg.feature_flags.loaded_child_objects_fixed = true;
3141 cfg.max_size_written_objects = Some(5 * 1000 * 1000);
3144 cfg.max_size_written_objects_system_tx = Some(50 * 1000 * 1000);
3147 cfg.feature_flags.package_upgrades = true;
3148 }
3149 4 => {
3154 cfg.reward_slashing_rate = Some(10000);
3156 cfg.gas_model_version = Some(3);
3158 }
3159 5 => {
3160 cfg.feature_flags.missing_type_is_compatibility_error = true;
3161 cfg.gas_model_version = Some(4);
3162 cfg.feature_flags.scoring_decision_with_validity_cutoff = true;
3163 }
3167 6 => {
3168 cfg.gas_model_version = Some(5);
3169 cfg.buffer_stake_for_protocol_upgrade_bps = Some(5000);
3170 cfg.feature_flags.consensus_order_end_of_epoch_last = true;
3171 }
3172 7 => {
3173 cfg.feature_flags.disallow_adding_abilities_on_upgrade = true;
3174 cfg.feature_flags
3175 .disable_invariant_violation_check_in_swap_loc = true;
3176 cfg.feature_flags.ban_entry_init = true;
3177 cfg.feature_flags.package_digest_hash_module = true;
3178 }
3179 8 => {
3180 cfg.feature_flags
3181 .disallow_change_struct_type_params_on_upgrade = true;
3182 }
3183 9 => {
3184 cfg.max_move_identifier_len = Some(128);
3186 cfg.feature_flags.no_extraneous_module_bytes = true;
3187 cfg.feature_flags
3188 .advance_to_highest_supported_protocol_version = true;
3189 }
3190 10 => {
3191 cfg.max_verifier_meter_ticks_per_function = Some(16_000_000);
3192 cfg.max_meter_ticks_per_module = Some(16_000_000);
3193 }
3194 11 => {
3195 cfg.max_move_value_depth = Some(128);
3196 }
3197 12 => {
3198 cfg.feature_flags.narwhal_versioned_metadata = true;
3199 if chain != Chain::Mainnet {
3200 cfg.feature_flags.commit_root_state_digest = true;
3201 }
3202
3203 if chain != Chain::Mainnet && chain != Chain::Testnet {
3204 cfg.feature_flags.zklogin_auth = true;
3205 }
3206 }
3207 13 => {}
3208 14 => {
3209 cfg.gas_rounding_step = Some(1_000);
3210 cfg.gas_model_version = Some(6);
3211 }
3212 15 => {
3213 cfg.feature_flags.consensus_transaction_ordering =
3214 ConsensusTransactionOrdering::ByGasPrice;
3215 }
3216 16 => {
3217 cfg.feature_flags.simplified_unwrap_then_delete = true;
3218 }
3219 17 => {
3220 cfg.feature_flags.upgraded_multisig_supported = true;
3221 }
3222 18 => {
3223 cfg.execution_version = Some(1);
3224 cfg.feature_flags.txn_base_cost_as_multiplier = true;
3233 cfg.base_tx_cost_fixed = Some(1_000);
3235 }
3236 19 => {
3237 cfg.max_num_event_emit = Some(1024);
3238 cfg.max_event_emit_size_total = Some(
3241 256 * 250 * 1024, );
3243 }
3244 20 => {
3245 cfg.feature_flags.commit_root_state_digest = true;
3246
3247 if chain != Chain::Mainnet {
3248 cfg.feature_flags.narwhal_new_leader_election_schedule = true;
3249 cfg.consensus_bad_nodes_stake_threshold = Some(20);
3250 }
3251 }
3252
3253 21 => {
3254 if chain != Chain::Mainnet {
3255 cfg.feature_flags.zklogin_supported_providers = BTreeSet::from([
3256 "Google".to_string(),
3257 "Facebook".to_string(),
3258 "Twitch".to_string(),
3259 ]);
3260 }
3261 }
3262 22 => {
3263 cfg.feature_flags.loaded_child_object_format = true;
3264 }
3265 23 => {
3266 cfg.feature_flags.loaded_child_object_format_type = true;
3267 cfg.feature_flags.narwhal_new_leader_election_schedule = true;
3268 cfg.consensus_bad_nodes_stake_threshold = Some(20);
3274 }
3275 24 => {
3276 cfg.feature_flags.simple_conservation_checks = true;
3277 cfg.max_publish_or_upgrade_per_ptb = Some(5);
3278
3279 cfg.feature_flags.end_of_epoch_transaction_supported = true;
3280
3281 if chain != Chain::Mainnet {
3282 cfg.feature_flags.enable_jwk_consensus_updates = true;
3283 cfg.max_jwk_votes_per_validator_per_epoch = Some(240);
3285 cfg.max_age_of_jwk_in_epochs = Some(1);
3286 }
3287 }
3288 25 => {
3289 cfg.feature_flags.zklogin_supported_providers = BTreeSet::from([
3291 "Google".to_string(),
3292 "Facebook".to_string(),
3293 "Twitch".to_string(),
3294 ]);
3295 cfg.feature_flags.zklogin_auth = true;
3296
3297 cfg.feature_flags.enable_jwk_consensus_updates = true;
3299 cfg.max_jwk_votes_per_validator_per_epoch = Some(240);
3300 cfg.max_age_of_jwk_in_epochs = Some(1);
3301 }
3302 26 => {
3303 cfg.gas_model_version = Some(7);
3304 if chain != Chain::Mainnet && chain != Chain::Testnet {
3306 cfg.transfer_receive_object_cost_base = Some(52);
3307 cfg.feature_flags.receive_objects = true;
3308 }
3309 }
3310 27 => {
3311 cfg.gas_model_version = Some(8);
3312 }
3313 28 => {
3314 cfg.check_zklogin_id_cost_base = Some(200);
3316 cfg.check_zklogin_issuer_cost_base = Some(200);
3318
3319 if chain != Chain::Mainnet && chain != Chain::Testnet {
3321 cfg.feature_flags.enable_effects_v2 = true;
3322 }
3323 }
3324 29 => {
3325 cfg.feature_flags.verify_legacy_zklogin_address = true;
3326 }
3327 30 => {
3328 if chain != Chain::Mainnet {
3330 cfg.feature_flags.narwhal_certificate_v2 = true;
3331 }
3332
3333 cfg.random_beacon_reduction_allowed_delta = Some(800);
3334 if chain != Chain::Mainnet {
3336 cfg.feature_flags.enable_effects_v2 = true;
3337 }
3338
3339 cfg.feature_flags.zklogin_supported_providers = BTreeSet::default();
3343
3344 cfg.feature_flags.recompute_has_public_transfer_in_execution = true;
3345 }
3346 31 => {
3347 cfg.execution_version = Some(2);
3348 if chain != Chain::Mainnet && chain != Chain::Testnet {
3350 cfg.feature_flags.shared_object_deletion = true;
3351 }
3352 }
3353 32 => {
3354 if chain != Chain::Mainnet {
3356 cfg.feature_flags.accept_zklogin_in_multisig = true;
3357 }
3358 if chain != Chain::Mainnet {
3360 cfg.transfer_receive_object_cost_base = Some(52);
3361 cfg.feature_flags.receive_objects = true;
3362 }
3363 if chain != Chain::Mainnet && chain != Chain::Testnet {
3365 cfg.feature_flags.random_beacon = true;
3366 cfg.random_beacon_reduction_lower_bound = Some(1600);
3367 cfg.random_beacon_dkg_timeout_round = Some(3000);
3368 cfg.random_beacon_min_round_interval_ms = Some(150);
3369 }
3370 if chain != Chain::Testnet && chain != Chain::Mainnet {
3372 cfg.feature_flags.include_consensus_digest_in_prologue = true;
3373 }
3374
3375 cfg.feature_flags.narwhal_certificate_v2 = true;
3377 }
3378 33 => {
3379 cfg.feature_flags.hardened_otw_check = true;
3380 cfg.feature_flags.allow_receiving_object_id = true;
3381
3382 cfg.transfer_receive_object_cost_base = Some(52);
3384 cfg.feature_flags.receive_objects = true;
3385
3386 if chain != Chain::Mainnet {
3388 cfg.feature_flags.shared_object_deletion = true;
3389 }
3390
3391 cfg.feature_flags.enable_effects_v2 = true;
3392 }
3393 34 => {}
3394 35 => {
3395 if chain != Chain::Mainnet && chain != Chain::Testnet {
3397 cfg.feature_flags.enable_poseidon = true;
3398 cfg.poseidon_bn254_cost_base = Some(260);
3399 cfg.poseidon_bn254_cost_per_block = Some(10);
3400 }
3401
3402 cfg.feature_flags.enable_coin_deny_list = true;
3403 }
3404 36 => {
3405 if chain != Chain::Mainnet && chain != Chain::Testnet {
3407 cfg.feature_flags.enable_group_ops_native_functions = true;
3408 cfg.feature_flags.enable_group_ops_native_function_msm = true;
3409 cfg.group_ops_bls12381_decode_scalar_cost = Some(52);
3411 cfg.group_ops_bls12381_decode_g1_cost = Some(52);
3412 cfg.group_ops_bls12381_decode_g2_cost = Some(52);
3413 cfg.group_ops_bls12381_decode_gt_cost = Some(52);
3414 cfg.group_ops_bls12381_scalar_add_cost = Some(52);
3415 cfg.group_ops_bls12381_g1_add_cost = Some(52);
3416 cfg.group_ops_bls12381_g2_add_cost = Some(52);
3417 cfg.group_ops_bls12381_gt_add_cost = Some(52);
3418 cfg.group_ops_bls12381_scalar_sub_cost = Some(52);
3419 cfg.group_ops_bls12381_g1_sub_cost = Some(52);
3420 cfg.group_ops_bls12381_g2_sub_cost = Some(52);
3421 cfg.group_ops_bls12381_gt_sub_cost = Some(52);
3422 cfg.group_ops_bls12381_scalar_mul_cost = Some(52);
3423 cfg.group_ops_bls12381_g1_mul_cost = Some(52);
3424 cfg.group_ops_bls12381_g2_mul_cost = Some(52);
3425 cfg.group_ops_bls12381_gt_mul_cost = Some(52);
3426 cfg.group_ops_bls12381_scalar_div_cost = Some(52);
3427 cfg.group_ops_bls12381_g1_div_cost = Some(52);
3428 cfg.group_ops_bls12381_g2_div_cost = Some(52);
3429 cfg.group_ops_bls12381_gt_div_cost = Some(52);
3430 cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(52);
3431 cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(52);
3432 cfg.group_ops_bls12381_g1_hash_to_cost_per_byte = Some(2);
3433 cfg.group_ops_bls12381_g2_hash_to_cost_per_byte = Some(2);
3434 cfg.group_ops_bls12381_g1_msm_base_cost = Some(52);
3435 cfg.group_ops_bls12381_g2_msm_base_cost = Some(52);
3436 cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(52);
3437 cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(52);
3438 cfg.group_ops_bls12381_msm_max_len = Some(32);
3439 cfg.group_ops_bls12381_pairing_cost = Some(52);
3440 }
3441 cfg.feature_flags.shared_object_deletion = true;
3443
3444 cfg.consensus_max_transaction_size_bytes = Some(256 * 1024); cfg.consensus_max_transactions_in_block_bytes = Some(6 * 1_024 * 1024);
3446 }
3448 37 => {
3449 cfg.feature_flags.reject_mutable_random_on_entry_functions = true;
3450
3451 if chain != Chain::Mainnet {
3453 cfg.feature_flags.include_consensus_digest_in_prologue = true;
3454 }
3455 }
3456 38 => {
3457 cfg.binary_module_handles = Some(100);
3458 cfg.binary_struct_handles = Some(300);
3459 cfg.binary_function_handles = Some(1500);
3460 cfg.binary_function_instantiations = Some(750);
3461 cfg.binary_signatures = Some(1000);
3462 cfg.binary_constant_pool = Some(4000);
3466 cfg.binary_identifiers = Some(10000);
3467 cfg.binary_address_identifiers = Some(100);
3468 cfg.binary_struct_defs = Some(200);
3469 cfg.binary_struct_def_instantiations = Some(100);
3470 cfg.binary_function_defs = Some(1000);
3471 cfg.binary_field_handles = Some(500);
3472 cfg.binary_field_instantiations = Some(250);
3473 cfg.binary_friend_decls = Some(100);
3474 cfg.max_package_dependencies = Some(32);
3476 cfg.max_modules_in_publish = Some(64);
3477 cfg.execution_version = Some(3);
3479 }
3480 39 => {
3481 }
3483 40 => {}
3484 41 => {
3485 cfg.feature_flags.enable_group_ops_native_functions = true;
3487 cfg.group_ops_bls12381_decode_scalar_cost = Some(52);
3489 cfg.group_ops_bls12381_decode_g1_cost = Some(52);
3490 cfg.group_ops_bls12381_decode_g2_cost = Some(52);
3491 cfg.group_ops_bls12381_decode_gt_cost = Some(52);
3492 cfg.group_ops_bls12381_scalar_add_cost = Some(52);
3493 cfg.group_ops_bls12381_g1_add_cost = Some(52);
3494 cfg.group_ops_bls12381_g2_add_cost = Some(52);
3495 cfg.group_ops_bls12381_gt_add_cost = Some(52);
3496 cfg.group_ops_bls12381_scalar_sub_cost = Some(52);
3497 cfg.group_ops_bls12381_g1_sub_cost = Some(52);
3498 cfg.group_ops_bls12381_g2_sub_cost = Some(52);
3499 cfg.group_ops_bls12381_gt_sub_cost = Some(52);
3500 cfg.group_ops_bls12381_scalar_mul_cost = Some(52);
3501 cfg.group_ops_bls12381_g1_mul_cost = Some(52);
3502 cfg.group_ops_bls12381_g2_mul_cost = Some(52);
3503 cfg.group_ops_bls12381_gt_mul_cost = Some(52);
3504 cfg.group_ops_bls12381_scalar_div_cost = Some(52);
3505 cfg.group_ops_bls12381_g1_div_cost = Some(52);
3506 cfg.group_ops_bls12381_g2_div_cost = Some(52);
3507 cfg.group_ops_bls12381_gt_div_cost = Some(52);
3508 cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(52);
3509 cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(52);
3510 cfg.group_ops_bls12381_g1_hash_to_cost_per_byte = Some(2);
3511 cfg.group_ops_bls12381_g2_hash_to_cost_per_byte = Some(2);
3512 cfg.group_ops_bls12381_g1_msm_base_cost = Some(52);
3513 cfg.group_ops_bls12381_g2_msm_base_cost = Some(52);
3514 cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(52);
3515 cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(52);
3516 cfg.group_ops_bls12381_msm_max_len = Some(32);
3517 cfg.group_ops_bls12381_pairing_cost = Some(52);
3518 }
3519 42 => {}
3520 43 => {
3521 cfg.feature_flags.zklogin_max_epoch_upper_bound_delta = Some(30);
3522 cfg.max_meter_ticks_per_package = Some(16_000_000);
3523 }
3524 44 => {
3525 cfg.feature_flags.include_consensus_digest_in_prologue = true;
3527 if chain != Chain::Mainnet {
3529 cfg.feature_flags.consensus_choice = ConsensusChoice::SwapEachEpoch;
3530 }
3531 }
3532 45 => {
3533 if chain != Chain::Testnet && chain != Chain::Mainnet {
3535 cfg.feature_flags.consensus_network = ConsensusNetwork::Tonic;
3536 }
3537
3538 if chain != Chain::Mainnet {
3539 cfg.feature_flags.mysticeti_leader_scoring_and_schedule = true;
3541 }
3542 cfg.min_move_binary_format_version = Some(6);
3543 cfg.feature_flags.accept_zklogin_in_multisig = true;
3544
3545 if chain != Chain::Mainnet && chain != Chain::Testnet {
3549 cfg.feature_flags.bridge = true;
3550 }
3551 }
3552 46 => {
3553 if chain != Chain::Mainnet {
3555 cfg.feature_flags.bridge = true;
3556 }
3557
3558 cfg.feature_flags.reshare_at_same_initial_version = true;
3560 }
3561 47 => {}
3562 48 => {
3563 cfg.feature_flags.consensus_network = ConsensusNetwork::Tonic;
3565
3566 cfg.feature_flags.resolve_abort_locations_to_package_id = true;
3568
3569 if chain != Chain::Mainnet {
3571 cfg.feature_flags.random_beacon = true;
3572 cfg.random_beacon_reduction_lower_bound = Some(1600);
3573 cfg.random_beacon_dkg_timeout_round = Some(3000);
3574 cfg.random_beacon_min_round_interval_ms = Some(200);
3575 }
3576
3577 cfg.feature_flags.mysticeti_use_committed_subdag_digest = true;
3579 }
3580 49 => {
3581 if chain != Chain::Testnet && chain != Chain::Mainnet {
3582 cfg.move_binary_format_version = Some(7);
3583 }
3584
3585 if chain != Chain::Mainnet && chain != Chain::Testnet {
3587 cfg.feature_flags.enable_vdf = true;
3588 cfg.vdf_verify_vdf_cost = Some(1500);
3591 cfg.vdf_hash_to_input_cost = Some(100);
3592 }
3593
3594 if chain != Chain::Testnet && chain != Chain::Mainnet {
3596 cfg.feature_flags
3597 .record_consensus_determined_version_assignments_in_prologue = true;
3598 }
3599
3600 if chain != Chain::Mainnet {
3602 cfg.feature_flags.consensus_choice = ConsensusChoice::Mysticeti;
3603 }
3604
3605 cfg.feature_flags.fresh_vm_on_framework_upgrade = true;
3607 }
3608 50 => {
3609 if chain != Chain::Mainnet {
3611 cfg.checkpoint_summary_version_specific_data = Some(1);
3612 cfg.min_checkpoint_interval_ms = Some(200);
3613 }
3614
3615 if chain != Chain::Testnet && chain != Chain::Mainnet {
3617 cfg.feature_flags
3618 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = true;
3619 }
3620
3621 cfg.feature_flags.mysticeti_num_leaders_per_round = Some(1);
3622
3623 cfg.max_deferral_rounds_for_congestion_control = Some(10);
3625 }
3626 51 => {
3627 cfg.random_beacon_dkg_version = Some(1);
3628
3629 if chain != Chain::Testnet && chain != Chain::Mainnet {
3630 cfg.feature_flags.enable_coin_deny_list_v2 = true;
3631 }
3632 }
3633 52 => {
3634 if chain != Chain::Mainnet {
3635 cfg.feature_flags.soft_bundle = true;
3636 cfg.max_soft_bundle_size = Some(5);
3637 }
3638
3639 cfg.config_read_setting_impl_cost_base = Some(100);
3640 cfg.config_read_setting_impl_cost_per_byte = Some(40);
3641
3642 if chain != Chain::Testnet && chain != Chain::Mainnet {
3644 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(100);
3645 cfg.feature_flags.per_object_congestion_control_mode =
3646 PerObjectCongestionControlMode::TotalTxCount;
3647 }
3648
3649 cfg.feature_flags.consensus_choice = ConsensusChoice::Mysticeti;
3651
3652 cfg.feature_flags.mysticeti_leader_scoring_and_schedule = true;
3654
3655 cfg.checkpoint_summary_version_specific_data = Some(1);
3657 cfg.min_checkpoint_interval_ms = Some(200);
3658
3659 if chain != Chain::Mainnet {
3661 cfg.feature_flags
3662 .record_consensus_determined_version_assignments_in_prologue = true;
3663 cfg.feature_flags
3664 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = true;
3665 }
3666 if chain != Chain::Mainnet {
3668 cfg.move_binary_format_version = Some(7);
3669 }
3670
3671 if chain != Chain::Testnet && chain != Chain::Mainnet {
3672 cfg.feature_flags.passkey_auth = true;
3673 }
3674 cfg.feature_flags.enable_coin_deny_list_v2 = true;
3675 }
3676 53 => {
3677 cfg.bridge_should_try_to_finalize_committee = Some(chain != Chain::Mainnet);
3679
3680 cfg.feature_flags
3682 .record_consensus_determined_version_assignments_in_prologue = true;
3683 cfg.feature_flags
3684 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = true;
3685
3686 if chain == Chain::Unknown {
3687 cfg.feature_flags.authority_capabilities_v2 = true;
3688 }
3689
3690 if chain != Chain::Mainnet {
3692 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(100);
3693 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(10);
3694 cfg.feature_flags.per_object_congestion_control_mode =
3695 PerObjectCongestionControlMode::TotalTxCount;
3696 }
3697
3698 cfg.bcs_per_byte_serialized_cost = Some(2);
3700 cfg.bcs_legacy_min_output_size_cost = Some(1);
3701 cfg.bcs_failure_cost = Some(52);
3702 cfg.debug_print_base_cost = Some(52);
3703 cfg.debug_print_stack_trace_base_cost = Some(52);
3704 cfg.hash_sha2_256_base_cost = Some(52);
3705 cfg.hash_sha2_256_per_byte_cost = Some(2);
3706 cfg.hash_sha2_256_legacy_min_input_len_cost = Some(1);
3707 cfg.hash_sha3_256_base_cost = Some(52);
3708 cfg.hash_sha3_256_per_byte_cost = Some(2);
3709 cfg.hash_sha3_256_legacy_min_input_len_cost = Some(1);
3710 cfg.type_name_get_base_cost = Some(52);
3711 cfg.type_name_get_per_byte_cost = Some(2);
3712 cfg.string_check_utf8_base_cost = Some(52);
3713 cfg.string_check_utf8_per_byte_cost = Some(2);
3714 cfg.string_is_char_boundary_base_cost = Some(52);
3715 cfg.string_sub_string_base_cost = Some(52);
3716 cfg.string_sub_string_per_byte_cost = Some(2);
3717 cfg.string_index_of_base_cost = Some(52);
3718 cfg.string_index_of_per_byte_pattern_cost = Some(2);
3719 cfg.string_index_of_per_byte_searched_cost = Some(2);
3720 cfg.vector_empty_base_cost = Some(52);
3721 cfg.vector_length_base_cost = Some(52);
3722 cfg.vector_push_back_base_cost = Some(52);
3723 cfg.vector_push_back_legacy_per_abstract_memory_unit_cost = Some(2);
3724 cfg.vector_borrow_base_cost = Some(52);
3725 cfg.vector_pop_back_base_cost = Some(52);
3726 cfg.vector_destroy_empty_base_cost = Some(52);
3727 cfg.vector_swap_base_cost = Some(52);
3728 }
3729 54 => {
3730 cfg.feature_flags.random_beacon = true;
3732 cfg.random_beacon_reduction_lower_bound = Some(1000);
3733 cfg.random_beacon_dkg_timeout_round = Some(3000);
3734 cfg.random_beacon_min_round_interval_ms = Some(500);
3735
3736 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(100);
3738 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(10);
3739 cfg.feature_flags.per_object_congestion_control_mode =
3740 PerObjectCongestionControlMode::TotalTxCount;
3741
3742 cfg.feature_flags.soft_bundle = true;
3744 cfg.max_soft_bundle_size = Some(5);
3745 }
3746 55 => {
3747 cfg.move_binary_format_version = Some(7);
3749
3750 cfg.consensus_max_transactions_in_block_bytes = Some(512 * 1024);
3752 cfg.consensus_max_num_transactions_in_block = Some(512);
3755
3756 cfg.feature_flags.rethrow_serialization_type_layout_errors = true;
3757 }
3758 56 => {
3759 if chain == Chain::Mainnet {
3760 cfg.feature_flags.bridge = true;
3761 }
3762 }
3763 57 => {
3764 cfg.random_beacon_reduction_lower_bound = Some(800);
3766 }
3767 58 => {
3768 if chain == Chain::Mainnet {
3769 cfg.bridge_should_try_to_finalize_committee = Some(true);
3770 }
3771
3772 if chain != Chain::Mainnet && chain != Chain::Testnet {
3773 cfg.feature_flags
3775 .consensus_distributed_vote_scoring_strategy = true;
3776 }
3777 }
3778 59 => {
3779 cfg.feature_flags.consensus_round_prober = true;
3781 }
3782 60 => {
3783 cfg.max_type_to_layout_nodes = Some(512);
3784 cfg.feature_flags.validate_identifier_inputs = true;
3785 }
3786 61 => {
3787 if chain != Chain::Mainnet {
3788 cfg.feature_flags
3790 .consensus_distributed_vote_scoring_strategy = true;
3791 }
3792 cfg.random_beacon_reduction_lower_bound = Some(700);
3794
3795 if chain != Chain::Mainnet && chain != Chain::Testnet {
3796 cfg.feature_flags.mysticeti_fastpath = true;
3798 }
3799 }
3800 62 => {
3801 cfg.feature_flags.relocate_event_module = true;
3802 }
3803 63 => {
3804 cfg.feature_flags.per_object_congestion_control_mode =
3805 PerObjectCongestionControlMode::TotalGasBudgetWithCap;
3806 cfg.gas_budget_based_txn_cost_cap_factor = Some(400_000);
3807 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(18_500_000);
3808 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(240_000_000);
3809 }
3810 64 => {
3811 cfg.feature_flags.per_object_congestion_control_mode =
3812 PerObjectCongestionControlMode::TotalTxCount;
3813 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(40);
3814 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(3);
3815 }
3816 65 => {
3817 cfg.feature_flags
3819 .consensus_distributed_vote_scoring_strategy = true;
3820 }
3821 66 => {
3822 if chain == Chain::Mainnet {
3823 cfg.feature_flags
3825 .consensus_distributed_vote_scoring_strategy = false;
3826 }
3827 }
3828 67 => {
3829 cfg.feature_flags
3831 .consensus_distributed_vote_scoring_strategy = true;
3832 }
3833 68 => {
3834 cfg.group_ops_bls12381_g1_to_uncompressed_g1_cost = Some(26);
3835 cfg.group_ops_bls12381_uncompressed_g1_to_g1_cost = Some(52);
3836 cfg.group_ops_bls12381_uncompressed_g1_sum_base_cost = Some(26);
3837 cfg.group_ops_bls12381_uncompressed_g1_sum_cost_per_term = Some(13);
3838 cfg.group_ops_bls12381_uncompressed_g1_sum_max_terms = Some(2000);
3839
3840 if chain != Chain::Mainnet && chain != Chain::Testnet {
3841 cfg.feature_flags.uncompressed_g1_group_elements = true;
3842 }
3843
3844 cfg.feature_flags.per_object_congestion_control_mode =
3845 PerObjectCongestionControlMode::TotalGasBudgetWithCap;
3846 cfg.gas_budget_based_txn_cost_cap_factor = Some(400_000);
3847 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(18_500_000);
3848 cfg.max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit =
3849 Some(3_700_000); cfg.max_txn_cost_overage_per_object_in_commit = Some(u64::MAX);
3851 cfg.gas_budget_based_txn_cost_absolute_cap_commit_count = Some(50);
3852
3853 cfg.random_beacon_reduction_lower_bound = Some(500);
3855
3856 cfg.feature_flags.disallow_new_modules_in_deps_only_packages = true;
3857 }
3858 69 => {
3859 cfg.consensus_voting_rounds = Some(40);
3861
3862 if chain != Chain::Mainnet && chain != Chain::Testnet {
3863 cfg.feature_flags.consensus_smart_ancestor_selection = true;
3865 }
3866
3867 if chain != Chain::Mainnet {
3868 cfg.feature_flags.uncompressed_g1_group_elements = true;
3869 }
3870 }
3871 70 => {
3872 if chain != Chain::Mainnet {
3873 cfg.feature_flags.consensus_smart_ancestor_selection = true;
3875 cfg.feature_flags
3877 .consensus_round_prober_probe_accepted_rounds = true;
3878 }
3879
3880 cfg.poseidon_bn254_cost_per_block = Some(388);
3881
3882 cfg.gas_model_version = Some(9);
3883 cfg.feature_flags.native_charging_v2 = true;
3884 cfg.bls12381_bls12381_min_sig_verify_cost_base = Some(44064);
3885 cfg.bls12381_bls12381_min_pk_verify_cost_base = Some(49282);
3886 cfg.ecdsa_k1_secp256k1_verify_keccak256_cost_base = Some(1470);
3887 cfg.ecdsa_k1_secp256k1_verify_sha256_cost_base = Some(1470);
3888 cfg.ecdsa_r1_secp256r1_verify_sha256_cost_base = Some(4225);
3889 cfg.ecdsa_r1_secp256r1_verify_keccak256_cost_base = Some(4225);
3890 cfg.ecvrf_ecvrf_verify_cost_base = Some(4848);
3891 cfg.ed25519_ed25519_verify_cost_base = Some(1802);
3892
3893 cfg.ecdsa_r1_ecrecover_keccak256_cost_base = Some(1173);
3895 cfg.ecdsa_r1_ecrecover_sha256_cost_base = Some(1173);
3896 cfg.ecdsa_k1_ecrecover_keccak256_cost_base = Some(500);
3897 cfg.ecdsa_k1_ecrecover_sha256_cost_base = Some(500);
3898
3899 cfg.groth16_prepare_verifying_key_bls12381_cost_base = Some(53838);
3900 cfg.groth16_prepare_verifying_key_bn254_cost_base = Some(82010);
3901 cfg.groth16_verify_groth16_proof_internal_bls12381_cost_base = Some(72090);
3902 cfg.groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input =
3903 Some(8213);
3904 cfg.groth16_verify_groth16_proof_internal_bn254_cost_base = Some(115502);
3905 cfg.groth16_verify_groth16_proof_internal_bn254_cost_per_public_input =
3906 Some(9484);
3907
3908 cfg.hash_keccak256_cost_base = Some(10);
3909 cfg.hash_blake2b256_cost_base = Some(10);
3910
3911 cfg.group_ops_bls12381_decode_scalar_cost = Some(7);
3913 cfg.group_ops_bls12381_decode_g1_cost = Some(2848);
3914 cfg.group_ops_bls12381_decode_g2_cost = Some(3770);
3915 cfg.group_ops_bls12381_decode_gt_cost = Some(3068);
3916
3917 cfg.group_ops_bls12381_scalar_add_cost = Some(10);
3918 cfg.group_ops_bls12381_g1_add_cost = Some(1556);
3919 cfg.group_ops_bls12381_g2_add_cost = Some(3048);
3920 cfg.group_ops_bls12381_gt_add_cost = Some(188);
3921
3922 cfg.group_ops_bls12381_scalar_sub_cost = Some(10);
3923 cfg.group_ops_bls12381_g1_sub_cost = Some(1550);
3924 cfg.group_ops_bls12381_g2_sub_cost = Some(3019);
3925 cfg.group_ops_bls12381_gt_sub_cost = Some(497);
3926
3927 cfg.group_ops_bls12381_scalar_mul_cost = Some(11);
3928 cfg.group_ops_bls12381_g1_mul_cost = Some(4842);
3929 cfg.group_ops_bls12381_g2_mul_cost = Some(9108);
3930 cfg.group_ops_bls12381_gt_mul_cost = Some(27490);
3931
3932 cfg.group_ops_bls12381_scalar_div_cost = Some(91);
3933 cfg.group_ops_bls12381_g1_div_cost = Some(5091);
3934 cfg.group_ops_bls12381_g2_div_cost = Some(9206);
3935 cfg.group_ops_bls12381_gt_div_cost = Some(27804);
3936
3937 cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(2962);
3938 cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(8688);
3939
3940 cfg.group_ops_bls12381_g1_msm_base_cost = Some(62648);
3941 cfg.group_ops_bls12381_g2_msm_base_cost = Some(131192);
3942 cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(1333);
3943 cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(3216);
3944
3945 cfg.group_ops_bls12381_uncompressed_g1_to_g1_cost = Some(677);
3946 cfg.group_ops_bls12381_g1_to_uncompressed_g1_cost = Some(2099);
3947 cfg.group_ops_bls12381_uncompressed_g1_sum_base_cost = Some(77);
3948 cfg.group_ops_bls12381_uncompressed_g1_sum_cost_per_term = Some(26);
3949
3950 cfg.group_ops_bls12381_pairing_cost = Some(26897);
3951 cfg.group_ops_bls12381_uncompressed_g1_sum_max_terms = Some(1200);
3952
3953 cfg.validator_validate_metadata_cost_base = Some(20000);
3954 }
3955 71 => {
3956 cfg.sip_45_consensus_amplification_threshold = Some(5);
3957
3958 cfg.allowed_txn_cost_overage_burst_per_object_in_commit = Some(185_000_000);
3960 }
3961 72 => {
3962 cfg.feature_flags.convert_type_argument_error = true;
3963
3964 cfg.max_tx_gas = Some(50_000_000_000_000);
3967 cfg.max_gas_price = Some(50_000_000_000);
3969
3970 cfg.feature_flags.variant_nodes = true;
3971 }
3972 73 => {
3973 cfg.use_object_per_epoch_marker_table_v2 = Some(true);
3975
3976 if chain != Chain::Mainnet && chain != Chain::Testnet {
3977 cfg.consensus_gc_depth = Some(60);
3980 }
3981
3982 if chain != Chain::Mainnet {
3983 cfg.feature_flags.consensus_zstd_compression = true;
3985 }
3986
3987 cfg.feature_flags.consensus_smart_ancestor_selection = true;
3989 cfg.feature_flags
3991 .consensus_round_prober_probe_accepted_rounds = true;
3992
3993 cfg.feature_flags.per_object_congestion_control_mode =
3995 PerObjectCongestionControlMode::TotalGasBudgetWithCap;
3996 cfg.gas_budget_based_txn_cost_cap_factor = Some(400_000);
3997 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(37_000_000);
3998 cfg.max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit =
3999 Some(7_400_000); cfg.max_txn_cost_overage_per_object_in_commit = Some(u64::MAX);
4001 cfg.gas_budget_based_txn_cost_absolute_cap_commit_count = Some(50);
4002 cfg.allowed_txn_cost_overage_burst_per_object_in_commit = Some(370_000_000);
4003 }
4004 74 => {
4005 if chain != Chain::Mainnet && chain != Chain::Testnet {
4007 cfg.feature_flags.enable_nitro_attestation = true;
4008 }
4009 cfg.nitro_attestation_parse_base_cost = Some(53 * 50);
4010 cfg.nitro_attestation_parse_cost_per_byte = Some(50);
4011 cfg.nitro_attestation_verify_base_cost = Some(49632 * 50);
4012 cfg.nitro_attestation_verify_cost_per_cert = Some(52369 * 50);
4013
4014 cfg.feature_flags.consensus_zstd_compression = true;
4016
4017 if chain != Chain::Mainnet && chain != Chain::Testnet {
4018 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
4019 }
4020 }
4021 75 => {
4022 if chain != Chain::Mainnet {
4023 cfg.feature_flags.passkey_auth = true;
4024 }
4025 }
4026 76 => {
4027 if chain != Chain::Mainnet && chain != Chain::Testnet {
4028 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
4029 cfg.consensus_commit_rate_estimation_window_size = Some(10);
4030 }
4031 cfg.feature_flags.minimize_child_object_mutations = true;
4032
4033 if chain != Chain::Mainnet {
4034 cfg.feature_flags.accept_passkey_in_multisig = true;
4035 }
4036 }
4037 77 => {
4038 cfg.feature_flags.uncompressed_g1_group_elements = true;
4039
4040 if chain != Chain::Mainnet {
4041 cfg.consensus_gc_depth = Some(60);
4042 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
4043 }
4044 }
4045 78 => {
4046 cfg.feature_flags.move_native_context = true;
4047 cfg.tx_context_fresh_id_cost_base = Some(52);
4048 cfg.tx_context_sender_cost_base = Some(30);
4049 cfg.tx_context_epoch_cost_base = Some(30);
4050 cfg.tx_context_epoch_timestamp_ms_cost_base = Some(30);
4051 cfg.tx_context_sponsor_cost_base = Some(30);
4052 cfg.tx_context_gas_price_cost_base = Some(30);
4053 cfg.tx_context_gas_budget_cost_base = Some(30);
4054 cfg.tx_context_ids_created_cost_base = Some(30);
4055 cfg.tx_context_replace_cost_base = Some(30);
4056 cfg.gas_model_version = Some(10);
4057
4058 if chain != Chain::Mainnet {
4059 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
4060 cfg.consensus_commit_rate_estimation_window_size = Some(10);
4061
4062 cfg.feature_flags.per_object_congestion_control_mode =
4064 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4065 ExecutionTimeEstimateParams {
4066 target_utilization: 30,
4067 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4069 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4071 stored_observations_limit: u64::MAX,
4072 stake_weighted_median_threshold: 0,
4073 default_none_duration_for_new_keys: false,
4074 observations_chunk_size: None,
4075 },
4076 );
4077 }
4078 }
4079 79 => {
4080 if chain != Chain::Mainnet {
4081 cfg.feature_flags.consensus_median_based_commit_timestamp = true;
4082
4083 cfg.consensus_bad_nodes_stake_threshold = Some(30);
4086
4087 cfg.feature_flags.consensus_batched_block_sync = true;
4088
4089 cfg.feature_flags.enable_nitro_attestation = true
4091 }
4092 cfg.feature_flags.normalize_ptb_arguments = true;
4093
4094 cfg.consensus_gc_depth = Some(60);
4095 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
4096 }
4097 80 => {
4098 cfg.max_ptb_value_size = Some(1024 * 1024);
4099 }
4100 81 => {
4101 cfg.feature_flags.consensus_median_based_commit_timestamp = true;
4102 cfg.feature_flags.enforce_checkpoint_timestamp_monotonicity = true;
4103 cfg.consensus_bad_nodes_stake_threshold = Some(30)
4104 }
4105 82 => {
4106 cfg.feature_flags.max_ptb_value_size_v2 = true;
4107 }
4108 83 => {
4109 if chain == Chain::Mainnet {
4110 let aliased: [u8; 32] = Hex::decode(
4112 "0x0b2da327ba6a4cacbe75dddd50e6e8bbf81d6496e92d66af9154c61c77f7332f",
4113 )
4114 .unwrap()
4115 .try_into()
4116 .unwrap();
4117
4118 cfg.aliased_addresses.push(AliasedAddress {
4120 original: Hex::decode("0xcd8962dad278d8b50fa0f9eb0186bfa4cbdecc6d59377214c88d0286a0ac9562").unwrap().try_into().unwrap(),
4121 aliased,
4122 allowed_tx_digests: vec![
4123 Base58::decode("B2eGLFoMHgj93Ni8dAJBfqGzo8EWSTLBesZzhEpTPA4").unwrap().try_into().unwrap(),
4124 ],
4125 });
4126
4127 cfg.aliased_addresses.push(AliasedAddress {
4128 original: Hex::decode("0xe28b50cef1d633ea43d3296a3f6b67ff0312a5f1a99f0af753c85b8b5de8ff06").unwrap().try_into().unwrap(),
4129 aliased,
4130 allowed_tx_digests: vec![
4131 Base58::decode("J4QqSAgp7VrQtQpMy5wDX4QGsCSEZu3U5KuDAkbESAge").unwrap().try_into().unwrap(),
4132 ],
4133 });
4134 }
4135
4136 if chain != Chain::Mainnet {
4139 cfg.feature_flags.resolve_type_input_ids_to_defining_id = true;
4140 cfg.transfer_party_transfer_internal_cost_base = Some(52);
4141
4142 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
4144 cfg.consensus_commit_rate_estimation_window_size = Some(10);
4145 cfg.feature_flags.per_object_congestion_control_mode =
4146 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4147 ExecutionTimeEstimateParams {
4148 target_utilization: 30,
4149 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4151 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4153 stored_observations_limit: u64::MAX,
4154 stake_weighted_median_threshold: 0,
4155 default_none_duration_for_new_keys: false,
4156 observations_chunk_size: None,
4157 },
4158 );
4159
4160 cfg.feature_flags.consensus_batched_block_sync = true;
4162
4163 cfg.feature_flags.enable_nitro_attestation_upgraded_parsing = true;
4166 cfg.feature_flags.enable_nitro_attestation = true;
4167 }
4168 }
4169 84 => {
4170 if chain == Chain::Mainnet {
4171 cfg.feature_flags.resolve_type_input_ids_to_defining_id = true;
4172 cfg.transfer_party_transfer_internal_cost_base = Some(52);
4173
4174 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
4176 cfg.consensus_commit_rate_estimation_window_size = Some(10);
4177 cfg.feature_flags.per_object_congestion_control_mode =
4178 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4179 ExecutionTimeEstimateParams {
4180 target_utilization: 30,
4181 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4183 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4185 stored_observations_limit: u64::MAX,
4186 stake_weighted_median_threshold: 0,
4187 default_none_duration_for_new_keys: false,
4188 observations_chunk_size: None,
4189 },
4190 );
4191
4192 cfg.feature_flags.consensus_batched_block_sync = true;
4194
4195 cfg.feature_flags.enable_nitro_attestation_upgraded_parsing = true;
4198 cfg.feature_flags.enable_nitro_attestation = true;
4199 }
4200
4201 cfg.feature_flags.per_object_congestion_control_mode =
4203 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4204 ExecutionTimeEstimateParams {
4205 target_utilization: 30,
4206 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4208 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4210 stored_observations_limit: 20,
4211 stake_weighted_median_threshold: 0,
4212 default_none_duration_for_new_keys: false,
4213 observations_chunk_size: None,
4214 },
4215 );
4216 cfg.feature_flags.allow_unbounded_system_objects = true;
4217 }
4218 85 => {
4219 if chain != Chain::Mainnet && chain != Chain::Testnet {
4220 cfg.feature_flags.enable_party_transfer = true;
4221 }
4222
4223 cfg.feature_flags
4224 .record_consensus_determined_version_assignments_in_prologue_v2 = true;
4225 cfg.feature_flags.disallow_self_identifier = true;
4226 cfg.feature_flags.per_object_congestion_control_mode =
4227 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4228 ExecutionTimeEstimateParams {
4229 target_utilization: 50,
4230 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4232 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4234 stored_observations_limit: 20,
4235 stake_weighted_median_threshold: 0,
4236 default_none_duration_for_new_keys: false,
4237 observations_chunk_size: None,
4238 },
4239 );
4240 }
4241 86 => {
4242 cfg.feature_flags.type_tags_in_object_runtime = true;
4243 cfg.max_move_enum_variants = Some(move_core_types::VARIANT_COUNT_MAX);
4244
4245 cfg.feature_flags.per_object_congestion_control_mode =
4247 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4248 ExecutionTimeEstimateParams {
4249 target_utilization: 50,
4250 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4252 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4254 stored_observations_limit: 20,
4255 stake_weighted_median_threshold: 3334,
4256 default_none_duration_for_new_keys: false,
4257 observations_chunk_size: None,
4258 },
4259 );
4260 if chain != Chain::Mainnet {
4262 cfg.feature_flags.enable_party_transfer = true;
4263 }
4264 }
4265 87 => {
4266 if chain == Chain::Mainnet {
4267 cfg.feature_flags.record_time_estimate_processed = true;
4268 }
4269 cfg.feature_flags.better_adapter_type_resolution_errors = true;
4270 }
4271 88 => {
4272 cfg.feature_flags.record_time_estimate_processed = true;
4273 cfg.tx_context_rgp_cost_base = Some(30);
4274 cfg.feature_flags
4275 .ignore_execution_time_observations_after_certs_closed = true;
4276
4277 cfg.feature_flags.per_object_congestion_control_mode =
4280 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4281 ExecutionTimeEstimateParams {
4282 target_utilization: 50,
4283 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4285 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4287 stored_observations_limit: 20,
4288 stake_weighted_median_threshold: 3334,
4289 default_none_duration_for_new_keys: true,
4290 observations_chunk_size: None,
4291 },
4292 );
4293 }
4294 89 => {
4295 cfg.feature_flags.dependency_linkage_error = true;
4296 cfg.feature_flags.additional_multisig_checks = true;
4297 }
4298 90 => {
4299 cfg.max_gas_price_rgp_factor_for_aborted_transactions = Some(100);
4301 cfg.feature_flags.debug_fatal_on_move_invariant_violation = true;
4302 cfg.feature_flags.additional_consensus_digest_indirect_state = true;
4303 cfg.feature_flags.accept_passkey_in_multisig = true;
4304 cfg.feature_flags.passkey_auth = true;
4305 cfg.feature_flags.check_for_init_during_upgrade = true;
4306
4307 if chain != Chain::Mainnet {
4309 cfg.feature_flags.mysticeti_fastpath = true;
4310 }
4311 }
4312 91 => {
4313 cfg.feature_flags.per_command_shared_object_transfer_rules = true;
4314 }
4315 92 => {
4316 cfg.feature_flags.per_command_shared_object_transfer_rules = false;
4317 }
4318 93 => {
4319 cfg.feature_flags
4320 .consensus_checkpoint_signature_key_includes_digest = true;
4321 }
4322 94 => {
4323 cfg.feature_flags.per_object_congestion_control_mode =
4325 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4326 ExecutionTimeEstimateParams {
4327 target_utilization: 50,
4328 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4330 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4332 stored_observations_limit: 18,
4333 stake_weighted_median_threshold: 3334,
4334 default_none_duration_for_new_keys: true,
4335 observations_chunk_size: None,
4336 },
4337 );
4338
4339 cfg.feature_flags.enable_party_transfer = true;
4341 }
4342 95 => {
4343 cfg.type_name_id_base_cost = Some(52);
4344
4345 cfg.max_transactions_per_checkpoint = Some(20_000);
4347 }
4348 96 => {
4349 if chain != Chain::Mainnet && chain != Chain::Testnet {
4351 cfg.feature_flags
4352 .include_checkpoint_artifacts_digest_in_summary = true;
4353 }
4354 cfg.feature_flags.correct_gas_payment_limit_check = true;
4355 cfg.feature_flags.authority_capabilities_v2 = true;
4356 cfg.feature_flags.use_mfp_txns_in_load_initial_object_debts = true;
4357 cfg.feature_flags.cancel_for_failed_dkg_early = true;
4358 cfg.feature_flags.enable_coin_registry = true;
4359
4360 cfg.feature_flags.mysticeti_fastpath = true;
4362 }
4363 97 => {
4364 cfg.feature_flags.additional_borrow_checks = true;
4365 }
4366 98 => {
4367 cfg.event_emit_auth_stream_cost = Some(52);
4368 cfg.feature_flags.better_loader_errors = true;
4369 cfg.feature_flags.generate_df_type_layouts = true;
4370 }
4371 99 => {
4372 cfg.feature_flags.use_new_commit_handler = true;
4373 }
4374 100 => {
4375 cfg.feature_flags.private_generics_verifier_v2 = true;
4376 }
4377 101 => {
4378 cfg.feature_flags.create_root_accumulator_object = true;
4379 cfg.max_updates_per_settlement_txn = Some(100);
4380 if chain != Chain::Mainnet {
4381 cfg.feature_flags.enable_poseidon = true;
4382 }
4383 }
4384 102 => {
4385 cfg.feature_flags.per_object_congestion_control_mode =
4389 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4390 ExecutionTimeEstimateParams {
4391 target_utilization: 50,
4392 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4394 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4396 stored_observations_limit: 180,
4397 stake_weighted_median_threshold: 3334,
4398 default_none_duration_for_new_keys: true,
4399 observations_chunk_size: Some(18),
4400 },
4401 );
4402 cfg.feature_flags.deprecate_global_storage_ops = true;
4403 }
4404 103 => {}
4405 104 => {
4406 cfg.translation_per_command_base_charge = Some(1);
4407 cfg.translation_per_input_base_charge = Some(1);
4408 cfg.translation_pure_input_per_byte_charge = Some(1);
4409 cfg.translation_per_type_node_charge = Some(1);
4410 cfg.translation_per_reference_node_charge = Some(1);
4411 cfg.translation_per_linkage_entry_charge = Some(10);
4412 cfg.gas_model_version = Some(11);
4413 cfg.feature_flags.abstract_size_in_object_runtime = true;
4414 cfg.feature_flags.object_runtime_charge_cache_load_gas = true;
4415 cfg.dynamic_field_hash_type_and_key_cost_base = Some(52);
4416 cfg.dynamic_field_add_child_object_cost_base = Some(52);
4417 cfg.dynamic_field_add_child_object_value_cost_per_byte = Some(1);
4418 cfg.dynamic_field_borrow_child_object_cost_base = Some(52);
4419 cfg.dynamic_field_borrow_child_object_child_ref_cost_per_byte = Some(1);
4420 cfg.dynamic_field_remove_child_object_cost_base = Some(52);
4421 cfg.dynamic_field_remove_child_object_child_cost_per_byte = Some(1);
4422 cfg.dynamic_field_has_child_object_cost_base = Some(52);
4423 cfg.dynamic_field_has_child_object_with_ty_cost_base = Some(52);
4424 cfg.feature_flags.enable_ptb_execution_v2 = true;
4425
4426 cfg.poseidon_bn254_cost_base = Some(260);
4427
4428 cfg.feature_flags.consensus_skip_gced_accept_votes = true;
4429
4430 if chain != Chain::Mainnet {
4431 cfg.feature_flags
4432 .enable_nitro_attestation_all_nonzero_pcrs_parsing = true;
4433 }
4434
4435 cfg.feature_flags
4436 .include_cancelled_randomness_txns_in_prologue = true;
4437 }
4438 105 => {
4439 cfg.feature_flags.enable_multi_epoch_transaction_expiration = true;
4440 cfg.feature_flags.disable_preconsensus_locking = true;
4441
4442 if chain != Chain::Mainnet {
4443 cfg.feature_flags
4444 .enable_nitro_attestation_always_include_required_pcrs_parsing = true;
4445 }
4446 }
4447 106 => {
4448 cfg.accumulator_object_storage_cost = Some(7600);
4450
4451 if chain != Chain::Mainnet && chain != Chain::Testnet {
4452 cfg.feature_flags.enable_accumulators = true;
4453 cfg.feature_flags.enable_address_balance_gas_payments = true;
4454 cfg.feature_flags.enable_authenticated_event_streams = true;
4455 cfg.feature_flags.enable_object_funds_withdraw = true;
4456 }
4457 }
4458 107 => {
4459 cfg.feature_flags
4460 .consensus_skip_gced_blocks_in_direct_finalization = true;
4461
4462 if in_integration_test() {
4464 cfg.consensus_gc_depth = Some(6);
4465 cfg.consensus_max_num_transactions_in_block = Some(8);
4466 }
4467 }
4468 108 => {
4469 cfg.feature_flags.gas_rounding_halve_digits = true;
4470 cfg.feature_flags.flexible_tx_context_positions = true;
4471 cfg.feature_flags.disable_entry_point_signature_check = true;
4472
4473 if chain != Chain::Mainnet {
4474 cfg.feature_flags.address_aliases = true;
4475
4476 cfg.feature_flags.enable_accumulators = true;
4477 cfg.feature_flags.enable_address_balance_gas_payments = true;
4478 }
4479
4480 cfg.feature_flags.enable_poseidon = true;
4481 }
4482 109 => {
4483 cfg.binary_variant_handles = Some(1024);
4484 cfg.binary_variant_instantiation_handles = Some(1024);
4485 cfg.feature_flags.restrict_hot_or_not_entry_functions = true;
4486 }
4487 110 => {
4488 cfg.feature_flags
4489 .enable_nitro_attestation_all_nonzero_pcrs_parsing = true;
4490 cfg.feature_flags
4491 .enable_nitro_attestation_always_include_required_pcrs_parsing = true;
4492 if chain != Chain::Mainnet && chain != Chain::Testnet {
4493 cfg.feature_flags.split_checkpoints_in_consensus_handler = true;
4494 }
4495 cfg.feature_flags.validate_zklogin_public_identifier = true;
4496 cfg.feature_flags.fix_checkpoint_signature_mapping = true;
4497 cfg.feature_flags
4498 .consensus_always_accept_system_transactions = true;
4499 if chain != Chain::Mainnet {
4500 cfg.feature_flags.enable_object_funds_withdraw = true;
4501 }
4502 }
4503 111 => {
4504 cfg.feature_flags.validator_metadata_verify_v2 = true;
4505 }
4506 112 => {
4507 cfg.group_ops_ristretto_decode_scalar_cost = Some(7);
4508 cfg.group_ops_ristretto_decode_point_cost = Some(200);
4509 cfg.group_ops_ristretto_scalar_add_cost = Some(10);
4510 cfg.group_ops_ristretto_point_add_cost = Some(500);
4511 cfg.group_ops_ristretto_scalar_sub_cost = Some(10);
4512 cfg.group_ops_ristretto_point_sub_cost = Some(500);
4513 cfg.group_ops_ristretto_scalar_mul_cost = Some(11);
4514 cfg.group_ops_ristretto_point_mul_cost = Some(1200);
4515 cfg.group_ops_ristretto_scalar_div_cost = Some(151);
4516 cfg.group_ops_ristretto_point_div_cost = Some(2500);
4517
4518 if chain != Chain::Mainnet && chain != Chain::Testnet {
4519 cfg.feature_flags.enable_ristretto255_group_ops = true;
4520 }
4521 }
4522 113 => {
4523 cfg.feature_flags.address_balance_gas_check_rgp_at_signing = true;
4524 if chain != Chain::Mainnet && chain != Chain::Testnet {
4525 cfg.feature_flags.defer_unpaid_amplification = true;
4526 }
4527 }
4528 114 => {
4529 cfg.feature_flags.randomize_checkpoint_tx_limit_in_tests = true;
4530 cfg.feature_flags.address_balance_gas_reject_gas_coin_arg = true;
4531 if chain != Chain::Mainnet {
4532 cfg.feature_flags.split_checkpoints_in_consensus_handler = true;
4533 cfg.feature_flags.enable_authenticated_event_streams = true;
4534 cfg.feature_flags
4535 .include_checkpoint_artifacts_digest_in_summary = true;
4536 }
4537 }
4538 115 => {
4539 cfg.feature_flags.normalize_depth_formula = true;
4540 }
4541 116 => {
4542 cfg.feature_flags.gasless_transaction_drop_safety = true;
4543 cfg.feature_flags.address_aliases = true;
4544 cfg.feature_flags.relax_valid_during_for_owned_inputs = true;
4545 cfg.feature_flags.defer_unpaid_amplification = false;
4547 cfg.feature_flags.enable_display_registry = true;
4548 }
4549 117 => {}
4550 118 => {
4551 cfg.feature_flags.use_coin_party_owner = true;
4552 }
4553 119 => {
4554 cfg.execution_version = Some(4);
4556 cfg.feature_flags.address_balance_gas_reject_gas_coin_arg = false;
4557 cfg.feature_flags.merge_randomness_into_checkpoint = true;
4558 if chain != Chain::Mainnet {
4559 cfg.feature_flags.enable_gasless = true;
4560 cfg.gasless_max_computation_units = Some(50_000);
4561 cfg.gasless_allowed_token_types = Some(vec![]);
4562 cfg.feature_flags.enable_coin_reservation_obj_refs = true;
4563 cfg.feature_flags
4564 .convert_withdrawal_compatibility_ptb_arguments = true;
4565 }
4566 cfg.gasless_max_unused_inputs = Some(1);
4567 cfg.gasless_max_pure_input_bytes = Some(32);
4568 if chain == Chain::Testnet {
4569 cfg.gasless_allowed_token_types = Some(vec![(TESTNET_USDC.to_string(), 0)]);
4570 }
4571 cfg.transfer_receive_object_cost_per_byte = Some(1);
4572 cfg.transfer_receive_object_type_cost_per_byte = Some(2);
4573 }
4574 120 => {
4575 cfg.feature_flags.disallow_jump_orphans = true;
4576 }
4577 121 => {
4578 if chain != Chain::Mainnet {
4580 cfg.feature_flags.defer_unpaid_amplification = true;
4581 cfg.gasless_max_tps = Some(50);
4582 }
4583 cfg.feature_flags
4584 .early_return_receive_object_mismatched_type = true;
4585 }
4586 122 => {
4587 cfg.feature_flags.defer_unpaid_amplification = true;
4589 cfg.verify_bulletproofs_ristretto255_base_cost = Some(30000);
4591 cfg.verify_bulletproofs_ristretto255_cost_per_bit_and_commitment = Some(6500);
4592 if chain != Chain::Mainnet && chain != Chain::Testnet {
4593 cfg.feature_flags.enable_verify_bulletproofs_ristretto255 = true;
4594 }
4595 cfg.feature_flags.gasless_verify_remaining_balance = true;
4596 cfg.include_special_package_amendments = match chain {
4597 Chain::Mainnet => Some(MAINNET_LINKAGE_AMENDMENTS.clone()),
4598 Chain::Testnet => Some(TESTNET_LINKAGE_AMENDMENTS.clone()),
4599 Chain::Unknown => None,
4600 };
4601 cfg.gasless_max_tx_size_bytes = Some(16 * 1024);
4602 cfg.gasless_max_tps = Some(300);
4603 cfg.gasless_max_computation_units = Some(5_000);
4604 }
4605 123 => {
4606 cfg.gas_model_version = Some(13);
4607 }
4608 124 => {
4609 if chain != Chain::Mainnet && chain != Chain::Testnet {
4610 cfg.feature_flags.timestamp_based_epoch_close = true;
4611 }
4612 cfg.gas_model_version = Some(14);
4613 cfg.feature_flags.limit_groth16_pvk_inputs = true;
4614
4615 cfg.feature_flags.enable_accumulators = true;
4621 cfg.feature_flags.enable_address_balance_gas_payments = true;
4622 cfg.feature_flags.enable_authenticated_event_streams = true;
4623 cfg.feature_flags.enable_coin_reservation_obj_refs = true;
4624 cfg.feature_flags.enable_object_funds_withdraw = true;
4625 cfg.feature_flags
4626 .convert_withdrawal_compatibility_ptb_arguments = true;
4627 cfg.feature_flags.split_checkpoints_in_consensus_handler = true;
4628 cfg.feature_flags
4629 .include_checkpoint_artifacts_digest_in_summary = true;
4630 cfg.feature_flags.enable_gasless = true;
4631
4632 if chain == Chain::Mainnet {
4637 cfg.gasless_allowed_token_types = Some(vec![
4638 (MAINNET_USDC.to_string(), 10_000),
4639 (MAINNET_USDSUI.to_string(), 10_000),
4640 (MAINNET_SUI_USDE.to_string(), 10_000),
4641 (MAINNET_USDY.to_string(), 10_000),
4642 (MAINNET_FDUSD.to_string(), 10_000),
4643 (MAINNET_AUSD.to_string(), 10_000),
4644 (MAINNET_USDB.to_string(), 10_000),
4645 ]);
4646 }
4647 }
4648 125 => {
4649 cfg.feature_flags.granular_post_execution_checks = true;
4650 if chain != Chain::Mainnet {
4651 cfg.feature_flags.timestamp_based_epoch_close = true;
4652 }
4653 }
4654 126 => {
4655 cfg.feature_flags.early_exit_on_iffw = true;
4656 }
4657 127 => {
4658 cfg.feature_flags.always_advance_dkg_to_resolution = true;
4659
4660 cfg.verify_bulletproofs_ristretto255_base_cost = Some(23866);
4661 cfg.verify_bulletproofs_ristretto255_cost_per_bit_and_commitment = Some(1324);
4662 cfg.group_ops_ristretto_decode_scalar_cost = Some(5);
4663 cfg.group_ops_ristretto_decode_point_cost = Some(216);
4664 cfg.group_ops_ristretto_scalar_add_cost = Some(2);
4665 cfg.group_ops_ristretto_point_add_cost = Some(8);
4666 cfg.group_ops_ristretto_scalar_sub_cost = Some(2);
4667 cfg.group_ops_ristretto_point_sub_cost = Some(8);
4668 cfg.group_ops_ristretto_scalar_mul_cost = Some(5);
4669 cfg.group_ops_ristretto_point_mul_cost = Some(1763);
4670 cfg.group_ops_ristretto_scalar_div_cost = Some(557);
4671 cfg.group_ops_ristretto_point_div_cost = Some(2244);
4672
4673 if chain != Chain::Mainnet {
4674 cfg.feature_flags.enable_ristretto255_group_ops = true;
4675 cfg.feature_flags.enable_verify_bulletproofs_ristretto255 = true;
4676 }
4677
4678 cfg.feature_flags.timestamp_based_epoch_close = true;
4679 }
4680 128 => {
4681 cfg.max_generic_instantiation_type_nodes_per_function = Some(10_000);
4682 cfg.max_generic_instantiation_type_nodes_per_module = Some(500_000);
4683 cfg.binary_enum_defs = Some(200);
4684 cfg.binary_enum_def_instantiations = Some(100);
4685 }
4686 129 => {
4687 cfg.feature_flags.enable_unified_linkage = true;
4688 }
4689 130 => {
4690 cfg.feature_flags.record_net_unsettled_object_withdraws = true;
4691 cfg.feature_flags.enable_init_on_upgrade = true;
4692 cfg.epoch_close_deadline_ms = Some(120_000);
4693 cfg.scratch_add_cost_base = Some(13);
4694 cfg.scratch_read_cost_base = Some(13);
4695 cfg.scratch_read_value_cost = Some(1);
4696 cfg.scratch_remove_cost_base = Some(13);
4697 cfg.scratch_exists_cost_base = Some(13);
4698 cfg.scratch_exists_with_type_cost_base = Some(13);
4699 cfg.scratch_exists_with_type_type_cost = Some(1);
4700 let max_commands = cfg.max_programmable_tx_commands() as u64;
4701 cfg.max_scratch_pad_size = Some(16 * max_commands);
4702 if chain != Chain::Mainnet && chain != Chain::Testnet {
4704 cfg.feature_flags.zklogin_circuit_mode = 1;
4705 }
4706 }
4707 131 => {
4708 cfg.feature_flags.share_transaction_deny_config_in_consensus = true;
4709 cfg.feature_flags.framework_tx_context_mut_restrictions = true;
4710 }
4711 132 => {
4712 if chain != Chain::Mainnet && chain != Chain::Testnet {
4713 cfg.feature_flags.defer_owned_object_double_spend = true;
4714 cfg.feature_flags.create_forwarding_address_registry = true;
4715 }
4716 cfg.object_record_new_uid_from_hash_cost_base = Some(1);
4717 cfg.feature_flags
4718 .enable_order_independent_upgrade_init_linkage = true;
4719 }
4720 133 => {
4721 cfg.feature_flags
4722 .include_function_signatures_in_instantiation_limits = true;
4723 cfg.max_accumulator_type_nodes = Some(16);
4724 }
4725 134 => {
4726 if chain != Chain::Mainnet {
4733 cfg.package_original_package_id_impl_cost_base = Some(52);
4734 let package_read_cost_per_byte = cfg.obj_access_cost_read_per_byte();
4735 cfg.package_original_package_id_impl_cost_per_byte =
4736 Some(package_read_cost_per_byte);
4737
4738 cfg.consensus_max_transactions_in_block_bytes = Some(288 * 1024);
4739 cfg.consensus_max_num_transactions_in_block = Some(128);
4740 }
4741
4742 if chain == Chain::Mainnet {
4743 cfg.feature_flags.defer_unpaid_amplification = false;
4744 }
4745 }
4746 135 => {
4747 cfg.package_original_package_id_impl_cost_base = Some(52);
4750 let package_read_cost_per_byte = cfg.obj_access_cost_read_per_byte();
4751 cfg.package_original_package_id_impl_cost_per_byte =
4752 Some(package_read_cost_per_byte);
4753
4754 cfg.consensus_max_transactions_in_block_bytes = Some(288 * 1024);
4755 cfg.consensus_max_num_transactions_in_block = Some(128);
4756
4757 cfg.feature_flags.defer_unpaid_amplification = false;
4758 }
4759 136 => {
4760 cfg.feature_flags.ptb_tx_context_restrictions = true;
4761
4762 cfg.translation_per_live_reference_charge = Some(1);
4763 cfg.max_ptb_live_references = Some(64);
4764 cfg.max_ptb_returned_references = Some(16);
4765 cfg.max_ptb_total_returned_references = Some(256);
4766
4767 if chain != Chain::Mainnet && chain != Chain::Testnet {
4768 cfg.feature_flags.allowed_proposers = true;
4769 }
4770 cfg.feature_flags.harden_linkage_consistency = true;
4771
4772 cfg.package_arena_size_in_bytes = Some(10_000_000);
4773 }
4774 137 => {
4775 cfg.verify_bulletproofs_ristretto255_cost_per_bit_and_commitment = Some(621);
4776 cfg.max_bulletproofs_total_bits = Some(1024);
4777
4778 if chain != Chain::Mainnet {
4779 cfg.feature_flags.enable_allowances = true;
4780 }
4781 cfg.feature_flags.fix_ptb_generated_reads = true;
4782 cfg.feature_flags.charge_ld_const_abstract_size = true;
4783 if chain != Chain::Mainnet && chain != Chain::Testnet {
4784 cfg.feature_flags.check_object_funds_withdraw_in_execution = true;
4785 }
4786 cfg.reserve_object_funds_for_withdrawal_cost_base = Some(52);
4787 cfg.reserve_object_funds_for_withdrawal_cold_read_cost = Some(184);
4790
4791 cfg.feature_flags.allowed_proposers = true;
4792
4793 cfg.feature_flags.validate_ptb_argument_indices = true;
4794 cfg.feature_flags.memory_safety_invariant_check_v2 = true;
4795 }
4796 138 => {
4797 cfg.gas_model_version = Some(15);
4798 cfg.feature_flags.enable_allowances = true;
4799 if chain != Chain::Mainnet {
4800 cfg.feature_flags.check_object_funds_withdraw_in_execution = true;
4801 cfg.feature_flags.disable_effects_tx_dependencies = true;
4802 }
4803 cfg.feature_flags.merge_colliding_deferrals = true;
4804 }
4805 139 => {
4806 if chain != Chain::Mainnet && chain != Chain::Testnet {
4807 cfg.feature_flags.enable_forwarding_addresses = true;
4808 }
4809 cfg.storage_rebate_rate = Some(9999);
4810 }
4811 _ => panic!("unsupported version {:?}", version),
4822 }
4823 }
4824
4825 cfg
4826 }
4827
4828 pub fn apply_seeded_test_overrides(&mut self, seed: &[u8; 32]) {
4829 if !self.feature_flags.randomize_checkpoint_tx_limit_in_tests
4830 || !self.feature_flags.split_checkpoints_in_consensus_handler
4831 {
4832 return;
4833 }
4834
4835 if !mysten_common::in_test_configuration() {
4836 return;
4837 }
4838
4839 use rand::{Rng, SeedableRng, rngs::StdRng};
4840 let mut rng = StdRng::from_seed(*seed);
4841 let max_txns = rng.gen_range(10..=100u64);
4842 info!("seeded test override: max_transactions_per_checkpoint = {max_txns}");
4843 self.max_transactions_per_checkpoint = Some(max_txns);
4844 }
4845
4846 pub fn verifier_config(&self, signing_limits: Option<(usize, usize, usize)>) -> VerifierConfig {
4852 let (
4853 max_back_edges_per_function,
4854 max_back_edges_per_module,
4855 sanity_check_with_regex_reference_safety,
4856 ) = if let Some((
4857 max_back_edges_per_function,
4858 max_back_edges_per_module,
4859 sanity_check_with_regex_reference_safety,
4860 )) = signing_limits
4861 {
4862 (
4863 Some(max_back_edges_per_function),
4864 Some(max_back_edges_per_module),
4865 Some(sanity_check_with_regex_reference_safety),
4866 )
4867 } else {
4868 (None, None, None)
4869 };
4870
4871 let additional_borrow_checks = if signing_limits.is_some() {
4872 true
4874 } else {
4875 self.additional_borrow_checks()
4876 };
4877 let deprecate_global_storage_ops = if signing_limits.is_some() {
4878 true
4880 } else {
4881 self.deprecate_global_storage_ops()
4882 };
4883
4884 VerifierConfig {
4885 max_loop_depth: Some(self.max_loop_depth() as usize),
4886 max_generic_instantiation_length: Some(self.max_generic_instantiation_length() as usize),
4887 max_function_parameters: Some(self.max_function_parameters() as usize),
4888 max_basic_blocks: Some(self.max_basic_blocks() as usize),
4889 max_value_stack_size: self.max_value_stack_size() as usize,
4890 max_type_nodes: Some(self.max_type_nodes() as usize),
4891 max_generic_instantiation_type_nodes_per_function: self
4892 .max_generic_instantiation_type_nodes_per_function_as_option()
4893 .map(|v| v as usize),
4894 max_generic_instantiation_type_nodes_per_module: self
4895 .max_generic_instantiation_type_nodes_per_module_as_option()
4896 .map(|v| v as usize),
4897 include_function_signatures_in_instantiation_limits: self
4898 .include_function_signatures_in_instantiation_limits(),
4899 max_push_size: Some(self.max_push_size() as usize),
4900 max_dependency_depth: Some(self.max_dependency_depth() as usize),
4901 max_fields_in_struct: Some(self.max_fields_in_struct() as usize),
4902 max_function_definitions: Some(self.max_function_definitions() as usize),
4903 max_data_definitions: Some(self.max_struct_definitions() as usize),
4904 max_constant_vector_len: Some(self.max_move_vector_len()),
4905 max_back_edges_per_function,
4906 max_back_edges_per_module,
4907 max_basic_blocks_in_script: None,
4908 max_identifier_len: self.max_move_identifier_len_as_option(), disallow_self_identifier: self.feature_flags.disallow_self_identifier,
4910 allow_receiving_object_id: self.allow_receiving_object_id(),
4911 reject_mutable_random_on_entry_functions: self
4912 .reject_mutable_random_on_entry_functions(),
4913 bytecode_version: self.move_binary_format_version(),
4914 max_variants_in_enum: self.max_move_enum_variants_as_option(),
4915 additional_borrow_checks,
4916 better_loader_errors: self.better_loader_errors(),
4917 private_generics_verifier_v2: self.private_generics_verifier_v2(),
4918 sanity_check_with_regex_reference_safety: sanity_check_with_regex_reference_safety
4919 .map(|limit| limit as u128),
4920 deprecate_global_storage_ops,
4921 disable_entry_point_signature_check: self.disable_entry_point_signature_check(),
4922 switch_to_regex_reference_safety: false,
4923 framework_tx_context_mut_restrictions: self.framework_tx_context_mut_restrictions(),
4924 disallow_jump_orphans: self.disallow_jump_orphans(),
4925 }
4926 }
4927
4928 pub fn binary_config(
4929 &self,
4930 override_deprecate_global_storage_ops_during_deserialization: Option<bool>,
4931 ) -> BinaryConfig {
4932 let deprecate_global_storage_ops =
4933 override_deprecate_global_storage_ops_during_deserialization
4934 .unwrap_or_else(|| self.deprecate_global_storage_ops());
4935 BinaryConfig::new(
4936 self.move_binary_format_version(),
4937 self.min_move_binary_format_version_as_option()
4938 .unwrap_or(VERSION_1),
4939 self.no_extraneous_module_bytes(),
4940 deprecate_global_storage_ops,
4941 TableConfig {
4942 module_handles: self.binary_module_handles_as_option().unwrap_or(u16::MAX),
4943 datatype_handles: self.binary_struct_handles_as_option().unwrap_or(u16::MAX),
4944 function_handles: self.binary_function_handles_as_option().unwrap_or(u16::MAX),
4945 function_instantiations: self
4946 .binary_function_instantiations_as_option()
4947 .unwrap_or(u16::MAX),
4948 signatures: self.binary_signatures_as_option().unwrap_or(u16::MAX),
4949 constant_pool: self.binary_constant_pool_as_option().unwrap_or(u16::MAX),
4950 identifiers: self.binary_identifiers_as_option().unwrap_or(u16::MAX),
4951 address_identifiers: self
4952 .binary_address_identifiers_as_option()
4953 .unwrap_or(u16::MAX),
4954 struct_defs: self.binary_struct_defs_as_option().unwrap_or(u16::MAX),
4955 struct_def_instantiations: self
4956 .binary_struct_def_instantiations_as_option()
4957 .unwrap_or(u16::MAX),
4958 function_defs: self.binary_function_defs_as_option().unwrap_or(u16::MAX),
4959 field_handles: self.binary_field_handles_as_option().unwrap_or(u16::MAX),
4960 field_instantiations: self
4961 .binary_field_instantiations_as_option()
4962 .unwrap_or(u16::MAX),
4963 friend_decls: self.binary_friend_decls_as_option().unwrap_or(u16::MAX),
4964 enum_defs: self.binary_enum_defs_as_option().unwrap_or(u16::MAX),
4965 enum_def_instantiations: self
4966 .binary_enum_def_instantiations_as_option()
4967 .unwrap_or(u16::MAX),
4968 variant_handles: self.binary_variant_handles_as_option().unwrap_or(u16::MAX),
4969 variant_instantiation_handles: self
4970 .binary_variant_instantiation_handles_as_option()
4971 .unwrap_or(u16::MAX),
4972 },
4973 )
4974 }
4975
4976 pub fn apply_overrides_for_testing(
4980 override_fn: impl Fn(ProtocolVersion, Self) -> Self + Send + Sync + 'static,
4981 ) -> OverrideGuard {
4982 let mut cur = CONFIG_OVERRIDE.lock().unwrap();
4983 assert!(cur.is_none(), "config override already present");
4984 *cur = Some(Box::new(override_fn));
4985 OverrideGuard
4986 }
4987
4988 fn apply_config_override(version: ProtocolVersion, mut ret: Self) -> Self {
4989 if let Some(override_fn) = CONFIG_OVERRIDE.lock().unwrap().as_ref() {
4990 warn!(
4991 "overriding ProtocolConfig settings with custom settings (you should not see this log outside of tests)"
4992 );
4993 ret = override_fn(version, ret);
4994 }
4995 ret
4996 }
4997}
4998
4999impl ProtocolConfig {
5003 pub fn set_execution_version_for_testing(&mut self, val: u64) {
5007 let current = self.execution_version.unwrap_or(0);
5008 assert!(
5009 val >= current,
5010 "cannot downgrade execution_version from {current} to {val}: running an old \
5011 executor against a newer protocol config/framework is unsupported. To test \
5012 frozen executor behavior, start from the last protocol version of that executor \
5013 instead, so genesis loads the matching framework snapshot (see \
5014 test_address_balance_gas_v3_accumulator_sign)."
5015 );
5016 self.execution_version = Some(val);
5017 }
5018
5019 pub fn set_zklogin_circuit_mode_for_testing(&mut self, val: u64) {
5022 self.feature_flags.zklogin_circuit_mode = val
5023 }
5024
5025 pub fn set_per_object_congestion_control_mode_for_testing(
5026 &mut self,
5027 val: PerObjectCongestionControlMode,
5028 ) {
5029 self.feature_flags.per_object_congestion_control_mode = val;
5030 }
5031
5032 pub fn set_consensus_choice_for_testing(&mut self, val: ConsensusChoice) {
5033 self.feature_flags.consensus_choice = val;
5034 }
5035
5036 pub fn set_consensus_network_for_testing(&mut self, val: ConsensusNetwork) {
5037 self.feature_flags.consensus_network = val;
5038 }
5039
5040 pub fn set_zklogin_max_epoch_upper_bound_delta_for_testing(&mut self, val: Option<u64>) {
5041 self.feature_flags.zklogin_max_epoch_upper_bound_delta = val
5042 }
5043
5044 pub fn set_mysticeti_num_leaders_per_round_for_testing(&mut self, val: Option<usize>) {
5045 self.feature_flags.mysticeti_num_leaders_per_round = val;
5046 }
5047
5048 pub fn disable_accumulators_for_testing(&mut self) {
5049 self.feature_flags.enable_accumulators = false;
5050 self.feature_flags.enable_address_balance_gas_payments = false;
5051 }
5052
5053 pub fn enable_coin_reservation_for_testing(&mut self) {
5054 self.feature_flags.enable_coin_reservation_obj_refs = true;
5055 self.feature_flags
5056 .convert_withdrawal_compatibility_ptb_arguments = true;
5057 self.execution_version = Some(self.execution_version.map_or(4, |v| v.max(4)));
5060 }
5061
5062 pub fn disable_coin_reservation_for_testing(&mut self) {
5063 self.feature_flags.enable_coin_reservation_obj_refs = false;
5064 self.feature_flags
5065 .convert_withdrawal_compatibility_ptb_arguments = false;
5066 }
5067
5068 pub fn enable_address_balance_gas_payments_for_testing(&mut self) {
5069 self.feature_flags.enable_accumulators = true;
5070 self.feature_flags.allow_private_accumulator_entrypoints = true;
5071 self.feature_flags.enable_address_balance_gas_payments = true;
5072 self.feature_flags.address_balance_gas_check_rgp_at_signing = true;
5073 self.feature_flags.address_balance_gas_reject_gas_coin_arg = false;
5074 self.execution_version = Some(self.execution_version.map_or(4, |v| v.max(4)))
5075 }
5076
5077 pub fn enable_gasless_for_testing(&mut self) {
5078 self.enable_address_balance_gas_payments_for_testing();
5079 self.feature_flags.enable_gasless = true;
5080 self.feature_flags.gasless_verify_remaining_balance = true;
5081 self.gasless_max_computation_units = Some(5_000);
5082 self.gasless_allowed_token_types = Some(vec![]);
5083 self.gasless_max_tps = Some(1000);
5084 self.gasless_max_tx_size_bytes = Some(16 * 1024);
5085 }
5086
5087 pub fn disable_gasless_for_testing(&mut self) {
5088 self.feature_flags.enable_gasless = false;
5089 self.gasless_max_computation_units = None;
5090 self.gasless_allowed_token_types = None;
5091 }
5092
5093 pub fn enable_authenticated_event_streams_for_testing(&mut self) {
5094 self.feature_flags.enable_accumulators = true;
5095 self.feature_flags.enable_authenticated_event_streams = true;
5096 self.feature_flags
5097 .include_checkpoint_artifacts_digest_in_summary = true;
5098 self.feature_flags.split_checkpoints_in_consensus_handler = true;
5099 }
5100}
5101
5102type OverrideFn = dyn Fn(ProtocolVersion, ProtocolConfig) -> ProtocolConfig + Send + Sync;
5103
5104static CONFIG_OVERRIDE: Mutex<Option<Box<OverrideFn>>> = Mutex::new(None);
5105
5106#[must_use]
5107pub struct OverrideGuard;
5108
5109impl Drop for OverrideGuard {
5110 fn drop(&mut self) {
5111 info!("restoring override fn");
5112 *CONFIG_OVERRIDE.lock().unwrap() = None;
5113 }
5114}
5115
5116#[derive(PartialEq, Eq)]
5119pub enum LimitThresholdCrossed {
5120 None,
5121 Soft(u128, u128),
5122 Hard(u128, u128),
5123}
5124
5125pub fn check_limit_in_range<T: Into<V>, U: Into<V>, V: PartialOrd + Into<u128>>(
5128 x: T,
5129 soft_limit: U,
5130 hard_limit: V,
5131) -> LimitThresholdCrossed {
5132 let x: V = x.into();
5133 let soft_limit: V = soft_limit.into();
5134
5135 debug_assert!(soft_limit <= hard_limit);
5136
5137 if x >= hard_limit {
5140 LimitThresholdCrossed::Hard(x.into(), hard_limit.into())
5141 } else if x < soft_limit {
5142 LimitThresholdCrossed::None
5143 } else {
5144 LimitThresholdCrossed::Soft(x.into(), soft_limit.into())
5145 }
5146}
5147
5148#[macro_export]
5149macro_rules! check_limit {
5150 ($x:expr, $hard:expr) => {
5151 check_limit!($x, $hard, $hard)
5152 };
5153 ($x:expr, $soft:expr, $hard:expr) => {
5154 check_limit_in_range($x as u64, $soft, $hard)
5155 };
5156}
5157
5158#[macro_export]
5162macro_rules! check_limit_by_meter {
5163 ($is_metered:expr, $x:expr, $metered_limit:expr, $unmetered_hard_limit:expr, $metric:expr) => {{
5164 let (h, metered_str) = if $is_metered {
5166 ($metered_limit, "metered")
5167 } else {
5168 ($unmetered_hard_limit, "unmetered")
5170 };
5171 use sui_protocol_config::check_limit_in_range;
5172 let result = check_limit_in_range($x as u64, $metered_limit, h);
5173 match result {
5174 LimitThresholdCrossed::None => {}
5175 LimitThresholdCrossed::Soft(_, _) => {
5176 $metric.with_label_values(&[metered_str, "soft"]).inc();
5177 }
5178 LimitThresholdCrossed::Hard(_, _) => {
5179 $metric.with_label_values(&[metered_str, "hard"]).inc();
5180 }
5181 };
5182 result
5183 }};
5184}
5185
5186pub type Amendments = BTreeMap<AccountAddress, BTreeMap<AccountAddress, AccountAddress>>;
5189
5190static MAINNET_LINKAGE_AMENDMENTS: LazyLock<Arc<Amendments>> =
5191 LazyLock::new(|| parse_amendments(include_str!("mainnet_amendments.json")));
5192
5193static TESTNET_LINKAGE_AMENDMENTS: LazyLock<Arc<Amendments>> =
5194 LazyLock::new(|| parse_amendments(include_str!("testnet_amendments.json")));
5195
5196fn parse_amendments(json: &str) -> Arc<Amendments> {
5197 #[derive(serde::Deserialize)]
5198 struct AmendmentEntry {
5199 root: String,
5200 deps: Vec<DepEntry>,
5201 }
5202
5203 #[derive(serde::Deserialize)]
5204 struct DepEntry {
5205 original_id: String,
5206 version_id: String,
5207 }
5208
5209 let entries: Vec<AmendmentEntry> =
5210 serde_json::from_str(json).expect("Failed to parse amendments JSON");
5211 let mut amendments = BTreeMap::new();
5212 for entry in entries {
5213 let root_id = AccountAddress::from_hex_literal(&entry.root).unwrap();
5214 let mut dep_ids = BTreeMap::new();
5215 for dep in entry.deps {
5216 let orig_id = AccountAddress::from_hex_literal(&dep.original_id).unwrap();
5217 let upgraded_id = AccountAddress::from_hex_literal(&dep.version_id).unwrap();
5218 assert!(
5219 dep_ids.insert(orig_id, upgraded_id).is_none(),
5220 "Duplicate original ID in amendments table"
5221 );
5222 }
5223 assert!(
5224 amendments.insert(root_id, dep_ids).is_none(),
5225 "Duplicate root ID in amendments table"
5226 );
5227 }
5228 Arc::new(amendments)
5229}
5230
5231#[cfg(all(test, not(msim)))]
5232mod test {
5233 use insta::assert_yaml_snapshot;
5234
5235 use super::*;
5236
5237 #[test]
5238 fn snapshot_tests() {
5239 println!("\n============================================================================");
5240 println!("! !");
5241 println!("! IMPORTANT: never update snapshots from this test. only add new versions! !");
5242 println!("! !");
5243 println!("============================================================================\n");
5244 for chain_id in &[Chain::Unknown, Chain::Mainnet, Chain::Testnet] {
5245 let chain_str = match chain_id {
5249 Chain::Unknown => "".to_string(),
5250 _ => format!("{:?}_", chain_id),
5251 };
5252 for i in MIN_PROTOCOL_VERSION..=MAX_PROTOCOL_VERSION {
5253 let cur = ProtocolVersion::new(i);
5254 assert_yaml_snapshot!(
5255 format!("{}version_{}", chain_str, cur.as_u64()),
5256 ProtocolConfig::get_for_version(cur, *chain_id)
5257 );
5258 }
5259 }
5260 }
5261
5262 #[test]
5263 fn test_getters() {
5264 let prot: ProtocolConfig =
5265 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5266 assert_eq!(
5267 prot.max_arguments(),
5268 prot.max_arguments_as_option().unwrap()
5269 );
5270 }
5271
5272 #[test]
5273 fn test_setters() {
5274 let mut prot: ProtocolConfig =
5275 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5276 prot.set_max_arguments_for_testing(123);
5277 assert_eq!(prot.max_arguments(), 123);
5278
5279 prot.set_max_arguments_from_str_for_testing("321".to_string());
5280 assert_eq!(prot.max_arguments(), 321);
5281
5282 prot.disable_max_arguments_for_testing();
5283 assert_eq!(prot.max_arguments_as_option(), None);
5284
5285 prot.set_attr_for_testing("max_arguments".to_string(), "456".to_string());
5286 assert_eq!(prot.max_arguments(), 456);
5287 }
5288
5289 #[test]
5290 fn test_execution_version_setter_allows_upgrade() {
5291 let mut prot = ProtocolConfig::get_for_max_version_UNSAFE();
5292 let current = prot.execution_version();
5293 prot.set_execution_version_for_testing(current);
5294 prot.set_execution_version_for_testing(current + 1);
5295 assert_eq!(prot.execution_version(), current + 1);
5296 }
5297
5298 #[test]
5299 #[should_panic(expected = "cannot downgrade execution_version")]
5300 fn test_execution_version_setter_panics_on_downgrade() {
5301 let mut prot = ProtocolConfig::get_for_max_version_UNSAFE();
5302 let current = prot.execution_version();
5303 prot.set_execution_version_for_testing(current - 1);
5304 }
5305
5306 #[test]
5307 fn test_feature_flag_setter_by_string() {
5308 let mut prot: ProtocolConfig =
5309 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5310 assert!(!prot.zklogin_auth());
5311 prot.set_feature_flag_for_testing("zklogin_auth".to_string(), true);
5312 assert!(prot.zklogin_auth());
5313 prot.set_feature_flag_for_testing("zklogin_auth".to_string(), false);
5314 assert!(!prot.zklogin_auth());
5315 }
5316
5317 #[test]
5318 #[should_panic(expected = "unknown feature flag")]
5319 fn test_feature_flag_setter_unknown_flag() {
5320 let mut prot: ProtocolConfig =
5321 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5322 prot.set_feature_flag_for_testing("some random string".to_string(), true);
5323 }
5324
5325 #[test]
5326 fn test_get_for_version_if_supported_applies_test_overrides() {
5327 let before =
5328 ProtocolConfig::get_for_version_if_supported(ProtocolVersion::new(1), Chain::Unknown)
5329 .unwrap();
5330
5331 assert!(!before.enable_coin_reservation_obj_refs());
5332
5333 let _guard = ProtocolConfig::apply_overrides_for_testing(|_, mut cfg| {
5334 cfg.enable_coin_reservation_for_testing();
5335 cfg
5336 });
5337
5338 let after =
5339 ProtocolConfig::get_for_version_if_supported(ProtocolVersion::new(1), Chain::Unknown)
5340 .unwrap();
5341
5342 assert!(after.enable_coin_reservation_obj_refs());
5343 }
5344
5345 #[test]
5346 #[should_panic(expected = "unsupported version")]
5347 fn max_version_test() {
5348 let _ = ProtocolConfig::get_for_version_impl(
5351 ProtocolVersion::new(MAX_PROTOCOL_VERSION + 1),
5352 Chain::Unknown,
5353 );
5354 }
5355
5356 #[test]
5357 fn lookup_by_string_test() {
5358 let prot: ProtocolConfig =
5359 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5360 assert!(prot.lookup_attr("some random string".to_string()).is_none());
5362
5363 assert!(
5364 prot.lookup_attr("max_arguments".to_string())
5365 == Some(ProtocolConfigValue::u32(prot.max_arguments())),
5366 );
5367
5368 assert!(
5370 prot.lookup_attr("max_move_identifier_len".to_string())
5371 .is_none()
5372 );
5373
5374 let prot: ProtocolConfig =
5376 ProtocolConfig::get_for_version(ProtocolVersion::new(9), Chain::Unknown);
5377 assert!(
5378 prot.lookup_attr("max_move_identifier_len".to_string())
5379 == Some(ProtocolConfigValue::u64(prot.max_move_identifier_len()))
5380 );
5381
5382 let prot: ProtocolConfig =
5383 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5384 assert!(
5386 prot.attr_map()
5387 .get("max_move_identifier_len")
5388 .unwrap()
5389 .is_none()
5390 );
5391 assert!(
5393 prot.attr_map().get("max_arguments").unwrap()
5394 == &Some(ProtocolConfigValue::u32(prot.max_arguments()))
5395 );
5396
5397 let prot: ProtocolConfig =
5399 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5400 assert!(
5402 prot.feature_flags
5403 .lookup_attr("some random string".to_owned())
5404 .is_none()
5405 );
5406 assert!(
5407 !prot
5408 .feature_flags
5409 .attr_map()
5410 .contains_key("some random string")
5411 );
5412
5413 assert!(
5415 prot.feature_flags
5416 .lookup_attr("package_upgrades".to_owned())
5417 == Some(false)
5418 );
5419 assert!(
5420 prot.feature_flags
5421 .attr_map()
5422 .get("package_upgrades")
5423 .unwrap()
5424 == &false
5425 );
5426 let prot: ProtocolConfig =
5427 ProtocolConfig::get_for_version(ProtocolVersion::new(4), Chain::Unknown);
5428 assert!(
5430 prot.feature_flags
5431 .lookup_attr("package_upgrades".to_owned())
5432 == Some(true)
5433 );
5434 assert!(
5435 prot.feature_flags
5436 .attr_map()
5437 .get("package_upgrades")
5438 .unwrap()
5439 == &true
5440 );
5441 }
5442
5443 #[test]
5444 fn limit_range_fn_test() {
5445 let low = 100u32;
5446 let high = 10000u64;
5447
5448 assert!(check_limit!(1u8, low, high) == LimitThresholdCrossed::None);
5449 assert!(matches!(
5450 check_limit!(255u16, low, high),
5451 LimitThresholdCrossed::Soft(255u128, 100)
5452 ));
5453 assert!(matches!(
5459 check_limit!(2550000u64, low, high),
5460 LimitThresholdCrossed::Hard(2550000, 10000)
5461 ));
5462
5463 assert!(matches!(
5464 check_limit!(2550000u64, high, high),
5465 LimitThresholdCrossed::Hard(2550000, 10000)
5466 ));
5467
5468 assert!(matches!(
5469 check_limit!(1u8, high),
5470 LimitThresholdCrossed::None
5471 ));
5472
5473 assert!(check_limit!(255u16, high) == LimitThresholdCrossed::None);
5474
5475 assert!(matches!(
5476 check_limit!(2550000u64, high),
5477 LimitThresholdCrossed::Hard(2550000, 10000)
5478 ));
5479 }
5480
5481 #[test]
5482 fn linkage_amendments_load() {
5483 let mainnet = LazyLock::force(&MAINNET_LINKAGE_AMENDMENTS);
5484 let testnet = LazyLock::force(&TESTNET_LINKAGE_AMENDMENTS);
5485 assert!(!mainnet.is_empty(), "mainnet amendments must not be empty");
5486 assert!(!testnet.is_empty(), "testnet amendments must not be empty");
5487 }
5488
5489 #[test]
5490 fn render_scalar_fields_use_precision_safe_encoding() {
5491 use mysten_common::rpc_format::Unmetered;
5492
5493 let config = ProtocolConfig::get_for_max_version_UNSAFE();
5494 let rendered = config
5495 .render::<serde_json::Value>(&mut Unmetered)
5496 .expect("render should succeed");
5497
5498 let max_args = rendered
5499 .get("max_arguments")
5500 .expect("max_arguments set at max version");
5501 assert!(
5502 max_args.is_number(),
5503 "u32 should render as number, got {max_args:?}",
5504 );
5505
5506 let max_tx_size = rendered
5507 .get("max_tx_size_bytes")
5508 .expect("max_tx_size_bytes set at max version");
5509 assert!(
5510 max_tx_size.is_string(),
5511 "u64 should render as string, got {max_tx_size:?}",
5512 );
5513 }
5514
5515 #[test]
5516 fn render_includes_non_scalar_gasless_allowlist_as_json() {
5517 use mysten_common::rpc_format::Unmetered;
5518 use serde_json::json;
5519
5520 let mut config = ProtocolConfig::get_for_max_version_UNSAFE();
5521 config.set_gasless_allowed_token_types_for_testing(vec![
5522 ("0xa::usdc::USDC".to_string(), 10_000),
5523 ("0xb::usdt::USDT".to_string(), 0),
5524 ]);
5525
5526 let rendered = config
5527 .render::<serde_json::Value>(&mut Unmetered)
5528 .expect("render should succeed under Unmetered budget");
5529 let allowlist = rendered
5530 .get("gasless_allowed_token_types")
5531 .expect("entry should be present after the testing setter");
5532
5533 assert_eq!(
5536 allowlist,
5537 &json!([["0xa::usdc::USDC", "10000"], ["0xb::usdt::USDT", "0"],]),
5538 );
5539 }
5540
5541 #[test]
5542 fn render_targets_prost_value_for_grpc() {
5543 use mysten_common::rpc_format::Unmetered;
5544 use prost_types::value::Kind;
5545
5546 let mut config = ProtocolConfig::get_for_max_version_UNSAFE();
5547 config.set_gasless_allowed_token_types_for_testing(vec![(
5548 "0xa::usdc::USDC".to_string(),
5549 10_000,
5550 )]);
5551
5552 let rendered = config
5553 .render::<prost_types::Value>(&mut Unmetered)
5554 .expect("render to prost Value should succeed");
5555 let allowlist = rendered
5556 .get("gasless_allowed_token_types")
5557 .expect("entry should be present after the testing setter");
5558
5559 let Some(Kind::ListValue(outer)) = &allowlist.kind else {
5561 panic!(
5562 "expected ListValue at the top level, got {:?}",
5563 allowlist.kind
5564 );
5565 };
5566 assert_eq!(outer.values.len(), 1, "one allowlisted entry");
5567 let Some(Kind::ListValue(entry)) = &outer.values[0].kind else {
5568 panic!("expected each entry to be a ListValue");
5569 };
5570 assert_eq!(entry.values.len(), 2, "entry has (coin_type, amount)");
5571
5572 let Some(Kind::StringValue(coin_type)) = &entry.values[0].kind else {
5573 panic!("expected coin_type as StringValue");
5574 };
5575 assert_eq!(coin_type, "0xa::usdc::USDC");
5576
5577 let Some(Kind::StringValue(amount)) = &entry.values[1].kind else {
5579 panic!(
5580 "expected minimum_transfer_amount as StringValue (precision-safe u64); got {:?}",
5581 entry.values[1].kind,
5582 );
5583 };
5584 assert_eq!(amount, "10000");
5585 }
5586
5587 #[test]
5588 fn render_emits_null_for_unset_protocol_versions() {
5589 use mysten_common::rpc_format::Unmetered;
5590
5591 let config = ProtocolConfig::get_for_version(1.into(), Chain::Unknown);
5592 let rendered = config
5593 .render::<serde_json::Value>(&mut Unmetered)
5594 .expect("render should succeed");
5595 let entry = rendered
5599 .get("gasless_allowed_token_types")
5600 .expect("key should be present for every protocol version");
5601 assert!(
5602 entry.is_null(),
5603 "value should be null for pre-feature protocol version, got {entry:?}",
5604 );
5605 }
5606}