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
30pub mod reachability;
31
32#[doc(hidden)]
35pub use antithesis_sdk::linkme;
36#[doc(hidden)]
37pub use mysten_common::assert_reachable_simtest;
38
39const MIN_PROTOCOL_VERSION: u64 = 1;
41const MAX_PROTOCOL_VERSION: u64 = 138;
42
43const TESTNET_USDC: &str =
44 "0xa1ec7fc00a6f40db9693ad1415d0c193ad3906494428cf252621037bd7117e29::usdc::USDC";
45
46const MAINNET_USDC: &str =
47 "0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC";
48const MAINNET_USDSUI: &str =
49 "0x44f838219cf67b058f3b37907b655f226153c18e33dfcd0da559a844fea9b1c1::usdsui::USDSUI";
50const MAINNET_SUI_USDE: &str =
51 "0x41d587e5336f1c86cad50d38a7136db99333bb9bda91cea4ba69115defeb1402::sui_usde::SUI_USDE";
52const MAINNET_USDY: &str =
53 "0x960b531667636f39e85867775f52f6b1f220a058c4de786905bdf761e06a56bb::usdy::USDY";
54const MAINNET_FDUSD: &str =
55 "0xf16e6b723f242ec745dfd7634ad072c42d5c1d9ac9d62a39c381303eaa57693a::fdusd::FDUSD";
56const MAINNET_AUSD: &str =
57 "0x2053d08c1e2bd02791056171aab0fd12bd7cd7efad2ab8f6b9c8902f14df2ff2::ausd::AUSD";
58const MAINNET_USDB: &str =
59 "0xe14726c336e81b32328e92afc37345d159f5b550b09fa92bd43640cfdd0a0cfd::usdb::USDB";
60
61#[derive(Copy, Clone, Debug, Hash, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)]
413pub struct ProtocolVersion(u64);
414
415impl ProtocolVersion {
416 pub const MIN: Self = Self(MIN_PROTOCOL_VERSION);
421
422 pub const MAX: Self = Self(MAX_PROTOCOL_VERSION);
423
424 #[cfg(not(msim))]
425 pub const MAX_ALLOWED: Self = Self::MAX;
426
427 #[cfg(msim)]
429 pub const MAX_ALLOWED: Self = Self(MAX_PROTOCOL_VERSION + 1);
430
431 pub fn new(v: u64) -> Self {
432 Self(v)
433 }
434
435 pub const fn as_u64(&self) -> u64 {
436 self.0
437 }
438
439 pub fn max() -> Self {
442 Self::MAX
443 }
444
445 pub fn prev(self) -> Self {
446 Self(self.0.checked_sub(1).unwrap())
447 }
448}
449
450impl From<u64> for ProtocolVersion {
451 fn from(v: u64) -> Self {
452 Self::new(v)
453 }
454}
455
456impl std::ops::Sub<u64> for ProtocolVersion {
457 type Output = Self;
458 fn sub(self, rhs: u64) -> Self::Output {
459 Self::new(self.0 - rhs)
460 }
461}
462
463impl std::ops::Add<u64> for ProtocolVersion {
464 type Output = Self;
465 fn add(self, rhs: u64) -> Self::Output {
466 Self::new(self.0 + rhs)
467 }
468}
469
470#[derive(
471 Clone, Serialize, Deserialize, Debug, Default, PartialEq, Copy, PartialOrd, Ord, Eq, ValueEnum,
472)]
473pub enum Chain {
474 Mainnet,
475 Testnet,
476 #[default]
477 Unknown,
478}
479
480impl Chain {
481 pub fn as_str(self) -> &'static str {
482 match self {
483 Chain::Mainnet => "mainnet",
484 Chain::Testnet => "testnet",
485 Chain::Unknown => "unknown",
486 }
487 }
488}
489
490pub struct Error(pub String);
491
492#[derive(Default, Clone, Serialize, Deserialize, Debug, ProtocolConfigFeatureFlagsGetters)]
495struct FeatureFlags {
496 #[serde(skip_serializing_if = "is_false")]
499 package_upgrades: bool,
500 #[serde(skip_serializing_if = "is_false")]
503 commit_root_state_digest: bool,
504 #[serde(skip_serializing_if = "is_false")]
506 advance_epoch_start_time_in_safe_mode: bool,
507 #[serde(skip_serializing_if = "is_false")]
510 loaded_child_objects_fixed: bool,
511 #[serde(skip_serializing_if = "is_false")]
514 missing_type_is_compatibility_error: bool,
515 #[serde(skip_serializing_if = "is_false")]
518 scoring_decision_with_validity_cutoff: bool,
519
520 #[serde(skip_serializing_if = "is_false")]
523 consensus_order_end_of_epoch_last: bool,
524
525 #[serde(skip_serializing_if = "is_false")]
529 consensus_slim_block_propagation: bool,
530
531 #[serde(skip_serializing_if = "is_false")]
533 disallow_adding_abilities_on_upgrade: bool,
534 #[serde(skip_serializing_if = "is_false")]
536 disable_invariant_violation_check_in_swap_loc: bool,
537 #[serde(skip_serializing_if = "is_false")]
540 advance_to_highest_supported_protocol_version: bool,
541 #[serde(skip_serializing_if = "is_false")]
543 ban_entry_init: bool,
544 #[serde(skip_serializing_if = "is_false")]
546 package_digest_hash_module: bool,
547 #[serde(skip_serializing_if = "is_false")]
549 disallow_change_struct_type_params_on_upgrade: bool,
550 #[serde(skip_serializing_if = "is_false")]
552 no_extraneous_module_bytes: bool,
553 #[serde(skip_serializing_if = "is_false")]
555 narwhal_versioned_metadata: bool,
556
557 #[serde(skip_serializing_if = "is_false")]
559 zklogin_auth: bool,
560 #[serde(skip_serializing_if = "is_zero")]
563 zklogin_circuit_mode: u64,
564 #[serde(skip_serializing_if = "ConsensusTransactionOrdering::is_none")]
566 consensus_transaction_ordering: ConsensusTransactionOrdering,
567
568 #[serde(skip_serializing_if = "is_false")]
576 simplified_unwrap_then_delete: bool,
577 #[serde(skip_serializing_if = "is_false")]
579 upgraded_multisig_supported: bool,
580 #[serde(skip_serializing_if = "is_false")]
582 txn_base_cost_as_multiplier: bool,
583
584 #[serde(skip_serializing_if = "is_false")]
586 shared_object_deletion: bool,
587
588 #[serde(skip_serializing_if = "is_false")]
590 narwhal_new_leader_election_schedule: bool,
591
592 #[serde(skip_serializing_if = "is_empty")]
594 zklogin_supported_providers: BTreeSet<String>,
595
596 #[serde(skip_serializing_if = "is_false")]
598 loaded_child_object_format: bool,
599
600 #[serde(skip_serializing_if = "is_false")]
601 #[skip_protocol_config_accessor]
602 enable_jwk_consensus_updates: bool,
603
604 #[serde(skip_serializing_if = "is_false")]
605 #[skip_protocol_config_accessor]
606 end_of_epoch_transaction_supported: bool,
607
608 #[serde(skip_serializing_if = "is_false")]
611 simple_conservation_checks: bool,
612
613 #[serde(skip_serializing_if = "is_false")]
615 loaded_child_object_format_type: bool,
616
617 #[serde(skip_serializing_if = "is_false")]
619 receive_objects: bool,
620
621 #[serde(skip_serializing_if = "is_false")]
623 consensus_checkpoint_signature_key_includes_digest: bool,
624
625 #[serde(skip_serializing_if = "is_false")]
627 random_beacon: bool,
628
629 #[serde(skip_serializing_if = "is_false")]
631 #[skip_protocol_config_accessor]
632 bridge: bool,
633
634 #[serde(skip_serializing_if = "is_false")]
635 enable_effects_v2: bool,
636
637 #[serde(skip_serializing_if = "is_false")]
639 narwhal_certificate_v2: bool,
640
641 #[serde(skip_serializing_if = "is_false")]
643 verify_legacy_zklogin_address: bool,
644
645 #[serde(skip_serializing_if = "is_false")]
647 throughput_aware_consensus_submission: bool,
648
649 #[serde(skip_serializing_if = "is_false")]
651 recompute_has_public_transfer_in_execution: bool,
652
653 #[serde(skip_serializing_if = "is_false")]
655 accept_zklogin_in_multisig: bool,
656
657 #[serde(skip_serializing_if = "is_false")]
659 accept_passkey_in_multisig: bool,
660
661 #[serde(skip_serializing_if = "is_false")]
663 validate_zklogin_public_identifier: bool,
664
665 #[serde(skip_serializing_if = "is_false")]
668 include_consensus_digest_in_prologue: bool,
669
670 #[serde(skip_serializing_if = "is_false")]
672 hardened_otw_check: bool,
673
674 #[serde(skip_serializing_if = "is_false")]
676 allow_receiving_object_id: bool,
677
678 #[serde(skip_serializing_if = "is_false")]
680 enable_poseidon: bool,
681
682 #[serde(skip_serializing_if = "is_false")]
684 enable_coin_deny_list: bool,
685
686 #[serde(skip_serializing_if = "is_false")]
688 enable_group_ops_native_functions: bool,
689
690 #[serde(skip_serializing_if = "is_false")]
692 enable_group_ops_native_function_msm: bool,
693
694 #[serde(skip_serializing_if = "is_false")]
696 enable_ristretto255_group_ops: bool,
697
698 #[serde(skip_serializing_if = "is_false")]
700 enable_verify_bulletproofs_ristretto255: bool,
701
702 #[serde(skip_serializing_if = "is_false")]
704 enable_nitro_attestation: bool,
705
706 #[serde(skip_serializing_if = "is_false")]
708 enable_nitro_attestation_upgraded_parsing: bool,
709
710 #[serde(skip_serializing_if = "is_false")]
712 enable_nitro_attestation_all_nonzero_pcrs_parsing: bool,
713
714 #[serde(skip_serializing_if = "is_false")]
716 enable_nitro_attestation_always_include_required_pcrs_parsing: bool,
717
718 #[serde(skip_serializing_if = "is_false")]
720 reject_mutable_random_on_entry_functions: bool,
721
722 #[serde(skip_serializing_if = "PerObjectCongestionControlMode::is_none")]
724 per_object_congestion_control_mode: PerObjectCongestionControlMode,
725
726 #[serde(skip_serializing_if = "ConsensusChoice::is_narwhal")]
728 consensus_choice: ConsensusChoice,
729
730 #[serde(skip_serializing_if = "ConsensusNetwork::is_anemo")]
732 consensus_network: ConsensusNetwork,
733
734 #[serde(skip_serializing_if = "is_false")]
736 correct_gas_payment_limit_check: bool,
737
738 #[serde(skip_serializing_if = "Option::is_none")]
740 zklogin_max_epoch_upper_bound_delta: Option<u64>,
741
742 #[serde(skip_serializing_if = "is_false")]
744 mysticeti_leader_scoring_and_schedule: bool,
745
746 #[serde(skip_serializing_if = "is_false")]
748 reshare_at_same_initial_version: bool,
749
750 #[serde(skip_serializing_if = "is_false")]
752 resolve_abort_locations_to_package_id: bool,
753
754 #[serde(skip_serializing_if = "is_false")]
758 mysticeti_use_committed_subdag_digest: bool,
759
760 #[serde(skip_serializing_if = "is_false")]
762 enable_vdf: bool,
763
764 #[serde(skip_serializing_if = "is_false")]
768 record_consensus_determined_version_assignments_in_prologue: bool,
769 #[serde(skip_serializing_if = "is_false")]
772 record_consensus_determined_version_assignments_in_prologue_v2: bool,
773
774 #[serde(skip_serializing_if = "is_false")]
776 fresh_vm_on_framework_upgrade: bool,
777
778 #[serde(skip_serializing_if = "is_false")]
786 prepend_prologue_tx_in_consensus_commit_in_checkpoints: bool,
787
788 #[serde(skip_serializing_if = "Option::is_none")]
790 mysticeti_num_leaders_per_round: Option<usize>,
791
792 #[serde(skip_serializing_if = "is_false")]
794 soft_bundle: bool,
795
796 #[serde(skip_serializing_if = "is_false")]
798 enable_coin_deny_list_v2: bool,
799
800 #[serde(skip_serializing_if = "is_false")]
802 passkey_auth: bool,
803
804 #[serde(skip_serializing_if = "is_false")]
806 authority_capabilities_v2: bool,
807
808 #[serde(skip_serializing_if = "is_false")]
810 rethrow_serialization_type_layout_errors: bool,
811
812 #[serde(skip_serializing_if = "is_false")]
814 consensus_distributed_vote_scoring_strategy: bool,
815
816 #[serde(skip_serializing_if = "is_false")]
818 consensus_round_prober: bool,
819
820 #[serde(skip_serializing_if = "is_false")]
822 validate_identifier_inputs: bool,
823
824 #[serde(skip_serializing_if = "is_false")]
826 disallow_self_identifier: bool,
827
828 #[serde(skip_serializing_if = "is_false")]
830 mysticeti_fastpath: bool,
831
832 #[serde(skip_serializing_if = "is_false")]
836 disable_preconsensus_locking: bool,
837
838 #[serde(skip_serializing_if = "is_false")]
840 relocate_event_module: bool,
841
842 #[serde(skip_serializing_if = "is_false")]
844 uncompressed_g1_group_elements: bool,
845
846 #[serde(skip_serializing_if = "is_false")]
847 disallow_new_modules_in_deps_only_packages: bool,
848
849 #[serde(skip_serializing_if = "is_false")]
851 consensus_smart_ancestor_selection: bool,
852
853 #[serde(skip_serializing_if = "is_false")]
855 consensus_round_prober_probe_accepted_rounds: bool,
856
857 #[serde(skip_serializing_if = "is_false")]
859 native_charging_v2: bool,
860
861 #[serde(skip_serializing_if = "is_false")]
864 #[skip_protocol_config_accessor]
865 consensus_linearize_subdag_v2: bool,
866
867 #[serde(skip_serializing_if = "is_false")]
869 convert_type_argument_error: bool,
870
871 #[serde(skip_serializing_if = "is_false")]
873 variant_nodes: bool,
874
875 #[serde(skip_serializing_if = "is_false")]
877 consensus_zstd_compression: bool,
878
879 #[serde(skip_serializing_if = "is_false")]
881 minimize_child_object_mutations: bool,
882
883 #[serde(skip_serializing_if = "is_false")]
886 record_additional_state_digest_in_prologue: bool,
887
888 #[serde(skip_serializing_if = "is_false")]
890 move_native_context: bool,
891
892 #[serde(skip_serializing_if = "is_false")]
895 #[skip_protocol_config_accessor]
896 consensus_median_based_commit_timestamp: bool,
897
898 #[serde(skip_serializing_if = "is_false")]
901 normalize_ptb_arguments: bool,
902
903 #[serde(skip_serializing_if = "is_false")]
905 consensus_batched_block_sync: bool,
906
907 #[serde(skip_serializing_if = "is_false")]
909 enforce_checkpoint_timestamp_monotonicity: bool,
910
911 #[serde(skip_serializing_if = "is_false")]
913 max_ptb_value_size_v2: bool,
914
915 #[serde(skip_serializing_if = "is_false")]
917 resolve_type_input_ids_to_defining_id: bool,
918
919 #[serde(skip_serializing_if = "is_false")]
921 enable_party_transfer: bool,
922
923 #[serde(skip_serializing_if = "is_false")]
925 allow_unbounded_system_objects: bool,
926
927 #[serde(skip_serializing_if = "is_false")]
929 type_tags_in_object_runtime: bool,
930
931 #[serde(skip_serializing_if = "is_false")]
933 enable_accumulators: bool,
934
935 #[serde(skip_serializing_if = "is_false")]
937 #[skip_protocol_config_accessor]
938 enable_coin_reservation_obj_refs: bool,
939
940 #[serde(skip_serializing_if = "is_false")]
943 create_root_accumulator_object: bool,
944
945 #[serde(skip_serializing_if = "is_false")]
947 #[skip_protocol_config_accessor]
948 enable_authenticated_event_streams: bool,
949
950 #[serde(skip_serializing_if = "is_false")]
952 enable_address_balance_gas_payments: bool,
953
954 #[serde(skip_serializing_if = "is_false")]
956 address_balance_gas_check_rgp_at_signing: bool,
957
958 #[serde(skip_serializing_if = "is_false")]
959 address_balance_gas_reject_gas_coin_arg: bool,
960
961 #[serde(skip_serializing_if = "is_false")]
963 enable_multi_epoch_transaction_expiration: bool,
964
965 #[serde(skip_serializing_if = "is_false")]
967 relax_valid_during_for_owned_inputs: bool,
968
969 #[serde(skip_serializing_if = "is_false")]
971 enable_ptb_execution_v2: bool,
972
973 #[serde(skip_serializing_if = "is_false")]
975 better_adapter_type_resolution_errors: bool,
976
977 #[serde(skip_serializing_if = "is_false")]
979 record_time_estimate_processed: bool,
980
981 #[serde(skip_serializing_if = "is_false")]
983 dependency_linkage_error: bool,
984
985 #[serde(skip_serializing_if = "is_false")]
987 additional_multisig_checks: bool,
988
989 #[serde(skip_serializing_if = "is_false")]
991 ignore_execution_time_observations_after_certs_closed: bool,
992
993 #[serde(skip_serializing_if = "is_false")]
997 debug_fatal_on_move_invariant_violation: bool,
998
999 #[serde(skip_serializing_if = "is_false")]
1002 allow_private_accumulator_entrypoints: bool,
1003
1004 #[serde(skip_serializing_if = "is_false")]
1007 additional_consensus_digest_indirect_state: bool,
1008
1009 #[serde(skip_serializing_if = "is_false")]
1011 check_for_init_during_upgrade: bool,
1012
1013 #[serde(skip_serializing_if = "is_false")]
1015 enable_init_on_upgrade: bool,
1016
1017 #[serde(skip_serializing_if = "is_false")]
1019 enable_order_independent_upgrade_init_linkage: bool,
1020
1021 #[serde(skip_serializing_if = "is_false")]
1024 harden_linkage_consistency: bool,
1025
1026 #[serde(skip_serializing_if = "is_false")]
1028 per_command_shared_object_transfer_rules: bool,
1029
1030 #[serde(skip_serializing_if = "is_false")]
1032 validate_ptb_argument_indices: bool,
1033
1034 #[serde(skip_serializing_if = "is_false")]
1036 include_checkpoint_artifacts_digest_in_summary: bool,
1037
1038 #[serde(skip_serializing_if = "is_false")]
1040 use_mfp_txns_in_load_initial_object_debts: bool,
1041
1042 #[serde(skip_serializing_if = "is_false")]
1044 cancel_for_failed_dkg_early: bool,
1045
1046 #[serde(skip_serializing_if = "is_false")]
1048 always_advance_dkg_to_resolution: bool,
1049
1050 #[serde(skip_serializing_if = "is_false")]
1052 enable_coin_registry: bool,
1053
1054 #[serde(skip_serializing_if = "is_false")]
1056 abstract_size_in_object_runtime: bool,
1057
1058 #[serde(skip_serializing_if = "is_false")]
1060 object_runtime_charge_cache_load_gas: bool,
1061
1062 #[serde(skip_serializing_if = "is_false")]
1064 additional_borrow_checks: bool,
1065
1066 #[serde(skip_serializing_if = "is_false")]
1068 use_new_commit_handler: bool,
1069
1070 #[serde(skip_serializing_if = "is_false")]
1072 better_loader_errors: bool,
1073
1074 #[serde(skip_serializing_if = "is_false")]
1076 generate_df_type_layouts: bool,
1077
1078 #[serde(skip_serializing_if = "is_false")]
1080 allow_references_in_ptbs: bool,
1081
1082 #[serde(skip_serializing_if = "is_false")]
1089 framework_tx_context_mut_restrictions: bool,
1090
1091 #[serde(skip_serializing_if = "is_false")]
1093 include_function_signatures_in_instantiation_limits: bool,
1094
1095 #[serde(skip_serializing_if = "is_false")]
1100 ptb_tx_context_restrictions: bool,
1101
1102 #[serde(skip_serializing_if = "is_false")]
1104 enable_display_registry: bool,
1105
1106 #[serde(skip_serializing_if = "is_false")]
1108 private_generics_verifier_v2: bool,
1109
1110 #[serde(skip_serializing_if = "is_false")]
1112 deprecate_global_storage_ops_during_deserialization: bool,
1113
1114 #[serde(skip_serializing_if = "is_false")]
1117 enable_non_exclusive_writes: bool,
1118
1119 #[serde(skip_serializing_if = "is_false")]
1121 deprecate_global_storage_ops: bool,
1122
1123 #[serde(skip_serializing_if = "is_false")]
1125 normalize_depth_formula: bool,
1126
1127 #[serde(skip_serializing_if = "is_false")]
1130 charge_ld_const_abstract_size: bool,
1131
1132 #[serde(skip_serializing_if = "is_false")]
1134 consensus_skip_gced_accept_votes: bool,
1135
1136 #[serde(skip_serializing_if = "is_false")]
1139 include_cancelled_randomness_txns_in_prologue: bool,
1140
1141 #[serde(skip_serializing_if = "is_false")]
1143 #[skip_protocol_config_accessor]
1144 address_aliases: bool,
1145
1146 #[serde(skip_serializing_if = "is_false")]
1148 create_forwarding_address_registry: bool,
1149
1150 #[serde(skip_serializing_if = "is_false")]
1153 fix_checkpoint_signature_mapping: bool,
1154
1155 #[serde(skip_serializing_if = "is_false")]
1157 enable_object_funds_withdraw: bool,
1158
1159 #[serde(skip_serializing_if = "is_false")]
1162 record_net_unsettled_object_withdraws: bool,
1163
1164 #[serde(skip_serializing_if = "is_false")]
1166 consensus_skip_gced_blocks_in_direct_finalization: bool,
1167
1168 #[serde(skip_serializing_if = "is_false")]
1170 gas_rounding_halve_digits: bool,
1171
1172 #[serde(skip_serializing_if = "is_false")]
1174 flexible_tx_context_positions: bool,
1175
1176 #[serde(skip_serializing_if = "is_false")]
1178 disable_entry_point_signature_check: bool,
1179
1180 #[serde(skip_serializing_if = "is_false")]
1182 convert_withdrawal_compatibility_ptb_arguments: bool,
1183
1184 #[serde(skip_serializing_if = "is_false")]
1186 restrict_hot_or_not_entry_functions: bool,
1187
1188 #[serde(skip_serializing_if = "is_false")]
1190 split_checkpoints_in_consensus_handler: bool,
1191
1192 #[serde(skip_serializing_if = "is_false")]
1194 consensus_always_accept_system_transactions: bool,
1195
1196 #[serde(skip_serializing_if = "is_false")]
1198 validator_metadata_verify_v2: bool,
1199
1200 #[serde(skip_serializing_if = "is_false")]
1203 defer_unpaid_amplification: bool,
1204
1205 #[serde(skip_serializing_if = "is_false")]
1208 defer_owned_object_double_spend: bool,
1209
1210 #[serde(skip_serializing_if = "is_false")]
1213 allowed_proposers: bool,
1214
1215 #[serde(skip_serializing_if = "is_false")]
1216 randomize_checkpoint_tx_limit_in_tests: bool,
1217
1218 #[serde(skip_serializing_if = "is_false")]
1220 gasless_transaction_drop_safety: bool,
1221
1222 #[serde(skip_serializing_if = "is_false")]
1225 merge_randomness_into_checkpoint: bool,
1226
1227 #[serde(skip_serializing_if = "is_false")]
1229 use_coin_party_owner: bool,
1230
1231 #[serde(skip_serializing_if = "is_false")]
1232 enable_gasless: bool,
1233
1234 #[serde(skip_serializing_if = "is_false")]
1235 gasless_verify_remaining_balance: bool,
1236
1237 #[serde(skip_serializing_if = "is_false")]
1238 disallow_jump_orphans: bool,
1239
1240 #[serde(skip_serializing_if = "is_false")]
1242 early_return_receive_object_mismatched_type: bool,
1243
1244 #[serde(skip_serializing_if = "is_false")]
1249 timestamp_based_epoch_close: bool,
1250
1251 #[serde(skip_serializing_if = "is_false")]
1254 limit_groth16_pvk_inputs: bool,
1255
1256 #[serde(skip_serializing_if = "is_false")]
1261 enforce_address_balance_change_invariant: bool,
1262
1263 #[serde(skip_serializing_if = "is_false")]
1265 share_transaction_deny_config_in_consensus: bool,
1266
1267 #[serde(skip_serializing_if = "is_false")]
1269 granular_post_execution_checks: bool,
1270
1271 #[serde(skip_serializing_if = "is_false")]
1273 early_exit_on_iffw: bool,
1274
1275 #[serde(skip_serializing_if = "is_false")]
1277 enable_unified_linkage: bool,
1278
1279 #[serde(skip_serializing_if = "is_false")]
1282 #[skip_protocol_config_accessor]
1283 enable_allowances: bool,
1284
1285 #[serde(skip_serializing_if = "is_false")]
1287 fix_ptb_generated_reads: bool,
1288
1289 #[serde(skip_serializing_if = "is_false")]
1290 check_object_funds_withdraw_in_execution: bool,
1291 #[serde(skip_serializing_if = "is_false")]
1293 memory_safety_invariant_check_v2: bool,
1294}
1295
1296fn is_false(b: &bool) -> bool {
1297 !b
1298}
1299
1300fn is_empty(b: &BTreeSet<String>) -> bool {
1301 b.is_empty()
1302}
1303
1304fn is_zero(val: &u64) -> bool {
1305 *val == 0
1306}
1307
1308#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1310pub enum ConsensusTransactionOrdering {
1311 #[default]
1313 None,
1314 ByGasPrice,
1316}
1317
1318impl ConsensusTransactionOrdering {
1319 pub fn is_none(&self) -> bool {
1320 matches!(self, ConsensusTransactionOrdering::None)
1321 }
1322}
1323
1324#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1325pub struct ExecutionTimeEstimateParams {
1326 pub target_utilization: u64,
1328 pub allowed_txn_cost_overage_burst_limit_us: u64,
1332
1333 pub randomness_scalar: u64,
1336
1337 pub max_estimate_us: u64,
1339
1340 pub stored_observations_num_included_checkpoints: u64,
1343
1344 pub stored_observations_limit: u64,
1346
1347 #[serde(skip_serializing_if = "is_zero")]
1350 pub stake_weighted_median_threshold: u64,
1351
1352 #[serde(skip_serializing_if = "is_false")]
1356 pub default_none_duration_for_new_keys: bool,
1357
1358 #[serde(skip_serializing_if = "Option::is_none")]
1360 pub observations_chunk_size: Option<u64>,
1361}
1362
1363#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1365pub enum PerObjectCongestionControlMode {
1366 #[default]
1367 None, TotalGasBudget, TotalTxCount, TotalGasBudgetWithCap, ExecutionTimeEstimate(ExecutionTimeEstimateParams), }
1373
1374impl PerObjectCongestionControlMode {
1375 pub fn is_none(&self) -> bool {
1376 matches!(self, PerObjectCongestionControlMode::None)
1377 }
1378}
1379
1380#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1382pub enum ConsensusChoice {
1383 #[default]
1384 Narwhal,
1385 SwapEachEpoch,
1386 Mysticeti,
1387}
1388
1389impl ConsensusChoice {
1390 pub fn is_narwhal(&self) -> bool {
1391 matches!(self, ConsensusChoice::Narwhal)
1392 }
1393}
1394
1395#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1397pub enum ConsensusNetwork {
1398 #[default]
1399 Anemo,
1400 Tonic,
1401}
1402
1403impl ConsensusNetwork {
1404 pub fn is_anemo(&self) -> bool {
1405 matches!(self, ConsensusNetwork::Anemo)
1406 }
1407}
1408
1409#[skip_serializing_none]
1441#[derive(Clone, Serialize, Debug, ProtocolConfigAccessors, ProtocolConfigOverride)]
1442pub struct ProtocolConfig {
1443 pub version: ProtocolVersion,
1444
1445 #[serde(skip)]
1450 chain: Chain,
1451
1452 feature_flags: FeatureFlags,
1453
1454 max_tx_size_bytes: Option<u64>,
1457
1458 max_input_objects: Option<u64>,
1460
1461 max_size_written_objects: Option<u64>,
1465 max_size_written_objects_system_tx: Option<u64>,
1468
1469 max_serialized_tx_effects_size_bytes: Option<u64>,
1471
1472 max_serialized_tx_effects_size_bytes_system_tx: Option<u64>,
1474
1475 max_gas_payment_objects: Option<u32>,
1477
1478 max_modules_in_publish: Option<u32>,
1480
1481 max_package_dependencies: Option<u32>,
1483
1484 max_arguments: Option<u32>,
1487
1488 max_type_arguments: Option<u32>,
1490
1491 max_type_argument_depth: Option<u32>,
1493
1494 max_pure_argument_size: Option<u32>,
1496
1497 max_programmable_tx_commands: Option<u32>,
1499
1500 move_binary_format_version: Option<u32>,
1503 min_move_binary_format_version: Option<u32>,
1504
1505 binary_module_handles: Option<u16>,
1507 binary_struct_handles: Option<u16>,
1508 binary_function_handles: Option<u16>,
1509 binary_function_instantiations: Option<u16>,
1510 binary_signatures: Option<u16>,
1511 binary_constant_pool: Option<u16>,
1512 binary_identifiers: Option<u16>,
1513 binary_address_identifiers: Option<u16>,
1514 binary_struct_defs: Option<u16>,
1515 binary_struct_def_instantiations: Option<u16>,
1516 binary_function_defs: Option<u16>,
1517 binary_field_handles: Option<u16>,
1518 binary_field_instantiations: Option<u16>,
1519 binary_friend_decls: Option<u16>,
1520 binary_enum_defs: Option<u16>,
1521 binary_enum_def_instantiations: Option<u16>,
1522 binary_variant_handles: Option<u16>,
1523 binary_variant_instantiation_handles: Option<u16>,
1524
1525 max_move_object_size: Option<u64>,
1527
1528 max_move_package_size: Option<u64>,
1531
1532 max_publish_or_upgrade_per_ptb: Option<u64>,
1534
1535 max_tx_gas: Option<u64>,
1537
1538 max_gas_price: Option<u64>,
1540
1541 max_gas_price_rgp_factor_for_aborted_transactions: Option<u64>,
1544
1545 max_gas_computation_bucket: Option<u64>,
1547
1548 gas_rounding_step: Option<u64>,
1550
1551 max_loop_depth: Option<u64>,
1553
1554 max_generic_instantiation_length: Option<u64>,
1556
1557 max_function_parameters: Option<u64>,
1559
1560 max_basic_blocks: Option<u64>,
1562
1563 max_value_stack_size: Option<u64>,
1565
1566 max_type_nodes: Option<u64>,
1568
1569 max_generic_instantiation_type_nodes_per_function: Option<u64>,
1571
1572 max_generic_instantiation_type_nodes_per_module: Option<u64>,
1574
1575 max_accumulator_type_nodes: Option<u64>,
1577
1578 max_push_size: Option<u64>,
1580
1581 max_struct_definitions: Option<u64>,
1583
1584 max_function_definitions: Option<u64>,
1586
1587 max_fields_in_struct: Option<u64>,
1589
1590 max_dependency_depth: Option<u64>,
1592
1593 max_num_event_emit: Option<u64>,
1595
1596 max_num_new_move_object_ids: Option<u64>,
1598
1599 max_num_new_move_object_ids_system_tx: Option<u64>,
1601
1602 max_num_deleted_move_object_ids: Option<u64>,
1604
1605 max_num_deleted_move_object_ids_system_tx: Option<u64>,
1607
1608 max_num_transferred_move_object_ids: Option<u64>,
1610
1611 max_num_transferred_move_object_ids_system_tx: Option<u64>,
1613
1614 max_event_emit_size: Option<u64>,
1616
1617 max_event_emit_size_total: Option<u64>,
1619
1620 max_move_vector_len: Option<u64>,
1622
1623 max_move_identifier_len: Option<u64>,
1625
1626 max_move_value_depth: Option<u64>,
1628
1629 package_arena_size_in_bytes: Option<u64>,
1632
1633 max_move_enum_variants: Option<u64>,
1635
1636 max_back_edges_per_function: Option<u64>,
1638
1639 max_back_edges_per_module: Option<u64>,
1641
1642 max_verifier_meter_ticks_per_function: Option<u64>,
1644
1645 max_meter_ticks_per_module: Option<u64>,
1647
1648 max_meter_ticks_per_package: Option<u64>,
1650
1651 object_runtime_max_num_cached_objects: Option<u64>,
1655
1656 object_runtime_max_num_cached_objects_system_tx: Option<u64>,
1658
1659 object_runtime_max_num_store_entries: Option<u64>,
1661
1662 object_runtime_max_num_store_entries_system_tx: Option<u64>,
1664
1665 base_tx_cost_fixed: Option<u64>,
1668
1669 package_publish_cost_fixed: Option<u64>,
1672
1673 base_tx_cost_per_byte: Option<u64>,
1676
1677 package_publish_cost_per_byte: Option<u64>,
1679
1680 obj_access_cost_read_per_byte: Option<u64>,
1682
1683 obj_access_cost_mutate_per_byte: Option<u64>,
1685
1686 obj_access_cost_delete_per_byte: Option<u64>,
1688
1689 obj_access_cost_verify_per_byte: Option<u64>,
1699
1700 max_type_to_layout_nodes: Option<u64>,
1702
1703 max_ptb_value_size: Option<u64>,
1705
1706 gas_model_version: Option<u64>,
1709
1710 obj_data_cost_refundable: Option<u64>,
1713
1714 obj_metadata_cost_non_refundable: Option<u64>,
1718
1719 storage_rebate_rate: Option<u64>,
1725
1726 storage_fund_reinvest_rate: Option<u64>,
1729
1730 reward_slashing_rate: Option<u64>,
1733
1734 storage_gas_price: Option<u64>,
1736
1737 accumulator_object_storage_cost: Option<u64>,
1739
1740 max_transactions_per_checkpoint: Option<u64>,
1745
1746 max_checkpoint_size_bytes: Option<u64>,
1750
1751 buffer_stake_for_protocol_upgrade_bps: Option<u64>,
1756
1757 address_from_bytes_cost_base: Option<u64>,
1762 address_to_u256_cost_base: Option<u64>,
1764 address_from_u256_cost_base: Option<u64>,
1766
1767 config_read_setting_impl_cost_base: Option<u64>,
1772 config_read_setting_impl_cost_per_byte: Option<u64>,
1773
1774 package_original_package_id_impl_cost_base: Option<u64>,
1775 package_original_package_id_impl_cost_per_byte: Option<u64>,
1776
1777 dynamic_field_hash_type_and_key_cost_base: Option<u64>,
1780 dynamic_field_hash_type_and_key_type_cost_per_byte: Option<u64>,
1781 dynamic_field_hash_type_and_key_value_cost_per_byte: Option<u64>,
1782 dynamic_field_hash_type_and_key_type_tag_cost_per_byte: Option<u64>,
1783 dynamic_field_add_child_object_cost_base: Option<u64>,
1785 dynamic_field_add_child_object_type_cost_per_byte: Option<u64>,
1786 dynamic_field_add_child_object_value_cost_per_byte: Option<u64>,
1787 dynamic_field_add_child_object_struct_tag_cost_per_byte: Option<u64>,
1788 dynamic_field_borrow_child_object_cost_base: Option<u64>,
1790 dynamic_field_borrow_child_object_child_ref_cost_per_byte: Option<u64>,
1791 dynamic_field_borrow_child_object_type_cost_per_byte: Option<u64>,
1792 dynamic_field_remove_child_object_cost_base: Option<u64>,
1794 dynamic_field_remove_child_object_child_cost_per_byte: Option<u64>,
1795 dynamic_field_remove_child_object_type_cost_per_byte: Option<u64>,
1796 dynamic_field_has_child_object_cost_base: Option<u64>,
1798 dynamic_field_has_child_object_with_ty_cost_base: Option<u64>,
1800 dynamic_field_has_child_object_with_ty_type_cost_per_byte: Option<u64>,
1801 dynamic_field_has_child_object_with_ty_type_tag_cost_per_byte: Option<u64>,
1802
1803 scratch_add_cost_base: Option<u64>,
1806 scratch_read_cost_base: Option<u64>,
1808 scratch_read_value_cost: Option<u64>,
1809 scratch_remove_cost_base: Option<u64>,
1811 scratch_exists_cost_base: Option<u64>,
1813 scratch_exists_with_type_cost_base: Option<u64>,
1815 scratch_exists_with_type_type_cost: Option<u64>,
1816 max_scratch_pad_size: Option<u64>,
1818
1819 event_emit_cost_base: Option<u64>,
1822 event_emit_value_size_derivation_cost_per_byte: Option<u64>,
1823 event_emit_tag_size_derivation_cost_per_byte: Option<u64>,
1824 event_emit_output_cost_per_byte: Option<u64>,
1825 event_emit_auth_stream_cost: Option<u64>,
1826
1827 reserve_object_funds_for_withdrawal_cost_base: Option<u64>,
1830 reserve_object_funds_for_withdrawal_cold_read_cost: Option<u64>,
1832
1833 object_borrow_uid_cost_base: Option<u64>,
1836 object_delete_impl_cost_base: Option<u64>,
1838 object_record_new_uid_cost_base: Option<u64>,
1840 object_record_new_uid_from_hash_cost_base: Option<u64>,
1843
1844 transfer_transfer_internal_cost_base: Option<u64>,
1847 transfer_party_transfer_internal_cost_base: Option<u64>,
1849 transfer_freeze_object_cost_base: Option<u64>,
1851 transfer_share_object_cost_base: Option<u64>,
1853 transfer_receive_object_cost_base: Option<u64>,
1856 transfer_receive_object_cost_per_byte: Option<u64>,
1857 transfer_receive_object_type_cost_per_byte: Option<u64>,
1858
1859 tx_context_derive_id_cost_base: Option<u64>,
1862 tx_context_fresh_id_cost_base: Option<u64>,
1863 tx_context_sender_cost_base: Option<u64>,
1864 tx_context_epoch_cost_base: Option<u64>,
1865 tx_context_epoch_timestamp_ms_cost_base: Option<u64>,
1866 tx_context_sponsor_cost_base: Option<u64>,
1867 tx_context_rgp_cost_base: Option<u64>,
1868 tx_context_gas_price_cost_base: Option<u64>,
1869 tx_context_gas_budget_cost_base: Option<u64>,
1870 tx_context_ids_created_cost_base: Option<u64>,
1871 tx_context_replace_cost_base: Option<u64>,
1872
1873 types_is_one_time_witness_cost_base: Option<u64>,
1876 types_is_one_time_witness_type_tag_cost_per_byte: Option<u64>,
1877 types_is_one_time_witness_type_cost_per_byte: Option<u64>,
1878
1879 validator_validate_metadata_cost_base: Option<u64>,
1882 validator_validate_metadata_data_cost_per_byte: Option<u64>,
1883
1884 crypto_invalid_arguments_cost: Option<u64>,
1886 bls12381_bls12381_min_sig_verify_cost_base: Option<u64>,
1888 bls12381_bls12381_min_sig_verify_msg_cost_per_byte: Option<u64>,
1889 bls12381_bls12381_min_sig_verify_msg_cost_per_block: Option<u64>,
1890
1891 bls12381_bls12381_min_pk_verify_cost_base: Option<u64>,
1893 bls12381_bls12381_min_pk_verify_msg_cost_per_byte: Option<u64>,
1894 bls12381_bls12381_min_pk_verify_msg_cost_per_block: Option<u64>,
1895
1896 ecdsa_k1_ecrecover_keccak256_cost_base: Option<u64>,
1898 ecdsa_k1_ecrecover_keccak256_msg_cost_per_byte: Option<u64>,
1899 ecdsa_k1_ecrecover_keccak256_msg_cost_per_block: Option<u64>,
1900 ecdsa_k1_ecrecover_sha256_cost_base: Option<u64>,
1901 ecdsa_k1_ecrecover_sha256_msg_cost_per_byte: Option<u64>,
1902 ecdsa_k1_ecrecover_sha256_msg_cost_per_block: Option<u64>,
1903
1904 ecdsa_k1_decompress_pubkey_cost_base: Option<u64>,
1906
1907 ecdsa_k1_secp256k1_verify_keccak256_cost_base: Option<u64>,
1909 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_byte: Option<u64>,
1910 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_block: Option<u64>,
1911 ecdsa_k1_secp256k1_verify_sha256_cost_base: Option<u64>,
1912 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_byte: Option<u64>,
1913 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_block: Option<u64>,
1914
1915 ecdsa_r1_ecrecover_keccak256_cost_base: Option<u64>,
1917 ecdsa_r1_ecrecover_keccak256_msg_cost_per_byte: Option<u64>,
1918 ecdsa_r1_ecrecover_keccak256_msg_cost_per_block: Option<u64>,
1919 ecdsa_r1_ecrecover_sha256_cost_base: Option<u64>,
1920 ecdsa_r1_ecrecover_sha256_msg_cost_per_byte: Option<u64>,
1921 ecdsa_r1_ecrecover_sha256_msg_cost_per_block: Option<u64>,
1922
1923 ecdsa_r1_secp256r1_verify_keccak256_cost_base: Option<u64>,
1925 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_byte: Option<u64>,
1926 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_block: Option<u64>,
1927 ecdsa_r1_secp256r1_verify_sha256_cost_base: Option<u64>,
1928 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_byte: Option<u64>,
1929 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_block: Option<u64>,
1930
1931 ecvrf_ecvrf_verify_cost_base: Option<u64>,
1933 ecvrf_ecvrf_verify_alpha_string_cost_per_byte: Option<u64>,
1934 ecvrf_ecvrf_verify_alpha_string_cost_per_block: Option<u64>,
1935
1936 ed25519_ed25519_verify_cost_base: Option<u64>,
1938 ed25519_ed25519_verify_msg_cost_per_byte: Option<u64>,
1939 ed25519_ed25519_verify_msg_cost_per_block: Option<u64>,
1940
1941 groth16_prepare_verifying_key_bls12381_cost_base: Option<u64>,
1943 groth16_prepare_verifying_key_bn254_cost_base: Option<u64>,
1944
1945 groth16_verify_groth16_proof_internal_bls12381_cost_base: Option<u64>,
1947 groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input: Option<u64>,
1948 groth16_verify_groth16_proof_internal_bn254_cost_base: Option<u64>,
1949 groth16_verify_groth16_proof_internal_bn254_cost_per_public_input: Option<u64>,
1950 groth16_verify_groth16_proof_internal_public_input_cost_per_byte: Option<u64>,
1951
1952 hash_blake2b256_cost_base: Option<u64>,
1954 hash_blake2b256_data_cost_per_byte: Option<u64>,
1955 hash_blake2b256_data_cost_per_block: Option<u64>,
1956
1957 hash_keccak256_cost_base: Option<u64>,
1959 hash_keccak256_data_cost_per_byte: Option<u64>,
1960 hash_keccak256_data_cost_per_block: Option<u64>,
1961
1962 poseidon_bn254_cost_base: Option<u64>,
1964 poseidon_bn254_cost_per_block: Option<u64>,
1965
1966 group_ops_bls12381_decode_scalar_cost: Option<u64>,
1968 group_ops_bls12381_decode_g1_cost: Option<u64>,
1969 group_ops_bls12381_decode_g2_cost: Option<u64>,
1970 group_ops_bls12381_decode_gt_cost: Option<u64>,
1971 group_ops_bls12381_scalar_add_cost: Option<u64>,
1972 group_ops_bls12381_g1_add_cost: Option<u64>,
1973 group_ops_bls12381_g2_add_cost: Option<u64>,
1974 group_ops_bls12381_gt_add_cost: Option<u64>,
1975 group_ops_bls12381_scalar_sub_cost: Option<u64>,
1976 group_ops_bls12381_g1_sub_cost: Option<u64>,
1977 group_ops_bls12381_g2_sub_cost: Option<u64>,
1978 group_ops_bls12381_gt_sub_cost: Option<u64>,
1979 group_ops_bls12381_scalar_mul_cost: Option<u64>,
1980 group_ops_bls12381_g1_mul_cost: Option<u64>,
1981 group_ops_bls12381_g2_mul_cost: Option<u64>,
1982 group_ops_bls12381_gt_mul_cost: Option<u64>,
1983 group_ops_bls12381_scalar_div_cost: Option<u64>,
1984 group_ops_bls12381_g1_div_cost: Option<u64>,
1985 group_ops_bls12381_g2_div_cost: Option<u64>,
1986 group_ops_bls12381_gt_div_cost: Option<u64>,
1987 group_ops_bls12381_g1_hash_to_base_cost: Option<u64>,
1988 group_ops_bls12381_g2_hash_to_base_cost: Option<u64>,
1989 group_ops_bls12381_g1_hash_to_cost_per_byte: Option<u64>,
1990 group_ops_bls12381_g2_hash_to_cost_per_byte: Option<u64>,
1991 group_ops_bls12381_g1_msm_base_cost: Option<u64>,
1992 group_ops_bls12381_g2_msm_base_cost: Option<u64>,
1993 group_ops_bls12381_g1_msm_base_cost_per_input: Option<u64>,
1994 group_ops_bls12381_g2_msm_base_cost_per_input: Option<u64>,
1995 group_ops_bls12381_msm_max_len: Option<u32>,
1996 group_ops_bls12381_pairing_cost: Option<u64>,
1997 group_ops_bls12381_g1_to_uncompressed_g1_cost: Option<u64>,
1998 group_ops_bls12381_uncompressed_g1_to_g1_cost: Option<u64>,
1999 group_ops_bls12381_uncompressed_g1_sum_base_cost: Option<u64>,
2000 group_ops_bls12381_uncompressed_g1_sum_cost_per_term: Option<u64>,
2001 group_ops_bls12381_uncompressed_g1_sum_max_terms: Option<u64>,
2002
2003 group_ops_ristretto_decode_scalar_cost: Option<u64>,
2004 group_ops_ristretto_decode_point_cost: Option<u64>,
2005 group_ops_ristretto_scalar_add_cost: Option<u64>,
2006 group_ops_ristretto_point_add_cost: Option<u64>,
2007 group_ops_ristretto_scalar_sub_cost: Option<u64>,
2008 group_ops_ristretto_point_sub_cost: Option<u64>,
2009 group_ops_ristretto_scalar_mul_cost: Option<u64>,
2010 group_ops_ristretto_point_mul_cost: Option<u64>,
2011 group_ops_ristretto_scalar_div_cost: Option<u64>,
2012 group_ops_ristretto_point_div_cost: Option<u64>,
2013
2014 verify_bulletproofs_ristretto255_base_cost: Option<u64>,
2015 verify_bulletproofs_ristretto255_cost_per_bit_and_commitment: Option<u64>,
2016 max_bulletproofs_total_bits: Option<u64>,
2019
2020 hmac_hmac_sha3_256_cost_base: Option<u64>,
2022 hmac_hmac_sha3_256_input_cost_per_byte: Option<u64>,
2023 hmac_hmac_sha3_256_input_cost_per_block: Option<u64>,
2024
2025 check_zklogin_id_cost_base: Option<u64>,
2027 check_zklogin_issuer_cost_base: Option<u64>,
2029
2030 vdf_verify_vdf_cost: Option<u64>,
2031 vdf_hash_to_input_cost: Option<u64>,
2032
2033 nitro_attestation_parse_base_cost: Option<u64>,
2035 nitro_attestation_parse_cost_per_byte: Option<u64>,
2036 nitro_attestation_verify_base_cost: Option<u64>,
2037 nitro_attestation_verify_cost_per_cert: Option<u64>,
2038
2039 bcs_per_byte_serialized_cost: Option<u64>,
2041 bcs_legacy_min_output_size_cost: Option<u64>,
2042 bcs_failure_cost: Option<u64>,
2043
2044 hash_sha2_256_base_cost: Option<u64>,
2045 hash_sha2_256_per_byte_cost: Option<u64>,
2046 hash_sha2_256_legacy_min_input_len_cost: Option<u64>,
2047 hash_sha3_256_base_cost: Option<u64>,
2048 hash_sha3_256_per_byte_cost: Option<u64>,
2049 hash_sha3_256_legacy_min_input_len_cost: Option<u64>,
2050 type_name_get_base_cost: Option<u64>,
2051 type_name_get_per_byte_cost: Option<u64>,
2052 type_name_id_base_cost: Option<u64>,
2053
2054 string_check_utf8_base_cost: Option<u64>,
2055 string_check_utf8_per_byte_cost: Option<u64>,
2056 string_is_char_boundary_base_cost: Option<u64>,
2057 string_sub_string_base_cost: Option<u64>,
2058 string_sub_string_per_byte_cost: Option<u64>,
2059 string_index_of_base_cost: Option<u64>,
2060 string_index_of_per_byte_pattern_cost: Option<u64>,
2061 string_index_of_per_byte_searched_cost: Option<u64>,
2062
2063 vector_empty_base_cost: Option<u64>,
2064 vector_length_base_cost: Option<u64>,
2065 vector_push_back_base_cost: Option<u64>,
2066 vector_push_back_legacy_per_abstract_memory_unit_cost: Option<u64>,
2067 vector_borrow_base_cost: Option<u64>,
2068 vector_pop_back_base_cost: Option<u64>,
2069 vector_destroy_empty_base_cost: Option<u64>,
2070 vector_swap_base_cost: Option<u64>,
2071 debug_print_base_cost: Option<u64>,
2072 debug_print_stack_trace_base_cost: Option<u64>,
2073
2074 #[custom_setter]
2084 execution_version: Option<u64>,
2085
2086 consensus_bad_nodes_stake_threshold: Option<u64>,
2090
2091 max_jwk_votes_per_validator_per_epoch: Option<u64>,
2092 max_age_of_jwk_in_epochs: Option<u64>,
2096
2097 random_beacon_reduction_allowed_delta: Option<u16>,
2101
2102 random_beacon_reduction_lower_bound: Option<u32>,
2105
2106 random_beacon_dkg_timeout_round: Option<u32>,
2109
2110 random_beacon_min_round_interval_ms: Option<u64>,
2112
2113 random_beacon_dkg_version: Option<u64>,
2116
2117 consensus_max_transaction_size_bytes: Option<u64>,
2120 consensus_max_transactions_in_block_bytes: Option<u64>,
2122 consensus_max_num_transactions_in_block: Option<u64>,
2124
2125 consensus_voting_rounds: Option<u32>,
2127
2128 max_accumulated_txn_cost_per_object_in_narwhal_commit: Option<u64>,
2130
2131 max_deferral_rounds_for_congestion_control: Option<u64>,
2134
2135 epoch_close_deadline_ms: Option<u64>,
2140
2141 max_txn_cost_overage_per_object_in_commit: Option<u64>,
2143
2144 allowed_txn_cost_overage_burst_per_object_in_commit: Option<u64>,
2146
2147 min_checkpoint_interval_ms: Option<u64>,
2149
2150 checkpoint_summary_version_specific_data: Option<u64>,
2152
2153 max_soft_bundle_size: Option<u64>,
2155
2156 bridge_should_try_to_finalize_committee: Option<bool>,
2160
2161 max_accumulated_txn_cost_per_object_in_mysticeti_commit: Option<u64>,
2167
2168 max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit: Option<u64>,
2171
2172 consensus_gc_depth: Option<u32>,
2175
2176 gas_budget_based_txn_cost_cap_factor: Option<u64>,
2178
2179 gas_budget_based_txn_cost_absolute_cap_commit_count: Option<u64>,
2181
2182 sip_45_consensus_amplification_threshold: Option<u64>,
2185
2186 use_object_per_epoch_marker_table_v2: Option<bool>,
2189
2190 consensus_commit_rate_estimation_window_size: Option<u32>,
2192
2193 #[serde(skip_serializing_if = "Vec::is_empty")]
2197 aliased_addresses: Vec<AliasedAddress>,
2198
2199 translation_per_command_base_charge: Option<u64>,
2202
2203 translation_per_input_base_charge: Option<u64>,
2206
2207 translation_pure_input_per_byte_charge: Option<u64>,
2209
2210 translation_per_type_node_charge: Option<u64>,
2214
2215 translation_per_reference_node_charge: Option<u64>,
2218
2219 translation_per_linkage_entry_charge: Option<u64>,
2222
2223 max_updates_per_settlement_txn: Option<u32>,
2225
2226 gasless_max_computation_units: Option<u64>,
2228
2229 gasless_allowed_token_types: Option<Vec<(String, u64)>>,
2231
2232 gasless_max_unused_inputs: Option<u64>,
2236
2237 gasless_max_pure_input_bytes: Option<u64>,
2240
2241 gasless_max_tps: Option<u64>,
2243
2244 #[serde(skip_serializing_if = "Option::is_none")]
2245 #[skip_accessor]
2246 include_special_package_amendments: Option<Arc<Amendments>>,
2247
2248 gasless_max_tx_size_bytes: Option<u64>,
2251
2252 translation_per_live_reference_charge: Option<u64>,
2255
2256 max_ptb_live_references: Option<u64>,
2259
2260 max_ptb_returned_references: Option<u64>,
2263
2264 max_ptb_total_returned_references: Option<u64>,
2267}
2268
2269#[derive(Clone, Serialize, Deserialize, Debug)]
2271pub struct AliasedAddress {
2272 pub original: [u8; 32],
2274 pub aliased: [u8; 32],
2276 pub allowed_tx_digests: Vec<[u8; 32]>,
2278}
2279
2280impl ProtocolConfig {
2282 pub fn chain(&self) -> Chain {
2284 self.chain
2285 }
2286
2287 pub fn check_package_upgrades_supported(&self) -> Result<(), Error> {
2300 if self.feature_flags.package_upgrades {
2301 Ok(())
2302 } else {
2303 Err(Error(format!(
2304 "package upgrades are not supported at {:?}",
2305 self.version
2306 )))
2307 }
2308 }
2309
2310 pub fn zklogin_supported_providers(&self) -> &BTreeSet<String> {
2311 &self.feature_flags.zklogin_supported_providers
2312 }
2313
2314 pub fn zklogin_circuit_mode(&self) -> u64 {
2317 self.feature_flags.zklogin_circuit_mode
2318 }
2319
2320 pub fn consensus_transaction_ordering(&self) -> ConsensusTransactionOrdering {
2321 self.feature_flags.consensus_transaction_ordering
2322 }
2323
2324 pub fn enable_jwk_consensus_updates(&self) -> bool {
2325 let ret = self.feature_flags.enable_jwk_consensus_updates;
2326 if ret {
2327 assert!(self.feature_flags.end_of_epoch_transaction_supported);
2329 }
2330 ret
2331 }
2332
2333 pub fn end_of_epoch_transaction_supported(&self) -> bool {
2334 let ret = self.feature_flags.end_of_epoch_transaction_supported;
2335 if !ret {
2336 assert!(!self.feature_flags.enable_jwk_consensus_updates);
2338 }
2339 ret
2340 }
2341
2342 pub fn dkg_version(&self) -> u64 {
2343 self.random_beacon_dkg_version.unwrap_or(1)
2345 }
2346
2347 pub fn bridge(&self) -> bool {
2348 let ret = self.feature_flags.bridge;
2349 if ret {
2350 assert!(self.feature_flags.end_of_epoch_transaction_supported);
2352 }
2353 ret
2354 }
2355
2356 pub fn should_try_to_finalize_bridge_committee(&self) -> bool {
2357 if !self.bridge() {
2358 return false;
2359 }
2360 self.bridge_should_try_to_finalize_committee.unwrap_or(true)
2362 }
2363
2364 pub fn zklogin_max_epoch_upper_bound_delta(&self) -> Option<u64> {
2365 self.feature_flags.zklogin_max_epoch_upper_bound_delta
2366 }
2367
2368 pub fn enable_allowances(&self) -> bool {
2369 self.feature_flags.enable_allowances && self.enable_accumulators()
2370 }
2371
2372 pub fn enable_coin_reservation_obj_refs(&self) -> bool {
2373 self.new_vm_enabled() && self.feature_flags.enable_coin_reservation_obj_refs
2374 }
2375
2376 pub fn enable_authenticated_event_streams(&self) -> bool {
2377 self.feature_flags.enable_authenticated_event_streams && self.enable_accumulators()
2378 }
2379
2380 pub fn per_object_congestion_control_mode(&self) -> PerObjectCongestionControlMode {
2381 self.feature_flags.per_object_congestion_control_mode
2382 }
2383
2384 pub fn consensus_choice(&self) -> ConsensusChoice {
2385 self.feature_flags.consensus_choice
2386 }
2387
2388 pub fn consensus_network(&self) -> ConsensusNetwork {
2389 self.feature_flags.consensus_network
2390 }
2391
2392 pub fn mysticeti_num_leaders_per_round(&self) -> Option<usize> {
2393 self.feature_flags.mysticeti_num_leaders_per_round
2394 }
2395
2396 pub fn max_transaction_size_bytes(&self) -> u64 {
2397 self.consensus_max_transaction_size_bytes
2399 .unwrap_or(256 * 1024)
2400 }
2401
2402 pub fn max_transactions_in_block_bytes(&self) -> u64 {
2403 if cfg!(msim) {
2404 256 * 1024
2405 } else {
2406 self.consensus_max_transactions_in_block_bytes
2407 .unwrap_or(512 * 1024)
2408 }
2409 }
2410
2411 pub fn max_num_transactions_in_block(&self) -> u64 {
2412 if cfg!(msim) {
2413 8
2414 } else {
2415 self.consensus_max_num_transactions_in_block.unwrap_or(512)
2416 }
2417 }
2418
2419 pub fn gc_depth(&self) -> u32 {
2420 self.consensus_gc_depth.unwrap_or(0)
2421 }
2422
2423 pub fn consensus_linearize_subdag_v2(&self) -> bool {
2424 let res = self.feature_flags.consensus_linearize_subdag_v2;
2425 assert!(
2426 !res || self.gc_depth() > 0,
2427 "The consensus linearize sub dag V2 requires GC to be enabled"
2428 );
2429 res
2430 }
2431
2432 pub fn consensus_median_based_commit_timestamp(&self) -> bool {
2433 let res = self.feature_flags.consensus_median_based_commit_timestamp;
2434 assert!(
2435 !res || self.gc_depth() > 0,
2436 "The consensus median based commit timestamp requires GC to be enabled"
2437 );
2438 res
2439 }
2440
2441 pub fn get_consensus_commit_rate_estimation_window_size(&self) -> u32 {
2442 self.consensus_commit_rate_estimation_window_size
2443 .unwrap_or(0)
2444 }
2445
2446 pub fn consensus_num_requested_prior_commits_at_startup(&self) -> u32 {
2447 let window_size = self.get_consensus_commit_rate_estimation_window_size();
2451 assert!(window_size == 0 || self.record_additional_state_digest_in_prologue());
2453 window_size
2454 }
2455
2456 pub fn address_aliases(&self) -> bool {
2457 let address_aliases = self.feature_flags.address_aliases;
2458 assert!(
2459 !address_aliases || self.mysticeti_fastpath(),
2460 "Address aliases requires Mysticeti fastpath to be enabled"
2461 );
2462 if address_aliases {
2463 assert!(
2464 self.feature_flags.disable_preconsensus_locking,
2465 "Address aliases requires CertifiedTransaction to be disabled"
2466 );
2467 }
2468 address_aliases
2469 }
2470
2471 pub fn new_vm_enabled(&self) -> bool {
2472 self.execution_version.is_some_and(|v| v >= 4)
2473 }
2474
2475 pub fn gasless_allowed_token_types(&self) -> &[(String, u64)] {
2476 debug_assert!(self.gasless_allowed_token_types.is_some());
2477 self.gasless_allowed_token_types.as_deref().unwrap_or(&[])
2478 }
2479
2480 pub fn get_gasless_max_unused_inputs(&self) -> u64 {
2481 self.gasless_max_unused_inputs.unwrap_or(u64::MAX)
2482 }
2483
2484 pub fn get_gasless_max_pure_input_bytes(&self) -> u64 {
2485 self.gasless_max_pure_input_bytes.unwrap_or(u64::MAX)
2486 }
2487
2488 pub fn get_gasless_max_tx_size_bytes(&self) -> u64 {
2489 self.gasless_max_tx_size_bytes.unwrap_or(u64::MAX)
2490 }
2491
2492 pub fn include_special_package_amendments_as_option(&self) -> &Option<Arc<Amendments>> {
2493 &self.include_special_package_amendments
2494 }
2495}
2496
2497static POISON_VERSION_METHODS: AtomicBool = AtomicBool::new(false);
2498
2499impl ProtocolConfig {
2501 pub fn get_for_version(version: ProtocolVersion, chain: Chain) -> Self {
2503 assert!(
2505 version >= ProtocolVersion::MIN,
2506 "Network protocol version is {:?}, but the minimum supported version by the binary is {:?}. Please upgrade the binary.",
2507 version,
2508 ProtocolVersion::MIN.0,
2509 );
2510 assert!(
2511 version <= ProtocolVersion::MAX_ALLOWED,
2512 "Network protocol version is {:?}, but the maximum supported version by the binary is {:?}. Please upgrade the binary.",
2513 version,
2514 ProtocolVersion::MAX_ALLOWED.0,
2515 );
2516
2517 let mut ret = Self::get_for_version_impl(version, chain);
2518 ret.version = version;
2519 ret.chain = chain;
2520
2521 ret = Self::apply_config_override(version, ret);
2522
2523 if std::env::var("SUI_PROTOCOL_CONFIG_OVERRIDE_ENABLE").is_ok() {
2524 warn!(
2525 "overriding ProtocolConfig settings with custom settings; this may break non-local networks"
2526 );
2527 let overrides: ProtocolConfigOptional =
2528 serde_env::from_env_with_prefix("SUI_PROTOCOL_CONFIG_OVERRIDE")
2529 .expect("failed to parse ProtocolConfig override env variables");
2530 overrides.apply_to(&mut ret);
2531 }
2532
2533 ret
2534 }
2535
2536 pub fn get_for_version_if_supported(version: ProtocolVersion, chain: Chain) -> Option<Self> {
2539 if version.0 >= ProtocolVersion::MIN.0 && version.0 <= ProtocolVersion::MAX_ALLOWED.0 {
2540 let mut ret = Self::get_for_version_impl(version, chain);
2541 ret.version = version;
2542 ret.chain = chain;
2543 ret = Self::apply_config_override(version, ret);
2544 Some(ret)
2545 } else {
2546 None
2547 }
2548 }
2549
2550 pub fn poison_get_for_min_version() {
2551 POISON_VERSION_METHODS.store(true, Ordering::Relaxed);
2552 }
2553
2554 fn load_poison_get_for_min_version() -> bool {
2555 POISON_VERSION_METHODS.load(Ordering::Relaxed)
2556 }
2557
2558 pub fn get_for_min_version() -> Self {
2561 if Self::load_poison_get_for_min_version() {
2562 panic!("get_for_min_version called on validator");
2563 }
2564 ProtocolConfig::get_for_version(ProtocolVersion::MIN, Chain::Unknown)
2565 }
2566
2567 #[allow(non_snake_case)]
2577 pub fn get_for_max_version_UNSAFE() -> Self {
2578 if Self::load_poison_get_for_min_version() {
2579 panic!("get_for_max_version_UNSAFE called on validator");
2580 }
2581 ProtocolConfig::get_for_version(ProtocolVersion::MAX, Chain::Unknown)
2582 }
2583
2584 fn get_for_version_impl(version: ProtocolVersion, chain: Chain) -> Self {
2585 #[cfg(msim)]
2586 {
2587 if version == ProtocolVersion::MAX_ALLOWED {
2589 let mut config = Self::get_for_version_impl(version - 1, Chain::Unknown);
2590 config.base_tx_cost_fixed = Some(config.base_tx_cost_fixed() + 1000);
2591 return config;
2592 }
2593 }
2594
2595 let mut cfg = Self {
2598 version,
2600 chain,
2601
2602 feature_flags: Default::default(),
2604
2605 max_tx_size_bytes: Some(128 * 1024),
2606 max_input_objects: Some(2048),
2608 max_serialized_tx_effects_size_bytes: Some(512 * 1024),
2609 max_serialized_tx_effects_size_bytes_system_tx: Some(512 * 1024 * 16),
2610 max_gas_payment_objects: Some(256),
2611 max_modules_in_publish: Some(128),
2612 max_package_dependencies: None,
2613 max_arguments: Some(512),
2614 max_type_arguments: Some(16),
2615 max_type_argument_depth: Some(16),
2616 max_pure_argument_size: Some(16 * 1024),
2617 max_programmable_tx_commands: Some(1024),
2618 move_binary_format_version: Some(6),
2619 min_move_binary_format_version: None,
2620 binary_module_handles: None,
2621 binary_struct_handles: None,
2622 binary_function_handles: None,
2623 binary_function_instantiations: None,
2624 binary_signatures: None,
2625 binary_constant_pool: None,
2626 binary_identifiers: None,
2627 binary_address_identifiers: None,
2628 binary_struct_defs: None,
2629 binary_struct_def_instantiations: None,
2630 binary_function_defs: None,
2631 binary_field_handles: None,
2632 binary_field_instantiations: None,
2633 binary_friend_decls: None,
2634 binary_enum_defs: None,
2635 binary_enum_def_instantiations: None,
2636 binary_variant_handles: None,
2637 binary_variant_instantiation_handles: None,
2638 max_move_object_size: Some(250 * 1024),
2639 max_move_package_size: Some(100 * 1024),
2640 max_publish_or_upgrade_per_ptb: None,
2641 max_tx_gas: Some(10_000_000_000),
2642 max_gas_price: Some(100_000),
2643 max_gas_price_rgp_factor_for_aborted_transactions: None,
2644 max_gas_computation_bucket: Some(5_000_000),
2645 max_loop_depth: Some(5),
2646 max_generic_instantiation_length: Some(32),
2647 max_function_parameters: Some(128),
2648 max_basic_blocks: Some(1024),
2649 max_value_stack_size: Some(1024),
2650 max_type_nodes: Some(256),
2651 max_generic_instantiation_type_nodes_per_function: None,
2652 max_generic_instantiation_type_nodes_per_module: None,
2653 max_accumulator_type_nodes: None,
2654 max_push_size: Some(10000),
2655 max_struct_definitions: Some(200),
2656 max_function_definitions: Some(1000),
2657 max_fields_in_struct: Some(32),
2658 max_dependency_depth: Some(100),
2659 max_num_event_emit: Some(256),
2660 max_num_new_move_object_ids: Some(2048),
2661 max_num_new_move_object_ids_system_tx: Some(2048 * 16),
2662 max_num_deleted_move_object_ids: Some(2048),
2663 max_num_deleted_move_object_ids_system_tx: Some(2048 * 16),
2664 max_num_transferred_move_object_ids: Some(2048),
2665 max_num_transferred_move_object_ids_system_tx: Some(2048 * 16),
2666 max_event_emit_size: Some(250 * 1024),
2667 max_move_vector_len: Some(256 * 1024),
2668 max_type_to_layout_nodes: None,
2669 max_ptb_value_size: None,
2670
2671 max_back_edges_per_function: Some(10_000),
2672 max_back_edges_per_module: Some(10_000),
2673 max_verifier_meter_ticks_per_function: Some(6_000_000),
2674 max_meter_ticks_per_module: Some(6_000_000),
2675 max_meter_ticks_per_package: None,
2676
2677 object_runtime_max_num_cached_objects: Some(1000),
2678 object_runtime_max_num_cached_objects_system_tx: Some(1000 * 16),
2679 object_runtime_max_num_store_entries: Some(1000),
2680 object_runtime_max_num_store_entries_system_tx: Some(1000 * 16),
2681 base_tx_cost_fixed: Some(110_000),
2682 package_publish_cost_fixed: Some(1_000),
2683 base_tx_cost_per_byte: Some(0),
2684 package_publish_cost_per_byte: Some(80),
2685 obj_access_cost_read_per_byte: Some(15),
2686 obj_access_cost_mutate_per_byte: Some(40),
2687 obj_access_cost_delete_per_byte: Some(40),
2688 obj_access_cost_verify_per_byte: Some(200),
2689 obj_data_cost_refundable: Some(100),
2690 obj_metadata_cost_non_refundable: Some(50),
2691 gas_model_version: Some(1),
2692 storage_rebate_rate: Some(9900),
2693 storage_fund_reinvest_rate: Some(500),
2694 reward_slashing_rate: Some(5000),
2695 storage_gas_price: Some(1),
2696 accumulator_object_storage_cost: None,
2697 max_transactions_per_checkpoint: Some(10_000),
2698 max_checkpoint_size_bytes: Some(30 * 1024 * 1024),
2699
2700 buffer_stake_for_protocol_upgrade_bps: Some(0),
2703
2704 address_from_bytes_cost_base: Some(52),
2708 address_to_u256_cost_base: Some(52),
2710 address_from_u256_cost_base: Some(52),
2712
2713 config_read_setting_impl_cost_base: None,
2716 config_read_setting_impl_cost_per_byte: None,
2717
2718 package_original_package_id_impl_cost_base: None,
2719 package_original_package_id_impl_cost_per_byte: None,
2720
2721 dynamic_field_hash_type_and_key_cost_base: Some(100),
2724 dynamic_field_hash_type_and_key_type_cost_per_byte: Some(2),
2725 dynamic_field_hash_type_and_key_value_cost_per_byte: Some(2),
2726 dynamic_field_hash_type_and_key_type_tag_cost_per_byte: Some(2),
2727 dynamic_field_add_child_object_cost_base: Some(100),
2729 dynamic_field_add_child_object_type_cost_per_byte: Some(10),
2730 dynamic_field_add_child_object_value_cost_per_byte: Some(10),
2731 dynamic_field_add_child_object_struct_tag_cost_per_byte: Some(10),
2732 dynamic_field_borrow_child_object_cost_base: Some(100),
2734 dynamic_field_borrow_child_object_child_ref_cost_per_byte: Some(10),
2735 dynamic_field_borrow_child_object_type_cost_per_byte: Some(10),
2736 dynamic_field_remove_child_object_cost_base: Some(100),
2738 dynamic_field_remove_child_object_child_cost_per_byte: Some(2),
2739 dynamic_field_remove_child_object_type_cost_per_byte: Some(2),
2740 dynamic_field_has_child_object_cost_base: Some(100),
2742 dynamic_field_has_child_object_with_ty_cost_base: Some(100),
2744 dynamic_field_has_child_object_with_ty_type_cost_per_byte: Some(2),
2745 dynamic_field_has_child_object_with_ty_type_tag_cost_per_byte: Some(2),
2746
2747 scratch_add_cost_base: None,
2749 scratch_read_cost_base: None,
2750 scratch_read_value_cost: None,
2751 scratch_remove_cost_base: None,
2752 scratch_exists_cost_base: None,
2753 scratch_exists_with_type_cost_base: None,
2754 scratch_exists_with_type_type_cost: None,
2755 max_scratch_pad_size: None,
2756
2757 event_emit_cost_base: Some(52),
2760 event_emit_value_size_derivation_cost_per_byte: Some(2),
2761 event_emit_tag_size_derivation_cost_per_byte: Some(5),
2762 event_emit_output_cost_per_byte: Some(10),
2763 event_emit_auth_stream_cost: None,
2764
2765 reserve_object_funds_for_withdrawal_cost_base: None,
2767 reserve_object_funds_for_withdrawal_cold_read_cost: None,
2768
2769 object_borrow_uid_cost_base: Some(52),
2772 object_delete_impl_cost_base: Some(52),
2774 object_record_new_uid_cost_base: Some(52),
2776 object_record_new_uid_from_hash_cost_base: None,
2779
2780 transfer_transfer_internal_cost_base: Some(52),
2783 transfer_party_transfer_internal_cost_base: None,
2785 transfer_freeze_object_cost_base: Some(52),
2787 transfer_share_object_cost_base: Some(52),
2789 transfer_receive_object_cost_base: None,
2790 transfer_receive_object_type_cost_per_byte: None,
2791 transfer_receive_object_cost_per_byte: None,
2792
2793 tx_context_derive_id_cost_base: Some(52),
2796 tx_context_fresh_id_cost_base: None,
2797 tx_context_sender_cost_base: None,
2798 tx_context_epoch_cost_base: None,
2799 tx_context_epoch_timestamp_ms_cost_base: None,
2800 tx_context_sponsor_cost_base: None,
2801 tx_context_rgp_cost_base: None,
2802 tx_context_gas_price_cost_base: None,
2803 tx_context_gas_budget_cost_base: None,
2804 tx_context_ids_created_cost_base: None,
2805 tx_context_replace_cost_base: None,
2806
2807 types_is_one_time_witness_cost_base: Some(52),
2810 types_is_one_time_witness_type_tag_cost_per_byte: Some(2),
2811 types_is_one_time_witness_type_cost_per_byte: Some(2),
2812
2813 validator_validate_metadata_cost_base: Some(52),
2816 validator_validate_metadata_data_cost_per_byte: Some(2),
2817
2818 crypto_invalid_arguments_cost: Some(100),
2820 bls12381_bls12381_min_sig_verify_cost_base: Some(52),
2822 bls12381_bls12381_min_sig_verify_msg_cost_per_byte: Some(2),
2823 bls12381_bls12381_min_sig_verify_msg_cost_per_block: Some(2),
2824
2825 bls12381_bls12381_min_pk_verify_cost_base: Some(52),
2827 bls12381_bls12381_min_pk_verify_msg_cost_per_byte: Some(2),
2828 bls12381_bls12381_min_pk_verify_msg_cost_per_block: Some(2),
2829
2830 ecdsa_k1_ecrecover_keccak256_cost_base: Some(52),
2832 ecdsa_k1_ecrecover_keccak256_msg_cost_per_byte: Some(2),
2833 ecdsa_k1_ecrecover_keccak256_msg_cost_per_block: Some(2),
2834 ecdsa_k1_ecrecover_sha256_cost_base: Some(52),
2835 ecdsa_k1_ecrecover_sha256_msg_cost_per_byte: Some(2),
2836 ecdsa_k1_ecrecover_sha256_msg_cost_per_block: Some(2),
2837
2838 ecdsa_k1_decompress_pubkey_cost_base: Some(52),
2840
2841 ecdsa_k1_secp256k1_verify_keccak256_cost_base: Some(52),
2843 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_byte: Some(2),
2844 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_block: Some(2),
2845 ecdsa_k1_secp256k1_verify_sha256_cost_base: Some(52),
2846 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_byte: Some(2),
2847 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_block: Some(2),
2848
2849 ecdsa_r1_ecrecover_keccak256_cost_base: Some(52),
2851 ecdsa_r1_ecrecover_keccak256_msg_cost_per_byte: Some(2),
2852 ecdsa_r1_ecrecover_keccak256_msg_cost_per_block: Some(2),
2853 ecdsa_r1_ecrecover_sha256_cost_base: Some(52),
2854 ecdsa_r1_ecrecover_sha256_msg_cost_per_byte: Some(2),
2855 ecdsa_r1_ecrecover_sha256_msg_cost_per_block: Some(2),
2856
2857 ecdsa_r1_secp256r1_verify_keccak256_cost_base: Some(52),
2859 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_byte: Some(2),
2860 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_block: Some(2),
2861 ecdsa_r1_secp256r1_verify_sha256_cost_base: Some(52),
2862 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_byte: Some(2),
2863 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_block: Some(2),
2864
2865 ecvrf_ecvrf_verify_cost_base: Some(52),
2867 ecvrf_ecvrf_verify_alpha_string_cost_per_byte: Some(2),
2868 ecvrf_ecvrf_verify_alpha_string_cost_per_block: Some(2),
2869
2870 ed25519_ed25519_verify_cost_base: Some(52),
2872 ed25519_ed25519_verify_msg_cost_per_byte: Some(2),
2873 ed25519_ed25519_verify_msg_cost_per_block: Some(2),
2874
2875 groth16_prepare_verifying_key_bls12381_cost_base: Some(52),
2877 groth16_prepare_verifying_key_bn254_cost_base: Some(52),
2878
2879 groth16_verify_groth16_proof_internal_bls12381_cost_base: Some(52),
2881 groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input: Some(2),
2882 groth16_verify_groth16_proof_internal_bn254_cost_base: Some(52),
2883 groth16_verify_groth16_proof_internal_bn254_cost_per_public_input: Some(2),
2884 groth16_verify_groth16_proof_internal_public_input_cost_per_byte: Some(2),
2885
2886 hash_blake2b256_cost_base: Some(52),
2888 hash_blake2b256_data_cost_per_byte: Some(2),
2889 hash_blake2b256_data_cost_per_block: Some(2),
2890
2891 hash_keccak256_cost_base: Some(52),
2893 hash_keccak256_data_cost_per_byte: Some(2),
2894 hash_keccak256_data_cost_per_block: Some(2),
2895
2896 poseidon_bn254_cost_base: None,
2897 poseidon_bn254_cost_per_block: None,
2898
2899 hmac_hmac_sha3_256_cost_base: Some(52),
2901 hmac_hmac_sha3_256_input_cost_per_byte: Some(2),
2902 hmac_hmac_sha3_256_input_cost_per_block: Some(2),
2903
2904 group_ops_bls12381_decode_scalar_cost: None,
2906 group_ops_bls12381_decode_g1_cost: None,
2907 group_ops_bls12381_decode_g2_cost: None,
2908 group_ops_bls12381_decode_gt_cost: None,
2909 group_ops_bls12381_scalar_add_cost: None,
2910 group_ops_bls12381_g1_add_cost: None,
2911 group_ops_bls12381_g2_add_cost: None,
2912 group_ops_bls12381_gt_add_cost: None,
2913 group_ops_bls12381_scalar_sub_cost: None,
2914 group_ops_bls12381_g1_sub_cost: None,
2915 group_ops_bls12381_g2_sub_cost: None,
2916 group_ops_bls12381_gt_sub_cost: None,
2917 group_ops_bls12381_scalar_mul_cost: None,
2918 group_ops_bls12381_g1_mul_cost: None,
2919 group_ops_bls12381_g2_mul_cost: None,
2920 group_ops_bls12381_gt_mul_cost: None,
2921 group_ops_bls12381_scalar_div_cost: None,
2922 group_ops_bls12381_g1_div_cost: None,
2923 group_ops_bls12381_g2_div_cost: None,
2924 group_ops_bls12381_gt_div_cost: None,
2925 group_ops_bls12381_g1_hash_to_base_cost: None,
2926 group_ops_bls12381_g2_hash_to_base_cost: None,
2927 group_ops_bls12381_g1_hash_to_cost_per_byte: None,
2928 group_ops_bls12381_g2_hash_to_cost_per_byte: None,
2929 group_ops_bls12381_g1_msm_base_cost: None,
2930 group_ops_bls12381_g2_msm_base_cost: None,
2931 group_ops_bls12381_g1_msm_base_cost_per_input: None,
2932 group_ops_bls12381_g2_msm_base_cost_per_input: None,
2933 group_ops_bls12381_msm_max_len: None,
2934 group_ops_bls12381_pairing_cost: None,
2935 group_ops_bls12381_g1_to_uncompressed_g1_cost: None,
2936 group_ops_bls12381_uncompressed_g1_to_g1_cost: None,
2937 group_ops_bls12381_uncompressed_g1_sum_base_cost: None,
2938 group_ops_bls12381_uncompressed_g1_sum_cost_per_term: None,
2939 group_ops_bls12381_uncompressed_g1_sum_max_terms: None,
2940
2941 group_ops_ristretto_decode_scalar_cost: None,
2942 group_ops_ristretto_decode_point_cost: None,
2943 group_ops_ristretto_scalar_add_cost: None,
2944 group_ops_ristretto_point_add_cost: None,
2945 group_ops_ristretto_scalar_sub_cost: None,
2946 group_ops_ristretto_point_sub_cost: None,
2947 group_ops_ristretto_scalar_mul_cost: None,
2948 group_ops_ristretto_point_mul_cost: None,
2949 group_ops_ristretto_scalar_div_cost: None,
2950 group_ops_ristretto_point_div_cost: None,
2951
2952 verify_bulletproofs_ristretto255_base_cost: None,
2953 verify_bulletproofs_ristretto255_cost_per_bit_and_commitment: None,
2954 max_bulletproofs_total_bits: None,
2955
2956 check_zklogin_id_cost_base: None,
2958 check_zklogin_issuer_cost_base: None,
2960
2961 vdf_verify_vdf_cost: None,
2962 vdf_hash_to_input_cost: None,
2963
2964 nitro_attestation_parse_base_cost: None,
2966 nitro_attestation_parse_cost_per_byte: None,
2967 nitro_attestation_verify_base_cost: None,
2968 nitro_attestation_verify_cost_per_cert: None,
2969
2970 bcs_per_byte_serialized_cost: None,
2971 bcs_legacy_min_output_size_cost: None,
2972 bcs_failure_cost: None,
2973 hash_sha2_256_base_cost: None,
2974 hash_sha2_256_per_byte_cost: None,
2975 hash_sha2_256_legacy_min_input_len_cost: None,
2976 hash_sha3_256_base_cost: None,
2977 hash_sha3_256_per_byte_cost: None,
2978 hash_sha3_256_legacy_min_input_len_cost: None,
2979 type_name_get_base_cost: None,
2980 type_name_get_per_byte_cost: None,
2981 type_name_id_base_cost: None,
2982 string_check_utf8_base_cost: None,
2983 string_check_utf8_per_byte_cost: None,
2984 string_is_char_boundary_base_cost: None,
2985 string_sub_string_base_cost: None,
2986 string_sub_string_per_byte_cost: None,
2987 string_index_of_base_cost: None,
2988 string_index_of_per_byte_pattern_cost: None,
2989 string_index_of_per_byte_searched_cost: None,
2990 vector_empty_base_cost: None,
2991 vector_length_base_cost: None,
2992 vector_push_back_base_cost: None,
2993 vector_push_back_legacy_per_abstract_memory_unit_cost: None,
2994 vector_borrow_base_cost: None,
2995 vector_pop_back_base_cost: None,
2996 vector_destroy_empty_base_cost: None,
2997 vector_swap_base_cost: None,
2998 debug_print_base_cost: None,
2999 debug_print_stack_trace_base_cost: None,
3000
3001 max_size_written_objects: None,
3002 max_size_written_objects_system_tx: None,
3003
3004 max_move_identifier_len: None,
3011 max_move_value_depth: None,
3012 package_arena_size_in_bytes: None,
3013 max_move_enum_variants: None,
3014
3015 gas_rounding_step: None,
3016
3017 execution_version: None,
3018
3019 max_event_emit_size_total: None,
3020
3021 consensus_bad_nodes_stake_threshold: None,
3022
3023 max_jwk_votes_per_validator_per_epoch: None,
3024
3025 max_age_of_jwk_in_epochs: None,
3026
3027 random_beacon_reduction_allowed_delta: None,
3028
3029 random_beacon_reduction_lower_bound: None,
3030
3031 random_beacon_dkg_timeout_round: None,
3032
3033 random_beacon_min_round_interval_ms: None,
3034
3035 random_beacon_dkg_version: None,
3036
3037 consensus_max_transaction_size_bytes: None,
3038
3039 consensus_max_transactions_in_block_bytes: None,
3040
3041 consensus_max_num_transactions_in_block: None,
3042
3043 consensus_voting_rounds: None,
3044
3045 max_accumulated_txn_cost_per_object_in_narwhal_commit: None,
3046
3047 max_deferral_rounds_for_congestion_control: None,
3048
3049 epoch_close_deadline_ms: None,
3050
3051 max_txn_cost_overage_per_object_in_commit: None,
3052
3053 allowed_txn_cost_overage_burst_per_object_in_commit: None,
3054
3055 min_checkpoint_interval_ms: None,
3056
3057 checkpoint_summary_version_specific_data: None,
3058
3059 max_soft_bundle_size: None,
3060
3061 bridge_should_try_to_finalize_committee: None,
3062
3063 max_accumulated_txn_cost_per_object_in_mysticeti_commit: None,
3064
3065 max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit: None,
3066
3067 consensus_gc_depth: None,
3068
3069 gas_budget_based_txn_cost_cap_factor: None,
3070
3071 gas_budget_based_txn_cost_absolute_cap_commit_count: None,
3072
3073 sip_45_consensus_amplification_threshold: None,
3074
3075 use_object_per_epoch_marker_table_v2: None,
3076
3077 consensus_commit_rate_estimation_window_size: None,
3078
3079 aliased_addresses: vec![],
3080
3081 translation_per_command_base_charge: None,
3082 translation_per_input_base_charge: None,
3083 translation_pure_input_per_byte_charge: None,
3084 translation_per_type_node_charge: None,
3085 translation_per_reference_node_charge: None,
3086 translation_per_linkage_entry_charge: None,
3087 translation_per_live_reference_charge: None,
3088 max_ptb_live_references: None,
3089 max_ptb_returned_references: None,
3090 max_ptb_total_returned_references: None,
3091
3092 max_updates_per_settlement_txn: None,
3093
3094 gasless_max_computation_units: None,
3095 gasless_allowed_token_types: None,
3096 gasless_max_unused_inputs: None,
3097 gasless_max_pure_input_bytes: None,
3098 gasless_max_tps: None,
3099 include_special_package_amendments: None,
3100 gasless_max_tx_size_bytes: None,
3101 };
3104 for cur in 2..=version.0 {
3105 match cur {
3106 1 => unreachable!(),
3107 2 => {
3108 cfg.feature_flags.advance_epoch_start_time_in_safe_mode = true;
3109 }
3110 3 => {
3111 cfg.gas_model_version = Some(2);
3113 cfg.max_tx_gas = Some(50_000_000_000);
3115 cfg.base_tx_cost_fixed = Some(2_000);
3117 cfg.storage_gas_price = Some(76);
3119 cfg.feature_flags.loaded_child_objects_fixed = true;
3120 cfg.max_size_written_objects = Some(5 * 1000 * 1000);
3123 cfg.max_size_written_objects_system_tx = Some(50 * 1000 * 1000);
3126 cfg.feature_flags.package_upgrades = true;
3127 }
3128 4 => {
3133 cfg.reward_slashing_rate = Some(10000);
3135 cfg.gas_model_version = Some(3);
3137 }
3138 5 => {
3139 cfg.feature_flags.missing_type_is_compatibility_error = true;
3140 cfg.gas_model_version = Some(4);
3141 cfg.feature_flags.scoring_decision_with_validity_cutoff = true;
3142 }
3146 6 => {
3147 cfg.gas_model_version = Some(5);
3148 cfg.buffer_stake_for_protocol_upgrade_bps = Some(5000);
3149 cfg.feature_flags.consensus_order_end_of_epoch_last = true;
3150 }
3151 7 => {
3152 cfg.feature_flags.disallow_adding_abilities_on_upgrade = true;
3153 cfg.feature_flags
3154 .disable_invariant_violation_check_in_swap_loc = true;
3155 cfg.feature_flags.ban_entry_init = true;
3156 cfg.feature_flags.package_digest_hash_module = true;
3157 }
3158 8 => {
3159 cfg.feature_flags
3160 .disallow_change_struct_type_params_on_upgrade = true;
3161 }
3162 9 => {
3163 cfg.max_move_identifier_len = Some(128);
3165 cfg.feature_flags.no_extraneous_module_bytes = true;
3166 cfg.feature_flags
3167 .advance_to_highest_supported_protocol_version = true;
3168 }
3169 10 => {
3170 cfg.max_verifier_meter_ticks_per_function = Some(16_000_000);
3171 cfg.max_meter_ticks_per_module = Some(16_000_000);
3172 }
3173 11 => {
3174 cfg.max_move_value_depth = Some(128);
3175 }
3176 12 => {
3177 cfg.feature_flags.narwhal_versioned_metadata = true;
3178 if chain != Chain::Mainnet {
3179 cfg.feature_flags.commit_root_state_digest = true;
3180 }
3181
3182 if chain != Chain::Mainnet && chain != Chain::Testnet {
3183 cfg.feature_flags.zklogin_auth = true;
3184 }
3185 }
3186 13 => {}
3187 14 => {
3188 cfg.gas_rounding_step = Some(1_000);
3189 cfg.gas_model_version = Some(6);
3190 }
3191 15 => {
3192 cfg.feature_flags.consensus_transaction_ordering =
3193 ConsensusTransactionOrdering::ByGasPrice;
3194 }
3195 16 => {
3196 cfg.feature_flags.simplified_unwrap_then_delete = true;
3197 }
3198 17 => {
3199 cfg.feature_flags.upgraded_multisig_supported = true;
3200 }
3201 18 => {
3202 cfg.execution_version = Some(1);
3203 cfg.feature_flags.txn_base_cost_as_multiplier = true;
3212 cfg.base_tx_cost_fixed = Some(1_000);
3214 }
3215 19 => {
3216 cfg.max_num_event_emit = Some(1024);
3217 cfg.max_event_emit_size_total = Some(
3220 256 * 250 * 1024, );
3222 }
3223 20 => {
3224 cfg.feature_flags.commit_root_state_digest = true;
3225
3226 if chain != Chain::Mainnet {
3227 cfg.feature_flags.narwhal_new_leader_election_schedule = true;
3228 cfg.consensus_bad_nodes_stake_threshold = Some(20);
3229 }
3230 }
3231
3232 21 => {
3233 if chain != Chain::Mainnet {
3234 cfg.feature_flags.zklogin_supported_providers = BTreeSet::from([
3235 "Google".to_string(),
3236 "Facebook".to_string(),
3237 "Twitch".to_string(),
3238 ]);
3239 }
3240 }
3241 22 => {
3242 cfg.feature_flags.loaded_child_object_format = true;
3243 }
3244 23 => {
3245 cfg.feature_flags.loaded_child_object_format_type = true;
3246 cfg.feature_flags.narwhal_new_leader_election_schedule = true;
3247 cfg.consensus_bad_nodes_stake_threshold = Some(20);
3253 }
3254 24 => {
3255 cfg.feature_flags.simple_conservation_checks = true;
3256 cfg.max_publish_or_upgrade_per_ptb = Some(5);
3257
3258 cfg.feature_flags.end_of_epoch_transaction_supported = true;
3259
3260 if chain != Chain::Mainnet {
3261 cfg.feature_flags.enable_jwk_consensus_updates = true;
3262 cfg.max_jwk_votes_per_validator_per_epoch = Some(240);
3264 cfg.max_age_of_jwk_in_epochs = Some(1);
3265 }
3266 }
3267 25 => {
3268 cfg.feature_flags.zklogin_supported_providers = BTreeSet::from([
3270 "Google".to_string(),
3271 "Facebook".to_string(),
3272 "Twitch".to_string(),
3273 ]);
3274 cfg.feature_flags.zklogin_auth = true;
3275
3276 cfg.feature_flags.enable_jwk_consensus_updates = true;
3278 cfg.max_jwk_votes_per_validator_per_epoch = Some(240);
3279 cfg.max_age_of_jwk_in_epochs = Some(1);
3280 }
3281 26 => {
3282 cfg.gas_model_version = Some(7);
3283 if chain != Chain::Mainnet && chain != Chain::Testnet {
3285 cfg.transfer_receive_object_cost_base = Some(52);
3286 cfg.feature_flags.receive_objects = true;
3287 }
3288 }
3289 27 => {
3290 cfg.gas_model_version = Some(8);
3291 }
3292 28 => {
3293 cfg.check_zklogin_id_cost_base = Some(200);
3295 cfg.check_zklogin_issuer_cost_base = Some(200);
3297
3298 if chain != Chain::Mainnet && chain != Chain::Testnet {
3300 cfg.feature_flags.enable_effects_v2 = true;
3301 }
3302 }
3303 29 => {
3304 cfg.feature_flags.verify_legacy_zklogin_address = true;
3305 }
3306 30 => {
3307 if chain != Chain::Mainnet {
3309 cfg.feature_flags.narwhal_certificate_v2 = true;
3310 }
3311
3312 cfg.random_beacon_reduction_allowed_delta = Some(800);
3313 if chain != Chain::Mainnet {
3315 cfg.feature_flags.enable_effects_v2 = true;
3316 }
3317
3318 cfg.feature_flags.zklogin_supported_providers = BTreeSet::default();
3322
3323 cfg.feature_flags.recompute_has_public_transfer_in_execution = true;
3324 }
3325 31 => {
3326 cfg.execution_version = Some(2);
3327 if chain != Chain::Mainnet && chain != Chain::Testnet {
3329 cfg.feature_flags.shared_object_deletion = true;
3330 }
3331 }
3332 32 => {
3333 if chain != Chain::Mainnet {
3335 cfg.feature_flags.accept_zklogin_in_multisig = true;
3336 }
3337 if chain != Chain::Mainnet {
3339 cfg.transfer_receive_object_cost_base = Some(52);
3340 cfg.feature_flags.receive_objects = true;
3341 }
3342 if chain != Chain::Mainnet && chain != Chain::Testnet {
3344 cfg.feature_flags.random_beacon = true;
3345 cfg.random_beacon_reduction_lower_bound = Some(1600);
3346 cfg.random_beacon_dkg_timeout_round = Some(3000);
3347 cfg.random_beacon_min_round_interval_ms = Some(150);
3348 }
3349 if chain != Chain::Testnet && chain != Chain::Mainnet {
3351 cfg.feature_flags.include_consensus_digest_in_prologue = true;
3352 }
3353
3354 cfg.feature_flags.narwhal_certificate_v2 = true;
3356 }
3357 33 => {
3358 cfg.feature_flags.hardened_otw_check = true;
3359 cfg.feature_flags.allow_receiving_object_id = true;
3360
3361 cfg.transfer_receive_object_cost_base = Some(52);
3363 cfg.feature_flags.receive_objects = true;
3364
3365 if chain != Chain::Mainnet {
3367 cfg.feature_flags.shared_object_deletion = true;
3368 }
3369
3370 cfg.feature_flags.enable_effects_v2 = true;
3371 }
3372 34 => {}
3373 35 => {
3374 if chain != Chain::Mainnet && chain != Chain::Testnet {
3376 cfg.feature_flags.enable_poseidon = true;
3377 cfg.poseidon_bn254_cost_base = Some(260);
3378 cfg.poseidon_bn254_cost_per_block = Some(10);
3379 }
3380
3381 cfg.feature_flags.enable_coin_deny_list = true;
3382 }
3383 36 => {
3384 if chain != Chain::Mainnet && chain != Chain::Testnet {
3386 cfg.feature_flags.enable_group_ops_native_functions = true;
3387 cfg.feature_flags.enable_group_ops_native_function_msm = true;
3388 cfg.group_ops_bls12381_decode_scalar_cost = Some(52);
3390 cfg.group_ops_bls12381_decode_g1_cost = Some(52);
3391 cfg.group_ops_bls12381_decode_g2_cost = Some(52);
3392 cfg.group_ops_bls12381_decode_gt_cost = Some(52);
3393 cfg.group_ops_bls12381_scalar_add_cost = Some(52);
3394 cfg.group_ops_bls12381_g1_add_cost = Some(52);
3395 cfg.group_ops_bls12381_g2_add_cost = Some(52);
3396 cfg.group_ops_bls12381_gt_add_cost = Some(52);
3397 cfg.group_ops_bls12381_scalar_sub_cost = Some(52);
3398 cfg.group_ops_bls12381_g1_sub_cost = Some(52);
3399 cfg.group_ops_bls12381_g2_sub_cost = Some(52);
3400 cfg.group_ops_bls12381_gt_sub_cost = Some(52);
3401 cfg.group_ops_bls12381_scalar_mul_cost = Some(52);
3402 cfg.group_ops_bls12381_g1_mul_cost = Some(52);
3403 cfg.group_ops_bls12381_g2_mul_cost = Some(52);
3404 cfg.group_ops_bls12381_gt_mul_cost = Some(52);
3405 cfg.group_ops_bls12381_scalar_div_cost = Some(52);
3406 cfg.group_ops_bls12381_g1_div_cost = Some(52);
3407 cfg.group_ops_bls12381_g2_div_cost = Some(52);
3408 cfg.group_ops_bls12381_gt_div_cost = Some(52);
3409 cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(52);
3410 cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(52);
3411 cfg.group_ops_bls12381_g1_hash_to_cost_per_byte = Some(2);
3412 cfg.group_ops_bls12381_g2_hash_to_cost_per_byte = Some(2);
3413 cfg.group_ops_bls12381_g1_msm_base_cost = Some(52);
3414 cfg.group_ops_bls12381_g2_msm_base_cost = Some(52);
3415 cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(52);
3416 cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(52);
3417 cfg.group_ops_bls12381_msm_max_len = Some(32);
3418 cfg.group_ops_bls12381_pairing_cost = Some(52);
3419 }
3420 cfg.feature_flags.shared_object_deletion = true;
3422
3423 cfg.consensus_max_transaction_size_bytes = Some(256 * 1024); cfg.consensus_max_transactions_in_block_bytes = Some(6 * 1_024 * 1024);
3425 }
3427 37 => {
3428 cfg.feature_flags.reject_mutable_random_on_entry_functions = true;
3429
3430 if chain != Chain::Mainnet {
3432 cfg.feature_flags.include_consensus_digest_in_prologue = true;
3433 }
3434 }
3435 38 => {
3436 cfg.binary_module_handles = Some(100);
3437 cfg.binary_struct_handles = Some(300);
3438 cfg.binary_function_handles = Some(1500);
3439 cfg.binary_function_instantiations = Some(750);
3440 cfg.binary_signatures = Some(1000);
3441 cfg.binary_constant_pool = Some(4000);
3445 cfg.binary_identifiers = Some(10000);
3446 cfg.binary_address_identifiers = Some(100);
3447 cfg.binary_struct_defs = Some(200);
3448 cfg.binary_struct_def_instantiations = Some(100);
3449 cfg.binary_function_defs = Some(1000);
3450 cfg.binary_field_handles = Some(500);
3451 cfg.binary_field_instantiations = Some(250);
3452 cfg.binary_friend_decls = Some(100);
3453 cfg.max_package_dependencies = Some(32);
3455 cfg.max_modules_in_publish = Some(64);
3456 cfg.execution_version = Some(3);
3458 }
3459 39 => {
3460 }
3462 40 => {}
3463 41 => {
3464 cfg.feature_flags.enable_group_ops_native_functions = true;
3466 cfg.group_ops_bls12381_decode_scalar_cost = Some(52);
3468 cfg.group_ops_bls12381_decode_g1_cost = Some(52);
3469 cfg.group_ops_bls12381_decode_g2_cost = Some(52);
3470 cfg.group_ops_bls12381_decode_gt_cost = Some(52);
3471 cfg.group_ops_bls12381_scalar_add_cost = Some(52);
3472 cfg.group_ops_bls12381_g1_add_cost = Some(52);
3473 cfg.group_ops_bls12381_g2_add_cost = Some(52);
3474 cfg.group_ops_bls12381_gt_add_cost = Some(52);
3475 cfg.group_ops_bls12381_scalar_sub_cost = Some(52);
3476 cfg.group_ops_bls12381_g1_sub_cost = Some(52);
3477 cfg.group_ops_bls12381_g2_sub_cost = Some(52);
3478 cfg.group_ops_bls12381_gt_sub_cost = Some(52);
3479 cfg.group_ops_bls12381_scalar_mul_cost = Some(52);
3480 cfg.group_ops_bls12381_g1_mul_cost = Some(52);
3481 cfg.group_ops_bls12381_g2_mul_cost = Some(52);
3482 cfg.group_ops_bls12381_gt_mul_cost = Some(52);
3483 cfg.group_ops_bls12381_scalar_div_cost = Some(52);
3484 cfg.group_ops_bls12381_g1_div_cost = Some(52);
3485 cfg.group_ops_bls12381_g2_div_cost = Some(52);
3486 cfg.group_ops_bls12381_gt_div_cost = Some(52);
3487 cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(52);
3488 cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(52);
3489 cfg.group_ops_bls12381_g1_hash_to_cost_per_byte = Some(2);
3490 cfg.group_ops_bls12381_g2_hash_to_cost_per_byte = Some(2);
3491 cfg.group_ops_bls12381_g1_msm_base_cost = Some(52);
3492 cfg.group_ops_bls12381_g2_msm_base_cost = Some(52);
3493 cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(52);
3494 cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(52);
3495 cfg.group_ops_bls12381_msm_max_len = Some(32);
3496 cfg.group_ops_bls12381_pairing_cost = Some(52);
3497 }
3498 42 => {}
3499 43 => {
3500 cfg.feature_flags.zklogin_max_epoch_upper_bound_delta = Some(30);
3501 cfg.max_meter_ticks_per_package = Some(16_000_000);
3502 }
3503 44 => {
3504 cfg.feature_flags.include_consensus_digest_in_prologue = true;
3506 if chain != Chain::Mainnet {
3508 cfg.feature_flags.consensus_choice = ConsensusChoice::SwapEachEpoch;
3509 }
3510 }
3511 45 => {
3512 if chain != Chain::Testnet && chain != Chain::Mainnet {
3514 cfg.feature_flags.consensus_network = ConsensusNetwork::Tonic;
3515 }
3516
3517 if chain != Chain::Mainnet {
3518 cfg.feature_flags.mysticeti_leader_scoring_and_schedule = true;
3520 }
3521 cfg.min_move_binary_format_version = Some(6);
3522 cfg.feature_flags.accept_zklogin_in_multisig = true;
3523
3524 if chain != Chain::Mainnet && chain != Chain::Testnet {
3528 cfg.feature_flags.bridge = true;
3529 }
3530 }
3531 46 => {
3532 if chain != Chain::Mainnet {
3534 cfg.feature_flags.bridge = true;
3535 }
3536
3537 cfg.feature_flags.reshare_at_same_initial_version = true;
3539 }
3540 47 => {}
3541 48 => {
3542 cfg.feature_flags.consensus_network = ConsensusNetwork::Tonic;
3544
3545 cfg.feature_flags.resolve_abort_locations_to_package_id = true;
3547
3548 if chain != Chain::Mainnet {
3550 cfg.feature_flags.random_beacon = true;
3551 cfg.random_beacon_reduction_lower_bound = Some(1600);
3552 cfg.random_beacon_dkg_timeout_round = Some(3000);
3553 cfg.random_beacon_min_round_interval_ms = Some(200);
3554 }
3555
3556 cfg.feature_flags.mysticeti_use_committed_subdag_digest = true;
3558 }
3559 49 => {
3560 if chain != Chain::Testnet && chain != Chain::Mainnet {
3561 cfg.move_binary_format_version = Some(7);
3562 }
3563
3564 if chain != Chain::Mainnet && chain != Chain::Testnet {
3566 cfg.feature_flags.enable_vdf = true;
3567 cfg.vdf_verify_vdf_cost = Some(1500);
3570 cfg.vdf_hash_to_input_cost = Some(100);
3571 }
3572
3573 if chain != Chain::Testnet && chain != Chain::Mainnet {
3575 cfg.feature_flags
3576 .record_consensus_determined_version_assignments_in_prologue = true;
3577 }
3578
3579 if chain != Chain::Mainnet {
3581 cfg.feature_flags.consensus_choice = ConsensusChoice::Mysticeti;
3582 }
3583
3584 cfg.feature_flags.fresh_vm_on_framework_upgrade = true;
3586 }
3587 50 => {
3588 if chain != Chain::Mainnet {
3590 cfg.checkpoint_summary_version_specific_data = Some(1);
3591 cfg.min_checkpoint_interval_ms = Some(200);
3592 }
3593
3594 if chain != Chain::Testnet && chain != Chain::Mainnet {
3596 cfg.feature_flags
3597 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = true;
3598 }
3599
3600 cfg.feature_flags.mysticeti_num_leaders_per_round = Some(1);
3601
3602 cfg.max_deferral_rounds_for_congestion_control = Some(10);
3604 }
3605 51 => {
3606 cfg.random_beacon_dkg_version = Some(1);
3607
3608 if chain != Chain::Testnet && chain != Chain::Mainnet {
3609 cfg.feature_flags.enable_coin_deny_list_v2 = true;
3610 }
3611 }
3612 52 => {
3613 if chain != Chain::Mainnet {
3614 cfg.feature_flags.soft_bundle = true;
3615 cfg.max_soft_bundle_size = Some(5);
3616 }
3617
3618 cfg.config_read_setting_impl_cost_base = Some(100);
3619 cfg.config_read_setting_impl_cost_per_byte = Some(40);
3620
3621 if chain != Chain::Testnet && chain != Chain::Mainnet {
3623 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(100);
3624 cfg.feature_flags.per_object_congestion_control_mode =
3625 PerObjectCongestionControlMode::TotalTxCount;
3626 }
3627
3628 cfg.feature_flags.consensus_choice = ConsensusChoice::Mysticeti;
3630
3631 cfg.feature_flags.mysticeti_leader_scoring_and_schedule = true;
3633
3634 cfg.checkpoint_summary_version_specific_data = Some(1);
3636 cfg.min_checkpoint_interval_ms = Some(200);
3637
3638 if chain != Chain::Mainnet {
3640 cfg.feature_flags
3641 .record_consensus_determined_version_assignments_in_prologue = true;
3642 cfg.feature_flags
3643 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = true;
3644 }
3645 if chain != Chain::Mainnet {
3647 cfg.move_binary_format_version = Some(7);
3648 }
3649
3650 if chain != Chain::Testnet && chain != Chain::Mainnet {
3651 cfg.feature_flags.passkey_auth = true;
3652 }
3653 cfg.feature_flags.enable_coin_deny_list_v2 = true;
3654 }
3655 53 => {
3656 cfg.bridge_should_try_to_finalize_committee = Some(chain != Chain::Mainnet);
3658
3659 cfg.feature_flags
3661 .record_consensus_determined_version_assignments_in_prologue = true;
3662 cfg.feature_flags
3663 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = true;
3664
3665 if chain == Chain::Unknown {
3666 cfg.feature_flags.authority_capabilities_v2 = true;
3667 }
3668
3669 if chain != Chain::Mainnet {
3671 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(100);
3672 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(10);
3673 cfg.feature_flags.per_object_congestion_control_mode =
3674 PerObjectCongestionControlMode::TotalTxCount;
3675 }
3676
3677 cfg.bcs_per_byte_serialized_cost = Some(2);
3679 cfg.bcs_legacy_min_output_size_cost = Some(1);
3680 cfg.bcs_failure_cost = Some(52);
3681 cfg.debug_print_base_cost = Some(52);
3682 cfg.debug_print_stack_trace_base_cost = Some(52);
3683 cfg.hash_sha2_256_base_cost = Some(52);
3684 cfg.hash_sha2_256_per_byte_cost = Some(2);
3685 cfg.hash_sha2_256_legacy_min_input_len_cost = Some(1);
3686 cfg.hash_sha3_256_base_cost = Some(52);
3687 cfg.hash_sha3_256_per_byte_cost = Some(2);
3688 cfg.hash_sha3_256_legacy_min_input_len_cost = Some(1);
3689 cfg.type_name_get_base_cost = Some(52);
3690 cfg.type_name_get_per_byte_cost = Some(2);
3691 cfg.string_check_utf8_base_cost = Some(52);
3692 cfg.string_check_utf8_per_byte_cost = Some(2);
3693 cfg.string_is_char_boundary_base_cost = Some(52);
3694 cfg.string_sub_string_base_cost = Some(52);
3695 cfg.string_sub_string_per_byte_cost = Some(2);
3696 cfg.string_index_of_base_cost = Some(52);
3697 cfg.string_index_of_per_byte_pattern_cost = Some(2);
3698 cfg.string_index_of_per_byte_searched_cost = Some(2);
3699 cfg.vector_empty_base_cost = Some(52);
3700 cfg.vector_length_base_cost = Some(52);
3701 cfg.vector_push_back_base_cost = Some(52);
3702 cfg.vector_push_back_legacy_per_abstract_memory_unit_cost = Some(2);
3703 cfg.vector_borrow_base_cost = Some(52);
3704 cfg.vector_pop_back_base_cost = Some(52);
3705 cfg.vector_destroy_empty_base_cost = Some(52);
3706 cfg.vector_swap_base_cost = Some(52);
3707 }
3708 54 => {
3709 cfg.feature_flags.random_beacon = true;
3711 cfg.random_beacon_reduction_lower_bound = Some(1000);
3712 cfg.random_beacon_dkg_timeout_round = Some(3000);
3713 cfg.random_beacon_min_round_interval_ms = Some(500);
3714
3715 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(100);
3717 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(10);
3718 cfg.feature_flags.per_object_congestion_control_mode =
3719 PerObjectCongestionControlMode::TotalTxCount;
3720
3721 cfg.feature_flags.soft_bundle = true;
3723 cfg.max_soft_bundle_size = Some(5);
3724 }
3725 55 => {
3726 cfg.move_binary_format_version = Some(7);
3728
3729 cfg.consensus_max_transactions_in_block_bytes = Some(512 * 1024);
3731 cfg.consensus_max_num_transactions_in_block = Some(512);
3734
3735 cfg.feature_flags.rethrow_serialization_type_layout_errors = true;
3736 }
3737 56 => {
3738 if chain == Chain::Mainnet {
3739 cfg.feature_flags.bridge = true;
3740 }
3741 }
3742 57 => {
3743 cfg.random_beacon_reduction_lower_bound = Some(800);
3745 }
3746 58 => {
3747 if chain == Chain::Mainnet {
3748 cfg.bridge_should_try_to_finalize_committee = Some(true);
3749 }
3750
3751 if chain != Chain::Mainnet && chain != Chain::Testnet {
3752 cfg.feature_flags
3754 .consensus_distributed_vote_scoring_strategy = true;
3755 }
3756 }
3757 59 => {
3758 cfg.feature_flags.consensus_round_prober = true;
3760 }
3761 60 => {
3762 cfg.max_type_to_layout_nodes = Some(512);
3763 cfg.feature_flags.validate_identifier_inputs = true;
3764 }
3765 61 => {
3766 if chain != Chain::Mainnet {
3767 cfg.feature_flags
3769 .consensus_distributed_vote_scoring_strategy = true;
3770 }
3771 cfg.random_beacon_reduction_lower_bound = Some(700);
3773
3774 if chain != Chain::Mainnet && chain != Chain::Testnet {
3775 cfg.feature_flags.mysticeti_fastpath = true;
3777 }
3778 }
3779 62 => {
3780 cfg.feature_flags.relocate_event_module = true;
3781 }
3782 63 => {
3783 cfg.feature_flags.per_object_congestion_control_mode =
3784 PerObjectCongestionControlMode::TotalGasBudgetWithCap;
3785 cfg.gas_budget_based_txn_cost_cap_factor = Some(400_000);
3786 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(18_500_000);
3787 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(240_000_000);
3788 }
3789 64 => {
3790 cfg.feature_flags.per_object_congestion_control_mode =
3791 PerObjectCongestionControlMode::TotalTxCount;
3792 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(40);
3793 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(3);
3794 }
3795 65 => {
3796 cfg.feature_flags
3798 .consensus_distributed_vote_scoring_strategy = true;
3799 }
3800 66 => {
3801 if chain == Chain::Mainnet {
3802 cfg.feature_flags
3804 .consensus_distributed_vote_scoring_strategy = false;
3805 }
3806 }
3807 67 => {
3808 cfg.feature_flags
3810 .consensus_distributed_vote_scoring_strategy = true;
3811 }
3812 68 => {
3813 cfg.group_ops_bls12381_g1_to_uncompressed_g1_cost = Some(26);
3814 cfg.group_ops_bls12381_uncompressed_g1_to_g1_cost = Some(52);
3815 cfg.group_ops_bls12381_uncompressed_g1_sum_base_cost = Some(26);
3816 cfg.group_ops_bls12381_uncompressed_g1_sum_cost_per_term = Some(13);
3817 cfg.group_ops_bls12381_uncompressed_g1_sum_max_terms = Some(2000);
3818
3819 if chain != Chain::Mainnet && chain != Chain::Testnet {
3820 cfg.feature_flags.uncompressed_g1_group_elements = true;
3821 }
3822
3823 cfg.feature_flags.per_object_congestion_control_mode =
3824 PerObjectCongestionControlMode::TotalGasBudgetWithCap;
3825 cfg.gas_budget_based_txn_cost_cap_factor = Some(400_000);
3826 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(18_500_000);
3827 cfg.max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit =
3828 Some(3_700_000); cfg.max_txn_cost_overage_per_object_in_commit = Some(u64::MAX);
3830 cfg.gas_budget_based_txn_cost_absolute_cap_commit_count = Some(50);
3831
3832 cfg.random_beacon_reduction_lower_bound = Some(500);
3834
3835 cfg.feature_flags.disallow_new_modules_in_deps_only_packages = true;
3836 }
3837 69 => {
3838 cfg.consensus_voting_rounds = Some(40);
3840
3841 if chain != Chain::Mainnet && chain != Chain::Testnet {
3842 cfg.feature_flags.consensus_smart_ancestor_selection = true;
3844 }
3845
3846 if chain != Chain::Mainnet {
3847 cfg.feature_flags.uncompressed_g1_group_elements = true;
3848 }
3849 }
3850 70 => {
3851 if chain != Chain::Mainnet {
3852 cfg.feature_flags.consensus_smart_ancestor_selection = true;
3854 cfg.feature_flags
3856 .consensus_round_prober_probe_accepted_rounds = true;
3857 }
3858
3859 cfg.poseidon_bn254_cost_per_block = Some(388);
3860
3861 cfg.gas_model_version = Some(9);
3862 cfg.feature_flags.native_charging_v2 = true;
3863 cfg.bls12381_bls12381_min_sig_verify_cost_base = Some(44064);
3864 cfg.bls12381_bls12381_min_pk_verify_cost_base = Some(49282);
3865 cfg.ecdsa_k1_secp256k1_verify_keccak256_cost_base = Some(1470);
3866 cfg.ecdsa_k1_secp256k1_verify_sha256_cost_base = Some(1470);
3867 cfg.ecdsa_r1_secp256r1_verify_sha256_cost_base = Some(4225);
3868 cfg.ecdsa_r1_secp256r1_verify_keccak256_cost_base = Some(4225);
3869 cfg.ecvrf_ecvrf_verify_cost_base = Some(4848);
3870 cfg.ed25519_ed25519_verify_cost_base = Some(1802);
3871
3872 cfg.ecdsa_r1_ecrecover_keccak256_cost_base = Some(1173);
3874 cfg.ecdsa_r1_ecrecover_sha256_cost_base = Some(1173);
3875 cfg.ecdsa_k1_ecrecover_keccak256_cost_base = Some(500);
3876 cfg.ecdsa_k1_ecrecover_sha256_cost_base = Some(500);
3877
3878 cfg.groth16_prepare_verifying_key_bls12381_cost_base = Some(53838);
3879 cfg.groth16_prepare_verifying_key_bn254_cost_base = Some(82010);
3880 cfg.groth16_verify_groth16_proof_internal_bls12381_cost_base = Some(72090);
3881 cfg.groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input =
3882 Some(8213);
3883 cfg.groth16_verify_groth16_proof_internal_bn254_cost_base = Some(115502);
3884 cfg.groth16_verify_groth16_proof_internal_bn254_cost_per_public_input =
3885 Some(9484);
3886
3887 cfg.hash_keccak256_cost_base = Some(10);
3888 cfg.hash_blake2b256_cost_base = Some(10);
3889
3890 cfg.group_ops_bls12381_decode_scalar_cost = Some(7);
3892 cfg.group_ops_bls12381_decode_g1_cost = Some(2848);
3893 cfg.group_ops_bls12381_decode_g2_cost = Some(3770);
3894 cfg.group_ops_bls12381_decode_gt_cost = Some(3068);
3895
3896 cfg.group_ops_bls12381_scalar_add_cost = Some(10);
3897 cfg.group_ops_bls12381_g1_add_cost = Some(1556);
3898 cfg.group_ops_bls12381_g2_add_cost = Some(3048);
3899 cfg.group_ops_bls12381_gt_add_cost = Some(188);
3900
3901 cfg.group_ops_bls12381_scalar_sub_cost = Some(10);
3902 cfg.group_ops_bls12381_g1_sub_cost = Some(1550);
3903 cfg.group_ops_bls12381_g2_sub_cost = Some(3019);
3904 cfg.group_ops_bls12381_gt_sub_cost = Some(497);
3905
3906 cfg.group_ops_bls12381_scalar_mul_cost = Some(11);
3907 cfg.group_ops_bls12381_g1_mul_cost = Some(4842);
3908 cfg.group_ops_bls12381_g2_mul_cost = Some(9108);
3909 cfg.group_ops_bls12381_gt_mul_cost = Some(27490);
3910
3911 cfg.group_ops_bls12381_scalar_div_cost = Some(91);
3912 cfg.group_ops_bls12381_g1_div_cost = Some(5091);
3913 cfg.group_ops_bls12381_g2_div_cost = Some(9206);
3914 cfg.group_ops_bls12381_gt_div_cost = Some(27804);
3915
3916 cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(2962);
3917 cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(8688);
3918
3919 cfg.group_ops_bls12381_g1_msm_base_cost = Some(62648);
3920 cfg.group_ops_bls12381_g2_msm_base_cost = Some(131192);
3921 cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(1333);
3922 cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(3216);
3923
3924 cfg.group_ops_bls12381_uncompressed_g1_to_g1_cost = Some(677);
3925 cfg.group_ops_bls12381_g1_to_uncompressed_g1_cost = Some(2099);
3926 cfg.group_ops_bls12381_uncompressed_g1_sum_base_cost = Some(77);
3927 cfg.group_ops_bls12381_uncompressed_g1_sum_cost_per_term = Some(26);
3928
3929 cfg.group_ops_bls12381_pairing_cost = Some(26897);
3930 cfg.group_ops_bls12381_uncompressed_g1_sum_max_terms = Some(1200);
3931
3932 cfg.validator_validate_metadata_cost_base = Some(20000);
3933 }
3934 71 => {
3935 cfg.sip_45_consensus_amplification_threshold = Some(5);
3936
3937 cfg.allowed_txn_cost_overage_burst_per_object_in_commit = Some(185_000_000);
3939 }
3940 72 => {
3941 cfg.feature_flags.convert_type_argument_error = true;
3942
3943 cfg.max_tx_gas = Some(50_000_000_000_000);
3946 cfg.max_gas_price = Some(50_000_000_000);
3948
3949 cfg.feature_flags.variant_nodes = true;
3950 }
3951 73 => {
3952 cfg.use_object_per_epoch_marker_table_v2 = Some(true);
3954
3955 if chain != Chain::Mainnet && chain != Chain::Testnet {
3956 cfg.consensus_gc_depth = Some(60);
3959 }
3960
3961 if chain != Chain::Mainnet {
3962 cfg.feature_flags.consensus_zstd_compression = true;
3964 }
3965
3966 cfg.feature_flags.consensus_smart_ancestor_selection = true;
3968 cfg.feature_flags
3970 .consensus_round_prober_probe_accepted_rounds = true;
3971
3972 cfg.feature_flags.per_object_congestion_control_mode =
3974 PerObjectCongestionControlMode::TotalGasBudgetWithCap;
3975 cfg.gas_budget_based_txn_cost_cap_factor = Some(400_000);
3976 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(37_000_000);
3977 cfg.max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit =
3978 Some(7_400_000); cfg.max_txn_cost_overage_per_object_in_commit = Some(u64::MAX);
3980 cfg.gas_budget_based_txn_cost_absolute_cap_commit_count = Some(50);
3981 cfg.allowed_txn_cost_overage_burst_per_object_in_commit = Some(370_000_000);
3982 }
3983 74 => {
3984 if chain != Chain::Mainnet && chain != Chain::Testnet {
3986 cfg.feature_flags.enable_nitro_attestation = true;
3987 }
3988 cfg.nitro_attestation_parse_base_cost = Some(53 * 50);
3989 cfg.nitro_attestation_parse_cost_per_byte = Some(50);
3990 cfg.nitro_attestation_verify_base_cost = Some(49632 * 50);
3991 cfg.nitro_attestation_verify_cost_per_cert = Some(52369 * 50);
3992
3993 cfg.feature_flags.consensus_zstd_compression = true;
3995
3996 if chain != Chain::Mainnet && chain != Chain::Testnet {
3997 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
3998 }
3999 }
4000 75 => {
4001 if chain != Chain::Mainnet {
4002 cfg.feature_flags.passkey_auth = true;
4003 }
4004 }
4005 76 => {
4006 if chain != Chain::Mainnet && chain != Chain::Testnet {
4007 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
4008 cfg.consensus_commit_rate_estimation_window_size = Some(10);
4009 }
4010 cfg.feature_flags.minimize_child_object_mutations = true;
4011
4012 if chain != Chain::Mainnet {
4013 cfg.feature_flags.accept_passkey_in_multisig = true;
4014 }
4015 }
4016 77 => {
4017 cfg.feature_flags.uncompressed_g1_group_elements = true;
4018
4019 if chain != Chain::Mainnet {
4020 cfg.consensus_gc_depth = Some(60);
4021 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
4022 }
4023 }
4024 78 => {
4025 cfg.feature_flags.move_native_context = true;
4026 cfg.tx_context_fresh_id_cost_base = Some(52);
4027 cfg.tx_context_sender_cost_base = Some(30);
4028 cfg.tx_context_epoch_cost_base = Some(30);
4029 cfg.tx_context_epoch_timestamp_ms_cost_base = Some(30);
4030 cfg.tx_context_sponsor_cost_base = Some(30);
4031 cfg.tx_context_gas_price_cost_base = Some(30);
4032 cfg.tx_context_gas_budget_cost_base = Some(30);
4033 cfg.tx_context_ids_created_cost_base = Some(30);
4034 cfg.tx_context_replace_cost_base = Some(30);
4035 cfg.gas_model_version = Some(10);
4036
4037 if chain != Chain::Mainnet {
4038 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
4039 cfg.consensus_commit_rate_estimation_window_size = Some(10);
4040
4041 cfg.feature_flags.per_object_congestion_control_mode =
4043 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4044 ExecutionTimeEstimateParams {
4045 target_utilization: 30,
4046 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4048 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4050 stored_observations_limit: u64::MAX,
4051 stake_weighted_median_threshold: 0,
4052 default_none_duration_for_new_keys: false,
4053 observations_chunk_size: None,
4054 },
4055 );
4056 }
4057 }
4058 79 => {
4059 if chain != Chain::Mainnet {
4060 cfg.feature_flags.consensus_median_based_commit_timestamp = true;
4061
4062 cfg.consensus_bad_nodes_stake_threshold = Some(30);
4065
4066 cfg.feature_flags.consensus_batched_block_sync = true;
4067
4068 cfg.feature_flags.enable_nitro_attestation = true
4070 }
4071 cfg.feature_flags.normalize_ptb_arguments = true;
4072
4073 cfg.consensus_gc_depth = Some(60);
4074 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
4075 }
4076 80 => {
4077 cfg.max_ptb_value_size = Some(1024 * 1024);
4078 }
4079 81 => {
4080 cfg.feature_flags.consensus_median_based_commit_timestamp = true;
4081 cfg.feature_flags.enforce_checkpoint_timestamp_monotonicity = true;
4082 cfg.consensus_bad_nodes_stake_threshold = Some(30)
4083 }
4084 82 => {
4085 cfg.feature_flags.max_ptb_value_size_v2 = true;
4086 }
4087 83 => {
4088 if chain == Chain::Mainnet {
4089 let aliased: [u8; 32] = Hex::decode(
4091 "0x0b2da327ba6a4cacbe75dddd50e6e8bbf81d6496e92d66af9154c61c77f7332f",
4092 )
4093 .unwrap()
4094 .try_into()
4095 .unwrap();
4096
4097 cfg.aliased_addresses.push(AliasedAddress {
4099 original: Hex::decode("0xcd8962dad278d8b50fa0f9eb0186bfa4cbdecc6d59377214c88d0286a0ac9562").unwrap().try_into().unwrap(),
4100 aliased,
4101 allowed_tx_digests: vec![
4102 Base58::decode("B2eGLFoMHgj93Ni8dAJBfqGzo8EWSTLBesZzhEpTPA4").unwrap().try_into().unwrap(),
4103 ],
4104 });
4105
4106 cfg.aliased_addresses.push(AliasedAddress {
4107 original: Hex::decode("0xe28b50cef1d633ea43d3296a3f6b67ff0312a5f1a99f0af753c85b8b5de8ff06").unwrap().try_into().unwrap(),
4108 aliased,
4109 allowed_tx_digests: vec![
4110 Base58::decode("J4QqSAgp7VrQtQpMy5wDX4QGsCSEZu3U5KuDAkbESAge").unwrap().try_into().unwrap(),
4111 ],
4112 });
4113 }
4114
4115 if chain != Chain::Mainnet {
4118 cfg.feature_flags.resolve_type_input_ids_to_defining_id = true;
4119 cfg.transfer_party_transfer_internal_cost_base = Some(52);
4120
4121 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
4123 cfg.consensus_commit_rate_estimation_window_size = Some(10);
4124 cfg.feature_flags.per_object_congestion_control_mode =
4125 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4126 ExecutionTimeEstimateParams {
4127 target_utilization: 30,
4128 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4130 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4132 stored_observations_limit: u64::MAX,
4133 stake_weighted_median_threshold: 0,
4134 default_none_duration_for_new_keys: false,
4135 observations_chunk_size: None,
4136 },
4137 );
4138
4139 cfg.feature_flags.consensus_batched_block_sync = true;
4141
4142 cfg.feature_flags.enable_nitro_attestation_upgraded_parsing = true;
4145 cfg.feature_flags.enable_nitro_attestation = true;
4146 }
4147 }
4148 84 => {
4149 if chain == Chain::Mainnet {
4150 cfg.feature_flags.resolve_type_input_ids_to_defining_id = true;
4151 cfg.transfer_party_transfer_internal_cost_base = Some(52);
4152
4153 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
4155 cfg.consensus_commit_rate_estimation_window_size = Some(10);
4156 cfg.feature_flags.per_object_congestion_control_mode =
4157 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4158 ExecutionTimeEstimateParams {
4159 target_utilization: 30,
4160 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4162 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4164 stored_observations_limit: u64::MAX,
4165 stake_weighted_median_threshold: 0,
4166 default_none_duration_for_new_keys: false,
4167 observations_chunk_size: None,
4168 },
4169 );
4170
4171 cfg.feature_flags.consensus_batched_block_sync = true;
4173
4174 cfg.feature_flags.enable_nitro_attestation_upgraded_parsing = true;
4177 cfg.feature_flags.enable_nitro_attestation = true;
4178 }
4179
4180 cfg.feature_flags.per_object_congestion_control_mode =
4182 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4183 ExecutionTimeEstimateParams {
4184 target_utilization: 30,
4185 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4187 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4189 stored_observations_limit: 20,
4190 stake_weighted_median_threshold: 0,
4191 default_none_duration_for_new_keys: false,
4192 observations_chunk_size: None,
4193 },
4194 );
4195 cfg.feature_flags.allow_unbounded_system_objects = true;
4196 }
4197 85 => {
4198 if chain != Chain::Mainnet && chain != Chain::Testnet {
4199 cfg.feature_flags.enable_party_transfer = true;
4200 }
4201
4202 cfg.feature_flags
4203 .record_consensus_determined_version_assignments_in_prologue_v2 = true;
4204 cfg.feature_flags.disallow_self_identifier = true;
4205 cfg.feature_flags.per_object_congestion_control_mode =
4206 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4207 ExecutionTimeEstimateParams {
4208 target_utilization: 50,
4209 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4211 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4213 stored_observations_limit: 20,
4214 stake_weighted_median_threshold: 0,
4215 default_none_duration_for_new_keys: false,
4216 observations_chunk_size: None,
4217 },
4218 );
4219 }
4220 86 => {
4221 cfg.feature_flags.type_tags_in_object_runtime = true;
4222 cfg.max_move_enum_variants = Some(move_core_types::VARIANT_COUNT_MAX);
4223
4224 cfg.feature_flags.per_object_congestion_control_mode =
4226 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4227 ExecutionTimeEstimateParams {
4228 target_utilization: 50,
4229 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4231 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4233 stored_observations_limit: 20,
4234 stake_weighted_median_threshold: 3334,
4235 default_none_duration_for_new_keys: false,
4236 observations_chunk_size: None,
4237 },
4238 );
4239 if chain != Chain::Mainnet {
4241 cfg.feature_flags.enable_party_transfer = true;
4242 }
4243 }
4244 87 => {
4245 if chain == Chain::Mainnet {
4246 cfg.feature_flags.record_time_estimate_processed = true;
4247 }
4248 cfg.feature_flags.better_adapter_type_resolution_errors = true;
4249 }
4250 88 => {
4251 cfg.feature_flags.record_time_estimate_processed = true;
4252 cfg.tx_context_rgp_cost_base = Some(30);
4253 cfg.feature_flags
4254 .ignore_execution_time_observations_after_certs_closed = true;
4255
4256 cfg.feature_flags.per_object_congestion_control_mode =
4259 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4260 ExecutionTimeEstimateParams {
4261 target_utilization: 50,
4262 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4264 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4266 stored_observations_limit: 20,
4267 stake_weighted_median_threshold: 3334,
4268 default_none_duration_for_new_keys: true,
4269 observations_chunk_size: None,
4270 },
4271 );
4272 }
4273 89 => {
4274 cfg.feature_flags.dependency_linkage_error = true;
4275 cfg.feature_flags.additional_multisig_checks = true;
4276 }
4277 90 => {
4278 cfg.max_gas_price_rgp_factor_for_aborted_transactions = Some(100);
4280 cfg.feature_flags.debug_fatal_on_move_invariant_violation = true;
4281 cfg.feature_flags.additional_consensus_digest_indirect_state = true;
4282 cfg.feature_flags.accept_passkey_in_multisig = true;
4283 cfg.feature_flags.passkey_auth = true;
4284 cfg.feature_flags.check_for_init_during_upgrade = true;
4285
4286 if chain != Chain::Mainnet {
4288 cfg.feature_flags.mysticeti_fastpath = true;
4289 }
4290 }
4291 91 => {
4292 cfg.feature_flags.per_command_shared_object_transfer_rules = true;
4293 }
4294 92 => {
4295 cfg.feature_flags.per_command_shared_object_transfer_rules = false;
4296 }
4297 93 => {
4298 cfg.feature_flags
4299 .consensus_checkpoint_signature_key_includes_digest = true;
4300 }
4301 94 => {
4302 cfg.feature_flags.per_object_congestion_control_mode =
4304 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4305 ExecutionTimeEstimateParams {
4306 target_utilization: 50,
4307 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4309 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4311 stored_observations_limit: 18,
4312 stake_weighted_median_threshold: 3334,
4313 default_none_duration_for_new_keys: true,
4314 observations_chunk_size: None,
4315 },
4316 );
4317
4318 cfg.feature_flags.enable_party_transfer = true;
4320 }
4321 95 => {
4322 cfg.type_name_id_base_cost = Some(52);
4323
4324 cfg.max_transactions_per_checkpoint = Some(20_000);
4326 }
4327 96 => {
4328 if chain != Chain::Mainnet && chain != Chain::Testnet {
4330 cfg.feature_flags
4331 .include_checkpoint_artifacts_digest_in_summary = true;
4332 }
4333 cfg.feature_flags.correct_gas_payment_limit_check = true;
4334 cfg.feature_flags.authority_capabilities_v2 = true;
4335 cfg.feature_flags.use_mfp_txns_in_load_initial_object_debts = true;
4336 cfg.feature_flags.cancel_for_failed_dkg_early = true;
4337 cfg.feature_flags.enable_coin_registry = true;
4338
4339 cfg.feature_flags.mysticeti_fastpath = true;
4341 }
4342 97 => {
4343 cfg.feature_flags.additional_borrow_checks = true;
4344 }
4345 98 => {
4346 cfg.event_emit_auth_stream_cost = Some(52);
4347 cfg.feature_flags.better_loader_errors = true;
4348 cfg.feature_flags.generate_df_type_layouts = true;
4349 }
4350 99 => {
4351 cfg.feature_flags.use_new_commit_handler = true;
4352 }
4353 100 => {
4354 cfg.feature_flags.private_generics_verifier_v2 = true;
4355 }
4356 101 => {
4357 cfg.feature_flags.create_root_accumulator_object = true;
4358 cfg.max_updates_per_settlement_txn = Some(100);
4359 if chain != Chain::Mainnet {
4360 cfg.feature_flags.enable_poseidon = true;
4361 }
4362 }
4363 102 => {
4364 cfg.feature_flags.per_object_congestion_control_mode =
4368 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4369 ExecutionTimeEstimateParams {
4370 target_utilization: 50,
4371 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4373 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4375 stored_observations_limit: 180,
4376 stake_weighted_median_threshold: 3334,
4377 default_none_duration_for_new_keys: true,
4378 observations_chunk_size: Some(18),
4379 },
4380 );
4381 cfg.feature_flags.deprecate_global_storage_ops = true;
4382 }
4383 103 => {}
4384 104 => {
4385 cfg.translation_per_command_base_charge = Some(1);
4386 cfg.translation_per_input_base_charge = Some(1);
4387 cfg.translation_pure_input_per_byte_charge = Some(1);
4388 cfg.translation_per_type_node_charge = Some(1);
4389 cfg.translation_per_reference_node_charge = Some(1);
4390 cfg.translation_per_linkage_entry_charge = Some(10);
4391 cfg.gas_model_version = Some(11);
4392 cfg.feature_flags.abstract_size_in_object_runtime = true;
4393 cfg.feature_flags.object_runtime_charge_cache_load_gas = true;
4394 cfg.dynamic_field_hash_type_and_key_cost_base = Some(52);
4395 cfg.dynamic_field_add_child_object_cost_base = Some(52);
4396 cfg.dynamic_field_add_child_object_value_cost_per_byte = Some(1);
4397 cfg.dynamic_field_borrow_child_object_cost_base = Some(52);
4398 cfg.dynamic_field_borrow_child_object_child_ref_cost_per_byte = Some(1);
4399 cfg.dynamic_field_remove_child_object_cost_base = Some(52);
4400 cfg.dynamic_field_remove_child_object_child_cost_per_byte = Some(1);
4401 cfg.dynamic_field_has_child_object_cost_base = Some(52);
4402 cfg.dynamic_field_has_child_object_with_ty_cost_base = Some(52);
4403 cfg.feature_flags.enable_ptb_execution_v2 = true;
4404
4405 cfg.poseidon_bn254_cost_base = Some(260);
4406
4407 cfg.feature_flags.consensus_skip_gced_accept_votes = true;
4408
4409 if chain != Chain::Mainnet {
4410 cfg.feature_flags
4411 .enable_nitro_attestation_all_nonzero_pcrs_parsing = true;
4412 }
4413
4414 cfg.feature_flags
4415 .include_cancelled_randomness_txns_in_prologue = true;
4416 }
4417 105 => {
4418 cfg.feature_flags.enable_multi_epoch_transaction_expiration = true;
4419 cfg.feature_flags.disable_preconsensus_locking = true;
4420
4421 if chain != Chain::Mainnet {
4422 cfg.feature_flags
4423 .enable_nitro_attestation_always_include_required_pcrs_parsing = true;
4424 }
4425 }
4426 106 => {
4427 cfg.accumulator_object_storage_cost = Some(7600);
4429
4430 if chain != Chain::Mainnet && chain != Chain::Testnet {
4431 cfg.feature_flags.enable_accumulators = true;
4432 cfg.feature_flags.enable_address_balance_gas_payments = true;
4433 cfg.feature_flags.enable_authenticated_event_streams = true;
4434 cfg.feature_flags.enable_object_funds_withdraw = true;
4435 }
4436 }
4437 107 => {
4438 cfg.feature_flags
4439 .consensus_skip_gced_blocks_in_direct_finalization = true;
4440
4441 if in_integration_test() {
4443 cfg.consensus_gc_depth = Some(6);
4444 cfg.consensus_max_num_transactions_in_block = Some(8);
4445 }
4446 }
4447 108 => {
4448 cfg.feature_flags.gas_rounding_halve_digits = true;
4449 cfg.feature_flags.flexible_tx_context_positions = true;
4450 cfg.feature_flags.disable_entry_point_signature_check = true;
4451
4452 if chain != Chain::Mainnet {
4453 cfg.feature_flags.address_aliases = true;
4454
4455 cfg.feature_flags.enable_accumulators = true;
4456 cfg.feature_flags.enable_address_balance_gas_payments = true;
4457 }
4458
4459 cfg.feature_flags.enable_poseidon = true;
4460 }
4461 109 => {
4462 cfg.binary_variant_handles = Some(1024);
4463 cfg.binary_variant_instantiation_handles = Some(1024);
4464 cfg.feature_flags.restrict_hot_or_not_entry_functions = true;
4465 }
4466 110 => {
4467 cfg.feature_flags
4468 .enable_nitro_attestation_all_nonzero_pcrs_parsing = true;
4469 cfg.feature_flags
4470 .enable_nitro_attestation_always_include_required_pcrs_parsing = true;
4471 if chain != Chain::Mainnet && chain != Chain::Testnet {
4472 cfg.feature_flags.split_checkpoints_in_consensus_handler = true;
4473 }
4474 cfg.feature_flags.validate_zklogin_public_identifier = true;
4475 cfg.feature_flags.fix_checkpoint_signature_mapping = true;
4476 cfg.feature_flags
4477 .consensus_always_accept_system_transactions = true;
4478 if chain != Chain::Mainnet {
4479 cfg.feature_flags.enable_object_funds_withdraw = true;
4480 }
4481 }
4482 111 => {
4483 cfg.feature_flags.validator_metadata_verify_v2 = true;
4484 }
4485 112 => {
4486 cfg.group_ops_ristretto_decode_scalar_cost = Some(7);
4487 cfg.group_ops_ristretto_decode_point_cost = Some(200);
4488 cfg.group_ops_ristretto_scalar_add_cost = Some(10);
4489 cfg.group_ops_ristretto_point_add_cost = Some(500);
4490 cfg.group_ops_ristretto_scalar_sub_cost = Some(10);
4491 cfg.group_ops_ristretto_point_sub_cost = Some(500);
4492 cfg.group_ops_ristretto_scalar_mul_cost = Some(11);
4493 cfg.group_ops_ristretto_point_mul_cost = Some(1200);
4494 cfg.group_ops_ristretto_scalar_div_cost = Some(151);
4495 cfg.group_ops_ristretto_point_div_cost = Some(2500);
4496
4497 if chain != Chain::Mainnet && chain != Chain::Testnet {
4498 cfg.feature_flags.enable_ristretto255_group_ops = true;
4499 }
4500 }
4501 113 => {
4502 cfg.feature_flags.address_balance_gas_check_rgp_at_signing = true;
4503 if chain != Chain::Mainnet && chain != Chain::Testnet {
4504 cfg.feature_flags.defer_unpaid_amplification = true;
4505 }
4506 }
4507 114 => {
4508 cfg.feature_flags.randomize_checkpoint_tx_limit_in_tests = true;
4509 cfg.feature_flags.address_balance_gas_reject_gas_coin_arg = true;
4510 if chain != Chain::Mainnet {
4511 cfg.feature_flags.split_checkpoints_in_consensus_handler = true;
4512 cfg.feature_flags.enable_authenticated_event_streams = true;
4513 cfg.feature_flags
4514 .include_checkpoint_artifacts_digest_in_summary = true;
4515 }
4516 }
4517 115 => {
4518 cfg.feature_flags.normalize_depth_formula = true;
4519 }
4520 116 => {
4521 cfg.feature_flags.gasless_transaction_drop_safety = true;
4522 cfg.feature_flags.address_aliases = true;
4523 cfg.feature_flags.relax_valid_during_for_owned_inputs = true;
4524 cfg.feature_flags.defer_unpaid_amplification = false;
4526 cfg.feature_flags.enable_display_registry = true;
4527 }
4528 117 => {}
4529 118 => {
4530 cfg.feature_flags.use_coin_party_owner = true;
4531 }
4532 119 => {
4533 cfg.execution_version = Some(4);
4535 cfg.feature_flags.address_balance_gas_reject_gas_coin_arg = false;
4536 cfg.feature_flags.merge_randomness_into_checkpoint = true;
4537 if chain != Chain::Mainnet {
4538 cfg.feature_flags.enable_gasless = true;
4539 cfg.gasless_max_computation_units = Some(50_000);
4540 cfg.gasless_allowed_token_types = Some(vec![]);
4541 cfg.feature_flags.enable_coin_reservation_obj_refs = true;
4542 cfg.feature_flags
4543 .convert_withdrawal_compatibility_ptb_arguments = true;
4544 }
4545 cfg.gasless_max_unused_inputs = Some(1);
4546 cfg.gasless_max_pure_input_bytes = Some(32);
4547 if chain == Chain::Testnet {
4548 cfg.gasless_allowed_token_types = Some(vec![(TESTNET_USDC.to_string(), 0)]);
4549 }
4550 cfg.transfer_receive_object_cost_per_byte = Some(1);
4551 cfg.transfer_receive_object_type_cost_per_byte = Some(2);
4552 }
4553 120 => {
4554 cfg.feature_flags.disallow_jump_orphans = true;
4555 }
4556 121 => {
4557 if chain != Chain::Mainnet {
4559 cfg.feature_flags.defer_unpaid_amplification = true;
4560 cfg.gasless_max_tps = Some(50);
4561 }
4562 cfg.feature_flags
4563 .early_return_receive_object_mismatched_type = true;
4564 }
4565 122 => {
4566 cfg.feature_flags.defer_unpaid_amplification = true;
4568 cfg.verify_bulletproofs_ristretto255_base_cost = Some(30000);
4570 cfg.verify_bulletproofs_ristretto255_cost_per_bit_and_commitment = Some(6500);
4571 if chain != Chain::Mainnet && chain != Chain::Testnet {
4572 cfg.feature_flags.enable_verify_bulletproofs_ristretto255 = true;
4573 }
4574 cfg.feature_flags.gasless_verify_remaining_balance = true;
4575 cfg.include_special_package_amendments = match chain {
4576 Chain::Mainnet => Some(MAINNET_LINKAGE_AMENDMENTS.clone()),
4577 Chain::Testnet => Some(TESTNET_LINKAGE_AMENDMENTS.clone()),
4578 Chain::Unknown => None,
4579 };
4580 cfg.gasless_max_tx_size_bytes = Some(16 * 1024);
4581 cfg.gasless_max_tps = Some(300);
4582 cfg.gasless_max_computation_units = Some(5_000);
4583 }
4584 123 => {
4585 cfg.gas_model_version = Some(13);
4586 }
4587 124 => {
4588 if chain != Chain::Mainnet && chain != Chain::Testnet {
4589 cfg.feature_flags.timestamp_based_epoch_close = true;
4590 }
4591 cfg.gas_model_version = Some(14);
4592 cfg.feature_flags.limit_groth16_pvk_inputs = true;
4593
4594 cfg.feature_flags.enable_accumulators = true;
4600 cfg.feature_flags.enable_address_balance_gas_payments = true;
4601 cfg.feature_flags.enable_authenticated_event_streams = true;
4602 cfg.feature_flags.enable_coin_reservation_obj_refs = true;
4603 cfg.feature_flags.enable_object_funds_withdraw = true;
4604 cfg.feature_flags
4605 .convert_withdrawal_compatibility_ptb_arguments = true;
4606 cfg.feature_flags.split_checkpoints_in_consensus_handler = true;
4607 cfg.feature_flags
4608 .include_checkpoint_artifacts_digest_in_summary = true;
4609 cfg.feature_flags.enable_gasless = true;
4610
4611 if chain == Chain::Mainnet {
4616 cfg.gasless_allowed_token_types = Some(vec![
4617 (MAINNET_USDC.to_string(), 10_000),
4618 (MAINNET_USDSUI.to_string(), 10_000),
4619 (MAINNET_SUI_USDE.to_string(), 10_000),
4620 (MAINNET_USDY.to_string(), 10_000),
4621 (MAINNET_FDUSD.to_string(), 10_000),
4622 (MAINNET_AUSD.to_string(), 10_000),
4623 (MAINNET_USDB.to_string(), 10_000),
4624 ]);
4625 }
4626 }
4627 125 => {
4628 cfg.feature_flags.granular_post_execution_checks = true;
4629 if chain != Chain::Mainnet {
4630 cfg.feature_flags.timestamp_based_epoch_close = true;
4631 }
4632 }
4633 126 => {
4634 cfg.feature_flags.early_exit_on_iffw = true;
4635 }
4636 127 => {
4637 cfg.feature_flags.always_advance_dkg_to_resolution = true;
4638
4639 cfg.verify_bulletproofs_ristretto255_base_cost = Some(23866);
4640 cfg.verify_bulletproofs_ristretto255_cost_per_bit_and_commitment = Some(1324);
4641 cfg.group_ops_ristretto_decode_scalar_cost = Some(5);
4642 cfg.group_ops_ristretto_decode_point_cost = Some(216);
4643 cfg.group_ops_ristretto_scalar_add_cost = Some(2);
4644 cfg.group_ops_ristretto_point_add_cost = Some(8);
4645 cfg.group_ops_ristretto_scalar_sub_cost = Some(2);
4646 cfg.group_ops_ristretto_point_sub_cost = Some(8);
4647 cfg.group_ops_ristretto_scalar_mul_cost = Some(5);
4648 cfg.group_ops_ristretto_point_mul_cost = Some(1763);
4649 cfg.group_ops_ristretto_scalar_div_cost = Some(557);
4650 cfg.group_ops_ristretto_point_div_cost = Some(2244);
4651
4652 if chain != Chain::Mainnet {
4653 cfg.feature_flags.enable_ristretto255_group_ops = true;
4654 cfg.feature_flags.enable_verify_bulletproofs_ristretto255 = true;
4655 }
4656
4657 cfg.feature_flags.timestamp_based_epoch_close = true;
4658 }
4659 128 => {
4660 cfg.max_generic_instantiation_type_nodes_per_function = Some(10_000);
4661 cfg.max_generic_instantiation_type_nodes_per_module = Some(500_000);
4662 cfg.binary_enum_defs = Some(200);
4663 cfg.binary_enum_def_instantiations = Some(100);
4664 }
4665 129 => {
4666 cfg.feature_flags.enable_unified_linkage = true;
4667 }
4668 130 => {
4669 cfg.feature_flags.record_net_unsettled_object_withdraws = true;
4670 cfg.feature_flags.enable_init_on_upgrade = true;
4671 cfg.epoch_close_deadline_ms = Some(120_000);
4672 cfg.scratch_add_cost_base = Some(13);
4673 cfg.scratch_read_cost_base = Some(13);
4674 cfg.scratch_read_value_cost = Some(1);
4675 cfg.scratch_remove_cost_base = Some(13);
4676 cfg.scratch_exists_cost_base = Some(13);
4677 cfg.scratch_exists_with_type_cost_base = Some(13);
4678 cfg.scratch_exists_with_type_type_cost = Some(1);
4679 let max_commands = cfg.max_programmable_tx_commands() as u64;
4680 cfg.max_scratch_pad_size = Some(16 * max_commands);
4681 if chain != Chain::Mainnet && chain != Chain::Testnet {
4683 cfg.feature_flags.zklogin_circuit_mode = 1;
4684 }
4685 }
4686 131 => {
4687 cfg.feature_flags.share_transaction_deny_config_in_consensus = true;
4688 cfg.feature_flags.framework_tx_context_mut_restrictions = true;
4689 }
4690 132 => {
4691 if chain != Chain::Mainnet && chain != Chain::Testnet {
4692 cfg.feature_flags.defer_owned_object_double_spend = true;
4693 cfg.feature_flags.create_forwarding_address_registry = true;
4694 }
4695 cfg.object_record_new_uid_from_hash_cost_base = Some(1);
4696 cfg.feature_flags
4697 .enable_order_independent_upgrade_init_linkage = true;
4698 }
4699 133 => {
4700 cfg.feature_flags
4701 .include_function_signatures_in_instantiation_limits = true;
4702 cfg.max_accumulator_type_nodes = Some(16);
4703 }
4704 134 => {
4705 if chain != Chain::Mainnet {
4712 cfg.package_original_package_id_impl_cost_base = Some(52);
4713 let package_read_cost_per_byte = cfg.obj_access_cost_read_per_byte();
4714 cfg.package_original_package_id_impl_cost_per_byte =
4715 Some(package_read_cost_per_byte);
4716
4717 cfg.consensus_max_transactions_in_block_bytes = Some(288 * 1024);
4718 cfg.consensus_max_num_transactions_in_block = Some(128);
4719 }
4720
4721 if chain == Chain::Mainnet {
4722 cfg.feature_flags.defer_unpaid_amplification = false;
4723 }
4724 }
4725 135 => {
4726 cfg.package_original_package_id_impl_cost_base = Some(52);
4729 let package_read_cost_per_byte = cfg.obj_access_cost_read_per_byte();
4730 cfg.package_original_package_id_impl_cost_per_byte =
4731 Some(package_read_cost_per_byte);
4732
4733 cfg.consensus_max_transactions_in_block_bytes = Some(288 * 1024);
4734 cfg.consensus_max_num_transactions_in_block = Some(128);
4735
4736 cfg.feature_flags.defer_unpaid_amplification = false;
4737 }
4738 136 => {
4739 cfg.feature_flags.ptb_tx_context_restrictions = true;
4740
4741 cfg.translation_per_live_reference_charge = Some(1);
4742 cfg.max_ptb_live_references = Some(64);
4743 cfg.max_ptb_returned_references = Some(16);
4744 cfg.max_ptb_total_returned_references = Some(256);
4745
4746 if chain != Chain::Mainnet && chain != Chain::Testnet {
4747 cfg.feature_flags.allowed_proposers = true;
4748 }
4749 cfg.feature_flags.harden_linkage_consistency = true;
4750
4751 cfg.package_arena_size_in_bytes = Some(10_000_000);
4752 }
4753 137 => {
4754 cfg.verify_bulletproofs_ristretto255_cost_per_bit_and_commitment = Some(621);
4755 cfg.max_bulletproofs_total_bits = Some(1024);
4756
4757 cfg.feature_flags.enable_allowances = true;
4758 cfg.feature_flags.fix_ptb_generated_reads = true;
4759 cfg.feature_flags.charge_ld_const_abstract_size = true;
4760 if chain != Chain::Mainnet && chain != Chain::Testnet {
4761 cfg.feature_flags.check_object_funds_withdraw_in_execution = true;
4762 }
4763 cfg.reserve_object_funds_for_withdrawal_cost_base = Some(52);
4764 cfg.reserve_object_funds_for_withdrawal_cold_read_cost = Some(184);
4767
4768 cfg.feature_flags.allowed_proposers = true;
4769
4770 cfg.feature_flags.validate_ptb_argument_indices = true;
4771 cfg.feature_flags.memory_safety_invariant_check_v2 = true;
4772 }
4773 138 => {
4774 cfg.gas_model_version = Some(15);
4775 }
4776 _ => panic!("unsupported version {:?}", version),
4787 }
4788 }
4789
4790 cfg
4791 }
4792
4793 pub fn apply_seeded_test_overrides(&mut self, seed: &[u8; 32]) {
4794 if !self.feature_flags.randomize_checkpoint_tx_limit_in_tests
4795 || !self.feature_flags.split_checkpoints_in_consensus_handler
4796 {
4797 return;
4798 }
4799
4800 if !mysten_common::in_test_configuration() {
4801 return;
4802 }
4803
4804 use rand::{Rng, SeedableRng, rngs::StdRng};
4805 let mut rng = StdRng::from_seed(*seed);
4806 let max_txns = rng.gen_range(10..=100u64);
4807 info!("seeded test override: max_transactions_per_checkpoint = {max_txns}");
4808 self.max_transactions_per_checkpoint = Some(max_txns);
4809 }
4810
4811 pub fn verifier_config(&self, signing_limits: Option<(usize, usize, usize)>) -> VerifierConfig {
4817 let (
4818 max_back_edges_per_function,
4819 max_back_edges_per_module,
4820 sanity_check_with_regex_reference_safety,
4821 ) = if let Some((
4822 max_back_edges_per_function,
4823 max_back_edges_per_module,
4824 sanity_check_with_regex_reference_safety,
4825 )) = signing_limits
4826 {
4827 (
4828 Some(max_back_edges_per_function),
4829 Some(max_back_edges_per_module),
4830 Some(sanity_check_with_regex_reference_safety),
4831 )
4832 } else {
4833 (None, None, None)
4834 };
4835
4836 let additional_borrow_checks = if signing_limits.is_some() {
4837 true
4839 } else {
4840 self.additional_borrow_checks()
4841 };
4842 let deprecate_global_storage_ops = if signing_limits.is_some() {
4843 true
4845 } else {
4846 self.deprecate_global_storage_ops()
4847 };
4848
4849 VerifierConfig {
4850 max_loop_depth: Some(self.max_loop_depth() as usize),
4851 max_generic_instantiation_length: Some(self.max_generic_instantiation_length() as usize),
4852 max_function_parameters: Some(self.max_function_parameters() as usize),
4853 max_basic_blocks: Some(self.max_basic_blocks() as usize),
4854 max_value_stack_size: self.max_value_stack_size() as usize,
4855 max_type_nodes: Some(self.max_type_nodes() as usize),
4856 max_generic_instantiation_type_nodes_per_function: self
4857 .max_generic_instantiation_type_nodes_per_function_as_option()
4858 .map(|v| v as usize),
4859 max_generic_instantiation_type_nodes_per_module: self
4860 .max_generic_instantiation_type_nodes_per_module_as_option()
4861 .map(|v| v as usize),
4862 include_function_signatures_in_instantiation_limits: self
4863 .include_function_signatures_in_instantiation_limits(),
4864 max_push_size: Some(self.max_push_size() as usize),
4865 max_dependency_depth: Some(self.max_dependency_depth() as usize),
4866 max_fields_in_struct: Some(self.max_fields_in_struct() as usize),
4867 max_function_definitions: Some(self.max_function_definitions() as usize),
4868 max_data_definitions: Some(self.max_struct_definitions() as usize),
4869 max_constant_vector_len: Some(self.max_move_vector_len()),
4870 max_back_edges_per_function,
4871 max_back_edges_per_module,
4872 max_basic_blocks_in_script: None,
4873 max_identifier_len: self.max_move_identifier_len_as_option(), disallow_self_identifier: self.feature_flags.disallow_self_identifier,
4875 allow_receiving_object_id: self.allow_receiving_object_id(),
4876 reject_mutable_random_on_entry_functions: self
4877 .reject_mutable_random_on_entry_functions(),
4878 bytecode_version: self.move_binary_format_version(),
4879 max_variants_in_enum: self.max_move_enum_variants_as_option(),
4880 additional_borrow_checks,
4881 better_loader_errors: self.better_loader_errors(),
4882 private_generics_verifier_v2: self.private_generics_verifier_v2(),
4883 sanity_check_with_regex_reference_safety: sanity_check_with_regex_reference_safety
4884 .map(|limit| limit as u128),
4885 deprecate_global_storage_ops,
4886 disable_entry_point_signature_check: self.disable_entry_point_signature_check(),
4887 switch_to_regex_reference_safety: false,
4888 framework_tx_context_mut_restrictions: self.framework_tx_context_mut_restrictions(),
4889 disallow_jump_orphans: self.disallow_jump_orphans(),
4890 }
4891 }
4892
4893 pub fn binary_config(
4894 &self,
4895 override_deprecate_global_storage_ops_during_deserialization: Option<bool>,
4896 ) -> BinaryConfig {
4897 let deprecate_global_storage_ops =
4898 override_deprecate_global_storage_ops_during_deserialization
4899 .unwrap_or_else(|| self.deprecate_global_storage_ops());
4900 BinaryConfig::new(
4901 self.move_binary_format_version(),
4902 self.min_move_binary_format_version_as_option()
4903 .unwrap_or(VERSION_1),
4904 self.no_extraneous_module_bytes(),
4905 deprecate_global_storage_ops,
4906 TableConfig {
4907 module_handles: self.binary_module_handles_as_option().unwrap_or(u16::MAX),
4908 datatype_handles: self.binary_struct_handles_as_option().unwrap_or(u16::MAX),
4909 function_handles: self.binary_function_handles_as_option().unwrap_or(u16::MAX),
4910 function_instantiations: self
4911 .binary_function_instantiations_as_option()
4912 .unwrap_or(u16::MAX),
4913 signatures: self.binary_signatures_as_option().unwrap_or(u16::MAX),
4914 constant_pool: self.binary_constant_pool_as_option().unwrap_or(u16::MAX),
4915 identifiers: self.binary_identifiers_as_option().unwrap_or(u16::MAX),
4916 address_identifiers: self
4917 .binary_address_identifiers_as_option()
4918 .unwrap_or(u16::MAX),
4919 struct_defs: self.binary_struct_defs_as_option().unwrap_or(u16::MAX),
4920 struct_def_instantiations: self
4921 .binary_struct_def_instantiations_as_option()
4922 .unwrap_or(u16::MAX),
4923 function_defs: self.binary_function_defs_as_option().unwrap_or(u16::MAX),
4924 field_handles: self.binary_field_handles_as_option().unwrap_or(u16::MAX),
4925 field_instantiations: self
4926 .binary_field_instantiations_as_option()
4927 .unwrap_or(u16::MAX),
4928 friend_decls: self.binary_friend_decls_as_option().unwrap_or(u16::MAX),
4929 enum_defs: self.binary_enum_defs_as_option().unwrap_or(u16::MAX),
4930 enum_def_instantiations: self
4931 .binary_enum_def_instantiations_as_option()
4932 .unwrap_or(u16::MAX),
4933 variant_handles: self.binary_variant_handles_as_option().unwrap_or(u16::MAX),
4934 variant_instantiation_handles: self
4935 .binary_variant_instantiation_handles_as_option()
4936 .unwrap_or(u16::MAX),
4937 },
4938 )
4939 }
4940
4941 pub fn apply_overrides_for_testing(
4945 override_fn: impl Fn(ProtocolVersion, Self) -> Self + Send + Sync + 'static,
4946 ) -> OverrideGuard {
4947 let mut cur = CONFIG_OVERRIDE.lock().unwrap();
4948 assert!(cur.is_none(), "config override already present");
4949 *cur = Some(Box::new(override_fn));
4950 OverrideGuard
4951 }
4952
4953 fn apply_config_override(version: ProtocolVersion, mut ret: Self) -> Self {
4954 if let Some(override_fn) = CONFIG_OVERRIDE.lock().unwrap().as_ref() {
4955 warn!(
4956 "overriding ProtocolConfig settings with custom settings (you should not see this log outside of tests)"
4957 );
4958 ret = override_fn(version, ret);
4959 }
4960 ret
4961 }
4962}
4963
4964impl ProtocolConfig {
4968 pub fn set_execution_version_for_testing(&mut self, val: u64) {
4972 let current = self.execution_version.unwrap_or(0);
4973 assert!(
4974 val >= current,
4975 "cannot downgrade execution_version from {current} to {val}: running an old \
4976 executor against a newer protocol config/framework is unsupported. To test \
4977 frozen executor behavior, start from the last protocol version of that executor \
4978 instead, so genesis loads the matching framework snapshot (see \
4979 test_address_balance_gas_v3_accumulator_sign)."
4980 );
4981 self.execution_version = Some(val);
4982 }
4983
4984 pub fn set_zklogin_circuit_mode_for_testing(&mut self, val: u64) {
4987 self.feature_flags.zklogin_circuit_mode = val
4988 }
4989
4990 pub fn set_per_object_congestion_control_mode_for_testing(
4991 &mut self,
4992 val: PerObjectCongestionControlMode,
4993 ) {
4994 self.feature_flags.per_object_congestion_control_mode = val;
4995 }
4996
4997 pub fn set_consensus_choice_for_testing(&mut self, val: ConsensusChoice) {
4998 self.feature_flags.consensus_choice = val;
4999 }
5000
5001 pub fn set_consensus_network_for_testing(&mut self, val: ConsensusNetwork) {
5002 self.feature_flags.consensus_network = val;
5003 }
5004
5005 pub fn set_zklogin_max_epoch_upper_bound_delta_for_testing(&mut self, val: Option<u64>) {
5006 self.feature_flags.zklogin_max_epoch_upper_bound_delta = val
5007 }
5008
5009 pub fn set_mysticeti_num_leaders_per_round_for_testing(&mut self, val: Option<usize>) {
5010 self.feature_flags.mysticeti_num_leaders_per_round = val;
5011 }
5012
5013 pub fn disable_accumulators_for_testing(&mut self) {
5014 self.feature_flags.enable_accumulators = false;
5015 self.feature_flags.enable_address_balance_gas_payments = false;
5016 }
5017
5018 pub fn enable_coin_reservation_for_testing(&mut self) {
5019 self.feature_flags.enable_coin_reservation_obj_refs = true;
5020 self.feature_flags
5021 .convert_withdrawal_compatibility_ptb_arguments = true;
5022 self.execution_version = Some(self.execution_version.map_or(4, |v| v.max(4)));
5025 }
5026
5027 pub fn disable_coin_reservation_for_testing(&mut self) {
5028 self.feature_flags.enable_coin_reservation_obj_refs = false;
5029 self.feature_flags
5030 .convert_withdrawal_compatibility_ptb_arguments = false;
5031 }
5032
5033 pub fn enable_address_balance_gas_payments_for_testing(&mut self) {
5034 self.feature_flags.enable_accumulators = true;
5035 self.feature_flags.allow_private_accumulator_entrypoints = true;
5036 self.feature_flags.enable_address_balance_gas_payments = true;
5037 self.feature_flags.address_balance_gas_check_rgp_at_signing = true;
5038 self.feature_flags.address_balance_gas_reject_gas_coin_arg = false;
5039 self.execution_version = Some(self.execution_version.map_or(4, |v| v.max(4)))
5040 }
5041
5042 pub fn enable_gasless_for_testing(&mut self) {
5043 self.enable_address_balance_gas_payments_for_testing();
5044 self.feature_flags.enable_gasless = true;
5045 self.feature_flags.gasless_verify_remaining_balance = true;
5046 self.gasless_max_computation_units = Some(5_000);
5047 self.gasless_allowed_token_types = Some(vec![]);
5048 self.gasless_max_tps = Some(1000);
5049 self.gasless_max_tx_size_bytes = Some(16 * 1024);
5050 }
5051
5052 pub fn disable_gasless_for_testing(&mut self) {
5053 self.feature_flags.enable_gasless = false;
5054 self.gasless_max_computation_units = None;
5055 self.gasless_allowed_token_types = None;
5056 }
5057
5058 pub fn enable_authenticated_event_streams_for_testing(&mut self) {
5059 self.feature_flags.enable_accumulators = true;
5060 self.feature_flags.enable_authenticated_event_streams = true;
5061 self.feature_flags
5062 .include_checkpoint_artifacts_digest_in_summary = true;
5063 self.feature_flags.split_checkpoints_in_consensus_handler = true;
5064 }
5065}
5066
5067type OverrideFn = dyn Fn(ProtocolVersion, ProtocolConfig) -> ProtocolConfig + Send + Sync;
5068
5069static CONFIG_OVERRIDE: Mutex<Option<Box<OverrideFn>>> = Mutex::new(None);
5070
5071#[must_use]
5072pub struct OverrideGuard;
5073
5074impl Drop for OverrideGuard {
5075 fn drop(&mut self) {
5076 info!("restoring override fn");
5077 *CONFIG_OVERRIDE.lock().unwrap() = None;
5078 }
5079}
5080
5081#[derive(PartialEq, Eq)]
5084pub enum LimitThresholdCrossed {
5085 None,
5086 Soft(u128, u128),
5087 Hard(u128, u128),
5088}
5089
5090pub fn check_limit_in_range<T: Into<V>, U: Into<V>, V: PartialOrd + Into<u128>>(
5093 x: T,
5094 soft_limit: U,
5095 hard_limit: V,
5096) -> LimitThresholdCrossed {
5097 let x: V = x.into();
5098 let soft_limit: V = soft_limit.into();
5099
5100 debug_assert!(soft_limit <= hard_limit);
5101
5102 if x >= hard_limit {
5105 LimitThresholdCrossed::Hard(x.into(), hard_limit.into())
5106 } else if x < soft_limit {
5107 LimitThresholdCrossed::None
5108 } else {
5109 LimitThresholdCrossed::Soft(x.into(), soft_limit.into())
5110 }
5111}
5112
5113#[macro_export]
5114macro_rules! check_limit {
5115 ($x:expr, $hard:expr) => {
5116 check_limit!($x, $hard, $hard)
5117 };
5118 ($x:expr, $soft:expr, $hard:expr) => {
5119 check_limit_in_range($x as u64, $soft, $hard)
5120 };
5121}
5122
5123#[macro_export]
5127macro_rules! check_limit_by_meter {
5128 ($is_metered:expr, $x:expr, $metered_limit:expr, $unmetered_hard_limit:expr, $metric:expr) => {{
5129 let (h, metered_str) = if $is_metered {
5131 ($metered_limit, "metered")
5132 } else {
5133 ($unmetered_hard_limit, "unmetered")
5135 };
5136 use sui_protocol_config::check_limit_in_range;
5137 let result = check_limit_in_range($x as u64, $metered_limit, h);
5138 match result {
5139 LimitThresholdCrossed::None => {}
5140 LimitThresholdCrossed::Soft(_, _) => {
5141 $metric.with_label_values(&[metered_str, "soft"]).inc();
5142 }
5143 LimitThresholdCrossed::Hard(_, _) => {
5144 $metric.with_label_values(&[metered_str, "hard"]).inc();
5145 }
5146 };
5147 result
5148 }};
5149}
5150
5151pub type Amendments = BTreeMap<AccountAddress, BTreeMap<AccountAddress, AccountAddress>>;
5154
5155static MAINNET_LINKAGE_AMENDMENTS: LazyLock<Arc<Amendments>> =
5156 LazyLock::new(|| parse_amendments(include_str!("mainnet_amendments.json")));
5157
5158static TESTNET_LINKAGE_AMENDMENTS: LazyLock<Arc<Amendments>> =
5159 LazyLock::new(|| parse_amendments(include_str!("testnet_amendments.json")));
5160
5161fn parse_amendments(json: &str) -> Arc<Amendments> {
5162 #[derive(serde::Deserialize)]
5163 struct AmendmentEntry {
5164 root: String,
5165 deps: Vec<DepEntry>,
5166 }
5167
5168 #[derive(serde::Deserialize)]
5169 struct DepEntry {
5170 original_id: String,
5171 version_id: String,
5172 }
5173
5174 let entries: Vec<AmendmentEntry> =
5175 serde_json::from_str(json).expect("Failed to parse amendments JSON");
5176 let mut amendments = BTreeMap::new();
5177 for entry in entries {
5178 let root_id = AccountAddress::from_hex_literal(&entry.root).unwrap();
5179 let mut dep_ids = BTreeMap::new();
5180 for dep in entry.deps {
5181 let orig_id = AccountAddress::from_hex_literal(&dep.original_id).unwrap();
5182 let upgraded_id = AccountAddress::from_hex_literal(&dep.version_id).unwrap();
5183 assert!(
5184 dep_ids.insert(orig_id, upgraded_id).is_none(),
5185 "Duplicate original ID in amendments table"
5186 );
5187 }
5188 assert!(
5189 amendments.insert(root_id, dep_ids).is_none(),
5190 "Duplicate root ID in amendments table"
5191 );
5192 }
5193 Arc::new(amendments)
5194}
5195
5196#[cfg(all(test, not(msim)))]
5197mod test {
5198 use insta::assert_yaml_snapshot;
5199
5200 use super::*;
5201
5202 #[test]
5203 fn snapshot_tests() {
5204 println!("\n============================================================================");
5205 println!("! !");
5206 println!("! IMPORTANT: never update snapshots from this test. only add new versions! !");
5207 println!("! !");
5208 println!("============================================================================\n");
5209 for chain_id in &[Chain::Unknown, Chain::Mainnet, Chain::Testnet] {
5210 let chain_str = match chain_id {
5214 Chain::Unknown => "".to_string(),
5215 _ => format!("{:?}_", chain_id),
5216 };
5217 for i in MIN_PROTOCOL_VERSION..=MAX_PROTOCOL_VERSION {
5218 let cur = ProtocolVersion::new(i);
5219 assert_yaml_snapshot!(
5220 format!("{}version_{}", chain_str, cur.as_u64()),
5221 ProtocolConfig::get_for_version(cur, *chain_id)
5222 );
5223 }
5224 }
5225 }
5226
5227 #[test]
5228 fn test_getters() {
5229 let prot: ProtocolConfig =
5230 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5231 assert_eq!(
5232 prot.max_arguments(),
5233 prot.max_arguments_as_option().unwrap()
5234 );
5235 }
5236
5237 #[test]
5238 fn test_setters() {
5239 let mut prot: ProtocolConfig =
5240 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5241 prot.set_max_arguments_for_testing(123);
5242 assert_eq!(prot.max_arguments(), 123);
5243
5244 prot.set_max_arguments_from_str_for_testing("321".to_string());
5245 assert_eq!(prot.max_arguments(), 321);
5246
5247 prot.disable_max_arguments_for_testing();
5248 assert_eq!(prot.max_arguments_as_option(), None);
5249
5250 prot.set_attr_for_testing("max_arguments".to_string(), "456".to_string());
5251 assert_eq!(prot.max_arguments(), 456);
5252 }
5253
5254 #[test]
5255 fn test_execution_version_setter_allows_upgrade() {
5256 let mut prot = ProtocolConfig::get_for_max_version_UNSAFE();
5257 let current = prot.execution_version();
5258 prot.set_execution_version_for_testing(current);
5259 prot.set_execution_version_for_testing(current + 1);
5260 assert_eq!(prot.execution_version(), current + 1);
5261 }
5262
5263 #[test]
5264 #[should_panic(expected = "cannot downgrade execution_version")]
5265 fn test_execution_version_setter_panics_on_downgrade() {
5266 let mut prot = ProtocolConfig::get_for_max_version_UNSAFE();
5267 let current = prot.execution_version();
5268 prot.set_execution_version_for_testing(current - 1);
5269 }
5270
5271 #[test]
5272 fn test_feature_flag_setter_by_string() {
5273 let mut prot: ProtocolConfig =
5274 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5275 assert!(!prot.zklogin_auth());
5276 prot.set_feature_flag_for_testing("zklogin_auth".to_string(), true);
5277 assert!(prot.zklogin_auth());
5278 prot.set_feature_flag_for_testing("zklogin_auth".to_string(), false);
5279 assert!(!prot.zklogin_auth());
5280 }
5281
5282 #[test]
5283 #[should_panic(expected = "unknown feature flag")]
5284 fn test_feature_flag_setter_unknown_flag() {
5285 let mut prot: ProtocolConfig =
5286 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5287 prot.set_feature_flag_for_testing("some random string".to_string(), true);
5288 }
5289
5290 #[test]
5291 fn test_get_for_version_if_supported_applies_test_overrides() {
5292 let before =
5293 ProtocolConfig::get_for_version_if_supported(ProtocolVersion::new(1), Chain::Unknown)
5294 .unwrap();
5295
5296 assert!(!before.enable_coin_reservation_obj_refs());
5297
5298 let _guard = ProtocolConfig::apply_overrides_for_testing(|_, mut cfg| {
5299 cfg.enable_coin_reservation_for_testing();
5300 cfg
5301 });
5302
5303 let after =
5304 ProtocolConfig::get_for_version_if_supported(ProtocolVersion::new(1), Chain::Unknown)
5305 .unwrap();
5306
5307 assert!(after.enable_coin_reservation_obj_refs());
5308 }
5309
5310 #[test]
5311 #[should_panic(expected = "unsupported version")]
5312 fn max_version_test() {
5313 let _ = ProtocolConfig::get_for_version_impl(
5316 ProtocolVersion::new(MAX_PROTOCOL_VERSION + 1),
5317 Chain::Unknown,
5318 );
5319 }
5320
5321 #[test]
5322 fn lookup_by_string_test() {
5323 let prot: ProtocolConfig =
5324 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5325 assert!(prot.lookup_attr("some random string".to_string()).is_none());
5327
5328 assert!(
5329 prot.lookup_attr("max_arguments".to_string())
5330 == Some(ProtocolConfigValue::u32(prot.max_arguments())),
5331 );
5332
5333 assert!(
5335 prot.lookup_attr("max_move_identifier_len".to_string())
5336 .is_none()
5337 );
5338
5339 let prot: ProtocolConfig =
5341 ProtocolConfig::get_for_version(ProtocolVersion::new(9), Chain::Unknown);
5342 assert!(
5343 prot.lookup_attr("max_move_identifier_len".to_string())
5344 == Some(ProtocolConfigValue::u64(prot.max_move_identifier_len()))
5345 );
5346
5347 let prot: ProtocolConfig =
5348 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5349 assert!(
5351 prot.attr_map()
5352 .get("max_move_identifier_len")
5353 .unwrap()
5354 .is_none()
5355 );
5356 assert!(
5358 prot.attr_map().get("max_arguments").unwrap()
5359 == &Some(ProtocolConfigValue::u32(prot.max_arguments()))
5360 );
5361
5362 let prot: ProtocolConfig =
5364 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5365 assert!(
5367 prot.feature_flags
5368 .lookup_attr("some random string".to_owned())
5369 .is_none()
5370 );
5371 assert!(
5372 !prot
5373 .feature_flags
5374 .attr_map()
5375 .contains_key("some random string")
5376 );
5377
5378 assert!(
5380 prot.feature_flags
5381 .lookup_attr("package_upgrades".to_owned())
5382 == Some(false)
5383 );
5384 assert!(
5385 prot.feature_flags
5386 .attr_map()
5387 .get("package_upgrades")
5388 .unwrap()
5389 == &false
5390 );
5391 let prot: ProtocolConfig =
5392 ProtocolConfig::get_for_version(ProtocolVersion::new(4), Chain::Unknown);
5393 assert!(
5395 prot.feature_flags
5396 .lookup_attr("package_upgrades".to_owned())
5397 == Some(true)
5398 );
5399 assert!(
5400 prot.feature_flags
5401 .attr_map()
5402 .get("package_upgrades")
5403 .unwrap()
5404 == &true
5405 );
5406 }
5407
5408 #[test]
5409 fn limit_range_fn_test() {
5410 let low = 100u32;
5411 let high = 10000u64;
5412
5413 assert!(check_limit!(1u8, low, high) == LimitThresholdCrossed::None);
5414 assert!(matches!(
5415 check_limit!(255u16, low, high),
5416 LimitThresholdCrossed::Soft(255u128, 100)
5417 ));
5418 assert!(matches!(
5424 check_limit!(2550000u64, low, high),
5425 LimitThresholdCrossed::Hard(2550000, 10000)
5426 ));
5427
5428 assert!(matches!(
5429 check_limit!(2550000u64, high, high),
5430 LimitThresholdCrossed::Hard(2550000, 10000)
5431 ));
5432
5433 assert!(matches!(
5434 check_limit!(1u8, high),
5435 LimitThresholdCrossed::None
5436 ));
5437
5438 assert!(check_limit!(255u16, high) == LimitThresholdCrossed::None);
5439
5440 assert!(matches!(
5441 check_limit!(2550000u64, high),
5442 LimitThresholdCrossed::Hard(2550000, 10000)
5443 ));
5444 }
5445
5446 #[test]
5447 fn linkage_amendments_load() {
5448 let mainnet = LazyLock::force(&MAINNET_LINKAGE_AMENDMENTS);
5449 let testnet = LazyLock::force(&TESTNET_LINKAGE_AMENDMENTS);
5450 assert!(!mainnet.is_empty(), "mainnet amendments must not be empty");
5451 assert!(!testnet.is_empty(), "testnet amendments must not be empty");
5452 }
5453
5454 #[test]
5455 fn render_scalar_fields_use_precision_safe_encoding() {
5456 use mysten_common::rpc_format::Unmetered;
5457
5458 let config = ProtocolConfig::get_for_max_version_UNSAFE();
5459 let rendered = config
5460 .render::<serde_json::Value>(&mut Unmetered)
5461 .expect("render should succeed");
5462
5463 let max_args = rendered
5464 .get("max_arguments")
5465 .expect("max_arguments set at max version");
5466 assert!(
5467 max_args.is_number(),
5468 "u32 should render as number, got {max_args:?}",
5469 );
5470
5471 let max_tx_size = rendered
5472 .get("max_tx_size_bytes")
5473 .expect("max_tx_size_bytes set at max version");
5474 assert!(
5475 max_tx_size.is_string(),
5476 "u64 should render as string, got {max_tx_size:?}",
5477 );
5478 }
5479
5480 #[test]
5481 fn render_includes_non_scalar_gasless_allowlist_as_json() {
5482 use mysten_common::rpc_format::Unmetered;
5483 use serde_json::json;
5484
5485 let mut config = ProtocolConfig::get_for_max_version_UNSAFE();
5486 config.set_gasless_allowed_token_types_for_testing(vec![
5487 ("0xa::usdc::USDC".to_string(), 10_000),
5488 ("0xb::usdt::USDT".to_string(), 0),
5489 ]);
5490
5491 let rendered = config
5492 .render::<serde_json::Value>(&mut Unmetered)
5493 .expect("render should succeed under Unmetered budget");
5494 let allowlist = rendered
5495 .get("gasless_allowed_token_types")
5496 .expect("entry should be present after the testing setter");
5497
5498 assert_eq!(
5501 allowlist,
5502 &json!([["0xa::usdc::USDC", "10000"], ["0xb::usdt::USDT", "0"],]),
5503 );
5504 }
5505
5506 #[test]
5507 fn render_targets_prost_value_for_grpc() {
5508 use mysten_common::rpc_format::Unmetered;
5509 use prost_types::value::Kind;
5510
5511 let mut config = ProtocolConfig::get_for_max_version_UNSAFE();
5512 config.set_gasless_allowed_token_types_for_testing(vec![(
5513 "0xa::usdc::USDC".to_string(),
5514 10_000,
5515 )]);
5516
5517 let rendered = config
5518 .render::<prost_types::Value>(&mut Unmetered)
5519 .expect("render to prost Value should succeed");
5520 let allowlist = rendered
5521 .get("gasless_allowed_token_types")
5522 .expect("entry should be present after the testing setter");
5523
5524 let Some(Kind::ListValue(outer)) = &allowlist.kind else {
5526 panic!(
5527 "expected ListValue at the top level, got {:?}",
5528 allowlist.kind
5529 );
5530 };
5531 assert_eq!(outer.values.len(), 1, "one allowlisted entry");
5532 let Some(Kind::ListValue(entry)) = &outer.values[0].kind else {
5533 panic!("expected each entry to be a ListValue");
5534 };
5535 assert_eq!(entry.values.len(), 2, "entry has (coin_type, amount)");
5536
5537 let Some(Kind::StringValue(coin_type)) = &entry.values[0].kind else {
5538 panic!("expected coin_type as StringValue");
5539 };
5540 assert_eq!(coin_type, "0xa::usdc::USDC");
5541
5542 let Some(Kind::StringValue(amount)) = &entry.values[1].kind else {
5544 panic!(
5545 "expected minimum_transfer_amount as StringValue (precision-safe u64); got {:?}",
5546 entry.values[1].kind,
5547 );
5548 };
5549 assert_eq!(amount, "10000");
5550 }
5551
5552 #[test]
5553 fn render_emits_null_for_unset_protocol_versions() {
5554 use mysten_common::rpc_format::Unmetered;
5555
5556 let config = ProtocolConfig::get_for_version(1.into(), Chain::Unknown);
5557 let rendered = config
5558 .render::<serde_json::Value>(&mut Unmetered)
5559 .expect("render should succeed");
5560 let entry = rendered
5564 .get("gasless_allowed_token_types")
5565 .expect("key should be present for every protocol version");
5566 assert!(
5567 entry.is_null(),
5568 "value should be null for pre-feature protocol version, got {entry:?}",
5569 );
5570 }
5571}