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
30const MIN_PROTOCOL_VERSION: u64 = 1;
32const MAX_PROTOCOL_VERSION: u64 = 137;
33
34const TESTNET_USDC: &str =
35 "0xa1ec7fc00a6f40db9693ad1415d0c193ad3906494428cf252621037bd7117e29::usdc::USDC";
36
37const MAINNET_USDC: &str =
38 "0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC";
39const MAINNET_USDSUI: &str =
40 "0x44f838219cf67b058f3b37907b655f226153c18e33dfcd0da559a844fea9b1c1::usdsui::USDSUI";
41const MAINNET_SUI_USDE: &str =
42 "0x41d587e5336f1c86cad50d38a7136db99333bb9bda91cea4ba69115defeb1402::sui_usde::SUI_USDE";
43const MAINNET_USDY: &str =
44 "0x960b531667636f39e85867775f52f6b1f220a058c4de786905bdf761e06a56bb::usdy::USDY";
45const MAINNET_FDUSD: &str =
46 "0xf16e6b723f242ec745dfd7634ad072c42d5c1d9ac9d62a39c381303eaa57693a::fdusd::FDUSD";
47const MAINNET_AUSD: &str =
48 "0x2053d08c1e2bd02791056171aab0fd12bd7cd7efad2ab8f6b9c8902f14df2ff2::ausd::AUSD";
49const MAINNET_USDB: &str =
50 "0xe14726c336e81b32328e92afc37345d159f5b550b09fa92bd43640cfdd0a0cfd::usdb::USDB";
51
52#[derive(Copy, Clone, Debug, Hash, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)]
395pub struct ProtocolVersion(u64);
396
397impl ProtocolVersion {
398 pub const MIN: Self = Self(MIN_PROTOCOL_VERSION);
403
404 pub const MAX: Self = Self(MAX_PROTOCOL_VERSION);
405
406 #[cfg(not(msim))]
407 pub const MAX_ALLOWED: Self = Self::MAX;
408
409 #[cfg(msim)]
411 pub const MAX_ALLOWED: Self = Self(MAX_PROTOCOL_VERSION + 1);
412
413 pub fn new(v: u64) -> Self {
414 Self(v)
415 }
416
417 pub const fn as_u64(&self) -> u64 {
418 self.0
419 }
420
421 pub fn max() -> Self {
424 Self::MAX
425 }
426
427 pub fn prev(self) -> Self {
428 Self(self.0.checked_sub(1).unwrap())
429 }
430}
431
432impl From<u64> for ProtocolVersion {
433 fn from(v: u64) -> Self {
434 Self::new(v)
435 }
436}
437
438impl std::ops::Sub<u64> for ProtocolVersion {
439 type Output = Self;
440 fn sub(self, rhs: u64) -> Self::Output {
441 Self::new(self.0 - rhs)
442 }
443}
444
445impl std::ops::Add<u64> for ProtocolVersion {
446 type Output = Self;
447 fn add(self, rhs: u64) -> Self::Output {
448 Self::new(self.0 + rhs)
449 }
450}
451
452#[derive(
453 Clone, Serialize, Deserialize, Debug, Default, PartialEq, Copy, PartialOrd, Ord, Eq, ValueEnum,
454)]
455pub enum Chain {
456 Mainnet,
457 Testnet,
458 #[default]
459 Unknown,
460}
461
462impl Chain {
463 pub fn as_str(self) -> &'static str {
464 match self {
465 Chain::Mainnet => "mainnet",
466 Chain::Testnet => "testnet",
467 Chain::Unknown => "unknown",
468 }
469 }
470}
471
472pub struct Error(pub String);
473
474#[derive(Default, Clone, Serialize, Deserialize, Debug, ProtocolConfigFeatureFlagsGetters)]
477struct FeatureFlags {
478 #[serde(skip_serializing_if = "is_false")]
481 package_upgrades: bool,
482 #[serde(skip_serializing_if = "is_false")]
485 commit_root_state_digest: bool,
486 #[serde(skip_serializing_if = "is_false")]
488 advance_epoch_start_time_in_safe_mode: bool,
489 #[serde(skip_serializing_if = "is_false")]
492 loaded_child_objects_fixed: bool,
493 #[serde(skip_serializing_if = "is_false")]
496 missing_type_is_compatibility_error: bool,
497 #[serde(skip_serializing_if = "is_false")]
500 scoring_decision_with_validity_cutoff: bool,
501
502 #[serde(skip_serializing_if = "is_false")]
505 consensus_order_end_of_epoch_last: bool,
506
507 #[serde(skip_serializing_if = "is_false")]
511 consensus_slim_block_propagation: bool,
512
513 #[serde(skip_serializing_if = "is_false")]
515 disallow_adding_abilities_on_upgrade: bool,
516 #[serde(skip_serializing_if = "is_false")]
518 disable_invariant_violation_check_in_swap_loc: bool,
519 #[serde(skip_serializing_if = "is_false")]
522 advance_to_highest_supported_protocol_version: bool,
523 #[serde(skip_serializing_if = "is_false")]
525 ban_entry_init: bool,
526 #[serde(skip_serializing_if = "is_false")]
528 package_digest_hash_module: bool,
529 #[serde(skip_serializing_if = "is_false")]
531 disallow_change_struct_type_params_on_upgrade: bool,
532 #[serde(skip_serializing_if = "is_false")]
534 no_extraneous_module_bytes: bool,
535 #[serde(skip_serializing_if = "is_false")]
537 narwhal_versioned_metadata: bool,
538
539 #[serde(skip_serializing_if = "is_false")]
541 zklogin_auth: bool,
542 #[serde(skip_serializing_if = "is_zero")]
545 zklogin_circuit_mode: u64,
546 #[serde(skip_serializing_if = "ConsensusTransactionOrdering::is_none")]
548 consensus_transaction_ordering: ConsensusTransactionOrdering,
549
550 #[serde(skip_serializing_if = "is_false")]
558 simplified_unwrap_then_delete: bool,
559 #[serde(skip_serializing_if = "is_false")]
561 upgraded_multisig_supported: bool,
562 #[serde(skip_serializing_if = "is_false")]
564 txn_base_cost_as_multiplier: bool,
565
566 #[serde(skip_serializing_if = "is_false")]
568 shared_object_deletion: bool,
569
570 #[serde(skip_serializing_if = "is_false")]
572 narwhal_new_leader_election_schedule: bool,
573
574 #[serde(skip_serializing_if = "is_empty")]
576 zklogin_supported_providers: BTreeSet<String>,
577
578 #[serde(skip_serializing_if = "is_false")]
580 loaded_child_object_format: bool,
581
582 #[serde(skip_serializing_if = "is_false")]
583 #[skip_protocol_config_accessor]
584 enable_jwk_consensus_updates: bool,
585
586 #[serde(skip_serializing_if = "is_false")]
587 #[skip_protocol_config_accessor]
588 end_of_epoch_transaction_supported: bool,
589
590 #[serde(skip_serializing_if = "is_false")]
593 simple_conservation_checks: bool,
594
595 #[serde(skip_serializing_if = "is_false")]
597 loaded_child_object_format_type: bool,
598
599 #[serde(skip_serializing_if = "is_false")]
601 receive_objects: bool,
602
603 #[serde(skip_serializing_if = "is_false")]
605 consensus_checkpoint_signature_key_includes_digest: bool,
606
607 #[serde(skip_serializing_if = "is_false")]
609 random_beacon: bool,
610
611 #[serde(skip_serializing_if = "is_false")]
613 #[skip_protocol_config_accessor]
614 bridge: bool,
615
616 #[serde(skip_serializing_if = "is_false")]
617 enable_effects_v2: bool,
618
619 #[serde(skip_serializing_if = "is_false")]
621 narwhal_certificate_v2: bool,
622
623 #[serde(skip_serializing_if = "is_false")]
625 verify_legacy_zklogin_address: bool,
626
627 #[serde(skip_serializing_if = "is_false")]
629 throughput_aware_consensus_submission: bool,
630
631 #[serde(skip_serializing_if = "is_false")]
633 recompute_has_public_transfer_in_execution: bool,
634
635 #[serde(skip_serializing_if = "is_false")]
637 accept_zklogin_in_multisig: bool,
638
639 #[serde(skip_serializing_if = "is_false")]
641 accept_passkey_in_multisig: bool,
642
643 #[serde(skip_serializing_if = "is_false")]
645 validate_zklogin_public_identifier: bool,
646
647 #[serde(skip_serializing_if = "is_false")]
650 include_consensus_digest_in_prologue: bool,
651
652 #[serde(skip_serializing_if = "is_false")]
654 hardened_otw_check: bool,
655
656 #[serde(skip_serializing_if = "is_false")]
658 allow_receiving_object_id: bool,
659
660 #[serde(skip_serializing_if = "is_false")]
662 enable_poseidon: bool,
663
664 #[serde(skip_serializing_if = "is_false")]
666 enable_coin_deny_list: bool,
667
668 #[serde(skip_serializing_if = "is_false")]
670 enable_group_ops_native_functions: bool,
671
672 #[serde(skip_serializing_if = "is_false")]
674 enable_group_ops_native_function_msm: bool,
675
676 #[serde(skip_serializing_if = "is_false")]
678 enable_ristretto255_group_ops: bool,
679
680 #[serde(skip_serializing_if = "is_false")]
682 enable_verify_bulletproofs_ristretto255: bool,
683
684 #[serde(skip_serializing_if = "is_false")]
686 enable_nitro_attestation: bool,
687
688 #[serde(skip_serializing_if = "is_false")]
690 enable_nitro_attestation_upgraded_parsing: bool,
691
692 #[serde(skip_serializing_if = "is_false")]
694 enable_nitro_attestation_all_nonzero_pcrs_parsing: bool,
695
696 #[serde(skip_serializing_if = "is_false")]
698 enable_nitro_attestation_always_include_required_pcrs_parsing: bool,
699
700 #[serde(skip_serializing_if = "is_false")]
702 reject_mutable_random_on_entry_functions: bool,
703
704 #[serde(skip_serializing_if = "PerObjectCongestionControlMode::is_none")]
706 per_object_congestion_control_mode: PerObjectCongestionControlMode,
707
708 #[serde(skip_serializing_if = "ConsensusChoice::is_narwhal")]
710 consensus_choice: ConsensusChoice,
711
712 #[serde(skip_serializing_if = "ConsensusNetwork::is_anemo")]
714 consensus_network: ConsensusNetwork,
715
716 #[serde(skip_serializing_if = "is_false")]
718 correct_gas_payment_limit_check: bool,
719
720 #[serde(skip_serializing_if = "Option::is_none")]
722 zklogin_max_epoch_upper_bound_delta: Option<u64>,
723
724 #[serde(skip_serializing_if = "is_false")]
726 mysticeti_leader_scoring_and_schedule: bool,
727
728 #[serde(skip_serializing_if = "is_false")]
730 reshare_at_same_initial_version: bool,
731
732 #[serde(skip_serializing_if = "is_false")]
734 resolve_abort_locations_to_package_id: bool,
735
736 #[serde(skip_serializing_if = "is_false")]
740 mysticeti_use_committed_subdag_digest: bool,
741
742 #[serde(skip_serializing_if = "is_false")]
744 enable_vdf: bool,
745
746 #[serde(skip_serializing_if = "is_false")]
750 record_consensus_determined_version_assignments_in_prologue: bool,
751 #[serde(skip_serializing_if = "is_false")]
754 record_consensus_determined_version_assignments_in_prologue_v2: bool,
755
756 #[serde(skip_serializing_if = "is_false")]
758 fresh_vm_on_framework_upgrade: bool,
759
760 #[serde(skip_serializing_if = "is_false")]
768 prepend_prologue_tx_in_consensus_commit_in_checkpoints: bool,
769
770 #[serde(skip_serializing_if = "Option::is_none")]
772 mysticeti_num_leaders_per_round: Option<usize>,
773
774 #[serde(skip_serializing_if = "is_false")]
776 soft_bundle: bool,
777
778 #[serde(skip_serializing_if = "is_false")]
780 enable_coin_deny_list_v2: bool,
781
782 #[serde(skip_serializing_if = "is_false")]
784 passkey_auth: bool,
785
786 #[serde(skip_serializing_if = "is_false")]
788 authority_capabilities_v2: bool,
789
790 #[serde(skip_serializing_if = "is_false")]
792 rethrow_serialization_type_layout_errors: bool,
793
794 #[serde(skip_serializing_if = "is_false")]
796 consensus_distributed_vote_scoring_strategy: bool,
797
798 #[serde(skip_serializing_if = "is_false")]
800 consensus_round_prober: bool,
801
802 #[serde(skip_serializing_if = "is_false")]
804 validate_identifier_inputs: bool,
805
806 #[serde(skip_serializing_if = "is_false")]
808 disallow_self_identifier: bool,
809
810 #[serde(skip_serializing_if = "is_false")]
812 mysticeti_fastpath: bool,
813
814 #[serde(skip_serializing_if = "is_false")]
818 disable_preconsensus_locking: bool,
819
820 #[serde(skip_serializing_if = "is_false")]
822 relocate_event_module: bool,
823
824 #[serde(skip_serializing_if = "is_false")]
826 uncompressed_g1_group_elements: bool,
827
828 #[serde(skip_serializing_if = "is_false")]
829 disallow_new_modules_in_deps_only_packages: bool,
830
831 #[serde(skip_serializing_if = "is_false")]
833 consensus_smart_ancestor_selection: bool,
834
835 #[serde(skip_serializing_if = "is_false")]
837 consensus_round_prober_probe_accepted_rounds: bool,
838
839 #[serde(skip_serializing_if = "is_false")]
841 native_charging_v2: bool,
842
843 #[serde(skip_serializing_if = "is_false")]
846 #[skip_protocol_config_accessor]
847 consensus_linearize_subdag_v2: bool,
848
849 #[serde(skip_serializing_if = "is_false")]
851 convert_type_argument_error: bool,
852
853 #[serde(skip_serializing_if = "is_false")]
855 variant_nodes: bool,
856
857 #[serde(skip_serializing_if = "is_false")]
859 consensus_zstd_compression: bool,
860
861 #[serde(skip_serializing_if = "is_false")]
863 minimize_child_object_mutations: bool,
864
865 #[serde(skip_serializing_if = "is_false")]
868 record_additional_state_digest_in_prologue: bool,
869
870 #[serde(skip_serializing_if = "is_false")]
872 move_native_context: bool,
873
874 #[serde(skip_serializing_if = "is_false")]
877 #[skip_protocol_config_accessor]
878 consensus_median_based_commit_timestamp: bool,
879
880 #[serde(skip_serializing_if = "is_false")]
883 normalize_ptb_arguments: bool,
884
885 #[serde(skip_serializing_if = "is_false")]
887 consensus_batched_block_sync: bool,
888
889 #[serde(skip_serializing_if = "is_false")]
891 enforce_checkpoint_timestamp_monotonicity: bool,
892
893 #[serde(skip_serializing_if = "is_false")]
895 max_ptb_value_size_v2: bool,
896
897 #[serde(skip_serializing_if = "is_false")]
899 resolve_type_input_ids_to_defining_id: bool,
900
901 #[serde(skip_serializing_if = "is_false")]
903 enable_party_transfer: bool,
904
905 #[serde(skip_serializing_if = "is_false")]
907 allow_unbounded_system_objects: bool,
908
909 #[serde(skip_serializing_if = "is_false")]
911 type_tags_in_object_runtime: bool,
912
913 #[serde(skip_serializing_if = "is_false")]
915 enable_accumulators: bool,
916
917 #[serde(skip_serializing_if = "is_false")]
919 #[skip_protocol_config_accessor]
920 enable_coin_reservation_obj_refs: bool,
921
922 #[serde(skip_serializing_if = "is_false")]
925 create_root_accumulator_object: bool,
926
927 #[serde(skip_serializing_if = "is_false")]
929 #[skip_protocol_config_accessor]
930 enable_authenticated_event_streams: bool,
931
932 #[serde(skip_serializing_if = "is_false")]
934 enable_address_balance_gas_payments: bool,
935
936 #[serde(skip_serializing_if = "is_false")]
938 address_balance_gas_check_rgp_at_signing: bool,
939
940 #[serde(skip_serializing_if = "is_false")]
941 address_balance_gas_reject_gas_coin_arg: bool,
942
943 #[serde(skip_serializing_if = "is_false")]
945 enable_multi_epoch_transaction_expiration: bool,
946
947 #[serde(skip_serializing_if = "is_false")]
949 relax_valid_during_for_owned_inputs: bool,
950
951 #[serde(skip_serializing_if = "is_false")]
953 enable_ptb_execution_v2: bool,
954
955 #[serde(skip_serializing_if = "is_false")]
957 better_adapter_type_resolution_errors: bool,
958
959 #[serde(skip_serializing_if = "is_false")]
961 record_time_estimate_processed: bool,
962
963 #[serde(skip_serializing_if = "is_false")]
965 dependency_linkage_error: bool,
966
967 #[serde(skip_serializing_if = "is_false")]
969 additional_multisig_checks: bool,
970
971 #[serde(skip_serializing_if = "is_false")]
973 ignore_execution_time_observations_after_certs_closed: bool,
974
975 #[serde(skip_serializing_if = "is_false")]
979 debug_fatal_on_move_invariant_violation: bool,
980
981 #[serde(skip_serializing_if = "is_false")]
984 allow_private_accumulator_entrypoints: bool,
985
986 #[serde(skip_serializing_if = "is_false")]
989 additional_consensus_digest_indirect_state: bool,
990
991 #[serde(skip_serializing_if = "is_false")]
993 check_for_init_during_upgrade: bool,
994
995 #[serde(skip_serializing_if = "is_false")]
997 enable_init_on_upgrade: bool,
998
999 #[serde(skip_serializing_if = "is_false")]
1001 enable_order_independent_upgrade_init_linkage: bool,
1002
1003 #[serde(skip_serializing_if = "is_false")]
1006 harden_linkage_consistency: bool,
1007
1008 #[serde(skip_serializing_if = "is_false")]
1010 per_command_shared_object_transfer_rules: bool,
1011
1012 #[serde(skip_serializing_if = "is_false")]
1014 include_checkpoint_artifacts_digest_in_summary: bool,
1015
1016 #[serde(skip_serializing_if = "is_false")]
1018 use_mfp_txns_in_load_initial_object_debts: bool,
1019
1020 #[serde(skip_serializing_if = "is_false")]
1022 cancel_for_failed_dkg_early: bool,
1023
1024 #[serde(skip_serializing_if = "is_false")]
1026 always_advance_dkg_to_resolution: bool,
1027
1028 #[serde(skip_serializing_if = "is_false")]
1030 enable_coin_registry: bool,
1031
1032 #[serde(skip_serializing_if = "is_false")]
1034 abstract_size_in_object_runtime: bool,
1035
1036 #[serde(skip_serializing_if = "is_false")]
1038 object_runtime_charge_cache_load_gas: bool,
1039
1040 #[serde(skip_serializing_if = "is_false")]
1042 additional_borrow_checks: bool,
1043
1044 #[serde(skip_serializing_if = "is_false")]
1046 use_new_commit_handler: bool,
1047
1048 #[serde(skip_serializing_if = "is_false")]
1050 better_loader_errors: bool,
1051
1052 #[serde(skip_serializing_if = "is_false")]
1054 generate_df_type_layouts: bool,
1055
1056 #[serde(skip_serializing_if = "is_false")]
1058 allow_references_in_ptbs: bool,
1059
1060 #[serde(skip_serializing_if = "is_false")]
1067 framework_tx_context_mut_restrictions: bool,
1068
1069 #[serde(skip_serializing_if = "is_false")]
1071 include_function_signatures_in_instantiation_limits: bool,
1072
1073 #[serde(skip_serializing_if = "is_false")]
1078 ptb_tx_context_restrictions: bool,
1079
1080 #[serde(skip_serializing_if = "is_false")]
1082 enable_display_registry: bool,
1083
1084 #[serde(skip_serializing_if = "is_false")]
1086 private_generics_verifier_v2: bool,
1087
1088 #[serde(skip_serializing_if = "is_false")]
1090 deprecate_global_storage_ops_during_deserialization: bool,
1091
1092 #[serde(skip_serializing_if = "is_false")]
1095 enable_non_exclusive_writes: bool,
1096
1097 #[serde(skip_serializing_if = "is_false")]
1099 deprecate_global_storage_ops: bool,
1100
1101 #[serde(skip_serializing_if = "is_false")]
1103 normalize_depth_formula: bool,
1104
1105 #[serde(skip_serializing_if = "is_false")]
1107 consensus_skip_gced_accept_votes: bool,
1108
1109 #[serde(skip_serializing_if = "is_false")]
1112 include_cancelled_randomness_txns_in_prologue: bool,
1113
1114 #[serde(skip_serializing_if = "is_false")]
1116 #[skip_protocol_config_accessor]
1117 address_aliases: bool,
1118
1119 #[serde(skip_serializing_if = "is_false")]
1121 create_forwarding_address_registry: bool,
1122
1123 #[serde(skip_serializing_if = "is_false")]
1126 fix_checkpoint_signature_mapping: bool,
1127
1128 #[serde(skip_serializing_if = "is_false")]
1130 enable_object_funds_withdraw: bool,
1131
1132 #[serde(skip_serializing_if = "is_false")]
1135 record_net_unsettled_object_withdraws: bool,
1136
1137 #[serde(skip_serializing_if = "is_false")]
1139 consensus_skip_gced_blocks_in_direct_finalization: bool,
1140
1141 #[serde(skip_serializing_if = "is_false")]
1143 gas_rounding_halve_digits: bool,
1144
1145 #[serde(skip_serializing_if = "is_false")]
1147 flexible_tx_context_positions: bool,
1148
1149 #[serde(skip_serializing_if = "is_false")]
1151 disable_entry_point_signature_check: bool,
1152
1153 #[serde(skip_serializing_if = "is_false")]
1155 convert_withdrawal_compatibility_ptb_arguments: bool,
1156
1157 #[serde(skip_serializing_if = "is_false")]
1159 restrict_hot_or_not_entry_functions: bool,
1160
1161 #[serde(skip_serializing_if = "is_false")]
1163 split_checkpoints_in_consensus_handler: bool,
1164
1165 #[serde(skip_serializing_if = "is_false")]
1167 consensus_always_accept_system_transactions: bool,
1168
1169 #[serde(skip_serializing_if = "is_false")]
1171 validator_metadata_verify_v2: bool,
1172
1173 #[serde(skip_serializing_if = "is_false")]
1176 defer_unpaid_amplification: bool,
1177
1178 #[serde(skip_serializing_if = "is_false")]
1181 defer_owned_object_double_spend: bool,
1182
1183 #[serde(skip_serializing_if = "is_false")]
1186 allowed_proposers: bool,
1187
1188 #[serde(skip_serializing_if = "is_false")]
1189 randomize_checkpoint_tx_limit_in_tests: bool,
1190
1191 #[serde(skip_serializing_if = "is_false")]
1193 gasless_transaction_drop_safety: bool,
1194
1195 #[serde(skip_serializing_if = "is_false")]
1198 merge_randomness_into_checkpoint: bool,
1199
1200 #[serde(skip_serializing_if = "is_false")]
1202 use_coin_party_owner: bool,
1203
1204 #[serde(skip_serializing_if = "is_false")]
1205 enable_gasless: bool,
1206
1207 #[serde(skip_serializing_if = "is_false")]
1208 gasless_verify_remaining_balance: bool,
1209
1210 #[serde(skip_serializing_if = "is_false")]
1211 disallow_jump_orphans: bool,
1212
1213 #[serde(skip_serializing_if = "is_false")]
1215 early_return_receive_object_mismatched_type: bool,
1216
1217 #[serde(skip_serializing_if = "is_false")]
1222 timestamp_based_epoch_close: bool,
1223
1224 #[serde(skip_serializing_if = "is_false")]
1227 limit_groth16_pvk_inputs: bool,
1228
1229 #[serde(skip_serializing_if = "is_false")]
1234 enforce_address_balance_change_invariant: bool,
1235
1236 #[serde(skip_serializing_if = "is_false")]
1238 share_transaction_deny_config_in_consensus: bool,
1239
1240 #[serde(skip_serializing_if = "is_false")]
1242 granular_post_execution_checks: bool,
1243
1244 #[serde(skip_serializing_if = "is_false")]
1246 early_exit_on_iffw: bool,
1247
1248 #[serde(skip_serializing_if = "is_false")]
1250 enable_unified_linkage: bool,
1251}
1252
1253fn is_false(b: &bool) -> bool {
1254 !b
1255}
1256
1257fn is_empty(b: &BTreeSet<String>) -> bool {
1258 b.is_empty()
1259}
1260
1261fn is_zero(val: &u64) -> bool {
1262 *val == 0
1263}
1264
1265#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1267pub enum ConsensusTransactionOrdering {
1268 #[default]
1270 None,
1271 ByGasPrice,
1273}
1274
1275impl ConsensusTransactionOrdering {
1276 pub fn is_none(&self) -> bool {
1277 matches!(self, ConsensusTransactionOrdering::None)
1278 }
1279}
1280
1281#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1282pub struct ExecutionTimeEstimateParams {
1283 pub target_utilization: u64,
1285 pub allowed_txn_cost_overage_burst_limit_us: u64,
1289
1290 pub randomness_scalar: u64,
1293
1294 pub max_estimate_us: u64,
1296
1297 pub stored_observations_num_included_checkpoints: u64,
1300
1301 pub stored_observations_limit: u64,
1303
1304 #[serde(skip_serializing_if = "is_zero")]
1307 pub stake_weighted_median_threshold: u64,
1308
1309 #[serde(skip_serializing_if = "is_false")]
1313 pub default_none_duration_for_new_keys: bool,
1314
1315 #[serde(skip_serializing_if = "Option::is_none")]
1317 pub observations_chunk_size: Option<u64>,
1318}
1319
1320#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1322pub enum PerObjectCongestionControlMode {
1323 #[default]
1324 None, TotalGasBudget, TotalTxCount, TotalGasBudgetWithCap, ExecutionTimeEstimate(ExecutionTimeEstimateParams), }
1330
1331impl PerObjectCongestionControlMode {
1332 pub fn is_none(&self) -> bool {
1333 matches!(self, PerObjectCongestionControlMode::None)
1334 }
1335}
1336
1337#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1339pub enum ConsensusChoice {
1340 #[default]
1341 Narwhal,
1342 SwapEachEpoch,
1343 Mysticeti,
1344}
1345
1346impl ConsensusChoice {
1347 pub fn is_narwhal(&self) -> bool {
1348 matches!(self, ConsensusChoice::Narwhal)
1349 }
1350}
1351
1352#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1354pub enum ConsensusNetwork {
1355 #[default]
1356 Anemo,
1357 Tonic,
1358}
1359
1360impl ConsensusNetwork {
1361 pub fn is_anemo(&self) -> bool {
1362 matches!(self, ConsensusNetwork::Anemo)
1363 }
1364}
1365
1366#[skip_serializing_none]
1398#[derive(Clone, Serialize, Debug, ProtocolConfigAccessors, ProtocolConfigOverride)]
1399pub struct ProtocolConfig {
1400 pub version: ProtocolVersion,
1401
1402 #[serde(skip)]
1407 chain: Chain,
1408
1409 feature_flags: FeatureFlags,
1410
1411 max_tx_size_bytes: Option<u64>,
1414
1415 max_input_objects: Option<u64>,
1417
1418 max_size_written_objects: Option<u64>,
1422 max_size_written_objects_system_tx: Option<u64>,
1425
1426 max_serialized_tx_effects_size_bytes: Option<u64>,
1428
1429 max_serialized_tx_effects_size_bytes_system_tx: Option<u64>,
1431
1432 max_gas_payment_objects: Option<u32>,
1434
1435 max_modules_in_publish: Option<u32>,
1437
1438 max_package_dependencies: Option<u32>,
1440
1441 max_arguments: Option<u32>,
1444
1445 max_type_arguments: Option<u32>,
1447
1448 max_type_argument_depth: Option<u32>,
1450
1451 max_pure_argument_size: Option<u32>,
1453
1454 max_programmable_tx_commands: Option<u32>,
1456
1457 move_binary_format_version: Option<u32>,
1460 min_move_binary_format_version: Option<u32>,
1461
1462 binary_module_handles: Option<u16>,
1464 binary_struct_handles: Option<u16>,
1465 binary_function_handles: Option<u16>,
1466 binary_function_instantiations: Option<u16>,
1467 binary_signatures: Option<u16>,
1468 binary_constant_pool: Option<u16>,
1469 binary_identifiers: Option<u16>,
1470 binary_address_identifiers: Option<u16>,
1471 binary_struct_defs: Option<u16>,
1472 binary_struct_def_instantiations: Option<u16>,
1473 binary_function_defs: Option<u16>,
1474 binary_field_handles: Option<u16>,
1475 binary_field_instantiations: Option<u16>,
1476 binary_friend_decls: Option<u16>,
1477 binary_enum_defs: Option<u16>,
1478 binary_enum_def_instantiations: Option<u16>,
1479 binary_variant_handles: Option<u16>,
1480 binary_variant_instantiation_handles: Option<u16>,
1481
1482 max_move_object_size: Option<u64>,
1484
1485 max_move_package_size: Option<u64>,
1488
1489 max_publish_or_upgrade_per_ptb: Option<u64>,
1491
1492 max_tx_gas: Option<u64>,
1494
1495 max_gas_price: Option<u64>,
1497
1498 max_gas_price_rgp_factor_for_aborted_transactions: Option<u64>,
1501
1502 max_gas_computation_bucket: Option<u64>,
1504
1505 gas_rounding_step: Option<u64>,
1507
1508 max_loop_depth: Option<u64>,
1510
1511 max_generic_instantiation_length: Option<u64>,
1513
1514 max_function_parameters: Option<u64>,
1516
1517 max_basic_blocks: Option<u64>,
1519
1520 max_value_stack_size: Option<u64>,
1522
1523 max_type_nodes: Option<u64>,
1525
1526 max_generic_instantiation_type_nodes_per_function: Option<u64>,
1528
1529 max_generic_instantiation_type_nodes_per_module: Option<u64>,
1531
1532 max_accumulator_type_nodes: Option<u64>,
1534
1535 max_push_size: Option<u64>,
1537
1538 max_struct_definitions: Option<u64>,
1540
1541 max_function_definitions: Option<u64>,
1543
1544 max_fields_in_struct: Option<u64>,
1546
1547 max_dependency_depth: Option<u64>,
1549
1550 max_num_event_emit: Option<u64>,
1552
1553 max_num_new_move_object_ids: Option<u64>,
1555
1556 max_num_new_move_object_ids_system_tx: Option<u64>,
1558
1559 max_num_deleted_move_object_ids: Option<u64>,
1561
1562 max_num_deleted_move_object_ids_system_tx: Option<u64>,
1564
1565 max_num_transferred_move_object_ids: Option<u64>,
1567
1568 max_num_transferred_move_object_ids_system_tx: Option<u64>,
1570
1571 max_event_emit_size: Option<u64>,
1573
1574 max_event_emit_size_total: Option<u64>,
1576
1577 max_move_vector_len: Option<u64>,
1579
1580 max_move_identifier_len: Option<u64>,
1582
1583 max_move_value_depth: Option<u64>,
1585
1586 package_arena_size_in_bytes: Option<u64>,
1589
1590 max_move_enum_variants: Option<u64>,
1592
1593 max_back_edges_per_function: Option<u64>,
1595
1596 max_back_edges_per_module: Option<u64>,
1598
1599 max_verifier_meter_ticks_per_function: Option<u64>,
1601
1602 max_meter_ticks_per_module: Option<u64>,
1604
1605 max_meter_ticks_per_package: Option<u64>,
1607
1608 object_runtime_max_num_cached_objects: Option<u64>,
1612
1613 object_runtime_max_num_cached_objects_system_tx: Option<u64>,
1615
1616 object_runtime_max_num_store_entries: Option<u64>,
1618
1619 object_runtime_max_num_store_entries_system_tx: Option<u64>,
1621
1622 base_tx_cost_fixed: Option<u64>,
1625
1626 package_publish_cost_fixed: Option<u64>,
1629
1630 base_tx_cost_per_byte: Option<u64>,
1633
1634 package_publish_cost_per_byte: Option<u64>,
1636
1637 obj_access_cost_read_per_byte: Option<u64>,
1639
1640 obj_access_cost_mutate_per_byte: Option<u64>,
1642
1643 obj_access_cost_delete_per_byte: Option<u64>,
1645
1646 obj_access_cost_verify_per_byte: Option<u64>,
1656
1657 max_type_to_layout_nodes: Option<u64>,
1659
1660 max_ptb_value_size: Option<u64>,
1662
1663 gas_model_version: Option<u64>,
1666
1667 obj_data_cost_refundable: Option<u64>,
1670
1671 obj_metadata_cost_non_refundable: Option<u64>,
1675
1676 storage_rebate_rate: Option<u64>,
1682
1683 storage_fund_reinvest_rate: Option<u64>,
1686
1687 reward_slashing_rate: Option<u64>,
1690
1691 storage_gas_price: Option<u64>,
1693
1694 accumulator_object_storage_cost: Option<u64>,
1696
1697 max_transactions_per_checkpoint: Option<u64>,
1702
1703 max_checkpoint_size_bytes: Option<u64>,
1707
1708 buffer_stake_for_protocol_upgrade_bps: Option<u64>,
1713
1714 address_from_bytes_cost_base: Option<u64>,
1719 address_to_u256_cost_base: Option<u64>,
1721 address_from_u256_cost_base: Option<u64>,
1723
1724 config_read_setting_impl_cost_base: Option<u64>,
1729 config_read_setting_impl_cost_per_byte: Option<u64>,
1730
1731 package_original_package_id_impl_cost_base: Option<u64>,
1732 package_original_package_id_impl_cost_per_byte: Option<u64>,
1733
1734 dynamic_field_hash_type_and_key_cost_base: Option<u64>,
1737 dynamic_field_hash_type_and_key_type_cost_per_byte: Option<u64>,
1738 dynamic_field_hash_type_and_key_value_cost_per_byte: Option<u64>,
1739 dynamic_field_hash_type_and_key_type_tag_cost_per_byte: Option<u64>,
1740 dynamic_field_add_child_object_cost_base: Option<u64>,
1742 dynamic_field_add_child_object_type_cost_per_byte: Option<u64>,
1743 dynamic_field_add_child_object_value_cost_per_byte: Option<u64>,
1744 dynamic_field_add_child_object_struct_tag_cost_per_byte: Option<u64>,
1745 dynamic_field_borrow_child_object_cost_base: Option<u64>,
1747 dynamic_field_borrow_child_object_child_ref_cost_per_byte: Option<u64>,
1748 dynamic_field_borrow_child_object_type_cost_per_byte: Option<u64>,
1749 dynamic_field_remove_child_object_cost_base: Option<u64>,
1751 dynamic_field_remove_child_object_child_cost_per_byte: Option<u64>,
1752 dynamic_field_remove_child_object_type_cost_per_byte: Option<u64>,
1753 dynamic_field_has_child_object_cost_base: Option<u64>,
1755 dynamic_field_has_child_object_with_ty_cost_base: Option<u64>,
1757 dynamic_field_has_child_object_with_ty_type_cost_per_byte: Option<u64>,
1758 dynamic_field_has_child_object_with_ty_type_tag_cost_per_byte: Option<u64>,
1759
1760 scratch_add_cost_base: Option<u64>,
1763 scratch_read_cost_base: Option<u64>,
1765 scratch_read_value_cost: Option<u64>,
1766 scratch_remove_cost_base: Option<u64>,
1768 scratch_exists_cost_base: Option<u64>,
1770 scratch_exists_with_type_cost_base: Option<u64>,
1772 scratch_exists_with_type_type_cost: Option<u64>,
1773 max_scratch_pad_size: Option<u64>,
1775
1776 event_emit_cost_base: Option<u64>,
1779 event_emit_value_size_derivation_cost_per_byte: Option<u64>,
1780 event_emit_tag_size_derivation_cost_per_byte: Option<u64>,
1781 event_emit_output_cost_per_byte: Option<u64>,
1782 event_emit_auth_stream_cost: Option<u64>,
1783
1784 object_borrow_uid_cost_base: Option<u64>,
1787 object_delete_impl_cost_base: Option<u64>,
1789 object_record_new_uid_cost_base: Option<u64>,
1791 object_record_new_uid_from_hash_cost_base: Option<u64>,
1794
1795 transfer_transfer_internal_cost_base: Option<u64>,
1798 transfer_party_transfer_internal_cost_base: Option<u64>,
1800 transfer_freeze_object_cost_base: Option<u64>,
1802 transfer_share_object_cost_base: Option<u64>,
1804 transfer_receive_object_cost_base: Option<u64>,
1807 transfer_receive_object_cost_per_byte: Option<u64>,
1808 transfer_receive_object_type_cost_per_byte: Option<u64>,
1809
1810 tx_context_derive_id_cost_base: Option<u64>,
1813 tx_context_fresh_id_cost_base: Option<u64>,
1814 tx_context_sender_cost_base: Option<u64>,
1815 tx_context_epoch_cost_base: Option<u64>,
1816 tx_context_epoch_timestamp_ms_cost_base: Option<u64>,
1817 tx_context_sponsor_cost_base: Option<u64>,
1818 tx_context_rgp_cost_base: Option<u64>,
1819 tx_context_gas_price_cost_base: Option<u64>,
1820 tx_context_gas_budget_cost_base: Option<u64>,
1821 tx_context_ids_created_cost_base: Option<u64>,
1822 tx_context_replace_cost_base: Option<u64>,
1823
1824 types_is_one_time_witness_cost_base: Option<u64>,
1827 types_is_one_time_witness_type_tag_cost_per_byte: Option<u64>,
1828 types_is_one_time_witness_type_cost_per_byte: Option<u64>,
1829
1830 validator_validate_metadata_cost_base: Option<u64>,
1833 validator_validate_metadata_data_cost_per_byte: Option<u64>,
1834
1835 crypto_invalid_arguments_cost: Option<u64>,
1837 bls12381_bls12381_min_sig_verify_cost_base: Option<u64>,
1839 bls12381_bls12381_min_sig_verify_msg_cost_per_byte: Option<u64>,
1840 bls12381_bls12381_min_sig_verify_msg_cost_per_block: Option<u64>,
1841
1842 bls12381_bls12381_min_pk_verify_cost_base: Option<u64>,
1844 bls12381_bls12381_min_pk_verify_msg_cost_per_byte: Option<u64>,
1845 bls12381_bls12381_min_pk_verify_msg_cost_per_block: Option<u64>,
1846
1847 ecdsa_k1_ecrecover_keccak256_cost_base: Option<u64>,
1849 ecdsa_k1_ecrecover_keccak256_msg_cost_per_byte: Option<u64>,
1850 ecdsa_k1_ecrecover_keccak256_msg_cost_per_block: Option<u64>,
1851 ecdsa_k1_ecrecover_sha256_cost_base: Option<u64>,
1852 ecdsa_k1_ecrecover_sha256_msg_cost_per_byte: Option<u64>,
1853 ecdsa_k1_ecrecover_sha256_msg_cost_per_block: Option<u64>,
1854
1855 ecdsa_k1_decompress_pubkey_cost_base: Option<u64>,
1857
1858 ecdsa_k1_secp256k1_verify_keccak256_cost_base: Option<u64>,
1860 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_byte: Option<u64>,
1861 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_block: Option<u64>,
1862 ecdsa_k1_secp256k1_verify_sha256_cost_base: Option<u64>,
1863 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_byte: Option<u64>,
1864 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_block: Option<u64>,
1865
1866 ecdsa_r1_ecrecover_keccak256_cost_base: Option<u64>,
1868 ecdsa_r1_ecrecover_keccak256_msg_cost_per_byte: Option<u64>,
1869 ecdsa_r1_ecrecover_keccak256_msg_cost_per_block: Option<u64>,
1870 ecdsa_r1_ecrecover_sha256_cost_base: Option<u64>,
1871 ecdsa_r1_ecrecover_sha256_msg_cost_per_byte: Option<u64>,
1872 ecdsa_r1_ecrecover_sha256_msg_cost_per_block: Option<u64>,
1873
1874 ecdsa_r1_secp256r1_verify_keccak256_cost_base: Option<u64>,
1876 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_byte: Option<u64>,
1877 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_block: Option<u64>,
1878 ecdsa_r1_secp256r1_verify_sha256_cost_base: Option<u64>,
1879 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_byte: Option<u64>,
1880 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_block: Option<u64>,
1881
1882 ecvrf_ecvrf_verify_cost_base: Option<u64>,
1884 ecvrf_ecvrf_verify_alpha_string_cost_per_byte: Option<u64>,
1885 ecvrf_ecvrf_verify_alpha_string_cost_per_block: Option<u64>,
1886
1887 ed25519_ed25519_verify_cost_base: Option<u64>,
1889 ed25519_ed25519_verify_msg_cost_per_byte: Option<u64>,
1890 ed25519_ed25519_verify_msg_cost_per_block: Option<u64>,
1891
1892 groth16_prepare_verifying_key_bls12381_cost_base: Option<u64>,
1894 groth16_prepare_verifying_key_bn254_cost_base: Option<u64>,
1895
1896 groth16_verify_groth16_proof_internal_bls12381_cost_base: Option<u64>,
1898 groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input: Option<u64>,
1899 groth16_verify_groth16_proof_internal_bn254_cost_base: Option<u64>,
1900 groth16_verify_groth16_proof_internal_bn254_cost_per_public_input: Option<u64>,
1901 groth16_verify_groth16_proof_internal_public_input_cost_per_byte: Option<u64>,
1902
1903 hash_blake2b256_cost_base: Option<u64>,
1905 hash_blake2b256_data_cost_per_byte: Option<u64>,
1906 hash_blake2b256_data_cost_per_block: Option<u64>,
1907
1908 hash_keccak256_cost_base: Option<u64>,
1910 hash_keccak256_data_cost_per_byte: Option<u64>,
1911 hash_keccak256_data_cost_per_block: Option<u64>,
1912
1913 poseidon_bn254_cost_base: Option<u64>,
1915 poseidon_bn254_cost_per_block: Option<u64>,
1916
1917 group_ops_bls12381_decode_scalar_cost: Option<u64>,
1919 group_ops_bls12381_decode_g1_cost: Option<u64>,
1920 group_ops_bls12381_decode_g2_cost: Option<u64>,
1921 group_ops_bls12381_decode_gt_cost: Option<u64>,
1922 group_ops_bls12381_scalar_add_cost: Option<u64>,
1923 group_ops_bls12381_g1_add_cost: Option<u64>,
1924 group_ops_bls12381_g2_add_cost: Option<u64>,
1925 group_ops_bls12381_gt_add_cost: Option<u64>,
1926 group_ops_bls12381_scalar_sub_cost: Option<u64>,
1927 group_ops_bls12381_g1_sub_cost: Option<u64>,
1928 group_ops_bls12381_g2_sub_cost: Option<u64>,
1929 group_ops_bls12381_gt_sub_cost: Option<u64>,
1930 group_ops_bls12381_scalar_mul_cost: Option<u64>,
1931 group_ops_bls12381_g1_mul_cost: Option<u64>,
1932 group_ops_bls12381_g2_mul_cost: Option<u64>,
1933 group_ops_bls12381_gt_mul_cost: Option<u64>,
1934 group_ops_bls12381_scalar_div_cost: Option<u64>,
1935 group_ops_bls12381_g1_div_cost: Option<u64>,
1936 group_ops_bls12381_g2_div_cost: Option<u64>,
1937 group_ops_bls12381_gt_div_cost: Option<u64>,
1938 group_ops_bls12381_g1_hash_to_base_cost: Option<u64>,
1939 group_ops_bls12381_g2_hash_to_base_cost: Option<u64>,
1940 group_ops_bls12381_g1_hash_to_cost_per_byte: Option<u64>,
1941 group_ops_bls12381_g2_hash_to_cost_per_byte: Option<u64>,
1942 group_ops_bls12381_g1_msm_base_cost: Option<u64>,
1943 group_ops_bls12381_g2_msm_base_cost: Option<u64>,
1944 group_ops_bls12381_g1_msm_base_cost_per_input: Option<u64>,
1945 group_ops_bls12381_g2_msm_base_cost_per_input: Option<u64>,
1946 group_ops_bls12381_msm_max_len: Option<u32>,
1947 group_ops_bls12381_pairing_cost: Option<u64>,
1948 group_ops_bls12381_g1_to_uncompressed_g1_cost: Option<u64>,
1949 group_ops_bls12381_uncompressed_g1_to_g1_cost: Option<u64>,
1950 group_ops_bls12381_uncompressed_g1_sum_base_cost: Option<u64>,
1951 group_ops_bls12381_uncompressed_g1_sum_cost_per_term: Option<u64>,
1952 group_ops_bls12381_uncompressed_g1_sum_max_terms: Option<u64>,
1953
1954 group_ops_ristretto_decode_scalar_cost: Option<u64>,
1955 group_ops_ristretto_decode_point_cost: Option<u64>,
1956 group_ops_ristretto_scalar_add_cost: Option<u64>,
1957 group_ops_ristretto_point_add_cost: Option<u64>,
1958 group_ops_ristretto_scalar_sub_cost: Option<u64>,
1959 group_ops_ristretto_point_sub_cost: Option<u64>,
1960 group_ops_ristretto_scalar_mul_cost: Option<u64>,
1961 group_ops_ristretto_point_mul_cost: Option<u64>,
1962 group_ops_ristretto_scalar_div_cost: Option<u64>,
1963 group_ops_ristretto_point_div_cost: Option<u64>,
1964
1965 verify_bulletproofs_ristretto255_base_cost: Option<u64>,
1966 verify_bulletproofs_ristretto255_cost_per_bit_and_commitment: Option<u64>,
1967 max_bulletproofs_total_bits: Option<u64>,
1970
1971 hmac_hmac_sha3_256_cost_base: Option<u64>,
1973 hmac_hmac_sha3_256_input_cost_per_byte: Option<u64>,
1974 hmac_hmac_sha3_256_input_cost_per_block: Option<u64>,
1975
1976 check_zklogin_id_cost_base: Option<u64>,
1978 check_zklogin_issuer_cost_base: Option<u64>,
1980
1981 vdf_verify_vdf_cost: Option<u64>,
1982 vdf_hash_to_input_cost: Option<u64>,
1983
1984 nitro_attestation_parse_base_cost: Option<u64>,
1986 nitro_attestation_parse_cost_per_byte: Option<u64>,
1987 nitro_attestation_verify_base_cost: Option<u64>,
1988 nitro_attestation_verify_cost_per_cert: Option<u64>,
1989
1990 bcs_per_byte_serialized_cost: Option<u64>,
1992 bcs_legacy_min_output_size_cost: Option<u64>,
1993 bcs_failure_cost: Option<u64>,
1994
1995 hash_sha2_256_base_cost: Option<u64>,
1996 hash_sha2_256_per_byte_cost: Option<u64>,
1997 hash_sha2_256_legacy_min_input_len_cost: Option<u64>,
1998 hash_sha3_256_base_cost: Option<u64>,
1999 hash_sha3_256_per_byte_cost: Option<u64>,
2000 hash_sha3_256_legacy_min_input_len_cost: Option<u64>,
2001 type_name_get_base_cost: Option<u64>,
2002 type_name_get_per_byte_cost: Option<u64>,
2003 type_name_id_base_cost: Option<u64>,
2004
2005 string_check_utf8_base_cost: Option<u64>,
2006 string_check_utf8_per_byte_cost: Option<u64>,
2007 string_is_char_boundary_base_cost: Option<u64>,
2008 string_sub_string_base_cost: Option<u64>,
2009 string_sub_string_per_byte_cost: Option<u64>,
2010 string_index_of_base_cost: Option<u64>,
2011 string_index_of_per_byte_pattern_cost: Option<u64>,
2012 string_index_of_per_byte_searched_cost: Option<u64>,
2013
2014 vector_empty_base_cost: Option<u64>,
2015 vector_length_base_cost: Option<u64>,
2016 vector_push_back_base_cost: Option<u64>,
2017 vector_push_back_legacy_per_abstract_memory_unit_cost: Option<u64>,
2018 vector_borrow_base_cost: Option<u64>,
2019 vector_pop_back_base_cost: Option<u64>,
2020 vector_destroy_empty_base_cost: Option<u64>,
2021 vector_swap_base_cost: Option<u64>,
2022 debug_print_base_cost: Option<u64>,
2023 debug_print_stack_trace_base_cost: Option<u64>,
2024
2025 #[custom_setter]
2035 execution_version: Option<u64>,
2036
2037 consensus_bad_nodes_stake_threshold: Option<u64>,
2041
2042 max_jwk_votes_per_validator_per_epoch: Option<u64>,
2043 max_age_of_jwk_in_epochs: Option<u64>,
2047
2048 random_beacon_reduction_allowed_delta: Option<u16>,
2052
2053 random_beacon_reduction_lower_bound: Option<u32>,
2056
2057 random_beacon_dkg_timeout_round: Option<u32>,
2060
2061 random_beacon_min_round_interval_ms: Option<u64>,
2063
2064 random_beacon_dkg_version: Option<u64>,
2067
2068 consensus_max_transaction_size_bytes: Option<u64>,
2071 consensus_max_transactions_in_block_bytes: Option<u64>,
2073 consensus_max_num_transactions_in_block: Option<u64>,
2075
2076 consensus_voting_rounds: Option<u32>,
2078
2079 max_accumulated_txn_cost_per_object_in_narwhal_commit: Option<u64>,
2081
2082 max_deferral_rounds_for_congestion_control: Option<u64>,
2085
2086 epoch_close_deadline_ms: Option<u64>,
2091
2092 max_txn_cost_overage_per_object_in_commit: Option<u64>,
2094
2095 allowed_txn_cost_overage_burst_per_object_in_commit: Option<u64>,
2097
2098 min_checkpoint_interval_ms: Option<u64>,
2100
2101 checkpoint_summary_version_specific_data: Option<u64>,
2103
2104 max_soft_bundle_size: Option<u64>,
2106
2107 bridge_should_try_to_finalize_committee: Option<bool>,
2111
2112 max_accumulated_txn_cost_per_object_in_mysticeti_commit: Option<u64>,
2118
2119 max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit: Option<u64>,
2122
2123 consensus_gc_depth: Option<u32>,
2126
2127 gas_budget_based_txn_cost_cap_factor: Option<u64>,
2129
2130 gas_budget_based_txn_cost_absolute_cap_commit_count: Option<u64>,
2132
2133 sip_45_consensus_amplification_threshold: Option<u64>,
2136
2137 use_object_per_epoch_marker_table_v2: Option<bool>,
2140
2141 consensus_commit_rate_estimation_window_size: Option<u32>,
2143
2144 #[serde(skip_serializing_if = "Vec::is_empty")]
2148 aliased_addresses: Vec<AliasedAddress>,
2149
2150 translation_per_command_base_charge: Option<u64>,
2153
2154 translation_per_input_base_charge: Option<u64>,
2157
2158 translation_pure_input_per_byte_charge: Option<u64>,
2160
2161 translation_per_type_node_charge: Option<u64>,
2165
2166 translation_per_reference_node_charge: Option<u64>,
2169
2170 translation_per_linkage_entry_charge: Option<u64>,
2173
2174 max_updates_per_settlement_txn: Option<u32>,
2176
2177 gasless_max_computation_units: Option<u64>,
2179
2180 gasless_allowed_token_types: Option<Vec<(String, u64)>>,
2182
2183 gasless_max_unused_inputs: Option<u64>,
2187
2188 gasless_max_pure_input_bytes: Option<u64>,
2191
2192 gasless_max_tps: Option<u64>,
2194
2195 #[serde(skip_serializing_if = "Option::is_none")]
2196 #[skip_accessor]
2197 include_special_package_amendments: Option<Arc<Amendments>>,
2198
2199 gasless_max_tx_size_bytes: Option<u64>,
2202
2203 translation_per_live_reference_charge: Option<u64>,
2206
2207 max_ptb_live_references: Option<u64>,
2210
2211 max_ptb_returned_references: Option<u64>,
2214
2215 max_ptb_total_returned_references: Option<u64>,
2218}
2219
2220#[derive(Clone, Serialize, Deserialize, Debug)]
2222pub struct AliasedAddress {
2223 pub original: [u8; 32],
2225 pub aliased: [u8; 32],
2227 pub allowed_tx_digests: Vec<[u8; 32]>,
2229}
2230
2231impl ProtocolConfig {
2233 pub fn chain(&self) -> Chain {
2235 self.chain
2236 }
2237
2238 pub fn check_package_upgrades_supported(&self) -> Result<(), Error> {
2251 if self.feature_flags.package_upgrades {
2252 Ok(())
2253 } else {
2254 Err(Error(format!(
2255 "package upgrades are not supported at {:?}",
2256 self.version
2257 )))
2258 }
2259 }
2260
2261 pub fn zklogin_supported_providers(&self) -> &BTreeSet<String> {
2262 &self.feature_flags.zklogin_supported_providers
2263 }
2264
2265 pub fn zklogin_circuit_mode(&self) -> u64 {
2268 self.feature_flags.zklogin_circuit_mode
2269 }
2270
2271 pub fn consensus_transaction_ordering(&self) -> ConsensusTransactionOrdering {
2272 self.feature_flags.consensus_transaction_ordering
2273 }
2274
2275 pub fn enable_jwk_consensus_updates(&self) -> bool {
2276 let ret = self.feature_flags.enable_jwk_consensus_updates;
2277 if ret {
2278 assert!(self.feature_flags.end_of_epoch_transaction_supported);
2280 }
2281 ret
2282 }
2283
2284 pub fn end_of_epoch_transaction_supported(&self) -> bool {
2285 let ret = self.feature_flags.end_of_epoch_transaction_supported;
2286 if !ret {
2287 assert!(!self.feature_flags.enable_jwk_consensus_updates);
2289 }
2290 ret
2291 }
2292
2293 pub fn dkg_version(&self) -> u64 {
2294 self.random_beacon_dkg_version.unwrap_or(1)
2296 }
2297
2298 pub fn bridge(&self) -> bool {
2299 let ret = self.feature_flags.bridge;
2300 if ret {
2301 assert!(self.feature_flags.end_of_epoch_transaction_supported);
2303 }
2304 ret
2305 }
2306
2307 pub fn should_try_to_finalize_bridge_committee(&self) -> bool {
2308 if !self.bridge() {
2309 return false;
2310 }
2311 self.bridge_should_try_to_finalize_committee.unwrap_or(true)
2313 }
2314
2315 pub fn zklogin_max_epoch_upper_bound_delta(&self) -> Option<u64> {
2316 self.feature_flags.zklogin_max_epoch_upper_bound_delta
2317 }
2318
2319 pub fn enable_coin_reservation_obj_refs(&self) -> bool {
2320 self.new_vm_enabled() && self.feature_flags.enable_coin_reservation_obj_refs
2321 }
2322
2323 pub fn enable_authenticated_event_streams(&self) -> bool {
2324 self.feature_flags.enable_authenticated_event_streams && self.enable_accumulators()
2325 }
2326
2327 pub fn per_object_congestion_control_mode(&self) -> PerObjectCongestionControlMode {
2328 self.feature_flags.per_object_congestion_control_mode
2329 }
2330
2331 pub fn consensus_choice(&self) -> ConsensusChoice {
2332 self.feature_flags.consensus_choice
2333 }
2334
2335 pub fn consensus_network(&self) -> ConsensusNetwork {
2336 self.feature_flags.consensus_network
2337 }
2338
2339 pub fn mysticeti_num_leaders_per_round(&self) -> Option<usize> {
2340 self.feature_flags.mysticeti_num_leaders_per_round
2341 }
2342
2343 pub fn max_transaction_size_bytes(&self) -> u64 {
2344 self.consensus_max_transaction_size_bytes
2346 .unwrap_or(256 * 1024)
2347 }
2348
2349 pub fn max_transactions_in_block_bytes(&self) -> u64 {
2350 if cfg!(msim) {
2351 256 * 1024
2352 } else {
2353 self.consensus_max_transactions_in_block_bytes
2354 .unwrap_or(512 * 1024)
2355 }
2356 }
2357
2358 pub fn max_num_transactions_in_block(&self) -> u64 {
2359 if cfg!(msim) {
2360 8
2361 } else {
2362 self.consensus_max_num_transactions_in_block.unwrap_or(512)
2363 }
2364 }
2365
2366 pub fn gc_depth(&self) -> u32 {
2367 self.consensus_gc_depth.unwrap_or(0)
2368 }
2369
2370 pub fn consensus_linearize_subdag_v2(&self) -> bool {
2371 let res = self.feature_flags.consensus_linearize_subdag_v2;
2372 assert!(
2373 !res || self.gc_depth() > 0,
2374 "The consensus linearize sub dag V2 requires GC to be enabled"
2375 );
2376 res
2377 }
2378
2379 pub fn consensus_median_based_commit_timestamp(&self) -> bool {
2380 let res = self.feature_flags.consensus_median_based_commit_timestamp;
2381 assert!(
2382 !res || self.gc_depth() > 0,
2383 "The consensus median based commit timestamp requires GC to be enabled"
2384 );
2385 res
2386 }
2387
2388 pub fn get_consensus_commit_rate_estimation_window_size(&self) -> u32 {
2389 self.consensus_commit_rate_estimation_window_size
2390 .unwrap_or(0)
2391 }
2392
2393 pub fn consensus_num_requested_prior_commits_at_startup(&self) -> u32 {
2394 let window_size = self.get_consensus_commit_rate_estimation_window_size();
2398 assert!(window_size == 0 || self.record_additional_state_digest_in_prologue());
2400 window_size
2401 }
2402
2403 pub fn address_aliases(&self) -> bool {
2404 let address_aliases = self.feature_flags.address_aliases;
2405 assert!(
2406 !address_aliases || self.mysticeti_fastpath(),
2407 "Address aliases requires Mysticeti fastpath to be enabled"
2408 );
2409 if address_aliases {
2410 assert!(
2411 self.feature_flags.disable_preconsensus_locking,
2412 "Address aliases requires CertifiedTransaction to be disabled"
2413 );
2414 }
2415 address_aliases
2416 }
2417
2418 pub fn new_vm_enabled(&self) -> bool {
2419 self.execution_version.is_some_and(|v| v >= 4)
2420 }
2421
2422 pub fn gasless_allowed_token_types(&self) -> &[(String, u64)] {
2423 debug_assert!(self.gasless_allowed_token_types.is_some());
2424 self.gasless_allowed_token_types.as_deref().unwrap_or(&[])
2425 }
2426
2427 pub fn get_gasless_max_unused_inputs(&self) -> u64 {
2428 self.gasless_max_unused_inputs.unwrap_or(u64::MAX)
2429 }
2430
2431 pub fn get_gasless_max_pure_input_bytes(&self) -> u64 {
2432 self.gasless_max_pure_input_bytes.unwrap_or(u64::MAX)
2433 }
2434
2435 pub fn get_gasless_max_tx_size_bytes(&self) -> u64 {
2436 self.gasless_max_tx_size_bytes.unwrap_or(u64::MAX)
2437 }
2438
2439 pub fn include_special_package_amendments_as_option(&self) -> &Option<Arc<Amendments>> {
2440 &self.include_special_package_amendments
2441 }
2442}
2443
2444static POISON_VERSION_METHODS: AtomicBool = AtomicBool::new(false);
2445
2446impl ProtocolConfig {
2448 pub fn get_for_version(version: ProtocolVersion, chain: Chain) -> Self {
2450 assert!(
2452 version >= ProtocolVersion::MIN,
2453 "Network protocol version is {:?}, but the minimum supported version by the binary is {:?}. Please upgrade the binary.",
2454 version,
2455 ProtocolVersion::MIN.0,
2456 );
2457 assert!(
2458 version <= ProtocolVersion::MAX_ALLOWED,
2459 "Network protocol version is {:?}, but the maximum supported version by the binary is {:?}. Please upgrade the binary.",
2460 version,
2461 ProtocolVersion::MAX_ALLOWED.0,
2462 );
2463
2464 let mut ret = Self::get_for_version_impl(version, chain);
2465 ret.version = version;
2466 ret.chain = chain;
2467
2468 ret = Self::apply_config_override(version, ret);
2469
2470 if std::env::var("SUI_PROTOCOL_CONFIG_OVERRIDE_ENABLE").is_ok() {
2471 warn!(
2472 "overriding ProtocolConfig settings with custom settings; this may break non-local networks"
2473 );
2474 let overrides: ProtocolConfigOptional =
2475 serde_env::from_env_with_prefix("SUI_PROTOCOL_CONFIG_OVERRIDE")
2476 .expect("failed to parse ProtocolConfig override env variables");
2477 overrides.apply_to(&mut ret);
2478 }
2479
2480 ret
2481 }
2482
2483 pub fn get_for_version_if_supported(version: ProtocolVersion, chain: Chain) -> Option<Self> {
2486 if version.0 >= ProtocolVersion::MIN.0 && version.0 <= ProtocolVersion::MAX_ALLOWED.0 {
2487 let mut ret = Self::get_for_version_impl(version, chain);
2488 ret.version = version;
2489 ret.chain = chain;
2490 ret = Self::apply_config_override(version, ret);
2491 Some(ret)
2492 } else {
2493 None
2494 }
2495 }
2496
2497 pub fn poison_get_for_min_version() {
2498 POISON_VERSION_METHODS.store(true, Ordering::Relaxed);
2499 }
2500
2501 fn load_poison_get_for_min_version() -> bool {
2502 POISON_VERSION_METHODS.load(Ordering::Relaxed)
2503 }
2504
2505 pub fn get_for_min_version() -> Self {
2508 if Self::load_poison_get_for_min_version() {
2509 panic!("get_for_min_version called on validator");
2510 }
2511 ProtocolConfig::get_for_version(ProtocolVersion::MIN, Chain::Unknown)
2512 }
2513
2514 #[allow(non_snake_case)]
2524 pub fn get_for_max_version_UNSAFE() -> Self {
2525 if Self::load_poison_get_for_min_version() {
2526 panic!("get_for_max_version_UNSAFE called on validator");
2527 }
2528 ProtocolConfig::get_for_version(ProtocolVersion::MAX, Chain::Unknown)
2529 }
2530
2531 fn get_for_version_impl(version: ProtocolVersion, chain: Chain) -> Self {
2532 #[cfg(msim)]
2533 {
2534 if version == ProtocolVersion::MAX_ALLOWED {
2536 let mut config = Self::get_for_version_impl(version - 1, Chain::Unknown);
2537 config.base_tx_cost_fixed = Some(config.base_tx_cost_fixed() + 1000);
2538 return config;
2539 }
2540 }
2541
2542 let mut cfg = Self {
2545 version,
2547 chain,
2548
2549 feature_flags: Default::default(),
2551
2552 max_tx_size_bytes: Some(128 * 1024),
2553 max_input_objects: Some(2048),
2555 max_serialized_tx_effects_size_bytes: Some(512 * 1024),
2556 max_serialized_tx_effects_size_bytes_system_tx: Some(512 * 1024 * 16),
2557 max_gas_payment_objects: Some(256),
2558 max_modules_in_publish: Some(128),
2559 max_package_dependencies: None,
2560 max_arguments: Some(512),
2561 max_type_arguments: Some(16),
2562 max_type_argument_depth: Some(16),
2563 max_pure_argument_size: Some(16 * 1024),
2564 max_programmable_tx_commands: Some(1024),
2565 move_binary_format_version: Some(6),
2566 min_move_binary_format_version: None,
2567 binary_module_handles: None,
2568 binary_struct_handles: None,
2569 binary_function_handles: None,
2570 binary_function_instantiations: None,
2571 binary_signatures: None,
2572 binary_constant_pool: None,
2573 binary_identifiers: None,
2574 binary_address_identifiers: None,
2575 binary_struct_defs: None,
2576 binary_struct_def_instantiations: None,
2577 binary_function_defs: None,
2578 binary_field_handles: None,
2579 binary_field_instantiations: None,
2580 binary_friend_decls: None,
2581 binary_enum_defs: None,
2582 binary_enum_def_instantiations: None,
2583 binary_variant_handles: None,
2584 binary_variant_instantiation_handles: None,
2585 max_move_object_size: Some(250 * 1024),
2586 max_move_package_size: Some(100 * 1024),
2587 max_publish_or_upgrade_per_ptb: None,
2588 max_tx_gas: Some(10_000_000_000),
2589 max_gas_price: Some(100_000),
2590 max_gas_price_rgp_factor_for_aborted_transactions: None,
2591 max_gas_computation_bucket: Some(5_000_000),
2592 max_loop_depth: Some(5),
2593 max_generic_instantiation_length: Some(32),
2594 max_function_parameters: Some(128),
2595 max_basic_blocks: Some(1024),
2596 max_value_stack_size: Some(1024),
2597 max_type_nodes: Some(256),
2598 max_generic_instantiation_type_nodes_per_function: None,
2599 max_generic_instantiation_type_nodes_per_module: None,
2600 max_accumulator_type_nodes: None,
2601 max_push_size: Some(10000),
2602 max_struct_definitions: Some(200),
2603 max_function_definitions: Some(1000),
2604 max_fields_in_struct: Some(32),
2605 max_dependency_depth: Some(100),
2606 max_num_event_emit: Some(256),
2607 max_num_new_move_object_ids: Some(2048),
2608 max_num_new_move_object_ids_system_tx: Some(2048 * 16),
2609 max_num_deleted_move_object_ids: Some(2048),
2610 max_num_deleted_move_object_ids_system_tx: Some(2048 * 16),
2611 max_num_transferred_move_object_ids: Some(2048),
2612 max_num_transferred_move_object_ids_system_tx: Some(2048 * 16),
2613 max_event_emit_size: Some(250 * 1024),
2614 max_move_vector_len: Some(256 * 1024),
2615 max_type_to_layout_nodes: None,
2616 max_ptb_value_size: None,
2617
2618 max_back_edges_per_function: Some(10_000),
2619 max_back_edges_per_module: Some(10_000),
2620 max_verifier_meter_ticks_per_function: Some(6_000_000),
2621 max_meter_ticks_per_module: Some(6_000_000),
2622 max_meter_ticks_per_package: None,
2623
2624 object_runtime_max_num_cached_objects: Some(1000),
2625 object_runtime_max_num_cached_objects_system_tx: Some(1000 * 16),
2626 object_runtime_max_num_store_entries: Some(1000),
2627 object_runtime_max_num_store_entries_system_tx: Some(1000 * 16),
2628 base_tx_cost_fixed: Some(110_000),
2629 package_publish_cost_fixed: Some(1_000),
2630 base_tx_cost_per_byte: Some(0),
2631 package_publish_cost_per_byte: Some(80),
2632 obj_access_cost_read_per_byte: Some(15),
2633 obj_access_cost_mutate_per_byte: Some(40),
2634 obj_access_cost_delete_per_byte: Some(40),
2635 obj_access_cost_verify_per_byte: Some(200),
2636 obj_data_cost_refundable: Some(100),
2637 obj_metadata_cost_non_refundable: Some(50),
2638 gas_model_version: Some(1),
2639 storage_rebate_rate: Some(9900),
2640 storage_fund_reinvest_rate: Some(500),
2641 reward_slashing_rate: Some(5000),
2642 storage_gas_price: Some(1),
2643 accumulator_object_storage_cost: None,
2644 max_transactions_per_checkpoint: Some(10_000),
2645 max_checkpoint_size_bytes: Some(30 * 1024 * 1024),
2646
2647 buffer_stake_for_protocol_upgrade_bps: Some(0),
2650
2651 address_from_bytes_cost_base: Some(52),
2655 address_to_u256_cost_base: Some(52),
2657 address_from_u256_cost_base: Some(52),
2659
2660 config_read_setting_impl_cost_base: None,
2663 config_read_setting_impl_cost_per_byte: None,
2664
2665 package_original_package_id_impl_cost_base: None,
2666 package_original_package_id_impl_cost_per_byte: None,
2667
2668 dynamic_field_hash_type_and_key_cost_base: Some(100),
2671 dynamic_field_hash_type_and_key_type_cost_per_byte: Some(2),
2672 dynamic_field_hash_type_and_key_value_cost_per_byte: Some(2),
2673 dynamic_field_hash_type_and_key_type_tag_cost_per_byte: Some(2),
2674 dynamic_field_add_child_object_cost_base: Some(100),
2676 dynamic_field_add_child_object_type_cost_per_byte: Some(10),
2677 dynamic_field_add_child_object_value_cost_per_byte: Some(10),
2678 dynamic_field_add_child_object_struct_tag_cost_per_byte: Some(10),
2679 dynamic_field_borrow_child_object_cost_base: Some(100),
2681 dynamic_field_borrow_child_object_child_ref_cost_per_byte: Some(10),
2682 dynamic_field_borrow_child_object_type_cost_per_byte: Some(10),
2683 dynamic_field_remove_child_object_cost_base: Some(100),
2685 dynamic_field_remove_child_object_child_cost_per_byte: Some(2),
2686 dynamic_field_remove_child_object_type_cost_per_byte: Some(2),
2687 dynamic_field_has_child_object_cost_base: Some(100),
2689 dynamic_field_has_child_object_with_ty_cost_base: Some(100),
2691 dynamic_field_has_child_object_with_ty_type_cost_per_byte: Some(2),
2692 dynamic_field_has_child_object_with_ty_type_tag_cost_per_byte: Some(2),
2693
2694 scratch_add_cost_base: None,
2696 scratch_read_cost_base: None,
2697 scratch_read_value_cost: None,
2698 scratch_remove_cost_base: None,
2699 scratch_exists_cost_base: None,
2700 scratch_exists_with_type_cost_base: None,
2701 scratch_exists_with_type_type_cost: None,
2702 max_scratch_pad_size: None,
2703
2704 event_emit_cost_base: Some(52),
2707 event_emit_value_size_derivation_cost_per_byte: Some(2),
2708 event_emit_tag_size_derivation_cost_per_byte: Some(5),
2709 event_emit_output_cost_per_byte: Some(10),
2710 event_emit_auth_stream_cost: None,
2711
2712 object_borrow_uid_cost_base: Some(52),
2715 object_delete_impl_cost_base: Some(52),
2717 object_record_new_uid_cost_base: Some(52),
2719 object_record_new_uid_from_hash_cost_base: None,
2722
2723 transfer_transfer_internal_cost_base: Some(52),
2726 transfer_party_transfer_internal_cost_base: None,
2728 transfer_freeze_object_cost_base: Some(52),
2730 transfer_share_object_cost_base: Some(52),
2732 transfer_receive_object_cost_base: None,
2733 transfer_receive_object_type_cost_per_byte: None,
2734 transfer_receive_object_cost_per_byte: None,
2735
2736 tx_context_derive_id_cost_base: Some(52),
2739 tx_context_fresh_id_cost_base: None,
2740 tx_context_sender_cost_base: None,
2741 tx_context_epoch_cost_base: None,
2742 tx_context_epoch_timestamp_ms_cost_base: None,
2743 tx_context_sponsor_cost_base: None,
2744 tx_context_rgp_cost_base: None,
2745 tx_context_gas_price_cost_base: None,
2746 tx_context_gas_budget_cost_base: None,
2747 tx_context_ids_created_cost_base: None,
2748 tx_context_replace_cost_base: None,
2749
2750 types_is_one_time_witness_cost_base: Some(52),
2753 types_is_one_time_witness_type_tag_cost_per_byte: Some(2),
2754 types_is_one_time_witness_type_cost_per_byte: Some(2),
2755
2756 validator_validate_metadata_cost_base: Some(52),
2759 validator_validate_metadata_data_cost_per_byte: Some(2),
2760
2761 crypto_invalid_arguments_cost: Some(100),
2763 bls12381_bls12381_min_sig_verify_cost_base: Some(52),
2765 bls12381_bls12381_min_sig_verify_msg_cost_per_byte: Some(2),
2766 bls12381_bls12381_min_sig_verify_msg_cost_per_block: Some(2),
2767
2768 bls12381_bls12381_min_pk_verify_cost_base: Some(52),
2770 bls12381_bls12381_min_pk_verify_msg_cost_per_byte: Some(2),
2771 bls12381_bls12381_min_pk_verify_msg_cost_per_block: Some(2),
2772
2773 ecdsa_k1_ecrecover_keccak256_cost_base: Some(52),
2775 ecdsa_k1_ecrecover_keccak256_msg_cost_per_byte: Some(2),
2776 ecdsa_k1_ecrecover_keccak256_msg_cost_per_block: Some(2),
2777 ecdsa_k1_ecrecover_sha256_cost_base: Some(52),
2778 ecdsa_k1_ecrecover_sha256_msg_cost_per_byte: Some(2),
2779 ecdsa_k1_ecrecover_sha256_msg_cost_per_block: Some(2),
2780
2781 ecdsa_k1_decompress_pubkey_cost_base: Some(52),
2783
2784 ecdsa_k1_secp256k1_verify_keccak256_cost_base: Some(52),
2786 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_byte: Some(2),
2787 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_block: Some(2),
2788 ecdsa_k1_secp256k1_verify_sha256_cost_base: Some(52),
2789 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_byte: Some(2),
2790 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_block: Some(2),
2791
2792 ecdsa_r1_ecrecover_keccak256_cost_base: Some(52),
2794 ecdsa_r1_ecrecover_keccak256_msg_cost_per_byte: Some(2),
2795 ecdsa_r1_ecrecover_keccak256_msg_cost_per_block: Some(2),
2796 ecdsa_r1_ecrecover_sha256_cost_base: Some(52),
2797 ecdsa_r1_ecrecover_sha256_msg_cost_per_byte: Some(2),
2798 ecdsa_r1_ecrecover_sha256_msg_cost_per_block: Some(2),
2799
2800 ecdsa_r1_secp256r1_verify_keccak256_cost_base: Some(52),
2802 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_byte: Some(2),
2803 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_block: Some(2),
2804 ecdsa_r1_secp256r1_verify_sha256_cost_base: Some(52),
2805 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_byte: Some(2),
2806 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_block: Some(2),
2807
2808 ecvrf_ecvrf_verify_cost_base: Some(52),
2810 ecvrf_ecvrf_verify_alpha_string_cost_per_byte: Some(2),
2811 ecvrf_ecvrf_verify_alpha_string_cost_per_block: Some(2),
2812
2813 ed25519_ed25519_verify_cost_base: Some(52),
2815 ed25519_ed25519_verify_msg_cost_per_byte: Some(2),
2816 ed25519_ed25519_verify_msg_cost_per_block: Some(2),
2817
2818 groth16_prepare_verifying_key_bls12381_cost_base: Some(52),
2820 groth16_prepare_verifying_key_bn254_cost_base: Some(52),
2821
2822 groth16_verify_groth16_proof_internal_bls12381_cost_base: Some(52),
2824 groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input: Some(2),
2825 groth16_verify_groth16_proof_internal_bn254_cost_base: Some(52),
2826 groth16_verify_groth16_proof_internal_bn254_cost_per_public_input: Some(2),
2827 groth16_verify_groth16_proof_internal_public_input_cost_per_byte: Some(2),
2828
2829 hash_blake2b256_cost_base: Some(52),
2831 hash_blake2b256_data_cost_per_byte: Some(2),
2832 hash_blake2b256_data_cost_per_block: Some(2),
2833
2834 hash_keccak256_cost_base: Some(52),
2836 hash_keccak256_data_cost_per_byte: Some(2),
2837 hash_keccak256_data_cost_per_block: Some(2),
2838
2839 poseidon_bn254_cost_base: None,
2840 poseidon_bn254_cost_per_block: None,
2841
2842 hmac_hmac_sha3_256_cost_base: Some(52),
2844 hmac_hmac_sha3_256_input_cost_per_byte: Some(2),
2845 hmac_hmac_sha3_256_input_cost_per_block: Some(2),
2846
2847 group_ops_bls12381_decode_scalar_cost: None,
2849 group_ops_bls12381_decode_g1_cost: None,
2850 group_ops_bls12381_decode_g2_cost: None,
2851 group_ops_bls12381_decode_gt_cost: None,
2852 group_ops_bls12381_scalar_add_cost: None,
2853 group_ops_bls12381_g1_add_cost: None,
2854 group_ops_bls12381_g2_add_cost: None,
2855 group_ops_bls12381_gt_add_cost: None,
2856 group_ops_bls12381_scalar_sub_cost: None,
2857 group_ops_bls12381_g1_sub_cost: None,
2858 group_ops_bls12381_g2_sub_cost: None,
2859 group_ops_bls12381_gt_sub_cost: None,
2860 group_ops_bls12381_scalar_mul_cost: None,
2861 group_ops_bls12381_g1_mul_cost: None,
2862 group_ops_bls12381_g2_mul_cost: None,
2863 group_ops_bls12381_gt_mul_cost: None,
2864 group_ops_bls12381_scalar_div_cost: None,
2865 group_ops_bls12381_g1_div_cost: None,
2866 group_ops_bls12381_g2_div_cost: None,
2867 group_ops_bls12381_gt_div_cost: None,
2868 group_ops_bls12381_g1_hash_to_base_cost: None,
2869 group_ops_bls12381_g2_hash_to_base_cost: None,
2870 group_ops_bls12381_g1_hash_to_cost_per_byte: None,
2871 group_ops_bls12381_g2_hash_to_cost_per_byte: None,
2872 group_ops_bls12381_g1_msm_base_cost: None,
2873 group_ops_bls12381_g2_msm_base_cost: None,
2874 group_ops_bls12381_g1_msm_base_cost_per_input: None,
2875 group_ops_bls12381_g2_msm_base_cost_per_input: None,
2876 group_ops_bls12381_msm_max_len: None,
2877 group_ops_bls12381_pairing_cost: None,
2878 group_ops_bls12381_g1_to_uncompressed_g1_cost: None,
2879 group_ops_bls12381_uncompressed_g1_to_g1_cost: None,
2880 group_ops_bls12381_uncompressed_g1_sum_base_cost: None,
2881 group_ops_bls12381_uncompressed_g1_sum_cost_per_term: None,
2882 group_ops_bls12381_uncompressed_g1_sum_max_terms: None,
2883
2884 group_ops_ristretto_decode_scalar_cost: None,
2885 group_ops_ristretto_decode_point_cost: None,
2886 group_ops_ristretto_scalar_add_cost: None,
2887 group_ops_ristretto_point_add_cost: None,
2888 group_ops_ristretto_scalar_sub_cost: None,
2889 group_ops_ristretto_point_sub_cost: None,
2890 group_ops_ristretto_scalar_mul_cost: None,
2891 group_ops_ristretto_point_mul_cost: None,
2892 group_ops_ristretto_scalar_div_cost: None,
2893 group_ops_ristretto_point_div_cost: None,
2894
2895 verify_bulletproofs_ristretto255_base_cost: None,
2896 verify_bulletproofs_ristretto255_cost_per_bit_and_commitment: None,
2897 max_bulletproofs_total_bits: None,
2898
2899 check_zklogin_id_cost_base: None,
2901 check_zklogin_issuer_cost_base: None,
2903
2904 vdf_verify_vdf_cost: None,
2905 vdf_hash_to_input_cost: None,
2906
2907 nitro_attestation_parse_base_cost: None,
2909 nitro_attestation_parse_cost_per_byte: None,
2910 nitro_attestation_verify_base_cost: None,
2911 nitro_attestation_verify_cost_per_cert: None,
2912
2913 bcs_per_byte_serialized_cost: None,
2914 bcs_legacy_min_output_size_cost: None,
2915 bcs_failure_cost: None,
2916 hash_sha2_256_base_cost: None,
2917 hash_sha2_256_per_byte_cost: None,
2918 hash_sha2_256_legacy_min_input_len_cost: None,
2919 hash_sha3_256_base_cost: None,
2920 hash_sha3_256_per_byte_cost: None,
2921 hash_sha3_256_legacy_min_input_len_cost: None,
2922 type_name_get_base_cost: None,
2923 type_name_get_per_byte_cost: None,
2924 type_name_id_base_cost: None,
2925 string_check_utf8_base_cost: None,
2926 string_check_utf8_per_byte_cost: None,
2927 string_is_char_boundary_base_cost: None,
2928 string_sub_string_base_cost: None,
2929 string_sub_string_per_byte_cost: None,
2930 string_index_of_base_cost: None,
2931 string_index_of_per_byte_pattern_cost: None,
2932 string_index_of_per_byte_searched_cost: None,
2933 vector_empty_base_cost: None,
2934 vector_length_base_cost: None,
2935 vector_push_back_base_cost: None,
2936 vector_push_back_legacy_per_abstract_memory_unit_cost: None,
2937 vector_borrow_base_cost: None,
2938 vector_pop_back_base_cost: None,
2939 vector_destroy_empty_base_cost: None,
2940 vector_swap_base_cost: None,
2941 debug_print_base_cost: None,
2942 debug_print_stack_trace_base_cost: None,
2943
2944 max_size_written_objects: None,
2945 max_size_written_objects_system_tx: None,
2946
2947 max_move_identifier_len: None,
2954 max_move_value_depth: None,
2955 package_arena_size_in_bytes: None,
2956 max_move_enum_variants: None,
2957
2958 gas_rounding_step: None,
2959
2960 execution_version: None,
2961
2962 max_event_emit_size_total: None,
2963
2964 consensus_bad_nodes_stake_threshold: None,
2965
2966 max_jwk_votes_per_validator_per_epoch: None,
2967
2968 max_age_of_jwk_in_epochs: None,
2969
2970 random_beacon_reduction_allowed_delta: None,
2971
2972 random_beacon_reduction_lower_bound: None,
2973
2974 random_beacon_dkg_timeout_round: None,
2975
2976 random_beacon_min_round_interval_ms: None,
2977
2978 random_beacon_dkg_version: None,
2979
2980 consensus_max_transaction_size_bytes: None,
2981
2982 consensus_max_transactions_in_block_bytes: None,
2983
2984 consensus_max_num_transactions_in_block: None,
2985
2986 consensus_voting_rounds: None,
2987
2988 max_accumulated_txn_cost_per_object_in_narwhal_commit: None,
2989
2990 max_deferral_rounds_for_congestion_control: None,
2991
2992 epoch_close_deadline_ms: None,
2993
2994 max_txn_cost_overage_per_object_in_commit: None,
2995
2996 allowed_txn_cost_overage_burst_per_object_in_commit: None,
2997
2998 min_checkpoint_interval_ms: None,
2999
3000 checkpoint_summary_version_specific_data: None,
3001
3002 max_soft_bundle_size: None,
3003
3004 bridge_should_try_to_finalize_committee: None,
3005
3006 max_accumulated_txn_cost_per_object_in_mysticeti_commit: None,
3007
3008 max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit: None,
3009
3010 consensus_gc_depth: None,
3011
3012 gas_budget_based_txn_cost_cap_factor: None,
3013
3014 gas_budget_based_txn_cost_absolute_cap_commit_count: None,
3015
3016 sip_45_consensus_amplification_threshold: None,
3017
3018 use_object_per_epoch_marker_table_v2: None,
3019
3020 consensus_commit_rate_estimation_window_size: None,
3021
3022 aliased_addresses: vec![],
3023
3024 translation_per_command_base_charge: None,
3025 translation_per_input_base_charge: None,
3026 translation_pure_input_per_byte_charge: None,
3027 translation_per_type_node_charge: None,
3028 translation_per_reference_node_charge: None,
3029 translation_per_linkage_entry_charge: None,
3030 translation_per_live_reference_charge: None,
3031 max_ptb_live_references: None,
3032 max_ptb_returned_references: None,
3033 max_ptb_total_returned_references: None,
3034
3035 max_updates_per_settlement_txn: None,
3036
3037 gasless_max_computation_units: None,
3038 gasless_allowed_token_types: None,
3039 gasless_max_unused_inputs: None,
3040 gasless_max_pure_input_bytes: None,
3041 gasless_max_tps: None,
3042 include_special_package_amendments: None,
3043 gasless_max_tx_size_bytes: None,
3044 };
3047 for cur in 2..=version.0 {
3048 match cur {
3049 1 => unreachable!(),
3050 2 => {
3051 cfg.feature_flags.advance_epoch_start_time_in_safe_mode = true;
3052 }
3053 3 => {
3054 cfg.gas_model_version = Some(2);
3056 cfg.max_tx_gas = Some(50_000_000_000);
3058 cfg.base_tx_cost_fixed = Some(2_000);
3060 cfg.storage_gas_price = Some(76);
3062 cfg.feature_flags.loaded_child_objects_fixed = true;
3063 cfg.max_size_written_objects = Some(5 * 1000 * 1000);
3066 cfg.max_size_written_objects_system_tx = Some(50 * 1000 * 1000);
3069 cfg.feature_flags.package_upgrades = true;
3070 }
3071 4 => {
3076 cfg.reward_slashing_rate = Some(10000);
3078 cfg.gas_model_version = Some(3);
3080 }
3081 5 => {
3082 cfg.feature_flags.missing_type_is_compatibility_error = true;
3083 cfg.gas_model_version = Some(4);
3084 cfg.feature_flags.scoring_decision_with_validity_cutoff = true;
3085 }
3089 6 => {
3090 cfg.gas_model_version = Some(5);
3091 cfg.buffer_stake_for_protocol_upgrade_bps = Some(5000);
3092 cfg.feature_flags.consensus_order_end_of_epoch_last = true;
3093 }
3094 7 => {
3095 cfg.feature_flags.disallow_adding_abilities_on_upgrade = true;
3096 cfg.feature_flags
3097 .disable_invariant_violation_check_in_swap_loc = true;
3098 cfg.feature_flags.ban_entry_init = true;
3099 cfg.feature_flags.package_digest_hash_module = true;
3100 }
3101 8 => {
3102 cfg.feature_flags
3103 .disallow_change_struct_type_params_on_upgrade = true;
3104 }
3105 9 => {
3106 cfg.max_move_identifier_len = Some(128);
3108 cfg.feature_flags.no_extraneous_module_bytes = true;
3109 cfg.feature_flags
3110 .advance_to_highest_supported_protocol_version = true;
3111 }
3112 10 => {
3113 cfg.max_verifier_meter_ticks_per_function = Some(16_000_000);
3114 cfg.max_meter_ticks_per_module = Some(16_000_000);
3115 }
3116 11 => {
3117 cfg.max_move_value_depth = Some(128);
3118 }
3119 12 => {
3120 cfg.feature_flags.narwhal_versioned_metadata = true;
3121 if chain != Chain::Mainnet {
3122 cfg.feature_flags.commit_root_state_digest = true;
3123 }
3124
3125 if chain != Chain::Mainnet && chain != Chain::Testnet {
3126 cfg.feature_flags.zklogin_auth = true;
3127 }
3128 }
3129 13 => {}
3130 14 => {
3131 cfg.gas_rounding_step = Some(1_000);
3132 cfg.gas_model_version = Some(6);
3133 }
3134 15 => {
3135 cfg.feature_flags.consensus_transaction_ordering =
3136 ConsensusTransactionOrdering::ByGasPrice;
3137 }
3138 16 => {
3139 cfg.feature_flags.simplified_unwrap_then_delete = true;
3140 }
3141 17 => {
3142 cfg.feature_flags.upgraded_multisig_supported = true;
3143 }
3144 18 => {
3145 cfg.execution_version = Some(1);
3146 cfg.feature_flags.txn_base_cost_as_multiplier = true;
3155 cfg.base_tx_cost_fixed = Some(1_000);
3157 }
3158 19 => {
3159 cfg.max_num_event_emit = Some(1024);
3160 cfg.max_event_emit_size_total = Some(
3163 256 * 250 * 1024, );
3165 }
3166 20 => {
3167 cfg.feature_flags.commit_root_state_digest = true;
3168
3169 if chain != Chain::Mainnet {
3170 cfg.feature_flags.narwhal_new_leader_election_schedule = true;
3171 cfg.consensus_bad_nodes_stake_threshold = Some(20);
3172 }
3173 }
3174
3175 21 => {
3176 if chain != Chain::Mainnet {
3177 cfg.feature_flags.zklogin_supported_providers = BTreeSet::from([
3178 "Google".to_string(),
3179 "Facebook".to_string(),
3180 "Twitch".to_string(),
3181 ]);
3182 }
3183 }
3184 22 => {
3185 cfg.feature_flags.loaded_child_object_format = true;
3186 }
3187 23 => {
3188 cfg.feature_flags.loaded_child_object_format_type = true;
3189 cfg.feature_flags.narwhal_new_leader_election_schedule = true;
3190 cfg.consensus_bad_nodes_stake_threshold = Some(20);
3196 }
3197 24 => {
3198 cfg.feature_flags.simple_conservation_checks = true;
3199 cfg.max_publish_or_upgrade_per_ptb = Some(5);
3200
3201 cfg.feature_flags.end_of_epoch_transaction_supported = true;
3202
3203 if chain != Chain::Mainnet {
3204 cfg.feature_flags.enable_jwk_consensus_updates = true;
3205 cfg.max_jwk_votes_per_validator_per_epoch = Some(240);
3207 cfg.max_age_of_jwk_in_epochs = Some(1);
3208 }
3209 }
3210 25 => {
3211 cfg.feature_flags.zklogin_supported_providers = BTreeSet::from([
3213 "Google".to_string(),
3214 "Facebook".to_string(),
3215 "Twitch".to_string(),
3216 ]);
3217 cfg.feature_flags.zklogin_auth = true;
3218
3219 cfg.feature_flags.enable_jwk_consensus_updates = true;
3221 cfg.max_jwk_votes_per_validator_per_epoch = Some(240);
3222 cfg.max_age_of_jwk_in_epochs = Some(1);
3223 }
3224 26 => {
3225 cfg.gas_model_version = Some(7);
3226 if chain != Chain::Mainnet && chain != Chain::Testnet {
3228 cfg.transfer_receive_object_cost_base = Some(52);
3229 cfg.feature_flags.receive_objects = true;
3230 }
3231 }
3232 27 => {
3233 cfg.gas_model_version = Some(8);
3234 }
3235 28 => {
3236 cfg.check_zklogin_id_cost_base = Some(200);
3238 cfg.check_zklogin_issuer_cost_base = Some(200);
3240
3241 if chain != Chain::Mainnet && chain != Chain::Testnet {
3243 cfg.feature_flags.enable_effects_v2 = true;
3244 }
3245 }
3246 29 => {
3247 cfg.feature_flags.verify_legacy_zklogin_address = true;
3248 }
3249 30 => {
3250 if chain != Chain::Mainnet {
3252 cfg.feature_flags.narwhal_certificate_v2 = true;
3253 }
3254
3255 cfg.random_beacon_reduction_allowed_delta = Some(800);
3256 if chain != Chain::Mainnet {
3258 cfg.feature_flags.enable_effects_v2 = true;
3259 }
3260
3261 cfg.feature_flags.zklogin_supported_providers = BTreeSet::default();
3265
3266 cfg.feature_flags.recompute_has_public_transfer_in_execution = true;
3267 }
3268 31 => {
3269 cfg.execution_version = Some(2);
3270 if chain != Chain::Mainnet && chain != Chain::Testnet {
3272 cfg.feature_flags.shared_object_deletion = true;
3273 }
3274 }
3275 32 => {
3276 if chain != Chain::Mainnet {
3278 cfg.feature_flags.accept_zklogin_in_multisig = true;
3279 }
3280 if chain != Chain::Mainnet {
3282 cfg.transfer_receive_object_cost_base = Some(52);
3283 cfg.feature_flags.receive_objects = true;
3284 }
3285 if chain != Chain::Mainnet && chain != Chain::Testnet {
3287 cfg.feature_flags.random_beacon = true;
3288 cfg.random_beacon_reduction_lower_bound = Some(1600);
3289 cfg.random_beacon_dkg_timeout_round = Some(3000);
3290 cfg.random_beacon_min_round_interval_ms = Some(150);
3291 }
3292 if chain != Chain::Testnet && chain != Chain::Mainnet {
3294 cfg.feature_flags.include_consensus_digest_in_prologue = true;
3295 }
3296
3297 cfg.feature_flags.narwhal_certificate_v2 = true;
3299 }
3300 33 => {
3301 cfg.feature_flags.hardened_otw_check = true;
3302 cfg.feature_flags.allow_receiving_object_id = true;
3303
3304 cfg.transfer_receive_object_cost_base = Some(52);
3306 cfg.feature_flags.receive_objects = true;
3307
3308 if chain != Chain::Mainnet {
3310 cfg.feature_flags.shared_object_deletion = true;
3311 }
3312
3313 cfg.feature_flags.enable_effects_v2 = true;
3314 }
3315 34 => {}
3316 35 => {
3317 if chain != Chain::Mainnet && chain != Chain::Testnet {
3319 cfg.feature_flags.enable_poseidon = true;
3320 cfg.poseidon_bn254_cost_base = Some(260);
3321 cfg.poseidon_bn254_cost_per_block = Some(10);
3322 }
3323
3324 cfg.feature_flags.enable_coin_deny_list = true;
3325 }
3326 36 => {
3327 if chain != Chain::Mainnet && chain != Chain::Testnet {
3329 cfg.feature_flags.enable_group_ops_native_functions = true;
3330 cfg.feature_flags.enable_group_ops_native_function_msm = true;
3331 cfg.group_ops_bls12381_decode_scalar_cost = Some(52);
3333 cfg.group_ops_bls12381_decode_g1_cost = Some(52);
3334 cfg.group_ops_bls12381_decode_g2_cost = Some(52);
3335 cfg.group_ops_bls12381_decode_gt_cost = Some(52);
3336 cfg.group_ops_bls12381_scalar_add_cost = Some(52);
3337 cfg.group_ops_bls12381_g1_add_cost = Some(52);
3338 cfg.group_ops_bls12381_g2_add_cost = Some(52);
3339 cfg.group_ops_bls12381_gt_add_cost = Some(52);
3340 cfg.group_ops_bls12381_scalar_sub_cost = Some(52);
3341 cfg.group_ops_bls12381_g1_sub_cost = Some(52);
3342 cfg.group_ops_bls12381_g2_sub_cost = Some(52);
3343 cfg.group_ops_bls12381_gt_sub_cost = Some(52);
3344 cfg.group_ops_bls12381_scalar_mul_cost = Some(52);
3345 cfg.group_ops_bls12381_g1_mul_cost = Some(52);
3346 cfg.group_ops_bls12381_g2_mul_cost = Some(52);
3347 cfg.group_ops_bls12381_gt_mul_cost = Some(52);
3348 cfg.group_ops_bls12381_scalar_div_cost = Some(52);
3349 cfg.group_ops_bls12381_g1_div_cost = Some(52);
3350 cfg.group_ops_bls12381_g2_div_cost = Some(52);
3351 cfg.group_ops_bls12381_gt_div_cost = Some(52);
3352 cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(52);
3353 cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(52);
3354 cfg.group_ops_bls12381_g1_hash_to_cost_per_byte = Some(2);
3355 cfg.group_ops_bls12381_g2_hash_to_cost_per_byte = Some(2);
3356 cfg.group_ops_bls12381_g1_msm_base_cost = Some(52);
3357 cfg.group_ops_bls12381_g2_msm_base_cost = Some(52);
3358 cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(52);
3359 cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(52);
3360 cfg.group_ops_bls12381_msm_max_len = Some(32);
3361 cfg.group_ops_bls12381_pairing_cost = Some(52);
3362 }
3363 cfg.feature_flags.shared_object_deletion = true;
3365
3366 cfg.consensus_max_transaction_size_bytes = Some(256 * 1024); cfg.consensus_max_transactions_in_block_bytes = Some(6 * 1_024 * 1024);
3368 }
3370 37 => {
3371 cfg.feature_flags.reject_mutable_random_on_entry_functions = true;
3372
3373 if chain != Chain::Mainnet {
3375 cfg.feature_flags.include_consensus_digest_in_prologue = true;
3376 }
3377 }
3378 38 => {
3379 cfg.binary_module_handles = Some(100);
3380 cfg.binary_struct_handles = Some(300);
3381 cfg.binary_function_handles = Some(1500);
3382 cfg.binary_function_instantiations = Some(750);
3383 cfg.binary_signatures = Some(1000);
3384 cfg.binary_constant_pool = Some(4000);
3388 cfg.binary_identifiers = Some(10000);
3389 cfg.binary_address_identifiers = Some(100);
3390 cfg.binary_struct_defs = Some(200);
3391 cfg.binary_struct_def_instantiations = Some(100);
3392 cfg.binary_function_defs = Some(1000);
3393 cfg.binary_field_handles = Some(500);
3394 cfg.binary_field_instantiations = Some(250);
3395 cfg.binary_friend_decls = Some(100);
3396 cfg.max_package_dependencies = Some(32);
3398 cfg.max_modules_in_publish = Some(64);
3399 cfg.execution_version = Some(3);
3401 }
3402 39 => {
3403 }
3405 40 => {}
3406 41 => {
3407 cfg.feature_flags.enable_group_ops_native_functions = true;
3409 cfg.group_ops_bls12381_decode_scalar_cost = Some(52);
3411 cfg.group_ops_bls12381_decode_g1_cost = Some(52);
3412 cfg.group_ops_bls12381_decode_g2_cost = Some(52);
3413 cfg.group_ops_bls12381_decode_gt_cost = Some(52);
3414 cfg.group_ops_bls12381_scalar_add_cost = Some(52);
3415 cfg.group_ops_bls12381_g1_add_cost = Some(52);
3416 cfg.group_ops_bls12381_g2_add_cost = Some(52);
3417 cfg.group_ops_bls12381_gt_add_cost = Some(52);
3418 cfg.group_ops_bls12381_scalar_sub_cost = Some(52);
3419 cfg.group_ops_bls12381_g1_sub_cost = Some(52);
3420 cfg.group_ops_bls12381_g2_sub_cost = Some(52);
3421 cfg.group_ops_bls12381_gt_sub_cost = Some(52);
3422 cfg.group_ops_bls12381_scalar_mul_cost = Some(52);
3423 cfg.group_ops_bls12381_g1_mul_cost = Some(52);
3424 cfg.group_ops_bls12381_g2_mul_cost = Some(52);
3425 cfg.group_ops_bls12381_gt_mul_cost = Some(52);
3426 cfg.group_ops_bls12381_scalar_div_cost = Some(52);
3427 cfg.group_ops_bls12381_g1_div_cost = Some(52);
3428 cfg.group_ops_bls12381_g2_div_cost = Some(52);
3429 cfg.group_ops_bls12381_gt_div_cost = Some(52);
3430 cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(52);
3431 cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(52);
3432 cfg.group_ops_bls12381_g1_hash_to_cost_per_byte = Some(2);
3433 cfg.group_ops_bls12381_g2_hash_to_cost_per_byte = Some(2);
3434 cfg.group_ops_bls12381_g1_msm_base_cost = Some(52);
3435 cfg.group_ops_bls12381_g2_msm_base_cost = Some(52);
3436 cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(52);
3437 cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(52);
3438 cfg.group_ops_bls12381_msm_max_len = Some(32);
3439 cfg.group_ops_bls12381_pairing_cost = Some(52);
3440 }
3441 42 => {}
3442 43 => {
3443 cfg.feature_flags.zklogin_max_epoch_upper_bound_delta = Some(30);
3444 cfg.max_meter_ticks_per_package = Some(16_000_000);
3445 }
3446 44 => {
3447 cfg.feature_flags.include_consensus_digest_in_prologue = true;
3449 if chain != Chain::Mainnet {
3451 cfg.feature_flags.consensus_choice = ConsensusChoice::SwapEachEpoch;
3452 }
3453 }
3454 45 => {
3455 if chain != Chain::Testnet && chain != Chain::Mainnet {
3457 cfg.feature_flags.consensus_network = ConsensusNetwork::Tonic;
3458 }
3459
3460 if chain != Chain::Mainnet {
3461 cfg.feature_flags.mysticeti_leader_scoring_and_schedule = true;
3463 }
3464 cfg.min_move_binary_format_version = Some(6);
3465 cfg.feature_flags.accept_zklogin_in_multisig = true;
3466
3467 if chain != Chain::Mainnet && chain != Chain::Testnet {
3471 cfg.feature_flags.bridge = true;
3472 }
3473 }
3474 46 => {
3475 if chain != Chain::Mainnet {
3477 cfg.feature_flags.bridge = true;
3478 }
3479
3480 cfg.feature_flags.reshare_at_same_initial_version = true;
3482 }
3483 47 => {}
3484 48 => {
3485 cfg.feature_flags.consensus_network = ConsensusNetwork::Tonic;
3487
3488 cfg.feature_flags.resolve_abort_locations_to_package_id = true;
3490
3491 if chain != Chain::Mainnet {
3493 cfg.feature_flags.random_beacon = true;
3494 cfg.random_beacon_reduction_lower_bound = Some(1600);
3495 cfg.random_beacon_dkg_timeout_round = Some(3000);
3496 cfg.random_beacon_min_round_interval_ms = Some(200);
3497 }
3498
3499 cfg.feature_flags.mysticeti_use_committed_subdag_digest = true;
3501 }
3502 49 => {
3503 if chain != Chain::Testnet && chain != Chain::Mainnet {
3504 cfg.move_binary_format_version = Some(7);
3505 }
3506
3507 if chain != Chain::Mainnet && chain != Chain::Testnet {
3509 cfg.feature_flags.enable_vdf = true;
3510 cfg.vdf_verify_vdf_cost = Some(1500);
3513 cfg.vdf_hash_to_input_cost = Some(100);
3514 }
3515
3516 if chain != Chain::Testnet && chain != Chain::Mainnet {
3518 cfg.feature_flags
3519 .record_consensus_determined_version_assignments_in_prologue = true;
3520 }
3521
3522 if chain != Chain::Mainnet {
3524 cfg.feature_flags.consensus_choice = ConsensusChoice::Mysticeti;
3525 }
3526
3527 cfg.feature_flags.fresh_vm_on_framework_upgrade = true;
3529 }
3530 50 => {
3531 if chain != Chain::Mainnet {
3533 cfg.checkpoint_summary_version_specific_data = Some(1);
3534 cfg.min_checkpoint_interval_ms = Some(200);
3535 }
3536
3537 if chain != Chain::Testnet && chain != Chain::Mainnet {
3539 cfg.feature_flags
3540 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = true;
3541 }
3542
3543 cfg.feature_flags.mysticeti_num_leaders_per_round = Some(1);
3544
3545 cfg.max_deferral_rounds_for_congestion_control = Some(10);
3547 }
3548 51 => {
3549 cfg.random_beacon_dkg_version = Some(1);
3550
3551 if chain != Chain::Testnet && chain != Chain::Mainnet {
3552 cfg.feature_flags.enable_coin_deny_list_v2 = true;
3553 }
3554 }
3555 52 => {
3556 if chain != Chain::Mainnet {
3557 cfg.feature_flags.soft_bundle = true;
3558 cfg.max_soft_bundle_size = Some(5);
3559 }
3560
3561 cfg.config_read_setting_impl_cost_base = Some(100);
3562 cfg.config_read_setting_impl_cost_per_byte = Some(40);
3563
3564 if chain != Chain::Testnet && chain != Chain::Mainnet {
3566 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(100);
3567 cfg.feature_flags.per_object_congestion_control_mode =
3568 PerObjectCongestionControlMode::TotalTxCount;
3569 }
3570
3571 cfg.feature_flags.consensus_choice = ConsensusChoice::Mysticeti;
3573
3574 cfg.feature_flags.mysticeti_leader_scoring_and_schedule = true;
3576
3577 cfg.checkpoint_summary_version_specific_data = Some(1);
3579 cfg.min_checkpoint_interval_ms = Some(200);
3580
3581 if chain != Chain::Mainnet {
3583 cfg.feature_flags
3584 .record_consensus_determined_version_assignments_in_prologue = true;
3585 cfg.feature_flags
3586 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = true;
3587 }
3588 if chain != Chain::Mainnet {
3590 cfg.move_binary_format_version = Some(7);
3591 }
3592
3593 if chain != Chain::Testnet && chain != Chain::Mainnet {
3594 cfg.feature_flags.passkey_auth = true;
3595 }
3596 cfg.feature_flags.enable_coin_deny_list_v2 = true;
3597 }
3598 53 => {
3599 cfg.bridge_should_try_to_finalize_committee = Some(chain != Chain::Mainnet);
3601
3602 cfg.feature_flags
3604 .record_consensus_determined_version_assignments_in_prologue = true;
3605 cfg.feature_flags
3606 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = true;
3607
3608 if chain == Chain::Unknown {
3609 cfg.feature_flags.authority_capabilities_v2 = true;
3610 }
3611
3612 if chain != Chain::Mainnet {
3614 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(100);
3615 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(10);
3616 cfg.feature_flags.per_object_congestion_control_mode =
3617 PerObjectCongestionControlMode::TotalTxCount;
3618 }
3619
3620 cfg.bcs_per_byte_serialized_cost = Some(2);
3622 cfg.bcs_legacy_min_output_size_cost = Some(1);
3623 cfg.bcs_failure_cost = Some(52);
3624 cfg.debug_print_base_cost = Some(52);
3625 cfg.debug_print_stack_trace_base_cost = Some(52);
3626 cfg.hash_sha2_256_base_cost = Some(52);
3627 cfg.hash_sha2_256_per_byte_cost = Some(2);
3628 cfg.hash_sha2_256_legacy_min_input_len_cost = Some(1);
3629 cfg.hash_sha3_256_base_cost = Some(52);
3630 cfg.hash_sha3_256_per_byte_cost = Some(2);
3631 cfg.hash_sha3_256_legacy_min_input_len_cost = Some(1);
3632 cfg.type_name_get_base_cost = Some(52);
3633 cfg.type_name_get_per_byte_cost = Some(2);
3634 cfg.string_check_utf8_base_cost = Some(52);
3635 cfg.string_check_utf8_per_byte_cost = Some(2);
3636 cfg.string_is_char_boundary_base_cost = Some(52);
3637 cfg.string_sub_string_base_cost = Some(52);
3638 cfg.string_sub_string_per_byte_cost = Some(2);
3639 cfg.string_index_of_base_cost = Some(52);
3640 cfg.string_index_of_per_byte_pattern_cost = Some(2);
3641 cfg.string_index_of_per_byte_searched_cost = Some(2);
3642 cfg.vector_empty_base_cost = Some(52);
3643 cfg.vector_length_base_cost = Some(52);
3644 cfg.vector_push_back_base_cost = Some(52);
3645 cfg.vector_push_back_legacy_per_abstract_memory_unit_cost = Some(2);
3646 cfg.vector_borrow_base_cost = Some(52);
3647 cfg.vector_pop_back_base_cost = Some(52);
3648 cfg.vector_destroy_empty_base_cost = Some(52);
3649 cfg.vector_swap_base_cost = Some(52);
3650 }
3651 54 => {
3652 cfg.feature_flags.random_beacon = true;
3654 cfg.random_beacon_reduction_lower_bound = Some(1000);
3655 cfg.random_beacon_dkg_timeout_round = Some(3000);
3656 cfg.random_beacon_min_round_interval_ms = Some(500);
3657
3658 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(100);
3660 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(10);
3661 cfg.feature_flags.per_object_congestion_control_mode =
3662 PerObjectCongestionControlMode::TotalTxCount;
3663
3664 cfg.feature_flags.soft_bundle = true;
3666 cfg.max_soft_bundle_size = Some(5);
3667 }
3668 55 => {
3669 cfg.move_binary_format_version = Some(7);
3671
3672 cfg.consensus_max_transactions_in_block_bytes = Some(512 * 1024);
3674 cfg.consensus_max_num_transactions_in_block = Some(512);
3677
3678 cfg.feature_flags.rethrow_serialization_type_layout_errors = true;
3679 }
3680 56 => {
3681 if chain == Chain::Mainnet {
3682 cfg.feature_flags.bridge = true;
3683 }
3684 }
3685 57 => {
3686 cfg.random_beacon_reduction_lower_bound = Some(800);
3688 }
3689 58 => {
3690 if chain == Chain::Mainnet {
3691 cfg.bridge_should_try_to_finalize_committee = Some(true);
3692 }
3693
3694 if chain != Chain::Mainnet && chain != Chain::Testnet {
3695 cfg.feature_flags
3697 .consensus_distributed_vote_scoring_strategy = true;
3698 }
3699 }
3700 59 => {
3701 cfg.feature_flags.consensus_round_prober = true;
3703 }
3704 60 => {
3705 cfg.max_type_to_layout_nodes = Some(512);
3706 cfg.feature_flags.validate_identifier_inputs = true;
3707 }
3708 61 => {
3709 if chain != Chain::Mainnet {
3710 cfg.feature_flags
3712 .consensus_distributed_vote_scoring_strategy = true;
3713 }
3714 cfg.random_beacon_reduction_lower_bound = Some(700);
3716
3717 if chain != Chain::Mainnet && chain != Chain::Testnet {
3718 cfg.feature_flags.mysticeti_fastpath = true;
3720 }
3721 }
3722 62 => {
3723 cfg.feature_flags.relocate_event_module = true;
3724 }
3725 63 => {
3726 cfg.feature_flags.per_object_congestion_control_mode =
3727 PerObjectCongestionControlMode::TotalGasBudgetWithCap;
3728 cfg.gas_budget_based_txn_cost_cap_factor = Some(400_000);
3729 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(18_500_000);
3730 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(240_000_000);
3731 }
3732 64 => {
3733 cfg.feature_flags.per_object_congestion_control_mode =
3734 PerObjectCongestionControlMode::TotalTxCount;
3735 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(40);
3736 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(3);
3737 }
3738 65 => {
3739 cfg.feature_flags
3741 .consensus_distributed_vote_scoring_strategy = true;
3742 }
3743 66 => {
3744 if chain == Chain::Mainnet {
3745 cfg.feature_flags
3747 .consensus_distributed_vote_scoring_strategy = false;
3748 }
3749 }
3750 67 => {
3751 cfg.feature_flags
3753 .consensus_distributed_vote_scoring_strategy = true;
3754 }
3755 68 => {
3756 cfg.group_ops_bls12381_g1_to_uncompressed_g1_cost = Some(26);
3757 cfg.group_ops_bls12381_uncompressed_g1_to_g1_cost = Some(52);
3758 cfg.group_ops_bls12381_uncompressed_g1_sum_base_cost = Some(26);
3759 cfg.group_ops_bls12381_uncompressed_g1_sum_cost_per_term = Some(13);
3760 cfg.group_ops_bls12381_uncompressed_g1_sum_max_terms = Some(2000);
3761
3762 if chain != Chain::Mainnet && chain != Chain::Testnet {
3763 cfg.feature_flags.uncompressed_g1_group_elements = true;
3764 }
3765
3766 cfg.feature_flags.per_object_congestion_control_mode =
3767 PerObjectCongestionControlMode::TotalGasBudgetWithCap;
3768 cfg.gas_budget_based_txn_cost_cap_factor = Some(400_000);
3769 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(18_500_000);
3770 cfg.max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit =
3771 Some(3_700_000); cfg.max_txn_cost_overage_per_object_in_commit = Some(u64::MAX);
3773 cfg.gas_budget_based_txn_cost_absolute_cap_commit_count = Some(50);
3774
3775 cfg.random_beacon_reduction_lower_bound = Some(500);
3777
3778 cfg.feature_flags.disallow_new_modules_in_deps_only_packages = true;
3779 }
3780 69 => {
3781 cfg.consensus_voting_rounds = Some(40);
3783
3784 if chain != Chain::Mainnet && chain != Chain::Testnet {
3785 cfg.feature_flags.consensus_smart_ancestor_selection = true;
3787 }
3788
3789 if chain != Chain::Mainnet {
3790 cfg.feature_flags.uncompressed_g1_group_elements = true;
3791 }
3792 }
3793 70 => {
3794 if chain != Chain::Mainnet {
3795 cfg.feature_flags.consensus_smart_ancestor_selection = true;
3797 cfg.feature_flags
3799 .consensus_round_prober_probe_accepted_rounds = true;
3800 }
3801
3802 cfg.poseidon_bn254_cost_per_block = Some(388);
3803
3804 cfg.gas_model_version = Some(9);
3805 cfg.feature_flags.native_charging_v2 = true;
3806 cfg.bls12381_bls12381_min_sig_verify_cost_base = Some(44064);
3807 cfg.bls12381_bls12381_min_pk_verify_cost_base = Some(49282);
3808 cfg.ecdsa_k1_secp256k1_verify_keccak256_cost_base = Some(1470);
3809 cfg.ecdsa_k1_secp256k1_verify_sha256_cost_base = Some(1470);
3810 cfg.ecdsa_r1_secp256r1_verify_sha256_cost_base = Some(4225);
3811 cfg.ecdsa_r1_secp256r1_verify_keccak256_cost_base = Some(4225);
3812 cfg.ecvrf_ecvrf_verify_cost_base = Some(4848);
3813 cfg.ed25519_ed25519_verify_cost_base = Some(1802);
3814
3815 cfg.ecdsa_r1_ecrecover_keccak256_cost_base = Some(1173);
3817 cfg.ecdsa_r1_ecrecover_sha256_cost_base = Some(1173);
3818 cfg.ecdsa_k1_ecrecover_keccak256_cost_base = Some(500);
3819 cfg.ecdsa_k1_ecrecover_sha256_cost_base = Some(500);
3820
3821 cfg.groth16_prepare_verifying_key_bls12381_cost_base = Some(53838);
3822 cfg.groth16_prepare_verifying_key_bn254_cost_base = Some(82010);
3823 cfg.groth16_verify_groth16_proof_internal_bls12381_cost_base = Some(72090);
3824 cfg.groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input =
3825 Some(8213);
3826 cfg.groth16_verify_groth16_proof_internal_bn254_cost_base = Some(115502);
3827 cfg.groth16_verify_groth16_proof_internal_bn254_cost_per_public_input =
3828 Some(9484);
3829
3830 cfg.hash_keccak256_cost_base = Some(10);
3831 cfg.hash_blake2b256_cost_base = Some(10);
3832
3833 cfg.group_ops_bls12381_decode_scalar_cost = Some(7);
3835 cfg.group_ops_bls12381_decode_g1_cost = Some(2848);
3836 cfg.group_ops_bls12381_decode_g2_cost = Some(3770);
3837 cfg.group_ops_bls12381_decode_gt_cost = Some(3068);
3838
3839 cfg.group_ops_bls12381_scalar_add_cost = Some(10);
3840 cfg.group_ops_bls12381_g1_add_cost = Some(1556);
3841 cfg.group_ops_bls12381_g2_add_cost = Some(3048);
3842 cfg.group_ops_bls12381_gt_add_cost = Some(188);
3843
3844 cfg.group_ops_bls12381_scalar_sub_cost = Some(10);
3845 cfg.group_ops_bls12381_g1_sub_cost = Some(1550);
3846 cfg.group_ops_bls12381_g2_sub_cost = Some(3019);
3847 cfg.group_ops_bls12381_gt_sub_cost = Some(497);
3848
3849 cfg.group_ops_bls12381_scalar_mul_cost = Some(11);
3850 cfg.group_ops_bls12381_g1_mul_cost = Some(4842);
3851 cfg.group_ops_bls12381_g2_mul_cost = Some(9108);
3852 cfg.group_ops_bls12381_gt_mul_cost = Some(27490);
3853
3854 cfg.group_ops_bls12381_scalar_div_cost = Some(91);
3855 cfg.group_ops_bls12381_g1_div_cost = Some(5091);
3856 cfg.group_ops_bls12381_g2_div_cost = Some(9206);
3857 cfg.group_ops_bls12381_gt_div_cost = Some(27804);
3858
3859 cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(2962);
3860 cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(8688);
3861
3862 cfg.group_ops_bls12381_g1_msm_base_cost = Some(62648);
3863 cfg.group_ops_bls12381_g2_msm_base_cost = Some(131192);
3864 cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(1333);
3865 cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(3216);
3866
3867 cfg.group_ops_bls12381_uncompressed_g1_to_g1_cost = Some(677);
3868 cfg.group_ops_bls12381_g1_to_uncompressed_g1_cost = Some(2099);
3869 cfg.group_ops_bls12381_uncompressed_g1_sum_base_cost = Some(77);
3870 cfg.group_ops_bls12381_uncompressed_g1_sum_cost_per_term = Some(26);
3871
3872 cfg.group_ops_bls12381_pairing_cost = Some(26897);
3873 cfg.group_ops_bls12381_uncompressed_g1_sum_max_terms = Some(1200);
3874
3875 cfg.validator_validate_metadata_cost_base = Some(20000);
3876 }
3877 71 => {
3878 cfg.sip_45_consensus_amplification_threshold = Some(5);
3879
3880 cfg.allowed_txn_cost_overage_burst_per_object_in_commit = Some(185_000_000);
3882 }
3883 72 => {
3884 cfg.feature_flags.convert_type_argument_error = true;
3885
3886 cfg.max_tx_gas = Some(50_000_000_000_000);
3889 cfg.max_gas_price = Some(50_000_000_000);
3891
3892 cfg.feature_flags.variant_nodes = true;
3893 }
3894 73 => {
3895 cfg.use_object_per_epoch_marker_table_v2 = Some(true);
3897
3898 if chain != Chain::Mainnet && chain != Chain::Testnet {
3899 cfg.consensus_gc_depth = Some(60);
3902 }
3903
3904 if chain != Chain::Mainnet {
3905 cfg.feature_flags.consensus_zstd_compression = true;
3907 }
3908
3909 cfg.feature_flags.consensus_smart_ancestor_selection = true;
3911 cfg.feature_flags
3913 .consensus_round_prober_probe_accepted_rounds = true;
3914
3915 cfg.feature_flags.per_object_congestion_control_mode =
3917 PerObjectCongestionControlMode::TotalGasBudgetWithCap;
3918 cfg.gas_budget_based_txn_cost_cap_factor = Some(400_000);
3919 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(37_000_000);
3920 cfg.max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit =
3921 Some(7_400_000); cfg.max_txn_cost_overage_per_object_in_commit = Some(u64::MAX);
3923 cfg.gas_budget_based_txn_cost_absolute_cap_commit_count = Some(50);
3924 cfg.allowed_txn_cost_overage_burst_per_object_in_commit = Some(370_000_000);
3925 }
3926 74 => {
3927 if chain != Chain::Mainnet && chain != Chain::Testnet {
3929 cfg.feature_flags.enable_nitro_attestation = true;
3930 }
3931 cfg.nitro_attestation_parse_base_cost = Some(53 * 50);
3932 cfg.nitro_attestation_parse_cost_per_byte = Some(50);
3933 cfg.nitro_attestation_verify_base_cost = Some(49632 * 50);
3934 cfg.nitro_attestation_verify_cost_per_cert = Some(52369 * 50);
3935
3936 cfg.feature_flags.consensus_zstd_compression = true;
3938
3939 if chain != Chain::Mainnet && chain != Chain::Testnet {
3940 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
3941 }
3942 }
3943 75 => {
3944 if chain != Chain::Mainnet {
3945 cfg.feature_flags.passkey_auth = true;
3946 }
3947 }
3948 76 => {
3949 if chain != Chain::Mainnet && chain != Chain::Testnet {
3950 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
3951 cfg.consensus_commit_rate_estimation_window_size = Some(10);
3952 }
3953 cfg.feature_flags.minimize_child_object_mutations = true;
3954
3955 if chain != Chain::Mainnet {
3956 cfg.feature_flags.accept_passkey_in_multisig = true;
3957 }
3958 }
3959 77 => {
3960 cfg.feature_flags.uncompressed_g1_group_elements = true;
3961
3962 if chain != Chain::Mainnet {
3963 cfg.consensus_gc_depth = Some(60);
3964 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
3965 }
3966 }
3967 78 => {
3968 cfg.feature_flags.move_native_context = true;
3969 cfg.tx_context_fresh_id_cost_base = Some(52);
3970 cfg.tx_context_sender_cost_base = Some(30);
3971 cfg.tx_context_epoch_cost_base = Some(30);
3972 cfg.tx_context_epoch_timestamp_ms_cost_base = Some(30);
3973 cfg.tx_context_sponsor_cost_base = Some(30);
3974 cfg.tx_context_gas_price_cost_base = Some(30);
3975 cfg.tx_context_gas_budget_cost_base = Some(30);
3976 cfg.tx_context_ids_created_cost_base = Some(30);
3977 cfg.tx_context_replace_cost_base = Some(30);
3978 cfg.gas_model_version = Some(10);
3979
3980 if chain != Chain::Mainnet {
3981 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
3982 cfg.consensus_commit_rate_estimation_window_size = Some(10);
3983
3984 cfg.feature_flags.per_object_congestion_control_mode =
3986 PerObjectCongestionControlMode::ExecutionTimeEstimate(
3987 ExecutionTimeEstimateParams {
3988 target_utilization: 30,
3989 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
3991 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
3993 stored_observations_limit: u64::MAX,
3994 stake_weighted_median_threshold: 0,
3995 default_none_duration_for_new_keys: false,
3996 observations_chunk_size: None,
3997 },
3998 );
3999 }
4000 }
4001 79 => {
4002 if chain != Chain::Mainnet {
4003 cfg.feature_flags.consensus_median_based_commit_timestamp = true;
4004
4005 cfg.consensus_bad_nodes_stake_threshold = Some(30);
4008
4009 cfg.feature_flags.consensus_batched_block_sync = true;
4010
4011 cfg.feature_flags.enable_nitro_attestation = true
4013 }
4014 cfg.feature_flags.normalize_ptb_arguments = true;
4015
4016 cfg.consensus_gc_depth = Some(60);
4017 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
4018 }
4019 80 => {
4020 cfg.max_ptb_value_size = Some(1024 * 1024);
4021 }
4022 81 => {
4023 cfg.feature_flags.consensus_median_based_commit_timestamp = true;
4024 cfg.feature_flags.enforce_checkpoint_timestamp_monotonicity = true;
4025 cfg.consensus_bad_nodes_stake_threshold = Some(30)
4026 }
4027 82 => {
4028 cfg.feature_flags.max_ptb_value_size_v2 = true;
4029 }
4030 83 => {
4031 if chain == Chain::Mainnet {
4032 let aliased: [u8; 32] = Hex::decode(
4034 "0x0b2da327ba6a4cacbe75dddd50e6e8bbf81d6496e92d66af9154c61c77f7332f",
4035 )
4036 .unwrap()
4037 .try_into()
4038 .unwrap();
4039
4040 cfg.aliased_addresses.push(AliasedAddress {
4042 original: Hex::decode("0xcd8962dad278d8b50fa0f9eb0186bfa4cbdecc6d59377214c88d0286a0ac9562").unwrap().try_into().unwrap(),
4043 aliased,
4044 allowed_tx_digests: vec![
4045 Base58::decode("B2eGLFoMHgj93Ni8dAJBfqGzo8EWSTLBesZzhEpTPA4").unwrap().try_into().unwrap(),
4046 ],
4047 });
4048
4049 cfg.aliased_addresses.push(AliasedAddress {
4050 original: Hex::decode("0xe28b50cef1d633ea43d3296a3f6b67ff0312a5f1a99f0af753c85b8b5de8ff06").unwrap().try_into().unwrap(),
4051 aliased,
4052 allowed_tx_digests: vec![
4053 Base58::decode("J4QqSAgp7VrQtQpMy5wDX4QGsCSEZu3U5KuDAkbESAge").unwrap().try_into().unwrap(),
4054 ],
4055 });
4056 }
4057
4058 if chain != Chain::Mainnet {
4061 cfg.feature_flags.resolve_type_input_ids_to_defining_id = true;
4062 cfg.transfer_party_transfer_internal_cost_base = Some(52);
4063
4064 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
4066 cfg.consensus_commit_rate_estimation_window_size = Some(10);
4067 cfg.feature_flags.per_object_congestion_control_mode =
4068 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4069 ExecutionTimeEstimateParams {
4070 target_utilization: 30,
4071 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4073 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4075 stored_observations_limit: u64::MAX,
4076 stake_weighted_median_threshold: 0,
4077 default_none_duration_for_new_keys: false,
4078 observations_chunk_size: None,
4079 },
4080 );
4081
4082 cfg.feature_flags.consensus_batched_block_sync = true;
4084
4085 cfg.feature_flags.enable_nitro_attestation_upgraded_parsing = true;
4088 cfg.feature_flags.enable_nitro_attestation = true;
4089 }
4090 }
4091 84 => {
4092 if chain == Chain::Mainnet {
4093 cfg.feature_flags.resolve_type_input_ids_to_defining_id = true;
4094 cfg.transfer_party_transfer_internal_cost_base = Some(52);
4095
4096 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
4098 cfg.consensus_commit_rate_estimation_window_size = Some(10);
4099 cfg.feature_flags.per_object_congestion_control_mode =
4100 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4101 ExecutionTimeEstimateParams {
4102 target_utilization: 30,
4103 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4105 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4107 stored_observations_limit: u64::MAX,
4108 stake_weighted_median_threshold: 0,
4109 default_none_duration_for_new_keys: false,
4110 observations_chunk_size: None,
4111 },
4112 );
4113
4114 cfg.feature_flags.consensus_batched_block_sync = true;
4116
4117 cfg.feature_flags.enable_nitro_attestation_upgraded_parsing = true;
4120 cfg.feature_flags.enable_nitro_attestation = true;
4121 }
4122
4123 cfg.feature_flags.per_object_congestion_control_mode =
4125 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4126 ExecutionTimeEstimateParams {
4127 target_utilization: 30,
4128 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4130 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4132 stored_observations_limit: 20,
4133 stake_weighted_median_threshold: 0,
4134 default_none_duration_for_new_keys: false,
4135 observations_chunk_size: None,
4136 },
4137 );
4138 cfg.feature_flags.allow_unbounded_system_objects = true;
4139 }
4140 85 => {
4141 if chain != Chain::Mainnet && chain != Chain::Testnet {
4142 cfg.feature_flags.enable_party_transfer = true;
4143 }
4144
4145 cfg.feature_flags
4146 .record_consensus_determined_version_assignments_in_prologue_v2 = true;
4147 cfg.feature_flags.disallow_self_identifier = true;
4148 cfg.feature_flags.per_object_congestion_control_mode =
4149 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4150 ExecutionTimeEstimateParams {
4151 target_utilization: 50,
4152 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4154 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4156 stored_observations_limit: 20,
4157 stake_weighted_median_threshold: 0,
4158 default_none_duration_for_new_keys: false,
4159 observations_chunk_size: None,
4160 },
4161 );
4162 }
4163 86 => {
4164 cfg.feature_flags.type_tags_in_object_runtime = true;
4165 cfg.max_move_enum_variants = Some(move_core_types::VARIANT_COUNT_MAX);
4166
4167 cfg.feature_flags.per_object_congestion_control_mode =
4169 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4170 ExecutionTimeEstimateParams {
4171 target_utilization: 50,
4172 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4174 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4176 stored_observations_limit: 20,
4177 stake_weighted_median_threshold: 3334,
4178 default_none_duration_for_new_keys: false,
4179 observations_chunk_size: None,
4180 },
4181 );
4182 if chain != Chain::Mainnet {
4184 cfg.feature_flags.enable_party_transfer = true;
4185 }
4186 }
4187 87 => {
4188 if chain == Chain::Mainnet {
4189 cfg.feature_flags.record_time_estimate_processed = true;
4190 }
4191 cfg.feature_flags.better_adapter_type_resolution_errors = true;
4192 }
4193 88 => {
4194 cfg.feature_flags.record_time_estimate_processed = true;
4195 cfg.tx_context_rgp_cost_base = Some(30);
4196 cfg.feature_flags
4197 .ignore_execution_time_observations_after_certs_closed = true;
4198
4199 cfg.feature_flags.per_object_congestion_control_mode =
4202 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4203 ExecutionTimeEstimateParams {
4204 target_utilization: 50,
4205 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4207 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4209 stored_observations_limit: 20,
4210 stake_weighted_median_threshold: 3334,
4211 default_none_duration_for_new_keys: true,
4212 observations_chunk_size: None,
4213 },
4214 );
4215 }
4216 89 => {
4217 cfg.feature_flags.dependency_linkage_error = true;
4218 cfg.feature_flags.additional_multisig_checks = true;
4219 }
4220 90 => {
4221 cfg.max_gas_price_rgp_factor_for_aborted_transactions = Some(100);
4223 cfg.feature_flags.debug_fatal_on_move_invariant_violation = true;
4224 cfg.feature_flags.additional_consensus_digest_indirect_state = true;
4225 cfg.feature_flags.accept_passkey_in_multisig = true;
4226 cfg.feature_flags.passkey_auth = true;
4227 cfg.feature_flags.check_for_init_during_upgrade = true;
4228
4229 if chain != Chain::Mainnet {
4231 cfg.feature_flags.mysticeti_fastpath = true;
4232 }
4233 }
4234 91 => {
4235 cfg.feature_flags.per_command_shared_object_transfer_rules = true;
4236 }
4237 92 => {
4238 cfg.feature_flags.per_command_shared_object_transfer_rules = false;
4239 }
4240 93 => {
4241 cfg.feature_flags
4242 .consensus_checkpoint_signature_key_includes_digest = true;
4243 }
4244 94 => {
4245 cfg.feature_flags.per_object_congestion_control_mode =
4247 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4248 ExecutionTimeEstimateParams {
4249 target_utilization: 50,
4250 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4252 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4254 stored_observations_limit: 18,
4255 stake_weighted_median_threshold: 3334,
4256 default_none_duration_for_new_keys: true,
4257 observations_chunk_size: None,
4258 },
4259 );
4260
4261 cfg.feature_flags.enable_party_transfer = true;
4263 }
4264 95 => {
4265 cfg.type_name_id_base_cost = Some(52);
4266
4267 cfg.max_transactions_per_checkpoint = Some(20_000);
4269 }
4270 96 => {
4271 if chain != Chain::Mainnet && chain != Chain::Testnet {
4273 cfg.feature_flags
4274 .include_checkpoint_artifacts_digest_in_summary = true;
4275 }
4276 cfg.feature_flags.correct_gas_payment_limit_check = true;
4277 cfg.feature_flags.authority_capabilities_v2 = true;
4278 cfg.feature_flags.use_mfp_txns_in_load_initial_object_debts = true;
4279 cfg.feature_flags.cancel_for_failed_dkg_early = true;
4280 cfg.feature_flags.enable_coin_registry = true;
4281
4282 cfg.feature_flags.mysticeti_fastpath = true;
4284 }
4285 97 => {
4286 cfg.feature_flags.additional_borrow_checks = true;
4287 }
4288 98 => {
4289 cfg.event_emit_auth_stream_cost = Some(52);
4290 cfg.feature_flags.better_loader_errors = true;
4291 cfg.feature_flags.generate_df_type_layouts = true;
4292 }
4293 99 => {
4294 cfg.feature_flags.use_new_commit_handler = true;
4295 }
4296 100 => {
4297 cfg.feature_flags.private_generics_verifier_v2 = true;
4298 }
4299 101 => {
4300 cfg.feature_flags.create_root_accumulator_object = true;
4301 cfg.max_updates_per_settlement_txn = Some(100);
4302 if chain != Chain::Mainnet {
4303 cfg.feature_flags.enable_poseidon = true;
4304 }
4305 }
4306 102 => {
4307 cfg.feature_flags.per_object_congestion_control_mode =
4311 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4312 ExecutionTimeEstimateParams {
4313 target_utilization: 50,
4314 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4316 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4318 stored_observations_limit: 180,
4319 stake_weighted_median_threshold: 3334,
4320 default_none_duration_for_new_keys: true,
4321 observations_chunk_size: Some(18),
4322 },
4323 );
4324 cfg.feature_flags.deprecate_global_storage_ops = true;
4325 }
4326 103 => {}
4327 104 => {
4328 cfg.translation_per_command_base_charge = Some(1);
4329 cfg.translation_per_input_base_charge = Some(1);
4330 cfg.translation_pure_input_per_byte_charge = Some(1);
4331 cfg.translation_per_type_node_charge = Some(1);
4332 cfg.translation_per_reference_node_charge = Some(1);
4333 cfg.translation_per_linkage_entry_charge = Some(10);
4334 cfg.gas_model_version = Some(11);
4335 cfg.feature_flags.abstract_size_in_object_runtime = true;
4336 cfg.feature_flags.object_runtime_charge_cache_load_gas = true;
4337 cfg.dynamic_field_hash_type_and_key_cost_base = Some(52);
4338 cfg.dynamic_field_add_child_object_cost_base = Some(52);
4339 cfg.dynamic_field_add_child_object_value_cost_per_byte = Some(1);
4340 cfg.dynamic_field_borrow_child_object_cost_base = Some(52);
4341 cfg.dynamic_field_borrow_child_object_child_ref_cost_per_byte = Some(1);
4342 cfg.dynamic_field_remove_child_object_cost_base = Some(52);
4343 cfg.dynamic_field_remove_child_object_child_cost_per_byte = Some(1);
4344 cfg.dynamic_field_has_child_object_cost_base = Some(52);
4345 cfg.dynamic_field_has_child_object_with_ty_cost_base = Some(52);
4346 cfg.feature_flags.enable_ptb_execution_v2 = true;
4347
4348 cfg.poseidon_bn254_cost_base = Some(260);
4349
4350 cfg.feature_flags.consensus_skip_gced_accept_votes = true;
4351
4352 if chain != Chain::Mainnet {
4353 cfg.feature_flags
4354 .enable_nitro_attestation_all_nonzero_pcrs_parsing = true;
4355 }
4356
4357 cfg.feature_flags
4358 .include_cancelled_randomness_txns_in_prologue = true;
4359 }
4360 105 => {
4361 cfg.feature_flags.enable_multi_epoch_transaction_expiration = true;
4362 cfg.feature_flags.disable_preconsensus_locking = true;
4363
4364 if chain != Chain::Mainnet {
4365 cfg.feature_flags
4366 .enable_nitro_attestation_always_include_required_pcrs_parsing = true;
4367 }
4368 }
4369 106 => {
4370 cfg.accumulator_object_storage_cost = Some(7600);
4372
4373 if chain != Chain::Mainnet && chain != Chain::Testnet {
4374 cfg.feature_flags.enable_accumulators = true;
4375 cfg.feature_flags.enable_address_balance_gas_payments = true;
4376 cfg.feature_flags.enable_authenticated_event_streams = true;
4377 cfg.feature_flags.enable_object_funds_withdraw = true;
4378 }
4379 }
4380 107 => {
4381 cfg.feature_flags
4382 .consensus_skip_gced_blocks_in_direct_finalization = true;
4383
4384 if in_integration_test() {
4386 cfg.consensus_gc_depth = Some(6);
4387 cfg.consensus_max_num_transactions_in_block = Some(8);
4388 }
4389 }
4390 108 => {
4391 cfg.feature_flags.gas_rounding_halve_digits = true;
4392 cfg.feature_flags.flexible_tx_context_positions = true;
4393 cfg.feature_flags.disable_entry_point_signature_check = true;
4394
4395 if chain != Chain::Mainnet {
4396 cfg.feature_flags.address_aliases = true;
4397
4398 cfg.feature_flags.enable_accumulators = true;
4399 cfg.feature_flags.enable_address_balance_gas_payments = true;
4400 }
4401
4402 cfg.feature_flags.enable_poseidon = true;
4403 }
4404 109 => {
4405 cfg.binary_variant_handles = Some(1024);
4406 cfg.binary_variant_instantiation_handles = Some(1024);
4407 cfg.feature_flags.restrict_hot_or_not_entry_functions = true;
4408 }
4409 110 => {
4410 cfg.feature_flags
4411 .enable_nitro_attestation_all_nonzero_pcrs_parsing = true;
4412 cfg.feature_flags
4413 .enable_nitro_attestation_always_include_required_pcrs_parsing = true;
4414 if chain != Chain::Mainnet && chain != Chain::Testnet {
4415 cfg.feature_flags.split_checkpoints_in_consensus_handler = true;
4416 }
4417 cfg.feature_flags.validate_zklogin_public_identifier = true;
4418 cfg.feature_flags.fix_checkpoint_signature_mapping = true;
4419 cfg.feature_flags
4420 .consensus_always_accept_system_transactions = true;
4421 if chain != Chain::Mainnet {
4422 cfg.feature_flags.enable_object_funds_withdraw = true;
4423 }
4424 }
4425 111 => {
4426 cfg.feature_flags.validator_metadata_verify_v2 = true;
4427 }
4428 112 => {
4429 cfg.group_ops_ristretto_decode_scalar_cost = Some(7);
4430 cfg.group_ops_ristretto_decode_point_cost = Some(200);
4431 cfg.group_ops_ristretto_scalar_add_cost = Some(10);
4432 cfg.group_ops_ristretto_point_add_cost = Some(500);
4433 cfg.group_ops_ristretto_scalar_sub_cost = Some(10);
4434 cfg.group_ops_ristretto_point_sub_cost = Some(500);
4435 cfg.group_ops_ristretto_scalar_mul_cost = Some(11);
4436 cfg.group_ops_ristretto_point_mul_cost = Some(1200);
4437 cfg.group_ops_ristretto_scalar_div_cost = Some(151);
4438 cfg.group_ops_ristretto_point_div_cost = Some(2500);
4439
4440 if chain != Chain::Mainnet && chain != Chain::Testnet {
4441 cfg.feature_flags.enable_ristretto255_group_ops = true;
4442 }
4443 }
4444 113 => {
4445 cfg.feature_flags.address_balance_gas_check_rgp_at_signing = true;
4446 if chain != Chain::Mainnet && chain != Chain::Testnet {
4447 cfg.feature_flags.defer_unpaid_amplification = true;
4448 }
4449 }
4450 114 => {
4451 cfg.feature_flags.randomize_checkpoint_tx_limit_in_tests = true;
4452 cfg.feature_flags.address_balance_gas_reject_gas_coin_arg = true;
4453 if chain != Chain::Mainnet {
4454 cfg.feature_flags.split_checkpoints_in_consensus_handler = true;
4455 cfg.feature_flags.enable_authenticated_event_streams = true;
4456 cfg.feature_flags
4457 .include_checkpoint_artifacts_digest_in_summary = true;
4458 }
4459 }
4460 115 => {
4461 cfg.feature_flags.normalize_depth_formula = true;
4462 }
4463 116 => {
4464 cfg.feature_flags.gasless_transaction_drop_safety = true;
4465 cfg.feature_flags.address_aliases = true;
4466 cfg.feature_flags.relax_valid_during_for_owned_inputs = true;
4467 cfg.feature_flags.defer_unpaid_amplification = false;
4469 cfg.feature_flags.enable_display_registry = true;
4470 }
4471 117 => {}
4472 118 => {
4473 cfg.feature_flags.use_coin_party_owner = true;
4474 }
4475 119 => {
4476 cfg.execution_version = Some(4);
4478 cfg.feature_flags.address_balance_gas_reject_gas_coin_arg = false;
4479 cfg.feature_flags.merge_randomness_into_checkpoint = true;
4480 if chain != Chain::Mainnet {
4481 cfg.feature_flags.enable_gasless = true;
4482 cfg.gasless_max_computation_units = Some(50_000);
4483 cfg.gasless_allowed_token_types = Some(vec![]);
4484 cfg.feature_flags.enable_coin_reservation_obj_refs = true;
4485 cfg.feature_flags
4486 .convert_withdrawal_compatibility_ptb_arguments = true;
4487 }
4488 cfg.gasless_max_unused_inputs = Some(1);
4489 cfg.gasless_max_pure_input_bytes = Some(32);
4490 if chain == Chain::Testnet {
4491 cfg.gasless_allowed_token_types = Some(vec![(TESTNET_USDC.to_string(), 0)]);
4492 }
4493 cfg.transfer_receive_object_cost_per_byte = Some(1);
4494 cfg.transfer_receive_object_type_cost_per_byte = Some(2);
4495 }
4496 120 => {
4497 cfg.feature_flags.disallow_jump_orphans = true;
4498 }
4499 121 => {
4500 if chain != Chain::Mainnet {
4502 cfg.feature_flags.defer_unpaid_amplification = true;
4503 cfg.gasless_max_tps = Some(50);
4504 }
4505 cfg.feature_flags
4506 .early_return_receive_object_mismatched_type = true;
4507 }
4508 122 => {
4509 cfg.feature_flags.defer_unpaid_amplification = true;
4511 cfg.verify_bulletproofs_ristretto255_base_cost = Some(30000);
4513 cfg.verify_bulletproofs_ristretto255_cost_per_bit_and_commitment = Some(6500);
4514 if chain != Chain::Mainnet && chain != Chain::Testnet {
4515 cfg.feature_flags.enable_verify_bulletproofs_ristretto255 = true;
4516 }
4517 cfg.feature_flags.gasless_verify_remaining_balance = true;
4518 cfg.include_special_package_amendments = match chain {
4519 Chain::Mainnet => Some(MAINNET_LINKAGE_AMENDMENTS.clone()),
4520 Chain::Testnet => Some(TESTNET_LINKAGE_AMENDMENTS.clone()),
4521 Chain::Unknown => None,
4522 };
4523 cfg.gasless_max_tx_size_bytes = Some(16 * 1024);
4524 cfg.gasless_max_tps = Some(300);
4525 cfg.gasless_max_computation_units = Some(5_000);
4526 }
4527 123 => {
4528 cfg.gas_model_version = Some(13);
4529 }
4530 124 => {
4531 if chain != Chain::Mainnet && chain != Chain::Testnet {
4532 cfg.feature_flags.timestamp_based_epoch_close = true;
4533 }
4534 cfg.gas_model_version = Some(14);
4535 cfg.feature_flags.limit_groth16_pvk_inputs = true;
4536
4537 cfg.feature_flags.enable_accumulators = true;
4543 cfg.feature_flags.enable_address_balance_gas_payments = true;
4544 cfg.feature_flags.enable_authenticated_event_streams = true;
4545 cfg.feature_flags.enable_coin_reservation_obj_refs = true;
4546 cfg.feature_flags.enable_object_funds_withdraw = true;
4547 cfg.feature_flags
4548 .convert_withdrawal_compatibility_ptb_arguments = true;
4549 cfg.feature_flags.split_checkpoints_in_consensus_handler = true;
4550 cfg.feature_flags
4551 .include_checkpoint_artifacts_digest_in_summary = true;
4552 cfg.feature_flags.enable_gasless = true;
4553
4554 if chain == Chain::Mainnet {
4559 cfg.gasless_allowed_token_types = Some(vec![
4560 (MAINNET_USDC.to_string(), 10_000),
4561 (MAINNET_USDSUI.to_string(), 10_000),
4562 (MAINNET_SUI_USDE.to_string(), 10_000),
4563 (MAINNET_USDY.to_string(), 10_000),
4564 (MAINNET_FDUSD.to_string(), 10_000),
4565 (MAINNET_AUSD.to_string(), 10_000),
4566 (MAINNET_USDB.to_string(), 10_000),
4567 ]);
4568 }
4569 }
4570 125 => {
4571 cfg.feature_flags.granular_post_execution_checks = true;
4572 if chain != Chain::Mainnet {
4573 cfg.feature_flags.timestamp_based_epoch_close = true;
4574 }
4575 }
4576 126 => {
4577 cfg.feature_flags.early_exit_on_iffw = true;
4578 }
4579 127 => {
4580 cfg.feature_flags.always_advance_dkg_to_resolution = true;
4581
4582 cfg.verify_bulletproofs_ristretto255_base_cost = Some(23866);
4583 cfg.verify_bulletproofs_ristretto255_cost_per_bit_and_commitment = Some(1324);
4584 cfg.group_ops_ristretto_decode_scalar_cost = Some(5);
4585 cfg.group_ops_ristretto_decode_point_cost = Some(216);
4586 cfg.group_ops_ristretto_scalar_add_cost = Some(2);
4587 cfg.group_ops_ristretto_point_add_cost = Some(8);
4588 cfg.group_ops_ristretto_scalar_sub_cost = Some(2);
4589 cfg.group_ops_ristretto_point_sub_cost = Some(8);
4590 cfg.group_ops_ristretto_scalar_mul_cost = Some(5);
4591 cfg.group_ops_ristretto_point_mul_cost = Some(1763);
4592 cfg.group_ops_ristretto_scalar_div_cost = Some(557);
4593 cfg.group_ops_ristretto_point_div_cost = Some(2244);
4594
4595 if chain != Chain::Mainnet {
4596 cfg.feature_flags.enable_ristretto255_group_ops = true;
4597 cfg.feature_flags.enable_verify_bulletproofs_ristretto255 = true;
4598 }
4599
4600 cfg.feature_flags.timestamp_based_epoch_close = true;
4601 }
4602 128 => {
4603 cfg.max_generic_instantiation_type_nodes_per_function = Some(10_000);
4604 cfg.max_generic_instantiation_type_nodes_per_module = Some(500_000);
4605 cfg.binary_enum_defs = Some(200);
4606 cfg.binary_enum_def_instantiations = Some(100);
4607 }
4608 129 => {
4609 cfg.feature_flags.enable_unified_linkage = true;
4610 }
4611 130 => {
4612 cfg.feature_flags.record_net_unsettled_object_withdraws = true;
4613 cfg.feature_flags.enable_init_on_upgrade = true;
4614 cfg.epoch_close_deadline_ms = Some(120_000);
4615 cfg.scratch_add_cost_base = Some(13);
4616 cfg.scratch_read_cost_base = Some(13);
4617 cfg.scratch_read_value_cost = Some(1);
4618 cfg.scratch_remove_cost_base = Some(13);
4619 cfg.scratch_exists_cost_base = Some(13);
4620 cfg.scratch_exists_with_type_cost_base = Some(13);
4621 cfg.scratch_exists_with_type_type_cost = Some(1);
4622 let max_commands = cfg.max_programmable_tx_commands() as u64;
4623 cfg.max_scratch_pad_size = Some(16 * max_commands);
4624 if chain != Chain::Mainnet && chain != Chain::Testnet {
4626 cfg.feature_flags.zklogin_circuit_mode = 1;
4627 }
4628 }
4629 131 => {
4630 cfg.feature_flags.share_transaction_deny_config_in_consensus = true;
4631 cfg.feature_flags.framework_tx_context_mut_restrictions = true;
4632 }
4633 132 => {
4634 if chain != Chain::Mainnet && chain != Chain::Testnet {
4635 cfg.feature_flags.defer_owned_object_double_spend = true;
4636 cfg.feature_flags.create_forwarding_address_registry = true;
4637 }
4638 cfg.object_record_new_uid_from_hash_cost_base = Some(1);
4639 cfg.feature_flags
4640 .enable_order_independent_upgrade_init_linkage = true;
4641 }
4642 133 => {
4643 cfg.feature_flags
4644 .include_function_signatures_in_instantiation_limits = true;
4645 cfg.max_accumulator_type_nodes = Some(16);
4646 }
4647 134 => {
4648 if chain != Chain::Mainnet {
4655 cfg.package_original_package_id_impl_cost_base = Some(52);
4656 let package_read_cost_per_byte = cfg.obj_access_cost_read_per_byte();
4657 cfg.package_original_package_id_impl_cost_per_byte =
4658 Some(package_read_cost_per_byte);
4659
4660 cfg.consensus_max_transactions_in_block_bytes = Some(288 * 1024);
4661 cfg.consensus_max_num_transactions_in_block = Some(128);
4662 }
4663
4664 if chain == Chain::Mainnet {
4665 cfg.feature_flags.defer_unpaid_amplification = false;
4666 }
4667 }
4668 135 => {
4669 cfg.package_original_package_id_impl_cost_base = Some(52);
4672 let package_read_cost_per_byte = cfg.obj_access_cost_read_per_byte();
4673 cfg.package_original_package_id_impl_cost_per_byte =
4674 Some(package_read_cost_per_byte);
4675
4676 cfg.consensus_max_transactions_in_block_bytes = Some(288 * 1024);
4677 cfg.consensus_max_num_transactions_in_block = Some(128);
4678
4679 cfg.feature_flags.defer_unpaid_amplification = false;
4680 }
4681 136 => {
4682 cfg.feature_flags.ptb_tx_context_restrictions = true;
4683
4684 cfg.translation_per_live_reference_charge = Some(1);
4685 cfg.max_ptb_live_references = Some(64);
4686 cfg.max_ptb_returned_references = Some(16);
4687 cfg.max_ptb_total_returned_references = Some(256);
4688
4689 if chain != Chain::Mainnet && chain != Chain::Testnet {
4690 cfg.feature_flags.allowed_proposers = true;
4691 }
4692 cfg.feature_flags.harden_linkage_consistency = true;
4693
4694 cfg.package_arena_size_in_bytes = Some(10_000_000);
4695 }
4696 137 => {
4697 cfg.verify_bulletproofs_ristretto255_cost_per_bit_and_commitment = Some(621);
4698 cfg.max_bulletproofs_total_bits = Some(1024);
4699 }
4700 _ => panic!("unsupported version {:?}", version),
4711 }
4712 }
4713
4714 cfg
4715 }
4716
4717 pub fn apply_seeded_test_overrides(&mut self, seed: &[u8; 32]) {
4718 if !self.feature_flags.randomize_checkpoint_tx_limit_in_tests
4719 || !self.feature_flags.split_checkpoints_in_consensus_handler
4720 {
4721 return;
4722 }
4723
4724 if !mysten_common::in_test_configuration() {
4725 return;
4726 }
4727
4728 use rand::{Rng, SeedableRng, rngs::StdRng};
4729 let mut rng = StdRng::from_seed(*seed);
4730 let max_txns = rng.gen_range(10..=100u64);
4731 info!("seeded test override: max_transactions_per_checkpoint = {max_txns}");
4732 self.max_transactions_per_checkpoint = Some(max_txns);
4733 }
4734
4735 pub fn verifier_config(&self, signing_limits: Option<(usize, usize, usize)>) -> VerifierConfig {
4741 let (
4742 max_back_edges_per_function,
4743 max_back_edges_per_module,
4744 sanity_check_with_regex_reference_safety,
4745 ) = if let Some((
4746 max_back_edges_per_function,
4747 max_back_edges_per_module,
4748 sanity_check_with_regex_reference_safety,
4749 )) = signing_limits
4750 {
4751 (
4752 Some(max_back_edges_per_function),
4753 Some(max_back_edges_per_module),
4754 Some(sanity_check_with_regex_reference_safety),
4755 )
4756 } else {
4757 (None, None, None)
4758 };
4759
4760 let additional_borrow_checks = if signing_limits.is_some() {
4761 true
4763 } else {
4764 self.additional_borrow_checks()
4765 };
4766 let deprecate_global_storage_ops = if signing_limits.is_some() {
4767 true
4769 } else {
4770 self.deprecate_global_storage_ops()
4771 };
4772
4773 VerifierConfig {
4774 max_loop_depth: Some(self.max_loop_depth() as usize),
4775 max_generic_instantiation_length: Some(self.max_generic_instantiation_length() as usize),
4776 max_function_parameters: Some(self.max_function_parameters() as usize),
4777 max_basic_blocks: Some(self.max_basic_blocks() as usize),
4778 max_value_stack_size: self.max_value_stack_size() as usize,
4779 max_type_nodes: Some(self.max_type_nodes() as usize),
4780 max_generic_instantiation_type_nodes_per_function: self
4781 .max_generic_instantiation_type_nodes_per_function_as_option()
4782 .map(|v| v as usize),
4783 max_generic_instantiation_type_nodes_per_module: self
4784 .max_generic_instantiation_type_nodes_per_module_as_option()
4785 .map(|v| v as usize),
4786 include_function_signatures_in_instantiation_limits: self
4787 .include_function_signatures_in_instantiation_limits(),
4788 max_push_size: Some(self.max_push_size() as usize),
4789 max_dependency_depth: Some(self.max_dependency_depth() as usize),
4790 max_fields_in_struct: Some(self.max_fields_in_struct() as usize),
4791 max_function_definitions: Some(self.max_function_definitions() as usize),
4792 max_data_definitions: Some(self.max_struct_definitions() as usize),
4793 max_constant_vector_len: Some(self.max_move_vector_len()),
4794 max_back_edges_per_function,
4795 max_back_edges_per_module,
4796 max_basic_blocks_in_script: None,
4797 max_identifier_len: self.max_move_identifier_len_as_option(), disallow_self_identifier: self.feature_flags.disallow_self_identifier,
4799 allow_receiving_object_id: self.allow_receiving_object_id(),
4800 reject_mutable_random_on_entry_functions: self
4801 .reject_mutable_random_on_entry_functions(),
4802 bytecode_version: self.move_binary_format_version(),
4803 max_variants_in_enum: self.max_move_enum_variants_as_option(),
4804 additional_borrow_checks,
4805 better_loader_errors: self.better_loader_errors(),
4806 private_generics_verifier_v2: self.private_generics_verifier_v2(),
4807 sanity_check_with_regex_reference_safety: sanity_check_with_regex_reference_safety
4808 .map(|limit| limit as u128),
4809 deprecate_global_storage_ops,
4810 disable_entry_point_signature_check: self.disable_entry_point_signature_check(),
4811 switch_to_regex_reference_safety: false,
4812 framework_tx_context_mut_restrictions: self.framework_tx_context_mut_restrictions(),
4813 disallow_jump_orphans: self.disallow_jump_orphans(),
4814 }
4815 }
4816
4817 pub fn binary_config(
4818 &self,
4819 override_deprecate_global_storage_ops_during_deserialization: Option<bool>,
4820 ) -> BinaryConfig {
4821 let deprecate_global_storage_ops =
4822 override_deprecate_global_storage_ops_during_deserialization
4823 .unwrap_or_else(|| self.deprecate_global_storage_ops());
4824 BinaryConfig::new(
4825 self.move_binary_format_version(),
4826 self.min_move_binary_format_version_as_option()
4827 .unwrap_or(VERSION_1),
4828 self.no_extraneous_module_bytes(),
4829 deprecate_global_storage_ops,
4830 TableConfig {
4831 module_handles: self.binary_module_handles_as_option().unwrap_or(u16::MAX),
4832 datatype_handles: self.binary_struct_handles_as_option().unwrap_or(u16::MAX),
4833 function_handles: self.binary_function_handles_as_option().unwrap_or(u16::MAX),
4834 function_instantiations: self
4835 .binary_function_instantiations_as_option()
4836 .unwrap_or(u16::MAX),
4837 signatures: self.binary_signatures_as_option().unwrap_or(u16::MAX),
4838 constant_pool: self.binary_constant_pool_as_option().unwrap_or(u16::MAX),
4839 identifiers: self.binary_identifiers_as_option().unwrap_or(u16::MAX),
4840 address_identifiers: self
4841 .binary_address_identifiers_as_option()
4842 .unwrap_or(u16::MAX),
4843 struct_defs: self.binary_struct_defs_as_option().unwrap_or(u16::MAX),
4844 struct_def_instantiations: self
4845 .binary_struct_def_instantiations_as_option()
4846 .unwrap_or(u16::MAX),
4847 function_defs: self.binary_function_defs_as_option().unwrap_or(u16::MAX),
4848 field_handles: self.binary_field_handles_as_option().unwrap_or(u16::MAX),
4849 field_instantiations: self
4850 .binary_field_instantiations_as_option()
4851 .unwrap_or(u16::MAX),
4852 friend_decls: self.binary_friend_decls_as_option().unwrap_or(u16::MAX),
4853 enum_defs: self.binary_enum_defs_as_option().unwrap_or(u16::MAX),
4854 enum_def_instantiations: self
4855 .binary_enum_def_instantiations_as_option()
4856 .unwrap_or(u16::MAX),
4857 variant_handles: self.binary_variant_handles_as_option().unwrap_or(u16::MAX),
4858 variant_instantiation_handles: self
4859 .binary_variant_instantiation_handles_as_option()
4860 .unwrap_or(u16::MAX),
4861 },
4862 )
4863 }
4864
4865 pub fn apply_overrides_for_testing(
4869 override_fn: impl Fn(ProtocolVersion, Self) -> Self + Send + Sync + 'static,
4870 ) -> OverrideGuard {
4871 let mut cur = CONFIG_OVERRIDE.lock().unwrap();
4872 assert!(cur.is_none(), "config override already present");
4873 *cur = Some(Box::new(override_fn));
4874 OverrideGuard
4875 }
4876
4877 fn apply_config_override(version: ProtocolVersion, mut ret: Self) -> Self {
4878 if let Some(override_fn) = CONFIG_OVERRIDE.lock().unwrap().as_ref() {
4879 warn!(
4880 "overriding ProtocolConfig settings with custom settings (you should not see this log outside of tests)"
4881 );
4882 ret = override_fn(version, ret);
4883 }
4884 ret
4885 }
4886}
4887
4888impl ProtocolConfig {
4892 pub fn set_execution_version_for_testing(&mut self, val: u64) {
4896 let current = self.execution_version.unwrap_or(0);
4897 assert!(
4898 val >= current,
4899 "cannot downgrade execution_version from {current} to {val}: running an old \
4900 executor against a newer protocol config/framework is unsupported. To test \
4901 frozen executor behavior, start from the last protocol version of that executor \
4902 instead, so genesis loads the matching framework snapshot (see \
4903 test_address_balance_gas_v3_accumulator_sign)."
4904 );
4905 self.execution_version = Some(val);
4906 }
4907
4908 pub fn set_zklogin_circuit_mode_for_testing(&mut self, val: u64) {
4911 self.feature_flags.zklogin_circuit_mode = val
4912 }
4913
4914 pub fn set_per_object_congestion_control_mode_for_testing(
4915 &mut self,
4916 val: PerObjectCongestionControlMode,
4917 ) {
4918 self.feature_flags.per_object_congestion_control_mode = val;
4919 }
4920
4921 pub fn set_consensus_choice_for_testing(&mut self, val: ConsensusChoice) {
4922 self.feature_flags.consensus_choice = val;
4923 }
4924
4925 pub fn set_consensus_network_for_testing(&mut self, val: ConsensusNetwork) {
4926 self.feature_flags.consensus_network = val;
4927 }
4928
4929 pub fn set_zklogin_max_epoch_upper_bound_delta_for_testing(&mut self, val: Option<u64>) {
4930 self.feature_flags.zklogin_max_epoch_upper_bound_delta = val
4931 }
4932
4933 pub fn set_mysticeti_num_leaders_per_round_for_testing(&mut self, val: Option<usize>) {
4934 self.feature_flags.mysticeti_num_leaders_per_round = val;
4935 }
4936
4937 pub fn disable_accumulators_for_testing(&mut self) {
4938 self.feature_flags.enable_accumulators = false;
4939 self.feature_flags.enable_address_balance_gas_payments = false;
4940 }
4941
4942 pub fn enable_coin_reservation_for_testing(&mut self) {
4943 self.feature_flags.enable_coin_reservation_obj_refs = true;
4944 self.feature_flags
4945 .convert_withdrawal_compatibility_ptb_arguments = true;
4946 self.execution_version = Some(self.execution_version.map_or(4, |v| v.max(4)));
4949 }
4950
4951 pub fn disable_coin_reservation_for_testing(&mut self) {
4952 self.feature_flags.enable_coin_reservation_obj_refs = false;
4953 self.feature_flags
4954 .convert_withdrawal_compatibility_ptb_arguments = false;
4955 }
4956
4957 pub fn enable_address_balance_gas_payments_for_testing(&mut self) {
4958 self.feature_flags.enable_accumulators = true;
4959 self.feature_flags.allow_private_accumulator_entrypoints = true;
4960 self.feature_flags.enable_address_balance_gas_payments = true;
4961 self.feature_flags.address_balance_gas_check_rgp_at_signing = true;
4962 self.feature_flags.address_balance_gas_reject_gas_coin_arg = false;
4963 self.execution_version = Some(self.execution_version.map_or(4, |v| v.max(4)))
4964 }
4965
4966 pub fn enable_gasless_for_testing(&mut self) {
4967 self.enable_address_balance_gas_payments_for_testing();
4968 self.feature_flags.enable_gasless = true;
4969 self.feature_flags.gasless_verify_remaining_balance = true;
4970 self.gasless_max_computation_units = Some(5_000);
4971 self.gasless_allowed_token_types = Some(vec![]);
4972 self.gasless_max_tps = Some(1000);
4973 self.gasless_max_tx_size_bytes = Some(16 * 1024);
4974 }
4975
4976 pub fn disable_gasless_for_testing(&mut self) {
4977 self.feature_flags.enable_gasless = false;
4978 self.gasless_max_computation_units = None;
4979 self.gasless_allowed_token_types = None;
4980 }
4981
4982 pub fn enable_authenticated_event_streams_for_testing(&mut self) {
4983 self.feature_flags.enable_accumulators = true;
4984 self.feature_flags.enable_authenticated_event_streams = true;
4985 self.feature_flags
4986 .include_checkpoint_artifacts_digest_in_summary = true;
4987 self.feature_flags.split_checkpoints_in_consensus_handler = true;
4988 }
4989}
4990
4991type OverrideFn = dyn Fn(ProtocolVersion, ProtocolConfig) -> ProtocolConfig + Send + Sync;
4992
4993static CONFIG_OVERRIDE: Mutex<Option<Box<OverrideFn>>> = Mutex::new(None);
4994
4995#[must_use]
4996pub struct OverrideGuard;
4997
4998impl Drop for OverrideGuard {
4999 fn drop(&mut self) {
5000 info!("restoring override fn");
5001 *CONFIG_OVERRIDE.lock().unwrap() = None;
5002 }
5003}
5004
5005#[derive(PartialEq, Eq)]
5008pub enum LimitThresholdCrossed {
5009 None,
5010 Soft(u128, u128),
5011 Hard(u128, u128),
5012}
5013
5014pub fn check_limit_in_range<T: Into<V>, U: Into<V>, V: PartialOrd + Into<u128>>(
5017 x: T,
5018 soft_limit: U,
5019 hard_limit: V,
5020) -> LimitThresholdCrossed {
5021 let x: V = x.into();
5022 let soft_limit: V = soft_limit.into();
5023
5024 debug_assert!(soft_limit <= hard_limit);
5025
5026 if x >= hard_limit {
5029 LimitThresholdCrossed::Hard(x.into(), hard_limit.into())
5030 } else if x < soft_limit {
5031 LimitThresholdCrossed::None
5032 } else {
5033 LimitThresholdCrossed::Soft(x.into(), soft_limit.into())
5034 }
5035}
5036
5037#[macro_export]
5038macro_rules! check_limit {
5039 ($x:expr, $hard:expr) => {
5040 check_limit!($x, $hard, $hard)
5041 };
5042 ($x:expr, $soft:expr, $hard:expr) => {
5043 check_limit_in_range($x as u64, $soft, $hard)
5044 };
5045}
5046
5047#[macro_export]
5051macro_rules! check_limit_by_meter {
5052 ($is_metered:expr, $x:expr, $metered_limit:expr, $unmetered_hard_limit:expr, $metric:expr) => {{
5053 let (h, metered_str) = if $is_metered {
5055 ($metered_limit, "metered")
5056 } else {
5057 ($unmetered_hard_limit, "unmetered")
5059 };
5060 use sui_protocol_config::check_limit_in_range;
5061 let result = check_limit_in_range($x as u64, $metered_limit, h);
5062 match result {
5063 LimitThresholdCrossed::None => {}
5064 LimitThresholdCrossed::Soft(_, _) => {
5065 $metric.with_label_values(&[metered_str, "soft"]).inc();
5066 }
5067 LimitThresholdCrossed::Hard(_, _) => {
5068 $metric.with_label_values(&[metered_str, "hard"]).inc();
5069 }
5070 };
5071 result
5072 }};
5073}
5074
5075pub type Amendments = BTreeMap<AccountAddress, BTreeMap<AccountAddress, AccountAddress>>;
5078
5079static MAINNET_LINKAGE_AMENDMENTS: LazyLock<Arc<Amendments>> =
5080 LazyLock::new(|| parse_amendments(include_str!("mainnet_amendments.json")));
5081
5082static TESTNET_LINKAGE_AMENDMENTS: LazyLock<Arc<Amendments>> =
5083 LazyLock::new(|| parse_amendments(include_str!("testnet_amendments.json")));
5084
5085fn parse_amendments(json: &str) -> Arc<Amendments> {
5086 #[derive(serde::Deserialize)]
5087 struct AmendmentEntry {
5088 root: String,
5089 deps: Vec<DepEntry>,
5090 }
5091
5092 #[derive(serde::Deserialize)]
5093 struct DepEntry {
5094 original_id: String,
5095 version_id: String,
5096 }
5097
5098 let entries: Vec<AmendmentEntry> =
5099 serde_json::from_str(json).expect("Failed to parse amendments JSON");
5100 let mut amendments = BTreeMap::new();
5101 for entry in entries {
5102 let root_id = AccountAddress::from_hex_literal(&entry.root).unwrap();
5103 let mut dep_ids = BTreeMap::new();
5104 for dep in entry.deps {
5105 let orig_id = AccountAddress::from_hex_literal(&dep.original_id).unwrap();
5106 let upgraded_id = AccountAddress::from_hex_literal(&dep.version_id).unwrap();
5107 assert!(
5108 dep_ids.insert(orig_id, upgraded_id).is_none(),
5109 "Duplicate original ID in amendments table"
5110 );
5111 }
5112 assert!(
5113 amendments.insert(root_id, dep_ids).is_none(),
5114 "Duplicate root ID in amendments table"
5115 );
5116 }
5117 Arc::new(amendments)
5118}
5119
5120#[cfg(all(test, not(msim)))]
5121mod test {
5122 use insta::assert_yaml_snapshot;
5123
5124 use super::*;
5125
5126 #[test]
5127 fn snapshot_tests() {
5128 println!("\n============================================================================");
5129 println!("! !");
5130 println!("! IMPORTANT: never update snapshots from this test. only add new versions! !");
5131 println!("! !");
5132 println!("============================================================================\n");
5133 for chain_id in &[Chain::Unknown, Chain::Mainnet, Chain::Testnet] {
5134 let chain_str = match chain_id {
5138 Chain::Unknown => "".to_string(),
5139 _ => format!("{:?}_", chain_id),
5140 };
5141 for i in MIN_PROTOCOL_VERSION..=MAX_PROTOCOL_VERSION {
5142 let cur = ProtocolVersion::new(i);
5143 assert_yaml_snapshot!(
5144 format!("{}version_{}", chain_str, cur.as_u64()),
5145 ProtocolConfig::get_for_version(cur, *chain_id)
5146 );
5147 }
5148 }
5149 }
5150
5151 #[test]
5152 fn test_getters() {
5153 let prot: ProtocolConfig =
5154 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5155 assert_eq!(
5156 prot.max_arguments(),
5157 prot.max_arguments_as_option().unwrap()
5158 );
5159 }
5160
5161 #[test]
5162 fn test_setters() {
5163 let mut prot: ProtocolConfig =
5164 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5165 prot.set_max_arguments_for_testing(123);
5166 assert_eq!(prot.max_arguments(), 123);
5167
5168 prot.set_max_arguments_from_str_for_testing("321".to_string());
5169 assert_eq!(prot.max_arguments(), 321);
5170
5171 prot.disable_max_arguments_for_testing();
5172 assert_eq!(prot.max_arguments_as_option(), None);
5173
5174 prot.set_attr_for_testing("max_arguments".to_string(), "456".to_string());
5175 assert_eq!(prot.max_arguments(), 456);
5176 }
5177
5178 #[test]
5179 fn test_execution_version_setter_allows_upgrade() {
5180 let mut prot = ProtocolConfig::get_for_max_version_UNSAFE();
5181 let current = prot.execution_version();
5182 prot.set_execution_version_for_testing(current);
5183 prot.set_execution_version_for_testing(current + 1);
5184 assert_eq!(prot.execution_version(), current + 1);
5185 }
5186
5187 #[test]
5188 #[should_panic(expected = "cannot downgrade execution_version")]
5189 fn test_execution_version_setter_panics_on_downgrade() {
5190 let mut prot = ProtocolConfig::get_for_max_version_UNSAFE();
5191 let current = prot.execution_version();
5192 prot.set_execution_version_for_testing(current - 1);
5193 }
5194
5195 #[test]
5196 fn test_feature_flag_setter_by_string() {
5197 let mut prot: ProtocolConfig =
5198 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5199 assert!(!prot.zklogin_auth());
5200 prot.set_feature_flag_for_testing("zklogin_auth".to_string(), true);
5201 assert!(prot.zklogin_auth());
5202 prot.set_feature_flag_for_testing("zklogin_auth".to_string(), false);
5203 assert!(!prot.zklogin_auth());
5204 }
5205
5206 #[test]
5207 #[should_panic(expected = "unknown feature flag")]
5208 fn test_feature_flag_setter_unknown_flag() {
5209 let mut prot: ProtocolConfig =
5210 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5211 prot.set_feature_flag_for_testing("some random string".to_string(), true);
5212 }
5213
5214 #[test]
5215 fn test_get_for_version_if_supported_applies_test_overrides() {
5216 let before =
5217 ProtocolConfig::get_for_version_if_supported(ProtocolVersion::new(1), Chain::Unknown)
5218 .unwrap();
5219
5220 assert!(!before.enable_coin_reservation_obj_refs());
5221
5222 let _guard = ProtocolConfig::apply_overrides_for_testing(|_, mut cfg| {
5223 cfg.enable_coin_reservation_for_testing();
5224 cfg
5225 });
5226
5227 let after =
5228 ProtocolConfig::get_for_version_if_supported(ProtocolVersion::new(1), Chain::Unknown)
5229 .unwrap();
5230
5231 assert!(after.enable_coin_reservation_obj_refs());
5232 }
5233
5234 #[test]
5235 #[should_panic(expected = "unsupported version")]
5236 fn max_version_test() {
5237 let _ = ProtocolConfig::get_for_version_impl(
5240 ProtocolVersion::new(MAX_PROTOCOL_VERSION + 1),
5241 Chain::Unknown,
5242 );
5243 }
5244
5245 #[test]
5246 fn lookup_by_string_test() {
5247 let prot: ProtocolConfig =
5248 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5249 assert!(prot.lookup_attr("some random string".to_string()).is_none());
5251
5252 assert!(
5253 prot.lookup_attr("max_arguments".to_string())
5254 == Some(ProtocolConfigValue::u32(prot.max_arguments())),
5255 );
5256
5257 assert!(
5259 prot.lookup_attr("max_move_identifier_len".to_string())
5260 .is_none()
5261 );
5262
5263 let prot: ProtocolConfig =
5265 ProtocolConfig::get_for_version(ProtocolVersion::new(9), Chain::Unknown);
5266 assert!(
5267 prot.lookup_attr("max_move_identifier_len".to_string())
5268 == Some(ProtocolConfigValue::u64(prot.max_move_identifier_len()))
5269 );
5270
5271 let prot: ProtocolConfig =
5272 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5273 assert!(
5275 prot.attr_map()
5276 .get("max_move_identifier_len")
5277 .unwrap()
5278 .is_none()
5279 );
5280 assert!(
5282 prot.attr_map().get("max_arguments").unwrap()
5283 == &Some(ProtocolConfigValue::u32(prot.max_arguments()))
5284 );
5285
5286 let prot: ProtocolConfig =
5288 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5289 assert!(
5291 prot.feature_flags
5292 .lookup_attr("some random string".to_owned())
5293 .is_none()
5294 );
5295 assert!(
5296 !prot
5297 .feature_flags
5298 .attr_map()
5299 .contains_key("some random string")
5300 );
5301
5302 assert!(
5304 prot.feature_flags
5305 .lookup_attr("package_upgrades".to_owned())
5306 == Some(false)
5307 );
5308 assert!(
5309 prot.feature_flags
5310 .attr_map()
5311 .get("package_upgrades")
5312 .unwrap()
5313 == &false
5314 );
5315 let prot: ProtocolConfig =
5316 ProtocolConfig::get_for_version(ProtocolVersion::new(4), Chain::Unknown);
5317 assert!(
5319 prot.feature_flags
5320 .lookup_attr("package_upgrades".to_owned())
5321 == Some(true)
5322 );
5323 assert!(
5324 prot.feature_flags
5325 .attr_map()
5326 .get("package_upgrades")
5327 .unwrap()
5328 == &true
5329 );
5330 }
5331
5332 #[test]
5333 fn limit_range_fn_test() {
5334 let low = 100u32;
5335 let high = 10000u64;
5336
5337 assert!(check_limit!(1u8, low, high) == LimitThresholdCrossed::None);
5338 assert!(matches!(
5339 check_limit!(255u16, low, high),
5340 LimitThresholdCrossed::Soft(255u128, 100)
5341 ));
5342 assert!(matches!(
5348 check_limit!(2550000u64, low, high),
5349 LimitThresholdCrossed::Hard(2550000, 10000)
5350 ));
5351
5352 assert!(matches!(
5353 check_limit!(2550000u64, high, high),
5354 LimitThresholdCrossed::Hard(2550000, 10000)
5355 ));
5356
5357 assert!(matches!(
5358 check_limit!(1u8, high),
5359 LimitThresholdCrossed::None
5360 ));
5361
5362 assert!(check_limit!(255u16, high) == LimitThresholdCrossed::None);
5363
5364 assert!(matches!(
5365 check_limit!(2550000u64, high),
5366 LimitThresholdCrossed::Hard(2550000, 10000)
5367 ));
5368 }
5369
5370 #[test]
5371 fn linkage_amendments_load() {
5372 let mainnet = LazyLock::force(&MAINNET_LINKAGE_AMENDMENTS);
5373 let testnet = LazyLock::force(&TESTNET_LINKAGE_AMENDMENTS);
5374 assert!(!mainnet.is_empty(), "mainnet amendments must not be empty");
5375 assert!(!testnet.is_empty(), "testnet amendments must not be empty");
5376 }
5377
5378 #[test]
5379 fn render_scalar_fields_use_precision_safe_encoding() {
5380 use mysten_common::rpc_format::Unmetered;
5381
5382 let config = ProtocolConfig::get_for_max_version_UNSAFE();
5383 let rendered = config
5384 .render::<serde_json::Value>(&mut Unmetered)
5385 .expect("render should succeed");
5386
5387 let max_args = rendered
5388 .get("max_arguments")
5389 .expect("max_arguments set at max version");
5390 assert!(
5391 max_args.is_number(),
5392 "u32 should render as number, got {max_args:?}",
5393 );
5394
5395 let max_tx_size = rendered
5396 .get("max_tx_size_bytes")
5397 .expect("max_tx_size_bytes set at max version");
5398 assert!(
5399 max_tx_size.is_string(),
5400 "u64 should render as string, got {max_tx_size:?}",
5401 );
5402 }
5403
5404 #[test]
5405 fn render_includes_non_scalar_gasless_allowlist_as_json() {
5406 use mysten_common::rpc_format::Unmetered;
5407 use serde_json::json;
5408
5409 let mut config = ProtocolConfig::get_for_max_version_UNSAFE();
5410 config.set_gasless_allowed_token_types_for_testing(vec![
5411 ("0xa::usdc::USDC".to_string(), 10_000),
5412 ("0xb::usdt::USDT".to_string(), 0),
5413 ]);
5414
5415 let rendered = config
5416 .render::<serde_json::Value>(&mut Unmetered)
5417 .expect("render should succeed under Unmetered budget");
5418 let allowlist = rendered
5419 .get("gasless_allowed_token_types")
5420 .expect("entry should be present after the testing setter");
5421
5422 assert_eq!(
5425 allowlist,
5426 &json!([["0xa::usdc::USDC", "10000"], ["0xb::usdt::USDT", "0"],]),
5427 );
5428 }
5429
5430 #[test]
5431 fn render_targets_prost_value_for_grpc() {
5432 use mysten_common::rpc_format::Unmetered;
5433 use prost_types::value::Kind;
5434
5435 let mut config = ProtocolConfig::get_for_max_version_UNSAFE();
5436 config.set_gasless_allowed_token_types_for_testing(vec![(
5437 "0xa::usdc::USDC".to_string(),
5438 10_000,
5439 )]);
5440
5441 let rendered = config
5442 .render::<prost_types::Value>(&mut Unmetered)
5443 .expect("render to prost Value should succeed");
5444 let allowlist = rendered
5445 .get("gasless_allowed_token_types")
5446 .expect("entry should be present after the testing setter");
5447
5448 let Some(Kind::ListValue(outer)) = &allowlist.kind else {
5450 panic!(
5451 "expected ListValue at the top level, got {:?}",
5452 allowlist.kind
5453 );
5454 };
5455 assert_eq!(outer.values.len(), 1, "one allowlisted entry");
5456 let Some(Kind::ListValue(entry)) = &outer.values[0].kind else {
5457 panic!("expected each entry to be a ListValue");
5458 };
5459 assert_eq!(entry.values.len(), 2, "entry has (coin_type, amount)");
5460
5461 let Some(Kind::StringValue(coin_type)) = &entry.values[0].kind else {
5462 panic!("expected coin_type as StringValue");
5463 };
5464 assert_eq!(coin_type, "0xa::usdc::USDC");
5465
5466 let Some(Kind::StringValue(amount)) = &entry.values[1].kind else {
5468 panic!(
5469 "expected minimum_transfer_amount as StringValue (precision-safe u64); got {:?}",
5470 entry.values[1].kind,
5471 );
5472 };
5473 assert_eq!(amount, "10000");
5474 }
5475
5476 #[test]
5477 fn render_emits_null_for_unset_protocol_versions() {
5478 use mysten_common::rpc_format::Unmetered;
5479
5480 let config = ProtocolConfig::get_for_version(1.into(), Chain::Unknown);
5481 let rendered = config
5482 .render::<serde_json::Value>(&mut Unmetered)
5483 .expect("render should succeed");
5484 let entry = rendered
5488 .get("gasless_allowed_token_types")
5489 .expect("key should be present for every protocol version");
5490 assert!(
5491 entry.is_null(),
5492 "value should be null for pre-feature protocol version, got {entry:?}",
5493 );
5494 }
5495}