1use std::{
5 collections::{BTreeMap, BTreeSet},
6 sync::{
7 Arc, LazyLock,
8 atomic::{AtomicBool, Ordering},
9 },
10};
11
12#[cfg(msim)]
13use std::cell::RefCell;
14#[cfg(not(msim))]
15use std::sync::Mutex;
16
17use clap::*;
18use fastcrypto::encoding::{Base58, Encoding, Hex};
19use move_binary_format::{
20 binary_config::{BinaryConfig, TableConfig},
21 file_format_common::VERSION_1,
22};
23use move_core_types::account_address::AccountAddress;
24use move_vm_config::verifier::VerifierConfig;
25use mysten_common::in_integration_test;
26use serde::{Deserialize, Serialize};
27use serde_with::skip_serializing_none;
28use sui_protocol_config_macros::{
29 ProtocolConfigAccessors, ProtocolConfigFeatureFlagsGetters, ProtocolConfigOverride,
30};
31use tracing::{info, warn};
32
33const MIN_PROTOCOL_VERSION: u64 = 1;
35const MAX_PROTOCOL_VERSION: u64 = 132;
36
37const TESTNET_USDC: &str =
38 "0xa1ec7fc00a6f40db9693ad1415d0c193ad3906494428cf252621037bd7117e29::usdc::USDC";
39
40const MAINNET_USDC: &str =
41 "0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC";
42const MAINNET_USDSUI: &str =
43 "0x44f838219cf67b058f3b37907b655f226153c18e33dfcd0da559a844fea9b1c1::usdsui::USDSUI";
44const MAINNET_SUI_USDE: &str =
45 "0x41d587e5336f1c86cad50d38a7136db99333bb9bda91cea4ba69115defeb1402::sui_usde::SUI_USDE";
46const MAINNET_USDY: &str =
47 "0x960b531667636f39e85867775f52f6b1f220a058c4de786905bdf761e06a56bb::usdy::USDY";
48const MAINNET_FDUSD: &str =
49 "0xf16e6b723f242ec745dfd7634ad072c42d5c1d9ac9d62a39c381303eaa57693a::fdusd::FDUSD";
50const MAINNET_AUSD: &str =
51 "0x2053d08c1e2bd02791056171aab0fd12bd7cd7efad2ab8f6b9c8902f14df2ff2::ausd::AUSD";
52const MAINNET_USDB: &str =
53 "0xe14726c336e81b32328e92afc37345d159f5b550b09fa92bd43640cfdd0a0cfd::usdb::USDB";
54
55#[derive(Copy, Clone, Debug, Hash, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)]
379pub struct ProtocolVersion(u64);
380
381impl ProtocolVersion {
382 pub const MIN: Self = Self(MIN_PROTOCOL_VERSION);
387
388 pub const MAX: Self = Self(MAX_PROTOCOL_VERSION);
389
390 #[cfg(not(msim))]
391 pub const MAX_ALLOWED: Self = Self::MAX;
392
393 #[cfg(msim)]
395 pub const MAX_ALLOWED: Self = Self(MAX_PROTOCOL_VERSION + 1);
396
397 pub fn new(v: u64) -> Self {
398 Self(v)
399 }
400
401 pub const fn as_u64(&self) -> u64 {
402 self.0
403 }
404
405 pub fn max() -> Self {
408 Self::MAX
409 }
410
411 pub fn prev(self) -> Self {
412 Self(self.0.checked_sub(1).unwrap())
413 }
414}
415
416impl From<u64> for ProtocolVersion {
417 fn from(v: u64) -> Self {
418 Self::new(v)
419 }
420}
421
422impl std::ops::Sub<u64> for ProtocolVersion {
423 type Output = Self;
424 fn sub(self, rhs: u64) -> Self::Output {
425 Self::new(self.0 - rhs)
426 }
427}
428
429impl std::ops::Add<u64> for ProtocolVersion {
430 type Output = Self;
431 fn add(self, rhs: u64) -> Self::Output {
432 Self::new(self.0 + rhs)
433 }
434}
435
436#[derive(
437 Clone, Serialize, Deserialize, Debug, Default, PartialEq, Copy, PartialOrd, Ord, Eq, ValueEnum,
438)]
439pub enum Chain {
440 Mainnet,
441 Testnet,
442 #[default]
443 Unknown,
444}
445
446impl Chain {
447 pub fn as_str(self) -> &'static str {
448 match self {
449 Chain::Mainnet => "mainnet",
450 Chain::Testnet => "testnet",
451 Chain::Unknown => "unknown",
452 }
453 }
454}
455
456pub struct Error(pub String);
457
458#[derive(Default, Clone, Serialize, Deserialize, Debug, ProtocolConfigFeatureFlagsGetters)]
461struct FeatureFlags {
462 #[serde(skip_serializing_if = "is_false")]
465 package_upgrades: bool,
466 #[serde(skip_serializing_if = "is_false")]
469 commit_root_state_digest: bool,
470 #[serde(skip_serializing_if = "is_false")]
472 advance_epoch_start_time_in_safe_mode: bool,
473 #[serde(skip_serializing_if = "is_false")]
476 loaded_child_objects_fixed: bool,
477 #[serde(skip_serializing_if = "is_false")]
480 missing_type_is_compatibility_error: bool,
481 #[serde(skip_serializing_if = "is_false")]
484 scoring_decision_with_validity_cutoff: bool,
485
486 #[serde(skip_serializing_if = "is_false")]
489 consensus_order_end_of_epoch_last: bool,
490
491 #[serde(skip_serializing_if = "is_false")]
493 disallow_adding_abilities_on_upgrade: bool,
494 #[serde(skip_serializing_if = "is_false")]
496 disable_invariant_violation_check_in_swap_loc: bool,
497 #[serde(skip_serializing_if = "is_false")]
500 advance_to_highest_supported_protocol_version: bool,
501 #[serde(skip_serializing_if = "is_false")]
503 ban_entry_init: bool,
504 #[serde(skip_serializing_if = "is_false")]
506 package_digest_hash_module: bool,
507 #[serde(skip_serializing_if = "is_false")]
509 disallow_change_struct_type_params_on_upgrade: bool,
510 #[serde(skip_serializing_if = "is_false")]
512 no_extraneous_module_bytes: bool,
513 #[serde(skip_serializing_if = "is_false")]
515 narwhal_versioned_metadata: bool,
516
517 #[serde(skip_serializing_if = "is_false")]
519 zklogin_auth: bool,
520 #[serde(skip_serializing_if = "is_zero")]
523 zklogin_circuit_mode: u64,
524 #[serde(skip_serializing_if = "ConsensusTransactionOrdering::is_none")]
526 consensus_transaction_ordering: ConsensusTransactionOrdering,
527
528 #[serde(skip_serializing_if = "is_false")]
536 simplified_unwrap_then_delete: bool,
537 #[serde(skip_serializing_if = "is_false")]
539 upgraded_multisig_supported: bool,
540 #[serde(skip_serializing_if = "is_false")]
542 txn_base_cost_as_multiplier: bool,
543
544 #[serde(skip_serializing_if = "is_false")]
546 shared_object_deletion: bool,
547
548 #[serde(skip_serializing_if = "is_false")]
550 narwhal_new_leader_election_schedule: bool,
551
552 #[serde(skip_serializing_if = "is_empty")]
554 zklogin_supported_providers: BTreeSet<String>,
555
556 #[serde(skip_serializing_if = "is_false")]
558 loaded_child_object_format: bool,
559
560 #[serde(skip_serializing_if = "is_false")]
561 #[skip_protocol_config_accessor]
562 enable_jwk_consensus_updates: bool,
563
564 #[serde(skip_serializing_if = "is_false")]
565 #[skip_protocol_config_accessor]
566 end_of_epoch_transaction_supported: bool,
567
568 #[serde(skip_serializing_if = "is_false")]
571 simple_conservation_checks: bool,
572
573 #[serde(skip_serializing_if = "is_false")]
575 loaded_child_object_format_type: bool,
576
577 #[serde(skip_serializing_if = "is_false")]
579 receive_objects: bool,
580
581 #[serde(skip_serializing_if = "is_false")]
583 consensus_checkpoint_signature_key_includes_digest: bool,
584
585 #[serde(skip_serializing_if = "is_false")]
587 random_beacon: bool,
588
589 #[serde(skip_serializing_if = "is_false")]
591 #[skip_protocol_config_accessor]
592 bridge: bool,
593
594 #[serde(skip_serializing_if = "is_false")]
595 enable_effects_v2: bool,
596
597 #[serde(skip_serializing_if = "is_false")]
599 narwhal_certificate_v2: bool,
600
601 #[serde(skip_serializing_if = "is_false")]
603 verify_legacy_zklogin_address: bool,
604
605 #[serde(skip_serializing_if = "is_false")]
607 throughput_aware_consensus_submission: bool,
608
609 #[serde(skip_serializing_if = "is_false")]
611 recompute_has_public_transfer_in_execution: bool,
612
613 #[serde(skip_serializing_if = "is_false")]
615 accept_zklogin_in_multisig: bool,
616
617 #[serde(skip_serializing_if = "is_false")]
619 accept_passkey_in_multisig: bool,
620
621 #[serde(skip_serializing_if = "is_false")]
623 validate_zklogin_public_identifier: bool,
624
625 #[serde(skip_serializing_if = "is_false")]
628 include_consensus_digest_in_prologue: bool,
629
630 #[serde(skip_serializing_if = "is_false")]
632 hardened_otw_check: bool,
633
634 #[serde(skip_serializing_if = "is_false")]
636 allow_receiving_object_id: bool,
637
638 #[serde(skip_serializing_if = "is_false")]
640 enable_poseidon: bool,
641
642 #[serde(skip_serializing_if = "is_false")]
644 enable_coin_deny_list: bool,
645
646 #[serde(skip_serializing_if = "is_false")]
648 enable_group_ops_native_functions: bool,
649
650 #[serde(skip_serializing_if = "is_false")]
652 enable_group_ops_native_function_msm: bool,
653
654 #[serde(skip_serializing_if = "is_false")]
656 enable_ristretto255_group_ops: bool,
657
658 #[serde(skip_serializing_if = "is_false")]
660 enable_verify_bulletproofs_ristretto255: bool,
661
662 #[serde(skip_serializing_if = "is_false")]
664 enable_nitro_attestation: bool,
665
666 #[serde(skip_serializing_if = "is_false")]
668 enable_nitro_attestation_upgraded_parsing: bool,
669
670 #[serde(skip_serializing_if = "is_false")]
672 enable_nitro_attestation_all_nonzero_pcrs_parsing: bool,
673
674 #[serde(skip_serializing_if = "is_false")]
676 enable_nitro_attestation_always_include_required_pcrs_parsing: bool,
677
678 #[serde(skip_serializing_if = "is_false")]
680 reject_mutable_random_on_entry_functions: bool,
681
682 #[serde(skip_serializing_if = "PerObjectCongestionControlMode::is_none")]
684 per_object_congestion_control_mode: PerObjectCongestionControlMode,
685
686 #[serde(skip_serializing_if = "ConsensusChoice::is_narwhal")]
688 consensus_choice: ConsensusChoice,
689
690 #[serde(skip_serializing_if = "ConsensusNetwork::is_anemo")]
692 consensus_network: ConsensusNetwork,
693
694 #[serde(skip_serializing_if = "is_false")]
696 correct_gas_payment_limit_check: bool,
697
698 #[serde(skip_serializing_if = "Option::is_none")]
700 zklogin_max_epoch_upper_bound_delta: Option<u64>,
701
702 #[serde(skip_serializing_if = "is_false")]
704 mysticeti_leader_scoring_and_schedule: bool,
705
706 #[serde(skip_serializing_if = "is_false")]
708 reshare_at_same_initial_version: bool,
709
710 #[serde(skip_serializing_if = "is_false")]
712 resolve_abort_locations_to_package_id: bool,
713
714 #[serde(skip_serializing_if = "is_false")]
718 mysticeti_use_committed_subdag_digest: bool,
719
720 #[serde(skip_serializing_if = "is_false")]
722 enable_vdf: bool,
723
724 #[serde(skip_serializing_if = "is_false")]
728 record_consensus_determined_version_assignments_in_prologue: bool,
729 #[serde(skip_serializing_if = "is_false")]
732 record_consensus_determined_version_assignments_in_prologue_v2: bool,
733
734 #[serde(skip_serializing_if = "is_false")]
736 fresh_vm_on_framework_upgrade: bool,
737
738 #[serde(skip_serializing_if = "is_false")]
746 prepend_prologue_tx_in_consensus_commit_in_checkpoints: bool,
747
748 #[serde(skip_serializing_if = "Option::is_none")]
750 mysticeti_num_leaders_per_round: Option<usize>,
751
752 #[serde(skip_serializing_if = "is_false")]
754 soft_bundle: bool,
755
756 #[serde(skip_serializing_if = "is_false")]
758 enable_coin_deny_list_v2: bool,
759
760 #[serde(skip_serializing_if = "is_false")]
762 passkey_auth: bool,
763
764 #[serde(skip_serializing_if = "is_false")]
766 authority_capabilities_v2: bool,
767
768 #[serde(skip_serializing_if = "is_false")]
770 rethrow_serialization_type_layout_errors: bool,
771
772 #[serde(skip_serializing_if = "is_false")]
774 consensus_distributed_vote_scoring_strategy: bool,
775
776 #[serde(skip_serializing_if = "is_false")]
778 consensus_round_prober: bool,
779
780 #[serde(skip_serializing_if = "is_false")]
782 validate_identifier_inputs: bool,
783
784 #[serde(skip_serializing_if = "is_false")]
786 disallow_self_identifier: bool,
787
788 #[serde(skip_serializing_if = "is_false")]
790 mysticeti_fastpath: bool,
791
792 #[serde(skip_serializing_if = "is_false")]
796 disable_preconsensus_locking: bool,
797
798 #[serde(skip_serializing_if = "is_false")]
800 relocate_event_module: bool,
801
802 #[serde(skip_serializing_if = "is_false")]
804 uncompressed_g1_group_elements: bool,
805
806 #[serde(skip_serializing_if = "is_false")]
807 disallow_new_modules_in_deps_only_packages: bool,
808
809 #[serde(skip_serializing_if = "is_false")]
811 consensus_smart_ancestor_selection: bool,
812
813 #[serde(skip_serializing_if = "is_false")]
815 consensus_round_prober_probe_accepted_rounds: bool,
816
817 #[serde(skip_serializing_if = "is_false")]
819 native_charging_v2: bool,
820
821 #[serde(skip_serializing_if = "is_false")]
824 #[skip_protocol_config_accessor]
825 consensus_linearize_subdag_v2: bool,
826
827 #[serde(skip_serializing_if = "is_false")]
829 convert_type_argument_error: bool,
830
831 #[serde(skip_serializing_if = "is_false")]
833 variant_nodes: bool,
834
835 #[serde(skip_serializing_if = "is_false")]
837 consensus_zstd_compression: bool,
838
839 #[serde(skip_serializing_if = "is_false")]
841 minimize_child_object_mutations: bool,
842
843 #[serde(skip_serializing_if = "is_false")]
846 record_additional_state_digest_in_prologue: bool,
847
848 #[serde(skip_serializing_if = "is_false")]
850 move_native_context: bool,
851
852 #[serde(skip_serializing_if = "is_false")]
855 #[skip_protocol_config_accessor]
856 consensus_median_based_commit_timestamp: bool,
857
858 #[serde(skip_serializing_if = "is_false")]
861 normalize_ptb_arguments: bool,
862
863 #[serde(skip_serializing_if = "is_false")]
865 consensus_batched_block_sync: bool,
866
867 #[serde(skip_serializing_if = "is_false")]
869 enforce_checkpoint_timestamp_monotonicity: bool,
870
871 #[serde(skip_serializing_if = "is_false")]
873 max_ptb_value_size_v2: bool,
874
875 #[serde(skip_serializing_if = "is_false")]
877 resolve_type_input_ids_to_defining_id: bool,
878
879 #[serde(skip_serializing_if = "is_false")]
881 enable_party_transfer: bool,
882
883 #[serde(skip_serializing_if = "is_false")]
885 allow_unbounded_system_objects: bool,
886
887 #[serde(skip_serializing_if = "is_false")]
889 type_tags_in_object_runtime: bool,
890
891 #[serde(skip_serializing_if = "is_false")]
893 enable_accumulators: bool,
894
895 #[serde(skip_serializing_if = "is_false")]
897 #[skip_protocol_config_accessor]
898 enable_coin_reservation_obj_refs: bool,
899
900 #[serde(skip_serializing_if = "is_false")]
903 create_root_accumulator_object: bool,
904
905 #[serde(skip_serializing_if = "is_false")]
907 #[skip_protocol_config_accessor]
908 enable_authenticated_event_streams: bool,
909
910 #[serde(skip_serializing_if = "is_false")]
912 enable_address_balance_gas_payments: bool,
913
914 #[serde(skip_serializing_if = "is_false")]
916 address_balance_gas_check_rgp_at_signing: bool,
917
918 #[serde(skip_serializing_if = "is_false")]
919 address_balance_gas_reject_gas_coin_arg: bool,
920
921 #[serde(skip_serializing_if = "is_false")]
923 enable_multi_epoch_transaction_expiration: bool,
924
925 #[serde(skip_serializing_if = "is_false")]
927 relax_valid_during_for_owned_inputs: bool,
928
929 #[serde(skip_serializing_if = "is_false")]
931 enable_ptb_execution_v2: bool,
932
933 #[serde(skip_serializing_if = "is_false")]
935 better_adapter_type_resolution_errors: bool,
936
937 #[serde(skip_serializing_if = "is_false")]
939 record_time_estimate_processed: bool,
940
941 #[serde(skip_serializing_if = "is_false")]
943 dependency_linkage_error: bool,
944
945 #[serde(skip_serializing_if = "is_false")]
947 additional_multisig_checks: bool,
948
949 #[serde(skip_serializing_if = "is_false")]
951 ignore_execution_time_observations_after_certs_closed: bool,
952
953 #[serde(skip_serializing_if = "is_false")]
957 debug_fatal_on_move_invariant_violation: bool,
958
959 #[serde(skip_serializing_if = "is_false")]
962 allow_private_accumulator_entrypoints: bool,
963
964 #[serde(skip_serializing_if = "is_false")]
967 additional_consensus_digest_indirect_state: bool,
968
969 #[serde(skip_serializing_if = "is_false")]
971 check_for_init_during_upgrade: bool,
972
973 #[serde(skip_serializing_if = "is_false")]
975 enable_init_on_upgrade: bool,
976
977 #[serde(skip_serializing_if = "is_false")]
979 per_command_shared_object_transfer_rules: bool,
980
981 #[serde(skip_serializing_if = "is_false")]
983 include_checkpoint_artifacts_digest_in_summary: bool,
984
985 #[serde(skip_serializing_if = "is_false")]
987 use_mfp_txns_in_load_initial_object_debts: bool,
988
989 #[serde(skip_serializing_if = "is_false")]
991 cancel_for_failed_dkg_early: bool,
992
993 #[serde(skip_serializing_if = "is_false")]
995 always_advance_dkg_to_resolution: bool,
996
997 #[serde(skip_serializing_if = "is_false")]
999 enable_coin_registry: bool,
1000
1001 #[serde(skip_serializing_if = "is_false")]
1003 abstract_size_in_object_runtime: bool,
1004
1005 #[serde(skip_serializing_if = "is_false")]
1007 object_runtime_charge_cache_load_gas: bool,
1008
1009 #[serde(skip_serializing_if = "is_false")]
1011 additional_borrow_checks: bool,
1012
1013 #[serde(skip_serializing_if = "is_false")]
1015 use_new_commit_handler: bool,
1016
1017 #[serde(skip_serializing_if = "is_false")]
1019 better_loader_errors: bool,
1020
1021 #[serde(skip_serializing_if = "is_false")]
1023 generate_df_type_layouts: bool,
1024
1025 #[serde(skip_serializing_if = "is_false")]
1027 allow_references_in_ptbs: bool,
1028
1029 #[serde(skip_serializing_if = "is_false")]
1036 framework_tx_context_mut_restrictions: bool,
1037
1038 #[serde(skip_serializing_if = "is_false")]
1040 enable_display_registry: bool,
1041
1042 #[serde(skip_serializing_if = "is_false")]
1044 private_generics_verifier_v2: bool,
1045
1046 #[serde(skip_serializing_if = "is_false")]
1048 deprecate_global_storage_ops_during_deserialization: bool,
1049
1050 #[serde(skip_serializing_if = "is_false")]
1053 enable_non_exclusive_writes: bool,
1054
1055 #[serde(skip_serializing_if = "is_false")]
1057 deprecate_global_storage_ops: bool,
1058
1059 #[serde(skip_serializing_if = "is_false")]
1061 normalize_depth_formula: bool,
1062
1063 #[serde(skip_serializing_if = "is_false")]
1065 consensus_skip_gced_accept_votes: bool,
1066
1067 #[serde(skip_serializing_if = "is_false")]
1070 include_cancelled_randomness_txns_in_prologue: bool,
1071
1072 #[serde(skip_serializing_if = "is_false")]
1074 #[skip_protocol_config_accessor]
1075 address_aliases: bool,
1076
1077 #[serde(skip_serializing_if = "is_false")]
1080 fix_checkpoint_signature_mapping: bool,
1081
1082 #[serde(skip_serializing_if = "is_false")]
1084 enable_object_funds_withdraw: bool,
1085
1086 #[serde(skip_serializing_if = "is_false")]
1089 record_net_unsettled_object_withdraws: bool,
1090
1091 #[serde(skip_serializing_if = "is_false")]
1093 consensus_skip_gced_blocks_in_direct_finalization: bool,
1094
1095 #[serde(skip_serializing_if = "is_false")]
1097 gas_rounding_halve_digits: bool,
1098
1099 #[serde(skip_serializing_if = "is_false")]
1101 flexible_tx_context_positions: bool,
1102
1103 #[serde(skip_serializing_if = "is_false")]
1105 disable_entry_point_signature_check: bool,
1106
1107 #[serde(skip_serializing_if = "is_false")]
1109 convert_withdrawal_compatibility_ptb_arguments: bool,
1110
1111 #[serde(skip_serializing_if = "is_false")]
1113 restrict_hot_or_not_entry_functions: bool,
1114
1115 #[serde(skip_serializing_if = "is_false")]
1117 split_checkpoints_in_consensus_handler: bool,
1118
1119 #[serde(skip_serializing_if = "is_false")]
1121 consensus_always_accept_system_transactions: bool,
1122
1123 #[serde(skip_serializing_if = "is_false")]
1125 validator_metadata_verify_v2: bool,
1126
1127 #[serde(skip_serializing_if = "is_false")]
1130 defer_unpaid_amplification: bool,
1131
1132 #[serde(skip_serializing_if = "is_false")]
1135 defer_owned_object_double_spend: bool,
1136
1137 #[serde(skip_serializing_if = "is_false")]
1138 randomize_checkpoint_tx_limit_in_tests: bool,
1139
1140 #[serde(skip_serializing_if = "is_false")]
1142 gasless_transaction_drop_safety: bool,
1143
1144 #[serde(skip_serializing_if = "is_false")]
1147 merge_randomness_into_checkpoint: bool,
1148
1149 #[serde(skip_serializing_if = "is_false")]
1151 use_coin_party_owner: bool,
1152
1153 #[serde(skip_serializing_if = "is_false")]
1154 enable_gasless: bool,
1155
1156 #[serde(skip_serializing_if = "is_false")]
1157 gasless_verify_remaining_balance: bool,
1158
1159 #[serde(skip_serializing_if = "is_false")]
1160 disallow_jump_orphans: bool,
1161
1162 #[serde(skip_serializing_if = "is_false")]
1164 early_return_receive_object_mismatched_type: bool,
1165
1166 #[serde(skip_serializing_if = "is_false")]
1171 timestamp_based_epoch_close: bool,
1172
1173 #[serde(skip_serializing_if = "is_false")]
1176 limit_groth16_pvk_inputs: bool,
1177
1178 #[serde(skip_serializing_if = "is_false")]
1183 enforce_address_balance_change_invariant: bool,
1184
1185 #[serde(skip_serializing_if = "is_false")]
1187 share_transaction_deny_config_in_consensus: bool,
1188
1189 #[serde(skip_serializing_if = "is_false")]
1191 granular_post_execution_checks: bool,
1192
1193 #[serde(skip_serializing_if = "is_false")]
1195 early_exit_on_iffw: bool,
1196
1197 #[serde(skip_serializing_if = "is_false")]
1199 enable_unified_linkage: bool,
1200}
1201
1202fn is_false(b: &bool) -> bool {
1203 !b
1204}
1205
1206fn is_empty(b: &BTreeSet<String>) -> bool {
1207 b.is_empty()
1208}
1209
1210fn is_zero(val: &u64) -> bool {
1211 *val == 0
1212}
1213
1214#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1216pub enum ConsensusTransactionOrdering {
1217 #[default]
1219 None,
1220 ByGasPrice,
1222}
1223
1224impl ConsensusTransactionOrdering {
1225 pub fn is_none(&self) -> bool {
1226 matches!(self, ConsensusTransactionOrdering::None)
1227 }
1228}
1229
1230#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1231pub struct ExecutionTimeEstimateParams {
1232 pub target_utilization: u64,
1234 pub allowed_txn_cost_overage_burst_limit_us: u64,
1238
1239 pub randomness_scalar: u64,
1242
1243 pub max_estimate_us: u64,
1245
1246 pub stored_observations_num_included_checkpoints: u64,
1249
1250 pub stored_observations_limit: u64,
1252
1253 #[serde(skip_serializing_if = "is_zero")]
1256 pub stake_weighted_median_threshold: u64,
1257
1258 #[serde(skip_serializing_if = "is_false")]
1262 pub default_none_duration_for_new_keys: bool,
1263
1264 #[serde(skip_serializing_if = "Option::is_none")]
1266 pub observations_chunk_size: Option<u64>,
1267}
1268
1269#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1271pub enum PerObjectCongestionControlMode {
1272 #[default]
1273 None, TotalGasBudget, TotalTxCount, TotalGasBudgetWithCap, ExecutionTimeEstimate(ExecutionTimeEstimateParams), }
1279
1280impl PerObjectCongestionControlMode {
1281 pub fn is_none(&self) -> bool {
1282 matches!(self, PerObjectCongestionControlMode::None)
1283 }
1284}
1285
1286#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1288pub enum ConsensusChoice {
1289 #[default]
1290 Narwhal,
1291 SwapEachEpoch,
1292 Mysticeti,
1293}
1294
1295impl ConsensusChoice {
1296 pub fn is_narwhal(&self) -> bool {
1297 matches!(self, ConsensusChoice::Narwhal)
1298 }
1299}
1300
1301#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1303pub enum ConsensusNetwork {
1304 #[default]
1305 Anemo,
1306 Tonic,
1307}
1308
1309impl ConsensusNetwork {
1310 pub fn is_anemo(&self) -> bool {
1311 matches!(self, ConsensusNetwork::Anemo)
1312 }
1313}
1314
1315#[skip_serializing_none]
1347#[derive(Clone, Serialize, Debug, ProtocolConfigAccessors, ProtocolConfigOverride)]
1348pub struct ProtocolConfig {
1349 pub version: ProtocolVersion,
1350
1351 #[serde(skip)]
1356 chain: Chain,
1357
1358 feature_flags: FeatureFlags,
1359
1360 max_tx_size_bytes: Option<u64>,
1363
1364 max_input_objects: Option<u64>,
1366
1367 max_size_written_objects: Option<u64>,
1371 max_size_written_objects_system_tx: Option<u64>,
1374
1375 max_serialized_tx_effects_size_bytes: Option<u64>,
1377
1378 max_serialized_tx_effects_size_bytes_system_tx: Option<u64>,
1380
1381 max_gas_payment_objects: Option<u32>,
1383
1384 max_modules_in_publish: Option<u32>,
1386
1387 max_package_dependencies: Option<u32>,
1389
1390 max_arguments: Option<u32>,
1393
1394 max_type_arguments: Option<u32>,
1396
1397 max_type_argument_depth: Option<u32>,
1399
1400 max_pure_argument_size: Option<u32>,
1402
1403 max_programmable_tx_commands: Option<u32>,
1405
1406 move_binary_format_version: Option<u32>,
1409 min_move_binary_format_version: Option<u32>,
1410
1411 binary_module_handles: Option<u16>,
1413 binary_struct_handles: Option<u16>,
1414 binary_function_handles: Option<u16>,
1415 binary_function_instantiations: Option<u16>,
1416 binary_signatures: Option<u16>,
1417 binary_constant_pool: Option<u16>,
1418 binary_identifiers: Option<u16>,
1419 binary_address_identifiers: Option<u16>,
1420 binary_struct_defs: Option<u16>,
1421 binary_struct_def_instantiations: Option<u16>,
1422 binary_function_defs: Option<u16>,
1423 binary_field_handles: Option<u16>,
1424 binary_field_instantiations: Option<u16>,
1425 binary_friend_decls: Option<u16>,
1426 binary_enum_defs: Option<u16>,
1427 binary_enum_def_instantiations: Option<u16>,
1428 binary_variant_handles: Option<u16>,
1429 binary_variant_instantiation_handles: Option<u16>,
1430
1431 max_move_object_size: Option<u64>,
1433
1434 max_move_package_size: Option<u64>,
1437
1438 max_publish_or_upgrade_per_ptb: Option<u64>,
1440
1441 max_tx_gas: Option<u64>,
1443
1444 max_gas_price: Option<u64>,
1446
1447 max_gas_price_rgp_factor_for_aborted_transactions: Option<u64>,
1450
1451 max_gas_computation_bucket: Option<u64>,
1453
1454 gas_rounding_step: Option<u64>,
1456
1457 max_loop_depth: Option<u64>,
1459
1460 max_generic_instantiation_length: Option<u64>,
1462
1463 max_function_parameters: Option<u64>,
1465
1466 max_basic_blocks: Option<u64>,
1468
1469 max_value_stack_size: Option<u64>,
1471
1472 max_type_nodes: Option<u64>,
1474
1475 max_generic_instantiation_type_nodes_per_function: Option<u64>,
1477
1478 max_generic_instantiation_type_nodes_per_module: Option<u64>,
1480
1481 max_push_size: Option<u64>,
1483
1484 max_struct_definitions: Option<u64>,
1486
1487 max_function_definitions: Option<u64>,
1489
1490 max_fields_in_struct: Option<u64>,
1492
1493 max_dependency_depth: Option<u64>,
1495
1496 max_num_event_emit: Option<u64>,
1498
1499 max_num_new_move_object_ids: Option<u64>,
1501
1502 max_num_new_move_object_ids_system_tx: Option<u64>,
1504
1505 max_num_deleted_move_object_ids: Option<u64>,
1507
1508 max_num_deleted_move_object_ids_system_tx: Option<u64>,
1510
1511 max_num_transferred_move_object_ids: Option<u64>,
1513
1514 max_num_transferred_move_object_ids_system_tx: Option<u64>,
1516
1517 max_event_emit_size: Option<u64>,
1519
1520 max_event_emit_size_total: Option<u64>,
1522
1523 max_move_vector_len: Option<u64>,
1525
1526 max_move_identifier_len: Option<u64>,
1528
1529 max_move_value_depth: Option<u64>,
1531
1532 max_move_enum_variants: Option<u64>,
1534
1535 max_back_edges_per_function: Option<u64>,
1537
1538 max_back_edges_per_module: Option<u64>,
1540
1541 max_verifier_meter_ticks_per_function: Option<u64>,
1543
1544 max_meter_ticks_per_module: Option<u64>,
1546
1547 max_meter_ticks_per_package: Option<u64>,
1549
1550 object_runtime_max_num_cached_objects: Option<u64>,
1554
1555 object_runtime_max_num_cached_objects_system_tx: Option<u64>,
1557
1558 object_runtime_max_num_store_entries: Option<u64>,
1560
1561 object_runtime_max_num_store_entries_system_tx: Option<u64>,
1563
1564 base_tx_cost_fixed: Option<u64>,
1567
1568 package_publish_cost_fixed: Option<u64>,
1571
1572 base_tx_cost_per_byte: Option<u64>,
1575
1576 package_publish_cost_per_byte: Option<u64>,
1578
1579 obj_access_cost_read_per_byte: Option<u64>,
1581
1582 obj_access_cost_mutate_per_byte: Option<u64>,
1584
1585 obj_access_cost_delete_per_byte: Option<u64>,
1587
1588 obj_access_cost_verify_per_byte: Option<u64>,
1598
1599 max_type_to_layout_nodes: Option<u64>,
1601
1602 max_ptb_value_size: Option<u64>,
1604
1605 gas_model_version: Option<u64>,
1608
1609 obj_data_cost_refundable: Option<u64>,
1612
1613 obj_metadata_cost_non_refundable: Option<u64>,
1617
1618 storage_rebate_rate: Option<u64>,
1624
1625 storage_fund_reinvest_rate: Option<u64>,
1628
1629 reward_slashing_rate: Option<u64>,
1632
1633 storage_gas_price: Option<u64>,
1635
1636 accumulator_object_storage_cost: Option<u64>,
1638
1639 max_transactions_per_checkpoint: Option<u64>,
1644
1645 max_checkpoint_size_bytes: Option<u64>,
1649
1650 buffer_stake_for_protocol_upgrade_bps: Option<u64>,
1655
1656 address_from_bytes_cost_base: Option<u64>,
1661 address_to_u256_cost_base: Option<u64>,
1663 address_from_u256_cost_base: Option<u64>,
1665
1666 config_read_setting_impl_cost_base: Option<u64>,
1671 config_read_setting_impl_cost_per_byte: Option<u64>,
1672
1673 dynamic_field_hash_type_and_key_cost_base: Option<u64>,
1676 dynamic_field_hash_type_and_key_type_cost_per_byte: Option<u64>,
1677 dynamic_field_hash_type_and_key_value_cost_per_byte: Option<u64>,
1678 dynamic_field_hash_type_and_key_type_tag_cost_per_byte: Option<u64>,
1679 dynamic_field_add_child_object_cost_base: Option<u64>,
1681 dynamic_field_add_child_object_type_cost_per_byte: Option<u64>,
1682 dynamic_field_add_child_object_value_cost_per_byte: Option<u64>,
1683 dynamic_field_add_child_object_struct_tag_cost_per_byte: Option<u64>,
1684 dynamic_field_borrow_child_object_cost_base: Option<u64>,
1686 dynamic_field_borrow_child_object_child_ref_cost_per_byte: Option<u64>,
1687 dynamic_field_borrow_child_object_type_cost_per_byte: Option<u64>,
1688 dynamic_field_remove_child_object_cost_base: Option<u64>,
1690 dynamic_field_remove_child_object_child_cost_per_byte: Option<u64>,
1691 dynamic_field_remove_child_object_type_cost_per_byte: Option<u64>,
1692 dynamic_field_has_child_object_cost_base: Option<u64>,
1694 dynamic_field_has_child_object_with_ty_cost_base: Option<u64>,
1696 dynamic_field_has_child_object_with_ty_type_cost_per_byte: Option<u64>,
1697 dynamic_field_has_child_object_with_ty_type_tag_cost_per_byte: Option<u64>,
1698
1699 scratch_add_cost_base: Option<u64>,
1702 scratch_read_cost_base: Option<u64>,
1704 scratch_read_value_cost: Option<u64>,
1705 scratch_remove_cost_base: Option<u64>,
1707 scratch_exists_cost_base: Option<u64>,
1709 scratch_exists_with_type_cost_base: Option<u64>,
1711 scratch_exists_with_type_type_cost: Option<u64>,
1712 max_scratch_pad_size: Option<u64>,
1714
1715 event_emit_cost_base: Option<u64>,
1718 event_emit_value_size_derivation_cost_per_byte: Option<u64>,
1719 event_emit_tag_size_derivation_cost_per_byte: Option<u64>,
1720 event_emit_output_cost_per_byte: Option<u64>,
1721 event_emit_auth_stream_cost: Option<u64>,
1722
1723 object_borrow_uid_cost_base: Option<u64>,
1726 object_delete_impl_cost_base: Option<u64>,
1728 object_record_new_uid_cost_base: Option<u64>,
1730 object_record_new_uid_from_hash_cost_base: Option<u64>,
1733
1734 transfer_transfer_internal_cost_base: Option<u64>,
1737 transfer_party_transfer_internal_cost_base: Option<u64>,
1739 transfer_freeze_object_cost_base: Option<u64>,
1741 transfer_share_object_cost_base: Option<u64>,
1743 transfer_receive_object_cost_base: Option<u64>,
1746 transfer_receive_object_cost_per_byte: Option<u64>,
1747 transfer_receive_object_type_cost_per_byte: Option<u64>,
1748
1749 tx_context_derive_id_cost_base: Option<u64>,
1752 tx_context_fresh_id_cost_base: Option<u64>,
1753 tx_context_sender_cost_base: Option<u64>,
1754 tx_context_epoch_cost_base: Option<u64>,
1755 tx_context_epoch_timestamp_ms_cost_base: Option<u64>,
1756 tx_context_sponsor_cost_base: Option<u64>,
1757 tx_context_rgp_cost_base: Option<u64>,
1758 tx_context_gas_price_cost_base: Option<u64>,
1759 tx_context_gas_budget_cost_base: Option<u64>,
1760 tx_context_ids_created_cost_base: Option<u64>,
1761 tx_context_replace_cost_base: Option<u64>,
1762
1763 types_is_one_time_witness_cost_base: Option<u64>,
1766 types_is_one_time_witness_type_tag_cost_per_byte: Option<u64>,
1767 types_is_one_time_witness_type_cost_per_byte: Option<u64>,
1768
1769 validator_validate_metadata_cost_base: Option<u64>,
1772 validator_validate_metadata_data_cost_per_byte: Option<u64>,
1773
1774 crypto_invalid_arguments_cost: Option<u64>,
1776 bls12381_bls12381_min_sig_verify_cost_base: Option<u64>,
1778 bls12381_bls12381_min_sig_verify_msg_cost_per_byte: Option<u64>,
1779 bls12381_bls12381_min_sig_verify_msg_cost_per_block: Option<u64>,
1780
1781 bls12381_bls12381_min_pk_verify_cost_base: Option<u64>,
1783 bls12381_bls12381_min_pk_verify_msg_cost_per_byte: Option<u64>,
1784 bls12381_bls12381_min_pk_verify_msg_cost_per_block: Option<u64>,
1785
1786 ecdsa_k1_ecrecover_keccak256_cost_base: Option<u64>,
1788 ecdsa_k1_ecrecover_keccak256_msg_cost_per_byte: Option<u64>,
1789 ecdsa_k1_ecrecover_keccak256_msg_cost_per_block: Option<u64>,
1790 ecdsa_k1_ecrecover_sha256_cost_base: Option<u64>,
1791 ecdsa_k1_ecrecover_sha256_msg_cost_per_byte: Option<u64>,
1792 ecdsa_k1_ecrecover_sha256_msg_cost_per_block: Option<u64>,
1793
1794 ecdsa_k1_decompress_pubkey_cost_base: Option<u64>,
1796
1797 ecdsa_k1_secp256k1_verify_keccak256_cost_base: Option<u64>,
1799 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_byte: Option<u64>,
1800 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_block: Option<u64>,
1801 ecdsa_k1_secp256k1_verify_sha256_cost_base: Option<u64>,
1802 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_byte: Option<u64>,
1803 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_block: Option<u64>,
1804
1805 ecdsa_r1_ecrecover_keccak256_cost_base: Option<u64>,
1807 ecdsa_r1_ecrecover_keccak256_msg_cost_per_byte: Option<u64>,
1808 ecdsa_r1_ecrecover_keccak256_msg_cost_per_block: Option<u64>,
1809 ecdsa_r1_ecrecover_sha256_cost_base: Option<u64>,
1810 ecdsa_r1_ecrecover_sha256_msg_cost_per_byte: Option<u64>,
1811 ecdsa_r1_ecrecover_sha256_msg_cost_per_block: Option<u64>,
1812
1813 ecdsa_r1_secp256r1_verify_keccak256_cost_base: Option<u64>,
1815 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_byte: Option<u64>,
1816 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_block: Option<u64>,
1817 ecdsa_r1_secp256r1_verify_sha256_cost_base: Option<u64>,
1818 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_byte: Option<u64>,
1819 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_block: Option<u64>,
1820
1821 ecvrf_ecvrf_verify_cost_base: Option<u64>,
1823 ecvrf_ecvrf_verify_alpha_string_cost_per_byte: Option<u64>,
1824 ecvrf_ecvrf_verify_alpha_string_cost_per_block: Option<u64>,
1825
1826 ed25519_ed25519_verify_cost_base: Option<u64>,
1828 ed25519_ed25519_verify_msg_cost_per_byte: Option<u64>,
1829 ed25519_ed25519_verify_msg_cost_per_block: Option<u64>,
1830
1831 groth16_prepare_verifying_key_bls12381_cost_base: Option<u64>,
1833 groth16_prepare_verifying_key_bn254_cost_base: Option<u64>,
1834
1835 groth16_verify_groth16_proof_internal_bls12381_cost_base: Option<u64>,
1837 groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input: Option<u64>,
1838 groth16_verify_groth16_proof_internal_bn254_cost_base: Option<u64>,
1839 groth16_verify_groth16_proof_internal_bn254_cost_per_public_input: Option<u64>,
1840 groth16_verify_groth16_proof_internal_public_input_cost_per_byte: Option<u64>,
1841
1842 hash_blake2b256_cost_base: Option<u64>,
1844 hash_blake2b256_data_cost_per_byte: Option<u64>,
1845 hash_blake2b256_data_cost_per_block: Option<u64>,
1846
1847 hash_keccak256_cost_base: Option<u64>,
1849 hash_keccak256_data_cost_per_byte: Option<u64>,
1850 hash_keccak256_data_cost_per_block: Option<u64>,
1851
1852 poseidon_bn254_cost_base: Option<u64>,
1854 poseidon_bn254_cost_per_block: Option<u64>,
1855
1856 group_ops_bls12381_decode_scalar_cost: Option<u64>,
1858 group_ops_bls12381_decode_g1_cost: Option<u64>,
1859 group_ops_bls12381_decode_g2_cost: Option<u64>,
1860 group_ops_bls12381_decode_gt_cost: Option<u64>,
1861 group_ops_bls12381_scalar_add_cost: Option<u64>,
1862 group_ops_bls12381_g1_add_cost: Option<u64>,
1863 group_ops_bls12381_g2_add_cost: Option<u64>,
1864 group_ops_bls12381_gt_add_cost: Option<u64>,
1865 group_ops_bls12381_scalar_sub_cost: Option<u64>,
1866 group_ops_bls12381_g1_sub_cost: Option<u64>,
1867 group_ops_bls12381_g2_sub_cost: Option<u64>,
1868 group_ops_bls12381_gt_sub_cost: Option<u64>,
1869 group_ops_bls12381_scalar_mul_cost: Option<u64>,
1870 group_ops_bls12381_g1_mul_cost: Option<u64>,
1871 group_ops_bls12381_g2_mul_cost: Option<u64>,
1872 group_ops_bls12381_gt_mul_cost: Option<u64>,
1873 group_ops_bls12381_scalar_div_cost: Option<u64>,
1874 group_ops_bls12381_g1_div_cost: Option<u64>,
1875 group_ops_bls12381_g2_div_cost: Option<u64>,
1876 group_ops_bls12381_gt_div_cost: Option<u64>,
1877 group_ops_bls12381_g1_hash_to_base_cost: Option<u64>,
1878 group_ops_bls12381_g2_hash_to_base_cost: Option<u64>,
1879 group_ops_bls12381_g1_hash_to_cost_per_byte: Option<u64>,
1880 group_ops_bls12381_g2_hash_to_cost_per_byte: Option<u64>,
1881 group_ops_bls12381_g1_msm_base_cost: Option<u64>,
1882 group_ops_bls12381_g2_msm_base_cost: Option<u64>,
1883 group_ops_bls12381_g1_msm_base_cost_per_input: Option<u64>,
1884 group_ops_bls12381_g2_msm_base_cost_per_input: Option<u64>,
1885 group_ops_bls12381_msm_max_len: Option<u32>,
1886 group_ops_bls12381_pairing_cost: Option<u64>,
1887 group_ops_bls12381_g1_to_uncompressed_g1_cost: Option<u64>,
1888 group_ops_bls12381_uncompressed_g1_to_g1_cost: Option<u64>,
1889 group_ops_bls12381_uncompressed_g1_sum_base_cost: Option<u64>,
1890 group_ops_bls12381_uncompressed_g1_sum_cost_per_term: Option<u64>,
1891 group_ops_bls12381_uncompressed_g1_sum_max_terms: Option<u64>,
1892
1893 group_ops_ristretto_decode_scalar_cost: Option<u64>,
1894 group_ops_ristretto_decode_point_cost: Option<u64>,
1895 group_ops_ristretto_scalar_add_cost: Option<u64>,
1896 group_ops_ristretto_point_add_cost: Option<u64>,
1897 group_ops_ristretto_scalar_sub_cost: Option<u64>,
1898 group_ops_ristretto_point_sub_cost: Option<u64>,
1899 group_ops_ristretto_scalar_mul_cost: Option<u64>,
1900 group_ops_ristretto_point_mul_cost: Option<u64>,
1901 group_ops_ristretto_scalar_div_cost: Option<u64>,
1902 group_ops_ristretto_point_div_cost: Option<u64>,
1903
1904 verify_bulletproofs_ristretto255_base_cost: Option<u64>,
1905 verify_bulletproofs_ristretto255_cost_per_bit_and_commitment: Option<u64>,
1906
1907 hmac_hmac_sha3_256_cost_base: Option<u64>,
1909 hmac_hmac_sha3_256_input_cost_per_byte: Option<u64>,
1910 hmac_hmac_sha3_256_input_cost_per_block: Option<u64>,
1911
1912 check_zklogin_id_cost_base: Option<u64>,
1914 check_zklogin_issuer_cost_base: Option<u64>,
1916
1917 vdf_verify_vdf_cost: Option<u64>,
1918 vdf_hash_to_input_cost: Option<u64>,
1919
1920 nitro_attestation_parse_base_cost: Option<u64>,
1922 nitro_attestation_parse_cost_per_byte: Option<u64>,
1923 nitro_attestation_verify_base_cost: Option<u64>,
1924 nitro_attestation_verify_cost_per_cert: Option<u64>,
1925
1926 bcs_per_byte_serialized_cost: Option<u64>,
1928 bcs_legacy_min_output_size_cost: Option<u64>,
1929 bcs_failure_cost: Option<u64>,
1930
1931 hash_sha2_256_base_cost: Option<u64>,
1932 hash_sha2_256_per_byte_cost: Option<u64>,
1933 hash_sha2_256_legacy_min_input_len_cost: Option<u64>,
1934 hash_sha3_256_base_cost: Option<u64>,
1935 hash_sha3_256_per_byte_cost: Option<u64>,
1936 hash_sha3_256_legacy_min_input_len_cost: Option<u64>,
1937 type_name_get_base_cost: Option<u64>,
1938 type_name_get_per_byte_cost: Option<u64>,
1939 type_name_id_base_cost: Option<u64>,
1940
1941 string_check_utf8_base_cost: Option<u64>,
1942 string_check_utf8_per_byte_cost: Option<u64>,
1943 string_is_char_boundary_base_cost: Option<u64>,
1944 string_sub_string_base_cost: Option<u64>,
1945 string_sub_string_per_byte_cost: Option<u64>,
1946 string_index_of_base_cost: Option<u64>,
1947 string_index_of_per_byte_pattern_cost: Option<u64>,
1948 string_index_of_per_byte_searched_cost: Option<u64>,
1949
1950 vector_empty_base_cost: Option<u64>,
1951 vector_length_base_cost: Option<u64>,
1952 vector_push_back_base_cost: Option<u64>,
1953 vector_push_back_legacy_per_abstract_memory_unit_cost: Option<u64>,
1954 vector_borrow_base_cost: Option<u64>,
1955 vector_pop_back_base_cost: Option<u64>,
1956 vector_destroy_empty_base_cost: Option<u64>,
1957 vector_swap_base_cost: Option<u64>,
1958 debug_print_base_cost: Option<u64>,
1959 debug_print_stack_trace_base_cost: Option<u64>,
1960
1961 #[custom_setter]
1971 execution_version: Option<u64>,
1972
1973 consensus_bad_nodes_stake_threshold: Option<u64>,
1977
1978 max_jwk_votes_per_validator_per_epoch: Option<u64>,
1979 max_age_of_jwk_in_epochs: Option<u64>,
1983
1984 random_beacon_reduction_allowed_delta: Option<u16>,
1988
1989 random_beacon_reduction_lower_bound: Option<u32>,
1992
1993 random_beacon_dkg_timeout_round: Option<u32>,
1996
1997 random_beacon_min_round_interval_ms: Option<u64>,
1999
2000 random_beacon_dkg_version: Option<u64>,
2003
2004 consensus_max_transaction_size_bytes: Option<u64>,
2007 consensus_max_transactions_in_block_bytes: Option<u64>,
2009 consensus_max_num_transactions_in_block: Option<u64>,
2011
2012 consensus_voting_rounds: Option<u32>,
2014
2015 max_accumulated_txn_cost_per_object_in_narwhal_commit: Option<u64>,
2017
2018 max_deferral_rounds_for_congestion_control: Option<u64>,
2021
2022 epoch_close_deadline_ms: Option<u64>,
2027
2028 max_txn_cost_overage_per_object_in_commit: Option<u64>,
2030
2031 allowed_txn_cost_overage_burst_per_object_in_commit: Option<u64>,
2033
2034 min_checkpoint_interval_ms: Option<u64>,
2036
2037 checkpoint_summary_version_specific_data: Option<u64>,
2039
2040 max_soft_bundle_size: Option<u64>,
2042
2043 bridge_should_try_to_finalize_committee: Option<bool>,
2047
2048 max_accumulated_txn_cost_per_object_in_mysticeti_commit: Option<u64>,
2054
2055 max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit: Option<u64>,
2058
2059 consensus_gc_depth: Option<u32>,
2062
2063 gas_budget_based_txn_cost_cap_factor: Option<u64>,
2065
2066 gas_budget_based_txn_cost_absolute_cap_commit_count: Option<u64>,
2068
2069 sip_45_consensus_amplification_threshold: Option<u64>,
2072
2073 use_object_per_epoch_marker_table_v2: Option<bool>,
2076
2077 consensus_commit_rate_estimation_window_size: Option<u32>,
2079
2080 #[serde(skip_serializing_if = "Vec::is_empty")]
2084 aliased_addresses: Vec<AliasedAddress>,
2085
2086 translation_per_command_base_charge: Option<u64>,
2089
2090 translation_per_input_base_charge: Option<u64>,
2093
2094 translation_pure_input_per_byte_charge: Option<u64>,
2096
2097 translation_per_type_node_charge: Option<u64>,
2101
2102 translation_per_reference_node_charge: Option<u64>,
2105
2106 translation_per_linkage_entry_charge: Option<u64>,
2109
2110 max_updates_per_settlement_txn: Option<u32>,
2112
2113 gasless_max_computation_units: Option<u64>,
2115
2116 gasless_allowed_token_types: Option<Vec<(String, u64)>>,
2118
2119 gasless_max_unused_inputs: Option<u64>,
2123
2124 gasless_max_pure_input_bytes: Option<u64>,
2127
2128 gasless_max_tps: Option<u64>,
2130
2131 #[serde(skip_serializing_if = "Option::is_none")]
2132 #[skip_accessor]
2133 include_special_package_amendments: Option<Arc<Amendments>>,
2134
2135 gasless_max_tx_size_bytes: Option<u64>,
2138}
2139
2140#[derive(Clone, Serialize, Deserialize, Debug)]
2142pub struct AliasedAddress {
2143 pub original: [u8; 32],
2145 pub aliased: [u8; 32],
2147 pub allowed_tx_digests: Vec<[u8; 32]>,
2149}
2150
2151impl ProtocolConfig {
2153 pub fn chain(&self) -> Chain {
2155 self.chain
2156 }
2157
2158 pub fn check_package_upgrades_supported(&self) -> Result<(), Error> {
2171 if self.feature_flags.package_upgrades {
2172 Ok(())
2173 } else {
2174 Err(Error(format!(
2175 "package upgrades are not supported at {:?}",
2176 self.version
2177 )))
2178 }
2179 }
2180
2181 pub fn zklogin_supported_providers(&self) -> &BTreeSet<String> {
2182 &self.feature_flags.zklogin_supported_providers
2183 }
2184
2185 pub fn zklogin_circuit_mode(&self) -> u64 {
2188 self.feature_flags.zklogin_circuit_mode
2189 }
2190
2191 pub fn consensus_transaction_ordering(&self) -> ConsensusTransactionOrdering {
2192 self.feature_flags.consensus_transaction_ordering
2193 }
2194
2195 pub fn enable_jwk_consensus_updates(&self) -> bool {
2196 let ret = self.feature_flags.enable_jwk_consensus_updates;
2197 if ret {
2198 assert!(self.feature_flags.end_of_epoch_transaction_supported);
2200 }
2201 ret
2202 }
2203
2204 pub fn end_of_epoch_transaction_supported(&self) -> bool {
2205 let ret = self.feature_flags.end_of_epoch_transaction_supported;
2206 if !ret {
2207 assert!(!self.feature_flags.enable_jwk_consensus_updates);
2209 }
2210 ret
2211 }
2212
2213 pub fn dkg_version(&self) -> u64 {
2214 self.random_beacon_dkg_version.unwrap_or(1)
2216 }
2217
2218 pub fn bridge(&self) -> bool {
2219 let ret = self.feature_flags.bridge;
2220 if ret {
2221 assert!(self.feature_flags.end_of_epoch_transaction_supported);
2223 }
2224 ret
2225 }
2226
2227 pub fn should_try_to_finalize_bridge_committee(&self) -> bool {
2228 if !self.bridge() {
2229 return false;
2230 }
2231 self.bridge_should_try_to_finalize_committee.unwrap_or(true)
2233 }
2234
2235 pub fn zklogin_max_epoch_upper_bound_delta(&self) -> Option<u64> {
2236 self.feature_flags.zklogin_max_epoch_upper_bound_delta
2237 }
2238
2239 pub fn enable_coin_reservation_obj_refs(&self) -> bool {
2240 self.new_vm_enabled() && self.feature_flags.enable_coin_reservation_obj_refs
2241 }
2242
2243 pub fn enable_authenticated_event_streams(&self) -> bool {
2244 self.feature_flags.enable_authenticated_event_streams && self.enable_accumulators()
2245 }
2246
2247 pub fn per_object_congestion_control_mode(&self) -> PerObjectCongestionControlMode {
2248 self.feature_flags.per_object_congestion_control_mode
2249 }
2250
2251 pub fn consensus_choice(&self) -> ConsensusChoice {
2252 self.feature_flags.consensus_choice
2253 }
2254
2255 pub fn consensus_network(&self) -> ConsensusNetwork {
2256 self.feature_flags.consensus_network
2257 }
2258
2259 pub fn mysticeti_num_leaders_per_round(&self) -> Option<usize> {
2260 self.feature_flags.mysticeti_num_leaders_per_round
2261 }
2262
2263 pub fn max_transaction_size_bytes(&self) -> u64 {
2264 self.consensus_max_transaction_size_bytes
2266 .unwrap_or(256 * 1024)
2267 }
2268
2269 pub fn max_transactions_in_block_bytes(&self) -> u64 {
2270 if cfg!(msim) {
2271 256 * 1024
2272 } else {
2273 self.consensus_max_transactions_in_block_bytes
2274 .unwrap_or(512 * 1024)
2275 }
2276 }
2277
2278 pub fn max_num_transactions_in_block(&self) -> u64 {
2279 if cfg!(msim) {
2280 8
2281 } else {
2282 self.consensus_max_num_transactions_in_block.unwrap_or(512)
2283 }
2284 }
2285
2286 pub fn gc_depth(&self) -> u32 {
2287 self.consensus_gc_depth.unwrap_or(0)
2288 }
2289
2290 pub fn consensus_linearize_subdag_v2(&self) -> bool {
2291 let res = self.feature_flags.consensus_linearize_subdag_v2;
2292 assert!(
2293 !res || self.gc_depth() > 0,
2294 "The consensus linearize sub dag V2 requires GC to be enabled"
2295 );
2296 res
2297 }
2298
2299 pub fn consensus_median_based_commit_timestamp(&self) -> bool {
2300 let res = self.feature_flags.consensus_median_based_commit_timestamp;
2301 assert!(
2302 !res || self.gc_depth() > 0,
2303 "The consensus median based commit timestamp requires GC to be enabled"
2304 );
2305 res
2306 }
2307
2308 pub fn get_consensus_commit_rate_estimation_window_size(&self) -> u32 {
2309 self.consensus_commit_rate_estimation_window_size
2310 .unwrap_or(0)
2311 }
2312
2313 pub fn consensus_num_requested_prior_commits_at_startup(&self) -> u32 {
2314 let window_size = self.get_consensus_commit_rate_estimation_window_size();
2318 assert!(window_size == 0 || self.record_additional_state_digest_in_prologue());
2320 window_size
2321 }
2322
2323 pub fn enable_observation_chunking(&self) -> bool {
2324 matches!(self.feature_flags.per_object_congestion_control_mode,
2325 PerObjectCongestionControlMode::ExecutionTimeEstimate(ref params)
2326 if params.observations_chunk_size.is_some()
2327 )
2328 }
2329
2330 pub fn address_aliases(&self) -> bool {
2331 let address_aliases = self.feature_flags.address_aliases;
2332 assert!(
2333 !address_aliases || self.mysticeti_fastpath(),
2334 "Address aliases requires Mysticeti fastpath to be enabled"
2335 );
2336 if address_aliases {
2337 assert!(
2338 self.feature_flags.disable_preconsensus_locking,
2339 "Address aliases requires CertifiedTransaction to be disabled"
2340 );
2341 }
2342 address_aliases
2343 }
2344
2345 pub fn new_vm_enabled(&self) -> bool {
2346 self.execution_version.is_some_and(|v| v >= 4)
2347 }
2348
2349 pub fn gasless_allowed_token_types(&self) -> &[(String, u64)] {
2350 debug_assert!(self.gasless_allowed_token_types.is_some());
2351 self.gasless_allowed_token_types.as_deref().unwrap_or(&[])
2352 }
2353
2354 pub fn get_gasless_max_unused_inputs(&self) -> u64 {
2355 self.gasless_max_unused_inputs.unwrap_or(u64::MAX)
2356 }
2357
2358 pub fn get_gasless_max_pure_input_bytes(&self) -> u64 {
2359 self.gasless_max_pure_input_bytes.unwrap_or(u64::MAX)
2360 }
2361
2362 pub fn get_gasless_max_tx_size_bytes(&self) -> u64 {
2363 self.gasless_max_tx_size_bytes.unwrap_or(u64::MAX)
2364 }
2365
2366 pub fn include_special_package_amendments_as_option(&self) -> &Option<Arc<Amendments>> {
2367 &self.include_special_package_amendments
2368 }
2369}
2370
2371#[cfg(not(msim))]
2372static POISON_VERSION_METHODS: AtomicBool = AtomicBool::new(false);
2373
2374#[cfg(msim)]
2376thread_local! {
2377 static POISON_VERSION_METHODS: AtomicBool = AtomicBool::new(false);
2378}
2379
2380impl ProtocolConfig {
2382 pub fn get_for_version(version: ProtocolVersion, chain: Chain) -> Self {
2384 assert!(
2386 version >= ProtocolVersion::MIN,
2387 "Network protocol version is {:?}, but the minimum supported version by the binary is {:?}. Please upgrade the binary.",
2388 version,
2389 ProtocolVersion::MIN.0,
2390 );
2391 assert!(
2392 version <= ProtocolVersion::MAX_ALLOWED,
2393 "Network protocol version is {:?}, but the maximum supported version by the binary is {:?}. Please upgrade the binary.",
2394 version,
2395 ProtocolVersion::MAX_ALLOWED.0,
2396 );
2397
2398 let mut ret = Self::get_for_version_impl(version, chain);
2399 ret.version = version;
2400 ret.chain = chain;
2401
2402 ret = Self::apply_config_override(version, ret);
2403
2404 if std::env::var("SUI_PROTOCOL_CONFIG_OVERRIDE_ENABLE").is_ok() {
2405 warn!(
2406 "overriding ProtocolConfig settings with custom settings; this may break non-local networks"
2407 );
2408 let overrides: ProtocolConfigOptional =
2409 serde_env::from_env_with_prefix("SUI_PROTOCOL_CONFIG_OVERRIDE")
2410 .expect("failed to parse ProtocolConfig override env variables");
2411 overrides.apply_to(&mut ret);
2412 }
2413
2414 ret
2415 }
2416
2417 pub fn get_for_version_if_supported(version: ProtocolVersion, chain: Chain) -> Option<Self> {
2420 if version.0 >= ProtocolVersion::MIN.0 && version.0 <= ProtocolVersion::MAX_ALLOWED.0 {
2421 let mut ret = Self::get_for_version_impl(version, chain);
2422 ret.version = version;
2423 ret.chain = chain;
2424 ret = Self::apply_config_override(version, ret);
2425 Some(ret)
2426 } else {
2427 None
2428 }
2429 }
2430
2431 #[cfg(not(msim))]
2432 pub fn poison_get_for_min_version() {
2433 POISON_VERSION_METHODS.store(true, Ordering::Relaxed);
2434 }
2435
2436 #[cfg(not(msim))]
2437 fn load_poison_get_for_min_version() -> bool {
2438 POISON_VERSION_METHODS.load(Ordering::Relaxed)
2439 }
2440
2441 #[cfg(msim)]
2442 pub fn poison_get_for_min_version() {
2443 POISON_VERSION_METHODS.with(|p| p.store(true, Ordering::Relaxed));
2444 }
2445
2446 #[cfg(msim)]
2447 fn load_poison_get_for_min_version() -> bool {
2448 POISON_VERSION_METHODS.with(|p| p.load(Ordering::Relaxed))
2449 }
2450
2451 pub fn get_for_min_version() -> Self {
2454 if Self::load_poison_get_for_min_version() {
2455 panic!("get_for_min_version called on validator");
2456 }
2457 ProtocolConfig::get_for_version(ProtocolVersion::MIN, Chain::Unknown)
2458 }
2459
2460 #[allow(non_snake_case)]
2470 pub fn get_for_max_version_UNSAFE() -> Self {
2471 if Self::load_poison_get_for_min_version() {
2472 panic!("get_for_max_version_UNSAFE called on validator");
2473 }
2474 ProtocolConfig::get_for_version(ProtocolVersion::MAX, Chain::Unknown)
2475 }
2476
2477 fn get_for_version_impl(version: ProtocolVersion, chain: Chain) -> Self {
2478 #[cfg(msim)]
2479 {
2480 if version == ProtocolVersion::MAX_ALLOWED {
2482 let mut config = Self::get_for_version_impl(version - 1, Chain::Unknown);
2483 config.base_tx_cost_fixed = Some(config.base_tx_cost_fixed() + 1000);
2484 return config;
2485 }
2486 }
2487
2488 let mut cfg = Self {
2491 version,
2493 chain,
2494
2495 feature_flags: Default::default(),
2497
2498 max_tx_size_bytes: Some(128 * 1024),
2499 max_input_objects: Some(2048),
2501 max_serialized_tx_effects_size_bytes: Some(512 * 1024),
2502 max_serialized_tx_effects_size_bytes_system_tx: Some(512 * 1024 * 16),
2503 max_gas_payment_objects: Some(256),
2504 max_modules_in_publish: Some(128),
2505 max_package_dependencies: None,
2506 max_arguments: Some(512),
2507 max_type_arguments: Some(16),
2508 max_type_argument_depth: Some(16),
2509 max_pure_argument_size: Some(16 * 1024),
2510 max_programmable_tx_commands: Some(1024),
2511 move_binary_format_version: Some(6),
2512 min_move_binary_format_version: None,
2513 binary_module_handles: None,
2514 binary_struct_handles: None,
2515 binary_function_handles: None,
2516 binary_function_instantiations: None,
2517 binary_signatures: None,
2518 binary_constant_pool: None,
2519 binary_identifiers: None,
2520 binary_address_identifiers: None,
2521 binary_struct_defs: None,
2522 binary_struct_def_instantiations: None,
2523 binary_function_defs: None,
2524 binary_field_handles: None,
2525 binary_field_instantiations: None,
2526 binary_friend_decls: None,
2527 binary_enum_defs: None,
2528 binary_enum_def_instantiations: None,
2529 binary_variant_handles: None,
2530 binary_variant_instantiation_handles: None,
2531 max_move_object_size: Some(250 * 1024),
2532 max_move_package_size: Some(100 * 1024),
2533 max_publish_or_upgrade_per_ptb: None,
2534 max_tx_gas: Some(10_000_000_000),
2535 max_gas_price: Some(100_000),
2536 max_gas_price_rgp_factor_for_aborted_transactions: None,
2537 max_gas_computation_bucket: Some(5_000_000),
2538 max_loop_depth: Some(5),
2539 max_generic_instantiation_length: Some(32),
2540 max_function_parameters: Some(128),
2541 max_basic_blocks: Some(1024),
2542 max_value_stack_size: Some(1024),
2543 max_type_nodes: Some(256),
2544 max_generic_instantiation_type_nodes_per_function: None,
2545 max_generic_instantiation_type_nodes_per_module: None,
2546 max_push_size: Some(10000),
2547 max_struct_definitions: Some(200),
2548 max_function_definitions: Some(1000),
2549 max_fields_in_struct: Some(32),
2550 max_dependency_depth: Some(100),
2551 max_num_event_emit: Some(256),
2552 max_num_new_move_object_ids: Some(2048),
2553 max_num_new_move_object_ids_system_tx: Some(2048 * 16),
2554 max_num_deleted_move_object_ids: Some(2048),
2555 max_num_deleted_move_object_ids_system_tx: Some(2048 * 16),
2556 max_num_transferred_move_object_ids: Some(2048),
2557 max_num_transferred_move_object_ids_system_tx: Some(2048 * 16),
2558 max_event_emit_size: Some(250 * 1024),
2559 max_move_vector_len: Some(256 * 1024),
2560 max_type_to_layout_nodes: None,
2561 max_ptb_value_size: None,
2562
2563 max_back_edges_per_function: Some(10_000),
2564 max_back_edges_per_module: Some(10_000),
2565 max_verifier_meter_ticks_per_function: Some(6_000_000),
2566 max_meter_ticks_per_module: Some(6_000_000),
2567 max_meter_ticks_per_package: None,
2568
2569 object_runtime_max_num_cached_objects: Some(1000),
2570 object_runtime_max_num_cached_objects_system_tx: Some(1000 * 16),
2571 object_runtime_max_num_store_entries: Some(1000),
2572 object_runtime_max_num_store_entries_system_tx: Some(1000 * 16),
2573 base_tx_cost_fixed: Some(110_000),
2574 package_publish_cost_fixed: Some(1_000),
2575 base_tx_cost_per_byte: Some(0),
2576 package_publish_cost_per_byte: Some(80),
2577 obj_access_cost_read_per_byte: Some(15),
2578 obj_access_cost_mutate_per_byte: Some(40),
2579 obj_access_cost_delete_per_byte: Some(40),
2580 obj_access_cost_verify_per_byte: Some(200),
2581 obj_data_cost_refundable: Some(100),
2582 obj_metadata_cost_non_refundable: Some(50),
2583 gas_model_version: Some(1),
2584 storage_rebate_rate: Some(9900),
2585 storage_fund_reinvest_rate: Some(500),
2586 reward_slashing_rate: Some(5000),
2587 storage_gas_price: Some(1),
2588 accumulator_object_storage_cost: None,
2589 max_transactions_per_checkpoint: Some(10_000),
2590 max_checkpoint_size_bytes: Some(30 * 1024 * 1024),
2591
2592 buffer_stake_for_protocol_upgrade_bps: Some(0),
2595
2596 address_from_bytes_cost_base: Some(52),
2600 address_to_u256_cost_base: Some(52),
2602 address_from_u256_cost_base: Some(52),
2604
2605 config_read_setting_impl_cost_base: None,
2608 config_read_setting_impl_cost_per_byte: None,
2609
2610 dynamic_field_hash_type_and_key_cost_base: Some(100),
2613 dynamic_field_hash_type_and_key_type_cost_per_byte: Some(2),
2614 dynamic_field_hash_type_and_key_value_cost_per_byte: Some(2),
2615 dynamic_field_hash_type_and_key_type_tag_cost_per_byte: Some(2),
2616 dynamic_field_add_child_object_cost_base: Some(100),
2618 dynamic_field_add_child_object_type_cost_per_byte: Some(10),
2619 dynamic_field_add_child_object_value_cost_per_byte: Some(10),
2620 dynamic_field_add_child_object_struct_tag_cost_per_byte: Some(10),
2621 dynamic_field_borrow_child_object_cost_base: Some(100),
2623 dynamic_field_borrow_child_object_child_ref_cost_per_byte: Some(10),
2624 dynamic_field_borrow_child_object_type_cost_per_byte: Some(10),
2625 dynamic_field_remove_child_object_cost_base: Some(100),
2627 dynamic_field_remove_child_object_child_cost_per_byte: Some(2),
2628 dynamic_field_remove_child_object_type_cost_per_byte: Some(2),
2629 dynamic_field_has_child_object_cost_base: Some(100),
2631 dynamic_field_has_child_object_with_ty_cost_base: Some(100),
2633 dynamic_field_has_child_object_with_ty_type_cost_per_byte: Some(2),
2634 dynamic_field_has_child_object_with_ty_type_tag_cost_per_byte: Some(2),
2635
2636 scratch_add_cost_base: None,
2638 scratch_read_cost_base: None,
2639 scratch_read_value_cost: None,
2640 scratch_remove_cost_base: None,
2641 scratch_exists_cost_base: None,
2642 scratch_exists_with_type_cost_base: None,
2643 scratch_exists_with_type_type_cost: None,
2644 max_scratch_pad_size: None,
2645
2646 event_emit_cost_base: Some(52),
2649 event_emit_value_size_derivation_cost_per_byte: Some(2),
2650 event_emit_tag_size_derivation_cost_per_byte: Some(5),
2651 event_emit_output_cost_per_byte: Some(10),
2652 event_emit_auth_stream_cost: None,
2653
2654 object_borrow_uid_cost_base: Some(52),
2657 object_delete_impl_cost_base: Some(52),
2659 object_record_new_uid_cost_base: Some(52),
2661 object_record_new_uid_from_hash_cost_base: None,
2664
2665 transfer_transfer_internal_cost_base: Some(52),
2668 transfer_party_transfer_internal_cost_base: None,
2670 transfer_freeze_object_cost_base: Some(52),
2672 transfer_share_object_cost_base: Some(52),
2674 transfer_receive_object_cost_base: None,
2675 transfer_receive_object_type_cost_per_byte: None,
2676 transfer_receive_object_cost_per_byte: None,
2677
2678 tx_context_derive_id_cost_base: Some(52),
2681 tx_context_fresh_id_cost_base: None,
2682 tx_context_sender_cost_base: None,
2683 tx_context_epoch_cost_base: None,
2684 tx_context_epoch_timestamp_ms_cost_base: None,
2685 tx_context_sponsor_cost_base: None,
2686 tx_context_rgp_cost_base: None,
2687 tx_context_gas_price_cost_base: None,
2688 tx_context_gas_budget_cost_base: None,
2689 tx_context_ids_created_cost_base: None,
2690 tx_context_replace_cost_base: None,
2691
2692 types_is_one_time_witness_cost_base: Some(52),
2695 types_is_one_time_witness_type_tag_cost_per_byte: Some(2),
2696 types_is_one_time_witness_type_cost_per_byte: Some(2),
2697
2698 validator_validate_metadata_cost_base: Some(52),
2701 validator_validate_metadata_data_cost_per_byte: Some(2),
2702
2703 crypto_invalid_arguments_cost: Some(100),
2705 bls12381_bls12381_min_sig_verify_cost_base: Some(52),
2707 bls12381_bls12381_min_sig_verify_msg_cost_per_byte: Some(2),
2708 bls12381_bls12381_min_sig_verify_msg_cost_per_block: Some(2),
2709
2710 bls12381_bls12381_min_pk_verify_cost_base: Some(52),
2712 bls12381_bls12381_min_pk_verify_msg_cost_per_byte: Some(2),
2713 bls12381_bls12381_min_pk_verify_msg_cost_per_block: Some(2),
2714
2715 ecdsa_k1_ecrecover_keccak256_cost_base: Some(52),
2717 ecdsa_k1_ecrecover_keccak256_msg_cost_per_byte: Some(2),
2718 ecdsa_k1_ecrecover_keccak256_msg_cost_per_block: Some(2),
2719 ecdsa_k1_ecrecover_sha256_cost_base: Some(52),
2720 ecdsa_k1_ecrecover_sha256_msg_cost_per_byte: Some(2),
2721 ecdsa_k1_ecrecover_sha256_msg_cost_per_block: Some(2),
2722
2723 ecdsa_k1_decompress_pubkey_cost_base: Some(52),
2725
2726 ecdsa_k1_secp256k1_verify_keccak256_cost_base: Some(52),
2728 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_byte: Some(2),
2729 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_block: Some(2),
2730 ecdsa_k1_secp256k1_verify_sha256_cost_base: Some(52),
2731 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_byte: Some(2),
2732 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_block: Some(2),
2733
2734 ecdsa_r1_ecrecover_keccak256_cost_base: Some(52),
2736 ecdsa_r1_ecrecover_keccak256_msg_cost_per_byte: Some(2),
2737 ecdsa_r1_ecrecover_keccak256_msg_cost_per_block: Some(2),
2738 ecdsa_r1_ecrecover_sha256_cost_base: Some(52),
2739 ecdsa_r1_ecrecover_sha256_msg_cost_per_byte: Some(2),
2740 ecdsa_r1_ecrecover_sha256_msg_cost_per_block: Some(2),
2741
2742 ecdsa_r1_secp256r1_verify_keccak256_cost_base: Some(52),
2744 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_byte: Some(2),
2745 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_block: Some(2),
2746 ecdsa_r1_secp256r1_verify_sha256_cost_base: Some(52),
2747 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_byte: Some(2),
2748 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_block: Some(2),
2749
2750 ecvrf_ecvrf_verify_cost_base: Some(52),
2752 ecvrf_ecvrf_verify_alpha_string_cost_per_byte: Some(2),
2753 ecvrf_ecvrf_verify_alpha_string_cost_per_block: Some(2),
2754
2755 ed25519_ed25519_verify_cost_base: Some(52),
2757 ed25519_ed25519_verify_msg_cost_per_byte: Some(2),
2758 ed25519_ed25519_verify_msg_cost_per_block: Some(2),
2759
2760 groth16_prepare_verifying_key_bls12381_cost_base: Some(52),
2762 groth16_prepare_verifying_key_bn254_cost_base: Some(52),
2763
2764 groth16_verify_groth16_proof_internal_bls12381_cost_base: Some(52),
2766 groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input: Some(2),
2767 groth16_verify_groth16_proof_internal_bn254_cost_base: Some(52),
2768 groth16_verify_groth16_proof_internal_bn254_cost_per_public_input: Some(2),
2769 groth16_verify_groth16_proof_internal_public_input_cost_per_byte: Some(2),
2770
2771 hash_blake2b256_cost_base: Some(52),
2773 hash_blake2b256_data_cost_per_byte: Some(2),
2774 hash_blake2b256_data_cost_per_block: Some(2),
2775
2776 hash_keccak256_cost_base: Some(52),
2778 hash_keccak256_data_cost_per_byte: Some(2),
2779 hash_keccak256_data_cost_per_block: Some(2),
2780
2781 poseidon_bn254_cost_base: None,
2782 poseidon_bn254_cost_per_block: None,
2783
2784 hmac_hmac_sha3_256_cost_base: Some(52),
2786 hmac_hmac_sha3_256_input_cost_per_byte: Some(2),
2787 hmac_hmac_sha3_256_input_cost_per_block: Some(2),
2788
2789 group_ops_bls12381_decode_scalar_cost: None,
2791 group_ops_bls12381_decode_g1_cost: None,
2792 group_ops_bls12381_decode_g2_cost: None,
2793 group_ops_bls12381_decode_gt_cost: None,
2794 group_ops_bls12381_scalar_add_cost: None,
2795 group_ops_bls12381_g1_add_cost: None,
2796 group_ops_bls12381_g2_add_cost: None,
2797 group_ops_bls12381_gt_add_cost: None,
2798 group_ops_bls12381_scalar_sub_cost: None,
2799 group_ops_bls12381_g1_sub_cost: None,
2800 group_ops_bls12381_g2_sub_cost: None,
2801 group_ops_bls12381_gt_sub_cost: None,
2802 group_ops_bls12381_scalar_mul_cost: None,
2803 group_ops_bls12381_g1_mul_cost: None,
2804 group_ops_bls12381_g2_mul_cost: None,
2805 group_ops_bls12381_gt_mul_cost: None,
2806 group_ops_bls12381_scalar_div_cost: None,
2807 group_ops_bls12381_g1_div_cost: None,
2808 group_ops_bls12381_g2_div_cost: None,
2809 group_ops_bls12381_gt_div_cost: None,
2810 group_ops_bls12381_g1_hash_to_base_cost: None,
2811 group_ops_bls12381_g2_hash_to_base_cost: None,
2812 group_ops_bls12381_g1_hash_to_cost_per_byte: None,
2813 group_ops_bls12381_g2_hash_to_cost_per_byte: None,
2814 group_ops_bls12381_g1_msm_base_cost: None,
2815 group_ops_bls12381_g2_msm_base_cost: None,
2816 group_ops_bls12381_g1_msm_base_cost_per_input: None,
2817 group_ops_bls12381_g2_msm_base_cost_per_input: None,
2818 group_ops_bls12381_msm_max_len: None,
2819 group_ops_bls12381_pairing_cost: None,
2820 group_ops_bls12381_g1_to_uncompressed_g1_cost: None,
2821 group_ops_bls12381_uncompressed_g1_to_g1_cost: None,
2822 group_ops_bls12381_uncompressed_g1_sum_base_cost: None,
2823 group_ops_bls12381_uncompressed_g1_sum_cost_per_term: None,
2824 group_ops_bls12381_uncompressed_g1_sum_max_terms: None,
2825
2826 group_ops_ristretto_decode_scalar_cost: None,
2827 group_ops_ristretto_decode_point_cost: None,
2828 group_ops_ristretto_scalar_add_cost: None,
2829 group_ops_ristretto_point_add_cost: None,
2830 group_ops_ristretto_scalar_sub_cost: None,
2831 group_ops_ristretto_point_sub_cost: None,
2832 group_ops_ristretto_scalar_mul_cost: None,
2833 group_ops_ristretto_point_mul_cost: None,
2834 group_ops_ristretto_scalar_div_cost: None,
2835 group_ops_ristretto_point_div_cost: None,
2836
2837 verify_bulletproofs_ristretto255_base_cost: None,
2838 verify_bulletproofs_ristretto255_cost_per_bit_and_commitment: None,
2839
2840 check_zklogin_id_cost_base: None,
2842 check_zklogin_issuer_cost_base: None,
2844
2845 vdf_verify_vdf_cost: None,
2846 vdf_hash_to_input_cost: None,
2847
2848 nitro_attestation_parse_base_cost: None,
2850 nitro_attestation_parse_cost_per_byte: None,
2851 nitro_attestation_verify_base_cost: None,
2852 nitro_attestation_verify_cost_per_cert: None,
2853
2854 bcs_per_byte_serialized_cost: None,
2855 bcs_legacy_min_output_size_cost: None,
2856 bcs_failure_cost: None,
2857 hash_sha2_256_base_cost: None,
2858 hash_sha2_256_per_byte_cost: None,
2859 hash_sha2_256_legacy_min_input_len_cost: None,
2860 hash_sha3_256_base_cost: None,
2861 hash_sha3_256_per_byte_cost: None,
2862 hash_sha3_256_legacy_min_input_len_cost: None,
2863 type_name_get_base_cost: None,
2864 type_name_get_per_byte_cost: None,
2865 type_name_id_base_cost: None,
2866 string_check_utf8_base_cost: None,
2867 string_check_utf8_per_byte_cost: None,
2868 string_is_char_boundary_base_cost: None,
2869 string_sub_string_base_cost: None,
2870 string_sub_string_per_byte_cost: None,
2871 string_index_of_base_cost: None,
2872 string_index_of_per_byte_pattern_cost: None,
2873 string_index_of_per_byte_searched_cost: None,
2874 vector_empty_base_cost: None,
2875 vector_length_base_cost: None,
2876 vector_push_back_base_cost: None,
2877 vector_push_back_legacy_per_abstract_memory_unit_cost: None,
2878 vector_borrow_base_cost: None,
2879 vector_pop_back_base_cost: None,
2880 vector_destroy_empty_base_cost: None,
2881 vector_swap_base_cost: None,
2882 debug_print_base_cost: None,
2883 debug_print_stack_trace_base_cost: None,
2884
2885 max_size_written_objects: None,
2886 max_size_written_objects_system_tx: None,
2887
2888 max_move_identifier_len: None,
2895 max_move_value_depth: None,
2896 max_move_enum_variants: None,
2897
2898 gas_rounding_step: None,
2899
2900 execution_version: None,
2901
2902 max_event_emit_size_total: None,
2903
2904 consensus_bad_nodes_stake_threshold: None,
2905
2906 max_jwk_votes_per_validator_per_epoch: None,
2907
2908 max_age_of_jwk_in_epochs: None,
2909
2910 random_beacon_reduction_allowed_delta: None,
2911
2912 random_beacon_reduction_lower_bound: None,
2913
2914 random_beacon_dkg_timeout_round: None,
2915
2916 random_beacon_min_round_interval_ms: None,
2917
2918 random_beacon_dkg_version: None,
2919
2920 consensus_max_transaction_size_bytes: None,
2921
2922 consensus_max_transactions_in_block_bytes: None,
2923
2924 consensus_max_num_transactions_in_block: None,
2925
2926 consensus_voting_rounds: None,
2927
2928 max_accumulated_txn_cost_per_object_in_narwhal_commit: None,
2929
2930 max_deferral_rounds_for_congestion_control: None,
2931
2932 epoch_close_deadline_ms: None,
2933
2934 max_txn_cost_overage_per_object_in_commit: None,
2935
2936 allowed_txn_cost_overage_burst_per_object_in_commit: None,
2937
2938 min_checkpoint_interval_ms: None,
2939
2940 checkpoint_summary_version_specific_data: None,
2941
2942 max_soft_bundle_size: None,
2943
2944 bridge_should_try_to_finalize_committee: None,
2945
2946 max_accumulated_txn_cost_per_object_in_mysticeti_commit: None,
2947
2948 max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit: None,
2949
2950 consensus_gc_depth: None,
2951
2952 gas_budget_based_txn_cost_cap_factor: None,
2953
2954 gas_budget_based_txn_cost_absolute_cap_commit_count: None,
2955
2956 sip_45_consensus_amplification_threshold: None,
2957
2958 use_object_per_epoch_marker_table_v2: None,
2959
2960 consensus_commit_rate_estimation_window_size: None,
2961
2962 aliased_addresses: vec![],
2963
2964 translation_per_command_base_charge: None,
2965 translation_per_input_base_charge: None,
2966 translation_pure_input_per_byte_charge: None,
2967 translation_per_type_node_charge: None,
2968 translation_per_reference_node_charge: None,
2969 translation_per_linkage_entry_charge: None,
2970
2971 max_updates_per_settlement_txn: None,
2972
2973 gasless_max_computation_units: None,
2974 gasless_allowed_token_types: None,
2975 gasless_max_unused_inputs: None,
2976 gasless_max_pure_input_bytes: None,
2977 gasless_max_tps: None,
2978 include_special_package_amendments: None,
2979 gasless_max_tx_size_bytes: None,
2980 };
2983 for cur in 2..=version.0 {
2984 match cur {
2985 1 => unreachable!(),
2986 2 => {
2987 cfg.feature_flags.advance_epoch_start_time_in_safe_mode = true;
2988 }
2989 3 => {
2990 cfg.gas_model_version = Some(2);
2992 cfg.max_tx_gas = Some(50_000_000_000);
2994 cfg.base_tx_cost_fixed = Some(2_000);
2996 cfg.storage_gas_price = Some(76);
2998 cfg.feature_flags.loaded_child_objects_fixed = true;
2999 cfg.max_size_written_objects = Some(5 * 1000 * 1000);
3002 cfg.max_size_written_objects_system_tx = Some(50 * 1000 * 1000);
3005 cfg.feature_flags.package_upgrades = true;
3006 }
3007 4 => {
3012 cfg.reward_slashing_rate = Some(10000);
3014 cfg.gas_model_version = Some(3);
3016 }
3017 5 => {
3018 cfg.feature_flags.missing_type_is_compatibility_error = true;
3019 cfg.gas_model_version = Some(4);
3020 cfg.feature_flags.scoring_decision_with_validity_cutoff = true;
3021 }
3025 6 => {
3026 cfg.gas_model_version = Some(5);
3027 cfg.buffer_stake_for_protocol_upgrade_bps = Some(5000);
3028 cfg.feature_flags.consensus_order_end_of_epoch_last = true;
3029 }
3030 7 => {
3031 cfg.feature_flags.disallow_adding_abilities_on_upgrade = true;
3032 cfg.feature_flags
3033 .disable_invariant_violation_check_in_swap_loc = true;
3034 cfg.feature_flags.ban_entry_init = true;
3035 cfg.feature_flags.package_digest_hash_module = true;
3036 }
3037 8 => {
3038 cfg.feature_flags
3039 .disallow_change_struct_type_params_on_upgrade = true;
3040 }
3041 9 => {
3042 cfg.max_move_identifier_len = Some(128);
3044 cfg.feature_flags.no_extraneous_module_bytes = true;
3045 cfg.feature_flags
3046 .advance_to_highest_supported_protocol_version = true;
3047 }
3048 10 => {
3049 cfg.max_verifier_meter_ticks_per_function = Some(16_000_000);
3050 cfg.max_meter_ticks_per_module = Some(16_000_000);
3051 }
3052 11 => {
3053 cfg.max_move_value_depth = Some(128);
3054 }
3055 12 => {
3056 cfg.feature_flags.narwhal_versioned_metadata = true;
3057 if chain != Chain::Mainnet {
3058 cfg.feature_flags.commit_root_state_digest = true;
3059 }
3060
3061 if chain != Chain::Mainnet && chain != Chain::Testnet {
3062 cfg.feature_flags.zklogin_auth = true;
3063 }
3064 }
3065 13 => {}
3066 14 => {
3067 cfg.gas_rounding_step = Some(1_000);
3068 cfg.gas_model_version = Some(6);
3069 }
3070 15 => {
3071 cfg.feature_flags.consensus_transaction_ordering =
3072 ConsensusTransactionOrdering::ByGasPrice;
3073 }
3074 16 => {
3075 cfg.feature_flags.simplified_unwrap_then_delete = true;
3076 }
3077 17 => {
3078 cfg.feature_flags.upgraded_multisig_supported = true;
3079 }
3080 18 => {
3081 cfg.execution_version = Some(1);
3082 cfg.feature_flags.txn_base_cost_as_multiplier = true;
3091 cfg.base_tx_cost_fixed = Some(1_000);
3093 }
3094 19 => {
3095 cfg.max_num_event_emit = Some(1024);
3096 cfg.max_event_emit_size_total = Some(
3099 256 * 250 * 1024, );
3101 }
3102 20 => {
3103 cfg.feature_flags.commit_root_state_digest = true;
3104
3105 if chain != Chain::Mainnet {
3106 cfg.feature_flags.narwhal_new_leader_election_schedule = true;
3107 cfg.consensus_bad_nodes_stake_threshold = Some(20);
3108 }
3109 }
3110
3111 21 => {
3112 if chain != Chain::Mainnet {
3113 cfg.feature_flags.zklogin_supported_providers = BTreeSet::from([
3114 "Google".to_string(),
3115 "Facebook".to_string(),
3116 "Twitch".to_string(),
3117 ]);
3118 }
3119 }
3120 22 => {
3121 cfg.feature_flags.loaded_child_object_format = true;
3122 }
3123 23 => {
3124 cfg.feature_flags.loaded_child_object_format_type = true;
3125 cfg.feature_flags.narwhal_new_leader_election_schedule = true;
3126 cfg.consensus_bad_nodes_stake_threshold = Some(20);
3132 }
3133 24 => {
3134 cfg.feature_flags.simple_conservation_checks = true;
3135 cfg.max_publish_or_upgrade_per_ptb = Some(5);
3136
3137 cfg.feature_flags.end_of_epoch_transaction_supported = true;
3138
3139 if chain != Chain::Mainnet {
3140 cfg.feature_flags.enable_jwk_consensus_updates = true;
3141 cfg.max_jwk_votes_per_validator_per_epoch = Some(240);
3143 cfg.max_age_of_jwk_in_epochs = Some(1);
3144 }
3145 }
3146 25 => {
3147 cfg.feature_flags.zklogin_supported_providers = BTreeSet::from([
3149 "Google".to_string(),
3150 "Facebook".to_string(),
3151 "Twitch".to_string(),
3152 ]);
3153 cfg.feature_flags.zklogin_auth = true;
3154
3155 cfg.feature_flags.enable_jwk_consensus_updates = true;
3157 cfg.max_jwk_votes_per_validator_per_epoch = Some(240);
3158 cfg.max_age_of_jwk_in_epochs = Some(1);
3159 }
3160 26 => {
3161 cfg.gas_model_version = Some(7);
3162 if chain != Chain::Mainnet && chain != Chain::Testnet {
3164 cfg.transfer_receive_object_cost_base = Some(52);
3165 cfg.feature_flags.receive_objects = true;
3166 }
3167 }
3168 27 => {
3169 cfg.gas_model_version = Some(8);
3170 }
3171 28 => {
3172 cfg.check_zklogin_id_cost_base = Some(200);
3174 cfg.check_zklogin_issuer_cost_base = Some(200);
3176
3177 if chain != Chain::Mainnet && chain != Chain::Testnet {
3179 cfg.feature_flags.enable_effects_v2 = true;
3180 }
3181 }
3182 29 => {
3183 cfg.feature_flags.verify_legacy_zklogin_address = true;
3184 }
3185 30 => {
3186 if chain != Chain::Mainnet {
3188 cfg.feature_flags.narwhal_certificate_v2 = true;
3189 }
3190
3191 cfg.random_beacon_reduction_allowed_delta = Some(800);
3192 if chain != Chain::Mainnet {
3194 cfg.feature_flags.enable_effects_v2 = true;
3195 }
3196
3197 cfg.feature_flags.zklogin_supported_providers = BTreeSet::default();
3201
3202 cfg.feature_flags.recompute_has_public_transfer_in_execution = true;
3203 }
3204 31 => {
3205 cfg.execution_version = Some(2);
3206 if chain != Chain::Mainnet && chain != Chain::Testnet {
3208 cfg.feature_flags.shared_object_deletion = true;
3209 }
3210 }
3211 32 => {
3212 if chain != Chain::Mainnet {
3214 cfg.feature_flags.accept_zklogin_in_multisig = true;
3215 }
3216 if chain != Chain::Mainnet {
3218 cfg.transfer_receive_object_cost_base = Some(52);
3219 cfg.feature_flags.receive_objects = true;
3220 }
3221 if chain != Chain::Mainnet && chain != Chain::Testnet {
3223 cfg.feature_flags.random_beacon = true;
3224 cfg.random_beacon_reduction_lower_bound = Some(1600);
3225 cfg.random_beacon_dkg_timeout_round = Some(3000);
3226 cfg.random_beacon_min_round_interval_ms = Some(150);
3227 }
3228 if chain != Chain::Testnet && chain != Chain::Mainnet {
3230 cfg.feature_flags.include_consensus_digest_in_prologue = true;
3231 }
3232
3233 cfg.feature_flags.narwhal_certificate_v2 = true;
3235 }
3236 33 => {
3237 cfg.feature_flags.hardened_otw_check = true;
3238 cfg.feature_flags.allow_receiving_object_id = true;
3239
3240 cfg.transfer_receive_object_cost_base = Some(52);
3242 cfg.feature_flags.receive_objects = true;
3243
3244 if chain != Chain::Mainnet {
3246 cfg.feature_flags.shared_object_deletion = true;
3247 }
3248
3249 cfg.feature_flags.enable_effects_v2 = true;
3250 }
3251 34 => {}
3252 35 => {
3253 if chain != Chain::Mainnet && chain != Chain::Testnet {
3255 cfg.feature_flags.enable_poseidon = true;
3256 cfg.poseidon_bn254_cost_base = Some(260);
3257 cfg.poseidon_bn254_cost_per_block = Some(10);
3258 }
3259
3260 cfg.feature_flags.enable_coin_deny_list = true;
3261 }
3262 36 => {
3263 if chain != Chain::Mainnet && chain != Chain::Testnet {
3265 cfg.feature_flags.enable_group_ops_native_functions = true;
3266 cfg.feature_flags.enable_group_ops_native_function_msm = true;
3267 cfg.group_ops_bls12381_decode_scalar_cost = Some(52);
3269 cfg.group_ops_bls12381_decode_g1_cost = Some(52);
3270 cfg.group_ops_bls12381_decode_g2_cost = Some(52);
3271 cfg.group_ops_bls12381_decode_gt_cost = Some(52);
3272 cfg.group_ops_bls12381_scalar_add_cost = Some(52);
3273 cfg.group_ops_bls12381_g1_add_cost = Some(52);
3274 cfg.group_ops_bls12381_g2_add_cost = Some(52);
3275 cfg.group_ops_bls12381_gt_add_cost = Some(52);
3276 cfg.group_ops_bls12381_scalar_sub_cost = Some(52);
3277 cfg.group_ops_bls12381_g1_sub_cost = Some(52);
3278 cfg.group_ops_bls12381_g2_sub_cost = Some(52);
3279 cfg.group_ops_bls12381_gt_sub_cost = Some(52);
3280 cfg.group_ops_bls12381_scalar_mul_cost = Some(52);
3281 cfg.group_ops_bls12381_g1_mul_cost = Some(52);
3282 cfg.group_ops_bls12381_g2_mul_cost = Some(52);
3283 cfg.group_ops_bls12381_gt_mul_cost = Some(52);
3284 cfg.group_ops_bls12381_scalar_div_cost = Some(52);
3285 cfg.group_ops_bls12381_g1_div_cost = Some(52);
3286 cfg.group_ops_bls12381_g2_div_cost = Some(52);
3287 cfg.group_ops_bls12381_gt_div_cost = Some(52);
3288 cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(52);
3289 cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(52);
3290 cfg.group_ops_bls12381_g1_hash_to_cost_per_byte = Some(2);
3291 cfg.group_ops_bls12381_g2_hash_to_cost_per_byte = Some(2);
3292 cfg.group_ops_bls12381_g1_msm_base_cost = Some(52);
3293 cfg.group_ops_bls12381_g2_msm_base_cost = Some(52);
3294 cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(52);
3295 cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(52);
3296 cfg.group_ops_bls12381_msm_max_len = Some(32);
3297 cfg.group_ops_bls12381_pairing_cost = Some(52);
3298 }
3299 cfg.feature_flags.shared_object_deletion = true;
3301
3302 cfg.consensus_max_transaction_size_bytes = Some(256 * 1024); cfg.consensus_max_transactions_in_block_bytes = Some(6 * 1_024 * 1024);
3304 }
3306 37 => {
3307 cfg.feature_flags.reject_mutable_random_on_entry_functions = true;
3308
3309 if chain != Chain::Mainnet {
3311 cfg.feature_flags.include_consensus_digest_in_prologue = true;
3312 }
3313 }
3314 38 => {
3315 cfg.binary_module_handles = Some(100);
3316 cfg.binary_struct_handles = Some(300);
3317 cfg.binary_function_handles = Some(1500);
3318 cfg.binary_function_instantiations = Some(750);
3319 cfg.binary_signatures = Some(1000);
3320 cfg.binary_constant_pool = Some(4000);
3324 cfg.binary_identifiers = Some(10000);
3325 cfg.binary_address_identifiers = Some(100);
3326 cfg.binary_struct_defs = Some(200);
3327 cfg.binary_struct_def_instantiations = Some(100);
3328 cfg.binary_function_defs = Some(1000);
3329 cfg.binary_field_handles = Some(500);
3330 cfg.binary_field_instantiations = Some(250);
3331 cfg.binary_friend_decls = Some(100);
3332 cfg.max_package_dependencies = Some(32);
3334 cfg.max_modules_in_publish = Some(64);
3335 cfg.execution_version = Some(3);
3337 }
3338 39 => {
3339 }
3341 40 => {}
3342 41 => {
3343 cfg.feature_flags.enable_group_ops_native_functions = true;
3345 cfg.group_ops_bls12381_decode_scalar_cost = Some(52);
3347 cfg.group_ops_bls12381_decode_g1_cost = Some(52);
3348 cfg.group_ops_bls12381_decode_g2_cost = Some(52);
3349 cfg.group_ops_bls12381_decode_gt_cost = Some(52);
3350 cfg.group_ops_bls12381_scalar_add_cost = Some(52);
3351 cfg.group_ops_bls12381_g1_add_cost = Some(52);
3352 cfg.group_ops_bls12381_g2_add_cost = Some(52);
3353 cfg.group_ops_bls12381_gt_add_cost = Some(52);
3354 cfg.group_ops_bls12381_scalar_sub_cost = Some(52);
3355 cfg.group_ops_bls12381_g1_sub_cost = Some(52);
3356 cfg.group_ops_bls12381_g2_sub_cost = Some(52);
3357 cfg.group_ops_bls12381_gt_sub_cost = Some(52);
3358 cfg.group_ops_bls12381_scalar_mul_cost = Some(52);
3359 cfg.group_ops_bls12381_g1_mul_cost = Some(52);
3360 cfg.group_ops_bls12381_g2_mul_cost = Some(52);
3361 cfg.group_ops_bls12381_gt_mul_cost = Some(52);
3362 cfg.group_ops_bls12381_scalar_div_cost = Some(52);
3363 cfg.group_ops_bls12381_g1_div_cost = Some(52);
3364 cfg.group_ops_bls12381_g2_div_cost = Some(52);
3365 cfg.group_ops_bls12381_gt_div_cost = Some(52);
3366 cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(52);
3367 cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(52);
3368 cfg.group_ops_bls12381_g1_hash_to_cost_per_byte = Some(2);
3369 cfg.group_ops_bls12381_g2_hash_to_cost_per_byte = Some(2);
3370 cfg.group_ops_bls12381_g1_msm_base_cost = Some(52);
3371 cfg.group_ops_bls12381_g2_msm_base_cost = Some(52);
3372 cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(52);
3373 cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(52);
3374 cfg.group_ops_bls12381_msm_max_len = Some(32);
3375 cfg.group_ops_bls12381_pairing_cost = Some(52);
3376 }
3377 42 => {}
3378 43 => {
3379 cfg.feature_flags.zklogin_max_epoch_upper_bound_delta = Some(30);
3380 cfg.max_meter_ticks_per_package = Some(16_000_000);
3381 }
3382 44 => {
3383 cfg.feature_flags.include_consensus_digest_in_prologue = true;
3385 if chain != Chain::Mainnet {
3387 cfg.feature_flags.consensus_choice = ConsensusChoice::SwapEachEpoch;
3388 }
3389 }
3390 45 => {
3391 if chain != Chain::Testnet && chain != Chain::Mainnet {
3393 cfg.feature_flags.consensus_network = ConsensusNetwork::Tonic;
3394 }
3395
3396 if chain != Chain::Mainnet {
3397 cfg.feature_flags.mysticeti_leader_scoring_and_schedule = true;
3399 }
3400 cfg.min_move_binary_format_version = Some(6);
3401 cfg.feature_flags.accept_zklogin_in_multisig = true;
3402
3403 if chain != Chain::Mainnet && chain != Chain::Testnet {
3407 cfg.feature_flags.bridge = true;
3408 }
3409 }
3410 46 => {
3411 if chain != Chain::Mainnet {
3413 cfg.feature_flags.bridge = true;
3414 }
3415
3416 cfg.feature_flags.reshare_at_same_initial_version = true;
3418 }
3419 47 => {}
3420 48 => {
3421 cfg.feature_flags.consensus_network = ConsensusNetwork::Tonic;
3423
3424 cfg.feature_flags.resolve_abort_locations_to_package_id = true;
3426
3427 if chain != Chain::Mainnet {
3429 cfg.feature_flags.random_beacon = true;
3430 cfg.random_beacon_reduction_lower_bound = Some(1600);
3431 cfg.random_beacon_dkg_timeout_round = Some(3000);
3432 cfg.random_beacon_min_round_interval_ms = Some(200);
3433 }
3434
3435 cfg.feature_flags.mysticeti_use_committed_subdag_digest = true;
3437 }
3438 49 => {
3439 if chain != Chain::Testnet && chain != Chain::Mainnet {
3440 cfg.move_binary_format_version = Some(7);
3441 }
3442
3443 if chain != Chain::Mainnet && chain != Chain::Testnet {
3445 cfg.feature_flags.enable_vdf = true;
3446 cfg.vdf_verify_vdf_cost = Some(1500);
3449 cfg.vdf_hash_to_input_cost = Some(100);
3450 }
3451
3452 if chain != Chain::Testnet && chain != Chain::Mainnet {
3454 cfg.feature_flags
3455 .record_consensus_determined_version_assignments_in_prologue = true;
3456 }
3457
3458 if chain != Chain::Mainnet {
3460 cfg.feature_flags.consensus_choice = ConsensusChoice::Mysticeti;
3461 }
3462
3463 cfg.feature_flags.fresh_vm_on_framework_upgrade = true;
3465 }
3466 50 => {
3467 if chain != Chain::Mainnet {
3469 cfg.checkpoint_summary_version_specific_data = Some(1);
3470 cfg.min_checkpoint_interval_ms = Some(200);
3471 }
3472
3473 if chain != Chain::Testnet && chain != Chain::Mainnet {
3475 cfg.feature_flags
3476 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = true;
3477 }
3478
3479 cfg.feature_flags.mysticeti_num_leaders_per_round = Some(1);
3480
3481 cfg.max_deferral_rounds_for_congestion_control = Some(10);
3483 }
3484 51 => {
3485 cfg.random_beacon_dkg_version = Some(1);
3486
3487 if chain != Chain::Testnet && chain != Chain::Mainnet {
3488 cfg.feature_flags.enable_coin_deny_list_v2 = true;
3489 }
3490 }
3491 52 => {
3492 if chain != Chain::Mainnet {
3493 cfg.feature_flags.soft_bundle = true;
3494 cfg.max_soft_bundle_size = Some(5);
3495 }
3496
3497 cfg.config_read_setting_impl_cost_base = Some(100);
3498 cfg.config_read_setting_impl_cost_per_byte = Some(40);
3499
3500 if chain != Chain::Testnet && chain != Chain::Mainnet {
3502 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(100);
3503 cfg.feature_flags.per_object_congestion_control_mode =
3504 PerObjectCongestionControlMode::TotalTxCount;
3505 }
3506
3507 cfg.feature_flags.consensus_choice = ConsensusChoice::Mysticeti;
3509
3510 cfg.feature_flags.mysticeti_leader_scoring_and_schedule = true;
3512
3513 cfg.checkpoint_summary_version_specific_data = Some(1);
3515 cfg.min_checkpoint_interval_ms = Some(200);
3516
3517 if chain != Chain::Mainnet {
3519 cfg.feature_flags
3520 .record_consensus_determined_version_assignments_in_prologue = true;
3521 cfg.feature_flags
3522 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = true;
3523 }
3524 if chain != Chain::Mainnet {
3526 cfg.move_binary_format_version = Some(7);
3527 }
3528
3529 if chain != Chain::Testnet && chain != Chain::Mainnet {
3530 cfg.feature_flags.passkey_auth = true;
3531 }
3532 cfg.feature_flags.enable_coin_deny_list_v2 = true;
3533 }
3534 53 => {
3535 cfg.bridge_should_try_to_finalize_committee = Some(chain != Chain::Mainnet);
3537
3538 cfg.feature_flags
3540 .record_consensus_determined_version_assignments_in_prologue = true;
3541 cfg.feature_flags
3542 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = true;
3543
3544 if chain == Chain::Unknown {
3545 cfg.feature_flags.authority_capabilities_v2 = true;
3546 }
3547
3548 if chain != Chain::Mainnet {
3550 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(100);
3551 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(10);
3552 cfg.feature_flags.per_object_congestion_control_mode =
3553 PerObjectCongestionControlMode::TotalTxCount;
3554 }
3555
3556 cfg.bcs_per_byte_serialized_cost = Some(2);
3558 cfg.bcs_legacy_min_output_size_cost = Some(1);
3559 cfg.bcs_failure_cost = Some(52);
3560 cfg.debug_print_base_cost = Some(52);
3561 cfg.debug_print_stack_trace_base_cost = Some(52);
3562 cfg.hash_sha2_256_base_cost = Some(52);
3563 cfg.hash_sha2_256_per_byte_cost = Some(2);
3564 cfg.hash_sha2_256_legacy_min_input_len_cost = Some(1);
3565 cfg.hash_sha3_256_base_cost = Some(52);
3566 cfg.hash_sha3_256_per_byte_cost = Some(2);
3567 cfg.hash_sha3_256_legacy_min_input_len_cost = Some(1);
3568 cfg.type_name_get_base_cost = Some(52);
3569 cfg.type_name_get_per_byte_cost = Some(2);
3570 cfg.string_check_utf8_base_cost = Some(52);
3571 cfg.string_check_utf8_per_byte_cost = Some(2);
3572 cfg.string_is_char_boundary_base_cost = Some(52);
3573 cfg.string_sub_string_base_cost = Some(52);
3574 cfg.string_sub_string_per_byte_cost = Some(2);
3575 cfg.string_index_of_base_cost = Some(52);
3576 cfg.string_index_of_per_byte_pattern_cost = Some(2);
3577 cfg.string_index_of_per_byte_searched_cost = Some(2);
3578 cfg.vector_empty_base_cost = Some(52);
3579 cfg.vector_length_base_cost = Some(52);
3580 cfg.vector_push_back_base_cost = Some(52);
3581 cfg.vector_push_back_legacy_per_abstract_memory_unit_cost = Some(2);
3582 cfg.vector_borrow_base_cost = Some(52);
3583 cfg.vector_pop_back_base_cost = Some(52);
3584 cfg.vector_destroy_empty_base_cost = Some(52);
3585 cfg.vector_swap_base_cost = Some(52);
3586 }
3587 54 => {
3588 cfg.feature_flags.random_beacon = true;
3590 cfg.random_beacon_reduction_lower_bound = Some(1000);
3591 cfg.random_beacon_dkg_timeout_round = Some(3000);
3592 cfg.random_beacon_min_round_interval_ms = Some(500);
3593
3594 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(100);
3596 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(10);
3597 cfg.feature_flags.per_object_congestion_control_mode =
3598 PerObjectCongestionControlMode::TotalTxCount;
3599
3600 cfg.feature_flags.soft_bundle = true;
3602 cfg.max_soft_bundle_size = Some(5);
3603 }
3604 55 => {
3605 cfg.move_binary_format_version = Some(7);
3607
3608 cfg.consensus_max_transactions_in_block_bytes = Some(512 * 1024);
3610 cfg.consensus_max_num_transactions_in_block = Some(512);
3613
3614 cfg.feature_flags.rethrow_serialization_type_layout_errors = true;
3615 }
3616 56 => {
3617 if chain == Chain::Mainnet {
3618 cfg.feature_flags.bridge = true;
3619 }
3620 }
3621 57 => {
3622 cfg.random_beacon_reduction_lower_bound = Some(800);
3624 }
3625 58 => {
3626 if chain == Chain::Mainnet {
3627 cfg.bridge_should_try_to_finalize_committee = Some(true);
3628 }
3629
3630 if chain != Chain::Mainnet && chain != Chain::Testnet {
3631 cfg.feature_flags
3633 .consensus_distributed_vote_scoring_strategy = true;
3634 }
3635 }
3636 59 => {
3637 cfg.feature_flags.consensus_round_prober = true;
3639 }
3640 60 => {
3641 cfg.max_type_to_layout_nodes = Some(512);
3642 cfg.feature_flags.validate_identifier_inputs = true;
3643 }
3644 61 => {
3645 if chain != Chain::Mainnet {
3646 cfg.feature_flags
3648 .consensus_distributed_vote_scoring_strategy = true;
3649 }
3650 cfg.random_beacon_reduction_lower_bound = Some(700);
3652
3653 if chain != Chain::Mainnet && chain != Chain::Testnet {
3654 cfg.feature_flags.mysticeti_fastpath = true;
3656 }
3657 }
3658 62 => {
3659 cfg.feature_flags.relocate_event_module = true;
3660 }
3661 63 => {
3662 cfg.feature_flags.per_object_congestion_control_mode =
3663 PerObjectCongestionControlMode::TotalGasBudgetWithCap;
3664 cfg.gas_budget_based_txn_cost_cap_factor = Some(400_000);
3665 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(18_500_000);
3666 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(240_000_000);
3667 }
3668 64 => {
3669 cfg.feature_flags.per_object_congestion_control_mode =
3670 PerObjectCongestionControlMode::TotalTxCount;
3671 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(40);
3672 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(3);
3673 }
3674 65 => {
3675 cfg.feature_flags
3677 .consensus_distributed_vote_scoring_strategy = true;
3678 }
3679 66 => {
3680 if chain == Chain::Mainnet {
3681 cfg.feature_flags
3683 .consensus_distributed_vote_scoring_strategy = false;
3684 }
3685 }
3686 67 => {
3687 cfg.feature_flags
3689 .consensus_distributed_vote_scoring_strategy = true;
3690 }
3691 68 => {
3692 cfg.group_ops_bls12381_g1_to_uncompressed_g1_cost = Some(26);
3693 cfg.group_ops_bls12381_uncompressed_g1_to_g1_cost = Some(52);
3694 cfg.group_ops_bls12381_uncompressed_g1_sum_base_cost = Some(26);
3695 cfg.group_ops_bls12381_uncompressed_g1_sum_cost_per_term = Some(13);
3696 cfg.group_ops_bls12381_uncompressed_g1_sum_max_terms = Some(2000);
3697
3698 if chain != Chain::Mainnet && chain != Chain::Testnet {
3699 cfg.feature_flags.uncompressed_g1_group_elements = true;
3700 }
3701
3702 cfg.feature_flags.per_object_congestion_control_mode =
3703 PerObjectCongestionControlMode::TotalGasBudgetWithCap;
3704 cfg.gas_budget_based_txn_cost_cap_factor = Some(400_000);
3705 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(18_500_000);
3706 cfg.max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit =
3707 Some(3_700_000); cfg.max_txn_cost_overage_per_object_in_commit = Some(u64::MAX);
3709 cfg.gas_budget_based_txn_cost_absolute_cap_commit_count = Some(50);
3710
3711 cfg.random_beacon_reduction_lower_bound = Some(500);
3713
3714 cfg.feature_flags.disallow_new_modules_in_deps_only_packages = true;
3715 }
3716 69 => {
3717 cfg.consensus_voting_rounds = Some(40);
3719
3720 if chain != Chain::Mainnet && chain != Chain::Testnet {
3721 cfg.feature_flags.consensus_smart_ancestor_selection = true;
3723 }
3724
3725 if chain != Chain::Mainnet {
3726 cfg.feature_flags.uncompressed_g1_group_elements = true;
3727 }
3728 }
3729 70 => {
3730 if chain != Chain::Mainnet {
3731 cfg.feature_flags.consensus_smart_ancestor_selection = true;
3733 cfg.feature_flags
3735 .consensus_round_prober_probe_accepted_rounds = true;
3736 }
3737
3738 cfg.poseidon_bn254_cost_per_block = Some(388);
3739
3740 cfg.gas_model_version = Some(9);
3741 cfg.feature_flags.native_charging_v2 = true;
3742 cfg.bls12381_bls12381_min_sig_verify_cost_base = Some(44064);
3743 cfg.bls12381_bls12381_min_pk_verify_cost_base = Some(49282);
3744 cfg.ecdsa_k1_secp256k1_verify_keccak256_cost_base = Some(1470);
3745 cfg.ecdsa_k1_secp256k1_verify_sha256_cost_base = Some(1470);
3746 cfg.ecdsa_r1_secp256r1_verify_sha256_cost_base = Some(4225);
3747 cfg.ecdsa_r1_secp256r1_verify_keccak256_cost_base = Some(4225);
3748 cfg.ecvrf_ecvrf_verify_cost_base = Some(4848);
3749 cfg.ed25519_ed25519_verify_cost_base = Some(1802);
3750
3751 cfg.ecdsa_r1_ecrecover_keccak256_cost_base = Some(1173);
3753 cfg.ecdsa_r1_ecrecover_sha256_cost_base = Some(1173);
3754 cfg.ecdsa_k1_ecrecover_keccak256_cost_base = Some(500);
3755 cfg.ecdsa_k1_ecrecover_sha256_cost_base = Some(500);
3756
3757 cfg.groth16_prepare_verifying_key_bls12381_cost_base = Some(53838);
3758 cfg.groth16_prepare_verifying_key_bn254_cost_base = Some(82010);
3759 cfg.groth16_verify_groth16_proof_internal_bls12381_cost_base = Some(72090);
3760 cfg.groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input =
3761 Some(8213);
3762 cfg.groth16_verify_groth16_proof_internal_bn254_cost_base = Some(115502);
3763 cfg.groth16_verify_groth16_proof_internal_bn254_cost_per_public_input =
3764 Some(9484);
3765
3766 cfg.hash_keccak256_cost_base = Some(10);
3767 cfg.hash_blake2b256_cost_base = Some(10);
3768
3769 cfg.group_ops_bls12381_decode_scalar_cost = Some(7);
3771 cfg.group_ops_bls12381_decode_g1_cost = Some(2848);
3772 cfg.group_ops_bls12381_decode_g2_cost = Some(3770);
3773 cfg.group_ops_bls12381_decode_gt_cost = Some(3068);
3774
3775 cfg.group_ops_bls12381_scalar_add_cost = Some(10);
3776 cfg.group_ops_bls12381_g1_add_cost = Some(1556);
3777 cfg.group_ops_bls12381_g2_add_cost = Some(3048);
3778 cfg.group_ops_bls12381_gt_add_cost = Some(188);
3779
3780 cfg.group_ops_bls12381_scalar_sub_cost = Some(10);
3781 cfg.group_ops_bls12381_g1_sub_cost = Some(1550);
3782 cfg.group_ops_bls12381_g2_sub_cost = Some(3019);
3783 cfg.group_ops_bls12381_gt_sub_cost = Some(497);
3784
3785 cfg.group_ops_bls12381_scalar_mul_cost = Some(11);
3786 cfg.group_ops_bls12381_g1_mul_cost = Some(4842);
3787 cfg.group_ops_bls12381_g2_mul_cost = Some(9108);
3788 cfg.group_ops_bls12381_gt_mul_cost = Some(27490);
3789
3790 cfg.group_ops_bls12381_scalar_div_cost = Some(91);
3791 cfg.group_ops_bls12381_g1_div_cost = Some(5091);
3792 cfg.group_ops_bls12381_g2_div_cost = Some(9206);
3793 cfg.group_ops_bls12381_gt_div_cost = Some(27804);
3794
3795 cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(2962);
3796 cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(8688);
3797
3798 cfg.group_ops_bls12381_g1_msm_base_cost = Some(62648);
3799 cfg.group_ops_bls12381_g2_msm_base_cost = Some(131192);
3800 cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(1333);
3801 cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(3216);
3802
3803 cfg.group_ops_bls12381_uncompressed_g1_to_g1_cost = Some(677);
3804 cfg.group_ops_bls12381_g1_to_uncompressed_g1_cost = Some(2099);
3805 cfg.group_ops_bls12381_uncompressed_g1_sum_base_cost = Some(77);
3806 cfg.group_ops_bls12381_uncompressed_g1_sum_cost_per_term = Some(26);
3807
3808 cfg.group_ops_bls12381_pairing_cost = Some(26897);
3809 cfg.group_ops_bls12381_uncompressed_g1_sum_max_terms = Some(1200);
3810
3811 cfg.validator_validate_metadata_cost_base = Some(20000);
3812 }
3813 71 => {
3814 cfg.sip_45_consensus_amplification_threshold = Some(5);
3815
3816 cfg.allowed_txn_cost_overage_burst_per_object_in_commit = Some(185_000_000);
3818 }
3819 72 => {
3820 cfg.feature_flags.convert_type_argument_error = true;
3821
3822 cfg.max_tx_gas = Some(50_000_000_000_000);
3825 cfg.max_gas_price = Some(50_000_000_000);
3827
3828 cfg.feature_flags.variant_nodes = true;
3829 }
3830 73 => {
3831 cfg.use_object_per_epoch_marker_table_v2 = Some(true);
3833
3834 if chain != Chain::Mainnet && chain != Chain::Testnet {
3835 cfg.consensus_gc_depth = Some(60);
3838 }
3839
3840 if chain != Chain::Mainnet {
3841 cfg.feature_flags.consensus_zstd_compression = true;
3843 }
3844
3845 cfg.feature_flags.consensus_smart_ancestor_selection = true;
3847 cfg.feature_flags
3849 .consensus_round_prober_probe_accepted_rounds = true;
3850
3851 cfg.feature_flags.per_object_congestion_control_mode =
3853 PerObjectCongestionControlMode::TotalGasBudgetWithCap;
3854 cfg.gas_budget_based_txn_cost_cap_factor = Some(400_000);
3855 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(37_000_000);
3856 cfg.max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit =
3857 Some(7_400_000); cfg.max_txn_cost_overage_per_object_in_commit = Some(u64::MAX);
3859 cfg.gas_budget_based_txn_cost_absolute_cap_commit_count = Some(50);
3860 cfg.allowed_txn_cost_overage_burst_per_object_in_commit = Some(370_000_000);
3861 }
3862 74 => {
3863 if chain != Chain::Mainnet && chain != Chain::Testnet {
3865 cfg.feature_flags.enable_nitro_attestation = true;
3866 }
3867 cfg.nitro_attestation_parse_base_cost = Some(53 * 50);
3868 cfg.nitro_attestation_parse_cost_per_byte = Some(50);
3869 cfg.nitro_attestation_verify_base_cost = Some(49632 * 50);
3870 cfg.nitro_attestation_verify_cost_per_cert = Some(52369 * 50);
3871
3872 cfg.feature_flags.consensus_zstd_compression = true;
3874
3875 if chain != Chain::Mainnet && chain != Chain::Testnet {
3876 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
3877 }
3878 }
3879 75 => {
3880 if chain != Chain::Mainnet {
3881 cfg.feature_flags.passkey_auth = true;
3882 }
3883 }
3884 76 => {
3885 if chain != Chain::Mainnet && chain != Chain::Testnet {
3886 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
3887 cfg.consensus_commit_rate_estimation_window_size = Some(10);
3888 }
3889 cfg.feature_flags.minimize_child_object_mutations = true;
3890
3891 if chain != Chain::Mainnet {
3892 cfg.feature_flags.accept_passkey_in_multisig = true;
3893 }
3894 }
3895 77 => {
3896 cfg.feature_flags.uncompressed_g1_group_elements = true;
3897
3898 if chain != Chain::Mainnet {
3899 cfg.consensus_gc_depth = Some(60);
3900 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
3901 }
3902 }
3903 78 => {
3904 cfg.feature_flags.move_native_context = true;
3905 cfg.tx_context_fresh_id_cost_base = Some(52);
3906 cfg.tx_context_sender_cost_base = Some(30);
3907 cfg.tx_context_epoch_cost_base = Some(30);
3908 cfg.tx_context_epoch_timestamp_ms_cost_base = Some(30);
3909 cfg.tx_context_sponsor_cost_base = Some(30);
3910 cfg.tx_context_gas_price_cost_base = Some(30);
3911 cfg.tx_context_gas_budget_cost_base = Some(30);
3912 cfg.tx_context_ids_created_cost_base = Some(30);
3913 cfg.tx_context_replace_cost_base = Some(30);
3914 cfg.gas_model_version = Some(10);
3915
3916 if chain != Chain::Mainnet {
3917 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
3918 cfg.consensus_commit_rate_estimation_window_size = Some(10);
3919
3920 cfg.feature_flags.per_object_congestion_control_mode =
3922 PerObjectCongestionControlMode::ExecutionTimeEstimate(
3923 ExecutionTimeEstimateParams {
3924 target_utilization: 30,
3925 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
3927 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
3929 stored_observations_limit: u64::MAX,
3930 stake_weighted_median_threshold: 0,
3931 default_none_duration_for_new_keys: false,
3932 observations_chunk_size: None,
3933 },
3934 );
3935 }
3936 }
3937 79 => {
3938 if chain != Chain::Mainnet {
3939 cfg.feature_flags.consensus_median_based_commit_timestamp = true;
3940
3941 cfg.consensus_bad_nodes_stake_threshold = Some(30);
3944
3945 cfg.feature_flags.consensus_batched_block_sync = true;
3946
3947 cfg.feature_flags.enable_nitro_attestation = true
3949 }
3950 cfg.feature_flags.normalize_ptb_arguments = true;
3951
3952 cfg.consensus_gc_depth = Some(60);
3953 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
3954 }
3955 80 => {
3956 cfg.max_ptb_value_size = Some(1024 * 1024);
3957 }
3958 81 => {
3959 cfg.feature_flags.consensus_median_based_commit_timestamp = true;
3960 cfg.feature_flags.enforce_checkpoint_timestamp_monotonicity = true;
3961 cfg.consensus_bad_nodes_stake_threshold = Some(30)
3962 }
3963 82 => {
3964 cfg.feature_flags.max_ptb_value_size_v2 = true;
3965 }
3966 83 => {
3967 if chain == Chain::Mainnet {
3968 let aliased: [u8; 32] = Hex::decode(
3970 "0x0b2da327ba6a4cacbe75dddd50e6e8bbf81d6496e92d66af9154c61c77f7332f",
3971 )
3972 .unwrap()
3973 .try_into()
3974 .unwrap();
3975
3976 cfg.aliased_addresses.push(AliasedAddress {
3978 original: Hex::decode("0xcd8962dad278d8b50fa0f9eb0186bfa4cbdecc6d59377214c88d0286a0ac9562").unwrap().try_into().unwrap(),
3979 aliased,
3980 allowed_tx_digests: vec![
3981 Base58::decode("B2eGLFoMHgj93Ni8dAJBfqGzo8EWSTLBesZzhEpTPA4").unwrap().try_into().unwrap(),
3982 ],
3983 });
3984
3985 cfg.aliased_addresses.push(AliasedAddress {
3986 original: Hex::decode("0xe28b50cef1d633ea43d3296a3f6b67ff0312a5f1a99f0af753c85b8b5de8ff06").unwrap().try_into().unwrap(),
3987 aliased,
3988 allowed_tx_digests: vec![
3989 Base58::decode("J4QqSAgp7VrQtQpMy5wDX4QGsCSEZu3U5KuDAkbESAge").unwrap().try_into().unwrap(),
3990 ],
3991 });
3992 }
3993
3994 if chain != Chain::Mainnet {
3997 cfg.feature_flags.resolve_type_input_ids_to_defining_id = true;
3998 cfg.transfer_party_transfer_internal_cost_base = Some(52);
3999
4000 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
4002 cfg.consensus_commit_rate_estimation_window_size = Some(10);
4003 cfg.feature_flags.per_object_congestion_control_mode =
4004 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4005 ExecutionTimeEstimateParams {
4006 target_utilization: 30,
4007 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4009 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4011 stored_observations_limit: u64::MAX,
4012 stake_weighted_median_threshold: 0,
4013 default_none_duration_for_new_keys: false,
4014 observations_chunk_size: None,
4015 },
4016 );
4017
4018 cfg.feature_flags.consensus_batched_block_sync = true;
4020
4021 cfg.feature_flags.enable_nitro_attestation_upgraded_parsing = true;
4024 cfg.feature_flags.enable_nitro_attestation = true;
4025 }
4026 }
4027 84 => {
4028 if chain == Chain::Mainnet {
4029 cfg.feature_flags.resolve_type_input_ids_to_defining_id = true;
4030 cfg.transfer_party_transfer_internal_cost_base = Some(52);
4031
4032 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
4034 cfg.consensus_commit_rate_estimation_window_size = Some(10);
4035 cfg.feature_flags.per_object_congestion_control_mode =
4036 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4037 ExecutionTimeEstimateParams {
4038 target_utilization: 30,
4039 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4041 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4043 stored_observations_limit: u64::MAX,
4044 stake_weighted_median_threshold: 0,
4045 default_none_duration_for_new_keys: false,
4046 observations_chunk_size: None,
4047 },
4048 );
4049
4050 cfg.feature_flags.consensus_batched_block_sync = true;
4052
4053 cfg.feature_flags.enable_nitro_attestation_upgraded_parsing = true;
4056 cfg.feature_flags.enable_nitro_attestation = true;
4057 }
4058
4059 cfg.feature_flags.per_object_congestion_control_mode =
4061 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4062 ExecutionTimeEstimateParams {
4063 target_utilization: 30,
4064 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4066 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4068 stored_observations_limit: 20,
4069 stake_weighted_median_threshold: 0,
4070 default_none_duration_for_new_keys: false,
4071 observations_chunk_size: None,
4072 },
4073 );
4074 cfg.feature_flags.allow_unbounded_system_objects = true;
4075 }
4076 85 => {
4077 if chain != Chain::Mainnet && chain != Chain::Testnet {
4078 cfg.feature_flags.enable_party_transfer = true;
4079 }
4080
4081 cfg.feature_flags
4082 .record_consensus_determined_version_assignments_in_prologue_v2 = true;
4083 cfg.feature_flags.disallow_self_identifier = true;
4084 cfg.feature_flags.per_object_congestion_control_mode =
4085 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4086 ExecutionTimeEstimateParams {
4087 target_utilization: 50,
4088 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4090 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4092 stored_observations_limit: 20,
4093 stake_weighted_median_threshold: 0,
4094 default_none_duration_for_new_keys: false,
4095 observations_chunk_size: None,
4096 },
4097 );
4098 }
4099 86 => {
4100 cfg.feature_flags.type_tags_in_object_runtime = true;
4101 cfg.max_move_enum_variants = Some(move_core_types::VARIANT_COUNT_MAX);
4102
4103 cfg.feature_flags.per_object_congestion_control_mode =
4105 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4106 ExecutionTimeEstimateParams {
4107 target_utilization: 50,
4108 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4110 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4112 stored_observations_limit: 20,
4113 stake_weighted_median_threshold: 3334,
4114 default_none_duration_for_new_keys: false,
4115 observations_chunk_size: None,
4116 },
4117 );
4118 if chain != Chain::Mainnet {
4120 cfg.feature_flags.enable_party_transfer = true;
4121 }
4122 }
4123 87 => {
4124 if chain == Chain::Mainnet {
4125 cfg.feature_flags.record_time_estimate_processed = true;
4126 }
4127 cfg.feature_flags.better_adapter_type_resolution_errors = true;
4128 }
4129 88 => {
4130 cfg.feature_flags.record_time_estimate_processed = true;
4131 cfg.tx_context_rgp_cost_base = Some(30);
4132 cfg.feature_flags
4133 .ignore_execution_time_observations_after_certs_closed = true;
4134
4135 cfg.feature_flags.per_object_congestion_control_mode =
4138 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4139 ExecutionTimeEstimateParams {
4140 target_utilization: 50,
4141 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4143 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4145 stored_observations_limit: 20,
4146 stake_weighted_median_threshold: 3334,
4147 default_none_duration_for_new_keys: true,
4148 observations_chunk_size: None,
4149 },
4150 );
4151 }
4152 89 => {
4153 cfg.feature_flags.dependency_linkage_error = true;
4154 cfg.feature_flags.additional_multisig_checks = true;
4155 }
4156 90 => {
4157 cfg.max_gas_price_rgp_factor_for_aborted_transactions = Some(100);
4159 cfg.feature_flags.debug_fatal_on_move_invariant_violation = true;
4160 cfg.feature_flags.additional_consensus_digest_indirect_state = true;
4161 cfg.feature_flags.accept_passkey_in_multisig = true;
4162 cfg.feature_flags.passkey_auth = true;
4163 cfg.feature_flags.check_for_init_during_upgrade = true;
4164
4165 if chain != Chain::Mainnet {
4167 cfg.feature_flags.mysticeti_fastpath = true;
4168 }
4169 }
4170 91 => {
4171 cfg.feature_flags.per_command_shared_object_transfer_rules = true;
4172 }
4173 92 => {
4174 cfg.feature_flags.per_command_shared_object_transfer_rules = false;
4175 }
4176 93 => {
4177 cfg.feature_flags
4178 .consensus_checkpoint_signature_key_includes_digest = true;
4179 }
4180 94 => {
4181 cfg.feature_flags.per_object_congestion_control_mode =
4183 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4184 ExecutionTimeEstimateParams {
4185 target_utilization: 50,
4186 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4188 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4190 stored_observations_limit: 18,
4191 stake_weighted_median_threshold: 3334,
4192 default_none_duration_for_new_keys: true,
4193 observations_chunk_size: None,
4194 },
4195 );
4196
4197 cfg.feature_flags.enable_party_transfer = true;
4199 }
4200 95 => {
4201 cfg.type_name_id_base_cost = Some(52);
4202
4203 cfg.max_transactions_per_checkpoint = Some(20_000);
4205 }
4206 96 => {
4207 if chain != Chain::Mainnet && chain != Chain::Testnet {
4209 cfg.feature_flags
4210 .include_checkpoint_artifacts_digest_in_summary = true;
4211 }
4212 cfg.feature_flags.correct_gas_payment_limit_check = true;
4213 cfg.feature_flags.authority_capabilities_v2 = true;
4214 cfg.feature_flags.use_mfp_txns_in_load_initial_object_debts = true;
4215 cfg.feature_flags.cancel_for_failed_dkg_early = true;
4216 cfg.feature_flags.enable_coin_registry = true;
4217
4218 cfg.feature_flags.mysticeti_fastpath = true;
4220 }
4221 97 => {
4222 cfg.feature_flags.additional_borrow_checks = true;
4223 }
4224 98 => {
4225 cfg.event_emit_auth_stream_cost = Some(52);
4226 cfg.feature_flags.better_loader_errors = true;
4227 cfg.feature_flags.generate_df_type_layouts = true;
4228 }
4229 99 => {
4230 cfg.feature_flags.use_new_commit_handler = true;
4231 }
4232 100 => {
4233 cfg.feature_flags.private_generics_verifier_v2 = true;
4234 }
4235 101 => {
4236 cfg.feature_flags.create_root_accumulator_object = true;
4237 cfg.max_updates_per_settlement_txn = Some(100);
4238 if chain != Chain::Mainnet {
4239 cfg.feature_flags.enable_poseidon = true;
4240 }
4241 }
4242 102 => {
4243 cfg.feature_flags.per_object_congestion_control_mode =
4247 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4248 ExecutionTimeEstimateParams {
4249 target_utilization: 50,
4250 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4252 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4254 stored_observations_limit: 180,
4255 stake_weighted_median_threshold: 3334,
4256 default_none_duration_for_new_keys: true,
4257 observations_chunk_size: Some(18),
4258 },
4259 );
4260 cfg.feature_flags.deprecate_global_storage_ops = true;
4261 }
4262 103 => {}
4263 104 => {
4264 cfg.translation_per_command_base_charge = Some(1);
4265 cfg.translation_per_input_base_charge = Some(1);
4266 cfg.translation_pure_input_per_byte_charge = Some(1);
4267 cfg.translation_per_type_node_charge = Some(1);
4268 cfg.translation_per_reference_node_charge = Some(1);
4269 cfg.translation_per_linkage_entry_charge = Some(10);
4270 cfg.gas_model_version = Some(11);
4271 cfg.feature_flags.abstract_size_in_object_runtime = true;
4272 cfg.feature_flags.object_runtime_charge_cache_load_gas = true;
4273 cfg.dynamic_field_hash_type_and_key_cost_base = Some(52);
4274 cfg.dynamic_field_add_child_object_cost_base = Some(52);
4275 cfg.dynamic_field_add_child_object_value_cost_per_byte = Some(1);
4276 cfg.dynamic_field_borrow_child_object_cost_base = Some(52);
4277 cfg.dynamic_field_borrow_child_object_child_ref_cost_per_byte = Some(1);
4278 cfg.dynamic_field_remove_child_object_cost_base = Some(52);
4279 cfg.dynamic_field_remove_child_object_child_cost_per_byte = Some(1);
4280 cfg.dynamic_field_has_child_object_cost_base = Some(52);
4281 cfg.dynamic_field_has_child_object_with_ty_cost_base = Some(52);
4282 cfg.feature_flags.enable_ptb_execution_v2 = true;
4283
4284 cfg.poseidon_bn254_cost_base = Some(260);
4285
4286 cfg.feature_flags.consensus_skip_gced_accept_votes = true;
4287
4288 if chain != Chain::Mainnet {
4289 cfg.feature_flags
4290 .enable_nitro_attestation_all_nonzero_pcrs_parsing = true;
4291 }
4292
4293 cfg.feature_flags
4294 .include_cancelled_randomness_txns_in_prologue = true;
4295 }
4296 105 => {
4297 cfg.feature_flags.enable_multi_epoch_transaction_expiration = true;
4298 cfg.feature_flags.disable_preconsensus_locking = true;
4299
4300 if chain != Chain::Mainnet {
4301 cfg.feature_flags
4302 .enable_nitro_attestation_always_include_required_pcrs_parsing = true;
4303 }
4304 }
4305 106 => {
4306 cfg.accumulator_object_storage_cost = Some(7600);
4308
4309 if chain != Chain::Mainnet && chain != Chain::Testnet {
4310 cfg.feature_flags.enable_accumulators = true;
4311 cfg.feature_flags.enable_address_balance_gas_payments = true;
4312 cfg.feature_flags.enable_authenticated_event_streams = true;
4313 cfg.feature_flags.enable_object_funds_withdraw = true;
4314 }
4315 }
4316 107 => {
4317 cfg.feature_flags
4318 .consensus_skip_gced_blocks_in_direct_finalization = true;
4319
4320 if in_integration_test() {
4322 cfg.consensus_gc_depth = Some(6);
4323 cfg.consensus_max_num_transactions_in_block = Some(8);
4324 }
4325 }
4326 108 => {
4327 cfg.feature_flags.gas_rounding_halve_digits = true;
4328 cfg.feature_flags.flexible_tx_context_positions = true;
4329 cfg.feature_flags.disable_entry_point_signature_check = true;
4330
4331 if chain != Chain::Mainnet {
4332 cfg.feature_flags.address_aliases = true;
4333
4334 cfg.feature_flags.enable_accumulators = true;
4335 cfg.feature_flags.enable_address_balance_gas_payments = true;
4336 }
4337
4338 cfg.feature_flags.enable_poseidon = true;
4339 }
4340 109 => {
4341 cfg.binary_variant_handles = Some(1024);
4342 cfg.binary_variant_instantiation_handles = Some(1024);
4343 cfg.feature_flags.restrict_hot_or_not_entry_functions = true;
4344 }
4345 110 => {
4346 cfg.feature_flags
4347 .enable_nitro_attestation_all_nonzero_pcrs_parsing = true;
4348 cfg.feature_flags
4349 .enable_nitro_attestation_always_include_required_pcrs_parsing = true;
4350 if chain != Chain::Mainnet && chain != Chain::Testnet {
4351 cfg.feature_flags.split_checkpoints_in_consensus_handler = true;
4352 }
4353 cfg.feature_flags.validate_zklogin_public_identifier = true;
4354 cfg.feature_flags.fix_checkpoint_signature_mapping = true;
4355 cfg.feature_flags
4356 .consensus_always_accept_system_transactions = true;
4357 if chain != Chain::Mainnet {
4358 cfg.feature_flags.enable_object_funds_withdraw = true;
4359 }
4360 }
4361 111 => {
4362 cfg.feature_flags.validator_metadata_verify_v2 = true;
4363 }
4364 112 => {
4365 cfg.group_ops_ristretto_decode_scalar_cost = Some(7);
4366 cfg.group_ops_ristretto_decode_point_cost = Some(200);
4367 cfg.group_ops_ristretto_scalar_add_cost = Some(10);
4368 cfg.group_ops_ristretto_point_add_cost = Some(500);
4369 cfg.group_ops_ristretto_scalar_sub_cost = Some(10);
4370 cfg.group_ops_ristretto_point_sub_cost = Some(500);
4371 cfg.group_ops_ristretto_scalar_mul_cost = Some(11);
4372 cfg.group_ops_ristretto_point_mul_cost = Some(1200);
4373 cfg.group_ops_ristretto_scalar_div_cost = Some(151);
4374 cfg.group_ops_ristretto_point_div_cost = Some(2500);
4375
4376 if chain != Chain::Mainnet && chain != Chain::Testnet {
4377 cfg.feature_flags.enable_ristretto255_group_ops = true;
4378 }
4379 }
4380 113 => {
4381 cfg.feature_flags.address_balance_gas_check_rgp_at_signing = true;
4382 if chain != Chain::Mainnet && chain != Chain::Testnet {
4383 cfg.feature_flags.defer_unpaid_amplification = true;
4384 }
4385 }
4386 114 => {
4387 cfg.feature_flags.randomize_checkpoint_tx_limit_in_tests = true;
4388 cfg.feature_flags.address_balance_gas_reject_gas_coin_arg = true;
4389 if chain != Chain::Mainnet {
4390 cfg.feature_flags.split_checkpoints_in_consensus_handler = true;
4391 cfg.feature_flags.enable_authenticated_event_streams = true;
4392 cfg.feature_flags
4393 .include_checkpoint_artifacts_digest_in_summary = true;
4394 }
4395 }
4396 115 => {
4397 cfg.feature_flags.normalize_depth_formula = true;
4398 }
4399 116 => {
4400 cfg.feature_flags.gasless_transaction_drop_safety = true;
4401 cfg.feature_flags.address_aliases = true;
4402 cfg.feature_flags.relax_valid_during_for_owned_inputs = true;
4403 cfg.feature_flags.defer_unpaid_amplification = false;
4405 cfg.feature_flags.enable_display_registry = true;
4406 }
4407 117 => {}
4408 118 => {
4409 cfg.feature_flags.use_coin_party_owner = true;
4410 }
4411 119 => {
4412 cfg.execution_version = Some(4);
4414 cfg.feature_flags.address_balance_gas_reject_gas_coin_arg = false;
4415 cfg.feature_flags.merge_randomness_into_checkpoint = true;
4416 if chain != Chain::Mainnet {
4417 cfg.feature_flags.enable_gasless = true;
4418 cfg.gasless_max_computation_units = Some(50_000);
4419 cfg.gasless_allowed_token_types = Some(vec![]);
4420 cfg.feature_flags.enable_coin_reservation_obj_refs = true;
4421 cfg.feature_flags
4422 .convert_withdrawal_compatibility_ptb_arguments = true;
4423 }
4424 cfg.gasless_max_unused_inputs = Some(1);
4425 cfg.gasless_max_pure_input_bytes = Some(32);
4426 if chain == Chain::Testnet {
4427 cfg.gasless_allowed_token_types = Some(vec![(TESTNET_USDC.to_string(), 0)]);
4428 }
4429 cfg.transfer_receive_object_cost_per_byte = Some(1);
4430 cfg.transfer_receive_object_type_cost_per_byte = Some(2);
4431 }
4432 120 => {
4433 cfg.feature_flags.disallow_jump_orphans = true;
4434 }
4435 121 => {
4436 if chain != Chain::Mainnet {
4438 cfg.feature_flags.defer_unpaid_amplification = true;
4439 cfg.gasless_max_tps = Some(50);
4440 }
4441 cfg.feature_flags
4442 .early_return_receive_object_mismatched_type = true;
4443 }
4444 122 => {
4445 cfg.feature_flags.defer_unpaid_amplification = true;
4447 cfg.verify_bulletproofs_ristretto255_base_cost = Some(30000);
4449 cfg.verify_bulletproofs_ristretto255_cost_per_bit_and_commitment = Some(6500);
4450 if chain != Chain::Mainnet && chain != Chain::Testnet {
4451 cfg.feature_flags.enable_verify_bulletproofs_ristretto255 = true;
4452 }
4453 cfg.feature_flags.gasless_verify_remaining_balance = true;
4454 cfg.include_special_package_amendments = match chain {
4455 Chain::Mainnet => Some(MAINNET_LINKAGE_AMENDMENTS.clone()),
4456 Chain::Testnet => Some(TESTNET_LINKAGE_AMENDMENTS.clone()),
4457 Chain::Unknown => None,
4458 };
4459 cfg.gasless_max_tx_size_bytes = Some(16 * 1024);
4460 cfg.gasless_max_tps = Some(300);
4461 cfg.gasless_max_computation_units = Some(5_000);
4462 }
4463 123 => {
4464 cfg.gas_model_version = Some(13);
4465 }
4466 124 => {
4467 if chain != Chain::Mainnet && chain != Chain::Testnet {
4468 cfg.feature_flags.timestamp_based_epoch_close = true;
4469 }
4470 cfg.gas_model_version = Some(14);
4471 cfg.feature_flags.limit_groth16_pvk_inputs = true;
4472
4473 cfg.feature_flags.enable_accumulators = true;
4479 cfg.feature_flags.enable_address_balance_gas_payments = true;
4480 cfg.feature_flags.enable_authenticated_event_streams = true;
4481 cfg.feature_flags.enable_coin_reservation_obj_refs = true;
4482 cfg.feature_flags.enable_object_funds_withdraw = true;
4483 cfg.feature_flags
4484 .convert_withdrawal_compatibility_ptb_arguments = true;
4485 cfg.feature_flags.split_checkpoints_in_consensus_handler = true;
4486 cfg.feature_flags
4487 .include_checkpoint_artifacts_digest_in_summary = true;
4488 cfg.feature_flags.enable_gasless = true;
4489
4490 if chain == Chain::Mainnet {
4495 cfg.gasless_allowed_token_types = Some(vec![
4496 (MAINNET_USDC.to_string(), 10_000),
4497 (MAINNET_USDSUI.to_string(), 10_000),
4498 (MAINNET_SUI_USDE.to_string(), 10_000),
4499 (MAINNET_USDY.to_string(), 10_000),
4500 (MAINNET_FDUSD.to_string(), 10_000),
4501 (MAINNET_AUSD.to_string(), 10_000),
4502 (MAINNET_USDB.to_string(), 10_000),
4503 ]);
4504 }
4505 }
4506 125 => {
4507 cfg.feature_flags.granular_post_execution_checks = true;
4508 if chain != Chain::Mainnet {
4509 cfg.feature_flags.timestamp_based_epoch_close = true;
4510 }
4511 }
4512 126 => {
4513 cfg.feature_flags.early_exit_on_iffw = true;
4514 }
4515 127 => {
4516 cfg.feature_flags.always_advance_dkg_to_resolution = true;
4517
4518 cfg.verify_bulletproofs_ristretto255_base_cost = Some(23866);
4519 cfg.verify_bulletproofs_ristretto255_cost_per_bit_and_commitment = Some(1324);
4520 cfg.group_ops_ristretto_decode_scalar_cost = Some(5);
4521 cfg.group_ops_ristretto_decode_point_cost = Some(216);
4522 cfg.group_ops_ristretto_scalar_add_cost = Some(2);
4523 cfg.group_ops_ristretto_point_add_cost = Some(8);
4524 cfg.group_ops_ristretto_scalar_sub_cost = Some(2);
4525 cfg.group_ops_ristretto_point_sub_cost = Some(8);
4526 cfg.group_ops_ristretto_scalar_mul_cost = Some(5);
4527 cfg.group_ops_ristretto_point_mul_cost = Some(1763);
4528 cfg.group_ops_ristretto_scalar_div_cost = Some(557);
4529 cfg.group_ops_ristretto_point_div_cost = Some(2244);
4530
4531 if chain != Chain::Mainnet {
4532 cfg.feature_flags.enable_ristretto255_group_ops = true;
4533 cfg.feature_flags.enable_verify_bulletproofs_ristretto255 = true;
4534 }
4535
4536 cfg.feature_flags.timestamp_based_epoch_close = true;
4537 }
4538 128 => {
4539 cfg.max_generic_instantiation_type_nodes_per_function = Some(10_000);
4540 cfg.max_generic_instantiation_type_nodes_per_module = Some(500_000);
4541 cfg.binary_enum_defs = Some(200);
4542 cfg.binary_enum_def_instantiations = Some(100);
4543 }
4544 129 => {
4545 cfg.feature_flags.enable_unified_linkage = true;
4546 }
4547 130 => {
4548 cfg.feature_flags.record_net_unsettled_object_withdraws = true;
4549 cfg.feature_flags.enable_init_on_upgrade = true;
4550 cfg.epoch_close_deadline_ms = Some(120_000);
4551 cfg.scratch_add_cost_base = Some(13);
4552 cfg.scratch_read_cost_base = Some(13);
4553 cfg.scratch_read_value_cost = Some(1);
4554 cfg.scratch_remove_cost_base = Some(13);
4555 cfg.scratch_exists_cost_base = Some(13);
4556 cfg.scratch_exists_with_type_cost_base = Some(13);
4557 cfg.scratch_exists_with_type_type_cost = Some(1);
4558 let max_commands = cfg.max_programmable_tx_commands() as u64;
4559 cfg.max_scratch_pad_size = Some(16 * max_commands);
4560 if chain != Chain::Mainnet && chain != Chain::Testnet {
4562 cfg.feature_flags.zklogin_circuit_mode = 1;
4563 }
4564 }
4565 131 => {
4566 cfg.feature_flags.share_transaction_deny_config_in_consensus = true;
4567 cfg.feature_flags.framework_tx_context_mut_restrictions = true;
4568 }
4569 132 => {
4570 if chain != Chain::Mainnet && chain != Chain::Testnet {
4571 cfg.feature_flags.defer_owned_object_double_spend = true;
4572 }
4573 cfg.object_record_new_uid_from_hash_cost_base = Some(1);
4574 }
4575 _ => panic!("unsupported version {:?}", version),
4586 }
4587 }
4588
4589 cfg
4590 }
4591
4592 pub fn apply_seeded_test_overrides(&mut self, seed: &[u8; 32]) {
4593 if !self.feature_flags.randomize_checkpoint_tx_limit_in_tests
4594 || !self.feature_flags.split_checkpoints_in_consensus_handler
4595 {
4596 return;
4597 }
4598
4599 if !mysten_common::in_test_configuration() {
4600 return;
4601 }
4602
4603 use rand::{Rng, SeedableRng, rngs::StdRng};
4604 let mut rng = StdRng::from_seed(*seed);
4605 let max_txns = rng.gen_range(10..=100u64);
4606 info!("seeded test override: max_transactions_per_checkpoint = {max_txns}");
4607 self.max_transactions_per_checkpoint = Some(max_txns);
4608 }
4609
4610 pub fn verifier_config(&self, signing_limits: Option<(usize, usize, usize)>) -> VerifierConfig {
4616 let (
4617 max_back_edges_per_function,
4618 max_back_edges_per_module,
4619 sanity_check_with_regex_reference_safety,
4620 ) = if let Some((
4621 max_back_edges_per_function,
4622 max_back_edges_per_module,
4623 sanity_check_with_regex_reference_safety,
4624 )) = signing_limits
4625 {
4626 (
4627 Some(max_back_edges_per_function),
4628 Some(max_back_edges_per_module),
4629 Some(sanity_check_with_regex_reference_safety),
4630 )
4631 } else {
4632 (None, None, None)
4633 };
4634
4635 let additional_borrow_checks = if signing_limits.is_some() {
4636 true
4638 } else {
4639 self.additional_borrow_checks()
4640 };
4641 let deprecate_global_storage_ops = if signing_limits.is_some() {
4642 true
4644 } else {
4645 self.deprecate_global_storage_ops()
4646 };
4647
4648 VerifierConfig {
4649 max_loop_depth: Some(self.max_loop_depth() as usize),
4650 max_generic_instantiation_length: Some(self.max_generic_instantiation_length() as usize),
4651 max_function_parameters: Some(self.max_function_parameters() as usize),
4652 max_basic_blocks: Some(self.max_basic_blocks() as usize),
4653 max_value_stack_size: self.max_value_stack_size() as usize,
4654 max_type_nodes: Some(self.max_type_nodes() as usize),
4655 max_generic_instantiation_type_nodes_per_function: self
4656 .max_generic_instantiation_type_nodes_per_function_as_option()
4657 .map(|v| v as usize),
4658 max_generic_instantiation_type_nodes_per_module: self
4659 .max_generic_instantiation_type_nodes_per_module_as_option()
4660 .map(|v| v as usize),
4661 max_push_size: Some(self.max_push_size() as usize),
4662 max_dependency_depth: Some(self.max_dependency_depth() as usize),
4663 max_fields_in_struct: Some(self.max_fields_in_struct() as usize),
4664 max_function_definitions: Some(self.max_function_definitions() as usize),
4665 max_data_definitions: Some(self.max_struct_definitions() as usize),
4666 max_constant_vector_len: Some(self.max_move_vector_len()),
4667 max_back_edges_per_function,
4668 max_back_edges_per_module,
4669 max_basic_blocks_in_script: None,
4670 max_identifier_len: self.max_move_identifier_len_as_option(), disallow_self_identifier: self.feature_flags.disallow_self_identifier,
4672 allow_receiving_object_id: self.allow_receiving_object_id(),
4673 reject_mutable_random_on_entry_functions: self
4674 .reject_mutable_random_on_entry_functions(),
4675 bytecode_version: self.move_binary_format_version(),
4676 max_variants_in_enum: self.max_move_enum_variants_as_option(),
4677 additional_borrow_checks,
4678 better_loader_errors: self.better_loader_errors(),
4679 private_generics_verifier_v2: self.private_generics_verifier_v2(),
4680 sanity_check_with_regex_reference_safety: sanity_check_with_regex_reference_safety
4681 .map(|limit| limit as u128),
4682 deprecate_global_storage_ops,
4683 disable_entry_point_signature_check: self.disable_entry_point_signature_check(),
4684 switch_to_regex_reference_safety: false,
4685 framework_tx_context_mut_restrictions: self.framework_tx_context_mut_restrictions(),
4686 disallow_jump_orphans: self.disallow_jump_orphans(),
4687 }
4688 }
4689
4690 pub fn binary_config(
4691 &self,
4692 override_deprecate_global_storage_ops_during_deserialization: Option<bool>,
4693 ) -> BinaryConfig {
4694 let deprecate_global_storage_ops =
4695 override_deprecate_global_storage_ops_during_deserialization
4696 .unwrap_or_else(|| self.deprecate_global_storage_ops());
4697 BinaryConfig::new(
4698 self.move_binary_format_version(),
4699 self.min_move_binary_format_version_as_option()
4700 .unwrap_or(VERSION_1),
4701 self.no_extraneous_module_bytes(),
4702 deprecate_global_storage_ops,
4703 TableConfig {
4704 module_handles: self.binary_module_handles_as_option().unwrap_or(u16::MAX),
4705 datatype_handles: self.binary_struct_handles_as_option().unwrap_or(u16::MAX),
4706 function_handles: self.binary_function_handles_as_option().unwrap_or(u16::MAX),
4707 function_instantiations: self
4708 .binary_function_instantiations_as_option()
4709 .unwrap_or(u16::MAX),
4710 signatures: self.binary_signatures_as_option().unwrap_or(u16::MAX),
4711 constant_pool: self.binary_constant_pool_as_option().unwrap_or(u16::MAX),
4712 identifiers: self.binary_identifiers_as_option().unwrap_or(u16::MAX),
4713 address_identifiers: self
4714 .binary_address_identifiers_as_option()
4715 .unwrap_or(u16::MAX),
4716 struct_defs: self.binary_struct_defs_as_option().unwrap_or(u16::MAX),
4717 struct_def_instantiations: self
4718 .binary_struct_def_instantiations_as_option()
4719 .unwrap_or(u16::MAX),
4720 function_defs: self.binary_function_defs_as_option().unwrap_or(u16::MAX),
4721 field_handles: self.binary_field_handles_as_option().unwrap_or(u16::MAX),
4722 field_instantiations: self
4723 .binary_field_instantiations_as_option()
4724 .unwrap_or(u16::MAX),
4725 friend_decls: self.binary_friend_decls_as_option().unwrap_or(u16::MAX),
4726 enum_defs: self.binary_enum_defs_as_option().unwrap_or(u16::MAX),
4727 enum_def_instantiations: self
4728 .binary_enum_def_instantiations_as_option()
4729 .unwrap_or(u16::MAX),
4730 variant_handles: self.binary_variant_handles_as_option().unwrap_or(u16::MAX),
4731 variant_instantiation_handles: self
4732 .binary_variant_instantiation_handles_as_option()
4733 .unwrap_or(u16::MAX),
4734 },
4735 )
4736 }
4737
4738 #[cfg(not(msim))]
4742 pub fn apply_overrides_for_testing(
4743 override_fn: impl Fn(ProtocolVersion, Self) -> Self + Send + Sync + 'static,
4744 ) -> OverrideGuard {
4745 let mut cur = CONFIG_OVERRIDE.lock().unwrap();
4746 assert!(cur.is_none(), "config override already present");
4747 *cur = Some(Box::new(override_fn));
4748 OverrideGuard
4749 }
4750
4751 #[cfg(msim)]
4755 pub fn apply_overrides_for_testing(
4756 override_fn: impl Fn(ProtocolVersion, Self) -> Self + Send + 'static,
4757 ) -> OverrideGuard {
4758 CONFIG_OVERRIDE.with(|ovr| {
4759 let mut cur = ovr.borrow_mut();
4760 assert!(cur.is_none(), "config override already present");
4761 *cur = Some(Box::new(override_fn));
4762 OverrideGuard
4763 })
4764 }
4765
4766 #[cfg(not(msim))]
4767 fn apply_config_override(version: ProtocolVersion, mut ret: Self) -> Self {
4768 if let Some(override_fn) = CONFIG_OVERRIDE.lock().unwrap().as_ref() {
4769 warn!(
4770 "overriding ProtocolConfig settings with custom settings (you should not see this log outside of tests)"
4771 );
4772 ret = override_fn(version, ret);
4773 }
4774 ret
4775 }
4776
4777 #[cfg(msim)]
4778 fn apply_config_override(version: ProtocolVersion, ret: Self) -> Self {
4779 CONFIG_OVERRIDE.with(|ovr| {
4780 if let Some(override_fn) = &*ovr.borrow() {
4781 warn!(
4782 "overriding ProtocolConfig settings with custom settings (you should not see this log outside of tests)"
4783 );
4784 override_fn(version, ret)
4785 } else {
4786 ret
4787 }
4788 })
4789 }
4790}
4791
4792impl ProtocolConfig {
4796 pub fn set_execution_version_for_testing(&mut self, val: u64) {
4800 let current = self.execution_version.unwrap_or(0);
4801 assert!(
4802 val >= current,
4803 "cannot downgrade execution_version from {current} to {val}: running an old \
4804 executor against a newer protocol config/framework is unsupported. To test \
4805 frozen executor behavior, start from the last protocol version of that executor \
4806 instead, so genesis loads the matching framework snapshot (see \
4807 test_address_balance_gas_v3_accumulator_sign)."
4808 );
4809 self.execution_version = Some(val);
4810 }
4811
4812 pub fn set_zklogin_circuit_mode_for_testing(&mut self, val: u64) {
4815 self.feature_flags.zklogin_circuit_mode = val
4816 }
4817
4818 pub fn set_per_object_congestion_control_mode_for_testing(
4819 &mut self,
4820 val: PerObjectCongestionControlMode,
4821 ) {
4822 self.feature_flags.per_object_congestion_control_mode = val;
4823 }
4824
4825 pub fn set_consensus_choice_for_testing(&mut self, val: ConsensusChoice) {
4826 self.feature_flags.consensus_choice = val;
4827 }
4828
4829 pub fn set_consensus_network_for_testing(&mut self, val: ConsensusNetwork) {
4830 self.feature_flags.consensus_network = val;
4831 }
4832
4833 pub fn set_zklogin_max_epoch_upper_bound_delta_for_testing(&mut self, val: Option<u64>) {
4834 self.feature_flags.zklogin_max_epoch_upper_bound_delta = val
4835 }
4836
4837 pub fn set_mysticeti_num_leaders_per_round_for_testing(&mut self, val: Option<usize>) {
4838 self.feature_flags.mysticeti_num_leaders_per_round = val;
4839 }
4840
4841 pub fn disable_accumulators_for_testing(&mut self) {
4842 self.feature_flags.enable_accumulators = false;
4843 self.feature_flags.enable_address_balance_gas_payments = false;
4844 }
4845
4846 pub fn enable_coin_reservation_for_testing(&mut self) {
4847 self.feature_flags.enable_coin_reservation_obj_refs = true;
4848 self.feature_flags
4849 .convert_withdrawal_compatibility_ptb_arguments = true;
4850 self.execution_version = Some(self.execution_version.map_or(4, |v| v.max(4)));
4853 }
4854
4855 pub fn disable_coin_reservation_for_testing(&mut self) {
4856 self.feature_flags.enable_coin_reservation_obj_refs = false;
4857 self.feature_flags
4858 .convert_withdrawal_compatibility_ptb_arguments = false;
4859 }
4860
4861 pub fn enable_address_balance_gas_payments_for_testing(&mut self) {
4862 self.feature_flags.enable_accumulators = true;
4863 self.feature_flags.allow_private_accumulator_entrypoints = true;
4864 self.feature_flags.enable_address_balance_gas_payments = true;
4865 self.feature_flags.address_balance_gas_check_rgp_at_signing = true;
4866 self.feature_flags.address_balance_gas_reject_gas_coin_arg = false;
4867 self.execution_version = Some(self.execution_version.map_or(4, |v| v.max(4)))
4868 }
4869
4870 pub fn enable_gasless_for_testing(&mut self) {
4871 self.enable_address_balance_gas_payments_for_testing();
4872 self.feature_flags.enable_gasless = true;
4873 self.feature_flags.gasless_verify_remaining_balance = true;
4874 self.gasless_max_computation_units = Some(5_000);
4875 self.gasless_allowed_token_types = Some(vec![]);
4876 self.gasless_max_tps = Some(1000);
4877 self.gasless_max_tx_size_bytes = Some(16 * 1024);
4878 }
4879
4880 pub fn disable_gasless_for_testing(&mut self) {
4881 self.feature_flags.enable_gasless = false;
4882 self.gasless_max_computation_units = None;
4883 self.gasless_allowed_token_types = None;
4884 }
4885
4886 pub fn enable_authenticated_event_streams_for_testing(&mut self) {
4887 self.feature_flags.enable_accumulators = true;
4888 self.feature_flags.enable_authenticated_event_streams = true;
4889 self.feature_flags
4890 .include_checkpoint_artifacts_digest_in_summary = true;
4891 self.feature_flags.split_checkpoints_in_consensus_handler = true;
4892 }
4893}
4894
4895#[cfg(not(msim))]
4896type OverrideFn = dyn Fn(ProtocolVersion, ProtocolConfig) -> ProtocolConfig + Send + Sync;
4897
4898#[cfg(not(msim))]
4899static CONFIG_OVERRIDE: Mutex<Option<Box<OverrideFn>>> = Mutex::new(None);
4900
4901#[cfg(msim)]
4902type OverrideFn = dyn Fn(ProtocolVersion, ProtocolConfig) -> ProtocolConfig + Send;
4903
4904#[cfg(msim)]
4905thread_local! {
4906 static CONFIG_OVERRIDE: RefCell<Option<Box<OverrideFn>>> = RefCell::new(None);
4907}
4908
4909#[must_use]
4910pub struct OverrideGuard;
4911
4912#[cfg(not(msim))]
4913impl Drop for OverrideGuard {
4914 fn drop(&mut self) {
4915 info!("restoring override fn");
4916 *CONFIG_OVERRIDE.lock().unwrap() = None;
4917 }
4918}
4919
4920#[cfg(msim)]
4921impl Drop for OverrideGuard {
4922 fn drop(&mut self) {
4923 info!("restoring override fn");
4924 CONFIG_OVERRIDE.with(|ovr| {
4925 *ovr.borrow_mut() = None;
4926 });
4927 }
4928}
4929
4930#[derive(PartialEq, Eq)]
4933pub enum LimitThresholdCrossed {
4934 None,
4935 Soft(u128, u128),
4936 Hard(u128, u128),
4937}
4938
4939pub fn check_limit_in_range<T: Into<V>, U: Into<V>, V: PartialOrd + Into<u128>>(
4942 x: T,
4943 soft_limit: U,
4944 hard_limit: V,
4945) -> LimitThresholdCrossed {
4946 let x: V = x.into();
4947 let soft_limit: V = soft_limit.into();
4948
4949 debug_assert!(soft_limit <= hard_limit);
4950
4951 if x >= hard_limit {
4954 LimitThresholdCrossed::Hard(x.into(), hard_limit.into())
4955 } else if x < soft_limit {
4956 LimitThresholdCrossed::None
4957 } else {
4958 LimitThresholdCrossed::Soft(x.into(), soft_limit.into())
4959 }
4960}
4961
4962#[macro_export]
4963macro_rules! check_limit {
4964 ($x:expr, $hard:expr) => {
4965 check_limit!($x, $hard, $hard)
4966 };
4967 ($x:expr, $soft:expr, $hard:expr) => {
4968 check_limit_in_range($x as u64, $soft, $hard)
4969 };
4970}
4971
4972#[macro_export]
4976macro_rules! check_limit_by_meter {
4977 ($is_metered:expr, $x:expr, $metered_limit:expr, $unmetered_hard_limit:expr, $metric:expr) => {{
4978 let (h, metered_str) = if $is_metered {
4980 ($metered_limit, "metered")
4981 } else {
4982 ($unmetered_hard_limit, "unmetered")
4984 };
4985 use sui_protocol_config::check_limit_in_range;
4986 let result = check_limit_in_range($x as u64, $metered_limit, h);
4987 match result {
4988 LimitThresholdCrossed::None => {}
4989 LimitThresholdCrossed::Soft(_, _) => {
4990 $metric.with_label_values(&[metered_str, "soft"]).inc();
4991 }
4992 LimitThresholdCrossed::Hard(_, _) => {
4993 $metric.with_label_values(&[metered_str, "hard"]).inc();
4994 }
4995 };
4996 result
4997 }};
4998}
4999
5000pub type Amendments = BTreeMap<AccountAddress, BTreeMap<AccountAddress, AccountAddress>>;
5003
5004static MAINNET_LINKAGE_AMENDMENTS: LazyLock<Arc<Amendments>> =
5005 LazyLock::new(|| parse_amendments(include_str!("mainnet_amendments.json")));
5006
5007static TESTNET_LINKAGE_AMENDMENTS: LazyLock<Arc<Amendments>> =
5008 LazyLock::new(|| parse_amendments(include_str!("testnet_amendments.json")));
5009
5010fn parse_amendments(json: &str) -> Arc<Amendments> {
5011 #[derive(serde::Deserialize)]
5012 struct AmendmentEntry {
5013 root: String,
5014 deps: Vec<DepEntry>,
5015 }
5016
5017 #[derive(serde::Deserialize)]
5018 struct DepEntry {
5019 original_id: String,
5020 version_id: String,
5021 }
5022
5023 let entries: Vec<AmendmentEntry> =
5024 serde_json::from_str(json).expect("Failed to parse amendments JSON");
5025 let mut amendments = BTreeMap::new();
5026 for entry in entries {
5027 let root_id = AccountAddress::from_hex_literal(&entry.root).unwrap();
5028 let mut dep_ids = BTreeMap::new();
5029 for dep in entry.deps {
5030 let orig_id = AccountAddress::from_hex_literal(&dep.original_id).unwrap();
5031 let upgraded_id = AccountAddress::from_hex_literal(&dep.version_id).unwrap();
5032 assert!(
5033 dep_ids.insert(orig_id, upgraded_id).is_none(),
5034 "Duplicate original ID in amendments table"
5035 );
5036 }
5037 assert!(
5038 amendments.insert(root_id, dep_ids).is_none(),
5039 "Duplicate root ID in amendments table"
5040 );
5041 }
5042 Arc::new(amendments)
5043}
5044
5045#[cfg(all(test, not(msim)))]
5046mod test {
5047 use insta::assert_yaml_snapshot;
5048
5049 use super::*;
5050
5051 #[test]
5052 fn snapshot_tests() {
5053 println!("\n============================================================================");
5054 println!("! !");
5055 println!("! IMPORTANT: never update snapshots from this test. only add new versions! !");
5056 println!("! !");
5057 println!("============================================================================\n");
5058 for chain_id in &[Chain::Unknown, Chain::Mainnet, Chain::Testnet] {
5059 let chain_str = match chain_id {
5063 Chain::Unknown => "".to_string(),
5064 _ => format!("{:?}_", chain_id),
5065 };
5066 for i in MIN_PROTOCOL_VERSION..=MAX_PROTOCOL_VERSION {
5067 let cur = ProtocolVersion::new(i);
5068 assert_yaml_snapshot!(
5069 format!("{}version_{}", chain_str, cur.as_u64()),
5070 ProtocolConfig::get_for_version(cur, *chain_id)
5071 );
5072 }
5073 }
5074 }
5075
5076 #[test]
5077 fn test_getters() {
5078 let prot: ProtocolConfig =
5079 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5080 assert_eq!(
5081 prot.max_arguments(),
5082 prot.max_arguments_as_option().unwrap()
5083 );
5084 }
5085
5086 #[test]
5087 fn test_setters() {
5088 let mut prot: ProtocolConfig =
5089 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5090 prot.set_max_arguments_for_testing(123);
5091 assert_eq!(prot.max_arguments(), 123);
5092
5093 prot.set_max_arguments_from_str_for_testing("321".to_string());
5094 assert_eq!(prot.max_arguments(), 321);
5095
5096 prot.disable_max_arguments_for_testing();
5097 assert_eq!(prot.max_arguments_as_option(), None);
5098
5099 prot.set_attr_for_testing("max_arguments".to_string(), "456".to_string());
5100 assert_eq!(prot.max_arguments(), 456);
5101 }
5102
5103 #[test]
5104 fn test_execution_version_setter_allows_upgrade() {
5105 let mut prot = ProtocolConfig::get_for_max_version_UNSAFE();
5106 let current = prot.execution_version();
5107 prot.set_execution_version_for_testing(current);
5108 prot.set_execution_version_for_testing(current + 1);
5109 assert_eq!(prot.execution_version(), current + 1);
5110 }
5111
5112 #[test]
5113 #[should_panic(expected = "cannot downgrade execution_version")]
5114 fn test_execution_version_setter_panics_on_downgrade() {
5115 let mut prot = ProtocolConfig::get_for_max_version_UNSAFE();
5116 let current = prot.execution_version();
5117 prot.set_execution_version_for_testing(current - 1);
5118 }
5119
5120 #[test]
5121 fn test_feature_flag_setter_by_string() {
5122 let mut prot: ProtocolConfig =
5123 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5124 assert!(!prot.zklogin_auth());
5125 prot.set_feature_flag_for_testing("zklogin_auth".to_string(), true);
5126 assert!(prot.zklogin_auth());
5127 prot.set_feature_flag_for_testing("zklogin_auth".to_string(), false);
5128 assert!(!prot.zklogin_auth());
5129 }
5130
5131 #[test]
5132 #[should_panic(expected = "unknown feature flag")]
5133 fn test_feature_flag_setter_unknown_flag() {
5134 let mut prot: ProtocolConfig =
5135 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5136 prot.set_feature_flag_for_testing("some random string".to_string(), true);
5137 }
5138
5139 #[test]
5140 fn test_get_for_version_if_supported_applies_test_overrides() {
5141 let before =
5142 ProtocolConfig::get_for_version_if_supported(ProtocolVersion::new(1), Chain::Unknown)
5143 .unwrap();
5144
5145 assert!(!before.enable_coin_reservation_obj_refs());
5146
5147 let _guard = ProtocolConfig::apply_overrides_for_testing(|_, mut cfg| {
5148 cfg.enable_coin_reservation_for_testing();
5149 cfg
5150 });
5151
5152 let after =
5153 ProtocolConfig::get_for_version_if_supported(ProtocolVersion::new(1), Chain::Unknown)
5154 .unwrap();
5155
5156 assert!(after.enable_coin_reservation_obj_refs());
5157 }
5158
5159 #[test]
5160 #[should_panic(expected = "unsupported version")]
5161 fn max_version_test() {
5162 let _ = ProtocolConfig::get_for_version_impl(
5165 ProtocolVersion::new(MAX_PROTOCOL_VERSION + 1),
5166 Chain::Unknown,
5167 );
5168 }
5169
5170 #[test]
5171 fn lookup_by_string_test() {
5172 let prot: ProtocolConfig =
5173 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5174 assert!(prot.lookup_attr("some random string".to_string()).is_none());
5176
5177 assert!(
5178 prot.lookup_attr("max_arguments".to_string())
5179 == Some(ProtocolConfigValue::u32(prot.max_arguments())),
5180 );
5181
5182 assert!(
5184 prot.lookup_attr("max_move_identifier_len".to_string())
5185 .is_none()
5186 );
5187
5188 let prot: ProtocolConfig =
5190 ProtocolConfig::get_for_version(ProtocolVersion::new(9), Chain::Unknown);
5191 assert!(
5192 prot.lookup_attr("max_move_identifier_len".to_string())
5193 == Some(ProtocolConfigValue::u64(prot.max_move_identifier_len()))
5194 );
5195
5196 let prot: ProtocolConfig =
5197 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5198 assert!(
5200 prot.attr_map()
5201 .get("max_move_identifier_len")
5202 .unwrap()
5203 .is_none()
5204 );
5205 assert!(
5207 prot.attr_map().get("max_arguments").unwrap()
5208 == &Some(ProtocolConfigValue::u32(prot.max_arguments()))
5209 );
5210
5211 let prot: ProtocolConfig =
5213 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5214 assert!(
5216 prot.feature_flags
5217 .lookup_attr("some random string".to_owned())
5218 .is_none()
5219 );
5220 assert!(
5221 !prot
5222 .feature_flags
5223 .attr_map()
5224 .contains_key("some random string")
5225 );
5226
5227 assert!(
5229 prot.feature_flags
5230 .lookup_attr("package_upgrades".to_owned())
5231 == Some(false)
5232 );
5233 assert!(
5234 prot.feature_flags
5235 .attr_map()
5236 .get("package_upgrades")
5237 .unwrap()
5238 == &false
5239 );
5240 let prot: ProtocolConfig =
5241 ProtocolConfig::get_for_version(ProtocolVersion::new(4), Chain::Unknown);
5242 assert!(
5244 prot.feature_flags
5245 .lookup_attr("package_upgrades".to_owned())
5246 == Some(true)
5247 );
5248 assert!(
5249 prot.feature_flags
5250 .attr_map()
5251 .get("package_upgrades")
5252 .unwrap()
5253 == &true
5254 );
5255 }
5256
5257 #[test]
5258 fn limit_range_fn_test() {
5259 let low = 100u32;
5260 let high = 10000u64;
5261
5262 assert!(check_limit!(1u8, low, high) == LimitThresholdCrossed::None);
5263 assert!(matches!(
5264 check_limit!(255u16, low, high),
5265 LimitThresholdCrossed::Soft(255u128, 100)
5266 ));
5267 assert!(matches!(
5273 check_limit!(2550000u64, low, high),
5274 LimitThresholdCrossed::Hard(2550000, 10000)
5275 ));
5276
5277 assert!(matches!(
5278 check_limit!(2550000u64, high, high),
5279 LimitThresholdCrossed::Hard(2550000, 10000)
5280 ));
5281
5282 assert!(matches!(
5283 check_limit!(1u8, high),
5284 LimitThresholdCrossed::None
5285 ));
5286
5287 assert!(check_limit!(255u16, high) == LimitThresholdCrossed::None);
5288
5289 assert!(matches!(
5290 check_limit!(2550000u64, high),
5291 LimitThresholdCrossed::Hard(2550000, 10000)
5292 ));
5293 }
5294
5295 #[test]
5296 fn linkage_amendments_load() {
5297 let mainnet = LazyLock::force(&MAINNET_LINKAGE_AMENDMENTS);
5298 let testnet = LazyLock::force(&TESTNET_LINKAGE_AMENDMENTS);
5299 assert!(!mainnet.is_empty(), "mainnet amendments must not be empty");
5300 assert!(!testnet.is_empty(), "testnet amendments must not be empty");
5301 }
5302
5303 #[test]
5304 fn render_scalar_fields_use_precision_safe_encoding() {
5305 use mysten_common::rpc_format::Unmetered;
5306
5307 let config = ProtocolConfig::get_for_max_version_UNSAFE();
5308 let rendered = config
5309 .render::<serde_json::Value>(&mut Unmetered)
5310 .expect("render should succeed");
5311
5312 let max_args = rendered
5313 .get("max_arguments")
5314 .expect("max_arguments set at max version");
5315 assert!(
5316 max_args.is_number(),
5317 "u32 should render as number, got {max_args:?}",
5318 );
5319
5320 let max_tx_size = rendered
5321 .get("max_tx_size_bytes")
5322 .expect("max_tx_size_bytes set at max version");
5323 assert!(
5324 max_tx_size.is_string(),
5325 "u64 should render as string, got {max_tx_size:?}",
5326 );
5327 }
5328
5329 #[test]
5330 fn render_includes_non_scalar_gasless_allowlist_as_json() {
5331 use mysten_common::rpc_format::Unmetered;
5332 use serde_json::json;
5333
5334 let mut config = ProtocolConfig::get_for_max_version_UNSAFE();
5335 config.set_gasless_allowed_token_types_for_testing(vec![
5336 ("0xa::usdc::USDC".to_string(), 10_000),
5337 ("0xb::usdt::USDT".to_string(), 0),
5338 ]);
5339
5340 let rendered = config
5341 .render::<serde_json::Value>(&mut Unmetered)
5342 .expect("render should succeed under Unmetered budget");
5343 let allowlist = rendered
5344 .get("gasless_allowed_token_types")
5345 .expect("entry should be present after the testing setter");
5346
5347 assert_eq!(
5350 allowlist,
5351 &json!([["0xa::usdc::USDC", "10000"], ["0xb::usdt::USDT", "0"],]),
5352 );
5353 }
5354
5355 #[test]
5356 fn render_targets_prost_value_for_grpc() {
5357 use mysten_common::rpc_format::Unmetered;
5358 use prost_types::value::Kind;
5359
5360 let mut config = ProtocolConfig::get_for_max_version_UNSAFE();
5361 config.set_gasless_allowed_token_types_for_testing(vec![(
5362 "0xa::usdc::USDC".to_string(),
5363 10_000,
5364 )]);
5365
5366 let rendered = config
5367 .render::<prost_types::Value>(&mut Unmetered)
5368 .expect("render to prost Value should succeed");
5369 let allowlist = rendered
5370 .get("gasless_allowed_token_types")
5371 .expect("entry should be present after the testing setter");
5372
5373 let Some(Kind::ListValue(outer)) = &allowlist.kind else {
5375 panic!(
5376 "expected ListValue at the top level, got {:?}",
5377 allowlist.kind
5378 );
5379 };
5380 assert_eq!(outer.values.len(), 1, "one allowlisted entry");
5381 let Some(Kind::ListValue(entry)) = &outer.values[0].kind else {
5382 panic!("expected each entry to be a ListValue");
5383 };
5384 assert_eq!(entry.values.len(), 2, "entry has (coin_type, amount)");
5385
5386 let Some(Kind::StringValue(coin_type)) = &entry.values[0].kind else {
5387 panic!("expected coin_type as StringValue");
5388 };
5389 assert_eq!(coin_type, "0xa::usdc::USDC");
5390
5391 let Some(Kind::StringValue(amount)) = &entry.values[1].kind else {
5393 panic!(
5394 "expected minimum_transfer_amount as StringValue (precision-safe u64); got {:?}",
5395 entry.values[1].kind,
5396 );
5397 };
5398 assert_eq!(amount, "10000");
5399 }
5400
5401 #[test]
5402 fn render_emits_null_for_unset_protocol_versions() {
5403 use mysten_common::rpc_format::Unmetered;
5404
5405 let config = ProtocolConfig::get_for_version(1.into(), Chain::Unknown);
5406 let rendered = config
5407 .render::<serde_json::Value>(&mut Unmetered)
5408 .expect("render should succeed");
5409 let entry = rendered
5413 .get("gasless_allowed_token_types")
5414 .expect("key should be present for every protocol version");
5415 assert!(
5416 entry.is_null(),
5417 "value should be null for pre-feature protocol version, got {entry:?}",
5418 );
5419 }
5420}