1use std::{
5 collections::{BTreeMap, BTreeSet},
6 sync::{
7 Arc, LazyLock,
8 atomic::{AtomicBool, Ordering},
9 },
10};
11
12use std::sync::Mutex;
13
14use clap::*;
15use fastcrypto::encoding::{Base58, Encoding, Hex};
16use move_binary_format::{
17 binary_config::{BinaryConfig, TableConfig},
18 file_format_common::VERSION_1,
19};
20use move_core_types::account_address::AccountAddress;
21use move_vm_config::verifier::VerifierConfig;
22use mysten_common::in_integration_test;
23use serde::{Deserialize, Serialize};
24use serde_with::skip_serializing_none;
25use sui_protocol_config_macros::{
26 ProtocolConfigAccessors, ProtocolConfigFeatureFlagsGetters, ProtocolConfigOverride,
27};
28use tracing::{info, warn};
29
30const MIN_PROTOCOL_VERSION: u64 = 1;
32const MAX_PROTOCOL_VERSION: u64 = 132;
33
34const TESTNET_USDC: &str =
35 "0xa1ec7fc00a6f40db9693ad1415d0c193ad3906494428cf252621037bd7117e29::usdc::USDC";
36
37const MAINNET_USDC: &str =
38 "0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC";
39const MAINNET_USDSUI: &str =
40 "0x44f838219cf67b058f3b37907b655f226153c18e33dfcd0da559a844fea9b1c1::usdsui::USDSUI";
41const MAINNET_SUI_USDE: &str =
42 "0x41d587e5336f1c86cad50d38a7136db99333bb9bda91cea4ba69115defeb1402::sui_usde::SUI_USDE";
43const MAINNET_USDY: &str =
44 "0x960b531667636f39e85867775f52f6b1f220a058c4de786905bdf761e06a56bb::usdy::USDY";
45const MAINNET_FDUSD: &str =
46 "0xf16e6b723f242ec745dfd7634ad072c42d5c1d9ac9d62a39c381303eaa57693a::fdusd::FDUSD";
47const MAINNET_AUSD: &str =
48 "0x2053d08c1e2bd02791056171aab0fd12bd7cd7efad2ab8f6b9c8902f14df2ff2::ausd::AUSD";
49const MAINNET_USDB: &str =
50 "0xe14726c336e81b32328e92afc37345d159f5b550b09fa92bd43640cfdd0a0cfd::usdb::USDB";
51
52#[derive(Copy, Clone, Debug, Hash, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)]
377pub struct ProtocolVersion(u64);
378
379impl ProtocolVersion {
380 pub const MIN: Self = Self(MIN_PROTOCOL_VERSION);
385
386 pub const MAX: Self = Self(MAX_PROTOCOL_VERSION);
387
388 #[cfg(not(msim))]
389 pub const MAX_ALLOWED: Self = Self::MAX;
390
391 #[cfg(msim)]
393 pub const MAX_ALLOWED: Self = Self(MAX_PROTOCOL_VERSION + 1);
394
395 pub fn new(v: u64) -> Self {
396 Self(v)
397 }
398
399 pub const fn as_u64(&self) -> u64 {
400 self.0
401 }
402
403 pub fn max() -> Self {
406 Self::MAX
407 }
408
409 pub fn prev(self) -> Self {
410 Self(self.0.checked_sub(1).unwrap())
411 }
412}
413
414impl From<u64> for ProtocolVersion {
415 fn from(v: u64) -> Self {
416 Self::new(v)
417 }
418}
419
420impl std::ops::Sub<u64> for ProtocolVersion {
421 type Output = Self;
422 fn sub(self, rhs: u64) -> Self::Output {
423 Self::new(self.0 - rhs)
424 }
425}
426
427impl std::ops::Add<u64> for ProtocolVersion {
428 type Output = Self;
429 fn add(self, rhs: u64) -> Self::Output {
430 Self::new(self.0 + rhs)
431 }
432}
433
434#[derive(
435 Clone, Serialize, Deserialize, Debug, Default, PartialEq, Copy, PartialOrd, Ord, Eq, ValueEnum,
436)]
437pub enum Chain {
438 Mainnet,
439 Testnet,
440 #[default]
441 Unknown,
442}
443
444impl Chain {
445 pub fn as_str(self) -> &'static str {
446 match self {
447 Chain::Mainnet => "mainnet",
448 Chain::Testnet => "testnet",
449 Chain::Unknown => "unknown",
450 }
451 }
452}
453
454pub struct Error(pub String);
455
456#[derive(Default, Clone, Serialize, Deserialize, Debug, ProtocolConfigFeatureFlagsGetters)]
459struct FeatureFlags {
460 #[serde(skip_serializing_if = "is_false")]
463 package_upgrades: bool,
464 #[serde(skip_serializing_if = "is_false")]
467 commit_root_state_digest: bool,
468 #[serde(skip_serializing_if = "is_false")]
470 advance_epoch_start_time_in_safe_mode: bool,
471 #[serde(skip_serializing_if = "is_false")]
474 loaded_child_objects_fixed: bool,
475 #[serde(skip_serializing_if = "is_false")]
478 missing_type_is_compatibility_error: bool,
479 #[serde(skip_serializing_if = "is_false")]
482 scoring_decision_with_validity_cutoff: bool,
483
484 #[serde(skip_serializing_if = "is_false")]
487 consensus_order_end_of_epoch_last: bool,
488
489 #[serde(skip_serializing_if = "is_false")]
491 disallow_adding_abilities_on_upgrade: bool,
492 #[serde(skip_serializing_if = "is_false")]
494 disable_invariant_violation_check_in_swap_loc: bool,
495 #[serde(skip_serializing_if = "is_false")]
498 advance_to_highest_supported_protocol_version: bool,
499 #[serde(skip_serializing_if = "is_false")]
501 ban_entry_init: bool,
502 #[serde(skip_serializing_if = "is_false")]
504 package_digest_hash_module: bool,
505 #[serde(skip_serializing_if = "is_false")]
507 disallow_change_struct_type_params_on_upgrade: bool,
508 #[serde(skip_serializing_if = "is_false")]
510 no_extraneous_module_bytes: bool,
511 #[serde(skip_serializing_if = "is_false")]
513 narwhal_versioned_metadata: bool,
514
515 #[serde(skip_serializing_if = "is_false")]
517 zklogin_auth: bool,
518 #[serde(skip_serializing_if = "is_zero")]
521 zklogin_circuit_mode: u64,
522 #[serde(skip_serializing_if = "ConsensusTransactionOrdering::is_none")]
524 consensus_transaction_ordering: ConsensusTransactionOrdering,
525
526 #[serde(skip_serializing_if = "is_false")]
534 simplified_unwrap_then_delete: bool,
535 #[serde(skip_serializing_if = "is_false")]
537 upgraded_multisig_supported: bool,
538 #[serde(skip_serializing_if = "is_false")]
540 txn_base_cost_as_multiplier: bool,
541
542 #[serde(skip_serializing_if = "is_false")]
544 shared_object_deletion: bool,
545
546 #[serde(skip_serializing_if = "is_false")]
548 narwhal_new_leader_election_schedule: bool,
549
550 #[serde(skip_serializing_if = "is_empty")]
552 zklogin_supported_providers: BTreeSet<String>,
553
554 #[serde(skip_serializing_if = "is_false")]
556 loaded_child_object_format: bool,
557
558 #[serde(skip_serializing_if = "is_false")]
559 #[skip_protocol_config_accessor]
560 enable_jwk_consensus_updates: bool,
561
562 #[serde(skip_serializing_if = "is_false")]
563 #[skip_protocol_config_accessor]
564 end_of_epoch_transaction_supported: bool,
565
566 #[serde(skip_serializing_if = "is_false")]
569 simple_conservation_checks: bool,
570
571 #[serde(skip_serializing_if = "is_false")]
573 loaded_child_object_format_type: bool,
574
575 #[serde(skip_serializing_if = "is_false")]
577 receive_objects: bool,
578
579 #[serde(skip_serializing_if = "is_false")]
581 consensus_checkpoint_signature_key_includes_digest: bool,
582
583 #[serde(skip_serializing_if = "is_false")]
585 random_beacon: bool,
586
587 #[serde(skip_serializing_if = "is_false")]
589 #[skip_protocol_config_accessor]
590 bridge: bool,
591
592 #[serde(skip_serializing_if = "is_false")]
593 enable_effects_v2: bool,
594
595 #[serde(skip_serializing_if = "is_false")]
597 narwhal_certificate_v2: bool,
598
599 #[serde(skip_serializing_if = "is_false")]
601 verify_legacy_zklogin_address: bool,
602
603 #[serde(skip_serializing_if = "is_false")]
605 throughput_aware_consensus_submission: bool,
606
607 #[serde(skip_serializing_if = "is_false")]
609 recompute_has_public_transfer_in_execution: bool,
610
611 #[serde(skip_serializing_if = "is_false")]
613 accept_zklogin_in_multisig: bool,
614
615 #[serde(skip_serializing_if = "is_false")]
617 accept_passkey_in_multisig: bool,
618
619 #[serde(skip_serializing_if = "is_false")]
621 validate_zklogin_public_identifier: bool,
622
623 #[serde(skip_serializing_if = "is_false")]
626 include_consensus_digest_in_prologue: bool,
627
628 #[serde(skip_serializing_if = "is_false")]
630 hardened_otw_check: bool,
631
632 #[serde(skip_serializing_if = "is_false")]
634 allow_receiving_object_id: bool,
635
636 #[serde(skip_serializing_if = "is_false")]
638 enable_poseidon: bool,
639
640 #[serde(skip_serializing_if = "is_false")]
642 enable_coin_deny_list: bool,
643
644 #[serde(skip_serializing_if = "is_false")]
646 enable_group_ops_native_functions: bool,
647
648 #[serde(skip_serializing_if = "is_false")]
650 enable_group_ops_native_function_msm: bool,
651
652 #[serde(skip_serializing_if = "is_false")]
654 enable_ristretto255_group_ops: bool,
655
656 #[serde(skip_serializing_if = "is_false")]
658 enable_verify_bulletproofs_ristretto255: bool,
659
660 #[serde(skip_serializing_if = "is_false")]
662 enable_nitro_attestation: bool,
663
664 #[serde(skip_serializing_if = "is_false")]
666 enable_nitro_attestation_upgraded_parsing: bool,
667
668 #[serde(skip_serializing_if = "is_false")]
670 enable_nitro_attestation_all_nonzero_pcrs_parsing: bool,
671
672 #[serde(skip_serializing_if = "is_false")]
674 enable_nitro_attestation_always_include_required_pcrs_parsing: bool,
675
676 #[serde(skip_serializing_if = "is_false")]
678 reject_mutable_random_on_entry_functions: bool,
679
680 #[serde(skip_serializing_if = "PerObjectCongestionControlMode::is_none")]
682 per_object_congestion_control_mode: PerObjectCongestionControlMode,
683
684 #[serde(skip_serializing_if = "ConsensusChoice::is_narwhal")]
686 consensus_choice: ConsensusChoice,
687
688 #[serde(skip_serializing_if = "ConsensusNetwork::is_anemo")]
690 consensus_network: ConsensusNetwork,
691
692 #[serde(skip_serializing_if = "is_false")]
694 correct_gas_payment_limit_check: bool,
695
696 #[serde(skip_serializing_if = "Option::is_none")]
698 zklogin_max_epoch_upper_bound_delta: Option<u64>,
699
700 #[serde(skip_serializing_if = "is_false")]
702 mysticeti_leader_scoring_and_schedule: bool,
703
704 #[serde(skip_serializing_if = "is_false")]
706 reshare_at_same_initial_version: bool,
707
708 #[serde(skip_serializing_if = "is_false")]
710 resolve_abort_locations_to_package_id: bool,
711
712 #[serde(skip_serializing_if = "is_false")]
716 mysticeti_use_committed_subdag_digest: bool,
717
718 #[serde(skip_serializing_if = "is_false")]
720 enable_vdf: bool,
721
722 #[serde(skip_serializing_if = "is_false")]
726 record_consensus_determined_version_assignments_in_prologue: bool,
727 #[serde(skip_serializing_if = "is_false")]
730 record_consensus_determined_version_assignments_in_prologue_v2: bool,
731
732 #[serde(skip_serializing_if = "is_false")]
734 fresh_vm_on_framework_upgrade: bool,
735
736 #[serde(skip_serializing_if = "is_false")]
744 prepend_prologue_tx_in_consensus_commit_in_checkpoints: bool,
745
746 #[serde(skip_serializing_if = "Option::is_none")]
748 mysticeti_num_leaders_per_round: Option<usize>,
749
750 #[serde(skip_serializing_if = "is_false")]
752 soft_bundle: bool,
753
754 #[serde(skip_serializing_if = "is_false")]
756 enable_coin_deny_list_v2: bool,
757
758 #[serde(skip_serializing_if = "is_false")]
760 passkey_auth: bool,
761
762 #[serde(skip_serializing_if = "is_false")]
764 authority_capabilities_v2: bool,
765
766 #[serde(skip_serializing_if = "is_false")]
768 rethrow_serialization_type_layout_errors: bool,
769
770 #[serde(skip_serializing_if = "is_false")]
772 consensus_distributed_vote_scoring_strategy: bool,
773
774 #[serde(skip_serializing_if = "is_false")]
776 consensus_round_prober: bool,
777
778 #[serde(skip_serializing_if = "is_false")]
780 validate_identifier_inputs: bool,
781
782 #[serde(skip_serializing_if = "is_false")]
784 disallow_self_identifier: bool,
785
786 #[serde(skip_serializing_if = "is_false")]
788 mysticeti_fastpath: bool,
789
790 #[serde(skip_serializing_if = "is_false")]
794 disable_preconsensus_locking: bool,
795
796 #[serde(skip_serializing_if = "is_false")]
798 relocate_event_module: bool,
799
800 #[serde(skip_serializing_if = "is_false")]
802 uncompressed_g1_group_elements: bool,
803
804 #[serde(skip_serializing_if = "is_false")]
805 disallow_new_modules_in_deps_only_packages: bool,
806
807 #[serde(skip_serializing_if = "is_false")]
809 consensus_smart_ancestor_selection: bool,
810
811 #[serde(skip_serializing_if = "is_false")]
813 consensus_round_prober_probe_accepted_rounds: bool,
814
815 #[serde(skip_serializing_if = "is_false")]
817 native_charging_v2: bool,
818
819 #[serde(skip_serializing_if = "is_false")]
822 #[skip_protocol_config_accessor]
823 consensus_linearize_subdag_v2: bool,
824
825 #[serde(skip_serializing_if = "is_false")]
827 convert_type_argument_error: bool,
828
829 #[serde(skip_serializing_if = "is_false")]
831 variant_nodes: bool,
832
833 #[serde(skip_serializing_if = "is_false")]
835 consensus_zstd_compression: bool,
836
837 #[serde(skip_serializing_if = "is_false")]
839 minimize_child_object_mutations: bool,
840
841 #[serde(skip_serializing_if = "is_false")]
844 record_additional_state_digest_in_prologue: bool,
845
846 #[serde(skip_serializing_if = "is_false")]
848 move_native_context: bool,
849
850 #[serde(skip_serializing_if = "is_false")]
853 #[skip_protocol_config_accessor]
854 consensus_median_based_commit_timestamp: bool,
855
856 #[serde(skip_serializing_if = "is_false")]
859 normalize_ptb_arguments: bool,
860
861 #[serde(skip_serializing_if = "is_false")]
863 consensus_batched_block_sync: bool,
864
865 #[serde(skip_serializing_if = "is_false")]
867 enforce_checkpoint_timestamp_monotonicity: bool,
868
869 #[serde(skip_serializing_if = "is_false")]
871 max_ptb_value_size_v2: bool,
872
873 #[serde(skip_serializing_if = "is_false")]
875 resolve_type_input_ids_to_defining_id: bool,
876
877 #[serde(skip_serializing_if = "is_false")]
879 enable_party_transfer: bool,
880
881 #[serde(skip_serializing_if = "is_false")]
883 allow_unbounded_system_objects: bool,
884
885 #[serde(skip_serializing_if = "is_false")]
887 type_tags_in_object_runtime: bool,
888
889 #[serde(skip_serializing_if = "is_false")]
891 enable_accumulators: bool,
892
893 #[serde(skip_serializing_if = "is_false")]
895 #[skip_protocol_config_accessor]
896 enable_coin_reservation_obj_refs: bool,
897
898 #[serde(skip_serializing_if = "is_false")]
901 create_root_accumulator_object: bool,
902
903 #[serde(skip_serializing_if = "is_false")]
905 #[skip_protocol_config_accessor]
906 enable_authenticated_event_streams: bool,
907
908 #[serde(skip_serializing_if = "is_false")]
910 enable_address_balance_gas_payments: bool,
911
912 #[serde(skip_serializing_if = "is_false")]
914 address_balance_gas_check_rgp_at_signing: bool,
915
916 #[serde(skip_serializing_if = "is_false")]
917 address_balance_gas_reject_gas_coin_arg: bool,
918
919 #[serde(skip_serializing_if = "is_false")]
921 enable_multi_epoch_transaction_expiration: bool,
922
923 #[serde(skip_serializing_if = "is_false")]
925 relax_valid_during_for_owned_inputs: bool,
926
927 #[serde(skip_serializing_if = "is_false")]
929 enable_ptb_execution_v2: bool,
930
931 #[serde(skip_serializing_if = "is_false")]
933 better_adapter_type_resolution_errors: bool,
934
935 #[serde(skip_serializing_if = "is_false")]
937 record_time_estimate_processed: bool,
938
939 #[serde(skip_serializing_if = "is_false")]
941 dependency_linkage_error: bool,
942
943 #[serde(skip_serializing_if = "is_false")]
945 additional_multisig_checks: bool,
946
947 #[serde(skip_serializing_if = "is_false")]
949 ignore_execution_time_observations_after_certs_closed: bool,
950
951 #[serde(skip_serializing_if = "is_false")]
955 debug_fatal_on_move_invariant_violation: bool,
956
957 #[serde(skip_serializing_if = "is_false")]
960 allow_private_accumulator_entrypoints: bool,
961
962 #[serde(skip_serializing_if = "is_false")]
965 additional_consensus_digest_indirect_state: bool,
966
967 #[serde(skip_serializing_if = "is_false")]
969 check_for_init_during_upgrade: bool,
970
971 #[serde(skip_serializing_if = "is_false")]
973 enable_init_on_upgrade: bool,
974
975 #[serde(skip_serializing_if = "is_false")]
977 per_command_shared_object_transfer_rules: bool,
978
979 #[serde(skip_serializing_if = "is_false")]
981 include_checkpoint_artifacts_digest_in_summary: bool,
982
983 #[serde(skip_serializing_if = "is_false")]
985 use_mfp_txns_in_load_initial_object_debts: bool,
986
987 #[serde(skip_serializing_if = "is_false")]
989 cancel_for_failed_dkg_early: bool,
990
991 #[serde(skip_serializing_if = "is_false")]
993 always_advance_dkg_to_resolution: bool,
994
995 #[serde(skip_serializing_if = "is_false")]
997 enable_coin_registry: bool,
998
999 #[serde(skip_serializing_if = "is_false")]
1001 abstract_size_in_object_runtime: bool,
1002
1003 #[serde(skip_serializing_if = "is_false")]
1005 object_runtime_charge_cache_load_gas: bool,
1006
1007 #[serde(skip_serializing_if = "is_false")]
1009 additional_borrow_checks: bool,
1010
1011 #[serde(skip_serializing_if = "is_false")]
1013 use_new_commit_handler: bool,
1014
1015 #[serde(skip_serializing_if = "is_false")]
1017 better_loader_errors: bool,
1018
1019 #[serde(skip_serializing_if = "is_false")]
1021 generate_df_type_layouts: bool,
1022
1023 #[serde(skip_serializing_if = "is_false")]
1025 allow_references_in_ptbs: bool,
1026
1027 #[serde(skip_serializing_if = "is_false")]
1034 framework_tx_context_mut_restrictions: bool,
1035
1036 #[serde(skip_serializing_if = "is_false")]
1038 enable_display_registry: bool,
1039
1040 #[serde(skip_serializing_if = "is_false")]
1042 private_generics_verifier_v2: bool,
1043
1044 #[serde(skip_serializing_if = "is_false")]
1046 deprecate_global_storage_ops_during_deserialization: bool,
1047
1048 #[serde(skip_serializing_if = "is_false")]
1051 enable_non_exclusive_writes: bool,
1052
1053 #[serde(skip_serializing_if = "is_false")]
1055 deprecate_global_storage_ops: bool,
1056
1057 #[serde(skip_serializing_if = "is_false")]
1059 normalize_depth_formula: bool,
1060
1061 #[serde(skip_serializing_if = "is_false")]
1063 consensus_skip_gced_accept_votes: bool,
1064
1065 #[serde(skip_serializing_if = "is_false")]
1068 include_cancelled_randomness_txns_in_prologue: bool,
1069
1070 #[serde(skip_serializing_if = "is_false")]
1072 #[skip_protocol_config_accessor]
1073 address_aliases: bool,
1074
1075 #[serde(skip_serializing_if = "is_false")]
1077 create_forwarding_address_registry: bool,
1078
1079 #[serde(skip_serializing_if = "is_false")]
1082 fix_checkpoint_signature_mapping: bool,
1083
1084 #[serde(skip_serializing_if = "is_false")]
1086 enable_object_funds_withdraw: bool,
1087
1088 #[serde(skip_serializing_if = "is_false")]
1091 record_net_unsettled_object_withdraws: bool,
1092
1093 #[serde(skip_serializing_if = "is_false")]
1095 consensus_skip_gced_blocks_in_direct_finalization: bool,
1096
1097 #[serde(skip_serializing_if = "is_false")]
1099 gas_rounding_halve_digits: bool,
1100
1101 #[serde(skip_serializing_if = "is_false")]
1103 flexible_tx_context_positions: bool,
1104
1105 #[serde(skip_serializing_if = "is_false")]
1107 disable_entry_point_signature_check: bool,
1108
1109 #[serde(skip_serializing_if = "is_false")]
1111 convert_withdrawal_compatibility_ptb_arguments: bool,
1112
1113 #[serde(skip_serializing_if = "is_false")]
1115 restrict_hot_or_not_entry_functions: bool,
1116
1117 #[serde(skip_serializing_if = "is_false")]
1119 split_checkpoints_in_consensus_handler: bool,
1120
1121 #[serde(skip_serializing_if = "is_false")]
1123 consensus_always_accept_system_transactions: bool,
1124
1125 #[serde(skip_serializing_if = "is_false")]
1127 validator_metadata_verify_v2: bool,
1128
1129 #[serde(skip_serializing_if = "is_false")]
1132 defer_unpaid_amplification: bool,
1133
1134 #[serde(skip_serializing_if = "is_false")]
1137 defer_owned_object_double_spend: bool,
1138
1139 #[serde(skip_serializing_if = "is_false")]
1140 randomize_checkpoint_tx_limit_in_tests: bool,
1141
1142 #[serde(skip_serializing_if = "is_false")]
1144 gasless_transaction_drop_safety: bool,
1145
1146 #[serde(skip_serializing_if = "is_false")]
1149 merge_randomness_into_checkpoint: bool,
1150
1151 #[serde(skip_serializing_if = "is_false")]
1153 use_coin_party_owner: bool,
1154
1155 #[serde(skip_serializing_if = "is_false")]
1156 enable_gasless: bool,
1157
1158 #[serde(skip_serializing_if = "is_false")]
1159 gasless_verify_remaining_balance: bool,
1160
1161 #[serde(skip_serializing_if = "is_false")]
1162 disallow_jump_orphans: bool,
1163
1164 #[serde(skip_serializing_if = "is_false")]
1166 early_return_receive_object_mismatched_type: bool,
1167
1168 #[serde(skip_serializing_if = "is_false")]
1173 timestamp_based_epoch_close: bool,
1174
1175 #[serde(skip_serializing_if = "is_false")]
1178 limit_groth16_pvk_inputs: bool,
1179
1180 #[serde(skip_serializing_if = "is_false")]
1185 enforce_address_balance_change_invariant: bool,
1186
1187 #[serde(skip_serializing_if = "is_false")]
1189 share_transaction_deny_config_in_consensus: bool,
1190
1191 #[serde(skip_serializing_if = "is_false")]
1193 granular_post_execution_checks: bool,
1194
1195 #[serde(skip_serializing_if = "is_false")]
1197 early_exit_on_iffw: bool,
1198
1199 #[serde(skip_serializing_if = "is_false")]
1201 enable_unified_linkage: bool,
1202}
1203
1204fn is_false(b: &bool) -> bool {
1205 !b
1206}
1207
1208fn is_empty(b: &BTreeSet<String>) -> bool {
1209 b.is_empty()
1210}
1211
1212fn is_zero(val: &u64) -> bool {
1213 *val == 0
1214}
1215
1216#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1218pub enum ConsensusTransactionOrdering {
1219 #[default]
1221 None,
1222 ByGasPrice,
1224}
1225
1226impl ConsensusTransactionOrdering {
1227 pub fn is_none(&self) -> bool {
1228 matches!(self, ConsensusTransactionOrdering::None)
1229 }
1230}
1231
1232#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1233pub struct ExecutionTimeEstimateParams {
1234 pub target_utilization: u64,
1236 pub allowed_txn_cost_overage_burst_limit_us: u64,
1240
1241 pub randomness_scalar: u64,
1244
1245 pub max_estimate_us: u64,
1247
1248 pub stored_observations_num_included_checkpoints: u64,
1251
1252 pub stored_observations_limit: u64,
1254
1255 #[serde(skip_serializing_if = "is_zero")]
1258 pub stake_weighted_median_threshold: u64,
1259
1260 #[serde(skip_serializing_if = "is_false")]
1264 pub default_none_duration_for_new_keys: bool,
1265
1266 #[serde(skip_serializing_if = "Option::is_none")]
1268 pub observations_chunk_size: Option<u64>,
1269}
1270
1271#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1273pub enum PerObjectCongestionControlMode {
1274 #[default]
1275 None, TotalGasBudget, TotalTxCount, TotalGasBudgetWithCap, ExecutionTimeEstimate(ExecutionTimeEstimateParams), }
1281
1282impl PerObjectCongestionControlMode {
1283 pub fn is_none(&self) -> bool {
1284 matches!(self, PerObjectCongestionControlMode::None)
1285 }
1286}
1287
1288#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1290pub enum ConsensusChoice {
1291 #[default]
1292 Narwhal,
1293 SwapEachEpoch,
1294 Mysticeti,
1295}
1296
1297impl ConsensusChoice {
1298 pub fn is_narwhal(&self) -> bool {
1299 matches!(self, ConsensusChoice::Narwhal)
1300 }
1301}
1302
1303#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1305pub enum ConsensusNetwork {
1306 #[default]
1307 Anemo,
1308 Tonic,
1309}
1310
1311impl ConsensusNetwork {
1312 pub fn is_anemo(&self) -> bool {
1313 matches!(self, ConsensusNetwork::Anemo)
1314 }
1315}
1316
1317#[skip_serializing_none]
1349#[derive(Clone, Serialize, Debug, ProtocolConfigAccessors, ProtocolConfigOverride)]
1350pub struct ProtocolConfig {
1351 pub version: ProtocolVersion,
1352
1353 #[serde(skip)]
1358 chain: Chain,
1359
1360 feature_flags: FeatureFlags,
1361
1362 max_tx_size_bytes: Option<u64>,
1365
1366 max_input_objects: Option<u64>,
1368
1369 max_size_written_objects: Option<u64>,
1373 max_size_written_objects_system_tx: Option<u64>,
1376
1377 max_serialized_tx_effects_size_bytes: Option<u64>,
1379
1380 max_serialized_tx_effects_size_bytes_system_tx: Option<u64>,
1382
1383 max_gas_payment_objects: Option<u32>,
1385
1386 max_modules_in_publish: Option<u32>,
1388
1389 max_package_dependencies: Option<u32>,
1391
1392 max_arguments: Option<u32>,
1395
1396 max_type_arguments: Option<u32>,
1398
1399 max_type_argument_depth: Option<u32>,
1401
1402 max_pure_argument_size: Option<u32>,
1404
1405 max_programmable_tx_commands: Option<u32>,
1407
1408 move_binary_format_version: Option<u32>,
1411 min_move_binary_format_version: Option<u32>,
1412
1413 binary_module_handles: Option<u16>,
1415 binary_struct_handles: Option<u16>,
1416 binary_function_handles: Option<u16>,
1417 binary_function_instantiations: Option<u16>,
1418 binary_signatures: Option<u16>,
1419 binary_constant_pool: Option<u16>,
1420 binary_identifiers: Option<u16>,
1421 binary_address_identifiers: Option<u16>,
1422 binary_struct_defs: Option<u16>,
1423 binary_struct_def_instantiations: Option<u16>,
1424 binary_function_defs: Option<u16>,
1425 binary_field_handles: Option<u16>,
1426 binary_field_instantiations: Option<u16>,
1427 binary_friend_decls: Option<u16>,
1428 binary_enum_defs: Option<u16>,
1429 binary_enum_def_instantiations: Option<u16>,
1430 binary_variant_handles: Option<u16>,
1431 binary_variant_instantiation_handles: Option<u16>,
1432
1433 max_move_object_size: Option<u64>,
1435
1436 max_move_package_size: Option<u64>,
1439
1440 max_publish_or_upgrade_per_ptb: Option<u64>,
1442
1443 max_tx_gas: Option<u64>,
1445
1446 max_gas_price: Option<u64>,
1448
1449 max_gas_price_rgp_factor_for_aborted_transactions: Option<u64>,
1452
1453 max_gas_computation_bucket: Option<u64>,
1455
1456 gas_rounding_step: Option<u64>,
1458
1459 max_loop_depth: Option<u64>,
1461
1462 max_generic_instantiation_length: Option<u64>,
1464
1465 max_function_parameters: Option<u64>,
1467
1468 max_basic_blocks: Option<u64>,
1470
1471 max_value_stack_size: Option<u64>,
1473
1474 max_type_nodes: Option<u64>,
1476
1477 max_generic_instantiation_type_nodes_per_function: Option<u64>,
1479
1480 max_generic_instantiation_type_nodes_per_module: Option<u64>,
1482
1483 max_push_size: Option<u64>,
1485
1486 max_struct_definitions: Option<u64>,
1488
1489 max_function_definitions: Option<u64>,
1491
1492 max_fields_in_struct: Option<u64>,
1494
1495 max_dependency_depth: Option<u64>,
1497
1498 max_num_event_emit: Option<u64>,
1500
1501 max_num_new_move_object_ids: Option<u64>,
1503
1504 max_num_new_move_object_ids_system_tx: Option<u64>,
1506
1507 max_num_deleted_move_object_ids: Option<u64>,
1509
1510 max_num_deleted_move_object_ids_system_tx: Option<u64>,
1512
1513 max_num_transferred_move_object_ids: Option<u64>,
1515
1516 max_num_transferred_move_object_ids_system_tx: Option<u64>,
1518
1519 max_event_emit_size: Option<u64>,
1521
1522 max_event_emit_size_total: Option<u64>,
1524
1525 max_move_vector_len: Option<u64>,
1527
1528 max_move_identifier_len: Option<u64>,
1530
1531 max_move_value_depth: Option<u64>,
1533
1534 max_move_enum_variants: Option<u64>,
1536
1537 max_back_edges_per_function: Option<u64>,
1539
1540 max_back_edges_per_module: Option<u64>,
1542
1543 max_verifier_meter_ticks_per_function: Option<u64>,
1545
1546 max_meter_ticks_per_module: Option<u64>,
1548
1549 max_meter_ticks_per_package: Option<u64>,
1551
1552 object_runtime_max_num_cached_objects: Option<u64>,
1556
1557 object_runtime_max_num_cached_objects_system_tx: Option<u64>,
1559
1560 object_runtime_max_num_store_entries: Option<u64>,
1562
1563 object_runtime_max_num_store_entries_system_tx: Option<u64>,
1565
1566 base_tx_cost_fixed: Option<u64>,
1569
1570 package_publish_cost_fixed: Option<u64>,
1573
1574 base_tx_cost_per_byte: Option<u64>,
1577
1578 package_publish_cost_per_byte: Option<u64>,
1580
1581 obj_access_cost_read_per_byte: Option<u64>,
1583
1584 obj_access_cost_mutate_per_byte: Option<u64>,
1586
1587 obj_access_cost_delete_per_byte: Option<u64>,
1589
1590 obj_access_cost_verify_per_byte: Option<u64>,
1600
1601 max_type_to_layout_nodes: Option<u64>,
1603
1604 max_ptb_value_size: Option<u64>,
1606
1607 gas_model_version: Option<u64>,
1610
1611 obj_data_cost_refundable: Option<u64>,
1614
1615 obj_metadata_cost_non_refundable: Option<u64>,
1619
1620 storage_rebate_rate: Option<u64>,
1626
1627 storage_fund_reinvest_rate: Option<u64>,
1630
1631 reward_slashing_rate: Option<u64>,
1634
1635 storage_gas_price: Option<u64>,
1637
1638 accumulator_object_storage_cost: Option<u64>,
1640
1641 max_transactions_per_checkpoint: Option<u64>,
1646
1647 max_checkpoint_size_bytes: Option<u64>,
1651
1652 buffer_stake_for_protocol_upgrade_bps: Option<u64>,
1657
1658 address_from_bytes_cost_base: Option<u64>,
1663 address_to_u256_cost_base: Option<u64>,
1665 address_from_u256_cost_base: Option<u64>,
1667
1668 config_read_setting_impl_cost_base: Option<u64>,
1673 config_read_setting_impl_cost_per_byte: Option<u64>,
1674
1675 dynamic_field_hash_type_and_key_cost_base: Option<u64>,
1678 dynamic_field_hash_type_and_key_type_cost_per_byte: Option<u64>,
1679 dynamic_field_hash_type_and_key_value_cost_per_byte: Option<u64>,
1680 dynamic_field_hash_type_and_key_type_tag_cost_per_byte: Option<u64>,
1681 dynamic_field_add_child_object_cost_base: Option<u64>,
1683 dynamic_field_add_child_object_type_cost_per_byte: Option<u64>,
1684 dynamic_field_add_child_object_value_cost_per_byte: Option<u64>,
1685 dynamic_field_add_child_object_struct_tag_cost_per_byte: Option<u64>,
1686 dynamic_field_borrow_child_object_cost_base: Option<u64>,
1688 dynamic_field_borrow_child_object_child_ref_cost_per_byte: Option<u64>,
1689 dynamic_field_borrow_child_object_type_cost_per_byte: Option<u64>,
1690 dynamic_field_remove_child_object_cost_base: Option<u64>,
1692 dynamic_field_remove_child_object_child_cost_per_byte: Option<u64>,
1693 dynamic_field_remove_child_object_type_cost_per_byte: Option<u64>,
1694 dynamic_field_has_child_object_cost_base: Option<u64>,
1696 dynamic_field_has_child_object_with_ty_cost_base: Option<u64>,
1698 dynamic_field_has_child_object_with_ty_type_cost_per_byte: Option<u64>,
1699 dynamic_field_has_child_object_with_ty_type_tag_cost_per_byte: Option<u64>,
1700
1701 scratch_add_cost_base: Option<u64>,
1704 scratch_read_cost_base: Option<u64>,
1706 scratch_read_value_cost: Option<u64>,
1707 scratch_remove_cost_base: Option<u64>,
1709 scratch_exists_cost_base: Option<u64>,
1711 scratch_exists_with_type_cost_base: Option<u64>,
1713 scratch_exists_with_type_type_cost: Option<u64>,
1714 max_scratch_pad_size: Option<u64>,
1716
1717 event_emit_cost_base: Option<u64>,
1720 event_emit_value_size_derivation_cost_per_byte: Option<u64>,
1721 event_emit_tag_size_derivation_cost_per_byte: Option<u64>,
1722 event_emit_output_cost_per_byte: Option<u64>,
1723 event_emit_auth_stream_cost: Option<u64>,
1724
1725 object_borrow_uid_cost_base: Option<u64>,
1728 object_delete_impl_cost_base: Option<u64>,
1730 object_record_new_uid_cost_base: Option<u64>,
1732 object_record_new_uid_from_hash_cost_base: Option<u64>,
1735
1736 transfer_transfer_internal_cost_base: Option<u64>,
1739 transfer_party_transfer_internal_cost_base: Option<u64>,
1741 transfer_freeze_object_cost_base: Option<u64>,
1743 transfer_share_object_cost_base: Option<u64>,
1745 transfer_receive_object_cost_base: Option<u64>,
1748 transfer_receive_object_cost_per_byte: Option<u64>,
1749 transfer_receive_object_type_cost_per_byte: Option<u64>,
1750
1751 tx_context_derive_id_cost_base: Option<u64>,
1754 tx_context_fresh_id_cost_base: Option<u64>,
1755 tx_context_sender_cost_base: Option<u64>,
1756 tx_context_epoch_cost_base: Option<u64>,
1757 tx_context_epoch_timestamp_ms_cost_base: Option<u64>,
1758 tx_context_sponsor_cost_base: Option<u64>,
1759 tx_context_rgp_cost_base: Option<u64>,
1760 tx_context_gas_price_cost_base: Option<u64>,
1761 tx_context_gas_budget_cost_base: Option<u64>,
1762 tx_context_ids_created_cost_base: Option<u64>,
1763 tx_context_replace_cost_base: Option<u64>,
1764
1765 types_is_one_time_witness_cost_base: Option<u64>,
1768 types_is_one_time_witness_type_tag_cost_per_byte: Option<u64>,
1769 types_is_one_time_witness_type_cost_per_byte: Option<u64>,
1770
1771 validator_validate_metadata_cost_base: Option<u64>,
1774 validator_validate_metadata_data_cost_per_byte: Option<u64>,
1775
1776 crypto_invalid_arguments_cost: Option<u64>,
1778 bls12381_bls12381_min_sig_verify_cost_base: Option<u64>,
1780 bls12381_bls12381_min_sig_verify_msg_cost_per_byte: Option<u64>,
1781 bls12381_bls12381_min_sig_verify_msg_cost_per_block: Option<u64>,
1782
1783 bls12381_bls12381_min_pk_verify_cost_base: Option<u64>,
1785 bls12381_bls12381_min_pk_verify_msg_cost_per_byte: Option<u64>,
1786 bls12381_bls12381_min_pk_verify_msg_cost_per_block: Option<u64>,
1787
1788 ecdsa_k1_ecrecover_keccak256_cost_base: Option<u64>,
1790 ecdsa_k1_ecrecover_keccak256_msg_cost_per_byte: Option<u64>,
1791 ecdsa_k1_ecrecover_keccak256_msg_cost_per_block: Option<u64>,
1792 ecdsa_k1_ecrecover_sha256_cost_base: Option<u64>,
1793 ecdsa_k1_ecrecover_sha256_msg_cost_per_byte: Option<u64>,
1794 ecdsa_k1_ecrecover_sha256_msg_cost_per_block: Option<u64>,
1795
1796 ecdsa_k1_decompress_pubkey_cost_base: Option<u64>,
1798
1799 ecdsa_k1_secp256k1_verify_keccak256_cost_base: Option<u64>,
1801 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_byte: Option<u64>,
1802 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_block: Option<u64>,
1803 ecdsa_k1_secp256k1_verify_sha256_cost_base: Option<u64>,
1804 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_byte: Option<u64>,
1805 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_block: Option<u64>,
1806
1807 ecdsa_r1_ecrecover_keccak256_cost_base: Option<u64>,
1809 ecdsa_r1_ecrecover_keccak256_msg_cost_per_byte: Option<u64>,
1810 ecdsa_r1_ecrecover_keccak256_msg_cost_per_block: Option<u64>,
1811 ecdsa_r1_ecrecover_sha256_cost_base: Option<u64>,
1812 ecdsa_r1_ecrecover_sha256_msg_cost_per_byte: Option<u64>,
1813 ecdsa_r1_ecrecover_sha256_msg_cost_per_block: Option<u64>,
1814
1815 ecdsa_r1_secp256r1_verify_keccak256_cost_base: Option<u64>,
1817 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_byte: Option<u64>,
1818 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_block: Option<u64>,
1819 ecdsa_r1_secp256r1_verify_sha256_cost_base: Option<u64>,
1820 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_byte: Option<u64>,
1821 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_block: Option<u64>,
1822
1823 ecvrf_ecvrf_verify_cost_base: Option<u64>,
1825 ecvrf_ecvrf_verify_alpha_string_cost_per_byte: Option<u64>,
1826 ecvrf_ecvrf_verify_alpha_string_cost_per_block: Option<u64>,
1827
1828 ed25519_ed25519_verify_cost_base: Option<u64>,
1830 ed25519_ed25519_verify_msg_cost_per_byte: Option<u64>,
1831 ed25519_ed25519_verify_msg_cost_per_block: Option<u64>,
1832
1833 groth16_prepare_verifying_key_bls12381_cost_base: Option<u64>,
1835 groth16_prepare_verifying_key_bn254_cost_base: Option<u64>,
1836
1837 groth16_verify_groth16_proof_internal_bls12381_cost_base: Option<u64>,
1839 groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input: Option<u64>,
1840 groth16_verify_groth16_proof_internal_bn254_cost_base: Option<u64>,
1841 groth16_verify_groth16_proof_internal_bn254_cost_per_public_input: Option<u64>,
1842 groth16_verify_groth16_proof_internal_public_input_cost_per_byte: Option<u64>,
1843
1844 hash_blake2b256_cost_base: Option<u64>,
1846 hash_blake2b256_data_cost_per_byte: Option<u64>,
1847 hash_blake2b256_data_cost_per_block: Option<u64>,
1848
1849 hash_keccak256_cost_base: Option<u64>,
1851 hash_keccak256_data_cost_per_byte: Option<u64>,
1852 hash_keccak256_data_cost_per_block: Option<u64>,
1853
1854 poseidon_bn254_cost_base: Option<u64>,
1856 poseidon_bn254_cost_per_block: Option<u64>,
1857
1858 group_ops_bls12381_decode_scalar_cost: Option<u64>,
1860 group_ops_bls12381_decode_g1_cost: Option<u64>,
1861 group_ops_bls12381_decode_g2_cost: Option<u64>,
1862 group_ops_bls12381_decode_gt_cost: Option<u64>,
1863 group_ops_bls12381_scalar_add_cost: Option<u64>,
1864 group_ops_bls12381_g1_add_cost: Option<u64>,
1865 group_ops_bls12381_g2_add_cost: Option<u64>,
1866 group_ops_bls12381_gt_add_cost: Option<u64>,
1867 group_ops_bls12381_scalar_sub_cost: Option<u64>,
1868 group_ops_bls12381_g1_sub_cost: Option<u64>,
1869 group_ops_bls12381_g2_sub_cost: Option<u64>,
1870 group_ops_bls12381_gt_sub_cost: Option<u64>,
1871 group_ops_bls12381_scalar_mul_cost: Option<u64>,
1872 group_ops_bls12381_g1_mul_cost: Option<u64>,
1873 group_ops_bls12381_g2_mul_cost: Option<u64>,
1874 group_ops_bls12381_gt_mul_cost: Option<u64>,
1875 group_ops_bls12381_scalar_div_cost: Option<u64>,
1876 group_ops_bls12381_g1_div_cost: Option<u64>,
1877 group_ops_bls12381_g2_div_cost: Option<u64>,
1878 group_ops_bls12381_gt_div_cost: Option<u64>,
1879 group_ops_bls12381_g1_hash_to_base_cost: Option<u64>,
1880 group_ops_bls12381_g2_hash_to_base_cost: Option<u64>,
1881 group_ops_bls12381_g1_hash_to_cost_per_byte: Option<u64>,
1882 group_ops_bls12381_g2_hash_to_cost_per_byte: Option<u64>,
1883 group_ops_bls12381_g1_msm_base_cost: Option<u64>,
1884 group_ops_bls12381_g2_msm_base_cost: Option<u64>,
1885 group_ops_bls12381_g1_msm_base_cost_per_input: Option<u64>,
1886 group_ops_bls12381_g2_msm_base_cost_per_input: Option<u64>,
1887 group_ops_bls12381_msm_max_len: Option<u32>,
1888 group_ops_bls12381_pairing_cost: Option<u64>,
1889 group_ops_bls12381_g1_to_uncompressed_g1_cost: Option<u64>,
1890 group_ops_bls12381_uncompressed_g1_to_g1_cost: Option<u64>,
1891 group_ops_bls12381_uncompressed_g1_sum_base_cost: Option<u64>,
1892 group_ops_bls12381_uncompressed_g1_sum_cost_per_term: Option<u64>,
1893 group_ops_bls12381_uncompressed_g1_sum_max_terms: Option<u64>,
1894
1895 group_ops_ristretto_decode_scalar_cost: Option<u64>,
1896 group_ops_ristretto_decode_point_cost: Option<u64>,
1897 group_ops_ristretto_scalar_add_cost: Option<u64>,
1898 group_ops_ristretto_point_add_cost: Option<u64>,
1899 group_ops_ristretto_scalar_sub_cost: Option<u64>,
1900 group_ops_ristretto_point_sub_cost: Option<u64>,
1901 group_ops_ristretto_scalar_mul_cost: Option<u64>,
1902 group_ops_ristretto_point_mul_cost: Option<u64>,
1903 group_ops_ristretto_scalar_div_cost: Option<u64>,
1904 group_ops_ristretto_point_div_cost: Option<u64>,
1905
1906 verify_bulletproofs_ristretto255_base_cost: Option<u64>,
1907 verify_bulletproofs_ristretto255_cost_per_bit_and_commitment: Option<u64>,
1908
1909 hmac_hmac_sha3_256_cost_base: Option<u64>,
1911 hmac_hmac_sha3_256_input_cost_per_byte: Option<u64>,
1912 hmac_hmac_sha3_256_input_cost_per_block: Option<u64>,
1913
1914 check_zklogin_id_cost_base: Option<u64>,
1916 check_zklogin_issuer_cost_base: Option<u64>,
1918
1919 vdf_verify_vdf_cost: Option<u64>,
1920 vdf_hash_to_input_cost: Option<u64>,
1921
1922 nitro_attestation_parse_base_cost: Option<u64>,
1924 nitro_attestation_parse_cost_per_byte: Option<u64>,
1925 nitro_attestation_verify_base_cost: Option<u64>,
1926 nitro_attestation_verify_cost_per_cert: Option<u64>,
1927
1928 bcs_per_byte_serialized_cost: Option<u64>,
1930 bcs_legacy_min_output_size_cost: Option<u64>,
1931 bcs_failure_cost: Option<u64>,
1932
1933 hash_sha2_256_base_cost: Option<u64>,
1934 hash_sha2_256_per_byte_cost: Option<u64>,
1935 hash_sha2_256_legacy_min_input_len_cost: Option<u64>,
1936 hash_sha3_256_base_cost: Option<u64>,
1937 hash_sha3_256_per_byte_cost: Option<u64>,
1938 hash_sha3_256_legacy_min_input_len_cost: Option<u64>,
1939 type_name_get_base_cost: Option<u64>,
1940 type_name_get_per_byte_cost: Option<u64>,
1941 type_name_id_base_cost: Option<u64>,
1942
1943 string_check_utf8_base_cost: Option<u64>,
1944 string_check_utf8_per_byte_cost: Option<u64>,
1945 string_is_char_boundary_base_cost: Option<u64>,
1946 string_sub_string_base_cost: Option<u64>,
1947 string_sub_string_per_byte_cost: Option<u64>,
1948 string_index_of_base_cost: Option<u64>,
1949 string_index_of_per_byte_pattern_cost: Option<u64>,
1950 string_index_of_per_byte_searched_cost: Option<u64>,
1951
1952 vector_empty_base_cost: Option<u64>,
1953 vector_length_base_cost: Option<u64>,
1954 vector_push_back_base_cost: Option<u64>,
1955 vector_push_back_legacy_per_abstract_memory_unit_cost: Option<u64>,
1956 vector_borrow_base_cost: Option<u64>,
1957 vector_pop_back_base_cost: Option<u64>,
1958 vector_destroy_empty_base_cost: Option<u64>,
1959 vector_swap_base_cost: Option<u64>,
1960 debug_print_base_cost: Option<u64>,
1961 debug_print_stack_trace_base_cost: Option<u64>,
1962
1963 #[custom_setter]
1973 execution_version: Option<u64>,
1974
1975 consensus_bad_nodes_stake_threshold: Option<u64>,
1979
1980 max_jwk_votes_per_validator_per_epoch: Option<u64>,
1981 max_age_of_jwk_in_epochs: Option<u64>,
1985
1986 random_beacon_reduction_allowed_delta: Option<u16>,
1990
1991 random_beacon_reduction_lower_bound: Option<u32>,
1994
1995 random_beacon_dkg_timeout_round: Option<u32>,
1998
1999 random_beacon_min_round_interval_ms: Option<u64>,
2001
2002 random_beacon_dkg_version: Option<u64>,
2005
2006 consensus_max_transaction_size_bytes: Option<u64>,
2009 consensus_max_transactions_in_block_bytes: Option<u64>,
2011 consensus_max_num_transactions_in_block: Option<u64>,
2013
2014 consensus_voting_rounds: Option<u32>,
2016
2017 max_accumulated_txn_cost_per_object_in_narwhal_commit: Option<u64>,
2019
2020 max_deferral_rounds_for_congestion_control: Option<u64>,
2023
2024 epoch_close_deadline_ms: Option<u64>,
2029
2030 max_txn_cost_overage_per_object_in_commit: Option<u64>,
2032
2033 allowed_txn_cost_overage_burst_per_object_in_commit: Option<u64>,
2035
2036 min_checkpoint_interval_ms: Option<u64>,
2038
2039 checkpoint_summary_version_specific_data: Option<u64>,
2041
2042 max_soft_bundle_size: Option<u64>,
2044
2045 bridge_should_try_to_finalize_committee: Option<bool>,
2049
2050 max_accumulated_txn_cost_per_object_in_mysticeti_commit: Option<u64>,
2056
2057 max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit: Option<u64>,
2060
2061 consensus_gc_depth: Option<u32>,
2064
2065 gas_budget_based_txn_cost_cap_factor: Option<u64>,
2067
2068 gas_budget_based_txn_cost_absolute_cap_commit_count: Option<u64>,
2070
2071 sip_45_consensus_amplification_threshold: Option<u64>,
2074
2075 use_object_per_epoch_marker_table_v2: Option<bool>,
2078
2079 consensus_commit_rate_estimation_window_size: Option<u32>,
2081
2082 #[serde(skip_serializing_if = "Vec::is_empty")]
2086 aliased_addresses: Vec<AliasedAddress>,
2087
2088 translation_per_command_base_charge: Option<u64>,
2091
2092 translation_per_input_base_charge: Option<u64>,
2095
2096 translation_pure_input_per_byte_charge: Option<u64>,
2098
2099 translation_per_type_node_charge: Option<u64>,
2103
2104 translation_per_reference_node_charge: Option<u64>,
2107
2108 translation_per_linkage_entry_charge: Option<u64>,
2111
2112 max_updates_per_settlement_txn: Option<u32>,
2114
2115 gasless_max_computation_units: Option<u64>,
2117
2118 gasless_allowed_token_types: Option<Vec<(String, u64)>>,
2120
2121 gasless_max_unused_inputs: Option<u64>,
2125
2126 gasless_max_pure_input_bytes: Option<u64>,
2129
2130 gasless_max_tps: Option<u64>,
2132
2133 #[serde(skip_serializing_if = "Option::is_none")]
2134 #[skip_accessor]
2135 include_special_package_amendments: Option<Arc<Amendments>>,
2136
2137 gasless_max_tx_size_bytes: Option<u64>,
2140}
2141
2142#[derive(Clone, Serialize, Deserialize, Debug)]
2144pub struct AliasedAddress {
2145 pub original: [u8; 32],
2147 pub aliased: [u8; 32],
2149 pub allowed_tx_digests: Vec<[u8; 32]>,
2151}
2152
2153impl ProtocolConfig {
2155 pub fn chain(&self) -> Chain {
2157 self.chain
2158 }
2159
2160 pub fn check_package_upgrades_supported(&self) -> Result<(), Error> {
2173 if self.feature_flags.package_upgrades {
2174 Ok(())
2175 } else {
2176 Err(Error(format!(
2177 "package upgrades are not supported at {:?}",
2178 self.version
2179 )))
2180 }
2181 }
2182
2183 pub fn zklogin_supported_providers(&self) -> &BTreeSet<String> {
2184 &self.feature_flags.zklogin_supported_providers
2185 }
2186
2187 pub fn zklogin_circuit_mode(&self) -> u64 {
2190 self.feature_flags.zklogin_circuit_mode
2191 }
2192
2193 pub fn consensus_transaction_ordering(&self) -> ConsensusTransactionOrdering {
2194 self.feature_flags.consensus_transaction_ordering
2195 }
2196
2197 pub fn enable_jwk_consensus_updates(&self) -> bool {
2198 let ret = self.feature_flags.enable_jwk_consensus_updates;
2199 if ret {
2200 assert!(self.feature_flags.end_of_epoch_transaction_supported);
2202 }
2203 ret
2204 }
2205
2206 pub fn end_of_epoch_transaction_supported(&self) -> bool {
2207 let ret = self.feature_flags.end_of_epoch_transaction_supported;
2208 if !ret {
2209 assert!(!self.feature_flags.enable_jwk_consensus_updates);
2211 }
2212 ret
2213 }
2214
2215 pub fn dkg_version(&self) -> u64 {
2216 self.random_beacon_dkg_version.unwrap_or(1)
2218 }
2219
2220 pub fn bridge(&self) -> bool {
2221 let ret = self.feature_flags.bridge;
2222 if ret {
2223 assert!(self.feature_flags.end_of_epoch_transaction_supported);
2225 }
2226 ret
2227 }
2228
2229 pub fn should_try_to_finalize_bridge_committee(&self) -> bool {
2230 if !self.bridge() {
2231 return false;
2232 }
2233 self.bridge_should_try_to_finalize_committee.unwrap_or(true)
2235 }
2236
2237 pub fn zklogin_max_epoch_upper_bound_delta(&self) -> Option<u64> {
2238 self.feature_flags.zklogin_max_epoch_upper_bound_delta
2239 }
2240
2241 pub fn enable_coin_reservation_obj_refs(&self) -> bool {
2242 self.new_vm_enabled() && self.feature_flags.enable_coin_reservation_obj_refs
2243 }
2244
2245 pub fn enable_authenticated_event_streams(&self) -> bool {
2246 self.feature_flags.enable_authenticated_event_streams && self.enable_accumulators()
2247 }
2248
2249 pub fn per_object_congestion_control_mode(&self) -> PerObjectCongestionControlMode {
2250 self.feature_flags.per_object_congestion_control_mode
2251 }
2252
2253 pub fn consensus_choice(&self) -> ConsensusChoice {
2254 self.feature_flags.consensus_choice
2255 }
2256
2257 pub fn consensus_network(&self) -> ConsensusNetwork {
2258 self.feature_flags.consensus_network
2259 }
2260
2261 pub fn mysticeti_num_leaders_per_round(&self) -> Option<usize> {
2262 self.feature_flags.mysticeti_num_leaders_per_round
2263 }
2264
2265 pub fn max_transaction_size_bytes(&self) -> u64 {
2266 self.consensus_max_transaction_size_bytes
2268 .unwrap_or(256 * 1024)
2269 }
2270
2271 pub fn max_transactions_in_block_bytes(&self) -> u64 {
2272 if cfg!(msim) {
2273 256 * 1024
2274 } else {
2275 self.consensus_max_transactions_in_block_bytes
2276 .unwrap_or(512 * 1024)
2277 }
2278 }
2279
2280 pub fn max_num_transactions_in_block(&self) -> u64 {
2281 if cfg!(msim) {
2282 8
2283 } else {
2284 self.consensus_max_num_transactions_in_block.unwrap_or(512)
2285 }
2286 }
2287
2288 pub fn gc_depth(&self) -> u32 {
2289 self.consensus_gc_depth.unwrap_or(0)
2290 }
2291
2292 pub fn consensus_linearize_subdag_v2(&self) -> bool {
2293 let res = self.feature_flags.consensus_linearize_subdag_v2;
2294 assert!(
2295 !res || self.gc_depth() > 0,
2296 "The consensus linearize sub dag V2 requires GC to be enabled"
2297 );
2298 res
2299 }
2300
2301 pub fn consensus_median_based_commit_timestamp(&self) -> bool {
2302 let res = self.feature_flags.consensus_median_based_commit_timestamp;
2303 assert!(
2304 !res || self.gc_depth() > 0,
2305 "The consensus median based commit timestamp requires GC to be enabled"
2306 );
2307 res
2308 }
2309
2310 pub fn get_consensus_commit_rate_estimation_window_size(&self) -> u32 {
2311 self.consensus_commit_rate_estimation_window_size
2312 .unwrap_or(0)
2313 }
2314
2315 pub fn consensus_num_requested_prior_commits_at_startup(&self) -> u32 {
2316 let window_size = self.get_consensus_commit_rate_estimation_window_size();
2320 assert!(window_size == 0 || self.record_additional_state_digest_in_prologue());
2322 window_size
2323 }
2324
2325 pub fn enable_observation_chunking(&self) -> bool {
2326 matches!(self.feature_flags.per_object_congestion_control_mode,
2327 PerObjectCongestionControlMode::ExecutionTimeEstimate(ref params)
2328 if params.observations_chunk_size.is_some()
2329 )
2330 }
2331
2332 pub fn address_aliases(&self) -> bool {
2333 let address_aliases = self.feature_flags.address_aliases;
2334 assert!(
2335 !address_aliases || self.mysticeti_fastpath(),
2336 "Address aliases requires Mysticeti fastpath to be enabled"
2337 );
2338 if address_aliases {
2339 assert!(
2340 self.feature_flags.disable_preconsensus_locking,
2341 "Address aliases requires CertifiedTransaction to be disabled"
2342 );
2343 }
2344 address_aliases
2345 }
2346
2347 pub fn new_vm_enabled(&self) -> bool {
2348 self.execution_version.is_some_and(|v| v >= 4)
2349 }
2350
2351 pub fn gasless_allowed_token_types(&self) -> &[(String, u64)] {
2352 debug_assert!(self.gasless_allowed_token_types.is_some());
2353 self.gasless_allowed_token_types.as_deref().unwrap_or(&[])
2354 }
2355
2356 pub fn get_gasless_max_unused_inputs(&self) -> u64 {
2357 self.gasless_max_unused_inputs.unwrap_or(u64::MAX)
2358 }
2359
2360 pub fn get_gasless_max_pure_input_bytes(&self) -> u64 {
2361 self.gasless_max_pure_input_bytes.unwrap_or(u64::MAX)
2362 }
2363
2364 pub fn get_gasless_max_tx_size_bytes(&self) -> u64 {
2365 self.gasless_max_tx_size_bytes.unwrap_or(u64::MAX)
2366 }
2367
2368 pub fn include_special_package_amendments_as_option(&self) -> &Option<Arc<Amendments>> {
2369 &self.include_special_package_amendments
2370 }
2371}
2372
2373static POISON_VERSION_METHODS: AtomicBool = AtomicBool::new(false);
2374
2375impl ProtocolConfig {
2377 pub fn get_for_version(version: ProtocolVersion, chain: Chain) -> Self {
2379 assert!(
2381 version >= ProtocolVersion::MIN,
2382 "Network protocol version is {:?}, but the minimum supported version by the binary is {:?}. Please upgrade the binary.",
2383 version,
2384 ProtocolVersion::MIN.0,
2385 );
2386 assert!(
2387 version <= ProtocolVersion::MAX_ALLOWED,
2388 "Network protocol version is {:?}, but the maximum supported version by the binary is {:?}. Please upgrade the binary.",
2389 version,
2390 ProtocolVersion::MAX_ALLOWED.0,
2391 );
2392
2393 let mut ret = Self::get_for_version_impl(version, chain);
2394 ret.version = version;
2395 ret.chain = chain;
2396
2397 ret = Self::apply_config_override(version, ret);
2398
2399 if std::env::var("SUI_PROTOCOL_CONFIG_OVERRIDE_ENABLE").is_ok() {
2400 warn!(
2401 "overriding ProtocolConfig settings with custom settings; this may break non-local networks"
2402 );
2403 let overrides: ProtocolConfigOptional =
2404 serde_env::from_env_with_prefix("SUI_PROTOCOL_CONFIG_OVERRIDE")
2405 .expect("failed to parse ProtocolConfig override env variables");
2406 overrides.apply_to(&mut ret);
2407 }
2408
2409 ret
2410 }
2411
2412 pub fn get_for_version_if_supported(version: ProtocolVersion, chain: Chain) -> Option<Self> {
2415 if version.0 >= ProtocolVersion::MIN.0 && version.0 <= ProtocolVersion::MAX_ALLOWED.0 {
2416 let mut ret = Self::get_for_version_impl(version, chain);
2417 ret.version = version;
2418 ret.chain = chain;
2419 ret = Self::apply_config_override(version, ret);
2420 Some(ret)
2421 } else {
2422 None
2423 }
2424 }
2425
2426 pub fn poison_get_for_min_version() {
2427 POISON_VERSION_METHODS.store(true, Ordering::Relaxed);
2428 }
2429
2430 fn load_poison_get_for_min_version() -> bool {
2431 POISON_VERSION_METHODS.load(Ordering::Relaxed)
2432 }
2433
2434 pub fn get_for_min_version() -> Self {
2437 if Self::load_poison_get_for_min_version() {
2438 panic!("get_for_min_version called on validator");
2439 }
2440 ProtocolConfig::get_for_version(ProtocolVersion::MIN, Chain::Unknown)
2441 }
2442
2443 #[allow(non_snake_case)]
2453 pub fn get_for_max_version_UNSAFE() -> Self {
2454 if Self::load_poison_get_for_min_version() {
2455 panic!("get_for_max_version_UNSAFE called on validator");
2456 }
2457 ProtocolConfig::get_for_version(ProtocolVersion::MAX, Chain::Unknown)
2458 }
2459
2460 fn get_for_version_impl(version: ProtocolVersion, chain: Chain) -> Self {
2461 #[cfg(msim)]
2462 {
2463 if version == ProtocolVersion::MAX_ALLOWED {
2465 let mut config = Self::get_for_version_impl(version - 1, Chain::Unknown);
2466 config.base_tx_cost_fixed = Some(config.base_tx_cost_fixed() + 1000);
2467 return config;
2468 }
2469 }
2470
2471 let mut cfg = Self {
2474 version,
2476 chain,
2477
2478 feature_flags: Default::default(),
2480
2481 max_tx_size_bytes: Some(128 * 1024),
2482 max_input_objects: Some(2048),
2484 max_serialized_tx_effects_size_bytes: Some(512 * 1024),
2485 max_serialized_tx_effects_size_bytes_system_tx: Some(512 * 1024 * 16),
2486 max_gas_payment_objects: Some(256),
2487 max_modules_in_publish: Some(128),
2488 max_package_dependencies: None,
2489 max_arguments: Some(512),
2490 max_type_arguments: Some(16),
2491 max_type_argument_depth: Some(16),
2492 max_pure_argument_size: Some(16 * 1024),
2493 max_programmable_tx_commands: Some(1024),
2494 move_binary_format_version: Some(6),
2495 min_move_binary_format_version: None,
2496 binary_module_handles: None,
2497 binary_struct_handles: None,
2498 binary_function_handles: None,
2499 binary_function_instantiations: None,
2500 binary_signatures: None,
2501 binary_constant_pool: None,
2502 binary_identifiers: None,
2503 binary_address_identifiers: None,
2504 binary_struct_defs: None,
2505 binary_struct_def_instantiations: None,
2506 binary_function_defs: None,
2507 binary_field_handles: None,
2508 binary_field_instantiations: None,
2509 binary_friend_decls: None,
2510 binary_enum_defs: None,
2511 binary_enum_def_instantiations: None,
2512 binary_variant_handles: None,
2513 binary_variant_instantiation_handles: None,
2514 max_move_object_size: Some(250 * 1024),
2515 max_move_package_size: Some(100 * 1024),
2516 max_publish_or_upgrade_per_ptb: None,
2517 max_tx_gas: Some(10_000_000_000),
2518 max_gas_price: Some(100_000),
2519 max_gas_price_rgp_factor_for_aborted_transactions: None,
2520 max_gas_computation_bucket: Some(5_000_000),
2521 max_loop_depth: Some(5),
2522 max_generic_instantiation_length: Some(32),
2523 max_function_parameters: Some(128),
2524 max_basic_blocks: Some(1024),
2525 max_value_stack_size: Some(1024),
2526 max_type_nodes: Some(256),
2527 max_generic_instantiation_type_nodes_per_function: None,
2528 max_generic_instantiation_type_nodes_per_module: None,
2529 max_push_size: Some(10000),
2530 max_struct_definitions: Some(200),
2531 max_function_definitions: Some(1000),
2532 max_fields_in_struct: Some(32),
2533 max_dependency_depth: Some(100),
2534 max_num_event_emit: Some(256),
2535 max_num_new_move_object_ids: Some(2048),
2536 max_num_new_move_object_ids_system_tx: Some(2048 * 16),
2537 max_num_deleted_move_object_ids: Some(2048),
2538 max_num_deleted_move_object_ids_system_tx: Some(2048 * 16),
2539 max_num_transferred_move_object_ids: Some(2048),
2540 max_num_transferred_move_object_ids_system_tx: Some(2048 * 16),
2541 max_event_emit_size: Some(250 * 1024),
2542 max_move_vector_len: Some(256 * 1024),
2543 max_type_to_layout_nodes: None,
2544 max_ptb_value_size: None,
2545
2546 max_back_edges_per_function: Some(10_000),
2547 max_back_edges_per_module: Some(10_000),
2548 max_verifier_meter_ticks_per_function: Some(6_000_000),
2549 max_meter_ticks_per_module: Some(6_000_000),
2550 max_meter_ticks_per_package: None,
2551
2552 object_runtime_max_num_cached_objects: Some(1000),
2553 object_runtime_max_num_cached_objects_system_tx: Some(1000 * 16),
2554 object_runtime_max_num_store_entries: Some(1000),
2555 object_runtime_max_num_store_entries_system_tx: Some(1000 * 16),
2556 base_tx_cost_fixed: Some(110_000),
2557 package_publish_cost_fixed: Some(1_000),
2558 base_tx_cost_per_byte: Some(0),
2559 package_publish_cost_per_byte: Some(80),
2560 obj_access_cost_read_per_byte: Some(15),
2561 obj_access_cost_mutate_per_byte: Some(40),
2562 obj_access_cost_delete_per_byte: Some(40),
2563 obj_access_cost_verify_per_byte: Some(200),
2564 obj_data_cost_refundable: Some(100),
2565 obj_metadata_cost_non_refundable: Some(50),
2566 gas_model_version: Some(1),
2567 storage_rebate_rate: Some(9900),
2568 storage_fund_reinvest_rate: Some(500),
2569 reward_slashing_rate: Some(5000),
2570 storage_gas_price: Some(1),
2571 accumulator_object_storage_cost: None,
2572 max_transactions_per_checkpoint: Some(10_000),
2573 max_checkpoint_size_bytes: Some(30 * 1024 * 1024),
2574
2575 buffer_stake_for_protocol_upgrade_bps: Some(0),
2578
2579 address_from_bytes_cost_base: Some(52),
2583 address_to_u256_cost_base: Some(52),
2585 address_from_u256_cost_base: Some(52),
2587
2588 config_read_setting_impl_cost_base: None,
2591 config_read_setting_impl_cost_per_byte: None,
2592
2593 dynamic_field_hash_type_and_key_cost_base: Some(100),
2596 dynamic_field_hash_type_and_key_type_cost_per_byte: Some(2),
2597 dynamic_field_hash_type_and_key_value_cost_per_byte: Some(2),
2598 dynamic_field_hash_type_and_key_type_tag_cost_per_byte: Some(2),
2599 dynamic_field_add_child_object_cost_base: Some(100),
2601 dynamic_field_add_child_object_type_cost_per_byte: Some(10),
2602 dynamic_field_add_child_object_value_cost_per_byte: Some(10),
2603 dynamic_field_add_child_object_struct_tag_cost_per_byte: Some(10),
2604 dynamic_field_borrow_child_object_cost_base: Some(100),
2606 dynamic_field_borrow_child_object_child_ref_cost_per_byte: Some(10),
2607 dynamic_field_borrow_child_object_type_cost_per_byte: Some(10),
2608 dynamic_field_remove_child_object_cost_base: Some(100),
2610 dynamic_field_remove_child_object_child_cost_per_byte: Some(2),
2611 dynamic_field_remove_child_object_type_cost_per_byte: Some(2),
2612 dynamic_field_has_child_object_cost_base: Some(100),
2614 dynamic_field_has_child_object_with_ty_cost_base: Some(100),
2616 dynamic_field_has_child_object_with_ty_type_cost_per_byte: Some(2),
2617 dynamic_field_has_child_object_with_ty_type_tag_cost_per_byte: Some(2),
2618
2619 scratch_add_cost_base: None,
2621 scratch_read_cost_base: None,
2622 scratch_read_value_cost: None,
2623 scratch_remove_cost_base: None,
2624 scratch_exists_cost_base: None,
2625 scratch_exists_with_type_cost_base: None,
2626 scratch_exists_with_type_type_cost: None,
2627 max_scratch_pad_size: None,
2628
2629 event_emit_cost_base: Some(52),
2632 event_emit_value_size_derivation_cost_per_byte: Some(2),
2633 event_emit_tag_size_derivation_cost_per_byte: Some(5),
2634 event_emit_output_cost_per_byte: Some(10),
2635 event_emit_auth_stream_cost: None,
2636
2637 object_borrow_uid_cost_base: Some(52),
2640 object_delete_impl_cost_base: Some(52),
2642 object_record_new_uid_cost_base: Some(52),
2644 object_record_new_uid_from_hash_cost_base: None,
2647
2648 transfer_transfer_internal_cost_base: Some(52),
2651 transfer_party_transfer_internal_cost_base: None,
2653 transfer_freeze_object_cost_base: Some(52),
2655 transfer_share_object_cost_base: Some(52),
2657 transfer_receive_object_cost_base: None,
2658 transfer_receive_object_type_cost_per_byte: None,
2659 transfer_receive_object_cost_per_byte: None,
2660
2661 tx_context_derive_id_cost_base: Some(52),
2664 tx_context_fresh_id_cost_base: None,
2665 tx_context_sender_cost_base: None,
2666 tx_context_epoch_cost_base: None,
2667 tx_context_epoch_timestamp_ms_cost_base: None,
2668 tx_context_sponsor_cost_base: None,
2669 tx_context_rgp_cost_base: None,
2670 tx_context_gas_price_cost_base: None,
2671 tx_context_gas_budget_cost_base: None,
2672 tx_context_ids_created_cost_base: None,
2673 tx_context_replace_cost_base: None,
2674
2675 types_is_one_time_witness_cost_base: Some(52),
2678 types_is_one_time_witness_type_tag_cost_per_byte: Some(2),
2679 types_is_one_time_witness_type_cost_per_byte: Some(2),
2680
2681 validator_validate_metadata_cost_base: Some(52),
2684 validator_validate_metadata_data_cost_per_byte: Some(2),
2685
2686 crypto_invalid_arguments_cost: Some(100),
2688 bls12381_bls12381_min_sig_verify_cost_base: Some(52),
2690 bls12381_bls12381_min_sig_verify_msg_cost_per_byte: Some(2),
2691 bls12381_bls12381_min_sig_verify_msg_cost_per_block: Some(2),
2692
2693 bls12381_bls12381_min_pk_verify_cost_base: Some(52),
2695 bls12381_bls12381_min_pk_verify_msg_cost_per_byte: Some(2),
2696 bls12381_bls12381_min_pk_verify_msg_cost_per_block: Some(2),
2697
2698 ecdsa_k1_ecrecover_keccak256_cost_base: Some(52),
2700 ecdsa_k1_ecrecover_keccak256_msg_cost_per_byte: Some(2),
2701 ecdsa_k1_ecrecover_keccak256_msg_cost_per_block: Some(2),
2702 ecdsa_k1_ecrecover_sha256_cost_base: Some(52),
2703 ecdsa_k1_ecrecover_sha256_msg_cost_per_byte: Some(2),
2704 ecdsa_k1_ecrecover_sha256_msg_cost_per_block: Some(2),
2705
2706 ecdsa_k1_decompress_pubkey_cost_base: Some(52),
2708
2709 ecdsa_k1_secp256k1_verify_keccak256_cost_base: Some(52),
2711 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_byte: Some(2),
2712 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_block: Some(2),
2713 ecdsa_k1_secp256k1_verify_sha256_cost_base: Some(52),
2714 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_byte: Some(2),
2715 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_block: Some(2),
2716
2717 ecdsa_r1_ecrecover_keccak256_cost_base: Some(52),
2719 ecdsa_r1_ecrecover_keccak256_msg_cost_per_byte: Some(2),
2720 ecdsa_r1_ecrecover_keccak256_msg_cost_per_block: Some(2),
2721 ecdsa_r1_ecrecover_sha256_cost_base: Some(52),
2722 ecdsa_r1_ecrecover_sha256_msg_cost_per_byte: Some(2),
2723 ecdsa_r1_ecrecover_sha256_msg_cost_per_block: Some(2),
2724
2725 ecdsa_r1_secp256r1_verify_keccak256_cost_base: Some(52),
2727 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_byte: Some(2),
2728 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_block: Some(2),
2729 ecdsa_r1_secp256r1_verify_sha256_cost_base: Some(52),
2730 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_byte: Some(2),
2731 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_block: Some(2),
2732
2733 ecvrf_ecvrf_verify_cost_base: Some(52),
2735 ecvrf_ecvrf_verify_alpha_string_cost_per_byte: Some(2),
2736 ecvrf_ecvrf_verify_alpha_string_cost_per_block: Some(2),
2737
2738 ed25519_ed25519_verify_cost_base: Some(52),
2740 ed25519_ed25519_verify_msg_cost_per_byte: Some(2),
2741 ed25519_ed25519_verify_msg_cost_per_block: Some(2),
2742
2743 groth16_prepare_verifying_key_bls12381_cost_base: Some(52),
2745 groth16_prepare_verifying_key_bn254_cost_base: Some(52),
2746
2747 groth16_verify_groth16_proof_internal_bls12381_cost_base: Some(52),
2749 groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input: Some(2),
2750 groth16_verify_groth16_proof_internal_bn254_cost_base: Some(52),
2751 groth16_verify_groth16_proof_internal_bn254_cost_per_public_input: Some(2),
2752 groth16_verify_groth16_proof_internal_public_input_cost_per_byte: Some(2),
2753
2754 hash_blake2b256_cost_base: Some(52),
2756 hash_blake2b256_data_cost_per_byte: Some(2),
2757 hash_blake2b256_data_cost_per_block: Some(2),
2758
2759 hash_keccak256_cost_base: Some(52),
2761 hash_keccak256_data_cost_per_byte: Some(2),
2762 hash_keccak256_data_cost_per_block: Some(2),
2763
2764 poseidon_bn254_cost_base: None,
2765 poseidon_bn254_cost_per_block: None,
2766
2767 hmac_hmac_sha3_256_cost_base: Some(52),
2769 hmac_hmac_sha3_256_input_cost_per_byte: Some(2),
2770 hmac_hmac_sha3_256_input_cost_per_block: Some(2),
2771
2772 group_ops_bls12381_decode_scalar_cost: None,
2774 group_ops_bls12381_decode_g1_cost: None,
2775 group_ops_bls12381_decode_g2_cost: None,
2776 group_ops_bls12381_decode_gt_cost: None,
2777 group_ops_bls12381_scalar_add_cost: None,
2778 group_ops_bls12381_g1_add_cost: None,
2779 group_ops_bls12381_g2_add_cost: None,
2780 group_ops_bls12381_gt_add_cost: None,
2781 group_ops_bls12381_scalar_sub_cost: None,
2782 group_ops_bls12381_g1_sub_cost: None,
2783 group_ops_bls12381_g2_sub_cost: None,
2784 group_ops_bls12381_gt_sub_cost: None,
2785 group_ops_bls12381_scalar_mul_cost: None,
2786 group_ops_bls12381_g1_mul_cost: None,
2787 group_ops_bls12381_g2_mul_cost: None,
2788 group_ops_bls12381_gt_mul_cost: None,
2789 group_ops_bls12381_scalar_div_cost: None,
2790 group_ops_bls12381_g1_div_cost: None,
2791 group_ops_bls12381_g2_div_cost: None,
2792 group_ops_bls12381_gt_div_cost: None,
2793 group_ops_bls12381_g1_hash_to_base_cost: None,
2794 group_ops_bls12381_g2_hash_to_base_cost: None,
2795 group_ops_bls12381_g1_hash_to_cost_per_byte: None,
2796 group_ops_bls12381_g2_hash_to_cost_per_byte: None,
2797 group_ops_bls12381_g1_msm_base_cost: None,
2798 group_ops_bls12381_g2_msm_base_cost: None,
2799 group_ops_bls12381_g1_msm_base_cost_per_input: None,
2800 group_ops_bls12381_g2_msm_base_cost_per_input: None,
2801 group_ops_bls12381_msm_max_len: None,
2802 group_ops_bls12381_pairing_cost: None,
2803 group_ops_bls12381_g1_to_uncompressed_g1_cost: None,
2804 group_ops_bls12381_uncompressed_g1_to_g1_cost: None,
2805 group_ops_bls12381_uncompressed_g1_sum_base_cost: None,
2806 group_ops_bls12381_uncompressed_g1_sum_cost_per_term: None,
2807 group_ops_bls12381_uncompressed_g1_sum_max_terms: None,
2808
2809 group_ops_ristretto_decode_scalar_cost: None,
2810 group_ops_ristretto_decode_point_cost: None,
2811 group_ops_ristretto_scalar_add_cost: None,
2812 group_ops_ristretto_point_add_cost: None,
2813 group_ops_ristretto_scalar_sub_cost: None,
2814 group_ops_ristretto_point_sub_cost: None,
2815 group_ops_ristretto_scalar_mul_cost: None,
2816 group_ops_ristretto_point_mul_cost: None,
2817 group_ops_ristretto_scalar_div_cost: None,
2818 group_ops_ristretto_point_div_cost: None,
2819
2820 verify_bulletproofs_ristretto255_base_cost: None,
2821 verify_bulletproofs_ristretto255_cost_per_bit_and_commitment: None,
2822
2823 check_zklogin_id_cost_base: None,
2825 check_zklogin_issuer_cost_base: None,
2827
2828 vdf_verify_vdf_cost: None,
2829 vdf_hash_to_input_cost: None,
2830
2831 nitro_attestation_parse_base_cost: None,
2833 nitro_attestation_parse_cost_per_byte: None,
2834 nitro_attestation_verify_base_cost: None,
2835 nitro_attestation_verify_cost_per_cert: None,
2836
2837 bcs_per_byte_serialized_cost: None,
2838 bcs_legacy_min_output_size_cost: None,
2839 bcs_failure_cost: None,
2840 hash_sha2_256_base_cost: None,
2841 hash_sha2_256_per_byte_cost: None,
2842 hash_sha2_256_legacy_min_input_len_cost: None,
2843 hash_sha3_256_base_cost: None,
2844 hash_sha3_256_per_byte_cost: None,
2845 hash_sha3_256_legacy_min_input_len_cost: None,
2846 type_name_get_base_cost: None,
2847 type_name_get_per_byte_cost: None,
2848 type_name_id_base_cost: None,
2849 string_check_utf8_base_cost: None,
2850 string_check_utf8_per_byte_cost: None,
2851 string_is_char_boundary_base_cost: None,
2852 string_sub_string_base_cost: None,
2853 string_sub_string_per_byte_cost: None,
2854 string_index_of_base_cost: None,
2855 string_index_of_per_byte_pattern_cost: None,
2856 string_index_of_per_byte_searched_cost: None,
2857 vector_empty_base_cost: None,
2858 vector_length_base_cost: None,
2859 vector_push_back_base_cost: None,
2860 vector_push_back_legacy_per_abstract_memory_unit_cost: None,
2861 vector_borrow_base_cost: None,
2862 vector_pop_back_base_cost: None,
2863 vector_destroy_empty_base_cost: None,
2864 vector_swap_base_cost: None,
2865 debug_print_base_cost: None,
2866 debug_print_stack_trace_base_cost: None,
2867
2868 max_size_written_objects: None,
2869 max_size_written_objects_system_tx: None,
2870
2871 max_move_identifier_len: None,
2878 max_move_value_depth: None,
2879 max_move_enum_variants: None,
2880
2881 gas_rounding_step: None,
2882
2883 execution_version: None,
2884
2885 max_event_emit_size_total: None,
2886
2887 consensus_bad_nodes_stake_threshold: None,
2888
2889 max_jwk_votes_per_validator_per_epoch: None,
2890
2891 max_age_of_jwk_in_epochs: None,
2892
2893 random_beacon_reduction_allowed_delta: None,
2894
2895 random_beacon_reduction_lower_bound: None,
2896
2897 random_beacon_dkg_timeout_round: None,
2898
2899 random_beacon_min_round_interval_ms: None,
2900
2901 random_beacon_dkg_version: None,
2902
2903 consensus_max_transaction_size_bytes: None,
2904
2905 consensus_max_transactions_in_block_bytes: None,
2906
2907 consensus_max_num_transactions_in_block: None,
2908
2909 consensus_voting_rounds: None,
2910
2911 max_accumulated_txn_cost_per_object_in_narwhal_commit: None,
2912
2913 max_deferral_rounds_for_congestion_control: None,
2914
2915 epoch_close_deadline_ms: None,
2916
2917 max_txn_cost_overage_per_object_in_commit: None,
2918
2919 allowed_txn_cost_overage_burst_per_object_in_commit: None,
2920
2921 min_checkpoint_interval_ms: None,
2922
2923 checkpoint_summary_version_specific_data: None,
2924
2925 max_soft_bundle_size: None,
2926
2927 bridge_should_try_to_finalize_committee: None,
2928
2929 max_accumulated_txn_cost_per_object_in_mysticeti_commit: None,
2930
2931 max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit: None,
2932
2933 consensus_gc_depth: None,
2934
2935 gas_budget_based_txn_cost_cap_factor: None,
2936
2937 gas_budget_based_txn_cost_absolute_cap_commit_count: None,
2938
2939 sip_45_consensus_amplification_threshold: None,
2940
2941 use_object_per_epoch_marker_table_v2: None,
2942
2943 consensus_commit_rate_estimation_window_size: None,
2944
2945 aliased_addresses: vec![],
2946
2947 translation_per_command_base_charge: None,
2948 translation_per_input_base_charge: None,
2949 translation_pure_input_per_byte_charge: None,
2950 translation_per_type_node_charge: None,
2951 translation_per_reference_node_charge: None,
2952 translation_per_linkage_entry_charge: None,
2953
2954 max_updates_per_settlement_txn: None,
2955
2956 gasless_max_computation_units: None,
2957 gasless_allowed_token_types: None,
2958 gasless_max_unused_inputs: None,
2959 gasless_max_pure_input_bytes: None,
2960 gasless_max_tps: None,
2961 include_special_package_amendments: None,
2962 gasless_max_tx_size_bytes: None,
2963 };
2966 for cur in 2..=version.0 {
2967 match cur {
2968 1 => unreachable!(),
2969 2 => {
2970 cfg.feature_flags.advance_epoch_start_time_in_safe_mode = true;
2971 }
2972 3 => {
2973 cfg.gas_model_version = Some(2);
2975 cfg.max_tx_gas = Some(50_000_000_000);
2977 cfg.base_tx_cost_fixed = Some(2_000);
2979 cfg.storage_gas_price = Some(76);
2981 cfg.feature_flags.loaded_child_objects_fixed = true;
2982 cfg.max_size_written_objects = Some(5 * 1000 * 1000);
2985 cfg.max_size_written_objects_system_tx = Some(50 * 1000 * 1000);
2988 cfg.feature_flags.package_upgrades = true;
2989 }
2990 4 => {
2995 cfg.reward_slashing_rate = Some(10000);
2997 cfg.gas_model_version = Some(3);
2999 }
3000 5 => {
3001 cfg.feature_flags.missing_type_is_compatibility_error = true;
3002 cfg.gas_model_version = Some(4);
3003 cfg.feature_flags.scoring_decision_with_validity_cutoff = true;
3004 }
3008 6 => {
3009 cfg.gas_model_version = Some(5);
3010 cfg.buffer_stake_for_protocol_upgrade_bps = Some(5000);
3011 cfg.feature_flags.consensus_order_end_of_epoch_last = true;
3012 }
3013 7 => {
3014 cfg.feature_flags.disallow_adding_abilities_on_upgrade = true;
3015 cfg.feature_flags
3016 .disable_invariant_violation_check_in_swap_loc = true;
3017 cfg.feature_flags.ban_entry_init = true;
3018 cfg.feature_flags.package_digest_hash_module = true;
3019 }
3020 8 => {
3021 cfg.feature_flags
3022 .disallow_change_struct_type_params_on_upgrade = true;
3023 }
3024 9 => {
3025 cfg.max_move_identifier_len = Some(128);
3027 cfg.feature_flags.no_extraneous_module_bytes = true;
3028 cfg.feature_flags
3029 .advance_to_highest_supported_protocol_version = true;
3030 }
3031 10 => {
3032 cfg.max_verifier_meter_ticks_per_function = Some(16_000_000);
3033 cfg.max_meter_ticks_per_module = Some(16_000_000);
3034 }
3035 11 => {
3036 cfg.max_move_value_depth = Some(128);
3037 }
3038 12 => {
3039 cfg.feature_flags.narwhal_versioned_metadata = true;
3040 if chain != Chain::Mainnet {
3041 cfg.feature_flags.commit_root_state_digest = true;
3042 }
3043
3044 if chain != Chain::Mainnet && chain != Chain::Testnet {
3045 cfg.feature_flags.zklogin_auth = true;
3046 }
3047 }
3048 13 => {}
3049 14 => {
3050 cfg.gas_rounding_step = Some(1_000);
3051 cfg.gas_model_version = Some(6);
3052 }
3053 15 => {
3054 cfg.feature_flags.consensus_transaction_ordering =
3055 ConsensusTransactionOrdering::ByGasPrice;
3056 }
3057 16 => {
3058 cfg.feature_flags.simplified_unwrap_then_delete = true;
3059 }
3060 17 => {
3061 cfg.feature_flags.upgraded_multisig_supported = true;
3062 }
3063 18 => {
3064 cfg.execution_version = Some(1);
3065 cfg.feature_flags.txn_base_cost_as_multiplier = true;
3074 cfg.base_tx_cost_fixed = Some(1_000);
3076 }
3077 19 => {
3078 cfg.max_num_event_emit = Some(1024);
3079 cfg.max_event_emit_size_total = Some(
3082 256 * 250 * 1024, );
3084 }
3085 20 => {
3086 cfg.feature_flags.commit_root_state_digest = true;
3087
3088 if chain != Chain::Mainnet {
3089 cfg.feature_flags.narwhal_new_leader_election_schedule = true;
3090 cfg.consensus_bad_nodes_stake_threshold = Some(20);
3091 }
3092 }
3093
3094 21 => {
3095 if chain != Chain::Mainnet {
3096 cfg.feature_flags.zklogin_supported_providers = BTreeSet::from([
3097 "Google".to_string(),
3098 "Facebook".to_string(),
3099 "Twitch".to_string(),
3100 ]);
3101 }
3102 }
3103 22 => {
3104 cfg.feature_flags.loaded_child_object_format = true;
3105 }
3106 23 => {
3107 cfg.feature_flags.loaded_child_object_format_type = true;
3108 cfg.feature_flags.narwhal_new_leader_election_schedule = true;
3109 cfg.consensus_bad_nodes_stake_threshold = Some(20);
3115 }
3116 24 => {
3117 cfg.feature_flags.simple_conservation_checks = true;
3118 cfg.max_publish_or_upgrade_per_ptb = Some(5);
3119
3120 cfg.feature_flags.end_of_epoch_transaction_supported = true;
3121
3122 if chain != Chain::Mainnet {
3123 cfg.feature_flags.enable_jwk_consensus_updates = true;
3124 cfg.max_jwk_votes_per_validator_per_epoch = Some(240);
3126 cfg.max_age_of_jwk_in_epochs = Some(1);
3127 }
3128 }
3129 25 => {
3130 cfg.feature_flags.zklogin_supported_providers = BTreeSet::from([
3132 "Google".to_string(),
3133 "Facebook".to_string(),
3134 "Twitch".to_string(),
3135 ]);
3136 cfg.feature_flags.zklogin_auth = true;
3137
3138 cfg.feature_flags.enable_jwk_consensus_updates = true;
3140 cfg.max_jwk_votes_per_validator_per_epoch = Some(240);
3141 cfg.max_age_of_jwk_in_epochs = Some(1);
3142 }
3143 26 => {
3144 cfg.gas_model_version = Some(7);
3145 if chain != Chain::Mainnet && chain != Chain::Testnet {
3147 cfg.transfer_receive_object_cost_base = Some(52);
3148 cfg.feature_flags.receive_objects = true;
3149 }
3150 }
3151 27 => {
3152 cfg.gas_model_version = Some(8);
3153 }
3154 28 => {
3155 cfg.check_zklogin_id_cost_base = Some(200);
3157 cfg.check_zklogin_issuer_cost_base = Some(200);
3159
3160 if chain != Chain::Mainnet && chain != Chain::Testnet {
3162 cfg.feature_flags.enable_effects_v2 = true;
3163 }
3164 }
3165 29 => {
3166 cfg.feature_flags.verify_legacy_zklogin_address = true;
3167 }
3168 30 => {
3169 if chain != Chain::Mainnet {
3171 cfg.feature_flags.narwhal_certificate_v2 = true;
3172 }
3173
3174 cfg.random_beacon_reduction_allowed_delta = Some(800);
3175 if chain != Chain::Mainnet {
3177 cfg.feature_flags.enable_effects_v2 = true;
3178 }
3179
3180 cfg.feature_flags.zklogin_supported_providers = BTreeSet::default();
3184
3185 cfg.feature_flags.recompute_has_public_transfer_in_execution = true;
3186 }
3187 31 => {
3188 cfg.execution_version = Some(2);
3189 if chain != Chain::Mainnet && chain != Chain::Testnet {
3191 cfg.feature_flags.shared_object_deletion = true;
3192 }
3193 }
3194 32 => {
3195 if chain != Chain::Mainnet {
3197 cfg.feature_flags.accept_zklogin_in_multisig = true;
3198 }
3199 if chain != Chain::Mainnet {
3201 cfg.transfer_receive_object_cost_base = Some(52);
3202 cfg.feature_flags.receive_objects = true;
3203 }
3204 if chain != Chain::Mainnet && chain != Chain::Testnet {
3206 cfg.feature_flags.random_beacon = true;
3207 cfg.random_beacon_reduction_lower_bound = Some(1600);
3208 cfg.random_beacon_dkg_timeout_round = Some(3000);
3209 cfg.random_beacon_min_round_interval_ms = Some(150);
3210 }
3211 if chain != Chain::Testnet && chain != Chain::Mainnet {
3213 cfg.feature_flags.include_consensus_digest_in_prologue = true;
3214 }
3215
3216 cfg.feature_flags.narwhal_certificate_v2 = true;
3218 }
3219 33 => {
3220 cfg.feature_flags.hardened_otw_check = true;
3221 cfg.feature_flags.allow_receiving_object_id = true;
3222
3223 cfg.transfer_receive_object_cost_base = Some(52);
3225 cfg.feature_flags.receive_objects = true;
3226
3227 if chain != Chain::Mainnet {
3229 cfg.feature_flags.shared_object_deletion = true;
3230 }
3231
3232 cfg.feature_flags.enable_effects_v2 = true;
3233 }
3234 34 => {}
3235 35 => {
3236 if chain != Chain::Mainnet && chain != Chain::Testnet {
3238 cfg.feature_flags.enable_poseidon = true;
3239 cfg.poseidon_bn254_cost_base = Some(260);
3240 cfg.poseidon_bn254_cost_per_block = Some(10);
3241 }
3242
3243 cfg.feature_flags.enable_coin_deny_list = true;
3244 }
3245 36 => {
3246 if chain != Chain::Mainnet && chain != Chain::Testnet {
3248 cfg.feature_flags.enable_group_ops_native_functions = true;
3249 cfg.feature_flags.enable_group_ops_native_function_msm = true;
3250 cfg.group_ops_bls12381_decode_scalar_cost = Some(52);
3252 cfg.group_ops_bls12381_decode_g1_cost = Some(52);
3253 cfg.group_ops_bls12381_decode_g2_cost = Some(52);
3254 cfg.group_ops_bls12381_decode_gt_cost = Some(52);
3255 cfg.group_ops_bls12381_scalar_add_cost = Some(52);
3256 cfg.group_ops_bls12381_g1_add_cost = Some(52);
3257 cfg.group_ops_bls12381_g2_add_cost = Some(52);
3258 cfg.group_ops_bls12381_gt_add_cost = Some(52);
3259 cfg.group_ops_bls12381_scalar_sub_cost = Some(52);
3260 cfg.group_ops_bls12381_g1_sub_cost = Some(52);
3261 cfg.group_ops_bls12381_g2_sub_cost = Some(52);
3262 cfg.group_ops_bls12381_gt_sub_cost = Some(52);
3263 cfg.group_ops_bls12381_scalar_mul_cost = Some(52);
3264 cfg.group_ops_bls12381_g1_mul_cost = Some(52);
3265 cfg.group_ops_bls12381_g2_mul_cost = Some(52);
3266 cfg.group_ops_bls12381_gt_mul_cost = Some(52);
3267 cfg.group_ops_bls12381_scalar_div_cost = Some(52);
3268 cfg.group_ops_bls12381_g1_div_cost = Some(52);
3269 cfg.group_ops_bls12381_g2_div_cost = Some(52);
3270 cfg.group_ops_bls12381_gt_div_cost = Some(52);
3271 cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(52);
3272 cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(52);
3273 cfg.group_ops_bls12381_g1_hash_to_cost_per_byte = Some(2);
3274 cfg.group_ops_bls12381_g2_hash_to_cost_per_byte = Some(2);
3275 cfg.group_ops_bls12381_g1_msm_base_cost = Some(52);
3276 cfg.group_ops_bls12381_g2_msm_base_cost = Some(52);
3277 cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(52);
3278 cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(52);
3279 cfg.group_ops_bls12381_msm_max_len = Some(32);
3280 cfg.group_ops_bls12381_pairing_cost = Some(52);
3281 }
3282 cfg.feature_flags.shared_object_deletion = true;
3284
3285 cfg.consensus_max_transaction_size_bytes = Some(256 * 1024); cfg.consensus_max_transactions_in_block_bytes = Some(6 * 1_024 * 1024);
3287 }
3289 37 => {
3290 cfg.feature_flags.reject_mutable_random_on_entry_functions = true;
3291
3292 if chain != Chain::Mainnet {
3294 cfg.feature_flags.include_consensus_digest_in_prologue = true;
3295 }
3296 }
3297 38 => {
3298 cfg.binary_module_handles = Some(100);
3299 cfg.binary_struct_handles = Some(300);
3300 cfg.binary_function_handles = Some(1500);
3301 cfg.binary_function_instantiations = Some(750);
3302 cfg.binary_signatures = Some(1000);
3303 cfg.binary_constant_pool = Some(4000);
3307 cfg.binary_identifiers = Some(10000);
3308 cfg.binary_address_identifiers = Some(100);
3309 cfg.binary_struct_defs = Some(200);
3310 cfg.binary_struct_def_instantiations = Some(100);
3311 cfg.binary_function_defs = Some(1000);
3312 cfg.binary_field_handles = Some(500);
3313 cfg.binary_field_instantiations = Some(250);
3314 cfg.binary_friend_decls = Some(100);
3315 cfg.max_package_dependencies = Some(32);
3317 cfg.max_modules_in_publish = Some(64);
3318 cfg.execution_version = Some(3);
3320 }
3321 39 => {
3322 }
3324 40 => {}
3325 41 => {
3326 cfg.feature_flags.enable_group_ops_native_functions = true;
3328 cfg.group_ops_bls12381_decode_scalar_cost = Some(52);
3330 cfg.group_ops_bls12381_decode_g1_cost = Some(52);
3331 cfg.group_ops_bls12381_decode_g2_cost = Some(52);
3332 cfg.group_ops_bls12381_decode_gt_cost = Some(52);
3333 cfg.group_ops_bls12381_scalar_add_cost = Some(52);
3334 cfg.group_ops_bls12381_g1_add_cost = Some(52);
3335 cfg.group_ops_bls12381_g2_add_cost = Some(52);
3336 cfg.group_ops_bls12381_gt_add_cost = Some(52);
3337 cfg.group_ops_bls12381_scalar_sub_cost = Some(52);
3338 cfg.group_ops_bls12381_g1_sub_cost = Some(52);
3339 cfg.group_ops_bls12381_g2_sub_cost = Some(52);
3340 cfg.group_ops_bls12381_gt_sub_cost = Some(52);
3341 cfg.group_ops_bls12381_scalar_mul_cost = Some(52);
3342 cfg.group_ops_bls12381_g1_mul_cost = Some(52);
3343 cfg.group_ops_bls12381_g2_mul_cost = Some(52);
3344 cfg.group_ops_bls12381_gt_mul_cost = Some(52);
3345 cfg.group_ops_bls12381_scalar_div_cost = Some(52);
3346 cfg.group_ops_bls12381_g1_div_cost = Some(52);
3347 cfg.group_ops_bls12381_g2_div_cost = Some(52);
3348 cfg.group_ops_bls12381_gt_div_cost = Some(52);
3349 cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(52);
3350 cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(52);
3351 cfg.group_ops_bls12381_g1_hash_to_cost_per_byte = Some(2);
3352 cfg.group_ops_bls12381_g2_hash_to_cost_per_byte = Some(2);
3353 cfg.group_ops_bls12381_g1_msm_base_cost = Some(52);
3354 cfg.group_ops_bls12381_g2_msm_base_cost = Some(52);
3355 cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(52);
3356 cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(52);
3357 cfg.group_ops_bls12381_msm_max_len = Some(32);
3358 cfg.group_ops_bls12381_pairing_cost = Some(52);
3359 }
3360 42 => {}
3361 43 => {
3362 cfg.feature_flags.zklogin_max_epoch_upper_bound_delta = Some(30);
3363 cfg.max_meter_ticks_per_package = Some(16_000_000);
3364 }
3365 44 => {
3366 cfg.feature_flags.include_consensus_digest_in_prologue = true;
3368 if chain != Chain::Mainnet {
3370 cfg.feature_flags.consensus_choice = ConsensusChoice::SwapEachEpoch;
3371 }
3372 }
3373 45 => {
3374 if chain != Chain::Testnet && chain != Chain::Mainnet {
3376 cfg.feature_flags.consensus_network = ConsensusNetwork::Tonic;
3377 }
3378
3379 if chain != Chain::Mainnet {
3380 cfg.feature_flags.mysticeti_leader_scoring_and_schedule = true;
3382 }
3383 cfg.min_move_binary_format_version = Some(6);
3384 cfg.feature_flags.accept_zklogin_in_multisig = true;
3385
3386 if chain != Chain::Mainnet && chain != Chain::Testnet {
3390 cfg.feature_flags.bridge = true;
3391 }
3392 }
3393 46 => {
3394 if chain != Chain::Mainnet {
3396 cfg.feature_flags.bridge = true;
3397 }
3398
3399 cfg.feature_flags.reshare_at_same_initial_version = true;
3401 }
3402 47 => {}
3403 48 => {
3404 cfg.feature_flags.consensus_network = ConsensusNetwork::Tonic;
3406
3407 cfg.feature_flags.resolve_abort_locations_to_package_id = true;
3409
3410 if chain != Chain::Mainnet {
3412 cfg.feature_flags.random_beacon = true;
3413 cfg.random_beacon_reduction_lower_bound = Some(1600);
3414 cfg.random_beacon_dkg_timeout_round = Some(3000);
3415 cfg.random_beacon_min_round_interval_ms = Some(200);
3416 }
3417
3418 cfg.feature_flags.mysticeti_use_committed_subdag_digest = true;
3420 }
3421 49 => {
3422 if chain != Chain::Testnet && chain != Chain::Mainnet {
3423 cfg.move_binary_format_version = Some(7);
3424 }
3425
3426 if chain != Chain::Mainnet && chain != Chain::Testnet {
3428 cfg.feature_flags.enable_vdf = true;
3429 cfg.vdf_verify_vdf_cost = Some(1500);
3432 cfg.vdf_hash_to_input_cost = Some(100);
3433 }
3434
3435 if chain != Chain::Testnet && chain != Chain::Mainnet {
3437 cfg.feature_flags
3438 .record_consensus_determined_version_assignments_in_prologue = true;
3439 }
3440
3441 if chain != Chain::Mainnet {
3443 cfg.feature_flags.consensus_choice = ConsensusChoice::Mysticeti;
3444 }
3445
3446 cfg.feature_flags.fresh_vm_on_framework_upgrade = true;
3448 }
3449 50 => {
3450 if chain != Chain::Mainnet {
3452 cfg.checkpoint_summary_version_specific_data = Some(1);
3453 cfg.min_checkpoint_interval_ms = Some(200);
3454 }
3455
3456 if chain != Chain::Testnet && chain != Chain::Mainnet {
3458 cfg.feature_flags
3459 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = true;
3460 }
3461
3462 cfg.feature_flags.mysticeti_num_leaders_per_round = Some(1);
3463
3464 cfg.max_deferral_rounds_for_congestion_control = Some(10);
3466 }
3467 51 => {
3468 cfg.random_beacon_dkg_version = Some(1);
3469
3470 if chain != Chain::Testnet && chain != Chain::Mainnet {
3471 cfg.feature_flags.enable_coin_deny_list_v2 = true;
3472 }
3473 }
3474 52 => {
3475 if chain != Chain::Mainnet {
3476 cfg.feature_flags.soft_bundle = true;
3477 cfg.max_soft_bundle_size = Some(5);
3478 }
3479
3480 cfg.config_read_setting_impl_cost_base = Some(100);
3481 cfg.config_read_setting_impl_cost_per_byte = Some(40);
3482
3483 if chain != Chain::Testnet && chain != Chain::Mainnet {
3485 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(100);
3486 cfg.feature_flags.per_object_congestion_control_mode =
3487 PerObjectCongestionControlMode::TotalTxCount;
3488 }
3489
3490 cfg.feature_flags.consensus_choice = ConsensusChoice::Mysticeti;
3492
3493 cfg.feature_flags.mysticeti_leader_scoring_and_schedule = true;
3495
3496 cfg.checkpoint_summary_version_specific_data = Some(1);
3498 cfg.min_checkpoint_interval_ms = Some(200);
3499
3500 if chain != Chain::Mainnet {
3502 cfg.feature_flags
3503 .record_consensus_determined_version_assignments_in_prologue = true;
3504 cfg.feature_flags
3505 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = true;
3506 }
3507 if chain != Chain::Mainnet {
3509 cfg.move_binary_format_version = Some(7);
3510 }
3511
3512 if chain != Chain::Testnet && chain != Chain::Mainnet {
3513 cfg.feature_flags.passkey_auth = true;
3514 }
3515 cfg.feature_flags.enable_coin_deny_list_v2 = true;
3516 }
3517 53 => {
3518 cfg.bridge_should_try_to_finalize_committee = Some(chain != Chain::Mainnet);
3520
3521 cfg.feature_flags
3523 .record_consensus_determined_version_assignments_in_prologue = true;
3524 cfg.feature_flags
3525 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = true;
3526
3527 if chain == Chain::Unknown {
3528 cfg.feature_flags.authority_capabilities_v2 = true;
3529 }
3530
3531 if chain != Chain::Mainnet {
3533 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(100);
3534 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(10);
3535 cfg.feature_flags.per_object_congestion_control_mode =
3536 PerObjectCongestionControlMode::TotalTxCount;
3537 }
3538
3539 cfg.bcs_per_byte_serialized_cost = Some(2);
3541 cfg.bcs_legacy_min_output_size_cost = Some(1);
3542 cfg.bcs_failure_cost = Some(52);
3543 cfg.debug_print_base_cost = Some(52);
3544 cfg.debug_print_stack_trace_base_cost = Some(52);
3545 cfg.hash_sha2_256_base_cost = Some(52);
3546 cfg.hash_sha2_256_per_byte_cost = Some(2);
3547 cfg.hash_sha2_256_legacy_min_input_len_cost = Some(1);
3548 cfg.hash_sha3_256_base_cost = Some(52);
3549 cfg.hash_sha3_256_per_byte_cost = Some(2);
3550 cfg.hash_sha3_256_legacy_min_input_len_cost = Some(1);
3551 cfg.type_name_get_base_cost = Some(52);
3552 cfg.type_name_get_per_byte_cost = Some(2);
3553 cfg.string_check_utf8_base_cost = Some(52);
3554 cfg.string_check_utf8_per_byte_cost = Some(2);
3555 cfg.string_is_char_boundary_base_cost = Some(52);
3556 cfg.string_sub_string_base_cost = Some(52);
3557 cfg.string_sub_string_per_byte_cost = Some(2);
3558 cfg.string_index_of_base_cost = Some(52);
3559 cfg.string_index_of_per_byte_pattern_cost = Some(2);
3560 cfg.string_index_of_per_byte_searched_cost = Some(2);
3561 cfg.vector_empty_base_cost = Some(52);
3562 cfg.vector_length_base_cost = Some(52);
3563 cfg.vector_push_back_base_cost = Some(52);
3564 cfg.vector_push_back_legacy_per_abstract_memory_unit_cost = Some(2);
3565 cfg.vector_borrow_base_cost = Some(52);
3566 cfg.vector_pop_back_base_cost = Some(52);
3567 cfg.vector_destroy_empty_base_cost = Some(52);
3568 cfg.vector_swap_base_cost = Some(52);
3569 }
3570 54 => {
3571 cfg.feature_flags.random_beacon = true;
3573 cfg.random_beacon_reduction_lower_bound = Some(1000);
3574 cfg.random_beacon_dkg_timeout_round = Some(3000);
3575 cfg.random_beacon_min_round_interval_ms = Some(500);
3576
3577 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(100);
3579 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(10);
3580 cfg.feature_flags.per_object_congestion_control_mode =
3581 PerObjectCongestionControlMode::TotalTxCount;
3582
3583 cfg.feature_flags.soft_bundle = true;
3585 cfg.max_soft_bundle_size = Some(5);
3586 }
3587 55 => {
3588 cfg.move_binary_format_version = Some(7);
3590
3591 cfg.consensus_max_transactions_in_block_bytes = Some(512 * 1024);
3593 cfg.consensus_max_num_transactions_in_block = Some(512);
3596
3597 cfg.feature_flags.rethrow_serialization_type_layout_errors = true;
3598 }
3599 56 => {
3600 if chain == Chain::Mainnet {
3601 cfg.feature_flags.bridge = true;
3602 }
3603 }
3604 57 => {
3605 cfg.random_beacon_reduction_lower_bound = Some(800);
3607 }
3608 58 => {
3609 if chain == Chain::Mainnet {
3610 cfg.bridge_should_try_to_finalize_committee = Some(true);
3611 }
3612
3613 if chain != Chain::Mainnet && chain != Chain::Testnet {
3614 cfg.feature_flags
3616 .consensus_distributed_vote_scoring_strategy = true;
3617 }
3618 }
3619 59 => {
3620 cfg.feature_flags.consensus_round_prober = true;
3622 }
3623 60 => {
3624 cfg.max_type_to_layout_nodes = Some(512);
3625 cfg.feature_flags.validate_identifier_inputs = true;
3626 }
3627 61 => {
3628 if chain != Chain::Mainnet {
3629 cfg.feature_flags
3631 .consensus_distributed_vote_scoring_strategy = true;
3632 }
3633 cfg.random_beacon_reduction_lower_bound = Some(700);
3635
3636 if chain != Chain::Mainnet && chain != Chain::Testnet {
3637 cfg.feature_flags.mysticeti_fastpath = true;
3639 }
3640 }
3641 62 => {
3642 cfg.feature_flags.relocate_event_module = true;
3643 }
3644 63 => {
3645 cfg.feature_flags.per_object_congestion_control_mode =
3646 PerObjectCongestionControlMode::TotalGasBudgetWithCap;
3647 cfg.gas_budget_based_txn_cost_cap_factor = Some(400_000);
3648 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(18_500_000);
3649 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(240_000_000);
3650 }
3651 64 => {
3652 cfg.feature_flags.per_object_congestion_control_mode =
3653 PerObjectCongestionControlMode::TotalTxCount;
3654 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(40);
3655 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(3);
3656 }
3657 65 => {
3658 cfg.feature_flags
3660 .consensus_distributed_vote_scoring_strategy = true;
3661 }
3662 66 => {
3663 if chain == Chain::Mainnet {
3664 cfg.feature_flags
3666 .consensus_distributed_vote_scoring_strategy = false;
3667 }
3668 }
3669 67 => {
3670 cfg.feature_flags
3672 .consensus_distributed_vote_scoring_strategy = true;
3673 }
3674 68 => {
3675 cfg.group_ops_bls12381_g1_to_uncompressed_g1_cost = Some(26);
3676 cfg.group_ops_bls12381_uncompressed_g1_to_g1_cost = Some(52);
3677 cfg.group_ops_bls12381_uncompressed_g1_sum_base_cost = Some(26);
3678 cfg.group_ops_bls12381_uncompressed_g1_sum_cost_per_term = Some(13);
3679 cfg.group_ops_bls12381_uncompressed_g1_sum_max_terms = Some(2000);
3680
3681 if chain != Chain::Mainnet && chain != Chain::Testnet {
3682 cfg.feature_flags.uncompressed_g1_group_elements = true;
3683 }
3684
3685 cfg.feature_flags.per_object_congestion_control_mode =
3686 PerObjectCongestionControlMode::TotalGasBudgetWithCap;
3687 cfg.gas_budget_based_txn_cost_cap_factor = Some(400_000);
3688 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(18_500_000);
3689 cfg.max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit =
3690 Some(3_700_000); cfg.max_txn_cost_overage_per_object_in_commit = Some(u64::MAX);
3692 cfg.gas_budget_based_txn_cost_absolute_cap_commit_count = Some(50);
3693
3694 cfg.random_beacon_reduction_lower_bound = Some(500);
3696
3697 cfg.feature_flags.disallow_new_modules_in_deps_only_packages = true;
3698 }
3699 69 => {
3700 cfg.consensus_voting_rounds = Some(40);
3702
3703 if chain != Chain::Mainnet && chain != Chain::Testnet {
3704 cfg.feature_flags.consensus_smart_ancestor_selection = true;
3706 }
3707
3708 if chain != Chain::Mainnet {
3709 cfg.feature_flags.uncompressed_g1_group_elements = true;
3710 }
3711 }
3712 70 => {
3713 if chain != Chain::Mainnet {
3714 cfg.feature_flags.consensus_smart_ancestor_selection = true;
3716 cfg.feature_flags
3718 .consensus_round_prober_probe_accepted_rounds = true;
3719 }
3720
3721 cfg.poseidon_bn254_cost_per_block = Some(388);
3722
3723 cfg.gas_model_version = Some(9);
3724 cfg.feature_flags.native_charging_v2 = true;
3725 cfg.bls12381_bls12381_min_sig_verify_cost_base = Some(44064);
3726 cfg.bls12381_bls12381_min_pk_verify_cost_base = Some(49282);
3727 cfg.ecdsa_k1_secp256k1_verify_keccak256_cost_base = Some(1470);
3728 cfg.ecdsa_k1_secp256k1_verify_sha256_cost_base = Some(1470);
3729 cfg.ecdsa_r1_secp256r1_verify_sha256_cost_base = Some(4225);
3730 cfg.ecdsa_r1_secp256r1_verify_keccak256_cost_base = Some(4225);
3731 cfg.ecvrf_ecvrf_verify_cost_base = Some(4848);
3732 cfg.ed25519_ed25519_verify_cost_base = Some(1802);
3733
3734 cfg.ecdsa_r1_ecrecover_keccak256_cost_base = Some(1173);
3736 cfg.ecdsa_r1_ecrecover_sha256_cost_base = Some(1173);
3737 cfg.ecdsa_k1_ecrecover_keccak256_cost_base = Some(500);
3738 cfg.ecdsa_k1_ecrecover_sha256_cost_base = Some(500);
3739
3740 cfg.groth16_prepare_verifying_key_bls12381_cost_base = Some(53838);
3741 cfg.groth16_prepare_verifying_key_bn254_cost_base = Some(82010);
3742 cfg.groth16_verify_groth16_proof_internal_bls12381_cost_base = Some(72090);
3743 cfg.groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input =
3744 Some(8213);
3745 cfg.groth16_verify_groth16_proof_internal_bn254_cost_base = Some(115502);
3746 cfg.groth16_verify_groth16_proof_internal_bn254_cost_per_public_input =
3747 Some(9484);
3748
3749 cfg.hash_keccak256_cost_base = Some(10);
3750 cfg.hash_blake2b256_cost_base = Some(10);
3751
3752 cfg.group_ops_bls12381_decode_scalar_cost = Some(7);
3754 cfg.group_ops_bls12381_decode_g1_cost = Some(2848);
3755 cfg.group_ops_bls12381_decode_g2_cost = Some(3770);
3756 cfg.group_ops_bls12381_decode_gt_cost = Some(3068);
3757
3758 cfg.group_ops_bls12381_scalar_add_cost = Some(10);
3759 cfg.group_ops_bls12381_g1_add_cost = Some(1556);
3760 cfg.group_ops_bls12381_g2_add_cost = Some(3048);
3761 cfg.group_ops_bls12381_gt_add_cost = Some(188);
3762
3763 cfg.group_ops_bls12381_scalar_sub_cost = Some(10);
3764 cfg.group_ops_bls12381_g1_sub_cost = Some(1550);
3765 cfg.group_ops_bls12381_g2_sub_cost = Some(3019);
3766 cfg.group_ops_bls12381_gt_sub_cost = Some(497);
3767
3768 cfg.group_ops_bls12381_scalar_mul_cost = Some(11);
3769 cfg.group_ops_bls12381_g1_mul_cost = Some(4842);
3770 cfg.group_ops_bls12381_g2_mul_cost = Some(9108);
3771 cfg.group_ops_bls12381_gt_mul_cost = Some(27490);
3772
3773 cfg.group_ops_bls12381_scalar_div_cost = Some(91);
3774 cfg.group_ops_bls12381_g1_div_cost = Some(5091);
3775 cfg.group_ops_bls12381_g2_div_cost = Some(9206);
3776 cfg.group_ops_bls12381_gt_div_cost = Some(27804);
3777
3778 cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(2962);
3779 cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(8688);
3780
3781 cfg.group_ops_bls12381_g1_msm_base_cost = Some(62648);
3782 cfg.group_ops_bls12381_g2_msm_base_cost = Some(131192);
3783 cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(1333);
3784 cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(3216);
3785
3786 cfg.group_ops_bls12381_uncompressed_g1_to_g1_cost = Some(677);
3787 cfg.group_ops_bls12381_g1_to_uncompressed_g1_cost = Some(2099);
3788 cfg.group_ops_bls12381_uncompressed_g1_sum_base_cost = Some(77);
3789 cfg.group_ops_bls12381_uncompressed_g1_sum_cost_per_term = Some(26);
3790
3791 cfg.group_ops_bls12381_pairing_cost = Some(26897);
3792 cfg.group_ops_bls12381_uncompressed_g1_sum_max_terms = Some(1200);
3793
3794 cfg.validator_validate_metadata_cost_base = Some(20000);
3795 }
3796 71 => {
3797 cfg.sip_45_consensus_amplification_threshold = Some(5);
3798
3799 cfg.allowed_txn_cost_overage_burst_per_object_in_commit = Some(185_000_000);
3801 }
3802 72 => {
3803 cfg.feature_flags.convert_type_argument_error = true;
3804
3805 cfg.max_tx_gas = Some(50_000_000_000_000);
3808 cfg.max_gas_price = Some(50_000_000_000);
3810
3811 cfg.feature_flags.variant_nodes = true;
3812 }
3813 73 => {
3814 cfg.use_object_per_epoch_marker_table_v2 = Some(true);
3816
3817 if chain != Chain::Mainnet && chain != Chain::Testnet {
3818 cfg.consensus_gc_depth = Some(60);
3821 }
3822
3823 if chain != Chain::Mainnet {
3824 cfg.feature_flags.consensus_zstd_compression = true;
3826 }
3827
3828 cfg.feature_flags.consensus_smart_ancestor_selection = true;
3830 cfg.feature_flags
3832 .consensus_round_prober_probe_accepted_rounds = true;
3833
3834 cfg.feature_flags.per_object_congestion_control_mode =
3836 PerObjectCongestionControlMode::TotalGasBudgetWithCap;
3837 cfg.gas_budget_based_txn_cost_cap_factor = Some(400_000);
3838 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(37_000_000);
3839 cfg.max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit =
3840 Some(7_400_000); cfg.max_txn_cost_overage_per_object_in_commit = Some(u64::MAX);
3842 cfg.gas_budget_based_txn_cost_absolute_cap_commit_count = Some(50);
3843 cfg.allowed_txn_cost_overage_burst_per_object_in_commit = Some(370_000_000);
3844 }
3845 74 => {
3846 if chain != Chain::Mainnet && chain != Chain::Testnet {
3848 cfg.feature_flags.enable_nitro_attestation = true;
3849 }
3850 cfg.nitro_attestation_parse_base_cost = Some(53 * 50);
3851 cfg.nitro_attestation_parse_cost_per_byte = Some(50);
3852 cfg.nitro_attestation_verify_base_cost = Some(49632 * 50);
3853 cfg.nitro_attestation_verify_cost_per_cert = Some(52369 * 50);
3854
3855 cfg.feature_flags.consensus_zstd_compression = true;
3857
3858 if chain != Chain::Mainnet && chain != Chain::Testnet {
3859 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
3860 }
3861 }
3862 75 => {
3863 if chain != Chain::Mainnet {
3864 cfg.feature_flags.passkey_auth = true;
3865 }
3866 }
3867 76 => {
3868 if chain != Chain::Mainnet && chain != Chain::Testnet {
3869 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
3870 cfg.consensus_commit_rate_estimation_window_size = Some(10);
3871 }
3872 cfg.feature_flags.minimize_child_object_mutations = true;
3873
3874 if chain != Chain::Mainnet {
3875 cfg.feature_flags.accept_passkey_in_multisig = true;
3876 }
3877 }
3878 77 => {
3879 cfg.feature_flags.uncompressed_g1_group_elements = true;
3880
3881 if chain != Chain::Mainnet {
3882 cfg.consensus_gc_depth = Some(60);
3883 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
3884 }
3885 }
3886 78 => {
3887 cfg.feature_flags.move_native_context = true;
3888 cfg.tx_context_fresh_id_cost_base = Some(52);
3889 cfg.tx_context_sender_cost_base = Some(30);
3890 cfg.tx_context_epoch_cost_base = Some(30);
3891 cfg.tx_context_epoch_timestamp_ms_cost_base = Some(30);
3892 cfg.tx_context_sponsor_cost_base = Some(30);
3893 cfg.tx_context_gas_price_cost_base = Some(30);
3894 cfg.tx_context_gas_budget_cost_base = Some(30);
3895 cfg.tx_context_ids_created_cost_base = Some(30);
3896 cfg.tx_context_replace_cost_base = Some(30);
3897 cfg.gas_model_version = Some(10);
3898
3899 if chain != Chain::Mainnet {
3900 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
3901 cfg.consensus_commit_rate_estimation_window_size = Some(10);
3902
3903 cfg.feature_flags.per_object_congestion_control_mode =
3905 PerObjectCongestionControlMode::ExecutionTimeEstimate(
3906 ExecutionTimeEstimateParams {
3907 target_utilization: 30,
3908 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
3910 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
3912 stored_observations_limit: u64::MAX,
3913 stake_weighted_median_threshold: 0,
3914 default_none_duration_for_new_keys: false,
3915 observations_chunk_size: None,
3916 },
3917 );
3918 }
3919 }
3920 79 => {
3921 if chain != Chain::Mainnet {
3922 cfg.feature_flags.consensus_median_based_commit_timestamp = true;
3923
3924 cfg.consensus_bad_nodes_stake_threshold = Some(30);
3927
3928 cfg.feature_flags.consensus_batched_block_sync = true;
3929
3930 cfg.feature_flags.enable_nitro_attestation = true
3932 }
3933 cfg.feature_flags.normalize_ptb_arguments = true;
3934
3935 cfg.consensus_gc_depth = Some(60);
3936 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
3937 }
3938 80 => {
3939 cfg.max_ptb_value_size = Some(1024 * 1024);
3940 }
3941 81 => {
3942 cfg.feature_flags.consensus_median_based_commit_timestamp = true;
3943 cfg.feature_flags.enforce_checkpoint_timestamp_monotonicity = true;
3944 cfg.consensus_bad_nodes_stake_threshold = Some(30)
3945 }
3946 82 => {
3947 cfg.feature_flags.max_ptb_value_size_v2 = true;
3948 }
3949 83 => {
3950 if chain == Chain::Mainnet {
3951 let aliased: [u8; 32] = Hex::decode(
3953 "0x0b2da327ba6a4cacbe75dddd50e6e8bbf81d6496e92d66af9154c61c77f7332f",
3954 )
3955 .unwrap()
3956 .try_into()
3957 .unwrap();
3958
3959 cfg.aliased_addresses.push(AliasedAddress {
3961 original: Hex::decode("0xcd8962dad278d8b50fa0f9eb0186bfa4cbdecc6d59377214c88d0286a0ac9562").unwrap().try_into().unwrap(),
3962 aliased,
3963 allowed_tx_digests: vec![
3964 Base58::decode("B2eGLFoMHgj93Ni8dAJBfqGzo8EWSTLBesZzhEpTPA4").unwrap().try_into().unwrap(),
3965 ],
3966 });
3967
3968 cfg.aliased_addresses.push(AliasedAddress {
3969 original: Hex::decode("0xe28b50cef1d633ea43d3296a3f6b67ff0312a5f1a99f0af753c85b8b5de8ff06").unwrap().try_into().unwrap(),
3970 aliased,
3971 allowed_tx_digests: vec![
3972 Base58::decode("J4QqSAgp7VrQtQpMy5wDX4QGsCSEZu3U5KuDAkbESAge").unwrap().try_into().unwrap(),
3973 ],
3974 });
3975 }
3976
3977 if chain != Chain::Mainnet {
3980 cfg.feature_flags.resolve_type_input_ids_to_defining_id = true;
3981 cfg.transfer_party_transfer_internal_cost_base = Some(52);
3982
3983 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
3985 cfg.consensus_commit_rate_estimation_window_size = Some(10);
3986 cfg.feature_flags.per_object_congestion_control_mode =
3987 PerObjectCongestionControlMode::ExecutionTimeEstimate(
3988 ExecutionTimeEstimateParams {
3989 target_utilization: 30,
3990 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
3992 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
3994 stored_observations_limit: u64::MAX,
3995 stake_weighted_median_threshold: 0,
3996 default_none_duration_for_new_keys: false,
3997 observations_chunk_size: None,
3998 },
3999 );
4000
4001 cfg.feature_flags.consensus_batched_block_sync = true;
4003
4004 cfg.feature_flags.enable_nitro_attestation_upgraded_parsing = true;
4007 cfg.feature_flags.enable_nitro_attestation = true;
4008 }
4009 }
4010 84 => {
4011 if chain == Chain::Mainnet {
4012 cfg.feature_flags.resolve_type_input_ids_to_defining_id = true;
4013 cfg.transfer_party_transfer_internal_cost_base = Some(52);
4014
4015 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
4017 cfg.consensus_commit_rate_estimation_window_size = Some(10);
4018 cfg.feature_flags.per_object_congestion_control_mode =
4019 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4020 ExecutionTimeEstimateParams {
4021 target_utilization: 30,
4022 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4024 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4026 stored_observations_limit: u64::MAX,
4027 stake_weighted_median_threshold: 0,
4028 default_none_duration_for_new_keys: false,
4029 observations_chunk_size: None,
4030 },
4031 );
4032
4033 cfg.feature_flags.consensus_batched_block_sync = true;
4035
4036 cfg.feature_flags.enable_nitro_attestation_upgraded_parsing = true;
4039 cfg.feature_flags.enable_nitro_attestation = true;
4040 }
4041
4042 cfg.feature_flags.per_object_congestion_control_mode =
4044 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4045 ExecutionTimeEstimateParams {
4046 target_utilization: 30,
4047 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4049 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4051 stored_observations_limit: 20,
4052 stake_weighted_median_threshold: 0,
4053 default_none_duration_for_new_keys: false,
4054 observations_chunk_size: None,
4055 },
4056 );
4057 cfg.feature_flags.allow_unbounded_system_objects = true;
4058 }
4059 85 => {
4060 if chain != Chain::Mainnet && chain != Chain::Testnet {
4061 cfg.feature_flags.enable_party_transfer = true;
4062 }
4063
4064 cfg.feature_flags
4065 .record_consensus_determined_version_assignments_in_prologue_v2 = true;
4066 cfg.feature_flags.disallow_self_identifier = true;
4067 cfg.feature_flags.per_object_congestion_control_mode =
4068 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4069 ExecutionTimeEstimateParams {
4070 target_utilization: 50,
4071 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4073 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4075 stored_observations_limit: 20,
4076 stake_weighted_median_threshold: 0,
4077 default_none_duration_for_new_keys: false,
4078 observations_chunk_size: None,
4079 },
4080 );
4081 }
4082 86 => {
4083 cfg.feature_flags.type_tags_in_object_runtime = true;
4084 cfg.max_move_enum_variants = Some(move_core_types::VARIANT_COUNT_MAX);
4085
4086 cfg.feature_flags.per_object_congestion_control_mode =
4088 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4089 ExecutionTimeEstimateParams {
4090 target_utilization: 50,
4091 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4093 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4095 stored_observations_limit: 20,
4096 stake_weighted_median_threshold: 3334,
4097 default_none_duration_for_new_keys: false,
4098 observations_chunk_size: None,
4099 },
4100 );
4101 if chain != Chain::Mainnet {
4103 cfg.feature_flags.enable_party_transfer = true;
4104 }
4105 }
4106 87 => {
4107 if chain == Chain::Mainnet {
4108 cfg.feature_flags.record_time_estimate_processed = true;
4109 }
4110 cfg.feature_flags.better_adapter_type_resolution_errors = true;
4111 }
4112 88 => {
4113 cfg.feature_flags.record_time_estimate_processed = true;
4114 cfg.tx_context_rgp_cost_base = Some(30);
4115 cfg.feature_flags
4116 .ignore_execution_time_observations_after_certs_closed = true;
4117
4118 cfg.feature_flags.per_object_congestion_control_mode =
4121 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4122 ExecutionTimeEstimateParams {
4123 target_utilization: 50,
4124 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4126 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4128 stored_observations_limit: 20,
4129 stake_weighted_median_threshold: 3334,
4130 default_none_duration_for_new_keys: true,
4131 observations_chunk_size: None,
4132 },
4133 );
4134 }
4135 89 => {
4136 cfg.feature_flags.dependency_linkage_error = true;
4137 cfg.feature_flags.additional_multisig_checks = true;
4138 }
4139 90 => {
4140 cfg.max_gas_price_rgp_factor_for_aborted_transactions = Some(100);
4142 cfg.feature_flags.debug_fatal_on_move_invariant_violation = true;
4143 cfg.feature_flags.additional_consensus_digest_indirect_state = true;
4144 cfg.feature_flags.accept_passkey_in_multisig = true;
4145 cfg.feature_flags.passkey_auth = true;
4146 cfg.feature_flags.check_for_init_during_upgrade = true;
4147
4148 if chain != Chain::Mainnet {
4150 cfg.feature_flags.mysticeti_fastpath = true;
4151 }
4152 }
4153 91 => {
4154 cfg.feature_flags.per_command_shared_object_transfer_rules = true;
4155 }
4156 92 => {
4157 cfg.feature_flags.per_command_shared_object_transfer_rules = false;
4158 }
4159 93 => {
4160 cfg.feature_flags
4161 .consensus_checkpoint_signature_key_includes_digest = true;
4162 }
4163 94 => {
4164 cfg.feature_flags.per_object_congestion_control_mode =
4166 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4167 ExecutionTimeEstimateParams {
4168 target_utilization: 50,
4169 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4171 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4173 stored_observations_limit: 18,
4174 stake_weighted_median_threshold: 3334,
4175 default_none_duration_for_new_keys: true,
4176 observations_chunk_size: None,
4177 },
4178 );
4179
4180 cfg.feature_flags.enable_party_transfer = true;
4182 }
4183 95 => {
4184 cfg.type_name_id_base_cost = Some(52);
4185
4186 cfg.max_transactions_per_checkpoint = Some(20_000);
4188 }
4189 96 => {
4190 if chain != Chain::Mainnet && chain != Chain::Testnet {
4192 cfg.feature_flags
4193 .include_checkpoint_artifacts_digest_in_summary = true;
4194 }
4195 cfg.feature_flags.correct_gas_payment_limit_check = true;
4196 cfg.feature_flags.authority_capabilities_v2 = true;
4197 cfg.feature_flags.use_mfp_txns_in_load_initial_object_debts = true;
4198 cfg.feature_flags.cancel_for_failed_dkg_early = true;
4199 cfg.feature_flags.enable_coin_registry = true;
4200
4201 cfg.feature_flags.mysticeti_fastpath = true;
4203 }
4204 97 => {
4205 cfg.feature_flags.additional_borrow_checks = true;
4206 }
4207 98 => {
4208 cfg.event_emit_auth_stream_cost = Some(52);
4209 cfg.feature_flags.better_loader_errors = true;
4210 cfg.feature_flags.generate_df_type_layouts = true;
4211 }
4212 99 => {
4213 cfg.feature_flags.use_new_commit_handler = true;
4214 }
4215 100 => {
4216 cfg.feature_flags.private_generics_verifier_v2 = true;
4217 }
4218 101 => {
4219 cfg.feature_flags.create_root_accumulator_object = true;
4220 cfg.max_updates_per_settlement_txn = Some(100);
4221 if chain != Chain::Mainnet {
4222 cfg.feature_flags.enable_poseidon = true;
4223 }
4224 }
4225 102 => {
4226 cfg.feature_flags.per_object_congestion_control_mode =
4230 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4231 ExecutionTimeEstimateParams {
4232 target_utilization: 50,
4233 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4235 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4237 stored_observations_limit: 180,
4238 stake_weighted_median_threshold: 3334,
4239 default_none_duration_for_new_keys: true,
4240 observations_chunk_size: Some(18),
4241 },
4242 );
4243 cfg.feature_flags.deprecate_global_storage_ops = true;
4244 }
4245 103 => {}
4246 104 => {
4247 cfg.translation_per_command_base_charge = Some(1);
4248 cfg.translation_per_input_base_charge = Some(1);
4249 cfg.translation_pure_input_per_byte_charge = Some(1);
4250 cfg.translation_per_type_node_charge = Some(1);
4251 cfg.translation_per_reference_node_charge = Some(1);
4252 cfg.translation_per_linkage_entry_charge = Some(10);
4253 cfg.gas_model_version = Some(11);
4254 cfg.feature_flags.abstract_size_in_object_runtime = true;
4255 cfg.feature_flags.object_runtime_charge_cache_load_gas = true;
4256 cfg.dynamic_field_hash_type_and_key_cost_base = Some(52);
4257 cfg.dynamic_field_add_child_object_cost_base = Some(52);
4258 cfg.dynamic_field_add_child_object_value_cost_per_byte = Some(1);
4259 cfg.dynamic_field_borrow_child_object_cost_base = Some(52);
4260 cfg.dynamic_field_borrow_child_object_child_ref_cost_per_byte = Some(1);
4261 cfg.dynamic_field_remove_child_object_cost_base = Some(52);
4262 cfg.dynamic_field_remove_child_object_child_cost_per_byte = Some(1);
4263 cfg.dynamic_field_has_child_object_cost_base = Some(52);
4264 cfg.dynamic_field_has_child_object_with_ty_cost_base = Some(52);
4265 cfg.feature_flags.enable_ptb_execution_v2 = true;
4266
4267 cfg.poseidon_bn254_cost_base = Some(260);
4268
4269 cfg.feature_flags.consensus_skip_gced_accept_votes = true;
4270
4271 if chain != Chain::Mainnet {
4272 cfg.feature_flags
4273 .enable_nitro_attestation_all_nonzero_pcrs_parsing = true;
4274 }
4275
4276 cfg.feature_flags
4277 .include_cancelled_randomness_txns_in_prologue = true;
4278 }
4279 105 => {
4280 cfg.feature_flags.enable_multi_epoch_transaction_expiration = true;
4281 cfg.feature_flags.disable_preconsensus_locking = true;
4282
4283 if chain != Chain::Mainnet {
4284 cfg.feature_flags
4285 .enable_nitro_attestation_always_include_required_pcrs_parsing = true;
4286 }
4287 }
4288 106 => {
4289 cfg.accumulator_object_storage_cost = Some(7600);
4291
4292 if chain != Chain::Mainnet && chain != Chain::Testnet {
4293 cfg.feature_flags.enable_accumulators = true;
4294 cfg.feature_flags.enable_address_balance_gas_payments = true;
4295 cfg.feature_flags.enable_authenticated_event_streams = true;
4296 cfg.feature_flags.enable_object_funds_withdraw = true;
4297 }
4298 }
4299 107 => {
4300 cfg.feature_flags
4301 .consensus_skip_gced_blocks_in_direct_finalization = true;
4302
4303 if in_integration_test() {
4305 cfg.consensus_gc_depth = Some(6);
4306 cfg.consensus_max_num_transactions_in_block = Some(8);
4307 }
4308 }
4309 108 => {
4310 cfg.feature_flags.gas_rounding_halve_digits = true;
4311 cfg.feature_flags.flexible_tx_context_positions = true;
4312 cfg.feature_flags.disable_entry_point_signature_check = true;
4313
4314 if chain != Chain::Mainnet {
4315 cfg.feature_flags.address_aliases = true;
4316
4317 cfg.feature_flags.enable_accumulators = true;
4318 cfg.feature_flags.enable_address_balance_gas_payments = true;
4319 }
4320
4321 cfg.feature_flags.enable_poseidon = true;
4322 }
4323 109 => {
4324 cfg.binary_variant_handles = Some(1024);
4325 cfg.binary_variant_instantiation_handles = Some(1024);
4326 cfg.feature_flags.restrict_hot_or_not_entry_functions = true;
4327 }
4328 110 => {
4329 cfg.feature_flags
4330 .enable_nitro_attestation_all_nonzero_pcrs_parsing = true;
4331 cfg.feature_flags
4332 .enable_nitro_attestation_always_include_required_pcrs_parsing = true;
4333 if chain != Chain::Mainnet && chain != Chain::Testnet {
4334 cfg.feature_flags.split_checkpoints_in_consensus_handler = true;
4335 }
4336 cfg.feature_flags.validate_zklogin_public_identifier = true;
4337 cfg.feature_flags.fix_checkpoint_signature_mapping = true;
4338 cfg.feature_flags
4339 .consensus_always_accept_system_transactions = true;
4340 if chain != Chain::Mainnet {
4341 cfg.feature_flags.enable_object_funds_withdraw = true;
4342 }
4343 }
4344 111 => {
4345 cfg.feature_flags.validator_metadata_verify_v2 = true;
4346 }
4347 112 => {
4348 cfg.group_ops_ristretto_decode_scalar_cost = Some(7);
4349 cfg.group_ops_ristretto_decode_point_cost = Some(200);
4350 cfg.group_ops_ristretto_scalar_add_cost = Some(10);
4351 cfg.group_ops_ristretto_point_add_cost = Some(500);
4352 cfg.group_ops_ristretto_scalar_sub_cost = Some(10);
4353 cfg.group_ops_ristretto_point_sub_cost = Some(500);
4354 cfg.group_ops_ristretto_scalar_mul_cost = Some(11);
4355 cfg.group_ops_ristretto_point_mul_cost = Some(1200);
4356 cfg.group_ops_ristretto_scalar_div_cost = Some(151);
4357 cfg.group_ops_ristretto_point_div_cost = Some(2500);
4358
4359 if chain != Chain::Mainnet && chain != Chain::Testnet {
4360 cfg.feature_flags.enable_ristretto255_group_ops = true;
4361 }
4362 }
4363 113 => {
4364 cfg.feature_flags.address_balance_gas_check_rgp_at_signing = true;
4365 if chain != Chain::Mainnet && chain != Chain::Testnet {
4366 cfg.feature_flags.defer_unpaid_amplification = true;
4367 }
4368 }
4369 114 => {
4370 cfg.feature_flags.randomize_checkpoint_tx_limit_in_tests = true;
4371 cfg.feature_flags.address_balance_gas_reject_gas_coin_arg = true;
4372 if chain != Chain::Mainnet {
4373 cfg.feature_flags.split_checkpoints_in_consensus_handler = true;
4374 cfg.feature_flags.enable_authenticated_event_streams = true;
4375 cfg.feature_flags
4376 .include_checkpoint_artifacts_digest_in_summary = true;
4377 }
4378 }
4379 115 => {
4380 cfg.feature_flags.normalize_depth_formula = true;
4381 }
4382 116 => {
4383 cfg.feature_flags.gasless_transaction_drop_safety = true;
4384 cfg.feature_flags.address_aliases = true;
4385 cfg.feature_flags.relax_valid_during_for_owned_inputs = true;
4386 cfg.feature_flags.defer_unpaid_amplification = false;
4388 cfg.feature_flags.enable_display_registry = true;
4389 }
4390 117 => {}
4391 118 => {
4392 cfg.feature_flags.use_coin_party_owner = true;
4393 }
4394 119 => {
4395 cfg.execution_version = Some(4);
4397 cfg.feature_flags.address_balance_gas_reject_gas_coin_arg = false;
4398 cfg.feature_flags.merge_randomness_into_checkpoint = true;
4399 if chain != Chain::Mainnet {
4400 cfg.feature_flags.enable_gasless = true;
4401 cfg.gasless_max_computation_units = Some(50_000);
4402 cfg.gasless_allowed_token_types = Some(vec![]);
4403 cfg.feature_flags.enable_coin_reservation_obj_refs = true;
4404 cfg.feature_flags
4405 .convert_withdrawal_compatibility_ptb_arguments = true;
4406 }
4407 cfg.gasless_max_unused_inputs = Some(1);
4408 cfg.gasless_max_pure_input_bytes = Some(32);
4409 if chain == Chain::Testnet {
4410 cfg.gasless_allowed_token_types = Some(vec![(TESTNET_USDC.to_string(), 0)]);
4411 }
4412 cfg.transfer_receive_object_cost_per_byte = Some(1);
4413 cfg.transfer_receive_object_type_cost_per_byte = Some(2);
4414 }
4415 120 => {
4416 cfg.feature_flags.disallow_jump_orphans = true;
4417 }
4418 121 => {
4419 if chain != Chain::Mainnet {
4421 cfg.feature_flags.defer_unpaid_amplification = true;
4422 cfg.gasless_max_tps = Some(50);
4423 }
4424 cfg.feature_flags
4425 .early_return_receive_object_mismatched_type = true;
4426 }
4427 122 => {
4428 cfg.feature_flags.defer_unpaid_amplification = true;
4430 cfg.verify_bulletproofs_ristretto255_base_cost = Some(30000);
4432 cfg.verify_bulletproofs_ristretto255_cost_per_bit_and_commitment = Some(6500);
4433 if chain != Chain::Mainnet && chain != Chain::Testnet {
4434 cfg.feature_flags.enable_verify_bulletproofs_ristretto255 = true;
4435 }
4436 cfg.feature_flags.gasless_verify_remaining_balance = true;
4437 cfg.include_special_package_amendments = match chain {
4438 Chain::Mainnet => Some(MAINNET_LINKAGE_AMENDMENTS.clone()),
4439 Chain::Testnet => Some(TESTNET_LINKAGE_AMENDMENTS.clone()),
4440 Chain::Unknown => None,
4441 };
4442 cfg.gasless_max_tx_size_bytes = Some(16 * 1024);
4443 cfg.gasless_max_tps = Some(300);
4444 cfg.gasless_max_computation_units = Some(5_000);
4445 }
4446 123 => {
4447 cfg.gas_model_version = Some(13);
4448 }
4449 124 => {
4450 if chain != Chain::Mainnet && chain != Chain::Testnet {
4451 cfg.feature_flags.timestamp_based_epoch_close = true;
4452 }
4453 cfg.gas_model_version = Some(14);
4454 cfg.feature_flags.limit_groth16_pvk_inputs = true;
4455
4456 cfg.feature_flags.enable_accumulators = true;
4462 cfg.feature_flags.enable_address_balance_gas_payments = true;
4463 cfg.feature_flags.enable_authenticated_event_streams = true;
4464 cfg.feature_flags.enable_coin_reservation_obj_refs = true;
4465 cfg.feature_flags.enable_object_funds_withdraw = true;
4466 cfg.feature_flags
4467 .convert_withdrawal_compatibility_ptb_arguments = true;
4468 cfg.feature_flags.split_checkpoints_in_consensus_handler = true;
4469 cfg.feature_flags
4470 .include_checkpoint_artifacts_digest_in_summary = true;
4471 cfg.feature_flags.enable_gasless = true;
4472
4473 if chain == Chain::Mainnet {
4478 cfg.gasless_allowed_token_types = Some(vec![
4479 (MAINNET_USDC.to_string(), 10_000),
4480 (MAINNET_USDSUI.to_string(), 10_000),
4481 (MAINNET_SUI_USDE.to_string(), 10_000),
4482 (MAINNET_USDY.to_string(), 10_000),
4483 (MAINNET_FDUSD.to_string(), 10_000),
4484 (MAINNET_AUSD.to_string(), 10_000),
4485 (MAINNET_USDB.to_string(), 10_000),
4486 ]);
4487 }
4488 }
4489 125 => {
4490 cfg.feature_flags.granular_post_execution_checks = true;
4491 if chain != Chain::Mainnet {
4492 cfg.feature_flags.timestamp_based_epoch_close = true;
4493 }
4494 }
4495 126 => {
4496 cfg.feature_flags.early_exit_on_iffw = true;
4497 }
4498 127 => {
4499 cfg.feature_flags.always_advance_dkg_to_resolution = true;
4500
4501 cfg.verify_bulletproofs_ristretto255_base_cost = Some(23866);
4502 cfg.verify_bulletproofs_ristretto255_cost_per_bit_and_commitment = Some(1324);
4503 cfg.group_ops_ristretto_decode_scalar_cost = Some(5);
4504 cfg.group_ops_ristretto_decode_point_cost = Some(216);
4505 cfg.group_ops_ristretto_scalar_add_cost = Some(2);
4506 cfg.group_ops_ristretto_point_add_cost = Some(8);
4507 cfg.group_ops_ristretto_scalar_sub_cost = Some(2);
4508 cfg.group_ops_ristretto_point_sub_cost = Some(8);
4509 cfg.group_ops_ristretto_scalar_mul_cost = Some(5);
4510 cfg.group_ops_ristretto_point_mul_cost = Some(1763);
4511 cfg.group_ops_ristretto_scalar_div_cost = Some(557);
4512 cfg.group_ops_ristretto_point_div_cost = Some(2244);
4513
4514 if chain != Chain::Mainnet {
4515 cfg.feature_flags.enable_ristretto255_group_ops = true;
4516 cfg.feature_flags.enable_verify_bulletproofs_ristretto255 = true;
4517 }
4518
4519 cfg.feature_flags.timestamp_based_epoch_close = true;
4520 }
4521 128 => {
4522 cfg.max_generic_instantiation_type_nodes_per_function = Some(10_000);
4523 cfg.max_generic_instantiation_type_nodes_per_module = Some(500_000);
4524 cfg.binary_enum_defs = Some(200);
4525 cfg.binary_enum_def_instantiations = Some(100);
4526 }
4527 129 => {
4528 cfg.feature_flags.enable_unified_linkage = true;
4529 }
4530 130 => {
4531 cfg.feature_flags.record_net_unsettled_object_withdraws = true;
4532 cfg.feature_flags.enable_init_on_upgrade = true;
4533 cfg.epoch_close_deadline_ms = Some(120_000);
4534 cfg.scratch_add_cost_base = Some(13);
4535 cfg.scratch_read_cost_base = Some(13);
4536 cfg.scratch_read_value_cost = Some(1);
4537 cfg.scratch_remove_cost_base = Some(13);
4538 cfg.scratch_exists_cost_base = Some(13);
4539 cfg.scratch_exists_with_type_cost_base = Some(13);
4540 cfg.scratch_exists_with_type_type_cost = Some(1);
4541 let max_commands = cfg.max_programmable_tx_commands() as u64;
4542 cfg.max_scratch_pad_size = Some(16 * max_commands);
4543 if chain != Chain::Mainnet && chain != Chain::Testnet {
4545 cfg.feature_flags.zklogin_circuit_mode = 1;
4546 }
4547 }
4548 131 => {
4549 cfg.feature_flags.share_transaction_deny_config_in_consensus = true;
4550 cfg.feature_flags.framework_tx_context_mut_restrictions = true;
4551 }
4552 132 => {
4553 if chain != Chain::Mainnet && chain != Chain::Testnet {
4554 cfg.feature_flags.defer_owned_object_double_spend = true;
4555 cfg.feature_flags.create_forwarding_address_registry = true;
4556 }
4557 cfg.object_record_new_uid_from_hash_cost_base = Some(1);
4558 }
4559 _ => panic!("unsupported version {:?}", version),
4570 }
4571 }
4572
4573 cfg
4574 }
4575
4576 pub fn apply_seeded_test_overrides(&mut self, seed: &[u8; 32]) {
4577 if !self.feature_flags.randomize_checkpoint_tx_limit_in_tests
4578 || !self.feature_flags.split_checkpoints_in_consensus_handler
4579 {
4580 return;
4581 }
4582
4583 if !mysten_common::in_test_configuration() {
4584 return;
4585 }
4586
4587 use rand::{Rng, SeedableRng, rngs::StdRng};
4588 let mut rng = StdRng::from_seed(*seed);
4589 let max_txns = rng.gen_range(10..=100u64);
4590 info!("seeded test override: max_transactions_per_checkpoint = {max_txns}");
4591 self.max_transactions_per_checkpoint = Some(max_txns);
4592 }
4593
4594 pub fn verifier_config(&self, signing_limits: Option<(usize, usize, usize)>) -> VerifierConfig {
4600 let (
4601 max_back_edges_per_function,
4602 max_back_edges_per_module,
4603 sanity_check_with_regex_reference_safety,
4604 ) = if let Some((
4605 max_back_edges_per_function,
4606 max_back_edges_per_module,
4607 sanity_check_with_regex_reference_safety,
4608 )) = signing_limits
4609 {
4610 (
4611 Some(max_back_edges_per_function),
4612 Some(max_back_edges_per_module),
4613 Some(sanity_check_with_regex_reference_safety),
4614 )
4615 } else {
4616 (None, None, None)
4617 };
4618
4619 let additional_borrow_checks = if signing_limits.is_some() {
4620 true
4622 } else {
4623 self.additional_borrow_checks()
4624 };
4625 let deprecate_global_storage_ops = if signing_limits.is_some() {
4626 true
4628 } else {
4629 self.deprecate_global_storage_ops()
4630 };
4631
4632 VerifierConfig {
4633 max_loop_depth: Some(self.max_loop_depth() as usize),
4634 max_generic_instantiation_length: Some(self.max_generic_instantiation_length() as usize),
4635 max_function_parameters: Some(self.max_function_parameters() as usize),
4636 max_basic_blocks: Some(self.max_basic_blocks() as usize),
4637 max_value_stack_size: self.max_value_stack_size() as usize,
4638 max_type_nodes: Some(self.max_type_nodes() as usize),
4639 max_generic_instantiation_type_nodes_per_function: self
4640 .max_generic_instantiation_type_nodes_per_function_as_option()
4641 .map(|v| v as usize),
4642 max_generic_instantiation_type_nodes_per_module: self
4643 .max_generic_instantiation_type_nodes_per_module_as_option()
4644 .map(|v| v as usize),
4645 max_push_size: Some(self.max_push_size() as usize),
4646 max_dependency_depth: Some(self.max_dependency_depth() as usize),
4647 max_fields_in_struct: Some(self.max_fields_in_struct() as usize),
4648 max_function_definitions: Some(self.max_function_definitions() as usize),
4649 max_data_definitions: Some(self.max_struct_definitions() as usize),
4650 max_constant_vector_len: Some(self.max_move_vector_len()),
4651 max_back_edges_per_function,
4652 max_back_edges_per_module,
4653 max_basic_blocks_in_script: None,
4654 max_identifier_len: self.max_move_identifier_len_as_option(), disallow_self_identifier: self.feature_flags.disallow_self_identifier,
4656 allow_receiving_object_id: self.allow_receiving_object_id(),
4657 reject_mutable_random_on_entry_functions: self
4658 .reject_mutable_random_on_entry_functions(),
4659 bytecode_version: self.move_binary_format_version(),
4660 max_variants_in_enum: self.max_move_enum_variants_as_option(),
4661 additional_borrow_checks,
4662 better_loader_errors: self.better_loader_errors(),
4663 private_generics_verifier_v2: self.private_generics_verifier_v2(),
4664 sanity_check_with_regex_reference_safety: sanity_check_with_regex_reference_safety
4665 .map(|limit| limit as u128),
4666 deprecate_global_storage_ops,
4667 disable_entry_point_signature_check: self.disable_entry_point_signature_check(),
4668 switch_to_regex_reference_safety: false,
4669 framework_tx_context_mut_restrictions: self.framework_tx_context_mut_restrictions(),
4670 disallow_jump_orphans: self.disallow_jump_orphans(),
4671 }
4672 }
4673
4674 pub fn binary_config(
4675 &self,
4676 override_deprecate_global_storage_ops_during_deserialization: Option<bool>,
4677 ) -> BinaryConfig {
4678 let deprecate_global_storage_ops =
4679 override_deprecate_global_storage_ops_during_deserialization
4680 .unwrap_or_else(|| self.deprecate_global_storage_ops());
4681 BinaryConfig::new(
4682 self.move_binary_format_version(),
4683 self.min_move_binary_format_version_as_option()
4684 .unwrap_or(VERSION_1),
4685 self.no_extraneous_module_bytes(),
4686 deprecate_global_storage_ops,
4687 TableConfig {
4688 module_handles: self.binary_module_handles_as_option().unwrap_or(u16::MAX),
4689 datatype_handles: self.binary_struct_handles_as_option().unwrap_or(u16::MAX),
4690 function_handles: self.binary_function_handles_as_option().unwrap_or(u16::MAX),
4691 function_instantiations: self
4692 .binary_function_instantiations_as_option()
4693 .unwrap_or(u16::MAX),
4694 signatures: self.binary_signatures_as_option().unwrap_or(u16::MAX),
4695 constant_pool: self.binary_constant_pool_as_option().unwrap_or(u16::MAX),
4696 identifiers: self.binary_identifiers_as_option().unwrap_or(u16::MAX),
4697 address_identifiers: self
4698 .binary_address_identifiers_as_option()
4699 .unwrap_or(u16::MAX),
4700 struct_defs: self.binary_struct_defs_as_option().unwrap_or(u16::MAX),
4701 struct_def_instantiations: self
4702 .binary_struct_def_instantiations_as_option()
4703 .unwrap_or(u16::MAX),
4704 function_defs: self.binary_function_defs_as_option().unwrap_or(u16::MAX),
4705 field_handles: self.binary_field_handles_as_option().unwrap_or(u16::MAX),
4706 field_instantiations: self
4707 .binary_field_instantiations_as_option()
4708 .unwrap_or(u16::MAX),
4709 friend_decls: self.binary_friend_decls_as_option().unwrap_or(u16::MAX),
4710 enum_defs: self.binary_enum_defs_as_option().unwrap_or(u16::MAX),
4711 enum_def_instantiations: self
4712 .binary_enum_def_instantiations_as_option()
4713 .unwrap_or(u16::MAX),
4714 variant_handles: self.binary_variant_handles_as_option().unwrap_or(u16::MAX),
4715 variant_instantiation_handles: self
4716 .binary_variant_instantiation_handles_as_option()
4717 .unwrap_or(u16::MAX),
4718 },
4719 )
4720 }
4721
4722 pub fn apply_overrides_for_testing(
4726 override_fn: impl Fn(ProtocolVersion, Self) -> Self + Send + Sync + 'static,
4727 ) -> OverrideGuard {
4728 let mut cur = CONFIG_OVERRIDE.lock().unwrap();
4729 assert!(cur.is_none(), "config override already present");
4730 *cur = Some(Box::new(override_fn));
4731 OverrideGuard
4732 }
4733
4734 fn apply_config_override(version: ProtocolVersion, mut ret: Self) -> Self {
4735 if let Some(override_fn) = CONFIG_OVERRIDE.lock().unwrap().as_ref() {
4736 warn!(
4737 "overriding ProtocolConfig settings with custom settings (you should not see this log outside of tests)"
4738 );
4739 ret = override_fn(version, ret);
4740 }
4741 ret
4742 }
4743}
4744
4745impl ProtocolConfig {
4749 pub fn set_execution_version_for_testing(&mut self, val: u64) {
4753 let current = self.execution_version.unwrap_or(0);
4754 assert!(
4755 val >= current,
4756 "cannot downgrade execution_version from {current} to {val}: running an old \
4757 executor against a newer protocol config/framework is unsupported. To test \
4758 frozen executor behavior, start from the last protocol version of that executor \
4759 instead, so genesis loads the matching framework snapshot (see \
4760 test_address_balance_gas_v3_accumulator_sign)."
4761 );
4762 self.execution_version = Some(val);
4763 }
4764
4765 pub fn set_zklogin_circuit_mode_for_testing(&mut self, val: u64) {
4768 self.feature_flags.zklogin_circuit_mode = val
4769 }
4770
4771 pub fn set_per_object_congestion_control_mode_for_testing(
4772 &mut self,
4773 val: PerObjectCongestionControlMode,
4774 ) {
4775 self.feature_flags.per_object_congestion_control_mode = val;
4776 }
4777
4778 pub fn set_consensus_choice_for_testing(&mut self, val: ConsensusChoice) {
4779 self.feature_flags.consensus_choice = val;
4780 }
4781
4782 pub fn set_consensus_network_for_testing(&mut self, val: ConsensusNetwork) {
4783 self.feature_flags.consensus_network = val;
4784 }
4785
4786 pub fn set_zklogin_max_epoch_upper_bound_delta_for_testing(&mut self, val: Option<u64>) {
4787 self.feature_flags.zklogin_max_epoch_upper_bound_delta = val
4788 }
4789
4790 pub fn set_mysticeti_num_leaders_per_round_for_testing(&mut self, val: Option<usize>) {
4791 self.feature_flags.mysticeti_num_leaders_per_round = val;
4792 }
4793
4794 pub fn disable_accumulators_for_testing(&mut self) {
4795 self.feature_flags.enable_accumulators = false;
4796 self.feature_flags.enable_address_balance_gas_payments = false;
4797 }
4798
4799 pub fn enable_coin_reservation_for_testing(&mut self) {
4800 self.feature_flags.enable_coin_reservation_obj_refs = true;
4801 self.feature_flags
4802 .convert_withdrawal_compatibility_ptb_arguments = true;
4803 self.execution_version = Some(self.execution_version.map_or(4, |v| v.max(4)));
4806 }
4807
4808 pub fn disable_coin_reservation_for_testing(&mut self) {
4809 self.feature_flags.enable_coin_reservation_obj_refs = false;
4810 self.feature_flags
4811 .convert_withdrawal_compatibility_ptb_arguments = false;
4812 }
4813
4814 pub fn enable_address_balance_gas_payments_for_testing(&mut self) {
4815 self.feature_flags.enable_accumulators = true;
4816 self.feature_flags.allow_private_accumulator_entrypoints = true;
4817 self.feature_flags.enable_address_balance_gas_payments = true;
4818 self.feature_flags.address_balance_gas_check_rgp_at_signing = true;
4819 self.feature_flags.address_balance_gas_reject_gas_coin_arg = false;
4820 self.execution_version = Some(self.execution_version.map_or(4, |v| v.max(4)))
4821 }
4822
4823 pub fn enable_gasless_for_testing(&mut self) {
4824 self.enable_address_balance_gas_payments_for_testing();
4825 self.feature_flags.enable_gasless = true;
4826 self.feature_flags.gasless_verify_remaining_balance = true;
4827 self.gasless_max_computation_units = Some(5_000);
4828 self.gasless_allowed_token_types = Some(vec![]);
4829 self.gasless_max_tps = Some(1000);
4830 self.gasless_max_tx_size_bytes = Some(16 * 1024);
4831 }
4832
4833 pub fn disable_gasless_for_testing(&mut self) {
4834 self.feature_flags.enable_gasless = false;
4835 self.gasless_max_computation_units = None;
4836 self.gasless_allowed_token_types = None;
4837 }
4838
4839 pub fn enable_authenticated_event_streams_for_testing(&mut self) {
4840 self.feature_flags.enable_accumulators = true;
4841 self.feature_flags.enable_authenticated_event_streams = true;
4842 self.feature_flags
4843 .include_checkpoint_artifacts_digest_in_summary = true;
4844 self.feature_flags.split_checkpoints_in_consensus_handler = true;
4845 }
4846}
4847
4848type OverrideFn = dyn Fn(ProtocolVersion, ProtocolConfig) -> ProtocolConfig + Send + Sync;
4849
4850static CONFIG_OVERRIDE: Mutex<Option<Box<OverrideFn>>> = Mutex::new(None);
4851
4852#[must_use]
4853pub struct OverrideGuard;
4854
4855impl Drop for OverrideGuard {
4856 fn drop(&mut self) {
4857 info!("restoring override fn");
4858 *CONFIG_OVERRIDE.lock().unwrap() = None;
4859 }
4860}
4861
4862#[derive(PartialEq, Eq)]
4865pub enum LimitThresholdCrossed {
4866 None,
4867 Soft(u128, u128),
4868 Hard(u128, u128),
4869}
4870
4871pub fn check_limit_in_range<T: Into<V>, U: Into<V>, V: PartialOrd + Into<u128>>(
4874 x: T,
4875 soft_limit: U,
4876 hard_limit: V,
4877) -> LimitThresholdCrossed {
4878 let x: V = x.into();
4879 let soft_limit: V = soft_limit.into();
4880
4881 debug_assert!(soft_limit <= hard_limit);
4882
4883 if x >= hard_limit {
4886 LimitThresholdCrossed::Hard(x.into(), hard_limit.into())
4887 } else if x < soft_limit {
4888 LimitThresholdCrossed::None
4889 } else {
4890 LimitThresholdCrossed::Soft(x.into(), soft_limit.into())
4891 }
4892}
4893
4894#[macro_export]
4895macro_rules! check_limit {
4896 ($x:expr, $hard:expr) => {
4897 check_limit!($x, $hard, $hard)
4898 };
4899 ($x:expr, $soft:expr, $hard:expr) => {
4900 check_limit_in_range($x as u64, $soft, $hard)
4901 };
4902}
4903
4904#[macro_export]
4908macro_rules! check_limit_by_meter {
4909 ($is_metered:expr, $x:expr, $metered_limit:expr, $unmetered_hard_limit:expr, $metric:expr) => {{
4910 let (h, metered_str) = if $is_metered {
4912 ($metered_limit, "metered")
4913 } else {
4914 ($unmetered_hard_limit, "unmetered")
4916 };
4917 use sui_protocol_config::check_limit_in_range;
4918 let result = check_limit_in_range($x as u64, $metered_limit, h);
4919 match result {
4920 LimitThresholdCrossed::None => {}
4921 LimitThresholdCrossed::Soft(_, _) => {
4922 $metric.with_label_values(&[metered_str, "soft"]).inc();
4923 }
4924 LimitThresholdCrossed::Hard(_, _) => {
4925 $metric.with_label_values(&[metered_str, "hard"]).inc();
4926 }
4927 };
4928 result
4929 }};
4930}
4931
4932pub type Amendments = BTreeMap<AccountAddress, BTreeMap<AccountAddress, AccountAddress>>;
4935
4936static MAINNET_LINKAGE_AMENDMENTS: LazyLock<Arc<Amendments>> =
4937 LazyLock::new(|| parse_amendments(include_str!("mainnet_amendments.json")));
4938
4939static TESTNET_LINKAGE_AMENDMENTS: LazyLock<Arc<Amendments>> =
4940 LazyLock::new(|| parse_amendments(include_str!("testnet_amendments.json")));
4941
4942fn parse_amendments(json: &str) -> Arc<Amendments> {
4943 #[derive(serde::Deserialize)]
4944 struct AmendmentEntry {
4945 root: String,
4946 deps: Vec<DepEntry>,
4947 }
4948
4949 #[derive(serde::Deserialize)]
4950 struct DepEntry {
4951 original_id: String,
4952 version_id: String,
4953 }
4954
4955 let entries: Vec<AmendmentEntry> =
4956 serde_json::from_str(json).expect("Failed to parse amendments JSON");
4957 let mut amendments = BTreeMap::new();
4958 for entry in entries {
4959 let root_id = AccountAddress::from_hex_literal(&entry.root).unwrap();
4960 let mut dep_ids = BTreeMap::new();
4961 for dep in entry.deps {
4962 let orig_id = AccountAddress::from_hex_literal(&dep.original_id).unwrap();
4963 let upgraded_id = AccountAddress::from_hex_literal(&dep.version_id).unwrap();
4964 assert!(
4965 dep_ids.insert(orig_id, upgraded_id).is_none(),
4966 "Duplicate original ID in amendments table"
4967 );
4968 }
4969 assert!(
4970 amendments.insert(root_id, dep_ids).is_none(),
4971 "Duplicate root ID in amendments table"
4972 );
4973 }
4974 Arc::new(amendments)
4975}
4976
4977#[cfg(all(test, not(msim)))]
4978mod test {
4979 use insta::assert_yaml_snapshot;
4980
4981 use super::*;
4982
4983 #[test]
4984 fn snapshot_tests() {
4985 println!("\n============================================================================");
4986 println!("! !");
4987 println!("! IMPORTANT: never update snapshots from this test. only add new versions! !");
4988 println!("! !");
4989 println!("============================================================================\n");
4990 for chain_id in &[Chain::Unknown, Chain::Mainnet, Chain::Testnet] {
4991 let chain_str = match chain_id {
4995 Chain::Unknown => "".to_string(),
4996 _ => format!("{:?}_", chain_id),
4997 };
4998 for i in MIN_PROTOCOL_VERSION..=MAX_PROTOCOL_VERSION {
4999 let cur = ProtocolVersion::new(i);
5000 assert_yaml_snapshot!(
5001 format!("{}version_{}", chain_str, cur.as_u64()),
5002 ProtocolConfig::get_for_version(cur, *chain_id)
5003 );
5004 }
5005 }
5006 }
5007
5008 #[test]
5009 fn test_getters() {
5010 let prot: ProtocolConfig =
5011 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5012 assert_eq!(
5013 prot.max_arguments(),
5014 prot.max_arguments_as_option().unwrap()
5015 );
5016 }
5017
5018 #[test]
5019 fn test_setters() {
5020 let mut prot: ProtocolConfig =
5021 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5022 prot.set_max_arguments_for_testing(123);
5023 assert_eq!(prot.max_arguments(), 123);
5024
5025 prot.set_max_arguments_from_str_for_testing("321".to_string());
5026 assert_eq!(prot.max_arguments(), 321);
5027
5028 prot.disable_max_arguments_for_testing();
5029 assert_eq!(prot.max_arguments_as_option(), None);
5030
5031 prot.set_attr_for_testing("max_arguments".to_string(), "456".to_string());
5032 assert_eq!(prot.max_arguments(), 456);
5033 }
5034
5035 #[test]
5036 fn test_execution_version_setter_allows_upgrade() {
5037 let mut prot = ProtocolConfig::get_for_max_version_UNSAFE();
5038 let current = prot.execution_version();
5039 prot.set_execution_version_for_testing(current);
5040 prot.set_execution_version_for_testing(current + 1);
5041 assert_eq!(prot.execution_version(), current + 1);
5042 }
5043
5044 #[test]
5045 #[should_panic(expected = "cannot downgrade execution_version")]
5046 fn test_execution_version_setter_panics_on_downgrade() {
5047 let mut prot = ProtocolConfig::get_for_max_version_UNSAFE();
5048 let current = prot.execution_version();
5049 prot.set_execution_version_for_testing(current - 1);
5050 }
5051
5052 #[test]
5053 fn test_feature_flag_setter_by_string() {
5054 let mut prot: ProtocolConfig =
5055 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5056 assert!(!prot.zklogin_auth());
5057 prot.set_feature_flag_for_testing("zklogin_auth".to_string(), true);
5058 assert!(prot.zklogin_auth());
5059 prot.set_feature_flag_for_testing("zklogin_auth".to_string(), false);
5060 assert!(!prot.zklogin_auth());
5061 }
5062
5063 #[test]
5064 #[should_panic(expected = "unknown feature flag")]
5065 fn test_feature_flag_setter_unknown_flag() {
5066 let mut prot: ProtocolConfig =
5067 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5068 prot.set_feature_flag_for_testing("some random string".to_string(), true);
5069 }
5070
5071 #[test]
5072 fn test_get_for_version_if_supported_applies_test_overrides() {
5073 let before =
5074 ProtocolConfig::get_for_version_if_supported(ProtocolVersion::new(1), Chain::Unknown)
5075 .unwrap();
5076
5077 assert!(!before.enable_coin_reservation_obj_refs());
5078
5079 let _guard = ProtocolConfig::apply_overrides_for_testing(|_, mut cfg| {
5080 cfg.enable_coin_reservation_for_testing();
5081 cfg
5082 });
5083
5084 let after =
5085 ProtocolConfig::get_for_version_if_supported(ProtocolVersion::new(1), Chain::Unknown)
5086 .unwrap();
5087
5088 assert!(after.enable_coin_reservation_obj_refs());
5089 }
5090
5091 #[test]
5092 #[should_panic(expected = "unsupported version")]
5093 fn max_version_test() {
5094 let _ = ProtocolConfig::get_for_version_impl(
5097 ProtocolVersion::new(MAX_PROTOCOL_VERSION + 1),
5098 Chain::Unknown,
5099 );
5100 }
5101
5102 #[test]
5103 fn lookup_by_string_test() {
5104 let prot: ProtocolConfig =
5105 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5106 assert!(prot.lookup_attr("some random string".to_string()).is_none());
5108
5109 assert!(
5110 prot.lookup_attr("max_arguments".to_string())
5111 == Some(ProtocolConfigValue::u32(prot.max_arguments())),
5112 );
5113
5114 assert!(
5116 prot.lookup_attr("max_move_identifier_len".to_string())
5117 .is_none()
5118 );
5119
5120 let prot: ProtocolConfig =
5122 ProtocolConfig::get_for_version(ProtocolVersion::new(9), Chain::Unknown);
5123 assert!(
5124 prot.lookup_attr("max_move_identifier_len".to_string())
5125 == Some(ProtocolConfigValue::u64(prot.max_move_identifier_len()))
5126 );
5127
5128 let prot: ProtocolConfig =
5129 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5130 assert!(
5132 prot.attr_map()
5133 .get("max_move_identifier_len")
5134 .unwrap()
5135 .is_none()
5136 );
5137 assert!(
5139 prot.attr_map().get("max_arguments").unwrap()
5140 == &Some(ProtocolConfigValue::u32(prot.max_arguments()))
5141 );
5142
5143 let prot: ProtocolConfig =
5145 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5146 assert!(
5148 prot.feature_flags
5149 .lookup_attr("some random string".to_owned())
5150 .is_none()
5151 );
5152 assert!(
5153 !prot
5154 .feature_flags
5155 .attr_map()
5156 .contains_key("some random string")
5157 );
5158
5159 assert!(
5161 prot.feature_flags
5162 .lookup_attr("package_upgrades".to_owned())
5163 == Some(false)
5164 );
5165 assert!(
5166 prot.feature_flags
5167 .attr_map()
5168 .get("package_upgrades")
5169 .unwrap()
5170 == &false
5171 );
5172 let prot: ProtocolConfig =
5173 ProtocolConfig::get_for_version(ProtocolVersion::new(4), Chain::Unknown);
5174 assert!(
5176 prot.feature_flags
5177 .lookup_attr("package_upgrades".to_owned())
5178 == Some(true)
5179 );
5180 assert!(
5181 prot.feature_flags
5182 .attr_map()
5183 .get("package_upgrades")
5184 .unwrap()
5185 == &true
5186 );
5187 }
5188
5189 #[test]
5190 fn limit_range_fn_test() {
5191 let low = 100u32;
5192 let high = 10000u64;
5193
5194 assert!(check_limit!(1u8, low, high) == LimitThresholdCrossed::None);
5195 assert!(matches!(
5196 check_limit!(255u16, low, high),
5197 LimitThresholdCrossed::Soft(255u128, 100)
5198 ));
5199 assert!(matches!(
5205 check_limit!(2550000u64, low, high),
5206 LimitThresholdCrossed::Hard(2550000, 10000)
5207 ));
5208
5209 assert!(matches!(
5210 check_limit!(2550000u64, high, high),
5211 LimitThresholdCrossed::Hard(2550000, 10000)
5212 ));
5213
5214 assert!(matches!(
5215 check_limit!(1u8, high),
5216 LimitThresholdCrossed::None
5217 ));
5218
5219 assert!(check_limit!(255u16, high) == LimitThresholdCrossed::None);
5220
5221 assert!(matches!(
5222 check_limit!(2550000u64, high),
5223 LimitThresholdCrossed::Hard(2550000, 10000)
5224 ));
5225 }
5226
5227 #[test]
5228 fn linkage_amendments_load() {
5229 let mainnet = LazyLock::force(&MAINNET_LINKAGE_AMENDMENTS);
5230 let testnet = LazyLock::force(&TESTNET_LINKAGE_AMENDMENTS);
5231 assert!(!mainnet.is_empty(), "mainnet amendments must not be empty");
5232 assert!(!testnet.is_empty(), "testnet amendments must not be empty");
5233 }
5234
5235 #[test]
5236 fn render_scalar_fields_use_precision_safe_encoding() {
5237 use mysten_common::rpc_format::Unmetered;
5238
5239 let config = ProtocolConfig::get_for_max_version_UNSAFE();
5240 let rendered = config
5241 .render::<serde_json::Value>(&mut Unmetered)
5242 .expect("render should succeed");
5243
5244 let max_args = rendered
5245 .get("max_arguments")
5246 .expect("max_arguments set at max version");
5247 assert!(
5248 max_args.is_number(),
5249 "u32 should render as number, got {max_args:?}",
5250 );
5251
5252 let max_tx_size = rendered
5253 .get("max_tx_size_bytes")
5254 .expect("max_tx_size_bytes set at max version");
5255 assert!(
5256 max_tx_size.is_string(),
5257 "u64 should render as string, got {max_tx_size:?}",
5258 );
5259 }
5260
5261 #[test]
5262 fn render_includes_non_scalar_gasless_allowlist_as_json() {
5263 use mysten_common::rpc_format::Unmetered;
5264 use serde_json::json;
5265
5266 let mut config = ProtocolConfig::get_for_max_version_UNSAFE();
5267 config.set_gasless_allowed_token_types_for_testing(vec![
5268 ("0xa::usdc::USDC".to_string(), 10_000),
5269 ("0xb::usdt::USDT".to_string(), 0),
5270 ]);
5271
5272 let rendered = config
5273 .render::<serde_json::Value>(&mut Unmetered)
5274 .expect("render should succeed under Unmetered budget");
5275 let allowlist = rendered
5276 .get("gasless_allowed_token_types")
5277 .expect("entry should be present after the testing setter");
5278
5279 assert_eq!(
5282 allowlist,
5283 &json!([["0xa::usdc::USDC", "10000"], ["0xb::usdt::USDT", "0"],]),
5284 );
5285 }
5286
5287 #[test]
5288 fn render_targets_prost_value_for_grpc() {
5289 use mysten_common::rpc_format::Unmetered;
5290 use prost_types::value::Kind;
5291
5292 let mut config = ProtocolConfig::get_for_max_version_UNSAFE();
5293 config.set_gasless_allowed_token_types_for_testing(vec![(
5294 "0xa::usdc::USDC".to_string(),
5295 10_000,
5296 )]);
5297
5298 let rendered = config
5299 .render::<prost_types::Value>(&mut Unmetered)
5300 .expect("render to prost Value should succeed");
5301 let allowlist = rendered
5302 .get("gasless_allowed_token_types")
5303 .expect("entry should be present after the testing setter");
5304
5305 let Some(Kind::ListValue(outer)) = &allowlist.kind else {
5307 panic!(
5308 "expected ListValue at the top level, got {:?}",
5309 allowlist.kind
5310 );
5311 };
5312 assert_eq!(outer.values.len(), 1, "one allowlisted entry");
5313 let Some(Kind::ListValue(entry)) = &outer.values[0].kind else {
5314 panic!("expected each entry to be a ListValue");
5315 };
5316 assert_eq!(entry.values.len(), 2, "entry has (coin_type, amount)");
5317
5318 let Some(Kind::StringValue(coin_type)) = &entry.values[0].kind else {
5319 panic!("expected coin_type as StringValue");
5320 };
5321 assert_eq!(coin_type, "0xa::usdc::USDC");
5322
5323 let Some(Kind::StringValue(amount)) = &entry.values[1].kind else {
5325 panic!(
5326 "expected minimum_transfer_amount as StringValue (precision-safe u64); got {:?}",
5327 entry.values[1].kind,
5328 );
5329 };
5330 assert_eq!(amount, "10000");
5331 }
5332
5333 #[test]
5334 fn render_emits_null_for_unset_protocol_versions() {
5335 use mysten_common::rpc_format::Unmetered;
5336
5337 let config = ProtocolConfig::get_for_version(1.into(), Chain::Unknown);
5338 let rendered = config
5339 .render::<serde_json::Value>(&mut Unmetered)
5340 .expect("render should succeed");
5341 let entry = rendered
5345 .get("gasless_allowed_token_types")
5346 .expect("key should be present for every protocol version");
5347 assert!(
5348 entry.is_null(),
5349 "value should be null for pre-feature protocol version, got {entry:?}",
5350 );
5351 }
5352}