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 = 138;
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)]
415pub struct ProtocolVersion(u64);
416
417impl ProtocolVersion {
418 pub const MIN: Self = Self(MIN_PROTOCOL_VERSION);
423
424 pub const MAX: Self = Self(MAX_PROTOCOL_VERSION);
425
426 #[cfg(not(msim))]
427 pub const MAX_ALLOWED: Self = Self::MAX;
428
429 #[cfg(msim)]
431 pub const MAX_ALLOWED: Self = Self(MAX_PROTOCOL_VERSION + 1);
432
433 pub fn new(v: u64) -> Self {
434 Self(v)
435 }
436
437 pub const fn as_u64(&self) -> u64 {
438 self.0
439 }
440
441 pub fn max() -> Self {
444 Self::MAX
445 }
446
447 pub fn prev(self) -> Self {
448 Self(self.0.checked_sub(1).unwrap())
449 }
450}
451
452impl From<u64> for ProtocolVersion {
453 fn from(v: u64) -> Self {
454 Self::new(v)
455 }
456}
457
458impl std::ops::Sub<u64> for ProtocolVersion {
459 type Output = Self;
460 fn sub(self, rhs: u64) -> Self::Output {
461 Self::new(self.0 - rhs)
462 }
463}
464
465impl std::ops::Add<u64> for ProtocolVersion {
466 type Output = Self;
467 fn add(self, rhs: u64) -> Self::Output {
468 Self::new(self.0 + rhs)
469 }
470}
471
472#[derive(
473 Clone, Serialize, Deserialize, Debug, Default, PartialEq, Copy, PartialOrd, Ord, Eq, ValueEnum,
474)]
475pub enum Chain {
476 Mainnet,
477 Testnet,
478 #[default]
479 Unknown,
480}
481
482impl Chain {
483 pub fn as_str(self) -> &'static str {
484 match self {
485 Chain::Mainnet => "mainnet",
486 Chain::Testnet => "testnet",
487 Chain::Unknown => "unknown",
488 }
489 }
490}
491
492pub struct Error(pub String);
493
494#[derive(Default, Clone, Serialize, Deserialize, Debug, ProtocolConfigFeatureFlagsGetters)]
497struct FeatureFlags {
498 #[serde(skip_serializing_if = "is_false")]
501 package_upgrades: bool,
502 #[serde(skip_serializing_if = "is_false")]
505 commit_root_state_digest: bool,
506 #[serde(skip_serializing_if = "is_false")]
508 advance_epoch_start_time_in_safe_mode: bool,
509 #[serde(skip_serializing_if = "is_false")]
512 loaded_child_objects_fixed: bool,
513 #[serde(skip_serializing_if = "is_false")]
516 missing_type_is_compatibility_error: bool,
517 #[serde(skip_serializing_if = "is_false")]
520 scoring_decision_with_validity_cutoff: bool,
521
522 #[serde(skip_serializing_if = "is_false")]
525 consensus_order_end_of_epoch_last: bool,
526
527 #[serde(skip_serializing_if = "is_false")]
531 consensus_slim_block_propagation: bool,
532
533 #[serde(skip_serializing_if = "is_false")]
535 disallow_adding_abilities_on_upgrade: bool,
536 #[serde(skip_serializing_if = "is_false")]
538 disable_invariant_violation_check_in_swap_loc: bool,
539 #[serde(skip_serializing_if = "is_false")]
542 advance_to_highest_supported_protocol_version: bool,
543 #[serde(skip_serializing_if = "is_false")]
545 ban_entry_init: bool,
546 #[serde(skip_serializing_if = "is_false")]
548 package_digest_hash_module: bool,
549 #[serde(skip_serializing_if = "is_false")]
551 disallow_change_struct_type_params_on_upgrade: bool,
552 #[serde(skip_serializing_if = "is_false")]
554 no_extraneous_module_bytes: bool,
555 #[serde(skip_serializing_if = "is_false")]
557 narwhal_versioned_metadata: bool,
558
559 #[serde(skip_serializing_if = "is_false")]
561 zklogin_auth: bool,
562 #[serde(skip_serializing_if = "is_zero")]
565 zklogin_circuit_mode: u64,
566 #[serde(skip_serializing_if = "ConsensusTransactionOrdering::is_none")]
568 consensus_transaction_ordering: ConsensusTransactionOrdering,
569
570 #[serde(skip_serializing_if = "is_false")]
578 simplified_unwrap_then_delete: bool,
579 #[serde(skip_serializing_if = "is_false")]
581 upgraded_multisig_supported: bool,
582 #[serde(skip_serializing_if = "is_false")]
584 txn_base_cost_as_multiplier: bool,
585
586 #[serde(skip_serializing_if = "is_false")]
588 shared_object_deletion: bool,
589
590 #[serde(skip_serializing_if = "is_false")]
592 narwhal_new_leader_election_schedule: bool,
593
594 #[serde(skip_serializing_if = "is_empty")]
596 zklogin_supported_providers: BTreeSet<String>,
597
598 #[serde(skip_serializing_if = "is_false")]
600 loaded_child_object_format: bool,
601
602 #[serde(skip_serializing_if = "is_false")]
603 #[skip_protocol_config_accessor]
604 enable_jwk_consensus_updates: bool,
605
606 #[serde(skip_serializing_if = "is_false")]
607 #[skip_protocol_config_accessor]
608 end_of_epoch_transaction_supported: bool,
609
610 #[serde(skip_serializing_if = "is_false")]
613 simple_conservation_checks: bool,
614
615 #[serde(skip_serializing_if = "is_false")]
617 loaded_child_object_format_type: bool,
618
619 #[serde(skip_serializing_if = "is_false")]
621 receive_objects: bool,
622
623 #[serde(skip_serializing_if = "is_false")]
625 consensus_checkpoint_signature_key_includes_digest: bool,
626
627 #[serde(skip_serializing_if = "is_false")]
629 random_beacon: bool,
630
631 #[serde(skip_serializing_if = "is_false")]
633 #[skip_protocol_config_accessor]
634 bridge: bool,
635
636 #[serde(skip_serializing_if = "is_false")]
637 enable_effects_v2: bool,
638
639 #[serde(skip_serializing_if = "is_false")]
641 narwhal_certificate_v2: bool,
642
643 #[serde(skip_serializing_if = "is_false")]
645 verify_legacy_zklogin_address: bool,
646
647 #[serde(skip_serializing_if = "is_false")]
649 throughput_aware_consensus_submission: bool,
650
651 #[serde(skip_serializing_if = "is_false")]
653 recompute_has_public_transfer_in_execution: bool,
654
655 #[serde(skip_serializing_if = "is_false")]
657 accept_zklogin_in_multisig: bool,
658
659 #[serde(skip_serializing_if = "is_false")]
661 accept_passkey_in_multisig: bool,
662
663 #[serde(skip_serializing_if = "is_false")]
665 validate_zklogin_public_identifier: bool,
666
667 #[serde(skip_serializing_if = "is_false")]
670 include_consensus_digest_in_prologue: bool,
671
672 #[serde(skip_serializing_if = "is_false")]
674 hardened_otw_check: bool,
675
676 #[serde(skip_serializing_if = "is_false")]
678 allow_receiving_object_id: bool,
679
680 #[serde(skip_serializing_if = "is_false")]
682 enable_poseidon: bool,
683
684 #[serde(skip_serializing_if = "is_false")]
686 enable_coin_deny_list: bool,
687
688 #[serde(skip_serializing_if = "is_false")]
690 enable_group_ops_native_functions: bool,
691
692 #[serde(skip_serializing_if = "is_false")]
694 enable_group_ops_native_function_msm: bool,
695
696 #[serde(skip_serializing_if = "is_false")]
698 enable_ristretto255_group_ops: bool,
699
700 #[serde(skip_serializing_if = "is_false")]
702 enable_verify_bulletproofs_ristretto255: bool,
703
704 #[serde(skip_serializing_if = "is_false")]
706 enable_nitro_attestation: bool,
707
708 #[serde(skip_serializing_if = "is_false")]
710 enable_nitro_attestation_upgraded_parsing: bool,
711
712 #[serde(skip_serializing_if = "is_false")]
714 enable_nitro_attestation_all_nonzero_pcrs_parsing: bool,
715
716 #[serde(skip_serializing_if = "is_false")]
718 enable_nitro_attestation_always_include_required_pcrs_parsing: bool,
719
720 #[serde(skip_serializing_if = "is_false")]
722 reject_mutable_random_on_entry_functions: bool,
723
724 #[serde(skip_serializing_if = "PerObjectCongestionControlMode::is_none")]
726 per_object_congestion_control_mode: PerObjectCongestionControlMode,
727
728 #[serde(skip_serializing_if = "ConsensusChoice::is_narwhal")]
730 consensus_choice: ConsensusChoice,
731
732 #[serde(skip_serializing_if = "ConsensusNetwork::is_anemo")]
734 consensus_network: ConsensusNetwork,
735
736 #[serde(skip_serializing_if = "is_false")]
738 correct_gas_payment_limit_check: bool,
739
740 #[serde(skip_serializing_if = "Option::is_none")]
742 zklogin_max_epoch_upper_bound_delta: Option<u64>,
743
744 #[serde(skip_serializing_if = "is_false")]
746 mysticeti_leader_scoring_and_schedule: bool,
747
748 #[serde(skip_serializing_if = "is_false")]
750 reshare_at_same_initial_version: bool,
751
752 #[serde(skip_serializing_if = "is_false")]
754 resolve_abort_locations_to_package_id: bool,
755
756 #[serde(skip_serializing_if = "is_false")]
760 mysticeti_use_committed_subdag_digest: bool,
761
762 #[serde(skip_serializing_if = "is_false")]
764 enable_vdf: bool,
765
766 #[serde(skip_serializing_if = "is_false")]
770 record_consensus_determined_version_assignments_in_prologue: bool,
771 #[serde(skip_serializing_if = "is_false")]
774 record_consensus_determined_version_assignments_in_prologue_v2: bool,
775
776 #[serde(skip_serializing_if = "is_false")]
778 fresh_vm_on_framework_upgrade: bool,
779
780 #[serde(skip_serializing_if = "is_false")]
788 prepend_prologue_tx_in_consensus_commit_in_checkpoints: bool,
789
790 #[serde(skip_serializing_if = "Option::is_none")]
792 mysticeti_num_leaders_per_round: Option<usize>,
793
794 #[serde(skip_serializing_if = "is_false")]
796 soft_bundle: bool,
797
798 #[serde(skip_serializing_if = "is_false")]
800 enable_coin_deny_list_v2: bool,
801
802 #[serde(skip_serializing_if = "is_false")]
804 passkey_auth: bool,
805
806 #[serde(skip_serializing_if = "is_false")]
808 authority_capabilities_v2: bool,
809
810 #[serde(skip_serializing_if = "is_false")]
812 rethrow_serialization_type_layout_errors: bool,
813
814 #[serde(skip_serializing_if = "is_false")]
816 consensus_distributed_vote_scoring_strategy: bool,
817
818 #[serde(skip_serializing_if = "is_false")]
820 consensus_round_prober: bool,
821
822 #[serde(skip_serializing_if = "is_false")]
824 validate_identifier_inputs: bool,
825
826 #[serde(skip_serializing_if = "is_false")]
828 disallow_self_identifier: bool,
829
830 #[serde(skip_serializing_if = "is_false")]
832 mysticeti_fastpath: bool,
833
834 #[serde(skip_serializing_if = "is_false")]
838 disable_preconsensus_locking: bool,
839
840 #[serde(skip_serializing_if = "is_false")]
842 relocate_event_module: bool,
843
844 #[serde(skip_serializing_if = "is_false")]
846 uncompressed_g1_group_elements: bool,
847
848 #[serde(skip_serializing_if = "is_false")]
849 disallow_new_modules_in_deps_only_packages: bool,
850
851 #[serde(skip_serializing_if = "is_false")]
853 consensus_smart_ancestor_selection: bool,
854
855 #[serde(skip_serializing_if = "is_false")]
857 consensus_round_prober_probe_accepted_rounds: bool,
858
859 #[serde(skip_serializing_if = "is_false")]
861 native_charging_v2: bool,
862
863 #[serde(skip_serializing_if = "is_false")]
866 #[skip_protocol_config_accessor]
867 consensus_linearize_subdag_v2: bool,
868
869 #[serde(skip_serializing_if = "is_false")]
871 convert_type_argument_error: bool,
872
873 #[serde(skip_serializing_if = "is_false")]
875 variant_nodes: bool,
876
877 #[serde(skip_serializing_if = "is_false")]
879 consensus_zstd_compression: bool,
880
881 #[serde(skip_serializing_if = "is_false")]
883 minimize_child_object_mutations: bool,
884
885 #[serde(skip_serializing_if = "is_false")]
888 record_additional_state_digest_in_prologue: bool,
889
890 #[serde(skip_serializing_if = "is_false")]
892 move_native_context: bool,
893
894 #[serde(skip_serializing_if = "is_false")]
897 #[skip_protocol_config_accessor]
898 consensus_median_based_commit_timestamp: bool,
899
900 #[serde(skip_serializing_if = "is_false")]
903 normalize_ptb_arguments: bool,
904
905 #[serde(skip_serializing_if = "is_false")]
907 consensus_batched_block_sync: bool,
908
909 #[serde(skip_serializing_if = "is_false")]
911 enforce_checkpoint_timestamp_monotonicity: bool,
912
913 #[serde(skip_serializing_if = "is_false")]
915 max_ptb_value_size_v2: bool,
916
917 #[serde(skip_serializing_if = "is_false")]
919 resolve_type_input_ids_to_defining_id: bool,
920
921 #[serde(skip_serializing_if = "is_false")]
923 enable_party_transfer: bool,
924
925 #[serde(skip_serializing_if = "is_false")]
927 allow_unbounded_system_objects: bool,
928
929 #[serde(skip_serializing_if = "is_false")]
931 type_tags_in_object_runtime: bool,
932
933 #[serde(skip_serializing_if = "is_false")]
935 enable_accumulators: bool,
936
937 #[serde(skip_serializing_if = "is_false")]
939 #[skip_protocol_config_accessor]
940 enable_coin_reservation_obj_refs: bool,
941
942 #[serde(skip_serializing_if = "is_false")]
945 create_root_accumulator_object: bool,
946
947 #[serde(skip_serializing_if = "is_false")]
949 #[skip_protocol_config_accessor]
950 enable_authenticated_event_streams: bool,
951
952 #[serde(skip_serializing_if = "is_false")]
954 enable_address_balance_gas_payments: bool,
955
956 #[serde(skip_serializing_if = "is_false")]
958 address_balance_gas_check_rgp_at_signing: bool,
959
960 #[serde(skip_serializing_if = "is_false")]
961 address_balance_gas_reject_gas_coin_arg: bool,
962
963 #[serde(skip_serializing_if = "is_false")]
965 enable_multi_epoch_transaction_expiration: bool,
966
967 #[serde(skip_serializing_if = "is_false")]
969 relax_valid_during_for_owned_inputs: bool,
970
971 #[serde(skip_serializing_if = "is_false")]
973 enable_ptb_execution_v2: bool,
974
975 #[serde(skip_serializing_if = "is_false")]
977 better_adapter_type_resolution_errors: bool,
978
979 #[serde(skip_serializing_if = "is_false")]
981 record_time_estimate_processed: bool,
982
983 #[serde(skip_serializing_if = "is_false")]
985 dependency_linkage_error: bool,
986
987 #[serde(skip_serializing_if = "is_false")]
989 additional_multisig_checks: bool,
990
991 #[serde(skip_serializing_if = "is_false")]
993 ignore_execution_time_observations_after_certs_closed: bool,
994
995 #[serde(skip_serializing_if = "is_false")]
999 debug_fatal_on_move_invariant_violation: bool,
1000
1001 #[serde(skip_serializing_if = "is_false")]
1004 allow_private_accumulator_entrypoints: bool,
1005
1006 #[serde(skip_serializing_if = "is_false")]
1009 additional_consensus_digest_indirect_state: bool,
1010
1011 #[serde(skip_serializing_if = "is_false")]
1013 check_for_init_during_upgrade: bool,
1014
1015 #[serde(skip_serializing_if = "is_false")]
1017 enable_init_on_upgrade: bool,
1018
1019 #[serde(skip_serializing_if = "is_false")]
1021 enable_order_independent_upgrade_init_linkage: bool,
1022
1023 #[serde(skip_serializing_if = "is_false")]
1026 harden_linkage_consistency: bool,
1027
1028 #[serde(skip_serializing_if = "is_false")]
1030 per_command_shared_object_transfer_rules: bool,
1031
1032 #[serde(skip_serializing_if = "is_false")]
1034 validate_ptb_argument_indices: bool,
1035
1036 #[serde(skip_serializing_if = "is_false")]
1038 include_checkpoint_artifacts_digest_in_summary: bool,
1039
1040 #[serde(skip_serializing_if = "is_false")]
1042 use_mfp_txns_in_load_initial_object_debts: bool,
1043
1044 #[serde(skip_serializing_if = "is_false")]
1046 cancel_for_failed_dkg_early: bool,
1047
1048 #[serde(skip_serializing_if = "is_false")]
1050 always_advance_dkg_to_resolution: bool,
1051
1052 #[serde(skip_serializing_if = "is_false")]
1054 enable_coin_registry: bool,
1055
1056 #[serde(skip_serializing_if = "is_false")]
1058 abstract_size_in_object_runtime: bool,
1059
1060 #[serde(skip_serializing_if = "is_false")]
1062 object_runtime_charge_cache_load_gas: bool,
1063
1064 #[serde(skip_serializing_if = "is_false")]
1066 additional_borrow_checks: bool,
1067
1068 #[serde(skip_serializing_if = "is_false")]
1070 use_new_commit_handler: bool,
1071
1072 #[serde(skip_serializing_if = "is_false")]
1074 better_loader_errors: bool,
1075
1076 #[serde(skip_serializing_if = "is_false")]
1078 generate_df_type_layouts: bool,
1079
1080 #[serde(skip_serializing_if = "is_false")]
1082 allow_references_in_ptbs: bool,
1083
1084 #[serde(skip_serializing_if = "is_false")]
1091 framework_tx_context_mut_restrictions: bool,
1092
1093 #[serde(skip_serializing_if = "is_false")]
1095 include_function_signatures_in_instantiation_limits: bool,
1096
1097 #[serde(skip_serializing_if = "is_false")]
1102 ptb_tx_context_restrictions: bool,
1103
1104 #[serde(skip_serializing_if = "is_false")]
1106 enable_display_registry: bool,
1107
1108 #[serde(skip_serializing_if = "is_false")]
1110 private_generics_verifier_v2: bool,
1111
1112 #[serde(skip_serializing_if = "is_false")]
1114 deprecate_global_storage_ops_during_deserialization: bool,
1115
1116 #[serde(skip_serializing_if = "is_false")]
1119 enable_non_exclusive_writes: bool,
1120
1121 #[serde(skip_serializing_if = "is_false")]
1123 deprecate_global_storage_ops: bool,
1124
1125 #[serde(skip_serializing_if = "is_false")]
1127 normalize_depth_formula: bool,
1128
1129 #[serde(skip_serializing_if = "is_false")]
1132 charge_ld_const_abstract_size: bool,
1133
1134 #[serde(skip_serializing_if = "is_false")]
1136 consensus_skip_gced_accept_votes: bool,
1137
1138 #[serde(skip_serializing_if = "is_false")]
1141 include_cancelled_randomness_txns_in_prologue: bool,
1142
1143 #[serde(skip_serializing_if = "is_false")]
1145 #[skip_protocol_config_accessor]
1146 address_aliases: bool,
1147
1148 #[serde(skip_serializing_if = "is_false")]
1150 create_forwarding_address_registry: bool,
1151
1152 #[serde(skip_serializing_if = "is_false")]
1155 fix_checkpoint_signature_mapping: bool,
1156
1157 #[serde(skip_serializing_if = "is_false")]
1159 enable_object_funds_withdraw: bool,
1160
1161 #[serde(skip_serializing_if = "is_false")]
1164 record_net_unsettled_object_withdraws: bool,
1165
1166 #[serde(skip_serializing_if = "is_false")]
1168 consensus_skip_gced_blocks_in_direct_finalization: bool,
1169
1170 #[serde(skip_serializing_if = "is_false")]
1172 gas_rounding_halve_digits: bool,
1173
1174 #[serde(skip_serializing_if = "is_false")]
1176 flexible_tx_context_positions: bool,
1177
1178 #[serde(skip_serializing_if = "is_false")]
1180 disable_entry_point_signature_check: bool,
1181
1182 #[serde(skip_serializing_if = "is_false")]
1184 convert_withdrawal_compatibility_ptb_arguments: bool,
1185
1186 #[serde(skip_serializing_if = "is_false")]
1188 restrict_hot_or_not_entry_functions: bool,
1189
1190 #[serde(skip_serializing_if = "is_false")]
1192 split_checkpoints_in_consensus_handler: bool,
1193
1194 #[serde(skip_serializing_if = "is_false")]
1196 consensus_always_accept_system_transactions: bool,
1197
1198 #[serde(skip_serializing_if = "is_false")]
1200 validator_metadata_verify_v2: bool,
1201
1202 #[serde(skip_serializing_if = "is_false")]
1205 defer_unpaid_amplification: bool,
1206
1207 #[serde(skip_serializing_if = "is_false")]
1210 defer_owned_object_double_spend: bool,
1211
1212 #[serde(skip_serializing_if = "is_false")]
1215 allowed_proposers: bool,
1216
1217 #[serde(skip_serializing_if = "is_false")]
1218 randomize_checkpoint_tx_limit_in_tests: bool,
1219
1220 #[serde(skip_serializing_if = "is_false")]
1222 gasless_transaction_drop_safety: bool,
1223
1224 #[serde(skip_serializing_if = "is_false")]
1227 merge_randomness_into_checkpoint: bool,
1228
1229 #[serde(skip_serializing_if = "is_false")]
1231 use_coin_party_owner: bool,
1232
1233 #[serde(skip_serializing_if = "is_false")]
1234 enable_gasless: bool,
1235
1236 #[serde(skip_serializing_if = "is_false")]
1237 gasless_verify_remaining_balance: bool,
1238
1239 #[serde(skip_serializing_if = "is_false")]
1240 disallow_jump_orphans: bool,
1241
1242 #[serde(skip_serializing_if = "is_false")]
1244 early_return_receive_object_mismatched_type: bool,
1245
1246 #[serde(skip_serializing_if = "is_false")]
1251 timestamp_based_epoch_close: bool,
1252
1253 #[serde(skip_serializing_if = "is_false")]
1256 limit_groth16_pvk_inputs: bool,
1257
1258 #[serde(skip_serializing_if = "is_false")]
1263 enforce_address_balance_change_invariant: bool,
1264
1265 #[serde(skip_serializing_if = "is_false")]
1267 share_transaction_deny_config_in_consensus: bool,
1268
1269 #[serde(skip_serializing_if = "is_false")]
1271 granular_post_execution_checks: bool,
1272
1273 #[serde(skip_serializing_if = "is_false")]
1275 early_exit_on_iffw: bool,
1276
1277 #[serde(skip_serializing_if = "is_false")]
1279 enable_unified_linkage: bool,
1280
1281 #[serde(skip_serializing_if = "is_false")]
1284 #[skip_protocol_config_accessor]
1285 enable_allowances: bool,
1286
1287 #[serde(skip_serializing_if = "is_false")]
1289 fix_ptb_generated_reads: bool,
1290
1291 #[serde(skip_serializing_if = "is_false")]
1292 check_object_funds_withdraw_in_execution: bool,
1293 #[serde(skip_serializing_if = "is_false")]
1295 memory_safety_invariant_check_v2: bool,
1296
1297 #[serde(skip_serializing_if = "is_false")]
1299 disable_effects_tx_dependencies: bool,
1300}
1301
1302fn is_false(b: &bool) -> bool {
1303 !b
1304}
1305
1306fn is_empty(b: &BTreeSet<String>) -> bool {
1307 b.is_empty()
1308}
1309
1310fn is_zero(val: &u64) -> bool {
1311 *val == 0
1312}
1313
1314#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1316pub enum ConsensusTransactionOrdering {
1317 #[default]
1319 None,
1320 ByGasPrice,
1322}
1323
1324impl ConsensusTransactionOrdering {
1325 pub fn is_none(&self) -> bool {
1326 matches!(self, ConsensusTransactionOrdering::None)
1327 }
1328}
1329
1330#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1331pub struct ExecutionTimeEstimateParams {
1332 pub target_utilization: u64,
1334 pub allowed_txn_cost_overage_burst_limit_us: u64,
1338
1339 pub randomness_scalar: u64,
1342
1343 pub max_estimate_us: u64,
1345
1346 pub stored_observations_num_included_checkpoints: u64,
1349
1350 pub stored_observations_limit: u64,
1352
1353 #[serde(skip_serializing_if = "is_zero")]
1356 pub stake_weighted_median_threshold: u64,
1357
1358 #[serde(skip_serializing_if = "is_false")]
1362 pub default_none_duration_for_new_keys: bool,
1363
1364 #[serde(skip_serializing_if = "Option::is_none")]
1366 pub observations_chunk_size: Option<u64>,
1367}
1368
1369#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1371pub enum PerObjectCongestionControlMode {
1372 #[default]
1373 None, TotalGasBudget, TotalTxCount, TotalGasBudgetWithCap, ExecutionTimeEstimate(ExecutionTimeEstimateParams), }
1379
1380impl PerObjectCongestionControlMode {
1381 pub fn is_none(&self) -> bool {
1382 matches!(self, PerObjectCongestionControlMode::None)
1383 }
1384}
1385
1386#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1388pub enum ConsensusChoice {
1389 #[default]
1390 Narwhal,
1391 SwapEachEpoch,
1392 Mysticeti,
1393}
1394
1395impl ConsensusChoice {
1396 pub fn is_narwhal(&self) -> bool {
1397 matches!(self, ConsensusChoice::Narwhal)
1398 }
1399}
1400
1401#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1403pub enum ConsensusNetwork {
1404 #[default]
1405 Anemo,
1406 Tonic,
1407}
1408
1409impl ConsensusNetwork {
1410 pub fn is_anemo(&self) -> bool {
1411 matches!(self, ConsensusNetwork::Anemo)
1412 }
1413}
1414
1415#[skip_serializing_none]
1447#[derive(Clone, Serialize, Debug, ProtocolConfigAccessors, ProtocolConfigOverride)]
1448pub struct ProtocolConfig {
1449 pub version: ProtocolVersion,
1450
1451 #[serde(skip)]
1456 chain: Chain,
1457
1458 feature_flags: FeatureFlags,
1459
1460 max_tx_size_bytes: Option<u64>,
1463
1464 max_input_objects: Option<u64>,
1466
1467 max_size_written_objects: Option<u64>,
1471 max_size_written_objects_system_tx: Option<u64>,
1474
1475 max_serialized_tx_effects_size_bytes: Option<u64>,
1477
1478 max_serialized_tx_effects_size_bytes_system_tx: Option<u64>,
1480
1481 max_gas_payment_objects: Option<u32>,
1483
1484 max_modules_in_publish: Option<u32>,
1486
1487 max_package_dependencies: Option<u32>,
1489
1490 max_arguments: Option<u32>,
1493
1494 max_type_arguments: Option<u32>,
1496
1497 max_type_argument_depth: Option<u32>,
1499
1500 max_pure_argument_size: Option<u32>,
1502
1503 max_programmable_tx_commands: Option<u32>,
1505
1506 move_binary_format_version: Option<u32>,
1509 min_move_binary_format_version: Option<u32>,
1510
1511 binary_module_handles: Option<u16>,
1513 binary_struct_handles: Option<u16>,
1514 binary_function_handles: Option<u16>,
1515 binary_function_instantiations: Option<u16>,
1516 binary_signatures: Option<u16>,
1517 binary_constant_pool: Option<u16>,
1518 binary_identifiers: Option<u16>,
1519 binary_address_identifiers: Option<u16>,
1520 binary_struct_defs: Option<u16>,
1521 binary_struct_def_instantiations: Option<u16>,
1522 binary_function_defs: Option<u16>,
1523 binary_field_handles: Option<u16>,
1524 binary_field_instantiations: Option<u16>,
1525 binary_friend_decls: Option<u16>,
1526 binary_enum_defs: Option<u16>,
1527 binary_enum_def_instantiations: Option<u16>,
1528 binary_variant_handles: Option<u16>,
1529 binary_variant_instantiation_handles: Option<u16>,
1530
1531 max_move_object_size: Option<u64>,
1533
1534 max_move_package_size: Option<u64>,
1537
1538 max_publish_or_upgrade_per_ptb: Option<u64>,
1540
1541 max_tx_gas: Option<u64>,
1543
1544 max_gas_price: Option<u64>,
1546
1547 max_gas_price_rgp_factor_for_aborted_transactions: Option<u64>,
1550
1551 max_gas_computation_bucket: Option<u64>,
1553
1554 gas_rounding_step: Option<u64>,
1556
1557 max_loop_depth: Option<u64>,
1559
1560 max_generic_instantiation_length: Option<u64>,
1562
1563 max_function_parameters: Option<u64>,
1565
1566 max_basic_blocks: Option<u64>,
1568
1569 max_value_stack_size: Option<u64>,
1571
1572 max_type_nodes: Option<u64>,
1574
1575 max_generic_instantiation_type_nodes_per_function: Option<u64>,
1577
1578 max_generic_instantiation_type_nodes_per_module: Option<u64>,
1580
1581 max_accumulator_type_nodes: Option<u64>,
1583
1584 max_push_size: Option<u64>,
1586
1587 max_struct_definitions: Option<u64>,
1589
1590 max_function_definitions: Option<u64>,
1592
1593 max_fields_in_struct: Option<u64>,
1595
1596 max_dependency_depth: Option<u64>,
1598
1599 max_num_event_emit: Option<u64>,
1601
1602 max_num_new_move_object_ids: Option<u64>,
1604
1605 max_num_new_move_object_ids_system_tx: Option<u64>,
1607
1608 max_num_deleted_move_object_ids: Option<u64>,
1610
1611 max_num_deleted_move_object_ids_system_tx: Option<u64>,
1613
1614 max_num_transferred_move_object_ids: Option<u64>,
1616
1617 max_num_transferred_move_object_ids_system_tx: Option<u64>,
1619
1620 max_event_emit_size: Option<u64>,
1622
1623 max_event_emit_size_total: Option<u64>,
1625
1626 max_move_vector_len: Option<u64>,
1628
1629 max_move_identifier_len: Option<u64>,
1631
1632 max_move_value_depth: Option<u64>,
1634
1635 package_arena_size_in_bytes: Option<u64>,
1638
1639 max_move_enum_variants: Option<u64>,
1641
1642 max_back_edges_per_function: Option<u64>,
1644
1645 max_back_edges_per_module: Option<u64>,
1647
1648 max_verifier_meter_ticks_per_function: Option<u64>,
1650
1651 max_meter_ticks_per_module: Option<u64>,
1653
1654 max_meter_ticks_per_package: Option<u64>,
1656
1657 object_runtime_max_num_cached_objects: Option<u64>,
1661
1662 object_runtime_max_num_cached_objects_system_tx: Option<u64>,
1664
1665 object_runtime_max_num_store_entries: Option<u64>,
1667
1668 object_runtime_max_num_store_entries_system_tx: Option<u64>,
1670
1671 base_tx_cost_fixed: Option<u64>,
1674
1675 package_publish_cost_fixed: Option<u64>,
1678
1679 base_tx_cost_per_byte: Option<u64>,
1682
1683 package_publish_cost_per_byte: Option<u64>,
1685
1686 obj_access_cost_read_per_byte: Option<u64>,
1688
1689 obj_access_cost_mutate_per_byte: Option<u64>,
1691
1692 obj_access_cost_delete_per_byte: Option<u64>,
1694
1695 obj_access_cost_verify_per_byte: Option<u64>,
1705
1706 max_type_to_layout_nodes: Option<u64>,
1708
1709 max_ptb_value_size: Option<u64>,
1711
1712 gas_model_version: Option<u64>,
1715
1716 obj_data_cost_refundable: Option<u64>,
1719
1720 obj_metadata_cost_non_refundable: Option<u64>,
1724
1725 storage_rebate_rate: Option<u64>,
1731
1732 storage_fund_reinvest_rate: Option<u64>,
1735
1736 reward_slashing_rate: Option<u64>,
1739
1740 storage_gas_price: Option<u64>,
1742
1743 accumulator_object_storage_cost: Option<u64>,
1745
1746 max_transactions_per_checkpoint: Option<u64>,
1751
1752 max_checkpoint_size_bytes: Option<u64>,
1756
1757 buffer_stake_for_protocol_upgrade_bps: Option<u64>,
1762
1763 address_from_bytes_cost_base: Option<u64>,
1768 address_to_u256_cost_base: Option<u64>,
1770 address_from_u256_cost_base: Option<u64>,
1772
1773 config_read_setting_impl_cost_base: Option<u64>,
1778 config_read_setting_impl_cost_per_byte: Option<u64>,
1779
1780 package_original_package_id_impl_cost_base: Option<u64>,
1781 package_original_package_id_impl_cost_per_byte: Option<u64>,
1782
1783 dynamic_field_hash_type_and_key_cost_base: Option<u64>,
1786 dynamic_field_hash_type_and_key_type_cost_per_byte: Option<u64>,
1787 dynamic_field_hash_type_and_key_value_cost_per_byte: Option<u64>,
1788 dynamic_field_hash_type_and_key_type_tag_cost_per_byte: Option<u64>,
1789 dynamic_field_add_child_object_cost_base: Option<u64>,
1791 dynamic_field_add_child_object_type_cost_per_byte: Option<u64>,
1792 dynamic_field_add_child_object_value_cost_per_byte: Option<u64>,
1793 dynamic_field_add_child_object_struct_tag_cost_per_byte: Option<u64>,
1794 dynamic_field_borrow_child_object_cost_base: Option<u64>,
1796 dynamic_field_borrow_child_object_child_ref_cost_per_byte: Option<u64>,
1797 dynamic_field_borrow_child_object_type_cost_per_byte: Option<u64>,
1798 dynamic_field_remove_child_object_cost_base: Option<u64>,
1800 dynamic_field_remove_child_object_child_cost_per_byte: Option<u64>,
1801 dynamic_field_remove_child_object_type_cost_per_byte: Option<u64>,
1802 dynamic_field_has_child_object_cost_base: Option<u64>,
1804 dynamic_field_has_child_object_with_ty_cost_base: Option<u64>,
1806 dynamic_field_has_child_object_with_ty_type_cost_per_byte: Option<u64>,
1807 dynamic_field_has_child_object_with_ty_type_tag_cost_per_byte: Option<u64>,
1808
1809 scratch_add_cost_base: Option<u64>,
1812 scratch_read_cost_base: Option<u64>,
1814 scratch_read_value_cost: Option<u64>,
1815 scratch_remove_cost_base: Option<u64>,
1817 scratch_exists_cost_base: Option<u64>,
1819 scratch_exists_with_type_cost_base: Option<u64>,
1821 scratch_exists_with_type_type_cost: Option<u64>,
1822 max_scratch_pad_size: Option<u64>,
1824
1825 event_emit_cost_base: Option<u64>,
1828 event_emit_value_size_derivation_cost_per_byte: Option<u64>,
1829 event_emit_tag_size_derivation_cost_per_byte: Option<u64>,
1830 event_emit_output_cost_per_byte: Option<u64>,
1831 event_emit_auth_stream_cost: Option<u64>,
1832
1833 reserve_object_funds_for_withdrawal_cost_base: Option<u64>,
1836 reserve_object_funds_for_withdrawal_cold_read_cost: Option<u64>,
1838
1839 object_borrow_uid_cost_base: Option<u64>,
1842 object_delete_impl_cost_base: Option<u64>,
1844 object_record_new_uid_cost_base: Option<u64>,
1846 object_record_new_uid_from_hash_cost_base: Option<u64>,
1849
1850 transfer_transfer_internal_cost_base: Option<u64>,
1853 transfer_party_transfer_internal_cost_base: Option<u64>,
1855 transfer_freeze_object_cost_base: Option<u64>,
1857 transfer_share_object_cost_base: Option<u64>,
1859 transfer_receive_object_cost_base: Option<u64>,
1862 transfer_receive_object_cost_per_byte: Option<u64>,
1863 transfer_receive_object_type_cost_per_byte: Option<u64>,
1864
1865 tx_context_derive_id_cost_base: Option<u64>,
1868 tx_context_fresh_id_cost_base: Option<u64>,
1869 tx_context_sender_cost_base: Option<u64>,
1870 tx_context_epoch_cost_base: Option<u64>,
1871 tx_context_epoch_timestamp_ms_cost_base: Option<u64>,
1872 tx_context_sponsor_cost_base: Option<u64>,
1873 tx_context_rgp_cost_base: Option<u64>,
1874 tx_context_gas_price_cost_base: Option<u64>,
1875 tx_context_gas_budget_cost_base: Option<u64>,
1876 tx_context_ids_created_cost_base: Option<u64>,
1877 tx_context_replace_cost_base: Option<u64>,
1878
1879 types_is_one_time_witness_cost_base: Option<u64>,
1882 types_is_one_time_witness_type_tag_cost_per_byte: Option<u64>,
1883 types_is_one_time_witness_type_cost_per_byte: Option<u64>,
1884
1885 validator_validate_metadata_cost_base: Option<u64>,
1888 validator_validate_metadata_data_cost_per_byte: Option<u64>,
1889
1890 crypto_invalid_arguments_cost: Option<u64>,
1892 bls12381_bls12381_min_sig_verify_cost_base: Option<u64>,
1894 bls12381_bls12381_min_sig_verify_msg_cost_per_byte: Option<u64>,
1895 bls12381_bls12381_min_sig_verify_msg_cost_per_block: Option<u64>,
1896
1897 bls12381_bls12381_min_pk_verify_cost_base: Option<u64>,
1899 bls12381_bls12381_min_pk_verify_msg_cost_per_byte: Option<u64>,
1900 bls12381_bls12381_min_pk_verify_msg_cost_per_block: Option<u64>,
1901
1902 ecdsa_k1_ecrecover_keccak256_cost_base: Option<u64>,
1904 ecdsa_k1_ecrecover_keccak256_msg_cost_per_byte: Option<u64>,
1905 ecdsa_k1_ecrecover_keccak256_msg_cost_per_block: Option<u64>,
1906 ecdsa_k1_ecrecover_sha256_cost_base: Option<u64>,
1907 ecdsa_k1_ecrecover_sha256_msg_cost_per_byte: Option<u64>,
1908 ecdsa_k1_ecrecover_sha256_msg_cost_per_block: Option<u64>,
1909
1910 ecdsa_k1_decompress_pubkey_cost_base: Option<u64>,
1912
1913 ecdsa_k1_secp256k1_verify_keccak256_cost_base: Option<u64>,
1915 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_byte: Option<u64>,
1916 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_block: Option<u64>,
1917 ecdsa_k1_secp256k1_verify_sha256_cost_base: Option<u64>,
1918 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_byte: Option<u64>,
1919 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_block: Option<u64>,
1920
1921 ecdsa_r1_ecrecover_keccak256_cost_base: Option<u64>,
1923 ecdsa_r1_ecrecover_keccak256_msg_cost_per_byte: Option<u64>,
1924 ecdsa_r1_ecrecover_keccak256_msg_cost_per_block: Option<u64>,
1925 ecdsa_r1_ecrecover_sha256_cost_base: Option<u64>,
1926 ecdsa_r1_ecrecover_sha256_msg_cost_per_byte: Option<u64>,
1927 ecdsa_r1_ecrecover_sha256_msg_cost_per_block: Option<u64>,
1928
1929 ecdsa_r1_secp256r1_verify_keccak256_cost_base: Option<u64>,
1931 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_byte: Option<u64>,
1932 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_block: Option<u64>,
1933 ecdsa_r1_secp256r1_verify_sha256_cost_base: Option<u64>,
1934 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_byte: Option<u64>,
1935 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_block: Option<u64>,
1936
1937 ecvrf_ecvrf_verify_cost_base: Option<u64>,
1939 ecvrf_ecvrf_verify_alpha_string_cost_per_byte: Option<u64>,
1940 ecvrf_ecvrf_verify_alpha_string_cost_per_block: Option<u64>,
1941
1942 ed25519_ed25519_verify_cost_base: Option<u64>,
1944 ed25519_ed25519_verify_msg_cost_per_byte: Option<u64>,
1945 ed25519_ed25519_verify_msg_cost_per_block: Option<u64>,
1946
1947 groth16_prepare_verifying_key_bls12381_cost_base: Option<u64>,
1949 groth16_prepare_verifying_key_bn254_cost_base: Option<u64>,
1950
1951 groth16_verify_groth16_proof_internal_bls12381_cost_base: Option<u64>,
1953 groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input: Option<u64>,
1954 groth16_verify_groth16_proof_internal_bn254_cost_base: Option<u64>,
1955 groth16_verify_groth16_proof_internal_bn254_cost_per_public_input: Option<u64>,
1956 groth16_verify_groth16_proof_internal_public_input_cost_per_byte: Option<u64>,
1957
1958 hash_blake2b256_cost_base: Option<u64>,
1960 hash_blake2b256_data_cost_per_byte: Option<u64>,
1961 hash_blake2b256_data_cost_per_block: Option<u64>,
1962
1963 hash_keccak256_cost_base: Option<u64>,
1965 hash_keccak256_data_cost_per_byte: Option<u64>,
1966 hash_keccak256_data_cost_per_block: Option<u64>,
1967
1968 poseidon_bn254_cost_base: Option<u64>,
1970 poseidon_bn254_cost_per_block: Option<u64>,
1971
1972 group_ops_bls12381_decode_scalar_cost: Option<u64>,
1974 group_ops_bls12381_decode_g1_cost: Option<u64>,
1975 group_ops_bls12381_decode_g2_cost: Option<u64>,
1976 group_ops_bls12381_decode_gt_cost: Option<u64>,
1977 group_ops_bls12381_scalar_add_cost: Option<u64>,
1978 group_ops_bls12381_g1_add_cost: Option<u64>,
1979 group_ops_bls12381_g2_add_cost: Option<u64>,
1980 group_ops_bls12381_gt_add_cost: Option<u64>,
1981 group_ops_bls12381_scalar_sub_cost: Option<u64>,
1982 group_ops_bls12381_g1_sub_cost: Option<u64>,
1983 group_ops_bls12381_g2_sub_cost: Option<u64>,
1984 group_ops_bls12381_gt_sub_cost: Option<u64>,
1985 group_ops_bls12381_scalar_mul_cost: Option<u64>,
1986 group_ops_bls12381_g1_mul_cost: Option<u64>,
1987 group_ops_bls12381_g2_mul_cost: Option<u64>,
1988 group_ops_bls12381_gt_mul_cost: Option<u64>,
1989 group_ops_bls12381_scalar_div_cost: Option<u64>,
1990 group_ops_bls12381_g1_div_cost: Option<u64>,
1991 group_ops_bls12381_g2_div_cost: Option<u64>,
1992 group_ops_bls12381_gt_div_cost: Option<u64>,
1993 group_ops_bls12381_g1_hash_to_base_cost: Option<u64>,
1994 group_ops_bls12381_g2_hash_to_base_cost: Option<u64>,
1995 group_ops_bls12381_g1_hash_to_cost_per_byte: Option<u64>,
1996 group_ops_bls12381_g2_hash_to_cost_per_byte: Option<u64>,
1997 group_ops_bls12381_g1_msm_base_cost: Option<u64>,
1998 group_ops_bls12381_g2_msm_base_cost: Option<u64>,
1999 group_ops_bls12381_g1_msm_base_cost_per_input: Option<u64>,
2000 group_ops_bls12381_g2_msm_base_cost_per_input: Option<u64>,
2001 group_ops_bls12381_msm_max_len: Option<u32>,
2002 group_ops_bls12381_pairing_cost: Option<u64>,
2003 group_ops_bls12381_g1_to_uncompressed_g1_cost: Option<u64>,
2004 group_ops_bls12381_uncompressed_g1_to_g1_cost: Option<u64>,
2005 group_ops_bls12381_uncompressed_g1_sum_base_cost: Option<u64>,
2006 group_ops_bls12381_uncompressed_g1_sum_cost_per_term: Option<u64>,
2007 group_ops_bls12381_uncompressed_g1_sum_max_terms: Option<u64>,
2008
2009 group_ops_ristretto_decode_scalar_cost: Option<u64>,
2010 group_ops_ristretto_decode_point_cost: Option<u64>,
2011 group_ops_ristretto_scalar_add_cost: Option<u64>,
2012 group_ops_ristretto_point_add_cost: Option<u64>,
2013 group_ops_ristretto_scalar_sub_cost: Option<u64>,
2014 group_ops_ristretto_point_sub_cost: Option<u64>,
2015 group_ops_ristretto_scalar_mul_cost: Option<u64>,
2016 group_ops_ristretto_point_mul_cost: Option<u64>,
2017 group_ops_ristretto_scalar_div_cost: Option<u64>,
2018 group_ops_ristretto_point_div_cost: Option<u64>,
2019
2020 verify_bulletproofs_ristretto255_base_cost: Option<u64>,
2021 verify_bulletproofs_ristretto255_cost_per_bit_and_commitment: Option<u64>,
2022 max_bulletproofs_total_bits: Option<u64>,
2025
2026 hmac_hmac_sha3_256_cost_base: Option<u64>,
2028 hmac_hmac_sha3_256_input_cost_per_byte: Option<u64>,
2029 hmac_hmac_sha3_256_input_cost_per_block: Option<u64>,
2030
2031 check_zklogin_id_cost_base: Option<u64>,
2033 check_zklogin_issuer_cost_base: Option<u64>,
2035
2036 vdf_verify_vdf_cost: Option<u64>,
2037 vdf_hash_to_input_cost: Option<u64>,
2038
2039 nitro_attestation_parse_base_cost: Option<u64>,
2041 nitro_attestation_parse_cost_per_byte: Option<u64>,
2042 nitro_attestation_verify_base_cost: Option<u64>,
2043 nitro_attestation_verify_cost_per_cert: Option<u64>,
2044
2045 bcs_per_byte_serialized_cost: Option<u64>,
2047 bcs_legacy_min_output_size_cost: Option<u64>,
2048 bcs_failure_cost: Option<u64>,
2049
2050 hash_sha2_256_base_cost: Option<u64>,
2051 hash_sha2_256_per_byte_cost: Option<u64>,
2052 hash_sha2_256_legacy_min_input_len_cost: Option<u64>,
2053 hash_sha3_256_base_cost: Option<u64>,
2054 hash_sha3_256_per_byte_cost: Option<u64>,
2055 hash_sha3_256_legacy_min_input_len_cost: Option<u64>,
2056 type_name_get_base_cost: Option<u64>,
2057 type_name_get_per_byte_cost: Option<u64>,
2058 type_name_id_base_cost: Option<u64>,
2059
2060 string_check_utf8_base_cost: Option<u64>,
2061 string_check_utf8_per_byte_cost: Option<u64>,
2062 string_is_char_boundary_base_cost: Option<u64>,
2063 string_sub_string_base_cost: Option<u64>,
2064 string_sub_string_per_byte_cost: Option<u64>,
2065 string_index_of_base_cost: Option<u64>,
2066 string_index_of_per_byte_pattern_cost: Option<u64>,
2067 string_index_of_per_byte_searched_cost: Option<u64>,
2068
2069 vector_empty_base_cost: Option<u64>,
2070 vector_length_base_cost: Option<u64>,
2071 vector_push_back_base_cost: Option<u64>,
2072 vector_push_back_legacy_per_abstract_memory_unit_cost: Option<u64>,
2073 vector_borrow_base_cost: Option<u64>,
2074 vector_pop_back_base_cost: Option<u64>,
2075 vector_destroy_empty_base_cost: Option<u64>,
2076 vector_swap_base_cost: Option<u64>,
2077 debug_print_base_cost: Option<u64>,
2078 debug_print_stack_trace_base_cost: Option<u64>,
2079
2080 #[custom_setter]
2090 execution_version: Option<u64>,
2091
2092 consensus_bad_nodes_stake_threshold: Option<u64>,
2096
2097 max_jwk_votes_per_validator_per_epoch: Option<u64>,
2098 max_age_of_jwk_in_epochs: Option<u64>,
2102
2103 random_beacon_reduction_allowed_delta: Option<u16>,
2107
2108 random_beacon_reduction_lower_bound: Option<u32>,
2111
2112 random_beacon_dkg_timeout_round: Option<u32>,
2115
2116 random_beacon_min_round_interval_ms: Option<u64>,
2118
2119 random_beacon_dkg_version: Option<u64>,
2122
2123 consensus_max_transaction_size_bytes: Option<u64>,
2126 consensus_max_transactions_in_block_bytes: Option<u64>,
2128 consensus_max_num_transactions_in_block: Option<u64>,
2130
2131 consensus_voting_rounds: Option<u32>,
2133
2134 max_accumulated_txn_cost_per_object_in_narwhal_commit: Option<u64>,
2136
2137 max_deferral_rounds_for_congestion_control: Option<u64>,
2140
2141 epoch_close_deadline_ms: Option<u64>,
2146
2147 max_txn_cost_overage_per_object_in_commit: Option<u64>,
2149
2150 allowed_txn_cost_overage_burst_per_object_in_commit: Option<u64>,
2152
2153 min_checkpoint_interval_ms: Option<u64>,
2155
2156 checkpoint_summary_version_specific_data: Option<u64>,
2158
2159 max_soft_bundle_size: Option<u64>,
2161
2162 bridge_should_try_to_finalize_committee: Option<bool>,
2166
2167 max_accumulated_txn_cost_per_object_in_mysticeti_commit: Option<u64>,
2173
2174 max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit: Option<u64>,
2177
2178 consensus_gc_depth: Option<u32>,
2181
2182 gas_budget_based_txn_cost_cap_factor: Option<u64>,
2184
2185 gas_budget_based_txn_cost_absolute_cap_commit_count: Option<u64>,
2187
2188 sip_45_consensus_amplification_threshold: Option<u64>,
2191
2192 use_object_per_epoch_marker_table_v2: Option<bool>,
2195
2196 consensus_commit_rate_estimation_window_size: Option<u32>,
2198
2199 #[serde(skip_serializing_if = "Vec::is_empty")]
2203 aliased_addresses: Vec<AliasedAddress>,
2204
2205 translation_per_command_base_charge: Option<u64>,
2208
2209 translation_per_input_base_charge: Option<u64>,
2212
2213 translation_pure_input_per_byte_charge: Option<u64>,
2215
2216 translation_per_type_node_charge: Option<u64>,
2220
2221 translation_per_reference_node_charge: Option<u64>,
2224
2225 translation_per_linkage_entry_charge: Option<u64>,
2228
2229 max_updates_per_settlement_txn: Option<u32>,
2231
2232 gasless_max_computation_units: Option<u64>,
2234
2235 gasless_allowed_token_types: Option<Vec<(String, u64)>>,
2237
2238 gasless_max_unused_inputs: Option<u64>,
2242
2243 gasless_max_pure_input_bytes: Option<u64>,
2246
2247 gasless_max_tps: Option<u64>,
2249
2250 #[serde(skip_serializing_if = "Option::is_none")]
2251 #[skip_accessor]
2252 include_special_package_amendments: Option<Arc<Amendments>>,
2253
2254 gasless_max_tx_size_bytes: Option<u64>,
2257
2258 translation_per_live_reference_charge: Option<u64>,
2261
2262 max_ptb_live_references: Option<u64>,
2265
2266 max_ptb_returned_references: Option<u64>,
2269
2270 max_ptb_total_returned_references: Option<u64>,
2273}
2274
2275#[derive(Clone, Serialize, Deserialize, Debug)]
2277pub struct AliasedAddress {
2278 pub original: [u8; 32],
2280 pub aliased: [u8; 32],
2282 pub allowed_tx_digests: Vec<[u8; 32]>,
2284}
2285
2286impl ProtocolConfig {
2288 pub fn chain(&self) -> Chain {
2290 self.chain
2291 }
2292
2293 pub fn check_package_upgrades_supported(&self) -> Result<(), Error> {
2306 if self.feature_flags.package_upgrades {
2307 Ok(())
2308 } else {
2309 Err(Error(format!(
2310 "package upgrades are not supported at {:?}",
2311 self.version
2312 )))
2313 }
2314 }
2315
2316 pub fn zklogin_supported_providers(&self) -> &BTreeSet<String> {
2317 &self.feature_flags.zklogin_supported_providers
2318 }
2319
2320 pub fn zklogin_circuit_mode(&self) -> u64 {
2323 self.feature_flags.zklogin_circuit_mode
2324 }
2325
2326 pub fn consensus_transaction_ordering(&self) -> ConsensusTransactionOrdering {
2327 self.feature_flags.consensus_transaction_ordering
2328 }
2329
2330 pub fn enable_jwk_consensus_updates(&self) -> bool {
2331 let ret = self.feature_flags.enable_jwk_consensus_updates;
2332 if ret {
2333 assert!(self.feature_flags.end_of_epoch_transaction_supported);
2335 }
2336 ret
2337 }
2338
2339 pub fn end_of_epoch_transaction_supported(&self) -> bool {
2340 let ret = self.feature_flags.end_of_epoch_transaction_supported;
2341 if !ret {
2342 assert!(!self.feature_flags.enable_jwk_consensus_updates);
2344 }
2345 ret
2346 }
2347
2348 pub fn dkg_version(&self) -> u64 {
2349 self.random_beacon_dkg_version.unwrap_or(1)
2351 }
2352
2353 pub fn bridge(&self) -> bool {
2354 let ret = self.feature_flags.bridge;
2355 if ret {
2356 assert!(self.feature_flags.end_of_epoch_transaction_supported);
2358 }
2359 ret
2360 }
2361
2362 pub fn should_try_to_finalize_bridge_committee(&self) -> bool {
2363 if !self.bridge() {
2364 return false;
2365 }
2366 self.bridge_should_try_to_finalize_committee.unwrap_or(true)
2368 }
2369
2370 pub fn zklogin_max_epoch_upper_bound_delta(&self) -> Option<u64> {
2371 self.feature_flags.zklogin_max_epoch_upper_bound_delta
2372 }
2373
2374 pub fn enable_allowances(&self) -> bool {
2375 self.feature_flags.enable_allowances && self.enable_accumulators()
2376 }
2377
2378 pub fn enable_coin_reservation_obj_refs(&self) -> bool {
2379 self.new_vm_enabled() && self.feature_flags.enable_coin_reservation_obj_refs
2380 }
2381
2382 pub fn enable_authenticated_event_streams(&self) -> bool {
2383 self.feature_flags.enable_authenticated_event_streams && self.enable_accumulators()
2384 }
2385
2386 pub fn per_object_congestion_control_mode(&self) -> PerObjectCongestionControlMode {
2387 self.feature_flags.per_object_congestion_control_mode
2388 }
2389
2390 pub fn consensus_choice(&self) -> ConsensusChoice {
2391 self.feature_flags.consensus_choice
2392 }
2393
2394 pub fn consensus_network(&self) -> ConsensusNetwork {
2395 self.feature_flags.consensus_network
2396 }
2397
2398 pub fn mysticeti_num_leaders_per_round(&self) -> Option<usize> {
2399 self.feature_flags.mysticeti_num_leaders_per_round
2400 }
2401
2402 pub fn max_transaction_size_bytes(&self) -> u64 {
2403 self.consensus_max_transaction_size_bytes
2405 .unwrap_or(256 * 1024)
2406 }
2407
2408 pub fn max_transactions_in_block_bytes(&self) -> u64 {
2409 if cfg!(msim) {
2410 256 * 1024
2411 } else {
2412 self.consensus_max_transactions_in_block_bytes
2413 .unwrap_or(512 * 1024)
2414 }
2415 }
2416
2417 pub fn max_num_transactions_in_block(&self) -> u64 {
2418 if cfg!(msim) {
2419 8
2420 } else {
2421 self.consensus_max_num_transactions_in_block.unwrap_or(512)
2422 }
2423 }
2424
2425 pub fn gc_depth(&self) -> u32 {
2426 self.consensus_gc_depth.unwrap_or(0)
2427 }
2428
2429 pub fn consensus_linearize_subdag_v2(&self) -> bool {
2430 let res = self.feature_flags.consensus_linearize_subdag_v2;
2431 assert!(
2432 !res || self.gc_depth() > 0,
2433 "The consensus linearize sub dag V2 requires GC to be enabled"
2434 );
2435 res
2436 }
2437
2438 pub fn consensus_median_based_commit_timestamp(&self) -> bool {
2439 let res = self.feature_flags.consensus_median_based_commit_timestamp;
2440 assert!(
2441 !res || self.gc_depth() > 0,
2442 "The consensus median based commit timestamp requires GC to be enabled"
2443 );
2444 res
2445 }
2446
2447 pub fn get_consensus_commit_rate_estimation_window_size(&self) -> u32 {
2448 self.consensus_commit_rate_estimation_window_size
2449 .unwrap_or(0)
2450 }
2451
2452 pub fn consensus_num_requested_prior_commits_at_startup(&self) -> u32 {
2453 let window_size = self.get_consensus_commit_rate_estimation_window_size();
2457 assert!(window_size == 0 || self.record_additional_state_digest_in_prologue());
2459 window_size
2460 }
2461
2462 pub fn address_aliases(&self) -> bool {
2463 let address_aliases = self.feature_flags.address_aliases;
2464 assert!(
2465 !address_aliases || self.mysticeti_fastpath(),
2466 "Address aliases requires Mysticeti fastpath to be enabled"
2467 );
2468 if address_aliases {
2469 assert!(
2470 self.feature_flags.disable_preconsensus_locking,
2471 "Address aliases requires CertifiedTransaction to be disabled"
2472 );
2473 }
2474 address_aliases
2475 }
2476
2477 pub fn new_vm_enabled(&self) -> bool {
2478 self.execution_version.is_some_and(|v| v >= 4)
2479 }
2480
2481 pub fn gasless_allowed_token_types(&self) -> &[(String, u64)] {
2482 debug_assert!(self.gasless_allowed_token_types.is_some());
2483 self.gasless_allowed_token_types.as_deref().unwrap_or(&[])
2484 }
2485
2486 pub fn get_gasless_max_unused_inputs(&self) -> u64 {
2487 self.gasless_max_unused_inputs.unwrap_or(u64::MAX)
2488 }
2489
2490 pub fn get_gasless_max_pure_input_bytes(&self) -> u64 {
2491 self.gasless_max_pure_input_bytes.unwrap_or(u64::MAX)
2492 }
2493
2494 pub fn get_gasless_max_tx_size_bytes(&self) -> u64 {
2495 self.gasless_max_tx_size_bytes.unwrap_or(u64::MAX)
2496 }
2497
2498 pub fn include_special_package_amendments_as_option(&self) -> &Option<Arc<Amendments>> {
2499 &self.include_special_package_amendments
2500 }
2501}
2502
2503static POISON_VERSION_METHODS: AtomicBool = AtomicBool::new(false);
2504
2505impl ProtocolConfig {
2507 pub fn get_for_version(version: ProtocolVersion, chain: Chain) -> Self {
2509 assert!(
2511 version >= ProtocolVersion::MIN,
2512 "Network protocol version is {:?}, but the minimum supported version by the binary is {:?}. Please upgrade the binary.",
2513 version,
2514 ProtocolVersion::MIN.0,
2515 );
2516 assert!(
2517 version <= ProtocolVersion::MAX_ALLOWED,
2518 "Network protocol version is {:?}, but the maximum supported version by the binary is {:?}. Please upgrade the binary.",
2519 version,
2520 ProtocolVersion::MAX_ALLOWED.0,
2521 );
2522
2523 let mut ret = Self::get_for_version_impl(version, chain);
2524 ret.version = version;
2525 ret.chain = chain;
2526
2527 ret = Self::apply_config_override(version, ret);
2528
2529 if std::env::var("SUI_PROTOCOL_CONFIG_OVERRIDE_ENABLE").is_ok() {
2530 warn!(
2531 "overriding ProtocolConfig settings with custom settings; this may break non-local networks"
2532 );
2533 let overrides: ProtocolConfigOptional =
2534 serde_env::from_env_with_prefix("SUI_PROTOCOL_CONFIG_OVERRIDE")
2535 .expect("failed to parse ProtocolConfig override env variables");
2536 overrides.apply_to(&mut ret);
2537 }
2538
2539 ret
2540 }
2541
2542 pub fn get_for_version_if_supported(version: ProtocolVersion, chain: Chain) -> Option<Self> {
2545 if version.0 >= ProtocolVersion::MIN.0 && version.0 <= ProtocolVersion::MAX_ALLOWED.0 {
2546 let mut ret = Self::get_for_version_impl(version, chain);
2547 ret.version = version;
2548 ret.chain = chain;
2549 ret = Self::apply_config_override(version, ret);
2550 Some(ret)
2551 } else {
2552 None
2553 }
2554 }
2555
2556 pub fn poison_get_for_min_version() {
2557 POISON_VERSION_METHODS.store(true, Ordering::Relaxed);
2558 }
2559
2560 fn load_poison_get_for_min_version() -> bool {
2561 POISON_VERSION_METHODS.load(Ordering::Relaxed)
2562 }
2563
2564 pub fn get_for_min_version() -> Self {
2567 if Self::load_poison_get_for_min_version() {
2568 panic!("get_for_min_version called on validator");
2569 }
2570 ProtocolConfig::get_for_version(ProtocolVersion::MIN, Chain::Unknown)
2571 }
2572
2573 #[allow(non_snake_case)]
2583 pub fn get_for_max_version_UNSAFE() -> Self {
2584 if Self::load_poison_get_for_min_version() {
2585 panic!("get_for_max_version_UNSAFE called on validator");
2586 }
2587 ProtocolConfig::get_for_version(ProtocolVersion::MAX, Chain::Unknown)
2588 }
2589
2590 fn get_for_version_impl(version: ProtocolVersion, chain: Chain) -> Self {
2591 #[cfg(msim)]
2592 {
2593 if version == ProtocolVersion::MAX_ALLOWED {
2595 let mut config = Self::get_for_version_impl(version - 1, Chain::Unknown);
2596 config.base_tx_cost_fixed = Some(config.base_tx_cost_fixed() + 1000);
2597 return config;
2598 }
2599 }
2600
2601 let mut cfg = Self {
2604 version,
2606 chain,
2607
2608 feature_flags: Default::default(),
2610
2611 max_tx_size_bytes: Some(128 * 1024),
2612 max_input_objects: Some(2048),
2614 max_serialized_tx_effects_size_bytes: Some(512 * 1024),
2615 max_serialized_tx_effects_size_bytes_system_tx: Some(512 * 1024 * 16),
2616 max_gas_payment_objects: Some(256),
2617 max_modules_in_publish: Some(128),
2618 max_package_dependencies: None,
2619 max_arguments: Some(512),
2620 max_type_arguments: Some(16),
2621 max_type_argument_depth: Some(16),
2622 max_pure_argument_size: Some(16 * 1024),
2623 max_programmable_tx_commands: Some(1024),
2624 move_binary_format_version: Some(6),
2625 min_move_binary_format_version: None,
2626 binary_module_handles: None,
2627 binary_struct_handles: None,
2628 binary_function_handles: None,
2629 binary_function_instantiations: None,
2630 binary_signatures: None,
2631 binary_constant_pool: None,
2632 binary_identifiers: None,
2633 binary_address_identifiers: None,
2634 binary_struct_defs: None,
2635 binary_struct_def_instantiations: None,
2636 binary_function_defs: None,
2637 binary_field_handles: None,
2638 binary_field_instantiations: None,
2639 binary_friend_decls: None,
2640 binary_enum_defs: None,
2641 binary_enum_def_instantiations: None,
2642 binary_variant_handles: None,
2643 binary_variant_instantiation_handles: None,
2644 max_move_object_size: Some(250 * 1024),
2645 max_move_package_size: Some(100 * 1024),
2646 max_publish_or_upgrade_per_ptb: None,
2647 max_tx_gas: Some(10_000_000_000),
2648 max_gas_price: Some(100_000),
2649 max_gas_price_rgp_factor_for_aborted_transactions: None,
2650 max_gas_computation_bucket: Some(5_000_000),
2651 max_loop_depth: Some(5),
2652 max_generic_instantiation_length: Some(32),
2653 max_function_parameters: Some(128),
2654 max_basic_blocks: Some(1024),
2655 max_value_stack_size: Some(1024),
2656 max_type_nodes: Some(256),
2657 max_generic_instantiation_type_nodes_per_function: None,
2658 max_generic_instantiation_type_nodes_per_module: None,
2659 max_accumulator_type_nodes: None,
2660 max_push_size: Some(10000),
2661 max_struct_definitions: Some(200),
2662 max_function_definitions: Some(1000),
2663 max_fields_in_struct: Some(32),
2664 max_dependency_depth: Some(100),
2665 max_num_event_emit: Some(256),
2666 max_num_new_move_object_ids: Some(2048),
2667 max_num_new_move_object_ids_system_tx: Some(2048 * 16),
2668 max_num_deleted_move_object_ids: Some(2048),
2669 max_num_deleted_move_object_ids_system_tx: Some(2048 * 16),
2670 max_num_transferred_move_object_ids: Some(2048),
2671 max_num_transferred_move_object_ids_system_tx: Some(2048 * 16),
2672 max_event_emit_size: Some(250 * 1024),
2673 max_move_vector_len: Some(256 * 1024),
2674 max_type_to_layout_nodes: None,
2675 max_ptb_value_size: None,
2676
2677 max_back_edges_per_function: Some(10_000),
2678 max_back_edges_per_module: Some(10_000),
2679 max_verifier_meter_ticks_per_function: Some(6_000_000),
2680 max_meter_ticks_per_module: Some(6_000_000),
2681 max_meter_ticks_per_package: None,
2682
2683 object_runtime_max_num_cached_objects: Some(1000),
2684 object_runtime_max_num_cached_objects_system_tx: Some(1000 * 16),
2685 object_runtime_max_num_store_entries: Some(1000),
2686 object_runtime_max_num_store_entries_system_tx: Some(1000 * 16),
2687 base_tx_cost_fixed: Some(110_000),
2688 package_publish_cost_fixed: Some(1_000),
2689 base_tx_cost_per_byte: Some(0),
2690 package_publish_cost_per_byte: Some(80),
2691 obj_access_cost_read_per_byte: Some(15),
2692 obj_access_cost_mutate_per_byte: Some(40),
2693 obj_access_cost_delete_per_byte: Some(40),
2694 obj_access_cost_verify_per_byte: Some(200),
2695 obj_data_cost_refundable: Some(100),
2696 obj_metadata_cost_non_refundable: Some(50),
2697 gas_model_version: Some(1),
2698 storage_rebate_rate: Some(9900),
2699 storage_fund_reinvest_rate: Some(500),
2700 reward_slashing_rate: Some(5000),
2701 storage_gas_price: Some(1),
2702 accumulator_object_storage_cost: None,
2703 max_transactions_per_checkpoint: Some(10_000),
2704 max_checkpoint_size_bytes: Some(30 * 1024 * 1024),
2705
2706 buffer_stake_for_protocol_upgrade_bps: Some(0),
2709
2710 address_from_bytes_cost_base: Some(52),
2714 address_to_u256_cost_base: Some(52),
2716 address_from_u256_cost_base: Some(52),
2718
2719 config_read_setting_impl_cost_base: None,
2722 config_read_setting_impl_cost_per_byte: None,
2723
2724 package_original_package_id_impl_cost_base: None,
2725 package_original_package_id_impl_cost_per_byte: None,
2726
2727 dynamic_field_hash_type_and_key_cost_base: Some(100),
2730 dynamic_field_hash_type_and_key_type_cost_per_byte: Some(2),
2731 dynamic_field_hash_type_and_key_value_cost_per_byte: Some(2),
2732 dynamic_field_hash_type_and_key_type_tag_cost_per_byte: Some(2),
2733 dynamic_field_add_child_object_cost_base: Some(100),
2735 dynamic_field_add_child_object_type_cost_per_byte: Some(10),
2736 dynamic_field_add_child_object_value_cost_per_byte: Some(10),
2737 dynamic_field_add_child_object_struct_tag_cost_per_byte: Some(10),
2738 dynamic_field_borrow_child_object_cost_base: Some(100),
2740 dynamic_field_borrow_child_object_child_ref_cost_per_byte: Some(10),
2741 dynamic_field_borrow_child_object_type_cost_per_byte: Some(10),
2742 dynamic_field_remove_child_object_cost_base: Some(100),
2744 dynamic_field_remove_child_object_child_cost_per_byte: Some(2),
2745 dynamic_field_remove_child_object_type_cost_per_byte: Some(2),
2746 dynamic_field_has_child_object_cost_base: Some(100),
2748 dynamic_field_has_child_object_with_ty_cost_base: Some(100),
2750 dynamic_field_has_child_object_with_ty_type_cost_per_byte: Some(2),
2751 dynamic_field_has_child_object_with_ty_type_tag_cost_per_byte: Some(2),
2752
2753 scratch_add_cost_base: None,
2755 scratch_read_cost_base: None,
2756 scratch_read_value_cost: None,
2757 scratch_remove_cost_base: None,
2758 scratch_exists_cost_base: None,
2759 scratch_exists_with_type_cost_base: None,
2760 scratch_exists_with_type_type_cost: None,
2761 max_scratch_pad_size: None,
2762
2763 event_emit_cost_base: Some(52),
2766 event_emit_value_size_derivation_cost_per_byte: Some(2),
2767 event_emit_tag_size_derivation_cost_per_byte: Some(5),
2768 event_emit_output_cost_per_byte: Some(10),
2769 event_emit_auth_stream_cost: None,
2770
2771 reserve_object_funds_for_withdrawal_cost_base: None,
2773 reserve_object_funds_for_withdrawal_cold_read_cost: None,
2774
2775 object_borrow_uid_cost_base: Some(52),
2778 object_delete_impl_cost_base: Some(52),
2780 object_record_new_uid_cost_base: Some(52),
2782 object_record_new_uid_from_hash_cost_base: None,
2785
2786 transfer_transfer_internal_cost_base: Some(52),
2789 transfer_party_transfer_internal_cost_base: None,
2791 transfer_freeze_object_cost_base: Some(52),
2793 transfer_share_object_cost_base: Some(52),
2795 transfer_receive_object_cost_base: None,
2796 transfer_receive_object_type_cost_per_byte: None,
2797 transfer_receive_object_cost_per_byte: None,
2798
2799 tx_context_derive_id_cost_base: Some(52),
2802 tx_context_fresh_id_cost_base: None,
2803 tx_context_sender_cost_base: None,
2804 tx_context_epoch_cost_base: None,
2805 tx_context_epoch_timestamp_ms_cost_base: None,
2806 tx_context_sponsor_cost_base: None,
2807 tx_context_rgp_cost_base: None,
2808 tx_context_gas_price_cost_base: None,
2809 tx_context_gas_budget_cost_base: None,
2810 tx_context_ids_created_cost_base: None,
2811 tx_context_replace_cost_base: None,
2812
2813 types_is_one_time_witness_cost_base: Some(52),
2816 types_is_one_time_witness_type_tag_cost_per_byte: Some(2),
2817 types_is_one_time_witness_type_cost_per_byte: Some(2),
2818
2819 validator_validate_metadata_cost_base: Some(52),
2822 validator_validate_metadata_data_cost_per_byte: Some(2),
2823
2824 crypto_invalid_arguments_cost: Some(100),
2826 bls12381_bls12381_min_sig_verify_cost_base: Some(52),
2828 bls12381_bls12381_min_sig_verify_msg_cost_per_byte: Some(2),
2829 bls12381_bls12381_min_sig_verify_msg_cost_per_block: Some(2),
2830
2831 bls12381_bls12381_min_pk_verify_cost_base: Some(52),
2833 bls12381_bls12381_min_pk_verify_msg_cost_per_byte: Some(2),
2834 bls12381_bls12381_min_pk_verify_msg_cost_per_block: Some(2),
2835
2836 ecdsa_k1_ecrecover_keccak256_cost_base: Some(52),
2838 ecdsa_k1_ecrecover_keccak256_msg_cost_per_byte: Some(2),
2839 ecdsa_k1_ecrecover_keccak256_msg_cost_per_block: Some(2),
2840 ecdsa_k1_ecrecover_sha256_cost_base: Some(52),
2841 ecdsa_k1_ecrecover_sha256_msg_cost_per_byte: Some(2),
2842 ecdsa_k1_ecrecover_sha256_msg_cost_per_block: Some(2),
2843
2844 ecdsa_k1_decompress_pubkey_cost_base: Some(52),
2846
2847 ecdsa_k1_secp256k1_verify_keccak256_cost_base: Some(52),
2849 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_byte: Some(2),
2850 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_block: Some(2),
2851 ecdsa_k1_secp256k1_verify_sha256_cost_base: Some(52),
2852 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_byte: Some(2),
2853 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_block: Some(2),
2854
2855 ecdsa_r1_ecrecover_keccak256_cost_base: Some(52),
2857 ecdsa_r1_ecrecover_keccak256_msg_cost_per_byte: Some(2),
2858 ecdsa_r1_ecrecover_keccak256_msg_cost_per_block: Some(2),
2859 ecdsa_r1_ecrecover_sha256_cost_base: Some(52),
2860 ecdsa_r1_ecrecover_sha256_msg_cost_per_byte: Some(2),
2861 ecdsa_r1_ecrecover_sha256_msg_cost_per_block: Some(2),
2862
2863 ecdsa_r1_secp256r1_verify_keccak256_cost_base: Some(52),
2865 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_byte: Some(2),
2866 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_block: Some(2),
2867 ecdsa_r1_secp256r1_verify_sha256_cost_base: Some(52),
2868 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_byte: Some(2),
2869 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_block: Some(2),
2870
2871 ecvrf_ecvrf_verify_cost_base: Some(52),
2873 ecvrf_ecvrf_verify_alpha_string_cost_per_byte: Some(2),
2874 ecvrf_ecvrf_verify_alpha_string_cost_per_block: Some(2),
2875
2876 ed25519_ed25519_verify_cost_base: Some(52),
2878 ed25519_ed25519_verify_msg_cost_per_byte: Some(2),
2879 ed25519_ed25519_verify_msg_cost_per_block: Some(2),
2880
2881 groth16_prepare_verifying_key_bls12381_cost_base: Some(52),
2883 groth16_prepare_verifying_key_bn254_cost_base: Some(52),
2884
2885 groth16_verify_groth16_proof_internal_bls12381_cost_base: Some(52),
2887 groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input: Some(2),
2888 groth16_verify_groth16_proof_internal_bn254_cost_base: Some(52),
2889 groth16_verify_groth16_proof_internal_bn254_cost_per_public_input: Some(2),
2890 groth16_verify_groth16_proof_internal_public_input_cost_per_byte: Some(2),
2891
2892 hash_blake2b256_cost_base: Some(52),
2894 hash_blake2b256_data_cost_per_byte: Some(2),
2895 hash_blake2b256_data_cost_per_block: Some(2),
2896
2897 hash_keccak256_cost_base: Some(52),
2899 hash_keccak256_data_cost_per_byte: Some(2),
2900 hash_keccak256_data_cost_per_block: Some(2),
2901
2902 poseidon_bn254_cost_base: None,
2903 poseidon_bn254_cost_per_block: None,
2904
2905 hmac_hmac_sha3_256_cost_base: Some(52),
2907 hmac_hmac_sha3_256_input_cost_per_byte: Some(2),
2908 hmac_hmac_sha3_256_input_cost_per_block: Some(2),
2909
2910 group_ops_bls12381_decode_scalar_cost: None,
2912 group_ops_bls12381_decode_g1_cost: None,
2913 group_ops_bls12381_decode_g2_cost: None,
2914 group_ops_bls12381_decode_gt_cost: None,
2915 group_ops_bls12381_scalar_add_cost: None,
2916 group_ops_bls12381_g1_add_cost: None,
2917 group_ops_bls12381_g2_add_cost: None,
2918 group_ops_bls12381_gt_add_cost: None,
2919 group_ops_bls12381_scalar_sub_cost: None,
2920 group_ops_bls12381_g1_sub_cost: None,
2921 group_ops_bls12381_g2_sub_cost: None,
2922 group_ops_bls12381_gt_sub_cost: None,
2923 group_ops_bls12381_scalar_mul_cost: None,
2924 group_ops_bls12381_g1_mul_cost: None,
2925 group_ops_bls12381_g2_mul_cost: None,
2926 group_ops_bls12381_gt_mul_cost: None,
2927 group_ops_bls12381_scalar_div_cost: None,
2928 group_ops_bls12381_g1_div_cost: None,
2929 group_ops_bls12381_g2_div_cost: None,
2930 group_ops_bls12381_gt_div_cost: None,
2931 group_ops_bls12381_g1_hash_to_base_cost: None,
2932 group_ops_bls12381_g2_hash_to_base_cost: None,
2933 group_ops_bls12381_g1_hash_to_cost_per_byte: None,
2934 group_ops_bls12381_g2_hash_to_cost_per_byte: None,
2935 group_ops_bls12381_g1_msm_base_cost: None,
2936 group_ops_bls12381_g2_msm_base_cost: None,
2937 group_ops_bls12381_g1_msm_base_cost_per_input: None,
2938 group_ops_bls12381_g2_msm_base_cost_per_input: None,
2939 group_ops_bls12381_msm_max_len: None,
2940 group_ops_bls12381_pairing_cost: None,
2941 group_ops_bls12381_g1_to_uncompressed_g1_cost: None,
2942 group_ops_bls12381_uncompressed_g1_to_g1_cost: None,
2943 group_ops_bls12381_uncompressed_g1_sum_base_cost: None,
2944 group_ops_bls12381_uncompressed_g1_sum_cost_per_term: None,
2945 group_ops_bls12381_uncompressed_g1_sum_max_terms: None,
2946
2947 group_ops_ristretto_decode_scalar_cost: None,
2948 group_ops_ristretto_decode_point_cost: None,
2949 group_ops_ristretto_scalar_add_cost: None,
2950 group_ops_ristretto_point_add_cost: None,
2951 group_ops_ristretto_scalar_sub_cost: None,
2952 group_ops_ristretto_point_sub_cost: None,
2953 group_ops_ristretto_scalar_mul_cost: None,
2954 group_ops_ristretto_point_mul_cost: None,
2955 group_ops_ristretto_scalar_div_cost: None,
2956 group_ops_ristretto_point_div_cost: None,
2957
2958 verify_bulletproofs_ristretto255_base_cost: None,
2959 verify_bulletproofs_ristretto255_cost_per_bit_and_commitment: None,
2960 max_bulletproofs_total_bits: None,
2961
2962 check_zklogin_id_cost_base: None,
2964 check_zklogin_issuer_cost_base: None,
2966
2967 vdf_verify_vdf_cost: None,
2968 vdf_hash_to_input_cost: None,
2969
2970 nitro_attestation_parse_base_cost: None,
2972 nitro_attestation_parse_cost_per_byte: None,
2973 nitro_attestation_verify_base_cost: None,
2974 nitro_attestation_verify_cost_per_cert: None,
2975
2976 bcs_per_byte_serialized_cost: None,
2977 bcs_legacy_min_output_size_cost: None,
2978 bcs_failure_cost: None,
2979 hash_sha2_256_base_cost: None,
2980 hash_sha2_256_per_byte_cost: None,
2981 hash_sha2_256_legacy_min_input_len_cost: None,
2982 hash_sha3_256_base_cost: None,
2983 hash_sha3_256_per_byte_cost: None,
2984 hash_sha3_256_legacy_min_input_len_cost: None,
2985 type_name_get_base_cost: None,
2986 type_name_get_per_byte_cost: None,
2987 type_name_id_base_cost: None,
2988 string_check_utf8_base_cost: None,
2989 string_check_utf8_per_byte_cost: None,
2990 string_is_char_boundary_base_cost: None,
2991 string_sub_string_base_cost: None,
2992 string_sub_string_per_byte_cost: None,
2993 string_index_of_base_cost: None,
2994 string_index_of_per_byte_pattern_cost: None,
2995 string_index_of_per_byte_searched_cost: None,
2996 vector_empty_base_cost: None,
2997 vector_length_base_cost: None,
2998 vector_push_back_base_cost: None,
2999 vector_push_back_legacy_per_abstract_memory_unit_cost: None,
3000 vector_borrow_base_cost: None,
3001 vector_pop_back_base_cost: None,
3002 vector_destroy_empty_base_cost: None,
3003 vector_swap_base_cost: None,
3004 debug_print_base_cost: None,
3005 debug_print_stack_trace_base_cost: None,
3006
3007 max_size_written_objects: None,
3008 max_size_written_objects_system_tx: None,
3009
3010 max_move_identifier_len: None,
3017 max_move_value_depth: None,
3018 package_arena_size_in_bytes: None,
3019 max_move_enum_variants: None,
3020
3021 gas_rounding_step: None,
3022
3023 execution_version: None,
3024
3025 max_event_emit_size_total: None,
3026
3027 consensus_bad_nodes_stake_threshold: None,
3028
3029 max_jwk_votes_per_validator_per_epoch: None,
3030
3031 max_age_of_jwk_in_epochs: None,
3032
3033 random_beacon_reduction_allowed_delta: None,
3034
3035 random_beacon_reduction_lower_bound: None,
3036
3037 random_beacon_dkg_timeout_round: None,
3038
3039 random_beacon_min_round_interval_ms: None,
3040
3041 random_beacon_dkg_version: None,
3042
3043 consensus_max_transaction_size_bytes: None,
3044
3045 consensus_max_transactions_in_block_bytes: None,
3046
3047 consensus_max_num_transactions_in_block: None,
3048
3049 consensus_voting_rounds: None,
3050
3051 max_accumulated_txn_cost_per_object_in_narwhal_commit: None,
3052
3053 max_deferral_rounds_for_congestion_control: None,
3054
3055 epoch_close_deadline_ms: None,
3056
3057 max_txn_cost_overage_per_object_in_commit: None,
3058
3059 allowed_txn_cost_overage_burst_per_object_in_commit: None,
3060
3061 min_checkpoint_interval_ms: None,
3062
3063 checkpoint_summary_version_specific_data: None,
3064
3065 max_soft_bundle_size: None,
3066
3067 bridge_should_try_to_finalize_committee: None,
3068
3069 max_accumulated_txn_cost_per_object_in_mysticeti_commit: None,
3070
3071 max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit: None,
3072
3073 consensus_gc_depth: None,
3074
3075 gas_budget_based_txn_cost_cap_factor: None,
3076
3077 gas_budget_based_txn_cost_absolute_cap_commit_count: None,
3078
3079 sip_45_consensus_amplification_threshold: None,
3080
3081 use_object_per_epoch_marker_table_v2: None,
3082
3083 consensus_commit_rate_estimation_window_size: None,
3084
3085 aliased_addresses: vec![],
3086
3087 translation_per_command_base_charge: None,
3088 translation_per_input_base_charge: None,
3089 translation_pure_input_per_byte_charge: None,
3090 translation_per_type_node_charge: None,
3091 translation_per_reference_node_charge: None,
3092 translation_per_linkage_entry_charge: None,
3093 translation_per_live_reference_charge: None,
3094 max_ptb_live_references: None,
3095 max_ptb_returned_references: None,
3096 max_ptb_total_returned_references: None,
3097
3098 max_updates_per_settlement_txn: None,
3099
3100 gasless_max_computation_units: None,
3101 gasless_allowed_token_types: None,
3102 gasless_max_unused_inputs: None,
3103 gasless_max_pure_input_bytes: None,
3104 gasless_max_tps: None,
3105 include_special_package_amendments: None,
3106 gasless_max_tx_size_bytes: None,
3107 };
3110 for cur in 2..=version.0 {
3111 match cur {
3112 1 => unreachable!(),
3113 2 => {
3114 cfg.feature_flags.advance_epoch_start_time_in_safe_mode = true;
3115 }
3116 3 => {
3117 cfg.gas_model_version = Some(2);
3119 cfg.max_tx_gas = Some(50_000_000_000);
3121 cfg.base_tx_cost_fixed = Some(2_000);
3123 cfg.storage_gas_price = Some(76);
3125 cfg.feature_flags.loaded_child_objects_fixed = true;
3126 cfg.max_size_written_objects = Some(5 * 1000 * 1000);
3129 cfg.max_size_written_objects_system_tx = Some(50 * 1000 * 1000);
3132 cfg.feature_flags.package_upgrades = true;
3133 }
3134 4 => {
3139 cfg.reward_slashing_rate = Some(10000);
3141 cfg.gas_model_version = Some(3);
3143 }
3144 5 => {
3145 cfg.feature_flags.missing_type_is_compatibility_error = true;
3146 cfg.gas_model_version = Some(4);
3147 cfg.feature_flags.scoring_decision_with_validity_cutoff = true;
3148 }
3152 6 => {
3153 cfg.gas_model_version = Some(5);
3154 cfg.buffer_stake_for_protocol_upgrade_bps = Some(5000);
3155 cfg.feature_flags.consensus_order_end_of_epoch_last = true;
3156 }
3157 7 => {
3158 cfg.feature_flags.disallow_adding_abilities_on_upgrade = true;
3159 cfg.feature_flags
3160 .disable_invariant_violation_check_in_swap_loc = true;
3161 cfg.feature_flags.ban_entry_init = true;
3162 cfg.feature_flags.package_digest_hash_module = true;
3163 }
3164 8 => {
3165 cfg.feature_flags
3166 .disallow_change_struct_type_params_on_upgrade = true;
3167 }
3168 9 => {
3169 cfg.max_move_identifier_len = Some(128);
3171 cfg.feature_flags.no_extraneous_module_bytes = true;
3172 cfg.feature_flags
3173 .advance_to_highest_supported_protocol_version = true;
3174 }
3175 10 => {
3176 cfg.max_verifier_meter_ticks_per_function = Some(16_000_000);
3177 cfg.max_meter_ticks_per_module = Some(16_000_000);
3178 }
3179 11 => {
3180 cfg.max_move_value_depth = Some(128);
3181 }
3182 12 => {
3183 cfg.feature_flags.narwhal_versioned_metadata = true;
3184 if chain != Chain::Mainnet {
3185 cfg.feature_flags.commit_root_state_digest = true;
3186 }
3187
3188 if chain != Chain::Mainnet && chain != Chain::Testnet {
3189 cfg.feature_flags.zklogin_auth = true;
3190 }
3191 }
3192 13 => {}
3193 14 => {
3194 cfg.gas_rounding_step = Some(1_000);
3195 cfg.gas_model_version = Some(6);
3196 }
3197 15 => {
3198 cfg.feature_flags.consensus_transaction_ordering =
3199 ConsensusTransactionOrdering::ByGasPrice;
3200 }
3201 16 => {
3202 cfg.feature_flags.simplified_unwrap_then_delete = true;
3203 }
3204 17 => {
3205 cfg.feature_flags.upgraded_multisig_supported = true;
3206 }
3207 18 => {
3208 cfg.execution_version = Some(1);
3209 cfg.feature_flags.txn_base_cost_as_multiplier = true;
3218 cfg.base_tx_cost_fixed = Some(1_000);
3220 }
3221 19 => {
3222 cfg.max_num_event_emit = Some(1024);
3223 cfg.max_event_emit_size_total = Some(
3226 256 * 250 * 1024, );
3228 }
3229 20 => {
3230 cfg.feature_flags.commit_root_state_digest = true;
3231
3232 if chain != Chain::Mainnet {
3233 cfg.feature_flags.narwhal_new_leader_election_schedule = true;
3234 cfg.consensus_bad_nodes_stake_threshold = Some(20);
3235 }
3236 }
3237
3238 21 => {
3239 if chain != Chain::Mainnet {
3240 cfg.feature_flags.zklogin_supported_providers = BTreeSet::from([
3241 "Google".to_string(),
3242 "Facebook".to_string(),
3243 "Twitch".to_string(),
3244 ]);
3245 }
3246 }
3247 22 => {
3248 cfg.feature_flags.loaded_child_object_format = true;
3249 }
3250 23 => {
3251 cfg.feature_flags.loaded_child_object_format_type = true;
3252 cfg.feature_flags.narwhal_new_leader_election_schedule = true;
3253 cfg.consensus_bad_nodes_stake_threshold = Some(20);
3259 }
3260 24 => {
3261 cfg.feature_flags.simple_conservation_checks = true;
3262 cfg.max_publish_or_upgrade_per_ptb = Some(5);
3263
3264 cfg.feature_flags.end_of_epoch_transaction_supported = true;
3265
3266 if chain != Chain::Mainnet {
3267 cfg.feature_flags.enable_jwk_consensus_updates = true;
3268 cfg.max_jwk_votes_per_validator_per_epoch = Some(240);
3270 cfg.max_age_of_jwk_in_epochs = Some(1);
3271 }
3272 }
3273 25 => {
3274 cfg.feature_flags.zklogin_supported_providers = BTreeSet::from([
3276 "Google".to_string(),
3277 "Facebook".to_string(),
3278 "Twitch".to_string(),
3279 ]);
3280 cfg.feature_flags.zklogin_auth = true;
3281
3282 cfg.feature_flags.enable_jwk_consensus_updates = true;
3284 cfg.max_jwk_votes_per_validator_per_epoch = Some(240);
3285 cfg.max_age_of_jwk_in_epochs = Some(1);
3286 }
3287 26 => {
3288 cfg.gas_model_version = Some(7);
3289 if chain != Chain::Mainnet && chain != Chain::Testnet {
3291 cfg.transfer_receive_object_cost_base = Some(52);
3292 cfg.feature_flags.receive_objects = true;
3293 }
3294 }
3295 27 => {
3296 cfg.gas_model_version = Some(8);
3297 }
3298 28 => {
3299 cfg.check_zklogin_id_cost_base = Some(200);
3301 cfg.check_zklogin_issuer_cost_base = Some(200);
3303
3304 if chain != Chain::Mainnet && chain != Chain::Testnet {
3306 cfg.feature_flags.enable_effects_v2 = true;
3307 }
3308 }
3309 29 => {
3310 cfg.feature_flags.verify_legacy_zklogin_address = true;
3311 }
3312 30 => {
3313 if chain != Chain::Mainnet {
3315 cfg.feature_flags.narwhal_certificate_v2 = true;
3316 }
3317
3318 cfg.random_beacon_reduction_allowed_delta = Some(800);
3319 if chain != Chain::Mainnet {
3321 cfg.feature_flags.enable_effects_v2 = true;
3322 }
3323
3324 cfg.feature_flags.zklogin_supported_providers = BTreeSet::default();
3328
3329 cfg.feature_flags.recompute_has_public_transfer_in_execution = true;
3330 }
3331 31 => {
3332 cfg.execution_version = Some(2);
3333 if chain != Chain::Mainnet && chain != Chain::Testnet {
3335 cfg.feature_flags.shared_object_deletion = true;
3336 }
3337 }
3338 32 => {
3339 if chain != Chain::Mainnet {
3341 cfg.feature_flags.accept_zklogin_in_multisig = true;
3342 }
3343 if chain != Chain::Mainnet {
3345 cfg.transfer_receive_object_cost_base = Some(52);
3346 cfg.feature_flags.receive_objects = true;
3347 }
3348 if chain != Chain::Mainnet && chain != Chain::Testnet {
3350 cfg.feature_flags.random_beacon = true;
3351 cfg.random_beacon_reduction_lower_bound = Some(1600);
3352 cfg.random_beacon_dkg_timeout_round = Some(3000);
3353 cfg.random_beacon_min_round_interval_ms = Some(150);
3354 }
3355 if chain != Chain::Testnet && chain != Chain::Mainnet {
3357 cfg.feature_flags.include_consensus_digest_in_prologue = true;
3358 }
3359
3360 cfg.feature_flags.narwhal_certificate_v2 = true;
3362 }
3363 33 => {
3364 cfg.feature_flags.hardened_otw_check = true;
3365 cfg.feature_flags.allow_receiving_object_id = true;
3366
3367 cfg.transfer_receive_object_cost_base = Some(52);
3369 cfg.feature_flags.receive_objects = true;
3370
3371 if chain != Chain::Mainnet {
3373 cfg.feature_flags.shared_object_deletion = true;
3374 }
3375
3376 cfg.feature_flags.enable_effects_v2 = true;
3377 }
3378 34 => {}
3379 35 => {
3380 if chain != Chain::Mainnet && chain != Chain::Testnet {
3382 cfg.feature_flags.enable_poseidon = true;
3383 cfg.poseidon_bn254_cost_base = Some(260);
3384 cfg.poseidon_bn254_cost_per_block = Some(10);
3385 }
3386
3387 cfg.feature_flags.enable_coin_deny_list = true;
3388 }
3389 36 => {
3390 if chain != Chain::Mainnet && chain != Chain::Testnet {
3392 cfg.feature_flags.enable_group_ops_native_functions = true;
3393 cfg.feature_flags.enable_group_ops_native_function_msm = true;
3394 cfg.group_ops_bls12381_decode_scalar_cost = Some(52);
3396 cfg.group_ops_bls12381_decode_g1_cost = Some(52);
3397 cfg.group_ops_bls12381_decode_g2_cost = Some(52);
3398 cfg.group_ops_bls12381_decode_gt_cost = Some(52);
3399 cfg.group_ops_bls12381_scalar_add_cost = Some(52);
3400 cfg.group_ops_bls12381_g1_add_cost = Some(52);
3401 cfg.group_ops_bls12381_g2_add_cost = Some(52);
3402 cfg.group_ops_bls12381_gt_add_cost = Some(52);
3403 cfg.group_ops_bls12381_scalar_sub_cost = Some(52);
3404 cfg.group_ops_bls12381_g1_sub_cost = Some(52);
3405 cfg.group_ops_bls12381_g2_sub_cost = Some(52);
3406 cfg.group_ops_bls12381_gt_sub_cost = Some(52);
3407 cfg.group_ops_bls12381_scalar_mul_cost = Some(52);
3408 cfg.group_ops_bls12381_g1_mul_cost = Some(52);
3409 cfg.group_ops_bls12381_g2_mul_cost = Some(52);
3410 cfg.group_ops_bls12381_gt_mul_cost = Some(52);
3411 cfg.group_ops_bls12381_scalar_div_cost = Some(52);
3412 cfg.group_ops_bls12381_g1_div_cost = Some(52);
3413 cfg.group_ops_bls12381_g2_div_cost = Some(52);
3414 cfg.group_ops_bls12381_gt_div_cost = Some(52);
3415 cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(52);
3416 cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(52);
3417 cfg.group_ops_bls12381_g1_hash_to_cost_per_byte = Some(2);
3418 cfg.group_ops_bls12381_g2_hash_to_cost_per_byte = Some(2);
3419 cfg.group_ops_bls12381_g1_msm_base_cost = Some(52);
3420 cfg.group_ops_bls12381_g2_msm_base_cost = Some(52);
3421 cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(52);
3422 cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(52);
3423 cfg.group_ops_bls12381_msm_max_len = Some(32);
3424 cfg.group_ops_bls12381_pairing_cost = Some(52);
3425 }
3426 cfg.feature_flags.shared_object_deletion = true;
3428
3429 cfg.consensus_max_transaction_size_bytes = Some(256 * 1024); cfg.consensus_max_transactions_in_block_bytes = Some(6 * 1_024 * 1024);
3431 }
3433 37 => {
3434 cfg.feature_flags.reject_mutable_random_on_entry_functions = true;
3435
3436 if chain != Chain::Mainnet {
3438 cfg.feature_flags.include_consensus_digest_in_prologue = true;
3439 }
3440 }
3441 38 => {
3442 cfg.binary_module_handles = Some(100);
3443 cfg.binary_struct_handles = Some(300);
3444 cfg.binary_function_handles = Some(1500);
3445 cfg.binary_function_instantiations = Some(750);
3446 cfg.binary_signatures = Some(1000);
3447 cfg.binary_constant_pool = Some(4000);
3451 cfg.binary_identifiers = Some(10000);
3452 cfg.binary_address_identifiers = Some(100);
3453 cfg.binary_struct_defs = Some(200);
3454 cfg.binary_struct_def_instantiations = Some(100);
3455 cfg.binary_function_defs = Some(1000);
3456 cfg.binary_field_handles = Some(500);
3457 cfg.binary_field_instantiations = Some(250);
3458 cfg.binary_friend_decls = Some(100);
3459 cfg.max_package_dependencies = Some(32);
3461 cfg.max_modules_in_publish = Some(64);
3462 cfg.execution_version = Some(3);
3464 }
3465 39 => {
3466 }
3468 40 => {}
3469 41 => {
3470 cfg.feature_flags.enable_group_ops_native_functions = true;
3472 cfg.group_ops_bls12381_decode_scalar_cost = Some(52);
3474 cfg.group_ops_bls12381_decode_g1_cost = Some(52);
3475 cfg.group_ops_bls12381_decode_g2_cost = Some(52);
3476 cfg.group_ops_bls12381_decode_gt_cost = Some(52);
3477 cfg.group_ops_bls12381_scalar_add_cost = Some(52);
3478 cfg.group_ops_bls12381_g1_add_cost = Some(52);
3479 cfg.group_ops_bls12381_g2_add_cost = Some(52);
3480 cfg.group_ops_bls12381_gt_add_cost = Some(52);
3481 cfg.group_ops_bls12381_scalar_sub_cost = Some(52);
3482 cfg.group_ops_bls12381_g1_sub_cost = Some(52);
3483 cfg.group_ops_bls12381_g2_sub_cost = Some(52);
3484 cfg.group_ops_bls12381_gt_sub_cost = Some(52);
3485 cfg.group_ops_bls12381_scalar_mul_cost = Some(52);
3486 cfg.group_ops_bls12381_g1_mul_cost = Some(52);
3487 cfg.group_ops_bls12381_g2_mul_cost = Some(52);
3488 cfg.group_ops_bls12381_gt_mul_cost = Some(52);
3489 cfg.group_ops_bls12381_scalar_div_cost = Some(52);
3490 cfg.group_ops_bls12381_g1_div_cost = Some(52);
3491 cfg.group_ops_bls12381_g2_div_cost = Some(52);
3492 cfg.group_ops_bls12381_gt_div_cost = Some(52);
3493 cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(52);
3494 cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(52);
3495 cfg.group_ops_bls12381_g1_hash_to_cost_per_byte = Some(2);
3496 cfg.group_ops_bls12381_g2_hash_to_cost_per_byte = Some(2);
3497 cfg.group_ops_bls12381_g1_msm_base_cost = Some(52);
3498 cfg.group_ops_bls12381_g2_msm_base_cost = Some(52);
3499 cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(52);
3500 cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(52);
3501 cfg.group_ops_bls12381_msm_max_len = Some(32);
3502 cfg.group_ops_bls12381_pairing_cost = Some(52);
3503 }
3504 42 => {}
3505 43 => {
3506 cfg.feature_flags.zklogin_max_epoch_upper_bound_delta = Some(30);
3507 cfg.max_meter_ticks_per_package = Some(16_000_000);
3508 }
3509 44 => {
3510 cfg.feature_flags.include_consensus_digest_in_prologue = true;
3512 if chain != Chain::Mainnet {
3514 cfg.feature_flags.consensus_choice = ConsensusChoice::SwapEachEpoch;
3515 }
3516 }
3517 45 => {
3518 if chain != Chain::Testnet && chain != Chain::Mainnet {
3520 cfg.feature_flags.consensus_network = ConsensusNetwork::Tonic;
3521 }
3522
3523 if chain != Chain::Mainnet {
3524 cfg.feature_flags.mysticeti_leader_scoring_and_schedule = true;
3526 }
3527 cfg.min_move_binary_format_version = Some(6);
3528 cfg.feature_flags.accept_zklogin_in_multisig = true;
3529
3530 if chain != Chain::Mainnet && chain != Chain::Testnet {
3534 cfg.feature_flags.bridge = true;
3535 }
3536 }
3537 46 => {
3538 if chain != Chain::Mainnet {
3540 cfg.feature_flags.bridge = true;
3541 }
3542
3543 cfg.feature_flags.reshare_at_same_initial_version = true;
3545 }
3546 47 => {}
3547 48 => {
3548 cfg.feature_flags.consensus_network = ConsensusNetwork::Tonic;
3550
3551 cfg.feature_flags.resolve_abort_locations_to_package_id = true;
3553
3554 if chain != Chain::Mainnet {
3556 cfg.feature_flags.random_beacon = true;
3557 cfg.random_beacon_reduction_lower_bound = Some(1600);
3558 cfg.random_beacon_dkg_timeout_round = Some(3000);
3559 cfg.random_beacon_min_round_interval_ms = Some(200);
3560 }
3561
3562 cfg.feature_flags.mysticeti_use_committed_subdag_digest = true;
3564 }
3565 49 => {
3566 if chain != Chain::Testnet && chain != Chain::Mainnet {
3567 cfg.move_binary_format_version = Some(7);
3568 }
3569
3570 if chain != Chain::Mainnet && chain != Chain::Testnet {
3572 cfg.feature_flags.enable_vdf = true;
3573 cfg.vdf_verify_vdf_cost = Some(1500);
3576 cfg.vdf_hash_to_input_cost = Some(100);
3577 }
3578
3579 if chain != Chain::Testnet && chain != Chain::Mainnet {
3581 cfg.feature_flags
3582 .record_consensus_determined_version_assignments_in_prologue = true;
3583 }
3584
3585 if chain != Chain::Mainnet {
3587 cfg.feature_flags.consensus_choice = ConsensusChoice::Mysticeti;
3588 }
3589
3590 cfg.feature_flags.fresh_vm_on_framework_upgrade = true;
3592 }
3593 50 => {
3594 if chain != Chain::Mainnet {
3596 cfg.checkpoint_summary_version_specific_data = Some(1);
3597 cfg.min_checkpoint_interval_ms = Some(200);
3598 }
3599
3600 if chain != Chain::Testnet && chain != Chain::Mainnet {
3602 cfg.feature_flags
3603 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = true;
3604 }
3605
3606 cfg.feature_flags.mysticeti_num_leaders_per_round = Some(1);
3607
3608 cfg.max_deferral_rounds_for_congestion_control = Some(10);
3610 }
3611 51 => {
3612 cfg.random_beacon_dkg_version = Some(1);
3613
3614 if chain != Chain::Testnet && chain != Chain::Mainnet {
3615 cfg.feature_flags.enable_coin_deny_list_v2 = true;
3616 }
3617 }
3618 52 => {
3619 if chain != Chain::Mainnet {
3620 cfg.feature_flags.soft_bundle = true;
3621 cfg.max_soft_bundle_size = Some(5);
3622 }
3623
3624 cfg.config_read_setting_impl_cost_base = Some(100);
3625 cfg.config_read_setting_impl_cost_per_byte = Some(40);
3626
3627 if chain != Chain::Testnet && chain != Chain::Mainnet {
3629 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(100);
3630 cfg.feature_flags.per_object_congestion_control_mode =
3631 PerObjectCongestionControlMode::TotalTxCount;
3632 }
3633
3634 cfg.feature_flags.consensus_choice = ConsensusChoice::Mysticeti;
3636
3637 cfg.feature_flags.mysticeti_leader_scoring_and_schedule = true;
3639
3640 cfg.checkpoint_summary_version_specific_data = Some(1);
3642 cfg.min_checkpoint_interval_ms = Some(200);
3643
3644 if chain != Chain::Mainnet {
3646 cfg.feature_flags
3647 .record_consensus_determined_version_assignments_in_prologue = true;
3648 cfg.feature_flags
3649 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = true;
3650 }
3651 if chain != Chain::Mainnet {
3653 cfg.move_binary_format_version = Some(7);
3654 }
3655
3656 if chain != Chain::Testnet && chain != Chain::Mainnet {
3657 cfg.feature_flags.passkey_auth = true;
3658 }
3659 cfg.feature_flags.enable_coin_deny_list_v2 = true;
3660 }
3661 53 => {
3662 cfg.bridge_should_try_to_finalize_committee = Some(chain != Chain::Mainnet);
3664
3665 cfg.feature_flags
3667 .record_consensus_determined_version_assignments_in_prologue = true;
3668 cfg.feature_flags
3669 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = true;
3670
3671 if chain == Chain::Unknown {
3672 cfg.feature_flags.authority_capabilities_v2 = true;
3673 }
3674
3675 if chain != Chain::Mainnet {
3677 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(100);
3678 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(10);
3679 cfg.feature_flags.per_object_congestion_control_mode =
3680 PerObjectCongestionControlMode::TotalTxCount;
3681 }
3682
3683 cfg.bcs_per_byte_serialized_cost = Some(2);
3685 cfg.bcs_legacy_min_output_size_cost = Some(1);
3686 cfg.bcs_failure_cost = Some(52);
3687 cfg.debug_print_base_cost = Some(52);
3688 cfg.debug_print_stack_trace_base_cost = Some(52);
3689 cfg.hash_sha2_256_base_cost = Some(52);
3690 cfg.hash_sha2_256_per_byte_cost = Some(2);
3691 cfg.hash_sha2_256_legacy_min_input_len_cost = Some(1);
3692 cfg.hash_sha3_256_base_cost = Some(52);
3693 cfg.hash_sha3_256_per_byte_cost = Some(2);
3694 cfg.hash_sha3_256_legacy_min_input_len_cost = Some(1);
3695 cfg.type_name_get_base_cost = Some(52);
3696 cfg.type_name_get_per_byte_cost = Some(2);
3697 cfg.string_check_utf8_base_cost = Some(52);
3698 cfg.string_check_utf8_per_byte_cost = Some(2);
3699 cfg.string_is_char_boundary_base_cost = Some(52);
3700 cfg.string_sub_string_base_cost = Some(52);
3701 cfg.string_sub_string_per_byte_cost = Some(2);
3702 cfg.string_index_of_base_cost = Some(52);
3703 cfg.string_index_of_per_byte_pattern_cost = Some(2);
3704 cfg.string_index_of_per_byte_searched_cost = Some(2);
3705 cfg.vector_empty_base_cost = Some(52);
3706 cfg.vector_length_base_cost = Some(52);
3707 cfg.vector_push_back_base_cost = Some(52);
3708 cfg.vector_push_back_legacy_per_abstract_memory_unit_cost = Some(2);
3709 cfg.vector_borrow_base_cost = Some(52);
3710 cfg.vector_pop_back_base_cost = Some(52);
3711 cfg.vector_destroy_empty_base_cost = Some(52);
3712 cfg.vector_swap_base_cost = Some(52);
3713 }
3714 54 => {
3715 cfg.feature_flags.random_beacon = true;
3717 cfg.random_beacon_reduction_lower_bound = Some(1000);
3718 cfg.random_beacon_dkg_timeout_round = Some(3000);
3719 cfg.random_beacon_min_round_interval_ms = Some(500);
3720
3721 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 cfg.feature_flags.soft_bundle = true;
3729 cfg.max_soft_bundle_size = Some(5);
3730 }
3731 55 => {
3732 cfg.move_binary_format_version = Some(7);
3734
3735 cfg.consensus_max_transactions_in_block_bytes = Some(512 * 1024);
3737 cfg.consensus_max_num_transactions_in_block = Some(512);
3740
3741 cfg.feature_flags.rethrow_serialization_type_layout_errors = true;
3742 }
3743 56 => {
3744 if chain == Chain::Mainnet {
3745 cfg.feature_flags.bridge = true;
3746 }
3747 }
3748 57 => {
3749 cfg.random_beacon_reduction_lower_bound = Some(800);
3751 }
3752 58 => {
3753 if chain == Chain::Mainnet {
3754 cfg.bridge_should_try_to_finalize_committee = Some(true);
3755 }
3756
3757 if chain != Chain::Mainnet && chain != Chain::Testnet {
3758 cfg.feature_flags
3760 .consensus_distributed_vote_scoring_strategy = true;
3761 }
3762 }
3763 59 => {
3764 cfg.feature_flags.consensus_round_prober = true;
3766 }
3767 60 => {
3768 cfg.max_type_to_layout_nodes = Some(512);
3769 cfg.feature_flags.validate_identifier_inputs = true;
3770 }
3771 61 => {
3772 if chain != Chain::Mainnet {
3773 cfg.feature_flags
3775 .consensus_distributed_vote_scoring_strategy = true;
3776 }
3777 cfg.random_beacon_reduction_lower_bound = Some(700);
3779
3780 if chain != Chain::Mainnet && chain != Chain::Testnet {
3781 cfg.feature_flags.mysticeti_fastpath = true;
3783 }
3784 }
3785 62 => {
3786 cfg.feature_flags.relocate_event_module = true;
3787 }
3788 63 => {
3789 cfg.feature_flags.per_object_congestion_control_mode =
3790 PerObjectCongestionControlMode::TotalGasBudgetWithCap;
3791 cfg.gas_budget_based_txn_cost_cap_factor = Some(400_000);
3792 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(18_500_000);
3793 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(240_000_000);
3794 }
3795 64 => {
3796 cfg.feature_flags.per_object_congestion_control_mode =
3797 PerObjectCongestionControlMode::TotalTxCount;
3798 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(40);
3799 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(3);
3800 }
3801 65 => {
3802 cfg.feature_flags
3804 .consensus_distributed_vote_scoring_strategy = true;
3805 }
3806 66 => {
3807 if chain == Chain::Mainnet {
3808 cfg.feature_flags
3810 .consensus_distributed_vote_scoring_strategy = false;
3811 }
3812 }
3813 67 => {
3814 cfg.feature_flags
3816 .consensus_distributed_vote_scoring_strategy = true;
3817 }
3818 68 => {
3819 cfg.group_ops_bls12381_g1_to_uncompressed_g1_cost = Some(26);
3820 cfg.group_ops_bls12381_uncompressed_g1_to_g1_cost = Some(52);
3821 cfg.group_ops_bls12381_uncompressed_g1_sum_base_cost = Some(26);
3822 cfg.group_ops_bls12381_uncompressed_g1_sum_cost_per_term = Some(13);
3823 cfg.group_ops_bls12381_uncompressed_g1_sum_max_terms = Some(2000);
3824
3825 if chain != Chain::Mainnet && chain != Chain::Testnet {
3826 cfg.feature_flags.uncompressed_g1_group_elements = true;
3827 }
3828
3829 cfg.feature_flags.per_object_congestion_control_mode =
3830 PerObjectCongestionControlMode::TotalGasBudgetWithCap;
3831 cfg.gas_budget_based_txn_cost_cap_factor = Some(400_000);
3832 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(18_500_000);
3833 cfg.max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit =
3834 Some(3_700_000); cfg.max_txn_cost_overage_per_object_in_commit = Some(u64::MAX);
3836 cfg.gas_budget_based_txn_cost_absolute_cap_commit_count = Some(50);
3837
3838 cfg.random_beacon_reduction_lower_bound = Some(500);
3840
3841 cfg.feature_flags.disallow_new_modules_in_deps_only_packages = true;
3842 }
3843 69 => {
3844 cfg.consensus_voting_rounds = Some(40);
3846
3847 if chain != Chain::Mainnet && chain != Chain::Testnet {
3848 cfg.feature_flags.consensus_smart_ancestor_selection = true;
3850 }
3851
3852 if chain != Chain::Mainnet {
3853 cfg.feature_flags.uncompressed_g1_group_elements = true;
3854 }
3855 }
3856 70 => {
3857 if chain != Chain::Mainnet {
3858 cfg.feature_flags.consensus_smart_ancestor_selection = true;
3860 cfg.feature_flags
3862 .consensus_round_prober_probe_accepted_rounds = true;
3863 }
3864
3865 cfg.poseidon_bn254_cost_per_block = Some(388);
3866
3867 cfg.gas_model_version = Some(9);
3868 cfg.feature_flags.native_charging_v2 = true;
3869 cfg.bls12381_bls12381_min_sig_verify_cost_base = Some(44064);
3870 cfg.bls12381_bls12381_min_pk_verify_cost_base = Some(49282);
3871 cfg.ecdsa_k1_secp256k1_verify_keccak256_cost_base = Some(1470);
3872 cfg.ecdsa_k1_secp256k1_verify_sha256_cost_base = Some(1470);
3873 cfg.ecdsa_r1_secp256r1_verify_sha256_cost_base = Some(4225);
3874 cfg.ecdsa_r1_secp256r1_verify_keccak256_cost_base = Some(4225);
3875 cfg.ecvrf_ecvrf_verify_cost_base = Some(4848);
3876 cfg.ed25519_ed25519_verify_cost_base = Some(1802);
3877
3878 cfg.ecdsa_r1_ecrecover_keccak256_cost_base = Some(1173);
3880 cfg.ecdsa_r1_ecrecover_sha256_cost_base = Some(1173);
3881 cfg.ecdsa_k1_ecrecover_keccak256_cost_base = Some(500);
3882 cfg.ecdsa_k1_ecrecover_sha256_cost_base = Some(500);
3883
3884 cfg.groth16_prepare_verifying_key_bls12381_cost_base = Some(53838);
3885 cfg.groth16_prepare_verifying_key_bn254_cost_base = Some(82010);
3886 cfg.groth16_verify_groth16_proof_internal_bls12381_cost_base = Some(72090);
3887 cfg.groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input =
3888 Some(8213);
3889 cfg.groth16_verify_groth16_proof_internal_bn254_cost_base = Some(115502);
3890 cfg.groth16_verify_groth16_proof_internal_bn254_cost_per_public_input =
3891 Some(9484);
3892
3893 cfg.hash_keccak256_cost_base = Some(10);
3894 cfg.hash_blake2b256_cost_base = Some(10);
3895
3896 cfg.group_ops_bls12381_decode_scalar_cost = Some(7);
3898 cfg.group_ops_bls12381_decode_g1_cost = Some(2848);
3899 cfg.group_ops_bls12381_decode_g2_cost = Some(3770);
3900 cfg.group_ops_bls12381_decode_gt_cost = Some(3068);
3901
3902 cfg.group_ops_bls12381_scalar_add_cost = Some(10);
3903 cfg.group_ops_bls12381_g1_add_cost = Some(1556);
3904 cfg.group_ops_bls12381_g2_add_cost = Some(3048);
3905 cfg.group_ops_bls12381_gt_add_cost = Some(188);
3906
3907 cfg.group_ops_bls12381_scalar_sub_cost = Some(10);
3908 cfg.group_ops_bls12381_g1_sub_cost = Some(1550);
3909 cfg.group_ops_bls12381_g2_sub_cost = Some(3019);
3910 cfg.group_ops_bls12381_gt_sub_cost = Some(497);
3911
3912 cfg.group_ops_bls12381_scalar_mul_cost = Some(11);
3913 cfg.group_ops_bls12381_g1_mul_cost = Some(4842);
3914 cfg.group_ops_bls12381_g2_mul_cost = Some(9108);
3915 cfg.group_ops_bls12381_gt_mul_cost = Some(27490);
3916
3917 cfg.group_ops_bls12381_scalar_div_cost = Some(91);
3918 cfg.group_ops_bls12381_g1_div_cost = Some(5091);
3919 cfg.group_ops_bls12381_g2_div_cost = Some(9206);
3920 cfg.group_ops_bls12381_gt_div_cost = Some(27804);
3921
3922 cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(2962);
3923 cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(8688);
3924
3925 cfg.group_ops_bls12381_g1_msm_base_cost = Some(62648);
3926 cfg.group_ops_bls12381_g2_msm_base_cost = Some(131192);
3927 cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(1333);
3928 cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(3216);
3929
3930 cfg.group_ops_bls12381_uncompressed_g1_to_g1_cost = Some(677);
3931 cfg.group_ops_bls12381_g1_to_uncompressed_g1_cost = Some(2099);
3932 cfg.group_ops_bls12381_uncompressed_g1_sum_base_cost = Some(77);
3933 cfg.group_ops_bls12381_uncompressed_g1_sum_cost_per_term = Some(26);
3934
3935 cfg.group_ops_bls12381_pairing_cost = Some(26897);
3936 cfg.group_ops_bls12381_uncompressed_g1_sum_max_terms = Some(1200);
3937
3938 cfg.validator_validate_metadata_cost_base = Some(20000);
3939 }
3940 71 => {
3941 cfg.sip_45_consensus_amplification_threshold = Some(5);
3942
3943 cfg.allowed_txn_cost_overage_burst_per_object_in_commit = Some(185_000_000);
3945 }
3946 72 => {
3947 cfg.feature_flags.convert_type_argument_error = true;
3948
3949 cfg.max_tx_gas = Some(50_000_000_000_000);
3952 cfg.max_gas_price = Some(50_000_000_000);
3954
3955 cfg.feature_flags.variant_nodes = true;
3956 }
3957 73 => {
3958 cfg.use_object_per_epoch_marker_table_v2 = Some(true);
3960
3961 if chain != Chain::Mainnet && chain != Chain::Testnet {
3962 cfg.consensus_gc_depth = Some(60);
3965 }
3966
3967 if chain != Chain::Mainnet {
3968 cfg.feature_flags.consensus_zstd_compression = true;
3970 }
3971
3972 cfg.feature_flags.consensus_smart_ancestor_selection = true;
3974 cfg.feature_flags
3976 .consensus_round_prober_probe_accepted_rounds = true;
3977
3978 cfg.feature_flags.per_object_congestion_control_mode =
3980 PerObjectCongestionControlMode::TotalGasBudgetWithCap;
3981 cfg.gas_budget_based_txn_cost_cap_factor = Some(400_000);
3982 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(37_000_000);
3983 cfg.max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit =
3984 Some(7_400_000); cfg.max_txn_cost_overage_per_object_in_commit = Some(u64::MAX);
3986 cfg.gas_budget_based_txn_cost_absolute_cap_commit_count = Some(50);
3987 cfg.allowed_txn_cost_overage_burst_per_object_in_commit = Some(370_000_000);
3988 }
3989 74 => {
3990 if chain != Chain::Mainnet && chain != Chain::Testnet {
3992 cfg.feature_flags.enable_nitro_attestation = true;
3993 }
3994 cfg.nitro_attestation_parse_base_cost = Some(53 * 50);
3995 cfg.nitro_attestation_parse_cost_per_byte = Some(50);
3996 cfg.nitro_attestation_verify_base_cost = Some(49632 * 50);
3997 cfg.nitro_attestation_verify_cost_per_cert = Some(52369 * 50);
3998
3999 cfg.feature_flags.consensus_zstd_compression = true;
4001
4002 if chain != Chain::Mainnet && chain != Chain::Testnet {
4003 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
4004 }
4005 }
4006 75 => {
4007 if chain != Chain::Mainnet {
4008 cfg.feature_flags.passkey_auth = true;
4009 }
4010 }
4011 76 => {
4012 if chain != Chain::Mainnet && chain != Chain::Testnet {
4013 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
4014 cfg.consensus_commit_rate_estimation_window_size = Some(10);
4015 }
4016 cfg.feature_flags.minimize_child_object_mutations = true;
4017
4018 if chain != Chain::Mainnet {
4019 cfg.feature_flags.accept_passkey_in_multisig = true;
4020 }
4021 }
4022 77 => {
4023 cfg.feature_flags.uncompressed_g1_group_elements = true;
4024
4025 if chain != Chain::Mainnet {
4026 cfg.consensus_gc_depth = Some(60);
4027 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
4028 }
4029 }
4030 78 => {
4031 cfg.feature_flags.move_native_context = true;
4032 cfg.tx_context_fresh_id_cost_base = Some(52);
4033 cfg.tx_context_sender_cost_base = Some(30);
4034 cfg.tx_context_epoch_cost_base = Some(30);
4035 cfg.tx_context_epoch_timestamp_ms_cost_base = Some(30);
4036 cfg.tx_context_sponsor_cost_base = Some(30);
4037 cfg.tx_context_gas_price_cost_base = Some(30);
4038 cfg.tx_context_gas_budget_cost_base = Some(30);
4039 cfg.tx_context_ids_created_cost_base = Some(30);
4040 cfg.tx_context_replace_cost_base = Some(30);
4041 cfg.gas_model_version = Some(10);
4042
4043 if chain != Chain::Mainnet {
4044 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
4045 cfg.consensus_commit_rate_estimation_window_size = Some(10);
4046
4047 cfg.feature_flags.per_object_congestion_control_mode =
4049 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4050 ExecutionTimeEstimateParams {
4051 target_utilization: 30,
4052 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4054 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4056 stored_observations_limit: u64::MAX,
4057 stake_weighted_median_threshold: 0,
4058 default_none_duration_for_new_keys: false,
4059 observations_chunk_size: None,
4060 },
4061 );
4062 }
4063 }
4064 79 => {
4065 if chain != Chain::Mainnet {
4066 cfg.feature_flags.consensus_median_based_commit_timestamp = true;
4067
4068 cfg.consensus_bad_nodes_stake_threshold = Some(30);
4071
4072 cfg.feature_flags.consensus_batched_block_sync = true;
4073
4074 cfg.feature_flags.enable_nitro_attestation = true
4076 }
4077 cfg.feature_flags.normalize_ptb_arguments = true;
4078
4079 cfg.consensus_gc_depth = Some(60);
4080 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
4081 }
4082 80 => {
4083 cfg.max_ptb_value_size = Some(1024 * 1024);
4084 }
4085 81 => {
4086 cfg.feature_flags.consensus_median_based_commit_timestamp = true;
4087 cfg.feature_flags.enforce_checkpoint_timestamp_monotonicity = true;
4088 cfg.consensus_bad_nodes_stake_threshold = Some(30)
4089 }
4090 82 => {
4091 cfg.feature_flags.max_ptb_value_size_v2 = true;
4092 }
4093 83 => {
4094 if chain == Chain::Mainnet {
4095 let aliased: [u8; 32] = Hex::decode(
4097 "0x0b2da327ba6a4cacbe75dddd50e6e8bbf81d6496e92d66af9154c61c77f7332f",
4098 )
4099 .unwrap()
4100 .try_into()
4101 .unwrap();
4102
4103 cfg.aliased_addresses.push(AliasedAddress {
4105 original: Hex::decode("0xcd8962dad278d8b50fa0f9eb0186bfa4cbdecc6d59377214c88d0286a0ac9562").unwrap().try_into().unwrap(),
4106 aliased,
4107 allowed_tx_digests: vec![
4108 Base58::decode("B2eGLFoMHgj93Ni8dAJBfqGzo8EWSTLBesZzhEpTPA4").unwrap().try_into().unwrap(),
4109 ],
4110 });
4111
4112 cfg.aliased_addresses.push(AliasedAddress {
4113 original: Hex::decode("0xe28b50cef1d633ea43d3296a3f6b67ff0312a5f1a99f0af753c85b8b5de8ff06").unwrap().try_into().unwrap(),
4114 aliased,
4115 allowed_tx_digests: vec![
4116 Base58::decode("J4QqSAgp7VrQtQpMy5wDX4QGsCSEZu3U5KuDAkbESAge").unwrap().try_into().unwrap(),
4117 ],
4118 });
4119 }
4120
4121 if chain != Chain::Mainnet {
4124 cfg.feature_flags.resolve_type_input_ids_to_defining_id = true;
4125 cfg.transfer_party_transfer_internal_cost_base = Some(52);
4126
4127 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
4129 cfg.consensus_commit_rate_estimation_window_size = Some(10);
4130 cfg.feature_flags.per_object_congestion_control_mode =
4131 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4132 ExecutionTimeEstimateParams {
4133 target_utilization: 30,
4134 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4136 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4138 stored_observations_limit: u64::MAX,
4139 stake_weighted_median_threshold: 0,
4140 default_none_duration_for_new_keys: false,
4141 observations_chunk_size: None,
4142 },
4143 );
4144
4145 cfg.feature_flags.consensus_batched_block_sync = true;
4147
4148 cfg.feature_flags.enable_nitro_attestation_upgraded_parsing = true;
4151 cfg.feature_flags.enable_nitro_attestation = true;
4152 }
4153 }
4154 84 => {
4155 if chain == Chain::Mainnet {
4156 cfg.feature_flags.resolve_type_input_ids_to_defining_id = true;
4157 cfg.transfer_party_transfer_internal_cost_base = Some(52);
4158
4159 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
4161 cfg.consensus_commit_rate_estimation_window_size = Some(10);
4162 cfg.feature_flags.per_object_congestion_control_mode =
4163 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4164 ExecutionTimeEstimateParams {
4165 target_utilization: 30,
4166 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4168 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4170 stored_observations_limit: u64::MAX,
4171 stake_weighted_median_threshold: 0,
4172 default_none_duration_for_new_keys: false,
4173 observations_chunk_size: None,
4174 },
4175 );
4176
4177 cfg.feature_flags.consensus_batched_block_sync = true;
4179
4180 cfg.feature_flags.enable_nitro_attestation_upgraded_parsing = true;
4183 cfg.feature_flags.enable_nitro_attestation = true;
4184 }
4185
4186 cfg.feature_flags.per_object_congestion_control_mode =
4188 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4189 ExecutionTimeEstimateParams {
4190 target_utilization: 30,
4191 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4193 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4195 stored_observations_limit: 20,
4196 stake_weighted_median_threshold: 0,
4197 default_none_duration_for_new_keys: false,
4198 observations_chunk_size: None,
4199 },
4200 );
4201 cfg.feature_flags.allow_unbounded_system_objects = true;
4202 }
4203 85 => {
4204 if chain != Chain::Mainnet && chain != Chain::Testnet {
4205 cfg.feature_flags.enable_party_transfer = true;
4206 }
4207
4208 cfg.feature_flags
4209 .record_consensus_determined_version_assignments_in_prologue_v2 = true;
4210 cfg.feature_flags.disallow_self_identifier = true;
4211 cfg.feature_flags.per_object_congestion_control_mode =
4212 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4213 ExecutionTimeEstimateParams {
4214 target_utilization: 50,
4215 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4217 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4219 stored_observations_limit: 20,
4220 stake_weighted_median_threshold: 0,
4221 default_none_duration_for_new_keys: false,
4222 observations_chunk_size: None,
4223 },
4224 );
4225 }
4226 86 => {
4227 cfg.feature_flags.type_tags_in_object_runtime = true;
4228 cfg.max_move_enum_variants = Some(move_core_types::VARIANT_COUNT_MAX);
4229
4230 cfg.feature_flags.per_object_congestion_control_mode =
4232 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4233 ExecutionTimeEstimateParams {
4234 target_utilization: 50,
4235 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4237 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4239 stored_observations_limit: 20,
4240 stake_weighted_median_threshold: 3334,
4241 default_none_duration_for_new_keys: false,
4242 observations_chunk_size: None,
4243 },
4244 );
4245 if chain != Chain::Mainnet {
4247 cfg.feature_flags.enable_party_transfer = true;
4248 }
4249 }
4250 87 => {
4251 if chain == Chain::Mainnet {
4252 cfg.feature_flags.record_time_estimate_processed = true;
4253 }
4254 cfg.feature_flags.better_adapter_type_resolution_errors = true;
4255 }
4256 88 => {
4257 cfg.feature_flags.record_time_estimate_processed = true;
4258 cfg.tx_context_rgp_cost_base = Some(30);
4259 cfg.feature_flags
4260 .ignore_execution_time_observations_after_certs_closed = true;
4261
4262 cfg.feature_flags.per_object_congestion_control_mode =
4265 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4266 ExecutionTimeEstimateParams {
4267 target_utilization: 50,
4268 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4270 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4272 stored_observations_limit: 20,
4273 stake_weighted_median_threshold: 3334,
4274 default_none_duration_for_new_keys: true,
4275 observations_chunk_size: None,
4276 },
4277 );
4278 }
4279 89 => {
4280 cfg.feature_flags.dependency_linkage_error = true;
4281 cfg.feature_flags.additional_multisig_checks = true;
4282 }
4283 90 => {
4284 cfg.max_gas_price_rgp_factor_for_aborted_transactions = Some(100);
4286 cfg.feature_flags.debug_fatal_on_move_invariant_violation = true;
4287 cfg.feature_flags.additional_consensus_digest_indirect_state = true;
4288 cfg.feature_flags.accept_passkey_in_multisig = true;
4289 cfg.feature_flags.passkey_auth = true;
4290 cfg.feature_flags.check_for_init_during_upgrade = true;
4291
4292 if chain != Chain::Mainnet {
4294 cfg.feature_flags.mysticeti_fastpath = true;
4295 }
4296 }
4297 91 => {
4298 cfg.feature_flags.per_command_shared_object_transfer_rules = true;
4299 }
4300 92 => {
4301 cfg.feature_flags.per_command_shared_object_transfer_rules = false;
4302 }
4303 93 => {
4304 cfg.feature_flags
4305 .consensus_checkpoint_signature_key_includes_digest = true;
4306 }
4307 94 => {
4308 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: 18,
4318 stake_weighted_median_threshold: 3334,
4319 default_none_duration_for_new_keys: true,
4320 observations_chunk_size: None,
4321 },
4322 );
4323
4324 cfg.feature_flags.enable_party_transfer = true;
4326 }
4327 95 => {
4328 cfg.type_name_id_base_cost = Some(52);
4329
4330 cfg.max_transactions_per_checkpoint = Some(20_000);
4332 }
4333 96 => {
4334 if chain != Chain::Mainnet && chain != Chain::Testnet {
4336 cfg.feature_flags
4337 .include_checkpoint_artifacts_digest_in_summary = true;
4338 }
4339 cfg.feature_flags.correct_gas_payment_limit_check = true;
4340 cfg.feature_flags.authority_capabilities_v2 = true;
4341 cfg.feature_flags.use_mfp_txns_in_load_initial_object_debts = true;
4342 cfg.feature_flags.cancel_for_failed_dkg_early = true;
4343 cfg.feature_flags.enable_coin_registry = true;
4344
4345 cfg.feature_flags.mysticeti_fastpath = true;
4347 }
4348 97 => {
4349 cfg.feature_flags.additional_borrow_checks = true;
4350 }
4351 98 => {
4352 cfg.event_emit_auth_stream_cost = Some(52);
4353 cfg.feature_flags.better_loader_errors = true;
4354 cfg.feature_flags.generate_df_type_layouts = true;
4355 }
4356 99 => {
4357 cfg.feature_flags.use_new_commit_handler = true;
4358 }
4359 100 => {
4360 cfg.feature_flags.private_generics_verifier_v2 = true;
4361 }
4362 101 => {
4363 cfg.feature_flags.create_root_accumulator_object = true;
4364 cfg.max_updates_per_settlement_txn = Some(100);
4365 if chain != Chain::Mainnet {
4366 cfg.feature_flags.enable_poseidon = true;
4367 }
4368 }
4369 102 => {
4370 cfg.feature_flags.per_object_congestion_control_mode =
4374 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4375 ExecutionTimeEstimateParams {
4376 target_utilization: 50,
4377 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4379 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4381 stored_observations_limit: 180,
4382 stake_weighted_median_threshold: 3334,
4383 default_none_duration_for_new_keys: true,
4384 observations_chunk_size: Some(18),
4385 },
4386 );
4387 cfg.feature_flags.deprecate_global_storage_ops = true;
4388 }
4389 103 => {}
4390 104 => {
4391 cfg.translation_per_command_base_charge = Some(1);
4392 cfg.translation_per_input_base_charge = Some(1);
4393 cfg.translation_pure_input_per_byte_charge = Some(1);
4394 cfg.translation_per_type_node_charge = Some(1);
4395 cfg.translation_per_reference_node_charge = Some(1);
4396 cfg.translation_per_linkage_entry_charge = Some(10);
4397 cfg.gas_model_version = Some(11);
4398 cfg.feature_flags.abstract_size_in_object_runtime = true;
4399 cfg.feature_flags.object_runtime_charge_cache_load_gas = true;
4400 cfg.dynamic_field_hash_type_and_key_cost_base = Some(52);
4401 cfg.dynamic_field_add_child_object_cost_base = Some(52);
4402 cfg.dynamic_field_add_child_object_value_cost_per_byte = Some(1);
4403 cfg.dynamic_field_borrow_child_object_cost_base = Some(52);
4404 cfg.dynamic_field_borrow_child_object_child_ref_cost_per_byte = Some(1);
4405 cfg.dynamic_field_remove_child_object_cost_base = Some(52);
4406 cfg.dynamic_field_remove_child_object_child_cost_per_byte = Some(1);
4407 cfg.dynamic_field_has_child_object_cost_base = Some(52);
4408 cfg.dynamic_field_has_child_object_with_ty_cost_base = Some(52);
4409 cfg.feature_flags.enable_ptb_execution_v2 = true;
4410
4411 cfg.poseidon_bn254_cost_base = Some(260);
4412
4413 cfg.feature_flags.consensus_skip_gced_accept_votes = true;
4414
4415 if chain != Chain::Mainnet {
4416 cfg.feature_flags
4417 .enable_nitro_attestation_all_nonzero_pcrs_parsing = true;
4418 }
4419
4420 cfg.feature_flags
4421 .include_cancelled_randomness_txns_in_prologue = true;
4422 }
4423 105 => {
4424 cfg.feature_flags.enable_multi_epoch_transaction_expiration = true;
4425 cfg.feature_flags.disable_preconsensus_locking = true;
4426
4427 if chain != Chain::Mainnet {
4428 cfg.feature_flags
4429 .enable_nitro_attestation_always_include_required_pcrs_parsing = true;
4430 }
4431 }
4432 106 => {
4433 cfg.accumulator_object_storage_cost = Some(7600);
4435
4436 if chain != Chain::Mainnet && chain != Chain::Testnet {
4437 cfg.feature_flags.enable_accumulators = true;
4438 cfg.feature_flags.enable_address_balance_gas_payments = true;
4439 cfg.feature_flags.enable_authenticated_event_streams = true;
4440 cfg.feature_flags.enable_object_funds_withdraw = true;
4441 }
4442 }
4443 107 => {
4444 cfg.feature_flags
4445 .consensus_skip_gced_blocks_in_direct_finalization = true;
4446
4447 if in_integration_test() {
4449 cfg.consensus_gc_depth = Some(6);
4450 cfg.consensus_max_num_transactions_in_block = Some(8);
4451 }
4452 }
4453 108 => {
4454 cfg.feature_flags.gas_rounding_halve_digits = true;
4455 cfg.feature_flags.flexible_tx_context_positions = true;
4456 cfg.feature_flags.disable_entry_point_signature_check = true;
4457
4458 if chain != Chain::Mainnet {
4459 cfg.feature_flags.address_aliases = true;
4460
4461 cfg.feature_flags.enable_accumulators = true;
4462 cfg.feature_flags.enable_address_balance_gas_payments = true;
4463 }
4464
4465 cfg.feature_flags.enable_poseidon = true;
4466 }
4467 109 => {
4468 cfg.binary_variant_handles = Some(1024);
4469 cfg.binary_variant_instantiation_handles = Some(1024);
4470 cfg.feature_flags.restrict_hot_or_not_entry_functions = true;
4471 }
4472 110 => {
4473 cfg.feature_flags
4474 .enable_nitro_attestation_all_nonzero_pcrs_parsing = true;
4475 cfg.feature_flags
4476 .enable_nitro_attestation_always_include_required_pcrs_parsing = true;
4477 if chain != Chain::Mainnet && chain != Chain::Testnet {
4478 cfg.feature_flags.split_checkpoints_in_consensus_handler = true;
4479 }
4480 cfg.feature_flags.validate_zklogin_public_identifier = true;
4481 cfg.feature_flags.fix_checkpoint_signature_mapping = true;
4482 cfg.feature_flags
4483 .consensus_always_accept_system_transactions = true;
4484 if chain != Chain::Mainnet {
4485 cfg.feature_flags.enable_object_funds_withdraw = true;
4486 }
4487 }
4488 111 => {
4489 cfg.feature_flags.validator_metadata_verify_v2 = true;
4490 }
4491 112 => {
4492 cfg.group_ops_ristretto_decode_scalar_cost = Some(7);
4493 cfg.group_ops_ristretto_decode_point_cost = Some(200);
4494 cfg.group_ops_ristretto_scalar_add_cost = Some(10);
4495 cfg.group_ops_ristretto_point_add_cost = Some(500);
4496 cfg.group_ops_ristretto_scalar_sub_cost = Some(10);
4497 cfg.group_ops_ristretto_point_sub_cost = Some(500);
4498 cfg.group_ops_ristretto_scalar_mul_cost = Some(11);
4499 cfg.group_ops_ristretto_point_mul_cost = Some(1200);
4500 cfg.group_ops_ristretto_scalar_div_cost = Some(151);
4501 cfg.group_ops_ristretto_point_div_cost = Some(2500);
4502
4503 if chain != Chain::Mainnet && chain != Chain::Testnet {
4504 cfg.feature_flags.enable_ristretto255_group_ops = true;
4505 }
4506 }
4507 113 => {
4508 cfg.feature_flags.address_balance_gas_check_rgp_at_signing = true;
4509 if chain != Chain::Mainnet && chain != Chain::Testnet {
4510 cfg.feature_flags.defer_unpaid_amplification = true;
4511 }
4512 }
4513 114 => {
4514 cfg.feature_flags.randomize_checkpoint_tx_limit_in_tests = true;
4515 cfg.feature_flags.address_balance_gas_reject_gas_coin_arg = true;
4516 if chain != Chain::Mainnet {
4517 cfg.feature_flags.split_checkpoints_in_consensus_handler = true;
4518 cfg.feature_flags.enable_authenticated_event_streams = true;
4519 cfg.feature_flags
4520 .include_checkpoint_artifacts_digest_in_summary = true;
4521 }
4522 }
4523 115 => {
4524 cfg.feature_flags.normalize_depth_formula = true;
4525 }
4526 116 => {
4527 cfg.feature_flags.gasless_transaction_drop_safety = true;
4528 cfg.feature_flags.address_aliases = true;
4529 cfg.feature_flags.relax_valid_during_for_owned_inputs = true;
4530 cfg.feature_flags.defer_unpaid_amplification = false;
4532 cfg.feature_flags.enable_display_registry = true;
4533 }
4534 117 => {}
4535 118 => {
4536 cfg.feature_flags.use_coin_party_owner = true;
4537 }
4538 119 => {
4539 cfg.execution_version = Some(4);
4541 cfg.feature_flags.address_balance_gas_reject_gas_coin_arg = false;
4542 cfg.feature_flags.merge_randomness_into_checkpoint = true;
4543 if chain != Chain::Mainnet {
4544 cfg.feature_flags.enable_gasless = true;
4545 cfg.gasless_max_computation_units = Some(50_000);
4546 cfg.gasless_allowed_token_types = Some(vec![]);
4547 cfg.feature_flags.enable_coin_reservation_obj_refs = true;
4548 cfg.feature_flags
4549 .convert_withdrawal_compatibility_ptb_arguments = true;
4550 }
4551 cfg.gasless_max_unused_inputs = Some(1);
4552 cfg.gasless_max_pure_input_bytes = Some(32);
4553 if chain == Chain::Testnet {
4554 cfg.gasless_allowed_token_types = Some(vec![(TESTNET_USDC.to_string(), 0)]);
4555 }
4556 cfg.transfer_receive_object_cost_per_byte = Some(1);
4557 cfg.transfer_receive_object_type_cost_per_byte = Some(2);
4558 }
4559 120 => {
4560 cfg.feature_flags.disallow_jump_orphans = true;
4561 }
4562 121 => {
4563 if chain != Chain::Mainnet {
4565 cfg.feature_flags.defer_unpaid_amplification = true;
4566 cfg.gasless_max_tps = Some(50);
4567 }
4568 cfg.feature_flags
4569 .early_return_receive_object_mismatched_type = true;
4570 }
4571 122 => {
4572 cfg.feature_flags.defer_unpaid_amplification = true;
4574 cfg.verify_bulletproofs_ristretto255_base_cost = Some(30000);
4576 cfg.verify_bulletproofs_ristretto255_cost_per_bit_and_commitment = Some(6500);
4577 if chain != Chain::Mainnet && chain != Chain::Testnet {
4578 cfg.feature_flags.enable_verify_bulletproofs_ristretto255 = true;
4579 }
4580 cfg.feature_flags.gasless_verify_remaining_balance = true;
4581 cfg.include_special_package_amendments = match chain {
4582 Chain::Mainnet => Some(MAINNET_LINKAGE_AMENDMENTS.clone()),
4583 Chain::Testnet => Some(TESTNET_LINKAGE_AMENDMENTS.clone()),
4584 Chain::Unknown => None,
4585 };
4586 cfg.gasless_max_tx_size_bytes = Some(16 * 1024);
4587 cfg.gasless_max_tps = Some(300);
4588 cfg.gasless_max_computation_units = Some(5_000);
4589 }
4590 123 => {
4591 cfg.gas_model_version = Some(13);
4592 }
4593 124 => {
4594 if chain != Chain::Mainnet && chain != Chain::Testnet {
4595 cfg.feature_flags.timestamp_based_epoch_close = true;
4596 }
4597 cfg.gas_model_version = Some(14);
4598 cfg.feature_flags.limit_groth16_pvk_inputs = true;
4599
4600 cfg.feature_flags.enable_accumulators = true;
4606 cfg.feature_flags.enable_address_balance_gas_payments = true;
4607 cfg.feature_flags.enable_authenticated_event_streams = true;
4608 cfg.feature_flags.enable_coin_reservation_obj_refs = true;
4609 cfg.feature_flags.enable_object_funds_withdraw = true;
4610 cfg.feature_flags
4611 .convert_withdrawal_compatibility_ptb_arguments = true;
4612 cfg.feature_flags.split_checkpoints_in_consensus_handler = true;
4613 cfg.feature_flags
4614 .include_checkpoint_artifacts_digest_in_summary = true;
4615 cfg.feature_flags.enable_gasless = true;
4616
4617 if chain == Chain::Mainnet {
4622 cfg.gasless_allowed_token_types = Some(vec![
4623 (MAINNET_USDC.to_string(), 10_000),
4624 (MAINNET_USDSUI.to_string(), 10_000),
4625 (MAINNET_SUI_USDE.to_string(), 10_000),
4626 (MAINNET_USDY.to_string(), 10_000),
4627 (MAINNET_FDUSD.to_string(), 10_000),
4628 (MAINNET_AUSD.to_string(), 10_000),
4629 (MAINNET_USDB.to_string(), 10_000),
4630 ]);
4631 }
4632 }
4633 125 => {
4634 cfg.feature_flags.granular_post_execution_checks = true;
4635 if chain != Chain::Mainnet {
4636 cfg.feature_flags.timestamp_based_epoch_close = true;
4637 }
4638 }
4639 126 => {
4640 cfg.feature_flags.early_exit_on_iffw = true;
4641 }
4642 127 => {
4643 cfg.feature_flags.always_advance_dkg_to_resolution = true;
4644
4645 cfg.verify_bulletproofs_ristretto255_base_cost = Some(23866);
4646 cfg.verify_bulletproofs_ristretto255_cost_per_bit_and_commitment = Some(1324);
4647 cfg.group_ops_ristretto_decode_scalar_cost = Some(5);
4648 cfg.group_ops_ristretto_decode_point_cost = Some(216);
4649 cfg.group_ops_ristretto_scalar_add_cost = Some(2);
4650 cfg.group_ops_ristretto_point_add_cost = Some(8);
4651 cfg.group_ops_ristretto_scalar_sub_cost = Some(2);
4652 cfg.group_ops_ristretto_point_sub_cost = Some(8);
4653 cfg.group_ops_ristretto_scalar_mul_cost = Some(5);
4654 cfg.group_ops_ristretto_point_mul_cost = Some(1763);
4655 cfg.group_ops_ristretto_scalar_div_cost = Some(557);
4656 cfg.group_ops_ristretto_point_div_cost = Some(2244);
4657
4658 if chain != Chain::Mainnet {
4659 cfg.feature_flags.enable_ristretto255_group_ops = true;
4660 cfg.feature_flags.enable_verify_bulletproofs_ristretto255 = true;
4661 }
4662
4663 cfg.feature_flags.timestamp_based_epoch_close = true;
4664 }
4665 128 => {
4666 cfg.max_generic_instantiation_type_nodes_per_function = Some(10_000);
4667 cfg.max_generic_instantiation_type_nodes_per_module = Some(500_000);
4668 cfg.binary_enum_defs = Some(200);
4669 cfg.binary_enum_def_instantiations = Some(100);
4670 }
4671 129 => {
4672 cfg.feature_flags.enable_unified_linkage = true;
4673 }
4674 130 => {
4675 cfg.feature_flags.record_net_unsettled_object_withdraws = true;
4676 cfg.feature_flags.enable_init_on_upgrade = true;
4677 cfg.epoch_close_deadline_ms = Some(120_000);
4678 cfg.scratch_add_cost_base = Some(13);
4679 cfg.scratch_read_cost_base = Some(13);
4680 cfg.scratch_read_value_cost = Some(1);
4681 cfg.scratch_remove_cost_base = Some(13);
4682 cfg.scratch_exists_cost_base = Some(13);
4683 cfg.scratch_exists_with_type_cost_base = Some(13);
4684 cfg.scratch_exists_with_type_type_cost = Some(1);
4685 let max_commands = cfg.max_programmable_tx_commands() as u64;
4686 cfg.max_scratch_pad_size = Some(16 * max_commands);
4687 if chain != Chain::Mainnet && chain != Chain::Testnet {
4689 cfg.feature_flags.zklogin_circuit_mode = 1;
4690 }
4691 }
4692 131 => {
4693 cfg.feature_flags.share_transaction_deny_config_in_consensus = true;
4694 cfg.feature_flags.framework_tx_context_mut_restrictions = true;
4695 }
4696 132 => {
4697 if chain != Chain::Mainnet && chain != Chain::Testnet {
4698 cfg.feature_flags.defer_owned_object_double_spend = true;
4699 cfg.feature_flags.create_forwarding_address_registry = true;
4700 }
4701 cfg.object_record_new_uid_from_hash_cost_base = Some(1);
4702 cfg.feature_flags
4703 .enable_order_independent_upgrade_init_linkage = true;
4704 }
4705 133 => {
4706 cfg.feature_flags
4707 .include_function_signatures_in_instantiation_limits = true;
4708 cfg.max_accumulator_type_nodes = Some(16);
4709 }
4710 134 => {
4711 if chain != Chain::Mainnet {
4718 cfg.package_original_package_id_impl_cost_base = Some(52);
4719 let package_read_cost_per_byte = cfg.obj_access_cost_read_per_byte();
4720 cfg.package_original_package_id_impl_cost_per_byte =
4721 Some(package_read_cost_per_byte);
4722
4723 cfg.consensus_max_transactions_in_block_bytes = Some(288 * 1024);
4724 cfg.consensus_max_num_transactions_in_block = Some(128);
4725 }
4726
4727 if chain == Chain::Mainnet {
4728 cfg.feature_flags.defer_unpaid_amplification = false;
4729 }
4730 }
4731 135 => {
4732 cfg.package_original_package_id_impl_cost_base = Some(52);
4735 let package_read_cost_per_byte = cfg.obj_access_cost_read_per_byte();
4736 cfg.package_original_package_id_impl_cost_per_byte =
4737 Some(package_read_cost_per_byte);
4738
4739 cfg.consensus_max_transactions_in_block_bytes = Some(288 * 1024);
4740 cfg.consensus_max_num_transactions_in_block = Some(128);
4741
4742 cfg.feature_flags.defer_unpaid_amplification = false;
4743 }
4744 136 => {
4745 cfg.feature_flags.ptb_tx_context_restrictions = true;
4746
4747 cfg.translation_per_live_reference_charge = Some(1);
4748 cfg.max_ptb_live_references = Some(64);
4749 cfg.max_ptb_returned_references = Some(16);
4750 cfg.max_ptb_total_returned_references = Some(256);
4751
4752 if chain != Chain::Mainnet && chain != Chain::Testnet {
4753 cfg.feature_flags.allowed_proposers = true;
4754 }
4755 cfg.feature_flags.harden_linkage_consistency = true;
4756
4757 cfg.package_arena_size_in_bytes = Some(10_000_000);
4758 }
4759 137 => {
4760 cfg.verify_bulletproofs_ristretto255_cost_per_bit_and_commitment = Some(621);
4761 cfg.max_bulletproofs_total_bits = Some(1024);
4762
4763 if chain != Chain::Mainnet {
4764 cfg.feature_flags.enable_allowances = true;
4765 }
4766 cfg.feature_flags.fix_ptb_generated_reads = true;
4767 cfg.feature_flags.charge_ld_const_abstract_size = true;
4768 if chain != Chain::Mainnet && chain != Chain::Testnet {
4769 cfg.feature_flags.check_object_funds_withdraw_in_execution = true;
4770 }
4771 cfg.reserve_object_funds_for_withdrawal_cost_base = Some(52);
4772 cfg.reserve_object_funds_for_withdrawal_cold_read_cost = Some(184);
4775
4776 cfg.feature_flags.allowed_proposers = true;
4777
4778 cfg.feature_flags.validate_ptb_argument_indices = true;
4779 cfg.feature_flags.memory_safety_invariant_check_v2 = true;
4780 }
4781 138 => {
4782 cfg.gas_model_version = Some(15);
4783 if chain != Chain::Mainnet {
4784 cfg.feature_flags.check_object_funds_withdraw_in_execution = true;
4785 cfg.feature_flags.disable_effects_tx_dependencies = true;
4786 }
4787 }
4788 _ => panic!("unsupported version {:?}", version),
4799 }
4800 }
4801
4802 cfg
4803 }
4804
4805 pub fn apply_seeded_test_overrides(&mut self, seed: &[u8; 32]) {
4806 if !self.feature_flags.randomize_checkpoint_tx_limit_in_tests
4807 || !self.feature_flags.split_checkpoints_in_consensus_handler
4808 {
4809 return;
4810 }
4811
4812 if !mysten_common::in_test_configuration() {
4813 return;
4814 }
4815
4816 use rand::{Rng, SeedableRng, rngs::StdRng};
4817 let mut rng = StdRng::from_seed(*seed);
4818 let max_txns = rng.gen_range(10..=100u64);
4819 info!("seeded test override: max_transactions_per_checkpoint = {max_txns}");
4820 self.max_transactions_per_checkpoint = Some(max_txns);
4821 }
4822
4823 pub fn verifier_config(&self, signing_limits: Option<(usize, usize, usize)>) -> VerifierConfig {
4829 let (
4830 max_back_edges_per_function,
4831 max_back_edges_per_module,
4832 sanity_check_with_regex_reference_safety,
4833 ) = if let Some((
4834 max_back_edges_per_function,
4835 max_back_edges_per_module,
4836 sanity_check_with_regex_reference_safety,
4837 )) = signing_limits
4838 {
4839 (
4840 Some(max_back_edges_per_function),
4841 Some(max_back_edges_per_module),
4842 Some(sanity_check_with_regex_reference_safety),
4843 )
4844 } else {
4845 (None, None, None)
4846 };
4847
4848 let additional_borrow_checks = if signing_limits.is_some() {
4849 true
4851 } else {
4852 self.additional_borrow_checks()
4853 };
4854 let deprecate_global_storage_ops = if signing_limits.is_some() {
4855 true
4857 } else {
4858 self.deprecate_global_storage_ops()
4859 };
4860
4861 VerifierConfig {
4862 max_loop_depth: Some(self.max_loop_depth() as usize),
4863 max_generic_instantiation_length: Some(self.max_generic_instantiation_length() as usize),
4864 max_function_parameters: Some(self.max_function_parameters() as usize),
4865 max_basic_blocks: Some(self.max_basic_blocks() as usize),
4866 max_value_stack_size: self.max_value_stack_size() as usize,
4867 max_type_nodes: Some(self.max_type_nodes() as usize),
4868 max_generic_instantiation_type_nodes_per_function: self
4869 .max_generic_instantiation_type_nodes_per_function_as_option()
4870 .map(|v| v as usize),
4871 max_generic_instantiation_type_nodes_per_module: self
4872 .max_generic_instantiation_type_nodes_per_module_as_option()
4873 .map(|v| v as usize),
4874 include_function_signatures_in_instantiation_limits: self
4875 .include_function_signatures_in_instantiation_limits(),
4876 max_push_size: Some(self.max_push_size() as usize),
4877 max_dependency_depth: Some(self.max_dependency_depth() as usize),
4878 max_fields_in_struct: Some(self.max_fields_in_struct() as usize),
4879 max_function_definitions: Some(self.max_function_definitions() as usize),
4880 max_data_definitions: Some(self.max_struct_definitions() as usize),
4881 max_constant_vector_len: Some(self.max_move_vector_len()),
4882 max_back_edges_per_function,
4883 max_back_edges_per_module,
4884 max_basic_blocks_in_script: None,
4885 max_identifier_len: self.max_move_identifier_len_as_option(), disallow_self_identifier: self.feature_flags.disallow_self_identifier,
4887 allow_receiving_object_id: self.allow_receiving_object_id(),
4888 reject_mutable_random_on_entry_functions: self
4889 .reject_mutable_random_on_entry_functions(),
4890 bytecode_version: self.move_binary_format_version(),
4891 max_variants_in_enum: self.max_move_enum_variants_as_option(),
4892 additional_borrow_checks,
4893 better_loader_errors: self.better_loader_errors(),
4894 private_generics_verifier_v2: self.private_generics_verifier_v2(),
4895 sanity_check_with_regex_reference_safety: sanity_check_with_regex_reference_safety
4896 .map(|limit| limit as u128),
4897 deprecate_global_storage_ops,
4898 disable_entry_point_signature_check: self.disable_entry_point_signature_check(),
4899 switch_to_regex_reference_safety: false,
4900 framework_tx_context_mut_restrictions: self.framework_tx_context_mut_restrictions(),
4901 disallow_jump_orphans: self.disallow_jump_orphans(),
4902 }
4903 }
4904
4905 pub fn binary_config(
4906 &self,
4907 override_deprecate_global_storage_ops_during_deserialization: Option<bool>,
4908 ) -> BinaryConfig {
4909 let deprecate_global_storage_ops =
4910 override_deprecate_global_storage_ops_during_deserialization
4911 .unwrap_or_else(|| self.deprecate_global_storage_ops());
4912 BinaryConfig::new(
4913 self.move_binary_format_version(),
4914 self.min_move_binary_format_version_as_option()
4915 .unwrap_or(VERSION_1),
4916 self.no_extraneous_module_bytes(),
4917 deprecate_global_storage_ops,
4918 TableConfig {
4919 module_handles: self.binary_module_handles_as_option().unwrap_or(u16::MAX),
4920 datatype_handles: self.binary_struct_handles_as_option().unwrap_or(u16::MAX),
4921 function_handles: self.binary_function_handles_as_option().unwrap_or(u16::MAX),
4922 function_instantiations: self
4923 .binary_function_instantiations_as_option()
4924 .unwrap_or(u16::MAX),
4925 signatures: self.binary_signatures_as_option().unwrap_or(u16::MAX),
4926 constant_pool: self.binary_constant_pool_as_option().unwrap_or(u16::MAX),
4927 identifiers: self.binary_identifiers_as_option().unwrap_or(u16::MAX),
4928 address_identifiers: self
4929 .binary_address_identifiers_as_option()
4930 .unwrap_or(u16::MAX),
4931 struct_defs: self.binary_struct_defs_as_option().unwrap_or(u16::MAX),
4932 struct_def_instantiations: self
4933 .binary_struct_def_instantiations_as_option()
4934 .unwrap_or(u16::MAX),
4935 function_defs: self.binary_function_defs_as_option().unwrap_or(u16::MAX),
4936 field_handles: self.binary_field_handles_as_option().unwrap_or(u16::MAX),
4937 field_instantiations: self
4938 .binary_field_instantiations_as_option()
4939 .unwrap_or(u16::MAX),
4940 friend_decls: self.binary_friend_decls_as_option().unwrap_or(u16::MAX),
4941 enum_defs: self.binary_enum_defs_as_option().unwrap_or(u16::MAX),
4942 enum_def_instantiations: self
4943 .binary_enum_def_instantiations_as_option()
4944 .unwrap_or(u16::MAX),
4945 variant_handles: self.binary_variant_handles_as_option().unwrap_or(u16::MAX),
4946 variant_instantiation_handles: self
4947 .binary_variant_instantiation_handles_as_option()
4948 .unwrap_or(u16::MAX),
4949 },
4950 )
4951 }
4952
4953 pub fn apply_overrides_for_testing(
4957 override_fn: impl Fn(ProtocolVersion, Self) -> Self + Send + Sync + 'static,
4958 ) -> OverrideGuard {
4959 let mut cur = CONFIG_OVERRIDE.lock().unwrap();
4960 assert!(cur.is_none(), "config override already present");
4961 *cur = Some(Box::new(override_fn));
4962 OverrideGuard
4963 }
4964
4965 fn apply_config_override(version: ProtocolVersion, mut ret: Self) -> Self {
4966 if let Some(override_fn) = CONFIG_OVERRIDE.lock().unwrap().as_ref() {
4967 warn!(
4968 "overriding ProtocolConfig settings with custom settings (you should not see this log outside of tests)"
4969 );
4970 ret = override_fn(version, ret);
4971 }
4972 ret
4973 }
4974}
4975
4976impl ProtocolConfig {
4980 pub fn set_execution_version_for_testing(&mut self, val: u64) {
4984 let current = self.execution_version.unwrap_or(0);
4985 assert!(
4986 val >= current,
4987 "cannot downgrade execution_version from {current} to {val}: running an old \
4988 executor against a newer protocol config/framework is unsupported. To test \
4989 frozen executor behavior, start from the last protocol version of that executor \
4990 instead, so genesis loads the matching framework snapshot (see \
4991 test_address_balance_gas_v3_accumulator_sign)."
4992 );
4993 self.execution_version = Some(val);
4994 }
4995
4996 pub fn set_zklogin_circuit_mode_for_testing(&mut self, val: u64) {
4999 self.feature_flags.zklogin_circuit_mode = val
5000 }
5001
5002 pub fn set_per_object_congestion_control_mode_for_testing(
5003 &mut self,
5004 val: PerObjectCongestionControlMode,
5005 ) {
5006 self.feature_flags.per_object_congestion_control_mode = val;
5007 }
5008
5009 pub fn set_consensus_choice_for_testing(&mut self, val: ConsensusChoice) {
5010 self.feature_flags.consensus_choice = val;
5011 }
5012
5013 pub fn set_consensus_network_for_testing(&mut self, val: ConsensusNetwork) {
5014 self.feature_flags.consensus_network = val;
5015 }
5016
5017 pub fn set_zklogin_max_epoch_upper_bound_delta_for_testing(&mut self, val: Option<u64>) {
5018 self.feature_flags.zklogin_max_epoch_upper_bound_delta = val
5019 }
5020
5021 pub fn set_mysticeti_num_leaders_per_round_for_testing(&mut self, val: Option<usize>) {
5022 self.feature_flags.mysticeti_num_leaders_per_round = val;
5023 }
5024
5025 pub fn disable_accumulators_for_testing(&mut self) {
5026 self.feature_flags.enable_accumulators = false;
5027 self.feature_flags.enable_address_balance_gas_payments = false;
5028 }
5029
5030 pub fn enable_coin_reservation_for_testing(&mut self) {
5031 self.feature_flags.enable_coin_reservation_obj_refs = true;
5032 self.feature_flags
5033 .convert_withdrawal_compatibility_ptb_arguments = true;
5034 self.execution_version = Some(self.execution_version.map_or(4, |v| v.max(4)));
5037 }
5038
5039 pub fn disable_coin_reservation_for_testing(&mut self) {
5040 self.feature_flags.enable_coin_reservation_obj_refs = false;
5041 self.feature_flags
5042 .convert_withdrawal_compatibility_ptb_arguments = false;
5043 }
5044
5045 pub fn enable_address_balance_gas_payments_for_testing(&mut self) {
5046 self.feature_flags.enable_accumulators = true;
5047 self.feature_flags.allow_private_accumulator_entrypoints = true;
5048 self.feature_flags.enable_address_balance_gas_payments = true;
5049 self.feature_flags.address_balance_gas_check_rgp_at_signing = true;
5050 self.feature_flags.address_balance_gas_reject_gas_coin_arg = false;
5051 self.execution_version = Some(self.execution_version.map_or(4, |v| v.max(4)))
5052 }
5053
5054 pub fn enable_gasless_for_testing(&mut self) {
5055 self.enable_address_balance_gas_payments_for_testing();
5056 self.feature_flags.enable_gasless = true;
5057 self.feature_flags.gasless_verify_remaining_balance = true;
5058 self.gasless_max_computation_units = Some(5_000);
5059 self.gasless_allowed_token_types = Some(vec![]);
5060 self.gasless_max_tps = Some(1000);
5061 self.gasless_max_tx_size_bytes = Some(16 * 1024);
5062 }
5063
5064 pub fn disable_gasless_for_testing(&mut self) {
5065 self.feature_flags.enable_gasless = false;
5066 self.gasless_max_computation_units = None;
5067 self.gasless_allowed_token_types = None;
5068 }
5069
5070 pub fn enable_authenticated_event_streams_for_testing(&mut self) {
5071 self.feature_flags.enable_accumulators = true;
5072 self.feature_flags.enable_authenticated_event_streams = true;
5073 self.feature_flags
5074 .include_checkpoint_artifacts_digest_in_summary = true;
5075 self.feature_flags.split_checkpoints_in_consensus_handler = true;
5076 }
5077}
5078
5079type OverrideFn = dyn Fn(ProtocolVersion, ProtocolConfig) -> ProtocolConfig + Send + Sync;
5080
5081static CONFIG_OVERRIDE: Mutex<Option<Box<OverrideFn>>> = Mutex::new(None);
5082
5083#[must_use]
5084pub struct OverrideGuard;
5085
5086impl Drop for OverrideGuard {
5087 fn drop(&mut self) {
5088 info!("restoring override fn");
5089 *CONFIG_OVERRIDE.lock().unwrap() = None;
5090 }
5091}
5092
5093#[derive(PartialEq, Eq)]
5096pub enum LimitThresholdCrossed {
5097 None,
5098 Soft(u128, u128),
5099 Hard(u128, u128),
5100}
5101
5102pub fn check_limit_in_range<T: Into<V>, U: Into<V>, V: PartialOrd + Into<u128>>(
5105 x: T,
5106 soft_limit: U,
5107 hard_limit: V,
5108) -> LimitThresholdCrossed {
5109 let x: V = x.into();
5110 let soft_limit: V = soft_limit.into();
5111
5112 debug_assert!(soft_limit <= hard_limit);
5113
5114 if x >= hard_limit {
5117 LimitThresholdCrossed::Hard(x.into(), hard_limit.into())
5118 } else if x < soft_limit {
5119 LimitThresholdCrossed::None
5120 } else {
5121 LimitThresholdCrossed::Soft(x.into(), soft_limit.into())
5122 }
5123}
5124
5125#[macro_export]
5126macro_rules! check_limit {
5127 ($x:expr, $hard:expr) => {
5128 check_limit!($x, $hard, $hard)
5129 };
5130 ($x:expr, $soft:expr, $hard:expr) => {
5131 check_limit_in_range($x as u64, $soft, $hard)
5132 };
5133}
5134
5135#[macro_export]
5139macro_rules! check_limit_by_meter {
5140 ($is_metered:expr, $x:expr, $metered_limit:expr, $unmetered_hard_limit:expr, $metric:expr) => {{
5141 let (h, metered_str) = if $is_metered {
5143 ($metered_limit, "metered")
5144 } else {
5145 ($unmetered_hard_limit, "unmetered")
5147 };
5148 use sui_protocol_config::check_limit_in_range;
5149 let result = check_limit_in_range($x as u64, $metered_limit, h);
5150 match result {
5151 LimitThresholdCrossed::None => {}
5152 LimitThresholdCrossed::Soft(_, _) => {
5153 $metric.with_label_values(&[metered_str, "soft"]).inc();
5154 }
5155 LimitThresholdCrossed::Hard(_, _) => {
5156 $metric.with_label_values(&[metered_str, "hard"]).inc();
5157 }
5158 };
5159 result
5160 }};
5161}
5162
5163pub type Amendments = BTreeMap<AccountAddress, BTreeMap<AccountAddress, AccountAddress>>;
5166
5167static MAINNET_LINKAGE_AMENDMENTS: LazyLock<Arc<Amendments>> =
5168 LazyLock::new(|| parse_amendments(include_str!("mainnet_amendments.json")));
5169
5170static TESTNET_LINKAGE_AMENDMENTS: LazyLock<Arc<Amendments>> =
5171 LazyLock::new(|| parse_amendments(include_str!("testnet_amendments.json")));
5172
5173fn parse_amendments(json: &str) -> Arc<Amendments> {
5174 #[derive(serde::Deserialize)]
5175 struct AmendmentEntry {
5176 root: String,
5177 deps: Vec<DepEntry>,
5178 }
5179
5180 #[derive(serde::Deserialize)]
5181 struct DepEntry {
5182 original_id: String,
5183 version_id: String,
5184 }
5185
5186 let entries: Vec<AmendmentEntry> =
5187 serde_json::from_str(json).expect("Failed to parse amendments JSON");
5188 let mut amendments = BTreeMap::new();
5189 for entry in entries {
5190 let root_id = AccountAddress::from_hex_literal(&entry.root).unwrap();
5191 let mut dep_ids = BTreeMap::new();
5192 for dep in entry.deps {
5193 let orig_id = AccountAddress::from_hex_literal(&dep.original_id).unwrap();
5194 let upgraded_id = AccountAddress::from_hex_literal(&dep.version_id).unwrap();
5195 assert!(
5196 dep_ids.insert(orig_id, upgraded_id).is_none(),
5197 "Duplicate original ID in amendments table"
5198 );
5199 }
5200 assert!(
5201 amendments.insert(root_id, dep_ids).is_none(),
5202 "Duplicate root ID in amendments table"
5203 );
5204 }
5205 Arc::new(amendments)
5206}
5207
5208#[cfg(all(test, not(msim)))]
5209mod test {
5210 use insta::assert_yaml_snapshot;
5211
5212 use super::*;
5213
5214 #[test]
5215 fn snapshot_tests() {
5216 println!("\n============================================================================");
5217 println!("! !");
5218 println!("! IMPORTANT: never update snapshots from this test. only add new versions! !");
5219 println!("! !");
5220 println!("============================================================================\n");
5221 for chain_id in &[Chain::Unknown, Chain::Mainnet, Chain::Testnet] {
5222 let chain_str = match chain_id {
5226 Chain::Unknown => "".to_string(),
5227 _ => format!("{:?}_", chain_id),
5228 };
5229 for i in MIN_PROTOCOL_VERSION..=MAX_PROTOCOL_VERSION {
5230 let cur = ProtocolVersion::new(i);
5231 assert_yaml_snapshot!(
5232 format!("{}version_{}", chain_str, cur.as_u64()),
5233 ProtocolConfig::get_for_version(cur, *chain_id)
5234 );
5235 }
5236 }
5237 }
5238
5239 #[test]
5240 fn test_getters() {
5241 let prot: ProtocolConfig =
5242 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5243 assert_eq!(
5244 prot.max_arguments(),
5245 prot.max_arguments_as_option().unwrap()
5246 );
5247 }
5248
5249 #[test]
5250 fn test_setters() {
5251 let mut prot: ProtocolConfig =
5252 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5253 prot.set_max_arguments_for_testing(123);
5254 assert_eq!(prot.max_arguments(), 123);
5255
5256 prot.set_max_arguments_from_str_for_testing("321".to_string());
5257 assert_eq!(prot.max_arguments(), 321);
5258
5259 prot.disable_max_arguments_for_testing();
5260 assert_eq!(prot.max_arguments_as_option(), None);
5261
5262 prot.set_attr_for_testing("max_arguments".to_string(), "456".to_string());
5263 assert_eq!(prot.max_arguments(), 456);
5264 }
5265
5266 #[test]
5267 fn test_execution_version_setter_allows_upgrade() {
5268 let mut prot = ProtocolConfig::get_for_max_version_UNSAFE();
5269 let current = prot.execution_version();
5270 prot.set_execution_version_for_testing(current);
5271 prot.set_execution_version_for_testing(current + 1);
5272 assert_eq!(prot.execution_version(), current + 1);
5273 }
5274
5275 #[test]
5276 #[should_panic(expected = "cannot downgrade execution_version")]
5277 fn test_execution_version_setter_panics_on_downgrade() {
5278 let mut prot = ProtocolConfig::get_for_max_version_UNSAFE();
5279 let current = prot.execution_version();
5280 prot.set_execution_version_for_testing(current - 1);
5281 }
5282
5283 #[test]
5284 fn test_feature_flag_setter_by_string() {
5285 let mut prot: ProtocolConfig =
5286 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5287 assert!(!prot.zklogin_auth());
5288 prot.set_feature_flag_for_testing("zklogin_auth".to_string(), true);
5289 assert!(prot.zklogin_auth());
5290 prot.set_feature_flag_for_testing("zklogin_auth".to_string(), false);
5291 assert!(!prot.zklogin_auth());
5292 }
5293
5294 #[test]
5295 #[should_panic(expected = "unknown feature flag")]
5296 fn test_feature_flag_setter_unknown_flag() {
5297 let mut prot: ProtocolConfig =
5298 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5299 prot.set_feature_flag_for_testing("some random string".to_string(), true);
5300 }
5301
5302 #[test]
5303 fn test_get_for_version_if_supported_applies_test_overrides() {
5304 let before =
5305 ProtocolConfig::get_for_version_if_supported(ProtocolVersion::new(1), Chain::Unknown)
5306 .unwrap();
5307
5308 assert!(!before.enable_coin_reservation_obj_refs());
5309
5310 let _guard = ProtocolConfig::apply_overrides_for_testing(|_, mut cfg| {
5311 cfg.enable_coin_reservation_for_testing();
5312 cfg
5313 });
5314
5315 let after =
5316 ProtocolConfig::get_for_version_if_supported(ProtocolVersion::new(1), Chain::Unknown)
5317 .unwrap();
5318
5319 assert!(after.enable_coin_reservation_obj_refs());
5320 }
5321
5322 #[test]
5323 #[should_panic(expected = "unsupported version")]
5324 fn max_version_test() {
5325 let _ = ProtocolConfig::get_for_version_impl(
5328 ProtocolVersion::new(MAX_PROTOCOL_VERSION + 1),
5329 Chain::Unknown,
5330 );
5331 }
5332
5333 #[test]
5334 fn lookup_by_string_test() {
5335 let prot: ProtocolConfig =
5336 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5337 assert!(prot.lookup_attr("some random string".to_string()).is_none());
5339
5340 assert!(
5341 prot.lookup_attr("max_arguments".to_string())
5342 == Some(ProtocolConfigValue::u32(prot.max_arguments())),
5343 );
5344
5345 assert!(
5347 prot.lookup_attr("max_move_identifier_len".to_string())
5348 .is_none()
5349 );
5350
5351 let prot: ProtocolConfig =
5353 ProtocolConfig::get_for_version(ProtocolVersion::new(9), Chain::Unknown);
5354 assert!(
5355 prot.lookup_attr("max_move_identifier_len".to_string())
5356 == Some(ProtocolConfigValue::u64(prot.max_move_identifier_len()))
5357 );
5358
5359 let prot: ProtocolConfig =
5360 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5361 assert!(
5363 prot.attr_map()
5364 .get("max_move_identifier_len")
5365 .unwrap()
5366 .is_none()
5367 );
5368 assert!(
5370 prot.attr_map().get("max_arguments").unwrap()
5371 == &Some(ProtocolConfigValue::u32(prot.max_arguments()))
5372 );
5373
5374 let prot: ProtocolConfig =
5376 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5377 assert!(
5379 prot.feature_flags
5380 .lookup_attr("some random string".to_owned())
5381 .is_none()
5382 );
5383 assert!(
5384 !prot
5385 .feature_flags
5386 .attr_map()
5387 .contains_key("some random string")
5388 );
5389
5390 assert!(
5392 prot.feature_flags
5393 .lookup_attr("package_upgrades".to_owned())
5394 == Some(false)
5395 );
5396 assert!(
5397 prot.feature_flags
5398 .attr_map()
5399 .get("package_upgrades")
5400 .unwrap()
5401 == &false
5402 );
5403 let prot: ProtocolConfig =
5404 ProtocolConfig::get_for_version(ProtocolVersion::new(4), Chain::Unknown);
5405 assert!(
5407 prot.feature_flags
5408 .lookup_attr("package_upgrades".to_owned())
5409 == Some(true)
5410 );
5411 assert!(
5412 prot.feature_flags
5413 .attr_map()
5414 .get("package_upgrades")
5415 .unwrap()
5416 == &true
5417 );
5418 }
5419
5420 #[test]
5421 fn limit_range_fn_test() {
5422 let low = 100u32;
5423 let high = 10000u64;
5424
5425 assert!(check_limit!(1u8, low, high) == LimitThresholdCrossed::None);
5426 assert!(matches!(
5427 check_limit!(255u16, low, high),
5428 LimitThresholdCrossed::Soft(255u128, 100)
5429 ));
5430 assert!(matches!(
5436 check_limit!(2550000u64, low, high),
5437 LimitThresholdCrossed::Hard(2550000, 10000)
5438 ));
5439
5440 assert!(matches!(
5441 check_limit!(2550000u64, high, high),
5442 LimitThresholdCrossed::Hard(2550000, 10000)
5443 ));
5444
5445 assert!(matches!(
5446 check_limit!(1u8, high),
5447 LimitThresholdCrossed::None
5448 ));
5449
5450 assert!(check_limit!(255u16, high) == LimitThresholdCrossed::None);
5451
5452 assert!(matches!(
5453 check_limit!(2550000u64, high),
5454 LimitThresholdCrossed::Hard(2550000, 10000)
5455 ));
5456 }
5457
5458 #[test]
5459 fn linkage_amendments_load() {
5460 let mainnet = LazyLock::force(&MAINNET_LINKAGE_AMENDMENTS);
5461 let testnet = LazyLock::force(&TESTNET_LINKAGE_AMENDMENTS);
5462 assert!(!mainnet.is_empty(), "mainnet amendments must not be empty");
5463 assert!(!testnet.is_empty(), "testnet amendments must not be empty");
5464 }
5465
5466 #[test]
5467 fn render_scalar_fields_use_precision_safe_encoding() {
5468 use mysten_common::rpc_format::Unmetered;
5469
5470 let config = ProtocolConfig::get_for_max_version_UNSAFE();
5471 let rendered = config
5472 .render::<serde_json::Value>(&mut Unmetered)
5473 .expect("render should succeed");
5474
5475 let max_args = rendered
5476 .get("max_arguments")
5477 .expect("max_arguments set at max version");
5478 assert!(
5479 max_args.is_number(),
5480 "u32 should render as number, got {max_args:?}",
5481 );
5482
5483 let max_tx_size = rendered
5484 .get("max_tx_size_bytes")
5485 .expect("max_tx_size_bytes set at max version");
5486 assert!(
5487 max_tx_size.is_string(),
5488 "u64 should render as string, got {max_tx_size:?}",
5489 );
5490 }
5491
5492 #[test]
5493 fn render_includes_non_scalar_gasless_allowlist_as_json() {
5494 use mysten_common::rpc_format::Unmetered;
5495 use serde_json::json;
5496
5497 let mut config = ProtocolConfig::get_for_max_version_UNSAFE();
5498 config.set_gasless_allowed_token_types_for_testing(vec![
5499 ("0xa::usdc::USDC".to_string(), 10_000),
5500 ("0xb::usdt::USDT".to_string(), 0),
5501 ]);
5502
5503 let rendered = config
5504 .render::<serde_json::Value>(&mut Unmetered)
5505 .expect("render should succeed under Unmetered budget");
5506 let allowlist = rendered
5507 .get("gasless_allowed_token_types")
5508 .expect("entry should be present after the testing setter");
5509
5510 assert_eq!(
5513 allowlist,
5514 &json!([["0xa::usdc::USDC", "10000"], ["0xb::usdt::USDT", "0"],]),
5515 );
5516 }
5517
5518 #[test]
5519 fn render_targets_prost_value_for_grpc() {
5520 use mysten_common::rpc_format::Unmetered;
5521 use prost_types::value::Kind;
5522
5523 let mut config = ProtocolConfig::get_for_max_version_UNSAFE();
5524 config.set_gasless_allowed_token_types_for_testing(vec![(
5525 "0xa::usdc::USDC".to_string(),
5526 10_000,
5527 )]);
5528
5529 let rendered = config
5530 .render::<prost_types::Value>(&mut Unmetered)
5531 .expect("render to prost Value should succeed");
5532 let allowlist = rendered
5533 .get("gasless_allowed_token_types")
5534 .expect("entry should be present after the testing setter");
5535
5536 let Some(Kind::ListValue(outer)) = &allowlist.kind else {
5538 panic!(
5539 "expected ListValue at the top level, got {:?}",
5540 allowlist.kind
5541 );
5542 };
5543 assert_eq!(outer.values.len(), 1, "one allowlisted entry");
5544 let Some(Kind::ListValue(entry)) = &outer.values[0].kind else {
5545 panic!("expected each entry to be a ListValue");
5546 };
5547 assert_eq!(entry.values.len(), 2, "entry has (coin_type, amount)");
5548
5549 let Some(Kind::StringValue(coin_type)) = &entry.values[0].kind else {
5550 panic!("expected coin_type as StringValue");
5551 };
5552 assert_eq!(coin_type, "0xa::usdc::USDC");
5553
5554 let Some(Kind::StringValue(amount)) = &entry.values[1].kind else {
5556 panic!(
5557 "expected minimum_transfer_amount as StringValue (precision-safe u64); got {:?}",
5558 entry.values[1].kind,
5559 );
5560 };
5561 assert_eq!(amount, "10000");
5562 }
5563
5564 #[test]
5565 fn render_emits_null_for_unset_protocol_versions() {
5566 use mysten_common::rpc_format::Unmetered;
5567
5568 let config = ProtocolConfig::get_for_version(1.into(), Chain::Unknown);
5569 let rendered = config
5570 .render::<serde_json::Value>(&mut Unmetered)
5571 .expect("render should succeed");
5572 let entry = rendered
5576 .get("gasless_allowed_token_types")
5577 .expect("key should be present for every protocol version");
5578 assert!(
5579 entry.is_null(),
5580 "value should be null for pre-feature protocol version, got {entry:?}",
5581 );
5582 }
5583}