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 = 126;
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)]
359pub struct ProtocolVersion(u64);
360
361impl ProtocolVersion {
362 pub const MIN: Self = Self(MIN_PROTOCOL_VERSION);
367
368 pub const MAX: Self = Self(MAX_PROTOCOL_VERSION);
369
370 #[cfg(not(msim))]
371 pub const MAX_ALLOWED: Self = Self::MAX;
372
373 #[cfg(msim)]
375 pub const MAX_ALLOWED: Self = Self(MAX_PROTOCOL_VERSION + 1);
376
377 pub fn new(v: u64) -> Self {
378 Self(v)
379 }
380
381 pub const fn as_u64(&self) -> u64 {
382 self.0
383 }
384
385 pub fn max() -> Self {
388 Self::MAX
389 }
390
391 pub fn prev(self) -> Self {
392 Self(self.0.checked_sub(1).unwrap())
393 }
394}
395
396impl From<u64> for ProtocolVersion {
397 fn from(v: u64) -> Self {
398 Self::new(v)
399 }
400}
401
402impl std::ops::Sub<u64> for ProtocolVersion {
403 type Output = Self;
404 fn sub(self, rhs: u64) -> Self::Output {
405 Self::new(self.0 - rhs)
406 }
407}
408
409impl std::ops::Add<u64> for ProtocolVersion {
410 type Output = Self;
411 fn add(self, rhs: u64) -> Self::Output {
412 Self::new(self.0 + rhs)
413 }
414}
415
416#[derive(
417 Clone, Serialize, Deserialize, Debug, Default, PartialEq, Copy, PartialOrd, Ord, Eq, ValueEnum,
418)]
419pub enum Chain {
420 Mainnet,
421 Testnet,
422 #[default]
423 Unknown,
424}
425
426impl Chain {
427 pub fn as_str(self) -> &'static str {
428 match self {
429 Chain::Mainnet => "mainnet",
430 Chain::Testnet => "testnet",
431 Chain::Unknown => "unknown",
432 }
433 }
434}
435
436pub struct Error(pub String);
437
438#[derive(Default, Clone, Serialize, Deserialize, Debug, ProtocolConfigFeatureFlagsGetters)]
441struct FeatureFlags {
442 #[serde(skip_serializing_if = "is_false")]
445 package_upgrades: bool,
446 #[serde(skip_serializing_if = "is_false")]
449 commit_root_state_digest: bool,
450 #[serde(skip_serializing_if = "is_false")]
452 advance_epoch_start_time_in_safe_mode: bool,
453 #[serde(skip_serializing_if = "is_false")]
456 loaded_child_objects_fixed: bool,
457 #[serde(skip_serializing_if = "is_false")]
460 missing_type_is_compatibility_error: bool,
461 #[serde(skip_serializing_if = "is_false")]
464 scoring_decision_with_validity_cutoff: bool,
465
466 #[serde(skip_serializing_if = "is_false")]
469 consensus_order_end_of_epoch_last: bool,
470
471 #[serde(skip_serializing_if = "is_false")]
473 disallow_adding_abilities_on_upgrade: bool,
474 #[serde(skip_serializing_if = "is_false")]
476 disable_invariant_violation_check_in_swap_loc: bool,
477 #[serde(skip_serializing_if = "is_false")]
480 advance_to_highest_supported_protocol_version: bool,
481 #[serde(skip_serializing_if = "is_false")]
483 ban_entry_init: bool,
484 #[serde(skip_serializing_if = "is_false")]
486 package_digest_hash_module: bool,
487 #[serde(skip_serializing_if = "is_false")]
489 disallow_change_struct_type_params_on_upgrade: bool,
490 #[serde(skip_serializing_if = "is_false")]
492 no_extraneous_module_bytes: bool,
493 #[serde(skip_serializing_if = "is_false")]
495 narwhal_versioned_metadata: bool,
496
497 #[serde(skip_serializing_if = "is_false")]
499 zklogin_auth: bool,
500 #[serde(skip_serializing_if = "ConsensusTransactionOrdering::is_none")]
502 consensus_transaction_ordering: ConsensusTransactionOrdering,
503
504 #[serde(skip_serializing_if = "is_false")]
512 simplified_unwrap_then_delete: bool,
513 #[serde(skip_serializing_if = "is_false")]
515 upgraded_multisig_supported: bool,
516 #[serde(skip_serializing_if = "is_false")]
518 txn_base_cost_as_multiplier: bool,
519
520 #[serde(skip_serializing_if = "is_false")]
522 shared_object_deletion: bool,
523
524 #[serde(skip_serializing_if = "is_false")]
526 narwhal_new_leader_election_schedule: bool,
527
528 #[serde(skip_serializing_if = "is_empty")]
530 zklogin_supported_providers: BTreeSet<String>,
531
532 #[serde(skip_serializing_if = "is_false")]
534 loaded_child_object_format: bool,
535
536 #[serde(skip_serializing_if = "is_false")]
537 enable_jwk_consensus_updates: bool,
538
539 #[serde(skip_serializing_if = "is_false")]
540 end_of_epoch_transaction_supported: bool,
541
542 #[serde(skip_serializing_if = "is_false")]
545 simple_conservation_checks: bool,
546
547 #[serde(skip_serializing_if = "is_false")]
549 loaded_child_object_format_type: bool,
550
551 #[serde(skip_serializing_if = "is_false")]
553 receive_objects: bool,
554
555 #[serde(skip_serializing_if = "is_false")]
557 consensus_checkpoint_signature_key_includes_digest: bool,
558
559 #[serde(skip_serializing_if = "is_false")]
561 random_beacon: bool,
562
563 #[serde(skip_serializing_if = "is_false")]
565 bridge: bool,
566
567 #[serde(skip_serializing_if = "is_false")]
568 enable_effects_v2: bool,
569
570 #[serde(skip_serializing_if = "is_false")]
572 narwhal_certificate_v2: bool,
573
574 #[serde(skip_serializing_if = "is_false")]
576 verify_legacy_zklogin_address: bool,
577
578 #[serde(skip_serializing_if = "is_false")]
580 throughput_aware_consensus_submission: bool,
581
582 #[serde(skip_serializing_if = "is_false")]
584 recompute_has_public_transfer_in_execution: bool,
585
586 #[serde(skip_serializing_if = "is_false")]
588 accept_zklogin_in_multisig: bool,
589
590 #[serde(skip_serializing_if = "is_false")]
592 accept_passkey_in_multisig: bool,
593
594 #[serde(skip_serializing_if = "is_false")]
596 validate_zklogin_public_identifier: bool,
597
598 #[serde(skip_serializing_if = "is_false")]
601 include_consensus_digest_in_prologue: bool,
602
603 #[serde(skip_serializing_if = "is_false")]
605 hardened_otw_check: bool,
606
607 #[serde(skip_serializing_if = "is_false")]
609 allow_receiving_object_id: bool,
610
611 #[serde(skip_serializing_if = "is_false")]
613 enable_poseidon: bool,
614
615 #[serde(skip_serializing_if = "is_false")]
617 enable_coin_deny_list: bool,
618
619 #[serde(skip_serializing_if = "is_false")]
621 enable_group_ops_native_functions: bool,
622
623 #[serde(skip_serializing_if = "is_false")]
625 enable_group_ops_native_function_msm: bool,
626
627 #[serde(skip_serializing_if = "is_false")]
629 enable_ristretto255_group_ops: bool,
630
631 #[serde(skip_serializing_if = "is_false")]
633 enable_verify_bulletproofs_ristretto255: bool,
634
635 #[serde(skip_serializing_if = "is_false")]
637 enable_nitro_attestation: bool,
638
639 #[serde(skip_serializing_if = "is_false")]
641 enable_nitro_attestation_upgraded_parsing: bool,
642
643 #[serde(skip_serializing_if = "is_false")]
645 enable_nitro_attestation_all_nonzero_pcrs_parsing: bool,
646
647 #[serde(skip_serializing_if = "is_false")]
649 enable_nitro_attestation_always_include_required_pcrs_parsing: bool,
650
651 #[serde(skip_serializing_if = "is_false")]
653 reject_mutable_random_on_entry_functions: bool,
654
655 #[serde(skip_serializing_if = "PerObjectCongestionControlMode::is_none")]
657 per_object_congestion_control_mode: PerObjectCongestionControlMode,
658
659 #[serde(skip_serializing_if = "ConsensusChoice::is_narwhal")]
661 consensus_choice: ConsensusChoice,
662
663 #[serde(skip_serializing_if = "ConsensusNetwork::is_anemo")]
665 consensus_network: ConsensusNetwork,
666
667 #[serde(skip_serializing_if = "is_false")]
669 correct_gas_payment_limit_check: bool,
670
671 #[serde(skip_serializing_if = "Option::is_none")]
673 zklogin_max_epoch_upper_bound_delta: Option<u64>,
674
675 #[serde(skip_serializing_if = "is_false")]
677 mysticeti_leader_scoring_and_schedule: bool,
678
679 #[serde(skip_serializing_if = "is_false")]
681 reshare_at_same_initial_version: bool,
682
683 #[serde(skip_serializing_if = "is_false")]
685 resolve_abort_locations_to_package_id: bool,
686
687 #[serde(skip_serializing_if = "is_false")]
691 mysticeti_use_committed_subdag_digest: bool,
692
693 #[serde(skip_serializing_if = "is_false")]
695 enable_vdf: bool,
696
697 #[serde(skip_serializing_if = "is_false")]
702 record_consensus_determined_version_assignments_in_prologue: bool,
703 #[serde(skip_serializing_if = "is_false")]
704 record_consensus_determined_version_assignments_in_prologue_v2: bool,
705
706 #[serde(skip_serializing_if = "is_false")]
708 fresh_vm_on_framework_upgrade: bool,
709
710 #[serde(skip_serializing_if = "is_false")]
718 prepend_prologue_tx_in_consensus_commit_in_checkpoints: bool,
719
720 #[serde(skip_serializing_if = "Option::is_none")]
722 mysticeti_num_leaders_per_round: Option<usize>,
723
724 #[serde(skip_serializing_if = "is_false")]
726 soft_bundle: bool,
727
728 #[serde(skip_serializing_if = "is_false")]
730 enable_coin_deny_list_v2: bool,
731
732 #[serde(skip_serializing_if = "is_false")]
734 passkey_auth: bool,
735
736 #[serde(skip_serializing_if = "is_false")]
738 authority_capabilities_v2: bool,
739
740 #[serde(skip_serializing_if = "is_false")]
742 rethrow_serialization_type_layout_errors: bool,
743
744 #[serde(skip_serializing_if = "is_false")]
746 consensus_distributed_vote_scoring_strategy: bool,
747
748 #[serde(skip_serializing_if = "is_false")]
750 consensus_round_prober: bool,
751
752 #[serde(skip_serializing_if = "is_false")]
754 validate_identifier_inputs: bool,
755
756 #[serde(skip_serializing_if = "is_false")]
758 disallow_self_identifier: bool,
759
760 #[serde(skip_serializing_if = "is_false")]
762 mysticeti_fastpath: bool,
763
764 #[serde(skip_serializing_if = "is_false")]
768 disable_preconsensus_locking: bool,
769
770 #[serde(skip_serializing_if = "is_false")]
772 relocate_event_module: bool,
773
774 #[serde(skip_serializing_if = "is_false")]
776 uncompressed_g1_group_elements: bool,
777
778 #[serde(skip_serializing_if = "is_false")]
779 disallow_new_modules_in_deps_only_packages: bool,
780
781 #[serde(skip_serializing_if = "is_false")]
783 consensus_smart_ancestor_selection: bool,
784
785 #[serde(skip_serializing_if = "is_false")]
787 consensus_round_prober_probe_accepted_rounds: bool,
788
789 #[serde(skip_serializing_if = "is_false")]
791 native_charging_v2: bool,
792
793 #[serde(skip_serializing_if = "is_false")]
796 consensus_linearize_subdag_v2: bool,
797
798 #[serde(skip_serializing_if = "is_false")]
800 convert_type_argument_error: bool,
801
802 #[serde(skip_serializing_if = "is_false")]
804 variant_nodes: bool,
805
806 #[serde(skip_serializing_if = "is_false")]
808 consensus_zstd_compression: bool,
809
810 #[serde(skip_serializing_if = "is_false")]
812 minimize_child_object_mutations: bool,
813
814 #[serde(skip_serializing_if = "is_false")]
816 record_additional_state_digest_in_prologue: bool,
817
818 #[serde(skip_serializing_if = "is_false")]
820 move_native_context: bool,
821
822 #[serde(skip_serializing_if = "is_false")]
825 consensus_median_based_commit_timestamp: bool,
826
827 #[serde(skip_serializing_if = "is_false")]
830 normalize_ptb_arguments: bool,
831
832 #[serde(skip_serializing_if = "is_false")]
834 consensus_batched_block_sync: bool,
835
836 #[serde(skip_serializing_if = "is_false")]
838 enforce_checkpoint_timestamp_monotonicity: bool,
839
840 #[serde(skip_serializing_if = "is_false")]
842 max_ptb_value_size_v2: bool,
843
844 #[serde(skip_serializing_if = "is_false")]
846 resolve_type_input_ids_to_defining_id: bool,
847
848 #[serde(skip_serializing_if = "is_false")]
850 enable_party_transfer: bool,
851
852 #[serde(skip_serializing_if = "is_false")]
854 allow_unbounded_system_objects: bool,
855
856 #[serde(skip_serializing_if = "is_false")]
858 type_tags_in_object_runtime: bool,
859
860 #[serde(skip_serializing_if = "is_false")]
862 enable_accumulators: bool,
863
864 #[serde(skip_serializing_if = "is_false")]
866 enable_coin_reservation_obj_refs: bool,
867
868 #[serde(skip_serializing_if = "is_false")]
871 create_root_accumulator_object: bool,
872
873 #[serde(skip_serializing_if = "is_false")]
875 enable_authenticated_event_streams: bool,
876
877 #[serde(skip_serializing_if = "is_false")]
879 enable_address_balance_gas_payments: bool,
880
881 #[serde(skip_serializing_if = "is_false")]
883 address_balance_gas_check_rgp_at_signing: bool,
884
885 #[serde(skip_serializing_if = "is_false")]
886 address_balance_gas_reject_gas_coin_arg: bool,
887
888 #[serde(skip_serializing_if = "is_false")]
890 enable_multi_epoch_transaction_expiration: bool,
891
892 #[serde(skip_serializing_if = "is_false")]
894 relax_valid_during_for_owned_inputs: bool,
895
896 #[serde(skip_serializing_if = "is_false")]
898 enable_ptb_execution_v2: bool,
899
900 #[serde(skip_serializing_if = "is_false")]
902 better_adapter_type_resolution_errors: bool,
903
904 #[serde(skip_serializing_if = "is_false")]
906 record_time_estimate_processed: bool,
907
908 #[serde(skip_serializing_if = "is_false")]
910 dependency_linkage_error: bool,
911
912 #[serde(skip_serializing_if = "is_false")]
914 additional_multisig_checks: bool,
915
916 #[serde(skip_serializing_if = "is_false")]
918 ignore_execution_time_observations_after_certs_closed: bool,
919
920 #[serde(skip_serializing_if = "is_false")]
924 debug_fatal_on_move_invariant_violation: bool,
925
926 #[serde(skip_serializing_if = "is_false")]
929 allow_private_accumulator_entrypoints: bool,
930
931 #[serde(skip_serializing_if = "is_false")]
933 additional_consensus_digest_indirect_state: bool,
934
935 #[serde(skip_serializing_if = "is_false")]
937 check_for_init_during_upgrade: bool,
938
939 #[serde(skip_serializing_if = "is_false")]
941 per_command_shared_object_transfer_rules: bool,
942
943 #[serde(skip_serializing_if = "is_false")]
945 include_checkpoint_artifacts_digest_in_summary: bool,
946
947 #[serde(skip_serializing_if = "is_false")]
949 use_mfp_txns_in_load_initial_object_debts: bool,
950
951 #[serde(skip_serializing_if = "is_false")]
953 cancel_for_failed_dkg_early: bool,
954
955 #[serde(skip_serializing_if = "is_false")]
957 enable_coin_registry: bool,
958
959 #[serde(skip_serializing_if = "is_false")]
961 abstract_size_in_object_runtime: bool,
962
963 #[serde(skip_serializing_if = "is_false")]
965 object_runtime_charge_cache_load_gas: bool,
966
967 #[serde(skip_serializing_if = "is_false")]
969 additional_borrow_checks: bool,
970
971 #[serde(skip_serializing_if = "is_false")]
973 use_new_commit_handler: bool,
974
975 #[serde(skip_serializing_if = "is_false")]
977 better_loader_errors: bool,
978
979 #[serde(skip_serializing_if = "is_false")]
981 generate_df_type_layouts: bool,
982
983 #[serde(skip_serializing_if = "is_false")]
985 allow_references_in_ptbs: bool,
986
987 #[serde(skip_serializing_if = "is_false")]
989 enable_display_registry: bool,
990
991 #[serde(skip_serializing_if = "is_false")]
993 private_generics_verifier_v2: bool,
994
995 #[serde(skip_serializing_if = "is_false")]
997 deprecate_global_storage_ops_during_deserialization: bool,
998
999 #[serde(skip_serializing_if = "is_false")]
1002 enable_non_exclusive_writes: bool,
1003
1004 #[serde(skip_serializing_if = "is_false")]
1006 deprecate_global_storage_ops: bool,
1007
1008 #[serde(skip_serializing_if = "is_false")]
1010 normalize_depth_formula: bool,
1011
1012 #[serde(skip_serializing_if = "is_false")]
1014 consensus_skip_gced_accept_votes: bool,
1015
1016 #[serde(skip_serializing_if = "is_false")]
1018 include_cancelled_randomness_txns_in_prologue: bool,
1019
1020 #[serde(skip_serializing_if = "is_false")]
1022 address_aliases: bool,
1023
1024 #[serde(skip_serializing_if = "is_false")]
1027 fix_checkpoint_signature_mapping: bool,
1028
1029 #[serde(skip_serializing_if = "is_false")]
1031 enable_object_funds_withdraw: bool,
1032
1033 #[serde(skip_serializing_if = "is_false")]
1035 consensus_skip_gced_blocks_in_direct_finalization: bool,
1036
1037 #[serde(skip_serializing_if = "is_false")]
1039 gas_rounding_halve_digits: bool,
1040
1041 #[serde(skip_serializing_if = "is_false")]
1043 flexible_tx_context_positions: bool,
1044
1045 #[serde(skip_serializing_if = "is_false")]
1047 disable_entry_point_signature_check: bool,
1048
1049 #[serde(skip_serializing_if = "is_false")]
1051 convert_withdrawal_compatibility_ptb_arguments: bool,
1052
1053 #[serde(skip_serializing_if = "is_false")]
1055 restrict_hot_or_not_entry_functions: bool,
1056
1057 #[serde(skip_serializing_if = "is_false")]
1059 split_checkpoints_in_consensus_handler: bool,
1060
1061 #[serde(skip_serializing_if = "is_false")]
1063 consensus_always_accept_system_transactions: bool,
1064
1065 #[serde(skip_serializing_if = "is_false")]
1067 validator_metadata_verify_v2: bool,
1068
1069 #[serde(skip_serializing_if = "is_false")]
1072 defer_unpaid_amplification: bool,
1073
1074 #[serde(skip_serializing_if = "is_false")]
1075 randomize_checkpoint_tx_limit_in_tests: bool,
1076
1077 #[serde(skip_serializing_if = "is_false")]
1079 gasless_transaction_drop_safety: bool,
1080
1081 #[serde(skip_serializing_if = "is_false")]
1083 merge_randomness_into_checkpoint: bool,
1084
1085 #[serde(skip_serializing_if = "is_false")]
1087 use_coin_party_owner: bool,
1088
1089 #[serde(skip_serializing_if = "is_false")]
1090 enable_gasless: bool,
1091
1092 #[serde(skip_serializing_if = "is_false")]
1093 gasless_verify_remaining_balance: bool,
1094
1095 #[serde(skip_serializing_if = "is_false")]
1096 disallow_jump_orphans: bool,
1097
1098 #[serde(skip_serializing_if = "is_false")]
1100 early_return_receive_object_mismatched_type: bool,
1101
1102 #[serde(skip_serializing_if = "is_false")]
1107 timestamp_based_epoch_close: bool,
1108
1109 #[serde(skip_serializing_if = "is_false")]
1112 limit_groth16_pvk_inputs: bool,
1113
1114 #[serde(skip_serializing_if = "is_false")]
1119 enforce_address_balance_change_invariant: bool,
1120
1121 #[serde(skip_serializing_if = "is_false")]
1123 granular_post_execution_checks: bool,
1124
1125 #[serde(skip_serializing_if = "is_false")]
1127 early_exit_on_iffw: bool,
1128}
1129
1130fn is_false(b: &bool) -> bool {
1131 !b
1132}
1133
1134fn is_empty(b: &BTreeSet<String>) -> bool {
1135 b.is_empty()
1136}
1137
1138fn is_zero(val: &u64) -> bool {
1139 *val == 0
1140}
1141
1142#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1144pub enum ConsensusTransactionOrdering {
1145 #[default]
1147 None,
1148 ByGasPrice,
1150}
1151
1152impl ConsensusTransactionOrdering {
1153 pub fn is_none(&self) -> bool {
1154 matches!(self, ConsensusTransactionOrdering::None)
1155 }
1156}
1157
1158#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1159pub struct ExecutionTimeEstimateParams {
1160 pub target_utilization: u64,
1162 pub allowed_txn_cost_overage_burst_limit_us: u64,
1166
1167 pub randomness_scalar: u64,
1170
1171 pub max_estimate_us: u64,
1173
1174 pub stored_observations_num_included_checkpoints: u64,
1177
1178 pub stored_observations_limit: u64,
1180
1181 #[serde(skip_serializing_if = "is_zero")]
1184 pub stake_weighted_median_threshold: u64,
1185
1186 #[serde(skip_serializing_if = "is_false")]
1190 pub default_none_duration_for_new_keys: bool,
1191
1192 #[serde(skip_serializing_if = "Option::is_none")]
1194 pub observations_chunk_size: Option<u64>,
1195}
1196
1197#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1199pub enum PerObjectCongestionControlMode {
1200 #[default]
1201 None, TotalGasBudget, TotalTxCount, TotalGasBudgetWithCap, ExecutionTimeEstimate(ExecutionTimeEstimateParams), }
1207
1208impl PerObjectCongestionControlMode {
1209 pub fn is_none(&self) -> bool {
1210 matches!(self, PerObjectCongestionControlMode::None)
1211 }
1212}
1213
1214#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1216pub enum ConsensusChoice {
1217 #[default]
1218 Narwhal,
1219 SwapEachEpoch,
1220 Mysticeti,
1221}
1222
1223impl ConsensusChoice {
1224 pub fn is_narwhal(&self) -> bool {
1225 matches!(self, ConsensusChoice::Narwhal)
1226 }
1227}
1228
1229#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1231pub enum ConsensusNetwork {
1232 #[default]
1233 Anemo,
1234 Tonic,
1235}
1236
1237impl ConsensusNetwork {
1238 pub fn is_anemo(&self) -> bool {
1239 matches!(self, ConsensusNetwork::Anemo)
1240 }
1241}
1242
1243#[skip_serializing_none]
1275#[derive(Clone, Serialize, Debug, ProtocolConfigAccessors, ProtocolConfigOverride)]
1276pub struct ProtocolConfig {
1277 pub version: ProtocolVersion,
1278
1279 feature_flags: FeatureFlags,
1280
1281 max_tx_size_bytes: Option<u64>,
1284
1285 max_input_objects: Option<u64>,
1287
1288 max_size_written_objects: Option<u64>,
1292 max_size_written_objects_system_tx: Option<u64>,
1295
1296 max_serialized_tx_effects_size_bytes: Option<u64>,
1298
1299 max_serialized_tx_effects_size_bytes_system_tx: Option<u64>,
1301
1302 max_gas_payment_objects: Option<u32>,
1304
1305 max_modules_in_publish: Option<u32>,
1307
1308 max_package_dependencies: Option<u32>,
1310
1311 max_arguments: Option<u32>,
1314
1315 max_type_arguments: Option<u32>,
1317
1318 max_type_argument_depth: Option<u32>,
1320
1321 max_pure_argument_size: Option<u32>,
1323
1324 max_programmable_tx_commands: Option<u32>,
1326
1327 move_binary_format_version: Option<u32>,
1330 min_move_binary_format_version: Option<u32>,
1331
1332 binary_module_handles: Option<u16>,
1334 binary_struct_handles: Option<u16>,
1335 binary_function_handles: Option<u16>,
1336 binary_function_instantiations: Option<u16>,
1337 binary_signatures: Option<u16>,
1338 binary_constant_pool: Option<u16>,
1339 binary_identifiers: Option<u16>,
1340 binary_address_identifiers: Option<u16>,
1341 binary_struct_defs: Option<u16>,
1342 binary_struct_def_instantiations: Option<u16>,
1343 binary_function_defs: Option<u16>,
1344 binary_field_handles: Option<u16>,
1345 binary_field_instantiations: Option<u16>,
1346 binary_friend_decls: Option<u16>,
1347 binary_enum_defs: Option<u16>,
1348 binary_enum_def_instantiations: Option<u16>,
1349 binary_variant_handles: Option<u16>,
1350 binary_variant_instantiation_handles: Option<u16>,
1351
1352 max_move_object_size: Option<u64>,
1354
1355 max_move_package_size: Option<u64>,
1358
1359 max_publish_or_upgrade_per_ptb: Option<u64>,
1361
1362 max_tx_gas: Option<u64>,
1364
1365 max_gas_price: Option<u64>,
1367
1368 max_gas_price_rgp_factor_for_aborted_transactions: Option<u64>,
1371
1372 max_gas_computation_bucket: Option<u64>,
1374
1375 gas_rounding_step: Option<u64>,
1377
1378 max_loop_depth: Option<u64>,
1380
1381 max_generic_instantiation_length: Option<u64>,
1383
1384 max_function_parameters: Option<u64>,
1386
1387 max_basic_blocks: Option<u64>,
1389
1390 max_value_stack_size: Option<u64>,
1392
1393 max_type_nodes: Option<u64>,
1395
1396 max_push_size: Option<u64>,
1398
1399 max_struct_definitions: Option<u64>,
1401
1402 max_function_definitions: Option<u64>,
1404
1405 max_fields_in_struct: Option<u64>,
1407
1408 max_dependency_depth: Option<u64>,
1410
1411 max_num_event_emit: Option<u64>,
1413
1414 max_num_new_move_object_ids: Option<u64>,
1416
1417 max_num_new_move_object_ids_system_tx: Option<u64>,
1419
1420 max_num_deleted_move_object_ids: Option<u64>,
1422
1423 max_num_deleted_move_object_ids_system_tx: Option<u64>,
1425
1426 max_num_transferred_move_object_ids: Option<u64>,
1428
1429 max_num_transferred_move_object_ids_system_tx: Option<u64>,
1431
1432 max_event_emit_size: Option<u64>,
1434
1435 max_event_emit_size_total: Option<u64>,
1437
1438 max_move_vector_len: Option<u64>,
1440
1441 max_move_identifier_len: Option<u64>,
1443
1444 max_move_value_depth: Option<u64>,
1446
1447 max_move_enum_variants: Option<u64>,
1449
1450 max_back_edges_per_function: Option<u64>,
1452
1453 max_back_edges_per_module: Option<u64>,
1455
1456 max_verifier_meter_ticks_per_function: Option<u64>,
1458
1459 max_meter_ticks_per_module: Option<u64>,
1461
1462 max_meter_ticks_per_package: Option<u64>,
1464
1465 object_runtime_max_num_cached_objects: Option<u64>,
1469
1470 object_runtime_max_num_cached_objects_system_tx: Option<u64>,
1472
1473 object_runtime_max_num_store_entries: Option<u64>,
1475
1476 object_runtime_max_num_store_entries_system_tx: Option<u64>,
1478
1479 base_tx_cost_fixed: Option<u64>,
1482
1483 package_publish_cost_fixed: Option<u64>,
1486
1487 base_tx_cost_per_byte: Option<u64>,
1490
1491 package_publish_cost_per_byte: Option<u64>,
1493
1494 obj_access_cost_read_per_byte: Option<u64>,
1496
1497 obj_access_cost_mutate_per_byte: Option<u64>,
1499
1500 obj_access_cost_delete_per_byte: Option<u64>,
1502
1503 obj_access_cost_verify_per_byte: Option<u64>,
1513
1514 max_type_to_layout_nodes: Option<u64>,
1516
1517 max_ptb_value_size: Option<u64>,
1519
1520 gas_model_version: Option<u64>,
1523
1524 obj_data_cost_refundable: Option<u64>,
1527
1528 obj_metadata_cost_non_refundable: Option<u64>,
1532
1533 storage_rebate_rate: Option<u64>,
1539
1540 storage_fund_reinvest_rate: Option<u64>,
1543
1544 reward_slashing_rate: Option<u64>,
1547
1548 storage_gas_price: Option<u64>,
1550
1551 accumulator_object_storage_cost: Option<u64>,
1553
1554 max_transactions_per_checkpoint: Option<u64>,
1559
1560 max_checkpoint_size_bytes: Option<u64>,
1564
1565 buffer_stake_for_protocol_upgrade_bps: Option<u64>,
1570
1571 address_from_bytes_cost_base: Option<u64>,
1576 address_to_u256_cost_base: Option<u64>,
1578 address_from_u256_cost_base: Option<u64>,
1580
1581 config_read_setting_impl_cost_base: Option<u64>,
1586 config_read_setting_impl_cost_per_byte: Option<u64>,
1587
1588 dynamic_field_hash_type_and_key_cost_base: Option<u64>,
1591 dynamic_field_hash_type_and_key_type_cost_per_byte: Option<u64>,
1592 dynamic_field_hash_type_and_key_value_cost_per_byte: Option<u64>,
1593 dynamic_field_hash_type_and_key_type_tag_cost_per_byte: Option<u64>,
1594 dynamic_field_add_child_object_cost_base: Option<u64>,
1596 dynamic_field_add_child_object_type_cost_per_byte: Option<u64>,
1597 dynamic_field_add_child_object_value_cost_per_byte: Option<u64>,
1598 dynamic_field_add_child_object_struct_tag_cost_per_byte: Option<u64>,
1599 dynamic_field_borrow_child_object_cost_base: Option<u64>,
1601 dynamic_field_borrow_child_object_child_ref_cost_per_byte: Option<u64>,
1602 dynamic_field_borrow_child_object_type_cost_per_byte: Option<u64>,
1603 dynamic_field_remove_child_object_cost_base: Option<u64>,
1605 dynamic_field_remove_child_object_child_cost_per_byte: Option<u64>,
1606 dynamic_field_remove_child_object_type_cost_per_byte: Option<u64>,
1607 dynamic_field_has_child_object_cost_base: Option<u64>,
1609 dynamic_field_has_child_object_with_ty_cost_base: Option<u64>,
1611 dynamic_field_has_child_object_with_ty_type_cost_per_byte: Option<u64>,
1612 dynamic_field_has_child_object_with_ty_type_tag_cost_per_byte: Option<u64>,
1613
1614 event_emit_cost_base: Option<u64>,
1617 event_emit_value_size_derivation_cost_per_byte: Option<u64>,
1618 event_emit_tag_size_derivation_cost_per_byte: Option<u64>,
1619 event_emit_output_cost_per_byte: Option<u64>,
1620 event_emit_auth_stream_cost: Option<u64>,
1621
1622 object_borrow_uid_cost_base: Option<u64>,
1625 object_delete_impl_cost_base: Option<u64>,
1627 object_record_new_uid_cost_base: Option<u64>,
1629
1630 transfer_transfer_internal_cost_base: Option<u64>,
1633 transfer_party_transfer_internal_cost_base: Option<u64>,
1635 transfer_freeze_object_cost_base: Option<u64>,
1637 transfer_share_object_cost_base: Option<u64>,
1639 transfer_receive_object_cost_base: Option<u64>,
1642 transfer_receive_object_cost_per_byte: Option<u64>,
1643 transfer_receive_object_type_cost_per_byte: Option<u64>,
1644
1645 tx_context_derive_id_cost_base: Option<u64>,
1648 tx_context_fresh_id_cost_base: Option<u64>,
1649 tx_context_sender_cost_base: Option<u64>,
1650 tx_context_epoch_cost_base: Option<u64>,
1651 tx_context_epoch_timestamp_ms_cost_base: Option<u64>,
1652 tx_context_sponsor_cost_base: Option<u64>,
1653 tx_context_rgp_cost_base: Option<u64>,
1654 tx_context_gas_price_cost_base: Option<u64>,
1655 tx_context_gas_budget_cost_base: Option<u64>,
1656 tx_context_ids_created_cost_base: Option<u64>,
1657 tx_context_replace_cost_base: Option<u64>,
1658
1659 types_is_one_time_witness_cost_base: Option<u64>,
1662 types_is_one_time_witness_type_tag_cost_per_byte: Option<u64>,
1663 types_is_one_time_witness_type_cost_per_byte: Option<u64>,
1664
1665 validator_validate_metadata_cost_base: Option<u64>,
1668 validator_validate_metadata_data_cost_per_byte: Option<u64>,
1669
1670 crypto_invalid_arguments_cost: Option<u64>,
1672 bls12381_bls12381_min_sig_verify_cost_base: Option<u64>,
1674 bls12381_bls12381_min_sig_verify_msg_cost_per_byte: Option<u64>,
1675 bls12381_bls12381_min_sig_verify_msg_cost_per_block: Option<u64>,
1676
1677 bls12381_bls12381_min_pk_verify_cost_base: Option<u64>,
1679 bls12381_bls12381_min_pk_verify_msg_cost_per_byte: Option<u64>,
1680 bls12381_bls12381_min_pk_verify_msg_cost_per_block: Option<u64>,
1681
1682 ecdsa_k1_ecrecover_keccak256_cost_base: Option<u64>,
1684 ecdsa_k1_ecrecover_keccak256_msg_cost_per_byte: Option<u64>,
1685 ecdsa_k1_ecrecover_keccak256_msg_cost_per_block: Option<u64>,
1686 ecdsa_k1_ecrecover_sha256_cost_base: Option<u64>,
1687 ecdsa_k1_ecrecover_sha256_msg_cost_per_byte: Option<u64>,
1688 ecdsa_k1_ecrecover_sha256_msg_cost_per_block: Option<u64>,
1689
1690 ecdsa_k1_decompress_pubkey_cost_base: Option<u64>,
1692
1693 ecdsa_k1_secp256k1_verify_keccak256_cost_base: Option<u64>,
1695 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_byte: Option<u64>,
1696 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_block: Option<u64>,
1697 ecdsa_k1_secp256k1_verify_sha256_cost_base: Option<u64>,
1698 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_byte: Option<u64>,
1699 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_block: Option<u64>,
1700
1701 ecdsa_r1_ecrecover_keccak256_cost_base: Option<u64>,
1703 ecdsa_r1_ecrecover_keccak256_msg_cost_per_byte: Option<u64>,
1704 ecdsa_r1_ecrecover_keccak256_msg_cost_per_block: Option<u64>,
1705 ecdsa_r1_ecrecover_sha256_cost_base: Option<u64>,
1706 ecdsa_r1_ecrecover_sha256_msg_cost_per_byte: Option<u64>,
1707 ecdsa_r1_ecrecover_sha256_msg_cost_per_block: Option<u64>,
1708
1709 ecdsa_r1_secp256r1_verify_keccak256_cost_base: Option<u64>,
1711 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_byte: Option<u64>,
1712 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_block: Option<u64>,
1713 ecdsa_r1_secp256r1_verify_sha256_cost_base: Option<u64>,
1714 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_byte: Option<u64>,
1715 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_block: Option<u64>,
1716
1717 ecvrf_ecvrf_verify_cost_base: Option<u64>,
1719 ecvrf_ecvrf_verify_alpha_string_cost_per_byte: Option<u64>,
1720 ecvrf_ecvrf_verify_alpha_string_cost_per_block: Option<u64>,
1721
1722 ed25519_ed25519_verify_cost_base: Option<u64>,
1724 ed25519_ed25519_verify_msg_cost_per_byte: Option<u64>,
1725 ed25519_ed25519_verify_msg_cost_per_block: Option<u64>,
1726
1727 groth16_prepare_verifying_key_bls12381_cost_base: Option<u64>,
1729 groth16_prepare_verifying_key_bn254_cost_base: Option<u64>,
1730
1731 groth16_verify_groth16_proof_internal_bls12381_cost_base: Option<u64>,
1733 groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input: Option<u64>,
1734 groth16_verify_groth16_proof_internal_bn254_cost_base: Option<u64>,
1735 groth16_verify_groth16_proof_internal_bn254_cost_per_public_input: Option<u64>,
1736 groth16_verify_groth16_proof_internal_public_input_cost_per_byte: Option<u64>,
1737
1738 hash_blake2b256_cost_base: Option<u64>,
1740 hash_blake2b256_data_cost_per_byte: Option<u64>,
1741 hash_blake2b256_data_cost_per_block: Option<u64>,
1742
1743 hash_keccak256_cost_base: Option<u64>,
1745 hash_keccak256_data_cost_per_byte: Option<u64>,
1746 hash_keccak256_data_cost_per_block: Option<u64>,
1747
1748 poseidon_bn254_cost_base: Option<u64>,
1750 poseidon_bn254_cost_per_block: Option<u64>,
1751
1752 group_ops_bls12381_decode_scalar_cost: Option<u64>,
1754 group_ops_bls12381_decode_g1_cost: Option<u64>,
1755 group_ops_bls12381_decode_g2_cost: Option<u64>,
1756 group_ops_bls12381_decode_gt_cost: Option<u64>,
1757 group_ops_bls12381_scalar_add_cost: Option<u64>,
1758 group_ops_bls12381_g1_add_cost: Option<u64>,
1759 group_ops_bls12381_g2_add_cost: Option<u64>,
1760 group_ops_bls12381_gt_add_cost: Option<u64>,
1761 group_ops_bls12381_scalar_sub_cost: Option<u64>,
1762 group_ops_bls12381_g1_sub_cost: Option<u64>,
1763 group_ops_bls12381_g2_sub_cost: Option<u64>,
1764 group_ops_bls12381_gt_sub_cost: Option<u64>,
1765 group_ops_bls12381_scalar_mul_cost: Option<u64>,
1766 group_ops_bls12381_g1_mul_cost: Option<u64>,
1767 group_ops_bls12381_g2_mul_cost: Option<u64>,
1768 group_ops_bls12381_gt_mul_cost: Option<u64>,
1769 group_ops_bls12381_scalar_div_cost: Option<u64>,
1770 group_ops_bls12381_g1_div_cost: Option<u64>,
1771 group_ops_bls12381_g2_div_cost: Option<u64>,
1772 group_ops_bls12381_gt_div_cost: Option<u64>,
1773 group_ops_bls12381_g1_hash_to_base_cost: Option<u64>,
1774 group_ops_bls12381_g2_hash_to_base_cost: Option<u64>,
1775 group_ops_bls12381_g1_hash_to_cost_per_byte: Option<u64>,
1776 group_ops_bls12381_g2_hash_to_cost_per_byte: Option<u64>,
1777 group_ops_bls12381_g1_msm_base_cost: Option<u64>,
1778 group_ops_bls12381_g2_msm_base_cost: Option<u64>,
1779 group_ops_bls12381_g1_msm_base_cost_per_input: Option<u64>,
1780 group_ops_bls12381_g2_msm_base_cost_per_input: Option<u64>,
1781 group_ops_bls12381_msm_max_len: Option<u32>,
1782 group_ops_bls12381_pairing_cost: Option<u64>,
1783 group_ops_bls12381_g1_to_uncompressed_g1_cost: Option<u64>,
1784 group_ops_bls12381_uncompressed_g1_to_g1_cost: Option<u64>,
1785 group_ops_bls12381_uncompressed_g1_sum_base_cost: Option<u64>,
1786 group_ops_bls12381_uncompressed_g1_sum_cost_per_term: Option<u64>,
1787 group_ops_bls12381_uncompressed_g1_sum_max_terms: Option<u64>,
1788
1789 group_ops_ristretto_decode_scalar_cost: Option<u64>,
1790 group_ops_ristretto_decode_point_cost: Option<u64>,
1791 group_ops_ristretto_scalar_add_cost: Option<u64>,
1792 group_ops_ristretto_point_add_cost: Option<u64>,
1793 group_ops_ristretto_scalar_sub_cost: Option<u64>,
1794 group_ops_ristretto_point_sub_cost: Option<u64>,
1795 group_ops_ristretto_scalar_mul_cost: Option<u64>,
1796 group_ops_ristretto_point_mul_cost: Option<u64>,
1797 group_ops_ristretto_scalar_div_cost: Option<u64>,
1798 group_ops_ristretto_point_div_cost: Option<u64>,
1799
1800 verify_bulletproofs_ristretto255_base_cost: Option<u64>,
1801 verify_bulletproofs_ristretto255_cost_per_bit_and_commitment: Option<u64>,
1802
1803 hmac_hmac_sha3_256_cost_base: Option<u64>,
1805 hmac_hmac_sha3_256_input_cost_per_byte: Option<u64>,
1806 hmac_hmac_sha3_256_input_cost_per_block: Option<u64>,
1807
1808 check_zklogin_id_cost_base: Option<u64>,
1810 check_zklogin_issuer_cost_base: Option<u64>,
1812
1813 vdf_verify_vdf_cost: Option<u64>,
1814 vdf_hash_to_input_cost: Option<u64>,
1815
1816 nitro_attestation_parse_base_cost: Option<u64>,
1818 nitro_attestation_parse_cost_per_byte: Option<u64>,
1819 nitro_attestation_verify_base_cost: Option<u64>,
1820 nitro_attestation_verify_cost_per_cert: Option<u64>,
1821
1822 bcs_per_byte_serialized_cost: Option<u64>,
1824 bcs_legacy_min_output_size_cost: Option<u64>,
1825 bcs_failure_cost: Option<u64>,
1826
1827 hash_sha2_256_base_cost: Option<u64>,
1828 hash_sha2_256_per_byte_cost: Option<u64>,
1829 hash_sha2_256_legacy_min_input_len_cost: Option<u64>,
1830 hash_sha3_256_base_cost: Option<u64>,
1831 hash_sha3_256_per_byte_cost: Option<u64>,
1832 hash_sha3_256_legacy_min_input_len_cost: Option<u64>,
1833 type_name_get_base_cost: Option<u64>,
1834 type_name_get_per_byte_cost: Option<u64>,
1835 type_name_id_base_cost: Option<u64>,
1836
1837 string_check_utf8_base_cost: Option<u64>,
1838 string_check_utf8_per_byte_cost: Option<u64>,
1839 string_is_char_boundary_base_cost: Option<u64>,
1840 string_sub_string_base_cost: Option<u64>,
1841 string_sub_string_per_byte_cost: Option<u64>,
1842 string_index_of_base_cost: Option<u64>,
1843 string_index_of_per_byte_pattern_cost: Option<u64>,
1844 string_index_of_per_byte_searched_cost: Option<u64>,
1845
1846 vector_empty_base_cost: Option<u64>,
1847 vector_length_base_cost: Option<u64>,
1848 vector_push_back_base_cost: Option<u64>,
1849 vector_push_back_legacy_per_abstract_memory_unit_cost: Option<u64>,
1850 vector_borrow_base_cost: Option<u64>,
1851 vector_pop_back_base_cost: Option<u64>,
1852 vector_destroy_empty_base_cost: Option<u64>,
1853 vector_swap_base_cost: Option<u64>,
1854 debug_print_base_cost: Option<u64>,
1855 debug_print_stack_trace_base_cost: Option<u64>,
1856
1857 execution_version: Option<u64>,
1866
1867 consensus_bad_nodes_stake_threshold: Option<u64>,
1871
1872 max_jwk_votes_per_validator_per_epoch: Option<u64>,
1873 max_age_of_jwk_in_epochs: Option<u64>,
1877
1878 random_beacon_reduction_allowed_delta: Option<u16>,
1882
1883 random_beacon_reduction_lower_bound: Option<u32>,
1886
1887 random_beacon_dkg_timeout_round: Option<u32>,
1890
1891 random_beacon_min_round_interval_ms: Option<u64>,
1893
1894 random_beacon_dkg_version: Option<u64>,
1897
1898 consensus_max_transaction_size_bytes: Option<u64>,
1901 consensus_max_transactions_in_block_bytes: Option<u64>,
1903 consensus_max_num_transactions_in_block: Option<u64>,
1905
1906 consensus_voting_rounds: Option<u32>,
1908
1909 max_accumulated_txn_cost_per_object_in_narwhal_commit: Option<u64>,
1911
1912 max_deferral_rounds_for_congestion_control: Option<u64>,
1915
1916 max_txn_cost_overage_per_object_in_commit: Option<u64>,
1918
1919 allowed_txn_cost_overage_burst_per_object_in_commit: Option<u64>,
1921
1922 min_checkpoint_interval_ms: Option<u64>,
1924
1925 checkpoint_summary_version_specific_data: Option<u64>,
1927
1928 max_soft_bundle_size: Option<u64>,
1930
1931 bridge_should_try_to_finalize_committee: Option<bool>,
1935
1936 max_accumulated_txn_cost_per_object_in_mysticeti_commit: Option<u64>,
1942
1943 max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit: Option<u64>,
1946
1947 consensus_gc_depth: Option<u32>,
1950
1951 gas_budget_based_txn_cost_cap_factor: Option<u64>,
1953
1954 gas_budget_based_txn_cost_absolute_cap_commit_count: Option<u64>,
1956
1957 sip_45_consensus_amplification_threshold: Option<u64>,
1960
1961 use_object_per_epoch_marker_table_v2: Option<bool>,
1964
1965 consensus_commit_rate_estimation_window_size: Option<u32>,
1967
1968 #[serde(skip_serializing_if = "Vec::is_empty")]
1972 aliased_addresses: Vec<AliasedAddress>,
1973
1974 translation_per_command_base_charge: Option<u64>,
1977
1978 translation_per_input_base_charge: Option<u64>,
1981
1982 translation_pure_input_per_byte_charge: Option<u64>,
1984
1985 translation_per_type_node_charge: Option<u64>,
1989
1990 translation_per_reference_node_charge: Option<u64>,
1993
1994 translation_per_linkage_entry_charge: Option<u64>,
1997
1998 max_updates_per_settlement_txn: Option<u32>,
2000
2001 gasless_max_computation_units: Option<u64>,
2003
2004 gasless_allowed_token_types: Option<Vec<(String, u64)>>,
2006
2007 gasless_max_unused_inputs: Option<u64>,
2011
2012 gasless_max_pure_input_bytes: Option<u64>,
2015
2016 gasless_max_tps: Option<u64>,
2018
2019 #[serde(skip_serializing_if = "Option::is_none")]
2020 #[skip_accessor]
2021 include_special_package_amendments: Option<Arc<Amendments>>,
2022
2023 gasless_max_tx_size_bytes: Option<u64>,
2026}
2027
2028#[derive(Clone, Serialize, Deserialize, Debug)]
2030pub struct AliasedAddress {
2031 pub original: [u8; 32],
2033 pub aliased: [u8; 32],
2035 pub allowed_tx_digests: Vec<[u8; 32]>,
2037}
2038
2039impl ProtocolConfig {
2041 pub fn check_package_upgrades_supported(&self) -> Result<(), Error> {
2054 if self.feature_flags.package_upgrades {
2055 Ok(())
2056 } else {
2057 Err(Error(format!(
2058 "package upgrades are not supported at {:?}",
2059 self.version
2060 )))
2061 }
2062 }
2063
2064 pub fn allow_receiving_object_id(&self) -> bool {
2065 self.feature_flags.allow_receiving_object_id
2066 }
2067
2068 pub fn receiving_objects_supported(&self) -> bool {
2069 self.feature_flags.receive_objects
2070 }
2071
2072 pub fn package_upgrades_supported(&self) -> bool {
2073 self.feature_flags.package_upgrades
2074 }
2075
2076 pub fn check_commit_root_state_digest_supported(&self) -> bool {
2077 self.feature_flags.commit_root_state_digest
2078 }
2079
2080 pub fn get_advance_epoch_start_time_in_safe_mode(&self) -> bool {
2081 self.feature_flags.advance_epoch_start_time_in_safe_mode
2082 }
2083
2084 pub fn loaded_child_objects_fixed(&self) -> bool {
2085 self.feature_flags.loaded_child_objects_fixed
2086 }
2087
2088 pub fn missing_type_is_compatibility_error(&self) -> bool {
2089 self.feature_flags.missing_type_is_compatibility_error
2090 }
2091
2092 pub fn scoring_decision_with_validity_cutoff(&self) -> bool {
2093 self.feature_flags.scoring_decision_with_validity_cutoff
2094 }
2095
2096 pub fn narwhal_versioned_metadata(&self) -> bool {
2097 self.feature_flags.narwhal_versioned_metadata
2098 }
2099
2100 pub fn consensus_order_end_of_epoch_last(&self) -> bool {
2101 self.feature_flags.consensus_order_end_of_epoch_last
2102 }
2103
2104 pub fn disallow_adding_abilities_on_upgrade(&self) -> bool {
2105 self.feature_flags.disallow_adding_abilities_on_upgrade
2106 }
2107
2108 pub fn disable_invariant_violation_check_in_swap_loc(&self) -> bool {
2109 self.feature_flags
2110 .disable_invariant_violation_check_in_swap_loc
2111 }
2112
2113 pub fn advance_to_highest_supported_protocol_version(&self) -> bool {
2114 self.feature_flags
2115 .advance_to_highest_supported_protocol_version
2116 }
2117
2118 pub fn ban_entry_init(&self) -> bool {
2119 self.feature_flags.ban_entry_init
2120 }
2121
2122 pub fn package_digest_hash_module(&self) -> bool {
2123 self.feature_flags.package_digest_hash_module
2124 }
2125
2126 pub fn disallow_change_struct_type_params_on_upgrade(&self) -> bool {
2127 self.feature_flags
2128 .disallow_change_struct_type_params_on_upgrade
2129 }
2130
2131 pub fn no_extraneous_module_bytes(&self) -> bool {
2132 self.feature_flags.no_extraneous_module_bytes
2133 }
2134
2135 pub fn zklogin_auth(&self) -> bool {
2136 self.feature_flags.zklogin_auth
2137 }
2138
2139 pub fn zklogin_supported_providers(&self) -> &BTreeSet<String> {
2140 &self.feature_flags.zklogin_supported_providers
2141 }
2142
2143 pub fn consensus_transaction_ordering(&self) -> ConsensusTransactionOrdering {
2144 self.feature_flags.consensus_transaction_ordering
2145 }
2146
2147 pub fn simplified_unwrap_then_delete(&self) -> bool {
2148 self.feature_flags.simplified_unwrap_then_delete
2149 }
2150
2151 pub fn supports_upgraded_multisig(&self) -> bool {
2152 self.feature_flags.upgraded_multisig_supported
2153 }
2154
2155 pub fn txn_base_cost_as_multiplier(&self) -> bool {
2156 self.feature_flags.txn_base_cost_as_multiplier
2157 }
2158
2159 pub fn shared_object_deletion(&self) -> bool {
2160 self.feature_flags.shared_object_deletion
2161 }
2162
2163 pub fn narwhal_new_leader_election_schedule(&self) -> bool {
2164 self.feature_flags.narwhal_new_leader_election_schedule
2165 }
2166
2167 pub fn loaded_child_object_format(&self) -> bool {
2168 self.feature_flags.loaded_child_object_format
2169 }
2170
2171 pub fn enable_jwk_consensus_updates(&self) -> bool {
2172 let ret = self.feature_flags.enable_jwk_consensus_updates;
2173 if ret {
2174 assert!(self.feature_flags.end_of_epoch_transaction_supported);
2176 }
2177 ret
2178 }
2179
2180 pub fn simple_conservation_checks(&self) -> bool {
2181 self.feature_flags.simple_conservation_checks
2182 }
2183
2184 pub fn loaded_child_object_format_type(&self) -> bool {
2185 self.feature_flags.loaded_child_object_format_type
2186 }
2187
2188 pub fn end_of_epoch_transaction_supported(&self) -> bool {
2189 let ret = self.feature_flags.end_of_epoch_transaction_supported;
2190 if !ret {
2191 assert!(!self.feature_flags.enable_jwk_consensus_updates);
2193 }
2194 ret
2195 }
2196
2197 pub fn recompute_has_public_transfer_in_execution(&self) -> bool {
2198 self.feature_flags
2199 .recompute_has_public_transfer_in_execution
2200 }
2201
2202 pub fn create_authenticator_state_in_genesis(&self) -> bool {
2204 self.enable_jwk_consensus_updates()
2205 }
2206
2207 pub fn random_beacon(&self) -> bool {
2208 self.feature_flags.random_beacon
2209 }
2210
2211 pub fn dkg_version(&self) -> u64 {
2212 self.random_beacon_dkg_version.unwrap_or(1)
2214 }
2215
2216 pub fn enable_bridge(&self) -> bool {
2217 let ret = self.feature_flags.bridge;
2218 if ret {
2219 assert!(self.feature_flags.end_of_epoch_transaction_supported);
2221 }
2222 ret
2223 }
2224
2225 pub fn should_try_to_finalize_bridge_committee(&self) -> bool {
2226 if !self.enable_bridge() {
2227 return false;
2228 }
2229 self.bridge_should_try_to_finalize_committee.unwrap_or(true)
2231 }
2232
2233 pub fn enable_effects_v2(&self) -> bool {
2234 self.feature_flags.enable_effects_v2
2235 }
2236
2237 pub fn narwhal_certificate_v2(&self) -> bool {
2238 self.feature_flags.narwhal_certificate_v2
2239 }
2240
2241 pub fn verify_legacy_zklogin_address(&self) -> bool {
2242 self.feature_flags.verify_legacy_zklogin_address
2243 }
2244
2245 pub fn accept_zklogin_in_multisig(&self) -> bool {
2246 self.feature_flags.accept_zklogin_in_multisig
2247 }
2248
2249 pub fn accept_passkey_in_multisig(&self) -> bool {
2250 self.feature_flags.accept_passkey_in_multisig
2251 }
2252
2253 pub fn validate_zklogin_public_identifier(&self) -> bool {
2254 self.feature_flags.validate_zklogin_public_identifier
2255 }
2256
2257 pub fn zklogin_max_epoch_upper_bound_delta(&self) -> Option<u64> {
2258 self.feature_flags.zklogin_max_epoch_upper_bound_delta
2259 }
2260
2261 pub fn throughput_aware_consensus_submission(&self) -> bool {
2262 self.feature_flags.throughput_aware_consensus_submission
2263 }
2264
2265 pub fn include_consensus_digest_in_prologue(&self) -> bool {
2266 self.feature_flags.include_consensus_digest_in_prologue
2267 }
2268
2269 pub fn record_consensus_determined_version_assignments_in_prologue(&self) -> bool {
2270 self.feature_flags
2271 .record_consensus_determined_version_assignments_in_prologue
2272 }
2273
2274 pub fn record_additional_state_digest_in_prologue(&self) -> bool {
2275 self.feature_flags
2276 .record_additional_state_digest_in_prologue
2277 }
2278
2279 pub fn record_consensus_determined_version_assignments_in_prologue_v2(&self) -> bool {
2280 self.feature_flags
2281 .record_consensus_determined_version_assignments_in_prologue_v2
2282 }
2283
2284 pub fn prepend_prologue_tx_in_consensus_commit_in_checkpoints(&self) -> bool {
2285 self.feature_flags
2286 .prepend_prologue_tx_in_consensus_commit_in_checkpoints
2287 }
2288
2289 pub fn hardened_otw_check(&self) -> bool {
2290 self.feature_flags.hardened_otw_check
2291 }
2292
2293 pub fn enable_poseidon(&self) -> bool {
2294 self.feature_flags.enable_poseidon
2295 }
2296
2297 pub fn enable_coin_deny_list_v1(&self) -> bool {
2298 self.feature_flags.enable_coin_deny_list
2299 }
2300
2301 pub fn enable_accumulators(&self) -> bool {
2302 self.feature_flags.enable_accumulators
2303 }
2304
2305 pub fn enable_coin_reservation_obj_refs(&self) -> bool {
2306 self.new_vm_enabled() && self.feature_flags.enable_coin_reservation_obj_refs
2307 }
2308
2309 pub fn create_root_accumulator_object(&self) -> bool {
2310 self.feature_flags.create_root_accumulator_object
2311 }
2312
2313 pub fn enable_address_balance_gas_payments(&self) -> bool {
2314 self.feature_flags.enable_address_balance_gas_payments
2315 }
2316
2317 pub fn address_balance_gas_check_rgp_at_signing(&self) -> bool {
2318 self.feature_flags.address_balance_gas_check_rgp_at_signing
2319 }
2320
2321 pub fn address_balance_gas_reject_gas_coin_arg(&self) -> bool {
2322 self.feature_flags.address_balance_gas_reject_gas_coin_arg
2323 }
2324
2325 pub fn enable_multi_epoch_transaction_expiration(&self) -> bool {
2326 self.feature_flags.enable_multi_epoch_transaction_expiration
2327 }
2328
2329 pub fn relax_valid_during_for_owned_inputs(&self) -> bool {
2330 self.feature_flags.relax_valid_during_for_owned_inputs
2331 }
2332
2333 pub fn enable_authenticated_event_streams(&self) -> bool {
2334 self.feature_flags.enable_authenticated_event_streams && self.enable_accumulators()
2335 }
2336
2337 pub fn enable_non_exclusive_writes(&self) -> bool {
2338 self.feature_flags.enable_non_exclusive_writes
2339 }
2340
2341 pub fn enable_coin_registry(&self) -> bool {
2342 self.feature_flags.enable_coin_registry
2343 }
2344
2345 pub fn enable_display_registry(&self) -> bool {
2346 self.feature_flags.enable_display_registry
2347 }
2348
2349 pub fn enable_coin_deny_list_v2(&self) -> bool {
2350 self.feature_flags.enable_coin_deny_list_v2
2351 }
2352
2353 pub fn enable_group_ops_native_functions(&self) -> bool {
2354 self.feature_flags.enable_group_ops_native_functions
2355 }
2356
2357 pub fn enable_group_ops_native_function_msm(&self) -> bool {
2358 self.feature_flags.enable_group_ops_native_function_msm
2359 }
2360
2361 pub fn enable_ristretto255_group_ops(&self) -> bool {
2362 self.feature_flags.enable_ristretto255_group_ops
2363 }
2364
2365 pub fn enable_verify_bulletproofs_ristretto255(&self) -> bool {
2366 self.feature_flags.enable_verify_bulletproofs_ristretto255
2367 }
2368
2369 pub fn reject_mutable_random_on_entry_functions(&self) -> bool {
2370 self.feature_flags.reject_mutable_random_on_entry_functions
2371 }
2372
2373 pub fn per_object_congestion_control_mode(&self) -> PerObjectCongestionControlMode {
2374 self.feature_flags.per_object_congestion_control_mode
2375 }
2376
2377 pub fn consensus_choice(&self) -> ConsensusChoice {
2378 self.feature_flags.consensus_choice
2379 }
2380
2381 pub fn consensus_network(&self) -> ConsensusNetwork {
2382 self.feature_flags.consensus_network
2383 }
2384
2385 pub fn correct_gas_payment_limit_check(&self) -> bool {
2386 self.feature_flags.correct_gas_payment_limit_check
2387 }
2388
2389 pub fn reshare_at_same_initial_version(&self) -> bool {
2390 self.feature_flags.reshare_at_same_initial_version
2391 }
2392
2393 pub fn resolve_abort_locations_to_package_id(&self) -> bool {
2394 self.feature_flags.resolve_abort_locations_to_package_id
2395 }
2396
2397 pub fn mysticeti_use_committed_subdag_digest(&self) -> bool {
2398 self.feature_flags.mysticeti_use_committed_subdag_digest
2399 }
2400
2401 pub fn enable_vdf(&self) -> bool {
2402 self.feature_flags.enable_vdf
2403 }
2404
2405 pub fn fresh_vm_on_framework_upgrade(&self) -> bool {
2406 self.feature_flags.fresh_vm_on_framework_upgrade
2407 }
2408
2409 pub fn mysticeti_num_leaders_per_round(&self) -> Option<usize> {
2410 self.feature_flags.mysticeti_num_leaders_per_round
2411 }
2412
2413 pub fn soft_bundle(&self) -> bool {
2414 self.feature_flags.soft_bundle
2415 }
2416
2417 pub fn passkey_auth(&self) -> bool {
2418 self.feature_flags.passkey_auth
2419 }
2420
2421 pub fn authority_capabilities_v2(&self) -> bool {
2422 self.feature_flags.authority_capabilities_v2
2423 }
2424
2425 pub fn max_transaction_size_bytes(&self) -> u64 {
2426 self.consensus_max_transaction_size_bytes
2428 .unwrap_or(256 * 1024)
2429 }
2430
2431 pub fn max_transactions_in_block_bytes(&self) -> u64 {
2432 if cfg!(msim) {
2433 256 * 1024
2434 } else {
2435 self.consensus_max_transactions_in_block_bytes
2436 .unwrap_or(512 * 1024)
2437 }
2438 }
2439
2440 pub fn max_num_transactions_in_block(&self) -> u64 {
2441 if cfg!(msim) {
2442 8
2443 } else {
2444 self.consensus_max_num_transactions_in_block.unwrap_or(512)
2445 }
2446 }
2447
2448 pub fn rethrow_serialization_type_layout_errors(&self) -> bool {
2449 self.feature_flags.rethrow_serialization_type_layout_errors
2450 }
2451
2452 pub fn consensus_distributed_vote_scoring_strategy(&self) -> bool {
2453 self.feature_flags
2454 .consensus_distributed_vote_scoring_strategy
2455 }
2456
2457 pub fn consensus_round_prober(&self) -> bool {
2458 self.feature_flags.consensus_round_prober
2459 }
2460
2461 pub fn validate_identifier_inputs(&self) -> bool {
2462 self.feature_flags.validate_identifier_inputs
2463 }
2464
2465 pub fn gc_depth(&self) -> u32 {
2466 self.consensus_gc_depth.unwrap_or(0)
2467 }
2468
2469 pub fn mysticeti_fastpath(&self) -> bool {
2470 self.feature_flags.mysticeti_fastpath
2471 }
2472
2473 pub fn relocate_event_module(&self) -> bool {
2474 self.feature_flags.relocate_event_module
2475 }
2476
2477 pub fn uncompressed_g1_group_elements(&self) -> bool {
2478 self.feature_flags.uncompressed_g1_group_elements
2479 }
2480
2481 pub fn disallow_new_modules_in_deps_only_packages(&self) -> bool {
2482 self.feature_flags
2483 .disallow_new_modules_in_deps_only_packages
2484 }
2485
2486 pub fn consensus_smart_ancestor_selection(&self) -> bool {
2487 self.feature_flags.consensus_smart_ancestor_selection
2488 }
2489
2490 pub fn disable_preconsensus_locking(&self) -> bool {
2491 self.feature_flags.disable_preconsensus_locking
2492 }
2493
2494 pub fn consensus_round_prober_probe_accepted_rounds(&self) -> bool {
2495 self.feature_flags
2496 .consensus_round_prober_probe_accepted_rounds
2497 }
2498
2499 pub fn native_charging_v2(&self) -> bool {
2500 self.feature_flags.native_charging_v2
2501 }
2502
2503 pub fn consensus_linearize_subdag_v2(&self) -> bool {
2504 let res = self.feature_flags.consensus_linearize_subdag_v2;
2505 assert!(
2506 !res || self.gc_depth() > 0,
2507 "The consensus linearize sub dag V2 requires GC to be enabled"
2508 );
2509 res
2510 }
2511
2512 pub fn consensus_median_based_commit_timestamp(&self) -> bool {
2513 let res = self.feature_flags.consensus_median_based_commit_timestamp;
2514 assert!(
2515 !res || self.gc_depth() > 0,
2516 "The consensus median based commit timestamp requires GC to be enabled"
2517 );
2518 res
2519 }
2520
2521 pub fn consensus_batched_block_sync(&self) -> bool {
2522 self.feature_flags.consensus_batched_block_sync
2523 }
2524
2525 pub fn convert_type_argument_error(&self) -> bool {
2526 self.feature_flags.convert_type_argument_error
2527 }
2528
2529 pub fn variant_nodes(&self) -> bool {
2530 self.feature_flags.variant_nodes
2531 }
2532
2533 pub fn consensus_zstd_compression(&self) -> bool {
2534 self.feature_flags.consensus_zstd_compression
2535 }
2536
2537 pub fn enable_nitro_attestation(&self) -> bool {
2538 self.feature_flags.enable_nitro_attestation
2539 }
2540
2541 pub fn enable_nitro_attestation_upgraded_parsing(&self) -> bool {
2542 self.feature_flags.enable_nitro_attestation_upgraded_parsing
2543 }
2544
2545 pub fn enable_nitro_attestation_all_nonzero_pcrs_parsing(&self) -> bool {
2546 self.feature_flags
2547 .enable_nitro_attestation_all_nonzero_pcrs_parsing
2548 }
2549
2550 pub fn enable_nitro_attestation_always_include_required_pcrs_parsing(&self) -> bool {
2551 self.feature_flags
2552 .enable_nitro_attestation_always_include_required_pcrs_parsing
2553 }
2554
2555 pub fn get_consensus_commit_rate_estimation_window_size(&self) -> u32 {
2556 self.consensus_commit_rate_estimation_window_size
2557 .unwrap_or(0)
2558 }
2559
2560 pub fn consensus_num_requested_prior_commits_at_startup(&self) -> u32 {
2561 let window_size = self.get_consensus_commit_rate_estimation_window_size();
2565 assert!(window_size == 0 || self.record_additional_state_digest_in_prologue());
2567 window_size
2568 }
2569
2570 pub fn minimize_child_object_mutations(&self) -> bool {
2571 self.feature_flags.minimize_child_object_mutations
2572 }
2573
2574 pub fn move_native_context(&self) -> bool {
2575 self.feature_flags.move_native_context
2576 }
2577
2578 pub fn normalize_ptb_arguments(&self) -> bool {
2579 self.feature_flags.normalize_ptb_arguments
2580 }
2581
2582 pub fn enforce_checkpoint_timestamp_monotonicity(&self) -> bool {
2583 self.feature_flags.enforce_checkpoint_timestamp_monotonicity
2584 }
2585
2586 pub fn max_ptb_value_size_v2(&self) -> bool {
2587 self.feature_flags.max_ptb_value_size_v2
2588 }
2589
2590 pub fn resolve_type_input_ids_to_defining_id(&self) -> bool {
2591 self.feature_flags.resolve_type_input_ids_to_defining_id
2592 }
2593
2594 pub fn enable_party_transfer(&self) -> bool {
2595 self.feature_flags.enable_party_transfer
2596 }
2597
2598 pub fn allow_unbounded_system_objects(&self) -> bool {
2599 self.feature_flags.allow_unbounded_system_objects
2600 }
2601
2602 pub fn type_tags_in_object_runtime(&self) -> bool {
2603 self.feature_flags.type_tags_in_object_runtime
2604 }
2605
2606 pub fn enable_ptb_execution_v2(&self) -> bool {
2607 self.feature_flags.enable_ptb_execution_v2
2608 }
2609
2610 pub fn better_adapter_type_resolution_errors(&self) -> bool {
2611 self.feature_flags.better_adapter_type_resolution_errors
2612 }
2613
2614 pub fn record_time_estimate_processed(&self) -> bool {
2615 self.feature_flags.record_time_estimate_processed
2616 }
2617
2618 pub fn ignore_execution_time_observations_after_certs_closed(&self) -> bool {
2619 self.feature_flags
2620 .ignore_execution_time_observations_after_certs_closed
2621 }
2622
2623 pub fn dependency_linkage_error(&self) -> bool {
2624 self.feature_flags.dependency_linkage_error
2625 }
2626
2627 pub fn additional_multisig_checks(&self) -> bool {
2628 self.feature_flags.additional_multisig_checks
2629 }
2630
2631 pub fn debug_fatal_on_move_invariant_violation(&self) -> bool {
2632 self.feature_flags.debug_fatal_on_move_invariant_violation
2633 }
2634
2635 pub fn allow_private_accumulator_entrypoints(&self) -> bool {
2636 self.feature_flags.allow_private_accumulator_entrypoints
2637 }
2638
2639 pub fn additional_consensus_digest_indirect_state(&self) -> bool {
2640 self.feature_flags
2641 .additional_consensus_digest_indirect_state
2642 }
2643
2644 pub fn check_for_init_during_upgrade(&self) -> bool {
2645 self.feature_flags.check_for_init_during_upgrade
2646 }
2647
2648 pub fn per_command_shared_object_transfer_rules(&self) -> bool {
2649 self.feature_flags.per_command_shared_object_transfer_rules
2650 }
2651
2652 pub fn consensus_checkpoint_signature_key_includes_digest(&self) -> bool {
2653 self.feature_flags
2654 .consensus_checkpoint_signature_key_includes_digest
2655 }
2656
2657 pub fn include_checkpoint_artifacts_digest_in_summary(&self) -> bool {
2658 self.feature_flags
2659 .include_checkpoint_artifacts_digest_in_summary
2660 }
2661
2662 pub fn use_mfp_txns_in_load_initial_object_debts(&self) -> bool {
2663 self.feature_flags.use_mfp_txns_in_load_initial_object_debts
2664 }
2665
2666 pub fn cancel_for_failed_dkg_early(&self) -> bool {
2667 self.feature_flags.cancel_for_failed_dkg_early
2668 }
2669
2670 pub fn abstract_size_in_object_runtime(&self) -> bool {
2671 self.feature_flags.abstract_size_in_object_runtime
2672 }
2673
2674 pub fn object_runtime_charge_cache_load_gas(&self) -> bool {
2675 self.feature_flags.object_runtime_charge_cache_load_gas
2676 }
2677
2678 pub fn additional_borrow_checks(&self) -> bool {
2679 self.feature_flags.additional_borrow_checks
2680 }
2681
2682 pub fn use_new_commit_handler(&self) -> bool {
2683 self.feature_flags.use_new_commit_handler
2684 }
2685
2686 pub fn better_loader_errors(&self) -> bool {
2687 self.feature_flags.better_loader_errors
2688 }
2689
2690 pub fn generate_df_type_layouts(&self) -> bool {
2691 self.feature_flags.generate_df_type_layouts
2692 }
2693
2694 pub fn allow_references_in_ptbs(&self) -> bool {
2695 self.feature_flags.allow_references_in_ptbs
2696 }
2697
2698 pub fn private_generics_verifier_v2(&self) -> bool {
2699 self.feature_flags.private_generics_verifier_v2
2700 }
2701
2702 pub fn deprecate_global_storage_ops_during_deserialization(&self) -> bool {
2703 self.feature_flags
2704 .deprecate_global_storage_ops_during_deserialization
2705 }
2706
2707 pub fn enable_observation_chunking(&self) -> bool {
2708 matches!(self.feature_flags.per_object_congestion_control_mode,
2709 PerObjectCongestionControlMode::ExecutionTimeEstimate(ref params)
2710 if params.observations_chunk_size.is_some()
2711 )
2712 }
2713
2714 pub fn deprecate_global_storage_ops(&self) -> bool {
2715 self.feature_flags.deprecate_global_storage_ops
2716 }
2717
2718 pub fn normalize_depth_formula(&self) -> bool {
2719 self.feature_flags.normalize_depth_formula
2720 }
2721
2722 pub fn consensus_skip_gced_accept_votes(&self) -> bool {
2723 self.feature_flags.consensus_skip_gced_accept_votes
2724 }
2725
2726 pub fn include_cancelled_randomness_txns_in_prologue(&self) -> bool {
2727 self.feature_flags
2728 .include_cancelled_randomness_txns_in_prologue
2729 }
2730
2731 pub fn address_aliases(&self) -> bool {
2732 let address_aliases = self.feature_flags.address_aliases;
2733 assert!(
2734 !address_aliases || self.mysticeti_fastpath(),
2735 "Address aliases requires Mysticeti fastpath to be enabled"
2736 );
2737 if address_aliases {
2738 assert!(
2739 self.feature_flags.disable_preconsensus_locking,
2740 "Address aliases requires CertifiedTransaction to be disabled"
2741 );
2742 }
2743 address_aliases
2744 }
2745
2746 pub fn fix_checkpoint_signature_mapping(&self) -> bool {
2747 self.feature_flags.fix_checkpoint_signature_mapping
2748 }
2749
2750 pub fn enable_object_funds_withdraw(&self) -> bool {
2751 self.feature_flags.enable_object_funds_withdraw
2752 }
2753
2754 pub fn gas_rounding_halve_digits(&self) -> bool {
2755 self.feature_flags.gas_rounding_halve_digits
2756 }
2757
2758 pub fn flexible_tx_context_positions(&self) -> bool {
2759 self.feature_flags.flexible_tx_context_positions
2760 }
2761
2762 pub fn disable_entry_point_signature_check(&self) -> bool {
2763 self.feature_flags.disable_entry_point_signature_check
2764 }
2765
2766 pub fn consensus_skip_gced_blocks_in_direct_finalization(&self) -> bool {
2767 self.feature_flags
2768 .consensus_skip_gced_blocks_in_direct_finalization
2769 }
2770
2771 pub fn convert_withdrawal_compatibility_ptb_arguments(&self) -> bool {
2772 self.feature_flags
2773 .convert_withdrawal_compatibility_ptb_arguments
2774 }
2775
2776 pub fn restrict_hot_or_not_entry_functions(&self) -> bool {
2777 self.feature_flags.restrict_hot_or_not_entry_functions
2778 }
2779
2780 pub fn split_checkpoints_in_consensus_handler(&self) -> bool {
2781 self.feature_flags.split_checkpoints_in_consensus_handler
2782 }
2783
2784 pub fn consensus_always_accept_system_transactions(&self) -> bool {
2785 self.feature_flags
2786 .consensus_always_accept_system_transactions
2787 }
2788
2789 pub fn validator_metadata_verify_v2(&self) -> bool {
2790 self.feature_flags.validator_metadata_verify_v2
2791 }
2792
2793 pub fn defer_unpaid_amplification(&self) -> bool {
2794 self.feature_flags.defer_unpaid_amplification
2795 }
2796
2797 pub fn gasless_transaction_drop_safety(&self) -> bool {
2798 self.feature_flags.gasless_transaction_drop_safety
2799 }
2800
2801 pub fn new_vm_enabled(&self) -> bool {
2802 self.execution_version.is_some_and(|v| v >= 4)
2803 }
2804
2805 pub fn merge_randomness_into_checkpoint(&self) -> bool {
2806 self.feature_flags.merge_randomness_into_checkpoint
2807 }
2808
2809 pub fn use_coin_party_owner(&self) -> bool {
2810 self.feature_flags.use_coin_party_owner
2811 }
2812
2813 pub fn enable_gasless(&self) -> bool {
2814 self.feature_flags.enable_gasless
2815 }
2816
2817 pub fn gasless_verify_remaining_balance(&self) -> bool {
2818 self.feature_flags.gasless_verify_remaining_balance
2819 }
2820
2821 pub fn gasless_allowed_token_types(&self) -> &[(String, u64)] {
2822 debug_assert!(self.gasless_allowed_token_types.is_some());
2823 self.gasless_allowed_token_types.as_deref().unwrap_or(&[])
2824 }
2825
2826 pub fn get_gasless_max_unused_inputs(&self) -> u64 {
2827 self.gasless_max_unused_inputs.unwrap_or(u64::MAX)
2828 }
2829
2830 pub fn get_gasless_max_pure_input_bytes(&self) -> u64 {
2831 self.gasless_max_pure_input_bytes.unwrap_or(u64::MAX)
2832 }
2833
2834 pub fn get_gasless_max_tx_size_bytes(&self) -> u64 {
2835 self.gasless_max_tx_size_bytes.unwrap_or(u64::MAX)
2836 }
2837
2838 pub fn disallow_jump_orphans(&self) -> bool {
2839 self.feature_flags.disallow_jump_orphans
2840 }
2841
2842 pub fn early_return_receive_object_mismatched_type(&self) -> bool {
2843 self.feature_flags
2844 .early_return_receive_object_mismatched_type
2845 }
2846
2847 pub fn include_special_package_amendments_as_option(&self) -> &Option<Arc<Amendments>> {
2848 &self.include_special_package_amendments
2849 }
2850
2851 pub fn timestamp_based_epoch_close(&self) -> bool {
2852 self.feature_flags.timestamp_based_epoch_close
2853 }
2854
2855 pub fn limit_groth16_pvk_inputs(&self) -> bool {
2856 self.feature_flags.limit_groth16_pvk_inputs
2857 }
2858
2859 pub fn enforce_address_balance_change_invariant(&self) -> bool {
2860 self.feature_flags.enforce_address_balance_change_invariant
2861 }
2862
2863 pub fn granular_post_execution_checks(&self) -> bool {
2864 self.feature_flags.granular_post_execution_checks
2865 }
2866
2867 pub fn early_exit_on_iffw(&self) -> bool {
2868 self.feature_flags.early_exit_on_iffw
2869 }
2870}
2871
2872#[cfg(not(msim))]
2873static POISON_VERSION_METHODS: AtomicBool = AtomicBool::new(false);
2874
2875#[cfg(msim)]
2877thread_local! {
2878 static POISON_VERSION_METHODS: AtomicBool = AtomicBool::new(false);
2879}
2880
2881impl ProtocolConfig {
2883 pub fn get_for_version(version: ProtocolVersion, chain: Chain) -> Self {
2885 assert!(
2887 version >= ProtocolVersion::MIN,
2888 "Network protocol version is {:?}, but the minimum supported version by the binary is {:?}. Please upgrade the binary.",
2889 version,
2890 ProtocolVersion::MIN.0,
2891 );
2892 assert!(
2893 version <= ProtocolVersion::MAX_ALLOWED,
2894 "Network protocol version is {:?}, but the maximum supported version by the binary is {:?}. Please upgrade the binary.",
2895 version,
2896 ProtocolVersion::MAX_ALLOWED.0,
2897 );
2898
2899 let mut ret = Self::get_for_version_impl(version, chain);
2900 ret.version = version;
2901
2902 ret = Self::apply_config_override(version, ret);
2903
2904 if std::env::var("SUI_PROTOCOL_CONFIG_OVERRIDE_ENABLE").is_ok() {
2905 warn!(
2906 "overriding ProtocolConfig settings with custom settings; this may break non-local networks"
2907 );
2908 let overrides: ProtocolConfigOptional =
2909 serde_env::from_env_with_prefix("SUI_PROTOCOL_CONFIG_OVERRIDE")
2910 .expect("failed to parse ProtocolConfig override env variables");
2911 overrides.apply_to(&mut ret);
2912 }
2913
2914 ret
2915 }
2916
2917 pub fn get_for_version_if_supported(version: ProtocolVersion, chain: Chain) -> Option<Self> {
2920 if version.0 >= ProtocolVersion::MIN.0 && version.0 <= ProtocolVersion::MAX_ALLOWED.0 {
2921 let mut ret = Self::get_for_version_impl(version, chain);
2922 ret.version = version;
2923 ret = Self::apply_config_override(version, ret);
2924 Some(ret)
2925 } else {
2926 None
2927 }
2928 }
2929
2930 #[cfg(not(msim))]
2931 pub fn poison_get_for_min_version() {
2932 POISON_VERSION_METHODS.store(true, Ordering::Relaxed);
2933 }
2934
2935 #[cfg(not(msim))]
2936 fn load_poison_get_for_min_version() -> bool {
2937 POISON_VERSION_METHODS.load(Ordering::Relaxed)
2938 }
2939
2940 #[cfg(msim)]
2941 pub fn poison_get_for_min_version() {
2942 POISON_VERSION_METHODS.with(|p| p.store(true, Ordering::Relaxed));
2943 }
2944
2945 #[cfg(msim)]
2946 fn load_poison_get_for_min_version() -> bool {
2947 POISON_VERSION_METHODS.with(|p| p.load(Ordering::Relaxed))
2948 }
2949
2950 pub fn get_for_min_version() -> Self {
2953 if Self::load_poison_get_for_min_version() {
2954 panic!("get_for_min_version called on validator");
2955 }
2956 ProtocolConfig::get_for_version(ProtocolVersion::MIN, Chain::Unknown)
2957 }
2958
2959 #[allow(non_snake_case)]
2969 pub fn get_for_max_version_UNSAFE() -> Self {
2970 if Self::load_poison_get_for_min_version() {
2971 panic!("get_for_max_version_UNSAFE called on validator");
2972 }
2973 ProtocolConfig::get_for_version(ProtocolVersion::MAX, Chain::Unknown)
2974 }
2975
2976 fn get_for_version_impl(version: ProtocolVersion, chain: Chain) -> Self {
2977 #[cfg(msim)]
2978 {
2979 if version == ProtocolVersion::MAX_ALLOWED {
2981 let mut config = Self::get_for_version_impl(version - 1, Chain::Unknown);
2982 config.base_tx_cost_fixed = Some(config.base_tx_cost_fixed() + 1000);
2983 return config;
2984 }
2985 }
2986
2987 let mut cfg = Self {
2990 version,
2992
2993 feature_flags: Default::default(),
2995
2996 max_tx_size_bytes: Some(128 * 1024),
2997 max_input_objects: Some(2048),
2999 max_serialized_tx_effects_size_bytes: Some(512 * 1024),
3000 max_serialized_tx_effects_size_bytes_system_tx: Some(512 * 1024 * 16),
3001 max_gas_payment_objects: Some(256),
3002 max_modules_in_publish: Some(128),
3003 max_package_dependencies: None,
3004 max_arguments: Some(512),
3005 max_type_arguments: Some(16),
3006 max_type_argument_depth: Some(16),
3007 max_pure_argument_size: Some(16 * 1024),
3008 max_programmable_tx_commands: Some(1024),
3009 move_binary_format_version: Some(6),
3010 min_move_binary_format_version: None,
3011 binary_module_handles: None,
3012 binary_struct_handles: None,
3013 binary_function_handles: None,
3014 binary_function_instantiations: None,
3015 binary_signatures: None,
3016 binary_constant_pool: None,
3017 binary_identifiers: None,
3018 binary_address_identifiers: None,
3019 binary_struct_defs: None,
3020 binary_struct_def_instantiations: None,
3021 binary_function_defs: None,
3022 binary_field_handles: None,
3023 binary_field_instantiations: None,
3024 binary_friend_decls: None,
3025 binary_enum_defs: None,
3026 binary_enum_def_instantiations: None,
3027 binary_variant_handles: None,
3028 binary_variant_instantiation_handles: None,
3029 max_move_object_size: Some(250 * 1024),
3030 max_move_package_size: Some(100 * 1024),
3031 max_publish_or_upgrade_per_ptb: None,
3032 max_tx_gas: Some(10_000_000_000),
3033 max_gas_price: Some(100_000),
3034 max_gas_price_rgp_factor_for_aborted_transactions: None,
3035 max_gas_computation_bucket: Some(5_000_000),
3036 max_loop_depth: Some(5),
3037 max_generic_instantiation_length: Some(32),
3038 max_function_parameters: Some(128),
3039 max_basic_blocks: Some(1024),
3040 max_value_stack_size: Some(1024),
3041 max_type_nodes: Some(256),
3042 max_push_size: Some(10000),
3043 max_struct_definitions: Some(200),
3044 max_function_definitions: Some(1000),
3045 max_fields_in_struct: Some(32),
3046 max_dependency_depth: Some(100),
3047 max_num_event_emit: Some(256),
3048 max_num_new_move_object_ids: Some(2048),
3049 max_num_new_move_object_ids_system_tx: Some(2048 * 16),
3050 max_num_deleted_move_object_ids: Some(2048),
3051 max_num_deleted_move_object_ids_system_tx: Some(2048 * 16),
3052 max_num_transferred_move_object_ids: Some(2048),
3053 max_num_transferred_move_object_ids_system_tx: Some(2048 * 16),
3054 max_event_emit_size: Some(250 * 1024),
3055 max_move_vector_len: Some(256 * 1024),
3056 max_type_to_layout_nodes: None,
3057 max_ptb_value_size: None,
3058
3059 max_back_edges_per_function: Some(10_000),
3060 max_back_edges_per_module: Some(10_000),
3061 max_verifier_meter_ticks_per_function: Some(6_000_000),
3062 max_meter_ticks_per_module: Some(6_000_000),
3063 max_meter_ticks_per_package: None,
3064
3065 object_runtime_max_num_cached_objects: Some(1000),
3066 object_runtime_max_num_cached_objects_system_tx: Some(1000 * 16),
3067 object_runtime_max_num_store_entries: Some(1000),
3068 object_runtime_max_num_store_entries_system_tx: Some(1000 * 16),
3069 base_tx_cost_fixed: Some(110_000),
3070 package_publish_cost_fixed: Some(1_000),
3071 base_tx_cost_per_byte: Some(0),
3072 package_publish_cost_per_byte: Some(80),
3073 obj_access_cost_read_per_byte: Some(15),
3074 obj_access_cost_mutate_per_byte: Some(40),
3075 obj_access_cost_delete_per_byte: Some(40),
3076 obj_access_cost_verify_per_byte: Some(200),
3077 obj_data_cost_refundable: Some(100),
3078 obj_metadata_cost_non_refundable: Some(50),
3079 gas_model_version: Some(1),
3080 storage_rebate_rate: Some(9900),
3081 storage_fund_reinvest_rate: Some(500),
3082 reward_slashing_rate: Some(5000),
3083 storage_gas_price: Some(1),
3084 accumulator_object_storage_cost: None,
3085 max_transactions_per_checkpoint: Some(10_000),
3086 max_checkpoint_size_bytes: Some(30 * 1024 * 1024),
3087
3088 buffer_stake_for_protocol_upgrade_bps: Some(0),
3091
3092 address_from_bytes_cost_base: Some(52),
3096 address_to_u256_cost_base: Some(52),
3098 address_from_u256_cost_base: Some(52),
3100
3101 config_read_setting_impl_cost_base: None,
3104 config_read_setting_impl_cost_per_byte: None,
3105
3106 dynamic_field_hash_type_and_key_cost_base: Some(100),
3109 dynamic_field_hash_type_and_key_type_cost_per_byte: Some(2),
3110 dynamic_field_hash_type_and_key_value_cost_per_byte: Some(2),
3111 dynamic_field_hash_type_and_key_type_tag_cost_per_byte: Some(2),
3112 dynamic_field_add_child_object_cost_base: Some(100),
3114 dynamic_field_add_child_object_type_cost_per_byte: Some(10),
3115 dynamic_field_add_child_object_value_cost_per_byte: Some(10),
3116 dynamic_field_add_child_object_struct_tag_cost_per_byte: Some(10),
3117 dynamic_field_borrow_child_object_cost_base: Some(100),
3119 dynamic_field_borrow_child_object_child_ref_cost_per_byte: Some(10),
3120 dynamic_field_borrow_child_object_type_cost_per_byte: Some(10),
3121 dynamic_field_remove_child_object_cost_base: Some(100),
3123 dynamic_field_remove_child_object_child_cost_per_byte: Some(2),
3124 dynamic_field_remove_child_object_type_cost_per_byte: Some(2),
3125 dynamic_field_has_child_object_cost_base: Some(100),
3127 dynamic_field_has_child_object_with_ty_cost_base: Some(100),
3129 dynamic_field_has_child_object_with_ty_type_cost_per_byte: Some(2),
3130 dynamic_field_has_child_object_with_ty_type_tag_cost_per_byte: Some(2),
3131
3132 event_emit_cost_base: Some(52),
3135 event_emit_value_size_derivation_cost_per_byte: Some(2),
3136 event_emit_tag_size_derivation_cost_per_byte: Some(5),
3137 event_emit_output_cost_per_byte: Some(10),
3138 event_emit_auth_stream_cost: None,
3139
3140 object_borrow_uid_cost_base: Some(52),
3143 object_delete_impl_cost_base: Some(52),
3145 object_record_new_uid_cost_base: Some(52),
3147
3148 transfer_transfer_internal_cost_base: Some(52),
3151 transfer_party_transfer_internal_cost_base: None,
3153 transfer_freeze_object_cost_base: Some(52),
3155 transfer_share_object_cost_base: Some(52),
3157 transfer_receive_object_cost_base: None,
3158 transfer_receive_object_type_cost_per_byte: None,
3159 transfer_receive_object_cost_per_byte: None,
3160
3161 tx_context_derive_id_cost_base: Some(52),
3164 tx_context_fresh_id_cost_base: None,
3165 tx_context_sender_cost_base: None,
3166 tx_context_epoch_cost_base: None,
3167 tx_context_epoch_timestamp_ms_cost_base: None,
3168 tx_context_sponsor_cost_base: None,
3169 tx_context_rgp_cost_base: None,
3170 tx_context_gas_price_cost_base: None,
3171 tx_context_gas_budget_cost_base: None,
3172 tx_context_ids_created_cost_base: None,
3173 tx_context_replace_cost_base: None,
3174
3175 types_is_one_time_witness_cost_base: Some(52),
3178 types_is_one_time_witness_type_tag_cost_per_byte: Some(2),
3179 types_is_one_time_witness_type_cost_per_byte: Some(2),
3180
3181 validator_validate_metadata_cost_base: Some(52),
3184 validator_validate_metadata_data_cost_per_byte: Some(2),
3185
3186 crypto_invalid_arguments_cost: Some(100),
3188 bls12381_bls12381_min_sig_verify_cost_base: Some(52),
3190 bls12381_bls12381_min_sig_verify_msg_cost_per_byte: Some(2),
3191 bls12381_bls12381_min_sig_verify_msg_cost_per_block: Some(2),
3192
3193 bls12381_bls12381_min_pk_verify_cost_base: Some(52),
3195 bls12381_bls12381_min_pk_verify_msg_cost_per_byte: Some(2),
3196 bls12381_bls12381_min_pk_verify_msg_cost_per_block: Some(2),
3197
3198 ecdsa_k1_ecrecover_keccak256_cost_base: Some(52),
3200 ecdsa_k1_ecrecover_keccak256_msg_cost_per_byte: Some(2),
3201 ecdsa_k1_ecrecover_keccak256_msg_cost_per_block: Some(2),
3202 ecdsa_k1_ecrecover_sha256_cost_base: Some(52),
3203 ecdsa_k1_ecrecover_sha256_msg_cost_per_byte: Some(2),
3204 ecdsa_k1_ecrecover_sha256_msg_cost_per_block: Some(2),
3205
3206 ecdsa_k1_decompress_pubkey_cost_base: Some(52),
3208
3209 ecdsa_k1_secp256k1_verify_keccak256_cost_base: Some(52),
3211 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_byte: Some(2),
3212 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_block: Some(2),
3213 ecdsa_k1_secp256k1_verify_sha256_cost_base: Some(52),
3214 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_byte: Some(2),
3215 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_block: Some(2),
3216
3217 ecdsa_r1_ecrecover_keccak256_cost_base: Some(52),
3219 ecdsa_r1_ecrecover_keccak256_msg_cost_per_byte: Some(2),
3220 ecdsa_r1_ecrecover_keccak256_msg_cost_per_block: Some(2),
3221 ecdsa_r1_ecrecover_sha256_cost_base: Some(52),
3222 ecdsa_r1_ecrecover_sha256_msg_cost_per_byte: Some(2),
3223 ecdsa_r1_ecrecover_sha256_msg_cost_per_block: Some(2),
3224
3225 ecdsa_r1_secp256r1_verify_keccak256_cost_base: Some(52),
3227 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_byte: Some(2),
3228 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_block: Some(2),
3229 ecdsa_r1_secp256r1_verify_sha256_cost_base: Some(52),
3230 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_byte: Some(2),
3231 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_block: Some(2),
3232
3233 ecvrf_ecvrf_verify_cost_base: Some(52),
3235 ecvrf_ecvrf_verify_alpha_string_cost_per_byte: Some(2),
3236 ecvrf_ecvrf_verify_alpha_string_cost_per_block: Some(2),
3237
3238 ed25519_ed25519_verify_cost_base: Some(52),
3240 ed25519_ed25519_verify_msg_cost_per_byte: Some(2),
3241 ed25519_ed25519_verify_msg_cost_per_block: Some(2),
3242
3243 groth16_prepare_verifying_key_bls12381_cost_base: Some(52),
3245 groth16_prepare_verifying_key_bn254_cost_base: Some(52),
3246
3247 groth16_verify_groth16_proof_internal_bls12381_cost_base: Some(52),
3249 groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input: Some(2),
3250 groth16_verify_groth16_proof_internal_bn254_cost_base: Some(52),
3251 groth16_verify_groth16_proof_internal_bn254_cost_per_public_input: Some(2),
3252 groth16_verify_groth16_proof_internal_public_input_cost_per_byte: Some(2),
3253
3254 hash_blake2b256_cost_base: Some(52),
3256 hash_blake2b256_data_cost_per_byte: Some(2),
3257 hash_blake2b256_data_cost_per_block: Some(2),
3258
3259 hash_keccak256_cost_base: Some(52),
3261 hash_keccak256_data_cost_per_byte: Some(2),
3262 hash_keccak256_data_cost_per_block: Some(2),
3263
3264 poseidon_bn254_cost_base: None,
3265 poseidon_bn254_cost_per_block: None,
3266
3267 hmac_hmac_sha3_256_cost_base: Some(52),
3269 hmac_hmac_sha3_256_input_cost_per_byte: Some(2),
3270 hmac_hmac_sha3_256_input_cost_per_block: Some(2),
3271
3272 group_ops_bls12381_decode_scalar_cost: None,
3274 group_ops_bls12381_decode_g1_cost: None,
3275 group_ops_bls12381_decode_g2_cost: None,
3276 group_ops_bls12381_decode_gt_cost: None,
3277 group_ops_bls12381_scalar_add_cost: None,
3278 group_ops_bls12381_g1_add_cost: None,
3279 group_ops_bls12381_g2_add_cost: None,
3280 group_ops_bls12381_gt_add_cost: None,
3281 group_ops_bls12381_scalar_sub_cost: None,
3282 group_ops_bls12381_g1_sub_cost: None,
3283 group_ops_bls12381_g2_sub_cost: None,
3284 group_ops_bls12381_gt_sub_cost: None,
3285 group_ops_bls12381_scalar_mul_cost: None,
3286 group_ops_bls12381_g1_mul_cost: None,
3287 group_ops_bls12381_g2_mul_cost: None,
3288 group_ops_bls12381_gt_mul_cost: None,
3289 group_ops_bls12381_scalar_div_cost: None,
3290 group_ops_bls12381_g1_div_cost: None,
3291 group_ops_bls12381_g2_div_cost: None,
3292 group_ops_bls12381_gt_div_cost: None,
3293 group_ops_bls12381_g1_hash_to_base_cost: None,
3294 group_ops_bls12381_g2_hash_to_base_cost: None,
3295 group_ops_bls12381_g1_hash_to_cost_per_byte: None,
3296 group_ops_bls12381_g2_hash_to_cost_per_byte: None,
3297 group_ops_bls12381_g1_msm_base_cost: None,
3298 group_ops_bls12381_g2_msm_base_cost: None,
3299 group_ops_bls12381_g1_msm_base_cost_per_input: None,
3300 group_ops_bls12381_g2_msm_base_cost_per_input: None,
3301 group_ops_bls12381_msm_max_len: None,
3302 group_ops_bls12381_pairing_cost: None,
3303 group_ops_bls12381_g1_to_uncompressed_g1_cost: None,
3304 group_ops_bls12381_uncompressed_g1_to_g1_cost: None,
3305 group_ops_bls12381_uncompressed_g1_sum_base_cost: None,
3306 group_ops_bls12381_uncompressed_g1_sum_cost_per_term: None,
3307 group_ops_bls12381_uncompressed_g1_sum_max_terms: None,
3308
3309 group_ops_ristretto_decode_scalar_cost: None,
3310 group_ops_ristretto_decode_point_cost: None,
3311 group_ops_ristretto_scalar_add_cost: None,
3312 group_ops_ristretto_point_add_cost: None,
3313 group_ops_ristretto_scalar_sub_cost: None,
3314 group_ops_ristretto_point_sub_cost: None,
3315 group_ops_ristretto_scalar_mul_cost: None,
3316 group_ops_ristretto_point_mul_cost: None,
3317 group_ops_ristretto_scalar_div_cost: None,
3318 group_ops_ristretto_point_div_cost: None,
3319
3320 verify_bulletproofs_ristretto255_base_cost: None,
3321 verify_bulletproofs_ristretto255_cost_per_bit_and_commitment: None,
3322
3323 check_zklogin_id_cost_base: None,
3325 check_zklogin_issuer_cost_base: None,
3327
3328 vdf_verify_vdf_cost: None,
3329 vdf_hash_to_input_cost: None,
3330
3331 nitro_attestation_parse_base_cost: None,
3333 nitro_attestation_parse_cost_per_byte: None,
3334 nitro_attestation_verify_base_cost: None,
3335 nitro_attestation_verify_cost_per_cert: None,
3336
3337 bcs_per_byte_serialized_cost: None,
3338 bcs_legacy_min_output_size_cost: None,
3339 bcs_failure_cost: None,
3340 hash_sha2_256_base_cost: None,
3341 hash_sha2_256_per_byte_cost: None,
3342 hash_sha2_256_legacy_min_input_len_cost: None,
3343 hash_sha3_256_base_cost: None,
3344 hash_sha3_256_per_byte_cost: None,
3345 hash_sha3_256_legacy_min_input_len_cost: None,
3346 type_name_get_base_cost: None,
3347 type_name_get_per_byte_cost: None,
3348 type_name_id_base_cost: None,
3349 string_check_utf8_base_cost: None,
3350 string_check_utf8_per_byte_cost: None,
3351 string_is_char_boundary_base_cost: None,
3352 string_sub_string_base_cost: None,
3353 string_sub_string_per_byte_cost: None,
3354 string_index_of_base_cost: None,
3355 string_index_of_per_byte_pattern_cost: None,
3356 string_index_of_per_byte_searched_cost: None,
3357 vector_empty_base_cost: None,
3358 vector_length_base_cost: None,
3359 vector_push_back_base_cost: None,
3360 vector_push_back_legacy_per_abstract_memory_unit_cost: None,
3361 vector_borrow_base_cost: None,
3362 vector_pop_back_base_cost: None,
3363 vector_destroy_empty_base_cost: None,
3364 vector_swap_base_cost: None,
3365 debug_print_base_cost: None,
3366 debug_print_stack_trace_base_cost: None,
3367
3368 max_size_written_objects: None,
3369 max_size_written_objects_system_tx: None,
3370
3371 max_move_identifier_len: None,
3378 max_move_value_depth: None,
3379 max_move_enum_variants: None,
3380
3381 gas_rounding_step: None,
3382
3383 execution_version: None,
3384
3385 max_event_emit_size_total: None,
3386
3387 consensus_bad_nodes_stake_threshold: None,
3388
3389 max_jwk_votes_per_validator_per_epoch: None,
3390
3391 max_age_of_jwk_in_epochs: None,
3392
3393 random_beacon_reduction_allowed_delta: None,
3394
3395 random_beacon_reduction_lower_bound: None,
3396
3397 random_beacon_dkg_timeout_round: None,
3398
3399 random_beacon_min_round_interval_ms: None,
3400
3401 random_beacon_dkg_version: None,
3402
3403 consensus_max_transaction_size_bytes: None,
3404
3405 consensus_max_transactions_in_block_bytes: None,
3406
3407 consensus_max_num_transactions_in_block: None,
3408
3409 consensus_voting_rounds: None,
3410
3411 max_accumulated_txn_cost_per_object_in_narwhal_commit: None,
3412
3413 max_deferral_rounds_for_congestion_control: None,
3414
3415 max_txn_cost_overage_per_object_in_commit: None,
3416
3417 allowed_txn_cost_overage_burst_per_object_in_commit: None,
3418
3419 min_checkpoint_interval_ms: None,
3420
3421 checkpoint_summary_version_specific_data: None,
3422
3423 max_soft_bundle_size: None,
3424
3425 bridge_should_try_to_finalize_committee: None,
3426
3427 max_accumulated_txn_cost_per_object_in_mysticeti_commit: None,
3428
3429 max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit: None,
3430
3431 consensus_gc_depth: None,
3432
3433 gas_budget_based_txn_cost_cap_factor: None,
3434
3435 gas_budget_based_txn_cost_absolute_cap_commit_count: None,
3436
3437 sip_45_consensus_amplification_threshold: None,
3438
3439 use_object_per_epoch_marker_table_v2: None,
3440
3441 consensus_commit_rate_estimation_window_size: None,
3442
3443 aliased_addresses: vec![],
3444
3445 translation_per_command_base_charge: None,
3446 translation_per_input_base_charge: None,
3447 translation_pure_input_per_byte_charge: None,
3448 translation_per_type_node_charge: None,
3449 translation_per_reference_node_charge: None,
3450 translation_per_linkage_entry_charge: None,
3451
3452 max_updates_per_settlement_txn: None,
3453
3454 gasless_max_computation_units: None,
3455 gasless_allowed_token_types: None,
3456 gasless_max_unused_inputs: None,
3457 gasless_max_pure_input_bytes: None,
3458 gasless_max_tps: None,
3459 include_special_package_amendments: None,
3460 gasless_max_tx_size_bytes: None,
3461 };
3464 for cur in 2..=version.0 {
3465 match cur {
3466 1 => unreachable!(),
3467 2 => {
3468 cfg.feature_flags.advance_epoch_start_time_in_safe_mode = true;
3469 }
3470 3 => {
3471 cfg.gas_model_version = Some(2);
3473 cfg.max_tx_gas = Some(50_000_000_000);
3475 cfg.base_tx_cost_fixed = Some(2_000);
3477 cfg.storage_gas_price = Some(76);
3479 cfg.feature_flags.loaded_child_objects_fixed = true;
3480 cfg.max_size_written_objects = Some(5 * 1000 * 1000);
3483 cfg.max_size_written_objects_system_tx = Some(50 * 1000 * 1000);
3486 cfg.feature_flags.package_upgrades = true;
3487 }
3488 4 => {
3493 cfg.reward_slashing_rate = Some(10000);
3495 cfg.gas_model_version = Some(3);
3497 }
3498 5 => {
3499 cfg.feature_flags.missing_type_is_compatibility_error = true;
3500 cfg.gas_model_version = Some(4);
3501 cfg.feature_flags.scoring_decision_with_validity_cutoff = true;
3502 }
3506 6 => {
3507 cfg.gas_model_version = Some(5);
3508 cfg.buffer_stake_for_protocol_upgrade_bps = Some(5000);
3509 cfg.feature_flags.consensus_order_end_of_epoch_last = true;
3510 }
3511 7 => {
3512 cfg.feature_flags.disallow_adding_abilities_on_upgrade = true;
3513 cfg.feature_flags
3514 .disable_invariant_violation_check_in_swap_loc = true;
3515 cfg.feature_flags.ban_entry_init = true;
3516 cfg.feature_flags.package_digest_hash_module = true;
3517 }
3518 8 => {
3519 cfg.feature_flags
3520 .disallow_change_struct_type_params_on_upgrade = true;
3521 }
3522 9 => {
3523 cfg.max_move_identifier_len = Some(128);
3525 cfg.feature_flags.no_extraneous_module_bytes = true;
3526 cfg.feature_flags
3527 .advance_to_highest_supported_protocol_version = true;
3528 }
3529 10 => {
3530 cfg.max_verifier_meter_ticks_per_function = Some(16_000_000);
3531 cfg.max_meter_ticks_per_module = Some(16_000_000);
3532 }
3533 11 => {
3534 cfg.max_move_value_depth = Some(128);
3535 }
3536 12 => {
3537 cfg.feature_flags.narwhal_versioned_metadata = true;
3538 if chain != Chain::Mainnet {
3539 cfg.feature_flags.commit_root_state_digest = true;
3540 }
3541
3542 if chain != Chain::Mainnet && chain != Chain::Testnet {
3543 cfg.feature_flags.zklogin_auth = true;
3544 }
3545 }
3546 13 => {}
3547 14 => {
3548 cfg.gas_rounding_step = Some(1_000);
3549 cfg.gas_model_version = Some(6);
3550 }
3551 15 => {
3552 cfg.feature_flags.consensus_transaction_ordering =
3553 ConsensusTransactionOrdering::ByGasPrice;
3554 }
3555 16 => {
3556 cfg.feature_flags.simplified_unwrap_then_delete = true;
3557 }
3558 17 => {
3559 cfg.feature_flags.upgraded_multisig_supported = true;
3560 }
3561 18 => {
3562 cfg.execution_version = Some(1);
3563 cfg.feature_flags.txn_base_cost_as_multiplier = true;
3572 cfg.base_tx_cost_fixed = Some(1_000);
3574 }
3575 19 => {
3576 cfg.max_num_event_emit = Some(1024);
3577 cfg.max_event_emit_size_total = Some(
3580 256 * 250 * 1024, );
3582 }
3583 20 => {
3584 cfg.feature_flags.commit_root_state_digest = true;
3585
3586 if chain != Chain::Mainnet {
3587 cfg.feature_flags.narwhal_new_leader_election_schedule = true;
3588 cfg.consensus_bad_nodes_stake_threshold = Some(20);
3589 }
3590 }
3591
3592 21 => {
3593 if chain != Chain::Mainnet {
3594 cfg.feature_flags.zklogin_supported_providers = BTreeSet::from([
3595 "Google".to_string(),
3596 "Facebook".to_string(),
3597 "Twitch".to_string(),
3598 ]);
3599 }
3600 }
3601 22 => {
3602 cfg.feature_flags.loaded_child_object_format = true;
3603 }
3604 23 => {
3605 cfg.feature_flags.loaded_child_object_format_type = true;
3606 cfg.feature_flags.narwhal_new_leader_election_schedule = true;
3607 cfg.consensus_bad_nodes_stake_threshold = Some(20);
3613 }
3614 24 => {
3615 cfg.feature_flags.simple_conservation_checks = true;
3616 cfg.max_publish_or_upgrade_per_ptb = Some(5);
3617
3618 cfg.feature_flags.end_of_epoch_transaction_supported = true;
3619
3620 if chain != Chain::Mainnet {
3621 cfg.feature_flags.enable_jwk_consensus_updates = true;
3622 cfg.max_jwk_votes_per_validator_per_epoch = Some(240);
3624 cfg.max_age_of_jwk_in_epochs = Some(1);
3625 }
3626 }
3627 25 => {
3628 cfg.feature_flags.zklogin_supported_providers = BTreeSet::from([
3630 "Google".to_string(),
3631 "Facebook".to_string(),
3632 "Twitch".to_string(),
3633 ]);
3634 cfg.feature_flags.zklogin_auth = true;
3635
3636 cfg.feature_flags.enable_jwk_consensus_updates = true;
3638 cfg.max_jwk_votes_per_validator_per_epoch = Some(240);
3639 cfg.max_age_of_jwk_in_epochs = Some(1);
3640 }
3641 26 => {
3642 cfg.gas_model_version = Some(7);
3643 if chain != Chain::Mainnet && chain != Chain::Testnet {
3645 cfg.transfer_receive_object_cost_base = Some(52);
3646 cfg.feature_flags.receive_objects = true;
3647 }
3648 }
3649 27 => {
3650 cfg.gas_model_version = Some(8);
3651 }
3652 28 => {
3653 cfg.check_zklogin_id_cost_base = Some(200);
3655 cfg.check_zklogin_issuer_cost_base = Some(200);
3657
3658 if chain != Chain::Mainnet && chain != Chain::Testnet {
3660 cfg.feature_flags.enable_effects_v2 = true;
3661 }
3662 }
3663 29 => {
3664 cfg.feature_flags.verify_legacy_zklogin_address = true;
3665 }
3666 30 => {
3667 if chain != Chain::Mainnet {
3669 cfg.feature_flags.narwhal_certificate_v2 = true;
3670 }
3671
3672 cfg.random_beacon_reduction_allowed_delta = Some(800);
3673 if chain != Chain::Mainnet {
3675 cfg.feature_flags.enable_effects_v2 = true;
3676 }
3677
3678 cfg.feature_flags.zklogin_supported_providers = BTreeSet::default();
3682
3683 cfg.feature_flags.recompute_has_public_transfer_in_execution = true;
3684 }
3685 31 => {
3686 cfg.execution_version = Some(2);
3687 if chain != Chain::Mainnet && chain != Chain::Testnet {
3689 cfg.feature_flags.shared_object_deletion = true;
3690 }
3691 }
3692 32 => {
3693 if chain != Chain::Mainnet {
3695 cfg.feature_flags.accept_zklogin_in_multisig = true;
3696 }
3697 if chain != Chain::Mainnet {
3699 cfg.transfer_receive_object_cost_base = Some(52);
3700 cfg.feature_flags.receive_objects = true;
3701 }
3702 if chain != Chain::Mainnet && chain != Chain::Testnet {
3704 cfg.feature_flags.random_beacon = true;
3705 cfg.random_beacon_reduction_lower_bound = Some(1600);
3706 cfg.random_beacon_dkg_timeout_round = Some(3000);
3707 cfg.random_beacon_min_round_interval_ms = Some(150);
3708 }
3709 if chain != Chain::Testnet && chain != Chain::Mainnet {
3711 cfg.feature_flags.include_consensus_digest_in_prologue = true;
3712 }
3713
3714 cfg.feature_flags.narwhal_certificate_v2 = true;
3716 }
3717 33 => {
3718 cfg.feature_flags.hardened_otw_check = true;
3719 cfg.feature_flags.allow_receiving_object_id = true;
3720
3721 cfg.transfer_receive_object_cost_base = Some(52);
3723 cfg.feature_flags.receive_objects = true;
3724
3725 if chain != Chain::Mainnet {
3727 cfg.feature_flags.shared_object_deletion = true;
3728 }
3729
3730 cfg.feature_flags.enable_effects_v2 = true;
3731 }
3732 34 => {}
3733 35 => {
3734 if chain != Chain::Mainnet && chain != Chain::Testnet {
3736 cfg.feature_flags.enable_poseidon = true;
3737 cfg.poseidon_bn254_cost_base = Some(260);
3738 cfg.poseidon_bn254_cost_per_block = Some(10);
3739 }
3740
3741 cfg.feature_flags.enable_coin_deny_list = true;
3742 }
3743 36 => {
3744 if chain != Chain::Mainnet && chain != Chain::Testnet {
3746 cfg.feature_flags.enable_group_ops_native_functions = true;
3747 cfg.feature_flags.enable_group_ops_native_function_msm = true;
3748 cfg.group_ops_bls12381_decode_scalar_cost = Some(52);
3750 cfg.group_ops_bls12381_decode_g1_cost = Some(52);
3751 cfg.group_ops_bls12381_decode_g2_cost = Some(52);
3752 cfg.group_ops_bls12381_decode_gt_cost = Some(52);
3753 cfg.group_ops_bls12381_scalar_add_cost = Some(52);
3754 cfg.group_ops_bls12381_g1_add_cost = Some(52);
3755 cfg.group_ops_bls12381_g2_add_cost = Some(52);
3756 cfg.group_ops_bls12381_gt_add_cost = Some(52);
3757 cfg.group_ops_bls12381_scalar_sub_cost = Some(52);
3758 cfg.group_ops_bls12381_g1_sub_cost = Some(52);
3759 cfg.group_ops_bls12381_g2_sub_cost = Some(52);
3760 cfg.group_ops_bls12381_gt_sub_cost = Some(52);
3761 cfg.group_ops_bls12381_scalar_mul_cost = Some(52);
3762 cfg.group_ops_bls12381_g1_mul_cost = Some(52);
3763 cfg.group_ops_bls12381_g2_mul_cost = Some(52);
3764 cfg.group_ops_bls12381_gt_mul_cost = Some(52);
3765 cfg.group_ops_bls12381_scalar_div_cost = Some(52);
3766 cfg.group_ops_bls12381_g1_div_cost = Some(52);
3767 cfg.group_ops_bls12381_g2_div_cost = Some(52);
3768 cfg.group_ops_bls12381_gt_div_cost = Some(52);
3769 cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(52);
3770 cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(52);
3771 cfg.group_ops_bls12381_g1_hash_to_cost_per_byte = Some(2);
3772 cfg.group_ops_bls12381_g2_hash_to_cost_per_byte = Some(2);
3773 cfg.group_ops_bls12381_g1_msm_base_cost = Some(52);
3774 cfg.group_ops_bls12381_g2_msm_base_cost = Some(52);
3775 cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(52);
3776 cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(52);
3777 cfg.group_ops_bls12381_msm_max_len = Some(32);
3778 cfg.group_ops_bls12381_pairing_cost = Some(52);
3779 }
3780 cfg.feature_flags.shared_object_deletion = true;
3782
3783 cfg.consensus_max_transaction_size_bytes = Some(256 * 1024); cfg.consensus_max_transactions_in_block_bytes = Some(6 * 1_024 * 1024);
3785 }
3787 37 => {
3788 cfg.feature_flags.reject_mutable_random_on_entry_functions = true;
3789
3790 if chain != Chain::Mainnet {
3792 cfg.feature_flags.include_consensus_digest_in_prologue = true;
3793 }
3794 }
3795 38 => {
3796 cfg.binary_module_handles = Some(100);
3797 cfg.binary_struct_handles = Some(300);
3798 cfg.binary_function_handles = Some(1500);
3799 cfg.binary_function_instantiations = Some(750);
3800 cfg.binary_signatures = Some(1000);
3801 cfg.binary_constant_pool = Some(4000);
3805 cfg.binary_identifiers = Some(10000);
3806 cfg.binary_address_identifiers = Some(100);
3807 cfg.binary_struct_defs = Some(200);
3808 cfg.binary_struct_def_instantiations = Some(100);
3809 cfg.binary_function_defs = Some(1000);
3810 cfg.binary_field_handles = Some(500);
3811 cfg.binary_field_instantiations = Some(250);
3812 cfg.binary_friend_decls = Some(100);
3813 cfg.max_package_dependencies = Some(32);
3815 cfg.max_modules_in_publish = Some(64);
3816 cfg.execution_version = Some(3);
3818 }
3819 39 => {
3820 }
3822 40 => {}
3823 41 => {
3824 cfg.feature_flags.enable_group_ops_native_functions = true;
3826 cfg.group_ops_bls12381_decode_scalar_cost = Some(52);
3828 cfg.group_ops_bls12381_decode_g1_cost = Some(52);
3829 cfg.group_ops_bls12381_decode_g2_cost = Some(52);
3830 cfg.group_ops_bls12381_decode_gt_cost = Some(52);
3831 cfg.group_ops_bls12381_scalar_add_cost = Some(52);
3832 cfg.group_ops_bls12381_g1_add_cost = Some(52);
3833 cfg.group_ops_bls12381_g2_add_cost = Some(52);
3834 cfg.group_ops_bls12381_gt_add_cost = Some(52);
3835 cfg.group_ops_bls12381_scalar_sub_cost = Some(52);
3836 cfg.group_ops_bls12381_g1_sub_cost = Some(52);
3837 cfg.group_ops_bls12381_g2_sub_cost = Some(52);
3838 cfg.group_ops_bls12381_gt_sub_cost = Some(52);
3839 cfg.group_ops_bls12381_scalar_mul_cost = Some(52);
3840 cfg.group_ops_bls12381_g1_mul_cost = Some(52);
3841 cfg.group_ops_bls12381_g2_mul_cost = Some(52);
3842 cfg.group_ops_bls12381_gt_mul_cost = Some(52);
3843 cfg.group_ops_bls12381_scalar_div_cost = Some(52);
3844 cfg.group_ops_bls12381_g1_div_cost = Some(52);
3845 cfg.group_ops_bls12381_g2_div_cost = Some(52);
3846 cfg.group_ops_bls12381_gt_div_cost = Some(52);
3847 cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(52);
3848 cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(52);
3849 cfg.group_ops_bls12381_g1_hash_to_cost_per_byte = Some(2);
3850 cfg.group_ops_bls12381_g2_hash_to_cost_per_byte = Some(2);
3851 cfg.group_ops_bls12381_g1_msm_base_cost = Some(52);
3852 cfg.group_ops_bls12381_g2_msm_base_cost = Some(52);
3853 cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(52);
3854 cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(52);
3855 cfg.group_ops_bls12381_msm_max_len = Some(32);
3856 cfg.group_ops_bls12381_pairing_cost = Some(52);
3857 }
3858 42 => {}
3859 43 => {
3860 cfg.feature_flags.zklogin_max_epoch_upper_bound_delta = Some(30);
3861 cfg.max_meter_ticks_per_package = Some(16_000_000);
3862 }
3863 44 => {
3864 cfg.feature_flags.include_consensus_digest_in_prologue = true;
3866 if chain != Chain::Mainnet {
3868 cfg.feature_flags.consensus_choice = ConsensusChoice::SwapEachEpoch;
3869 }
3870 }
3871 45 => {
3872 if chain != Chain::Testnet && chain != Chain::Mainnet {
3874 cfg.feature_flags.consensus_network = ConsensusNetwork::Tonic;
3875 }
3876
3877 if chain != Chain::Mainnet {
3878 cfg.feature_flags.mysticeti_leader_scoring_and_schedule = true;
3880 }
3881 cfg.min_move_binary_format_version = Some(6);
3882 cfg.feature_flags.accept_zklogin_in_multisig = true;
3883
3884 if chain != Chain::Mainnet && chain != Chain::Testnet {
3888 cfg.feature_flags.bridge = true;
3889 }
3890 }
3891 46 => {
3892 if chain != Chain::Mainnet {
3894 cfg.feature_flags.bridge = true;
3895 }
3896
3897 cfg.feature_flags.reshare_at_same_initial_version = true;
3899 }
3900 47 => {}
3901 48 => {
3902 cfg.feature_flags.consensus_network = ConsensusNetwork::Tonic;
3904
3905 cfg.feature_flags.resolve_abort_locations_to_package_id = true;
3907
3908 if chain != Chain::Mainnet {
3910 cfg.feature_flags.random_beacon = true;
3911 cfg.random_beacon_reduction_lower_bound = Some(1600);
3912 cfg.random_beacon_dkg_timeout_round = Some(3000);
3913 cfg.random_beacon_min_round_interval_ms = Some(200);
3914 }
3915
3916 cfg.feature_flags.mysticeti_use_committed_subdag_digest = true;
3918 }
3919 49 => {
3920 if chain != Chain::Testnet && chain != Chain::Mainnet {
3921 cfg.move_binary_format_version = Some(7);
3922 }
3923
3924 if chain != Chain::Mainnet && chain != Chain::Testnet {
3926 cfg.feature_flags.enable_vdf = true;
3927 cfg.vdf_verify_vdf_cost = Some(1500);
3930 cfg.vdf_hash_to_input_cost = Some(100);
3931 }
3932
3933 if chain != Chain::Testnet && chain != Chain::Mainnet {
3935 cfg.feature_flags
3936 .record_consensus_determined_version_assignments_in_prologue = true;
3937 }
3938
3939 if chain != Chain::Mainnet {
3941 cfg.feature_flags.consensus_choice = ConsensusChoice::Mysticeti;
3942 }
3943
3944 cfg.feature_flags.fresh_vm_on_framework_upgrade = true;
3946 }
3947 50 => {
3948 if chain != Chain::Mainnet {
3950 cfg.checkpoint_summary_version_specific_data = Some(1);
3951 cfg.min_checkpoint_interval_ms = Some(200);
3952 }
3953
3954 if chain != Chain::Testnet && chain != Chain::Mainnet {
3956 cfg.feature_flags
3957 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = true;
3958 }
3959
3960 cfg.feature_flags.mysticeti_num_leaders_per_round = Some(1);
3961
3962 cfg.max_deferral_rounds_for_congestion_control = Some(10);
3964 }
3965 51 => {
3966 cfg.random_beacon_dkg_version = Some(1);
3967
3968 if chain != Chain::Testnet && chain != Chain::Mainnet {
3969 cfg.feature_flags.enable_coin_deny_list_v2 = true;
3970 }
3971 }
3972 52 => {
3973 if chain != Chain::Mainnet {
3974 cfg.feature_flags.soft_bundle = true;
3975 cfg.max_soft_bundle_size = Some(5);
3976 }
3977
3978 cfg.config_read_setting_impl_cost_base = Some(100);
3979 cfg.config_read_setting_impl_cost_per_byte = Some(40);
3980
3981 if chain != Chain::Testnet && chain != Chain::Mainnet {
3983 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(100);
3984 cfg.feature_flags.per_object_congestion_control_mode =
3985 PerObjectCongestionControlMode::TotalTxCount;
3986 }
3987
3988 cfg.feature_flags.consensus_choice = ConsensusChoice::Mysticeti;
3990
3991 cfg.feature_flags.mysticeti_leader_scoring_and_schedule = true;
3993
3994 cfg.checkpoint_summary_version_specific_data = Some(1);
3996 cfg.min_checkpoint_interval_ms = Some(200);
3997
3998 if chain != Chain::Mainnet {
4000 cfg.feature_flags
4001 .record_consensus_determined_version_assignments_in_prologue = true;
4002 cfg.feature_flags
4003 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = true;
4004 }
4005 if chain != Chain::Mainnet {
4007 cfg.move_binary_format_version = Some(7);
4008 }
4009
4010 if chain != Chain::Testnet && chain != Chain::Mainnet {
4011 cfg.feature_flags.passkey_auth = true;
4012 }
4013 cfg.feature_flags.enable_coin_deny_list_v2 = true;
4014 }
4015 53 => {
4016 cfg.bridge_should_try_to_finalize_committee = Some(chain != Chain::Mainnet);
4018
4019 cfg.feature_flags
4021 .record_consensus_determined_version_assignments_in_prologue = true;
4022 cfg.feature_flags
4023 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = true;
4024
4025 if chain == Chain::Unknown {
4026 cfg.feature_flags.authority_capabilities_v2 = true;
4027 }
4028
4029 if chain != Chain::Mainnet {
4031 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(100);
4032 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(10);
4033 cfg.feature_flags.per_object_congestion_control_mode =
4034 PerObjectCongestionControlMode::TotalTxCount;
4035 }
4036
4037 cfg.bcs_per_byte_serialized_cost = Some(2);
4039 cfg.bcs_legacy_min_output_size_cost = Some(1);
4040 cfg.bcs_failure_cost = Some(52);
4041 cfg.debug_print_base_cost = Some(52);
4042 cfg.debug_print_stack_trace_base_cost = Some(52);
4043 cfg.hash_sha2_256_base_cost = Some(52);
4044 cfg.hash_sha2_256_per_byte_cost = Some(2);
4045 cfg.hash_sha2_256_legacy_min_input_len_cost = Some(1);
4046 cfg.hash_sha3_256_base_cost = Some(52);
4047 cfg.hash_sha3_256_per_byte_cost = Some(2);
4048 cfg.hash_sha3_256_legacy_min_input_len_cost = Some(1);
4049 cfg.type_name_get_base_cost = Some(52);
4050 cfg.type_name_get_per_byte_cost = Some(2);
4051 cfg.string_check_utf8_base_cost = Some(52);
4052 cfg.string_check_utf8_per_byte_cost = Some(2);
4053 cfg.string_is_char_boundary_base_cost = Some(52);
4054 cfg.string_sub_string_base_cost = Some(52);
4055 cfg.string_sub_string_per_byte_cost = Some(2);
4056 cfg.string_index_of_base_cost = Some(52);
4057 cfg.string_index_of_per_byte_pattern_cost = Some(2);
4058 cfg.string_index_of_per_byte_searched_cost = Some(2);
4059 cfg.vector_empty_base_cost = Some(52);
4060 cfg.vector_length_base_cost = Some(52);
4061 cfg.vector_push_back_base_cost = Some(52);
4062 cfg.vector_push_back_legacy_per_abstract_memory_unit_cost = Some(2);
4063 cfg.vector_borrow_base_cost = Some(52);
4064 cfg.vector_pop_back_base_cost = Some(52);
4065 cfg.vector_destroy_empty_base_cost = Some(52);
4066 cfg.vector_swap_base_cost = Some(52);
4067 }
4068 54 => {
4069 cfg.feature_flags.random_beacon = true;
4071 cfg.random_beacon_reduction_lower_bound = Some(1000);
4072 cfg.random_beacon_dkg_timeout_round = Some(3000);
4073 cfg.random_beacon_min_round_interval_ms = Some(500);
4074
4075 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(100);
4077 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(10);
4078 cfg.feature_flags.per_object_congestion_control_mode =
4079 PerObjectCongestionControlMode::TotalTxCount;
4080
4081 cfg.feature_flags.soft_bundle = true;
4083 cfg.max_soft_bundle_size = Some(5);
4084 }
4085 55 => {
4086 cfg.move_binary_format_version = Some(7);
4088
4089 cfg.consensus_max_transactions_in_block_bytes = Some(512 * 1024);
4091 cfg.consensus_max_num_transactions_in_block = Some(512);
4094
4095 cfg.feature_flags.rethrow_serialization_type_layout_errors = true;
4096 }
4097 56 => {
4098 if chain == Chain::Mainnet {
4099 cfg.feature_flags.bridge = true;
4100 }
4101 }
4102 57 => {
4103 cfg.random_beacon_reduction_lower_bound = Some(800);
4105 }
4106 58 => {
4107 if chain == Chain::Mainnet {
4108 cfg.bridge_should_try_to_finalize_committee = Some(true);
4109 }
4110
4111 if chain != Chain::Mainnet && chain != Chain::Testnet {
4112 cfg.feature_flags
4114 .consensus_distributed_vote_scoring_strategy = true;
4115 }
4116 }
4117 59 => {
4118 cfg.feature_flags.consensus_round_prober = true;
4120 }
4121 60 => {
4122 cfg.max_type_to_layout_nodes = Some(512);
4123 cfg.feature_flags.validate_identifier_inputs = true;
4124 }
4125 61 => {
4126 if chain != Chain::Mainnet {
4127 cfg.feature_flags
4129 .consensus_distributed_vote_scoring_strategy = true;
4130 }
4131 cfg.random_beacon_reduction_lower_bound = Some(700);
4133
4134 if chain != Chain::Mainnet && chain != Chain::Testnet {
4135 cfg.feature_flags.mysticeti_fastpath = true;
4137 }
4138 }
4139 62 => {
4140 cfg.feature_flags.relocate_event_module = true;
4141 }
4142 63 => {
4143 cfg.feature_flags.per_object_congestion_control_mode =
4144 PerObjectCongestionControlMode::TotalGasBudgetWithCap;
4145 cfg.gas_budget_based_txn_cost_cap_factor = Some(400_000);
4146 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(18_500_000);
4147 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(240_000_000);
4148 }
4149 64 => {
4150 cfg.feature_flags.per_object_congestion_control_mode =
4151 PerObjectCongestionControlMode::TotalTxCount;
4152 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(40);
4153 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(3);
4154 }
4155 65 => {
4156 cfg.feature_flags
4158 .consensus_distributed_vote_scoring_strategy = true;
4159 }
4160 66 => {
4161 if chain == Chain::Mainnet {
4162 cfg.feature_flags
4164 .consensus_distributed_vote_scoring_strategy = false;
4165 }
4166 }
4167 67 => {
4168 cfg.feature_flags
4170 .consensus_distributed_vote_scoring_strategy = true;
4171 }
4172 68 => {
4173 cfg.group_ops_bls12381_g1_to_uncompressed_g1_cost = Some(26);
4174 cfg.group_ops_bls12381_uncompressed_g1_to_g1_cost = Some(52);
4175 cfg.group_ops_bls12381_uncompressed_g1_sum_base_cost = Some(26);
4176 cfg.group_ops_bls12381_uncompressed_g1_sum_cost_per_term = Some(13);
4177 cfg.group_ops_bls12381_uncompressed_g1_sum_max_terms = Some(2000);
4178
4179 if chain != Chain::Mainnet && chain != Chain::Testnet {
4180 cfg.feature_flags.uncompressed_g1_group_elements = true;
4181 }
4182
4183 cfg.feature_flags.per_object_congestion_control_mode =
4184 PerObjectCongestionControlMode::TotalGasBudgetWithCap;
4185 cfg.gas_budget_based_txn_cost_cap_factor = Some(400_000);
4186 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(18_500_000);
4187 cfg.max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit =
4188 Some(3_700_000); cfg.max_txn_cost_overage_per_object_in_commit = Some(u64::MAX);
4190 cfg.gas_budget_based_txn_cost_absolute_cap_commit_count = Some(50);
4191
4192 cfg.random_beacon_reduction_lower_bound = Some(500);
4194
4195 cfg.feature_flags.disallow_new_modules_in_deps_only_packages = true;
4196 }
4197 69 => {
4198 cfg.consensus_voting_rounds = Some(40);
4200
4201 if chain != Chain::Mainnet && chain != Chain::Testnet {
4202 cfg.feature_flags.consensus_smart_ancestor_selection = true;
4204 }
4205
4206 if chain != Chain::Mainnet {
4207 cfg.feature_flags.uncompressed_g1_group_elements = true;
4208 }
4209 }
4210 70 => {
4211 if chain != Chain::Mainnet {
4212 cfg.feature_flags.consensus_smart_ancestor_selection = true;
4214 cfg.feature_flags
4216 .consensus_round_prober_probe_accepted_rounds = true;
4217 }
4218
4219 cfg.poseidon_bn254_cost_per_block = Some(388);
4220
4221 cfg.gas_model_version = Some(9);
4222 cfg.feature_flags.native_charging_v2 = true;
4223 cfg.bls12381_bls12381_min_sig_verify_cost_base = Some(44064);
4224 cfg.bls12381_bls12381_min_pk_verify_cost_base = Some(49282);
4225 cfg.ecdsa_k1_secp256k1_verify_keccak256_cost_base = Some(1470);
4226 cfg.ecdsa_k1_secp256k1_verify_sha256_cost_base = Some(1470);
4227 cfg.ecdsa_r1_secp256r1_verify_sha256_cost_base = Some(4225);
4228 cfg.ecdsa_r1_secp256r1_verify_keccak256_cost_base = Some(4225);
4229 cfg.ecvrf_ecvrf_verify_cost_base = Some(4848);
4230 cfg.ed25519_ed25519_verify_cost_base = Some(1802);
4231
4232 cfg.ecdsa_r1_ecrecover_keccak256_cost_base = Some(1173);
4234 cfg.ecdsa_r1_ecrecover_sha256_cost_base = Some(1173);
4235 cfg.ecdsa_k1_ecrecover_keccak256_cost_base = Some(500);
4236 cfg.ecdsa_k1_ecrecover_sha256_cost_base = Some(500);
4237
4238 cfg.groth16_prepare_verifying_key_bls12381_cost_base = Some(53838);
4239 cfg.groth16_prepare_verifying_key_bn254_cost_base = Some(82010);
4240 cfg.groth16_verify_groth16_proof_internal_bls12381_cost_base = Some(72090);
4241 cfg.groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input =
4242 Some(8213);
4243 cfg.groth16_verify_groth16_proof_internal_bn254_cost_base = Some(115502);
4244 cfg.groth16_verify_groth16_proof_internal_bn254_cost_per_public_input =
4245 Some(9484);
4246
4247 cfg.hash_keccak256_cost_base = Some(10);
4248 cfg.hash_blake2b256_cost_base = Some(10);
4249
4250 cfg.group_ops_bls12381_decode_scalar_cost = Some(7);
4252 cfg.group_ops_bls12381_decode_g1_cost = Some(2848);
4253 cfg.group_ops_bls12381_decode_g2_cost = Some(3770);
4254 cfg.group_ops_bls12381_decode_gt_cost = Some(3068);
4255
4256 cfg.group_ops_bls12381_scalar_add_cost = Some(10);
4257 cfg.group_ops_bls12381_g1_add_cost = Some(1556);
4258 cfg.group_ops_bls12381_g2_add_cost = Some(3048);
4259 cfg.group_ops_bls12381_gt_add_cost = Some(188);
4260
4261 cfg.group_ops_bls12381_scalar_sub_cost = Some(10);
4262 cfg.group_ops_bls12381_g1_sub_cost = Some(1550);
4263 cfg.group_ops_bls12381_g2_sub_cost = Some(3019);
4264 cfg.group_ops_bls12381_gt_sub_cost = Some(497);
4265
4266 cfg.group_ops_bls12381_scalar_mul_cost = Some(11);
4267 cfg.group_ops_bls12381_g1_mul_cost = Some(4842);
4268 cfg.group_ops_bls12381_g2_mul_cost = Some(9108);
4269 cfg.group_ops_bls12381_gt_mul_cost = Some(27490);
4270
4271 cfg.group_ops_bls12381_scalar_div_cost = Some(91);
4272 cfg.group_ops_bls12381_g1_div_cost = Some(5091);
4273 cfg.group_ops_bls12381_g2_div_cost = Some(9206);
4274 cfg.group_ops_bls12381_gt_div_cost = Some(27804);
4275
4276 cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(2962);
4277 cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(8688);
4278
4279 cfg.group_ops_bls12381_g1_msm_base_cost = Some(62648);
4280 cfg.group_ops_bls12381_g2_msm_base_cost = Some(131192);
4281 cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(1333);
4282 cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(3216);
4283
4284 cfg.group_ops_bls12381_uncompressed_g1_to_g1_cost = Some(677);
4285 cfg.group_ops_bls12381_g1_to_uncompressed_g1_cost = Some(2099);
4286 cfg.group_ops_bls12381_uncompressed_g1_sum_base_cost = Some(77);
4287 cfg.group_ops_bls12381_uncompressed_g1_sum_cost_per_term = Some(26);
4288
4289 cfg.group_ops_bls12381_pairing_cost = Some(26897);
4290 cfg.group_ops_bls12381_uncompressed_g1_sum_max_terms = Some(1200);
4291
4292 cfg.validator_validate_metadata_cost_base = Some(20000);
4293 }
4294 71 => {
4295 cfg.sip_45_consensus_amplification_threshold = Some(5);
4296
4297 cfg.allowed_txn_cost_overage_burst_per_object_in_commit = Some(185_000_000);
4299 }
4300 72 => {
4301 cfg.feature_flags.convert_type_argument_error = true;
4302
4303 cfg.max_tx_gas = Some(50_000_000_000_000);
4306 cfg.max_gas_price = Some(50_000_000_000);
4308
4309 cfg.feature_flags.variant_nodes = true;
4310 }
4311 73 => {
4312 cfg.use_object_per_epoch_marker_table_v2 = Some(true);
4314
4315 if chain != Chain::Mainnet && chain != Chain::Testnet {
4316 cfg.consensus_gc_depth = Some(60);
4319 }
4320
4321 if chain != Chain::Mainnet {
4322 cfg.feature_flags.consensus_zstd_compression = true;
4324 }
4325
4326 cfg.feature_flags.consensus_smart_ancestor_selection = true;
4328 cfg.feature_flags
4330 .consensus_round_prober_probe_accepted_rounds = true;
4331
4332 cfg.feature_flags.per_object_congestion_control_mode =
4334 PerObjectCongestionControlMode::TotalGasBudgetWithCap;
4335 cfg.gas_budget_based_txn_cost_cap_factor = Some(400_000);
4336 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(37_000_000);
4337 cfg.max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit =
4338 Some(7_400_000); cfg.max_txn_cost_overage_per_object_in_commit = Some(u64::MAX);
4340 cfg.gas_budget_based_txn_cost_absolute_cap_commit_count = Some(50);
4341 cfg.allowed_txn_cost_overage_burst_per_object_in_commit = Some(370_000_000);
4342 }
4343 74 => {
4344 if chain != Chain::Mainnet && chain != Chain::Testnet {
4346 cfg.feature_flags.enable_nitro_attestation = true;
4347 }
4348 cfg.nitro_attestation_parse_base_cost = Some(53 * 50);
4349 cfg.nitro_attestation_parse_cost_per_byte = Some(50);
4350 cfg.nitro_attestation_verify_base_cost = Some(49632 * 50);
4351 cfg.nitro_attestation_verify_cost_per_cert = Some(52369 * 50);
4352
4353 cfg.feature_flags.consensus_zstd_compression = true;
4355
4356 if chain != Chain::Mainnet && chain != Chain::Testnet {
4357 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
4358 }
4359 }
4360 75 => {
4361 if chain != Chain::Mainnet {
4362 cfg.feature_flags.passkey_auth = true;
4363 }
4364 }
4365 76 => {
4366 if chain != Chain::Mainnet && chain != Chain::Testnet {
4367 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
4368 cfg.consensus_commit_rate_estimation_window_size = Some(10);
4369 }
4370 cfg.feature_flags.minimize_child_object_mutations = true;
4371
4372 if chain != Chain::Mainnet {
4373 cfg.feature_flags.accept_passkey_in_multisig = true;
4374 }
4375 }
4376 77 => {
4377 cfg.feature_flags.uncompressed_g1_group_elements = true;
4378
4379 if chain != Chain::Mainnet {
4380 cfg.consensus_gc_depth = Some(60);
4381 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
4382 }
4383 }
4384 78 => {
4385 cfg.feature_flags.move_native_context = true;
4386 cfg.tx_context_fresh_id_cost_base = Some(52);
4387 cfg.tx_context_sender_cost_base = Some(30);
4388 cfg.tx_context_epoch_cost_base = Some(30);
4389 cfg.tx_context_epoch_timestamp_ms_cost_base = Some(30);
4390 cfg.tx_context_sponsor_cost_base = Some(30);
4391 cfg.tx_context_gas_price_cost_base = Some(30);
4392 cfg.tx_context_gas_budget_cost_base = Some(30);
4393 cfg.tx_context_ids_created_cost_base = Some(30);
4394 cfg.tx_context_replace_cost_base = Some(30);
4395 cfg.gas_model_version = Some(10);
4396
4397 if chain != Chain::Mainnet {
4398 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
4399 cfg.consensus_commit_rate_estimation_window_size = Some(10);
4400
4401 cfg.feature_flags.per_object_congestion_control_mode =
4403 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4404 ExecutionTimeEstimateParams {
4405 target_utilization: 30,
4406 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4408 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4410 stored_observations_limit: u64::MAX,
4411 stake_weighted_median_threshold: 0,
4412 default_none_duration_for_new_keys: false,
4413 observations_chunk_size: None,
4414 },
4415 );
4416 }
4417 }
4418 79 => {
4419 if chain != Chain::Mainnet {
4420 cfg.feature_flags.consensus_median_based_commit_timestamp = true;
4421
4422 cfg.consensus_bad_nodes_stake_threshold = Some(30);
4425
4426 cfg.feature_flags.consensus_batched_block_sync = true;
4427
4428 cfg.feature_flags.enable_nitro_attestation = true
4430 }
4431 cfg.feature_flags.normalize_ptb_arguments = true;
4432
4433 cfg.consensus_gc_depth = Some(60);
4434 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
4435 }
4436 80 => {
4437 cfg.max_ptb_value_size = Some(1024 * 1024);
4438 }
4439 81 => {
4440 cfg.feature_flags.consensus_median_based_commit_timestamp = true;
4441 cfg.feature_flags.enforce_checkpoint_timestamp_monotonicity = true;
4442 cfg.consensus_bad_nodes_stake_threshold = Some(30)
4443 }
4444 82 => {
4445 cfg.feature_flags.max_ptb_value_size_v2 = true;
4446 }
4447 83 => {
4448 if chain == Chain::Mainnet {
4449 let aliased: [u8; 32] = Hex::decode(
4451 "0x0b2da327ba6a4cacbe75dddd50e6e8bbf81d6496e92d66af9154c61c77f7332f",
4452 )
4453 .unwrap()
4454 .try_into()
4455 .unwrap();
4456
4457 cfg.aliased_addresses.push(AliasedAddress {
4459 original: Hex::decode("0xcd8962dad278d8b50fa0f9eb0186bfa4cbdecc6d59377214c88d0286a0ac9562").unwrap().try_into().unwrap(),
4460 aliased,
4461 allowed_tx_digests: vec![
4462 Base58::decode("B2eGLFoMHgj93Ni8dAJBfqGzo8EWSTLBesZzhEpTPA4").unwrap().try_into().unwrap(),
4463 ],
4464 });
4465
4466 cfg.aliased_addresses.push(AliasedAddress {
4467 original: Hex::decode("0xe28b50cef1d633ea43d3296a3f6b67ff0312a5f1a99f0af753c85b8b5de8ff06").unwrap().try_into().unwrap(),
4468 aliased,
4469 allowed_tx_digests: vec![
4470 Base58::decode("J4QqSAgp7VrQtQpMy5wDX4QGsCSEZu3U5KuDAkbESAge").unwrap().try_into().unwrap(),
4471 ],
4472 });
4473 }
4474
4475 if chain != Chain::Mainnet {
4478 cfg.feature_flags.resolve_type_input_ids_to_defining_id = true;
4479 cfg.transfer_party_transfer_internal_cost_base = Some(52);
4480
4481 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
4483 cfg.consensus_commit_rate_estimation_window_size = Some(10);
4484 cfg.feature_flags.per_object_congestion_control_mode =
4485 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4486 ExecutionTimeEstimateParams {
4487 target_utilization: 30,
4488 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4490 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4492 stored_observations_limit: u64::MAX,
4493 stake_weighted_median_threshold: 0,
4494 default_none_duration_for_new_keys: false,
4495 observations_chunk_size: None,
4496 },
4497 );
4498
4499 cfg.feature_flags.consensus_batched_block_sync = true;
4501
4502 cfg.feature_flags.enable_nitro_attestation_upgraded_parsing = true;
4505 cfg.feature_flags.enable_nitro_attestation = true;
4506 }
4507 }
4508 84 => {
4509 if chain == Chain::Mainnet {
4510 cfg.feature_flags.resolve_type_input_ids_to_defining_id = true;
4511 cfg.transfer_party_transfer_internal_cost_base = Some(52);
4512
4513 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
4515 cfg.consensus_commit_rate_estimation_window_size = Some(10);
4516 cfg.feature_flags.per_object_congestion_control_mode =
4517 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4518 ExecutionTimeEstimateParams {
4519 target_utilization: 30,
4520 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4522 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4524 stored_observations_limit: u64::MAX,
4525 stake_weighted_median_threshold: 0,
4526 default_none_duration_for_new_keys: false,
4527 observations_chunk_size: None,
4528 },
4529 );
4530
4531 cfg.feature_flags.consensus_batched_block_sync = true;
4533
4534 cfg.feature_flags.enable_nitro_attestation_upgraded_parsing = true;
4537 cfg.feature_flags.enable_nitro_attestation = true;
4538 }
4539
4540 cfg.feature_flags.per_object_congestion_control_mode =
4542 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4543 ExecutionTimeEstimateParams {
4544 target_utilization: 30,
4545 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4547 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4549 stored_observations_limit: 20,
4550 stake_weighted_median_threshold: 0,
4551 default_none_duration_for_new_keys: false,
4552 observations_chunk_size: None,
4553 },
4554 );
4555 cfg.feature_flags.allow_unbounded_system_objects = true;
4556 }
4557 85 => {
4558 if chain != Chain::Mainnet && chain != Chain::Testnet {
4559 cfg.feature_flags.enable_party_transfer = true;
4560 }
4561
4562 cfg.feature_flags
4563 .record_consensus_determined_version_assignments_in_prologue_v2 = true;
4564 cfg.feature_flags.disallow_self_identifier = true;
4565 cfg.feature_flags.per_object_congestion_control_mode =
4566 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4567 ExecutionTimeEstimateParams {
4568 target_utilization: 50,
4569 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4571 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4573 stored_observations_limit: 20,
4574 stake_weighted_median_threshold: 0,
4575 default_none_duration_for_new_keys: false,
4576 observations_chunk_size: None,
4577 },
4578 );
4579 }
4580 86 => {
4581 cfg.feature_flags.type_tags_in_object_runtime = true;
4582 cfg.max_move_enum_variants = Some(move_core_types::VARIANT_COUNT_MAX);
4583
4584 cfg.feature_flags.per_object_congestion_control_mode =
4586 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4587 ExecutionTimeEstimateParams {
4588 target_utilization: 50,
4589 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4591 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4593 stored_observations_limit: 20,
4594 stake_weighted_median_threshold: 3334,
4595 default_none_duration_for_new_keys: false,
4596 observations_chunk_size: None,
4597 },
4598 );
4599 if chain != Chain::Mainnet {
4601 cfg.feature_flags.enable_party_transfer = true;
4602 }
4603 }
4604 87 => {
4605 if chain == Chain::Mainnet {
4606 cfg.feature_flags.record_time_estimate_processed = true;
4607 }
4608 cfg.feature_flags.better_adapter_type_resolution_errors = true;
4609 }
4610 88 => {
4611 cfg.feature_flags.record_time_estimate_processed = true;
4612 cfg.tx_context_rgp_cost_base = Some(30);
4613 cfg.feature_flags
4614 .ignore_execution_time_observations_after_certs_closed = true;
4615
4616 cfg.feature_flags.per_object_congestion_control_mode =
4619 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4620 ExecutionTimeEstimateParams {
4621 target_utilization: 50,
4622 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4624 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4626 stored_observations_limit: 20,
4627 stake_weighted_median_threshold: 3334,
4628 default_none_duration_for_new_keys: true,
4629 observations_chunk_size: None,
4630 },
4631 );
4632 }
4633 89 => {
4634 cfg.feature_flags.dependency_linkage_error = true;
4635 cfg.feature_flags.additional_multisig_checks = true;
4636 }
4637 90 => {
4638 cfg.max_gas_price_rgp_factor_for_aborted_transactions = Some(100);
4640 cfg.feature_flags.debug_fatal_on_move_invariant_violation = true;
4641 cfg.feature_flags.additional_consensus_digest_indirect_state = true;
4642 cfg.feature_flags.accept_passkey_in_multisig = true;
4643 cfg.feature_flags.passkey_auth = true;
4644 cfg.feature_flags.check_for_init_during_upgrade = true;
4645
4646 if chain != Chain::Mainnet {
4648 cfg.feature_flags.mysticeti_fastpath = true;
4649 }
4650 }
4651 91 => {
4652 cfg.feature_flags.per_command_shared_object_transfer_rules = true;
4653 }
4654 92 => {
4655 cfg.feature_flags.per_command_shared_object_transfer_rules = false;
4656 }
4657 93 => {
4658 cfg.feature_flags
4659 .consensus_checkpoint_signature_key_includes_digest = true;
4660 }
4661 94 => {
4662 cfg.feature_flags.per_object_congestion_control_mode =
4664 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4665 ExecutionTimeEstimateParams {
4666 target_utilization: 50,
4667 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4669 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4671 stored_observations_limit: 18,
4672 stake_weighted_median_threshold: 3334,
4673 default_none_duration_for_new_keys: true,
4674 observations_chunk_size: None,
4675 },
4676 );
4677
4678 cfg.feature_flags.enable_party_transfer = true;
4680 }
4681 95 => {
4682 cfg.type_name_id_base_cost = Some(52);
4683
4684 cfg.max_transactions_per_checkpoint = Some(20_000);
4686 }
4687 96 => {
4688 if chain != Chain::Mainnet && chain != Chain::Testnet {
4690 cfg.feature_flags
4691 .include_checkpoint_artifacts_digest_in_summary = true;
4692 }
4693 cfg.feature_flags.correct_gas_payment_limit_check = true;
4694 cfg.feature_flags.authority_capabilities_v2 = true;
4695 cfg.feature_flags.use_mfp_txns_in_load_initial_object_debts = true;
4696 cfg.feature_flags.cancel_for_failed_dkg_early = true;
4697 cfg.feature_flags.enable_coin_registry = true;
4698
4699 cfg.feature_flags.mysticeti_fastpath = true;
4701 }
4702 97 => {
4703 cfg.feature_flags.additional_borrow_checks = true;
4704 }
4705 98 => {
4706 cfg.event_emit_auth_stream_cost = Some(52);
4707 cfg.feature_flags.better_loader_errors = true;
4708 cfg.feature_flags.generate_df_type_layouts = true;
4709 }
4710 99 => {
4711 cfg.feature_flags.use_new_commit_handler = true;
4712 }
4713 100 => {
4714 cfg.feature_flags.private_generics_verifier_v2 = true;
4715 }
4716 101 => {
4717 cfg.feature_flags.create_root_accumulator_object = true;
4718 cfg.max_updates_per_settlement_txn = Some(100);
4719 if chain != Chain::Mainnet {
4720 cfg.feature_flags.enable_poseidon = true;
4721 }
4722 }
4723 102 => {
4724 cfg.feature_flags.per_object_congestion_control_mode =
4728 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4729 ExecutionTimeEstimateParams {
4730 target_utilization: 50,
4731 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4733 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4735 stored_observations_limit: 180,
4736 stake_weighted_median_threshold: 3334,
4737 default_none_duration_for_new_keys: true,
4738 observations_chunk_size: Some(18),
4739 },
4740 );
4741 cfg.feature_flags.deprecate_global_storage_ops = true;
4742 }
4743 103 => {}
4744 104 => {
4745 cfg.translation_per_command_base_charge = Some(1);
4746 cfg.translation_per_input_base_charge = Some(1);
4747 cfg.translation_pure_input_per_byte_charge = Some(1);
4748 cfg.translation_per_type_node_charge = Some(1);
4749 cfg.translation_per_reference_node_charge = Some(1);
4750 cfg.translation_per_linkage_entry_charge = Some(10);
4751 cfg.gas_model_version = Some(11);
4752 cfg.feature_flags.abstract_size_in_object_runtime = true;
4753 cfg.feature_flags.object_runtime_charge_cache_load_gas = true;
4754 cfg.dynamic_field_hash_type_and_key_cost_base = Some(52);
4755 cfg.dynamic_field_add_child_object_cost_base = Some(52);
4756 cfg.dynamic_field_add_child_object_value_cost_per_byte = Some(1);
4757 cfg.dynamic_field_borrow_child_object_cost_base = Some(52);
4758 cfg.dynamic_field_borrow_child_object_child_ref_cost_per_byte = Some(1);
4759 cfg.dynamic_field_remove_child_object_cost_base = Some(52);
4760 cfg.dynamic_field_remove_child_object_child_cost_per_byte = Some(1);
4761 cfg.dynamic_field_has_child_object_cost_base = Some(52);
4762 cfg.dynamic_field_has_child_object_with_ty_cost_base = Some(52);
4763 cfg.feature_flags.enable_ptb_execution_v2 = true;
4764
4765 cfg.poseidon_bn254_cost_base = Some(260);
4766
4767 cfg.feature_flags.consensus_skip_gced_accept_votes = true;
4768
4769 if chain != Chain::Mainnet {
4770 cfg.feature_flags
4771 .enable_nitro_attestation_all_nonzero_pcrs_parsing = true;
4772 }
4773
4774 cfg.feature_flags
4775 .include_cancelled_randomness_txns_in_prologue = true;
4776 }
4777 105 => {
4778 cfg.feature_flags.enable_multi_epoch_transaction_expiration = true;
4779 cfg.feature_flags.disable_preconsensus_locking = true;
4780
4781 if chain != Chain::Mainnet {
4782 cfg.feature_flags
4783 .enable_nitro_attestation_always_include_required_pcrs_parsing = true;
4784 }
4785 }
4786 106 => {
4787 cfg.accumulator_object_storage_cost = Some(7600);
4789
4790 if chain != Chain::Mainnet && chain != Chain::Testnet {
4791 cfg.feature_flags.enable_accumulators = true;
4792 cfg.feature_flags.enable_address_balance_gas_payments = true;
4793 cfg.feature_flags.enable_authenticated_event_streams = true;
4794 cfg.feature_flags.enable_object_funds_withdraw = true;
4795 }
4796 }
4797 107 => {
4798 cfg.feature_flags
4799 .consensus_skip_gced_blocks_in_direct_finalization = true;
4800
4801 if in_integration_test() {
4803 cfg.consensus_gc_depth = Some(6);
4804 cfg.consensus_max_num_transactions_in_block = Some(8);
4805 }
4806 }
4807 108 => {
4808 cfg.feature_flags.gas_rounding_halve_digits = true;
4809 cfg.feature_flags.flexible_tx_context_positions = true;
4810 cfg.feature_flags.disable_entry_point_signature_check = true;
4811
4812 if chain != Chain::Mainnet {
4813 cfg.feature_flags.address_aliases = true;
4814
4815 cfg.feature_flags.enable_accumulators = true;
4816 cfg.feature_flags.enable_address_balance_gas_payments = true;
4817 }
4818
4819 cfg.feature_flags.enable_poseidon = true;
4820 }
4821 109 => {
4822 cfg.binary_variant_handles = Some(1024);
4823 cfg.binary_variant_instantiation_handles = Some(1024);
4824 cfg.feature_flags.restrict_hot_or_not_entry_functions = true;
4825 }
4826 110 => {
4827 cfg.feature_flags
4828 .enable_nitro_attestation_all_nonzero_pcrs_parsing = true;
4829 cfg.feature_flags
4830 .enable_nitro_attestation_always_include_required_pcrs_parsing = true;
4831 if chain != Chain::Mainnet && chain != Chain::Testnet {
4832 cfg.feature_flags.split_checkpoints_in_consensus_handler = true;
4833 }
4834 cfg.feature_flags.validate_zklogin_public_identifier = true;
4835 cfg.feature_flags.fix_checkpoint_signature_mapping = true;
4836 cfg.feature_flags
4837 .consensus_always_accept_system_transactions = true;
4838 if chain != Chain::Mainnet {
4839 cfg.feature_flags.enable_object_funds_withdraw = true;
4840 }
4841 }
4842 111 => {
4843 cfg.feature_flags.validator_metadata_verify_v2 = true;
4844 }
4845 112 => {
4846 cfg.group_ops_ristretto_decode_scalar_cost = Some(7);
4847 cfg.group_ops_ristretto_decode_point_cost = Some(200);
4848 cfg.group_ops_ristretto_scalar_add_cost = Some(10);
4849 cfg.group_ops_ristretto_point_add_cost = Some(500);
4850 cfg.group_ops_ristretto_scalar_sub_cost = Some(10);
4851 cfg.group_ops_ristretto_point_sub_cost = Some(500);
4852 cfg.group_ops_ristretto_scalar_mul_cost = Some(11);
4853 cfg.group_ops_ristretto_point_mul_cost = Some(1200);
4854 cfg.group_ops_ristretto_scalar_div_cost = Some(151);
4855 cfg.group_ops_ristretto_point_div_cost = Some(2500);
4856
4857 if chain != Chain::Mainnet && chain != Chain::Testnet {
4858 cfg.feature_flags.enable_ristretto255_group_ops = true;
4859 }
4860 }
4861 113 => {
4862 cfg.feature_flags.address_balance_gas_check_rgp_at_signing = true;
4863 if chain != Chain::Mainnet && chain != Chain::Testnet {
4864 cfg.feature_flags.defer_unpaid_amplification = true;
4865 }
4866 }
4867 114 => {
4868 cfg.feature_flags.randomize_checkpoint_tx_limit_in_tests = true;
4869 cfg.feature_flags.address_balance_gas_reject_gas_coin_arg = true;
4870 if chain != Chain::Mainnet {
4871 cfg.feature_flags.split_checkpoints_in_consensus_handler = true;
4872 cfg.feature_flags.enable_authenticated_event_streams = true;
4873 cfg.feature_flags
4874 .include_checkpoint_artifacts_digest_in_summary = true;
4875 }
4876 }
4877 115 => {
4878 cfg.feature_flags.normalize_depth_formula = true;
4879 }
4880 116 => {
4881 cfg.feature_flags.gasless_transaction_drop_safety = true;
4882 cfg.feature_flags.address_aliases = true;
4883 cfg.feature_flags.relax_valid_during_for_owned_inputs = true;
4884 cfg.feature_flags.defer_unpaid_amplification = false;
4886 cfg.feature_flags.enable_display_registry = true;
4887 }
4888 117 => {}
4889 118 => {
4890 cfg.feature_flags.use_coin_party_owner = true;
4891 }
4892 119 => {
4893 cfg.execution_version = Some(4);
4895 cfg.feature_flags.address_balance_gas_reject_gas_coin_arg = false;
4896 cfg.feature_flags.merge_randomness_into_checkpoint = true;
4897 if chain != Chain::Mainnet {
4898 cfg.feature_flags.enable_gasless = true;
4899 cfg.gasless_max_computation_units = Some(50_000);
4900 cfg.gasless_allowed_token_types = Some(vec![]);
4901 cfg.feature_flags.enable_coin_reservation_obj_refs = true;
4902 cfg.feature_flags
4903 .convert_withdrawal_compatibility_ptb_arguments = true;
4904 }
4905 cfg.gasless_max_unused_inputs = Some(1);
4906 cfg.gasless_max_pure_input_bytes = Some(32);
4907 if chain == Chain::Testnet {
4908 cfg.gasless_allowed_token_types = Some(vec![(TESTNET_USDC.to_string(), 0)]);
4909 }
4910 cfg.transfer_receive_object_cost_per_byte = Some(1);
4911 cfg.transfer_receive_object_type_cost_per_byte = Some(2);
4912 }
4913 120 => {
4914 cfg.feature_flags.disallow_jump_orphans = true;
4915 }
4916 121 => {
4917 if chain != Chain::Mainnet {
4919 cfg.feature_flags.defer_unpaid_amplification = true;
4920 cfg.gasless_max_tps = Some(50);
4921 }
4922 cfg.feature_flags
4923 .early_return_receive_object_mismatched_type = true;
4924 }
4925 122 => {
4926 cfg.feature_flags.defer_unpaid_amplification = true;
4928 cfg.verify_bulletproofs_ristretto255_base_cost = Some(30000);
4930 cfg.verify_bulletproofs_ristretto255_cost_per_bit_and_commitment = Some(6500);
4931 if chain != Chain::Mainnet && chain != Chain::Testnet {
4932 cfg.feature_flags.enable_verify_bulletproofs_ristretto255 = true;
4933 }
4934 cfg.feature_flags.gasless_verify_remaining_balance = true;
4935 cfg.include_special_package_amendments = match chain {
4936 Chain::Mainnet => Some(MAINNET_LINKAGE_AMENDMENTS.clone()),
4937 Chain::Testnet => Some(TESTNET_LINKAGE_AMENDMENTS.clone()),
4938 Chain::Unknown => None,
4939 };
4940 cfg.gasless_max_tx_size_bytes = Some(16 * 1024);
4941 cfg.gasless_max_tps = Some(300);
4942 cfg.gasless_max_computation_units = Some(5_000);
4943 }
4944 123 => {
4945 cfg.gas_model_version = Some(13);
4946 }
4947 124 => {
4948 if chain != Chain::Mainnet && chain != Chain::Testnet {
4949 cfg.feature_flags.timestamp_based_epoch_close = true;
4950 }
4951 cfg.gas_model_version = Some(14);
4952 cfg.feature_flags.limit_groth16_pvk_inputs = true;
4953
4954 cfg.feature_flags.enable_accumulators = true;
4960 cfg.feature_flags.enable_address_balance_gas_payments = true;
4961 cfg.feature_flags.enable_authenticated_event_streams = true;
4962 cfg.feature_flags.enable_coin_reservation_obj_refs = true;
4963 cfg.feature_flags.enable_object_funds_withdraw = true;
4964 cfg.feature_flags
4965 .convert_withdrawal_compatibility_ptb_arguments = true;
4966 cfg.feature_flags.split_checkpoints_in_consensus_handler = true;
4967 cfg.feature_flags
4968 .include_checkpoint_artifacts_digest_in_summary = true;
4969 cfg.feature_flags.enable_gasless = true;
4970
4971 if chain == Chain::Mainnet {
4976 cfg.gasless_allowed_token_types = Some(vec![
4977 (MAINNET_USDC.to_string(), 10_000),
4978 (MAINNET_USDSUI.to_string(), 10_000),
4979 (MAINNET_SUI_USDE.to_string(), 10_000),
4980 (MAINNET_USDY.to_string(), 10_000),
4981 (MAINNET_FDUSD.to_string(), 10_000),
4982 (MAINNET_AUSD.to_string(), 10_000),
4983 (MAINNET_USDB.to_string(), 10_000),
4984 ]);
4985 }
4986 }
4987 125 => {
4988 cfg.feature_flags.granular_post_execution_checks = true;
4989 if chain != Chain::Mainnet {
4990 cfg.feature_flags.timestamp_based_epoch_close = true;
4991 }
4992 }
4993 126 => {
4994 cfg.feature_flags.early_exit_on_iffw = true;
4995 }
4996 _ => panic!("unsupported version {:?}", version),
5007 }
5008 }
5009
5010 cfg
5011 }
5012
5013 pub fn apply_seeded_test_overrides(&mut self, seed: &[u8; 32]) {
5014 if !self.feature_flags.randomize_checkpoint_tx_limit_in_tests
5015 || !self.feature_flags.split_checkpoints_in_consensus_handler
5016 {
5017 return;
5018 }
5019
5020 if !mysten_common::in_test_configuration() {
5021 return;
5022 }
5023
5024 use rand::{Rng, SeedableRng, rngs::StdRng};
5025 let mut rng = StdRng::from_seed(*seed);
5026 let max_txns = rng.gen_range(10..=100u64);
5027 info!("seeded test override: max_transactions_per_checkpoint = {max_txns}");
5028 self.max_transactions_per_checkpoint = Some(max_txns);
5029 }
5030
5031 pub fn verifier_config(&self, signing_limits: Option<(usize, usize, usize)>) -> VerifierConfig {
5037 let (
5038 max_back_edges_per_function,
5039 max_back_edges_per_module,
5040 sanity_check_with_regex_reference_safety,
5041 ) = if let Some((
5042 max_back_edges_per_function,
5043 max_back_edges_per_module,
5044 sanity_check_with_regex_reference_safety,
5045 )) = signing_limits
5046 {
5047 (
5048 Some(max_back_edges_per_function),
5049 Some(max_back_edges_per_module),
5050 Some(sanity_check_with_regex_reference_safety),
5051 )
5052 } else {
5053 (None, None, None)
5054 };
5055
5056 let additional_borrow_checks = if signing_limits.is_some() {
5057 true
5059 } else {
5060 self.additional_borrow_checks()
5061 };
5062 let deprecate_global_storage_ops = if signing_limits.is_some() {
5063 true
5065 } else {
5066 self.deprecate_global_storage_ops()
5067 };
5068
5069 VerifierConfig {
5070 max_loop_depth: Some(self.max_loop_depth() as usize),
5071 max_generic_instantiation_length: Some(self.max_generic_instantiation_length() as usize),
5072 max_function_parameters: Some(self.max_function_parameters() as usize),
5073 max_basic_blocks: Some(self.max_basic_blocks() as usize),
5074 max_value_stack_size: self.max_value_stack_size() as usize,
5075 max_type_nodes: Some(self.max_type_nodes() as usize),
5076 max_push_size: Some(self.max_push_size() as usize),
5077 max_dependency_depth: Some(self.max_dependency_depth() as usize),
5078 max_fields_in_struct: Some(self.max_fields_in_struct() as usize),
5079 max_function_definitions: Some(self.max_function_definitions() as usize),
5080 max_data_definitions: Some(self.max_struct_definitions() as usize),
5081 max_constant_vector_len: Some(self.max_move_vector_len()),
5082 max_back_edges_per_function,
5083 max_back_edges_per_module,
5084 max_basic_blocks_in_script: None,
5085 max_identifier_len: self.max_move_identifier_len_as_option(), disallow_self_identifier: self.feature_flags.disallow_self_identifier,
5087 allow_receiving_object_id: self.allow_receiving_object_id(),
5088 reject_mutable_random_on_entry_functions: self
5089 .reject_mutable_random_on_entry_functions(),
5090 bytecode_version: self.move_binary_format_version(),
5091 max_variants_in_enum: self.max_move_enum_variants_as_option(),
5092 additional_borrow_checks,
5093 better_loader_errors: self.better_loader_errors(),
5094 private_generics_verifier_v2: self.private_generics_verifier_v2(),
5095 sanity_check_with_regex_reference_safety: sanity_check_with_regex_reference_safety
5096 .map(|limit| limit as u128),
5097 deprecate_global_storage_ops,
5098 disable_entry_point_signature_check: self.disable_entry_point_signature_check(),
5099 switch_to_regex_reference_safety: false,
5100 disallow_jump_orphans: self.disallow_jump_orphans(),
5101 }
5102 }
5103
5104 pub fn binary_config(
5105 &self,
5106 override_deprecate_global_storage_ops_during_deserialization: Option<bool>,
5107 ) -> BinaryConfig {
5108 let deprecate_global_storage_ops =
5109 override_deprecate_global_storage_ops_during_deserialization
5110 .unwrap_or_else(|| self.deprecate_global_storage_ops());
5111 BinaryConfig::new(
5112 self.move_binary_format_version(),
5113 self.min_move_binary_format_version_as_option()
5114 .unwrap_or(VERSION_1),
5115 self.no_extraneous_module_bytes(),
5116 deprecate_global_storage_ops,
5117 TableConfig {
5118 module_handles: self.binary_module_handles_as_option().unwrap_or(u16::MAX),
5119 datatype_handles: self.binary_struct_handles_as_option().unwrap_or(u16::MAX),
5120 function_handles: self.binary_function_handles_as_option().unwrap_or(u16::MAX),
5121 function_instantiations: self
5122 .binary_function_instantiations_as_option()
5123 .unwrap_or(u16::MAX),
5124 signatures: self.binary_signatures_as_option().unwrap_or(u16::MAX),
5125 constant_pool: self.binary_constant_pool_as_option().unwrap_or(u16::MAX),
5126 identifiers: self.binary_identifiers_as_option().unwrap_or(u16::MAX),
5127 address_identifiers: self
5128 .binary_address_identifiers_as_option()
5129 .unwrap_or(u16::MAX),
5130 struct_defs: self.binary_struct_defs_as_option().unwrap_or(u16::MAX),
5131 struct_def_instantiations: self
5132 .binary_struct_def_instantiations_as_option()
5133 .unwrap_or(u16::MAX),
5134 function_defs: self.binary_function_defs_as_option().unwrap_or(u16::MAX),
5135 field_handles: self.binary_field_handles_as_option().unwrap_or(u16::MAX),
5136 field_instantiations: self
5137 .binary_field_instantiations_as_option()
5138 .unwrap_or(u16::MAX),
5139 friend_decls: self.binary_friend_decls_as_option().unwrap_or(u16::MAX),
5140 enum_defs: self.binary_enum_defs_as_option().unwrap_or(u16::MAX),
5141 enum_def_instantiations: self
5142 .binary_enum_def_instantiations_as_option()
5143 .unwrap_or(u16::MAX),
5144 variant_handles: self.binary_variant_handles_as_option().unwrap_or(u16::MAX),
5145 variant_instantiation_handles: self
5146 .binary_variant_instantiation_handles_as_option()
5147 .unwrap_or(u16::MAX),
5148 },
5149 )
5150 }
5151
5152 #[cfg(not(msim))]
5156 pub fn apply_overrides_for_testing(
5157 override_fn: impl Fn(ProtocolVersion, Self) -> Self + Send + Sync + 'static,
5158 ) -> OverrideGuard {
5159 let mut cur = CONFIG_OVERRIDE.lock().unwrap();
5160 assert!(cur.is_none(), "config override already present");
5161 *cur = Some(Box::new(override_fn));
5162 OverrideGuard
5163 }
5164
5165 #[cfg(msim)]
5169 pub fn apply_overrides_for_testing(
5170 override_fn: impl Fn(ProtocolVersion, Self) -> Self + Send + 'static,
5171 ) -> OverrideGuard {
5172 CONFIG_OVERRIDE.with(|ovr| {
5173 let mut cur = ovr.borrow_mut();
5174 assert!(cur.is_none(), "config override already present");
5175 *cur = Some(Box::new(override_fn));
5176 OverrideGuard
5177 })
5178 }
5179
5180 #[cfg(not(msim))]
5181 fn apply_config_override(version: ProtocolVersion, mut ret: Self) -> Self {
5182 if let Some(override_fn) = CONFIG_OVERRIDE.lock().unwrap().as_ref() {
5183 warn!(
5184 "overriding ProtocolConfig settings with custom settings (you should not see this log outside of tests)"
5185 );
5186 ret = override_fn(version, ret);
5187 }
5188 ret
5189 }
5190
5191 #[cfg(msim)]
5192 fn apply_config_override(version: ProtocolVersion, ret: Self) -> Self {
5193 CONFIG_OVERRIDE.with(|ovr| {
5194 if let Some(override_fn) = &*ovr.borrow() {
5195 warn!(
5196 "overriding ProtocolConfig settings with custom settings (you should not see this log outside of tests)"
5197 );
5198 override_fn(version, ret)
5199 } else {
5200 ret
5201 }
5202 })
5203 }
5204}
5205
5206impl ProtocolConfig {
5210 pub fn set_advance_to_highest_supported_protocol_version_for_testing(&mut self, val: bool) {
5211 self.feature_flags
5212 .advance_to_highest_supported_protocol_version = val
5213 }
5214 pub fn set_commit_root_state_digest_supported_for_testing(&mut self, val: bool) {
5215 self.feature_flags.commit_root_state_digest = val
5216 }
5217 pub fn set_zklogin_auth_for_testing(&mut self, val: bool) {
5218 self.feature_flags.zklogin_auth = val
5219 }
5220 pub fn set_enable_jwk_consensus_updates_for_testing(&mut self, val: bool) {
5221 self.feature_flags.enable_jwk_consensus_updates = val
5222 }
5223 pub fn set_random_beacon_for_testing(&mut self, val: bool) {
5224 self.feature_flags.random_beacon = val
5225 }
5226
5227 pub fn set_upgraded_multisig_for_testing(&mut self, val: bool) {
5228 self.feature_flags.upgraded_multisig_supported = val
5229 }
5230 pub fn set_accept_zklogin_in_multisig_for_testing(&mut self, val: bool) {
5231 self.feature_flags.accept_zklogin_in_multisig = val
5232 }
5233
5234 pub fn set_shared_object_deletion_for_testing(&mut self, val: bool) {
5235 self.feature_flags.shared_object_deletion = val;
5236 }
5237
5238 pub fn set_narwhal_new_leader_election_schedule_for_testing(&mut self, val: bool) {
5239 self.feature_flags.narwhal_new_leader_election_schedule = val;
5240 }
5241
5242 pub fn set_receive_object_for_testing(&mut self, val: bool) {
5243 self.feature_flags.receive_objects = val
5244 }
5245 pub fn set_narwhal_certificate_v2_for_testing(&mut self, val: bool) {
5246 self.feature_flags.narwhal_certificate_v2 = val
5247 }
5248 pub fn set_verify_legacy_zklogin_address_for_testing(&mut self, val: bool) {
5249 self.feature_flags.verify_legacy_zklogin_address = val
5250 }
5251
5252 pub fn set_per_object_congestion_control_mode_for_testing(
5253 &mut self,
5254 val: PerObjectCongestionControlMode,
5255 ) {
5256 self.feature_flags.per_object_congestion_control_mode = val;
5257 }
5258
5259 pub fn set_consensus_choice_for_testing(&mut self, val: ConsensusChoice) {
5260 self.feature_flags.consensus_choice = val;
5261 }
5262
5263 pub fn set_consensus_network_for_testing(&mut self, val: ConsensusNetwork) {
5264 self.feature_flags.consensus_network = val;
5265 }
5266
5267 pub fn set_zklogin_max_epoch_upper_bound_delta_for_testing(&mut self, val: Option<u64>) {
5268 self.feature_flags.zklogin_max_epoch_upper_bound_delta = val
5269 }
5270
5271 pub fn set_disable_bridge_for_testing(&mut self) {
5272 self.feature_flags.bridge = false
5273 }
5274
5275 pub fn set_mysticeti_num_leaders_per_round_for_testing(&mut self, val: Option<usize>) {
5276 self.feature_flags.mysticeti_num_leaders_per_round = val;
5277 }
5278
5279 pub fn set_enable_soft_bundle_for_testing(&mut self, val: bool) {
5280 self.feature_flags.soft_bundle = val;
5281 }
5282
5283 pub fn set_passkey_auth_for_testing(&mut self, val: bool) {
5284 self.feature_flags.passkey_auth = val
5285 }
5286
5287 pub fn set_enable_party_transfer_for_testing(&mut self, val: bool) {
5288 self.feature_flags.enable_party_transfer = val
5289 }
5290
5291 pub fn set_consensus_distributed_vote_scoring_strategy_for_testing(&mut self, val: bool) {
5292 self.feature_flags
5293 .consensus_distributed_vote_scoring_strategy = val;
5294 }
5295
5296 pub fn set_consensus_round_prober_for_testing(&mut self, val: bool) {
5297 self.feature_flags.consensus_round_prober = val;
5298 }
5299
5300 pub fn set_disallow_new_modules_in_deps_only_packages_for_testing(&mut self, val: bool) {
5301 self.feature_flags
5302 .disallow_new_modules_in_deps_only_packages = val;
5303 }
5304
5305 pub fn set_correct_gas_payment_limit_check_for_testing(&mut self, val: bool) {
5306 self.feature_flags.correct_gas_payment_limit_check = val;
5307 }
5308
5309 pub fn set_address_aliases_for_testing(&mut self, val: bool) {
5310 self.feature_flags.address_aliases = val;
5311 }
5312
5313 pub fn set_consensus_round_prober_probe_accepted_rounds(&mut self, val: bool) {
5314 self.feature_flags
5315 .consensus_round_prober_probe_accepted_rounds = val;
5316 }
5317
5318 pub fn set_mysticeti_fastpath_for_testing(&mut self, val: bool) {
5319 self.feature_flags.mysticeti_fastpath = val;
5320 }
5321
5322 pub fn set_accept_passkey_in_multisig_for_testing(&mut self, val: bool) {
5323 self.feature_flags.accept_passkey_in_multisig = val;
5324 }
5325
5326 pub fn set_consensus_batched_block_sync_for_testing(&mut self, val: bool) {
5327 self.feature_flags.consensus_batched_block_sync = val;
5328 }
5329
5330 pub fn set_record_time_estimate_processed_for_testing(&mut self, val: bool) {
5331 self.feature_flags.record_time_estimate_processed = val;
5332 }
5333
5334 pub fn set_prepend_prologue_tx_in_consensus_commit_in_checkpoints_for_testing(
5335 &mut self,
5336 val: bool,
5337 ) {
5338 self.feature_flags
5339 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = val;
5340 }
5341
5342 pub fn enable_accumulators_for_testing(&mut self) {
5343 self.feature_flags.enable_accumulators = true;
5344 }
5345
5346 pub fn disable_accumulators_for_testing(&mut self) {
5347 self.feature_flags.enable_accumulators = false;
5348 self.feature_flags.enable_address_balance_gas_payments = false;
5349 }
5350
5351 pub fn enable_coin_reservation_for_testing(&mut self) {
5352 self.feature_flags.enable_coin_reservation_obj_refs = true;
5353 self.feature_flags
5354 .convert_withdrawal_compatibility_ptb_arguments = true;
5355 self.execution_version = Some(self.execution_version.map_or(4, |v| v.max(4)));
5358 }
5359
5360 pub fn disable_coin_reservation_for_testing(&mut self) {
5361 self.feature_flags.enable_coin_reservation_obj_refs = false;
5362 self.feature_flags
5363 .convert_withdrawal_compatibility_ptb_arguments = false;
5364 }
5365
5366 pub fn create_root_accumulator_object_for_testing(&mut self) {
5367 self.feature_flags.create_root_accumulator_object = true;
5368 }
5369
5370 pub fn disable_create_root_accumulator_object_for_testing(&mut self) {
5371 self.feature_flags.create_root_accumulator_object = false;
5372 }
5373
5374 pub fn enable_address_balance_gas_payments_for_testing(&mut self) {
5375 self.feature_flags.enable_accumulators = true;
5376 self.feature_flags.allow_private_accumulator_entrypoints = true;
5377 self.feature_flags.enable_address_balance_gas_payments = true;
5378 self.feature_flags.address_balance_gas_check_rgp_at_signing = true;
5379 self.feature_flags.address_balance_gas_reject_gas_coin_arg = false;
5380 self.execution_version = Some(self.execution_version.map_or(4, |v| v.max(4)))
5381 }
5382
5383 pub fn disable_address_balance_gas_payments_for_testing(&mut self) {
5384 self.feature_flags.enable_address_balance_gas_payments = false;
5385 }
5386
5387 pub fn enable_gasless_for_testing(&mut self) {
5388 self.enable_address_balance_gas_payments_for_testing();
5389 self.feature_flags.enable_gasless = true;
5390 self.feature_flags.gasless_verify_remaining_balance = true;
5391 self.gasless_max_computation_units = Some(5_000);
5392 self.gasless_allowed_token_types = Some(vec![]);
5393 self.gasless_max_tps = Some(1000);
5394 self.gasless_max_tx_size_bytes = Some(16 * 1024);
5395 }
5396
5397 pub fn disable_gasless_for_testing(&mut self) {
5398 self.feature_flags.enable_gasless = false;
5399 self.gasless_max_computation_units = None;
5400 self.gasless_allowed_token_types = None;
5401 }
5402
5403 pub fn enable_multi_epoch_transaction_expiration_for_testing(&mut self) {
5404 self.feature_flags.enable_multi_epoch_transaction_expiration = true;
5405 }
5406
5407 pub fn enable_authenticated_event_streams_for_testing(&mut self) {
5408 self.enable_accumulators_for_testing();
5409 self.feature_flags.enable_authenticated_event_streams = true;
5410 self.feature_flags
5411 .include_checkpoint_artifacts_digest_in_summary = true;
5412 self.feature_flags.split_checkpoints_in_consensus_handler = true;
5413 }
5414
5415 pub fn disable_authenticated_event_streams_for_testing(&mut self) {
5416 self.feature_flags.enable_authenticated_event_streams = false;
5417 }
5418
5419 pub fn disable_randomize_checkpoint_tx_limit_for_testing(&mut self) {
5420 self.feature_flags.randomize_checkpoint_tx_limit_in_tests = false;
5421 }
5422
5423 pub fn enable_non_exclusive_writes_for_testing(&mut self) {
5424 self.feature_flags.enable_non_exclusive_writes = true;
5425 }
5426
5427 pub fn set_relax_valid_during_for_owned_inputs_for_testing(&mut self, val: bool) {
5428 self.feature_flags.relax_valid_during_for_owned_inputs = val;
5429 }
5430
5431 pub fn set_ignore_execution_time_observations_after_certs_closed_for_testing(
5432 &mut self,
5433 val: bool,
5434 ) {
5435 self.feature_flags
5436 .ignore_execution_time_observations_after_certs_closed = val;
5437 }
5438
5439 pub fn set_consensus_checkpoint_signature_key_includes_digest_for_testing(
5440 &mut self,
5441 val: bool,
5442 ) {
5443 self.feature_flags
5444 .consensus_checkpoint_signature_key_includes_digest = val;
5445 }
5446
5447 pub fn set_cancel_for_failed_dkg_early_for_testing(&mut self, val: bool) {
5448 self.feature_flags.cancel_for_failed_dkg_early = val;
5449 }
5450
5451 pub fn set_use_mfp_txns_in_load_initial_object_debts_for_testing(&mut self, val: bool) {
5452 self.feature_flags.use_mfp_txns_in_load_initial_object_debts = val;
5453 }
5454
5455 pub fn set_authority_capabilities_v2_for_testing(&mut self, val: bool) {
5456 self.feature_flags.authority_capabilities_v2 = val;
5457 }
5458
5459 pub fn allow_references_in_ptbs_for_testing(&mut self) {
5460 self.feature_flags.allow_references_in_ptbs = true;
5461 }
5462
5463 pub fn set_consensus_skip_gced_accept_votes_for_testing(&mut self, val: bool) {
5464 self.feature_flags.consensus_skip_gced_accept_votes = val;
5465 }
5466
5467 pub fn set_enable_object_funds_withdraw_for_testing(&mut self, val: bool) {
5468 self.feature_flags.enable_object_funds_withdraw = val;
5469 }
5470
5471 pub fn set_split_checkpoints_in_consensus_handler_for_testing(&mut self, val: bool) {
5472 self.feature_flags.split_checkpoints_in_consensus_handler = val;
5473 }
5474
5475 pub fn set_merge_randomness_into_checkpoint_for_testing(&mut self, val: bool) {
5476 self.feature_flags.merge_randomness_into_checkpoint = val;
5477 }
5478}
5479
5480#[cfg(not(msim))]
5481type OverrideFn = dyn Fn(ProtocolVersion, ProtocolConfig) -> ProtocolConfig + Send + Sync;
5482
5483#[cfg(not(msim))]
5484static CONFIG_OVERRIDE: Mutex<Option<Box<OverrideFn>>> = Mutex::new(None);
5485
5486#[cfg(msim)]
5487type OverrideFn = dyn Fn(ProtocolVersion, ProtocolConfig) -> ProtocolConfig + Send;
5488
5489#[cfg(msim)]
5490thread_local! {
5491 static CONFIG_OVERRIDE: RefCell<Option<Box<OverrideFn>>> = RefCell::new(None);
5492}
5493
5494#[must_use]
5495pub struct OverrideGuard;
5496
5497#[cfg(not(msim))]
5498impl Drop for OverrideGuard {
5499 fn drop(&mut self) {
5500 info!("restoring override fn");
5501 *CONFIG_OVERRIDE.lock().unwrap() = None;
5502 }
5503}
5504
5505#[cfg(msim)]
5506impl Drop for OverrideGuard {
5507 fn drop(&mut self) {
5508 info!("restoring override fn");
5509 CONFIG_OVERRIDE.with(|ovr| {
5510 *ovr.borrow_mut() = None;
5511 });
5512 }
5513}
5514
5515#[derive(PartialEq, Eq)]
5518pub enum LimitThresholdCrossed {
5519 None,
5520 Soft(u128, u128),
5521 Hard(u128, u128),
5522}
5523
5524pub fn check_limit_in_range<T: Into<V>, U: Into<V>, V: PartialOrd + Into<u128>>(
5527 x: T,
5528 soft_limit: U,
5529 hard_limit: V,
5530) -> LimitThresholdCrossed {
5531 let x: V = x.into();
5532 let soft_limit: V = soft_limit.into();
5533
5534 debug_assert!(soft_limit <= hard_limit);
5535
5536 if x >= hard_limit {
5539 LimitThresholdCrossed::Hard(x.into(), hard_limit.into())
5540 } else if x < soft_limit {
5541 LimitThresholdCrossed::None
5542 } else {
5543 LimitThresholdCrossed::Soft(x.into(), soft_limit.into())
5544 }
5545}
5546
5547#[macro_export]
5548macro_rules! check_limit {
5549 ($x:expr, $hard:expr) => {
5550 check_limit!($x, $hard, $hard)
5551 };
5552 ($x:expr, $soft:expr, $hard:expr) => {
5553 check_limit_in_range($x as u64, $soft, $hard)
5554 };
5555}
5556
5557#[macro_export]
5561macro_rules! check_limit_by_meter {
5562 ($is_metered:expr, $x:expr, $metered_limit:expr, $unmetered_hard_limit:expr, $metric:expr) => {{
5563 let (h, metered_str) = if $is_metered {
5565 ($metered_limit, "metered")
5566 } else {
5567 ($unmetered_hard_limit, "unmetered")
5569 };
5570 use sui_protocol_config::check_limit_in_range;
5571 let result = check_limit_in_range($x as u64, $metered_limit, h);
5572 match result {
5573 LimitThresholdCrossed::None => {}
5574 LimitThresholdCrossed::Soft(_, _) => {
5575 $metric.with_label_values(&[metered_str, "soft"]).inc();
5576 }
5577 LimitThresholdCrossed::Hard(_, _) => {
5578 $metric.with_label_values(&[metered_str, "hard"]).inc();
5579 }
5580 };
5581 result
5582 }};
5583}
5584
5585pub type Amendments = BTreeMap<AccountAddress, BTreeMap<AccountAddress, AccountAddress>>;
5588
5589static MAINNET_LINKAGE_AMENDMENTS: LazyLock<Arc<Amendments>> =
5590 LazyLock::new(|| parse_amendments(include_str!("mainnet_amendments.json")));
5591
5592static TESTNET_LINKAGE_AMENDMENTS: LazyLock<Arc<Amendments>> =
5593 LazyLock::new(|| parse_amendments(include_str!("testnet_amendments.json")));
5594
5595fn parse_amendments(json: &str) -> Arc<Amendments> {
5596 #[derive(serde::Deserialize)]
5597 struct AmendmentEntry {
5598 root: String,
5599 deps: Vec<DepEntry>,
5600 }
5601
5602 #[derive(serde::Deserialize)]
5603 struct DepEntry {
5604 original_id: String,
5605 version_id: String,
5606 }
5607
5608 let entries: Vec<AmendmentEntry> =
5609 serde_json::from_str(json).expect("Failed to parse amendments JSON");
5610 let mut amendments = BTreeMap::new();
5611 for entry in entries {
5612 let root_id = AccountAddress::from_hex_literal(&entry.root).unwrap();
5613 let mut dep_ids = BTreeMap::new();
5614 for dep in entry.deps {
5615 let orig_id = AccountAddress::from_hex_literal(&dep.original_id).unwrap();
5616 let upgraded_id = AccountAddress::from_hex_literal(&dep.version_id).unwrap();
5617 assert!(
5618 dep_ids.insert(orig_id, upgraded_id).is_none(),
5619 "Duplicate original ID in amendments table"
5620 );
5621 }
5622 assert!(
5623 amendments.insert(root_id, dep_ids).is_none(),
5624 "Duplicate root ID in amendments table"
5625 );
5626 }
5627 Arc::new(amendments)
5628}
5629
5630#[cfg(all(test, not(msim)))]
5631mod test {
5632 use insta::assert_yaml_snapshot;
5633
5634 use super::*;
5635
5636 #[test]
5637 fn snapshot_tests() {
5638 println!("\n============================================================================");
5639 println!("! !");
5640 println!("! IMPORTANT: never update snapshots from this test. only add new versions! !");
5641 println!("! !");
5642 println!("============================================================================\n");
5643 for chain_id in &[Chain::Unknown, Chain::Mainnet, Chain::Testnet] {
5644 let chain_str = match chain_id {
5648 Chain::Unknown => "".to_string(),
5649 _ => format!("{:?}_", chain_id),
5650 };
5651 for i in MIN_PROTOCOL_VERSION..=MAX_PROTOCOL_VERSION {
5652 let cur = ProtocolVersion::new(i);
5653 assert_yaml_snapshot!(
5654 format!("{}version_{}", chain_str, cur.as_u64()),
5655 ProtocolConfig::get_for_version(cur, *chain_id)
5656 );
5657 }
5658 }
5659 }
5660
5661 #[test]
5662 fn test_getters() {
5663 let prot: ProtocolConfig =
5664 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5665 assert_eq!(
5666 prot.max_arguments(),
5667 prot.max_arguments_as_option().unwrap()
5668 );
5669 }
5670
5671 #[test]
5672 fn test_setters() {
5673 let mut prot: ProtocolConfig =
5674 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5675 prot.set_max_arguments_for_testing(123);
5676 assert_eq!(prot.max_arguments(), 123);
5677
5678 prot.set_max_arguments_from_str_for_testing("321".to_string());
5679 assert_eq!(prot.max_arguments(), 321);
5680
5681 prot.disable_max_arguments_for_testing();
5682 assert_eq!(prot.max_arguments_as_option(), None);
5683
5684 prot.set_attr_for_testing("max_arguments".to_string(), "456".to_string());
5685 assert_eq!(prot.max_arguments(), 456);
5686 }
5687
5688 #[test]
5689 fn test_get_for_version_if_supported_applies_test_overrides() {
5690 let before =
5691 ProtocolConfig::get_for_version_if_supported(ProtocolVersion::new(1), Chain::Unknown)
5692 .unwrap();
5693
5694 assert!(!before.enable_coin_reservation_obj_refs());
5695
5696 let _guard = ProtocolConfig::apply_overrides_for_testing(|_, mut cfg| {
5697 cfg.enable_coin_reservation_for_testing();
5698 cfg
5699 });
5700
5701 let after =
5702 ProtocolConfig::get_for_version_if_supported(ProtocolVersion::new(1), Chain::Unknown)
5703 .unwrap();
5704
5705 assert!(after.enable_coin_reservation_obj_refs());
5706 }
5707
5708 #[test]
5709 #[should_panic(expected = "unsupported version")]
5710 fn max_version_test() {
5711 let _ = ProtocolConfig::get_for_version_impl(
5714 ProtocolVersion::new(MAX_PROTOCOL_VERSION + 1),
5715 Chain::Unknown,
5716 );
5717 }
5718
5719 #[test]
5720 fn lookup_by_string_test() {
5721 let prot: ProtocolConfig =
5722 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5723 assert!(prot.lookup_attr("some random string".to_string()).is_none());
5725
5726 assert!(
5727 prot.lookup_attr("max_arguments".to_string())
5728 == Some(ProtocolConfigValue::u32(prot.max_arguments())),
5729 );
5730
5731 assert!(
5733 prot.lookup_attr("max_move_identifier_len".to_string())
5734 .is_none()
5735 );
5736
5737 let prot: ProtocolConfig =
5739 ProtocolConfig::get_for_version(ProtocolVersion::new(9), Chain::Unknown);
5740 assert!(
5741 prot.lookup_attr("max_move_identifier_len".to_string())
5742 == Some(ProtocolConfigValue::u64(prot.max_move_identifier_len()))
5743 );
5744
5745 let prot: ProtocolConfig =
5746 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5747 assert!(
5749 prot.attr_map()
5750 .get("max_move_identifier_len")
5751 .unwrap()
5752 .is_none()
5753 );
5754 assert!(
5756 prot.attr_map().get("max_arguments").unwrap()
5757 == &Some(ProtocolConfigValue::u32(prot.max_arguments()))
5758 );
5759
5760 let prot: ProtocolConfig =
5762 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5763 assert!(
5765 prot.feature_flags
5766 .lookup_attr("some random string".to_owned())
5767 .is_none()
5768 );
5769 assert!(
5770 !prot
5771 .feature_flags
5772 .attr_map()
5773 .contains_key("some random string")
5774 );
5775
5776 assert!(
5778 prot.feature_flags
5779 .lookup_attr("package_upgrades".to_owned())
5780 == Some(false)
5781 );
5782 assert!(
5783 prot.feature_flags
5784 .attr_map()
5785 .get("package_upgrades")
5786 .unwrap()
5787 == &false
5788 );
5789 let prot: ProtocolConfig =
5790 ProtocolConfig::get_for_version(ProtocolVersion::new(4), Chain::Unknown);
5791 assert!(
5793 prot.feature_flags
5794 .lookup_attr("package_upgrades".to_owned())
5795 == Some(true)
5796 );
5797 assert!(
5798 prot.feature_flags
5799 .attr_map()
5800 .get("package_upgrades")
5801 .unwrap()
5802 == &true
5803 );
5804 }
5805
5806 #[test]
5807 fn limit_range_fn_test() {
5808 let low = 100u32;
5809 let high = 10000u64;
5810
5811 assert!(check_limit!(1u8, low, high) == LimitThresholdCrossed::None);
5812 assert!(matches!(
5813 check_limit!(255u16, low, high),
5814 LimitThresholdCrossed::Soft(255u128, 100)
5815 ));
5816 assert!(matches!(
5822 check_limit!(2550000u64, low, high),
5823 LimitThresholdCrossed::Hard(2550000, 10000)
5824 ));
5825
5826 assert!(matches!(
5827 check_limit!(2550000u64, high, high),
5828 LimitThresholdCrossed::Hard(2550000, 10000)
5829 ));
5830
5831 assert!(matches!(
5832 check_limit!(1u8, high),
5833 LimitThresholdCrossed::None
5834 ));
5835
5836 assert!(check_limit!(255u16, high) == LimitThresholdCrossed::None);
5837
5838 assert!(matches!(
5839 check_limit!(2550000u64, high),
5840 LimitThresholdCrossed::Hard(2550000, 10000)
5841 ));
5842 }
5843
5844 #[test]
5845 fn linkage_amendments_load() {
5846 let mainnet = LazyLock::force(&MAINNET_LINKAGE_AMENDMENTS);
5847 let testnet = LazyLock::force(&TESTNET_LINKAGE_AMENDMENTS);
5848 assert!(!mainnet.is_empty(), "mainnet amendments must not be empty");
5849 assert!(!testnet.is_empty(), "testnet amendments must not be empty");
5850 }
5851
5852 #[test]
5853 fn render_scalar_fields_use_precision_safe_encoding() {
5854 use mysten_common::rpc_format::Unmetered;
5855
5856 let config = ProtocolConfig::get_for_max_version_UNSAFE();
5857 let rendered = config
5858 .render::<serde_json::Value>(&mut Unmetered)
5859 .expect("render should succeed");
5860
5861 let max_args = rendered
5862 .get("max_arguments")
5863 .expect("max_arguments set at max version");
5864 assert!(
5865 max_args.is_number(),
5866 "u32 should render as number, got {max_args:?}",
5867 );
5868
5869 let max_tx_size = rendered
5870 .get("max_tx_size_bytes")
5871 .expect("max_tx_size_bytes set at max version");
5872 assert!(
5873 max_tx_size.is_string(),
5874 "u64 should render as string, got {max_tx_size:?}",
5875 );
5876 }
5877
5878 #[test]
5879 fn render_includes_non_scalar_gasless_allowlist_as_json() {
5880 use mysten_common::rpc_format::Unmetered;
5881 use serde_json::json;
5882
5883 let mut config = ProtocolConfig::get_for_max_version_UNSAFE();
5884 config.set_gasless_allowed_token_types_for_testing(vec![
5885 ("0xa::usdc::USDC".to_string(), 10_000),
5886 ("0xb::usdt::USDT".to_string(), 0),
5887 ]);
5888
5889 let rendered = config
5890 .render::<serde_json::Value>(&mut Unmetered)
5891 .expect("render should succeed under Unmetered budget");
5892 let allowlist = rendered
5893 .get("gasless_allowed_token_types")
5894 .expect("entry should be present after the testing setter");
5895
5896 assert_eq!(
5899 allowlist,
5900 &json!([["0xa::usdc::USDC", "10000"], ["0xb::usdt::USDT", "0"],]),
5901 );
5902 }
5903
5904 #[test]
5905 fn render_targets_prost_value_for_grpc() {
5906 use mysten_common::rpc_format::Unmetered;
5907 use prost_types::value::Kind;
5908
5909 let mut config = ProtocolConfig::get_for_max_version_UNSAFE();
5910 config.set_gasless_allowed_token_types_for_testing(vec![(
5911 "0xa::usdc::USDC".to_string(),
5912 10_000,
5913 )]);
5914
5915 let rendered = config
5916 .render::<prost_types::Value>(&mut Unmetered)
5917 .expect("render to prost Value should succeed");
5918 let allowlist = rendered
5919 .get("gasless_allowed_token_types")
5920 .expect("entry should be present after the testing setter");
5921
5922 let Some(Kind::ListValue(outer)) = &allowlist.kind else {
5924 panic!(
5925 "expected ListValue at the top level, got {:?}",
5926 allowlist.kind
5927 );
5928 };
5929 assert_eq!(outer.values.len(), 1, "one allowlisted entry");
5930 let Some(Kind::ListValue(entry)) = &outer.values[0].kind else {
5931 panic!("expected each entry to be a ListValue");
5932 };
5933 assert_eq!(entry.values.len(), 2, "entry has (coin_type, amount)");
5934
5935 let Some(Kind::StringValue(coin_type)) = &entry.values[0].kind else {
5936 panic!("expected coin_type as StringValue");
5937 };
5938 assert_eq!(coin_type, "0xa::usdc::USDC");
5939
5940 let Some(Kind::StringValue(amount)) = &entry.values[1].kind else {
5942 panic!(
5943 "expected minimum_transfer_amount as StringValue (precision-safe u64); got {:?}",
5944 entry.values[1].kind,
5945 );
5946 };
5947 assert_eq!(amount, "10000");
5948 }
5949
5950 #[test]
5951 fn render_emits_null_for_unset_protocol_versions() {
5952 use mysten_common::rpc_format::Unmetered;
5953
5954 let config = ProtocolConfig::get_for_version(1.into(), Chain::Unknown);
5955 let rendered = config
5956 .render::<serde_json::Value>(&mut Unmetered)
5957 .expect("render should succeed");
5958 let entry = rendered
5962 .get("gasless_allowed_token_types")
5963 .expect("key should be present for every protocol version");
5964 assert!(
5965 entry.is_null(),
5966 "value should be null for pre-feature protocol version, got {entry:?}",
5967 );
5968 }
5969}