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 = 112;
28
29#[derive(Copy, Clone, Debug, Hash, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)]
303pub struct ProtocolVersion(u64);
304
305impl ProtocolVersion {
306 pub const MIN: Self = Self(MIN_PROTOCOL_VERSION);
311
312 pub const MAX: Self = Self(MAX_PROTOCOL_VERSION);
313
314 #[cfg(not(msim))]
315 pub const MAX_ALLOWED: Self = Self::MAX;
316
317 #[cfg(msim)]
319 pub const MAX_ALLOWED: Self = Self(MAX_PROTOCOL_VERSION + 1);
320
321 pub fn new(v: u64) -> Self {
322 Self(v)
323 }
324
325 pub const fn as_u64(&self) -> u64 {
326 self.0
327 }
328
329 pub fn max() -> Self {
332 Self::MAX
333 }
334
335 pub fn prev(self) -> Self {
336 Self(self.0.checked_sub(1).unwrap())
337 }
338}
339
340impl From<u64> for ProtocolVersion {
341 fn from(v: u64) -> Self {
342 Self::new(v)
343 }
344}
345
346impl std::ops::Sub<u64> for ProtocolVersion {
347 type Output = Self;
348 fn sub(self, rhs: u64) -> Self::Output {
349 Self::new(self.0 - rhs)
350 }
351}
352
353impl std::ops::Add<u64> for ProtocolVersion {
354 type Output = Self;
355 fn add(self, rhs: u64) -> Self::Output {
356 Self::new(self.0 + rhs)
357 }
358}
359
360#[derive(
361 Clone, Serialize, Deserialize, Debug, Default, PartialEq, Copy, PartialOrd, Ord, Eq, ValueEnum,
362)]
363pub enum Chain {
364 Mainnet,
365 Testnet,
366 #[default]
367 Unknown,
368}
369
370impl Chain {
371 pub fn as_str(self) -> &'static str {
372 match self {
373 Chain::Mainnet => "mainnet",
374 Chain::Testnet => "testnet",
375 Chain::Unknown => "unknown",
376 }
377 }
378}
379
380pub struct Error(pub String);
381
382#[derive(Default, Clone, Serialize, Deserialize, Debug, ProtocolConfigFeatureFlagsGetters)]
385struct FeatureFlags {
386 #[serde(skip_serializing_if = "is_false")]
389 package_upgrades: bool,
390 #[serde(skip_serializing_if = "is_false")]
393 commit_root_state_digest: bool,
394 #[serde(skip_serializing_if = "is_false")]
396 advance_epoch_start_time_in_safe_mode: bool,
397 #[serde(skip_serializing_if = "is_false")]
400 loaded_child_objects_fixed: bool,
401 #[serde(skip_serializing_if = "is_false")]
404 missing_type_is_compatibility_error: bool,
405 #[serde(skip_serializing_if = "is_false")]
408 scoring_decision_with_validity_cutoff: bool,
409
410 #[serde(skip_serializing_if = "is_false")]
413 consensus_order_end_of_epoch_last: bool,
414
415 #[serde(skip_serializing_if = "is_false")]
417 disallow_adding_abilities_on_upgrade: bool,
418 #[serde(skip_serializing_if = "is_false")]
420 disable_invariant_violation_check_in_swap_loc: bool,
421 #[serde(skip_serializing_if = "is_false")]
424 advance_to_highest_supported_protocol_version: bool,
425 #[serde(skip_serializing_if = "is_false")]
427 ban_entry_init: bool,
428 #[serde(skip_serializing_if = "is_false")]
430 package_digest_hash_module: bool,
431 #[serde(skip_serializing_if = "is_false")]
433 disallow_change_struct_type_params_on_upgrade: bool,
434 #[serde(skip_serializing_if = "is_false")]
436 no_extraneous_module_bytes: bool,
437 #[serde(skip_serializing_if = "is_false")]
439 narwhal_versioned_metadata: bool,
440
441 #[serde(skip_serializing_if = "is_false")]
443 zklogin_auth: bool,
444 #[serde(skip_serializing_if = "ConsensusTransactionOrdering::is_none")]
446 consensus_transaction_ordering: ConsensusTransactionOrdering,
447
448 #[serde(skip_serializing_if = "is_false")]
456 simplified_unwrap_then_delete: bool,
457 #[serde(skip_serializing_if = "is_false")]
459 upgraded_multisig_supported: bool,
460 #[serde(skip_serializing_if = "is_false")]
462 txn_base_cost_as_multiplier: bool,
463
464 #[serde(skip_serializing_if = "is_false")]
466 shared_object_deletion: bool,
467
468 #[serde(skip_serializing_if = "is_false")]
470 narwhal_new_leader_election_schedule: bool,
471
472 #[serde(skip_serializing_if = "is_empty")]
474 zklogin_supported_providers: BTreeSet<String>,
475
476 #[serde(skip_serializing_if = "is_false")]
478 loaded_child_object_format: bool,
479
480 #[serde(skip_serializing_if = "is_false")]
481 enable_jwk_consensus_updates: bool,
482
483 #[serde(skip_serializing_if = "is_false")]
484 end_of_epoch_transaction_supported: bool,
485
486 #[serde(skip_serializing_if = "is_false")]
489 simple_conservation_checks: bool,
490
491 #[serde(skip_serializing_if = "is_false")]
493 loaded_child_object_format_type: bool,
494
495 #[serde(skip_serializing_if = "is_false")]
497 receive_objects: bool,
498
499 #[serde(skip_serializing_if = "is_false")]
501 consensus_checkpoint_signature_key_includes_digest: bool,
502
503 #[serde(skip_serializing_if = "is_false")]
505 random_beacon: bool,
506
507 #[serde(skip_serializing_if = "is_false")]
509 bridge: bool,
510
511 #[serde(skip_serializing_if = "is_false")]
512 enable_effects_v2: bool,
513
514 #[serde(skip_serializing_if = "is_false")]
516 narwhal_certificate_v2: bool,
517
518 #[serde(skip_serializing_if = "is_false")]
520 verify_legacy_zklogin_address: bool,
521
522 #[serde(skip_serializing_if = "is_false")]
524 throughput_aware_consensus_submission: bool,
525
526 #[serde(skip_serializing_if = "is_false")]
528 recompute_has_public_transfer_in_execution: bool,
529
530 #[serde(skip_serializing_if = "is_false")]
532 accept_zklogin_in_multisig: bool,
533
534 #[serde(skip_serializing_if = "is_false")]
536 accept_passkey_in_multisig: bool,
537
538 #[serde(skip_serializing_if = "is_false")]
540 validate_zklogin_public_identifier: bool,
541
542 #[serde(skip_serializing_if = "is_false")]
545 include_consensus_digest_in_prologue: bool,
546
547 #[serde(skip_serializing_if = "is_false")]
549 hardened_otw_check: bool,
550
551 #[serde(skip_serializing_if = "is_false")]
553 allow_receiving_object_id: bool,
554
555 #[serde(skip_serializing_if = "is_false")]
557 enable_poseidon: bool,
558
559 #[serde(skip_serializing_if = "is_false")]
561 enable_coin_deny_list: bool,
562
563 #[serde(skip_serializing_if = "is_false")]
565 enable_group_ops_native_functions: bool,
566
567 #[serde(skip_serializing_if = "is_false")]
569 enable_group_ops_native_function_msm: bool,
570
571 #[serde(skip_serializing_if = "is_false")]
573 enable_ristretto255_group_ops: bool,
574
575 #[serde(skip_serializing_if = "is_false")]
577 enable_nitro_attestation: bool,
578
579 #[serde(skip_serializing_if = "is_false")]
581 enable_nitro_attestation_upgraded_parsing: bool,
582
583 #[serde(skip_serializing_if = "is_false")]
585 enable_nitro_attestation_all_nonzero_pcrs_parsing: bool,
586
587 #[serde(skip_serializing_if = "is_false")]
589 enable_nitro_attestation_always_include_required_pcrs_parsing: bool,
590
591 #[serde(skip_serializing_if = "is_false")]
593 reject_mutable_random_on_entry_functions: bool,
594
595 #[serde(skip_serializing_if = "PerObjectCongestionControlMode::is_none")]
597 per_object_congestion_control_mode: PerObjectCongestionControlMode,
598
599 #[serde(skip_serializing_if = "ConsensusChoice::is_narwhal")]
601 consensus_choice: ConsensusChoice,
602
603 #[serde(skip_serializing_if = "ConsensusNetwork::is_anemo")]
605 consensus_network: ConsensusNetwork,
606
607 #[serde(skip_serializing_if = "is_false")]
609 correct_gas_payment_limit_check: bool,
610
611 #[serde(skip_serializing_if = "Option::is_none")]
613 zklogin_max_epoch_upper_bound_delta: Option<u64>,
614
615 #[serde(skip_serializing_if = "is_false")]
617 mysticeti_leader_scoring_and_schedule: bool,
618
619 #[serde(skip_serializing_if = "is_false")]
621 reshare_at_same_initial_version: bool,
622
623 #[serde(skip_serializing_if = "is_false")]
625 resolve_abort_locations_to_package_id: bool,
626
627 #[serde(skip_serializing_if = "is_false")]
631 mysticeti_use_committed_subdag_digest: bool,
632
633 #[serde(skip_serializing_if = "is_false")]
635 enable_vdf: bool,
636
637 #[serde(skip_serializing_if = "is_false")]
642 record_consensus_determined_version_assignments_in_prologue: bool,
643 #[serde(skip_serializing_if = "is_false")]
644 record_consensus_determined_version_assignments_in_prologue_v2: bool,
645
646 #[serde(skip_serializing_if = "is_false")]
648 fresh_vm_on_framework_upgrade: bool,
649
650 #[serde(skip_serializing_if = "is_false")]
658 prepend_prologue_tx_in_consensus_commit_in_checkpoints: bool,
659
660 #[serde(skip_serializing_if = "Option::is_none")]
662 mysticeti_num_leaders_per_round: Option<usize>,
663
664 #[serde(skip_serializing_if = "is_false")]
666 soft_bundle: bool,
667
668 #[serde(skip_serializing_if = "is_false")]
670 enable_coin_deny_list_v2: bool,
671
672 #[serde(skip_serializing_if = "is_false")]
674 passkey_auth: bool,
675
676 #[serde(skip_serializing_if = "is_false")]
678 authority_capabilities_v2: bool,
679
680 #[serde(skip_serializing_if = "is_false")]
682 rethrow_serialization_type_layout_errors: bool,
683
684 #[serde(skip_serializing_if = "is_false")]
686 consensus_distributed_vote_scoring_strategy: bool,
687
688 #[serde(skip_serializing_if = "is_false")]
690 consensus_round_prober: bool,
691
692 #[serde(skip_serializing_if = "is_false")]
694 validate_identifier_inputs: bool,
695
696 #[serde(skip_serializing_if = "is_false")]
698 disallow_self_identifier: bool,
699
700 #[serde(skip_serializing_if = "is_false")]
702 mysticeti_fastpath: bool,
703
704 #[serde(skip_serializing_if = "is_false")]
708 disable_preconsensus_locking: bool,
709
710 #[serde(skip_serializing_if = "is_false")]
712 relocate_event_module: bool,
713
714 #[serde(skip_serializing_if = "is_false")]
716 uncompressed_g1_group_elements: bool,
717
718 #[serde(skip_serializing_if = "is_false")]
719 disallow_new_modules_in_deps_only_packages: bool,
720
721 #[serde(skip_serializing_if = "is_false")]
723 consensus_smart_ancestor_selection: bool,
724
725 #[serde(skip_serializing_if = "is_false")]
727 consensus_round_prober_probe_accepted_rounds: bool,
728
729 #[serde(skip_serializing_if = "is_false")]
731 native_charging_v2: bool,
732
733 #[serde(skip_serializing_if = "is_false")]
736 consensus_linearize_subdag_v2: bool,
737
738 #[serde(skip_serializing_if = "is_false")]
740 convert_type_argument_error: bool,
741
742 #[serde(skip_serializing_if = "is_false")]
744 variant_nodes: bool,
745
746 #[serde(skip_serializing_if = "is_false")]
748 consensus_zstd_compression: bool,
749
750 #[serde(skip_serializing_if = "is_false")]
752 minimize_child_object_mutations: bool,
753
754 #[serde(skip_serializing_if = "is_false")]
756 record_additional_state_digest_in_prologue: bool,
757
758 #[serde(skip_serializing_if = "is_false")]
760 move_native_context: bool,
761
762 #[serde(skip_serializing_if = "is_false")]
765 consensus_median_based_commit_timestamp: bool,
766
767 #[serde(skip_serializing_if = "is_false")]
770 normalize_ptb_arguments: bool,
771
772 #[serde(skip_serializing_if = "is_false")]
774 consensus_batched_block_sync: bool,
775
776 #[serde(skip_serializing_if = "is_false")]
778 enforce_checkpoint_timestamp_monotonicity: bool,
779
780 #[serde(skip_serializing_if = "is_false")]
782 max_ptb_value_size_v2: bool,
783
784 #[serde(skip_serializing_if = "is_false")]
786 resolve_type_input_ids_to_defining_id: bool,
787
788 #[serde(skip_serializing_if = "is_false")]
790 enable_party_transfer: bool,
791
792 #[serde(skip_serializing_if = "is_false")]
794 allow_unbounded_system_objects: bool,
795
796 #[serde(skip_serializing_if = "is_false")]
798 type_tags_in_object_runtime: bool,
799
800 #[serde(skip_serializing_if = "is_false")]
802 enable_accumulators: bool,
803
804 #[serde(skip_serializing_if = "is_false")]
806 enable_coin_reservation_obj_refs: bool,
807
808 #[serde(skip_serializing_if = "is_false")]
811 create_root_accumulator_object: bool,
812
813 #[serde(skip_serializing_if = "is_false")]
815 enable_authenticated_event_streams: bool,
816
817 #[serde(skip_serializing_if = "is_false")]
819 enable_address_balance_gas_payments: bool,
820
821 #[serde(skip_serializing_if = "is_false")]
823 enable_multi_epoch_transaction_expiration: bool,
824
825 #[serde(skip_serializing_if = "is_false")]
827 enable_ptb_execution_v2: bool,
828
829 #[serde(skip_serializing_if = "is_false")]
831 better_adapter_type_resolution_errors: bool,
832
833 #[serde(skip_serializing_if = "is_false")]
835 record_time_estimate_processed: bool,
836
837 #[serde(skip_serializing_if = "is_false")]
839 dependency_linkage_error: bool,
840
841 #[serde(skip_serializing_if = "is_false")]
843 additional_multisig_checks: bool,
844
845 #[serde(skip_serializing_if = "is_false")]
847 ignore_execution_time_observations_after_certs_closed: bool,
848
849 #[serde(skip_serializing_if = "is_false")]
853 debug_fatal_on_move_invariant_violation: bool,
854
855 #[serde(skip_serializing_if = "is_false")]
858 allow_private_accumulator_entrypoints: bool,
859
860 #[serde(skip_serializing_if = "is_false")]
862 additional_consensus_digest_indirect_state: bool,
863
864 #[serde(skip_serializing_if = "is_false")]
866 check_for_init_during_upgrade: bool,
867
868 #[serde(skip_serializing_if = "is_false")]
870 per_command_shared_object_transfer_rules: bool,
871
872 #[serde(skip_serializing_if = "is_false")]
874 include_checkpoint_artifacts_digest_in_summary: bool,
875
876 #[serde(skip_serializing_if = "is_false")]
878 use_mfp_txns_in_load_initial_object_debts: bool,
879
880 #[serde(skip_serializing_if = "is_false")]
882 cancel_for_failed_dkg_early: bool,
883
884 #[serde(skip_serializing_if = "is_false")]
886 enable_coin_registry: bool,
887
888 #[serde(skip_serializing_if = "is_false")]
890 abstract_size_in_object_runtime: bool,
891
892 #[serde(skip_serializing_if = "is_false")]
894 object_runtime_charge_cache_load_gas: bool,
895
896 #[serde(skip_serializing_if = "is_false")]
898 additional_borrow_checks: bool,
899
900 #[serde(skip_serializing_if = "is_false")]
902 use_new_commit_handler: bool,
903
904 #[serde(skip_serializing_if = "is_false")]
906 better_loader_errors: bool,
907
908 #[serde(skip_serializing_if = "is_false")]
910 generate_df_type_layouts: bool,
911
912 #[serde(skip_serializing_if = "is_false")]
914 allow_references_in_ptbs: bool,
915
916 #[serde(skip_serializing_if = "is_false")]
918 enable_display_registry: bool,
919
920 #[serde(skip_serializing_if = "is_false")]
922 private_generics_verifier_v2: bool,
923
924 #[serde(skip_serializing_if = "is_false")]
926 deprecate_global_storage_ops_during_deserialization: bool,
927
928 #[serde(skip_serializing_if = "is_false")]
931 enable_non_exclusive_writes: bool,
932
933 #[serde(skip_serializing_if = "is_false")]
935 deprecate_global_storage_ops: bool,
936
937 #[serde(skip_serializing_if = "is_false")]
939 consensus_skip_gced_accept_votes: bool,
940
941 #[serde(skip_serializing_if = "is_false")]
943 include_cancelled_randomness_txns_in_prologue: bool,
944
945 #[serde(skip_serializing_if = "is_false")]
947 address_aliases: bool,
948
949 #[serde(skip_serializing_if = "is_false")]
952 fix_checkpoint_signature_mapping: bool,
953
954 #[serde(skip_serializing_if = "is_false")]
956 enable_object_funds_withdraw: bool,
957
958 #[serde(skip_serializing_if = "is_false")]
960 consensus_skip_gced_blocks_in_direct_finalization: bool,
961
962 #[serde(skip_serializing_if = "is_false")]
964 gas_rounding_halve_digits: bool,
965
966 #[serde(skip_serializing_if = "is_false")]
968 flexible_tx_context_positions: bool,
969
970 #[serde(skip_serializing_if = "is_false")]
972 disable_entry_point_signature_check: bool,
973
974 #[serde(skip_serializing_if = "is_false")]
976 convert_withdrawal_compatibility_ptb_arguments: bool,
977
978 #[serde(skip_serializing_if = "is_false")]
980 restrict_hot_or_not_entry_functions: bool,
981
982 #[serde(skip_serializing_if = "is_false")]
984 split_checkpoints_in_consensus_handler: bool,
985
986 #[serde(skip_serializing_if = "is_false")]
988 consensus_always_accept_system_transactions: bool,
989
990 #[serde(skip_serializing_if = "is_false")]
992 validator_metadata_verify_v2: bool,
993}
994
995fn is_false(b: &bool) -> bool {
996 !b
997}
998
999fn is_empty(b: &BTreeSet<String>) -> bool {
1000 b.is_empty()
1001}
1002
1003fn is_zero(val: &u64) -> bool {
1004 *val == 0
1005}
1006
1007#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1009pub enum ConsensusTransactionOrdering {
1010 #[default]
1012 None,
1013 ByGasPrice,
1015}
1016
1017impl ConsensusTransactionOrdering {
1018 pub fn is_none(&self) -> bool {
1019 matches!(self, ConsensusTransactionOrdering::None)
1020 }
1021}
1022
1023#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1024pub struct ExecutionTimeEstimateParams {
1025 pub target_utilization: u64,
1027 pub allowed_txn_cost_overage_burst_limit_us: u64,
1031
1032 pub randomness_scalar: u64,
1035
1036 pub max_estimate_us: u64,
1038
1039 pub stored_observations_num_included_checkpoints: u64,
1042
1043 pub stored_observations_limit: u64,
1045
1046 #[serde(skip_serializing_if = "is_zero")]
1049 pub stake_weighted_median_threshold: u64,
1050
1051 #[serde(skip_serializing_if = "is_false")]
1055 pub default_none_duration_for_new_keys: bool,
1056
1057 #[serde(skip_serializing_if = "Option::is_none")]
1059 pub observations_chunk_size: Option<u64>,
1060}
1061
1062#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1064pub enum PerObjectCongestionControlMode {
1065 #[default]
1066 None, TotalGasBudget, TotalTxCount, TotalGasBudgetWithCap, ExecutionTimeEstimate(ExecutionTimeEstimateParams), }
1072
1073impl PerObjectCongestionControlMode {
1074 pub fn is_none(&self) -> bool {
1075 matches!(self, PerObjectCongestionControlMode::None)
1076 }
1077}
1078
1079#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1081pub enum ConsensusChoice {
1082 #[default]
1083 Narwhal,
1084 SwapEachEpoch,
1085 Mysticeti,
1086}
1087
1088impl ConsensusChoice {
1089 pub fn is_narwhal(&self) -> bool {
1090 matches!(self, ConsensusChoice::Narwhal)
1091 }
1092}
1093
1094#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1096pub enum ConsensusNetwork {
1097 #[default]
1098 Anemo,
1099 Tonic,
1100}
1101
1102impl ConsensusNetwork {
1103 pub fn is_anemo(&self) -> bool {
1104 matches!(self, ConsensusNetwork::Anemo)
1105 }
1106}
1107
1108#[skip_serializing_none]
1140#[derive(Clone, Serialize, Debug, ProtocolConfigAccessors, ProtocolConfigOverride)]
1141pub struct ProtocolConfig {
1142 pub version: ProtocolVersion,
1143
1144 feature_flags: FeatureFlags,
1145
1146 max_tx_size_bytes: Option<u64>,
1149
1150 max_input_objects: Option<u64>,
1152
1153 max_size_written_objects: Option<u64>,
1157 max_size_written_objects_system_tx: Option<u64>,
1160
1161 max_serialized_tx_effects_size_bytes: Option<u64>,
1163
1164 max_serialized_tx_effects_size_bytes_system_tx: Option<u64>,
1166
1167 max_gas_payment_objects: Option<u32>,
1169
1170 max_modules_in_publish: Option<u32>,
1172
1173 max_package_dependencies: Option<u32>,
1175
1176 max_arguments: Option<u32>,
1179
1180 max_type_arguments: Option<u32>,
1182
1183 max_type_argument_depth: Option<u32>,
1185
1186 max_pure_argument_size: Option<u32>,
1188
1189 max_programmable_tx_commands: Option<u32>,
1191
1192 move_binary_format_version: Option<u32>,
1195 min_move_binary_format_version: Option<u32>,
1196
1197 binary_module_handles: Option<u16>,
1199 binary_struct_handles: Option<u16>,
1200 binary_function_handles: Option<u16>,
1201 binary_function_instantiations: Option<u16>,
1202 binary_signatures: Option<u16>,
1203 binary_constant_pool: Option<u16>,
1204 binary_identifiers: Option<u16>,
1205 binary_address_identifiers: Option<u16>,
1206 binary_struct_defs: Option<u16>,
1207 binary_struct_def_instantiations: Option<u16>,
1208 binary_function_defs: Option<u16>,
1209 binary_field_handles: Option<u16>,
1210 binary_field_instantiations: Option<u16>,
1211 binary_friend_decls: Option<u16>,
1212 binary_enum_defs: Option<u16>,
1213 binary_enum_def_instantiations: Option<u16>,
1214 binary_variant_handles: Option<u16>,
1215 binary_variant_instantiation_handles: Option<u16>,
1216
1217 max_move_object_size: Option<u64>,
1219
1220 max_move_package_size: Option<u64>,
1223
1224 max_publish_or_upgrade_per_ptb: Option<u64>,
1226
1227 max_tx_gas: Option<u64>,
1229
1230 max_gas_price: Option<u64>,
1232
1233 max_gas_price_rgp_factor_for_aborted_transactions: Option<u64>,
1236
1237 max_gas_computation_bucket: Option<u64>,
1239
1240 gas_rounding_step: Option<u64>,
1242
1243 max_loop_depth: Option<u64>,
1245
1246 max_generic_instantiation_length: Option<u64>,
1248
1249 max_function_parameters: Option<u64>,
1251
1252 max_basic_blocks: Option<u64>,
1254
1255 max_value_stack_size: Option<u64>,
1257
1258 max_type_nodes: Option<u64>,
1260
1261 max_push_size: Option<u64>,
1263
1264 max_struct_definitions: Option<u64>,
1266
1267 max_function_definitions: Option<u64>,
1269
1270 max_fields_in_struct: Option<u64>,
1272
1273 max_dependency_depth: Option<u64>,
1275
1276 max_num_event_emit: Option<u64>,
1278
1279 max_num_new_move_object_ids: Option<u64>,
1281
1282 max_num_new_move_object_ids_system_tx: Option<u64>,
1284
1285 max_num_deleted_move_object_ids: Option<u64>,
1287
1288 max_num_deleted_move_object_ids_system_tx: Option<u64>,
1290
1291 max_num_transferred_move_object_ids: Option<u64>,
1293
1294 max_num_transferred_move_object_ids_system_tx: Option<u64>,
1296
1297 max_event_emit_size: Option<u64>,
1299
1300 max_event_emit_size_total: Option<u64>,
1302
1303 max_move_vector_len: Option<u64>,
1305
1306 max_move_identifier_len: Option<u64>,
1308
1309 max_move_value_depth: Option<u64>,
1311
1312 max_move_enum_variants: Option<u64>,
1314
1315 max_back_edges_per_function: Option<u64>,
1317
1318 max_back_edges_per_module: Option<u64>,
1320
1321 max_verifier_meter_ticks_per_function: Option<u64>,
1323
1324 max_meter_ticks_per_module: Option<u64>,
1326
1327 max_meter_ticks_per_package: Option<u64>,
1329
1330 object_runtime_max_num_cached_objects: Option<u64>,
1334
1335 object_runtime_max_num_cached_objects_system_tx: Option<u64>,
1337
1338 object_runtime_max_num_store_entries: Option<u64>,
1340
1341 object_runtime_max_num_store_entries_system_tx: Option<u64>,
1343
1344 base_tx_cost_fixed: Option<u64>,
1347
1348 package_publish_cost_fixed: Option<u64>,
1351
1352 base_tx_cost_per_byte: Option<u64>,
1355
1356 package_publish_cost_per_byte: Option<u64>,
1358
1359 obj_access_cost_read_per_byte: Option<u64>,
1361
1362 obj_access_cost_mutate_per_byte: Option<u64>,
1364
1365 obj_access_cost_delete_per_byte: Option<u64>,
1367
1368 obj_access_cost_verify_per_byte: Option<u64>,
1378
1379 max_type_to_layout_nodes: Option<u64>,
1381
1382 max_ptb_value_size: Option<u64>,
1384
1385 gas_model_version: Option<u64>,
1388
1389 obj_data_cost_refundable: Option<u64>,
1392
1393 obj_metadata_cost_non_refundable: Option<u64>,
1397
1398 storage_rebate_rate: Option<u64>,
1404
1405 storage_fund_reinvest_rate: Option<u64>,
1408
1409 reward_slashing_rate: Option<u64>,
1412
1413 storage_gas_price: Option<u64>,
1415
1416 accumulator_object_storage_cost: Option<u64>,
1418
1419 max_transactions_per_checkpoint: Option<u64>,
1424
1425 max_checkpoint_size_bytes: Option<u64>,
1429
1430 buffer_stake_for_protocol_upgrade_bps: Option<u64>,
1435
1436 address_from_bytes_cost_base: Option<u64>,
1441 address_to_u256_cost_base: Option<u64>,
1443 address_from_u256_cost_base: Option<u64>,
1445
1446 config_read_setting_impl_cost_base: Option<u64>,
1451 config_read_setting_impl_cost_per_byte: Option<u64>,
1452
1453 dynamic_field_hash_type_and_key_cost_base: Option<u64>,
1456 dynamic_field_hash_type_and_key_type_cost_per_byte: Option<u64>,
1457 dynamic_field_hash_type_and_key_value_cost_per_byte: Option<u64>,
1458 dynamic_field_hash_type_and_key_type_tag_cost_per_byte: Option<u64>,
1459 dynamic_field_add_child_object_cost_base: Option<u64>,
1461 dynamic_field_add_child_object_type_cost_per_byte: Option<u64>,
1462 dynamic_field_add_child_object_value_cost_per_byte: Option<u64>,
1463 dynamic_field_add_child_object_struct_tag_cost_per_byte: Option<u64>,
1464 dynamic_field_borrow_child_object_cost_base: Option<u64>,
1466 dynamic_field_borrow_child_object_child_ref_cost_per_byte: Option<u64>,
1467 dynamic_field_borrow_child_object_type_cost_per_byte: Option<u64>,
1468 dynamic_field_remove_child_object_cost_base: Option<u64>,
1470 dynamic_field_remove_child_object_child_cost_per_byte: Option<u64>,
1471 dynamic_field_remove_child_object_type_cost_per_byte: Option<u64>,
1472 dynamic_field_has_child_object_cost_base: Option<u64>,
1474 dynamic_field_has_child_object_with_ty_cost_base: Option<u64>,
1476 dynamic_field_has_child_object_with_ty_type_cost_per_byte: Option<u64>,
1477 dynamic_field_has_child_object_with_ty_type_tag_cost_per_byte: Option<u64>,
1478
1479 event_emit_cost_base: Option<u64>,
1482 event_emit_value_size_derivation_cost_per_byte: Option<u64>,
1483 event_emit_tag_size_derivation_cost_per_byte: Option<u64>,
1484 event_emit_output_cost_per_byte: Option<u64>,
1485 event_emit_auth_stream_cost: Option<u64>,
1486
1487 object_borrow_uid_cost_base: Option<u64>,
1490 object_delete_impl_cost_base: Option<u64>,
1492 object_record_new_uid_cost_base: Option<u64>,
1494
1495 transfer_transfer_internal_cost_base: Option<u64>,
1498 transfer_party_transfer_internal_cost_base: Option<u64>,
1500 transfer_freeze_object_cost_base: Option<u64>,
1502 transfer_share_object_cost_base: Option<u64>,
1504 transfer_receive_object_cost_base: Option<u64>,
1507
1508 tx_context_derive_id_cost_base: Option<u64>,
1511 tx_context_fresh_id_cost_base: Option<u64>,
1512 tx_context_sender_cost_base: Option<u64>,
1513 tx_context_epoch_cost_base: Option<u64>,
1514 tx_context_epoch_timestamp_ms_cost_base: Option<u64>,
1515 tx_context_sponsor_cost_base: Option<u64>,
1516 tx_context_rgp_cost_base: Option<u64>,
1517 tx_context_gas_price_cost_base: Option<u64>,
1518 tx_context_gas_budget_cost_base: Option<u64>,
1519 tx_context_ids_created_cost_base: Option<u64>,
1520 tx_context_replace_cost_base: Option<u64>,
1521
1522 types_is_one_time_witness_cost_base: Option<u64>,
1525 types_is_one_time_witness_type_tag_cost_per_byte: Option<u64>,
1526 types_is_one_time_witness_type_cost_per_byte: Option<u64>,
1527
1528 validator_validate_metadata_cost_base: Option<u64>,
1531 validator_validate_metadata_data_cost_per_byte: Option<u64>,
1532
1533 crypto_invalid_arguments_cost: Option<u64>,
1535 bls12381_bls12381_min_sig_verify_cost_base: Option<u64>,
1537 bls12381_bls12381_min_sig_verify_msg_cost_per_byte: Option<u64>,
1538 bls12381_bls12381_min_sig_verify_msg_cost_per_block: Option<u64>,
1539
1540 bls12381_bls12381_min_pk_verify_cost_base: Option<u64>,
1542 bls12381_bls12381_min_pk_verify_msg_cost_per_byte: Option<u64>,
1543 bls12381_bls12381_min_pk_verify_msg_cost_per_block: Option<u64>,
1544
1545 ecdsa_k1_ecrecover_keccak256_cost_base: Option<u64>,
1547 ecdsa_k1_ecrecover_keccak256_msg_cost_per_byte: Option<u64>,
1548 ecdsa_k1_ecrecover_keccak256_msg_cost_per_block: Option<u64>,
1549 ecdsa_k1_ecrecover_sha256_cost_base: Option<u64>,
1550 ecdsa_k1_ecrecover_sha256_msg_cost_per_byte: Option<u64>,
1551 ecdsa_k1_ecrecover_sha256_msg_cost_per_block: Option<u64>,
1552
1553 ecdsa_k1_decompress_pubkey_cost_base: Option<u64>,
1555
1556 ecdsa_k1_secp256k1_verify_keccak256_cost_base: Option<u64>,
1558 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_byte: Option<u64>,
1559 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_block: Option<u64>,
1560 ecdsa_k1_secp256k1_verify_sha256_cost_base: Option<u64>,
1561 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_byte: Option<u64>,
1562 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_block: Option<u64>,
1563
1564 ecdsa_r1_ecrecover_keccak256_cost_base: Option<u64>,
1566 ecdsa_r1_ecrecover_keccak256_msg_cost_per_byte: Option<u64>,
1567 ecdsa_r1_ecrecover_keccak256_msg_cost_per_block: Option<u64>,
1568 ecdsa_r1_ecrecover_sha256_cost_base: Option<u64>,
1569 ecdsa_r1_ecrecover_sha256_msg_cost_per_byte: Option<u64>,
1570 ecdsa_r1_ecrecover_sha256_msg_cost_per_block: Option<u64>,
1571
1572 ecdsa_r1_secp256r1_verify_keccak256_cost_base: Option<u64>,
1574 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_byte: Option<u64>,
1575 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_block: Option<u64>,
1576 ecdsa_r1_secp256r1_verify_sha256_cost_base: Option<u64>,
1577 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_byte: Option<u64>,
1578 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_block: Option<u64>,
1579
1580 ecvrf_ecvrf_verify_cost_base: Option<u64>,
1582 ecvrf_ecvrf_verify_alpha_string_cost_per_byte: Option<u64>,
1583 ecvrf_ecvrf_verify_alpha_string_cost_per_block: Option<u64>,
1584
1585 ed25519_ed25519_verify_cost_base: Option<u64>,
1587 ed25519_ed25519_verify_msg_cost_per_byte: Option<u64>,
1588 ed25519_ed25519_verify_msg_cost_per_block: Option<u64>,
1589
1590 groth16_prepare_verifying_key_bls12381_cost_base: Option<u64>,
1592 groth16_prepare_verifying_key_bn254_cost_base: Option<u64>,
1593
1594 groth16_verify_groth16_proof_internal_bls12381_cost_base: Option<u64>,
1596 groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input: Option<u64>,
1597 groth16_verify_groth16_proof_internal_bn254_cost_base: Option<u64>,
1598 groth16_verify_groth16_proof_internal_bn254_cost_per_public_input: Option<u64>,
1599 groth16_verify_groth16_proof_internal_public_input_cost_per_byte: Option<u64>,
1600
1601 hash_blake2b256_cost_base: Option<u64>,
1603 hash_blake2b256_data_cost_per_byte: Option<u64>,
1604 hash_blake2b256_data_cost_per_block: Option<u64>,
1605
1606 hash_keccak256_cost_base: Option<u64>,
1608 hash_keccak256_data_cost_per_byte: Option<u64>,
1609 hash_keccak256_data_cost_per_block: Option<u64>,
1610
1611 poseidon_bn254_cost_base: Option<u64>,
1613 poseidon_bn254_cost_per_block: Option<u64>,
1614
1615 group_ops_bls12381_decode_scalar_cost: Option<u64>,
1617 group_ops_bls12381_decode_g1_cost: Option<u64>,
1618 group_ops_bls12381_decode_g2_cost: Option<u64>,
1619 group_ops_bls12381_decode_gt_cost: Option<u64>,
1620 group_ops_bls12381_scalar_add_cost: Option<u64>,
1621 group_ops_bls12381_g1_add_cost: Option<u64>,
1622 group_ops_bls12381_g2_add_cost: Option<u64>,
1623 group_ops_bls12381_gt_add_cost: Option<u64>,
1624 group_ops_bls12381_scalar_sub_cost: Option<u64>,
1625 group_ops_bls12381_g1_sub_cost: Option<u64>,
1626 group_ops_bls12381_g2_sub_cost: Option<u64>,
1627 group_ops_bls12381_gt_sub_cost: Option<u64>,
1628 group_ops_bls12381_scalar_mul_cost: Option<u64>,
1629 group_ops_bls12381_g1_mul_cost: Option<u64>,
1630 group_ops_bls12381_g2_mul_cost: Option<u64>,
1631 group_ops_bls12381_gt_mul_cost: Option<u64>,
1632 group_ops_bls12381_scalar_div_cost: Option<u64>,
1633 group_ops_bls12381_g1_div_cost: Option<u64>,
1634 group_ops_bls12381_g2_div_cost: Option<u64>,
1635 group_ops_bls12381_gt_div_cost: Option<u64>,
1636 group_ops_bls12381_g1_hash_to_base_cost: Option<u64>,
1637 group_ops_bls12381_g2_hash_to_base_cost: Option<u64>,
1638 group_ops_bls12381_g1_hash_to_cost_per_byte: Option<u64>,
1639 group_ops_bls12381_g2_hash_to_cost_per_byte: Option<u64>,
1640 group_ops_bls12381_g1_msm_base_cost: Option<u64>,
1641 group_ops_bls12381_g2_msm_base_cost: Option<u64>,
1642 group_ops_bls12381_g1_msm_base_cost_per_input: Option<u64>,
1643 group_ops_bls12381_g2_msm_base_cost_per_input: Option<u64>,
1644 group_ops_bls12381_msm_max_len: Option<u32>,
1645 group_ops_bls12381_pairing_cost: Option<u64>,
1646 group_ops_bls12381_g1_to_uncompressed_g1_cost: Option<u64>,
1647 group_ops_bls12381_uncompressed_g1_to_g1_cost: Option<u64>,
1648 group_ops_bls12381_uncompressed_g1_sum_base_cost: Option<u64>,
1649 group_ops_bls12381_uncompressed_g1_sum_cost_per_term: Option<u64>,
1650 group_ops_bls12381_uncompressed_g1_sum_max_terms: Option<u64>,
1651
1652 group_ops_ristretto_decode_scalar_cost: Option<u64>,
1653 group_ops_ristretto_decode_point_cost: Option<u64>,
1654 group_ops_ristretto_scalar_add_cost: Option<u64>,
1655 group_ops_ristretto_point_add_cost: Option<u64>,
1656 group_ops_ristretto_scalar_sub_cost: Option<u64>,
1657 group_ops_ristretto_point_sub_cost: Option<u64>,
1658 group_ops_ristretto_scalar_mul_cost: Option<u64>,
1659 group_ops_ristretto_point_mul_cost: Option<u64>,
1660 group_ops_ristretto_scalar_div_cost: Option<u64>,
1661 group_ops_ristretto_point_div_cost: Option<u64>,
1662
1663 hmac_hmac_sha3_256_cost_base: Option<u64>,
1665 hmac_hmac_sha3_256_input_cost_per_byte: Option<u64>,
1666 hmac_hmac_sha3_256_input_cost_per_block: Option<u64>,
1667
1668 check_zklogin_id_cost_base: Option<u64>,
1670 check_zklogin_issuer_cost_base: Option<u64>,
1672
1673 vdf_verify_vdf_cost: Option<u64>,
1674 vdf_hash_to_input_cost: Option<u64>,
1675
1676 nitro_attestation_parse_base_cost: Option<u64>,
1678 nitro_attestation_parse_cost_per_byte: Option<u64>,
1679 nitro_attestation_verify_base_cost: Option<u64>,
1680 nitro_attestation_verify_cost_per_cert: Option<u64>,
1681
1682 bcs_per_byte_serialized_cost: Option<u64>,
1684 bcs_legacy_min_output_size_cost: Option<u64>,
1685 bcs_failure_cost: Option<u64>,
1686
1687 hash_sha2_256_base_cost: Option<u64>,
1688 hash_sha2_256_per_byte_cost: Option<u64>,
1689 hash_sha2_256_legacy_min_input_len_cost: Option<u64>,
1690 hash_sha3_256_base_cost: Option<u64>,
1691 hash_sha3_256_per_byte_cost: Option<u64>,
1692 hash_sha3_256_legacy_min_input_len_cost: Option<u64>,
1693 type_name_get_base_cost: Option<u64>,
1694 type_name_get_per_byte_cost: Option<u64>,
1695 type_name_id_base_cost: Option<u64>,
1696
1697 string_check_utf8_base_cost: Option<u64>,
1698 string_check_utf8_per_byte_cost: Option<u64>,
1699 string_is_char_boundary_base_cost: Option<u64>,
1700 string_sub_string_base_cost: Option<u64>,
1701 string_sub_string_per_byte_cost: Option<u64>,
1702 string_index_of_base_cost: Option<u64>,
1703 string_index_of_per_byte_pattern_cost: Option<u64>,
1704 string_index_of_per_byte_searched_cost: Option<u64>,
1705
1706 vector_empty_base_cost: Option<u64>,
1707 vector_length_base_cost: Option<u64>,
1708 vector_push_back_base_cost: Option<u64>,
1709 vector_push_back_legacy_per_abstract_memory_unit_cost: Option<u64>,
1710 vector_borrow_base_cost: Option<u64>,
1711 vector_pop_back_base_cost: Option<u64>,
1712 vector_destroy_empty_base_cost: Option<u64>,
1713 vector_swap_base_cost: Option<u64>,
1714 debug_print_base_cost: Option<u64>,
1715 debug_print_stack_trace_base_cost: Option<u64>,
1716
1717 execution_version: Option<u64>,
1726
1727 consensus_bad_nodes_stake_threshold: Option<u64>,
1731
1732 max_jwk_votes_per_validator_per_epoch: Option<u64>,
1733 max_age_of_jwk_in_epochs: Option<u64>,
1737
1738 random_beacon_reduction_allowed_delta: Option<u16>,
1742
1743 random_beacon_reduction_lower_bound: Option<u32>,
1746
1747 random_beacon_dkg_timeout_round: Option<u32>,
1750
1751 random_beacon_min_round_interval_ms: Option<u64>,
1753
1754 random_beacon_dkg_version: Option<u64>,
1757
1758 consensus_max_transaction_size_bytes: Option<u64>,
1761 consensus_max_transactions_in_block_bytes: Option<u64>,
1763 consensus_max_num_transactions_in_block: Option<u64>,
1765
1766 consensus_voting_rounds: Option<u32>,
1768
1769 max_accumulated_txn_cost_per_object_in_narwhal_commit: Option<u64>,
1771
1772 max_deferral_rounds_for_congestion_control: Option<u64>,
1775
1776 max_txn_cost_overage_per_object_in_commit: Option<u64>,
1778
1779 allowed_txn_cost_overage_burst_per_object_in_commit: Option<u64>,
1781
1782 min_checkpoint_interval_ms: Option<u64>,
1784
1785 checkpoint_summary_version_specific_data: Option<u64>,
1787
1788 max_soft_bundle_size: Option<u64>,
1790
1791 bridge_should_try_to_finalize_committee: Option<bool>,
1795
1796 max_accumulated_txn_cost_per_object_in_mysticeti_commit: Option<u64>,
1802
1803 max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit: Option<u64>,
1806
1807 consensus_gc_depth: Option<u32>,
1810
1811 gas_budget_based_txn_cost_cap_factor: Option<u64>,
1813
1814 gas_budget_based_txn_cost_absolute_cap_commit_count: Option<u64>,
1816
1817 sip_45_consensus_amplification_threshold: Option<u64>,
1820
1821 use_object_per_epoch_marker_table_v2: Option<bool>,
1824
1825 consensus_commit_rate_estimation_window_size: Option<u32>,
1827
1828 #[serde(skip_serializing_if = "Vec::is_empty")]
1832 aliased_addresses: Vec<AliasedAddress>,
1833
1834 translation_per_command_base_charge: Option<u64>,
1837
1838 translation_per_input_base_charge: Option<u64>,
1841
1842 translation_pure_input_per_byte_charge: Option<u64>,
1844
1845 translation_per_type_node_charge: Option<u64>,
1849
1850 translation_per_reference_node_charge: Option<u64>,
1853
1854 translation_per_linkage_entry_charge: Option<u64>,
1857
1858 max_updates_per_settlement_txn: Option<u32>,
1860}
1861
1862#[derive(Clone, Serialize, Deserialize, Debug)]
1864pub struct AliasedAddress {
1865 pub original: [u8; 32],
1867 pub aliased: [u8; 32],
1869 pub allowed_tx_digests: Vec<[u8; 32]>,
1871}
1872
1873impl ProtocolConfig {
1875 pub fn check_package_upgrades_supported(&self) -> Result<(), Error> {
1888 if self.feature_flags.package_upgrades {
1889 Ok(())
1890 } else {
1891 Err(Error(format!(
1892 "package upgrades are not supported at {:?}",
1893 self.version
1894 )))
1895 }
1896 }
1897
1898 pub fn allow_receiving_object_id(&self) -> bool {
1899 self.feature_flags.allow_receiving_object_id
1900 }
1901
1902 pub fn receiving_objects_supported(&self) -> bool {
1903 self.feature_flags.receive_objects
1904 }
1905
1906 pub fn package_upgrades_supported(&self) -> bool {
1907 self.feature_flags.package_upgrades
1908 }
1909
1910 pub fn check_commit_root_state_digest_supported(&self) -> bool {
1911 self.feature_flags.commit_root_state_digest
1912 }
1913
1914 pub fn get_advance_epoch_start_time_in_safe_mode(&self) -> bool {
1915 self.feature_flags.advance_epoch_start_time_in_safe_mode
1916 }
1917
1918 pub fn loaded_child_objects_fixed(&self) -> bool {
1919 self.feature_flags.loaded_child_objects_fixed
1920 }
1921
1922 pub fn missing_type_is_compatibility_error(&self) -> bool {
1923 self.feature_flags.missing_type_is_compatibility_error
1924 }
1925
1926 pub fn scoring_decision_with_validity_cutoff(&self) -> bool {
1927 self.feature_flags.scoring_decision_with_validity_cutoff
1928 }
1929
1930 pub fn narwhal_versioned_metadata(&self) -> bool {
1931 self.feature_flags.narwhal_versioned_metadata
1932 }
1933
1934 pub fn consensus_order_end_of_epoch_last(&self) -> bool {
1935 self.feature_flags.consensus_order_end_of_epoch_last
1936 }
1937
1938 pub fn disallow_adding_abilities_on_upgrade(&self) -> bool {
1939 self.feature_flags.disallow_adding_abilities_on_upgrade
1940 }
1941
1942 pub fn disable_invariant_violation_check_in_swap_loc(&self) -> bool {
1943 self.feature_flags
1944 .disable_invariant_violation_check_in_swap_loc
1945 }
1946
1947 pub fn advance_to_highest_supported_protocol_version(&self) -> bool {
1948 self.feature_flags
1949 .advance_to_highest_supported_protocol_version
1950 }
1951
1952 pub fn ban_entry_init(&self) -> bool {
1953 self.feature_flags.ban_entry_init
1954 }
1955
1956 pub fn package_digest_hash_module(&self) -> bool {
1957 self.feature_flags.package_digest_hash_module
1958 }
1959
1960 pub fn disallow_change_struct_type_params_on_upgrade(&self) -> bool {
1961 self.feature_flags
1962 .disallow_change_struct_type_params_on_upgrade
1963 }
1964
1965 pub fn no_extraneous_module_bytes(&self) -> bool {
1966 self.feature_flags.no_extraneous_module_bytes
1967 }
1968
1969 pub fn zklogin_auth(&self) -> bool {
1970 self.feature_flags.zklogin_auth
1971 }
1972
1973 pub fn zklogin_supported_providers(&self) -> &BTreeSet<String> {
1974 &self.feature_flags.zklogin_supported_providers
1975 }
1976
1977 pub fn consensus_transaction_ordering(&self) -> ConsensusTransactionOrdering {
1978 self.feature_flags.consensus_transaction_ordering
1979 }
1980
1981 pub fn simplified_unwrap_then_delete(&self) -> bool {
1982 self.feature_flags.simplified_unwrap_then_delete
1983 }
1984
1985 pub fn supports_upgraded_multisig(&self) -> bool {
1986 self.feature_flags.upgraded_multisig_supported
1987 }
1988
1989 pub fn txn_base_cost_as_multiplier(&self) -> bool {
1990 self.feature_flags.txn_base_cost_as_multiplier
1991 }
1992
1993 pub fn shared_object_deletion(&self) -> bool {
1994 self.feature_flags.shared_object_deletion
1995 }
1996
1997 pub fn narwhal_new_leader_election_schedule(&self) -> bool {
1998 self.feature_flags.narwhal_new_leader_election_schedule
1999 }
2000
2001 pub fn loaded_child_object_format(&self) -> bool {
2002 self.feature_flags.loaded_child_object_format
2003 }
2004
2005 pub fn enable_jwk_consensus_updates(&self) -> bool {
2006 let ret = self.feature_flags.enable_jwk_consensus_updates;
2007 if ret {
2008 assert!(self.feature_flags.end_of_epoch_transaction_supported);
2010 }
2011 ret
2012 }
2013
2014 pub fn simple_conservation_checks(&self) -> bool {
2015 self.feature_flags.simple_conservation_checks
2016 }
2017
2018 pub fn loaded_child_object_format_type(&self) -> bool {
2019 self.feature_flags.loaded_child_object_format_type
2020 }
2021
2022 pub fn end_of_epoch_transaction_supported(&self) -> bool {
2023 let ret = self.feature_flags.end_of_epoch_transaction_supported;
2024 if !ret {
2025 assert!(!self.feature_flags.enable_jwk_consensus_updates);
2027 }
2028 ret
2029 }
2030
2031 pub fn recompute_has_public_transfer_in_execution(&self) -> bool {
2032 self.feature_flags
2033 .recompute_has_public_transfer_in_execution
2034 }
2035
2036 pub fn create_authenticator_state_in_genesis(&self) -> bool {
2038 self.enable_jwk_consensus_updates()
2039 }
2040
2041 pub fn random_beacon(&self) -> bool {
2042 self.feature_flags.random_beacon
2043 }
2044
2045 pub fn dkg_version(&self) -> u64 {
2046 self.random_beacon_dkg_version.unwrap_or(1)
2048 }
2049
2050 pub fn enable_bridge(&self) -> bool {
2051 let ret = self.feature_flags.bridge;
2052 if ret {
2053 assert!(self.feature_flags.end_of_epoch_transaction_supported);
2055 }
2056 ret
2057 }
2058
2059 pub fn should_try_to_finalize_bridge_committee(&self) -> bool {
2060 if !self.enable_bridge() {
2061 return false;
2062 }
2063 self.bridge_should_try_to_finalize_committee.unwrap_or(true)
2065 }
2066
2067 pub fn enable_effects_v2(&self) -> bool {
2068 self.feature_flags.enable_effects_v2
2069 }
2070
2071 pub fn narwhal_certificate_v2(&self) -> bool {
2072 self.feature_flags.narwhal_certificate_v2
2073 }
2074
2075 pub fn verify_legacy_zklogin_address(&self) -> bool {
2076 self.feature_flags.verify_legacy_zklogin_address
2077 }
2078
2079 pub fn accept_zklogin_in_multisig(&self) -> bool {
2080 self.feature_flags.accept_zklogin_in_multisig
2081 }
2082
2083 pub fn accept_passkey_in_multisig(&self) -> bool {
2084 self.feature_flags.accept_passkey_in_multisig
2085 }
2086
2087 pub fn validate_zklogin_public_identifier(&self) -> bool {
2088 self.feature_flags.validate_zklogin_public_identifier
2089 }
2090
2091 pub fn zklogin_max_epoch_upper_bound_delta(&self) -> Option<u64> {
2092 self.feature_flags.zklogin_max_epoch_upper_bound_delta
2093 }
2094
2095 pub fn throughput_aware_consensus_submission(&self) -> bool {
2096 self.feature_flags.throughput_aware_consensus_submission
2097 }
2098
2099 pub fn include_consensus_digest_in_prologue(&self) -> bool {
2100 self.feature_flags.include_consensus_digest_in_prologue
2101 }
2102
2103 pub fn record_consensus_determined_version_assignments_in_prologue(&self) -> bool {
2104 self.feature_flags
2105 .record_consensus_determined_version_assignments_in_prologue
2106 }
2107
2108 pub fn record_additional_state_digest_in_prologue(&self) -> bool {
2109 self.feature_flags
2110 .record_additional_state_digest_in_prologue
2111 }
2112
2113 pub fn record_consensus_determined_version_assignments_in_prologue_v2(&self) -> bool {
2114 self.feature_flags
2115 .record_consensus_determined_version_assignments_in_prologue_v2
2116 }
2117
2118 pub fn prepend_prologue_tx_in_consensus_commit_in_checkpoints(&self) -> bool {
2119 self.feature_flags
2120 .prepend_prologue_tx_in_consensus_commit_in_checkpoints
2121 }
2122
2123 pub fn hardened_otw_check(&self) -> bool {
2124 self.feature_flags.hardened_otw_check
2125 }
2126
2127 pub fn enable_poseidon(&self) -> bool {
2128 self.feature_flags.enable_poseidon
2129 }
2130
2131 pub fn enable_coin_deny_list_v1(&self) -> bool {
2132 self.feature_flags.enable_coin_deny_list
2133 }
2134
2135 pub fn enable_accumulators(&self) -> bool {
2136 self.feature_flags.enable_accumulators
2137 }
2138
2139 pub fn enable_coin_reservation_obj_refs(&self) -> bool {
2140 self.feature_flags.enable_coin_reservation_obj_refs
2141 }
2142
2143 pub fn create_root_accumulator_object(&self) -> bool {
2144 self.feature_flags.create_root_accumulator_object
2145 }
2146
2147 pub fn enable_address_balance_gas_payments(&self) -> bool {
2148 self.feature_flags.enable_address_balance_gas_payments
2149 }
2150
2151 pub fn enable_multi_epoch_transaction_expiration(&self) -> bool {
2152 self.feature_flags.enable_multi_epoch_transaction_expiration
2153 }
2154
2155 pub fn enable_authenticated_event_streams(&self) -> bool {
2156 self.feature_flags.enable_authenticated_event_streams && self.enable_accumulators()
2157 }
2158
2159 pub fn enable_non_exclusive_writes(&self) -> bool {
2160 self.feature_flags.enable_non_exclusive_writes
2161 }
2162
2163 pub fn enable_coin_registry(&self) -> bool {
2164 self.feature_flags.enable_coin_registry
2165 }
2166
2167 pub fn enable_display_registry(&self) -> bool {
2168 self.feature_flags.enable_display_registry
2169 }
2170
2171 pub fn enable_coin_deny_list_v2(&self) -> bool {
2172 self.feature_flags.enable_coin_deny_list_v2
2173 }
2174
2175 pub fn enable_group_ops_native_functions(&self) -> bool {
2176 self.feature_flags.enable_group_ops_native_functions
2177 }
2178
2179 pub fn enable_group_ops_native_function_msm(&self) -> bool {
2180 self.feature_flags.enable_group_ops_native_function_msm
2181 }
2182
2183 pub fn enable_ristretto255_group_ops(&self) -> bool {
2184 self.feature_flags.enable_ristretto255_group_ops
2185 }
2186
2187 pub fn reject_mutable_random_on_entry_functions(&self) -> bool {
2188 self.feature_flags.reject_mutable_random_on_entry_functions
2189 }
2190
2191 pub fn per_object_congestion_control_mode(&self) -> PerObjectCongestionControlMode {
2192 self.feature_flags.per_object_congestion_control_mode
2193 }
2194
2195 pub fn consensus_choice(&self) -> ConsensusChoice {
2196 self.feature_flags.consensus_choice
2197 }
2198
2199 pub fn consensus_network(&self) -> ConsensusNetwork {
2200 self.feature_flags.consensus_network
2201 }
2202
2203 pub fn correct_gas_payment_limit_check(&self) -> bool {
2204 self.feature_flags.correct_gas_payment_limit_check
2205 }
2206
2207 pub fn reshare_at_same_initial_version(&self) -> bool {
2208 self.feature_flags.reshare_at_same_initial_version
2209 }
2210
2211 pub fn resolve_abort_locations_to_package_id(&self) -> bool {
2212 self.feature_flags.resolve_abort_locations_to_package_id
2213 }
2214
2215 pub fn mysticeti_use_committed_subdag_digest(&self) -> bool {
2216 self.feature_flags.mysticeti_use_committed_subdag_digest
2217 }
2218
2219 pub fn enable_vdf(&self) -> bool {
2220 self.feature_flags.enable_vdf
2221 }
2222
2223 pub fn fresh_vm_on_framework_upgrade(&self) -> bool {
2224 self.feature_flags.fresh_vm_on_framework_upgrade
2225 }
2226
2227 pub fn mysticeti_num_leaders_per_round(&self) -> Option<usize> {
2228 self.feature_flags.mysticeti_num_leaders_per_round
2229 }
2230
2231 pub fn soft_bundle(&self) -> bool {
2232 self.feature_flags.soft_bundle
2233 }
2234
2235 pub fn passkey_auth(&self) -> bool {
2236 self.feature_flags.passkey_auth
2237 }
2238
2239 pub fn authority_capabilities_v2(&self) -> bool {
2240 self.feature_flags.authority_capabilities_v2
2241 }
2242
2243 pub fn max_transaction_size_bytes(&self) -> u64 {
2244 self.consensus_max_transaction_size_bytes
2246 .unwrap_or(256 * 1024)
2247 }
2248
2249 pub fn max_transactions_in_block_bytes(&self) -> u64 {
2250 if cfg!(msim) {
2251 256 * 1024
2252 } else {
2253 self.consensus_max_transactions_in_block_bytes
2254 .unwrap_or(512 * 1024)
2255 }
2256 }
2257
2258 pub fn max_num_transactions_in_block(&self) -> u64 {
2259 if cfg!(msim) {
2260 8
2261 } else {
2262 self.consensus_max_num_transactions_in_block.unwrap_or(512)
2263 }
2264 }
2265
2266 pub fn rethrow_serialization_type_layout_errors(&self) -> bool {
2267 self.feature_flags.rethrow_serialization_type_layout_errors
2268 }
2269
2270 pub fn consensus_distributed_vote_scoring_strategy(&self) -> bool {
2271 self.feature_flags
2272 .consensus_distributed_vote_scoring_strategy
2273 }
2274
2275 pub fn consensus_round_prober(&self) -> bool {
2276 self.feature_flags.consensus_round_prober
2277 }
2278
2279 pub fn validate_identifier_inputs(&self) -> bool {
2280 self.feature_flags.validate_identifier_inputs
2281 }
2282
2283 pub fn gc_depth(&self) -> u32 {
2284 self.consensus_gc_depth.unwrap_or(0)
2285 }
2286
2287 pub fn mysticeti_fastpath(&self) -> bool {
2288 self.feature_flags.mysticeti_fastpath
2289 }
2290
2291 pub fn relocate_event_module(&self) -> bool {
2292 self.feature_flags.relocate_event_module
2293 }
2294
2295 pub fn uncompressed_g1_group_elements(&self) -> bool {
2296 self.feature_flags.uncompressed_g1_group_elements
2297 }
2298
2299 pub fn disallow_new_modules_in_deps_only_packages(&self) -> bool {
2300 self.feature_flags
2301 .disallow_new_modules_in_deps_only_packages
2302 }
2303
2304 pub fn consensus_smart_ancestor_selection(&self) -> bool {
2305 self.feature_flags.consensus_smart_ancestor_selection
2306 }
2307
2308 pub fn disable_preconsensus_locking(&self) -> bool {
2309 self.feature_flags.disable_preconsensus_locking
2310 }
2311
2312 pub fn consensus_round_prober_probe_accepted_rounds(&self) -> bool {
2313 self.feature_flags
2314 .consensus_round_prober_probe_accepted_rounds
2315 }
2316
2317 pub fn native_charging_v2(&self) -> bool {
2318 self.feature_flags.native_charging_v2
2319 }
2320
2321 pub fn consensus_linearize_subdag_v2(&self) -> bool {
2322 let res = self.feature_flags.consensus_linearize_subdag_v2;
2323 assert!(
2324 !res || self.gc_depth() > 0,
2325 "The consensus linearize sub dag V2 requires GC to be enabled"
2326 );
2327 res
2328 }
2329
2330 pub fn consensus_median_based_commit_timestamp(&self) -> bool {
2331 let res = self.feature_flags.consensus_median_based_commit_timestamp;
2332 assert!(
2333 !res || self.gc_depth() > 0,
2334 "The consensus median based commit timestamp requires GC to be enabled"
2335 );
2336 res
2337 }
2338
2339 pub fn consensus_batched_block_sync(&self) -> bool {
2340 self.feature_flags.consensus_batched_block_sync
2341 }
2342
2343 pub fn convert_type_argument_error(&self) -> bool {
2344 self.feature_flags.convert_type_argument_error
2345 }
2346
2347 pub fn variant_nodes(&self) -> bool {
2348 self.feature_flags.variant_nodes
2349 }
2350
2351 pub fn consensus_zstd_compression(&self) -> bool {
2352 self.feature_flags.consensus_zstd_compression
2353 }
2354
2355 pub fn enable_nitro_attestation(&self) -> bool {
2356 self.feature_flags.enable_nitro_attestation
2357 }
2358
2359 pub fn enable_nitro_attestation_upgraded_parsing(&self) -> bool {
2360 self.feature_flags.enable_nitro_attestation_upgraded_parsing
2361 }
2362
2363 pub fn enable_nitro_attestation_all_nonzero_pcrs_parsing(&self) -> bool {
2364 self.feature_flags
2365 .enable_nitro_attestation_all_nonzero_pcrs_parsing
2366 }
2367
2368 pub fn enable_nitro_attestation_always_include_required_pcrs_parsing(&self) -> bool {
2369 self.feature_flags
2370 .enable_nitro_attestation_always_include_required_pcrs_parsing
2371 }
2372
2373 pub fn get_consensus_commit_rate_estimation_window_size(&self) -> u32 {
2374 self.consensus_commit_rate_estimation_window_size
2375 .unwrap_or(0)
2376 }
2377
2378 pub fn consensus_num_requested_prior_commits_at_startup(&self) -> u32 {
2379 let window_size = self.get_consensus_commit_rate_estimation_window_size();
2383 assert!(window_size == 0 || self.record_additional_state_digest_in_prologue());
2385 window_size
2386 }
2387
2388 pub fn minimize_child_object_mutations(&self) -> bool {
2389 self.feature_flags.minimize_child_object_mutations
2390 }
2391
2392 pub fn move_native_context(&self) -> bool {
2393 self.feature_flags.move_native_context
2394 }
2395
2396 pub fn normalize_ptb_arguments(&self) -> bool {
2397 self.feature_flags.normalize_ptb_arguments
2398 }
2399
2400 pub fn enforce_checkpoint_timestamp_monotonicity(&self) -> bool {
2401 self.feature_flags.enforce_checkpoint_timestamp_monotonicity
2402 }
2403
2404 pub fn max_ptb_value_size_v2(&self) -> bool {
2405 self.feature_flags.max_ptb_value_size_v2
2406 }
2407
2408 pub fn resolve_type_input_ids_to_defining_id(&self) -> bool {
2409 self.feature_flags.resolve_type_input_ids_to_defining_id
2410 }
2411
2412 pub fn enable_party_transfer(&self) -> bool {
2413 self.feature_flags.enable_party_transfer
2414 }
2415
2416 pub fn allow_unbounded_system_objects(&self) -> bool {
2417 self.feature_flags.allow_unbounded_system_objects
2418 }
2419
2420 pub fn type_tags_in_object_runtime(&self) -> bool {
2421 self.feature_flags.type_tags_in_object_runtime
2422 }
2423
2424 pub fn enable_ptb_execution_v2(&self) -> bool {
2425 self.feature_flags.enable_ptb_execution_v2
2426 }
2427
2428 pub fn better_adapter_type_resolution_errors(&self) -> bool {
2429 self.feature_flags.better_adapter_type_resolution_errors
2430 }
2431
2432 pub fn record_time_estimate_processed(&self) -> bool {
2433 self.feature_flags.record_time_estimate_processed
2434 }
2435
2436 pub fn ignore_execution_time_observations_after_certs_closed(&self) -> bool {
2437 self.feature_flags
2438 .ignore_execution_time_observations_after_certs_closed
2439 }
2440
2441 pub fn dependency_linkage_error(&self) -> bool {
2442 self.feature_flags.dependency_linkage_error
2443 }
2444
2445 pub fn additional_multisig_checks(&self) -> bool {
2446 self.feature_flags.additional_multisig_checks
2447 }
2448
2449 pub fn debug_fatal_on_move_invariant_violation(&self) -> bool {
2450 self.feature_flags.debug_fatal_on_move_invariant_violation
2451 }
2452
2453 pub fn allow_private_accumulator_entrypoints(&self) -> bool {
2454 self.feature_flags.allow_private_accumulator_entrypoints
2455 }
2456
2457 pub fn additional_consensus_digest_indirect_state(&self) -> bool {
2458 self.feature_flags
2459 .additional_consensus_digest_indirect_state
2460 }
2461
2462 pub fn check_for_init_during_upgrade(&self) -> bool {
2463 self.feature_flags.check_for_init_during_upgrade
2464 }
2465
2466 pub fn per_command_shared_object_transfer_rules(&self) -> bool {
2467 self.feature_flags.per_command_shared_object_transfer_rules
2468 }
2469
2470 pub fn consensus_checkpoint_signature_key_includes_digest(&self) -> bool {
2471 self.feature_flags
2472 .consensus_checkpoint_signature_key_includes_digest
2473 }
2474
2475 pub fn include_checkpoint_artifacts_digest_in_summary(&self) -> bool {
2476 self.feature_flags
2477 .include_checkpoint_artifacts_digest_in_summary
2478 }
2479
2480 pub fn use_mfp_txns_in_load_initial_object_debts(&self) -> bool {
2481 self.feature_flags.use_mfp_txns_in_load_initial_object_debts
2482 }
2483
2484 pub fn cancel_for_failed_dkg_early(&self) -> bool {
2485 self.feature_flags.cancel_for_failed_dkg_early
2486 }
2487
2488 pub fn abstract_size_in_object_runtime(&self) -> bool {
2489 self.feature_flags.abstract_size_in_object_runtime
2490 }
2491
2492 pub fn object_runtime_charge_cache_load_gas(&self) -> bool {
2493 self.feature_flags.object_runtime_charge_cache_load_gas
2494 }
2495
2496 pub fn additional_borrow_checks(&self) -> bool {
2497 self.feature_flags.additional_borrow_checks
2498 }
2499
2500 pub fn use_new_commit_handler(&self) -> bool {
2501 self.feature_flags.use_new_commit_handler
2502 }
2503
2504 pub fn better_loader_errors(&self) -> bool {
2505 self.feature_flags.better_loader_errors
2506 }
2507
2508 pub fn generate_df_type_layouts(&self) -> bool {
2509 self.feature_flags.generate_df_type_layouts
2510 }
2511
2512 pub fn allow_references_in_ptbs(&self) -> bool {
2513 self.feature_flags.allow_references_in_ptbs
2514 }
2515
2516 pub fn private_generics_verifier_v2(&self) -> bool {
2517 self.feature_flags.private_generics_verifier_v2
2518 }
2519
2520 pub fn deprecate_global_storage_ops_during_deserialization(&self) -> bool {
2521 self.feature_flags
2522 .deprecate_global_storage_ops_during_deserialization
2523 }
2524
2525 pub fn enable_observation_chunking(&self) -> bool {
2526 matches!(self.feature_flags.per_object_congestion_control_mode,
2527 PerObjectCongestionControlMode::ExecutionTimeEstimate(ref params)
2528 if params.observations_chunk_size.is_some()
2529 )
2530 }
2531
2532 pub fn deprecate_global_storage_ops(&self) -> bool {
2533 self.feature_flags.deprecate_global_storage_ops
2534 }
2535
2536 pub fn consensus_skip_gced_accept_votes(&self) -> bool {
2537 self.feature_flags.consensus_skip_gced_accept_votes
2538 }
2539
2540 pub fn include_cancelled_randomness_txns_in_prologue(&self) -> bool {
2541 self.feature_flags
2542 .include_cancelled_randomness_txns_in_prologue
2543 }
2544
2545 pub fn address_aliases(&self) -> bool {
2546 let address_aliases = self.feature_flags.address_aliases;
2547 assert!(
2548 !address_aliases || self.mysticeti_fastpath(),
2549 "Address aliases requires Mysticeti fastpath to be enabled"
2550 );
2551 if address_aliases {
2552 assert!(
2553 self.feature_flags.disable_preconsensus_locking,
2554 "Address aliases requires CertifiedTransaction to be disabled"
2555 );
2556 }
2557 address_aliases
2558 }
2559
2560 pub fn fix_checkpoint_signature_mapping(&self) -> bool {
2561 self.feature_flags.fix_checkpoint_signature_mapping
2562 }
2563
2564 pub fn enable_object_funds_withdraw(&self) -> bool {
2565 self.feature_flags.enable_object_funds_withdraw
2566 }
2567
2568 pub fn gas_rounding_halve_digits(&self) -> bool {
2569 self.feature_flags.gas_rounding_halve_digits
2570 }
2571
2572 pub fn flexible_tx_context_positions(&self) -> bool {
2573 self.feature_flags.flexible_tx_context_positions
2574 }
2575
2576 pub fn disable_entry_point_signature_check(&self) -> bool {
2577 self.feature_flags.disable_entry_point_signature_check
2578 }
2579
2580 pub fn consensus_skip_gced_blocks_in_direct_finalization(&self) -> bool {
2581 self.feature_flags
2582 .consensus_skip_gced_blocks_in_direct_finalization
2583 }
2584
2585 pub fn convert_withdrawal_compatibility_ptb_arguments(&self) -> bool {
2586 self.feature_flags
2587 .convert_withdrawal_compatibility_ptb_arguments
2588 }
2589
2590 pub fn restrict_hot_or_not_entry_functions(&self) -> bool {
2591 self.feature_flags.restrict_hot_or_not_entry_functions
2592 }
2593
2594 pub fn split_checkpoints_in_consensus_handler(&self) -> bool {
2595 self.feature_flags.split_checkpoints_in_consensus_handler
2596 }
2597
2598 pub fn consensus_always_accept_system_transactions(&self) -> bool {
2599 self.feature_flags
2600 .consensus_always_accept_system_transactions
2601 }
2602
2603 pub fn validator_metadata_verify_v2(&self) -> bool {
2604 self.feature_flags.validator_metadata_verify_v2
2605 }
2606}
2607
2608#[cfg(not(msim))]
2609static POISON_VERSION_METHODS: AtomicBool = AtomicBool::new(false);
2610
2611#[cfg(msim)]
2613thread_local! {
2614 static POISON_VERSION_METHODS: AtomicBool = AtomicBool::new(false);
2615}
2616
2617impl ProtocolConfig {
2619 pub fn get_for_version(version: ProtocolVersion, chain: Chain) -> Self {
2621 assert!(
2623 version >= ProtocolVersion::MIN,
2624 "Network protocol version is {:?}, but the minimum supported version by the binary is {:?}. Please upgrade the binary.",
2625 version,
2626 ProtocolVersion::MIN.0,
2627 );
2628 assert!(
2629 version <= ProtocolVersion::MAX_ALLOWED,
2630 "Network protocol version is {:?}, but the maximum supported version by the binary is {:?}. Please upgrade the binary.",
2631 version,
2632 ProtocolVersion::MAX_ALLOWED.0,
2633 );
2634
2635 let mut ret = Self::get_for_version_impl(version, chain);
2636 ret.version = version;
2637
2638 ret = CONFIG_OVERRIDE.with(|ovr| {
2639 if let Some(override_fn) = &*ovr.borrow() {
2640 warn!(
2641 "overriding ProtocolConfig settings with custom settings (you should not see this log outside of tests)"
2642 );
2643 override_fn(version, ret)
2644 } else {
2645 ret
2646 }
2647 });
2648
2649 if std::env::var("SUI_PROTOCOL_CONFIG_OVERRIDE_ENABLE").is_ok() {
2650 warn!(
2651 "overriding ProtocolConfig settings with custom settings; this may break non-local networks"
2652 );
2653 let overrides: ProtocolConfigOptional =
2654 serde_env::from_env_with_prefix("SUI_PROTOCOL_CONFIG_OVERRIDE")
2655 .expect("failed to parse ProtocolConfig override env variables");
2656 overrides.apply_to(&mut ret);
2657 }
2658
2659 ret
2660 }
2661
2662 pub fn get_for_version_if_supported(version: ProtocolVersion, chain: Chain) -> Option<Self> {
2665 if version.0 >= ProtocolVersion::MIN.0 && version.0 <= ProtocolVersion::MAX_ALLOWED.0 {
2666 let mut ret = Self::get_for_version_impl(version, chain);
2667 ret.version = version;
2668 Some(ret)
2669 } else {
2670 None
2671 }
2672 }
2673
2674 #[cfg(not(msim))]
2675 pub fn poison_get_for_min_version() {
2676 POISON_VERSION_METHODS.store(true, Ordering::Relaxed);
2677 }
2678
2679 #[cfg(not(msim))]
2680 fn load_poison_get_for_min_version() -> bool {
2681 POISON_VERSION_METHODS.load(Ordering::Relaxed)
2682 }
2683
2684 #[cfg(msim)]
2685 pub fn poison_get_for_min_version() {
2686 POISON_VERSION_METHODS.with(|p| p.store(true, Ordering::Relaxed));
2687 }
2688
2689 #[cfg(msim)]
2690 fn load_poison_get_for_min_version() -> bool {
2691 POISON_VERSION_METHODS.with(|p| p.load(Ordering::Relaxed))
2692 }
2693
2694 pub fn get_for_min_version() -> Self {
2697 if Self::load_poison_get_for_min_version() {
2698 panic!("get_for_min_version called on validator");
2699 }
2700 ProtocolConfig::get_for_version(ProtocolVersion::MIN, Chain::Unknown)
2701 }
2702
2703 #[allow(non_snake_case)]
2713 pub fn get_for_max_version_UNSAFE() -> Self {
2714 if Self::load_poison_get_for_min_version() {
2715 panic!("get_for_max_version_UNSAFE called on validator");
2716 }
2717 ProtocolConfig::get_for_version(ProtocolVersion::MAX, Chain::Unknown)
2718 }
2719
2720 fn get_for_version_impl(version: ProtocolVersion, chain: Chain) -> Self {
2721 #[cfg(msim)]
2722 {
2723 if version == ProtocolVersion::MAX_ALLOWED {
2725 let mut config = Self::get_for_version_impl(version - 1, Chain::Unknown);
2726 config.base_tx_cost_fixed = Some(config.base_tx_cost_fixed() + 1000);
2727 return config;
2728 }
2729 }
2730
2731 let mut cfg = Self {
2734 version,
2736
2737 feature_flags: Default::default(),
2739
2740 max_tx_size_bytes: Some(128 * 1024),
2741 max_input_objects: Some(2048),
2743 max_serialized_tx_effects_size_bytes: Some(512 * 1024),
2744 max_serialized_tx_effects_size_bytes_system_tx: Some(512 * 1024 * 16),
2745 max_gas_payment_objects: Some(256),
2746 max_modules_in_publish: Some(128),
2747 max_package_dependencies: None,
2748 max_arguments: Some(512),
2749 max_type_arguments: Some(16),
2750 max_type_argument_depth: Some(16),
2751 max_pure_argument_size: Some(16 * 1024),
2752 max_programmable_tx_commands: Some(1024),
2753 move_binary_format_version: Some(6),
2754 min_move_binary_format_version: None,
2755 binary_module_handles: None,
2756 binary_struct_handles: None,
2757 binary_function_handles: None,
2758 binary_function_instantiations: None,
2759 binary_signatures: None,
2760 binary_constant_pool: None,
2761 binary_identifiers: None,
2762 binary_address_identifiers: None,
2763 binary_struct_defs: None,
2764 binary_struct_def_instantiations: None,
2765 binary_function_defs: None,
2766 binary_field_handles: None,
2767 binary_field_instantiations: None,
2768 binary_friend_decls: None,
2769 binary_enum_defs: None,
2770 binary_enum_def_instantiations: None,
2771 binary_variant_handles: None,
2772 binary_variant_instantiation_handles: None,
2773 max_move_object_size: Some(250 * 1024),
2774 max_move_package_size: Some(100 * 1024),
2775 max_publish_or_upgrade_per_ptb: None,
2776 max_tx_gas: Some(10_000_000_000),
2777 max_gas_price: Some(100_000),
2778 max_gas_price_rgp_factor_for_aborted_transactions: None,
2779 max_gas_computation_bucket: Some(5_000_000),
2780 max_loop_depth: Some(5),
2781 max_generic_instantiation_length: Some(32),
2782 max_function_parameters: Some(128),
2783 max_basic_blocks: Some(1024),
2784 max_value_stack_size: Some(1024),
2785 max_type_nodes: Some(256),
2786 max_push_size: Some(10000),
2787 max_struct_definitions: Some(200),
2788 max_function_definitions: Some(1000),
2789 max_fields_in_struct: Some(32),
2790 max_dependency_depth: Some(100),
2791 max_num_event_emit: Some(256),
2792 max_num_new_move_object_ids: Some(2048),
2793 max_num_new_move_object_ids_system_tx: Some(2048 * 16),
2794 max_num_deleted_move_object_ids: Some(2048),
2795 max_num_deleted_move_object_ids_system_tx: Some(2048 * 16),
2796 max_num_transferred_move_object_ids: Some(2048),
2797 max_num_transferred_move_object_ids_system_tx: Some(2048 * 16),
2798 max_event_emit_size: Some(250 * 1024),
2799 max_move_vector_len: Some(256 * 1024),
2800 max_type_to_layout_nodes: None,
2801 max_ptb_value_size: None,
2802
2803 max_back_edges_per_function: Some(10_000),
2804 max_back_edges_per_module: Some(10_000),
2805 max_verifier_meter_ticks_per_function: Some(6_000_000),
2806 max_meter_ticks_per_module: Some(6_000_000),
2807 max_meter_ticks_per_package: None,
2808
2809 object_runtime_max_num_cached_objects: Some(1000),
2810 object_runtime_max_num_cached_objects_system_tx: Some(1000 * 16),
2811 object_runtime_max_num_store_entries: Some(1000),
2812 object_runtime_max_num_store_entries_system_tx: Some(1000 * 16),
2813 base_tx_cost_fixed: Some(110_000),
2814 package_publish_cost_fixed: Some(1_000),
2815 base_tx_cost_per_byte: Some(0),
2816 package_publish_cost_per_byte: Some(80),
2817 obj_access_cost_read_per_byte: Some(15),
2818 obj_access_cost_mutate_per_byte: Some(40),
2819 obj_access_cost_delete_per_byte: Some(40),
2820 obj_access_cost_verify_per_byte: Some(200),
2821 obj_data_cost_refundable: Some(100),
2822 obj_metadata_cost_non_refundable: Some(50),
2823 gas_model_version: Some(1),
2824 storage_rebate_rate: Some(9900),
2825 storage_fund_reinvest_rate: Some(500),
2826 reward_slashing_rate: Some(5000),
2827 storage_gas_price: Some(1),
2828 accumulator_object_storage_cost: None,
2829 max_transactions_per_checkpoint: Some(10_000),
2830 max_checkpoint_size_bytes: Some(30 * 1024 * 1024),
2831
2832 buffer_stake_for_protocol_upgrade_bps: Some(0),
2835
2836 address_from_bytes_cost_base: Some(52),
2840 address_to_u256_cost_base: Some(52),
2842 address_from_u256_cost_base: Some(52),
2844
2845 config_read_setting_impl_cost_base: None,
2848 config_read_setting_impl_cost_per_byte: None,
2849
2850 dynamic_field_hash_type_and_key_cost_base: Some(100),
2853 dynamic_field_hash_type_and_key_type_cost_per_byte: Some(2),
2854 dynamic_field_hash_type_and_key_value_cost_per_byte: Some(2),
2855 dynamic_field_hash_type_and_key_type_tag_cost_per_byte: Some(2),
2856 dynamic_field_add_child_object_cost_base: Some(100),
2858 dynamic_field_add_child_object_type_cost_per_byte: Some(10),
2859 dynamic_field_add_child_object_value_cost_per_byte: Some(10),
2860 dynamic_field_add_child_object_struct_tag_cost_per_byte: Some(10),
2861 dynamic_field_borrow_child_object_cost_base: Some(100),
2863 dynamic_field_borrow_child_object_child_ref_cost_per_byte: Some(10),
2864 dynamic_field_borrow_child_object_type_cost_per_byte: Some(10),
2865 dynamic_field_remove_child_object_cost_base: Some(100),
2867 dynamic_field_remove_child_object_child_cost_per_byte: Some(2),
2868 dynamic_field_remove_child_object_type_cost_per_byte: Some(2),
2869 dynamic_field_has_child_object_cost_base: Some(100),
2871 dynamic_field_has_child_object_with_ty_cost_base: Some(100),
2873 dynamic_field_has_child_object_with_ty_type_cost_per_byte: Some(2),
2874 dynamic_field_has_child_object_with_ty_type_tag_cost_per_byte: Some(2),
2875
2876 event_emit_cost_base: Some(52),
2879 event_emit_value_size_derivation_cost_per_byte: Some(2),
2880 event_emit_tag_size_derivation_cost_per_byte: Some(5),
2881 event_emit_output_cost_per_byte: Some(10),
2882 event_emit_auth_stream_cost: None,
2883
2884 object_borrow_uid_cost_base: Some(52),
2887 object_delete_impl_cost_base: Some(52),
2889 object_record_new_uid_cost_base: Some(52),
2891
2892 transfer_transfer_internal_cost_base: Some(52),
2895 transfer_party_transfer_internal_cost_base: None,
2897 transfer_freeze_object_cost_base: Some(52),
2899 transfer_share_object_cost_base: Some(52),
2901 transfer_receive_object_cost_base: None,
2902
2903 tx_context_derive_id_cost_base: Some(52),
2906 tx_context_fresh_id_cost_base: None,
2907 tx_context_sender_cost_base: None,
2908 tx_context_epoch_cost_base: None,
2909 tx_context_epoch_timestamp_ms_cost_base: None,
2910 tx_context_sponsor_cost_base: None,
2911 tx_context_rgp_cost_base: None,
2912 tx_context_gas_price_cost_base: None,
2913 tx_context_gas_budget_cost_base: None,
2914 tx_context_ids_created_cost_base: None,
2915 tx_context_replace_cost_base: None,
2916
2917 types_is_one_time_witness_cost_base: Some(52),
2920 types_is_one_time_witness_type_tag_cost_per_byte: Some(2),
2921 types_is_one_time_witness_type_cost_per_byte: Some(2),
2922
2923 validator_validate_metadata_cost_base: Some(52),
2926 validator_validate_metadata_data_cost_per_byte: Some(2),
2927
2928 crypto_invalid_arguments_cost: Some(100),
2930 bls12381_bls12381_min_sig_verify_cost_base: Some(52),
2932 bls12381_bls12381_min_sig_verify_msg_cost_per_byte: Some(2),
2933 bls12381_bls12381_min_sig_verify_msg_cost_per_block: Some(2),
2934
2935 bls12381_bls12381_min_pk_verify_cost_base: Some(52),
2937 bls12381_bls12381_min_pk_verify_msg_cost_per_byte: Some(2),
2938 bls12381_bls12381_min_pk_verify_msg_cost_per_block: Some(2),
2939
2940 ecdsa_k1_ecrecover_keccak256_cost_base: Some(52),
2942 ecdsa_k1_ecrecover_keccak256_msg_cost_per_byte: Some(2),
2943 ecdsa_k1_ecrecover_keccak256_msg_cost_per_block: Some(2),
2944 ecdsa_k1_ecrecover_sha256_cost_base: Some(52),
2945 ecdsa_k1_ecrecover_sha256_msg_cost_per_byte: Some(2),
2946 ecdsa_k1_ecrecover_sha256_msg_cost_per_block: Some(2),
2947
2948 ecdsa_k1_decompress_pubkey_cost_base: Some(52),
2950
2951 ecdsa_k1_secp256k1_verify_keccak256_cost_base: Some(52),
2953 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_byte: Some(2),
2954 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_block: Some(2),
2955 ecdsa_k1_secp256k1_verify_sha256_cost_base: Some(52),
2956 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_byte: Some(2),
2957 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_block: Some(2),
2958
2959 ecdsa_r1_ecrecover_keccak256_cost_base: Some(52),
2961 ecdsa_r1_ecrecover_keccak256_msg_cost_per_byte: Some(2),
2962 ecdsa_r1_ecrecover_keccak256_msg_cost_per_block: Some(2),
2963 ecdsa_r1_ecrecover_sha256_cost_base: Some(52),
2964 ecdsa_r1_ecrecover_sha256_msg_cost_per_byte: Some(2),
2965 ecdsa_r1_ecrecover_sha256_msg_cost_per_block: Some(2),
2966
2967 ecdsa_r1_secp256r1_verify_keccak256_cost_base: Some(52),
2969 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_byte: Some(2),
2970 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_block: Some(2),
2971 ecdsa_r1_secp256r1_verify_sha256_cost_base: Some(52),
2972 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_byte: Some(2),
2973 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_block: Some(2),
2974
2975 ecvrf_ecvrf_verify_cost_base: Some(52),
2977 ecvrf_ecvrf_verify_alpha_string_cost_per_byte: Some(2),
2978 ecvrf_ecvrf_verify_alpha_string_cost_per_block: Some(2),
2979
2980 ed25519_ed25519_verify_cost_base: Some(52),
2982 ed25519_ed25519_verify_msg_cost_per_byte: Some(2),
2983 ed25519_ed25519_verify_msg_cost_per_block: Some(2),
2984
2985 groth16_prepare_verifying_key_bls12381_cost_base: Some(52),
2987 groth16_prepare_verifying_key_bn254_cost_base: Some(52),
2988
2989 groth16_verify_groth16_proof_internal_bls12381_cost_base: Some(52),
2991 groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input: Some(2),
2992 groth16_verify_groth16_proof_internal_bn254_cost_base: Some(52),
2993 groth16_verify_groth16_proof_internal_bn254_cost_per_public_input: Some(2),
2994 groth16_verify_groth16_proof_internal_public_input_cost_per_byte: Some(2),
2995
2996 hash_blake2b256_cost_base: Some(52),
2998 hash_blake2b256_data_cost_per_byte: Some(2),
2999 hash_blake2b256_data_cost_per_block: Some(2),
3000
3001 hash_keccak256_cost_base: Some(52),
3003 hash_keccak256_data_cost_per_byte: Some(2),
3004 hash_keccak256_data_cost_per_block: Some(2),
3005
3006 poseidon_bn254_cost_base: None,
3007 poseidon_bn254_cost_per_block: None,
3008
3009 hmac_hmac_sha3_256_cost_base: Some(52),
3011 hmac_hmac_sha3_256_input_cost_per_byte: Some(2),
3012 hmac_hmac_sha3_256_input_cost_per_block: Some(2),
3013
3014 group_ops_bls12381_decode_scalar_cost: None,
3016 group_ops_bls12381_decode_g1_cost: None,
3017 group_ops_bls12381_decode_g2_cost: None,
3018 group_ops_bls12381_decode_gt_cost: None,
3019 group_ops_bls12381_scalar_add_cost: None,
3020 group_ops_bls12381_g1_add_cost: None,
3021 group_ops_bls12381_g2_add_cost: None,
3022 group_ops_bls12381_gt_add_cost: None,
3023 group_ops_bls12381_scalar_sub_cost: None,
3024 group_ops_bls12381_g1_sub_cost: None,
3025 group_ops_bls12381_g2_sub_cost: None,
3026 group_ops_bls12381_gt_sub_cost: None,
3027 group_ops_bls12381_scalar_mul_cost: None,
3028 group_ops_bls12381_g1_mul_cost: None,
3029 group_ops_bls12381_g2_mul_cost: None,
3030 group_ops_bls12381_gt_mul_cost: None,
3031 group_ops_bls12381_scalar_div_cost: None,
3032 group_ops_bls12381_g1_div_cost: None,
3033 group_ops_bls12381_g2_div_cost: None,
3034 group_ops_bls12381_gt_div_cost: None,
3035 group_ops_bls12381_g1_hash_to_base_cost: None,
3036 group_ops_bls12381_g2_hash_to_base_cost: None,
3037 group_ops_bls12381_g1_hash_to_cost_per_byte: None,
3038 group_ops_bls12381_g2_hash_to_cost_per_byte: None,
3039 group_ops_bls12381_g1_msm_base_cost: None,
3040 group_ops_bls12381_g2_msm_base_cost: None,
3041 group_ops_bls12381_g1_msm_base_cost_per_input: None,
3042 group_ops_bls12381_g2_msm_base_cost_per_input: None,
3043 group_ops_bls12381_msm_max_len: None,
3044 group_ops_bls12381_pairing_cost: None,
3045 group_ops_bls12381_g1_to_uncompressed_g1_cost: None,
3046 group_ops_bls12381_uncompressed_g1_to_g1_cost: None,
3047 group_ops_bls12381_uncompressed_g1_sum_base_cost: None,
3048 group_ops_bls12381_uncompressed_g1_sum_cost_per_term: None,
3049 group_ops_bls12381_uncompressed_g1_sum_max_terms: None,
3050
3051 group_ops_ristretto_decode_scalar_cost: None,
3052 group_ops_ristretto_decode_point_cost: None,
3053 group_ops_ristretto_scalar_add_cost: None,
3054 group_ops_ristretto_point_add_cost: None,
3055 group_ops_ristretto_scalar_sub_cost: None,
3056 group_ops_ristretto_point_sub_cost: None,
3057 group_ops_ristretto_scalar_mul_cost: None,
3058 group_ops_ristretto_point_mul_cost: None,
3059 group_ops_ristretto_scalar_div_cost: None,
3060 group_ops_ristretto_point_div_cost: None,
3061
3062 check_zklogin_id_cost_base: None,
3064 check_zklogin_issuer_cost_base: None,
3066
3067 vdf_verify_vdf_cost: None,
3068 vdf_hash_to_input_cost: None,
3069
3070 nitro_attestation_parse_base_cost: None,
3072 nitro_attestation_parse_cost_per_byte: None,
3073 nitro_attestation_verify_base_cost: None,
3074 nitro_attestation_verify_cost_per_cert: None,
3075
3076 bcs_per_byte_serialized_cost: None,
3077 bcs_legacy_min_output_size_cost: None,
3078 bcs_failure_cost: None,
3079 hash_sha2_256_base_cost: None,
3080 hash_sha2_256_per_byte_cost: None,
3081 hash_sha2_256_legacy_min_input_len_cost: None,
3082 hash_sha3_256_base_cost: None,
3083 hash_sha3_256_per_byte_cost: None,
3084 hash_sha3_256_legacy_min_input_len_cost: None,
3085 type_name_get_base_cost: None,
3086 type_name_get_per_byte_cost: None,
3087 type_name_id_base_cost: None,
3088 string_check_utf8_base_cost: None,
3089 string_check_utf8_per_byte_cost: None,
3090 string_is_char_boundary_base_cost: None,
3091 string_sub_string_base_cost: None,
3092 string_sub_string_per_byte_cost: None,
3093 string_index_of_base_cost: None,
3094 string_index_of_per_byte_pattern_cost: None,
3095 string_index_of_per_byte_searched_cost: None,
3096 vector_empty_base_cost: None,
3097 vector_length_base_cost: None,
3098 vector_push_back_base_cost: None,
3099 vector_push_back_legacy_per_abstract_memory_unit_cost: None,
3100 vector_borrow_base_cost: None,
3101 vector_pop_back_base_cost: None,
3102 vector_destroy_empty_base_cost: None,
3103 vector_swap_base_cost: None,
3104 debug_print_base_cost: None,
3105 debug_print_stack_trace_base_cost: None,
3106
3107 max_size_written_objects: None,
3108 max_size_written_objects_system_tx: None,
3109
3110 max_move_identifier_len: None,
3117 max_move_value_depth: None,
3118 max_move_enum_variants: None,
3119
3120 gas_rounding_step: None,
3121
3122 execution_version: None,
3123
3124 max_event_emit_size_total: None,
3125
3126 consensus_bad_nodes_stake_threshold: None,
3127
3128 max_jwk_votes_per_validator_per_epoch: None,
3129
3130 max_age_of_jwk_in_epochs: None,
3131
3132 random_beacon_reduction_allowed_delta: None,
3133
3134 random_beacon_reduction_lower_bound: None,
3135
3136 random_beacon_dkg_timeout_round: None,
3137
3138 random_beacon_min_round_interval_ms: None,
3139
3140 random_beacon_dkg_version: None,
3141
3142 consensus_max_transaction_size_bytes: None,
3143
3144 consensus_max_transactions_in_block_bytes: None,
3145
3146 consensus_max_num_transactions_in_block: None,
3147
3148 consensus_voting_rounds: None,
3149
3150 max_accumulated_txn_cost_per_object_in_narwhal_commit: None,
3151
3152 max_deferral_rounds_for_congestion_control: None,
3153
3154 max_txn_cost_overage_per_object_in_commit: None,
3155
3156 allowed_txn_cost_overage_burst_per_object_in_commit: None,
3157
3158 min_checkpoint_interval_ms: None,
3159
3160 checkpoint_summary_version_specific_data: None,
3161
3162 max_soft_bundle_size: None,
3163
3164 bridge_should_try_to_finalize_committee: None,
3165
3166 max_accumulated_txn_cost_per_object_in_mysticeti_commit: None,
3167
3168 max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit: None,
3169
3170 consensus_gc_depth: None,
3171
3172 gas_budget_based_txn_cost_cap_factor: None,
3173
3174 gas_budget_based_txn_cost_absolute_cap_commit_count: None,
3175
3176 sip_45_consensus_amplification_threshold: None,
3177
3178 use_object_per_epoch_marker_table_v2: None,
3179
3180 consensus_commit_rate_estimation_window_size: None,
3181
3182 aliased_addresses: vec![],
3183
3184 translation_per_command_base_charge: None,
3185 translation_per_input_base_charge: None,
3186 translation_pure_input_per_byte_charge: None,
3187 translation_per_type_node_charge: None,
3188 translation_per_reference_node_charge: None,
3189 translation_per_linkage_entry_charge: None,
3190
3191 max_updates_per_settlement_txn: None,
3192 };
3195 for cur in 2..=version.0 {
3196 match cur {
3197 1 => unreachable!(),
3198 2 => {
3199 cfg.feature_flags.advance_epoch_start_time_in_safe_mode = true;
3200 }
3201 3 => {
3202 cfg.gas_model_version = Some(2);
3204 cfg.max_tx_gas = Some(50_000_000_000);
3206 cfg.base_tx_cost_fixed = Some(2_000);
3208 cfg.storage_gas_price = Some(76);
3210 cfg.feature_flags.loaded_child_objects_fixed = true;
3211 cfg.max_size_written_objects = Some(5 * 1000 * 1000);
3214 cfg.max_size_written_objects_system_tx = Some(50 * 1000 * 1000);
3217 cfg.feature_flags.package_upgrades = true;
3218 }
3219 4 => {
3224 cfg.reward_slashing_rate = Some(10000);
3226 cfg.gas_model_version = Some(3);
3228 }
3229 5 => {
3230 cfg.feature_flags.missing_type_is_compatibility_error = true;
3231 cfg.gas_model_version = Some(4);
3232 cfg.feature_flags.scoring_decision_with_validity_cutoff = true;
3233 }
3237 6 => {
3238 cfg.gas_model_version = Some(5);
3239 cfg.buffer_stake_for_protocol_upgrade_bps = Some(5000);
3240 cfg.feature_flags.consensus_order_end_of_epoch_last = true;
3241 }
3242 7 => {
3243 cfg.feature_flags.disallow_adding_abilities_on_upgrade = true;
3244 cfg.feature_flags
3245 .disable_invariant_violation_check_in_swap_loc = true;
3246 cfg.feature_flags.ban_entry_init = true;
3247 cfg.feature_flags.package_digest_hash_module = true;
3248 }
3249 8 => {
3250 cfg.feature_flags
3251 .disallow_change_struct_type_params_on_upgrade = true;
3252 }
3253 9 => {
3254 cfg.max_move_identifier_len = Some(128);
3256 cfg.feature_flags.no_extraneous_module_bytes = true;
3257 cfg.feature_flags
3258 .advance_to_highest_supported_protocol_version = true;
3259 }
3260 10 => {
3261 cfg.max_verifier_meter_ticks_per_function = Some(16_000_000);
3262 cfg.max_meter_ticks_per_module = Some(16_000_000);
3263 }
3264 11 => {
3265 cfg.max_move_value_depth = Some(128);
3266 }
3267 12 => {
3268 cfg.feature_flags.narwhal_versioned_metadata = true;
3269 if chain != Chain::Mainnet {
3270 cfg.feature_flags.commit_root_state_digest = true;
3271 }
3272
3273 if chain != Chain::Mainnet && chain != Chain::Testnet {
3274 cfg.feature_flags.zklogin_auth = true;
3275 }
3276 }
3277 13 => {}
3278 14 => {
3279 cfg.gas_rounding_step = Some(1_000);
3280 cfg.gas_model_version = Some(6);
3281 }
3282 15 => {
3283 cfg.feature_flags.consensus_transaction_ordering =
3284 ConsensusTransactionOrdering::ByGasPrice;
3285 }
3286 16 => {
3287 cfg.feature_flags.simplified_unwrap_then_delete = true;
3288 }
3289 17 => {
3290 cfg.feature_flags.upgraded_multisig_supported = true;
3291 }
3292 18 => {
3293 cfg.execution_version = Some(1);
3294 cfg.feature_flags.txn_base_cost_as_multiplier = true;
3303 cfg.base_tx_cost_fixed = Some(1_000);
3305 }
3306 19 => {
3307 cfg.max_num_event_emit = Some(1024);
3308 cfg.max_event_emit_size_total = Some(
3311 256 * 250 * 1024, );
3313 }
3314 20 => {
3315 cfg.feature_flags.commit_root_state_digest = true;
3316
3317 if chain != Chain::Mainnet {
3318 cfg.feature_flags.narwhal_new_leader_election_schedule = true;
3319 cfg.consensus_bad_nodes_stake_threshold = Some(20);
3320 }
3321 }
3322
3323 21 => {
3324 if chain != Chain::Mainnet {
3325 cfg.feature_flags.zklogin_supported_providers = BTreeSet::from([
3326 "Google".to_string(),
3327 "Facebook".to_string(),
3328 "Twitch".to_string(),
3329 ]);
3330 }
3331 }
3332 22 => {
3333 cfg.feature_flags.loaded_child_object_format = true;
3334 }
3335 23 => {
3336 cfg.feature_flags.loaded_child_object_format_type = true;
3337 cfg.feature_flags.narwhal_new_leader_election_schedule = true;
3338 cfg.consensus_bad_nodes_stake_threshold = Some(20);
3344 }
3345 24 => {
3346 cfg.feature_flags.simple_conservation_checks = true;
3347 cfg.max_publish_or_upgrade_per_ptb = Some(5);
3348
3349 cfg.feature_flags.end_of_epoch_transaction_supported = true;
3350
3351 if chain != Chain::Mainnet {
3352 cfg.feature_flags.enable_jwk_consensus_updates = true;
3353 cfg.max_jwk_votes_per_validator_per_epoch = Some(240);
3355 cfg.max_age_of_jwk_in_epochs = Some(1);
3356 }
3357 }
3358 25 => {
3359 cfg.feature_flags.zklogin_supported_providers = BTreeSet::from([
3361 "Google".to_string(),
3362 "Facebook".to_string(),
3363 "Twitch".to_string(),
3364 ]);
3365 cfg.feature_flags.zklogin_auth = true;
3366
3367 cfg.feature_flags.enable_jwk_consensus_updates = true;
3369 cfg.max_jwk_votes_per_validator_per_epoch = Some(240);
3370 cfg.max_age_of_jwk_in_epochs = Some(1);
3371 }
3372 26 => {
3373 cfg.gas_model_version = Some(7);
3374 if chain != Chain::Mainnet && chain != Chain::Testnet {
3376 cfg.transfer_receive_object_cost_base = Some(52);
3377 cfg.feature_flags.receive_objects = true;
3378 }
3379 }
3380 27 => {
3381 cfg.gas_model_version = Some(8);
3382 }
3383 28 => {
3384 cfg.check_zklogin_id_cost_base = Some(200);
3386 cfg.check_zklogin_issuer_cost_base = Some(200);
3388
3389 if chain != Chain::Mainnet && chain != Chain::Testnet {
3391 cfg.feature_flags.enable_effects_v2 = true;
3392 }
3393 }
3394 29 => {
3395 cfg.feature_flags.verify_legacy_zklogin_address = true;
3396 }
3397 30 => {
3398 if chain != Chain::Mainnet {
3400 cfg.feature_flags.narwhal_certificate_v2 = true;
3401 }
3402
3403 cfg.random_beacon_reduction_allowed_delta = Some(800);
3404 if chain != Chain::Mainnet {
3406 cfg.feature_flags.enable_effects_v2 = true;
3407 }
3408
3409 cfg.feature_flags.zklogin_supported_providers = BTreeSet::default();
3413
3414 cfg.feature_flags.recompute_has_public_transfer_in_execution = true;
3415 }
3416 31 => {
3417 cfg.execution_version = Some(2);
3418 if chain != Chain::Mainnet && chain != Chain::Testnet {
3420 cfg.feature_flags.shared_object_deletion = true;
3421 }
3422 }
3423 32 => {
3424 if chain != Chain::Mainnet {
3426 cfg.feature_flags.accept_zklogin_in_multisig = true;
3427 }
3428 if chain != Chain::Mainnet {
3430 cfg.transfer_receive_object_cost_base = Some(52);
3431 cfg.feature_flags.receive_objects = true;
3432 }
3433 if chain != Chain::Mainnet && chain != Chain::Testnet {
3435 cfg.feature_flags.random_beacon = true;
3436 cfg.random_beacon_reduction_lower_bound = Some(1600);
3437 cfg.random_beacon_dkg_timeout_round = Some(3000);
3438 cfg.random_beacon_min_round_interval_ms = Some(150);
3439 }
3440 if chain != Chain::Testnet && chain != Chain::Mainnet {
3442 cfg.feature_flags.include_consensus_digest_in_prologue = true;
3443 }
3444
3445 cfg.feature_flags.narwhal_certificate_v2 = true;
3447 }
3448 33 => {
3449 cfg.feature_flags.hardened_otw_check = true;
3450 cfg.feature_flags.allow_receiving_object_id = true;
3451
3452 cfg.transfer_receive_object_cost_base = Some(52);
3454 cfg.feature_flags.receive_objects = true;
3455
3456 if chain != Chain::Mainnet {
3458 cfg.feature_flags.shared_object_deletion = true;
3459 }
3460
3461 cfg.feature_flags.enable_effects_v2 = true;
3462 }
3463 34 => {}
3464 35 => {
3465 if chain != Chain::Mainnet && chain != Chain::Testnet {
3467 cfg.feature_flags.enable_poseidon = true;
3468 cfg.poseidon_bn254_cost_base = Some(260);
3469 cfg.poseidon_bn254_cost_per_block = Some(10);
3470 }
3471
3472 cfg.feature_flags.enable_coin_deny_list = true;
3473 }
3474 36 => {
3475 if chain != Chain::Mainnet && chain != Chain::Testnet {
3477 cfg.feature_flags.enable_group_ops_native_functions = true;
3478 cfg.feature_flags.enable_group_ops_native_function_msm = true;
3479 cfg.group_ops_bls12381_decode_scalar_cost = Some(52);
3481 cfg.group_ops_bls12381_decode_g1_cost = Some(52);
3482 cfg.group_ops_bls12381_decode_g2_cost = Some(52);
3483 cfg.group_ops_bls12381_decode_gt_cost = Some(52);
3484 cfg.group_ops_bls12381_scalar_add_cost = Some(52);
3485 cfg.group_ops_bls12381_g1_add_cost = Some(52);
3486 cfg.group_ops_bls12381_g2_add_cost = Some(52);
3487 cfg.group_ops_bls12381_gt_add_cost = Some(52);
3488 cfg.group_ops_bls12381_scalar_sub_cost = Some(52);
3489 cfg.group_ops_bls12381_g1_sub_cost = Some(52);
3490 cfg.group_ops_bls12381_g2_sub_cost = Some(52);
3491 cfg.group_ops_bls12381_gt_sub_cost = Some(52);
3492 cfg.group_ops_bls12381_scalar_mul_cost = Some(52);
3493 cfg.group_ops_bls12381_g1_mul_cost = Some(52);
3494 cfg.group_ops_bls12381_g2_mul_cost = Some(52);
3495 cfg.group_ops_bls12381_gt_mul_cost = Some(52);
3496 cfg.group_ops_bls12381_scalar_div_cost = Some(52);
3497 cfg.group_ops_bls12381_g1_div_cost = Some(52);
3498 cfg.group_ops_bls12381_g2_div_cost = Some(52);
3499 cfg.group_ops_bls12381_gt_div_cost = Some(52);
3500 cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(52);
3501 cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(52);
3502 cfg.group_ops_bls12381_g1_hash_to_cost_per_byte = Some(2);
3503 cfg.group_ops_bls12381_g2_hash_to_cost_per_byte = Some(2);
3504 cfg.group_ops_bls12381_g1_msm_base_cost = Some(52);
3505 cfg.group_ops_bls12381_g2_msm_base_cost = Some(52);
3506 cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(52);
3507 cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(52);
3508 cfg.group_ops_bls12381_msm_max_len = Some(32);
3509 cfg.group_ops_bls12381_pairing_cost = Some(52);
3510 }
3511 cfg.feature_flags.shared_object_deletion = true;
3513
3514 cfg.consensus_max_transaction_size_bytes = Some(256 * 1024); cfg.consensus_max_transactions_in_block_bytes = Some(6 * 1_024 * 1024);
3516 }
3518 37 => {
3519 cfg.feature_flags.reject_mutable_random_on_entry_functions = true;
3520
3521 if chain != Chain::Mainnet {
3523 cfg.feature_flags.include_consensus_digest_in_prologue = true;
3524 }
3525 }
3526 38 => {
3527 cfg.binary_module_handles = Some(100);
3528 cfg.binary_struct_handles = Some(300);
3529 cfg.binary_function_handles = Some(1500);
3530 cfg.binary_function_instantiations = Some(750);
3531 cfg.binary_signatures = Some(1000);
3532 cfg.binary_constant_pool = Some(4000);
3536 cfg.binary_identifiers = Some(10000);
3537 cfg.binary_address_identifiers = Some(100);
3538 cfg.binary_struct_defs = Some(200);
3539 cfg.binary_struct_def_instantiations = Some(100);
3540 cfg.binary_function_defs = Some(1000);
3541 cfg.binary_field_handles = Some(500);
3542 cfg.binary_field_instantiations = Some(250);
3543 cfg.binary_friend_decls = Some(100);
3544 cfg.max_package_dependencies = Some(32);
3546 cfg.max_modules_in_publish = Some(64);
3547 cfg.execution_version = Some(3);
3549 }
3550 39 => {
3551 }
3553 40 => {}
3554 41 => {
3555 cfg.feature_flags.enable_group_ops_native_functions = true;
3557 cfg.group_ops_bls12381_decode_scalar_cost = Some(52);
3559 cfg.group_ops_bls12381_decode_g1_cost = Some(52);
3560 cfg.group_ops_bls12381_decode_g2_cost = Some(52);
3561 cfg.group_ops_bls12381_decode_gt_cost = Some(52);
3562 cfg.group_ops_bls12381_scalar_add_cost = Some(52);
3563 cfg.group_ops_bls12381_g1_add_cost = Some(52);
3564 cfg.group_ops_bls12381_g2_add_cost = Some(52);
3565 cfg.group_ops_bls12381_gt_add_cost = Some(52);
3566 cfg.group_ops_bls12381_scalar_sub_cost = Some(52);
3567 cfg.group_ops_bls12381_g1_sub_cost = Some(52);
3568 cfg.group_ops_bls12381_g2_sub_cost = Some(52);
3569 cfg.group_ops_bls12381_gt_sub_cost = Some(52);
3570 cfg.group_ops_bls12381_scalar_mul_cost = Some(52);
3571 cfg.group_ops_bls12381_g1_mul_cost = Some(52);
3572 cfg.group_ops_bls12381_g2_mul_cost = Some(52);
3573 cfg.group_ops_bls12381_gt_mul_cost = Some(52);
3574 cfg.group_ops_bls12381_scalar_div_cost = Some(52);
3575 cfg.group_ops_bls12381_g1_div_cost = Some(52);
3576 cfg.group_ops_bls12381_g2_div_cost = Some(52);
3577 cfg.group_ops_bls12381_gt_div_cost = Some(52);
3578 cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(52);
3579 cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(52);
3580 cfg.group_ops_bls12381_g1_hash_to_cost_per_byte = Some(2);
3581 cfg.group_ops_bls12381_g2_hash_to_cost_per_byte = Some(2);
3582 cfg.group_ops_bls12381_g1_msm_base_cost = Some(52);
3583 cfg.group_ops_bls12381_g2_msm_base_cost = Some(52);
3584 cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(52);
3585 cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(52);
3586 cfg.group_ops_bls12381_msm_max_len = Some(32);
3587 cfg.group_ops_bls12381_pairing_cost = Some(52);
3588 }
3589 42 => {}
3590 43 => {
3591 cfg.feature_flags.zklogin_max_epoch_upper_bound_delta = Some(30);
3592 cfg.max_meter_ticks_per_package = Some(16_000_000);
3593 }
3594 44 => {
3595 cfg.feature_flags.include_consensus_digest_in_prologue = true;
3597 if chain != Chain::Mainnet {
3599 cfg.feature_flags.consensus_choice = ConsensusChoice::SwapEachEpoch;
3600 }
3601 }
3602 45 => {
3603 if chain != Chain::Testnet && chain != Chain::Mainnet {
3605 cfg.feature_flags.consensus_network = ConsensusNetwork::Tonic;
3606 }
3607
3608 if chain != Chain::Mainnet {
3609 cfg.feature_flags.mysticeti_leader_scoring_and_schedule = true;
3611 }
3612 cfg.min_move_binary_format_version = Some(6);
3613 cfg.feature_flags.accept_zklogin_in_multisig = true;
3614
3615 if chain != Chain::Mainnet && chain != Chain::Testnet {
3619 cfg.feature_flags.bridge = true;
3620 }
3621 }
3622 46 => {
3623 if chain != Chain::Mainnet {
3625 cfg.feature_flags.bridge = true;
3626 }
3627
3628 cfg.feature_flags.reshare_at_same_initial_version = true;
3630 }
3631 47 => {}
3632 48 => {
3633 cfg.feature_flags.consensus_network = ConsensusNetwork::Tonic;
3635
3636 cfg.feature_flags.resolve_abort_locations_to_package_id = true;
3638
3639 if chain != Chain::Mainnet {
3641 cfg.feature_flags.random_beacon = true;
3642 cfg.random_beacon_reduction_lower_bound = Some(1600);
3643 cfg.random_beacon_dkg_timeout_round = Some(3000);
3644 cfg.random_beacon_min_round_interval_ms = Some(200);
3645 }
3646
3647 cfg.feature_flags.mysticeti_use_committed_subdag_digest = true;
3649 }
3650 49 => {
3651 if chain != Chain::Testnet && chain != Chain::Mainnet {
3652 cfg.move_binary_format_version = Some(7);
3653 }
3654
3655 if chain != Chain::Mainnet && chain != Chain::Testnet {
3657 cfg.feature_flags.enable_vdf = true;
3658 cfg.vdf_verify_vdf_cost = Some(1500);
3661 cfg.vdf_hash_to_input_cost = Some(100);
3662 }
3663
3664 if chain != Chain::Testnet && chain != Chain::Mainnet {
3666 cfg.feature_flags
3667 .record_consensus_determined_version_assignments_in_prologue = true;
3668 }
3669
3670 if chain != Chain::Mainnet {
3672 cfg.feature_flags.consensus_choice = ConsensusChoice::Mysticeti;
3673 }
3674
3675 cfg.feature_flags.fresh_vm_on_framework_upgrade = true;
3677 }
3678 50 => {
3679 if chain != Chain::Mainnet {
3681 cfg.checkpoint_summary_version_specific_data = Some(1);
3682 cfg.min_checkpoint_interval_ms = Some(200);
3683 }
3684
3685 if chain != Chain::Testnet && chain != Chain::Mainnet {
3687 cfg.feature_flags
3688 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = true;
3689 }
3690
3691 cfg.feature_flags.mysticeti_num_leaders_per_round = Some(1);
3692
3693 cfg.max_deferral_rounds_for_congestion_control = Some(10);
3695 }
3696 51 => {
3697 cfg.random_beacon_dkg_version = Some(1);
3698
3699 if chain != Chain::Testnet && chain != Chain::Mainnet {
3700 cfg.feature_flags.enable_coin_deny_list_v2 = true;
3701 }
3702 }
3703 52 => {
3704 if chain != Chain::Mainnet {
3705 cfg.feature_flags.soft_bundle = true;
3706 cfg.max_soft_bundle_size = Some(5);
3707 }
3708
3709 cfg.config_read_setting_impl_cost_base = Some(100);
3710 cfg.config_read_setting_impl_cost_per_byte = Some(40);
3711
3712 if chain != Chain::Testnet && chain != Chain::Mainnet {
3714 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(100);
3715 cfg.feature_flags.per_object_congestion_control_mode =
3716 PerObjectCongestionControlMode::TotalTxCount;
3717 }
3718
3719 cfg.feature_flags.consensus_choice = ConsensusChoice::Mysticeti;
3721
3722 cfg.feature_flags.mysticeti_leader_scoring_and_schedule = true;
3724
3725 cfg.checkpoint_summary_version_specific_data = Some(1);
3727 cfg.min_checkpoint_interval_ms = Some(200);
3728
3729 if chain != Chain::Mainnet {
3731 cfg.feature_flags
3732 .record_consensus_determined_version_assignments_in_prologue = true;
3733 cfg.feature_flags
3734 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = true;
3735 }
3736 if chain != Chain::Mainnet {
3738 cfg.move_binary_format_version = Some(7);
3739 }
3740
3741 if chain != Chain::Testnet && chain != Chain::Mainnet {
3742 cfg.feature_flags.passkey_auth = true;
3743 }
3744 cfg.feature_flags.enable_coin_deny_list_v2 = true;
3745 }
3746 53 => {
3747 cfg.bridge_should_try_to_finalize_committee = Some(chain != Chain::Mainnet);
3749
3750 cfg.feature_flags
3752 .record_consensus_determined_version_assignments_in_prologue = true;
3753 cfg.feature_flags
3754 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = true;
3755
3756 if chain == Chain::Unknown {
3757 cfg.feature_flags.authority_capabilities_v2 = true;
3758 }
3759
3760 if chain != Chain::Mainnet {
3762 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(100);
3763 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(10);
3764 cfg.feature_flags.per_object_congestion_control_mode =
3765 PerObjectCongestionControlMode::TotalTxCount;
3766 }
3767
3768 cfg.bcs_per_byte_serialized_cost = Some(2);
3770 cfg.bcs_legacy_min_output_size_cost = Some(1);
3771 cfg.bcs_failure_cost = Some(52);
3772 cfg.debug_print_base_cost = Some(52);
3773 cfg.debug_print_stack_trace_base_cost = Some(52);
3774 cfg.hash_sha2_256_base_cost = Some(52);
3775 cfg.hash_sha2_256_per_byte_cost = Some(2);
3776 cfg.hash_sha2_256_legacy_min_input_len_cost = Some(1);
3777 cfg.hash_sha3_256_base_cost = Some(52);
3778 cfg.hash_sha3_256_per_byte_cost = Some(2);
3779 cfg.hash_sha3_256_legacy_min_input_len_cost = Some(1);
3780 cfg.type_name_get_base_cost = Some(52);
3781 cfg.type_name_get_per_byte_cost = Some(2);
3782 cfg.string_check_utf8_base_cost = Some(52);
3783 cfg.string_check_utf8_per_byte_cost = Some(2);
3784 cfg.string_is_char_boundary_base_cost = Some(52);
3785 cfg.string_sub_string_base_cost = Some(52);
3786 cfg.string_sub_string_per_byte_cost = Some(2);
3787 cfg.string_index_of_base_cost = Some(52);
3788 cfg.string_index_of_per_byte_pattern_cost = Some(2);
3789 cfg.string_index_of_per_byte_searched_cost = Some(2);
3790 cfg.vector_empty_base_cost = Some(52);
3791 cfg.vector_length_base_cost = Some(52);
3792 cfg.vector_push_back_base_cost = Some(52);
3793 cfg.vector_push_back_legacy_per_abstract_memory_unit_cost = Some(2);
3794 cfg.vector_borrow_base_cost = Some(52);
3795 cfg.vector_pop_back_base_cost = Some(52);
3796 cfg.vector_destroy_empty_base_cost = Some(52);
3797 cfg.vector_swap_base_cost = Some(52);
3798 }
3799 54 => {
3800 cfg.feature_flags.random_beacon = true;
3802 cfg.random_beacon_reduction_lower_bound = Some(1000);
3803 cfg.random_beacon_dkg_timeout_round = Some(3000);
3804 cfg.random_beacon_min_round_interval_ms = Some(500);
3805
3806 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(100);
3808 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(10);
3809 cfg.feature_flags.per_object_congestion_control_mode =
3810 PerObjectCongestionControlMode::TotalTxCount;
3811
3812 cfg.feature_flags.soft_bundle = true;
3814 cfg.max_soft_bundle_size = Some(5);
3815 }
3816 55 => {
3817 cfg.move_binary_format_version = Some(7);
3819
3820 cfg.consensus_max_transactions_in_block_bytes = Some(512 * 1024);
3822 cfg.consensus_max_num_transactions_in_block = Some(512);
3825
3826 cfg.feature_flags.rethrow_serialization_type_layout_errors = true;
3827 }
3828 56 => {
3829 if chain == Chain::Mainnet {
3830 cfg.feature_flags.bridge = true;
3831 }
3832 }
3833 57 => {
3834 cfg.random_beacon_reduction_lower_bound = Some(800);
3836 }
3837 58 => {
3838 if chain == Chain::Mainnet {
3839 cfg.bridge_should_try_to_finalize_committee = Some(true);
3840 }
3841
3842 if chain != Chain::Mainnet && chain != Chain::Testnet {
3843 cfg.feature_flags
3845 .consensus_distributed_vote_scoring_strategy = true;
3846 }
3847 }
3848 59 => {
3849 cfg.feature_flags.consensus_round_prober = true;
3851 }
3852 60 => {
3853 cfg.max_type_to_layout_nodes = Some(512);
3854 cfg.feature_flags.validate_identifier_inputs = true;
3855 }
3856 61 => {
3857 if chain != Chain::Mainnet {
3858 cfg.feature_flags
3860 .consensus_distributed_vote_scoring_strategy = true;
3861 }
3862 cfg.random_beacon_reduction_lower_bound = Some(700);
3864
3865 if chain != Chain::Mainnet && chain != Chain::Testnet {
3866 cfg.feature_flags.mysticeti_fastpath = true;
3868 }
3869 }
3870 62 => {
3871 cfg.feature_flags.relocate_event_module = true;
3872 }
3873 63 => {
3874 cfg.feature_flags.per_object_congestion_control_mode =
3875 PerObjectCongestionControlMode::TotalGasBudgetWithCap;
3876 cfg.gas_budget_based_txn_cost_cap_factor = Some(400_000);
3877 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(18_500_000);
3878 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(240_000_000);
3879 }
3880 64 => {
3881 cfg.feature_flags.per_object_congestion_control_mode =
3882 PerObjectCongestionControlMode::TotalTxCount;
3883 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(40);
3884 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(3);
3885 }
3886 65 => {
3887 cfg.feature_flags
3889 .consensus_distributed_vote_scoring_strategy = true;
3890 }
3891 66 => {
3892 if chain == Chain::Mainnet {
3893 cfg.feature_flags
3895 .consensus_distributed_vote_scoring_strategy = false;
3896 }
3897 }
3898 67 => {
3899 cfg.feature_flags
3901 .consensus_distributed_vote_scoring_strategy = true;
3902 }
3903 68 => {
3904 cfg.group_ops_bls12381_g1_to_uncompressed_g1_cost = Some(26);
3905 cfg.group_ops_bls12381_uncompressed_g1_to_g1_cost = Some(52);
3906 cfg.group_ops_bls12381_uncompressed_g1_sum_base_cost = Some(26);
3907 cfg.group_ops_bls12381_uncompressed_g1_sum_cost_per_term = Some(13);
3908 cfg.group_ops_bls12381_uncompressed_g1_sum_max_terms = Some(2000);
3909
3910 if chain != Chain::Mainnet && chain != Chain::Testnet {
3911 cfg.feature_flags.uncompressed_g1_group_elements = true;
3912 }
3913
3914 cfg.feature_flags.per_object_congestion_control_mode =
3915 PerObjectCongestionControlMode::TotalGasBudgetWithCap;
3916 cfg.gas_budget_based_txn_cost_cap_factor = Some(400_000);
3917 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(18_500_000);
3918 cfg.max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit =
3919 Some(3_700_000); cfg.max_txn_cost_overage_per_object_in_commit = Some(u64::MAX);
3921 cfg.gas_budget_based_txn_cost_absolute_cap_commit_count = Some(50);
3922
3923 cfg.random_beacon_reduction_lower_bound = Some(500);
3925
3926 cfg.feature_flags.disallow_new_modules_in_deps_only_packages = true;
3927 }
3928 69 => {
3929 cfg.consensus_voting_rounds = Some(40);
3931
3932 if chain != Chain::Mainnet && chain != Chain::Testnet {
3933 cfg.feature_flags.consensus_smart_ancestor_selection = true;
3935 }
3936
3937 if chain != Chain::Mainnet {
3938 cfg.feature_flags.uncompressed_g1_group_elements = true;
3939 }
3940 }
3941 70 => {
3942 if chain != Chain::Mainnet {
3943 cfg.feature_flags.consensus_smart_ancestor_selection = true;
3945 cfg.feature_flags
3947 .consensus_round_prober_probe_accepted_rounds = true;
3948 }
3949
3950 cfg.poseidon_bn254_cost_per_block = Some(388);
3951
3952 cfg.gas_model_version = Some(9);
3953 cfg.feature_flags.native_charging_v2 = true;
3954 cfg.bls12381_bls12381_min_sig_verify_cost_base = Some(44064);
3955 cfg.bls12381_bls12381_min_pk_verify_cost_base = Some(49282);
3956 cfg.ecdsa_k1_secp256k1_verify_keccak256_cost_base = Some(1470);
3957 cfg.ecdsa_k1_secp256k1_verify_sha256_cost_base = Some(1470);
3958 cfg.ecdsa_r1_secp256r1_verify_sha256_cost_base = Some(4225);
3959 cfg.ecdsa_r1_secp256r1_verify_keccak256_cost_base = Some(4225);
3960 cfg.ecvrf_ecvrf_verify_cost_base = Some(4848);
3961 cfg.ed25519_ed25519_verify_cost_base = Some(1802);
3962
3963 cfg.ecdsa_r1_ecrecover_keccak256_cost_base = Some(1173);
3965 cfg.ecdsa_r1_ecrecover_sha256_cost_base = Some(1173);
3966 cfg.ecdsa_k1_ecrecover_keccak256_cost_base = Some(500);
3967 cfg.ecdsa_k1_ecrecover_sha256_cost_base = Some(500);
3968
3969 cfg.groth16_prepare_verifying_key_bls12381_cost_base = Some(53838);
3970 cfg.groth16_prepare_verifying_key_bn254_cost_base = Some(82010);
3971 cfg.groth16_verify_groth16_proof_internal_bls12381_cost_base = Some(72090);
3972 cfg.groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input =
3973 Some(8213);
3974 cfg.groth16_verify_groth16_proof_internal_bn254_cost_base = Some(115502);
3975 cfg.groth16_verify_groth16_proof_internal_bn254_cost_per_public_input =
3976 Some(9484);
3977
3978 cfg.hash_keccak256_cost_base = Some(10);
3979 cfg.hash_blake2b256_cost_base = Some(10);
3980
3981 cfg.group_ops_bls12381_decode_scalar_cost = Some(7);
3983 cfg.group_ops_bls12381_decode_g1_cost = Some(2848);
3984 cfg.group_ops_bls12381_decode_g2_cost = Some(3770);
3985 cfg.group_ops_bls12381_decode_gt_cost = Some(3068);
3986
3987 cfg.group_ops_bls12381_scalar_add_cost = Some(10);
3988 cfg.group_ops_bls12381_g1_add_cost = Some(1556);
3989 cfg.group_ops_bls12381_g2_add_cost = Some(3048);
3990 cfg.group_ops_bls12381_gt_add_cost = Some(188);
3991
3992 cfg.group_ops_bls12381_scalar_sub_cost = Some(10);
3993 cfg.group_ops_bls12381_g1_sub_cost = Some(1550);
3994 cfg.group_ops_bls12381_g2_sub_cost = Some(3019);
3995 cfg.group_ops_bls12381_gt_sub_cost = Some(497);
3996
3997 cfg.group_ops_bls12381_scalar_mul_cost = Some(11);
3998 cfg.group_ops_bls12381_g1_mul_cost = Some(4842);
3999 cfg.group_ops_bls12381_g2_mul_cost = Some(9108);
4000 cfg.group_ops_bls12381_gt_mul_cost = Some(27490);
4001
4002 cfg.group_ops_bls12381_scalar_div_cost = Some(91);
4003 cfg.group_ops_bls12381_g1_div_cost = Some(5091);
4004 cfg.group_ops_bls12381_g2_div_cost = Some(9206);
4005 cfg.group_ops_bls12381_gt_div_cost = Some(27804);
4006
4007 cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(2962);
4008 cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(8688);
4009
4010 cfg.group_ops_bls12381_g1_msm_base_cost = Some(62648);
4011 cfg.group_ops_bls12381_g2_msm_base_cost = Some(131192);
4012 cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(1333);
4013 cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(3216);
4014
4015 cfg.group_ops_bls12381_uncompressed_g1_to_g1_cost = Some(677);
4016 cfg.group_ops_bls12381_g1_to_uncompressed_g1_cost = Some(2099);
4017 cfg.group_ops_bls12381_uncompressed_g1_sum_base_cost = Some(77);
4018 cfg.group_ops_bls12381_uncompressed_g1_sum_cost_per_term = Some(26);
4019
4020 cfg.group_ops_bls12381_pairing_cost = Some(26897);
4021 cfg.group_ops_bls12381_uncompressed_g1_sum_max_terms = Some(1200);
4022
4023 cfg.validator_validate_metadata_cost_base = Some(20000);
4024 }
4025 71 => {
4026 cfg.sip_45_consensus_amplification_threshold = Some(5);
4027
4028 cfg.allowed_txn_cost_overage_burst_per_object_in_commit = Some(185_000_000);
4030 }
4031 72 => {
4032 cfg.feature_flags.convert_type_argument_error = true;
4033
4034 cfg.max_tx_gas = Some(50_000_000_000_000);
4037 cfg.max_gas_price = Some(50_000_000_000);
4039
4040 cfg.feature_flags.variant_nodes = true;
4041 }
4042 73 => {
4043 cfg.use_object_per_epoch_marker_table_v2 = Some(true);
4045
4046 if chain != Chain::Mainnet && chain != Chain::Testnet {
4047 cfg.consensus_gc_depth = Some(60);
4050 }
4051
4052 if chain != Chain::Mainnet {
4053 cfg.feature_flags.consensus_zstd_compression = true;
4055 }
4056
4057 cfg.feature_flags.consensus_smart_ancestor_selection = true;
4059 cfg.feature_flags
4061 .consensus_round_prober_probe_accepted_rounds = true;
4062
4063 cfg.feature_flags.per_object_congestion_control_mode =
4065 PerObjectCongestionControlMode::TotalGasBudgetWithCap;
4066 cfg.gas_budget_based_txn_cost_cap_factor = Some(400_000);
4067 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(37_000_000);
4068 cfg.max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit =
4069 Some(7_400_000); cfg.max_txn_cost_overage_per_object_in_commit = Some(u64::MAX);
4071 cfg.gas_budget_based_txn_cost_absolute_cap_commit_count = Some(50);
4072 cfg.allowed_txn_cost_overage_burst_per_object_in_commit = Some(370_000_000);
4073 }
4074 74 => {
4075 if chain != Chain::Mainnet && chain != Chain::Testnet {
4077 cfg.feature_flags.enable_nitro_attestation = true;
4078 }
4079 cfg.nitro_attestation_parse_base_cost = Some(53 * 50);
4080 cfg.nitro_attestation_parse_cost_per_byte = Some(50);
4081 cfg.nitro_attestation_verify_base_cost = Some(49632 * 50);
4082 cfg.nitro_attestation_verify_cost_per_cert = Some(52369 * 50);
4083
4084 cfg.feature_flags.consensus_zstd_compression = true;
4086
4087 if chain != Chain::Mainnet && chain != Chain::Testnet {
4088 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
4089 }
4090 }
4091 75 => {
4092 if chain != Chain::Mainnet {
4093 cfg.feature_flags.passkey_auth = true;
4094 }
4095 }
4096 76 => {
4097 if chain != Chain::Mainnet && chain != Chain::Testnet {
4098 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
4099 cfg.consensus_commit_rate_estimation_window_size = Some(10);
4100 }
4101 cfg.feature_flags.minimize_child_object_mutations = true;
4102
4103 if chain != Chain::Mainnet {
4104 cfg.feature_flags.accept_passkey_in_multisig = true;
4105 }
4106 }
4107 77 => {
4108 cfg.feature_flags.uncompressed_g1_group_elements = true;
4109
4110 if chain != Chain::Mainnet {
4111 cfg.consensus_gc_depth = Some(60);
4112 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
4113 }
4114 }
4115 78 => {
4116 cfg.feature_flags.move_native_context = true;
4117 cfg.tx_context_fresh_id_cost_base = Some(52);
4118 cfg.tx_context_sender_cost_base = Some(30);
4119 cfg.tx_context_epoch_cost_base = Some(30);
4120 cfg.tx_context_epoch_timestamp_ms_cost_base = Some(30);
4121 cfg.tx_context_sponsor_cost_base = Some(30);
4122 cfg.tx_context_gas_price_cost_base = Some(30);
4123 cfg.tx_context_gas_budget_cost_base = Some(30);
4124 cfg.tx_context_ids_created_cost_base = Some(30);
4125 cfg.tx_context_replace_cost_base = Some(30);
4126 cfg.gas_model_version = Some(10);
4127
4128 if chain != Chain::Mainnet {
4129 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
4130 cfg.consensus_commit_rate_estimation_window_size = Some(10);
4131
4132 cfg.feature_flags.per_object_congestion_control_mode =
4134 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4135 ExecutionTimeEstimateParams {
4136 target_utilization: 30,
4137 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4139 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4141 stored_observations_limit: u64::MAX,
4142 stake_weighted_median_threshold: 0,
4143 default_none_duration_for_new_keys: false,
4144 observations_chunk_size: None,
4145 },
4146 );
4147 }
4148 }
4149 79 => {
4150 if chain != Chain::Mainnet {
4151 cfg.feature_flags.consensus_median_based_commit_timestamp = true;
4152
4153 cfg.consensus_bad_nodes_stake_threshold = Some(30);
4156
4157 cfg.feature_flags.consensus_batched_block_sync = true;
4158
4159 cfg.feature_flags.enable_nitro_attestation = true
4161 }
4162 cfg.feature_flags.normalize_ptb_arguments = true;
4163
4164 cfg.consensus_gc_depth = Some(60);
4165 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
4166 }
4167 80 => {
4168 cfg.max_ptb_value_size = Some(1024 * 1024);
4169 }
4170 81 => {
4171 cfg.feature_flags.consensus_median_based_commit_timestamp = true;
4172 cfg.feature_flags.enforce_checkpoint_timestamp_monotonicity = true;
4173 cfg.consensus_bad_nodes_stake_threshold = Some(30)
4174 }
4175 82 => {
4176 cfg.feature_flags.max_ptb_value_size_v2 = true;
4177 }
4178 83 => {
4179 if chain == Chain::Mainnet {
4180 let aliased: [u8; 32] = Hex::decode(
4182 "0x0b2da327ba6a4cacbe75dddd50e6e8bbf81d6496e92d66af9154c61c77f7332f",
4183 )
4184 .unwrap()
4185 .try_into()
4186 .unwrap();
4187
4188 cfg.aliased_addresses.push(AliasedAddress {
4190 original: Hex::decode("0xcd8962dad278d8b50fa0f9eb0186bfa4cbdecc6d59377214c88d0286a0ac9562").unwrap().try_into().unwrap(),
4191 aliased,
4192 allowed_tx_digests: vec![
4193 Base58::decode("B2eGLFoMHgj93Ni8dAJBfqGzo8EWSTLBesZzhEpTPA4").unwrap().try_into().unwrap(),
4194 ],
4195 });
4196
4197 cfg.aliased_addresses.push(AliasedAddress {
4198 original: Hex::decode("0xe28b50cef1d633ea43d3296a3f6b67ff0312a5f1a99f0af753c85b8b5de8ff06").unwrap().try_into().unwrap(),
4199 aliased,
4200 allowed_tx_digests: vec![
4201 Base58::decode("J4QqSAgp7VrQtQpMy5wDX4QGsCSEZu3U5KuDAkbESAge").unwrap().try_into().unwrap(),
4202 ],
4203 });
4204 }
4205
4206 if chain != Chain::Mainnet {
4209 cfg.feature_flags.resolve_type_input_ids_to_defining_id = true;
4210 cfg.transfer_party_transfer_internal_cost_base = Some(52);
4211
4212 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
4214 cfg.consensus_commit_rate_estimation_window_size = Some(10);
4215 cfg.feature_flags.per_object_congestion_control_mode =
4216 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4217 ExecutionTimeEstimateParams {
4218 target_utilization: 30,
4219 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4221 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4223 stored_observations_limit: u64::MAX,
4224 stake_weighted_median_threshold: 0,
4225 default_none_duration_for_new_keys: false,
4226 observations_chunk_size: None,
4227 },
4228 );
4229
4230 cfg.feature_flags.consensus_batched_block_sync = true;
4232
4233 cfg.feature_flags.enable_nitro_attestation_upgraded_parsing = true;
4236 cfg.feature_flags.enable_nitro_attestation = true;
4237 }
4238 }
4239 84 => {
4240 if chain == Chain::Mainnet {
4241 cfg.feature_flags.resolve_type_input_ids_to_defining_id = true;
4242 cfg.transfer_party_transfer_internal_cost_base = Some(52);
4243
4244 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
4246 cfg.consensus_commit_rate_estimation_window_size = Some(10);
4247 cfg.feature_flags.per_object_congestion_control_mode =
4248 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4249 ExecutionTimeEstimateParams {
4250 target_utilization: 30,
4251 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4253 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4255 stored_observations_limit: u64::MAX,
4256 stake_weighted_median_threshold: 0,
4257 default_none_duration_for_new_keys: false,
4258 observations_chunk_size: None,
4259 },
4260 );
4261
4262 cfg.feature_flags.consensus_batched_block_sync = true;
4264
4265 cfg.feature_flags.enable_nitro_attestation_upgraded_parsing = true;
4268 cfg.feature_flags.enable_nitro_attestation = true;
4269 }
4270
4271 cfg.feature_flags.per_object_congestion_control_mode =
4273 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4274 ExecutionTimeEstimateParams {
4275 target_utilization: 30,
4276 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4278 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4280 stored_observations_limit: 20,
4281 stake_weighted_median_threshold: 0,
4282 default_none_duration_for_new_keys: false,
4283 observations_chunk_size: None,
4284 },
4285 );
4286 cfg.feature_flags.allow_unbounded_system_objects = true;
4287 }
4288 85 => {
4289 if chain != Chain::Mainnet && chain != Chain::Testnet {
4290 cfg.feature_flags.enable_party_transfer = true;
4291 }
4292
4293 cfg.feature_flags
4294 .record_consensus_determined_version_assignments_in_prologue_v2 = true;
4295 cfg.feature_flags.disallow_self_identifier = true;
4296 cfg.feature_flags.per_object_congestion_control_mode =
4297 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4298 ExecutionTimeEstimateParams {
4299 target_utilization: 50,
4300 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4302 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4304 stored_observations_limit: 20,
4305 stake_weighted_median_threshold: 0,
4306 default_none_duration_for_new_keys: false,
4307 observations_chunk_size: None,
4308 },
4309 );
4310 }
4311 86 => {
4312 cfg.feature_flags.type_tags_in_object_runtime = true;
4313 cfg.max_move_enum_variants = Some(move_core_types::VARIANT_COUNT_MAX);
4314
4315 cfg.feature_flags.per_object_congestion_control_mode =
4317 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4318 ExecutionTimeEstimateParams {
4319 target_utilization: 50,
4320 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4322 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4324 stored_observations_limit: 20,
4325 stake_weighted_median_threshold: 3334,
4326 default_none_duration_for_new_keys: false,
4327 observations_chunk_size: None,
4328 },
4329 );
4330 if chain != Chain::Mainnet {
4332 cfg.feature_flags.enable_party_transfer = true;
4333 }
4334 }
4335 87 => {
4336 if chain == Chain::Mainnet {
4337 cfg.feature_flags.record_time_estimate_processed = true;
4338 }
4339 cfg.feature_flags.better_adapter_type_resolution_errors = true;
4340 }
4341 88 => {
4342 cfg.feature_flags.record_time_estimate_processed = true;
4343 cfg.tx_context_rgp_cost_base = Some(30);
4344 cfg.feature_flags
4345 .ignore_execution_time_observations_after_certs_closed = true;
4346
4347 cfg.feature_flags.per_object_congestion_control_mode =
4350 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4351 ExecutionTimeEstimateParams {
4352 target_utilization: 50,
4353 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4355 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4357 stored_observations_limit: 20,
4358 stake_weighted_median_threshold: 3334,
4359 default_none_duration_for_new_keys: true,
4360 observations_chunk_size: None,
4361 },
4362 );
4363 }
4364 89 => {
4365 cfg.feature_flags.dependency_linkage_error = true;
4366 cfg.feature_flags.additional_multisig_checks = true;
4367 }
4368 90 => {
4369 cfg.max_gas_price_rgp_factor_for_aborted_transactions = Some(100);
4371 cfg.feature_flags.debug_fatal_on_move_invariant_violation = true;
4372 cfg.feature_flags.additional_consensus_digest_indirect_state = true;
4373 cfg.feature_flags.accept_passkey_in_multisig = true;
4374 cfg.feature_flags.passkey_auth = true;
4375 cfg.feature_flags.check_for_init_during_upgrade = true;
4376
4377 if chain != Chain::Mainnet {
4379 cfg.feature_flags.mysticeti_fastpath = true;
4380 }
4381 }
4382 91 => {
4383 cfg.feature_flags.per_command_shared_object_transfer_rules = true;
4384 }
4385 92 => {
4386 cfg.feature_flags.per_command_shared_object_transfer_rules = false;
4387 }
4388 93 => {
4389 cfg.feature_flags
4390 .consensus_checkpoint_signature_key_includes_digest = true;
4391 }
4392 94 => {
4393 cfg.feature_flags.per_object_congestion_control_mode =
4395 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4396 ExecutionTimeEstimateParams {
4397 target_utilization: 50,
4398 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4400 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4402 stored_observations_limit: 18,
4403 stake_weighted_median_threshold: 3334,
4404 default_none_duration_for_new_keys: true,
4405 observations_chunk_size: None,
4406 },
4407 );
4408
4409 cfg.feature_flags.enable_party_transfer = true;
4411 }
4412 95 => {
4413 cfg.type_name_id_base_cost = Some(52);
4414
4415 cfg.max_transactions_per_checkpoint = Some(20_000);
4417 }
4418 96 => {
4419 if chain != Chain::Mainnet && chain != Chain::Testnet {
4421 cfg.feature_flags
4422 .include_checkpoint_artifacts_digest_in_summary = true;
4423 }
4424 cfg.feature_flags.correct_gas_payment_limit_check = true;
4425 cfg.feature_flags.authority_capabilities_v2 = true;
4426 cfg.feature_flags.use_mfp_txns_in_load_initial_object_debts = true;
4427 cfg.feature_flags.cancel_for_failed_dkg_early = true;
4428 cfg.feature_flags.enable_coin_registry = true;
4429
4430 cfg.feature_flags.mysticeti_fastpath = true;
4432 }
4433 97 => {
4434 cfg.feature_flags.additional_borrow_checks = true;
4435 }
4436 98 => {
4437 cfg.event_emit_auth_stream_cost = Some(52);
4438 cfg.feature_flags.better_loader_errors = true;
4439 cfg.feature_flags.generate_df_type_layouts = true;
4440 }
4441 99 => {
4442 cfg.feature_flags.use_new_commit_handler = true;
4443 }
4444 100 => {
4445 cfg.feature_flags.private_generics_verifier_v2 = true;
4446 }
4447 101 => {
4448 cfg.feature_flags.create_root_accumulator_object = true;
4449 cfg.max_updates_per_settlement_txn = Some(100);
4450 if chain != Chain::Mainnet {
4451 cfg.feature_flags.enable_poseidon = true;
4452 }
4453 }
4454 102 => {
4455 cfg.feature_flags.per_object_congestion_control_mode =
4459 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4460 ExecutionTimeEstimateParams {
4461 target_utilization: 50,
4462 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4464 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4466 stored_observations_limit: 180,
4467 stake_weighted_median_threshold: 3334,
4468 default_none_duration_for_new_keys: true,
4469 observations_chunk_size: Some(18),
4470 },
4471 );
4472 cfg.feature_flags.deprecate_global_storage_ops = true;
4473 }
4474 103 => {}
4475 104 => {
4476 cfg.translation_per_command_base_charge = Some(1);
4477 cfg.translation_per_input_base_charge = Some(1);
4478 cfg.translation_pure_input_per_byte_charge = Some(1);
4479 cfg.translation_per_type_node_charge = Some(1);
4480 cfg.translation_per_reference_node_charge = Some(1);
4481 cfg.translation_per_linkage_entry_charge = Some(10);
4482 cfg.gas_model_version = Some(11);
4483 cfg.feature_flags.abstract_size_in_object_runtime = true;
4484 cfg.feature_flags.object_runtime_charge_cache_load_gas = true;
4485 cfg.dynamic_field_hash_type_and_key_cost_base = Some(52);
4486 cfg.dynamic_field_add_child_object_cost_base = Some(52);
4487 cfg.dynamic_field_add_child_object_value_cost_per_byte = Some(1);
4488 cfg.dynamic_field_borrow_child_object_cost_base = Some(52);
4489 cfg.dynamic_field_borrow_child_object_child_ref_cost_per_byte = Some(1);
4490 cfg.dynamic_field_remove_child_object_cost_base = Some(52);
4491 cfg.dynamic_field_remove_child_object_child_cost_per_byte = Some(1);
4492 cfg.dynamic_field_has_child_object_cost_base = Some(52);
4493 cfg.dynamic_field_has_child_object_with_ty_cost_base = Some(52);
4494 cfg.feature_flags.enable_ptb_execution_v2 = true;
4495
4496 cfg.poseidon_bn254_cost_base = Some(260);
4497
4498 cfg.feature_flags.consensus_skip_gced_accept_votes = true;
4499
4500 if chain != Chain::Mainnet {
4501 cfg.feature_flags
4502 .enable_nitro_attestation_all_nonzero_pcrs_parsing = true;
4503 }
4504
4505 cfg.feature_flags
4506 .include_cancelled_randomness_txns_in_prologue = true;
4507 }
4508 105 => {
4509 cfg.feature_flags.enable_multi_epoch_transaction_expiration = true;
4510 cfg.feature_flags.disable_preconsensus_locking = true;
4511
4512 if chain != Chain::Mainnet {
4513 cfg.feature_flags
4514 .enable_nitro_attestation_always_include_required_pcrs_parsing = true;
4515 }
4516 }
4517 106 => {
4518 cfg.accumulator_object_storage_cost = Some(7600);
4520
4521 if chain != Chain::Mainnet && chain != Chain::Testnet {
4522 cfg.feature_flags.enable_accumulators = true;
4523 cfg.feature_flags.enable_address_balance_gas_payments = true;
4524 cfg.feature_flags.enable_authenticated_event_streams = true;
4525 cfg.feature_flags.enable_object_funds_withdraw = true;
4526 }
4527 }
4528 107 => {
4529 cfg.feature_flags
4530 .consensus_skip_gced_blocks_in_direct_finalization = true;
4531
4532 if in_integration_test() {
4534 cfg.consensus_gc_depth = Some(6);
4535 cfg.consensus_max_num_transactions_in_block = Some(8);
4536 }
4537 }
4538 108 => {
4539 cfg.feature_flags.gas_rounding_halve_digits = true;
4540 cfg.feature_flags.flexible_tx_context_positions = true;
4541 cfg.feature_flags.disable_entry_point_signature_check = true;
4542
4543 if chain != Chain::Mainnet {
4544 cfg.feature_flags.address_aliases = true;
4545
4546 cfg.feature_flags.enable_accumulators = true;
4547 cfg.feature_flags.enable_address_balance_gas_payments = true;
4548 }
4549
4550 cfg.feature_flags.enable_poseidon = true;
4551 }
4552 109 => {
4553 cfg.binary_variant_handles = Some(1024);
4554 cfg.binary_variant_instantiation_handles = Some(1024);
4555 cfg.feature_flags.restrict_hot_or_not_entry_functions = true;
4556 }
4557 110 => {
4558 cfg.feature_flags
4559 .enable_nitro_attestation_all_nonzero_pcrs_parsing = true;
4560 cfg.feature_flags
4561 .enable_nitro_attestation_always_include_required_pcrs_parsing = true;
4562 if chain != Chain::Mainnet && chain != Chain::Testnet {
4563 cfg.feature_flags.split_checkpoints_in_consensus_handler = true;
4564 }
4565 cfg.feature_flags.validate_zklogin_public_identifier = true;
4566 cfg.feature_flags.fix_checkpoint_signature_mapping = true;
4567 cfg.feature_flags
4568 .consensus_always_accept_system_transactions = true;
4569 if chain != Chain::Mainnet {
4570 cfg.feature_flags.enable_object_funds_withdraw = true;
4571 }
4572 }
4573 111 => {
4574 cfg.feature_flags.validator_metadata_verify_v2 = true;
4575 }
4576 112 => {
4577 cfg.group_ops_ristretto_decode_scalar_cost = Some(7);
4578 cfg.group_ops_ristretto_decode_point_cost = Some(200);
4579 cfg.group_ops_ristretto_scalar_add_cost = Some(10);
4580 cfg.group_ops_ristretto_point_add_cost = Some(500);
4581 cfg.group_ops_ristretto_scalar_sub_cost = Some(10);
4582 cfg.group_ops_ristretto_point_sub_cost = Some(500);
4583 cfg.group_ops_ristretto_scalar_mul_cost = Some(11);
4584 cfg.group_ops_ristretto_point_mul_cost = Some(1200);
4585 cfg.group_ops_ristretto_scalar_div_cost = Some(151);
4586 cfg.group_ops_ristretto_point_div_cost = Some(2500);
4587
4588 if chain != Chain::Mainnet && chain != Chain::Testnet {
4589 cfg.feature_flags.enable_ristretto255_group_ops = true;
4590 }
4591
4592 cfg.feature_flags.address_aliases = true;
4593 }
4594 _ => panic!("unsupported version {:?}", version),
4605 }
4606 }
4607
4608 if cfg!(msim) {
4610 }
4615
4616 cfg
4617 }
4618
4619 pub fn verifier_config(&self, signing_limits: Option<(usize, usize, usize)>) -> VerifierConfig {
4625 let (
4626 max_back_edges_per_function,
4627 max_back_edges_per_module,
4628 sanity_check_with_regex_reference_safety,
4629 ) = if let Some((
4630 max_back_edges_per_function,
4631 max_back_edges_per_module,
4632 sanity_check_with_regex_reference_safety,
4633 )) = signing_limits
4634 {
4635 (
4636 Some(max_back_edges_per_function),
4637 Some(max_back_edges_per_module),
4638 Some(sanity_check_with_regex_reference_safety),
4639 )
4640 } else {
4641 (None, None, None)
4642 };
4643
4644 let additional_borrow_checks = if signing_limits.is_some() {
4645 true
4647 } else {
4648 self.additional_borrow_checks()
4649 };
4650 let deprecate_global_storage_ops = if signing_limits.is_some() {
4651 true
4653 } else {
4654 self.deprecate_global_storage_ops()
4655 };
4656
4657 VerifierConfig {
4658 max_loop_depth: Some(self.max_loop_depth() as usize),
4659 max_generic_instantiation_length: Some(self.max_generic_instantiation_length() as usize),
4660 max_function_parameters: Some(self.max_function_parameters() as usize),
4661 max_basic_blocks: Some(self.max_basic_blocks() as usize),
4662 max_value_stack_size: self.max_value_stack_size() as usize,
4663 max_type_nodes: Some(self.max_type_nodes() as usize),
4664 max_push_size: Some(self.max_push_size() as usize),
4665 max_dependency_depth: Some(self.max_dependency_depth() as usize),
4666 max_fields_in_struct: Some(self.max_fields_in_struct() as usize),
4667 max_function_definitions: Some(self.max_function_definitions() as usize),
4668 max_data_definitions: Some(self.max_struct_definitions() as usize),
4669 max_constant_vector_len: Some(self.max_move_vector_len()),
4670 max_back_edges_per_function,
4671 max_back_edges_per_module,
4672 max_basic_blocks_in_script: None,
4673 max_identifier_len: self.max_move_identifier_len_as_option(), disallow_self_identifier: self.feature_flags.disallow_self_identifier,
4675 allow_receiving_object_id: self.allow_receiving_object_id(),
4676 reject_mutable_random_on_entry_functions: self
4677 .reject_mutable_random_on_entry_functions(),
4678 bytecode_version: self.move_binary_format_version(),
4679 max_variants_in_enum: self.max_move_enum_variants_as_option(),
4680 additional_borrow_checks,
4681 better_loader_errors: self.better_loader_errors(),
4682 private_generics_verifier_v2: self.private_generics_verifier_v2(),
4683 sanity_check_with_regex_reference_safety: sanity_check_with_regex_reference_safety
4684 .map(|limit| limit as u128),
4685 deprecate_global_storage_ops,
4686 disable_entry_point_signature_check: self.disable_entry_point_signature_check(),
4687 switch_to_regex_reference_safety: false,
4688 }
4689 }
4690
4691 pub fn binary_config(
4692 &self,
4693 override_deprecate_global_storage_ops_during_deserialization: Option<bool>,
4694 ) -> BinaryConfig {
4695 let deprecate_global_storage_ops =
4696 override_deprecate_global_storage_ops_during_deserialization
4697 .unwrap_or_else(|| self.deprecate_global_storage_ops());
4698 BinaryConfig::new(
4699 self.move_binary_format_version(),
4700 self.min_move_binary_format_version_as_option()
4701 .unwrap_or(VERSION_1),
4702 self.no_extraneous_module_bytes(),
4703 deprecate_global_storage_ops,
4704 TableConfig {
4705 module_handles: self.binary_module_handles_as_option().unwrap_or(u16::MAX),
4706 datatype_handles: self.binary_struct_handles_as_option().unwrap_or(u16::MAX),
4707 function_handles: self.binary_function_handles_as_option().unwrap_or(u16::MAX),
4708 function_instantiations: self
4709 .binary_function_instantiations_as_option()
4710 .unwrap_or(u16::MAX),
4711 signatures: self.binary_signatures_as_option().unwrap_or(u16::MAX),
4712 constant_pool: self.binary_constant_pool_as_option().unwrap_or(u16::MAX),
4713 identifiers: self.binary_identifiers_as_option().unwrap_or(u16::MAX),
4714 address_identifiers: self
4715 .binary_address_identifiers_as_option()
4716 .unwrap_or(u16::MAX),
4717 struct_defs: self.binary_struct_defs_as_option().unwrap_or(u16::MAX),
4718 struct_def_instantiations: self
4719 .binary_struct_def_instantiations_as_option()
4720 .unwrap_or(u16::MAX),
4721 function_defs: self.binary_function_defs_as_option().unwrap_or(u16::MAX),
4722 field_handles: self.binary_field_handles_as_option().unwrap_or(u16::MAX),
4723 field_instantiations: self
4724 .binary_field_instantiations_as_option()
4725 .unwrap_or(u16::MAX),
4726 friend_decls: self.binary_friend_decls_as_option().unwrap_or(u16::MAX),
4727 enum_defs: self.binary_enum_defs_as_option().unwrap_or(u16::MAX),
4728 enum_def_instantiations: self
4729 .binary_enum_def_instantiations_as_option()
4730 .unwrap_or(u16::MAX),
4731 variant_handles: self.binary_variant_handles_as_option().unwrap_or(u16::MAX),
4732 variant_instantiation_handles: self
4733 .binary_variant_instantiation_handles_as_option()
4734 .unwrap_or(u16::MAX),
4735 },
4736 )
4737 }
4738
4739 pub fn apply_overrides_for_testing(
4743 override_fn: impl Fn(ProtocolVersion, Self) -> Self + Send + 'static,
4744 ) -> OverrideGuard {
4745 CONFIG_OVERRIDE.with(|ovr| {
4746 let mut cur = ovr.borrow_mut();
4747 assert!(cur.is_none(), "config override already present");
4748 *cur = Some(Box::new(override_fn));
4749 OverrideGuard
4750 })
4751 }
4752}
4753
4754impl ProtocolConfig {
4758 pub fn set_advance_to_highest_supported_protocol_version_for_testing(&mut self, val: bool) {
4759 self.feature_flags
4760 .advance_to_highest_supported_protocol_version = val
4761 }
4762 pub fn set_commit_root_state_digest_supported_for_testing(&mut self, val: bool) {
4763 self.feature_flags.commit_root_state_digest = val
4764 }
4765 pub fn set_zklogin_auth_for_testing(&mut self, val: bool) {
4766 self.feature_flags.zklogin_auth = val
4767 }
4768 pub fn set_enable_jwk_consensus_updates_for_testing(&mut self, val: bool) {
4769 self.feature_flags.enable_jwk_consensus_updates = val
4770 }
4771 pub fn set_random_beacon_for_testing(&mut self, val: bool) {
4772 self.feature_flags.random_beacon = val
4773 }
4774
4775 pub fn set_upgraded_multisig_for_testing(&mut self, val: bool) {
4776 self.feature_flags.upgraded_multisig_supported = val
4777 }
4778 pub fn set_accept_zklogin_in_multisig_for_testing(&mut self, val: bool) {
4779 self.feature_flags.accept_zklogin_in_multisig = val
4780 }
4781
4782 pub fn set_shared_object_deletion_for_testing(&mut self, val: bool) {
4783 self.feature_flags.shared_object_deletion = val;
4784 }
4785
4786 pub fn set_narwhal_new_leader_election_schedule_for_testing(&mut self, val: bool) {
4787 self.feature_flags.narwhal_new_leader_election_schedule = val;
4788 }
4789
4790 pub fn set_receive_object_for_testing(&mut self, val: bool) {
4791 self.feature_flags.receive_objects = val
4792 }
4793 pub fn set_narwhal_certificate_v2_for_testing(&mut self, val: bool) {
4794 self.feature_flags.narwhal_certificate_v2 = val
4795 }
4796 pub fn set_verify_legacy_zklogin_address_for_testing(&mut self, val: bool) {
4797 self.feature_flags.verify_legacy_zklogin_address = val
4798 }
4799
4800 pub fn set_per_object_congestion_control_mode_for_testing(
4801 &mut self,
4802 val: PerObjectCongestionControlMode,
4803 ) {
4804 self.feature_flags.per_object_congestion_control_mode = val;
4805 }
4806
4807 pub fn set_consensus_choice_for_testing(&mut self, val: ConsensusChoice) {
4808 self.feature_flags.consensus_choice = val;
4809 }
4810
4811 pub fn set_consensus_network_for_testing(&mut self, val: ConsensusNetwork) {
4812 self.feature_flags.consensus_network = val;
4813 }
4814
4815 pub fn set_zklogin_max_epoch_upper_bound_delta_for_testing(&mut self, val: Option<u64>) {
4816 self.feature_flags.zklogin_max_epoch_upper_bound_delta = val
4817 }
4818
4819 pub fn set_disable_bridge_for_testing(&mut self) {
4820 self.feature_flags.bridge = false
4821 }
4822
4823 pub fn set_mysticeti_num_leaders_per_round_for_testing(&mut self, val: Option<usize>) {
4824 self.feature_flags.mysticeti_num_leaders_per_round = val;
4825 }
4826
4827 pub fn set_enable_soft_bundle_for_testing(&mut self, val: bool) {
4828 self.feature_flags.soft_bundle = val;
4829 }
4830
4831 pub fn set_passkey_auth_for_testing(&mut self, val: bool) {
4832 self.feature_flags.passkey_auth = val
4833 }
4834
4835 pub fn set_enable_party_transfer_for_testing(&mut self, val: bool) {
4836 self.feature_flags.enable_party_transfer = val
4837 }
4838
4839 pub fn set_consensus_distributed_vote_scoring_strategy_for_testing(&mut self, val: bool) {
4840 self.feature_flags
4841 .consensus_distributed_vote_scoring_strategy = val;
4842 }
4843
4844 pub fn set_consensus_round_prober_for_testing(&mut self, val: bool) {
4845 self.feature_flags.consensus_round_prober = val;
4846 }
4847
4848 pub fn set_disallow_new_modules_in_deps_only_packages_for_testing(&mut self, val: bool) {
4849 self.feature_flags
4850 .disallow_new_modules_in_deps_only_packages = val;
4851 }
4852
4853 pub fn set_correct_gas_payment_limit_check_for_testing(&mut self, val: bool) {
4854 self.feature_flags.correct_gas_payment_limit_check = val;
4855 }
4856
4857 pub fn set_address_aliases_for_testing(&mut self, val: bool) {
4858 self.feature_flags.address_aliases = val;
4859 }
4860
4861 pub fn set_consensus_round_prober_probe_accepted_rounds(&mut self, val: bool) {
4862 self.feature_flags
4863 .consensus_round_prober_probe_accepted_rounds = val;
4864 }
4865
4866 pub fn set_mysticeti_fastpath_for_testing(&mut self, val: bool) {
4867 self.feature_flags.mysticeti_fastpath = val;
4868 }
4869
4870 pub fn set_accept_passkey_in_multisig_for_testing(&mut self, val: bool) {
4871 self.feature_flags.accept_passkey_in_multisig = val;
4872 }
4873
4874 pub fn set_consensus_batched_block_sync_for_testing(&mut self, val: bool) {
4875 self.feature_flags.consensus_batched_block_sync = val;
4876 }
4877
4878 pub fn set_record_time_estimate_processed_for_testing(&mut self, val: bool) {
4879 self.feature_flags.record_time_estimate_processed = val;
4880 }
4881
4882 pub fn set_prepend_prologue_tx_in_consensus_commit_in_checkpoints_for_testing(
4883 &mut self,
4884 val: bool,
4885 ) {
4886 self.feature_flags
4887 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = val;
4888 }
4889
4890 pub fn enable_accumulators_for_testing(&mut self) {
4891 self.feature_flags.enable_accumulators = true;
4892 }
4893
4894 pub fn disable_accumulators_for_testing(&mut self) {
4895 self.feature_flags.enable_accumulators = false;
4896 self.feature_flags.enable_address_balance_gas_payments = false;
4897 }
4898
4899 pub fn enable_coin_reservation_for_testing(&mut self) {
4900 self.feature_flags.enable_coin_reservation_obj_refs = true;
4901 }
4902
4903 pub fn create_root_accumulator_object_for_testing(&mut self) {
4904 self.feature_flags.create_root_accumulator_object = true;
4905 }
4906
4907 pub fn disable_create_root_accumulator_object_for_testing(&mut self) {
4908 self.feature_flags.create_root_accumulator_object = false;
4909 }
4910
4911 pub fn enable_address_balance_gas_payments_for_testing(&mut self) {
4912 self.feature_flags.enable_accumulators = true;
4913 self.feature_flags.allow_private_accumulator_entrypoints = true;
4914 self.feature_flags.enable_address_balance_gas_payments = true;
4915 }
4916
4917 pub fn disable_address_balance_gas_payments_for_testing(&mut self) {
4918 self.feature_flags.enable_address_balance_gas_payments = false;
4919 }
4920
4921 pub fn enable_multi_epoch_transaction_expiration_for_testing(&mut self) {
4922 self.feature_flags.enable_multi_epoch_transaction_expiration = true;
4923 }
4924
4925 pub fn enable_authenticated_event_streams_for_testing(&mut self) {
4926 self.enable_accumulators_for_testing();
4927 self.feature_flags.enable_authenticated_event_streams = true;
4928 self.feature_flags
4929 .include_checkpoint_artifacts_digest_in_summary = true;
4930 }
4931
4932 pub fn disable_authenticated_event_streams_for_testing(&mut self) {
4933 self.feature_flags.enable_authenticated_event_streams = false;
4934 }
4935
4936 pub fn enable_non_exclusive_writes_for_testing(&mut self) {
4937 self.feature_flags.enable_non_exclusive_writes = true;
4938 }
4939
4940 pub fn set_ignore_execution_time_observations_after_certs_closed_for_testing(
4941 &mut self,
4942 val: bool,
4943 ) {
4944 self.feature_flags
4945 .ignore_execution_time_observations_after_certs_closed = val;
4946 }
4947
4948 pub fn set_consensus_checkpoint_signature_key_includes_digest_for_testing(
4949 &mut self,
4950 val: bool,
4951 ) {
4952 self.feature_flags
4953 .consensus_checkpoint_signature_key_includes_digest = val;
4954 }
4955
4956 pub fn set_cancel_for_failed_dkg_early_for_testing(&mut self, val: bool) {
4957 self.feature_flags.cancel_for_failed_dkg_early = val;
4958 }
4959
4960 pub fn set_use_mfp_txns_in_load_initial_object_debts_for_testing(&mut self, val: bool) {
4961 self.feature_flags.use_mfp_txns_in_load_initial_object_debts = val;
4962 }
4963
4964 pub fn set_authority_capabilities_v2_for_testing(&mut self, val: bool) {
4965 self.feature_flags.authority_capabilities_v2 = val;
4966 }
4967
4968 pub fn allow_references_in_ptbs_for_testing(&mut self) {
4969 self.feature_flags.allow_references_in_ptbs = true;
4970 }
4971
4972 pub fn set_consensus_skip_gced_accept_votes_for_testing(&mut self, val: bool) {
4973 self.feature_flags.consensus_skip_gced_accept_votes = val;
4974 }
4975
4976 pub fn set_enable_object_funds_withdraw_for_testing(&mut self, val: bool) {
4977 self.feature_flags.enable_object_funds_withdraw = val;
4978 }
4979
4980 pub fn set_split_checkpoints_in_consensus_handler_for_testing(&mut self, val: bool) {
4981 self.feature_flags.split_checkpoints_in_consensus_handler = val;
4982 }
4983}
4984
4985type OverrideFn = dyn Fn(ProtocolVersion, ProtocolConfig) -> ProtocolConfig + Send;
4986
4987thread_local! {
4988 static CONFIG_OVERRIDE: RefCell<Option<Box<OverrideFn>>> = RefCell::new(None);
4989}
4990
4991#[must_use]
4992pub struct OverrideGuard;
4993
4994impl Drop for OverrideGuard {
4995 fn drop(&mut self) {
4996 info!("restoring override fn");
4997 CONFIG_OVERRIDE.with(|ovr| {
4998 *ovr.borrow_mut() = None;
4999 });
5000 }
5001}
5002
5003#[derive(PartialEq, Eq)]
5006pub enum LimitThresholdCrossed {
5007 None,
5008 Soft(u128, u128),
5009 Hard(u128, u128),
5010}
5011
5012pub fn check_limit_in_range<T: Into<V>, U: Into<V>, V: PartialOrd + Into<u128>>(
5015 x: T,
5016 soft_limit: U,
5017 hard_limit: V,
5018) -> LimitThresholdCrossed {
5019 let x: V = x.into();
5020 let soft_limit: V = soft_limit.into();
5021
5022 debug_assert!(soft_limit <= hard_limit);
5023
5024 if x >= hard_limit {
5027 LimitThresholdCrossed::Hard(x.into(), hard_limit.into())
5028 } else if x < soft_limit {
5029 LimitThresholdCrossed::None
5030 } else {
5031 LimitThresholdCrossed::Soft(x.into(), soft_limit.into())
5032 }
5033}
5034
5035#[macro_export]
5036macro_rules! check_limit {
5037 ($x:expr, $hard:expr) => {
5038 check_limit!($x, $hard, $hard)
5039 };
5040 ($x:expr, $soft:expr, $hard:expr) => {
5041 check_limit_in_range($x as u64, $soft, $hard)
5042 };
5043}
5044
5045#[macro_export]
5049macro_rules! check_limit_by_meter {
5050 ($is_metered:expr, $x:expr, $metered_limit:expr, $unmetered_hard_limit:expr, $metric:expr) => {{
5051 let (h, metered_str) = if $is_metered {
5053 ($metered_limit, "metered")
5054 } else {
5055 ($unmetered_hard_limit, "unmetered")
5057 };
5058 use sui_protocol_config::check_limit_in_range;
5059 let result = check_limit_in_range($x as u64, $metered_limit, h);
5060 match result {
5061 LimitThresholdCrossed::None => {}
5062 LimitThresholdCrossed::Soft(_, _) => {
5063 $metric.with_label_values(&[metered_str, "soft"]).inc();
5064 }
5065 LimitThresholdCrossed::Hard(_, _) => {
5066 $metric.with_label_values(&[metered_str, "hard"]).inc();
5067 }
5068 };
5069 result
5070 }};
5071}
5072#[cfg(all(test, not(msim)))]
5073mod test {
5074 use insta::assert_yaml_snapshot;
5075
5076 use super::*;
5077
5078 #[test]
5079 fn snapshot_tests() {
5080 println!("\n============================================================================");
5081 println!("! !");
5082 println!("! IMPORTANT: never update snapshots from this test. only add new versions! !");
5083 println!("! !");
5084 println!("============================================================================\n");
5085 for chain_id in &[Chain::Unknown, Chain::Mainnet, Chain::Testnet] {
5086 let chain_str = match chain_id {
5090 Chain::Unknown => "".to_string(),
5091 _ => format!("{:?}_", chain_id),
5092 };
5093 for i in MIN_PROTOCOL_VERSION..=MAX_PROTOCOL_VERSION {
5094 let cur = ProtocolVersion::new(i);
5095 assert_yaml_snapshot!(
5096 format!("{}version_{}", chain_str, cur.as_u64()),
5097 ProtocolConfig::get_for_version(cur, *chain_id)
5098 );
5099 }
5100 }
5101 }
5102
5103 #[test]
5104 fn test_getters() {
5105 let prot: ProtocolConfig =
5106 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5107 assert_eq!(
5108 prot.max_arguments(),
5109 prot.max_arguments_as_option().unwrap()
5110 );
5111 }
5112
5113 #[test]
5114 fn test_setters() {
5115 let mut prot: ProtocolConfig =
5116 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5117 prot.set_max_arguments_for_testing(123);
5118 assert_eq!(prot.max_arguments(), 123);
5119
5120 prot.set_max_arguments_from_str_for_testing("321".to_string());
5121 assert_eq!(prot.max_arguments(), 321);
5122
5123 prot.disable_max_arguments_for_testing();
5124 assert_eq!(prot.max_arguments_as_option(), None);
5125
5126 prot.set_attr_for_testing("max_arguments".to_string(), "456".to_string());
5127 assert_eq!(prot.max_arguments(), 456);
5128 }
5129
5130 #[test]
5131 #[should_panic(expected = "unsupported version")]
5132 fn max_version_test() {
5133 let _ = ProtocolConfig::get_for_version_impl(
5136 ProtocolVersion::new(MAX_PROTOCOL_VERSION + 1),
5137 Chain::Unknown,
5138 );
5139 }
5140
5141 #[test]
5142 fn lookup_by_string_test() {
5143 let prot: ProtocolConfig =
5144 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5145 assert!(prot.lookup_attr("some random string".to_string()).is_none());
5147
5148 assert!(
5149 prot.lookup_attr("max_arguments".to_string())
5150 == Some(ProtocolConfigValue::u32(prot.max_arguments())),
5151 );
5152
5153 assert!(
5155 prot.lookup_attr("max_move_identifier_len".to_string())
5156 .is_none()
5157 );
5158
5159 let prot: ProtocolConfig =
5161 ProtocolConfig::get_for_version(ProtocolVersion::new(9), Chain::Unknown);
5162 assert!(
5163 prot.lookup_attr("max_move_identifier_len".to_string())
5164 == Some(ProtocolConfigValue::u64(prot.max_move_identifier_len()))
5165 );
5166
5167 let prot: ProtocolConfig =
5168 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5169 assert!(
5171 prot.attr_map()
5172 .get("max_move_identifier_len")
5173 .unwrap()
5174 .is_none()
5175 );
5176 assert!(
5178 prot.attr_map().get("max_arguments").unwrap()
5179 == &Some(ProtocolConfigValue::u32(prot.max_arguments()))
5180 );
5181
5182 let prot: ProtocolConfig =
5184 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5185 assert!(
5187 prot.feature_flags
5188 .lookup_attr("some random string".to_owned())
5189 .is_none()
5190 );
5191 assert!(
5192 !prot
5193 .feature_flags
5194 .attr_map()
5195 .contains_key("some random string")
5196 );
5197
5198 assert!(
5200 prot.feature_flags
5201 .lookup_attr("package_upgrades".to_owned())
5202 == Some(false)
5203 );
5204 assert!(
5205 prot.feature_flags
5206 .attr_map()
5207 .get("package_upgrades")
5208 .unwrap()
5209 == &false
5210 );
5211 let prot: ProtocolConfig =
5212 ProtocolConfig::get_for_version(ProtocolVersion::new(4), Chain::Unknown);
5213 assert!(
5215 prot.feature_flags
5216 .lookup_attr("package_upgrades".to_owned())
5217 == Some(true)
5218 );
5219 assert!(
5220 prot.feature_flags
5221 .attr_map()
5222 .get("package_upgrades")
5223 .unwrap()
5224 == &true
5225 );
5226 }
5227
5228 #[test]
5229 fn limit_range_fn_test() {
5230 let low = 100u32;
5231 let high = 10000u64;
5232
5233 assert!(check_limit!(1u8, low, high) == LimitThresholdCrossed::None);
5234 assert!(matches!(
5235 check_limit!(255u16, low, high),
5236 LimitThresholdCrossed::Soft(255u128, 100)
5237 ));
5238 assert!(matches!(
5244 check_limit!(2550000u64, low, high),
5245 LimitThresholdCrossed::Hard(2550000, 10000)
5246 ));
5247
5248 assert!(matches!(
5249 check_limit!(2550000u64, high, high),
5250 LimitThresholdCrossed::Hard(2550000, 10000)
5251 ));
5252
5253 assert!(matches!(
5254 check_limit!(1u8, high),
5255 LimitThresholdCrossed::None
5256 ));
5257
5258 assert!(check_limit!(255u16, high) == LimitThresholdCrossed::None);
5259
5260 assert!(matches!(
5261 check_limit!(2550000u64, high),
5262 LimitThresholdCrossed::Hard(2550000, 10000)
5263 ));
5264 }
5265}