1use std::{
5 collections::{BTreeMap, BTreeSet},
6 sync::{
7 Arc, LazyLock,
8 atomic::{AtomicBool, Ordering},
9 },
10};
11
12#[cfg(msim)]
13use std::cell::RefCell;
14#[cfg(not(msim))]
15use std::sync::Mutex;
16
17use clap::*;
18use fastcrypto::encoding::{Base58, Encoding, Hex};
19use move_binary_format::{
20 binary_config::{BinaryConfig, TableConfig},
21 file_format_common::VERSION_1,
22};
23use move_core_types::account_address::AccountAddress;
24use move_vm_config::verifier::VerifierConfig;
25use mysten_common::in_integration_test;
26use serde::{Deserialize, Serialize};
27use serde_with::skip_serializing_none;
28use sui_protocol_config_macros::{
29 ProtocolConfigAccessors, ProtocolConfigFeatureFlagsGetters, ProtocolConfigOverride,
30};
31use tracing::{info, warn};
32
33const MIN_PROTOCOL_VERSION: u64 = 1;
35const MAX_PROTOCOL_VERSION: u64 = 131;
36
37const TESTNET_USDC: &str =
38 "0xa1ec7fc00a6f40db9693ad1415d0c193ad3906494428cf252621037bd7117e29::usdc::USDC";
39
40const MAINNET_USDC: &str =
41 "0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC";
42const MAINNET_USDSUI: &str =
43 "0x44f838219cf67b058f3b37907b655f226153c18e33dfcd0da559a844fea9b1c1::usdsui::USDSUI";
44const MAINNET_SUI_USDE: &str =
45 "0x41d587e5336f1c86cad50d38a7136db99333bb9bda91cea4ba69115defeb1402::sui_usde::SUI_USDE";
46const MAINNET_USDY: &str =
47 "0x960b531667636f39e85867775f52f6b1f220a058c4de786905bdf761e06a56bb::usdy::USDY";
48const MAINNET_FDUSD: &str =
49 "0xf16e6b723f242ec745dfd7634ad072c42d5c1d9ac9d62a39c381303eaa57693a::fdusd::FDUSD";
50const MAINNET_AUSD: &str =
51 "0x2053d08c1e2bd02791056171aab0fd12bd7cd7efad2ab8f6b9c8902f14df2ff2::ausd::AUSD";
52const MAINNET_USDB: &str =
53 "0xe14726c336e81b32328e92afc37345d159f5b550b09fa92bd43640cfdd0a0cfd::usdb::USDB";
54
55#[derive(Copy, Clone, Debug, Hash, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)]
373pub struct ProtocolVersion(u64);
374
375impl ProtocolVersion {
376 pub const MIN: Self = Self(MIN_PROTOCOL_VERSION);
381
382 pub const MAX: Self = Self(MAX_PROTOCOL_VERSION);
383
384 #[cfg(not(msim))]
385 pub const MAX_ALLOWED: Self = Self::MAX;
386
387 #[cfg(msim)]
389 pub const MAX_ALLOWED: Self = Self(MAX_PROTOCOL_VERSION + 1);
390
391 pub fn new(v: u64) -> Self {
392 Self(v)
393 }
394
395 pub const fn as_u64(&self) -> u64 {
396 self.0
397 }
398
399 pub fn max() -> Self {
402 Self::MAX
403 }
404
405 pub fn prev(self) -> Self {
406 Self(self.0.checked_sub(1).unwrap())
407 }
408}
409
410impl From<u64> for ProtocolVersion {
411 fn from(v: u64) -> Self {
412 Self::new(v)
413 }
414}
415
416impl std::ops::Sub<u64> for ProtocolVersion {
417 type Output = Self;
418 fn sub(self, rhs: u64) -> Self::Output {
419 Self::new(self.0 - rhs)
420 }
421}
422
423impl std::ops::Add<u64> for ProtocolVersion {
424 type Output = Self;
425 fn add(self, rhs: u64) -> Self::Output {
426 Self::new(self.0 + rhs)
427 }
428}
429
430#[derive(
431 Clone, Serialize, Deserialize, Debug, Default, PartialEq, Copy, PartialOrd, Ord, Eq, ValueEnum,
432)]
433pub enum Chain {
434 Mainnet,
435 Testnet,
436 #[default]
437 Unknown,
438}
439
440impl Chain {
441 pub fn as_str(self) -> &'static str {
442 match self {
443 Chain::Mainnet => "mainnet",
444 Chain::Testnet => "testnet",
445 Chain::Unknown => "unknown",
446 }
447 }
448}
449
450pub struct Error(pub String);
451
452#[derive(Default, Clone, Serialize, Deserialize, Debug, ProtocolConfigFeatureFlagsGetters)]
455struct FeatureFlags {
456 #[serde(skip_serializing_if = "is_false")]
459 package_upgrades: bool,
460 #[serde(skip_serializing_if = "is_false")]
463 commit_root_state_digest: bool,
464 #[serde(skip_serializing_if = "is_false")]
466 advance_epoch_start_time_in_safe_mode: bool,
467 #[serde(skip_serializing_if = "is_false")]
470 loaded_child_objects_fixed: bool,
471 #[serde(skip_serializing_if = "is_false")]
474 missing_type_is_compatibility_error: bool,
475 #[serde(skip_serializing_if = "is_false")]
478 scoring_decision_with_validity_cutoff: bool,
479
480 #[serde(skip_serializing_if = "is_false")]
483 consensus_order_end_of_epoch_last: bool,
484
485 #[serde(skip_serializing_if = "is_false")]
487 disallow_adding_abilities_on_upgrade: bool,
488 #[serde(skip_serializing_if = "is_false")]
490 disable_invariant_violation_check_in_swap_loc: bool,
491 #[serde(skip_serializing_if = "is_false")]
494 advance_to_highest_supported_protocol_version: bool,
495 #[serde(skip_serializing_if = "is_false")]
497 ban_entry_init: bool,
498 #[serde(skip_serializing_if = "is_false")]
500 package_digest_hash_module: bool,
501 #[serde(skip_serializing_if = "is_false")]
503 disallow_change_struct_type_params_on_upgrade: bool,
504 #[serde(skip_serializing_if = "is_false")]
506 no_extraneous_module_bytes: bool,
507 #[serde(skip_serializing_if = "is_false")]
509 narwhal_versioned_metadata: bool,
510
511 #[serde(skip_serializing_if = "is_false")]
513 zklogin_auth: bool,
514 #[serde(skip_serializing_if = "is_zero")]
517 zklogin_circuit_mode: u64,
518 #[serde(skip_serializing_if = "ConsensusTransactionOrdering::is_none")]
520 consensus_transaction_ordering: ConsensusTransactionOrdering,
521
522 #[serde(skip_serializing_if = "is_false")]
530 simplified_unwrap_then_delete: bool,
531 #[serde(skip_serializing_if = "is_false")]
533 upgraded_multisig_supported: bool,
534 #[serde(skip_serializing_if = "is_false")]
536 txn_base_cost_as_multiplier: bool,
537
538 #[serde(skip_serializing_if = "is_false")]
540 shared_object_deletion: bool,
541
542 #[serde(skip_serializing_if = "is_false")]
544 narwhal_new_leader_election_schedule: bool,
545
546 #[serde(skip_serializing_if = "is_empty")]
548 zklogin_supported_providers: BTreeSet<String>,
549
550 #[serde(skip_serializing_if = "is_false")]
552 loaded_child_object_format: bool,
553
554 #[serde(skip_serializing_if = "is_false")]
555 #[skip_protocol_config_accessor]
556 enable_jwk_consensus_updates: bool,
557
558 #[serde(skip_serializing_if = "is_false")]
559 #[skip_protocol_config_accessor]
560 end_of_epoch_transaction_supported: bool,
561
562 #[serde(skip_serializing_if = "is_false")]
565 simple_conservation_checks: bool,
566
567 #[serde(skip_serializing_if = "is_false")]
569 loaded_child_object_format_type: bool,
570
571 #[serde(skip_serializing_if = "is_false")]
573 receive_objects: bool,
574
575 #[serde(skip_serializing_if = "is_false")]
577 consensus_checkpoint_signature_key_includes_digest: bool,
578
579 #[serde(skip_serializing_if = "is_false")]
581 random_beacon: bool,
582
583 #[serde(skip_serializing_if = "is_false")]
585 #[skip_protocol_config_accessor]
586 bridge: bool,
587
588 #[serde(skip_serializing_if = "is_false")]
589 enable_effects_v2: bool,
590
591 #[serde(skip_serializing_if = "is_false")]
593 narwhal_certificate_v2: bool,
594
595 #[serde(skip_serializing_if = "is_false")]
597 verify_legacy_zklogin_address: bool,
598
599 #[serde(skip_serializing_if = "is_false")]
601 throughput_aware_consensus_submission: bool,
602
603 #[serde(skip_serializing_if = "is_false")]
605 recompute_has_public_transfer_in_execution: bool,
606
607 #[serde(skip_serializing_if = "is_false")]
609 accept_zklogin_in_multisig: bool,
610
611 #[serde(skip_serializing_if = "is_false")]
613 accept_passkey_in_multisig: bool,
614
615 #[serde(skip_serializing_if = "is_false")]
617 validate_zklogin_public_identifier: bool,
618
619 #[serde(skip_serializing_if = "is_false")]
622 include_consensus_digest_in_prologue: bool,
623
624 #[serde(skip_serializing_if = "is_false")]
626 hardened_otw_check: bool,
627
628 #[serde(skip_serializing_if = "is_false")]
630 allow_receiving_object_id: bool,
631
632 #[serde(skip_serializing_if = "is_false")]
634 enable_poseidon: bool,
635
636 #[serde(skip_serializing_if = "is_false")]
638 enable_coin_deny_list: bool,
639
640 #[serde(skip_serializing_if = "is_false")]
642 enable_group_ops_native_functions: bool,
643
644 #[serde(skip_serializing_if = "is_false")]
646 enable_group_ops_native_function_msm: bool,
647
648 #[serde(skip_serializing_if = "is_false")]
650 enable_ristretto255_group_ops: bool,
651
652 #[serde(skip_serializing_if = "is_false")]
654 enable_verify_bulletproofs_ristretto255: bool,
655
656 #[serde(skip_serializing_if = "is_false")]
658 enable_nitro_attestation: bool,
659
660 #[serde(skip_serializing_if = "is_false")]
662 enable_nitro_attestation_upgraded_parsing: bool,
663
664 #[serde(skip_serializing_if = "is_false")]
666 enable_nitro_attestation_all_nonzero_pcrs_parsing: bool,
667
668 #[serde(skip_serializing_if = "is_false")]
670 enable_nitro_attestation_always_include_required_pcrs_parsing: bool,
671
672 #[serde(skip_serializing_if = "is_false")]
674 reject_mutable_random_on_entry_functions: bool,
675
676 #[serde(skip_serializing_if = "PerObjectCongestionControlMode::is_none")]
678 per_object_congestion_control_mode: PerObjectCongestionControlMode,
679
680 #[serde(skip_serializing_if = "ConsensusChoice::is_narwhal")]
682 consensus_choice: ConsensusChoice,
683
684 #[serde(skip_serializing_if = "ConsensusNetwork::is_anemo")]
686 consensus_network: ConsensusNetwork,
687
688 #[serde(skip_serializing_if = "is_false")]
690 correct_gas_payment_limit_check: bool,
691
692 #[serde(skip_serializing_if = "Option::is_none")]
694 zklogin_max_epoch_upper_bound_delta: Option<u64>,
695
696 #[serde(skip_serializing_if = "is_false")]
698 mysticeti_leader_scoring_and_schedule: bool,
699
700 #[serde(skip_serializing_if = "is_false")]
702 reshare_at_same_initial_version: bool,
703
704 #[serde(skip_serializing_if = "is_false")]
706 resolve_abort_locations_to_package_id: bool,
707
708 #[serde(skip_serializing_if = "is_false")]
712 mysticeti_use_committed_subdag_digest: bool,
713
714 #[serde(skip_serializing_if = "is_false")]
716 enable_vdf: bool,
717
718 #[serde(skip_serializing_if = "is_false")]
722 record_consensus_determined_version_assignments_in_prologue: bool,
723 #[serde(skip_serializing_if = "is_false")]
726 record_consensus_determined_version_assignments_in_prologue_v2: bool,
727
728 #[serde(skip_serializing_if = "is_false")]
730 fresh_vm_on_framework_upgrade: bool,
731
732 #[serde(skip_serializing_if = "is_false")]
740 prepend_prologue_tx_in_consensus_commit_in_checkpoints: bool,
741
742 #[serde(skip_serializing_if = "Option::is_none")]
744 mysticeti_num_leaders_per_round: Option<usize>,
745
746 #[serde(skip_serializing_if = "is_false")]
748 soft_bundle: bool,
749
750 #[serde(skip_serializing_if = "is_false")]
752 enable_coin_deny_list_v2: bool,
753
754 #[serde(skip_serializing_if = "is_false")]
756 passkey_auth: bool,
757
758 #[serde(skip_serializing_if = "is_false")]
760 authority_capabilities_v2: bool,
761
762 #[serde(skip_serializing_if = "is_false")]
764 rethrow_serialization_type_layout_errors: bool,
765
766 #[serde(skip_serializing_if = "is_false")]
768 consensus_distributed_vote_scoring_strategy: bool,
769
770 #[serde(skip_serializing_if = "is_false")]
772 consensus_round_prober: bool,
773
774 #[serde(skip_serializing_if = "is_false")]
776 validate_identifier_inputs: bool,
777
778 #[serde(skip_serializing_if = "is_false")]
780 disallow_self_identifier: bool,
781
782 #[serde(skip_serializing_if = "is_false")]
784 mysticeti_fastpath: bool,
785
786 #[serde(skip_serializing_if = "is_false")]
790 disable_preconsensus_locking: bool,
791
792 #[serde(skip_serializing_if = "is_false")]
794 relocate_event_module: bool,
795
796 #[serde(skip_serializing_if = "is_false")]
798 uncompressed_g1_group_elements: bool,
799
800 #[serde(skip_serializing_if = "is_false")]
801 disallow_new_modules_in_deps_only_packages: bool,
802
803 #[serde(skip_serializing_if = "is_false")]
805 consensus_smart_ancestor_selection: bool,
806
807 #[serde(skip_serializing_if = "is_false")]
809 consensus_round_prober_probe_accepted_rounds: bool,
810
811 #[serde(skip_serializing_if = "is_false")]
813 native_charging_v2: bool,
814
815 #[serde(skip_serializing_if = "is_false")]
818 #[skip_protocol_config_accessor]
819 consensus_linearize_subdag_v2: bool,
820
821 #[serde(skip_serializing_if = "is_false")]
823 convert_type_argument_error: bool,
824
825 #[serde(skip_serializing_if = "is_false")]
827 variant_nodes: bool,
828
829 #[serde(skip_serializing_if = "is_false")]
831 consensus_zstd_compression: bool,
832
833 #[serde(skip_serializing_if = "is_false")]
835 minimize_child_object_mutations: bool,
836
837 #[serde(skip_serializing_if = "is_false")]
840 record_additional_state_digest_in_prologue: bool,
841
842 #[serde(skip_serializing_if = "is_false")]
844 move_native_context: bool,
845
846 #[serde(skip_serializing_if = "is_false")]
849 #[skip_protocol_config_accessor]
850 consensus_median_based_commit_timestamp: bool,
851
852 #[serde(skip_serializing_if = "is_false")]
855 normalize_ptb_arguments: bool,
856
857 #[serde(skip_serializing_if = "is_false")]
859 consensus_batched_block_sync: bool,
860
861 #[serde(skip_serializing_if = "is_false")]
863 enforce_checkpoint_timestamp_monotonicity: bool,
864
865 #[serde(skip_serializing_if = "is_false")]
867 max_ptb_value_size_v2: bool,
868
869 #[serde(skip_serializing_if = "is_false")]
871 resolve_type_input_ids_to_defining_id: bool,
872
873 #[serde(skip_serializing_if = "is_false")]
875 enable_party_transfer: bool,
876
877 #[serde(skip_serializing_if = "is_false")]
879 allow_unbounded_system_objects: bool,
880
881 #[serde(skip_serializing_if = "is_false")]
883 type_tags_in_object_runtime: bool,
884
885 #[serde(skip_serializing_if = "is_false")]
887 enable_accumulators: bool,
888
889 #[serde(skip_serializing_if = "is_false")]
891 #[skip_protocol_config_accessor]
892 enable_coin_reservation_obj_refs: bool,
893
894 #[serde(skip_serializing_if = "is_false")]
897 create_root_accumulator_object: bool,
898
899 #[serde(skip_serializing_if = "is_false")]
901 #[skip_protocol_config_accessor]
902 enable_authenticated_event_streams: bool,
903
904 #[serde(skip_serializing_if = "is_false")]
906 enable_address_balance_gas_payments: bool,
907
908 #[serde(skip_serializing_if = "is_false")]
910 address_balance_gas_check_rgp_at_signing: bool,
911
912 #[serde(skip_serializing_if = "is_false")]
913 address_balance_gas_reject_gas_coin_arg: bool,
914
915 #[serde(skip_serializing_if = "is_false")]
917 enable_multi_epoch_transaction_expiration: bool,
918
919 #[serde(skip_serializing_if = "is_false")]
921 relax_valid_during_for_owned_inputs: bool,
922
923 #[serde(skip_serializing_if = "is_false")]
925 enable_ptb_execution_v2: bool,
926
927 #[serde(skip_serializing_if = "is_false")]
929 better_adapter_type_resolution_errors: bool,
930
931 #[serde(skip_serializing_if = "is_false")]
933 record_time_estimate_processed: bool,
934
935 #[serde(skip_serializing_if = "is_false")]
937 dependency_linkage_error: bool,
938
939 #[serde(skip_serializing_if = "is_false")]
941 additional_multisig_checks: bool,
942
943 #[serde(skip_serializing_if = "is_false")]
945 ignore_execution_time_observations_after_certs_closed: bool,
946
947 #[serde(skip_serializing_if = "is_false")]
951 debug_fatal_on_move_invariant_violation: bool,
952
953 #[serde(skip_serializing_if = "is_false")]
956 allow_private_accumulator_entrypoints: bool,
957
958 #[serde(skip_serializing_if = "is_false")]
961 additional_consensus_digest_indirect_state: bool,
962
963 #[serde(skip_serializing_if = "is_false")]
965 check_for_init_during_upgrade: bool,
966
967 #[serde(skip_serializing_if = "is_false")]
969 enable_init_on_upgrade: bool,
970
971 #[serde(skip_serializing_if = "is_false")]
973 per_command_shared_object_transfer_rules: bool,
974
975 #[serde(skip_serializing_if = "is_false")]
977 include_checkpoint_artifacts_digest_in_summary: bool,
978
979 #[serde(skip_serializing_if = "is_false")]
981 use_mfp_txns_in_load_initial_object_debts: bool,
982
983 #[serde(skip_serializing_if = "is_false")]
985 cancel_for_failed_dkg_early: bool,
986
987 #[serde(skip_serializing_if = "is_false")]
989 always_advance_dkg_to_resolution: bool,
990
991 #[serde(skip_serializing_if = "is_false")]
993 enable_coin_registry: bool,
994
995 #[serde(skip_serializing_if = "is_false")]
997 abstract_size_in_object_runtime: bool,
998
999 #[serde(skip_serializing_if = "is_false")]
1001 object_runtime_charge_cache_load_gas: bool,
1002
1003 #[serde(skip_serializing_if = "is_false")]
1005 additional_borrow_checks: bool,
1006
1007 #[serde(skip_serializing_if = "is_false")]
1009 use_new_commit_handler: bool,
1010
1011 #[serde(skip_serializing_if = "is_false")]
1013 better_loader_errors: bool,
1014
1015 #[serde(skip_serializing_if = "is_false")]
1017 generate_df_type_layouts: bool,
1018
1019 #[serde(skip_serializing_if = "is_false")]
1021 allow_references_in_ptbs: bool,
1022
1023 #[serde(skip_serializing_if = "is_false")]
1025 enable_display_registry: bool,
1026
1027 #[serde(skip_serializing_if = "is_false")]
1029 private_generics_verifier_v2: bool,
1030
1031 #[serde(skip_serializing_if = "is_false")]
1033 deprecate_global_storage_ops_during_deserialization: bool,
1034
1035 #[serde(skip_serializing_if = "is_false")]
1038 enable_non_exclusive_writes: bool,
1039
1040 #[serde(skip_serializing_if = "is_false")]
1042 deprecate_global_storage_ops: bool,
1043
1044 #[serde(skip_serializing_if = "is_false")]
1046 normalize_depth_formula: bool,
1047
1048 #[serde(skip_serializing_if = "is_false")]
1050 consensus_skip_gced_accept_votes: bool,
1051
1052 #[serde(skip_serializing_if = "is_false")]
1055 include_cancelled_randomness_txns_in_prologue: bool,
1056
1057 #[serde(skip_serializing_if = "is_false")]
1059 #[skip_protocol_config_accessor]
1060 address_aliases: bool,
1061
1062 #[serde(skip_serializing_if = "is_false")]
1065 fix_checkpoint_signature_mapping: bool,
1066
1067 #[serde(skip_serializing_if = "is_false")]
1069 enable_object_funds_withdraw: bool,
1070
1071 #[serde(skip_serializing_if = "is_false")]
1074 record_net_unsettled_object_withdraws: bool,
1075
1076 #[serde(skip_serializing_if = "is_false")]
1078 consensus_skip_gced_blocks_in_direct_finalization: bool,
1079
1080 #[serde(skip_serializing_if = "is_false")]
1082 gas_rounding_halve_digits: bool,
1083
1084 #[serde(skip_serializing_if = "is_false")]
1086 flexible_tx_context_positions: bool,
1087
1088 #[serde(skip_serializing_if = "is_false")]
1090 disable_entry_point_signature_check: bool,
1091
1092 #[serde(skip_serializing_if = "is_false")]
1094 convert_withdrawal_compatibility_ptb_arguments: bool,
1095
1096 #[serde(skip_serializing_if = "is_false")]
1098 restrict_hot_or_not_entry_functions: bool,
1099
1100 #[serde(skip_serializing_if = "is_false")]
1102 split_checkpoints_in_consensus_handler: bool,
1103
1104 #[serde(skip_serializing_if = "is_false")]
1106 consensus_always_accept_system_transactions: bool,
1107
1108 #[serde(skip_serializing_if = "is_false")]
1110 validator_metadata_verify_v2: bool,
1111
1112 #[serde(skip_serializing_if = "is_false")]
1115 defer_unpaid_amplification: bool,
1116
1117 #[serde(skip_serializing_if = "is_false")]
1118 randomize_checkpoint_tx_limit_in_tests: bool,
1119
1120 #[serde(skip_serializing_if = "is_false")]
1122 gasless_transaction_drop_safety: bool,
1123
1124 #[serde(skip_serializing_if = "is_false")]
1127 merge_randomness_into_checkpoint: bool,
1128
1129 #[serde(skip_serializing_if = "is_false")]
1131 use_coin_party_owner: bool,
1132
1133 #[serde(skip_serializing_if = "is_false")]
1134 enable_gasless: bool,
1135
1136 #[serde(skip_serializing_if = "is_false")]
1137 gasless_verify_remaining_balance: bool,
1138
1139 #[serde(skip_serializing_if = "is_false")]
1140 disallow_jump_orphans: bool,
1141
1142 #[serde(skip_serializing_if = "is_false")]
1144 early_return_receive_object_mismatched_type: bool,
1145
1146 #[serde(skip_serializing_if = "is_false")]
1151 timestamp_based_epoch_close: bool,
1152
1153 #[serde(skip_serializing_if = "is_false")]
1156 limit_groth16_pvk_inputs: bool,
1157
1158 #[serde(skip_serializing_if = "is_false")]
1163 enforce_address_balance_change_invariant: bool,
1164
1165 #[serde(skip_serializing_if = "is_false")]
1167 share_transaction_deny_config_in_consensus: bool,
1168
1169 #[serde(skip_serializing_if = "is_false")]
1171 granular_post_execution_checks: bool,
1172
1173 #[serde(skip_serializing_if = "is_false")]
1175 early_exit_on_iffw: bool,
1176
1177 #[serde(skip_serializing_if = "is_false")]
1179 enable_unified_linkage: bool,
1180}
1181
1182fn is_false(b: &bool) -> bool {
1183 !b
1184}
1185
1186fn is_empty(b: &BTreeSet<String>) -> bool {
1187 b.is_empty()
1188}
1189
1190fn is_zero(val: &u64) -> bool {
1191 *val == 0
1192}
1193
1194#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1196pub enum ConsensusTransactionOrdering {
1197 #[default]
1199 None,
1200 ByGasPrice,
1202}
1203
1204impl ConsensusTransactionOrdering {
1205 pub fn is_none(&self) -> bool {
1206 matches!(self, ConsensusTransactionOrdering::None)
1207 }
1208}
1209
1210#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1211pub struct ExecutionTimeEstimateParams {
1212 pub target_utilization: u64,
1214 pub allowed_txn_cost_overage_burst_limit_us: u64,
1218
1219 pub randomness_scalar: u64,
1222
1223 pub max_estimate_us: u64,
1225
1226 pub stored_observations_num_included_checkpoints: u64,
1229
1230 pub stored_observations_limit: u64,
1232
1233 #[serde(skip_serializing_if = "is_zero")]
1236 pub stake_weighted_median_threshold: u64,
1237
1238 #[serde(skip_serializing_if = "is_false")]
1242 pub default_none_duration_for_new_keys: bool,
1243
1244 #[serde(skip_serializing_if = "Option::is_none")]
1246 pub observations_chunk_size: Option<u64>,
1247}
1248
1249#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1251pub enum PerObjectCongestionControlMode {
1252 #[default]
1253 None, TotalGasBudget, TotalTxCount, TotalGasBudgetWithCap, ExecutionTimeEstimate(ExecutionTimeEstimateParams), }
1259
1260impl PerObjectCongestionControlMode {
1261 pub fn is_none(&self) -> bool {
1262 matches!(self, PerObjectCongestionControlMode::None)
1263 }
1264}
1265
1266#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1268pub enum ConsensusChoice {
1269 #[default]
1270 Narwhal,
1271 SwapEachEpoch,
1272 Mysticeti,
1273}
1274
1275impl ConsensusChoice {
1276 pub fn is_narwhal(&self) -> bool {
1277 matches!(self, ConsensusChoice::Narwhal)
1278 }
1279}
1280
1281#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1283pub enum ConsensusNetwork {
1284 #[default]
1285 Anemo,
1286 Tonic,
1287}
1288
1289impl ConsensusNetwork {
1290 pub fn is_anemo(&self) -> bool {
1291 matches!(self, ConsensusNetwork::Anemo)
1292 }
1293}
1294
1295#[skip_serializing_none]
1327#[derive(Clone, Serialize, Debug, ProtocolConfigAccessors, ProtocolConfigOverride)]
1328pub struct ProtocolConfig {
1329 pub version: ProtocolVersion,
1330
1331 #[serde(skip)]
1336 chain: Chain,
1337
1338 feature_flags: FeatureFlags,
1339
1340 max_tx_size_bytes: Option<u64>,
1343
1344 max_input_objects: Option<u64>,
1346
1347 max_size_written_objects: Option<u64>,
1351 max_size_written_objects_system_tx: Option<u64>,
1354
1355 max_serialized_tx_effects_size_bytes: Option<u64>,
1357
1358 max_serialized_tx_effects_size_bytes_system_tx: Option<u64>,
1360
1361 max_gas_payment_objects: Option<u32>,
1363
1364 max_modules_in_publish: Option<u32>,
1366
1367 max_package_dependencies: Option<u32>,
1369
1370 max_arguments: Option<u32>,
1373
1374 max_type_arguments: Option<u32>,
1376
1377 max_type_argument_depth: Option<u32>,
1379
1380 max_pure_argument_size: Option<u32>,
1382
1383 max_programmable_tx_commands: Option<u32>,
1385
1386 move_binary_format_version: Option<u32>,
1389 min_move_binary_format_version: Option<u32>,
1390
1391 binary_module_handles: Option<u16>,
1393 binary_struct_handles: Option<u16>,
1394 binary_function_handles: Option<u16>,
1395 binary_function_instantiations: Option<u16>,
1396 binary_signatures: Option<u16>,
1397 binary_constant_pool: Option<u16>,
1398 binary_identifiers: Option<u16>,
1399 binary_address_identifiers: Option<u16>,
1400 binary_struct_defs: Option<u16>,
1401 binary_struct_def_instantiations: Option<u16>,
1402 binary_function_defs: Option<u16>,
1403 binary_field_handles: Option<u16>,
1404 binary_field_instantiations: Option<u16>,
1405 binary_friend_decls: Option<u16>,
1406 binary_enum_defs: Option<u16>,
1407 binary_enum_def_instantiations: Option<u16>,
1408 binary_variant_handles: Option<u16>,
1409 binary_variant_instantiation_handles: Option<u16>,
1410
1411 max_move_object_size: Option<u64>,
1413
1414 max_move_package_size: Option<u64>,
1417
1418 max_publish_or_upgrade_per_ptb: Option<u64>,
1420
1421 max_tx_gas: Option<u64>,
1423
1424 max_gas_price: Option<u64>,
1426
1427 max_gas_price_rgp_factor_for_aborted_transactions: Option<u64>,
1430
1431 max_gas_computation_bucket: Option<u64>,
1433
1434 gas_rounding_step: Option<u64>,
1436
1437 max_loop_depth: Option<u64>,
1439
1440 max_generic_instantiation_length: Option<u64>,
1442
1443 max_function_parameters: Option<u64>,
1445
1446 max_basic_blocks: Option<u64>,
1448
1449 max_value_stack_size: Option<u64>,
1451
1452 max_type_nodes: Option<u64>,
1454
1455 max_generic_instantiation_type_nodes_per_function: Option<u64>,
1457
1458 max_generic_instantiation_type_nodes_per_module: Option<u64>,
1460
1461 max_push_size: Option<u64>,
1463
1464 max_struct_definitions: Option<u64>,
1466
1467 max_function_definitions: Option<u64>,
1469
1470 max_fields_in_struct: Option<u64>,
1472
1473 max_dependency_depth: Option<u64>,
1475
1476 max_num_event_emit: Option<u64>,
1478
1479 max_num_new_move_object_ids: Option<u64>,
1481
1482 max_num_new_move_object_ids_system_tx: Option<u64>,
1484
1485 max_num_deleted_move_object_ids: Option<u64>,
1487
1488 max_num_deleted_move_object_ids_system_tx: Option<u64>,
1490
1491 max_num_transferred_move_object_ids: Option<u64>,
1493
1494 max_num_transferred_move_object_ids_system_tx: Option<u64>,
1496
1497 max_event_emit_size: Option<u64>,
1499
1500 max_event_emit_size_total: Option<u64>,
1502
1503 max_move_vector_len: Option<u64>,
1505
1506 max_move_identifier_len: Option<u64>,
1508
1509 max_move_value_depth: Option<u64>,
1511
1512 max_move_enum_variants: Option<u64>,
1514
1515 max_back_edges_per_function: Option<u64>,
1517
1518 max_back_edges_per_module: Option<u64>,
1520
1521 max_verifier_meter_ticks_per_function: Option<u64>,
1523
1524 max_meter_ticks_per_module: Option<u64>,
1526
1527 max_meter_ticks_per_package: Option<u64>,
1529
1530 object_runtime_max_num_cached_objects: Option<u64>,
1534
1535 object_runtime_max_num_cached_objects_system_tx: Option<u64>,
1537
1538 object_runtime_max_num_store_entries: Option<u64>,
1540
1541 object_runtime_max_num_store_entries_system_tx: Option<u64>,
1543
1544 base_tx_cost_fixed: Option<u64>,
1547
1548 package_publish_cost_fixed: Option<u64>,
1551
1552 base_tx_cost_per_byte: Option<u64>,
1555
1556 package_publish_cost_per_byte: Option<u64>,
1558
1559 obj_access_cost_read_per_byte: Option<u64>,
1561
1562 obj_access_cost_mutate_per_byte: Option<u64>,
1564
1565 obj_access_cost_delete_per_byte: Option<u64>,
1567
1568 obj_access_cost_verify_per_byte: Option<u64>,
1578
1579 max_type_to_layout_nodes: Option<u64>,
1581
1582 max_ptb_value_size: Option<u64>,
1584
1585 gas_model_version: Option<u64>,
1588
1589 obj_data_cost_refundable: Option<u64>,
1592
1593 obj_metadata_cost_non_refundable: Option<u64>,
1597
1598 storage_rebate_rate: Option<u64>,
1604
1605 storage_fund_reinvest_rate: Option<u64>,
1608
1609 reward_slashing_rate: Option<u64>,
1612
1613 storage_gas_price: Option<u64>,
1615
1616 accumulator_object_storage_cost: Option<u64>,
1618
1619 max_transactions_per_checkpoint: Option<u64>,
1624
1625 max_checkpoint_size_bytes: Option<u64>,
1629
1630 buffer_stake_for_protocol_upgrade_bps: Option<u64>,
1635
1636 address_from_bytes_cost_base: Option<u64>,
1641 address_to_u256_cost_base: Option<u64>,
1643 address_from_u256_cost_base: Option<u64>,
1645
1646 config_read_setting_impl_cost_base: Option<u64>,
1651 config_read_setting_impl_cost_per_byte: Option<u64>,
1652
1653 dynamic_field_hash_type_and_key_cost_base: Option<u64>,
1656 dynamic_field_hash_type_and_key_type_cost_per_byte: Option<u64>,
1657 dynamic_field_hash_type_and_key_value_cost_per_byte: Option<u64>,
1658 dynamic_field_hash_type_and_key_type_tag_cost_per_byte: Option<u64>,
1659 dynamic_field_add_child_object_cost_base: Option<u64>,
1661 dynamic_field_add_child_object_type_cost_per_byte: Option<u64>,
1662 dynamic_field_add_child_object_value_cost_per_byte: Option<u64>,
1663 dynamic_field_add_child_object_struct_tag_cost_per_byte: Option<u64>,
1664 dynamic_field_borrow_child_object_cost_base: Option<u64>,
1666 dynamic_field_borrow_child_object_child_ref_cost_per_byte: Option<u64>,
1667 dynamic_field_borrow_child_object_type_cost_per_byte: Option<u64>,
1668 dynamic_field_remove_child_object_cost_base: Option<u64>,
1670 dynamic_field_remove_child_object_child_cost_per_byte: Option<u64>,
1671 dynamic_field_remove_child_object_type_cost_per_byte: Option<u64>,
1672 dynamic_field_has_child_object_cost_base: Option<u64>,
1674 dynamic_field_has_child_object_with_ty_cost_base: Option<u64>,
1676 dynamic_field_has_child_object_with_ty_type_cost_per_byte: Option<u64>,
1677 dynamic_field_has_child_object_with_ty_type_tag_cost_per_byte: Option<u64>,
1678
1679 scratch_add_cost_base: Option<u64>,
1682 scratch_read_cost_base: Option<u64>,
1684 scratch_read_value_cost: Option<u64>,
1685 scratch_remove_cost_base: Option<u64>,
1687 scratch_exists_cost_base: Option<u64>,
1689 scratch_exists_with_type_cost_base: Option<u64>,
1691 scratch_exists_with_type_type_cost: Option<u64>,
1692 max_scratch_pad_size: Option<u64>,
1694
1695 event_emit_cost_base: Option<u64>,
1698 event_emit_value_size_derivation_cost_per_byte: Option<u64>,
1699 event_emit_tag_size_derivation_cost_per_byte: Option<u64>,
1700 event_emit_output_cost_per_byte: Option<u64>,
1701 event_emit_auth_stream_cost: Option<u64>,
1702
1703 object_borrow_uid_cost_base: Option<u64>,
1706 object_delete_impl_cost_base: Option<u64>,
1708 object_record_new_uid_cost_base: Option<u64>,
1710
1711 transfer_transfer_internal_cost_base: Option<u64>,
1714 transfer_party_transfer_internal_cost_base: Option<u64>,
1716 transfer_freeze_object_cost_base: Option<u64>,
1718 transfer_share_object_cost_base: Option<u64>,
1720 transfer_receive_object_cost_base: Option<u64>,
1723 transfer_receive_object_cost_per_byte: Option<u64>,
1724 transfer_receive_object_type_cost_per_byte: Option<u64>,
1725
1726 tx_context_derive_id_cost_base: Option<u64>,
1729 tx_context_fresh_id_cost_base: Option<u64>,
1730 tx_context_sender_cost_base: Option<u64>,
1731 tx_context_epoch_cost_base: Option<u64>,
1732 tx_context_epoch_timestamp_ms_cost_base: Option<u64>,
1733 tx_context_sponsor_cost_base: Option<u64>,
1734 tx_context_rgp_cost_base: Option<u64>,
1735 tx_context_gas_price_cost_base: Option<u64>,
1736 tx_context_gas_budget_cost_base: Option<u64>,
1737 tx_context_ids_created_cost_base: Option<u64>,
1738 tx_context_replace_cost_base: Option<u64>,
1739
1740 types_is_one_time_witness_cost_base: Option<u64>,
1743 types_is_one_time_witness_type_tag_cost_per_byte: Option<u64>,
1744 types_is_one_time_witness_type_cost_per_byte: Option<u64>,
1745
1746 validator_validate_metadata_cost_base: Option<u64>,
1749 validator_validate_metadata_data_cost_per_byte: Option<u64>,
1750
1751 crypto_invalid_arguments_cost: Option<u64>,
1753 bls12381_bls12381_min_sig_verify_cost_base: Option<u64>,
1755 bls12381_bls12381_min_sig_verify_msg_cost_per_byte: Option<u64>,
1756 bls12381_bls12381_min_sig_verify_msg_cost_per_block: Option<u64>,
1757
1758 bls12381_bls12381_min_pk_verify_cost_base: Option<u64>,
1760 bls12381_bls12381_min_pk_verify_msg_cost_per_byte: Option<u64>,
1761 bls12381_bls12381_min_pk_verify_msg_cost_per_block: Option<u64>,
1762
1763 ecdsa_k1_ecrecover_keccak256_cost_base: Option<u64>,
1765 ecdsa_k1_ecrecover_keccak256_msg_cost_per_byte: Option<u64>,
1766 ecdsa_k1_ecrecover_keccak256_msg_cost_per_block: Option<u64>,
1767 ecdsa_k1_ecrecover_sha256_cost_base: Option<u64>,
1768 ecdsa_k1_ecrecover_sha256_msg_cost_per_byte: Option<u64>,
1769 ecdsa_k1_ecrecover_sha256_msg_cost_per_block: Option<u64>,
1770
1771 ecdsa_k1_decompress_pubkey_cost_base: Option<u64>,
1773
1774 ecdsa_k1_secp256k1_verify_keccak256_cost_base: Option<u64>,
1776 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_byte: Option<u64>,
1777 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_block: Option<u64>,
1778 ecdsa_k1_secp256k1_verify_sha256_cost_base: Option<u64>,
1779 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_byte: Option<u64>,
1780 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_block: Option<u64>,
1781
1782 ecdsa_r1_ecrecover_keccak256_cost_base: Option<u64>,
1784 ecdsa_r1_ecrecover_keccak256_msg_cost_per_byte: Option<u64>,
1785 ecdsa_r1_ecrecover_keccak256_msg_cost_per_block: Option<u64>,
1786 ecdsa_r1_ecrecover_sha256_cost_base: Option<u64>,
1787 ecdsa_r1_ecrecover_sha256_msg_cost_per_byte: Option<u64>,
1788 ecdsa_r1_ecrecover_sha256_msg_cost_per_block: Option<u64>,
1789
1790 ecdsa_r1_secp256r1_verify_keccak256_cost_base: Option<u64>,
1792 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_byte: Option<u64>,
1793 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_block: Option<u64>,
1794 ecdsa_r1_secp256r1_verify_sha256_cost_base: Option<u64>,
1795 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_byte: Option<u64>,
1796 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_block: Option<u64>,
1797
1798 ecvrf_ecvrf_verify_cost_base: Option<u64>,
1800 ecvrf_ecvrf_verify_alpha_string_cost_per_byte: Option<u64>,
1801 ecvrf_ecvrf_verify_alpha_string_cost_per_block: Option<u64>,
1802
1803 ed25519_ed25519_verify_cost_base: Option<u64>,
1805 ed25519_ed25519_verify_msg_cost_per_byte: Option<u64>,
1806 ed25519_ed25519_verify_msg_cost_per_block: Option<u64>,
1807
1808 groth16_prepare_verifying_key_bls12381_cost_base: Option<u64>,
1810 groth16_prepare_verifying_key_bn254_cost_base: Option<u64>,
1811
1812 groth16_verify_groth16_proof_internal_bls12381_cost_base: Option<u64>,
1814 groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input: Option<u64>,
1815 groth16_verify_groth16_proof_internal_bn254_cost_base: Option<u64>,
1816 groth16_verify_groth16_proof_internal_bn254_cost_per_public_input: Option<u64>,
1817 groth16_verify_groth16_proof_internal_public_input_cost_per_byte: Option<u64>,
1818
1819 hash_blake2b256_cost_base: Option<u64>,
1821 hash_blake2b256_data_cost_per_byte: Option<u64>,
1822 hash_blake2b256_data_cost_per_block: Option<u64>,
1823
1824 hash_keccak256_cost_base: Option<u64>,
1826 hash_keccak256_data_cost_per_byte: Option<u64>,
1827 hash_keccak256_data_cost_per_block: Option<u64>,
1828
1829 poseidon_bn254_cost_base: Option<u64>,
1831 poseidon_bn254_cost_per_block: Option<u64>,
1832
1833 group_ops_bls12381_decode_scalar_cost: Option<u64>,
1835 group_ops_bls12381_decode_g1_cost: Option<u64>,
1836 group_ops_bls12381_decode_g2_cost: Option<u64>,
1837 group_ops_bls12381_decode_gt_cost: Option<u64>,
1838 group_ops_bls12381_scalar_add_cost: Option<u64>,
1839 group_ops_bls12381_g1_add_cost: Option<u64>,
1840 group_ops_bls12381_g2_add_cost: Option<u64>,
1841 group_ops_bls12381_gt_add_cost: Option<u64>,
1842 group_ops_bls12381_scalar_sub_cost: Option<u64>,
1843 group_ops_bls12381_g1_sub_cost: Option<u64>,
1844 group_ops_bls12381_g2_sub_cost: Option<u64>,
1845 group_ops_bls12381_gt_sub_cost: Option<u64>,
1846 group_ops_bls12381_scalar_mul_cost: Option<u64>,
1847 group_ops_bls12381_g1_mul_cost: Option<u64>,
1848 group_ops_bls12381_g2_mul_cost: Option<u64>,
1849 group_ops_bls12381_gt_mul_cost: Option<u64>,
1850 group_ops_bls12381_scalar_div_cost: Option<u64>,
1851 group_ops_bls12381_g1_div_cost: Option<u64>,
1852 group_ops_bls12381_g2_div_cost: Option<u64>,
1853 group_ops_bls12381_gt_div_cost: Option<u64>,
1854 group_ops_bls12381_g1_hash_to_base_cost: Option<u64>,
1855 group_ops_bls12381_g2_hash_to_base_cost: Option<u64>,
1856 group_ops_bls12381_g1_hash_to_cost_per_byte: Option<u64>,
1857 group_ops_bls12381_g2_hash_to_cost_per_byte: Option<u64>,
1858 group_ops_bls12381_g1_msm_base_cost: Option<u64>,
1859 group_ops_bls12381_g2_msm_base_cost: Option<u64>,
1860 group_ops_bls12381_g1_msm_base_cost_per_input: Option<u64>,
1861 group_ops_bls12381_g2_msm_base_cost_per_input: Option<u64>,
1862 group_ops_bls12381_msm_max_len: Option<u32>,
1863 group_ops_bls12381_pairing_cost: Option<u64>,
1864 group_ops_bls12381_g1_to_uncompressed_g1_cost: Option<u64>,
1865 group_ops_bls12381_uncompressed_g1_to_g1_cost: Option<u64>,
1866 group_ops_bls12381_uncompressed_g1_sum_base_cost: Option<u64>,
1867 group_ops_bls12381_uncompressed_g1_sum_cost_per_term: Option<u64>,
1868 group_ops_bls12381_uncompressed_g1_sum_max_terms: Option<u64>,
1869
1870 group_ops_ristretto_decode_scalar_cost: Option<u64>,
1871 group_ops_ristretto_decode_point_cost: Option<u64>,
1872 group_ops_ristretto_scalar_add_cost: Option<u64>,
1873 group_ops_ristretto_point_add_cost: Option<u64>,
1874 group_ops_ristretto_scalar_sub_cost: Option<u64>,
1875 group_ops_ristretto_point_sub_cost: Option<u64>,
1876 group_ops_ristretto_scalar_mul_cost: Option<u64>,
1877 group_ops_ristretto_point_mul_cost: Option<u64>,
1878 group_ops_ristretto_scalar_div_cost: Option<u64>,
1879 group_ops_ristretto_point_div_cost: Option<u64>,
1880
1881 verify_bulletproofs_ristretto255_base_cost: Option<u64>,
1882 verify_bulletproofs_ristretto255_cost_per_bit_and_commitment: Option<u64>,
1883
1884 hmac_hmac_sha3_256_cost_base: Option<u64>,
1886 hmac_hmac_sha3_256_input_cost_per_byte: Option<u64>,
1887 hmac_hmac_sha3_256_input_cost_per_block: Option<u64>,
1888
1889 check_zklogin_id_cost_base: Option<u64>,
1891 check_zklogin_issuer_cost_base: Option<u64>,
1893
1894 vdf_verify_vdf_cost: Option<u64>,
1895 vdf_hash_to_input_cost: Option<u64>,
1896
1897 nitro_attestation_parse_base_cost: Option<u64>,
1899 nitro_attestation_parse_cost_per_byte: Option<u64>,
1900 nitro_attestation_verify_base_cost: Option<u64>,
1901 nitro_attestation_verify_cost_per_cert: Option<u64>,
1902
1903 bcs_per_byte_serialized_cost: Option<u64>,
1905 bcs_legacy_min_output_size_cost: Option<u64>,
1906 bcs_failure_cost: Option<u64>,
1907
1908 hash_sha2_256_base_cost: Option<u64>,
1909 hash_sha2_256_per_byte_cost: Option<u64>,
1910 hash_sha2_256_legacy_min_input_len_cost: Option<u64>,
1911 hash_sha3_256_base_cost: Option<u64>,
1912 hash_sha3_256_per_byte_cost: Option<u64>,
1913 hash_sha3_256_legacy_min_input_len_cost: Option<u64>,
1914 type_name_get_base_cost: Option<u64>,
1915 type_name_get_per_byte_cost: Option<u64>,
1916 type_name_id_base_cost: Option<u64>,
1917
1918 string_check_utf8_base_cost: Option<u64>,
1919 string_check_utf8_per_byte_cost: Option<u64>,
1920 string_is_char_boundary_base_cost: Option<u64>,
1921 string_sub_string_base_cost: Option<u64>,
1922 string_sub_string_per_byte_cost: Option<u64>,
1923 string_index_of_base_cost: Option<u64>,
1924 string_index_of_per_byte_pattern_cost: Option<u64>,
1925 string_index_of_per_byte_searched_cost: Option<u64>,
1926
1927 vector_empty_base_cost: Option<u64>,
1928 vector_length_base_cost: Option<u64>,
1929 vector_push_back_base_cost: Option<u64>,
1930 vector_push_back_legacy_per_abstract_memory_unit_cost: Option<u64>,
1931 vector_borrow_base_cost: Option<u64>,
1932 vector_pop_back_base_cost: Option<u64>,
1933 vector_destroy_empty_base_cost: Option<u64>,
1934 vector_swap_base_cost: Option<u64>,
1935 debug_print_base_cost: Option<u64>,
1936 debug_print_stack_trace_base_cost: Option<u64>,
1937
1938 execution_version: Option<u64>,
1947
1948 consensus_bad_nodes_stake_threshold: Option<u64>,
1952
1953 max_jwk_votes_per_validator_per_epoch: Option<u64>,
1954 max_age_of_jwk_in_epochs: Option<u64>,
1958
1959 random_beacon_reduction_allowed_delta: Option<u16>,
1963
1964 random_beacon_reduction_lower_bound: Option<u32>,
1967
1968 random_beacon_dkg_timeout_round: Option<u32>,
1971
1972 random_beacon_min_round_interval_ms: Option<u64>,
1974
1975 random_beacon_dkg_version: Option<u64>,
1978
1979 consensus_max_transaction_size_bytes: Option<u64>,
1982 consensus_max_transactions_in_block_bytes: Option<u64>,
1984 consensus_max_num_transactions_in_block: Option<u64>,
1986
1987 consensus_voting_rounds: Option<u32>,
1989
1990 max_accumulated_txn_cost_per_object_in_narwhal_commit: Option<u64>,
1992
1993 max_deferral_rounds_for_congestion_control: Option<u64>,
1996
1997 epoch_close_deadline_ms: Option<u64>,
2002
2003 max_txn_cost_overage_per_object_in_commit: Option<u64>,
2005
2006 allowed_txn_cost_overage_burst_per_object_in_commit: Option<u64>,
2008
2009 min_checkpoint_interval_ms: Option<u64>,
2011
2012 checkpoint_summary_version_specific_data: Option<u64>,
2014
2015 max_soft_bundle_size: Option<u64>,
2017
2018 bridge_should_try_to_finalize_committee: Option<bool>,
2022
2023 max_accumulated_txn_cost_per_object_in_mysticeti_commit: Option<u64>,
2029
2030 max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit: Option<u64>,
2033
2034 consensus_gc_depth: Option<u32>,
2037
2038 gas_budget_based_txn_cost_cap_factor: Option<u64>,
2040
2041 gas_budget_based_txn_cost_absolute_cap_commit_count: Option<u64>,
2043
2044 sip_45_consensus_amplification_threshold: Option<u64>,
2047
2048 use_object_per_epoch_marker_table_v2: Option<bool>,
2051
2052 consensus_commit_rate_estimation_window_size: Option<u32>,
2054
2055 #[serde(skip_serializing_if = "Vec::is_empty")]
2059 aliased_addresses: Vec<AliasedAddress>,
2060
2061 translation_per_command_base_charge: Option<u64>,
2064
2065 translation_per_input_base_charge: Option<u64>,
2068
2069 translation_pure_input_per_byte_charge: Option<u64>,
2071
2072 translation_per_type_node_charge: Option<u64>,
2076
2077 translation_per_reference_node_charge: Option<u64>,
2080
2081 translation_per_linkage_entry_charge: Option<u64>,
2084
2085 max_updates_per_settlement_txn: Option<u32>,
2087
2088 gasless_max_computation_units: Option<u64>,
2090
2091 gasless_allowed_token_types: Option<Vec<(String, u64)>>,
2093
2094 gasless_max_unused_inputs: Option<u64>,
2098
2099 gasless_max_pure_input_bytes: Option<u64>,
2102
2103 gasless_max_tps: Option<u64>,
2105
2106 #[serde(skip_serializing_if = "Option::is_none")]
2107 #[skip_accessor]
2108 include_special_package_amendments: Option<Arc<Amendments>>,
2109
2110 gasless_max_tx_size_bytes: Option<u64>,
2113}
2114
2115#[derive(Clone, Serialize, Deserialize, Debug)]
2117pub struct AliasedAddress {
2118 pub original: [u8; 32],
2120 pub aliased: [u8; 32],
2122 pub allowed_tx_digests: Vec<[u8; 32]>,
2124}
2125
2126impl ProtocolConfig {
2128 pub fn chain(&self) -> Chain {
2130 self.chain
2131 }
2132
2133 pub fn check_package_upgrades_supported(&self) -> Result<(), Error> {
2146 if self.feature_flags.package_upgrades {
2147 Ok(())
2148 } else {
2149 Err(Error(format!(
2150 "package upgrades are not supported at {:?}",
2151 self.version
2152 )))
2153 }
2154 }
2155
2156 pub fn zklogin_supported_providers(&self) -> &BTreeSet<String> {
2157 &self.feature_flags.zklogin_supported_providers
2158 }
2159
2160 pub fn zklogin_circuit_mode(&self) -> u64 {
2163 self.feature_flags.zklogin_circuit_mode
2164 }
2165
2166 pub fn consensus_transaction_ordering(&self) -> ConsensusTransactionOrdering {
2167 self.feature_flags.consensus_transaction_ordering
2168 }
2169
2170 pub fn enable_jwk_consensus_updates(&self) -> bool {
2171 let ret = self.feature_flags.enable_jwk_consensus_updates;
2172 if ret {
2173 assert!(self.feature_flags.end_of_epoch_transaction_supported);
2175 }
2176 ret
2177 }
2178
2179 pub fn end_of_epoch_transaction_supported(&self) -> bool {
2180 let ret = self.feature_flags.end_of_epoch_transaction_supported;
2181 if !ret {
2182 assert!(!self.feature_flags.enable_jwk_consensus_updates);
2184 }
2185 ret
2186 }
2187
2188 pub fn dkg_version(&self) -> u64 {
2189 self.random_beacon_dkg_version.unwrap_or(1)
2191 }
2192
2193 pub fn bridge(&self) -> bool {
2194 let ret = self.feature_flags.bridge;
2195 if ret {
2196 assert!(self.feature_flags.end_of_epoch_transaction_supported);
2198 }
2199 ret
2200 }
2201
2202 pub fn should_try_to_finalize_bridge_committee(&self) -> bool {
2203 if !self.bridge() {
2204 return false;
2205 }
2206 self.bridge_should_try_to_finalize_committee.unwrap_or(true)
2208 }
2209
2210 pub fn zklogin_max_epoch_upper_bound_delta(&self) -> Option<u64> {
2211 self.feature_flags.zklogin_max_epoch_upper_bound_delta
2212 }
2213
2214 pub fn enable_coin_reservation_obj_refs(&self) -> bool {
2215 self.new_vm_enabled() && self.feature_flags.enable_coin_reservation_obj_refs
2216 }
2217
2218 pub fn enable_authenticated_event_streams(&self) -> bool {
2219 self.feature_flags.enable_authenticated_event_streams && self.enable_accumulators()
2220 }
2221
2222 pub fn per_object_congestion_control_mode(&self) -> PerObjectCongestionControlMode {
2223 self.feature_flags.per_object_congestion_control_mode
2224 }
2225
2226 pub fn consensus_choice(&self) -> ConsensusChoice {
2227 self.feature_flags.consensus_choice
2228 }
2229
2230 pub fn consensus_network(&self) -> ConsensusNetwork {
2231 self.feature_flags.consensus_network
2232 }
2233
2234 pub fn mysticeti_num_leaders_per_round(&self) -> Option<usize> {
2235 self.feature_flags.mysticeti_num_leaders_per_round
2236 }
2237
2238 pub fn max_transaction_size_bytes(&self) -> u64 {
2239 self.consensus_max_transaction_size_bytes
2241 .unwrap_or(256 * 1024)
2242 }
2243
2244 pub fn max_transactions_in_block_bytes(&self) -> u64 {
2245 if cfg!(msim) {
2246 256 * 1024
2247 } else {
2248 self.consensus_max_transactions_in_block_bytes
2249 .unwrap_or(512 * 1024)
2250 }
2251 }
2252
2253 pub fn max_num_transactions_in_block(&self) -> u64 {
2254 if cfg!(msim) {
2255 8
2256 } else {
2257 self.consensus_max_num_transactions_in_block.unwrap_or(512)
2258 }
2259 }
2260
2261 pub fn gc_depth(&self) -> u32 {
2262 self.consensus_gc_depth.unwrap_or(0)
2263 }
2264
2265 pub fn consensus_linearize_subdag_v2(&self) -> bool {
2266 let res = self.feature_flags.consensus_linearize_subdag_v2;
2267 assert!(
2268 !res || self.gc_depth() > 0,
2269 "The consensus linearize sub dag V2 requires GC to be enabled"
2270 );
2271 res
2272 }
2273
2274 pub fn consensus_median_based_commit_timestamp(&self) -> bool {
2275 let res = self.feature_flags.consensus_median_based_commit_timestamp;
2276 assert!(
2277 !res || self.gc_depth() > 0,
2278 "The consensus median based commit timestamp requires GC to be enabled"
2279 );
2280 res
2281 }
2282
2283 pub fn get_consensus_commit_rate_estimation_window_size(&self) -> u32 {
2284 self.consensus_commit_rate_estimation_window_size
2285 .unwrap_or(0)
2286 }
2287
2288 pub fn consensus_num_requested_prior_commits_at_startup(&self) -> u32 {
2289 let window_size = self.get_consensus_commit_rate_estimation_window_size();
2293 assert!(window_size == 0 || self.record_additional_state_digest_in_prologue());
2295 window_size
2296 }
2297
2298 pub fn enable_observation_chunking(&self) -> bool {
2299 matches!(self.feature_flags.per_object_congestion_control_mode,
2300 PerObjectCongestionControlMode::ExecutionTimeEstimate(ref params)
2301 if params.observations_chunk_size.is_some()
2302 )
2303 }
2304
2305 pub fn address_aliases(&self) -> bool {
2306 let address_aliases = self.feature_flags.address_aliases;
2307 assert!(
2308 !address_aliases || self.mysticeti_fastpath(),
2309 "Address aliases requires Mysticeti fastpath to be enabled"
2310 );
2311 if address_aliases {
2312 assert!(
2313 self.feature_flags.disable_preconsensus_locking,
2314 "Address aliases requires CertifiedTransaction to be disabled"
2315 );
2316 }
2317 address_aliases
2318 }
2319
2320 pub fn new_vm_enabled(&self) -> bool {
2321 self.execution_version.is_some_and(|v| v >= 4)
2322 }
2323
2324 pub fn gasless_allowed_token_types(&self) -> &[(String, u64)] {
2325 debug_assert!(self.gasless_allowed_token_types.is_some());
2326 self.gasless_allowed_token_types.as_deref().unwrap_or(&[])
2327 }
2328
2329 pub fn get_gasless_max_unused_inputs(&self) -> u64 {
2330 self.gasless_max_unused_inputs.unwrap_or(u64::MAX)
2331 }
2332
2333 pub fn get_gasless_max_pure_input_bytes(&self) -> u64 {
2334 self.gasless_max_pure_input_bytes.unwrap_or(u64::MAX)
2335 }
2336
2337 pub fn get_gasless_max_tx_size_bytes(&self) -> u64 {
2338 self.gasless_max_tx_size_bytes.unwrap_or(u64::MAX)
2339 }
2340
2341 pub fn include_special_package_amendments_as_option(&self) -> &Option<Arc<Amendments>> {
2342 &self.include_special_package_amendments
2343 }
2344}
2345
2346#[cfg(not(msim))]
2347static POISON_VERSION_METHODS: AtomicBool = AtomicBool::new(false);
2348
2349#[cfg(msim)]
2351thread_local! {
2352 static POISON_VERSION_METHODS: AtomicBool = AtomicBool::new(false);
2353}
2354
2355impl ProtocolConfig {
2357 pub fn get_for_version(version: ProtocolVersion, chain: Chain) -> Self {
2359 assert!(
2361 version >= ProtocolVersion::MIN,
2362 "Network protocol version is {:?}, but the minimum supported version by the binary is {:?}. Please upgrade the binary.",
2363 version,
2364 ProtocolVersion::MIN.0,
2365 );
2366 assert!(
2367 version <= ProtocolVersion::MAX_ALLOWED,
2368 "Network protocol version is {:?}, but the maximum supported version by the binary is {:?}. Please upgrade the binary.",
2369 version,
2370 ProtocolVersion::MAX_ALLOWED.0,
2371 );
2372
2373 let mut ret = Self::get_for_version_impl(version, chain);
2374 ret.version = version;
2375 ret.chain = chain;
2376
2377 ret = Self::apply_config_override(version, ret);
2378
2379 if std::env::var("SUI_PROTOCOL_CONFIG_OVERRIDE_ENABLE").is_ok() {
2380 warn!(
2381 "overriding ProtocolConfig settings with custom settings; this may break non-local networks"
2382 );
2383 let overrides: ProtocolConfigOptional =
2384 serde_env::from_env_with_prefix("SUI_PROTOCOL_CONFIG_OVERRIDE")
2385 .expect("failed to parse ProtocolConfig override env variables");
2386 overrides.apply_to(&mut ret);
2387 }
2388
2389 ret
2390 }
2391
2392 pub fn get_for_version_if_supported(version: ProtocolVersion, chain: Chain) -> Option<Self> {
2395 if version.0 >= ProtocolVersion::MIN.0 && version.0 <= ProtocolVersion::MAX_ALLOWED.0 {
2396 let mut ret = Self::get_for_version_impl(version, chain);
2397 ret.version = version;
2398 ret.chain = chain;
2399 ret = Self::apply_config_override(version, ret);
2400 Some(ret)
2401 } else {
2402 None
2403 }
2404 }
2405
2406 #[cfg(not(msim))]
2407 pub fn poison_get_for_min_version() {
2408 POISON_VERSION_METHODS.store(true, Ordering::Relaxed);
2409 }
2410
2411 #[cfg(not(msim))]
2412 fn load_poison_get_for_min_version() -> bool {
2413 POISON_VERSION_METHODS.load(Ordering::Relaxed)
2414 }
2415
2416 #[cfg(msim)]
2417 pub fn poison_get_for_min_version() {
2418 POISON_VERSION_METHODS.with(|p| p.store(true, Ordering::Relaxed));
2419 }
2420
2421 #[cfg(msim)]
2422 fn load_poison_get_for_min_version() -> bool {
2423 POISON_VERSION_METHODS.with(|p| p.load(Ordering::Relaxed))
2424 }
2425
2426 pub fn get_for_min_version() -> Self {
2429 if Self::load_poison_get_for_min_version() {
2430 panic!("get_for_min_version called on validator");
2431 }
2432 ProtocolConfig::get_for_version(ProtocolVersion::MIN, Chain::Unknown)
2433 }
2434
2435 #[allow(non_snake_case)]
2445 pub fn get_for_max_version_UNSAFE() -> Self {
2446 if Self::load_poison_get_for_min_version() {
2447 panic!("get_for_max_version_UNSAFE called on validator");
2448 }
2449 ProtocolConfig::get_for_version(ProtocolVersion::MAX, Chain::Unknown)
2450 }
2451
2452 fn get_for_version_impl(version: ProtocolVersion, chain: Chain) -> Self {
2453 #[cfg(msim)]
2454 {
2455 if version == ProtocolVersion::MAX_ALLOWED {
2457 let mut config = Self::get_for_version_impl(version - 1, Chain::Unknown);
2458 config.base_tx_cost_fixed = Some(config.base_tx_cost_fixed() + 1000);
2459 return config;
2460 }
2461 }
2462
2463 let mut cfg = Self {
2466 version,
2468 chain,
2469
2470 feature_flags: Default::default(),
2472
2473 max_tx_size_bytes: Some(128 * 1024),
2474 max_input_objects: Some(2048),
2476 max_serialized_tx_effects_size_bytes: Some(512 * 1024),
2477 max_serialized_tx_effects_size_bytes_system_tx: Some(512 * 1024 * 16),
2478 max_gas_payment_objects: Some(256),
2479 max_modules_in_publish: Some(128),
2480 max_package_dependencies: None,
2481 max_arguments: Some(512),
2482 max_type_arguments: Some(16),
2483 max_type_argument_depth: Some(16),
2484 max_pure_argument_size: Some(16 * 1024),
2485 max_programmable_tx_commands: Some(1024),
2486 move_binary_format_version: Some(6),
2487 min_move_binary_format_version: None,
2488 binary_module_handles: None,
2489 binary_struct_handles: None,
2490 binary_function_handles: None,
2491 binary_function_instantiations: None,
2492 binary_signatures: None,
2493 binary_constant_pool: None,
2494 binary_identifiers: None,
2495 binary_address_identifiers: None,
2496 binary_struct_defs: None,
2497 binary_struct_def_instantiations: None,
2498 binary_function_defs: None,
2499 binary_field_handles: None,
2500 binary_field_instantiations: None,
2501 binary_friend_decls: None,
2502 binary_enum_defs: None,
2503 binary_enum_def_instantiations: None,
2504 binary_variant_handles: None,
2505 binary_variant_instantiation_handles: None,
2506 max_move_object_size: Some(250 * 1024),
2507 max_move_package_size: Some(100 * 1024),
2508 max_publish_or_upgrade_per_ptb: None,
2509 max_tx_gas: Some(10_000_000_000),
2510 max_gas_price: Some(100_000),
2511 max_gas_price_rgp_factor_for_aborted_transactions: None,
2512 max_gas_computation_bucket: Some(5_000_000),
2513 max_loop_depth: Some(5),
2514 max_generic_instantiation_length: Some(32),
2515 max_function_parameters: Some(128),
2516 max_basic_blocks: Some(1024),
2517 max_value_stack_size: Some(1024),
2518 max_type_nodes: Some(256),
2519 max_generic_instantiation_type_nodes_per_function: None,
2520 max_generic_instantiation_type_nodes_per_module: None,
2521 max_push_size: Some(10000),
2522 max_struct_definitions: Some(200),
2523 max_function_definitions: Some(1000),
2524 max_fields_in_struct: Some(32),
2525 max_dependency_depth: Some(100),
2526 max_num_event_emit: Some(256),
2527 max_num_new_move_object_ids: Some(2048),
2528 max_num_new_move_object_ids_system_tx: Some(2048 * 16),
2529 max_num_deleted_move_object_ids: Some(2048),
2530 max_num_deleted_move_object_ids_system_tx: Some(2048 * 16),
2531 max_num_transferred_move_object_ids: Some(2048),
2532 max_num_transferred_move_object_ids_system_tx: Some(2048 * 16),
2533 max_event_emit_size: Some(250 * 1024),
2534 max_move_vector_len: Some(256 * 1024),
2535 max_type_to_layout_nodes: None,
2536 max_ptb_value_size: None,
2537
2538 max_back_edges_per_function: Some(10_000),
2539 max_back_edges_per_module: Some(10_000),
2540 max_verifier_meter_ticks_per_function: Some(6_000_000),
2541 max_meter_ticks_per_module: Some(6_000_000),
2542 max_meter_ticks_per_package: None,
2543
2544 object_runtime_max_num_cached_objects: Some(1000),
2545 object_runtime_max_num_cached_objects_system_tx: Some(1000 * 16),
2546 object_runtime_max_num_store_entries: Some(1000),
2547 object_runtime_max_num_store_entries_system_tx: Some(1000 * 16),
2548 base_tx_cost_fixed: Some(110_000),
2549 package_publish_cost_fixed: Some(1_000),
2550 base_tx_cost_per_byte: Some(0),
2551 package_publish_cost_per_byte: Some(80),
2552 obj_access_cost_read_per_byte: Some(15),
2553 obj_access_cost_mutate_per_byte: Some(40),
2554 obj_access_cost_delete_per_byte: Some(40),
2555 obj_access_cost_verify_per_byte: Some(200),
2556 obj_data_cost_refundable: Some(100),
2557 obj_metadata_cost_non_refundable: Some(50),
2558 gas_model_version: Some(1),
2559 storage_rebate_rate: Some(9900),
2560 storage_fund_reinvest_rate: Some(500),
2561 reward_slashing_rate: Some(5000),
2562 storage_gas_price: Some(1),
2563 accumulator_object_storage_cost: None,
2564 max_transactions_per_checkpoint: Some(10_000),
2565 max_checkpoint_size_bytes: Some(30 * 1024 * 1024),
2566
2567 buffer_stake_for_protocol_upgrade_bps: Some(0),
2570
2571 address_from_bytes_cost_base: Some(52),
2575 address_to_u256_cost_base: Some(52),
2577 address_from_u256_cost_base: Some(52),
2579
2580 config_read_setting_impl_cost_base: None,
2583 config_read_setting_impl_cost_per_byte: None,
2584
2585 dynamic_field_hash_type_and_key_cost_base: Some(100),
2588 dynamic_field_hash_type_and_key_type_cost_per_byte: Some(2),
2589 dynamic_field_hash_type_and_key_value_cost_per_byte: Some(2),
2590 dynamic_field_hash_type_and_key_type_tag_cost_per_byte: Some(2),
2591 dynamic_field_add_child_object_cost_base: Some(100),
2593 dynamic_field_add_child_object_type_cost_per_byte: Some(10),
2594 dynamic_field_add_child_object_value_cost_per_byte: Some(10),
2595 dynamic_field_add_child_object_struct_tag_cost_per_byte: Some(10),
2596 dynamic_field_borrow_child_object_cost_base: Some(100),
2598 dynamic_field_borrow_child_object_child_ref_cost_per_byte: Some(10),
2599 dynamic_field_borrow_child_object_type_cost_per_byte: Some(10),
2600 dynamic_field_remove_child_object_cost_base: Some(100),
2602 dynamic_field_remove_child_object_child_cost_per_byte: Some(2),
2603 dynamic_field_remove_child_object_type_cost_per_byte: Some(2),
2604 dynamic_field_has_child_object_cost_base: Some(100),
2606 dynamic_field_has_child_object_with_ty_cost_base: Some(100),
2608 dynamic_field_has_child_object_with_ty_type_cost_per_byte: Some(2),
2609 dynamic_field_has_child_object_with_ty_type_tag_cost_per_byte: Some(2),
2610
2611 scratch_add_cost_base: None,
2613 scratch_read_cost_base: None,
2614 scratch_read_value_cost: None,
2615 scratch_remove_cost_base: None,
2616 scratch_exists_cost_base: None,
2617 scratch_exists_with_type_cost_base: None,
2618 scratch_exists_with_type_type_cost: None,
2619 max_scratch_pad_size: None,
2620
2621 event_emit_cost_base: Some(52),
2624 event_emit_value_size_derivation_cost_per_byte: Some(2),
2625 event_emit_tag_size_derivation_cost_per_byte: Some(5),
2626 event_emit_output_cost_per_byte: Some(10),
2627 event_emit_auth_stream_cost: None,
2628
2629 object_borrow_uid_cost_base: Some(52),
2632 object_delete_impl_cost_base: Some(52),
2634 object_record_new_uid_cost_base: Some(52),
2636
2637 transfer_transfer_internal_cost_base: Some(52),
2640 transfer_party_transfer_internal_cost_base: None,
2642 transfer_freeze_object_cost_base: Some(52),
2644 transfer_share_object_cost_base: Some(52),
2646 transfer_receive_object_cost_base: None,
2647 transfer_receive_object_type_cost_per_byte: None,
2648 transfer_receive_object_cost_per_byte: None,
2649
2650 tx_context_derive_id_cost_base: Some(52),
2653 tx_context_fresh_id_cost_base: None,
2654 tx_context_sender_cost_base: None,
2655 tx_context_epoch_cost_base: None,
2656 tx_context_epoch_timestamp_ms_cost_base: None,
2657 tx_context_sponsor_cost_base: None,
2658 tx_context_rgp_cost_base: None,
2659 tx_context_gas_price_cost_base: None,
2660 tx_context_gas_budget_cost_base: None,
2661 tx_context_ids_created_cost_base: None,
2662 tx_context_replace_cost_base: None,
2663
2664 types_is_one_time_witness_cost_base: Some(52),
2667 types_is_one_time_witness_type_tag_cost_per_byte: Some(2),
2668 types_is_one_time_witness_type_cost_per_byte: Some(2),
2669
2670 validator_validate_metadata_cost_base: Some(52),
2673 validator_validate_metadata_data_cost_per_byte: Some(2),
2674
2675 crypto_invalid_arguments_cost: Some(100),
2677 bls12381_bls12381_min_sig_verify_cost_base: Some(52),
2679 bls12381_bls12381_min_sig_verify_msg_cost_per_byte: Some(2),
2680 bls12381_bls12381_min_sig_verify_msg_cost_per_block: Some(2),
2681
2682 bls12381_bls12381_min_pk_verify_cost_base: Some(52),
2684 bls12381_bls12381_min_pk_verify_msg_cost_per_byte: Some(2),
2685 bls12381_bls12381_min_pk_verify_msg_cost_per_block: Some(2),
2686
2687 ecdsa_k1_ecrecover_keccak256_cost_base: Some(52),
2689 ecdsa_k1_ecrecover_keccak256_msg_cost_per_byte: Some(2),
2690 ecdsa_k1_ecrecover_keccak256_msg_cost_per_block: Some(2),
2691 ecdsa_k1_ecrecover_sha256_cost_base: Some(52),
2692 ecdsa_k1_ecrecover_sha256_msg_cost_per_byte: Some(2),
2693 ecdsa_k1_ecrecover_sha256_msg_cost_per_block: Some(2),
2694
2695 ecdsa_k1_decompress_pubkey_cost_base: Some(52),
2697
2698 ecdsa_k1_secp256k1_verify_keccak256_cost_base: Some(52),
2700 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_byte: Some(2),
2701 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_block: Some(2),
2702 ecdsa_k1_secp256k1_verify_sha256_cost_base: Some(52),
2703 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_byte: Some(2),
2704 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_block: Some(2),
2705
2706 ecdsa_r1_ecrecover_keccak256_cost_base: Some(52),
2708 ecdsa_r1_ecrecover_keccak256_msg_cost_per_byte: Some(2),
2709 ecdsa_r1_ecrecover_keccak256_msg_cost_per_block: Some(2),
2710 ecdsa_r1_ecrecover_sha256_cost_base: Some(52),
2711 ecdsa_r1_ecrecover_sha256_msg_cost_per_byte: Some(2),
2712 ecdsa_r1_ecrecover_sha256_msg_cost_per_block: Some(2),
2713
2714 ecdsa_r1_secp256r1_verify_keccak256_cost_base: Some(52),
2716 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_byte: Some(2),
2717 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_block: Some(2),
2718 ecdsa_r1_secp256r1_verify_sha256_cost_base: Some(52),
2719 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_byte: Some(2),
2720 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_block: Some(2),
2721
2722 ecvrf_ecvrf_verify_cost_base: Some(52),
2724 ecvrf_ecvrf_verify_alpha_string_cost_per_byte: Some(2),
2725 ecvrf_ecvrf_verify_alpha_string_cost_per_block: Some(2),
2726
2727 ed25519_ed25519_verify_cost_base: Some(52),
2729 ed25519_ed25519_verify_msg_cost_per_byte: Some(2),
2730 ed25519_ed25519_verify_msg_cost_per_block: Some(2),
2731
2732 groth16_prepare_verifying_key_bls12381_cost_base: Some(52),
2734 groth16_prepare_verifying_key_bn254_cost_base: Some(52),
2735
2736 groth16_verify_groth16_proof_internal_bls12381_cost_base: Some(52),
2738 groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input: Some(2),
2739 groth16_verify_groth16_proof_internal_bn254_cost_base: Some(52),
2740 groth16_verify_groth16_proof_internal_bn254_cost_per_public_input: Some(2),
2741 groth16_verify_groth16_proof_internal_public_input_cost_per_byte: Some(2),
2742
2743 hash_blake2b256_cost_base: Some(52),
2745 hash_blake2b256_data_cost_per_byte: Some(2),
2746 hash_blake2b256_data_cost_per_block: Some(2),
2747
2748 hash_keccak256_cost_base: Some(52),
2750 hash_keccak256_data_cost_per_byte: Some(2),
2751 hash_keccak256_data_cost_per_block: Some(2),
2752
2753 poseidon_bn254_cost_base: None,
2754 poseidon_bn254_cost_per_block: None,
2755
2756 hmac_hmac_sha3_256_cost_base: Some(52),
2758 hmac_hmac_sha3_256_input_cost_per_byte: Some(2),
2759 hmac_hmac_sha3_256_input_cost_per_block: Some(2),
2760
2761 group_ops_bls12381_decode_scalar_cost: None,
2763 group_ops_bls12381_decode_g1_cost: None,
2764 group_ops_bls12381_decode_g2_cost: None,
2765 group_ops_bls12381_decode_gt_cost: None,
2766 group_ops_bls12381_scalar_add_cost: None,
2767 group_ops_bls12381_g1_add_cost: None,
2768 group_ops_bls12381_g2_add_cost: None,
2769 group_ops_bls12381_gt_add_cost: None,
2770 group_ops_bls12381_scalar_sub_cost: None,
2771 group_ops_bls12381_g1_sub_cost: None,
2772 group_ops_bls12381_g2_sub_cost: None,
2773 group_ops_bls12381_gt_sub_cost: None,
2774 group_ops_bls12381_scalar_mul_cost: None,
2775 group_ops_bls12381_g1_mul_cost: None,
2776 group_ops_bls12381_g2_mul_cost: None,
2777 group_ops_bls12381_gt_mul_cost: None,
2778 group_ops_bls12381_scalar_div_cost: None,
2779 group_ops_bls12381_g1_div_cost: None,
2780 group_ops_bls12381_g2_div_cost: None,
2781 group_ops_bls12381_gt_div_cost: None,
2782 group_ops_bls12381_g1_hash_to_base_cost: None,
2783 group_ops_bls12381_g2_hash_to_base_cost: None,
2784 group_ops_bls12381_g1_hash_to_cost_per_byte: None,
2785 group_ops_bls12381_g2_hash_to_cost_per_byte: None,
2786 group_ops_bls12381_g1_msm_base_cost: None,
2787 group_ops_bls12381_g2_msm_base_cost: None,
2788 group_ops_bls12381_g1_msm_base_cost_per_input: None,
2789 group_ops_bls12381_g2_msm_base_cost_per_input: None,
2790 group_ops_bls12381_msm_max_len: None,
2791 group_ops_bls12381_pairing_cost: None,
2792 group_ops_bls12381_g1_to_uncompressed_g1_cost: None,
2793 group_ops_bls12381_uncompressed_g1_to_g1_cost: None,
2794 group_ops_bls12381_uncompressed_g1_sum_base_cost: None,
2795 group_ops_bls12381_uncompressed_g1_sum_cost_per_term: None,
2796 group_ops_bls12381_uncompressed_g1_sum_max_terms: None,
2797
2798 group_ops_ristretto_decode_scalar_cost: None,
2799 group_ops_ristretto_decode_point_cost: None,
2800 group_ops_ristretto_scalar_add_cost: None,
2801 group_ops_ristretto_point_add_cost: None,
2802 group_ops_ristretto_scalar_sub_cost: None,
2803 group_ops_ristretto_point_sub_cost: None,
2804 group_ops_ristretto_scalar_mul_cost: None,
2805 group_ops_ristretto_point_mul_cost: None,
2806 group_ops_ristretto_scalar_div_cost: None,
2807 group_ops_ristretto_point_div_cost: None,
2808
2809 verify_bulletproofs_ristretto255_base_cost: None,
2810 verify_bulletproofs_ristretto255_cost_per_bit_and_commitment: None,
2811
2812 check_zklogin_id_cost_base: None,
2814 check_zklogin_issuer_cost_base: None,
2816
2817 vdf_verify_vdf_cost: None,
2818 vdf_hash_to_input_cost: None,
2819
2820 nitro_attestation_parse_base_cost: None,
2822 nitro_attestation_parse_cost_per_byte: None,
2823 nitro_attestation_verify_base_cost: None,
2824 nitro_attestation_verify_cost_per_cert: None,
2825
2826 bcs_per_byte_serialized_cost: None,
2827 bcs_legacy_min_output_size_cost: None,
2828 bcs_failure_cost: None,
2829 hash_sha2_256_base_cost: None,
2830 hash_sha2_256_per_byte_cost: None,
2831 hash_sha2_256_legacy_min_input_len_cost: None,
2832 hash_sha3_256_base_cost: None,
2833 hash_sha3_256_per_byte_cost: None,
2834 hash_sha3_256_legacy_min_input_len_cost: None,
2835 type_name_get_base_cost: None,
2836 type_name_get_per_byte_cost: None,
2837 type_name_id_base_cost: None,
2838 string_check_utf8_base_cost: None,
2839 string_check_utf8_per_byte_cost: None,
2840 string_is_char_boundary_base_cost: None,
2841 string_sub_string_base_cost: None,
2842 string_sub_string_per_byte_cost: None,
2843 string_index_of_base_cost: None,
2844 string_index_of_per_byte_pattern_cost: None,
2845 string_index_of_per_byte_searched_cost: None,
2846 vector_empty_base_cost: None,
2847 vector_length_base_cost: None,
2848 vector_push_back_base_cost: None,
2849 vector_push_back_legacy_per_abstract_memory_unit_cost: None,
2850 vector_borrow_base_cost: None,
2851 vector_pop_back_base_cost: None,
2852 vector_destroy_empty_base_cost: None,
2853 vector_swap_base_cost: None,
2854 debug_print_base_cost: None,
2855 debug_print_stack_trace_base_cost: None,
2856
2857 max_size_written_objects: None,
2858 max_size_written_objects_system_tx: None,
2859
2860 max_move_identifier_len: None,
2867 max_move_value_depth: None,
2868 max_move_enum_variants: None,
2869
2870 gas_rounding_step: None,
2871
2872 execution_version: None,
2873
2874 max_event_emit_size_total: None,
2875
2876 consensus_bad_nodes_stake_threshold: None,
2877
2878 max_jwk_votes_per_validator_per_epoch: None,
2879
2880 max_age_of_jwk_in_epochs: None,
2881
2882 random_beacon_reduction_allowed_delta: None,
2883
2884 random_beacon_reduction_lower_bound: None,
2885
2886 random_beacon_dkg_timeout_round: None,
2887
2888 random_beacon_min_round_interval_ms: None,
2889
2890 random_beacon_dkg_version: None,
2891
2892 consensus_max_transaction_size_bytes: None,
2893
2894 consensus_max_transactions_in_block_bytes: None,
2895
2896 consensus_max_num_transactions_in_block: None,
2897
2898 consensus_voting_rounds: None,
2899
2900 max_accumulated_txn_cost_per_object_in_narwhal_commit: None,
2901
2902 max_deferral_rounds_for_congestion_control: None,
2903
2904 epoch_close_deadline_ms: None,
2905
2906 max_txn_cost_overage_per_object_in_commit: None,
2907
2908 allowed_txn_cost_overage_burst_per_object_in_commit: None,
2909
2910 min_checkpoint_interval_ms: None,
2911
2912 checkpoint_summary_version_specific_data: None,
2913
2914 max_soft_bundle_size: None,
2915
2916 bridge_should_try_to_finalize_committee: None,
2917
2918 max_accumulated_txn_cost_per_object_in_mysticeti_commit: None,
2919
2920 max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit: None,
2921
2922 consensus_gc_depth: None,
2923
2924 gas_budget_based_txn_cost_cap_factor: None,
2925
2926 gas_budget_based_txn_cost_absolute_cap_commit_count: None,
2927
2928 sip_45_consensus_amplification_threshold: None,
2929
2930 use_object_per_epoch_marker_table_v2: None,
2931
2932 consensus_commit_rate_estimation_window_size: None,
2933
2934 aliased_addresses: vec![],
2935
2936 translation_per_command_base_charge: None,
2937 translation_per_input_base_charge: None,
2938 translation_pure_input_per_byte_charge: None,
2939 translation_per_type_node_charge: None,
2940 translation_per_reference_node_charge: None,
2941 translation_per_linkage_entry_charge: None,
2942
2943 max_updates_per_settlement_txn: None,
2944
2945 gasless_max_computation_units: None,
2946 gasless_allowed_token_types: None,
2947 gasless_max_unused_inputs: None,
2948 gasless_max_pure_input_bytes: None,
2949 gasless_max_tps: None,
2950 include_special_package_amendments: None,
2951 gasless_max_tx_size_bytes: None,
2952 };
2955 for cur in 2..=version.0 {
2956 match cur {
2957 1 => unreachable!(),
2958 2 => {
2959 cfg.feature_flags.advance_epoch_start_time_in_safe_mode = true;
2960 }
2961 3 => {
2962 cfg.gas_model_version = Some(2);
2964 cfg.max_tx_gas = Some(50_000_000_000);
2966 cfg.base_tx_cost_fixed = Some(2_000);
2968 cfg.storage_gas_price = Some(76);
2970 cfg.feature_flags.loaded_child_objects_fixed = true;
2971 cfg.max_size_written_objects = Some(5 * 1000 * 1000);
2974 cfg.max_size_written_objects_system_tx = Some(50 * 1000 * 1000);
2977 cfg.feature_flags.package_upgrades = true;
2978 }
2979 4 => {
2984 cfg.reward_slashing_rate = Some(10000);
2986 cfg.gas_model_version = Some(3);
2988 }
2989 5 => {
2990 cfg.feature_flags.missing_type_is_compatibility_error = true;
2991 cfg.gas_model_version = Some(4);
2992 cfg.feature_flags.scoring_decision_with_validity_cutoff = true;
2993 }
2997 6 => {
2998 cfg.gas_model_version = Some(5);
2999 cfg.buffer_stake_for_protocol_upgrade_bps = Some(5000);
3000 cfg.feature_flags.consensus_order_end_of_epoch_last = true;
3001 }
3002 7 => {
3003 cfg.feature_flags.disallow_adding_abilities_on_upgrade = true;
3004 cfg.feature_flags
3005 .disable_invariant_violation_check_in_swap_loc = true;
3006 cfg.feature_flags.ban_entry_init = true;
3007 cfg.feature_flags.package_digest_hash_module = true;
3008 }
3009 8 => {
3010 cfg.feature_flags
3011 .disallow_change_struct_type_params_on_upgrade = true;
3012 }
3013 9 => {
3014 cfg.max_move_identifier_len = Some(128);
3016 cfg.feature_flags.no_extraneous_module_bytes = true;
3017 cfg.feature_flags
3018 .advance_to_highest_supported_protocol_version = true;
3019 }
3020 10 => {
3021 cfg.max_verifier_meter_ticks_per_function = Some(16_000_000);
3022 cfg.max_meter_ticks_per_module = Some(16_000_000);
3023 }
3024 11 => {
3025 cfg.max_move_value_depth = Some(128);
3026 }
3027 12 => {
3028 cfg.feature_flags.narwhal_versioned_metadata = true;
3029 if chain != Chain::Mainnet {
3030 cfg.feature_flags.commit_root_state_digest = true;
3031 }
3032
3033 if chain != Chain::Mainnet && chain != Chain::Testnet {
3034 cfg.feature_flags.zklogin_auth = true;
3035 }
3036 }
3037 13 => {}
3038 14 => {
3039 cfg.gas_rounding_step = Some(1_000);
3040 cfg.gas_model_version = Some(6);
3041 }
3042 15 => {
3043 cfg.feature_flags.consensus_transaction_ordering =
3044 ConsensusTransactionOrdering::ByGasPrice;
3045 }
3046 16 => {
3047 cfg.feature_flags.simplified_unwrap_then_delete = true;
3048 }
3049 17 => {
3050 cfg.feature_flags.upgraded_multisig_supported = true;
3051 }
3052 18 => {
3053 cfg.execution_version = Some(1);
3054 cfg.feature_flags.txn_base_cost_as_multiplier = true;
3063 cfg.base_tx_cost_fixed = Some(1_000);
3065 }
3066 19 => {
3067 cfg.max_num_event_emit = Some(1024);
3068 cfg.max_event_emit_size_total = Some(
3071 256 * 250 * 1024, );
3073 }
3074 20 => {
3075 cfg.feature_flags.commit_root_state_digest = true;
3076
3077 if chain != Chain::Mainnet {
3078 cfg.feature_flags.narwhal_new_leader_election_schedule = true;
3079 cfg.consensus_bad_nodes_stake_threshold = Some(20);
3080 }
3081 }
3082
3083 21 => {
3084 if chain != Chain::Mainnet {
3085 cfg.feature_flags.zklogin_supported_providers = BTreeSet::from([
3086 "Google".to_string(),
3087 "Facebook".to_string(),
3088 "Twitch".to_string(),
3089 ]);
3090 }
3091 }
3092 22 => {
3093 cfg.feature_flags.loaded_child_object_format = true;
3094 }
3095 23 => {
3096 cfg.feature_flags.loaded_child_object_format_type = true;
3097 cfg.feature_flags.narwhal_new_leader_election_schedule = true;
3098 cfg.consensus_bad_nodes_stake_threshold = Some(20);
3104 }
3105 24 => {
3106 cfg.feature_flags.simple_conservation_checks = true;
3107 cfg.max_publish_or_upgrade_per_ptb = Some(5);
3108
3109 cfg.feature_flags.end_of_epoch_transaction_supported = true;
3110
3111 if chain != Chain::Mainnet {
3112 cfg.feature_flags.enable_jwk_consensus_updates = true;
3113 cfg.max_jwk_votes_per_validator_per_epoch = Some(240);
3115 cfg.max_age_of_jwk_in_epochs = Some(1);
3116 }
3117 }
3118 25 => {
3119 cfg.feature_flags.zklogin_supported_providers = BTreeSet::from([
3121 "Google".to_string(),
3122 "Facebook".to_string(),
3123 "Twitch".to_string(),
3124 ]);
3125 cfg.feature_flags.zklogin_auth = true;
3126
3127 cfg.feature_flags.enable_jwk_consensus_updates = true;
3129 cfg.max_jwk_votes_per_validator_per_epoch = Some(240);
3130 cfg.max_age_of_jwk_in_epochs = Some(1);
3131 }
3132 26 => {
3133 cfg.gas_model_version = Some(7);
3134 if chain != Chain::Mainnet && chain != Chain::Testnet {
3136 cfg.transfer_receive_object_cost_base = Some(52);
3137 cfg.feature_flags.receive_objects = true;
3138 }
3139 }
3140 27 => {
3141 cfg.gas_model_version = Some(8);
3142 }
3143 28 => {
3144 cfg.check_zklogin_id_cost_base = Some(200);
3146 cfg.check_zklogin_issuer_cost_base = Some(200);
3148
3149 if chain != Chain::Mainnet && chain != Chain::Testnet {
3151 cfg.feature_flags.enable_effects_v2 = true;
3152 }
3153 }
3154 29 => {
3155 cfg.feature_flags.verify_legacy_zklogin_address = true;
3156 }
3157 30 => {
3158 if chain != Chain::Mainnet {
3160 cfg.feature_flags.narwhal_certificate_v2 = true;
3161 }
3162
3163 cfg.random_beacon_reduction_allowed_delta = Some(800);
3164 if chain != Chain::Mainnet {
3166 cfg.feature_flags.enable_effects_v2 = true;
3167 }
3168
3169 cfg.feature_flags.zklogin_supported_providers = BTreeSet::default();
3173
3174 cfg.feature_flags.recompute_has_public_transfer_in_execution = true;
3175 }
3176 31 => {
3177 cfg.execution_version = Some(2);
3178 if chain != Chain::Mainnet && chain != Chain::Testnet {
3180 cfg.feature_flags.shared_object_deletion = true;
3181 }
3182 }
3183 32 => {
3184 if chain != Chain::Mainnet {
3186 cfg.feature_flags.accept_zklogin_in_multisig = true;
3187 }
3188 if chain != Chain::Mainnet {
3190 cfg.transfer_receive_object_cost_base = Some(52);
3191 cfg.feature_flags.receive_objects = true;
3192 }
3193 if chain != Chain::Mainnet && chain != Chain::Testnet {
3195 cfg.feature_flags.random_beacon = true;
3196 cfg.random_beacon_reduction_lower_bound = Some(1600);
3197 cfg.random_beacon_dkg_timeout_round = Some(3000);
3198 cfg.random_beacon_min_round_interval_ms = Some(150);
3199 }
3200 if chain != Chain::Testnet && chain != Chain::Mainnet {
3202 cfg.feature_flags.include_consensus_digest_in_prologue = true;
3203 }
3204
3205 cfg.feature_flags.narwhal_certificate_v2 = true;
3207 }
3208 33 => {
3209 cfg.feature_flags.hardened_otw_check = true;
3210 cfg.feature_flags.allow_receiving_object_id = true;
3211
3212 cfg.transfer_receive_object_cost_base = Some(52);
3214 cfg.feature_flags.receive_objects = true;
3215
3216 if chain != Chain::Mainnet {
3218 cfg.feature_flags.shared_object_deletion = true;
3219 }
3220
3221 cfg.feature_flags.enable_effects_v2 = true;
3222 }
3223 34 => {}
3224 35 => {
3225 if chain != Chain::Mainnet && chain != Chain::Testnet {
3227 cfg.feature_flags.enable_poseidon = true;
3228 cfg.poseidon_bn254_cost_base = Some(260);
3229 cfg.poseidon_bn254_cost_per_block = Some(10);
3230 }
3231
3232 cfg.feature_flags.enable_coin_deny_list = true;
3233 }
3234 36 => {
3235 if chain != Chain::Mainnet && chain != Chain::Testnet {
3237 cfg.feature_flags.enable_group_ops_native_functions = true;
3238 cfg.feature_flags.enable_group_ops_native_function_msm = true;
3239 cfg.group_ops_bls12381_decode_scalar_cost = Some(52);
3241 cfg.group_ops_bls12381_decode_g1_cost = Some(52);
3242 cfg.group_ops_bls12381_decode_g2_cost = Some(52);
3243 cfg.group_ops_bls12381_decode_gt_cost = Some(52);
3244 cfg.group_ops_bls12381_scalar_add_cost = Some(52);
3245 cfg.group_ops_bls12381_g1_add_cost = Some(52);
3246 cfg.group_ops_bls12381_g2_add_cost = Some(52);
3247 cfg.group_ops_bls12381_gt_add_cost = Some(52);
3248 cfg.group_ops_bls12381_scalar_sub_cost = Some(52);
3249 cfg.group_ops_bls12381_g1_sub_cost = Some(52);
3250 cfg.group_ops_bls12381_g2_sub_cost = Some(52);
3251 cfg.group_ops_bls12381_gt_sub_cost = Some(52);
3252 cfg.group_ops_bls12381_scalar_mul_cost = Some(52);
3253 cfg.group_ops_bls12381_g1_mul_cost = Some(52);
3254 cfg.group_ops_bls12381_g2_mul_cost = Some(52);
3255 cfg.group_ops_bls12381_gt_mul_cost = Some(52);
3256 cfg.group_ops_bls12381_scalar_div_cost = Some(52);
3257 cfg.group_ops_bls12381_g1_div_cost = Some(52);
3258 cfg.group_ops_bls12381_g2_div_cost = Some(52);
3259 cfg.group_ops_bls12381_gt_div_cost = Some(52);
3260 cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(52);
3261 cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(52);
3262 cfg.group_ops_bls12381_g1_hash_to_cost_per_byte = Some(2);
3263 cfg.group_ops_bls12381_g2_hash_to_cost_per_byte = Some(2);
3264 cfg.group_ops_bls12381_g1_msm_base_cost = Some(52);
3265 cfg.group_ops_bls12381_g2_msm_base_cost = Some(52);
3266 cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(52);
3267 cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(52);
3268 cfg.group_ops_bls12381_msm_max_len = Some(32);
3269 cfg.group_ops_bls12381_pairing_cost = Some(52);
3270 }
3271 cfg.feature_flags.shared_object_deletion = true;
3273
3274 cfg.consensus_max_transaction_size_bytes = Some(256 * 1024); cfg.consensus_max_transactions_in_block_bytes = Some(6 * 1_024 * 1024);
3276 }
3278 37 => {
3279 cfg.feature_flags.reject_mutable_random_on_entry_functions = true;
3280
3281 if chain != Chain::Mainnet {
3283 cfg.feature_flags.include_consensus_digest_in_prologue = true;
3284 }
3285 }
3286 38 => {
3287 cfg.binary_module_handles = Some(100);
3288 cfg.binary_struct_handles = Some(300);
3289 cfg.binary_function_handles = Some(1500);
3290 cfg.binary_function_instantiations = Some(750);
3291 cfg.binary_signatures = Some(1000);
3292 cfg.binary_constant_pool = Some(4000);
3296 cfg.binary_identifiers = Some(10000);
3297 cfg.binary_address_identifiers = Some(100);
3298 cfg.binary_struct_defs = Some(200);
3299 cfg.binary_struct_def_instantiations = Some(100);
3300 cfg.binary_function_defs = Some(1000);
3301 cfg.binary_field_handles = Some(500);
3302 cfg.binary_field_instantiations = Some(250);
3303 cfg.binary_friend_decls = Some(100);
3304 cfg.max_package_dependencies = Some(32);
3306 cfg.max_modules_in_publish = Some(64);
3307 cfg.execution_version = Some(3);
3309 }
3310 39 => {
3311 }
3313 40 => {}
3314 41 => {
3315 cfg.feature_flags.enable_group_ops_native_functions = true;
3317 cfg.group_ops_bls12381_decode_scalar_cost = Some(52);
3319 cfg.group_ops_bls12381_decode_g1_cost = Some(52);
3320 cfg.group_ops_bls12381_decode_g2_cost = Some(52);
3321 cfg.group_ops_bls12381_decode_gt_cost = Some(52);
3322 cfg.group_ops_bls12381_scalar_add_cost = Some(52);
3323 cfg.group_ops_bls12381_g1_add_cost = Some(52);
3324 cfg.group_ops_bls12381_g2_add_cost = Some(52);
3325 cfg.group_ops_bls12381_gt_add_cost = Some(52);
3326 cfg.group_ops_bls12381_scalar_sub_cost = Some(52);
3327 cfg.group_ops_bls12381_g1_sub_cost = Some(52);
3328 cfg.group_ops_bls12381_g2_sub_cost = Some(52);
3329 cfg.group_ops_bls12381_gt_sub_cost = Some(52);
3330 cfg.group_ops_bls12381_scalar_mul_cost = Some(52);
3331 cfg.group_ops_bls12381_g1_mul_cost = Some(52);
3332 cfg.group_ops_bls12381_g2_mul_cost = Some(52);
3333 cfg.group_ops_bls12381_gt_mul_cost = Some(52);
3334 cfg.group_ops_bls12381_scalar_div_cost = Some(52);
3335 cfg.group_ops_bls12381_g1_div_cost = Some(52);
3336 cfg.group_ops_bls12381_g2_div_cost = Some(52);
3337 cfg.group_ops_bls12381_gt_div_cost = Some(52);
3338 cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(52);
3339 cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(52);
3340 cfg.group_ops_bls12381_g1_hash_to_cost_per_byte = Some(2);
3341 cfg.group_ops_bls12381_g2_hash_to_cost_per_byte = Some(2);
3342 cfg.group_ops_bls12381_g1_msm_base_cost = Some(52);
3343 cfg.group_ops_bls12381_g2_msm_base_cost = Some(52);
3344 cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(52);
3345 cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(52);
3346 cfg.group_ops_bls12381_msm_max_len = Some(32);
3347 cfg.group_ops_bls12381_pairing_cost = Some(52);
3348 }
3349 42 => {}
3350 43 => {
3351 cfg.feature_flags.zklogin_max_epoch_upper_bound_delta = Some(30);
3352 cfg.max_meter_ticks_per_package = Some(16_000_000);
3353 }
3354 44 => {
3355 cfg.feature_flags.include_consensus_digest_in_prologue = true;
3357 if chain != Chain::Mainnet {
3359 cfg.feature_flags.consensus_choice = ConsensusChoice::SwapEachEpoch;
3360 }
3361 }
3362 45 => {
3363 if chain != Chain::Testnet && chain != Chain::Mainnet {
3365 cfg.feature_flags.consensus_network = ConsensusNetwork::Tonic;
3366 }
3367
3368 if chain != Chain::Mainnet {
3369 cfg.feature_flags.mysticeti_leader_scoring_and_schedule = true;
3371 }
3372 cfg.min_move_binary_format_version = Some(6);
3373 cfg.feature_flags.accept_zklogin_in_multisig = true;
3374
3375 if chain != Chain::Mainnet && chain != Chain::Testnet {
3379 cfg.feature_flags.bridge = true;
3380 }
3381 }
3382 46 => {
3383 if chain != Chain::Mainnet {
3385 cfg.feature_flags.bridge = true;
3386 }
3387
3388 cfg.feature_flags.reshare_at_same_initial_version = true;
3390 }
3391 47 => {}
3392 48 => {
3393 cfg.feature_flags.consensus_network = ConsensusNetwork::Tonic;
3395
3396 cfg.feature_flags.resolve_abort_locations_to_package_id = true;
3398
3399 if chain != Chain::Mainnet {
3401 cfg.feature_flags.random_beacon = true;
3402 cfg.random_beacon_reduction_lower_bound = Some(1600);
3403 cfg.random_beacon_dkg_timeout_round = Some(3000);
3404 cfg.random_beacon_min_round_interval_ms = Some(200);
3405 }
3406
3407 cfg.feature_flags.mysticeti_use_committed_subdag_digest = true;
3409 }
3410 49 => {
3411 if chain != Chain::Testnet && chain != Chain::Mainnet {
3412 cfg.move_binary_format_version = Some(7);
3413 }
3414
3415 if chain != Chain::Mainnet && chain != Chain::Testnet {
3417 cfg.feature_flags.enable_vdf = true;
3418 cfg.vdf_verify_vdf_cost = Some(1500);
3421 cfg.vdf_hash_to_input_cost = Some(100);
3422 }
3423
3424 if chain != Chain::Testnet && chain != Chain::Mainnet {
3426 cfg.feature_flags
3427 .record_consensus_determined_version_assignments_in_prologue = true;
3428 }
3429
3430 if chain != Chain::Mainnet {
3432 cfg.feature_flags.consensus_choice = ConsensusChoice::Mysticeti;
3433 }
3434
3435 cfg.feature_flags.fresh_vm_on_framework_upgrade = true;
3437 }
3438 50 => {
3439 if chain != Chain::Mainnet {
3441 cfg.checkpoint_summary_version_specific_data = Some(1);
3442 cfg.min_checkpoint_interval_ms = Some(200);
3443 }
3444
3445 if chain != Chain::Testnet && chain != Chain::Mainnet {
3447 cfg.feature_flags
3448 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = true;
3449 }
3450
3451 cfg.feature_flags.mysticeti_num_leaders_per_round = Some(1);
3452
3453 cfg.max_deferral_rounds_for_congestion_control = Some(10);
3455 }
3456 51 => {
3457 cfg.random_beacon_dkg_version = Some(1);
3458
3459 if chain != Chain::Testnet && chain != Chain::Mainnet {
3460 cfg.feature_flags.enable_coin_deny_list_v2 = true;
3461 }
3462 }
3463 52 => {
3464 if chain != Chain::Mainnet {
3465 cfg.feature_flags.soft_bundle = true;
3466 cfg.max_soft_bundle_size = Some(5);
3467 }
3468
3469 cfg.config_read_setting_impl_cost_base = Some(100);
3470 cfg.config_read_setting_impl_cost_per_byte = Some(40);
3471
3472 if chain != Chain::Testnet && chain != Chain::Mainnet {
3474 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(100);
3475 cfg.feature_flags.per_object_congestion_control_mode =
3476 PerObjectCongestionControlMode::TotalTxCount;
3477 }
3478
3479 cfg.feature_flags.consensus_choice = ConsensusChoice::Mysticeti;
3481
3482 cfg.feature_flags.mysticeti_leader_scoring_and_schedule = true;
3484
3485 cfg.checkpoint_summary_version_specific_data = Some(1);
3487 cfg.min_checkpoint_interval_ms = Some(200);
3488
3489 if chain != Chain::Mainnet {
3491 cfg.feature_flags
3492 .record_consensus_determined_version_assignments_in_prologue = true;
3493 cfg.feature_flags
3494 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = true;
3495 }
3496 if chain != Chain::Mainnet {
3498 cfg.move_binary_format_version = Some(7);
3499 }
3500
3501 if chain != Chain::Testnet && chain != Chain::Mainnet {
3502 cfg.feature_flags.passkey_auth = true;
3503 }
3504 cfg.feature_flags.enable_coin_deny_list_v2 = true;
3505 }
3506 53 => {
3507 cfg.bridge_should_try_to_finalize_committee = Some(chain != Chain::Mainnet);
3509
3510 cfg.feature_flags
3512 .record_consensus_determined_version_assignments_in_prologue = true;
3513 cfg.feature_flags
3514 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = true;
3515
3516 if chain == Chain::Unknown {
3517 cfg.feature_flags.authority_capabilities_v2 = true;
3518 }
3519
3520 if chain != Chain::Mainnet {
3522 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(100);
3523 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(10);
3524 cfg.feature_flags.per_object_congestion_control_mode =
3525 PerObjectCongestionControlMode::TotalTxCount;
3526 }
3527
3528 cfg.bcs_per_byte_serialized_cost = Some(2);
3530 cfg.bcs_legacy_min_output_size_cost = Some(1);
3531 cfg.bcs_failure_cost = Some(52);
3532 cfg.debug_print_base_cost = Some(52);
3533 cfg.debug_print_stack_trace_base_cost = Some(52);
3534 cfg.hash_sha2_256_base_cost = Some(52);
3535 cfg.hash_sha2_256_per_byte_cost = Some(2);
3536 cfg.hash_sha2_256_legacy_min_input_len_cost = Some(1);
3537 cfg.hash_sha3_256_base_cost = Some(52);
3538 cfg.hash_sha3_256_per_byte_cost = Some(2);
3539 cfg.hash_sha3_256_legacy_min_input_len_cost = Some(1);
3540 cfg.type_name_get_base_cost = Some(52);
3541 cfg.type_name_get_per_byte_cost = Some(2);
3542 cfg.string_check_utf8_base_cost = Some(52);
3543 cfg.string_check_utf8_per_byte_cost = Some(2);
3544 cfg.string_is_char_boundary_base_cost = Some(52);
3545 cfg.string_sub_string_base_cost = Some(52);
3546 cfg.string_sub_string_per_byte_cost = Some(2);
3547 cfg.string_index_of_base_cost = Some(52);
3548 cfg.string_index_of_per_byte_pattern_cost = Some(2);
3549 cfg.string_index_of_per_byte_searched_cost = Some(2);
3550 cfg.vector_empty_base_cost = Some(52);
3551 cfg.vector_length_base_cost = Some(52);
3552 cfg.vector_push_back_base_cost = Some(52);
3553 cfg.vector_push_back_legacy_per_abstract_memory_unit_cost = Some(2);
3554 cfg.vector_borrow_base_cost = Some(52);
3555 cfg.vector_pop_back_base_cost = Some(52);
3556 cfg.vector_destroy_empty_base_cost = Some(52);
3557 cfg.vector_swap_base_cost = Some(52);
3558 }
3559 54 => {
3560 cfg.feature_flags.random_beacon = true;
3562 cfg.random_beacon_reduction_lower_bound = Some(1000);
3563 cfg.random_beacon_dkg_timeout_round = Some(3000);
3564 cfg.random_beacon_min_round_interval_ms = Some(500);
3565
3566 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(100);
3568 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(10);
3569 cfg.feature_flags.per_object_congestion_control_mode =
3570 PerObjectCongestionControlMode::TotalTxCount;
3571
3572 cfg.feature_flags.soft_bundle = true;
3574 cfg.max_soft_bundle_size = Some(5);
3575 }
3576 55 => {
3577 cfg.move_binary_format_version = Some(7);
3579
3580 cfg.consensus_max_transactions_in_block_bytes = Some(512 * 1024);
3582 cfg.consensus_max_num_transactions_in_block = Some(512);
3585
3586 cfg.feature_flags.rethrow_serialization_type_layout_errors = true;
3587 }
3588 56 => {
3589 if chain == Chain::Mainnet {
3590 cfg.feature_flags.bridge = true;
3591 }
3592 }
3593 57 => {
3594 cfg.random_beacon_reduction_lower_bound = Some(800);
3596 }
3597 58 => {
3598 if chain == Chain::Mainnet {
3599 cfg.bridge_should_try_to_finalize_committee = Some(true);
3600 }
3601
3602 if chain != Chain::Mainnet && chain != Chain::Testnet {
3603 cfg.feature_flags
3605 .consensus_distributed_vote_scoring_strategy = true;
3606 }
3607 }
3608 59 => {
3609 cfg.feature_flags.consensus_round_prober = true;
3611 }
3612 60 => {
3613 cfg.max_type_to_layout_nodes = Some(512);
3614 cfg.feature_flags.validate_identifier_inputs = true;
3615 }
3616 61 => {
3617 if chain != Chain::Mainnet {
3618 cfg.feature_flags
3620 .consensus_distributed_vote_scoring_strategy = true;
3621 }
3622 cfg.random_beacon_reduction_lower_bound = Some(700);
3624
3625 if chain != Chain::Mainnet && chain != Chain::Testnet {
3626 cfg.feature_flags.mysticeti_fastpath = true;
3628 }
3629 }
3630 62 => {
3631 cfg.feature_flags.relocate_event_module = true;
3632 }
3633 63 => {
3634 cfg.feature_flags.per_object_congestion_control_mode =
3635 PerObjectCongestionControlMode::TotalGasBudgetWithCap;
3636 cfg.gas_budget_based_txn_cost_cap_factor = Some(400_000);
3637 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(18_500_000);
3638 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(240_000_000);
3639 }
3640 64 => {
3641 cfg.feature_flags.per_object_congestion_control_mode =
3642 PerObjectCongestionControlMode::TotalTxCount;
3643 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(40);
3644 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(3);
3645 }
3646 65 => {
3647 cfg.feature_flags
3649 .consensus_distributed_vote_scoring_strategy = true;
3650 }
3651 66 => {
3652 if chain == Chain::Mainnet {
3653 cfg.feature_flags
3655 .consensus_distributed_vote_scoring_strategy = false;
3656 }
3657 }
3658 67 => {
3659 cfg.feature_flags
3661 .consensus_distributed_vote_scoring_strategy = true;
3662 }
3663 68 => {
3664 cfg.group_ops_bls12381_g1_to_uncompressed_g1_cost = Some(26);
3665 cfg.group_ops_bls12381_uncompressed_g1_to_g1_cost = Some(52);
3666 cfg.group_ops_bls12381_uncompressed_g1_sum_base_cost = Some(26);
3667 cfg.group_ops_bls12381_uncompressed_g1_sum_cost_per_term = Some(13);
3668 cfg.group_ops_bls12381_uncompressed_g1_sum_max_terms = Some(2000);
3669
3670 if chain != Chain::Mainnet && chain != Chain::Testnet {
3671 cfg.feature_flags.uncompressed_g1_group_elements = true;
3672 }
3673
3674 cfg.feature_flags.per_object_congestion_control_mode =
3675 PerObjectCongestionControlMode::TotalGasBudgetWithCap;
3676 cfg.gas_budget_based_txn_cost_cap_factor = Some(400_000);
3677 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(18_500_000);
3678 cfg.max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit =
3679 Some(3_700_000); cfg.max_txn_cost_overage_per_object_in_commit = Some(u64::MAX);
3681 cfg.gas_budget_based_txn_cost_absolute_cap_commit_count = Some(50);
3682
3683 cfg.random_beacon_reduction_lower_bound = Some(500);
3685
3686 cfg.feature_flags.disallow_new_modules_in_deps_only_packages = true;
3687 }
3688 69 => {
3689 cfg.consensus_voting_rounds = Some(40);
3691
3692 if chain != Chain::Mainnet && chain != Chain::Testnet {
3693 cfg.feature_flags.consensus_smart_ancestor_selection = true;
3695 }
3696
3697 if chain != Chain::Mainnet {
3698 cfg.feature_flags.uncompressed_g1_group_elements = true;
3699 }
3700 }
3701 70 => {
3702 if chain != Chain::Mainnet {
3703 cfg.feature_flags.consensus_smart_ancestor_selection = true;
3705 cfg.feature_flags
3707 .consensus_round_prober_probe_accepted_rounds = true;
3708 }
3709
3710 cfg.poseidon_bn254_cost_per_block = Some(388);
3711
3712 cfg.gas_model_version = Some(9);
3713 cfg.feature_flags.native_charging_v2 = true;
3714 cfg.bls12381_bls12381_min_sig_verify_cost_base = Some(44064);
3715 cfg.bls12381_bls12381_min_pk_verify_cost_base = Some(49282);
3716 cfg.ecdsa_k1_secp256k1_verify_keccak256_cost_base = Some(1470);
3717 cfg.ecdsa_k1_secp256k1_verify_sha256_cost_base = Some(1470);
3718 cfg.ecdsa_r1_secp256r1_verify_sha256_cost_base = Some(4225);
3719 cfg.ecdsa_r1_secp256r1_verify_keccak256_cost_base = Some(4225);
3720 cfg.ecvrf_ecvrf_verify_cost_base = Some(4848);
3721 cfg.ed25519_ed25519_verify_cost_base = Some(1802);
3722
3723 cfg.ecdsa_r1_ecrecover_keccak256_cost_base = Some(1173);
3725 cfg.ecdsa_r1_ecrecover_sha256_cost_base = Some(1173);
3726 cfg.ecdsa_k1_ecrecover_keccak256_cost_base = Some(500);
3727 cfg.ecdsa_k1_ecrecover_sha256_cost_base = Some(500);
3728
3729 cfg.groth16_prepare_verifying_key_bls12381_cost_base = Some(53838);
3730 cfg.groth16_prepare_verifying_key_bn254_cost_base = Some(82010);
3731 cfg.groth16_verify_groth16_proof_internal_bls12381_cost_base = Some(72090);
3732 cfg.groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input =
3733 Some(8213);
3734 cfg.groth16_verify_groth16_proof_internal_bn254_cost_base = Some(115502);
3735 cfg.groth16_verify_groth16_proof_internal_bn254_cost_per_public_input =
3736 Some(9484);
3737
3738 cfg.hash_keccak256_cost_base = Some(10);
3739 cfg.hash_blake2b256_cost_base = Some(10);
3740
3741 cfg.group_ops_bls12381_decode_scalar_cost = Some(7);
3743 cfg.group_ops_bls12381_decode_g1_cost = Some(2848);
3744 cfg.group_ops_bls12381_decode_g2_cost = Some(3770);
3745 cfg.group_ops_bls12381_decode_gt_cost = Some(3068);
3746
3747 cfg.group_ops_bls12381_scalar_add_cost = Some(10);
3748 cfg.group_ops_bls12381_g1_add_cost = Some(1556);
3749 cfg.group_ops_bls12381_g2_add_cost = Some(3048);
3750 cfg.group_ops_bls12381_gt_add_cost = Some(188);
3751
3752 cfg.group_ops_bls12381_scalar_sub_cost = Some(10);
3753 cfg.group_ops_bls12381_g1_sub_cost = Some(1550);
3754 cfg.group_ops_bls12381_g2_sub_cost = Some(3019);
3755 cfg.group_ops_bls12381_gt_sub_cost = Some(497);
3756
3757 cfg.group_ops_bls12381_scalar_mul_cost = Some(11);
3758 cfg.group_ops_bls12381_g1_mul_cost = Some(4842);
3759 cfg.group_ops_bls12381_g2_mul_cost = Some(9108);
3760 cfg.group_ops_bls12381_gt_mul_cost = Some(27490);
3761
3762 cfg.group_ops_bls12381_scalar_div_cost = Some(91);
3763 cfg.group_ops_bls12381_g1_div_cost = Some(5091);
3764 cfg.group_ops_bls12381_g2_div_cost = Some(9206);
3765 cfg.group_ops_bls12381_gt_div_cost = Some(27804);
3766
3767 cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(2962);
3768 cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(8688);
3769
3770 cfg.group_ops_bls12381_g1_msm_base_cost = Some(62648);
3771 cfg.group_ops_bls12381_g2_msm_base_cost = Some(131192);
3772 cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(1333);
3773 cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(3216);
3774
3775 cfg.group_ops_bls12381_uncompressed_g1_to_g1_cost = Some(677);
3776 cfg.group_ops_bls12381_g1_to_uncompressed_g1_cost = Some(2099);
3777 cfg.group_ops_bls12381_uncompressed_g1_sum_base_cost = Some(77);
3778 cfg.group_ops_bls12381_uncompressed_g1_sum_cost_per_term = Some(26);
3779
3780 cfg.group_ops_bls12381_pairing_cost = Some(26897);
3781 cfg.group_ops_bls12381_uncompressed_g1_sum_max_terms = Some(1200);
3782
3783 cfg.validator_validate_metadata_cost_base = Some(20000);
3784 }
3785 71 => {
3786 cfg.sip_45_consensus_amplification_threshold = Some(5);
3787
3788 cfg.allowed_txn_cost_overage_burst_per_object_in_commit = Some(185_000_000);
3790 }
3791 72 => {
3792 cfg.feature_flags.convert_type_argument_error = true;
3793
3794 cfg.max_tx_gas = Some(50_000_000_000_000);
3797 cfg.max_gas_price = Some(50_000_000_000);
3799
3800 cfg.feature_flags.variant_nodes = true;
3801 }
3802 73 => {
3803 cfg.use_object_per_epoch_marker_table_v2 = Some(true);
3805
3806 if chain != Chain::Mainnet && chain != Chain::Testnet {
3807 cfg.consensus_gc_depth = Some(60);
3810 }
3811
3812 if chain != Chain::Mainnet {
3813 cfg.feature_flags.consensus_zstd_compression = true;
3815 }
3816
3817 cfg.feature_flags.consensus_smart_ancestor_selection = true;
3819 cfg.feature_flags
3821 .consensus_round_prober_probe_accepted_rounds = true;
3822
3823 cfg.feature_flags.per_object_congestion_control_mode =
3825 PerObjectCongestionControlMode::TotalGasBudgetWithCap;
3826 cfg.gas_budget_based_txn_cost_cap_factor = Some(400_000);
3827 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(37_000_000);
3828 cfg.max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit =
3829 Some(7_400_000); cfg.max_txn_cost_overage_per_object_in_commit = Some(u64::MAX);
3831 cfg.gas_budget_based_txn_cost_absolute_cap_commit_count = Some(50);
3832 cfg.allowed_txn_cost_overage_burst_per_object_in_commit = Some(370_000_000);
3833 }
3834 74 => {
3835 if chain != Chain::Mainnet && chain != Chain::Testnet {
3837 cfg.feature_flags.enable_nitro_attestation = true;
3838 }
3839 cfg.nitro_attestation_parse_base_cost = Some(53 * 50);
3840 cfg.nitro_attestation_parse_cost_per_byte = Some(50);
3841 cfg.nitro_attestation_verify_base_cost = Some(49632 * 50);
3842 cfg.nitro_attestation_verify_cost_per_cert = Some(52369 * 50);
3843
3844 cfg.feature_flags.consensus_zstd_compression = true;
3846
3847 if chain != Chain::Mainnet && chain != Chain::Testnet {
3848 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
3849 }
3850 }
3851 75 => {
3852 if chain != Chain::Mainnet {
3853 cfg.feature_flags.passkey_auth = true;
3854 }
3855 }
3856 76 => {
3857 if chain != Chain::Mainnet && chain != Chain::Testnet {
3858 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
3859 cfg.consensus_commit_rate_estimation_window_size = Some(10);
3860 }
3861 cfg.feature_flags.minimize_child_object_mutations = true;
3862
3863 if chain != Chain::Mainnet {
3864 cfg.feature_flags.accept_passkey_in_multisig = true;
3865 }
3866 }
3867 77 => {
3868 cfg.feature_flags.uncompressed_g1_group_elements = true;
3869
3870 if chain != Chain::Mainnet {
3871 cfg.consensus_gc_depth = Some(60);
3872 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
3873 }
3874 }
3875 78 => {
3876 cfg.feature_flags.move_native_context = true;
3877 cfg.tx_context_fresh_id_cost_base = Some(52);
3878 cfg.tx_context_sender_cost_base = Some(30);
3879 cfg.tx_context_epoch_cost_base = Some(30);
3880 cfg.tx_context_epoch_timestamp_ms_cost_base = Some(30);
3881 cfg.tx_context_sponsor_cost_base = Some(30);
3882 cfg.tx_context_gas_price_cost_base = Some(30);
3883 cfg.tx_context_gas_budget_cost_base = Some(30);
3884 cfg.tx_context_ids_created_cost_base = Some(30);
3885 cfg.tx_context_replace_cost_base = Some(30);
3886 cfg.gas_model_version = Some(10);
3887
3888 if chain != Chain::Mainnet {
3889 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
3890 cfg.consensus_commit_rate_estimation_window_size = Some(10);
3891
3892 cfg.feature_flags.per_object_congestion_control_mode =
3894 PerObjectCongestionControlMode::ExecutionTimeEstimate(
3895 ExecutionTimeEstimateParams {
3896 target_utilization: 30,
3897 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
3899 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
3901 stored_observations_limit: u64::MAX,
3902 stake_weighted_median_threshold: 0,
3903 default_none_duration_for_new_keys: false,
3904 observations_chunk_size: None,
3905 },
3906 );
3907 }
3908 }
3909 79 => {
3910 if chain != Chain::Mainnet {
3911 cfg.feature_flags.consensus_median_based_commit_timestamp = true;
3912
3913 cfg.consensus_bad_nodes_stake_threshold = Some(30);
3916
3917 cfg.feature_flags.consensus_batched_block_sync = true;
3918
3919 cfg.feature_flags.enable_nitro_attestation = true
3921 }
3922 cfg.feature_flags.normalize_ptb_arguments = true;
3923
3924 cfg.consensus_gc_depth = Some(60);
3925 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
3926 }
3927 80 => {
3928 cfg.max_ptb_value_size = Some(1024 * 1024);
3929 }
3930 81 => {
3931 cfg.feature_flags.consensus_median_based_commit_timestamp = true;
3932 cfg.feature_flags.enforce_checkpoint_timestamp_monotonicity = true;
3933 cfg.consensus_bad_nodes_stake_threshold = Some(30)
3934 }
3935 82 => {
3936 cfg.feature_flags.max_ptb_value_size_v2 = true;
3937 }
3938 83 => {
3939 if chain == Chain::Mainnet {
3940 let aliased: [u8; 32] = Hex::decode(
3942 "0x0b2da327ba6a4cacbe75dddd50e6e8bbf81d6496e92d66af9154c61c77f7332f",
3943 )
3944 .unwrap()
3945 .try_into()
3946 .unwrap();
3947
3948 cfg.aliased_addresses.push(AliasedAddress {
3950 original: Hex::decode("0xcd8962dad278d8b50fa0f9eb0186bfa4cbdecc6d59377214c88d0286a0ac9562").unwrap().try_into().unwrap(),
3951 aliased,
3952 allowed_tx_digests: vec![
3953 Base58::decode("B2eGLFoMHgj93Ni8dAJBfqGzo8EWSTLBesZzhEpTPA4").unwrap().try_into().unwrap(),
3954 ],
3955 });
3956
3957 cfg.aliased_addresses.push(AliasedAddress {
3958 original: Hex::decode("0xe28b50cef1d633ea43d3296a3f6b67ff0312a5f1a99f0af753c85b8b5de8ff06").unwrap().try_into().unwrap(),
3959 aliased,
3960 allowed_tx_digests: vec![
3961 Base58::decode("J4QqSAgp7VrQtQpMy5wDX4QGsCSEZu3U5KuDAkbESAge").unwrap().try_into().unwrap(),
3962 ],
3963 });
3964 }
3965
3966 if chain != Chain::Mainnet {
3969 cfg.feature_flags.resolve_type_input_ids_to_defining_id = true;
3970 cfg.transfer_party_transfer_internal_cost_base = Some(52);
3971
3972 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
3974 cfg.consensus_commit_rate_estimation_window_size = Some(10);
3975 cfg.feature_flags.per_object_congestion_control_mode =
3976 PerObjectCongestionControlMode::ExecutionTimeEstimate(
3977 ExecutionTimeEstimateParams {
3978 target_utilization: 30,
3979 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
3981 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
3983 stored_observations_limit: u64::MAX,
3984 stake_weighted_median_threshold: 0,
3985 default_none_duration_for_new_keys: false,
3986 observations_chunk_size: None,
3987 },
3988 );
3989
3990 cfg.feature_flags.consensus_batched_block_sync = true;
3992
3993 cfg.feature_flags.enable_nitro_attestation_upgraded_parsing = true;
3996 cfg.feature_flags.enable_nitro_attestation = true;
3997 }
3998 }
3999 84 => {
4000 if chain == Chain::Mainnet {
4001 cfg.feature_flags.resolve_type_input_ids_to_defining_id = true;
4002 cfg.transfer_party_transfer_internal_cost_base = Some(52);
4003
4004 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
4006 cfg.consensus_commit_rate_estimation_window_size = Some(10);
4007 cfg.feature_flags.per_object_congestion_control_mode =
4008 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4009 ExecutionTimeEstimateParams {
4010 target_utilization: 30,
4011 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4013 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4015 stored_observations_limit: u64::MAX,
4016 stake_weighted_median_threshold: 0,
4017 default_none_duration_for_new_keys: false,
4018 observations_chunk_size: None,
4019 },
4020 );
4021
4022 cfg.feature_flags.consensus_batched_block_sync = true;
4024
4025 cfg.feature_flags.enable_nitro_attestation_upgraded_parsing = true;
4028 cfg.feature_flags.enable_nitro_attestation = true;
4029 }
4030
4031 cfg.feature_flags.per_object_congestion_control_mode =
4033 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4034 ExecutionTimeEstimateParams {
4035 target_utilization: 30,
4036 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4038 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4040 stored_observations_limit: 20,
4041 stake_weighted_median_threshold: 0,
4042 default_none_duration_for_new_keys: false,
4043 observations_chunk_size: None,
4044 },
4045 );
4046 cfg.feature_flags.allow_unbounded_system_objects = true;
4047 }
4048 85 => {
4049 if chain != Chain::Mainnet && chain != Chain::Testnet {
4050 cfg.feature_flags.enable_party_transfer = true;
4051 }
4052
4053 cfg.feature_flags
4054 .record_consensus_determined_version_assignments_in_prologue_v2 = true;
4055 cfg.feature_flags.disallow_self_identifier = true;
4056 cfg.feature_flags.per_object_congestion_control_mode =
4057 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4058 ExecutionTimeEstimateParams {
4059 target_utilization: 50,
4060 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4062 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4064 stored_observations_limit: 20,
4065 stake_weighted_median_threshold: 0,
4066 default_none_duration_for_new_keys: false,
4067 observations_chunk_size: None,
4068 },
4069 );
4070 }
4071 86 => {
4072 cfg.feature_flags.type_tags_in_object_runtime = true;
4073 cfg.max_move_enum_variants = Some(move_core_types::VARIANT_COUNT_MAX);
4074
4075 cfg.feature_flags.per_object_congestion_control_mode =
4077 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4078 ExecutionTimeEstimateParams {
4079 target_utilization: 50,
4080 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4082 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4084 stored_observations_limit: 20,
4085 stake_weighted_median_threshold: 3334,
4086 default_none_duration_for_new_keys: false,
4087 observations_chunk_size: None,
4088 },
4089 );
4090 if chain != Chain::Mainnet {
4092 cfg.feature_flags.enable_party_transfer = true;
4093 }
4094 }
4095 87 => {
4096 if chain == Chain::Mainnet {
4097 cfg.feature_flags.record_time_estimate_processed = true;
4098 }
4099 cfg.feature_flags.better_adapter_type_resolution_errors = true;
4100 }
4101 88 => {
4102 cfg.feature_flags.record_time_estimate_processed = true;
4103 cfg.tx_context_rgp_cost_base = Some(30);
4104 cfg.feature_flags
4105 .ignore_execution_time_observations_after_certs_closed = true;
4106
4107 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: true,
4120 observations_chunk_size: None,
4121 },
4122 );
4123 }
4124 89 => {
4125 cfg.feature_flags.dependency_linkage_error = true;
4126 cfg.feature_flags.additional_multisig_checks = true;
4127 }
4128 90 => {
4129 cfg.max_gas_price_rgp_factor_for_aborted_transactions = Some(100);
4131 cfg.feature_flags.debug_fatal_on_move_invariant_violation = true;
4132 cfg.feature_flags.additional_consensus_digest_indirect_state = true;
4133 cfg.feature_flags.accept_passkey_in_multisig = true;
4134 cfg.feature_flags.passkey_auth = true;
4135 cfg.feature_flags.check_for_init_during_upgrade = true;
4136
4137 if chain != Chain::Mainnet {
4139 cfg.feature_flags.mysticeti_fastpath = true;
4140 }
4141 }
4142 91 => {
4143 cfg.feature_flags.per_command_shared_object_transfer_rules = true;
4144 }
4145 92 => {
4146 cfg.feature_flags.per_command_shared_object_transfer_rules = false;
4147 }
4148 93 => {
4149 cfg.feature_flags
4150 .consensus_checkpoint_signature_key_includes_digest = true;
4151 }
4152 94 => {
4153 cfg.feature_flags.per_object_congestion_control_mode =
4155 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4156 ExecutionTimeEstimateParams {
4157 target_utilization: 50,
4158 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4160 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4162 stored_observations_limit: 18,
4163 stake_weighted_median_threshold: 3334,
4164 default_none_duration_for_new_keys: true,
4165 observations_chunk_size: None,
4166 },
4167 );
4168
4169 cfg.feature_flags.enable_party_transfer = true;
4171 }
4172 95 => {
4173 cfg.type_name_id_base_cost = Some(52);
4174
4175 cfg.max_transactions_per_checkpoint = Some(20_000);
4177 }
4178 96 => {
4179 if chain != Chain::Mainnet && chain != Chain::Testnet {
4181 cfg.feature_flags
4182 .include_checkpoint_artifacts_digest_in_summary = true;
4183 }
4184 cfg.feature_flags.correct_gas_payment_limit_check = true;
4185 cfg.feature_flags.authority_capabilities_v2 = true;
4186 cfg.feature_flags.use_mfp_txns_in_load_initial_object_debts = true;
4187 cfg.feature_flags.cancel_for_failed_dkg_early = true;
4188 cfg.feature_flags.enable_coin_registry = true;
4189
4190 cfg.feature_flags.mysticeti_fastpath = true;
4192 }
4193 97 => {
4194 cfg.feature_flags.additional_borrow_checks = true;
4195 }
4196 98 => {
4197 cfg.event_emit_auth_stream_cost = Some(52);
4198 cfg.feature_flags.better_loader_errors = true;
4199 cfg.feature_flags.generate_df_type_layouts = true;
4200 }
4201 99 => {
4202 cfg.feature_flags.use_new_commit_handler = true;
4203 }
4204 100 => {
4205 cfg.feature_flags.private_generics_verifier_v2 = true;
4206 }
4207 101 => {
4208 cfg.feature_flags.create_root_accumulator_object = true;
4209 cfg.max_updates_per_settlement_txn = Some(100);
4210 if chain != Chain::Mainnet {
4211 cfg.feature_flags.enable_poseidon = true;
4212 }
4213 }
4214 102 => {
4215 cfg.feature_flags.per_object_congestion_control_mode =
4219 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4220 ExecutionTimeEstimateParams {
4221 target_utilization: 50,
4222 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4224 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4226 stored_observations_limit: 180,
4227 stake_weighted_median_threshold: 3334,
4228 default_none_duration_for_new_keys: true,
4229 observations_chunk_size: Some(18),
4230 },
4231 );
4232 cfg.feature_flags.deprecate_global_storage_ops = true;
4233 }
4234 103 => {}
4235 104 => {
4236 cfg.translation_per_command_base_charge = Some(1);
4237 cfg.translation_per_input_base_charge = Some(1);
4238 cfg.translation_pure_input_per_byte_charge = Some(1);
4239 cfg.translation_per_type_node_charge = Some(1);
4240 cfg.translation_per_reference_node_charge = Some(1);
4241 cfg.translation_per_linkage_entry_charge = Some(10);
4242 cfg.gas_model_version = Some(11);
4243 cfg.feature_flags.abstract_size_in_object_runtime = true;
4244 cfg.feature_flags.object_runtime_charge_cache_load_gas = true;
4245 cfg.dynamic_field_hash_type_and_key_cost_base = Some(52);
4246 cfg.dynamic_field_add_child_object_cost_base = Some(52);
4247 cfg.dynamic_field_add_child_object_value_cost_per_byte = Some(1);
4248 cfg.dynamic_field_borrow_child_object_cost_base = Some(52);
4249 cfg.dynamic_field_borrow_child_object_child_ref_cost_per_byte = Some(1);
4250 cfg.dynamic_field_remove_child_object_cost_base = Some(52);
4251 cfg.dynamic_field_remove_child_object_child_cost_per_byte = Some(1);
4252 cfg.dynamic_field_has_child_object_cost_base = Some(52);
4253 cfg.dynamic_field_has_child_object_with_ty_cost_base = Some(52);
4254 cfg.feature_flags.enable_ptb_execution_v2 = true;
4255
4256 cfg.poseidon_bn254_cost_base = Some(260);
4257
4258 cfg.feature_flags.consensus_skip_gced_accept_votes = true;
4259
4260 if chain != Chain::Mainnet {
4261 cfg.feature_flags
4262 .enable_nitro_attestation_all_nonzero_pcrs_parsing = true;
4263 }
4264
4265 cfg.feature_flags
4266 .include_cancelled_randomness_txns_in_prologue = true;
4267 }
4268 105 => {
4269 cfg.feature_flags.enable_multi_epoch_transaction_expiration = true;
4270 cfg.feature_flags.disable_preconsensus_locking = true;
4271
4272 if chain != Chain::Mainnet {
4273 cfg.feature_flags
4274 .enable_nitro_attestation_always_include_required_pcrs_parsing = true;
4275 }
4276 }
4277 106 => {
4278 cfg.accumulator_object_storage_cost = Some(7600);
4280
4281 if chain != Chain::Mainnet && chain != Chain::Testnet {
4282 cfg.feature_flags.enable_accumulators = true;
4283 cfg.feature_flags.enable_address_balance_gas_payments = true;
4284 cfg.feature_flags.enable_authenticated_event_streams = true;
4285 cfg.feature_flags.enable_object_funds_withdraw = true;
4286 }
4287 }
4288 107 => {
4289 cfg.feature_flags
4290 .consensus_skip_gced_blocks_in_direct_finalization = true;
4291
4292 if in_integration_test() {
4294 cfg.consensus_gc_depth = Some(6);
4295 cfg.consensus_max_num_transactions_in_block = Some(8);
4296 }
4297 }
4298 108 => {
4299 cfg.feature_flags.gas_rounding_halve_digits = true;
4300 cfg.feature_flags.flexible_tx_context_positions = true;
4301 cfg.feature_flags.disable_entry_point_signature_check = true;
4302
4303 if chain != Chain::Mainnet {
4304 cfg.feature_flags.address_aliases = true;
4305
4306 cfg.feature_flags.enable_accumulators = true;
4307 cfg.feature_flags.enable_address_balance_gas_payments = true;
4308 }
4309
4310 cfg.feature_flags.enable_poseidon = true;
4311 }
4312 109 => {
4313 cfg.binary_variant_handles = Some(1024);
4314 cfg.binary_variant_instantiation_handles = Some(1024);
4315 cfg.feature_flags.restrict_hot_or_not_entry_functions = true;
4316 }
4317 110 => {
4318 cfg.feature_flags
4319 .enable_nitro_attestation_all_nonzero_pcrs_parsing = true;
4320 cfg.feature_flags
4321 .enable_nitro_attestation_always_include_required_pcrs_parsing = true;
4322 if chain != Chain::Mainnet && chain != Chain::Testnet {
4323 cfg.feature_flags.split_checkpoints_in_consensus_handler = true;
4324 }
4325 cfg.feature_flags.validate_zklogin_public_identifier = true;
4326 cfg.feature_flags.fix_checkpoint_signature_mapping = true;
4327 cfg.feature_flags
4328 .consensus_always_accept_system_transactions = true;
4329 if chain != Chain::Mainnet {
4330 cfg.feature_flags.enable_object_funds_withdraw = true;
4331 }
4332 }
4333 111 => {
4334 cfg.feature_flags.validator_metadata_verify_v2 = true;
4335 }
4336 112 => {
4337 cfg.group_ops_ristretto_decode_scalar_cost = Some(7);
4338 cfg.group_ops_ristretto_decode_point_cost = Some(200);
4339 cfg.group_ops_ristretto_scalar_add_cost = Some(10);
4340 cfg.group_ops_ristretto_point_add_cost = Some(500);
4341 cfg.group_ops_ristretto_scalar_sub_cost = Some(10);
4342 cfg.group_ops_ristretto_point_sub_cost = Some(500);
4343 cfg.group_ops_ristretto_scalar_mul_cost = Some(11);
4344 cfg.group_ops_ristretto_point_mul_cost = Some(1200);
4345 cfg.group_ops_ristretto_scalar_div_cost = Some(151);
4346 cfg.group_ops_ristretto_point_div_cost = Some(2500);
4347
4348 if chain != Chain::Mainnet && chain != Chain::Testnet {
4349 cfg.feature_flags.enable_ristretto255_group_ops = true;
4350 }
4351 }
4352 113 => {
4353 cfg.feature_flags.address_balance_gas_check_rgp_at_signing = true;
4354 if chain != Chain::Mainnet && chain != Chain::Testnet {
4355 cfg.feature_flags.defer_unpaid_amplification = true;
4356 }
4357 }
4358 114 => {
4359 cfg.feature_flags.randomize_checkpoint_tx_limit_in_tests = true;
4360 cfg.feature_flags.address_balance_gas_reject_gas_coin_arg = true;
4361 if chain != Chain::Mainnet {
4362 cfg.feature_flags.split_checkpoints_in_consensus_handler = true;
4363 cfg.feature_flags.enable_authenticated_event_streams = true;
4364 cfg.feature_flags
4365 .include_checkpoint_artifacts_digest_in_summary = true;
4366 }
4367 }
4368 115 => {
4369 cfg.feature_flags.normalize_depth_formula = true;
4370 }
4371 116 => {
4372 cfg.feature_flags.gasless_transaction_drop_safety = true;
4373 cfg.feature_flags.address_aliases = true;
4374 cfg.feature_flags.relax_valid_during_for_owned_inputs = true;
4375 cfg.feature_flags.defer_unpaid_amplification = false;
4377 cfg.feature_flags.enable_display_registry = true;
4378 }
4379 117 => {}
4380 118 => {
4381 cfg.feature_flags.use_coin_party_owner = true;
4382 }
4383 119 => {
4384 cfg.execution_version = Some(4);
4386 cfg.feature_flags.address_balance_gas_reject_gas_coin_arg = false;
4387 cfg.feature_flags.merge_randomness_into_checkpoint = true;
4388 if chain != Chain::Mainnet {
4389 cfg.feature_flags.enable_gasless = true;
4390 cfg.gasless_max_computation_units = Some(50_000);
4391 cfg.gasless_allowed_token_types = Some(vec![]);
4392 cfg.feature_flags.enable_coin_reservation_obj_refs = true;
4393 cfg.feature_flags
4394 .convert_withdrawal_compatibility_ptb_arguments = true;
4395 }
4396 cfg.gasless_max_unused_inputs = Some(1);
4397 cfg.gasless_max_pure_input_bytes = Some(32);
4398 if chain == Chain::Testnet {
4399 cfg.gasless_allowed_token_types = Some(vec![(TESTNET_USDC.to_string(), 0)]);
4400 }
4401 cfg.transfer_receive_object_cost_per_byte = Some(1);
4402 cfg.transfer_receive_object_type_cost_per_byte = Some(2);
4403 }
4404 120 => {
4405 cfg.feature_flags.disallow_jump_orphans = true;
4406 }
4407 121 => {
4408 if chain != Chain::Mainnet {
4410 cfg.feature_flags.defer_unpaid_amplification = true;
4411 cfg.gasless_max_tps = Some(50);
4412 }
4413 cfg.feature_flags
4414 .early_return_receive_object_mismatched_type = true;
4415 }
4416 122 => {
4417 cfg.feature_flags.defer_unpaid_amplification = true;
4419 cfg.verify_bulletproofs_ristretto255_base_cost = Some(30000);
4421 cfg.verify_bulletproofs_ristretto255_cost_per_bit_and_commitment = Some(6500);
4422 if chain != Chain::Mainnet && chain != Chain::Testnet {
4423 cfg.feature_flags.enable_verify_bulletproofs_ristretto255 = true;
4424 }
4425 cfg.feature_flags.gasless_verify_remaining_balance = true;
4426 cfg.include_special_package_amendments = match chain {
4427 Chain::Mainnet => Some(MAINNET_LINKAGE_AMENDMENTS.clone()),
4428 Chain::Testnet => Some(TESTNET_LINKAGE_AMENDMENTS.clone()),
4429 Chain::Unknown => None,
4430 };
4431 cfg.gasless_max_tx_size_bytes = Some(16 * 1024);
4432 cfg.gasless_max_tps = Some(300);
4433 cfg.gasless_max_computation_units = Some(5_000);
4434 }
4435 123 => {
4436 cfg.gas_model_version = Some(13);
4437 }
4438 124 => {
4439 if chain != Chain::Mainnet && chain != Chain::Testnet {
4440 cfg.feature_flags.timestamp_based_epoch_close = true;
4441 }
4442 cfg.gas_model_version = Some(14);
4443 cfg.feature_flags.limit_groth16_pvk_inputs = true;
4444
4445 cfg.feature_flags.enable_accumulators = true;
4451 cfg.feature_flags.enable_address_balance_gas_payments = true;
4452 cfg.feature_flags.enable_authenticated_event_streams = true;
4453 cfg.feature_flags.enable_coin_reservation_obj_refs = true;
4454 cfg.feature_flags.enable_object_funds_withdraw = true;
4455 cfg.feature_flags
4456 .convert_withdrawal_compatibility_ptb_arguments = true;
4457 cfg.feature_flags.split_checkpoints_in_consensus_handler = true;
4458 cfg.feature_flags
4459 .include_checkpoint_artifacts_digest_in_summary = true;
4460 cfg.feature_flags.enable_gasless = true;
4461
4462 if chain == Chain::Mainnet {
4467 cfg.gasless_allowed_token_types = Some(vec![
4468 (MAINNET_USDC.to_string(), 10_000),
4469 (MAINNET_USDSUI.to_string(), 10_000),
4470 (MAINNET_SUI_USDE.to_string(), 10_000),
4471 (MAINNET_USDY.to_string(), 10_000),
4472 (MAINNET_FDUSD.to_string(), 10_000),
4473 (MAINNET_AUSD.to_string(), 10_000),
4474 (MAINNET_USDB.to_string(), 10_000),
4475 ]);
4476 }
4477 }
4478 125 => {
4479 cfg.feature_flags.granular_post_execution_checks = true;
4480 if chain != Chain::Mainnet {
4481 cfg.feature_flags.timestamp_based_epoch_close = true;
4482 }
4483 }
4484 126 => {
4485 cfg.feature_flags.early_exit_on_iffw = true;
4486 }
4487 127 => {
4488 cfg.feature_flags.always_advance_dkg_to_resolution = true;
4489
4490 cfg.verify_bulletproofs_ristretto255_base_cost = Some(23866);
4491 cfg.verify_bulletproofs_ristretto255_cost_per_bit_and_commitment = Some(1324);
4492 cfg.group_ops_ristretto_decode_scalar_cost = Some(5);
4493 cfg.group_ops_ristretto_decode_point_cost = Some(216);
4494 cfg.group_ops_ristretto_scalar_add_cost = Some(2);
4495 cfg.group_ops_ristretto_point_add_cost = Some(8);
4496 cfg.group_ops_ristretto_scalar_sub_cost = Some(2);
4497 cfg.group_ops_ristretto_point_sub_cost = Some(8);
4498 cfg.group_ops_ristretto_scalar_mul_cost = Some(5);
4499 cfg.group_ops_ristretto_point_mul_cost = Some(1763);
4500 cfg.group_ops_ristretto_scalar_div_cost = Some(557);
4501 cfg.group_ops_ristretto_point_div_cost = Some(2244);
4502
4503 if chain != Chain::Mainnet {
4504 cfg.feature_flags.enable_ristretto255_group_ops = true;
4505 cfg.feature_flags.enable_verify_bulletproofs_ristretto255 = true;
4506 }
4507
4508 cfg.feature_flags.timestamp_based_epoch_close = true;
4509 }
4510 128 => {
4511 cfg.max_generic_instantiation_type_nodes_per_function = Some(10_000);
4512 cfg.max_generic_instantiation_type_nodes_per_module = Some(500_000);
4513 cfg.binary_enum_defs = Some(200);
4514 cfg.binary_enum_def_instantiations = Some(100);
4515 }
4516 129 => {
4517 cfg.feature_flags.enable_unified_linkage = true;
4518 }
4519 130 => {
4520 cfg.feature_flags.record_net_unsettled_object_withdraws = true;
4521 cfg.feature_flags.enable_init_on_upgrade = true;
4522 cfg.epoch_close_deadline_ms = Some(120_000);
4523 cfg.scratch_add_cost_base = Some(13);
4524 cfg.scratch_read_cost_base = Some(13);
4525 cfg.scratch_read_value_cost = Some(1);
4526 cfg.scratch_remove_cost_base = Some(13);
4527 cfg.scratch_exists_cost_base = Some(13);
4528 cfg.scratch_exists_with_type_cost_base = Some(13);
4529 cfg.scratch_exists_with_type_type_cost = Some(1);
4530 let max_commands = cfg.max_programmable_tx_commands() as u64;
4531 cfg.max_scratch_pad_size = Some(16 * max_commands);
4532 if chain != Chain::Mainnet && chain != Chain::Testnet {
4534 cfg.feature_flags.zklogin_circuit_mode = 1;
4535 }
4536 }
4537 131 => {
4538 cfg.feature_flags.share_transaction_deny_config_in_consensus = true;
4539 }
4540 _ => panic!("unsupported version {:?}", version),
4551 }
4552 }
4553
4554 cfg
4555 }
4556
4557 pub fn apply_seeded_test_overrides(&mut self, seed: &[u8; 32]) {
4558 if !self.feature_flags.randomize_checkpoint_tx_limit_in_tests
4559 || !self.feature_flags.split_checkpoints_in_consensus_handler
4560 {
4561 return;
4562 }
4563
4564 if !mysten_common::in_test_configuration() {
4565 return;
4566 }
4567
4568 use rand::{Rng, SeedableRng, rngs::StdRng};
4569 let mut rng = StdRng::from_seed(*seed);
4570 let max_txns = rng.gen_range(10..=100u64);
4571 info!("seeded test override: max_transactions_per_checkpoint = {max_txns}");
4572 self.max_transactions_per_checkpoint = Some(max_txns);
4573 }
4574
4575 pub fn verifier_config(&self, signing_limits: Option<(usize, usize, usize)>) -> VerifierConfig {
4581 let (
4582 max_back_edges_per_function,
4583 max_back_edges_per_module,
4584 sanity_check_with_regex_reference_safety,
4585 ) = if let Some((
4586 max_back_edges_per_function,
4587 max_back_edges_per_module,
4588 sanity_check_with_regex_reference_safety,
4589 )) = signing_limits
4590 {
4591 (
4592 Some(max_back_edges_per_function),
4593 Some(max_back_edges_per_module),
4594 Some(sanity_check_with_regex_reference_safety),
4595 )
4596 } else {
4597 (None, None, None)
4598 };
4599
4600 let additional_borrow_checks = if signing_limits.is_some() {
4601 true
4603 } else {
4604 self.additional_borrow_checks()
4605 };
4606 let deprecate_global_storage_ops = if signing_limits.is_some() {
4607 true
4609 } else {
4610 self.deprecate_global_storage_ops()
4611 };
4612
4613 VerifierConfig {
4614 max_loop_depth: Some(self.max_loop_depth() as usize),
4615 max_generic_instantiation_length: Some(self.max_generic_instantiation_length() as usize),
4616 max_function_parameters: Some(self.max_function_parameters() as usize),
4617 max_basic_blocks: Some(self.max_basic_blocks() as usize),
4618 max_value_stack_size: self.max_value_stack_size() as usize,
4619 max_type_nodes: Some(self.max_type_nodes() as usize),
4620 max_generic_instantiation_type_nodes_per_function: self
4621 .max_generic_instantiation_type_nodes_per_function_as_option()
4622 .map(|v| v as usize),
4623 max_generic_instantiation_type_nodes_per_module: self
4624 .max_generic_instantiation_type_nodes_per_module_as_option()
4625 .map(|v| v as usize),
4626 max_push_size: Some(self.max_push_size() as usize),
4627 max_dependency_depth: Some(self.max_dependency_depth() as usize),
4628 max_fields_in_struct: Some(self.max_fields_in_struct() as usize),
4629 max_function_definitions: Some(self.max_function_definitions() as usize),
4630 max_data_definitions: Some(self.max_struct_definitions() as usize),
4631 max_constant_vector_len: Some(self.max_move_vector_len()),
4632 max_back_edges_per_function,
4633 max_back_edges_per_module,
4634 max_basic_blocks_in_script: None,
4635 max_identifier_len: self.max_move_identifier_len_as_option(), disallow_self_identifier: self.feature_flags.disallow_self_identifier,
4637 allow_receiving_object_id: self.allow_receiving_object_id(),
4638 reject_mutable_random_on_entry_functions: self
4639 .reject_mutable_random_on_entry_functions(),
4640 bytecode_version: self.move_binary_format_version(),
4641 max_variants_in_enum: self.max_move_enum_variants_as_option(),
4642 additional_borrow_checks,
4643 better_loader_errors: self.better_loader_errors(),
4644 private_generics_verifier_v2: self.private_generics_verifier_v2(),
4645 sanity_check_with_regex_reference_safety: sanity_check_with_regex_reference_safety
4646 .map(|limit| limit as u128),
4647 deprecate_global_storage_ops,
4648 disable_entry_point_signature_check: self.disable_entry_point_signature_check(),
4649 switch_to_regex_reference_safety: false,
4650 disallow_jump_orphans: self.disallow_jump_orphans(),
4651 }
4652 }
4653
4654 pub fn binary_config(
4655 &self,
4656 override_deprecate_global_storage_ops_during_deserialization: Option<bool>,
4657 ) -> BinaryConfig {
4658 let deprecate_global_storage_ops =
4659 override_deprecate_global_storage_ops_during_deserialization
4660 .unwrap_or_else(|| self.deprecate_global_storage_ops());
4661 BinaryConfig::new(
4662 self.move_binary_format_version(),
4663 self.min_move_binary_format_version_as_option()
4664 .unwrap_or(VERSION_1),
4665 self.no_extraneous_module_bytes(),
4666 deprecate_global_storage_ops,
4667 TableConfig {
4668 module_handles: self.binary_module_handles_as_option().unwrap_or(u16::MAX),
4669 datatype_handles: self.binary_struct_handles_as_option().unwrap_or(u16::MAX),
4670 function_handles: self.binary_function_handles_as_option().unwrap_or(u16::MAX),
4671 function_instantiations: self
4672 .binary_function_instantiations_as_option()
4673 .unwrap_or(u16::MAX),
4674 signatures: self.binary_signatures_as_option().unwrap_or(u16::MAX),
4675 constant_pool: self.binary_constant_pool_as_option().unwrap_or(u16::MAX),
4676 identifiers: self.binary_identifiers_as_option().unwrap_or(u16::MAX),
4677 address_identifiers: self
4678 .binary_address_identifiers_as_option()
4679 .unwrap_or(u16::MAX),
4680 struct_defs: self.binary_struct_defs_as_option().unwrap_or(u16::MAX),
4681 struct_def_instantiations: self
4682 .binary_struct_def_instantiations_as_option()
4683 .unwrap_or(u16::MAX),
4684 function_defs: self.binary_function_defs_as_option().unwrap_or(u16::MAX),
4685 field_handles: self.binary_field_handles_as_option().unwrap_or(u16::MAX),
4686 field_instantiations: self
4687 .binary_field_instantiations_as_option()
4688 .unwrap_or(u16::MAX),
4689 friend_decls: self.binary_friend_decls_as_option().unwrap_or(u16::MAX),
4690 enum_defs: self.binary_enum_defs_as_option().unwrap_or(u16::MAX),
4691 enum_def_instantiations: self
4692 .binary_enum_def_instantiations_as_option()
4693 .unwrap_or(u16::MAX),
4694 variant_handles: self.binary_variant_handles_as_option().unwrap_or(u16::MAX),
4695 variant_instantiation_handles: self
4696 .binary_variant_instantiation_handles_as_option()
4697 .unwrap_or(u16::MAX),
4698 },
4699 )
4700 }
4701
4702 #[cfg(not(msim))]
4706 pub fn apply_overrides_for_testing(
4707 override_fn: impl Fn(ProtocolVersion, Self) -> Self + Send + Sync + 'static,
4708 ) -> OverrideGuard {
4709 let mut cur = CONFIG_OVERRIDE.lock().unwrap();
4710 assert!(cur.is_none(), "config override already present");
4711 *cur = Some(Box::new(override_fn));
4712 OverrideGuard
4713 }
4714
4715 #[cfg(msim)]
4719 pub fn apply_overrides_for_testing(
4720 override_fn: impl Fn(ProtocolVersion, Self) -> Self + Send + 'static,
4721 ) -> OverrideGuard {
4722 CONFIG_OVERRIDE.with(|ovr| {
4723 let mut cur = ovr.borrow_mut();
4724 assert!(cur.is_none(), "config override already present");
4725 *cur = Some(Box::new(override_fn));
4726 OverrideGuard
4727 })
4728 }
4729
4730 #[cfg(not(msim))]
4731 fn apply_config_override(version: ProtocolVersion, mut ret: Self) -> Self {
4732 if let Some(override_fn) = CONFIG_OVERRIDE.lock().unwrap().as_ref() {
4733 warn!(
4734 "overriding ProtocolConfig settings with custom settings (you should not see this log outside of tests)"
4735 );
4736 ret = override_fn(version, ret);
4737 }
4738 ret
4739 }
4740
4741 #[cfg(msim)]
4742 fn apply_config_override(version: ProtocolVersion, ret: Self) -> Self {
4743 CONFIG_OVERRIDE.with(|ovr| {
4744 if let Some(override_fn) = &*ovr.borrow() {
4745 warn!(
4746 "overriding ProtocolConfig settings with custom settings (you should not see this log outside of tests)"
4747 );
4748 override_fn(version, ret)
4749 } else {
4750 ret
4751 }
4752 })
4753 }
4754}
4755
4756impl ProtocolConfig {
4760 pub fn set_zklogin_circuit_mode_for_testing(&mut self, val: u64) {
4763 self.feature_flags.zklogin_circuit_mode = val
4764 }
4765
4766 pub fn set_per_object_congestion_control_mode_for_testing(
4767 &mut self,
4768 val: PerObjectCongestionControlMode,
4769 ) {
4770 self.feature_flags.per_object_congestion_control_mode = val;
4771 }
4772
4773 pub fn set_consensus_choice_for_testing(&mut self, val: ConsensusChoice) {
4774 self.feature_flags.consensus_choice = val;
4775 }
4776
4777 pub fn set_consensus_network_for_testing(&mut self, val: ConsensusNetwork) {
4778 self.feature_flags.consensus_network = val;
4779 }
4780
4781 pub fn set_zklogin_max_epoch_upper_bound_delta_for_testing(&mut self, val: Option<u64>) {
4782 self.feature_flags.zklogin_max_epoch_upper_bound_delta = val
4783 }
4784
4785 pub fn set_mysticeti_num_leaders_per_round_for_testing(&mut self, val: Option<usize>) {
4786 self.feature_flags.mysticeti_num_leaders_per_round = val;
4787 }
4788
4789 pub fn disable_accumulators_for_testing(&mut self) {
4790 self.feature_flags.enable_accumulators = false;
4791 self.feature_flags.enable_address_balance_gas_payments = false;
4792 }
4793
4794 pub fn enable_coin_reservation_for_testing(&mut self) {
4795 self.feature_flags.enable_coin_reservation_obj_refs = true;
4796 self.feature_flags
4797 .convert_withdrawal_compatibility_ptb_arguments = true;
4798 self.execution_version = Some(self.execution_version.map_or(4, |v| v.max(4)));
4801 }
4802
4803 pub fn disable_coin_reservation_for_testing(&mut self) {
4804 self.feature_flags.enable_coin_reservation_obj_refs = false;
4805 self.feature_flags
4806 .convert_withdrawal_compatibility_ptb_arguments = false;
4807 }
4808
4809 pub fn enable_address_balance_gas_payments_for_testing(&mut self) {
4810 self.feature_flags.enable_accumulators = true;
4811 self.feature_flags.allow_private_accumulator_entrypoints = true;
4812 self.feature_flags.enable_address_balance_gas_payments = true;
4813 self.feature_flags.address_balance_gas_check_rgp_at_signing = true;
4814 self.feature_flags.address_balance_gas_reject_gas_coin_arg = false;
4815 self.execution_version = Some(self.execution_version.map_or(4, |v| v.max(4)))
4816 }
4817
4818 pub fn enable_gasless_for_testing(&mut self) {
4819 self.enable_address_balance_gas_payments_for_testing();
4820 self.feature_flags.enable_gasless = true;
4821 self.feature_flags.gasless_verify_remaining_balance = true;
4822 self.gasless_max_computation_units = Some(5_000);
4823 self.gasless_allowed_token_types = Some(vec![]);
4824 self.gasless_max_tps = Some(1000);
4825 self.gasless_max_tx_size_bytes = Some(16 * 1024);
4826 }
4827
4828 pub fn disable_gasless_for_testing(&mut self) {
4829 self.feature_flags.enable_gasless = false;
4830 self.gasless_max_computation_units = None;
4831 self.gasless_allowed_token_types = None;
4832 }
4833
4834 pub fn enable_authenticated_event_streams_for_testing(&mut self) {
4835 self.feature_flags.enable_accumulators = true;
4836 self.feature_flags.enable_authenticated_event_streams = true;
4837 self.feature_flags
4838 .include_checkpoint_artifacts_digest_in_summary = true;
4839 self.feature_flags.split_checkpoints_in_consensus_handler = true;
4840 }
4841}
4842
4843#[cfg(not(msim))]
4844type OverrideFn = dyn Fn(ProtocolVersion, ProtocolConfig) -> ProtocolConfig + Send + Sync;
4845
4846#[cfg(not(msim))]
4847static CONFIG_OVERRIDE: Mutex<Option<Box<OverrideFn>>> = Mutex::new(None);
4848
4849#[cfg(msim)]
4850type OverrideFn = dyn Fn(ProtocolVersion, ProtocolConfig) -> ProtocolConfig + Send;
4851
4852#[cfg(msim)]
4853thread_local! {
4854 static CONFIG_OVERRIDE: RefCell<Option<Box<OverrideFn>>> = RefCell::new(None);
4855}
4856
4857#[must_use]
4858pub struct OverrideGuard;
4859
4860#[cfg(not(msim))]
4861impl Drop for OverrideGuard {
4862 fn drop(&mut self) {
4863 info!("restoring override fn");
4864 *CONFIG_OVERRIDE.lock().unwrap() = None;
4865 }
4866}
4867
4868#[cfg(msim)]
4869impl Drop for OverrideGuard {
4870 fn drop(&mut self) {
4871 info!("restoring override fn");
4872 CONFIG_OVERRIDE.with(|ovr| {
4873 *ovr.borrow_mut() = None;
4874 });
4875 }
4876}
4877
4878#[derive(PartialEq, Eq)]
4881pub enum LimitThresholdCrossed {
4882 None,
4883 Soft(u128, u128),
4884 Hard(u128, u128),
4885}
4886
4887pub fn check_limit_in_range<T: Into<V>, U: Into<V>, V: PartialOrd + Into<u128>>(
4890 x: T,
4891 soft_limit: U,
4892 hard_limit: V,
4893) -> LimitThresholdCrossed {
4894 let x: V = x.into();
4895 let soft_limit: V = soft_limit.into();
4896
4897 debug_assert!(soft_limit <= hard_limit);
4898
4899 if x >= hard_limit {
4902 LimitThresholdCrossed::Hard(x.into(), hard_limit.into())
4903 } else if x < soft_limit {
4904 LimitThresholdCrossed::None
4905 } else {
4906 LimitThresholdCrossed::Soft(x.into(), soft_limit.into())
4907 }
4908}
4909
4910#[macro_export]
4911macro_rules! check_limit {
4912 ($x:expr, $hard:expr) => {
4913 check_limit!($x, $hard, $hard)
4914 };
4915 ($x:expr, $soft:expr, $hard:expr) => {
4916 check_limit_in_range($x as u64, $soft, $hard)
4917 };
4918}
4919
4920#[macro_export]
4924macro_rules! check_limit_by_meter {
4925 ($is_metered:expr, $x:expr, $metered_limit:expr, $unmetered_hard_limit:expr, $metric:expr) => {{
4926 let (h, metered_str) = if $is_metered {
4928 ($metered_limit, "metered")
4929 } else {
4930 ($unmetered_hard_limit, "unmetered")
4932 };
4933 use sui_protocol_config::check_limit_in_range;
4934 let result = check_limit_in_range($x as u64, $metered_limit, h);
4935 match result {
4936 LimitThresholdCrossed::None => {}
4937 LimitThresholdCrossed::Soft(_, _) => {
4938 $metric.with_label_values(&[metered_str, "soft"]).inc();
4939 }
4940 LimitThresholdCrossed::Hard(_, _) => {
4941 $metric.with_label_values(&[metered_str, "hard"]).inc();
4942 }
4943 };
4944 result
4945 }};
4946}
4947
4948pub type Amendments = BTreeMap<AccountAddress, BTreeMap<AccountAddress, AccountAddress>>;
4951
4952static MAINNET_LINKAGE_AMENDMENTS: LazyLock<Arc<Amendments>> =
4953 LazyLock::new(|| parse_amendments(include_str!("mainnet_amendments.json")));
4954
4955static TESTNET_LINKAGE_AMENDMENTS: LazyLock<Arc<Amendments>> =
4956 LazyLock::new(|| parse_amendments(include_str!("testnet_amendments.json")));
4957
4958fn parse_amendments(json: &str) -> Arc<Amendments> {
4959 #[derive(serde::Deserialize)]
4960 struct AmendmentEntry {
4961 root: String,
4962 deps: Vec<DepEntry>,
4963 }
4964
4965 #[derive(serde::Deserialize)]
4966 struct DepEntry {
4967 original_id: String,
4968 version_id: String,
4969 }
4970
4971 let entries: Vec<AmendmentEntry> =
4972 serde_json::from_str(json).expect("Failed to parse amendments JSON");
4973 let mut amendments = BTreeMap::new();
4974 for entry in entries {
4975 let root_id = AccountAddress::from_hex_literal(&entry.root).unwrap();
4976 let mut dep_ids = BTreeMap::new();
4977 for dep in entry.deps {
4978 let orig_id = AccountAddress::from_hex_literal(&dep.original_id).unwrap();
4979 let upgraded_id = AccountAddress::from_hex_literal(&dep.version_id).unwrap();
4980 assert!(
4981 dep_ids.insert(orig_id, upgraded_id).is_none(),
4982 "Duplicate original ID in amendments table"
4983 );
4984 }
4985 assert!(
4986 amendments.insert(root_id, dep_ids).is_none(),
4987 "Duplicate root ID in amendments table"
4988 );
4989 }
4990 Arc::new(amendments)
4991}
4992
4993#[cfg(all(test, not(msim)))]
4994mod test {
4995 use insta::assert_yaml_snapshot;
4996
4997 use super::*;
4998
4999 #[test]
5000 fn snapshot_tests() {
5001 println!("\n============================================================================");
5002 println!("! !");
5003 println!("! IMPORTANT: never update snapshots from this test. only add new versions! !");
5004 println!("! !");
5005 println!("============================================================================\n");
5006 for chain_id in &[Chain::Unknown, Chain::Mainnet, Chain::Testnet] {
5007 let chain_str = match chain_id {
5011 Chain::Unknown => "".to_string(),
5012 _ => format!("{:?}_", chain_id),
5013 };
5014 for i in MIN_PROTOCOL_VERSION..=MAX_PROTOCOL_VERSION {
5015 let cur = ProtocolVersion::new(i);
5016 assert_yaml_snapshot!(
5017 format!("{}version_{}", chain_str, cur.as_u64()),
5018 ProtocolConfig::get_for_version(cur, *chain_id)
5019 );
5020 }
5021 }
5022 }
5023
5024 #[test]
5025 fn test_getters() {
5026 let prot: ProtocolConfig =
5027 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5028 assert_eq!(
5029 prot.max_arguments(),
5030 prot.max_arguments_as_option().unwrap()
5031 );
5032 }
5033
5034 #[test]
5035 fn test_setters() {
5036 let mut prot: ProtocolConfig =
5037 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5038 prot.set_max_arguments_for_testing(123);
5039 assert_eq!(prot.max_arguments(), 123);
5040
5041 prot.set_max_arguments_from_str_for_testing("321".to_string());
5042 assert_eq!(prot.max_arguments(), 321);
5043
5044 prot.disable_max_arguments_for_testing();
5045 assert_eq!(prot.max_arguments_as_option(), None);
5046
5047 prot.set_attr_for_testing("max_arguments".to_string(), "456".to_string());
5048 assert_eq!(prot.max_arguments(), 456);
5049 }
5050
5051 #[test]
5052 fn test_feature_flag_setter_by_string() {
5053 let mut prot: ProtocolConfig =
5054 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5055 assert!(!prot.zklogin_auth());
5056 prot.set_feature_flag_for_testing("zklogin_auth".to_string(), true);
5057 assert!(prot.zklogin_auth());
5058 prot.set_feature_flag_for_testing("zklogin_auth".to_string(), false);
5059 assert!(!prot.zklogin_auth());
5060 }
5061
5062 #[test]
5063 #[should_panic(expected = "unknown feature flag")]
5064 fn test_feature_flag_setter_unknown_flag() {
5065 let mut prot: ProtocolConfig =
5066 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5067 prot.set_feature_flag_for_testing("some random string".to_string(), true);
5068 }
5069
5070 #[test]
5071 fn test_get_for_version_if_supported_applies_test_overrides() {
5072 let before =
5073 ProtocolConfig::get_for_version_if_supported(ProtocolVersion::new(1), Chain::Unknown)
5074 .unwrap();
5075
5076 assert!(!before.enable_coin_reservation_obj_refs());
5077
5078 let _guard = ProtocolConfig::apply_overrides_for_testing(|_, mut cfg| {
5079 cfg.enable_coin_reservation_for_testing();
5080 cfg
5081 });
5082
5083 let after =
5084 ProtocolConfig::get_for_version_if_supported(ProtocolVersion::new(1), Chain::Unknown)
5085 .unwrap();
5086
5087 assert!(after.enable_coin_reservation_obj_refs());
5088 }
5089
5090 #[test]
5091 #[should_panic(expected = "unsupported version")]
5092 fn max_version_test() {
5093 let _ = ProtocolConfig::get_for_version_impl(
5096 ProtocolVersion::new(MAX_PROTOCOL_VERSION + 1),
5097 Chain::Unknown,
5098 );
5099 }
5100
5101 #[test]
5102 fn lookup_by_string_test() {
5103 let prot: ProtocolConfig =
5104 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5105 assert!(prot.lookup_attr("some random string".to_string()).is_none());
5107
5108 assert!(
5109 prot.lookup_attr("max_arguments".to_string())
5110 == Some(ProtocolConfigValue::u32(prot.max_arguments())),
5111 );
5112
5113 assert!(
5115 prot.lookup_attr("max_move_identifier_len".to_string())
5116 .is_none()
5117 );
5118
5119 let prot: ProtocolConfig =
5121 ProtocolConfig::get_for_version(ProtocolVersion::new(9), Chain::Unknown);
5122 assert!(
5123 prot.lookup_attr("max_move_identifier_len".to_string())
5124 == Some(ProtocolConfigValue::u64(prot.max_move_identifier_len()))
5125 );
5126
5127 let prot: ProtocolConfig =
5128 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5129 assert!(
5131 prot.attr_map()
5132 .get("max_move_identifier_len")
5133 .unwrap()
5134 .is_none()
5135 );
5136 assert!(
5138 prot.attr_map().get("max_arguments").unwrap()
5139 == &Some(ProtocolConfigValue::u32(prot.max_arguments()))
5140 );
5141
5142 let prot: ProtocolConfig =
5144 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5145 assert!(
5147 prot.feature_flags
5148 .lookup_attr("some random string".to_owned())
5149 .is_none()
5150 );
5151 assert!(
5152 !prot
5153 .feature_flags
5154 .attr_map()
5155 .contains_key("some random string")
5156 );
5157
5158 assert!(
5160 prot.feature_flags
5161 .lookup_attr("package_upgrades".to_owned())
5162 == Some(false)
5163 );
5164 assert!(
5165 prot.feature_flags
5166 .attr_map()
5167 .get("package_upgrades")
5168 .unwrap()
5169 == &false
5170 );
5171 let prot: ProtocolConfig =
5172 ProtocolConfig::get_for_version(ProtocolVersion::new(4), Chain::Unknown);
5173 assert!(
5175 prot.feature_flags
5176 .lookup_attr("package_upgrades".to_owned())
5177 == Some(true)
5178 );
5179 assert!(
5180 prot.feature_flags
5181 .attr_map()
5182 .get("package_upgrades")
5183 .unwrap()
5184 == &true
5185 );
5186 }
5187
5188 #[test]
5189 fn limit_range_fn_test() {
5190 let low = 100u32;
5191 let high = 10000u64;
5192
5193 assert!(check_limit!(1u8, low, high) == LimitThresholdCrossed::None);
5194 assert!(matches!(
5195 check_limit!(255u16, low, high),
5196 LimitThresholdCrossed::Soft(255u128, 100)
5197 ));
5198 assert!(matches!(
5204 check_limit!(2550000u64, low, high),
5205 LimitThresholdCrossed::Hard(2550000, 10000)
5206 ));
5207
5208 assert!(matches!(
5209 check_limit!(2550000u64, high, high),
5210 LimitThresholdCrossed::Hard(2550000, 10000)
5211 ));
5212
5213 assert!(matches!(
5214 check_limit!(1u8, high),
5215 LimitThresholdCrossed::None
5216 ));
5217
5218 assert!(check_limit!(255u16, high) == LimitThresholdCrossed::None);
5219
5220 assert!(matches!(
5221 check_limit!(2550000u64, high),
5222 LimitThresholdCrossed::Hard(2550000, 10000)
5223 ));
5224 }
5225
5226 #[test]
5227 fn linkage_amendments_load() {
5228 let mainnet = LazyLock::force(&MAINNET_LINKAGE_AMENDMENTS);
5229 let testnet = LazyLock::force(&TESTNET_LINKAGE_AMENDMENTS);
5230 assert!(!mainnet.is_empty(), "mainnet amendments must not be empty");
5231 assert!(!testnet.is_empty(), "testnet amendments must not be empty");
5232 }
5233
5234 #[test]
5235 fn render_scalar_fields_use_precision_safe_encoding() {
5236 use mysten_common::rpc_format::Unmetered;
5237
5238 let config = ProtocolConfig::get_for_max_version_UNSAFE();
5239 let rendered = config
5240 .render::<serde_json::Value>(&mut Unmetered)
5241 .expect("render should succeed");
5242
5243 let max_args = rendered
5244 .get("max_arguments")
5245 .expect("max_arguments set at max version");
5246 assert!(
5247 max_args.is_number(),
5248 "u32 should render as number, got {max_args:?}",
5249 );
5250
5251 let max_tx_size = rendered
5252 .get("max_tx_size_bytes")
5253 .expect("max_tx_size_bytes set at max version");
5254 assert!(
5255 max_tx_size.is_string(),
5256 "u64 should render as string, got {max_tx_size:?}",
5257 );
5258 }
5259
5260 #[test]
5261 fn render_includes_non_scalar_gasless_allowlist_as_json() {
5262 use mysten_common::rpc_format::Unmetered;
5263 use serde_json::json;
5264
5265 let mut config = ProtocolConfig::get_for_max_version_UNSAFE();
5266 config.set_gasless_allowed_token_types_for_testing(vec![
5267 ("0xa::usdc::USDC".to_string(), 10_000),
5268 ("0xb::usdt::USDT".to_string(), 0),
5269 ]);
5270
5271 let rendered = config
5272 .render::<serde_json::Value>(&mut Unmetered)
5273 .expect("render should succeed under Unmetered budget");
5274 let allowlist = rendered
5275 .get("gasless_allowed_token_types")
5276 .expect("entry should be present after the testing setter");
5277
5278 assert_eq!(
5281 allowlist,
5282 &json!([["0xa::usdc::USDC", "10000"], ["0xb::usdt::USDT", "0"],]),
5283 );
5284 }
5285
5286 #[test]
5287 fn render_targets_prost_value_for_grpc() {
5288 use mysten_common::rpc_format::Unmetered;
5289 use prost_types::value::Kind;
5290
5291 let mut config = ProtocolConfig::get_for_max_version_UNSAFE();
5292 config.set_gasless_allowed_token_types_for_testing(vec![(
5293 "0xa::usdc::USDC".to_string(),
5294 10_000,
5295 )]);
5296
5297 let rendered = config
5298 .render::<prost_types::Value>(&mut Unmetered)
5299 .expect("render to prost Value should succeed");
5300 let allowlist = rendered
5301 .get("gasless_allowed_token_types")
5302 .expect("entry should be present after the testing setter");
5303
5304 let Some(Kind::ListValue(outer)) = &allowlist.kind else {
5306 panic!(
5307 "expected ListValue at the top level, got {:?}",
5308 allowlist.kind
5309 );
5310 };
5311 assert_eq!(outer.values.len(), 1, "one allowlisted entry");
5312 let Some(Kind::ListValue(entry)) = &outer.values[0].kind else {
5313 panic!("expected each entry to be a ListValue");
5314 };
5315 assert_eq!(entry.values.len(), 2, "entry has (coin_type, amount)");
5316
5317 let Some(Kind::StringValue(coin_type)) = &entry.values[0].kind else {
5318 panic!("expected coin_type as StringValue");
5319 };
5320 assert_eq!(coin_type, "0xa::usdc::USDC");
5321
5322 let Some(Kind::StringValue(amount)) = &entry.values[1].kind else {
5324 panic!(
5325 "expected minimum_transfer_amount as StringValue (precision-safe u64); got {:?}",
5326 entry.values[1].kind,
5327 );
5328 };
5329 assert_eq!(amount, "10000");
5330 }
5331
5332 #[test]
5333 fn render_emits_null_for_unset_protocol_versions() {
5334 use mysten_common::rpc_format::Unmetered;
5335
5336 let config = ProtocolConfig::get_for_version(1.into(), Chain::Unknown);
5337 let rendered = config
5338 .render::<serde_json::Value>(&mut Unmetered)
5339 .expect("render should succeed");
5340 let entry = rendered
5344 .get("gasless_allowed_token_types")
5345 .expect("key should be present for every protocol version");
5346 assert!(
5347 entry.is_null(),
5348 "value should be null for pre-feature protocol version, got {entry:?}",
5349 );
5350 }
5351}