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)]
414pub struct ProtocolVersion(u64);
415
416impl ProtocolVersion {
417 pub const MIN: Self = Self(MIN_PROTOCOL_VERSION);
422
423 pub const MAX: Self = Self(MAX_PROTOCOL_VERSION);
424
425 #[cfg(not(msim))]
426 pub const MAX_ALLOWED: Self = Self::MAX;
427
428 #[cfg(msim)]
430 pub const MAX_ALLOWED: Self = Self(MAX_PROTOCOL_VERSION + 1);
431
432 pub fn new(v: u64) -> Self {
433 Self(v)
434 }
435
436 pub const fn as_u64(&self) -> u64 {
437 self.0
438 }
439
440 pub fn max() -> Self {
443 Self::MAX
444 }
445
446 pub fn prev(self) -> Self {
447 Self(self.0.checked_sub(1).unwrap())
448 }
449}
450
451impl From<u64> for ProtocolVersion {
452 fn from(v: u64) -> Self {
453 Self::new(v)
454 }
455}
456
457impl std::ops::Sub<u64> for ProtocolVersion {
458 type Output = Self;
459 fn sub(self, rhs: u64) -> Self::Output {
460 Self::new(self.0 - rhs)
461 }
462}
463
464impl std::ops::Add<u64> for ProtocolVersion {
465 type Output = Self;
466 fn add(self, rhs: u64) -> Self::Output {
467 Self::new(self.0 + rhs)
468 }
469}
470
471#[derive(
472 Clone, Serialize, Deserialize, Debug, Default, PartialEq, Copy, PartialOrd, Ord, Eq, ValueEnum,
473)]
474pub enum Chain {
475 Mainnet,
476 Testnet,
477 #[default]
478 Unknown,
479}
480
481impl Chain {
482 pub fn as_str(self) -> &'static str {
483 match self {
484 Chain::Mainnet => "mainnet",
485 Chain::Testnet => "testnet",
486 Chain::Unknown => "unknown",
487 }
488 }
489}
490
491pub struct Error(pub String);
492
493#[derive(Default, Clone, Serialize, Deserialize, Debug, ProtocolConfigFeatureFlagsGetters)]
496struct FeatureFlags {
497 #[serde(skip_serializing_if = "is_false")]
500 package_upgrades: bool,
501 #[serde(skip_serializing_if = "is_false")]
504 commit_root_state_digest: bool,
505 #[serde(skip_serializing_if = "is_false")]
507 advance_epoch_start_time_in_safe_mode: bool,
508 #[serde(skip_serializing_if = "is_false")]
511 loaded_child_objects_fixed: bool,
512 #[serde(skip_serializing_if = "is_false")]
515 missing_type_is_compatibility_error: bool,
516 #[serde(skip_serializing_if = "is_false")]
519 scoring_decision_with_validity_cutoff: bool,
520
521 #[serde(skip_serializing_if = "is_false")]
524 consensus_order_end_of_epoch_last: bool,
525
526 #[serde(skip_serializing_if = "is_false")]
530 consensus_slim_block_propagation: bool,
531
532 #[serde(skip_serializing_if = "is_false")]
534 disallow_adding_abilities_on_upgrade: bool,
535 #[serde(skip_serializing_if = "is_false")]
537 disable_invariant_violation_check_in_swap_loc: bool,
538 #[serde(skip_serializing_if = "is_false")]
541 advance_to_highest_supported_protocol_version: bool,
542 #[serde(skip_serializing_if = "is_false")]
544 ban_entry_init: bool,
545 #[serde(skip_serializing_if = "is_false")]
547 package_digest_hash_module: bool,
548 #[serde(skip_serializing_if = "is_false")]
550 disallow_change_struct_type_params_on_upgrade: bool,
551 #[serde(skip_serializing_if = "is_false")]
553 no_extraneous_module_bytes: bool,
554 #[serde(skip_serializing_if = "is_false")]
556 narwhal_versioned_metadata: bool,
557
558 #[serde(skip_serializing_if = "is_false")]
560 zklogin_auth: bool,
561 #[serde(skip_serializing_if = "is_zero")]
564 zklogin_circuit_mode: u64,
565 #[serde(skip_serializing_if = "ConsensusTransactionOrdering::is_none")]
567 consensus_transaction_ordering: ConsensusTransactionOrdering,
568
569 #[serde(skip_serializing_if = "is_false")]
577 simplified_unwrap_then_delete: bool,
578 #[serde(skip_serializing_if = "is_false")]
580 upgraded_multisig_supported: bool,
581 #[serde(skip_serializing_if = "is_false")]
583 txn_base_cost_as_multiplier: bool,
584
585 #[serde(skip_serializing_if = "is_false")]
587 shared_object_deletion: bool,
588
589 #[serde(skip_serializing_if = "is_false")]
591 narwhal_new_leader_election_schedule: bool,
592
593 #[serde(skip_serializing_if = "is_empty")]
595 zklogin_supported_providers: BTreeSet<String>,
596
597 #[serde(skip_serializing_if = "is_false")]
599 loaded_child_object_format: bool,
600
601 #[serde(skip_serializing_if = "is_false")]
602 #[skip_protocol_config_accessor]
603 enable_jwk_consensus_updates: bool,
604
605 #[serde(skip_serializing_if = "is_false")]
606 #[skip_protocol_config_accessor]
607 end_of_epoch_transaction_supported: bool,
608
609 #[serde(skip_serializing_if = "is_false")]
612 simple_conservation_checks: bool,
613
614 #[serde(skip_serializing_if = "is_false")]
616 loaded_child_object_format_type: bool,
617
618 #[serde(skip_serializing_if = "is_false")]
620 receive_objects: bool,
621
622 #[serde(skip_serializing_if = "is_false")]
624 consensus_checkpoint_signature_key_includes_digest: bool,
625
626 #[serde(skip_serializing_if = "is_false")]
628 random_beacon: bool,
629
630 #[serde(skip_serializing_if = "is_false")]
632 #[skip_protocol_config_accessor]
633 bridge: bool,
634
635 #[serde(skip_serializing_if = "is_false")]
636 enable_effects_v2: bool,
637
638 #[serde(skip_serializing_if = "is_false")]
640 narwhal_certificate_v2: bool,
641
642 #[serde(skip_serializing_if = "is_false")]
644 verify_legacy_zklogin_address: bool,
645
646 #[serde(skip_serializing_if = "is_false")]
648 throughput_aware_consensus_submission: bool,
649
650 #[serde(skip_serializing_if = "is_false")]
652 recompute_has_public_transfer_in_execution: bool,
653
654 #[serde(skip_serializing_if = "is_false")]
656 accept_zklogin_in_multisig: bool,
657
658 #[serde(skip_serializing_if = "is_false")]
660 accept_passkey_in_multisig: bool,
661
662 #[serde(skip_serializing_if = "is_false")]
664 validate_zklogin_public_identifier: bool,
665
666 #[serde(skip_serializing_if = "is_false")]
669 include_consensus_digest_in_prologue: bool,
670
671 #[serde(skip_serializing_if = "is_false")]
673 hardened_otw_check: bool,
674
675 #[serde(skip_serializing_if = "is_false")]
677 allow_receiving_object_id: bool,
678
679 #[serde(skip_serializing_if = "is_false")]
681 enable_poseidon: bool,
682
683 #[serde(skip_serializing_if = "is_false")]
685 enable_coin_deny_list: bool,
686
687 #[serde(skip_serializing_if = "is_false")]
689 enable_group_ops_native_functions: bool,
690
691 #[serde(skip_serializing_if = "is_false")]
693 enable_group_ops_native_function_msm: bool,
694
695 #[serde(skip_serializing_if = "is_false")]
697 enable_ristretto255_group_ops: bool,
698
699 #[serde(skip_serializing_if = "is_false")]
701 enable_verify_bulletproofs_ristretto255: bool,
702
703 #[serde(skip_serializing_if = "is_false")]
705 enable_nitro_attestation: bool,
706
707 #[serde(skip_serializing_if = "is_false")]
709 enable_nitro_attestation_upgraded_parsing: bool,
710
711 #[serde(skip_serializing_if = "is_false")]
713 enable_nitro_attestation_all_nonzero_pcrs_parsing: bool,
714
715 #[serde(skip_serializing_if = "is_false")]
717 enable_nitro_attestation_always_include_required_pcrs_parsing: bool,
718
719 #[serde(skip_serializing_if = "is_false")]
721 reject_mutable_random_on_entry_functions: bool,
722
723 #[serde(skip_serializing_if = "PerObjectCongestionControlMode::is_none")]
725 per_object_congestion_control_mode: PerObjectCongestionControlMode,
726
727 #[serde(skip_serializing_if = "ConsensusChoice::is_narwhal")]
729 consensus_choice: ConsensusChoice,
730
731 #[serde(skip_serializing_if = "ConsensusNetwork::is_anemo")]
733 consensus_network: ConsensusNetwork,
734
735 #[serde(skip_serializing_if = "is_false")]
737 correct_gas_payment_limit_check: bool,
738
739 #[serde(skip_serializing_if = "Option::is_none")]
741 zklogin_max_epoch_upper_bound_delta: Option<u64>,
742
743 #[serde(skip_serializing_if = "is_false")]
745 mysticeti_leader_scoring_and_schedule: bool,
746
747 #[serde(skip_serializing_if = "is_false")]
749 reshare_at_same_initial_version: bool,
750
751 #[serde(skip_serializing_if = "is_false")]
753 resolve_abort_locations_to_package_id: bool,
754
755 #[serde(skip_serializing_if = "is_false")]
759 mysticeti_use_committed_subdag_digest: bool,
760
761 #[serde(skip_serializing_if = "is_false")]
763 enable_vdf: bool,
764
765 #[serde(skip_serializing_if = "is_false")]
769 record_consensus_determined_version_assignments_in_prologue: bool,
770 #[serde(skip_serializing_if = "is_false")]
773 record_consensus_determined_version_assignments_in_prologue_v2: bool,
774
775 #[serde(skip_serializing_if = "is_false")]
777 fresh_vm_on_framework_upgrade: bool,
778
779 #[serde(skip_serializing_if = "is_false")]
787 prepend_prologue_tx_in_consensus_commit_in_checkpoints: bool,
788
789 #[serde(skip_serializing_if = "Option::is_none")]
791 mysticeti_num_leaders_per_round: Option<usize>,
792
793 #[serde(skip_serializing_if = "is_false")]
795 soft_bundle: bool,
796
797 #[serde(skip_serializing_if = "is_false")]
799 enable_coin_deny_list_v2: bool,
800
801 #[serde(skip_serializing_if = "is_false")]
803 passkey_auth: bool,
804
805 #[serde(skip_serializing_if = "is_false")]
807 authority_capabilities_v2: bool,
808
809 #[serde(skip_serializing_if = "is_false")]
811 rethrow_serialization_type_layout_errors: bool,
812
813 #[serde(skip_serializing_if = "is_false")]
815 consensus_distributed_vote_scoring_strategy: bool,
816
817 #[serde(skip_serializing_if = "is_false")]
819 consensus_round_prober: bool,
820
821 #[serde(skip_serializing_if = "is_false")]
823 validate_identifier_inputs: bool,
824
825 #[serde(skip_serializing_if = "is_false")]
827 disallow_self_identifier: bool,
828
829 #[serde(skip_serializing_if = "is_false")]
831 mysticeti_fastpath: bool,
832
833 #[serde(skip_serializing_if = "is_false")]
837 disable_preconsensus_locking: bool,
838
839 #[serde(skip_serializing_if = "is_false")]
841 relocate_event_module: bool,
842
843 #[serde(skip_serializing_if = "is_false")]
845 uncompressed_g1_group_elements: bool,
846
847 #[serde(skip_serializing_if = "is_false")]
848 disallow_new_modules_in_deps_only_packages: bool,
849
850 #[serde(skip_serializing_if = "is_false")]
852 consensus_smart_ancestor_selection: bool,
853
854 #[serde(skip_serializing_if = "is_false")]
856 consensus_round_prober_probe_accepted_rounds: bool,
857
858 #[serde(skip_serializing_if = "is_false")]
860 native_charging_v2: bool,
861
862 #[serde(skip_serializing_if = "is_false")]
865 #[skip_protocol_config_accessor]
866 consensus_linearize_subdag_v2: bool,
867
868 #[serde(skip_serializing_if = "is_false")]
870 convert_type_argument_error: bool,
871
872 #[serde(skip_serializing_if = "is_false")]
874 variant_nodes: bool,
875
876 #[serde(skip_serializing_if = "is_false")]
878 consensus_zstd_compression: bool,
879
880 #[serde(skip_serializing_if = "is_false")]
882 minimize_child_object_mutations: bool,
883
884 #[serde(skip_serializing_if = "is_false")]
887 record_additional_state_digest_in_prologue: bool,
888
889 #[serde(skip_serializing_if = "is_false")]
891 move_native_context: bool,
892
893 #[serde(skip_serializing_if = "is_false")]
896 #[skip_protocol_config_accessor]
897 consensus_median_based_commit_timestamp: bool,
898
899 #[serde(skip_serializing_if = "is_false")]
902 normalize_ptb_arguments: bool,
903
904 #[serde(skip_serializing_if = "is_false")]
906 consensus_batched_block_sync: bool,
907
908 #[serde(skip_serializing_if = "is_false")]
910 enforce_checkpoint_timestamp_monotonicity: bool,
911
912 #[serde(skip_serializing_if = "is_false")]
914 max_ptb_value_size_v2: bool,
915
916 #[serde(skip_serializing_if = "is_false")]
918 resolve_type_input_ids_to_defining_id: bool,
919
920 #[serde(skip_serializing_if = "is_false")]
922 enable_party_transfer: bool,
923
924 #[serde(skip_serializing_if = "is_false")]
926 allow_unbounded_system_objects: bool,
927
928 #[serde(skip_serializing_if = "is_false")]
930 type_tags_in_object_runtime: bool,
931
932 #[serde(skip_serializing_if = "is_false")]
934 enable_accumulators: bool,
935
936 #[serde(skip_serializing_if = "is_false")]
938 #[skip_protocol_config_accessor]
939 enable_coin_reservation_obj_refs: bool,
940
941 #[serde(skip_serializing_if = "is_false")]
944 create_root_accumulator_object: bool,
945
946 #[serde(skip_serializing_if = "is_false")]
948 #[skip_protocol_config_accessor]
949 enable_authenticated_event_streams: bool,
950
951 #[serde(skip_serializing_if = "is_false")]
953 enable_address_balance_gas_payments: bool,
954
955 #[serde(skip_serializing_if = "is_false")]
957 address_balance_gas_check_rgp_at_signing: bool,
958
959 #[serde(skip_serializing_if = "is_false")]
960 address_balance_gas_reject_gas_coin_arg: bool,
961
962 #[serde(skip_serializing_if = "is_false")]
964 enable_multi_epoch_transaction_expiration: bool,
965
966 #[serde(skip_serializing_if = "is_false")]
968 relax_valid_during_for_owned_inputs: bool,
969
970 #[serde(skip_serializing_if = "is_false")]
972 enable_ptb_execution_v2: bool,
973
974 #[serde(skip_serializing_if = "is_false")]
976 better_adapter_type_resolution_errors: bool,
977
978 #[serde(skip_serializing_if = "is_false")]
980 record_time_estimate_processed: bool,
981
982 #[serde(skip_serializing_if = "is_false")]
984 dependency_linkage_error: bool,
985
986 #[serde(skip_serializing_if = "is_false")]
988 additional_multisig_checks: bool,
989
990 #[serde(skip_serializing_if = "is_false")]
992 ignore_execution_time_observations_after_certs_closed: bool,
993
994 #[serde(skip_serializing_if = "is_false")]
998 debug_fatal_on_move_invariant_violation: bool,
999
1000 #[serde(skip_serializing_if = "is_false")]
1003 allow_private_accumulator_entrypoints: bool,
1004
1005 #[serde(skip_serializing_if = "is_false")]
1008 additional_consensus_digest_indirect_state: bool,
1009
1010 #[serde(skip_serializing_if = "is_false")]
1012 check_for_init_during_upgrade: bool,
1013
1014 #[serde(skip_serializing_if = "is_false")]
1016 enable_init_on_upgrade: bool,
1017
1018 #[serde(skip_serializing_if = "is_false")]
1020 enable_order_independent_upgrade_init_linkage: bool,
1021
1022 #[serde(skip_serializing_if = "is_false")]
1025 harden_linkage_consistency: bool,
1026
1027 #[serde(skip_serializing_if = "is_false")]
1029 per_command_shared_object_transfer_rules: bool,
1030
1031 #[serde(skip_serializing_if = "is_false")]
1033 validate_ptb_argument_indices: bool,
1034
1035 #[serde(skip_serializing_if = "is_false")]
1037 include_checkpoint_artifacts_digest_in_summary: bool,
1038
1039 #[serde(skip_serializing_if = "is_false")]
1041 use_mfp_txns_in_load_initial_object_debts: bool,
1042
1043 #[serde(skip_serializing_if = "is_false")]
1045 cancel_for_failed_dkg_early: bool,
1046
1047 #[serde(skip_serializing_if = "is_false")]
1049 always_advance_dkg_to_resolution: bool,
1050
1051 #[serde(skip_serializing_if = "is_false")]
1053 enable_coin_registry: bool,
1054
1055 #[serde(skip_serializing_if = "is_false")]
1057 abstract_size_in_object_runtime: bool,
1058
1059 #[serde(skip_serializing_if = "is_false")]
1061 object_runtime_charge_cache_load_gas: bool,
1062
1063 #[serde(skip_serializing_if = "is_false")]
1065 additional_borrow_checks: bool,
1066
1067 #[serde(skip_serializing_if = "is_false")]
1069 use_new_commit_handler: bool,
1070
1071 #[serde(skip_serializing_if = "is_false")]
1073 better_loader_errors: bool,
1074
1075 #[serde(skip_serializing_if = "is_false")]
1077 generate_df_type_layouts: bool,
1078
1079 #[serde(skip_serializing_if = "is_false")]
1081 allow_references_in_ptbs: bool,
1082
1083 #[serde(skip_serializing_if = "is_false")]
1090 framework_tx_context_mut_restrictions: bool,
1091
1092 #[serde(skip_serializing_if = "is_false")]
1094 include_function_signatures_in_instantiation_limits: bool,
1095
1096 #[serde(skip_serializing_if = "is_false")]
1101 ptb_tx_context_restrictions: bool,
1102
1103 #[serde(skip_serializing_if = "is_false")]
1105 enable_display_registry: bool,
1106
1107 #[serde(skip_serializing_if = "is_false")]
1109 private_generics_verifier_v2: bool,
1110
1111 #[serde(skip_serializing_if = "is_false")]
1113 deprecate_global_storage_ops_during_deserialization: bool,
1114
1115 #[serde(skip_serializing_if = "is_false")]
1118 enable_non_exclusive_writes: bool,
1119
1120 #[serde(skip_serializing_if = "is_false")]
1122 deprecate_global_storage_ops: bool,
1123
1124 #[serde(skip_serializing_if = "is_false")]
1126 normalize_depth_formula: bool,
1127
1128 #[serde(skip_serializing_if = "is_false")]
1131 charge_ld_const_abstract_size: bool,
1132
1133 #[serde(skip_serializing_if = "is_false")]
1135 consensus_skip_gced_accept_votes: bool,
1136
1137 #[serde(skip_serializing_if = "is_false")]
1140 include_cancelled_randomness_txns_in_prologue: bool,
1141
1142 #[serde(skip_serializing_if = "is_false")]
1144 #[skip_protocol_config_accessor]
1145 address_aliases: bool,
1146
1147 #[serde(skip_serializing_if = "is_false")]
1149 create_forwarding_address_registry: bool,
1150
1151 #[serde(skip_serializing_if = "is_false")]
1154 fix_checkpoint_signature_mapping: bool,
1155
1156 #[serde(skip_serializing_if = "is_false")]
1158 enable_object_funds_withdraw: bool,
1159
1160 #[serde(skip_serializing_if = "is_false")]
1163 record_net_unsettled_object_withdraws: bool,
1164
1165 #[serde(skip_serializing_if = "is_false")]
1167 consensus_skip_gced_blocks_in_direct_finalization: bool,
1168
1169 #[serde(skip_serializing_if = "is_false")]
1171 gas_rounding_halve_digits: bool,
1172
1173 #[serde(skip_serializing_if = "is_false")]
1175 flexible_tx_context_positions: bool,
1176
1177 #[serde(skip_serializing_if = "is_false")]
1179 disable_entry_point_signature_check: bool,
1180
1181 #[serde(skip_serializing_if = "is_false")]
1183 convert_withdrawal_compatibility_ptb_arguments: bool,
1184
1185 #[serde(skip_serializing_if = "is_false")]
1187 restrict_hot_or_not_entry_functions: bool,
1188
1189 #[serde(skip_serializing_if = "is_false")]
1191 split_checkpoints_in_consensus_handler: bool,
1192
1193 #[serde(skip_serializing_if = "is_false")]
1195 consensus_always_accept_system_transactions: bool,
1196
1197 #[serde(skip_serializing_if = "is_false")]
1199 validator_metadata_verify_v2: bool,
1200
1201 #[serde(skip_serializing_if = "is_false")]
1204 defer_unpaid_amplification: bool,
1205
1206 #[serde(skip_serializing_if = "is_false")]
1209 defer_owned_object_double_spend: bool,
1210
1211 #[serde(skip_serializing_if = "is_false")]
1214 allowed_proposers: bool,
1215
1216 #[serde(skip_serializing_if = "is_false")]
1217 randomize_checkpoint_tx_limit_in_tests: bool,
1218
1219 #[serde(skip_serializing_if = "is_false")]
1221 gasless_transaction_drop_safety: bool,
1222
1223 #[serde(skip_serializing_if = "is_false")]
1226 merge_randomness_into_checkpoint: bool,
1227
1228 #[serde(skip_serializing_if = "is_false")]
1230 use_coin_party_owner: bool,
1231
1232 #[serde(skip_serializing_if = "is_false")]
1233 enable_gasless: bool,
1234
1235 #[serde(skip_serializing_if = "is_false")]
1236 gasless_verify_remaining_balance: bool,
1237
1238 #[serde(skip_serializing_if = "is_false")]
1239 disallow_jump_orphans: bool,
1240
1241 #[serde(skip_serializing_if = "is_false")]
1243 early_return_receive_object_mismatched_type: bool,
1244
1245 #[serde(skip_serializing_if = "is_false")]
1250 timestamp_based_epoch_close: bool,
1251
1252 #[serde(skip_serializing_if = "is_false")]
1255 limit_groth16_pvk_inputs: bool,
1256
1257 #[serde(skip_serializing_if = "is_false")]
1262 enforce_address_balance_change_invariant: bool,
1263
1264 #[serde(skip_serializing_if = "is_false")]
1266 share_transaction_deny_config_in_consensus: bool,
1267
1268 #[serde(skip_serializing_if = "is_false")]
1270 granular_post_execution_checks: bool,
1271
1272 #[serde(skip_serializing_if = "is_false")]
1274 early_exit_on_iffw: bool,
1275
1276 #[serde(skip_serializing_if = "is_false")]
1278 enable_unified_linkage: bool,
1279
1280 #[serde(skip_serializing_if = "is_false")]
1283 #[skip_protocol_config_accessor]
1284 enable_allowances: bool,
1285
1286 #[serde(skip_serializing_if = "is_false")]
1288 fix_ptb_generated_reads: bool,
1289
1290 #[serde(skip_serializing_if = "is_false")]
1291 check_object_funds_withdraw_in_execution: bool,
1292 #[serde(skip_serializing_if = "is_false")]
1294 memory_safety_invariant_check_v2: bool,
1295}
1296
1297fn is_false(b: &bool) -> bool {
1298 !b
1299}
1300
1301fn is_empty(b: &BTreeSet<String>) -> bool {
1302 b.is_empty()
1303}
1304
1305fn is_zero(val: &u64) -> bool {
1306 *val == 0
1307}
1308
1309#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1311pub enum ConsensusTransactionOrdering {
1312 #[default]
1314 None,
1315 ByGasPrice,
1317}
1318
1319impl ConsensusTransactionOrdering {
1320 pub fn is_none(&self) -> bool {
1321 matches!(self, ConsensusTransactionOrdering::None)
1322 }
1323}
1324
1325#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1326pub struct ExecutionTimeEstimateParams {
1327 pub target_utilization: u64,
1329 pub allowed_txn_cost_overage_burst_limit_us: u64,
1333
1334 pub randomness_scalar: u64,
1337
1338 pub max_estimate_us: u64,
1340
1341 pub stored_observations_num_included_checkpoints: u64,
1344
1345 pub stored_observations_limit: u64,
1347
1348 #[serde(skip_serializing_if = "is_zero")]
1351 pub stake_weighted_median_threshold: u64,
1352
1353 #[serde(skip_serializing_if = "is_false")]
1357 pub default_none_duration_for_new_keys: bool,
1358
1359 #[serde(skip_serializing_if = "Option::is_none")]
1361 pub observations_chunk_size: Option<u64>,
1362}
1363
1364#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1366pub enum PerObjectCongestionControlMode {
1367 #[default]
1368 None, TotalGasBudget, TotalTxCount, TotalGasBudgetWithCap, ExecutionTimeEstimate(ExecutionTimeEstimateParams), }
1374
1375impl PerObjectCongestionControlMode {
1376 pub fn is_none(&self) -> bool {
1377 matches!(self, PerObjectCongestionControlMode::None)
1378 }
1379}
1380
1381#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1383pub enum ConsensusChoice {
1384 #[default]
1385 Narwhal,
1386 SwapEachEpoch,
1387 Mysticeti,
1388}
1389
1390impl ConsensusChoice {
1391 pub fn is_narwhal(&self) -> bool {
1392 matches!(self, ConsensusChoice::Narwhal)
1393 }
1394}
1395
1396#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1398pub enum ConsensusNetwork {
1399 #[default]
1400 Anemo,
1401 Tonic,
1402}
1403
1404impl ConsensusNetwork {
1405 pub fn is_anemo(&self) -> bool {
1406 matches!(self, ConsensusNetwork::Anemo)
1407 }
1408}
1409
1410#[skip_serializing_none]
1442#[derive(Clone, Serialize, Debug, ProtocolConfigAccessors, ProtocolConfigOverride)]
1443pub struct ProtocolConfig {
1444 pub version: ProtocolVersion,
1445
1446 #[serde(skip)]
1451 chain: Chain,
1452
1453 feature_flags: FeatureFlags,
1454
1455 max_tx_size_bytes: Option<u64>,
1458
1459 max_input_objects: Option<u64>,
1461
1462 max_size_written_objects: Option<u64>,
1466 max_size_written_objects_system_tx: Option<u64>,
1469
1470 max_serialized_tx_effects_size_bytes: Option<u64>,
1472
1473 max_serialized_tx_effects_size_bytes_system_tx: Option<u64>,
1475
1476 max_gas_payment_objects: Option<u32>,
1478
1479 max_modules_in_publish: Option<u32>,
1481
1482 max_package_dependencies: Option<u32>,
1484
1485 max_arguments: Option<u32>,
1488
1489 max_type_arguments: Option<u32>,
1491
1492 max_type_argument_depth: Option<u32>,
1494
1495 max_pure_argument_size: Option<u32>,
1497
1498 max_programmable_tx_commands: Option<u32>,
1500
1501 move_binary_format_version: Option<u32>,
1504 min_move_binary_format_version: Option<u32>,
1505
1506 binary_module_handles: Option<u16>,
1508 binary_struct_handles: Option<u16>,
1509 binary_function_handles: Option<u16>,
1510 binary_function_instantiations: Option<u16>,
1511 binary_signatures: Option<u16>,
1512 binary_constant_pool: Option<u16>,
1513 binary_identifiers: Option<u16>,
1514 binary_address_identifiers: Option<u16>,
1515 binary_struct_defs: Option<u16>,
1516 binary_struct_def_instantiations: Option<u16>,
1517 binary_function_defs: Option<u16>,
1518 binary_field_handles: Option<u16>,
1519 binary_field_instantiations: Option<u16>,
1520 binary_friend_decls: Option<u16>,
1521 binary_enum_defs: Option<u16>,
1522 binary_enum_def_instantiations: Option<u16>,
1523 binary_variant_handles: Option<u16>,
1524 binary_variant_instantiation_handles: Option<u16>,
1525
1526 max_move_object_size: Option<u64>,
1528
1529 max_move_package_size: Option<u64>,
1532
1533 max_publish_or_upgrade_per_ptb: Option<u64>,
1535
1536 max_tx_gas: Option<u64>,
1538
1539 max_gas_price: Option<u64>,
1541
1542 max_gas_price_rgp_factor_for_aborted_transactions: Option<u64>,
1545
1546 max_gas_computation_bucket: Option<u64>,
1548
1549 gas_rounding_step: Option<u64>,
1551
1552 max_loop_depth: Option<u64>,
1554
1555 max_generic_instantiation_length: Option<u64>,
1557
1558 max_function_parameters: Option<u64>,
1560
1561 max_basic_blocks: Option<u64>,
1563
1564 max_value_stack_size: Option<u64>,
1566
1567 max_type_nodes: Option<u64>,
1569
1570 max_generic_instantiation_type_nodes_per_function: Option<u64>,
1572
1573 max_generic_instantiation_type_nodes_per_module: Option<u64>,
1575
1576 max_accumulator_type_nodes: Option<u64>,
1578
1579 max_push_size: Option<u64>,
1581
1582 max_struct_definitions: Option<u64>,
1584
1585 max_function_definitions: Option<u64>,
1587
1588 max_fields_in_struct: Option<u64>,
1590
1591 max_dependency_depth: Option<u64>,
1593
1594 max_num_event_emit: Option<u64>,
1596
1597 max_num_new_move_object_ids: Option<u64>,
1599
1600 max_num_new_move_object_ids_system_tx: Option<u64>,
1602
1603 max_num_deleted_move_object_ids: Option<u64>,
1605
1606 max_num_deleted_move_object_ids_system_tx: Option<u64>,
1608
1609 max_num_transferred_move_object_ids: Option<u64>,
1611
1612 max_num_transferred_move_object_ids_system_tx: Option<u64>,
1614
1615 max_event_emit_size: Option<u64>,
1617
1618 max_event_emit_size_total: Option<u64>,
1620
1621 max_move_vector_len: Option<u64>,
1623
1624 max_move_identifier_len: Option<u64>,
1626
1627 max_move_value_depth: Option<u64>,
1629
1630 package_arena_size_in_bytes: Option<u64>,
1633
1634 max_move_enum_variants: Option<u64>,
1636
1637 max_back_edges_per_function: Option<u64>,
1639
1640 max_back_edges_per_module: Option<u64>,
1642
1643 max_verifier_meter_ticks_per_function: Option<u64>,
1645
1646 max_meter_ticks_per_module: Option<u64>,
1648
1649 max_meter_ticks_per_package: Option<u64>,
1651
1652 object_runtime_max_num_cached_objects: Option<u64>,
1656
1657 object_runtime_max_num_cached_objects_system_tx: Option<u64>,
1659
1660 object_runtime_max_num_store_entries: Option<u64>,
1662
1663 object_runtime_max_num_store_entries_system_tx: Option<u64>,
1665
1666 base_tx_cost_fixed: Option<u64>,
1669
1670 package_publish_cost_fixed: Option<u64>,
1673
1674 base_tx_cost_per_byte: Option<u64>,
1677
1678 package_publish_cost_per_byte: Option<u64>,
1680
1681 obj_access_cost_read_per_byte: Option<u64>,
1683
1684 obj_access_cost_mutate_per_byte: Option<u64>,
1686
1687 obj_access_cost_delete_per_byte: Option<u64>,
1689
1690 obj_access_cost_verify_per_byte: Option<u64>,
1700
1701 max_type_to_layout_nodes: Option<u64>,
1703
1704 max_ptb_value_size: Option<u64>,
1706
1707 gas_model_version: Option<u64>,
1710
1711 obj_data_cost_refundable: Option<u64>,
1714
1715 obj_metadata_cost_non_refundable: Option<u64>,
1719
1720 storage_rebate_rate: Option<u64>,
1726
1727 storage_fund_reinvest_rate: Option<u64>,
1730
1731 reward_slashing_rate: Option<u64>,
1734
1735 storage_gas_price: Option<u64>,
1737
1738 accumulator_object_storage_cost: Option<u64>,
1740
1741 max_transactions_per_checkpoint: Option<u64>,
1746
1747 max_checkpoint_size_bytes: Option<u64>,
1751
1752 buffer_stake_for_protocol_upgrade_bps: Option<u64>,
1757
1758 address_from_bytes_cost_base: Option<u64>,
1763 address_to_u256_cost_base: Option<u64>,
1765 address_from_u256_cost_base: Option<u64>,
1767
1768 config_read_setting_impl_cost_base: Option<u64>,
1773 config_read_setting_impl_cost_per_byte: Option<u64>,
1774
1775 package_original_package_id_impl_cost_base: Option<u64>,
1776 package_original_package_id_impl_cost_per_byte: Option<u64>,
1777
1778 dynamic_field_hash_type_and_key_cost_base: Option<u64>,
1781 dynamic_field_hash_type_and_key_type_cost_per_byte: Option<u64>,
1782 dynamic_field_hash_type_and_key_value_cost_per_byte: Option<u64>,
1783 dynamic_field_hash_type_and_key_type_tag_cost_per_byte: Option<u64>,
1784 dynamic_field_add_child_object_cost_base: Option<u64>,
1786 dynamic_field_add_child_object_type_cost_per_byte: Option<u64>,
1787 dynamic_field_add_child_object_value_cost_per_byte: Option<u64>,
1788 dynamic_field_add_child_object_struct_tag_cost_per_byte: Option<u64>,
1789 dynamic_field_borrow_child_object_cost_base: Option<u64>,
1791 dynamic_field_borrow_child_object_child_ref_cost_per_byte: Option<u64>,
1792 dynamic_field_borrow_child_object_type_cost_per_byte: Option<u64>,
1793 dynamic_field_remove_child_object_cost_base: Option<u64>,
1795 dynamic_field_remove_child_object_child_cost_per_byte: Option<u64>,
1796 dynamic_field_remove_child_object_type_cost_per_byte: Option<u64>,
1797 dynamic_field_has_child_object_cost_base: Option<u64>,
1799 dynamic_field_has_child_object_with_ty_cost_base: Option<u64>,
1801 dynamic_field_has_child_object_with_ty_type_cost_per_byte: Option<u64>,
1802 dynamic_field_has_child_object_with_ty_type_tag_cost_per_byte: Option<u64>,
1803
1804 scratch_add_cost_base: Option<u64>,
1807 scratch_read_cost_base: Option<u64>,
1809 scratch_read_value_cost: Option<u64>,
1810 scratch_remove_cost_base: Option<u64>,
1812 scratch_exists_cost_base: Option<u64>,
1814 scratch_exists_with_type_cost_base: Option<u64>,
1816 scratch_exists_with_type_type_cost: Option<u64>,
1817 max_scratch_pad_size: Option<u64>,
1819
1820 event_emit_cost_base: Option<u64>,
1823 event_emit_value_size_derivation_cost_per_byte: Option<u64>,
1824 event_emit_tag_size_derivation_cost_per_byte: Option<u64>,
1825 event_emit_output_cost_per_byte: Option<u64>,
1826 event_emit_auth_stream_cost: Option<u64>,
1827
1828 reserve_object_funds_for_withdrawal_cost_base: Option<u64>,
1831 reserve_object_funds_for_withdrawal_cold_read_cost: Option<u64>,
1833
1834 object_borrow_uid_cost_base: Option<u64>,
1837 object_delete_impl_cost_base: Option<u64>,
1839 object_record_new_uid_cost_base: Option<u64>,
1841 object_record_new_uid_from_hash_cost_base: Option<u64>,
1844
1845 transfer_transfer_internal_cost_base: Option<u64>,
1848 transfer_party_transfer_internal_cost_base: Option<u64>,
1850 transfer_freeze_object_cost_base: Option<u64>,
1852 transfer_share_object_cost_base: Option<u64>,
1854 transfer_receive_object_cost_base: Option<u64>,
1857 transfer_receive_object_cost_per_byte: Option<u64>,
1858 transfer_receive_object_type_cost_per_byte: Option<u64>,
1859
1860 tx_context_derive_id_cost_base: Option<u64>,
1863 tx_context_fresh_id_cost_base: Option<u64>,
1864 tx_context_sender_cost_base: Option<u64>,
1865 tx_context_epoch_cost_base: Option<u64>,
1866 tx_context_epoch_timestamp_ms_cost_base: Option<u64>,
1867 tx_context_sponsor_cost_base: Option<u64>,
1868 tx_context_rgp_cost_base: Option<u64>,
1869 tx_context_gas_price_cost_base: Option<u64>,
1870 tx_context_gas_budget_cost_base: Option<u64>,
1871 tx_context_ids_created_cost_base: Option<u64>,
1872 tx_context_replace_cost_base: Option<u64>,
1873
1874 types_is_one_time_witness_cost_base: Option<u64>,
1877 types_is_one_time_witness_type_tag_cost_per_byte: Option<u64>,
1878 types_is_one_time_witness_type_cost_per_byte: Option<u64>,
1879
1880 validator_validate_metadata_cost_base: Option<u64>,
1883 validator_validate_metadata_data_cost_per_byte: Option<u64>,
1884
1885 crypto_invalid_arguments_cost: Option<u64>,
1887 bls12381_bls12381_min_sig_verify_cost_base: Option<u64>,
1889 bls12381_bls12381_min_sig_verify_msg_cost_per_byte: Option<u64>,
1890 bls12381_bls12381_min_sig_verify_msg_cost_per_block: Option<u64>,
1891
1892 bls12381_bls12381_min_pk_verify_cost_base: Option<u64>,
1894 bls12381_bls12381_min_pk_verify_msg_cost_per_byte: Option<u64>,
1895 bls12381_bls12381_min_pk_verify_msg_cost_per_block: Option<u64>,
1896
1897 ecdsa_k1_ecrecover_keccak256_cost_base: Option<u64>,
1899 ecdsa_k1_ecrecover_keccak256_msg_cost_per_byte: Option<u64>,
1900 ecdsa_k1_ecrecover_keccak256_msg_cost_per_block: Option<u64>,
1901 ecdsa_k1_ecrecover_sha256_cost_base: Option<u64>,
1902 ecdsa_k1_ecrecover_sha256_msg_cost_per_byte: Option<u64>,
1903 ecdsa_k1_ecrecover_sha256_msg_cost_per_block: Option<u64>,
1904
1905 ecdsa_k1_decompress_pubkey_cost_base: Option<u64>,
1907
1908 ecdsa_k1_secp256k1_verify_keccak256_cost_base: Option<u64>,
1910 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_byte: Option<u64>,
1911 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_block: Option<u64>,
1912 ecdsa_k1_secp256k1_verify_sha256_cost_base: Option<u64>,
1913 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_byte: Option<u64>,
1914 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_block: Option<u64>,
1915
1916 ecdsa_r1_ecrecover_keccak256_cost_base: Option<u64>,
1918 ecdsa_r1_ecrecover_keccak256_msg_cost_per_byte: Option<u64>,
1919 ecdsa_r1_ecrecover_keccak256_msg_cost_per_block: Option<u64>,
1920 ecdsa_r1_ecrecover_sha256_cost_base: Option<u64>,
1921 ecdsa_r1_ecrecover_sha256_msg_cost_per_byte: Option<u64>,
1922 ecdsa_r1_ecrecover_sha256_msg_cost_per_block: Option<u64>,
1923
1924 ecdsa_r1_secp256r1_verify_keccak256_cost_base: Option<u64>,
1926 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_byte: Option<u64>,
1927 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_block: Option<u64>,
1928 ecdsa_r1_secp256r1_verify_sha256_cost_base: Option<u64>,
1929 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_byte: Option<u64>,
1930 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_block: Option<u64>,
1931
1932 ecvrf_ecvrf_verify_cost_base: Option<u64>,
1934 ecvrf_ecvrf_verify_alpha_string_cost_per_byte: Option<u64>,
1935 ecvrf_ecvrf_verify_alpha_string_cost_per_block: Option<u64>,
1936
1937 ed25519_ed25519_verify_cost_base: Option<u64>,
1939 ed25519_ed25519_verify_msg_cost_per_byte: Option<u64>,
1940 ed25519_ed25519_verify_msg_cost_per_block: Option<u64>,
1941
1942 groth16_prepare_verifying_key_bls12381_cost_base: Option<u64>,
1944 groth16_prepare_verifying_key_bn254_cost_base: Option<u64>,
1945
1946 groth16_verify_groth16_proof_internal_bls12381_cost_base: Option<u64>,
1948 groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input: Option<u64>,
1949 groth16_verify_groth16_proof_internal_bn254_cost_base: Option<u64>,
1950 groth16_verify_groth16_proof_internal_bn254_cost_per_public_input: Option<u64>,
1951 groth16_verify_groth16_proof_internal_public_input_cost_per_byte: Option<u64>,
1952
1953 hash_blake2b256_cost_base: Option<u64>,
1955 hash_blake2b256_data_cost_per_byte: Option<u64>,
1956 hash_blake2b256_data_cost_per_block: Option<u64>,
1957
1958 hash_keccak256_cost_base: Option<u64>,
1960 hash_keccak256_data_cost_per_byte: Option<u64>,
1961 hash_keccak256_data_cost_per_block: Option<u64>,
1962
1963 poseidon_bn254_cost_base: Option<u64>,
1965 poseidon_bn254_cost_per_block: Option<u64>,
1966
1967 group_ops_bls12381_decode_scalar_cost: Option<u64>,
1969 group_ops_bls12381_decode_g1_cost: Option<u64>,
1970 group_ops_bls12381_decode_g2_cost: Option<u64>,
1971 group_ops_bls12381_decode_gt_cost: Option<u64>,
1972 group_ops_bls12381_scalar_add_cost: Option<u64>,
1973 group_ops_bls12381_g1_add_cost: Option<u64>,
1974 group_ops_bls12381_g2_add_cost: Option<u64>,
1975 group_ops_bls12381_gt_add_cost: Option<u64>,
1976 group_ops_bls12381_scalar_sub_cost: Option<u64>,
1977 group_ops_bls12381_g1_sub_cost: Option<u64>,
1978 group_ops_bls12381_g2_sub_cost: Option<u64>,
1979 group_ops_bls12381_gt_sub_cost: Option<u64>,
1980 group_ops_bls12381_scalar_mul_cost: Option<u64>,
1981 group_ops_bls12381_g1_mul_cost: Option<u64>,
1982 group_ops_bls12381_g2_mul_cost: Option<u64>,
1983 group_ops_bls12381_gt_mul_cost: Option<u64>,
1984 group_ops_bls12381_scalar_div_cost: Option<u64>,
1985 group_ops_bls12381_g1_div_cost: Option<u64>,
1986 group_ops_bls12381_g2_div_cost: Option<u64>,
1987 group_ops_bls12381_gt_div_cost: Option<u64>,
1988 group_ops_bls12381_g1_hash_to_base_cost: Option<u64>,
1989 group_ops_bls12381_g2_hash_to_base_cost: Option<u64>,
1990 group_ops_bls12381_g1_hash_to_cost_per_byte: Option<u64>,
1991 group_ops_bls12381_g2_hash_to_cost_per_byte: Option<u64>,
1992 group_ops_bls12381_g1_msm_base_cost: Option<u64>,
1993 group_ops_bls12381_g2_msm_base_cost: Option<u64>,
1994 group_ops_bls12381_g1_msm_base_cost_per_input: Option<u64>,
1995 group_ops_bls12381_g2_msm_base_cost_per_input: Option<u64>,
1996 group_ops_bls12381_msm_max_len: Option<u32>,
1997 group_ops_bls12381_pairing_cost: Option<u64>,
1998 group_ops_bls12381_g1_to_uncompressed_g1_cost: Option<u64>,
1999 group_ops_bls12381_uncompressed_g1_to_g1_cost: Option<u64>,
2000 group_ops_bls12381_uncompressed_g1_sum_base_cost: Option<u64>,
2001 group_ops_bls12381_uncompressed_g1_sum_cost_per_term: Option<u64>,
2002 group_ops_bls12381_uncompressed_g1_sum_max_terms: Option<u64>,
2003
2004 group_ops_ristretto_decode_scalar_cost: Option<u64>,
2005 group_ops_ristretto_decode_point_cost: Option<u64>,
2006 group_ops_ristretto_scalar_add_cost: Option<u64>,
2007 group_ops_ristretto_point_add_cost: Option<u64>,
2008 group_ops_ristretto_scalar_sub_cost: Option<u64>,
2009 group_ops_ristretto_point_sub_cost: Option<u64>,
2010 group_ops_ristretto_scalar_mul_cost: Option<u64>,
2011 group_ops_ristretto_point_mul_cost: Option<u64>,
2012 group_ops_ristretto_scalar_div_cost: Option<u64>,
2013 group_ops_ristretto_point_div_cost: Option<u64>,
2014
2015 verify_bulletproofs_ristretto255_base_cost: Option<u64>,
2016 verify_bulletproofs_ristretto255_cost_per_bit_and_commitment: Option<u64>,
2017 max_bulletproofs_total_bits: Option<u64>,
2020
2021 hmac_hmac_sha3_256_cost_base: Option<u64>,
2023 hmac_hmac_sha3_256_input_cost_per_byte: Option<u64>,
2024 hmac_hmac_sha3_256_input_cost_per_block: Option<u64>,
2025
2026 check_zklogin_id_cost_base: Option<u64>,
2028 check_zklogin_issuer_cost_base: Option<u64>,
2030
2031 vdf_verify_vdf_cost: Option<u64>,
2032 vdf_hash_to_input_cost: Option<u64>,
2033
2034 nitro_attestation_parse_base_cost: Option<u64>,
2036 nitro_attestation_parse_cost_per_byte: Option<u64>,
2037 nitro_attestation_verify_base_cost: Option<u64>,
2038 nitro_attestation_verify_cost_per_cert: Option<u64>,
2039
2040 bcs_per_byte_serialized_cost: Option<u64>,
2042 bcs_legacy_min_output_size_cost: Option<u64>,
2043 bcs_failure_cost: Option<u64>,
2044
2045 hash_sha2_256_base_cost: Option<u64>,
2046 hash_sha2_256_per_byte_cost: Option<u64>,
2047 hash_sha2_256_legacy_min_input_len_cost: Option<u64>,
2048 hash_sha3_256_base_cost: Option<u64>,
2049 hash_sha3_256_per_byte_cost: Option<u64>,
2050 hash_sha3_256_legacy_min_input_len_cost: Option<u64>,
2051 type_name_get_base_cost: Option<u64>,
2052 type_name_get_per_byte_cost: Option<u64>,
2053 type_name_id_base_cost: Option<u64>,
2054
2055 string_check_utf8_base_cost: Option<u64>,
2056 string_check_utf8_per_byte_cost: Option<u64>,
2057 string_is_char_boundary_base_cost: Option<u64>,
2058 string_sub_string_base_cost: Option<u64>,
2059 string_sub_string_per_byte_cost: Option<u64>,
2060 string_index_of_base_cost: Option<u64>,
2061 string_index_of_per_byte_pattern_cost: Option<u64>,
2062 string_index_of_per_byte_searched_cost: Option<u64>,
2063
2064 vector_empty_base_cost: Option<u64>,
2065 vector_length_base_cost: Option<u64>,
2066 vector_push_back_base_cost: Option<u64>,
2067 vector_push_back_legacy_per_abstract_memory_unit_cost: Option<u64>,
2068 vector_borrow_base_cost: Option<u64>,
2069 vector_pop_back_base_cost: Option<u64>,
2070 vector_destroy_empty_base_cost: Option<u64>,
2071 vector_swap_base_cost: Option<u64>,
2072 debug_print_base_cost: Option<u64>,
2073 debug_print_stack_trace_base_cost: Option<u64>,
2074
2075 #[custom_setter]
2085 execution_version: Option<u64>,
2086
2087 consensus_bad_nodes_stake_threshold: Option<u64>,
2091
2092 max_jwk_votes_per_validator_per_epoch: Option<u64>,
2093 max_age_of_jwk_in_epochs: Option<u64>,
2097
2098 random_beacon_reduction_allowed_delta: Option<u16>,
2102
2103 random_beacon_reduction_lower_bound: Option<u32>,
2106
2107 random_beacon_dkg_timeout_round: Option<u32>,
2110
2111 random_beacon_min_round_interval_ms: Option<u64>,
2113
2114 random_beacon_dkg_version: Option<u64>,
2117
2118 consensus_max_transaction_size_bytes: Option<u64>,
2121 consensus_max_transactions_in_block_bytes: Option<u64>,
2123 consensus_max_num_transactions_in_block: Option<u64>,
2125
2126 consensus_voting_rounds: Option<u32>,
2128
2129 max_accumulated_txn_cost_per_object_in_narwhal_commit: Option<u64>,
2131
2132 max_deferral_rounds_for_congestion_control: Option<u64>,
2135
2136 epoch_close_deadline_ms: Option<u64>,
2141
2142 max_txn_cost_overage_per_object_in_commit: Option<u64>,
2144
2145 allowed_txn_cost_overage_burst_per_object_in_commit: Option<u64>,
2147
2148 min_checkpoint_interval_ms: Option<u64>,
2150
2151 checkpoint_summary_version_specific_data: Option<u64>,
2153
2154 max_soft_bundle_size: Option<u64>,
2156
2157 bridge_should_try_to_finalize_committee: Option<bool>,
2161
2162 max_accumulated_txn_cost_per_object_in_mysticeti_commit: Option<u64>,
2168
2169 max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit: Option<u64>,
2172
2173 consensus_gc_depth: Option<u32>,
2176
2177 gas_budget_based_txn_cost_cap_factor: Option<u64>,
2179
2180 gas_budget_based_txn_cost_absolute_cap_commit_count: Option<u64>,
2182
2183 sip_45_consensus_amplification_threshold: Option<u64>,
2186
2187 use_object_per_epoch_marker_table_v2: Option<bool>,
2190
2191 consensus_commit_rate_estimation_window_size: Option<u32>,
2193
2194 #[serde(skip_serializing_if = "Vec::is_empty")]
2198 aliased_addresses: Vec<AliasedAddress>,
2199
2200 translation_per_command_base_charge: Option<u64>,
2203
2204 translation_per_input_base_charge: Option<u64>,
2207
2208 translation_pure_input_per_byte_charge: Option<u64>,
2210
2211 translation_per_type_node_charge: Option<u64>,
2215
2216 translation_per_reference_node_charge: Option<u64>,
2219
2220 translation_per_linkage_entry_charge: Option<u64>,
2223
2224 max_updates_per_settlement_txn: Option<u32>,
2226
2227 gasless_max_computation_units: Option<u64>,
2229
2230 gasless_allowed_token_types: Option<Vec<(String, u64)>>,
2232
2233 gasless_max_unused_inputs: Option<u64>,
2237
2238 gasless_max_pure_input_bytes: Option<u64>,
2241
2242 gasless_max_tps: Option<u64>,
2244
2245 #[serde(skip_serializing_if = "Option::is_none")]
2246 #[skip_accessor]
2247 include_special_package_amendments: Option<Arc<Amendments>>,
2248
2249 gasless_max_tx_size_bytes: Option<u64>,
2252
2253 translation_per_live_reference_charge: Option<u64>,
2256
2257 max_ptb_live_references: Option<u64>,
2260
2261 max_ptb_returned_references: Option<u64>,
2264
2265 max_ptb_total_returned_references: Option<u64>,
2268}
2269
2270#[derive(Clone, Serialize, Deserialize, Debug)]
2272pub struct AliasedAddress {
2273 pub original: [u8; 32],
2275 pub aliased: [u8; 32],
2277 pub allowed_tx_digests: Vec<[u8; 32]>,
2279}
2280
2281impl ProtocolConfig {
2283 pub fn chain(&self) -> Chain {
2285 self.chain
2286 }
2287
2288 pub fn check_package_upgrades_supported(&self) -> Result<(), Error> {
2301 if self.feature_flags.package_upgrades {
2302 Ok(())
2303 } else {
2304 Err(Error(format!(
2305 "package upgrades are not supported at {:?}",
2306 self.version
2307 )))
2308 }
2309 }
2310
2311 pub fn zklogin_supported_providers(&self) -> &BTreeSet<String> {
2312 &self.feature_flags.zklogin_supported_providers
2313 }
2314
2315 pub fn zklogin_circuit_mode(&self) -> u64 {
2318 self.feature_flags.zklogin_circuit_mode
2319 }
2320
2321 pub fn consensus_transaction_ordering(&self) -> ConsensusTransactionOrdering {
2322 self.feature_flags.consensus_transaction_ordering
2323 }
2324
2325 pub fn enable_jwk_consensus_updates(&self) -> bool {
2326 let ret = self.feature_flags.enable_jwk_consensus_updates;
2327 if ret {
2328 assert!(self.feature_flags.end_of_epoch_transaction_supported);
2330 }
2331 ret
2332 }
2333
2334 pub fn end_of_epoch_transaction_supported(&self) -> bool {
2335 let ret = self.feature_flags.end_of_epoch_transaction_supported;
2336 if !ret {
2337 assert!(!self.feature_flags.enable_jwk_consensus_updates);
2339 }
2340 ret
2341 }
2342
2343 pub fn dkg_version(&self) -> u64 {
2344 self.random_beacon_dkg_version.unwrap_or(1)
2346 }
2347
2348 pub fn bridge(&self) -> bool {
2349 let ret = self.feature_flags.bridge;
2350 if ret {
2351 assert!(self.feature_flags.end_of_epoch_transaction_supported);
2353 }
2354 ret
2355 }
2356
2357 pub fn should_try_to_finalize_bridge_committee(&self) -> bool {
2358 if !self.bridge() {
2359 return false;
2360 }
2361 self.bridge_should_try_to_finalize_committee.unwrap_or(true)
2363 }
2364
2365 pub fn zklogin_max_epoch_upper_bound_delta(&self) -> Option<u64> {
2366 self.feature_flags.zklogin_max_epoch_upper_bound_delta
2367 }
2368
2369 pub fn enable_allowances(&self) -> bool {
2370 self.feature_flags.enable_allowances && self.enable_accumulators()
2371 }
2372
2373 pub fn enable_coin_reservation_obj_refs(&self) -> bool {
2374 self.new_vm_enabled() && self.feature_flags.enable_coin_reservation_obj_refs
2375 }
2376
2377 pub fn enable_authenticated_event_streams(&self) -> bool {
2378 self.feature_flags.enable_authenticated_event_streams && self.enable_accumulators()
2379 }
2380
2381 pub fn per_object_congestion_control_mode(&self) -> PerObjectCongestionControlMode {
2382 self.feature_flags.per_object_congestion_control_mode
2383 }
2384
2385 pub fn consensus_choice(&self) -> ConsensusChoice {
2386 self.feature_flags.consensus_choice
2387 }
2388
2389 pub fn consensus_network(&self) -> ConsensusNetwork {
2390 self.feature_flags.consensus_network
2391 }
2392
2393 pub fn mysticeti_num_leaders_per_round(&self) -> Option<usize> {
2394 self.feature_flags.mysticeti_num_leaders_per_round
2395 }
2396
2397 pub fn max_transaction_size_bytes(&self) -> u64 {
2398 self.consensus_max_transaction_size_bytes
2400 .unwrap_or(256 * 1024)
2401 }
2402
2403 pub fn max_transactions_in_block_bytes(&self) -> u64 {
2404 if cfg!(msim) {
2405 256 * 1024
2406 } else {
2407 self.consensus_max_transactions_in_block_bytes
2408 .unwrap_or(512 * 1024)
2409 }
2410 }
2411
2412 pub fn max_num_transactions_in_block(&self) -> u64 {
2413 if cfg!(msim) {
2414 8
2415 } else {
2416 self.consensus_max_num_transactions_in_block.unwrap_or(512)
2417 }
2418 }
2419
2420 pub fn gc_depth(&self) -> u32 {
2421 self.consensus_gc_depth.unwrap_or(0)
2422 }
2423
2424 pub fn consensus_linearize_subdag_v2(&self) -> bool {
2425 let res = self.feature_flags.consensus_linearize_subdag_v2;
2426 assert!(
2427 !res || self.gc_depth() > 0,
2428 "The consensus linearize sub dag V2 requires GC to be enabled"
2429 );
2430 res
2431 }
2432
2433 pub fn consensus_median_based_commit_timestamp(&self) -> bool {
2434 let res = self.feature_flags.consensus_median_based_commit_timestamp;
2435 assert!(
2436 !res || self.gc_depth() > 0,
2437 "The consensus median based commit timestamp requires GC to be enabled"
2438 );
2439 res
2440 }
2441
2442 pub fn get_consensus_commit_rate_estimation_window_size(&self) -> u32 {
2443 self.consensus_commit_rate_estimation_window_size
2444 .unwrap_or(0)
2445 }
2446
2447 pub fn consensus_num_requested_prior_commits_at_startup(&self) -> u32 {
2448 let window_size = self.get_consensus_commit_rate_estimation_window_size();
2452 assert!(window_size == 0 || self.record_additional_state_digest_in_prologue());
2454 window_size
2455 }
2456
2457 pub fn address_aliases(&self) -> bool {
2458 let address_aliases = self.feature_flags.address_aliases;
2459 assert!(
2460 !address_aliases || self.mysticeti_fastpath(),
2461 "Address aliases requires Mysticeti fastpath to be enabled"
2462 );
2463 if address_aliases {
2464 assert!(
2465 self.feature_flags.disable_preconsensus_locking,
2466 "Address aliases requires CertifiedTransaction to be disabled"
2467 );
2468 }
2469 address_aliases
2470 }
2471
2472 pub fn new_vm_enabled(&self) -> bool {
2473 self.execution_version.is_some_and(|v| v >= 4)
2474 }
2475
2476 pub fn gasless_allowed_token_types(&self) -> &[(String, u64)] {
2477 debug_assert!(self.gasless_allowed_token_types.is_some());
2478 self.gasless_allowed_token_types.as_deref().unwrap_or(&[])
2479 }
2480
2481 pub fn get_gasless_max_unused_inputs(&self) -> u64 {
2482 self.gasless_max_unused_inputs.unwrap_or(u64::MAX)
2483 }
2484
2485 pub fn get_gasless_max_pure_input_bytes(&self) -> u64 {
2486 self.gasless_max_pure_input_bytes.unwrap_or(u64::MAX)
2487 }
2488
2489 pub fn get_gasless_max_tx_size_bytes(&self) -> u64 {
2490 self.gasless_max_tx_size_bytes.unwrap_or(u64::MAX)
2491 }
2492
2493 pub fn include_special_package_amendments_as_option(&self) -> &Option<Arc<Amendments>> {
2494 &self.include_special_package_amendments
2495 }
2496}
2497
2498static POISON_VERSION_METHODS: AtomicBool = AtomicBool::new(false);
2499
2500impl ProtocolConfig {
2502 pub fn get_for_version(version: ProtocolVersion, chain: Chain) -> Self {
2504 assert!(
2506 version >= ProtocolVersion::MIN,
2507 "Network protocol version is {:?}, but the minimum supported version by the binary is {:?}. Please upgrade the binary.",
2508 version,
2509 ProtocolVersion::MIN.0,
2510 );
2511 assert!(
2512 version <= ProtocolVersion::MAX_ALLOWED,
2513 "Network protocol version is {:?}, but the maximum supported version by the binary is {:?}. Please upgrade the binary.",
2514 version,
2515 ProtocolVersion::MAX_ALLOWED.0,
2516 );
2517
2518 let mut ret = Self::get_for_version_impl(version, chain);
2519 ret.version = version;
2520 ret.chain = chain;
2521
2522 ret = Self::apply_config_override(version, ret);
2523
2524 if std::env::var("SUI_PROTOCOL_CONFIG_OVERRIDE_ENABLE").is_ok() {
2525 warn!(
2526 "overriding ProtocolConfig settings with custom settings; this may break non-local networks"
2527 );
2528 let overrides: ProtocolConfigOptional =
2529 serde_env::from_env_with_prefix("SUI_PROTOCOL_CONFIG_OVERRIDE")
2530 .expect("failed to parse ProtocolConfig override env variables");
2531 overrides.apply_to(&mut ret);
2532 }
2533
2534 ret
2535 }
2536
2537 pub fn get_for_version_if_supported(version: ProtocolVersion, chain: Chain) -> Option<Self> {
2540 if version.0 >= ProtocolVersion::MIN.0 && version.0 <= ProtocolVersion::MAX_ALLOWED.0 {
2541 let mut ret = Self::get_for_version_impl(version, chain);
2542 ret.version = version;
2543 ret.chain = chain;
2544 ret = Self::apply_config_override(version, ret);
2545 Some(ret)
2546 } else {
2547 None
2548 }
2549 }
2550
2551 pub fn poison_get_for_min_version() {
2552 POISON_VERSION_METHODS.store(true, Ordering::Relaxed);
2553 }
2554
2555 fn load_poison_get_for_min_version() -> bool {
2556 POISON_VERSION_METHODS.load(Ordering::Relaxed)
2557 }
2558
2559 pub fn get_for_min_version() -> Self {
2562 if Self::load_poison_get_for_min_version() {
2563 panic!("get_for_min_version called on validator");
2564 }
2565 ProtocolConfig::get_for_version(ProtocolVersion::MIN, Chain::Unknown)
2566 }
2567
2568 #[allow(non_snake_case)]
2578 pub fn get_for_max_version_UNSAFE() -> Self {
2579 if Self::load_poison_get_for_min_version() {
2580 panic!("get_for_max_version_UNSAFE called on validator");
2581 }
2582 ProtocolConfig::get_for_version(ProtocolVersion::MAX, Chain::Unknown)
2583 }
2584
2585 fn get_for_version_impl(version: ProtocolVersion, chain: Chain) -> Self {
2586 #[cfg(msim)]
2587 {
2588 if version == ProtocolVersion::MAX_ALLOWED {
2590 let mut config = Self::get_for_version_impl(version - 1, Chain::Unknown);
2591 config.base_tx_cost_fixed = Some(config.base_tx_cost_fixed() + 1000);
2592 return config;
2593 }
2594 }
2595
2596 let mut cfg = Self {
2599 version,
2601 chain,
2602
2603 feature_flags: Default::default(),
2605
2606 max_tx_size_bytes: Some(128 * 1024),
2607 max_input_objects: Some(2048),
2609 max_serialized_tx_effects_size_bytes: Some(512 * 1024),
2610 max_serialized_tx_effects_size_bytes_system_tx: Some(512 * 1024 * 16),
2611 max_gas_payment_objects: Some(256),
2612 max_modules_in_publish: Some(128),
2613 max_package_dependencies: None,
2614 max_arguments: Some(512),
2615 max_type_arguments: Some(16),
2616 max_type_argument_depth: Some(16),
2617 max_pure_argument_size: Some(16 * 1024),
2618 max_programmable_tx_commands: Some(1024),
2619 move_binary_format_version: Some(6),
2620 min_move_binary_format_version: None,
2621 binary_module_handles: None,
2622 binary_struct_handles: None,
2623 binary_function_handles: None,
2624 binary_function_instantiations: None,
2625 binary_signatures: None,
2626 binary_constant_pool: None,
2627 binary_identifiers: None,
2628 binary_address_identifiers: None,
2629 binary_struct_defs: None,
2630 binary_struct_def_instantiations: None,
2631 binary_function_defs: None,
2632 binary_field_handles: None,
2633 binary_field_instantiations: None,
2634 binary_friend_decls: None,
2635 binary_enum_defs: None,
2636 binary_enum_def_instantiations: None,
2637 binary_variant_handles: None,
2638 binary_variant_instantiation_handles: None,
2639 max_move_object_size: Some(250 * 1024),
2640 max_move_package_size: Some(100 * 1024),
2641 max_publish_or_upgrade_per_ptb: None,
2642 max_tx_gas: Some(10_000_000_000),
2643 max_gas_price: Some(100_000),
2644 max_gas_price_rgp_factor_for_aborted_transactions: None,
2645 max_gas_computation_bucket: Some(5_000_000),
2646 max_loop_depth: Some(5),
2647 max_generic_instantiation_length: Some(32),
2648 max_function_parameters: Some(128),
2649 max_basic_blocks: Some(1024),
2650 max_value_stack_size: Some(1024),
2651 max_type_nodes: Some(256),
2652 max_generic_instantiation_type_nodes_per_function: None,
2653 max_generic_instantiation_type_nodes_per_module: None,
2654 max_accumulator_type_nodes: None,
2655 max_push_size: Some(10000),
2656 max_struct_definitions: Some(200),
2657 max_function_definitions: Some(1000),
2658 max_fields_in_struct: Some(32),
2659 max_dependency_depth: Some(100),
2660 max_num_event_emit: Some(256),
2661 max_num_new_move_object_ids: Some(2048),
2662 max_num_new_move_object_ids_system_tx: Some(2048 * 16),
2663 max_num_deleted_move_object_ids: Some(2048),
2664 max_num_deleted_move_object_ids_system_tx: Some(2048 * 16),
2665 max_num_transferred_move_object_ids: Some(2048),
2666 max_num_transferred_move_object_ids_system_tx: Some(2048 * 16),
2667 max_event_emit_size: Some(250 * 1024),
2668 max_move_vector_len: Some(256 * 1024),
2669 max_type_to_layout_nodes: None,
2670 max_ptb_value_size: None,
2671
2672 max_back_edges_per_function: Some(10_000),
2673 max_back_edges_per_module: Some(10_000),
2674 max_verifier_meter_ticks_per_function: Some(6_000_000),
2675 max_meter_ticks_per_module: Some(6_000_000),
2676 max_meter_ticks_per_package: None,
2677
2678 object_runtime_max_num_cached_objects: Some(1000),
2679 object_runtime_max_num_cached_objects_system_tx: Some(1000 * 16),
2680 object_runtime_max_num_store_entries: Some(1000),
2681 object_runtime_max_num_store_entries_system_tx: Some(1000 * 16),
2682 base_tx_cost_fixed: Some(110_000),
2683 package_publish_cost_fixed: Some(1_000),
2684 base_tx_cost_per_byte: Some(0),
2685 package_publish_cost_per_byte: Some(80),
2686 obj_access_cost_read_per_byte: Some(15),
2687 obj_access_cost_mutate_per_byte: Some(40),
2688 obj_access_cost_delete_per_byte: Some(40),
2689 obj_access_cost_verify_per_byte: Some(200),
2690 obj_data_cost_refundable: Some(100),
2691 obj_metadata_cost_non_refundable: Some(50),
2692 gas_model_version: Some(1),
2693 storage_rebate_rate: Some(9900),
2694 storage_fund_reinvest_rate: Some(500),
2695 reward_slashing_rate: Some(5000),
2696 storage_gas_price: Some(1),
2697 accumulator_object_storage_cost: None,
2698 max_transactions_per_checkpoint: Some(10_000),
2699 max_checkpoint_size_bytes: Some(30 * 1024 * 1024),
2700
2701 buffer_stake_for_protocol_upgrade_bps: Some(0),
2704
2705 address_from_bytes_cost_base: Some(52),
2709 address_to_u256_cost_base: Some(52),
2711 address_from_u256_cost_base: Some(52),
2713
2714 config_read_setting_impl_cost_base: None,
2717 config_read_setting_impl_cost_per_byte: None,
2718
2719 package_original_package_id_impl_cost_base: None,
2720 package_original_package_id_impl_cost_per_byte: None,
2721
2722 dynamic_field_hash_type_and_key_cost_base: Some(100),
2725 dynamic_field_hash_type_and_key_type_cost_per_byte: Some(2),
2726 dynamic_field_hash_type_and_key_value_cost_per_byte: Some(2),
2727 dynamic_field_hash_type_and_key_type_tag_cost_per_byte: Some(2),
2728 dynamic_field_add_child_object_cost_base: Some(100),
2730 dynamic_field_add_child_object_type_cost_per_byte: Some(10),
2731 dynamic_field_add_child_object_value_cost_per_byte: Some(10),
2732 dynamic_field_add_child_object_struct_tag_cost_per_byte: Some(10),
2733 dynamic_field_borrow_child_object_cost_base: Some(100),
2735 dynamic_field_borrow_child_object_child_ref_cost_per_byte: Some(10),
2736 dynamic_field_borrow_child_object_type_cost_per_byte: Some(10),
2737 dynamic_field_remove_child_object_cost_base: Some(100),
2739 dynamic_field_remove_child_object_child_cost_per_byte: Some(2),
2740 dynamic_field_remove_child_object_type_cost_per_byte: Some(2),
2741 dynamic_field_has_child_object_cost_base: Some(100),
2743 dynamic_field_has_child_object_with_ty_cost_base: Some(100),
2745 dynamic_field_has_child_object_with_ty_type_cost_per_byte: Some(2),
2746 dynamic_field_has_child_object_with_ty_type_tag_cost_per_byte: Some(2),
2747
2748 scratch_add_cost_base: None,
2750 scratch_read_cost_base: None,
2751 scratch_read_value_cost: None,
2752 scratch_remove_cost_base: None,
2753 scratch_exists_cost_base: None,
2754 scratch_exists_with_type_cost_base: None,
2755 scratch_exists_with_type_type_cost: None,
2756 max_scratch_pad_size: None,
2757
2758 event_emit_cost_base: Some(52),
2761 event_emit_value_size_derivation_cost_per_byte: Some(2),
2762 event_emit_tag_size_derivation_cost_per_byte: Some(5),
2763 event_emit_output_cost_per_byte: Some(10),
2764 event_emit_auth_stream_cost: None,
2765
2766 reserve_object_funds_for_withdrawal_cost_base: None,
2768 reserve_object_funds_for_withdrawal_cold_read_cost: None,
2769
2770 object_borrow_uid_cost_base: Some(52),
2773 object_delete_impl_cost_base: Some(52),
2775 object_record_new_uid_cost_base: Some(52),
2777 object_record_new_uid_from_hash_cost_base: None,
2780
2781 transfer_transfer_internal_cost_base: Some(52),
2784 transfer_party_transfer_internal_cost_base: None,
2786 transfer_freeze_object_cost_base: Some(52),
2788 transfer_share_object_cost_base: Some(52),
2790 transfer_receive_object_cost_base: None,
2791 transfer_receive_object_type_cost_per_byte: None,
2792 transfer_receive_object_cost_per_byte: None,
2793
2794 tx_context_derive_id_cost_base: Some(52),
2797 tx_context_fresh_id_cost_base: None,
2798 tx_context_sender_cost_base: None,
2799 tx_context_epoch_cost_base: None,
2800 tx_context_epoch_timestamp_ms_cost_base: None,
2801 tx_context_sponsor_cost_base: None,
2802 tx_context_rgp_cost_base: None,
2803 tx_context_gas_price_cost_base: None,
2804 tx_context_gas_budget_cost_base: None,
2805 tx_context_ids_created_cost_base: None,
2806 tx_context_replace_cost_base: None,
2807
2808 types_is_one_time_witness_cost_base: Some(52),
2811 types_is_one_time_witness_type_tag_cost_per_byte: Some(2),
2812 types_is_one_time_witness_type_cost_per_byte: Some(2),
2813
2814 validator_validate_metadata_cost_base: Some(52),
2817 validator_validate_metadata_data_cost_per_byte: Some(2),
2818
2819 crypto_invalid_arguments_cost: Some(100),
2821 bls12381_bls12381_min_sig_verify_cost_base: Some(52),
2823 bls12381_bls12381_min_sig_verify_msg_cost_per_byte: Some(2),
2824 bls12381_bls12381_min_sig_verify_msg_cost_per_block: Some(2),
2825
2826 bls12381_bls12381_min_pk_verify_cost_base: Some(52),
2828 bls12381_bls12381_min_pk_verify_msg_cost_per_byte: Some(2),
2829 bls12381_bls12381_min_pk_verify_msg_cost_per_block: Some(2),
2830
2831 ecdsa_k1_ecrecover_keccak256_cost_base: Some(52),
2833 ecdsa_k1_ecrecover_keccak256_msg_cost_per_byte: Some(2),
2834 ecdsa_k1_ecrecover_keccak256_msg_cost_per_block: Some(2),
2835 ecdsa_k1_ecrecover_sha256_cost_base: Some(52),
2836 ecdsa_k1_ecrecover_sha256_msg_cost_per_byte: Some(2),
2837 ecdsa_k1_ecrecover_sha256_msg_cost_per_block: Some(2),
2838
2839 ecdsa_k1_decompress_pubkey_cost_base: Some(52),
2841
2842 ecdsa_k1_secp256k1_verify_keccak256_cost_base: Some(52),
2844 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_byte: Some(2),
2845 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_block: Some(2),
2846 ecdsa_k1_secp256k1_verify_sha256_cost_base: Some(52),
2847 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_byte: Some(2),
2848 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_block: Some(2),
2849
2850 ecdsa_r1_ecrecover_keccak256_cost_base: Some(52),
2852 ecdsa_r1_ecrecover_keccak256_msg_cost_per_byte: Some(2),
2853 ecdsa_r1_ecrecover_keccak256_msg_cost_per_block: Some(2),
2854 ecdsa_r1_ecrecover_sha256_cost_base: Some(52),
2855 ecdsa_r1_ecrecover_sha256_msg_cost_per_byte: Some(2),
2856 ecdsa_r1_ecrecover_sha256_msg_cost_per_block: Some(2),
2857
2858 ecdsa_r1_secp256r1_verify_keccak256_cost_base: Some(52),
2860 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_byte: Some(2),
2861 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_block: Some(2),
2862 ecdsa_r1_secp256r1_verify_sha256_cost_base: Some(52),
2863 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_byte: Some(2),
2864 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_block: Some(2),
2865
2866 ecvrf_ecvrf_verify_cost_base: Some(52),
2868 ecvrf_ecvrf_verify_alpha_string_cost_per_byte: Some(2),
2869 ecvrf_ecvrf_verify_alpha_string_cost_per_block: Some(2),
2870
2871 ed25519_ed25519_verify_cost_base: Some(52),
2873 ed25519_ed25519_verify_msg_cost_per_byte: Some(2),
2874 ed25519_ed25519_verify_msg_cost_per_block: Some(2),
2875
2876 groth16_prepare_verifying_key_bls12381_cost_base: Some(52),
2878 groth16_prepare_verifying_key_bn254_cost_base: Some(52),
2879
2880 groth16_verify_groth16_proof_internal_bls12381_cost_base: Some(52),
2882 groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input: Some(2),
2883 groth16_verify_groth16_proof_internal_bn254_cost_base: Some(52),
2884 groth16_verify_groth16_proof_internal_bn254_cost_per_public_input: Some(2),
2885 groth16_verify_groth16_proof_internal_public_input_cost_per_byte: Some(2),
2886
2887 hash_blake2b256_cost_base: Some(52),
2889 hash_blake2b256_data_cost_per_byte: Some(2),
2890 hash_blake2b256_data_cost_per_block: Some(2),
2891
2892 hash_keccak256_cost_base: Some(52),
2894 hash_keccak256_data_cost_per_byte: Some(2),
2895 hash_keccak256_data_cost_per_block: Some(2),
2896
2897 poseidon_bn254_cost_base: None,
2898 poseidon_bn254_cost_per_block: None,
2899
2900 hmac_hmac_sha3_256_cost_base: Some(52),
2902 hmac_hmac_sha3_256_input_cost_per_byte: Some(2),
2903 hmac_hmac_sha3_256_input_cost_per_block: Some(2),
2904
2905 group_ops_bls12381_decode_scalar_cost: None,
2907 group_ops_bls12381_decode_g1_cost: None,
2908 group_ops_bls12381_decode_g2_cost: None,
2909 group_ops_bls12381_decode_gt_cost: None,
2910 group_ops_bls12381_scalar_add_cost: None,
2911 group_ops_bls12381_g1_add_cost: None,
2912 group_ops_bls12381_g2_add_cost: None,
2913 group_ops_bls12381_gt_add_cost: None,
2914 group_ops_bls12381_scalar_sub_cost: None,
2915 group_ops_bls12381_g1_sub_cost: None,
2916 group_ops_bls12381_g2_sub_cost: None,
2917 group_ops_bls12381_gt_sub_cost: None,
2918 group_ops_bls12381_scalar_mul_cost: None,
2919 group_ops_bls12381_g1_mul_cost: None,
2920 group_ops_bls12381_g2_mul_cost: None,
2921 group_ops_bls12381_gt_mul_cost: None,
2922 group_ops_bls12381_scalar_div_cost: None,
2923 group_ops_bls12381_g1_div_cost: None,
2924 group_ops_bls12381_g2_div_cost: None,
2925 group_ops_bls12381_gt_div_cost: None,
2926 group_ops_bls12381_g1_hash_to_base_cost: None,
2927 group_ops_bls12381_g2_hash_to_base_cost: None,
2928 group_ops_bls12381_g1_hash_to_cost_per_byte: None,
2929 group_ops_bls12381_g2_hash_to_cost_per_byte: None,
2930 group_ops_bls12381_g1_msm_base_cost: None,
2931 group_ops_bls12381_g2_msm_base_cost: None,
2932 group_ops_bls12381_g1_msm_base_cost_per_input: None,
2933 group_ops_bls12381_g2_msm_base_cost_per_input: None,
2934 group_ops_bls12381_msm_max_len: None,
2935 group_ops_bls12381_pairing_cost: None,
2936 group_ops_bls12381_g1_to_uncompressed_g1_cost: None,
2937 group_ops_bls12381_uncompressed_g1_to_g1_cost: None,
2938 group_ops_bls12381_uncompressed_g1_sum_base_cost: None,
2939 group_ops_bls12381_uncompressed_g1_sum_cost_per_term: None,
2940 group_ops_bls12381_uncompressed_g1_sum_max_terms: None,
2941
2942 group_ops_ristretto_decode_scalar_cost: None,
2943 group_ops_ristretto_decode_point_cost: None,
2944 group_ops_ristretto_scalar_add_cost: None,
2945 group_ops_ristretto_point_add_cost: None,
2946 group_ops_ristretto_scalar_sub_cost: None,
2947 group_ops_ristretto_point_sub_cost: None,
2948 group_ops_ristretto_scalar_mul_cost: None,
2949 group_ops_ristretto_point_mul_cost: None,
2950 group_ops_ristretto_scalar_div_cost: None,
2951 group_ops_ristretto_point_div_cost: None,
2952
2953 verify_bulletproofs_ristretto255_base_cost: None,
2954 verify_bulletproofs_ristretto255_cost_per_bit_and_commitment: None,
2955 max_bulletproofs_total_bits: None,
2956
2957 check_zklogin_id_cost_base: None,
2959 check_zklogin_issuer_cost_base: None,
2961
2962 vdf_verify_vdf_cost: None,
2963 vdf_hash_to_input_cost: None,
2964
2965 nitro_attestation_parse_base_cost: None,
2967 nitro_attestation_parse_cost_per_byte: None,
2968 nitro_attestation_verify_base_cost: None,
2969 nitro_attestation_verify_cost_per_cert: None,
2970
2971 bcs_per_byte_serialized_cost: None,
2972 bcs_legacy_min_output_size_cost: None,
2973 bcs_failure_cost: None,
2974 hash_sha2_256_base_cost: None,
2975 hash_sha2_256_per_byte_cost: None,
2976 hash_sha2_256_legacy_min_input_len_cost: None,
2977 hash_sha3_256_base_cost: None,
2978 hash_sha3_256_per_byte_cost: None,
2979 hash_sha3_256_legacy_min_input_len_cost: None,
2980 type_name_get_base_cost: None,
2981 type_name_get_per_byte_cost: None,
2982 type_name_id_base_cost: None,
2983 string_check_utf8_base_cost: None,
2984 string_check_utf8_per_byte_cost: None,
2985 string_is_char_boundary_base_cost: None,
2986 string_sub_string_base_cost: None,
2987 string_sub_string_per_byte_cost: None,
2988 string_index_of_base_cost: None,
2989 string_index_of_per_byte_pattern_cost: None,
2990 string_index_of_per_byte_searched_cost: None,
2991 vector_empty_base_cost: None,
2992 vector_length_base_cost: None,
2993 vector_push_back_base_cost: None,
2994 vector_push_back_legacy_per_abstract_memory_unit_cost: None,
2995 vector_borrow_base_cost: None,
2996 vector_pop_back_base_cost: None,
2997 vector_destroy_empty_base_cost: None,
2998 vector_swap_base_cost: None,
2999 debug_print_base_cost: None,
3000 debug_print_stack_trace_base_cost: None,
3001
3002 max_size_written_objects: None,
3003 max_size_written_objects_system_tx: None,
3004
3005 max_move_identifier_len: None,
3012 max_move_value_depth: None,
3013 package_arena_size_in_bytes: None,
3014 max_move_enum_variants: None,
3015
3016 gas_rounding_step: None,
3017
3018 execution_version: None,
3019
3020 max_event_emit_size_total: None,
3021
3022 consensus_bad_nodes_stake_threshold: None,
3023
3024 max_jwk_votes_per_validator_per_epoch: None,
3025
3026 max_age_of_jwk_in_epochs: None,
3027
3028 random_beacon_reduction_allowed_delta: None,
3029
3030 random_beacon_reduction_lower_bound: None,
3031
3032 random_beacon_dkg_timeout_round: None,
3033
3034 random_beacon_min_round_interval_ms: None,
3035
3036 random_beacon_dkg_version: None,
3037
3038 consensus_max_transaction_size_bytes: None,
3039
3040 consensus_max_transactions_in_block_bytes: None,
3041
3042 consensus_max_num_transactions_in_block: None,
3043
3044 consensus_voting_rounds: None,
3045
3046 max_accumulated_txn_cost_per_object_in_narwhal_commit: None,
3047
3048 max_deferral_rounds_for_congestion_control: None,
3049
3050 epoch_close_deadline_ms: None,
3051
3052 max_txn_cost_overage_per_object_in_commit: None,
3053
3054 allowed_txn_cost_overage_burst_per_object_in_commit: None,
3055
3056 min_checkpoint_interval_ms: None,
3057
3058 checkpoint_summary_version_specific_data: None,
3059
3060 max_soft_bundle_size: None,
3061
3062 bridge_should_try_to_finalize_committee: None,
3063
3064 max_accumulated_txn_cost_per_object_in_mysticeti_commit: None,
3065
3066 max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit: None,
3067
3068 consensus_gc_depth: None,
3069
3070 gas_budget_based_txn_cost_cap_factor: None,
3071
3072 gas_budget_based_txn_cost_absolute_cap_commit_count: None,
3073
3074 sip_45_consensus_amplification_threshold: None,
3075
3076 use_object_per_epoch_marker_table_v2: None,
3077
3078 consensus_commit_rate_estimation_window_size: None,
3079
3080 aliased_addresses: vec![],
3081
3082 translation_per_command_base_charge: None,
3083 translation_per_input_base_charge: None,
3084 translation_pure_input_per_byte_charge: None,
3085 translation_per_type_node_charge: None,
3086 translation_per_reference_node_charge: None,
3087 translation_per_linkage_entry_charge: None,
3088 translation_per_live_reference_charge: None,
3089 max_ptb_live_references: None,
3090 max_ptb_returned_references: None,
3091 max_ptb_total_returned_references: None,
3092
3093 max_updates_per_settlement_txn: None,
3094
3095 gasless_max_computation_units: None,
3096 gasless_allowed_token_types: None,
3097 gasless_max_unused_inputs: None,
3098 gasless_max_pure_input_bytes: None,
3099 gasless_max_tps: None,
3100 include_special_package_amendments: None,
3101 gasless_max_tx_size_bytes: None,
3102 };
3105 for cur in 2..=version.0 {
3106 match cur {
3107 1 => unreachable!(),
3108 2 => {
3109 cfg.feature_flags.advance_epoch_start_time_in_safe_mode = true;
3110 }
3111 3 => {
3112 cfg.gas_model_version = Some(2);
3114 cfg.max_tx_gas = Some(50_000_000_000);
3116 cfg.base_tx_cost_fixed = Some(2_000);
3118 cfg.storage_gas_price = Some(76);
3120 cfg.feature_flags.loaded_child_objects_fixed = true;
3121 cfg.max_size_written_objects = Some(5 * 1000 * 1000);
3124 cfg.max_size_written_objects_system_tx = Some(50 * 1000 * 1000);
3127 cfg.feature_flags.package_upgrades = true;
3128 }
3129 4 => {
3134 cfg.reward_slashing_rate = Some(10000);
3136 cfg.gas_model_version = Some(3);
3138 }
3139 5 => {
3140 cfg.feature_flags.missing_type_is_compatibility_error = true;
3141 cfg.gas_model_version = Some(4);
3142 cfg.feature_flags.scoring_decision_with_validity_cutoff = true;
3143 }
3147 6 => {
3148 cfg.gas_model_version = Some(5);
3149 cfg.buffer_stake_for_protocol_upgrade_bps = Some(5000);
3150 cfg.feature_flags.consensus_order_end_of_epoch_last = true;
3151 }
3152 7 => {
3153 cfg.feature_flags.disallow_adding_abilities_on_upgrade = true;
3154 cfg.feature_flags
3155 .disable_invariant_violation_check_in_swap_loc = true;
3156 cfg.feature_flags.ban_entry_init = true;
3157 cfg.feature_flags.package_digest_hash_module = true;
3158 }
3159 8 => {
3160 cfg.feature_flags
3161 .disallow_change_struct_type_params_on_upgrade = true;
3162 }
3163 9 => {
3164 cfg.max_move_identifier_len = Some(128);
3166 cfg.feature_flags.no_extraneous_module_bytes = true;
3167 cfg.feature_flags
3168 .advance_to_highest_supported_protocol_version = true;
3169 }
3170 10 => {
3171 cfg.max_verifier_meter_ticks_per_function = Some(16_000_000);
3172 cfg.max_meter_ticks_per_module = Some(16_000_000);
3173 }
3174 11 => {
3175 cfg.max_move_value_depth = Some(128);
3176 }
3177 12 => {
3178 cfg.feature_flags.narwhal_versioned_metadata = true;
3179 if chain != Chain::Mainnet {
3180 cfg.feature_flags.commit_root_state_digest = true;
3181 }
3182
3183 if chain != Chain::Mainnet && chain != Chain::Testnet {
3184 cfg.feature_flags.zklogin_auth = true;
3185 }
3186 }
3187 13 => {}
3188 14 => {
3189 cfg.gas_rounding_step = Some(1_000);
3190 cfg.gas_model_version = Some(6);
3191 }
3192 15 => {
3193 cfg.feature_flags.consensus_transaction_ordering =
3194 ConsensusTransactionOrdering::ByGasPrice;
3195 }
3196 16 => {
3197 cfg.feature_flags.simplified_unwrap_then_delete = true;
3198 }
3199 17 => {
3200 cfg.feature_flags.upgraded_multisig_supported = true;
3201 }
3202 18 => {
3203 cfg.execution_version = Some(1);
3204 cfg.feature_flags.txn_base_cost_as_multiplier = true;
3213 cfg.base_tx_cost_fixed = Some(1_000);
3215 }
3216 19 => {
3217 cfg.max_num_event_emit = Some(1024);
3218 cfg.max_event_emit_size_total = Some(
3221 256 * 250 * 1024, );
3223 }
3224 20 => {
3225 cfg.feature_flags.commit_root_state_digest = true;
3226
3227 if chain != Chain::Mainnet {
3228 cfg.feature_flags.narwhal_new_leader_election_schedule = true;
3229 cfg.consensus_bad_nodes_stake_threshold = Some(20);
3230 }
3231 }
3232
3233 21 => {
3234 if chain != Chain::Mainnet {
3235 cfg.feature_flags.zklogin_supported_providers = BTreeSet::from([
3236 "Google".to_string(),
3237 "Facebook".to_string(),
3238 "Twitch".to_string(),
3239 ]);
3240 }
3241 }
3242 22 => {
3243 cfg.feature_flags.loaded_child_object_format = true;
3244 }
3245 23 => {
3246 cfg.feature_flags.loaded_child_object_format_type = true;
3247 cfg.feature_flags.narwhal_new_leader_election_schedule = true;
3248 cfg.consensus_bad_nodes_stake_threshold = Some(20);
3254 }
3255 24 => {
3256 cfg.feature_flags.simple_conservation_checks = true;
3257 cfg.max_publish_or_upgrade_per_ptb = Some(5);
3258
3259 cfg.feature_flags.end_of_epoch_transaction_supported = true;
3260
3261 if chain != Chain::Mainnet {
3262 cfg.feature_flags.enable_jwk_consensus_updates = true;
3263 cfg.max_jwk_votes_per_validator_per_epoch = Some(240);
3265 cfg.max_age_of_jwk_in_epochs = Some(1);
3266 }
3267 }
3268 25 => {
3269 cfg.feature_flags.zklogin_supported_providers = BTreeSet::from([
3271 "Google".to_string(),
3272 "Facebook".to_string(),
3273 "Twitch".to_string(),
3274 ]);
3275 cfg.feature_flags.zklogin_auth = true;
3276
3277 cfg.feature_flags.enable_jwk_consensus_updates = true;
3279 cfg.max_jwk_votes_per_validator_per_epoch = Some(240);
3280 cfg.max_age_of_jwk_in_epochs = Some(1);
3281 }
3282 26 => {
3283 cfg.gas_model_version = Some(7);
3284 if chain != Chain::Mainnet && chain != Chain::Testnet {
3286 cfg.transfer_receive_object_cost_base = Some(52);
3287 cfg.feature_flags.receive_objects = true;
3288 }
3289 }
3290 27 => {
3291 cfg.gas_model_version = Some(8);
3292 }
3293 28 => {
3294 cfg.check_zklogin_id_cost_base = Some(200);
3296 cfg.check_zklogin_issuer_cost_base = Some(200);
3298
3299 if chain != Chain::Mainnet && chain != Chain::Testnet {
3301 cfg.feature_flags.enable_effects_v2 = true;
3302 }
3303 }
3304 29 => {
3305 cfg.feature_flags.verify_legacy_zklogin_address = true;
3306 }
3307 30 => {
3308 if chain != Chain::Mainnet {
3310 cfg.feature_flags.narwhal_certificate_v2 = true;
3311 }
3312
3313 cfg.random_beacon_reduction_allowed_delta = Some(800);
3314 if chain != Chain::Mainnet {
3316 cfg.feature_flags.enable_effects_v2 = true;
3317 }
3318
3319 cfg.feature_flags.zklogin_supported_providers = BTreeSet::default();
3323
3324 cfg.feature_flags.recompute_has_public_transfer_in_execution = true;
3325 }
3326 31 => {
3327 cfg.execution_version = Some(2);
3328 if chain != Chain::Mainnet && chain != Chain::Testnet {
3330 cfg.feature_flags.shared_object_deletion = true;
3331 }
3332 }
3333 32 => {
3334 if chain != Chain::Mainnet {
3336 cfg.feature_flags.accept_zklogin_in_multisig = true;
3337 }
3338 if chain != Chain::Mainnet {
3340 cfg.transfer_receive_object_cost_base = Some(52);
3341 cfg.feature_flags.receive_objects = true;
3342 }
3343 if chain != Chain::Mainnet && chain != Chain::Testnet {
3345 cfg.feature_flags.random_beacon = true;
3346 cfg.random_beacon_reduction_lower_bound = Some(1600);
3347 cfg.random_beacon_dkg_timeout_round = Some(3000);
3348 cfg.random_beacon_min_round_interval_ms = Some(150);
3349 }
3350 if chain != Chain::Testnet && chain != Chain::Mainnet {
3352 cfg.feature_flags.include_consensus_digest_in_prologue = true;
3353 }
3354
3355 cfg.feature_flags.narwhal_certificate_v2 = true;
3357 }
3358 33 => {
3359 cfg.feature_flags.hardened_otw_check = true;
3360 cfg.feature_flags.allow_receiving_object_id = true;
3361
3362 cfg.transfer_receive_object_cost_base = Some(52);
3364 cfg.feature_flags.receive_objects = true;
3365
3366 if chain != Chain::Mainnet {
3368 cfg.feature_flags.shared_object_deletion = true;
3369 }
3370
3371 cfg.feature_flags.enable_effects_v2 = true;
3372 }
3373 34 => {}
3374 35 => {
3375 if chain != Chain::Mainnet && chain != Chain::Testnet {
3377 cfg.feature_flags.enable_poseidon = true;
3378 cfg.poseidon_bn254_cost_base = Some(260);
3379 cfg.poseidon_bn254_cost_per_block = Some(10);
3380 }
3381
3382 cfg.feature_flags.enable_coin_deny_list = true;
3383 }
3384 36 => {
3385 if chain != Chain::Mainnet && chain != Chain::Testnet {
3387 cfg.feature_flags.enable_group_ops_native_functions = true;
3388 cfg.feature_flags.enable_group_ops_native_function_msm = true;
3389 cfg.group_ops_bls12381_decode_scalar_cost = Some(52);
3391 cfg.group_ops_bls12381_decode_g1_cost = Some(52);
3392 cfg.group_ops_bls12381_decode_g2_cost = Some(52);
3393 cfg.group_ops_bls12381_decode_gt_cost = Some(52);
3394 cfg.group_ops_bls12381_scalar_add_cost = Some(52);
3395 cfg.group_ops_bls12381_g1_add_cost = Some(52);
3396 cfg.group_ops_bls12381_g2_add_cost = Some(52);
3397 cfg.group_ops_bls12381_gt_add_cost = Some(52);
3398 cfg.group_ops_bls12381_scalar_sub_cost = Some(52);
3399 cfg.group_ops_bls12381_g1_sub_cost = Some(52);
3400 cfg.group_ops_bls12381_g2_sub_cost = Some(52);
3401 cfg.group_ops_bls12381_gt_sub_cost = Some(52);
3402 cfg.group_ops_bls12381_scalar_mul_cost = Some(52);
3403 cfg.group_ops_bls12381_g1_mul_cost = Some(52);
3404 cfg.group_ops_bls12381_g2_mul_cost = Some(52);
3405 cfg.group_ops_bls12381_gt_mul_cost = Some(52);
3406 cfg.group_ops_bls12381_scalar_div_cost = Some(52);
3407 cfg.group_ops_bls12381_g1_div_cost = Some(52);
3408 cfg.group_ops_bls12381_g2_div_cost = Some(52);
3409 cfg.group_ops_bls12381_gt_div_cost = Some(52);
3410 cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(52);
3411 cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(52);
3412 cfg.group_ops_bls12381_g1_hash_to_cost_per_byte = Some(2);
3413 cfg.group_ops_bls12381_g2_hash_to_cost_per_byte = Some(2);
3414 cfg.group_ops_bls12381_g1_msm_base_cost = Some(52);
3415 cfg.group_ops_bls12381_g2_msm_base_cost = Some(52);
3416 cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(52);
3417 cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(52);
3418 cfg.group_ops_bls12381_msm_max_len = Some(32);
3419 cfg.group_ops_bls12381_pairing_cost = Some(52);
3420 }
3421 cfg.feature_flags.shared_object_deletion = true;
3423
3424 cfg.consensus_max_transaction_size_bytes = Some(256 * 1024); cfg.consensus_max_transactions_in_block_bytes = Some(6 * 1_024 * 1024);
3426 }
3428 37 => {
3429 cfg.feature_flags.reject_mutable_random_on_entry_functions = true;
3430
3431 if chain != Chain::Mainnet {
3433 cfg.feature_flags.include_consensus_digest_in_prologue = true;
3434 }
3435 }
3436 38 => {
3437 cfg.binary_module_handles = Some(100);
3438 cfg.binary_struct_handles = Some(300);
3439 cfg.binary_function_handles = Some(1500);
3440 cfg.binary_function_instantiations = Some(750);
3441 cfg.binary_signatures = Some(1000);
3442 cfg.binary_constant_pool = Some(4000);
3446 cfg.binary_identifiers = Some(10000);
3447 cfg.binary_address_identifiers = Some(100);
3448 cfg.binary_struct_defs = Some(200);
3449 cfg.binary_struct_def_instantiations = Some(100);
3450 cfg.binary_function_defs = Some(1000);
3451 cfg.binary_field_handles = Some(500);
3452 cfg.binary_field_instantiations = Some(250);
3453 cfg.binary_friend_decls = Some(100);
3454 cfg.max_package_dependencies = Some(32);
3456 cfg.max_modules_in_publish = Some(64);
3457 cfg.execution_version = Some(3);
3459 }
3460 39 => {
3461 }
3463 40 => {}
3464 41 => {
3465 cfg.feature_flags.enable_group_ops_native_functions = true;
3467 cfg.group_ops_bls12381_decode_scalar_cost = Some(52);
3469 cfg.group_ops_bls12381_decode_g1_cost = Some(52);
3470 cfg.group_ops_bls12381_decode_g2_cost = Some(52);
3471 cfg.group_ops_bls12381_decode_gt_cost = Some(52);
3472 cfg.group_ops_bls12381_scalar_add_cost = Some(52);
3473 cfg.group_ops_bls12381_g1_add_cost = Some(52);
3474 cfg.group_ops_bls12381_g2_add_cost = Some(52);
3475 cfg.group_ops_bls12381_gt_add_cost = Some(52);
3476 cfg.group_ops_bls12381_scalar_sub_cost = Some(52);
3477 cfg.group_ops_bls12381_g1_sub_cost = Some(52);
3478 cfg.group_ops_bls12381_g2_sub_cost = Some(52);
3479 cfg.group_ops_bls12381_gt_sub_cost = Some(52);
3480 cfg.group_ops_bls12381_scalar_mul_cost = Some(52);
3481 cfg.group_ops_bls12381_g1_mul_cost = Some(52);
3482 cfg.group_ops_bls12381_g2_mul_cost = Some(52);
3483 cfg.group_ops_bls12381_gt_mul_cost = Some(52);
3484 cfg.group_ops_bls12381_scalar_div_cost = Some(52);
3485 cfg.group_ops_bls12381_g1_div_cost = Some(52);
3486 cfg.group_ops_bls12381_g2_div_cost = Some(52);
3487 cfg.group_ops_bls12381_gt_div_cost = Some(52);
3488 cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(52);
3489 cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(52);
3490 cfg.group_ops_bls12381_g1_hash_to_cost_per_byte = Some(2);
3491 cfg.group_ops_bls12381_g2_hash_to_cost_per_byte = Some(2);
3492 cfg.group_ops_bls12381_g1_msm_base_cost = Some(52);
3493 cfg.group_ops_bls12381_g2_msm_base_cost = Some(52);
3494 cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(52);
3495 cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(52);
3496 cfg.group_ops_bls12381_msm_max_len = Some(32);
3497 cfg.group_ops_bls12381_pairing_cost = Some(52);
3498 }
3499 42 => {}
3500 43 => {
3501 cfg.feature_flags.zklogin_max_epoch_upper_bound_delta = Some(30);
3502 cfg.max_meter_ticks_per_package = Some(16_000_000);
3503 }
3504 44 => {
3505 cfg.feature_flags.include_consensus_digest_in_prologue = true;
3507 if chain != Chain::Mainnet {
3509 cfg.feature_flags.consensus_choice = ConsensusChoice::SwapEachEpoch;
3510 }
3511 }
3512 45 => {
3513 if chain != Chain::Testnet && chain != Chain::Mainnet {
3515 cfg.feature_flags.consensus_network = ConsensusNetwork::Tonic;
3516 }
3517
3518 if chain != Chain::Mainnet {
3519 cfg.feature_flags.mysticeti_leader_scoring_and_schedule = true;
3521 }
3522 cfg.min_move_binary_format_version = Some(6);
3523 cfg.feature_flags.accept_zklogin_in_multisig = true;
3524
3525 if chain != Chain::Mainnet && chain != Chain::Testnet {
3529 cfg.feature_flags.bridge = true;
3530 }
3531 }
3532 46 => {
3533 if chain != Chain::Mainnet {
3535 cfg.feature_flags.bridge = true;
3536 }
3537
3538 cfg.feature_flags.reshare_at_same_initial_version = true;
3540 }
3541 47 => {}
3542 48 => {
3543 cfg.feature_flags.consensus_network = ConsensusNetwork::Tonic;
3545
3546 cfg.feature_flags.resolve_abort_locations_to_package_id = true;
3548
3549 if chain != Chain::Mainnet {
3551 cfg.feature_flags.random_beacon = true;
3552 cfg.random_beacon_reduction_lower_bound = Some(1600);
3553 cfg.random_beacon_dkg_timeout_round = Some(3000);
3554 cfg.random_beacon_min_round_interval_ms = Some(200);
3555 }
3556
3557 cfg.feature_flags.mysticeti_use_committed_subdag_digest = true;
3559 }
3560 49 => {
3561 if chain != Chain::Testnet && chain != Chain::Mainnet {
3562 cfg.move_binary_format_version = Some(7);
3563 }
3564
3565 if chain != Chain::Mainnet && chain != Chain::Testnet {
3567 cfg.feature_flags.enable_vdf = true;
3568 cfg.vdf_verify_vdf_cost = Some(1500);
3571 cfg.vdf_hash_to_input_cost = Some(100);
3572 }
3573
3574 if chain != Chain::Testnet && chain != Chain::Mainnet {
3576 cfg.feature_flags
3577 .record_consensus_determined_version_assignments_in_prologue = true;
3578 }
3579
3580 if chain != Chain::Mainnet {
3582 cfg.feature_flags.consensus_choice = ConsensusChoice::Mysticeti;
3583 }
3584
3585 cfg.feature_flags.fresh_vm_on_framework_upgrade = true;
3587 }
3588 50 => {
3589 if chain != Chain::Mainnet {
3591 cfg.checkpoint_summary_version_specific_data = Some(1);
3592 cfg.min_checkpoint_interval_ms = Some(200);
3593 }
3594
3595 if chain != Chain::Testnet && chain != Chain::Mainnet {
3597 cfg.feature_flags
3598 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = true;
3599 }
3600
3601 cfg.feature_flags.mysticeti_num_leaders_per_round = Some(1);
3602
3603 cfg.max_deferral_rounds_for_congestion_control = Some(10);
3605 }
3606 51 => {
3607 cfg.random_beacon_dkg_version = Some(1);
3608
3609 if chain != Chain::Testnet && chain != Chain::Mainnet {
3610 cfg.feature_flags.enable_coin_deny_list_v2 = true;
3611 }
3612 }
3613 52 => {
3614 if chain != Chain::Mainnet {
3615 cfg.feature_flags.soft_bundle = true;
3616 cfg.max_soft_bundle_size = Some(5);
3617 }
3618
3619 cfg.config_read_setting_impl_cost_base = Some(100);
3620 cfg.config_read_setting_impl_cost_per_byte = Some(40);
3621
3622 if chain != Chain::Testnet && chain != Chain::Mainnet {
3624 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(100);
3625 cfg.feature_flags.per_object_congestion_control_mode =
3626 PerObjectCongestionControlMode::TotalTxCount;
3627 }
3628
3629 cfg.feature_flags.consensus_choice = ConsensusChoice::Mysticeti;
3631
3632 cfg.feature_flags.mysticeti_leader_scoring_and_schedule = true;
3634
3635 cfg.checkpoint_summary_version_specific_data = Some(1);
3637 cfg.min_checkpoint_interval_ms = Some(200);
3638
3639 if chain != Chain::Mainnet {
3641 cfg.feature_flags
3642 .record_consensus_determined_version_assignments_in_prologue = true;
3643 cfg.feature_flags
3644 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = true;
3645 }
3646 if chain != Chain::Mainnet {
3648 cfg.move_binary_format_version = Some(7);
3649 }
3650
3651 if chain != Chain::Testnet && chain != Chain::Mainnet {
3652 cfg.feature_flags.passkey_auth = true;
3653 }
3654 cfg.feature_flags.enable_coin_deny_list_v2 = true;
3655 }
3656 53 => {
3657 cfg.bridge_should_try_to_finalize_committee = Some(chain != Chain::Mainnet);
3659
3660 cfg.feature_flags
3662 .record_consensus_determined_version_assignments_in_prologue = true;
3663 cfg.feature_flags
3664 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = true;
3665
3666 if chain == Chain::Unknown {
3667 cfg.feature_flags.authority_capabilities_v2 = true;
3668 }
3669
3670 if chain != Chain::Mainnet {
3672 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(100);
3673 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(10);
3674 cfg.feature_flags.per_object_congestion_control_mode =
3675 PerObjectCongestionControlMode::TotalTxCount;
3676 }
3677
3678 cfg.bcs_per_byte_serialized_cost = Some(2);
3680 cfg.bcs_legacy_min_output_size_cost = Some(1);
3681 cfg.bcs_failure_cost = Some(52);
3682 cfg.debug_print_base_cost = Some(52);
3683 cfg.debug_print_stack_trace_base_cost = Some(52);
3684 cfg.hash_sha2_256_base_cost = Some(52);
3685 cfg.hash_sha2_256_per_byte_cost = Some(2);
3686 cfg.hash_sha2_256_legacy_min_input_len_cost = Some(1);
3687 cfg.hash_sha3_256_base_cost = Some(52);
3688 cfg.hash_sha3_256_per_byte_cost = Some(2);
3689 cfg.hash_sha3_256_legacy_min_input_len_cost = Some(1);
3690 cfg.type_name_get_base_cost = Some(52);
3691 cfg.type_name_get_per_byte_cost = Some(2);
3692 cfg.string_check_utf8_base_cost = Some(52);
3693 cfg.string_check_utf8_per_byte_cost = Some(2);
3694 cfg.string_is_char_boundary_base_cost = Some(52);
3695 cfg.string_sub_string_base_cost = Some(52);
3696 cfg.string_sub_string_per_byte_cost = Some(2);
3697 cfg.string_index_of_base_cost = Some(52);
3698 cfg.string_index_of_per_byte_pattern_cost = Some(2);
3699 cfg.string_index_of_per_byte_searched_cost = Some(2);
3700 cfg.vector_empty_base_cost = Some(52);
3701 cfg.vector_length_base_cost = Some(52);
3702 cfg.vector_push_back_base_cost = Some(52);
3703 cfg.vector_push_back_legacy_per_abstract_memory_unit_cost = Some(2);
3704 cfg.vector_borrow_base_cost = Some(52);
3705 cfg.vector_pop_back_base_cost = Some(52);
3706 cfg.vector_destroy_empty_base_cost = Some(52);
3707 cfg.vector_swap_base_cost = Some(52);
3708 }
3709 54 => {
3710 cfg.feature_flags.random_beacon = true;
3712 cfg.random_beacon_reduction_lower_bound = Some(1000);
3713 cfg.random_beacon_dkg_timeout_round = Some(3000);
3714 cfg.random_beacon_min_round_interval_ms = Some(500);
3715
3716 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(100);
3718 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(10);
3719 cfg.feature_flags.per_object_congestion_control_mode =
3720 PerObjectCongestionControlMode::TotalTxCount;
3721
3722 cfg.feature_flags.soft_bundle = true;
3724 cfg.max_soft_bundle_size = Some(5);
3725 }
3726 55 => {
3727 cfg.move_binary_format_version = Some(7);
3729
3730 cfg.consensus_max_transactions_in_block_bytes = Some(512 * 1024);
3732 cfg.consensus_max_num_transactions_in_block = Some(512);
3735
3736 cfg.feature_flags.rethrow_serialization_type_layout_errors = true;
3737 }
3738 56 => {
3739 if chain == Chain::Mainnet {
3740 cfg.feature_flags.bridge = true;
3741 }
3742 }
3743 57 => {
3744 cfg.random_beacon_reduction_lower_bound = Some(800);
3746 }
3747 58 => {
3748 if chain == Chain::Mainnet {
3749 cfg.bridge_should_try_to_finalize_committee = Some(true);
3750 }
3751
3752 if chain != Chain::Mainnet && chain != Chain::Testnet {
3753 cfg.feature_flags
3755 .consensus_distributed_vote_scoring_strategy = true;
3756 }
3757 }
3758 59 => {
3759 cfg.feature_flags.consensus_round_prober = true;
3761 }
3762 60 => {
3763 cfg.max_type_to_layout_nodes = Some(512);
3764 cfg.feature_flags.validate_identifier_inputs = true;
3765 }
3766 61 => {
3767 if chain != Chain::Mainnet {
3768 cfg.feature_flags
3770 .consensus_distributed_vote_scoring_strategy = true;
3771 }
3772 cfg.random_beacon_reduction_lower_bound = Some(700);
3774
3775 if chain != Chain::Mainnet && chain != Chain::Testnet {
3776 cfg.feature_flags.mysticeti_fastpath = true;
3778 }
3779 }
3780 62 => {
3781 cfg.feature_flags.relocate_event_module = true;
3782 }
3783 63 => {
3784 cfg.feature_flags.per_object_congestion_control_mode =
3785 PerObjectCongestionControlMode::TotalGasBudgetWithCap;
3786 cfg.gas_budget_based_txn_cost_cap_factor = Some(400_000);
3787 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(18_500_000);
3788 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(240_000_000);
3789 }
3790 64 => {
3791 cfg.feature_flags.per_object_congestion_control_mode =
3792 PerObjectCongestionControlMode::TotalTxCount;
3793 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(40);
3794 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(3);
3795 }
3796 65 => {
3797 cfg.feature_flags
3799 .consensus_distributed_vote_scoring_strategy = true;
3800 }
3801 66 => {
3802 if chain == Chain::Mainnet {
3803 cfg.feature_flags
3805 .consensus_distributed_vote_scoring_strategy = false;
3806 }
3807 }
3808 67 => {
3809 cfg.feature_flags
3811 .consensus_distributed_vote_scoring_strategy = true;
3812 }
3813 68 => {
3814 cfg.group_ops_bls12381_g1_to_uncompressed_g1_cost = Some(26);
3815 cfg.group_ops_bls12381_uncompressed_g1_to_g1_cost = Some(52);
3816 cfg.group_ops_bls12381_uncompressed_g1_sum_base_cost = Some(26);
3817 cfg.group_ops_bls12381_uncompressed_g1_sum_cost_per_term = Some(13);
3818 cfg.group_ops_bls12381_uncompressed_g1_sum_max_terms = Some(2000);
3819
3820 if chain != Chain::Mainnet && chain != Chain::Testnet {
3821 cfg.feature_flags.uncompressed_g1_group_elements = true;
3822 }
3823
3824 cfg.feature_flags.per_object_congestion_control_mode =
3825 PerObjectCongestionControlMode::TotalGasBudgetWithCap;
3826 cfg.gas_budget_based_txn_cost_cap_factor = Some(400_000);
3827 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(18_500_000);
3828 cfg.max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit =
3829 Some(3_700_000); cfg.max_txn_cost_overage_per_object_in_commit = Some(u64::MAX);
3831 cfg.gas_budget_based_txn_cost_absolute_cap_commit_count = Some(50);
3832
3833 cfg.random_beacon_reduction_lower_bound = Some(500);
3835
3836 cfg.feature_flags.disallow_new_modules_in_deps_only_packages = true;
3837 }
3838 69 => {
3839 cfg.consensus_voting_rounds = Some(40);
3841
3842 if chain != Chain::Mainnet && chain != Chain::Testnet {
3843 cfg.feature_flags.consensus_smart_ancestor_selection = true;
3845 }
3846
3847 if chain != Chain::Mainnet {
3848 cfg.feature_flags.uncompressed_g1_group_elements = true;
3849 }
3850 }
3851 70 => {
3852 if chain != Chain::Mainnet {
3853 cfg.feature_flags.consensus_smart_ancestor_selection = true;
3855 cfg.feature_flags
3857 .consensus_round_prober_probe_accepted_rounds = true;
3858 }
3859
3860 cfg.poseidon_bn254_cost_per_block = Some(388);
3861
3862 cfg.gas_model_version = Some(9);
3863 cfg.feature_flags.native_charging_v2 = true;
3864 cfg.bls12381_bls12381_min_sig_verify_cost_base = Some(44064);
3865 cfg.bls12381_bls12381_min_pk_verify_cost_base = Some(49282);
3866 cfg.ecdsa_k1_secp256k1_verify_keccak256_cost_base = Some(1470);
3867 cfg.ecdsa_k1_secp256k1_verify_sha256_cost_base = Some(1470);
3868 cfg.ecdsa_r1_secp256r1_verify_sha256_cost_base = Some(4225);
3869 cfg.ecdsa_r1_secp256r1_verify_keccak256_cost_base = Some(4225);
3870 cfg.ecvrf_ecvrf_verify_cost_base = Some(4848);
3871 cfg.ed25519_ed25519_verify_cost_base = Some(1802);
3872
3873 cfg.ecdsa_r1_ecrecover_keccak256_cost_base = Some(1173);
3875 cfg.ecdsa_r1_ecrecover_sha256_cost_base = Some(1173);
3876 cfg.ecdsa_k1_ecrecover_keccak256_cost_base = Some(500);
3877 cfg.ecdsa_k1_ecrecover_sha256_cost_base = Some(500);
3878
3879 cfg.groth16_prepare_verifying_key_bls12381_cost_base = Some(53838);
3880 cfg.groth16_prepare_verifying_key_bn254_cost_base = Some(82010);
3881 cfg.groth16_verify_groth16_proof_internal_bls12381_cost_base = Some(72090);
3882 cfg.groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input =
3883 Some(8213);
3884 cfg.groth16_verify_groth16_proof_internal_bn254_cost_base = Some(115502);
3885 cfg.groth16_verify_groth16_proof_internal_bn254_cost_per_public_input =
3886 Some(9484);
3887
3888 cfg.hash_keccak256_cost_base = Some(10);
3889 cfg.hash_blake2b256_cost_base = Some(10);
3890
3891 cfg.group_ops_bls12381_decode_scalar_cost = Some(7);
3893 cfg.group_ops_bls12381_decode_g1_cost = Some(2848);
3894 cfg.group_ops_bls12381_decode_g2_cost = Some(3770);
3895 cfg.group_ops_bls12381_decode_gt_cost = Some(3068);
3896
3897 cfg.group_ops_bls12381_scalar_add_cost = Some(10);
3898 cfg.group_ops_bls12381_g1_add_cost = Some(1556);
3899 cfg.group_ops_bls12381_g2_add_cost = Some(3048);
3900 cfg.group_ops_bls12381_gt_add_cost = Some(188);
3901
3902 cfg.group_ops_bls12381_scalar_sub_cost = Some(10);
3903 cfg.group_ops_bls12381_g1_sub_cost = Some(1550);
3904 cfg.group_ops_bls12381_g2_sub_cost = Some(3019);
3905 cfg.group_ops_bls12381_gt_sub_cost = Some(497);
3906
3907 cfg.group_ops_bls12381_scalar_mul_cost = Some(11);
3908 cfg.group_ops_bls12381_g1_mul_cost = Some(4842);
3909 cfg.group_ops_bls12381_g2_mul_cost = Some(9108);
3910 cfg.group_ops_bls12381_gt_mul_cost = Some(27490);
3911
3912 cfg.group_ops_bls12381_scalar_div_cost = Some(91);
3913 cfg.group_ops_bls12381_g1_div_cost = Some(5091);
3914 cfg.group_ops_bls12381_g2_div_cost = Some(9206);
3915 cfg.group_ops_bls12381_gt_div_cost = Some(27804);
3916
3917 cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(2962);
3918 cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(8688);
3919
3920 cfg.group_ops_bls12381_g1_msm_base_cost = Some(62648);
3921 cfg.group_ops_bls12381_g2_msm_base_cost = Some(131192);
3922 cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(1333);
3923 cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(3216);
3924
3925 cfg.group_ops_bls12381_uncompressed_g1_to_g1_cost = Some(677);
3926 cfg.group_ops_bls12381_g1_to_uncompressed_g1_cost = Some(2099);
3927 cfg.group_ops_bls12381_uncompressed_g1_sum_base_cost = Some(77);
3928 cfg.group_ops_bls12381_uncompressed_g1_sum_cost_per_term = Some(26);
3929
3930 cfg.group_ops_bls12381_pairing_cost = Some(26897);
3931 cfg.group_ops_bls12381_uncompressed_g1_sum_max_terms = Some(1200);
3932
3933 cfg.validator_validate_metadata_cost_base = Some(20000);
3934 }
3935 71 => {
3936 cfg.sip_45_consensus_amplification_threshold = Some(5);
3937
3938 cfg.allowed_txn_cost_overage_burst_per_object_in_commit = Some(185_000_000);
3940 }
3941 72 => {
3942 cfg.feature_flags.convert_type_argument_error = true;
3943
3944 cfg.max_tx_gas = Some(50_000_000_000_000);
3947 cfg.max_gas_price = Some(50_000_000_000);
3949
3950 cfg.feature_flags.variant_nodes = true;
3951 }
3952 73 => {
3953 cfg.use_object_per_epoch_marker_table_v2 = Some(true);
3955
3956 if chain != Chain::Mainnet && chain != Chain::Testnet {
3957 cfg.consensus_gc_depth = Some(60);
3960 }
3961
3962 if chain != Chain::Mainnet {
3963 cfg.feature_flags.consensus_zstd_compression = true;
3965 }
3966
3967 cfg.feature_flags.consensus_smart_ancestor_selection = true;
3969 cfg.feature_flags
3971 .consensus_round_prober_probe_accepted_rounds = true;
3972
3973 cfg.feature_flags.per_object_congestion_control_mode =
3975 PerObjectCongestionControlMode::TotalGasBudgetWithCap;
3976 cfg.gas_budget_based_txn_cost_cap_factor = Some(400_000);
3977 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(37_000_000);
3978 cfg.max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit =
3979 Some(7_400_000); cfg.max_txn_cost_overage_per_object_in_commit = Some(u64::MAX);
3981 cfg.gas_budget_based_txn_cost_absolute_cap_commit_count = Some(50);
3982 cfg.allowed_txn_cost_overage_burst_per_object_in_commit = Some(370_000_000);
3983 }
3984 74 => {
3985 if chain != Chain::Mainnet && chain != Chain::Testnet {
3987 cfg.feature_flags.enable_nitro_attestation = true;
3988 }
3989 cfg.nitro_attestation_parse_base_cost = Some(53 * 50);
3990 cfg.nitro_attestation_parse_cost_per_byte = Some(50);
3991 cfg.nitro_attestation_verify_base_cost = Some(49632 * 50);
3992 cfg.nitro_attestation_verify_cost_per_cert = Some(52369 * 50);
3993
3994 cfg.feature_flags.consensus_zstd_compression = true;
3996
3997 if chain != Chain::Mainnet && chain != Chain::Testnet {
3998 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
3999 }
4000 }
4001 75 => {
4002 if chain != Chain::Mainnet {
4003 cfg.feature_flags.passkey_auth = true;
4004 }
4005 }
4006 76 => {
4007 if chain != Chain::Mainnet && chain != Chain::Testnet {
4008 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
4009 cfg.consensus_commit_rate_estimation_window_size = Some(10);
4010 }
4011 cfg.feature_flags.minimize_child_object_mutations = true;
4012
4013 if chain != Chain::Mainnet {
4014 cfg.feature_flags.accept_passkey_in_multisig = true;
4015 }
4016 }
4017 77 => {
4018 cfg.feature_flags.uncompressed_g1_group_elements = true;
4019
4020 if chain != Chain::Mainnet {
4021 cfg.consensus_gc_depth = Some(60);
4022 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
4023 }
4024 }
4025 78 => {
4026 cfg.feature_flags.move_native_context = true;
4027 cfg.tx_context_fresh_id_cost_base = Some(52);
4028 cfg.tx_context_sender_cost_base = Some(30);
4029 cfg.tx_context_epoch_cost_base = Some(30);
4030 cfg.tx_context_epoch_timestamp_ms_cost_base = Some(30);
4031 cfg.tx_context_sponsor_cost_base = Some(30);
4032 cfg.tx_context_gas_price_cost_base = Some(30);
4033 cfg.tx_context_gas_budget_cost_base = Some(30);
4034 cfg.tx_context_ids_created_cost_base = Some(30);
4035 cfg.tx_context_replace_cost_base = Some(30);
4036 cfg.gas_model_version = Some(10);
4037
4038 if chain != Chain::Mainnet {
4039 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
4040 cfg.consensus_commit_rate_estimation_window_size = Some(10);
4041
4042 cfg.feature_flags.per_object_congestion_control_mode =
4044 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4045 ExecutionTimeEstimateParams {
4046 target_utilization: 30,
4047 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4049 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4051 stored_observations_limit: u64::MAX,
4052 stake_weighted_median_threshold: 0,
4053 default_none_duration_for_new_keys: false,
4054 observations_chunk_size: None,
4055 },
4056 );
4057 }
4058 }
4059 79 => {
4060 if chain != Chain::Mainnet {
4061 cfg.feature_flags.consensus_median_based_commit_timestamp = true;
4062
4063 cfg.consensus_bad_nodes_stake_threshold = Some(30);
4066
4067 cfg.feature_flags.consensus_batched_block_sync = true;
4068
4069 cfg.feature_flags.enable_nitro_attestation = true
4071 }
4072 cfg.feature_flags.normalize_ptb_arguments = true;
4073
4074 cfg.consensus_gc_depth = Some(60);
4075 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
4076 }
4077 80 => {
4078 cfg.max_ptb_value_size = Some(1024 * 1024);
4079 }
4080 81 => {
4081 cfg.feature_flags.consensus_median_based_commit_timestamp = true;
4082 cfg.feature_flags.enforce_checkpoint_timestamp_monotonicity = true;
4083 cfg.consensus_bad_nodes_stake_threshold = Some(30)
4084 }
4085 82 => {
4086 cfg.feature_flags.max_ptb_value_size_v2 = true;
4087 }
4088 83 => {
4089 if chain == Chain::Mainnet {
4090 let aliased: [u8; 32] = Hex::decode(
4092 "0x0b2da327ba6a4cacbe75dddd50e6e8bbf81d6496e92d66af9154c61c77f7332f",
4093 )
4094 .unwrap()
4095 .try_into()
4096 .unwrap();
4097
4098 cfg.aliased_addresses.push(AliasedAddress {
4100 original: Hex::decode("0xcd8962dad278d8b50fa0f9eb0186bfa4cbdecc6d59377214c88d0286a0ac9562").unwrap().try_into().unwrap(),
4101 aliased,
4102 allowed_tx_digests: vec![
4103 Base58::decode("B2eGLFoMHgj93Ni8dAJBfqGzo8EWSTLBesZzhEpTPA4").unwrap().try_into().unwrap(),
4104 ],
4105 });
4106
4107 cfg.aliased_addresses.push(AliasedAddress {
4108 original: Hex::decode("0xe28b50cef1d633ea43d3296a3f6b67ff0312a5f1a99f0af753c85b8b5de8ff06").unwrap().try_into().unwrap(),
4109 aliased,
4110 allowed_tx_digests: vec![
4111 Base58::decode("J4QqSAgp7VrQtQpMy5wDX4QGsCSEZu3U5KuDAkbESAge").unwrap().try_into().unwrap(),
4112 ],
4113 });
4114 }
4115
4116 if chain != Chain::Mainnet {
4119 cfg.feature_flags.resolve_type_input_ids_to_defining_id = true;
4120 cfg.transfer_party_transfer_internal_cost_base = Some(52);
4121
4122 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
4124 cfg.consensus_commit_rate_estimation_window_size = Some(10);
4125 cfg.feature_flags.per_object_congestion_control_mode =
4126 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4127 ExecutionTimeEstimateParams {
4128 target_utilization: 30,
4129 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4131 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4133 stored_observations_limit: u64::MAX,
4134 stake_weighted_median_threshold: 0,
4135 default_none_duration_for_new_keys: false,
4136 observations_chunk_size: None,
4137 },
4138 );
4139
4140 cfg.feature_flags.consensus_batched_block_sync = true;
4142
4143 cfg.feature_flags.enable_nitro_attestation_upgraded_parsing = true;
4146 cfg.feature_flags.enable_nitro_attestation = true;
4147 }
4148 }
4149 84 => {
4150 if chain == Chain::Mainnet {
4151 cfg.feature_flags.resolve_type_input_ids_to_defining_id = true;
4152 cfg.transfer_party_transfer_internal_cost_base = Some(52);
4153
4154 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
4156 cfg.consensus_commit_rate_estimation_window_size = Some(10);
4157 cfg.feature_flags.per_object_congestion_control_mode =
4158 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4159 ExecutionTimeEstimateParams {
4160 target_utilization: 30,
4161 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4163 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4165 stored_observations_limit: u64::MAX,
4166 stake_weighted_median_threshold: 0,
4167 default_none_duration_for_new_keys: false,
4168 observations_chunk_size: None,
4169 },
4170 );
4171
4172 cfg.feature_flags.consensus_batched_block_sync = true;
4174
4175 cfg.feature_flags.enable_nitro_attestation_upgraded_parsing = true;
4178 cfg.feature_flags.enable_nitro_attestation = true;
4179 }
4180
4181 cfg.feature_flags.per_object_congestion_control_mode =
4183 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4184 ExecutionTimeEstimateParams {
4185 target_utilization: 30,
4186 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4188 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4190 stored_observations_limit: 20,
4191 stake_weighted_median_threshold: 0,
4192 default_none_duration_for_new_keys: false,
4193 observations_chunk_size: None,
4194 },
4195 );
4196 cfg.feature_flags.allow_unbounded_system_objects = true;
4197 }
4198 85 => {
4199 if chain != Chain::Mainnet && chain != Chain::Testnet {
4200 cfg.feature_flags.enable_party_transfer = true;
4201 }
4202
4203 cfg.feature_flags
4204 .record_consensus_determined_version_assignments_in_prologue_v2 = true;
4205 cfg.feature_flags.disallow_self_identifier = true;
4206 cfg.feature_flags.per_object_congestion_control_mode =
4207 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4208 ExecutionTimeEstimateParams {
4209 target_utilization: 50,
4210 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4212 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4214 stored_observations_limit: 20,
4215 stake_weighted_median_threshold: 0,
4216 default_none_duration_for_new_keys: false,
4217 observations_chunk_size: None,
4218 },
4219 );
4220 }
4221 86 => {
4222 cfg.feature_flags.type_tags_in_object_runtime = true;
4223 cfg.max_move_enum_variants = Some(move_core_types::VARIANT_COUNT_MAX);
4224
4225 cfg.feature_flags.per_object_congestion_control_mode =
4227 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4228 ExecutionTimeEstimateParams {
4229 target_utilization: 50,
4230 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4232 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4234 stored_observations_limit: 20,
4235 stake_weighted_median_threshold: 3334,
4236 default_none_duration_for_new_keys: false,
4237 observations_chunk_size: None,
4238 },
4239 );
4240 if chain != Chain::Mainnet {
4242 cfg.feature_flags.enable_party_transfer = true;
4243 }
4244 }
4245 87 => {
4246 if chain == Chain::Mainnet {
4247 cfg.feature_flags.record_time_estimate_processed = true;
4248 }
4249 cfg.feature_flags.better_adapter_type_resolution_errors = true;
4250 }
4251 88 => {
4252 cfg.feature_flags.record_time_estimate_processed = true;
4253 cfg.tx_context_rgp_cost_base = Some(30);
4254 cfg.feature_flags
4255 .ignore_execution_time_observations_after_certs_closed = true;
4256
4257 cfg.feature_flags.per_object_congestion_control_mode =
4260 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4261 ExecutionTimeEstimateParams {
4262 target_utilization: 50,
4263 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4265 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4267 stored_observations_limit: 20,
4268 stake_weighted_median_threshold: 3334,
4269 default_none_duration_for_new_keys: true,
4270 observations_chunk_size: None,
4271 },
4272 );
4273 }
4274 89 => {
4275 cfg.feature_flags.dependency_linkage_error = true;
4276 cfg.feature_flags.additional_multisig_checks = true;
4277 }
4278 90 => {
4279 cfg.max_gas_price_rgp_factor_for_aborted_transactions = Some(100);
4281 cfg.feature_flags.debug_fatal_on_move_invariant_violation = true;
4282 cfg.feature_flags.additional_consensus_digest_indirect_state = true;
4283 cfg.feature_flags.accept_passkey_in_multisig = true;
4284 cfg.feature_flags.passkey_auth = true;
4285 cfg.feature_flags.check_for_init_during_upgrade = true;
4286
4287 if chain != Chain::Mainnet {
4289 cfg.feature_flags.mysticeti_fastpath = true;
4290 }
4291 }
4292 91 => {
4293 cfg.feature_flags.per_command_shared_object_transfer_rules = true;
4294 }
4295 92 => {
4296 cfg.feature_flags.per_command_shared_object_transfer_rules = false;
4297 }
4298 93 => {
4299 cfg.feature_flags
4300 .consensus_checkpoint_signature_key_includes_digest = true;
4301 }
4302 94 => {
4303 cfg.feature_flags.per_object_congestion_control_mode =
4305 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4306 ExecutionTimeEstimateParams {
4307 target_utilization: 50,
4308 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4310 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4312 stored_observations_limit: 18,
4313 stake_weighted_median_threshold: 3334,
4314 default_none_duration_for_new_keys: true,
4315 observations_chunk_size: None,
4316 },
4317 );
4318
4319 cfg.feature_flags.enable_party_transfer = true;
4321 }
4322 95 => {
4323 cfg.type_name_id_base_cost = Some(52);
4324
4325 cfg.max_transactions_per_checkpoint = Some(20_000);
4327 }
4328 96 => {
4329 if chain != Chain::Mainnet && chain != Chain::Testnet {
4331 cfg.feature_flags
4332 .include_checkpoint_artifacts_digest_in_summary = true;
4333 }
4334 cfg.feature_flags.correct_gas_payment_limit_check = true;
4335 cfg.feature_flags.authority_capabilities_v2 = true;
4336 cfg.feature_flags.use_mfp_txns_in_load_initial_object_debts = true;
4337 cfg.feature_flags.cancel_for_failed_dkg_early = true;
4338 cfg.feature_flags.enable_coin_registry = true;
4339
4340 cfg.feature_flags.mysticeti_fastpath = true;
4342 }
4343 97 => {
4344 cfg.feature_flags.additional_borrow_checks = true;
4345 }
4346 98 => {
4347 cfg.event_emit_auth_stream_cost = Some(52);
4348 cfg.feature_flags.better_loader_errors = true;
4349 cfg.feature_flags.generate_df_type_layouts = true;
4350 }
4351 99 => {
4352 cfg.feature_flags.use_new_commit_handler = true;
4353 }
4354 100 => {
4355 cfg.feature_flags.private_generics_verifier_v2 = true;
4356 }
4357 101 => {
4358 cfg.feature_flags.create_root_accumulator_object = true;
4359 cfg.max_updates_per_settlement_txn = Some(100);
4360 if chain != Chain::Mainnet {
4361 cfg.feature_flags.enable_poseidon = true;
4362 }
4363 }
4364 102 => {
4365 cfg.feature_flags.per_object_congestion_control_mode =
4369 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4370 ExecutionTimeEstimateParams {
4371 target_utilization: 50,
4372 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4374 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4376 stored_observations_limit: 180,
4377 stake_weighted_median_threshold: 3334,
4378 default_none_duration_for_new_keys: true,
4379 observations_chunk_size: Some(18),
4380 },
4381 );
4382 cfg.feature_flags.deprecate_global_storage_ops = true;
4383 }
4384 103 => {}
4385 104 => {
4386 cfg.translation_per_command_base_charge = Some(1);
4387 cfg.translation_per_input_base_charge = Some(1);
4388 cfg.translation_pure_input_per_byte_charge = Some(1);
4389 cfg.translation_per_type_node_charge = Some(1);
4390 cfg.translation_per_reference_node_charge = Some(1);
4391 cfg.translation_per_linkage_entry_charge = Some(10);
4392 cfg.gas_model_version = Some(11);
4393 cfg.feature_flags.abstract_size_in_object_runtime = true;
4394 cfg.feature_flags.object_runtime_charge_cache_load_gas = true;
4395 cfg.dynamic_field_hash_type_and_key_cost_base = Some(52);
4396 cfg.dynamic_field_add_child_object_cost_base = Some(52);
4397 cfg.dynamic_field_add_child_object_value_cost_per_byte = Some(1);
4398 cfg.dynamic_field_borrow_child_object_cost_base = Some(52);
4399 cfg.dynamic_field_borrow_child_object_child_ref_cost_per_byte = Some(1);
4400 cfg.dynamic_field_remove_child_object_cost_base = Some(52);
4401 cfg.dynamic_field_remove_child_object_child_cost_per_byte = Some(1);
4402 cfg.dynamic_field_has_child_object_cost_base = Some(52);
4403 cfg.dynamic_field_has_child_object_with_ty_cost_base = Some(52);
4404 cfg.feature_flags.enable_ptb_execution_v2 = true;
4405
4406 cfg.poseidon_bn254_cost_base = Some(260);
4407
4408 cfg.feature_flags.consensus_skip_gced_accept_votes = true;
4409
4410 if chain != Chain::Mainnet {
4411 cfg.feature_flags
4412 .enable_nitro_attestation_all_nonzero_pcrs_parsing = true;
4413 }
4414
4415 cfg.feature_flags
4416 .include_cancelled_randomness_txns_in_prologue = true;
4417 }
4418 105 => {
4419 cfg.feature_flags.enable_multi_epoch_transaction_expiration = true;
4420 cfg.feature_flags.disable_preconsensus_locking = true;
4421
4422 if chain != Chain::Mainnet {
4423 cfg.feature_flags
4424 .enable_nitro_attestation_always_include_required_pcrs_parsing = true;
4425 }
4426 }
4427 106 => {
4428 cfg.accumulator_object_storage_cost = Some(7600);
4430
4431 if chain != Chain::Mainnet && chain != Chain::Testnet {
4432 cfg.feature_flags.enable_accumulators = true;
4433 cfg.feature_flags.enable_address_balance_gas_payments = true;
4434 cfg.feature_flags.enable_authenticated_event_streams = true;
4435 cfg.feature_flags.enable_object_funds_withdraw = true;
4436 }
4437 }
4438 107 => {
4439 cfg.feature_flags
4440 .consensus_skip_gced_blocks_in_direct_finalization = true;
4441
4442 if in_integration_test() {
4444 cfg.consensus_gc_depth = Some(6);
4445 cfg.consensus_max_num_transactions_in_block = Some(8);
4446 }
4447 }
4448 108 => {
4449 cfg.feature_flags.gas_rounding_halve_digits = true;
4450 cfg.feature_flags.flexible_tx_context_positions = true;
4451 cfg.feature_flags.disable_entry_point_signature_check = true;
4452
4453 if chain != Chain::Mainnet {
4454 cfg.feature_flags.address_aliases = true;
4455
4456 cfg.feature_flags.enable_accumulators = true;
4457 cfg.feature_flags.enable_address_balance_gas_payments = true;
4458 }
4459
4460 cfg.feature_flags.enable_poseidon = true;
4461 }
4462 109 => {
4463 cfg.binary_variant_handles = Some(1024);
4464 cfg.binary_variant_instantiation_handles = Some(1024);
4465 cfg.feature_flags.restrict_hot_or_not_entry_functions = true;
4466 }
4467 110 => {
4468 cfg.feature_flags
4469 .enable_nitro_attestation_all_nonzero_pcrs_parsing = true;
4470 cfg.feature_flags
4471 .enable_nitro_attestation_always_include_required_pcrs_parsing = true;
4472 if chain != Chain::Mainnet && chain != Chain::Testnet {
4473 cfg.feature_flags.split_checkpoints_in_consensus_handler = true;
4474 }
4475 cfg.feature_flags.validate_zklogin_public_identifier = true;
4476 cfg.feature_flags.fix_checkpoint_signature_mapping = true;
4477 cfg.feature_flags
4478 .consensus_always_accept_system_transactions = true;
4479 if chain != Chain::Mainnet {
4480 cfg.feature_flags.enable_object_funds_withdraw = true;
4481 }
4482 }
4483 111 => {
4484 cfg.feature_flags.validator_metadata_verify_v2 = true;
4485 }
4486 112 => {
4487 cfg.group_ops_ristretto_decode_scalar_cost = Some(7);
4488 cfg.group_ops_ristretto_decode_point_cost = Some(200);
4489 cfg.group_ops_ristretto_scalar_add_cost = Some(10);
4490 cfg.group_ops_ristretto_point_add_cost = Some(500);
4491 cfg.group_ops_ristretto_scalar_sub_cost = Some(10);
4492 cfg.group_ops_ristretto_point_sub_cost = Some(500);
4493 cfg.group_ops_ristretto_scalar_mul_cost = Some(11);
4494 cfg.group_ops_ristretto_point_mul_cost = Some(1200);
4495 cfg.group_ops_ristretto_scalar_div_cost = Some(151);
4496 cfg.group_ops_ristretto_point_div_cost = Some(2500);
4497
4498 if chain != Chain::Mainnet && chain != Chain::Testnet {
4499 cfg.feature_flags.enable_ristretto255_group_ops = true;
4500 }
4501 }
4502 113 => {
4503 cfg.feature_flags.address_balance_gas_check_rgp_at_signing = true;
4504 if chain != Chain::Mainnet && chain != Chain::Testnet {
4505 cfg.feature_flags.defer_unpaid_amplification = true;
4506 }
4507 }
4508 114 => {
4509 cfg.feature_flags.randomize_checkpoint_tx_limit_in_tests = true;
4510 cfg.feature_flags.address_balance_gas_reject_gas_coin_arg = true;
4511 if chain != Chain::Mainnet {
4512 cfg.feature_flags.split_checkpoints_in_consensus_handler = true;
4513 cfg.feature_flags.enable_authenticated_event_streams = true;
4514 cfg.feature_flags
4515 .include_checkpoint_artifacts_digest_in_summary = true;
4516 }
4517 }
4518 115 => {
4519 cfg.feature_flags.normalize_depth_formula = true;
4520 }
4521 116 => {
4522 cfg.feature_flags.gasless_transaction_drop_safety = true;
4523 cfg.feature_flags.address_aliases = true;
4524 cfg.feature_flags.relax_valid_during_for_owned_inputs = true;
4525 cfg.feature_flags.defer_unpaid_amplification = false;
4527 cfg.feature_flags.enable_display_registry = true;
4528 }
4529 117 => {}
4530 118 => {
4531 cfg.feature_flags.use_coin_party_owner = true;
4532 }
4533 119 => {
4534 cfg.execution_version = Some(4);
4536 cfg.feature_flags.address_balance_gas_reject_gas_coin_arg = false;
4537 cfg.feature_flags.merge_randomness_into_checkpoint = true;
4538 if chain != Chain::Mainnet {
4539 cfg.feature_flags.enable_gasless = true;
4540 cfg.gasless_max_computation_units = Some(50_000);
4541 cfg.gasless_allowed_token_types = Some(vec![]);
4542 cfg.feature_flags.enable_coin_reservation_obj_refs = true;
4543 cfg.feature_flags
4544 .convert_withdrawal_compatibility_ptb_arguments = true;
4545 }
4546 cfg.gasless_max_unused_inputs = Some(1);
4547 cfg.gasless_max_pure_input_bytes = Some(32);
4548 if chain == Chain::Testnet {
4549 cfg.gasless_allowed_token_types = Some(vec![(TESTNET_USDC.to_string(), 0)]);
4550 }
4551 cfg.transfer_receive_object_cost_per_byte = Some(1);
4552 cfg.transfer_receive_object_type_cost_per_byte = Some(2);
4553 }
4554 120 => {
4555 cfg.feature_flags.disallow_jump_orphans = true;
4556 }
4557 121 => {
4558 if chain != Chain::Mainnet {
4560 cfg.feature_flags.defer_unpaid_amplification = true;
4561 cfg.gasless_max_tps = Some(50);
4562 }
4563 cfg.feature_flags
4564 .early_return_receive_object_mismatched_type = true;
4565 }
4566 122 => {
4567 cfg.feature_flags.defer_unpaid_amplification = true;
4569 cfg.verify_bulletproofs_ristretto255_base_cost = Some(30000);
4571 cfg.verify_bulletproofs_ristretto255_cost_per_bit_and_commitment = Some(6500);
4572 if chain != Chain::Mainnet && chain != Chain::Testnet {
4573 cfg.feature_flags.enable_verify_bulletproofs_ristretto255 = true;
4574 }
4575 cfg.feature_flags.gasless_verify_remaining_balance = true;
4576 cfg.include_special_package_amendments = match chain {
4577 Chain::Mainnet => Some(MAINNET_LINKAGE_AMENDMENTS.clone()),
4578 Chain::Testnet => Some(TESTNET_LINKAGE_AMENDMENTS.clone()),
4579 Chain::Unknown => None,
4580 };
4581 cfg.gasless_max_tx_size_bytes = Some(16 * 1024);
4582 cfg.gasless_max_tps = Some(300);
4583 cfg.gasless_max_computation_units = Some(5_000);
4584 }
4585 123 => {
4586 cfg.gas_model_version = Some(13);
4587 }
4588 124 => {
4589 if chain != Chain::Mainnet && chain != Chain::Testnet {
4590 cfg.feature_flags.timestamp_based_epoch_close = true;
4591 }
4592 cfg.gas_model_version = Some(14);
4593 cfg.feature_flags.limit_groth16_pvk_inputs = true;
4594
4595 cfg.feature_flags.enable_accumulators = true;
4601 cfg.feature_flags.enable_address_balance_gas_payments = true;
4602 cfg.feature_flags.enable_authenticated_event_streams = true;
4603 cfg.feature_flags.enable_coin_reservation_obj_refs = true;
4604 cfg.feature_flags.enable_object_funds_withdraw = true;
4605 cfg.feature_flags
4606 .convert_withdrawal_compatibility_ptb_arguments = true;
4607 cfg.feature_flags.split_checkpoints_in_consensus_handler = true;
4608 cfg.feature_flags
4609 .include_checkpoint_artifacts_digest_in_summary = true;
4610 cfg.feature_flags.enable_gasless = true;
4611
4612 if chain == Chain::Mainnet {
4617 cfg.gasless_allowed_token_types = Some(vec![
4618 (MAINNET_USDC.to_string(), 10_000),
4619 (MAINNET_USDSUI.to_string(), 10_000),
4620 (MAINNET_SUI_USDE.to_string(), 10_000),
4621 (MAINNET_USDY.to_string(), 10_000),
4622 (MAINNET_FDUSD.to_string(), 10_000),
4623 (MAINNET_AUSD.to_string(), 10_000),
4624 (MAINNET_USDB.to_string(), 10_000),
4625 ]);
4626 }
4627 }
4628 125 => {
4629 cfg.feature_flags.granular_post_execution_checks = true;
4630 if chain != Chain::Mainnet {
4631 cfg.feature_flags.timestamp_based_epoch_close = true;
4632 }
4633 }
4634 126 => {
4635 cfg.feature_flags.early_exit_on_iffw = true;
4636 }
4637 127 => {
4638 cfg.feature_flags.always_advance_dkg_to_resolution = true;
4639
4640 cfg.verify_bulletproofs_ristretto255_base_cost = Some(23866);
4641 cfg.verify_bulletproofs_ristretto255_cost_per_bit_and_commitment = Some(1324);
4642 cfg.group_ops_ristretto_decode_scalar_cost = Some(5);
4643 cfg.group_ops_ristretto_decode_point_cost = Some(216);
4644 cfg.group_ops_ristretto_scalar_add_cost = Some(2);
4645 cfg.group_ops_ristretto_point_add_cost = Some(8);
4646 cfg.group_ops_ristretto_scalar_sub_cost = Some(2);
4647 cfg.group_ops_ristretto_point_sub_cost = Some(8);
4648 cfg.group_ops_ristretto_scalar_mul_cost = Some(5);
4649 cfg.group_ops_ristretto_point_mul_cost = Some(1763);
4650 cfg.group_ops_ristretto_scalar_div_cost = Some(557);
4651 cfg.group_ops_ristretto_point_div_cost = Some(2244);
4652
4653 if chain != Chain::Mainnet {
4654 cfg.feature_flags.enable_ristretto255_group_ops = true;
4655 cfg.feature_flags.enable_verify_bulletproofs_ristretto255 = true;
4656 }
4657
4658 cfg.feature_flags.timestamp_based_epoch_close = true;
4659 }
4660 128 => {
4661 cfg.max_generic_instantiation_type_nodes_per_function = Some(10_000);
4662 cfg.max_generic_instantiation_type_nodes_per_module = Some(500_000);
4663 cfg.binary_enum_defs = Some(200);
4664 cfg.binary_enum_def_instantiations = Some(100);
4665 }
4666 129 => {
4667 cfg.feature_flags.enable_unified_linkage = true;
4668 }
4669 130 => {
4670 cfg.feature_flags.record_net_unsettled_object_withdraws = true;
4671 cfg.feature_flags.enable_init_on_upgrade = true;
4672 cfg.epoch_close_deadline_ms = Some(120_000);
4673 cfg.scratch_add_cost_base = Some(13);
4674 cfg.scratch_read_cost_base = Some(13);
4675 cfg.scratch_read_value_cost = Some(1);
4676 cfg.scratch_remove_cost_base = Some(13);
4677 cfg.scratch_exists_cost_base = Some(13);
4678 cfg.scratch_exists_with_type_cost_base = Some(13);
4679 cfg.scratch_exists_with_type_type_cost = Some(1);
4680 let max_commands = cfg.max_programmable_tx_commands() as u64;
4681 cfg.max_scratch_pad_size = Some(16 * max_commands);
4682 if chain != Chain::Mainnet && chain != Chain::Testnet {
4684 cfg.feature_flags.zklogin_circuit_mode = 1;
4685 }
4686 }
4687 131 => {
4688 cfg.feature_flags.share_transaction_deny_config_in_consensus = true;
4689 cfg.feature_flags.framework_tx_context_mut_restrictions = true;
4690 }
4691 132 => {
4692 if chain != Chain::Mainnet && chain != Chain::Testnet {
4693 cfg.feature_flags.defer_owned_object_double_spend = true;
4694 cfg.feature_flags.create_forwarding_address_registry = true;
4695 }
4696 cfg.object_record_new_uid_from_hash_cost_base = Some(1);
4697 cfg.feature_flags
4698 .enable_order_independent_upgrade_init_linkage = true;
4699 }
4700 133 => {
4701 cfg.feature_flags
4702 .include_function_signatures_in_instantiation_limits = true;
4703 cfg.max_accumulator_type_nodes = Some(16);
4704 }
4705 134 => {
4706 if chain != Chain::Mainnet {
4713 cfg.package_original_package_id_impl_cost_base = Some(52);
4714 let package_read_cost_per_byte = cfg.obj_access_cost_read_per_byte();
4715 cfg.package_original_package_id_impl_cost_per_byte =
4716 Some(package_read_cost_per_byte);
4717
4718 cfg.consensus_max_transactions_in_block_bytes = Some(288 * 1024);
4719 cfg.consensus_max_num_transactions_in_block = Some(128);
4720 }
4721
4722 if chain == Chain::Mainnet {
4723 cfg.feature_flags.defer_unpaid_amplification = false;
4724 }
4725 }
4726 135 => {
4727 cfg.package_original_package_id_impl_cost_base = Some(52);
4730 let package_read_cost_per_byte = cfg.obj_access_cost_read_per_byte();
4731 cfg.package_original_package_id_impl_cost_per_byte =
4732 Some(package_read_cost_per_byte);
4733
4734 cfg.consensus_max_transactions_in_block_bytes = Some(288 * 1024);
4735 cfg.consensus_max_num_transactions_in_block = Some(128);
4736
4737 cfg.feature_flags.defer_unpaid_amplification = false;
4738 }
4739 136 => {
4740 cfg.feature_flags.ptb_tx_context_restrictions = true;
4741
4742 cfg.translation_per_live_reference_charge = Some(1);
4743 cfg.max_ptb_live_references = Some(64);
4744 cfg.max_ptb_returned_references = Some(16);
4745 cfg.max_ptb_total_returned_references = Some(256);
4746
4747 if chain != Chain::Mainnet && chain != Chain::Testnet {
4748 cfg.feature_flags.allowed_proposers = true;
4749 }
4750 cfg.feature_flags.harden_linkage_consistency = true;
4751
4752 cfg.package_arena_size_in_bytes = Some(10_000_000);
4753 }
4754 137 => {
4755 cfg.verify_bulletproofs_ristretto255_cost_per_bit_and_commitment = Some(621);
4756 cfg.max_bulletproofs_total_bits = Some(1024);
4757
4758 if chain != Chain::Mainnet {
4759 cfg.feature_flags.enable_allowances = true;
4760 }
4761 cfg.feature_flags.fix_ptb_generated_reads = true;
4762 cfg.feature_flags.charge_ld_const_abstract_size = true;
4763 if chain != Chain::Mainnet && chain != Chain::Testnet {
4764 cfg.feature_flags.check_object_funds_withdraw_in_execution = true;
4765 }
4766 cfg.reserve_object_funds_for_withdrawal_cost_base = Some(52);
4767 cfg.reserve_object_funds_for_withdrawal_cold_read_cost = Some(184);
4770
4771 cfg.feature_flags.allowed_proposers = true;
4772
4773 cfg.feature_flags.validate_ptb_argument_indices = true;
4774 cfg.feature_flags.memory_safety_invariant_check_v2 = true;
4775 }
4776 138 => {
4777 cfg.gas_model_version = Some(15);
4778 if chain != Chain::Mainnet {
4779 cfg.feature_flags.check_object_funds_withdraw_in_execution = true;
4780 }
4781 }
4782 _ => panic!("unsupported version {:?}", version),
4793 }
4794 }
4795
4796 cfg
4797 }
4798
4799 pub fn apply_seeded_test_overrides(&mut self, seed: &[u8; 32]) {
4800 if !self.feature_flags.randomize_checkpoint_tx_limit_in_tests
4801 || !self.feature_flags.split_checkpoints_in_consensus_handler
4802 {
4803 return;
4804 }
4805
4806 if !mysten_common::in_test_configuration() {
4807 return;
4808 }
4809
4810 use rand::{Rng, SeedableRng, rngs::StdRng};
4811 let mut rng = StdRng::from_seed(*seed);
4812 let max_txns = rng.gen_range(10..=100u64);
4813 info!("seeded test override: max_transactions_per_checkpoint = {max_txns}");
4814 self.max_transactions_per_checkpoint = Some(max_txns);
4815 }
4816
4817 pub fn verifier_config(&self, signing_limits: Option<(usize, usize, usize)>) -> VerifierConfig {
4823 let (
4824 max_back_edges_per_function,
4825 max_back_edges_per_module,
4826 sanity_check_with_regex_reference_safety,
4827 ) = if let Some((
4828 max_back_edges_per_function,
4829 max_back_edges_per_module,
4830 sanity_check_with_regex_reference_safety,
4831 )) = signing_limits
4832 {
4833 (
4834 Some(max_back_edges_per_function),
4835 Some(max_back_edges_per_module),
4836 Some(sanity_check_with_regex_reference_safety),
4837 )
4838 } else {
4839 (None, None, None)
4840 };
4841
4842 let additional_borrow_checks = if signing_limits.is_some() {
4843 true
4845 } else {
4846 self.additional_borrow_checks()
4847 };
4848 let deprecate_global_storage_ops = if signing_limits.is_some() {
4849 true
4851 } else {
4852 self.deprecate_global_storage_ops()
4853 };
4854
4855 VerifierConfig {
4856 max_loop_depth: Some(self.max_loop_depth() as usize),
4857 max_generic_instantiation_length: Some(self.max_generic_instantiation_length() as usize),
4858 max_function_parameters: Some(self.max_function_parameters() as usize),
4859 max_basic_blocks: Some(self.max_basic_blocks() as usize),
4860 max_value_stack_size: self.max_value_stack_size() as usize,
4861 max_type_nodes: Some(self.max_type_nodes() as usize),
4862 max_generic_instantiation_type_nodes_per_function: self
4863 .max_generic_instantiation_type_nodes_per_function_as_option()
4864 .map(|v| v as usize),
4865 max_generic_instantiation_type_nodes_per_module: self
4866 .max_generic_instantiation_type_nodes_per_module_as_option()
4867 .map(|v| v as usize),
4868 include_function_signatures_in_instantiation_limits: self
4869 .include_function_signatures_in_instantiation_limits(),
4870 max_push_size: Some(self.max_push_size() as usize),
4871 max_dependency_depth: Some(self.max_dependency_depth() as usize),
4872 max_fields_in_struct: Some(self.max_fields_in_struct() as usize),
4873 max_function_definitions: Some(self.max_function_definitions() as usize),
4874 max_data_definitions: Some(self.max_struct_definitions() as usize),
4875 max_constant_vector_len: Some(self.max_move_vector_len()),
4876 max_back_edges_per_function,
4877 max_back_edges_per_module,
4878 max_basic_blocks_in_script: None,
4879 max_identifier_len: self.max_move_identifier_len_as_option(), disallow_self_identifier: self.feature_flags.disallow_self_identifier,
4881 allow_receiving_object_id: self.allow_receiving_object_id(),
4882 reject_mutable_random_on_entry_functions: self
4883 .reject_mutable_random_on_entry_functions(),
4884 bytecode_version: self.move_binary_format_version(),
4885 max_variants_in_enum: self.max_move_enum_variants_as_option(),
4886 additional_borrow_checks,
4887 better_loader_errors: self.better_loader_errors(),
4888 private_generics_verifier_v2: self.private_generics_verifier_v2(),
4889 sanity_check_with_regex_reference_safety: sanity_check_with_regex_reference_safety
4890 .map(|limit| limit as u128),
4891 deprecate_global_storage_ops,
4892 disable_entry_point_signature_check: self.disable_entry_point_signature_check(),
4893 switch_to_regex_reference_safety: false,
4894 framework_tx_context_mut_restrictions: self.framework_tx_context_mut_restrictions(),
4895 disallow_jump_orphans: self.disallow_jump_orphans(),
4896 }
4897 }
4898
4899 pub fn binary_config(
4900 &self,
4901 override_deprecate_global_storage_ops_during_deserialization: Option<bool>,
4902 ) -> BinaryConfig {
4903 let deprecate_global_storage_ops =
4904 override_deprecate_global_storage_ops_during_deserialization
4905 .unwrap_or_else(|| self.deprecate_global_storage_ops());
4906 BinaryConfig::new(
4907 self.move_binary_format_version(),
4908 self.min_move_binary_format_version_as_option()
4909 .unwrap_or(VERSION_1),
4910 self.no_extraneous_module_bytes(),
4911 deprecate_global_storage_ops,
4912 TableConfig {
4913 module_handles: self.binary_module_handles_as_option().unwrap_or(u16::MAX),
4914 datatype_handles: self.binary_struct_handles_as_option().unwrap_or(u16::MAX),
4915 function_handles: self.binary_function_handles_as_option().unwrap_or(u16::MAX),
4916 function_instantiations: self
4917 .binary_function_instantiations_as_option()
4918 .unwrap_or(u16::MAX),
4919 signatures: self.binary_signatures_as_option().unwrap_or(u16::MAX),
4920 constant_pool: self.binary_constant_pool_as_option().unwrap_or(u16::MAX),
4921 identifiers: self.binary_identifiers_as_option().unwrap_or(u16::MAX),
4922 address_identifiers: self
4923 .binary_address_identifiers_as_option()
4924 .unwrap_or(u16::MAX),
4925 struct_defs: self.binary_struct_defs_as_option().unwrap_or(u16::MAX),
4926 struct_def_instantiations: self
4927 .binary_struct_def_instantiations_as_option()
4928 .unwrap_or(u16::MAX),
4929 function_defs: self.binary_function_defs_as_option().unwrap_or(u16::MAX),
4930 field_handles: self.binary_field_handles_as_option().unwrap_or(u16::MAX),
4931 field_instantiations: self
4932 .binary_field_instantiations_as_option()
4933 .unwrap_or(u16::MAX),
4934 friend_decls: self.binary_friend_decls_as_option().unwrap_or(u16::MAX),
4935 enum_defs: self.binary_enum_defs_as_option().unwrap_or(u16::MAX),
4936 enum_def_instantiations: self
4937 .binary_enum_def_instantiations_as_option()
4938 .unwrap_or(u16::MAX),
4939 variant_handles: self.binary_variant_handles_as_option().unwrap_or(u16::MAX),
4940 variant_instantiation_handles: self
4941 .binary_variant_instantiation_handles_as_option()
4942 .unwrap_or(u16::MAX),
4943 },
4944 )
4945 }
4946
4947 pub fn apply_overrides_for_testing(
4951 override_fn: impl Fn(ProtocolVersion, Self) -> Self + Send + Sync + 'static,
4952 ) -> OverrideGuard {
4953 let mut cur = CONFIG_OVERRIDE.lock().unwrap();
4954 assert!(cur.is_none(), "config override already present");
4955 *cur = Some(Box::new(override_fn));
4956 OverrideGuard
4957 }
4958
4959 fn apply_config_override(version: ProtocolVersion, mut ret: Self) -> Self {
4960 if let Some(override_fn) = CONFIG_OVERRIDE.lock().unwrap().as_ref() {
4961 warn!(
4962 "overriding ProtocolConfig settings with custom settings (you should not see this log outside of tests)"
4963 );
4964 ret = override_fn(version, ret);
4965 }
4966 ret
4967 }
4968}
4969
4970impl ProtocolConfig {
4974 pub fn set_execution_version_for_testing(&mut self, val: u64) {
4978 let current = self.execution_version.unwrap_or(0);
4979 assert!(
4980 val >= current,
4981 "cannot downgrade execution_version from {current} to {val}: running an old \
4982 executor against a newer protocol config/framework is unsupported. To test \
4983 frozen executor behavior, start from the last protocol version of that executor \
4984 instead, so genesis loads the matching framework snapshot (see \
4985 test_address_balance_gas_v3_accumulator_sign)."
4986 );
4987 self.execution_version = Some(val);
4988 }
4989
4990 pub fn set_zklogin_circuit_mode_for_testing(&mut self, val: u64) {
4993 self.feature_flags.zklogin_circuit_mode = val
4994 }
4995
4996 pub fn set_per_object_congestion_control_mode_for_testing(
4997 &mut self,
4998 val: PerObjectCongestionControlMode,
4999 ) {
5000 self.feature_flags.per_object_congestion_control_mode = val;
5001 }
5002
5003 pub fn set_consensus_choice_for_testing(&mut self, val: ConsensusChoice) {
5004 self.feature_flags.consensus_choice = val;
5005 }
5006
5007 pub fn set_consensus_network_for_testing(&mut self, val: ConsensusNetwork) {
5008 self.feature_flags.consensus_network = val;
5009 }
5010
5011 pub fn set_zklogin_max_epoch_upper_bound_delta_for_testing(&mut self, val: Option<u64>) {
5012 self.feature_flags.zklogin_max_epoch_upper_bound_delta = val
5013 }
5014
5015 pub fn set_mysticeti_num_leaders_per_round_for_testing(&mut self, val: Option<usize>) {
5016 self.feature_flags.mysticeti_num_leaders_per_round = val;
5017 }
5018
5019 pub fn disable_accumulators_for_testing(&mut self) {
5020 self.feature_flags.enable_accumulators = false;
5021 self.feature_flags.enable_address_balance_gas_payments = false;
5022 }
5023
5024 pub fn enable_coin_reservation_for_testing(&mut self) {
5025 self.feature_flags.enable_coin_reservation_obj_refs = true;
5026 self.feature_flags
5027 .convert_withdrawal_compatibility_ptb_arguments = true;
5028 self.execution_version = Some(self.execution_version.map_or(4, |v| v.max(4)));
5031 }
5032
5033 pub fn disable_coin_reservation_for_testing(&mut self) {
5034 self.feature_flags.enable_coin_reservation_obj_refs = false;
5035 self.feature_flags
5036 .convert_withdrawal_compatibility_ptb_arguments = false;
5037 }
5038
5039 pub fn enable_address_balance_gas_payments_for_testing(&mut self) {
5040 self.feature_flags.enable_accumulators = true;
5041 self.feature_flags.allow_private_accumulator_entrypoints = true;
5042 self.feature_flags.enable_address_balance_gas_payments = true;
5043 self.feature_flags.address_balance_gas_check_rgp_at_signing = true;
5044 self.feature_flags.address_balance_gas_reject_gas_coin_arg = false;
5045 self.execution_version = Some(self.execution_version.map_or(4, |v| v.max(4)))
5046 }
5047
5048 pub fn enable_gasless_for_testing(&mut self) {
5049 self.enable_address_balance_gas_payments_for_testing();
5050 self.feature_flags.enable_gasless = true;
5051 self.feature_flags.gasless_verify_remaining_balance = true;
5052 self.gasless_max_computation_units = Some(5_000);
5053 self.gasless_allowed_token_types = Some(vec![]);
5054 self.gasless_max_tps = Some(1000);
5055 self.gasless_max_tx_size_bytes = Some(16 * 1024);
5056 }
5057
5058 pub fn disable_gasless_for_testing(&mut self) {
5059 self.feature_flags.enable_gasless = false;
5060 self.gasless_max_computation_units = None;
5061 self.gasless_allowed_token_types = None;
5062 }
5063
5064 pub fn enable_authenticated_event_streams_for_testing(&mut self) {
5065 self.feature_flags.enable_accumulators = true;
5066 self.feature_flags.enable_authenticated_event_streams = true;
5067 self.feature_flags
5068 .include_checkpoint_artifacts_digest_in_summary = true;
5069 self.feature_flags.split_checkpoints_in_consensus_handler = true;
5070 }
5071}
5072
5073type OverrideFn = dyn Fn(ProtocolVersion, ProtocolConfig) -> ProtocolConfig + Send + Sync;
5074
5075static CONFIG_OVERRIDE: Mutex<Option<Box<OverrideFn>>> = Mutex::new(None);
5076
5077#[must_use]
5078pub struct OverrideGuard;
5079
5080impl Drop for OverrideGuard {
5081 fn drop(&mut self) {
5082 info!("restoring override fn");
5083 *CONFIG_OVERRIDE.lock().unwrap() = None;
5084 }
5085}
5086
5087#[derive(PartialEq, Eq)]
5090pub enum LimitThresholdCrossed {
5091 None,
5092 Soft(u128, u128),
5093 Hard(u128, u128),
5094}
5095
5096pub fn check_limit_in_range<T: Into<V>, U: Into<V>, V: PartialOrd + Into<u128>>(
5099 x: T,
5100 soft_limit: U,
5101 hard_limit: V,
5102) -> LimitThresholdCrossed {
5103 let x: V = x.into();
5104 let soft_limit: V = soft_limit.into();
5105
5106 debug_assert!(soft_limit <= hard_limit);
5107
5108 if x >= hard_limit {
5111 LimitThresholdCrossed::Hard(x.into(), hard_limit.into())
5112 } else if x < soft_limit {
5113 LimitThresholdCrossed::None
5114 } else {
5115 LimitThresholdCrossed::Soft(x.into(), soft_limit.into())
5116 }
5117}
5118
5119#[macro_export]
5120macro_rules! check_limit {
5121 ($x:expr, $hard:expr) => {
5122 check_limit!($x, $hard, $hard)
5123 };
5124 ($x:expr, $soft:expr, $hard:expr) => {
5125 check_limit_in_range($x as u64, $soft, $hard)
5126 };
5127}
5128
5129#[macro_export]
5133macro_rules! check_limit_by_meter {
5134 ($is_metered:expr, $x:expr, $metered_limit:expr, $unmetered_hard_limit:expr, $metric:expr) => {{
5135 let (h, metered_str) = if $is_metered {
5137 ($metered_limit, "metered")
5138 } else {
5139 ($unmetered_hard_limit, "unmetered")
5141 };
5142 use sui_protocol_config::check_limit_in_range;
5143 let result = check_limit_in_range($x as u64, $metered_limit, h);
5144 match result {
5145 LimitThresholdCrossed::None => {}
5146 LimitThresholdCrossed::Soft(_, _) => {
5147 $metric.with_label_values(&[metered_str, "soft"]).inc();
5148 }
5149 LimitThresholdCrossed::Hard(_, _) => {
5150 $metric.with_label_values(&[metered_str, "hard"]).inc();
5151 }
5152 };
5153 result
5154 }};
5155}
5156
5157pub type Amendments = BTreeMap<AccountAddress, BTreeMap<AccountAddress, AccountAddress>>;
5160
5161static MAINNET_LINKAGE_AMENDMENTS: LazyLock<Arc<Amendments>> =
5162 LazyLock::new(|| parse_amendments(include_str!("mainnet_amendments.json")));
5163
5164static TESTNET_LINKAGE_AMENDMENTS: LazyLock<Arc<Amendments>> =
5165 LazyLock::new(|| parse_amendments(include_str!("testnet_amendments.json")));
5166
5167fn parse_amendments(json: &str) -> Arc<Amendments> {
5168 #[derive(serde::Deserialize)]
5169 struct AmendmentEntry {
5170 root: String,
5171 deps: Vec<DepEntry>,
5172 }
5173
5174 #[derive(serde::Deserialize)]
5175 struct DepEntry {
5176 original_id: String,
5177 version_id: String,
5178 }
5179
5180 let entries: Vec<AmendmentEntry> =
5181 serde_json::from_str(json).expect("Failed to parse amendments JSON");
5182 let mut amendments = BTreeMap::new();
5183 for entry in entries {
5184 let root_id = AccountAddress::from_hex_literal(&entry.root).unwrap();
5185 let mut dep_ids = BTreeMap::new();
5186 for dep in entry.deps {
5187 let orig_id = AccountAddress::from_hex_literal(&dep.original_id).unwrap();
5188 let upgraded_id = AccountAddress::from_hex_literal(&dep.version_id).unwrap();
5189 assert!(
5190 dep_ids.insert(orig_id, upgraded_id).is_none(),
5191 "Duplicate original ID in amendments table"
5192 );
5193 }
5194 assert!(
5195 amendments.insert(root_id, dep_ids).is_none(),
5196 "Duplicate root ID in amendments table"
5197 );
5198 }
5199 Arc::new(amendments)
5200}
5201
5202#[cfg(all(test, not(msim)))]
5203mod test {
5204 use insta::assert_yaml_snapshot;
5205
5206 use super::*;
5207
5208 #[test]
5209 fn snapshot_tests() {
5210 println!("\n============================================================================");
5211 println!("! !");
5212 println!("! IMPORTANT: never update snapshots from this test. only add new versions! !");
5213 println!("! !");
5214 println!("============================================================================\n");
5215 for chain_id in &[Chain::Unknown, Chain::Mainnet, Chain::Testnet] {
5216 let chain_str = match chain_id {
5220 Chain::Unknown => "".to_string(),
5221 _ => format!("{:?}_", chain_id),
5222 };
5223 for i in MIN_PROTOCOL_VERSION..=MAX_PROTOCOL_VERSION {
5224 let cur = ProtocolVersion::new(i);
5225 assert_yaml_snapshot!(
5226 format!("{}version_{}", chain_str, cur.as_u64()),
5227 ProtocolConfig::get_for_version(cur, *chain_id)
5228 );
5229 }
5230 }
5231 }
5232
5233 #[test]
5234 fn test_getters() {
5235 let prot: ProtocolConfig =
5236 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5237 assert_eq!(
5238 prot.max_arguments(),
5239 prot.max_arguments_as_option().unwrap()
5240 );
5241 }
5242
5243 #[test]
5244 fn test_setters() {
5245 let mut prot: ProtocolConfig =
5246 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5247 prot.set_max_arguments_for_testing(123);
5248 assert_eq!(prot.max_arguments(), 123);
5249
5250 prot.set_max_arguments_from_str_for_testing("321".to_string());
5251 assert_eq!(prot.max_arguments(), 321);
5252
5253 prot.disable_max_arguments_for_testing();
5254 assert_eq!(prot.max_arguments_as_option(), None);
5255
5256 prot.set_attr_for_testing("max_arguments".to_string(), "456".to_string());
5257 assert_eq!(prot.max_arguments(), 456);
5258 }
5259
5260 #[test]
5261 fn test_execution_version_setter_allows_upgrade() {
5262 let mut prot = ProtocolConfig::get_for_max_version_UNSAFE();
5263 let current = prot.execution_version();
5264 prot.set_execution_version_for_testing(current);
5265 prot.set_execution_version_for_testing(current + 1);
5266 assert_eq!(prot.execution_version(), current + 1);
5267 }
5268
5269 #[test]
5270 #[should_panic(expected = "cannot downgrade execution_version")]
5271 fn test_execution_version_setter_panics_on_downgrade() {
5272 let mut prot = ProtocolConfig::get_for_max_version_UNSAFE();
5273 let current = prot.execution_version();
5274 prot.set_execution_version_for_testing(current - 1);
5275 }
5276
5277 #[test]
5278 fn test_feature_flag_setter_by_string() {
5279 let mut prot: ProtocolConfig =
5280 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5281 assert!(!prot.zklogin_auth());
5282 prot.set_feature_flag_for_testing("zklogin_auth".to_string(), true);
5283 assert!(prot.zklogin_auth());
5284 prot.set_feature_flag_for_testing("zklogin_auth".to_string(), false);
5285 assert!(!prot.zklogin_auth());
5286 }
5287
5288 #[test]
5289 #[should_panic(expected = "unknown feature flag")]
5290 fn test_feature_flag_setter_unknown_flag() {
5291 let mut prot: ProtocolConfig =
5292 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5293 prot.set_feature_flag_for_testing("some random string".to_string(), true);
5294 }
5295
5296 #[test]
5297 fn test_get_for_version_if_supported_applies_test_overrides() {
5298 let before =
5299 ProtocolConfig::get_for_version_if_supported(ProtocolVersion::new(1), Chain::Unknown)
5300 .unwrap();
5301
5302 assert!(!before.enable_coin_reservation_obj_refs());
5303
5304 let _guard = ProtocolConfig::apply_overrides_for_testing(|_, mut cfg| {
5305 cfg.enable_coin_reservation_for_testing();
5306 cfg
5307 });
5308
5309 let after =
5310 ProtocolConfig::get_for_version_if_supported(ProtocolVersion::new(1), Chain::Unknown)
5311 .unwrap();
5312
5313 assert!(after.enable_coin_reservation_obj_refs());
5314 }
5315
5316 #[test]
5317 #[should_panic(expected = "unsupported version")]
5318 fn max_version_test() {
5319 let _ = ProtocolConfig::get_for_version_impl(
5322 ProtocolVersion::new(MAX_PROTOCOL_VERSION + 1),
5323 Chain::Unknown,
5324 );
5325 }
5326
5327 #[test]
5328 fn lookup_by_string_test() {
5329 let prot: ProtocolConfig =
5330 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5331 assert!(prot.lookup_attr("some random string".to_string()).is_none());
5333
5334 assert!(
5335 prot.lookup_attr("max_arguments".to_string())
5336 == Some(ProtocolConfigValue::u32(prot.max_arguments())),
5337 );
5338
5339 assert!(
5341 prot.lookup_attr("max_move_identifier_len".to_string())
5342 .is_none()
5343 );
5344
5345 let prot: ProtocolConfig =
5347 ProtocolConfig::get_for_version(ProtocolVersion::new(9), Chain::Unknown);
5348 assert!(
5349 prot.lookup_attr("max_move_identifier_len".to_string())
5350 == Some(ProtocolConfigValue::u64(prot.max_move_identifier_len()))
5351 );
5352
5353 let prot: ProtocolConfig =
5354 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5355 assert!(
5357 prot.attr_map()
5358 .get("max_move_identifier_len")
5359 .unwrap()
5360 .is_none()
5361 );
5362 assert!(
5364 prot.attr_map().get("max_arguments").unwrap()
5365 == &Some(ProtocolConfigValue::u32(prot.max_arguments()))
5366 );
5367
5368 let prot: ProtocolConfig =
5370 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5371 assert!(
5373 prot.feature_flags
5374 .lookup_attr("some random string".to_owned())
5375 .is_none()
5376 );
5377 assert!(
5378 !prot
5379 .feature_flags
5380 .attr_map()
5381 .contains_key("some random string")
5382 );
5383
5384 assert!(
5386 prot.feature_flags
5387 .lookup_attr("package_upgrades".to_owned())
5388 == Some(false)
5389 );
5390 assert!(
5391 prot.feature_flags
5392 .attr_map()
5393 .get("package_upgrades")
5394 .unwrap()
5395 == &false
5396 );
5397 let prot: ProtocolConfig =
5398 ProtocolConfig::get_for_version(ProtocolVersion::new(4), Chain::Unknown);
5399 assert!(
5401 prot.feature_flags
5402 .lookup_attr("package_upgrades".to_owned())
5403 == Some(true)
5404 );
5405 assert!(
5406 prot.feature_flags
5407 .attr_map()
5408 .get("package_upgrades")
5409 .unwrap()
5410 == &true
5411 );
5412 }
5413
5414 #[test]
5415 fn limit_range_fn_test() {
5416 let low = 100u32;
5417 let high = 10000u64;
5418
5419 assert!(check_limit!(1u8, low, high) == LimitThresholdCrossed::None);
5420 assert!(matches!(
5421 check_limit!(255u16, low, high),
5422 LimitThresholdCrossed::Soft(255u128, 100)
5423 ));
5424 assert!(matches!(
5430 check_limit!(2550000u64, low, high),
5431 LimitThresholdCrossed::Hard(2550000, 10000)
5432 ));
5433
5434 assert!(matches!(
5435 check_limit!(2550000u64, high, high),
5436 LimitThresholdCrossed::Hard(2550000, 10000)
5437 ));
5438
5439 assert!(matches!(
5440 check_limit!(1u8, high),
5441 LimitThresholdCrossed::None
5442 ));
5443
5444 assert!(check_limit!(255u16, high) == LimitThresholdCrossed::None);
5445
5446 assert!(matches!(
5447 check_limit!(2550000u64, high),
5448 LimitThresholdCrossed::Hard(2550000, 10000)
5449 ));
5450 }
5451
5452 #[test]
5453 fn linkage_amendments_load() {
5454 let mainnet = LazyLock::force(&MAINNET_LINKAGE_AMENDMENTS);
5455 let testnet = LazyLock::force(&TESTNET_LINKAGE_AMENDMENTS);
5456 assert!(!mainnet.is_empty(), "mainnet amendments must not be empty");
5457 assert!(!testnet.is_empty(), "testnet amendments must not be empty");
5458 }
5459
5460 #[test]
5461 fn render_scalar_fields_use_precision_safe_encoding() {
5462 use mysten_common::rpc_format::Unmetered;
5463
5464 let config = ProtocolConfig::get_for_max_version_UNSAFE();
5465 let rendered = config
5466 .render::<serde_json::Value>(&mut Unmetered)
5467 .expect("render should succeed");
5468
5469 let max_args = rendered
5470 .get("max_arguments")
5471 .expect("max_arguments set at max version");
5472 assert!(
5473 max_args.is_number(),
5474 "u32 should render as number, got {max_args:?}",
5475 );
5476
5477 let max_tx_size = rendered
5478 .get("max_tx_size_bytes")
5479 .expect("max_tx_size_bytes set at max version");
5480 assert!(
5481 max_tx_size.is_string(),
5482 "u64 should render as string, got {max_tx_size:?}",
5483 );
5484 }
5485
5486 #[test]
5487 fn render_includes_non_scalar_gasless_allowlist_as_json() {
5488 use mysten_common::rpc_format::Unmetered;
5489 use serde_json::json;
5490
5491 let mut config = ProtocolConfig::get_for_max_version_UNSAFE();
5492 config.set_gasless_allowed_token_types_for_testing(vec![
5493 ("0xa::usdc::USDC".to_string(), 10_000),
5494 ("0xb::usdt::USDT".to_string(), 0),
5495 ]);
5496
5497 let rendered = config
5498 .render::<serde_json::Value>(&mut Unmetered)
5499 .expect("render should succeed under Unmetered budget");
5500 let allowlist = rendered
5501 .get("gasless_allowed_token_types")
5502 .expect("entry should be present after the testing setter");
5503
5504 assert_eq!(
5507 allowlist,
5508 &json!([["0xa::usdc::USDC", "10000"], ["0xb::usdt::USDT", "0"],]),
5509 );
5510 }
5511
5512 #[test]
5513 fn render_targets_prost_value_for_grpc() {
5514 use mysten_common::rpc_format::Unmetered;
5515 use prost_types::value::Kind;
5516
5517 let mut config = ProtocolConfig::get_for_max_version_UNSAFE();
5518 config.set_gasless_allowed_token_types_for_testing(vec![(
5519 "0xa::usdc::USDC".to_string(),
5520 10_000,
5521 )]);
5522
5523 let rendered = config
5524 .render::<prost_types::Value>(&mut Unmetered)
5525 .expect("render to prost Value should succeed");
5526 let allowlist = rendered
5527 .get("gasless_allowed_token_types")
5528 .expect("entry should be present after the testing setter");
5529
5530 let Some(Kind::ListValue(outer)) = &allowlist.kind else {
5532 panic!(
5533 "expected ListValue at the top level, got {:?}",
5534 allowlist.kind
5535 );
5536 };
5537 assert_eq!(outer.values.len(), 1, "one allowlisted entry");
5538 let Some(Kind::ListValue(entry)) = &outer.values[0].kind else {
5539 panic!("expected each entry to be a ListValue");
5540 };
5541 assert_eq!(entry.values.len(), 2, "entry has (coin_type, amount)");
5542
5543 let Some(Kind::StringValue(coin_type)) = &entry.values[0].kind else {
5544 panic!("expected coin_type as StringValue");
5545 };
5546 assert_eq!(coin_type, "0xa::usdc::USDC");
5547
5548 let Some(Kind::StringValue(amount)) = &entry.values[1].kind else {
5550 panic!(
5551 "expected minimum_transfer_amount as StringValue (precision-safe u64); got {:?}",
5552 entry.values[1].kind,
5553 );
5554 };
5555 assert_eq!(amount, "10000");
5556 }
5557
5558 #[test]
5559 fn render_emits_null_for_unset_protocol_versions() {
5560 use mysten_common::rpc_format::Unmetered;
5561
5562 let config = ProtocolConfig::get_for_version(1.into(), Chain::Unknown);
5563 let rendered = config
5564 .render::<serde_json::Value>(&mut Unmetered)
5565 .expect("render should succeed");
5566 let entry = rendered
5570 .get("gasless_allowed_token_types")
5571 .expect("key should be present for every protocol version");
5572 assert!(
5573 entry.is_null(),
5574 "value should be null for pre-feature protocol version, got {entry:?}",
5575 );
5576 }
5577}