1use std::{
5 cell::RefCell,
6 collections::BTreeSet,
7 sync::atomic::{AtomicBool, Ordering},
8};
9
10use clap::*;
11use fastcrypto::encoding::{Base58, Encoding, Hex};
12use move_binary_format::{
13 binary_config::{BinaryConfig, TableConfig},
14 file_format_common::VERSION_1,
15};
16use move_vm_config::verifier::VerifierConfig;
17use mysten_common::in_integration_test;
18use serde::{Deserialize, Serialize};
19use serde_with::skip_serializing_none;
20use sui_protocol_config_macros::{
21 ProtocolConfigAccessors, ProtocolConfigFeatureFlagsGetters, ProtocolConfigOverride,
22};
23use tracing::{info, warn};
24
25const MIN_PROTOCOL_VERSION: u64 = 1;
27const MAX_PROTOCOL_VERSION: u64 = 116;
28
29#[derive(Copy, Clone, Debug, Hash, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)]
309pub struct ProtocolVersion(u64);
310
311impl ProtocolVersion {
312 pub const MIN: Self = Self(MIN_PROTOCOL_VERSION);
317
318 pub const MAX: Self = Self(MAX_PROTOCOL_VERSION);
319
320 #[cfg(not(msim))]
321 pub const MAX_ALLOWED: Self = Self::MAX;
322
323 #[cfg(msim)]
325 pub const MAX_ALLOWED: Self = Self(MAX_PROTOCOL_VERSION + 1);
326
327 pub fn new(v: u64) -> Self {
328 Self(v)
329 }
330
331 pub const fn as_u64(&self) -> u64 {
332 self.0
333 }
334
335 pub fn max() -> Self {
338 Self::MAX
339 }
340
341 pub fn prev(self) -> Self {
342 Self(self.0.checked_sub(1).unwrap())
343 }
344}
345
346impl From<u64> for ProtocolVersion {
347 fn from(v: u64) -> Self {
348 Self::new(v)
349 }
350}
351
352impl std::ops::Sub<u64> for ProtocolVersion {
353 type Output = Self;
354 fn sub(self, rhs: u64) -> Self::Output {
355 Self::new(self.0 - rhs)
356 }
357}
358
359impl std::ops::Add<u64> for ProtocolVersion {
360 type Output = Self;
361 fn add(self, rhs: u64) -> Self::Output {
362 Self::new(self.0 + rhs)
363 }
364}
365
366#[derive(
367 Clone, Serialize, Deserialize, Debug, Default, PartialEq, Copy, PartialOrd, Ord, Eq, ValueEnum,
368)]
369pub enum Chain {
370 Mainnet,
371 Testnet,
372 #[default]
373 Unknown,
374}
375
376impl Chain {
377 pub fn as_str(self) -> &'static str {
378 match self {
379 Chain::Mainnet => "mainnet",
380 Chain::Testnet => "testnet",
381 Chain::Unknown => "unknown",
382 }
383 }
384}
385
386pub struct Error(pub String);
387
388#[derive(Default, Clone, Serialize, Deserialize, Debug, ProtocolConfigFeatureFlagsGetters)]
391struct FeatureFlags {
392 #[serde(skip_serializing_if = "is_false")]
395 package_upgrades: bool,
396 #[serde(skip_serializing_if = "is_false")]
399 commit_root_state_digest: bool,
400 #[serde(skip_serializing_if = "is_false")]
402 advance_epoch_start_time_in_safe_mode: bool,
403 #[serde(skip_serializing_if = "is_false")]
406 loaded_child_objects_fixed: bool,
407 #[serde(skip_serializing_if = "is_false")]
410 missing_type_is_compatibility_error: bool,
411 #[serde(skip_serializing_if = "is_false")]
414 scoring_decision_with_validity_cutoff: bool,
415
416 #[serde(skip_serializing_if = "is_false")]
419 consensus_order_end_of_epoch_last: bool,
420
421 #[serde(skip_serializing_if = "is_false")]
423 disallow_adding_abilities_on_upgrade: bool,
424 #[serde(skip_serializing_if = "is_false")]
426 disable_invariant_violation_check_in_swap_loc: bool,
427 #[serde(skip_serializing_if = "is_false")]
430 advance_to_highest_supported_protocol_version: bool,
431 #[serde(skip_serializing_if = "is_false")]
433 ban_entry_init: bool,
434 #[serde(skip_serializing_if = "is_false")]
436 package_digest_hash_module: bool,
437 #[serde(skip_serializing_if = "is_false")]
439 disallow_change_struct_type_params_on_upgrade: bool,
440 #[serde(skip_serializing_if = "is_false")]
442 no_extraneous_module_bytes: bool,
443 #[serde(skip_serializing_if = "is_false")]
445 narwhal_versioned_metadata: bool,
446
447 #[serde(skip_serializing_if = "is_false")]
449 zklogin_auth: bool,
450 #[serde(skip_serializing_if = "ConsensusTransactionOrdering::is_none")]
452 consensus_transaction_ordering: ConsensusTransactionOrdering,
453
454 #[serde(skip_serializing_if = "is_false")]
462 simplified_unwrap_then_delete: bool,
463 #[serde(skip_serializing_if = "is_false")]
465 upgraded_multisig_supported: bool,
466 #[serde(skip_serializing_if = "is_false")]
468 txn_base_cost_as_multiplier: bool,
469
470 #[serde(skip_serializing_if = "is_false")]
472 shared_object_deletion: bool,
473
474 #[serde(skip_serializing_if = "is_false")]
476 narwhal_new_leader_election_schedule: bool,
477
478 #[serde(skip_serializing_if = "is_empty")]
480 zklogin_supported_providers: BTreeSet<String>,
481
482 #[serde(skip_serializing_if = "is_false")]
484 loaded_child_object_format: bool,
485
486 #[serde(skip_serializing_if = "is_false")]
487 enable_jwk_consensus_updates: bool,
488
489 #[serde(skip_serializing_if = "is_false")]
490 end_of_epoch_transaction_supported: bool,
491
492 #[serde(skip_serializing_if = "is_false")]
495 simple_conservation_checks: bool,
496
497 #[serde(skip_serializing_if = "is_false")]
499 loaded_child_object_format_type: bool,
500
501 #[serde(skip_serializing_if = "is_false")]
503 receive_objects: bool,
504
505 #[serde(skip_serializing_if = "is_false")]
507 consensus_checkpoint_signature_key_includes_digest: bool,
508
509 #[serde(skip_serializing_if = "is_false")]
511 random_beacon: bool,
512
513 #[serde(skip_serializing_if = "is_false")]
515 bridge: bool,
516
517 #[serde(skip_serializing_if = "is_false")]
518 enable_effects_v2: bool,
519
520 #[serde(skip_serializing_if = "is_false")]
522 narwhal_certificate_v2: bool,
523
524 #[serde(skip_serializing_if = "is_false")]
526 verify_legacy_zklogin_address: bool,
527
528 #[serde(skip_serializing_if = "is_false")]
530 throughput_aware_consensus_submission: bool,
531
532 #[serde(skip_serializing_if = "is_false")]
534 recompute_has_public_transfer_in_execution: bool,
535
536 #[serde(skip_serializing_if = "is_false")]
538 accept_zklogin_in_multisig: bool,
539
540 #[serde(skip_serializing_if = "is_false")]
542 accept_passkey_in_multisig: bool,
543
544 #[serde(skip_serializing_if = "is_false")]
546 validate_zklogin_public_identifier: bool,
547
548 #[serde(skip_serializing_if = "is_false")]
551 include_consensus_digest_in_prologue: bool,
552
553 #[serde(skip_serializing_if = "is_false")]
555 hardened_otw_check: bool,
556
557 #[serde(skip_serializing_if = "is_false")]
559 allow_receiving_object_id: bool,
560
561 #[serde(skip_serializing_if = "is_false")]
563 enable_poseidon: bool,
564
565 #[serde(skip_serializing_if = "is_false")]
567 enable_coin_deny_list: bool,
568
569 #[serde(skip_serializing_if = "is_false")]
571 enable_group_ops_native_functions: bool,
572
573 #[serde(skip_serializing_if = "is_false")]
575 enable_group_ops_native_function_msm: bool,
576
577 #[serde(skip_serializing_if = "is_false")]
579 enable_ristretto255_group_ops: bool,
580
581 #[serde(skip_serializing_if = "is_false")]
583 enable_nitro_attestation: bool,
584
585 #[serde(skip_serializing_if = "is_false")]
587 enable_nitro_attestation_upgraded_parsing: bool,
588
589 #[serde(skip_serializing_if = "is_false")]
591 enable_nitro_attestation_all_nonzero_pcrs_parsing: bool,
592
593 #[serde(skip_serializing_if = "is_false")]
595 enable_nitro_attestation_always_include_required_pcrs_parsing: bool,
596
597 #[serde(skip_serializing_if = "is_false")]
599 reject_mutable_random_on_entry_functions: bool,
600
601 #[serde(skip_serializing_if = "PerObjectCongestionControlMode::is_none")]
603 per_object_congestion_control_mode: PerObjectCongestionControlMode,
604
605 #[serde(skip_serializing_if = "ConsensusChoice::is_narwhal")]
607 consensus_choice: ConsensusChoice,
608
609 #[serde(skip_serializing_if = "ConsensusNetwork::is_anemo")]
611 consensus_network: ConsensusNetwork,
612
613 #[serde(skip_serializing_if = "is_false")]
615 correct_gas_payment_limit_check: bool,
616
617 #[serde(skip_serializing_if = "Option::is_none")]
619 zklogin_max_epoch_upper_bound_delta: Option<u64>,
620
621 #[serde(skip_serializing_if = "is_false")]
623 mysticeti_leader_scoring_and_schedule: bool,
624
625 #[serde(skip_serializing_if = "is_false")]
627 reshare_at_same_initial_version: bool,
628
629 #[serde(skip_serializing_if = "is_false")]
631 resolve_abort_locations_to_package_id: bool,
632
633 #[serde(skip_serializing_if = "is_false")]
637 mysticeti_use_committed_subdag_digest: bool,
638
639 #[serde(skip_serializing_if = "is_false")]
641 enable_vdf: bool,
642
643 #[serde(skip_serializing_if = "is_false")]
648 record_consensus_determined_version_assignments_in_prologue: bool,
649 #[serde(skip_serializing_if = "is_false")]
650 record_consensus_determined_version_assignments_in_prologue_v2: bool,
651
652 #[serde(skip_serializing_if = "is_false")]
654 fresh_vm_on_framework_upgrade: bool,
655
656 #[serde(skip_serializing_if = "is_false")]
664 prepend_prologue_tx_in_consensus_commit_in_checkpoints: bool,
665
666 #[serde(skip_serializing_if = "Option::is_none")]
668 mysticeti_num_leaders_per_round: Option<usize>,
669
670 #[serde(skip_serializing_if = "is_false")]
672 soft_bundle: bool,
673
674 #[serde(skip_serializing_if = "is_false")]
676 enable_coin_deny_list_v2: bool,
677
678 #[serde(skip_serializing_if = "is_false")]
680 passkey_auth: bool,
681
682 #[serde(skip_serializing_if = "is_false")]
684 authority_capabilities_v2: bool,
685
686 #[serde(skip_serializing_if = "is_false")]
688 rethrow_serialization_type_layout_errors: bool,
689
690 #[serde(skip_serializing_if = "is_false")]
692 consensus_distributed_vote_scoring_strategy: bool,
693
694 #[serde(skip_serializing_if = "is_false")]
696 consensus_round_prober: bool,
697
698 #[serde(skip_serializing_if = "is_false")]
700 validate_identifier_inputs: bool,
701
702 #[serde(skip_serializing_if = "is_false")]
704 disallow_self_identifier: bool,
705
706 #[serde(skip_serializing_if = "is_false")]
708 mysticeti_fastpath: bool,
709
710 #[serde(skip_serializing_if = "is_false")]
714 disable_preconsensus_locking: bool,
715
716 #[serde(skip_serializing_if = "is_false")]
718 relocate_event_module: bool,
719
720 #[serde(skip_serializing_if = "is_false")]
722 uncompressed_g1_group_elements: bool,
723
724 #[serde(skip_serializing_if = "is_false")]
725 disallow_new_modules_in_deps_only_packages: bool,
726
727 #[serde(skip_serializing_if = "is_false")]
729 consensus_smart_ancestor_selection: bool,
730
731 #[serde(skip_serializing_if = "is_false")]
733 consensus_round_prober_probe_accepted_rounds: bool,
734
735 #[serde(skip_serializing_if = "is_false")]
737 native_charging_v2: bool,
738
739 #[serde(skip_serializing_if = "is_false")]
742 consensus_linearize_subdag_v2: bool,
743
744 #[serde(skip_serializing_if = "is_false")]
746 convert_type_argument_error: bool,
747
748 #[serde(skip_serializing_if = "is_false")]
750 variant_nodes: bool,
751
752 #[serde(skip_serializing_if = "is_false")]
754 consensus_zstd_compression: bool,
755
756 #[serde(skip_serializing_if = "is_false")]
758 minimize_child_object_mutations: bool,
759
760 #[serde(skip_serializing_if = "is_false")]
762 record_additional_state_digest_in_prologue: bool,
763
764 #[serde(skip_serializing_if = "is_false")]
766 move_native_context: bool,
767
768 #[serde(skip_serializing_if = "is_false")]
771 consensus_median_based_commit_timestamp: bool,
772
773 #[serde(skip_serializing_if = "is_false")]
776 normalize_ptb_arguments: bool,
777
778 #[serde(skip_serializing_if = "is_false")]
780 consensus_batched_block_sync: bool,
781
782 #[serde(skip_serializing_if = "is_false")]
784 enforce_checkpoint_timestamp_monotonicity: bool,
785
786 #[serde(skip_serializing_if = "is_false")]
788 max_ptb_value_size_v2: bool,
789
790 #[serde(skip_serializing_if = "is_false")]
792 resolve_type_input_ids_to_defining_id: bool,
793
794 #[serde(skip_serializing_if = "is_false")]
796 enable_party_transfer: bool,
797
798 #[serde(skip_serializing_if = "is_false")]
800 allow_unbounded_system_objects: bool,
801
802 #[serde(skip_serializing_if = "is_false")]
804 type_tags_in_object_runtime: bool,
805
806 #[serde(skip_serializing_if = "is_false")]
808 enable_accumulators: bool,
809
810 #[serde(skip_serializing_if = "is_false")]
812 enable_coin_reservation_obj_refs: bool,
813
814 #[serde(skip_serializing_if = "is_false")]
817 create_root_accumulator_object: bool,
818
819 #[serde(skip_serializing_if = "is_false")]
821 enable_authenticated_event_streams: bool,
822
823 #[serde(skip_serializing_if = "is_false")]
825 enable_address_balance_gas_payments: bool,
826
827 #[serde(skip_serializing_if = "is_false")]
829 address_balance_gas_check_rgp_at_signing: bool,
830
831 #[serde(skip_serializing_if = "is_false")]
832 address_balance_gas_reject_gas_coin_arg: bool,
833
834 #[serde(skip_serializing_if = "is_false")]
836 enable_multi_epoch_transaction_expiration: bool,
837
838 #[serde(skip_serializing_if = "is_false")]
840 relax_valid_during_for_owned_inputs: bool,
841
842 #[serde(skip_serializing_if = "is_false")]
844 enable_ptb_execution_v2: bool,
845
846 #[serde(skip_serializing_if = "is_false")]
848 better_adapter_type_resolution_errors: bool,
849
850 #[serde(skip_serializing_if = "is_false")]
852 record_time_estimate_processed: bool,
853
854 #[serde(skip_serializing_if = "is_false")]
856 dependency_linkage_error: bool,
857
858 #[serde(skip_serializing_if = "is_false")]
860 additional_multisig_checks: bool,
861
862 #[serde(skip_serializing_if = "is_false")]
864 ignore_execution_time_observations_after_certs_closed: bool,
865
866 #[serde(skip_serializing_if = "is_false")]
870 debug_fatal_on_move_invariant_violation: bool,
871
872 #[serde(skip_serializing_if = "is_false")]
875 allow_private_accumulator_entrypoints: bool,
876
877 #[serde(skip_serializing_if = "is_false")]
879 additional_consensus_digest_indirect_state: bool,
880
881 #[serde(skip_serializing_if = "is_false")]
883 check_for_init_during_upgrade: bool,
884
885 #[serde(skip_serializing_if = "is_false")]
887 per_command_shared_object_transfer_rules: bool,
888
889 #[serde(skip_serializing_if = "is_false")]
891 include_checkpoint_artifacts_digest_in_summary: bool,
892
893 #[serde(skip_serializing_if = "is_false")]
895 use_mfp_txns_in_load_initial_object_debts: bool,
896
897 #[serde(skip_serializing_if = "is_false")]
899 cancel_for_failed_dkg_early: bool,
900
901 #[serde(skip_serializing_if = "is_false")]
903 enable_coin_registry: bool,
904
905 #[serde(skip_serializing_if = "is_false")]
907 abstract_size_in_object_runtime: bool,
908
909 #[serde(skip_serializing_if = "is_false")]
911 object_runtime_charge_cache_load_gas: bool,
912
913 #[serde(skip_serializing_if = "is_false")]
915 additional_borrow_checks: bool,
916
917 #[serde(skip_serializing_if = "is_false")]
919 use_new_commit_handler: bool,
920
921 #[serde(skip_serializing_if = "is_false")]
923 better_loader_errors: bool,
924
925 #[serde(skip_serializing_if = "is_false")]
927 generate_df_type_layouts: bool,
928
929 #[serde(skip_serializing_if = "is_false")]
931 allow_references_in_ptbs: bool,
932
933 #[serde(skip_serializing_if = "is_false")]
935 enable_display_registry: bool,
936
937 #[serde(skip_serializing_if = "is_false")]
939 private_generics_verifier_v2: bool,
940
941 #[serde(skip_serializing_if = "is_false")]
943 deprecate_global_storage_ops_during_deserialization: bool,
944
945 #[serde(skip_serializing_if = "is_false")]
948 enable_non_exclusive_writes: bool,
949
950 #[serde(skip_serializing_if = "is_false")]
952 deprecate_global_storage_ops: bool,
953
954 #[serde(skip_serializing_if = "is_false")]
956 normalize_depth_formula: bool,
957
958 #[serde(skip_serializing_if = "is_false")]
960 consensus_skip_gced_accept_votes: bool,
961
962 #[serde(skip_serializing_if = "is_false")]
964 include_cancelled_randomness_txns_in_prologue: bool,
965
966 #[serde(skip_serializing_if = "is_false")]
968 address_aliases: bool,
969
970 #[serde(skip_serializing_if = "is_false")]
973 fix_checkpoint_signature_mapping: bool,
974
975 #[serde(skip_serializing_if = "is_false")]
977 enable_object_funds_withdraw: bool,
978
979 #[serde(skip_serializing_if = "is_false")]
981 consensus_skip_gced_blocks_in_direct_finalization: bool,
982
983 #[serde(skip_serializing_if = "is_false")]
985 gas_rounding_halve_digits: bool,
986
987 #[serde(skip_serializing_if = "is_false")]
989 flexible_tx_context_positions: bool,
990
991 #[serde(skip_serializing_if = "is_false")]
993 disable_entry_point_signature_check: bool,
994
995 #[serde(skip_serializing_if = "is_false")]
997 convert_withdrawal_compatibility_ptb_arguments: bool,
998
999 #[serde(skip_serializing_if = "is_false")]
1001 restrict_hot_or_not_entry_functions: bool,
1002
1003 #[serde(skip_serializing_if = "is_false")]
1005 split_checkpoints_in_consensus_handler: bool,
1006
1007 #[serde(skip_serializing_if = "is_false")]
1009 consensus_always_accept_system_transactions: bool,
1010
1011 #[serde(skip_serializing_if = "is_false")]
1013 validator_metadata_verify_v2: bool,
1014
1015 #[serde(skip_serializing_if = "is_false")]
1018 defer_unpaid_amplification: bool,
1019
1020 #[serde(skip_serializing_if = "is_false")]
1021 randomize_checkpoint_tx_limit_in_tests: bool,
1022
1023 #[serde(skip_serializing_if = "is_false")]
1025 gasless_transaction_drop_safety: bool,
1026}
1027
1028fn is_false(b: &bool) -> bool {
1029 !b
1030}
1031
1032fn is_empty(b: &BTreeSet<String>) -> bool {
1033 b.is_empty()
1034}
1035
1036fn is_zero(val: &u64) -> bool {
1037 *val == 0
1038}
1039
1040#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1042pub enum ConsensusTransactionOrdering {
1043 #[default]
1045 None,
1046 ByGasPrice,
1048}
1049
1050impl ConsensusTransactionOrdering {
1051 pub fn is_none(&self) -> bool {
1052 matches!(self, ConsensusTransactionOrdering::None)
1053 }
1054}
1055
1056#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1057pub struct ExecutionTimeEstimateParams {
1058 pub target_utilization: u64,
1060 pub allowed_txn_cost_overage_burst_limit_us: u64,
1064
1065 pub randomness_scalar: u64,
1068
1069 pub max_estimate_us: u64,
1071
1072 pub stored_observations_num_included_checkpoints: u64,
1075
1076 pub stored_observations_limit: u64,
1078
1079 #[serde(skip_serializing_if = "is_zero")]
1082 pub stake_weighted_median_threshold: u64,
1083
1084 #[serde(skip_serializing_if = "is_false")]
1088 pub default_none_duration_for_new_keys: bool,
1089
1090 #[serde(skip_serializing_if = "Option::is_none")]
1092 pub observations_chunk_size: Option<u64>,
1093}
1094
1095#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1097pub enum PerObjectCongestionControlMode {
1098 #[default]
1099 None, TotalGasBudget, TotalTxCount, TotalGasBudgetWithCap, ExecutionTimeEstimate(ExecutionTimeEstimateParams), }
1105
1106impl PerObjectCongestionControlMode {
1107 pub fn is_none(&self) -> bool {
1108 matches!(self, PerObjectCongestionControlMode::None)
1109 }
1110}
1111
1112#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1114pub enum ConsensusChoice {
1115 #[default]
1116 Narwhal,
1117 SwapEachEpoch,
1118 Mysticeti,
1119}
1120
1121impl ConsensusChoice {
1122 pub fn is_narwhal(&self) -> bool {
1123 matches!(self, ConsensusChoice::Narwhal)
1124 }
1125}
1126
1127#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1129pub enum ConsensusNetwork {
1130 #[default]
1131 Anemo,
1132 Tonic,
1133}
1134
1135impl ConsensusNetwork {
1136 pub fn is_anemo(&self) -> bool {
1137 matches!(self, ConsensusNetwork::Anemo)
1138 }
1139}
1140
1141#[skip_serializing_none]
1173#[derive(Clone, Serialize, Debug, ProtocolConfigAccessors, ProtocolConfigOverride)]
1174pub struct ProtocolConfig {
1175 pub version: ProtocolVersion,
1176
1177 feature_flags: FeatureFlags,
1178
1179 max_tx_size_bytes: Option<u64>,
1182
1183 max_input_objects: Option<u64>,
1185
1186 max_size_written_objects: Option<u64>,
1190 max_size_written_objects_system_tx: Option<u64>,
1193
1194 max_serialized_tx_effects_size_bytes: Option<u64>,
1196
1197 max_serialized_tx_effects_size_bytes_system_tx: Option<u64>,
1199
1200 max_gas_payment_objects: Option<u32>,
1202
1203 max_modules_in_publish: Option<u32>,
1205
1206 max_package_dependencies: Option<u32>,
1208
1209 max_arguments: Option<u32>,
1212
1213 max_type_arguments: Option<u32>,
1215
1216 max_type_argument_depth: Option<u32>,
1218
1219 max_pure_argument_size: Option<u32>,
1221
1222 max_programmable_tx_commands: Option<u32>,
1224
1225 move_binary_format_version: Option<u32>,
1228 min_move_binary_format_version: Option<u32>,
1229
1230 binary_module_handles: Option<u16>,
1232 binary_struct_handles: Option<u16>,
1233 binary_function_handles: Option<u16>,
1234 binary_function_instantiations: Option<u16>,
1235 binary_signatures: Option<u16>,
1236 binary_constant_pool: Option<u16>,
1237 binary_identifiers: Option<u16>,
1238 binary_address_identifiers: Option<u16>,
1239 binary_struct_defs: Option<u16>,
1240 binary_struct_def_instantiations: Option<u16>,
1241 binary_function_defs: Option<u16>,
1242 binary_field_handles: Option<u16>,
1243 binary_field_instantiations: Option<u16>,
1244 binary_friend_decls: Option<u16>,
1245 binary_enum_defs: Option<u16>,
1246 binary_enum_def_instantiations: Option<u16>,
1247 binary_variant_handles: Option<u16>,
1248 binary_variant_instantiation_handles: Option<u16>,
1249
1250 max_move_object_size: Option<u64>,
1252
1253 max_move_package_size: Option<u64>,
1256
1257 max_publish_or_upgrade_per_ptb: Option<u64>,
1259
1260 max_tx_gas: Option<u64>,
1262
1263 max_gas_price: Option<u64>,
1265
1266 max_gas_price_rgp_factor_for_aborted_transactions: Option<u64>,
1269
1270 max_gas_computation_bucket: Option<u64>,
1272
1273 gas_rounding_step: Option<u64>,
1275
1276 max_loop_depth: Option<u64>,
1278
1279 max_generic_instantiation_length: Option<u64>,
1281
1282 max_function_parameters: Option<u64>,
1284
1285 max_basic_blocks: Option<u64>,
1287
1288 max_value_stack_size: Option<u64>,
1290
1291 max_type_nodes: Option<u64>,
1293
1294 max_push_size: Option<u64>,
1296
1297 max_struct_definitions: Option<u64>,
1299
1300 max_function_definitions: Option<u64>,
1302
1303 max_fields_in_struct: Option<u64>,
1305
1306 max_dependency_depth: Option<u64>,
1308
1309 max_num_event_emit: Option<u64>,
1311
1312 max_num_new_move_object_ids: Option<u64>,
1314
1315 max_num_new_move_object_ids_system_tx: Option<u64>,
1317
1318 max_num_deleted_move_object_ids: Option<u64>,
1320
1321 max_num_deleted_move_object_ids_system_tx: Option<u64>,
1323
1324 max_num_transferred_move_object_ids: Option<u64>,
1326
1327 max_num_transferred_move_object_ids_system_tx: Option<u64>,
1329
1330 max_event_emit_size: Option<u64>,
1332
1333 max_event_emit_size_total: Option<u64>,
1335
1336 max_move_vector_len: Option<u64>,
1338
1339 max_move_identifier_len: Option<u64>,
1341
1342 max_move_value_depth: Option<u64>,
1344
1345 max_move_enum_variants: Option<u64>,
1347
1348 max_back_edges_per_function: Option<u64>,
1350
1351 max_back_edges_per_module: Option<u64>,
1353
1354 max_verifier_meter_ticks_per_function: Option<u64>,
1356
1357 max_meter_ticks_per_module: Option<u64>,
1359
1360 max_meter_ticks_per_package: Option<u64>,
1362
1363 object_runtime_max_num_cached_objects: Option<u64>,
1367
1368 object_runtime_max_num_cached_objects_system_tx: Option<u64>,
1370
1371 object_runtime_max_num_store_entries: Option<u64>,
1373
1374 object_runtime_max_num_store_entries_system_tx: Option<u64>,
1376
1377 base_tx_cost_fixed: Option<u64>,
1380
1381 package_publish_cost_fixed: Option<u64>,
1384
1385 base_tx_cost_per_byte: Option<u64>,
1388
1389 package_publish_cost_per_byte: Option<u64>,
1391
1392 obj_access_cost_read_per_byte: Option<u64>,
1394
1395 obj_access_cost_mutate_per_byte: Option<u64>,
1397
1398 obj_access_cost_delete_per_byte: Option<u64>,
1400
1401 obj_access_cost_verify_per_byte: Option<u64>,
1411
1412 max_type_to_layout_nodes: Option<u64>,
1414
1415 max_ptb_value_size: Option<u64>,
1417
1418 gas_model_version: Option<u64>,
1421
1422 obj_data_cost_refundable: Option<u64>,
1425
1426 obj_metadata_cost_non_refundable: Option<u64>,
1430
1431 storage_rebate_rate: Option<u64>,
1437
1438 storage_fund_reinvest_rate: Option<u64>,
1441
1442 reward_slashing_rate: Option<u64>,
1445
1446 storage_gas_price: Option<u64>,
1448
1449 accumulator_object_storage_cost: Option<u64>,
1451
1452 max_transactions_per_checkpoint: Option<u64>,
1457
1458 max_checkpoint_size_bytes: Option<u64>,
1462
1463 buffer_stake_for_protocol_upgrade_bps: Option<u64>,
1468
1469 address_from_bytes_cost_base: Option<u64>,
1474 address_to_u256_cost_base: Option<u64>,
1476 address_from_u256_cost_base: Option<u64>,
1478
1479 config_read_setting_impl_cost_base: Option<u64>,
1484 config_read_setting_impl_cost_per_byte: Option<u64>,
1485
1486 dynamic_field_hash_type_and_key_cost_base: Option<u64>,
1489 dynamic_field_hash_type_and_key_type_cost_per_byte: Option<u64>,
1490 dynamic_field_hash_type_and_key_value_cost_per_byte: Option<u64>,
1491 dynamic_field_hash_type_and_key_type_tag_cost_per_byte: Option<u64>,
1492 dynamic_field_add_child_object_cost_base: Option<u64>,
1494 dynamic_field_add_child_object_type_cost_per_byte: Option<u64>,
1495 dynamic_field_add_child_object_value_cost_per_byte: Option<u64>,
1496 dynamic_field_add_child_object_struct_tag_cost_per_byte: Option<u64>,
1497 dynamic_field_borrow_child_object_cost_base: Option<u64>,
1499 dynamic_field_borrow_child_object_child_ref_cost_per_byte: Option<u64>,
1500 dynamic_field_borrow_child_object_type_cost_per_byte: Option<u64>,
1501 dynamic_field_remove_child_object_cost_base: Option<u64>,
1503 dynamic_field_remove_child_object_child_cost_per_byte: Option<u64>,
1504 dynamic_field_remove_child_object_type_cost_per_byte: Option<u64>,
1505 dynamic_field_has_child_object_cost_base: Option<u64>,
1507 dynamic_field_has_child_object_with_ty_cost_base: Option<u64>,
1509 dynamic_field_has_child_object_with_ty_type_cost_per_byte: Option<u64>,
1510 dynamic_field_has_child_object_with_ty_type_tag_cost_per_byte: Option<u64>,
1511
1512 event_emit_cost_base: Option<u64>,
1515 event_emit_value_size_derivation_cost_per_byte: Option<u64>,
1516 event_emit_tag_size_derivation_cost_per_byte: Option<u64>,
1517 event_emit_output_cost_per_byte: Option<u64>,
1518 event_emit_auth_stream_cost: Option<u64>,
1519
1520 object_borrow_uid_cost_base: Option<u64>,
1523 object_delete_impl_cost_base: Option<u64>,
1525 object_record_new_uid_cost_base: Option<u64>,
1527
1528 transfer_transfer_internal_cost_base: Option<u64>,
1531 transfer_party_transfer_internal_cost_base: Option<u64>,
1533 transfer_freeze_object_cost_base: Option<u64>,
1535 transfer_share_object_cost_base: Option<u64>,
1537 transfer_receive_object_cost_base: Option<u64>,
1540
1541 tx_context_derive_id_cost_base: Option<u64>,
1544 tx_context_fresh_id_cost_base: Option<u64>,
1545 tx_context_sender_cost_base: Option<u64>,
1546 tx_context_epoch_cost_base: Option<u64>,
1547 tx_context_epoch_timestamp_ms_cost_base: Option<u64>,
1548 tx_context_sponsor_cost_base: Option<u64>,
1549 tx_context_rgp_cost_base: Option<u64>,
1550 tx_context_gas_price_cost_base: Option<u64>,
1551 tx_context_gas_budget_cost_base: Option<u64>,
1552 tx_context_ids_created_cost_base: Option<u64>,
1553 tx_context_replace_cost_base: Option<u64>,
1554
1555 types_is_one_time_witness_cost_base: Option<u64>,
1558 types_is_one_time_witness_type_tag_cost_per_byte: Option<u64>,
1559 types_is_one_time_witness_type_cost_per_byte: Option<u64>,
1560
1561 validator_validate_metadata_cost_base: Option<u64>,
1564 validator_validate_metadata_data_cost_per_byte: Option<u64>,
1565
1566 crypto_invalid_arguments_cost: Option<u64>,
1568 bls12381_bls12381_min_sig_verify_cost_base: Option<u64>,
1570 bls12381_bls12381_min_sig_verify_msg_cost_per_byte: Option<u64>,
1571 bls12381_bls12381_min_sig_verify_msg_cost_per_block: Option<u64>,
1572
1573 bls12381_bls12381_min_pk_verify_cost_base: Option<u64>,
1575 bls12381_bls12381_min_pk_verify_msg_cost_per_byte: Option<u64>,
1576 bls12381_bls12381_min_pk_verify_msg_cost_per_block: Option<u64>,
1577
1578 ecdsa_k1_ecrecover_keccak256_cost_base: Option<u64>,
1580 ecdsa_k1_ecrecover_keccak256_msg_cost_per_byte: Option<u64>,
1581 ecdsa_k1_ecrecover_keccak256_msg_cost_per_block: Option<u64>,
1582 ecdsa_k1_ecrecover_sha256_cost_base: Option<u64>,
1583 ecdsa_k1_ecrecover_sha256_msg_cost_per_byte: Option<u64>,
1584 ecdsa_k1_ecrecover_sha256_msg_cost_per_block: Option<u64>,
1585
1586 ecdsa_k1_decompress_pubkey_cost_base: Option<u64>,
1588
1589 ecdsa_k1_secp256k1_verify_keccak256_cost_base: Option<u64>,
1591 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_byte: Option<u64>,
1592 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_block: Option<u64>,
1593 ecdsa_k1_secp256k1_verify_sha256_cost_base: Option<u64>,
1594 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_byte: Option<u64>,
1595 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_block: Option<u64>,
1596
1597 ecdsa_r1_ecrecover_keccak256_cost_base: Option<u64>,
1599 ecdsa_r1_ecrecover_keccak256_msg_cost_per_byte: Option<u64>,
1600 ecdsa_r1_ecrecover_keccak256_msg_cost_per_block: Option<u64>,
1601 ecdsa_r1_ecrecover_sha256_cost_base: Option<u64>,
1602 ecdsa_r1_ecrecover_sha256_msg_cost_per_byte: Option<u64>,
1603 ecdsa_r1_ecrecover_sha256_msg_cost_per_block: Option<u64>,
1604
1605 ecdsa_r1_secp256r1_verify_keccak256_cost_base: Option<u64>,
1607 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_byte: Option<u64>,
1608 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_block: Option<u64>,
1609 ecdsa_r1_secp256r1_verify_sha256_cost_base: Option<u64>,
1610 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_byte: Option<u64>,
1611 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_block: Option<u64>,
1612
1613 ecvrf_ecvrf_verify_cost_base: Option<u64>,
1615 ecvrf_ecvrf_verify_alpha_string_cost_per_byte: Option<u64>,
1616 ecvrf_ecvrf_verify_alpha_string_cost_per_block: Option<u64>,
1617
1618 ed25519_ed25519_verify_cost_base: Option<u64>,
1620 ed25519_ed25519_verify_msg_cost_per_byte: Option<u64>,
1621 ed25519_ed25519_verify_msg_cost_per_block: Option<u64>,
1622
1623 groth16_prepare_verifying_key_bls12381_cost_base: Option<u64>,
1625 groth16_prepare_verifying_key_bn254_cost_base: Option<u64>,
1626
1627 groth16_verify_groth16_proof_internal_bls12381_cost_base: Option<u64>,
1629 groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input: Option<u64>,
1630 groth16_verify_groth16_proof_internal_bn254_cost_base: Option<u64>,
1631 groth16_verify_groth16_proof_internal_bn254_cost_per_public_input: Option<u64>,
1632 groth16_verify_groth16_proof_internal_public_input_cost_per_byte: Option<u64>,
1633
1634 hash_blake2b256_cost_base: Option<u64>,
1636 hash_blake2b256_data_cost_per_byte: Option<u64>,
1637 hash_blake2b256_data_cost_per_block: Option<u64>,
1638
1639 hash_keccak256_cost_base: Option<u64>,
1641 hash_keccak256_data_cost_per_byte: Option<u64>,
1642 hash_keccak256_data_cost_per_block: Option<u64>,
1643
1644 poseidon_bn254_cost_base: Option<u64>,
1646 poseidon_bn254_cost_per_block: Option<u64>,
1647
1648 group_ops_bls12381_decode_scalar_cost: Option<u64>,
1650 group_ops_bls12381_decode_g1_cost: Option<u64>,
1651 group_ops_bls12381_decode_g2_cost: Option<u64>,
1652 group_ops_bls12381_decode_gt_cost: Option<u64>,
1653 group_ops_bls12381_scalar_add_cost: Option<u64>,
1654 group_ops_bls12381_g1_add_cost: Option<u64>,
1655 group_ops_bls12381_g2_add_cost: Option<u64>,
1656 group_ops_bls12381_gt_add_cost: Option<u64>,
1657 group_ops_bls12381_scalar_sub_cost: Option<u64>,
1658 group_ops_bls12381_g1_sub_cost: Option<u64>,
1659 group_ops_bls12381_g2_sub_cost: Option<u64>,
1660 group_ops_bls12381_gt_sub_cost: Option<u64>,
1661 group_ops_bls12381_scalar_mul_cost: Option<u64>,
1662 group_ops_bls12381_g1_mul_cost: Option<u64>,
1663 group_ops_bls12381_g2_mul_cost: Option<u64>,
1664 group_ops_bls12381_gt_mul_cost: Option<u64>,
1665 group_ops_bls12381_scalar_div_cost: Option<u64>,
1666 group_ops_bls12381_g1_div_cost: Option<u64>,
1667 group_ops_bls12381_g2_div_cost: Option<u64>,
1668 group_ops_bls12381_gt_div_cost: Option<u64>,
1669 group_ops_bls12381_g1_hash_to_base_cost: Option<u64>,
1670 group_ops_bls12381_g2_hash_to_base_cost: Option<u64>,
1671 group_ops_bls12381_g1_hash_to_cost_per_byte: Option<u64>,
1672 group_ops_bls12381_g2_hash_to_cost_per_byte: Option<u64>,
1673 group_ops_bls12381_g1_msm_base_cost: Option<u64>,
1674 group_ops_bls12381_g2_msm_base_cost: Option<u64>,
1675 group_ops_bls12381_g1_msm_base_cost_per_input: Option<u64>,
1676 group_ops_bls12381_g2_msm_base_cost_per_input: Option<u64>,
1677 group_ops_bls12381_msm_max_len: Option<u32>,
1678 group_ops_bls12381_pairing_cost: Option<u64>,
1679 group_ops_bls12381_g1_to_uncompressed_g1_cost: Option<u64>,
1680 group_ops_bls12381_uncompressed_g1_to_g1_cost: Option<u64>,
1681 group_ops_bls12381_uncompressed_g1_sum_base_cost: Option<u64>,
1682 group_ops_bls12381_uncompressed_g1_sum_cost_per_term: Option<u64>,
1683 group_ops_bls12381_uncompressed_g1_sum_max_terms: Option<u64>,
1684
1685 group_ops_ristretto_decode_scalar_cost: Option<u64>,
1686 group_ops_ristretto_decode_point_cost: Option<u64>,
1687 group_ops_ristretto_scalar_add_cost: Option<u64>,
1688 group_ops_ristretto_point_add_cost: Option<u64>,
1689 group_ops_ristretto_scalar_sub_cost: Option<u64>,
1690 group_ops_ristretto_point_sub_cost: Option<u64>,
1691 group_ops_ristretto_scalar_mul_cost: Option<u64>,
1692 group_ops_ristretto_point_mul_cost: Option<u64>,
1693 group_ops_ristretto_scalar_div_cost: Option<u64>,
1694 group_ops_ristretto_point_div_cost: Option<u64>,
1695
1696 hmac_hmac_sha3_256_cost_base: Option<u64>,
1698 hmac_hmac_sha3_256_input_cost_per_byte: Option<u64>,
1699 hmac_hmac_sha3_256_input_cost_per_block: Option<u64>,
1700
1701 check_zklogin_id_cost_base: Option<u64>,
1703 check_zklogin_issuer_cost_base: Option<u64>,
1705
1706 vdf_verify_vdf_cost: Option<u64>,
1707 vdf_hash_to_input_cost: Option<u64>,
1708
1709 nitro_attestation_parse_base_cost: Option<u64>,
1711 nitro_attestation_parse_cost_per_byte: Option<u64>,
1712 nitro_attestation_verify_base_cost: Option<u64>,
1713 nitro_attestation_verify_cost_per_cert: Option<u64>,
1714
1715 bcs_per_byte_serialized_cost: Option<u64>,
1717 bcs_legacy_min_output_size_cost: Option<u64>,
1718 bcs_failure_cost: Option<u64>,
1719
1720 hash_sha2_256_base_cost: Option<u64>,
1721 hash_sha2_256_per_byte_cost: Option<u64>,
1722 hash_sha2_256_legacy_min_input_len_cost: Option<u64>,
1723 hash_sha3_256_base_cost: Option<u64>,
1724 hash_sha3_256_per_byte_cost: Option<u64>,
1725 hash_sha3_256_legacy_min_input_len_cost: Option<u64>,
1726 type_name_get_base_cost: Option<u64>,
1727 type_name_get_per_byte_cost: Option<u64>,
1728 type_name_id_base_cost: Option<u64>,
1729
1730 string_check_utf8_base_cost: Option<u64>,
1731 string_check_utf8_per_byte_cost: Option<u64>,
1732 string_is_char_boundary_base_cost: Option<u64>,
1733 string_sub_string_base_cost: Option<u64>,
1734 string_sub_string_per_byte_cost: Option<u64>,
1735 string_index_of_base_cost: Option<u64>,
1736 string_index_of_per_byte_pattern_cost: Option<u64>,
1737 string_index_of_per_byte_searched_cost: Option<u64>,
1738
1739 vector_empty_base_cost: Option<u64>,
1740 vector_length_base_cost: Option<u64>,
1741 vector_push_back_base_cost: Option<u64>,
1742 vector_push_back_legacy_per_abstract_memory_unit_cost: Option<u64>,
1743 vector_borrow_base_cost: Option<u64>,
1744 vector_pop_back_base_cost: Option<u64>,
1745 vector_destroy_empty_base_cost: Option<u64>,
1746 vector_swap_base_cost: Option<u64>,
1747 debug_print_base_cost: Option<u64>,
1748 debug_print_stack_trace_base_cost: Option<u64>,
1749
1750 execution_version: Option<u64>,
1759
1760 consensus_bad_nodes_stake_threshold: Option<u64>,
1764
1765 max_jwk_votes_per_validator_per_epoch: Option<u64>,
1766 max_age_of_jwk_in_epochs: Option<u64>,
1770
1771 random_beacon_reduction_allowed_delta: Option<u16>,
1775
1776 random_beacon_reduction_lower_bound: Option<u32>,
1779
1780 random_beacon_dkg_timeout_round: Option<u32>,
1783
1784 random_beacon_min_round_interval_ms: Option<u64>,
1786
1787 random_beacon_dkg_version: Option<u64>,
1790
1791 consensus_max_transaction_size_bytes: Option<u64>,
1794 consensus_max_transactions_in_block_bytes: Option<u64>,
1796 consensus_max_num_transactions_in_block: Option<u64>,
1798
1799 consensus_voting_rounds: Option<u32>,
1801
1802 max_accumulated_txn_cost_per_object_in_narwhal_commit: Option<u64>,
1804
1805 max_deferral_rounds_for_congestion_control: Option<u64>,
1808
1809 max_txn_cost_overage_per_object_in_commit: Option<u64>,
1811
1812 allowed_txn_cost_overage_burst_per_object_in_commit: Option<u64>,
1814
1815 min_checkpoint_interval_ms: Option<u64>,
1817
1818 checkpoint_summary_version_specific_data: Option<u64>,
1820
1821 max_soft_bundle_size: Option<u64>,
1823
1824 bridge_should_try_to_finalize_committee: Option<bool>,
1828
1829 max_accumulated_txn_cost_per_object_in_mysticeti_commit: Option<u64>,
1835
1836 max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit: Option<u64>,
1839
1840 consensus_gc_depth: Option<u32>,
1843
1844 gas_budget_based_txn_cost_cap_factor: Option<u64>,
1846
1847 gas_budget_based_txn_cost_absolute_cap_commit_count: Option<u64>,
1849
1850 sip_45_consensus_amplification_threshold: Option<u64>,
1853
1854 use_object_per_epoch_marker_table_v2: Option<bool>,
1857
1858 consensus_commit_rate_estimation_window_size: Option<u32>,
1860
1861 #[serde(skip_serializing_if = "Vec::is_empty")]
1865 aliased_addresses: Vec<AliasedAddress>,
1866
1867 translation_per_command_base_charge: Option<u64>,
1870
1871 translation_per_input_base_charge: Option<u64>,
1874
1875 translation_pure_input_per_byte_charge: Option<u64>,
1877
1878 translation_per_type_node_charge: Option<u64>,
1882
1883 translation_per_reference_node_charge: Option<u64>,
1886
1887 translation_per_linkage_entry_charge: Option<u64>,
1890
1891 max_updates_per_settlement_txn: Option<u32>,
1893}
1894
1895#[derive(Clone, Serialize, Deserialize, Debug)]
1897pub struct AliasedAddress {
1898 pub original: [u8; 32],
1900 pub aliased: [u8; 32],
1902 pub allowed_tx_digests: Vec<[u8; 32]>,
1904}
1905
1906impl ProtocolConfig {
1908 pub fn check_package_upgrades_supported(&self) -> Result<(), Error> {
1921 if self.feature_flags.package_upgrades {
1922 Ok(())
1923 } else {
1924 Err(Error(format!(
1925 "package upgrades are not supported at {:?}",
1926 self.version
1927 )))
1928 }
1929 }
1930
1931 pub fn allow_receiving_object_id(&self) -> bool {
1932 self.feature_flags.allow_receiving_object_id
1933 }
1934
1935 pub fn receiving_objects_supported(&self) -> bool {
1936 self.feature_flags.receive_objects
1937 }
1938
1939 pub fn package_upgrades_supported(&self) -> bool {
1940 self.feature_flags.package_upgrades
1941 }
1942
1943 pub fn check_commit_root_state_digest_supported(&self) -> bool {
1944 self.feature_flags.commit_root_state_digest
1945 }
1946
1947 pub fn get_advance_epoch_start_time_in_safe_mode(&self) -> bool {
1948 self.feature_flags.advance_epoch_start_time_in_safe_mode
1949 }
1950
1951 pub fn loaded_child_objects_fixed(&self) -> bool {
1952 self.feature_flags.loaded_child_objects_fixed
1953 }
1954
1955 pub fn missing_type_is_compatibility_error(&self) -> bool {
1956 self.feature_flags.missing_type_is_compatibility_error
1957 }
1958
1959 pub fn scoring_decision_with_validity_cutoff(&self) -> bool {
1960 self.feature_flags.scoring_decision_with_validity_cutoff
1961 }
1962
1963 pub fn narwhal_versioned_metadata(&self) -> bool {
1964 self.feature_flags.narwhal_versioned_metadata
1965 }
1966
1967 pub fn consensus_order_end_of_epoch_last(&self) -> bool {
1968 self.feature_flags.consensus_order_end_of_epoch_last
1969 }
1970
1971 pub fn disallow_adding_abilities_on_upgrade(&self) -> bool {
1972 self.feature_flags.disallow_adding_abilities_on_upgrade
1973 }
1974
1975 pub fn disable_invariant_violation_check_in_swap_loc(&self) -> bool {
1976 self.feature_flags
1977 .disable_invariant_violation_check_in_swap_loc
1978 }
1979
1980 pub fn advance_to_highest_supported_protocol_version(&self) -> bool {
1981 self.feature_flags
1982 .advance_to_highest_supported_protocol_version
1983 }
1984
1985 pub fn ban_entry_init(&self) -> bool {
1986 self.feature_flags.ban_entry_init
1987 }
1988
1989 pub fn package_digest_hash_module(&self) -> bool {
1990 self.feature_flags.package_digest_hash_module
1991 }
1992
1993 pub fn disallow_change_struct_type_params_on_upgrade(&self) -> bool {
1994 self.feature_flags
1995 .disallow_change_struct_type_params_on_upgrade
1996 }
1997
1998 pub fn no_extraneous_module_bytes(&self) -> bool {
1999 self.feature_flags.no_extraneous_module_bytes
2000 }
2001
2002 pub fn zklogin_auth(&self) -> bool {
2003 self.feature_flags.zklogin_auth
2004 }
2005
2006 pub fn zklogin_supported_providers(&self) -> &BTreeSet<String> {
2007 &self.feature_flags.zklogin_supported_providers
2008 }
2009
2010 pub fn consensus_transaction_ordering(&self) -> ConsensusTransactionOrdering {
2011 self.feature_flags.consensus_transaction_ordering
2012 }
2013
2014 pub fn simplified_unwrap_then_delete(&self) -> bool {
2015 self.feature_flags.simplified_unwrap_then_delete
2016 }
2017
2018 pub fn supports_upgraded_multisig(&self) -> bool {
2019 self.feature_flags.upgraded_multisig_supported
2020 }
2021
2022 pub fn txn_base_cost_as_multiplier(&self) -> bool {
2023 self.feature_flags.txn_base_cost_as_multiplier
2024 }
2025
2026 pub fn shared_object_deletion(&self) -> bool {
2027 self.feature_flags.shared_object_deletion
2028 }
2029
2030 pub fn narwhal_new_leader_election_schedule(&self) -> bool {
2031 self.feature_flags.narwhal_new_leader_election_schedule
2032 }
2033
2034 pub fn loaded_child_object_format(&self) -> bool {
2035 self.feature_flags.loaded_child_object_format
2036 }
2037
2038 pub fn enable_jwk_consensus_updates(&self) -> bool {
2039 let ret = self.feature_flags.enable_jwk_consensus_updates;
2040 if ret {
2041 assert!(self.feature_flags.end_of_epoch_transaction_supported);
2043 }
2044 ret
2045 }
2046
2047 pub fn simple_conservation_checks(&self) -> bool {
2048 self.feature_flags.simple_conservation_checks
2049 }
2050
2051 pub fn loaded_child_object_format_type(&self) -> bool {
2052 self.feature_flags.loaded_child_object_format_type
2053 }
2054
2055 pub fn end_of_epoch_transaction_supported(&self) -> bool {
2056 let ret = self.feature_flags.end_of_epoch_transaction_supported;
2057 if !ret {
2058 assert!(!self.feature_flags.enable_jwk_consensus_updates);
2060 }
2061 ret
2062 }
2063
2064 pub fn recompute_has_public_transfer_in_execution(&self) -> bool {
2065 self.feature_flags
2066 .recompute_has_public_transfer_in_execution
2067 }
2068
2069 pub fn create_authenticator_state_in_genesis(&self) -> bool {
2071 self.enable_jwk_consensus_updates()
2072 }
2073
2074 pub fn random_beacon(&self) -> bool {
2075 self.feature_flags.random_beacon
2076 }
2077
2078 pub fn dkg_version(&self) -> u64 {
2079 self.random_beacon_dkg_version.unwrap_or(1)
2081 }
2082
2083 pub fn enable_bridge(&self) -> bool {
2084 let ret = self.feature_flags.bridge;
2085 if ret {
2086 assert!(self.feature_flags.end_of_epoch_transaction_supported);
2088 }
2089 ret
2090 }
2091
2092 pub fn should_try_to_finalize_bridge_committee(&self) -> bool {
2093 if !self.enable_bridge() {
2094 return false;
2095 }
2096 self.bridge_should_try_to_finalize_committee.unwrap_or(true)
2098 }
2099
2100 pub fn enable_effects_v2(&self) -> bool {
2101 self.feature_flags.enable_effects_v2
2102 }
2103
2104 pub fn narwhal_certificate_v2(&self) -> bool {
2105 self.feature_flags.narwhal_certificate_v2
2106 }
2107
2108 pub fn verify_legacy_zklogin_address(&self) -> bool {
2109 self.feature_flags.verify_legacy_zklogin_address
2110 }
2111
2112 pub fn accept_zklogin_in_multisig(&self) -> bool {
2113 self.feature_flags.accept_zklogin_in_multisig
2114 }
2115
2116 pub fn accept_passkey_in_multisig(&self) -> bool {
2117 self.feature_flags.accept_passkey_in_multisig
2118 }
2119
2120 pub fn validate_zklogin_public_identifier(&self) -> bool {
2121 self.feature_flags.validate_zklogin_public_identifier
2122 }
2123
2124 pub fn zklogin_max_epoch_upper_bound_delta(&self) -> Option<u64> {
2125 self.feature_flags.zklogin_max_epoch_upper_bound_delta
2126 }
2127
2128 pub fn throughput_aware_consensus_submission(&self) -> bool {
2129 self.feature_flags.throughput_aware_consensus_submission
2130 }
2131
2132 pub fn include_consensus_digest_in_prologue(&self) -> bool {
2133 self.feature_flags.include_consensus_digest_in_prologue
2134 }
2135
2136 pub fn record_consensus_determined_version_assignments_in_prologue(&self) -> bool {
2137 self.feature_flags
2138 .record_consensus_determined_version_assignments_in_prologue
2139 }
2140
2141 pub fn record_additional_state_digest_in_prologue(&self) -> bool {
2142 self.feature_flags
2143 .record_additional_state_digest_in_prologue
2144 }
2145
2146 pub fn record_consensus_determined_version_assignments_in_prologue_v2(&self) -> bool {
2147 self.feature_flags
2148 .record_consensus_determined_version_assignments_in_prologue_v2
2149 }
2150
2151 pub fn prepend_prologue_tx_in_consensus_commit_in_checkpoints(&self) -> bool {
2152 self.feature_flags
2153 .prepend_prologue_tx_in_consensus_commit_in_checkpoints
2154 }
2155
2156 pub fn hardened_otw_check(&self) -> bool {
2157 self.feature_flags.hardened_otw_check
2158 }
2159
2160 pub fn enable_poseidon(&self) -> bool {
2161 self.feature_flags.enable_poseidon
2162 }
2163
2164 pub fn enable_coin_deny_list_v1(&self) -> bool {
2165 self.feature_flags.enable_coin_deny_list
2166 }
2167
2168 pub fn enable_accumulators(&self) -> bool {
2169 self.feature_flags.enable_accumulators
2170 }
2171
2172 pub fn enable_coin_reservation_obj_refs(&self) -> bool {
2173 self.feature_flags.enable_coin_reservation_obj_refs
2174 }
2175
2176 pub fn create_root_accumulator_object(&self) -> bool {
2177 self.feature_flags.create_root_accumulator_object
2178 }
2179
2180 pub fn enable_address_balance_gas_payments(&self) -> bool {
2181 self.feature_flags.enable_address_balance_gas_payments
2182 }
2183
2184 pub fn address_balance_gas_check_rgp_at_signing(&self) -> bool {
2185 self.feature_flags.address_balance_gas_check_rgp_at_signing
2186 }
2187
2188 pub fn address_balance_gas_reject_gas_coin_arg(&self) -> bool {
2189 self.feature_flags.address_balance_gas_reject_gas_coin_arg
2190 }
2191
2192 pub fn enable_multi_epoch_transaction_expiration(&self) -> bool {
2193 self.feature_flags.enable_multi_epoch_transaction_expiration
2194 }
2195
2196 pub fn relax_valid_during_for_owned_inputs(&self) -> bool {
2197 self.feature_flags.relax_valid_during_for_owned_inputs
2198 }
2199
2200 pub fn enable_authenticated_event_streams(&self) -> bool {
2201 self.feature_flags.enable_authenticated_event_streams && self.enable_accumulators()
2202 }
2203
2204 pub fn enable_non_exclusive_writes(&self) -> bool {
2205 self.feature_flags.enable_non_exclusive_writes
2206 }
2207
2208 pub fn enable_coin_registry(&self) -> bool {
2209 self.feature_flags.enable_coin_registry
2210 }
2211
2212 pub fn enable_display_registry(&self) -> bool {
2213 self.feature_flags.enable_display_registry
2214 }
2215
2216 pub fn enable_coin_deny_list_v2(&self) -> bool {
2217 self.feature_flags.enable_coin_deny_list_v2
2218 }
2219
2220 pub fn enable_group_ops_native_functions(&self) -> bool {
2221 self.feature_flags.enable_group_ops_native_functions
2222 }
2223
2224 pub fn enable_group_ops_native_function_msm(&self) -> bool {
2225 self.feature_flags.enable_group_ops_native_function_msm
2226 }
2227
2228 pub fn enable_ristretto255_group_ops(&self) -> bool {
2229 self.feature_flags.enable_ristretto255_group_ops
2230 }
2231
2232 pub fn reject_mutable_random_on_entry_functions(&self) -> bool {
2233 self.feature_flags.reject_mutable_random_on_entry_functions
2234 }
2235
2236 pub fn per_object_congestion_control_mode(&self) -> PerObjectCongestionControlMode {
2237 self.feature_flags.per_object_congestion_control_mode
2238 }
2239
2240 pub fn consensus_choice(&self) -> ConsensusChoice {
2241 self.feature_flags.consensus_choice
2242 }
2243
2244 pub fn consensus_network(&self) -> ConsensusNetwork {
2245 self.feature_flags.consensus_network
2246 }
2247
2248 pub fn correct_gas_payment_limit_check(&self) -> bool {
2249 self.feature_flags.correct_gas_payment_limit_check
2250 }
2251
2252 pub fn reshare_at_same_initial_version(&self) -> bool {
2253 self.feature_flags.reshare_at_same_initial_version
2254 }
2255
2256 pub fn resolve_abort_locations_to_package_id(&self) -> bool {
2257 self.feature_flags.resolve_abort_locations_to_package_id
2258 }
2259
2260 pub fn mysticeti_use_committed_subdag_digest(&self) -> bool {
2261 self.feature_flags.mysticeti_use_committed_subdag_digest
2262 }
2263
2264 pub fn enable_vdf(&self) -> bool {
2265 self.feature_flags.enable_vdf
2266 }
2267
2268 pub fn fresh_vm_on_framework_upgrade(&self) -> bool {
2269 self.feature_flags.fresh_vm_on_framework_upgrade
2270 }
2271
2272 pub fn mysticeti_num_leaders_per_round(&self) -> Option<usize> {
2273 self.feature_flags.mysticeti_num_leaders_per_round
2274 }
2275
2276 pub fn soft_bundle(&self) -> bool {
2277 self.feature_flags.soft_bundle
2278 }
2279
2280 pub fn passkey_auth(&self) -> bool {
2281 self.feature_flags.passkey_auth
2282 }
2283
2284 pub fn authority_capabilities_v2(&self) -> bool {
2285 self.feature_flags.authority_capabilities_v2
2286 }
2287
2288 pub fn max_transaction_size_bytes(&self) -> u64 {
2289 self.consensus_max_transaction_size_bytes
2291 .unwrap_or(256 * 1024)
2292 }
2293
2294 pub fn max_transactions_in_block_bytes(&self) -> u64 {
2295 if cfg!(msim) {
2296 256 * 1024
2297 } else {
2298 self.consensus_max_transactions_in_block_bytes
2299 .unwrap_or(512 * 1024)
2300 }
2301 }
2302
2303 pub fn max_num_transactions_in_block(&self) -> u64 {
2304 if cfg!(msim) {
2305 8
2306 } else {
2307 self.consensus_max_num_transactions_in_block.unwrap_or(512)
2308 }
2309 }
2310
2311 pub fn rethrow_serialization_type_layout_errors(&self) -> bool {
2312 self.feature_flags.rethrow_serialization_type_layout_errors
2313 }
2314
2315 pub fn consensus_distributed_vote_scoring_strategy(&self) -> bool {
2316 self.feature_flags
2317 .consensus_distributed_vote_scoring_strategy
2318 }
2319
2320 pub fn consensus_round_prober(&self) -> bool {
2321 self.feature_flags.consensus_round_prober
2322 }
2323
2324 pub fn validate_identifier_inputs(&self) -> bool {
2325 self.feature_flags.validate_identifier_inputs
2326 }
2327
2328 pub fn gc_depth(&self) -> u32 {
2329 self.consensus_gc_depth.unwrap_or(0)
2330 }
2331
2332 pub fn mysticeti_fastpath(&self) -> bool {
2333 self.feature_flags.mysticeti_fastpath
2334 }
2335
2336 pub fn relocate_event_module(&self) -> bool {
2337 self.feature_flags.relocate_event_module
2338 }
2339
2340 pub fn uncompressed_g1_group_elements(&self) -> bool {
2341 self.feature_flags.uncompressed_g1_group_elements
2342 }
2343
2344 pub fn disallow_new_modules_in_deps_only_packages(&self) -> bool {
2345 self.feature_flags
2346 .disallow_new_modules_in_deps_only_packages
2347 }
2348
2349 pub fn consensus_smart_ancestor_selection(&self) -> bool {
2350 self.feature_flags.consensus_smart_ancestor_selection
2351 }
2352
2353 pub fn disable_preconsensus_locking(&self) -> bool {
2354 self.feature_flags.disable_preconsensus_locking
2355 }
2356
2357 pub fn consensus_round_prober_probe_accepted_rounds(&self) -> bool {
2358 self.feature_flags
2359 .consensus_round_prober_probe_accepted_rounds
2360 }
2361
2362 pub fn native_charging_v2(&self) -> bool {
2363 self.feature_flags.native_charging_v2
2364 }
2365
2366 pub fn consensus_linearize_subdag_v2(&self) -> bool {
2367 let res = self.feature_flags.consensus_linearize_subdag_v2;
2368 assert!(
2369 !res || self.gc_depth() > 0,
2370 "The consensus linearize sub dag V2 requires GC to be enabled"
2371 );
2372 res
2373 }
2374
2375 pub fn consensus_median_based_commit_timestamp(&self) -> bool {
2376 let res = self.feature_flags.consensus_median_based_commit_timestamp;
2377 assert!(
2378 !res || self.gc_depth() > 0,
2379 "The consensus median based commit timestamp requires GC to be enabled"
2380 );
2381 res
2382 }
2383
2384 pub fn consensus_batched_block_sync(&self) -> bool {
2385 self.feature_flags.consensus_batched_block_sync
2386 }
2387
2388 pub fn convert_type_argument_error(&self) -> bool {
2389 self.feature_flags.convert_type_argument_error
2390 }
2391
2392 pub fn variant_nodes(&self) -> bool {
2393 self.feature_flags.variant_nodes
2394 }
2395
2396 pub fn consensus_zstd_compression(&self) -> bool {
2397 self.feature_flags.consensus_zstd_compression
2398 }
2399
2400 pub fn enable_nitro_attestation(&self) -> bool {
2401 self.feature_flags.enable_nitro_attestation
2402 }
2403
2404 pub fn enable_nitro_attestation_upgraded_parsing(&self) -> bool {
2405 self.feature_flags.enable_nitro_attestation_upgraded_parsing
2406 }
2407
2408 pub fn enable_nitro_attestation_all_nonzero_pcrs_parsing(&self) -> bool {
2409 self.feature_flags
2410 .enable_nitro_attestation_all_nonzero_pcrs_parsing
2411 }
2412
2413 pub fn enable_nitro_attestation_always_include_required_pcrs_parsing(&self) -> bool {
2414 self.feature_flags
2415 .enable_nitro_attestation_always_include_required_pcrs_parsing
2416 }
2417
2418 pub fn get_consensus_commit_rate_estimation_window_size(&self) -> u32 {
2419 self.consensus_commit_rate_estimation_window_size
2420 .unwrap_or(0)
2421 }
2422
2423 pub fn consensus_num_requested_prior_commits_at_startup(&self) -> u32 {
2424 let window_size = self.get_consensus_commit_rate_estimation_window_size();
2428 assert!(window_size == 0 || self.record_additional_state_digest_in_prologue());
2430 window_size
2431 }
2432
2433 pub fn minimize_child_object_mutations(&self) -> bool {
2434 self.feature_flags.minimize_child_object_mutations
2435 }
2436
2437 pub fn move_native_context(&self) -> bool {
2438 self.feature_flags.move_native_context
2439 }
2440
2441 pub fn normalize_ptb_arguments(&self) -> bool {
2442 self.feature_flags.normalize_ptb_arguments
2443 }
2444
2445 pub fn enforce_checkpoint_timestamp_monotonicity(&self) -> bool {
2446 self.feature_flags.enforce_checkpoint_timestamp_monotonicity
2447 }
2448
2449 pub fn max_ptb_value_size_v2(&self) -> bool {
2450 self.feature_flags.max_ptb_value_size_v2
2451 }
2452
2453 pub fn resolve_type_input_ids_to_defining_id(&self) -> bool {
2454 self.feature_flags.resolve_type_input_ids_to_defining_id
2455 }
2456
2457 pub fn enable_party_transfer(&self) -> bool {
2458 self.feature_flags.enable_party_transfer
2459 }
2460
2461 pub fn allow_unbounded_system_objects(&self) -> bool {
2462 self.feature_flags.allow_unbounded_system_objects
2463 }
2464
2465 pub fn type_tags_in_object_runtime(&self) -> bool {
2466 self.feature_flags.type_tags_in_object_runtime
2467 }
2468
2469 pub fn enable_ptb_execution_v2(&self) -> bool {
2470 self.feature_flags.enable_ptb_execution_v2
2471 }
2472
2473 pub fn better_adapter_type_resolution_errors(&self) -> bool {
2474 self.feature_flags.better_adapter_type_resolution_errors
2475 }
2476
2477 pub fn record_time_estimate_processed(&self) -> bool {
2478 self.feature_flags.record_time_estimate_processed
2479 }
2480
2481 pub fn ignore_execution_time_observations_after_certs_closed(&self) -> bool {
2482 self.feature_flags
2483 .ignore_execution_time_observations_after_certs_closed
2484 }
2485
2486 pub fn dependency_linkage_error(&self) -> bool {
2487 self.feature_flags.dependency_linkage_error
2488 }
2489
2490 pub fn additional_multisig_checks(&self) -> bool {
2491 self.feature_flags.additional_multisig_checks
2492 }
2493
2494 pub fn debug_fatal_on_move_invariant_violation(&self) -> bool {
2495 self.feature_flags.debug_fatal_on_move_invariant_violation
2496 }
2497
2498 pub fn allow_private_accumulator_entrypoints(&self) -> bool {
2499 self.feature_flags.allow_private_accumulator_entrypoints
2500 }
2501
2502 pub fn additional_consensus_digest_indirect_state(&self) -> bool {
2503 self.feature_flags
2504 .additional_consensus_digest_indirect_state
2505 }
2506
2507 pub fn check_for_init_during_upgrade(&self) -> bool {
2508 self.feature_flags.check_for_init_during_upgrade
2509 }
2510
2511 pub fn per_command_shared_object_transfer_rules(&self) -> bool {
2512 self.feature_flags.per_command_shared_object_transfer_rules
2513 }
2514
2515 pub fn consensus_checkpoint_signature_key_includes_digest(&self) -> bool {
2516 self.feature_flags
2517 .consensus_checkpoint_signature_key_includes_digest
2518 }
2519
2520 pub fn include_checkpoint_artifacts_digest_in_summary(&self) -> bool {
2521 self.feature_flags
2522 .include_checkpoint_artifacts_digest_in_summary
2523 }
2524
2525 pub fn use_mfp_txns_in_load_initial_object_debts(&self) -> bool {
2526 self.feature_flags.use_mfp_txns_in_load_initial_object_debts
2527 }
2528
2529 pub fn cancel_for_failed_dkg_early(&self) -> bool {
2530 self.feature_flags.cancel_for_failed_dkg_early
2531 }
2532
2533 pub fn abstract_size_in_object_runtime(&self) -> bool {
2534 self.feature_flags.abstract_size_in_object_runtime
2535 }
2536
2537 pub fn object_runtime_charge_cache_load_gas(&self) -> bool {
2538 self.feature_flags.object_runtime_charge_cache_load_gas
2539 }
2540
2541 pub fn additional_borrow_checks(&self) -> bool {
2542 self.feature_flags.additional_borrow_checks
2543 }
2544
2545 pub fn use_new_commit_handler(&self) -> bool {
2546 self.feature_flags.use_new_commit_handler
2547 }
2548
2549 pub fn better_loader_errors(&self) -> bool {
2550 self.feature_flags.better_loader_errors
2551 }
2552
2553 pub fn generate_df_type_layouts(&self) -> bool {
2554 self.feature_flags.generate_df_type_layouts
2555 }
2556
2557 pub fn allow_references_in_ptbs(&self) -> bool {
2558 self.feature_flags.allow_references_in_ptbs
2559 }
2560
2561 pub fn private_generics_verifier_v2(&self) -> bool {
2562 self.feature_flags.private_generics_verifier_v2
2563 }
2564
2565 pub fn deprecate_global_storage_ops_during_deserialization(&self) -> bool {
2566 self.feature_flags
2567 .deprecate_global_storage_ops_during_deserialization
2568 }
2569
2570 pub fn enable_observation_chunking(&self) -> bool {
2571 matches!(self.feature_flags.per_object_congestion_control_mode,
2572 PerObjectCongestionControlMode::ExecutionTimeEstimate(ref params)
2573 if params.observations_chunk_size.is_some()
2574 )
2575 }
2576
2577 pub fn deprecate_global_storage_ops(&self) -> bool {
2578 self.feature_flags.deprecate_global_storage_ops
2579 }
2580
2581 pub fn normalize_depth_formula(&self) -> bool {
2582 self.feature_flags.normalize_depth_formula
2583 }
2584
2585 pub fn consensus_skip_gced_accept_votes(&self) -> bool {
2586 self.feature_flags.consensus_skip_gced_accept_votes
2587 }
2588
2589 pub fn include_cancelled_randomness_txns_in_prologue(&self) -> bool {
2590 self.feature_flags
2591 .include_cancelled_randomness_txns_in_prologue
2592 }
2593
2594 pub fn address_aliases(&self) -> bool {
2595 let address_aliases = self.feature_flags.address_aliases;
2596 assert!(
2597 !address_aliases || self.mysticeti_fastpath(),
2598 "Address aliases requires Mysticeti fastpath to be enabled"
2599 );
2600 if address_aliases {
2601 assert!(
2602 self.feature_flags.disable_preconsensus_locking,
2603 "Address aliases requires CertifiedTransaction to be disabled"
2604 );
2605 }
2606 address_aliases
2607 }
2608
2609 pub fn fix_checkpoint_signature_mapping(&self) -> bool {
2610 self.feature_flags.fix_checkpoint_signature_mapping
2611 }
2612
2613 pub fn enable_object_funds_withdraw(&self) -> bool {
2614 self.feature_flags.enable_object_funds_withdraw
2615 }
2616
2617 pub fn gas_rounding_halve_digits(&self) -> bool {
2618 self.feature_flags.gas_rounding_halve_digits
2619 }
2620
2621 pub fn flexible_tx_context_positions(&self) -> bool {
2622 self.feature_flags.flexible_tx_context_positions
2623 }
2624
2625 pub fn disable_entry_point_signature_check(&self) -> bool {
2626 self.feature_flags.disable_entry_point_signature_check
2627 }
2628
2629 pub fn consensus_skip_gced_blocks_in_direct_finalization(&self) -> bool {
2630 self.feature_flags
2631 .consensus_skip_gced_blocks_in_direct_finalization
2632 }
2633
2634 pub fn convert_withdrawal_compatibility_ptb_arguments(&self) -> bool {
2635 self.feature_flags
2636 .convert_withdrawal_compatibility_ptb_arguments
2637 }
2638
2639 pub fn restrict_hot_or_not_entry_functions(&self) -> bool {
2640 self.feature_flags.restrict_hot_or_not_entry_functions
2641 }
2642
2643 pub fn split_checkpoints_in_consensus_handler(&self) -> bool {
2644 self.feature_flags.split_checkpoints_in_consensus_handler
2645 }
2646
2647 pub fn consensus_always_accept_system_transactions(&self) -> bool {
2648 self.feature_flags
2649 .consensus_always_accept_system_transactions
2650 }
2651
2652 pub fn validator_metadata_verify_v2(&self) -> bool {
2653 self.feature_flags.validator_metadata_verify_v2
2654 }
2655
2656 pub fn defer_unpaid_amplification(&self) -> bool {
2657 self.feature_flags.defer_unpaid_amplification
2658 }
2659
2660 pub fn gasless_transaction_drop_safety(&self) -> bool {
2661 self.feature_flags.gasless_transaction_drop_safety
2662 }
2663}
2664
2665#[cfg(not(msim))]
2666static POISON_VERSION_METHODS: AtomicBool = AtomicBool::new(false);
2667
2668#[cfg(msim)]
2670thread_local! {
2671 static POISON_VERSION_METHODS: AtomicBool = AtomicBool::new(false);
2672}
2673
2674impl ProtocolConfig {
2676 pub fn get_for_version(version: ProtocolVersion, chain: Chain) -> Self {
2678 assert!(
2680 version >= ProtocolVersion::MIN,
2681 "Network protocol version is {:?}, but the minimum supported version by the binary is {:?}. Please upgrade the binary.",
2682 version,
2683 ProtocolVersion::MIN.0,
2684 );
2685 assert!(
2686 version <= ProtocolVersion::MAX_ALLOWED,
2687 "Network protocol version is {:?}, but the maximum supported version by the binary is {:?}. Please upgrade the binary.",
2688 version,
2689 ProtocolVersion::MAX_ALLOWED.0,
2690 );
2691
2692 let mut ret = Self::get_for_version_impl(version, chain);
2693 ret.version = version;
2694
2695 ret = CONFIG_OVERRIDE.with(|ovr| {
2696 if let Some(override_fn) = &*ovr.borrow() {
2697 warn!(
2698 "overriding ProtocolConfig settings with custom settings (you should not see this log outside of tests)"
2699 );
2700 override_fn(version, ret)
2701 } else {
2702 ret
2703 }
2704 });
2705
2706 if std::env::var("SUI_PROTOCOL_CONFIG_OVERRIDE_ENABLE").is_ok() {
2707 warn!(
2708 "overriding ProtocolConfig settings with custom settings; this may break non-local networks"
2709 );
2710 let overrides: ProtocolConfigOptional =
2711 serde_env::from_env_with_prefix("SUI_PROTOCOL_CONFIG_OVERRIDE")
2712 .expect("failed to parse ProtocolConfig override env variables");
2713 overrides.apply_to(&mut ret);
2714 }
2715
2716 ret
2717 }
2718
2719 pub fn get_for_version_if_supported(version: ProtocolVersion, chain: Chain) -> Option<Self> {
2722 if version.0 >= ProtocolVersion::MIN.0 && version.0 <= ProtocolVersion::MAX_ALLOWED.0 {
2723 let mut ret = Self::get_for_version_impl(version, chain);
2724 ret.version = version;
2725 Some(ret)
2726 } else {
2727 None
2728 }
2729 }
2730
2731 #[cfg(not(msim))]
2732 pub fn poison_get_for_min_version() {
2733 POISON_VERSION_METHODS.store(true, Ordering::Relaxed);
2734 }
2735
2736 #[cfg(not(msim))]
2737 fn load_poison_get_for_min_version() -> bool {
2738 POISON_VERSION_METHODS.load(Ordering::Relaxed)
2739 }
2740
2741 #[cfg(msim)]
2742 pub fn poison_get_for_min_version() {
2743 POISON_VERSION_METHODS.with(|p| p.store(true, Ordering::Relaxed));
2744 }
2745
2746 #[cfg(msim)]
2747 fn load_poison_get_for_min_version() -> bool {
2748 POISON_VERSION_METHODS.with(|p| p.load(Ordering::Relaxed))
2749 }
2750
2751 pub fn get_for_min_version() -> Self {
2754 if Self::load_poison_get_for_min_version() {
2755 panic!("get_for_min_version called on validator");
2756 }
2757 ProtocolConfig::get_for_version(ProtocolVersion::MIN, Chain::Unknown)
2758 }
2759
2760 #[allow(non_snake_case)]
2770 pub fn get_for_max_version_UNSAFE() -> Self {
2771 if Self::load_poison_get_for_min_version() {
2772 panic!("get_for_max_version_UNSAFE called on validator");
2773 }
2774 ProtocolConfig::get_for_version(ProtocolVersion::MAX, Chain::Unknown)
2775 }
2776
2777 fn get_for_version_impl(version: ProtocolVersion, chain: Chain) -> Self {
2778 #[cfg(msim)]
2779 {
2780 if version == ProtocolVersion::MAX_ALLOWED {
2782 let mut config = Self::get_for_version_impl(version - 1, Chain::Unknown);
2783 config.base_tx_cost_fixed = Some(config.base_tx_cost_fixed() + 1000);
2784 return config;
2785 }
2786 }
2787
2788 let mut cfg = Self {
2791 version,
2793
2794 feature_flags: Default::default(),
2796
2797 max_tx_size_bytes: Some(128 * 1024),
2798 max_input_objects: Some(2048),
2800 max_serialized_tx_effects_size_bytes: Some(512 * 1024),
2801 max_serialized_tx_effects_size_bytes_system_tx: Some(512 * 1024 * 16),
2802 max_gas_payment_objects: Some(256),
2803 max_modules_in_publish: Some(128),
2804 max_package_dependencies: None,
2805 max_arguments: Some(512),
2806 max_type_arguments: Some(16),
2807 max_type_argument_depth: Some(16),
2808 max_pure_argument_size: Some(16 * 1024),
2809 max_programmable_tx_commands: Some(1024),
2810 move_binary_format_version: Some(6),
2811 min_move_binary_format_version: None,
2812 binary_module_handles: None,
2813 binary_struct_handles: None,
2814 binary_function_handles: None,
2815 binary_function_instantiations: None,
2816 binary_signatures: None,
2817 binary_constant_pool: None,
2818 binary_identifiers: None,
2819 binary_address_identifiers: None,
2820 binary_struct_defs: None,
2821 binary_struct_def_instantiations: None,
2822 binary_function_defs: None,
2823 binary_field_handles: None,
2824 binary_field_instantiations: None,
2825 binary_friend_decls: None,
2826 binary_enum_defs: None,
2827 binary_enum_def_instantiations: None,
2828 binary_variant_handles: None,
2829 binary_variant_instantiation_handles: None,
2830 max_move_object_size: Some(250 * 1024),
2831 max_move_package_size: Some(100 * 1024),
2832 max_publish_or_upgrade_per_ptb: None,
2833 max_tx_gas: Some(10_000_000_000),
2834 max_gas_price: Some(100_000),
2835 max_gas_price_rgp_factor_for_aborted_transactions: None,
2836 max_gas_computation_bucket: Some(5_000_000),
2837 max_loop_depth: Some(5),
2838 max_generic_instantiation_length: Some(32),
2839 max_function_parameters: Some(128),
2840 max_basic_blocks: Some(1024),
2841 max_value_stack_size: Some(1024),
2842 max_type_nodes: Some(256),
2843 max_push_size: Some(10000),
2844 max_struct_definitions: Some(200),
2845 max_function_definitions: Some(1000),
2846 max_fields_in_struct: Some(32),
2847 max_dependency_depth: Some(100),
2848 max_num_event_emit: Some(256),
2849 max_num_new_move_object_ids: Some(2048),
2850 max_num_new_move_object_ids_system_tx: Some(2048 * 16),
2851 max_num_deleted_move_object_ids: Some(2048),
2852 max_num_deleted_move_object_ids_system_tx: Some(2048 * 16),
2853 max_num_transferred_move_object_ids: Some(2048),
2854 max_num_transferred_move_object_ids_system_tx: Some(2048 * 16),
2855 max_event_emit_size: Some(250 * 1024),
2856 max_move_vector_len: Some(256 * 1024),
2857 max_type_to_layout_nodes: None,
2858 max_ptb_value_size: None,
2859
2860 max_back_edges_per_function: Some(10_000),
2861 max_back_edges_per_module: Some(10_000),
2862 max_verifier_meter_ticks_per_function: Some(6_000_000),
2863 max_meter_ticks_per_module: Some(6_000_000),
2864 max_meter_ticks_per_package: None,
2865
2866 object_runtime_max_num_cached_objects: Some(1000),
2867 object_runtime_max_num_cached_objects_system_tx: Some(1000 * 16),
2868 object_runtime_max_num_store_entries: Some(1000),
2869 object_runtime_max_num_store_entries_system_tx: Some(1000 * 16),
2870 base_tx_cost_fixed: Some(110_000),
2871 package_publish_cost_fixed: Some(1_000),
2872 base_tx_cost_per_byte: Some(0),
2873 package_publish_cost_per_byte: Some(80),
2874 obj_access_cost_read_per_byte: Some(15),
2875 obj_access_cost_mutate_per_byte: Some(40),
2876 obj_access_cost_delete_per_byte: Some(40),
2877 obj_access_cost_verify_per_byte: Some(200),
2878 obj_data_cost_refundable: Some(100),
2879 obj_metadata_cost_non_refundable: Some(50),
2880 gas_model_version: Some(1),
2881 storage_rebate_rate: Some(9900),
2882 storage_fund_reinvest_rate: Some(500),
2883 reward_slashing_rate: Some(5000),
2884 storage_gas_price: Some(1),
2885 accumulator_object_storage_cost: None,
2886 max_transactions_per_checkpoint: Some(10_000),
2887 max_checkpoint_size_bytes: Some(30 * 1024 * 1024),
2888
2889 buffer_stake_for_protocol_upgrade_bps: Some(0),
2892
2893 address_from_bytes_cost_base: Some(52),
2897 address_to_u256_cost_base: Some(52),
2899 address_from_u256_cost_base: Some(52),
2901
2902 config_read_setting_impl_cost_base: None,
2905 config_read_setting_impl_cost_per_byte: None,
2906
2907 dynamic_field_hash_type_and_key_cost_base: Some(100),
2910 dynamic_field_hash_type_and_key_type_cost_per_byte: Some(2),
2911 dynamic_field_hash_type_and_key_value_cost_per_byte: Some(2),
2912 dynamic_field_hash_type_and_key_type_tag_cost_per_byte: Some(2),
2913 dynamic_field_add_child_object_cost_base: Some(100),
2915 dynamic_field_add_child_object_type_cost_per_byte: Some(10),
2916 dynamic_field_add_child_object_value_cost_per_byte: Some(10),
2917 dynamic_field_add_child_object_struct_tag_cost_per_byte: Some(10),
2918 dynamic_field_borrow_child_object_cost_base: Some(100),
2920 dynamic_field_borrow_child_object_child_ref_cost_per_byte: Some(10),
2921 dynamic_field_borrow_child_object_type_cost_per_byte: Some(10),
2922 dynamic_field_remove_child_object_cost_base: Some(100),
2924 dynamic_field_remove_child_object_child_cost_per_byte: Some(2),
2925 dynamic_field_remove_child_object_type_cost_per_byte: Some(2),
2926 dynamic_field_has_child_object_cost_base: Some(100),
2928 dynamic_field_has_child_object_with_ty_cost_base: Some(100),
2930 dynamic_field_has_child_object_with_ty_type_cost_per_byte: Some(2),
2931 dynamic_field_has_child_object_with_ty_type_tag_cost_per_byte: Some(2),
2932
2933 event_emit_cost_base: Some(52),
2936 event_emit_value_size_derivation_cost_per_byte: Some(2),
2937 event_emit_tag_size_derivation_cost_per_byte: Some(5),
2938 event_emit_output_cost_per_byte: Some(10),
2939 event_emit_auth_stream_cost: None,
2940
2941 object_borrow_uid_cost_base: Some(52),
2944 object_delete_impl_cost_base: Some(52),
2946 object_record_new_uid_cost_base: Some(52),
2948
2949 transfer_transfer_internal_cost_base: Some(52),
2952 transfer_party_transfer_internal_cost_base: None,
2954 transfer_freeze_object_cost_base: Some(52),
2956 transfer_share_object_cost_base: Some(52),
2958 transfer_receive_object_cost_base: None,
2959
2960 tx_context_derive_id_cost_base: Some(52),
2963 tx_context_fresh_id_cost_base: None,
2964 tx_context_sender_cost_base: None,
2965 tx_context_epoch_cost_base: None,
2966 tx_context_epoch_timestamp_ms_cost_base: None,
2967 tx_context_sponsor_cost_base: None,
2968 tx_context_rgp_cost_base: None,
2969 tx_context_gas_price_cost_base: None,
2970 tx_context_gas_budget_cost_base: None,
2971 tx_context_ids_created_cost_base: None,
2972 tx_context_replace_cost_base: None,
2973
2974 types_is_one_time_witness_cost_base: Some(52),
2977 types_is_one_time_witness_type_tag_cost_per_byte: Some(2),
2978 types_is_one_time_witness_type_cost_per_byte: Some(2),
2979
2980 validator_validate_metadata_cost_base: Some(52),
2983 validator_validate_metadata_data_cost_per_byte: Some(2),
2984
2985 crypto_invalid_arguments_cost: Some(100),
2987 bls12381_bls12381_min_sig_verify_cost_base: Some(52),
2989 bls12381_bls12381_min_sig_verify_msg_cost_per_byte: Some(2),
2990 bls12381_bls12381_min_sig_verify_msg_cost_per_block: Some(2),
2991
2992 bls12381_bls12381_min_pk_verify_cost_base: Some(52),
2994 bls12381_bls12381_min_pk_verify_msg_cost_per_byte: Some(2),
2995 bls12381_bls12381_min_pk_verify_msg_cost_per_block: Some(2),
2996
2997 ecdsa_k1_ecrecover_keccak256_cost_base: Some(52),
2999 ecdsa_k1_ecrecover_keccak256_msg_cost_per_byte: Some(2),
3000 ecdsa_k1_ecrecover_keccak256_msg_cost_per_block: Some(2),
3001 ecdsa_k1_ecrecover_sha256_cost_base: Some(52),
3002 ecdsa_k1_ecrecover_sha256_msg_cost_per_byte: Some(2),
3003 ecdsa_k1_ecrecover_sha256_msg_cost_per_block: Some(2),
3004
3005 ecdsa_k1_decompress_pubkey_cost_base: Some(52),
3007
3008 ecdsa_k1_secp256k1_verify_keccak256_cost_base: Some(52),
3010 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_byte: Some(2),
3011 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_block: Some(2),
3012 ecdsa_k1_secp256k1_verify_sha256_cost_base: Some(52),
3013 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_byte: Some(2),
3014 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_block: Some(2),
3015
3016 ecdsa_r1_ecrecover_keccak256_cost_base: Some(52),
3018 ecdsa_r1_ecrecover_keccak256_msg_cost_per_byte: Some(2),
3019 ecdsa_r1_ecrecover_keccak256_msg_cost_per_block: Some(2),
3020 ecdsa_r1_ecrecover_sha256_cost_base: Some(52),
3021 ecdsa_r1_ecrecover_sha256_msg_cost_per_byte: Some(2),
3022 ecdsa_r1_ecrecover_sha256_msg_cost_per_block: Some(2),
3023
3024 ecdsa_r1_secp256r1_verify_keccak256_cost_base: Some(52),
3026 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_byte: Some(2),
3027 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_block: Some(2),
3028 ecdsa_r1_secp256r1_verify_sha256_cost_base: Some(52),
3029 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_byte: Some(2),
3030 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_block: Some(2),
3031
3032 ecvrf_ecvrf_verify_cost_base: Some(52),
3034 ecvrf_ecvrf_verify_alpha_string_cost_per_byte: Some(2),
3035 ecvrf_ecvrf_verify_alpha_string_cost_per_block: Some(2),
3036
3037 ed25519_ed25519_verify_cost_base: Some(52),
3039 ed25519_ed25519_verify_msg_cost_per_byte: Some(2),
3040 ed25519_ed25519_verify_msg_cost_per_block: Some(2),
3041
3042 groth16_prepare_verifying_key_bls12381_cost_base: Some(52),
3044 groth16_prepare_verifying_key_bn254_cost_base: Some(52),
3045
3046 groth16_verify_groth16_proof_internal_bls12381_cost_base: Some(52),
3048 groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input: Some(2),
3049 groth16_verify_groth16_proof_internal_bn254_cost_base: Some(52),
3050 groth16_verify_groth16_proof_internal_bn254_cost_per_public_input: Some(2),
3051 groth16_verify_groth16_proof_internal_public_input_cost_per_byte: Some(2),
3052
3053 hash_blake2b256_cost_base: Some(52),
3055 hash_blake2b256_data_cost_per_byte: Some(2),
3056 hash_blake2b256_data_cost_per_block: Some(2),
3057
3058 hash_keccak256_cost_base: Some(52),
3060 hash_keccak256_data_cost_per_byte: Some(2),
3061 hash_keccak256_data_cost_per_block: Some(2),
3062
3063 poseidon_bn254_cost_base: None,
3064 poseidon_bn254_cost_per_block: None,
3065
3066 hmac_hmac_sha3_256_cost_base: Some(52),
3068 hmac_hmac_sha3_256_input_cost_per_byte: Some(2),
3069 hmac_hmac_sha3_256_input_cost_per_block: Some(2),
3070
3071 group_ops_bls12381_decode_scalar_cost: None,
3073 group_ops_bls12381_decode_g1_cost: None,
3074 group_ops_bls12381_decode_g2_cost: None,
3075 group_ops_bls12381_decode_gt_cost: None,
3076 group_ops_bls12381_scalar_add_cost: None,
3077 group_ops_bls12381_g1_add_cost: None,
3078 group_ops_bls12381_g2_add_cost: None,
3079 group_ops_bls12381_gt_add_cost: None,
3080 group_ops_bls12381_scalar_sub_cost: None,
3081 group_ops_bls12381_g1_sub_cost: None,
3082 group_ops_bls12381_g2_sub_cost: None,
3083 group_ops_bls12381_gt_sub_cost: None,
3084 group_ops_bls12381_scalar_mul_cost: None,
3085 group_ops_bls12381_g1_mul_cost: None,
3086 group_ops_bls12381_g2_mul_cost: None,
3087 group_ops_bls12381_gt_mul_cost: None,
3088 group_ops_bls12381_scalar_div_cost: None,
3089 group_ops_bls12381_g1_div_cost: None,
3090 group_ops_bls12381_g2_div_cost: None,
3091 group_ops_bls12381_gt_div_cost: None,
3092 group_ops_bls12381_g1_hash_to_base_cost: None,
3093 group_ops_bls12381_g2_hash_to_base_cost: None,
3094 group_ops_bls12381_g1_hash_to_cost_per_byte: None,
3095 group_ops_bls12381_g2_hash_to_cost_per_byte: None,
3096 group_ops_bls12381_g1_msm_base_cost: None,
3097 group_ops_bls12381_g2_msm_base_cost: None,
3098 group_ops_bls12381_g1_msm_base_cost_per_input: None,
3099 group_ops_bls12381_g2_msm_base_cost_per_input: None,
3100 group_ops_bls12381_msm_max_len: None,
3101 group_ops_bls12381_pairing_cost: None,
3102 group_ops_bls12381_g1_to_uncompressed_g1_cost: None,
3103 group_ops_bls12381_uncompressed_g1_to_g1_cost: None,
3104 group_ops_bls12381_uncompressed_g1_sum_base_cost: None,
3105 group_ops_bls12381_uncompressed_g1_sum_cost_per_term: None,
3106 group_ops_bls12381_uncompressed_g1_sum_max_terms: None,
3107
3108 group_ops_ristretto_decode_scalar_cost: None,
3109 group_ops_ristretto_decode_point_cost: None,
3110 group_ops_ristretto_scalar_add_cost: None,
3111 group_ops_ristretto_point_add_cost: None,
3112 group_ops_ristretto_scalar_sub_cost: None,
3113 group_ops_ristretto_point_sub_cost: None,
3114 group_ops_ristretto_scalar_mul_cost: None,
3115 group_ops_ristretto_point_mul_cost: None,
3116 group_ops_ristretto_scalar_div_cost: None,
3117 group_ops_ristretto_point_div_cost: None,
3118
3119 check_zklogin_id_cost_base: None,
3121 check_zklogin_issuer_cost_base: None,
3123
3124 vdf_verify_vdf_cost: None,
3125 vdf_hash_to_input_cost: None,
3126
3127 nitro_attestation_parse_base_cost: None,
3129 nitro_attestation_parse_cost_per_byte: None,
3130 nitro_attestation_verify_base_cost: None,
3131 nitro_attestation_verify_cost_per_cert: None,
3132
3133 bcs_per_byte_serialized_cost: None,
3134 bcs_legacy_min_output_size_cost: None,
3135 bcs_failure_cost: None,
3136 hash_sha2_256_base_cost: None,
3137 hash_sha2_256_per_byte_cost: None,
3138 hash_sha2_256_legacy_min_input_len_cost: None,
3139 hash_sha3_256_base_cost: None,
3140 hash_sha3_256_per_byte_cost: None,
3141 hash_sha3_256_legacy_min_input_len_cost: None,
3142 type_name_get_base_cost: None,
3143 type_name_get_per_byte_cost: None,
3144 type_name_id_base_cost: None,
3145 string_check_utf8_base_cost: None,
3146 string_check_utf8_per_byte_cost: None,
3147 string_is_char_boundary_base_cost: None,
3148 string_sub_string_base_cost: None,
3149 string_sub_string_per_byte_cost: None,
3150 string_index_of_base_cost: None,
3151 string_index_of_per_byte_pattern_cost: None,
3152 string_index_of_per_byte_searched_cost: None,
3153 vector_empty_base_cost: None,
3154 vector_length_base_cost: None,
3155 vector_push_back_base_cost: None,
3156 vector_push_back_legacy_per_abstract_memory_unit_cost: None,
3157 vector_borrow_base_cost: None,
3158 vector_pop_back_base_cost: None,
3159 vector_destroy_empty_base_cost: None,
3160 vector_swap_base_cost: None,
3161 debug_print_base_cost: None,
3162 debug_print_stack_trace_base_cost: None,
3163
3164 max_size_written_objects: None,
3165 max_size_written_objects_system_tx: None,
3166
3167 max_move_identifier_len: None,
3174 max_move_value_depth: None,
3175 max_move_enum_variants: None,
3176
3177 gas_rounding_step: None,
3178
3179 execution_version: None,
3180
3181 max_event_emit_size_total: None,
3182
3183 consensus_bad_nodes_stake_threshold: None,
3184
3185 max_jwk_votes_per_validator_per_epoch: None,
3186
3187 max_age_of_jwk_in_epochs: None,
3188
3189 random_beacon_reduction_allowed_delta: None,
3190
3191 random_beacon_reduction_lower_bound: None,
3192
3193 random_beacon_dkg_timeout_round: None,
3194
3195 random_beacon_min_round_interval_ms: None,
3196
3197 random_beacon_dkg_version: None,
3198
3199 consensus_max_transaction_size_bytes: None,
3200
3201 consensus_max_transactions_in_block_bytes: None,
3202
3203 consensus_max_num_transactions_in_block: None,
3204
3205 consensus_voting_rounds: None,
3206
3207 max_accumulated_txn_cost_per_object_in_narwhal_commit: None,
3208
3209 max_deferral_rounds_for_congestion_control: None,
3210
3211 max_txn_cost_overage_per_object_in_commit: None,
3212
3213 allowed_txn_cost_overage_burst_per_object_in_commit: None,
3214
3215 min_checkpoint_interval_ms: None,
3216
3217 checkpoint_summary_version_specific_data: None,
3218
3219 max_soft_bundle_size: None,
3220
3221 bridge_should_try_to_finalize_committee: None,
3222
3223 max_accumulated_txn_cost_per_object_in_mysticeti_commit: None,
3224
3225 max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit: None,
3226
3227 consensus_gc_depth: None,
3228
3229 gas_budget_based_txn_cost_cap_factor: None,
3230
3231 gas_budget_based_txn_cost_absolute_cap_commit_count: None,
3232
3233 sip_45_consensus_amplification_threshold: None,
3234
3235 use_object_per_epoch_marker_table_v2: None,
3236
3237 consensus_commit_rate_estimation_window_size: None,
3238
3239 aliased_addresses: vec![],
3240
3241 translation_per_command_base_charge: None,
3242 translation_per_input_base_charge: None,
3243 translation_pure_input_per_byte_charge: None,
3244 translation_per_type_node_charge: None,
3245 translation_per_reference_node_charge: None,
3246 translation_per_linkage_entry_charge: None,
3247
3248 max_updates_per_settlement_txn: None,
3249 };
3252 for cur in 2..=version.0 {
3253 match cur {
3254 1 => unreachable!(),
3255 2 => {
3256 cfg.feature_flags.advance_epoch_start_time_in_safe_mode = true;
3257 }
3258 3 => {
3259 cfg.gas_model_version = Some(2);
3261 cfg.max_tx_gas = Some(50_000_000_000);
3263 cfg.base_tx_cost_fixed = Some(2_000);
3265 cfg.storage_gas_price = Some(76);
3267 cfg.feature_flags.loaded_child_objects_fixed = true;
3268 cfg.max_size_written_objects = Some(5 * 1000 * 1000);
3271 cfg.max_size_written_objects_system_tx = Some(50 * 1000 * 1000);
3274 cfg.feature_flags.package_upgrades = true;
3275 }
3276 4 => {
3281 cfg.reward_slashing_rate = Some(10000);
3283 cfg.gas_model_version = Some(3);
3285 }
3286 5 => {
3287 cfg.feature_flags.missing_type_is_compatibility_error = true;
3288 cfg.gas_model_version = Some(4);
3289 cfg.feature_flags.scoring_decision_with_validity_cutoff = true;
3290 }
3294 6 => {
3295 cfg.gas_model_version = Some(5);
3296 cfg.buffer_stake_for_protocol_upgrade_bps = Some(5000);
3297 cfg.feature_flags.consensus_order_end_of_epoch_last = true;
3298 }
3299 7 => {
3300 cfg.feature_flags.disallow_adding_abilities_on_upgrade = true;
3301 cfg.feature_flags
3302 .disable_invariant_violation_check_in_swap_loc = true;
3303 cfg.feature_flags.ban_entry_init = true;
3304 cfg.feature_flags.package_digest_hash_module = true;
3305 }
3306 8 => {
3307 cfg.feature_flags
3308 .disallow_change_struct_type_params_on_upgrade = true;
3309 }
3310 9 => {
3311 cfg.max_move_identifier_len = Some(128);
3313 cfg.feature_flags.no_extraneous_module_bytes = true;
3314 cfg.feature_flags
3315 .advance_to_highest_supported_protocol_version = true;
3316 }
3317 10 => {
3318 cfg.max_verifier_meter_ticks_per_function = Some(16_000_000);
3319 cfg.max_meter_ticks_per_module = Some(16_000_000);
3320 }
3321 11 => {
3322 cfg.max_move_value_depth = Some(128);
3323 }
3324 12 => {
3325 cfg.feature_flags.narwhal_versioned_metadata = true;
3326 if chain != Chain::Mainnet {
3327 cfg.feature_flags.commit_root_state_digest = true;
3328 }
3329
3330 if chain != Chain::Mainnet && chain != Chain::Testnet {
3331 cfg.feature_flags.zklogin_auth = true;
3332 }
3333 }
3334 13 => {}
3335 14 => {
3336 cfg.gas_rounding_step = Some(1_000);
3337 cfg.gas_model_version = Some(6);
3338 }
3339 15 => {
3340 cfg.feature_flags.consensus_transaction_ordering =
3341 ConsensusTransactionOrdering::ByGasPrice;
3342 }
3343 16 => {
3344 cfg.feature_flags.simplified_unwrap_then_delete = true;
3345 }
3346 17 => {
3347 cfg.feature_flags.upgraded_multisig_supported = true;
3348 }
3349 18 => {
3350 cfg.execution_version = Some(1);
3351 cfg.feature_flags.txn_base_cost_as_multiplier = true;
3360 cfg.base_tx_cost_fixed = Some(1_000);
3362 }
3363 19 => {
3364 cfg.max_num_event_emit = Some(1024);
3365 cfg.max_event_emit_size_total = Some(
3368 256 * 250 * 1024, );
3370 }
3371 20 => {
3372 cfg.feature_flags.commit_root_state_digest = true;
3373
3374 if chain != Chain::Mainnet {
3375 cfg.feature_flags.narwhal_new_leader_election_schedule = true;
3376 cfg.consensus_bad_nodes_stake_threshold = Some(20);
3377 }
3378 }
3379
3380 21 => {
3381 if chain != Chain::Mainnet {
3382 cfg.feature_flags.zklogin_supported_providers = BTreeSet::from([
3383 "Google".to_string(),
3384 "Facebook".to_string(),
3385 "Twitch".to_string(),
3386 ]);
3387 }
3388 }
3389 22 => {
3390 cfg.feature_flags.loaded_child_object_format = true;
3391 }
3392 23 => {
3393 cfg.feature_flags.loaded_child_object_format_type = true;
3394 cfg.feature_flags.narwhal_new_leader_election_schedule = true;
3395 cfg.consensus_bad_nodes_stake_threshold = Some(20);
3401 }
3402 24 => {
3403 cfg.feature_flags.simple_conservation_checks = true;
3404 cfg.max_publish_or_upgrade_per_ptb = Some(5);
3405
3406 cfg.feature_flags.end_of_epoch_transaction_supported = true;
3407
3408 if chain != Chain::Mainnet {
3409 cfg.feature_flags.enable_jwk_consensus_updates = true;
3410 cfg.max_jwk_votes_per_validator_per_epoch = Some(240);
3412 cfg.max_age_of_jwk_in_epochs = Some(1);
3413 }
3414 }
3415 25 => {
3416 cfg.feature_flags.zklogin_supported_providers = BTreeSet::from([
3418 "Google".to_string(),
3419 "Facebook".to_string(),
3420 "Twitch".to_string(),
3421 ]);
3422 cfg.feature_flags.zklogin_auth = true;
3423
3424 cfg.feature_flags.enable_jwk_consensus_updates = true;
3426 cfg.max_jwk_votes_per_validator_per_epoch = Some(240);
3427 cfg.max_age_of_jwk_in_epochs = Some(1);
3428 }
3429 26 => {
3430 cfg.gas_model_version = Some(7);
3431 if chain != Chain::Mainnet && chain != Chain::Testnet {
3433 cfg.transfer_receive_object_cost_base = Some(52);
3434 cfg.feature_flags.receive_objects = true;
3435 }
3436 }
3437 27 => {
3438 cfg.gas_model_version = Some(8);
3439 }
3440 28 => {
3441 cfg.check_zklogin_id_cost_base = Some(200);
3443 cfg.check_zklogin_issuer_cost_base = Some(200);
3445
3446 if chain != Chain::Mainnet && chain != Chain::Testnet {
3448 cfg.feature_flags.enable_effects_v2 = true;
3449 }
3450 }
3451 29 => {
3452 cfg.feature_flags.verify_legacy_zklogin_address = true;
3453 }
3454 30 => {
3455 if chain != Chain::Mainnet {
3457 cfg.feature_flags.narwhal_certificate_v2 = true;
3458 }
3459
3460 cfg.random_beacon_reduction_allowed_delta = Some(800);
3461 if chain != Chain::Mainnet {
3463 cfg.feature_flags.enable_effects_v2 = true;
3464 }
3465
3466 cfg.feature_flags.zklogin_supported_providers = BTreeSet::default();
3470
3471 cfg.feature_flags.recompute_has_public_transfer_in_execution = true;
3472 }
3473 31 => {
3474 cfg.execution_version = Some(2);
3475 if chain != Chain::Mainnet && chain != Chain::Testnet {
3477 cfg.feature_flags.shared_object_deletion = true;
3478 }
3479 }
3480 32 => {
3481 if chain != Chain::Mainnet {
3483 cfg.feature_flags.accept_zklogin_in_multisig = true;
3484 }
3485 if chain != Chain::Mainnet {
3487 cfg.transfer_receive_object_cost_base = Some(52);
3488 cfg.feature_flags.receive_objects = true;
3489 }
3490 if chain != Chain::Mainnet && chain != Chain::Testnet {
3492 cfg.feature_flags.random_beacon = true;
3493 cfg.random_beacon_reduction_lower_bound = Some(1600);
3494 cfg.random_beacon_dkg_timeout_round = Some(3000);
3495 cfg.random_beacon_min_round_interval_ms = Some(150);
3496 }
3497 if chain != Chain::Testnet && chain != Chain::Mainnet {
3499 cfg.feature_flags.include_consensus_digest_in_prologue = true;
3500 }
3501
3502 cfg.feature_flags.narwhal_certificate_v2 = true;
3504 }
3505 33 => {
3506 cfg.feature_flags.hardened_otw_check = true;
3507 cfg.feature_flags.allow_receiving_object_id = true;
3508
3509 cfg.transfer_receive_object_cost_base = Some(52);
3511 cfg.feature_flags.receive_objects = true;
3512
3513 if chain != Chain::Mainnet {
3515 cfg.feature_flags.shared_object_deletion = true;
3516 }
3517
3518 cfg.feature_flags.enable_effects_v2 = true;
3519 }
3520 34 => {}
3521 35 => {
3522 if chain != Chain::Mainnet && chain != Chain::Testnet {
3524 cfg.feature_flags.enable_poseidon = true;
3525 cfg.poseidon_bn254_cost_base = Some(260);
3526 cfg.poseidon_bn254_cost_per_block = Some(10);
3527 }
3528
3529 cfg.feature_flags.enable_coin_deny_list = true;
3530 }
3531 36 => {
3532 if chain != Chain::Mainnet && chain != Chain::Testnet {
3534 cfg.feature_flags.enable_group_ops_native_functions = true;
3535 cfg.feature_flags.enable_group_ops_native_function_msm = true;
3536 cfg.group_ops_bls12381_decode_scalar_cost = Some(52);
3538 cfg.group_ops_bls12381_decode_g1_cost = Some(52);
3539 cfg.group_ops_bls12381_decode_g2_cost = Some(52);
3540 cfg.group_ops_bls12381_decode_gt_cost = Some(52);
3541 cfg.group_ops_bls12381_scalar_add_cost = Some(52);
3542 cfg.group_ops_bls12381_g1_add_cost = Some(52);
3543 cfg.group_ops_bls12381_g2_add_cost = Some(52);
3544 cfg.group_ops_bls12381_gt_add_cost = Some(52);
3545 cfg.group_ops_bls12381_scalar_sub_cost = Some(52);
3546 cfg.group_ops_bls12381_g1_sub_cost = Some(52);
3547 cfg.group_ops_bls12381_g2_sub_cost = Some(52);
3548 cfg.group_ops_bls12381_gt_sub_cost = Some(52);
3549 cfg.group_ops_bls12381_scalar_mul_cost = Some(52);
3550 cfg.group_ops_bls12381_g1_mul_cost = Some(52);
3551 cfg.group_ops_bls12381_g2_mul_cost = Some(52);
3552 cfg.group_ops_bls12381_gt_mul_cost = Some(52);
3553 cfg.group_ops_bls12381_scalar_div_cost = Some(52);
3554 cfg.group_ops_bls12381_g1_div_cost = Some(52);
3555 cfg.group_ops_bls12381_g2_div_cost = Some(52);
3556 cfg.group_ops_bls12381_gt_div_cost = Some(52);
3557 cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(52);
3558 cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(52);
3559 cfg.group_ops_bls12381_g1_hash_to_cost_per_byte = Some(2);
3560 cfg.group_ops_bls12381_g2_hash_to_cost_per_byte = Some(2);
3561 cfg.group_ops_bls12381_g1_msm_base_cost = Some(52);
3562 cfg.group_ops_bls12381_g2_msm_base_cost = Some(52);
3563 cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(52);
3564 cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(52);
3565 cfg.group_ops_bls12381_msm_max_len = Some(32);
3566 cfg.group_ops_bls12381_pairing_cost = Some(52);
3567 }
3568 cfg.feature_flags.shared_object_deletion = true;
3570
3571 cfg.consensus_max_transaction_size_bytes = Some(256 * 1024); cfg.consensus_max_transactions_in_block_bytes = Some(6 * 1_024 * 1024);
3573 }
3575 37 => {
3576 cfg.feature_flags.reject_mutable_random_on_entry_functions = true;
3577
3578 if chain != Chain::Mainnet {
3580 cfg.feature_flags.include_consensus_digest_in_prologue = true;
3581 }
3582 }
3583 38 => {
3584 cfg.binary_module_handles = Some(100);
3585 cfg.binary_struct_handles = Some(300);
3586 cfg.binary_function_handles = Some(1500);
3587 cfg.binary_function_instantiations = Some(750);
3588 cfg.binary_signatures = Some(1000);
3589 cfg.binary_constant_pool = Some(4000);
3593 cfg.binary_identifiers = Some(10000);
3594 cfg.binary_address_identifiers = Some(100);
3595 cfg.binary_struct_defs = Some(200);
3596 cfg.binary_struct_def_instantiations = Some(100);
3597 cfg.binary_function_defs = Some(1000);
3598 cfg.binary_field_handles = Some(500);
3599 cfg.binary_field_instantiations = Some(250);
3600 cfg.binary_friend_decls = Some(100);
3601 cfg.max_package_dependencies = Some(32);
3603 cfg.max_modules_in_publish = Some(64);
3604 cfg.execution_version = Some(3);
3606 }
3607 39 => {
3608 }
3610 40 => {}
3611 41 => {
3612 cfg.feature_flags.enable_group_ops_native_functions = true;
3614 cfg.group_ops_bls12381_decode_scalar_cost = Some(52);
3616 cfg.group_ops_bls12381_decode_g1_cost = Some(52);
3617 cfg.group_ops_bls12381_decode_g2_cost = Some(52);
3618 cfg.group_ops_bls12381_decode_gt_cost = Some(52);
3619 cfg.group_ops_bls12381_scalar_add_cost = Some(52);
3620 cfg.group_ops_bls12381_g1_add_cost = Some(52);
3621 cfg.group_ops_bls12381_g2_add_cost = Some(52);
3622 cfg.group_ops_bls12381_gt_add_cost = Some(52);
3623 cfg.group_ops_bls12381_scalar_sub_cost = Some(52);
3624 cfg.group_ops_bls12381_g1_sub_cost = Some(52);
3625 cfg.group_ops_bls12381_g2_sub_cost = Some(52);
3626 cfg.group_ops_bls12381_gt_sub_cost = Some(52);
3627 cfg.group_ops_bls12381_scalar_mul_cost = Some(52);
3628 cfg.group_ops_bls12381_g1_mul_cost = Some(52);
3629 cfg.group_ops_bls12381_g2_mul_cost = Some(52);
3630 cfg.group_ops_bls12381_gt_mul_cost = Some(52);
3631 cfg.group_ops_bls12381_scalar_div_cost = Some(52);
3632 cfg.group_ops_bls12381_g1_div_cost = Some(52);
3633 cfg.group_ops_bls12381_g2_div_cost = Some(52);
3634 cfg.group_ops_bls12381_gt_div_cost = Some(52);
3635 cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(52);
3636 cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(52);
3637 cfg.group_ops_bls12381_g1_hash_to_cost_per_byte = Some(2);
3638 cfg.group_ops_bls12381_g2_hash_to_cost_per_byte = Some(2);
3639 cfg.group_ops_bls12381_g1_msm_base_cost = Some(52);
3640 cfg.group_ops_bls12381_g2_msm_base_cost = Some(52);
3641 cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(52);
3642 cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(52);
3643 cfg.group_ops_bls12381_msm_max_len = Some(32);
3644 cfg.group_ops_bls12381_pairing_cost = Some(52);
3645 }
3646 42 => {}
3647 43 => {
3648 cfg.feature_flags.zklogin_max_epoch_upper_bound_delta = Some(30);
3649 cfg.max_meter_ticks_per_package = Some(16_000_000);
3650 }
3651 44 => {
3652 cfg.feature_flags.include_consensus_digest_in_prologue = true;
3654 if chain != Chain::Mainnet {
3656 cfg.feature_flags.consensus_choice = ConsensusChoice::SwapEachEpoch;
3657 }
3658 }
3659 45 => {
3660 if chain != Chain::Testnet && chain != Chain::Mainnet {
3662 cfg.feature_flags.consensus_network = ConsensusNetwork::Tonic;
3663 }
3664
3665 if chain != Chain::Mainnet {
3666 cfg.feature_flags.mysticeti_leader_scoring_and_schedule = true;
3668 }
3669 cfg.min_move_binary_format_version = Some(6);
3670 cfg.feature_flags.accept_zklogin_in_multisig = true;
3671
3672 if chain != Chain::Mainnet && chain != Chain::Testnet {
3676 cfg.feature_flags.bridge = true;
3677 }
3678 }
3679 46 => {
3680 if chain != Chain::Mainnet {
3682 cfg.feature_flags.bridge = true;
3683 }
3684
3685 cfg.feature_flags.reshare_at_same_initial_version = true;
3687 }
3688 47 => {}
3689 48 => {
3690 cfg.feature_flags.consensus_network = ConsensusNetwork::Tonic;
3692
3693 cfg.feature_flags.resolve_abort_locations_to_package_id = true;
3695
3696 if chain != Chain::Mainnet {
3698 cfg.feature_flags.random_beacon = true;
3699 cfg.random_beacon_reduction_lower_bound = Some(1600);
3700 cfg.random_beacon_dkg_timeout_round = Some(3000);
3701 cfg.random_beacon_min_round_interval_ms = Some(200);
3702 }
3703
3704 cfg.feature_flags.mysticeti_use_committed_subdag_digest = true;
3706 }
3707 49 => {
3708 if chain != Chain::Testnet && chain != Chain::Mainnet {
3709 cfg.move_binary_format_version = Some(7);
3710 }
3711
3712 if chain != Chain::Mainnet && chain != Chain::Testnet {
3714 cfg.feature_flags.enable_vdf = true;
3715 cfg.vdf_verify_vdf_cost = Some(1500);
3718 cfg.vdf_hash_to_input_cost = Some(100);
3719 }
3720
3721 if chain != Chain::Testnet && chain != Chain::Mainnet {
3723 cfg.feature_flags
3724 .record_consensus_determined_version_assignments_in_prologue = true;
3725 }
3726
3727 if chain != Chain::Mainnet {
3729 cfg.feature_flags.consensus_choice = ConsensusChoice::Mysticeti;
3730 }
3731
3732 cfg.feature_flags.fresh_vm_on_framework_upgrade = true;
3734 }
3735 50 => {
3736 if chain != Chain::Mainnet {
3738 cfg.checkpoint_summary_version_specific_data = Some(1);
3739 cfg.min_checkpoint_interval_ms = Some(200);
3740 }
3741
3742 if chain != Chain::Testnet && chain != Chain::Mainnet {
3744 cfg.feature_flags
3745 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = true;
3746 }
3747
3748 cfg.feature_flags.mysticeti_num_leaders_per_round = Some(1);
3749
3750 cfg.max_deferral_rounds_for_congestion_control = Some(10);
3752 }
3753 51 => {
3754 cfg.random_beacon_dkg_version = Some(1);
3755
3756 if chain != Chain::Testnet && chain != Chain::Mainnet {
3757 cfg.feature_flags.enable_coin_deny_list_v2 = true;
3758 }
3759 }
3760 52 => {
3761 if chain != Chain::Mainnet {
3762 cfg.feature_flags.soft_bundle = true;
3763 cfg.max_soft_bundle_size = Some(5);
3764 }
3765
3766 cfg.config_read_setting_impl_cost_base = Some(100);
3767 cfg.config_read_setting_impl_cost_per_byte = Some(40);
3768
3769 if chain != Chain::Testnet && chain != Chain::Mainnet {
3771 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(100);
3772 cfg.feature_flags.per_object_congestion_control_mode =
3773 PerObjectCongestionControlMode::TotalTxCount;
3774 }
3775
3776 cfg.feature_flags.consensus_choice = ConsensusChoice::Mysticeti;
3778
3779 cfg.feature_flags.mysticeti_leader_scoring_and_schedule = true;
3781
3782 cfg.checkpoint_summary_version_specific_data = Some(1);
3784 cfg.min_checkpoint_interval_ms = Some(200);
3785
3786 if chain != Chain::Mainnet {
3788 cfg.feature_flags
3789 .record_consensus_determined_version_assignments_in_prologue = true;
3790 cfg.feature_flags
3791 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = true;
3792 }
3793 if chain != Chain::Mainnet {
3795 cfg.move_binary_format_version = Some(7);
3796 }
3797
3798 if chain != Chain::Testnet && chain != Chain::Mainnet {
3799 cfg.feature_flags.passkey_auth = true;
3800 }
3801 cfg.feature_flags.enable_coin_deny_list_v2 = true;
3802 }
3803 53 => {
3804 cfg.bridge_should_try_to_finalize_committee = Some(chain != Chain::Mainnet);
3806
3807 cfg.feature_flags
3809 .record_consensus_determined_version_assignments_in_prologue = true;
3810 cfg.feature_flags
3811 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = true;
3812
3813 if chain == Chain::Unknown {
3814 cfg.feature_flags.authority_capabilities_v2 = true;
3815 }
3816
3817 if chain != Chain::Mainnet {
3819 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(100);
3820 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(10);
3821 cfg.feature_flags.per_object_congestion_control_mode =
3822 PerObjectCongestionControlMode::TotalTxCount;
3823 }
3824
3825 cfg.bcs_per_byte_serialized_cost = Some(2);
3827 cfg.bcs_legacy_min_output_size_cost = Some(1);
3828 cfg.bcs_failure_cost = Some(52);
3829 cfg.debug_print_base_cost = Some(52);
3830 cfg.debug_print_stack_trace_base_cost = Some(52);
3831 cfg.hash_sha2_256_base_cost = Some(52);
3832 cfg.hash_sha2_256_per_byte_cost = Some(2);
3833 cfg.hash_sha2_256_legacy_min_input_len_cost = Some(1);
3834 cfg.hash_sha3_256_base_cost = Some(52);
3835 cfg.hash_sha3_256_per_byte_cost = Some(2);
3836 cfg.hash_sha3_256_legacy_min_input_len_cost = Some(1);
3837 cfg.type_name_get_base_cost = Some(52);
3838 cfg.type_name_get_per_byte_cost = Some(2);
3839 cfg.string_check_utf8_base_cost = Some(52);
3840 cfg.string_check_utf8_per_byte_cost = Some(2);
3841 cfg.string_is_char_boundary_base_cost = Some(52);
3842 cfg.string_sub_string_base_cost = Some(52);
3843 cfg.string_sub_string_per_byte_cost = Some(2);
3844 cfg.string_index_of_base_cost = Some(52);
3845 cfg.string_index_of_per_byte_pattern_cost = Some(2);
3846 cfg.string_index_of_per_byte_searched_cost = Some(2);
3847 cfg.vector_empty_base_cost = Some(52);
3848 cfg.vector_length_base_cost = Some(52);
3849 cfg.vector_push_back_base_cost = Some(52);
3850 cfg.vector_push_back_legacy_per_abstract_memory_unit_cost = Some(2);
3851 cfg.vector_borrow_base_cost = Some(52);
3852 cfg.vector_pop_back_base_cost = Some(52);
3853 cfg.vector_destroy_empty_base_cost = Some(52);
3854 cfg.vector_swap_base_cost = Some(52);
3855 }
3856 54 => {
3857 cfg.feature_flags.random_beacon = true;
3859 cfg.random_beacon_reduction_lower_bound = Some(1000);
3860 cfg.random_beacon_dkg_timeout_round = Some(3000);
3861 cfg.random_beacon_min_round_interval_ms = Some(500);
3862
3863 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(100);
3865 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(10);
3866 cfg.feature_flags.per_object_congestion_control_mode =
3867 PerObjectCongestionControlMode::TotalTxCount;
3868
3869 cfg.feature_flags.soft_bundle = true;
3871 cfg.max_soft_bundle_size = Some(5);
3872 }
3873 55 => {
3874 cfg.move_binary_format_version = Some(7);
3876
3877 cfg.consensus_max_transactions_in_block_bytes = Some(512 * 1024);
3879 cfg.consensus_max_num_transactions_in_block = Some(512);
3882
3883 cfg.feature_flags.rethrow_serialization_type_layout_errors = true;
3884 }
3885 56 => {
3886 if chain == Chain::Mainnet {
3887 cfg.feature_flags.bridge = true;
3888 }
3889 }
3890 57 => {
3891 cfg.random_beacon_reduction_lower_bound = Some(800);
3893 }
3894 58 => {
3895 if chain == Chain::Mainnet {
3896 cfg.bridge_should_try_to_finalize_committee = Some(true);
3897 }
3898
3899 if chain != Chain::Mainnet && chain != Chain::Testnet {
3900 cfg.feature_flags
3902 .consensus_distributed_vote_scoring_strategy = true;
3903 }
3904 }
3905 59 => {
3906 cfg.feature_flags.consensus_round_prober = true;
3908 }
3909 60 => {
3910 cfg.max_type_to_layout_nodes = Some(512);
3911 cfg.feature_flags.validate_identifier_inputs = true;
3912 }
3913 61 => {
3914 if chain != Chain::Mainnet {
3915 cfg.feature_flags
3917 .consensus_distributed_vote_scoring_strategy = true;
3918 }
3919 cfg.random_beacon_reduction_lower_bound = Some(700);
3921
3922 if chain != Chain::Mainnet && chain != Chain::Testnet {
3923 cfg.feature_flags.mysticeti_fastpath = true;
3925 }
3926 }
3927 62 => {
3928 cfg.feature_flags.relocate_event_module = true;
3929 }
3930 63 => {
3931 cfg.feature_flags.per_object_congestion_control_mode =
3932 PerObjectCongestionControlMode::TotalGasBudgetWithCap;
3933 cfg.gas_budget_based_txn_cost_cap_factor = Some(400_000);
3934 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(18_500_000);
3935 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(240_000_000);
3936 }
3937 64 => {
3938 cfg.feature_flags.per_object_congestion_control_mode =
3939 PerObjectCongestionControlMode::TotalTxCount;
3940 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(40);
3941 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(3);
3942 }
3943 65 => {
3944 cfg.feature_flags
3946 .consensus_distributed_vote_scoring_strategy = true;
3947 }
3948 66 => {
3949 if chain == Chain::Mainnet {
3950 cfg.feature_flags
3952 .consensus_distributed_vote_scoring_strategy = false;
3953 }
3954 }
3955 67 => {
3956 cfg.feature_flags
3958 .consensus_distributed_vote_scoring_strategy = true;
3959 }
3960 68 => {
3961 cfg.group_ops_bls12381_g1_to_uncompressed_g1_cost = Some(26);
3962 cfg.group_ops_bls12381_uncompressed_g1_to_g1_cost = Some(52);
3963 cfg.group_ops_bls12381_uncompressed_g1_sum_base_cost = Some(26);
3964 cfg.group_ops_bls12381_uncompressed_g1_sum_cost_per_term = Some(13);
3965 cfg.group_ops_bls12381_uncompressed_g1_sum_max_terms = Some(2000);
3966
3967 if chain != Chain::Mainnet && chain != Chain::Testnet {
3968 cfg.feature_flags.uncompressed_g1_group_elements = true;
3969 }
3970
3971 cfg.feature_flags.per_object_congestion_control_mode =
3972 PerObjectCongestionControlMode::TotalGasBudgetWithCap;
3973 cfg.gas_budget_based_txn_cost_cap_factor = Some(400_000);
3974 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(18_500_000);
3975 cfg.max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit =
3976 Some(3_700_000); cfg.max_txn_cost_overage_per_object_in_commit = Some(u64::MAX);
3978 cfg.gas_budget_based_txn_cost_absolute_cap_commit_count = Some(50);
3979
3980 cfg.random_beacon_reduction_lower_bound = Some(500);
3982
3983 cfg.feature_flags.disallow_new_modules_in_deps_only_packages = true;
3984 }
3985 69 => {
3986 cfg.consensus_voting_rounds = Some(40);
3988
3989 if chain != Chain::Mainnet && chain != Chain::Testnet {
3990 cfg.feature_flags.consensus_smart_ancestor_selection = true;
3992 }
3993
3994 if chain != Chain::Mainnet {
3995 cfg.feature_flags.uncompressed_g1_group_elements = true;
3996 }
3997 }
3998 70 => {
3999 if chain != Chain::Mainnet {
4000 cfg.feature_flags.consensus_smart_ancestor_selection = true;
4002 cfg.feature_flags
4004 .consensus_round_prober_probe_accepted_rounds = true;
4005 }
4006
4007 cfg.poseidon_bn254_cost_per_block = Some(388);
4008
4009 cfg.gas_model_version = Some(9);
4010 cfg.feature_flags.native_charging_v2 = true;
4011 cfg.bls12381_bls12381_min_sig_verify_cost_base = Some(44064);
4012 cfg.bls12381_bls12381_min_pk_verify_cost_base = Some(49282);
4013 cfg.ecdsa_k1_secp256k1_verify_keccak256_cost_base = Some(1470);
4014 cfg.ecdsa_k1_secp256k1_verify_sha256_cost_base = Some(1470);
4015 cfg.ecdsa_r1_secp256r1_verify_sha256_cost_base = Some(4225);
4016 cfg.ecdsa_r1_secp256r1_verify_keccak256_cost_base = Some(4225);
4017 cfg.ecvrf_ecvrf_verify_cost_base = Some(4848);
4018 cfg.ed25519_ed25519_verify_cost_base = Some(1802);
4019
4020 cfg.ecdsa_r1_ecrecover_keccak256_cost_base = Some(1173);
4022 cfg.ecdsa_r1_ecrecover_sha256_cost_base = Some(1173);
4023 cfg.ecdsa_k1_ecrecover_keccak256_cost_base = Some(500);
4024 cfg.ecdsa_k1_ecrecover_sha256_cost_base = Some(500);
4025
4026 cfg.groth16_prepare_verifying_key_bls12381_cost_base = Some(53838);
4027 cfg.groth16_prepare_verifying_key_bn254_cost_base = Some(82010);
4028 cfg.groth16_verify_groth16_proof_internal_bls12381_cost_base = Some(72090);
4029 cfg.groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input =
4030 Some(8213);
4031 cfg.groth16_verify_groth16_proof_internal_bn254_cost_base = Some(115502);
4032 cfg.groth16_verify_groth16_proof_internal_bn254_cost_per_public_input =
4033 Some(9484);
4034
4035 cfg.hash_keccak256_cost_base = Some(10);
4036 cfg.hash_blake2b256_cost_base = Some(10);
4037
4038 cfg.group_ops_bls12381_decode_scalar_cost = Some(7);
4040 cfg.group_ops_bls12381_decode_g1_cost = Some(2848);
4041 cfg.group_ops_bls12381_decode_g2_cost = Some(3770);
4042 cfg.group_ops_bls12381_decode_gt_cost = Some(3068);
4043
4044 cfg.group_ops_bls12381_scalar_add_cost = Some(10);
4045 cfg.group_ops_bls12381_g1_add_cost = Some(1556);
4046 cfg.group_ops_bls12381_g2_add_cost = Some(3048);
4047 cfg.group_ops_bls12381_gt_add_cost = Some(188);
4048
4049 cfg.group_ops_bls12381_scalar_sub_cost = Some(10);
4050 cfg.group_ops_bls12381_g1_sub_cost = Some(1550);
4051 cfg.group_ops_bls12381_g2_sub_cost = Some(3019);
4052 cfg.group_ops_bls12381_gt_sub_cost = Some(497);
4053
4054 cfg.group_ops_bls12381_scalar_mul_cost = Some(11);
4055 cfg.group_ops_bls12381_g1_mul_cost = Some(4842);
4056 cfg.group_ops_bls12381_g2_mul_cost = Some(9108);
4057 cfg.group_ops_bls12381_gt_mul_cost = Some(27490);
4058
4059 cfg.group_ops_bls12381_scalar_div_cost = Some(91);
4060 cfg.group_ops_bls12381_g1_div_cost = Some(5091);
4061 cfg.group_ops_bls12381_g2_div_cost = Some(9206);
4062 cfg.group_ops_bls12381_gt_div_cost = Some(27804);
4063
4064 cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(2962);
4065 cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(8688);
4066
4067 cfg.group_ops_bls12381_g1_msm_base_cost = Some(62648);
4068 cfg.group_ops_bls12381_g2_msm_base_cost = Some(131192);
4069 cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(1333);
4070 cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(3216);
4071
4072 cfg.group_ops_bls12381_uncompressed_g1_to_g1_cost = Some(677);
4073 cfg.group_ops_bls12381_g1_to_uncompressed_g1_cost = Some(2099);
4074 cfg.group_ops_bls12381_uncompressed_g1_sum_base_cost = Some(77);
4075 cfg.group_ops_bls12381_uncompressed_g1_sum_cost_per_term = Some(26);
4076
4077 cfg.group_ops_bls12381_pairing_cost = Some(26897);
4078 cfg.group_ops_bls12381_uncompressed_g1_sum_max_terms = Some(1200);
4079
4080 cfg.validator_validate_metadata_cost_base = Some(20000);
4081 }
4082 71 => {
4083 cfg.sip_45_consensus_amplification_threshold = Some(5);
4084
4085 cfg.allowed_txn_cost_overage_burst_per_object_in_commit = Some(185_000_000);
4087 }
4088 72 => {
4089 cfg.feature_flags.convert_type_argument_error = true;
4090
4091 cfg.max_tx_gas = Some(50_000_000_000_000);
4094 cfg.max_gas_price = Some(50_000_000_000);
4096
4097 cfg.feature_flags.variant_nodes = true;
4098 }
4099 73 => {
4100 cfg.use_object_per_epoch_marker_table_v2 = Some(true);
4102
4103 if chain != Chain::Mainnet && chain != Chain::Testnet {
4104 cfg.consensus_gc_depth = Some(60);
4107 }
4108
4109 if chain != Chain::Mainnet {
4110 cfg.feature_flags.consensus_zstd_compression = true;
4112 }
4113
4114 cfg.feature_flags.consensus_smart_ancestor_selection = true;
4116 cfg.feature_flags
4118 .consensus_round_prober_probe_accepted_rounds = true;
4119
4120 cfg.feature_flags.per_object_congestion_control_mode =
4122 PerObjectCongestionControlMode::TotalGasBudgetWithCap;
4123 cfg.gas_budget_based_txn_cost_cap_factor = Some(400_000);
4124 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(37_000_000);
4125 cfg.max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit =
4126 Some(7_400_000); cfg.max_txn_cost_overage_per_object_in_commit = Some(u64::MAX);
4128 cfg.gas_budget_based_txn_cost_absolute_cap_commit_count = Some(50);
4129 cfg.allowed_txn_cost_overage_burst_per_object_in_commit = Some(370_000_000);
4130 }
4131 74 => {
4132 if chain != Chain::Mainnet && chain != Chain::Testnet {
4134 cfg.feature_flags.enable_nitro_attestation = true;
4135 }
4136 cfg.nitro_attestation_parse_base_cost = Some(53 * 50);
4137 cfg.nitro_attestation_parse_cost_per_byte = Some(50);
4138 cfg.nitro_attestation_verify_base_cost = Some(49632 * 50);
4139 cfg.nitro_attestation_verify_cost_per_cert = Some(52369 * 50);
4140
4141 cfg.feature_flags.consensus_zstd_compression = true;
4143
4144 if chain != Chain::Mainnet && chain != Chain::Testnet {
4145 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
4146 }
4147 }
4148 75 => {
4149 if chain != Chain::Mainnet {
4150 cfg.feature_flags.passkey_auth = true;
4151 }
4152 }
4153 76 => {
4154 if chain != Chain::Mainnet && chain != Chain::Testnet {
4155 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
4156 cfg.consensus_commit_rate_estimation_window_size = Some(10);
4157 }
4158 cfg.feature_flags.minimize_child_object_mutations = true;
4159
4160 if chain != Chain::Mainnet {
4161 cfg.feature_flags.accept_passkey_in_multisig = true;
4162 }
4163 }
4164 77 => {
4165 cfg.feature_flags.uncompressed_g1_group_elements = true;
4166
4167 if chain != Chain::Mainnet {
4168 cfg.consensus_gc_depth = Some(60);
4169 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
4170 }
4171 }
4172 78 => {
4173 cfg.feature_flags.move_native_context = true;
4174 cfg.tx_context_fresh_id_cost_base = Some(52);
4175 cfg.tx_context_sender_cost_base = Some(30);
4176 cfg.tx_context_epoch_cost_base = Some(30);
4177 cfg.tx_context_epoch_timestamp_ms_cost_base = Some(30);
4178 cfg.tx_context_sponsor_cost_base = Some(30);
4179 cfg.tx_context_gas_price_cost_base = Some(30);
4180 cfg.tx_context_gas_budget_cost_base = Some(30);
4181 cfg.tx_context_ids_created_cost_base = Some(30);
4182 cfg.tx_context_replace_cost_base = Some(30);
4183 cfg.gas_model_version = Some(10);
4184
4185 if chain != Chain::Mainnet {
4186 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
4187 cfg.consensus_commit_rate_estimation_window_size = Some(10);
4188
4189 cfg.feature_flags.per_object_congestion_control_mode =
4191 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4192 ExecutionTimeEstimateParams {
4193 target_utilization: 30,
4194 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4196 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4198 stored_observations_limit: u64::MAX,
4199 stake_weighted_median_threshold: 0,
4200 default_none_duration_for_new_keys: false,
4201 observations_chunk_size: None,
4202 },
4203 );
4204 }
4205 }
4206 79 => {
4207 if chain != Chain::Mainnet {
4208 cfg.feature_flags.consensus_median_based_commit_timestamp = true;
4209
4210 cfg.consensus_bad_nodes_stake_threshold = Some(30);
4213
4214 cfg.feature_flags.consensus_batched_block_sync = true;
4215
4216 cfg.feature_flags.enable_nitro_attestation = true
4218 }
4219 cfg.feature_flags.normalize_ptb_arguments = true;
4220
4221 cfg.consensus_gc_depth = Some(60);
4222 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
4223 }
4224 80 => {
4225 cfg.max_ptb_value_size = Some(1024 * 1024);
4226 }
4227 81 => {
4228 cfg.feature_flags.consensus_median_based_commit_timestamp = true;
4229 cfg.feature_flags.enforce_checkpoint_timestamp_monotonicity = true;
4230 cfg.consensus_bad_nodes_stake_threshold = Some(30)
4231 }
4232 82 => {
4233 cfg.feature_flags.max_ptb_value_size_v2 = true;
4234 }
4235 83 => {
4236 if chain == Chain::Mainnet {
4237 let aliased: [u8; 32] = Hex::decode(
4239 "0x0b2da327ba6a4cacbe75dddd50e6e8bbf81d6496e92d66af9154c61c77f7332f",
4240 )
4241 .unwrap()
4242 .try_into()
4243 .unwrap();
4244
4245 cfg.aliased_addresses.push(AliasedAddress {
4247 original: Hex::decode("0xcd8962dad278d8b50fa0f9eb0186bfa4cbdecc6d59377214c88d0286a0ac9562").unwrap().try_into().unwrap(),
4248 aliased,
4249 allowed_tx_digests: vec![
4250 Base58::decode("B2eGLFoMHgj93Ni8dAJBfqGzo8EWSTLBesZzhEpTPA4").unwrap().try_into().unwrap(),
4251 ],
4252 });
4253
4254 cfg.aliased_addresses.push(AliasedAddress {
4255 original: Hex::decode("0xe28b50cef1d633ea43d3296a3f6b67ff0312a5f1a99f0af753c85b8b5de8ff06").unwrap().try_into().unwrap(),
4256 aliased,
4257 allowed_tx_digests: vec![
4258 Base58::decode("J4QqSAgp7VrQtQpMy5wDX4QGsCSEZu3U5KuDAkbESAge").unwrap().try_into().unwrap(),
4259 ],
4260 });
4261 }
4262
4263 if chain != Chain::Mainnet {
4266 cfg.feature_flags.resolve_type_input_ids_to_defining_id = true;
4267 cfg.transfer_party_transfer_internal_cost_base = Some(52);
4268
4269 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
4271 cfg.consensus_commit_rate_estimation_window_size = Some(10);
4272 cfg.feature_flags.per_object_congestion_control_mode =
4273 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4274 ExecutionTimeEstimateParams {
4275 target_utilization: 30,
4276 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4278 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4280 stored_observations_limit: u64::MAX,
4281 stake_weighted_median_threshold: 0,
4282 default_none_duration_for_new_keys: false,
4283 observations_chunk_size: None,
4284 },
4285 );
4286
4287 cfg.feature_flags.consensus_batched_block_sync = true;
4289
4290 cfg.feature_flags.enable_nitro_attestation_upgraded_parsing = true;
4293 cfg.feature_flags.enable_nitro_attestation = true;
4294 }
4295 }
4296 84 => {
4297 if chain == Chain::Mainnet {
4298 cfg.feature_flags.resolve_type_input_ids_to_defining_id = true;
4299 cfg.transfer_party_transfer_internal_cost_base = Some(52);
4300
4301 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
4303 cfg.consensus_commit_rate_estimation_window_size = Some(10);
4304 cfg.feature_flags.per_object_congestion_control_mode =
4305 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4306 ExecutionTimeEstimateParams {
4307 target_utilization: 30,
4308 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4310 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4312 stored_observations_limit: u64::MAX,
4313 stake_weighted_median_threshold: 0,
4314 default_none_duration_for_new_keys: false,
4315 observations_chunk_size: None,
4316 },
4317 );
4318
4319 cfg.feature_flags.consensus_batched_block_sync = true;
4321
4322 cfg.feature_flags.enable_nitro_attestation_upgraded_parsing = true;
4325 cfg.feature_flags.enable_nitro_attestation = true;
4326 }
4327
4328 cfg.feature_flags.per_object_congestion_control_mode =
4330 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4331 ExecutionTimeEstimateParams {
4332 target_utilization: 30,
4333 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4335 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4337 stored_observations_limit: 20,
4338 stake_weighted_median_threshold: 0,
4339 default_none_duration_for_new_keys: false,
4340 observations_chunk_size: None,
4341 },
4342 );
4343 cfg.feature_flags.allow_unbounded_system_objects = true;
4344 }
4345 85 => {
4346 if chain != Chain::Mainnet && chain != Chain::Testnet {
4347 cfg.feature_flags.enable_party_transfer = true;
4348 }
4349
4350 cfg.feature_flags
4351 .record_consensus_determined_version_assignments_in_prologue_v2 = true;
4352 cfg.feature_flags.disallow_self_identifier = true;
4353 cfg.feature_flags.per_object_congestion_control_mode =
4354 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4355 ExecutionTimeEstimateParams {
4356 target_utilization: 50,
4357 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4359 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4361 stored_observations_limit: 20,
4362 stake_weighted_median_threshold: 0,
4363 default_none_duration_for_new_keys: false,
4364 observations_chunk_size: None,
4365 },
4366 );
4367 }
4368 86 => {
4369 cfg.feature_flags.type_tags_in_object_runtime = true;
4370 cfg.max_move_enum_variants = Some(move_core_types::VARIANT_COUNT_MAX);
4371
4372 cfg.feature_flags.per_object_congestion_control_mode =
4374 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4375 ExecutionTimeEstimateParams {
4376 target_utilization: 50,
4377 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4379 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4381 stored_observations_limit: 20,
4382 stake_weighted_median_threshold: 3334,
4383 default_none_duration_for_new_keys: false,
4384 observations_chunk_size: None,
4385 },
4386 );
4387 if chain != Chain::Mainnet {
4389 cfg.feature_flags.enable_party_transfer = true;
4390 }
4391 }
4392 87 => {
4393 if chain == Chain::Mainnet {
4394 cfg.feature_flags.record_time_estimate_processed = true;
4395 }
4396 cfg.feature_flags.better_adapter_type_resolution_errors = true;
4397 }
4398 88 => {
4399 cfg.feature_flags.record_time_estimate_processed = true;
4400 cfg.tx_context_rgp_cost_base = Some(30);
4401 cfg.feature_flags
4402 .ignore_execution_time_observations_after_certs_closed = true;
4403
4404 cfg.feature_flags.per_object_congestion_control_mode =
4407 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4408 ExecutionTimeEstimateParams {
4409 target_utilization: 50,
4410 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4412 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4414 stored_observations_limit: 20,
4415 stake_weighted_median_threshold: 3334,
4416 default_none_duration_for_new_keys: true,
4417 observations_chunk_size: None,
4418 },
4419 );
4420 }
4421 89 => {
4422 cfg.feature_flags.dependency_linkage_error = true;
4423 cfg.feature_flags.additional_multisig_checks = true;
4424 }
4425 90 => {
4426 cfg.max_gas_price_rgp_factor_for_aborted_transactions = Some(100);
4428 cfg.feature_flags.debug_fatal_on_move_invariant_violation = true;
4429 cfg.feature_flags.additional_consensus_digest_indirect_state = true;
4430 cfg.feature_flags.accept_passkey_in_multisig = true;
4431 cfg.feature_flags.passkey_auth = true;
4432 cfg.feature_flags.check_for_init_during_upgrade = true;
4433
4434 if chain != Chain::Mainnet {
4436 cfg.feature_flags.mysticeti_fastpath = true;
4437 }
4438 }
4439 91 => {
4440 cfg.feature_flags.per_command_shared_object_transfer_rules = true;
4441 }
4442 92 => {
4443 cfg.feature_flags.per_command_shared_object_transfer_rules = false;
4444 }
4445 93 => {
4446 cfg.feature_flags
4447 .consensus_checkpoint_signature_key_includes_digest = true;
4448 }
4449 94 => {
4450 cfg.feature_flags.per_object_congestion_control_mode =
4452 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4453 ExecutionTimeEstimateParams {
4454 target_utilization: 50,
4455 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4457 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4459 stored_observations_limit: 18,
4460 stake_weighted_median_threshold: 3334,
4461 default_none_duration_for_new_keys: true,
4462 observations_chunk_size: None,
4463 },
4464 );
4465
4466 cfg.feature_flags.enable_party_transfer = true;
4468 }
4469 95 => {
4470 cfg.type_name_id_base_cost = Some(52);
4471
4472 cfg.max_transactions_per_checkpoint = Some(20_000);
4474 }
4475 96 => {
4476 if chain != Chain::Mainnet && chain != Chain::Testnet {
4478 cfg.feature_flags
4479 .include_checkpoint_artifacts_digest_in_summary = true;
4480 }
4481 cfg.feature_flags.correct_gas_payment_limit_check = true;
4482 cfg.feature_flags.authority_capabilities_v2 = true;
4483 cfg.feature_flags.use_mfp_txns_in_load_initial_object_debts = true;
4484 cfg.feature_flags.cancel_for_failed_dkg_early = true;
4485 cfg.feature_flags.enable_coin_registry = true;
4486
4487 cfg.feature_flags.mysticeti_fastpath = true;
4489 }
4490 97 => {
4491 cfg.feature_flags.additional_borrow_checks = true;
4492 }
4493 98 => {
4494 cfg.event_emit_auth_stream_cost = Some(52);
4495 cfg.feature_flags.better_loader_errors = true;
4496 cfg.feature_flags.generate_df_type_layouts = true;
4497 }
4498 99 => {
4499 cfg.feature_flags.use_new_commit_handler = true;
4500 }
4501 100 => {
4502 cfg.feature_flags.private_generics_verifier_v2 = true;
4503 }
4504 101 => {
4505 cfg.feature_flags.create_root_accumulator_object = true;
4506 cfg.max_updates_per_settlement_txn = Some(100);
4507 if chain != Chain::Mainnet {
4508 cfg.feature_flags.enable_poseidon = true;
4509 }
4510 }
4511 102 => {
4512 cfg.feature_flags.per_object_congestion_control_mode =
4516 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4517 ExecutionTimeEstimateParams {
4518 target_utilization: 50,
4519 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4521 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4523 stored_observations_limit: 180,
4524 stake_weighted_median_threshold: 3334,
4525 default_none_duration_for_new_keys: true,
4526 observations_chunk_size: Some(18),
4527 },
4528 );
4529 cfg.feature_flags.deprecate_global_storage_ops = true;
4530 }
4531 103 => {}
4532 104 => {
4533 cfg.translation_per_command_base_charge = Some(1);
4534 cfg.translation_per_input_base_charge = Some(1);
4535 cfg.translation_pure_input_per_byte_charge = Some(1);
4536 cfg.translation_per_type_node_charge = Some(1);
4537 cfg.translation_per_reference_node_charge = Some(1);
4538 cfg.translation_per_linkage_entry_charge = Some(10);
4539 cfg.gas_model_version = Some(11);
4540 cfg.feature_flags.abstract_size_in_object_runtime = true;
4541 cfg.feature_flags.object_runtime_charge_cache_load_gas = true;
4542 cfg.dynamic_field_hash_type_and_key_cost_base = Some(52);
4543 cfg.dynamic_field_add_child_object_cost_base = Some(52);
4544 cfg.dynamic_field_add_child_object_value_cost_per_byte = Some(1);
4545 cfg.dynamic_field_borrow_child_object_cost_base = Some(52);
4546 cfg.dynamic_field_borrow_child_object_child_ref_cost_per_byte = Some(1);
4547 cfg.dynamic_field_remove_child_object_cost_base = Some(52);
4548 cfg.dynamic_field_remove_child_object_child_cost_per_byte = Some(1);
4549 cfg.dynamic_field_has_child_object_cost_base = Some(52);
4550 cfg.dynamic_field_has_child_object_with_ty_cost_base = Some(52);
4551 cfg.feature_flags.enable_ptb_execution_v2 = true;
4552
4553 cfg.poseidon_bn254_cost_base = Some(260);
4554
4555 cfg.feature_flags.consensus_skip_gced_accept_votes = true;
4556
4557 if chain != Chain::Mainnet {
4558 cfg.feature_flags
4559 .enable_nitro_attestation_all_nonzero_pcrs_parsing = true;
4560 }
4561
4562 cfg.feature_flags
4563 .include_cancelled_randomness_txns_in_prologue = true;
4564 }
4565 105 => {
4566 cfg.feature_flags.enable_multi_epoch_transaction_expiration = true;
4567 cfg.feature_flags.disable_preconsensus_locking = true;
4568
4569 if chain != Chain::Mainnet {
4570 cfg.feature_flags
4571 .enable_nitro_attestation_always_include_required_pcrs_parsing = true;
4572 }
4573 }
4574 106 => {
4575 cfg.accumulator_object_storage_cost = Some(7600);
4577
4578 if chain != Chain::Mainnet && chain != Chain::Testnet {
4579 cfg.feature_flags.enable_accumulators = true;
4580 cfg.feature_flags.enable_address_balance_gas_payments = true;
4581 cfg.feature_flags.enable_authenticated_event_streams = true;
4582 cfg.feature_flags.enable_object_funds_withdraw = true;
4583 }
4584 }
4585 107 => {
4586 cfg.feature_flags
4587 .consensus_skip_gced_blocks_in_direct_finalization = true;
4588
4589 if in_integration_test() {
4591 cfg.consensus_gc_depth = Some(6);
4592 cfg.consensus_max_num_transactions_in_block = Some(8);
4593 }
4594 }
4595 108 => {
4596 cfg.feature_flags.gas_rounding_halve_digits = true;
4597 cfg.feature_flags.flexible_tx_context_positions = true;
4598 cfg.feature_flags.disable_entry_point_signature_check = true;
4599
4600 if chain != Chain::Mainnet {
4601 cfg.feature_flags.address_aliases = true;
4602
4603 cfg.feature_flags.enable_accumulators = true;
4604 cfg.feature_flags.enable_address_balance_gas_payments = true;
4605 }
4606
4607 cfg.feature_flags.enable_poseidon = true;
4608 }
4609 109 => {
4610 cfg.binary_variant_handles = Some(1024);
4611 cfg.binary_variant_instantiation_handles = Some(1024);
4612 cfg.feature_flags.restrict_hot_or_not_entry_functions = true;
4613 }
4614 110 => {
4615 cfg.feature_flags
4616 .enable_nitro_attestation_all_nonzero_pcrs_parsing = true;
4617 cfg.feature_flags
4618 .enable_nitro_attestation_always_include_required_pcrs_parsing = true;
4619 if chain != Chain::Mainnet && chain != Chain::Testnet {
4620 cfg.feature_flags.split_checkpoints_in_consensus_handler = true;
4621 }
4622 cfg.feature_flags.validate_zklogin_public_identifier = true;
4623 cfg.feature_flags.fix_checkpoint_signature_mapping = true;
4624 cfg.feature_flags
4625 .consensus_always_accept_system_transactions = true;
4626 if chain != Chain::Mainnet {
4627 cfg.feature_flags.enable_object_funds_withdraw = true;
4628 }
4629 }
4630 111 => {
4631 cfg.feature_flags.validator_metadata_verify_v2 = true;
4632 }
4633 112 => {
4634 cfg.group_ops_ristretto_decode_scalar_cost = Some(7);
4635 cfg.group_ops_ristretto_decode_point_cost = Some(200);
4636 cfg.group_ops_ristretto_scalar_add_cost = Some(10);
4637 cfg.group_ops_ristretto_point_add_cost = Some(500);
4638 cfg.group_ops_ristretto_scalar_sub_cost = Some(10);
4639 cfg.group_ops_ristretto_point_sub_cost = Some(500);
4640 cfg.group_ops_ristretto_scalar_mul_cost = Some(11);
4641 cfg.group_ops_ristretto_point_mul_cost = Some(1200);
4642 cfg.group_ops_ristretto_scalar_div_cost = Some(151);
4643 cfg.group_ops_ristretto_point_div_cost = Some(2500);
4644
4645 if chain != Chain::Mainnet && chain != Chain::Testnet {
4646 cfg.feature_flags.enable_ristretto255_group_ops = true;
4647 }
4648 }
4649 113 => {
4650 cfg.feature_flags.address_balance_gas_check_rgp_at_signing = true;
4651 if chain != Chain::Mainnet && chain != Chain::Testnet {
4652 cfg.feature_flags.defer_unpaid_amplification = true;
4653 }
4654 }
4655 114 => {
4656 cfg.feature_flags.randomize_checkpoint_tx_limit_in_tests = true;
4657 cfg.feature_flags.address_balance_gas_reject_gas_coin_arg = true;
4658 if chain != Chain::Mainnet {
4659 cfg.feature_flags.split_checkpoints_in_consensus_handler = true;
4660 cfg.feature_flags.enable_authenticated_event_streams = true;
4661 cfg.feature_flags
4662 .include_checkpoint_artifacts_digest_in_summary = true;
4663 }
4664 }
4665 115 => {
4666 cfg.feature_flags.normalize_depth_formula = true;
4667 }
4668 116 => {
4669 cfg.feature_flags.gasless_transaction_drop_safety = true;
4670 cfg.feature_flags.address_aliases = true;
4671 cfg.feature_flags.relax_valid_during_for_owned_inputs = true;
4672 cfg.feature_flags.defer_unpaid_amplification = false;
4674 cfg.feature_flags.enable_display_registry = true;
4675 }
4676 _ => panic!("unsupported version {:?}", version),
4687 }
4688 }
4689
4690 cfg
4691 }
4692
4693 pub fn apply_seeded_test_overrides(&mut self, seed: &[u8; 32]) {
4694 if !self.feature_flags.randomize_checkpoint_tx_limit_in_tests
4695 || !self.feature_flags.split_checkpoints_in_consensus_handler
4696 {
4697 return;
4698 }
4699
4700 if !mysten_common::in_test_configuration() {
4701 return;
4702 }
4703
4704 use rand::{Rng, SeedableRng, rngs::StdRng};
4705 let mut rng = StdRng::from_seed(*seed);
4706 let max_txns = rng.gen_range(10..=100u64);
4707 info!("seeded test override: max_transactions_per_checkpoint = {max_txns}");
4708 self.max_transactions_per_checkpoint = Some(max_txns);
4709 }
4710
4711 pub fn verifier_config(&self, signing_limits: Option<(usize, usize, usize)>) -> VerifierConfig {
4717 let (
4718 max_back_edges_per_function,
4719 max_back_edges_per_module,
4720 sanity_check_with_regex_reference_safety,
4721 ) = if let Some((
4722 max_back_edges_per_function,
4723 max_back_edges_per_module,
4724 sanity_check_with_regex_reference_safety,
4725 )) = signing_limits
4726 {
4727 (
4728 Some(max_back_edges_per_function),
4729 Some(max_back_edges_per_module),
4730 Some(sanity_check_with_regex_reference_safety),
4731 )
4732 } else {
4733 (None, None, None)
4734 };
4735
4736 let additional_borrow_checks = if signing_limits.is_some() {
4737 true
4739 } else {
4740 self.additional_borrow_checks()
4741 };
4742 let deprecate_global_storage_ops = if signing_limits.is_some() {
4743 true
4745 } else {
4746 self.deprecate_global_storage_ops()
4747 };
4748
4749 VerifierConfig {
4750 max_loop_depth: Some(self.max_loop_depth() as usize),
4751 max_generic_instantiation_length: Some(self.max_generic_instantiation_length() as usize),
4752 max_function_parameters: Some(self.max_function_parameters() as usize),
4753 max_basic_blocks: Some(self.max_basic_blocks() as usize),
4754 max_value_stack_size: self.max_value_stack_size() as usize,
4755 max_type_nodes: Some(self.max_type_nodes() as usize),
4756 max_push_size: Some(self.max_push_size() as usize),
4757 max_dependency_depth: Some(self.max_dependency_depth() as usize),
4758 max_fields_in_struct: Some(self.max_fields_in_struct() as usize),
4759 max_function_definitions: Some(self.max_function_definitions() as usize),
4760 max_data_definitions: Some(self.max_struct_definitions() as usize),
4761 max_constant_vector_len: Some(self.max_move_vector_len()),
4762 max_back_edges_per_function,
4763 max_back_edges_per_module,
4764 max_basic_blocks_in_script: None,
4765 max_identifier_len: self.max_move_identifier_len_as_option(), disallow_self_identifier: self.feature_flags.disallow_self_identifier,
4767 allow_receiving_object_id: self.allow_receiving_object_id(),
4768 reject_mutable_random_on_entry_functions: self
4769 .reject_mutable_random_on_entry_functions(),
4770 bytecode_version: self.move_binary_format_version(),
4771 max_variants_in_enum: self.max_move_enum_variants_as_option(),
4772 additional_borrow_checks,
4773 better_loader_errors: self.better_loader_errors(),
4774 private_generics_verifier_v2: self.private_generics_verifier_v2(),
4775 sanity_check_with_regex_reference_safety: sanity_check_with_regex_reference_safety
4776 .map(|limit| limit as u128),
4777 deprecate_global_storage_ops,
4778 disable_entry_point_signature_check: self.disable_entry_point_signature_check(),
4779 switch_to_regex_reference_safety: false,
4780 }
4781 }
4782
4783 pub fn binary_config(
4784 &self,
4785 override_deprecate_global_storage_ops_during_deserialization: Option<bool>,
4786 ) -> BinaryConfig {
4787 let deprecate_global_storage_ops =
4788 override_deprecate_global_storage_ops_during_deserialization
4789 .unwrap_or_else(|| self.deprecate_global_storage_ops());
4790 BinaryConfig::new(
4791 self.move_binary_format_version(),
4792 self.min_move_binary_format_version_as_option()
4793 .unwrap_or(VERSION_1),
4794 self.no_extraneous_module_bytes(),
4795 deprecate_global_storage_ops,
4796 TableConfig {
4797 module_handles: self.binary_module_handles_as_option().unwrap_or(u16::MAX),
4798 datatype_handles: self.binary_struct_handles_as_option().unwrap_or(u16::MAX),
4799 function_handles: self.binary_function_handles_as_option().unwrap_or(u16::MAX),
4800 function_instantiations: self
4801 .binary_function_instantiations_as_option()
4802 .unwrap_or(u16::MAX),
4803 signatures: self.binary_signatures_as_option().unwrap_or(u16::MAX),
4804 constant_pool: self.binary_constant_pool_as_option().unwrap_or(u16::MAX),
4805 identifiers: self.binary_identifiers_as_option().unwrap_or(u16::MAX),
4806 address_identifiers: self
4807 .binary_address_identifiers_as_option()
4808 .unwrap_or(u16::MAX),
4809 struct_defs: self.binary_struct_defs_as_option().unwrap_or(u16::MAX),
4810 struct_def_instantiations: self
4811 .binary_struct_def_instantiations_as_option()
4812 .unwrap_or(u16::MAX),
4813 function_defs: self.binary_function_defs_as_option().unwrap_or(u16::MAX),
4814 field_handles: self.binary_field_handles_as_option().unwrap_or(u16::MAX),
4815 field_instantiations: self
4816 .binary_field_instantiations_as_option()
4817 .unwrap_or(u16::MAX),
4818 friend_decls: self.binary_friend_decls_as_option().unwrap_or(u16::MAX),
4819 enum_defs: self.binary_enum_defs_as_option().unwrap_or(u16::MAX),
4820 enum_def_instantiations: self
4821 .binary_enum_def_instantiations_as_option()
4822 .unwrap_or(u16::MAX),
4823 variant_handles: self.binary_variant_handles_as_option().unwrap_or(u16::MAX),
4824 variant_instantiation_handles: self
4825 .binary_variant_instantiation_handles_as_option()
4826 .unwrap_or(u16::MAX),
4827 },
4828 )
4829 }
4830
4831 pub fn apply_overrides_for_testing(
4835 override_fn: impl Fn(ProtocolVersion, Self) -> Self + Send + 'static,
4836 ) -> OverrideGuard {
4837 CONFIG_OVERRIDE.with(|ovr| {
4838 let mut cur = ovr.borrow_mut();
4839 assert!(cur.is_none(), "config override already present");
4840 *cur = Some(Box::new(override_fn));
4841 OverrideGuard
4842 })
4843 }
4844}
4845
4846impl ProtocolConfig {
4850 pub fn set_advance_to_highest_supported_protocol_version_for_testing(&mut self, val: bool) {
4851 self.feature_flags
4852 .advance_to_highest_supported_protocol_version = val
4853 }
4854 pub fn set_commit_root_state_digest_supported_for_testing(&mut self, val: bool) {
4855 self.feature_flags.commit_root_state_digest = val
4856 }
4857 pub fn set_zklogin_auth_for_testing(&mut self, val: bool) {
4858 self.feature_flags.zklogin_auth = val
4859 }
4860 pub fn set_enable_jwk_consensus_updates_for_testing(&mut self, val: bool) {
4861 self.feature_flags.enable_jwk_consensus_updates = val
4862 }
4863 pub fn set_random_beacon_for_testing(&mut self, val: bool) {
4864 self.feature_flags.random_beacon = val
4865 }
4866
4867 pub fn set_upgraded_multisig_for_testing(&mut self, val: bool) {
4868 self.feature_flags.upgraded_multisig_supported = val
4869 }
4870 pub fn set_accept_zklogin_in_multisig_for_testing(&mut self, val: bool) {
4871 self.feature_flags.accept_zklogin_in_multisig = val
4872 }
4873
4874 pub fn set_shared_object_deletion_for_testing(&mut self, val: bool) {
4875 self.feature_flags.shared_object_deletion = val;
4876 }
4877
4878 pub fn set_narwhal_new_leader_election_schedule_for_testing(&mut self, val: bool) {
4879 self.feature_flags.narwhal_new_leader_election_schedule = val;
4880 }
4881
4882 pub fn set_receive_object_for_testing(&mut self, val: bool) {
4883 self.feature_flags.receive_objects = val
4884 }
4885 pub fn set_narwhal_certificate_v2_for_testing(&mut self, val: bool) {
4886 self.feature_flags.narwhal_certificate_v2 = val
4887 }
4888 pub fn set_verify_legacy_zklogin_address_for_testing(&mut self, val: bool) {
4889 self.feature_flags.verify_legacy_zklogin_address = val
4890 }
4891
4892 pub fn set_per_object_congestion_control_mode_for_testing(
4893 &mut self,
4894 val: PerObjectCongestionControlMode,
4895 ) {
4896 self.feature_flags.per_object_congestion_control_mode = val;
4897 }
4898
4899 pub fn set_consensus_choice_for_testing(&mut self, val: ConsensusChoice) {
4900 self.feature_flags.consensus_choice = val;
4901 }
4902
4903 pub fn set_consensus_network_for_testing(&mut self, val: ConsensusNetwork) {
4904 self.feature_flags.consensus_network = val;
4905 }
4906
4907 pub fn set_zklogin_max_epoch_upper_bound_delta_for_testing(&mut self, val: Option<u64>) {
4908 self.feature_flags.zklogin_max_epoch_upper_bound_delta = val
4909 }
4910
4911 pub fn set_disable_bridge_for_testing(&mut self) {
4912 self.feature_flags.bridge = false
4913 }
4914
4915 pub fn set_mysticeti_num_leaders_per_round_for_testing(&mut self, val: Option<usize>) {
4916 self.feature_flags.mysticeti_num_leaders_per_round = val;
4917 }
4918
4919 pub fn set_enable_soft_bundle_for_testing(&mut self, val: bool) {
4920 self.feature_flags.soft_bundle = val;
4921 }
4922
4923 pub fn set_passkey_auth_for_testing(&mut self, val: bool) {
4924 self.feature_flags.passkey_auth = val
4925 }
4926
4927 pub fn set_enable_party_transfer_for_testing(&mut self, val: bool) {
4928 self.feature_flags.enable_party_transfer = val
4929 }
4930
4931 pub fn set_consensus_distributed_vote_scoring_strategy_for_testing(&mut self, val: bool) {
4932 self.feature_flags
4933 .consensus_distributed_vote_scoring_strategy = val;
4934 }
4935
4936 pub fn set_consensus_round_prober_for_testing(&mut self, val: bool) {
4937 self.feature_flags.consensus_round_prober = val;
4938 }
4939
4940 pub fn set_disallow_new_modules_in_deps_only_packages_for_testing(&mut self, val: bool) {
4941 self.feature_flags
4942 .disallow_new_modules_in_deps_only_packages = val;
4943 }
4944
4945 pub fn set_correct_gas_payment_limit_check_for_testing(&mut self, val: bool) {
4946 self.feature_flags.correct_gas_payment_limit_check = val;
4947 }
4948
4949 pub fn set_address_aliases_for_testing(&mut self, val: bool) {
4950 self.feature_flags.address_aliases = val;
4951 }
4952
4953 pub fn set_consensus_round_prober_probe_accepted_rounds(&mut self, val: bool) {
4954 self.feature_flags
4955 .consensus_round_prober_probe_accepted_rounds = val;
4956 }
4957
4958 pub fn set_mysticeti_fastpath_for_testing(&mut self, val: bool) {
4959 self.feature_flags.mysticeti_fastpath = val;
4960 }
4961
4962 pub fn set_accept_passkey_in_multisig_for_testing(&mut self, val: bool) {
4963 self.feature_flags.accept_passkey_in_multisig = val;
4964 }
4965
4966 pub fn set_consensus_batched_block_sync_for_testing(&mut self, val: bool) {
4967 self.feature_flags.consensus_batched_block_sync = val;
4968 }
4969
4970 pub fn set_record_time_estimate_processed_for_testing(&mut self, val: bool) {
4971 self.feature_flags.record_time_estimate_processed = val;
4972 }
4973
4974 pub fn set_prepend_prologue_tx_in_consensus_commit_in_checkpoints_for_testing(
4975 &mut self,
4976 val: bool,
4977 ) {
4978 self.feature_flags
4979 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = val;
4980 }
4981
4982 pub fn enable_accumulators_for_testing(&mut self) {
4983 self.feature_flags.enable_accumulators = true;
4984 }
4985
4986 pub fn disable_accumulators_for_testing(&mut self) {
4987 self.feature_flags.enable_accumulators = false;
4988 self.feature_flags.enable_address_balance_gas_payments = false;
4989 }
4990
4991 pub fn enable_coin_reservation_for_testing(&mut self) {
4992 self.feature_flags.enable_coin_reservation_obj_refs = true;
4993 }
4994
4995 pub fn create_root_accumulator_object_for_testing(&mut self) {
4996 self.feature_flags.create_root_accumulator_object = true;
4997 }
4998
4999 pub fn disable_create_root_accumulator_object_for_testing(&mut self) {
5000 self.feature_flags.create_root_accumulator_object = false;
5001 }
5002
5003 pub fn enable_address_balance_gas_payments_for_testing(&mut self) {
5004 self.feature_flags.enable_accumulators = true;
5005 self.feature_flags.allow_private_accumulator_entrypoints = true;
5006 self.feature_flags.enable_address_balance_gas_payments = true;
5007 self.feature_flags.address_balance_gas_check_rgp_at_signing = true;
5008 self.feature_flags.address_balance_gas_reject_gas_coin_arg = true;
5009 }
5010
5011 pub fn disable_address_balance_gas_payments_for_testing(&mut self) {
5012 self.feature_flags.enable_address_balance_gas_payments = false;
5013 }
5014
5015 pub fn enable_multi_epoch_transaction_expiration_for_testing(&mut self) {
5016 self.feature_flags.enable_multi_epoch_transaction_expiration = true;
5017 }
5018
5019 pub fn enable_authenticated_event_streams_for_testing(&mut self) {
5020 self.enable_accumulators_for_testing();
5021 self.feature_flags.enable_authenticated_event_streams = true;
5022 self.feature_flags
5023 .include_checkpoint_artifacts_digest_in_summary = true;
5024 self.feature_flags.split_checkpoints_in_consensus_handler = true;
5025 }
5026
5027 pub fn disable_authenticated_event_streams_for_testing(&mut self) {
5028 self.feature_flags.enable_authenticated_event_streams = false;
5029 }
5030
5031 pub fn disable_randomize_checkpoint_tx_limit_for_testing(&mut self) {
5032 self.feature_flags.randomize_checkpoint_tx_limit_in_tests = false;
5033 }
5034
5035 pub fn enable_non_exclusive_writes_for_testing(&mut self) {
5036 self.feature_flags.enable_non_exclusive_writes = true;
5037 }
5038
5039 pub fn set_relax_valid_during_for_owned_inputs_for_testing(&mut self, val: bool) {
5040 self.feature_flags.relax_valid_during_for_owned_inputs = val;
5041 }
5042
5043 pub fn set_ignore_execution_time_observations_after_certs_closed_for_testing(
5044 &mut self,
5045 val: bool,
5046 ) {
5047 self.feature_flags
5048 .ignore_execution_time_observations_after_certs_closed = val;
5049 }
5050
5051 pub fn set_consensus_checkpoint_signature_key_includes_digest_for_testing(
5052 &mut self,
5053 val: bool,
5054 ) {
5055 self.feature_flags
5056 .consensus_checkpoint_signature_key_includes_digest = val;
5057 }
5058
5059 pub fn set_cancel_for_failed_dkg_early_for_testing(&mut self, val: bool) {
5060 self.feature_flags.cancel_for_failed_dkg_early = val;
5061 }
5062
5063 pub fn set_use_mfp_txns_in_load_initial_object_debts_for_testing(&mut self, val: bool) {
5064 self.feature_flags.use_mfp_txns_in_load_initial_object_debts = val;
5065 }
5066
5067 pub fn set_authority_capabilities_v2_for_testing(&mut self, val: bool) {
5068 self.feature_flags.authority_capabilities_v2 = val;
5069 }
5070
5071 pub fn allow_references_in_ptbs_for_testing(&mut self) {
5072 self.feature_flags.allow_references_in_ptbs = true;
5073 }
5074
5075 pub fn set_consensus_skip_gced_accept_votes_for_testing(&mut self, val: bool) {
5076 self.feature_flags.consensus_skip_gced_accept_votes = val;
5077 }
5078
5079 pub fn set_enable_object_funds_withdraw_for_testing(&mut self, val: bool) {
5080 self.feature_flags.enable_object_funds_withdraw = val;
5081 }
5082
5083 pub fn set_split_checkpoints_in_consensus_handler_for_testing(&mut self, val: bool) {
5084 self.feature_flags.split_checkpoints_in_consensus_handler = val;
5085 }
5086}
5087
5088type OverrideFn = dyn Fn(ProtocolVersion, ProtocolConfig) -> ProtocolConfig + Send;
5089
5090thread_local! {
5091 static CONFIG_OVERRIDE: RefCell<Option<Box<OverrideFn>>> = RefCell::new(None);
5092}
5093
5094#[must_use]
5095pub struct OverrideGuard;
5096
5097impl Drop for OverrideGuard {
5098 fn drop(&mut self) {
5099 info!("restoring override fn");
5100 CONFIG_OVERRIDE.with(|ovr| {
5101 *ovr.borrow_mut() = None;
5102 });
5103 }
5104}
5105
5106#[derive(PartialEq, Eq)]
5109pub enum LimitThresholdCrossed {
5110 None,
5111 Soft(u128, u128),
5112 Hard(u128, u128),
5113}
5114
5115pub fn check_limit_in_range<T: Into<V>, U: Into<V>, V: PartialOrd + Into<u128>>(
5118 x: T,
5119 soft_limit: U,
5120 hard_limit: V,
5121) -> LimitThresholdCrossed {
5122 let x: V = x.into();
5123 let soft_limit: V = soft_limit.into();
5124
5125 debug_assert!(soft_limit <= hard_limit);
5126
5127 if x >= hard_limit {
5130 LimitThresholdCrossed::Hard(x.into(), hard_limit.into())
5131 } else if x < soft_limit {
5132 LimitThresholdCrossed::None
5133 } else {
5134 LimitThresholdCrossed::Soft(x.into(), soft_limit.into())
5135 }
5136}
5137
5138#[macro_export]
5139macro_rules! check_limit {
5140 ($x:expr, $hard:expr) => {
5141 check_limit!($x, $hard, $hard)
5142 };
5143 ($x:expr, $soft:expr, $hard:expr) => {
5144 check_limit_in_range($x as u64, $soft, $hard)
5145 };
5146}
5147
5148#[macro_export]
5152macro_rules! check_limit_by_meter {
5153 ($is_metered:expr, $x:expr, $metered_limit:expr, $unmetered_hard_limit:expr, $metric:expr) => {{
5154 let (h, metered_str) = if $is_metered {
5156 ($metered_limit, "metered")
5157 } else {
5158 ($unmetered_hard_limit, "unmetered")
5160 };
5161 use sui_protocol_config::check_limit_in_range;
5162 let result = check_limit_in_range($x as u64, $metered_limit, h);
5163 match result {
5164 LimitThresholdCrossed::None => {}
5165 LimitThresholdCrossed::Soft(_, _) => {
5166 $metric.with_label_values(&[metered_str, "soft"]).inc();
5167 }
5168 LimitThresholdCrossed::Hard(_, _) => {
5169 $metric.with_label_values(&[metered_str, "hard"]).inc();
5170 }
5171 };
5172 result
5173 }};
5174}
5175#[cfg(all(test, not(msim)))]
5176mod test {
5177 use insta::assert_yaml_snapshot;
5178
5179 use super::*;
5180
5181 #[test]
5182 fn snapshot_tests() {
5183 println!("\n============================================================================");
5184 println!("! !");
5185 println!("! IMPORTANT: never update snapshots from this test. only add new versions! !");
5186 println!("! !");
5187 println!("============================================================================\n");
5188 for chain_id in &[Chain::Unknown, Chain::Mainnet, Chain::Testnet] {
5189 let chain_str = match chain_id {
5193 Chain::Unknown => "".to_string(),
5194 _ => format!("{:?}_", chain_id),
5195 };
5196 for i in MIN_PROTOCOL_VERSION..=MAX_PROTOCOL_VERSION {
5197 let cur = ProtocolVersion::new(i);
5198 assert_yaml_snapshot!(
5199 format!("{}version_{}", chain_str, cur.as_u64()),
5200 ProtocolConfig::get_for_version(cur, *chain_id)
5201 );
5202 }
5203 }
5204 }
5205
5206 #[test]
5207 fn test_getters() {
5208 let prot: ProtocolConfig =
5209 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5210 assert_eq!(
5211 prot.max_arguments(),
5212 prot.max_arguments_as_option().unwrap()
5213 );
5214 }
5215
5216 #[test]
5217 fn test_setters() {
5218 let mut prot: ProtocolConfig =
5219 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5220 prot.set_max_arguments_for_testing(123);
5221 assert_eq!(prot.max_arguments(), 123);
5222
5223 prot.set_max_arguments_from_str_for_testing("321".to_string());
5224 assert_eq!(prot.max_arguments(), 321);
5225
5226 prot.disable_max_arguments_for_testing();
5227 assert_eq!(prot.max_arguments_as_option(), None);
5228
5229 prot.set_attr_for_testing("max_arguments".to_string(), "456".to_string());
5230 assert_eq!(prot.max_arguments(), 456);
5231 }
5232
5233 #[test]
5234 #[should_panic(expected = "unsupported version")]
5235 fn max_version_test() {
5236 let _ = ProtocolConfig::get_for_version_impl(
5239 ProtocolVersion::new(MAX_PROTOCOL_VERSION + 1),
5240 Chain::Unknown,
5241 );
5242 }
5243
5244 #[test]
5245 fn lookup_by_string_test() {
5246 let prot: ProtocolConfig =
5247 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5248 assert!(prot.lookup_attr("some random string".to_string()).is_none());
5250
5251 assert!(
5252 prot.lookup_attr("max_arguments".to_string())
5253 == Some(ProtocolConfigValue::u32(prot.max_arguments())),
5254 );
5255
5256 assert!(
5258 prot.lookup_attr("max_move_identifier_len".to_string())
5259 .is_none()
5260 );
5261
5262 let prot: ProtocolConfig =
5264 ProtocolConfig::get_for_version(ProtocolVersion::new(9), Chain::Unknown);
5265 assert!(
5266 prot.lookup_attr("max_move_identifier_len".to_string())
5267 == Some(ProtocolConfigValue::u64(prot.max_move_identifier_len()))
5268 );
5269
5270 let prot: ProtocolConfig =
5271 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5272 assert!(
5274 prot.attr_map()
5275 .get("max_move_identifier_len")
5276 .unwrap()
5277 .is_none()
5278 );
5279 assert!(
5281 prot.attr_map().get("max_arguments").unwrap()
5282 == &Some(ProtocolConfigValue::u32(prot.max_arguments()))
5283 );
5284
5285 let prot: ProtocolConfig =
5287 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5288 assert!(
5290 prot.feature_flags
5291 .lookup_attr("some random string".to_owned())
5292 .is_none()
5293 );
5294 assert!(
5295 !prot
5296 .feature_flags
5297 .attr_map()
5298 .contains_key("some random string")
5299 );
5300
5301 assert!(
5303 prot.feature_flags
5304 .lookup_attr("package_upgrades".to_owned())
5305 == Some(false)
5306 );
5307 assert!(
5308 prot.feature_flags
5309 .attr_map()
5310 .get("package_upgrades")
5311 .unwrap()
5312 == &false
5313 );
5314 let prot: ProtocolConfig =
5315 ProtocolConfig::get_for_version(ProtocolVersion::new(4), Chain::Unknown);
5316 assert!(
5318 prot.feature_flags
5319 .lookup_attr("package_upgrades".to_owned())
5320 == Some(true)
5321 );
5322 assert!(
5323 prot.feature_flags
5324 .attr_map()
5325 .get("package_upgrades")
5326 .unwrap()
5327 == &true
5328 );
5329 }
5330
5331 #[test]
5332 fn limit_range_fn_test() {
5333 let low = 100u32;
5334 let high = 10000u64;
5335
5336 assert!(check_limit!(1u8, low, high) == LimitThresholdCrossed::None);
5337 assert!(matches!(
5338 check_limit!(255u16, low, high),
5339 LimitThresholdCrossed::Soft(255u128, 100)
5340 ));
5341 assert!(matches!(
5347 check_limit!(2550000u64, low, high),
5348 LimitThresholdCrossed::Hard(2550000, 10000)
5349 ));
5350
5351 assert!(matches!(
5352 check_limit!(2550000u64, high, high),
5353 LimitThresholdCrossed::Hard(2550000, 10000)
5354 ));
5355
5356 assert!(matches!(
5357 check_limit!(1u8, high),
5358 LimitThresholdCrossed::None
5359 ));
5360
5361 assert!(check_limit!(255u16, high) == LimitThresholdCrossed::None);
5362
5363 assert!(matches!(
5364 check_limit!(2550000u64, high),
5365 LimitThresholdCrossed::Hard(2550000, 10000)
5366 ));
5367 }
5368}