1use std::{
5 collections::{BTreeMap, BTreeSet},
6 sync::{
7 Arc, LazyLock,
8 atomic::{AtomicBool, Ordering},
9 },
10};
11
12use std::sync::Mutex;
13
14use clap::*;
15use fastcrypto::encoding::{Base58, Encoding, Hex};
16use move_binary_format::{
17 binary_config::{BinaryConfig, TableConfig},
18 file_format_common::VERSION_1,
19};
20use move_core_types::account_address::AccountAddress;
21use move_vm_config::verifier::VerifierConfig;
22use mysten_common::in_integration_test;
23use serde::{Deserialize, Serialize};
24use serde_with::skip_serializing_none;
25use sui_protocol_config_macros::{
26 ProtocolConfigAccessors, ProtocolConfigFeatureFlagsGetters, ProtocolConfigOverride,
27};
28use tracing::{info, warn};
29
30pub mod reachability;
31
32#[doc(hidden)]
35pub use antithesis_sdk::linkme;
36#[doc(hidden)]
37pub use mysten_common::assert_reachable_simtest;
38
39const MIN_PROTOCOL_VERSION: u64 = 1;
41const MAX_PROTOCOL_VERSION: u64 = 139;
42
43const TESTNET_USDC: &str =
44 "0xa1ec7fc00a6f40db9693ad1415d0c193ad3906494428cf252621037bd7117e29::usdc::USDC";
45
46const MAINNET_USDC: &str =
47 "0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC";
48const MAINNET_USDSUI: &str =
49 "0x44f838219cf67b058f3b37907b655f226153c18e33dfcd0da559a844fea9b1c1::usdsui::USDSUI";
50const MAINNET_SUI_USDE: &str =
51 "0x41d587e5336f1c86cad50d38a7136db99333bb9bda91cea4ba69115defeb1402::sui_usde::SUI_USDE";
52const MAINNET_USDY: &str =
53 "0x960b531667636f39e85867775f52f6b1f220a058c4de786905bdf761e06a56bb::usdy::USDY";
54const MAINNET_FDUSD: &str =
55 "0xf16e6b723f242ec745dfd7634ad072c42d5c1d9ac9d62a39c381303eaa57693a::fdusd::FDUSD";
56const MAINNET_AUSD: &str =
57 "0x2053d08c1e2bd02791056171aab0fd12bd7cd7efad2ab8f6b9c8902f14df2ff2::ausd::AUSD";
58const MAINNET_USDB: &str =
59 "0xe14726c336e81b32328e92afc37345d159f5b550b09fa92bd43640cfdd0a0cfd::usdb::USDB";
60
61#[derive(Copy, Clone, Debug, Hash, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)]
424pub struct ProtocolVersion(u64);
425
426impl ProtocolVersion {
427 pub const MIN: Self = Self(MIN_PROTOCOL_VERSION);
432
433 pub const MAX: Self = Self(MAX_PROTOCOL_VERSION);
434
435 #[cfg(not(msim))]
436 pub const MAX_ALLOWED: Self = Self::MAX;
437
438 #[cfg(msim)]
440 pub const MAX_ALLOWED: Self = Self(MAX_PROTOCOL_VERSION + 1);
441
442 pub fn new(v: u64) -> Self {
443 Self(v)
444 }
445
446 pub const fn as_u64(&self) -> u64 {
447 self.0
448 }
449
450 pub fn max() -> Self {
453 Self::MAX
454 }
455
456 pub fn prev(self) -> Self {
457 Self(self.0.checked_sub(1).unwrap())
458 }
459}
460
461impl From<u64> for ProtocolVersion {
462 fn from(v: u64) -> Self {
463 Self::new(v)
464 }
465}
466
467impl std::ops::Sub<u64> for ProtocolVersion {
468 type Output = Self;
469 fn sub(self, rhs: u64) -> Self::Output {
470 Self::new(self.0 - rhs)
471 }
472}
473
474impl std::ops::Add<u64> for ProtocolVersion {
475 type Output = Self;
476 fn add(self, rhs: u64) -> Self::Output {
477 Self::new(self.0 + rhs)
478 }
479}
480
481#[derive(
482 Clone, Serialize, Deserialize, Debug, Default, PartialEq, Copy, PartialOrd, Ord, Eq, ValueEnum,
483)]
484pub enum Chain {
485 Mainnet,
486 Testnet,
487 #[default]
488 Unknown,
489}
490
491impl Chain {
492 pub fn as_str(self) -> &'static str {
493 match self {
494 Chain::Mainnet => "mainnet",
495 Chain::Testnet => "testnet",
496 Chain::Unknown => "unknown",
497 }
498 }
499}
500
501pub struct Error(pub String);
502
503#[derive(Default, Clone, Serialize, Deserialize, Debug, ProtocolConfigFeatureFlagsGetters)]
506struct FeatureFlags {
507 #[serde(skip_serializing_if = "is_false")]
510 package_upgrades: bool,
511 #[serde(skip_serializing_if = "is_false")]
514 commit_root_state_digest: bool,
515 #[serde(skip_serializing_if = "is_false")]
517 advance_epoch_start_time_in_safe_mode: bool,
518 #[serde(skip_serializing_if = "is_false")]
521 loaded_child_objects_fixed: bool,
522 #[serde(skip_serializing_if = "is_false")]
525 missing_type_is_compatibility_error: bool,
526 #[serde(skip_serializing_if = "is_false")]
529 scoring_decision_with_validity_cutoff: bool,
530
531 #[serde(skip_serializing_if = "is_false")]
534 consensus_order_end_of_epoch_last: bool,
535
536 #[serde(skip_serializing_if = "is_false")]
540 consensus_slim_block_propagation: bool,
541
542 #[serde(skip_serializing_if = "is_false")]
544 disallow_adding_abilities_on_upgrade: bool,
545 #[serde(skip_serializing_if = "is_false")]
547 disable_invariant_violation_check_in_swap_loc: bool,
548 #[serde(skip_serializing_if = "is_false")]
551 advance_to_highest_supported_protocol_version: bool,
552 #[serde(skip_serializing_if = "is_false")]
554 ban_entry_init: bool,
555 #[serde(skip_serializing_if = "is_false")]
557 package_digest_hash_module: bool,
558 #[serde(skip_serializing_if = "is_false")]
560 disallow_change_struct_type_params_on_upgrade: bool,
561 #[serde(skip_serializing_if = "is_false")]
563 no_extraneous_module_bytes: bool,
564 #[serde(skip_serializing_if = "is_false")]
566 narwhal_versioned_metadata: bool,
567
568 #[serde(skip_serializing_if = "is_false")]
570 zklogin_auth: bool,
571 #[serde(skip_serializing_if = "is_zero")]
574 zklogin_circuit_mode: u64,
575 #[serde(skip_serializing_if = "ConsensusTransactionOrdering::is_none")]
577 consensus_transaction_ordering: ConsensusTransactionOrdering,
578
579 #[serde(skip_serializing_if = "is_false")]
587 simplified_unwrap_then_delete: bool,
588 #[serde(skip_serializing_if = "is_false")]
590 upgraded_multisig_supported: bool,
591 #[serde(skip_serializing_if = "is_false")]
593 txn_base_cost_as_multiplier: bool,
594
595 #[serde(skip_serializing_if = "is_false")]
597 shared_object_deletion: bool,
598
599 #[serde(skip_serializing_if = "is_false")]
601 narwhal_new_leader_election_schedule: bool,
602
603 #[serde(skip_serializing_if = "is_empty")]
605 zklogin_supported_providers: BTreeSet<String>,
606
607 #[serde(skip_serializing_if = "is_false")]
609 loaded_child_object_format: bool,
610
611 #[serde(skip_serializing_if = "is_false")]
612 #[skip_protocol_config_accessor]
613 enable_jwk_consensus_updates: bool,
614
615 #[serde(skip_serializing_if = "is_false")]
616 #[skip_protocol_config_accessor]
617 end_of_epoch_transaction_supported: bool,
618
619 #[serde(skip_serializing_if = "is_false")]
622 simple_conservation_checks: bool,
623
624 #[serde(skip_serializing_if = "is_false")]
626 loaded_child_object_format_type: bool,
627
628 #[serde(skip_serializing_if = "is_false")]
630 receive_objects: bool,
631
632 #[serde(skip_serializing_if = "is_false")]
634 consensus_checkpoint_signature_key_includes_digest: bool,
635
636 #[serde(skip_serializing_if = "is_false")]
638 random_beacon: bool,
639
640 #[serde(skip_serializing_if = "is_false")]
642 #[skip_protocol_config_accessor]
643 bridge: bool,
644
645 #[serde(skip_serializing_if = "is_false")]
646 enable_effects_v2: bool,
647
648 #[serde(skip_serializing_if = "is_false")]
650 narwhal_certificate_v2: bool,
651
652 #[serde(skip_serializing_if = "is_false")]
654 verify_legacy_zklogin_address: bool,
655
656 #[serde(skip_serializing_if = "is_false")]
658 throughput_aware_consensus_submission: bool,
659
660 #[serde(skip_serializing_if = "is_false")]
662 recompute_has_public_transfer_in_execution: bool,
663
664 #[serde(skip_serializing_if = "is_false")]
666 accept_zklogin_in_multisig: bool,
667
668 #[serde(skip_serializing_if = "is_false")]
670 accept_passkey_in_multisig: bool,
671
672 #[serde(skip_serializing_if = "is_false")]
674 validate_zklogin_public_identifier: bool,
675
676 #[serde(skip_serializing_if = "is_false")]
679 include_consensus_digest_in_prologue: bool,
680
681 #[serde(skip_serializing_if = "is_false")]
683 hardened_otw_check: bool,
684
685 #[serde(skip_serializing_if = "is_false")]
687 allow_receiving_object_id: bool,
688
689 #[serde(skip_serializing_if = "is_false")]
691 enable_poseidon: bool,
692
693 #[serde(skip_serializing_if = "is_false")]
695 enable_coin_deny_list: bool,
696
697 #[serde(skip_serializing_if = "is_false")]
699 enable_group_ops_native_functions: bool,
700
701 #[serde(skip_serializing_if = "is_false")]
703 enable_group_ops_native_function_msm: bool,
704
705 #[serde(skip_serializing_if = "is_false")]
707 enable_ristretto255_group_ops: bool,
708
709 #[serde(skip_serializing_if = "is_false")]
711 enable_verify_bulletproofs_ristretto255: bool,
712
713 #[serde(skip_serializing_if = "is_false")]
715 enable_nitro_attestation: bool,
716
717 #[serde(skip_serializing_if = "is_false")]
719 enable_nitro_attestation_upgraded_parsing: bool,
720
721 #[serde(skip_serializing_if = "is_false")]
723 enable_nitro_attestation_all_nonzero_pcrs_parsing: bool,
724
725 #[serde(skip_serializing_if = "is_false")]
727 enable_nitro_attestation_always_include_required_pcrs_parsing: bool,
728
729 #[serde(skip_serializing_if = "is_false")]
731 reject_mutable_random_on_entry_functions: bool,
732
733 #[serde(skip_serializing_if = "PerObjectCongestionControlMode::is_none")]
735 per_object_congestion_control_mode: PerObjectCongestionControlMode,
736
737 #[serde(skip_serializing_if = "ConsensusChoice::is_narwhal")]
739 consensus_choice: ConsensusChoice,
740
741 #[serde(skip_serializing_if = "ConsensusNetwork::is_anemo")]
743 consensus_network: ConsensusNetwork,
744
745 #[serde(skip_serializing_if = "is_false")]
747 correct_gas_payment_limit_check: bool,
748
749 #[serde(skip_serializing_if = "Option::is_none")]
751 zklogin_max_epoch_upper_bound_delta: Option<u64>,
752
753 #[serde(skip_serializing_if = "is_false")]
755 mysticeti_leader_scoring_and_schedule: bool,
756
757 #[serde(skip_serializing_if = "is_false")]
759 reshare_at_same_initial_version: bool,
760
761 #[serde(skip_serializing_if = "is_false")]
763 resolve_abort_locations_to_package_id: bool,
764
765 #[serde(skip_serializing_if = "is_false")]
769 mysticeti_use_committed_subdag_digest: bool,
770
771 #[serde(skip_serializing_if = "is_false")]
773 enable_vdf: bool,
774
775 #[serde(skip_serializing_if = "is_false")]
779 record_consensus_determined_version_assignments_in_prologue: bool,
780 #[serde(skip_serializing_if = "is_false")]
783 record_consensus_determined_version_assignments_in_prologue_v2: bool,
784
785 #[serde(skip_serializing_if = "is_false")]
787 fresh_vm_on_framework_upgrade: bool,
788
789 #[serde(skip_serializing_if = "is_false")]
797 prepend_prologue_tx_in_consensus_commit_in_checkpoints: bool,
798
799 #[serde(skip_serializing_if = "Option::is_none")]
801 mysticeti_num_leaders_per_round: Option<usize>,
802
803 #[serde(skip_serializing_if = "is_false")]
805 soft_bundle: bool,
806
807 #[serde(skip_serializing_if = "is_false")]
809 enable_coin_deny_list_v2: bool,
810
811 #[serde(skip_serializing_if = "is_false")]
813 passkey_auth: bool,
814
815 #[serde(skip_serializing_if = "is_false")]
820 #[skip_accessor]
821 mldsa65_auth: bool,
822
823 #[serde(skip_serializing_if = "is_false")]
825 authority_capabilities_v2: bool,
826
827 #[serde(skip_serializing_if = "is_false")]
829 rethrow_serialization_type_layout_errors: bool,
830
831 #[serde(skip_serializing_if = "is_false")]
833 consensus_distributed_vote_scoring_strategy: bool,
834
835 #[serde(skip_serializing_if = "is_false")]
837 consensus_round_prober: bool,
838
839 #[serde(skip_serializing_if = "is_false")]
841 validate_identifier_inputs: bool,
842
843 #[serde(skip_serializing_if = "is_false")]
845 disallow_self_identifier: bool,
846
847 #[serde(skip_serializing_if = "is_false")]
849 mysticeti_fastpath: bool,
850
851 #[serde(skip_serializing_if = "is_false")]
855 disable_preconsensus_locking: bool,
856
857 #[serde(skip_serializing_if = "is_false")]
859 relocate_event_module: bool,
860
861 #[serde(skip_serializing_if = "is_false")]
863 uncompressed_g1_group_elements: bool,
864
865 #[serde(skip_serializing_if = "is_false")]
866 disallow_new_modules_in_deps_only_packages: bool,
867
868 #[serde(skip_serializing_if = "is_false")]
870 consensus_smart_ancestor_selection: bool,
871
872 #[serde(skip_serializing_if = "is_false")]
874 consensus_round_prober_probe_accepted_rounds: bool,
875
876 #[serde(skip_serializing_if = "is_false")]
878 native_charging_v2: bool,
879
880 #[serde(skip_serializing_if = "is_false")]
883 #[skip_protocol_config_accessor]
884 consensus_linearize_subdag_v2: bool,
885
886 #[serde(skip_serializing_if = "is_false")]
888 convert_type_argument_error: bool,
889
890 #[serde(skip_serializing_if = "is_false")]
892 variant_nodes: bool,
893
894 #[serde(skip_serializing_if = "is_false")]
896 consensus_zstd_compression: bool,
897
898 #[serde(skip_serializing_if = "is_false")]
900 minimize_child_object_mutations: bool,
901
902 #[serde(skip_serializing_if = "is_false")]
905 record_additional_state_digest_in_prologue: bool,
906
907 #[serde(skip_serializing_if = "is_false")]
909 move_native_context: bool,
910
911 #[serde(skip_serializing_if = "is_false")]
914 #[skip_protocol_config_accessor]
915 consensus_median_based_commit_timestamp: bool,
916
917 #[serde(skip_serializing_if = "is_false")]
920 normalize_ptb_arguments: bool,
921
922 #[serde(skip_serializing_if = "is_false")]
924 consensus_batched_block_sync: bool,
925
926 #[serde(skip_serializing_if = "is_false")]
928 enforce_checkpoint_timestamp_monotonicity: bool,
929
930 #[serde(skip_serializing_if = "is_false")]
932 max_ptb_value_size_v2: bool,
933
934 #[serde(skip_serializing_if = "is_false")]
936 resolve_type_input_ids_to_defining_id: bool,
937
938 #[serde(skip_serializing_if = "is_false")]
940 enable_party_transfer: bool,
941
942 #[serde(skip_serializing_if = "is_false")]
944 allow_unbounded_system_objects: bool,
945
946 #[serde(skip_serializing_if = "is_false")]
948 type_tags_in_object_runtime: bool,
949
950 #[serde(skip_serializing_if = "is_false")]
952 enable_accumulators: bool,
953
954 #[serde(skip_serializing_if = "is_false")]
956 #[skip_protocol_config_accessor]
957 enable_coin_reservation_obj_refs: bool,
958
959 #[serde(skip_serializing_if = "is_false")]
962 create_root_accumulator_object: bool,
963
964 #[serde(skip_serializing_if = "is_false")]
966 #[skip_protocol_config_accessor]
967 enable_authenticated_event_streams: bool,
968
969 #[serde(skip_serializing_if = "is_false")]
971 enable_address_balance_gas_payments: bool,
972
973 #[serde(skip_serializing_if = "is_false")]
975 address_balance_gas_check_rgp_at_signing: bool,
976
977 #[serde(skip_serializing_if = "is_false")]
978 address_balance_gas_reject_gas_coin_arg: bool,
979
980 #[serde(skip_serializing_if = "is_false")]
982 enable_multi_epoch_transaction_expiration: bool,
983
984 #[serde(skip_serializing_if = "is_false")]
986 relax_valid_during_for_owned_inputs: bool,
987
988 #[serde(skip_serializing_if = "is_false")]
990 enable_ptb_execution_v2: bool,
991
992 #[serde(skip_serializing_if = "is_false")]
994 better_adapter_type_resolution_errors: bool,
995
996 #[serde(skip_serializing_if = "is_false")]
998 record_time_estimate_processed: bool,
999
1000 #[serde(skip_serializing_if = "is_false")]
1002 dependency_linkage_error: bool,
1003
1004 #[serde(skip_serializing_if = "is_false")]
1006 additional_multisig_checks: bool,
1007
1008 #[serde(skip_serializing_if = "is_false")]
1010 ignore_execution_time_observations_after_certs_closed: bool,
1011
1012 #[serde(skip_serializing_if = "is_false")]
1016 debug_fatal_on_move_invariant_violation: bool,
1017
1018 #[serde(skip_serializing_if = "is_false")]
1021 allow_private_accumulator_entrypoints: bool,
1022
1023 #[serde(skip_serializing_if = "is_false")]
1026 additional_consensus_digest_indirect_state: bool,
1027
1028 #[serde(skip_serializing_if = "is_false")]
1030 check_for_init_during_upgrade: bool,
1031
1032 #[serde(skip_serializing_if = "is_false")]
1034 enable_init_on_upgrade: bool,
1035
1036 #[serde(skip_serializing_if = "is_false")]
1038 enable_order_independent_upgrade_init_linkage: bool,
1039
1040 #[serde(skip_serializing_if = "is_false")]
1043 harden_linkage_consistency: bool,
1044
1045 #[serde(skip_serializing_if = "is_false")]
1047 per_command_shared_object_transfer_rules: bool,
1048
1049 #[serde(skip_serializing_if = "is_false")]
1051 validate_ptb_argument_indices: bool,
1052
1053 #[serde(skip_serializing_if = "is_false")]
1055 include_checkpoint_artifacts_digest_in_summary: bool,
1056
1057 #[serde(skip_serializing_if = "is_false")]
1059 use_mfp_txns_in_load_initial_object_debts: bool,
1060
1061 #[serde(skip_serializing_if = "is_false")]
1063 cancel_for_failed_dkg_early: bool,
1064
1065 #[serde(skip_serializing_if = "is_false")]
1067 always_advance_dkg_to_resolution: bool,
1068
1069 #[serde(skip_serializing_if = "is_false")]
1071 allow_dkg_completion_after_timeout: bool,
1072
1073 #[serde(skip_serializing_if = "is_false")]
1075 enable_coin_registry: bool,
1076
1077 #[serde(skip_serializing_if = "is_false")]
1079 abstract_size_in_object_runtime: bool,
1080
1081 #[serde(skip_serializing_if = "is_false")]
1083 object_runtime_charge_cache_load_gas: bool,
1084
1085 #[serde(skip_serializing_if = "is_false")]
1087 additional_borrow_checks: bool,
1088
1089 #[serde(skip_serializing_if = "is_false")]
1091 use_new_commit_handler: bool,
1092
1093 #[serde(skip_serializing_if = "is_false")]
1095 better_loader_errors: bool,
1096
1097 #[serde(skip_serializing_if = "is_false")]
1099 generate_df_type_layouts: bool,
1100
1101 #[serde(skip_serializing_if = "is_false")]
1103 allow_references_in_ptbs: bool,
1104
1105 #[serde(skip_serializing_if = "is_false")]
1112 framework_tx_context_mut_restrictions: bool,
1113
1114 #[serde(skip_serializing_if = "is_false")]
1116 include_function_signatures_in_instantiation_limits: bool,
1117
1118 #[serde(skip_serializing_if = "is_false")]
1123 ptb_tx_context_restrictions: bool,
1124
1125 #[serde(skip_serializing_if = "is_false")]
1127 enable_display_registry: bool,
1128
1129 #[serde(skip_serializing_if = "is_false")]
1131 private_generics_verifier_v2: bool,
1132
1133 #[serde(skip_serializing_if = "is_false")]
1135 deprecate_global_storage_ops_during_deserialization: bool,
1136
1137 #[serde(skip_serializing_if = "is_false")]
1140 enable_non_exclusive_writes: bool,
1141
1142 #[serde(skip_serializing_if = "is_false")]
1144 deprecate_global_storage_ops: bool,
1145
1146 #[serde(skip_serializing_if = "is_false")]
1148 normalize_depth_formula: bool,
1149
1150 #[serde(skip_serializing_if = "is_false")]
1153 charge_ld_const_abstract_size: bool,
1154
1155 #[serde(skip_serializing_if = "is_false")]
1157 consensus_skip_gced_accept_votes: bool,
1158
1159 #[serde(skip_serializing_if = "is_false")]
1162 include_cancelled_randomness_txns_in_prologue: bool,
1163
1164 #[serde(skip_serializing_if = "is_false")]
1166 #[skip_protocol_config_accessor]
1167 address_aliases: bool,
1168
1169 #[serde(skip_serializing_if = "is_false")]
1171 create_forwarding_address_registry: bool,
1172
1173 #[serde(skip_serializing_if = "is_false")]
1175 enable_forwarding_addresses: bool,
1176
1177 #[serde(skip_serializing_if = "is_false")]
1180 fix_checkpoint_signature_mapping: bool,
1181
1182 #[serde(skip_serializing_if = "is_false")]
1184 enable_object_funds_withdraw: bool,
1185
1186 #[serde(skip_serializing_if = "is_false")]
1189 record_net_unsettled_object_withdraws: bool,
1190
1191 #[serde(skip_serializing_if = "is_false")]
1193 consensus_skip_gced_blocks_in_direct_finalization: bool,
1194
1195 #[serde(skip_serializing_if = "is_false")]
1197 gas_rounding_halve_digits: bool,
1198
1199 #[serde(skip_serializing_if = "is_false")]
1201 flexible_tx_context_positions: bool,
1202
1203 #[serde(skip_serializing_if = "is_false")]
1205 disable_entry_point_signature_check: bool,
1206
1207 #[serde(skip_serializing_if = "is_false")]
1209 convert_withdrawal_compatibility_ptb_arguments: bool,
1210
1211 #[serde(skip_serializing_if = "is_false")]
1213 restrict_hot_or_not_entry_functions: bool,
1214
1215 #[serde(skip_serializing_if = "is_false")]
1217 split_checkpoints_in_consensus_handler: bool,
1218
1219 #[serde(skip_serializing_if = "is_false")]
1221 consensus_always_accept_system_transactions: bool,
1222
1223 #[serde(skip_serializing_if = "is_false")]
1225 validator_metadata_verify_v2: bool,
1226
1227 #[serde(skip_serializing_if = "is_false")]
1230 defer_unpaid_amplification: bool,
1231
1232 #[serde(skip_serializing_if = "is_false")]
1235 defer_owned_object_double_spend: bool,
1236
1237 #[serde(skip_serializing_if = "is_false")]
1240 allowed_proposers: bool,
1241
1242 #[serde(skip_serializing_if = "is_false")]
1243 randomize_checkpoint_tx_limit_in_tests: bool,
1244
1245 #[serde(skip_serializing_if = "is_false")]
1247 gasless_transaction_drop_safety: bool,
1248
1249 #[serde(skip_serializing_if = "is_false")]
1252 merge_randomness_into_checkpoint: bool,
1253
1254 #[serde(skip_serializing_if = "is_false")]
1256 use_coin_party_owner: bool,
1257
1258 #[serde(skip_serializing_if = "is_false")]
1259 enable_gasless: bool,
1260
1261 #[serde(skip_serializing_if = "is_false")]
1262 gasless_verify_remaining_balance: bool,
1263
1264 #[serde(skip_serializing_if = "is_false")]
1265 disallow_jump_orphans: bool,
1266
1267 #[serde(skip_serializing_if = "is_false")]
1269 early_return_receive_object_mismatched_type: bool,
1270
1271 #[serde(skip_serializing_if = "is_false")]
1276 timestamp_based_epoch_close: bool,
1277
1278 #[serde(skip_serializing_if = "is_false")]
1281 limit_groth16_pvk_inputs: bool,
1282
1283 #[serde(skip_serializing_if = "is_false")]
1288 enforce_address_balance_change_invariant: bool,
1289
1290 #[serde(skip_serializing_if = "is_false")]
1292 share_transaction_deny_config_in_consensus: bool,
1293
1294 #[serde(skip_serializing_if = "is_false")]
1296 granular_post_execution_checks: bool,
1297
1298 #[serde(skip_serializing_if = "is_false")]
1300 early_exit_on_iffw: bool,
1301
1302 #[serde(skip_serializing_if = "is_false")]
1304 enable_unified_linkage: bool,
1305
1306 #[serde(skip_serializing_if = "is_false")]
1309 #[skip_protocol_config_accessor]
1310 enable_allowances: bool,
1311
1312 #[serde(skip_serializing_if = "is_false")]
1314 fix_ptb_generated_reads: bool,
1315
1316 #[serde(skip_serializing_if = "is_false")]
1317 check_object_funds_withdraw_in_execution: bool,
1318 #[serde(skip_serializing_if = "is_false")]
1320 memory_safety_invariant_check_v2: bool,
1321
1322 #[serde(skip_serializing_if = "is_false")]
1324 disable_effects_tx_dependencies: bool,
1325
1326 #[serde(skip_serializing_if = "is_false")]
1330 merge_colliding_deferrals: bool,
1331}
1332
1333fn is_false(b: &bool) -> bool {
1334 !b
1335}
1336
1337fn is_empty(b: &BTreeSet<String>) -> bool {
1338 b.is_empty()
1339}
1340
1341fn is_zero(val: &u64) -> bool {
1342 *val == 0
1343}
1344
1345#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1347pub enum ConsensusTransactionOrdering {
1348 #[default]
1350 None,
1351 ByGasPrice,
1353}
1354
1355impl ConsensusTransactionOrdering {
1356 pub fn is_none(&self) -> bool {
1357 matches!(self, ConsensusTransactionOrdering::None)
1358 }
1359}
1360
1361#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1362pub struct ExecutionTimeEstimateParams {
1363 pub target_utilization: u64,
1365 pub allowed_txn_cost_overage_burst_limit_us: u64,
1369
1370 pub randomness_scalar: u64,
1373
1374 pub max_estimate_us: u64,
1376
1377 pub stored_observations_num_included_checkpoints: u64,
1380
1381 pub stored_observations_limit: u64,
1383
1384 #[serde(skip_serializing_if = "is_zero")]
1387 pub stake_weighted_median_threshold: u64,
1388
1389 #[serde(skip_serializing_if = "is_false")]
1393 pub default_none_duration_for_new_keys: bool,
1394
1395 #[serde(skip_serializing_if = "Option::is_none")]
1397 pub observations_chunk_size: Option<u64>,
1398}
1399
1400#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1402pub enum PerObjectCongestionControlMode {
1403 #[default]
1404 None, TotalGasBudget, TotalTxCount, TotalGasBudgetWithCap, ExecutionTimeEstimate(ExecutionTimeEstimateParams), }
1410
1411impl PerObjectCongestionControlMode {
1412 pub fn is_none(&self) -> bool {
1413 matches!(self, PerObjectCongestionControlMode::None)
1414 }
1415}
1416
1417#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1419pub enum ConsensusChoice {
1420 #[default]
1421 Narwhal,
1422 SwapEachEpoch,
1423 Mysticeti,
1424}
1425
1426impl ConsensusChoice {
1427 pub fn is_narwhal(&self) -> bool {
1428 matches!(self, ConsensusChoice::Narwhal)
1429 }
1430}
1431
1432#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1434pub enum ConsensusNetwork {
1435 #[default]
1436 Anemo,
1437 Tonic,
1438}
1439
1440impl ConsensusNetwork {
1441 pub fn is_anemo(&self) -> bool {
1442 matches!(self, ConsensusNetwork::Anemo)
1443 }
1444}
1445
1446#[skip_serializing_none]
1478#[derive(Clone, Serialize, Debug, ProtocolConfigAccessors, ProtocolConfigOverride)]
1479pub struct ProtocolConfig {
1480 pub version: ProtocolVersion,
1481
1482 #[serde(skip)]
1487 chain: Chain,
1488
1489 feature_flags: FeatureFlags,
1490
1491 max_tx_size_bytes: Option<u64>,
1494
1495 max_input_objects: Option<u64>,
1497
1498 max_size_written_objects: Option<u64>,
1502 max_size_written_objects_system_tx: Option<u64>,
1505
1506 max_serialized_tx_effects_size_bytes: Option<u64>,
1508
1509 max_serialized_tx_effects_size_bytes_system_tx: Option<u64>,
1511
1512 max_gas_payment_objects: Option<u32>,
1514
1515 max_modules_in_publish: Option<u32>,
1517
1518 max_package_dependencies: Option<u32>,
1520
1521 max_arguments: Option<u32>,
1524
1525 max_type_arguments: Option<u32>,
1527
1528 max_type_argument_depth: Option<u32>,
1530
1531 max_pure_argument_size: Option<u32>,
1533
1534 max_programmable_tx_commands: Option<u32>,
1536
1537 move_binary_format_version: Option<u32>,
1540 min_move_binary_format_version: Option<u32>,
1541
1542 binary_module_handles: Option<u16>,
1544 binary_struct_handles: Option<u16>,
1545 binary_function_handles: Option<u16>,
1546 binary_function_instantiations: Option<u16>,
1547 binary_signatures: Option<u16>,
1548 binary_constant_pool: Option<u16>,
1549 binary_identifiers: Option<u16>,
1550 binary_address_identifiers: Option<u16>,
1551 binary_struct_defs: Option<u16>,
1552 binary_struct_def_instantiations: Option<u16>,
1553 binary_function_defs: Option<u16>,
1554 binary_field_handles: Option<u16>,
1555 binary_field_instantiations: Option<u16>,
1556 binary_friend_decls: Option<u16>,
1557 binary_enum_defs: Option<u16>,
1558 binary_enum_def_instantiations: Option<u16>,
1559 binary_variant_handles: Option<u16>,
1560 binary_variant_instantiation_handles: Option<u16>,
1561
1562 max_move_object_size: Option<u64>,
1564
1565 max_move_package_size: Option<u64>,
1568
1569 max_publish_or_upgrade_per_ptb: Option<u64>,
1571
1572 max_tx_gas: Option<u64>,
1574
1575 max_gas_price: Option<u64>,
1577
1578 max_gas_price_rgp_factor_for_aborted_transactions: Option<u64>,
1581
1582 max_gas_computation_bucket: Option<u64>,
1584
1585 gas_rounding_step: Option<u64>,
1587
1588 max_loop_depth: Option<u64>,
1590
1591 max_generic_instantiation_length: Option<u64>,
1593
1594 max_function_parameters: Option<u64>,
1596
1597 max_basic_blocks: Option<u64>,
1599
1600 max_value_stack_size: Option<u64>,
1602
1603 max_type_nodes: Option<u64>,
1605
1606 max_generic_instantiation_type_nodes_per_function: Option<u64>,
1608
1609 max_generic_instantiation_type_nodes_per_module: Option<u64>,
1611
1612 max_accumulator_type_nodes: Option<u64>,
1614
1615 max_push_size: Option<u64>,
1617
1618 max_struct_definitions: Option<u64>,
1620
1621 max_function_definitions: Option<u64>,
1623
1624 max_fields_in_struct: Option<u64>,
1626
1627 max_dependency_depth: Option<u64>,
1629
1630 max_num_event_emit: Option<u64>,
1632
1633 max_num_new_move_object_ids: Option<u64>,
1635
1636 max_num_new_move_object_ids_system_tx: Option<u64>,
1638
1639 max_num_deleted_move_object_ids: Option<u64>,
1641
1642 max_num_deleted_move_object_ids_system_tx: Option<u64>,
1644
1645 max_num_transferred_move_object_ids: Option<u64>,
1647
1648 max_num_transferred_move_object_ids_system_tx: Option<u64>,
1650
1651 max_event_emit_size: Option<u64>,
1653
1654 max_event_emit_size_total: Option<u64>,
1656
1657 max_move_vector_len: Option<u64>,
1659
1660 max_move_identifier_len: Option<u64>,
1662
1663 max_move_value_depth: Option<u64>,
1665
1666 package_arena_size_in_bytes: Option<u64>,
1669
1670 max_move_enum_variants: Option<u64>,
1672
1673 max_back_edges_per_function: Option<u64>,
1675
1676 max_back_edges_per_module: Option<u64>,
1678
1679 max_verifier_meter_ticks_per_function: Option<u64>,
1681
1682 max_meter_ticks_per_module: Option<u64>,
1684
1685 max_meter_ticks_per_package: Option<u64>,
1687
1688 object_runtime_max_num_cached_objects: Option<u64>,
1692
1693 object_runtime_max_num_cached_objects_system_tx: Option<u64>,
1695
1696 object_runtime_max_num_store_entries: Option<u64>,
1698
1699 object_runtime_max_num_store_entries_system_tx: Option<u64>,
1701
1702 base_tx_cost_fixed: Option<u64>,
1705
1706 package_publish_cost_fixed: Option<u64>,
1709
1710 base_tx_cost_per_byte: Option<u64>,
1713
1714 package_publish_cost_per_byte: Option<u64>,
1716
1717 obj_access_cost_read_per_byte: Option<u64>,
1719
1720 obj_access_cost_read_per_package_kb: Option<u64>,
1723
1724 obj_access_cost_mutate_per_byte: Option<u64>,
1726
1727 obj_access_cost_delete_per_byte: Option<u64>,
1729
1730 obj_access_cost_verify_per_byte: Option<u64>,
1740
1741 max_type_to_layout_nodes: Option<u64>,
1743
1744 max_ptb_value_size: Option<u64>,
1746
1747 gas_model_version: Option<u64>,
1750
1751 obj_data_cost_refundable: Option<u64>,
1754
1755 obj_metadata_cost_non_refundable: Option<u64>,
1759
1760 storage_rebate_rate: Option<u64>,
1766
1767 storage_fund_reinvest_rate: Option<u64>,
1770
1771 reward_slashing_rate: Option<u64>,
1774
1775 storage_gas_price: Option<u64>,
1777
1778 accumulator_object_storage_cost: Option<u64>,
1780
1781 max_transactions_per_checkpoint: Option<u64>,
1786
1787 max_checkpoint_size_bytes: Option<u64>,
1791
1792 buffer_stake_for_protocol_upgrade_bps: Option<u64>,
1797
1798 address_from_bytes_cost_base: Option<u64>,
1803 address_to_u256_cost_base: Option<u64>,
1805 address_from_u256_cost_base: Option<u64>,
1807
1808 config_read_setting_impl_cost_base: Option<u64>,
1813 config_read_setting_impl_cost_per_byte: Option<u64>,
1814
1815 package_original_package_id_impl_cost_base: Option<u64>,
1816 package_original_package_id_impl_cost_per_byte: Option<u64>,
1817
1818 dynamic_field_hash_type_and_key_cost_base: Option<u64>,
1821 dynamic_field_hash_type_and_key_type_cost_per_byte: Option<u64>,
1822 dynamic_field_hash_type_and_key_value_cost_per_byte: Option<u64>,
1823 dynamic_field_hash_type_and_key_type_tag_cost_per_byte: Option<u64>,
1824 dynamic_field_add_child_object_cost_base: Option<u64>,
1826 dynamic_field_add_child_object_type_cost_per_byte: Option<u64>,
1827 dynamic_field_add_child_object_value_cost_per_byte: Option<u64>,
1828 dynamic_field_add_child_object_struct_tag_cost_per_byte: Option<u64>,
1829 dynamic_field_borrow_child_object_cost_base: Option<u64>,
1831 dynamic_field_borrow_child_object_child_ref_cost_per_byte: Option<u64>,
1832 dynamic_field_borrow_child_object_type_cost_per_byte: Option<u64>,
1833 dynamic_field_remove_child_object_cost_base: Option<u64>,
1835 dynamic_field_remove_child_object_child_cost_per_byte: Option<u64>,
1836 dynamic_field_remove_child_object_type_cost_per_byte: Option<u64>,
1837 dynamic_field_has_child_object_cost_base: Option<u64>,
1839 dynamic_field_has_child_object_with_ty_cost_base: Option<u64>,
1841 dynamic_field_has_child_object_with_ty_type_cost_per_byte: Option<u64>,
1842 dynamic_field_has_child_object_with_ty_type_tag_cost_per_byte: Option<u64>,
1843
1844 scratch_add_cost_base: Option<u64>,
1847 scratch_read_cost_base: Option<u64>,
1849 scratch_read_value_cost: Option<u64>,
1850 scratch_remove_cost_base: Option<u64>,
1852 scratch_exists_cost_base: Option<u64>,
1854 scratch_exists_with_type_cost_base: Option<u64>,
1856 scratch_exists_with_type_type_cost: Option<u64>,
1857 max_scratch_pad_size: Option<u64>,
1859
1860 event_emit_cost_base: Option<u64>,
1863 event_emit_value_size_derivation_cost_per_byte: Option<u64>,
1864 event_emit_tag_size_derivation_cost_per_byte: Option<u64>,
1865 event_emit_output_cost_per_byte: Option<u64>,
1866 event_emit_auth_stream_cost: Option<u64>,
1867
1868 reserve_object_funds_for_withdrawal_cost_base: Option<u64>,
1871 reserve_object_funds_for_withdrawal_cold_read_cost: Option<u64>,
1873
1874 object_borrow_uid_cost_base: Option<u64>,
1877 object_delete_impl_cost_base: Option<u64>,
1879 object_record_new_uid_cost_base: Option<u64>,
1881 object_record_new_uid_from_hash_cost_base: Option<u64>,
1884
1885 transfer_transfer_internal_cost_base: Option<u64>,
1888 transfer_party_transfer_internal_cost_base: Option<u64>,
1890 transfer_freeze_object_cost_base: Option<u64>,
1892 transfer_share_object_cost_base: Option<u64>,
1894 transfer_receive_object_cost_base: Option<u64>,
1897 transfer_receive_object_cost_per_byte: Option<u64>,
1898 transfer_receive_object_type_cost_per_byte: Option<u64>,
1899
1900 tx_context_derive_id_cost_base: Option<u64>,
1903 tx_context_fresh_id_cost_base: Option<u64>,
1904 tx_context_sender_cost_base: Option<u64>,
1905 tx_context_epoch_cost_base: Option<u64>,
1906 tx_context_epoch_timestamp_ms_cost_base: Option<u64>,
1907 tx_context_sponsor_cost_base: Option<u64>,
1908 tx_context_rgp_cost_base: Option<u64>,
1909 tx_context_gas_price_cost_base: Option<u64>,
1910 tx_context_gas_budget_cost_base: Option<u64>,
1911 tx_context_ids_created_cost_base: Option<u64>,
1912 tx_context_replace_cost_base: Option<u64>,
1913
1914 types_is_one_time_witness_cost_base: Option<u64>,
1917 types_is_one_time_witness_type_tag_cost_per_byte: Option<u64>,
1918 types_is_one_time_witness_type_cost_per_byte: Option<u64>,
1919
1920 validator_validate_metadata_cost_base: Option<u64>,
1923 validator_validate_metadata_data_cost_per_byte: Option<u64>,
1924
1925 crypto_invalid_arguments_cost: Option<u64>,
1927 bls12381_bls12381_min_sig_verify_cost_base: Option<u64>,
1929 bls12381_bls12381_min_sig_verify_msg_cost_per_byte: Option<u64>,
1930 bls12381_bls12381_min_sig_verify_msg_cost_per_block: Option<u64>,
1931
1932 bls12381_bls12381_min_pk_verify_cost_base: Option<u64>,
1934 bls12381_bls12381_min_pk_verify_msg_cost_per_byte: Option<u64>,
1935 bls12381_bls12381_min_pk_verify_msg_cost_per_block: Option<u64>,
1936
1937 ecdsa_k1_ecrecover_keccak256_cost_base: Option<u64>,
1939 ecdsa_k1_ecrecover_keccak256_msg_cost_per_byte: Option<u64>,
1940 ecdsa_k1_ecrecover_keccak256_msg_cost_per_block: Option<u64>,
1941 ecdsa_k1_ecrecover_sha256_cost_base: Option<u64>,
1942 ecdsa_k1_ecrecover_sha256_msg_cost_per_byte: Option<u64>,
1943 ecdsa_k1_ecrecover_sha256_msg_cost_per_block: Option<u64>,
1944
1945 ecdsa_k1_decompress_pubkey_cost_base: Option<u64>,
1947
1948 ecdsa_k1_secp256k1_verify_keccak256_cost_base: Option<u64>,
1950 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_byte: Option<u64>,
1951 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_block: Option<u64>,
1952 ecdsa_k1_secp256k1_verify_sha256_cost_base: Option<u64>,
1953 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_byte: Option<u64>,
1954 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_block: Option<u64>,
1955
1956 ecdsa_r1_ecrecover_keccak256_cost_base: Option<u64>,
1958 ecdsa_r1_ecrecover_keccak256_msg_cost_per_byte: Option<u64>,
1959 ecdsa_r1_ecrecover_keccak256_msg_cost_per_block: Option<u64>,
1960 ecdsa_r1_ecrecover_sha256_cost_base: Option<u64>,
1961 ecdsa_r1_ecrecover_sha256_msg_cost_per_byte: Option<u64>,
1962 ecdsa_r1_ecrecover_sha256_msg_cost_per_block: Option<u64>,
1963
1964 ecdsa_r1_secp256r1_verify_keccak256_cost_base: Option<u64>,
1966 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_byte: Option<u64>,
1967 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_block: Option<u64>,
1968 ecdsa_r1_secp256r1_verify_sha256_cost_base: Option<u64>,
1969 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_byte: Option<u64>,
1970 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_block: Option<u64>,
1971
1972 ecvrf_ecvrf_verify_cost_base: Option<u64>,
1974 ecvrf_ecvrf_verify_alpha_string_cost_per_byte: Option<u64>,
1975 ecvrf_ecvrf_verify_alpha_string_cost_per_block: Option<u64>,
1976
1977 ed25519_ed25519_verify_cost_base: Option<u64>,
1979 ed25519_ed25519_verify_msg_cost_per_byte: Option<u64>,
1980 ed25519_ed25519_verify_msg_cost_per_block: Option<u64>,
1981
1982 groth16_prepare_verifying_key_bls12381_cost_base: Option<u64>,
1984 groth16_prepare_verifying_key_bn254_cost_base: Option<u64>,
1985
1986 groth16_verify_groth16_proof_internal_bls12381_cost_base: Option<u64>,
1988 groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input: Option<u64>,
1989 groth16_verify_groth16_proof_internal_bn254_cost_base: Option<u64>,
1990 groth16_verify_groth16_proof_internal_bn254_cost_per_public_input: Option<u64>,
1991 groth16_verify_groth16_proof_internal_public_input_cost_per_byte: Option<u64>,
1992
1993 hash_blake2b256_cost_base: Option<u64>,
1995 hash_blake2b256_data_cost_per_byte: Option<u64>,
1996 hash_blake2b256_data_cost_per_block: Option<u64>,
1997
1998 hash_keccak256_cost_base: Option<u64>,
2000 hash_keccak256_data_cost_per_byte: Option<u64>,
2001 hash_keccak256_data_cost_per_block: Option<u64>,
2002
2003 poseidon_bn254_cost_base: Option<u64>,
2005 poseidon_bn254_cost_per_block: Option<u64>,
2006
2007 group_ops_bls12381_decode_scalar_cost: Option<u64>,
2009 group_ops_bls12381_decode_g1_cost: Option<u64>,
2010 group_ops_bls12381_decode_g2_cost: Option<u64>,
2011 group_ops_bls12381_decode_gt_cost: Option<u64>,
2012 group_ops_bls12381_scalar_add_cost: Option<u64>,
2013 group_ops_bls12381_g1_add_cost: Option<u64>,
2014 group_ops_bls12381_g2_add_cost: Option<u64>,
2015 group_ops_bls12381_gt_add_cost: Option<u64>,
2016 group_ops_bls12381_scalar_sub_cost: Option<u64>,
2017 group_ops_bls12381_g1_sub_cost: Option<u64>,
2018 group_ops_bls12381_g2_sub_cost: Option<u64>,
2019 group_ops_bls12381_gt_sub_cost: Option<u64>,
2020 group_ops_bls12381_scalar_mul_cost: Option<u64>,
2021 group_ops_bls12381_g1_mul_cost: Option<u64>,
2022 group_ops_bls12381_g2_mul_cost: Option<u64>,
2023 group_ops_bls12381_gt_mul_cost: Option<u64>,
2024 group_ops_bls12381_scalar_div_cost: Option<u64>,
2025 group_ops_bls12381_g1_div_cost: Option<u64>,
2026 group_ops_bls12381_g2_div_cost: Option<u64>,
2027 group_ops_bls12381_gt_div_cost: Option<u64>,
2028 group_ops_bls12381_g1_hash_to_base_cost: Option<u64>,
2029 group_ops_bls12381_g2_hash_to_base_cost: Option<u64>,
2030 group_ops_bls12381_g1_hash_to_cost_per_byte: Option<u64>,
2031 group_ops_bls12381_g2_hash_to_cost_per_byte: Option<u64>,
2032 group_ops_bls12381_g1_msm_base_cost: Option<u64>,
2033 group_ops_bls12381_g2_msm_base_cost: Option<u64>,
2034 group_ops_bls12381_g1_msm_base_cost_per_input: Option<u64>,
2035 group_ops_bls12381_g2_msm_base_cost_per_input: Option<u64>,
2036 group_ops_bls12381_msm_max_len: Option<u32>,
2037 group_ops_bls12381_pairing_cost: Option<u64>,
2038 group_ops_bls12381_g1_to_uncompressed_g1_cost: Option<u64>,
2039 group_ops_bls12381_uncompressed_g1_to_g1_cost: Option<u64>,
2040 group_ops_bls12381_uncompressed_g1_sum_base_cost: Option<u64>,
2041 group_ops_bls12381_uncompressed_g1_sum_cost_per_term: Option<u64>,
2042 group_ops_bls12381_uncompressed_g1_sum_max_terms: Option<u64>,
2043
2044 group_ops_ristretto_decode_scalar_cost: Option<u64>,
2045 group_ops_ristretto_decode_point_cost: Option<u64>,
2046 group_ops_ristretto_scalar_add_cost: Option<u64>,
2047 group_ops_ristretto_point_add_cost: Option<u64>,
2048 group_ops_ristretto_scalar_sub_cost: Option<u64>,
2049 group_ops_ristretto_point_sub_cost: Option<u64>,
2050 group_ops_ristretto_scalar_mul_cost: Option<u64>,
2051 group_ops_ristretto_point_mul_cost: Option<u64>,
2052 group_ops_ristretto_scalar_div_cost: Option<u64>,
2053 group_ops_ristretto_point_div_cost: Option<u64>,
2054
2055 verify_bulletproofs_ristretto255_base_cost: Option<u64>,
2056 verify_bulletproofs_ristretto255_cost_per_bit_and_commitment: Option<u64>,
2057 max_bulletproofs_total_bits: Option<u64>,
2060
2061 hmac_hmac_sha3_256_cost_base: Option<u64>,
2063 hmac_hmac_sha3_256_input_cost_per_byte: Option<u64>,
2064 hmac_hmac_sha3_256_input_cost_per_block: Option<u64>,
2065
2066 check_zklogin_id_cost_base: Option<u64>,
2068 check_zklogin_issuer_cost_base: Option<u64>,
2070
2071 vdf_verify_vdf_cost: Option<u64>,
2072 vdf_hash_to_input_cost: Option<u64>,
2073
2074 nitro_attestation_parse_base_cost: Option<u64>,
2076 nitro_attestation_parse_cost_per_byte: Option<u64>,
2077 nitro_attestation_verify_base_cost: Option<u64>,
2078 nitro_attestation_verify_cost_per_cert: Option<u64>,
2079
2080 bcs_per_byte_serialized_cost: Option<u64>,
2082 bcs_legacy_min_output_size_cost: Option<u64>,
2083 bcs_failure_cost: Option<u64>,
2084
2085 hash_sha2_256_base_cost: Option<u64>,
2086 hash_sha2_256_per_byte_cost: Option<u64>,
2087 hash_sha2_256_legacy_min_input_len_cost: Option<u64>,
2088 hash_sha3_256_base_cost: Option<u64>,
2089 hash_sha3_256_per_byte_cost: Option<u64>,
2090 hash_sha3_256_legacy_min_input_len_cost: Option<u64>,
2091 type_name_get_base_cost: Option<u64>,
2092 type_name_get_per_byte_cost: Option<u64>,
2093 type_name_id_base_cost: Option<u64>,
2094
2095 string_check_utf8_base_cost: Option<u64>,
2096 string_check_utf8_per_byte_cost: Option<u64>,
2097 string_is_char_boundary_base_cost: Option<u64>,
2098 string_sub_string_base_cost: Option<u64>,
2099 string_sub_string_per_byte_cost: Option<u64>,
2100 string_index_of_base_cost: Option<u64>,
2101 string_index_of_per_byte_pattern_cost: Option<u64>,
2102 string_index_of_per_byte_searched_cost: Option<u64>,
2103
2104 vector_empty_base_cost: Option<u64>,
2105 vector_length_base_cost: Option<u64>,
2106 vector_push_back_base_cost: Option<u64>,
2107 vector_push_back_legacy_per_abstract_memory_unit_cost: Option<u64>,
2108 vector_borrow_base_cost: Option<u64>,
2109 vector_pop_back_base_cost: Option<u64>,
2110 vector_destroy_empty_base_cost: Option<u64>,
2111 vector_swap_base_cost: Option<u64>,
2112 debug_print_base_cost: Option<u64>,
2113 debug_print_stack_trace_base_cost: Option<u64>,
2114
2115 #[custom_setter]
2125 execution_version: Option<u64>,
2126
2127 consensus_bad_nodes_stake_threshold: Option<u64>,
2131
2132 max_jwk_votes_per_validator_per_epoch: Option<u64>,
2133 max_age_of_jwk_in_epochs: Option<u64>,
2137
2138 random_beacon_reduction_allowed_delta: Option<u16>,
2142
2143 random_beacon_reduction_lower_bound: Option<u32>,
2146
2147 random_beacon_dkg_timeout_round: Option<u32>,
2150
2151 random_beacon_min_round_interval_ms: Option<u64>,
2153
2154 random_beacon_dkg_version: Option<u64>,
2157
2158 consensus_max_transaction_size_bytes: Option<u64>,
2161 consensus_max_transactions_in_block_bytes: Option<u64>,
2163 consensus_max_num_transactions_in_block: Option<u64>,
2165
2166 consensus_voting_rounds: Option<u32>,
2168
2169 max_accumulated_txn_cost_per_object_in_narwhal_commit: Option<u64>,
2171
2172 max_deferral_rounds_for_congestion_control: Option<u64>,
2175
2176 epoch_close_deadline_ms: Option<u64>,
2181
2182 max_txn_cost_overage_per_object_in_commit: Option<u64>,
2184
2185 allowed_txn_cost_overage_burst_per_object_in_commit: Option<u64>,
2187
2188 min_checkpoint_interval_ms: Option<u64>,
2190
2191 checkpoint_summary_version_specific_data: Option<u64>,
2193
2194 max_soft_bundle_size: Option<u64>,
2196
2197 bridge_should_try_to_finalize_committee: Option<bool>,
2201
2202 max_accumulated_txn_cost_per_object_in_mysticeti_commit: Option<u64>,
2208
2209 max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit: Option<u64>,
2212
2213 consensus_gc_depth: Option<u32>,
2216
2217 gas_budget_based_txn_cost_cap_factor: Option<u64>,
2219
2220 gas_budget_based_txn_cost_absolute_cap_commit_count: Option<u64>,
2222
2223 sip_45_consensus_amplification_threshold: Option<u64>,
2226
2227 use_object_per_epoch_marker_table_v2: Option<bool>,
2230
2231 consensus_commit_rate_estimation_window_size: Option<u32>,
2233
2234 #[serde(skip_serializing_if = "Vec::is_empty")]
2238 aliased_addresses: Vec<AliasedAddress>,
2239
2240 translation_per_command_base_charge: Option<u64>,
2243
2244 translation_per_input_base_charge: Option<u64>,
2247
2248 translation_pure_input_per_byte_charge: Option<u64>,
2250
2251 translation_per_type_node_charge: Option<u64>,
2255
2256 translation_per_reference_node_charge: Option<u64>,
2259
2260 translation_per_linkage_entry_charge: Option<u64>,
2263
2264 max_updates_per_settlement_txn: Option<u32>,
2266
2267 gasless_max_computation_units: Option<u64>,
2269
2270 gasless_allowed_token_types: Option<Vec<(String, u64)>>,
2272
2273 gasless_max_unused_inputs: Option<u64>,
2277
2278 gasless_max_pure_input_bytes: Option<u64>,
2281
2282 gasless_max_tps: Option<u64>,
2284
2285 #[serde(skip_serializing_if = "Option::is_none")]
2286 #[skip_accessor]
2287 include_special_package_amendments: Option<Arc<Amendments>>,
2288
2289 gasless_max_tx_size_bytes: Option<u64>,
2292
2293 translation_per_live_reference_charge: Option<u64>,
2296
2297 max_ptb_live_references: Option<u64>,
2300
2301 max_ptb_returned_references: Option<u64>,
2304
2305 max_ptb_total_returned_references: Option<u64>,
2308}
2309
2310#[derive(Clone, Serialize, Deserialize, Debug)]
2312pub struct AliasedAddress {
2313 pub original: [u8; 32],
2315 pub aliased: [u8; 32],
2317 pub allowed_tx_digests: Vec<[u8; 32]>,
2319}
2320
2321impl ProtocolConfig {
2323 pub fn chain(&self) -> Chain {
2325 self.chain
2326 }
2327
2328 pub fn check_package_upgrades_supported(&self) -> Result<(), Error> {
2341 if self.feature_flags.package_upgrades {
2342 Ok(())
2343 } else {
2344 Err(Error(format!(
2345 "package upgrades are not supported at {:?}",
2346 self.version
2347 )))
2348 }
2349 }
2350
2351 pub fn zklogin_supported_providers(&self) -> &BTreeSet<String> {
2352 &self.feature_flags.zklogin_supported_providers
2353 }
2354
2355 pub fn zklogin_circuit_mode(&self) -> u64 {
2358 self.feature_flags.zklogin_circuit_mode
2359 }
2360
2361 pub fn consensus_transaction_ordering(&self) -> ConsensusTransactionOrdering {
2362 self.feature_flags.consensus_transaction_ordering
2363 }
2364
2365 pub fn mldsa65_auth(&self) -> bool {
2367 self.feature_flags.mldsa65_auth
2368 }
2369
2370 pub fn set_mldsa65_auth_for_testing(&mut self, val: bool) {
2371 self.feature_flags.mldsa65_auth = val;
2372 }
2373
2374 pub fn enable_jwk_consensus_updates(&self) -> bool {
2375 let ret = self.feature_flags.enable_jwk_consensus_updates;
2376 if ret {
2377 assert!(self.feature_flags.end_of_epoch_transaction_supported);
2379 }
2380 ret
2381 }
2382
2383 pub fn end_of_epoch_transaction_supported(&self) -> bool {
2384 let ret = self.feature_flags.end_of_epoch_transaction_supported;
2385 if !ret {
2386 assert!(!self.feature_flags.enable_jwk_consensus_updates);
2388 }
2389 ret
2390 }
2391
2392 pub fn dkg_version(&self) -> u64 {
2393 self.random_beacon_dkg_version.unwrap_or(1)
2395 }
2396
2397 pub fn bridge(&self) -> bool {
2398 let ret = self.feature_flags.bridge;
2399 if ret {
2400 assert!(self.feature_flags.end_of_epoch_transaction_supported);
2402 }
2403 ret
2404 }
2405
2406 pub fn should_try_to_finalize_bridge_committee(&self) -> bool {
2407 if !self.bridge() {
2408 return false;
2409 }
2410 self.bridge_should_try_to_finalize_committee.unwrap_or(true)
2412 }
2413
2414 pub fn zklogin_max_epoch_upper_bound_delta(&self) -> Option<u64> {
2415 self.feature_flags.zklogin_max_epoch_upper_bound_delta
2416 }
2417
2418 pub fn enable_allowances(&self) -> bool {
2419 self.feature_flags.enable_allowances && self.enable_accumulators()
2420 }
2421
2422 pub fn enable_coin_reservation_obj_refs(&self) -> bool {
2423 self.new_vm_enabled() && self.feature_flags.enable_coin_reservation_obj_refs
2424 }
2425
2426 pub fn enable_authenticated_event_streams(&self) -> bool {
2427 self.feature_flags.enable_authenticated_event_streams && self.enable_accumulators()
2428 }
2429
2430 pub fn per_object_congestion_control_mode(&self) -> PerObjectCongestionControlMode {
2431 self.feature_flags.per_object_congestion_control_mode
2432 }
2433
2434 pub fn consensus_choice(&self) -> ConsensusChoice {
2435 self.feature_flags.consensus_choice
2436 }
2437
2438 pub fn consensus_network(&self) -> ConsensusNetwork {
2439 self.feature_flags.consensus_network
2440 }
2441
2442 pub fn mysticeti_num_leaders_per_round(&self) -> Option<usize> {
2443 self.feature_flags.mysticeti_num_leaders_per_round
2444 }
2445
2446 pub fn max_transaction_size_bytes(&self) -> u64 {
2447 self.consensus_max_transaction_size_bytes
2449 .unwrap_or(256 * 1024)
2450 }
2451
2452 pub fn max_transactions_in_block_bytes(&self) -> u64 {
2453 if cfg!(msim) {
2454 256 * 1024
2455 } else {
2456 self.consensus_max_transactions_in_block_bytes
2457 .unwrap_or(512 * 1024)
2458 }
2459 }
2460
2461 pub fn max_num_transactions_in_block(&self) -> u64 {
2462 if cfg!(msim) {
2463 8
2464 } else {
2465 self.consensus_max_num_transactions_in_block.unwrap_or(512)
2466 }
2467 }
2468
2469 pub fn gc_depth(&self) -> u32 {
2470 self.consensus_gc_depth.unwrap_or(0)
2471 }
2472
2473 pub fn consensus_linearize_subdag_v2(&self) -> bool {
2474 let res = self.feature_flags.consensus_linearize_subdag_v2;
2475 assert!(
2476 !res || self.gc_depth() > 0,
2477 "The consensus linearize sub dag V2 requires GC to be enabled"
2478 );
2479 res
2480 }
2481
2482 pub fn consensus_median_based_commit_timestamp(&self) -> bool {
2483 let res = self.feature_flags.consensus_median_based_commit_timestamp;
2484 assert!(
2485 !res || self.gc_depth() > 0,
2486 "The consensus median based commit timestamp requires GC to be enabled"
2487 );
2488 res
2489 }
2490
2491 pub fn get_consensus_commit_rate_estimation_window_size(&self) -> u32 {
2492 self.consensus_commit_rate_estimation_window_size
2493 .unwrap_or(0)
2494 }
2495
2496 pub fn consensus_num_requested_prior_commits_at_startup(&self) -> u32 {
2497 let window_size = self.get_consensus_commit_rate_estimation_window_size();
2501 assert!(window_size == 0 || self.record_additional_state_digest_in_prologue());
2503 window_size
2504 }
2505
2506 pub fn address_aliases(&self) -> bool {
2507 let address_aliases = self.feature_flags.address_aliases;
2508 assert!(
2509 !address_aliases || self.mysticeti_fastpath(),
2510 "Address aliases requires Mysticeti fastpath to be enabled"
2511 );
2512 if address_aliases {
2513 assert!(
2514 self.feature_flags.disable_preconsensus_locking,
2515 "Address aliases requires CertifiedTransaction to be disabled"
2516 );
2517 }
2518 address_aliases
2519 }
2520
2521 pub fn new_vm_enabled(&self) -> bool {
2522 self.execution_version.is_some_and(|v| v >= 4)
2523 }
2524
2525 pub fn gasless_allowed_token_types(&self) -> &[(String, u64)] {
2526 debug_assert!(self.gasless_allowed_token_types.is_some());
2527 self.gasless_allowed_token_types.as_deref().unwrap_or(&[])
2528 }
2529
2530 pub fn get_gasless_max_unused_inputs(&self) -> u64 {
2531 self.gasless_max_unused_inputs.unwrap_or(u64::MAX)
2532 }
2533
2534 pub fn get_gasless_max_pure_input_bytes(&self) -> u64 {
2535 self.gasless_max_pure_input_bytes.unwrap_or(u64::MAX)
2536 }
2537
2538 pub fn get_gasless_max_tx_size_bytes(&self) -> u64 {
2539 self.gasless_max_tx_size_bytes.unwrap_or(u64::MAX)
2540 }
2541
2542 pub fn include_special_package_amendments_as_option(&self) -> &Option<Arc<Amendments>> {
2543 &self.include_special_package_amendments
2544 }
2545}
2546
2547static POISON_VERSION_METHODS: AtomicBool = AtomicBool::new(false);
2548
2549impl ProtocolConfig {
2551 pub fn get_for_version(version: ProtocolVersion, chain: Chain) -> Self {
2553 assert!(
2555 version >= ProtocolVersion::MIN,
2556 "Network protocol version is {:?}, but the minimum supported version by the binary is {:?}. Please upgrade the binary.",
2557 version,
2558 ProtocolVersion::MIN.0,
2559 );
2560 assert!(
2561 version <= ProtocolVersion::MAX_ALLOWED,
2562 "Network protocol version is {:?}, but the maximum supported version by the binary is {:?}. Please upgrade the binary.",
2563 version,
2564 ProtocolVersion::MAX_ALLOWED.0,
2565 );
2566
2567 let mut ret = Self::get_for_version_impl(version, chain);
2568 ret.version = version;
2569 ret.chain = chain;
2570
2571 ret = Self::apply_config_override(version, ret);
2572
2573 if std::env::var("SUI_PROTOCOL_CONFIG_OVERRIDE_ENABLE").is_ok() {
2574 warn!(
2575 "overriding ProtocolConfig settings with custom settings; this may break non-local networks"
2576 );
2577 let overrides: ProtocolConfigOptional =
2578 serde_env::from_env_with_prefix("SUI_PROTOCOL_CONFIG_OVERRIDE")
2579 .expect("failed to parse ProtocolConfig override env variables");
2580 overrides.apply_to(&mut ret);
2581 }
2582
2583 ret
2584 }
2585
2586 pub fn get_for_version_if_supported(version: ProtocolVersion, chain: Chain) -> Option<Self> {
2589 if version.0 >= ProtocolVersion::MIN.0 && version.0 <= ProtocolVersion::MAX_ALLOWED.0 {
2590 let mut ret = Self::get_for_version_impl(version, chain);
2591 ret.version = version;
2592 ret.chain = chain;
2593 ret = Self::apply_config_override(version, ret);
2594 Some(ret)
2595 } else {
2596 None
2597 }
2598 }
2599
2600 pub fn poison_get_for_min_version() {
2601 POISON_VERSION_METHODS.store(true, Ordering::Relaxed);
2602 }
2603
2604 fn load_poison_get_for_min_version() -> bool {
2605 POISON_VERSION_METHODS.load(Ordering::Relaxed)
2606 }
2607
2608 pub fn get_for_min_version() -> Self {
2611 if Self::load_poison_get_for_min_version() {
2612 panic!("get_for_min_version called on validator");
2613 }
2614 ProtocolConfig::get_for_version(ProtocolVersion::MIN, Chain::Unknown)
2615 }
2616
2617 #[allow(non_snake_case)]
2627 pub fn get_for_max_version_UNSAFE() -> Self {
2628 if Self::load_poison_get_for_min_version() {
2629 panic!("get_for_max_version_UNSAFE called on validator");
2630 }
2631 ProtocolConfig::get_for_version(ProtocolVersion::MAX, Chain::Unknown)
2632 }
2633
2634 fn get_for_version_impl(version: ProtocolVersion, chain: Chain) -> Self {
2635 #[cfg(msim)]
2636 {
2637 if version == ProtocolVersion::MAX_ALLOWED {
2639 let mut config = Self::get_for_version_impl(version - 1, Chain::Unknown);
2640 config.base_tx_cost_fixed = Some(config.base_tx_cost_fixed() + 1000);
2641 return config;
2642 }
2643 }
2644
2645 let mut cfg = Self {
2648 version,
2650 chain,
2651
2652 feature_flags: Default::default(),
2654
2655 max_tx_size_bytes: Some(128 * 1024),
2656 max_input_objects: Some(2048),
2658 max_serialized_tx_effects_size_bytes: Some(512 * 1024),
2659 max_serialized_tx_effects_size_bytes_system_tx: Some(512 * 1024 * 16),
2660 max_gas_payment_objects: Some(256),
2661 max_modules_in_publish: Some(128),
2662 max_package_dependencies: None,
2663 max_arguments: Some(512),
2664 max_type_arguments: Some(16),
2665 max_type_argument_depth: Some(16),
2666 max_pure_argument_size: Some(16 * 1024),
2667 max_programmable_tx_commands: Some(1024),
2668 move_binary_format_version: Some(6),
2669 min_move_binary_format_version: None,
2670 binary_module_handles: None,
2671 binary_struct_handles: None,
2672 binary_function_handles: None,
2673 binary_function_instantiations: None,
2674 binary_signatures: None,
2675 binary_constant_pool: None,
2676 binary_identifiers: None,
2677 binary_address_identifiers: None,
2678 binary_struct_defs: None,
2679 binary_struct_def_instantiations: None,
2680 binary_function_defs: None,
2681 binary_field_handles: None,
2682 binary_field_instantiations: None,
2683 binary_friend_decls: None,
2684 binary_enum_defs: None,
2685 binary_enum_def_instantiations: None,
2686 binary_variant_handles: None,
2687 binary_variant_instantiation_handles: None,
2688 max_move_object_size: Some(250 * 1024),
2689 max_move_package_size: Some(100 * 1024),
2690 max_publish_or_upgrade_per_ptb: None,
2691 max_tx_gas: Some(10_000_000_000),
2692 max_gas_price: Some(100_000),
2693 max_gas_price_rgp_factor_for_aborted_transactions: None,
2694 max_gas_computation_bucket: Some(5_000_000),
2695 max_loop_depth: Some(5),
2696 max_generic_instantiation_length: Some(32),
2697 max_function_parameters: Some(128),
2698 max_basic_blocks: Some(1024),
2699 max_value_stack_size: Some(1024),
2700 max_type_nodes: Some(256),
2701 max_generic_instantiation_type_nodes_per_function: None,
2702 max_generic_instantiation_type_nodes_per_module: None,
2703 max_accumulator_type_nodes: None,
2704 max_push_size: Some(10000),
2705 max_struct_definitions: Some(200),
2706 max_function_definitions: Some(1000),
2707 max_fields_in_struct: Some(32),
2708 max_dependency_depth: Some(100),
2709 max_num_event_emit: Some(256),
2710 max_num_new_move_object_ids: Some(2048),
2711 max_num_new_move_object_ids_system_tx: Some(2048 * 16),
2712 max_num_deleted_move_object_ids: Some(2048),
2713 max_num_deleted_move_object_ids_system_tx: Some(2048 * 16),
2714 max_num_transferred_move_object_ids: Some(2048),
2715 max_num_transferred_move_object_ids_system_tx: Some(2048 * 16),
2716 max_event_emit_size: Some(250 * 1024),
2717 max_move_vector_len: Some(256 * 1024),
2718 max_type_to_layout_nodes: None,
2719 max_ptb_value_size: None,
2720
2721 max_back_edges_per_function: Some(10_000),
2722 max_back_edges_per_module: Some(10_000),
2723 max_verifier_meter_ticks_per_function: Some(6_000_000),
2724 max_meter_ticks_per_module: Some(6_000_000),
2725 max_meter_ticks_per_package: None,
2726
2727 object_runtime_max_num_cached_objects: Some(1000),
2728 object_runtime_max_num_cached_objects_system_tx: Some(1000 * 16),
2729 object_runtime_max_num_store_entries: Some(1000),
2730 object_runtime_max_num_store_entries_system_tx: Some(1000 * 16),
2731 base_tx_cost_fixed: Some(110_000),
2732 package_publish_cost_fixed: Some(1_000),
2733 base_tx_cost_per_byte: Some(0),
2734 package_publish_cost_per_byte: Some(80),
2735 obj_access_cost_read_per_byte: Some(15),
2736 obj_access_cost_read_per_package_kb: None,
2737 obj_access_cost_mutate_per_byte: Some(40),
2738 obj_access_cost_delete_per_byte: Some(40),
2739 obj_access_cost_verify_per_byte: Some(200),
2740 obj_data_cost_refundable: Some(100),
2741 obj_metadata_cost_non_refundable: Some(50),
2742 gas_model_version: Some(1),
2743 storage_rebate_rate: Some(9900),
2744 storage_fund_reinvest_rate: Some(500),
2745 reward_slashing_rate: Some(5000),
2746 storage_gas_price: Some(1),
2747 accumulator_object_storage_cost: None,
2748 max_transactions_per_checkpoint: Some(10_000),
2749 max_checkpoint_size_bytes: Some(30 * 1024 * 1024),
2750
2751 buffer_stake_for_protocol_upgrade_bps: Some(0),
2754
2755 address_from_bytes_cost_base: Some(52),
2759 address_to_u256_cost_base: Some(52),
2761 address_from_u256_cost_base: Some(52),
2763
2764 config_read_setting_impl_cost_base: None,
2767 config_read_setting_impl_cost_per_byte: None,
2768
2769 package_original_package_id_impl_cost_base: None,
2770 package_original_package_id_impl_cost_per_byte: None,
2771
2772 dynamic_field_hash_type_and_key_cost_base: Some(100),
2775 dynamic_field_hash_type_and_key_type_cost_per_byte: Some(2),
2776 dynamic_field_hash_type_and_key_value_cost_per_byte: Some(2),
2777 dynamic_field_hash_type_and_key_type_tag_cost_per_byte: Some(2),
2778 dynamic_field_add_child_object_cost_base: Some(100),
2780 dynamic_field_add_child_object_type_cost_per_byte: Some(10),
2781 dynamic_field_add_child_object_value_cost_per_byte: Some(10),
2782 dynamic_field_add_child_object_struct_tag_cost_per_byte: Some(10),
2783 dynamic_field_borrow_child_object_cost_base: Some(100),
2785 dynamic_field_borrow_child_object_child_ref_cost_per_byte: Some(10),
2786 dynamic_field_borrow_child_object_type_cost_per_byte: Some(10),
2787 dynamic_field_remove_child_object_cost_base: Some(100),
2789 dynamic_field_remove_child_object_child_cost_per_byte: Some(2),
2790 dynamic_field_remove_child_object_type_cost_per_byte: Some(2),
2791 dynamic_field_has_child_object_cost_base: Some(100),
2793 dynamic_field_has_child_object_with_ty_cost_base: Some(100),
2795 dynamic_field_has_child_object_with_ty_type_cost_per_byte: Some(2),
2796 dynamic_field_has_child_object_with_ty_type_tag_cost_per_byte: Some(2),
2797
2798 scratch_add_cost_base: None,
2800 scratch_read_cost_base: None,
2801 scratch_read_value_cost: None,
2802 scratch_remove_cost_base: None,
2803 scratch_exists_cost_base: None,
2804 scratch_exists_with_type_cost_base: None,
2805 scratch_exists_with_type_type_cost: None,
2806 max_scratch_pad_size: None,
2807
2808 event_emit_cost_base: Some(52),
2811 event_emit_value_size_derivation_cost_per_byte: Some(2),
2812 event_emit_tag_size_derivation_cost_per_byte: Some(5),
2813 event_emit_output_cost_per_byte: Some(10),
2814 event_emit_auth_stream_cost: None,
2815
2816 reserve_object_funds_for_withdrawal_cost_base: None,
2818 reserve_object_funds_for_withdrawal_cold_read_cost: None,
2819
2820 object_borrow_uid_cost_base: Some(52),
2823 object_delete_impl_cost_base: Some(52),
2825 object_record_new_uid_cost_base: Some(52),
2827 object_record_new_uid_from_hash_cost_base: None,
2830
2831 transfer_transfer_internal_cost_base: Some(52),
2834 transfer_party_transfer_internal_cost_base: None,
2836 transfer_freeze_object_cost_base: Some(52),
2838 transfer_share_object_cost_base: Some(52),
2840 transfer_receive_object_cost_base: None,
2841 transfer_receive_object_type_cost_per_byte: None,
2842 transfer_receive_object_cost_per_byte: None,
2843
2844 tx_context_derive_id_cost_base: Some(52),
2847 tx_context_fresh_id_cost_base: None,
2848 tx_context_sender_cost_base: None,
2849 tx_context_epoch_cost_base: None,
2850 tx_context_epoch_timestamp_ms_cost_base: None,
2851 tx_context_sponsor_cost_base: None,
2852 tx_context_rgp_cost_base: None,
2853 tx_context_gas_price_cost_base: None,
2854 tx_context_gas_budget_cost_base: None,
2855 tx_context_ids_created_cost_base: None,
2856 tx_context_replace_cost_base: None,
2857
2858 types_is_one_time_witness_cost_base: Some(52),
2861 types_is_one_time_witness_type_tag_cost_per_byte: Some(2),
2862 types_is_one_time_witness_type_cost_per_byte: Some(2),
2863
2864 validator_validate_metadata_cost_base: Some(52),
2867 validator_validate_metadata_data_cost_per_byte: Some(2),
2868
2869 crypto_invalid_arguments_cost: Some(100),
2871 bls12381_bls12381_min_sig_verify_cost_base: Some(52),
2873 bls12381_bls12381_min_sig_verify_msg_cost_per_byte: Some(2),
2874 bls12381_bls12381_min_sig_verify_msg_cost_per_block: Some(2),
2875
2876 bls12381_bls12381_min_pk_verify_cost_base: Some(52),
2878 bls12381_bls12381_min_pk_verify_msg_cost_per_byte: Some(2),
2879 bls12381_bls12381_min_pk_verify_msg_cost_per_block: Some(2),
2880
2881 ecdsa_k1_ecrecover_keccak256_cost_base: Some(52),
2883 ecdsa_k1_ecrecover_keccak256_msg_cost_per_byte: Some(2),
2884 ecdsa_k1_ecrecover_keccak256_msg_cost_per_block: Some(2),
2885 ecdsa_k1_ecrecover_sha256_cost_base: Some(52),
2886 ecdsa_k1_ecrecover_sha256_msg_cost_per_byte: Some(2),
2887 ecdsa_k1_ecrecover_sha256_msg_cost_per_block: Some(2),
2888
2889 ecdsa_k1_decompress_pubkey_cost_base: Some(52),
2891
2892 ecdsa_k1_secp256k1_verify_keccak256_cost_base: Some(52),
2894 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_byte: Some(2),
2895 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_block: Some(2),
2896 ecdsa_k1_secp256k1_verify_sha256_cost_base: Some(52),
2897 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_byte: Some(2),
2898 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_block: Some(2),
2899
2900 ecdsa_r1_ecrecover_keccak256_cost_base: Some(52),
2902 ecdsa_r1_ecrecover_keccak256_msg_cost_per_byte: Some(2),
2903 ecdsa_r1_ecrecover_keccak256_msg_cost_per_block: Some(2),
2904 ecdsa_r1_ecrecover_sha256_cost_base: Some(52),
2905 ecdsa_r1_ecrecover_sha256_msg_cost_per_byte: Some(2),
2906 ecdsa_r1_ecrecover_sha256_msg_cost_per_block: Some(2),
2907
2908 ecdsa_r1_secp256r1_verify_keccak256_cost_base: Some(52),
2910 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_byte: Some(2),
2911 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_block: Some(2),
2912 ecdsa_r1_secp256r1_verify_sha256_cost_base: Some(52),
2913 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_byte: Some(2),
2914 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_block: Some(2),
2915
2916 ecvrf_ecvrf_verify_cost_base: Some(52),
2918 ecvrf_ecvrf_verify_alpha_string_cost_per_byte: Some(2),
2919 ecvrf_ecvrf_verify_alpha_string_cost_per_block: Some(2),
2920
2921 ed25519_ed25519_verify_cost_base: Some(52),
2923 ed25519_ed25519_verify_msg_cost_per_byte: Some(2),
2924 ed25519_ed25519_verify_msg_cost_per_block: Some(2),
2925
2926 groth16_prepare_verifying_key_bls12381_cost_base: Some(52),
2928 groth16_prepare_verifying_key_bn254_cost_base: Some(52),
2929
2930 groth16_verify_groth16_proof_internal_bls12381_cost_base: Some(52),
2932 groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input: Some(2),
2933 groth16_verify_groth16_proof_internal_bn254_cost_base: Some(52),
2934 groth16_verify_groth16_proof_internal_bn254_cost_per_public_input: Some(2),
2935 groth16_verify_groth16_proof_internal_public_input_cost_per_byte: Some(2),
2936
2937 hash_blake2b256_cost_base: Some(52),
2939 hash_blake2b256_data_cost_per_byte: Some(2),
2940 hash_blake2b256_data_cost_per_block: Some(2),
2941
2942 hash_keccak256_cost_base: Some(52),
2944 hash_keccak256_data_cost_per_byte: Some(2),
2945 hash_keccak256_data_cost_per_block: Some(2),
2946
2947 poseidon_bn254_cost_base: None,
2948 poseidon_bn254_cost_per_block: None,
2949
2950 hmac_hmac_sha3_256_cost_base: Some(52),
2952 hmac_hmac_sha3_256_input_cost_per_byte: Some(2),
2953 hmac_hmac_sha3_256_input_cost_per_block: Some(2),
2954
2955 group_ops_bls12381_decode_scalar_cost: None,
2957 group_ops_bls12381_decode_g1_cost: None,
2958 group_ops_bls12381_decode_g2_cost: None,
2959 group_ops_bls12381_decode_gt_cost: None,
2960 group_ops_bls12381_scalar_add_cost: None,
2961 group_ops_bls12381_g1_add_cost: None,
2962 group_ops_bls12381_g2_add_cost: None,
2963 group_ops_bls12381_gt_add_cost: None,
2964 group_ops_bls12381_scalar_sub_cost: None,
2965 group_ops_bls12381_g1_sub_cost: None,
2966 group_ops_bls12381_g2_sub_cost: None,
2967 group_ops_bls12381_gt_sub_cost: None,
2968 group_ops_bls12381_scalar_mul_cost: None,
2969 group_ops_bls12381_g1_mul_cost: None,
2970 group_ops_bls12381_g2_mul_cost: None,
2971 group_ops_bls12381_gt_mul_cost: None,
2972 group_ops_bls12381_scalar_div_cost: None,
2973 group_ops_bls12381_g1_div_cost: None,
2974 group_ops_bls12381_g2_div_cost: None,
2975 group_ops_bls12381_gt_div_cost: None,
2976 group_ops_bls12381_g1_hash_to_base_cost: None,
2977 group_ops_bls12381_g2_hash_to_base_cost: None,
2978 group_ops_bls12381_g1_hash_to_cost_per_byte: None,
2979 group_ops_bls12381_g2_hash_to_cost_per_byte: None,
2980 group_ops_bls12381_g1_msm_base_cost: None,
2981 group_ops_bls12381_g2_msm_base_cost: None,
2982 group_ops_bls12381_g1_msm_base_cost_per_input: None,
2983 group_ops_bls12381_g2_msm_base_cost_per_input: None,
2984 group_ops_bls12381_msm_max_len: None,
2985 group_ops_bls12381_pairing_cost: None,
2986 group_ops_bls12381_g1_to_uncompressed_g1_cost: None,
2987 group_ops_bls12381_uncompressed_g1_to_g1_cost: None,
2988 group_ops_bls12381_uncompressed_g1_sum_base_cost: None,
2989 group_ops_bls12381_uncompressed_g1_sum_cost_per_term: None,
2990 group_ops_bls12381_uncompressed_g1_sum_max_terms: None,
2991
2992 group_ops_ristretto_decode_scalar_cost: None,
2993 group_ops_ristretto_decode_point_cost: None,
2994 group_ops_ristretto_scalar_add_cost: None,
2995 group_ops_ristretto_point_add_cost: None,
2996 group_ops_ristretto_scalar_sub_cost: None,
2997 group_ops_ristretto_point_sub_cost: None,
2998 group_ops_ristretto_scalar_mul_cost: None,
2999 group_ops_ristretto_point_mul_cost: None,
3000 group_ops_ristretto_scalar_div_cost: None,
3001 group_ops_ristretto_point_div_cost: None,
3002
3003 verify_bulletproofs_ristretto255_base_cost: None,
3004 verify_bulletproofs_ristretto255_cost_per_bit_and_commitment: None,
3005 max_bulletproofs_total_bits: None,
3006
3007 check_zklogin_id_cost_base: None,
3009 check_zklogin_issuer_cost_base: None,
3011
3012 vdf_verify_vdf_cost: None,
3013 vdf_hash_to_input_cost: None,
3014
3015 nitro_attestation_parse_base_cost: None,
3017 nitro_attestation_parse_cost_per_byte: None,
3018 nitro_attestation_verify_base_cost: None,
3019 nitro_attestation_verify_cost_per_cert: None,
3020
3021 bcs_per_byte_serialized_cost: None,
3022 bcs_legacy_min_output_size_cost: None,
3023 bcs_failure_cost: None,
3024 hash_sha2_256_base_cost: None,
3025 hash_sha2_256_per_byte_cost: None,
3026 hash_sha2_256_legacy_min_input_len_cost: None,
3027 hash_sha3_256_base_cost: None,
3028 hash_sha3_256_per_byte_cost: None,
3029 hash_sha3_256_legacy_min_input_len_cost: None,
3030 type_name_get_base_cost: None,
3031 type_name_get_per_byte_cost: None,
3032 type_name_id_base_cost: None,
3033 string_check_utf8_base_cost: None,
3034 string_check_utf8_per_byte_cost: None,
3035 string_is_char_boundary_base_cost: None,
3036 string_sub_string_base_cost: None,
3037 string_sub_string_per_byte_cost: None,
3038 string_index_of_base_cost: None,
3039 string_index_of_per_byte_pattern_cost: None,
3040 string_index_of_per_byte_searched_cost: None,
3041 vector_empty_base_cost: None,
3042 vector_length_base_cost: None,
3043 vector_push_back_base_cost: None,
3044 vector_push_back_legacy_per_abstract_memory_unit_cost: None,
3045 vector_borrow_base_cost: None,
3046 vector_pop_back_base_cost: None,
3047 vector_destroy_empty_base_cost: None,
3048 vector_swap_base_cost: None,
3049 debug_print_base_cost: None,
3050 debug_print_stack_trace_base_cost: None,
3051
3052 max_size_written_objects: None,
3053 max_size_written_objects_system_tx: None,
3054
3055 max_move_identifier_len: None,
3062 max_move_value_depth: None,
3063 package_arena_size_in_bytes: None,
3064 max_move_enum_variants: None,
3065
3066 gas_rounding_step: None,
3067
3068 execution_version: None,
3069
3070 max_event_emit_size_total: None,
3071
3072 consensus_bad_nodes_stake_threshold: None,
3073
3074 max_jwk_votes_per_validator_per_epoch: None,
3075
3076 max_age_of_jwk_in_epochs: None,
3077
3078 random_beacon_reduction_allowed_delta: None,
3079
3080 random_beacon_reduction_lower_bound: None,
3081
3082 random_beacon_dkg_timeout_round: None,
3083
3084 random_beacon_min_round_interval_ms: None,
3085
3086 random_beacon_dkg_version: None,
3087
3088 consensus_max_transaction_size_bytes: None,
3089
3090 consensus_max_transactions_in_block_bytes: None,
3091
3092 consensus_max_num_transactions_in_block: None,
3093
3094 consensus_voting_rounds: None,
3095
3096 max_accumulated_txn_cost_per_object_in_narwhal_commit: None,
3097
3098 max_deferral_rounds_for_congestion_control: None,
3099
3100 epoch_close_deadline_ms: None,
3101
3102 max_txn_cost_overage_per_object_in_commit: None,
3103
3104 allowed_txn_cost_overage_burst_per_object_in_commit: None,
3105
3106 min_checkpoint_interval_ms: None,
3107
3108 checkpoint_summary_version_specific_data: None,
3109
3110 max_soft_bundle_size: None,
3111
3112 bridge_should_try_to_finalize_committee: None,
3113
3114 max_accumulated_txn_cost_per_object_in_mysticeti_commit: None,
3115
3116 max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit: None,
3117
3118 consensus_gc_depth: None,
3119
3120 gas_budget_based_txn_cost_cap_factor: None,
3121
3122 gas_budget_based_txn_cost_absolute_cap_commit_count: None,
3123
3124 sip_45_consensus_amplification_threshold: None,
3125
3126 use_object_per_epoch_marker_table_v2: None,
3127
3128 consensus_commit_rate_estimation_window_size: None,
3129
3130 aliased_addresses: vec![],
3131
3132 translation_per_command_base_charge: None,
3133 translation_per_input_base_charge: None,
3134 translation_pure_input_per_byte_charge: None,
3135 translation_per_type_node_charge: None,
3136 translation_per_reference_node_charge: None,
3137 translation_per_linkage_entry_charge: None,
3138 translation_per_live_reference_charge: None,
3139 max_ptb_live_references: None,
3140 max_ptb_returned_references: None,
3141 max_ptb_total_returned_references: None,
3142
3143 max_updates_per_settlement_txn: None,
3144
3145 gasless_max_computation_units: None,
3146 gasless_allowed_token_types: None,
3147 gasless_max_unused_inputs: None,
3148 gasless_max_pure_input_bytes: None,
3149 gasless_max_tps: None,
3150 include_special_package_amendments: None,
3151 gasless_max_tx_size_bytes: None,
3152 };
3155 for cur in 2..=version.0 {
3156 match cur {
3157 1 => unreachable!(),
3158 2 => {
3159 cfg.feature_flags.advance_epoch_start_time_in_safe_mode = true;
3160 }
3161 3 => {
3162 cfg.gas_model_version = Some(2);
3164 cfg.max_tx_gas = Some(50_000_000_000);
3166 cfg.base_tx_cost_fixed = Some(2_000);
3168 cfg.storage_gas_price = Some(76);
3170 cfg.feature_flags.loaded_child_objects_fixed = true;
3171 cfg.max_size_written_objects = Some(5 * 1000 * 1000);
3174 cfg.max_size_written_objects_system_tx = Some(50 * 1000 * 1000);
3177 cfg.feature_flags.package_upgrades = true;
3178 }
3179 4 => {
3184 cfg.reward_slashing_rate = Some(10000);
3186 cfg.gas_model_version = Some(3);
3188 }
3189 5 => {
3190 cfg.feature_flags.missing_type_is_compatibility_error = true;
3191 cfg.gas_model_version = Some(4);
3192 cfg.feature_flags.scoring_decision_with_validity_cutoff = true;
3193 }
3197 6 => {
3198 cfg.gas_model_version = Some(5);
3199 cfg.buffer_stake_for_protocol_upgrade_bps = Some(5000);
3200 cfg.feature_flags.consensus_order_end_of_epoch_last = true;
3201 }
3202 7 => {
3203 cfg.feature_flags.disallow_adding_abilities_on_upgrade = true;
3204 cfg.feature_flags
3205 .disable_invariant_violation_check_in_swap_loc = true;
3206 cfg.feature_flags.ban_entry_init = true;
3207 cfg.feature_flags.package_digest_hash_module = true;
3208 }
3209 8 => {
3210 cfg.feature_flags
3211 .disallow_change_struct_type_params_on_upgrade = true;
3212 }
3213 9 => {
3214 cfg.max_move_identifier_len = Some(128);
3216 cfg.feature_flags.no_extraneous_module_bytes = true;
3217 cfg.feature_flags
3218 .advance_to_highest_supported_protocol_version = true;
3219 }
3220 10 => {
3221 cfg.max_verifier_meter_ticks_per_function = Some(16_000_000);
3222 cfg.max_meter_ticks_per_module = Some(16_000_000);
3223 }
3224 11 => {
3225 cfg.max_move_value_depth = Some(128);
3226 }
3227 12 => {
3228 cfg.feature_flags.narwhal_versioned_metadata = true;
3229 if chain != Chain::Mainnet {
3230 cfg.feature_flags.commit_root_state_digest = true;
3231 }
3232
3233 if chain != Chain::Mainnet && chain != Chain::Testnet {
3234 cfg.feature_flags.zklogin_auth = true;
3235 }
3236 }
3237 13 => {}
3238 14 => {
3239 cfg.gas_rounding_step = Some(1_000);
3240 cfg.gas_model_version = Some(6);
3241 }
3242 15 => {
3243 cfg.feature_flags.consensus_transaction_ordering =
3244 ConsensusTransactionOrdering::ByGasPrice;
3245 }
3246 16 => {
3247 cfg.feature_flags.simplified_unwrap_then_delete = true;
3248 }
3249 17 => {
3250 cfg.feature_flags.upgraded_multisig_supported = true;
3251 }
3252 18 => {
3253 cfg.execution_version = Some(1);
3254 cfg.feature_flags.txn_base_cost_as_multiplier = true;
3263 cfg.base_tx_cost_fixed = Some(1_000);
3265 }
3266 19 => {
3267 cfg.max_num_event_emit = Some(1024);
3268 cfg.max_event_emit_size_total = Some(
3271 256 * 250 * 1024, );
3273 }
3274 20 => {
3275 cfg.feature_flags.commit_root_state_digest = true;
3276
3277 if chain != Chain::Mainnet {
3278 cfg.feature_flags.narwhal_new_leader_election_schedule = true;
3279 cfg.consensus_bad_nodes_stake_threshold = Some(20);
3280 }
3281 }
3282
3283 21 => {
3284 if chain != Chain::Mainnet {
3285 cfg.feature_flags.zklogin_supported_providers = BTreeSet::from([
3286 "Google".to_string(),
3287 "Facebook".to_string(),
3288 "Twitch".to_string(),
3289 ]);
3290 }
3291 }
3292 22 => {
3293 cfg.feature_flags.loaded_child_object_format = true;
3294 }
3295 23 => {
3296 cfg.feature_flags.loaded_child_object_format_type = true;
3297 cfg.feature_flags.narwhal_new_leader_election_schedule = true;
3298 cfg.consensus_bad_nodes_stake_threshold = Some(20);
3304 }
3305 24 => {
3306 cfg.feature_flags.simple_conservation_checks = true;
3307 cfg.max_publish_or_upgrade_per_ptb = Some(5);
3308
3309 cfg.feature_flags.end_of_epoch_transaction_supported = true;
3310
3311 if chain != Chain::Mainnet {
3312 cfg.feature_flags.enable_jwk_consensus_updates = true;
3313 cfg.max_jwk_votes_per_validator_per_epoch = Some(240);
3315 cfg.max_age_of_jwk_in_epochs = Some(1);
3316 }
3317 }
3318 25 => {
3319 cfg.feature_flags.zklogin_supported_providers = BTreeSet::from([
3321 "Google".to_string(),
3322 "Facebook".to_string(),
3323 "Twitch".to_string(),
3324 ]);
3325 cfg.feature_flags.zklogin_auth = true;
3326
3327 cfg.feature_flags.enable_jwk_consensus_updates = true;
3329 cfg.max_jwk_votes_per_validator_per_epoch = Some(240);
3330 cfg.max_age_of_jwk_in_epochs = Some(1);
3331 }
3332 26 => {
3333 cfg.gas_model_version = Some(7);
3334 if chain != Chain::Mainnet && chain != Chain::Testnet {
3336 cfg.transfer_receive_object_cost_base = Some(52);
3337 cfg.feature_flags.receive_objects = true;
3338 }
3339 }
3340 27 => {
3341 cfg.gas_model_version = Some(8);
3342 }
3343 28 => {
3344 cfg.check_zklogin_id_cost_base = Some(200);
3346 cfg.check_zklogin_issuer_cost_base = Some(200);
3348
3349 if chain != Chain::Mainnet && chain != Chain::Testnet {
3351 cfg.feature_flags.enable_effects_v2 = true;
3352 }
3353 }
3354 29 => {
3355 cfg.feature_flags.verify_legacy_zklogin_address = true;
3356 }
3357 30 => {
3358 if chain != Chain::Mainnet {
3360 cfg.feature_flags.narwhal_certificate_v2 = true;
3361 }
3362
3363 cfg.random_beacon_reduction_allowed_delta = Some(800);
3364 if chain != Chain::Mainnet {
3366 cfg.feature_flags.enable_effects_v2 = true;
3367 }
3368
3369 cfg.feature_flags.zklogin_supported_providers = BTreeSet::default();
3373
3374 cfg.feature_flags.recompute_has_public_transfer_in_execution = true;
3375 }
3376 31 => {
3377 cfg.execution_version = Some(2);
3378 if chain != Chain::Mainnet && chain != Chain::Testnet {
3380 cfg.feature_flags.shared_object_deletion = true;
3381 }
3382 }
3383 32 => {
3384 if chain != Chain::Mainnet {
3386 cfg.feature_flags.accept_zklogin_in_multisig = true;
3387 }
3388 if chain != Chain::Mainnet {
3390 cfg.transfer_receive_object_cost_base = Some(52);
3391 cfg.feature_flags.receive_objects = true;
3392 }
3393 if chain != Chain::Mainnet && chain != Chain::Testnet {
3395 cfg.feature_flags.random_beacon = true;
3396 cfg.random_beacon_reduction_lower_bound = Some(1600);
3397 cfg.random_beacon_dkg_timeout_round = Some(3000);
3398 cfg.random_beacon_min_round_interval_ms = Some(150);
3399 }
3400 if chain != Chain::Testnet && chain != Chain::Mainnet {
3402 cfg.feature_flags.include_consensus_digest_in_prologue = true;
3403 }
3404
3405 cfg.feature_flags.narwhal_certificate_v2 = true;
3407 }
3408 33 => {
3409 cfg.feature_flags.hardened_otw_check = true;
3410 cfg.feature_flags.allow_receiving_object_id = true;
3411
3412 cfg.transfer_receive_object_cost_base = Some(52);
3414 cfg.feature_flags.receive_objects = true;
3415
3416 if chain != Chain::Mainnet {
3418 cfg.feature_flags.shared_object_deletion = true;
3419 }
3420
3421 cfg.feature_flags.enable_effects_v2 = true;
3422 }
3423 34 => {}
3424 35 => {
3425 if chain != Chain::Mainnet && chain != Chain::Testnet {
3427 cfg.feature_flags.enable_poseidon = true;
3428 cfg.poseidon_bn254_cost_base = Some(260);
3429 cfg.poseidon_bn254_cost_per_block = Some(10);
3430 }
3431
3432 cfg.feature_flags.enable_coin_deny_list = true;
3433 }
3434 36 => {
3435 if chain != Chain::Mainnet && chain != Chain::Testnet {
3437 cfg.feature_flags.enable_group_ops_native_functions = true;
3438 cfg.feature_flags.enable_group_ops_native_function_msm = true;
3439 cfg.group_ops_bls12381_decode_scalar_cost = Some(52);
3441 cfg.group_ops_bls12381_decode_g1_cost = Some(52);
3442 cfg.group_ops_bls12381_decode_g2_cost = Some(52);
3443 cfg.group_ops_bls12381_decode_gt_cost = Some(52);
3444 cfg.group_ops_bls12381_scalar_add_cost = Some(52);
3445 cfg.group_ops_bls12381_g1_add_cost = Some(52);
3446 cfg.group_ops_bls12381_g2_add_cost = Some(52);
3447 cfg.group_ops_bls12381_gt_add_cost = Some(52);
3448 cfg.group_ops_bls12381_scalar_sub_cost = Some(52);
3449 cfg.group_ops_bls12381_g1_sub_cost = Some(52);
3450 cfg.group_ops_bls12381_g2_sub_cost = Some(52);
3451 cfg.group_ops_bls12381_gt_sub_cost = Some(52);
3452 cfg.group_ops_bls12381_scalar_mul_cost = Some(52);
3453 cfg.group_ops_bls12381_g1_mul_cost = Some(52);
3454 cfg.group_ops_bls12381_g2_mul_cost = Some(52);
3455 cfg.group_ops_bls12381_gt_mul_cost = Some(52);
3456 cfg.group_ops_bls12381_scalar_div_cost = Some(52);
3457 cfg.group_ops_bls12381_g1_div_cost = Some(52);
3458 cfg.group_ops_bls12381_g2_div_cost = Some(52);
3459 cfg.group_ops_bls12381_gt_div_cost = Some(52);
3460 cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(52);
3461 cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(52);
3462 cfg.group_ops_bls12381_g1_hash_to_cost_per_byte = Some(2);
3463 cfg.group_ops_bls12381_g2_hash_to_cost_per_byte = Some(2);
3464 cfg.group_ops_bls12381_g1_msm_base_cost = Some(52);
3465 cfg.group_ops_bls12381_g2_msm_base_cost = Some(52);
3466 cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(52);
3467 cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(52);
3468 cfg.group_ops_bls12381_msm_max_len = Some(32);
3469 cfg.group_ops_bls12381_pairing_cost = Some(52);
3470 }
3471 cfg.feature_flags.shared_object_deletion = true;
3473
3474 cfg.consensus_max_transaction_size_bytes = Some(256 * 1024); cfg.consensus_max_transactions_in_block_bytes = Some(6 * 1_024 * 1024);
3476 }
3478 37 => {
3479 cfg.feature_flags.reject_mutable_random_on_entry_functions = true;
3480
3481 if chain != Chain::Mainnet {
3483 cfg.feature_flags.include_consensus_digest_in_prologue = true;
3484 }
3485 }
3486 38 => {
3487 cfg.binary_module_handles = Some(100);
3488 cfg.binary_struct_handles = Some(300);
3489 cfg.binary_function_handles = Some(1500);
3490 cfg.binary_function_instantiations = Some(750);
3491 cfg.binary_signatures = Some(1000);
3492 cfg.binary_constant_pool = Some(4000);
3496 cfg.binary_identifiers = Some(10000);
3497 cfg.binary_address_identifiers = Some(100);
3498 cfg.binary_struct_defs = Some(200);
3499 cfg.binary_struct_def_instantiations = Some(100);
3500 cfg.binary_function_defs = Some(1000);
3501 cfg.binary_field_handles = Some(500);
3502 cfg.binary_field_instantiations = Some(250);
3503 cfg.binary_friend_decls = Some(100);
3504 cfg.max_package_dependencies = Some(32);
3506 cfg.max_modules_in_publish = Some(64);
3507 cfg.execution_version = Some(3);
3509 }
3510 39 => {
3511 }
3513 40 => {}
3514 41 => {
3515 cfg.feature_flags.enable_group_ops_native_functions = true;
3517 cfg.group_ops_bls12381_decode_scalar_cost = Some(52);
3519 cfg.group_ops_bls12381_decode_g1_cost = Some(52);
3520 cfg.group_ops_bls12381_decode_g2_cost = Some(52);
3521 cfg.group_ops_bls12381_decode_gt_cost = Some(52);
3522 cfg.group_ops_bls12381_scalar_add_cost = Some(52);
3523 cfg.group_ops_bls12381_g1_add_cost = Some(52);
3524 cfg.group_ops_bls12381_g2_add_cost = Some(52);
3525 cfg.group_ops_bls12381_gt_add_cost = Some(52);
3526 cfg.group_ops_bls12381_scalar_sub_cost = Some(52);
3527 cfg.group_ops_bls12381_g1_sub_cost = Some(52);
3528 cfg.group_ops_bls12381_g2_sub_cost = Some(52);
3529 cfg.group_ops_bls12381_gt_sub_cost = Some(52);
3530 cfg.group_ops_bls12381_scalar_mul_cost = Some(52);
3531 cfg.group_ops_bls12381_g1_mul_cost = Some(52);
3532 cfg.group_ops_bls12381_g2_mul_cost = Some(52);
3533 cfg.group_ops_bls12381_gt_mul_cost = Some(52);
3534 cfg.group_ops_bls12381_scalar_div_cost = Some(52);
3535 cfg.group_ops_bls12381_g1_div_cost = Some(52);
3536 cfg.group_ops_bls12381_g2_div_cost = Some(52);
3537 cfg.group_ops_bls12381_gt_div_cost = Some(52);
3538 cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(52);
3539 cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(52);
3540 cfg.group_ops_bls12381_g1_hash_to_cost_per_byte = Some(2);
3541 cfg.group_ops_bls12381_g2_hash_to_cost_per_byte = Some(2);
3542 cfg.group_ops_bls12381_g1_msm_base_cost = Some(52);
3543 cfg.group_ops_bls12381_g2_msm_base_cost = Some(52);
3544 cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(52);
3545 cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(52);
3546 cfg.group_ops_bls12381_msm_max_len = Some(32);
3547 cfg.group_ops_bls12381_pairing_cost = Some(52);
3548 }
3549 42 => {}
3550 43 => {
3551 cfg.feature_flags.zklogin_max_epoch_upper_bound_delta = Some(30);
3552 cfg.max_meter_ticks_per_package = Some(16_000_000);
3553 }
3554 44 => {
3555 cfg.feature_flags.include_consensus_digest_in_prologue = true;
3557 if chain != Chain::Mainnet {
3559 cfg.feature_flags.consensus_choice = ConsensusChoice::SwapEachEpoch;
3560 }
3561 }
3562 45 => {
3563 if chain != Chain::Testnet && chain != Chain::Mainnet {
3565 cfg.feature_flags.consensus_network = ConsensusNetwork::Tonic;
3566 }
3567
3568 if chain != Chain::Mainnet {
3569 cfg.feature_flags.mysticeti_leader_scoring_and_schedule = true;
3571 }
3572 cfg.min_move_binary_format_version = Some(6);
3573 cfg.feature_flags.accept_zklogin_in_multisig = true;
3574
3575 if chain != Chain::Mainnet && chain != Chain::Testnet {
3579 cfg.feature_flags.bridge = true;
3580 }
3581 }
3582 46 => {
3583 if chain != Chain::Mainnet {
3585 cfg.feature_flags.bridge = true;
3586 }
3587
3588 cfg.feature_flags.reshare_at_same_initial_version = true;
3590 }
3591 47 => {}
3592 48 => {
3593 cfg.feature_flags.consensus_network = ConsensusNetwork::Tonic;
3595
3596 cfg.feature_flags.resolve_abort_locations_to_package_id = true;
3598
3599 if chain != Chain::Mainnet {
3601 cfg.feature_flags.random_beacon = true;
3602 cfg.random_beacon_reduction_lower_bound = Some(1600);
3603 cfg.random_beacon_dkg_timeout_round = Some(3000);
3604 cfg.random_beacon_min_round_interval_ms = Some(200);
3605 }
3606
3607 cfg.feature_flags.mysticeti_use_committed_subdag_digest = true;
3609 }
3610 49 => {
3611 if chain != Chain::Testnet && chain != Chain::Mainnet {
3612 cfg.move_binary_format_version = Some(7);
3613 }
3614
3615 if chain != Chain::Mainnet && chain != Chain::Testnet {
3617 cfg.feature_flags.enable_vdf = true;
3618 cfg.vdf_verify_vdf_cost = Some(1500);
3621 cfg.vdf_hash_to_input_cost = Some(100);
3622 }
3623
3624 if chain != Chain::Testnet && chain != Chain::Mainnet {
3626 cfg.feature_flags
3627 .record_consensus_determined_version_assignments_in_prologue = true;
3628 }
3629
3630 if chain != Chain::Mainnet {
3632 cfg.feature_flags.consensus_choice = ConsensusChoice::Mysticeti;
3633 }
3634
3635 cfg.feature_flags.fresh_vm_on_framework_upgrade = true;
3637 }
3638 50 => {
3639 if chain != Chain::Mainnet {
3641 cfg.checkpoint_summary_version_specific_data = Some(1);
3642 cfg.min_checkpoint_interval_ms = Some(200);
3643 }
3644
3645 if chain != Chain::Testnet && chain != Chain::Mainnet {
3647 cfg.feature_flags
3648 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = true;
3649 }
3650
3651 cfg.feature_flags.mysticeti_num_leaders_per_round = Some(1);
3652
3653 cfg.max_deferral_rounds_for_congestion_control = Some(10);
3655 }
3656 51 => {
3657 cfg.random_beacon_dkg_version = Some(1);
3658
3659 if chain != Chain::Testnet && chain != Chain::Mainnet {
3660 cfg.feature_flags.enable_coin_deny_list_v2 = true;
3661 }
3662 }
3663 52 => {
3664 if chain != Chain::Mainnet {
3665 cfg.feature_flags.soft_bundle = true;
3666 cfg.max_soft_bundle_size = Some(5);
3667 }
3668
3669 cfg.config_read_setting_impl_cost_base = Some(100);
3670 cfg.config_read_setting_impl_cost_per_byte = Some(40);
3671
3672 if chain != Chain::Testnet && chain != Chain::Mainnet {
3674 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(100);
3675 cfg.feature_flags.per_object_congestion_control_mode =
3676 PerObjectCongestionControlMode::TotalTxCount;
3677 }
3678
3679 cfg.feature_flags.consensus_choice = ConsensusChoice::Mysticeti;
3681
3682 cfg.feature_flags.mysticeti_leader_scoring_and_schedule = true;
3684
3685 cfg.checkpoint_summary_version_specific_data = Some(1);
3687 cfg.min_checkpoint_interval_ms = Some(200);
3688
3689 if chain != Chain::Mainnet {
3691 cfg.feature_flags
3692 .record_consensus_determined_version_assignments_in_prologue = true;
3693 cfg.feature_flags
3694 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = true;
3695 }
3696 if chain != Chain::Mainnet {
3698 cfg.move_binary_format_version = Some(7);
3699 }
3700
3701 if chain != Chain::Testnet && chain != Chain::Mainnet {
3702 cfg.feature_flags.passkey_auth = true;
3703 }
3704 cfg.feature_flags.enable_coin_deny_list_v2 = true;
3705 }
3706 53 => {
3707 cfg.bridge_should_try_to_finalize_committee = Some(chain != Chain::Mainnet);
3709
3710 cfg.feature_flags
3712 .record_consensus_determined_version_assignments_in_prologue = true;
3713 cfg.feature_flags
3714 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = true;
3715
3716 if chain == Chain::Unknown {
3717 cfg.feature_flags.authority_capabilities_v2 = true;
3718 }
3719
3720 if chain != Chain::Mainnet {
3722 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(100);
3723 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(10);
3724 cfg.feature_flags.per_object_congestion_control_mode =
3725 PerObjectCongestionControlMode::TotalTxCount;
3726 }
3727
3728 cfg.bcs_per_byte_serialized_cost = Some(2);
3730 cfg.bcs_legacy_min_output_size_cost = Some(1);
3731 cfg.bcs_failure_cost = Some(52);
3732 cfg.debug_print_base_cost = Some(52);
3733 cfg.debug_print_stack_trace_base_cost = Some(52);
3734 cfg.hash_sha2_256_base_cost = Some(52);
3735 cfg.hash_sha2_256_per_byte_cost = Some(2);
3736 cfg.hash_sha2_256_legacy_min_input_len_cost = Some(1);
3737 cfg.hash_sha3_256_base_cost = Some(52);
3738 cfg.hash_sha3_256_per_byte_cost = Some(2);
3739 cfg.hash_sha3_256_legacy_min_input_len_cost = Some(1);
3740 cfg.type_name_get_base_cost = Some(52);
3741 cfg.type_name_get_per_byte_cost = Some(2);
3742 cfg.string_check_utf8_base_cost = Some(52);
3743 cfg.string_check_utf8_per_byte_cost = Some(2);
3744 cfg.string_is_char_boundary_base_cost = Some(52);
3745 cfg.string_sub_string_base_cost = Some(52);
3746 cfg.string_sub_string_per_byte_cost = Some(2);
3747 cfg.string_index_of_base_cost = Some(52);
3748 cfg.string_index_of_per_byte_pattern_cost = Some(2);
3749 cfg.string_index_of_per_byte_searched_cost = Some(2);
3750 cfg.vector_empty_base_cost = Some(52);
3751 cfg.vector_length_base_cost = Some(52);
3752 cfg.vector_push_back_base_cost = Some(52);
3753 cfg.vector_push_back_legacy_per_abstract_memory_unit_cost = Some(2);
3754 cfg.vector_borrow_base_cost = Some(52);
3755 cfg.vector_pop_back_base_cost = Some(52);
3756 cfg.vector_destroy_empty_base_cost = Some(52);
3757 cfg.vector_swap_base_cost = Some(52);
3758 }
3759 54 => {
3760 cfg.feature_flags.random_beacon = true;
3762 cfg.random_beacon_reduction_lower_bound = Some(1000);
3763 cfg.random_beacon_dkg_timeout_round = Some(3000);
3764 cfg.random_beacon_min_round_interval_ms = Some(500);
3765
3766 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(100);
3768 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(10);
3769 cfg.feature_flags.per_object_congestion_control_mode =
3770 PerObjectCongestionControlMode::TotalTxCount;
3771
3772 cfg.feature_flags.soft_bundle = true;
3774 cfg.max_soft_bundle_size = Some(5);
3775 }
3776 55 => {
3777 cfg.move_binary_format_version = Some(7);
3779
3780 cfg.consensus_max_transactions_in_block_bytes = Some(512 * 1024);
3782 cfg.consensus_max_num_transactions_in_block = Some(512);
3785
3786 cfg.feature_flags.rethrow_serialization_type_layout_errors = true;
3787 }
3788 56 => {
3789 if chain == Chain::Mainnet {
3790 cfg.feature_flags.bridge = true;
3791 }
3792 }
3793 57 => {
3794 cfg.random_beacon_reduction_lower_bound = Some(800);
3796 }
3797 58 => {
3798 if chain == Chain::Mainnet {
3799 cfg.bridge_should_try_to_finalize_committee = Some(true);
3800 }
3801
3802 if chain != Chain::Mainnet && chain != Chain::Testnet {
3803 cfg.feature_flags
3805 .consensus_distributed_vote_scoring_strategy = true;
3806 }
3807 }
3808 59 => {
3809 cfg.feature_flags.consensus_round_prober = true;
3811 }
3812 60 => {
3813 cfg.max_type_to_layout_nodes = Some(512);
3814 cfg.feature_flags.validate_identifier_inputs = true;
3815 }
3816 61 => {
3817 if chain != Chain::Mainnet {
3818 cfg.feature_flags
3820 .consensus_distributed_vote_scoring_strategy = true;
3821 }
3822 cfg.random_beacon_reduction_lower_bound = Some(700);
3824
3825 if chain != Chain::Mainnet && chain != Chain::Testnet {
3826 cfg.feature_flags.mysticeti_fastpath = true;
3828 }
3829 }
3830 62 => {
3831 cfg.feature_flags.relocate_event_module = true;
3832 }
3833 63 => {
3834 cfg.feature_flags.per_object_congestion_control_mode =
3835 PerObjectCongestionControlMode::TotalGasBudgetWithCap;
3836 cfg.gas_budget_based_txn_cost_cap_factor = Some(400_000);
3837 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(18_500_000);
3838 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(240_000_000);
3839 }
3840 64 => {
3841 cfg.feature_flags.per_object_congestion_control_mode =
3842 PerObjectCongestionControlMode::TotalTxCount;
3843 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(40);
3844 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(3);
3845 }
3846 65 => {
3847 cfg.feature_flags
3849 .consensus_distributed_vote_scoring_strategy = true;
3850 }
3851 66 => {
3852 if chain == Chain::Mainnet {
3853 cfg.feature_flags
3855 .consensus_distributed_vote_scoring_strategy = false;
3856 }
3857 }
3858 67 => {
3859 cfg.feature_flags
3861 .consensus_distributed_vote_scoring_strategy = true;
3862 }
3863 68 => {
3864 cfg.group_ops_bls12381_g1_to_uncompressed_g1_cost = Some(26);
3865 cfg.group_ops_bls12381_uncompressed_g1_to_g1_cost = Some(52);
3866 cfg.group_ops_bls12381_uncompressed_g1_sum_base_cost = Some(26);
3867 cfg.group_ops_bls12381_uncompressed_g1_sum_cost_per_term = Some(13);
3868 cfg.group_ops_bls12381_uncompressed_g1_sum_max_terms = Some(2000);
3869
3870 if chain != Chain::Mainnet && chain != Chain::Testnet {
3871 cfg.feature_flags.uncompressed_g1_group_elements = true;
3872 }
3873
3874 cfg.feature_flags.per_object_congestion_control_mode =
3875 PerObjectCongestionControlMode::TotalGasBudgetWithCap;
3876 cfg.gas_budget_based_txn_cost_cap_factor = Some(400_000);
3877 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(18_500_000);
3878 cfg.max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit =
3879 Some(3_700_000); cfg.max_txn_cost_overage_per_object_in_commit = Some(u64::MAX);
3881 cfg.gas_budget_based_txn_cost_absolute_cap_commit_count = Some(50);
3882
3883 cfg.random_beacon_reduction_lower_bound = Some(500);
3885
3886 cfg.feature_flags.disallow_new_modules_in_deps_only_packages = true;
3887 }
3888 69 => {
3889 cfg.consensus_voting_rounds = Some(40);
3891
3892 if chain != Chain::Mainnet && chain != Chain::Testnet {
3893 cfg.feature_flags.consensus_smart_ancestor_selection = true;
3895 }
3896
3897 if chain != Chain::Mainnet {
3898 cfg.feature_flags.uncompressed_g1_group_elements = true;
3899 }
3900 }
3901 70 => {
3902 if chain != Chain::Mainnet {
3903 cfg.feature_flags.consensus_smart_ancestor_selection = true;
3905 cfg.feature_flags
3907 .consensus_round_prober_probe_accepted_rounds = true;
3908 }
3909
3910 cfg.poseidon_bn254_cost_per_block = Some(388);
3911
3912 cfg.gas_model_version = Some(9);
3913 cfg.feature_flags.native_charging_v2 = true;
3914 cfg.bls12381_bls12381_min_sig_verify_cost_base = Some(44064);
3915 cfg.bls12381_bls12381_min_pk_verify_cost_base = Some(49282);
3916 cfg.ecdsa_k1_secp256k1_verify_keccak256_cost_base = Some(1470);
3917 cfg.ecdsa_k1_secp256k1_verify_sha256_cost_base = Some(1470);
3918 cfg.ecdsa_r1_secp256r1_verify_sha256_cost_base = Some(4225);
3919 cfg.ecdsa_r1_secp256r1_verify_keccak256_cost_base = Some(4225);
3920 cfg.ecvrf_ecvrf_verify_cost_base = Some(4848);
3921 cfg.ed25519_ed25519_verify_cost_base = Some(1802);
3922
3923 cfg.ecdsa_r1_ecrecover_keccak256_cost_base = Some(1173);
3925 cfg.ecdsa_r1_ecrecover_sha256_cost_base = Some(1173);
3926 cfg.ecdsa_k1_ecrecover_keccak256_cost_base = Some(500);
3927 cfg.ecdsa_k1_ecrecover_sha256_cost_base = Some(500);
3928
3929 cfg.groth16_prepare_verifying_key_bls12381_cost_base = Some(53838);
3930 cfg.groth16_prepare_verifying_key_bn254_cost_base = Some(82010);
3931 cfg.groth16_verify_groth16_proof_internal_bls12381_cost_base = Some(72090);
3932 cfg.groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input =
3933 Some(8213);
3934 cfg.groth16_verify_groth16_proof_internal_bn254_cost_base = Some(115502);
3935 cfg.groth16_verify_groth16_proof_internal_bn254_cost_per_public_input =
3936 Some(9484);
3937
3938 cfg.hash_keccak256_cost_base = Some(10);
3939 cfg.hash_blake2b256_cost_base = Some(10);
3940
3941 cfg.group_ops_bls12381_decode_scalar_cost = Some(7);
3943 cfg.group_ops_bls12381_decode_g1_cost = Some(2848);
3944 cfg.group_ops_bls12381_decode_g2_cost = Some(3770);
3945 cfg.group_ops_bls12381_decode_gt_cost = Some(3068);
3946
3947 cfg.group_ops_bls12381_scalar_add_cost = Some(10);
3948 cfg.group_ops_bls12381_g1_add_cost = Some(1556);
3949 cfg.group_ops_bls12381_g2_add_cost = Some(3048);
3950 cfg.group_ops_bls12381_gt_add_cost = Some(188);
3951
3952 cfg.group_ops_bls12381_scalar_sub_cost = Some(10);
3953 cfg.group_ops_bls12381_g1_sub_cost = Some(1550);
3954 cfg.group_ops_bls12381_g2_sub_cost = Some(3019);
3955 cfg.group_ops_bls12381_gt_sub_cost = Some(497);
3956
3957 cfg.group_ops_bls12381_scalar_mul_cost = Some(11);
3958 cfg.group_ops_bls12381_g1_mul_cost = Some(4842);
3959 cfg.group_ops_bls12381_g2_mul_cost = Some(9108);
3960 cfg.group_ops_bls12381_gt_mul_cost = Some(27490);
3961
3962 cfg.group_ops_bls12381_scalar_div_cost = Some(91);
3963 cfg.group_ops_bls12381_g1_div_cost = Some(5091);
3964 cfg.group_ops_bls12381_g2_div_cost = Some(9206);
3965 cfg.group_ops_bls12381_gt_div_cost = Some(27804);
3966
3967 cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(2962);
3968 cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(8688);
3969
3970 cfg.group_ops_bls12381_g1_msm_base_cost = Some(62648);
3971 cfg.group_ops_bls12381_g2_msm_base_cost = Some(131192);
3972 cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(1333);
3973 cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(3216);
3974
3975 cfg.group_ops_bls12381_uncompressed_g1_to_g1_cost = Some(677);
3976 cfg.group_ops_bls12381_g1_to_uncompressed_g1_cost = Some(2099);
3977 cfg.group_ops_bls12381_uncompressed_g1_sum_base_cost = Some(77);
3978 cfg.group_ops_bls12381_uncompressed_g1_sum_cost_per_term = Some(26);
3979
3980 cfg.group_ops_bls12381_pairing_cost = Some(26897);
3981 cfg.group_ops_bls12381_uncompressed_g1_sum_max_terms = Some(1200);
3982
3983 cfg.validator_validate_metadata_cost_base = Some(20000);
3984 }
3985 71 => {
3986 cfg.sip_45_consensus_amplification_threshold = Some(5);
3987
3988 cfg.allowed_txn_cost_overage_burst_per_object_in_commit = Some(185_000_000);
3990 }
3991 72 => {
3992 cfg.feature_flags.convert_type_argument_error = true;
3993
3994 cfg.max_tx_gas = Some(50_000_000_000_000);
3997 cfg.max_gas_price = Some(50_000_000_000);
3999
4000 cfg.feature_flags.variant_nodes = true;
4001 }
4002 73 => {
4003 cfg.use_object_per_epoch_marker_table_v2 = Some(true);
4005
4006 if chain != Chain::Mainnet && chain != Chain::Testnet {
4007 cfg.consensus_gc_depth = Some(60);
4010 }
4011
4012 if chain != Chain::Mainnet {
4013 cfg.feature_flags.consensus_zstd_compression = true;
4015 }
4016
4017 cfg.feature_flags.consensus_smart_ancestor_selection = true;
4019 cfg.feature_flags
4021 .consensus_round_prober_probe_accepted_rounds = true;
4022
4023 cfg.feature_flags.per_object_congestion_control_mode =
4025 PerObjectCongestionControlMode::TotalGasBudgetWithCap;
4026 cfg.gas_budget_based_txn_cost_cap_factor = Some(400_000);
4027 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(37_000_000);
4028 cfg.max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit =
4029 Some(7_400_000); cfg.max_txn_cost_overage_per_object_in_commit = Some(u64::MAX);
4031 cfg.gas_budget_based_txn_cost_absolute_cap_commit_count = Some(50);
4032 cfg.allowed_txn_cost_overage_burst_per_object_in_commit = Some(370_000_000);
4033 }
4034 74 => {
4035 if chain != Chain::Mainnet && chain != Chain::Testnet {
4037 cfg.feature_flags.enable_nitro_attestation = true;
4038 }
4039 cfg.nitro_attestation_parse_base_cost = Some(53 * 50);
4040 cfg.nitro_attestation_parse_cost_per_byte = Some(50);
4041 cfg.nitro_attestation_verify_base_cost = Some(49632 * 50);
4042 cfg.nitro_attestation_verify_cost_per_cert = Some(52369 * 50);
4043
4044 cfg.feature_flags.consensus_zstd_compression = true;
4046
4047 if chain != Chain::Mainnet && chain != Chain::Testnet {
4048 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
4049 }
4050 }
4051 75 => {
4052 if chain != Chain::Mainnet {
4053 cfg.feature_flags.passkey_auth = true;
4054 }
4055 }
4056 76 => {
4057 if chain != Chain::Mainnet && chain != Chain::Testnet {
4058 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
4059 cfg.consensus_commit_rate_estimation_window_size = Some(10);
4060 }
4061 cfg.feature_flags.minimize_child_object_mutations = true;
4062
4063 if chain != Chain::Mainnet {
4064 cfg.feature_flags.accept_passkey_in_multisig = true;
4065 }
4066 }
4067 77 => {
4068 cfg.feature_flags.uncompressed_g1_group_elements = true;
4069
4070 if chain != Chain::Mainnet {
4071 cfg.consensus_gc_depth = Some(60);
4072 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
4073 }
4074 }
4075 78 => {
4076 cfg.feature_flags.move_native_context = true;
4077 cfg.tx_context_fresh_id_cost_base = Some(52);
4078 cfg.tx_context_sender_cost_base = Some(30);
4079 cfg.tx_context_epoch_cost_base = Some(30);
4080 cfg.tx_context_epoch_timestamp_ms_cost_base = Some(30);
4081 cfg.tx_context_sponsor_cost_base = Some(30);
4082 cfg.tx_context_gas_price_cost_base = Some(30);
4083 cfg.tx_context_gas_budget_cost_base = Some(30);
4084 cfg.tx_context_ids_created_cost_base = Some(30);
4085 cfg.tx_context_replace_cost_base = Some(30);
4086 cfg.gas_model_version = Some(10);
4087
4088 if chain != Chain::Mainnet {
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.per_object_congestion_control_mode =
4094 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4095 ExecutionTimeEstimateParams {
4096 target_utilization: 30,
4097 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4099 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4101 stored_observations_limit: u64::MAX,
4102 stake_weighted_median_threshold: 0,
4103 default_none_duration_for_new_keys: false,
4104 observations_chunk_size: None,
4105 },
4106 );
4107 }
4108 }
4109 79 => {
4110 if chain != Chain::Mainnet {
4111 cfg.feature_flags.consensus_median_based_commit_timestamp = true;
4112
4113 cfg.consensus_bad_nodes_stake_threshold = Some(30);
4116
4117 cfg.feature_flags.consensus_batched_block_sync = true;
4118
4119 cfg.feature_flags.enable_nitro_attestation = true
4121 }
4122 cfg.feature_flags.normalize_ptb_arguments = true;
4123
4124 cfg.consensus_gc_depth = Some(60);
4125 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
4126 }
4127 80 => {
4128 cfg.max_ptb_value_size = Some(1024 * 1024);
4129 }
4130 81 => {
4131 cfg.feature_flags.consensus_median_based_commit_timestamp = true;
4132 cfg.feature_flags.enforce_checkpoint_timestamp_monotonicity = true;
4133 cfg.consensus_bad_nodes_stake_threshold = Some(30)
4134 }
4135 82 => {
4136 cfg.feature_flags.max_ptb_value_size_v2 = true;
4137 }
4138 83 => {
4139 if chain == Chain::Mainnet {
4140 let aliased: [u8; 32] = Hex::decode(
4142 "0x0b2da327ba6a4cacbe75dddd50e6e8bbf81d6496e92d66af9154c61c77f7332f",
4143 )
4144 .unwrap()
4145 .try_into()
4146 .unwrap();
4147
4148 cfg.aliased_addresses.push(AliasedAddress {
4150 original: Hex::decode("0xcd8962dad278d8b50fa0f9eb0186bfa4cbdecc6d59377214c88d0286a0ac9562").unwrap().try_into().unwrap(),
4151 aliased,
4152 allowed_tx_digests: vec![
4153 Base58::decode("B2eGLFoMHgj93Ni8dAJBfqGzo8EWSTLBesZzhEpTPA4").unwrap().try_into().unwrap(),
4154 ],
4155 });
4156
4157 cfg.aliased_addresses.push(AliasedAddress {
4158 original: Hex::decode("0xe28b50cef1d633ea43d3296a3f6b67ff0312a5f1a99f0af753c85b8b5de8ff06").unwrap().try_into().unwrap(),
4159 aliased,
4160 allowed_tx_digests: vec![
4161 Base58::decode("J4QqSAgp7VrQtQpMy5wDX4QGsCSEZu3U5KuDAkbESAge").unwrap().try_into().unwrap(),
4162 ],
4163 });
4164 }
4165
4166 if chain != Chain::Mainnet {
4169 cfg.feature_flags.resolve_type_input_ids_to_defining_id = true;
4170 cfg.transfer_party_transfer_internal_cost_base = Some(52);
4171
4172 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
4174 cfg.consensus_commit_rate_estimation_window_size = Some(10);
4175 cfg.feature_flags.per_object_congestion_control_mode =
4176 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4177 ExecutionTimeEstimateParams {
4178 target_utilization: 30,
4179 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4181 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4183 stored_observations_limit: u64::MAX,
4184 stake_weighted_median_threshold: 0,
4185 default_none_duration_for_new_keys: false,
4186 observations_chunk_size: None,
4187 },
4188 );
4189
4190 cfg.feature_flags.consensus_batched_block_sync = true;
4192
4193 cfg.feature_flags.enable_nitro_attestation_upgraded_parsing = true;
4196 cfg.feature_flags.enable_nitro_attestation = true;
4197 }
4198 }
4199 84 => {
4200 if chain == Chain::Mainnet {
4201 cfg.feature_flags.resolve_type_input_ids_to_defining_id = true;
4202 cfg.transfer_party_transfer_internal_cost_base = Some(52);
4203
4204 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
4206 cfg.consensus_commit_rate_estimation_window_size = Some(10);
4207 cfg.feature_flags.per_object_congestion_control_mode =
4208 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4209 ExecutionTimeEstimateParams {
4210 target_utilization: 30,
4211 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4213 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4215 stored_observations_limit: u64::MAX,
4216 stake_weighted_median_threshold: 0,
4217 default_none_duration_for_new_keys: false,
4218 observations_chunk_size: None,
4219 },
4220 );
4221
4222 cfg.feature_flags.consensus_batched_block_sync = true;
4224
4225 cfg.feature_flags.enable_nitro_attestation_upgraded_parsing = true;
4228 cfg.feature_flags.enable_nitro_attestation = true;
4229 }
4230
4231 cfg.feature_flags.per_object_congestion_control_mode =
4233 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4234 ExecutionTimeEstimateParams {
4235 target_utilization: 30,
4236 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4238 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4240 stored_observations_limit: 20,
4241 stake_weighted_median_threshold: 0,
4242 default_none_duration_for_new_keys: false,
4243 observations_chunk_size: None,
4244 },
4245 );
4246 cfg.feature_flags.allow_unbounded_system_objects = true;
4247 }
4248 85 => {
4249 if chain != Chain::Mainnet && chain != Chain::Testnet {
4250 cfg.feature_flags.enable_party_transfer = true;
4251 }
4252
4253 cfg.feature_flags
4254 .record_consensus_determined_version_assignments_in_prologue_v2 = true;
4255 cfg.feature_flags.disallow_self_identifier = true;
4256 cfg.feature_flags.per_object_congestion_control_mode =
4257 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4258 ExecutionTimeEstimateParams {
4259 target_utilization: 50,
4260 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4262 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4264 stored_observations_limit: 20,
4265 stake_weighted_median_threshold: 0,
4266 default_none_duration_for_new_keys: false,
4267 observations_chunk_size: None,
4268 },
4269 );
4270 }
4271 86 => {
4272 cfg.feature_flags.type_tags_in_object_runtime = true;
4273 cfg.max_move_enum_variants = Some(move_core_types::VARIANT_COUNT_MAX);
4274
4275 cfg.feature_flags.per_object_congestion_control_mode =
4277 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4278 ExecutionTimeEstimateParams {
4279 target_utilization: 50,
4280 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4282 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4284 stored_observations_limit: 20,
4285 stake_weighted_median_threshold: 3334,
4286 default_none_duration_for_new_keys: false,
4287 observations_chunk_size: None,
4288 },
4289 );
4290 if chain != Chain::Mainnet {
4292 cfg.feature_flags.enable_party_transfer = true;
4293 }
4294 }
4295 87 => {
4296 if chain == Chain::Mainnet {
4297 cfg.feature_flags.record_time_estimate_processed = true;
4298 }
4299 cfg.feature_flags.better_adapter_type_resolution_errors = true;
4300 }
4301 88 => {
4302 cfg.feature_flags.record_time_estimate_processed = true;
4303 cfg.tx_context_rgp_cost_base = Some(30);
4304 cfg.feature_flags
4305 .ignore_execution_time_observations_after_certs_closed = true;
4306
4307 cfg.feature_flags.per_object_congestion_control_mode =
4310 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4311 ExecutionTimeEstimateParams {
4312 target_utilization: 50,
4313 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4315 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4317 stored_observations_limit: 20,
4318 stake_weighted_median_threshold: 3334,
4319 default_none_duration_for_new_keys: true,
4320 observations_chunk_size: None,
4321 },
4322 );
4323 }
4324 89 => {
4325 cfg.feature_flags.dependency_linkage_error = true;
4326 cfg.feature_flags.additional_multisig_checks = true;
4327 }
4328 90 => {
4329 cfg.max_gas_price_rgp_factor_for_aborted_transactions = Some(100);
4331 cfg.feature_flags.debug_fatal_on_move_invariant_violation = true;
4332 cfg.feature_flags.additional_consensus_digest_indirect_state = true;
4333 cfg.feature_flags.accept_passkey_in_multisig = true;
4334 cfg.feature_flags.passkey_auth = true;
4335 cfg.feature_flags.check_for_init_during_upgrade = true;
4336
4337 if chain != Chain::Mainnet {
4339 cfg.feature_flags.mysticeti_fastpath = true;
4340 }
4341 }
4342 91 => {
4343 cfg.feature_flags.per_command_shared_object_transfer_rules = true;
4344 }
4345 92 => {
4346 cfg.feature_flags.per_command_shared_object_transfer_rules = false;
4347 }
4348 93 => {
4349 cfg.feature_flags
4350 .consensus_checkpoint_signature_key_includes_digest = true;
4351 }
4352 94 => {
4353 cfg.feature_flags.per_object_congestion_control_mode =
4355 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4356 ExecutionTimeEstimateParams {
4357 target_utilization: 50,
4358 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4360 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4362 stored_observations_limit: 18,
4363 stake_weighted_median_threshold: 3334,
4364 default_none_duration_for_new_keys: true,
4365 observations_chunk_size: None,
4366 },
4367 );
4368
4369 cfg.feature_flags.enable_party_transfer = true;
4371 }
4372 95 => {
4373 cfg.type_name_id_base_cost = Some(52);
4374
4375 cfg.max_transactions_per_checkpoint = Some(20_000);
4377 }
4378 96 => {
4379 if chain != Chain::Mainnet && chain != Chain::Testnet {
4381 cfg.feature_flags
4382 .include_checkpoint_artifacts_digest_in_summary = true;
4383 }
4384 cfg.feature_flags.correct_gas_payment_limit_check = true;
4385 cfg.feature_flags.authority_capabilities_v2 = true;
4386 cfg.feature_flags.use_mfp_txns_in_load_initial_object_debts = true;
4387 cfg.feature_flags.cancel_for_failed_dkg_early = true;
4388 cfg.feature_flags.enable_coin_registry = true;
4389
4390 cfg.feature_flags.mysticeti_fastpath = true;
4392 }
4393 97 => {
4394 cfg.feature_flags.additional_borrow_checks = true;
4395 }
4396 98 => {
4397 cfg.event_emit_auth_stream_cost = Some(52);
4398 cfg.feature_flags.better_loader_errors = true;
4399 cfg.feature_flags.generate_df_type_layouts = true;
4400 }
4401 99 => {
4402 cfg.feature_flags.use_new_commit_handler = true;
4403 }
4404 100 => {
4405 cfg.feature_flags.private_generics_verifier_v2 = true;
4406 }
4407 101 => {
4408 cfg.feature_flags.create_root_accumulator_object = true;
4409 cfg.max_updates_per_settlement_txn = Some(100);
4410 if chain != Chain::Mainnet {
4411 cfg.feature_flags.enable_poseidon = true;
4412 }
4413 }
4414 102 => {
4415 cfg.feature_flags.per_object_congestion_control_mode =
4419 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4420 ExecutionTimeEstimateParams {
4421 target_utilization: 50,
4422 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4424 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4426 stored_observations_limit: 180,
4427 stake_weighted_median_threshold: 3334,
4428 default_none_duration_for_new_keys: true,
4429 observations_chunk_size: Some(18),
4430 },
4431 );
4432 cfg.feature_flags.deprecate_global_storage_ops = true;
4433 }
4434 103 => {}
4435 104 => {
4436 cfg.translation_per_command_base_charge = Some(1);
4437 cfg.translation_per_input_base_charge = Some(1);
4438 cfg.translation_pure_input_per_byte_charge = Some(1);
4439 cfg.translation_per_type_node_charge = Some(1);
4440 cfg.translation_per_reference_node_charge = Some(1);
4441 cfg.translation_per_linkage_entry_charge = Some(10);
4442 cfg.gas_model_version = Some(11);
4443 cfg.feature_flags.abstract_size_in_object_runtime = true;
4444 cfg.feature_flags.object_runtime_charge_cache_load_gas = true;
4445 cfg.dynamic_field_hash_type_and_key_cost_base = Some(52);
4446 cfg.dynamic_field_add_child_object_cost_base = Some(52);
4447 cfg.dynamic_field_add_child_object_value_cost_per_byte = Some(1);
4448 cfg.dynamic_field_borrow_child_object_cost_base = Some(52);
4449 cfg.dynamic_field_borrow_child_object_child_ref_cost_per_byte = Some(1);
4450 cfg.dynamic_field_remove_child_object_cost_base = Some(52);
4451 cfg.dynamic_field_remove_child_object_child_cost_per_byte = Some(1);
4452 cfg.dynamic_field_has_child_object_cost_base = Some(52);
4453 cfg.dynamic_field_has_child_object_with_ty_cost_base = Some(52);
4454 cfg.feature_flags.enable_ptb_execution_v2 = true;
4455
4456 cfg.poseidon_bn254_cost_base = Some(260);
4457
4458 cfg.feature_flags.consensus_skip_gced_accept_votes = true;
4459
4460 if chain != Chain::Mainnet {
4461 cfg.feature_flags
4462 .enable_nitro_attestation_all_nonzero_pcrs_parsing = true;
4463 }
4464
4465 cfg.feature_flags
4466 .include_cancelled_randomness_txns_in_prologue = true;
4467 }
4468 105 => {
4469 cfg.feature_flags.enable_multi_epoch_transaction_expiration = true;
4470 cfg.feature_flags.disable_preconsensus_locking = true;
4471
4472 if chain != Chain::Mainnet {
4473 cfg.feature_flags
4474 .enable_nitro_attestation_always_include_required_pcrs_parsing = true;
4475 }
4476 }
4477 106 => {
4478 cfg.accumulator_object_storage_cost = Some(7600);
4480
4481 if chain != Chain::Mainnet && chain != Chain::Testnet {
4482 cfg.feature_flags.enable_accumulators = true;
4483 cfg.feature_flags.enable_address_balance_gas_payments = true;
4484 cfg.feature_flags.enable_authenticated_event_streams = true;
4485 cfg.feature_flags.enable_object_funds_withdraw = true;
4486 }
4487 }
4488 107 => {
4489 cfg.feature_flags
4490 .consensus_skip_gced_blocks_in_direct_finalization = true;
4491
4492 if in_integration_test() {
4494 cfg.consensus_gc_depth = Some(6);
4495 cfg.consensus_max_num_transactions_in_block = Some(8);
4496 }
4497 }
4498 108 => {
4499 cfg.feature_flags.gas_rounding_halve_digits = true;
4500 cfg.feature_flags.flexible_tx_context_positions = true;
4501 cfg.feature_flags.disable_entry_point_signature_check = true;
4502
4503 if chain != Chain::Mainnet {
4504 cfg.feature_flags.address_aliases = true;
4505
4506 cfg.feature_flags.enable_accumulators = true;
4507 cfg.feature_flags.enable_address_balance_gas_payments = true;
4508 }
4509
4510 cfg.feature_flags.enable_poseidon = true;
4511 }
4512 109 => {
4513 cfg.binary_variant_handles = Some(1024);
4514 cfg.binary_variant_instantiation_handles = Some(1024);
4515 cfg.feature_flags.restrict_hot_or_not_entry_functions = true;
4516 }
4517 110 => {
4518 cfg.feature_flags
4519 .enable_nitro_attestation_all_nonzero_pcrs_parsing = true;
4520 cfg.feature_flags
4521 .enable_nitro_attestation_always_include_required_pcrs_parsing = true;
4522 if chain != Chain::Mainnet && chain != Chain::Testnet {
4523 cfg.feature_flags.split_checkpoints_in_consensus_handler = true;
4524 }
4525 cfg.feature_flags.validate_zklogin_public_identifier = true;
4526 cfg.feature_flags.fix_checkpoint_signature_mapping = true;
4527 cfg.feature_flags
4528 .consensus_always_accept_system_transactions = true;
4529 if chain != Chain::Mainnet {
4530 cfg.feature_flags.enable_object_funds_withdraw = true;
4531 }
4532 }
4533 111 => {
4534 cfg.feature_flags.validator_metadata_verify_v2 = true;
4535 }
4536 112 => {
4537 cfg.group_ops_ristretto_decode_scalar_cost = Some(7);
4538 cfg.group_ops_ristretto_decode_point_cost = Some(200);
4539 cfg.group_ops_ristretto_scalar_add_cost = Some(10);
4540 cfg.group_ops_ristretto_point_add_cost = Some(500);
4541 cfg.group_ops_ristretto_scalar_sub_cost = Some(10);
4542 cfg.group_ops_ristretto_point_sub_cost = Some(500);
4543 cfg.group_ops_ristretto_scalar_mul_cost = Some(11);
4544 cfg.group_ops_ristretto_point_mul_cost = Some(1200);
4545 cfg.group_ops_ristretto_scalar_div_cost = Some(151);
4546 cfg.group_ops_ristretto_point_div_cost = Some(2500);
4547
4548 if chain != Chain::Mainnet && chain != Chain::Testnet {
4549 cfg.feature_flags.enable_ristretto255_group_ops = true;
4550 }
4551 }
4552 113 => {
4553 cfg.feature_flags.address_balance_gas_check_rgp_at_signing = true;
4554 if chain != Chain::Mainnet && chain != Chain::Testnet {
4555 cfg.feature_flags.defer_unpaid_amplification = true;
4556 }
4557 }
4558 114 => {
4559 cfg.feature_flags.randomize_checkpoint_tx_limit_in_tests = true;
4560 cfg.feature_flags.address_balance_gas_reject_gas_coin_arg = true;
4561 if chain != Chain::Mainnet {
4562 cfg.feature_flags.split_checkpoints_in_consensus_handler = true;
4563 cfg.feature_flags.enable_authenticated_event_streams = true;
4564 cfg.feature_flags
4565 .include_checkpoint_artifacts_digest_in_summary = true;
4566 }
4567 }
4568 115 => {
4569 cfg.feature_flags.normalize_depth_formula = true;
4570 }
4571 116 => {
4572 cfg.feature_flags.gasless_transaction_drop_safety = true;
4573 cfg.feature_flags.address_aliases = true;
4574 cfg.feature_flags.relax_valid_during_for_owned_inputs = true;
4575 cfg.feature_flags.defer_unpaid_amplification = false;
4577 cfg.feature_flags.enable_display_registry = true;
4578 }
4579 117 => {}
4580 118 => {
4581 cfg.feature_flags.use_coin_party_owner = true;
4582 }
4583 119 => {
4584 cfg.execution_version = Some(4);
4586 cfg.feature_flags.address_balance_gas_reject_gas_coin_arg = false;
4587 cfg.feature_flags.merge_randomness_into_checkpoint = true;
4588 if chain != Chain::Mainnet {
4589 cfg.feature_flags.enable_gasless = true;
4590 cfg.gasless_max_computation_units = Some(50_000);
4591 cfg.gasless_allowed_token_types = Some(vec![]);
4592 cfg.feature_flags.enable_coin_reservation_obj_refs = true;
4593 cfg.feature_flags
4594 .convert_withdrawal_compatibility_ptb_arguments = true;
4595 }
4596 cfg.gasless_max_unused_inputs = Some(1);
4597 cfg.gasless_max_pure_input_bytes = Some(32);
4598 if chain == Chain::Testnet {
4599 cfg.gasless_allowed_token_types = Some(vec![(TESTNET_USDC.to_string(), 0)]);
4600 }
4601 cfg.transfer_receive_object_cost_per_byte = Some(1);
4602 cfg.transfer_receive_object_type_cost_per_byte = Some(2);
4603 }
4604 120 => {
4605 cfg.feature_flags.disallow_jump_orphans = true;
4606 }
4607 121 => {
4608 if chain != Chain::Mainnet {
4610 cfg.feature_flags.defer_unpaid_amplification = true;
4611 cfg.gasless_max_tps = Some(50);
4612 }
4613 cfg.feature_flags
4614 .early_return_receive_object_mismatched_type = true;
4615 }
4616 122 => {
4617 cfg.feature_flags.defer_unpaid_amplification = true;
4619 cfg.verify_bulletproofs_ristretto255_base_cost = Some(30000);
4621 cfg.verify_bulletproofs_ristretto255_cost_per_bit_and_commitment = Some(6500);
4622 if chain != Chain::Mainnet && chain != Chain::Testnet {
4623 cfg.feature_flags.enable_verify_bulletproofs_ristretto255 = true;
4624 }
4625 cfg.feature_flags.gasless_verify_remaining_balance = true;
4626 cfg.include_special_package_amendments = match chain {
4627 Chain::Mainnet => Some(MAINNET_LINKAGE_AMENDMENTS.clone()),
4628 Chain::Testnet => Some(TESTNET_LINKAGE_AMENDMENTS.clone()),
4629 Chain::Unknown => None,
4630 };
4631 cfg.gasless_max_tx_size_bytes = Some(16 * 1024);
4632 cfg.gasless_max_tps = Some(300);
4633 cfg.gasless_max_computation_units = Some(5_000);
4634 }
4635 123 => {
4636 cfg.gas_model_version = Some(13);
4637 }
4638 124 => {
4639 if chain != Chain::Mainnet && chain != Chain::Testnet {
4640 cfg.feature_flags.timestamp_based_epoch_close = true;
4641 }
4642 cfg.gas_model_version = Some(14);
4643 cfg.feature_flags.limit_groth16_pvk_inputs = true;
4644
4645 cfg.feature_flags.enable_accumulators = true;
4651 cfg.feature_flags.enable_address_balance_gas_payments = true;
4652 cfg.feature_flags.enable_authenticated_event_streams = true;
4653 cfg.feature_flags.enable_coin_reservation_obj_refs = true;
4654 cfg.feature_flags.enable_object_funds_withdraw = true;
4655 cfg.feature_flags
4656 .convert_withdrawal_compatibility_ptb_arguments = true;
4657 cfg.feature_flags.split_checkpoints_in_consensus_handler = true;
4658 cfg.feature_flags
4659 .include_checkpoint_artifacts_digest_in_summary = true;
4660 cfg.feature_flags.enable_gasless = true;
4661
4662 if chain == Chain::Mainnet {
4667 cfg.gasless_allowed_token_types = Some(vec![
4668 (MAINNET_USDC.to_string(), 10_000),
4669 (MAINNET_USDSUI.to_string(), 10_000),
4670 (MAINNET_SUI_USDE.to_string(), 10_000),
4671 (MAINNET_USDY.to_string(), 10_000),
4672 (MAINNET_FDUSD.to_string(), 10_000),
4673 (MAINNET_AUSD.to_string(), 10_000),
4674 (MAINNET_USDB.to_string(), 10_000),
4675 ]);
4676 }
4677 }
4678 125 => {
4679 cfg.feature_flags.granular_post_execution_checks = true;
4680 if chain != Chain::Mainnet {
4681 cfg.feature_flags.timestamp_based_epoch_close = true;
4682 }
4683 }
4684 126 => {
4685 cfg.feature_flags.early_exit_on_iffw = true;
4686 }
4687 127 => {
4688 cfg.feature_flags.always_advance_dkg_to_resolution = true;
4689
4690 cfg.verify_bulletproofs_ristretto255_base_cost = Some(23866);
4691 cfg.verify_bulletproofs_ristretto255_cost_per_bit_and_commitment = Some(1324);
4692 cfg.group_ops_ristretto_decode_scalar_cost = Some(5);
4693 cfg.group_ops_ristretto_decode_point_cost = Some(216);
4694 cfg.group_ops_ristretto_scalar_add_cost = Some(2);
4695 cfg.group_ops_ristretto_point_add_cost = Some(8);
4696 cfg.group_ops_ristretto_scalar_sub_cost = Some(2);
4697 cfg.group_ops_ristretto_point_sub_cost = Some(8);
4698 cfg.group_ops_ristretto_scalar_mul_cost = Some(5);
4699 cfg.group_ops_ristretto_point_mul_cost = Some(1763);
4700 cfg.group_ops_ristretto_scalar_div_cost = Some(557);
4701 cfg.group_ops_ristretto_point_div_cost = Some(2244);
4702
4703 if chain != Chain::Mainnet {
4704 cfg.feature_flags.enable_ristretto255_group_ops = true;
4705 cfg.feature_flags.enable_verify_bulletproofs_ristretto255 = true;
4706 }
4707
4708 cfg.feature_flags.timestamp_based_epoch_close = true;
4709 }
4710 128 => {
4711 cfg.max_generic_instantiation_type_nodes_per_function = Some(10_000);
4712 cfg.max_generic_instantiation_type_nodes_per_module = Some(500_000);
4713 cfg.binary_enum_defs = Some(200);
4714 cfg.binary_enum_def_instantiations = Some(100);
4715 }
4716 129 => {
4717 cfg.feature_flags.enable_unified_linkage = true;
4718 }
4719 130 => {
4720 cfg.feature_flags.record_net_unsettled_object_withdraws = true;
4721 cfg.feature_flags.enable_init_on_upgrade = true;
4722 cfg.epoch_close_deadline_ms = Some(120_000);
4723 cfg.scratch_add_cost_base = Some(13);
4724 cfg.scratch_read_cost_base = Some(13);
4725 cfg.scratch_read_value_cost = Some(1);
4726 cfg.scratch_remove_cost_base = Some(13);
4727 cfg.scratch_exists_cost_base = Some(13);
4728 cfg.scratch_exists_with_type_cost_base = Some(13);
4729 cfg.scratch_exists_with_type_type_cost = Some(1);
4730 let max_commands = cfg.max_programmable_tx_commands() as u64;
4731 cfg.max_scratch_pad_size = Some(16 * max_commands);
4732 if chain != Chain::Mainnet && chain != Chain::Testnet {
4734 cfg.feature_flags.zklogin_circuit_mode = 1;
4735 }
4736 }
4737 131 => {
4738 cfg.feature_flags.share_transaction_deny_config_in_consensus = true;
4739 cfg.feature_flags.framework_tx_context_mut_restrictions = true;
4740 }
4741 132 => {
4742 if chain != Chain::Mainnet && chain != Chain::Testnet {
4743 cfg.feature_flags.defer_owned_object_double_spend = true;
4744 cfg.feature_flags.create_forwarding_address_registry = true;
4745 }
4746 cfg.object_record_new_uid_from_hash_cost_base = Some(1);
4747 cfg.feature_flags
4748 .enable_order_independent_upgrade_init_linkage = true;
4749 }
4750 133 => {
4751 cfg.feature_flags
4752 .include_function_signatures_in_instantiation_limits = true;
4753 cfg.max_accumulator_type_nodes = Some(16);
4754 }
4755 134 => {
4756 if chain != Chain::Mainnet {
4763 cfg.package_original_package_id_impl_cost_base = Some(52);
4764 let package_read_cost_per_byte = cfg.obj_access_cost_read_per_byte();
4765 cfg.package_original_package_id_impl_cost_per_byte =
4766 Some(package_read_cost_per_byte);
4767
4768 cfg.consensus_max_transactions_in_block_bytes = Some(288 * 1024);
4769 cfg.consensus_max_num_transactions_in_block = Some(128);
4770 }
4771
4772 if chain == Chain::Mainnet {
4773 cfg.feature_flags.defer_unpaid_amplification = false;
4774 }
4775 }
4776 135 => {
4777 cfg.package_original_package_id_impl_cost_base = Some(52);
4780 let package_read_cost_per_byte = cfg.obj_access_cost_read_per_byte();
4781 cfg.package_original_package_id_impl_cost_per_byte =
4782 Some(package_read_cost_per_byte);
4783
4784 cfg.consensus_max_transactions_in_block_bytes = Some(288 * 1024);
4785 cfg.consensus_max_num_transactions_in_block = Some(128);
4786
4787 cfg.feature_flags.defer_unpaid_amplification = false;
4788 }
4789 136 => {
4790 cfg.feature_flags.ptb_tx_context_restrictions = true;
4791
4792 cfg.translation_per_live_reference_charge = Some(1);
4793 cfg.max_ptb_live_references = Some(64);
4794 cfg.max_ptb_returned_references = Some(16);
4795 cfg.max_ptb_total_returned_references = Some(256);
4796
4797 if chain != Chain::Mainnet && chain != Chain::Testnet {
4798 cfg.feature_flags.allowed_proposers = true;
4799 }
4800 cfg.feature_flags.harden_linkage_consistency = true;
4801
4802 cfg.package_arena_size_in_bytes = Some(10_000_000);
4803 }
4804 137 => {
4805 cfg.verify_bulletproofs_ristretto255_cost_per_bit_and_commitment = Some(621);
4806 cfg.max_bulletproofs_total_bits = Some(1024);
4807
4808 if chain != Chain::Mainnet {
4809 cfg.feature_flags.enable_allowances = true;
4810 }
4811 cfg.feature_flags.fix_ptb_generated_reads = true;
4812 cfg.feature_flags.charge_ld_const_abstract_size = true;
4813 if chain != Chain::Mainnet && chain != Chain::Testnet {
4814 cfg.feature_flags.check_object_funds_withdraw_in_execution = true;
4815 }
4816 cfg.reserve_object_funds_for_withdrawal_cost_base = Some(52);
4817 cfg.reserve_object_funds_for_withdrawal_cold_read_cost = Some(184);
4820
4821 cfg.feature_flags.allowed_proposers = true;
4822
4823 cfg.feature_flags.validate_ptb_argument_indices = true;
4824 cfg.feature_flags.memory_safety_invariant_check_v2 = true;
4825 }
4826 138 => {
4827 cfg.gas_model_version = Some(15);
4828 cfg.feature_flags.enable_allowances = true;
4829 if chain != Chain::Mainnet {
4830 cfg.feature_flags.check_object_funds_withdraw_in_execution = true;
4831 cfg.feature_flags.disable_effects_tx_dependencies = true;
4832 }
4833 cfg.feature_flags.merge_colliding_deferrals = true;
4834 if chain == Chain::Mainnet {
4836 cfg.storage_rebate_rate = Some(9999);
4837 }
4838 }
4839 139 => {
4840 if chain != Chain::Mainnet && chain != Chain::Testnet {
4841 cfg.feature_flags.enable_forwarding_addresses = true;
4842 cfg.feature_flags.mldsa65_auth = true;
4843 }
4844 cfg.storage_rebate_rate = Some(9999);
4845 if chain != Chain::Mainnet {
4846 cfg.feature_flags.allow_dkg_completion_after_timeout = true;
4847 }
4848 cfg.obj_access_cost_read_per_package_kb = Some(154);
4850 }
4851 _ => panic!("unsupported version {:?}", version),
4862 }
4863 }
4864
4865 cfg
4866 }
4867
4868 pub fn apply_seeded_test_overrides(&mut self, seed: &[u8; 32]) {
4869 if !self.feature_flags.randomize_checkpoint_tx_limit_in_tests
4870 || !self.feature_flags.split_checkpoints_in_consensus_handler
4871 {
4872 return;
4873 }
4874
4875 if !mysten_common::in_test_configuration() {
4876 return;
4877 }
4878
4879 use rand::{Rng, SeedableRng, rngs::StdRng};
4880 let mut rng = StdRng::from_seed(*seed);
4881 let max_txns = rng.gen_range(10..=100u64);
4882 info!("seeded test override: max_transactions_per_checkpoint = {max_txns}");
4883 self.max_transactions_per_checkpoint = Some(max_txns);
4884 }
4885
4886 pub fn verifier_config(&self, signing_limits: Option<(usize, usize, usize)>) -> VerifierConfig {
4892 let (
4893 max_back_edges_per_function,
4894 max_back_edges_per_module,
4895 sanity_check_with_regex_reference_safety,
4896 ) = if let Some((
4897 max_back_edges_per_function,
4898 max_back_edges_per_module,
4899 sanity_check_with_regex_reference_safety,
4900 )) = signing_limits
4901 {
4902 (
4903 Some(max_back_edges_per_function),
4904 Some(max_back_edges_per_module),
4905 Some(sanity_check_with_regex_reference_safety),
4906 )
4907 } else {
4908 (None, None, None)
4909 };
4910
4911 let additional_borrow_checks = if signing_limits.is_some() {
4912 true
4914 } else {
4915 self.additional_borrow_checks()
4916 };
4917 let deprecate_global_storage_ops = if signing_limits.is_some() {
4918 true
4920 } else {
4921 self.deprecate_global_storage_ops()
4922 };
4923
4924 VerifierConfig {
4925 max_loop_depth: Some(self.max_loop_depth() as usize),
4926 max_generic_instantiation_length: Some(self.max_generic_instantiation_length() as usize),
4927 max_function_parameters: Some(self.max_function_parameters() as usize),
4928 max_basic_blocks: Some(self.max_basic_blocks() as usize),
4929 max_value_stack_size: self.max_value_stack_size() as usize,
4930 max_type_nodes: Some(self.max_type_nodes() as usize),
4931 max_generic_instantiation_type_nodes_per_function: self
4932 .max_generic_instantiation_type_nodes_per_function_as_option()
4933 .map(|v| v as usize),
4934 max_generic_instantiation_type_nodes_per_module: self
4935 .max_generic_instantiation_type_nodes_per_module_as_option()
4936 .map(|v| v as usize),
4937 include_function_signatures_in_instantiation_limits: self
4938 .include_function_signatures_in_instantiation_limits(),
4939 max_push_size: Some(self.max_push_size() as usize),
4940 max_dependency_depth: Some(self.max_dependency_depth() as usize),
4941 max_fields_in_struct: Some(self.max_fields_in_struct() as usize),
4942 max_function_definitions: Some(self.max_function_definitions() as usize),
4943 max_data_definitions: Some(self.max_struct_definitions() as usize),
4944 max_constant_vector_len: Some(self.max_move_vector_len()),
4945 max_back_edges_per_function,
4946 max_back_edges_per_module,
4947 max_basic_blocks_in_script: None,
4948 max_identifier_len: self.max_move_identifier_len_as_option(), disallow_self_identifier: self.feature_flags.disallow_self_identifier,
4950 allow_receiving_object_id: self.allow_receiving_object_id(),
4951 reject_mutable_random_on_entry_functions: self
4952 .reject_mutable_random_on_entry_functions(),
4953 bytecode_version: self.move_binary_format_version(),
4954 max_variants_in_enum: self.max_move_enum_variants_as_option(),
4955 additional_borrow_checks,
4956 better_loader_errors: self.better_loader_errors(),
4957 private_generics_verifier_v2: self.private_generics_verifier_v2(),
4958 sanity_check_with_regex_reference_safety: sanity_check_with_regex_reference_safety
4959 .map(|limit| limit as u128),
4960 deprecate_global_storage_ops,
4961 disable_entry_point_signature_check: self.disable_entry_point_signature_check(),
4962 switch_to_regex_reference_safety: false,
4963 framework_tx_context_mut_restrictions: self.framework_tx_context_mut_restrictions(),
4964 disallow_jump_orphans: self.disallow_jump_orphans(),
4965 }
4966 }
4967
4968 pub fn binary_config(
4969 &self,
4970 override_deprecate_global_storage_ops_during_deserialization: Option<bool>,
4971 ) -> BinaryConfig {
4972 let deprecate_global_storage_ops =
4973 override_deprecate_global_storage_ops_during_deserialization
4974 .unwrap_or_else(|| self.deprecate_global_storage_ops());
4975 BinaryConfig::new(
4976 self.move_binary_format_version(),
4977 self.min_move_binary_format_version_as_option()
4978 .unwrap_or(VERSION_1),
4979 self.no_extraneous_module_bytes(),
4980 deprecate_global_storage_ops,
4981 TableConfig {
4982 module_handles: self.binary_module_handles_as_option().unwrap_or(u16::MAX),
4983 datatype_handles: self.binary_struct_handles_as_option().unwrap_or(u16::MAX),
4984 function_handles: self.binary_function_handles_as_option().unwrap_or(u16::MAX),
4985 function_instantiations: self
4986 .binary_function_instantiations_as_option()
4987 .unwrap_or(u16::MAX),
4988 signatures: self.binary_signatures_as_option().unwrap_or(u16::MAX),
4989 constant_pool: self.binary_constant_pool_as_option().unwrap_or(u16::MAX),
4990 identifiers: self.binary_identifiers_as_option().unwrap_or(u16::MAX),
4991 address_identifiers: self
4992 .binary_address_identifiers_as_option()
4993 .unwrap_or(u16::MAX),
4994 struct_defs: self.binary_struct_defs_as_option().unwrap_or(u16::MAX),
4995 struct_def_instantiations: self
4996 .binary_struct_def_instantiations_as_option()
4997 .unwrap_or(u16::MAX),
4998 function_defs: self.binary_function_defs_as_option().unwrap_or(u16::MAX),
4999 field_handles: self.binary_field_handles_as_option().unwrap_or(u16::MAX),
5000 field_instantiations: self
5001 .binary_field_instantiations_as_option()
5002 .unwrap_or(u16::MAX),
5003 friend_decls: self.binary_friend_decls_as_option().unwrap_or(u16::MAX),
5004 enum_defs: self.binary_enum_defs_as_option().unwrap_or(u16::MAX),
5005 enum_def_instantiations: self
5006 .binary_enum_def_instantiations_as_option()
5007 .unwrap_or(u16::MAX),
5008 variant_handles: self.binary_variant_handles_as_option().unwrap_or(u16::MAX),
5009 variant_instantiation_handles: self
5010 .binary_variant_instantiation_handles_as_option()
5011 .unwrap_or(u16::MAX),
5012 },
5013 )
5014 }
5015
5016 pub fn apply_overrides_for_testing(
5020 override_fn: impl Fn(ProtocolVersion, Self) -> Self + Send + Sync + 'static,
5021 ) -> OverrideGuard {
5022 let mut cur = CONFIG_OVERRIDE.lock().unwrap();
5023 assert!(cur.is_none(), "config override already present");
5024 *cur = Some(Box::new(override_fn));
5025 OverrideGuard
5026 }
5027
5028 fn apply_config_override(version: ProtocolVersion, mut ret: Self) -> Self {
5029 if let Some(override_fn) = CONFIG_OVERRIDE.lock().unwrap().as_ref() {
5030 warn!(
5031 "overriding ProtocolConfig settings with custom settings (you should not see this log outside of tests)"
5032 );
5033 ret = override_fn(version, ret);
5034 }
5035 ret
5036 }
5037}
5038
5039impl ProtocolConfig {
5043 pub fn set_execution_version_for_testing(&mut self, val: u64) {
5047 let current = self.execution_version.unwrap_or(0);
5048 assert!(
5049 val >= current,
5050 "cannot downgrade execution_version from {current} to {val}: running an old \
5051 executor against a newer protocol config/framework is unsupported. To test \
5052 frozen executor behavior, start from the last protocol version of that executor \
5053 instead, so genesis loads the matching framework snapshot (see \
5054 test_address_balance_gas_v3_accumulator_sign)."
5055 );
5056 self.execution_version = Some(val);
5057 }
5058
5059 pub fn set_zklogin_circuit_mode_for_testing(&mut self, val: u64) {
5062 self.feature_flags.zklogin_circuit_mode = val
5063 }
5064
5065 pub fn set_per_object_congestion_control_mode_for_testing(
5066 &mut self,
5067 val: PerObjectCongestionControlMode,
5068 ) {
5069 self.feature_flags.per_object_congestion_control_mode = val;
5070 }
5071
5072 pub fn set_consensus_choice_for_testing(&mut self, val: ConsensusChoice) {
5073 self.feature_flags.consensus_choice = val;
5074 }
5075
5076 pub fn set_consensus_network_for_testing(&mut self, val: ConsensusNetwork) {
5077 self.feature_flags.consensus_network = val;
5078 }
5079
5080 pub fn set_zklogin_max_epoch_upper_bound_delta_for_testing(&mut self, val: Option<u64>) {
5081 self.feature_flags.zklogin_max_epoch_upper_bound_delta = val
5082 }
5083
5084 pub fn set_mysticeti_num_leaders_per_round_for_testing(&mut self, val: Option<usize>) {
5085 self.feature_flags.mysticeti_num_leaders_per_round = val;
5086 }
5087
5088 pub fn disable_accumulators_for_testing(&mut self) {
5089 self.feature_flags.enable_accumulators = false;
5090 self.feature_flags.enable_address_balance_gas_payments = false;
5091 }
5092
5093 pub fn enable_coin_reservation_for_testing(&mut self) {
5094 self.feature_flags.enable_coin_reservation_obj_refs = true;
5095 self.feature_flags
5096 .convert_withdrawal_compatibility_ptb_arguments = true;
5097 self.execution_version = Some(self.execution_version.map_or(4, |v| v.max(4)));
5100 }
5101
5102 pub fn disable_coin_reservation_for_testing(&mut self) {
5103 self.feature_flags.enable_coin_reservation_obj_refs = false;
5104 self.feature_flags
5105 .convert_withdrawal_compatibility_ptb_arguments = false;
5106 }
5107
5108 pub fn enable_address_balance_gas_payments_for_testing(&mut self) {
5109 self.feature_flags.enable_accumulators = true;
5110 self.feature_flags.allow_private_accumulator_entrypoints = true;
5111 self.feature_flags.enable_address_balance_gas_payments = true;
5112 self.feature_flags.address_balance_gas_check_rgp_at_signing = true;
5113 self.feature_flags.address_balance_gas_reject_gas_coin_arg = false;
5114 self.execution_version = Some(self.execution_version.map_or(4, |v| v.max(4)))
5115 }
5116
5117 pub fn enable_gasless_for_testing(&mut self) {
5118 self.enable_address_balance_gas_payments_for_testing();
5119 self.feature_flags.enable_gasless = true;
5120 self.feature_flags.gasless_verify_remaining_balance = true;
5121 self.gasless_max_computation_units = Some(5_000);
5122 self.gasless_allowed_token_types = Some(vec![]);
5123 self.gasless_max_tps = Some(1000);
5124 self.gasless_max_tx_size_bytes = Some(16 * 1024);
5125 }
5126
5127 pub fn disable_gasless_for_testing(&mut self) {
5128 self.feature_flags.enable_gasless = false;
5129 self.gasless_max_computation_units = None;
5130 self.gasless_allowed_token_types = None;
5131 }
5132
5133 pub fn enable_authenticated_event_streams_for_testing(&mut self) {
5134 self.feature_flags.enable_accumulators = true;
5135 self.feature_flags.enable_authenticated_event_streams = true;
5136 self.feature_flags
5137 .include_checkpoint_artifacts_digest_in_summary = true;
5138 self.feature_flags.split_checkpoints_in_consensus_handler = true;
5139 }
5140}
5141
5142type OverrideFn = dyn Fn(ProtocolVersion, ProtocolConfig) -> ProtocolConfig + Send + Sync;
5143
5144static CONFIG_OVERRIDE: Mutex<Option<Box<OverrideFn>>> = Mutex::new(None);
5145
5146#[must_use]
5147pub struct OverrideGuard;
5148
5149impl Drop for OverrideGuard {
5150 fn drop(&mut self) {
5151 info!("restoring override fn");
5152 *CONFIG_OVERRIDE.lock().unwrap() = None;
5153 }
5154}
5155
5156#[derive(PartialEq, Eq)]
5159pub enum LimitThresholdCrossed {
5160 None,
5161 Soft(u128, u128),
5162 Hard(u128, u128),
5163}
5164
5165pub fn check_limit_in_range<T: Into<V>, U: Into<V>, V: PartialOrd + Into<u128>>(
5168 x: T,
5169 soft_limit: U,
5170 hard_limit: V,
5171) -> LimitThresholdCrossed {
5172 let x: V = x.into();
5173 let soft_limit: V = soft_limit.into();
5174
5175 debug_assert!(soft_limit <= hard_limit);
5176
5177 if x >= hard_limit {
5180 LimitThresholdCrossed::Hard(x.into(), hard_limit.into())
5181 } else if x < soft_limit {
5182 LimitThresholdCrossed::None
5183 } else {
5184 LimitThresholdCrossed::Soft(x.into(), soft_limit.into())
5185 }
5186}
5187
5188#[macro_export]
5189macro_rules! check_limit {
5190 ($x:expr, $hard:expr) => {
5191 check_limit!($x, $hard, $hard)
5192 };
5193 ($x:expr, $soft:expr, $hard:expr) => {
5194 check_limit_in_range($x as u64, $soft, $hard)
5195 };
5196}
5197
5198#[macro_export]
5202macro_rules! check_limit_by_meter {
5203 ($is_metered:expr, $x:expr, $metered_limit:expr, $unmetered_hard_limit:expr, $metric:expr) => {{
5204 let (h, metered_str) = if $is_metered {
5206 ($metered_limit, "metered")
5207 } else {
5208 ($unmetered_hard_limit, "unmetered")
5210 };
5211 use sui_protocol_config::check_limit_in_range;
5212 let result = check_limit_in_range($x as u64, $metered_limit, h);
5213 match result {
5214 LimitThresholdCrossed::None => {}
5215 LimitThresholdCrossed::Soft(_, _) => {
5216 $metric.with_label_values(&[metered_str, "soft"]).inc();
5217 }
5218 LimitThresholdCrossed::Hard(_, _) => {
5219 $metric.with_label_values(&[metered_str, "hard"]).inc();
5220 }
5221 };
5222 result
5223 }};
5224}
5225
5226pub type Amendments = BTreeMap<AccountAddress, BTreeMap<AccountAddress, AccountAddress>>;
5229
5230static MAINNET_LINKAGE_AMENDMENTS: LazyLock<Arc<Amendments>> =
5231 LazyLock::new(|| parse_amendments(include_str!("mainnet_amendments.json")));
5232
5233static TESTNET_LINKAGE_AMENDMENTS: LazyLock<Arc<Amendments>> =
5234 LazyLock::new(|| parse_amendments(include_str!("testnet_amendments.json")));
5235
5236fn parse_amendments(json: &str) -> Arc<Amendments> {
5237 #[derive(serde::Deserialize)]
5238 struct AmendmentEntry {
5239 root: String,
5240 deps: Vec<DepEntry>,
5241 }
5242
5243 #[derive(serde::Deserialize)]
5244 struct DepEntry {
5245 original_id: String,
5246 version_id: String,
5247 }
5248
5249 let entries: Vec<AmendmentEntry> =
5250 serde_json::from_str(json).expect("Failed to parse amendments JSON");
5251 let mut amendments = BTreeMap::new();
5252 for entry in entries {
5253 let root_id = AccountAddress::from_hex_literal(&entry.root).unwrap();
5254 let mut dep_ids = BTreeMap::new();
5255 for dep in entry.deps {
5256 let orig_id = AccountAddress::from_hex_literal(&dep.original_id).unwrap();
5257 let upgraded_id = AccountAddress::from_hex_literal(&dep.version_id).unwrap();
5258 assert!(
5259 dep_ids.insert(orig_id, upgraded_id).is_none(),
5260 "Duplicate original ID in amendments table"
5261 );
5262 }
5263 assert!(
5264 amendments.insert(root_id, dep_ids).is_none(),
5265 "Duplicate root ID in amendments table"
5266 );
5267 }
5268 Arc::new(amendments)
5269}
5270
5271#[cfg(all(test, not(msim)))]
5272mod test {
5273 use insta::assert_yaml_snapshot;
5274
5275 use super::*;
5276
5277 #[test]
5278 fn snapshot_tests() {
5279 println!("\n============================================================================");
5280 println!("! !");
5281 println!("! IMPORTANT: never update snapshots from this test. only add new versions! !");
5282 println!("! !");
5283 println!("============================================================================\n");
5284 for chain_id in &[Chain::Unknown, Chain::Mainnet, Chain::Testnet] {
5285 let chain_str = match chain_id {
5289 Chain::Unknown => "".to_string(),
5290 _ => format!("{:?}_", chain_id),
5291 };
5292 for i in MIN_PROTOCOL_VERSION..=MAX_PROTOCOL_VERSION {
5293 let cur = ProtocolVersion::new(i);
5294 assert_yaml_snapshot!(
5295 format!("{}version_{}", chain_str, cur.as_u64()),
5296 ProtocolConfig::get_for_version(cur, *chain_id)
5297 );
5298 }
5299 }
5300 }
5301
5302 #[test]
5303 fn test_getters() {
5304 let prot: ProtocolConfig =
5305 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5306 assert_eq!(
5307 prot.max_arguments(),
5308 prot.max_arguments_as_option().unwrap()
5309 );
5310 }
5311
5312 #[test]
5313 fn test_setters() {
5314 let mut prot: ProtocolConfig =
5315 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5316 prot.set_max_arguments_for_testing(123);
5317 assert_eq!(prot.max_arguments(), 123);
5318
5319 prot.set_max_arguments_from_str_for_testing("321".to_string());
5320 assert_eq!(prot.max_arguments(), 321);
5321
5322 prot.disable_max_arguments_for_testing();
5323 assert_eq!(prot.max_arguments_as_option(), None);
5324
5325 prot.set_attr_for_testing("max_arguments".to_string(), "456".to_string());
5326 assert_eq!(prot.max_arguments(), 456);
5327 }
5328
5329 #[test]
5330 fn test_execution_version_setter_allows_upgrade() {
5331 let mut prot = ProtocolConfig::get_for_max_version_UNSAFE();
5332 let current = prot.execution_version();
5333 prot.set_execution_version_for_testing(current);
5334 prot.set_execution_version_for_testing(current + 1);
5335 assert_eq!(prot.execution_version(), current + 1);
5336 }
5337
5338 #[test]
5339 #[should_panic(expected = "cannot downgrade execution_version")]
5340 fn test_execution_version_setter_panics_on_downgrade() {
5341 let mut prot = ProtocolConfig::get_for_max_version_UNSAFE();
5342 let current = prot.execution_version();
5343 prot.set_execution_version_for_testing(current - 1);
5344 }
5345
5346 #[test]
5347 fn test_feature_flag_setter_by_string() {
5348 let mut prot: ProtocolConfig =
5349 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5350 assert!(!prot.zklogin_auth());
5351 prot.set_feature_flag_for_testing("zklogin_auth".to_string(), true);
5352 assert!(prot.zklogin_auth());
5353 prot.set_feature_flag_for_testing("zklogin_auth".to_string(), false);
5354 assert!(!prot.zklogin_auth());
5355 }
5356
5357 #[test]
5358 #[should_panic(expected = "unknown feature flag")]
5359 fn test_feature_flag_setter_unknown_flag() {
5360 let mut prot: ProtocolConfig =
5361 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5362 prot.set_feature_flag_for_testing("some random string".to_string(), true);
5363 }
5364
5365 #[test]
5366 fn test_get_for_version_if_supported_applies_test_overrides() {
5367 let before =
5368 ProtocolConfig::get_for_version_if_supported(ProtocolVersion::new(1), Chain::Unknown)
5369 .unwrap();
5370
5371 assert!(!before.enable_coin_reservation_obj_refs());
5372
5373 let _guard = ProtocolConfig::apply_overrides_for_testing(|_, mut cfg| {
5374 cfg.enable_coin_reservation_for_testing();
5375 cfg
5376 });
5377
5378 let after =
5379 ProtocolConfig::get_for_version_if_supported(ProtocolVersion::new(1), Chain::Unknown)
5380 .unwrap();
5381
5382 assert!(after.enable_coin_reservation_obj_refs());
5383 }
5384
5385 #[test]
5386 #[should_panic(expected = "unsupported version")]
5387 fn max_version_test() {
5388 let _ = ProtocolConfig::get_for_version_impl(
5391 ProtocolVersion::new(MAX_PROTOCOL_VERSION + 1),
5392 Chain::Unknown,
5393 );
5394 }
5395
5396 #[test]
5397 fn lookup_by_string_test() {
5398 let prot: ProtocolConfig =
5399 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5400 assert!(prot.lookup_attr("some random string".to_string()).is_none());
5402
5403 assert!(
5404 prot.lookup_attr("max_arguments".to_string())
5405 == Some(ProtocolConfigValue::u32(prot.max_arguments())),
5406 );
5407
5408 assert!(
5410 prot.lookup_attr("max_move_identifier_len".to_string())
5411 .is_none()
5412 );
5413
5414 let prot: ProtocolConfig =
5416 ProtocolConfig::get_for_version(ProtocolVersion::new(9), Chain::Unknown);
5417 assert!(
5418 prot.lookup_attr("max_move_identifier_len".to_string())
5419 == Some(ProtocolConfigValue::u64(prot.max_move_identifier_len()))
5420 );
5421
5422 let prot: ProtocolConfig =
5423 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5424 assert!(
5426 prot.attr_map()
5427 .get("max_move_identifier_len")
5428 .unwrap()
5429 .is_none()
5430 );
5431 assert!(
5433 prot.attr_map().get("max_arguments").unwrap()
5434 == &Some(ProtocolConfigValue::u32(prot.max_arguments()))
5435 );
5436
5437 let prot: ProtocolConfig =
5439 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5440 assert!(
5442 prot.feature_flags
5443 .lookup_attr("some random string".to_owned())
5444 .is_none()
5445 );
5446 assert!(
5447 !prot
5448 .feature_flags
5449 .attr_map()
5450 .contains_key("some random string")
5451 );
5452
5453 assert!(
5455 prot.feature_flags
5456 .lookup_attr("package_upgrades".to_owned())
5457 == Some(false)
5458 );
5459 assert!(
5460 prot.feature_flags
5461 .attr_map()
5462 .get("package_upgrades")
5463 .unwrap()
5464 == &false
5465 );
5466 let prot: ProtocolConfig =
5467 ProtocolConfig::get_for_version(ProtocolVersion::new(4), Chain::Unknown);
5468 assert!(
5470 prot.feature_flags
5471 .lookup_attr("package_upgrades".to_owned())
5472 == Some(true)
5473 );
5474 assert!(
5475 prot.feature_flags
5476 .attr_map()
5477 .get("package_upgrades")
5478 .unwrap()
5479 == &true
5480 );
5481 }
5482
5483 #[test]
5484 fn limit_range_fn_test() {
5485 let low = 100u32;
5486 let high = 10000u64;
5487
5488 assert!(check_limit!(1u8, low, high) == LimitThresholdCrossed::None);
5489 assert!(matches!(
5490 check_limit!(255u16, low, high),
5491 LimitThresholdCrossed::Soft(255u128, 100)
5492 ));
5493 assert!(matches!(
5499 check_limit!(2550000u64, low, high),
5500 LimitThresholdCrossed::Hard(2550000, 10000)
5501 ));
5502
5503 assert!(matches!(
5504 check_limit!(2550000u64, high, high),
5505 LimitThresholdCrossed::Hard(2550000, 10000)
5506 ));
5507
5508 assert!(matches!(
5509 check_limit!(1u8, high),
5510 LimitThresholdCrossed::None
5511 ));
5512
5513 assert!(check_limit!(255u16, high) == LimitThresholdCrossed::None);
5514
5515 assert!(matches!(
5516 check_limit!(2550000u64, high),
5517 LimitThresholdCrossed::Hard(2550000, 10000)
5518 ));
5519 }
5520
5521 #[test]
5522 fn linkage_amendments_load() {
5523 let mainnet = LazyLock::force(&MAINNET_LINKAGE_AMENDMENTS);
5524 let testnet = LazyLock::force(&TESTNET_LINKAGE_AMENDMENTS);
5525 assert!(!mainnet.is_empty(), "mainnet amendments must not be empty");
5526 assert!(!testnet.is_empty(), "testnet amendments must not be empty");
5527 }
5528
5529 #[test]
5530 fn render_scalar_fields_use_precision_safe_encoding() {
5531 use mysten_common::rpc_format::Unmetered;
5532
5533 let config = ProtocolConfig::get_for_max_version_UNSAFE();
5534 let rendered = config
5535 .render::<serde_json::Value>(&mut Unmetered)
5536 .expect("render should succeed");
5537
5538 let max_args = rendered
5539 .get("max_arguments")
5540 .expect("max_arguments set at max version");
5541 assert!(
5542 max_args.is_number(),
5543 "u32 should render as number, got {max_args:?}",
5544 );
5545
5546 let max_tx_size = rendered
5547 .get("max_tx_size_bytes")
5548 .expect("max_tx_size_bytes set at max version");
5549 assert!(
5550 max_tx_size.is_string(),
5551 "u64 should render as string, got {max_tx_size:?}",
5552 );
5553 }
5554
5555 #[test]
5556 fn render_includes_non_scalar_gasless_allowlist_as_json() {
5557 use mysten_common::rpc_format::Unmetered;
5558 use serde_json::json;
5559
5560 let mut config = ProtocolConfig::get_for_max_version_UNSAFE();
5561 config.set_gasless_allowed_token_types_for_testing(vec![
5562 ("0xa::usdc::USDC".to_string(), 10_000),
5563 ("0xb::usdt::USDT".to_string(), 0),
5564 ]);
5565
5566 let rendered = config
5567 .render::<serde_json::Value>(&mut Unmetered)
5568 .expect("render should succeed under Unmetered budget");
5569 let allowlist = rendered
5570 .get("gasless_allowed_token_types")
5571 .expect("entry should be present after the testing setter");
5572
5573 assert_eq!(
5576 allowlist,
5577 &json!([["0xa::usdc::USDC", "10000"], ["0xb::usdt::USDT", "0"],]),
5578 );
5579 }
5580
5581 #[test]
5582 fn render_targets_prost_value_for_grpc() {
5583 use mysten_common::rpc_format::Unmetered;
5584 use prost_types::value::Kind;
5585
5586 let mut config = ProtocolConfig::get_for_max_version_UNSAFE();
5587 config.set_gasless_allowed_token_types_for_testing(vec![(
5588 "0xa::usdc::USDC".to_string(),
5589 10_000,
5590 )]);
5591
5592 let rendered = config
5593 .render::<prost_types::Value>(&mut Unmetered)
5594 .expect("render to prost Value should succeed");
5595 let allowlist = rendered
5596 .get("gasless_allowed_token_types")
5597 .expect("entry should be present after the testing setter");
5598
5599 let Some(Kind::ListValue(outer)) = &allowlist.kind else {
5601 panic!(
5602 "expected ListValue at the top level, got {:?}",
5603 allowlist.kind
5604 );
5605 };
5606 assert_eq!(outer.values.len(), 1, "one allowlisted entry");
5607 let Some(Kind::ListValue(entry)) = &outer.values[0].kind else {
5608 panic!("expected each entry to be a ListValue");
5609 };
5610 assert_eq!(entry.values.len(), 2, "entry has (coin_type, amount)");
5611
5612 let Some(Kind::StringValue(coin_type)) = &entry.values[0].kind else {
5613 panic!("expected coin_type as StringValue");
5614 };
5615 assert_eq!(coin_type, "0xa::usdc::USDC");
5616
5617 let Some(Kind::StringValue(amount)) = &entry.values[1].kind else {
5619 panic!(
5620 "expected minimum_transfer_amount as StringValue (precision-safe u64); got {:?}",
5621 entry.values[1].kind,
5622 );
5623 };
5624 assert_eq!(amount, "10000");
5625 }
5626
5627 #[test]
5628 fn render_emits_null_for_unset_protocol_versions() {
5629 use mysten_common::rpc_format::Unmetered;
5630
5631 let config = ProtocolConfig::get_for_version(1.into(), Chain::Unknown);
5632 let rendered = config
5633 .render::<serde_json::Value>(&mut Unmetered)
5634 .expect("render should succeed");
5635 let entry = rendered
5639 .get("gasless_allowed_token_types")
5640 .expect("key should be present for every protocol version");
5641 assert!(
5642 entry.is_null(),
5643 "value should be null for pre-feature protocol version, got {entry:?}",
5644 );
5645 }
5646}