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)]
418pub struct ProtocolVersion(u64);
419
420impl ProtocolVersion {
421 pub const MIN: Self = Self(MIN_PROTOCOL_VERSION);
426
427 pub const MAX: Self = Self(MAX_PROTOCOL_VERSION);
428
429 #[cfg(not(msim))]
430 pub const MAX_ALLOWED: Self = Self::MAX;
431
432 #[cfg(msim)]
434 pub const MAX_ALLOWED: Self = Self(MAX_PROTOCOL_VERSION + 1);
435
436 pub fn new(v: u64) -> Self {
437 Self(v)
438 }
439
440 pub const fn as_u64(&self) -> u64 {
441 self.0
442 }
443
444 pub fn max() -> Self {
447 Self::MAX
448 }
449
450 pub fn prev(self) -> Self {
451 Self(self.0.checked_sub(1).unwrap())
452 }
453}
454
455impl From<u64> for ProtocolVersion {
456 fn from(v: u64) -> Self {
457 Self::new(v)
458 }
459}
460
461impl std::ops::Sub<u64> for ProtocolVersion {
462 type Output = Self;
463 fn sub(self, rhs: u64) -> Self::Output {
464 Self::new(self.0 - rhs)
465 }
466}
467
468impl std::ops::Add<u64> for ProtocolVersion {
469 type Output = Self;
470 fn add(self, rhs: u64) -> Self::Output {
471 Self::new(self.0 + rhs)
472 }
473}
474
475#[derive(
476 Clone, Serialize, Deserialize, Debug, Default, PartialEq, Copy, PartialOrd, Ord, Eq, ValueEnum,
477)]
478pub enum Chain {
479 Mainnet,
480 Testnet,
481 #[default]
482 Unknown,
483}
484
485impl Chain {
486 pub fn as_str(self) -> &'static str {
487 match self {
488 Chain::Mainnet => "mainnet",
489 Chain::Testnet => "testnet",
490 Chain::Unknown => "unknown",
491 }
492 }
493}
494
495pub struct Error(pub String);
496
497#[derive(Default, Clone, Serialize, Deserialize, Debug, ProtocolConfigFeatureFlagsGetters)]
500struct FeatureFlags {
501 #[serde(skip_serializing_if = "is_false")]
504 package_upgrades: bool,
505 #[serde(skip_serializing_if = "is_false")]
508 commit_root_state_digest: bool,
509 #[serde(skip_serializing_if = "is_false")]
511 advance_epoch_start_time_in_safe_mode: bool,
512 #[serde(skip_serializing_if = "is_false")]
515 loaded_child_objects_fixed: bool,
516 #[serde(skip_serializing_if = "is_false")]
519 missing_type_is_compatibility_error: bool,
520 #[serde(skip_serializing_if = "is_false")]
523 scoring_decision_with_validity_cutoff: bool,
524
525 #[serde(skip_serializing_if = "is_false")]
528 consensus_order_end_of_epoch_last: bool,
529
530 #[serde(skip_serializing_if = "is_false")]
534 consensus_slim_block_propagation: bool,
535
536 #[serde(skip_serializing_if = "is_false")]
538 disallow_adding_abilities_on_upgrade: bool,
539 #[serde(skip_serializing_if = "is_false")]
541 disable_invariant_violation_check_in_swap_loc: bool,
542 #[serde(skip_serializing_if = "is_false")]
545 advance_to_highest_supported_protocol_version: bool,
546 #[serde(skip_serializing_if = "is_false")]
548 ban_entry_init: bool,
549 #[serde(skip_serializing_if = "is_false")]
551 package_digest_hash_module: bool,
552 #[serde(skip_serializing_if = "is_false")]
554 disallow_change_struct_type_params_on_upgrade: bool,
555 #[serde(skip_serializing_if = "is_false")]
557 no_extraneous_module_bytes: bool,
558 #[serde(skip_serializing_if = "is_false")]
560 narwhal_versioned_metadata: bool,
561
562 #[serde(skip_serializing_if = "is_false")]
564 zklogin_auth: bool,
565 #[serde(skip_serializing_if = "is_zero")]
568 zklogin_circuit_mode: u64,
569 #[serde(skip_serializing_if = "ConsensusTransactionOrdering::is_none")]
571 consensus_transaction_ordering: ConsensusTransactionOrdering,
572
573 #[serde(skip_serializing_if = "is_false")]
581 simplified_unwrap_then_delete: bool,
582 #[serde(skip_serializing_if = "is_false")]
584 upgraded_multisig_supported: bool,
585 #[serde(skip_serializing_if = "is_false")]
587 txn_base_cost_as_multiplier: bool,
588
589 #[serde(skip_serializing_if = "is_false")]
591 shared_object_deletion: bool,
592
593 #[serde(skip_serializing_if = "is_false")]
595 narwhal_new_leader_election_schedule: bool,
596
597 #[serde(skip_serializing_if = "is_empty")]
599 zklogin_supported_providers: BTreeSet<String>,
600
601 #[serde(skip_serializing_if = "is_false")]
603 loaded_child_object_format: bool,
604
605 #[serde(skip_serializing_if = "is_false")]
606 #[skip_protocol_config_accessor]
607 enable_jwk_consensus_updates: bool,
608
609 #[serde(skip_serializing_if = "is_false")]
610 #[skip_protocol_config_accessor]
611 end_of_epoch_transaction_supported: bool,
612
613 #[serde(skip_serializing_if = "is_false")]
616 simple_conservation_checks: bool,
617
618 #[serde(skip_serializing_if = "is_false")]
620 loaded_child_object_format_type: bool,
621
622 #[serde(skip_serializing_if = "is_false")]
624 receive_objects: bool,
625
626 #[serde(skip_serializing_if = "is_false")]
628 consensus_checkpoint_signature_key_includes_digest: bool,
629
630 #[serde(skip_serializing_if = "is_false")]
632 random_beacon: bool,
633
634 #[serde(skip_serializing_if = "is_false")]
636 #[skip_protocol_config_accessor]
637 bridge: bool,
638
639 #[serde(skip_serializing_if = "is_false")]
640 enable_effects_v2: bool,
641
642 #[serde(skip_serializing_if = "is_false")]
644 narwhal_certificate_v2: bool,
645
646 #[serde(skip_serializing_if = "is_false")]
648 verify_legacy_zklogin_address: bool,
649
650 #[serde(skip_serializing_if = "is_false")]
652 throughput_aware_consensus_submission: bool,
653
654 #[serde(skip_serializing_if = "is_false")]
656 recompute_has_public_transfer_in_execution: bool,
657
658 #[serde(skip_serializing_if = "is_false")]
660 accept_zklogin_in_multisig: bool,
661
662 #[serde(skip_serializing_if = "is_false")]
664 accept_passkey_in_multisig: bool,
665
666 #[serde(skip_serializing_if = "is_false")]
668 validate_zklogin_public_identifier: bool,
669
670 #[serde(skip_serializing_if = "is_false")]
673 include_consensus_digest_in_prologue: bool,
674
675 #[serde(skip_serializing_if = "is_false")]
677 hardened_otw_check: bool,
678
679 #[serde(skip_serializing_if = "is_false")]
681 allow_receiving_object_id: bool,
682
683 #[serde(skip_serializing_if = "is_false")]
685 enable_poseidon: bool,
686
687 #[serde(skip_serializing_if = "is_false")]
689 enable_coin_deny_list: bool,
690
691 #[serde(skip_serializing_if = "is_false")]
693 enable_group_ops_native_functions: bool,
694
695 #[serde(skip_serializing_if = "is_false")]
697 enable_group_ops_native_function_msm: bool,
698
699 #[serde(skip_serializing_if = "is_false")]
701 enable_ristretto255_group_ops: bool,
702
703 #[serde(skip_serializing_if = "is_false")]
705 enable_verify_bulletproofs_ristretto255: bool,
706
707 #[serde(skip_serializing_if = "is_false")]
709 enable_nitro_attestation: bool,
710
711 #[serde(skip_serializing_if = "is_false")]
713 enable_nitro_attestation_upgraded_parsing: bool,
714
715 #[serde(skip_serializing_if = "is_false")]
717 enable_nitro_attestation_all_nonzero_pcrs_parsing: bool,
718
719 #[serde(skip_serializing_if = "is_false")]
721 enable_nitro_attestation_always_include_required_pcrs_parsing: bool,
722
723 #[serde(skip_serializing_if = "is_false")]
725 reject_mutable_random_on_entry_functions: bool,
726
727 #[serde(skip_serializing_if = "PerObjectCongestionControlMode::is_none")]
729 per_object_congestion_control_mode: PerObjectCongestionControlMode,
730
731 #[serde(skip_serializing_if = "ConsensusChoice::is_narwhal")]
733 consensus_choice: ConsensusChoice,
734
735 #[serde(skip_serializing_if = "ConsensusNetwork::is_anemo")]
737 consensus_network: ConsensusNetwork,
738
739 #[serde(skip_serializing_if = "is_false")]
741 correct_gas_payment_limit_check: bool,
742
743 #[serde(skip_serializing_if = "Option::is_none")]
745 zklogin_max_epoch_upper_bound_delta: Option<u64>,
746
747 #[serde(skip_serializing_if = "is_false")]
749 mysticeti_leader_scoring_and_schedule: bool,
750
751 #[serde(skip_serializing_if = "is_false")]
753 reshare_at_same_initial_version: bool,
754
755 #[serde(skip_serializing_if = "is_false")]
757 resolve_abort_locations_to_package_id: bool,
758
759 #[serde(skip_serializing_if = "is_false")]
763 mysticeti_use_committed_subdag_digest: bool,
764
765 #[serde(skip_serializing_if = "is_false")]
767 enable_vdf: bool,
768
769 #[serde(skip_serializing_if = "is_false")]
773 record_consensus_determined_version_assignments_in_prologue: bool,
774 #[serde(skip_serializing_if = "is_false")]
777 record_consensus_determined_version_assignments_in_prologue_v2: bool,
778
779 #[serde(skip_serializing_if = "is_false")]
781 fresh_vm_on_framework_upgrade: bool,
782
783 #[serde(skip_serializing_if = "is_false")]
791 prepend_prologue_tx_in_consensus_commit_in_checkpoints: bool,
792
793 #[serde(skip_serializing_if = "Option::is_none")]
795 mysticeti_num_leaders_per_round: Option<usize>,
796
797 #[serde(skip_serializing_if = "is_false")]
799 soft_bundle: bool,
800
801 #[serde(skip_serializing_if = "is_false")]
803 enable_coin_deny_list_v2: bool,
804
805 #[serde(skip_serializing_if = "is_false")]
807 passkey_auth: bool,
808
809 #[serde(skip_serializing_if = "is_false")]
811 authority_capabilities_v2: bool,
812
813 #[serde(skip_serializing_if = "is_false")]
815 rethrow_serialization_type_layout_errors: bool,
816
817 #[serde(skip_serializing_if = "is_false")]
819 consensus_distributed_vote_scoring_strategy: bool,
820
821 #[serde(skip_serializing_if = "is_false")]
823 consensus_round_prober: bool,
824
825 #[serde(skip_serializing_if = "is_false")]
827 validate_identifier_inputs: bool,
828
829 #[serde(skip_serializing_if = "is_false")]
831 disallow_self_identifier: bool,
832
833 #[serde(skip_serializing_if = "is_false")]
835 mysticeti_fastpath: bool,
836
837 #[serde(skip_serializing_if = "is_false")]
841 disable_preconsensus_locking: bool,
842
843 #[serde(skip_serializing_if = "is_false")]
845 relocate_event_module: bool,
846
847 #[serde(skip_serializing_if = "is_false")]
849 uncompressed_g1_group_elements: bool,
850
851 #[serde(skip_serializing_if = "is_false")]
852 disallow_new_modules_in_deps_only_packages: bool,
853
854 #[serde(skip_serializing_if = "is_false")]
856 consensus_smart_ancestor_selection: bool,
857
858 #[serde(skip_serializing_if = "is_false")]
860 consensus_round_prober_probe_accepted_rounds: bool,
861
862 #[serde(skip_serializing_if = "is_false")]
864 native_charging_v2: bool,
865
866 #[serde(skip_serializing_if = "is_false")]
869 #[skip_protocol_config_accessor]
870 consensus_linearize_subdag_v2: bool,
871
872 #[serde(skip_serializing_if = "is_false")]
874 convert_type_argument_error: bool,
875
876 #[serde(skip_serializing_if = "is_false")]
878 variant_nodes: bool,
879
880 #[serde(skip_serializing_if = "is_false")]
882 consensus_zstd_compression: bool,
883
884 #[serde(skip_serializing_if = "is_false")]
886 minimize_child_object_mutations: bool,
887
888 #[serde(skip_serializing_if = "is_false")]
891 record_additional_state_digest_in_prologue: bool,
892
893 #[serde(skip_serializing_if = "is_false")]
895 move_native_context: bool,
896
897 #[serde(skip_serializing_if = "is_false")]
900 #[skip_protocol_config_accessor]
901 consensus_median_based_commit_timestamp: bool,
902
903 #[serde(skip_serializing_if = "is_false")]
906 normalize_ptb_arguments: bool,
907
908 #[serde(skip_serializing_if = "is_false")]
910 consensus_batched_block_sync: bool,
911
912 #[serde(skip_serializing_if = "is_false")]
914 enforce_checkpoint_timestamp_monotonicity: bool,
915
916 #[serde(skip_serializing_if = "is_false")]
918 max_ptb_value_size_v2: bool,
919
920 #[serde(skip_serializing_if = "is_false")]
922 resolve_type_input_ids_to_defining_id: bool,
923
924 #[serde(skip_serializing_if = "is_false")]
926 enable_party_transfer: bool,
927
928 #[serde(skip_serializing_if = "is_false")]
930 allow_unbounded_system_objects: bool,
931
932 #[serde(skip_serializing_if = "is_false")]
934 type_tags_in_object_runtime: bool,
935
936 #[serde(skip_serializing_if = "is_false")]
938 enable_accumulators: bool,
939
940 #[serde(skip_serializing_if = "is_false")]
942 #[skip_protocol_config_accessor]
943 enable_coin_reservation_obj_refs: bool,
944
945 #[serde(skip_serializing_if = "is_false")]
948 create_root_accumulator_object: bool,
949
950 #[serde(skip_serializing_if = "is_false")]
952 #[skip_protocol_config_accessor]
953 enable_authenticated_event_streams: bool,
954
955 #[serde(skip_serializing_if = "is_false")]
957 enable_address_balance_gas_payments: bool,
958
959 #[serde(skip_serializing_if = "is_false")]
961 address_balance_gas_check_rgp_at_signing: bool,
962
963 #[serde(skip_serializing_if = "is_false")]
964 address_balance_gas_reject_gas_coin_arg: bool,
965
966 #[serde(skip_serializing_if = "is_false")]
968 enable_multi_epoch_transaction_expiration: bool,
969
970 #[serde(skip_serializing_if = "is_false")]
972 relax_valid_during_for_owned_inputs: bool,
973
974 #[serde(skip_serializing_if = "is_false")]
976 enable_ptb_execution_v2: bool,
977
978 #[serde(skip_serializing_if = "is_false")]
980 better_adapter_type_resolution_errors: bool,
981
982 #[serde(skip_serializing_if = "is_false")]
984 record_time_estimate_processed: bool,
985
986 #[serde(skip_serializing_if = "is_false")]
988 dependency_linkage_error: bool,
989
990 #[serde(skip_serializing_if = "is_false")]
992 additional_multisig_checks: bool,
993
994 #[serde(skip_serializing_if = "is_false")]
996 ignore_execution_time_observations_after_certs_closed: bool,
997
998 #[serde(skip_serializing_if = "is_false")]
1002 debug_fatal_on_move_invariant_violation: bool,
1003
1004 #[serde(skip_serializing_if = "is_false")]
1007 allow_private_accumulator_entrypoints: bool,
1008
1009 #[serde(skip_serializing_if = "is_false")]
1012 additional_consensus_digest_indirect_state: bool,
1013
1014 #[serde(skip_serializing_if = "is_false")]
1016 check_for_init_during_upgrade: bool,
1017
1018 #[serde(skip_serializing_if = "is_false")]
1020 enable_init_on_upgrade: bool,
1021
1022 #[serde(skip_serializing_if = "is_false")]
1024 enable_order_independent_upgrade_init_linkage: bool,
1025
1026 #[serde(skip_serializing_if = "is_false")]
1029 harden_linkage_consistency: bool,
1030
1031 #[serde(skip_serializing_if = "is_false")]
1033 per_command_shared_object_transfer_rules: bool,
1034
1035 #[serde(skip_serializing_if = "is_false")]
1037 validate_ptb_argument_indices: bool,
1038
1039 #[serde(skip_serializing_if = "is_false")]
1041 include_checkpoint_artifacts_digest_in_summary: bool,
1042
1043 #[serde(skip_serializing_if = "is_false")]
1045 use_mfp_txns_in_load_initial_object_debts: bool,
1046
1047 #[serde(skip_serializing_if = "is_false")]
1049 cancel_for_failed_dkg_early: bool,
1050
1051 #[serde(skip_serializing_if = "is_false")]
1053 always_advance_dkg_to_resolution: bool,
1054
1055 #[serde(skip_serializing_if = "is_false")]
1057 enable_coin_registry: bool,
1058
1059 #[serde(skip_serializing_if = "is_false")]
1061 abstract_size_in_object_runtime: bool,
1062
1063 #[serde(skip_serializing_if = "is_false")]
1065 object_runtime_charge_cache_load_gas: bool,
1066
1067 #[serde(skip_serializing_if = "is_false")]
1069 additional_borrow_checks: bool,
1070
1071 #[serde(skip_serializing_if = "is_false")]
1073 use_new_commit_handler: bool,
1074
1075 #[serde(skip_serializing_if = "is_false")]
1077 better_loader_errors: bool,
1078
1079 #[serde(skip_serializing_if = "is_false")]
1081 generate_df_type_layouts: bool,
1082
1083 #[serde(skip_serializing_if = "is_false")]
1085 allow_references_in_ptbs: bool,
1086
1087 #[serde(skip_serializing_if = "is_false")]
1094 framework_tx_context_mut_restrictions: bool,
1095
1096 #[serde(skip_serializing_if = "is_false")]
1098 include_function_signatures_in_instantiation_limits: bool,
1099
1100 #[serde(skip_serializing_if = "is_false")]
1105 ptb_tx_context_restrictions: bool,
1106
1107 #[serde(skip_serializing_if = "is_false")]
1109 enable_display_registry: bool,
1110
1111 #[serde(skip_serializing_if = "is_false")]
1113 private_generics_verifier_v2: bool,
1114
1115 #[serde(skip_serializing_if = "is_false")]
1117 deprecate_global_storage_ops_during_deserialization: bool,
1118
1119 #[serde(skip_serializing_if = "is_false")]
1122 enable_non_exclusive_writes: bool,
1123
1124 #[serde(skip_serializing_if = "is_false")]
1126 deprecate_global_storage_ops: bool,
1127
1128 #[serde(skip_serializing_if = "is_false")]
1130 normalize_depth_formula: bool,
1131
1132 #[serde(skip_serializing_if = "is_false")]
1135 charge_ld_const_abstract_size: bool,
1136
1137 #[serde(skip_serializing_if = "is_false")]
1139 consensus_skip_gced_accept_votes: bool,
1140
1141 #[serde(skip_serializing_if = "is_false")]
1144 include_cancelled_randomness_txns_in_prologue: bool,
1145
1146 #[serde(skip_serializing_if = "is_false")]
1148 #[skip_protocol_config_accessor]
1149 address_aliases: bool,
1150
1151 #[serde(skip_serializing_if = "is_false")]
1153 create_forwarding_address_registry: bool,
1154
1155 #[serde(skip_serializing_if = "is_false")]
1158 fix_checkpoint_signature_mapping: bool,
1159
1160 #[serde(skip_serializing_if = "is_false")]
1162 enable_object_funds_withdraw: bool,
1163
1164 #[serde(skip_serializing_if = "is_false")]
1167 record_net_unsettled_object_withdraws: bool,
1168
1169 #[serde(skip_serializing_if = "is_false")]
1171 consensus_skip_gced_blocks_in_direct_finalization: bool,
1172
1173 #[serde(skip_serializing_if = "is_false")]
1175 gas_rounding_halve_digits: bool,
1176
1177 #[serde(skip_serializing_if = "is_false")]
1179 flexible_tx_context_positions: bool,
1180
1181 #[serde(skip_serializing_if = "is_false")]
1183 disable_entry_point_signature_check: bool,
1184
1185 #[serde(skip_serializing_if = "is_false")]
1187 convert_withdrawal_compatibility_ptb_arguments: bool,
1188
1189 #[serde(skip_serializing_if = "is_false")]
1191 restrict_hot_or_not_entry_functions: bool,
1192
1193 #[serde(skip_serializing_if = "is_false")]
1195 split_checkpoints_in_consensus_handler: bool,
1196
1197 #[serde(skip_serializing_if = "is_false")]
1199 consensus_always_accept_system_transactions: bool,
1200
1201 #[serde(skip_serializing_if = "is_false")]
1203 validator_metadata_verify_v2: bool,
1204
1205 #[serde(skip_serializing_if = "is_false")]
1208 defer_unpaid_amplification: bool,
1209
1210 #[serde(skip_serializing_if = "is_false")]
1213 defer_owned_object_double_spend: bool,
1214
1215 #[serde(skip_serializing_if = "is_false")]
1218 allowed_proposers: bool,
1219
1220 #[serde(skip_serializing_if = "is_false")]
1221 randomize_checkpoint_tx_limit_in_tests: bool,
1222
1223 #[serde(skip_serializing_if = "is_false")]
1225 gasless_transaction_drop_safety: bool,
1226
1227 #[serde(skip_serializing_if = "is_false")]
1230 merge_randomness_into_checkpoint: bool,
1231
1232 #[serde(skip_serializing_if = "is_false")]
1234 use_coin_party_owner: bool,
1235
1236 #[serde(skip_serializing_if = "is_false")]
1237 enable_gasless: bool,
1238
1239 #[serde(skip_serializing_if = "is_false")]
1240 gasless_verify_remaining_balance: bool,
1241
1242 #[serde(skip_serializing_if = "is_false")]
1243 disallow_jump_orphans: bool,
1244
1245 #[serde(skip_serializing_if = "is_false")]
1247 early_return_receive_object_mismatched_type: bool,
1248
1249 #[serde(skip_serializing_if = "is_false")]
1254 timestamp_based_epoch_close: bool,
1255
1256 #[serde(skip_serializing_if = "is_false")]
1259 limit_groth16_pvk_inputs: bool,
1260
1261 #[serde(skip_serializing_if = "is_false")]
1266 enforce_address_balance_change_invariant: bool,
1267
1268 #[serde(skip_serializing_if = "is_false")]
1270 share_transaction_deny_config_in_consensus: bool,
1271
1272 #[serde(skip_serializing_if = "is_false")]
1274 granular_post_execution_checks: bool,
1275
1276 #[serde(skip_serializing_if = "is_false")]
1278 early_exit_on_iffw: bool,
1279
1280 #[serde(skip_serializing_if = "is_false")]
1282 enable_unified_linkage: bool,
1283
1284 #[serde(skip_serializing_if = "is_false")]
1287 #[skip_protocol_config_accessor]
1288 enable_allowances: bool,
1289
1290 #[serde(skip_serializing_if = "is_false")]
1292 fix_ptb_generated_reads: bool,
1293
1294 #[serde(skip_serializing_if = "is_false")]
1295 check_object_funds_withdraw_in_execution: bool,
1296 #[serde(skip_serializing_if = "is_false")]
1298 memory_safety_invariant_check_v2: bool,
1299
1300 #[serde(skip_serializing_if = "is_false")]
1302 disable_effects_tx_dependencies: bool,
1303
1304 #[serde(skip_serializing_if = "is_false")]
1308 merge_colliding_deferrals: bool,
1309}
1310
1311fn is_false(b: &bool) -> bool {
1312 !b
1313}
1314
1315fn is_empty(b: &BTreeSet<String>) -> bool {
1316 b.is_empty()
1317}
1318
1319fn is_zero(val: &u64) -> bool {
1320 *val == 0
1321}
1322
1323#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1325pub enum ConsensusTransactionOrdering {
1326 #[default]
1328 None,
1329 ByGasPrice,
1331}
1332
1333impl ConsensusTransactionOrdering {
1334 pub fn is_none(&self) -> bool {
1335 matches!(self, ConsensusTransactionOrdering::None)
1336 }
1337}
1338
1339#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1340pub struct ExecutionTimeEstimateParams {
1341 pub target_utilization: u64,
1343 pub allowed_txn_cost_overage_burst_limit_us: u64,
1347
1348 pub randomness_scalar: u64,
1351
1352 pub max_estimate_us: u64,
1354
1355 pub stored_observations_num_included_checkpoints: u64,
1358
1359 pub stored_observations_limit: u64,
1361
1362 #[serde(skip_serializing_if = "is_zero")]
1365 pub stake_weighted_median_threshold: u64,
1366
1367 #[serde(skip_serializing_if = "is_false")]
1371 pub default_none_duration_for_new_keys: bool,
1372
1373 #[serde(skip_serializing_if = "Option::is_none")]
1375 pub observations_chunk_size: Option<u64>,
1376}
1377
1378#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1380pub enum PerObjectCongestionControlMode {
1381 #[default]
1382 None, TotalGasBudget, TotalTxCount, TotalGasBudgetWithCap, ExecutionTimeEstimate(ExecutionTimeEstimateParams), }
1388
1389impl PerObjectCongestionControlMode {
1390 pub fn is_none(&self) -> bool {
1391 matches!(self, PerObjectCongestionControlMode::None)
1392 }
1393}
1394
1395#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1397pub enum ConsensusChoice {
1398 #[default]
1399 Narwhal,
1400 SwapEachEpoch,
1401 Mysticeti,
1402}
1403
1404impl ConsensusChoice {
1405 pub fn is_narwhal(&self) -> bool {
1406 matches!(self, ConsensusChoice::Narwhal)
1407 }
1408}
1409
1410#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1412pub enum ConsensusNetwork {
1413 #[default]
1414 Anemo,
1415 Tonic,
1416}
1417
1418impl ConsensusNetwork {
1419 pub fn is_anemo(&self) -> bool {
1420 matches!(self, ConsensusNetwork::Anemo)
1421 }
1422}
1423
1424#[skip_serializing_none]
1456#[derive(Clone, Serialize, Debug, ProtocolConfigAccessors, ProtocolConfigOverride)]
1457pub struct ProtocolConfig {
1458 pub version: ProtocolVersion,
1459
1460 #[serde(skip)]
1465 chain: Chain,
1466
1467 feature_flags: FeatureFlags,
1468
1469 max_tx_size_bytes: Option<u64>,
1472
1473 max_input_objects: Option<u64>,
1475
1476 max_size_written_objects: Option<u64>,
1480 max_size_written_objects_system_tx: Option<u64>,
1483
1484 max_serialized_tx_effects_size_bytes: Option<u64>,
1486
1487 max_serialized_tx_effects_size_bytes_system_tx: Option<u64>,
1489
1490 max_gas_payment_objects: Option<u32>,
1492
1493 max_modules_in_publish: Option<u32>,
1495
1496 max_package_dependencies: Option<u32>,
1498
1499 max_arguments: Option<u32>,
1502
1503 max_type_arguments: Option<u32>,
1505
1506 max_type_argument_depth: Option<u32>,
1508
1509 max_pure_argument_size: Option<u32>,
1511
1512 max_programmable_tx_commands: Option<u32>,
1514
1515 move_binary_format_version: Option<u32>,
1518 min_move_binary_format_version: Option<u32>,
1519
1520 binary_module_handles: Option<u16>,
1522 binary_struct_handles: Option<u16>,
1523 binary_function_handles: Option<u16>,
1524 binary_function_instantiations: Option<u16>,
1525 binary_signatures: Option<u16>,
1526 binary_constant_pool: Option<u16>,
1527 binary_identifiers: Option<u16>,
1528 binary_address_identifiers: Option<u16>,
1529 binary_struct_defs: Option<u16>,
1530 binary_struct_def_instantiations: Option<u16>,
1531 binary_function_defs: Option<u16>,
1532 binary_field_handles: Option<u16>,
1533 binary_field_instantiations: Option<u16>,
1534 binary_friend_decls: Option<u16>,
1535 binary_enum_defs: Option<u16>,
1536 binary_enum_def_instantiations: Option<u16>,
1537 binary_variant_handles: Option<u16>,
1538 binary_variant_instantiation_handles: Option<u16>,
1539
1540 max_move_object_size: Option<u64>,
1542
1543 max_move_package_size: Option<u64>,
1546
1547 max_publish_or_upgrade_per_ptb: Option<u64>,
1549
1550 max_tx_gas: Option<u64>,
1552
1553 max_gas_price: Option<u64>,
1555
1556 max_gas_price_rgp_factor_for_aborted_transactions: Option<u64>,
1559
1560 max_gas_computation_bucket: Option<u64>,
1562
1563 gas_rounding_step: Option<u64>,
1565
1566 max_loop_depth: Option<u64>,
1568
1569 max_generic_instantiation_length: Option<u64>,
1571
1572 max_function_parameters: Option<u64>,
1574
1575 max_basic_blocks: Option<u64>,
1577
1578 max_value_stack_size: Option<u64>,
1580
1581 max_type_nodes: Option<u64>,
1583
1584 max_generic_instantiation_type_nodes_per_function: Option<u64>,
1586
1587 max_generic_instantiation_type_nodes_per_module: Option<u64>,
1589
1590 max_accumulator_type_nodes: Option<u64>,
1592
1593 max_push_size: Option<u64>,
1595
1596 max_struct_definitions: Option<u64>,
1598
1599 max_function_definitions: Option<u64>,
1601
1602 max_fields_in_struct: Option<u64>,
1604
1605 max_dependency_depth: Option<u64>,
1607
1608 max_num_event_emit: Option<u64>,
1610
1611 max_num_new_move_object_ids: Option<u64>,
1613
1614 max_num_new_move_object_ids_system_tx: Option<u64>,
1616
1617 max_num_deleted_move_object_ids: Option<u64>,
1619
1620 max_num_deleted_move_object_ids_system_tx: Option<u64>,
1622
1623 max_num_transferred_move_object_ids: Option<u64>,
1625
1626 max_num_transferred_move_object_ids_system_tx: Option<u64>,
1628
1629 max_event_emit_size: Option<u64>,
1631
1632 max_event_emit_size_total: Option<u64>,
1634
1635 max_move_vector_len: Option<u64>,
1637
1638 max_move_identifier_len: Option<u64>,
1640
1641 max_move_value_depth: Option<u64>,
1643
1644 package_arena_size_in_bytes: Option<u64>,
1647
1648 max_move_enum_variants: Option<u64>,
1650
1651 max_back_edges_per_function: Option<u64>,
1653
1654 max_back_edges_per_module: Option<u64>,
1656
1657 max_verifier_meter_ticks_per_function: Option<u64>,
1659
1660 max_meter_ticks_per_module: Option<u64>,
1662
1663 max_meter_ticks_per_package: Option<u64>,
1665
1666 object_runtime_max_num_cached_objects: Option<u64>,
1670
1671 object_runtime_max_num_cached_objects_system_tx: Option<u64>,
1673
1674 object_runtime_max_num_store_entries: Option<u64>,
1676
1677 object_runtime_max_num_store_entries_system_tx: Option<u64>,
1679
1680 base_tx_cost_fixed: Option<u64>,
1683
1684 package_publish_cost_fixed: Option<u64>,
1687
1688 base_tx_cost_per_byte: Option<u64>,
1691
1692 package_publish_cost_per_byte: Option<u64>,
1694
1695 obj_access_cost_read_per_byte: Option<u64>,
1697
1698 obj_access_cost_mutate_per_byte: Option<u64>,
1700
1701 obj_access_cost_delete_per_byte: Option<u64>,
1703
1704 obj_access_cost_verify_per_byte: Option<u64>,
1714
1715 max_type_to_layout_nodes: Option<u64>,
1717
1718 max_ptb_value_size: Option<u64>,
1720
1721 gas_model_version: Option<u64>,
1724
1725 obj_data_cost_refundable: Option<u64>,
1728
1729 obj_metadata_cost_non_refundable: Option<u64>,
1733
1734 storage_rebate_rate: Option<u64>,
1740
1741 storage_fund_reinvest_rate: Option<u64>,
1744
1745 reward_slashing_rate: Option<u64>,
1748
1749 storage_gas_price: Option<u64>,
1751
1752 accumulator_object_storage_cost: Option<u64>,
1754
1755 max_transactions_per_checkpoint: Option<u64>,
1760
1761 max_checkpoint_size_bytes: Option<u64>,
1765
1766 buffer_stake_for_protocol_upgrade_bps: Option<u64>,
1771
1772 address_from_bytes_cost_base: Option<u64>,
1777 address_to_u256_cost_base: Option<u64>,
1779 address_from_u256_cost_base: Option<u64>,
1781
1782 config_read_setting_impl_cost_base: Option<u64>,
1787 config_read_setting_impl_cost_per_byte: Option<u64>,
1788
1789 package_original_package_id_impl_cost_base: Option<u64>,
1790 package_original_package_id_impl_cost_per_byte: Option<u64>,
1791
1792 dynamic_field_hash_type_and_key_cost_base: Option<u64>,
1795 dynamic_field_hash_type_and_key_type_cost_per_byte: Option<u64>,
1796 dynamic_field_hash_type_and_key_value_cost_per_byte: Option<u64>,
1797 dynamic_field_hash_type_and_key_type_tag_cost_per_byte: Option<u64>,
1798 dynamic_field_add_child_object_cost_base: Option<u64>,
1800 dynamic_field_add_child_object_type_cost_per_byte: Option<u64>,
1801 dynamic_field_add_child_object_value_cost_per_byte: Option<u64>,
1802 dynamic_field_add_child_object_struct_tag_cost_per_byte: Option<u64>,
1803 dynamic_field_borrow_child_object_cost_base: Option<u64>,
1805 dynamic_field_borrow_child_object_child_ref_cost_per_byte: Option<u64>,
1806 dynamic_field_borrow_child_object_type_cost_per_byte: Option<u64>,
1807 dynamic_field_remove_child_object_cost_base: Option<u64>,
1809 dynamic_field_remove_child_object_child_cost_per_byte: Option<u64>,
1810 dynamic_field_remove_child_object_type_cost_per_byte: Option<u64>,
1811 dynamic_field_has_child_object_cost_base: Option<u64>,
1813 dynamic_field_has_child_object_with_ty_cost_base: Option<u64>,
1815 dynamic_field_has_child_object_with_ty_type_cost_per_byte: Option<u64>,
1816 dynamic_field_has_child_object_with_ty_type_tag_cost_per_byte: Option<u64>,
1817
1818 scratch_add_cost_base: Option<u64>,
1821 scratch_read_cost_base: Option<u64>,
1823 scratch_read_value_cost: Option<u64>,
1824 scratch_remove_cost_base: Option<u64>,
1826 scratch_exists_cost_base: Option<u64>,
1828 scratch_exists_with_type_cost_base: Option<u64>,
1830 scratch_exists_with_type_type_cost: Option<u64>,
1831 max_scratch_pad_size: Option<u64>,
1833
1834 event_emit_cost_base: Option<u64>,
1837 event_emit_value_size_derivation_cost_per_byte: Option<u64>,
1838 event_emit_tag_size_derivation_cost_per_byte: Option<u64>,
1839 event_emit_output_cost_per_byte: Option<u64>,
1840 event_emit_auth_stream_cost: Option<u64>,
1841
1842 reserve_object_funds_for_withdrawal_cost_base: Option<u64>,
1845 reserve_object_funds_for_withdrawal_cold_read_cost: Option<u64>,
1847
1848 object_borrow_uid_cost_base: Option<u64>,
1851 object_delete_impl_cost_base: Option<u64>,
1853 object_record_new_uid_cost_base: Option<u64>,
1855 object_record_new_uid_from_hash_cost_base: Option<u64>,
1858
1859 transfer_transfer_internal_cost_base: Option<u64>,
1862 transfer_party_transfer_internal_cost_base: Option<u64>,
1864 transfer_freeze_object_cost_base: Option<u64>,
1866 transfer_share_object_cost_base: Option<u64>,
1868 transfer_receive_object_cost_base: Option<u64>,
1871 transfer_receive_object_cost_per_byte: Option<u64>,
1872 transfer_receive_object_type_cost_per_byte: Option<u64>,
1873
1874 tx_context_derive_id_cost_base: Option<u64>,
1877 tx_context_fresh_id_cost_base: Option<u64>,
1878 tx_context_sender_cost_base: Option<u64>,
1879 tx_context_epoch_cost_base: Option<u64>,
1880 tx_context_epoch_timestamp_ms_cost_base: Option<u64>,
1881 tx_context_sponsor_cost_base: Option<u64>,
1882 tx_context_rgp_cost_base: Option<u64>,
1883 tx_context_gas_price_cost_base: Option<u64>,
1884 tx_context_gas_budget_cost_base: Option<u64>,
1885 tx_context_ids_created_cost_base: Option<u64>,
1886 tx_context_replace_cost_base: Option<u64>,
1887
1888 types_is_one_time_witness_cost_base: Option<u64>,
1891 types_is_one_time_witness_type_tag_cost_per_byte: Option<u64>,
1892 types_is_one_time_witness_type_cost_per_byte: Option<u64>,
1893
1894 validator_validate_metadata_cost_base: Option<u64>,
1897 validator_validate_metadata_data_cost_per_byte: Option<u64>,
1898
1899 crypto_invalid_arguments_cost: Option<u64>,
1901 bls12381_bls12381_min_sig_verify_cost_base: Option<u64>,
1903 bls12381_bls12381_min_sig_verify_msg_cost_per_byte: Option<u64>,
1904 bls12381_bls12381_min_sig_verify_msg_cost_per_block: Option<u64>,
1905
1906 bls12381_bls12381_min_pk_verify_cost_base: Option<u64>,
1908 bls12381_bls12381_min_pk_verify_msg_cost_per_byte: Option<u64>,
1909 bls12381_bls12381_min_pk_verify_msg_cost_per_block: Option<u64>,
1910
1911 ecdsa_k1_ecrecover_keccak256_cost_base: Option<u64>,
1913 ecdsa_k1_ecrecover_keccak256_msg_cost_per_byte: Option<u64>,
1914 ecdsa_k1_ecrecover_keccak256_msg_cost_per_block: Option<u64>,
1915 ecdsa_k1_ecrecover_sha256_cost_base: Option<u64>,
1916 ecdsa_k1_ecrecover_sha256_msg_cost_per_byte: Option<u64>,
1917 ecdsa_k1_ecrecover_sha256_msg_cost_per_block: Option<u64>,
1918
1919 ecdsa_k1_decompress_pubkey_cost_base: Option<u64>,
1921
1922 ecdsa_k1_secp256k1_verify_keccak256_cost_base: Option<u64>,
1924 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_byte: Option<u64>,
1925 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_block: Option<u64>,
1926 ecdsa_k1_secp256k1_verify_sha256_cost_base: Option<u64>,
1927 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_byte: Option<u64>,
1928 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_block: Option<u64>,
1929
1930 ecdsa_r1_ecrecover_keccak256_cost_base: Option<u64>,
1932 ecdsa_r1_ecrecover_keccak256_msg_cost_per_byte: Option<u64>,
1933 ecdsa_r1_ecrecover_keccak256_msg_cost_per_block: Option<u64>,
1934 ecdsa_r1_ecrecover_sha256_cost_base: Option<u64>,
1935 ecdsa_r1_ecrecover_sha256_msg_cost_per_byte: Option<u64>,
1936 ecdsa_r1_ecrecover_sha256_msg_cost_per_block: Option<u64>,
1937
1938 ecdsa_r1_secp256r1_verify_keccak256_cost_base: Option<u64>,
1940 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_byte: Option<u64>,
1941 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_block: Option<u64>,
1942 ecdsa_r1_secp256r1_verify_sha256_cost_base: Option<u64>,
1943 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_byte: Option<u64>,
1944 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_block: Option<u64>,
1945
1946 ecvrf_ecvrf_verify_cost_base: Option<u64>,
1948 ecvrf_ecvrf_verify_alpha_string_cost_per_byte: Option<u64>,
1949 ecvrf_ecvrf_verify_alpha_string_cost_per_block: Option<u64>,
1950
1951 ed25519_ed25519_verify_cost_base: Option<u64>,
1953 ed25519_ed25519_verify_msg_cost_per_byte: Option<u64>,
1954 ed25519_ed25519_verify_msg_cost_per_block: Option<u64>,
1955
1956 groth16_prepare_verifying_key_bls12381_cost_base: Option<u64>,
1958 groth16_prepare_verifying_key_bn254_cost_base: Option<u64>,
1959
1960 groth16_verify_groth16_proof_internal_bls12381_cost_base: Option<u64>,
1962 groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input: Option<u64>,
1963 groth16_verify_groth16_proof_internal_bn254_cost_base: Option<u64>,
1964 groth16_verify_groth16_proof_internal_bn254_cost_per_public_input: Option<u64>,
1965 groth16_verify_groth16_proof_internal_public_input_cost_per_byte: Option<u64>,
1966
1967 hash_blake2b256_cost_base: Option<u64>,
1969 hash_blake2b256_data_cost_per_byte: Option<u64>,
1970 hash_blake2b256_data_cost_per_block: Option<u64>,
1971
1972 hash_keccak256_cost_base: Option<u64>,
1974 hash_keccak256_data_cost_per_byte: Option<u64>,
1975 hash_keccak256_data_cost_per_block: Option<u64>,
1976
1977 poseidon_bn254_cost_base: Option<u64>,
1979 poseidon_bn254_cost_per_block: Option<u64>,
1980
1981 group_ops_bls12381_decode_scalar_cost: Option<u64>,
1983 group_ops_bls12381_decode_g1_cost: Option<u64>,
1984 group_ops_bls12381_decode_g2_cost: Option<u64>,
1985 group_ops_bls12381_decode_gt_cost: Option<u64>,
1986 group_ops_bls12381_scalar_add_cost: Option<u64>,
1987 group_ops_bls12381_g1_add_cost: Option<u64>,
1988 group_ops_bls12381_g2_add_cost: Option<u64>,
1989 group_ops_bls12381_gt_add_cost: Option<u64>,
1990 group_ops_bls12381_scalar_sub_cost: Option<u64>,
1991 group_ops_bls12381_g1_sub_cost: Option<u64>,
1992 group_ops_bls12381_g2_sub_cost: Option<u64>,
1993 group_ops_bls12381_gt_sub_cost: Option<u64>,
1994 group_ops_bls12381_scalar_mul_cost: Option<u64>,
1995 group_ops_bls12381_g1_mul_cost: Option<u64>,
1996 group_ops_bls12381_g2_mul_cost: Option<u64>,
1997 group_ops_bls12381_gt_mul_cost: Option<u64>,
1998 group_ops_bls12381_scalar_div_cost: Option<u64>,
1999 group_ops_bls12381_g1_div_cost: Option<u64>,
2000 group_ops_bls12381_g2_div_cost: Option<u64>,
2001 group_ops_bls12381_gt_div_cost: Option<u64>,
2002 group_ops_bls12381_g1_hash_to_base_cost: Option<u64>,
2003 group_ops_bls12381_g2_hash_to_base_cost: Option<u64>,
2004 group_ops_bls12381_g1_hash_to_cost_per_byte: Option<u64>,
2005 group_ops_bls12381_g2_hash_to_cost_per_byte: Option<u64>,
2006 group_ops_bls12381_g1_msm_base_cost: Option<u64>,
2007 group_ops_bls12381_g2_msm_base_cost: Option<u64>,
2008 group_ops_bls12381_g1_msm_base_cost_per_input: Option<u64>,
2009 group_ops_bls12381_g2_msm_base_cost_per_input: Option<u64>,
2010 group_ops_bls12381_msm_max_len: Option<u32>,
2011 group_ops_bls12381_pairing_cost: Option<u64>,
2012 group_ops_bls12381_g1_to_uncompressed_g1_cost: Option<u64>,
2013 group_ops_bls12381_uncompressed_g1_to_g1_cost: Option<u64>,
2014 group_ops_bls12381_uncompressed_g1_sum_base_cost: Option<u64>,
2015 group_ops_bls12381_uncompressed_g1_sum_cost_per_term: Option<u64>,
2016 group_ops_bls12381_uncompressed_g1_sum_max_terms: Option<u64>,
2017
2018 group_ops_ristretto_decode_scalar_cost: Option<u64>,
2019 group_ops_ristretto_decode_point_cost: Option<u64>,
2020 group_ops_ristretto_scalar_add_cost: Option<u64>,
2021 group_ops_ristretto_point_add_cost: Option<u64>,
2022 group_ops_ristretto_scalar_sub_cost: Option<u64>,
2023 group_ops_ristretto_point_sub_cost: Option<u64>,
2024 group_ops_ristretto_scalar_mul_cost: Option<u64>,
2025 group_ops_ristretto_point_mul_cost: Option<u64>,
2026 group_ops_ristretto_scalar_div_cost: Option<u64>,
2027 group_ops_ristretto_point_div_cost: Option<u64>,
2028
2029 verify_bulletproofs_ristretto255_base_cost: Option<u64>,
2030 verify_bulletproofs_ristretto255_cost_per_bit_and_commitment: Option<u64>,
2031 max_bulletproofs_total_bits: Option<u64>,
2034
2035 hmac_hmac_sha3_256_cost_base: Option<u64>,
2037 hmac_hmac_sha3_256_input_cost_per_byte: Option<u64>,
2038 hmac_hmac_sha3_256_input_cost_per_block: Option<u64>,
2039
2040 check_zklogin_id_cost_base: Option<u64>,
2042 check_zklogin_issuer_cost_base: Option<u64>,
2044
2045 vdf_verify_vdf_cost: Option<u64>,
2046 vdf_hash_to_input_cost: Option<u64>,
2047
2048 nitro_attestation_parse_base_cost: Option<u64>,
2050 nitro_attestation_parse_cost_per_byte: Option<u64>,
2051 nitro_attestation_verify_base_cost: Option<u64>,
2052 nitro_attestation_verify_cost_per_cert: Option<u64>,
2053
2054 bcs_per_byte_serialized_cost: Option<u64>,
2056 bcs_legacy_min_output_size_cost: Option<u64>,
2057 bcs_failure_cost: Option<u64>,
2058
2059 hash_sha2_256_base_cost: Option<u64>,
2060 hash_sha2_256_per_byte_cost: Option<u64>,
2061 hash_sha2_256_legacy_min_input_len_cost: Option<u64>,
2062 hash_sha3_256_base_cost: Option<u64>,
2063 hash_sha3_256_per_byte_cost: Option<u64>,
2064 hash_sha3_256_legacy_min_input_len_cost: Option<u64>,
2065 type_name_get_base_cost: Option<u64>,
2066 type_name_get_per_byte_cost: Option<u64>,
2067 type_name_id_base_cost: Option<u64>,
2068
2069 string_check_utf8_base_cost: Option<u64>,
2070 string_check_utf8_per_byte_cost: Option<u64>,
2071 string_is_char_boundary_base_cost: Option<u64>,
2072 string_sub_string_base_cost: Option<u64>,
2073 string_sub_string_per_byte_cost: Option<u64>,
2074 string_index_of_base_cost: Option<u64>,
2075 string_index_of_per_byte_pattern_cost: Option<u64>,
2076 string_index_of_per_byte_searched_cost: Option<u64>,
2077
2078 vector_empty_base_cost: Option<u64>,
2079 vector_length_base_cost: Option<u64>,
2080 vector_push_back_base_cost: Option<u64>,
2081 vector_push_back_legacy_per_abstract_memory_unit_cost: Option<u64>,
2082 vector_borrow_base_cost: Option<u64>,
2083 vector_pop_back_base_cost: Option<u64>,
2084 vector_destroy_empty_base_cost: Option<u64>,
2085 vector_swap_base_cost: Option<u64>,
2086 debug_print_base_cost: Option<u64>,
2087 debug_print_stack_trace_base_cost: Option<u64>,
2088
2089 #[custom_setter]
2099 execution_version: Option<u64>,
2100
2101 consensus_bad_nodes_stake_threshold: Option<u64>,
2105
2106 max_jwk_votes_per_validator_per_epoch: Option<u64>,
2107 max_age_of_jwk_in_epochs: Option<u64>,
2111
2112 random_beacon_reduction_allowed_delta: Option<u16>,
2116
2117 random_beacon_reduction_lower_bound: Option<u32>,
2120
2121 random_beacon_dkg_timeout_round: Option<u32>,
2124
2125 random_beacon_min_round_interval_ms: Option<u64>,
2127
2128 random_beacon_dkg_version: Option<u64>,
2131
2132 consensus_max_transaction_size_bytes: Option<u64>,
2135 consensus_max_transactions_in_block_bytes: Option<u64>,
2137 consensus_max_num_transactions_in_block: Option<u64>,
2139
2140 consensus_voting_rounds: Option<u32>,
2142
2143 max_accumulated_txn_cost_per_object_in_narwhal_commit: Option<u64>,
2145
2146 max_deferral_rounds_for_congestion_control: Option<u64>,
2149
2150 epoch_close_deadline_ms: Option<u64>,
2155
2156 max_txn_cost_overage_per_object_in_commit: Option<u64>,
2158
2159 allowed_txn_cost_overage_burst_per_object_in_commit: Option<u64>,
2161
2162 min_checkpoint_interval_ms: Option<u64>,
2164
2165 checkpoint_summary_version_specific_data: Option<u64>,
2167
2168 max_soft_bundle_size: Option<u64>,
2170
2171 bridge_should_try_to_finalize_committee: Option<bool>,
2175
2176 max_accumulated_txn_cost_per_object_in_mysticeti_commit: Option<u64>,
2182
2183 max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit: Option<u64>,
2186
2187 consensus_gc_depth: Option<u32>,
2190
2191 gas_budget_based_txn_cost_cap_factor: Option<u64>,
2193
2194 gas_budget_based_txn_cost_absolute_cap_commit_count: Option<u64>,
2196
2197 sip_45_consensus_amplification_threshold: Option<u64>,
2200
2201 use_object_per_epoch_marker_table_v2: Option<bool>,
2204
2205 consensus_commit_rate_estimation_window_size: Option<u32>,
2207
2208 #[serde(skip_serializing_if = "Vec::is_empty")]
2212 aliased_addresses: Vec<AliasedAddress>,
2213
2214 translation_per_command_base_charge: Option<u64>,
2217
2218 translation_per_input_base_charge: Option<u64>,
2221
2222 translation_pure_input_per_byte_charge: Option<u64>,
2224
2225 translation_per_type_node_charge: Option<u64>,
2229
2230 translation_per_reference_node_charge: Option<u64>,
2233
2234 translation_per_linkage_entry_charge: Option<u64>,
2237
2238 max_updates_per_settlement_txn: Option<u32>,
2240
2241 gasless_max_computation_units: Option<u64>,
2243
2244 gasless_allowed_token_types: Option<Vec<(String, u64)>>,
2246
2247 gasless_max_unused_inputs: Option<u64>,
2251
2252 gasless_max_pure_input_bytes: Option<u64>,
2255
2256 gasless_max_tps: Option<u64>,
2258
2259 #[serde(skip_serializing_if = "Option::is_none")]
2260 #[skip_accessor]
2261 include_special_package_amendments: Option<Arc<Amendments>>,
2262
2263 gasless_max_tx_size_bytes: Option<u64>,
2266
2267 translation_per_live_reference_charge: Option<u64>,
2270
2271 max_ptb_live_references: Option<u64>,
2274
2275 max_ptb_returned_references: Option<u64>,
2278
2279 max_ptb_total_returned_references: Option<u64>,
2282}
2283
2284#[derive(Clone, Serialize, Deserialize, Debug)]
2286pub struct AliasedAddress {
2287 pub original: [u8; 32],
2289 pub aliased: [u8; 32],
2291 pub allowed_tx_digests: Vec<[u8; 32]>,
2293}
2294
2295impl ProtocolConfig {
2297 pub fn chain(&self) -> Chain {
2299 self.chain
2300 }
2301
2302 pub fn check_package_upgrades_supported(&self) -> Result<(), Error> {
2315 if self.feature_flags.package_upgrades {
2316 Ok(())
2317 } else {
2318 Err(Error(format!(
2319 "package upgrades are not supported at {:?}",
2320 self.version
2321 )))
2322 }
2323 }
2324
2325 pub fn zklogin_supported_providers(&self) -> &BTreeSet<String> {
2326 &self.feature_flags.zklogin_supported_providers
2327 }
2328
2329 pub fn zklogin_circuit_mode(&self) -> u64 {
2332 self.feature_flags.zklogin_circuit_mode
2333 }
2334
2335 pub fn consensus_transaction_ordering(&self) -> ConsensusTransactionOrdering {
2336 self.feature_flags.consensus_transaction_ordering
2337 }
2338
2339 pub fn enable_jwk_consensus_updates(&self) -> bool {
2340 let ret = self.feature_flags.enable_jwk_consensus_updates;
2341 if ret {
2342 assert!(self.feature_flags.end_of_epoch_transaction_supported);
2344 }
2345 ret
2346 }
2347
2348 pub fn end_of_epoch_transaction_supported(&self) -> bool {
2349 let ret = self.feature_flags.end_of_epoch_transaction_supported;
2350 if !ret {
2351 assert!(!self.feature_flags.enable_jwk_consensus_updates);
2353 }
2354 ret
2355 }
2356
2357 pub fn dkg_version(&self) -> u64 {
2358 self.random_beacon_dkg_version.unwrap_or(1)
2360 }
2361
2362 pub fn bridge(&self) -> bool {
2363 let ret = self.feature_flags.bridge;
2364 if ret {
2365 assert!(self.feature_flags.end_of_epoch_transaction_supported);
2367 }
2368 ret
2369 }
2370
2371 pub fn should_try_to_finalize_bridge_committee(&self) -> bool {
2372 if !self.bridge() {
2373 return false;
2374 }
2375 self.bridge_should_try_to_finalize_committee.unwrap_or(true)
2377 }
2378
2379 pub fn zklogin_max_epoch_upper_bound_delta(&self) -> Option<u64> {
2380 self.feature_flags.zklogin_max_epoch_upper_bound_delta
2381 }
2382
2383 pub fn enable_allowances(&self) -> bool {
2384 self.feature_flags.enable_allowances && self.enable_accumulators()
2385 }
2386
2387 pub fn enable_coin_reservation_obj_refs(&self) -> bool {
2388 self.new_vm_enabled() && self.feature_flags.enable_coin_reservation_obj_refs
2389 }
2390
2391 pub fn enable_authenticated_event_streams(&self) -> bool {
2392 self.feature_flags.enable_authenticated_event_streams && self.enable_accumulators()
2393 }
2394
2395 pub fn per_object_congestion_control_mode(&self) -> PerObjectCongestionControlMode {
2396 self.feature_flags.per_object_congestion_control_mode
2397 }
2398
2399 pub fn consensus_choice(&self) -> ConsensusChoice {
2400 self.feature_flags.consensus_choice
2401 }
2402
2403 pub fn consensus_network(&self) -> ConsensusNetwork {
2404 self.feature_flags.consensus_network
2405 }
2406
2407 pub fn mysticeti_num_leaders_per_round(&self) -> Option<usize> {
2408 self.feature_flags.mysticeti_num_leaders_per_round
2409 }
2410
2411 pub fn max_transaction_size_bytes(&self) -> u64 {
2412 self.consensus_max_transaction_size_bytes
2414 .unwrap_or(256 * 1024)
2415 }
2416
2417 pub fn max_transactions_in_block_bytes(&self) -> u64 {
2418 if cfg!(msim) {
2419 256 * 1024
2420 } else {
2421 self.consensus_max_transactions_in_block_bytes
2422 .unwrap_or(512 * 1024)
2423 }
2424 }
2425
2426 pub fn max_num_transactions_in_block(&self) -> u64 {
2427 if cfg!(msim) {
2428 8
2429 } else {
2430 self.consensus_max_num_transactions_in_block.unwrap_or(512)
2431 }
2432 }
2433
2434 pub fn gc_depth(&self) -> u32 {
2435 self.consensus_gc_depth.unwrap_or(0)
2436 }
2437
2438 pub fn consensus_linearize_subdag_v2(&self) -> bool {
2439 let res = self.feature_flags.consensus_linearize_subdag_v2;
2440 assert!(
2441 !res || self.gc_depth() > 0,
2442 "The consensus linearize sub dag V2 requires GC to be enabled"
2443 );
2444 res
2445 }
2446
2447 pub fn consensus_median_based_commit_timestamp(&self) -> bool {
2448 let res = self.feature_flags.consensus_median_based_commit_timestamp;
2449 assert!(
2450 !res || self.gc_depth() > 0,
2451 "The consensus median based commit timestamp requires GC to be enabled"
2452 );
2453 res
2454 }
2455
2456 pub fn get_consensus_commit_rate_estimation_window_size(&self) -> u32 {
2457 self.consensus_commit_rate_estimation_window_size
2458 .unwrap_or(0)
2459 }
2460
2461 pub fn consensus_num_requested_prior_commits_at_startup(&self) -> u32 {
2462 let window_size = self.get_consensus_commit_rate_estimation_window_size();
2466 assert!(window_size == 0 || self.record_additional_state_digest_in_prologue());
2468 window_size
2469 }
2470
2471 pub fn address_aliases(&self) -> bool {
2472 let address_aliases = self.feature_flags.address_aliases;
2473 assert!(
2474 !address_aliases || self.mysticeti_fastpath(),
2475 "Address aliases requires Mysticeti fastpath to be enabled"
2476 );
2477 if address_aliases {
2478 assert!(
2479 self.feature_flags.disable_preconsensus_locking,
2480 "Address aliases requires CertifiedTransaction to be disabled"
2481 );
2482 }
2483 address_aliases
2484 }
2485
2486 pub fn new_vm_enabled(&self) -> bool {
2487 self.execution_version.is_some_and(|v| v >= 4)
2488 }
2489
2490 pub fn gasless_allowed_token_types(&self) -> &[(String, u64)] {
2491 debug_assert!(self.gasless_allowed_token_types.is_some());
2492 self.gasless_allowed_token_types.as_deref().unwrap_or(&[])
2493 }
2494
2495 pub fn get_gasless_max_unused_inputs(&self) -> u64 {
2496 self.gasless_max_unused_inputs.unwrap_or(u64::MAX)
2497 }
2498
2499 pub fn get_gasless_max_pure_input_bytes(&self) -> u64 {
2500 self.gasless_max_pure_input_bytes.unwrap_or(u64::MAX)
2501 }
2502
2503 pub fn get_gasless_max_tx_size_bytes(&self) -> u64 {
2504 self.gasless_max_tx_size_bytes.unwrap_or(u64::MAX)
2505 }
2506
2507 pub fn include_special_package_amendments_as_option(&self) -> &Option<Arc<Amendments>> {
2508 &self.include_special_package_amendments
2509 }
2510}
2511
2512static POISON_VERSION_METHODS: AtomicBool = AtomicBool::new(false);
2513
2514impl ProtocolConfig {
2516 pub fn get_for_version(version: ProtocolVersion, chain: Chain) -> Self {
2518 assert!(
2520 version >= ProtocolVersion::MIN,
2521 "Network protocol version is {:?}, but the minimum supported version by the binary is {:?}. Please upgrade the binary.",
2522 version,
2523 ProtocolVersion::MIN.0,
2524 );
2525 assert!(
2526 version <= ProtocolVersion::MAX_ALLOWED,
2527 "Network protocol version is {:?}, but the maximum supported version by the binary is {:?}. Please upgrade the binary.",
2528 version,
2529 ProtocolVersion::MAX_ALLOWED.0,
2530 );
2531
2532 let mut ret = Self::get_for_version_impl(version, chain);
2533 ret.version = version;
2534 ret.chain = chain;
2535
2536 ret = Self::apply_config_override(version, ret);
2537
2538 if std::env::var("SUI_PROTOCOL_CONFIG_OVERRIDE_ENABLE").is_ok() {
2539 warn!(
2540 "overriding ProtocolConfig settings with custom settings; this may break non-local networks"
2541 );
2542 let overrides: ProtocolConfigOptional =
2543 serde_env::from_env_with_prefix("SUI_PROTOCOL_CONFIG_OVERRIDE")
2544 .expect("failed to parse ProtocolConfig override env variables");
2545 overrides.apply_to(&mut ret);
2546 }
2547
2548 ret
2549 }
2550
2551 pub fn get_for_version_if_supported(version: ProtocolVersion, chain: Chain) -> Option<Self> {
2554 if version.0 >= ProtocolVersion::MIN.0 && version.0 <= ProtocolVersion::MAX_ALLOWED.0 {
2555 let mut ret = Self::get_for_version_impl(version, chain);
2556 ret.version = version;
2557 ret.chain = chain;
2558 ret = Self::apply_config_override(version, ret);
2559 Some(ret)
2560 } else {
2561 None
2562 }
2563 }
2564
2565 pub fn poison_get_for_min_version() {
2566 POISON_VERSION_METHODS.store(true, Ordering::Relaxed);
2567 }
2568
2569 fn load_poison_get_for_min_version() -> bool {
2570 POISON_VERSION_METHODS.load(Ordering::Relaxed)
2571 }
2572
2573 pub fn get_for_min_version() -> Self {
2576 if Self::load_poison_get_for_min_version() {
2577 panic!("get_for_min_version called on validator");
2578 }
2579 ProtocolConfig::get_for_version(ProtocolVersion::MIN, Chain::Unknown)
2580 }
2581
2582 #[allow(non_snake_case)]
2592 pub fn get_for_max_version_UNSAFE() -> Self {
2593 if Self::load_poison_get_for_min_version() {
2594 panic!("get_for_max_version_UNSAFE called on validator");
2595 }
2596 ProtocolConfig::get_for_version(ProtocolVersion::MAX, Chain::Unknown)
2597 }
2598
2599 fn get_for_version_impl(version: ProtocolVersion, chain: Chain) -> Self {
2600 #[cfg(msim)]
2601 {
2602 if version == ProtocolVersion::MAX_ALLOWED {
2604 let mut config = Self::get_for_version_impl(version - 1, Chain::Unknown);
2605 config.base_tx_cost_fixed = Some(config.base_tx_cost_fixed() + 1000);
2606 return config;
2607 }
2608 }
2609
2610 let mut cfg = Self {
2613 version,
2615 chain,
2616
2617 feature_flags: Default::default(),
2619
2620 max_tx_size_bytes: Some(128 * 1024),
2621 max_input_objects: Some(2048),
2623 max_serialized_tx_effects_size_bytes: Some(512 * 1024),
2624 max_serialized_tx_effects_size_bytes_system_tx: Some(512 * 1024 * 16),
2625 max_gas_payment_objects: Some(256),
2626 max_modules_in_publish: Some(128),
2627 max_package_dependencies: None,
2628 max_arguments: Some(512),
2629 max_type_arguments: Some(16),
2630 max_type_argument_depth: Some(16),
2631 max_pure_argument_size: Some(16 * 1024),
2632 max_programmable_tx_commands: Some(1024),
2633 move_binary_format_version: Some(6),
2634 min_move_binary_format_version: None,
2635 binary_module_handles: None,
2636 binary_struct_handles: None,
2637 binary_function_handles: None,
2638 binary_function_instantiations: None,
2639 binary_signatures: None,
2640 binary_constant_pool: None,
2641 binary_identifiers: None,
2642 binary_address_identifiers: None,
2643 binary_struct_defs: None,
2644 binary_struct_def_instantiations: None,
2645 binary_function_defs: None,
2646 binary_field_handles: None,
2647 binary_field_instantiations: None,
2648 binary_friend_decls: None,
2649 binary_enum_defs: None,
2650 binary_enum_def_instantiations: None,
2651 binary_variant_handles: None,
2652 binary_variant_instantiation_handles: None,
2653 max_move_object_size: Some(250 * 1024),
2654 max_move_package_size: Some(100 * 1024),
2655 max_publish_or_upgrade_per_ptb: None,
2656 max_tx_gas: Some(10_000_000_000),
2657 max_gas_price: Some(100_000),
2658 max_gas_price_rgp_factor_for_aborted_transactions: None,
2659 max_gas_computation_bucket: Some(5_000_000),
2660 max_loop_depth: Some(5),
2661 max_generic_instantiation_length: Some(32),
2662 max_function_parameters: Some(128),
2663 max_basic_blocks: Some(1024),
2664 max_value_stack_size: Some(1024),
2665 max_type_nodes: Some(256),
2666 max_generic_instantiation_type_nodes_per_function: None,
2667 max_generic_instantiation_type_nodes_per_module: None,
2668 max_accumulator_type_nodes: None,
2669 max_push_size: Some(10000),
2670 max_struct_definitions: Some(200),
2671 max_function_definitions: Some(1000),
2672 max_fields_in_struct: Some(32),
2673 max_dependency_depth: Some(100),
2674 max_num_event_emit: Some(256),
2675 max_num_new_move_object_ids: Some(2048),
2676 max_num_new_move_object_ids_system_tx: Some(2048 * 16),
2677 max_num_deleted_move_object_ids: Some(2048),
2678 max_num_deleted_move_object_ids_system_tx: Some(2048 * 16),
2679 max_num_transferred_move_object_ids: Some(2048),
2680 max_num_transferred_move_object_ids_system_tx: Some(2048 * 16),
2681 max_event_emit_size: Some(250 * 1024),
2682 max_move_vector_len: Some(256 * 1024),
2683 max_type_to_layout_nodes: None,
2684 max_ptb_value_size: None,
2685
2686 max_back_edges_per_function: Some(10_000),
2687 max_back_edges_per_module: Some(10_000),
2688 max_verifier_meter_ticks_per_function: Some(6_000_000),
2689 max_meter_ticks_per_module: Some(6_000_000),
2690 max_meter_ticks_per_package: None,
2691
2692 object_runtime_max_num_cached_objects: Some(1000),
2693 object_runtime_max_num_cached_objects_system_tx: Some(1000 * 16),
2694 object_runtime_max_num_store_entries: Some(1000),
2695 object_runtime_max_num_store_entries_system_tx: Some(1000 * 16),
2696 base_tx_cost_fixed: Some(110_000),
2697 package_publish_cost_fixed: Some(1_000),
2698 base_tx_cost_per_byte: Some(0),
2699 package_publish_cost_per_byte: Some(80),
2700 obj_access_cost_read_per_byte: Some(15),
2701 obj_access_cost_mutate_per_byte: Some(40),
2702 obj_access_cost_delete_per_byte: Some(40),
2703 obj_access_cost_verify_per_byte: Some(200),
2704 obj_data_cost_refundable: Some(100),
2705 obj_metadata_cost_non_refundable: Some(50),
2706 gas_model_version: Some(1),
2707 storage_rebate_rate: Some(9900),
2708 storage_fund_reinvest_rate: Some(500),
2709 reward_slashing_rate: Some(5000),
2710 storage_gas_price: Some(1),
2711 accumulator_object_storage_cost: None,
2712 max_transactions_per_checkpoint: Some(10_000),
2713 max_checkpoint_size_bytes: Some(30 * 1024 * 1024),
2714
2715 buffer_stake_for_protocol_upgrade_bps: Some(0),
2718
2719 address_from_bytes_cost_base: Some(52),
2723 address_to_u256_cost_base: Some(52),
2725 address_from_u256_cost_base: Some(52),
2727
2728 config_read_setting_impl_cost_base: None,
2731 config_read_setting_impl_cost_per_byte: None,
2732
2733 package_original_package_id_impl_cost_base: None,
2734 package_original_package_id_impl_cost_per_byte: None,
2735
2736 dynamic_field_hash_type_and_key_cost_base: Some(100),
2739 dynamic_field_hash_type_and_key_type_cost_per_byte: Some(2),
2740 dynamic_field_hash_type_and_key_value_cost_per_byte: Some(2),
2741 dynamic_field_hash_type_and_key_type_tag_cost_per_byte: Some(2),
2742 dynamic_field_add_child_object_cost_base: Some(100),
2744 dynamic_field_add_child_object_type_cost_per_byte: Some(10),
2745 dynamic_field_add_child_object_value_cost_per_byte: Some(10),
2746 dynamic_field_add_child_object_struct_tag_cost_per_byte: Some(10),
2747 dynamic_field_borrow_child_object_cost_base: Some(100),
2749 dynamic_field_borrow_child_object_child_ref_cost_per_byte: Some(10),
2750 dynamic_field_borrow_child_object_type_cost_per_byte: Some(10),
2751 dynamic_field_remove_child_object_cost_base: Some(100),
2753 dynamic_field_remove_child_object_child_cost_per_byte: Some(2),
2754 dynamic_field_remove_child_object_type_cost_per_byte: Some(2),
2755 dynamic_field_has_child_object_cost_base: Some(100),
2757 dynamic_field_has_child_object_with_ty_cost_base: Some(100),
2759 dynamic_field_has_child_object_with_ty_type_cost_per_byte: Some(2),
2760 dynamic_field_has_child_object_with_ty_type_tag_cost_per_byte: Some(2),
2761
2762 scratch_add_cost_base: None,
2764 scratch_read_cost_base: None,
2765 scratch_read_value_cost: None,
2766 scratch_remove_cost_base: None,
2767 scratch_exists_cost_base: None,
2768 scratch_exists_with_type_cost_base: None,
2769 scratch_exists_with_type_type_cost: None,
2770 max_scratch_pad_size: None,
2771
2772 event_emit_cost_base: Some(52),
2775 event_emit_value_size_derivation_cost_per_byte: Some(2),
2776 event_emit_tag_size_derivation_cost_per_byte: Some(5),
2777 event_emit_output_cost_per_byte: Some(10),
2778 event_emit_auth_stream_cost: None,
2779
2780 reserve_object_funds_for_withdrawal_cost_base: None,
2782 reserve_object_funds_for_withdrawal_cold_read_cost: None,
2783
2784 object_borrow_uid_cost_base: Some(52),
2787 object_delete_impl_cost_base: Some(52),
2789 object_record_new_uid_cost_base: Some(52),
2791 object_record_new_uid_from_hash_cost_base: None,
2794
2795 transfer_transfer_internal_cost_base: Some(52),
2798 transfer_party_transfer_internal_cost_base: None,
2800 transfer_freeze_object_cost_base: Some(52),
2802 transfer_share_object_cost_base: Some(52),
2804 transfer_receive_object_cost_base: None,
2805 transfer_receive_object_type_cost_per_byte: None,
2806 transfer_receive_object_cost_per_byte: None,
2807
2808 tx_context_derive_id_cost_base: Some(52),
2811 tx_context_fresh_id_cost_base: None,
2812 tx_context_sender_cost_base: None,
2813 tx_context_epoch_cost_base: None,
2814 tx_context_epoch_timestamp_ms_cost_base: None,
2815 tx_context_sponsor_cost_base: None,
2816 tx_context_rgp_cost_base: None,
2817 tx_context_gas_price_cost_base: None,
2818 tx_context_gas_budget_cost_base: None,
2819 tx_context_ids_created_cost_base: None,
2820 tx_context_replace_cost_base: None,
2821
2822 types_is_one_time_witness_cost_base: Some(52),
2825 types_is_one_time_witness_type_tag_cost_per_byte: Some(2),
2826 types_is_one_time_witness_type_cost_per_byte: Some(2),
2827
2828 validator_validate_metadata_cost_base: Some(52),
2831 validator_validate_metadata_data_cost_per_byte: Some(2),
2832
2833 crypto_invalid_arguments_cost: Some(100),
2835 bls12381_bls12381_min_sig_verify_cost_base: Some(52),
2837 bls12381_bls12381_min_sig_verify_msg_cost_per_byte: Some(2),
2838 bls12381_bls12381_min_sig_verify_msg_cost_per_block: Some(2),
2839
2840 bls12381_bls12381_min_pk_verify_cost_base: Some(52),
2842 bls12381_bls12381_min_pk_verify_msg_cost_per_byte: Some(2),
2843 bls12381_bls12381_min_pk_verify_msg_cost_per_block: Some(2),
2844
2845 ecdsa_k1_ecrecover_keccak256_cost_base: Some(52),
2847 ecdsa_k1_ecrecover_keccak256_msg_cost_per_byte: Some(2),
2848 ecdsa_k1_ecrecover_keccak256_msg_cost_per_block: Some(2),
2849 ecdsa_k1_ecrecover_sha256_cost_base: Some(52),
2850 ecdsa_k1_ecrecover_sha256_msg_cost_per_byte: Some(2),
2851 ecdsa_k1_ecrecover_sha256_msg_cost_per_block: Some(2),
2852
2853 ecdsa_k1_decompress_pubkey_cost_base: Some(52),
2855
2856 ecdsa_k1_secp256k1_verify_keccak256_cost_base: Some(52),
2858 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_byte: Some(2),
2859 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_block: Some(2),
2860 ecdsa_k1_secp256k1_verify_sha256_cost_base: Some(52),
2861 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_byte: Some(2),
2862 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_block: Some(2),
2863
2864 ecdsa_r1_ecrecover_keccak256_cost_base: Some(52),
2866 ecdsa_r1_ecrecover_keccak256_msg_cost_per_byte: Some(2),
2867 ecdsa_r1_ecrecover_keccak256_msg_cost_per_block: Some(2),
2868 ecdsa_r1_ecrecover_sha256_cost_base: Some(52),
2869 ecdsa_r1_ecrecover_sha256_msg_cost_per_byte: Some(2),
2870 ecdsa_r1_ecrecover_sha256_msg_cost_per_block: Some(2),
2871
2872 ecdsa_r1_secp256r1_verify_keccak256_cost_base: Some(52),
2874 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_byte: Some(2),
2875 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_block: Some(2),
2876 ecdsa_r1_secp256r1_verify_sha256_cost_base: Some(52),
2877 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_byte: Some(2),
2878 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_block: Some(2),
2879
2880 ecvrf_ecvrf_verify_cost_base: Some(52),
2882 ecvrf_ecvrf_verify_alpha_string_cost_per_byte: Some(2),
2883 ecvrf_ecvrf_verify_alpha_string_cost_per_block: Some(2),
2884
2885 ed25519_ed25519_verify_cost_base: Some(52),
2887 ed25519_ed25519_verify_msg_cost_per_byte: Some(2),
2888 ed25519_ed25519_verify_msg_cost_per_block: Some(2),
2889
2890 groth16_prepare_verifying_key_bls12381_cost_base: Some(52),
2892 groth16_prepare_verifying_key_bn254_cost_base: Some(52),
2893
2894 groth16_verify_groth16_proof_internal_bls12381_cost_base: Some(52),
2896 groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input: Some(2),
2897 groth16_verify_groth16_proof_internal_bn254_cost_base: Some(52),
2898 groth16_verify_groth16_proof_internal_bn254_cost_per_public_input: Some(2),
2899 groth16_verify_groth16_proof_internal_public_input_cost_per_byte: Some(2),
2900
2901 hash_blake2b256_cost_base: Some(52),
2903 hash_blake2b256_data_cost_per_byte: Some(2),
2904 hash_blake2b256_data_cost_per_block: Some(2),
2905
2906 hash_keccak256_cost_base: Some(52),
2908 hash_keccak256_data_cost_per_byte: Some(2),
2909 hash_keccak256_data_cost_per_block: Some(2),
2910
2911 poseidon_bn254_cost_base: None,
2912 poseidon_bn254_cost_per_block: None,
2913
2914 hmac_hmac_sha3_256_cost_base: Some(52),
2916 hmac_hmac_sha3_256_input_cost_per_byte: Some(2),
2917 hmac_hmac_sha3_256_input_cost_per_block: Some(2),
2918
2919 group_ops_bls12381_decode_scalar_cost: None,
2921 group_ops_bls12381_decode_g1_cost: None,
2922 group_ops_bls12381_decode_g2_cost: None,
2923 group_ops_bls12381_decode_gt_cost: None,
2924 group_ops_bls12381_scalar_add_cost: None,
2925 group_ops_bls12381_g1_add_cost: None,
2926 group_ops_bls12381_g2_add_cost: None,
2927 group_ops_bls12381_gt_add_cost: None,
2928 group_ops_bls12381_scalar_sub_cost: None,
2929 group_ops_bls12381_g1_sub_cost: None,
2930 group_ops_bls12381_g2_sub_cost: None,
2931 group_ops_bls12381_gt_sub_cost: None,
2932 group_ops_bls12381_scalar_mul_cost: None,
2933 group_ops_bls12381_g1_mul_cost: None,
2934 group_ops_bls12381_g2_mul_cost: None,
2935 group_ops_bls12381_gt_mul_cost: None,
2936 group_ops_bls12381_scalar_div_cost: None,
2937 group_ops_bls12381_g1_div_cost: None,
2938 group_ops_bls12381_g2_div_cost: None,
2939 group_ops_bls12381_gt_div_cost: None,
2940 group_ops_bls12381_g1_hash_to_base_cost: None,
2941 group_ops_bls12381_g2_hash_to_base_cost: None,
2942 group_ops_bls12381_g1_hash_to_cost_per_byte: None,
2943 group_ops_bls12381_g2_hash_to_cost_per_byte: None,
2944 group_ops_bls12381_g1_msm_base_cost: None,
2945 group_ops_bls12381_g2_msm_base_cost: None,
2946 group_ops_bls12381_g1_msm_base_cost_per_input: None,
2947 group_ops_bls12381_g2_msm_base_cost_per_input: None,
2948 group_ops_bls12381_msm_max_len: None,
2949 group_ops_bls12381_pairing_cost: None,
2950 group_ops_bls12381_g1_to_uncompressed_g1_cost: None,
2951 group_ops_bls12381_uncompressed_g1_to_g1_cost: None,
2952 group_ops_bls12381_uncompressed_g1_sum_base_cost: None,
2953 group_ops_bls12381_uncompressed_g1_sum_cost_per_term: None,
2954 group_ops_bls12381_uncompressed_g1_sum_max_terms: None,
2955
2956 group_ops_ristretto_decode_scalar_cost: None,
2957 group_ops_ristretto_decode_point_cost: None,
2958 group_ops_ristretto_scalar_add_cost: None,
2959 group_ops_ristretto_point_add_cost: None,
2960 group_ops_ristretto_scalar_sub_cost: None,
2961 group_ops_ristretto_point_sub_cost: None,
2962 group_ops_ristretto_scalar_mul_cost: None,
2963 group_ops_ristretto_point_mul_cost: None,
2964 group_ops_ristretto_scalar_div_cost: None,
2965 group_ops_ristretto_point_div_cost: None,
2966
2967 verify_bulletproofs_ristretto255_base_cost: None,
2968 verify_bulletproofs_ristretto255_cost_per_bit_and_commitment: None,
2969 max_bulletproofs_total_bits: None,
2970
2971 check_zklogin_id_cost_base: None,
2973 check_zklogin_issuer_cost_base: None,
2975
2976 vdf_verify_vdf_cost: None,
2977 vdf_hash_to_input_cost: None,
2978
2979 nitro_attestation_parse_base_cost: None,
2981 nitro_attestation_parse_cost_per_byte: None,
2982 nitro_attestation_verify_base_cost: None,
2983 nitro_attestation_verify_cost_per_cert: None,
2984
2985 bcs_per_byte_serialized_cost: None,
2986 bcs_legacy_min_output_size_cost: None,
2987 bcs_failure_cost: None,
2988 hash_sha2_256_base_cost: None,
2989 hash_sha2_256_per_byte_cost: None,
2990 hash_sha2_256_legacy_min_input_len_cost: None,
2991 hash_sha3_256_base_cost: None,
2992 hash_sha3_256_per_byte_cost: None,
2993 hash_sha3_256_legacy_min_input_len_cost: None,
2994 type_name_get_base_cost: None,
2995 type_name_get_per_byte_cost: None,
2996 type_name_id_base_cost: None,
2997 string_check_utf8_base_cost: None,
2998 string_check_utf8_per_byte_cost: None,
2999 string_is_char_boundary_base_cost: None,
3000 string_sub_string_base_cost: None,
3001 string_sub_string_per_byte_cost: None,
3002 string_index_of_base_cost: None,
3003 string_index_of_per_byte_pattern_cost: None,
3004 string_index_of_per_byte_searched_cost: None,
3005 vector_empty_base_cost: None,
3006 vector_length_base_cost: None,
3007 vector_push_back_base_cost: None,
3008 vector_push_back_legacy_per_abstract_memory_unit_cost: None,
3009 vector_borrow_base_cost: None,
3010 vector_pop_back_base_cost: None,
3011 vector_destroy_empty_base_cost: None,
3012 vector_swap_base_cost: None,
3013 debug_print_base_cost: None,
3014 debug_print_stack_trace_base_cost: None,
3015
3016 max_size_written_objects: None,
3017 max_size_written_objects_system_tx: None,
3018
3019 max_move_identifier_len: None,
3026 max_move_value_depth: None,
3027 package_arena_size_in_bytes: None,
3028 max_move_enum_variants: None,
3029
3030 gas_rounding_step: None,
3031
3032 execution_version: None,
3033
3034 max_event_emit_size_total: None,
3035
3036 consensus_bad_nodes_stake_threshold: None,
3037
3038 max_jwk_votes_per_validator_per_epoch: None,
3039
3040 max_age_of_jwk_in_epochs: None,
3041
3042 random_beacon_reduction_allowed_delta: None,
3043
3044 random_beacon_reduction_lower_bound: None,
3045
3046 random_beacon_dkg_timeout_round: None,
3047
3048 random_beacon_min_round_interval_ms: None,
3049
3050 random_beacon_dkg_version: None,
3051
3052 consensus_max_transaction_size_bytes: None,
3053
3054 consensus_max_transactions_in_block_bytes: None,
3055
3056 consensus_max_num_transactions_in_block: None,
3057
3058 consensus_voting_rounds: None,
3059
3060 max_accumulated_txn_cost_per_object_in_narwhal_commit: None,
3061
3062 max_deferral_rounds_for_congestion_control: None,
3063
3064 epoch_close_deadline_ms: None,
3065
3066 max_txn_cost_overage_per_object_in_commit: None,
3067
3068 allowed_txn_cost_overage_burst_per_object_in_commit: None,
3069
3070 min_checkpoint_interval_ms: None,
3071
3072 checkpoint_summary_version_specific_data: None,
3073
3074 max_soft_bundle_size: None,
3075
3076 bridge_should_try_to_finalize_committee: None,
3077
3078 max_accumulated_txn_cost_per_object_in_mysticeti_commit: None,
3079
3080 max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit: None,
3081
3082 consensus_gc_depth: None,
3083
3084 gas_budget_based_txn_cost_cap_factor: None,
3085
3086 gas_budget_based_txn_cost_absolute_cap_commit_count: None,
3087
3088 sip_45_consensus_amplification_threshold: None,
3089
3090 use_object_per_epoch_marker_table_v2: None,
3091
3092 consensus_commit_rate_estimation_window_size: None,
3093
3094 aliased_addresses: vec![],
3095
3096 translation_per_command_base_charge: None,
3097 translation_per_input_base_charge: None,
3098 translation_pure_input_per_byte_charge: None,
3099 translation_per_type_node_charge: None,
3100 translation_per_reference_node_charge: None,
3101 translation_per_linkage_entry_charge: None,
3102 translation_per_live_reference_charge: None,
3103 max_ptb_live_references: None,
3104 max_ptb_returned_references: None,
3105 max_ptb_total_returned_references: None,
3106
3107 max_updates_per_settlement_txn: None,
3108
3109 gasless_max_computation_units: None,
3110 gasless_allowed_token_types: None,
3111 gasless_max_unused_inputs: None,
3112 gasless_max_pure_input_bytes: None,
3113 gasless_max_tps: None,
3114 include_special_package_amendments: None,
3115 gasless_max_tx_size_bytes: None,
3116 };
3119 for cur in 2..=version.0 {
3120 match cur {
3121 1 => unreachable!(),
3122 2 => {
3123 cfg.feature_flags.advance_epoch_start_time_in_safe_mode = true;
3124 }
3125 3 => {
3126 cfg.gas_model_version = Some(2);
3128 cfg.max_tx_gas = Some(50_000_000_000);
3130 cfg.base_tx_cost_fixed = Some(2_000);
3132 cfg.storage_gas_price = Some(76);
3134 cfg.feature_flags.loaded_child_objects_fixed = true;
3135 cfg.max_size_written_objects = Some(5 * 1000 * 1000);
3138 cfg.max_size_written_objects_system_tx = Some(50 * 1000 * 1000);
3141 cfg.feature_flags.package_upgrades = true;
3142 }
3143 4 => {
3148 cfg.reward_slashing_rate = Some(10000);
3150 cfg.gas_model_version = Some(3);
3152 }
3153 5 => {
3154 cfg.feature_flags.missing_type_is_compatibility_error = true;
3155 cfg.gas_model_version = Some(4);
3156 cfg.feature_flags.scoring_decision_with_validity_cutoff = true;
3157 }
3161 6 => {
3162 cfg.gas_model_version = Some(5);
3163 cfg.buffer_stake_for_protocol_upgrade_bps = Some(5000);
3164 cfg.feature_flags.consensus_order_end_of_epoch_last = true;
3165 }
3166 7 => {
3167 cfg.feature_flags.disallow_adding_abilities_on_upgrade = true;
3168 cfg.feature_flags
3169 .disable_invariant_violation_check_in_swap_loc = true;
3170 cfg.feature_flags.ban_entry_init = true;
3171 cfg.feature_flags.package_digest_hash_module = true;
3172 }
3173 8 => {
3174 cfg.feature_flags
3175 .disallow_change_struct_type_params_on_upgrade = true;
3176 }
3177 9 => {
3178 cfg.max_move_identifier_len = Some(128);
3180 cfg.feature_flags.no_extraneous_module_bytes = true;
3181 cfg.feature_flags
3182 .advance_to_highest_supported_protocol_version = true;
3183 }
3184 10 => {
3185 cfg.max_verifier_meter_ticks_per_function = Some(16_000_000);
3186 cfg.max_meter_ticks_per_module = Some(16_000_000);
3187 }
3188 11 => {
3189 cfg.max_move_value_depth = Some(128);
3190 }
3191 12 => {
3192 cfg.feature_flags.narwhal_versioned_metadata = true;
3193 if chain != Chain::Mainnet {
3194 cfg.feature_flags.commit_root_state_digest = true;
3195 }
3196
3197 if chain != Chain::Mainnet && chain != Chain::Testnet {
3198 cfg.feature_flags.zklogin_auth = true;
3199 }
3200 }
3201 13 => {}
3202 14 => {
3203 cfg.gas_rounding_step = Some(1_000);
3204 cfg.gas_model_version = Some(6);
3205 }
3206 15 => {
3207 cfg.feature_flags.consensus_transaction_ordering =
3208 ConsensusTransactionOrdering::ByGasPrice;
3209 }
3210 16 => {
3211 cfg.feature_flags.simplified_unwrap_then_delete = true;
3212 }
3213 17 => {
3214 cfg.feature_flags.upgraded_multisig_supported = true;
3215 }
3216 18 => {
3217 cfg.execution_version = Some(1);
3218 cfg.feature_flags.txn_base_cost_as_multiplier = true;
3227 cfg.base_tx_cost_fixed = Some(1_000);
3229 }
3230 19 => {
3231 cfg.max_num_event_emit = Some(1024);
3232 cfg.max_event_emit_size_total = Some(
3235 256 * 250 * 1024, );
3237 }
3238 20 => {
3239 cfg.feature_flags.commit_root_state_digest = true;
3240
3241 if chain != Chain::Mainnet {
3242 cfg.feature_flags.narwhal_new_leader_election_schedule = true;
3243 cfg.consensus_bad_nodes_stake_threshold = Some(20);
3244 }
3245 }
3246
3247 21 => {
3248 if chain != Chain::Mainnet {
3249 cfg.feature_flags.zklogin_supported_providers = BTreeSet::from([
3250 "Google".to_string(),
3251 "Facebook".to_string(),
3252 "Twitch".to_string(),
3253 ]);
3254 }
3255 }
3256 22 => {
3257 cfg.feature_flags.loaded_child_object_format = true;
3258 }
3259 23 => {
3260 cfg.feature_flags.loaded_child_object_format_type = true;
3261 cfg.feature_flags.narwhal_new_leader_election_schedule = true;
3262 cfg.consensus_bad_nodes_stake_threshold = Some(20);
3268 }
3269 24 => {
3270 cfg.feature_flags.simple_conservation_checks = true;
3271 cfg.max_publish_or_upgrade_per_ptb = Some(5);
3272
3273 cfg.feature_flags.end_of_epoch_transaction_supported = true;
3274
3275 if chain != Chain::Mainnet {
3276 cfg.feature_flags.enable_jwk_consensus_updates = true;
3277 cfg.max_jwk_votes_per_validator_per_epoch = Some(240);
3279 cfg.max_age_of_jwk_in_epochs = Some(1);
3280 }
3281 }
3282 25 => {
3283 cfg.feature_flags.zklogin_supported_providers = BTreeSet::from([
3285 "Google".to_string(),
3286 "Facebook".to_string(),
3287 "Twitch".to_string(),
3288 ]);
3289 cfg.feature_flags.zklogin_auth = true;
3290
3291 cfg.feature_flags.enable_jwk_consensus_updates = true;
3293 cfg.max_jwk_votes_per_validator_per_epoch = Some(240);
3294 cfg.max_age_of_jwk_in_epochs = Some(1);
3295 }
3296 26 => {
3297 cfg.gas_model_version = Some(7);
3298 if chain != Chain::Mainnet && chain != Chain::Testnet {
3300 cfg.transfer_receive_object_cost_base = Some(52);
3301 cfg.feature_flags.receive_objects = true;
3302 }
3303 }
3304 27 => {
3305 cfg.gas_model_version = Some(8);
3306 }
3307 28 => {
3308 cfg.check_zklogin_id_cost_base = Some(200);
3310 cfg.check_zklogin_issuer_cost_base = Some(200);
3312
3313 if chain != Chain::Mainnet && chain != Chain::Testnet {
3315 cfg.feature_flags.enable_effects_v2 = true;
3316 }
3317 }
3318 29 => {
3319 cfg.feature_flags.verify_legacy_zklogin_address = true;
3320 }
3321 30 => {
3322 if chain != Chain::Mainnet {
3324 cfg.feature_flags.narwhal_certificate_v2 = true;
3325 }
3326
3327 cfg.random_beacon_reduction_allowed_delta = Some(800);
3328 if chain != Chain::Mainnet {
3330 cfg.feature_flags.enable_effects_v2 = true;
3331 }
3332
3333 cfg.feature_flags.zklogin_supported_providers = BTreeSet::default();
3337
3338 cfg.feature_flags.recompute_has_public_transfer_in_execution = true;
3339 }
3340 31 => {
3341 cfg.execution_version = Some(2);
3342 if chain != Chain::Mainnet && chain != Chain::Testnet {
3344 cfg.feature_flags.shared_object_deletion = true;
3345 }
3346 }
3347 32 => {
3348 if chain != Chain::Mainnet {
3350 cfg.feature_flags.accept_zklogin_in_multisig = true;
3351 }
3352 if chain != Chain::Mainnet {
3354 cfg.transfer_receive_object_cost_base = Some(52);
3355 cfg.feature_flags.receive_objects = true;
3356 }
3357 if chain != Chain::Mainnet && chain != Chain::Testnet {
3359 cfg.feature_flags.random_beacon = true;
3360 cfg.random_beacon_reduction_lower_bound = Some(1600);
3361 cfg.random_beacon_dkg_timeout_round = Some(3000);
3362 cfg.random_beacon_min_round_interval_ms = Some(150);
3363 }
3364 if chain != Chain::Testnet && chain != Chain::Mainnet {
3366 cfg.feature_flags.include_consensus_digest_in_prologue = true;
3367 }
3368
3369 cfg.feature_flags.narwhal_certificate_v2 = true;
3371 }
3372 33 => {
3373 cfg.feature_flags.hardened_otw_check = true;
3374 cfg.feature_flags.allow_receiving_object_id = true;
3375
3376 cfg.transfer_receive_object_cost_base = Some(52);
3378 cfg.feature_flags.receive_objects = true;
3379
3380 if chain != Chain::Mainnet {
3382 cfg.feature_flags.shared_object_deletion = true;
3383 }
3384
3385 cfg.feature_flags.enable_effects_v2 = true;
3386 }
3387 34 => {}
3388 35 => {
3389 if chain != Chain::Mainnet && chain != Chain::Testnet {
3391 cfg.feature_flags.enable_poseidon = true;
3392 cfg.poseidon_bn254_cost_base = Some(260);
3393 cfg.poseidon_bn254_cost_per_block = Some(10);
3394 }
3395
3396 cfg.feature_flags.enable_coin_deny_list = true;
3397 }
3398 36 => {
3399 if chain != Chain::Mainnet && chain != Chain::Testnet {
3401 cfg.feature_flags.enable_group_ops_native_functions = true;
3402 cfg.feature_flags.enable_group_ops_native_function_msm = true;
3403 cfg.group_ops_bls12381_decode_scalar_cost = Some(52);
3405 cfg.group_ops_bls12381_decode_g1_cost = Some(52);
3406 cfg.group_ops_bls12381_decode_g2_cost = Some(52);
3407 cfg.group_ops_bls12381_decode_gt_cost = Some(52);
3408 cfg.group_ops_bls12381_scalar_add_cost = Some(52);
3409 cfg.group_ops_bls12381_g1_add_cost = Some(52);
3410 cfg.group_ops_bls12381_g2_add_cost = Some(52);
3411 cfg.group_ops_bls12381_gt_add_cost = Some(52);
3412 cfg.group_ops_bls12381_scalar_sub_cost = Some(52);
3413 cfg.group_ops_bls12381_g1_sub_cost = Some(52);
3414 cfg.group_ops_bls12381_g2_sub_cost = Some(52);
3415 cfg.group_ops_bls12381_gt_sub_cost = Some(52);
3416 cfg.group_ops_bls12381_scalar_mul_cost = Some(52);
3417 cfg.group_ops_bls12381_g1_mul_cost = Some(52);
3418 cfg.group_ops_bls12381_g2_mul_cost = Some(52);
3419 cfg.group_ops_bls12381_gt_mul_cost = Some(52);
3420 cfg.group_ops_bls12381_scalar_div_cost = Some(52);
3421 cfg.group_ops_bls12381_g1_div_cost = Some(52);
3422 cfg.group_ops_bls12381_g2_div_cost = Some(52);
3423 cfg.group_ops_bls12381_gt_div_cost = Some(52);
3424 cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(52);
3425 cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(52);
3426 cfg.group_ops_bls12381_g1_hash_to_cost_per_byte = Some(2);
3427 cfg.group_ops_bls12381_g2_hash_to_cost_per_byte = Some(2);
3428 cfg.group_ops_bls12381_g1_msm_base_cost = Some(52);
3429 cfg.group_ops_bls12381_g2_msm_base_cost = Some(52);
3430 cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(52);
3431 cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(52);
3432 cfg.group_ops_bls12381_msm_max_len = Some(32);
3433 cfg.group_ops_bls12381_pairing_cost = Some(52);
3434 }
3435 cfg.feature_flags.shared_object_deletion = true;
3437
3438 cfg.consensus_max_transaction_size_bytes = Some(256 * 1024); cfg.consensus_max_transactions_in_block_bytes = Some(6 * 1_024 * 1024);
3440 }
3442 37 => {
3443 cfg.feature_flags.reject_mutable_random_on_entry_functions = true;
3444
3445 if chain != Chain::Mainnet {
3447 cfg.feature_flags.include_consensus_digest_in_prologue = true;
3448 }
3449 }
3450 38 => {
3451 cfg.binary_module_handles = Some(100);
3452 cfg.binary_struct_handles = Some(300);
3453 cfg.binary_function_handles = Some(1500);
3454 cfg.binary_function_instantiations = Some(750);
3455 cfg.binary_signatures = Some(1000);
3456 cfg.binary_constant_pool = Some(4000);
3460 cfg.binary_identifiers = Some(10000);
3461 cfg.binary_address_identifiers = Some(100);
3462 cfg.binary_struct_defs = Some(200);
3463 cfg.binary_struct_def_instantiations = Some(100);
3464 cfg.binary_function_defs = Some(1000);
3465 cfg.binary_field_handles = Some(500);
3466 cfg.binary_field_instantiations = Some(250);
3467 cfg.binary_friend_decls = Some(100);
3468 cfg.max_package_dependencies = Some(32);
3470 cfg.max_modules_in_publish = Some(64);
3471 cfg.execution_version = Some(3);
3473 }
3474 39 => {
3475 }
3477 40 => {}
3478 41 => {
3479 cfg.feature_flags.enable_group_ops_native_functions = true;
3481 cfg.group_ops_bls12381_decode_scalar_cost = Some(52);
3483 cfg.group_ops_bls12381_decode_g1_cost = Some(52);
3484 cfg.group_ops_bls12381_decode_g2_cost = Some(52);
3485 cfg.group_ops_bls12381_decode_gt_cost = Some(52);
3486 cfg.group_ops_bls12381_scalar_add_cost = Some(52);
3487 cfg.group_ops_bls12381_g1_add_cost = Some(52);
3488 cfg.group_ops_bls12381_g2_add_cost = Some(52);
3489 cfg.group_ops_bls12381_gt_add_cost = Some(52);
3490 cfg.group_ops_bls12381_scalar_sub_cost = Some(52);
3491 cfg.group_ops_bls12381_g1_sub_cost = Some(52);
3492 cfg.group_ops_bls12381_g2_sub_cost = Some(52);
3493 cfg.group_ops_bls12381_gt_sub_cost = Some(52);
3494 cfg.group_ops_bls12381_scalar_mul_cost = Some(52);
3495 cfg.group_ops_bls12381_g1_mul_cost = Some(52);
3496 cfg.group_ops_bls12381_g2_mul_cost = Some(52);
3497 cfg.group_ops_bls12381_gt_mul_cost = Some(52);
3498 cfg.group_ops_bls12381_scalar_div_cost = Some(52);
3499 cfg.group_ops_bls12381_g1_div_cost = Some(52);
3500 cfg.group_ops_bls12381_g2_div_cost = Some(52);
3501 cfg.group_ops_bls12381_gt_div_cost = Some(52);
3502 cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(52);
3503 cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(52);
3504 cfg.group_ops_bls12381_g1_hash_to_cost_per_byte = Some(2);
3505 cfg.group_ops_bls12381_g2_hash_to_cost_per_byte = Some(2);
3506 cfg.group_ops_bls12381_g1_msm_base_cost = Some(52);
3507 cfg.group_ops_bls12381_g2_msm_base_cost = Some(52);
3508 cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(52);
3509 cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(52);
3510 cfg.group_ops_bls12381_msm_max_len = Some(32);
3511 cfg.group_ops_bls12381_pairing_cost = Some(52);
3512 }
3513 42 => {}
3514 43 => {
3515 cfg.feature_flags.zklogin_max_epoch_upper_bound_delta = Some(30);
3516 cfg.max_meter_ticks_per_package = Some(16_000_000);
3517 }
3518 44 => {
3519 cfg.feature_flags.include_consensus_digest_in_prologue = true;
3521 if chain != Chain::Mainnet {
3523 cfg.feature_flags.consensus_choice = ConsensusChoice::SwapEachEpoch;
3524 }
3525 }
3526 45 => {
3527 if chain != Chain::Testnet && chain != Chain::Mainnet {
3529 cfg.feature_flags.consensus_network = ConsensusNetwork::Tonic;
3530 }
3531
3532 if chain != Chain::Mainnet {
3533 cfg.feature_flags.mysticeti_leader_scoring_and_schedule = true;
3535 }
3536 cfg.min_move_binary_format_version = Some(6);
3537 cfg.feature_flags.accept_zklogin_in_multisig = true;
3538
3539 if chain != Chain::Mainnet && chain != Chain::Testnet {
3543 cfg.feature_flags.bridge = true;
3544 }
3545 }
3546 46 => {
3547 if chain != Chain::Mainnet {
3549 cfg.feature_flags.bridge = true;
3550 }
3551
3552 cfg.feature_flags.reshare_at_same_initial_version = true;
3554 }
3555 47 => {}
3556 48 => {
3557 cfg.feature_flags.consensus_network = ConsensusNetwork::Tonic;
3559
3560 cfg.feature_flags.resolve_abort_locations_to_package_id = true;
3562
3563 if chain != Chain::Mainnet {
3565 cfg.feature_flags.random_beacon = true;
3566 cfg.random_beacon_reduction_lower_bound = Some(1600);
3567 cfg.random_beacon_dkg_timeout_round = Some(3000);
3568 cfg.random_beacon_min_round_interval_ms = Some(200);
3569 }
3570
3571 cfg.feature_flags.mysticeti_use_committed_subdag_digest = true;
3573 }
3574 49 => {
3575 if chain != Chain::Testnet && chain != Chain::Mainnet {
3576 cfg.move_binary_format_version = Some(7);
3577 }
3578
3579 if chain != Chain::Mainnet && chain != Chain::Testnet {
3581 cfg.feature_flags.enable_vdf = true;
3582 cfg.vdf_verify_vdf_cost = Some(1500);
3585 cfg.vdf_hash_to_input_cost = Some(100);
3586 }
3587
3588 if chain != Chain::Testnet && chain != Chain::Mainnet {
3590 cfg.feature_flags
3591 .record_consensus_determined_version_assignments_in_prologue = true;
3592 }
3593
3594 if chain != Chain::Mainnet {
3596 cfg.feature_flags.consensus_choice = ConsensusChoice::Mysticeti;
3597 }
3598
3599 cfg.feature_flags.fresh_vm_on_framework_upgrade = true;
3601 }
3602 50 => {
3603 if chain != Chain::Mainnet {
3605 cfg.checkpoint_summary_version_specific_data = Some(1);
3606 cfg.min_checkpoint_interval_ms = Some(200);
3607 }
3608
3609 if chain != Chain::Testnet && chain != Chain::Mainnet {
3611 cfg.feature_flags
3612 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = true;
3613 }
3614
3615 cfg.feature_flags.mysticeti_num_leaders_per_round = Some(1);
3616
3617 cfg.max_deferral_rounds_for_congestion_control = Some(10);
3619 }
3620 51 => {
3621 cfg.random_beacon_dkg_version = Some(1);
3622
3623 if chain != Chain::Testnet && chain != Chain::Mainnet {
3624 cfg.feature_flags.enable_coin_deny_list_v2 = true;
3625 }
3626 }
3627 52 => {
3628 if chain != Chain::Mainnet {
3629 cfg.feature_flags.soft_bundle = true;
3630 cfg.max_soft_bundle_size = Some(5);
3631 }
3632
3633 cfg.config_read_setting_impl_cost_base = Some(100);
3634 cfg.config_read_setting_impl_cost_per_byte = Some(40);
3635
3636 if chain != Chain::Testnet && chain != Chain::Mainnet {
3638 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(100);
3639 cfg.feature_flags.per_object_congestion_control_mode =
3640 PerObjectCongestionControlMode::TotalTxCount;
3641 }
3642
3643 cfg.feature_flags.consensus_choice = ConsensusChoice::Mysticeti;
3645
3646 cfg.feature_flags.mysticeti_leader_scoring_and_schedule = true;
3648
3649 cfg.checkpoint_summary_version_specific_data = Some(1);
3651 cfg.min_checkpoint_interval_ms = Some(200);
3652
3653 if chain != Chain::Mainnet {
3655 cfg.feature_flags
3656 .record_consensus_determined_version_assignments_in_prologue = true;
3657 cfg.feature_flags
3658 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = true;
3659 }
3660 if chain != Chain::Mainnet {
3662 cfg.move_binary_format_version = Some(7);
3663 }
3664
3665 if chain != Chain::Testnet && chain != Chain::Mainnet {
3666 cfg.feature_flags.passkey_auth = true;
3667 }
3668 cfg.feature_flags.enable_coin_deny_list_v2 = true;
3669 }
3670 53 => {
3671 cfg.bridge_should_try_to_finalize_committee = Some(chain != Chain::Mainnet);
3673
3674 cfg.feature_flags
3676 .record_consensus_determined_version_assignments_in_prologue = true;
3677 cfg.feature_flags
3678 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = true;
3679
3680 if chain == Chain::Unknown {
3681 cfg.feature_flags.authority_capabilities_v2 = true;
3682 }
3683
3684 if chain != Chain::Mainnet {
3686 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(100);
3687 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(10);
3688 cfg.feature_flags.per_object_congestion_control_mode =
3689 PerObjectCongestionControlMode::TotalTxCount;
3690 }
3691
3692 cfg.bcs_per_byte_serialized_cost = Some(2);
3694 cfg.bcs_legacy_min_output_size_cost = Some(1);
3695 cfg.bcs_failure_cost = Some(52);
3696 cfg.debug_print_base_cost = Some(52);
3697 cfg.debug_print_stack_trace_base_cost = Some(52);
3698 cfg.hash_sha2_256_base_cost = Some(52);
3699 cfg.hash_sha2_256_per_byte_cost = Some(2);
3700 cfg.hash_sha2_256_legacy_min_input_len_cost = Some(1);
3701 cfg.hash_sha3_256_base_cost = Some(52);
3702 cfg.hash_sha3_256_per_byte_cost = Some(2);
3703 cfg.hash_sha3_256_legacy_min_input_len_cost = Some(1);
3704 cfg.type_name_get_base_cost = Some(52);
3705 cfg.type_name_get_per_byte_cost = Some(2);
3706 cfg.string_check_utf8_base_cost = Some(52);
3707 cfg.string_check_utf8_per_byte_cost = Some(2);
3708 cfg.string_is_char_boundary_base_cost = Some(52);
3709 cfg.string_sub_string_base_cost = Some(52);
3710 cfg.string_sub_string_per_byte_cost = Some(2);
3711 cfg.string_index_of_base_cost = Some(52);
3712 cfg.string_index_of_per_byte_pattern_cost = Some(2);
3713 cfg.string_index_of_per_byte_searched_cost = Some(2);
3714 cfg.vector_empty_base_cost = Some(52);
3715 cfg.vector_length_base_cost = Some(52);
3716 cfg.vector_push_back_base_cost = Some(52);
3717 cfg.vector_push_back_legacy_per_abstract_memory_unit_cost = Some(2);
3718 cfg.vector_borrow_base_cost = Some(52);
3719 cfg.vector_pop_back_base_cost = Some(52);
3720 cfg.vector_destroy_empty_base_cost = Some(52);
3721 cfg.vector_swap_base_cost = Some(52);
3722 }
3723 54 => {
3724 cfg.feature_flags.random_beacon = true;
3726 cfg.random_beacon_reduction_lower_bound = Some(1000);
3727 cfg.random_beacon_dkg_timeout_round = Some(3000);
3728 cfg.random_beacon_min_round_interval_ms = Some(500);
3729
3730 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(100);
3732 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(10);
3733 cfg.feature_flags.per_object_congestion_control_mode =
3734 PerObjectCongestionControlMode::TotalTxCount;
3735
3736 cfg.feature_flags.soft_bundle = true;
3738 cfg.max_soft_bundle_size = Some(5);
3739 }
3740 55 => {
3741 cfg.move_binary_format_version = Some(7);
3743
3744 cfg.consensus_max_transactions_in_block_bytes = Some(512 * 1024);
3746 cfg.consensus_max_num_transactions_in_block = Some(512);
3749
3750 cfg.feature_flags.rethrow_serialization_type_layout_errors = true;
3751 }
3752 56 => {
3753 if chain == Chain::Mainnet {
3754 cfg.feature_flags.bridge = true;
3755 }
3756 }
3757 57 => {
3758 cfg.random_beacon_reduction_lower_bound = Some(800);
3760 }
3761 58 => {
3762 if chain == Chain::Mainnet {
3763 cfg.bridge_should_try_to_finalize_committee = Some(true);
3764 }
3765
3766 if chain != Chain::Mainnet && chain != Chain::Testnet {
3767 cfg.feature_flags
3769 .consensus_distributed_vote_scoring_strategy = true;
3770 }
3771 }
3772 59 => {
3773 cfg.feature_flags.consensus_round_prober = true;
3775 }
3776 60 => {
3777 cfg.max_type_to_layout_nodes = Some(512);
3778 cfg.feature_flags.validate_identifier_inputs = true;
3779 }
3780 61 => {
3781 if chain != Chain::Mainnet {
3782 cfg.feature_flags
3784 .consensus_distributed_vote_scoring_strategy = true;
3785 }
3786 cfg.random_beacon_reduction_lower_bound = Some(700);
3788
3789 if chain != Chain::Mainnet && chain != Chain::Testnet {
3790 cfg.feature_flags.mysticeti_fastpath = true;
3792 }
3793 }
3794 62 => {
3795 cfg.feature_flags.relocate_event_module = true;
3796 }
3797 63 => {
3798 cfg.feature_flags.per_object_congestion_control_mode =
3799 PerObjectCongestionControlMode::TotalGasBudgetWithCap;
3800 cfg.gas_budget_based_txn_cost_cap_factor = Some(400_000);
3801 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(18_500_000);
3802 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(240_000_000);
3803 }
3804 64 => {
3805 cfg.feature_flags.per_object_congestion_control_mode =
3806 PerObjectCongestionControlMode::TotalTxCount;
3807 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(40);
3808 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(3);
3809 }
3810 65 => {
3811 cfg.feature_flags
3813 .consensus_distributed_vote_scoring_strategy = true;
3814 }
3815 66 => {
3816 if chain == Chain::Mainnet {
3817 cfg.feature_flags
3819 .consensus_distributed_vote_scoring_strategy = false;
3820 }
3821 }
3822 67 => {
3823 cfg.feature_flags
3825 .consensus_distributed_vote_scoring_strategy = true;
3826 }
3827 68 => {
3828 cfg.group_ops_bls12381_g1_to_uncompressed_g1_cost = Some(26);
3829 cfg.group_ops_bls12381_uncompressed_g1_to_g1_cost = Some(52);
3830 cfg.group_ops_bls12381_uncompressed_g1_sum_base_cost = Some(26);
3831 cfg.group_ops_bls12381_uncompressed_g1_sum_cost_per_term = Some(13);
3832 cfg.group_ops_bls12381_uncompressed_g1_sum_max_terms = Some(2000);
3833
3834 if chain != Chain::Mainnet && chain != Chain::Testnet {
3835 cfg.feature_flags.uncompressed_g1_group_elements = true;
3836 }
3837
3838 cfg.feature_flags.per_object_congestion_control_mode =
3839 PerObjectCongestionControlMode::TotalGasBudgetWithCap;
3840 cfg.gas_budget_based_txn_cost_cap_factor = Some(400_000);
3841 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(18_500_000);
3842 cfg.max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit =
3843 Some(3_700_000); cfg.max_txn_cost_overage_per_object_in_commit = Some(u64::MAX);
3845 cfg.gas_budget_based_txn_cost_absolute_cap_commit_count = Some(50);
3846
3847 cfg.random_beacon_reduction_lower_bound = Some(500);
3849
3850 cfg.feature_flags.disallow_new_modules_in_deps_only_packages = true;
3851 }
3852 69 => {
3853 cfg.consensus_voting_rounds = Some(40);
3855
3856 if chain != Chain::Mainnet && chain != Chain::Testnet {
3857 cfg.feature_flags.consensus_smart_ancestor_selection = true;
3859 }
3860
3861 if chain != Chain::Mainnet {
3862 cfg.feature_flags.uncompressed_g1_group_elements = true;
3863 }
3864 }
3865 70 => {
3866 if chain != Chain::Mainnet {
3867 cfg.feature_flags.consensus_smart_ancestor_selection = true;
3869 cfg.feature_flags
3871 .consensus_round_prober_probe_accepted_rounds = true;
3872 }
3873
3874 cfg.poseidon_bn254_cost_per_block = Some(388);
3875
3876 cfg.gas_model_version = Some(9);
3877 cfg.feature_flags.native_charging_v2 = true;
3878 cfg.bls12381_bls12381_min_sig_verify_cost_base = Some(44064);
3879 cfg.bls12381_bls12381_min_pk_verify_cost_base = Some(49282);
3880 cfg.ecdsa_k1_secp256k1_verify_keccak256_cost_base = Some(1470);
3881 cfg.ecdsa_k1_secp256k1_verify_sha256_cost_base = Some(1470);
3882 cfg.ecdsa_r1_secp256r1_verify_sha256_cost_base = Some(4225);
3883 cfg.ecdsa_r1_secp256r1_verify_keccak256_cost_base = Some(4225);
3884 cfg.ecvrf_ecvrf_verify_cost_base = Some(4848);
3885 cfg.ed25519_ed25519_verify_cost_base = Some(1802);
3886
3887 cfg.ecdsa_r1_ecrecover_keccak256_cost_base = Some(1173);
3889 cfg.ecdsa_r1_ecrecover_sha256_cost_base = Some(1173);
3890 cfg.ecdsa_k1_ecrecover_keccak256_cost_base = Some(500);
3891 cfg.ecdsa_k1_ecrecover_sha256_cost_base = Some(500);
3892
3893 cfg.groth16_prepare_verifying_key_bls12381_cost_base = Some(53838);
3894 cfg.groth16_prepare_verifying_key_bn254_cost_base = Some(82010);
3895 cfg.groth16_verify_groth16_proof_internal_bls12381_cost_base = Some(72090);
3896 cfg.groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input =
3897 Some(8213);
3898 cfg.groth16_verify_groth16_proof_internal_bn254_cost_base = Some(115502);
3899 cfg.groth16_verify_groth16_proof_internal_bn254_cost_per_public_input =
3900 Some(9484);
3901
3902 cfg.hash_keccak256_cost_base = Some(10);
3903 cfg.hash_blake2b256_cost_base = Some(10);
3904
3905 cfg.group_ops_bls12381_decode_scalar_cost = Some(7);
3907 cfg.group_ops_bls12381_decode_g1_cost = Some(2848);
3908 cfg.group_ops_bls12381_decode_g2_cost = Some(3770);
3909 cfg.group_ops_bls12381_decode_gt_cost = Some(3068);
3910
3911 cfg.group_ops_bls12381_scalar_add_cost = Some(10);
3912 cfg.group_ops_bls12381_g1_add_cost = Some(1556);
3913 cfg.group_ops_bls12381_g2_add_cost = Some(3048);
3914 cfg.group_ops_bls12381_gt_add_cost = Some(188);
3915
3916 cfg.group_ops_bls12381_scalar_sub_cost = Some(10);
3917 cfg.group_ops_bls12381_g1_sub_cost = Some(1550);
3918 cfg.group_ops_bls12381_g2_sub_cost = Some(3019);
3919 cfg.group_ops_bls12381_gt_sub_cost = Some(497);
3920
3921 cfg.group_ops_bls12381_scalar_mul_cost = Some(11);
3922 cfg.group_ops_bls12381_g1_mul_cost = Some(4842);
3923 cfg.group_ops_bls12381_g2_mul_cost = Some(9108);
3924 cfg.group_ops_bls12381_gt_mul_cost = Some(27490);
3925
3926 cfg.group_ops_bls12381_scalar_div_cost = Some(91);
3927 cfg.group_ops_bls12381_g1_div_cost = Some(5091);
3928 cfg.group_ops_bls12381_g2_div_cost = Some(9206);
3929 cfg.group_ops_bls12381_gt_div_cost = Some(27804);
3930
3931 cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(2962);
3932 cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(8688);
3933
3934 cfg.group_ops_bls12381_g1_msm_base_cost = Some(62648);
3935 cfg.group_ops_bls12381_g2_msm_base_cost = Some(131192);
3936 cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(1333);
3937 cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(3216);
3938
3939 cfg.group_ops_bls12381_uncompressed_g1_to_g1_cost = Some(677);
3940 cfg.group_ops_bls12381_g1_to_uncompressed_g1_cost = Some(2099);
3941 cfg.group_ops_bls12381_uncompressed_g1_sum_base_cost = Some(77);
3942 cfg.group_ops_bls12381_uncompressed_g1_sum_cost_per_term = Some(26);
3943
3944 cfg.group_ops_bls12381_pairing_cost = Some(26897);
3945 cfg.group_ops_bls12381_uncompressed_g1_sum_max_terms = Some(1200);
3946
3947 cfg.validator_validate_metadata_cost_base = Some(20000);
3948 }
3949 71 => {
3950 cfg.sip_45_consensus_amplification_threshold = Some(5);
3951
3952 cfg.allowed_txn_cost_overage_burst_per_object_in_commit = Some(185_000_000);
3954 }
3955 72 => {
3956 cfg.feature_flags.convert_type_argument_error = true;
3957
3958 cfg.max_tx_gas = Some(50_000_000_000_000);
3961 cfg.max_gas_price = Some(50_000_000_000);
3963
3964 cfg.feature_flags.variant_nodes = true;
3965 }
3966 73 => {
3967 cfg.use_object_per_epoch_marker_table_v2 = Some(true);
3969
3970 if chain != Chain::Mainnet && chain != Chain::Testnet {
3971 cfg.consensus_gc_depth = Some(60);
3974 }
3975
3976 if chain != Chain::Mainnet {
3977 cfg.feature_flags.consensus_zstd_compression = true;
3979 }
3980
3981 cfg.feature_flags.consensus_smart_ancestor_selection = true;
3983 cfg.feature_flags
3985 .consensus_round_prober_probe_accepted_rounds = true;
3986
3987 cfg.feature_flags.per_object_congestion_control_mode =
3989 PerObjectCongestionControlMode::TotalGasBudgetWithCap;
3990 cfg.gas_budget_based_txn_cost_cap_factor = Some(400_000);
3991 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(37_000_000);
3992 cfg.max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit =
3993 Some(7_400_000); cfg.max_txn_cost_overage_per_object_in_commit = Some(u64::MAX);
3995 cfg.gas_budget_based_txn_cost_absolute_cap_commit_count = Some(50);
3996 cfg.allowed_txn_cost_overage_burst_per_object_in_commit = Some(370_000_000);
3997 }
3998 74 => {
3999 if chain != Chain::Mainnet && chain != Chain::Testnet {
4001 cfg.feature_flags.enable_nitro_attestation = true;
4002 }
4003 cfg.nitro_attestation_parse_base_cost = Some(53 * 50);
4004 cfg.nitro_attestation_parse_cost_per_byte = Some(50);
4005 cfg.nitro_attestation_verify_base_cost = Some(49632 * 50);
4006 cfg.nitro_attestation_verify_cost_per_cert = Some(52369 * 50);
4007
4008 cfg.feature_flags.consensus_zstd_compression = true;
4010
4011 if chain != Chain::Mainnet && chain != Chain::Testnet {
4012 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
4013 }
4014 }
4015 75 => {
4016 if chain != Chain::Mainnet {
4017 cfg.feature_flags.passkey_auth = true;
4018 }
4019 }
4020 76 => {
4021 if chain != Chain::Mainnet && chain != Chain::Testnet {
4022 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
4023 cfg.consensus_commit_rate_estimation_window_size = Some(10);
4024 }
4025 cfg.feature_flags.minimize_child_object_mutations = true;
4026
4027 if chain != Chain::Mainnet {
4028 cfg.feature_flags.accept_passkey_in_multisig = true;
4029 }
4030 }
4031 77 => {
4032 cfg.feature_flags.uncompressed_g1_group_elements = true;
4033
4034 if chain != Chain::Mainnet {
4035 cfg.consensus_gc_depth = Some(60);
4036 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
4037 }
4038 }
4039 78 => {
4040 cfg.feature_flags.move_native_context = true;
4041 cfg.tx_context_fresh_id_cost_base = Some(52);
4042 cfg.tx_context_sender_cost_base = Some(30);
4043 cfg.tx_context_epoch_cost_base = Some(30);
4044 cfg.tx_context_epoch_timestamp_ms_cost_base = Some(30);
4045 cfg.tx_context_sponsor_cost_base = Some(30);
4046 cfg.tx_context_gas_price_cost_base = Some(30);
4047 cfg.tx_context_gas_budget_cost_base = Some(30);
4048 cfg.tx_context_ids_created_cost_base = Some(30);
4049 cfg.tx_context_replace_cost_base = Some(30);
4050 cfg.gas_model_version = Some(10);
4051
4052 if chain != Chain::Mainnet {
4053 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
4054 cfg.consensus_commit_rate_estimation_window_size = Some(10);
4055
4056 cfg.feature_flags.per_object_congestion_control_mode =
4058 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4059 ExecutionTimeEstimateParams {
4060 target_utilization: 30,
4061 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4063 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4065 stored_observations_limit: u64::MAX,
4066 stake_weighted_median_threshold: 0,
4067 default_none_duration_for_new_keys: false,
4068 observations_chunk_size: None,
4069 },
4070 );
4071 }
4072 }
4073 79 => {
4074 if chain != Chain::Mainnet {
4075 cfg.feature_flags.consensus_median_based_commit_timestamp = true;
4076
4077 cfg.consensus_bad_nodes_stake_threshold = Some(30);
4080
4081 cfg.feature_flags.consensus_batched_block_sync = true;
4082
4083 cfg.feature_flags.enable_nitro_attestation = true
4085 }
4086 cfg.feature_flags.normalize_ptb_arguments = true;
4087
4088 cfg.consensus_gc_depth = Some(60);
4089 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
4090 }
4091 80 => {
4092 cfg.max_ptb_value_size = Some(1024 * 1024);
4093 }
4094 81 => {
4095 cfg.feature_flags.consensus_median_based_commit_timestamp = true;
4096 cfg.feature_flags.enforce_checkpoint_timestamp_monotonicity = true;
4097 cfg.consensus_bad_nodes_stake_threshold = Some(30)
4098 }
4099 82 => {
4100 cfg.feature_flags.max_ptb_value_size_v2 = true;
4101 }
4102 83 => {
4103 if chain == Chain::Mainnet {
4104 let aliased: [u8; 32] = Hex::decode(
4106 "0x0b2da327ba6a4cacbe75dddd50e6e8bbf81d6496e92d66af9154c61c77f7332f",
4107 )
4108 .unwrap()
4109 .try_into()
4110 .unwrap();
4111
4112 cfg.aliased_addresses.push(AliasedAddress {
4114 original: Hex::decode("0xcd8962dad278d8b50fa0f9eb0186bfa4cbdecc6d59377214c88d0286a0ac9562").unwrap().try_into().unwrap(),
4115 aliased,
4116 allowed_tx_digests: vec![
4117 Base58::decode("B2eGLFoMHgj93Ni8dAJBfqGzo8EWSTLBesZzhEpTPA4").unwrap().try_into().unwrap(),
4118 ],
4119 });
4120
4121 cfg.aliased_addresses.push(AliasedAddress {
4122 original: Hex::decode("0xe28b50cef1d633ea43d3296a3f6b67ff0312a5f1a99f0af753c85b8b5de8ff06").unwrap().try_into().unwrap(),
4123 aliased,
4124 allowed_tx_digests: vec![
4125 Base58::decode("J4QqSAgp7VrQtQpMy5wDX4QGsCSEZu3U5KuDAkbESAge").unwrap().try_into().unwrap(),
4126 ],
4127 });
4128 }
4129
4130 if chain != Chain::Mainnet {
4133 cfg.feature_flags.resolve_type_input_ids_to_defining_id = true;
4134 cfg.transfer_party_transfer_internal_cost_base = Some(52);
4135
4136 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
4138 cfg.consensus_commit_rate_estimation_window_size = Some(10);
4139 cfg.feature_flags.per_object_congestion_control_mode =
4140 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4141 ExecutionTimeEstimateParams {
4142 target_utilization: 30,
4143 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4145 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4147 stored_observations_limit: u64::MAX,
4148 stake_weighted_median_threshold: 0,
4149 default_none_duration_for_new_keys: false,
4150 observations_chunk_size: None,
4151 },
4152 );
4153
4154 cfg.feature_flags.consensus_batched_block_sync = true;
4156
4157 cfg.feature_flags.enable_nitro_attestation_upgraded_parsing = true;
4160 cfg.feature_flags.enable_nitro_attestation = true;
4161 }
4162 }
4163 84 => {
4164 if chain == Chain::Mainnet {
4165 cfg.feature_flags.resolve_type_input_ids_to_defining_id = true;
4166 cfg.transfer_party_transfer_internal_cost_base = Some(52);
4167
4168 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
4170 cfg.consensus_commit_rate_estimation_window_size = Some(10);
4171 cfg.feature_flags.per_object_congestion_control_mode =
4172 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4173 ExecutionTimeEstimateParams {
4174 target_utilization: 30,
4175 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4177 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4179 stored_observations_limit: u64::MAX,
4180 stake_weighted_median_threshold: 0,
4181 default_none_duration_for_new_keys: false,
4182 observations_chunk_size: None,
4183 },
4184 );
4185
4186 cfg.feature_flags.consensus_batched_block_sync = true;
4188
4189 cfg.feature_flags.enable_nitro_attestation_upgraded_parsing = true;
4192 cfg.feature_flags.enable_nitro_attestation = true;
4193 }
4194
4195 cfg.feature_flags.per_object_congestion_control_mode =
4197 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4198 ExecutionTimeEstimateParams {
4199 target_utilization: 30,
4200 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4202 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4204 stored_observations_limit: 20,
4205 stake_weighted_median_threshold: 0,
4206 default_none_duration_for_new_keys: false,
4207 observations_chunk_size: None,
4208 },
4209 );
4210 cfg.feature_flags.allow_unbounded_system_objects = true;
4211 }
4212 85 => {
4213 if chain != Chain::Mainnet && chain != Chain::Testnet {
4214 cfg.feature_flags.enable_party_transfer = true;
4215 }
4216
4217 cfg.feature_flags
4218 .record_consensus_determined_version_assignments_in_prologue_v2 = true;
4219 cfg.feature_flags.disallow_self_identifier = true;
4220 cfg.feature_flags.per_object_congestion_control_mode =
4221 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4222 ExecutionTimeEstimateParams {
4223 target_utilization: 50,
4224 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4226 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4228 stored_observations_limit: 20,
4229 stake_weighted_median_threshold: 0,
4230 default_none_duration_for_new_keys: false,
4231 observations_chunk_size: None,
4232 },
4233 );
4234 }
4235 86 => {
4236 cfg.feature_flags.type_tags_in_object_runtime = true;
4237 cfg.max_move_enum_variants = Some(move_core_types::VARIANT_COUNT_MAX);
4238
4239 cfg.feature_flags.per_object_congestion_control_mode =
4241 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4242 ExecutionTimeEstimateParams {
4243 target_utilization: 50,
4244 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4246 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4248 stored_observations_limit: 20,
4249 stake_weighted_median_threshold: 3334,
4250 default_none_duration_for_new_keys: false,
4251 observations_chunk_size: None,
4252 },
4253 );
4254 if chain != Chain::Mainnet {
4256 cfg.feature_flags.enable_party_transfer = true;
4257 }
4258 }
4259 87 => {
4260 if chain == Chain::Mainnet {
4261 cfg.feature_flags.record_time_estimate_processed = true;
4262 }
4263 cfg.feature_flags.better_adapter_type_resolution_errors = true;
4264 }
4265 88 => {
4266 cfg.feature_flags.record_time_estimate_processed = true;
4267 cfg.tx_context_rgp_cost_base = Some(30);
4268 cfg.feature_flags
4269 .ignore_execution_time_observations_after_certs_closed = true;
4270
4271 cfg.feature_flags.per_object_congestion_control_mode =
4274 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4275 ExecutionTimeEstimateParams {
4276 target_utilization: 50,
4277 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4279 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4281 stored_observations_limit: 20,
4282 stake_weighted_median_threshold: 3334,
4283 default_none_duration_for_new_keys: true,
4284 observations_chunk_size: None,
4285 },
4286 );
4287 }
4288 89 => {
4289 cfg.feature_flags.dependency_linkage_error = true;
4290 cfg.feature_flags.additional_multisig_checks = true;
4291 }
4292 90 => {
4293 cfg.max_gas_price_rgp_factor_for_aborted_transactions = Some(100);
4295 cfg.feature_flags.debug_fatal_on_move_invariant_violation = true;
4296 cfg.feature_flags.additional_consensus_digest_indirect_state = true;
4297 cfg.feature_flags.accept_passkey_in_multisig = true;
4298 cfg.feature_flags.passkey_auth = true;
4299 cfg.feature_flags.check_for_init_during_upgrade = true;
4300
4301 if chain != Chain::Mainnet {
4303 cfg.feature_flags.mysticeti_fastpath = true;
4304 }
4305 }
4306 91 => {
4307 cfg.feature_flags.per_command_shared_object_transfer_rules = true;
4308 }
4309 92 => {
4310 cfg.feature_flags.per_command_shared_object_transfer_rules = false;
4311 }
4312 93 => {
4313 cfg.feature_flags
4314 .consensus_checkpoint_signature_key_includes_digest = true;
4315 }
4316 94 => {
4317 cfg.feature_flags.per_object_congestion_control_mode =
4319 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4320 ExecutionTimeEstimateParams {
4321 target_utilization: 50,
4322 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4324 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4326 stored_observations_limit: 18,
4327 stake_weighted_median_threshold: 3334,
4328 default_none_duration_for_new_keys: true,
4329 observations_chunk_size: None,
4330 },
4331 );
4332
4333 cfg.feature_flags.enable_party_transfer = true;
4335 }
4336 95 => {
4337 cfg.type_name_id_base_cost = Some(52);
4338
4339 cfg.max_transactions_per_checkpoint = Some(20_000);
4341 }
4342 96 => {
4343 if chain != Chain::Mainnet && chain != Chain::Testnet {
4345 cfg.feature_flags
4346 .include_checkpoint_artifacts_digest_in_summary = true;
4347 }
4348 cfg.feature_flags.correct_gas_payment_limit_check = true;
4349 cfg.feature_flags.authority_capabilities_v2 = true;
4350 cfg.feature_flags.use_mfp_txns_in_load_initial_object_debts = true;
4351 cfg.feature_flags.cancel_for_failed_dkg_early = true;
4352 cfg.feature_flags.enable_coin_registry = true;
4353
4354 cfg.feature_flags.mysticeti_fastpath = true;
4356 }
4357 97 => {
4358 cfg.feature_flags.additional_borrow_checks = true;
4359 }
4360 98 => {
4361 cfg.event_emit_auth_stream_cost = Some(52);
4362 cfg.feature_flags.better_loader_errors = true;
4363 cfg.feature_flags.generate_df_type_layouts = true;
4364 }
4365 99 => {
4366 cfg.feature_flags.use_new_commit_handler = true;
4367 }
4368 100 => {
4369 cfg.feature_flags.private_generics_verifier_v2 = true;
4370 }
4371 101 => {
4372 cfg.feature_flags.create_root_accumulator_object = true;
4373 cfg.max_updates_per_settlement_txn = Some(100);
4374 if chain != Chain::Mainnet {
4375 cfg.feature_flags.enable_poseidon = true;
4376 }
4377 }
4378 102 => {
4379 cfg.feature_flags.per_object_congestion_control_mode =
4383 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4384 ExecutionTimeEstimateParams {
4385 target_utilization: 50,
4386 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4388 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4390 stored_observations_limit: 180,
4391 stake_weighted_median_threshold: 3334,
4392 default_none_duration_for_new_keys: true,
4393 observations_chunk_size: Some(18),
4394 },
4395 );
4396 cfg.feature_flags.deprecate_global_storage_ops = true;
4397 }
4398 103 => {}
4399 104 => {
4400 cfg.translation_per_command_base_charge = Some(1);
4401 cfg.translation_per_input_base_charge = Some(1);
4402 cfg.translation_pure_input_per_byte_charge = Some(1);
4403 cfg.translation_per_type_node_charge = Some(1);
4404 cfg.translation_per_reference_node_charge = Some(1);
4405 cfg.translation_per_linkage_entry_charge = Some(10);
4406 cfg.gas_model_version = Some(11);
4407 cfg.feature_flags.abstract_size_in_object_runtime = true;
4408 cfg.feature_flags.object_runtime_charge_cache_load_gas = true;
4409 cfg.dynamic_field_hash_type_and_key_cost_base = Some(52);
4410 cfg.dynamic_field_add_child_object_cost_base = Some(52);
4411 cfg.dynamic_field_add_child_object_value_cost_per_byte = Some(1);
4412 cfg.dynamic_field_borrow_child_object_cost_base = Some(52);
4413 cfg.dynamic_field_borrow_child_object_child_ref_cost_per_byte = Some(1);
4414 cfg.dynamic_field_remove_child_object_cost_base = Some(52);
4415 cfg.dynamic_field_remove_child_object_child_cost_per_byte = Some(1);
4416 cfg.dynamic_field_has_child_object_cost_base = Some(52);
4417 cfg.dynamic_field_has_child_object_with_ty_cost_base = Some(52);
4418 cfg.feature_flags.enable_ptb_execution_v2 = true;
4419
4420 cfg.poseidon_bn254_cost_base = Some(260);
4421
4422 cfg.feature_flags.consensus_skip_gced_accept_votes = true;
4423
4424 if chain != Chain::Mainnet {
4425 cfg.feature_flags
4426 .enable_nitro_attestation_all_nonzero_pcrs_parsing = true;
4427 }
4428
4429 cfg.feature_flags
4430 .include_cancelled_randomness_txns_in_prologue = true;
4431 }
4432 105 => {
4433 cfg.feature_flags.enable_multi_epoch_transaction_expiration = true;
4434 cfg.feature_flags.disable_preconsensus_locking = true;
4435
4436 if chain != Chain::Mainnet {
4437 cfg.feature_flags
4438 .enable_nitro_attestation_always_include_required_pcrs_parsing = true;
4439 }
4440 }
4441 106 => {
4442 cfg.accumulator_object_storage_cost = Some(7600);
4444
4445 if chain != Chain::Mainnet && chain != Chain::Testnet {
4446 cfg.feature_flags.enable_accumulators = true;
4447 cfg.feature_flags.enable_address_balance_gas_payments = true;
4448 cfg.feature_flags.enable_authenticated_event_streams = true;
4449 cfg.feature_flags.enable_object_funds_withdraw = true;
4450 }
4451 }
4452 107 => {
4453 cfg.feature_flags
4454 .consensus_skip_gced_blocks_in_direct_finalization = true;
4455
4456 if in_integration_test() {
4458 cfg.consensus_gc_depth = Some(6);
4459 cfg.consensus_max_num_transactions_in_block = Some(8);
4460 }
4461 }
4462 108 => {
4463 cfg.feature_flags.gas_rounding_halve_digits = true;
4464 cfg.feature_flags.flexible_tx_context_positions = true;
4465 cfg.feature_flags.disable_entry_point_signature_check = true;
4466
4467 if chain != Chain::Mainnet {
4468 cfg.feature_flags.address_aliases = true;
4469
4470 cfg.feature_flags.enable_accumulators = true;
4471 cfg.feature_flags.enable_address_balance_gas_payments = true;
4472 }
4473
4474 cfg.feature_flags.enable_poseidon = true;
4475 }
4476 109 => {
4477 cfg.binary_variant_handles = Some(1024);
4478 cfg.binary_variant_instantiation_handles = Some(1024);
4479 cfg.feature_flags.restrict_hot_or_not_entry_functions = true;
4480 }
4481 110 => {
4482 cfg.feature_flags
4483 .enable_nitro_attestation_all_nonzero_pcrs_parsing = true;
4484 cfg.feature_flags
4485 .enable_nitro_attestation_always_include_required_pcrs_parsing = true;
4486 if chain != Chain::Mainnet && chain != Chain::Testnet {
4487 cfg.feature_flags.split_checkpoints_in_consensus_handler = true;
4488 }
4489 cfg.feature_flags.validate_zklogin_public_identifier = true;
4490 cfg.feature_flags.fix_checkpoint_signature_mapping = true;
4491 cfg.feature_flags
4492 .consensus_always_accept_system_transactions = true;
4493 if chain != Chain::Mainnet {
4494 cfg.feature_flags.enable_object_funds_withdraw = true;
4495 }
4496 }
4497 111 => {
4498 cfg.feature_flags.validator_metadata_verify_v2 = true;
4499 }
4500 112 => {
4501 cfg.group_ops_ristretto_decode_scalar_cost = Some(7);
4502 cfg.group_ops_ristretto_decode_point_cost = Some(200);
4503 cfg.group_ops_ristretto_scalar_add_cost = Some(10);
4504 cfg.group_ops_ristretto_point_add_cost = Some(500);
4505 cfg.group_ops_ristretto_scalar_sub_cost = Some(10);
4506 cfg.group_ops_ristretto_point_sub_cost = Some(500);
4507 cfg.group_ops_ristretto_scalar_mul_cost = Some(11);
4508 cfg.group_ops_ristretto_point_mul_cost = Some(1200);
4509 cfg.group_ops_ristretto_scalar_div_cost = Some(151);
4510 cfg.group_ops_ristretto_point_div_cost = Some(2500);
4511
4512 if chain != Chain::Mainnet && chain != Chain::Testnet {
4513 cfg.feature_flags.enable_ristretto255_group_ops = true;
4514 }
4515 }
4516 113 => {
4517 cfg.feature_flags.address_balance_gas_check_rgp_at_signing = true;
4518 if chain != Chain::Mainnet && chain != Chain::Testnet {
4519 cfg.feature_flags.defer_unpaid_amplification = true;
4520 }
4521 }
4522 114 => {
4523 cfg.feature_flags.randomize_checkpoint_tx_limit_in_tests = true;
4524 cfg.feature_flags.address_balance_gas_reject_gas_coin_arg = true;
4525 if chain != Chain::Mainnet {
4526 cfg.feature_flags.split_checkpoints_in_consensus_handler = true;
4527 cfg.feature_flags.enable_authenticated_event_streams = true;
4528 cfg.feature_flags
4529 .include_checkpoint_artifacts_digest_in_summary = true;
4530 }
4531 }
4532 115 => {
4533 cfg.feature_flags.normalize_depth_formula = true;
4534 }
4535 116 => {
4536 cfg.feature_flags.gasless_transaction_drop_safety = true;
4537 cfg.feature_flags.address_aliases = true;
4538 cfg.feature_flags.relax_valid_during_for_owned_inputs = true;
4539 cfg.feature_flags.defer_unpaid_amplification = false;
4541 cfg.feature_flags.enable_display_registry = true;
4542 }
4543 117 => {}
4544 118 => {
4545 cfg.feature_flags.use_coin_party_owner = true;
4546 }
4547 119 => {
4548 cfg.execution_version = Some(4);
4550 cfg.feature_flags.address_balance_gas_reject_gas_coin_arg = false;
4551 cfg.feature_flags.merge_randomness_into_checkpoint = true;
4552 if chain != Chain::Mainnet {
4553 cfg.feature_flags.enable_gasless = true;
4554 cfg.gasless_max_computation_units = Some(50_000);
4555 cfg.gasless_allowed_token_types = Some(vec![]);
4556 cfg.feature_flags.enable_coin_reservation_obj_refs = true;
4557 cfg.feature_flags
4558 .convert_withdrawal_compatibility_ptb_arguments = true;
4559 }
4560 cfg.gasless_max_unused_inputs = Some(1);
4561 cfg.gasless_max_pure_input_bytes = Some(32);
4562 if chain == Chain::Testnet {
4563 cfg.gasless_allowed_token_types = Some(vec![(TESTNET_USDC.to_string(), 0)]);
4564 }
4565 cfg.transfer_receive_object_cost_per_byte = Some(1);
4566 cfg.transfer_receive_object_type_cost_per_byte = Some(2);
4567 }
4568 120 => {
4569 cfg.feature_flags.disallow_jump_orphans = true;
4570 }
4571 121 => {
4572 if chain != Chain::Mainnet {
4574 cfg.feature_flags.defer_unpaid_amplification = true;
4575 cfg.gasless_max_tps = Some(50);
4576 }
4577 cfg.feature_flags
4578 .early_return_receive_object_mismatched_type = true;
4579 }
4580 122 => {
4581 cfg.feature_flags.defer_unpaid_amplification = true;
4583 cfg.verify_bulletproofs_ristretto255_base_cost = Some(30000);
4585 cfg.verify_bulletproofs_ristretto255_cost_per_bit_and_commitment = Some(6500);
4586 if chain != Chain::Mainnet && chain != Chain::Testnet {
4587 cfg.feature_flags.enable_verify_bulletproofs_ristretto255 = true;
4588 }
4589 cfg.feature_flags.gasless_verify_remaining_balance = true;
4590 cfg.include_special_package_amendments = match chain {
4591 Chain::Mainnet => Some(MAINNET_LINKAGE_AMENDMENTS.clone()),
4592 Chain::Testnet => Some(TESTNET_LINKAGE_AMENDMENTS.clone()),
4593 Chain::Unknown => None,
4594 };
4595 cfg.gasless_max_tx_size_bytes = Some(16 * 1024);
4596 cfg.gasless_max_tps = Some(300);
4597 cfg.gasless_max_computation_units = Some(5_000);
4598 }
4599 123 => {
4600 cfg.gas_model_version = Some(13);
4601 }
4602 124 => {
4603 if chain != Chain::Mainnet && chain != Chain::Testnet {
4604 cfg.feature_flags.timestamp_based_epoch_close = true;
4605 }
4606 cfg.gas_model_version = Some(14);
4607 cfg.feature_flags.limit_groth16_pvk_inputs = true;
4608
4609 cfg.feature_flags.enable_accumulators = true;
4615 cfg.feature_flags.enable_address_balance_gas_payments = true;
4616 cfg.feature_flags.enable_authenticated_event_streams = true;
4617 cfg.feature_flags.enable_coin_reservation_obj_refs = true;
4618 cfg.feature_flags.enable_object_funds_withdraw = true;
4619 cfg.feature_flags
4620 .convert_withdrawal_compatibility_ptb_arguments = true;
4621 cfg.feature_flags.split_checkpoints_in_consensus_handler = true;
4622 cfg.feature_flags
4623 .include_checkpoint_artifacts_digest_in_summary = true;
4624 cfg.feature_flags.enable_gasless = true;
4625
4626 if chain == Chain::Mainnet {
4631 cfg.gasless_allowed_token_types = Some(vec![
4632 (MAINNET_USDC.to_string(), 10_000),
4633 (MAINNET_USDSUI.to_string(), 10_000),
4634 (MAINNET_SUI_USDE.to_string(), 10_000),
4635 (MAINNET_USDY.to_string(), 10_000),
4636 (MAINNET_FDUSD.to_string(), 10_000),
4637 (MAINNET_AUSD.to_string(), 10_000),
4638 (MAINNET_USDB.to_string(), 10_000),
4639 ]);
4640 }
4641 }
4642 125 => {
4643 cfg.feature_flags.granular_post_execution_checks = true;
4644 if chain != Chain::Mainnet {
4645 cfg.feature_flags.timestamp_based_epoch_close = true;
4646 }
4647 }
4648 126 => {
4649 cfg.feature_flags.early_exit_on_iffw = true;
4650 }
4651 127 => {
4652 cfg.feature_flags.always_advance_dkg_to_resolution = true;
4653
4654 cfg.verify_bulletproofs_ristretto255_base_cost = Some(23866);
4655 cfg.verify_bulletproofs_ristretto255_cost_per_bit_and_commitment = Some(1324);
4656 cfg.group_ops_ristretto_decode_scalar_cost = Some(5);
4657 cfg.group_ops_ristretto_decode_point_cost = Some(216);
4658 cfg.group_ops_ristretto_scalar_add_cost = Some(2);
4659 cfg.group_ops_ristretto_point_add_cost = Some(8);
4660 cfg.group_ops_ristretto_scalar_sub_cost = Some(2);
4661 cfg.group_ops_ristretto_point_sub_cost = Some(8);
4662 cfg.group_ops_ristretto_scalar_mul_cost = Some(5);
4663 cfg.group_ops_ristretto_point_mul_cost = Some(1763);
4664 cfg.group_ops_ristretto_scalar_div_cost = Some(557);
4665 cfg.group_ops_ristretto_point_div_cost = Some(2244);
4666
4667 if chain != Chain::Mainnet {
4668 cfg.feature_flags.enable_ristretto255_group_ops = true;
4669 cfg.feature_flags.enable_verify_bulletproofs_ristretto255 = true;
4670 }
4671
4672 cfg.feature_flags.timestamp_based_epoch_close = true;
4673 }
4674 128 => {
4675 cfg.max_generic_instantiation_type_nodes_per_function = Some(10_000);
4676 cfg.max_generic_instantiation_type_nodes_per_module = Some(500_000);
4677 cfg.binary_enum_defs = Some(200);
4678 cfg.binary_enum_def_instantiations = Some(100);
4679 }
4680 129 => {
4681 cfg.feature_flags.enable_unified_linkage = true;
4682 }
4683 130 => {
4684 cfg.feature_flags.record_net_unsettled_object_withdraws = true;
4685 cfg.feature_flags.enable_init_on_upgrade = true;
4686 cfg.epoch_close_deadline_ms = Some(120_000);
4687 cfg.scratch_add_cost_base = Some(13);
4688 cfg.scratch_read_cost_base = Some(13);
4689 cfg.scratch_read_value_cost = Some(1);
4690 cfg.scratch_remove_cost_base = Some(13);
4691 cfg.scratch_exists_cost_base = Some(13);
4692 cfg.scratch_exists_with_type_cost_base = Some(13);
4693 cfg.scratch_exists_with_type_type_cost = Some(1);
4694 let max_commands = cfg.max_programmable_tx_commands() as u64;
4695 cfg.max_scratch_pad_size = Some(16 * max_commands);
4696 if chain != Chain::Mainnet && chain != Chain::Testnet {
4698 cfg.feature_flags.zklogin_circuit_mode = 1;
4699 }
4700 }
4701 131 => {
4702 cfg.feature_flags.share_transaction_deny_config_in_consensus = true;
4703 cfg.feature_flags.framework_tx_context_mut_restrictions = true;
4704 }
4705 132 => {
4706 if chain != Chain::Mainnet && chain != Chain::Testnet {
4707 cfg.feature_flags.defer_owned_object_double_spend = true;
4708 cfg.feature_flags.create_forwarding_address_registry = true;
4709 }
4710 cfg.object_record_new_uid_from_hash_cost_base = Some(1);
4711 cfg.feature_flags
4712 .enable_order_independent_upgrade_init_linkage = true;
4713 }
4714 133 => {
4715 cfg.feature_flags
4716 .include_function_signatures_in_instantiation_limits = true;
4717 cfg.max_accumulator_type_nodes = Some(16);
4718 }
4719 134 => {
4720 if chain != Chain::Mainnet {
4727 cfg.package_original_package_id_impl_cost_base = Some(52);
4728 let package_read_cost_per_byte = cfg.obj_access_cost_read_per_byte();
4729 cfg.package_original_package_id_impl_cost_per_byte =
4730 Some(package_read_cost_per_byte);
4731
4732 cfg.consensus_max_transactions_in_block_bytes = Some(288 * 1024);
4733 cfg.consensus_max_num_transactions_in_block = Some(128);
4734 }
4735
4736 if chain == Chain::Mainnet {
4737 cfg.feature_flags.defer_unpaid_amplification = false;
4738 }
4739 }
4740 135 => {
4741 cfg.package_original_package_id_impl_cost_base = Some(52);
4744 let package_read_cost_per_byte = cfg.obj_access_cost_read_per_byte();
4745 cfg.package_original_package_id_impl_cost_per_byte =
4746 Some(package_read_cost_per_byte);
4747
4748 cfg.consensus_max_transactions_in_block_bytes = Some(288 * 1024);
4749 cfg.consensus_max_num_transactions_in_block = Some(128);
4750
4751 cfg.feature_flags.defer_unpaid_amplification = false;
4752 }
4753 136 => {
4754 cfg.feature_flags.ptb_tx_context_restrictions = true;
4755
4756 cfg.translation_per_live_reference_charge = Some(1);
4757 cfg.max_ptb_live_references = Some(64);
4758 cfg.max_ptb_returned_references = Some(16);
4759 cfg.max_ptb_total_returned_references = Some(256);
4760
4761 if chain != Chain::Mainnet && chain != Chain::Testnet {
4762 cfg.feature_flags.allowed_proposers = true;
4763 }
4764 cfg.feature_flags.harden_linkage_consistency = true;
4765
4766 cfg.package_arena_size_in_bytes = Some(10_000_000);
4767 }
4768 137 => {
4769 cfg.verify_bulletproofs_ristretto255_cost_per_bit_and_commitment = Some(621);
4770 cfg.max_bulletproofs_total_bits = Some(1024);
4771
4772 if chain != Chain::Mainnet {
4773 cfg.feature_flags.enable_allowances = true;
4774 }
4775 cfg.feature_flags.fix_ptb_generated_reads = true;
4776 cfg.feature_flags.charge_ld_const_abstract_size = true;
4777 if chain != Chain::Mainnet && chain != Chain::Testnet {
4778 cfg.feature_flags.check_object_funds_withdraw_in_execution = true;
4779 }
4780 cfg.reserve_object_funds_for_withdrawal_cost_base = Some(52);
4781 cfg.reserve_object_funds_for_withdrawal_cold_read_cost = Some(184);
4784
4785 cfg.feature_flags.allowed_proposers = true;
4786
4787 cfg.feature_flags.validate_ptb_argument_indices = true;
4788 cfg.feature_flags.memory_safety_invariant_check_v2 = true;
4789 }
4790 138 => {
4791 cfg.gas_model_version = Some(15);
4792 cfg.feature_flags.enable_allowances = true;
4793 if chain != Chain::Mainnet {
4794 cfg.feature_flags.check_object_funds_withdraw_in_execution = true;
4795 cfg.feature_flags.disable_effects_tx_dependencies = true;
4796 }
4797 cfg.feature_flags.merge_colliding_deferrals = true;
4798 }
4799 _ => panic!("unsupported version {:?}", version),
4810 }
4811 }
4812
4813 cfg
4814 }
4815
4816 pub fn apply_seeded_test_overrides(&mut self, seed: &[u8; 32]) {
4817 if !self.feature_flags.randomize_checkpoint_tx_limit_in_tests
4818 || !self.feature_flags.split_checkpoints_in_consensus_handler
4819 {
4820 return;
4821 }
4822
4823 if !mysten_common::in_test_configuration() {
4824 return;
4825 }
4826
4827 use rand::{Rng, SeedableRng, rngs::StdRng};
4828 let mut rng = StdRng::from_seed(*seed);
4829 let max_txns = rng.gen_range(10..=100u64);
4830 info!("seeded test override: max_transactions_per_checkpoint = {max_txns}");
4831 self.max_transactions_per_checkpoint = Some(max_txns);
4832 }
4833
4834 pub fn verifier_config(&self, signing_limits: Option<(usize, usize, usize)>) -> VerifierConfig {
4840 let (
4841 max_back_edges_per_function,
4842 max_back_edges_per_module,
4843 sanity_check_with_regex_reference_safety,
4844 ) = if let Some((
4845 max_back_edges_per_function,
4846 max_back_edges_per_module,
4847 sanity_check_with_regex_reference_safety,
4848 )) = signing_limits
4849 {
4850 (
4851 Some(max_back_edges_per_function),
4852 Some(max_back_edges_per_module),
4853 Some(sanity_check_with_regex_reference_safety),
4854 )
4855 } else {
4856 (None, None, None)
4857 };
4858
4859 let additional_borrow_checks = if signing_limits.is_some() {
4860 true
4862 } else {
4863 self.additional_borrow_checks()
4864 };
4865 let deprecate_global_storage_ops = if signing_limits.is_some() {
4866 true
4868 } else {
4869 self.deprecate_global_storage_ops()
4870 };
4871
4872 VerifierConfig {
4873 max_loop_depth: Some(self.max_loop_depth() as usize),
4874 max_generic_instantiation_length: Some(self.max_generic_instantiation_length() as usize),
4875 max_function_parameters: Some(self.max_function_parameters() as usize),
4876 max_basic_blocks: Some(self.max_basic_blocks() as usize),
4877 max_value_stack_size: self.max_value_stack_size() as usize,
4878 max_type_nodes: Some(self.max_type_nodes() as usize),
4879 max_generic_instantiation_type_nodes_per_function: self
4880 .max_generic_instantiation_type_nodes_per_function_as_option()
4881 .map(|v| v as usize),
4882 max_generic_instantiation_type_nodes_per_module: self
4883 .max_generic_instantiation_type_nodes_per_module_as_option()
4884 .map(|v| v as usize),
4885 include_function_signatures_in_instantiation_limits: self
4886 .include_function_signatures_in_instantiation_limits(),
4887 max_push_size: Some(self.max_push_size() as usize),
4888 max_dependency_depth: Some(self.max_dependency_depth() as usize),
4889 max_fields_in_struct: Some(self.max_fields_in_struct() as usize),
4890 max_function_definitions: Some(self.max_function_definitions() as usize),
4891 max_data_definitions: Some(self.max_struct_definitions() as usize),
4892 max_constant_vector_len: Some(self.max_move_vector_len()),
4893 max_back_edges_per_function,
4894 max_back_edges_per_module,
4895 max_basic_blocks_in_script: None,
4896 max_identifier_len: self.max_move_identifier_len_as_option(), disallow_self_identifier: self.feature_flags.disallow_self_identifier,
4898 allow_receiving_object_id: self.allow_receiving_object_id(),
4899 reject_mutable_random_on_entry_functions: self
4900 .reject_mutable_random_on_entry_functions(),
4901 bytecode_version: self.move_binary_format_version(),
4902 max_variants_in_enum: self.max_move_enum_variants_as_option(),
4903 additional_borrow_checks,
4904 better_loader_errors: self.better_loader_errors(),
4905 private_generics_verifier_v2: self.private_generics_verifier_v2(),
4906 sanity_check_with_regex_reference_safety: sanity_check_with_regex_reference_safety
4907 .map(|limit| limit as u128),
4908 deprecate_global_storage_ops,
4909 disable_entry_point_signature_check: self.disable_entry_point_signature_check(),
4910 switch_to_regex_reference_safety: false,
4911 framework_tx_context_mut_restrictions: self.framework_tx_context_mut_restrictions(),
4912 disallow_jump_orphans: self.disallow_jump_orphans(),
4913 }
4914 }
4915
4916 pub fn binary_config(
4917 &self,
4918 override_deprecate_global_storage_ops_during_deserialization: Option<bool>,
4919 ) -> BinaryConfig {
4920 let deprecate_global_storage_ops =
4921 override_deprecate_global_storage_ops_during_deserialization
4922 .unwrap_or_else(|| self.deprecate_global_storage_ops());
4923 BinaryConfig::new(
4924 self.move_binary_format_version(),
4925 self.min_move_binary_format_version_as_option()
4926 .unwrap_or(VERSION_1),
4927 self.no_extraneous_module_bytes(),
4928 deprecate_global_storage_ops,
4929 TableConfig {
4930 module_handles: self.binary_module_handles_as_option().unwrap_or(u16::MAX),
4931 datatype_handles: self.binary_struct_handles_as_option().unwrap_or(u16::MAX),
4932 function_handles: self.binary_function_handles_as_option().unwrap_or(u16::MAX),
4933 function_instantiations: self
4934 .binary_function_instantiations_as_option()
4935 .unwrap_or(u16::MAX),
4936 signatures: self.binary_signatures_as_option().unwrap_or(u16::MAX),
4937 constant_pool: self.binary_constant_pool_as_option().unwrap_or(u16::MAX),
4938 identifiers: self.binary_identifiers_as_option().unwrap_or(u16::MAX),
4939 address_identifiers: self
4940 .binary_address_identifiers_as_option()
4941 .unwrap_or(u16::MAX),
4942 struct_defs: self.binary_struct_defs_as_option().unwrap_or(u16::MAX),
4943 struct_def_instantiations: self
4944 .binary_struct_def_instantiations_as_option()
4945 .unwrap_or(u16::MAX),
4946 function_defs: self.binary_function_defs_as_option().unwrap_or(u16::MAX),
4947 field_handles: self.binary_field_handles_as_option().unwrap_or(u16::MAX),
4948 field_instantiations: self
4949 .binary_field_instantiations_as_option()
4950 .unwrap_or(u16::MAX),
4951 friend_decls: self.binary_friend_decls_as_option().unwrap_or(u16::MAX),
4952 enum_defs: self.binary_enum_defs_as_option().unwrap_or(u16::MAX),
4953 enum_def_instantiations: self
4954 .binary_enum_def_instantiations_as_option()
4955 .unwrap_or(u16::MAX),
4956 variant_handles: self.binary_variant_handles_as_option().unwrap_or(u16::MAX),
4957 variant_instantiation_handles: self
4958 .binary_variant_instantiation_handles_as_option()
4959 .unwrap_or(u16::MAX),
4960 },
4961 )
4962 }
4963
4964 pub fn apply_overrides_for_testing(
4968 override_fn: impl Fn(ProtocolVersion, Self) -> Self + Send + Sync + 'static,
4969 ) -> OverrideGuard {
4970 let mut cur = CONFIG_OVERRIDE.lock().unwrap();
4971 assert!(cur.is_none(), "config override already present");
4972 *cur = Some(Box::new(override_fn));
4973 OverrideGuard
4974 }
4975
4976 fn apply_config_override(version: ProtocolVersion, mut ret: Self) -> Self {
4977 if let Some(override_fn) = CONFIG_OVERRIDE.lock().unwrap().as_ref() {
4978 warn!(
4979 "overriding ProtocolConfig settings with custom settings (you should not see this log outside of tests)"
4980 );
4981 ret = override_fn(version, ret);
4982 }
4983 ret
4984 }
4985}
4986
4987impl ProtocolConfig {
4991 pub fn set_execution_version_for_testing(&mut self, val: u64) {
4995 let current = self.execution_version.unwrap_or(0);
4996 assert!(
4997 val >= current,
4998 "cannot downgrade execution_version from {current} to {val}: running an old \
4999 executor against a newer protocol config/framework is unsupported. To test \
5000 frozen executor behavior, start from the last protocol version of that executor \
5001 instead, so genesis loads the matching framework snapshot (see \
5002 test_address_balance_gas_v3_accumulator_sign)."
5003 );
5004 self.execution_version = Some(val);
5005 }
5006
5007 pub fn set_zklogin_circuit_mode_for_testing(&mut self, val: u64) {
5010 self.feature_flags.zklogin_circuit_mode = val
5011 }
5012
5013 pub fn set_per_object_congestion_control_mode_for_testing(
5014 &mut self,
5015 val: PerObjectCongestionControlMode,
5016 ) {
5017 self.feature_flags.per_object_congestion_control_mode = val;
5018 }
5019
5020 pub fn set_consensus_choice_for_testing(&mut self, val: ConsensusChoice) {
5021 self.feature_flags.consensus_choice = val;
5022 }
5023
5024 pub fn set_consensus_network_for_testing(&mut self, val: ConsensusNetwork) {
5025 self.feature_flags.consensus_network = val;
5026 }
5027
5028 pub fn set_zklogin_max_epoch_upper_bound_delta_for_testing(&mut self, val: Option<u64>) {
5029 self.feature_flags.zklogin_max_epoch_upper_bound_delta = val
5030 }
5031
5032 pub fn set_mysticeti_num_leaders_per_round_for_testing(&mut self, val: Option<usize>) {
5033 self.feature_flags.mysticeti_num_leaders_per_round = val;
5034 }
5035
5036 pub fn disable_accumulators_for_testing(&mut self) {
5037 self.feature_flags.enable_accumulators = false;
5038 self.feature_flags.enable_address_balance_gas_payments = false;
5039 }
5040
5041 pub fn enable_coin_reservation_for_testing(&mut self) {
5042 self.feature_flags.enable_coin_reservation_obj_refs = true;
5043 self.feature_flags
5044 .convert_withdrawal_compatibility_ptb_arguments = true;
5045 self.execution_version = Some(self.execution_version.map_or(4, |v| v.max(4)));
5048 }
5049
5050 pub fn disable_coin_reservation_for_testing(&mut self) {
5051 self.feature_flags.enable_coin_reservation_obj_refs = false;
5052 self.feature_flags
5053 .convert_withdrawal_compatibility_ptb_arguments = false;
5054 }
5055
5056 pub fn enable_address_balance_gas_payments_for_testing(&mut self) {
5057 self.feature_flags.enable_accumulators = true;
5058 self.feature_flags.allow_private_accumulator_entrypoints = true;
5059 self.feature_flags.enable_address_balance_gas_payments = true;
5060 self.feature_flags.address_balance_gas_check_rgp_at_signing = true;
5061 self.feature_flags.address_balance_gas_reject_gas_coin_arg = false;
5062 self.execution_version = Some(self.execution_version.map_or(4, |v| v.max(4)))
5063 }
5064
5065 pub fn enable_gasless_for_testing(&mut self) {
5066 self.enable_address_balance_gas_payments_for_testing();
5067 self.feature_flags.enable_gasless = true;
5068 self.feature_flags.gasless_verify_remaining_balance = true;
5069 self.gasless_max_computation_units = Some(5_000);
5070 self.gasless_allowed_token_types = Some(vec![]);
5071 self.gasless_max_tps = Some(1000);
5072 self.gasless_max_tx_size_bytes = Some(16 * 1024);
5073 }
5074
5075 pub fn disable_gasless_for_testing(&mut self) {
5076 self.feature_flags.enable_gasless = false;
5077 self.gasless_max_computation_units = None;
5078 self.gasless_allowed_token_types = None;
5079 }
5080
5081 pub fn enable_authenticated_event_streams_for_testing(&mut self) {
5082 self.feature_flags.enable_accumulators = true;
5083 self.feature_flags.enable_authenticated_event_streams = true;
5084 self.feature_flags
5085 .include_checkpoint_artifacts_digest_in_summary = true;
5086 self.feature_flags.split_checkpoints_in_consensus_handler = true;
5087 }
5088}
5089
5090type OverrideFn = dyn Fn(ProtocolVersion, ProtocolConfig) -> ProtocolConfig + Send + Sync;
5091
5092static CONFIG_OVERRIDE: Mutex<Option<Box<OverrideFn>>> = Mutex::new(None);
5093
5094#[must_use]
5095pub struct OverrideGuard;
5096
5097impl Drop for OverrideGuard {
5098 fn drop(&mut self) {
5099 info!("restoring override fn");
5100 *CONFIG_OVERRIDE.lock().unwrap() = None;
5101 }
5102}
5103
5104#[derive(PartialEq, Eq)]
5107pub enum LimitThresholdCrossed {
5108 None,
5109 Soft(u128, u128),
5110 Hard(u128, u128),
5111}
5112
5113pub fn check_limit_in_range<T: Into<V>, U: Into<V>, V: PartialOrd + Into<u128>>(
5116 x: T,
5117 soft_limit: U,
5118 hard_limit: V,
5119) -> LimitThresholdCrossed {
5120 let x: V = x.into();
5121 let soft_limit: V = soft_limit.into();
5122
5123 debug_assert!(soft_limit <= hard_limit);
5124
5125 if x >= hard_limit {
5128 LimitThresholdCrossed::Hard(x.into(), hard_limit.into())
5129 } else if x < soft_limit {
5130 LimitThresholdCrossed::None
5131 } else {
5132 LimitThresholdCrossed::Soft(x.into(), soft_limit.into())
5133 }
5134}
5135
5136#[macro_export]
5137macro_rules! check_limit {
5138 ($x:expr, $hard:expr) => {
5139 check_limit!($x, $hard, $hard)
5140 };
5141 ($x:expr, $soft:expr, $hard:expr) => {
5142 check_limit_in_range($x as u64, $soft, $hard)
5143 };
5144}
5145
5146#[macro_export]
5150macro_rules! check_limit_by_meter {
5151 ($is_metered:expr, $x:expr, $metered_limit:expr, $unmetered_hard_limit:expr, $metric:expr) => {{
5152 let (h, metered_str) = if $is_metered {
5154 ($metered_limit, "metered")
5155 } else {
5156 ($unmetered_hard_limit, "unmetered")
5158 };
5159 use sui_protocol_config::check_limit_in_range;
5160 let result = check_limit_in_range($x as u64, $metered_limit, h);
5161 match result {
5162 LimitThresholdCrossed::None => {}
5163 LimitThresholdCrossed::Soft(_, _) => {
5164 $metric.with_label_values(&[metered_str, "soft"]).inc();
5165 }
5166 LimitThresholdCrossed::Hard(_, _) => {
5167 $metric.with_label_values(&[metered_str, "hard"]).inc();
5168 }
5169 };
5170 result
5171 }};
5172}
5173
5174pub type Amendments = BTreeMap<AccountAddress, BTreeMap<AccountAddress, AccountAddress>>;
5177
5178static MAINNET_LINKAGE_AMENDMENTS: LazyLock<Arc<Amendments>> =
5179 LazyLock::new(|| parse_amendments(include_str!("mainnet_amendments.json")));
5180
5181static TESTNET_LINKAGE_AMENDMENTS: LazyLock<Arc<Amendments>> =
5182 LazyLock::new(|| parse_amendments(include_str!("testnet_amendments.json")));
5183
5184fn parse_amendments(json: &str) -> Arc<Amendments> {
5185 #[derive(serde::Deserialize)]
5186 struct AmendmentEntry {
5187 root: String,
5188 deps: Vec<DepEntry>,
5189 }
5190
5191 #[derive(serde::Deserialize)]
5192 struct DepEntry {
5193 original_id: String,
5194 version_id: String,
5195 }
5196
5197 let entries: Vec<AmendmentEntry> =
5198 serde_json::from_str(json).expect("Failed to parse amendments JSON");
5199 let mut amendments = BTreeMap::new();
5200 for entry in entries {
5201 let root_id = AccountAddress::from_hex_literal(&entry.root).unwrap();
5202 let mut dep_ids = BTreeMap::new();
5203 for dep in entry.deps {
5204 let orig_id = AccountAddress::from_hex_literal(&dep.original_id).unwrap();
5205 let upgraded_id = AccountAddress::from_hex_literal(&dep.version_id).unwrap();
5206 assert!(
5207 dep_ids.insert(orig_id, upgraded_id).is_none(),
5208 "Duplicate original ID in amendments table"
5209 );
5210 }
5211 assert!(
5212 amendments.insert(root_id, dep_ids).is_none(),
5213 "Duplicate root ID in amendments table"
5214 );
5215 }
5216 Arc::new(amendments)
5217}
5218
5219#[cfg(all(test, not(msim)))]
5220mod test {
5221 use insta::assert_yaml_snapshot;
5222
5223 use super::*;
5224
5225 #[test]
5226 fn snapshot_tests() {
5227 println!("\n============================================================================");
5228 println!("! !");
5229 println!("! IMPORTANT: never update snapshots from this test. only add new versions! !");
5230 println!("! !");
5231 println!("============================================================================\n");
5232 for chain_id in &[Chain::Unknown, Chain::Mainnet, Chain::Testnet] {
5233 let chain_str = match chain_id {
5237 Chain::Unknown => "".to_string(),
5238 _ => format!("{:?}_", chain_id),
5239 };
5240 for i in MIN_PROTOCOL_VERSION..=MAX_PROTOCOL_VERSION {
5241 let cur = ProtocolVersion::new(i);
5242 assert_yaml_snapshot!(
5243 format!("{}version_{}", chain_str, cur.as_u64()),
5244 ProtocolConfig::get_for_version(cur, *chain_id)
5245 );
5246 }
5247 }
5248 }
5249
5250 #[test]
5251 fn test_getters() {
5252 let prot: ProtocolConfig =
5253 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5254 assert_eq!(
5255 prot.max_arguments(),
5256 prot.max_arguments_as_option().unwrap()
5257 );
5258 }
5259
5260 #[test]
5261 fn test_setters() {
5262 let mut prot: ProtocolConfig =
5263 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5264 prot.set_max_arguments_for_testing(123);
5265 assert_eq!(prot.max_arguments(), 123);
5266
5267 prot.set_max_arguments_from_str_for_testing("321".to_string());
5268 assert_eq!(prot.max_arguments(), 321);
5269
5270 prot.disable_max_arguments_for_testing();
5271 assert_eq!(prot.max_arguments_as_option(), None);
5272
5273 prot.set_attr_for_testing("max_arguments".to_string(), "456".to_string());
5274 assert_eq!(prot.max_arguments(), 456);
5275 }
5276
5277 #[test]
5278 fn test_execution_version_setter_allows_upgrade() {
5279 let mut prot = ProtocolConfig::get_for_max_version_UNSAFE();
5280 let current = prot.execution_version();
5281 prot.set_execution_version_for_testing(current);
5282 prot.set_execution_version_for_testing(current + 1);
5283 assert_eq!(prot.execution_version(), current + 1);
5284 }
5285
5286 #[test]
5287 #[should_panic(expected = "cannot downgrade execution_version")]
5288 fn test_execution_version_setter_panics_on_downgrade() {
5289 let mut prot = ProtocolConfig::get_for_max_version_UNSAFE();
5290 let current = prot.execution_version();
5291 prot.set_execution_version_for_testing(current - 1);
5292 }
5293
5294 #[test]
5295 fn test_feature_flag_setter_by_string() {
5296 let mut prot: ProtocolConfig =
5297 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5298 assert!(!prot.zklogin_auth());
5299 prot.set_feature_flag_for_testing("zklogin_auth".to_string(), true);
5300 assert!(prot.zklogin_auth());
5301 prot.set_feature_flag_for_testing("zklogin_auth".to_string(), false);
5302 assert!(!prot.zklogin_auth());
5303 }
5304
5305 #[test]
5306 #[should_panic(expected = "unknown feature flag")]
5307 fn test_feature_flag_setter_unknown_flag() {
5308 let mut prot: ProtocolConfig =
5309 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5310 prot.set_feature_flag_for_testing("some random string".to_string(), true);
5311 }
5312
5313 #[test]
5314 fn test_get_for_version_if_supported_applies_test_overrides() {
5315 let before =
5316 ProtocolConfig::get_for_version_if_supported(ProtocolVersion::new(1), Chain::Unknown)
5317 .unwrap();
5318
5319 assert!(!before.enable_coin_reservation_obj_refs());
5320
5321 let _guard = ProtocolConfig::apply_overrides_for_testing(|_, mut cfg| {
5322 cfg.enable_coin_reservation_for_testing();
5323 cfg
5324 });
5325
5326 let after =
5327 ProtocolConfig::get_for_version_if_supported(ProtocolVersion::new(1), Chain::Unknown)
5328 .unwrap();
5329
5330 assert!(after.enable_coin_reservation_obj_refs());
5331 }
5332
5333 #[test]
5334 #[should_panic(expected = "unsupported version")]
5335 fn max_version_test() {
5336 let _ = ProtocolConfig::get_for_version_impl(
5339 ProtocolVersion::new(MAX_PROTOCOL_VERSION + 1),
5340 Chain::Unknown,
5341 );
5342 }
5343
5344 #[test]
5345 fn lookup_by_string_test() {
5346 let prot: ProtocolConfig =
5347 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5348 assert!(prot.lookup_attr("some random string".to_string()).is_none());
5350
5351 assert!(
5352 prot.lookup_attr("max_arguments".to_string())
5353 == Some(ProtocolConfigValue::u32(prot.max_arguments())),
5354 );
5355
5356 assert!(
5358 prot.lookup_attr("max_move_identifier_len".to_string())
5359 .is_none()
5360 );
5361
5362 let prot: ProtocolConfig =
5364 ProtocolConfig::get_for_version(ProtocolVersion::new(9), Chain::Unknown);
5365 assert!(
5366 prot.lookup_attr("max_move_identifier_len".to_string())
5367 == Some(ProtocolConfigValue::u64(prot.max_move_identifier_len()))
5368 );
5369
5370 let prot: ProtocolConfig =
5371 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5372 assert!(
5374 prot.attr_map()
5375 .get("max_move_identifier_len")
5376 .unwrap()
5377 .is_none()
5378 );
5379 assert!(
5381 prot.attr_map().get("max_arguments").unwrap()
5382 == &Some(ProtocolConfigValue::u32(prot.max_arguments()))
5383 );
5384
5385 let prot: ProtocolConfig =
5387 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5388 assert!(
5390 prot.feature_flags
5391 .lookup_attr("some random string".to_owned())
5392 .is_none()
5393 );
5394 assert!(
5395 !prot
5396 .feature_flags
5397 .attr_map()
5398 .contains_key("some random string")
5399 );
5400
5401 assert!(
5403 prot.feature_flags
5404 .lookup_attr("package_upgrades".to_owned())
5405 == Some(false)
5406 );
5407 assert!(
5408 prot.feature_flags
5409 .attr_map()
5410 .get("package_upgrades")
5411 .unwrap()
5412 == &false
5413 );
5414 let prot: ProtocolConfig =
5415 ProtocolConfig::get_for_version(ProtocolVersion::new(4), Chain::Unknown);
5416 assert!(
5418 prot.feature_flags
5419 .lookup_attr("package_upgrades".to_owned())
5420 == Some(true)
5421 );
5422 assert!(
5423 prot.feature_flags
5424 .attr_map()
5425 .get("package_upgrades")
5426 .unwrap()
5427 == &true
5428 );
5429 }
5430
5431 #[test]
5432 fn limit_range_fn_test() {
5433 let low = 100u32;
5434 let high = 10000u64;
5435
5436 assert!(check_limit!(1u8, low, high) == LimitThresholdCrossed::None);
5437 assert!(matches!(
5438 check_limit!(255u16, low, high),
5439 LimitThresholdCrossed::Soft(255u128, 100)
5440 ));
5441 assert!(matches!(
5447 check_limit!(2550000u64, low, high),
5448 LimitThresholdCrossed::Hard(2550000, 10000)
5449 ));
5450
5451 assert!(matches!(
5452 check_limit!(2550000u64, high, high),
5453 LimitThresholdCrossed::Hard(2550000, 10000)
5454 ));
5455
5456 assert!(matches!(
5457 check_limit!(1u8, high),
5458 LimitThresholdCrossed::None
5459 ));
5460
5461 assert!(check_limit!(255u16, high) == LimitThresholdCrossed::None);
5462
5463 assert!(matches!(
5464 check_limit!(2550000u64, high),
5465 LimitThresholdCrossed::Hard(2550000, 10000)
5466 ));
5467 }
5468
5469 #[test]
5470 fn linkage_amendments_load() {
5471 let mainnet = LazyLock::force(&MAINNET_LINKAGE_AMENDMENTS);
5472 let testnet = LazyLock::force(&TESTNET_LINKAGE_AMENDMENTS);
5473 assert!(!mainnet.is_empty(), "mainnet amendments must not be empty");
5474 assert!(!testnet.is_empty(), "testnet amendments must not be empty");
5475 }
5476
5477 #[test]
5478 fn render_scalar_fields_use_precision_safe_encoding() {
5479 use mysten_common::rpc_format::Unmetered;
5480
5481 let config = ProtocolConfig::get_for_max_version_UNSAFE();
5482 let rendered = config
5483 .render::<serde_json::Value>(&mut Unmetered)
5484 .expect("render should succeed");
5485
5486 let max_args = rendered
5487 .get("max_arguments")
5488 .expect("max_arguments set at max version");
5489 assert!(
5490 max_args.is_number(),
5491 "u32 should render as number, got {max_args:?}",
5492 );
5493
5494 let max_tx_size = rendered
5495 .get("max_tx_size_bytes")
5496 .expect("max_tx_size_bytes set at max version");
5497 assert!(
5498 max_tx_size.is_string(),
5499 "u64 should render as string, got {max_tx_size:?}",
5500 );
5501 }
5502
5503 #[test]
5504 fn render_includes_non_scalar_gasless_allowlist_as_json() {
5505 use mysten_common::rpc_format::Unmetered;
5506 use serde_json::json;
5507
5508 let mut config = ProtocolConfig::get_for_max_version_UNSAFE();
5509 config.set_gasless_allowed_token_types_for_testing(vec![
5510 ("0xa::usdc::USDC".to_string(), 10_000),
5511 ("0xb::usdt::USDT".to_string(), 0),
5512 ]);
5513
5514 let rendered = config
5515 .render::<serde_json::Value>(&mut Unmetered)
5516 .expect("render should succeed under Unmetered budget");
5517 let allowlist = rendered
5518 .get("gasless_allowed_token_types")
5519 .expect("entry should be present after the testing setter");
5520
5521 assert_eq!(
5524 allowlist,
5525 &json!([["0xa::usdc::USDC", "10000"], ["0xb::usdt::USDT", "0"],]),
5526 );
5527 }
5528
5529 #[test]
5530 fn render_targets_prost_value_for_grpc() {
5531 use mysten_common::rpc_format::Unmetered;
5532 use prost_types::value::Kind;
5533
5534 let mut config = ProtocolConfig::get_for_max_version_UNSAFE();
5535 config.set_gasless_allowed_token_types_for_testing(vec![(
5536 "0xa::usdc::USDC".to_string(),
5537 10_000,
5538 )]);
5539
5540 let rendered = config
5541 .render::<prost_types::Value>(&mut Unmetered)
5542 .expect("render to prost Value should succeed");
5543 let allowlist = rendered
5544 .get("gasless_allowed_token_types")
5545 .expect("entry should be present after the testing setter");
5546
5547 let Some(Kind::ListValue(outer)) = &allowlist.kind else {
5549 panic!(
5550 "expected ListValue at the top level, got {:?}",
5551 allowlist.kind
5552 );
5553 };
5554 assert_eq!(outer.values.len(), 1, "one allowlisted entry");
5555 let Some(Kind::ListValue(entry)) = &outer.values[0].kind else {
5556 panic!("expected each entry to be a ListValue");
5557 };
5558 assert_eq!(entry.values.len(), 2, "entry has (coin_type, amount)");
5559
5560 let Some(Kind::StringValue(coin_type)) = &entry.values[0].kind else {
5561 panic!("expected coin_type as StringValue");
5562 };
5563 assert_eq!(coin_type, "0xa::usdc::USDC");
5564
5565 let Some(Kind::StringValue(amount)) = &entry.values[1].kind else {
5567 panic!(
5568 "expected minimum_transfer_amount as StringValue (precision-safe u64); got {:?}",
5569 entry.values[1].kind,
5570 );
5571 };
5572 assert_eq!(amount, "10000");
5573 }
5574
5575 #[test]
5576 fn render_emits_null_for_unset_protocol_versions() {
5577 use mysten_common::rpc_format::Unmetered;
5578
5579 let config = ProtocolConfig::get_for_version(1.into(), Chain::Unknown);
5580 let rendered = config
5581 .render::<serde_json::Value>(&mut Unmetered)
5582 .expect("render should succeed");
5583 let entry = rendered
5587 .get("gasless_allowed_token_types")
5588 .expect("key should be present for every protocol version");
5589 assert!(
5590 entry.is_null(),
5591 "value should be null for pre-feature protocol version, got {entry:?}",
5592 );
5593 }
5594}