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 = 135;
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)]
383pub struct ProtocolVersion(u64);
384
385impl ProtocolVersion {
386 pub const MIN: Self = Self(MIN_PROTOCOL_VERSION);
391
392 pub const MAX: Self = Self(MAX_PROTOCOL_VERSION);
393
394 #[cfg(not(msim))]
395 pub const MAX_ALLOWED: Self = Self::MAX;
396
397 #[cfg(msim)]
399 pub const MAX_ALLOWED: Self = Self(MAX_PROTOCOL_VERSION + 1);
400
401 pub fn new(v: u64) -> Self {
402 Self(v)
403 }
404
405 pub const fn as_u64(&self) -> u64 {
406 self.0
407 }
408
409 pub fn max() -> Self {
412 Self::MAX
413 }
414
415 pub fn prev(self) -> Self {
416 Self(self.0.checked_sub(1).unwrap())
417 }
418}
419
420impl From<u64> for ProtocolVersion {
421 fn from(v: u64) -> Self {
422 Self::new(v)
423 }
424}
425
426impl std::ops::Sub<u64> for ProtocolVersion {
427 type Output = Self;
428 fn sub(self, rhs: u64) -> Self::Output {
429 Self::new(self.0 - rhs)
430 }
431}
432
433impl std::ops::Add<u64> for ProtocolVersion {
434 type Output = Self;
435 fn add(self, rhs: u64) -> Self::Output {
436 Self::new(self.0 + rhs)
437 }
438}
439
440#[derive(
441 Clone, Serialize, Deserialize, Debug, Default, PartialEq, Copy, PartialOrd, Ord, Eq, ValueEnum,
442)]
443pub enum Chain {
444 Mainnet,
445 Testnet,
446 #[default]
447 Unknown,
448}
449
450impl Chain {
451 pub fn as_str(self) -> &'static str {
452 match self {
453 Chain::Mainnet => "mainnet",
454 Chain::Testnet => "testnet",
455 Chain::Unknown => "unknown",
456 }
457 }
458}
459
460pub struct Error(pub String);
461
462#[derive(Default, Clone, Serialize, Deserialize, Debug, ProtocolConfigFeatureFlagsGetters)]
465struct FeatureFlags {
466 #[serde(skip_serializing_if = "is_false")]
469 package_upgrades: bool,
470 #[serde(skip_serializing_if = "is_false")]
473 commit_root_state_digest: bool,
474 #[serde(skip_serializing_if = "is_false")]
476 advance_epoch_start_time_in_safe_mode: bool,
477 #[serde(skip_serializing_if = "is_false")]
480 loaded_child_objects_fixed: bool,
481 #[serde(skip_serializing_if = "is_false")]
484 missing_type_is_compatibility_error: bool,
485 #[serde(skip_serializing_if = "is_false")]
488 scoring_decision_with_validity_cutoff: bool,
489
490 #[serde(skip_serializing_if = "is_false")]
493 consensus_order_end_of_epoch_last: bool,
494
495 #[serde(skip_serializing_if = "is_false")]
497 disallow_adding_abilities_on_upgrade: bool,
498 #[serde(skip_serializing_if = "is_false")]
500 disable_invariant_violation_check_in_swap_loc: bool,
501 #[serde(skip_serializing_if = "is_false")]
504 advance_to_highest_supported_protocol_version: bool,
505 #[serde(skip_serializing_if = "is_false")]
507 ban_entry_init: bool,
508 #[serde(skip_serializing_if = "is_false")]
510 package_digest_hash_module: bool,
511 #[serde(skip_serializing_if = "is_false")]
513 disallow_change_struct_type_params_on_upgrade: bool,
514 #[serde(skip_serializing_if = "is_false")]
516 no_extraneous_module_bytes: bool,
517 #[serde(skip_serializing_if = "is_false")]
519 narwhal_versioned_metadata: bool,
520
521 #[serde(skip_serializing_if = "is_false")]
523 zklogin_auth: bool,
524 #[serde(skip_serializing_if = "is_zero")]
527 zklogin_circuit_mode: u64,
528 #[serde(skip_serializing_if = "ConsensusTransactionOrdering::is_none")]
530 consensus_transaction_ordering: ConsensusTransactionOrdering,
531
532 #[serde(skip_serializing_if = "is_false")]
540 simplified_unwrap_then_delete: bool,
541 #[serde(skip_serializing_if = "is_false")]
543 upgraded_multisig_supported: bool,
544 #[serde(skip_serializing_if = "is_false")]
546 txn_base_cost_as_multiplier: bool,
547
548 #[serde(skip_serializing_if = "is_false")]
550 shared_object_deletion: bool,
551
552 #[serde(skip_serializing_if = "is_false")]
554 narwhal_new_leader_election_schedule: bool,
555
556 #[serde(skip_serializing_if = "is_empty")]
558 zklogin_supported_providers: BTreeSet<String>,
559
560 #[serde(skip_serializing_if = "is_false")]
562 loaded_child_object_format: bool,
563
564 #[serde(skip_serializing_if = "is_false")]
565 #[skip_protocol_config_accessor]
566 enable_jwk_consensus_updates: bool,
567
568 #[serde(skip_serializing_if = "is_false")]
569 #[skip_protocol_config_accessor]
570 end_of_epoch_transaction_supported: bool,
571
572 #[serde(skip_serializing_if = "is_false")]
575 simple_conservation_checks: bool,
576
577 #[serde(skip_serializing_if = "is_false")]
579 loaded_child_object_format_type: bool,
580
581 #[serde(skip_serializing_if = "is_false")]
583 receive_objects: bool,
584
585 #[serde(skip_serializing_if = "is_false")]
587 consensus_checkpoint_signature_key_includes_digest: bool,
588
589 #[serde(skip_serializing_if = "is_false")]
591 random_beacon: bool,
592
593 #[serde(skip_serializing_if = "is_false")]
595 #[skip_protocol_config_accessor]
596 bridge: bool,
597
598 #[serde(skip_serializing_if = "is_false")]
599 enable_effects_v2: bool,
600
601 #[serde(skip_serializing_if = "is_false")]
603 narwhal_certificate_v2: bool,
604
605 #[serde(skip_serializing_if = "is_false")]
607 verify_legacy_zklogin_address: bool,
608
609 #[serde(skip_serializing_if = "is_false")]
611 throughput_aware_consensus_submission: bool,
612
613 #[serde(skip_serializing_if = "is_false")]
615 recompute_has_public_transfer_in_execution: bool,
616
617 #[serde(skip_serializing_if = "is_false")]
619 accept_zklogin_in_multisig: bool,
620
621 #[serde(skip_serializing_if = "is_false")]
623 accept_passkey_in_multisig: bool,
624
625 #[serde(skip_serializing_if = "is_false")]
627 validate_zklogin_public_identifier: bool,
628
629 #[serde(skip_serializing_if = "is_false")]
632 include_consensus_digest_in_prologue: bool,
633
634 #[serde(skip_serializing_if = "is_false")]
636 hardened_otw_check: bool,
637
638 #[serde(skip_serializing_if = "is_false")]
640 allow_receiving_object_id: bool,
641
642 #[serde(skip_serializing_if = "is_false")]
644 enable_poseidon: bool,
645
646 #[serde(skip_serializing_if = "is_false")]
648 enable_coin_deny_list: bool,
649
650 #[serde(skip_serializing_if = "is_false")]
652 enable_group_ops_native_functions: bool,
653
654 #[serde(skip_serializing_if = "is_false")]
656 enable_group_ops_native_function_msm: bool,
657
658 #[serde(skip_serializing_if = "is_false")]
660 enable_ristretto255_group_ops: bool,
661
662 #[serde(skip_serializing_if = "is_false")]
664 enable_verify_bulletproofs_ristretto255: bool,
665
666 #[serde(skip_serializing_if = "is_false")]
668 enable_nitro_attestation: bool,
669
670 #[serde(skip_serializing_if = "is_false")]
672 enable_nitro_attestation_upgraded_parsing: bool,
673
674 #[serde(skip_serializing_if = "is_false")]
676 enable_nitro_attestation_all_nonzero_pcrs_parsing: bool,
677
678 #[serde(skip_serializing_if = "is_false")]
680 enable_nitro_attestation_always_include_required_pcrs_parsing: bool,
681
682 #[serde(skip_serializing_if = "is_false")]
684 reject_mutable_random_on_entry_functions: bool,
685
686 #[serde(skip_serializing_if = "PerObjectCongestionControlMode::is_none")]
688 per_object_congestion_control_mode: PerObjectCongestionControlMode,
689
690 #[serde(skip_serializing_if = "ConsensusChoice::is_narwhal")]
692 consensus_choice: ConsensusChoice,
693
694 #[serde(skip_serializing_if = "ConsensusNetwork::is_anemo")]
696 consensus_network: ConsensusNetwork,
697
698 #[serde(skip_serializing_if = "is_false")]
700 correct_gas_payment_limit_check: bool,
701
702 #[serde(skip_serializing_if = "Option::is_none")]
704 zklogin_max_epoch_upper_bound_delta: Option<u64>,
705
706 #[serde(skip_serializing_if = "is_false")]
708 mysticeti_leader_scoring_and_schedule: bool,
709
710 #[serde(skip_serializing_if = "is_false")]
712 reshare_at_same_initial_version: bool,
713
714 #[serde(skip_serializing_if = "is_false")]
716 resolve_abort_locations_to_package_id: bool,
717
718 #[serde(skip_serializing_if = "is_false")]
722 mysticeti_use_committed_subdag_digest: bool,
723
724 #[serde(skip_serializing_if = "is_false")]
726 enable_vdf: bool,
727
728 #[serde(skip_serializing_if = "is_false")]
732 record_consensus_determined_version_assignments_in_prologue: bool,
733 #[serde(skip_serializing_if = "is_false")]
736 record_consensus_determined_version_assignments_in_prologue_v2: bool,
737
738 #[serde(skip_serializing_if = "is_false")]
740 fresh_vm_on_framework_upgrade: bool,
741
742 #[serde(skip_serializing_if = "is_false")]
750 prepend_prologue_tx_in_consensus_commit_in_checkpoints: bool,
751
752 #[serde(skip_serializing_if = "Option::is_none")]
754 mysticeti_num_leaders_per_round: Option<usize>,
755
756 #[serde(skip_serializing_if = "is_false")]
758 soft_bundle: bool,
759
760 #[serde(skip_serializing_if = "is_false")]
762 enable_coin_deny_list_v2: bool,
763
764 #[serde(skip_serializing_if = "is_false")]
766 passkey_auth: bool,
767
768 #[serde(skip_serializing_if = "is_false")]
770 authority_capabilities_v2: bool,
771
772 #[serde(skip_serializing_if = "is_false")]
774 rethrow_serialization_type_layout_errors: bool,
775
776 #[serde(skip_serializing_if = "is_false")]
778 consensus_distributed_vote_scoring_strategy: bool,
779
780 #[serde(skip_serializing_if = "is_false")]
782 consensus_round_prober: bool,
783
784 #[serde(skip_serializing_if = "is_false")]
786 validate_identifier_inputs: bool,
787
788 #[serde(skip_serializing_if = "is_false")]
790 disallow_self_identifier: bool,
791
792 #[serde(skip_serializing_if = "is_false")]
794 mysticeti_fastpath: bool,
795
796 #[serde(skip_serializing_if = "is_false")]
800 disable_preconsensus_locking: bool,
801
802 #[serde(skip_serializing_if = "is_false")]
804 relocate_event_module: bool,
805
806 #[serde(skip_serializing_if = "is_false")]
808 uncompressed_g1_group_elements: bool,
809
810 #[serde(skip_serializing_if = "is_false")]
811 disallow_new_modules_in_deps_only_packages: bool,
812
813 #[serde(skip_serializing_if = "is_false")]
815 consensus_smart_ancestor_selection: bool,
816
817 #[serde(skip_serializing_if = "is_false")]
819 consensus_round_prober_probe_accepted_rounds: bool,
820
821 #[serde(skip_serializing_if = "is_false")]
823 native_charging_v2: bool,
824
825 #[serde(skip_serializing_if = "is_false")]
828 #[skip_protocol_config_accessor]
829 consensus_linearize_subdag_v2: bool,
830
831 #[serde(skip_serializing_if = "is_false")]
833 convert_type_argument_error: bool,
834
835 #[serde(skip_serializing_if = "is_false")]
837 variant_nodes: bool,
838
839 #[serde(skip_serializing_if = "is_false")]
841 consensus_zstd_compression: bool,
842
843 #[serde(skip_serializing_if = "is_false")]
845 minimize_child_object_mutations: bool,
846
847 #[serde(skip_serializing_if = "is_false")]
850 record_additional_state_digest_in_prologue: bool,
851
852 #[serde(skip_serializing_if = "is_false")]
854 move_native_context: bool,
855
856 #[serde(skip_serializing_if = "is_false")]
859 #[skip_protocol_config_accessor]
860 consensus_median_based_commit_timestamp: bool,
861
862 #[serde(skip_serializing_if = "is_false")]
865 normalize_ptb_arguments: bool,
866
867 #[serde(skip_serializing_if = "is_false")]
869 consensus_batched_block_sync: bool,
870
871 #[serde(skip_serializing_if = "is_false")]
873 enforce_checkpoint_timestamp_monotonicity: bool,
874
875 #[serde(skip_serializing_if = "is_false")]
877 max_ptb_value_size_v2: bool,
878
879 #[serde(skip_serializing_if = "is_false")]
881 resolve_type_input_ids_to_defining_id: bool,
882
883 #[serde(skip_serializing_if = "is_false")]
885 enable_party_transfer: bool,
886
887 #[serde(skip_serializing_if = "is_false")]
889 allow_unbounded_system_objects: bool,
890
891 #[serde(skip_serializing_if = "is_false")]
893 type_tags_in_object_runtime: bool,
894
895 #[serde(skip_serializing_if = "is_false")]
897 enable_accumulators: bool,
898
899 #[serde(skip_serializing_if = "is_false")]
901 #[skip_protocol_config_accessor]
902 enable_coin_reservation_obj_refs: bool,
903
904 #[serde(skip_serializing_if = "is_false")]
907 create_root_accumulator_object: bool,
908
909 #[serde(skip_serializing_if = "is_false")]
911 #[skip_protocol_config_accessor]
912 enable_authenticated_event_streams: bool,
913
914 #[serde(skip_serializing_if = "is_false")]
916 enable_address_balance_gas_payments: bool,
917
918 #[serde(skip_serializing_if = "is_false")]
920 address_balance_gas_check_rgp_at_signing: bool,
921
922 #[serde(skip_serializing_if = "is_false")]
923 address_balance_gas_reject_gas_coin_arg: bool,
924
925 #[serde(skip_serializing_if = "is_false")]
927 enable_multi_epoch_transaction_expiration: bool,
928
929 #[serde(skip_serializing_if = "is_false")]
931 relax_valid_during_for_owned_inputs: bool,
932
933 #[serde(skip_serializing_if = "is_false")]
935 enable_ptb_execution_v2: bool,
936
937 #[serde(skip_serializing_if = "is_false")]
939 better_adapter_type_resolution_errors: bool,
940
941 #[serde(skip_serializing_if = "is_false")]
943 record_time_estimate_processed: bool,
944
945 #[serde(skip_serializing_if = "is_false")]
947 dependency_linkage_error: bool,
948
949 #[serde(skip_serializing_if = "is_false")]
951 additional_multisig_checks: bool,
952
953 #[serde(skip_serializing_if = "is_false")]
955 ignore_execution_time_observations_after_certs_closed: bool,
956
957 #[serde(skip_serializing_if = "is_false")]
961 debug_fatal_on_move_invariant_violation: bool,
962
963 #[serde(skip_serializing_if = "is_false")]
966 allow_private_accumulator_entrypoints: bool,
967
968 #[serde(skip_serializing_if = "is_false")]
971 additional_consensus_digest_indirect_state: bool,
972
973 #[serde(skip_serializing_if = "is_false")]
975 check_for_init_during_upgrade: bool,
976
977 #[serde(skip_serializing_if = "is_false")]
979 enable_init_on_upgrade: bool,
980
981 #[serde(skip_serializing_if = "is_false")]
983 enable_order_independent_upgrade_init_linkage: bool,
984
985 #[serde(skip_serializing_if = "is_false")]
987 per_command_shared_object_transfer_rules: bool,
988
989 #[serde(skip_serializing_if = "is_false")]
991 include_checkpoint_artifacts_digest_in_summary: bool,
992
993 #[serde(skip_serializing_if = "is_false")]
995 use_mfp_txns_in_load_initial_object_debts: bool,
996
997 #[serde(skip_serializing_if = "is_false")]
999 cancel_for_failed_dkg_early: bool,
1000
1001 #[serde(skip_serializing_if = "is_false")]
1003 always_advance_dkg_to_resolution: bool,
1004
1005 #[serde(skip_serializing_if = "is_false")]
1007 enable_coin_registry: bool,
1008
1009 #[serde(skip_serializing_if = "is_false")]
1011 abstract_size_in_object_runtime: bool,
1012
1013 #[serde(skip_serializing_if = "is_false")]
1015 object_runtime_charge_cache_load_gas: bool,
1016
1017 #[serde(skip_serializing_if = "is_false")]
1019 additional_borrow_checks: bool,
1020
1021 #[serde(skip_serializing_if = "is_false")]
1023 use_new_commit_handler: bool,
1024
1025 #[serde(skip_serializing_if = "is_false")]
1027 better_loader_errors: bool,
1028
1029 #[serde(skip_serializing_if = "is_false")]
1031 generate_df_type_layouts: bool,
1032
1033 #[serde(skip_serializing_if = "is_false")]
1035 allow_references_in_ptbs: bool,
1036
1037 #[serde(skip_serializing_if = "is_false")]
1044 framework_tx_context_mut_restrictions: bool,
1045
1046 #[serde(skip_serializing_if = "is_false")]
1048 include_function_signatures_in_instantiation_limits: bool,
1049
1050 #[serde(skip_serializing_if = "is_false")]
1052 enable_display_registry: bool,
1053
1054 #[serde(skip_serializing_if = "is_false")]
1056 private_generics_verifier_v2: bool,
1057
1058 #[serde(skip_serializing_if = "is_false")]
1060 deprecate_global_storage_ops_during_deserialization: bool,
1061
1062 #[serde(skip_serializing_if = "is_false")]
1065 enable_non_exclusive_writes: bool,
1066
1067 #[serde(skip_serializing_if = "is_false")]
1069 deprecate_global_storage_ops: bool,
1070
1071 #[serde(skip_serializing_if = "is_false")]
1073 normalize_depth_formula: bool,
1074
1075 #[serde(skip_serializing_if = "is_false")]
1077 consensus_skip_gced_accept_votes: bool,
1078
1079 #[serde(skip_serializing_if = "is_false")]
1082 include_cancelled_randomness_txns_in_prologue: bool,
1083
1084 #[serde(skip_serializing_if = "is_false")]
1086 #[skip_protocol_config_accessor]
1087 address_aliases: bool,
1088
1089 #[serde(skip_serializing_if = "is_false")]
1091 create_forwarding_address_registry: bool,
1092
1093 #[serde(skip_serializing_if = "is_false")]
1096 fix_checkpoint_signature_mapping: bool,
1097
1098 #[serde(skip_serializing_if = "is_false")]
1100 enable_object_funds_withdraw: bool,
1101
1102 #[serde(skip_serializing_if = "is_false")]
1105 record_net_unsettled_object_withdraws: bool,
1106
1107 #[serde(skip_serializing_if = "is_false")]
1109 consensus_skip_gced_blocks_in_direct_finalization: bool,
1110
1111 #[serde(skip_serializing_if = "is_false")]
1113 gas_rounding_halve_digits: bool,
1114
1115 #[serde(skip_serializing_if = "is_false")]
1117 flexible_tx_context_positions: bool,
1118
1119 #[serde(skip_serializing_if = "is_false")]
1121 disable_entry_point_signature_check: bool,
1122
1123 #[serde(skip_serializing_if = "is_false")]
1125 convert_withdrawal_compatibility_ptb_arguments: bool,
1126
1127 #[serde(skip_serializing_if = "is_false")]
1129 restrict_hot_or_not_entry_functions: bool,
1130
1131 #[serde(skip_serializing_if = "is_false")]
1133 split_checkpoints_in_consensus_handler: bool,
1134
1135 #[serde(skip_serializing_if = "is_false")]
1137 consensus_always_accept_system_transactions: bool,
1138
1139 #[serde(skip_serializing_if = "is_false")]
1141 validator_metadata_verify_v2: bool,
1142
1143 #[serde(skip_serializing_if = "is_false")]
1146 defer_unpaid_amplification: bool,
1147
1148 #[serde(skip_serializing_if = "is_false")]
1151 defer_owned_object_double_spend: bool,
1152
1153 #[serde(skip_serializing_if = "is_false")]
1156 allowed_proposers: bool,
1157
1158 #[serde(skip_serializing_if = "is_false")]
1159 randomize_checkpoint_tx_limit_in_tests: bool,
1160
1161 #[serde(skip_serializing_if = "is_false")]
1163 gasless_transaction_drop_safety: bool,
1164
1165 #[serde(skip_serializing_if = "is_false")]
1168 merge_randomness_into_checkpoint: bool,
1169
1170 #[serde(skip_serializing_if = "is_false")]
1172 use_coin_party_owner: bool,
1173
1174 #[serde(skip_serializing_if = "is_false")]
1175 enable_gasless: bool,
1176
1177 #[serde(skip_serializing_if = "is_false")]
1178 gasless_verify_remaining_balance: bool,
1179
1180 #[serde(skip_serializing_if = "is_false")]
1181 disallow_jump_orphans: bool,
1182
1183 #[serde(skip_serializing_if = "is_false")]
1185 early_return_receive_object_mismatched_type: bool,
1186
1187 #[serde(skip_serializing_if = "is_false")]
1192 timestamp_based_epoch_close: bool,
1193
1194 #[serde(skip_serializing_if = "is_false")]
1197 limit_groth16_pvk_inputs: bool,
1198
1199 #[serde(skip_serializing_if = "is_false")]
1204 enforce_address_balance_change_invariant: bool,
1205
1206 #[serde(skip_serializing_if = "is_false")]
1208 share_transaction_deny_config_in_consensus: bool,
1209
1210 #[serde(skip_serializing_if = "is_false")]
1212 granular_post_execution_checks: bool,
1213
1214 #[serde(skip_serializing_if = "is_false")]
1216 early_exit_on_iffw: bool,
1217
1218 #[serde(skip_serializing_if = "is_false")]
1220 enable_unified_linkage: bool,
1221}
1222
1223fn is_false(b: &bool) -> bool {
1224 !b
1225}
1226
1227fn is_empty(b: &BTreeSet<String>) -> bool {
1228 b.is_empty()
1229}
1230
1231fn is_zero(val: &u64) -> bool {
1232 *val == 0
1233}
1234
1235#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1237pub enum ConsensusTransactionOrdering {
1238 #[default]
1240 None,
1241 ByGasPrice,
1243}
1244
1245impl ConsensusTransactionOrdering {
1246 pub fn is_none(&self) -> bool {
1247 matches!(self, ConsensusTransactionOrdering::None)
1248 }
1249}
1250
1251#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1252pub struct ExecutionTimeEstimateParams {
1253 pub target_utilization: u64,
1255 pub allowed_txn_cost_overage_burst_limit_us: u64,
1259
1260 pub randomness_scalar: u64,
1263
1264 pub max_estimate_us: u64,
1266
1267 pub stored_observations_num_included_checkpoints: u64,
1270
1271 pub stored_observations_limit: u64,
1273
1274 #[serde(skip_serializing_if = "is_zero")]
1277 pub stake_weighted_median_threshold: u64,
1278
1279 #[serde(skip_serializing_if = "is_false")]
1283 pub default_none_duration_for_new_keys: bool,
1284
1285 #[serde(skip_serializing_if = "Option::is_none")]
1287 pub observations_chunk_size: Option<u64>,
1288}
1289
1290#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1292pub enum PerObjectCongestionControlMode {
1293 #[default]
1294 None, TotalGasBudget, TotalTxCount, TotalGasBudgetWithCap, ExecutionTimeEstimate(ExecutionTimeEstimateParams), }
1300
1301impl PerObjectCongestionControlMode {
1302 pub fn is_none(&self) -> bool {
1303 matches!(self, PerObjectCongestionControlMode::None)
1304 }
1305}
1306
1307#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1309pub enum ConsensusChoice {
1310 #[default]
1311 Narwhal,
1312 SwapEachEpoch,
1313 Mysticeti,
1314}
1315
1316impl ConsensusChoice {
1317 pub fn is_narwhal(&self) -> bool {
1318 matches!(self, ConsensusChoice::Narwhal)
1319 }
1320}
1321
1322#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1324pub enum ConsensusNetwork {
1325 #[default]
1326 Anemo,
1327 Tonic,
1328}
1329
1330impl ConsensusNetwork {
1331 pub fn is_anemo(&self) -> bool {
1332 matches!(self, ConsensusNetwork::Anemo)
1333 }
1334}
1335
1336#[skip_serializing_none]
1368#[derive(Clone, Serialize, Debug, ProtocolConfigAccessors, ProtocolConfigOverride)]
1369pub struct ProtocolConfig {
1370 pub version: ProtocolVersion,
1371
1372 #[serde(skip)]
1377 chain: Chain,
1378
1379 feature_flags: FeatureFlags,
1380
1381 max_tx_size_bytes: Option<u64>,
1384
1385 max_input_objects: Option<u64>,
1387
1388 max_size_written_objects: Option<u64>,
1392 max_size_written_objects_system_tx: Option<u64>,
1395
1396 max_serialized_tx_effects_size_bytes: Option<u64>,
1398
1399 max_serialized_tx_effects_size_bytes_system_tx: Option<u64>,
1401
1402 max_gas_payment_objects: Option<u32>,
1404
1405 max_modules_in_publish: Option<u32>,
1407
1408 max_package_dependencies: Option<u32>,
1410
1411 max_arguments: Option<u32>,
1414
1415 max_type_arguments: Option<u32>,
1417
1418 max_type_argument_depth: Option<u32>,
1420
1421 max_pure_argument_size: Option<u32>,
1423
1424 max_programmable_tx_commands: Option<u32>,
1426
1427 move_binary_format_version: Option<u32>,
1430 min_move_binary_format_version: Option<u32>,
1431
1432 binary_module_handles: Option<u16>,
1434 binary_struct_handles: Option<u16>,
1435 binary_function_handles: Option<u16>,
1436 binary_function_instantiations: Option<u16>,
1437 binary_signatures: Option<u16>,
1438 binary_constant_pool: Option<u16>,
1439 binary_identifiers: Option<u16>,
1440 binary_address_identifiers: Option<u16>,
1441 binary_struct_defs: Option<u16>,
1442 binary_struct_def_instantiations: Option<u16>,
1443 binary_function_defs: Option<u16>,
1444 binary_field_handles: Option<u16>,
1445 binary_field_instantiations: Option<u16>,
1446 binary_friend_decls: Option<u16>,
1447 binary_enum_defs: Option<u16>,
1448 binary_enum_def_instantiations: Option<u16>,
1449 binary_variant_handles: Option<u16>,
1450 binary_variant_instantiation_handles: Option<u16>,
1451
1452 max_move_object_size: Option<u64>,
1454
1455 max_move_package_size: Option<u64>,
1458
1459 max_publish_or_upgrade_per_ptb: Option<u64>,
1461
1462 max_tx_gas: Option<u64>,
1464
1465 max_gas_price: Option<u64>,
1467
1468 max_gas_price_rgp_factor_for_aborted_transactions: Option<u64>,
1471
1472 max_gas_computation_bucket: Option<u64>,
1474
1475 gas_rounding_step: Option<u64>,
1477
1478 max_loop_depth: Option<u64>,
1480
1481 max_generic_instantiation_length: Option<u64>,
1483
1484 max_function_parameters: Option<u64>,
1486
1487 max_basic_blocks: Option<u64>,
1489
1490 max_value_stack_size: Option<u64>,
1492
1493 max_type_nodes: Option<u64>,
1495
1496 max_generic_instantiation_type_nodes_per_function: Option<u64>,
1498
1499 max_generic_instantiation_type_nodes_per_module: Option<u64>,
1501
1502 max_accumulator_type_nodes: Option<u64>,
1504
1505 max_push_size: Option<u64>,
1507
1508 max_struct_definitions: Option<u64>,
1510
1511 max_function_definitions: Option<u64>,
1513
1514 max_fields_in_struct: Option<u64>,
1516
1517 max_dependency_depth: Option<u64>,
1519
1520 max_num_event_emit: Option<u64>,
1522
1523 max_num_new_move_object_ids: Option<u64>,
1525
1526 max_num_new_move_object_ids_system_tx: Option<u64>,
1528
1529 max_num_deleted_move_object_ids: Option<u64>,
1531
1532 max_num_deleted_move_object_ids_system_tx: Option<u64>,
1534
1535 max_num_transferred_move_object_ids: Option<u64>,
1537
1538 max_num_transferred_move_object_ids_system_tx: Option<u64>,
1540
1541 max_event_emit_size: Option<u64>,
1543
1544 max_event_emit_size_total: Option<u64>,
1546
1547 max_move_vector_len: Option<u64>,
1549
1550 max_move_identifier_len: Option<u64>,
1552
1553 max_move_value_depth: Option<u64>,
1555
1556 max_move_enum_variants: Option<u64>,
1558
1559 max_back_edges_per_function: Option<u64>,
1561
1562 max_back_edges_per_module: Option<u64>,
1564
1565 max_verifier_meter_ticks_per_function: Option<u64>,
1567
1568 max_meter_ticks_per_module: Option<u64>,
1570
1571 max_meter_ticks_per_package: Option<u64>,
1573
1574 object_runtime_max_num_cached_objects: Option<u64>,
1578
1579 object_runtime_max_num_cached_objects_system_tx: Option<u64>,
1581
1582 object_runtime_max_num_store_entries: Option<u64>,
1584
1585 object_runtime_max_num_store_entries_system_tx: Option<u64>,
1587
1588 base_tx_cost_fixed: Option<u64>,
1591
1592 package_publish_cost_fixed: Option<u64>,
1595
1596 base_tx_cost_per_byte: Option<u64>,
1599
1600 package_publish_cost_per_byte: Option<u64>,
1602
1603 obj_access_cost_read_per_byte: Option<u64>,
1605
1606 obj_access_cost_mutate_per_byte: Option<u64>,
1608
1609 obj_access_cost_delete_per_byte: Option<u64>,
1611
1612 obj_access_cost_verify_per_byte: Option<u64>,
1622
1623 max_type_to_layout_nodes: Option<u64>,
1625
1626 max_ptb_value_size: Option<u64>,
1628
1629 gas_model_version: Option<u64>,
1632
1633 obj_data_cost_refundable: Option<u64>,
1636
1637 obj_metadata_cost_non_refundable: Option<u64>,
1641
1642 storage_rebate_rate: Option<u64>,
1648
1649 storage_fund_reinvest_rate: Option<u64>,
1652
1653 reward_slashing_rate: Option<u64>,
1656
1657 storage_gas_price: Option<u64>,
1659
1660 accumulator_object_storage_cost: Option<u64>,
1662
1663 max_transactions_per_checkpoint: Option<u64>,
1668
1669 max_checkpoint_size_bytes: Option<u64>,
1673
1674 buffer_stake_for_protocol_upgrade_bps: Option<u64>,
1679
1680 address_from_bytes_cost_base: Option<u64>,
1685 address_to_u256_cost_base: Option<u64>,
1687 address_from_u256_cost_base: Option<u64>,
1689
1690 config_read_setting_impl_cost_base: Option<u64>,
1695 config_read_setting_impl_cost_per_byte: Option<u64>,
1696
1697 package_original_package_id_impl_cost_base: Option<u64>,
1698 package_original_package_id_impl_cost_per_byte: Option<u64>,
1699
1700 dynamic_field_hash_type_and_key_cost_base: Option<u64>,
1703 dynamic_field_hash_type_and_key_type_cost_per_byte: Option<u64>,
1704 dynamic_field_hash_type_and_key_value_cost_per_byte: Option<u64>,
1705 dynamic_field_hash_type_and_key_type_tag_cost_per_byte: Option<u64>,
1706 dynamic_field_add_child_object_cost_base: Option<u64>,
1708 dynamic_field_add_child_object_type_cost_per_byte: Option<u64>,
1709 dynamic_field_add_child_object_value_cost_per_byte: Option<u64>,
1710 dynamic_field_add_child_object_struct_tag_cost_per_byte: Option<u64>,
1711 dynamic_field_borrow_child_object_cost_base: Option<u64>,
1713 dynamic_field_borrow_child_object_child_ref_cost_per_byte: Option<u64>,
1714 dynamic_field_borrow_child_object_type_cost_per_byte: Option<u64>,
1715 dynamic_field_remove_child_object_cost_base: Option<u64>,
1717 dynamic_field_remove_child_object_child_cost_per_byte: Option<u64>,
1718 dynamic_field_remove_child_object_type_cost_per_byte: Option<u64>,
1719 dynamic_field_has_child_object_cost_base: Option<u64>,
1721 dynamic_field_has_child_object_with_ty_cost_base: Option<u64>,
1723 dynamic_field_has_child_object_with_ty_type_cost_per_byte: Option<u64>,
1724 dynamic_field_has_child_object_with_ty_type_tag_cost_per_byte: Option<u64>,
1725
1726 scratch_add_cost_base: Option<u64>,
1729 scratch_read_cost_base: Option<u64>,
1731 scratch_read_value_cost: Option<u64>,
1732 scratch_remove_cost_base: Option<u64>,
1734 scratch_exists_cost_base: Option<u64>,
1736 scratch_exists_with_type_cost_base: Option<u64>,
1738 scratch_exists_with_type_type_cost: Option<u64>,
1739 max_scratch_pad_size: Option<u64>,
1741
1742 event_emit_cost_base: Option<u64>,
1745 event_emit_value_size_derivation_cost_per_byte: Option<u64>,
1746 event_emit_tag_size_derivation_cost_per_byte: Option<u64>,
1747 event_emit_output_cost_per_byte: Option<u64>,
1748 event_emit_auth_stream_cost: Option<u64>,
1749
1750 object_borrow_uid_cost_base: Option<u64>,
1753 object_delete_impl_cost_base: Option<u64>,
1755 object_record_new_uid_cost_base: Option<u64>,
1757 object_record_new_uid_from_hash_cost_base: Option<u64>,
1760
1761 transfer_transfer_internal_cost_base: Option<u64>,
1764 transfer_party_transfer_internal_cost_base: Option<u64>,
1766 transfer_freeze_object_cost_base: Option<u64>,
1768 transfer_share_object_cost_base: Option<u64>,
1770 transfer_receive_object_cost_base: Option<u64>,
1773 transfer_receive_object_cost_per_byte: Option<u64>,
1774 transfer_receive_object_type_cost_per_byte: Option<u64>,
1775
1776 tx_context_derive_id_cost_base: Option<u64>,
1779 tx_context_fresh_id_cost_base: Option<u64>,
1780 tx_context_sender_cost_base: Option<u64>,
1781 tx_context_epoch_cost_base: Option<u64>,
1782 tx_context_epoch_timestamp_ms_cost_base: Option<u64>,
1783 tx_context_sponsor_cost_base: Option<u64>,
1784 tx_context_rgp_cost_base: Option<u64>,
1785 tx_context_gas_price_cost_base: Option<u64>,
1786 tx_context_gas_budget_cost_base: Option<u64>,
1787 tx_context_ids_created_cost_base: Option<u64>,
1788 tx_context_replace_cost_base: Option<u64>,
1789
1790 types_is_one_time_witness_cost_base: Option<u64>,
1793 types_is_one_time_witness_type_tag_cost_per_byte: Option<u64>,
1794 types_is_one_time_witness_type_cost_per_byte: Option<u64>,
1795
1796 validator_validate_metadata_cost_base: Option<u64>,
1799 validator_validate_metadata_data_cost_per_byte: Option<u64>,
1800
1801 crypto_invalid_arguments_cost: Option<u64>,
1803 bls12381_bls12381_min_sig_verify_cost_base: Option<u64>,
1805 bls12381_bls12381_min_sig_verify_msg_cost_per_byte: Option<u64>,
1806 bls12381_bls12381_min_sig_verify_msg_cost_per_block: Option<u64>,
1807
1808 bls12381_bls12381_min_pk_verify_cost_base: Option<u64>,
1810 bls12381_bls12381_min_pk_verify_msg_cost_per_byte: Option<u64>,
1811 bls12381_bls12381_min_pk_verify_msg_cost_per_block: Option<u64>,
1812
1813 ecdsa_k1_ecrecover_keccak256_cost_base: Option<u64>,
1815 ecdsa_k1_ecrecover_keccak256_msg_cost_per_byte: Option<u64>,
1816 ecdsa_k1_ecrecover_keccak256_msg_cost_per_block: Option<u64>,
1817 ecdsa_k1_ecrecover_sha256_cost_base: Option<u64>,
1818 ecdsa_k1_ecrecover_sha256_msg_cost_per_byte: Option<u64>,
1819 ecdsa_k1_ecrecover_sha256_msg_cost_per_block: Option<u64>,
1820
1821 ecdsa_k1_decompress_pubkey_cost_base: Option<u64>,
1823
1824 ecdsa_k1_secp256k1_verify_keccak256_cost_base: Option<u64>,
1826 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_byte: Option<u64>,
1827 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_block: Option<u64>,
1828 ecdsa_k1_secp256k1_verify_sha256_cost_base: Option<u64>,
1829 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_byte: Option<u64>,
1830 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_block: Option<u64>,
1831
1832 ecdsa_r1_ecrecover_keccak256_cost_base: Option<u64>,
1834 ecdsa_r1_ecrecover_keccak256_msg_cost_per_byte: Option<u64>,
1835 ecdsa_r1_ecrecover_keccak256_msg_cost_per_block: Option<u64>,
1836 ecdsa_r1_ecrecover_sha256_cost_base: Option<u64>,
1837 ecdsa_r1_ecrecover_sha256_msg_cost_per_byte: Option<u64>,
1838 ecdsa_r1_ecrecover_sha256_msg_cost_per_block: Option<u64>,
1839
1840 ecdsa_r1_secp256r1_verify_keccak256_cost_base: Option<u64>,
1842 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_byte: Option<u64>,
1843 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_block: Option<u64>,
1844 ecdsa_r1_secp256r1_verify_sha256_cost_base: Option<u64>,
1845 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_byte: Option<u64>,
1846 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_block: Option<u64>,
1847
1848 ecvrf_ecvrf_verify_cost_base: Option<u64>,
1850 ecvrf_ecvrf_verify_alpha_string_cost_per_byte: Option<u64>,
1851 ecvrf_ecvrf_verify_alpha_string_cost_per_block: Option<u64>,
1852
1853 ed25519_ed25519_verify_cost_base: Option<u64>,
1855 ed25519_ed25519_verify_msg_cost_per_byte: Option<u64>,
1856 ed25519_ed25519_verify_msg_cost_per_block: Option<u64>,
1857
1858 groth16_prepare_verifying_key_bls12381_cost_base: Option<u64>,
1860 groth16_prepare_verifying_key_bn254_cost_base: Option<u64>,
1861
1862 groth16_verify_groth16_proof_internal_bls12381_cost_base: Option<u64>,
1864 groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input: Option<u64>,
1865 groth16_verify_groth16_proof_internal_bn254_cost_base: Option<u64>,
1866 groth16_verify_groth16_proof_internal_bn254_cost_per_public_input: Option<u64>,
1867 groth16_verify_groth16_proof_internal_public_input_cost_per_byte: Option<u64>,
1868
1869 hash_blake2b256_cost_base: Option<u64>,
1871 hash_blake2b256_data_cost_per_byte: Option<u64>,
1872 hash_blake2b256_data_cost_per_block: Option<u64>,
1873
1874 hash_keccak256_cost_base: Option<u64>,
1876 hash_keccak256_data_cost_per_byte: Option<u64>,
1877 hash_keccak256_data_cost_per_block: Option<u64>,
1878
1879 poseidon_bn254_cost_base: Option<u64>,
1881 poseidon_bn254_cost_per_block: Option<u64>,
1882
1883 group_ops_bls12381_decode_scalar_cost: Option<u64>,
1885 group_ops_bls12381_decode_g1_cost: Option<u64>,
1886 group_ops_bls12381_decode_g2_cost: Option<u64>,
1887 group_ops_bls12381_decode_gt_cost: Option<u64>,
1888 group_ops_bls12381_scalar_add_cost: Option<u64>,
1889 group_ops_bls12381_g1_add_cost: Option<u64>,
1890 group_ops_bls12381_g2_add_cost: Option<u64>,
1891 group_ops_bls12381_gt_add_cost: Option<u64>,
1892 group_ops_bls12381_scalar_sub_cost: Option<u64>,
1893 group_ops_bls12381_g1_sub_cost: Option<u64>,
1894 group_ops_bls12381_g2_sub_cost: Option<u64>,
1895 group_ops_bls12381_gt_sub_cost: Option<u64>,
1896 group_ops_bls12381_scalar_mul_cost: Option<u64>,
1897 group_ops_bls12381_g1_mul_cost: Option<u64>,
1898 group_ops_bls12381_g2_mul_cost: Option<u64>,
1899 group_ops_bls12381_gt_mul_cost: Option<u64>,
1900 group_ops_bls12381_scalar_div_cost: Option<u64>,
1901 group_ops_bls12381_g1_div_cost: Option<u64>,
1902 group_ops_bls12381_g2_div_cost: Option<u64>,
1903 group_ops_bls12381_gt_div_cost: Option<u64>,
1904 group_ops_bls12381_g1_hash_to_base_cost: Option<u64>,
1905 group_ops_bls12381_g2_hash_to_base_cost: Option<u64>,
1906 group_ops_bls12381_g1_hash_to_cost_per_byte: Option<u64>,
1907 group_ops_bls12381_g2_hash_to_cost_per_byte: Option<u64>,
1908 group_ops_bls12381_g1_msm_base_cost: Option<u64>,
1909 group_ops_bls12381_g2_msm_base_cost: Option<u64>,
1910 group_ops_bls12381_g1_msm_base_cost_per_input: Option<u64>,
1911 group_ops_bls12381_g2_msm_base_cost_per_input: Option<u64>,
1912 group_ops_bls12381_msm_max_len: Option<u32>,
1913 group_ops_bls12381_pairing_cost: Option<u64>,
1914 group_ops_bls12381_g1_to_uncompressed_g1_cost: Option<u64>,
1915 group_ops_bls12381_uncompressed_g1_to_g1_cost: Option<u64>,
1916 group_ops_bls12381_uncompressed_g1_sum_base_cost: Option<u64>,
1917 group_ops_bls12381_uncompressed_g1_sum_cost_per_term: Option<u64>,
1918 group_ops_bls12381_uncompressed_g1_sum_max_terms: Option<u64>,
1919
1920 group_ops_ristretto_decode_scalar_cost: Option<u64>,
1921 group_ops_ristretto_decode_point_cost: Option<u64>,
1922 group_ops_ristretto_scalar_add_cost: Option<u64>,
1923 group_ops_ristretto_point_add_cost: Option<u64>,
1924 group_ops_ristretto_scalar_sub_cost: Option<u64>,
1925 group_ops_ristretto_point_sub_cost: Option<u64>,
1926 group_ops_ristretto_scalar_mul_cost: Option<u64>,
1927 group_ops_ristretto_point_mul_cost: Option<u64>,
1928 group_ops_ristretto_scalar_div_cost: Option<u64>,
1929 group_ops_ristretto_point_div_cost: Option<u64>,
1930
1931 verify_bulletproofs_ristretto255_base_cost: Option<u64>,
1932 verify_bulletproofs_ristretto255_cost_per_bit_and_commitment: Option<u64>,
1933
1934 hmac_hmac_sha3_256_cost_base: Option<u64>,
1936 hmac_hmac_sha3_256_input_cost_per_byte: Option<u64>,
1937 hmac_hmac_sha3_256_input_cost_per_block: Option<u64>,
1938
1939 check_zklogin_id_cost_base: Option<u64>,
1941 check_zklogin_issuer_cost_base: Option<u64>,
1943
1944 vdf_verify_vdf_cost: Option<u64>,
1945 vdf_hash_to_input_cost: Option<u64>,
1946
1947 nitro_attestation_parse_base_cost: Option<u64>,
1949 nitro_attestation_parse_cost_per_byte: Option<u64>,
1950 nitro_attestation_verify_base_cost: Option<u64>,
1951 nitro_attestation_verify_cost_per_cert: Option<u64>,
1952
1953 bcs_per_byte_serialized_cost: Option<u64>,
1955 bcs_legacy_min_output_size_cost: Option<u64>,
1956 bcs_failure_cost: Option<u64>,
1957
1958 hash_sha2_256_base_cost: Option<u64>,
1959 hash_sha2_256_per_byte_cost: Option<u64>,
1960 hash_sha2_256_legacy_min_input_len_cost: Option<u64>,
1961 hash_sha3_256_base_cost: Option<u64>,
1962 hash_sha3_256_per_byte_cost: Option<u64>,
1963 hash_sha3_256_legacy_min_input_len_cost: Option<u64>,
1964 type_name_get_base_cost: Option<u64>,
1965 type_name_get_per_byte_cost: Option<u64>,
1966 type_name_id_base_cost: Option<u64>,
1967
1968 string_check_utf8_base_cost: Option<u64>,
1969 string_check_utf8_per_byte_cost: Option<u64>,
1970 string_is_char_boundary_base_cost: Option<u64>,
1971 string_sub_string_base_cost: Option<u64>,
1972 string_sub_string_per_byte_cost: Option<u64>,
1973 string_index_of_base_cost: Option<u64>,
1974 string_index_of_per_byte_pattern_cost: Option<u64>,
1975 string_index_of_per_byte_searched_cost: Option<u64>,
1976
1977 vector_empty_base_cost: Option<u64>,
1978 vector_length_base_cost: Option<u64>,
1979 vector_push_back_base_cost: Option<u64>,
1980 vector_push_back_legacy_per_abstract_memory_unit_cost: Option<u64>,
1981 vector_borrow_base_cost: Option<u64>,
1982 vector_pop_back_base_cost: Option<u64>,
1983 vector_destroy_empty_base_cost: Option<u64>,
1984 vector_swap_base_cost: Option<u64>,
1985 debug_print_base_cost: Option<u64>,
1986 debug_print_stack_trace_base_cost: Option<u64>,
1987
1988 #[custom_setter]
1998 execution_version: Option<u64>,
1999
2000 consensus_bad_nodes_stake_threshold: Option<u64>,
2004
2005 max_jwk_votes_per_validator_per_epoch: Option<u64>,
2006 max_age_of_jwk_in_epochs: Option<u64>,
2010
2011 random_beacon_reduction_allowed_delta: Option<u16>,
2015
2016 random_beacon_reduction_lower_bound: Option<u32>,
2019
2020 random_beacon_dkg_timeout_round: Option<u32>,
2023
2024 random_beacon_min_round_interval_ms: Option<u64>,
2026
2027 random_beacon_dkg_version: Option<u64>,
2030
2031 consensus_max_transaction_size_bytes: Option<u64>,
2034 consensus_max_transactions_in_block_bytes: Option<u64>,
2036 consensus_max_num_transactions_in_block: Option<u64>,
2038
2039 consensus_voting_rounds: Option<u32>,
2041
2042 max_accumulated_txn_cost_per_object_in_narwhal_commit: Option<u64>,
2044
2045 max_deferral_rounds_for_congestion_control: Option<u64>,
2048
2049 epoch_close_deadline_ms: Option<u64>,
2054
2055 max_txn_cost_overage_per_object_in_commit: Option<u64>,
2057
2058 allowed_txn_cost_overage_burst_per_object_in_commit: Option<u64>,
2060
2061 min_checkpoint_interval_ms: Option<u64>,
2063
2064 checkpoint_summary_version_specific_data: Option<u64>,
2066
2067 max_soft_bundle_size: Option<u64>,
2069
2070 bridge_should_try_to_finalize_committee: Option<bool>,
2074
2075 max_accumulated_txn_cost_per_object_in_mysticeti_commit: Option<u64>,
2081
2082 max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit: Option<u64>,
2085
2086 consensus_gc_depth: Option<u32>,
2089
2090 gas_budget_based_txn_cost_cap_factor: Option<u64>,
2092
2093 gas_budget_based_txn_cost_absolute_cap_commit_count: Option<u64>,
2095
2096 sip_45_consensus_amplification_threshold: Option<u64>,
2099
2100 use_object_per_epoch_marker_table_v2: Option<bool>,
2103
2104 consensus_commit_rate_estimation_window_size: Option<u32>,
2106
2107 #[serde(skip_serializing_if = "Vec::is_empty")]
2111 aliased_addresses: Vec<AliasedAddress>,
2112
2113 translation_per_command_base_charge: Option<u64>,
2116
2117 translation_per_input_base_charge: Option<u64>,
2120
2121 translation_pure_input_per_byte_charge: Option<u64>,
2123
2124 translation_per_type_node_charge: Option<u64>,
2128
2129 translation_per_reference_node_charge: Option<u64>,
2132
2133 translation_per_linkage_entry_charge: Option<u64>,
2136
2137 max_updates_per_settlement_txn: Option<u32>,
2139
2140 gasless_max_computation_units: Option<u64>,
2142
2143 gasless_allowed_token_types: Option<Vec<(String, u64)>>,
2145
2146 gasless_max_unused_inputs: Option<u64>,
2150
2151 gasless_max_pure_input_bytes: Option<u64>,
2154
2155 gasless_max_tps: Option<u64>,
2157
2158 #[serde(skip_serializing_if = "Option::is_none")]
2159 #[skip_accessor]
2160 include_special_package_amendments: Option<Arc<Amendments>>,
2161
2162 gasless_max_tx_size_bytes: Option<u64>,
2165}
2166
2167#[derive(Clone, Serialize, Deserialize, Debug)]
2169pub struct AliasedAddress {
2170 pub original: [u8; 32],
2172 pub aliased: [u8; 32],
2174 pub allowed_tx_digests: Vec<[u8; 32]>,
2176}
2177
2178impl ProtocolConfig {
2180 pub fn chain(&self) -> Chain {
2182 self.chain
2183 }
2184
2185 pub fn check_package_upgrades_supported(&self) -> Result<(), Error> {
2198 if self.feature_flags.package_upgrades {
2199 Ok(())
2200 } else {
2201 Err(Error(format!(
2202 "package upgrades are not supported at {:?}",
2203 self.version
2204 )))
2205 }
2206 }
2207
2208 pub fn zklogin_supported_providers(&self) -> &BTreeSet<String> {
2209 &self.feature_flags.zklogin_supported_providers
2210 }
2211
2212 pub fn zklogin_circuit_mode(&self) -> u64 {
2215 self.feature_flags.zklogin_circuit_mode
2216 }
2217
2218 pub fn consensus_transaction_ordering(&self) -> ConsensusTransactionOrdering {
2219 self.feature_flags.consensus_transaction_ordering
2220 }
2221
2222 pub fn enable_jwk_consensus_updates(&self) -> bool {
2223 let ret = self.feature_flags.enable_jwk_consensus_updates;
2224 if ret {
2225 assert!(self.feature_flags.end_of_epoch_transaction_supported);
2227 }
2228 ret
2229 }
2230
2231 pub fn end_of_epoch_transaction_supported(&self) -> bool {
2232 let ret = self.feature_flags.end_of_epoch_transaction_supported;
2233 if !ret {
2234 assert!(!self.feature_flags.enable_jwk_consensus_updates);
2236 }
2237 ret
2238 }
2239
2240 pub fn dkg_version(&self) -> u64 {
2241 self.random_beacon_dkg_version.unwrap_or(1)
2243 }
2244
2245 pub fn bridge(&self) -> bool {
2246 let ret = self.feature_flags.bridge;
2247 if ret {
2248 assert!(self.feature_flags.end_of_epoch_transaction_supported);
2250 }
2251 ret
2252 }
2253
2254 pub fn should_try_to_finalize_bridge_committee(&self) -> bool {
2255 if !self.bridge() {
2256 return false;
2257 }
2258 self.bridge_should_try_to_finalize_committee.unwrap_or(true)
2260 }
2261
2262 pub fn zklogin_max_epoch_upper_bound_delta(&self) -> Option<u64> {
2263 self.feature_flags.zklogin_max_epoch_upper_bound_delta
2264 }
2265
2266 pub fn enable_coin_reservation_obj_refs(&self) -> bool {
2267 self.new_vm_enabled() && self.feature_flags.enable_coin_reservation_obj_refs
2268 }
2269
2270 pub fn enable_authenticated_event_streams(&self) -> bool {
2271 self.feature_flags.enable_authenticated_event_streams && self.enable_accumulators()
2272 }
2273
2274 pub fn per_object_congestion_control_mode(&self) -> PerObjectCongestionControlMode {
2275 self.feature_flags.per_object_congestion_control_mode
2276 }
2277
2278 pub fn consensus_choice(&self) -> ConsensusChoice {
2279 self.feature_flags.consensus_choice
2280 }
2281
2282 pub fn consensus_network(&self) -> ConsensusNetwork {
2283 self.feature_flags.consensus_network
2284 }
2285
2286 pub fn mysticeti_num_leaders_per_round(&self) -> Option<usize> {
2287 self.feature_flags.mysticeti_num_leaders_per_round
2288 }
2289
2290 pub fn max_transaction_size_bytes(&self) -> u64 {
2291 self.consensus_max_transaction_size_bytes
2293 .unwrap_or(256 * 1024)
2294 }
2295
2296 pub fn max_transactions_in_block_bytes(&self) -> u64 {
2297 if cfg!(msim) {
2298 256 * 1024
2299 } else {
2300 self.consensus_max_transactions_in_block_bytes
2301 .unwrap_or(512 * 1024)
2302 }
2303 }
2304
2305 pub fn max_num_transactions_in_block(&self) -> u64 {
2306 if cfg!(msim) {
2307 8
2308 } else {
2309 self.consensus_max_num_transactions_in_block.unwrap_or(512)
2310 }
2311 }
2312
2313 pub fn gc_depth(&self) -> u32 {
2314 self.consensus_gc_depth.unwrap_or(0)
2315 }
2316
2317 pub fn consensus_linearize_subdag_v2(&self) -> bool {
2318 let res = self.feature_flags.consensus_linearize_subdag_v2;
2319 assert!(
2320 !res || self.gc_depth() > 0,
2321 "The consensus linearize sub dag V2 requires GC to be enabled"
2322 );
2323 res
2324 }
2325
2326 pub fn consensus_median_based_commit_timestamp(&self) -> bool {
2327 let res = self.feature_flags.consensus_median_based_commit_timestamp;
2328 assert!(
2329 !res || self.gc_depth() > 0,
2330 "The consensus median based commit timestamp requires GC to be enabled"
2331 );
2332 res
2333 }
2334
2335 pub fn get_consensus_commit_rate_estimation_window_size(&self) -> u32 {
2336 self.consensus_commit_rate_estimation_window_size
2337 .unwrap_or(0)
2338 }
2339
2340 pub fn consensus_num_requested_prior_commits_at_startup(&self) -> u32 {
2341 let window_size = self.get_consensus_commit_rate_estimation_window_size();
2345 assert!(window_size == 0 || self.record_additional_state_digest_in_prologue());
2347 window_size
2348 }
2349
2350 pub fn address_aliases(&self) -> bool {
2351 let address_aliases = self.feature_flags.address_aliases;
2352 assert!(
2353 !address_aliases || self.mysticeti_fastpath(),
2354 "Address aliases requires Mysticeti fastpath to be enabled"
2355 );
2356 if address_aliases {
2357 assert!(
2358 self.feature_flags.disable_preconsensus_locking,
2359 "Address aliases requires CertifiedTransaction to be disabled"
2360 );
2361 }
2362 address_aliases
2363 }
2364
2365 pub fn new_vm_enabled(&self) -> bool {
2366 self.execution_version.is_some_and(|v| v >= 4)
2367 }
2368
2369 pub fn gasless_allowed_token_types(&self) -> &[(String, u64)] {
2370 debug_assert!(self.gasless_allowed_token_types.is_some());
2371 self.gasless_allowed_token_types.as_deref().unwrap_or(&[])
2372 }
2373
2374 pub fn get_gasless_max_unused_inputs(&self) -> u64 {
2375 self.gasless_max_unused_inputs.unwrap_or(u64::MAX)
2376 }
2377
2378 pub fn get_gasless_max_pure_input_bytes(&self) -> u64 {
2379 self.gasless_max_pure_input_bytes.unwrap_or(u64::MAX)
2380 }
2381
2382 pub fn get_gasless_max_tx_size_bytes(&self) -> u64 {
2383 self.gasless_max_tx_size_bytes.unwrap_or(u64::MAX)
2384 }
2385
2386 pub fn include_special_package_amendments_as_option(&self) -> &Option<Arc<Amendments>> {
2387 &self.include_special_package_amendments
2388 }
2389}
2390
2391static POISON_VERSION_METHODS: AtomicBool = AtomicBool::new(false);
2392
2393impl ProtocolConfig {
2395 pub fn get_for_version(version: ProtocolVersion, chain: Chain) -> Self {
2397 assert!(
2399 version >= ProtocolVersion::MIN,
2400 "Network protocol version is {:?}, but the minimum supported version by the binary is {:?}. Please upgrade the binary.",
2401 version,
2402 ProtocolVersion::MIN.0,
2403 );
2404 assert!(
2405 version <= ProtocolVersion::MAX_ALLOWED,
2406 "Network protocol version is {:?}, but the maximum supported version by the binary is {:?}. Please upgrade the binary.",
2407 version,
2408 ProtocolVersion::MAX_ALLOWED.0,
2409 );
2410
2411 let mut ret = Self::get_for_version_impl(version, chain);
2412 ret.version = version;
2413 ret.chain = chain;
2414
2415 ret = Self::apply_config_override(version, ret);
2416
2417 if std::env::var("SUI_PROTOCOL_CONFIG_OVERRIDE_ENABLE").is_ok() {
2418 warn!(
2419 "overriding ProtocolConfig settings with custom settings; this may break non-local networks"
2420 );
2421 let overrides: ProtocolConfigOptional =
2422 serde_env::from_env_with_prefix("SUI_PROTOCOL_CONFIG_OVERRIDE")
2423 .expect("failed to parse ProtocolConfig override env variables");
2424 overrides.apply_to(&mut ret);
2425 }
2426
2427 ret
2428 }
2429
2430 pub fn get_for_version_if_supported(version: ProtocolVersion, chain: Chain) -> Option<Self> {
2433 if version.0 >= ProtocolVersion::MIN.0 && version.0 <= ProtocolVersion::MAX_ALLOWED.0 {
2434 let mut ret = Self::get_for_version_impl(version, chain);
2435 ret.version = version;
2436 ret.chain = chain;
2437 ret = Self::apply_config_override(version, ret);
2438 Some(ret)
2439 } else {
2440 None
2441 }
2442 }
2443
2444 pub fn poison_get_for_min_version() {
2445 POISON_VERSION_METHODS.store(true, Ordering::Relaxed);
2446 }
2447
2448 fn load_poison_get_for_min_version() -> bool {
2449 POISON_VERSION_METHODS.load(Ordering::Relaxed)
2450 }
2451
2452 pub fn get_for_min_version() -> Self {
2455 if Self::load_poison_get_for_min_version() {
2456 panic!("get_for_min_version called on validator");
2457 }
2458 ProtocolConfig::get_for_version(ProtocolVersion::MIN, Chain::Unknown)
2459 }
2460
2461 #[allow(non_snake_case)]
2471 pub fn get_for_max_version_UNSAFE() -> Self {
2472 if Self::load_poison_get_for_min_version() {
2473 panic!("get_for_max_version_UNSAFE called on validator");
2474 }
2475 ProtocolConfig::get_for_version(ProtocolVersion::MAX, Chain::Unknown)
2476 }
2477
2478 fn get_for_version_impl(version: ProtocolVersion, chain: Chain) -> Self {
2479 #[cfg(msim)]
2480 {
2481 if version == ProtocolVersion::MAX_ALLOWED {
2483 let mut config = Self::get_for_version_impl(version - 1, Chain::Unknown);
2484 config.base_tx_cost_fixed = Some(config.base_tx_cost_fixed() + 1000);
2485 return config;
2486 }
2487 }
2488
2489 let mut cfg = Self {
2492 version,
2494 chain,
2495
2496 feature_flags: Default::default(),
2498
2499 max_tx_size_bytes: Some(128 * 1024),
2500 max_input_objects: Some(2048),
2502 max_serialized_tx_effects_size_bytes: Some(512 * 1024),
2503 max_serialized_tx_effects_size_bytes_system_tx: Some(512 * 1024 * 16),
2504 max_gas_payment_objects: Some(256),
2505 max_modules_in_publish: Some(128),
2506 max_package_dependencies: None,
2507 max_arguments: Some(512),
2508 max_type_arguments: Some(16),
2509 max_type_argument_depth: Some(16),
2510 max_pure_argument_size: Some(16 * 1024),
2511 max_programmable_tx_commands: Some(1024),
2512 move_binary_format_version: Some(6),
2513 min_move_binary_format_version: None,
2514 binary_module_handles: None,
2515 binary_struct_handles: None,
2516 binary_function_handles: None,
2517 binary_function_instantiations: None,
2518 binary_signatures: None,
2519 binary_constant_pool: None,
2520 binary_identifiers: None,
2521 binary_address_identifiers: None,
2522 binary_struct_defs: None,
2523 binary_struct_def_instantiations: None,
2524 binary_function_defs: None,
2525 binary_field_handles: None,
2526 binary_field_instantiations: None,
2527 binary_friend_decls: None,
2528 binary_enum_defs: None,
2529 binary_enum_def_instantiations: None,
2530 binary_variant_handles: None,
2531 binary_variant_instantiation_handles: None,
2532 max_move_object_size: Some(250 * 1024),
2533 max_move_package_size: Some(100 * 1024),
2534 max_publish_or_upgrade_per_ptb: None,
2535 max_tx_gas: Some(10_000_000_000),
2536 max_gas_price: Some(100_000),
2537 max_gas_price_rgp_factor_for_aborted_transactions: None,
2538 max_gas_computation_bucket: Some(5_000_000),
2539 max_loop_depth: Some(5),
2540 max_generic_instantiation_length: Some(32),
2541 max_function_parameters: Some(128),
2542 max_basic_blocks: Some(1024),
2543 max_value_stack_size: Some(1024),
2544 max_type_nodes: Some(256),
2545 max_generic_instantiation_type_nodes_per_function: None,
2546 max_generic_instantiation_type_nodes_per_module: None,
2547 max_accumulator_type_nodes: None,
2548 max_push_size: Some(10000),
2549 max_struct_definitions: Some(200),
2550 max_function_definitions: Some(1000),
2551 max_fields_in_struct: Some(32),
2552 max_dependency_depth: Some(100),
2553 max_num_event_emit: Some(256),
2554 max_num_new_move_object_ids: Some(2048),
2555 max_num_new_move_object_ids_system_tx: Some(2048 * 16),
2556 max_num_deleted_move_object_ids: Some(2048),
2557 max_num_deleted_move_object_ids_system_tx: Some(2048 * 16),
2558 max_num_transferred_move_object_ids: Some(2048),
2559 max_num_transferred_move_object_ids_system_tx: Some(2048 * 16),
2560 max_event_emit_size: Some(250 * 1024),
2561 max_move_vector_len: Some(256 * 1024),
2562 max_type_to_layout_nodes: None,
2563 max_ptb_value_size: None,
2564
2565 max_back_edges_per_function: Some(10_000),
2566 max_back_edges_per_module: Some(10_000),
2567 max_verifier_meter_ticks_per_function: Some(6_000_000),
2568 max_meter_ticks_per_module: Some(6_000_000),
2569 max_meter_ticks_per_package: None,
2570
2571 object_runtime_max_num_cached_objects: Some(1000),
2572 object_runtime_max_num_cached_objects_system_tx: Some(1000 * 16),
2573 object_runtime_max_num_store_entries: Some(1000),
2574 object_runtime_max_num_store_entries_system_tx: Some(1000 * 16),
2575 base_tx_cost_fixed: Some(110_000),
2576 package_publish_cost_fixed: Some(1_000),
2577 base_tx_cost_per_byte: Some(0),
2578 package_publish_cost_per_byte: Some(80),
2579 obj_access_cost_read_per_byte: Some(15),
2580 obj_access_cost_mutate_per_byte: Some(40),
2581 obj_access_cost_delete_per_byte: Some(40),
2582 obj_access_cost_verify_per_byte: Some(200),
2583 obj_data_cost_refundable: Some(100),
2584 obj_metadata_cost_non_refundable: Some(50),
2585 gas_model_version: Some(1),
2586 storage_rebate_rate: Some(9900),
2587 storage_fund_reinvest_rate: Some(500),
2588 reward_slashing_rate: Some(5000),
2589 storage_gas_price: Some(1),
2590 accumulator_object_storage_cost: None,
2591 max_transactions_per_checkpoint: Some(10_000),
2592 max_checkpoint_size_bytes: Some(30 * 1024 * 1024),
2593
2594 buffer_stake_for_protocol_upgrade_bps: Some(0),
2597
2598 address_from_bytes_cost_base: Some(52),
2602 address_to_u256_cost_base: Some(52),
2604 address_from_u256_cost_base: Some(52),
2606
2607 config_read_setting_impl_cost_base: None,
2610 config_read_setting_impl_cost_per_byte: None,
2611
2612 package_original_package_id_impl_cost_base: None,
2613 package_original_package_id_impl_cost_per_byte: None,
2614
2615 dynamic_field_hash_type_and_key_cost_base: Some(100),
2618 dynamic_field_hash_type_and_key_type_cost_per_byte: Some(2),
2619 dynamic_field_hash_type_and_key_value_cost_per_byte: Some(2),
2620 dynamic_field_hash_type_and_key_type_tag_cost_per_byte: Some(2),
2621 dynamic_field_add_child_object_cost_base: Some(100),
2623 dynamic_field_add_child_object_type_cost_per_byte: Some(10),
2624 dynamic_field_add_child_object_value_cost_per_byte: Some(10),
2625 dynamic_field_add_child_object_struct_tag_cost_per_byte: Some(10),
2626 dynamic_field_borrow_child_object_cost_base: Some(100),
2628 dynamic_field_borrow_child_object_child_ref_cost_per_byte: Some(10),
2629 dynamic_field_borrow_child_object_type_cost_per_byte: Some(10),
2630 dynamic_field_remove_child_object_cost_base: Some(100),
2632 dynamic_field_remove_child_object_child_cost_per_byte: Some(2),
2633 dynamic_field_remove_child_object_type_cost_per_byte: Some(2),
2634 dynamic_field_has_child_object_cost_base: Some(100),
2636 dynamic_field_has_child_object_with_ty_cost_base: Some(100),
2638 dynamic_field_has_child_object_with_ty_type_cost_per_byte: Some(2),
2639 dynamic_field_has_child_object_with_ty_type_tag_cost_per_byte: Some(2),
2640
2641 scratch_add_cost_base: None,
2643 scratch_read_cost_base: None,
2644 scratch_read_value_cost: None,
2645 scratch_remove_cost_base: None,
2646 scratch_exists_cost_base: None,
2647 scratch_exists_with_type_cost_base: None,
2648 scratch_exists_with_type_type_cost: None,
2649 max_scratch_pad_size: None,
2650
2651 event_emit_cost_base: Some(52),
2654 event_emit_value_size_derivation_cost_per_byte: Some(2),
2655 event_emit_tag_size_derivation_cost_per_byte: Some(5),
2656 event_emit_output_cost_per_byte: Some(10),
2657 event_emit_auth_stream_cost: None,
2658
2659 object_borrow_uid_cost_base: Some(52),
2662 object_delete_impl_cost_base: Some(52),
2664 object_record_new_uid_cost_base: Some(52),
2666 object_record_new_uid_from_hash_cost_base: None,
2669
2670 transfer_transfer_internal_cost_base: Some(52),
2673 transfer_party_transfer_internal_cost_base: None,
2675 transfer_freeze_object_cost_base: Some(52),
2677 transfer_share_object_cost_base: Some(52),
2679 transfer_receive_object_cost_base: None,
2680 transfer_receive_object_type_cost_per_byte: None,
2681 transfer_receive_object_cost_per_byte: None,
2682
2683 tx_context_derive_id_cost_base: Some(52),
2686 tx_context_fresh_id_cost_base: None,
2687 tx_context_sender_cost_base: None,
2688 tx_context_epoch_cost_base: None,
2689 tx_context_epoch_timestamp_ms_cost_base: None,
2690 tx_context_sponsor_cost_base: None,
2691 tx_context_rgp_cost_base: None,
2692 tx_context_gas_price_cost_base: None,
2693 tx_context_gas_budget_cost_base: None,
2694 tx_context_ids_created_cost_base: None,
2695 tx_context_replace_cost_base: None,
2696
2697 types_is_one_time_witness_cost_base: Some(52),
2700 types_is_one_time_witness_type_tag_cost_per_byte: Some(2),
2701 types_is_one_time_witness_type_cost_per_byte: Some(2),
2702
2703 validator_validate_metadata_cost_base: Some(52),
2706 validator_validate_metadata_data_cost_per_byte: Some(2),
2707
2708 crypto_invalid_arguments_cost: Some(100),
2710 bls12381_bls12381_min_sig_verify_cost_base: Some(52),
2712 bls12381_bls12381_min_sig_verify_msg_cost_per_byte: Some(2),
2713 bls12381_bls12381_min_sig_verify_msg_cost_per_block: Some(2),
2714
2715 bls12381_bls12381_min_pk_verify_cost_base: Some(52),
2717 bls12381_bls12381_min_pk_verify_msg_cost_per_byte: Some(2),
2718 bls12381_bls12381_min_pk_verify_msg_cost_per_block: Some(2),
2719
2720 ecdsa_k1_ecrecover_keccak256_cost_base: Some(52),
2722 ecdsa_k1_ecrecover_keccak256_msg_cost_per_byte: Some(2),
2723 ecdsa_k1_ecrecover_keccak256_msg_cost_per_block: Some(2),
2724 ecdsa_k1_ecrecover_sha256_cost_base: Some(52),
2725 ecdsa_k1_ecrecover_sha256_msg_cost_per_byte: Some(2),
2726 ecdsa_k1_ecrecover_sha256_msg_cost_per_block: Some(2),
2727
2728 ecdsa_k1_decompress_pubkey_cost_base: Some(52),
2730
2731 ecdsa_k1_secp256k1_verify_keccak256_cost_base: Some(52),
2733 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_byte: Some(2),
2734 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_block: Some(2),
2735 ecdsa_k1_secp256k1_verify_sha256_cost_base: Some(52),
2736 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_byte: Some(2),
2737 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_block: Some(2),
2738
2739 ecdsa_r1_ecrecover_keccak256_cost_base: Some(52),
2741 ecdsa_r1_ecrecover_keccak256_msg_cost_per_byte: Some(2),
2742 ecdsa_r1_ecrecover_keccak256_msg_cost_per_block: Some(2),
2743 ecdsa_r1_ecrecover_sha256_cost_base: Some(52),
2744 ecdsa_r1_ecrecover_sha256_msg_cost_per_byte: Some(2),
2745 ecdsa_r1_ecrecover_sha256_msg_cost_per_block: Some(2),
2746
2747 ecdsa_r1_secp256r1_verify_keccak256_cost_base: Some(52),
2749 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_byte: Some(2),
2750 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_block: Some(2),
2751 ecdsa_r1_secp256r1_verify_sha256_cost_base: Some(52),
2752 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_byte: Some(2),
2753 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_block: Some(2),
2754
2755 ecvrf_ecvrf_verify_cost_base: Some(52),
2757 ecvrf_ecvrf_verify_alpha_string_cost_per_byte: Some(2),
2758 ecvrf_ecvrf_verify_alpha_string_cost_per_block: Some(2),
2759
2760 ed25519_ed25519_verify_cost_base: Some(52),
2762 ed25519_ed25519_verify_msg_cost_per_byte: Some(2),
2763 ed25519_ed25519_verify_msg_cost_per_block: Some(2),
2764
2765 groth16_prepare_verifying_key_bls12381_cost_base: Some(52),
2767 groth16_prepare_verifying_key_bn254_cost_base: Some(52),
2768
2769 groth16_verify_groth16_proof_internal_bls12381_cost_base: Some(52),
2771 groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input: Some(2),
2772 groth16_verify_groth16_proof_internal_bn254_cost_base: Some(52),
2773 groth16_verify_groth16_proof_internal_bn254_cost_per_public_input: Some(2),
2774 groth16_verify_groth16_proof_internal_public_input_cost_per_byte: Some(2),
2775
2776 hash_blake2b256_cost_base: Some(52),
2778 hash_blake2b256_data_cost_per_byte: Some(2),
2779 hash_blake2b256_data_cost_per_block: Some(2),
2780
2781 hash_keccak256_cost_base: Some(52),
2783 hash_keccak256_data_cost_per_byte: Some(2),
2784 hash_keccak256_data_cost_per_block: Some(2),
2785
2786 poseidon_bn254_cost_base: None,
2787 poseidon_bn254_cost_per_block: None,
2788
2789 hmac_hmac_sha3_256_cost_base: Some(52),
2791 hmac_hmac_sha3_256_input_cost_per_byte: Some(2),
2792 hmac_hmac_sha3_256_input_cost_per_block: Some(2),
2793
2794 group_ops_bls12381_decode_scalar_cost: None,
2796 group_ops_bls12381_decode_g1_cost: None,
2797 group_ops_bls12381_decode_g2_cost: None,
2798 group_ops_bls12381_decode_gt_cost: None,
2799 group_ops_bls12381_scalar_add_cost: None,
2800 group_ops_bls12381_g1_add_cost: None,
2801 group_ops_bls12381_g2_add_cost: None,
2802 group_ops_bls12381_gt_add_cost: None,
2803 group_ops_bls12381_scalar_sub_cost: None,
2804 group_ops_bls12381_g1_sub_cost: None,
2805 group_ops_bls12381_g2_sub_cost: None,
2806 group_ops_bls12381_gt_sub_cost: None,
2807 group_ops_bls12381_scalar_mul_cost: None,
2808 group_ops_bls12381_g1_mul_cost: None,
2809 group_ops_bls12381_g2_mul_cost: None,
2810 group_ops_bls12381_gt_mul_cost: None,
2811 group_ops_bls12381_scalar_div_cost: None,
2812 group_ops_bls12381_g1_div_cost: None,
2813 group_ops_bls12381_g2_div_cost: None,
2814 group_ops_bls12381_gt_div_cost: None,
2815 group_ops_bls12381_g1_hash_to_base_cost: None,
2816 group_ops_bls12381_g2_hash_to_base_cost: None,
2817 group_ops_bls12381_g1_hash_to_cost_per_byte: None,
2818 group_ops_bls12381_g2_hash_to_cost_per_byte: None,
2819 group_ops_bls12381_g1_msm_base_cost: None,
2820 group_ops_bls12381_g2_msm_base_cost: None,
2821 group_ops_bls12381_g1_msm_base_cost_per_input: None,
2822 group_ops_bls12381_g2_msm_base_cost_per_input: None,
2823 group_ops_bls12381_msm_max_len: None,
2824 group_ops_bls12381_pairing_cost: None,
2825 group_ops_bls12381_g1_to_uncompressed_g1_cost: None,
2826 group_ops_bls12381_uncompressed_g1_to_g1_cost: None,
2827 group_ops_bls12381_uncompressed_g1_sum_base_cost: None,
2828 group_ops_bls12381_uncompressed_g1_sum_cost_per_term: None,
2829 group_ops_bls12381_uncompressed_g1_sum_max_terms: None,
2830
2831 group_ops_ristretto_decode_scalar_cost: None,
2832 group_ops_ristretto_decode_point_cost: None,
2833 group_ops_ristretto_scalar_add_cost: None,
2834 group_ops_ristretto_point_add_cost: None,
2835 group_ops_ristretto_scalar_sub_cost: None,
2836 group_ops_ristretto_point_sub_cost: None,
2837 group_ops_ristretto_scalar_mul_cost: None,
2838 group_ops_ristretto_point_mul_cost: None,
2839 group_ops_ristretto_scalar_div_cost: None,
2840 group_ops_ristretto_point_div_cost: None,
2841
2842 verify_bulletproofs_ristretto255_base_cost: None,
2843 verify_bulletproofs_ristretto255_cost_per_bit_and_commitment: None,
2844
2845 check_zklogin_id_cost_base: None,
2847 check_zklogin_issuer_cost_base: None,
2849
2850 vdf_verify_vdf_cost: None,
2851 vdf_hash_to_input_cost: None,
2852
2853 nitro_attestation_parse_base_cost: None,
2855 nitro_attestation_parse_cost_per_byte: None,
2856 nitro_attestation_verify_base_cost: None,
2857 nitro_attestation_verify_cost_per_cert: None,
2858
2859 bcs_per_byte_serialized_cost: None,
2860 bcs_legacy_min_output_size_cost: None,
2861 bcs_failure_cost: None,
2862 hash_sha2_256_base_cost: None,
2863 hash_sha2_256_per_byte_cost: None,
2864 hash_sha2_256_legacy_min_input_len_cost: None,
2865 hash_sha3_256_base_cost: None,
2866 hash_sha3_256_per_byte_cost: None,
2867 hash_sha3_256_legacy_min_input_len_cost: None,
2868 type_name_get_base_cost: None,
2869 type_name_get_per_byte_cost: None,
2870 type_name_id_base_cost: None,
2871 string_check_utf8_base_cost: None,
2872 string_check_utf8_per_byte_cost: None,
2873 string_is_char_boundary_base_cost: None,
2874 string_sub_string_base_cost: None,
2875 string_sub_string_per_byte_cost: None,
2876 string_index_of_base_cost: None,
2877 string_index_of_per_byte_pattern_cost: None,
2878 string_index_of_per_byte_searched_cost: None,
2879 vector_empty_base_cost: None,
2880 vector_length_base_cost: None,
2881 vector_push_back_base_cost: None,
2882 vector_push_back_legacy_per_abstract_memory_unit_cost: None,
2883 vector_borrow_base_cost: None,
2884 vector_pop_back_base_cost: None,
2885 vector_destroy_empty_base_cost: None,
2886 vector_swap_base_cost: None,
2887 debug_print_base_cost: None,
2888 debug_print_stack_trace_base_cost: None,
2889
2890 max_size_written_objects: None,
2891 max_size_written_objects_system_tx: None,
2892
2893 max_move_identifier_len: None,
2900 max_move_value_depth: None,
2901 max_move_enum_variants: None,
2902
2903 gas_rounding_step: None,
2904
2905 execution_version: None,
2906
2907 max_event_emit_size_total: None,
2908
2909 consensus_bad_nodes_stake_threshold: None,
2910
2911 max_jwk_votes_per_validator_per_epoch: None,
2912
2913 max_age_of_jwk_in_epochs: None,
2914
2915 random_beacon_reduction_allowed_delta: None,
2916
2917 random_beacon_reduction_lower_bound: None,
2918
2919 random_beacon_dkg_timeout_round: None,
2920
2921 random_beacon_min_round_interval_ms: None,
2922
2923 random_beacon_dkg_version: None,
2924
2925 consensus_max_transaction_size_bytes: None,
2926
2927 consensus_max_transactions_in_block_bytes: None,
2928
2929 consensus_max_num_transactions_in_block: None,
2930
2931 consensus_voting_rounds: None,
2932
2933 max_accumulated_txn_cost_per_object_in_narwhal_commit: None,
2934
2935 max_deferral_rounds_for_congestion_control: None,
2936
2937 epoch_close_deadline_ms: None,
2938
2939 max_txn_cost_overage_per_object_in_commit: None,
2940
2941 allowed_txn_cost_overage_burst_per_object_in_commit: None,
2942
2943 min_checkpoint_interval_ms: None,
2944
2945 checkpoint_summary_version_specific_data: None,
2946
2947 max_soft_bundle_size: None,
2948
2949 bridge_should_try_to_finalize_committee: None,
2950
2951 max_accumulated_txn_cost_per_object_in_mysticeti_commit: None,
2952
2953 max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit: None,
2954
2955 consensus_gc_depth: None,
2956
2957 gas_budget_based_txn_cost_cap_factor: None,
2958
2959 gas_budget_based_txn_cost_absolute_cap_commit_count: None,
2960
2961 sip_45_consensus_amplification_threshold: None,
2962
2963 use_object_per_epoch_marker_table_v2: None,
2964
2965 consensus_commit_rate_estimation_window_size: None,
2966
2967 aliased_addresses: vec![],
2968
2969 translation_per_command_base_charge: None,
2970 translation_per_input_base_charge: None,
2971 translation_pure_input_per_byte_charge: None,
2972 translation_per_type_node_charge: None,
2973 translation_per_reference_node_charge: None,
2974 translation_per_linkage_entry_charge: None,
2975
2976 max_updates_per_settlement_txn: None,
2977
2978 gasless_max_computation_units: None,
2979 gasless_allowed_token_types: None,
2980 gasless_max_unused_inputs: None,
2981 gasless_max_pure_input_bytes: None,
2982 gasless_max_tps: None,
2983 include_special_package_amendments: None,
2984 gasless_max_tx_size_bytes: None,
2985 };
2988 for cur in 2..=version.0 {
2989 match cur {
2990 1 => unreachable!(),
2991 2 => {
2992 cfg.feature_flags.advance_epoch_start_time_in_safe_mode = true;
2993 }
2994 3 => {
2995 cfg.gas_model_version = Some(2);
2997 cfg.max_tx_gas = Some(50_000_000_000);
2999 cfg.base_tx_cost_fixed = Some(2_000);
3001 cfg.storage_gas_price = Some(76);
3003 cfg.feature_flags.loaded_child_objects_fixed = true;
3004 cfg.max_size_written_objects = Some(5 * 1000 * 1000);
3007 cfg.max_size_written_objects_system_tx = Some(50 * 1000 * 1000);
3010 cfg.feature_flags.package_upgrades = true;
3011 }
3012 4 => {
3017 cfg.reward_slashing_rate = Some(10000);
3019 cfg.gas_model_version = Some(3);
3021 }
3022 5 => {
3023 cfg.feature_flags.missing_type_is_compatibility_error = true;
3024 cfg.gas_model_version = Some(4);
3025 cfg.feature_flags.scoring_decision_with_validity_cutoff = true;
3026 }
3030 6 => {
3031 cfg.gas_model_version = Some(5);
3032 cfg.buffer_stake_for_protocol_upgrade_bps = Some(5000);
3033 cfg.feature_flags.consensus_order_end_of_epoch_last = true;
3034 }
3035 7 => {
3036 cfg.feature_flags.disallow_adding_abilities_on_upgrade = true;
3037 cfg.feature_flags
3038 .disable_invariant_violation_check_in_swap_loc = true;
3039 cfg.feature_flags.ban_entry_init = true;
3040 cfg.feature_flags.package_digest_hash_module = true;
3041 }
3042 8 => {
3043 cfg.feature_flags
3044 .disallow_change_struct_type_params_on_upgrade = true;
3045 }
3046 9 => {
3047 cfg.max_move_identifier_len = Some(128);
3049 cfg.feature_flags.no_extraneous_module_bytes = true;
3050 cfg.feature_flags
3051 .advance_to_highest_supported_protocol_version = true;
3052 }
3053 10 => {
3054 cfg.max_verifier_meter_ticks_per_function = Some(16_000_000);
3055 cfg.max_meter_ticks_per_module = Some(16_000_000);
3056 }
3057 11 => {
3058 cfg.max_move_value_depth = Some(128);
3059 }
3060 12 => {
3061 cfg.feature_flags.narwhal_versioned_metadata = true;
3062 if chain != Chain::Mainnet {
3063 cfg.feature_flags.commit_root_state_digest = true;
3064 }
3065
3066 if chain != Chain::Mainnet && chain != Chain::Testnet {
3067 cfg.feature_flags.zklogin_auth = true;
3068 }
3069 }
3070 13 => {}
3071 14 => {
3072 cfg.gas_rounding_step = Some(1_000);
3073 cfg.gas_model_version = Some(6);
3074 }
3075 15 => {
3076 cfg.feature_flags.consensus_transaction_ordering =
3077 ConsensusTransactionOrdering::ByGasPrice;
3078 }
3079 16 => {
3080 cfg.feature_flags.simplified_unwrap_then_delete = true;
3081 }
3082 17 => {
3083 cfg.feature_flags.upgraded_multisig_supported = true;
3084 }
3085 18 => {
3086 cfg.execution_version = Some(1);
3087 cfg.feature_flags.txn_base_cost_as_multiplier = true;
3096 cfg.base_tx_cost_fixed = Some(1_000);
3098 }
3099 19 => {
3100 cfg.max_num_event_emit = Some(1024);
3101 cfg.max_event_emit_size_total = Some(
3104 256 * 250 * 1024, );
3106 }
3107 20 => {
3108 cfg.feature_flags.commit_root_state_digest = true;
3109
3110 if chain != Chain::Mainnet {
3111 cfg.feature_flags.narwhal_new_leader_election_schedule = true;
3112 cfg.consensus_bad_nodes_stake_threshold = Some(20);
3113 }
3114 }
3115
3116 21 => {
3117 if chain != Chain::Mainnet {
3118 cfg.feature_flags.zklogin_supported_providers = BTreeSet::from([
3119 "Google".to_string(),
3120 "Facebook".to_string(),
3121 "Twitch".to_string(),
3122 ]);
3123 }
3124 }
3125 22 => {
3126 cfg.feature_flags.loaded_child_object_format = true;
3127 }
3128 23 => {
3129 cfg.feature_flags.loaded_child_object_format_type = true;
3130 cfg.feature_flags.narwhal_new_leader_election_schedule = true;
3131 cfg.consensus_bad_nodes_stake_threshold = Some(20);
3137 }
3138 24 => {
3139 cfg.feature_flags.simple_conservation_checks = true;
3140 cfg.max_publish_or_upgrade_per_ptb = Some(5);
3141
3142 cfg.feature_flags.end_of_epoch_transaction_supported = true;
3143
3144 if chain != Chain::Mainnet {
3145 cfg.feature_flags.enable_jwk_consensus_updates = true;
3146 cfg.max_jwk_votes_per_validator_per_epoch = Some(240);
3148 cfg.max_age_of_jwk_in_epochs = Some(1);
3149 }
3150 }
3151 25 => {
3152 cfg.feature_flags.zklogin_supported_providers = BTreeSet::from([
3154 "Google".to_string(),
3155 "Facebook".to_string(),
3156 "Twitch".to_string(),
3157 ]);
3158 cfg.feature_flags.zklogin_auth = true;
3159
3160 cfg.feature_flags.enable_jwk_consensus_updates = true;
3162 cfg.max_jwk_votes_per_validator_per_epoch = Some(240);
3163 cfg.max_age_of_jwk_in_epochs = Some(1);
3164 }
3165 26 => {
3166 cfg.gas_model_version = Some(7);
3167 if chain != Chain::Mainnet && chain != Chain::Testnet {
3169 cfg.transfer_receive_object_cost_base = Some(52);
3170 cfg.feature_flags.receive_objects = true;
3171 }
3172 }
3173 27 => {
3174 cfg.gas_model_version = Some(8);
3175 }
3176 28 => {
3177 cfg.check_zklogin_id_cost_base = Some(200);
3179 cfg.check_zklogin_issuer_cost_base = Some(200);
3181
3182 if chain != Chain::Mainnet && chain != Chain::Testnet {
3184 cfg.feature_flags.enable_effects_v2 = true;
3185 }
3186 }
3187 29 => {
3188 cfg.feature_flags.verify_legacy_zklogin_address = true;
3189 }
3190 30 => {
3191 if chain != Chain::Mainnet {
3193 cfg.feature_flags.narwhal_certificate_v2 = true;
3194 }
3195
3196 cfg.random_beacon_reduction_allowed_delta = Some(800);
3197 if chain != Chain::Mainnet {
3199 cfg.feature_flags.enable_effects_v2 = true;
3200 }
3201
3202 cfg.feature_flags.zklogin_supported_providers = BTreeSet::default();
3206
3207 cfg.feature_flags.recompute_has_public_transfer_in_execution = true;
3208 }
3209 31 => {
3210 cfg.execution_version = Some(2);
3211 if chain != Chain::Mainnet && chain != Chain::Testnet {
3213 cfg.feature_flags.shared_object_deletion = true;
3214 }
3215 }
3216 32 => {
3217 if chain != Chain::Mainnet {
3219 cfg.feature_flags.accept_zklogin_in_multisig = true;
3220 }
3221 if chain != Chain::Mainnet {
3223 cfg.transfer_receive_object_cost_base = Some(52);
3224 cfg.feature_flags.receive_objects = true;
3225 }
3226 if chain != Chain::Mainnet && chain != Chain::Testnet {
3228 cfg.feature_flags.random_beacon = true;
3229 cfg.random_beacon_reduction_lower_bound = Some(1600);
3230 cfg.random_beacon_dkg_timeout_round = Some(3000);
3231 cfg.random_beacon_min_round_interval_ms = Some(150);
3232 }
3233 if chain != Chain::Testnet && chain != Chain::Mainnet {
3235 cfg.feature_flags.include_consensus_digest_in_prologue = true;
3236 }
3237
3238 cfg.feature_flags.narwhal_certificate_v2 = true;
3240 }
3241 33 => {
3242 cfg.feature_flags.hardened_otw_check = true;
3243 cfg.feature_flags.allow_receiving_object_id = true;
3244
3245 cfg.transfer_receive_object_cost_base = Some(52);
3247 cfg.feature_flags.receive_objects = true;
3248
3249 if chain != Chain::Mainnet {
3251 cfg.feature_flags.shared_object_deletion = true;
3252 }
3253
3254 cfg.feature_flags.enable_effects_v2 = true;
3255 }
3256 34 => {}
3257 35 => {
3258 if chain != Chain::Mainnet && chain != Chain::Testnet {
3260 cfg.feature_flags.enable_poseidon = true;
3261 cfg.poseidon_bn254_cost_base = Some(260);
3262 cfg.poseidon_bn254_cost_per_block = Some(10);
3263 }
3264
3265 cfg.feature_flags.enable_coin_deny_list = true;
3266 }
3267 36 => {
3268 if chain != Chain::Mainnet && chain != Chain::Testnet {
3270 cfg.feature_flags.enable_group_ops_native_functions = true;
3271 cfg.feature_flags.enable_group_ops_native_function_msm = true;
3272 cfg.group_ops_bls12381_decode_scalar_cost = Some(52);
3274 cfg.group_ops_bls12381_decode_g1_cost = Some(52);
3275 cfg.group_ops_bls12381_decode_g2_cost = Some(52);
3276 cfg.group_ops_bls12381_decode_gt_cost = Some(52);
3277 cfg.group_ops_bls12381_scalar_add_cost = Some(52);
3278 cfg.group_ops_bls12381_g1_add_cost = Some(52);
3279 cfg.group_ops_bls12381_g2_add_cost = Some(52);
3280 cfg.group_ops_bls12381_gt_add_cost = Some(52);
3281 cfg.group_ops_bls12381_scalar_sub_cost = Some(52);
3282 cfg.group_ops_bls12381_g1_sub_cost = Some(52);
3283 cfg.group_ops_bls12381_g2_sub_cost = Some(52);
3284 cfg.group_ops_bls12381_gt_sub_cost = Some(52);
3285 cfg.group_ops_bls12381_scalar_mul_cost = Some(52);
3286 cfg.group_ops_bls12381_g1_mul_cost = Some(52);
3287 cfg.group_ops_bls12381_g2_mul_cost = Some(52);
3288 cfg.group_ops_bls12381_gt_mul_cost = Some(52);
3289 cfg.group_ops_bls12381_scalar_div_cost = Some(52);
3290 cfg.group_ops_bls12381_g1_div_cost = Some(52);
3291 cfg.group_ops_bls12381_g2_div_cost = Some(52);
3292 cfg.group_ops_bls12381_gt_div_cost = Some(52);
3293 cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(52);
3294 cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(52);
3295 cfg.group_ops_bls12381_g1_hash_to_cost_per_byte = Some(2);
3296 cfg.group_ops_bls12381_g2_hash_to_cost_per_byte = Some(2);
3297 cfg.group_ops_bls12381_g1_msm_base_cost = Some(52);
3298 cfg.group_ops_bls12381_g2_msm_base_cost = Some(52);
3299 cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(52);
3300 cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(52);
3301 cfg.group_ops_bls12381_msm_max_len = Some(32);
3302 cfg.group_ops_bls12381_pairing_cost = Some(52);
3303 }
3304 cfg.feature_flags.shared_object_deletion = true;
3306
3307 cfg.consensus_max_transaction_size_bytes = Some(256 * 1024); cfg.consensus_max_transactions_in_block_bytes = Some(6 * 1_024 * 1024);
3309 }
3311 37 => {
3312 cfg.feature_flags.reject_mutable_random_on_entry_functions = true;
3313
3314 if chain != Chain::Mainnet {
3316 cfg.feature_flags.include_consensus_digest_in_prologue = true;
3317 }
3318 }
3319 38 => {
3320 cfg.binary_module_handles = Some(100);
3321 cfg.binary_struct_handles = Some(300);
3322 cfg.binary_function_handles = Some(1500);
3323 cfg.binary_function_instantiations = Some(750);
3324 cfg.binary_signatures = Some(1000);
3325 cfg.binary_constant_pool = Some(4000);
3329 cfg.binary_identifiers = Some(10000);
3330 cfg.binary_address_identifiers = Some(100);
3331 cfg.binary_struct_defs = Some(200);
3332 cfg.binary_struct_def_instantiations = Some(100);
3333 cfg.binary_function_defs = Some(1000);
3334 cfg.binary_field_handles = Some(500);
3335 cfg.binary_field_instantiations = Some(250);
3336 cfg.binary_friend_decls = Some(100);
3337 cfg.max_package_dependencies = Some(32);
3339 cfg.max_modules_in_publish = Some(64);
3340 cfg.execution_version = Some(3);
3342 }
3343 39 => {
3344 }
3346 40 => {}
3347 41 => {
3348 cfg.feature_flags.enable_group_ops_native_functions = true;
3350 cfg.group_ops_bls12381_decode_scalar_cost = Some(52);
3352 cfg.group_ops_bls12381_decode_g1_cost = Some(52);
3353 cfg.group_ops_bls12381_decode_g2_cost = Some(52);
3354 cfg.group_ops_bls12381_decode_gt_cost = Some(52);
3355 cfg.group_ops_bls12381_scalar_add_cost = Some(52);
3356 cfg.group_ops_bls12381_g1_add_cost = Some(52);
3357 cfg.group_ops_bls12381_g2_add_cost = Some(52);
3358 cfg.group_ops_bls12381_gt_add_cost = Some(52);
3359 cfg.group_ops_bls12381_scalar_sub_cost = Some(52);
3360 cfg.group_ops_bls12381_g1_sub_cost = Some(52);
3361 cfg.group_ops_bls12381_g2_sub_cost = Some(52);
3362 cfg.group_ops_bls12381_gt_sub_cost = Some(52);
3363 cfg.group_ops_bls12381_scalar_mul_cost = Some(52);
3364 cfg.group_ops_bls12381_g1_mul_cost = Some(52);
3365 cfg.group_ops_bls12381_g2_mul_cost = Some(52);
3366 cfg.group_ops_bls12381_gt_mul_cost = Some(52);
3367 cfg.group_ops_bls12381_scalar_div_cost = Some(52);
3368 cfg.group_ops_bls12381_g1_div_cost = Some(52);
3369 cfg.group_ops_bls12381_g2_div_cost = Some(52);
3370 cfg.group_ops_bls12381_gt_div_cost = Some(52);
3371 cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(52);
3372 cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(52);
3373 cfg.group_ops_bls12381_g1_hash_to_cost_per_byte = Some(2);
3374 cfg.group_ops_bls12381_g2_hash_to_cost_per_byte = Some(2);
3375 cfg.group_ops_bls12381_g1_msm_base_cost = Some(52);
3376 cfg.group_ops_bls12381_g2_msm_base_cost = Some(52);
3377 cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(52);
3378 cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(52);
3379 cfg.group_ops_bls12381_msm_max_len = Some(32);
3380 cfg.group_ops_bls12381_pairing_cost = Some(52);
3381 }
3382 42 => {}
3383 43 => {
3384 cfg.feature_flags.zklogin_max_epoch_upper_bound_delta = Some(30);
3385 cfg.max_meter_ticks_per_package = Some(16_000_000);
3386 }
3387 44 => {
3388 cfg.feature_flags.include_consensus_digest_in_prologue = true;
3390 if chain != Chain::Mainnet {
3392 cfg.feature_flags.consensus_choice = ConsensusChoice::SwapEachEpoch;
3393 }
3394 }
3395 45 => {
3396 if chain != Chain::Testnet && chain != Chain::Mainnet {
3398 cfg.feature_flags.consensus_network = ConsensusNetwork::Tonic;
3399 }
3400
3401 if chain != Chain::Mainnet {
3402 cfg.feature_flags.mysticeti_leader_scoring_and_schedule = true;
3404 }
3405 cfg.min_move_binary_format_version = Some(6);
3406 cfg.feature_flags.accept_zklogin_in_multisig = true;
3407
3408 if chain != Chain::Mainnet && chain != Chain::Testnet {
3412 cfg.feature_flags.bridge = true;
3413 }
3414 }
3415 46 => {
3416 if chain != Chain::Mainnet {
3418 cfg.feature_flags.bridge = true;
3419 }
3420
3421 cfg.feature_flags.reshare_at_same_initial_version = true;
3423 }
3424 47 => {}
3425 48 => {
3426 cfg.feature_flags.consensus_network = ConsensusNetwork::Tonic;
3428
3429 cfg.feature_flags.resolve_abort_locations_to_package_id = true;
3431
3432 if chain != Chain::Mainnet {
3434 cfg.feature_flags.random_beacon = true;
3435 cfg.random_beacon_reduction_lower_bound = Some(1600);
3436 cfg.random_beacon_dkg_timeout_round = Some(3000);
3437 cfg.random_beacon_min_round_interval_ms = Some(200);
3438 }
3439
3440 cfg.feature_flags.mysticeti_use_committed_subdag_digest = true;
3442 }
3443 49 => {
3444 if chain != Chain::Testnet && chain != Chain::Mainnet {
3445 cfg.move_binary_format_version = Some(7);
3446 }
3447
3448 if chain != Chain::Mainnet && chain != Chain::Testnet {
3450 cfg.feature_flags.enable_vdf = true;
3451 cfg.vdf_verify_vdf_cost = Some(1500);
3454 cfg.vdf_hash_to_input_cost = Some(100);
3455 }
3456
3457 if chain != Chain::Testnet && chain != Chain::Mainnet {
3459 cfg.feature_flags
3460 .record_consensus_determined_version_assignments_in_prologue = true;
3461 }
3462
3463 if chain != Chain::Mainnet {
3465 cfg.feature_flags.consensus_choice = ConsensusChoice::Mysticeti;
3466 }
3467
3468 cfg.feature_flags.fresh_vm_on_framework_upgrade = true;
3470 }
3471 50 => {
3472 if chain != Chain::Mainnet {
3474 cfg.checkpoint_summary_version_specific_data = Some(1);
3475 cfg.min_checkpoint_interval_ms = Some(200);
3476 }
3477
3478 if chain != Chain::Testnet && chain != Chain::Mainnet {
3480 cfg.feature_flags
3481 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = true;
3482 }
3483
3484 cfg.feature_flags.mysticeti_num_leaders_per_round = Some(1);
3485
3486 cfg.max_deferral_rounds_for_congestion_control = Some(10);
3488 }
3489 51 => {
3490 cfg.random_beacon_dkg_version = Some(1);
3491
3492 if chain != Chain::Testnet && chain != Chain::Mainnet {
3493 cfg.feature_flags.enable_coin_deny_list_v2 = true;
3494 }
3495 }
3496 52 => {
3497 if chain != Chain::Mainnet {
3498 cfg.feature_flags.soft_bundle = true;
3499 cfg.max_soft_bundle_size = Some(5);
3500 }
3501
3502 cfg.config_read_setting_impl_cost_base = Some(100);
3503 cfg.config_read_setting_impl_cost_per_byte = Some(40);
3504
3505 if chain != Chain::Testnet && chain != Chain::Mainnet {
3507 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(100);
3508 cfg.feature_flags.per_object_congestion_control_mode =
3509 PerObjectCongestionControlMode::TotalTxCount;
3510 }
3511
3512 cfg.feature_flags.consensus_choice = ConsensusChoice::Mysticeti;
3514
3515 cfg.feature_flags.mysticeti_leader_scoring_and_schedule = true;
3517
3518 cfg.checkpoint_summary_version_specific_data = Some(1);
3520 cfg.min_checkpoint_interval_ms = Some(200);
3521
3522 if chain != Chain::Mainnet {
3524 cfg.feature_flags
3525 .record_consensus_determined_version_assignments_in_prologue = true;
3526 cfg.feature_flags
3527 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = true;
3528 }
3529 if chain != Chain::Mainnet {
3531 cfg.move_binary_format_version = Some(7);
3532 }
3533
3534 if chain != Chain::Testnet && chain != Chain::Mainnet {
3535 cfg.feature_flags.passkey_auth = true;
3536 }
3537 cfg.feature_flags.enable_coin_deny_list_v2 = true;
3538 }
3539 53 => {
3540 cfg.bridge_should_try_to_finalize_committee = Some(chain != Chain::Mainnet);
3542
3543 cfg.feature_flags
3545 .record_consensus_determined_version_assignments_in_prologue = true;
3546 cfg.feature_flags
3547 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = true;
3548
3549 if chain == Chain::Unknown {
3550 cfg.feature_flags.authority_capabilities_v2 = true;
3551 }
3552
3553 if chain != Chain::Mainnet {
3555 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(100);
3556 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(10);
3557 cfg.feature_flags.per_object_congestion_control_mode =
3558 PerObjectCongestionControlMode::TotalTxCount;
3559 }
3560
3561 cfg.bcs_per_byte_serialized_cost = Some(2);
3563 cfg.bcs_legacy_min_output_size_cost = Some(1);
3564 cfg.bcs_failure_cost = Some(52);
3565 cfg.debug_print_base_cost = Some(52);
3566 cfg.debug_print_stack_trace_base_cost = Some(52);
3567 cfg.hash_sha2_256_base_cost = Some(52);
3568 cfg.hash_sha2_256_per_byte_cost = Some(2);
3569 cfg.hash_sha2_256_legacy_min_input_len_cost = Some(1);
3570 cfg.hash_sha3_256_base_cost = Some(52);
3571 cfg.hash_sha3_256_per_byte_cost = Some(2);
3572 cfg.hash_sha3_256_legacy_min_input_len_cost = Some(1);
3573 cfg.type_name_get_base_cost = Some(52);
3574 cfg.type_name_get_per_byte_cost = Some(2);
3575 cfg.string_check_utf8_base_cost = Some(52);
3576 cfg.string_check_utf8_per_byte_cost = Some(2);
3577 cfg.string_is_char_boundary_base_cost = Some(52);
3578 cfg.string_sub_string_base_cost = Some(52);
3579 cfg.string_sub_string_per_byte_cost = Some(2);
3580 cfg.string_index_of_base_cost = Some(52);
3581 cfg.string_index_of_per_byte_pattern_cost = Some(2);
3582 cfg.string_index_of_per_byte_searched_cost = Some(2);
3583 cfg.vector_empty_base_cost = Some(52);
3584 cfg.vector_length_base_cost = Some(52);
3585 cfg.vector_push_back_base_cost = Some(52);
3586 cfg.vector_push_back_legacy_per_abstract_memory_unit_cost = Some(2);
3587 cfg.vector_borrow_base_cost = Some(52);
3588 cfg.vector_pop_back_base_cost = Some(52);
3589 cfg.vector_destroy_empty_base_cost = Some(52);
3590 cfg.vector_swap_base_cost = Some(52);
3591 }
3592 54 => {
3593 cfg.feature_flags.random_beacon = true;
3595 cfg.random_beacon_reduction_lower_bound = Some(1000);
3596 cfg.random_beacon_dkg_timeout_round = Some(3000);
3597 cfg.random_beacon_min_round_interval_ms = Some(500);
3598
3599 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(100);
3601 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(10);
3602 cfg.feature_flags.per_object_congestion_control_mode =
3603 PerObjectCongestionControlMode::TotalTxCount;
3604
3605 cfg.feature_flags.soft_bundle = true;
3607 cfg.max_soft_bundle_size = Some(5);
3608 }
3609 55 => {
3610 cfg.move_binary_format_version = Some(7);
3612
3613 cfg.consensus_max_transactions_in_block_bytes = Some(512 * 1024);
3615 cfg.consensus_max_num_transactions_in_block = Some(512);
3618
3619 cfg.feature_flags.rethrow_serialization_type_layout_errors = true;
3620 }
3621 56 => {
3622 if chain == Chain::Mainnet {
3623 cfg.feature_flags.bridge = true;
3624 }
3625 }
3626 57 => {
3627 cfg.random_beacon_reduction_lower_bound = Some(800);
3629 }
3630 58 => {
3631 if chain == Chain::Mainnet {
3632 cfg.bridge_should_try_to_finalize_committee = Some(true);
3633 }
3634
3635 if chain != Chain::Mainnet && chain != Chain::Testnet {
3636 cfg.feature_flags
3638 .consensus_distributed_vote_scoring_strategy = true;
3639 }
3640 }
3641 59 => {
3642 cfg.feature_flags.consensus_round_prober = true;
3644 }
3645 60 => {
3646 cfg.max_type_to_layout_nodes = Some(512);
3647 cfg.feature_flags.validate_identifier_inputs = true;
3648 }
3649 61 => {
3650 if chain != Chain::Mainnet {
3651 cfg.feature_flags
3653 .consensus_distributed_vote_scoring_strategy = true;
3654 }
3655 cfg.random_beacon_reduction_lower_bound = Some(700);
3657
3658 if chain != Chain::Mainnet && chain != Chain::Testnet {
3659 cfg.feature_flags.mysticeti_fastpath = true;
3661 }
3662 }
3663 62 => {
3664 cfg.feature_flags.relocate_event_module = true;
3665 }
3666 63 => {
3667 cfg.feature_flags.per_object_congestion_control_mode =
3668 PerObjectCongestionControlMode::TotalGasBudgetWithCap;
3669 cfg.gas_budget_based_txn_cost_cap_factor = Some(400_000);
3670 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(18_500_000);
3671 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(240_000_000);
3672 }
3673 64 => {
3674 cfg.feature_flags.per_object_congestion_control_mode =
3675 PerObjectCongestionControlMode::TotalTxCount;
3676 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(40);
3677 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(3);
3678 }
3679 65 => {
3680 cfg.feature_flags
3682 .consensus_distributed_vote_scoring_strategy = true;
3683 }
3684 66 => {
3685 if chain == Chain::Mainnet {
3686 cfg.feature_flags
3688 .consensus_distributed_vote_scoring_strategy = false;
3689 }
3690 }
3691 67 => {
3692 cfg.feature_flags
3694 .consensus_distributed_vote_scoring_strategy = true;
3695 }
3696 68 => {
3697 cfg.group_ops_bls12381_g1_to_uncompressed_g1_cost = Some(26);
3698 cfg.group_ops_bls12381_uncompressed_g1_to_g1_cost = Some(52);
3699 cfg.group_ops_bls12381_uncompressed_g1_sum_base_cost = Some(26);
3700 cfg.group_ops_bls12381_uncompressed_g1_sum_cost_per_term = Some(13);
3701 cfg.group_ops_bls12381_uncompressed_g1_sum_max_terms = Some(2000);
3702
3703 if chain != Chain::Mainnet && chain != Chain::Testnet {
3704 cfg.feature_flags.uncompressed_g1_group_elements = true;
3705 }
3706
3707 cfg.feature_flags.per_object_congestion_control_mode =
3708 PerObjectCongestionControlMode::TotalGasBudgetWithCap;
3709 cfg.gas_budget_based_txn_cost_cap_factor = Some(400_000);
3710 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(18_500_000);
3711 cfg.max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit =
3712 Some(3_700_000); cfg.max_txn_cost_overage_per_object_in_commit = Some(u64::MAX);
3714 cfg.gas_budget_based_txn_cost_absolute_cap_commit_count = Some(50);
3715
3716 cfg.random_beacon_reduction_lower_bound = Some(500);
3718
3719 cfg.feature_flags.disallow_new_modules_in_deps_only_packages = true;
3720 }
3721 69 => {
3722 cfg.consensus_voting_rounds = Some(40);
3724
3725 if chain != Chain::Mainnet && chain != Chain::Testnet {
3726 cfg.feature_flags.consensus_smart_ancestor_selection = true;
3728 }
3729
3730 if chain != Chain::Mainnet {
3731 cfg.feature_flags.uncompressed_g1_group_elements = true;
3732 }
3733 }
3734 70 => {
3735 if chain != Chain::Mainnet {
3736 cfg.feature_flags.consensus_smart_ancestor_selection = true;
3738 cfg.feature_flags
3740 .consensus_round_prober_probe_accepted_rounds = true;
3741 }
3742
3743 cfg.poseidon_bn254_cost_per_block = Some(388);
3744
3745 cfg.gas_model_version = Some(9);
3746 cfg.feature_flags.native_charging_v2 = true;
3747 cfg.bls12381_bls12381_min_sig_verify_cost_base = Some(44064);
3748 cfg.bls12381_bls12381_min_pk_verify_cost_base = Some(49282);
3749 cfg.ecdsa_k1_secp256k1_verify_keccak256_cost_base = Some(1470);
3750 cfg.ecdsa_k1_secp256k1_verify_sha256_cost_base = Some(1470);
3751 cfg.ecdsa_r1_secp256r1_verify_sha256_cost_base = Some(4225);
3752 cfg.ecdsa_r1_secp256r1_verify_keccak256_cost_base = Some(4225);
3753 cfg.ecvrf_ecvrf_verify_cost_base = Some(4848);
3754 cfg.ed25519_ed25519_verify_cost_base = Some(1802);
3755
3756 cfg.ecdsa_r1_ecrecover_keccak256_cost_base = Some(1173);
3758 cfg.ecdsa_r1_ecrecover_sha256_cost_base = Some(1173);
3759 cfg.ecdsa_k1_ecrecover_keccak256_cost_base = Some(500);
3760 cfg.ecdsa_k1_ecrecover_sha256_cost_base = Some(500);
3761
3762 cfg.groth16_prepare_verifying_key_bls12381_cost_base = Some(53838);
3763 cfg.groth16_prepare_verifying_key_bn254_cost_base = Some(82010);
3764 cfg.groth16_verify_groth16_proof_internal_bls12381_cost_base = Some(72090);
3765 cfg.groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input =
3766 Some(8213);
3767 cfg.groth16_verify_groth16_proof_internal_bn254_cost_base = Some(115502);
3768 cfg.groth16_verify_groth16_proof_internal_bn254_cost_per_public_input =
3769 Some(9484);
3770
3771 cfg.hash_keccak256_cost_base = Some(10);
3772 cfg.hash_blake2b256_cost_base = Some(10);
3773
3774 cfg.group_ops_bls12381_decode_scalar_cost = Some(7);
3776 cfg.group_ops_bls12381_decode_g1_cost = Some(2848);
3777 cfg.group_ops_bls12381_decode_g2_cost = Some(3770);
3778 cfg.group_ops_bls12381_decode_gt_cost = Some(3068);
3779
3780 cfg.group_ops_bls12381_scalar_add_cost = Some(10);
3781 cfg.group_ops_bls12381_g1_add_cost = Some(1556);
3782 cfg.group_ops_bls12381_g2_add_cost = Some(3048);
3783 cfg.group_ops_bls12381_gt_add_cost = Some(188);
3784
3785 cfg.group_ops_bls12381_scalar_sub_cost = Some(10);
3786 cfg.group_ops_bls12381_g1_sub_cost = Some(1550);
3787 cfg.group_ops_bls12381_g2_sub_cost = Some(3019);
3788 cfg.group_ops_bls12381_gt_sub_cost = Some(497);
3789
3790 cfg.group_ops_bls12381_scalar_mul_cost = Some(11);
3791 cfg.group_ops_bls12381_g1_mul_cost = Some(4842);
3792 cfg.group_ops_bls12381_g2_mul_cost = Some(9108);
3793 cfg.group_ops_bls12381_gt_mul_cost = Some(27490);
3794
3795 cfg.group_ops_bls12381_scalar_div_cost = Some(91);
3796 cfg.group_ops_bls12381_g1_div_cost = Some(5091);
3797 cfg.group_ops_bls12381_g2_div_cost = Some(9206);
3798 cfg.group_ops_bls12381_gt_div_cost = Some(27804);
3799
3800 cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(2962);
3801 cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(8688);
3802
3803 cfg.group_ops_bls12381_g1_msm_base_cost = Some(62648);
3804 cfg.group_ops_bls12381_g2_msm_base_cost = Some(131192);
3805 cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(1333);
3806 cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(3216);
3807
3808 cfg.group_ops_bls12381_uncompressed_g1_to_g1_cost = Some(677);
3809 cfg.group_ops_bls12381_g1_to_uncompressed_g1_cost = Some(2099);
3810 cfg.group_ops_bls12381_uncompressed_g1_sum_base_cost = Some(77);
3811 cfg.group_ops_bls12381_uncompressed_g1_sum_cost_per_term = Some(26);
3812
3813 cfg.group_ops_bls12381_pairing_cost = Some(26897);
3814 cfg.group_ops_bls12381_uncompressed_g1_sum_max_terms = Some(1200);
3815
3816 cfg.validator_validate_metadata_cost_base = Some(20000);
3817 }
3818 71 => {
3819 cfg.sip_45_consensus_amplification_threshold = Some(5);
3820
3821 cfg.allowed_txn_cost_overage_burst_per_object_in_commit = Some(185_000_000);
3823 }
3824 72 => {
3825 cfg.feature_flags.convert_type_argument_error = true;
3826
3827 cfg.max_tx_gas = Some(50_000_000_000_000);
3830 cfg.max_gas_price = Some(50_000_000_000);
3832
3833 cfg.feature_flags.variant_nodes = true;
3834 }
3835 73 => {
3836 cfg.use_object_per_epoch_marker_table_v2 = Some(true);
3838
3839 if chain != Chain::Mainnet && chain != Chain::Testnet {
3840 cfg.consensus_gc_depth = Some(60);
3843 }
3844
3845 if chain != Chain::Mainnet {
3846 cfg.feature_flags.consensus_zstd_compression = true;
3848 }
3849
3850 cfg.feature_flags.consensus_smart_ancestor_selection = true;
3852 cfg.feature_flags
3854 .consensus_round_prober_probe_accepted_rounds = true;
3855
3856 cfg.feature_flags.per_object_congestion_control_mode =
3858 PerObjectCongestionControlMode::TotalGasBudgetWithCap;
3859 cfg.gas_budget_based_txn_cost_cap_factor = Some(400_000);
3860 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(37_000_000);
3861 cfg.max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit =
3862 Some(7_400_000); cfg.max_txn_cost_overage_per_object_in_commit = Some(u64::MAX);
3864 cfg.gas_budget_based_txn_cost_absolute_cap_commit_count = Some(50);
3865 cfg.allowed_txn_cost_overage_burst_per_object_in_commit = Some(370_000_000);
3866 }
3867 74 => {
3868 if chain != Chain::Mainnet && chain != Chain::Testnet {
3870 cfg.feature_flags.enable_nitro_attestation = true;
3871 }
3872 cfg.nitro_attestation_parse_base_cost = Some(53 * 50);
3873 cfg.nitro_attestation_parse_cost_per_byte = Some(50);
3874 cfg.nitro_attestation_verify_base_cost = Some(49632 * 50);
3875 cfg.nitro_attestation_verify_cost_per_cert = Some(52369 * 50);
3876
3877 cfg.feature_flags.consensus_zstd_compression = true;
3879
3880 if chain != Chain::Mainnet && chain != Chain::Testnet {
3881 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
3882 }
3883 }
3884 75 => {
3885 if chain != Chain::Mainnet {
3886 cfg.feature_flags.passkey_auth = true;
3887 }
3888 }
3889 76 => {
3890 if chain != Chain::Mainnet && chain != Chain::Testnet {
3891 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
3892 cfg.consensus_commit_rate_estimation_window_size = Some(10);
3893 }
3894 cfg.feature_flags.minimize_child_object_mutations = true;
3895
3896 if chain != Chain::Mainnet {
3897 cfg.feature_flags.accept_passkey_in_multisig = true;
3898 }
3899 }
3900 77 => {
3901 cfg.feature_flags.uncompressed_g1_group_elements = true;
3902
3903 if chain != Chain::Mainnet {
3904 cfg.consensus_gc_depth = Some(60);
3905 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
3906 }
3907 }
3908 78 => {
3909 cfg.feature_flags.move_native_context = true;
3910 cfg.tx_context_fresh_id_cost_base = Some(52);
3911 cfg.tx_context_sender_cost_base = Some(30);
3912 cfg.tx_context_epoch_cost_base = Some(30);
3913 cfg.tx_context_epoch_timestamp_ms_cost_base = Some(30);
3914 cfg.tx_context_sponsor_cost_base = Some(30);
3915 cfg.tx_context_gas_price_cost_base = Some(30);
3916 cfg.tx_context_gas_budget_cost_base = Some(30);
3917 cfg.tx_context_ids_created_cost_base = Some(30);
3918 cfg.tx_context_replace_cost_base = Some(30);
3919 cfg.gas_model_version = Some(10);
3920
3921 if chain != Chain::Mainnet {
3922 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
3923 cfg.consensus_commit_rate_estimation_window_size = Some(10);
3924
3925 cfg.feature_flags.per_object_congestion_control_mode =
3927 PerObjectCongestionControlMode::ExecutionTimeEstimate(
3928 ExecutionTimeEstimateParams {
3929 target_utilization: 30,
3930 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
3932 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
3934 stored_observations_limit: u64::MAX,
3935 stake_weighted_median_threshold: 0,
3936 default_none_duration_for_new_keys: false,
3937 observations_chunk_size: None,
3938 },
3939 );
3940 }
3941 }
3942 79 => {
3943 if chain != Chain::Mainnet {
3944 cfg.feature_flags.consensus_median_based_commit_timestamp = true;
3945
3946 cfg.consensus_bad_nodes_stake_threshold = Some(30);
3949
3950 cfg.feature_flags.consensus_batched_block_sync = true;
3951
3952 cfg.feature_flags.enable_nitro_attestation = true
3954 }
3955 cfg.feature_flags.normalize_ptb_arguments = true;
3956
3957 cfg.consensus_gc_depth = Some(60);
3958 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
3959 }
3960 80 => {
3961 cfg.max_ptb_value_size = Some(1024 * 1024);
3962 }
3963 81 => {
3964 cfg.feature_flags.consensus_median_based_commit_timestamp = true;
3965 cfg.feature_flags.enforce_checkpoint_timestamp_monotonicity = true;
3966 cfg.consensus_bad_nodes_stake_threshold = Some(30)
3967 }
3968 82 => {
3969 cfg.feature_flags.max_ptb_value_size_v2 = true;
3970 }
3971 83 => {
3972 if chain == Chain::Mainnet {
3973 let aliased: [u8; 32] = Hex::decode(
3975 "0x0b2da327ba6a4cacbe75dddd50e6e8bbf81d6496e92d66af9154c61c77f7332f",
3976 )
3977 .unwrap()
3978 .try_into()
3979 .unwrap();
3980
3981 cfg.aliased_addresses.push(AliasedAddress {
3983 original: Hex::decode("0xcd8962dad278d8b50fa0f9eb0186bfa4cbdecc6d59377214c88d0286a0ac9562").unwrap().try_into().unwrap(),
3984 aliased,
3985 allowed_tx_digests: vec![
3986 Base58::decode("B2eGLFoMHgj93Ni8dAJBfqGzo8EWSTLBesZzhEpTPA4").unwrap().try_into().unwrap(),
3987 ],
3988 });
3989
3990 cfg.aliased_addresses.push(AliasedAddress {
3991 original: Hex::decode("0xe28b50cef1d633ea43d3296a3f6b67ff0312a5f1a99f0af753c85b8b5de8ff06").unwrap().try_into().unwrap(),
3992 aliased,
3993 allowed_tx_digests: vec![
3994 Base58::decode("J4QqSAgp7VrQtQpMy5wDX4QGsCSEZu3U5KuDAkbESAge").unwrap().try_into().unwrap(),
3995 ],
3996 });
3997 }
3998
3999 if chain != Chain::Mainnet {
4002 cfg.feature_flags.resolve_type_input_ids_to_defining_id = true;
4003 cfg.transfer_party_transfer_internal_cost_base = Some(52);
4004
4005 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
4007 cfg.consensus_commit_rate_estimation_window_size = Some(10);
4008 cfg.feature_flags.per_object_congestion_control_mode =
4009 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4010 ExecutionTimeEstimateParams {
4011 target_utilization: 30,
4012 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4014 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4016 stored_observations_limit: u64::MAX,
4017 stake_weighted_median_threshold: 0,
4018 default_none_duration_for_new_keys: false,
4019 observations_chunk_size: None,
4020 },
4021 );
4022
4023 cfg.feature_flags.consensus_batched_block_sync = true;
4025
4026 cfg.feature_flags.enable_nitro_attestation_upgraded_parsing = true;
4029 cfg.feature_flags.enable_nitro_attestation = true;
4030 }
4031 }
4032 84 => {
4033 if chain == Chain::Mainnet {
4034 cfg.feature_flags.resolve_type_input_ids_to_defining_id = true;
4035 cfg.transfer_party_transfer_internal_cost_base = Some(52);
4036
4037 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
4039 cfg.consensus_commit_rate_estimation_window_size = Some(10);
4040 cfg.feature_flags.per_object_congestion_control_mode =
4041 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4042 ExecutionTimeEstimateParams {
4043 target_utilization: 30,
4044 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4046 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4048 stored_observations_limit: u64::MAX,
4049 stake_weighted_median_threshold: 0,
4050 default_none_duration_for_new_keys: false,
4051 observations_chunk_size: None,
4052 },
4053 );
4054
4055 cfg.feature_flags.consensus_batched_block_sync = true;
4057
4058 cfg.feature_flags.enable_nitro_attestation_upgraded_parsing = true;
4061 cfg.feature_flags.enable_nitro_attestation = true;
4062 }
4063
4064 cfg.feature_flags.per_object_congestion_control_mode =
4066 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4067 ExecutionTimeEstimateParams {
4068 target_utilization: 30,
4069 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4071 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4073 stored_observations_limit: 20,
4074 stake_weighted_median_threshold: 0,
4075 default_none_duration_for_new_keys: false,
4076 observations_chunk_size: None,
4077 },
4078 );
4079 cfg.feature_flags.allow_unbounded_system_objects = true;
4080 }
4081 85 => {
4082 if chain != Chain::Mainnet && chain != Chain::Testnet {
4083 cfg.feature_flags.enable_party_transfer = true;
4084 }
4085
4086 cfg.feature_flags
4087 .record_consensus_determined_version_assignments_in_prologue_v2 = true;
4088 cfg.feature_flags.disallow_self_identifier = true;
4089 cfg.feature_flags.per_object_congestion_control_mode =
4090 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4091 ExecutionTimeEstimateParams {
4092 target_utilization: 50,
4093 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4095 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4097 stored_observations_limit: 20,
4098 stake_weighted_median_threshold: 0,
4099 default_none_duration_for_new_keys: false,
4100 observations_chunk_size: None,
4101 },
4102 );
4103 }
4104 86 => {
4105 cfg.feature_flags.type_tags_in_object_runtime = true;
4106 cfg.max_move_enum_variants = Some(move_core_types::VARIANT_COUNT_MAX);
4107
4108 cfg.feature_flags.per_object_congestion_control_mode =
4110 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4111 ExecutionTimeEstimateParams {
4112 target_utilization: 50,
4113 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4115 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4117 stored_observations_limit: 20,
4118 stake_weighted_median_threshold: 3334,
4119 default_none_duration_for_new_keys: false,
4120 observations_chunk_size: None,
4121 },
4122 );
4123 if chain != Chain::Mainnet {
4125 cfg.feature_flags.enable_party_transfer = true;
4126 }
4127 }
4128 87 => {
4129 if chain == Chain::Mainnet {
4130 cfg.feature_flags.record_time_estimate_processed = true;
4131 }
4132 cfg.feature_flags.better_adapter_type_resolution_errors = true;
4133 }
4134 88 => {
4135 cfg.feature_flags.record_time_estimate_processed = true;
4136 cfg.tx_context_rgp_cost_base = Some(30);
4137 cfg.feature_flags
4138 .ignore_execution_time_observations_after_certs_closed = true;
4139
4140 cfg.feature_flags.per_object_congestion_control_mode =
4143 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4144 ExecutionTimeEstimateParams {
4145 target_utilization: 50,
4146 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4148 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4150 stored_observations_limit: 20,
4151 stake_weighted_median_threshold: 3334,
4152 default_none_duration_for_new_keys: true,
4153 observations_chunk_size: None,
4154 },
4155 );
4156 }
4157 89 => {
4158 cfg.feature_flags.dependency_linkage_error = true;
4159 cfg.feature_flags.additional_multisig_checks = true;
4160 }
4161 90 => {
4162 cfg.max_gas_price_rgp_factor_for_aborted_transactions = Some(100);
4164 cfg.feature_flags.debug_fatal_on_move_invariant_violation = true;
4165 cfg.feature_flags.additional_consensus_digest_indirect_state = true;
4166 cfg.feature_flags.accept_passkey_in_multisig = true;
4167 cfg.feature_flags.passkey_auth = true;
4168 cfg.feature_flags.check_for_init_during_upgrade = true;
4169
4170 if chain != Chain::Mainnet {
4172 cfg.feature_flags.mysticeti_fastpath = true;
4173 }
4174 }
4175 91 => {
4176 cfg.feature_flags.per_command_shared_object_transfer_rules = true;
4177 }
4178 92 => {
4179 cfg.feature_flags.per_command_shared_object_transfer_rules = false;
4180 }
4181 93 => {
4182 cfg.feature_flags
4183 .consensus_checkpoint_signature_key_includes_digest = true;
4184 }
4185 94 => {
4186 cfg.feature_flags.per_object_congestion_control_mode =
4188 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4189 ExecutionTimeEstimateParams {
4190 target_utilization: 50,
4191 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4193 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4195 stored_observations_limit: 18,
4196 stake_weighted_median_threshold: 3334,
4197 default_none_duration_for_new_keys: true,
4198 observations_chunk_size: None,
4199 },
4200 );
4201
4202 cfg.feature_flags.enable_party_transfer = true;
4204 }
4205 95 => {
4206 cfg.type_name_id_base_cost = Some(52);
4207
4208 cfg.max_transactions_per_checkpoint = Some(20_000);
4210 }
4211 96 => {
4212 if chain != Chain::Mainnet && chain != Chain::Testnet {
4214 cfg.feature_flags
4215 .include_checkpoint_artifacts_digest_in_summary = true;
4216 }
4217 cfg.feature_flags.correct_gas_payment_limit_check = true;
4218 cfg.feature_flags.authority_capabilities_v2 = true;
4219 cfg.feature_flags.use_mfp_txns_in_load_initial_object_debts = true;
4220 cfg.feature_flags.cancel_for_failed_dkg_early = true;
4221 cfg.feature_flags.enable_coin_registry = true;
4222
4223 cfg.feature_flags.mysticeti_fastpath = true;
4225 }
4226 97 => {
4227 cfg.feature_flags.additional_borrow_checks = true;
4228 }
4229 98 => {
4230 cfg.event_emit_auth_stream_cost = Some(52);
4231 cfg.feature_flags.better_loader_errors = true;
4232 cfg.feature_flags.generate_df_type_layouts = true;
4233 }
4234 99 => {
4235 cfg.feature_flags.use_new_commit_handler = true;
4236 }
4237 100 => {
4238 cfg.feature_flags.private_generics_verifier_v2 = true;
4239 }
4240 101 => {
4241 cfg.feature_flags.create_root_accumulator_object = true;
4242 cfg.max_updates_per_settlement_txn = Some(100);
4243 if chain != Chain::Mainnet {
4244 cfg.feature_flags.enable_poseidon = true;
4245 }
4246 }
4247 102 => {
4248 cfg.feature_flags.per_object_congestion_control_mode =
4252 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4253 ExecutionTimeEstimateParams {
4254 target_utilization: 50,
4255 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4257 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4259 stored_observations_limit: 180,
4260 stake_weighted_median_threshold: 3334,
4261 default_none_duration_for_new_keys: true,
4262 observations_chunk_size: Some(18),
4263 },
4264 );
4265 cfg.feature_flags.deprecate_global_storage_ops = true;
4266 }
4267 103 => {}
4268 104 => {
4269 cfg.translation_per_command_base_charge = Some(1);
4270 cfg.translation_per_input_base_charge = Some(1);
4271 cfg.translation_pure_input_per_byte_charge = Some(1);
4272 cfg.translation_per_type_node_charge = Some(1);
4273 cfg.translation_per_reference_node_charge = Some(1);
4274 cfg.translation_per_linkage_entry_charge = Some(10);
4275 cfg.gas_model_version = Some(11);
4276 cfg.feature_flags.abstract_size_in_object_runtime = true;
4277 cfg.feature_flags.object_runtime_charge_cache_load_gas = true;
4278 cfg.dynamic_field_hash_type_and_key_cost_base = Some(52);
4279 cfg.dynamic_field_add_child_object_cost_base = Some(52);
4280 cfg.dynamic_field_add_child_object_value_cost_per_byte = Some(1);
4281 cfg.dynamic_field_borrow_child_object_cost_base = Some(52);
4282 cfg.dynamic_field_borrow_child_object_child_ref_cost_per_byte = Some(1);
4283 cfg.dynamic_field_remove_child_object_cost_base = Some(52);
4284 cfg.dynamic_field_remove_child_object_child_cost_per_byte = Some(1);
4285 cfg.dynamic_field_has_child_object_cost_base = Some(52);
4286 cfg.dynamic_field_has_child_object_with_ty_cost_base = Some(52);
4287 cfg.feature_flags.enable_ptb_execution_v2 = true;
4288
4289 cfg.poseidon_bn254_cost_base = Some(260);
4290
4291 cfg.feature_flags.consensus_skip_gced_accept_votes = true;
4292
4293 if chain != Chain::Mainnet {
4294 cfg.feature_flags
4295 .enable_nitro_attestation_all_nonzero_pcrs_parsing = true;
4296 }
4297
4298 cfg.feature_flags
4299 .include_cancelled_randomness_txns_in_prologue = true;
4300 }
4301 105 => {
4302 cfg.feature_flags.enable_multi_epoch_transaction_expiration = true;
4303 cfg.feature_flags.disable_preconsensus_locking = true;
4304
4305 if chain != Chain::Mainnet {
4306 cfg.feature_flags
4307 .enable_nitro_attestation_always_include_required_pcrs_parsing = true;
4308 }
4309 }
4310 106 => {
4311 cfg.accumulator_object_storage_cost = Some(7600);
4313
4314 if chain != Chain::Mainnet && chain != Chain::Testnet {
4315 cfg.feature_flags.enable_accumulators = true;
4316 cfg.feature_flags.enable_address_balance_gas_payments = true;
4317 cfg.feature_flags.enable_authenticated_event_streams = true;
4318 cfg.feature_flags.enable_object_funds_withdraw = true;
4319 }
4320 }
4321 107 => {
4322 cfg.feature_flags
4323 .consensus_skip_gced_blocks_in_direct_finalization = true;
4324
4325 if in_integration_test() {
4327 cfg.consensus_gc_depth = Some(6);
4328 cfg.consensus_max_num_transactions_in_block = Some(8);
4329 }
4330 }
4331 108 => {
4332 cfg.feature_flags.gas_rounding_halve_digits = true;
4333 cfg.feature_flags.flexible_tx_context_positions = true;
4334 cfg.feature_flags.disable_entry_point_signature_check = true;
4335
4336 if chain != Chain::Mainnet {
4337 cfg.feature_flags.address_aliases = true;
4338
4339 cfg.feature_flags.enable_accumulators = true;
4340 cfg.feature_flags.enable_address_balance_gas_payments = true;
4341 }
4342
4343 cfg.feature_flags.enable_poseidon = true;
4344 }
4345 109 => {
4346 cfg.binary_variant_handles = Some(1024);
4347 cfg.binary_variant_instantiation_handles = Some(1024);
4348 cfg.feature_flags.restrict_hot_or_not_entry_functions = true;
4349 }
4350 110 => {
4351 cfg.feature_flags
4352 .enable_nitro_attestation_all_nonzero_pcrs_parsing = true;
4353 cfg.feature_flags
4354 .enable_nitro_attestation_always_include_required_pcrs_parsing = true;
4355 if chain != Chain::Mainnet && chain != Chain::Testnet {
4356 cfg.feature_flags.split_checkpoints_in_consensus_handler = true;
4357 }
4358 cfg.feature_flags.validate_zklogin_public_identifier = true;
4359 cfg.feature_flags.fix_checkpoint_signature_mapping = true;
4360 cfg.feature_flags
4361 .consensus_always_accept_system_transactions = true;
4362 if chain != Chain::Mainnet {
4363 cfg.feature_flags.enable_object_funds_withdraw = true;
4364 }
4365 }
4366 111 => {
4367 cfg.feature_flags.validator_metadata_verify_v2 = true;
4368 }
4369 112 => {
4370 cfg.group_ops_ristretto_decode_scalar_cost = Some(7);
4371 cfg.group_ops_ristretto_decode_point_cost = Some(200);
4372 cfg.group_ops_ristretto_scalar_add_cost = Some(10);
4373 cfg.group_ops_ristretto_point_add_cost = Some(500);
4374 cfg.group_ops_ristretto_scalar_sub_cost = Some(10);
4375 cfg.group_ops_ristretto_point_sub_cost = Some(500);
4376 cfg.group_ops_ristretto_scalar_mul_cost = Some(11);
4377 cfg.group_ops_ristretto_point_mul_cost = Some(1200);
4378 cfg.group_ops_ristretto_scalar_div_cost = Some(151);
4379 cfg.group_ops_ristretto_point_div_cost = Some(2500);
4380
4381 if chain != Chain::Mainnet && chain != Chain::Testnet {
4382 cfg.feature_flags.enable_ristretto255_group_ops = true;
4383 }
4384 }
4385 113 => {
4386 cfg.feature_flags.address_balance_gas_check_rgp_at_signing = true;
4387 if chain != Chain::Mainnet && chain != Chain::Testnet {
4388 cfg.feature_flags.defer_unpaid_amplification = true;
4389 }
4390 }
4391 114 => {
4392 cfg.feature_flags.randomize_checkpoint_tx_limit_in_tests = true;
4393 cfg.feature_flags.address_balance_gas_reject_gas_coin_arg = true;
4394 if chain != Chain::Mainnet {
4395 cfg.feature_flags.split_checkpoints_in_consensus_handler = true;
4396 cfg.feature_flags.enable_authenticated_event_streams = true;
4397 cfg.feature_flags
4398 .include_checkpoint_artifacts_digest_in_summary = true;
4399 }
4400 }
4401 115 => {
4402 cfg.feature_flags.normalize_depth_formula = true;
4403 }
4404 116 => {
4405 cfg.feature_flags.gasless_transaction_drop_safety = true;
4406 cfg.feature_flags.address_aliases = true;
4407 cfg.feature_flags.relax_valid_during_for_owned_inputs = true;
4408 cfg.feature_flags.defer_unpaid_amplification = false;
4410 cfg.feature_flags.enable_display_registry = true;
4411 }
4412 117 => {}
4413 118 => {
4414 cfg.feature_flags.use_coin_party_owner = true;
4415 }
4416 119 => {
4417 cfg.execution_version = Some(4);
4419 cfg.feature_flags.address_balance_gas_reject_gas_coin_arg = false;
4420 cfg.feature_flags.merge_randomness_into_checkpoint = true;
4421 if chain != Chain::Mainnet {
4422 cfg.feature_flags.enable_gasless = true;
4423 cfg.gasless_max_computation_units = Some(50_000);
4424 cfg.gasless_allowed_token_types = Some(vec![]);
4425 cfg.feature_flags.enable_coin_reservation_obj_refs = true;
4426 cfg.feature_flags
4427 .convert_withdrawal_compatibility_ptb_arguments = true;
4428 }
4429 cfg.gasless_max_unused_inputs = Some(1);
4430 cfg.gasless_max_pure_input_bytes = Some(32);
4431 if chain == Chain::Testnet {
4432 cfg.gasless_allowed_token_types = Some(vec![(TESTNET_USDC.to_string(), 0)]);
4433 }
4434 cfg.transfer_receive_object_cost_per_byte = Some(1);
4435 cfg.transfer_receive_object_type_cost_per_byte = Some(2);
4436 }
4437 120 => {
4438 cfg.feature_flags.disallow_jump_orphans = true;
4439 }
4440 121 => {
4441 if chain != Chain::Mainnet {
4443 cfg.feature_flags.defer_unpaid_amplification = true;
4444 cfg.gasless_max_tps = Some(50);
4445 }
4446 cfg.feature_flags
4447 .early_return_receive_object_mismatched_type = true;
4448 }
4449 122 => {
4450 cfg.feature_flags.defer_unpaid_amplification = true;
4452 cfg.verify_bulletproofs_ristretto255_base_cost = Some(30000);
4454 cfg.verify_bulletproofs_ristretto255_cost_per_bit_and_commitment = Some(6500);
4455 if chain != Chain::Mainnet && chain != Chain::Testnet {
4456 cfg.feature_flags.enable_verify_bulletproofs_ristretto255 = true;
4457 }
4458 cfg.feature_flags.gasless_verify_remaining_balance = true;
4459 cfg.include_special_package_amendments = match chain {
4460 Chain::Mainnet => Some(MAINNET_LINKAGE_AMENDMENTS.clone()),
4461 Chain::Testnet => Some(TESTNET_LINKAGE_AMENDMENTS.clone()),
4462 Chain::Unknown => None,
4463 };
4464 cfg.gasless_max_tx_size_bytes = Some(16 * 1024);
4465 cfg.gasless_max_tps = Some(300);
4466 cfg.gasless_max_computation_units = Some(5_000);
4467 }
4468 123 => {
4469 cfg.gas_model_version = Some(13);
4470 }
4471 124 => {
4472 if chain != Chain::Mainnet && chain != Chain::Testnet {
4473 cfg.feature_flags.timestamp_based_epoch_close = true;
4474 }
4475 cfg.gas_model_version = Some(14);
4476 cfg.feature_flags.limit_groth16_pvk_inputs = true;
4477
4478 cfg.feature_flags.enable_accumulators = true;
4484 cfg.feature_flags.enable_address_balance_gas_payments = true;
4485 cfg.feature_flags.enable_authenticated_event_streams = true;
4486 cfg.feature_flags.enable_coin_reservation_obj_refs = true;
4487 cfg.feature_flags.enable_object_funds_withdraw = true;
4488 cfg.feature_flags
4489 .convert_withdrawal_compatibility_ptb_arguments = true;
4490 cfg.feature_flags.split_checkpoints_in_consensus_handler = true;
4491 cfg.feature_flags
4492 .include_checkpoint_artifacts_digest_in_summary = true;
4493 cfg.feature_flags.enable_gasless = true;
4494
4495 if chain == Chain::Mainnet {
4500 cfg.gasless_allowed_token_types = Some(vec![
4501 (MAINNET_USDC.to_string(), 10_000),
4502 (MAINNET_USDSUI.to_string(), 10_000),
4503 (MAINNET_SUI_USDE.to_string(), 10_000),
4504 (MAINNET_USDY.to_string(), 10_000),
4505 (MAINNET_FDUSD.to_string(), 10_000),
4506 (MAINNET_AUSD.to_string(), 10_000),
4507 (MAINNET_USDB.to_string(), 10_000),
4508 ]);
4509 }
4510 }
4511 125 => {
4512 cfg.feature_flags.granular_post_execution_checks = true;
4513 if chain != Chain::Mainnet {
4514 cfg.feature_flags.timestamp_based_epoch_close = true;
4515 }
4516 }
4517 126 => {
4518 cfg.feature_flags.early_exit_on_iffw = true;
4519 }
4520 127 => {
4521 cfg.feature_flags.always_advance_dkg_to_resolution = true;
4522
4523 cfg.verify_bulletproofs_ristretto255_base_cost = Some(23866);
4524 cfg.verify_bulletproofs_ristretto255_cost_per_bit_and_commitment = Some(1324);
4525 cfg.group_ops_ristretto_decode_scalar_cost = Some(5);
4526 cfg.group_ops_ristretto_decode_point_cost = Some(216);
4527 cfg.group_ops_ristretto_scalar_add_cost = Some(2);
4528 cfg.group_ops_ristretto_point_add_cost = Some(8);
4529 cfg.group_ops_ristretto_scalar_sub_cost = Some(2);
4530 cfg.group_ops_ristretto_point_sub_cost = Some(8);
4531 cfg.group_ops_ristretto_scalar_mul_cost = Some(5);
4532 cfg.group_ops_ristretto_point_mul_cost = Some(1763);
4533 cfg.group_ops_ristretto_scalar_div_cost = Some(557);
4534 cfg.group_ops_ristretto_point_div_cost = Some(2244);
4535
4536 if chain != Chain::Mainnet {
4537 cfg.feature_flags.enable_ristretto255_group_ops = true;
4538 cfg.feature_flags.enable_verify_bulletproofs_ristretto255 = true;
4539 }
4540
4541 cfg.feature_flags.timestamp_based_epoch_close = true;
4542 }
4543 128 => {
4544 cfg.max_generic_instantiation_type_nodes_per_function = Some(10_000);
4545 cfg.max_generic_instantiation_type_nodes_per_module = Some(500_000);
4546 cfg.binary_enum_defs = Some(200);
4547 cfg.binary_enum_def_instantiations = Some(100);
4548 }
4549 129 => {
4550 cfg.feature_flags.enable_unified_linkage = true;
4551 }
4552 130 => {
4553 cfg.feature_flags.record_net_unsettled_object_withdraws = true;
4554 cfg.feature_flags.enable_init_on_upgrade = true;
4555 cfg.epoch_close_deadline_ms = Some(120_000);
4556 cfg.scratch_add_cost_base = Some(13);
4557 cfg.scratch_read_cost_base = Some(13);
4558 cfg.scratch_read_value_cost = Some(1);
4559 cfg.scratch_remove_cost_base = Some(13);
4560 cfg.scratch_exists_cost_base = Some(13);
4561 cfg.scratch_exists_with_type_cost_base = Some(13);
4562 cfg.scratch_exists_with_type_type_cost = Some(1);
4563 let max_commands = cfg.max_programmable_tx_commands() as u64;
4564 cfg.max_scratch_pad_size = Some(16 * max_commands);
4565 if chain != Chain::Mainnet && chain != Chain::Testnet {
4567 cfg.feature_flags.zklogin_circuit_mode = 1;
4568 }
4569 }
4570 131 => {
4571 cfg.feature_flags.share_transaction_deny_config_in_consensus = true;
4572 cfg.feature_flags.framework_tx_context_mut_restrictions = true;
4573 }
4574 132 => {
4575 if chain != Chain::Mainnet && chain != Chain::Testnet {
4576 cfg.feature_flags.defer_owned_object_double_spend = true;
4577 cfg.feature_flags.create_forwarding_address_registry = true;
4578 }
4579 cfg.object_record_new_uid_from_hash_cost_base = Some(1);
4580 cfg.feature_flags
4581 .enable_order_independent_upgrade_init_linkage = true;
4582 }
4583 133 => {
4584 cfg.feature_flags
4585 .include_function_signatures_in_instantiation_limits = true;
4586 cfg.max_accumulator_type_nodes = Some(16);
4587 }
4588 134 => {
4589 cfg.package_original_package_id_impl_cost_base = Some(52);
4590 let package_read_cost_per_byte = cfg.obj_access_cost_read_per_byte();
4591 cfg.package_original_package_id_impl_cost_per_byte =
4592 Some(package_read_cost_per_byte);
4593
4594 cfg.consensus_max_transactions_in_block_bytes = Some(288 * 1024);
4595 cfg.consensus_max_num_transactions_in_block = Some(128);
4596 }
4597 135 => {
4598 if chain != Chain::Mainnet && chain != Chain::Testnet {
4599 cfg.feature_flags.allowed_proposers = true;
4600 }
4601 }
4602 _ => panic!("unsupported version {:?}", version),
4613 }
4614 }
4615
4616 cfg
4617 }
4618
4619 pub fn apply_seeded_test_overrides(&mut self, seed: &[u8; 32]) {
4620 if !self.feature_flags.randomize_checkpoint_tx_limit_in_tests
4621 || !self.feature_flags.split_checkpoints_in_consensus_handler
4622 {
4623 return;
4624 }
4625
4626 if !mysten_common::in_test_configuration() {
4627 return;
4628 }
4629
4630 use rand::{Rng, SeedableRng, rngs::StdRng};
4631 let mut rng = StdRng::from_seed(*seed);
4632 let max_txns = rng.gen_range(10..=100u64);
4633 info!("seeded test override: max_transactions_per_checkpoint = {max_txns}");
4634 self.max_transactions_per_checkpoint = Some(max_txns);
4635 }
4636
4637 pub fn verifier_config(&self, signing_limits: Option<(usize, usize, usize)>) -> VerifierConfig {
4643 let (
4644 max_back_edges_per_function,
4645 max_back_edges_per_module,
4646 sanity_check_with_regex_reference_safety,
4647 ) = if let Some((
4648 max_back_edges_per_function,
4649 max_back_edges_per_module,
4650 sanity_check_with_regex_reference_safety,
4651 )) = signing_limits
4652 {
4653 (
4654 Some(max_back_edges_per_function),
4655 Some(max_back_edges_per_module),
4656 Some(sanity_check_with_regex_reference_safety),
4657 )
4658 } else {
4659 (None, None, None)
4660 };
4661
4662 let additional_borrow_checks = if signing_limits.is_some() {
4663 true
4665 } else {
4666 self.additional_borrow_checks()
4667 };
4668 let deprecate_global_storage_ops = if signing_limits.is_some() {
4669 true
4671 } else {
4672 self.deprecate_global_storage_ops()
4673 };
4674
4675 VerifierConfig {
4676 max_loop_depth: Some(self.max_loop_depth() as usize),
4677 max_generic_instantiation_length: Some(self.max_generic_instantiation_length() as usize),
4678 max_function_parameters: Some(self.max_function_parameters() as usize),
4679 max_basic_blocks: Some(self.max_basic_blocks() as usize),
4680 max_value_stack_size: self.max_value_stack_size() as usize,
4681 max_type_nodes: Some(self.max_type_nodes() as usize),
4682 max_generic_instantiation_type_nodes_per_function: self
4683 .max_generic_instantiation_type_nodes_per_function_as_option()
4684 .map(|v| v as usize),
4685 max_generic_instantiation_type_nodes_per_module: self
4686 .max_generic_instantiation_type_nodes_per_module_as_option()
4687 .map(|v| v as usize),
4688 include_function_signatures_in_instantiation_limits: self
4689 .include_function_signatures_in_instantiation_limits(),
4690 max_push_size: Some(self.max_push_size() as usize),
4691 max_dependency_depth: Some(self.max_dependency_depth() as usize),
4692 max_fields_in_struct: Some(self.max_fields_in_struct() as usize),
4693 max_function_definitions: Some(self.max_function_definitions() as usize),
4694 max_data_definitions: Some(self.max_struct_definitions() as usize),
4695 max_constant_vector_len: Some(self.max_move_vector_len()),
4696 max_back_edges_per_function,
4697 max_back_edges_per_module,
4698 max_basic_blocks_in_script: None,
4699 max_identifier_len: self.max_move_identifier_len_as_option(), disallow_self_identifier: self.feature_flags.disallow_self_identifier,
4701 allow_receiving_object_id: self.allow_receiving_object_id(),
4702 reject_mutable_random_on_entry_functions: self
4703 .reject_mutable_random_on_entry_functions(),
4704 bytecode_version: self.move_binary_format_version(),
4705 max_variants_in_enum: self.max_move_enum_variants_as_option(),
4706 additional_borrow_checks,
4707 better_loader_errors: self.better_loader_errors(),
4708 private_generics_verifier_v2: self.private_generics_verifier_v2(),
4709 sanity_check_with_regex_reference_safety: sanity_check_with_regex_reference_safety
4710 .map(|limit| limit as u128),
4711 deprecate_global_storage_ops,
4712 disable_entry_point_signature_check: self.disable_entry_point_signature_check(),
4713 switch_to_regex_reference_safety: false,
4714 framework_tx_context_mut_restrictions: self.framework_tx_context_mut_restrictions(),
4715 disallow_jump_orphans: self.disallow_jump_orphans(),
4716 }
4717 }
4718
4719 pub fn binary_config(
4720 &self,
4721 override_deprecate_global_storage_ops_during_deserialization: Option<bool>,
4722 ) -> BinaryConfig {
4723 let deprecate_global_storage_ops =
4724 override_deprecate_global_storage_ops_during_deserialization
4725 .unwrap_or_else(|| self.deprecate_global_storage_ops());
4726 BinaryConfig::new(
4727 self.move_binary_format_version(),
4728 self.min_move_binary_format_version_as_option()
4729 .unwrap_or(VERSION_1),
4730 self.no_extraneous_module_bytes(),
4731 deprecate_global_storage_ops,
4732 TableConfig {
4733 module_handles: self.binary_module_handles_as_option().unwrap_or(u16::MAX),
4734 datatype_handles: self.binary_struct_handles_as_option().unwrap_or(u16::MAX),
4735 function_handles: self.binary_function_handles_as_option().unwrap_or(u16::MAX),
4736 function_instantiations: self
4737 .binary_function_instantiations_as_option()
4738 .unwrap_or(u16::MAX),
4739 signatures: self.binary_signatures_as_option().unwrap_or(u16::MAX),
4740 constant_pool: self.binary_constant_pool_as_option().unwrap_or(u16::MAX),
4741 identifiers: self.binary_identifiers_as_option().unwrap_or(u16::MAX),
4742 address_identifiers: self
4743 .binary_address_identifiers_as_option()
4744 .unwrap_or(u16::MAX),
4745 struct_defs: self.binary_struct_defs_as_option().unwrap_or(u16::MAX),
4746 struct_def_instantiations: self
4747 .binary_struct_def_instantiations_as_option()
4748 .unwrap_or(u16::MAX),
4749 function_defs: self.binary_function_defs_as_option().unwrap_or(u16::MAX),
4750 field_handles: self.binary_field_handles_as_option().unwrap_or(u16::MAX),
4751 field_instantiations: self
4752 .binary_field_instantiations_as_option()
4753 .unwrap_or(u16::MAX),
4754 friend_decls: self.binary_friend_decls_as_option().unwrap_or(u16::MAX),
4755 enum_defs: self.binary_enum_defs_as_option().unwrap_or(u16::MAX),
4756 enum_def_instantiations: self
4757 .binary_enum_def_instantiations_as_option()
4758 .unwrap_or(u16::MAX),
4759 variant_handles: self.binary_variant_handles_as_option().unwrap_or(u16::MAX),
4760 variant_instantiation_handles: self
4761 .binary_variant_instantiation_handles_as_option()
4762 .unwrap_or(u16::MAX),
4763 },
4764 )
4765 }
4766
4767 pub fn apply_overrides_for_testing(
4771 override_fn: impl Fn(ProtocolVersion, Self) -> Self + Send + Sync + 'static,
4772 ) -> OverrideGuard {
4773 let mut cur = CONFIG_OVERRIDE.lock().unwrap();
4774 assert!(cur.is_none(), "config override already present");
4775 *cur = Some(Box::new(override_fn));
4776 OverrideGuard
4777 }
4778
4779 fn apply_config_override(version: ProtocolVersion, mut ret: Self) -> Self {
4780 if let Some(override_fn) = CONFIG_OVERRIDE.lock().unwrap().as_ref() {
4781 warn!(
4782 "overriding ProtocolConfig settings with custom settings (you should not see this log outside of tests)"
4783 );
4784 ret = override_fn(version, ret);
4785 }
4786 ret
4787 }
4788}
4789
4790impl ProtocolConfig {
4794 pub fn set_execution_version_for_testing(&mut self, val: u64) {
4798 let current = self.execution_version.unwrap_or(0);
4799 assert!(
4800 val >= current,
4801 "cannot downgrade execution_version from {current} to {val}: running an old \
4802 executor against a newer protocol config/framework is unsupported. To test \
4803 frozen executor behavior, start from the last protocol version of that executor \
4804 instead, so genesis loads the matching framework snapshot (see \
4805 test_address_balance_gas_v3_accumulator_sign)."
4806 );
4807 self.execution_version = Some(val);
4808 }
4809
4810 pub fn set_zklogin_circuit_mode_for_testing(&mut self, val: u64) {
4813 self.feature_flags.zklogin_circuit_mode = val
4814 }
4815
4816 pub fn set_per_object_congestion_control_mode_for_testing(
4817 &mut self,
4818 val: PerObjectCongestionControlMode,
4819 ) {
4820 self.feature_flags.per_object_congestion_control_mode = val;
4821 }
4822
4823 pub fn set_consensus_choice_for_testing(&mut self, val: ConsensusChoice) {
4824 self.feature_flags.consensus_choice = val;
4825 }
4826
4827 pub fn set_consensus_network_for_testing(&mut self, val: ConsensusNetwork) {
4828 self.feature_flags.consensus_network = val;
4829 }
4830
4831 pub fn set_zklogin_max_epoch_upper_bound_delta_for_testing(&mut self, val: Option<u64>) {
4832 self.feature_flags.zklogin_max_epoch_upper_bound_delta = val
4833 }
4834
4835 pub fn set_mysticeti_num_leaders_per_round_for_testing(&mut self, val: Option<usize>) {
4836 self.feature_flags.mysticeti_num_leaders_per_round = val;
4837 }
4838
4839 pub fn disable_accumulators_for_testing(&mut self) {
4840 self.feature_flags.enable_accumulators = false;
4841 self.feature_flags.enable_address_balance_gas_payments = false;
4842 }
4843
4844 pub fn enable_coin_reservation_for_testing(&mut self) {
4845 self.feature_flags.enable_coin_reservation_obj_refs = true;
4846 self.feature_flags
4847 .convert_withdrawal_compatibility_ptb_arguments = true;
4848 self.execution_version = Some(self.execution_version.map_or(4, |v| v.max(4)));
4851 }
4852
4853 pub fn disable_coin_reservation_for_testing(&mut self) {
4854 self.feature_flags.enable_coin_reservation_obj_refs = false;
4855 self.feature_flags
4856 .convert_withdrawal_compatibility_ptb_arguments = false;
4857 }
4858
4859 pub fn enable_address_balance_gas_payments_for_testing(&mut self) {
4860 self.feature_flags.enable_accumulators = true;
4861 self.feature_flags.allow_private_accumulator_entrypoints = true;
4862 self.feature_flags.enable_address_balance_gas_payments = true;
4863 self.feature_flags.address_balance_gas_check_rgp_at_signing = true;
4864 self.feature_flags.address_balance_gas_reject_gas_coin_arg = false;
4865 self.execution_version = Some(self.execution_version.map_or(4, |v| v.max(4)))
4866 }
4867
4868 pub fn enable_gasless_for_testing(&mut self) {
4869 self.enable_address_balance_gas_payments_for_testing();
4870 self.feature_flags.enable_gasless = true;
4871 self.feature_flags.gasless_verify_remaining_balance = true;
4872 self.gasless_max_computation_units = Some(5_000);
4873 self.gasless_allowed_token_types = Some(vec![]);
4874 self.gasless_max_tps = Some(1000);
4875 self.gasless_max_tx_size_bytes = Some(16 * 1024);
4876 }
4877
4878 pub fn disable_gasless_for_testing(&mut self) {
4879 self.feature_flags.enable_gasless = false;
4880 self.gasless_max_computation_units = None;
4881 self.gasless_allowed_token_types = None;
4882 }
4883
4884 pub fn enable_authenticated_event_streams_for_testing(&mut self) {
4885 self.feature_flags.enable_accumulators = true;
4886 self.feature_flags.enable_authenticated_event_streams = true;
4887 self.feature_flags
4888 .include_checkpoint_artifacts_digest_in_summary = true;
4889 self.feature_flags.split_checkpoints_in_consensus_handler = true;
4890 }
4891}
4892
4893type OverrideFn = dyn Fn(ProtocolVersion, ProtocolConfig) -> ProtocolConfig + Send + Sync;
4894
4895static CONFIG_OVERRIDE: Mutex<Option<Box<OverrideFn>>> = Mutex::new(None);
4896
4897#[must_use]
4898pub struct OverrideGuard;
4899
4900impl Drop for OverrideGuard {
4901 fn drop(&mut self) {
4902 info!("restoring override fn");
4903 *CONFIG_OVERRIDE.lock().unwrap() = None;
4904 }
4905}
4906
4907#[derive(PartialEq, Eq)]
4910pub enum LimitThresholdCrossed {
4911 None,
4912 Soft(u128, u128),
4913 Hard(u128, u128),
4914}
4915
4916pub fn check_limit_in_range<T: Into<V>, U: Into<V>, V: PartialOrd + Into<u128>>(
4919 x: T,
4920 soft_limit: U,
4921 hard_limit: V,
4922) -> LimitThresholdCrossed {
4923 let x: V = x.into();
4924 let soft_limit: V = soft_limit.into();
4925
4926 debug_assert!(soft_limit <= hard_limit);
4927
4928 if x >= hard_limit {
4931 LimitThresholdCrossed::Hard(x.into(), hard_limit.into())
4932 } else if x < soft_limit {
4933 LimitThresholdCrossed::None
4934 } else {
4935 LimitThresholdCrossed::Soft(x.into(), soft_limit.into())
4936 }
4937}
4938
4939#[macro_export]
4940macro_rules! check_limit {
4941 ($x:expr, $hard:expr) => {
4942 check_limit!($x, $hard, $hard)
4943 };
4944 ($x:expr, $soft:expr, $hard:expr) => {
4945 check_limit_in_range($x as u64, $soft, $hard)
4946 };
4947}
4948
4949#[macro_export]
4953macro_rules! check_limit_by_meter {
4954 ($is_metered:expr, $x:expr, $metered_limit:expr, $unmetered_hard_limit:expr, $metric:expr) => {{
4955 let (h, metered_str) = if $is_metered {
4957 ($metered_limit, "metered")
4958 } else {
4959 ($unmetered_hard_limit, "unmetered")
4961 };
4962 use sui_protocol_config::check_limit_in_range;
4963 let result = check_limit_in_range($x as u64, $metered_limit, h);
4964 match result {
4965 LimitThresholdCrossed::None => {}
4966 LimitThresholdCrossed::Soft(_, _) => {
4967 $metric.with_label_values(&[metered_str, "soft"]).inc();
4968 }
4969 LimitThresholdCrossed::Hard(_, _) => {
4970 $metric.with_label_values(&[metered_str, "hard"]).inc();
4971 }
4972 };
4973 result
4974 }};
4975}
4976
4977pub type Amendments = BTreeMap<AccountAddress, BTreeMap<AccountAddress, AccountAddress>>;
4980
4981static MAINNET_LINKAGE_AMENDMENTS: LazyLock<Arc<Amendments>> =
4982 LazyLock::new(|| parse_amendments(include_str!("mainnet_amendments.json")));
4983
4984static TESTNET_LINKAGE_AMENDMENTS: LazyLock<Arc<Amendments>> =
4985 LazyLock::new(|| parse_amendments(include_str!("testnet_amendments.json")));
4986
4987fn parse_amendments(json: &str) -> Arc<Amendments> {
4988 #[derive(serde::Deserialize)]
4989 struct AmendmentEntry {
4990 root: String,
4991 deps: Vec<DepEntry>,
4992 }
4993
4994 #[derive(serde::Deserialize)]
4995 struct DepEntry {
4996 original_id: String,
4997 version_id: String,
4998 }
4999
5000 let entries: Vec<AmendmentEntry> =
5001 serde_json::from_str(json).expect("Failed to parse amendments JSON");
5002 let mut amendments = BTreeMap::new();
5003 for entry in entries {
5004 let root_id = AccountAddress::from_hex_literal(&entry.root).unwrap();
5005 let mut dep_ids = BTreeMap::new();
5006 for dep in entry.deps {
5007 let orig_id = AccountAddress::from_hex_literal(&dep.original_id).unwrap();
5008 let upgraded_id = AccountAddress::from_hex_literal(&dep.version_id).unwrap();
5009 assert!(
5010 dep_ids.insert(orig_id, upgraded_id).is_none(),
5011 "Duplicate original ID in amendments table"
5012 );
5013 }
5014 assert!(
5015 amendments.insert(root_id, dep_ids).is_none(),
5016 "Duplicate root ID in amendments table"
5017 );
5018 }
5019 Arc::new(amendments)
5020}
5021
5022#[cfg(all(test, not(msim)))]
5023mod test {
5024 use insta::assert_yaml_snapshot;
5025
5026 use super::*;
5027
5028 #[test]
5029 fn snapshot_tests() {
5030 println!("\n============================================================================");
5031 println!("! !");
5032 println!("! IMPORTANT: never update snapshots from this test. only add new versions! !");
5033 println!("! !");
5034 println!("============================================================================\n");
5035 for chain_id in &[Chain::Unknown, Chain::Mainnet, Chain::Testnet] {
5036 let chain_str = match chain_id {
5040 Chain::Unknown => "".to_string(),
5041 _ => format!("{:?}_", chain_id),
5042 };
5043 for i in MIN_PROTOCOL_VERSION..=MAX_PROTOCOL_VERSION {
5044 let cur = ProtocolVersion::new(i);
5045 assert_yaml_snapshot!(
5046 format!("{}version_{}", chain_str, cur.as_u64()),
5047 ProtocolConfig::get_for_version(cur, *chain_id)
5048 );
5049 }
5050 }
5051 }
5052
5053 #[test]
5054 fn test_getters() {
5055 let prot: ProtocolConfig =
5056 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5057 assert_eq!(
5058 prot.max_arguments(),
5059 prot.max_arguments_as_option().unwrap()
5060 );
5061 }
5062
5063 #[test]
5064 fn test_setters() {
5065 let mut prot: ProtocolConfig =
5066 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5067 prot.set_max_arguments_for_testing(123);
5068 assert_eq!(prot.max_arguments(), 123);
5069
5070 prot.set_max_arguments_from_str_for_testing("321".to_string());
5071 assert_eq!(prot.max_arguments(), 321);
5072
5073 prot.disable_max_arguments_for_testing();
5074 assert_eq!(prot.max_arguments_as_option(), None);
5075
5076 prot.set_attr_for_testing("max_arguments".to_string(), "456".to_string());
5077 assert_eq!(prot.max_arguments(), 456);
5078 }
5079
5080 #[test]
5081 fn test_execution_version_setter_allows_upgrade() {
5082 let mut prot = ProtocolConfig::get_for_max_version_UNSAFE();
5083 let current = prot.execution_version();
5084 prot.set_execution_version_for_testing(current);
5085 prot.set_execution_version_for_testing(current + 1);
5086 assert_eq!(prot.execution_version(), current + 1);
5087 }
5088
5089 #[test]
5090 #[should_panic(expected = "cannot downgrade execution_version")]
5091 fn test_execution_version_setter_panics_on_downgrade() {
5092 let mut prot = ProtocolConfig::get_for_max_version_UNSAFE();
5093 let current = prot.execution_version();
5094 prot.set_execution_version_for_testing(current - 1);
5095 }
5096
5097 #[test]
5098 fn test_feature_flag_setter_by_string() {
5099 let mut prot: ProtocolConfig =
5100 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5101 assert!(!prot.zklogin_auth());
5102 prot.set_feature_flag_for_testing("zklogin_auth".to_string(), true);
5103 assert!(prot.zklogin_auth());
5104 prot.set_feature_flag_for_testing("zklogin_auth".to_string(), false);
5105 assert!(!prot.zklogin_auth());
5106 }
5107
5108 #[test]
5109 #[should_panic(expected = "unknown feature flag")]
5110 fn test_feature_flag_setter_unknown_flag() {
5111 let mut prot: ProtocolConfig =
5112 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5113 prot.set_feature_flag_for_testing("some random string".to_string(), true);
5114 }
5115
5116 #[test]
5117 fn test_get_for_version_if_supported_applies_test_overrides() {
5118 let before =
5119 ProtocolConfig::get_for_version_if_supported(ProtocolVersion::new(1), Chain::Unknown)
5120 .unwrap();
5121
5122 assert!(!before.enable_coin_reservation_obj_refs());
5123
5124 let _guard = ProtocolConfig::apply_overrides_for_testing(|_, mut cfg| {
5125 cfg.enable_coin_reservation_for_testing();
5126 cfg
5127 });
5128
5129 let after =
5130 ProtocolConfig::get_for_version_if_supported(ProtocolVersion::new(1), Chain::Unknown)
5131 .unwrap();
5132
5133 assert!(after.enable_coin_reservation_obj_refs());
5134 }
5135
5136 #[test]
5137 #[should_panic(expected = "unsupported version")]
5138 fn max_version_test() {
5139 let _ = ProtocolConfig::get_for_version_impl(
5142 ProtocolVersion::new(MAX_PROTOCOL_VERSION + 1),
5143 Chain::Unknown,
5144 );
5145 }
5146
5147 #[test]
5148 fn lookup_by_string_test() {
5149 let prot: ProtocolConfig =
5150 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5151 assert!(prot.lookup_attr("some random string".to_string()).is_none());
5153
5154 assert!(
5155 prot.lookup_attr("max_arguments".to_string())
5156 == Some(ProtocolConfigValue::u32(prot.max_arguments())),
5157 );
5158
5159 assert!(
5161 prot.lookup_attr("max_move_identifier_len".to_string())
5162 .is_none()
5163 );
5164
5165 let prot: ProtocolConfig =
5167 ProtocolConfig::get_for_version(ProtocolVersion::new(9), Chain::Unknown);
5168 assert!(
5169 prot.lookup_attr("max_move_identifier_len".to_string())
5170 == Some(ProtocolConfigValue::u64(prot.max_move_identifier_len()))
5171 );
5172
5173 let prot: ProtocolConfig =
5174 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5175 assert!(
5177 prot.attr_map()
5178 .get("max_move_identifier_len")
5179 .unwrap()
5180 .is_none()
5181 );
5182 assert!(
5184 prot.attr_map().get("max_arguments").unwrap()
5185 == &Some(ProtocolConfigValue::u32(prot.max_arguments()))
5186 );
5187
5188 let prot: ProtocolConfig =
5190 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5191 assert!(
5193 prot.feature_flags
5194 .lookup_attr("some random string".to_owned())
5195 .is_none()
5196 );
5197 assert!(
5198 !prot
5199 .feature_flags
5200 .attr_map()
5201 .contains_key("some random string")
5202 );
5203
5204 assert!(
5206 prot.feature_flags
5207 .lookup_attr("package_upgrades".to_owned())
5208 == Some(false)
5209 );
5210 assert!(
5211 prot.feature_flags
5212 .attr_map()
5213 .get("package_upgrades")
5214 .unwrap()
5215 == &false
5216 );
5217 let prot: ProtocolConfig =
5218 ProtocolConfig::get_for_version(ProtocolVersion::new(4), Chain::Unknown);
5219 assert!(
5221 prot.feature_flags
5222 .lookup_attr("package_upgrades".to_owned())
5223 == Some(true)
5224 );
5225 assert!(
5226 prot.feature_flags
5227 .attr_map()
5228 .get("package_upgrades")
5229 .unwrap()
5230 == &true
5231 );
5232 }
5233
5234 #[test]
5235 fn limit_range_fn_test() {
5236 let low = 100u32;
5237 let high = 10000u64;
5238
5239 assert!(check_limit!(1u8, low, high) == LimitThresholdCrossed::None);
5240 assert!(matches!(
5241 check_limit!(255u16, low, high),
5242 LimitThresholdCrossed::Soft(255u128, 100)
5243 ));
5244 assert!(matches!(
5250 check_limit!(2550000u64, low, high),
5251 LimitThresholdCrossed::Hard(2550000, 10000)
5252 ));
5253
5254 assert!(matches!(
5255 check_limit!(2550000u64, high, high),
5256 LimitThresholdCrossed::Hard(2550000, 10000)
5257 ));
5258
5259 assert!(matches!(
5260 check_limit!(1u8, high),
5261 LimitThresholdCrossed::None
5262 ));
5263
5264 assert!(check_limit!(255u16, high) == LimitThresholdCrossed::None);
5265
5266 assert!(matches!(
5267 check_limit!(2550000u64, high),
5268 LimitThresholdCrossed::Hard(2550000, 10000)
5269 ));
5270 }
5271
5272 #[test]
5273 fn linkage_amendments_load() {
5274 let mainnet = LazyLock::force(&MAINNET_LINKAGE_AMENDMENTS);
5275 let testnet = LazyLock::force(&TESTNET_LINKAGE_AMENDMENTS);
5276 assert!(!mainnet.is_empty(), "mainnet amendments must not be empty");
5277 assert!(!testnet.is_empty(), "testnet amendments must not be empty");
5278 }
5279
5280 #[test]
5281 fn render_scalar_fields_use_precision_safe_encoding() {
5282 use mysten_common::rpc_format::Unmetered;
5283
5284 let config = ProtocolConfig::get_for_max_version_UNSAFE();
5285 let rendered = config
5286 .render::<serde_json::Value>(&mut Unmetered)
5287 .expect("render should succeed");
5288
5289 let max_args = rendered
5290 .get("max_arguments")
5291 .expect("max_arguments set at max version");
5292 assert!(
5293 max_args.is_number(),
5294 "u32 should render as number, got {max_args:?}",
5295 );
5296
5297 let max_tx_size = rendered
5298 .get("max_tx_size_bytes")
5299 .expect("max_tx_size_bytes set at max version");
5300 assert!(
5301 max_tx_size.is_string(),
5302 "u64 should render as string, got {max_tx_size:?}",
5303 );
5304 }
5305
5306 #[test]
5307 fn render_includes_non_scalar_gasless_allowlist_as_json() {
5308 use mysten_common::rpc_format::Unmetered;
5309 use serde_json::json;
5310
5311 let mut config = ProtocolConfig::get_for_max_version_UNSAFE();
5312 config.set_gasless_allowed_token_types_for_testing(vec![
5313 ("0xa::usdc::USDC".to_string(), 10_000),
5314 ("0xb::usdt::USDT".to_string(), 0),
5315 ]);
5316
5317 let rendered = config
5318 .render::<serde_json::Value>(&mut Unmetered)
5319 .expect("render should succeed under Unmetered budget");
5320 let allowlist = rendered
5321 .get("gasless_allowed_token_types")
5322 .expect("entry should be present after the testing setter");
5323
5324 assert_eq!(
5327 allowlist,
5328 &json!([["0xa::usdc::USDC", "10000"], ["0xb::usdt::USDT", "0"],]),
5329 );
5330 }
5331
5332 #[test]
5333 fn render_targets_prost_value_for_grpc() {
5334 use mysten_common::rpc_format::Unmetered;
5335 use prost_types::value::Kind;
5336
5337 let mut config = ProtocolConfig::get_for_max_version_UNSAFE();
5338 config.set_gasless_allowed_token_types_for_testing(vec![(
5339 "0xa::usdc::USDC".to_string(),
5340 10_000,
5341 )]);
5342
5343 let rendered = config
5344 .render::<prost_types::Value>(&mut Unmetered)
5345 .expect("render to prost Value should succeed");
5346 let allowlist = rendered
5347 .get("gasless_allowed_token_types")
5348 .expect("entry should be present after the testing setter");
5349
5350 let Some(Kind::ListValue(outer)) = &allowlist.kind else {
5352 panic!(
5353 "expected ListValue at the top level, got {:?}",
5354 allowlist.kind
5355 );
5356 };
5357 assert_eq!(outer.values.len(), 1, "one allowlisted entry");
5358 let Some(Kind::ListValue(entry)) = &outer.values[0].kind else {
5359 panic!("expected each entry to be a ListValue");
5360 };
5361 assert_eq!(entry.values.len(), 2, "entry has (coin_type, amount)");
5362
5363 let Some(Kind::StringValue(coin_type)) = &entry.values[0].kind else {
5364 panic!("expected coin_type as StringValue");
5365 };
5366 assert_eq!(coin_type, "0xa::usdc::USDC");
5367
5368 let Some(Kind::StringValue(amount)) = &entry.values[1].kind else {
5370 panic!(
5371 "expected minimum_transfer_amount as StringValue (precision-safe u64); got {:?}",
5372 entry.values[1].kind,
5373 );
5374 };
5375 assert_eq!(amount, "10000");
5376 }
5377
5378 #[test]
5379 fn render_emits_null_for_unset_protocol_versions() {
5380 use mysten_common::rpc_format::Unmetered;
5381
5382 let config = ProtocolConfig::get_for_version(1.into(), Chain::Unknown);
5383 let rendered = config
5384 .render::<serde_json::Value>(&mut Unmetered)
5385 .expect("render should succeed");
5386 let entry = rendered
5390 .get("gasless_allowed_token_types")
5391 .expect("key should be present for every protocol version");
5392 assert!(
5393 entry.is_null(),
5394 "value should be null for pre-feature protocol version, got {entry:?}",
5395 );
5396 }
5397}