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 = 136;
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)]
390pub struct ProtocolVersion(u64);
391
392impl ProtocolVersion {
393 pub const MIN: Self = Self(MIN_PROTOCOL_VERSION);
398
399 pub const MAX: Self = Self(MAX_PROTOCOL_VERSION);
400
401 #[cfg(not(msim))]
402 pub const MAX_ALLOWED: Self = Self::MAX;
403
404 #[cfg(msim)]
406 pub const MAX_ALLOWED: Self = Self(MAX_PROTOCOL_VERSION + 1);
407
408 pub fn new(v: u64) -> Self {
409 Self(v)
410 }
411
412 pub const fn as_u64(&self) -> u64 {
413 self.0
414 }
415
416 pub fn max() -> Self {
419 Self::MAX
420 }
421
422 pub fn prev(self) -> Self {
423 Self(self.0.checked_sub(1).unwrap())
424 }
425}
426
427impl From<u64> for ProtocolVersion {
428 fn from(v: u64) -> Self {
429 Self::new(v)
430 }
431}
432
433impl std::ops::Sub<u64> for ProtocolVersion {
434 type Output = Self;
435 fn sub(self, rhs: u64) -> Self::Output {
436 Self::new(self.0 - rhs)
437 }
438}
439
440impl std::ops::Add<u64> for ProtocolVersion {
441 type Output = Self;
442 fn add(self, rhs: u64) -> Self::Output {
443 Self::new(self.0 + rhs)
444 }
445}
446
447#[derive(
448 Clone, Serialize, Deserialize, Debug, Default, PartialEq, Copy, PartialOrd, Ord, Eq, ValueEnum,
449)]
450pub enum Chain {
451 Mainnet,
452 Testnet,
453 #[default]
454 Unknown,
455}
456
457impl Chain {
458 pub fn as_str(self) -> &'static str {
459 match self {
460 Chain::Mainnet => "mainnet",
461 Chain::Testnet => "testnet",
462 Chain::Unknown => "unknown",
463 }
464 }
465}
466
467pub struct Error(pub String);
468
469#[derive(Default, Clone, Serialize, Deserialize, Debug, ProtocolConfigFeatureFlagsGetters)]
472struct FeatureFlags {
473 #[serde(skip_serializing_if = "is_false")]
476 package_upgrades: bool,
477 #[serde(skip_serializing_if = "is_false")]
480 commit_root_state_digest: bool,
481 #[serde(skip_serializing_if = "is_false")]
483 advance_epoch_start_time_in_safe_mode: bool,
484 #[serde(skip_serializing_if = "is_false")]
487 loaded_child_objects_fixed: bool,
488 #[serde(skip_serializing_if = "is_false")]
491 missing_type_is_compatibility_error: bool,
492 #[serde(skip_serializing_if = "is_false")]
495 scoring_decision_with_validity_cutoff: bool,
496
497 #[serde(skip_serializing_if = "is_false")]
500 consensus_order_end_of_epoch_last: bool,
501
502 #[serde(skip_serializing_if = "is_false")]
506 consensus_slim_block_propagation: bool,
507
508 #[serde(skip_serializing_if = "is_false")]
510 disallow_adding_abilities_on_upgrade: bool,
511 #[serde(skip_serializing_if = "is_false")]
513 disable_invariant_violation_check_in_swap_loc: bool,
514 #[serde(skip_serializing_if = "is_false")]
517 advance_to_highest_supported_protocol_version: bool,
518 #[serde(skip_serializing_if = "is_false")]
520 ban_entry_init: bool,
521 #[serde(skip_serializing_if = "is_false")]
523 package_digest_hash_module: bool,
524 #[serde(skip_serializing_if = "is_false")]
526 disallow_change_struct_type_params_on_upgrade: bool,
527 #[serde(skip_serializing_if = "is_false")]
529 no_extraneous_module_bytes: bool,
530 #[serde(skip_serializing_if = "is_false")]
532 narwhal_versioned_metadata: bool,
533
534 #[serde(skip_serializing_if = "is_false")]
536 zklogin_auth: bool,
537 #[serde(skip_serializing_if = "is_zero")]
540 zklogin_circuit_mode: u64,
541 #[serde(skip_serializing_if = "ConsensusTransactionOrdering::is_none")]
543 consensus_transaction_ordering: ConsensusTransactionOrdering,
544
545 #[serde(skip_serializing_if = "is_false")]
553 simplified_unwrap_then_delete: bool,
554 #[serde(skip_serializing_if = "is_false")]
556 upgraded_multisig_supported: bool,
557 #[serde(skip_serializing_if = "is_false")]
559 txn_base_cost_as_multiplier: bool,
560
561 #[serde(skip_serializing_if = "is_false")]
563 shared_object_deletion: bool,
564
565 #[serde(skip_serializing_if = "is_false")]
567 narwhal_new_leader_election_schedule: bool,
568
569 #[serde(skip_serializing_if = "is_empty")]
571 zklogin_supported_providers: BTreeSet<String>,
572
573 #[serde(skip_serializing_if = "is_false")]
575 loaded_child_object_format: bool,
576
577 #[serde(skip_serializing_if = "is_false")]
578 #[skip_protocol_config_accessor]
579 enable_jwk_consensus_updates: bool,
580
581 #[serde(skip_serializing_if = "is_false")]
582 #[skip_protocol_config_accessor]
583 end_of_epoch_transaction_supported: bool,
584
585 #[serde(skip_serializing_if = "is_false")]
588 simple_conservation_checks: bool,
589
590 #[serde(skip_serializing_if = "is_false")]
592 loaded_child_object_format_type: bool,
593
594 #[serde(skip_serializing_if = "is_false")]
596 receive_objects: bool,
597
598 #[serde(skip_serializing_if = "is_false")]
600 consensus_checkpoint_signature_key_includes_digest: bool,
601
602 #[serde(skip_serializing_if = "is_false")]
604 random_beacon: bool,
605
606 #[serde(skip_serializing_if = "is_false")]
608 #[skip_protocol_config_accessor]
609 bridge: bool,
610
611 #[serde(skip_serializing_if = "is_false")]
612 enable_effects_v2: bool,
613
614 #[serde(skip_serializing_if = "is_false")]
616 narwhal_certificate_v2: bool,
617
618 #[serde(skip_serializing_if = "is_false")]
620 verify_legacy_zklogin_address: bool,
621
622 #[serde(skip_serializing_if = "is_false")]
624 throughput_aware_consensus_submission: bool,
625
626 #[serde(skip_serializing_if = "is_false")]
628 recompute_has_public_transfer_in_execution: bool,
629
630 #[serde(skip_serializing_if = "is_false")]
632 accept_zklogin_in_multisig: bool,
633
634 #[serde(skip_serializing_if = "is_false")]
636 accept_passkey_in_multisig: bool,
637
638 #[serde(skip_serializing_if = "is_false")]
640 validate_zklogin_public_identifier: bool,
641
642 #[serde(skip_serializing_if = "is_false")]
645 include_consensus_digest_in_prologue: bool,
646
647 #[serde(skip_serializing_if = "is_false")]
649 hardened_otw_check: bool,
650
651 #[serde(skip_serializing_if = "is_false")]
653 allow_receiving_object_id: bool,
654
655 #[serde(skip_serializing_if = "is_false")]
657 enable_poseidon: bool,
658
659 #[serde(skip_serializing_if = "is_false")]
661 enable_coin_deny_list: bool,
662
663 #[serde(skip_serializing_if = "is_false")]
665 enable_group_ops_native_functions: bool,
666
667 #[serde(skip_serializing_if = "is_false")]
669 enable_group_ops_native_function_msm: bool,
670
671 #[serde(skip_serializing_if = "is_false")]
673 enable_ristretto255_group_ops: bool,
674
675 #[serde(skip_serializing_if = "is_false")]
677 enable_verify_bulletproofs_ristretto255: bool,
678
679 #[serde(skip_serializing_if = "is_false")]
681 enable_nitro_attestation: bool,
682
683 #[serde(skip_serializing_if = "is_false")]
685 enable_nitro_attestation_upgraded_parsing: bool,
686
687 #[serde(skip_serializing_if = "is_false")]
689 enable_nitro_attestation_all_nonzero_pcrs_parsing: bool,
690
691 #[serde(skip_serializing_if = "is_false")]
693 enable_nitro_attestation_always_include_required_pcrs_parsing: bool,
694
695 #[serde(skip_serializing_if = "is_false")]
697 reject_mutable_random_on_entry_functions: bool,
698
699 #[serde(skip_serializing_if = "PerObjectCongestionControlMode::is_none")]
701 per_object_congestion_control_mode: PerObjectCongestionControlMode,
702
703 #[serde(skip_serializing_if = "ConsensusChoice::is_narwhal")]
705 consensus_choice: ConsensusChoice,
706
707 #[serde(skip_serializing_if = "ConsensusNetwork::is_anemo")]
709 consensus_network: ConsensusNetwork,
710
711 #[serde(skip_serializing_if = "is_false")]
713 correct_gas_payment_limit_check: bool,
714
715 #[serde(skip_serializing_if = "Option::is_none")]
717 zklogin_max_epoch_upper_bound_delta: Option<u64>,
718
719 #[serde(skip_serializing_if = "is_false")]
721 mysticeti_leader_scoring_and_schedule: bool,
722
723 #[serde(skip_serializing_if = "is_false")]
725 reshare_at_same_initial_version: bool,
726
727 #[serde(skip_serializing_if = "is_false")]
729 resolve_abort_locations_to_package_id: bool,
730
731 #[serde(skip_serializing_if = "is_false")]
735 mysticeti_use_committed_subdag_digest: bool,
736
737 #[serde(skip_serializing_if = "is_false")]
739 enable_vdf: bool,
740
741 #[serde(skip_serializing_if = "is_false")]
745 record_consensus_determined_version_assignments_in_prologue: bool,
746 #[serde(skip_serializing_if = "is_false")]
749 record_consensus_determined_version_assignments_in_prologue_v2: bool,
750
751 #[serde(skip_serializing_if = "is_false")]
753 fresh_vm_on_framework_upgrade: bool,
754
755 #[serde(skip_serializing_if = "is_false")]
763 prepend_prologue_tx_in_consensus_commit_in_checkpoints: bool,
764
765 #[serde(skip_serializing_if = "Option::is_none")]
767 mysticeti_num_leaders_per_round: Option<usize>,
768
769 #[serde(skip_serializing_if = "is_false")]
771 soft_bundle: bool,
772
773 #[serde(skip_serializing_if = "is_false")]
775 enable_coin_deny_list_v2: bool,
776
777 #[serde(skip_serializing_if = "is_false")]
779 passkey_auth: bool,
780
781 #[serde(skip_serializing_if = "is_false")]
783 authority_capabilities_v2: bool,
784
785 #[serde(skip_serializing_if = "is_false")]
787 rethrow_serialization_type_layout_errors: bool,
788
789 #[serde(skip_serializing_if = "is_false")]
791 consensus_distributed_vote_scoring_strategy: bool,
792
793 #[serde(skip_serializing_if = "is_false")]
795 consensus_round_prober: bool,
796
797 #[serde(skip_serializing_if = "is_false")]
799 validate_identifier_inputs: bool,
800
801 #[serde(skip_serializing_if = "is_false")]
803 disallow_self_identifier: bool,
804
805 #[serde(skip_serializing_if = "is_false")]
807 mysticeti_fastpath: bool,
808
809 #[serde(skip_serializing_if = "is_false")]
813 disable_preconsensus_locking: bool,
814
815 #[serde(skip_serializing_if = "is_false")]
817 relocate_event_module: bool,
818
819 #[serde(skip_serializing_if = "is_false")]
821 uncompressed_g1_group_elements: bool,
822
823 #[serde(skip_serializing_if = "is_false")]
824 disallow_new_modules_in_deps_only_packages: bool,
825
826 #[serde(skip_serializing_if = "is_false")]
828 consensus_smart_ancestor_selection: bool,
829
830 #[serde(skip_serializing_if = "is_false")]
832 consensus_round_prober_probe_accepted_rounds: bool,
833
834 #[serde(skip_serializing_if = "is_false")]
836 native_charging_v2: bool,
837
838 #[serde(skip_serializing_if = "is_false")]
841 #[skip_protocol_config_accessor]
842 consensus_linearize_subdag_v2: bool,
843
844 #[serde(skip_serializing_if = "is_false")]
846 convert_type_argument_error: bool,
847
848 #[serde(skip_serializing_if = "is_false")]
850 variant_nodes: bool,
851
852 #[serde(skip_serializing_if = "is_false")]
854 consensus_zstd_compression: bool,
855
856 #[serde(skip_serializing_if = "is_false")]
858 minimize_child_object_mutations: bool,
859
860 #[serde(skip_serializing_if = "is_false")]
863 record_additional_state_digest_in_prologue: bool,
864
865 #[serde(skip_serializing_if = "is_false")]
867 move_native_context: bool,
868
869 #[serde(skip_serializing_if = "is_false")]
872 #[skip_protocol_config_accessor]
873 consensus_median_based_commit_timestamp: bool,
874
875 #[serde(skip_serializing_if = "is_false")]
878 normalize_ptb_arguments: bool,
879
880 #[serde(skip_serializing_if = "is_false")]
882 consensus_batched_block_sync: bool,
883
884 #[serde(skip_serializing_if = "is_false")]
886 enforce_checkpoint_timestamp_monotonicity: bool,
887
888 #[serde(skip_serializing_if = "is_false")]
890 max_ptb_value_size_v2: bool,
891
892 #[serde(skip_serializing_if = "is_false")]
894 resolve_type_input_ids_to_defining_id: bool,
895
896 #[serde(skip_serializing_if = "is_false")]
898 enable_party_transfer: bool,
899
900 #[serde(skip_serializing_if = "is_false")]
902 allow_unbounded_system_objects: bool,
903
904 #[serde(skip_serializing_if = "is_false")]
906 type_tags_in_object_runtime: bool,
907
908 #[serde(skip_serializing_if = "is_false")]
910 enable_accumulators: bool,
911
912 #[serde(skip_serializing_if = "is_false")]
914 #[skip_protocol_config_accessor]
915 enable_coin_reservation_obj_refs: bool,
916
917 #[serde(skip_serializing_if = "is_false")]
920 create_root_accumulator_object: bool,
921
922 #[serde(skip_serializing_if = "is_false")]
924 #[skip_protocol_config_accessor]
925 enable_authenticated_event_streams: bool,
926
927 #[serde(skip_serializing_if = "is_false")]
929 enable_address_balance_gas_payments: bool,
930
931 #[serde(skip_serializing_if = "is_false")]
933 address_balance_gas_check_rgp_at_signing: bool,
934
935 #[serde(skip_serializing_if = "is_false")]
936 address_balance_gas_reject_gas_coin_arg: bool,
937
938 #[serde(skip_serializing_if = "is_false")]
940 enable_multi_epoch_transaction_expiration: bool,
941
942 #[serde(skip_serializing_if = "is_false")]
944 relax_valid_during_for_owned_inputs: bool,
945
946 #[serde(skip_serializing_if = "is_false")]
948 enable_ptb_execution_v2: bool,
949
950 #[serde(skip_serializing_if = "is_false")]
952 better_adapter_type_resolution_errors: bool,
953
954 #[serde(skip_serializing_if = "is_false")]
956 record_time_estimate_processed: bool,
957
958 #[serde(skip_serializing_if = "is_false")]
960 dependency_linkage_error: bool,
961
962 #[serde(skip_serializing_if = "is_false")]
964 additional_multisig_checks: bool,
965
966 #[serde(skip_serializing_if = "is_false")]
968 ignore_execution_time_observations_after_certs_closed: bool,
969
970 #[serde(skip_serializing_if = "is_false")]
974 debug_fatal_on_move_invariant_violation: bool,
975
976 #[serde(skip_serializing_if = "is_false")]
979 allow_private_accumulator_entrypoints: bool,
980
981 #[serde(skip_serializing_if = "is_false")]
984 additional_consensus_digest_indirect_state: bool,
985
986 #[serde(skip_serializing_if = "is_false")]
988 check_for_init_during_upgrade: bool,
989
990 #[serde(skip_serializing_if = "is_false")]
992 enable_init_on_upgrade: bool,
993
994 #[serde(skip_serializing_if = "is_false")]
996 enable_order_independent_upgrade_init_linkage: bool,
997
998 #[serde(skip_serializing_if = "is_false")]
1000 per_command_shared_object_transfer_rules: bool,
1001
1002 #[serde(skip_serializing_if = "is_false")]
1004 include_checkpoint_artifacts_digest_in_summary: bool,
1005
1006 #[serde(skip_serializing_if = "is_false")]
1008 use_mfp_txns_in_load_initial_object_debts: bool,
1009
1010 #[serde(skip_serializing_if = "is_false")]
1012 cancel_for_failed_dkg_early: bool,
1013
1014 #[serde(skip_serializing_if = "is_false")]
1016 always_advance_dkg_to_resolution: bool,
1017
1018 #[serde(skip_serializing_if = "is_false")]
1020 enable_coin_registry: bool,
1021
1022 #[serde(skip_serializing_if = "is_false")]
1024 abstract_size_in_object_runtime: bool,
1025
1026 #[serde(skip_serializing_if = "is_false")]
1028 object_runtime_charge_cache_load_gas: bool,
1029
1030 #[serde(skip_serializing_if = "is_false")]
1032 additional_borrow_checks: bool,
1033
1034 #[serde(skip_serializing_if = "is_false")]
1036 use_new_commit_handler: bool,
1037
1038 #[serde(skip_serializing_if = "is_false")]
1040 better_loader_errors: bool,
1041
1042 #[serde(skip_serializing_if = "is_false")]
1044 generate_df_type_layouts: bool,
1045
1046 #[serde(skip_serializing_if = "is_false")]
1048 allow_references_in_ptbs: bool,
1049
1050 #[serde(skip_serializing_if = "is_false")]
1057 framework_tx_context_mut_restrictions: bool,
1058
1059 #[serde(skip_serializing_if = "is_false")]
1061 include_function_signatures_in_instantiation_limits: bool,
1062
1063 #[serde(skip_serializing_if = "is_false")]
1068 ptb_tx_context_restrictions: bool,
1069
1070 #[serde(skip_serializing_if = "is_false")]
1072 enable_display_registry: bool,
1073
1074 #[serde(skip_serializing_if = "is_false")]
1076 private_generics_verifier_v2: bool,
1077
1078 #[serde(skip_serializing_if = "is_false")]
1080 deprecate_global_storage_ops_during_deserialization: bool,
1081
1082 #[serde(skip_serializing_if = "is_false")]
1085 enable_non_exclusive_writes: bool,
1086
1087 #[serde(skip_serializing_if = "is_false")]
1089 deprecate_global_storage_ops: bool,
1090
1091 #[serde(skip_serializing_if = "is_false")]
1093 normalize_depth_formula: bool,
1094
1095 #[serde(skip_serializing_if = "is_false")]
1097 consensus_skip_gced_accept_votes: bool,
1098
1099 #[serde(skip_serializing_if = "is_false")]
1102 include_cancelled_randomness_txns_in_prologue: bool,
1103
1104 #[serde(skip_serializing_if = "is_false")]
1106 #[skip_protocol_config_accessor]
1107 address_aliases: bool,
1108
1109 #[serde(skip_serializing_if = "is_false")]
1111 create_forwarding_address_registry: bool,
1112
1113 #[serde(skip_serializing_if = "is_false")]
1116 fix_checkpoint_signature_mapping: bool,
1117
1118 #[serde(skip_serializing_if = "is_false")]
1120 enable_object_funds_withdraw: bool,
1121
1122 #[serde(skip_serializing_if = "is_false")]
1125 record_net_unsettled_object_withdraws: bool,
1126
1127 #[serde(skip_serializing_if = "is_false")]
1129 consensus_skip_gced_blocks_in_direct_finalization: bool,
1130
1131 #[serde(skip_serializing_if = "is_false")]
1133 gas_rounding_halve_digits: bool,
1134
1135 #[serde(skip_serializing_if = "is_false")]
1137 flexible_tx_context_positions: bool,
1138
1139 #[serde(skip_serializing_if = "is_false")]
1141 disable_entry_point_signature_check: bool,
1142
1143 #[serde(skip_serializing_if = "is_false")]
1145 convert_withdrawal_compatibility_ptb_arguments: bool,
1146
1147 #[serde(skip_serializing_if = "is_false")]
1149 restrict_hot_or_not_entry_functions: bool,
1150
1151 #[serde(skip_serializing_if = "is_false")]
1153 split_checkpoints_in_consensus_handler: bool,
1154
1155 #[serde(skip_serializing_if = "is_false")]
1157 consensus_always_accept_system_transactions: bool,
1158
1159 #[serde(skip_serializing_if = "is_false")]
1161 validator_metadata_verify_v2: bool,
1162
1163 #[serde(skip_serializing_if = "is_false")]
1166 defer_unpaid_amplification: bool,
1167
1168 #[serde(skip_serializing_if = "is_false")]
1171 defer_owned_object_double_spend: bool,
1172
1173 #[serde(skip_serializing_if = "is_false")]
1176 allowed_proposers: bool,
1177
1178 #[serde(skip_serializing_if = "is_false")]
1179 randomize_checkpoint_tx_limit_in_tests: bool,
1180
1181 #[serde(skip_serializing_if = "is_false")]
1183 gasless_transaction_drop_safety: bool,
1184
1185 #[serde(skip_serializing_if = "is_false")]
1188 merge_randomness_into_checkpoint: bool,
1189
1190 #[serde(skip_serializing_if = "is_false")]
1192 use_coin_party_owner: bool,
1193
1194 #[serde(skip_serializing_if = "is_false")]
1195 enable_gasless: bool,
1196
1197 #[serde(skip_serializing_if = "is_false")]
1198 gasless_verify_remaining_balance: bool,
1199
1200 #[serde(skip_serializing_if = "is_false")]
1201 disallow_jump_orphans: bool,
1202
1203 #[serde(skip_serializing_if = "is_false")]
1205 early_return_receive_object_mismatched_type: bool,
1206
1207 #[serde(skip_serializing_if = "is_false")]
1212 timestamp_based_epoch_close: bool,
1213
1214 #[serde(skip_serializing_if = "is_false")]
1217 limit_groth16_pvk_inputs: bool,
1218
1219 #[serde(skip_serializing_if = "is_false")]
1224 enforce_address_balance_change_invariant: bool,
1225
1226 #[serde(skip_serializing_if = "is_false")]
1228 share_transaction_deny_config_in_consensus: bool,
1229
1230 #[serde(skip_serializing_if = "is_false")]
1232 granular_post_execution_checks: bool,
1233
1234 #[serde(skip_serializing_if = "is_false")]
1236 early_exit_on_iffw: bool,
1237
1238 #[serde(skip_serializing_if = "is_false")]
1240 enable_unified_linkage: bool,
1241}
1242
1243fn is_false(b: &bool) -> bool {
1244 !b
1245}
1246
1247fn is_empty(b: &BTreeSet<String>) -> bool {
1248 b.is_empty()
1249}
1250
1251fn is_zero(val: &u64) -> bool {
1252 *val == 0
1253}
1254
1255#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1257pub enum ConsensusTransactionOrdering {
1258 #[default]
1260 None,
1261 ByGasPrice,
1263}
1264
1265impl ConsensusTransactionOrdering {
1266 pub fn is_none(&self) -> bool {
1267 matches!(self, ConsensusTransactionOrdering::None)
1268 }
1269}
1270
1271#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1272pub struct ExecutionTimeEstimateParams {
1273 pub target_utilization: u64,
1275 pub allowed_txn_cost_overage_burst_limit_us: u64,
1279
1280 pub randomness_scalar: u64,
1283
1284 pub max_estimate_us: u64,
1286
1287 pub stored_observations_num_included_checkpoints: u64,
1290
1291 pub stored_observations_limit: u64,
1293
1294 #[serde(skip_serializing_if = "is_zero")]
1297 pub stake_weighted_median_threshold: u64,
1298
1299 #[serde(skip_serializing_if = "is_false")]
1303 pub default_none_duration_for_new_keys: bool,
1304
1305 #[serde(skip_serializing_if = "Option::is_none")]
1307 pub observations_chunk_size: Option<u64>,
1308}
1309
1310#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1312pub enum PerObjectCongestionControlMode {
1313 #[default]
1314 None, TotalGasBudget, TotalTxCount, TotalGasBudgetWithCap, ExecutionTimeEstimate(ExecutionTimeEstimateParams), }
1320
1321impl PerObjectCongestionControlMode {
1322 pub fn is_none(&self) -> bool {
1323 matches!(self, PerObjectCongestionControlMode::None)
1324 }
1325}
1326
1327#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1329pub enum ConsensusChoice {
1330 #[default]
1331 Narwhal,
1332 SwapEachEpoch,
1333 Mysticeti,
1334}
1335
1336impl ConsensusChoice {
1337 pub fn is_narwhal(&self) -> bool {
1338 matches!(self, ConsensusChoice::Narwhal)
1339 }
1340}
1341
1342#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1344pub enum ConsensusNetwork {
1345 #[default]
1346 Anemo,
1347 Tonic,
1348}
1349
1350impl ConsensusNetwork {
1351 pub fn is_anemo(&self) -> bool {
1352 matches!(self, ConsensusNetwork::Anemo)
1353 }
1354}
1355
1356#[skip_serializing_none]
1388#[derive(Clone, Serialize, Debug, ProtocolConfigAccessors, ProtocolConfigOverride)]
1389pub struct ProtocolConfig {
1390 pub version: ProtocolVersion,
1391
1392 #[serde(skip)]
1397 chain: Chain,
1398
1399 feature_flags: FeatureFlags,
1400
1401 max_tx_size_bytes: Option<u64>,
1404
1405 max_input_objects: Option<u64>,
1407
1408 max_size_written_objects: Option<u64>,
1412 max_size_written_objects_system_tx: Option<u64>,
1415
1416 max_serialized_tx_effects_size_bytes: Option<u64>,
1418
1419 max_serialized_tx_effects_size_bytes_system_tx: Option<u64>,
1421
1422 max_gas_payment_objects: Option<u32>,
1424
1425 max_modules_in_publish: Option<u32>,
1427
1428 max_package_dependencies: Option<u32>,
1430
1431 max_arguments: Option<u32>,
1434
1435 max_type_arguments: Option<u32>,
1437
1438 max_type_argument_depth: Option<u32>,
1440
1441 max_pure_argument_size: Option<u32>,
1443
1444 max_programmable_tx_commands: Option<u32>,
1446
1447 move_binary_format_version: Option<u32>,
1450 min_move_binary_format_version: Option<u32>,
1451
1452 binary_module_handles: Option<u16>,
1454 binary_struct_handles: Option<u16>,
1455 binary_function_handles: Option<u16>,
1456 binary_function_instantiations: Option<u16>,
1457 binary_signatures: Option<u16>,
1458 binary_constant_pool: Option<u16>,
1459 binary_identifiers: Option<u16>,
1460 binary_address_identifiers: Option<u16>,
1461 binary_struct_defs: Option<u16>,
1462 binary_struct_def_instantiations: Option<u16>,
1463 binary_function_defs: Option<u16>,
1464 binary_field_handles: Option<u16>,
1465 binary_field_instantiations: Option<u16>,
1466 binary_friend_decls: Option<u16>,
1467 binary_enum_defs: Option<u16>,
1468 binary_enum_def_instantiations: Option<u16>,
1469 binary_variant_handles: Option<u16>,
1470 binary_variant_instantiation_handles: Option<u16>,
1471
1472 max_move_object_size: Option<u64>,
1474
1475 max_move_package_size: Option<u64>,
1478
1479 max_publish_or_upgrade_per_ptb: Option<u64>,
1481
1482 max_tx_gas: Option<u64>,
1484
1485 max_gas_price: Option<u64>,
1487
1488 max_gas_price_rgp_factor_for_aborted_transactions: Option<u64>,
1491
1492 max_gas_computation_bucket: Option<u64>,
1494
1495 gas_rounding_step: Option<u64>,
1497
1498 max_loop_depth: Option<u64>,
1500
1501 max_generic_instantiation_length: Option<u64>,
1503
1504 max_function_parameters: Option<u64>,
1506
1507 max_basic_blocks: Option<u64>,
1509
1510 max_value_stack_size: Option<u64>,
1512
1513 max_type_nodes: Option<u64>,
1515
1516 max_generic_instantiation_type_nodes_per_function: Option<u64>,
1518
1519 max_generic_instantiation_type_nodes_per_module: Option<u64>,
1521
1522 max_accumulator_type_nodes: Option<u64>,
1524
1525 max_push_size: Option<u64>,
1527
1528 max_struct_definitions: Option<u64>,
1530
1531 max_function_definitions: Option<u64>,
1533
1534 max_fields_in_struct: Option<u64>,
1536
1537 max_dependency_depth: Option<u64>,
1539
1540 max_num_event_emit: Option<u64>,
1542
1543 max_num_new_move_object_ids: Option<u64>,
1545
1546 max_num_new_move_object_ids_system_tx: Option<u64>,
1548
1549 max_num_deleted_move_object_ids: Option<u64>,
1551
1552 max_num_deleted_move_object_ids_system_tx: Option<u64>,
1554
1555 max_num_transferred_move_object_ids: Option<u64>,
1557
1558 max_num_transferred_move_object_ids_system_tx: Option<u64>,
1560
1561 max_event_emit_size: Option<u64>,
1563
1564 max_event_emit_size_total: Option<u64>,
1566
1567 max_move_vector_len: Option<u64>,
1569
1570 max_move_identifier_len: Option<u64>,
1572
1573 max_move_value_depth: Option<u64>,
1575
1576 max_move_enum_variants: Option<u64>,
1578
1579 max_back_edges_per_function: Option<u64>,
1581
1582 max_back_edges_per_module: Option<u64>,
1584
1585 max_verifier_meter_ticks_per_function: Option<u64>,
1587
1588 max_meter_ticks_per_module: Option<u64>,
1590
1591 max_meter_ticks_per_package: Option<u64>,
1593
1594 object_runtime_max_num_cached_objects: Option<u64>,
1598
1599 object_runtime_max_num_cached_objects_system_tx: Option<u64>,
1601
1602 object_runtime_max_num_store_entries: Option<u64>,
1604
1605 object_runtime_max_num_store_entries_system_tx: Option<u64>,
1607
1608 base_tx_cost_fixed: Option<u64>,
1611
1612 package_publish_cost_fixed: Option<u64>,
1615
1616 base_tx_cost_per_byte: Option<u64>,
1619
1620 package_publish_cost_per_byte: Option<u64>,
1622
1623 obj_access_cost_read_per_byte: Option<u64>,
1625
1626 obj_access_cost_mutate_per_byte: Option<u64>,
1628
1629 obj_access_cost_delete_per_byte: Option<u64>,
1631
1632 obj_access_cost_verify_per_byte: Option<u64>,
1642
1643 max_type_to_layout_nodes: Option<u64>,
1645
1646 max_ptb_value_size: Option<u64>,
1648
1649 gas_model_version: Option<u64>,
1652
1653 obj_data_cost_refundable: Option<u64>,
1656
1657 obj_metadata_cost_non_refundable: Option<u64>,
1661
1662 storage_rebate_rate: Option<u64>,
1668
1669 storage_fund_reinvest_rate: Option<u64>,
1672
1673 reward_slashing_rate: Option<u64>,
1676
1677 storage_gas_price: Option<u64>,
1679
1680 accumulator_object_storage_cost: Option<u64>,
1682
1683 max_transactions_per_checkpoint: Option<u64>,
1688
1689 max_checkpoint_size_bytes: Option<u64>,
1693
1694 buffer_stake_for_protocol_upgrade_bps: Option<u64>,
1699
1700 address_from_bytes_cost_base: Option<u64>,
1705 address_to_u256_cost_base: Option<u64>,
1707 address_from_u256_cost_base: Option<u64>,
1709
1710 config_read_setting_impl_cost_base: Option<u64>,
1715 config_read_setting_impl_cost_per_byte: Option<u64>,
1716
1717 package_original_package_id_impl_cost_base: Option<u64>,
1718 package_original_package_id_impl_cost_per_byte: Option<u64>,
1719
1720 dynamic_field_hash_type_and_key_cost_base: Option<u64>,
1723 dynamic_field_hash_type_and_key_type_cost_per_byte: Option<u64>,
1724 dynamic_field_hash_type_and_key_value_cost_per_byte: Option<u64>,
1725 dynamic_field_hash_type_and_key_type_tag_cost_per_byte: Option<u64>,
1726 dynamic_field_add_child_object_cost_base: Option<u64>,
1728 dynamic_field_add_child_object_type_cost_per_byte: Option<u64>,
1729 dynamic_field_add_child_object_value_cost_per_byte: Option<u64>,
1730 dynamic_field_add_child_object_struct_tag_cost_per_byte: Option<u64>,
1731 dynamic_field_borrow_child_object_cost_base: Option<u64>,
1733 dynamic_field_borrow_child_object_child_ref_cost_per_byte: Option<u64>,
1734 dynamic_field_borrow_child_object_type_cost_per_byte: Option<u64>,
1735 dynamic_field_remove_child_object_cost_base: Option<u64>,
1737 dynamic_field_remove_child_object_child_cost_per_byte: Option<u64>,
1738 dynamic_field_remove_child_object_type_cost_per_byte: Option<u64>,
1739 dynamic_field_has_child_object_cost_base: Option<u64>,
1741 dynamic_field_has_child_object_with_ty_cost_base: Option<u64>,
1743 dynamic_field_has_child_object_with_ty_type_cost_per_byte: Option<u64>,
1744 dynamic_field_has_child_object_with_ty_type_tag_cost_per_byte: Option<u64>,
1745
1746 scratch_add_cost_base: Option<u64>,
1749 scratch_read_cost_base: Option<u64>,
1751 scratch_read_value_cost: Option<u64>,
1752 scratch_remove_cost_base: Option<u64>,
1754 scratch_exists_cost_base: Option<u64>,
1756 scratch_exists_with_type_cost_base: Option<u64>,
1758 scratch_exists_with_type_type_cost: Option<u64>,
1759 max_scratch_pad_size: Option<u64>,
1761
1762 event_emit_cost_base: Option<u64>,
1765 event_emit_value_size_derivation_cost_per_byte: Option<u64>,
1766 event_emit_tag_size_derivation_cost_per_byte: Option<u64>,
1767 event_emit_output_cost_per_byte: Option<u64>,
1768 event_emit_auth_stream_cost: Option<u64>,
1769
1770 object_borrow_uid_cost_base: Option<u64>,
1773 object_delete_impl_cost_base: Option<u64>,
1775 object_record_new_uid_cost_base: Option<u64>,
1777 object_record_new_uid_from_hash_cost_base: Option<u64>,
1780
1781 transfer_transfer_internal_cost_base: Option<u64>,
1784 transfer_party_transfer_internal_cost_base: Option<u64>,
1786 transfer_freeze_object_cost_base: Option<u64>,
1788 transfer_share_object_cost_base: Option<u64>,
1790 transfer_receive_object_cost_base: Option<u64>,
1793 transfer_receive_object_cost_per_byte: Option<u64>,
1794 transfer_receive_object_type_cost_per_byte: Option<u64>,
1795
1796 tx_context_derive_id_cost_base: Option<u64>,
1799 tx_context_fresh_id_cost_base: Option<u64>,
1800 tx_context_sender_cost_base: Option<u64>,
1801 tx_context_epoch_cost_base: Option<u64>,
1802 tx_context_epoch_timestamp_ms_cost_base: Option<u64>,
1803 tx_context_sponsor_cost_base: Option<u64>,
1804 tx_context_rgp_cost_base: Option<u64>,
1805 tx_context_gas_price_cost_base: Option<u64>,
1806 tx_context_gas_budget_cost_base: Option<u64>,
1807 tx_context_ids_created_cost_base: Option<u64>,
1808 tx_context_replace_cost_base: Option<u64>,
1809
1810 types_is_one_time_witness_cost_base: Option<u64>,
1813 types_is_one_time_witness_type_tag_cost_per_byte: Option<u64>,
1814 types_is_one_time_witness_type_cost_per_byte: Option<u64>,
1815
1816 validator_validate_metadata_cost_base: Option<u64>,
1819 validator_validate_metadata_data_cost_per_byte: Option<u64>,
1820
1821 crypto_invalid_arguments_cost: Option<u64>,
1823 bls12381_bls12381_min_sig_verify_cost_base: Option<u64>,
1825 bls12381_bls12381_min_sig_verify_msg_cost_per_byte: Option<u64>,
1826 bls12381_bls12381_min_sig_verify_msg_cost_per_block: Option<u64>,
1827
1828 bls12381_bls12381_min_pk_verify_cost_base: Option<u64>,
1830 bls12381_bls12381_min_pk_verify_msg_cost_per_byte: Option<u64>,
1831 bls12381_bls12381_min_pk_verify_msg_cost_per_block: Option<u64>,
1832
1833 ecdsa_k1_ecrecover_keccak256_cost_base: Option<u64>,
1835 ecdsa_k1_ecrecover_keccak256_msg_cost_per_byte: Option<u64>,
1836 ecdsa_k1_ecrecover_keccak256_msg_cost_per_block: Option<u64>,
1837 ecdsa_k1_ecrecover_sha256_cost_base: Option<u64>,
1838 ecdsa_k1_ecrecover_sha256_msg_cost_per_byte: Option<u64>,
1839 ecdsa_k1_ecrecover_sha256_msg_cost_per_block: Option<u64>,
1840
1841 ecdsa_k1_decompress_pubkey_cost_base: Option<u64>,
1843
1844 ecdsa_k1_secp256k1_verify_keccak256_cost_base: Option<u64>,
1846 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_byte: Option<u64>,
1847 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_block: Option<u64>,
1848 ecdsa_k1_secp256k1_verify_sha256_cost_base: Option<u64>,
1849 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_byte: Option<u64>,
1850 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_block: Option<u64>,
1851
1852 ecdsa_r1_ecrecover_keccak256_cost_base: Option<u64>,
1854 ecdsa_r1_ecrecover_keccak256_msg_cost_per_byte: Option<u64>,
1855 ecdsa_r1_ecrecover_keccak256_msg_cost_per_block: Option<u64>,
1856 ecdsa_r1_ecrecover_sha256_cost_base: Option<u64>,
1857 ecdsa_r1_ecrecover_sha256_msg_cost_per_byte: Option<u64>,
1858 ecdsa_r1_ecrecover_sha256_msg_cost_per_block: Option<u64>,
1859
1860 ecdsa_r1_secp256r1_verify_keccak256_cost_base: Option<u64>,
1862 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_byte: Option<u64>,
1863 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_block: Option<u64>,
1864 ecdsa_r1_secp256r1_verify_sha256_cost_base: Option<u64>,
1865 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_byte: Option<u64>,
1866 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_block: Option<u64>,
1867
1868 ecvrf_ecvrf_verify_cost_base: Option<u64>,
1870 ecvrf_ecvrf_verify_alpha_string_cost_per_byte: Option<u64>,
1871 ecvrf_ecvrf_verify_alpha_string_cost_per_block: Option<u64>,
1872
1873 ed25519_ed25519_verify_cost_base: Option<u64>,
1875 ed25519_ed25519_verify_msg_cost_per_byte: Option<u64>,
1876 ed25519_ed25519_verify_msg_cost_per_block: Option<u64>,
1877
1878 groth16_prepare_verifying_key_bls12381_cost_base: Option<u64>,
1880 groth16_prepare_verifying_key_bn254_cost_base: Option<u64>,
1881
1882 groth16_verify_groth16_proof_internal_bls12381_cost_base: Option<u64>,
1884 groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input: Option<u64>,
1885 groth16_verify_groth16_proof_internal_bn254_cost_base: Option<u64>,
1886 groth16_verify_groth16_proof_internal_bn254_cost_per_public_input: Option<u64>,
1887 groth16_verify_groth16_proof_internal_public_input_cost_per_byte: Option<u64>,
1888
1889 hash_blake2b256_cost_base: Option<u64>,
1891 hash_blake2b256_data_cost_per_byte: Option<u64>,
1892 hash_blake2b256_data_cost_per_block: Option<u64>,
1893
1894 hash_keccak256_cost_base: Option<u64>,
1896 hash_keccak256_data_cost_per_byte: Option<u64>,
1897 hash_keccak256_data_cost_per_block: Option<u64>,
1898
1899 poseidon_bn254_cost_base: Option<u64>,
1901 poseidon_bn254_cost_per_block: Option<u64>,
1902
1903 group_ops_bls12381_decode_scalar_cost: Option<u64>,
1905 group_ops_bls12381_decode_g1_cost: Option<u64>,
1906 group_ops_bls12381_decode_g2_cost: Option<u64>,
1907 group_ops_bls12381_decode_gt_cost: Option<u64>,
1908 group_ops_bls12381_scalar_add_cost: Option<u64>,
1909 group_ops_bls12381_g1_add_cost: Option<u64>,
1910 group_ops_bls12381_g2_add_cost: Option<u64>,
1911 group_ops_bls12381_gt_add_cost: Option<u64>,
1912 group_ops_bls12381_scalar_sub_cost: Option<u64>,
1913 group_ops_bls12381_g1_sub_cost: Option<u64>,
1914 group_ops_bls12381_g2_sub_cost: Option<u64>,
1915 group_ops_bls12381_gt_sub_cost: Option<u64>,
1916 group_ops_bls12381_scalar_mul_cost: Option<u64>,
1917 group_ops_bls12381_g1_mul_cost: Option<u64>,
1918 group_ops_bls12381_g2_mul_cost: Option<u64>,
1919 group_ops_bls12381_gt_mul_cost: Option<u64>,
1920 group_ops_bls12381_scalar_div_cost: Option<u64>,
1921 group_ops_bls12381_g1_div_cost: Option<u64>,
1922 group_ops_bls12381_g2_div_cost: Option<u64>,
1923 group_ops_bls12381_gt_div_cost: Option<u64>,
1924 group_ops_bls12381_g1_hash_to_base_cost: Option<u64>,
1925 group_ops_bls12381_g2_hash_to_base_cost: Option<u64>,
1926 group_ops_bls12381_g1_hash_to_cost_per_byte: Option<u64>,
1927 group_ops_bls12381_g2_hash_to_cost_per_byte: Option<u64>,
1928 group_ops_bls12381_g1_msm_base_cost: Option<u64>,
1929 group_ops_bls12381_g2_msm_base_cost: Option<u64>,
1930 group_ops_bls12381_g1_msm_base_cost_per_input: Option<u64>,
1931 group_ops_bls12381_g2_msm_base_cost_per_input: Option<u64>,
1932 group_ops_bls12381_msm_max_len: Option<u32>,
1933 group_ops_bls12381_pairing_cost: Option<u64>,
1934 group_ops_bls12381_g1_to_uncompressed_g1_cost: Option<u64>,
1935 group_ops_bls12381_uncompressed_g1_to_g1_cost: Option<u64>,
1936 group_ops_bls12381_uncompressed_g1_sum_base_cost: Option<u64>,
1937 group_ops_bls12381_uncompressed_g1_sum_cost_per_term: Option<u64>,
1938 group_ops_bls12381_uncompressed_g1_sum_max_terms: Option<u64>,
1939
1940 group_ops_ristretto_decode_scalar_cost: Option<u64>,
1941 group_ops_ristretto_decode_point_cost: Option<u64>,
1942 group_ops_ristretto_scalar_add_cost: Option<u64>,
1943 group_ops_ristretto_point_add_cost: Option<u64>,
1944 group_ops_ristretto_scalar_sub_cost: Option<u64>,
1945 group_ops_ristretto_point_sub_cost: Option<u64>,
1946 group_ops_ristretto_scalar_mul_cost: Option<u64>,
1947 group_ops_ristretto_point_mul_cost: Option<u64>,
1948 group_ops_ristretto_scalar_div_cost: Option<u64>,
1949 group_ops_ristretto_point_div_cost: Option<u64>,
1950
1951 verify_bulletproofs_ristretto255_base_cost: Option<u64>,
1952 verify_bulletproofs_ristretto255_cost_per_bit_and_commitment: Option<u64>,
1953
1954 hmac_hmac_sha3_256_cost_base: Option<u64>,
1956 hmac_hmac_sha3_256_input_cost_per_byte: Option<u64>,
1957 hmac_hmac_sha3_256_input_cost_per_block: Option<u64>,
1958
1959 check_zklogin_id_cost_base: Option<u64>,
1961 check_zklogin_issuer_cost_base: Option<u64>,
1963
1964 vdf_verify_vdf_cost: Option<u64>,
1965 vdf_hash_to_input_cost: Option<u64>,
1966
1967 nitro_attestation_parse_base_cost: Option<u64>,
1969 nitro_attestation_parse_cost_per_byte: Option<u64>,
1970 nitro_attestation_verify_base_cost: Option<u64>,
1971 nitro_attestation_verify_cost_per_cert: Option<u64>,
1972
1973 bcs_per_byte_serialized_cost: Option<u64>,
1975 bcs_legacy_min_output_size_cost: Option<u64>,
1976 bcs_failure_cost: Option<u64>,
1977
1978 hash_sha2_256_base_cost: Option<u64>,
1979 hash_sha2_256_per_byte_cost: Option<u64>,
1980 hash_sha2_256_legacy_min_input_len_cost: Option<u64>,
1981 hash_sha3_256_base_cost: Option<u64>,
1982 hash_sha3_256_per_byte_cost: Option<u64>,
1983 hash_sha3_256_legacy_min_input_len_cost: Option<u64>,
1984 type_name_get_base_cost: Option<u64>,
1985 type_name_get_per_byte_cost: Option<u64>,
1986 type_name_id_base_cost: Option<u64>,
1987
1988 string_check_utf8_base_cost: Option<u64>,
1989 string_check_utf8_per_byte_cost: Option<u64>,
1990 string_is_char_boundary_base_cost: Option<u64>,
1991 string_sub_string_base_cost: Option<u64>,
1992 string_sub_string_per_byte_cost: Option<u64>,
1993 string_index_of_base_cost: Option<u64>,
1994 string_index_of_per_byte_pattern_cost: Option<u64>,
1995 string_index_of_per_byte_searched_cost: Option<u64>,
1996
1997 vector_empty_base_cost: Option<u64>,
1998 vector_length_base_cost: Option<u64>,
1999 vector_push_back_base_cost: Option<u64>,
2000 vector_push_back_legacy_per_abstract_memory_unit_cost: Option<u64>,
2001 vector_borrow_base_cost: Option<u64>,
2002 vector_pop_back_base_cost: Option<u64>,
2003 vector_destroy_empty_base_cost: Option<u64>,
2004 vector_swap_base_cost: Option<u64>,
2005 debug_print_base_cost: Option<u64>,
2006 debug_print_stack_trace_base_cost: Option<u64>,
2007
2008 #[custom_setter]
2018 execution_version: Option<u64>,
2019
2020 consensus_bad_nodes_stake_threshold: Option<u64>,
2024
2025 max_jwk_votes_per_validator_per_epoch: Option<u64>,
2026 max_age_of_jwk_in_epochs: Option<u64>,
2030
2031 random_beacon_reduction_allowed_delta: Option<u16>,
2035
2036 random_beacon_reduction_lower_bound: Option<u32>,
2039
2040 random_beacon_dkg_timeout_round: Option<u32>,
2043
2044 random_beacon_min_round_interval_ms: Option<u64>,
2046
2047 random_beacon_dkg_version: Option<u64>,
2050
2051 consensus_max_transaction_size_bytes: Option<u64>,
2054 consensus_max_transactions_in_block_bytes: Option<u64>,
2056 consensus_max_num_transactions_in_block: Option<u64>,
2058
2059 consensus_voting_rounds: Option<u32>,
2061
2062 max_accumulated_txn_cost_per_object_in_narwhal_commit: Option<u64>,
2064
2065 max_deferral_rounds_for_congestion_control: Option<u64>,
2068
2069 epoch_close_deadline_ms: Option<u64>,
2074
2075 max_txn_cost_overage_per_object_in_commit: Option<u64>,
2077
2078 allowed_txn_cost_overage_burst_per_object_in_commit: Option<u64>,
2080
2081 min_checkpoint_interval_ms: Option<u64>,
2083
2084 checkpoint_summary_version_specific_data: Option<u64>,
2086
2087 max_soft_bundle_size: Option<u64>,
2089
2090 bridge_should_try_to_finalize_committee: Option<bool>,
2094
2095 max_accumulated_txn_cost_per_object_in_mysticeti_commit: Option<u64>,
2101
2102 max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit: Option<u64>,
2105
2106 consensus_gc_depth: Option<u32>,
2109
2110 gas_budget_based_txn_cost_cap_factor: Option<u64>,
2112
2113 gas_budget_based_txn_cost_absolute_cap_commit_count: Option<u64>,
2115
2116 sip_45_consensus_amplification_threshold: Option<u64>,
2119
2120 use_object_per_epoch_marker_table_v2: Option<bool>,
2123
2124 consensus_commit_rate_estimation_window_size: Option<u32>,
2126
2127 #[serde(skip_serializing_if = "Vec::is_empty")]
2131 aliased_addresses: Vec<AliasedAddress>,
2132
2133 translation_per_command_base_charge: Option<u64>,
2136
2137 translation_per_input_base_charge: Option<u64>,
2140
2141 translation_pure_input_per_byte_charge: Option<u64>,
2143
2144 translation_per_type_node_charge: Option<u64>,
2148
2149 translation_per_reference_node_charge: Option<u64>,
2152
2153 translation_per_linkage_entry_charge: Option<u64>,
2156
2157 max_updates_per_settlement_txn: Option<u32>,
2159
2160 gasless_max_computation_units: Option<u64>,
2162
2163 gasless_allowed_token_types: Option<Vec<(String, u64)>>,
2165
2166 gasless_max_unused_inputs: Option<u64>,
2170
2171 gasless_max_pure_input_bytes: Option<u64>,
2174
2175 gasless_max_tps: Option<u64>,
2177
2178 #[serde(skip_serializing_if = "Option::is_none")]
2179 #[skip_accessor]
2180 include_special_package_amendments: Option<Arc<Amendments>>,
2181
2182 gasless_max_tx_size_bytes: Option<u64>,
2185}
2186
2187#[derive(Clone, Serialize, Deserialize, Debug)]
2189pub struct AliasedAddress {
2190 pub original: [u8; 32],
2192 pub aliased: [u8; 32],
2194 pub allowed_tx_digests: Vec<[u8; 32]>,
2196}
2197
2198impl ProtocolConfig {
2200 pub fn chain(&self) -> Chain {
2202 self.chain
2203 }
2204
2205 pub fn check_package_upgrades_supported(&self) -> Result<(), Error> {
2218 if self.feature_flags.package_upgrades {
2219 Ok(())
2220 } else {
2221 Err(Error(format!(
2222 "package upgrades are not supported at {:?}",
2223 self.version
2224 )))
2225 }
2226 }
2227
2228 pub fn zklogin_supported_providers(&self) -> &BTreeSet<String> {
2229 &self.feature_flags.zklogin_supported_providers
2230 }
2231
2232 pub fn zklogin_circuit_mode(&self) -> u64 {
2235 self.feature_flags.zklogin_circuit_mode
2236 }
2237
2238 pub fn consensus_transaction_ordering(&self) -> ConsensusTransactionOrdering {
2239 self.feature_flags.consensus_transaction_ordering
2240 }
2241
2242 pub fn enable_jwk_consensus_updates(&self) -> bool {
2243 let ret = self.feature_flags.enable_jwk_consensus_updates;
2244 if ret {
2245 assert!(self.feature_flags.end_of_epoch_transaction_supported);
2247 }
2248 ret
2249 }
2250
2251 pub fn end_of_epoch_transaction_supported(&self) -> bool {
2252 let ret = self.feature_flags.end_of_epoch_transaction_supported;
2253 if !ret {
2254 assert!(!self.feature_flags.enable_jwk_consensus_updates);
2256 }
2257 ret
2258 }
2259
2260 pub fn dkg_version(&self) -> u64 {
2261 self.random_beacon_dkg_version.unwrap_or(1)
2263 }
2264
2265 pub fn bridge(&self) -> bool {
2266 let ret = self.feature_flags.bridge;
2267 if ret {
2268 assert!(self.feature_flags.end_of_epoch_transaction_supported);
2270 }
2271 ret
2272 }
2273
2274 pub fn should_try_to_finalize_bridge_committee(&self) -> bool {
2275 if !self.bridge() {
2276 return false;
2277 }
2278 self.bridge_should_try_to_finalize_committee.unwrap_or(true)
2280 }
2281
2282 pub fn zklogin_max_epoch_upper_bound_delta(&self) -> Option<u64> {
2283 self.feature_flags.zklogin_max_epoch_upper_bound_delta
2284 }
2285
2286 pub fn enable_coin_reservation_obj_refs(&self) -> bool {
2287 self.new_vm_enabled() && self.feature_flags.enable_coin_reservation_obj_refs
2288 }
2289
2290 pub fn enable_authenticated_event_streams(&self) -> bool {
2291 self.feature_flags.enable_authenticated_event_streams && self.enable_accumulators()
2292 }
2293
2294 pub fn per_object_congestion_control_mode(&self) -> PerObjectCongestionControlMode {
2295 self.feature_flags.per_object_congestion_control_mode
2296 }
2297
2298 pub fn consensus_choice(&self) -> ConsensusChoice {
2299 self.feature_flags.consensus_choice
2300 }
2301
2302 pub fn consensus_network(&self) -> ConsensusNetwork {
2303 self.feature_flags.consensus_network
2304 }
2305
2306 pub fn mysticeti_num_leaders_per_round(&self) -> Option<usize> {
2307 self.feature_flags.mysticeti_num_leaders_per_round
2308 }
2309
2310 pub fn max_transaction_size_bytes(&self) -> u64 {
2311 self.consensus_max_transaction_size_bytes
2313 .unwrap_or(256 * 1024)
2314 }
2315
2316 pub fn max_transactions_in_block_bytes(&self) -> u64 {
2317 if cfg!(msim) {
2318 256 * 1024
2319 } else {
2320 self.consensus_max_transactions_in_block_bytes
2321 .unwrap_or(512 * 1024)
2322 }
2323 }
2324
2325 pub fn max_num_transactions_in_block(&self) -> u64 {
2326 if cfg!(msim) {
2327 8
2328 } else {
2329 self.consensus_max_num_transactions_in_block.unwrap_or(512)
2330 }
2331 }
2332
2333 pub fn gc_depth(&self) -> u32 {
2334 self.consensus_gc_depth.unwrap_or(0)
2335 }
2336
2337 pub fn consensus_linearize_subdag_v2(&self) -> bool {
2338 let res = self.feature_flags.consensus_linearize_subdag_v2;
2339 assert!(
2340 !res || self.gc_depth() > 0,
2341 "The consensus linearize sub dag V2 requires GC to be enabled"
2342 );
2343 res
2344 }
2345
2346 pub fn consensus_median_based_commit_timestamp(&self) -> bool {
2347 let res = self.feature_flags.consensus_median_based_commit_timestamp;
2348 assert!(
2349 !res || self.gc_depth() > 0,
2350 "The consensus median based commit timestamp requires GC to be enabled"
2351 );
2352 res
2353 }
2354
2355 pub fn get_consensus_commit_rate_estimation_window_size(&self) -> u32 {
2356 self.consensus_commit_rate_estimation_window_size
2357 .unwrap_or(0)
2358 }
2359
2360 pub fn consensus_num_requested_prior_commits_at_startup(&self) -> u32 {
2361 let window_size = self.get_consensus_commit_rate_estimation_window_size();
2365 assert!(window_size == 0 || self.record_additional_state_digest_in_prologue());
2367 window_size
2368 }
2369
2370 pub fn address_aliases(&self) -> bool {
2371 let address_aliases = self.feature_flags.address_aliases;
2372 assert!(
2373 !address_aliases || self.mysticeti_fastpath(),
2374 "Address aliases requires Mysticeti fastpath to be enabled"
2375 );
2376 if address_aliases {
2377 assert!(
2378 self.feature_flags.disable_preconsensus_locking,
2379 "Address aliases requires CertifiedTransaction to be disabled"
2380 );
2381 }
2382 address_aliases
2383 }
2384
2385 pub fn new_vm_enabled(&self) -> bool {
2386 self.execution_version.is_some_and(|v| v >= 4)
2387 }
2388
2389 pub fn gasless_allowed_token_types(&self) -> &[(String, u64)] {
2390 debug_assert!(self.gasless_allowed_token_types.is_some());
2391 self.gasless_allowed_token_types.as_deref().unwrap_or(&[])
2392 }
2393
2394 pub fn get_gasless_max_unused_inputs(&self) -> u64 {
2395 self.gasless_max_unused_inputs.unwrap_or(u64::MAX)
2396 }
2397
2398 pub fn get_gasless_max_pure_input_bytes(&self) -> u64 {
2399 self.gasless_max_pure_input_bytes.unwrap_or(u64::MAX)
2400 }
2401
2402 pub fn get_gasless_max_tx_size_bytes(&self) -> u64 {
2403 self.gasless_max_tx_size_bytes.unwrap_or(u64::MAX)
2404 }
2405
2406 pub fn include_special_package_amendments_as_option(&self) -> &Option<Arc<Amendments>> {
2407 &self.include_special_package_amendments
2408 }
2409}
2410
2411static POISON_VERSION_METHODS: AtomicBool = AtomicBool::new(false);
2412
2413impl ProtocolConfig {
2415 pub fn get_for_version(version: ProtocolVersion, chain: Chain) -> Self {
2417 assert!(
2419 version >= ProtocolVersion::MIN,
2420 "Network protocol version is {:?}, but the minimum supported version by the binary is {:?}. Please upgrade the binary.",
2421 version,
2422 ProtocolVersion::MIN.0,
2423 );
2424 assert!(
2425 version <= ProtocolVersion::MAX_ALLOWED,
2426 "Network protocol version is {:?}, but the maximum supported version by the binary is {:?}. Please upgrade the binary.",
2427 version,
2428 ProtocolVersion::MAX_ALLOWED.0,
2429 );
2430
2431 let mut ret = Self::get_for_version_impl(version, chain);
2432 ret.version = version;
2433 ret.chain = chain;
2434
2435 ret = Self::apply_config_override(version, ret);
2436
2437 if std::env::var("SUI_PROTOCOL_CONFIG_OVERRIDE_ENABLE").is_ok() {
2438 warn!(
2439 "overriding ProtocolConfig settings with custom settings; this may break non-local networks"
2440 );
2441 let overrides: ProtocolConfigOptional =
2442 serde_env::from_env_with_prefix("SUI_PROTOCOL_CONFIG_OVERRIDE")
2443 .expect("failed to parse ProtocolConfig override env variables");
2444 overrides.apply_to(&mut ret);
2445 }
2446
2447 ret
2448 }
2449
2450 pub fn get_for_version_if_supported(version: ProtocolVersion, chain: Chain) -> Option<Self> {
2453 if version.0 >= ProtocolVersion::MIN.0 && version.0 <= ProtocolVersion::MAX_ALLOWED.0 {
2454 let mut ret = Self::get_for_version_impl(version, chain);
2455 ret.version = version;
2456 ret.chain = chain;
2457 ret = Self::apply_config_override(version, ret);
2458 Some(ret)
2459 } else {
2460 None
2461 }
2462 }
2463
2464 pub fn poison_get_for_min_version() {
2465 POISON_VERSION_METHODS.store(true, Ordering::Relaxed);
2466 }
2467
2468 fn load_poison_get_for_min_version() -> bool {
2469 POISON_VERSION_METHODS.load(Ordering::Relaxed)
2470 }
2471
2472 pub fn get_for_min_version() -> Self {
2475 if Self::load_poison_get_for_min_version() {
2476 panic!("get_for_min_version called on validator");
2477 }
2478 ProtocolConfig::get_for_version(ProtocolVersion::MIN, Chain::Unknown)
2479 }
2480
2481 #[allow(non_snake_case)]
2491 pub fn get_for_max_version_UNSAFE() -> Self {
2492 if Self::load_poison_get_for_min_version() {
2493 panic!("get_for_max_version_UNSAFE called on validator");
2494 }
2495 ProtocolConfig::get_for_version(ProtocolVersion::MAX, Chain::Unknown)
2496 }
2497
2498 fn get_for_version_impl(version: ProtocolVersion, chain: Chain) -> Self {
2499 #[cfg(msim)]
2500 {
2501 if version == ProtocolVersion::MAX_ALLOWED {
2503 let mut config = Self::get_for_version_impl(version - 1, Chain::Unknown);
2504 config.base_tx_cost_fixed = Some(config.base_tx_cost_fixed() + 1000);
2505 return config;
2506 }
2507 }
2508
2509 let mut cfg = Self {
2512 version,
2514 chain,
2515
2516 feature_flags: Default::default(),
2518
2519 max_tx_size_bytes: Some(128 * 1024),
2520 max_input_objects: Some(2048),
2522 max_serialized_tx_effects_size_bytes: Some(512 * 1024),
2523 max_serialized_tx_effects_size_bytes_system_tx: Some(512 * 1024 * 16),
2524 max_gas_payment_objects: Some(256),
2525 max_modules_in_publish: Some(128),
2526 max_package_dependencies: None,
2527 max_arguments: Some(512),
2528 max_type_arguments: Some(16),
2529 max_type_argument_depth: Some(16),
2530 max_pure_argument_size: Some(16 * 1024),
2531 max_programmable_tx_commands: Some(1024),
2532 move_binary_format_version: Some(6),
2533 min_move_binary_format_version: None,
2534 binary_module_handles: None,
2535 binary_struct_handles: None,
2536 binary_function_handles: None,
2537 binary_function_instantiations: None,
2538 binary_signatures: None,
2539 binary_constant_pool: None,
2540 binary_identifiers: None,
2541 binary_address_identifiers: None,
2542 binary_struct_defs: None,
2543 binary_struct_def_instantiations: None,
2544 binary_function_defs: None,
2545 binary_field_handles: None,
2546 binary_field_instantiations: None,
2547 binary_friend_decls: None,
2548 binary_enum_defs: None,
2549 binary_enum_def_instantiations: None,
2550 binary_variant_handles: None,
2551 binary_variant_instantiation_handles: None,
2552 max_move_object_size: Some(250 * 1024),
2553 max_move_package_size: Some(100 * 1024),
2554 max_publish_or_upgrade_per_ptb: None,
2555 max_tx_gas: Some(10_000_000_000),
2556 max_gas_price: Some(100_000),
2557 max_gas_price_rgp_factor_for_aborted_transactions: None,
2558 max_gas_computation_bucket: Some(5_000_000),
2559 max_loop_depth: Some(5),
2560 max_generic_instantiation_length: Some(32),
2561 max_function_parameters: Some(128),
2562 max_basic_blocks: Some(1024),
2563 max_value_stack_size: Some(1024),
2564 max_type_nodes: Some(256),
2565 max_generic_instantiation_type_nodes_per_function: None,
2566 max_generic_instantiation_type_nodes_per_module: None,
2567 max_accumulator_type_nodes: None,
2568 max_push_size: Some(10000),
2569 max_struct_definitions: Some(200),
2570 max_function_definitions: Some(1000),
2571 max_fields_in_struct: Some(32),
2572 max_dependency_depth: Some(100),
2573 max_num_event_emit: Some(256),
2574 max_num_new_move_object_ids: Some(2048),
2575 max_num_new_move_object_ids_system_tx: Some(2048 * 16),
2576 max_num_deleted_move_object_ids: Some(2048),
2577 max_num_deleted_move_object_ids_system_tx: Some(2048 * 16),
2578 max_num_transferred_move_object_ids: Some(2048),
2579 max_num_transferred_move_object_ids_system_tx: Some(2048 * 16),
2580 max_event_emit_size: Some(250 * 1024),
2581 max_move_vector_len: Some(256 * 1024),
2582 max_type_to_layout_nodes: None,
2583 max_ptb_value_size: None,
2584
2585 max_back_edges_per_function: Some(10_000),
2586 max_back_edges_per_module: Some(10_000),
2587 max_verifier_meter_ticks_per_function: Some(6_000_000),
2588 max_meter_ticks_per_module: Some(6_000_000),
2589 max_meter_ticks_per_package: None,
2590
2591 object_runtime_max_num_cached_objects: Some(1000),
2592 object_runtime_max_num_cached_objects_system_tx: Some(1000 * 16),
2593 object_runtime_max_num_store_entries: Some(1000),
2594 object_runtime_max_num_store_entries_system_tx: Some(1000 * 16),
2595 base_tx_cost_fixed: Some(110_000),
2596 package_publish_cost_fixed: Some(1_000),
2597 base_tx_cost_per_byte: Some(0),
2598 package_publish_cost_per_byte: Some(80),
2599 obj_access_cost_read_per_byte: Some(15),
2600 obj_access_cost_mutate_per_byte: Some(40),
2601 obj_access_cost_delete_per_byte: Some(40),
2602 obj_access_cost_verify_per_byte: Some(200),
2603 obj_data_cost_refundable: Some(100),
2604 obj_metadata_cost_non_refundable: Some(50),
2605 gas_model_version: Some(1),
2606 storage_rebate_rate: Some(9900),
2607 storage_fund_reinvest_rate: Some(500),
2608 reward_slashing_rate: Some(5000),
2609 storage_gas_price: Some(1),
2610 accumulator_object_storage_cost: None,
2611 max_transactions_per_checkpoint: Some(10_000),
2612 max_checkpoint_size_bytes: Some(30 * 1024 * 1024),
2613
2614 buffer_stake_for_protocol_upgrade_bps: Some(0),
2617
2618 address_from_bytes_cost_base: Some(52),
2622 address_to_u256_cost_base: Some(52),
2624 address_from_u256_cost_base: Some(52),
2626
2627 config_read_setting_impl_cost_base: None,
2630 config_read_setting_impl_cost_per_byte: None,
2631
2632 package_original_package_id_impl_cost_base: None,
2633 package_original_package_id_impl_cost_per_byte: None,
2634
2635 dynamic_field_hash_type_and_key_cost_base: Some(100),
2638 dynamic_field_hash_type_and_key_type_cost_per_byte: Some(2),
2639 dynamic_field_hash_type_and_key_value_cost_per_byte: Some(2),
2640 dynamic_field_hash_type_and_key_type_tag_cost_per_byte: Some(2),
2641 dynamic_field_add_child_object_cost_base: Some(100),
2643 dynamic_field_add_child_object_type_cost_per_byte: Some(10),
2644 dynamic_field_add_child_object_value_cost_per_byte: Some(10),
2645 dynamic_field_add_child_object_struct_tag_cost_per_byte: Some(10),
2646 dynamic_field_borrow_child_object_cost_base: Some(100),
2648 dynamic_field_borrow_child_object_child_ref_cost_per_byte: Some(10),
2649 dynamic_field_borrow_child_object_type_cost_per_byte: Some(10),
2650 dynamic_field_remove_child_object_cost_base: Some(100),
2652 dynamic_field_remove_child_object_child_cost_per_byte: Some(2),
2653 dynamic_field_remove_child_object_type_cost_per_byte: Some(2),
2654 dynamic_field_has_child_object_cost_base: Some(100),
2656 dynamic_field_has_child_object_with_ty_cost_base: Some(100),
2658 dynamic_field_has_child_object_with_ty_type_cost_per_byte: Some(2),
2659 dynamic_field_has_child_object_with_ty_type_tag_cost_per_byte: Some(2),
2660
2661 scratch_add_cost_base: None,
2663 scratch_read_cost_base: None,
2664 scratch_read_value_cost: None,
2665 scratch_remove_cost_base: None,
2666 scratch_exists_cost_base: None,
2667 scratch_exists_with_type_cost_base: None,
2668 scratch_exists_with_type_type_cost: None,
2669 max_scratch_pad_size: None,
2670
2671 event_emit_cost_base: Some(52),
2674 event_emit_value_size_derivation_cost_per_byte: Some(2),
2675 event_emit_tag_size_derivation_cost_per_byte: Some(5),
2676 event_emit_output_cost_per_byte: Some(10),
2677 event_emit_auth_stream_cost: None,
2678
2679 object_borrow_uid_cost_base: Some(52),
2682 object_delete_impl_cost_base: Some(52),
2684 object_record_new_uid_cost_base: Some(52),
2686 object_record_new_uid_from_hash_cost_base: None,
2689
2690 transfer_transfer_internal_cost_base: Some(52),
2693 transfer_party_transfer_internal_cost_base: None,
2695 transfer_freeze_object_cost_base: Some(52),
2697 transfer_share_object_cost_base: Some(52),
2699 transfer_receive_object_cost_base: None,
2700 transfer_receive_object_type_cost_per_byte: None,
2701 transfer_receive_object_cost_per_byte: None,
2702
2703 tx_context_derive_id_cost_base: Some(52),
2706 tx_context_fresh_id_cost_base: None,
2707 tx_context_sender_cost_base: None,
2708 tx_context_epoch_cost_base: None,
2709 tx_context_epoch_timestamp_ms_cost_base: None,
2710 tx_context_sponsor_cost_base: None,
2711 tx_context_rgp_cost_base: None,
2712 tx_context_gas_price_cost_base: None,
2713 tx_context_gas_budget_cost_base: None,
2714 tx_context_ids_created_cost_base: None,
2715 tx_context_replace_cost_base: None,
2716
2717 types_is_one_time_witness_cost_base: Some(52),
2720 types_is_one_time_witness_type_tag_cost_per_byte: Some(2),
2721 types_is_one_time_witness_type_cost_per_byte: Some(2),
2722
2723 validator_validate_metadata_cost_base: Some(52),
2726 validator_validate_metadata_data_cost_per_byte: Some(2),
2727
2728 crypto_invalid_arguments_cost: Some(100),
2730 bls12381_bls12381_min_sig_verify_cost_base: Some(52),
2732 bls12381_bls12381_min_sig_verify_msg_cost_per_byte: Some(2),
2733 bls12381_bls12381_min_sig_verify_msg_cost_per_block: Some(2),
2734
2735 bls12381_bls12381_min_pk_verify_cost_base: Some(52),
2737 bls12381_bls12381_min_pk_verify_msg_cost_per_byte: Some(2),
2738 bls12381_bls12381_min_pk_verify_msg_cost_per_block: Some(2),
2739
2740 ecdsa_k1_ecrecover_keccak256_cost_base: Some(52),
2742 ecdsa_k1_ecrecover_keccak256_msg_cost_per_byte: Some(2),
2743 ecdsa_k1_ecrecover_keccak256_msg_cost_per_block: Some(2),
2744 ecdsa_k1_ecrecover_sha256_cost_base: Some(52),
2745 ecdsa_k1_ecrecover_sha256_msg_cost_per_byte: Some(2),
2746 ecdsa_k1_ecrecover_sha256_msg_cost_per_block: Some(2),
2747
2748 ecdsa_k1_decompress_pubkey_cost_base: Some(52),
2750
2751 ecdsa_k1_secp256k1_verify_keccak256_cost_base: Some(52),
2753 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_byte: Some(2),
2754 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_block: Some(2),
2755 ecdsa_k1_secp256k1_verify_sha256_cost_base: Some(52),
2756 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_byte: Some(2),
2757 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_block: Some(2),
2758
2759 ecdsa_r1_ecrecover_keccak256_cost_base: Some(52),
2761 ecdsa_r1_ecrecover_keccak256_msg_cost_per_byte: Some(2),
2762 ecdsa_r1_ecrecover_keccak256_msg_cost_per_block: Some(2),
2763 ecdsa_r1_ecrecover_sha256_cost_base: Some(52),
2764 ecdsa_r1_ecrecover_sha256_msg_cost_per_byte: Some(2),
2765 ecdsa_r1_ecrecover_sha256_msg_cost_per_block: Some(2),
2766
2767 ecdsa_r1_secp256r1_verify_keccak256_cost_base: Some(52),
2769 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_byte: Some(2),
2770 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_block: Some(2),
2771 ecdsa_r1_secp256r1_verify_sha256_cost_base: Some(52),
2772 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_byte: Some(2),
2773 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_block: Some(2),
2774
2775 ecvrf_ecvrf_verify_cost_base: Some(52),
2777 ecvrf_ecvrf_verify_alpha_string_cost_per_byte: Some(2),
2778 ecvrf_ecvrf_verify_alpha_string_cost_per_block: Some(2),
2779
2780 ed25519_ed25519_verify_cost_base: Some(52),
2782 ed25519_ed25519_verify_msg_cost_per_byte: Some(2),
2783 ed25519_ed25519_verify_msg_cost_per_block: Some(2),
2784
2785 groth16_prepare_verifying_key_bls12381_cost_base: Some(52),
2787 groth16_prepare_verifying_key_bn254_cost_base: Some(52),
2788
2789 groth16_verify_groth16_proof_internal_bls12381_cost_base: Some(52),
2791 groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input: Some(2),
2792 groth16_verify_groth16_proof_internal_bn254_cost_base: Some(52),
2793 groth16_verify_groth16_proof_internal_bn254_cost_per_public_input: Some(2),
2794 groth16_verify_groth16_proof_internal_public_input_cost_per_byte: Some(2),
2795
2796 hash_blake2b256_cost_base: Some(52),
2798 hash_blake2b256_data_cost_per_byte: Some(2),
2799 hash_blake2b256_data_cost_per_block: Some(2),
2800
2801 hash_keccak256_cost_base: Some(52),
2803 hash_keccak256_data_cost_per_byte: Some(2),
2804 hash_keccak256_data_cost_per_block: Some(2),
2805
2806 poseidon_bn254_cost_base: None,
2807 poseidon_bn254_cost_per_block: None,
2808
2809 hmac_hmac_sha3_256_cost_base: Some(52),
2811 hmac_hmac_sha3_256_input_cost_per_byte: Some(2),
2812 hmac_hmac_sha3_256_input_cost_per_block: Some(2),
2813
2814 group_ops_bls12381_decode_scalar_cost: None,
2816 group_ops_bls12381_decode_g1_cost: None,
2817 group_ops_bls12381_decode_g2_cost: None,
2818 group_ops_bls12381_decode_gt_cost: None,
2819 group_ops_bls12381_scalar_add_cost: None,
2820 group_ops_bls12381_g1_add_cost: None,
2821 group_ops_bls12381_g2_add_cost: None,
2822 group_ops_bls12381_gt_add_cost: None,
2823 group_ops_bls12381_scalar_sub_cost: None,
2824 group_ops_bls12381_g1_sub_cost: None,
2825 group_ops_bls12381_g2_sub_cost: None,
2826 group_ops_bls12381_gt_sub_cost: None,
2827 group_ops_bls12381_scalar_mul_cost: None,
2828 group_ops_bls12381_g1_mul_cost: None,
2829 group_ops_bls12381_g2_mul_cost: None,
2830 group_ops_bls12381_gt_mul_cost: None,
2831 group_ops_bls12381_scalar_div_cost: None,
2832 group_ops_bls12381_g1_div_cost: None,
2833 group_ops_bls12381_g2_div_cost: None,
2834 group_ops_bls12381_gt_div_cost: None,
2835 group_ops_bls12381_g1_hash_to_base_cost: None,
2836 group_ops_bls12381_g2_hash_to_base_cost: None,
2837 group_ops_bls12381_g1_hash_to_cost_per_byte: None,
2838 group_ops_bls12381_g2_hash_to_cost_per_byte: None,
2839 group_ops_bls12381_g1_msm_base_cost: None,
2840 group_ops_bls12381_g2_msm_base_cost: None,
2841 group_ops_bls12381_g1_msm_base_cost_per_input: None,
2842 group_ops_bls12381_g2_msm_base_cost_per_input: None,
2843 group_ops_bls12381_msm_max_len: None,
2844 group_ops_bls12381_pairing_cost: None,
2845 group_ops_bls12381_g1_to_uncompressed_g1_cost: None,
2846 group_ops_bls12381_uncompressed_g1_to_g1_cost: None,
2847 group_ops_bls12381_uncompressed_g1_sum_base_cost: None,
2848 group_ops_bls12381_uncompressed_g1_sum_cost_per_term: None,
2849 group_ops_bls12381_uncompressed_g1_sum_max_terms: None,
2850
2851 group_ops_ristretto_decode_scalar_cost: None,
2852 group_ops_ristretto_decode_point_cost: None,
2853 group_ops_ristretto_scalar_add_cost: None,
2854 group_ops_ristretto_point_add_cost: None,
2855 group_ops_ristretto_scalar_sub_cost: None,
2856 group_ops_ristretto_point_sub_cost: None,
2857 group_ops_ristretto_scalar_mul_cost: None,
2858 group_ops_ristretto_point_mul_cost: None,
2859 group_ops_ristretto_scalar_div_cost: None,
2860 group_ops_ristretto_point_div_cost: None,
2861
2862 verify_bulletproofs_ristretto255_base_cost: None,
2863 verify_bulletproofs_ristretto255_cost_per_bit_and_commitment: None,
2864
2865 check_zklogin_id_cost_base: None,
2867 check_zklogin_issuer_cost_base: None,
2869
2870 vdf_verify_vdf_cost: None,
2871 vdf_hash_to_input_cost: None,
2872
2873 nitro_attestation_parse_base_cost: None,
2875 nitro_attestation_parse_cost_per_byte: None,
2876 nitro_attestation_verify_base_cost: None,
2877 nitro_attestation_verify_cost_per_cert: None,
2878
2879 bcs_per_byte_serialized_cost: None,
2880 bcs_legacy_min_output_size_cost: None,
2881 bcs_failure_cost: None,
2882 hash_sha2_256_base_cost: None,
2883 hash_sha2_256_per_byte_cost: None,
2884 hash_sha2_256_legacy_min_input_len_cost: None,
2885 hash_sha3_256_base_cost: None,
2886 hash_sha3_256_per_byte_cost: None,
2887 hash_sha3_256_legacy_min_input_len_cost: None,
2888 type_name_get_base_cost: None,
2889 type_name_get_per_byte_cost: None,
2890 type_name_id_base_cost: None,
2891 string_check_utf8_base_cost: None,
2892 string_check_utf8_per_byte_cost: None,
2893 string_is_char_boundary_base_cost: None,
2894 string_sub_string_base_cost: None,
2895 string_sub_string_per_byte_cost: None,
2896 string_index_of_base_cost: None,
2897 string_index_of_per_byte_pattern_cost: None,
2898 string_index_of_per_byte_searched_cost: None,
2899 vector_empty_base_cost: None,
2900 vector_length_base_cost: None,
2901 vector_push_back_base_cost: None,
2902 vector_push_back_legacy_per_abstract_memory_unit_cost: None,
2903 vector_borrow_base_cost: None,
2904 vector_pop_back_base_cost: None,
2905 vector_destroy_empty_base_cost: None,
2906 vector_swap_base_cost: None,
2907 debug_print_base_cost: None,
2908 debug_print_stack_trace_base_cost: None,
2909
2910 max_size_written_objects: None,
2911 max_size_written_objects_system_tx: None,
2912
2913 max_move_identifier_len: None,
2920 max_move_value_depth: None,
2921 max_move_enum_variants: None,
2922
2923 gas_rounding_step: None,
2924
2925 execution_version: None,
2926
2927 max_event_emit_size_total: None,
2928
2929 consensus_bad_nodes_stake_threshold: None,
2930
2931 max_jwk_votes_per_validator_per_epoch: None,
2932
2933 max_age_of_jwk_in_epochs: None,
2934
2935 random_beacon_reduction_allowed_delta: None,
2936
2937 random_beacon_reduction_lower_bound: None,
2938
2939 random_beacon_dkg_timeout_round: None,
2940
2941 random_beacon_min_round_interval_ms: None,
2942
2943 random_beacon_dkg_version: None,
2944
2945 consensus_max_transaction_size_bytes: None,
2946
2947 consensus_max_transactions_in_block_bytes: None,
2948
2949 consensus_max_num_transactions_in_block: None,
2950
2951 consensus_voting_rounds: None,
2952
2953 max_accumulated_txn_cost_per_object_in_narwhal_commit: None,
2954
2955 max_deferral_rounds_for_congestion_control: None,
2956
2957 epoch_close_deadline_ms: None,
2958
2959 max_txn_cost_overage_per_object_in_commit: None,
2960
2961 allowed_txn_cost_overage_burst_per_object_in_commit: None,
2962
2963 min_checkpoint_interval_ms: None,
2964
2965 checkpoint_summary_version_specific_data: None,
2966
2967 max_soft_bundle_size: None,
2968
2969 bridge_should_try_to_finalize_committee: None,
2970
2971 max_accumulated_txn_cost_per_object_in_mysticeti_commit: None,
2972
2973 max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit: None,
2974
2975 consensus_gc_depth: None,
2976
2977 gas_budget_based_txn_cost_cap_factor: None,
2978
2979 gas_budget_based_txn_cost_absolute_cap_commit_count: None,
2980
2981 sip_45_consensus_amplification_threshold: None,
2982
2983 use_object_per_epoch_marker_table_v2: None,
2984
2985 consensus_commit_rate_estimation_window_size: None,
2986
2987 aliased_addresses: vec![],
2988
2989 translation_per_command_base_charge: None,
2990 translation_per_input_base_charge: None,
2991 translation_pure_input_per_byte_charge: None,
2992 translation_per_type_node_charge: None,
2993 translation_per_reference_node_charge: None,
2994 translation_per_linkage_entry_charge: None,
2995
2996 max_updates_per_settlement_txn: None,
2997
2998 gasless_max_computation_units: None,
2999 gasless_allowed_token_types: None,
3000 gasless_max_unused_inputs: None,
3001 gasless_max_pure_input_bytes: None,
3002 gasless_max_tps: None,
3003 include_special_package_amendments: None,
3004 gasless_max_tx_size_bytes: None,
3005 };
3008 for cur in 2..=version.0 {
3009 match cur {
3010 1 => unreachable!(),
3011 2 => {
3012 cfg.feature_flags.advance_epoch_start_time_in_safe_mode = true;
3013 }
3014 3 => {
3015 cfg.gas_model_version = Some(2);
3017 cfg.max_tx_gas = Some(50_000_000_000);
3019 cfg.base_tx_cost_fixed = Some(2_000);
3021 cfg.storage_gas_price = Some(76);
3023 cfg.feature_flags.loaded_child_objects_fixed = true;
3024 cfg.max_size_written_objects = Some(5 * 1000 * 1000);
3027 cfg.max_size_written_objects_system_tx = Some(50 * 1000 * 1000);
3030 cfg.feature_flags.package_upgrades = true;
3031 }
3032 4 => {
3037 cfg.reward_slashing_rate = Some(10000);
3039 cfg.gas_model_version = Some(3);
3041 }
3042 5 => {
3043 cfg.feature_flags.missing_type_is_compatibility_error = true;
3044 cfg.gas_model_version = Some(4);
3045 cfg.feature_flags.scoring_decision_with_validity_cutoff = true;
3046 }
3050 6 => {
3051 cfg.gas_model_version = Some(5);
3052 cfg.buffer_stake_for_protocol_upgrade_bps = Some(5000);
3053 cfg.feature_flags.consensus_order_end_of_epoch_last = true;
3054 }
3055 7 => {
3056 cfg.feature_flags.disallow_adding_abilities_on_upgrade = true;
3057 cfg.feature_flags
3058 .disable_invariant_violation_check_in_swap_loc = true;
3059 cfg.feature_flags.ban_entry_init = true;
3060 cfg.feature_flags.package_digest_hash_module = true;
3061 }
3062 8 => {
3063 cfg.feature_flags
3064 .disallow_change_struct_type_params_on_upgrade = true;
3065 }
3066 9 => {
3067 cfg.max_move_identifier_len = Some(128);
3069 cfg.feature_flags.no_extraneous_module_bytes = true;
3070 cfg.feature_flags
3071 .advance_to_highest_supported_protocol_version = true;
3072 }
3073 10 => {
3074 cfg.max_verifier_meter_ticks_per_function = Some(16_000_000);
3075 cfg.max_meter_ticks_per_module = Some(16_000_000);
3076 }
3077 11 => {
3078 cfg.max_move_value_depth = Some(128);
3079 }
3080 12 => {
3081 cfg.feature_flags.narwhal_versioned_metadata = true;
3082 if chain != Chain::Mainnet {
3083 cfg.feature_flags.commit_root_state_digest = true;
3084 }
3085
3086 if chain != Chain::Mainnet && chain != Chain::Testnet {
3087 cfg.feature_flags.zklogin_auth = true;
3088 }
3089 }
3090 13 => {}
3091 14 => {
3092 cfg.gas_rounding_step = Some(1_000);
3093 cfg.gas_model_version = Some(6);
3094 }
3095 15 => {
3096 cfg.feature_flags.consensus_transaction_ordering =
3097 ConsensusTransactionOrdering::ByGasPrice;
3098 }
3099 16 => {
3100 cfg.feature_flags.simplified_unwrap_then_delete = true;
3101 }
3102 17 => {
3103 cfg.feature_flags.upgraded_multisig_supported = true;
3104 }
3105 18 => {
3106 cfg.execution_version = Some(1);
3107 cfg.feature_flags.txn_base_cost_as_multiplier = true;
3116 cfg.base_tx_cost_fixed = Some(1_000);
3118 }
3119 19 => {
3120 cfg.max_num_event_emit = Some(1024);
3121 cfg.max_event_emit_size_total = Some(
3124 256 * 250 * 1024, );
3126 }
3127 20 => {
3128 cfg.feature_flags.commit_root_state_digest = true;
3129
3130 if chain != Chain::Mainnet {
3131 cfg.feature_flags.narwhal_new_leader_election_schedule = true;
3132 cfg.consensus_bad_nodes_stake_threshold = Some(20);
3133 }
3134 }
3135
3136 21 => {
3137 if chain != Chain::Mainnet {
3138 cfg.feature_flags.zklogin_supported_providers = BTreeSet::from([
3139 "Google".to_string(),
3140 "Facebook".to_string(),
3141 "Twitch".to_string(),
3142 ]);
3143 }
3144 }
3145 22 => {
3146 cfg.feature_flags.loaded_child_object_format = true;
3147 }
3148 23 => {
3149 cfg.feature_flags.loaded_child_object_format_type = true;
3150 cfg.feature_flags.narwhal_new_leader_election_schedule = true;
3151 cfg.consensus_bad_nodes_stake_threshold = Some(20);
3157 }
3158 24 => {
3159 cfg.feature_flags.simple_conservation_checks = true;
3160 cfg.max_publish_or_upgrade_per_ptb = Some(5);
3161
3162 cfg.feature_flags.end_of_epoch_transaction_supported = true;
3163
3164 if chain != Chain::Mainnet {
3165 cfg.feature_flags.enable_jwk_consensus_updates = true;
3166 cfg.max_jwk_votes_per_validator_per_epoch = Some(240);
3168 cfg.max_age_of_jwk_in_epochs = Some(1);
3169 }
3170 }
3171 25 => {
3172 cfg.feature_flags.zklogin_supported_providers = BTreeSet::from([
3174 "Google".to_string(),
3175 "Facebook".to_string(),
3176 "Twitch".to_string(),
3177 ]);
3178 cfg.feature_flags.zklogin_auth = true;
3179
3180 cfg.feature_flags.enable_jwk_consensus_updates = true;
3182 cfg.max_jwk_votes_per_validator_per_epoch = Some(240);
3183 cfg.max_age_of_jwk_in_epochs = Some(1);
3184 }
3185 26 => {
3186 cfg.gas_model_version = Some(7);
3187 if chain != Chain::Mainnet && chain != Chain::Testnet {
3189 cfg.transfer_receive_object_cost_base = Some(52);
3190 cfg.feature_flags.receive_objects = true;
3191 }
3192 }
3193 27 => {
3194 cfg.gas_model_version = Some(8);
3195 }
3196 28 => {
3197 cfg.check_zklogin_id_cost_base = Some(200);
3199 cfg.check_zklogin_issuer_cost_base = Some(200);
3201
3202 if chain != Chain::Mainnet && chain != Chain::Testnet {
3204 cfg.feature_flags.enable_effects_v2 = true;
3205 }
3206 }
3207 29 => {
3208 cfg.feature_flags.verify_legacy_zklogin_address = true;
3209 }
3210 30 => {
3211 if chain != Chain::Mainnet {
3213 cfg.feature_flags.narwhal_certificate_v2 = true;
3214 }
3215
3216 cfg.random_beacon_reduction_allowed_delta = Some(800);
3217 if chain != Chain::Mainnet {
3219 cfg.feature_flags.enable_effects_v2 = true;
3220 }
3221
3222 cfg.feature_flags.zklogin_supported_providers = BTreeSet::default();
3226
3227 cfg.feature_flags.recompute_has_public_transfer_in_execution = true;
3228 }
3229 31 => {
3230 cfg.execution_version = Some(2);
3231 if chain != Chain::Mainnet && chain != Chain::Testnet {
3233 cfg.feature_flags.shared_object_deletion = true;
3234 }
3235 }
3236 32 => {
3237 if chain != Chain::Mainnet {
3239 cfg.feature_flags.accept_zklogin_in_multisig = true;
3240 }
3241 if chain != Chain::Mainnet {
3243 cfg.transfer_receive_object_cost_base = Some(52);
3244 cfg.feature_flags.receive_objects = true;
3245 }
3246 if chain != Chain::Mainnet && chain != Chain::Testnet {
3248 cfg.feature_flags.random_beacon = true;
3249 cfg.random_beacon_reduction_lower_bound = Some(1600);
3250 cfg.random_beacon_dkg_timeout_round = Some(3000);
3251 cfg.random_beacon_min_round_interval_ms = Some(150);
3252 }
3253 if chain != Chain::Testnet && chain != Chain::Mainnet {
3255 cfg.feature_flags.include_consensus_digest_in_prologue = true;
3256 }
3257
3258 cfg.feature_flags.narwhal_certificate_v2 = true;
3260 }
3261 33 => {
3262 cfg.feature_flags.hardened_otw_check = true;
3263 cfg.feature_flags.allow_receiving_object_id = true;
3264
3265 cfg.transfer_receive_object_cost_base = Some(52);
3267 cfg.feature_flags.receive_objects = true;
3268
3269 if chain != Chain::Mainnet {
3271 cfg.feature_flags.shared_object_deletion = true;
3272 }
3273
3274 cfg.feature_flags.enable_effects_v2 = true;
3275 }
3276 34 => {}
3277 35 => {
3278 if chain != Chain::Mainnet && chain != Chain::Testnet {
3280 cfg.feature_flags.enable_poseidon = true;
3281 cfg.poseidon_bn254_cost_base = Some(260);
3282 cfg.poseidon_bn254_cost_per_block = Some(10);
3283 }
3284
3285 cfg.feature_flags.enable_coin_deny_list = true;
3286 }
3287 36 => {
3288 if chain != Chain::Mainnet && chain != Chain::Testnet {
3290 cfg.feature_flags.enable_group_ops_native_functions = true;
3291 cfg.feature_flags.enable_group_ops_native_function_msm = true;
3292 cfg.group_ops_bls12381_decode_scalar_cost = Some(52);
3294 cfg.group_ops_bls12381_decode_g1_cost = Some(52);
3295 cfg.group_ops_bls12381_decode_g2_cost = Some(52);
3296 cfg.group_ops_bls12381_decode_gt_cost = Some(52);
3297 cfg.group_ops_bls12381_scalar_add_cost = Some(52);
3298 cfg.group_ops_bls12381_g1_add_cost = Some(52);
3299 cfg.group_ops_bls12381_g2_add_cost = Some(52);
3300 cfg.group_ops_bls12381_gt_add_cost = Some(52);
3301 cfg.group_ops_bls12381_scalar_sub_cost = Some(52);
3302 cfg.group_ops_bls12381_g1_sub_cost = Some(52);
3303 cfg.group_ops_bls12381_g2_sub_cost = Some(52);
3304 cfg.group_ops_bls12381_gt_sub_cost = Some(52);
3305 cfg.group_ops_bls12381_scalar_mul_cost = Some(52);
3306 cfg.group_ops_bls12381_g1_mul_cost = Some(52);
3307 cfg.group_ops_bls12381_g2_mul_cost = Some(52);
3308 cfg.group_ops_bls12381_gt_mul_cost = Some(52);
3309 cfg.group_ops_bls12381_scalar_div_cost = Some(52);
3310 cfg.group_ops_bls12381_g1_div_cost = Some(52);
3311 cfg.group_ops_bls12381_g2_div_cost = Some(52);
3312 cfg.group_ops_bls12381_gt_div_cost = Some(52);
3313 cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(52);
3314 cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(52);
3315 cfg.group_ops_bls12381_g1_hash_to_cost_per_byte = Some(2);
3316 cfg.group_ops_bls12381_g2_hash_to_cost_per_byte = Some(2);
3317 cfg.group_ops_bls12381_g1_msm_base_cost = Some(52);
3318 cfg.group_ops_bls12381_g2_msm_base_cost = Some(52);
3319 cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(52);
3320 cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(52);
3321 cfg.group_ops_bls12381_msm_max_len = Some(32);
3322 cfg.group_ops_bls12381_pairing_cost = Some(52);
3323 }
3324 cfg.feature_flags.shared_object_deletion = true;
3326
3327 cfg.consensus_max_transaction_size_bytes = Some(256 * 1024); cfg.consensus_max_transactions_in_block_bytes = Some(6 * 1_024 * 1024);
3329 }
3331 37 => {
3332 cfg.feature_flags.reject_mutable_random_on_entry_functions = true;
3333
3334 if chain != Chain::Mainnet {
3336 cfg.feature_flags.include_consensus_digest_in_prologue = true;
3337 }
3338 }
3339 38 => {
3340 cfg.binary_module_handles = Some(100);
3341 cfg.binary_struct_handles = Some(300);
3342 cfg.binary_function_handles = Some(1500);
3343 cfg.binary_function_instantiations = Some(750);
3344 cfg.binary_signatures = Some(1000);
3345 cfg.binary_constant_pool = Some(4000);
3349 cfg.binary_identifiers = Some(10000);
3350 cfg.binary_address_identifiers = Some(100);
3351 cfg.binary_struct_defs = Some(200);
3352 cfg.binary_struct_def_instantiations = Some(100);
3353 cfg.binary_function_defs = Some(1000);
3354 cfg.binary_field_handles = Some(500);
3355 cfg.binary_field_instantiations = Some(250);
3356 cfg.binary_friend_decls = Some(100);
3357 cfg.max_package_dependencies = Some(32);
3359 cfg.max_modules_in_publish = Some(64);
3360 cfg.execution_version = Some(3);
3362 }
3363 39 => {
3364 }
3366 40 => {}
3367 41 => {
3368 cfg.feature_flags.enable_group_ops_native_functions = true;
3370 cfg.group_ops_bls12381_decode_scalar_cost = Some(52);
3372 cfg.group_ops_bls12381_decode_g1_cost = Some(52);
3373 cfg.group_ops_bls12381_decode_g2_cost = Some(52);
3374 cfg.group_ops_bls12381_decode_gt_cost = Some(52);
3375 cfg.group_ops_bls12381_scalar_add_cost = Some(52);
3376 cfg.group_ops_bls12381_g1_add_cost = Some(52);
3377 cfg.group_ops_bls12381_g2_add_cost = Some(52);
3378 cfg.group_ops_bls12381_gt_add_cost = Some(52);
3379 cfg.group_ops_bls12381_scalar_sub_cost = Some(52);
3380 cfg.group_ops_bls12381_g1_sub_cost = Some(52);
3381 cfg.group_ops_bls12381_g2_sub_cost = Some(52);
3382 cfg.group_ops_bls12381_gt_sub_cost = Some(52);
3383 cfg.group_ops_bls12381_scalar_mul_cost = Some(52);
3384 cfg.group_ops_bls12381_g1_mul_cost = Some(52);
3385 cfg.group_ops_bls12381_g2_mul_cost = Some(52);
3386 cfg.group_ops_bls12381_gt_mul_cost = Some(52);
3387 cfg.group_ops_bls12381_scalar_div_cost = Some(52);
3388 cfg.group_ops_bls12381_g1_div_cost = Some(52);
3389 cfg.group_ops_bls12381_g2_div_cost = Some(52);
3390 cfg.group_ops_bls12381_gt_div_cost = Some(52);
3391 cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(52);
3392 cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(52);
3393 cfg.group_ops_bls12381_g1_hash_to_cost_per_byte = Some(2);
3394 cfg.group_ops_bls12381_g2_hash_to_cost_per_byte = Some(2);
3395 cfg.group_ops_bls12381_g1_msm_base_cost = Some(52);
3396 cfg.group_ops_bls12381_g2_msm_base_cost = Some(52);
3397 cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(52);
3398 cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(52);
3399 cfg.group_ops_bls12381_msm_max_len = Some(32);
3400 cfg.group_ops_bls12381_pairing_cost = Some(52);
3401 }
3402 42 => {}
3403 43 => {
3404 cfg.feature_flags.zklogin_max_epoch_upper_bound_delta = Some(30);
3405 cfg.max_meter_ticks_per_package = Some(16_000_000);
3406 }
3407 44 => {
3408 cfg.feature_flags.include_consensus_digest_in_prologue = true;
3410 if chain != Chain::Mainnet {
3412 cfg.feature_flags.consensus_choice = ConsensusChoice::SwapEachEpoch;
3413 }
3414 }
3415 45 => {
3416 if chain != Chain::Testnet && chain != Chain::Mainnet {
3418 cfg.feature_flags.consensus_network = ConsensusNetwork::Tonic;
3419 }
3420
3421 if chain != Chain::Mainnet {
3422 cfg.feature_flags.mysticeti_leader_scoring_and_schedule = true;
3424 }
3425 cfg.min_move_binary_format_version = Some(6);
3426 cfg.feature_flags.accept_zklogin_in_multisig = true;
3427
3428 if chain != Chain::Mainnet && chain != Chain::Testnet {
3432 cfg.feature_flags.bridge = true;
3433 }
3434 }
3435 46 => {
3436 if chain != Chain::Mainnet {
3438 cfg.feature_flags.bridge = true;
3439 }
3440
3441 cfg.feature_flags.reshare_at_same_initial_version = true;
3443 }
3444 47 => {}
3445 48 => {
3446 cfg.feature_flags.consensus_network = ConsensusNetwork::Tonic;
3448
3449 cfg.feature_flags.resolve_abort_locations_to_package_id = true;
3451
3452 if chain != Chain::Mainnet {
3454 cfg.feature_flags.random_beacon = true;
3455 cfg.random_beacon_reduction_lower_bound = Some(1600);
3456 cfg.random_beacon_dkg_timeout_round = Some(3000);
3457 cfg.random_beacon_min_round_interval_ms = Some(200);
3458 }
3459
3460 cfg.feature_flags.mysticeti_use_committed_subdag_digest = true;
3462 }
3463 49 => {
3464 if chain != Chain::Testnet && chain != Chain::Mainnet {
3465 cfg.move_binary_format_version = Some(7);
3466 }
3467
3468 if chain != Chain::Mainnet && chain != Chain::Testnet {
3470 cfg.feature_flags.enable_vdf = true;
3471 cfg.vdf_verify_vdf_cost = Some(1500);
3474 cfg.vdf_hash_to_input_cost = Some(100);
3475 }
3476
3477 if chain != Chain::Testnet && chain != Chain::Mainnet {
3479 cfg.feature_flags
3480 .record_consensus_determined_version_assignments_in_prologue = true;
3481 }
3482
3483 if chain != Chain::Mainnet {
3485 cfg.feature_flags.consensus_choice = ConsensusChoice::Mysticeti;
3486 }
3487
3488 cfg.feature_flags.fresh_vm_on_framework_upgrade = true;
3490 }
3491 50 => {
3492 if chain != Chain::Mainnet {
3494 cfg.checkpoint_summary_version_specific_data = Some(1);
3495 cfg.min_checkpoint_interval_ms = Some(200);
3496 }
3497
3498 if chain != Chain::Testnet && chain != Chain::Mainnet {
3500 cfg.feature_flags
3501 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = true;
3502 }
3503
3504 cfg.feature_flags.mysticeti_num_leaders_per_round = Some(1);
3505
3506 cfg.max_deferral_rounds_for_congestion_control = Some(10);
3508 }
3509 51 => {
3510 cfg.random_beacon_dkg_version = Some(1);
3511
3512 if chain != Chain::Testnet && chain != Chain::Mainnet {
3513 cfg.feature_flags.enable_coin_deny_list_v2 = true;
3514 }
3515 }
3516 52 => {
3517 if chain != Chain::Mainnet {
3518 cfg.feature_flags.soft_bundle = true;
3519 cfg.max_soft_bundle_size = Some(5);
3520 }
3521
3522 cfg.config_read_setting_impl_cost_base = Some(100);
3523 cfg.config_read_setting_impl_cost_per_byte = Some(40);
3524
3525 if chain != Chain::Testnet && chain != Chain::Mainnet {
3527 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(100);
3528 cfg.feature_flags.per_object_congestion_control_mode =
3529 PerObjectCongestionControlMode::TotalTxCount;
3530 }
3531
3532 cfg.feature_flags.consensus_choice = ConsensusChoice::Mysticeti;
3534
3535 cfg.feature_flags.mysticeti_leader_scoring_and_schedule = true;
3537
3538 cfg.checkpoint_summary_version_specific_data = Some(1);
3540 cfg.min_checkpoint_interval_ms = Some(200);
3541
3542 if chain != Chain::Mainnet {
3544 cfg.feature_flags
3545 .record_consensus_determined_version_assignments_in_prologue = true;
3546 cfg.feature_flags
3547 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = true;
3548 }
3549 if chain != Chain::Mainnet {
3551 cfg.move_binary_format_version = Some(7);
3552 }
3553
3554 if chain != Chain::Testnet && chain != Chain::Mainnet {
3555 cfg.feature_flags.passkey_auth = true;
3556 }
3557 cfg.feature_flags.enable_coin_deny_list_v2 = true;
3558 }
3559 53 => {
3560 cfg.bridge_should_try_to_finalize_committee = Some(chain != Chain::Mainnet);
3562
3563 cfg.feature_flags
3565 .record_consensus_determined_version_assignments_in_prologue = true;
3566 cfg.feature_flags
3567 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = true;
3568
3569 if chain == Chain::Unknown {
3570 cfg.feature_flags.authority_capabilities_v2 = true;
3571 }
3572
3573 if chain != Chain::Mainnet {
3575 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(100);
3576 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(10);
3577 cfg.feature_flags.per_object_congestion_control_mode =
3578 PerObjectCongestionControlMode::TotalTxCount;
3579 }
3580
3581 cfg.bcs_per_byte_serialized_cost = Some(2);
3583 cfg.bcs_legacy_min_output_size_cost = Some(1);
3584 cfg.bcs_failure_cost = Some(52);
3585 cfg.debug_print_base_cost = Some(52);
3586 cfg.debug_print_stack_trace_base_cost = Some(52);
3587 cfg.hash_sha2_256_base_cost = Some(52);
3588 cfg.hash_sha2_256_per_byte_cost = Some(2);
3589 cfg.hash_sha2_256_legacy_min_input_len_cost = Some(1);
3590 cfg.hash_sha3_256_base_cost = Some(52);
3591 cfg.hash_sha3_256_per_byte_cost = Some(2);
3592 cfg.hash_sha3_256_legacy_min_input_len_cost = Some(1);
3593 cfg.type_name_get_base_cost = Some(52);
3594 cfg.type_name_get_per_byte_cost = Some(2);
3595 cfg.string_check_utf8_base_cost = Some(52);
3596 cfg.string_check_utf8_per_byte_cost = Some(2);
3597 cfg.string_is_char_boundary_base_cost = Some(52);
3598 cfg.string_sub_string_base_cost = Some(52);
3599 cfg.string_sub_string_per_byte_cost = Some(2);
3600 cfg.string_index_of_base_cost = Some(52);
3601 cfg.string_index_of_per_byte_pattern_cost = Some(2);
3602 cfg.string_index_of_per_byte_searched_cost = Some(2);
3603 cfg.vector_empty_base_cost = Some(52);
3604 cfg.vector_length_base_cost = Some(52);
3605 cfg.vector_push_back_base_cost = Some(52);
3606 cfg.vector_push_back_legacy_per_abstract_memory_unit_cost = Some(2);
3607 cfg.vector_borrow_base_cost = Some(52);
3608 cfg.vector_pop_back_base_cost = Some(52);
3609 cfg.vector_destroy_empty_base_cost = Some(52);
3610 cfg.vector_swap_base_cost = Some(52);
3611 }
3612 54 => {
3613 cfg.feature_flags.random_beacon = true;
3615 cfg.random_beacon_reduction_lower_bound = Some(1000);
3616 cfg.random_beacon_dkg_timeout_round = Some(3000);
3617 cfg.random_beacon_min_round_interval_ms = Some(500);
3618
3619 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(100);
3621 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(10);
3622 cfg.feature_flags.per_object_congestion_control_mode =
3623 PerObjectCongestionControlMode::TotalTxCount;
3624
3625 cfg.feature_flags.soft_bundle = true;
3627 cfg.max_soft_bundle_size = Some(5);
3628 }
3629 55 => {
3630 cfg.move_binary_format_version = Some(7);
3632
3633 cfg.consensus_max_transactions_in_block_bytes = Some(512 * 1024);
3635 cfg.consensus_max_num_transactions_in_block = Some(512);
3638
3639 cfg.feature_flags.rethrow_serialization_type_layout_errors = true;
3640 }
3641 56 => {
3642 if chain == Chain::Mainnet {
3643 cfg.feature_flags.bridge = true;
3644 }
3645 }
3646 57 => {
3647 cfg.random_beacon_reduction_lower_bound = Some(800);
3649 }
3650 58 => {
3651 if chain == Chain::Mainnet {
3652 cfg.bridge_should_try_to_finalize_committee = Some(true);
3653 }
3654
3655 if chain != Chain::Mainnet && chain != Chain::Testnet {
3656 cfg.feature_flags
3658 .consensus_distributed_vote_scoring_strategy = true;
3659 }
3660 }
3661 59 => {
3662 cfg.feature_flags.consensus_round_prober = true;
3664 }
3665 60 => {
3666 cfg.max_type_to_layout_nodes = Some(512);
3667 cfg.feature_flags.validate_identifier_inputs = true;
3668 }
3669 61 => {
3670 if chain != Chain::Mainnet {
3671 cfg.feature_flags
3673 .consensus_distributed_vote_scoring_strategy = true;
3674 }
3675 cfg.random_beacon_reduction_lower_bound = Some(700);
3677
3678 if chain != Chain::Mainnet && chain != Chain::Testnet {
3679 cfg.feature_flags.mysticeti_fastpath = true;
3681 }
3682 }
3683 62 => {
3684 cfg.feature_flags.relocate_event_module = true;
3685 }
3686 63 => {
3687 cfg.feature_flags.per_object_congestion_control_mode =
3688 PerObjectCongestionControlMode::TotalGasBudgetWithCap;
3689 cfg.gas_budget_based_txn_cost_cap_factor = Some(400_000);
3690 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(18_500_000);
3691 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(240_000_000);
3692 }
3693 64 => {
3694 cfg.feature_flags.per_object_congestion_control_mode =
3695 PerObjectCongestionControlMode::TotalTxCount;
3696 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(40);
3697 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(3);
3698 }
3699 65 => {
3700 cfg.feature_flags
3702 .consensus_distributed_vote_scoring_strategy = true;
3703 }
3704 66 => {
3705 if chain == Chain::Mainnet {
3706 cfg.feature_flags
3708 .consensus_distributed_vote_scoring_strategy = false;
3709 }
3710 }
3711 67 => {
3712 cfg.feature_flags
3714 .consensus_distributed_vote_scoring_strategy = true;
3715 }
3716 68 => {
3717 cfg.group_ops_bls12381_g1_to_uncompressed_g1_cost = Some(26);
3718 cfg.group_ops_bls12381_uncompressed_g1_to_g1_cost = Some(52);
3719 cfg.group_ops_bls12381_uncompressed_g1_sum_base_cost = Some(26);
3720 cfg.group_ops_bls12381_uncompressed_g1_sum_cost_per_term = Some(13);
3721 cfg.group_ops_bls12381_uncompressed_g1_sum_max_terms = Some(2000);
3722
3723 if chain != Chain::Mainnet && chain != Chain::Testnet {
3724 cfg.feature_flags.uncompressed_g1_group_elements = true;
3725 }
3726
3727 cfg.feature_flags.per_object_congestion_control_mode =
3728 PerObjectCongestionControlMode::TotalGasBudgetWithCap;
3729 cfg.gas_budget_based_txn_cost_cap_factor = Some(400_000);
3730 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(18_500_000);
3731 cfg.max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit =
3732 Some(3_700_000); cfg.max_txn_cost_overage_per_object_in_commit = Some(u64::MAX);
3734 cfg.gas_budget_based_txn_cost_absolute_cap_commit_count = Some(50);
3735
3736 cfg.random_beacon_reduction_lower_bound = Some(500);
3738
3739 cfg.feature_flags.disallow_new_modules_in_deps_only_packages = true;
3740 }
3741 69 => {
3742 cfg.consensus_voting_rounds = Some(40);
3744
3745 if chain != Chain::Mainnet && chain != Chain::Testnet {
3746 cfg.feature_flags.consensus_smart_ancestor_selection = true;
3748 }
3749
3750 if chain != Chain::Mainnet {
3751 cfg.feature_flags.uncompressed_g1_group_elements = true;
3752 }
3753 }
3754 70 => {
3755 if chain != Chain::Mainnet {
3756 cfg.feature_flags.consensus_smart_ancestor_selection = true;
3758 cfg.feature_flags
3760 .consensus_round_prober_probe_accepted_rounds = true;
3761 }
3762
3763 cfg.poseidon_bn254_cost_per_block = Some(388);
3764
3765 cfg.gas_model_version = Some(9);
3766 cfg.feature_flags.native_charging_v2 = true;
3767 cfg.bls12381_bls12381_min_sig_verify_cost_base = Some(44064);
3768 cfg.bls12381_bls12381_min_pk_verify_cost_base = Some(49282);
3769 cfg.ecdsa_k1_secp256k1_verify_keccak256_cost_base = Some(1470);
3770 cfg.ecdsa_k1_secp256k1_verify_sha256_cost_base = Some(1470);
3771 cfg.ecdsa_r1_secp256r1_verify_sha256_cost_base = Some(4225);
3772 cfg.ecdsa_r1_secp256r1_verify_keccak256_cost_base = Some(4225);
3773 cfg.ecvrf_ecvrf_verify_cost_base = Some(4848);
3774 cfg.ed25519_ed25519_verify_cost_base = Some(1802);
3775
3776 cfg.ecdsa_r1_ecrecover_keccak256_cost_base = Some(1173);
3778 cfg.ecdsa_r1_ecrecover_sha256_cost_base = Some(1173);
3779 cfg.ecdsa_k1_ecrecover_keccak256_cost_base = Some(500);
3780 cfg.ecdsa_k1_ecrecover_sha256_cost_base = Some(500);
3781
3782 cfg.groth16_prepare_verifying_key_bls12381_cost_base = Some(53838);
3783 cfg.groth16_prepare_verifying_key_bn254_cost_base = Some(82010);
3784 cfg.groth16_verify_groth16_proof_internal_bls12381_cost_base = Some(72090);
3785 cfg.groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input =
3786 Some(8213);
3787 cfg.groth16_verify_groth16_proof_internal_bn254_cost_base = Some(115502);
3788 cfg.groth16_verify_groth16_proof_internal_bn254_cost_per_public_input =
3789 Some(9484);
3790
3791 cfg.hash_keccak256_cost_base = Some(10);
3792 cfg.hash_blake2b256_cost_base = Some(10);
3793
3794 cfg.group_ops_bls12381_decode_scalar_cost = Some(7);
3796 cfg.group_ops_bls12381_decode_g1_cost = Some(2848);
3797 cfg.group_ops_bls12381_decode_g2_cost = Some(3770);
3798 cfg.group_ops_bls12381_decode_gt_cost = Some(3068);
3799
3800 cfg.group_ops_bls12381_scalar_add_cost = Some(10);
3801 cfg.group_ops_bls12381_g1_add_cost = Some(1556);
3802 cfg.group_ops_bls12381_g2_add_cost = Some(3048);
3803 cfg.group_ops_bls12381_gt_add_cost = Some(188);
3804
3805 cfg.group_ops_bls12381_scalar_sub_cost = Some(10);
3806 cfg.group_ops_bls12381_g1_sub_cost = Some(1550);
3807 cfg.group_ops_bls12381_g2_sub_cost = Some(3019);
3808 cfg.group_ops_bls12381_gt_sub_cost = Some(497);
3809
3810 cfg.group_ops_bls12381_scalar_mul_cost = Some(11);
3811 cfg.group_ops_bls12381_g1_mul_cost = Some(4842);
3812 cfg.group_ops_bls12381_g2_mul_cost = Some(9108);
3813 cfg.group_ops_bls12381_gt_mul_cost = Some(27490);
3814
3815 cfg.group_ops_bls12381_scalar_div_cost = Some(91);
3816 cfg.group_ops_bls12381_g1_div_cost = Some(5091);
3817 cfg.group_ops_bls12381_g2_div_cost = Some(9206);
3818 cfg.group_ops_bls12381_gt_div_cost = Some(27804);
3819
3820 cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(2962);
3821 cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(8688);
3822
3823 cfg.group_ops_bls12381_g1_msm_base_cost = Some(62648);
3824 cfg.group_ops_bls12381_g2_msm_base_cost = Some(131192);
3825 cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(1333);
3826 cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(3216);
3827
3828 cfg.group_ops_bls12381_uncompressed_g1_to_g1_cost = Some(677);
3829 cfg.group_ops_bls12381_g1_to_uncompressed_g1_cost = Some(2099);
3830 cfg.group_ops_bls12381_uncompressed_g1_sum_base_cost = Some(77);
3831 cfg.group_ops_bls12381_uncompressed_g1_sum_cost_per_term = Some(26);
3832
3833 cfg.group_ops_bls12381_pairing_cost = Some(26897);
3834 cfg.group_ops_bls12381_uncompressed_g1_sum_max_terms = Some(1200);
3835
3836 cfg.validator_validate_metadata_cost_base = Some(20000);
3837 }
3838 71 => {
3839 cfg.sip_45_consensus_amplification_threshold = Some(5);
3840
3841 cfg.allowed_txn_cost_overage_burst_per_object_in_commit = Some(185_000_000);
3843 }
3844 72 => {
3845 cfg.feature_flags.convert_type_argument_error = true;
3846
3847 cfg.max_tx_gas = Some(50_000_000_000_000);
3850 cfg.max_gas_price = Some(50_000_000_000);
3852
3853 cfg.feature_flags.variant_nodes = true;
3854 }
3855 73 => {
3856 cfg.use_object_per_epoch_marker_table_v2 = Some(true);
3858
3859 if chain != Chain::Mainnet && chain != Chain::Testnet {
3860 cfg.consensus_gc_depth = Some(60);
3863 }
3864
3865 if chain != Chain::Mainnet {
3866 cfg.feature_flags.consensus_zstd_compression = true;
3868 }
3869
3870 cfg.feature_flags.consensus_smart_ancestor_selection = true;
3872 cfg.feature_flags
3874 .consensus_round_prober_probe_accepted_rounds = true;
3875
3876 cfg.feature_flags.per_object_congestion_control_mode =
3878 PerObjectCongestionControlMode::TotalGasBudgetWithCap;
3879 cfg.gas_budget_based_txn_cost_cap_factor = Some(400_000);
3880 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(37_000_000);
3881 cfg.max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit =
3882 Some(7_400_000); cfg.max_txn_cost_overage_per_object_in_commit = Some(u64::MAX);
3884 cfg.gas_budget_based_txn_cost_absolute_cap_commit_count = Some(50);
3885 cfg.allowed_txn_cost_overage_burst_per_object_in_commit = Some(370_000_000);
3886 }
3887 74 => {
3888 if chain != Chain::Mainnet && chain != Chain::Testnet {
3890 cfg.feature_flags.enable_nitro_attestation = true;
3891 }
3892 cfg.nitro_attestation_parse_base_cost = Some(53 * 50);
3893 cfg.nitro_attestation_parse_cost_per_byte = Some(50);
3894 cfg.nitro_attestation_verify_base_cost = Some(49632 * 50);
3895 cfg.nitro_attestation_verify_cost_per_cert = Some(52369 * 50);
3896
3897 cfg.feature_flags.consensus_zstd_compression = true;
3899
3900 if chain != Chain::Mainnet && chain != Chain::Testnet {
3901 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
3902 }
3903 }
3904 75 => {
3905 if chain != Chain::Mainnet {
3906 cfg.feature_flags.passkey_auth = true;
3907 }
3908 }
3909 76 => {
3910 if chain != Chain::Mainnet && chain != Chain::Testnet {
3911 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
3912 cfg.consensus_commit_rate_estimation_window_size = Some(10);
3913 }
3914 cfg.feature_flags.minimize_child_object_mutations = true;
3915
3916 if chain != Chain::Mainnet {
3917 cfg.feature_flags.accept_passkey_in_multisig = true;
3918 }
3919 }
3920 77 => {
3921 cfg.feature_flags.uncompressed_g1_group_elements = true;
3922
3923 if chain != Chain::Mainnet {
3924 cfg.consensus_gc_depth = Some(60);
3925 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
3926 }
3927 }
3928 78 => {
3929 cfg.feature_flags.move_native_context = true;
3930 cfg.tx_context_fresh_id_cost_base = Some(52);
3931 cfg.tx_context_sender_cost_base = Some(30);
3932 cfg.tx_context_epoch_cost_base = Some(30);
3933 cfg.tx_context_epoch_timestamp_ms_cost_base = Some(30);
3934 cfg.tx_context_sponsor_cost_base = Some(30);
3935 cfg.tx_context_gas_price_cost_base = Some(30);
3936 cfg.tx_context_gas_budget_cost_base = Some(30);
3937 cfg.tx_context_ids_created_cost_base = Some(30);
3938 cfg.tx_context_replace_cost_base = Some(30);
3939 cfg.gas_model_version = Some(10);
3940
3941 if chain != Chain::Mainnet {
3942 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
3943 cfg.consensus_commit_rate_estimation_window_size = Some(10);
3944
3945 cfg.feature_flags.per_object_congestion_control_mode =
3947 PerObjectCongestionControlMode::ExecutionTimeEstimate(
3948 ExecutionTimeEstimateParams {
3949 target_utilization: 30,
3950 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
3952 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
3954 stored_observations_limit: u64::MAX,
3955 stake_weighted_median_threshold: 0,
3956 default_none_duration_for_new_keys: false,
3957 observations_chunk_size: None,
3958 },
3959 );
3960 }
3961 }
3962 79 => {
3963 if chain != Chain::Mainnet {
3964 cfg.feature_flags.consensus_median_based_commit_timestamp = true;
3965
3966 cfg.consensus_bad_nodes_stake_threshold = Some(30);
3969
3970 cfg.feature_flags.consensus_batched_block_sync = true;
3971
3972 cfg.feature_flags.enable_nitro_attestation = true
3974 }
3975 cfg.feature_flags.normalize_ptb_arguments = true;
3976
3977 cfg.consensus_gc_depth = Some(60);
3978 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
3979 }
3980 80 => {
3981 cfg.max_ptb_value_size = Some(1024 * 1024);
3982 }
3983 81 => {
3984 cfg.feature_flags.consensus_median_based_commit_timestamp = true;
3985 cfg.feature_flags.enforce_checkpoint_timestamp_monotonicity = true;
3986 cfg.consensus_bad_nodes_stake_threshold = Some(30)
3987 }
3988 82 => {
3989 cfg.feature_flags.max_ptb_value_size_v2 = true;
3990 }
3991 83 => {
3992 if chain == Chain::Mainnet {
3993 let aliased: [u8; 32] = Hex::decode(
3995 "0x0b2da327ba6a4cacbe75dddd50e6e8bbf81d6496e92d66af9154c61c77f7332f",
3996 )
3997 .unwrap()
3998 .try_into()
3999 .unwrap();
4000
4001 cfg.aliased_addresses.push(AliasedAddress {
4003 original: Hex::decode("0xcd8962dad278d8b50fa0f9eb0186bfa4cbdecc6d59377214c88d0286a0ac9562").unwrap().try_into().unwrap(),
4004 aliased,
4005 allowed_tx_digests: vec![
4006 Base58::decode("B2eGLFoMHgj93Ni8dAJBfqGzo8EWSTLBesZzhEpTPA4").unwrap().try_into().unwrap(),
4007 ],
4008 });
4009
4010 cfg.aliased_addresses.push(AliasedAddress {
4011 original: Hex::decode("0xe28b50cef1d633ea43d3296a3f6b67ff0312a5f1a99f0af753c85b8b5de8ff06").unwrap().try_into().unwrap(),
4012 aliased,
4013 allowed_tx_digests: vec![
4014 Base58::decode("J4QqSAgp7VrQtQpMy5wDX4QGsCSEZu3U5KuDAkbESAge").unwrap().try_into().unwrap(),
4015 ],
4016 });
4017 }
4018
4019 if chain != Chain::Mainnet {
4022 cfg.feature_flags.resolve_type_input_ids_to_defining_id = true;
4023 cfg.transfer_party_transfer_internal_cost_base = Some(52);
4024
4025 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
4027 cfg.consensus_commit_rate_estimation_window_size = Some(10);
4028 cfg.feature_flags.per_object_congestion_control_mode =
4029 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4030 ExecutionTimeEstimateParams {
4031 target_utilization: 30,
4032 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4034 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4036 stored_observations_limit: u64::MAX,
4037 stake_weighted_median_threshold: 0,
4038 default_none_duration_for_new_keys: false,
4039 observations_chunk_size: None,
4040 },
4041 );
4042
4043 cfg.feature_flags.consensus_batched_block_sync = true;
4045
4046 cfg.feature_flags.enable_nitro_attestation_upgraded_parsing = true;
4049 cfg.feature_flags.enable_nitro_attestation = true;
4050 }
4051 }
4052 84 => {
4053 if chain == Chain::Mainnet {
4054 cfg.feature_flags.resolve_type_input_ids_to_defining_id = true;
4055 cfg.transfer_party_transfer_internal_cost_base = Some(52);
4056
4057 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
4059 cfg.consensus_commit_rate_estimation_window_size = Some(10);
4060 cfg.feature_flags.per_object_congestion_control_mode =
4061 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4062 ExecutionTimeEstimateParams {
4063 target_utilization: 30,
4064 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4066 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4068 stored_observations_limit: u64::MAX,
4069 stake_weighted_median_threshold: 0,
4070 default_none_duration_for_new_keys: false,
4071 observations_chunk_size: None,
4072 },
4073 );
4074
4075 cfg.feature_flags.consensus_batched_block_sync = true;
4077
4078 cfg.feature_flags.enable_nitro_attestation_upgraded_parsing = true;
4081 cfg.feature_flags.enable_nitro_attestation = true;
4082 }
4083
4084 cfg.feature_flags.per_object_congestion_control_mode =
4086 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4087 ExecutionTimeEstimateParams {
4088 target_utilization: 30,
4089 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4091 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4093 stored_observations_limit: 20,
4094 stake_weighted_median_threshold: 0,
4095 default_none_duration_for_new_keys: false,
4096 observations_chunk_size: None,
4097 },
4098 );
4099 cfg.feature_flags.allow_unbounded_system_objects = true;
4100 }
4101 85 => {
4102 if chain != Chain::Mainnet && chain != Chain::Testnet {
4103 cfg.feature_flags.enable_party_transfer = true;
4104 }
4105
4106 cfg.feature_flags
4107 .record_consensus_determined_version_assignments_in_prologue_v2 = true;
4108 cfg.feature_flags.disallow_self_identifier = true;
4109 cfg.feature_flags.per_object_congestion_control_mode =
4110 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4111 ExecutionTimeEstimateParams {
4112 target_utilization: 50,
4113 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4115 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4117 stored_observations_limit: 20,
4118 stake_weighted_median_threshold: 0,
4119 default_none_duration_for_new_keys: false,
4120 observations_chunk_size: None,
4121 },
4122 );
4123 }
4124 86 => {
4125 cfg.feature_flags.type_tags_in_object_runtime = true;
4126 cfg.max_move_enum_variants = Some(move_core_types::VARIANT_COUNT_MAX);
4127
4128 cfg.feature_flags.per_object_congestion_control_mode =
4130 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4131 ExecutionTimeEstimateParams {
4132 target_utilization: 50,
4133 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4135 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4137 stored_observations_limit: 20,
4138 stake_weighted_median_threshold: 3334,
4139 default_none_duration_for_new_keys: false,
4140 observations_chunk_size: None,
4141 },
4142 );
4143 if chain != Chain::Mainnet {
4145 cfg.feature_flags.enable_party_transfer = true;
4146 }
4147 }
4148 87 => {
4149 if chain == Chain::Mainnet {
4150 cfg.feature_flags.record_time_estimate_processed = true;
4151 }
4152 cfg.feature_flags.better_adapter_type_resolution_errors = true;
4153 }
4154 88 => {
4155 cfg.feature_flags.record_time_estimate_processed = true;
4156 cfg.tx_context_rgp_cost_base = Some(30);
4157 cfg.feature_flags
4158 .ignore_execution_time_observations_after_certs_closed = true;
4159
4160 cfg.feature_flags.per_object_congestion_control_mode =
4163 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4164 ExecutionTimeEstimateParams {
4165 target_utilization: 50,
4166 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4168 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4170 stored_observations_limit: 20,
4171 stake_weighted_median_threshold: 3334,
4172 default_none_duration_for_new_keys: true,
4173 observations_chunk_size: None,
4174 },
4175 );
4176 }
4177 89 => {
4178 cfg.feature_flags.dependency_linkage_error = true;
4179 cfg.feature_flags.additional_multisig_checks = true;
4180 }
4181 90 => {
4182 cfg.max_gas_price_rgp_factor_for_aborted_transactions = Some(100);
4184 cfg.feature_flags.debug_fatal_on_move_invariant_violation = true;
4185 cfg.feature_flags.additional_consensus_digest_indirect_state = true;
4186 cfg.feature_flags.accept_passkey_in_multisig = true;
4187 cfg.feature_flags.passkey_auth = true;
4188 cfg.feature_flags.check_for_init_during_upgrade = true;
4189
4190 if chain != Chain::Mainnet {
4192 cfg.feature_flags.mysticeti_fastpath = true;
4193 }
4194 }
4195 91 => {
4196 cfg.feature_flags.per_command_shared_object_transfer_rules = true;
4197 }
4198 92 => {
4199 cfg.feature_flags.per_command_shared_object_transfer_rules = false;
4200 }
4201 93 => {
4202 cfg.feature_flags
4203 .consensus_checkpoint_signature_key_includes_digest = true;
4204 }
4205 94 => {
4206 cfg.feature_flags.per_object_congestion_control_mode =
4208 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4209 ExecutionTimeEstimateParams {
4210 target_utilization: 50,
4211 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4213 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4215 stored_observations_limit: 18,
4216 stake_weighted_median_threshold: 3334,
4217 default_none_duration_for_new_keys: true,
4218 observations_chunk_size: None,
4219 },
4220 );
4221
4222 cfg.feature_flags.enable_party_transfer = true;
4224 }
4225 95 => {
4226 cfg.type_name_id_base_cost = Some(52);
4227
4228 cfg.max_transactions_per_checkpoint = Some(20_000);
4230 }
4231 96 => {
4232 if chain != Chain::Mainnet && chain != Chain::Testnet {
4234 cfg.feature_flags
4235 .include_checkpoint_artifacts_digest_in_summary = true;
4236 }
4237 cfg.feature_flags.correct_gas_payment_limit_check = true;
4238 cfg.feature_flags.authority_capabilities_v2 = true;
4239 cfg.feature_flags.use_mfp_txns_in_load_initial_object_debts = true;
4240 cfg.feature_flags.cancel_for_failed_dkg_early = true;
4241 cfg.feature_flags.enable_coin_registry = true;
4242
4243 cfg.feature_flags.mysticeti_fastpath = true;
4245 }
4246 97 => {
4247 cfg.feature_flags.additional_borrow_checks = true;
4248 }
4249 98 => {
4250 cfg.event_emit_auth_stream_cost = Some(52);
4251 cfg.feature_flags.better_loader_errors = true;
4252 cfg.feature_flags.generate_df_type_layouts = true;
4253 }
4254 99 => {
4255 cfg.feature_flags.use_new_commit_handler = true;
4256 }
4257 100 => {
4258 cfg.feature_flags.private_generics_verifier_v2 = true;
4259 }
4260 101 => {
4261 cfg.feature_flags.create_root_accumulator_object = true;
4262 cfg.max_updates_per_settlement_txn = Some(100);
4263 if chain != Chain::Mainnet {
4264 cfg.feature_flags.enable_poseidon = true;
4265 }
4266 }
4267 102 => {
4268 cfg.feature_flags.per_object_congestion_control_mode =
4272 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4273 ExecutionTimeEstimateParams {
4274 target_utilization: 50,
4275 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4277 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4279 stored_observations_limit: 180,
4280 stake_weighted_median_threshold: 3334,
4281 default_none_duration_for_new_keys: true,
4282 observations_chunk_size: Some(18),
4283 },
4284 );
4285 cfg.feature_flags.deprecate_global_storage_ops = true;
4286 }
4287 103 => {}
4288 104 => {
4289 cfg.translation_per_command_base_charge = Some(1);
4290 cfg.translation_per_input_base_charge = Some(1);
4291 cfg.translation_pure_input_per_byte_charge = Some(1);
4292 cfg.translation_per_type_node_charge = Some(1);
4293 cfg.translation_per_reference_node_charge = Some(1);
4294 cfg.translation_per_linkage_entry_charge = Some(10);
4295 cfg.gas_model_version = Some(11);
4296 cfg.feature_flags.abstract_size_in_object_runtime = true;
4297 cfg.feature_flags.object_runtime_charge_cache_load_gas = true;
4298 cfg.dynamic_field_hash_type_and_key_cost_base = Some(52);
4299 cfg.dynamic_field_add_child_object_cost_base = Some(52);
4300 cfg.dynamic_field_add_child_object_value_cost_per_byte = Some(1);
4301 cfg.dynamic_field_borrow_child_object_cost_base = Some(52);
4302 cfg.dynamic_field_borrow_child_object_child_ref_cost_per_byte = Some(1);
4303 cfg.dynamic_field_remove_child_object_cost_base = Some(52);
4304 cfg.dynamic_field_remove_child_object_child_cost_per_byte = Some(1);
4305 cfg.dynamic_field_has_child_object_cost_base = Some(52);
4306 cfg.dynamic_field_has_child_object_with_ty_cost_base = Some(52);
4307 cfg.feature_flags.enable_ptb_execution_v2 = true;
4308
4309 cfg.poseidon_bn254_cost_base = Some(260);
4310
4311 cfg.feature_flags.consensus_skip_gced_accept_votes = true;
4312
4313 if chain != Chain::Mainnet {
4314 cfg.feature_flags
4315 .enable_nitro_attestation_all_nonzero_pcrs_parsing = true;
4316 }
4317
4318 cfg.feature_flags
4319 .include_cancelled_randomness_txns_in_prologue = true;
4320 }
4321 105 => {
4322 cfg.feature_flags.enable_multi_epoch_transaction_expiration = true;
4323 cfg.feature_flags.disable_preconsensus_locking = true;
4324
4325 if chain != Chain::Mainnet {
4326 cfg.feature_flags
4327 .enable_nitro_attestation_always_include_required_pcrs_parsing = true;
4328 }
4329 }
4330 106 => {
4331 cfg.accumulator_object_storage_cost = Some(7600);
4333
4334 if chain != Chain::Mainnet && chain != Chain::Testnet {
4335 cfg.feature_flags.enable_accumulators = true;
4336 cfg.feature_flags.enable_address_balance_gas_payments = true;
4337 cfg.feature_flags.enable_authenticated_event_streams = true;
4338 cfg.feature_flags.enable_object_funds_withdraw = true;
4339 }
4340 }
4341 107 => {
4342 cfg.feature_flags
4343 .consensus_skip_gced_blocks_in_direct_finalization = true;
4344
4345 if in_integration_test() {
4347 cfg.consensus_gc_depth = Some(6);
4348 cfg.consensus_max_num_transactions_in_block = Some(8);
4349 }
4350 }
4351 108 => {
4352 cfg.feature_flags.gas_rounding_halve_digits = true;
4353 cfg.feature_flags.flexible_tx_context_positions = true;
4354 cfg.feature_flags.disable_entry_point_signature_check = true;
4355
4356 if chain != Chain::Mainnet {
4357 cfg.feature_flags.address_aliases = true;
4358
4359 cfg.feature_flags.enable_accumulators = true;
4360 cfg.feature_flags.enable_address_balance_gas_payments = true;
4361 }
4362
4363 cfg.feature_flags.enable_poseidon = true;
4364 }
4365 109 => {
4366 cfg.binary_variant_handles = Some(1024);
4367 cfg.binary_variant_instantiation_handles = Some(1024);
4368 cfg.feature_flags.restrict_hot_or_not_entry_functions = true;
4369 }
4370 110 => {
4371 cfg.feature_flags
4372 .enable_nitro_attestation_all_nonzero_pcrs_parsing = true;
4373 cfg.feature_flags
4374 .enable_nitro_attestation_always_include_required_pcrs_parsing = true;
4375 if chain != Chain::Mainnet && chain != Chain::Testnet {
4376 cfg.feature_flags.split_checkpoints_in_consensus_handler = true;
4377 }
4378 cfg.feature_flags.validate_zklogin_public_identifier = true;
4379 cfg.feature_flags.fix_checkpoint_signature_mapping = true;
4380 cfg.feature_flags
4381 .consensus_always_accept_system_transactions = true;
4382 if chain != Chain::Mainnet {
4383 cfg.feature_flags.enable_object_funds_withdraw = true;
4384 }
4385 }
4386 111 => {
4387 cfg.feature_flags.validator_metadata_verify_v2 = true;
4388 }
4389 112 => {
4390 cfg.group_ops_ristretto_decode_scalar_cost = Some(7);
4391 cfg.group_ops_ristretto_decode_point_cost = Some(200);
4392 cfg.group_ops_ristretto_scalar_add_cost = Some(10);
4393 cfg.group_ops_ristretto_point_add_cost = Some(500);
4394 cfg.group_ops_ristretto_scalar_sub_cost = Some(10);
4395 cfg.group_ops_ristretto_point_sub_cost = Some(500);
4396 cfg.group_ops_ristretto_scalar_mul_cost = Some(11);
4397 cfg.group_ops_ristretto_point_mul_cost = Some(1200);
4398 cfg.group_ops_ristretto_scalar_div_cost = Some(151);
4399 cfg.group_ops_ristretto_point_div_cost = Some(2500);
4400
4401 if chain != Chain::Mainnet && chain != Chain::Testnet {
4402 cfg.feature_flags.enable_ristretto255_group_ops = true;
4403 }
4404 }
4405 113 => {
4406 cfg.feature_flags.address_balance_gas_check_rgp_at_signing = true;
4407 if chain != Chain::Mainnet && chain != Chain::Testnet {
4408 cfg.feature_flags.defer_unpaid_amplification = true;
4409 }
4410 }
4411 114 => {
4412 cfg.feature_flags.randomize_checkpoint_tx_limit_in_tests = true;
4413 cfg.feature_flags.address_balance_gas_reject_gas_coin_arg = true;
4414 if chain != Chain::Mainnet {
4415 cfg.feature_flags.split_checkpoints_in_consensus_handler = true;
4416 cfg.feature_flags.enable_authenticated_event_streams = true;
4417 cfg.feature_flags
4418 .include_checkpoint_artifacts_digest_in_summary = true;
4419 }
4420 }
4421 115 => {
4422 cfg.feature_flags.normalize_depth_formula = true;
4423 }
4424 116 => {
4425 cfg.feature_flags.gasless_transaction_drop_safety = true;
4426 cfg.feature_flags.address_aliases = true;
4427 cfg.feature_flags.relax_valid_during_for_owned_inputs = true;
4428 cfg.feature_flags.defer_unpaid_amplification = false;
4430 cfg.feature_flags.enable_display_registry = true;
4431 }
4432 117 => {}
4433 118 => {
4434 cfg.feature_flags.use_coin_party_owner = true;
4435 }
4436 119 => {
4437 cfg.execution_version = Some(4);
4439 cfg.feature_flags.address_balance_gas_reject_gas_coin_arg = false;
4440 cfg.feature_flags.merge_randomness_into_checkpoint = true;
4441 if chain != Chain::Mainnet {
4442 cfg.feature_flags.enable_gasless = true;
4443 cfg.gasless_max_computation_units = Some(50_000);
4444 cfg.gasless_allowed_token_types = Some(vec![]);
4445 cfg.feature_flags.enable_coin_reservation_obj_refs = true;
4446 cfg.feature_flags
4447 .convert_withdrawal_compatibility_ptb_arguments = true;
4448 }
4449 cfg.gasless_max_unused_inputs = Some(1);
4450 cfg.gasless_max_pure_input_bytes = Some(32);
4451 if chain == Chain::Testnet {
4452 cfg.gasless_allowed_token_types = Some(vec![(TESTNET_USDC.to_string(), 0)]);
4453 }
4454 cfg.transfer_receive_object_cost_per_byte = Some(1);
4455 cfg.transfer_receive_object_type_cost_per_byte = Some(2);
4456 }
4457 120 => {
4458 cfg.feature_flags.disallow_jump_orphans = true;
4459 }
4460 121 => {
4461 if chain != Chain::Mainnet {
4463 cfg.feature_flags.defer_unpaid_amplification = true;
4464 cfg.gasless_max_tps = Some(50);
4465 }
4466 cfg.feature_flags
4467 .early_return_receive_object_mismatched_type = true;
4468 }
4469 122 => {
4470 cfg.feature_flags.defer_unpaid_amplification = true;
4472 cfg.verify_bulletproofs_ristretto255_base_cost = Some(30000);
4474 cfg.verify_bulletproofs_ristretto255_cost_per_bit_and_commitment = Some(6500);
4475 if chain != Chain::Mainnet && chain != Chain::Testnet {
4476 cfg.feature_flags.enable_verify_bulletproofs_ristretto255 = true;
4477 }
4478 cfg.feature_flags.gasless_verify_remaining_balance = true;
4479 cfg.include_special_package_amendments = match chain {
4480 Chain::Mainnet => Some(MAINNET_LINKAGE_AMENDMENTS.clone()),
4481 Chain::Testnet => Some(TESTNET_LINKAGE_AMENDMENTS.clone()),
4482 Chain::Unknown => None,
4483 };
4484 cfg.gasless_max_tx_size_bytes = Some(16 * 1024);
4485 cfg.gasless_max_tps = Some(300);
4486 cfg.gasless_max_computation_units = Some(5_000);
4487 }
4488 123 => {
4489 cfg.gas_model_version = Some(13);
4490 }
4491 124 => {
4492 if chain != Chain::Mainnet && chain != Chain::Testnet {
4493 cfg.feature_flags.timestamp_based_epoch_close = true;
4494 }
4495 cfg.gas_model_version = Some(14);
4496 cfg.feature_flags.limit_groth16_pvk_inputs = true;
4497
4498 cfg.feature_flags.enable_accumulators = true;
4504 cfg.feature_flags.enable_address_balance_gas_payments = true;
4505 cfg.feature_flags.enable_authenticated_event_streams = true;
4506 cfg.feature_flags.enable_coin_reservation_obj_refs = true;
4507 cfg.feature_flags.enable_object_funds_withdraw = true;
4508 cfg.feature_flags
4509 .convert_withdrawal_compatibility_ptb_arguments = true;
4510 cfg.feature_flags.split_checkpoints_in_consensus_handler = true;
4511 cfg.feature_flags
4512 .include_checkpoint_artifacts_digest_in_summary = true;
4513 cfg.feature_flags.enable_gasless = true;
4514
4515 if chain == Chain::Mainnet {
4520 cfg.gasless_allowed_token_types = Some(vec![
4521 (MAINNET_USDC.to_string(), 10_000),
4522 (MAINNET_USDSUI.to_string(), 10_000),
4523 (MAINNET_SUI_USDE.to_string(), 10_000),
4524 (MAINNET_USDY.to_string(), 10_000),
4525 (MAINNET_FDUSD.to_string(), 10_000),
4526 (MAINNET_AUSD.to_string(), 10_000),
4527 (MAINNET_USDB.to_string(), 10_000),
4528 ]);
4529 }
4530 }
4531 125 => {
4532 cfg.feature_flags.granular_post_execution_checks = true;
4533 if chain != Chain::Mainnet {
4534 cfg.feature_flags.timestamp_based_epoch_close = true;
4535 }
4536 }
4537 126 => {
4538 cfg.feature_flags.early_exit_on_iffw = true;
4539 }
4540 127 => {
4541 cfg.feature_flags.always_advance_dkg_to_resolution = true;
4542
4543 cfg.verify_bulletproofs_ristretto255_base_cost = Some(23866);
4544 cfg.verify_bulletproofs_ristretto255_cost_per_bit_and_commitment = Some(1324);
4545 cfg.group_ops_ristretto_decode_scalar_cost = Some(5);
4546 cfg.group_ops_ristretto_decode_point_cost = Some(216);
4547 cfg.group_ops_ristretto_scalar_add_cost = Some(2);
4548 cfg.group_ops_ristretto_point_add_cost = Some(8);
4549 cfg.group_ops_ristretto_scalar_sub_cost = Some(2);
4550 cfg.group_ops_ristretto_point_sub_cost = Some(8);
4551 cfg.group_ops_ristretto_scalar_mul_cost = Some(5);
4552 cfg.group_ops_ristretto_point_mul_cost = Some(1763);
4553 cfg.group_ops_ristretto_scalar_div_cost = Some(557);
4554 cfg.group_ops_ristretto_point_div_cost = Some(2244);
4555
4556 if chain != Chain::Mainnet {
4557 cfg.feature_flags.enable_ristretto255_group_ops = true;
4558 cfg.feature_flags.enable_verify_bulletproofs_ristretto255 = true;
4559 }
4560
4561 cfg.feature_flags.timestamp_based_epoch_close = true;
4562 }
4563 128 => {
4564 cfg.max_generic_instantiation_type_nodes_per_function = Some(10_000);
4565 cfg.max_generic_instantiation_type_nodes_per_module = Some(500_000);
4566 cfg.binary_enum_defs = Some(200);
4567 cfg.binary_enum_def_instantiations = Some(100);
4568 }
4569 129 => {
4570 cfg.feature_flags.enable_unified_linkage = true;
4571 }
4572 130 => {
4573 cfg.feature_flags.record_net_unsettled_object_withdraws = true;
4574 cfg.feature_flags.enable_init_on_upgrade = true;
4575 cfg.epoch_close_deadline_ms = Some(120_000);
4576 cfg.scratch_add_cost_base = Some(13);
4577 cfg.scratch_read_cost_base = Some(13);
4578 cfg.scratch_read_value_cost = Some(1);
4579 cfg.scratch_remove_cost_base = Some(13);
4580 cfg.scratch_exists_cost_base = Some(13);
4581 cfg.scratch_exists_with_type_cost_base = Some(13);
4582 cfg.scratch_exists_with_type_type_cost = Some(1);
4583 let max_commands = cfg.max_programmable_tx_commands() as u64;
4584 cfg.max_scratch_pad_size = Some(16 * max_commands);
4585 if chain != Chain::Mainnet && chain != Chain::Testnet {
4587 cfg.feature_flags.zklogin_circuit_mode = 1;
4588 }
4589 }
4590 131 => {
4591 cfg.feature_flags.share_transaction_deny_config_in_consensus = true;
4592 cfg.feature_flags.framework_tx_context_mut_restrictions = true;
4593 }
4594 132 => {
4595 if chain != Chain::Mainnet && chain != Chain::Testnet {
4596 cfg.feature_flags.defer_owned_object_double_spend = true;
4597 cfg.feature_flags.create_forwarding_address_registry = true;
4598 }
4599 cfg.object_record_new_uid_from_hash_cost_base = Some(1);
4600 cfg.feature_flags
4601 .enable_order_independent_upgrade_init_linkage = true;
4602 }
4603 133 => {
4604 cfg.feature_flags
4605 .include_function_signatures_in_instantiation_limits = true;
4606 cfg.max_accumulator_type_nodes = Some(16);
4607 }
4608 134 => {
4609 if chain != Chain::Mainnet {
4616 cfg.package_original_package_id_impl_cost_base = Some(52);
4617 let package_read_cost_per_byte = cfg.obj_access_cost_read_per_byte();
4618 cfg.package_original_package_id_impl_cost_per_byte =
4619 Some(package_read_cost_per_byte);
4620
4621 cfg.consensus_max_transactions_in_block_bytes = Some(288 * 1024);
4622 cfg.consensus_max_num_transactions_in_block = Some(128);
4623 }
4624
4625 if chain == Chain::Mainnet {
4626 cfg.feature_flags.defer_unpaid_amplification = false;
4627 }
4628 }
4629 135 => {
4630 cfg.package_original_package_id_impl_cost_base = Some(52);
4633 let package_read_cost_per_byte = cfg.obj_access_cost_read_per_byte();
4634 cfg.package_original_package_id_impl_cost_per_byte =
4635 Some(package_read_cost_per_byte);
4636
4637 cfg.consensus_max_transactions_in_block_bytes = Some(288 * 1024);
4638 cfg.consensus_max_num_transactions_in_block = Some(128);
4639
4640 cfg.feature_flags.defer_unpaid_amplification = false;
4641 }
4642 136 => {
4643 cfg.feature_flags.ptb_tx_context_restrictions = true;
4644
4645 if chain != Chain::Mainnet && chain != Chain::Testnet {
4646 cfg.feature_flags.allowed_proposers = true;
4647 }
4648 }
4649 _ => panic!("unsupported version {:?}", version),
4660 }
4661 }
4662
4663 cfg
4664 }
4665
4666 pub fn apply_seeded_test_overrides(&mut self, seed: &[u8; 32]) {
4667 if !self.feature_flags.randomize_checkpoint_tx_limit_in_tests
4668 || !self.feature_flags.split_checkpoints_in_consensus_handler
4669 {
4670 return;
4671 }
4672
4673 if !mysten_common::in_test_configuration() {
4674 return;
4675 }
4676
4677 use rand::{Rng, SeedableRng, rngs::StdRng};
4678 let mut rng = StdRng::from_seed(*seed);
4679 let max_txns = rng.gen_range(10..=100u64);
4680 info!("seeded test override: max_transactions_per_checkpoint = {max_txns}");
4681 self.max_transactions_per_checkpoint = Some(max_txns);
4682 }
4683
4684 pub fn verifier_config(&self, signing_limits: Option<(usize, usize, usize)>) -> VerifierConfig {
4690 let (
4691 max_back_edges_per_function,
4692 max_back_edges_per_module,
4693 sanity_check_with_regex_reference_safety,
4694 ) = if let Some((
4695 max_back_edges_per_function,
4696 max_back_edges_per_module,
4697 sanity_check_with_regex_reference_safety,
4698 )) = signing_limits
4699 {
4700 (
4701 Some(max_back_edges_per_function),
4702 Some(max_back_edges_per_module),
4703 Some(sanity_check_with_regex_reference_safety),
4704 )
4705 } else {
4706 (None, None, None)
4707 };
4708
4709 let additional_borrow_checks = if signing_limits.is_some() {
4710 true
4712 } else {
4713 self.additional_borrow_checks()
4714 };
4715 let deprecate_global_storage_ops = if signing_limits.is_some() {
4716 true
4718 } else {
4719 self.deprecate_global_storage_ops()
4720 };
4721
4722 VerifierConfig {
4723 max_loop_depth: Some(self.max_loop_depth() as usize),
4724 max_generic_instantiation_length: Some(self.max_generic_instantiation_length() as usize),
4725 max_function_parameters: Some(self.max_function_parameters() as usize),
4726 max_basic_blocks: Some(self.max_basic_blocks() as usize),
4727 max_value_stack_size: self.max_value_stack_size() as usize,
4728 max_type_nodes: Some(self.max_type_nodes() as usize),
4729 max_generic_instantiation_type_nodes_per_function: self
4730 .max_generic_instantiation_type_nodes_per_function_as_option()
4731 .map(|v| v as usize),
4732 max_generic_instantiation_type_nodes_per_module: self
4733 .max_generic_instantiation_type_nodes_per_module_as_option()
4734 .map(|v| v as usize),
4735 include_function_signatures_in_instantiation_limits: self
4736 .include_function_signatures_in_instantiation_limits(),
4737 max_push_size: Some(self.max_push_size() as usize),
4738 max_dependency_depth: Some(self.max_dependency_depth() as usize),
4739 max_fields_in_struct: Some(self.max_fields_in_struct() as usize),
4740 max_function_definitions: Some(self.max_function_definitions() as usize),
4741 max_data_definitions: Some(self.max_struct_definitions() as usize),
4742 max_constant_vector_len: Some(self.max_move_vector_len()),
4743 max_back_edges_per_function,
4744 max_back_edges_per_module,
4745 max_basic_blocks_in_script: None,
4746 max_identifier_len: self.max_move_identifier_len_as_option(), disallow_self_identifier: self.feature_flags.disallow_self_identifier,
4748 allow_receiving_object_id: self.allow_receiving_object_id(),
4749 reject_mutable_random_on_entry_functions: self
4750 .reject_mutable_random_on_entry_functions(),
4751 bytecode_version: self.move_binary_format_version(),
4752 max_variants_in_enum: self.max_move_enum_variants_as_option(),
4753 additional_borrow_checks,
4754 better_loader_errors: self.better_loader_errors(),
4755 private_generics_verifier_v2: self.private_generics_verifier_v2(),
4756 sanity_check_with_regex_reference_safety: sanity_check_with_regex_reference_safety
4757 .map(|limit| limit as u128),
4758 deprecate_global_storage_ops,
4759 disable_entry_point_signature_check: self.disable_entry_point_signature_check(),
4760 switch_to_regex_reference_safety: false,
4761 framework_tx_context_mut_restrictions: self.framework_tx_context_mut_restrictions(),
4762 disallow_jump_orphans: self.disallow_jump_orphans(),
4763 }
4764 }
4765
4766 pub fn binary_config(
4767 &self,
4768 override_deprecate_global_storage_ops_during_deserialization: Option<bool>,
4769 ) -> BinaryConfig {
4770 let deprecate_global_storage_ops =
4771 override_deprecate_global_storage_ops_during_deserialization
4772 .unwrap_or_else(|| self.deprecate_global_storage_ops());
4773 BinaryConfig::new(
4774 self.move_binary_format_version(),
4775 self.min_move_binary_format_version_as_option()
4776 .unwrap_or(VERSION_1),
4777 self.no_extraneous_module_bytes(),
4778 deprecate_global_storage_ops,
4779 TableConfig {
4780 module_handles: self.binary_module_handles_as_option().unwrap_or(u16::MAX),
4781 datatype_handles: self.binary_struct_handles_as_option().unwrap_or(u16::MAX),
4782 function_handles: self.binary_function_handles_as_option().unwrap_or(u16::MAX),
4783 function_instantiations: self
4784 .binary_function_instantiations_as_option()
4785 .unwrap_or(u16::MAX),
4786 signatures: self.binary_signatures_as_option().unwrap_or(u16::MAX),
4787 constant_pool: self.binary_constant_pool_as_option().unwrap_or(u16::MAX),
4788 identifiers: self.binary_identifiers_as_option().unwrap_or(u16::MAX),
4789 address_identifiers: self
4790 .binary_address_identifiers_as_option()
4791 .unwrap_or(u16::MAX),
4792 struct_defs: self.binary_struct_defs_as_option().unwrap_or(u16::MAX),
4793 struct_def_instantiations: self
4794 .binary_struct_def_instantiations_as_option()
4795 .unwrap_or(u16::MAX),
4796 function_defs: self.binary_function_defs_as_option().unwrap_or(u16::MAX),
4797 field_handles: self.binary_field_handles_as_option().unwrap_or(u16::MAX),
4798 field_instantiations: self
4799 .binary_field_instantiations_as_option()
4800 .unwrap_or(u16::MAX),
4801 friend_decls: self.binary_friend_decls_as_option().unwrap_or(u16::MAX),
4802 enum_defs: self.binary_enum_defs_as_option().unwrap_or(u16::MAX),
4803 enum_def_instantiations: self
4804 .binary_enum_def_instantiations_as_option()
4805 .unwrap_or(u16::MAX),
4806 variant_handles: self.binary_variant_handles_as_option().unwrap_or(u16::MAX),
4807 variant_instantiation_handles: self
4808 .binary_variant_instantiation_handles_as_option()
4809 .unwrap_or(u16::MAX),
4810 },
4811 )
4812 }
4813
4814 pub fn apply_overrides_for_testing(
4818 override_fn: impl Fn(ProtocolVersion, Self) -> Self + Send + Sync + 'static,
4819 ) -> OverrideGuard {
4820 let mut cur = CONFIG_OVERRIDE.lock().unwrap();
4821 assert!(cur.is_none(), "config override already present");
4822 *cur = Some(Box::new(override_fn));
4823 OverrideGuard
4824 }
4825
4826 fn apply_config_override(version: ProtocolVersion, mut ret: Self) -> Self {
4827 if let Some(override_fn) = CONFIG_OVERRIDE.lock().unwrap().as_ref() {
4828 warn!(
4829 "overriding ProtocolConfig settings with custom settings (you should not see this log outside of tests)"
4830 );
4831 ret = override_fn(version, ret);
4832 }
4833 ret
4834 }
4835}
4836
4837impl ProtocolConfig {
4841 pub fn set_execution_version_for_testing(&mut self, val: u64) {
4845 let current = self.execution_version.unwrap_or(0);
4846 assert!(
4847 val >= current,
4848 "cannot downgrade execution_version from {current} to {val}: running an old \
4849 executor against a newer protocol config/framework is unsupported. To test \
4850 frozen executor behavior, start from the last protocol version of that executor \
4851 instead, so genesis loads the matching framework snapshot (see \
4852 test_address_balance_gas_v3_accumulator_sign)."
4853 );
4854 self.execution_version = Some(val);
4855 }
4856
4857 pub fn set_zklogin_circuit_mode_for_testing(&mut self, val: u64) {
4860 self.feature_flags.zklogin_circuit_mode = val
4861 }
4862
4863 pub fn set_per_object_congestion_control_mode_for_testing(
4864 &mut self,
4865 val: PerObjectCongestionControlMode,
4866 ) {
4867 self.feature_flags.per_object_congestion_control_mode = val;
4868 }
4869
4870 pub fn set_consensus_choice_for_testing(&mut self, val: ConsensusChoice) {
4871 self.feature_flags.consensus_choice = val;
4872 }
4873
4874 pub fn set_consensus_network_for_testing(&mut self, val: ConsensusNetwork) {
4875 self.feature_flags.consensus_network = val;
4876 }
4877
4878 pub fn set_zklogin_max_epoch_upper_bound_delta_for_testing(&mut self, val: Option<u64>) {
4879 self.feature_flags.zklogin_max_epoch_upper_bound_delta = val
4880 }
4881
4882 pub fn set_mysticeti_num_leaders_per_round_for_testing(&mut self, val: Option<usize>) {
4883 self.feature_flags.mysticeti_num_leaders_per_round = val;
4884 }
4885
4886 pub fn disable_accumulators_for_testing(&mut self) {
4887 self.feature_flags.enable_accumulators = false;
4888 self.feature_flags.enable_address_balance_gas_payments = false;
4889 }
4890
4891 pub fn enable_coin_reservation_for_testing(&mut self) {
4892 self.feature_flags.enable_coin_reservation_obj_refs = true;
4893 self.feature_flags
4894 .convert_withdrawal_compatibility_ptb_arguments = true;
4895 self.execution_version = Some(self.execution_version.map_or(4, |v| v.max(4)));
4898 }
4899
4900 pub fn disable_coin_reservation_for_testing(&mut self) {
4901 self.feature_flags.enable_coin_reservation_obj_refs = false;
4902 self.feature_flags
4903 .convert_withdrawal_compatibility_ptb_arguments = false;
4904 }
4905
4906 pub fn enable_address_balance_gas_payments_for_testing(&mut self) {
4907 self.feature_flags.enable_accumulators = true;
4908 self.feature_flags.allow_private_accumulator_entrypoints = true;
4909 self.feature_flags.enable_address_balance_gas_payments = true;
4910 self.feature_flags.address_balance_gas_check_rgp_at_signing = true;
4911 self.feature_flags.address_balance_gas_reject_gas_coin_arg = false;
4912 self.execution_version = Some(self.execution_version.map_or(4, |v| v.max(4)))
4913 }
4914
4915 pub fn enable_gasless_for_testing(&mut self) {
4916 self.enable_address_balance_gas_payments_for_testing();
4917 self.feature_flags.enable_gasless = true;
4918 self.feature_flags.gasless_verify_remaining_balance = true;
4919 self.gasless_max_computation_units = Some(5_000);
4920 self.gasless_allowed_token_types = Some(vec![]);
4921 self.gasless_max_tps = Some(1000);
4922 self.gasless_max_tx_size_bytes = Some(16 * 1024);
4923 }
4924
4925 pub fn disable_gasless_for_testing(&mut self) {
4926 self.feature_flags.enable_gasless = false;
4927 self.gasless_max_computation_units = None;
4928 self.gasless_allowed_token_types = None;
4929 }
4930
4931 pub fn enable_authenticated_event_streams_for_testing(&mut self) {
4932 self.feature_flags.enable_accumulators = true;
4933 self.feature_flags.enable_authenticated_event_streams = true;
4934 self.feature_flags
4935 .include_checkpoint_artifacts_digest_in_summary = true;
4936 self.feature_flags.split_checkpoints_in_consensus_handler = true;
4937 }
4938}
4939
4940type OverrideFn = dyn Fn(ProtocolVersion, ProtocolConfig) -> ProtocolConfig + Send + Sync;
4941
4942static CONFIG_OVERRIDE: Mutex<Option<Box<OverrideFn>>> = Mutex::new(None);
4943
4944#[must_use]
4945pub struct OverrideGuard;
4946
4947impl Drop for OverrideGuard {
4948 fn drop(&mut self) {
4949 info!("restoring override fn");
4950 *CONFIG_OVERRIDE.lock().unwrap() = None;
4951 }
4952}
4953
4954#[derive(PartialEq, Eq)]
4957pub enum LimitThresholdCrossed {
4958 None,
4959 Soft(u128, u128),
4960 Hard(u128, u128),
4961}
4962
4963pub fn check_limit_in_range<T: Into<V>, U: Into<V>, V: PartialOrd + Into<u128>>(
4966 x: T,
4967 soft_limit: U,
4968 hard_limit: V,
4969) -> LimitThresholdCrossed {
4970 let x: V = x.into();
4971 let soft_limit: V = soft_limit.into();
4972
4973 debug_assert!(soft_limit <= hard_limit);
4974
4975 if x >= hard_limit {
4978 LimitThresholdCrossed::Hard(x.into(), hard_limit.into())
4979 } else if x < soft_limit {
4980 LimitThresholdCrossed::None
4981 } else {
4982 LimitThresholdCrossed::Soft(x.into(), soft_limit.into())
4983 }
4984}
4985
4986#[macro_export]
4987macro_rules! check_limit {
4988 ($x:expr, $hard:expr) => {
4989 check_limit!($x, $hard, $hard)
4990 };
4991 ($x:expr, $soft:expr, $hard:expr) => {
4992 check_limit_in_range($x as u64, $soft, $hard)
4993 };
4994}
4995
4996#[macro_export]
5000macro_rules! check_limit_by_meter {
5001 ($is_metered:expr, $x:expr, $metered_limit:expr, $unmetered_hard_limit:expr, $metric:expr) => {{
5002 let (h, metered_str) = if $is_metered {
5004 ($metered_limit, "metered")
5005 } else {
5006 ($unmetered_hard_limit, "unmetered")
5008 };
5009 use sui_protocol_config::check_limit_in_range;
5010 let result = check_limit_in_range($x as u64, $metered_limit, h);
5011 match result {
5012 LimitThresholdCrossed::None => {}
5013 LimitThresholdCrossed::Soft(_, _) => {
5014 $metric.with_label_values(&[metered_str, "soft"]).inc();
5015 }
5016 LimitThresholdCrossed::Hard(_, _) => {
5017 $metric.with_label_values(&[metered_str, "hard"]).inc();
5018 }
5019 };
5020 result
5021 }};
5022}
5023
5024pub type Amendments = BTreeMap<AccountAddress, BTreeMap<AccountAddress, AccountAddress>>;
5027
5028static MAINNET_LINKAGE_AMENDMENTS: LazyLock<Arc<Amendments>> =
5029 LazyLock::new(|| parse_amendments(include_str!("mainnet_amendments.json")));
5030
5031static TESTNET_LINKAGE_AMENDMENTS: LazyLock<Arc<Amendments>> =
5032 LazyLock::new(|| parse_amendments(include_str!("testnet_amendments.json")));
5033
5034fn parse_amendments(json: &str) -> Arc<Amendments> {
5035 #[derive(serde::Deserialize)]
5036 struct AmendmentEntry {
5037 root: String,
5038 deps: Vec<DepEntry>,
5039 }
5040
5041 #[derive(serde::Deserialize)]
5042 struct DepEntry {
5043 original_id: String,
5044 version_id: String,
5045 }
5046
5047 let entries: Vec<AmendmentEntry> =
5048 serde_json::from_str(json).expect("Failed to parse amendments JSON");
5049 let mut amendments = BTreeMap::new();
5050 for entry in entries {
5051 let root_id = AccountAddress::from_hex_literal(&entry.root).unwrap();
5052 let mut dep_ids = BTreeMap::new();
5053 for dep in entry.deps {
5054 let orig_id = AccountAddress::from_hex_literal(&dep.original_id).unwrap();
5055 let upgraded_id = AccountAddress::from_hex_literal(&dep.version_id).unwrap();
5056 assert!(
5057 dep_ids.insert(orig_id, upgraded_id).is_none(),
5058 "Duplicate original ID in amendments table"
5059 );
5060 }
5061 assert!(
5062 amendments.insert(root_id, dep_ids).is_none(),
5063 "Duplicate root ID in amendments table"
5064 );
5065 }
5066 Arc::new(amendments)
5067}
5068
5069#[cfg(all(test, not(msim)))]
5070mod test {
5071 use insta::assert_yaml_snapshot;
5072
5073 use super::*;
5074
5075 #[test]
5076 fn snapshot_tests() {
5077 println!("\n============================================================================");
5078 println!("! !");
5079 println!("! IMPORTANT: never update snapshots from this test. only add new versions! !");
5080 println!("! !");
5081 println!("============================================================================\n");
5082 for chain_id in &[Chain::Unknown, Chain::Mainnet, Chain::Testnet] {
5083 let chain_str = match chain_id {
5087 Chain::Unknown => "".to_string(),
5088 _ => format!("{:?}_", chain_id),
5089 };
5090 for i in MIN_PROTOCOL_VERSION..=MAX_PROTOCOL_VERSION {
5091 let cur = ProtocolVersion::new(i);
5092 assert_yaml_snapshot!(
5093 format!("{}version_{}", chain_str, cur.as_u64()),
5094 ProtocolConfig::get_for_version(cur, *chain_id)
5095 );
5096 }
5097 }
5098 }
5099
5100 #[test]
5101 fn test_getters() {
5102 let prot: ProtocolConfig =
5103 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5104 assert_eq!(
5105 prot.max_arguments(),
5106 prot.max_arguments_as_option().unwrap()
5107 );
5108 }
5109
5110 #[test]
5111 fn test_setters() {
5112 let mut prot: ProtocolConfig =
5113 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5114 prot.set_max_arguments_for_testing(123);
5115 assert_eq!(prot.max_arguments(), 123);
5116
5117 prot.set_max_arguments_from_str_for_testing("321".to_string());
5118 assert_eq!(prot.max_arguments(), 321);
5119
5120 prot.disable_max_arguments_for_testing();
5121 assert_eq!(prot.max_arguments_as_option(), None);
5122
5123 prot.set_attr_for_testing("max_arguments".to_string(), "456".to_string());
5124 assert_eq!(prot.max_arguments(), 456);
5125 }
5126
5127 #[test]
5128 fn test_execution_version_setter_allows_upgrade() {
5129 let mut prot = ProtocolConfig::get_for_max_version_UNSAFE();
5130 let current = prot.execution_version();
5131 prot.set_execution_version_for_testing(current);
5132 prot.set_execution_version_for_testing(current + 1);
5133 assert_eq!(prot.execution_version(), current + 1);
5134 }
5135
5136 #[test]
5137 #[should_panic(expected = "cannot downgrade execution_version")]
5138 fn test_execution_version_setter_panics_on_downgrade() {
5139 let mut prot = ProtocolConfig::get_for_max_version_UNSAFE();
5140 let current = prot.execution_version();
5141 prot.set_execution_version_for_testing(current - 1);
5142 }
5143
5144 #[test]
5145 fn test_feature_flag_setter_by_string() {
5146 let mut prot: ProtocolConfig =
5147 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5148 assert!(!prot.zklogin_auth());
5149 prot.set_feature_flag_for_testing("zklogin_auth".to_string(), true);
5150 assert!(prot.zklogin_auth());
5151 prot.set_feature_flag_for_testing("zklogin_auth".to_string(), false);
5152 assert!(!prot.zklogin_auth());
5153 }
5154
5155 #[test]
5156 #[should_panic(expected = "unknown feature flag")]
5157 fn test_feature_flag_setter_unknown_flag() {
5158 let mut prot: ProtocolConfig =
5159 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5160 prot.set_feature_flag_for_testing("some random string".to_string(), true);
5161 }
5162
5163 #[test]
5164 fn test_get_for_version_if_supported_applies_test_overrides() {
5165 let before =
5166 ProtocolConfig::get_for_version_if_supported(ProtocolVersion::new(1), Chain::Unknown)
5167 .unwrap();
5168
5169 assert!(!before.enable_coin_reservation_obj_refs());
5170
5171 let _guard = ProtocolConfig::apply_overrides_for_testing(|_, mut cfg| {
5172 cfg.enable_coin_reservation_for_testing();
5173 cfg
5174 });
5175
5176 let after =
5177 ProtocolConfig::get_for_version_if_supported(ProtocolVersion::new(1), Chain::Unknown)
5178 .unwrap();
5179
5180 assert!(after.enable_coin_reservation_obj_refs());
5181 }
5182
5183 #[test]
5184 #[should_panic(expected = "unsupported version")]
5185 fn max_version_test() {
5186 let _ = ProtocolConfig::get_for_version_impl(
5189 ProtocolVersion::new(MAX_PROTOCOL_VERSION + 1),
5190 Chain::Unknown,
5191 );
5192 }
5193
5194 #[test]
5195 fn lookup_by_string_test() {
5196 let prot: ProtocolConfig =
5197 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5198 assert!(prot.lookup_attr("some random string".to_string()).is_none());
5200
5201 assert!(
5202 prot.lookup_attr("max_arguments".to_string())
5203 == Some(ProtocolConfigValue::u32(prot.max_arguments())),
5204 );
5205
5206 assert!(
5208 prot.lookup_attr("max_move_identifier_len".to_string())
5209 .is_none()
5210 );
5211
5212 let prot: ProtocolConfig =
5214 ProtocolConfig::get_for_version(ProtocolVersion::new(9), Chain::Unknown);
5215 assert!(
5216 prot.lookup_attr("max_move_identifier_len".to_string())
5217 == Some(ProtocolConfigValue::u64(prot.max_move_identifier_len()))
5218 );
5219
5220 let prot: ProtocolConfig =
5221 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5222 assert!(
5224 prot.attr_map()
5225 .get("max_move_identifier_len")
5226 .unwrap()
5227 .is_none()
5228 );
5229 assert!(
5231 prot.attr_map().get("max_arguments").unwrap()
5232 == &Some(ProtocolConfigValue::u32(prot.max_arguments()))
5233 );
5234
5235 let prot: ProtocolConfig =
5237 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5238 assert!(
5240 prot.feature_flags
5241 .lookup_attr("some random string".to_owned())
5242 .is_none()
5243 );
5244 assert!(
5245 !prot
5246 .feature_flags
5247 .attr_map()
5248 .contains_key("some random string")
5249 );
5250
5251 assert!(
5253 prot.feature_flags
5254 .lookup_attr("package_upgrades".to_owned())
5255 == Some(false)
5256 );
5257 assert!(
5258 prot.feature_flags
5259 .attr_map()
5260 .get("package_upgrades")
5261 .unwrap()
5262 == &false
5263 );
5264 let prot: ProtocolConfig =
5265 ProtocolConfig::get_for_version(ProtocolVersion::new(4), Chain::Unknown);
5266 assert!(
5268 prot.feature_flags
5269 .lookup_attr("package_upgrades".to_owned())
5270 == Some(true)
5271 );
5272 assert!(
5273 prot.feature_flags
5274 .attr_map()
5275 .get("package_upgrades")
5276 .unwrap()
5277 == &true
5278 );
5279 }
5280
5281 #[test]
5282 fn limit_range_fn_test() {
5283 let low = 100u32;
5284 let high = 10000u64;
5285
5286 assert!(check_limit!(1u8, low, high) == LimitThresholdCrossed::None);
5287 assert!(matches!(
5288 check_limit!(255u16, low, high),
5289 LimitThresholdCrossed::Soft(255u128, 100)
5290 ));
5291 assert!(matches!(
5297 check_limit!(2550000u64, low, high),
5298 LimitThresholdCrossed::Hard(2550000, 10000)
5299 ));
5300
5301 assert!(matches!(
5302 check_limit!(2550000u64, high, high),
5303 LimitThresholdCrossed::Hard(2550000, 10000)
5304 ));
5305
5306 assert!(matches!(
5307 check_limit!(1u8, high),
5308 LimitThresholdCrossed::None
5309 ));
5310
5311 assert!(check_limit!(255u16, high) == LimitThresholdCrossed::None);
5312
5313 assert!(matches!(
5314 check_limit!(2550000u64, high),
5315 LimitThresholdCrossed::Hard(2550000, 10000)
5316 ));
5317 }
5318
5319 #[test]
5320 fn linkage_amendments_load() {
5321 let mainnet = LazyLock::force(&MAINNET_LINKAGE_AMENDMENTS);
5322 let testnet = LazyLock::force(&TESTNET_LINKAGE_AMENDMENTS);
5323 assert!(!mainnet.is_empty(), "mainnet amendments must not be empty");
5324 assert!(!testnet.is_empty(), "testnet amendments must not be empty");
5325 }
5326
5327 #[test]
5328 fn render_scalar_fields_use_precision_safe_encoding() {
5329 use mysten_common::rpc_format::Unmetered;
5330
5331 let config = ProtocolConfig::get_for_max_version_UNSAFE();
5332 let rendered = config
5333 .render::<serde_json::Value>(&mut Unmetered)
5334 .expect("render should succeed");
5335
5336 let max_args = rendered
5337 .get("max_arguments")
5338 .expect("max_arguments set at max version");
5339 assert!(
5340 max_args.is_number(),
5341 "u32 should render as number, got {max_args:?}",
5342 );
5343
5344 let max_tx_size = rendered
5345 .get("max_tx_size_bytes")
5346 .expect("max_tx_size_bytes set at max version");
5347 assert!(
5348 max_tx_size.is_string(),
5349 "u64 should render as string, got {max_tx_size:?}",
5350 );
5351 }
5352
5353 #[test]
5354 fn render_includes_non_scalar_gasless_allowlist_as_json() {
5355 use mysten_common::rpc_format::Unmetered;
5356 use serde_json::json;
5357
5358 let mut config = ProtocolConfig::get_for_max_version_UNSAFE();
5359 config.set_gasless_allowed_token_types_for_testing(vec![
5360 ("0xa::usdc::USDC".to_string(), 10_000),
5361 ("0xb::usdt::USDT".to_string(), 0),
5362 ]);
5363
5364 let rendered = config
5365 .render::<serde_json::Value>(&mut Unmetered)
5366 .expect("render should succeed under Unmetered budget");
5367 let allowlist = rendered
5368 .get("gasless_allowed_token_types")
5369 .expect("entry should be present after the testing setter");
5370
5371 assert_eq!(
5374 allowlist,
5375 &json!([["0xa::usdc::USDC", "10000"], ["0xb::usdt::USDT", "0"],]),
5376 );
5377 }
5378
5379 #[test]
5380 fn render_targets_prost_value_for_grpc() {
5381 use mysten_common::rpc_format::Unmetered;
5382 use prost_types::value::Kind;
5383
5384 let mut config = ProtocolConfig::get_for_max_version_UNSAFE();
5385 config.set_gasless_allowed_token_types_for_testing(vec![(
5386 "0xa::usdc::USDC".to_string(),
5387 10_000,
5388 )]);
5389
5390 let rendered = config
5391 .render::<prost_types::Value>(&mut Unmetered)
5392 .expect("render to prost Value should succeed");
5393 let allowlist = rendered
5394 .get("gasless_allowed_token_types")
5395 .expect("entry should be present after the testing setter");
5396
5397 let Some(Kind::ListValue(outer)) = &allowlist.kind else {
5399 panic!(
5400 "expected ListValue at the top level, got {:?}",
5401 allowlist.kind
5402 );
5403 };
5404 assert_eq!(outer.values.len(), 1, "one allowlisted entry");
5405 let Some(Kind::ListValue(entry)) = &outer.values[0].kind else {
5406 panic!("expected each entry to be a ListValue");
5407 };
5408 assert_eq!(entry.values.len(), 2, "entry has (coin_type, amount)");
5409
5410 let Some(Kind::StringValue(coin_type)) = &entry.values[0].kind else {
5411 panic!("expected coin_type as StringValue");
5412 };
5413 assert_eq!(coin_type, "0xa::usdc::USDC");
5414
5415 let Some(Kind::StringValue(amount)) = &entry.values[1].kind else {
5417 panic!(
5418 "expected minimum_transfer_amount as StringValue (precision-safe u64); got {:?}",
5419 entry.values[1].kind,
5420 );
5421 };
5422 assert_eq!(amount, "10000");
5423 }
5424
5425 #[test]
5426 fn render_emits_null_for_unset_protocol_versions() {
5427 use mysten_common::rpc_format::Unmetered;
5428
5429 let config = ProtocolConfig::get_for_version(1.into(), Chain::Unknown);
5430 let rendered = config
5431 .render::<serde_json::Value>(&mut Unmetered)
5432 .expect("render should succeed");
5433 let entry = rendered
5437 .get("gasless_allowed_token_types")
5438 .expect("key should be present for every protocol version");
5439 assert!(
5440 entry.is_null(),
5441 "value should be null for pre-feature protocol version, got {entry:?}",
5442 );
5443 }
5444}