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 = 114;
28
29#[derive(Copy, Clone, Debug, Hash, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)]
304pub struct ProtocolVersion(u64);
305
306impl ProtocolVersion {
307 pub const MIN: Self = Self(MIN_PROTOCOL_VERSION);
312
313 pub const MAX: Self = Self(MAX_PROTOCOL_VERSION);
314
315 #[cfg(not(msim))]
316 pub const MAX_ALLOWED: Self = Self::MAX;
317
318 #[cfg(msim)]
320 pub const MAX_ALLOWED: Self = Self(MAX_PROTOCOL_VERSION + 1);
321
322 pub fn new(v: u64) -> Self {
323 Self(v)
324 }
325
326 pub const fn as_u64(&self) -> u64 {
327 self.0
328 }
329
330 pub fn max() -> Self {
333 Self::MAX
334 }
335
336 pub fn prev(self) -> Self {
337 Self(self.0.checked_sub(1).unwrap())
338 }
339}
340
341impl From<u64> for ProtocolVersion {
342 fn from(v: u64) -> Self {
343 Self::new(v)
344 }
345}
346
347impl std::ops::Sub<u64> for ProtocolVersion {
348 type Output = Self;
349 fn sub(self, rhs: u64) -> Self::Output {
350 Self::new(self.0 - rhs)
351 }
352}
353
354impl std::ops::Add<u64> for ProtocolVersion {
355 type Output = Self;
356 fn add(self, rhs: u64) -> Self::Output {
357 Self::new(self.0 + rhs)
358 }
359}
360
361#[derive(
362 Clone, Serialize, Deserialize, Debug, Default, PartialEq, Copy, PartialOrd, Ord, Eq, ValueEnum,
363)]
364pub enum Chain {
365 Mainnet,
366 Testnet,
367 #[default]
368 Unknown,
369}
370
371impl Chain {
372 pub fn as_str(self) -> &'static str {
373 match self {
374 Chain::Mainnet => "mainnet",
375 Chain::Testnet => "testnet",
376 Chain::Unknown => "unknown",
377 }
378 }
379}
380
381pub struct Error(pub String);
382
383#[derive(Default, Clone, Serialize, Deserialize, Debug, ProtocolConfigFeatureFlagsGetters)]
386struct FeatureFlags {
387 #[serde(skip_serializing_if = "is_false")]
390 package_upgrades: bool,
391 #[serde(skip_serializing_if = "is_false")]
394 commit_root_state_digest: bool,
395 #[serde(skip_serializing_if = "is_false")]
397 advance_epoch_start_time_in_safe_mode: bool,
398 #[serde(skip_serializing_if = "is_false")]
401 loaded_child_objects_fixed: bool,
402 #[serde(skip_serializing_if = "is_false")]
405 missing_type_is_compatibility_error: bool,
406 #[serde(skip_serializing_if = "is_false")]
409 scoring_decision_with_validity_cutoff: bool,
410
411 #[serde(skip_serializing_if = "is_false")]
414 consensus_order_end_of_epoch_last: bool,
415
416 #[serde(skip_serializing_if = "is_false")]
418 disallow_adding_abilities_on_upgrade: bool,
419 #[serde(skip_serializing_if = "is_false")]
421 disable_invariant_violation_check_in_swap_loc: bool,
422 #[serde(skip_serializing_if = "is_false")]
425 advance_to_highest_supported_protocol_version: bool,
426 #[serde(skip_serializing_if = "is_false")]
428 ban_entry_init: bool,
429 #[serde(skip_serializing_if = "is_false")]
431 package_digest_hash_module: bool,
432 #[serde(skip_serializing_if = "is_false")]
434 disallow_change_struct_type_params_on_upgrade: bool,
435 #[serde(skip_serializing_if = "is_false")]
437 no_extraneous_module_bytes: bool,
438 #[serde(skip_serializing_if = "is_false")]
440 narwhal_versioned_metadata: bool,
441
442 #[serde(skip_serializing_if = "is_false")]
444 zklogin_auth: bool,
445 #[serde(skip_serializing_if = "ConsensusTransactionOrdering::is_none")]
447 consensus_transaction_ordering: ConsensusTransactionOrdering,
448
449 #[serde(skip_serializing_if = "is_false")]
457 simplified_unwrap_then_delete: bool,
458 #[serde(skip_serializing_if = "is_false")]
460 upgraded_multisig_supported: bool,
461 #[serde(skip_serializing_if = "is_false")]
463 txn_base_cost_as_multiplier: bool,
464
465 #[serde(skip_serializing_if = "is_false")]
467 shared_object_deletion: bool,
468
469 #[serde(skip_serializing_if = "is_false")]
471 narwhal_new_leader_election_schedule: bool,
472
473 #[serde(skip_serializing_if = "is_empty")]
475 zklogin_supported_providers: BTreeSet<String>,
476
477 #[serde(skip_serializing_if = "is_false")]
479 loaded_child_object_format: bool,
480
481 #[serde(skip_serializing_if = "is_false")]
482 enable_jwk_consensus_updates: bool,
483
484 #[serde(skip_serializing_if = "is_false")]
485 end_of_epoch_transaction_supported: bool,
486
487 #[serde(skip_serializing_if = "is_false")]
490 simple_conservation_checks: bool,
491
492 #[serde(skip_serializing_if = "is_false")]
494 loaded_child_object_format_type: bool,
495
496 #[serde(skip_serializing_if = "is_false")]
498 receive_objects: bool,
499
500 #[serde(skip_serializing_if = "is_false")]
502 consensus_checkpoint_signature_key_includes_digest: bool,
503
504 #[serde(skip_serializing_if = "is_false")]
506 random_beacon: bool,
507
508 #[serde(skip_serializing_if = "is_false")]
510 bridge: bool,
511
512 #[serde(skip_serializing_if = "is_false")]
513 enable_effects_v2: bool,
514
515 #[serde(skip_serializing_if = "is_false")]
517 narwhal_certificate_v2: bool,
518
519 #[serde(skip_serializing_if = "is_false")]
521 verify_legacy_zklogin_address: bool,
522
523 #[serde(skip_serializing_if = "is_false")]
525 throughput_aware_consensus_submission: bool,
526
527 #[serde(skip_serializing_if = "is_false")]
529 recompute_has_public_transfer_in_execution: bool,
530
531 #[serde(skip_serializing_if = "is_false")]
533 accept_zklogin_in_multisig: bool,
534
535 #[serde(skip_serializing_if = "is_false")]
537 accept_passkey_in_multisig: bool,
538
539 #[serde(skip_serializing_if = "is_false")]
541 validate_zklogin_public_identifier: bool,
542
543 #[serde(skip_serializing_if = "is_false")]
546 include_consensus_digest_in_prologue: bool,
547
548 #[serde(skip_serializing_if = "is_false")]
550 hardened_otw_check: bool,
551
552 #[serde(skip_serializing_if = "is_false")]
554 allow_receiving_object_id: bool,
555
556 #[serde(skip_serializing_if = "is_false")]
558 enable_poseidon: bool,
559
560 #[serde(skip_serializing_if = "is_false")]
562 enable_coin_deny_list: bool,
563
564 #[serde(skip_serializing_if = "is_false")]
566 enable_group_ops_native_functions: bool,
567
568 #[serde(skip_serializing_if = "is_false")]
570 enable_group_ops_native_function_msm: bool,
571
572 #[serde(skip_serializing_if = "is_false")]
574 enable_ristretto255_group_ops: bool,
575
576 #[serde(skip_serializing_if = "is_false")]
578 enable_nitro_attestation: bool,
579
580 #[serde(skip_serializing_if = "is_false")]
582 enable_nitro_attestation_upgraded_parsing: bool,
583
584 #[serde(skip_serializing_if = "is_false")]
586 enable_nitro_attestation_all_nonzero_pcrs_parsing: bool,
587
588 #[serde(skip_serializing_if = "is_false")]
590 enable_nitro_attestation_always_include_required_pcrs_parsing: bool,
591
592 #[serde(skip_serializing_if = "is_false")]
594 reject_mutable_random_on_entry_functions: bool,
595
596 #[serde(skip_serializing_if = "PerObjectCongestionControlMode::is_none")]
598 per_object_congestion_control_mode: PerObjectCongestionControlMode,
599
600 #[serde(skip_serializing_if = "ConsensusChoice::is_narwhal")]
602 consensus_choice: ConsensusChoice,
603
604 #[serde(skip_serializing_if = "ConsensusNetwork::is_anemo")]
606 consensus_network: ConsensusNetwork,
607
608 #[serde(skip_serializing_if = "is_false")]
610 correct_gas_payment_limit_check: bool,
611
612 #[serde(skip_serializing_if = "Option::is_none")]
614 zklogin_max_epoch_upper_bound_delta: Option<u64>,
615
616 #[serde(skip_serializing_if = "is_false")]
618 mysticeti_leader_scoring_and_schedule: bool,
619
620 #[serde(skip_serializing_if = "is_false")]
622 reshare_at_same_initial_version: bool,
623
624 #[serde(skip_serializing_if = "is_false")]
626 resolve_abort_locations_to_package_id: bool,
627
628 #[serde(skip_serializing_if = "is_false")]
632 mysticeti_use_committed_subdag_digest: bool,
633
634 #[serde(skip_serializing_if = "is_false")]
636 enable_vdf: bool,
637
638 #[serde(skip_serializing_if = "is_false")]
643 record_consensus_determined_version_assignments_in_prologue: bool,
644 #[serde(skip_serializing_if = "is_false")]
645 record_consensus_determined_version_assignments_in_prologue_v2: bool,
646
647 #[serde(skip_serializing_if = "is_false")]
649 fresh_vm_on_framework_upgrade: bool,
650
651 #[serde(skip_serializing_if = "is_false")]
659 prepend_prologue_tx_in_consensus_commit_in_checkpoints: bool,
660
661 #[serde(skip_serializing_if = "Option::is_none")]
663 mysticeti_num_leaders_per_round: Option<usize>,
664
665 #[serde(skip_serializing_if = "is_false")]
667 soft_bundle: bool,
668
669 #[serde(skip_serializing_if = "is_false")]
671 enable_coin_deny_list_v2: bool,
672
673 #[serde(skip_serializing_if = "is_false")]
675 passkey_auth: bool,
676
677 #[serde(skip_serializing_if = "is_false")]
679 authority_capabilities_v2: bool,
680
681 #[serde(skip_serializing_if = "is_false")]
683 rethrow_serialization_type_layout_errors: bool,
684
685 #[serde(skip_serializing_if = "is_false")]
687 consensus_distributed_vote_scoring_strategy: bool,
688
689 #[serde(skip_serializing_if = "is_false")]
691 consensus_round_prober: bool,
692
693 #[serde(skip_serializing_if = "is_false")]
695 validate_identifier_inputs: bool,
696
697 #[serde(skip_serializing_if = "is_false")]
699 disallow_self_identifier: bool,
700
701 #[serde(skip_serializing_if = "is_false")]
703 mysticeti_fastpath: bool,
704
705 #[serde(skip_serializing_if = "is_false")]
709 disable_preconsensus_locking: bool,
710
711 #[serde(skip_serializing_if = "is_false")]
713 relocate_event_module: bool,
714
715 #[serde(skip_serializing_if = "is_false")]
717 uncompressed_g1_group_elements: bool,
718
719 #[serde(skip_serializing_if = "is_false")]
720 disallow_new_modules_in_deps_only_packages: bool,
721
722 #[serde(skip_serializing_if = "is_false")]
724 consensus_smart_ancestor_selection: bool,
725
726 #[serde(skip_serializing_if = "is_false")]
728 consensus_round_prober_probe_accepted_rounds: bool,
729
730 #[serde(skip_serializing_if = "is_false")]
732 native_charging_v2: bool,
733
734 #[serde(skip_serializing_if = "is_false")]
737 consensus_linearize_subdag_v2: bool,
738
739 #[serde(skip_serializing_if = "is_false")]
741 convert_type_argument_error: bool,
742
743 #[serde(skip_serializing_if = "is_false")]
745 variant_nodes: bool,
746
747 #[serde(skip_serializing_if = "is_false")]
749 consensus_zstd_compression: bool,
750
751 #[serde(skip_serializing_if = "is_false")]
753 minimize_child_object_mutations: bool,
754
755 #[serde(skip_serializing_if = "is_false")]
757 record_additional_state_digest_in_prologue: bool,
758
759 #[serde(skip_serializing_if = "is_false")]
761 move_native_context: bool,
762
763 #[serde(skip_serializing_if = "is_false")]
766 consensus_median_based_commit_timestamp: bool,
767
768 #[serde(skip_serializing_if = "is_false")]
771 normalize_ptb_arguments: bool,
772
773 #[serde(skip_serializing_if = "is_false")]
775 consensus_batched_block_sync: bool,
776
777 #[serde(skip_serializing_if = "is_false")]
779 enforce_checkpoint_timestamp_monotonicity: bool,
780
781 #[serde(skip_serializing_if = "is_false")]
783 max_ptb_value_size_v2: bool,
784
785 #[serde(skip_serializing_if = "is_false")]
787 resolve_type_input_ids_to_defining_id: bool,
788
789 #[serde(skip_serializing_if = "is_false")]
791 enable_party_transfer: bool,
792
793 #[serde(skip_serializing_if = "is_false")]
795 allow_unbounded_system_objects: bool,
796
797 #[serde(skip_serializing_if = "is_false")]
799 type_tags_in_object_runtime: bool,
800
801 #[serde(skip_serializing_if = "is_false")]
803 enable_accumulators: bool,
804
805 #[serde(skip_serializing_if = "is_false")]
807 enable_coin_reservation_obj_refs: bool,
808
809 #[serde(skip_serializing_if = "is_false")]
812 create_root_accumulator_object: bool,
813
814 #[serde(skip_serializing_if = "is_false")]
816 enable_authenticated_event_streams: bool,
817
818 #[serde(skip_serializing_if = "is_false")]
820 enable_address_balance_gas_payments: bool,
821
822 #[serde(skip_serializing_if = "is_false")]
824 address_balance_gas_check_rgp_at_signing: bool,
825
826 #[serde(skip_serializing_if = "is_false")]
827 address_balance_gas_reject_gas_coin_arg: bool,
828
829 #[serde(skip_serializing_if = "is_false")]
831 enable_multi_epoch_transaction_expiration: bool,
832
833 #[serde(skip_serializing_if = "is_false")]
835 enable_ptb_execution_v2: bool,
836
837 #[serde(skip_serializing_if = "is_false")]
839 better_adapter_type_resolution_errors: bool,
840
841 #[serde(skip_serializing_if = "is_false")]
843 record_time_estimate_processed: bool,
844
845 #[serde(skip_serializing_if = "is_false")]
847 dependency_linkage_error: bool,
848
849 #[serde(skip_serializing_if = "is_false")]
851 additional_multisig_checks: bool,
852
853 #[serde(skip_serializing_if = "is_false")]
855 ignore_execution_time_observations_after_certs_closed: bool,
856
857 #[serde(skip_serializing_if = "is_false")]
861 debug_fatal_on_move_invariant_violation: bool,
862
863 #[serde(skip_serializing_if = "is_false")]
866 allow_private_accumulator_entrypoints: bool,
867
868 #[serde(skip_serializing_if = "is_false")]
870 additional_consensus_digest_indirect_state: bool,
871
872 #[serde(skip_serializing_if = "is_false")]
874 check_for_init_during_upgrade: bool,
875
876 #[serde(skip_serializing_if = "is_false")]
878 per_command_shared_object_transfer_rules: bool,
879
880 #[serde(skip_serializing_if = "is_false")]
882 include_checkpoint_artifacts_digest_in_summary: bool,
883
884 #[serde(skip_serializing_if = "is_false")]
886 use_mfp_txns_in_load_initial_object_debts: bool,
887
888 #[serde(skip_serializing_if = "is_false")]
890 cancel_for_failed_dkg_early: bool,
891
892 #[serde(skip_serializing_if = "is_false")]
894 enable_coin_registry: bool,
895
896 #[serde(skip_serializing_if = "is_false")]
898 abstract_size_in_object_runtime: bool,
899
900 #[serde(skip_serializing_if = "is_false")]
902 object_runtime_charge_cache_load_gas: bool,
903
904 #[serde(skip_serializing_if = "is_false")]
906 additional_borrow_checks: bool,
907
908 #[serde(skip_serializing_if = "is_false")]
910 use_new_commit_handler: bool,
911
912 #[serde(skip_serializing_if = "is_false")]
914 better_loader_errors: bool,
915
916 #[serde(skip_serializing_if = "is_false")]
918 generate_df_type_layouts: bool,
919
920 #[serde(skip_serializing_if = "is_false")]
922 allow_references_in_ptbs: bool,
923
924 #[serde(skip_serializing_if = "is_false")]
926 enable_display_registry: bool,
927
928 #[serde(skip_serializing_if = "is_false")]
930 private_generics_verifier_v2: bool,
931
932 #[serde(skip_serializing_if = "is_false")]
934 deprecate_global_storage_ops_during_deserialization: bool,
935
936 #[serde(skip_serializing_if = "is_false")]
939 enable_non_exclusive_writes: bool,
940
941 #[serde(skip_serializing_if = "is_false")]
943 deprecate_global_storage_ops: bool,
944
945 #[serde(skip_serializing_if = "is_false")]
947 consensus_skip_gced_accept_votes: bool,
948
949 #[serde(skip_serializing_if = "is_false")]
951 include_cancelled_randomness_txns_in_prologue: bool,
952
953 #[serde(skip_serializing_if = "is_false")]
955 address_aliases: bool,
956
957 #[serde(skip_serializing_if = "is_false")]
960 fix_checkpoint_signature_mapping: bool,
961
962 #[serde(skip_serializing_if = "is_false")]
964 enable_object_funds_withdraw: bool,
965
966 #[serde(skip_serializing_if = "is_false")]
968 consensus_skip_gced_blocks_in_direct_finalization: bool,
969
970 #[serde(skip_serializing_if = "is_false")]
972 gas_rounding_halve_digits: bool,
973
974 #[serde(skip_serializing_if = "is_false")]
976 flexible_tx_context_positions: bool,
977
978 #[serde(skip_serializing_if = "is_false")]
980 disable_entry_point_signature_check: bool,
981
982 #[serde(skip_serializing_if = "is_false")]
984 convert_withdrawal_compatibility_ptb_arguments: bool,
985
986 #[serde(skip_serializing_if = "is_false")]
988 restrict_hot_or_not_entry_functions: bool,
989
990 #[serde(skip_serializing_if = "is_false")]
992 split_checkpoints_in_consensus_handler: bool,
993
994 #[serde(skip_serializing_if = "is_false")]
996 consensus_always_accept_system_transactions: bool,
997
998 #[serde(skip_serializing_if = "is_false")]
1000 validator_metadata_verify_v2: bool,
1001
1002 #[serde(skip_serializing_if = "is_false")]
1005 defer_unpaid_amplification: bool,
1006
1007 #[serde(skip_serializing_if = "is_false")]
1008 randomize_checkpoint_tx_limit_in_tests: bool,
1009}
1010
1011fn is_false(b: &bool) -> bool {
1012 !b
1013}
1014
1015fn is_empty(b: &BTreeSet<String>) -> bool {
1016 b.is_empty()
1017}
1018
1019fn is_zero(val: &u64) -> bool {
1020 *val == 0
1021}
1022
1023#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1025pub enum ConsensusTransactionOrdering {
1026 #[default]
1028 None,
1029 ByGasPrice,
1031}
1032
1033impl ConsensusTransactionOrdering {
1034 pub fn is_none(&self) -> bool {
1035 matches!(self, ConsensusTransactionOrdering::None)
1036 }
1037}
1038
1039#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1040pub struct ExecutionTimeEstimateParams {
1041 pub target_utilization: u64,
1043 pub allowed_txn_cost_overage_burst_limit_us: u64,
1047
1048 pub randomness_scalar: u64,
1051
1052 pub max_estimate_us: u64,
1054
1055 pub stored_observations_num_included_checkpoints: u64,
1058
1059 pub stored_observations_limit: u64,
1061
1062 #[serde(skip_serializing_if = "is_zero")]
1065 pub stake_weighted_median_threshold: u64,
1066
1067 #[serde(skip_serializing_if = "is_false")]
1071 pub default_none_duration_for_new_keys: bool,
1072
1073 #[serde(skip_serializing_if = "Option::is_none")]
1075 pub observations_chunk_size: Option<u64>,
1076}
1077
1078#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1080pub enum PerObjectCongestionControlMode {
1081 #[default]
1082 None, TotalGasBudget, TotalTxCount, TotalGasBudgetWithCap, ExecutionTimeEstimate(ExecutionTimeEstimateParams), }
1088
1089impl PerObjectCongestionControlMode {
1090 pub fn is_none(&self) -> bool {
1091 matches!(self, PerObjectCongestionControlMode::None)
1092 }
1093}
1094
1095#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1097pub enum ConsensusChoice {
1098 #[default]
1099 Narwhal,
1100 SwapEachEpoch,
1101 Mysticeti,
1102}
1103
1104impl ConsensusChoice {
1105 pub fn is_narwhal(&self) -> bool {
1106 matches!(self, ConsensusChoice::Narwhal)
1107 }
1108}
1109
1110#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1112pub enum ConsensusNetwork {
1113 #[default]
1114 Anemo,
1115 Tonic,
1116}
1117
1118impl ConsensusNetwork {
1119 pub fn is_anemo(&self) -> bool {
1120 matches!(self, ConsensusNetwork::Anemo)
1121 }
1122}
1123
1124#[skip_serializing_none]
1156#[derive(Clone, Serialize, Debug, ProtocolConfigAccessors, ProtocolConfigOverride)]
1157pub struct ProtocolConfig {
1158 pub version: ProtocolVersion,
1159
1160 feature_flags: FeatureFlags,
1161
1162 max_tx_size_bytes: Option<u64>,
1165
1166 max_input_objects: Option<u64>,
1168
1169 max_size_written_objects: Option<u64>,
1173 max_size_written_objects_system_tx: Option<u64>,
1176
1177 max_serialized_tx_effects_size_bytes: Option<u64>,
1179
1180 max_serialized_tx_effects_size_bytes_system_tx: Option<u64>,
1182
1183 max_gas_payment_objects: Option<u32>,
1185
1186 max_modules_in_publish: Option<u32>,
1188
1189 max_package_dependencies: Option<u32>,
1191
1192 max_arguments: Option<u32>,
1195
1196 max_type_arguments: Option<u32>,
1198
1199 max_type_argument_depth: Option<u32>,
1201
1202 max_pure_argument_size: Option<u32>,
1204
1205 max_programmable_tx_commands: Option<u32>,
1207
1208 move_binary_format_version: Option<u32>,
1211 min_move_binary_format_version: Option<u32>,
1212
1213 binary_module_handles: Option<u16>,
1215 binary_struct_handles: Option<u16>,
1216 binary_function_handles: Option<u16>,
1217 binary_function_instantiations: Option<u16>,
1218 binary_signatures: Option<u16>,
1219 binary_constant_pool: Option<u16>,
1220 binary_identifiers: Option<u16>,
1221 binary_address_identifiers: Option<u16>,
1222 binary_struct_defs: Option<u16>,
1223 binary_struct_def_instantiations: Option<u16>,
1224 binary_function_defs: Option<u16>,
1225 binary_field_handles: Option<u16>,
1226 binary_field_instantiations: Option<u16>,
1227 binary_friend_decls: Option<u16>,
1228 binary_enum_defs: Option<u16>,
1229 binary_enum_def_instantiations: Option<u16>,
1230 binary_variant_handles: Option<u16>,
1231 binary_variant_instantiation_handles: Option<u16>,
1232
1233 max_move_object_size: Option<u64>,
1235
1236 max_move_package_size: Option<u64>,
1239
1240 max_publish_or_upgrade_per_ptb: Option<u64>,
1242
1243 max_tx_gas: Option<u64>,
1245
1246 max_gas_price: Option<u64>,
1248
1249 max_gas_price_rgp_factor_for_aborted_transactions: Option<u64>,
1252
1253 max_gas_computation_bucket: Option<u64>,
1255
1256 gas_rounding_step: Option<u64>,
1258
1259 max_loop_depth: Option<u64>,
1261
1262 max_generic_instantiation_length: Option<u64>,
1264
1265 max_function_parameters: Option<u64>,
1267
1268 max_basic_blocks: Option<u64>,
1270
1271 max_value_stack_size: Option<u64>,
1273
1274 max_type_nodes: Option<u64>,
1276
1277 max_push_size: Option<u64>,
1279
1280 max_struct_definitions: Option<u64>,
1282
1283 max_function_definitions: Option<u64>,
1285
1286 max_fields_in_struct: Option<u64>,
1288
1289 max_dependency_depth: Option<u64>,
1291
1292 max_num_event_emit: Option<u64>,
1294
1295 max_num_new_move_object_ids: Option<u64>,
1297
1298 max_num_new_move_object_ids_system_tx: Option<u64>,
1300
1301 max_num_deleted_move_object_ids: Option<u64>,
1303
1304 max_num_deleted_move_object_ids_system_tx: Option<u64>,
1306
1307 max_num_transferred_move_object_ids: Option<u64>,
1309
1310 max_num_transferred_move_object_ids_system_tx: Option<u64>,
1312
1313 max_event_emit_size: Option<u64>,
1315
1316 max_event_emit_size_total: Option<u64>,
1318
1319 max_move_vector_len: Option<u64>,
1321
1322 max_move_identifier_len: Option<u64>,
1324
1325 max_move_value_depth: Option<u64>,
1327
1328 max_move_enum_variants: Option<u64>,
1330
1331 max_back_edges_per_function: Option<u64>,
1333
1334 max_back_edges_per_module: Option<u64>,
1336
1337 max_verifier_meter_ticks_per_function: Option<u64>,
1339
1340 max_meter_ticks_per_module: Option<u64>,
1342
1343 max_meter_ticks_per_package: Option<u64>,
1345
1346 object_runtime_max_num_cached_objects: Option<u64>,
1350
1351 object_runtime_max_num_cached_objects_system_tx: Option<u64>,
1353
1354 object_runtime_max_num_store_entries: Option<u64>,
1356
1357 object_runtime_max_num_store_entries_system_tx: Option<u64>,
1359
1360 base_tx_cost_fixed: Option<u64>,
1363
1364 package_publish_cost_fixed: Option<u64>,
1367
1368 base_tx_cost_per_byte: Option<u64>,
1371
1372 package_publish_cost_per_byte: Option<u64>,
1374
1375 obj_access_cost_read_per_byte: Option<u64>,
1377
1378 obj_access_cost_mutate_per_byte: Option<u64>,
1380
1381 obj_access_cost_delete_per_byte: Option<u64>,
1383
1384 obj_access_cost_verify_per_byte: Option<u64>,
1394
1395 max_type_to_layout_nodes: Option<u64>,
1397
1398 max_ptb_value_size: Option<u64>,
1400
1401 gas_model_version: Option<u64>,
1404
1405 obj_data_cost_refundable: Option<u64>,
1408
1409 obj_metadata_cost_non_refundable: Option<u64>,
1413
1414 storage_rebate_rate: Option<u64>,
1420
1421 storage_fund_reinvest_rate: Option<u64>,
1424
1425 reward_slashing_rate: Option<u64>,
1428
1429 storage_gas_price: Option<u64>,
1431
1432 accumulator_object_storage_cost: Option<u64>,
1434
1435 max_transactions_per_checkpoint: Option<u64>,
1440
1441 max_checkpoint_size_bytes: Option<u64>,
1445
1446 buffer_stake_for_protocol_upgrade_bps: Option<u64>,
1451
1452 address_from_bytes_cost_base: Option<u64>,
1457 address_to_u256_cost_base: Option<u64>,
1459 address_from_u256_cost_base: Option<u64>,
1461
1462 config_read_setting_impl_cost_base: Option<u64>,
1467 config_read_setting_impl_cost_per_byte: Option<u64>,
1468
1469 dynamic_field_hash_type_and_key_cost_base: Option<u64>,
1472 dynamic_field_hash_type_and_key_type_cost_per_byte: Option<u64>,
1473 dynamic_field_hash_type_and_key_value_cost_per_byte: Option<u64>,
1474 dynamic_field_hash_type_and_key_type_tag_cost_per_byte: Option<u64>,
1475 dynamic_field_add_child_object_cost_base: Option<u64>,
1477 dynamic_field_add_child_object_type_cost_per_byte: Option<u64>,
1478 dynamic_field_add_child_object_value_cost_per_byte: Option<u64>,
1479 dynamic_field_add_child_object_struct_tag_cost_per_byte: Option<u64>,
1480 dynamic_field_borrow_child_object_cost_base: Option<u64>,
1482 dynamic_field_borrow_child_object_child_ref_cost_per_byte: Option<u64>,
1483 dynamic_field_borrow_child_object_type_cost_per_byte: Option<u64>,
1484 dynamic_field_remove_child_object_cost_base: Option<u64>,
1486 dynamic_field_remove_child_object_child_cost_per_byte: Option<u64>,
1487 dynamic_field_remove_child_object_type_cost_per_byte: Option<u64>,
1488 dynamic_field_has_child_object_cost_base: Option<u64>,
1490 dynamic_field_has_child_object_with_ty_cost_base: Option<u64>,
1492 dynamic_field_has_child_object_with_ty_type_cost_per_byte: Option<u64>,
1493 dynamic_field_has_child_object_with_ty_type_tag_cost_per_byte: Option<u64>,
1494
1495 event_emit_cost_base: Option<u64>,
1498 event_emit_value_size_derivation_cost_per_byte: Option<u64>,
1499 event_emit_tag_size_derivation_cost_per_byte: Option<u64>,
1500 event_emit_output_cost_per_byte: Option<u64>,
1501 event_emit_auth_stream_cost: Option<u64>,
1502
1503 object_borrow_uid_cost_base: Option<u64>,
1506 object_delete_impl_cost_base: Option<u64>,
1508 object_record_new_uid_cost_base: Option<u64>,
1510
1511 transfer_transfer_internal_cost_base: Option<u64>,
1514 transfer_party_transfer_internal_cost_base: Option<u64>,
1516 transfer_freeze_object_cost_base: Option<u64>,
1518 transfer_share_object_cost_base: Option<u64>,
1520 transfer_receive_object_cost_base: Option<u64>,
1523
1524 tx_context_derive_id_cost_base: Option<u64>,
1527 tx_context_fresh_id_cost_base: Option<u64>,
1528 tx_context_sender_cost_base: Option<u64>,
1529 tx_context_epoch_cost_base: Option<u64>,
1530 tx_context_epoch_timestamp_ms_cost_base: Option<u64>,
1531 tx_context_sponsor_cost_base: Option<u64>,
1532 tx_context_rgp_cost_base: Option<u64>,
1533 tx_context_gas_price_cost_base: Option<u64>,
1534 tx_context_gas_budget_cost_base: Option<u64>,
1535 tx_context_ids_created_cost_base: Option<u64>,
1536 tx_context_replace_cost_base: Option<u64>,
1537
1538 types_is_one_time_witness_cost_base: Option<u64>,
1541 types_is_one_time_witness_type_tag_cost_per_byte: Option<u64>,
1542 types_is_one_time_witness_type_cost_per_byte: Option<u64>,
1543
1544 validator_validate_metadata_cost_base: Option<u64>,
1547 validator_validate_metadata_data_cost_per_byte: Option<u64>,
1548
1549 crypto_invalid_arguments_cost: Option<u64>,
1551 bls12381_bls12381_min_sig_verify_cost_base: Option<u64>,
1553 bls12381_bls12381_min_sig_verify_msg_cost_per_byte: Option<u64>,
1554 bls12381_bls12381_min_sig_verify_msg_cost_per_block: Option<u64>,
1555
1556 bls12381_bls12381_min_pk_verify_cost_base: Option<u64>,
1558 bls12381_bls12381_min_pk_verify_msg_cost_per_byte: Option<u64>,
1559 bls12381_bls12381_min_pk_verify_msg_cost_per_block: Option<u64>,
1560
1561 ecdsa_k1_ecrecover_keccak256_cost_base: Option<u64>,
1563 ecdsa_k1_ecrecover_keccak256_msg_cost_per_byte: Option<u64>,
1564 ecdsa_k1_ecrecover_keccak256_msg_cost_per_block: Option<u64>,
1565 ecdsa_k1_ecrecover_sha256_cost_base: Option<u64>,
1566 ecdsa_k1_ecrecover_sha256_msg_cost_per_byte: Option<u64>,
1567 ecdsa_k1_ecrecover_sha256_msg_cost_per_block: Option<u64>,
1568
1569 ecdsa_k1_decompress_pubkey_cost_base: Option<u64>,
1571
1572 ecdsa_k1_secp256k1_verify_keccak256_cost_base: Option<u64>,
1574 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_byte: Option<u64>,
1575 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_block: Option<u64>,
1576 ecdsa_k1_secp256k1_verify_sha256_cost_base: Option<u64>,
1577 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_byte: Option<u64>,
1578 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_block: Option<u64>,
1579
1580 ecdsa_r1_ecrecover_keccak256_cost_base: Option<u64>,
1582 ecdsa_r1_ecrecover_keccak256_msg_cost_per_byte: Option<u64>,
1583 ecdsa_r1_ecrecover_keccak256_msg_cost_per_block: Option<u64>,
1584 ecdsa_r1_ecrecover_sha256_cost_base: Option<u64>,
1585 ecdsa_r1_ecrecover_sha256_msg_cost_per_byte: Option<u64>,
1586 ecdsa_r1_ecrecover_sha256_msg_cost_per_block: Option<u64>,
1587
1588 ecdsa_r1_secp256r1_verify_keccak256_cost_base: Option<u64>,
1590 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_byte: Option<u64>,
1591 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_block: Option<u64>,
1592 ecdsa_r1_secp256r1_verify_sha256_cost_base: Option<u64>,
1593 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_byte: Option<u64>,
1594 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_block: Option<u64>,
1595
1596 ecvrf_ecvrf_verify_cost_base: Option<u64>,
1598 ecvrf_ecvrf_verify_alpha_string_cost_per_byte: Option<u64>,
1599 ecvrf_ecvrf_verify_alpha_string_cost_per_block: Option<u64>,
1600
1601 ed25519_ed25519_verify_cost_base: Option<u64>,
1603 ed25519_ed25519_verify_msg_cost_per_byte: Option<u64>,
1604 ed25519_ed25519_verify_msg_cost_per_block: Option<u64>,
1605
1606 groth16_prepare_verifying_key_bls12381_cost_base: Option<u64>,
1608 groth16_prepare_verifying_key_bn254_cost_base: Option<u64>,
1609
1610 groth16_verify_groth16_proof_internal_bls12381_cost_base: Option<u64>,
1612 groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input: Option<u64>,
1613 groth16_verify_groth16_proof_internal_bn254_cost_base: Option<u64>,
1614 groth16_verify_groth16_proof_internal_bn254_cost_per_public_input: Option<u64>,
1615 groth16_verify_groth16_proof_internal_public_input_cost_per_byte: Option<u64>,
1616
1617 hash_blake2b256_cost_base: Option<u64>,
1619 hash_blake2b256_data_cost_per_byte: Option<u64>,
1620 hash_blake2b256_data_cost_per_block: Option<u64>,
1621
1622 hash_keccak256_cost_base: Option<u64>,
1624 hash_keccak256_data_cost_per_byte: Option<u64>,
1625 hash_keccak256_data_cost_per_block: Option<u64>,
1626
1627 poseidon_bn254_cost_base: Option<u64>,
1629 poseidon_bn254_cost_per_block: Option<u64>,
1630
1631 group_ops_bls12381_decode_scalar_cost: Option<u64>,
1633 group_ops_bls12381_decode_g1_cost: Option<u64>,
1634 group_ops_bls12381_decode_g2_cost: Option<u64>,
1635 group_ops_bls12381_decode_gt_cost: Option<u64>,
1636 group_ops_bls12381_scalar_add_cost: Option<u64>,
1637 group_ops_bls12381_g1_add_cost: Option<u64>,
1638 group_ops_bls12381_g2_add_cost: Option<u64>,
1639 group_ops_bls12381_gt_add_cost: Option<u64>,
1640 group_ops_bls12381_scalar_sub_cost: Option<u64>,
1641 group_ops_bls12381_g1_sub_cost: Option<u64>,
1642 group_ops_bls12381_g2_sub_cost: Option<u64>,
1643 group_ops_bls12381_gt_sub_cost: Option<u64>,
1644 group_ops_bls12381_scalar_mul_cost: Option<u64>,
1645 group_ops_bls12381_g1_mul_cost: Option<u64>,
1646 group_ops_bls12381_g2_mul_cost: Option<u64>,
1647 group_ops_bls12381_gt_mul_cost: Option<u64>,
1648 group_ops_bls12381_scalar_div_cost: Option<u64>,
1649 group_ops_bls12381_g1_div_cost: Option<u64>,
1650 group_ops_bls12381_g2_div_cost: Option<u64>,
1651 group_ops_bls12381_gt_div_cost: Option<u64>,
1652 group_ops_bls12381_g1_hash_to_base_cost: Option<u64>,
1653 group_ops_bls12381_g2_hash_to_base_cost: Option<u64>,
1654 group_ops_bls12381_g1_hash_to_cost_per_byte: Option<u64>,
1655 group_ops_bls12381_g2_hash_to_cost_per_byte: Option<u64>,
1656 group_ops_bls12381_g1_msm_base_cost: Option<u64>,
1657 group_ops_bls12381_g2_msm_base_cost: Option<u64>,
1658 group_ops_bls12381_g1_msm_base_cost_per_input: Option<u64>,
1659 group_ops_bls12381_g2_msm_base_cost_per_input: Option<u64>,
1660 group_ops_bls12381_msm_max_len: Option<u32>,
1661 group_ops_bls12381_pairing_cost: Option<u64>,
1662 group_ops_bls12381_g1_to_uncompressed_g1_cost: Option<u64>,
1663 group_ops_bls12381_uncompressed_g1_to_g1_cost: Option<u64>,
1664 group_ops_bls12381_uncompressed_g1_sum_base_cost: Option<u64>,
1665 group_ops_bls12381_uncompressed_g1_sum_cost_per_term: Option<u64>,
1666 group_ops_bls12381_uncompressed_g1_sum_max_terms: Option<u64>,
1667
1668 group_ops_ristretto_decode_scalar_cost: Option<u64>,
1669 group_ops_ristretto_decode_point_cost: Option<u64>,
1670 group_ops_ristretto_scalar_add_cost: Option<u64>,
1671 group_ops_ristretto_point_add_cost: Option<u64>,
1672 group_ops_ristretto_scalar_sub_cost: Option<u64>,
1673 group_ops_ristretto_point_sub_cost: Option<u64>,
1674 group_ops_ristretto_scalar_mul_cost: Option<u64>,
1675 group_ops_ristretto_point_mul_cost: Option<u64>,
1676 group_ops_ristretto_scalar_div_cost: Option<u64>,
1677 group_ops_ristretto_point_div_cost: Option<u64>,
1678
1679 hmac_hmac_sha3_256_cost_base: Option<u64>,
1681 hmac_hmac_sha3_256_input_cost_per_byte: Option<u64>,
1682 hmac_hmac_sha3_256_input_cost_per_block: Option<u64>,
1683
1684 check_zklogin_id_cost_base: Option<u64>,
1686 check_zklogin_issuer_cost_base: Option<u64>,
1688
1689 vdf_verify_vdf_cost: Option<u64>,
1690 vdf_hash_to_input_cost: Option<u64>,
1691
1692 nitro_attestation_parse_base_cost: Option<u64>,
1694 nitro_attestation_parse_cost_per_byte: Option<u64>,
1695 nitro_attestation_verify_base_cost: Option<u64>,
1696 nitro_attestation_verify_cost_per_cert: Option<u64>,
1697
1698 bcs_per_byte_serialized_cost: Option<u64>,
1700 bcs_legacy_min_output_size_cost: Option<u64>,
1701 bcs_failure_cost: Option<u64>,
1702
1703 hash_sha2_256_base_cost: Option<u64>,
1704 hash_sha2_256_per_byte_cost: Option<u64>,
1705 hash_sha2_256_legacy_min_input_len_cost: Option<u64>,
1706 hash_sha3_256_base_cost: Option<u64>,
1707 hash_sha3_256_per_byte_cost: Option<u64>,
1708 hash_sha3_256_legacy_min_input_len_cost: Option<u64>,
1709 type_name_get_base_cost: Option<u64>,
1710 type_name_get_per_byte_cost: Option<u64>,
1711 type_name_id_base_cost: Option<u64>,
1712
1713 string_check_utf8_base_cost: Option<u64>,
1714 string_check_utf8_per_byte_cost: Option<u64>,
1715 string_is_char_boundary_base_cost: Option<u64>,
1716 string_sub_string_base_cost: Option<u64>,
1717 string_sub_string_per_byte_cost: Option<u64>,
1718 string_index_of_base_cost: Option<u64>,
1719 string_index_of_per_byte_pattern_cost: Option<u64>,
1720 string_index_of_per_byte_searched_cost: Option<u64>,
1721
1722 vector_empty_base_cost: Option<u64>,
1723 vector_length_base_cost: Option<u64>,
1724 vector_push_back_base_cost: Option<u64>,
1725 vector_push_back_legacy_per_abstract_memory_unit_cost: Option<u64>,
1726 vector_borrow_base_cost: Option<u64>,
1727 vector_pop_back_base_cost: Option<u64>,
1728 vector_destroy_empty_base_cost: Option<u64>,
1729 vector_swap_base_cost: Option<u64>,
1730 debug_print_base_cost: Option<u64>,
1731 debug_print_stack_trace_base_cost: Option<u64>,
1732
1733 execution_version: Option<u64>,
1742
1743 consensus_bad_nodes_stake_threshold: Option<u64>,
1747
1748 max_jwk_votes_per_validator_per_epoch: Option<u64>,
1749 max_age_of_jwk_in_epochs: Option<u64>,
1753
1754 random_beacon_reduction_allowed_delta: Option<u16>,
1758
1759 random_beacon_reduction_lower_bound: Option<u32>,
1762
1763 random_beacon_dkg_timeout_round: Option<u32>,
1766
1767 random_beacon_min_round_interval_ms: Option<u64>,
1769
1770 random_beacon_dkg_version: Option<u64>,
1773
1774 consensus_max_transaction_size_bytes: Option<u64>,
1777 consensus_max_transactions_in_block_bytes: Option<u64>,
1779 consensus_max_num_transactions_in_block: Option<u64>,
1781
1782 consensus_voting_rounds: Option<u32>,
1784
1785 max_accumulated_txn_cost_per_object_in_narwhal_commit: Option<u64>,
1787
1788 max_deferral_rounds_for_congestion_control: Option<u64>,
1791
1792 max_txn_cost_overage_per_object_in_commit: Option<u64>,
1794
1795 allowed_txn_cost_overage_burst_per_object_in_commit: Option<u64>,
1797
1798 min_checkpoint_interval_ms: Option<u64>,
1800
1801 checkpoint_summary_version_specific_data: Option<u64>,
1803
1804 max_soft_bundle_size: Option<u64>,
1806
1807 bridge_should_try_to_finalize_committee: Option<bool>,
1811
1812 max_accumulated_txn_cost_per_object_in_mysticeti_commit: Option<u64>,
1818
1819 max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit: Option<u64>,
1822
1823 consensus_gc_depth: Option<u32>,
1826
1827 gas_budget_based_txn_cost_cap_factor: Option<u64>,
1829
1830 gas_budget_based_txn_cost_absolute_cap_commit_count: Option<u64>,
1832
1833 sip_45_consensus_amplification_threshold: Option<u64>,
1836
1837 use_object_per_epoch_marker_table_v2: Option<bool>,
1840
1841 consensus_commit_rate_estimation_window_size: Option<u32>,
1843
1844 #[serde(skip_serializing_if = "Vec::is_empty")]
1848 aliased_addresses: Vec<AliasedAddress>,
1849
1850 translation_per_command_base_charge: Option<u64>,
1853
1854 translation_per_input_base_charge: Option<u64>,
1857
1858 translation_pure_input_per_byte_charge: Option<u64>,
1860
1861 translation_per_type_node_charge: Option<u64>,
1865
1866 translation_per_reference_node_charge: Option<u64>,
1869
1870 translation_per_linkage_entry_charge: Option<u64>,
1873
1874 max_updates_per_settlement_txn: Option<u32>,
1876}
1877
1878#[derive(Clone, Serialize, Deserialize, Debug)]
1880pub struct AliasedAddress {
1881 pub original: [u8; 32],
1883 pub aliased: [u8; 32],
1885 pub allowed_tx_digests: Vec<[u8; 32]>,
1887}
1888
1889impl ProtocolConfig {
1891 pub fn check_package_upgrades_supported(&self) -> Result<(), Error> {
1904 if self.feature_flags.package_upgrades {
1905 Ok(())
1906 } else {
1907 Err(Error(format!(
1908 "package upgrades are not supported at {:?}",
1909 self.version
1910 )))
1911 }
1912 }
1913
1914 pub fn allow_receiving_object_id(&self) -> bool {
1915 self.feature_flags.allow_receiving_object_id
1916 }
1917
1918 pub fn receiving_objects_supported(&self) -> bool {
1919 self.feature_flags.receive_objects
1920 }
1921
1922 pub fn package_upgrades_supported(&self) -> bool {
1923 self.feature_flags.package_upgrades
1924 }
1925
1926 pub fn check_commit_root_state_digest_supported(&self) -> bool {
1927 self.feature_flags.commit_root_state_digest
1928 }
1929
1930 pub fn get_advance_epoch_start_time_in_safe_mode(&self) -> bool {
1931 self.feature_flags.advance_epoch_start_time_in_safe_mode
1932 }
1933
1934 pub fn loaded_child_objects_fixed(&self) -> bool {
1935 self.feature_flags.loaded_child_objects_fixed
1936 }
1937
1938 pub fn missing_type_is_compatibility_error(&self) -> bool {
1939 self.feature_flags.missing_type_is_compatibility_error
1940 }
1941
1942 pub fn scoring_decision_with_validity_cutoff(&self) -> bool {
1943 self.feature_flags.scoring_decision_with_validity_cutoff
1944 }
1945
1946 pub fn narwhal_versioned_metadata(&self) -> bool {
1947 self.feature_flags.narwhal_versioned_metadata
1948 }
1949
1950 pub fn consensus_order_end_of_epoch_last(&self) -> bool {
1951 self.feature_flags.consensus_order_end_of_epoch_last
1952 }
1953
1954 pub fn disallow_adding_abilities_on_upgrade(&self) -> bool {
1955 self.feature_flags.disallow_adding_abilities_on_upgrade
1956 }
1957
1958 pub fn disable_invariant_violation_check_in_swap_loc(&self) -> bool {
1959 self.feature_flags
1960 .disable_invariant_violation_check_in_swap_loc
1961 }
1962
1963 pub fn advance_to_highest_supported_protocol_version(&self) -> bool {
1964 self.feature_flags
1965 .advance_to_highest_supported_protocol_version
1966 }
1967
1968 pub fn ban_entry_init(&self) -> bool {
1969 self.feature_flags.ban_entry_init
1970 }
1971
1972 pub fn package_digest_hash_module(&self) -> bool {
1973 self.feature_flags.package_digest_hash_module
1974 }
1975
1976 pub fn disallow_change_struct_type_params_on_upgrade(&self) -> bool {
1977 self.feature_flags
1978 .disallow_change_struct_type_params_on_upgrade
1979 }
1980
1981 pub fn no_extraneous_module_bytes(&self) -> bool {
1982 self.feature_flags.no_extraneous_module_bytes
1983 }
1984
1985 pub fn zklogin_auth(&self) -> bool {
1986 self.feature_flags.zklogin_auth
1987 }
1988
1989 pub fn zklogin_supported_providers(&self) -> &BTreeSet<String> {
1990 &self.feature_flags.zklogin_supported_providers
1991 }
1992
1993 pub fn consensus_transaction_ordering(&self) -> ConsensusTransactionOrdering {
1994 self.feature_flags.consensus_transaction_ordering
1995 }
1996
1997 pub fn simplified_unwrap_then_delete(&self) -> bool {
1998 self.feature_flags.simplified_unwrap_then_delete
1999 }
2000
2001 pub fn supports_upgraded_multisig(&self) -> bool {
2002 self.feature_flags.upgraded_multisig_supported
2003 }
2004
2005 pub fn txn_base_cost_as_multiplier(&self) -> bool {
2006 self.feature_flags.txn_base_cost_as_multiplier
2007 }
2008
2009 pub fn shared_object_deletion(&self) -> bool {
2010 self.feature_flags.shared_object_deletion
2011 }
2012
2013 pub fn narwhal_new_leader_election_schedule(&self) -> bool {
2014 self.feature_flags.narwhal_new_leader_election_schedule
2015 }
2016
2017 pub fn loaded_child_object_format(&self) -> bool {
2018 self.feature_flags.loaded_child_object_format
2019 }
2020
2021 pub fn enable_jwk_consensus_updates(&self) -> bool {
2022 let ret = self.feature_flags.enable_jwk_consensus_updates;
2023 if ret {
2024 assert!(self.feature_flags.end_of_epoch_transaction_supported);
2026 }
2027 ret
2028 }
2029
2030 pub fn simple_conservation_checks(&self) -> bool {
2031 self.feature_flags.simple_conservation_checks
2032 }
2033
2034 pub fn loaded_child_object_format_type(&self) -> bool {
2035 self.feature_flags.loaded_child_object_format_type
2036 }
2037
2038 pub fn end_of_epoch_transaction_supported(&self) -> bool {
2039 let ret = self.feature_flags.end_of_epoch_transaction_supported;
2040 if !ret {
2041 assert!(!self.feature_flags.enable_jwk_consensus_updates);
2043 }
2044 ret
2045 }
2046
2047 pub fn recompute_has_public_transfer_in_execution(&self) -> bool {
2048 self.feature_flags
2049 .recompute_has_public_transfer_in_execution
2050 }
2051
2052 pub fn create_authenticator_state_in_genesis(&self) -> bool {
2054 self.enable_jwk_consensus_updates()
2055 }
2056
2057 pub fn random_beacon(&self) -> bool {
2058 self.feature_flags.random_beacon
2059 }
2060
2061 pub fn dkg_version(&self) -> u64 {
2062 self.random_beacon_dkg_version.unwrap_or(1)
2064 }
2065
2066 pub fn enable_bridge(&self) -> bool {
2067 let ret = self.feature_flags.bridge;
2068 if ret {
2069 assert!(self.feature_flags.end_of_epoch_transaction_supported);
2071 }
2072 ret
2073 }
2074
2075 pub fn should_try_to_finalize_bridge_committee(&self) -> bool {
2076 if !self.enable_bridge() {
2077 return false;
2078 }
2079 self.bridge_should_try_to_finalize_committee.unwrap_or(true)
2081 }
2082
2083 pub fn enable_effects_v2(&self) -> bool {
2084 self.feature_flags.enable_effects_v2
2085 }
2086
2087 pub fn narwhal_certificate_v2(&self) -> bool {
2088 self.feature_flags.narwhal_certificate_v2
2089 }
2090
2091 pub fn verify_legacy_zklogin_address(&self) -> bool {
2092 self.feature_flags.verify_legacy_zklogin_address
2093 }
2094
2095 pub fn accept_zklogin_in_multisig(&self) -> bool {
2096 self.feature_flags.accept_zklogin_in_multisig
2097 }
2098
2099 pub fn accept_passkey_in_multisig(&self) -> bool {
2100 self.feature_flags.accept_passkey_in_multisig
2101 }
2102
2103 pub fn validate_zklogin_public_identifier(&self) -> bool {
2104 self.feature_flags.validate_zklogin_public_identifier
2105 }
2106
2107 pub fn zklogin_max_epoch_upper_bound_delta(&self) -> Option<u64> {
2108 self.feature_flags.zklogin_max_epoch_upper_bound_delta
2109 }
2110
2111 pub fn throughput_aware_consensus_submission(&self) -> bool {
2112 self.feature_flags.throughput_aware_consensus_submission
2113 }
2114
2115 pub fn include_consensus_digest_in_prologue(&self) -> bool {
2116 self.feature_flags.include_consensus_digest_in_prologue
2117 }
2118
2119 pub fn record_consensus_determined_version_assignments_in_prologue(&self) -> bool {
2120 self.feature_flags
2121 .record_consensus_determined_version_assignments_in_prologue
2122 }
2123
2124 pub fn record_additional_state_digest_in_prologue(&self) -> bool {
2125 self.feature_flags
2126 .record_additional_state_digest_in_prologue
2127 }
2128
2129 pub fn record_consensus_determined_version_assignments_in_prologue_v2(&self) -> bool {
2130 self.feature_flags
2131 .record_consensus_determined_version_assignments_in_prologue_v2
2132 }
2133
2134 pub fn prepend_prologue_tx_in_consensus_commit_in_checkpoints(&self) -> bool {
2135 self.feature_flags
2136 .prepend_prologue_tx_in_consensus_commit_in_checkpoints
2137 }
2138
2139 pub fn hardened_otw_check(&self) -> bool {
2140 self.feature_flags.hardened_otw_check
2141 }
2142
2143 pub fn enable_poseidon(&self) -> bool {
2144 self.feature_flags.enable_poseidon
2145 }
2146
2147 pub fn enable_coin_deny_list_v1(&self) -> bool {
2148 self.feature_flags.enable_coin_deny_list
2149 }
2150
2151 pub fn enable_accumulators(&self) -> bool {
2152 self.feature_flags.enable_accumulators
2153 }
2154
2155 pub fn enable_coin_reservation_obj_refs(&self) -> bool {
2156 self.feature_flags.enable_coin_reservation_obj_refs
2157 }
2158
2159 pub fn create_root_accumulator_object(&self) -> bool {
2160 self.feature_flags.create_root_accumulator_object
2161 }
2162
2163 pub fn enable_address_balance_gas_payments(&self) -> bool {
2164 self.feature_flags.enable_address_balance_gas_payments
2165 }
2166
2167 pub fn address_balance_gas_check_rgp_at_signing(&self) -> bool {
2168 self.feature_flags.address_balance_gas_check_rgp_at_signing
2169 }
2170
2171 pub fn address_balance_gas_reject_gas_coin_arg(&self) -> bool {
2172 self.feature_flags.address_balance_gas_reject_gas_coin_arg
2173 }
2174
2175 pub fn enable_multi_epoch_transaction_expiration(&self) -> bool {
2176 self.feature_flags.enable_multi_epoch_transaction_expiration
2177 }
2178
2179 pub fn enable_authenticated_event_streams(&self) -> bool {
2180 self.feature_flags.enable_authenticated_event_streams && self.enable_accumulators()
2181 }
2182
2183 pub fn enable_non_exclusive_writes(&self) -> bool {
2184 self.feature_flags.enable_non_exclusive_writes
2185 }
2186
2187 pub fn enable_coin_registry(&self) -> bool {
2188 self.feature_flags.enable_coin_registry
2189 }
2190
2191 pub fn enable_display_registry(&self) -> bool {
2192 self.feature_flags.enable_display_registry
2193 }
2194
2195 pub fn enable_coin_deny_list_v2(&self) -> bool {
2196 self.feature_flags.enable_coin_deny_list_v2
2197 }
2198
2199 pub fn enable_group_ops_native_functions(&self) -> bool {
2200 self.feature_flags.enable_group_ops_native_functions
2201 }
2202
2203 pub fn enable_group_ops_native_function_msm(&self) -> bool {
2204 self.feature_flags.enable_group_ops_native_function_msm
2205 }
2206
2207 pub fn enable_ristretto255_group_ops(&self) -> bool {
2208 self.feature_flags.enable_ristretto255_group_ops
2209 }
2210
2211 pub fn reject_mutable_random_on_entry_functions(&self) -> bool {
2212 self.feature_flags.reject_mutable_random_on_entry_functions
2213 }
2214
2215 pub fn per_object_congestion_control_mode(&self) -> PerObjectCongestionControlMode {
2216 self.feature_flags.per_object_congestion_control_mode
2217 }
2218
2219 pub fn consensus_choice(&self) -> ConsensusChoice {
2220 self.feature_flags.consensus_choice
2221 }
2222
2223 pub fn consensus_network(&self) -> ConsensusNetwork {
2224 self.feature_flags.consensus_network
2225 }
2226
2227 pub fn correct_gas_payment_limit_check(&self) -> bool {
2228 self.feature_flags.correct_gas_payment_limit_check
2229 }
2230
2231 pub fn reshare_at_same_initial_version(&self) -> bool {
2232 self.feature_flags.reshare_at_same_initial_version
2233 }
2234
2235 pub fn resolve_abort_locations_to_package_id(&self) -> bool {
2236 self.feature_flags.resolve_abort_locations_to_package_id
2237 }
2238
2239 pub fn mysticeti_use_committed_subdag_digest(&self) -> bool {
2240 self.feature_flags.mysticeti_use_committed_subdag_digest
2241 }
2242
2243 pub fn enable_vdf(&self) -> bool {
2244 self.feature_flags.enable_vdf
2245 }
2246
2247 pub fn fresh_vm_on_framework_upgrade(&self) -> bool {
2248 self.feature_flags.fresh_vm_on_framework_upgrade
2249 }
2250
2251 pub fn mysticeti_num_leaders_per_round(&self) -> Option<usize> {
2252 self.feature_flags.mysticeti_num_leaders_per_round
2253 }
2254
2255 pub fn soft_bundle(&self) -> bool {
2256 self.feature_flags.soft_bundle
2257 }
2258
2259 pub fn passkey_auth(&self) -> bool {
2260 self.feature_flags.passkey_auth
2261 }
2262
2263 pub fn authority_capabilities_v2(&self) -> bool {
2264 self.feature_flags.authority_capabilities_v2
2265 }
2266
2267 pub fn max_transaction_size_bytes(&self) -> u64 {
2268 self.consensus_max_transaction_size_bytes
2270 .unwrap_or(256 * 1024)
2271 }
2272
2273 pub fn max_transactions_in_block_bytes(&self) -> u64 {
2274 if cfg!(msim) {
2275 256 * 1024
2276 } else {
2277 self.consensus_max_transactions_in_block_bytes
2278 .unwrap_or(512 * 1024)
2279 }
2280 }
2281
2282 pub fn max_num_transactions_in_block(&self) -> u64 {
2283 if cfg!(msim) {
2284 8
2285 } else {
2286 self.consensus_max_num_transactions_in_block.unwrap_or(512)
2287 }
2288 }
2289
2290 pub fn rethrow_serialization_type_layout_errors(&self) -> bool {
2291 self.feature_flags.rethrow_serialization_type_layout_errors
2292 }
2293
2294 pub fn consensus_distributed_vote_scoring_strategy(&self) -> bool {
2295 self.feature_flags
2296 .consensus_distributed_vote_scoring_strategy
2297 }
2298
2299 pub fn consensus_round_prober(&self) -> bool {
2300 self.feature_flags.consensus_round_prober
2301 }
2302
2303 pub fn validate_identifier_inputs(&self) -> bool {
2304 self.feature_flags.validate_identifier_inputs
2305 }
2306
2307 pub fn gc_depth(&self) -> u32 {
2308 self.consensus_gc_depth.unwrap_or(0)
2309 }
2310
2311 pub fn mysticeti_fastpath(&self) -> bool {
2312 self.feature_flags.mysticeti_fastpath
2313 }
2314
2315 pub fn relocate_event_module(&self) -> bool {
2316 self.feature_flags.relocate_event_module
2317 }
2318
2319 pub fn uncompressed_g1_group_elements(&self) -> bool {
2320 self.feature_flags.uncompressed_g1_group_elements
2321 }
2322
2323 pub fn disallow_new_modules_in_deps_only_packages(&self) -> bool {
2324 self.feature_flags
2325 .disallow_new_modules_in_deps_only_packages
2326 }
2327
2328 pub fn consensus_smart_ancestor_selection(&self) -> bool {
2329 self.feature_flags.consensus_smart_ancestor_selection
2330 }
2331
2332 pub fn disable_preconsensus_locking(&self) -> bool {
2333 self.feature_flags.disable_preconsensus_locking
2334 }
2335
2336 pub fn consensus_round_prober_probe_accepted_rounds(&self) -> bool {
2337 self.feature_flags
2338 .consensus_round_prober_probe_accepted_rounds
2339 }
2340
2341 pub fn native_charging_v2(&self) -> bool {
2342 self.feature_flags.native_charging_v2
2343 }
2344
2345 pub fn consensus_linearize_subdag_v2(&self) -> bool {
2346 let res = self.feature_flags.consensus_linearize_subdag_v2;
2347 assert!(
2348 !res || self.gc_depth() > 0,
2349 "The consensus linearize sub dag V2 requires GC to be enabled"
2350 );
2351 res
2352 }
2353
2354 pub fn consensus_median_based_commit_timestamp(&self) -> bool {
2355 let res = self.feature_flags.consensus_median_based_commit_timestamp;
2356 assert!(
2357 !res || self.gc_depth() > 0,
2358 "The consensus median based commit timestamp requires GC to be enabled"
2359 );
2360 res
2361 }
2362
2363 pub fn consensus_batched_block_sync(&self) -> bool {
2364 self.feature_flags.consensus_batched_block_sync
2365 }
2366
2367 pub fn convert_type_argument_error(&self) -> bool {
2368 self.feature_flags.convert_type_argument_error
2369 }
2370
2371 pub fn variant_nodes(&self) -> bool {
2372 self.feature_flags.variant_nodes
2373 }
2374
2375 pub fn consensus_zstd_compression(&self) -> bool {
2376 self.feature_flags.consensus_zstd_compression
2377 }
2378
2379 pub fn enable_nitro_attestation(&self) -> bool {
2380 self.feature_flags.enable_nitro_attestation
2381 }
2382
2383 pub fn enable_nitro_attestation_upgraded_parsing(&self) -> bool {
2384 self.feature_flags.enable_nitro_attestation_upgraded_parsing
2385 }
2386
2387 pub fn enable_nitro_attestation_all_nonzero_pcrs_parsing(&self) -> bool {
2388 self.feature_flags
2389 .enable_nitro_attestation_all_nonzero_pcrs_parsing
2390 }
2391
2392 pub fn enable_nitro_attestation_always_include_required_pcrs_parsing(&self) -> bool {
2393 self.feature_flags
2394 .enable_nitro_attestation_always_include_required_pcrs_parsing
2395 }
2396
2397 pub fn get_consensus_commit_rate_estimation_window_size(&self) -> u32 {
2398 self.consensus_commit_rate_estimation_window_size
2399 .unwrap_or(0)
2400 }
2401
2402 pub fn consensus_num_requested_prior_commits_at_startup(&self) -> u32 {
2403 let window_size = self.get_consensus_commit_rate_estimation_window_size();
2407 assert!(window_size == 0 || self.record_additional_state_digest_in_prologue());
2409 window_size
2410 }
2411
2412 pub fn minimize_child_object_mutations(&self) -> bool {
2413 self.feature_flags.minimize_child_object_mutations
2414 }
2415
2416 pub fn move_native_context(&self) -> bool {
2417 self.feature_flags.move_native_context
2418 }
2419
2420 pub fn normalize_ptb_arguments(&self) -> bool {
2421 self.feature_flags.normalize_ptb_arguments
2422 }
2423
2424 pub fn enforce_checkpoint_timestamp_monotonicity(&self) -> bool {
2425 self.feature_flags.enforce_checkpoint_timestamp_monotonicity
2426 }
2427
2428 pub fn max_ptb_value_size_v2(&self) -> bool {
2429 self.feature_flags.max_ptb_value_size_v2
2430 }
2431
2432 pub fn resolve_type_input_ids_to_defining_id(&self) -> bool {
2433 self.feature_flags.resolve_type_input_ids_to_defining_id
2434 }
2435
2436 pub fn enable_party_transfer(&self) -> bool {
2437 self.feature_flags.enable_party_transfer
2438 }
2439
2440 pub fn allow_unbounded_system_objects(&self) -> bool {
2441 self.feature_flags.allow_unbounded_system_objects
2442 }
2443
2444 pub fn type_tags_in_object_runtime(&self) -> bool {
2445 self.feature_flags.type_tags_in_object_runtime
2446 }
2447
2448 pub fn enable_ptb_execution_v2(&self) -> bool {
2449 self.feature_flags.enable_ptb_execution_v2
2450 }
2451
2452 pub fn better_adapter_type_resolution_errors(&self) -> bool {
2453 self.feature_flags.better_adapter_type_resolution_errors
2454 }
2455
2456 pub fn record_time_estimate_processed(&self) -> bool {
2457 self.feature_flags.record_time_estimate_processed
2458 }
2459
2460 pub fn ignore_execution_time_observations_after_certs_closed(&self) -> bool {
2461 self.feature_flags
2462 .ignore_execution_time_observations_after_certs_closed
2463 }
2464
2465 pub fn dependency_linkage_error(&self) -> bool {
2466 self.feature_flags.dependency_linkage_error
2467 }
2468
2469 pub fn additional_multisig_checks(&self) -> bool {
2470 self.feature_flags.additional_multisig_checks
2471 }
2472
2473 pub fn debug_fatal_on_move_invariant_violation(&self) -> bool {
2474 self.feature_flags.debug_fatal_on_move_invariant_violation
2475 }
2476
2477 pub fn allow_private_accumulator_entrypoints(&self) -> bool {
2478 self.feature_flags.allow_private_accumulator_entrypoints
2479 }
2480
2481 pub fn additional_consensus_digest_indirect_state(&self) -> bool {
2482 self.feature_flags
2483 .additional_consensus_digest_indirect_state
2484 }
2485
2486 pub fn check_for_init_during_upgrade(&self) -> bool {
2487 self.feature_flags.check_for_init_during_upgrade
2488 }
2489
2490 pub fn per_command_shared_object_transfer_rules(&self) -> bool {
2491 self.feature_flags.per_command_shared_object_transfer_rules
2492 }
2493
2494 pub fn consensus_checkpoint_signature_key_includes_digest(&self) -> bool {
2495 self.feature_flags
2496 .consensus_checkpoint_signature_key_includes_digest
2497 }
2498
2499 pub fn include_checkpoint_artifacts_digest_in_summary(&self) -> bool {
2500 self.feature_flags
2501 .include_checkpoint_artifacts_digest_in_summary
2502 }
2503
2504 pub fn use_mfp_txns_in_load_initial_object_debts(&self) -> bool {
2505 self.feature_flags.use_mfp_txns_in_load_initial_object_debts
2506 }
2507
2508 pub fn cancel_for_failed_dkg_early(&self) -> bool {
2509 self.feature_flags.cancel_for_failed_dkg_early
2510 }
2511
2512 pub fn abstract_size_in_object_runtime(&self) -> bool {
2513 self.feature_flags.abstract_size_in_object_runtime
2514 }
2515
2516 pub fn object_runtime_charge_cache_load_gas(&self) -> bool {
2517 self.feature_flags.object_runtime_charge_cache_load_gas
2518 }
2519
2520 pub fn additional_borrow_checks(&self) -> bool {
2521 self.feature_flags.additional_borrow_checks
2522 }
2523
2524 pub fn use_new_commit_handler(&self) -> bool {
2525 self.feature_flags.use_new_commit_handler
2526 }
2527
2528 pub fn better_loader_errors(&self) -> bool {
2529 self.feature_flags.better_loader_errors
2530 }
2531
2532 pub fn generate_df_type_layouts(&self) -> bool {
2533 self.feature_flags.generate_df_type_layouts
2534 }
2535
2536 pub fn allow_references_in_ptbs(&self) -> bool {
2537 self.feature_flags.allow_references_in_ptbs
2538 }
2539
2540 pub fn private_generics_verifier_v2(&self) -> bool {
2541 self.feature_flags.private_generics_verifier_v2
2542 }
2543
2544 pub fn deprecate_global_storage_ops_during_deserialization(&self) -> bool {
2545 self.feature_flags
2546 .deprecate_global_storage_ops_during_deserialization
2547 }
2548
2549 pub fn enable_observation_chunking(&self) -> bool {
2550 matches!(self.feature_flags.per_object_congestion_control_mode,
2551 PerObjectCongestionControlMode::ExecutionTimeEstimate(ref params)
2552 if params.observations_chunk_size.is_some()
2553 )
2554 }
2555
2556 pub fn deprecate_global_storage_ops(&self) -> bool {
2557 self.feature_flags.deprecate_global_storage_ops
2558 }
2559
2560 pub fn consensus_skip_gced_accept_votes(&self) -> bool {
2561 self.feature_flags.consensus_skip_gced_accept_votes
2562 }
2563
2564 pub fn include_cancelled_randomness_txns_in_prologue(&self) -> bool {
2565 self.feature_flags
2566 .include_cancelled_randomness_txns_in_prologue
2567 }
2568
2569 pub fn address_aliases(&self) -> bool {
2570 let address_aliases = self.feature_flags.address_aliases;
2571 assert!(
2572 !address_aliases || self.mysticeti_fastpath(),
2573 "Address aliases requires Mysticeti fastpath to be enabled"
2574 );
2575 if address_aliases {
2576 assert!(
2577 self.feature_flags.disable_preconsensus_locking,
2578 "Address aliases requires CertifiedTransaction to be disabled"
2579 );
2580 }
2581 address_aliases
2582 }
2583
2584 pub fn fix_checkpoint_signature_mapping(&self) -> bool {
2585 self.feature_flags.fix_checkpoint_signature_mapping
2586 }
2587
2588 pub fn enable_object_funds_withdraw(&self) -> bool {
2589 self.feature_flags.enable_object_funds_withdraw
2590 }
2591
2592 pub fn gas_rounding_halve_digits(&self) -> bool {
2593 self.feature_flags.gas_rounding_halve_digits
2594 }
2595
2596 pub fn flexible_tx_context_positions(&self) -> bool {
2597 self.feature_flags.flexible_tx_context_positions
2598 }
2599
2600 pub fn disable_entry_point_signature_check(&self) -> bool {
2601 self.feature_flags.disable_entry_point_signature_check
2602 }
2603
2604 pub fn consensus_skip_gced_blocks_in_direct_finalization(&self) -> bool {
2605 self.feature_flags
2606 .consensus_skip_gced_blocks_in_direct_finalization
2607 }
2608
2609 pub fn convert_withdrawal_compatibility_ptb_arguments(&self) -> bool {
2610 self.feature_flags
2611 .convert_withdrawal_compatibility_ptb_arguments
2612 }
2613
2614 pub fn restrict_hot_or_not_entry_functions(&self) -> bool {
2615 self.feature_flags.restrict_hot_or_not_entry_functions
2616 }
2617
2618 pub fn split_checkpoints_in_consensus_handler(&self) -> bool {
2619 self.feature_flags.split_checkpoints_in_consensus_handler
2620 }
2621
2622 pub fn consensus_always_accept_system_transactions(&self) -> bool {
2623 self.feature_flags
2624 .consensus_always_accept_system_transactions
2625 }
2626
2627 pub fn validator_metadata_verify_v2(&self) -> bool {
2628 self.feature_flags.validator_metadata_verify_v2
2629 }
2630
2631 pub fn defer_unpaid_amplification(&self) -> bool {
2632 self.feature_flags.defer_unpaid_amplification
2633 }
2634}
2635
2636#[cfg(not(msim))]
2637static POISON_VERSION_METHODS: AtomicBool = AtomicBool::new(false);
2638
2639#[cfg(msim)]
2641thread_local! {
2642 static POISON_VERSION_METHODS: AtomicBool = AtomicBool::new(false);
2643}
2644
2645impl ProtocolConfig {
2647 pub fn get_for_version(version: ProtocolVersion, chain: Chain) -> Self {
2649 assert!(
2651 version >= ProtocolVersion::MIN,
2652 "Network protocol version is {:?}, but the minimum supported version by the binary is {:?}. Please upgrade the binary.",
2653 version,
2654 ProtocolVersion::MIN.0,
2655 );
2656 assert!(
2657 version <= ProtocolVersion::MAX_ALLOWED,
2658 "Network protocol version is {:?}, but the maximum supported version by the binary is {:?}. Please upgrade the binary.",
2659 version,
2660 ProtocolVersion::MAX_ALLOWED.0,
2661 );
2662
2663 let mut ret = Self::get_for_version_impl(version, chain);
2664 ret.version = version;
2665
2666 ret = CONFIG_OVERRIDE.with(|ovr| {
2667 if let Some(override_fn) = &*ovr.borrow() {
2668 warn!(
2669 "overriding ProtocolConfig settings with custom settings (you should not see this log outside of tests)"
2670 );
2671 override_fn(version, ret)
2672 } else {
2673 ret
2674 }
2675 });
2676
2677 if std::env::var("SUI_PROTOCOL_CONFIG_OVERRIDE_ENABLE").is_ok() {
2678 warn!(
2679 "overriding ProtocolConfig settings with custom settings; this may break non-local networks"
2680 );
2681 let overrides: ProtocolConfigOptional =
2682 serde_env::from_env_with_prefix("SUI_PROTOCOL_CONFIG_OVERRIDE")
2683 .expect("failed to parse ProtocolConfig override env variables");
2684 overrides.apply_to(&mut ret);
2685 }
2686
2687 ret
2688 }
2689
2690 pub fn get_for_version_if_supported(version: ProtocolVersion, chain: Chain) -> Option<Self> {
2693 if version.0 >= ProtocolVersion::MIN.0 && version.0 <= ProtocolVersion::MAX_ALLOWED.0 {
2694 let mut ret = Self::get_for_version_impl(version, chain);
2695 ret.version = version;
2696 Some(ret)
2697 } else {
2698 None
2699 }
2700 }
2701
2702 #[cfg(not(msim))]
2703 pub fn poison_get_for_min_version() {
2704 POISON_VERSION_METHODS.store(true, Ordering::Relaxed);
2705 }
2706
2707 #[cfg(not(msim))]
2708 fn load_poison_get_for_min_version() -> bool {
2709 POISON_VERSION_METHODS.load(Ordering::Relaxed)
2710 }
2711
2712 #[cfg(msim)]
2713 pub fn poison_get_for_min_version() {
2714 POISON_VERSION_METHODS.with(|p| p.store(true, Ordering::Relaxed));
2715 }
2716
2717 #[cfg(msim)]
2718 fn load_poison_get_for_min_version() -> bool {
2719 POISON_VERSION_METHODS.with(|p| p.load(Ordering::Relaxed))
2720 }
2721
2722 pub fn get_for_min_version() -> Self {
2725 if Self::load_poison_get_for_min_version() {
2726 panic!("get_for_min_version called on validator");
2727 }
2728 ProtocolConfig::get_for_version(ProtocolVersion::MIN, Chain::Unknown)
2729 }
2730
2731 #[allow(non_snake_case)]
2741 pub fn get_for_max_version_UNSAFE() -> Self {
2742 if Self::load_poison_get_for_min_version() {
2743 panic!("get_for_max_version_UNSAFE called on validator");
2744 }
2745 ProtocolConfig::get_for_version(ProtocolVersion::MAX, Chain::Unknown)
2746 }
2747
2748 fn get_for_version_impl(version: ProtocolVersion, chain: Chain) -> Self {
2749 #[cfg(msim)]
2750 {
2751 if version == ProtocolVersion::MAX_ALLOWED {
2753 let mut config = Self::get_for_version_impl(version - 1, Chain::Unknown);
2754 config.base_tx_cost_fixed = Some(config.base_tx_cost_fixed() + 1000);
2755 return config;
2756 }
2757 }
2758
2759 let mut cfg = Self {
2762 version,
2764
2765 feature_flags: Default::default(),
2767
2768 max_tx_size_bytes: Some(128 * 1024),
2769 max_input_objects: Some(2048),
2771 max_serialized_tx_effects_size_bytes: Some(512 * 1024),
2772 max_serialized_tx_effects_size_bytes_system_tx: Some(512 * 1024 * 16),
2773 max_gas_payment_objects: Some(256),
2774 max_modules_in_publish: Some(128),
2775 max_package_dependencies: None,
2776 max_arguments: Some(512),
2777 max_type_arguments: Some(16),
2778 max_type_argument_depth: Some(16),
2779 max_pure_argument_size: Some(16 * 1024),
2780 max_programmable_tx_commands: Some(1024),
2781 move_binary_format_version: Some(6),
2782 min_move_binary_format_version: None,
2783 binary_module_handles: None,
2784 binary_struct_handles: None,
2785 binary_function_handles: None,
2786 binary_function_instantiations: None,
2787 binary_signatures: None,
2788 binary_constant_pool: None,
2789 binary_identifiers: None,
2790 binary_address_identifiers: None,
2791 binary_struct_defs: None,
2792 binary_struct_def_instantiations: None,
2793 binary_function_defs: None,
2794 binary_field_handles: None,
2795 binary_field_instantiations: None,
2796 binary_friend_decls: None,
2797 binary_enum_defs: None,
2798 binary_enum_def_instantiations: None,
2799 binary_variant_handles: None,
2800 binary_variant_instantiation_handles: None,
2801 max_move_object_size: Some(250 * 1024),
2802 max_move_package_size: Some(100 * 1024),
2803 max_publish_or_upgrade_per_ptb: None,
2804 max_tx_gas: Some(10_000_000_000),
2805 max_gas_price: Some(100_000),
2806 max_gas_price_rgp_factor_for_aborted_transactions: None,
2807 max_gas_computation_bucket: Some(5_000_000),
2808 max_loop_depth: Some(5),
2809 max_generic_instantiation_length: Some(32),
2810 max_function_parameters: Some(128),
2811 max_basic_blocks: Some(1024),
2812 max_value_stack_size: Some(1024),
2813 max_type_nodes: Some(256),
2814 max_push_size: Some(10000),
2815 max_struct_definitions: Some(200),
2816 max_function_definitions: Some(1000),
2817 max_fields_in_struct: Some(32),
2818 max_dependency_depth: Some(100),
2819 max_num_event_emit: Some(256),
2820 max_num_new_move_object_ids: Some(2048),
2821 max_num_new_move_object_ids_system_tx: Some(2048 * 16),
2822 max_num_deleted_move_object_ids: Some(2048),
2823 max_num_deleted_move_object_ids_system_tx: Some(2048 * 16),
2824 max_num_transferred_move_object_ids: Some(2048),
2825 max_num_transferred_move_object_ids_system_tx: Some(2048 * 16),
2826 max_event_emit_size: Some(250 * 1024),
2827 max_move_vector_len: Some(256 * 1024),
2828 max_type_to_layout_nodes: None,
2829 max_ptb_value_size: None,
2830
2831 max_back_edges_per_function: Some(10_000),
2832 max_back_edges_per_module: Some(10_000),
2833 max_verifier_meter_ticks_per_function: Some(6_000_000),
2834 max_meter_ticks_per_module: Some(6_000_000),
2835 max_meter_ticks_per_package: None,
2836
2837 object_runtime_max_num_cached_objects: Some(1000),
2838 object_runtime_max_num_cached_objects_system_tx: Some(1000 * 16),
2839 object_runtime_max_num_store_entries: Some(1000),
2840 object_runtime_max_num_store_entries_system_tx: Some(1000 * 16),
2841 base_tx_cost_fixed: Some(110_000),
2842 package_publish_cost_fixed: Some(1_000),
2843 base_tx_cost_per_byte: Some(0),
2844 package_publish_cost_per_byte: Some(80),
2845 obj_access_cost_read_per_byte: Some(15),
2846 obj_access_cost_mutate_per_byte: Some(40),
2847 obj_access_cost_delete_per_byte: Some(40),
2848 obj_access_cost_verify_per_byte: Some(200),
2849 obj_data_cost_refundable: Some(100),
2850 obj_metadata_cost_non_refundable: Some(50),
2851 gas_model_version: Some(1),
2852 storage_rebate_rate: Some(9900),
2853 storage_fund_reinvest_rate: Some(500),
2854 reward_slashing_rate: Some(5000),
2855 storage_gas_price: Some(1),
2856 accumulator_object_storage_cost: None,
2857 max_transactions_per_checkpoint: Some(10_000),
2858 max_checkpoint_size_bytes: Some(30 * 1024 * 1024),
2859
2860 buffer_stake_for_protocol_upgrade_bps: Some(0),
2863
2864 address_from_bytes_cost_base: Some(52),
2868 address_to_u256_cost_base: Some(52),
2870 address_from_u256_cost_base: Some(52),
2872
2873 config_read_setting_impl_cost_base: None,
2876 config_read_setting_impl_cost_per_byte: None,
2877
2878 dynamic_field_hash_type_and_key_cost_base: Some(100),
2881 dynamic_field_hash_type_and_key_type_cost_per_byte: Some(2),
2882 dynamic_field_hash_type_and_key_value_cost_per_byte: Some(2),
2883 dynamic_field_hash_type_and_key_type_tag_cost_per_byte: Some(2),
2884 dynamic_field_add_child_object_cost_base: Some(100),
2886 dynamic_field_add_child_object_type_cost_per_byte: Some(10),
2887 dynamic_field_add_child_object_value_cost_per_byte: Some(10),
2888 dynamic_field_add_child_object_struct_tag_cost_per_byte: Some(10),
2889 dynamic_field_borrow_child_object_cost_base: Some(100),
2891 dynamic_field_borrow_child_object_child_ref_cost_per_byte: Some(10),
2892 dynamic_field_borrow_child_object_type_cost_per_byte: Some(10),
2893 dynamic_field_remove_child_object_cost_base: Some(100),
2895 dynamic_field_remove_child_object_child_cost_per_byte: Some(2),
2896 dynamic_field_remove_child_object_type_cost_per_byte: Some(2),
2897 dynamic_field_has_child_object_cost_base: Some(100),
2899 dynamic_field_has_child_object_with_ty_cost_base: Some(100),
2901 dynamic_field_has_child_object_with_ty_type_cost_per_byte: Some(2),
2902 dynamic_field_has_child_object_with_ty_type_tag_cost_per_byte: Some(2),
2903
2904 event_emit_cost_base: Some(52),
2907 event_emit_value_size_derivation_cost_per_byte: Some(2),
2908 event_emit_tag_size_derivation_cost_per_byte: Some(5),
2909 event_emit_output_cost_per_byte: Some(10),
2910 event_emit_auth_stream_cost: None,
2911
2912 object_borrow_uid_cost_base: Some(52),
2915 object_delete_impl_cost_base: Some(52),
2917 object_record_new_uid_cost_base: Some(52),
2919
2920 transfer_transfer_internal_cost_base: Some(52),
2923 transfer_party_transfer_internal_cost_base: None,
2925 transfer_freeze_object_cost_base: Some(52),
2927 transfer_share_object_cost_base: Some(52),
2929 transfer_receive_object_cost_base: None,
2930
2931 tx_context_derive_id_cost_base: Some(52),
2934 tx_context_fresh_id_cost_base: None,
2935 tx_context_sender_cost_base: None,
2936 tx_context_epoch_cost_base: None,
2937 tx_context_epoch_timestamp_ms_cost_base: None,
2938 tx_context_sponsor_cost_base: None,
2939 tx_context_rgp_cost_base: None,
2940 tx_context_gas_price_cost_base: None,
2941 tx_context_gas_budget_cost_base: None,
2942 tx_context_ids_created_cost_base: None,
2943 tx_context_replace_cost_base: None,
2944
2945 types_is_one_time_witness_cost_base: Some(52),
2948 types_is_one_time_witness_type_tag_cost_per_byte: Some(2),
2949 types_is_one_time_witness_type_cost_per_byte: Some(2),
2950
2951 validator_validate_metadata_cost_base: Some(52),
2954 validator_validate_metadata_data_cost_per_byte: Some(2),
2955
2956 crypto_invalid_arguments_cost: Some(100),
2958 bls12381_bls12381_min_sig_verify_cost_base: Some(52),
2960 bls12381_bls12381_min_sig_verify_msg_cost_per_byte: Some(2),
2961 bls12381_bls12381_min_sig_verify_msg_cost_per_block: Some(2),
2962
2963 bls12381_bls12381_min_pk_verify_cost_base: Some(52),
2965 bls12381_bls12381_min_pk_verify_msg_cost_per_byte: Some(2),
2966 bls12381_bls12381_min_pk_verify_msg_cost_per_block: Some(2),
2967
2968 ecdsa_k1_ecrecover_keccak256_cost_base: Some(52),
2970 ecdsa_k1_ecrecover_keccak256_msg_cost_per_byte: Some(2),
2971 ecdsa_k1_ecrecover_keccak256_msg_cost_per_block: Some(2),
2972 ecdsa_k1_ecrecover_sha256_cost_base: Some(52),
2973 ecdsa_k1_ecrecover_sha256_msg_cost_per_byte: Some(2),
2974 ecdsa_k1_ecrecover_sha256_msg_cost_per_block: Some(2),
2975
2976 ecdsa_k1_decompress_pubkey_cost_base: Some(52),
2978
2979 ecdsa_k1_secp256k1_verify_keccak256_cost_base: Some(52),
2981 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_byte: Some(2),
2982 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_block: Some(2),
2983 ecdsa_k1_secp256k1_verify_sha256_cost_base: Some(52),
2984 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_byte: Some(2),
2985 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_block: Some(2),
2986
2987 ecdsa_r1_ecrecover_keccak256_cost_base: Some(52),
2989 ecdsa_r1_ecrecover_keccak256_msg_cost_per_byte: Some(2),
2990 ecdsa_r1_ecrecover_keccak256_msg_cost_per_block: Some(2),
2991 ecdsa_r1_ecrecover_sha256_cost_base: Some(52),
2992 ecdsa_r1_ecrecover_sha256_msg_cost_per_byte: Some(2),
2993 ecdsa_r1_ecrecover_sha256_msg_cost_per_block: Some(2),
2994
2995 ecdsa_r1_secp256r1_verify_keccak256_cost_base: Some(52),
2997 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_byte: Some(2),
2998 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_block: Some(2),
2999 ecdsa_r1_secp256r1_verify_sha256_cost_base: Some(52),
3000 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_byte: Some(2),
3001 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_block: Some(2),
3002
3003 ecvrf_ecvrf_verify_cost_base: Some(52),
3005 ecvrf_ecvrf_verify_alpha_string_cost_per_byte: Some(2),
3006 ecvrf_ecvrf_verify_alpha_string_cost_per_block: Some(2),
3007
3008 ed25519_ed25519_verify_cost_base: Some(52),
3010 ed25519_ed25519_verify_msg_cost_per_byte: Some(2),
3011 ed25519_ed25519_verify_msg_cost_per_block: Some(2),
3012
3013 groth16_prepare_verifying_key_bls12381_cost_base: Some(52),
3015 groth16_prepare_verifying_key_bn254_cost_base: Some(52),
3016
3017 groth16_verify_groth16_proof_internal_bls12381_cost_base: Some(52),
3019 groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input: Some(2),
3020 groth16_verify_groth16_proof_internal_bn254_cost_base: Some(52),
3021 groth16_verify_groth16_proof_internal_bn254_cost_per_public_input: Some(2),
3022 groth16_verify_groth16_proof_internal_public_input_cost_per_byte: Some(2),
3023
3024 hash_blake2b256_cost_base: Some(52),
3026 hash_blake2b256_data_cost_per_byte: Some(2),
3027 hash_blake2b256_data_cost_per_block: Some(2),
3028
3029 hash_keccak256_cost_base: Some(52),
3031 hash_keccak256_data_cost_per_byte: Some(2),
3032 hash_keccak256_data_cost_per_block: Some(2),
3033
3034 poseidon_bn254_cost_base: None,
3035 poseidon_bn254_cost_per_block: None,
3036
3037 hmac_hmac_sha3_256_cost_base: Some(52),
3039 hmac_hmac_sha3_256_input_cost_per_byte: Some(2),
3040 hmac_hmac_sha3_256_input_cost_per_block: Some(2),
3041
3042 group_ops_bls12381_decode_scalar_cost: None,
3044 group_ops_bls12381_decode_g1_cost: None,
3045 group_ops_bls12381_decode_g2_cost: None,
3046 group_ops_bls12381_decode_gt_cost: None,
3047 group_ops_bls12381_scalar_add_cost: None,
3048 group_ops_bls12381_g1_add_cost: None,
3049 group_ops_bls12381_g2_add_cost: None,
3050 group_ops_bls12381_gt_add_cost: None,
3051 group_ops_bls12381_scalar_sub_cost: None,
3052 group_ops_bls12381_g1_sub_cost: None,
3053 group_ops_bls12381_g2_sub_cost: None,
3054 group_ops_bls12381_gt_sub_cost: None,
3055 group_ops_bls12381_scalar_mul_cost: None,
3056 group_ops_bls12381_g1_mul_cost: None,
3057 group_ops_bls12381_g2_mul_cost: None,
3058 group_ops_bls12381_gt_mul_cost: None,
3059 group_ops_bls12381_scalar_div_cost: None,
3060 group_ops_bls12381_g1_div_cost: None,
3061 group_ops_bls12381_g2_div_cost: None,
3062 group_ops_bls12381_gt_div_cost: None,
3063 group_ops_bls12381_g1_hash_to_base_cost: None,
3064 group_ops_bls12381_g2_hash_to_base_cost: None,
3065 group_ops_bls12381_g1_hash_to_cost_per_byte: None,
3066 group_ops_bls12381_g2_hash_to_cost_per_byte: None,
3067 group_ops_bls12381_g1_msm_base_cost: None,
3068 group_ops_bls12381_g2_msm_base_cost: None,
3069 group_ops_bls12381_g1_msm_base_cost_per_input: None,
3070 group_ops_bls12381_g2_msm_base_cost_per_input: None,
3071 group_ops_bls12381_msm_max_len: None,
3072 group_ops_bls12381_pairing_cost: None,
3073 group_ops_bls12381_g1_to_uncompressed_g1_cost: None,
3074 group_ops_bls12381_uncompressed_g1_to_g1_cost: None,
3075 group_ops_bls12381_uncompressed_g1_sum_base_cost: None,
3076 group_ops_bls12381_uncompressed_g1_sum_cost_per_term: None,
3077 group_ops_bls12381_uncompressed_g1_sum_max_terms: None,
3078
3079 group_ops_ristretto_decode_scalar_cost: None,
3080 group_ops_ristretto_decode_point_cost: None,
3081 group_ops_ristretto_scalar_add_cost: None,
3082 group_ops_ristretto_point_add_cost: None,
3083 group_ops_ristretto_scalar_sub_cost: None,
3084 group_ops_ristretto_point_sub_cost: None,
3085 group_ops_ristretto_scalar_mul_cost: None,
3086 group_ops_ristretto_point_mul_cost: None,
3087 group_ops_ristretto_scalar_div_cost: None,
3088 group_ops_ristretto_point_div_cost: None,
3089
3090 check_zklogin_id_cost_base: None,
3092 check_zklogin_issuer_cost_base: None,
3094
3095 vdf_verify_vdf_cost: None,
3096 vdf_hash_to_input_cost: None,
3097
3098 nitro_attestation_parse_base_cost: None,
3100 nitro_attestation_parse_cost_per_byte: None,
3101 nitro_attestation_verify_base_cost: None,
3102 nitro_attestation_verify_cost_per_cert: None,
3103
3104 bcs_per_byte_serialized_cost: None,
3105 bcs_legacy_min_output_size_cost: None,
3106 bcs_failure_cost: None,
3107 hash_sha2_256_base_cost: None,
3108 hash_sha2_256_per_byte_cost: None,
3109 hash_sha2_256_legacy_min_input_len_cost: None,
3110 hash_sha3_256_base_cost: None,
3111 hash_sha3_256_per_byte_cost: None,
3112 hash_sha3_256_legacy_min_input_len_cost: None,
3113 type_name_get_base_cost: None,
3114 type_name_get_per_byte_cost: None,
3115 type_name_id_base_cost: None,
3116 string_check_utf8_base_cost: None,
3117 string_check_utf8_per_byte_cost: None,
3118 string_is_char_boundary_base_cost: None,
3119 string_sub_string_base_cost: None,
3120 string_sub_string_per_byte_cost: None,
3121 string_index_of_base_cost: None,
3122 string_index_of_per_byte_pattern_cost: None,
3123 string_index_of_per_byte_searched_cost: None,
3124 vector_empty_base_cost: None,
3125 vector_length_base_cost: None,
3126 vector_push_back_base_cost: None,
3127 vector_push_back_legacy_per_abstract_memory_unit_cost: None,
3128 vector_borrow_base_cost: None,
3129 vector_pop_back_base_cost: None,
3130 vector_destroy_empty_base_cost: None,
3131 vector_swap_base_cost: None,
3132 debug_print_base_cost: None,
3133 debug_print_stack_trace_base_cost: None,
3134
3135 max_size_written_objects: None,
3136 max_size_written_objects_system_tx: None,
3137
3138 max_move_identifier_len: None,
3145 max_move_value_depth: None,
3146 max_move_enum_variants: None,
3147
3148 gas_rounding_step: None,
3149
3150 execution_version: None,
3151
3152 max_event_emit_size_total: None,
3153
3154 consensus_bad_nodes_stake_threshold: None,
3155
3156 max_jwk_votes_per_validator_per_epoch: None,
3157
3158 max_age_of_jwk_in_epochs: None,
3159
3160 random_beacon_reduction_allowed_delta: None,
3161
3162 random_beacon_reduction_lower_bound: None,
3163
3164 random_beacon_dkg_timeout_round: None,
3165
3166 random_beacon_min_round_interval_ms: None,
3167
3168 random_beacon_dkg_version: None,
3169
3170 consensus_max_transaction_size_bytes: None,
3171
3172 consensus_max_transactions_in_block_bytes: None,
3173
3174 consensus_max_num_transactions_in_block: None,
3175
3176 consensus_voting_rounds: None,
3177
3178 max_accumulated_txn_cost_per_object_in_narwhal_commit: None,
3179
3180 max_deferral_rounds_for_congestion_control: None,
3181
3182 max_txn_cost_overage_per_object_in_commit: None,
3183
3184 allowed_txn_cost_overage_burst_per_object_in_commit: None,
3185
3186 min_checkpoint_interval_ms: None,
3187
3188 checkpoint_summary_version_specific_data: None,
3189
3190 max_soft_bundle_size: None,
3191
3192 bridge_should_try_to_finalize_committee: None,
3193
3194 max_accumulated_txn_cost_per_object_in_mysticeti_commit: None,
3195
3196 max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit: None,
3197
3198 consensus_gc_depth: None,
3199
3200 gas_budget_based_txn_cost_cap_factor: None,
3201
3202 gas_budget_based_txn_cost_absolute_cap_commit_count: None,
3203
3204 sip_45_consensus_amplification_threshold: None,
3205
3206 use_object_per_epoch_marker_table_v2: None,
3207
3208 consensus_commit_rate_estimation_window_size: None,
3209
3210 aliased_addresses: vec![],
3211
3212 translation_per_command_base_charge: None,
3213 translation_per_input_base_charge: None,
3214 translation_pure_input_per_byte_charge: None,
3215 translation_per_type_node_charge: None,
3216 translation_per_reference_node_charge: None,
3217 translation_per_linkage_entry_charge: None,
3218
3219 max_updates_per_settlement_txn: None,
3220 };
3223 for cur in 2..=version.0 {
3224 match cur {
3225 1 => unreachable!(),
3226 2 => {
3227 cfg.feature_flags.advance_epoch_start_time_in_safe_mode = true;
3228 }
3229 3 => {
3230 cfg.gas_model_version = Some(2);
3232 cfg.max_tx_gas = Some(50_000_000_000);
3234 cfg.base_tx_cost_fixed = Some(2_000);
3236 cfg.storage_gas_price = Some(76);
3238 cfg.feature_flags.loaded_child_objects_fixed = true;
3239 cfg.max_size_written_objects = Some(5 * 1000 * 1000);
3242 cfg.max_size_written_objects_system_tx = Some(50 * 1000 * 1000);
3245 cfg.feature_flags.package_upgrades = true;
3246 }
3247 4 => {
3252 cfg.reward_slashing_rate = Some(10000);
3254 cfg.gas_model_version = Some(3);
3256 }
3257 5 => {
3258 cfg.feature_flags.missing_type_is_compatibility_error = true;
3259 cfg.gas_model_version = Some(4);
3260 cfg.feature_flags.scoring_decision_with_validity_cutoff = true;
3261 }
3265 6 => {
3266 cfg.gas_model_version = Some(5);
3267 cfg.buffer_stake_for_protocol_upgrade_bps = Some(5000);
3268 cfg.feature_flags.consensus_order_end_of_epoch_last = true;
3269 }
3270 7 => {
3271 cfg.feature_flags.disallow_adding_abilities_on_upgrade = true;
3272 cfg.feature_flags
3273 .disable_invariant_violation_check_in_swap_loc = true;
3274 cfg.feature_flags.ban_entry_init = true;
3275 cfg.feature_flags.package_digest_hash_module = true;
3276 }
3277 8 => {
3278 cfg.feature_flags
3279 .disallow_change_struct_type_params_on_upgrade = true;
3280 }
3281 9 => {
3282 cfg.max_move_identifier_len = Some(128);
3284 cfg.feature_flags.no_extraneous_module_bytes = true;
3285 cfg.feature_flags
3286 .advance_to_highest_supported_protocol_version = true;
3287 }
3288 10 => {
3289 cfg.max_verifier_meter_ticks_per_function = Some(16_000_000);
3290 cfg.max_meter_ticks_per_module = Some(16_000_000);
3291 }
3292 11 => {
3293 cfg.max_move_value_depth = Some(128);
3294 }
3295 12 => {
3296 cfg.feature_flags.narwhal_versioned_metadata = true;
3297 if chain != Chain::Mainnet {
3298 cfg.feature_flags.commit_root_state_digest = true;
3299 }
3300
3301 if chain != Chain::Mainnet && chain != Chain::Testnet {
3302 cfg.feature_flags.zklogin_auth = true;
3303 }
3304 }
3305 13 => {}
3306 14 => {
3307 cfg.gas_rounding_step = Some(1_000);
3308 cfg.gas_model_version = Some(6);
3309 }
3310 15 => {
3311 cfg.feature_flags.consensus_transaction_ordering =
3312 ConsensusTransactionOrdering::ByGasPrice;
3313 }
3314 16 => {
3315 cfg.feature_flags.simplified_unwrap_then_delete = true;
3316 }
3317 17 => {
3318 cfg.feature_flags.upgraded_multisig_supported = true;
3319 }
3320 18 => {
3321 cfg.execution_version = Some(1);
3322 cfg.feature_flags.txn_base_cost_as_multiplier = true;
3331 cfg.base_tx_cost_fixed = Some(1_000);
3333 }
3334 19 => {
3335 cfg.max_num_event_emit = Some(1024);
3336 cfg.max_event_emit_size_total = Some(
3339 256 * 250 * 1024, );
3341 }
3342 20 => {
3343 cfg.feature_flags.commit_root_state_digest = true;
3344
3345 if chain != Chain::Mainnet {
3346 cfg.feature_flags.narwhal_new_leader_election_schedule = true;
3347 cfg.consensus_bad_nodes_stake_threshold = Some(20);
3348 }
3349 }
3350
3351 21 => {
3352 if chain != Chain::Mainnet {
3353 cfg.feature_flags.zklogin_supported_providers = BTreeSet::from([
3354 "Google".to_string(),
3355 "Facebook".to_string(),
3356 "Twitch".to_string(),
3357 ]);
3358 }
3359 }
3360 22 => {
3361 cfg.feature_flags.loaded_child_object_format = true;
3362 }
3363 23 => {
3364 cfg.feature_flags.loaded_child_object_format_type = true;
3365 cfg.feature_flags.narwhal_new_leader_election_schedule = true;
3366 cfg.consensus_bad_nodes_stake_threshold = Some(20);
3372 }
3373 24 => {
3374 cfg.feature_flags.simple_conservation_checks = true;
3375 cfg.max_publish_or_upgrade_per_ptb = Some(5);
3376
3377 cfg.feature_flags.end_of_epoch_transaction_supported = true;
3378
3379 if chain != Chain::Mainnet {
3380 cfg.feature_flags.enable_jwk_consensus_updates = true;
3381 cfg.max_jwk_votes_per_validator_per_epoch = Some(240);
3383 cfg.max_age_of_jwk_in_epochs = Some(1);
3384 }
3385 }
3386 25 => {
3387 cfg.feature_flags.zklogin_supported_providers = BTreeSet::from([
3389 "Google".to_string(),
3390 "Facebook".to_string(),
3391 "Twitch".to_string(),
3392 ]);
3393 cfg.feature_flags.zklogin_auth = true;
3394
3395 cfg.feature_flags.enable_jwk_consensus_updates = true;
3397 cfg.max_jwk_votes_per_validator_per_epoch = Some(240);
3398 cfg.max_age_of_jwk_in_epochs = Some(1);
3399 }
3400 26 => {
3401 cfg.gas_model_version = Some(7);
3402 if chain != Chain::Mainnet && chain != Chain::Testnet {
3404 cfg.transfer_receive_object_cost_base = Some(52);
3405 cfg.feature_flags.receive_objects = true;
3406 }
3407 }
3408 27 => {
3409 cfg.gas_model_version = Some(8);
3410 }
3411 28 => {
3412 cfg.check_zklogin_id_cost_base = Some(200);
3414 cfg.check_zklogin_issuer_cost_base = Some(200);
3416
3417 if chain != Chain::Mainnet && chain != Chain::Testnet {
3419 cfg.feature_flags.enable_effects_v2 = true;
3420 }
3421 }
3422 29 => {
3423 cfg.feature_flags.verify_legacy_zklogin_address = true;
3424 }
3425 30 => {
3426 if chain != Chain::Mainnet {
3428 cfg.feature_flags.narwhal_certificate_v2 = true;
3429 }
3430
3431 cfg.random_beacon_reduction_allowed_delta = Some(800);
3432 if chain != Chain::Mainnet {
3434 cfg.feature_flags.enable_effects_v2 = true;
3435 }
3436
3437 cfg.feature_flags.zklogin_supported_providers = BTreeSet::default();
3441
3442 cfg.feature_flags.recompute_has_public_transfer_in_execution = true;
3443 }
3444 31 => {
3445 cfg.execution_version = Some(2);
3446 if chain != Chain::Mainnet && chain != Chain::Testnet {
3448 cfg.feature_flags.shared_object_deletion = true;
3449 }
3450 }
3451 32 => {
3452 if chain != Chain::Mainnet {
3454 cfg.feature_flags.accept_zklogin_in_multisig = true;
3455 }
3456 if chain != Chain::Mainnet {
3458 cfg.transfer_receive_object_cost_base = Some(52);
3459 cfg.feature_flags.receive_objects = true;
3460 }
3461 if chain != Chain::Mainnet && chain != Chain::Testnet {
3463 cfg.feature_flags.random_beacon = true;
3464 cfg.random_beacon_reduction_lower_bound = Some(1600);
3465 cfg.random_beacon_dkg_timeout_round = Some(3000);
3466 cfg.random_beacon_min_round_interval_ms = Some(150);
3467 }
3468 if chain != Chain::Testnet && chain != Chain::Mainnet {
3470 cfg.feature_flags.include_consensus_digest_in_prologue = true;
3471 }
3472
3473 cfg.feature_flags.narwhal_certificate_v2 = true;
3475 }
3476 33 => {
3477 cfg.feature_flags.hardened_otw_check = true;
3478 cfg.feature_flags.allow_receiving_object_id = true;
3479
3480 cfg.transfer_receive_object_cost_base = Some(52);
3482 cfg.feature_flags.receive_objects = true;
3483
3484 if chain != Chain::Mainnet {
3486 cfg.feature_flags.shared_object_deletion = true;
3487 }
3488
3489 cfg.feature_flags.enable_effects_v2 = true;
3490 }
3491 34 => {}
3492 35 => {
3493 if chain != Chain::Mainnet && chain != Chain::Testnet {
3495 cfg.feature_flags.enable_poseidon = true;
3496 cfg.poseidon_bn254_cost_base = Some(260);
3497 cfg.poseidon_bn254_cost_per_block = Some(10);
3498 }
3499
3500 cfg.feature_flags.enable_coin_deny_list = true;
3501 }
3502 36 => {
3503 if chain != Chain::Mainnet && chain != Chain::Testnet {
3505 cfg.feature_flags.enable_group_ops_native_functions = true;
3506 cfg.feature_flags.enable_group_ops_native_function_msm = true;
3507 cfg.group_ops_bls12381_decode_scalar_cost = Some(52);
3509 cfg.group_ops_bls12381_decode_g1_cost = Some(52);
3510 cfg.group_ops_bls12381_decode_g2_cost = Some(52);
3511 cfg.group_ops_bls12381_decode_gt_cost = Some(52);
3512 cfg.group_ops_bls12381_scalar_add_cost = Some(52);
3513 cfg.group_ops_bls12381_g1_add_cost = Some(52);
3514 cfg.group_ops_bls12381_g2_add_cost = Some(52);
3515 cfg.group_ops_bls12381_gt_add_cost = Some(52);
3516 cfg.group_ops_bls12381_scalar_sub_cost = Some(52);
3517 cfg.group_ops_bls12381_g1_sub_cost = Some(52);
3518 cfg.group_ops_bls12381_g2_sub_cost = Some(52);
3519 cfg.group_ops_bls12381_gt_sub_cost = Some(52);
3520 cfg.group_ops_bls12381_scalar_mul_cost = Some(52);
3521 cfg.group_ops_bls12381_g1_mul_cost = Some(52);
3522 cfg.group_ops_bls12381_g2_mul_cost = Some(52);
3523 cfg.group_ops_bls12381_gt_mul_cost = Some(52);
3524 cfg.group_ops_bls12381_scalar_div_cost = Some(52);
3525 cfg.group_ops_bls12381_g1_div_cost = Some(52);
3526 cfg.group_ops_bls12381_g2_div_cost = Some(52);
3527 cfg.group_ops_bls12381_gt_div_cost = Some(52);
3528 cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(52);
3529 cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(52);
3530 cfg.group_ops_bls12381_g1_hash_to_cost_per_byte = Some(2);
3531 cfg.group_ops_bls12381_g2_hash_to_cost_per_byte = Some(2);
3532 cfg.group_ops_bls12381_g1_msm_base_cost = Some(52);
3533 cfg.group_ops_bls12381_g2_msm_base_cost = Some(52);
3534 cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(52);
3535 cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(52);
3536 cfg.group_ops_bls12381_msm_max_len = Some(32);
3537 cfg.group_ops_bls12381_pairing_cost = Some(52);
3538 }
3539 cfg.feature_flags.shared_object_deletion = true;
3541
3542 cfg.consensus_max_transaction_size_bytes = Some(256 * 1024); cfg.consensus_max_transactions_in_block_bytes = Some(6 * 1_024 * 1024);
3544 }
3546 37 => {
3547 cfg.feature_flags.reject_mutable_random_on_entry_functions = true;
3548
3549 if chain != Chain::Mainnet {
3551 cfg.feature_flags.include_consensus_digest_in_prologue = true;
3552 }
3553 }
3554 38 => {
3555 cfg.binary_module_handles = Some(100);
3556 cfg.binary_struct_handles = Some(300);
3557 cfg.binary_function_handles = Some(1500);
3558 cfg.binary_function_instantiations = Some(750);
3559 cfg.binary_signatures = Some(1000);
3560 cfg.binary_constant_pool = Some(4000);
3564 cfg.binary_identifiers = Some(10000);
3565 cfg.binary_address_identifiers = Some(100);
3566 cfg.binary_struct_defs = Some(200);
3567 cfg.binary_struct_def_instantiations = Some(100);
3568 cfg.binary_function_defs = Some(1000);
3569 cfg.binary_field_handles = Some(500);
3570 cfg.binary_field_instantiations = Some(250);
3571 cfg.binary_friend_decls = Some(100);
3572 cfg.max_package_dependencies = Some(32);
3574 cfg.max_modules_in_publish = Some(64);
3575 cfg.execution_version = Some(3);
3577 }
3578 39 => {
3579 }
3581 40 => {}
3582 41 => {
3583 cfg.feature_flags.enable_group_ops_native_functions = true;
3585 cfg.group_ops_bls12381_decode_scalar_cost = Some(52);
3587 cfg.group_ops_bls12381_decode_g1_cost = Some(52);
3588 cfg.group_ops_bls12381_decode_g2_cost = Some(52);
3589 cfg.group_ops_bls12381_decode_gt_cost = Some(52);
3590 cfg.group_ops_bls12381_scalar_add_cost = Some(52);
3591 cfg.group_ops_bls12381_g1_add_cost = Some(52);
3592 cfg.group_ops_bls12381_g2_add_cost = Some(52);
3593 cfg.group_ops_bls12381_gt_add_cost = Some(52);
3594 cfg.group_ops_bls12381_scalar_sub_cost = Some(52);
3595 cfg.group_ops_bls12381_g1_sub_cost = Some(52);
3596 cfg.group_ops_bls12381_g2_sub_cost = Some(52);
3597 cfg.group_ops_bls12381_gt_sub_cost = Some(52);
3598 cfg.group_ops_bls12381_scalar_mul_cost = Some(52);
3599 cfg.group_ops_bls12381_g1_mul_cost = Some(52);
3600 cfg.group_ops_bls12381_g2_mul_cost = Some(52);
3601 cfg.group_ops_bls12381_gt_mul_cost = Some(52);
3602 cfg.group_ops_bls12381_scalar_div_cost = Some(52);
3603 cfg.group_ops_bls12381_g1_div_cost = Some(52);
3604 cfg.group_ops_bls12381_g2_div_cost = Some(52);
3605 cfg.group_ops_bls12381_gt_div_cost = Some(52);
3606 cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(52);
3607 cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(52);
3608 cfg.group_ops_bls12381_g1_hash_to_cost_per_byte = Some(2);
3609 cfg.group_ops_bls12381_g2_hash_to_cost_per_byte = Some(2);
3610 cfg.group_ops_bls12381_g1_msm_base_cost = Some(52);
3611 cfg.group_ops_bls12381_g2_msm_base_cost = Some(52);
3612 cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(52);
3613 cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(52);
3614 cfg.group_ops_bls12381_msm_max_len = Some(32);
3615 cfg.group_ops_bls12381_pairing_cost = Some(52);
3616 }
3617 42 => {}
3618 43 => {
3619 cfg.feature_flags.zklogin_max_epoch_upper_bound_delta = Some(30);
3620 cfg.max_meter_ticks_per_package = Some(16_000_000);
3621 }
3622 44 => {
3623 cfg.feature_flags.include_consensus_digest_in_prologue = true;
3625 if chain != Chain::Mainnet {
3627 cfg.feature_flags.consensus_choice = ConsensusChoice::SwapEachEpoch;
3628 }
3629 }
3630 45 => {
3631 if chain != Chain::Testnet && chain != Chain::Mainnet {
3633 cfg.feature_flags.consensus_network = ConsensusNetwork::Tonic;
3634 }
3635
3636 if chain != Chain::Mainnet {
3637 cfg.feature_flags.mysticeti_leader_scoring_and_schedule = true;
3639 }
3640 cfg.min_move_binary_format_version = Some(6);
3641 cfg.feature_flags.accept_zklogin_in_multisig = true;
3642
3643 if chain != Chain::Mainnet && chain != Chain::Testnet {
3647 cfg.feature_flags.bridge = true;
3648 }
3649 }
3650 46 => {
3651 if chain != Chain::Mainnet {
3653 cfg.feature_flags.bridge = true;
3654 }
3655
3656 cfg.feature_flags.reshare_at_same_initial_version = true;
3658 }
3659 47 => {}
3660 48 => {
3661 cfg.feature_flags.consensus_network = ConsensusNetwork::Tonic;
3663
3664 cfg.feature_flags.resolve_abort_locations_to_package_id = true;
3666
3667 if chain != Chain::Mainnet {
3669 cfg.feature_flags.random_beacon = true;
3670 cfg.random_beacon_reduction_lower_bound = Some(1600);
3671 cfg.random_beacon_dkg_timeout_round = Some(3000);
3672 cfg.random_beacon_min_round_interval_ms = Some(200);
3673 }
3674
3675 cfg.feature_flags.mysticeti_use_committed_subdag_digest = true;
3677 }
3678 49 => {
3679 if chain != Chain::Testnet && chain != Chain::Mainnet {
3680 cfg.move_binary_format_version = Some(7);
3681 }
3682
3683 if chain != Chain::Mainnet && chain != Chain::Testnet {
3685 cfg.feature_flags.enable_vdf = true;
3686 cfg.vdf_verify_vdf_cost = Some(1500);
3689 cfg.vdf_hash_to_input_cost = Some(100);
3690 }
3691
3692 if chain != Chain::Testnet && chain != Chain::Mainnet {
3694 cfg.feature_flags
3695 .record_consensus_determined_version_assignments_in_prologue = true;
3696 }
3697
3698 if chain != Chain::Mainnet {
3700 cfg.feature_flags.consensus_choice = ConsensusChoice::Mysticeti;
3701 }
3702
3703 cfg.feature_flags.fresh_vm_on_framework_upgrade = true;
3705 }
3706 50 => {
3707 if chain != Chain::Mainnet {
3709 cfg.checkpoint_summary_version_specific_data = Some(1);
3710 cfg.min_checkpoint_interval_ms = Some(200);
3711 }
3712
3713 if chain != Chain::Testnet && chain != Chain::Mainnet {
3715 cfg.feature_flags
3716 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = true;
3717 }
3718
3719 cfg.feature_flags.mysticeti_num_leaders_per_round = Some(1);
3720
3721 cfg.max_deferral_rounds_for_congestion_control = Some(10);
3723 }
3724 51 => {
3725 cfg.random_beacon_dkg_version = Some(1);
3726
3727 if chain != Chain::Testnet && chain != Chain::Mainnet {
3728 cfg.feature_flags.enable_coin_deny_list_v2 = true;
3729 }
3730 }
3731 52 => {
3732 if chain != Chain::Mainnet {
3733 cfg.feature_flags.soft_bundle = true;
3734 cfg.max_soft_bundle_size = Some(5);
3735 }
3736
3737 cfg.config_read_setting_impl_cost_base = Some(100);
3738 cfg.config_read_setting_impl_cost_per_byte = Some(40);
3739
3740 if chain != Chain::Testnet && chain != Chain::Mainnet {
3742 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(100);
3743 cfg.feature_flags.per_object_congestion_control_mode =
3744 PerObjectCongestionControlMode::TotalTxCount;
3745 }
3746
3747 cfg.feature_flags.consensus_choice = ConsensusChoice::Mysticeti;
3749
3750 cfg.feature_flags.mysticeti_leader_scoring_and_schedule = true;
3752
3753 cfg.checkpoint_summary_version_specific_data = Some(1);
3755 cfg.min_checkpoint_interval_ms = Some(200);
3756
3757 if chain != Chain::Mainnet {
3759 cfg.feature_flags
3760 .record_consensus_determined_version_assignments_in_prologue = true;
3761 cfg.feature_flags
3762 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = true;
3763 }
3764 if chain != Chain::Mainnet {
3766 cfg.move_binary_format_version = Some(7);
3767 }
3768
3769 if chain != Chain::Testnet && chain != Chain::Mainnet {
3770 cfg.feature_flags.passkey_auth = true;
3771 }
3772 cfg.feature_flags.enable_coin_deny_list_v2 = true;
3773 }
3774 53 => {
3775 cfg.bridge_should_try_to_finalize_committee = Some(chain != Chain::Mainnet);
3777
3778 cfg.feature_flags
3780 .record_consensus_determined_version_assignments_in_prologue = true;
3781 cfg.feature_flags
3782 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = true;
3783
3784 if chain == Chain::Unknown {
3785 cfg.feature_flags.authority_capabilities_v2 = true;
3786 }
3787
3788 if chain != Chain::Mainnet {
3790 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(100);
3791 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(10);
3792 cfg.feature_flags.per_object_congestion_control_mode =
3793 PerObjectCongestionControlMode::TotalTxCount;
3794 }
3795
3796 cfg.bcs_per_byte_serialized_cost = Some(2);
3798 cfg.bcs_legacy_min_output_size_cost = Some(1);
3799 cfg.bcs_failure_cost = Some(52);
3800 cfg.debug_print_base_cost = Some(52);
3801 cfg.debug_print_stack_trace_base_cost = Some(52);
3802 cfg.hash_sha2_256_base_cost = Some(52);
3803 cfg.hash_sha2_256_per_byte_cost = Some(2);
3804 cfg.hash_sha2_256_legacy_min_input_len_cost = Some(1);
3805 cfg.hash_sha3_256_base_cost = Some(52);
3806 cfg.hash_sha3_256_per_byte_cost = Some(2);
3807 cfg.hash_sha3_256_legacy_min_input_len_cost = Some(1);
3808 cfg.type_name_get_base_cost = Some(52);
3809 cfg.type_name_get_per_byte_cost = Some(2);
3810 cfg.string_check_utf8_base_cost = Some(52);
3811 cfg.string_check_utf8_per_byte_cost = Some(2);
3812 cfg.string_is_char_boundary_base_cost = Some(52);
3813 cfg.string_sub_string_base_cost = Some(52);
3814 cfg.string_sub_string_per_byte_cost = Some(2);
3815 cfg.string_index_of_base_cost = Some(52);
3816 cfg.string_index_of_per_byte_pattern_cost = Some(2);
3817 cfg.string_index_of_per_byte_searched_cost = Some(2);
3818 cfg.vector_empty_base_cost = Some(52);
3819 cfg.vector_length_base_cost = Some(52);
3820 cfg.vector_push_back_base_cost = Some(52);
3821 cfg.vector_push_back_legacy_per_abstract_memory_unit_cost = Some(2);
3822 cfg.vector_borrow_base_cost = Some(52);
3823 cfg.vector_pop_back_base_cost = Some(52);
3824 cfg.vector_destroy_empty_base_cost = Some(52);
3825 cfg.vector_swap_base_cost = Some(52);
3826 }
3827 54 => {
3828 cfg.feature_flags.random_beacon = true;
3830 cfg.random_beacon_reduction_lower_bound = Some(1000);
3831 cfg.random_beacon_dkg_timeout_round = Some(3000);
3832 cfg.random_beacon_min_round_interval_ms = Some(500);
3833
3834 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(100);
3836 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(10);
3837 cfg.feature_flags.per_object_congestion_control_mode =
3838 PerObjectCongestionControlMode::TotalTxCount;
3839
3840 cfg.feature_flags.soft_bundle = true;
3842 cfg.max_soft_bundle_size = Some(5);
3843 }
3844 55 => {
3845 cfg.move_binary_format_version = Some(7);
3847
3848 cfg.consensus_max_transactions_in_block_bytes = Some(512 * 1024);
3850 cfg.consensus_max_num_transactions_in_block = Some(512);
3853
3854 cfg.feature_flags.rethrow_serialization_type_layout_errors = true;
3855 }
3856 56 => {
3857 if chain == Chain::Mainnet {
3858 cfg.feature_flags.bridge = true;
3859 }
3860 }
3861 57 => {
3862 cfg.random_beacon_reduction_lower_bound = Some(800);
3864 }
3865 58 => {
3866 if chain == Chain::Mainnet {
3867 cfg.bridge_should_try_to_finalize_committee = Some(true);
3868 }
3869
3870 if chain != Chain::Mainnet && chain != Chain::Testnet {
3871 cfg.feature_flags
3873 .consensus_distributed_vote_scoring_strategy = true;
3874 }
3875 }
3876 59 => {
3877 cfg.feature_flags.consensus_round_prober = true;
3879 }
3880 60 => {
3881 cfg.max_type_to_layout_nodes = Some(512);
3882 cfg.feature_flags.validate_identifier_inputs = true;
3883 }
3884 61 => {
3885 if chain != Chain::Mainnet {
3886 cfg.feature_flags
3888 .consensus_distributed_vote_scoring_strategy = true;
3889 }
3890 cfg.random_beacon_reduction_lower_bound = Some(700);
3892
3893 if chain != Chain::Mainnet && chain != Chain::Testnet {
3894 cfg.feature_flags.mysticeti_fastpath = true;
3896 }
3897 }
3898 62 => {
3899 cfg.feature_flags.relocate_event_module = true;
3900 }
3901 63 => {
3902 cfg.feature_flags.per_object_congestion_control_mode =
3903 PerObjectCongestionControlMode::TotalGasBudgetWithCap;
3904 cfg.gas_budget_based_txn_cost_cap_factor = Some(400_000);
3905 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(18_500_000);
3906 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(240_000_000);
3907 }
3908 64 => {
3909 cfg.feature_flags.per_object_congestion_control_mode =
3910 PerObjectCongestionControlMode::TotalTxCount;
3911 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(40);
3912 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(3);
3913 }
3914 65 => {
3915 cfg.feature_flags
3917 .consensus_distributed_vote_scoring_strategy = true;
3918 }
3919 66 => {
3920 if chain == Chain::Mainnet {
3921 cfg.feature_flags
3923 .consensus_distributed_vote_scoring_strategy = false;
3924 }
3925 }
3926 67 => {
3927 cfg.feature_flags
3929 .consensus_distributed_vote_scoring_strategy = true;
3930 }
3931 68 => {
3932 cfg.group_ops_bls12381_g1_to_uncompressed_g1_cost = Some(26);
3933 cfg.group_ops_bls12381_uncompressed_g1_to_g1_cost = Some(52);
3934 cfg.group_ops_bls12381_uncompressed_g1_sum_base_cost = Some(26);
3935 cfg.group_ops_bls12381_uncompressed_g1_sum_cost_per_term = Some(13);
3936 cfg.group_ops_bls12381_uncompressed_g1_sum_max_terms = Some(2000);
3937
3938 if chain != Chain::Mainnet && chain != Chain::Testnet {
3939 cfg.feature_flags.uncompressed_g1_group_elements = true;
3940 }
3941
3942 cfg.feature_flags.per_object_congestion_control_mode =
3943 PerObjectCongestionControlMode::TotalGasBudgetWithCap;
3944 cfg.gas_budget_based_txn_cost_cap_factor = Some(400_000);
3945 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(18_500_000);
3946 cfg.max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit =
3947 Some(3_700_000); cfg.max_txn_cost_overage_per_object_in_commit = Some(u64::MAX);
3949 cfg.gas_budget_based_txn_cost_absolute_cap_commit_count = Some(50);
3950
3951 cfg.random_beacon_reduction_lower_bound = Some(500);
3953
3954 cfg.feature_flags.disallow_new_modules_in_deps_only_packages = true;
3955 }
3956 69 => {
3957 cfg.consensus_voting_rounds = Some(40);
3959
3960 if chain != Chain::Mainnet && chain != Chain::Testnet {
3961 cfg.feature_flags.consensus_smart_ancestor_selection = true;
3963 }
3964
3965 if chain != Chain::Mainnet {
3966 cfg.feature_flags.uncompressed_g1_group_elements = true;
3967 }
3968 }
3969 70 => {
3970 if chain != Chain::Mainnet {
3971 cfg.feature_flags.consensus_smart_ancestor_selection = true;
3973 cfg.feature_flags
3975 .consensus_round_prober_probe_accepted_rounds = true;
3976 }
3977
3978 cfg.poseidon_bn254_cost_per_block = Some(388);
3979
3980 cfg.gas_model_version = Some(9);
3981 cfg.feature_flags.native_charging_v2 = true;
3982 cfg.bls12381_bls12381_min_sig_verify_cost_base = Some(44064);
3983 cfg.bls12381_bls12381_min_pk_verify_cost_base = Some(49282);
3984 cfg.ecdsa_k1_secp256k1_verify_keccak256_cost_base = Some(1470);
3985 cfg.ecdsa_k1_secp256k1_verify_sha256_cost_base = Some(1470);
3986 cfg.ecdsa_r1_secp256r1_verify_sha256_cost_base = Some(4225);
3987 cfg.ecdsa_r1_secp256r1_verify_keccak256_cost_base = Some(4225);
3988 cfg.ecvrf_ecvrf_verify_cost_base = Some(4848);
3989 cfg.ed25519_ed25519_verify_cost_base = Some(1802);
3990
3991 cfg.ecdsa_r1_ecrecover_keccak256_cost_base = Some(1173);
3993 cfg.ecdsa_r1_ecrecover_sha256_cost_base = Some(1173);
3994 cfg.ecdsa_k1_ecrecover_keccak256_cost_base = Some(500);
3995 cfg.ecdsa_k1_ecrecover_sha256_cost_base = Some(500);
3996
3997 cfg.groth16_prepare_verifying_key_bls12381_cost_base = Some(53838);
3998 cfg.groth16_prepare_verifying_key_bn254_cost_base = Some(82010);
3999 cfg.groth16_verify_groth16_proof_internal_bls12381_cost_base = Some(72090);
4000 cfg.groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input =
4001 Some(8213);
4002 cfg.groth16_verify_groth16_proof_internal_bn254_cost_base = Some(115502);
4003 cfg.groth16_verify_groth16_proof_internal_bn254_cost_per_public_input =
4004 Some(9484);
4005
4006 cfg.hash_keccak256_cost_base = Some(10);
4007 cfg.hash_blake2b256_cost_base = Some(10);
4008
4009 cfg.group_ops_bls12381_decode_scalar_cost = Some(7);
4011 cfg.group_ops_bls12381_decode_g1_cost = Some(2848);
4012 cfg.group_ops_bls12381_decode_g2_cost = Some(3770);
4013 cfg.group_ops_bls12381_decode_gt_cost = Some(3068);
4014
4015 cfg.group_ops_bls12381_scalar_add_cost = Some(10);
4016 cfg.group_ops_bls12381_g1_add_cost = Some(1556);
4017 cfg.group_ops_bls12381_g2_add_cost = Some(3048);
4018 cfg.group_ops_bls12381_gt_add_cost = Some(188);
4019
4020 cfg.group_ops_bls12381_scalar_sub_cost = Some(10);
4021 cfg.group_ops_bls12381_g1_sub_cost = Some(1550);
4022 cfg.group_ops_bls12381_g2_sub_cost = Some(3019);
4023 cfg.group_ops_bls12381_gt_sub_cost = Some(497);
4024
4025 cfg.group_ops_bls12381_scalar_mul_cost = Some(11);
4026 cfg.group_ops_bls12381_g1_mul_cost = Some(4842);
4027 cfg.group_ops_bls12381_g2_mul_cost = Some(9108);
4028 cfg.group_ops_bls12381_gt_mul_cost = Some(27490);
4029
4030 cfg.group_ops_bls12381_scalar_div_cost = Some(91);
4031 cfg.group_ops_bls12381_g1_div_cost = Some(5091);
4032 cfg.group_ops_bls12381_g2_div_cost = Some(9206);
4033 cfg.group_ops_bls12381_gt_div_cost = Some(27804);
4034
4035 cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(2962);
4036 cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(8688);
4037
4038 cfg.group_ops_bls12381_g1_msm_base_cost = Some(62648);
4039 cfg.group_ops_bls12381_g2_msm_base_cost = Some(131192);
4040 cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(1333);
4041 cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(3216);
4042
4043 cfg.group_ops_bls12381_uncompressed_g1_to_g1_cost = Some(677);
4044 cfg.group_ops_bls12381_g1_to_uncompressed_g1_cost = Some(2099);
4045 cfg.group_ops_bls12381_uncompressed_g1_sum_base_cost = Some(77);
4046 cfg.group_ops_bls12381_uncompressed_g1_sum_cost_per_term = Some(26);
4047
4048 cfg.group_ops_bls12381_pairing_cost = Some(26897);
4049 cfg.group_ops_bls12381_uncompressed_g1_sum_max_terms = Some(1200);
4050
4051 cfg.validator_validate_metadata_cost_base = Some(20000);
4052 }
4053 71 => {
4054 cfg.sip_45_consensus_amplification_threshold = Some(5);
4055
4056 cfg.allowed_txn_cost_overage_burst_per_object_in_commit = Some(185_000_000);
4058 }
4059 72 => {
4060 cfg.feature_flags.convert_type_argument_error = true;
4061
4062 cfg.max_tx_gas = Some(50_000_000_000_000);
4065 cfg.max_gas_price = Some(50_000_000_000);
4067
4068 cfg.feature_flags.variant_nodes = true;
4069 }
4070 73 => {
4071 cfg.use_object_per_epoch_marker_table_v2 = Some(true);
4073
4074 if chain != Chain::Mainnet && chain != Chain::Testnet {
4075 cfg.consensus_gc_depth = Some(60);
4078 }
4079
4080 if chain != Chain::Mainnet {
4081 cfg.feature_flags.consensus_zstd_compression = true;
4083 }
4084
4085 cfg.feature_flags.consensus_smart_ancestor_selection = true;
4087 cfg.feature_flags
4089 .consensus_round_prober_probe_accepted_rounds = true;
4090
4091 cfg.feature_flags.per_object_congestion_control_mode =
4093 PerObjectCongestionControlMode::TotalGasBudgetWithCap;
4094 cfg.gas_budget_based_txn_cost_cap_factor = Some(400_000);
4095 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(37_000_000);
4096 cfg.max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit =
4097 Some(7_400_000); cfg.max_txn_cost_overage_per_object_in_commit = Some(u64::MAX);
4099 cfg.gas_budget_based_txn_cost_absolute_cap_commit_count = Some(50);
4100 cfg.allowed_txn_cost_overage_burst_per_object_in_commit = Some(370_000_000);
4101 }
4102 74 => {
4103 if chain != Chain::Mainnet && chain != Chain::Testnet {
4105 cfg.feature_flags.enable_nitro_attestation = true;
4106 }
4107 cfg.nitro_attestation_parse_base_cost = Some(53 * 50);
4108 cfg.nitro_attestation_parse_cost_per_byte = Some(50);
4109 cfg.nitro_attestation_verify_base_cost = Some(49632 * 50);
4110 cfg.nitro_attestation_verify_cost_per_cert = Some(52369 * 50);
4111
4112 cfg.feature_flags.consensus_zstd_compression = true;
4114
4115 if chain != Chain::Mainnet && chain != Chain::Testnet {
4116 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
4117 }
4118 }
4119 75 => {
4120 if chain != Chain::Mainnet {
4121 cfg.feature_flags.passkey_auth = true;
4122 }
4123 }
4124 76 => {
4125 if chain != Chain::Mainnet && chain != Chain::Testnet {
4126 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
4127 cfg.consensus_commit_rate_estimation_window_size = Some(10);
4128 }
4129 cfg.feature_flags.minimize_child_object_mutations = true;
4130
4131 if chain != Chain::Mainnet {
4132 cfg.feature_flags.accept_passkey_in_multisig = true;
4133 }
4134 }
4135 77 => {
4136 cfg.feature_flags.uncompressed_g1_group_elements = true;
4137
4138 if chain != Chain::Mainnet {
4139 cfg.consensus_gc_depth = Some(60);
4140 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
4141 }
4142 }
4143 78 => {
4144 cfg.feature_flags.move_native_context = true;
4145 cfg.tx_context_fresh_id_cost_base = Some(52);
4146 cfg.tx_context_sender_cost_base = Some(30);
4147 cfg.tx_context_epoch_cost_base = Some(30);
4148 cfg.tx_context_epoch_timestamp_ms_cost_base = Some(30);
4149 cfg.tx_context_sponsor_cost_base = Some(30);
4150 cfg.tx_context_gas_price_cost_base = Some(30);
4151 cfg.tx_context_gas_budget_cost_base = Some(30);
4152 cfg.tx_context_ids_created_cost_base = Some(30);
4153 cfg.tx_context_replace_cost_base = Some(30);
4154 cfg.gas_model_version = Some(10);
4155
4156 if chain != Chain::Mainnet {
4157 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
4158 cfg.consensus_commit_rate_estimation_window_size = Some(10);
4159
4160 cfg.feature_flags.per_object_congestion_control_mode =
4162 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4163 ExecutionTimeEstimateParams {
4164 target_utilization: 30,
4165 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4167 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4169 stored_observations_limit: u64::MAX,
4170 stake_weighted_median_threshold: 0,
4171 default_none_duration_for_new_keys: false,
4172 observations_chunk_size: None,
4173 },
4174 );
4175 }
4176 }
4177 79 => {
4178 if chain != Chain::Mainnet {
4179 cfg.feature_flags.consensus_median_based_commit_timestamp = true;
4180
4181 cfg.consensus_bad_nodes_stake_threshold = Some(30);
4184
4185 cfg.feature_flags.consensus_batched_block_sync = true;
4186
4187 cfg.feature_flags.enable_nitro_attestation = true
4189 }
4190 cfg.feature_flags.normalize_ptb_arguments = true;
4191
4192 cfg.consensus_gc_depth = Some(60);
4193 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
4194 }
4195 80 => {
4196 cfg.max_ptb_value_size = Some(1024 * 1024);
4197 }
4198 81 => {
4199 cfg.feature_flags.consensus_median_based_commit_timestamp = true;
4200 cfg.feature_flags.enforce_checkpoint_timestamp_monotonicity = true;
4201 cfg.consensus_bad_nodes_stake_threshold = Some(30)
4202 }
4203 82 => {
4204 cfg.feature_flags.max_ptb_value_size_v2 = true;
4205 }
4206 83 => {
4207 if chain == Chain::Mainnet {
4208 let aliased: [u8; 32] = Hex::decode(
4210 "0x0b2da327ba6a4cacbe75dddd50e6e8bbf81d6496e92d66af9154c61c77f7332f",
4211 )
4212 .unwrap()
4213 .try_into()
4214 .unwrap();
4215
4216 cfg.aliased_addresses.push(AliasedAddress {
4218 original: Hex::decode("0xcd8962dad278d8b50fa0f9eb0186bfa4cbdecc6d59377214c88d0286a0ac9562").unwrap().try_into().unwrap(),
4219 aliased,
4220 allowed_tx_digests: vec![
4221 Base58::decode("B2eGLFoMHgj93Ni8dAJBfqGzo8EWSTLBesZzhEpTPA4").unwrap().try_into().unwrap(),
4222 ],
4223 });
4224
4225 cfg.aliased_addresses.push(AliasedAddress {
4226 original: Hex::decode("0xe28b50cef1d633ea43d3296a3f6b67ff0312a5f1a99f0af753c85b8b5de8ff06").unwrap().try_into().unwrap(),
4227 aliased,
4228 allowed_tx_digests: vec![
4229 Base58::decode("J4QqSAgp7VrQtQpMy5wDX4QGsCSEZu3U5KuDAkbESAge").unwrap().try_into().unwrap(),
4230 ],
4231 });
4232 }
4233
4234 if chain != Chain::Mainnet {
4237 cfg.feature_flags.resolve_type_input_ids_to_defining_id = true;
4238 cfg.transfer_party_transfer_internal_cost_base = Some(52);
4239
4240 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
4242 cfg.consensus_commit_rate_estimation_window_size = Some(10);
4243 cfg.feature_flags.per_object_congestion_control_mode =
4244 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4245 ExecutionTimeEstimateParams {
4246 target_utilization: 30,
4247 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4249 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4251 stored_observations_limit: u64::MAX,
4252 stake_weighted_median_threshold: 0,
4253 default_none_duration_for_new_keys: false,
4254 observations_chunk_size: None,
4255 },
4256 );
4257
4258 cfg.feature_flags.consensus_batched_block_sync = true;
4260
4261 cfg.feature_flags.enable_nitro_attestation_upgraded_parsing = true;
4264 cfg.feature_flags.enable_nitro_attestation = true;
4265 }
4266 }
4267 84 => {
4268 if chain == Chain::Mainnet {
4269 cfg.feature_flags.resolve_type_input_ids_to_defining_id = true;
4270 cfg.transfer_party_transfer_internal_cost_base = Some(52);
4271
4272 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
4274 cfg.consensus_commit_rate_estimation_window_size = Some(10);
4275 cfg.feature_flags.per_object_congestion_control_mode =
4276 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4277 ExecutionTimeEstimateParams {
4278 target_utilization: 30,
4279 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4281 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4283 stored_observations_limit: u64::MAX,
4284 stake_weighted_median_threshold: 0,
4285 default_none_duration_for_new_keys: false,
4286 observations_chunk_size: None,
4287 },
4288 );
4289
4290 cfg.feature_flags.consensus_batched_block_sync = true;
4292
4293 cfg.feature_flags.enable_nitro_attestation_upgraded_parsing = true;
4296 cfg.feature_flags.enable_nitro_attestation = true;
4297 }
4298
4299 cfg.feature_flags.per_object_congestion_control_mode =
4301 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4302 ExecutionTimeEstimateParams {
4303 target_utilization: 30,
4304 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4306 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4308 stored_observations_limit: 20,
4309 stake_weighted_median_threshold: 0,
4310 default_none_duration_for_new_keys: false,
4311 observations_chunk_size: None,
4312 },
4313 );
4314 cfg.feature_flags.allow_unbounded_system_objects = true;
4315 }
4316 85 => {
4317 if chain != Chain::Mainnet && chain != Chain::Testnet {
4318 cfg.feature_flags.enable_party_transfer = true;
4319 }
4320
4321 cfg.feature_flags
4322 .record_consensus_determined_version_assignments_in_prologue_v2 = true;
4323 cfg.feature_flags.disallow_self_identifier = true;
4324 cfg.feature_flags.per_object_congestion_control_mode =
4325 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4326 ExecutionTimeEstimateParams {
4327 target_utilization: 50,
4328 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4330 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4332 stored_observations_limit: 20,
4333 stake_weighted_median_threshold: 0,
4334 default_none_duration_for_new_keys: false,
4335 observations_chunk_size: None,
4336 },
4337 );
4338 }
4339 86 => {
4340 cfg.feature_flags.type_tags_in_object_runtime = true;
4341 cfg.max_move_enum_variants = Some(move_core_types::VARIANT_COUNT_MAX);
4342
4343 cfg.feature_flags.per_object_congestion_control_mode =
4345 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4346 ExecutionTimeEstimateParams {
4347 target_utilization: 50,
4348 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4350 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4352 stored_observations_limit: 20,
4353 stake_weighted_median_threshold: 3334,
4354 default_none_duration_for_new_keys: false,
4355 observations_chunk_size: None,
4356 },
4357 );
4358 if chain != Chain::Mainnet {
4360 cfg.feature_flags.enable_party_transfer = true;
4361 }
4362 }
4363 87 => {
4364 if chain == Chain::Mainnet {
4365 cfg.feature_flags.record_time_estimate_processed = true;
4366 }
4367 cfg.feature_flags.better_adapter_type_resolution_errors = true;
4368 }
4369 88 => {
4370 cfg.feature_flags.record_time_estimate_processed = true;
4371 cfg.tx_context_rgp_cost_base = Some(30);
4372 cfg.feature_flags
4373 .ignore_execution_time_observations_after_certs_closed = true;
4374
4375 cfg.feature_flags.per_object_congestion_control_mode =
4378 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4379 ExecutionTimeEstimateParams {
4380 target_utilization: 50,
4381 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4383 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4385 stored_observations_limit: 20,
4386 stake_weighted_median_threshold: 3334,
4387 default_none_duration_for_new_keys: true,
4388 observations_chunk_size: None,
4389 },
4390 );
4391 }
4392 89 => {
4393 cfg.feature_flags.dependency_linkage_error = true;
4394 cfg.feature_flags.additional_multisig_checks = true;
4395 }
4396 90 => {
4397 cfg.max_gas_price_rgp_factor_for_aborted_transactions = Some(100);
4399 cfg.feature_flags.debug_fatal_on_move_invariant_violation = true;
4400 cfg.feature_flags.additional_consensus_digest_indirect_state = true;
4401 cfg.feature_flags.accept_passkey_in_multisig = true;
4402 cfg.feature_flags.passkey_auth = true;
4403 cfg.feature_flags.check_for_init_during_upgrade = true;
4404
4405 if chain != Chain::Mainnet {
4407 cfg.feature_flags.mysticeti_fastpath = true;
4408 }
4409 }
4410 91 => {
4411 cfg.feature_flags.per_command_shared_object_transfer_rules = true;
4412 }
4413 92 => {
4414 cfg.feature_flags.per_command_shared_object_transfer_rules = false;
4415 }
4416 93 => {
4417 cfg.feature_flags
4418 .consensus_checkpoint_signature_key_includes_digest = true;
4419 }
4420 94 => {
4421 cfg.feature_flags.per_object_congestion_control_mode =
4423 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4424 ExecutionTimeEstimateParams {
4425 target_utilization: 50,
4426 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4428 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4430 stored_observations_limit: 18,
4431 stake_weighted_median_threshold: 3334,
4432 default_none_duration_for_new_keys: true,
4433 observations_chunk_size: None,
4434 },
4435 );
4436
4437 cfg.feature_flags.enable_party_transfer = true;
4439 }
4440 95 => {
4441 cfg.type_name_id_base_cost = Some(52);
4442
4443 cfg.max_transactions_per_checkpoint = Some(20_000);
4445 }
4446 96 => {
4447 if chain != Chain::Mainnet && chain != Chain::Testnet {
4449 cfg.feature_flags
4450 .include_checkpoint_artifacts_digest_in_summary = true;
4451 }
4452 cfg.feature_flags.correct_gas_payment_limit_check = true;
4453 cfg.feature_flags.authority_capabilities_v2 = true;
4454 cfg.feature_flags.use_mfp_txns_in_load_initial_object_debts = true;
4455 cfg.feature_flags.cancel_for_failed_dkg_early = true;
4456 cfg.feature_flags.enable_coin_registry = true;
4457
4458 cfg.feature_flags.mysticeti_fastpath = true;
4460 }
4461 97 => {
4462 cfg.feature_flags.additional_borrow_checks = true;
4463 }
4464 98 => {
4465 cfg.event_emit_auth_stream_cost = Some(52);
4466 cfg.feature_flags.better_loader_errors = true;
4467 cfg.feature_flags.generate_df_type_layouts = true;
4468 }
4469 99 => {
4470 cfg.feature_flags.use_new_commit_handler = true;
4471 }
4472 100 => {
4473 cfg.feature_flags.private_generics_verifier_v2 = true;
4474 }
4475 101 => {
4476 cfg.feature_flags.create_root_accumulator_object = true;
4477 cfg.max_updates_per_settlement_txn = Some(100);
4478 if chain != Chain::Mainnet {
4479 cfg.feature_flags.enable_poseidon = true;
4480 }
4481 }
4482 102 => {
4483 cfg.feature_flags.per_object_congestion_control_mode =
4487 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4488 ExecutionTimeEstimateParams {
4489 target_utilization: 50,
4490 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4492 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4494 stored_observations_limit: 180,
4495 stake_weighted_median_threshold: 3334,
4496 default_none_duration_for_new_keys: true,
4497 observations_chunk_size: Some(18),
4498 },
4499 );
4500 cfg.feature_flags.deprecate_global_storage_ops = true;
4501 }
4502 103 => {}
4503 104 => {
4504 cfg.translation_per_command_base_charge = Some(1);
4505 cfg.translation_per_input_base_charge = Some(1);
4506 cfg.translation_pure_input_per_byte_charge = Some(1);
4507 cfg.translation_per_type_node_charge = Some(1);
4508 cfg.translation_per_reference_node_charge = Some(1);
4509 cfg.translation_per_linkage_entry_charge = Some(10);
4510 cfg.gas_model_version = Some(11);
4511 cfg.feature_flags.abstract_size_in_object_runtime = true;
4512 cfg.feature_flags.object_runtime_charge_cache_load_gas = true;
4513 cfg.dynamic_field_hash_type_and_key_cost_base = Some(52);
4514 cfg.dynamic_field_add_child_object_cost_base = Some(52);
4515 cfg.dynamic_field_add_child_object_value_cost_per_byte = Some(1);
4516 cfg.dynamic_field_borrow_child_object_cost_base = Some(52);
4517 cfg.dynamic_field_borrow_child_object_child_ref_cost_per_byte = Some(1);
4518 cfg.dynamic_field_remove_child_object_cost_base = Some(52);
4519 cfg.dynamic_field_remove_child_object_child_cost_per_byte = Some(1);
4520 cfg.dynamic_field_has_child_object_cost_base = Some(52);
4521 cfg.dynamic_field_has_child_object_with_ty_cost_base = Some(52);
4522 cfg.feature_flags.enable_ptb_execution_v2 = true;
4523
4524 cfg.poseidon_bn254_cost_base = Some(260);
4525
4526 cfg.feature_flags.consensus_skip_gced_accept_votes = true;
4527
4528 if chain != Chain::Mainnet {
4529 cfg.feature_flags
4530 .enable_nitro_attestation_all_nonzero_pcrs_parsing = true;
4531 }
4532
4533 cfg.feature_flags
4534 .include_cancelled_randomness_txns_in_prologue = true;
4535 }
4536 105 => {
4537 cfg.feature_flags.enable_multi_epoch_transaction_expiration = true;
4538 cfg.feature_flags.disable_preconsensus_locking = true;
4539
4540 if chain != Chain::Mainnet {
4541 cfg.feature_flags
4542 .enable_nitro_attestation_always_include_required_pcrs_parsing = true;
4543 }
4544 }
4545 106 => {
4546 cfg.accumulator_object_storage_cost = Some(7600);
4548
4549 if chain != Chain::Mainnet && chain != Chain::Testnet {
4550 cfg.feature_flags.enable_accumulators = true;
4551 cfg.feature_flags.enable_address_balance_gas_payments = true;
4552 cfg.feature_flags.enable_authenticated_event_streams = true;
4553 cfg.feature_flags.enable_object_funds_withdraw = true;
4554 }
4555 }
4556 107 => {
4557 cfg.feature_flags
4558 .consensus_skip_gced_blocks_in_direct_finalization = true;
4559
4560 if in_integration_test() {
4562 cfg.consensus_gc_depth = Some(6);
4563 cfg.consensus_max_num_transactions_in_block = Some(8);
4564 }
4565 }
4566 108 => {
4567 cfg.feature_flags.gas_rounding_halve_digits = true;
4568 cfg.feature_flags.flexible_tx_context_positions = true;
4569 cfg.feature_flags.disable_entry_point_signature_check = true;
4570
4571 if chain != Chain::Mainnet {
4572 cfg.feature_flags.address_aliases = true;
4573
4574 cfg.feature_flags.enable_accumulators = true;
4575 cfg.feature_flags.enable_address_balance_gas_payments = true;
4576 }
4577
4578 cfg.feature_flags.enable_poseidon = true;
4579 }
4580 109 => {
4581 cfg.binary_variant_handles = Some(1024);
4582 cfg.binary_variant_instantiation_handles = Some(1024);
4583 cfg.feature_flags.restrict_hot_or_not_entry_functions = true;
4584 }
4585 110 => {
4586 cfg.feature_flags
4587 .enable_nitro_attestation_all_nonzero_pcrs_parsing = true;
4588 cfg.feature_flags
4589 .enable_nitro_attestation_always_include_required_pcrs_parsing = true;
4590 if chain != Chain::Mainnet && chain != Chain::Testnet {
4591 cfg.feature_flags.split_checkpoints_in_consensus_handler = true;
4592 }
4593 cfg.feature_flags.validate_zklogin_public_identifier = true;
4594 cfg.feature_flags.fix_checkpoint_signature_mapping = true;
4595 cfg.feature_flags
4596 .consensus_always_accept_system_transactions = true;
4597 if chain != Chain::Mainnet {
4598 cfg.feature_flags.enable_object_funds_withdraw = true;
4599 }
4600 }
4601 111 => {
4602 cfg.feature_flags.validator_metadata_verify_v2 = true;
4603 }
4604 112 => {
4605 cfg.group_ops_ristretto_decode_scalar_cost = Some(7);
4606 cfg.group_ops_ristretto_decode_point_cost = Some(200);
4607 cfg.group_ops_ristretto_scalar_add_cost = Some(10);
4608 cfg.group_ops_ristretto_point_add_cost = Some(500);
4609 cfg.group_ops_ristretto_scalar_sub_cost = Some(10);
4610 cfg.group_ops_ristretto_point_sub_cost = Some(500);
4611 cfg.group_ops_ristretto_scalar_mul_cost = Some(11);
4612 cfg.group_ops_ristretto_point_mul_cost = Some(1200);
4613 cfg.group_ops_ristretto_scalar_div_cost = Some(151);
4614 cfg.group_ops_ristretto_point_div_cost = Some(2500);
4615
4616 if chain != Chain::Mainnet && chain != Chain::Testnet {
4617 cfg.feature_flags.enable_ristretto255_group_ops = true;
4618 }
4619 }
4620 113 => {
4621 cfg.feature_flags.address_balance_gas_check_rgp_at_signing = true;
4622 if chain != Chain::Mainnet && chain != Chain::Testnet {
4623 cfg.feature_flags.defer_unpaid_amplification = true;
4624 }
4625 }
4626 114 => {
4627 cfg.feature_flags.randomize_checkpoint_tx_limit_in_tests = true;
4628 cfg.feature_flags.address_balance_gas_reject_gas_coin_arg = true;
4629 if chain != Chain::Mainnet {
4630 cfg.feature_flags.split_checkpoints_in_consensus_handler = true;
4631 cfg.feature_flags.enable_authenticated_event_streams = true;
4632 cfg.feature_flags
4633 .include_checkpoint_artifacts_digest_in_summary = true;
4634 }
4635 }
4636 _ => panic!("unsupported version {:?}", version),
4647 }
4648 }
4649
4650 cfg
4651 }
4652
4653 pub fn apply_seeded_test_overrides(&mut self, seed: &[u8; 32]) {
4654 if !self.feature_flags.randomize_checkpoint_tx_limit_in_tests
4655 || !self.feature_flags.split_checkpoints_in_consensus_handler
4656 {
4657 return;
4658 }
4659
4660 if !mysten_common::in_test_configuration() {
4661 return;
4662 }
4663
4664 use rand::{Rng, SeedableRng, rngs::StdRng};
4665 let mut rng = StdRng::from_seed(*seed);
4666 let max_txns = rng.gen_range(10..=100u64);
4667 info!("seeded test override: max_transactions_per_checkpoint = {max_txns}");
4668 self.max_transactions_per_checkpoint = Some(max_txns);
4669 }
4670
4671 pub fn verifier_config(&self, signing_limits: Option<(usize, usize, usize)>) -> VerifierConfig {
4677 let (
4678 max_back_edges_per_function,
4679 max_back_edges_per_module,
4680 sanity_check_with_regex_reference_safety,
4681 ) = if let Some((
4682 max_back_edges_per_function,
4683 max_back_edges_per_module,
4684 sanity_check_with_regex_reference_safety,
4685 )) = signing_limits
4686 {
4687 (
4688 Some(max_back_edges_per_function),
4689 Some(max_back_edges_per_module),
4690 Some(sanity_check_with_regex_reference_safety),
4691 )
4692 } else {
4693 (None, None, None)
4694 };
4695
4696 let additional_borrow_checks = if signing_limits.is_some() {
4697 true
4699 } else {
4700 self.additional_borrow_checks()
4701 };
4702 let deprecate_global_storage_ops = if signing_limits.is_some() {
4703 true
4705 } else {
4706 self.deprecate_global_storage_ops()
4707 };
4708
4709 VerifierConfig {
4710 max_loop_depth: Some(self.max_loop_depth() as usize),
4711 max_generic_instantiation_length: Some(self.max_generic_instantiation_length() as usize),
4712 max_function_parameters: Some(self.max_function_parameters() as usize),
4713 max_basic_blocks: Some(self.max_basic_blocks() as usize),
4714 max_value_stack_size: self.max_value_stack_size() as usize,
4715 max_type_nodes: Some(self.max_type_nodes() as usize),
4716 max_push_size: Some(self.max_push_size() as usize),
4717 max_dependency_depth: Some(self.max_dependency_depth() as usize),
4718 max_fields_in_struct: Some(self.max_fields_in_struct() as usize),
4719 max_function_definitions: Some(self.max_function_definitions() as usize),
4720 max_data_definitions: Some(self.max_struct_definitions() as usize),
4721 max_constant_vector_len: Some(self.max_move_vector_len()),
4722 max_back_edges_per_function,
4723 max_back_edges_per_module,
4724 max_basic_blocks_in_script: None,
4725 max_identifier_len: self.max_move_identifier_len_as_option(), disallow_self_identifier: self.feature_flags.disallow_self_identifier,
4727 allow_receiving_object_id: self.allow_receiving_object_id(),
4728 reject_mutable_random_on_entry_functions: self
4729 .reject_mutable_random_on_entry_functions(),
4730 bytecode_version: self.move_binary_format_version(),
4731 max_variants_in_enum: self.max_move_enum_variants_as_option(),
4732 additional_borrow_checks,
4733 better_loader_errors: self.better_loader_errors(),
4734 private_generics_verifier_v2: self.private_generics_verifier_v2(),
4735 sanity_check_with_regex_reference_safety: sanity_check_with_regex_reference_safety
4736 .map(|limit| limit as u128),
4737 deprecate_global_storage_ops,
4738 disable_entry_point_signature_check: self.disable_entry_point_signature_check(),
4739 switch_to_regex_reference_safety: false,
4740 }
4741 }
4742
4743 pub fn binary_config(
4744 &self,
4745 override_deprecate_global_storage_ops_during_deserialization: Option<bool>,
4746 ) -> BinaryConfig {
4747 let deprecate_global_storage_ops =
4748 override_deprecate_global_storage_ops_during_deserialization
4749 .unwrap_or_else(|| self.deprecate_global_storage_ops());
4750 BinaryConfig::new(
4751 self.move_binary_format_version(),
4752 self.min_move_binary_format_version_as_option()
4753 .unwrap_or(VERSION_1),
4754 self.no_extraneous_module_bytes(),
4755 deprecate_global_storage_ops,
4756 TableConfig {
4757 module_handles: self.binary_module_handles_as_option().unwrap_or(u16::MAX),
4758 datatype_handles: self.binary_struct_handles_as_option().unwrap_or(u16::MAX),
4759 function_handles: self.binary_function_handles_as_option().unwrap_or(u16::MAX),
4760 function_instantiations: self
4761 .binary_function_instantiations_as_option()
4762 .unwrap_or(u16::MAX),
4763 signatures: self.binary_signatures_as_option().unwrap_or(u16::MAX),
4764 constant_pool: self.binary_constant_pool_as_option().unwrap_or(u16::MAX),
4765 identifiers: self.binary_identifiers_as_option().unwrap_or(u16::MAX),
4766 address_identifiers: self
4767 .binary_address_identifiers_as_option()
4768 .unwrap_or(u16::MAX),
4769 struct_defs: self.binary_struct_defs_as_option().unwrap_or(u16::MAX),
4770 struct_def_instantiations: self
4771 .binary_struct_def_instantiations_as_option()
4772 .unwrap_or(u16::MAX),
4773 function_defs: self.binary_function_defs_as_option().unwrap_or(u16::MAX),
4774 field_handles: self.binary_field_handles_as_option().unwrap_or(u16::MAX),
4775 field_instantiations: self
4776 .binary_field_instantiations_as_option()
4777 .unwrap_or(u16::MAX),
4778 friend_decls: self.binary_friend_decls_as_option().unwrap_or(u16::MAX),
4779 enum_defs: self.binary_enum_defs_as_option().unwrap_or(u16::MAX),
4780 enum_def_instantiations: self
4781 .binary_enum_def_instantiations_as_option()
4782 .unwrap_or(u16::MAX),
4783 variant_handles: self.binary_variant_handles_as_option().unwrap_or(u16::MAX),
4784 variant_instantiation_handles: self
4785 .binary_variant_instantiation_handles_as_option()
4786 .unwrap_or(u16::MAX),
4787 },
4788 )
4789 }
4790
4791 pub fn apply_overrides_for_testing(
4795 override_fn: impl Fn(ProtocolVersion, Self) -> Self + Send + 'static,
4796 ) -> OverrideGuard {
4797 CONFIG_OVERRIDE.with(|ovr| {
4798 let mut cur = ovr.borrow_mut();
4799 assert!(cur.is_none(), "config override already present");
4800 *cur = Some(Box::new(override_fn));
4801 OverrideGuard
4802 })
4803 }
4804}
4805
4806impl ProtocolConfig {
4810 pub fn set_advance_to_highest_supported_protocol_version_for_testing(&mut self, val: bool) {
4811 self.feature_flags
4812 .advance_to_highest_supported_protocol_version = val
4813 }
4814 pub fn set_commit_root_state_digest_supported_for_testing(&mut self, val: bool) {
4815 self.feature_flags.commit_root_state_digest = val
4816 }
4817 pub fn set_zklogin_auth_for_testing(&mut self, val: bool) {
4818 self.feature_flags.zklogin_auth = val
4819 }
4820 pub fn set_enable_jwk_consensus_updates_for_testing(&mut self, val: bool) {
4821 self.feature_flags.enable_jwk_consensus_updates = val
4822 }
4823 pub fn set_random_beacon_for_testing(&mut self, val: bool) {
4824 self.feature_flags.random_beacon = val
4825 }
4826
4827 pub fn set_upgraded_multisig_for_testing(&mut self, val: bool) {
4828 self.feature_flags.upgraded_multisig_supported = val
4829 }
4830 pub fn set_accept_zklogin_in_multisig_for_testing(&mut self, val: bool) {
4831 self.feature_flags.accept_zklogin_in_multisig = val
4832 }
4833
4834 pub fn set_shared_object_deletion_for_testing(&mut self, val: bool) {
4835 self.feature_flags.shared_object_deletion = val;
4836 }
4837
4838 pub fn set_narwhal_new_leader_election_schedule_for_testing(&mut self, val: bool) {
4839 self.feature_flags.narwhal_new_leader_election_schedule = val;
4840 }
4841
4842 pub fn set_receive_object_for_testing(&mut self, val: bool) {
4843 self.feature_flags.receive_objects = val
4844 }
4845 pub fn set_narwhal_certificate_v2_for_testing(&mut self, val: bool) {
4846 self.feature_flags.narwhal_certificate_v2 = val
4847 }
4848 pub fn set_verify_legacy_zklogin_address_for_testing(&mut self, val: bool) {
4849 self.feature_flags.verify_legacy_zklogin_address = val
4850 }
4851
4852 pub fn set_per_object_congestion_control_mode_for_testing(
4853 &mut self,
4854 val: PerObjectCongestionControlMode,
4855 ) {
4856 self.feature_flags.per_object_congestion_control_mode = val;
4857 }
4858
4859 pub fn set_consensus_choice_for_testing(&mut self, val: ConsensusChoice) {
4860 self.feature_flags.consensus_choice = val;
4861 }
4862
4863 pub fn set_consensus_network_for_testing(&mut self, val: ConsensusNetwork) {
4864 self.feature_flags.consensus_network = val;
4865 }
4866
4867 pub fn set_zklogin_max_epoch_upper_bound_delta_for_testing(&mut self, val: Option<u64>) {
4868 self.feature_flags.zklogin_max_epoch_upper_bound_delta = val
4869 }
4870
4871 pub fn set_disable_bridge_for_testing(&mut self) {
4872 self.feature_flags.bridge = false
4873 }
4874
4875 pub fn set_mysticeti_num_leaders_per_round_for_testing(&mut self, val: Option<usize>) {
4876 self.feature_flags.mysticeti_num_leaders_per_round = val;
4877 }
4878
4879 pub fn set_enable_soft_bundle_for_testing(&mut self, val: bool) {
4880 self.feature_flags.soft_bundle = val;
4881 }
4882
4883 pub fn set_passkey_auth_for_testing(&mut self, val: bool) {
4884 self.feature_flags.passkey_auth = val
4885 }
4886
4887 pub fn set_enable_party_transfer_for_testing(&mut self, val: bool) {
4888 self.feature_flags.enable_party_transfer = val
4889 }
4890
4891 pub fn set_consensus_distributed_vote_scoring_strategy_for_testing(&mut self, val: bool) {
4892 self.feature_flags
4893 .consensus_distributed_vote_scoring_strategy = val;
4894 }
4895
4896 pub fn set_consensus_round_prober_for_testing(&mut self, val: bool) {
4897 self.feature_flags.consensus_round_prober = val;
4898 }
4899
4900 pub fn set_disallow_new_modules_in_deps_only_packages_for_testing(&mut self, val: bool) {
4901 self.feature_flags
4902 .disallow_new_modules_in_deps_only_packages = val;
4903 }
4904
4905 pub fn set_correct_gas_payment_limit_check_for_testing(&mut self, val: bool) {
4906 self.feature_flags.correct_gas_payment_limit_check = val;
4907 }
4908
4909 pub fn set_address_aliases_for_testing(&mut self, val: bool) {
4910 self.feature_flags.address_aliases = val;
4911 }
4912
4913 pub fn set_consensus_round_prober_probe_accepted_rounds(&mut self, val: bool) {
4914 self.feature_flags
4915 .consensus_round_prober_probe_accepted_rounds = val;
4916 }
4917
4918 pub fn set_mysticeti_fastpath_for_testing(&mut self, val: bool) {
4919 self.feature_flags.mysticeti_fastpath = val;
4920 }
4921
4922 pub fn set_accept_passkey_in_multisig_for_testing(&mut self, val: bool) {
4923 self.feature_flags.accept_passkey_in_multisig = val;
4924 }
4925
4926 pub fn set_consensus_batched_block_sync_for_testing(&mut self, val: bool) {
4927 self.feature_flags.consensus_batched_block_sync = val;
4928 }
4929
4930 pub fn set_record_time_estimate_processed_for_testing(&mut self, val: bool) {
4931 self.feature_flags.record_time_estimate_processed = val;
4932 }
4933
4934 pub fn set_prepend_prologue_tx_in_consensus_commit_in_checkpoints_for_testing(
4935 &mut self,
4936 val: bool,
4937 ) {
4938 self.feature_flags
4939 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = val;
4940 }
4941
4942 pub fn enable_accumulators_for_testing(&mut self) {
4943 self.feature_flags.enable_accumulators = true;
4944 }
4945
4946 pub fn disable_accumulators_for_testing(&mut self) {
4947 self.feature_flags.enable_accumulators = false;
4948 self.feature_flags.enable_address_balance_gas_payments = false;
4949 }
4950
4951 pub fn enable_coin_reservation_for_testing(&mut self) {
4952 self.feature_flags.enable_coin_reservation_obj_refs = true;
4953 }
4954
4955 pub fn create_root_accumulator_object_for_testing(&mut self) {
4956 self.feature_flags.create_root_accumulator_object = true;
4957 }
4958
4959 pub fn disable_create_root_accumulator_object_for_testing(&mut self) {
4960 self.feature_flags.create_root_accumulator_object = false;
4961 }
4962
4963 pub fn enable_address_balance_gas_payments_for_testing(&mut self) {
4964 self.feature_flags.enable_accumulators = true;
4965 self.feature_flags.allow_private_accumulator_entrypoints = true;
4966 self.feature_flags.enable_address_balance_gas_payments = true;
4967 self.feature_flags.address_balance_gas_check_rgp_at_signing = true;
4968 self.feature_flags.address_balance_gas_reject_gas_coin_arg = true;
4969 }
4970
4971 pub fn disable_address_balance_gas_payments_for_testing(&mut self) {
4972 self.feature_flags.enable_address_balance_gas_payments = false;
4973 }
4974
4975 pub fn enable_multi_epoch_transaction_expiration_for_testing(&mut self) {
4976 self.feature_flags.enable_multi_epoch_transaction_expiration = true;
4977 }
4978
4979 pub fn enable_authenticated_event_streams_for_testing(&mut self) {
4980 self.enable_accumulators_for_testing();
4981 self.feature_flags.enable_authenticated_event_streams = true;
4982 self.feature_flags
4983 .include_checkpoint_artifacts_digest_in_summary = true;
4984 self.feature_flags.split_checkpoints_in_consensus_handler = true;
4985 }
4986
4987 pub fn disable_authenticated_event_streams_for_testing(&mut self) {
4988 self.feature_flags.enable_authenticated_event_streams = false;
4989 }
4990
4991 pub fn enable_non_exclusive_writes_for_testing(&mut self) {
4992 self.feature_flags.enable_non_exclusive_writes = true;
4993 }
4994
4995 pub fn set_ignore_execution_time_observations_after_certs_closed_for_testing(
4996 &mut self,
4997 val: bool,
4998 ) {
4999 self.feature_flags
5000 .ignore_execution_time_observations_after_certs_closed = val;
5001 }
5002
5003 pub fn set_consensus_checkpoint_signature_key_includes_digest_for_testing(
5004 &mut self,
5005 val: bool,
5006 ) {
5007 self.feature_flags
5008 .consensus_checkpoint_signature_key_includes_digest = val;
5009 }
5010
5011 pub fn set_cancel_for_failed_dkg_early_for_testing(&mut self, val: bool) {
5012 self.feature_flags.cancel_for_failed_dkg_early = val;
5013 }
5014
5015 pub fn set_use_mfp_txns_in_load_initial_object_debts_for_testing(&mut self, val: bool) {
5016 self.feature_flags.use_mfp_txns_in_load_initial_object_debts = val;
5017 }
5018
5019 pub fn set_authority_capabilities_v2_for_testing(&mut self, val: bool) {
5020 self.feature_flags.authority_capabilities_v2 = val;
5021 }
5022
5023 pub fn allow_references_in_ptbs_for_testing(&mut self) {
5024 self.feature_flags.allow_references_in_ptbs = true;
5025 }
5026
5027 pub fn set_consensus_skip_gced_accept_votes_for_testing(&mut self, val: bool) {
5028 self.feature_flags.consensus_skip_gced_accept_votes = val;
5029 }
5030
5031 pub fn set_enable_object_funds_withdraw_for_testing(&mut self, val: bool) {
5032 self.feature_flags.enable_object_funds_withdraw = val;
5033 }
5034
5035 pub fn set_split_checkpoints_in_consensus_handler_for_testing(&mut self, val: bool) {
5036 self.feature_flags.split_checkpoints_in_consensus_handler = val;
5037 }
5038}
5039
5040type OverrideFn = dyn Fn(ProtocolVersion, ProtocolConfig) -> ProtocolConfig + Send;
5041
5042thread_local! {
5043 static CONFIG_OVERRIDE: RefCell<Option<Box<OverrideFn>>> = RefCell::new(None);
5044}
5045
5046#[must_use]
5047pub struct OverrideGuard;
5048
5049impl Drop for OverrideGuard {
5050 fn drop(&mut self) {
5051 info!("restoring override fn");
5052 CONFIG_OVERRIDE.with(|ovr| {
5053 *ovr.borrow_mut() = None;
5054 });
5055 }
5056}
5057
5058#[derive(PartialEq, Eq)]
5061pub enum LimitThresholdCrossed {
5062 None,
5063 Soft(u128, u128),
5064 Hard(u128, u128),
5065}
5066
5067pub fn check_limit_in_range<T: Into<V>, U: Into<V>, V: PartialOrd + Into<u128>>(
5070 x: T,
5071 soft_limit: U,
5072 hard_limit: V,
5073) -> LimitThresholdCrossed {
5074 let x: V = x.into();
5075 let soft_limit: V = soft_limit.into();
5076
5077 debug_assert!(soft_limit <= hard_limit);
5078
5079 if x >= hard_limit {
5082 LimitThresholdCrossed::Hard(x.into(), hard_limit.into())
5083 } else if x < soft_limit {
5084 LimitThresholdCrossed::None
5085 } else {
5086 LimitThresholdCrossed::Soft(x.into(), soft_limit.into())
5087 }
5088}
5089
5090#[macro_export]
5091macro_rules! check_limit {
5092 ($x:expr, $hard:expr) => {
5093 check_limit!($x, $hard, $hard)
5094 };
5095 ($x:expr, $soft:expr, $hard:expr) => {
5096 check_limit_in_range($x as u64, $soft, $hard)
5097 };
5098}
5099
5100#[macro_export]
5104macro_rules! check_limit_by_meter {
5105 ($is_metered:expr, $x:expr, $metered_limit:expr, $unmetered_hard_limit:expr, $metric:expr) => {{
5106 let (h, metered_str) = if $is_metered {
5108 ($metered_limit, "metered")
5109 } else {
5110 ($unmetered_hard_limit, "unmetered")
5112 };
5113 use sui_protocol_config::check_limit_in_range;
5114 let result = check_limit_in_range($x as u64, $metered_limit, h);
5115 match result {
5116 LimitThresholdCrossed::None => {}
5117 LimitThresholdCrossed::Soft(_, _) => {
5118 $metric.with_label_values(&[metered_str, "soft"]).inc();
5119 }
5120 LimitThresholdCrossed::Hard(_, _) => {
5121 $metric.with_label_values(&[metered_str, "hard"]).inc();
5122 }
5123 };
5124 result
5125 }};
5126}
5127#[cfg(all(test, not(msim)))]
5128mod test {
5129 use insta::assert_yaml_snapshot;
5130
5131 use super::*;
5132
5133 #[test]
5134 fn snapshot_tests() {
5135 println!("\n============================================================================");
5136 println!("! !");
5137 println!("! IMPORTANT: never update snapshots from this test. only add new versions! !");
5138 println!("! !");
5139 println!("============================================================================\n");
5140 for chain_id in &[Chain::Unknown, Chain::Mainnet, Chain::Testnet] {
5141 let chain_str = match chain_id {
5145 Chain::Unknown => "".to_string(),
5146 _ => format!("{:?}_", chain_id),
5147 };
5148 for i in MIN_PROTOCOL_VERSION..=MAX_PROTOCOL_VERSION {
5149 let cur = ProtocolVersion::new(i);
5150 assert_yaml_snapshot!(
5151 format!("{}version_{}", chain_str, cur.as_u64()),
5152 ProtocolConfig::get_for_version(cur, *chain_id)
5153 );
5154 }
5155 }
5156 }
5157
5158 #[test]
5159 fn test_getters() {
5160 let prot: ProtocolConfig =
5161 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5162 assert_eq!(
5163 prot.max_arguments(),
5164 prot.max_arguments_as_option().unwrap()
5165 );
5166 }
5167
5168 #[test]
5169 fn test_setters() {
5170 let mut prot: ProtocolConfig =
5171 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5172 prot.set_max_arguments_for_testing(123);
5173 assert_eq!(prot.max_arguments(), 123);
5174
5175 prot.set_max_arguments_from_str_for_testing("321".to_string());
5176 assert_eq!(prot.max_arguments(), 321);
5177
5178 prot.disable_max_arguments_for_testing();
5179 assert_eq!(prot.max_arguments_as_option(), None);
5180
5181 prot.set_attr_for_testing("max_arguments".to_string(), "456".to_string());
5182 assert_eq!(prot.max_arguments(), 456);
5183 }
5184
5185 #[test]
5186 #[should_panic(expected = "unsupported version")]
5187 fn max_version_test() {
5188 let _ = ProtocolConfig::get_for_version_impl(
5191 ProtocolVersion::new(MAX_PROTOCOL_VERSION + 1),
5192 Chain::Unknown,
5193 );
5194 }
5195
5196 #[test]
5197 fn lookup_by_string_test() {
5198 let prot: ProtocolConfig =
5199 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5200 assert!(prot.lookup_attr("some random string".to_string()).is_none());
5202
5203 assert!(
5204 prot.lookup_attr("max_arguments".to_string())
5205 == Some(ProtocolConfigValue::u32(prot.max_arguments())),
5206 );
5207
5208 assert!(
5210 prot.lookup_attr("max_move_identifier_len".to_string())
5211 .is_none()
5212 );
5213
5214 let prot: ProtocolConfig =
5216 ProtocolConfig::get_for_version(ProtocolVersion::new(9), Chain::Unknown);
5217 assert!(
5218 prot.lookup_attr("max_move_identifier_len".to_string())
5219 == Some(ProtocolConfigValue::u64(prot.max_move_identifier_len()))
5220 );
5221
5222 let prot: ProtocolConfig =
5223 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5224 assert!(
5226 prot.attr_map()
5227 .get("max_move_identifier_len")
5228 .unwrap()
5229 .is_none()
5230 );
5231 assert!(
5233 prot.attr_map().get("max_arguments").unwrap()
5234 == &Some(ProtocolConfigValue::u32(prot.max_arguments()))
5235 );
5236
5237 let prot: ProtocolConfig =
5239 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5240 assert!(
5242 prot.feature_flags
5243 .lookup_attr("some random string".to_owned())
5244 .is_none()
5245 );
5246 assert!(
5247 !prot
5248 .feature_flags
5249 .attr_map()
5250 .contains_key("some random string")
5251 );
5252
5253 assert!(
5255 prot.feature_flags
5256 .lookup_attr("package_upgrades".to_owned())
5257 == Some(false)
5258 );
5259 assert!(
5260 prot.feature_flags
5261 .attr_map()
5262 .get("package_upgrades")
5263 .unwrap()
5264 == &false
5265 );
5266 let prot: ProtocolConfig =
5267 ProtocolConfig::get_for_version(ProtocolVersion::new(4), Chain::Unknown);
5268 assert!(
5270 prot.feature_flags
5271 .lookup_attr("package_upgrades".to_owned())
5272 == Some(true)
5273 );
5274 assert!(
5275 prot.feature_flags
5276 .attr_map()
5277 .get("package_upgrades")
5278 .unwrap()
5279 == &true
5280 );
5281 }
5282
5283 #[test]
5284 fn limit_range_fn_test() {
5285 let low = 100u32;
5286 let high = 10000u64;
5287
5288 assert!(check_limit!(1u8, low, high) == LimitThresholdCrossed::None);
5289 assert!(matches!(
5290 check_limit!(255u16, low, high),
5291 LimitThresholdCrossed::Soft(255u128, 100)
5292 ));
5293 assert!(matches!(
5299 check_limit!(2550000u64, low, high),
5300 LimitThresholdCrossed::Hard(2550000, 10000)
5301 ));
5302
5303 assert!(matches!(
5304 check_limit!(2550000u64, high, high),
5305 LimitThresholdCrossed::Hard(2550000, 10000)
5306 ));
5307
5308 assert!(matches!(
5309 check_limit!(1u8, high),
5310 LimitThresholdCrossed::None
5311 ));
5312
5313 assert!(check_limit!(255u16, high) == LimitThresholdCrossed::None);
5314
5315 assert!(matches!(
5316 check_limit!(2550000u64, high),
5317 LimitThresholdCrossed::Hard(2550000, 10000)
5318 ));
5319 }
5320}