1use std::{
5 collections::{BTreeMap, BTreeSet},
6 sync::{
7 Arc, LazyLock,
8 atomic::{AtomicBool, Ordering},
9 },
10};
11
12use std::sync::Mutex;
13
14use clap::*;
15use fastcrypto::encoding::{Base58, Encoding, Hex};
16use move_binary_format::{
17 binary_config::{BinaryConfig, TableConfig},
18 file_format_common::VERSION_1,
19};
20use move_core_types::account_address::AccountAddress;
21use move_vm_config::verifier::VerifierConfig;
22use mysten_common::in_integration_test;
23use serde::{Deserialize, Serialize};
24use serde_with::skip_serializing_none;
25use sui_protocol_config_macros::{
26 ProtocolConfigAccessors, ProtocolConfigFeatureFlagsGetters, ProtocolConfigOverride,
27};
28use tracing::{info, warn};
29
30pub mod reachability;
31
32#[doc(hidden)]
35pub use antithesis_sdk::linkme;
36#[doc(hidden)]
37pub use mysten_common::assert_reachable_simtest;
38
39const MIN_PROTOCOL_VERSION: u64 = 1;
41const MAX_PROTOCOL_VERSION: u64 = 140;
42
43const TESTNET_USDC: &str =
44 "0xa1ec7fc00a6f40db9693ad1415d0c193ad3906494428cf252621037bd7117e29::usdc::USDC";
45
46const MAINNET_USDC: &str =
47 "0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC";
48const MAINNET_USDSUI: &str =
49 "0x44f838219cf67b058f3b37907b655f226153c18e33dfcd0da559a844fea9b1c1::usdsui::USDSUI";
50const MAINNET_SUI_USDE: &str =
51 "0x41d587e5336f1c86cad50d38a7136db99333bb9bda91cea4ba69115defeb1402::sui_usde::SUI_USDE";
52const MAINNET_USDY: &str =
53 "0x960b531667636f39e85867775f52f6b1f220a058c4de786905bdf761e06a56bb::usdy::USDY";
54const MAINNET_FDUSD: &str =
55 "0xf16e6b723f242ec745dfd7634ad072c42d5c1d9ac9d62a39c381303eaa57693a::fdusd::FDUSD";
56const MAINNET_AUSD: &str =
57 "0x2053d08c1e2bd02791056171aab0fd12bd7cd7efad2ab8f6b9c8902f14df2ff2::ausd::AUSD";
58const MAINNET_USDB: &str =
59 "0xe14726c336e81b32328e92afc37345d159f5b550b09fa92bd43640cfdd0a0cfd::usdb::USDB";
60
61#[derive(Copy, Clone, Debug, Hash, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)]
428pub struct ProtocolVersion(u64);
429
430impl ProtocolVersion {
431 pub const MIN: Self = Self(MIN_PROTOCOL_VERSION);
436
437 pub const MAX: Self = Self(MAX_PROTOCOL_VERSION);
438
439 #[cfg(not(msim))]
440 pub const MAX_ALLOWED: Self = Self::MAX;
441
442 #[cfg(msim)]
444 pub const MAX_ALLOWED: Self = Self(MAX_PROTOCOL_VERSION + 1);
445
446 pub fn new(v: u64) -> Self {
447 Self(v)
448 }
449
450 pub const fn as_u64(&self) -> u64 {
451 self.0
452 }
453
454 pub fn max() -> Self {
457 Self::MAX
458 }
459
460 pub fn prev(self) -> Self {
461 Self(self.0.checked_sub(1).unwrap())
462 }
463}
464
465impl From<u64> for ProtocolVersion {
466 fn from(v: u64) -> Self {
467 Self::new(v)
468 }
469}
470
471impl std::ops::Sub<u64> for ProtocolVersion {
472 type Output = Self;
473 fn sub(self, rhs: u64) -> Self::Output {
474 Self::new(self.0 - rhs)
475 }
476}
477
478impl std::ops::Add<u64> for ProtocolVersion {
479 type Output = Self;
480 fn add(self, rhs: u64) -> Self::Output {
481 Self::new(self.0 + rhs)
482 }
483}
484
485#[derive(
486 Clone, Serialize, Deserialize, Debug, Default, PartialEq, Copy, PartialOrd, Ord, Eq, ValueEnum,
487)]
488pub enum Chain {
489 Mainnet,
490 Testnet,
491 #[default]
492 Unknown,
493}
494
495impl Chain {
496 pub fn as_str(self) -> &'static str {
497 match self {
498 Chain::Mainnet => "mainnet",
499 Chain::Testnet => "testnet",
500 Chain::Unknown => "unknown",
501 }
502 }
503}
504
505pub struct Error(pub String);
506
507#[derive(Default, Clone, Serialize, Deserialize, Debug, ProtocolConfigFeatureFlagsGetters)]
510struct FeatureFlags {
511 #[serde(skip_serializing_if = "is_false")]
514 package_upgrades: bool,
515 #[serde(skip_serializing_if = "is_false")]
518 commit_root_state_digest: bool,
519 #[serde(skip_serializing_if = "is_false")]
521 advance_epoch_start_time_in_safe_mode: bool,
522 #[serde(skip_serializing_if = "is_false")]
525 loaded_child_objects_fixed: bool,
526 #[serde(skip_serializing_if = "is_false")]
529 missing_type_is_compatibility_error: bool,
530 #[serde(skip_serializing_if = "is_false")]
533 scoring_decision_with_validity_cutoff: bool,
534
535 #[serde(skip_serializing_if = "is_false")]
538 consensus_order_end_of_epoch_last: bool,
539
540 #[serde(skip_serializing_if = "is_false")]
544 consensus_slim_block_propagation: bool,
545
546 #[serde(skip_serializing_if = "is_false")]
548 disallow_adding_abilities_on_upgrade: bool,
549 #[serde(skip_serializing_if = "is_false")]
551 disable_invariant_violation_check_in_swap_loc: bool,
552 #[serde(skip_serializing_if = "is_false")]
555 advance_to_highest_supported_protocol_version: bool,
556 #[serde(skip_serializing_if = "is_false")]
558 ban_entry_init: bool,
559 #[serde(skip_serializing_if = "is_false")]
561 package_digest_hash_module: bool,
562 #[serde(skip_serializing_if = "is_false")]
564 disallow_change_struct_type_params_on_upgrade: bool,
565 #[serde(skip_serializing_if = "is_false")]
567 no_extraneous_module_bytes: bool,
568 #[serde(skip_serializing_if = "is_false")]
570 narwhal_versioned_metadata: bool,
571
572 #[serde(skip_serializing_if = "is_false")]
574 zklogin_auth: bool,
575 #[serde(skip_serializing_if = "is_zero")]
578 zklogin_circuit_mode: u64,
579 #[serde(skip_serializing_if = "ConsensusTransactionOrdering::is_none")]
581 consensus_transaction_ordering: ConsensusTransactionOrdering,
582
583 #[serde(skip_serializing_if = "is_false")]
591 simplified_unwrap_then_delete: bool,
592 #[serde(skip_serializing_if = "is_false")]
594 upgraded_multisig_supported: bool,
595 #[serde(skip_serializing_if = "is_false")]
597 txn_base_cost_as_multiplier: bool,
598
599 #[serde(skip_serializing_if = "is_false")]
601 shared_object_deletion: bool,
602
603 #[serde(skip_serializing_if = "is_false")]
605 narwhal_new_leader_election_schedule: bool,
606
607 #[serde(skip_serializing_if = "is_empty")]
609 zklogin_supported_providers: BTreeSet<String>,
610
611 #[serde(skip_serializing_if = "is_false")]
613 loaded_child_object_format: bool,
614
615 #[serde(skip_serializing_if = "is_false")]
616 #[skip_protocol_config_accessor]
617 enable_jwk_consensus_updates: bool,
618
619 #[serde(skip_serializing_if = "is_false")]
620 #[skip_protocol_config_accessor]
621 end_of_epoch_transaction_supported: bool,
622
623 #[serde(skip_serializing_if = "is_false")]
626 simple_conservation_checks: bool,
627
628 #[serde(skip_serializing_if = "is_false")]
630 loaded_child_object_format_type: bool,
631
632 #[serde(skip_serializing_if = "is_false")]
634 receive_objects: bool,
635
636 #[serde(skip_serializing_if = "is_false")]
638 consensus_checkpoint_signature_key_includes_digest: bool,
639
640 #[serde(skip_serializing_if = "is_false")]
642 random_beacon: bool,
643
644 #[serde(skip_serializing_if = "is_false")]
646 #[skip_protocol_config_accessor]
647 bridge: bool,
648
649 #[serde(skip_serializing_if = "is_false")]
650 enable_effects_v2: bool,
651
652 #[serde(skip_serializing_if = "is_false")]
654 narwhal_certificate_v2: bool,
655
656 #[serde(skip_serializing_if = "is_false")]
658 verify_legacy_zklogin_address: bool,
659
660 #[serde(skip_serializing_if = "is_false")]
662 throughput_aware_consensus_submission: bool,
663
664 #[serde(skip_serializing_if = "is_false")]
666 recompute_has_public_transfer_in_execution: bool,
667
668 #[serde(skip_serializing_if = "is_false")]
670 accept_zklogin_in_multisig: bool,
671
672 #[serde(skip_serializing_if = "is_false")]
674 accept_passkey_in_multisig: bool,
675
676 #[serde(skip_serializing_if = "is_false")]
678 validate_zklogin_public_identifier: bool,
679
680 #[serde(skip_serializing_if = "is_false")]
683 include_consensus_digest_in_prologue: bool,
684
685 #[serde(skip_serializing_if = "is_false")]
687 hardened_otw_check: bool,
688
689 #[serde(skip_serializing_if = "is_false")]
691 allow_receiving_object_id: bool,
692
693 #[serde(skip_serializing_if = "is_false")]
695 enable_poseidon: bool,
696
697 #[serde(skip_serializing_if = "is_false")]
699 enable_coin_deny_list: bool,
700
701 #[serde(skip_serializing_if = "is_false")]
703 enable_group_ops_native_functions: bool,
704
705 #[serde(skip_serializing_if = "is_false")]
707 enable_group_ops_native_function_msm: bool,
708
709 #[serde(skip_serializing_if = "is_false")]
711 enable_ristretto255_group_ops: bool,
712
713 #[serde(skip_serializing_if = "is_false")]
715 enable_verify_bulletproofs_ristretto255: bool,
716
717 #[serde(skip_serializing_if = "is_false")]
719 enable_nitro_attestation: bool,
720
721 #[serde(skip_serializing_if = "is_false")]
723 enable_nitro_attestation_upgraded_parsing: bool,
724
725 #[serde(skip_serializing_if = "is_false")]
727 enable_nitro_attestation_all_nonzero_pcrs_parsing: bool,
728
729 #[serde(skip_serializing_if = "is_false")]
731 enable_nitro_attestation_always_include_required_pcrs_parsing: bool,
732
733 #[serde(skip_serializing_if = "is_false")]
735 reject_mutable_random_on_entry_functions: bool,
736
737 #[serde(skip_serializing_if = "PerObjectCongestionControlMode::is_none")]
739 per_object_congestion_control_mode: PerObjectCongestionControlMode,
740
741 #[serde(skip_serializing_if = "ConsensusChoice::is_narwhal")]
743 consensus_choice: ConsensusChoice,
744
745 #[serde(skip_serializing_if = "ConsensusNetwork::is_anemo")]
747 consensus_network: ConsensusNetwork,
748
749 #[serde(skip_serializing_if = "is_false")]
751 correct_gas_payment_limit_check: bool,
752
753 #[serde(skip_serializing_if = "Option::is_none")]
755 zklogin_max_epoch_upper_bound_delta: Option<u64>,
756
757 #[serde(skip_serializing_if = "is_false")]
759 mysticeti_leader_scoring_and_schedule: bool,
760
761 #[serde(skip_serializing_if = "is_false")]
763 reshare_at_same_initial_version: bool,
764
765 #[serde(skip_serializing_if = "is_false")]
767 resolve_abort_locations_to_package_id: bool,
768
769 #[serde(skip_serializing_if = "is_false")]
773 mysticeti_use_committed_subdag_digest: bool,
774
775 #[serde(skip_serializing_if = "is_false")]
777 enable_vdf: bool,
778
779 #[serde(skip_serializing_if = "is_false")]
783 record_consensus_determined_version_assignments_in_prologue: bool,
784 #[serde(skip_serializing_if = "is_false")]
787 record_consensus_determined_version_assignments_in_prologue_v2: bool,
788
789 #[serde(skip_serializing_if = "is_false")]
791 fresh_vm_on_framework_upgrade: bool,
792
793 #[serde(skip_serializing_if = "is_false")]
801 prepend_prologue_tx_in_consensus_commit_in_checkpoints: bool,
802
803 #[serde(skip_serializing_if = "Option::is_none")]
805 mysticeti_num_leaders_per_round: Option<usize>,
806
807 #[serde(skip_serializing_if = "is_false")]
809 soft_bundle: bool,
810
811 #[serde(skip_serializing_if = "is_false")]
813 enable_coin_deny_list_v2: bool,
814
815 #[serde(skip_serializing_if = "is_false")]
817 passkey_auth: bool,
818
819 #[serde(skip_serializing_if = "is_false")]
824 #[skip_accessor]
825 mldsa65_auth: bool,
826
827 #[serde(skip_serializing_if = "is_false")]
829 authority_capabilities_v2: bool,
830
831 #[serde(skip_serializing_if = "is_false")]
833 rethrow_serialization_type_layout_errors: bool,
834
835 #[serde(skip_serializing_if = "is_false")]
837 consensus_distributed_vote_scoring_strategy: bool,
838
839 #[serde(skip_serializing_if = "is_false")]
841 consensus_round_prober: bool,
842
843 #[serde(skip_serializing_if = "is_false")]
845 validate_identifier_inputs: bool,
846
847 #[serde(skip_serializing_if = "is_false")]
849 disallow_self_identifier: bool,
850
851 #[serde(skip_serializing_if = "is_false")]
853 mysticeti_fastpath: bool,
854
855 #[serde(skip_serializing_if = "is_false")]
859 disable_preconsensus_locking: bool,
860
861 #[serde(skip_serializing_if = "is_false")]
863 relocate_event_module: bool,
864
865 #[serde(skip_serializing_if = "is_false")]
867 uncompressed_g1_group_elements: bool,
868
869 #[serde(skip_serializing_if = "is_false")]
870 disallow_new_modules_in_deps_only_packages: bool,
871
872 #[serde(skip_serializing_if = "is_false")]
874 consensus_smart_ancestor_selection: bool,
875
876 #[serde(skip_serializing_if = "is_false")]
878 consensus_round_prober_probe_accepted_rounds: bool,
879
880 #[serde(skip_serializing_if = "is_false")]
882 native_charging_v2: bool,
883
884 #[serde(skip_serializing_if = "is_false")]
887 #[skip_protocol_config_accessor]
888 consensus_linearize_subdag_v2: bool,
889
890 #[serde(skip_serializing_if = "is_false")]
892 convert_type_argument_error: bool,
893
894 #[serde(skip_serializing_if = "is_false")]
896 variant_nodes: bool,
897
898 #[serde(skip_serializing_if = "is_false")]
900 consensus_zstd_compression: bool,
901
902 #[serde(skip_serializing_if = "is_false")]
904 minimize_child_object_mutations: bool,
905
906 #[serde(skip_serializing_if = "is_false")]
909 record_additional_state_digest_in_prologue: bool,
910
911 #[serde(skip_serializing_if = "is_false")]
913 move_native_context: bool,
914
915 #[serde(skip_serializing_if = "is_false")]
918 #[skip_protocol_config_accessor]
919 consensus_median_based_commit_timestamp: bool,
920
921 #[serde(skip_serializing_if = "is_false")]
924 normalize_ptb_arguments: bool,
925
926 #[serde(skip_serializing_if = "is_false")]
928 consensus_batched_block_sync: bool,
929
930 #[serde(skip_serializing_if = "is_false")]
932 enforce_checkpoint_timestamp_monotonicity: bool,
933
934 #[serde(skip_serializing_if = "is_false")]
936 max_ptb_value_size_v2: bool,
937
938 #[serde(skip_serializing_if = "is_false")]
940 resolve_type_input_ids_to_defining_id: bool,
941
942 #[serde(skip_serializing_if = "is_false")]
944 enable_party_transfer: bool,
945
946 #[serde(skip_serializing_if = "is_false")]
948 allow_unbounded_system_objects: bool,
949
950 #[serde(skip_serializing_if = "is_false")]
952 type_tags_in_object_runtime: bool,
953
954 #[serde(skip_serializing_if = "is_false")]
956 enable_accumulators: bool,
957
958 #[serde(skip_serializing_if = "is_false")]
960 #[skip_protocol_config_accessor]
961 enable_coin_reservation_obj_refs: bool,
962
963 #[serde(skip_serializing_if = "is_false")]
966 create_root_accumulator_object: bool,
967
968 #[serde(skip_serializing_if = "is_false")]
970 #[skip_protocol_config_accessor]
971 enable_authenticated_event_streams: bool,
972
973 #[serde(skip_serializing_if = "is_false")]
975 enable_address_balance_gas_payments: bool,
976
977 #[serde(skip_serializing_if = "is_false")]
979 address_balance_gas_check_rgp_at_signing: bool,
980
981 #[serde(skip_serializing_if = "is_false")]
982 address_balance_gas_reject_gas_coin_arg: bool,
983
984 #[serde(skip_serializing_if = "is_false")]
986 enable_multi_epoch_transaction_expiration: bool,
987
988 #[serde(skip_serializing_if = "is_false")]
990 relax_valid_during_for_owned_inputs: bool,
991
992 #[serde(skip_serializing_if = "is_false")]
994 enable_ptb_execution_v2: bool,
995
996 #[serde(skip_serializing_if = "is_false")]
998 better_adapter_type_resolution_errors: bool,
999
1000 #[serde(skip_serializing_if = "is_false")]
1002 record_time_estimate_processed: bool,
1003
1004 #[serde(skip_serializing_if = "is_false")]
1006 dependency_linkage_error: bool,
1007
1008 #[serde(skip_serializing_if = "is_false")]
1010 additional_multisig_checks: bool,
1011
1012 #[serde(skip_serializing_if = "is_false")]
1014 ignore_execution_time_observations_after_certs_closed: bool,
1015
1016 #[serde(skip_serializing_if = "is_false")]
1020 debug_fatal_on_move_invariant_violation: bool,
1021
1022 #[serde(skip_serializing_if = "is_false")]
1025 allow_private_accumulator_entrypoints: bool,
1026
1027 #[serde(skip_serializing_if = "is_false")]
1030 additional_consensus_digest_indirect_state: bool,
1031
1032 #[serde(skip_serializing_if = "is_false")]
1034 check_for_init_during_upgrade: bool,
1035
1036 #[serde(skip_serializing_if = "is_false")]
1038 enable_init_on_upgrade: bool,
1039
1040 #[serde(skip_serializing_if = "is_false")]
1042 enable_order_independent_upgrade_init_linkage: bool,
1043
1044 #[serde(skip_serializing_if = "is_false")]
1047 harden_linkage_consistency: bool,
1048
1049 #[serde(skip_serializing_if = "is_false")]
1051 per_command_shared_object_transfer_rules: bool,
1052
1053 #[serde(skip_serializing_if = "is_false")]
1055 validate_ptb_argument_indices: bool,
1056
1057 #[serde(skip_serializing_if = "is_false")]
1059 include_checkpoint_artifacts_digest_in_summary: bool,
1060
1061 #[serde(skip_serializing_if = "is_false")]
1063 use_mfp_txns_in_load_initial_object_debts: bool,
1064
1065 #[serde(skip_serializing_if = "is_false")]
1067 cancel_for_failed_dkg_early: bool,
1068
1069 #[serde(skip_serializing_if = "is_false")]
1071 always_advance_dkg_to_resolution: bool,
1072
1073 #[serde(skip_serializing_if = "is_false")]
1075 allow_dkg_completion_after_timeout: bool,
1076
1077 #[serde(skip_serializing_if = "is_false")]
1079 enable_coin_registry: bool,
1080
1081 #[serde(skip_serializing_if = "is_false")]
1083 abstract_size_in_object_runtime: bool,
1084
1085 #[serde(skip_serializing_if = "is_false")]
1087 object_runtime_charge_cache_load_gas: bool,
1088
1089 #[serde(skip_serializing_if = "is_false")]
1091 additional_borrow_checks: bool,
1092
1093 #[serde(skip_serializing_if = "is_false")]
1095 use_new_commit_handler: bool,
1096
1097 #[serde(skip_serializing_if = "is_false")]
1099 better_loader_errors: bool,
1100
1101 #[serde(skip_serializing_if = "is_false")]
1103 generate_df_type_layouts: bool,
1104
1105 #[serde(skip_serializing_if = "is_false")]
1107 allow_references_in_ptbs: bool,
1108
1109 #[serde(skip_serializing_if = "is_false")]
1116 framework_tx_context_mut_restrictions: bool,
1117
1118 #[serde(skip_serializing_if = "is_false")]
1120 include_function_signatures_in_instantiation_limits: bool,
1121
1122 #[serde(skip_serializing_if = "is_false")]
1127 ptb_tx_context_restrictions: bool,
1128
1129 #[serde(skip_serializing_if = "is_false")]
1131 enable_display_registry: bool,
1132
1133 #[serde(skip_serializing_if = "is_false")]
1135 private_generics_verifier_v2: bool,
1136
1137 #[serde(skip_serializing_if = "is_false")]
1139 deprecate_global_storage_ops_during_deserialization: bool,
1140
1141 #[serde(skip_serializing_if = "is_false")]
1144 enable_non_exclusive_writes: bool,
1145
1146 #[serde(skip_serializing_if = "is_false")]
1148 deprecate_global_storage_ops: bool,
1149
1150 #[serde(skip_serializing_if = "is_false")]
1152 normalize_depth_formula: bool,
1153
1154 #[serde(skip_serializing_if = "is_false")]
1157 charge_ld_const_abstract_size: bool,
1158
1159 #[serde(skip_serializing_if = "is_false")]
1161 consensus_skip_gced_accept_votes: bool,
1162
1163 #[serde(skip_serializing_if = "is_false")]
1166 include_cancelled_randomness_txns_in_prologue: bool,
1167
1168 #[serde(skip_serializing_if = "is_false")]
1170 #[skip_protocol_config_accessor]
1171 address_aliases: bool,
1172
1173 #[serde(skip_serializing_if = "is_false")]
1175 create_forwarding_address_registry: bool,
1176
1177 #[serde(skip_serializing_if = "is_false")]
1179 enable_forwarding_addresses: bool,
1180
1181 #[serde(skip_serializing_if = "is_false")]
1184 fix_checkpoint_signature_mapping: bool,
1185
1186 #[serde(skip_serializing_if = "is_false")]
1188 enable_object_funds_withdraw: bool,
1189
1190 #[serde(skip_serializing_if = "is_false")]
1193 record_net_unsettled_object_withdraws: bool,
1194
1195 #[serde(skip_serializing_if = "is_false")]
1197 consensus_skip_gced_blocks_in_direct_finalization: bool,
1198
1199 #[serde(skip_serializing_if = "is_false")]
1201 gas_rounding_halve_digits: bool,
1202
1203 #[serde(skip_serializing_if = "is_false")]
1205 flexible_tx_context_positions: bool,
1206
1207 #[serde(skip_serializing_if = "is_false")]
1209 disable_entry_point_signature_check: bool,
1210
1211 #[serde(skip_serializing_if = "is_false")]
1213 convert_withdrawal_compatibility_ptb_arguments: bool,
1214
1215 #[serde(skip_serializing_if = "is_false")]
1217 restrict_hot_or_not_entry_functions: bool,
1218
1219 #[serde(skip_serializing_if = "is_false")]
1221 split_checkpoints_in_consensus_handler: bool,
1222
1223 #[serde(skip_serializing_if = "is_false")]
1225 consensus_always_accept_system_transactions: bool,
1226
1227 #[serde(skip_serializing_if = "is_false")]
1229 validator_metadata_verify_v2: bool,
1230
1231 #[serde(skip_serializing_if = "is_false")]
1234 defer_unpaid_amplification: bool,
1235
1236 #[serde(skip_serializing_if = "is_false")]
1239 defer_owned_object_double_spend: bool,
1240
1241 #[serde(skip_serializing_if = "is_false")]
1244 allowed_proposers: bool,
1245
1246 #[serde(skip_serializing_if = "is_false")]
1247 randomize_checkpoint_tx_limit_in_tests: bool,
1248
1249 #[serde(skip_serializing_if = "is_false")]
1251 gasless_transaction_drop_safety: bool,
1252
1253 #[serde(skip_serializing_if = "is_false")]
1256 merge_randomness_into_checkpoint: bool,
1257
1258 #[serde(skip_serializing_if = "is_false")]
1260 use_coin_party_owner: bool,
1261
1262 #[serde(skip_serializing_if = "is_false")]
1263 enable_gasless: bool,
1264
1265 #[serde(skip_serializing_if = "is_false")]
1266 gasless_verify_remaining_balance: bool,
1267
1268 #[serde(skip_serializing_if = "is_false")]
1269 disallow_jump_orphans: bool,
1270
1271 #[serde(skip_serializing_if = "is_false")]
1273 early_return_receive_object_mismatched_type: bool,
1274
1275 #[serde(skip_serializing_if = "is_false")]
1280 timestamp_based_epoch_close: bool,
1281
1282 #[serde(skip_serializing_if = "is_false")]
1285 limit_groth16_pvk_inputs: bool,
1286
1287 #[serde(skip_serializing_if = "is_false")]
1292 enforce_address_balance_change_invariant: bool,
1293
1294 #[serde(skip_serializing_if = "is_false")]
1296 share_transaction_deny_config_in_consensus: bool,
1297
1298 #[serde(skip_serializing_if = "is_false")]
1300 granular_post_execution_checks: bool,
1301
1302 #[serde(skip_serializing_if = "is_false")]
1304 early_exit_on_iffw: bool,
1305
1306 #[serde(skip_serializing_if = "is_false")]
1308 enable_unified_linkage: bool,
1309
1310 #[serde(skip_serializing_if = "is_false")]
1313 #[skip_protocol_config_accessor]
1314 enable_allowances: bool,
1315
1316 #[serde(skip_serializing_if = "is_false")]
1318 fix_ptb_generated_reads: bool,
1319
1320 #[serde(skip_serializing_if = "is_false")]
1321 check_object_funds_withdraw_in_execution: bool,
1322 #[serde(skip_serializing_if = "is_false")]
1324 memory_safety_invariant_check_v2: bool,
1325
1326 #[serde(skip_serializing_if = "is_false")]
1328 disable_effects_tx_dependencies: bool,
1329
1330 #[serde(skip_serializing_if = "is_false")]
1334 merge_colliding_deferrals: bool,
1335
1336 #[serde(skip_serializing_if = "is_false")]
1340 shuffle_consensus_commit_blocks: bool,
1341
1342 #[serde(skip_serializing_if = "is_false")]
1345 disable_id_leak_verifier: bool,
1346}
1347
1348fn is_false(b: &bool) -> bool {
1349 !b
1350}
1351
1352fn is_empty(b: &BTreeSet<String>) -> bool {
1353 b.is_empty()
1354}
1355
1356fn is_zero(val: &u64) -> bool {
1357 *val == 0
1358}
1359
1360#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1362pub enum ConsensusTransactionOrdering {
1363 #[default]
1365 None,
1366 ByGasPrice,
1368}
1369
1370impl ConsensusTransactionOrdering {
1371 pub fn is_none(&self) -> bool {
1372 matches!(self, ConsensusTransactionOrdering::None)
1373 }
1374}
1375
1376#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1377pub struct ExecutionTimeEstimateParams {
1378 pub target_utilization: u64,
1380 pub allowed_txn_cost_overage_burst_limit_us: u64,
1384
1385 pub randomness_scalar: u64,
1388
1389 pub max_estimate_us: u64,
1391
1392 pub stored_observations_num_included_checkpoints: u64,
1395
1396 pub stored_observations_limit: u64,
1398
1399 #[serde(skip_serializing_if = "is_zero")]
1402 pub stake_weighted_median_threshold: u64,
1403
1404 #[serde(skip_serializing_if = "is_false")]
1408 pub default_none_duration_for_new_keys: bool,
1409
1410 #[serde(skip_serializing_if = "Option::is_none")]
1412 pub observations_chunk_size: Option<u64>,
1413}
1414
1415#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1417pub enum PerObjectCongestionControlMode {
1418 #[default]
1419 None, TotalGasBudget, TotalTxCount, TotalGasBudgetWithCap, ExecutionTimeEstimate(ExecutionTimeEstimateParams), }
1425
1426impl PerObjectCongestionControlMode {
1427 pub fn is_none(&self) -> bool {
1428 matches!(self, PerObjectCongestionControlMode::None)
1429 }
1430}
1431
1432#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1434pub enum ConsensusChoice {
1435 #[default]
1436 Narwhal,
1437 SwapEachEpoch,
1438 Mysticeti,
1439}
1440
1441impl ConsensusChoice {
1442 pub fn is_narwhal(&self) -> bool {
1443 matches!(self, ConsensusChoice::Narwhal)
1444 }
1445}
1446
1447#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1449pub enum ConsensusNetwork {
1450 #[default]
1451 Anemo,
1452 Tonic,
1453}
1454
1455impl ConsensusNetwork {
1456 pub fn is_anemo(&self) -> bool {
1457 matches!(self, ConsensusNetwork::Anemo)
1458 }
1459}
1460
1461#[skip_serializing_none]
1493#[derive(Clone, Serialize, Debug, ProtocolConfigAccessors, ProtocolConfigOverride)]
1494pub struct ProtocolConfig {
1495 pub version: ProtocolVersion,
1496
1497 #[serde(skip)]
1502 chain: Chain,
1503
1504 feature_flags: FeatureFlags,
1505
1506 max_tx_size_bytes: Option<u64>,
1509
1510 max_input_objects: Option<u64>,
1512
1513 max_size_written_objects: Option<u64>,
1517 max_size_written_objects_system_tx: Option<u64>,
1520
1521 max_serialized_tx_effects_size_bytes: Option<u64>,
1523
1524 max_serialized_tx_effects_size_bytes_system_tx: Option<u64>,
1526
1527 max_gas_payment_objects: Option<u32>,
1529
1530 max_modules_in_publish: Option<u32>,
1532
1533 max_package_dependencies: Option<u32>,
1535
1536 max_arguments: Option<u32>,
1539
1540 max_type_arguments: Option<u32>,
1542
1543 max_type_argument_depth: Option<u32>,
1545
1546 max_pure_argument_size: Option<u32>,
1548
1549 max_programmable_tx_commands: Option<u32>,
1551
1552 move_binary_format_version: Option<u32>,
1555 min_move_binary_format_version: Option<u32>,
1556
1557 binary_module_handles: Option<u16>,
1559 binary_struct_handles: Option<u16>,
1560 binary_function_handles: Option<u16>,
1561 binary_function_instantiations: Option<u16>,
1562 binary_signatures: Option<u16>,
1563 binary_constant_pool: Option<u16>,
1564 binary_identifiers: Option<u16>,
1565 binary_address_identifiers: Option<u16>,
1566 binary_struct_defs: Option<u16>,
1567 binary_struct_def_instantiations: Option<u16>,
1568 binary_function_defs: Option<u16>,
1569 binary_field_handles: Option<u16>,
1570 binary_field_instantiations: Option<u16>,
1571 binary_friend_decls: Option<u16>,
1572 binary_enum_defs: Option<u16>,
1573 binary_enum_def_instantiations: Option<u16>,
1574 binary_variant_handles: Option<u16>,
1575 binary_variant_instantiation_handles: Option<u16>,
1576
1577 max_move_object_size: Option<u64>,
1579
1580 max_move_package_size: Option<u64>,
1583
1584 max_publish_or_upgrade_per_ptb: Option<u64>,
1586
1587 max_tx_gas: Option<u64>,
1589
1590 max_gas_price: Option<u64>,
1592
1593 max_gas_price_rgp_factor_for_aborted_transactions: Option<u64>,
1596
1597 max_gas_computation_bucket: Option<u64>,
1599
1600 gas_rounding_step: Option<u64>,
1602
1603 max_loop_depth: Option<u64>,
1605
1606 max_generic_instantiation_length: Option<u64>,
1608
1609 max_function_parameters: Option<u64>,
1611
1612 max_basic_blocks: Option<u64>,
1614
1615 max_value_stack_size: Option<u64>,
1617
1618 max_type_nodes: Option<u64>,
1620
1621 max_generic_instantiation_type_nodes_per_function: Option<u64>,
1623
1624 max_generic_instantiation_type_nodes_per_module: Option<u64>,
1626
1627 max_accumulator_type_nodes: Option<u64>,
1629
1630 max_push_size: Option<u64>,
1632
1633 max_struct_definitions: Option<u64>,
1635
1636 max_function_definitions: Option<u64>,
1638
1639 max_fields_in_struct: Option<u64>,
1641
1642 max_dependency_depth: Option<u64>,
1644
1645 max_num_event_emit: Option<u64>,
1647
1648 max_num_new_move_object_ids: Option<u64>,
1650
1651 max_num_new_move_object_ids_system_tx: Option<u64>,
1653
1654 max_num_deleted_move_object_ids: Option<u64>,
1656
1657 max_num_deleted_move_object_ids_system_tx: Option<u64>,
1659
1660 max_num_transferred_move_object_ids: Option<u64>,
1662
1663 max_num_transferred_move_object_ids_system_tx: Option<u64>,
1665
1666 max_event_emit_size: Option<u64>,
1668
1669 max_event_emit_size_total: Option<u64>,
1671
1672 max_move_vector_len: Option<u64>,
1674
1675 max_move_identifier_len: Option<u64>,
1677
1678 max_move_value_depth: Option<u64>,
1680
1681 package_arena_size_in_bytes: Option<u64>,
1684
1685 max_move_enum_variants: Option<u64>,
1687
1688 max_back_edges_per_function: Option<u64>,
1690
1691 max_back_edges_per_module: Option<u64>,
1693
1694 max_verifier_meter_ticks_per_function: Option<u64>,
1696
1697 max_meter_ticks_per_module: Option<u64>,
1699
1700 max_meter_ticks_per_package: Option<u64>,
1702
1703 object_runtime_max_num_cached_objects: Option<u64>,
1707
1708 object_runtime_max_num_cached_objects_system_tx: Option<u64>,
1710
1711 object_runtime_max_num_store_entries: Option<u64>,
1713
1714 object_runtime_max_num_store_entries_system_tx: Option<u64>,
1716
1717 base_tx_cost_fixed: Option<u64>,
1720
1721 package_publish_cost_fixed: Option<u64>,
1724
1725 base_tx_cost_per_byte: Option<u64>,
1728
1729 package_publish_cost_per_byte: Option<u64>,
1731
1732 obj_access_cost_read_per_byte: Option<u64>,
1734
1735 obj_access_cost_read_per_package_kb: Option<u64>,
1738
1739 obj_access_cost_mutate_per_byte: Option<u64>,
1741
1742 obj_access_cost_delete_per_byte: Option<u64>,
1744
1745 obj_access_cost_verify_per_byte: Option<u64>,
1755
1756 max_type_to_layout_nodes: Option<u64>,
1758
1759 max_ptb_value_size: Option<u64>,
1761
1762 gas_model_version: Option<u64>,
1765
1766 obj_data_cost_refundable: Option<u64>,
1769
1770 obj_metadata_cost_non_refundable: Option<u64>,
1774
1775 storage_rebate_rate: Option<u64>,
1781
1782 storage_fund_reinvest_rate: Option<u64>,
1785
1786 reward_slashing_rate: Option<u64>,
1789
1790 storage_gas_price: Option<u64>,
1792
1793 accumulator_object_storage_cost: Option<u64>,
1795
1796 max_transactions_per_checkpoint: Option<u64>,
1801
1802 max_checkpoint_size_bytes: Option<u64>,
1806
1807 buffer_stake_for_protocol_upgrade_bps: Option<u64>,
1812
1813 address_from_bytes_cost_base: Option<u64>,
1818 address_to_u256_cost_base: Option<u64>,
1820 address_from_u256_cost_base: Option<u64>,
1822
1823 config_read_setting_impl_cost_base: Option<u64>,
1828 config_read_setting_impl_cost_per_byte: Option<u64>,
1829
1830 package_original_package_id_impl_cost_base: Option<u64>,
1831 package_original_package_id_impl_cost_per_byte: Option<u64>,
1832
1833 dynamic_field_hash_type_and_key_cost_base: Option<u64>,
1836 dynamic_field_hash_type_and_key_type_cost_per_byte: Option<u64>,
1837 dynamic_field_hash_type_and_key_value_cost_per_byte: Option<u64>,
1838 dynamic_field_hash_type_and_key_type_tag_cost_per_byte: Option<u64>,
1839 dynamic_field_add_child_object_cost_base: Option<u64>,
1841 dynamic_field_add_child_object_type_cost_per_byte: Option<u64>,
1842 dynamic_field_add_child_object_value_cost_per_byte: Option<u64>,
1843 dynamic_field_add_child_object_struct_tag_cost_per_byte: Option<u64>,
1844 dynamic_field_borrow_child_object_cost_base: Option<u64>,
1846 dynamic_field_borrow_child_object_child_ref_cost_per_byte: Option<u64>,
1847 dynamic_field_borrow_child_object_type_cost_per_byte: Option<u64>,
1848 dynamic_field_remove_child_object_cost_base: Option<u64>,
1850 dynamic_field_remove_child_object_child_cost_per_byte: Option<u64>,
1851 dynamic_field_remove_child_object_type_cost_per_byte: Option<u64>,
1852 dynamic_field_has_child_object_cost_base: Option<u64>,
1854 dynamic_field_has_child_object_with_ty_cost_base: Option<u64>,
1856 dynamic_field_has_child_object_with_ty_type_cost_per_byte: Option<u64>,
1857 dynamic_field_has_child_object_with_ty_type_tag_cost_per_byte: Option<u64>,
1858
1859 scratch_add_cost_base: Option<u64>,
1862 scratch_read_cost_base: Option<u64>,
1864 scratch_read_value_cost: Option<u64>,
1865 scratch_remove_cost_base: Option<u64>,
1867 scratch_exists_cost_base: Option<u64>,
1869 scratch_exists_with_type_cost_base: Option<u64>,
1871 scratch_exists_with_type_type_cost: Option<u64>,
1872 max_scratch_pad_size: Option<u64>,
1874
1875 event_emit_cost_base: Option<u64>,
1878 event_emit_value_size_derivation_cost_per_byte: Option<u64>,
1879 event_emit_tag_size_derivation_cost_per_byte: Option<u64>,
1880 event_emit_output_cost_per_byte: Option<u64>,
1881 event_emit_auth_stream_cost: Option<u64>,
1882
1883 reserve_object_funds_for_withdrawal_cost_base: Option<u64>,
1886 reserve_object_funds_for_withdrawal_cold_read_cost: Option<u64>,
1888
1889 object_borrow_uid_cost_base: Option<u64>,
1892 object_delete_impl_cost_base: Option<u64>,
1894 object_record_new_uid_cost_base: Option<u64>,
1896 object_record_new_uid_from_hash_cost_base: Option<u64>,
1899
1900 transfer_transfer_internal_cost_base: Option<u64>,
1903 transfer_party_transfer_internal_cost_base: Option<u64>,
1905 transfer_freeze_object_cost_base: Option<u64>,
1907 transfer_share_object_cost_base: Option<u64>,
1909 transfer_receive_object_cost_base: Option<u64>,
1912 transfer_receive_object_cost_per_byte: Option<u64>,
1913 transfer_receive_object_type_cost_per_byte: Option<u64>,
1914
1915 tx_context_derive_id_cost_base: Option<u64>,
1918 tx_context_fresh_id_cost_base: Option<u64>,
1919 tx_context_sender_cost_base: Option<u64>,
1920 tx_context_epoch_cost_base: Option<u64>,
1921 tx_context_epoch_timestamp_ms_cost_base: Option<u64>,
1922 tx_context_sponsor_cost_base: Option<u64>,
1923 tx_context_rgp_cost_base: Option<u64>,
1924 tx_context_gas_price_cost_base: Option<u64>,
1925 tx_context_gas_budget_cost_base: Option<u64>,
1926 tx_context_ids_created_cost_base: Option<u64>,
1927 tx_context_replace_cost_base: Option<u64>,
1928
1929 types_is_one_time_witness_cost_base: Option<u64>,
1932 types_is_one_time_witness_type_tag_cost_per_byte: Option<u64>,
1933 types_is_one_time_witness_type_cost_per_byte: Option<u64>,
1934
1935 validator_validate_metadata_cost_base: Option<u64>,
1938 validator_validate_metadata_data_cost_per_byte: Option<u64>,
1939
1940 crypto_invalid_arguments_cost: Option<u64>,
1942 bls12381_bls12381_min_sig_verify_cost_base: Option<u64>,
1944 bls12381_bls12381_min_sig_verify_msg_cost_per_byte: Option<u64>,
1945 bls12381_bls12381_min_sig_verify_msg_cost_per_block: Option<u64>,
1946
1947 bls12381_bls12381_min_pk_verify_cost_base: Option<u64>,
1949 bls12381_bls12381_min_pk_verify_msg_cost_per_byte: Option<u64>,
1950 bls12381_bls12381_min_pk_verify_msg_cost_per_block: Option<u64>,
1951
1952 ecdsa_k1_ecrecover_keccak256_cost_base: Option<u64>,
1954 ecdsa_k1_ecrecover_keccak256_msg_cost_per_byte: Option<u64>,
1955 ecdsa_k1_ecrecover_keccak256_msg_cost_per_block: Option<u64>,
1956 ecdsa_k1_ecrecover_sha256_cost_base: Option<u64>,
1957 ecdsa_k1_ecrecover_sha256_msg_cost_per_byte: Option<u64>,
1958 ecdsa_k1_ecrecover_sha256_msg_cost_per_block: Option<u64>,
1959
1960 ecdsa_k1_decompress_pubkey_cost_base: Option<u64>,
1962
1963 ecdsa_k1_secp256k1_verify_keccak256_cost_base: Option<u64>,
1965 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_byte: Option<u64>,
1966 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_block: Option<u64>,
1967 ecdsa_k1_secp256k1_verify_sha256_cost_base: Option<u64>,
1968 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_byte: Option<u64>,
1969 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_block: Option<u64>,
1970
1971 ecdsa_r1_ecrecover_keccak256_cost_base: Option<u64>,
1973 ecdsa_r1_ecrecover_keccak256_msg_cost_per_byte: Option<u64>,
1974 ecdsa_r1_ecrecover_keccak256_msg_cost_per_block: Option<u64>,
1975 ecdsa_r1_ecrecover_sha256_cost_base: Option<u64>,
1976 ecdsa_r1_ecrecover_sha256_msg_cost_per_byte: Option<u64>,
1977 ecdsa_r1_ecrecover_sha256_msg_cost_per_block: Option<u64>,
1978
1979 ecdsa_r1_secp256r1_verify_keccak256_cost_base: Option<u64>,
1981 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_byte: Option<u64>,
1982 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_block: Option<u64>,
1983 ecdsa_r1_secp256r1_verify_sha256_cost_base: Option<u64>,
1984 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_byte: Option<u64>,
1985 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_block: Option<u64>,
1986
1987 ecvrf_ecvrf_verify_cost_base: Option<u64>,
1989 ecvrf_ecvrf_verify_alpha_string_cost_per_byte: Option<u64>,
1990 ecvrf_ecvrf_verify_alpha_string_cost_per_block: Option<u64>,
1991
1992 ed25519_ed25519_verify_cost_base: Option<u64>,
1994 ed25519_ed25519_verify_msg_cost_per_byte: Option<u64>,
1995 ed25519_ed25519_verify_msg_cost_per_block: Option<u64>,
1996
1997 groth16_prepare_verifying_key_bls12381_cost_base: Option<u64>,
1999 groth16_prepare_verifying_key_bn254_cost_base: Option<u64>,
2000
2001 groth16_verify_groth16_proof_internal_bls12381_cost_base: Option<u64>,
2003 groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input: Option<u64>,
2004 groth16_verify_groth16_proof_internal_bn254_cost_base: Option<u64>,
2005 groth16_verify_groth16_proof_internal_bn254_cost_per_public_input: Option<u64>,
2006 groth16_verify_groth16_proof_internal_public_input_cost_per_byte: Option<u64>,
2007
2008 hash_blake2b256_cost_base: Option<u64>,
2010 hash_blake2b256_data_cost_per_byte: Option<u64>,
2011 hash_blake2b256_data_cost_per_block: Option<u64>,
2012
2013 hash_keccak256_cost_base: Option<u64>,
2015 hash_keccak256_data_cost_per_byte: Option<u64>,
2016 hash_keccak256_data_cost_per_block: Option<u64>,
2017
2018 poseidon_bn254_cost_base: Option<u64>,
2020 poseidon_bn254_cost_per_block: Option<u64>,
2021
2022 group_ops_bls12381_decode_scalar_cost: Option<u64>,
2024 group_ops_bls12381_decode_g1_cost: Option<u64>,
2025 group_ops_bls12381_decode_g2_cost: Option<u64>,
2026 group_ops_bls12381_decode_gt_cost: Option<u64>,
2027 group_ops_bls12381_scalar_add_cost: Option<u64>,
2028 group_ops_bls12381_g1_add_cost: Option<u64>,
2029 group_ops_bls12381_g2_add_cost: Option<u64>,
2030 group_ops_bls12381_gt_add_cost: Option<u64>,
2031 group_ops_bls12381_scalar_sub_cost: Option<u64>,
2032 group_ops_bls12381_g1_sub_cost: Option<u64>,
2033 group_ops_bls12381_g2_sub_cost: Option<u64>,
2034 group_ops_bls12381_gt_sub_cost: Option<u64>,
2035 group_ops_bls12381_scalar_mul_cost: Option<u64>,
2036 group_ops_bls12381_g1_mul_cost: Option<u64>,
2037 group_ops_bls12381_g2_mul_cost: Option<u64>,
2038 group_ops_bls12381_gt_mul_cost: Option<u64>,
2039 group_ops_bls12381_scalar_div_cost: Option<u64>,
2040 group_ops_bls12381_g1_div_cost: Option<u64>,
2041 group_ops_bls12381_g2_div_cost: Option<u64>,
2042 group_ops_bls12381_gt_div_cost: Option<u64>,
2043 group_ops_bls12381_g1_hash_to_base_cost: Option<u64>,
2044 group_ops_bls12381_g2_hash_to_base_cost: Option<u64>,
2045 group_ops_bls12381_g1_hash_to_cost_per_byte: Option<u64>,
2046 group_ops_bls12381_g2_hash_to_cost_per_byte: Option<u64>,
2047 group_ops_bls12381_g1_msm_base_cost: Option<u64>,
2048 group_ops_bls12381_g2_msm_base_cost: Option<u64>,
2049 group_ops_bls12381_g1_msm_base_cost_per_input: Option<u64>,
2050 group_ops_bls12381_g2_msm_base_cost_per_input: Option<u64>,
2051 group_ops_bls12381_msm_max_len: Option<u32>,
2052 group_ops_bls12381_pairing_cost: Option<u64>,
2053 group_ops_bls12381_g1_to_uncompressed_g1_cost: Option<u64>,
2054 group_ops_bls12381_uncompressed_g1_to_g1_cost: Option<u64>,
2055 group_ops_bls12381_uncompressed_g1_sum_base_cost: Option<u64>,
2056 group_ops_bls12381_uncompressed_g1_sum_cost_per_term: Option<u64>,
2057 group_ops_bls12381_uncompressed_g1_sum_max_terms: Option<u64>,
2058
2059 group_ops_ristretto_decode_scalar_cost: Option<u64>,
2060 group_ops_ristretto_decode_point_cost: Option<u64>,
2061 group_ops_ristretto_scalar_add_cost: Option<u64>,
2062 group_ops_ristretto_point_add_cost: Option<u64>,
2063 group_ops_ristretto_scalar_sub_cost: Option<u64>,
2064 group_ops_ristretto_point_sub_cost: Option<u64>,
2065 group_ops_ristretto_scalar_mul_cost: Option<u64>,
2066 group_ops_ristretto_point_mul_cost: Option<u64>,
2067 group_ops_ristretto_scalar_div_cost: Option<u64>,
2068 group_ops_ristretto_point_div_cost: Option<u64>,
2069
2070 verify_bulletproofs_ristretto255_base_cost: Option<u64>,
2071 verify_bulletproofs_ristretto255_cost_per_bit_and_commitment: Option<u64>,
2072 max_bulletproofs_total_bits: Option<u64>,
2075
2076 hmac_hmac_sha3_256_cost_base: Option<u64>,
2078 hmac_hmac_sha3_256_input_cost_per_byte: Option<u64>,
2079 hmac_hmac_sha3_256_input_cost_per_block: Option<u64>,
2080
2081 check_zklogin_id_cost_base: Option<u64>,
2083 check_zklogin_issuer_cost_base: Option<u64>,
2085
2086 vdf_verify_vdf_cost: Option<u64>,
2087 vdf_hash_to_input_cost: Option<u64>,
2088
2089 nitro_attestation_parse_base_cost: Option<u64>,
2091 nitro_attestation_parse_cost_per_byte: Option<u64>,
2092 nitro_attestation_verify_base_cost: Option<u64>,
2093 nitro_attestation_verify_cost_per_cert: Option<u64>,
2094
2095 bcs_per_byte_serialized_cost: Option<u64>,
2097 bcs_legacy_min_output_size_cost: Option<u64>,
2098 bcs_failure_cost: Option<u64>,
2099
2100 hash_sha2_256_base_cost: Option<u64>,
2101 hash_sha2_256_per_byte_cost: Option<u64>,
2102 hash_sha2_256_legacy_min_input_len_cost: Option<u64>,
2103 hash_sha3_256_base_cost: Option<u64>,
2104 hash_sha3_256_per_byte_cost: Option<u64>,
2105 hash_sha3_256_legacy_min_input_len_cost: Option<u64>,
2106 type_name_get_base_cost: Option<u64>,
2107 type_name_get_per_byte_cost: Option<u64>,
2108 type_name_id_base_cost: Option<u64>,
2109
2110 string_check_utf8_base_cost: Option<u64>,
2111 string_check_utf8_per_byte_cost: Option<u64>,
2112 string_is_char_boundary_base_cost: Option<u64>,
2113 string_sub_string_base_cost: Option<u64>,
2114 string_sub_string_per_byte_cost: Option<u64>,
2115 string_index_of_base_cost: Option<u64>,
2116 string_index_of_per_byte_pattern_cost: Option<u64>,
2117 string_index_of_per_byte_searched_cost: Option<u64>,
2118
2119 vector_empty_base_cost: Option<u64>,
2120 vector_length_base_cost: Option<u64>,
2121 vector_push_back_base_cost: Option<u64>,
2122 vector_push_back_legacy_per_abstract_memory_unit_cost: Option<u64>,
2123 vector_borrow_base_cost: Option<u64>,
2124 vector_pop_back_base_cost: Option<u64>,
2125 vector_destroy_empty_base_cost: Option<u64>,
2126 vector_swap_base_cost: Option<u64>,
2127 vector_reverse_base_cost: Option<u64>,
2128 vector_reverse_per_elem_cost: Option<u64>,
2129 vector_keep_range_base_cost: Option<u64>,
2130 vector_keep_range_per_dropped_elem_cost: Option<u64>,
2131 vector_keep_range_per_moved_elem_cost: Option<u64>,
2132 vector_copy_range_base_cost: Option<u64>,
2133 vector_replace_range_base_cost: Option<u64>,
2134 vector_replace_range_per_elem_cost: Option<u64>,
2135 debug_print_base_cost: Option<u64>,
2136 debug_print_stack_trace_base_cost: Option<u64>,
2137
2138 #[custom_setter]
2148 execution_version: Option<u64>,
2149
2150 consensus_bad_nodes_stake_threshold: Option<u64>,
2154
2155 max_jwk_votes_per_validator_per_epoch: Option<u64>,
2156 max_age_of_jwk_in_epochs: Option<u64>,
2160
2161 random_beacon_reduction_allowed_delta: Option<u16>,
2165
2166 random_beacon_reduction_lower_bound: Option<u32>,
2169
2170 random_beacon_dkg_timeout_round: Option<u32>,
2173
2174 random_beacon_min_round_interval_ms: Option<u64>,
2176
2177 random_beacon_dkg_version: Option<u64>,
2180
2181 consensus_max_transaction_size_bytes: Option<u64>,
2184 consensus_max_transactions_in_block_bytes: Option<u64>,
2186 consensus_max_num_transactions_in_block: Option<u64>,
2188
2189 consensus_voting_rounds: Option<u32>,
2191
2192 max_accumulated_txn_cost_per_object_in_narwhal_commit: Option<u64>,
2194
2195 max_deferral_rounds_for_congestion_control: Option<u64>,
2198
2199 epoch_close_deadline_ms: Option<u64>,
2204
2205 max_txn_cost_overage_per_object_in_commit: Option<u64>,
2207
2208 allowed_txn_cost_overage_burst_per_object_in_commit: Option<u64>,
2210
2211 min_checkpoint_interval_ms: Option<u64>,
2213
2214 checkpoint_summary_version_specific_data: Option<u64>,
2216
2217 max_soft_bundle_size: Option<u64>,
2219
2220 bridge_should_try_to_finalize_committee: Option<bool>,
2224
2225 max_accumulated_txn_cost_per_object_in_mysticeti_commit: Option<u64>,
2231
2232 max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit: Option<u64>,
2235
2236 consensus_gc_depth: Option<u32>,
2239
2240 gas_budget_based_txn_cost_cap_factor: Option<u64>,
2242
2243 gas_budget_based_txn_cost_absolute_cap_commit_count: Option<u64>,
2245
2246 sip_45_consensus_amplification_threshold: Option<u64>,
2249
2250 use_object_per_epoch_marker_table_v2: Option<bool>,
2253
2254 consensus_commit_rate_estimation_window_size: Option<u32>,
2256
2257 #[serde(skip_serializing_if = "Vec::is_empty")]
2261 aliased_addresses: Vec<AliasedAddress>,
2262
2263 translation_per_command_base_charge: Option<u64>,
2266
2267 translation_per_input_base_charge: Option<u64>,
2270
2271 translation_pure_input_per_byte_charge: Option<u64>,
2273
2274 translation_per_type_node_charge: Option<u64>,
2278
2279 translation_per_reference_node_charge: Option<u64>,
2282
2283 translation_per_linkage_entry_charge: Option<u64>,
2286
2287 max_updates_per_settlement_txn: Option<u32>,
2289
2290 gasless_max_computation_units: Option<u64>,
2292
2293 gasless_allowed_token_types: Option<Vec<(String, u64)>>,
2295
2296 gasless_max_unused_inputs: Option<u64>,
2300
2301 gasless_max_pure_input_bytes: Option<u64>,
2304
2305 gasless_max_tps: Option<u64>,
2307
2308 #[serde(skip_serializing_if = "Option::is_none")]
2309 #[skip_accessor]
2310 include_special_package_amendments: Option<Arc<Amendments>>,
2311
2312 gasless_max_tx_size_bytes: Option<u64>,
2315
2316 translation_per_live_reference_charge: Option<u64>,
2319
2320 max_ptb_live_references: Option<u64>,
2323
2324 max_ptb_returned_references: Option<u64>,
2327
2328 max_ptb_total_returned_references: Option<u64>,
2331}
2332
2333#[derive(Clone, Serialize, Deserialize, Debug)]
2335pub struct AliasedAddress {
2336 pub original: [u8; 32],
2338 pub aliased: [u8; 32],
2340 pub allowed_tx_digests: Vec<[u8; 32]>,
2342}
2343
2344impl ProtocolConfig {
2346 pub fn chain(&self) -> Chain {
2348 self.chain
2349 }
2350
2351 pub fn check_package_upgrades_supported(&self) -> Result<(), Error> {
2364 if self.feature_flags.package_upgrades {
2365 Ok(())
2366 } else {
2367 Err(Error(format!(
2368 "package upgrades are not supported at {:?}",
2369 self.version
2370 )))
2371 }
2372 }
2373
2374 pub fn zklogin_supported_providers(&self) -> &BTreeSet<String> {
2375 &self.feature_flags.zklogin_supported_providers
2376 }
2377
2378 pub fn zklogin_circuit_mode(&self) -> u64 {
2381 self.feature_flags.zklogin_circuit_mode
2382 }
2383
2384 pub fn consensus_transaction_ordering(&self) -> ConsensusTransactionOrdering {
2385 self.feature_flags.consensus_transaction_ordering
2386 }
2387
2388 pub fn mldsa65_auth(&self) -> bool {
2390 self.feature_flags.mldsa65_auth
2391 }
2392
2393 pub fn set_mldsa65_auth_for_testing(&mut self, val: bool) {
2394 self.feature_flags.mldsa65_auth = val;
2395 }
2396
2397 pub fn enable_jwk_consensus_updates(&self) -> bool {
2398 let ret = self.feature_flags.enable_jwk_consensus_updates;
2399 if ret {
2400 assert!(self.feature_flags.end_of_epoch_transaction_supported);
2402 }
2403 ret
2404 }
2405
2406 pub fn end_of_epoch_transaction_supported(&self) -> bool {
2407 let ret = self.feature_flags.end_of_epoch_transaction_supported;
2408 if !ret {
2409 assert!(!self.feature_flags.enable_jwk_consensus_updates);
2411 }
2412 ret
2413 }
2414
2415 pub fn dkg_version(&self) -> u64 {
2416 self.random_beacon_dkg_version.unwrap_or(1)
2418 }
2419
2420 pub fn bridge(&self) -> bool {
2421 let ret = self.feature_flags.bridge;
2422 if ret {
2423 assert!(self.feature_flags.end_of_epoch_transaction_supported);
2425 }
2426 ret
2427 }
2428
2429 pub fn should_try_to_finalize_bridge_committee(&self) -> bool {
2430 if !self.bridge() {
2431 return false;
2432 }
2433 self.bridge_should_try_to_finalize_committee.unwrap_or(true)
2435 }
2436
2437 pub fn zklogin_max_epoch_upper_bound_delta(&self) -> Option<u64> {
2438 self.feature_flags.zklogin_max_epoch_upper_bound_delta
2439 }
2440
2441 pub fn enable_allowances(&self) -> bool {
2442 self.feature_flags.enable_allowances && self.enable_accumulators()
2443 }
2444
2445 pub fn enable_coin_reservation_obj_refs(&self) -> bool {
2446 self.new_vm_enabled() && self.feature_flags.enable_coin_reservation_obj_refs
2447 }
2448
2449 pub fn enable_authenticated_event_streams(&self) -> bool {
2450 self.feature_flags.enable_authenticated_event_streams && self.enable_accumulators()
2451 }
2452
2453 pub fn per_object_congestion_control_mode(&self) -> PerObjectCongestionControlMode {
2454 self.feature_flags.per_object_congestion_control_mode
2455 }
2456
2457 pub fn consensus_choice(&self) -> ConsensusChoice {
2458 self.feature_flags.consensus_choice
2459 }
2460
2461 pub fn consensus_network(&self) -> ConsensusNetwork {
2462 self.feature_flags.consensus_network
2463 }
2464
2465 pub fn mysticeti_num_leaders_per_round(&self) -> Option<usize> {
2466 self.feature_flags.mysticeti_num_leaders_per_round
2467 }
2468
2469 pub fn max_transaction_size_bytes(&self) -> u64 {
2470 self.consensus_max_transaction_size_bytes
2472 .unwrap_or(256 * 1024)
2473 }
2474
2475 pub fn max_transactions_in_block_bytes(&self) -> u64 {
2476 if cfg!(msim) {
2477 256 * 1024
2478 } else {
2479 self.consensus_max_transactions_in_block_bytes
2480 .unwrap_or(512 * 1024)
2481 }
2482 }
2483
2484 pub fn max_num_transactions_in_block(&self) -> u64 {
2485 if cfg!(msim) {
2486 8
2487 } else {
2488 self.consensus_max_num_transactions_in_block.unwrap_or(512)
2489 }
2490 }
2491
2492 pub fn gc_depth(&self) -> u32 {
2493 self.consensus_gc_depth.unwrap_or(0)
2494 }
2495
2496 pub fn consensus_linearize_subdag_v2(&self) -> bool {
2497 let res = self.feature_flags.consensus_linearize_subdag_v2;
2498 assert!(
2499 !res || self.gc_depth() > 0,
2500 "The consensus linearize sub dag V2 requires GC to be enabled"
2501 );
2502 res
2503 }
2504
2505 pub fn consensus_median_based_commit_timestamp(&self) -> bool {
2506 let res = self.feature_flags.consensus_median_based_commit_timestamp;
2507 assert!(
2508 !res || self.gc_depth() > 0,
2509 "The consensus median based commit timestamp requires GC to be enabled"
2510 );
2511 res
2512 }
2513
2514 pub fn get_consensus_commit_rate_estimation_window_size(&self) -> u32 {
2515 self.consensus_commit_rate_estimation_window_size
2516 .unwrap_or(0)
2517 }
2518
2519 pub fn consensus_num_requested_prior_commits_at_startup(&self) -> u32 {
2520 let window_size = self.get_consensus_commit_rate_estimation_window_size();
2524 assert!(window_size == 0 || self.record_additional_state_digest_in_prologue());
2526 window_size
2527 }
2528
2529 pub fn address_aliases(&self) -> bool {
2530 let address_aliases = self.feature_flags.address_aliases;
2531 assert!(
2532 !address_aliases || self.mysticeti_fastpath(),
2533 "Address aliases requires Mysticeti fastpath to be enabled"
2534 );
2535 if address_aliases {
2536 assert!(
2537 self.feature_flags.disable_preconsensus_locking,
2538 "Address aliases requires CertifiedTransaction to be disabled"
2539 );
2540 }
2541 address_aliases
2542 }
2543
2544 pub fn new_vm_enabled(&self) -> bool {
2545 self.execution_version.is_some_and(|v| v >= 4)
2546 }
2547
2548 pub fn gasless_allowed_token_types(&self) -> &[(String, u64)] {
2549 debug_assert!(self.gasless_allowed_token_types.is_some());
2550 self.gasless_allowed_token_types.as_deref().unwrap_or(&[])
2551 }
2552
2553 pub fn get_gasless_max_unused_inputs(&self) -> u64 {
2554 self.gasless_max_unused_inputs.unwrap_or(u64::MAX)
2555 }
2556
2557 pub fn get_gasless_max_pure_input_bytes(&self) -> u64 {
2558 self.gasless_max_pure_input_bytes.unwrap_or(u64::MAX)
2559 }
2560
2561 pub fn get_gasless_max_tx_size_bytes(&self) -> u64 {
2562 self.gasless_max_tx_size_bytes.unwrap_or(u64::MAX)
2563 }
2564
2565 pub fn include_special_package_amendments_as_option(&self) -> &Option<Arc<Amendments>> {
2566 &self.include_special_package_amendments
2567 }
2568}
2569
2570static POISON_VERSION_METHODS: AtomicBool = AtomicBool::new(false);
2571
2572impl ProtocolConfig {
2574 pub fn get_for_version(version: ProtocolVersion, chain: Chain) -> Self {
2576 assert!(
2578 version >= ProtocolVersion::MIN,
2579 "Network protocol version is {:?}, but the minimum supported version by the binary is {:?}. Please upgrade the binary.",
2580 version,
2581 ProtocolVersion::MIN.0,
2582 );
2583 assert!(
2584 version <= ProtocolVersion::MAX_ALLOWED,
2585 "Network protocol version is {:?}, but the maximum supported version by the binary is {:?}. Please upgrade the binary.",
2586 version,
2587 ProtocolVersion::MAX_ALLOWED.0,
2588 );
2589
2590 let mut ret = Self::get_for_version_impl(version, chain);
2591 ret.version = version;
2592 ret.chain = chain;
2593
2594 ret = Self::apply_config_override(version, ret);
2595
2596 if std::env::var("SUI_PROTOCOL_CONFIG_OVERRIDE_ENABLE").is_ok() {
2597 warn!(
2598 "overriding ProtocolConfig settings with custom settings; this may break non-local networks"
2599 );
2600 let overrides: ProtocolConfigOptional =
2601 serde_env::from_env_with_prefix("SUI_PROTOCOL_CONFIG_OVERRIDE")
2602 .expect("failed to parse ProtocolConfig override env variables");
2603 overrides.apply_to(&mut ret);
2604 }
2605
2606 ret
2607 }
2608
2609 pub fn get_for_version_if_supported(version: ProtocolVersion, chain: Chain) -> Option<Self> {
2612 if version.0 >= ProtocolVersion::MIN.0 && version.0 <= ProtocolVersion::MAX_ALLOWED.0 {
2613 let mut ret = Self::get_for_version_impl(version, chain);
2614 ret.version = version;
2615 ret.chain = chain;
2616 ret = Self::apply_config_override(version, ret);
2617 Some(ret)
2618 } else {
2619 None
2620 }
2621 }
2622
2623 pub fn poison_get_for_min_version() {
2624 POISON_VERSION_METHODS.store(true, Ordering::Relaxed);
2625 }
2626
2627 fn load_poison_get_for_min_version() -> bool {
2628 POISON_VERSION_METHODS.load(Ordering::Relaxed)
2629 }
2630
2631 pub fn get_for_min_version() -> Self {
2634 if Self::load_poison_get_for_min_version() {
2635 panic!("get_for_min_version called on validator");
2636 }
2637 ProtocolConfig::get_for_version(ProtocolVersion::MIN, Chain::Unknown)
2638 }
2639
2640 #[allow(non_snake_case)]
2650 pub fn get_for_max_version_UNSAFE() -> Self {
2651 if Self::load_poison_get_for_min_version() {
2652 panic!("get_for_max_version_UNSAFE called on validator");
2653 }
2654 ProtocolConfig::get_for_version(ProtocolVersion::MAX, Chain::Unknown)
2655 }
2656
2657 fn get_for_version_impl(version: ProtocolVersion, chain: Chain) -> Self {
2658 #[cfg(msim)]
2659 {
2660 if version == ProtocolVersion::MAX_ALLOWED {
2662 let mut config = Self::get_for_version_impl(version - 1, Chain::Unknown);
2663 config.base_tx_cost_fixed = Some(config.base_tx_cost_fixed() + 1000);
2664 return config;
2665 }
2666 }
2667
2668 let mut cfg = Self {
2671 version,
2673 chain,
2674
2675 feature_flags: Default::default(),
2677
2678 max_tx_size_bytes: Some(128 * 1024),
2679 max_input_objects: Some(2048),
2681 max_serialized_tx_effects_size_bytes: Some(512 * 1024),
2682 max_serialized_tx_effects_size_bytes_system_tx: Some(512 * 1024 * 16),
2683 max_gas_payment_objects: Some(256),
2684 max_modules_in_publish: Some(128),
2685 max_package_dependencies: None,
2686 max_arguments: Some(512),
2687 max_type_arguments: Some(16),
2688 max_type_argument_depth: Some(16),
2689 max_pure_argument_size: Some(16 * 1024),
2690 max_programmable_tx_commands: Some(1024),
2691 move_binary_format_version: Some(6),
2692 min_move_binary_format_version: None,
2693 binary_module_handles: None,
2694 binary_struct_handles: None,
2695 binary_function_handles: None,
2696 binary_function_instantiations: None,
2697 binary_signatures: None,
2698 binary_constant_pool: None,
2699 binary_identifiers: None,
2700 binary_address_identifiers: None,
2701 binary_struct_defs: None,
2702 binary_struct_def_instantiations: None,
2703 binary_function_defs: None,
2704 binary_field_handles: None,
2705 binary_field_instantiations: None,
2706 binary_friend_decls: None,
2707 binary_enum_defs: None,
2708 binary_enum_def_instantiations: None,
2709 binary_variant_handles: None,
2710 binary_variant_instantiation_handles: None,
2711 max_move_object_size: Some(250 * 1024),
2712 max_move_package_size: Some(100 * 1024),
2713 max_publish_or_upgrade_per_ptb: None,
2714 max_tx_gas: Some(10_000_000_000),
2715 max_gas_price: Some(100_000),
2716 max_gas_price_rgp_factor_for_aborted_transactions: None,
2717 max_gas_computation_bucket: Some(5_000_000),
2718 max_loop_depth: Some(5),
2719 max_generic_instantiation_length: Some(32),
2720 max_function_parameters: Some(128),
2721 max_basic_blocks: Some(1024),
2722 max_value_stack_size: Some(1024),
2723 max_type_nodes: Some(256),
2724 max_generic_instantiation_type_nodes_per_function: None,
2725 max_generic_instantiation_type_nodes_per_module: None,
2726 max_accumulator_type_nodes: None,
2727 max_push_size: Some(10000),
2728 max_struct_definitions: Some(200),
2729 max_function_definitions: Some(1000),
2730 max_fields_in_struct: Some(32),
2731 max_dependency_depth: Some(100),
2732 max_num_event_emit: Some(256),
2733 max_num_new_move_object_ids: Some(2048),
2734 max_num_new_move_object_ids_system_tx: Some(2048 * 16),
2735 max_num_deleted_move_object_ids: Some(2048),
2736 max_num_deleted_move_object_ids_system_tx: Some(2048 * 16),
2737 max_num_transferred_move_object_ids: Some(2048),
2738 max_num_transferred_move_object_ids_system_tx: Some(2048 * 16),
2739 max_event_emit_size: Some(250 * 1024),
2740 max_move_vector_len: Some(256 * 1024),
2741 max_type_to_layout_nodes: None,
2742 max_ptb_value_size: None,
2743
2744 max_back_edges_per_function: Some(10_000),
2745 max_back_edges_per_module: Some(10_000),
2746 max_verifier_meter_ticks_per_function: Some(6_000_000),
2747 max_meter_ticks_per_module: Some(6_000_000),
2748 max_meter_ticks_per_package: None,
2749
2750 object_runtime_max_num_cached_objects: Some(1000),
2751 object_runtime_max_num_cached_objects_system_tx: Some(1000 * 16),
2752 object_runtime_max_num_store_entries: Some(1000),
2753 object_runtime_max_num_store_entries_system_tx: Some(1000 * 16),
2754 base_tx_cost_fixed: Some(110_000),
2755 package_publish_cost_fixed: Some(1_000),
2756 base_tx_cost_per_byte: Some(0),
2757 package_publish_cost_per_byte: Some(80),
2758 obj_access_cost_read_per_byte: Some(15),
2759 obj_access_cost_read_per_package_kb: None,
2760 obj_access_cost_mutate_per_byte: Some(40),
2761 obj_access_cost_delete_per_byte: Some(40),
2762 obj_access_cost_verify_per_byte: Some(200),
2763 obj_data_cost_refundable: Some(100),
2764 obj_metadata_cost_non_refundable: Some(50),
2765 gas_model_version: Some(1),
2766 storage_rebate_rate: Some(9900),
2767 storage_fund_reinvest_rate: Some(500),
2768 reward_slashing_rate: Some(5000),
2769 storage_gas_price: Some(1),
2770 accumulator_object_storage_cost: None,
2771 max_transactions_per_checkpoint: Some(10_000),
2772 max_checkpoint_size_bytes: Some(30 * 1024 * 1024),
2773
2774 buffer_stake_for_protocol_upgrade_bps: Some(0),
2777
2778 address_from_bytes_cost_base: Some(52),
2782 address_to_u256_cost_base: Some(52),
2784 address_from_u256_cost_base: Some(52),
2786
2787 config_read_setting_impl_cost_base: None,
2790 config_read_setting_impl_cost_per_byte: None,
2791
2792 package_original_package_id_impl_cost_base: None,
2793 package_original_package_id_impl_cost_per_byte: None,
2794
2795 dynamic_field_hash_type_and_key_cost_base: Some(100),
2798 dynamic_field_hash_type_and_key_type_cost_per_byte: Some(2),
2799 dynamic_field_hash_type_and_key_value_cost_per_byte: Some(2),
2800 dynamic_field_hash_type_and_key_type_tag_cost_per_byte: Some(2),
2801 dynamic_field_add_child_object_cost_base: Some(100),
2803 dynamic_field_add_child_object_type_cost_per_byte: Some(10),
2804 dynamic_field_add_child_object_value_cost_per_byte: Some(10),
2805 dynamic_field_add_child_object_struct_tag_cost_per_byte: Some(10),
2806 dynamic_field_borrow_child_object_cost_base: Some(100),
2808 dynamic_field_borrow_child_object_child_ref_cost_per_byte: Some(10),
2809 dynamic_field_borrow_child_object_type_cost_per_byte: Some(10),
2810 dynamic_field_remove_child_object_cost_base: Some(100),
2812 dynamic_field_remove_child_object_child_cost_per_byte: Some(2),
2813 dynamic_field_remove_child_object_type_cost_per_byte: Some(2),
2814 dynamic_field_has_child_object_cost_base: Some(100),
2816 dynamic_field_has_child_object_with_ty_cost_base: Some(100),
2818 dynamic_field_has_child_object_with_ty_type_cost_per_byte: Some(2),
2819 dynamic_field_has_child_object_with_ty_type_tag_cost_per_byte: Some(2),
2820
2821 scratch_add_cost_base: None,
2823 scratch_read_cost_base: None,
2824 scratch_read_value_cost: None,
2825 scratch_remove_cost_base: None,
2826 scratch_exists_cost_base: None,
2827 scratch_exists_with_type_cost_base: None,
2828 scratch_exists_with_type_type_cost: None,
2829 max_scratch_pad_size: None,
2830
2831 event_emit_cost_base: Some(52),
2834 event_emit_value_size_derivation_cost_per_byte: Some(2),
2835 event_emit_tag_size_derivation_cost_per_byte: Some(5),
2836 event_emit_output_cost_per_byte: Some(10),
2837 event_emit_auth_stream_cost: None,
2838
2839 reserve_object_funds_for_withdrawal_cost_base: None,
2841 reserve_object_funds_for_withdrawal_cold_read_cost: None,
2842
2843 object_borrow_uid_cost_base: Some(52),
2846 object_delete_impl_cost_base: Some(52),
2848 object_record_new_uid_cost_base: Some(52),
2850 object_record_new_uid_from_hash_cost_base: None,
2853
2854 transfer_transfer_internal_cost_base: Some(52),
2857 transfer_party_transfer_internal_cost_base: None,
2859 transfer_freeze_object_cost_base: Some(52),
2861 transfer_share_object_cost_base: Some(52),
2863 transfer_receive_object_cost_base: None,
2864 transfer_receive_object_type_cost_per_byte: None,
2865 transfer_receive_object_cost_per_byte: None,
2866
2867 tx_context_derive_id_cost_base: Some(52),
2870 tx_context_fresh_id_cost_base: None,
2871 tx_context_sender_cost_base: None,
2872 tx_context_epoch_cost_base: None,
2873 tx_context_epoch_timestamp_ms_cost_base: None,
2874 tx_context_sponsor_cost_base: None,
2875 tx_context_rgp_cost_base: None,
2876 tx_context_gas_price_cost_base: None,
2877 tx_context_gas_budget_cost_base: None,
2878 tx_context_ids_created_cost_base: None,
2879 tx_context_replace_cost_base: None,
2880
2881 types_is_one_time_witness_cost_base: Some(52),
2884 types_is_one_time_witness_type_tag_cost_per_byte: Some(2),
2885 types_is_one_time_witness_type_cost_per_byte: Some(2),
2886
2887 validator_validate_metadata_cost_base: Some(52),
2890 validator_validate_metadata_data_cost_per_byte: Some(2),
2891
2892 crypto_invalid_arguments_cost: Some(100),
2894 bls12381_bls12381_min_sig_verify_cost_base: Some(52),
2896 bls12381_bls12381_min_sig_verify_msg_cost_per_byte: Some(2),
2897 bls12381_bls12381_min_sig_verify_msg_cost_per_block: Some(2),
2898
2899 bls12381_bls12381_min_pk_verify_cost_base: Some(52),
2901 bls12381_bls12381_min_pk_verify_msg_cost_per_byte: Some(2),
2902 bls12381_bls12381_min_pk_verify_msg_cost_per_block: Some(2),
2903
2904 ecdsa_k1_ecrecover_keccak256_cost_base: Some(52),
2906 ecdsa_k1_ecrecover_keccak256_msg_cost_per_byte: Some(2),
2907 ecdsa_k1_ecrecover_keccak256_msg_cost_per_block: Some(2),
2908 ecdsa_k1_ecrecover_sha256_cost_base: Some(52),
2909 ecdsa_k1_ecrecover_sha256_msg_cost_per_byte: Some(2),
2910 ecdsa_k1_ecrecover_sha256_msg_cost_per_block: Some(2),
2911
2912 ecdsa_k1_decompress_pubkey_cost_base: Some(52),
2914
2915 ecdsa_k1_secp256k1_verify_keccak256_cost_base: Some(52),
2917 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_byte: Some(2),
2918 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_block: Some(2),
2919 ecdsa_k1_secp256k1_verify_sha256_cost_base: Some(52),
2920 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_byte: Some(2),
2921 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_block: Some(2),
2922
2923 ecdsa_r1_ecrecover_keccak256_cost_base: Some(52),
2925 ecdsa_r1_ecrecover_keccak256_msg_cost_per_byte: Some(2),
2926 ecdsa_r1_ecrecover_keccak256_msg_cost_per_block: Some(2),
2927 ecdsa_r1_ecrecover_sha256_cost_base: Some(52),
2928 ecdsa_r1_ecrecover_sha256_msg_cost_per_byte: Some(2),
2929 ecdsa_r1_ecrecover_sha256_msg_cost_per_block: Some(2),
2930
2931 ecdsa_r1_secp256r1_verify_keccak256_cost_base: Some(52),
2933 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_byte: Some(2),
2934 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_block: Some(2),
2935 ecdsa_r1_secp256r1_verify_sha256_cost_base: Some(52),
2936 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_byte: Some(2),
2937 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_block: Some(2),
2938
2939 ecvrf_ecvrf_verify_cost_base: Some(52),
2941 ecvrf_ecvrf_verify_alpha_string_cost_per_byte: Some(2),
2942 ecvrf_ecvrf_verify_alpha_string_cost_per_block: Some(2),
2943
2944 ed25519_ed25519_verify_cost_base: Some(52),
2946 ed25519_ed25519_verify_msg_cost_per_byte: Some(2),
2947 ed25519_ed25519_verify_msg_cost_per_block: Some(2),
2948
2949 groth16_prepare_verifying_key_bls12381_cost_base: Some(52),
2951 groth16_prepare_verifying_key_bn254_cost_base: Some(52),
2952
2953 groth16_verify_groth16_proof_internal_bls12381_cost_base: Some(52),
2955 groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input: Some(2),
2956 groth16_verify_groth16_proof_internal_bn254_cost_base: Some(52),
2957 groth16_verify_groth16_proof_internal_bn254_cost_per_public_input: Some(2),
2958 groth16_verify_groth16_proof_internal_public_input_cost_per_byte: Some(2),
2959
2960 hash_blake2b256_cost_base: Some(52),
2962 hash_blake2b256_data_cost_per_byte: Some(2),
2963 hash_blake2b256_data_cost_per_block: Some(2),
2964
2965 hash_keccak256_cost_base: Some(52),
2967 hash_keccak256_data_cost_per_byte: Some(2),
2968 hash_keccak256_data_cost_per_block: Some(2),
2969
2970 poseidon_bn254_cost_base: None,
2971 poseidon_bn254_cost_per_block: None,
2972
2973 hmac_hmac_sha3_256_cost_base: Some(52),
2975 hmac_hmac_sha3_256_input_cost_per_byte: Some(2),
2976 hmac_hmac_sha3_256_input_cost_per_block: Some(2),
2977
2978 group_ops_bls12381_decode_scalar_cost: None,
2980 group_ops_bls12381_decode_g1_cost: None,
2981 group_ops_bls12381_decode_g2_cost: None,
2982 group_ops_bls12381_decode_gt_cost: None,
2983 group_ops_bls12381_scalar_add_cost: None,
2984 group_ops_bls12381_g1_add_cost: None,
2985 group_ops_bls12381_g2_add_cost: None,
2986 group_ops_bls12381_gt_add_cost: None,
2987 group_ops_bls12381_scalar_sub_cost: None,
2988 group_ops_bls12381_g1_sub_cost: None,
2989 group_ops_bls12381_g2_sub_cost: None,
2990 group_ops_bls12381_gt_sub_cost: None,
2991 group_ops_bls12381_scalar_mul_cost: None,
2992 group_ops_bls12381_g1_mul_cost: None,
2993 group_ops_bls12381_g2_mul_cost: None,
2994 group_ops_bls12381_gt_mul_cost: None,
2995 group_ops_bls12381_scalar_div_cost: None,
2996 group_ops_bls12381_g1_div_cost: None,
2997 group_ops_bls12381_g2_div_cost: None,
2998 group_ops_bls12381_gt_div_cost: None,
2999 group_ops_bls12381_g1_hash_to_base_cost: None,
3000 group_ops_bls12381_g2_hash_to_base_cost: None,
3001 group_ops_bls12381_g1_hash_to_cost_per_byte: None,
3002 group_ops_bls12381_g2_hash_to_cost_per_byte: None,
3003 group_ops_bls12381_g1_msm_base_cost: None,
3004 group_ops_bls12381_g2_msm_base_cost: None,
3005 group_ops_bls12381_g1_msm_base_cost_per_input: None,
3006 group_ops_bls12381_g2_msm_base_cost_per_input: None,
3007 group_ops_bls12381_msm_max_len: None,
3008 group_ops_bls12381_pairing_cost: None,
3009 group_ops_bls12381_g1_to_uncompressed_g1_cost: None,
3010 group_ops_bls12381_uncompressed_g1_to_g1_cost: None,
3011 group_ops_bls12381_uncompressed_g1_sum_base_cost: None,
3012 group_ops_bls12381_uncompressed_g1_sum_cost_per_term: None,
3013 group_ops_bls12381_uncompressed_g1_sum_max_terms: None,
3014
3015 group_ops_ristretto_decode_scalar_cost: None,
3016 group_ops_ristretto_decode_point_cost: None,
3017 group_ops_ristretto_scalar_add_cost: None,
3018 group_ops_ristretto_point_add_cost: None,
3019 group_ops_ristretto_scalar_sub_cost: None,
3020 group_ops_ristretto_point_sub_cost: None,
3021 group_ops_ristretto_scalar_mul_cost: None,
3022 group_ops_ristretto_point_mul_cost: None,
3023 group_ops_ristretto_scalar_div_cost: None,
3024 group_ops_ristretto_point_div_cost: None,
3025
3026 verify_bulletproofs_ristretto255_base_cost: None,
3027 verify_bulletproofs_ristretto255_cost_per_bit_and_commitment: None,
3028 max_bulletproofs_total_bits: None,
3029
3030 check_zklogin_id_cost_base: None,
3032 check_zklogin_issuer_cost_base: None,
3034
3035 vdf_verify_vdf_cost: None,
3036 vdf_hash_to_input_cost: None,
3037
3038 nitro_attestation_parse_base_cost: None,
3040 nitro_attestation_parse_cost_per_byte: None,
3041 nitro_attestation_verify_base_cost: None,
3042 nitro_attestation_verify_cost_per_cert: None,
3043
3044 bcs_per_byte_serialized_cost: None,
3045 bcs_legacy_min_output_size_cost: None,
3046 bcs_failure_cost: None,
3047 hash_sha2_256_base_cost: None,
3048 hash_sha2_256_per_byte_cost: None,
3049 hash_sha2_256_legacy_min_input_len_cost: None,
3050 hash_sha3_256_base_cost: None,
3051 hash_sha3_256_per_byte_cost: None,
3052 hash_sha3_256_legacy_min_input_len_cost: None,
3053 type_name_get_base_cost: None,
3054 type_name_get_per_byte_cost: None,
3055 type_name_id_base_cost: None,
3056 string_check_utf8_base_cost: None,
3057 string_check_utf8_per_byte_cost: None,
3058 string_is_char_boundary_base_cost: None,
3059 string_sub_string_base_cost: None,
3060 string_sub_string_per_byte_cost: None,
3061 string_index_of_base_cost: None,
3062 string_index_of_per_byte_pattern_cost: None,
3063 string_index_of_per_byte_searched_cost: None,
3064 vector_empty_base_cost: None,
3065 vector_length_base_cost: None,
3066 vector_push_back_base_cost: None,
3067 vector_push_back_legacy_per_abstract_memory_unit_cost: None,
3068 vector_borrow_base_cost: None,
3069 vector_pop_back_base_cost: None,
3070 vector_destroy_empty_base_cost: None,
3071 vector_swap_base_cost: None,
3072 vector_reverse_base_cost: None,
3073 vector_reverse_per_elem_cost: None,
3074 vector_keep_range_base_cost: None,
3075 vector_keep_range_per_dropped_elem_cost: None,
3076 vector_keep_range_per_moved_elem_cost: None,
3077 vector_copy_range_base_cost: None,
3078 vector_replace_range_base_cost: None,
3079 vector_replace_range_per_elem_cost: None,
3080 debug_print_base_cost: None,
3081 debug_print_stack_trace_base_cost: None,
3082
3083 max_size_written_objects: None,
3084 max_size_written_objects_system_tx: None,
3085
3086 max_move_identifier_len: None,
3093 max_move_value_depth: None,
3094 package_arena_size_in_bytes: None,
3095 max_move_enum_variants: None,
3096
3097 gas_rounding_step: None,
3098
3099 execution_version: None,
3100
3101 max_event_emit_size_total: None,
3102
3103 consensus_bad_nodes_stake_threshold: None,
3104
3105 max_jwk_votes_per_validator_per_epoch: None,
3106
3107 max_age_of_jwk_in_epochs: None,
3108
3109 random_beacon_reduction_allowed_delta: None,
3110
3111 random_beacon_reduction_lower_bound: None,
3112
3113 random_beacon_dkg_timeout_round: None,
3114
3115 random_beacon_min_round_interval_ms: None,
3116
3117 random_beacon_dkg_version: None,
3118
3119 consensus_max_transaction_size_bytes: None,
3120
3121 consensus_max_transactions_in_block_bytes: None,
3122
3123 consensus_max_num_transactions_in_block: None,
3124
3125 consensus_voting_rounds: None,
3126
3127 max_accumulated_txn_cost_per_object_in_narwhal_commit: None,
3128
3129 max_deferral_rounds_for_congestion_control: None,
3130
3131 epoch_close_deadline_ms: None,
3132
3133 max_txn_cost_overage_per_object_in_commit: None,
3134
3135 allowed_txn_cost_overage_burst_per_object_in_commit: None,
3136
3137 min_checkpoint_interval_ms: None,
3138
3139 checkpoint_summary_version_specific_data: None,
3140
3141 max_soft_bundle_size: None,
3142
3143 bridge_should_try_to_finalize_committee: None,
3144
3145 max_accumulated_txn_cost_per_object_in_mysticeti_commit: None,
3146
3147 max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit: None,
3148
3149 consensus_gc_depth: None,
3150
3151 gas_budget_based_txn_cost_cap_factor: None,
3152
3153 gas_budget_based_txn_cost_absolute_cap_commit_count: None,
3154
3155 sip_45_consensus_amplification_threshold: None,
3156
3157 use_object_per_epoch_marker_table_v2: None,
3158
3159 consensus_commit_rate_estimation_window_size: None,
3160
3161 aliased_addresses: vec![],
3162
3163 translation_per_command_base_charge: None,
3164 translation_per_input_base_charge: None,
3165 translation_pure_input_per_byte_charge: None,
3166 translation_per_type_node_charge: None,
3167 translation_per_reference_node_charge: None,
3168 translation_per_linkage_entry_charge: None,
3169 translation_per_live_reference_charge: None,
3170 max_ptb_live_references: None,
3171 max_ptb_returned_references: None,
3172 max_ptb_total_returned_references: None,
3173
3174 max_updates_per_settlement_txn: None,
3175
3176 gasless_max_computation_units: None,
3177 gasless_allowed_token_types: None,
3178 gasless_max_unused_inputs: None,
3179 gasless_max_pure_input_bytes: None,
3180 gasless_max_tps: None,
3181 include_special_package_amendments: None,
3182 gasless_max_tx_size_bytes: None,
3183 };
3186 for cur in 2..=version.0 {
3187 match cur {
3188 1 => unreachable!(),
3189 2 => {
3190 cfg.feature_flags.advance_epoch_start_time_in_safe_mode = true;
3191 }
3192 3 => {
3193 cfg.gas_model_version = Some(2);
3195 cfg.max_tx_gas = Some(50_000_000_000);
3197 cfg.base_tx_cost_fixed = Some(2_000);
3199 cfg.storage_gas_price = Some(76);
3201 cfg.feature_flags.loaded_child_objects_fixed = true;
3202 cfg.max_size_written_objects = Some(5 * 1000 * 1000);
3205 cfg.max_size_written_objects_system_tx = Some(50 * 1000 * 1000);
3208 cfg.feature_flags.package_upgrades = true;
3209 }
3210 4 => {
3215 cfg.reward_slashing_rate = Some(10000);
3217 cfg.gas_model_version = Some(3);
3219 }
3220 5 => {
3221 cfg.feature_flags.missing_type_is_compatibility_error = true;
3222 cfg.gas_model_version = Some(4);
3223 cfg.feature_flags.scoring_decision_with_validity_cutoff = true;
3224 }
3228 6 => {
3229 cfg.gas_model_version = Some(5);
3230 cfg.buffer_stake_for_protocol_upgrade_bps = Some(5000);
3231 cfg.feature_flags.consensus_order_end_of_epoch_last = true;
3232 }
3233 7 => {
3234 cfg.feature_flags.disallow_adding_abilities_on_upgrade = true;
3235 cfg.feature_flags
3236 .disable_invariant_violation_check_in_swap_loc = true;
3237 cfg.feature_flags.ban_entry_init = true;
3238 cfg.feature_flags.package_digest_hash_module = true;
3239 }
3240 8 => {
3241 cfg.feature_flags
3242 .disallow_change_struct_type_params_on_upgrade = true;
3243 }
3244 9 => {
3245 cfg.max_move_identifier_len = Some(128);
3247 cfg.feature_flags.no_extraneous_module_bytes = true;
3248 cfg.feature_flags
3249 .advance_to_highest_supported_protocol_version = true;
3250 }
3251 10 => {
3252 cfg.max_verifier_meter_ticks_per_function = Some(16_000_000);
3253 cfg.max_meter_ticks_per_module = Some(16_000_000);
3254 }
3255 11 => {
3256 cfg.max_move_value_depth = Some(128);
3257 }
3258 12 => {
3259 cfg.feature_flags.narwhal_versioned_metadata = true;
3260 if chain != Chain::Mainnet {
3261 cfg.feature_flags.commit_root_state_digest = true;
3262 }
3263
3264 if chain != Chain::Mainnet && chain != Chain::Testnet {
3265 cfg.feature_flags.zklogin_auth = true;
3266 }
3267 }
3268 13 => {}
3269 14 => {
3270 cfg.gas_rounding_step = Some(1_000);
3271 cfg.gas_model_version = Some(6);
3272 }
3273 15 => {
3274 cfg.feature_flags.consensus_transaction_ordering =
3275 ConsensusTransactionOrdering::ByGasPrice;
3276 }
3277 16 => {
3278 cfg.feature_flags.simplified_unwrap_then_delete = true;
3279 }
3280 17 => {
3281 cfg.feature_flags.upgraded_multisig_supported = true;
3282 }
3283 18 => {
3284 cfg.execution_version = Some(1);
3285 cfg.feature_flags.txn_base_cost_as_multiplier = true;
3294 cfg.base_tx_cost_fixed = Some(1_000);
3296 }
3297 19 => {
3298 cfg.max_num_event_emit = Some(1024);
3299 cfg.max_event_emit_size_total = Some(
3302 256 * 250 * 1024, );
3304 }
3305 20 => {
3306 cfg.feature_flags.commit_root_state_digest = true;
3307
3308 if chain != Chain::Mainnet {
3309 cfg.feature_flags.narwhal_new_leader_election_schedule = true;
3310 cfg.consensus_bad_nodes_stake_threshold = Some(20);
3311 }
3312 }
3313
3314 21 => {
3315 if chain != Chain::Mainnet {
3316 cfg.feature_flags.zklogin_supported_providers = BTreeSet::from([
3317 "Google".to_string(),
3318 "Facebook".to_string(),
3319 "Twitch".to_string(),
3320 ]);
3321 }
3322 }
3323 22 => {
3324 cfg.feature_flags.loaded_child_object_format = true;
3325 }
3326 23 => {
3327 cfg.feature_flags.loaded_child_object_format_type = true;
3328 cfg.feature_flags.narwhal_new_leader_election_schedule = true;
3329 cfg.consensus_bad_nodes_stake_threshold = Some(20);
3335 }
3336 24 => {
3337 cfg.feature_flags.simple_conservation_checks = true;
3338 cfg.max_publish_or_upgrade_per_ptb = Some(5);
3339
3340 cfg.feature_flags.end_of_epoch_transaction_supported = true;
3341
3342 if chain != Chain::Mainnet {
3343 cfg.feature_flags.enable_jwk_consensus_updates = true;
3344 cfg.max_jwk_votes_per_validator_per_epoch = Some(240);
3346 cfg.max_age_of_jwk_in_epochs = Some(1);
3347 }
3348 }
3349 25 => {
3350 cfg.feature_flags.zklogin_supported_providers = BTreeSet::from([
3352 "Google".to_string(),
3353 "Facebook".to_string(),
3354 "Twitch".to_string(),
3355 ]);
3356 cfg.feature_flags.zklogin_auth = true;
3357
3358 cfg.feature_flags.enable_jwk_consensus_updates = true;
3360 cfg.max_jwk_votes_per_validator_per_epoch = Some(240);
3361 cfg.max_age_of_jwk_in_epochs = Some(1);
3362 }
3363 26 => {
3364 cfg.gas_model_version = Some(7);
3365 if chain != Chain::Mainnet && chain != Chain::Testnet {
3367 cfg.transfer_receive_object_cost_base = Some(52);
3368 cfg.feature_flags.receive_objects = true;
3369 }
3370 }
3371 27 => {
3372 cfg.gas_model_version = Some(8);
3373 }
3374 28 => {
3375 cfg.check_zklogin_id_cost_base = Some(200);
3377 cfg.check_zklogin_issuer_cost_base = Some(200);
3379
3380 if chain != Chain::Mainnet && chain != Chain::Testnet {
3382 cfg.feature_flags.enable_effects_v2 = true;
3383 }
3384 }
3385 29 => {
3386 cfg.feature_flags.verify_legacy_zklogin_address = true;
3387 }
3388 30 => {
3389 if chain != Chain::Mainnet {
3391 cfg.feature_flags.narwhal_certificate_v2 = true;
3392 }
3393
3394 cfg.random_beacon_reduction_allowed_delta = Some(800);
3395 if chain != Chain::Mainnet {
3397 cfg.feature_flags.enable_effects_v2 = true;
3398 }
3399
3400 cfg.feature_flags.zklogin_supported_providers = BTreeSet::default();
3404
3405 cfg.feature_flags.recompute_has_public_transfer_in_execution = true;
3406 }
3407 31 => {
3408 cfg.execution_version = Some(2);
3409 if chain != Chain::Mainnet && chain != Chain::Testnet {
3411 cfg.feature_flags.shared_object_deletion = true;
3412 }
3413 }
3414 32 => {
3415 if chain != Chain::Mainnet {
3417 cfg.feature_flags.accept_zklogin_in_multisig = true;
3418 }
3419 if chain != Chain::Mainnet {
3421 cfg.transfer_receive_object_cost_base = Some(52);
3422 cfg.feature_flags.receive_objects = true;
3423 }
3424 if chain != Chain::Mainnet && chain != Chain::Testnet {
3426 cfg.feature_flags.random_beacon = true;
3427 cfg.random_beacon_reduction_lower_bound = Some(1600);
3428 cfg.random_beacon_dkg_timeout_round = Some(3000);
3429 cfg.random_beacon_min_round_interval_ms = Some(150);
3430 }
3431 if chain != Chain::Testnet && chain != Chain::Mainnet {
3433 cfg.feature_flags.include_consensus_digest_in_prologue = true;
3434 }
3435
3436 cfg.feature_flags.narwhal_certificate_v2 = true;
3438 }
3439 33 => {
3440 cfg.feature_flags.hardened_otw_check = true;
3441 cfg.feature_flags.allow_receiving_object_id = true;
3442
3443 cfg.transfer_receive_object_cost_base = Some(52);
3445 cfg.feature_flags.receive_objects = true;
3446
3447 if chain != Chain::Mainnet {
3449 cfg.feature_flags.shared_object_deletion = true;
3450 }
3451
3452 cfg.feature_flags.enable_effects_v2 = true;
3453 }
3454 34 => {}
3455 35 => {
3456 if chain != Chain::Mainnet && chain != Chain::Testnet {
3458 cfg.feature_flags.enable_poseidon = true;
3459 cfg.poseidon_bn254_cost_base = Some(260);
3460 cfg.poseidon_bn254_cost_per_block = Some(10);
3461 }
3462
3463 cfg.feature_flags.enable_coin_deny_list = true;
3464 }
3465 36 => {
3466 if chain != Chain::Mainnet && chain != Chain::Testnet {
3468 cfg.feature_flags.enable_group_ops_native_functions = true;
3469 cfg.feature_flags.enable_group_ops_native_function_msm = true;
3470 cfg.group_ops_bls12381_decode_scalar_cost = Some(52);
3472 cfg.group_ops_bls12381_decode_g1_cost = Some(52);
3473 cfg.group_ops_bls12381_decode_g2_cost = Some(52);
3474 cfg.group_ops_bls12381_decode_gt_cost = Some(52);
3475 cfg.group_ops_bls12381_scalar_add_cost = Some(52);
3476 cfg.group_ops_bls12381_g1_add_cost = Some(52);
3477 cfg.group_ops_bls12381_g2_add_cost = Some(52);
3478 cfg.group_ops_bls12381_gt_add_cost = Some(52);
3479 cfg.group_ops_bls12381_scalar_sub_cost = Some(52);
3480 cfg.group_ops_bls12381_g1_sub_cost = Some(52);
3481 cfg.group_ops_bls12381_g2_sub_cost = Some(52);
3482 cfg.group_ops_bls12381_gt_sub_cost = Some(52);
3483 cfg.group_ops_bls12381_scalar_mul_cost = Some(52);
3484 cfg.group_ops_bls12381_g1_mul_cost = Some(52);
3485 cfg.group_ops_bls12381_g2_mul_cost = Some(52);
3486 cfg.group_ops_bls12381_gt_mul_cost = Some(52);
3487 cfg.group_ops_bls12381_scalar_div_cost = Some(52);
3488 cfg.group_ops_bls12381_g1_div_cost = Some(52);
3489 cfg.group_ops_bls12381_g2_div_cost = Some(52);
3490 cfg.group_ops_bls12381_gt_div_cost = Some(52);
3491 cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(52);
3492 cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(52);
3493 cfg.group_ops_bls12381_g1_hash_to_cost_per_byte = Some(2);
3494 cfg.group_ops_bls12381_g2_hash_to_cost_per_byte = Some(2);
3495 cfg.group_ops_bls12381_g1_msm_base_cost = Some(52);
3496 cfg.group_ops_bls12381_g2_msm_base_cost = Some(52);
3497 cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(52);
3498 cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(52);
3499 cfg.group_ops_bls12381_msm_max_len = Some(32);
3500 cfg.group_ops_bls12381_pairing_cost = Some(52);
3501 }
3502 cfg.feature_flags.shared_object_deletion = true;
3504
3505 cfg.consensus_max_transaction_size_bytes = Some(256 * 1024); cfg.consensus_max_transactions_in_block_bytes = Some(6 * 1_024 * 1024);
3507 }
3509 37 => {
3510 cfg.feature_flags.reject_mutable_random_on_entry_functions = true;
3511
3512 if chain != Chain::Mainnet {
3514 cfg.feature_flags.include_consensus_digest_in_prologue = true;
3515 }
3516 }
3517 38 => {
3518 cfg.binary_module_handles = Some(100);
3519 cfg.binary_struct_handles = Some(300);
3520 cfg.binary_function_handles = Some(1500);
3521 cfg.binary_function_instantiations = Some(750);
3522 cfg.binary_signatures = Some(1000);
3523 cfg.binary_constant_pool = Some(4000);
3527 cfg.binary_identifiers = Some(10000);
3528 cfg.binary_address_identifiers = Some(100);
3529 cfg.binary_struct_defs = Some(200);
3530 cfg.binary_struct_def_instantiations = Some(100);
3531 cfg.binary_function_defs = Some(1000);
3532 cfg.binary_field_handles = Some(500);
3533 cfg.binary_field_instantiations = Some(250);
3534 cfg.binary_friend_decls = Some(100);
3535 cfg.max_package_dependencies = Some(32);
3537 cfg.max_modules_in_publish = Some(64);
3538 cfg.execution_version = Some(3);
3540 }
3541 39 => {
3542 }
3544 40 => {}
3545 41 => {
3546 cfg.feature_flags.enable_group_ops_native_functions = true;
3548 cfg.group_ops_bls12381_decode_scalar_cost = Some(52);
3550 cfg.group_ops_bls12381_decode_g1_cost = Some(52);
3551 cfg.group_ops_bls12381_decode_g2_cost = Some(52);
3552 cfg.group_ops_bls12381_decode_gt_cost = Some(52);
3553 cfg.group_ops_bls12381_scalar_add_cost = Some(52);
3554 cfg.group_ops_bls12381_g1_add_cost = Some(52);
3555 cfg.group_ops_bls12381_g2_add_cost = Some(52);
3556 cfg.group_ops_bls12381_gt_add_cost = Some(52);
3557 cfg.group_ops_bls12381_scalar_sub_cost = Some(52);
3558 cfg.group_ops_bls12381_g1_sub_cost = Some(52);
3559 cfg.group_ops_bls12381_g2_sub_cost = Some(52);
3560 cfg.group_ops_bls12381_gt_sub_cost = Some(52);
3561 cfg.group_ops_bls12381_scalar_mul_cost = Some(52);
3562 cfg.group_ops_bls12381_g1_mul_cost = Some(52);
3563 cfg.group_ops_bls12381_g2_mul_cost = Some(52);
3564 cfg.group_ops_bls12381_gt_mul_cost = Some(52);
3565 cfg.group_ops_bls12381_scalar_div_cost = Some(52);
3566 cfg.group_ops_bls12381_g1_div_cost = Some(52);
3567 cfg.group_ops_bls12381_g2_div_cost = Some(52);
3568 cfg.group_ops_bls12381_gt_div_cost = Some(52);
3569 cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(52);
3570 cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(52);
3571 cfg.group_ops_bls12381_g1_hash_to_cost_per_byte = Some(2);
3572 cfg.group_ops_bls12381_g2_hash_to_cost_per_byte = Some(2);
3573 cfg.group_ops_bls12381_g1_msm_base_cost = Some(52);
3574 cfg.group_ops_bls12381_g2_msm_base_cost = Some(52);
3575 cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(52);
3576 cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(52);
3577 cfg.group_ops_bls12381_msm_max_len = Some(32);
3578 cfg.group_ops_bls12381_pairing_cost = Some(52);
3579 }
3580 42 => {}
3581 43 => {
3582 cfg.feature_flags.zklogin_max_epoch_upper_bound_delta = Some(30);
3583 cfg.max_meter_ticks_per_package = Some(16_000_000);
3584 }
3585 44 => {
3586 cfg.feature_flags.include_consensus_digest_in_prologue = true;
3588 if chain != Chain::Mainnet {
3590 cfg.feature_flags.consensus_choice = ConsensusChoice::SwapEachEpoch;
3591 }
3592 }
3593 45 => {
3594 if chain != Chain::Testnet && chain != Chain::Mainnet {
3596 cfg.feature_flags.consensus_network = ConsensusNetwork::Tonic;
3597 }
3598
3599 if chain != Chain::Mainnet {
3600 cfg.feature_flags.mysticeti_leader_scoring_and_schedule = true;
3602 }
3603 cfg.min_move_binary_format_version = Some(6);
3604 cfg.feature_flags.accept_zklogin_in_multisig = true;
3605
3606 if chain != Chain::Mainnet && chain != Chain::Testnet {
3610 cfg.feature_flags.bridge = true;
3611 }
3612 }
3613 46 => {
3614 if chain != Chain::Mainnet {
3616 cfg.feature_flags.bridge = true;
3617 }
3618
3619 cfg.feature_flags.reshare_at_same_initial_version = true;
3621 }
3622 47 => {}
3623 48 => {
3624 cfg.feature_flags.consensus_network = ConsensusNetwork::Tonic;
3626
3627 cfg.feature_flags.resolve_abort_locations_to_package_id = true;
3629
3630 if chain != Chain::Mainnet {
3632 cfg.feature_flags.random_beacon = true;
3633 cfg.random_beacon_reduction_lower_bound = Some(1600);
3634 cfg.random_beacon_dkg_timeout_round = Some(3000);
3635 cfg.random_beacon_min_round_interval_ms = Some(200);
3636 }
3637
3638 cfg.feature_flags.mysticeti_use_committed_subdag_digest = true;
3640 }
3641 49 => {
3642 if chain != Chain::Testnet && chain != Chain::Mainnet {
3643 cfg.move_binary_format_version = Some(7);
3644 }
3645
3646 if chain != Chain::Mainnet && chain != Chain::Testnet {
3648 cfg.feature_flags.enable_vdf = true;
3649 cfg.vdf_verify_vdf_cost = Some(1500);
3652 cfg.vdf_hash_to_input_cost = Some(100);
3653 }
3654
3655 if chain != Chain::Testnet && chain != Chain::Mainnet {
3657 cfg.feature_flags
3658 .record_consensus_determined_version_assignments_in_prologue = true;
3659 }
3660
3661 if chain != Chain::Mainnet {
3663 cfg.feature_flags.consensus_choice = ConsensusChoice::Mysticeti;
3664 }
3665
3666 cfg.feature_flags.fresh_vm_on_framework_upgrade = true;
3668 }
3669 50 => {
3670 if chain != Chain::Mainnet {
3672 cfg.checkpoint_summary_version_specific_data = Some(1);
3673 cfg.min_checkpoint_interval_ms = Some(200);
3674 }
3675
3676 if chain != Chain::Testnet && chain != Chain::Mainnet {
3678 cfg.feature_flags
3679 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = true;
3680 }
3681
3682 cfg.feature_flags.mysticeti_num_leaders_per_round = Some(1);
3683
3684 cfg.max_deferral_rounds_for_congestion_control = Some(10);
3686 }
3687 51 => {
3688 cfg.random_beacon_dkg_version = Some(1);
3689
3690 if chain != Chain::Testnet && chain != Chain::Mainnet {
3691 cfg.feature_flags.enable_coin_deny_list_v2 = true;
3692 }
3693 }
3694 52 => {
3695 if chain != Chain::Mainnet {
3696 cfg.feature_flags.soft_bundle = true;
3697 cfg.max_soft_bundle_size = Some(5);
3698 }
3699
3700 cfg.config_read_setting_impl_cost_base = Some(100);
3701 cfg.config_read_setting_impl_cost_per_byte = Some(40);
3702
3703 if chain != Chain::Testnet && chain != Chain::Mainnet {
3705 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(100);
3706 cfg.feature_flags.per_object_congestion_control_mode =
3707 PerObjectCongestionControlMode::TotalTxCount;
3708 }
3709
3710 cfg.feature_flags.consensus_choice = ConsensusChoice::Mysticeti;
3712
3713 cfg.feature_flags.mysticeti_leader_scoring_and_schedule = true;
3715
3716 cfg.checkpoint_summary_version_specific_data = Some(1);
3718 cfg.min_checkpoint_interval_ms = Some(200);
3719
3720 if chain != Chain::Mainnet {
3722 cfg.feature_flags
3723 .record_consensus_determined_version_assignments_in_prologue = true;
3724 cfg.feature_flags
3725 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = true;
3726 }
3727 if chain != Chain::Mainnet {
3729 cfg.move_binary_format_version = Some(7);
3730 }
3731
3732 if chain != Chain::Testnet && chain != Chain::Mainnet {
3733 cfg.feature_flags.passkey_auth = true;
3734 }
3735 cfg.feature_flags.enable_coin_deny_list_v2 = true;
3736 }
3737 53 => {
3738 cfg.bridge_should_try_to_finalize_committee = Some(chain != Chain::Mainnet);
3740
3741 cfg.feature_flags
3743 .record_consensus_determined_version_assignments_in_prologue = true;
3744 cfg.feature_flags
3745 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = true;
3746
3747 if chain == Chain::Unknown {
3748 cfg.feature_flags.authority_capabilities_v2 = true;
3749 }
3750
3751 if chain != Chain::Mainnet {
3753 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(100);
3754 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(10);
3755 cfg.feature_flags.per_object_congestion_control_mode =
3756 PerObjectCongestionControlMode::TotalTxCount;
3757 }
3758
3759 cfg.bcs_per_byte_serialized_cost = Some(2);
3761 cfg.bcs_legacy_min_output_size_cost = Some(1);
3762 cfg.bcs_failure_cost = Some(52);
3763 cfg.debug_print_base_cost = Some(52);
3764 cfg.debug_print_stack_trace_base_cost = Some(52);
3765 cfg.hash_sha2_256_base_cost = Some(52);
3766 cfg.hash_sha2_256_per_byte_cost = Some(2);
3767 cfg.hash_sha2_256_legacy_min_input_len_cost = Some(1);
3768 cfg.hash_sha3_256_base_cost = Some(52);
3769 cfg.hash_sha3_256_per_byte_cost = Some(2);
3770 cfg.hash_sha3_256_legacy_min_input_len_cost = Some(1);
3771 cfg.type_name_get_base_cost = Some(52);
3772 cfg.type_name_get_per_byte_cost = Some(2);
3773 cfg.string_check_utf8_base_cost = Some(52);
3774 cfg.string_check_utf8_per_byte_cost = Some(2);
3775 cfg.string_is_char_boundary_base_cost = Some(52);
3776 cfg.string_sub_string_base_cost = Some(52);
3777 cfg.string_sub_string_per_byte_cost = Some(2);
3778 cfg.string_index_of_base_cost = Some(52);
3779 cfg.string_index_of_per_byte_pattern_cost = Some(2);
3780 cfg.string_index_of_per_byte_searched_cost = Some(2);
3781 cfg.vector_empty_base_cost = Some(52);
3782 cfg.vector_length_base_cost = Some(52);
3783 cfg.vector_push_back_base_cost = Some(52);
3784 cfg.vector_push_back_legacy_per_abstract_memory_unit_cost = Some(2);
3785 cfg.vector_borrow_base_cost = Some(52);
3786 cfg.vector_pop_back_base_cost = Some(52);
3787 cfg.vector_destroy_empty_base_cost = Some(52);
3788 cfg.vector_swap_base_cost = Some(52);
3789 }
3790 54 => {
3791 cfg.feature_flags.random_beacon = true;
3793 cfg.random_beacon_reduction_lower_bound = Some(1000);
3794 cfg.random_beacon_dkg_timeout_round = Some(3000);
3795 cfg.random_beacon_min_round_interval_ms = Some(500);
3796
3797 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(100);
3799 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(10);
3800 cfg.feature_flags.per_object_congestion_control_mode =
3801 PerObjectCongestionControlMode::TotalTxCount;
3802
3803 cfg.feature_flags.soft_bundle = true;
3805 cfg.max_soft_bundle_size = Some(5);
3806 }
3807 55 => {
3808 cfg.move_binary_format_version = Some(7);
3810
3811 cfg.consensus_max_transactions_in_block_bytes = Some(512 * 1024);
3813 cfg.consensus_max_num_transactions_in_block = Some(512);
3816
3817 cfg.feature_flags.rethrow_serialization_type_layout_errors = true;
3818 }
3819 56 => {
3820 if chain == Chain::Mainnet {
3821 cfg.feature_flags.bridge = true;
3822 }
3823 }
3824 57 => {
3825 cfg.random_beacon_reduction_lower_bound = Some(800);
3827 }
3828 58 => {
3829 if chain == Chain::Mainnet {
3830 cfg.bridge_should_try_to_finalize_committee = Some(true);
3831 }
3832
3833 if chain != Chain::Mainnet && chain != Chain::Testnet {
3834 cfg.feature_flags
3836 .consensus_distributed_vote_scoring_strategy = true;
3837 }
3838 }
3839 59 => {
3840 cfg.feature_flags.consensus_round_prober = true;
3842 }
3843 60 => {
3844 cfg.max_type_to_layout_nodes = Some(512);
3845 cfg.feature_flags.validate_identifier_inputs = true;
3846 }
3847 61 => {
3848 if chain != Chain::Mainnet {
3849 cfg.feature_flags
3851 .consensus_distributed_vote_scoring_strategy = true;
3852 }
3853 cfg.random_beacon_reduction_lower_bound = Some(700);
3855
3856 if chain != Chain::Mainnet && chain != Chain::Testnet {
3857 cfg.feature_flags.mysticeti_fastpath = true;
3859 }
3860 }
3861 62 => {
3862 cfg.feature_flags.relocate_event_module = true;
3863 }
3864 63 => {
3865 cfg.feature_flags.per_object_congestion_control_mode =
3866 PerObjectCongestionControlMode::TotalGasBudgetWithCap;
3867 cfg.gas_budget_based_txn_cost_cap_factor = Some(400_000);
3868 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(18_500_000);
3869 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(240_000_000);
3870 }
3871 64 => {
3872 cfg.feature_flags.per_object_congestion_control_mode =
3873 PerObjectCongestionControlMode::TotalTxCount;
3874 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(40);
3875 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(3);
3876 }
3877 65 => {
3878 cfg.feature_flags
3880 .consensus_distributed_vote_scoring_strategy = true;
3881 }
3882 66 => {
3883 if chain == Chain::Mainnet {
3884 cfg.feature_flags
3886 .consensus_distributed_vote_scoring_strategy = false;
3887 }
3888 }
3889 67 => {
3890 cfg.feature_flags
3892 .consensus_distributed_vote_scoring_strategy = true;
3893 }
3894 68 => {
3895 cfg.group_ops_bls12381_g1_to_uncompressed_g1_cost = Some(26);
3896 cfg.group_ops_bls12381_uncompressed_g1_to_g1_cost = Some(52);
3897 cfg.group_ops_bls12381_uncompressed_g1_sum_base_cost = Some(26);
3898 cfg.group_ops_bls12381_uncompressed_g1_sum_cost_per_term = Some(13);
3899 cfg.group_ops_bls12381_uncompressed_g1_sum_max_terms = Some(2000);
3900
3901 if chain != Chain::Mainnet && chain != Chain::Testnet {
3902 cfg.feature_flags.uncompressed_g1_group_elements = true;
3903 }
3904
3905 cfg.feature_flags.per_object_congestion_control_mode =
3906 PerObjectCongestionControlMode::TotalGasBudgetWithCap;
3907 cfg.gas_budget_based_txn_cost_cap_factor = Some(400_000);
3908 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(18_500_000);
3909 cfg.max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit =
3910 Some(3_700_000); cfg.max_txn_cost_overage_per_object_in_commit = Some(u64::MAX);
3912 cfg.gas_budget_based_txn_cost_absolute_cap_commit_count = Some(50);
3913
3914 cfg.random_beacon_reduction_lower_bound = Some(500);
3916
3917 cfg.feature_flags.disallow_new_modules_in_deps_only_packages = true;
3918 }
3919 69 => {
3920 cfg.consensus_voting_rounds = Some(40);
3922
3923 if chain != Chain::Mainnet && chain != Chain::Testnet {
3924 cfg.feature_flags.consensus_smart_ancestor_selection = true;
3926 }
3927
3928 if chain != Chain::Mainnet {
3929 cfg.feature_flags.uncompressed_g1_group_elements = true;
3930 }
3931 }
3932 70 => {
3933 if chain != Chain::Mainnet {
3934 cfg.feature_flags.consensus_smart_ancestor_selection = true;
3936 cfg.feature_flags
3938 .consensus_round_prober_probe_accepted_rounds = true;
3939 }
3940
3941 cfg.poseidon_bn254_cost_per_block = Some(388);
3942
3943 cfg.gas_model_version = Some(9);
3944 cfg.feature_flags.native_charging_v2 = true;
3945 cfg.bls12381_bls12381_min_sig_verify_cost_base = Some(44064);
3946 cfg.bls12381_bls12381_min_pk_verify_cost_base = Some(49282);
3947 cfg.ecdsa_k1_secp256k1_verify_keccak256_cost_base = Some(1470);
3948 cfg.ecdsa_k1_secp256k1_verify_sha256_cost_base = Some(1470);
3949 cfg.ecdsa_r1_secp256r1_verify_sha256_cost_base = Some(4225);
3950 cfg.ecdsa_r1_secp256r1_verify_keccak256_cost_base = Some(4225);
3951 cfg.ecvrf_ecvrf_verify_cost_base = Some(4848);
3952 cfg.ed25519_ed25519_verify_cost_base = Some(1802);
3953
3954 cfg.ecdsa_r1_ecrecover_keccak256_cost_base = Some(1173);
3956 cfg.ecdsa_r1_ecrecover_sha256_cost_base = Some(1173);
3957 cfg.ecdsa_k1_ecrecover_keccak256_cost_base = Some(500);
3958 cfg.ecdsa_k1_ecrecover_sha256_cost_base = Some(500);
3959
3960 cfg.groth16_prepare_verifying_key_bls12381_cost_base = Some(53838);
3961 cfg.groth16_prepare_verifying_key_bn254_cost_base = Some(82010);
3962 cfg.groth16_verify_groth16_proof_internal_bls12381_cost_base = Some(72090);
3963 cfg.groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input =
3964 Some(8213);
3965 cfg.groth16_verify_groth16_proof_internal_bn254_cost_base = Some(115502);
3966 cfg.groth16_verify_groth16_proof_internal_bn254_cost_per_public_input =
3967 Some(9484);
3968
3969 cfg.hash_keccak256_cost_base = Some(10);
3970 cfg.hash_blake2b256_cost_base = Some(10);
3971
3972 cfg.group_ops_bls12381_decode_scalar_cost = Some(7);
3974 cfg.group_ops_bls12381_decode_g1_cost = Some(2848);
3975 cfg.group_ops_bls12381_decode_g2_cost = Some(3770);
3976 cfg.group_ops_bls12381_decode_gt_cost = Some(3068);
3977
3978 cfg.group_ops_bls12381_scalar_add_cost = Some(10);
3979 cfg.group_ops_bls12381_g1_add_cost = Some(1556);
3980 cfg.group_ops_bls12381_g2_add_cost = Some(3048);
3981 cfg.group_ops_bls12381_gt_add_cost = Some(188);
3982
3983 cfg.group_ops_bls12381_scalar_sub_cost = Some(10);
3984 cfg.group_ops_bls12381_g1_sub_cost = Some(1550);
3985 cfg.group_ops_bls12381_g2_sub_cost = Some(3019);
3986 cfg.group_ops_bls12381_gt_sub_cost = Some(497);
3987
3988 cfg.group_ops_bls12381_scalar_mul_cost = Some(11);
3989 cfg.group_ops_bls12381_g1_mul_cost = Some(4842);
3990 cfg.group_ops_bls12381_g2_mul_cost = Some(9108);
3991 cfg.group_ops_bls12381_gt_mul_cost = Some(27490);
3992
3993 cfg.group_ops_bls12381_scalar_div_cost = Some(91);
3994 cfg.group_ops_bls12381_g1_div_cost = Some(5091);
3995 cfg.group_ops_bls12381_g2_div_cost = Some(9206);
3996 cfg.group_ops_bls12381_gt_div_cost = Some(27804);
3997
3998 cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(2962);
3999 cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(8688);
4000
4001 cfg.group_ops_bls12381_g1_msm_base_cost = Some(62648);
4002 cfg.group_ops_bls12381_g2_msm_base_cost = Some(131192);
4003 cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(1333);
4004 cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(3216);
4005
4006 cfg.group_ops_bls12381_uncompressed_g1_to_g1_cost = Some(677);
4007 cfg.group_ops_bls12381_g1_to_uncompressed_g1_cost = Some(2099);
4008 cfg.group_ops_bls12381_uncompressed_g1_sum_base_cost = Some(77);
4009 cfg.group_ops_bls12381_uncompressed_g1_sum_cost_per_term = Some(26);
4010
4011 cfg.group_ops_bls12381_pairing_cost = Some(26897);
4012 cfg.group_ops_bls12381_uncompressed_g1_sum_max_terms = Some(1200);
4013
4014 cfg.validator_validate_metadata_cost_base = Some(20000);
4015 }
4016 71 => {
4017 cfg.sip_45_consensus_amplification_threshold = Some(5);
4018
4019 cfg.allowed_txn_cost_overage_burst_per_object_in_commit = Some(185_000_000);
4021 }
4022 72 => {
4023 cfg.feature_flags.convert_type_argument_error = true;
4024
4025 cfg.max_tx_gas = Some(50_000_000_000_000);
4028 cfg.max_gas_price = Some(50_000_000_000);
4030
4031 cfg.feature_flags.variant_nodes = true;
4032 }
4033 73 => {
4034 cfg.use_object_per_epoch_marker_table_v2 = Some(true);
4036
4037 if chain != Chain::Mainnet && chain != Chain::Testnet {
4038 cfg.consensus_gc_depth = Some(60);
4041 }
4042
4043 if chain != Chain::Mainnet {
4044 cfg.feature_flags.consensus_zstd_compression = true;
4046 }
4047
4048 cfg.feature_flags.consensus_smart_ancestor_selection = true;
4050 cfg.feature_flags
4052 .consensus_round_prober_probe_accepted_rounds = true;
4053
4054 cfg.feature_flags.per_object_congestion_control_mode =
4056 PerObjectCongestionControlMode::TotalGasBudgetWithCap;
4057 cfg.gas_budget_based_txn_cost_cap_factor = Some(400_000);
4058 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(37_000_000);
4059 cfg.max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit =
4060 Some(7_400_000); cfg.max_txn_cost_overage_per_object_in_commit = Some(u64::MAX);
4062 cfg.gas_budget_based_txn_cost_absolute_cap_commit_count = Some(50);
4063 cfg.allowed_txn_cost_overage_burst_per_object_in_commit = Some(370_000_000);
4064 }
4065 74 => {
4066 if chain != Chain::Mainnet && chain != Chain::Testnet {
4068 cfg.feature_flags.enable_nitro_attestation = true;
4069 }
4070 cfg.nitro_attestation_parse_base_cost = Some(53 * 50);
4071 cfg.nitro_attestation_parse_cost_per_byte = Some(50);
4072 cfg.nitro_attestation_verify_base_cost = Some(49632 * 50);
4073 cfg.nitro_attestation_verify_cost_per_cert = Some(52369 * 50);
4074
4075 cfg.feature_flags.consensus_zstd_compression = true;
4077
4078 if chain != Chain::Mainnet && chain != Chain::Testnet {
4079 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
4080 }
4081 }
4082 75 => {
4083 if chain != Chain::Mainnet {
4084 cfg.feature_flags.passkey_auth = true;
4085 }
4086 }
4087 76 => {
4088 if chain != Chain::Mainnet && chain != Chain::Testnet {
4089 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
4090 cfg.consensus_commit_rate_estimation_window_size = Some(10);
4091 }
4092 cfg.feature_flags.minimize_child_object_mutations = true;
4093
4094 if chain != Chain::Mainnet {
4095 cfg.feature_flags.accept_passkey_in_multisig = true;
4096 }
4097 }
4098 77 => {
4099 cfg.feature_flags.uncompressed_g1_group_elements = true;
4100
4101 if chain != Chain::Mainnet {
4102 cfg.consensus_gc_depth = Some(60);
4103 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
4104 }
4105 }
4106 78 => {
4107 cfg.feature_flags.move_native_context = true;
4108 cfg.tx_context_fresh_id_cost_base = Some(52);
4109 cfg.tx_context_sender_cost_base = Some(30);
4110 cfg.tx_context_epoch_cost_base = Some(30);
4111 cfg.tx_context_epoch_timestamp_ms_cost_base = Some(30);
4112 cfg.tx_context_sponsor_cost_base = Some(30);
4113 cfg.tx_context_gas_price_cost_base = Some(30);
4114 cfg.tx_context_gas_budget_cost_base = Some(30);
4115 cfg.tx_context_ids_created_cost_base = Some(30);
4116 cfg.tx_context_replace_cost_base = Some(30);
4117 cfg.gas_model_version = Some(10);
4118
4119 if chain != Chain::Mainnet {
4120 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
4121 cfg.consensus_commit_rate_estimation_window_size = Some(10);
4122
4123 cfg.feature_flags.per_object_congestion_control_mode =
4125 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4126 ExecutionTimeEstimateParams {
4127 target_utilization: 30,
4128 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4130 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4132 stored_observations_limit: u64::MAX,
4133 stake_weighted_median_threshold: 0,
4134 default_none_duration_for_new_keys: false,
4135 observations_chunk_size: None,
4136 },
4137 );
4138 }
4139 }
4140 79 => {
4141 if chain != Chain::Mainnet {
4142 cfg.feature_flags.consensus_median_based_commit_timestamp = true;
4143
4144 cfg.consensus_bad_nodes_stake_threshold = Some(30);
4147
4148 cfg.feature_flags.consensus_batched_block_sync = true;
4149
4150 cfg.feature_flags.enable_nitro_attestation = true
4152 }
4153 cfg.feature_flags.normalize_ptb_arguments = true;
4154
4155 cfg.consensus_gc_depth = Some(60);
4156 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
4157 }
4158 80 => {
4159 cfg.max_ptb_value_size = Some(1024 * 1024);
4160 }
4161 81 => {
4162 cfg.feature_flags.consensus_median_based_commit_timestamp = true;
4163 cfg.feature_flags.enforce_checkpoint_timestamp_monotonicity = true;
4164 cfg.consensus_bad_nodes_stake_threshold = Some(30)
4165 }
4166 82 => {
4167 cfg.feature_flags.max_ptb_value_size_v2 = true;
4168 }
4169 83 => {
4170 if chain == Chain::Mainnet {
4171 let aliased: [u8; 32] = Hex::decode(
4173 "0x0b2da327ba6a4cacbe75dddd50e6e8bbf81d6496e92d66af9154c61c77f7332f",
4174 )
4175 .unwrap()
4176 .try_into()
4177 .unwrap();
4178
4179 cfg.aliased_addresses.push(AliasedAddress {
4181 original: Hex::decode("0xcd8962dad278d8b50fa0f9eb0186bfa4cbdecc6d59377214c88d0286a0ac9562").unwrap().try_into().unwrap(),
4182 aliased,
4183 allowed_tx_digests: vec![
4184 Base58::decode("B2eGLFoMHgj93Ni8dAJBfqGzo8EWSTLBesZzhEpTPA4").unwrap().try_into().unwrap(),
4185 ],
4186 });
4187
4188 cfg.aliased_addresses.push(AliasedAddress {
4189 original: Hex::decode("0xe28b50cef1d633ea43d3296a3f6b67ff0312a5f1a99f0af753c85b8b5de8ff06").unwrap().try_into().unwrap(),
4190 aliased,
4191 allowed_tx_digests: vec![
4192 Base58::decode("J4QqSAgp7VrQtQpMy5wDX4QGsCSEZu3U5KuDAkbESAge").unwrap().try_into().unwrap(),
4193 ],
4194 });
4195 }
4196
4197 if chain != Chain::Mainnet {
4200 cfg.feature_flags.resolve_type_input_ids_to_defining_id = true;
4201 cfg.transfer_party_transfer_internal_cost_base = Some(52);
4202
4203 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
4205 cfg.consensus_commit_rate_estimation_window_size = Some(10);
4206 cfg.feature_flags.per_object_congestion_control_mode =
4207 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4208 ExecutionTimeEstimateParams {
4209 target_utilization: 30,
4210 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4212 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4214 stored_observations_limit: u64::MAX,
4215 stake_weighted_median_threshold: 0,
4216 default_none_duration_for_new_keys: false,
4217 observations_chunk_size: None,
4218 },
4219 );
4220
4221 cfg.feature_flags.consensus_batched_block_sync = true;
4223
4224 cfg.feature_flags.enable_nitro_attestation_upgraded_parsing = true;
4227 cfg.feature_flags.enable_nitro_attestation = true;
4228 }
4229 }
4230 84 => {
4231 if chain == Chain::Mainnet {
4232 cfg.feature_flags.resolve_type_input_ids_to_defining_id = true;
4233 cfg.transfer_party_transfer_internal_cost_base = Some(52);
4234
4235 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
4237 cfg.consensus_commit_rate_estimation_window_size = Some(10);
4238 cfg.feature_flags.per_object_congestion_control_mode =
4239 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4240 ExecutionTimeEstimateParams {
4241 target_utilization: 30,
4242 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4244 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4246 stored_observations_limit: u64::MAX,
4247 stake_weighted_median_threshold: 0,
4248 default_none_duration_for_new_keys: false,
4249 observations_chunk_size: None,
4250 },
4251 );
4252
4253 cfg.feature_flags.consensus_batched_block_sync = true;
4255
4256 cfg.feature_flags.enable_nitro_attestation_upgraded_parsing = true;
4259 cfg.feature_flags.enable_nitro_attestation = true;
4260 }
4261
4262 cfg.feature_flags.per_object_congestion_control_mode =
4264 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4265 ExecutionTimeEstimateParams {
4266 target_utilization: 30,
4267 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4269 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4271 stored_observations_limit: 20,
4272 stake_weighted_median_threshold: 0,
4273 default_none_duration_for_new_keys: false,
4274 observations_chunk_size: None,
4275 },
4276 );
4277 cfg.feature_flags.allow_unbounded_system_objects = true;
4278 }
4279 85 => {
4280 if chain != Chain::Mainnet && chain != Chain::Testnet {
4281 cfg.feature_flags.enable_party_transfer = true;
4282 }
4283
4284 cfg.feature_flags
4285 .record_consensus_determined_version_assignments_in_prologue_v2 = true;
4286 cfg.feature_flags.disallow_self_identifier = true;
4287 cfg.feature_flags.per_object_congestion_control_mode =
4288 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4289 ExecutionTimeEstimateParams {
4290 target_utilization: 50,
4291 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4293 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4295 stored_observations_limit: 20,
4296 stake_weighted_median_threshold: 0,
4297 default_none_duration_for_new_keys: false,
4298 observations_chunk_size: None,
4299 },
4300 );
4301 }
4302 86 => {
4303 cfg.feature_flags.type_tags_in_object_runtime = true;
4304 cfg.max_move_enum_variants = Some(move_core_types::VARIANT_COUNT_MAX);
4305
4306 cfg.feature_flags.per_object_congestion_control_mode =
4308 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4309 ExecutionTimeEstimateParams {
4310 target_utilization: 50,
4311 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4313 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4315 stored_observations_limit: 20,
4316 stake_weighted_median_threshold: 3334,
4317 default_none_duration_for_new_keys: false,
4318 observations_chunk_size: None,
4319 },
4320 );
4321 if chain != Chain::Mainnet {
4323 cfg.feature_flags.enable_party_transfer = true;
4324 }
4325 }
4326 87 => {
4327 if chain == Chain::Mainnet {
4328 cfg.feature_flags.record_time_estimate_processed = true;
4329 }
4330 cfg.feature_flags.better_adapter_type_resolution_errors = true;
4331 }
4332 88 => {
4333 cfg.feature_flags.record_time_estimate_processed = true;
4334 cfg.tx_context_rgp_cost_base = Some(30);
4335 cfg.feature_flags
4336 .ignore_execution_time_observations_after_certs_closed = true;
4337
4338 cfg.feature_flags.per_object_congestion_control_mode =
4341 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4342 ExecutionTimeEstimateParams {
4343 target_utilization: 50,
4344 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4346 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4348 stored_observations_limit: 20,
4349 stake_weighted_median_threshold: 3334,
4350 default_none_duration_for_new_keys: true,
4351 observations_chunk_size: None,
4352 },
4353 );
4354 }
4355 89 => {
4356 cfg.feature_flags.dependency_linkage_error = true;
4357 cfg.feature_flags.additional_multisig_checks = true;
4358 }
4359 90 => {
4360 cfg.max_gas_price_rgp_factor_for_aborted_transactions = Some(100);
4362 cfg.feature_flags.debug_fatal_on_move_invariant_violation = true;
4363 cfg.feature_flags.additional_consensus_digest_indirect_state = true;
4364 cfg.feature_flags.accept_passkey_in_multisig = true;
4365 cfg.feature_flags.passkey_auth = true;
4366 cfg.feature_flags.check_for_init_during_upgrade = true;
4367
4368 if chain != Chain::Mainnet {
4370 cfg.feature_flags.mysticeti_fastpath = true;
4371 }
4372 }
4373 91 => {
4374 cfg.feature_flags.per_command_shared_object_transfer_rules = true;
4375 }
4376 92 => {
4377 cfg.feature_flags.per_command_shared_object_transfer_rules = false;
4378 }
4379 93 => {
4380 cfg.feature_flags
4381 .consensus_checkpoint_signature_key_includes_digest = true;
4382 }
4383 94 => {
4384 cfg.feature_flags.per_object_congestion_control_mode =
4386 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4387 ExecutionTimeEstimateParams {
4388 target_utilization: 50,
4389 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4391 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4393 stored_observations_limit: 18,
4394 stake_weighted_median_threshold: 3334,
4395 default_none_duration_for_new_keys: true,
4396 observations_chunk_size: None,
4397 },
4398 );
4399
4400 cfg.feature_flags.enable_party_transfer = true;
4402 }
4403 95 => {
4404 cfg.type_name_id_base_cost = Some(52);
4405
4406 cfg.max_transactions_per_checkpoint = Some(20_000);
4408 }
4409 96 => {
4410 if chain != Chain::Mainnet && chain != Chain::Testnet {
4412 cfg.feature_flags
4413 .include_checkpoint_artifacts_digest_in_summary = true;
4414 }
4415 cfg.feature_flags.correct_gas_payment_limit_check = true;
4416 cfg.feature_flags.authority_capabilities_v2 = true;
4417 cfg.feature_flags.use_mfp_txns_in_load_initial_object_debts = true;
4418 cfg.feature_flags.cancel_for_failed_dkg_early = true;
4419 cfg.feature_flags.enable_coin_registry = true;
4420
4421 cfg.feature_flags.mysticeti_fastpath = true;
4423 }
4424 97 => {
4425 cfg.feature_flags.additional_borrow_checks = true;
4426 }
4427 98 => {
4428 cfg.event_emit_auth_stream_cost = Some(52);
4429 cfg.feature_flags.better_loader_errors = true;
4430 cfg.feature_flags.generate_df_type_layouts = true;
4431 }
4432 99 => {
4433 cfg.feature_flags.use_new_commit_handler = true;
4434 }
4435 100 => {
4436 cfg.feature_flags.private_generics_verifier_v2 = true;
4437 }
4438 101 => {
4439 cfg.feature_flags.create_root_accumulator_object = true;
4440 cfg.max_updates_per_settlement_txn = Some(100);
4441 if chain != Chain::Mainnet {
4442 cfg.feature_flags.enable_poseidon = true;
4443 }
4444 }
4445 102 => {
4446 cfg.feature_flags.per_object_congestion_control_mode =
4450 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4451 ExecutionTimeEstimateParams {
4452 target_utilization: 50,
4453 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4455 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4457 stored_observations_limit: 180,
4458 stake_weighted_median_threshold: 3334,
4459 default_none_duration_for_new_keys: true,
4460 observations_chunk_size: Some(18),
4461 },
4462 );
4463 cfg.feature_flags.deprecate_global_storage_ops = true;
4464 }
4465 103 => {}
4466 104 => {
4467 cfg.translation_per_command_base_charge = Some(1);
4468 cfg.translation_per_input_base_charge = Some(1);
4469 cfg.translation_pure_input_per_byte_charge = Some(1);
4470 cfg.translation_per_type_node_charge = Some(1);
4471 cfg.translation_per_reference_node_charge = Some(1);
4472 cfg.translation_per_linkage_entry_charge = Some(10);
4473 cfg.gas_model_version = Some(11);
4474 cfg.feature_flags.abstract_size_in_object_runtime = true;
4475 cfg.feature_flags.object_runtime_charge_cache_load_gas = true;
4476 cfg.dynamic_field_hash_type_and_key_cost_base = Some(52);
4477 cfg.dynamic_field_add_child_object_cost_base = Some(52);
4478 cfg.dynamic_field_add_child_object_value_cost_per_byte = Some(1);
4479 cfg.dynamic_field_borrow_child_object_cost_base = Some(52);
4480 cfg.dynamic_field_borrow_child_object_child_ref_cost_per_byte = Some(1);
4481 cfg.dynamic_field_remove_child_object_cost_base = Some(52);
4482 cfg.dynamic_field_remove_child_object_child_cost_per_byte = Some(1);
4483 cfg.dynamic_field_has_child_object_cost_base = Some(52);
4484 cfg.dynamic_field_has_child_object_with_ty_cost_base = Some(52);
4485 cfg.feature_flags.enable_ptb_execution_v2 = true;
4486
4487 cfg.poseidon_bn254_cost_base = Some(260);
4488
4489 cfg.feature_flags.consensus_skip_gced_accept_votes = true;
4490
4491 if chain != Chain::Mainnet {
4492 cfg.feature_flags
4493 .enable_nitro_attestation_all_nonzero_pcrs_parsing = true;
4494 }
4495
4496 cfg.feature_flags
4497 .include_cancelled_randomness_txns_in_prologue = true;
4498 }
4499 105 => {
4500 cfg.feature_flags.enable_multi_epoch_transaction_expiration = true;
4501 cfg.feature_flags.disable_preconsensus_locking = true;
4502
4503 if chain != Chain::Mainnet {
4504 cfg.feature_flags
4505 .enable_nitro_attestation_always_include_required_pcrs_parsing = true;
4506 }
4507 }
4508 106 => {
4509 cfg.accumulator_object_storage_cost = Some(7600);
4511
4512 if chain != Chain::Mainnet && chain != Chain::Testnet {
4513 cfg.feature_flags.enable_accumulators = true;
4514 cfg.feature_flags.enable_address_balance_gas_payments = true;
4515 cfg.feature_flags.enable_authenticated_event_streams = true;
4516 cfg.feature_flags.enable_object_funds_withdraw = true;
4517 }
4518 }
4519 107 => {
4520 cfg.feature_flags
4521 .consensus_skip_gced_blocks_in_direct_finalization = true;
4522
4523 if in_integration_test() {
4525 cfg.consensus_gc_depth = Some(6);
4526 cfg.consensus_max_num_transactions_in_block = Some(8);
4527 }
4528 }
4529 108 => {
4530 cfg.feature_flags.gas_rounding_halve_digits = true;
4531 cfg.feature_flags.flexible_tx_context_positions = true;
4532 cfg.feature_flags.disable_entry_point_signature_check = true;
4533
4534 if chain != Chain::Mainnet {
4535 cfg.feature_flags.address_aliases = true;
4536
4537 cfg.feature_flags.enable_accumulators = true;
4538 cfg.feature_flags.enable_address_balance_gas_payments = true;
4539 }
4540
4541 cfg.feature_flags.enable_poseidon = true;
4542 }
4543 109 => {
4544 cfg.binary_variant_handles = Some(1024);
4545 cfg.binary_variant_instantiation_handles = Some(1024);
4546 cfg.feature_flags.restrict_hot_or_not_entry_functions = true;
4547 }
4548 110 => {
4549 cfg.feature_flags
4550 .enable_nitro_attestation_all_nonzero_pcrs_parsing = true;
4551 cfg.feature_flags
4552 .enable_nitro_attestation_always_include_required_pcrs_parsing = true;
4553 if chain != Chain::Mainnet && chain != Chain::Testnet {
4554 cfg.feature_flags.split_checkpoints_in_consensus_handler = true;
4555 }
4556 cfg.feature_flags.validate_zklogin_public_identifier = true;
4557 cfg.feature_flags.fix_checkpoint_signature_mapping = true;
4558 cfg.feature_flags
4559 .consensus_always_accept_system_transactions = true;
4560 if chain != Chain::Mainnet {
4561 cfg.feature_flags.enable_object_funds_withdraw = true;
4562 }
4563 }
4564 111 => {
4565 cfg.feature_flags.validator_metadata_verify_v2 = true;
4566 }
4567 112 => {
4568 cfg.group_ops_ristretto_decode_scalar_cost = Some(7);
4569 cfg.group_ops_ristretto_decode_point_cost = Some(200);
4570 cfg.group_ops_ristretto_scalar_add_cost = Some(10);
4571 cfg.group_ops_ristretto_point_add_cost = Some(500);
4572 cfg.group_ops_ristretto_scalar_sub_cost = Some(10);
4573 cfg.group_ops_ristretto_point_sub_cost = Some(500);
4574 cfg.group_ops_ristretto_scalar_mul_cost = Some(11);
4575 cfg.group_ops_ristretto_point_mul_cost = Some(1200);
4576 cfg.group_ops_ristretto_scalar_div_cost = Some(151);
4577 cfg.group_ops_ristretto_point_div_cost = Some(2500);
4578
4579 if chain != Chain::Mainnet && chain != Chain::Testnet {
4580 cfg.feature_flags.enable_ristretto255_group_ops = true;
4581 }
4582 }
4583 113 => {
4584 cfg.feature_flags.address_balance_gas_check_rgp_at_signing = true;
4585 if chain != Chain::Mainnet && chain != Chain::Testnet {
4586 cfg.feature_flags.defer_unpaid_amplification = true;
4587 }
4588 }
4589 114 => {
4590 cfg.feature_flags.randomize_checkpoint_tx_limit_in_tests = true;
4591 cfg.feature_flags.address_balance_gas_reject_gas_coin_arg = true;
4592 if chain != Chain::Mainnet {
4593 cfg.feature_flags.split_checkpoints_in_consensus_handler = true;
4594 cfg.feature_flags.enable_authenticated_event_streams = true;
4595 cfg.feature_flags
4596 .include_checkpoint_artifacts_digest_in_summary = true;
4597 }
4598 }
4599 115 => {
4600 cfg.feature_flags.normalize_depth_formula = true;
4601 }
4602 116 => {
4603 cfg.feature_flags.gasless_transaction_drop_safety = true;
4604 cfg.feature_flags.address_aliases = true;
4605 cfg.feature_flags.relax_valid_during_for_owned_inputs = true;
4606 cfg.feature_flags.defer_unpaid_amplification = false;
4608 cfg.feature_flags.enable_display_registry = true;
4609 }
4610 117 => {}
4611 118 => {
4612 cfg.feature_flags.use_coin_party_owner = true;
4613 }
4614 119 => {
4615 cfg.execution_version = Some(4);
4617 cfg.feature_flags.address_balance_gas_reject_gas_coin_arg = false;
4618 cfg.feature_flags.merge_randomness_into_checkpoint = true;
4619 if chain != Chain::Mainnet {
4620 cfg.feature_flags.enable_gasless = true;
4621 cfg.gasless_max_computation_units = Some(50_000);
4622 cfg.gasless_allowed_token_types = Some(vec![]);
4623 cfg.feature_flags.enable_coin_reservation_obj_refs = true;
4624 cfg.feature_flags
4625 .convert_withdrawal_compatibility_ptb_arguments = true;
4626 }
4627 cfg.gasless_max_unused_inputs = Some(1);
4628 cfg.gasless_max_pure_input_bytes = Some(32);
4629 if chain == Chain::Testnet {
4630 cfg.gasless_allowed_token_types = Some(vec![(TESTNET_USDC.to_string(), 0)]);
4631 }
4632 cfg.transfer_receive_object_cost_per_byte = Some(1);
4633 cfg.transfer_receive_object_type_cost_per_byte = Some(2);
4634 }
4635 120 => {
4636 cfg.feature_flags.disallow_jump_orphans = true;
4637 }
4638 121 => {
4639 if chain != Chain::Mainnet {
4641 cfg.feature_flags.defer_unpaid_amplification = true;
4642 cfg.gasless_max_tps = Some(50);
4643 }
4644 cfg.feature_flags
4645 .early_return_receive_object_mismatched_type = true;
4646 }
4647 122 => {
4648 cfg.feature_flags.defer_unpaid_amplification = true;
4650 cfg.verify_bulletproofs_ristretto255_base_cost = Some(30000);
4652 cfg.verify_bulletproofs_ristretto255_cost_per_bit_and_commitment = Some(6500);
4653 if chain != Chain::Mainnet && chain != Chain::Testnet {
4654 cfg.feature_flags.enable_verify_bulletproofs_ristretto255 = true;
4655 }
4656 cfg.feature_flags.gasless_verify_remaining_balance = true;
4657 cfg.include_special_package_amendments = match chain {
4658 Chain::Mainnet => Some(MAINNET_LINKAGE_AMENDMENTS.clone()),
4659 Chain::Testnet => Some(TESTNET_LINKAGE_AMENDMENTS.clone()),
4660 Chain::Unknown => None,
4661 };
4662 cfg.gasless_max_tx_size_bytes = Some(16 * 1024);
4663 cfg.gasless_max_tps = Some(300);
4664 cfg.gasless_max_computation_units = Some(5_000);
4665 }
4666 123 => {
4667 cfg.gas_model_version = Some(13);
4668 }
4669 124 => {
4670 if chain != Chain::Mainnet && chain != Chain::Testnet {
4671 cfg.feature_flags.timestamp_based_epoch_close = true;
4672 }
4673 cfg.gas_model_version = Some(14);
4674 cfg.feature_flags.limit_groth16_pvk_inputs = true;
4675
4676 cfg.feature_flags.enable_accumulators = true;
4682 cfg.feature_flags.enable_address_balance_gas_payments = true;
4683 cfg.feature_flags.enable_authenticated_event_streams = true;
4684 cfg.feature_flags.enable_coin_reservation_obj_refs = true;
4685 cfg.feature_flags.enable_object_funds_withdraw = true;
4686 cfg.feature_flags
4687 .convert_withdrawal_compatibility_ptb_arguments = true;
4688 cfg.feature_flags.split_checkpoints_in_consensus_handler = true;
4689 cfg.feature_flags
4690 .include_checkpoint_artifacts_digest_in_summary = true;
4691 cfg.feature_flags.enable_gasless = true;
4692
4693 if chain == Chain::Mainnet {
4698 cfg.gasless_allowed_token_types = Some(vec![
4699 (MAINNET_USDC.to_string(), 10_000),
4700 (MAINNET_USDSUI.to_string(), 10_000),
4701 (MAINNET_SUI_USDE.to_string(), 10_000),
4702 (MAINNET_USDY.to_string(), 10_000),
4703 (MAINNET_FDUSD.to_string(), 10_000),
4704 (MAINNET_AUSD.to_string(), 10_000),
4705 (MAINNET_USDB.to_string(), 10_000),
4706 ]);
4707 }
4708 }
4709 125 => {
4710 cfg.feature_flags.granular_post_execution_checks = true;
4711 if chain != Chain::Mainnet {
4712 cfg.feature_flags.timestamp_based_epoch_close = true;
4713 }
4714 }
4715 126 => {
4716 cfg.feature_flags.early_exit_on_iffw = true;
4717 }
4718 127 => {
4719 cfg.feature_flags.always_advance_dkg_to_resolution = true;
4720
4721 cfg.verify_bulletproofs_ristretto255_base_cost = Some(23866);
4722 cfg.verify_bulletproofs_ristretto255_cost_per_bit_and_commitment = Some(1324);
4723 cfg.group_ops_ristretto_decode_scalar_cost = Some(5);
4724 cfg.group_ops_ristretto_decode_point_cost = Some(216);
4725 cfg.group_ops_ristretto_scalar_add_cost = Some(2);
4726 cfg.group_ops_ristretto_point_add_cost = Some(8);
4727 cfg.group_ops_ristretto_scalar_sub_cost = Some(2);
4728 cfg.group_ops_ristretto_point_sub_cost = Some(8);
4729 cfg.group_ops_ristretto_scalar_mul_cost = Some(5);
4730 cfg.group_ops_ristretto_point_mul_cost = Some(1763);
4731 cfg.group_ops_ristretto_scalar_div_cost = Some(557);
4732 cfg.group_ops_ristretto_point_div_cost = Some(2244);
4733
4734 if chain != Chain::Mainnet {
4735 cfg.feature_flags.enable_ristretto255_group_ops = true;
4736 cfg.feature_flags.enable_verify_bulletproofs_ristretto255 = true;
4737 }
4738
4739 cfg.feature_flags.timestamp_based_epoch_close = true;
4740 }
4741 128 => {
4742 cfg.max_generic_instantiation_type_nodes_per_function = Some(10_000);
4743 cfg.max_generic_instantiation_type_nodes_per_module = Some(500_000);
4744 cfg.binary_enum_defs = Some(200);
4745 cfg.binary_enum_def_instantiations = Some(100);
4746 }
4747 129 => {
4748 cfg.feature_flags.enable_unified_linkage = true;
4749 }
4750 130 => {
4751 cfg.feature_flags.record_net_unsettled_object_withdraws = true;
4752 cfg.feature_flags.enable_init_on_upgrade = true;
4753 cfg.epoch_close_deadline_ms = Some(120_000);
4754 cfg.scratch_add_cost_base = Some(13);
4755 cfg.scratch_read_cost_base = Some(13);
4756 cfg.scratch_read_value_cost = Some(1);
4757 cfg.scratch_remove_cost_base = Some(13);
4758 cfg.scratch_exists_cost_base = Some(13);
4759 cfg.scratch_exists_with_type_cost_base = Some(13);
4760 cfg.scratch_exists_with_type_type_cost = Some(1);
4761 let max_commands = cfg.max_programmable_tx_commands() as u64;
4762 cfg.max_scratch_pad_size = Some(16 * max_commands);
4763 if chain != Chain::Mainnet && chain != Chain::Testnet {
4765 cfg.feature_flags.zklogin_circuit_mode = 1;
4766 }
4767 }
4768 131 => {
4769 cfg.feature_flags.share_transaction_deny_config_in_consensus = true;
4770 cfg.feature_flags.framework_tx_context_mut_restrictions = true;
4771 }
4772 132 => {
4773 if chain != Chain::Mainnet && chain != Chain::Testnet {
4774 cfg.feature_flags.defer_owned_object_double_spend = true;
4775 cfg.feature_flags.create_forwarding_address_registry = true;
4776 }
4777 cfg.object_record_new_uid_from_hash_cost_base = Some(1);
4778 cfg.feature_flags
4779 .enable_order_independent_upgrade_init_linkage = true;
4780 }
4781 133 => {
4782 cfg.feature_flags
4783 .include_function_signatures_in_instantiation_limits = true;
4784 cfg.max_accumulator_type_nodes = Some(16);
4785 }
4786 134 => {
4787 if chain != Chain::Mainnet {
4794 cfg.package_original_package_id_impl_cost_base = Some(52);
4795 let package_read_cost_per_byte = cfg.obj_access_cost_read_per_byte();
4796 cfg.package_original_package_id_impl_cost_per_byte =
4797 Some(package_read_cost_per_byte);
4798
4799 cfg.consensus_max_transactions_in_block_bytes = Some(288 * 1024);
4800 cfg.consensus_max_num_transactions_in_block = Some(128);
4801 }
4802
4803 if chain == Chain::Mainnet {
4804 cfg.feature_flags.defer_unpaid_amplification = false;
4805 }
4806 }
4807 135 => {
4808 cfg.package_original_package_id_impl_cost_base = Some(52);
4811 let package_read_cost_per_byte = cfg.obj_access_cost_read_per_byte();
4812 cfg.package_original_package_id_impl_cost_per_byte =
4813 Some(package_read_cost_per_byte);
4814
4815 cfg.consensus_max_transactions_in_block_bytes = Some(288 * 1024);
4816 cfg.consensus_max_num_transactions_in_block = Some(128);
4817
4818 cfg.feature_flags.defer_unpaid_amplification = false;
4819 }
4820 136 => {
4821 cfg.feature_flags.ptb_tx_context_restrictions = true;
4822
4823 cfg.translation_per_live_reference_charge = Some(1);
4824 cfg.max_ptb_live_references = Some(64);
4825 cfg.max_ptb_returned_references = Some(16);
4826 cfg.max_ptb_total_returned_references = Some(256);
4827
4828 if chain != Chain::Mainnet && chain != Chain::Testnet {
4829 cfg.feature_flags.allowed_proposers = true;
4830 }
4831 cfg.feature_flags.harden_linkage_consistency = true;
4832
4833 cfg.package_arena_size_in_bytes = Some(10_000_000);
4834 }
4835 137 => {
4836 cfg.verify_bulletproofs_ristretto255_cost_per_bit_and_commitment = Some(621);
4837 cfg.max_bulletproofs_total_bits = Some(1024);
4838
4839 if chain != Chain::Mainnet {
4840 cfg.feature_flags.enable_allowances = true;
4841 }
4842 cfg.feature_flags.fix_ptb_generated_reads = true;
4843 cfg.feature_flags.charge_ld_const_abstract_size = true;
4844 if chain != Chain::Mainnet && chain != Chain::Testnet {
4845 cfg.feature_flags.check_object_funds_withdraw_in_execution = true;
4846 }
4847 cfg.reserve_object_funds_for_withdrawal_cost_base = Some(52);
4848 cfg.reserve_object_funds_for_withdrawal_cold_read_cost = Some(184);
4851
4852 cfg.feature_flags.allowed_proposers = true;
4853
4854 cfg.feature_flags.validate_ptb_argument_indices = true;
4855 cfg.feature_flags.memory_safety_invariant_check_v2 = true;
4856 }
4857 138 => {
4858 cfg.gas_model_version = Some(15);
4859 cfg.feature_flags.enable_allowances = true;
4860 if chain != Chain::Mainnet {
4861 cfg.feature_flags.check_object_funds_withdraw_in_execution = true;
4862 cfg.feature_flags.disable_effects_tx_dependencies = true;
4863 }
4864 cfg.feature_flags.merge_colliding_deferrals = true;
4865 if chain == Chain::Mainnet {
4867 cfg.storage_rebate_rate = Some(9999);
4868 }
4869 }
4870 139 => {
4871 if chain != Chain::Mainnet && chain != Chain::Testnet {
4872 cfg.feature_flags.enable_forwarding_addresses = true;
4873 cfg.feature_flags.mldsa65_auth = true;
4874 }
4875 cfg.storage_rebate_rate = Some(9999);
4876 if chain != Chain::Mainnet {
4877 cfg.feature_flags.allow_dkg_completion_after_timeout = true;
4878 }
4879 cfg.obj_access_cost_read_per_package_kb = Some(154);
4881 }
4882 140 => {
4883 cfg.vector_reverse_base_cost = Some(52);
4884 cfg.vector_reverse_per_elem_cost = Some(8);
4885 cfg.vector_keep_range_base_cost = Some(52);
4886 cfg.vector_keep_range_per_dropped_elem_cost = Some(1);
4887 cfg.vector_keep_range_per_moved_elem_cost = Some(8);
4888 cfg.vector_copy_range_base_cost = Some(52);
4889 cfg.vector_replace_range_base_cost = Some(52);
4890 cfg.vector_replace_range_per_elem_cost = Some(8);
4891
4892 if chain != Chain::Mainnet && chain != Chain::Testnet {
4893 cfg.feature_flags.shuffle_consensus_commit_blocks = true;
4894 }
4895
4896 cfg.feature_flags.allow_references_in_ptbs = true;
4897 cfg.feature_flags.disable_id_leak_verifier = true;
4898 }
4899 _ => panic!("unsupported version {:?}", version),
4910 }
4911 }
4912
4913 cfg
4914 }
4915
4916 pub fn apply_seeded_test_overrides(&mut self, seed: &[u8; 32]) {
4917 if !self.feature_flags.randomize_checkpoint_tx_limit_in_tests
4918 || !self.feature_flags.split_checkpoints_in_consensus_handler
4919 {
4920 return;
4921 }
4922
4923 if !mysten_common::in_test_configuration() {
4924 return;
4925 }
4926
4927 use rand::{Rng, SeedableRng, rngs::StdRng};
4928 let mut rng = StdRng::from_seed(*seed);
4929 let max_txns = rng.gen_range(10..=100u64);
4930 info!("seeded test override: max_transactions_per_checkpoint = {max_txns}");
4931 self.max_transactions_per_checkpoint = Some(max_txns);
4932 }
4933
4934 pub fn verifier_config(&self, signing_limits: Option<(usize, usize, usize)>) -> VerifierConfig {
4940 let (
4941 max_back_edges_per_function,
4942 max_back_edges_per_module,
4943 sanity_check_with_regex_reference_safety,
4944 ) = if let Some((
4945 max_back_edges_per_function,
4946 max_back_edges_per_module,
4947 sanity_check_with_regex_reference_safety,
4948 )) = signing_limits
4949 {
4950 (
4951 Some(max_back_edges_per_function),
4952 Some(max_back_edges_per_module),
4953 Some(sanity_check_with_regex_reference_safety),
4954 )
4955 } else {
4956 (None, None, None)
4957 };
4958
4959 let additional_borrow_checks = if signing_limits.is_some() {
4960 true
4962 } else {
4963 self.additional_borrow_checks()
4964 };
4965 let deprecate_global_storage_ops = if signing_limits.is_some() {
4966 true
4968 } else {
4969 self.deprecate_global_storage_ops()
4970 };
4971
4972 VerifierConfig {
4973 max_loop_depth: Some(self.max_loop_depth() as usize),
4974 max_generic_instantiation_length: Some(self.max_generic_instantiation_length() as usize),
4975 max_function_parameters: Some(self.max_function_parameters() as usize),
4976 max_basic_blocks: Some(self.max_basic_blocks() as usize),
4977 max_value_stack_size: self.max_value_stack_size() as usize,
4978 max_type_nodes: Some(self.max_type_nodes() as usize),
4979 max_generic_instantiation_type_nodes_per_function: self
4980 .max_generic_instantiation_type_nodes_per_function_as_option()
4981 .map(|v| v as usize),
4982 max_generic_instantiation_type_nodes_per_module: self
4983 .max_generic_instantiation_type_nodes_per_module_as_option()
4984 .map(|v| v as usize),
4985 include_function_signatures_in_instantiation_limits: self
4986 .include_function_signatures_in_instantiation_limits(),
4987 max_push_size: Some(self.max_push_size() as usize),
4988 max_dependency_depth: Some(self.max_dependency_depth() as usize),
4989 max_fields_in_struct: Some(self.max_fields_in_struct() as usize),
4990 max_function_definitions: Some(self.max_function_definitions() as usize),
4991 max_data_definitions: Some(self.max_struct_definitions() as usize),
4992 max_constant_vector_len: Some(self.max_move_vector_len()),
4993 max_back_edges_per_function,
4994 max_back_edges_per_module,
4995 max_basic_blocks_in_script: None,
4996 max_identifier_len: self.max_move_identifier_len_as_option(), disallow_self_identifier: self.feature_flags.disallow_self_identifier,
4998 allow_receiving_object_id: self.allow_receiving_object_id(),
4999 reject_mutable_random_on_entry_functions: self
5000 .reject_mutable_random_on_entry_functions(),
5001 bytecode_version: self.move_binary_format_version(),
5002 max_variants_in_enum: self.max_move_enum_variants_as_option(),
5003 additional_borrow_checks,
5004 better_loader_errors: self.better_loader_errors(),
5005 private_generics_verifier_v2: self.private_generics_verifier_v2(),
5006 sanity_check_with_regex_reference_safety: sanity_check_with_regex_reference_safety
5007 .map(|limit| limit as u128),
5008 deprecate_global_storage_ops,
5009 disable_entry_point_signature_check: self.disable_entry_point_signature_check(),
5010 disable_id_leak_verifier: self.disable_id_leak_verifier(),
5011 switch_to_regex_reference_safety: false,
5012 framework_tx_context_mut_restrictions: self.framework_tx_context_mut_restrictions(),
5013 disallow_jump_orphans: self.disallow_jump_orphans(),
5014 }
5015 }
5016
5017 pub fn binary_config(
5018 &self,
5019 override_deprecate_global_storage_ops_during_deserialization: Option<bool>,
5020 ) -> BinaryConfig {
5021 let deprecate_global_storage_ops =
5022 override_deprecate_global_storage_ops_during_deserialization
5023 .unwrap_or_else(|| self.deprecate_global_storage_ops());
5024 BinaryConfig::new(
5025 self.move_binary_format_version(),
5026 self.min_move_binary_format_version_as_option()
5027 .unwrap_or(VERSION_1),
5028 self.no_extraneous_module_bytes(),
5029 deprecate_global_storage_ops,
5030 TableConfig {
5031 module_handles: self.binary_module_handles_as_option().unwrap_or(u16::MAX),
5032 datatype_handles: self.binary_struct_handles_as_option().unwrap_or(u16::MAX),
5033 function_handles: self.binary_function_handles_as_option().unwrap_or(u16::MAX),
5034 function_instantiations: self
5035 .binary_function_instantiations_as_option()
5036 .unwrap_or(u16::MAX),
5037 signatures: self.binary_signatures_as_option().unwrap_or(u16::MAX),
5038 constant_pool: self.binary_constant_pool_as_option().unwrap_or(u16::MAX),
5039 identifiers: self.binary_identifiers_as_option().unwrap_or(u16::MAX),
5040 address_identifiers: self
5041 .binary_address_identifiers_as_option()
5042 .unwrap_or(u16::MAX),
5043 struct_defs: self.binary_struct_defs_as_option().unwrap_or(u16::MAX),
5044 struct_def_instantiations: self
5045 .binary_struct_def_instantiations_as_option()
5046 .unwrap_or(u16::MAX),
5047 function_defs: self.binary_function_defs_as_option().unwrap_or(u16::MAX),
5048 field_handles: self.binary_field_handles_as_option().unwrap_or(u16::MAX),
5049 field_instantiations: self
5050 .binary_field_instantiations_as_option()
5051 .unwrap_or(u16::MAX),
5052 friend_decls: self.binary_friend_decls_as_option().unwrap_or(u16::MAX),
5053 enum_defs: self.binary_enum_defs_as_option().unwrap_or(u16::MAX),
5054 enum_def_instantiations: self
5055 .binary_enum_def_instantiations_as_option()
5056 .unwrap_or(u16::MAX),
5057 variant_handles: self.binary_variant_handles_as_option().unwrap_or(u16::MAX),
5058 variant_instantiation_handles: self
5059 .binary_variant_instantiation_handles_as_option()
5060 .unwrap_or(u16::MAX),
5061 },
5062 )
5063 }
5064
5065 pub fn apply_overrides_for_testing(
5069 override_fn: impl Fn(ProtocolVersion, Self) -> Self + Send + Sync + 'static,
5070 ) -> OverrideGuard {
5071 let mut cur = CONFIG_OVERRIDE.lock().unwrap();
5072 assert!(cur.is_none(), "config override already present");
5073 *cur = Some(Box::new(override_fn));
5074 OverrideGuard
5075 }
5076
5077 fn apply_config_override(version: ProtocolVersion, mut ret: Self) -> Self {
5078 if let Some(override_fn) = CONFIG_OVERRIDE.lock().unwrap().as_ref() {
5079 warn!(
5080 "overriding ProtocolConfig settings with custom settings (you should not see this log outside of tests)"
5081 );
5082 ret = override_fn(version, ret);
5083 }
5084 ret
5085 }
5086}
5087
5088impl ProtocolConfig {
5092 pub fn set_execution_version_for_testing(&mut self, val: u64) {
5096 let current = self.execution_version.unwrap_or(0);
5097 assert!(
5098 val >= current,
5099 "cannot downgrade execution_version from {current} to {val}: running an old \
5100 executor against a newer protocol config/framework is unsupported. To test \
5101 frozen executor behavior, start from the last protocol version of that executor \
5102 instead, so genesis loads the matching framework snapshot (see \
5103 test_address_balance_gas_v3_accumulator_sign)."
5104 );
5105 self.execution_version = Some(val);
5106 }
5107
5108 pub fn set_zklogin_circuit_mode_for_testing(&mut self, val: u64) {
5111 self.feature_flags.zklogin_circuit_mode = val
5112 }
5113
5114 pub fn set_per_object_congestion_control_mode_for_testing(
5115 &mut self,
5116 val: PerObjectCongestionControlMode,
5117 ) {
5118 self.feature_flags.per_object_congestion_control_mode = val;
5119 }
5120
5121 pub fn set_consensus_choice_for_testing(&mut self, val: ConsensusChoice) {
5122 self.feature_flags.consensus_choice = val;
5123 }
5124
5125 pub fn set_consensus_network_for_testing(&mut self, val: ConsensusNetwork) {
5126 self.feature_flags.consensus_network = val;
5127 }
5128
5129 pub fn set_zklogin_max_epoch_upper_bound_delta_for_testing(&mut self, val: Option<u64>) {
5130 self.feature_flags.zklogin_max_epoch_upper_bound_delta = val
5131 }
5132
5133 pub fn set_mysticeti_num_leaders_per_round_for_testing(&mut self, val: Option<usize>) {
5134 self.feature_flags.mysticeti_num_leaders_per_round = val;
5135 }
5136
5137 pub fn disable_accumulators_for_testing(&mut self) {
5138 self.feature_flags.enable_accumulators = false;
5139 self.feature_flags.enable_address_balance_gas_payments = false;
5140 }
5141
5142 pub fn enable_coin_reservation_for_testing(&mut self) {
5143 self.feature_flags.enable_coin_reservation_obj_refs = true;
5144 self.feature_flags
5145 .convert_withdrawal_compatibility_ptb_arguments = true;
5146 self.execution_version = Some(self.execution_version.map_or(4, |v| v.max(4)));
5149 }
5150
5151 pub fn disable_coin_reservation_for_testing(&mut self) {
5152 self.feature_flags.enable_coin_reservation_obj_refs = false;
5153 self.feature_flags
5154 .convert_withdrawal_compatibility_ptb_arguments = false;
5155 }
5156
5157 pub fn enable_address_balance_gas_payments_for_testing(&mut self) {
5158 self.feature_flags.enable_accumulators = true;
5159 self.feature_flags.allow_private_accumulator_entrypoints = true;
5160 self.feature_flags.enable_address_balance_gas_payments = true;
5161 self.feature_flags.address_balance_gas_check_rgp_at_signing = true;
5162 self.feature_flags.address_balance_gas_reject_gas_coin_arg = false;
5163 self.execution_version = Some(self.execution_version.map_or(4, |v| v.max(4)))
5164 }
5165
5166 pub fn enable_gasless_for_testing(&mut self) {
5167 self.enable_address_balance_gas_payments_for_testing();
5168 self.feature_flags.enable_gasless = true;
5169 self.feature_flags.gasless_verify_remaining_balance = true;
5170 self.gasless_max_computation_units = Some(5_000);
5171 self.gasless_allowed_token_types = Some(vec![]);
5172 self.gasless_max_tps = Some(1000);
5173 self.gasless_max_tx_size_bytes = Some(16 * 1024);
5174 }
5175
5176 pub fn disable_gasless_for_testing(&mut self) {
5177 self.feature_flags.enable_gasless = false;
5178 self.gasless_max_computation_units = None;
5179 self.gasless_allowed_token_types = None;
5180 }
5181
5182 pub fn enable_authenticated_event_streams_for_testing(&mut self) {
5183 self.feature_flags.enable_accumulators = true;
5184 self.feature_flags.enable_authenticated_event_streams = true;
5185 self.feature_flags
5186 .include_checkpoint_artifacts_digest_in_summary = true;
5187 self.feature_flags.split_checkpoints_in_consensus_handler = true;
5188 }
5189}
5190
5191type OverrideFn = dyn Fn(ProtocolVersion, ProtocolConfig) -> ProtocolConfig + Send + Sync;
5192
5193static CONFIG_OVERRIDE: Mutex<Option<Box<OverrideFn>>> = Mutex::new(None);
5194
5195#[must_use]
5196pub struct OverrideGuard;
5197
5198impl Drop for OverrideGuard {
5199 fn drop(&mut self) {
5200 info!("restoring override fn");
5201 *CONFIG_OVERRIDE.lock().unwrap() = None;
5202 }
5203}
5204
5205#[derive(PartialEq, Eq)]
5208pub enum LimitThresholdCrossed {
5209 None,
5210 Soft(u128, u128),
5211 Hard(u128, u128),
5212}
5213
5214pub fn check_limit_in_range<T: Into<V>, U: Into<V>, V: PartialOrd + Into<u128>>(
5217 x: T,
5218 soft_limit: U,
5219 hard_limit: V,
5220) -> LimitThresholdCrossed {
5221 let x: V = x.into();
5222 let soft_limit: V = soft_limit.into();
5223
5224 debug_assert!(soft_limit <= hard_limit);
5225
5226 if x >= hard_limit {
5229 LimitThresholdCrossed::Hard(x.into(), hard_limit.into())
5230 } else if x < soft_limit {
5231 LimitThresholdCrossed::None
5232 } else {
5233 LimitThresholdCrossed::Soft(x.into(), soft_limit.into())
5234 }
5235}
5236
5237#[macro_export]
5238macro_rules! check_limit {
5239 ($x:expr, $hard:expr) => {
5240 check_limit!($x, $hard, $hard)
5241 };
5242 ($x:expr, $soft:expr, $hard:expr) => {
5243 check_limit_in_range($x as u64, $soft, $hard)
5244 };
5245}
5246
5247#[macro_export]
5251macro_rules! check_limit_by_meter {
5252 ($is_metered:expr, $x:expr, $metered_limit:expr, $unmetered_hard_limit:expr, $metric:expr) => {{
5253 let (h, metered_str) = if $is_metered {
5255 ($metered_limit, "metered")
5256 } else {
5257 ($unmetered_hard_limit, "unmetered")
5259 };
5260 use sui_protocol_config::check_limit_in_range;
5261 let result = check_limit_in_range($x as u64, $metered_limit, h);
5262 match result {
5263 LimitThresholdCrossed::None => {}
5264 LimitThresholdCrossed::Soft(_, _) => {
5265 $metric.with_label_values(&[metered_str, "soft"]).inc();
5266 }
5267 LimitThresholdCrossed::Hard(_, _) => {
5268 $metric.with_label_values(&[metered_str, "hard"]).inc();
5269 }
5270 };
5271 result
5272 }};
5273}
5274
5275pub type Amendments = BTreeMap<AccountAddress, BTreeMap<AccountAddress, AccountAddress>>;
5278
5279static MAINNET_LINKAGE_AMENDMENTS: LazyLock<Arc<Amendments>> =
5280 LazyLock::new(|| parse_amendments(include_str!("mainnet_amendments.json")));
5281
5282static TESTNET_LINKAGE_AMENDMENTS: LazyLock<Arc<Amendments>> =
5283 LazyLock::new(|| parse_amendments(include_str!("testnet_amendments.json")));
5284
5285fn parse_amendments(json: &str) -> Arc<Amendments> {
5286 #[derive(serde::Deserialize)]
5287 struct AmendmentEntry {
5288 root: String,
5289 deps: Vec<DepEntry>,
5290 }
5291
5292 #[derive(serde::Deserialize)]
5293 struct DepEntry {
5294 original_id: String,
5295 version_id: String,
5296 }
5297
5298 let entries: Vec<AmendmentEntry> =
5299 serde_json::from_str(json).expect("Failed to parse amendments JSON");
5300 let mut amendments = BTreeMap::new();
5301 for entry in entries {
5302 let root_id = AccountAddress::from_hex_literal(&entry.root).unwrap();
5303 let mut dep_ids = BTreeMap::new();
5304 for dep in entry.deps {
5305 let orig_id = AccountAddress::from_hex_literal(&dep.original_id).unwrap();
5306 let upgraded_id = AccountAddress::from_hex_literal(&dep.version_id).unwrap();
5307 assert!(
5308 dep_ids.insert(orig_id, upgraded_id).is_none(),
5309 "Duplicate original ID in amendments table"
5310 );
5311 }
5312 assert!(
5313 amendments.insert(root_id, dep_ids).is_none(),
5314 "Duplicate root ID in amendments table"
5315 );
5316 }
5317 Arc::new(amendments)
5318}
5319
5320#[cfg(all(test, not(msim)))]
5321mod test {
5322 use insta::assert_yaml_snapshot;
5323
5324 use super::*;
5325
5326 #[test]
5327 fn snapshot_tests() {
5328 println!("\n============================================================================");
5329 println!("! !");
5330 println!("! IMPORTANT: never update snapshots from this test. only add new versions! !");
5331 println!("! !");
5332 println!("============================================================================\n");
5333 for chain_id in &[Chain::Unknown, Chain::Mainnet, Chain::Testnet] {
5334 let chain_str = match chain_id {
5338 Chain::Unknown => "".to_string(),
5339 _ => format!("{:?}_", chain_id),
5340 };
5341 for i in MIN_PROTOCOL_VERSION..=MAX_PROTOCOL_VERSION {
5342 let cur = ProtocolVersion::new(i);
5343 assert_yaml_snapshot!(
5344 format!("{}version_{}", chain_str, cur.as_u64()),
5345 ProtocolConfig::get_for_version(cur, *chain_id)
5346 );
5347 }
5348 }
5349 }
5350
5351 #[test]
5352 fn test_getters() {
5353 let prot: ProtocolConfig =
5354 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5355 assert_eq!(
5356 prot.max_arguments(),
5357 prot.max_arguments_as_option().unwrap()
5358 );
5359 }
5360
5361 #[test]
5362 fn vector_bulk_native_gas_costs_start_at_version_140() {
5363 for chain in [Chain::Unknown, Chain::Mainnet, Chain::Testnet] {
5364 let before = ProtocolConfig::get_for_version(ProtocolVersion::new(139), chain);
5365 assert_eq!(before.vector_reverse_base_cost_as_option(), None);
5366 assert_eq!(before.vector_reverse_per_elem_cost_as_option(), None);
5367 assert_eq!(before.vector_keep_range_base_cost_as_option(), None);
5368 assert_eq!(
5369 before.vector_keep_range_per_dropped_elem_cost_as_option(),
5370 None
5371 );
5372 assert_eq!(
5373 before.vector_keep_range_per_moved_elem_cost_as_option(),
5374 None
5375 );
5376 assert_eq!(before.vector_copy_range_base_cost_as_option(), None);
5377 assert_eq!(before.vector_replace_range_base_cost_as_option(), None);
5378 assert_eq!(before.vector_replace_range_per_elem_cost_as_option(), None);
5379
5380 let active = ProtocolConfig::get_for_version(ProtocolVersion::new(140), chain);
5381 assert_eq!(active.vector_reverse_base_cost_as_option(), Some(52));
5382 assert_eq!(active.vector_reverse_per_elem_cost_as_option(), Some(8));
5383 assert_eq!(active.vector_keep_range_base_cost_as_option(), Some(52));
5384 assert_eq!(
5385 active.vector_keep_range_per_dropped_elem_cost_as_option(),
5386 Some(1)
5387 );
5388 assert_eq!(
5389 active.vector_keep_range_per_moved_elem_cost_as_option(),
5390 Some(8)
5391 );
5392 assert_eq!(active.vector_copy_range_base_cost_as_option(), Some(52));
5393 assert_eq!(active.vector_replace_range_base_cost_as_option(), Some(52));
5394 assert_eq!(
5395 active.vector_replace_range_per_elem_cost_as_option(),
5396 Some(8)
5397 );
5398 }
5399 }
5400
5401 #[test]
5402 fn test_setters() {
5403 let mut prot: ProtocolConfig =
5404 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5405 prot.set_max_arguments_for_testing(123);
5406 assert_eq!(prot.max_arguments(), 123);
5407
5408 prot.set_max_arguments_from_str_for_testing("321".to_string());
5409 assert_eq!(prot.max_arguments(), 321);
5410
5411 prot.disable_max_arguments_for_testing();
5412 assert_eq!(prot.max_arguments_as_option(), None);
5413
5414 prot.set_attr_for_testing("max_arguments".to_string(), "456".to_string());
5415 assert_eq!(prot.max_arguments(), 456);
5416 }
5417
5418 #[test]
5419 fn test_execution_version_setter_allows_upgrade() {
5420 let mut prot = ProtocolConfig::get_for_max_version_UNSAFE();
5421 let current = prot.execution_version();
5422 prot.set_execution_version_for_testing(current);
5423 prot.set_execution_version_for_testing(current + 1);
5424 assert_eq!(prot.execution_version(), current + 1);
5425 }
5426
5427 #[test]
5428 #[should_panic(expected = "cannot downgrade execution_version")]
5429 fn test_execution_version_setter_panics_on_downgrade() {
5430 let mut prot = ProtocolConfig::get_for_max_version_UNSAFE();
5431 let current = prot.execution_version();
5432 prot.set_execution_version_for_testing(current - 1);
5433 }
5434
5435 #[test]
5436 fn test_feature_flag_setter_by_string() {
5437 let mut prot: ProtocolConfig =
5438 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5439 assert!(!prot.zklogin_auth());
5440 prot.set_feature_flag_for_testing("zklogin_auth".to_string(), true);
5441 assert!(prot.zklogin_auth());
5442 prot.set_feature_flag_for_testing("zklogin_auth".to_string(), false);
5443 assert!(!prot.zklogin_auth());
5444 }
5445
5446 #[test]
5447 #[should_panic(expected = "unknown feature flag")]
5448 fn test_feature_flag_setter_unknown_flag() {
5449 let mut prot: ProtocolConfig =
5450 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5451 prot.set_feature_flag_for_testing("some random string".to_string(), true);
5452 }
5453
5454 #[test]
5455 fn test_get_for_version_if_supported_applies_test_overrides() {
5456 let before =
5457 ProtocolConfig::get_for_version_if_supported(ProtocolVersion::new(1), Chain::Unknown)
5458 .unwrap();
5459
5460 assert!(!before.enable_coin_reservation_obj_refs());
5461
5462 let _guard = ProtocolConfig::apply_overrides_for_testing(|_, mut cfg| {
5463 cfg.enable_coin_reservation_for_testing();
5464 cfg
5465 });
5466
5467 let after =
5468 ProtocolConfig::get_for_version_if_supported(ProtocolVersion::new(1), Chain::Unknown)
5469 .unwrap();
5470
5471 assert!(after.enable_coin_reservation_obj_refs());
5472 }
5473
5474 #[test]
5475 #[should_panic(expected = "unsupported version")]
5476 fn max_version_test() {
5477 let _ = ProtocolConfig::get_for_version_impl(
5480 ProtocolVersion::new(MAX_PROTOCOL_VERSION + 1),
5481 Chain::Unknown,
5482 );
5483 }
5484
5485 #[test]
5486 fn lookup_by_string_test() {
5487 let prot: ProtocolConfig =
5488 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5489 assert!(prot.lookup_attr("some random string".to_string()).is_none());
5491
5492 assert!(
5493 prot.lookup_attr("max_arguments".to_string())
5494 == Some(ProtocolConfigValue::u32(prot.max_arguments())),
5495 );
5496
5497 assert!(
5499 prot.lookup_attr("max_move_identifier_len".to_string())
5500 .is_none()
5501 );
5502
5503 let prot: ProtocolConfig =
5505 ProtocolConfig::get_for_version(ProtocolVersion::new(9), Chain::Unknown);
5506 assert!(
5507 prot.lookup_attr("max_move_identifier_len".to_string())
5508 == Some(ProtocolConfigValue::u64(prot.max_move_identifier_len()))
5509 );
5510
5511 let prot: ProtocolConfig =
5512 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5513 assert!(
5515 prot.attr_map()
5516 .get("max_move_identifier_len")
5517 .unwrap()
5518 .is_none()
5519 );
5520 assert!(
5522 prot.attr_map().get("max_arguments").unwrap()
5523 == &Some(ProtocolConfigValue::u32(prot.max_arguments()))
5524 );
5525
5526 let prot: ProtocolConfig =
5528 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5529 assert!(
5531 prot.feature_flags
5532 .lookup_attr("some random string".to_owned())
5533 .is_none()
5534 );
5535 assert!(
5536 !prot
5537 .feature_flags
5538 .attr_map()
5539 .contains_key("some random string")
5540 );
5541
5542 assert!(
5544 prot.feature_flags
5545 .lookup_attr("package_upgrades".to_owned())
5546 == Some(false)
5547 );
5548 assert!(
5549 prot.feature_flags
5550 .attr_map()
5551 .get("package_upgrades")
5552 .unwrap()
5553 == &false
5554 );
5555 let prot: ProtocolConfig =
5556 ProtocolConfig::get_for_version(ProtocolVersion::new(4), Chain::Unknown);
5557 assert!(
5559 prot.feature_flags
5560 .lookup_attr("package_upgrades".to_owned())
5561 == Some(true)
5562 );
5563 assert!(
5564 prot.feature_flags
5565 .attr_map()
5566 .get("package_upgrades")
5567 .unwrap()
5568 == &true
5569 );
5570 }
5571
5572 #[test]
5573 fn limit_range_fn_test() {
5574 let low = 100u32;
5575 let high = 10000u64;
5576
5577 assert!(check_limit!(1u8, low, high) == LimitThresholdCrossed::None);
5578 assert!(matches!(
5579 check_limit!(255u16, low, high),
5580 LimitThresholdCrossed::Soft(255u128, 100)
5581 ));
5582 assert!(matches!(
5588 check_limit!(2550000u64, low, high),
5589 LimitThresholdCrossed::Hard(2550000, 10000)
5590 ));
5591
5592 assert!(matches!(
5593 check_limit!(2550000u64, high, high),
5594 LimitThresholdCrossed::Hard(2550000, 10000)
5595 ));
5596
5597 assert!(matches!(
5598 check_limit!(1u8, high),
5599 LimitThresholdCrossed::None
5600 ));
5601
5602 assert!(check_limit!(255u16, high) == LimitThresholdCrossed::None);
5603
5604 assert!(matches!(
5605 check_limit!(2550000u64, high),
5606 LimitThresholdCrossed::Hard(2550000, 10000)
5607 ));
5608 }
5609
5610 #[test]
5611 fn linkage_amendments_load() {
5612 let mainnet = LazyLock::force(&MAINNET_LINKAGE_AMENDMENTS);
5613 let testnet = LazyLock::force(&TESTNET_LINKAGE_AMENDMENTS);
5614 assert!(!mainnet.is_empty(), "mainnet amendments must not be empty");
5615 assert!(!testnet.is_empty(), "testnet amendments must not be empty");
5616 }
5617
5618 #[test]
5619 fn render_scalar_fields_use_precision_safe_encoding() {
5620 use mysten_common::rpc_format::Unmetered;
5621
5622 let config = ProtocolConfig::get_for_max_version_UNSAFE();
5623 let rendered = config
5624 .render::<serde_json::Value>(&mut Unmetered)
5625 .expect("render should succeed");
5626
5627 let max_args = rendered
5628 .get("max_arguments")
5629 .expect("max_arguments set at max version");
5630 assert!(
5631 max_args.is_number(),
5632 "u32 should render as number, got {max_args:?}",
5633 );
5634
5635 let max_tx_size = rendered
5636 .get("max_tx_size_bytes")
5637 .expect("max_tx_size_bytes set at max version");
5638 assert!(
5639 max_tx_size.is_string(),
5640 "u64 should render as string, got {max_tx_size:?}",
5641 );
5642 }
5643
5644 #[test]
5645 fn render_includes_non_scalar_gasless_allowlist_as_json() {
5646 use mysten_common::rpc_format::Unmetered;
5647 use serde_json::json;
5648
5649 let mut config = ProtocolConfig::get_for_max_version_UNSAFE();
5650 config.set_gasless_allowed_token_types_for_testing(vec![
5651 ("0xa::usdc::USDC".to_string(), 10_000),
5652 ("0xb::usdt::USDT".to_string(), 0),
5653 ]);
5654
5655 let rendered = config
5656 .render::<serde_json::Value>(&mut Unmetered)
5657 .expect("render should succeed under Unmetered budget");
5658 let allowlist = rendered
5659 .get("gasless_allowed_token_types")
5660 .expect("entry should be present after the testing setter");
5661
5662 assert_eq!(
5665 allowlist,
5666 &json!([["0xa::usdc::USDC", "10000"], ["0xb::usdt::USDT", "0"],]),
5667 );
5668 }
5669
5670 #[test]
5671 fn render_targets_prost_value_for_grpc() {
5672 use mysten_common::rpc_format::Unmetered;
5673 use prost_types::value::Kind;
5674
5675 let mut config = ProtocolConfig::get_for_max_version_UNSAFE();
5676 config.set_gasless_allowed_token_types_for_testing(vec![(
5677 "0xa::usdc::USDC".to_string(),
5678 10_000,
5679 )]);
5680
5681 let rendered = config
5682 .render::<prost_types::Value>(&mut Unmetered)
5683 .expect("render to prost Value should succeed");
5684 let allowlist = rendered
5685 .get("gasless_allowed_token_types")
5686 .expect("entry should be present after the testing setter");
5687
5688 let Some(Kind::ListValue(outer)) = &allowlist.kind else {
5690 panic!(
5691 "expected ListValue at the top level, got {:?}",
5692 allowlist.kind
5693 );
5694 };
5695 assert_eq!(outer.values.len(), 1, "one allowlisted entry");
5696 let Some(Kind::ListValue(entry)) = &outer.values[0].kind else {
5697 panic!("expected each entry to be a ListValue");
5698 };
5699 assert_eq!(entry.values.len(), 2, "entry has (coin_type, amount)");
5700
5701 let Some(Kind::StringValue(coin_type)) = &entry.values[0].kind else {
5702 panic!("expected coin_type as StringValue");
5703 };
5704 assert_eq!(coin_type, "0xa::usdc::USDC");
5705
5706 let Some(Kind::StringValue(amount)) = &entry.values[1].kind else {
5708 panic!(
5709 "expected minimum_transfer_amount as StringValue (precision-safe u64); got {:?}",
5710 entry.values[1].kind,
5711 );
5712 };
5713 assert_eq!(amount, "10000");
5714 }
5715
5716 #[test]
5717 fn render_emits_null_for_unset_protocol_versions() {
5718 use mysten_common::rpc_format::Unmetered;
5719
5720 let config = ProtocolConfig::get_for_version(1.into(), Chain::Unknown);
5721 let rendered = config
5722 .render::<serde_json::Value>(&mut Unmetered)
5723 .expect("render should succeed");
5724 let entry = rendered
5728 .get("gasless_allowed_token_types")
5729 .expect("key should be present for every protocol version");
5730 assert!(
5731 entry.is_null(),
5732 "value should be null for pre-feature protocol version, got {entry:?}",
5733 );
5734 }
5735}