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 serde::{Deserialize, Serialize};
18use serde_with::skip_serializing_none;
19use sui_protocol_config_macros::{
20 ProtocolConfigAccessors, ProtocolConfigFeatureFlagsGetters, ProtocolConfigOverride,
21};
22use tracing::{info, warn};
23
24const MIN_PROTOCOL_VERSION: u64 = 1;
26const MAX_PROTOCOL_VERSION: u64 = 101;
27
28#[derive(Copy, Clone, Debug, Hash, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)]
280pub struct ProtocolVersion(u64);
281
282impl ProtocolVersion {
283 pub const MIN: Self = Self(MIN_PROTOCOL_VERSION);
288
289 pub const MAX: Self = Self(MAX_PROTOCOL_VERSION);
290
291 #[cfg(not(msim))]
292 pub const MAX_ALLOWED: Self = Self::MAX;
293
294 #[cfg(msim)]
296 pub const MAX_ALLOWED: Self = Self(MAX_PROTOCOL_VERSION + 1);
297
298 pub fn new(v: u64) -> Self {
299 Self(v)
300 }
301
302 pub const fn as_u64(&self) -> u64 {
303 self.0
304 }
305
306 pub fn max() -> Self {
309 Self::MAX
310 }
311
312 pub fn prev(self) -> Self {
313 Self(self.0.checked_sub(1).unwrap())
314 }
315}
316
317impl From<u64> for ProtocolVersion {
318 fn from(v: u64) -> Self {
319 Self::new(v)
320 }
321}
322
323impl std::ops::Sub<u64> for ProtocolVersion {
324 type Output = Self;
325 fn sub(self, rhs: u64) -> Self::Output {
326 Self::new(self.0 - rhs)
327 }
328}
329
330impl std::ops::Add<u64> for ProtocolVersion {
331 type Output = Self;
332 fn add(self, rhs: u64) -> Self::Output {
333 Self::new(self.0 + rhs)
334 }
335}
336
337#[derive(Clone, Serialize, Deserialize, Debug, PartialEq, Copy, PartialOrd, Ord, Eq, ValueEnum)]
338pub enum Chain {
339 Mainnet,
340 Testnet,
341 Unknown,
342}
343
344impl Default for Chain {
345 fn default() -> Self {
346 Self::Unknown
347 }
348}
349
350impl Chain {
351 pub fn as_str(self) -> &'static str {
352 match self {
353 Chain::Mainnet => "mainnet",
354 Chain::Testnet => "testnet",
355 Chain::Unknown => "unknown",
356 }
357 }
358}
359
360pub struct Error(pub String);
361
362#[derive(Default, Clone, Serialize, Deserialize, Debug, ProtocolConfigFeatureFlagsGetters)]
365struct FeatureFlags {
366 #[serde(skip_serializing_if = "is_false")]
369 package_upgrades: bool,
370 #[serde(skip_serializing_if = "is_false")]
373 commit_root_state_digest: bool,
374 #[serde(skip_serializing_if = "is_false")]
376 advance_epoch_start_time_in_safe_mode: bool,
377 #[serde(skip_serializing_if = "is_false")]
380 loaded_child_objects_fixed: bool,
381 #[serde(skip_serializing_if = "is_false")]
384 missing_type_is_compatibility_error: bool,
385 #[serde(skip_serializing_if = "is_false")]
388 scoring_decision_with_validity_cutoff: bool,
389
390 #[serde(skip_serializing_if = "is_false")]
393 consensus_order_end_of_epoch_last: bool,
394
395 #[serde(skip_serializing_if = "is_false")]
397 disallow_adding_abilities_on_upgrade: bool,
398 #[serde(skip_serializing_if = "is_false")]
400 disable_invariant_violation_check_in_swap_loc: bool,
401 #[serde(skip_serializing_if = "is_false")]
404 advance_to_highest_supported_protocol_version: bool,
405 #[serde(skip_serializing_if = "is_false")]
407 ban_entry_init: bool,
408 #[serde(skip_serializing_if = "is_false")]
410 package_digest_hash_module: bool,
411 #[serde(skip_serializing_if = "is_false")]
413 disallow_change_struct_type_params_on_upgrade: bool,
414 #[serde(skip_serializing_if = "is_false")]
416 no_extraneous_module_bytes: bool,
417 #[serde(skip_serializing_if = "is_false")]
419 narwhal_versioned_metadata: bool,
420
421 #[serde(skip_serializing_if = "is_false")]
423 zklogin_auth: bool,
424 #[serde(skip_serializing_if = "ConsensusTransactionOrdering::is_none")]
426 consensus_transaction_ordering: ConsensusTransactionOrdering,
427
428 #[serde(skip_serializing_if = "is_false")]
436 simplified_unwrap_then_delete: bool,
437 #[serde(skip_serializing_if = "is_false")]
439 upgraded_multisig_supported: bool,
440 #[serde(skip_serializing_if = "is_false")]
442 txn_base_cost_as_multiplier: bool,
443
444 #[serde(skip_serializing_if = "is_false")]
446 shared_object_deletion: bool,
447
448 #[serde(skip_serializing_if = "is_false")]
450 narwhal_new_leader_election_schedule: bool,
451
452 #[serde(skip_serializing_if = "is_empty")]
454 zklogin_supported_providers: BTreeSet<String>,
455
456 #[serde(skip_serializing_if = "is_false")]
458 loaded_child_object_format: bool,
459
460 #[serde(skip_serializing_if = "is_false")]
461 enable_jwk_consensus_updates: bool,
462
463 #[serde(skip_serializing_if = "is_false")]
464 end_of_epoch_transaction_supported: bool,
465
466 #[serde(skip_serializing_if = "is_false")]
469 simple_conservation_checks: bool,
470
471 #[serde(skip_serializing_if = "is_false")]
473 loaded_child_object_format_type: bool,
474
475 #[serde(skip_serializing_if = "is_false")]
477 receive_objects: bool,
478
479 #[serde(skip_serializing_if = "is_false")]
481 consensus_checkpoint_signature_key_includes_digest: bool,
482
483 #[serde(skip_serializing_if = "is_false")]
485 random_beacon: bool,
486
487 #[serde(skip_serializing_if = "is_false")]
489 bridge: bool,
490
491 #[serde(skip_serializing_if = "is_false")]
492 enable_effects_v2: bool,
493
494 #[serde(skip_serializing_if = "is_false")]
496 narwhal_certificate_v2: bool,
497
498 #[serde(skip_serializing_if = "is_false")]
500 verify_legacy_zklogin_address: bool,
501
502 #[serde(skip_serializing_if = "is_false")]
504 throughput_aware_consensus_submission: bool,
505
506 #[serde(skip_serializing_if = "is_false")]
508 recompute_has_public_transfer_in_execution: bool,
509
510 #[serde(skip_serializing_if = "is_false")]
512 accept_zklogin_in_multisig: bool,
513
514 #[serde(skip_serializing_if = "is_false")]
516 accept_passkey_in_multisig: bool,
517
518 #[serde(skip_serializing_if = "is_false")]
521 include_consensus_digest_in_prologue: bool,
522
523 #[serde(skip_serializing_if = "is_false")]
525 hardened_otw_check: bool,
526
527 #[serde(skip_serializing_if = "is_false")]
529 allow_receiving_object_id: bool,
530
531 #[serde(skip_serializing_if = "is_false")]
533 enable_poseidon: bool,
534
535 #[serde(skip_serializing_if = "is_false")]
537 enable_coin_deny_list: bool,
538
539 #[serde(skip_serializing_if = "is_false")]
541 enable_group_ops_native_functions: bool,
542
543 #[serde(skip_serializing_if = "is_false")]
545 enable_group_ops_native_function_msm: bool,
546
547 #[serde(skip_serializing_if = "is_false")]
549 enable_nitro_attestation: bool,
550
551 #[serde(skip_serializing_if = "is_false")]
553 enable_nitro_attestation_upgraded_parsing: bool,
554
555 #[serde(skip_serializing_if = "is_false")]
557 reject_mutable_random_on_entry_functions: bool,
558
559 #[serde(skip_serializing_if = "PerObjectCongestionControlMode::is_none")]
561 per_object_congestion_control_mode: PerObjectCongestionControlMode,
562
563 #[serde(skip_serializing_if = "ConsensusChoice::is_narwhal")]
565 consensus_choice: ConsensusChoice,
566
567 #[serde(skip_serializing_if = "ConsensusNetwork::is_anemo")]
569 consensus_network: ConsensusNetwork,
570
571 #[serde(skip_serializing_if = "is_false")]
573 correct_gas_payment_limit_check: bool,
574
575 #[serde(skip_serializing_if = "Option::is_none")]
577 zklogin_max_epoch_upper_bound_delta: Option<u64>,
578
579 #[serde(skip_serializing_if = "is_false")]
581 mysticeti_leader_scoring_and_schedule: bool,
582
583 #[serde(skip_serializing_if = "is_false")]
585 reshare_at_same_initial_version: bool,
586
587 #[serde(skip_serializing_if = "is_false")]
589 resolve_abort_locations_to_package_id: bool,
590
591 #[serde(skip_serializing_if = "is_false")]
595 mysticeti_use_committed_subdag_digest: bool,
596
597 #[serde(skip_serializing_if = "is_false")]
599 enable_vdf: bool,
600
601 #[serde(skip_serializing_if = "is_false")]
606 record_consensus_determined_version_assignments_in_prologue: bool,
607 #[serde(skip_serializing_if = "is_false")]
608 record_consensus_determined_version_assignments_in_prologue_v2: bool,
609
610 #[serde(skip_serializing_if = "is_false")]
612 fresh_vm_on_framework_upgrade: bool,
613
614 #[serde(skip_serializing_if = "is_false")]
622 prepend_prologue_tx_in_consensus_commit_in_checkpoints: bool,
623
624 #[serde(skip_serializing_if = "Option::is_none")]
626 mysticeti_num_leaders_per_round: Option<usize>,
627
628 #[serde(skip_serializing_if = "is_false")]
630 soft_bundle: bool,
631
632 #[serde(skip_serializing_if = "is_false")]
634 enable_coin_deny_list_v2: bool,
635
636 #[serde(skip_serializing_if = "is_false")]
638 passkey_auth: bool,
639
640 #[serde(skip_serializing_if = "is_false")]
642 authority_capabilities_v2: bool,
643
644 #[serde(skip_serializing_if = "is_false")]
646 rethrow_serialization_type_layout_errors: bool,
647
648 #[serde(skip_serializing_if = "is_false")]
650 consensus_distributed_vote_scoring_strategy: bool,
651
652 #[serde(skip_serializing_if = "is_false")]
654 consensus_round_prober: bool,
655
656 #[serde(skip_serializing_if = "is_false")]
658 validate_identifier_inputs: bool,
659
660 #[serde(skip_serializing_if = "is_false")]
662 disallow_self_identifier: bool,
663
664 #[serde(skip_serializing_if = "is_false")]
666 mysticeti_fastpath: bool,
667
668 #[serde(skip_serializing_if = "is_false")]
670 relocate_event_module: bool,
671
672 #[serde(skip_serializing_if = "is_false")]
674 uncompressed_g1_group_elements: bool,
675
676 #[serde(skip_serializing_if = "is_false")]
677 disallow_new_modules_in_deps_only_packages: bool,
678
679 #[serde(skip_serializing_if = "is_false")]
681 consensus_smart_ancestor_selection: bool,
682
683 #[serde(skip_serializing_if = "is_false")]
685 consensus_round_prober_probe_accepted_rounds: bool,
686
687 #[serde(skip_serializing_if = "is_false")]
689 native_charging_v2: bool,
690
691 #[serde(skip_serializing_if = "is_false")]
694 consensus_linearize_subdag_v2: bool,
695
696 #[serde(skip_serializing_if = "is_false")]
698 convert_type_argument_error: bool,
699
700 #[serde(skip_serializing_if = "is_false")]
702 variant_nodes: bool,
703
704 #[serde(skip_serializing_if = "is_false")]
706 consensus_zstd_compression: bool,
707
708 #[serde(skip_serializing_if = "is_false")]
710 minimize_child_object_mutations: bool,
711
712 #[serde(skip_serializing_if = "is_false")]
714 record_additional_state_digest_in_prologue: bool,
715
716 #[serde(skip_serializing_if = "is_false")]
718 move_native_context: bool,
719
720 #[serde(skip_serializing_if = "is_false")]
723 consensus_median_based_commit_timestamp: bool,
724
725 #[serde(skip_serializing_if = "is_false")]
728 normalize_ptb_arguments: bool,
729
730 #[serde(skip_serializing_if = "is_false")]
732 consensus_batched_block_sync: bool,
733
734 #[serde(skip_serializing_if = "is_false")]
736 enforce_checkpoint_timestamp_monotonicity: bool,
737
738 #[serde(skip_serializing_if = "is_false")]
740 max_ptb_value_size_v2: bool,
741
742 #[serde(skip_serializing_if = "is_false")]
744 resolve_type_input_ids_to_defining_id: bool,
745
746 #[serde(skip_serializing_if = "is_false")]
748 enable_party_transfer: bool,
749
750 #[serde(skip_serializing_if = "is_false")]
752 allow_unbounded_system_objects: bool,
753
754 #[serde(skip_serializing_if = "is_false")]
756 type_tags_in_object_runtime: bool,
757
758 #[serde(skip_serializing_if = "is_false")]
760 enable_accumulators: bool,
761
762 #[serde(skip_serializing_if = "is_false")]
765 create_root_accumulator_object: bool,
766
767 #[serde(skip_serializing_if = "is_false")]
769 enable_authenticated_event_streams: bool,
770
771 #[serde(skip_serializing_if = "is_false")]
773 enable_address_balance_gas_payments: bool,
774
775 #[serde(skip_serializing_if = "is_false")]
777 enable_ptb_execution_v2: bool,
778
779 #[serde(skip_serializing_if = "is_false")]
781 better_adapter_type_resolution_errors: bool,
782
783 #[serde(skip_serializing_if = "is_false")]
785 record_time_estimate_processed: bool,
786
787 #[serde(skip_serializing_if = "is_false")]
789 dependency_linkage_error: bool,
790
791 #[serde(skip_serializing_if = "is_false")]
793 additional_multisig_checks: bool,
794
795 #[serde(skip_serializing_if = "is_false")]
797 ignore_execution_time_observations_after_certs_closed: bool,
798
799 #[serde(skip_serializing_if = "is_false")]
803 debug_fatal_on_move_invariant_violation: bool,
804
805 #[serde(skip_serializing_if = "is_false")]
808 allow_private_accumulator_entrypoints: bool,
809
810 #[serde(skip_serializing_if = "is_false")]
812 additional_consensus_digest_indirect_state: bool,
813
814 #[serde(skip_serializing_if = "is_false")]
816 check_for_init_during_upgrade: bool,
817
818 #[serde(skip_serializing_if = "is_false")]
820 per_command_shared_object_transfer_rules: bool,
821
822 #[serde(skip_serializing_if = "is_false")]
824 include_checkpoint_artifacts_digest_in_summary: bool,
825
826 #[serde(skip_serializing_if = "is_false")]
828 use_mfp_txns_in_load_initial_object_debts: bool,
829
830 #[serde(skip_serializing_if = "is_false")]
832 cancel_for_failed_dkg_early: bool,
833
834 #[serde(skip_serializing_if = "is_false")]
836 enable_coin_registry: bool,
837
838 #[serde(skip_serializing_if = "is_false")]
840 abstract_size_in_object_runtime: bool,
841
842 #[serde(skip_serializing_if = "is_false")]
844 object_runtime_charge_cache_load_gas: bool,
845
846 #[serde(skip_serializing_if = "is_false")]
848 additional_borrow_checks: bool,
849
850 #[serde(skip_serializing_if = "is_false")]
852 use_new_commit_handler: bool,
853
854 #[serde(skip_serializing_if = "is_false")]
856 better_loader_errors: bool,
857
858 #[serde(skip_serializing_if = "is_false")]
860 generate_df_type_layouts: bool,
861
862 #[serde(skip_serializing_if = "is_false")]
864 allow_references_in_ptbs: bool,
865
866 #[serde(skip_serializing_if = "is_false")]
868 enable_display_registry: bool,
869
870 #[serde(skip_serializing_if = "is_false")]
872 private_generics_verifier_v2: bool,
873
874 #[serde(skip_serializing_if = "is_false")]
876 deprecate_global_storage_ops_during_deserialization: bool,
877
878 #[serde(skip_serializing_if = "is_false")]
881 enable_non_exclusive_writes: bool,
882}
883
884fn is_false(b: &bool) -> bool {
885 !b
886}
887
888fn is_empty(b: &BTreeSet<String>) -> bool {
889 b.is_empty()
890}
891
892fn is_zero(val: &u64) -> bool {
893 *val == 0
894}
895
896#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
898pub enum ConsensusTransactionOrdering {
899 #[default]
901 None,
902 ByGasPrice,
904}
905
906impl ConsensusTransactionOrdering {
907 pub fn is_none(&self) -> bool {
908 matches!(self, ConsensusTransactionOrdering::None)
909 }
910}
911
912#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
913pub struct ExecutionTimeEstimateParams {
914 pub target_utilization: u64,
916 pub allowed_txn_cost_overage_burst_limit_us: u64,
920
921 pub randomness_scalar: u64,
924
925 pub max_estimate_us: u64,
927
928 pub stored_observations_num_included_checkpoints: u64,
931
932 pub stored_observations_limit: u64,
934
935 #[serde(skip_serializing_if = "is_zero")]
938 pub stake_weighted_median_threshold: u64,
939
940 #[serde(skip_serializing_if = "is_false")]
944 pub default_none_duration_for_new_keys: bool,
945}
946
947#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
949pub enum PerObjectCongestionControlMode {
950 #[default]
951 None, TotalGasBudget, TotalTxCount, TotalGasBudgetWithCap, ExecutionTimeEstimate(ExecutionTimeEstimateParams), }
957
958impl PerObjectCongestionControlMode {
959 pub fn is_none(&self) -> bool {
960 matches!(self, PerObjectCongestionControlMode::None)
961 }
962}
963
964#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
966pub enum ConsensusChoice {
967 #[default]
968 Narwhal,
969 SwapEachEpoch,
970 Mysticeti,
971}
972
973impl ConsensusChoice {
974 pub fn is_narwhal(&self) -> bool {
975 matches!(self, ConsensusChoice::Narwhal)
976 }
977}
978
979#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
981pub enum ConsensusNetwork {
982 #[default]
983 Anemo,
984 Tonic,
985}
986
987impl ConsensusNetwork {
988 pub fn is_anemo(&self) -> bool {
989 matches!(self, ConsensusNetwork::Anemo)
990 }
991}
992
993#[skip_serializing_none]
1025#[derive(Clone, Serialize, Debug, ProtocolConfigAccessors, ProtocolConfigOverride)]
1026pub struct ProtocolConfig {
1027 pub version: ProtocolVersion,
1028
1029 feature_flags: FeatureFlags,
1030
1031 max_tx_size_bytes: Option<u64>,
1034
1035 max_input_objects: Option<u64>,
1037
1038 max_size_written_objects: Option<u64>,
1042 max_size_written_objects_system_tx: Option<u64>,
1045
1046 max_serialized_tx_effects_size_bytes: Option<u64>,
1048
1049 max_serialized_tx_effects_size_bytes_system_tx: Option<u64>,
1051
1052 max_gas_payment_objects: Option<u32>,
1054
1055 max_modules_in_publish: Option<u32>,
1057
1058 max_package_dependencies: Option<u32>,
1060
1061 max_arguments: Option<u32>,
1064
1065 max_type_arguments: Option<u32>,
1067
1068 max_type_argument_depth: Option<u32>,
1070
1071 max_pure_argument_size: Option<u32>,
1073
1074 max_programmable_tx_commands: Option<u32>,
1076
1077 move_binary_format_version: Option<u32>,
1080 min_move_binary_format_version: Option<u32>,
1081
1082 binary_module_handles: Option<u16>,
1084 binary_struct_handles: Option<u16>,
1085 binary_function_handles: Option<u16>,
1086 binary_function_instantiations: Option<u16>,
1087 binary_signatures: Option<u16>,
1088 binary_constant_pool: Option<u16>,
1089 binary_identifiers: Option<u16>,
1090 binary_address_identifiers: Option<u16>,
1091 binary_struct_defs: Option<u16>,
1092 binary_struct_def_instantiations: Option<u16>,
1093 binary_function_defs: Option<u16>,
1094 binary_field_handles: Option<u16>,
1095 binary_field_instantiations: Option<u16>,
1096 binary_friend_decls: Option<u16>,
1097 binary_enum_defs: Option<u16>,
1098 binary_enum_def_instantiations: Option<u16>,
1099 binary_variant_handles: Option<u16>,
1100 binary_variant_instantiation_handles: Option<u16>,
1101
1102 max_move_object_size: Option<u64>,
1104
1105 max_move_package_size: Option<u64>,
1108
1109 max_publish_or_upgrade_per_ptb: Option<u64>,
1111
1112 max_tx_gas: Option<u64>,
1114
1115 max_gas_price: Option<u64>,
1117
1118 max_gas_price_rgp_factor_for_aborted_transactions: Option<u64>,
1121
1122 max_gas_computation_bucket: Option<u64>,
1124
1125 gas_rounding_step: Option<u64>,
1127
1128 max_loop_depth: Option<u64>,
1130
1131 max_generic_instantiation_length: Option<u64>,
1133
1134 max_function_parameters: Option<u64>,
1136
1137 max_basic_blocks: Option<u64>,
1139
1140 max_value_stack_size: Option<u64>,
1142
1143 max_type_nodes: Option<u64>,
1145
1146 max_push_size: Option<u64>,
1148
1149 max_struct_definitions: Option<u64>,
1151
1152 max_function_definitions: Option<u64>,
1154
1155 max_fields_in_struct: Option<u64>,
1157
1158 max_dependency_depth: Option<u64>,
1160
1161 max_num_event_emit: Option<u64>,
1163
1164 max_num_new_move_object_ids: Option<u64>,
1166
1167 max_num_new_move_object_ids_system_tx: Option<u64>,
1169
1170 max_num_deleted_move_object_ids: Option<u64>,
1172
1173 max_num_deleted_move_object_ids_system_tx: Option<u64>,
1175
1176 max_num_transferred_move_object_ids: Option<u64>,
1178
1179 max_num_transferred_move_object_ids_system_tx: Option<u64>,
1181
1182 max_event_emit_size: Option<u64>,
1184
1185 max_event_emit_size_total: Option<u64>,
1187
1188 max_move_vector_len: Option<u64>,
1190
1191 max_move_identifier_len: Option<u64>,
1193
1194 max_move_value_depth: Option<u64>,
1196
1197 max_move_enum_variants: Option<u64>,
1199
1200 max_back_edges_per_function: Option<u64>,
1202
1203 max_back_edges_per_module: Option<u64>,
1205
1206 max_verifier_meter_ticks_per_function: Option<u64>,
1208
1209 max_meter_ticks_per_module: Option<u64>,
1211
1212 max_meter_ticks_per_package: Option<u64>,
1214
1215 object_runtime_max_num_cached_objects: Option<u64>,
1219
1220 object_runtime_max_num_cached_objects_system_tx: Option<u64>,
1222
1223 object_runtime_max_num_store_entries: Option<u64>,
1225
1226 object_runtime_max_num_store_entries_system_tx: Option<u64>,
1228
1229 base_tx_cost_fixed: Option<u64>,
1232
1233 package_publish_cost_fixed: Option<u64>,
1236
1237 base_tx_cost_per_byte: Option<u64>,
1240
1241 package_publish_cost_per_byte: Option<u64>,
1243
1244 obj_access_cost_read_per_byte: Option<u64>,
1246
1247 obj_access_cost_mutate_per_byte: Option<u64>,
1249
1250 obj_access_cost_delete_per_byte: Option<u64>,
1252
1253 obj_access_cost_verify_per_byte: Option<u64>,
1263
1264 max_type_to_layout_nodes: Option<u64>,
1266
1267 max_ptb_value_size: Option<u64>,
1269
1270 gas_model_version: Option<u64>,
1273
1274 obj_data_cost_refundable: Option<u64>,
1277
1278 obj_metadata_cost_non_refundable: Option<u64>,
1282
1283 storage_rebate_rate: Option<u64>,
1289
1290 storage_fund_reinvest_rate: Option<u64>,
1293
1294 reward_slashing_rate: Option<u64>,
1297
1298 storage_gas_price: Option<u64>,
1300
1301 max_transactions_per_checkpoint: Option<u64>,
1306
1307 max_checkpoint_size_bytes: Option<u64>,
1311
1312 buffer_stake_for_protocol_upgrade_bps: Option<u64>,
1317
1318 address_from_bytes_cost_base: Option<u64>,
1323 address_to_u256_cost_base: Option<u64>,
1325 address_from_u256_cost_base: Option<u64>,
1327
1328 config_read_setting_impl_cost_base: Option<u64>,
1333 config_read_setting_impl_cost_per_byte: Option<u64>,
1334
1335 dynamic_field_hash_type_and_key_cost_base: Option<u64>,
1338 dynamic_field_hash_type_and_key_type_cost_per_byte: Option<u64>,
1339 dynamic_field_hash_type_and_key_value_cost_per_byte: Option<u64>,
1340 dynamic_field_hash_type_and_key_type_tag_cost_per_byte: Option<u64>,
1341 dynamic_field_add_child_object_cost_base: Option<u64>,
1343 dynamic_field_add_child_object_type_cost_per_byte: Option<u64>,
1344 dynamic_field_add_child_object_value_cost_per_byte: Option<u64>,
1345 dynamic_field_add_child_object_struct_tag_cost_per_byte: Option<u64>,
1346 dynamic_field_borrow_child_object_cost_base: Option<u64>,
1348 dynamic_field_borrow_child_object_child_ref_cost_per_byte: Option<u64>,
1349 dynamic_field_borrow_child_object_type_cost_per_byte: Option<u64>,
1350 dynamic_field_remove_child_object_cost_base: Option<u64>,
1352 dynamic_field_remove_child_object_child_cost_per_byte: Option<u64>,
1353 dynamic_field_remove_child_object_type_cost_per_byte: Option<u64>,
1354 dynamic_field_has_child_object_cost_base: Option<u64>,
1356 dynamic_field_has_child_object_with_ty_cost_base: Option<u64>,
1358 dynamic_field_has_child_object_with_ty_type_cost_per_byte: Option<u64>,
1359 dynamic_field_has_child_object_with_ty_type_tag_cost_per_byte: Option<u64>,
1360
1361 event_emit_cost_base: Option<u64>,
1364 event_emit_value_size_derivation_cost_per_byte: Option<u64>,
1365 event_emit_tag_size_derivation_cost_per_byte: Option<u64>,
1366 event_emit_output_cost_per_byte: Option<u64>,
1367 event_emit_auth_stream_cost: Option<u64>,
1368
1369 object_borrow_uid_cost_base: Option<u64>,
1372 object_delete_impl_cost_base: Option<u64>,
1374 object_record_new_uid_cost_base: Option<u64>,
1376
1377 transfer_transfer_internal_cost_base: Option<u64>,
1380 transfer_party_transfer_internal_cost_base: Option<u64>,
1382 transfer_freeze_object_cost_base: Option<u64>,
1384 transfer_share_object_cost_base: Option<u64>,
1386 transfer_receive_object_cost_base: Option<u64>,
1389
1390 tx_context_derive_id_cost_base: Option<u64>,
1393 tx_context_fresh_id_cost_base: Option<u64>,
1394 tx_context_sender_cost_base: Option<u64>,
1395 tx_context_epoch_cost_base: Option<u64>,
1396 tx_context_epoch_timestamp_ms_cost_base: Option<u64>,
1397 tx_context_sponsor_cost_base: Option<u64>,
1398 tx_context_rgp_cost_base: Option<u64>,
1399 tx_context_gas_price_cost_base: Option<u64>,
1400 tx_context_gas_budget_cost_base: Option<u64>,
1401 tx_context_ids_created_cost_base: Option<u64>,
1402 tx_context_replace_cost_base: Option<u64>,
1403
1404 types_is_one_time_witness_cost_base: Option<u64>,
1407 types_is_one_time_witness_type_tag_cost_per_byte: Option<u64>,
1408 types_is_one_time_witness_type_cost_per_byte: Option<u64>,
1409
1410 validator_validate_metadata_cost_base: Option<u64>,
1413 validator_validate_metadata_data_cost_per_byte: Option<u64>,
1414
1415 crypto_invalid_arguments_cost: Option<u64>,
1417 bls12381_bls12381_min_sig_verify_cost_base: Option<u64>,
1419 bls12381_bls12381_min_sig_verify_msg_cost_per_byte: Option<u64>,
1420 bls12381_bls12381_min_sig_verify_msg_cost_per_block: Option<u64>,
1421
1422 bls12381_bls12381_min_pk_verify_cost_base: Option<u64>,
1424 bls12381_bls12381_min_pk_verify_msg_cost_per_byte: Option<u64>,
1425 bls12381_bls12381_min_pk_verify_msg_cost_per_block: Option<u64>,
1426
1427 ecdsa_k1_ecrecover_keccak256_cost_base: Option<u64>,
1429 ecdsa_k1_ecrecover_keccak256_msg_cost_per_byte: Option<u64>,
1430 ecdsa_k1_ecrecover_keccak256_msg_cost_per_block: Option<u64>,
1431 ecdsa_k1_ecrecover_sha256_cost_base: Option<u64>,
1432 ecdsa_k1_ecrecover_sha256_msg_cost_per_byte: Option<u64>,
1433 ecdsa_k1_ecrecover_sha256_msg_cost_per_block: Option<u64>,
1434
1435 ecdsa_k1_decompress_pubkey_cost_base: Option<u64>,
1437
1438 ecdsa_k1_secp256k1_verify_keccak256_cost_base: Option<u64>,
1440 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_byte: Option<u64>,
1441 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_block: Option<u64>,
1442 ecdsa_k1_secp256k1_verify_sha256_cost_base: Option<u64>,
1443 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_byte: Option<u64>,
1444 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_block: Option<u64>,
1445
1446 ecdsa_r1_ecrecover_keccak256_cost_base: Option<u64>,
1448 ecdsa_r1_ecrecover_keccak256_msg_cost_per_byte: Option<u64>,
1449 ecdsa_r1_ecrecover_keccak256_msg_cost_per_block: Option<u64>,
1450 ecdsa_r1_ecrecover_sha256_cost_base: Option<u64>,
1451 ecdsa_r1_ecrecover_sha256_msg_cost_per_byte: Option<u64>,
1452 ecdsa_r1_ecrecover_sha256_msg_cost_per_block: Option<u64>,
1453
1454 ecdsa_r1_secp256r1_verify_keccak256_cost_base: Option<u64>,
1456 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_byte: Option<u64>,
1457 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_block: Option<u64>,
1458 ecdsa_r1_secp256r1_verify_sha256_cost_base: Option<u64>,
1459 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_byte: Option<u64>,
1460 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_block: Option<u64>,
1461
1462 ecvrf_ecvrf_verify_cost_base: Option<u64>,
1464 ecvrf_ecvrf_verify_alpha_string_cost_per_byte: Option<u64>,
1465 ecvrf_ecvrf_verify_alpha_string_cost_per_block: Option<u64>,
1466
1467 ed25519_ed25519_verify_cost_base: Option<u64>,
1469 ed25519_ed25519_verify_msg_cost_per_byte: Option<u64>,
1470 ed25519_ed25519_verify_msg_cost_per_block: Option<u64>,
1471
1472 groth16_prepare_verifying_key_bls12381_cost_base: Option<u64>,
1474 groth16_prepare_verifying_key_bn254_cost_base: Option<u64>,
1475
1476 groth16_verify_groth16_proof_internal_bls12381_cost_base: Option<u64>,
1478 groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input: Option<u64>,
1479 groth16_verify_groth16_proof_internal_bn254_cost_base: Option<u64>,
1480 groth16_verify_groth16_proof_internal_bn254_cost_per_public_input: Option<u64>,
1481 groth16_verify_groth16_proof_internal_public_input_cost_per_byte: Option<u64>,
1482
1483 hash_blake2b256_cost_base: Option<u64>,
1485 hash_blake2b256_data_cost_per_byte: Option<u64>,
1486 hash_blake2b256_data_cost_per_block: Option<u64>,
1487
1488 hash_keccak256_cost_base: Option<u64>,
1490 hash_keccak256_data_cost_per_byte: Option<u64>,
1491 hash_keccak256_data_cost_per_block: Option<u64>,
1492
1493 poseidon_bn254_cost_base: Option<u64>,
1495 poseidon_bn254_cost_per_block: Option<u64>,
1496
1497 group_ops_bls12381_decode_scalar_cost: Option<u64>,
1499 group_ops_bls12381_decode_g1_cost: Option<u64>,
1500 group_ops_bls12381_decode_g2_cost: Option<u64>,
1501 group_ops_bls12381_decode_gt_cost: Option<u64>,
1502 group_ops_bls12381_scalar_add_cost: Option<u64>,
1503 group_ops_bls12381_g1_add_cost: Option<u64>,
1504 group_ops_bls12381_g2_add_cost: Option<u64>,
1505 group_ops_bls12381_gt_add_cost: Option<u64>,
1506 group_ops_bls12381_scalar_sub_cost: Option<u64>,
1507 group_ops_bls12381_g1_sub_cost: Option<u64>,
1508 group_ops_bls12381_g2_sub_cost: Option<u64>,
1509 group_ops_bls12381_gt_sub_cost: Option<u64>,
1510 group_ops_bls12381_scalar_mul_cost: Option<u64>,
1511 group_ops_bls12381_g1_mul_cost: Option<u64>,
1512 group_ops_bls12381_g2_mul_cost: Option<u64>,
1513 group_ops_bls12381_gt_mul_cost: Option<u64>,
1514 group_ops_bls12381_scalar_div_cost: Option<u64>,
1515 group_ops_bls12381_g1_div_cost: Option<u64>,
1516 group_ops_bls12381_g2_div_cost: Option<u64>,
1517 group_ops_bls12381_gt_div_cost: Option<u64>,
1518 group_ops_bls12381_g1_hash_to_base_cost: Option<u64>,
1519 group_ops_bls12381_g2_hash_to_base_cost: Option<u64>,
1520 group_ops_bls12381_g1_hash_to_cost_per_byte: Option<u64>,
1521 group_ops_bls12381_g2_hash_to_cost_per_byte: Option<u64>,
1522 group_ops_bls12381_g1_msm_base_cost: Option<u64>,
1523 group_ops_bls12381_g2_msm_base_cost: Option<u64>,
1524 group_ops_bls12381_g1_msm_base_cost_per_input: Option<u64>,
1525 group_ops_bls12381_g2_msm_base_cost_per_input: Option<u64>,
1526 group_ops_bls12381_msm_max_len: Option<u32>,
1527 group_ops_bls12381_pairing_cost: Option<u64>,
1528 group_ops_bls12381_g1_to_uncompressed_g1_cost: Option<u64>,
1529 group_ops_bls12381_uncompressed_g1_to_g1_cost: Option<u64>,
1530 group_ops_bls12381_uncompressed_g1_sum_base_cost: Option<u64>,
1531 group_ops_bls12381_uncompressed_g1_sum_cost_per_term: Option<u64>,
1532 group_ops_bls12381_uncompressed_g1_sum_max_terms: Option<u64>,
1533
1534 hmac_hmac_sha3_256_cost_base: Option<u64>,
1536 hmac_hmac_sha3_256_input_cost_per_byte: Option<u64>,
1537 hmac_hmac_sha3_256_input_cost_per_block: Option<u64>,
1538
1539 check_zklogin_id_cost_base: Option<u64>,
1541 check_zklogin_issuer_cost_base: Option<u64>,
1543
1544 vdf_verify_vdf_cost: Option<u64>,
1545 vdf_hash_to_input_cost: Option<u64>,
1546
1547 nitro_attestation_parse_base_cost: Option<u64>,
1549 nitro_attestation_parse_cost_per_byte: Option<u64>,
1550 nitro_attestation_verify_base_cost: Option<u64>,
1551 nitro_attestation_verify_cost_per_cert: Option<u64>,
1552
1553 bcs_per_byte_serialized_cost: Option<u64>,
1555 bcs_legacy_min_output_size_cost: Option<u64>,
1556 bcs_failure_cost: Option<u64>,
1557
1558 hash_sha2_256_base_cost: Option<u64>,
1559 hash_sha2_256_per_byte_cost: Option<u64>,
1560 hash_sha2_256_legacy_min_input_len_cost: Option<u64>,
1561 hash_sha3_256_base_cost: Option<u64>,
1562 hash_sha3_256_per_byte_cost: Option<u64>,
1563 hash_sha3_256_legacy_min_input_len_cost: Option<u64>,
1564 type_name_get_base_cost: Option<u64>,
1565 type_name_get_per_byte_cost: Option<u64>,
1566 type_name_id_base_cost: Option<u64>,
1567
1568 string_check_utf8_base_cost: Option<u64>,
1569 string_check_utf8_per_byte_cost: Option<u64>,
1570 string_is_char_boundary_base_cost: Option<u64>,
1571 string_sub_string_base_cost: Option<u64>,
1572 string_sub_string_per_byte_cost: Option<u64>,
1573 string_index_of_base_cost: Option<u64>,
1574 string_index_of_per_byte_pattern_cost: Option<u64>,
1575 string_index_of_per_byte_searched_cost: Option<u64>,
1576
1577 vector_empty_base_cost: Option<u64>,
1578 vector_length_base_cost: Option<u64>,
1579 vector_push_back_base_cost: Option<u64>,
1580 vector_push_back_legacy_per_abstract_memory_unit_cost: Option<u64>,
1581 vector_borrow_base_cost: Option<u64>,
1582 vector_pop_back_base_cost: Option<u64>,
1583 vector_destroy_empty_base_cost: Option<u64>,
1584 vector_swap_base_cost: Option<u64>,
1585 debug_print_base_cost: Option<u64>,
1586 debug_print_stack_trace_base_cost: Option<u64>,
1587
1588 execution_version: Option<u64>,
1597
1598 consensus_bad_nodes_stake_threshold: Option<u64>,
1602
1603 max_jwk_votes_per_validator_per_epoch: Option<u64>,
1604 max_age_of_jwk_in_epochs: Option<u64>,
1608
1609 random_beacon_reduction_allowed_delta: Option<u16>,
1613
1614 random_beacon_reduction_lower_bound: Option<u32>,
1617
1618 random_beacon_dkg_timeout_round: Option<u32>,
1621
1622 random_beacon_min_round_interval_ms: Option<u64>,
1624
1625 random_beacon_dkg_version: Option<u64>,
1628
1629 consensus_max_transaction_size_bytes: Option<u64>,
1632 consensus_max_transactions_in_block_bytes: Option<u64>,
1634 consensus_max_num_transactions_in_block: Option<u64>,
1636
1637 consensus_voting_rounds: Option<u32>,
1639
1640 max_accumulated_txn_cost_per_object_in_narwhal_commit: Option<u64>,
1642
1643 max_deferral_rounds_for_congestion_control: Option<u64>,
1646
1647 max_txn_cost_overage_per_object_in_commit: Option<u64>,
1651
1652 allowed_txn_cost_overage_burst_per_object_in_commit: Option<u64>,
1656
1657 min_checkpoint_interval_ms: Option<u64>,
1659
1660 checkpoint_summary_version_specific_data: Option<u64>,
1662
1663 max_soft_bundle_size: Option<u64>,
1665
1666 bridge_should_try_to_finalize_committee: Option<bool>,
1670
1671 max_accumulated_txn_cost_per_object_in_mysticeti_commit: Option<u64>,
1677
1678 max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit: Option<u64>,
1681
1682 consensus_gc_depth: Option<u32>,
1685
1686 gas_budget_based_txn_cost_cap_factor: Option<u64>,
1690
1691 gas_budget_based_txn_cost_absolute_cap_commit_count: Option<u64>,
1694
1695 sip_45_consensus_amplification_threshold: Option<u64>,
1698
1699 use_object_per_epoch_marker_table_v2: Option<bool>,
1702
1703 consensus_commit_rate_estimation_window_size: Option<u32>,
1705
1706 #[serde(skip_serializing_if = "Vec::is_empty")]
1710 aliased_addresses: Vec<AliasedAddress>,
1711
1712 translation_per_command_base_charge: Option<u64>,
1715
1716 translation_per_input_base_charge: Option<u64>,
1719
1720 translation_pure_input_per_byte_charge: Option<u64>,
1722
1723 translation_per_type_node_charge: Option<u64>,
1727
1728 translation_per_reference_node_charge: Option<u64>,
1731
1732 translation_metering_step_resolution: Option<u64>,
1735
1736 translation_per_linkage_entry_charge: Option<u64>,
1739
1740 max_updates_per_settlement_txn: Option<u32>,
1742}
1743
1744#[derive(Clone, Serialize, Deserialize, Debug)]
1746pub struct AliasedAddress {
1747 pub original: [u8; 32],
1749 pub aliased: [u8; 32],
1751 pub allowed_tx_digests: Vec<[u8; 32]>,
1753}
1754
1755impl ProtocolConfig {
1757 pub fn check_package_upgrades_supported(&self) -> Result<(), Error> {
1770 if self.feature_flags.package_upgrades {
1771 Ok(())
1772 } else {
1773 Err(Error(format!(
1774 "package upgrades are not supported at {:?}",
1775 self.version
1776 )))
1777 }
1778 }
1779
1780 pub fn allow_receiving_object_id(&self) -> bool {
1781 self.feature_flags.allow_receiving_object_id
1782 }
1783
1784 pub fn receiving_objects_supported(&self) -> bool {
1785 self.feature_flags.receive_objects
1786 }
1787
1788 pub fn package_upgrades_supported(&self) -> bool {
1789 self.feature_flags.package_upgrades
1790 }
1791
1792 pub fn check_commit_root_state_digest_supported(&self) -> bool {
1793 self.feature_flags.commit_root_state_digest
1794 }
1795
1796 pub fn get_advance_epoch_start_time_in_safe_mode(&self) -> bool {
1797 self.feature_flags.advance_epoch_start_time_in_safe_mode
1798 }
1799
1800 pub fn loaded_child_objects_fixed(&self) -> bool {
1801 self.feature_flags.loaded_child_objects_fixed
1802 }
1803
1804 pub fn missing_type_is_compatibility_error(&self) -> bool {
1805 self.feature_flags.missing_type_is_compatibility_error
1806 }
1807
1808 pub fn scoring_decision_with_validity_cutoff(&self) -> bool {
1809 self.feature_flags.scoring_decision_with_validity_cutoff
1810 }
1811
1812 pub fn narwhal_versioned_metadata(&self) -> bool {
1813 self.feature_flags.narwhal_versioned_metadata
1814 }
1815
1816 pub fn consensus_order_end_of_epoch_last(&self) -> bool {
1817 self.feature_flags.consensus_order_end_of_epoch_last
1818 }
1819
1820 pub fn disallow_adding_abilities_on_upgrade(&self) -> bool {
1821 self.feature_flags.disallow_adding_abilities_on_upgrade
1822 }
1823
1824 pub fn disable_invariant_violation_check_in_swap_loc(&self) -> bool {
1825 self.feature_flags
1826 .disable_invariant_violation_check_in_swap_loc
1827 }
1828
1829 pub fn advance_to_highest_supported_protocol_version(&self) -> bool {
1830 self.feature_flags
1831 .advance_to_highest_supported_protocol_version
1832 }
1833
1834 pub fn ban_entry_init(&self) -> bool {
1835 self.feature_flags.ban_entry_init
1836 }
1837
1838 pub fn package_digest_hash_module(&self) -> bool {
1839 self.feature_flags.package_digest_hash_module
1840 }
1841
1842 pub fn disallow_change_struct_type_params_on_upgrade(&self) -> bool {
1843 self.feature_flags
1844 .disallow_change_struct_type_params_on_upgrade
1845 }
1846
1847 pub fn no_extraneous_module_bytes(&self) -> bool {
1848 self.feature_flags.no_extraneous_module_bytes
1849 }
1850
1851 pub fn zklogin_auth(&self) -> bool {
1852 self.feature_flags.zklogin_auth
1853 }
1854
1855 pub fn zklogin_supported_providers(&self) -> &BTreeSet<String> {
1856 &self.feature_flags.zklogin_supported_providers
1857 }
1858
1859 pub fn consensus_transaction_ordering(&self) -> ConsensusTransactionOrdering {
1860 self.feature_flags.consensus_transaction_ordering
1861 }
1862
1863 pub fn simplified_unwrap_then_delete(&self) -> bool {
1864 self.feature_flags.simplified_unwrap_then_delete
1865 }
1866
1867 pub fn supports_upgraded_multisig(&self) -> bool {
1868 self.feature_flags.upgraded_multisig_supported
1869 }
1870
1871 pub fn txn_base_cost_as_multiplier(&self) -> bool {
1872 self.feature_flags.txn_base_cost_as_multiplier
1873 }
1874
1875 pub fn shared_object_deletion(&self) -> bool {
1876 self.feature_flags.shared_object_deletion
1877 }
1878
1879 pub fn narwhal_new_leader_election_schedule(&self) -> bool {
1880 self.feature_flags.narwhal_new_leader_election_schedule
1881 }
1882
1883 pub fn loaded_child_object_format(&self) -> bool {
1884 self.feature_flags.loaded_child_object_format
1885 }
1886
1887 pub fn enable_jwk_consensus_updates(&self) -> bool {
1888 let ret = self.feature_flags.enable_jwk_consensus_updates;
1889 if ret {
1890 assert!(self.feature_flags.end_of_epoch_transaction_supported);
1892 }
1893 ret
1894 }
1895
1896 pub fn simple_conservation_checks(&self) -> bool {
1897 self.feature_flags.simple_conservation_checks
1898 }
1899
1900 pub fn loaded_child_object_format_type(&self) -> bool {
1901 self.feature_flags.loaded_child_object_format_type
1902 }
1903
1904 pub fn end_of_epoch_transaction_supported(&self) -> bool {
1905 let ret = self.feature_flags.end_of_epoch_transaction_supported;
1906 if !ret {
1907 assert!(!self.feature_flags.enable_jwk_consensus_updates);
1909 }
1910 ret
1911 }
1912
1913 pub fn recompute_has_public_transfer_in_execution(&self) -> bool {
1914 self.feature_flags
1915 .recompute_has_public_transfer_in_execution
1916 }
1917
1918 pub fn create_authenticator_state_in_genesis(&self) -> bool {
1920 self.enable_jwk_consensus_updates()
1921 }
1922
1923 pub fn random_beacon(&self) -> bool {
1924 self.feature_flags.random_beacon
1925 }
1926
1927 pub fn dkg_version(&self) -> u64 {
1928 self.random_beacon_dkg_version.unwrap_or(1)
1930 }
1931
1932 pub fn enable_bridge(&self) -> bool {
1933 let ret = self.feature_flags.bridge;
1934 if ret {
1935 assert!(self.feature_flags.end_of_epoch_transaction_supported);
1937 }
1938 ret
1939 }
1940
1941 pub fn should_try_to_finalize_bridge_committee(&self) -> bool {
1942 if !self.enable_bridge() {
1943 return false;
1944 }
1945 self.bridge_should_try_to_finalize_committee.unwrap_or(true)
1947 }
1948
1949 pub fn enable_effects_v2(&self) -> bool {
1950 self.feature_flags.enable_effects_v2
1951 }
1952
1953 pub fn narwhal_certificate_v2(&self) -> bool {
1954 self.feature_flags.narwhal_certificate_v2
1955 }
1956
1957 pub fn verify_legacy_zklogin_address(&self) -> bool {
1958 self.feature_flags.verify_legacy_zklogin_address
1959 }
1960
1961 pub fn accept_zklogin_in_multisig(&self) -> bool {
1962 self.feature_flags.accept_zklogin_in_multisig
1963 }
1964
1965 pub fn accept_passkey_in_multisig(&self) -> bool {
1966 self.feature_flags.accept_passkey_in_multisig
1967 }
1968
1969 pub fn zklogin_max_epoch_upper_bound_delta(&self) -> Option<u64> {
1970 self.feature_flags.zklogin_max_epoch_upper_bound_delta
1971 }
1972
1973 pub fn throughput_aware_consensus_submission(&self) -> bool {
1974 self.feature_flags.throughput_aware_consensus_submission
1975 }
1976
1977 pub fn include_consensus_digest_in_prologue(&self) -> bool {
1978 self.feature_flags.include_consensus_digest_in_prologue
1979 }
1980
1981 pub fn record_consensus_determined_version_assignments_in_prologue(&self) -> bool {
1982 self.feature_flags
1983 .record_consensus_determined_version_assignments_in_prologue
1984 }
1985
1986 pub fn record_additional_state_digest_in_prologue(&self) -> bool {
1987 self.feature_flags
1988 .record_additional_state_digest_in_prologue
1989 }
1990
1991 pub fn record_consensus_determined_version_assignments_in_prologue_v2(&self) -> bool {
1992 self.feature_flags
1993 .record_consensus_determined_version_assignments_in_prologue_v2
1994 }
1995
1996 pub fn prepend_prologue_tx_in_consensus_commit_in_checkpoints(&self) -> bool {
1997 self.feature_flags
1998 .prepend_prologue_tx_in_consensus_commit_in_checkpoints
1999 }
2000
2001 pub fn hardened_otw_check(&self) -> bool {
2002 self.feature_flags.hardened_otw_check
2003 }
2004
2005 pub fn enable_poseidon(&self) -> bool {
2006 self.feature_flags.enable_poseidon
2007 }
2008
2009 pub fn enable_coin_deny_list_v1(&self) -> bool {
2010 self.feature_flags.enable_coin_deny_list
2011 }
2012
2013 pub fn enable_accumulators(&self) -> bool {
2014 self.feature_flags.enable_accumulators
2015 }
2016
2017 pub fn create_root_accumulator_object(&self) -> bool {
2018 self.feature_flags.create_root_accumulator_object
2019 }
2020
2021 pub fn enable_address_balance_gas_payments(&self) -> bool {
2022 self.feature_flags.enable_address_balance_gas_payments
2023 }
2024
2025 pub fn enable_authenticated_event_streams(&self) -> bool {
2026 self.feature_flags.enable_authenticated_event_streams && self.enable_accumulators()
2027 }
2028
2029 pub fn enable_non_exclusive_writes(&self) -> bool {
2030 self.feature_flags.enable_non_exclusive_writes
2031 }
2032
2033 pub fn enable_coin_registry(&self) -> bool {
2034 self.feature_flags.enable_coin_registry
2035 }
2036
2037 pub fn enable_display_registry(&self) -> bool {
2038 self.feature_flags.enable_display_registry
2039 }
2040
2041 pub fn enable_coin_deny_list_v2(&self) -> bool {
2042 self.feature_flags.enable_coin_deny_list_v2
2043 }
2044
2045 pub fn enable_group_ops_native_functions(&self) -> bool {
2046 self.feature_flags.enable_group_ops_native_functions
2047 }
2048
2049 pub fn enable_group_ops_native_function_msm(&self) -> bool {
2050 self.feature_flags.enable_group_ops_native_function_msm
2051 }
2052
2053 pub fn reject_mutable_random_on_entry_functions(&self) -> bool {
2054 self.feature_flags.reject_mutable_random_on_entry_functions
2055 }
2056
2057 pub fn per_object_congestion_control_mode(&self) -> PerObjectCongestionControlMode {
2058 self.feature_flags.per_object_congestion_control_mode
2059 }
2060
2061 pub fn consensus_choice(&self) -> ConsensusChoice {
2062 self.feature_flags.consensus_choice
2063 }
2064
2065 pub fn consensus_network(&self) -> ConsensusNetwork {
2066 self.feature_flags.consensus_network
2067 }
2068
2069 pub fn correct_gas_payment_limit_check(&self) -> bool {
2070 self.feature_flags.correct_gas_payment_limit_check
2071 }
2072
2073 pub fn reshare_at_same_initial_version(&self) -> bool {
2074 self.feature_flags.reshare_at_same_initial_version
2075 }
2076
2077 pub fn resolve_abort_locations_to_package_id(&self) -> bool {
2078 self.feature_flags.resolve_abort_locations_to_package_id
2079 }
2080
2081 pub fn mysticeti_use_committed_subdag_digest(&self) -> bool {
2082 self.feature_flags.mysticeti_use_committed_subdag_digest
2083 }
2084
2085 pub fn enable_vdf(&self) -> bool {
2086 self.feature_flags.enable_vdf
2087 }
2088
2089 pub fn fresh_vm_on_framework_upgrade(&self) -> bool {
2090 self.feature_flags.fresh_vm_on_framework_upgrade
2091 }
2092
2093 pub fn mysticeti_num_leaders_per_round(&self) -> Option<usize> {
2094 self.feature_flags.mysticeti_num_leaders_per_round
2095 }
2096
2097 pub fn soft_bundle(&self) -> bool {
2098 self.feature_flags.soft_bundle
2099 }
2100
2101 pub fn passkey_auth(&self) -> bool {
2102 self.feature_flags.passkey_auth
2103 }
2104
2105 pub fn authority_capabilities_v2(&self) -> bool {
2106 self.feature_flags.authority_capabilities_v2
2107 }
2108
2109 pub fn max_transaction_size_bytes(&self) -> u64 {
2110 self.consensus_max_transaction_size_bytes
2112 .unwrap_or(256 * 1024)
2113 }
2114
2115 pub fn max_transactions_in_block_bytes(&self) -> u64 {
2116 if cfg!(msim) {
2117 256 * 1024
2118 } else {
2119 self.consensus_max_transactions_in_block_bytes
2120 .unwrap_or(512 * 1024)
2121 }
2122 }
2123
2124 pub fn max_num_transactions_in_block(&self) -> u64 {
2125 if cfg!(msim) {
2126 8
2127 } else {
2128 self.consensus_max_num_transactions_in_block.unwrap_or(512)
2129 }
2130 }
2131
2132 pub fn rethrow_serialization_type_layout_errors(&self) -> bool {
2133 self.feature_flags.rethrow_serialization_type_layout_errors
2134 }
2135
2136 pub fn consensus_distributed_vote_scoring_strategy(&self) -> bool {
2137 self.feature_flags
2138 .consensus_distributed_vote_scoring_strategy
2139 }
2140
2141 pub fn consensus_round_prober(&self) -> bool {
2142 self.feature_flags.consensus_round_prober
2143 }
2144
2145 pub fn validate_identifier_inputs(&self) -> bool {
2146 self.feature_flags.validate_identifier_inputs
2147 }
2148
2149 pub fn gc_depth(&self) -> u32 {
2150 self.consensus_gc_depth.unwrap_or(0)
2151 }
2152
2153 pub fn mysticeti_fastpath(&self) -> bool {
2154 if let Some(enabled) = is_mysticeti_fpc_enabled_in_env() {
2155 return enabled;
2156 }
2157 self.feature_flags.mysticeti_fastpath
2158 }
2159
2160 pub fn relocate_event_module(&self) -> bool {
2161 self.feature_flags.relocate_event_module
2162 }
2163
2164 pub fn uncompressed_g1_group_elements(&self) -> bool {
2165 self.feature_flags.uncompressed_g1_group_elements
2166 }
2167
2168 pub fn disallow_new_modules_in_deps_only_packages(&self) -> bool {
2169 self.feature_flags
2170 .disallow_new_modules_in_deps_only_packages
2171 }
2172
2173 pub fn consensus_smart_ancestor_selection(&self) -> bool {
2174 self.feature_flags.consensus_smart_ancestor_selection
2175 }
2176
2177 pub fn consensus_round_prober_probe_accepted_rounds(&self) -> bool {
2178 self.feature_flags
2179 .consensus_round_prober_probe_accepted_rounds
2180 }
2181
2182 pub fn native_charging_v2(&self) -> bool {
2183 self.feature_flags.native_charging_v2
2184 }
2185
2186 pub fn consensus_linearize_subdag_v2(&self) -> bool {
2187 let res = self.feature_flags.consensus_linearize_subdag_v2;
2188 assert!(
2189 !res || self.gc_depth() > 0,
2190 "The consensus linearize sub dag V2 requires GC to be enabled"
2191 );
2192 res
2193 }
2194
2195 pub fn consensus_median_based_commit_timestamp(&self) -> bool {
2196 let res = self.feature_flags.consensus_median_based_commit_timestamp;
2197 assert!(
2198 !res || self.gc_depth() > 0,
2199 "The consensus median based commit timestamp requires GC to be enabled"
2200 );
2201 res
2202 }
2203
2204 pub fn consensus_batched_block_sync(&self) -> bool {
2205 self.feature_flags.consensus_batched_block_sync
2206 }
2207
2208 pub fn convert_type_argument_error(&self) -> bool {
2209 self.feature_flags.convert_type_argument_error
2210 }
2211
2212 pub fn variant_nodes(&self) -> bool {
2213 self.feature_flags.variant_nodes
2214 }
2215
2216 pub fn consensus_zstd_compression(&self) -> bool {
2217 self.feature_flags.consensus_zstd_compression
2218 }
2219
2220 pub fn enable_nitro_attestation(&self) -> bool {
2221 self.feature_flags.enable_nitro_attestation
2222 }
2223
2224 pub fn enable_nitro_attestation_upgraded_parsing(&self) -> bool {
2225 self.feature_flags.enable_nitro_attestation_upgraded_parsing
2226 }
2227
2228 pub fn get_consensus_commit_rate_estimation_window_size(&self) -> u32 {
2229 self.consensus_commit_rate_estimation_window_size
2230 .unwrap_or(0)
2231 }
2232
2233 pub fn consensus_num_requested_prior_commits_at_startup(&self) -> u32 {
2234 let window_size = self.get_consensus_commit_rate_estimation_window_size();
2238 assert!(window_size == 0 || self.record_additional_state_digest_in_prologue());
2240 window_size
2241 }
2242
2243 pub fn minimize_child_object_mutations(&self) -> bool {
2244 self.feature_flags.minimize_child_object_mutations
2245 }
2246
2247 pub fn move_native_context(&self) -> bool {
2248 self.feature_flags.move_native_context
2249 }
2250
2251 pub fn normalize_ptb_arguments(&self) -> bool {
2252 self.feature_flags.normalize_ptb_arguments
2253 }
2254
2255 pub fn enforce_checkpoint_timestamp_monotonicity(&self) -> bool {
2256 self.feature_flags.enforce_checkpoint_timestamp_monotonicity
2257 }
2258
2259 pub fn max_ptb_value_size_v2(&self) -> bool {
2260 self.feature_flags.max_ptb_value_size_v2
2261 }
2262
2263 pub fn resolve_type_input_ids_to_defining_id(&self) -> bool {
2264 self.feature_flags.resolve_type_input_ids_to_defining_id
2265 }
2266
2267 pub fn enable_party_transfer(&self) -> bool {
2268 self.feature_flags.enable_party_transfer
2269 }
2270
2271 pub fn allow_unbounded_system_objects(&self) -> bool {
2272 self.feature_flags.allow_unbounded_system_objects
2273 }
2274
2275 pub fn type_tags_in_object_runtime(&self) -> bool {
2276 self.feature_flags.type_tags_in_object_runtime
2277 }
2278
2279 pub fn enable_ptb_execution_v2(&self) -> bool {
2280 self.feature_flags.enable_ptb_execution_v2
2281 }
2282
2283 pub fn better_adapter_type_resolution_errors(&self) -> bool {
2284 self.feature_flags.better_adapter_type_resolution_errors
2285 }
2286
2287 pub fn record_time_estimate_processed(&self) -> bool {
2288 self.feature_flags.record_time_estimate_processed
2289 }
2290
2291 pub fn ignore_execution_time_observations_after_certs_closed(&self) -> bool {
2292 self.feature_flags
2293 .ignore_execution_time_observations_after_certs_closed
2294 }
2295
2296 pub fn dependency_linkage_error(&self) -> bool {
2297 self.feature_flags.dependency_linkage_error
2298 }
2299
2300 pub fn additional_multisig_checks(&self) -> bool {
2301 self.feature_flags.additional_multisig_checks
2302 }
2303
2304 pub fn debug_fatal_on_move_invariant_violation(&self) -> bool {
2305 self.feature_flags.debug_fatal_on_move_invariant_violation
2306 }
2307
2308 pub fn allow_private_accumulator_entrypoints(&self) -> bool {
2309 self.feature_flags.allow_private_accumulator_entrypoints
2310 }
2311
2312 pub fn additional_consensus_digest_indirect_state(&self) -> bool {
2313 self.feature_flags
2314 .additional_consensus_digest_indirect_state
2315 }
2316
2317 pub fn check_for_init_during_upgrade(&self) -> bool {
2318 self.feature_flags.check_for_init_during_upgrade
2319 }
2320
2321 pub fn per_command_shared_object_transfer_rules(&self) -> bool {
2322 self.feature_flags.per_command_shared_object_transfer_rules
2323 }
2324
2325 pub fn consensus_checkpoint_signature_key_includes_digest(&self) -> bool {
2326 self.feature_flags
2327 .consensus_checkpoint_signature_key_includes_digest
2328 }
2329
2330 pub fn include_checkpoint_artifacts_digest_in_summary(&self) -> bool {
2331 self.feature_flags
2332 .include_checkpoint_artifacts_digest_in_summary
2333 }
2334
2335 pub fn use_mfp_txns_in_load_initial_object_debts(&self) -> bool {
2336 self.feature_flags.use_mfp_txns_in_load_initial_object_debts
2337 }
2338
2339 pub fn cancel_for_failed_dkg_early(&self) -> bool {
2340 self.feature_flags.cancel_for_failed_dkg_early
2341 }
2342
2343 pub fn abstract_size_in_object_runtime(&self) -> bool {
2344 self.feature_flags.abstract_size_in_object_runtime
2345 }
2346
2347 pub fn object_runtime_charge_cache_load_gas(&self) -> bool {
2348 self.feature_flags.object_runtime_charge_cache_load_gas
2349 }
2350
2351 pub fn additional_borrow_checks(&self) -> bool {
2352 self.feature_flags.additional_borrow_checks
2353 }
2354
2355 pub fn use_new_commit_handler(&self) -> bool {
2356 self.feature_flags.use_new_commit_handler
2357 }
2358
2359 pub fn better_loader_errors(&self) -> bool {
2360 self.feature_flags.better_loader_errors
2361 }
2362
2363 pub fn generate_df_type_layouts(&self) -> bool {
2364 self.feature_flags.generate_df_type_layouts
2365 }
2366
2367 pub fn allow_references_in_ptbs(&self) -> bool {
2368 self.feature_flags.allow_references_in_ptbs
2369 }
2370
2371 pub fn private_generics_verifier_v2(&self) -> bool {
2372 self.feature_flags.private_generics_verifier_v2
2373 }
2374
2375 pub fn deprecate_global_storage_ops_during_deserialization(&self) -> bool {
2376 self.feature_flags
2377 .deprecate_global_storage_ops_during_deserialization
2378 }
2379}
2380
2381#[cfg(not(msim))]
2382static POISON_VERSION_METHODS: AtomicBool = AtomicBool::new(false);
2383
2384#[cfg(msim)]
2386thread_local! {
2387 static POISON_VERSION_METHODS: AtomicBool = AtomicBool::new(false);
2388}
2389
2390impl ProtocolConfig {
2392 pub fn get_for_version(version: ProtocolVersion, chain: Chain) -> Self {
2394 assert!(
2396 version >= ProtocolVersion::MIN,
2397 "Network protocol version is {:?}, but the minimum supported version by the binary is {:?}. Please upgrade the binary.",
2398 version,
2399 ProtocolVersion::MIN.0,
2400 );
2401 assert!(
2402 version <= ProtocolVersion::MAX_ALLOWED,
2403 "Network protocol version is {:?}, but the maximum supported version by the binary is {:?}. Please upgrade the binary.",
2404 version,
2405 ProtocolVersion::MAX_ALLOWED.0,
2406 );
2407
2408 let mut ret = Self::get_for_version_impl(version, chain);
2409 ret.version = version;
2410
2411 ret = CONFIG_OVERRIDE.with(|ovr| {
2412 if let Some(override_fn) = &*ovr.borrow() {
2413 warn!(
2414 "overriding ProtocolConfig settings with custom settings (you should not see this log outside of tests)"
2415 );
2416 override_fn(version, ret)
2417 } else {
2418 ret
2419 }
2420 });
2421
2422 if std::env::var("SUI_PROTOCOL_CONFIG_OVERRIDE_ENABLE").is_ok() {
2423 warn!(
2424 "overriding ProtocolConfig settings with custom settings; this may break non-local networks"
2425 );
2426 let overrides: ProtocolConfigOptional =
2427 serde_env::from_env_with_prefix("SUI_PROTOCOL_CONFIG_OVERRIDE")
2428 .expect("failed to parse ProtocolConfig override env variables");
2429 overrides.apply_to(&mut ret);
2430 }
2431
2432 ret
2433 }
2434
2435 pub fn get_for_version_if_supported(version: ProtocolVersion, chain: Chain) -> Option<Self> {
2438 if version.0 >= ProtocolVersion::MIN.0 && version.0 <= ProtocolVersion::MAX_ALLOWED.0 {
2439 let mut ret = Self::get_for_version_impl(version, chain);
2440 ret.version = version;
2441 Some(ret)
2442 } else {
2443 None
2444 }
2445 }
2446
2447 #[cfg(not(msim))]
2448 pub fn poison_get_for_min_version() {
2449 POISON_VERSION_METHODS.store(true, Ordering::Relaxed);
2450 }
2451
2452 #[cfg(not(msim))]
2453 fn load_poison_get_for_min_version() -> bool {
2454 POISON_VERSION_METHODS.load(Ordering::Relaxed)
2455 }
2456
2457 #[cfg(msim)]
2458 pub fn poison_get_for_min_version() {
2459 POISON_VERSION_METHODS.with(|p| p.store(true, Ordering::Relaxed));
2460 }
2461
2462 #[cfg(msim)]
2463 fn load_poison_get_for_min_version() -> bool {
2464 POISON_VERSION_METHODS.with(|p| p.load(Ordering::Relaxed))
2465 }
2466
2467 pub fn get_for_min_version() -> Self {
2470 if Self::load_poison_get_for_min_version() {
2471 panic!("get_for_min_version called on validator");
2472 }
2473 ProtocolConfig::get_for_version(ProtocolVersion::MIN, Chain::Unknown)
2474 }
2475
2476 #[allow(non_snake_case)]
2486 pub fn get_for_max_version_UNSAFE() -> Self {
2487 if Self::load_poison_get_for_min_version() {
2488 panic!("get_for_max_version_UNSAFE called on validator");
2489 }
2490 ProtocolConfig::get_for_version(ProtocolVersion::MAX, Chain::Unknown)
2491 }
2492
2493 fn get_for_version_impl(version: ProtocolVersion, chain: Chain) -> Self {
2494 #[cfg(msim)]
2495 {
2496 if version == ProtocolVersion::MAX_ALLOWED {
2498 let mut config = Self::get_for_version_impl(version - 1, Chain::Unknown);
2499 config.base_tx_cost_fixed = Some(config.base_tx_cost_fixed() + 1000);
2500 return config;
2501 }
2502 }
2503
2504 let mut cfg = Self {
2507 version,
2509
2510 feature_flags: Default::default(),
2512
2513 max_tx_size_bytes: Some(128 * 1024),
2514 max_input_objects: Some(2048),
2516 max_serialized_tx_effects_size_bytes: Some(512 * 1024),
2517 max_serialized_tx_effects_size_bytes_system_tx: Some(512 * 1024 * 16),
2518 max_gas_payment_objects: Some(256),
2519 max_modules_in_publish: Some(128),
2520 max_package_dependencies: None,
2521 max_arguments: Some(512),
2522 max_type_arguments: Some(16),
2523 max_type_argument_depth: Some(16),
2524 max_pure_argument_size: Some(16 * 1024),
2525 max_programmable_tx_commands: Some(1024),
2526 move_binary_format_version: Some(6),
2527 min_move_binary_format_version: None,
2528 binary_module_handles: None,
2529 binary_struct_handles: None,
2530 binary_function_handles: None,
2531 binary_function_instantiations: None,
2532 binary_signatures: None,
2533 binary_constant_pool: None,
2534 binary_identifiers: None,
2535 binary_address_identifiers: None,
2536 binary_struct_defs: None,
2537 binary_struct_def_instantiations: None,
2538 binary_function_defs: None,
2539 binary_field_handles: None,
2540 binary_field_instantiations: None,
2541 binary_friend_decls: None,
2542 binary_enum_defs: None,
2543 binary_enum_def_instantiations: None,
2544 binary_variant_handles: None,
2545 binary_variant_instantiation_handles: None,
2546 max_move_object_size: Some(250 * 1024),
2547 max_move_package_size: Some(100 * 1024),
2548 max_publish_or_upgrade_per_ptb: None,
2549 max_tx_gas: Some(10_000_000_000),
2550 max_gas_price: Some(100_000),
2551 max_gas_price_rgp_factor_for_aborted_transactions: None,
2552 max_gas_computation_bucket: Some(5_000_000),
2553 max_loop_depth: Some(5),
2554 max_generic_instantiation_length: Some(32),
2555 max_function_parameters: Some(128),
2556 max_basic_blocks: Some(1024),
2557 max_value_stack_size: Some(1024),
2558 max_type_nodes: Some(256),
2559 max_push_size: Some(10000),
2560 max_struct_definitions: Some(200),
2561 max_function_definitions: Some(1000),
2562 max_fields_in_struct: Some(32),
2563 max_dependency_depth: Some(100),
2564 max_num_event_emit: Some(256),
2565 max_num_new_move_object_ids: Some(2048),
2566 max_num_new_move_object_ids_system_tx: Some(2048 * 16),
2567 max_num_deleted_move_object_ids: Some(2048),
2568 max_num_deleted_move_object_ids_system_tx: Some(2048 * 16),
2569 max_num_transferred_move_object_ids: Some(2048),
2570 max_num_transferred_move_object_ids_system_tx: Some(2048 * 16),
2571 max_event_emit_size: Some(250 * 1024),
2572 max_move_vector_len: Some(256 * 1024),
2573 max_type_to_layout_nodes: None,
2574 max_ptb_value_size: None,
2575
2576 max_back_edges_per_function: Some(10_000),
2577 max_back_edges_per_module: Some(10_000),
2578 max_verifier_meter_ticks_per_function: Some(6_000_000),
2579 max_meter_ticks_per_module: Some(6_000_000),
2580 max_meter_ticks_per_package: None,
2581
2582 object_runtime_max_num_cached_objects: Some(1000),
2583 object_runtime_max_num_cached_objects_system_tx: Some(1000 * 16),
2584 object_runtime_max_num_store_entries: Some(1000),
2585 object_runtime_max_num_store_entries_system_tx: Some(1000 * 16),
2586 base_tx_cost_fixed: Some(110_000),
2587 package_publish_cost_fixed: Some(1_000),
2588 base_tx_cost_per_byte: Some(0),
2589 package_publish_cost_per_byte: Some(80),
2590 obj_access_cost_read_per_byte: Some(15),
2591 obj_access_cost_mutate_per_byte: Some(40),
2592 obj_access_cost_delete_per_byte: Some(40),
2593 obj_access_cost_verify_per_byte: Some(200),
2594 obj_data_cost_refundable: Some(100),
2595 obj_metadata_cost_non_refundable: Some(50),
2596 gas_model_version: Some(1),
2597 storage_rebate_rate: Some(9900),
2598 storage_fund_reinvest_rate: Some(500),
2599 reward_slashing_rate: Some(5000),
2600 storage_gas_price: Some(1),
2601 max_transactions_per_checkpoint: Some(10_000),
2602 max_checkpoint_size_bytes: Some(30 * 1024 * 1024),
2603
2604 buffer_stake_for_protocol_upgrade_bps: Some(0),
2607
2608 address_from_bytes_cost_base: Some(52),
2612 address_to_u256_cost_base: Some(52),
2614 address_from_u256_cost_base: Some(52),
2616
2617 config_read_setting_impl_cost_base: None,
2620 config_read_setting_impl_cost_per_byte: None,
2621
2622 dynamic_field_hash_type_and_key_cost_base: Some(100),
2625 dynamic_field_hash_type_and_key_type_cost_per_byte: Some(2),
2626 dynamic_field_hash_type_and_key_value_cost_per_byte: Some(2),
2627 dynamic_field_hash_type_and_key_type_tag_cost_per_byte: Some(2),
2628 dynamic_field_add_child_object_cost_base: Some(100),
2630 dynamic_field_add_child_object_type_cost_per_byte: Some(10),
2631 dynamic_field_add_child_object_value_cost_per_byte: Some(10),
2632 dynamic_field_add_child_object_struct_tag_cost_per_byte: Some(10),
2633 dynamic_field_borrow_child_object_cost_base: Some(100),
2635 dynamic_field_borrow_child_object_child_ref_cost_per_byte: Some(10),
2636 dynamic_field_borrow_child_object_type_cost_per_byte: Some(10),
2637 dynamic_field_remove_child_object_cost_base: Some(100),
2639 dynamic_field_remove_child_object_child_cost_per_byte: Some(2),
2640 dynamic_field_remove_child_object_type_cost_per_byte: Some(2),
2641 dynamic_field_has_child_object_cost_base: Some(100),
2643 dynamic_field_has_child_object_with_ty_cost_base: Some(100),
2645 dynamic_field_has_child_object_with_ty_type_cost_per_byte: Some(2),
2646 dynamic_field_has_child_object_with_ty_type_tag_cost_per_byte: Some(2),
2647
2648 event_emit_cost_base: Some(52),
2651 event_emit_value_size_derivation_cost_per_byte: Some(2),
2652 event_emit_tag_size_derivation_cost_per_byte: Some(5),
2653 event_emit_output_cost_per_byte: Some(10),
2654 event_emit_auth_stream_cost: None,
2655
2656 object_borrow_uid_cost_base: Some(52),
2659 object_delete_impl_cost_base: Some(52),
2661 object_record_new_uid_cost_base: Some(52),
2663
2664 transfer_transfer_internal_cost_base: Some(52),
2667 transfer_party_transfer_internal_cost_base: None,
2669 transfer_freeze_object_cost_base: Some(52),
2671 transfer_share_object_cost_base: Some(52),
2673 transfer_receive_object_cost_base: None,
2674
2675 tx_context_derive_id_cost_base: Some(52),
2678 tx_context_fresh_id_cost_base: None,
2679 tx_context_sender_cost_base: None,
2680 tx_context_epoch_cost_base: None,
2681 tx_context_epoch_timestamp_ms_cost_base: None,
2682 tx_context_sponsor_cost_base: None,
2683 tx_context_rgp_cost_base: None,
2684 tx_context_gas_price_cost_base: None,
2685 tx_context_gas_budget_cost_base: None,
2686 tx_context_ids_created_cost_base: None,
2687 tx_context_replace_cost_base: None,
2688
2689 types_is_one_time_witness_cost_base: Some(52),
2692 types_is_one_time_witness_type_tag_cost_per_byte: Some(2),
2693 types_is_one_time_witness_type_cost_per_byte: Some(2),
2694
2695 validator_validate_metadata_cost_base: Some(52),
2698 validator_validate_metadata_data_cost_per_byte: Some(2),
2699
2700 crypto_invalid_arguments_cost: Some(100),
2702 bls12381_bls12381_min_sig_verify_cost_base: Some(52),
2704 bls12381_bls12381_min_sig_verify_msg_cost_per_byte: Some(2),
2705 bls12381_bls12381_min_sig_verify_msg_cost_per_block: Some(2),
2706
2707 bls12381_bls12381_min_pk_verify_cost_base: Some(52),
2709 bls12381_bls12381_min_pk_verify_msg_cost_per_byte: Some(2),
2710 bls12381_bls12381_min_pk_verify_msg_cost_per_block: Some(2),
2711
2712 ecdsa_k1_ecrecover_keccak256_cost_base: Some(52),
2714 ecdsa_k1_ecrecover_keccak256_msg_cost_per_byte: Some(2),
2715 ecdsa_k1_ecrecover_keccak256_msg_cost_per_block: Some(2),
2716 ecdsa_k1_ecrecover_sha256_cost_base: Some(52),
2717 ecdsa_k1_ecrecover_sha256_msg_cost_per_byte: Some(2),
2718 ecdsa_k1_ecrecover_sha256_msg_cost_per_block: Some(2),
2719
2720 ecdsa_k1_decompress_pubkey_cost_base: Some(52),
2722
2723 ecdsa_k1_secp256k1_verify_keccak256_cost_base: Some(52),
2725 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_byte: Some(2),
2726 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_block: Some(2),
2727 ecdsa_k1_secp256k1_verify_sha256_cost_base: Some(52),
2728 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_byte: Some(2),
2729 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_block: Some(2),
2730
2731 ecdsa_r1_ecrecover_keccak256_cost_base: Some(52),
2733 ecdsa_r1_ecrecover_keccak256_msg_cost_per_byte: Some(2),
2734 ecdsa_r1_ecrecover_keccak256_msg_cost_per_block: Some(2),
2735 ecdsa_r1_ecrecover_sha256_cost_base: Some(52),
2736 ecdsa_r1_ecrecover_sha256_msg_cost_per_byte: Some(2),
2737 ecdsa_r1_ecrecover_sha256_msg_cost_per_block: Some(2),
2738
2739 ecdsa_r1_secp256r1_verify_keccak256_cost_base: Some(52),
2741 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_byte: Some(2),
2742 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_block: Some(2),
2743 ecdsa_r1_secp256r1_verify_sha256_cost_base: Some(52),
2744 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_byte: Some(2),
2745 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_block: Some(2),
2746
2747 ecvrf_ecvrf_verify_cost_base: Some(52),
2749 ecvrf_ecvrf_verify_alpha_string_cost_per_byte: Some(2),
2750 ecvrf_ecvrf_verify_alpha_string_cost_per_block: Some(2),
2751
2752 ed25519_ed25519_verify_cost_base: Some(52),
2754 ed25519_ed25519_verify_msg_cost_per_byte: Some(2),
2755 ed25519_ed25519_verify_msg_cost_per_block: Some(2),
2756
2757 groth16_prepare_verifying_key_bls12381_cost_base: Some(52),
2759 groth16_prepare_verifying_key_bn254_cost_base: Some(52),
2760
2761 groth16_verify_groth16_proof_internal_bls12381_cost_base: Some(52),
2763 groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input: Some(2),
2764 groth16_verify_groth16_proof_internal_bn254_cost_base: Some(52),
2765 groth16_verify_groth16_proof_internal_bn254_cost_per_public_input: Some(2),
2766 groth16_verify_groth16_proof_internal_public_input_cost_per_byte: Some(2),
2767
2768 hash_blake2b256_cost_base: Some(52),
2770 hash_blake2b256_data_cost_per_byte: Some(2),
2771 hash_blake2b256_data_cost_per_block: Some(2),
2772 hash_keccak256_cost_base: Some(52),
2774 hash_keccak256_data_cost_per_byte: Some(2),
2775 hash_keccak256_data_cost_per_block: Some(2),
2776
2777 poseidon_bn254_cost_base: None,
2778 poseidon_bn254_cost_per_block: None,
2779
2780 hmac_hmac_sha3_256_cost_base: Some(52),
2782 hmac_hmac_sha3_256_input_cost_per_byte: Some(2),
2783 hmac_hmac_sha3_256_input_cost_per_block: Some(2),
2784
2785 group_ops_bls12381_decode_scalar_cost: None,
2787 group_ops_bls12381_decode_g1_cost: None,
2788 group_ops_bls12381_decode_g2_cost: None,
2789 group_ops_bls12381_decode_gt_cost: None,
2790 group_ops_bls12381_scalar_add_cost: None,
2791 group_ops_bls12381_g1_add_cost: None,
2792 group_ops_bls12381_g2_add_cost: None,
2793 group_ops_bls12381_gt_add_cost: None,
2794 group_ops_bls12381_scalar_sub_cost: None,
2795 group_ops_bls12381_g1_sub_cost: None,
2796 group_ops_bls12381_g2_sub_cost: None,
2797 group_ops_bls12381_gt_sub_cost: None,
2798 group_ops_bls12381_scalar_mul_cost: None,
2799 group_ops_bls12381_g1_mul_cost: None,
2800 group_ops_bls12381_g2_mul_cost: None,
2801 group_ops_bls12381_gt_mul_cost: None,
2802 group_ops_bls12381_scalar_div_cost: None,
2803 group_ops_bls12381_g1_div_cost: None,
2804 group_ops_bls12381_g2_div_cost: None,
2805 group_ops_bls12381_gt_div_cost: None,
2806 group_ops_bls12381_g1_hash_to_base_cost: None,
2807 group_ops_bls12381_g2_hash_to_base_cost: None,
2808 group_ops_bls12381_g1_hash_to_cost_per_byte: None,
2809 group_ops_bls12381_g2_hash_to_cost_per_byte: None,
2810 group_ops_bls12381_g1_msm_base_cost: None,
2811 group_ops_bls12381_g2_msm_base_cost: None,
2812 group_ops_bls12381_g1_msm_base_cost_per_input: None,
2813 group_ops_bls12381_g2_msm_base_cost_per_input: None,
2814 group_ops_bls12381_msm_max_len: None,
2815 group_ops_bls12381_pairing_cost: None,
2816 group_ops_bls12381_g1_to_uncompressed_g1_cost: None,
2817 group_ops_bls12381_uncompressed_g1_to_g1_cost: None,
2818 group_ops_bls12381_uncompressed_g1_sum_base_cost: None,
2819 group_ops_bls12381_uncompressed_g1_sum_cost_per_term: None,
2820 group_ops_bls12381_uncompressed_g1_sum_max_terms: None,
2821
2822 check_zklogin_id_cost_base: None,
2824 check_zklogin_issuer_cost_base: None,
2826
2827 vdf_verify_vdf_cost: None,
2828 vdf_hash_to_input_cost: None,
2829
2830 nitro_attestation_parse_base_cost: None,
2832 nitro_attestation_parse_cost_per_byte: None,
2833 nitro_attestation_verify_base_cost: None,
2834 nitro_attestation_verify_cost_per_cert: None,
2835
2836 bcs_per_byte_serialized_cost: None,
2837 bcs_legacy_min_output_size_cost: None,
2838 bcs_failure_cost: None,
2839 hash_sha2_256_base_cost: None,
2840 hash_sha2_256_per_byte_cost: None,
2841 hash_sha2_256_legacy_min_input_len_cost: None,
2842 hash_sha3_256_base_cost: None,
2843 hash_sha3_256_per_byte_cost: None,
2844 hash_sha3_256_legacy_min_input_len_cost: None,
2845 type_name_get_base_cost: None,
2846 type_name_get_per_byte_cost: None,
2847 type_name_id_base_cost: None,
2848 string_check_utf8_base_cost: None,
2849 string_check_utf8_per_byte_cost: None,
2850 string_is_char_boundary_base_cost: None,
2851 string_sub_string_base_cost: None,
2852 string_sub_string_per_byte_cost: None,
2853 string_index_of_base_cost: None,
2854 string_index_of_per_byte_pattern_cost: None,
2855 string_index_of_per_byte_searched_cost: None,
2856 vector_empty_base_cost: None,
2857 vector_length_base_cost: None,
2858 vector_push_back_base_cost: None,
2859 vector_push_back_legacy_per_abstract_memory_unit_cost: None,
2860 vector_borrow_base_cost: None,
2861 vector_pop_back_base_cost: None,
2862 vector_destroy_empty_base_cost: None,
2863 vector_swap_base_cost: None,
2864 debug_print_base_cost: None,
2865 debug_print_stack_trace_base_cost: None,
2866
2867 max_size_written_objects: None,
2868 max_size_written_objects_system_tx: None,
2869
2870 max_move_identifier_len: None,
2877 max_move_value_depth: None,
2878 max_move_enum_variants: None,
2879
2880 gas_rounding_step: None,
2881
2882 execution_version: None,
2883
2884 max_event_emit_size_total: None,
2885
2886 consensus_bad_nodes_stake_threshold: None,
2887
2888 max_jwk_votes_per_validator_per_epoch: None,
2889
2890 max_age_of_jwk_in_epochs: None,
2891
2892 random_beacon_reduction_allowed_delta: None,
2893
2894 random_beacon_reduction_lower_bound: None,
2895
2896 random_beacon_dkg_timeout_round: None,
2897
2898 random_beacon_min_round_interval_ms: None,
2899
2900 random_beacon_dkg_version: None,
2901
2902 consensus_max_transaction_size_bytes: None,
2903
2904 consensus_max_transactions_in_block_bytes: None,
2905
2906 consensus_max_num_transactions_in_block: None,
2907
2908 consensus_voting_rounds: None,
2909
2910 max_accumulated_txn_cost_per_object_in_narwhal_commit: None,
2911
2912 max_deferral_rounds_for_congestion_control: None,
2913
2914 max_txn_cost_overage_per_object_in_commit: None,
2915
2916 allowed_txn_cost_overage_burst_per_object_in_commit: None,
2917
2918 min_checkpoint_interval_ms: None,
2919
2920 checkpoint_summary_version_specific_data: None,
2921
2922 max_soft_bundle_size: None,
2923
2924 bridge_should_try_to_finalize_committee: None,
2925
2926 max_accumulated_txn_cost_per_object_in_mysticeti_commit: None,
2927
2928 max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit: None,
2929
2930 consensus_gc_depth: None,
2931
2932 gas_budget_based_txn_cost_cap_factor: None,
2933
2934 gas_budget_based_txn_cost_absolute_cap_commit_count: None,
2935
2936 sip_45_consensus_amplification_threshold: None,
2937
2938 use_object_per_epoch_marker_table_v2: None,
2939
2940 consensus_commit_rate_estimation_window_size: None,
2941
2942 aliased_addresses: vec![],
2943
2944 translation_per_command_base_charge: None,
2945 translation_per_input_base_charge: None,
2946 translation_pure_input_per_byte_charge: None,
2947 translation_per_type_node_charge: None,
2948 translation_per_reference_node_charge: None,
2949 translation_metering_step_resolution: None,
2950 translation_per_linkage_entry_charge: None,
2951
2952 max_updates_per_settlement_txn: None,
2953 };
2956 for cur in 2..=version.0 {
2957 match cur {
2958 1 => unreachable!(),
2959 2 => {
2960 cfg.feature_flags.advance_epoch_start_time_in_safe_mode = true;
2961 }
2962 3 => {
2963 cfg.gas_model_version = Some(2);
2965 cfg.max_tx_gas = Some(50_000_000_000);
2967 cfg.base_tx_cost_fixed = Some(2_000);
2969 cfg.storage_gas_price = Some(76);
2971 cfg.feature_flags.loaded_child_objects_fixed = true;
2972 cfg.max_size_written_objects = Some(5 * 1000 * 1000);
2975 cfg.max_size_written_objects_system_tx = Some(50 * 1000 * 1000);
2978 cfg.feature_flags.package_upgrades = true;
2979 }
2980 4 => {
2985 cfg.reward_slashing_rate = Some(10000);
2987 cfg.gas_model_version = Some(3);
2989 }
2990 5 => {
2991 cfg.feature_flags.missing_type_is_compatibility_error = true;
2992 cfg.gas_model_version = Some(4);
2993 cfg.feature_flags.scoring_decision_with_validity_cutoff = true;
2994 }
2998 6 => {
2999 cfg.gas_model_version = Some(5);
3000 cfg.buffer_stake_for_protocol_upgrade_bps = Some(5000);
3001 cfg.feature_flags.consensus_order_end_of_epoch_last = true;
3002 }
3003 7 => {
3004 cfg.feature_flags.disallow_adding_abilities_on_upgrade = true;
3005 cfg.feature_flags
3006 .disable_invariant_violation_check_in_swap_loc = true;
3007 cfg.feature_flags.ban_entry_init = true;
3008 cfg.feature_flags.package_digest_hash_module = true;
3009 }
3010 8 => {
3011 cfg.feature_flags
3012 .disallow_change_struct_type_params_on_upgrade = true;
3013 }
3014 9 => {
3015 cfg.max_move_identifier_len = Some(128);
3017 cfg.feature_flags.no_extraneous_module_bytes = true;
3018 cfg.feature_flags
3019 .advance_to_highest_supported_protocol_version = true;
3020 }
3021 10 => {
3022 cfg.max_verifier_meter_ticks_per_function = Some(16_000_000);
3023 cfg.max_meter_ticks_per_module = Some(16_000_000);
3024 }
3025 11 => {
3026 cfg.max_move_value_depth = Some(128);
3027 }
3028 12 => {
3029 cfg.feature_flags.narwhal_versioned_metadata = true;
3030 if chain != Chain::Mainnet {
3031 cfg.feature_flags.commit_root_state_digest = true;
3032 }
3033
3034 if chain != Chain::Mainnet && chain != Chain::Testnet {
3035 cfg.feature_flags.zklogin_auth = true;
3036 }
3037 }
3038 13 => {}
3039 14 => {
3040 cfg.gas_rounding_step = Some(1_000);
3041 cfg.gas_model_version = Some(6);
3042 }
3043 15 => {
3044 cfg.feature_flags.consensus_transaction_ordering =
3045 ConsensusTransactionOrdering::ByGasPrice;
3046 }
3047 16 => {
3048 cfg.feature_flags.simplified_unwrap_then_delete = true;
3049 }
3050 17 => {
3051 cfg.feature_flags.upgraded_multisig_supported = true;
3052 }
3053 18 => {
3054 cfg.execution_version = Some(1);
3055 cfg.feature_flags.txn_base_cost_as_multiplier = true;
3064 cfg.base_tx_cost_fixed = Some(1_000);
3066 }
3067 19 => {
3068 cfg.max_num_event_emit = Some(1024);
3069 cfg.max_event_emit_size_total = Some(
3072 256 * 250 * 1024, );
3074 }
3075 20 => {
3076 cfg.feature_flags.commit_root_state_digest = true;
3077
3078 if chain != Chain::Mainnet {
3079 cfg.feature_flags.narwhal_new_leader_election_schedule = true;
3080 cfg.consensus_bad_nodes_stake_threshold = Some(20);
3081 }
3082 }
3083
3084 21 => {
3085 if chain != Chain::Mainnet {
3086 cfg.feature_flags.zklogin_supported_providers = BTreeSet::from([
3087 "Google".to_string(),
3088 "Facebook".to_string(),
3089 "Twitch".to_string(),
3090 ]);
3091 }
3092 }
3093 22 => {
3094 cfg.feature_flags.loaded_child_object_format = true;
3095 }
3096 23 => {
3097 cfg.feature_flags.loaded_child_object_format_type = true;
3098 cfg.feature_flags.narwhal_new_leader_election_schedule = true;
3099 cfg.consensus_bad_nodes_stake_threshold = Some(20);
3105 }
3106 24 => {
3107 cfg.feature_flags.simple_conservation_checks = true;
3108 cfg.max_publish_or_upgrade_per_ptb = Some(5);
3109
3110 cfg.feature_flags.end_of_epoch_transaction_supported = true;
3111
3112 if chain != Chain::Mainnet {
3113 cfg.feature_flags.enable_jwk_consensus_updates = true;
3114 cfg.max_jwk_votes_per_validator_per_epoch = Some(240);
3116 cfg.max_age_of_jwk_in_epochs = Some(1);
3117 }
3118 }
3119 25 => {
3120 cfg.feature_flags.zklogin_supported_providers = BTreeSet::from([
3122 "Google".to_string(),
3123 "Facebook".to_string(),
3124 "Twitch".to_string(),
3125 ]);
3126 cfg.feature_flags.zklogin_auth = true;
3127
3128 cfg.feature_flags.enable_jwk_consensus_updates = true;
3130 cfg.max_jwk_votes_per_validator_per_epoch = Some(240);
3131 cfg.max_age_of_jwk_in_epochs = Some(1);
3132 }
3133 26 => {
3134 cfg.gas_model_version = Some(7);
3135 if chain != Chain::Mainnet && chain != Chain::Testnet {
3137 cfg.transfer_receive_object_cost_base = Some(52);
3138 cfg.feature_flags.receive_objects = true;
3139 }
3140 }
3141 27 => {
3142 cfg.gas_model_version = Some(8);
3143 }
3144 28 => {
3145 cfg.check_zklogin_id_cost_base = Some(200);
3147 cfg.check_zklogin_issuer_cost_base = Some(200);
3149
3150 if chain != Chain::Mainnet && chain != Chain::Testnet {
3152 cfg.feature_flags.enable_effects_v2 = true;
3153 }
3154 }
3155 29 => {
3156 cfg.feature_flags.verify_legacy_zklogin_address = true;
3157 }
3158 30 => {
3159 if chain != Chain::Mainnet {
3161 cfg.feature_flags.narwhal_certificate_v2 = true;
3162 }
3163
3164 cfg.random_beacon_reduction_allowed_delta = Some(800);
3165 if chain != Chain::Mainnet {
3167 cfg.feature_flags.enable_effects_v2 = true;
3168 }
3169
3170 cfg.feature_flags.zklogin_supported_providers = BTreeSet::default();
3174
3175 cfg.feature_flags.recompute_has_public_transfer_in_execution = true;
3176 }
3177 31 => {
3178 cfg.execution_version = Some(2);
3179 if chain != Chain::Mainnet && chain != Chain::Testnet {
3181 cfg.feature_flags.shared_object_deletion = true;
3182 }
3183 }
3184 32 => {
3185 if chain != Chain::Mainnet {
3187 cfg.feature_flags.accept_zklogin_in_multisig = true;
3188 }
3189 if chain != Chain::Mainnet {
3191 cfg.transfer_receive_object_cost_base = Some(52);
3192 cfg.feature_flags.receive_objects = true;
3193 }
3194 if chain != Chain::Mainnet && chain != Chain::Testnet {
3196 cfg.feature_flags.random_beacon = true;
3197 cfg.random_beacon_reduction_lower_bound = Some(1600);
3198 cfg.random_beacon_dkg_timeout_round = Some(3000);
3199 cfg.random_beacon_min_round_interval_ms = Some(150);
3200 }
3201 if chain != Chain::Testnet && chain != Chain::Mainnet {
3203 cfg.feature_flags.include_consensus_digest_in_prologue = true;
3204 }
3205
3206 cfg.feature_flags.narwhal_certificate_v2 = true;
3208 }
3209 33 => {
3210 cfg.feature_flags.hardened_otw_check = true;
3211 cfg.feature_flags.allow_receiving_object_id = true;
3212
3213 cfg.transfer_receive_object_cost_base = Some(52);
3215 cfg.feature_flags.receive_objects = true;
3216
3217 if chain != Chain::Mainnet {
3219 cfg.feature_flags.shared_object_deletion = true;
3220 }
3221
3222 cfg.feature_flags.enable_effects_v2 = true;
3223 }
3224 34 => {}
3225 35 => {
3226 if chain != Chain::Mainnet && chain != Chain::Testnet {
3228 cfg.feature_flags.enable_poseidon = true;
3229 cfg.poseidon_bn254_cost_base = Some(260);
3230 cfg.poseidon_bn254_cost_per_block = Some(10);
3231 }
3232
3233 cfg.feature_flags.enable_coin_deny_list = true;
3234 }
3235 36 => {
3236 if chain != Chain::Mainnet && chain != Chain::Testnet {
3238 cfg.feature_flags.enable_group_ops_native_functions = true;
3239 cfg.feature_flags.enable_group_ops_native_function_msm = true;
3240 cfg.group_ops_bls12381_decode_scalar_cost = Some(52);
3242 cfg.group_ops_bls12381_decode_g1_cost = Some(52);
3243 cfg.group_ops_bls12381_decode_g2_cost = Some(52);
3244 cfg.group_ops_bls12381_decode_gt_cost = Some(52);
3245 cfg.group_ops_bls12381_scalar_add_cost = Some(52);
3246 cfg.group_ops_bls12381_g1_add_cost = Some(52);
3247 cfg.group_ops_bls12381_g2_add_cost = Some(52);
3248 cfg.group_ops_bls12381_gt_add_cost = Some(52);
3249 cfg.group_ops_bls12381_scalar_sub_cost = Some(52);
3250 cfg.group_ops_bls12381_g1_sub_cost = Some(52);
3251 cfg.group_ops_bls12381_g2_sub_cost = Some(52);
3252 cfg.group_ops_bls12381_gt_sub_cost = Some(52);
3253 cfg.group_ops_bls12381_scalar_mul_cost = Some(52);
3254 cfg.group_ops_bls12381_g1_mul_cost = Some(52);
3255 cfg.group_ops_bls12381_g2_mul_cost = Some(52);
3256 cfg.group_ops_bls12381_gt_mul_cost = Some(52);
3257 cfg.group_ops_bls12381_scalar_div_cost = Some(52);
3258 cfg.group_ops_bls12381_g1_div_cost = Some(52);
3259 cfg.group_ops_bls12381_g2_div_cost = Some(52);
3260 cfg.group_ops_bls12381_gt_div_cost = Some(52);
3261 cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(52);
3262 cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(52);
3263 cfg.group_ops_bls12381_g1_hash_to_cost_per_byte = Some(2);
3264 cfg.group_ops_bls12381_g2_hash_to_cost_per_byte = Some(2);
3265 cfg.group_ops_bls12381_g1_msm_base_cost = Some(52);
3266 cfg.group_ops_bls12381_g2_msm_base_cost = Some(52);
3267 cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(52);
3268 cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(52);
3269 cfg.group_ops_bls12381_msm_max_len = Some(32);
3270 cfg.group_ops_bls12381_pairing_cost = Some(52);
3271 }
3272 cfg.feature_flags.shared_object_deletion = true;
3274
3275 cfg.consensus_max_transaction_size_bytes = Some(256 * 1024); cfg.consensus_max_transactions_in_block_bytes = Some(6 * 1_024 * 1024);
3277 }
3279 37 => {
3280 cfg.feature_flags.reject_mutable_random_on_entry_functions = true;
3281
3282 if chain != Chain::Mainnet {
3284 cfg.feature_flags.include_consensus_digest_in_prologue = true;
3285 }
3286 }
3287 38 => {
3288 cfg.binary_module_handles = Some(100);
3289 cfg.binary_struct_handles = Some(300);
3290 cfg.binary_function_handles = Some(1500);
3291 cfg.binary_function_instantiations = Some(750);
3292 cfg.binary_signatures = Some(1000);
3293 cfg.binary_constant_pool = Some(4000);
3297 cfg.binary_identifiers = Some(10000);
3298 cfg.binary_address_identifiers = Some(100);
3299 cfg.binary_struct_defs = Some(200);
3300 cfg.binary_struct_def_instantiations = Some(100);
3301 cfg.binary_function_defs = Some(1000);
3302 cfg.binary_field_handles = Some(500);
3303 cfg.binary_field_instantiations = Some(250);
3304 cfg.binary_friend_decls = Some(100);
3305 cfg.max_package_dependencies = Some(32);
3307 cfg.max_modules_in_publish = Some(64);
3308 cfg.execution_version = Some(3);
3310 }
3311 39 => {
3312 }
3314 40 => {}
3315 41 => {
3316 cfg.feature_flags.enable_group_ops_native_functions = true;
3318 cfg.group_ops_bls12381_decode_scalar_cost = Some(52);
3320 cfg.group_ops_bls12381_decode_g1_cost = Some(52);
3321 cfg.group_ops_bls12381_decode_g2_cost = Some(52);
3322 cfg.group_ops_bls12381_decode_gt_cost = Some(52);
3323 cfg.group_ops_bls12381_scalar_add_cost = Some(52);
3324 cfg.group_ops_bls12381_g1_add_cost = Some(52);
3325 cfg.group_ops_bls12381_g2_add_cost = Some(52);
3326 cfg.group_ops_bls12381_gt_add_cost = Some(52);
3327 cfg.group_ops_bls12381_scalar_sub_cost = Some(52);
3328 cfg.group_ops_bls12381_g1_sub_cost = Some(52);
3329 cfg.group_ops_bls12381_g2_sub_cost = Some(52);
3330 cfg.group_ops_bls12381_gt_sub_cost = Some(52);
3331 cfg.group_ops_bls12381_scalar_mul_cost = Some(52);
3332 cfg.group_ops_bls12381_g1_mul_cost = Some(52);
3333 cfg.group_ops_bls12381_g2_mul_cost = Some(52);
3334 cfg.group_ops_bls12381_gt_mul_cost = Some(52);
3335 cfg.group_ops_bls12381_scalar_div_cost = Some(52);
3336 cfg.group_ops_bls12381_g1_div_cost = Some(52);
3337 cfg.group_ops_bls12381_g2_div_cost = Some(52);
3338 cfg.group_ops_bls12381_gt_div_cost = Some(52);
3339 cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(52);
3340 cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(52);
3341 cfg.group_ops_bls12381_g1_hash_to_cost_per_byte = Some(2);
3342 cfg.group_ops_bls12381_g2_hash_to_cost_per_byte = Some(2);
3343 cfg.group_ops_bls12381_g1_msm_base_cost = Some(52);
3344 cfg.group_ops_bls12381_g2_msm_base_cost = Some(52);
3345 cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(52);
3346 cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(52);
3347 cfg.group_ops_bls12381_msm_max_len = Some(32);
3348 cfg.group_ops_bls12381_pairing_cost = Some(52);
3349 }
3350 42 => {}
3351 43 => {
3352 cfg.feature_flags.zklogin_max_epoch_upper_bound_delta = Some(30);
3353 cfg.max_meter_ticks_per_package = Some(16_000_000);
3354 }
3355 44 => {
3356 cfg.feature_flags.include_consensus_digest_in_prologue = true;
3358 if chain != Chain::Mainnet {
3360 cfg.feature_flags.consensus_choice = ConsensusChoice::SwapEachEpoch;
3361 }
3362 }
3363 45 => {
3364 if chain != Chain::Testnet && chain != Chain::Mainnet {
3366 cfg.feature_flags.consensus_network = ConsensusNetwork::Tonic;
3367 }
3368
3369 if chain != Chain::Mainnet {
3370 cfg.feature_flags.mysticeti_leader_scoring_and_schedule = true;
3372 }
3373 cfg.min_move_binary_format_version = Some(6);
3374 cfg.feature_flags.accept_zklogin_in_multisig = true;
3375
3376 if chain != Chain::Mainnet && chain != Chain::Testnet {
3380 cfg.feature_flags.bridge = true;
3381 }
3382 }
3383 46 => {
3384 if chain != Chain::Mainnet {
3386 cfg.feature_flags.bridge = true;
3387 }
3388
3389 cfg.feature_flags.reshare_at_same_initial_version = true;
3391 }
3392 47 => {}
3393 48 => {
3394 cfg.feature_flags.consensus_network = ConsensusNetwork::Tonic;
3396
3397 cfg.feature_flags.resolve_abort_locations_to_package_id = true;
3399
3400 if chain != Chain::Mainnet {
3402 cfg.feature_flags.random_beacon = true;
3403 cfg.random_beacon_reduction_lower_bound = Some(1600);
3404 cfg.random_beacon_dkg_timeout_round = Some(3000);
3405 cfg.random_beacon_min_round_interval_ms = Some(200);
3406 }
3407
3408 cfg.feature_flags.mysticeti_use_committed_subdag_digest = true;
3410 }
3411 49 => {
3412 if chain != Chain::Testnet && chain != Chain::Mainnet {
3413 cfg.move_binary_format_version = Some(7);
3414 }
3415
3416 if chain != Chain::Mainnet && chain != Chain::Testnet {
3418 cfg.feature_flags.enable_vdf = true;
3419 cfg.vdf_verify_vdf_cost = Some(1500);
3422 cfg.vdf_hash_to_input_cost = Some(100);
3423 }
3424
3425 if chain != Chain::Testnet && chain != Chain::Mainnet {
3427 cfg.feature_flags
3428 .record_consensus_determined_version_assignments_in_prologue = true;
3429 }
3430
3431 if chain != Chain::Mainnet {
3433 cfg.feature_flags.consensus_choice = ConsensusChoice::Mysticeti;
3434 }
3435
3436 cfg.feature_flags.fresh_vm_on_framework_upgrade = true;
3438 }
3439 50 => {
3440 if chain != Chain::Mainnet {
3442 cfg.checkpoint_summary_version_specific_data = Some(1);
3443 cfg.min_checkpoint_interval_ms = Some(200);
3444 }
3445
3446 if chain != Chain::Testnet && chain != Chain::Mainnet {
3448 cfg.feature_flags
3449 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = true;
3450 }
3451
3452 cfg.feature_flags.mysticeti_num_leaders_per_round = Some(1);
3453
3454 cfg.max_deferral_rounds_for_congestion_control = Some(10);
3456 }
3457 51 => {
3458 cfg.random_beacon_dkg_version = Some(1);
3459
3460 if chain != Chain::Testnet && chain != Chain::Mainnet {
3461 cfg.feature_flags.enable_coin_deny_list_v2 = true;
3462 }
3463 }
3464 52 => {
3465 if chain != Chain::Mainnet {
3466 cfg.feature_flags.soft_bundle = true;
3467 cfg.max_soft_bundle_size = Some(5);
3468 }
3469
3470 cfg.config_read_setting_impl_cost_base = Some(100);
3471 cfg.config_read_setting_impl_cost_per_byte = Some(40);
3472
3473 if chain != Chain::Testnet && chain != Chain::Mainnet {
3475 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(100);
3476 cfg.feature_flags.per_object_congestion_control_mode =
3477 PerObjectCongestionControlMode::TotalTxCount;
3478 }
3479
3480 cfg.feature_flags.consensus_choice = ConsensusChoice::Mysticeti;
3482
3483 cfg.feature_flags.mysticeti_leader_scoring_and_schedule = true;
3485
3486 cfg.checkpoint_summary_version_specific_data = Some(1);
3488 cfg.min_checkpoint_interval_ms = Some(200);
3489
3490 if chain != Chain::Mainnet {
3492 cfg.feature_flags
3493 .record_consensus_determined_version_assignments_in_prologue = true;
3494 cfg.feature_flags
3495 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = true;
3496 }
3497 if chain != Chain::Mainnet {
3499 cfg.move_binary_format_version = Some(7);
3500 }
3501
3502 if chain != Chain::Testnet && chain != Chain::Mainnet {
3503 cfg.feature_flags.passkey_auth = true;
3504 }
3505 cfg.feature_flags.enable_coin_deny_list_v2 = true;
3506 }
3507 53 => {
3508 cfg.bridge_should_try_to_finalize_committee = Some(chain != Chain::Mainnet);
3510
3511 cfg.feature_flags
3513 .record_consensus_determined_version_assignments_in_prologue = true;
3514 cfg.feature_flags
3515 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = true;
3516
3517 if chain == Chain::Unknown {
3518 cfg.feature_flags.authority_capabilities_v2 = true;
3519 }
3520
3521 if chain != Chain::Mainnet {
3523 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(100);
3524 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(10);
3525 cfg.feature_flags.per_object_congestion_control_mode =
3526 PerObjectCongestionControlMode::TotalTxCount;
3527 }
3528
3529 cfg.bcs_per_byte_serialized_cost = Some(2);
3531 cfg.bcs_legacy_min_output_size_cost = Some(1);
3532 cfg.bcs_failure_cost = Some(52);
3533 cfg.debug_print_base_cost = Some(52);
3534 cfg.debug_print_stack_trace_base_cost = Some(52);
3535 cfg.hash_sha2_256_base_cost = Some(52);
3536 cfg.hash_sha2_256_per_byte_cost = Some(2);
3537 cfg.hash_sha2_256_legacy_min_input_len_cost = Some(1);
3538 cfg.hash_sha3_256_base_cost = Some(52);
3539 cfg.hash_sha3_256_per_byte_cost = Some(2);
3540 cfg.hash_sha3_256_legacy_min_input_len_cost = Some(1);
3541 cfg.type_name_get_base_cost = Some(52);
3542 cfg.type_name_get_per_byte_cost = Some(2);
3543 cfg.string_check_utf8_base_cost = Some(52);
3544 cfg.string_check_utf8_per_byte_cost = Some(2);
3545 cfg.string_is_char_boundary_base_cost = Some(52);
3546 cfg.string_sub_string_base_cost = Some(52);
3547 cfg.string_sub_string_per_byte_cost = Some(2);
3548 cfg.string_index_of_base_cost = Some(52);
3549 cfg.string_index_of_per_byte_pattern_cost = Some(2);
3550 cfg.string_index_of_per_byte_searched_cost = Some(2);
3551 cfg.vector_empty_base_cost = Some(52);
3552 cfg.vector_length_base_cost = Some(52);
3553 cfg.vector_push_back_base_cost = Some(52);
3554 cfg.vector_push_back_legacy_per_abstract_memory_unit_cost = Some(2);
3555 cfg.vector_borrow_base_cost = Some(52);
3556 cfg.vector_pop_back_base_cost = Some(52);
3557 cfg.vector_destroy_empty_base_cost = Some(52);
3558 cfg.vector_swap_base_cost = Some(52);
3559 }
3560 54 => {
3561 cfg.feature_flags.random_beacon = true;
3563 cfg.random_beacon_reduction_lower_bound = Some(1000);
3564 cfg.random_beacon_dkg_timeout_round = Some(3000);
3565 cfg.random_beacon_min_round_interval_ms = Some(500);
3566
3567 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(100);
3569 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(10);
3570 cfg.feature_flags.per_object_congestion_control_mode =
3571 PerObjectCongestionControlMode::TotalTxCount;
3572
3573 cfg.feature_flags.soft_bundle = true;
3575 cfg.max_soft_bundle_size = Some(5);
3576 }
3577 55 => {
3578 cfg.move_binary_format_version = Some(7);
3580
3581 cfg.consensus_max_transactions_in_block_bytes = Some(512 * 1024);
3583 cfg.consensus_max_num_transactions_in_block = Some(512);
3586
3587 cfg.feature_flags.rethrow_serialization_type_layout_errors = true;
3588 }
3589 56 => {
3590 if chain == Chain::Mainnet {
3591 cfg.feature_flags.bridge = true;
3592 }
3593 }
3594 57 => {
3595 cfg.random_beacon_reduction_lower_bound = Some(800);
3597 }
3598 58 => {
3599 if chain == Chain::Mainnet {
3600 cfg.bridge_should_try_to_finalize_committee = Some(true);
3601 }
3602
3603 if chain != Chain::Mainnet && chain != Chain::Testnet {
3604 cfg.feature_flags
3606 .consensus_distributed_vote_scoring_strategy = true;
3607 }
3608 }
3609 59 => {
3610 cfg.feature_flags.consensus_round_prober = true;
3612 }
3613 60 => {
3614 cfg.max_type_to_layout_nodes = Some(512);
3615 cfg.feature_flags.validate_identifier_inputs = true;
3616 }
3617 61 => {
3618 if chain != Chain::Mainnet {
3619 cfg.feature_flags
3621 .consensus_distributed_vote_scoring_strategy = true;
3622 }
3623 cfg.random_beacon_reduction_lower_bound = Some(700);
3625
3626 if chain != Chain::Mainnet && chain != Chain::Testnet {
3627 cfg.feature_flags.mysticeti_fastpath = true;
3629 }
3630 }
3631 62 => {
3632 cfg.feature_flags.relocate_event_module = true;
3633 }
3634 63 => {
3635 cfg.feature_flags.per_object_congestion_control_mode =
3636 PerObjectCongestionControlMode::TotalGasBudgetWithCap;
3637 cfg.gas_budget_based_txn_cost_cap_factor = Some(400_000);
3638 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(18_500_000);
3639 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(240_000_000);
3640 }
3641 64 => {
3642 cfg.feature_flags.per_object_congestion_control_mode =
3643 PerObjectCongestionControlMode::TotalTxCount;
3644 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(40);
3645 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(3);
3646 }
3647 65 => {
3648 cfg.feature_flags
3650 .consensus_distributed_vote_scoring_strategy = true;
3651 }
3652 66 => {
3653 if chain == Chain::Mainnet {
3654 cfg.feature_flags
3656 .consensus_distributed_vote_scoring_strategy = false;
3657 }
3658 }
3659 67 => {
3660 cfg.feature_flags
3662 .consensus_distributed_vote_scoring_strategy = true;
3663 }
3664 68 => {
3665 cfg.group_ops_bls12381_g1_to_uncompressed_g1_cost = Some(26);
3666 cfg.group_ops_bls12381_uncompressed_g1_to_g1_cost = Some(52);
3667 cfg.group_ops_bls12381_uncompressed_g1_sum_base_cost = Some(26);
3668 cfg.group_ops_bls12381_uncompressed_g1_sum_cost_per_term = Some(13);
3669 cfg.group_ops_bls12381_uncompressed_g1_sum_max_terms = Some(2000);
3670
3671 if chain != Chain::Mainnet && chain != Chain::Testnet {
3672 cfg.feature_flags.uncompressed_g1_group_elements = true;
3673 }
3674
3675 cfg.feature_flags.per_object_congestion_control_mode =
3676 PerObjectCongestionControlMode::TotalGasBudgetWithCap;
3677 cfg.gas_budget_based_txn_cost_cap_factor = Some(400_000);
3678 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(18_500_000);
3679 cfg.max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit =
3680 Some(3_700_000); cfg.max_txn_cost_overage_per_object_in_commit = Some(u64::MAX);
3682 cfg.gas_budget_based_txn_cost_absolute_cap_commit_count = Some(50);
3683
3684 cfg.random_beacon_reduction_lower_bound = Some(500);
3686
3687 cfg.feature_flags.disallow_new_modules_in_deps_only_packages = true;
3688 }
3689 69 => {
3690 cfg.consensus_voting_rounds = Some(40);
3692
3693 if chain != Chain::Mainnet && chain != Chain::Testnet {
3694 cfg.feature_flags.consensus_smart_ancestor_selection = true;
3696 }
3697
3698 if chain != Chain::Mainnet {
3699 cfg.feature_flags.uncompressed_g1_group_elements = true;
3700 }
3701 }
3702 70 => {
3703 if chain != Chain::Mainnet {
3704 cfg.feature_flags.consensus_smart_ancestor_selection = true;
3706 cfg.feature_flags
3708 .consensus_round_prober_probe_accepted_rounds = true;
3709 }
3710
3711 cfg.poseidon_bn254_cost_per_block = Some(388);
3712
3713 cfg.gas_model_version = Some(9);
3714 cfg.feature_flags.native_charging_v2 = true;
3715 cfg.bls12381_bls12381_min_sig_verify_cost_base = Some(44064);
3716 cfg.bls12381_bls12381_min_pk_verify_cost_base = Some(49282);
3717 cfg.ecdsa_k1_secp256k1_verify_keccak256_cost_base = Some(1470);
3718 cfg.ecdsa_k1_secp256k1_verify_sha256_cost_base = Some(1470);
3719 cfg.ecdsa_r1_secp256r1_verify_sha256_cost_base = Some(4225);
3720 cfg.ecdsa_r1_secp256r1_verify_keccak256_cost_base = Some(4225);
3721 cfg.ecvrf_ecvrf_verify_cost_base = Some(4848);
3722 cfg.ed25519_ed25519_verify_cost_base = Some(1802);
3723
3724 cfg.ecdsa_r1_ecrecover_keccak256_cost_base = Some(1173);
3726 cfg.ecdsa_r1_ecrecover_sha256_cost_base = Some(1173);
3727 cfg.ecdsa_k1_ecrecover_keccak256_cost_base = Some(500);
3728 cfg.ecdsa_k1_ecrecover_sha256_cost_base = Some(500);
3729
3730 cfg.groth16_prepare_verifying_key_bls12381_cost_base = Some(53838);
3731 cfg.groth16_prepare_verifying_key_bn254_cost_base = Some(82010);
3732 cfg.groth16_verify_groth16_proof_internal_bls12381_cost_base = Some(72090);
3733 cfg.groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input =
3734 Some(8213);
3735 cfg.groth16_verify_groth16_proof_internal_bn254_cost_base = Some(115502);
3736 cfg.groth16_verify_groth16_proof_internal_bn254_cost_per_public_input =
3737 Some(9484);
3738
3739 cfg.hash_keccak256_cost_base = Some(10);
3740 cfg.hash_blake2b256_cost_base = Some(10);
3741
3742 cfg.group_ops_bls12381_decode_scalar_cost = Some(7);
3744 cfg.group_ops_bls12381_decode_g1_cost = Some(2848);
3745 cfg.group_ops_bls12381_decode_g2_cost = Some(3770);
3746 cfg.group_ops_bls12381_decode_gt_cost = Some(3068);
3747
3748 cfg.group_ops_bls12381_scalar_add_cost = Some(10);
3749 cfg.group_ops_bls12381_g1_add_cost = Some(1556);
3750 cfg.group_ops_bls12381_g2_add_cost = Some(3048);
3751 cfg.group_ops_bls12381_gt_add_cost = Some(188);
3752
3753 cfg.group_ops_bls12381_scalar_sub_cost = Some(10);
3754 cfg.group_ops_bls12381_g1_sub_cost = Some(1550);
3755 cfg.group_ops_bls12381_g2_sub_cost = Some(3019);
3756 cfg.group_ops_bls12381_gt_sub_cost = Some(497);
3757
3758 cfg.group_ops_bls12381_scalar_mul_cost = Some(11);
3759 cfg.group_ops_bls12381_g1_mul_cost = Some(4842);
3760 cfg.group_ops_bls12381_g2_mul_cost = Some(9108);
3761 cfg.group_ops_bls12381_gt_mul_cost = Some(27490);
3762
3763 cfg.group_ops_bls12381_scalar_div_cost = Some(91);
3764 cfg.group_ops_bls12381_g1_div_cost = Some(5091);
3765 cfg.group_ops_bls12381_g2_div_cost = Some(9206);
3766 cfg.group_ops_bls12381_gt_div_cost = Some(27804);
3767
3768 cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(2962);
3769 cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(8688);
3770
3771 cfg.group_ops_bls12381_g1_msm_base_cost = Some(62648);
3772 cfg.group_ops_bls12381_g2_msm_base_cost = Some(131192);
3773 cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(1333);
3774 cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(3216);
3775
3776 cfg.group_ops_bls12381_uncompressed_g1_to_g1_cost = Some(677);
3777 cfg.group_ops_bls12381_g1_to_uncompressed_g1_cost = Some(2099);
3778 cfg.group_ops_bls12381_uncompressed_g1_sum_base_cost = Some(77);
3779 cfg.group_ops_bls12381_uncompressed_g1_sum_cost_per_term = Some(26);
3780
3781 cfg.group_ops_bls12381_pairing_cost = Some(26897);
3782 cfg.group_ops_bls12381_uncompressed_g1_sum_max_terms = Some(1200);
3783
3784 cfg.validator_validate_metadata_cost_base = Some(20000);
3785 }
3786 71 => {
3787 cfg.sip_45_consensus_amplification_threshold = Some(5);
3788
3789 cfg.allowed_txn_cost_overage_burst_per_object_in_commit = Some(185_000_000);
3791 }
3792 72 => {
3793 cfg.feature_flags.convert_type_argument_error = true;
3794
3795 cfg.max_tx_gas = Some(50_000_000_000_000);
3798 cfg.max_gas_price = Some(50_000_000_000);
3800
3801 cfg.feature_flags.variant_nodes = true;
3802 }
3803 73 => {
3804 cfg.use_object_per_epoch_marker_table_v2 = Some(true);
3806
3807 if chain != Chain::Mainnet && chain != Chain::Testnet {
3808 cfg.consensus_gc_depth = Some(60);
3811 }
3812
3813 if chain != Chain::Mainnet {
3814 cfg.feature_flags.consensus_zstd_compression = true;
3816 }
3817
3818 cfg.feature_flags.consensus_smart_ancestor_selection = true;
3820 cfg.feature_flags
3822 .consensus_round_prober_probe_accepted_rounds = true;
3823
3824 cfg.feature_flags.per_object_congestion_control_mode =
3826 PerObjectCongestionControlMode::TotalGasBudgetWithCap;
3827 cfg.gas_budget_based_txn_cost_cap_factor = Some(400_000);
3828 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(37_000_000);
3829 cfg.max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit =
3830 Some(7_400_000); cfg.max_txn_cost_overage_per_object_in_commit = Some(u64::MAX);
3832 cfg.gas_budget_based_txn_cost_absolute_cap_commit_count = Some(50);
3833 cfg.allowed_txn_cost_overage_burst_per_object_in_commit = Some(370_000_000);
3834 }
3835 74 => {
3836 if chain != Chain::Mainnet && chain != Chain::Testnet {
3838 cfg.feature_flags.enable_nitro_attestation = true;
3839 }
3840 cfg.nitro_attestation_parse_base_cost = Some(53 * 50);
3841 cfg.nitro_attestation_parse_cost_per_byte = Some(50);
3842 cfg.nitro_attestation_verify_base_cost = Some(49632 * 50);
3843 cfg.nitro_attestation_verify_cost_per_cert = Some(52369 * 50);
3844
3845 cfg.feature_flags.consensus_zstd_compression = true;
3847
3848 if chain != Chain::Mainnet && chain != Chain::Testnet {
3849 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
3850 }
3851 }
3852 75 => {
3853 if chain != Chain::Mainnet {
3854 cfg.feature_flags.passkey_auth = true;
3855 }
3856 }
3857 76 => {
3858 if chain != Chain::Mainnet && chain != Chain::Testnet {
3859 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
3860 cfg.consensus_commit_rate_estimation_window_size = Some(10);
3861 }
3862 cfg.feature_flags.minimize_child_object_mutations = true;
3863
3864 if chain != Chain::Mainnet {
3865 cfg.feature_flags.accept_passkey_in_multisig = true;
3866 }
3867 }
3868 77 => {
3869 cfg.feature_flags.uncompressed_g1_group_elements = true;
3870
3871 if chain != Chain::Mainnet {
3872 cfg.consensus_gc_depth = Some(60);
3873 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
3874 }
3875 }
3876 78 => {
3877 cfg.feature_flags.move_native_context = true;
3878 cfg.tx_context_fresh_id_cost_base = Some(52);
3879 cfg.tx_context_sender_cost_base = Some(30);
3880 cfg.tx_context_epoch_cost_base = Some(30);
3881 cfg.tx_context_epoch_timestamp_ms_cost_base = Some(30);
3882 cfg.tx_context_sponsor_cost_base = Some(30);
3883 cfg.tx_context_gas_price_cost_base = Some(30);
3884 cfg.tx_context_gas_budget_cost_base = Some(30);
3885 cfg.tx_context_ids_created_cost_base = Some(30);
3886 cfg.tx_context_replace_cost_base = Some(30);
3887 cfg.gas_model_version = Some(10);
3888
3889 if chain != Chain::Mainnet {
3890 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
3891 cfg.consensus_commit_rate_estimation_window_size = Some(10);
3892
3893 cfg.feature_flags.per_object_congestion_control_mode =
3895 PerObjectCongestionControlMode::ExecutionTimeEstimate(
3896 ExecutionTimeEstimateParams {
3897 target_utilization: 30,
3898 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
3900 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
3902 stored_observations_limit: u64::MAX,
3903 stake_weighted_median_threshold: 0,
3904 default_none_duration_for_new_keys: false,
3905 },
3906 );
3907 }
3908 }
3909 79 => {
3910 if chain != Chain::Mainnet {
3911 cfg.feature_flags.consensus_median_based_commit_timestamp = true;
3912
3913 cfg.consensus_bad_nodes_stake_threshold = Some(30);
3916
3917 cfg.feature_flags.consensus_batched_block_sync = true;
3918
3919 cfg.feature_flags.enable_nitro_attestation = true
3921 }
3922 cfg.feature_flags.normalize_ptb_arguments = true;
3923
3924 cfg.consensus_gc_depth = Some(60);
3925 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
3926 }
3927 80 => {
3928 cfg.max_ptb_value_size = Some(1024 * 1024);
3929 }
3930 81 => {
3931 cfg.feature_flags.consensus_median_based_commit_timestamp = true;
3932 cfg.feature_flags.enforce_checkpoint_timestamp_monotonicity = true;
3933 cfg.consensus_bad_nodes_stake_threshold = Some(30)
3934 }
3935 82 => {
3936 cfg.feature_flags.max_ptb_value_size_v2 = true;
3937 }
3938 83 => {
3939 if chain == Chain::Mainnet {
3940 let aliased: [u8; 32] = Hex::decode(
3942 "0x0b2da327ba6a4cacbe75dddd50e6e8bbf81d6496e92d66af9154c61c77f7332f",
3943 )
3944 .unwrap()
3945 .try_into()
3946 .unwrap();
3947
3948 cfg.aliased_addresses.push(AliasedAddress {
3950 original: Hex::decode("0xcd8962dad278d8b50fa0f9eb0186bfa4cbdecc6d59377214c88d0286a0ac9562").unwrap().try_into().unwrap(),
3951 aliased,
3952 allowed_tx_digests: vec![
3953 Base58::decode("B2eGLFoMHgj93Ni8dAJBfqGzo8EWSTLBesZzhEpTPA4").unwrap().try_into().unwrap(),
3954 ],
3955 });
3956
3957 cfg.aliased_addresses.push(AliasedAddress {
3958 original: Hex::decode("0xe28b50cef1d633ea43d3296a3f6b67ff0312a5f1a99f0af753c85b8b5de8ff06").unwrap().try_into().unwrap(),
3959 aliased,
3960 allowed_tx_digests: vec![
3961 Base58::decode("J4QqSAgp7VrQtQpMy5wDX4QGsCSEZu3U5KuDAkbESAge").unwrap().try_into().unwrap(),
3962 ],
3963 });
3964 }
3965
3966 if chain != Chain::Mainnet {
3969 cfg.feature_flags.resolve_type_input_ids_to_defining_id = true;
3970 cfg.transfer_party_transfer_internal_cost_base = Some(52);
3971
3972 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
3974 cfg.consensus_commit_rate_estimation_window_size = Some(10);
3975 cfg.feature_flags.per_object_congestion_control_mode =
3976 PerObjectCongestionControlMode::ExecutionTimeEstimate(
3977 ExecutionTimeEstimateParams {
3978 target_utilization: 30,
3979 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
3981 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
3983 stored_observations_limit: u64::MAX,
3984 stake_weighted_median_threshold: 0,
3985 default_none_duration_for_new_keys: false,
3986 },
3987 );
3988
3989 cfg.feature_flags.consensus_batched_block_sync = true;
3991
3992 cfg.feature_flags.enable_nitro_attestation_upgraded_parsing = true;
3995 cfg.feature_flags.enable_nitro_attestation = true;
3996 }
3997 }
3998 84 => {
3999 if chain == Chain::Mainnet {
4000 cfg.feature_flags.resolve_type_input_ids_to_defining_id = true;
4001 cfg.transfer_party_transfer_internal_cost_base = Some(52);
4002
4003 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
4005 cfg.consensus_commit_rate_estimation_window_size = Some(10);
4006 cfg.feature_flags.per_object_congestion_control_mode =
4007 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4008 ExecutionTimeEstimateParams {
4009 target_utilization: 30,
4010 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4012 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4014 stored_observations_limit: u64::MAX,
4015 stake_weighted_median_threshold: 0,
4016 default_none_duration_for_new_keys: false,
4017 },
4018 );
4019
4020 cfg.feature_flags.consensus_batched_block_sync = true;
4022
4023 cfg.feature_flags.enable_nitro_attestation_upgraded_parsing = true;
4026 cfg.feature_flags.enable_nitro_attestation = true;
4027 }
4028
4029 cfg.feature_flags.per_object_congestion_control_mode =
4031 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4032 ExecutionTimeEstimateParams {
4033 target_utilization: 30,
4034 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4036 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4038 stored_observations_limit: 20,
4039 stake_weighted_median_threshold: 0,
4040 default_none_duration_for_new_keys: false,
4041 },
4042 );
4043 cfg.feature_flags.allow_unbounded_system_objects = true;
4044 }
4045 85 => {
4046 if chain != Chain::Mainnet && chain != Chain::Testnet {
4047 cfg.feature_flags.enable_party_transfer = true;
4048 }
4049
4050 cfg.feature_flags
4051 .record_consensus_determined_version_assignments_in_prologue_v2 = true;
4052 cfg.feature_flags.disallow_self_identifier = true;
4053 cfg.feature_flags.per_object_congestion_control_mode =
4054 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4055 ExecutionTimeEstimateParams {
4056 target_utilization: 50,
4057 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4059 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4061 stored_observations_limit: 20,
4062 stake_weighted_median_threshold: 0,
4063 default_none_duration_for_new_keys: false,
4064 },
4065 );
4066 }
4067 86 => {
4068 cfg.feature_flags.type_tags_in_object_runtime = true;
4069 cfg.max_move_enum_variants = Some(move_core_types::VARIANT_COUNT_MAX);
4070
4071 cfg.feature_flags.per_object_congestion_control_mode =
4073 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4074 ExecutionTimeEstimateParams {
4075 target_utilization: 50,
4076 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4078 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4080 stored_observations_limit: 20,
4081 stake_weighted_median_threshold: 3334,
4082 default_none_duration_for_new_keys: false,
4083 },
4084 );
4085 if chain != Chain::Mainnet {
4087 cfg.feature_flags.enable_party_transfer = true;
4088 }
4089 }
4090 87 => {
4091 if chain == Chain::Mainnet {
4092 cfg.feature_flags.record_time_estimate_processed = true;
4093 }
4094 cfg.feature_flags.better_adapter_type_resolution_errors = true;
4095 }
4096 88 => {
4097 cfg.feature_flags.record_time_estimate_processed = true;
4098 cfg.tx_context_rgp_cost_base = Some(30);
4099 cfg.feature_flags
4100 .ignore_execution_time_observations_after_certs_closed = true;
4101
4102 cfg.feature_flags.per_object_congestion_control_mode =
4105 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4106 ExecutionTimeEstimateParams {
4107 target_utilization: 50,
4108 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4110 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4112 stored_observations_limit: 20,
4113 stake_weighted_median_threshold: 3334,
4114 default_none_duration_for_new_keys: true,
4115 },
4116 );
4117 }
4118 89 => {
4119 cfg.feature_flags.dependency_linkage_error = true;
4120 cfg.feature_flags.additional_multisig_checks = true;
4121 }
4122 90 => {
4123 cfg.max_gas_price_rgp_factor_for_aborted_transactions = Some(100);
4125 cfg.feature_flags.debug_fatal_on_move_invariant_violation = true;
4126 cfg.feature_flags.additional_consensus_digest_indirect_state = true;
4127 cfg.feature_flags.accept_passkey_in_multisig = true;
4128 cfg.feature_flags.passkey_auth = true;
4129 cfg.feature_flags.check_for_init_during_upgrade = true;
4130
4131 if chain != Chain::Mainnet {
4133 cfg.feature_flags.mysticeti_fastpath = true;
4134 }
4135 }
4136 91 => {
4137 cfg.feature_flags.per_command_shared_object_transfer_rules = true;
4138 }
4139 92 => {
4140 cfg.feature_flags.per_command_shared_object_transfer_rules = false;
4141 }
4142 93 => {
4143 cfg.feature_flags
4144 .consensus_checkpoint_signature_key_includes_digest = true;
4145 }
4146 94 => {
4147 cfg.feature_flags.per_object_congestion_control_mode =
4149 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4150 ExecutionTimeEstimateParams {
4151 target_utilization: 50,
4152 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4154 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4156 stored_observations_limit: 18,
4157 stake_weighted_median_threshold: 3334,
4158 default_none_duration_for_new_keys: true,
4159 },
4160 );
4161
4162 cfg.feature_flags.enable_party_transfer = true;
4164 }
4165 95 => {
4166 cfg.type_name_id_base_cost = Some(52);
4167
4168 cfg.max_transactions_per_checkpoint = Some(20_000);
4170 }
4171 96 => {
4172 if chain != Chain::Mainnet && chain != Chain::Testnet {
4174 cfg.feature_flags
4175 .include_checkpoint_artifacts_digest_in_summary = true;
4176 }
4177 cfg.feature_flags.correct_gas_payment_limit_check = true;
4178 cfg.feature_flags.authority_capabilities_v2 = true;
4179 cfg.feature_flags.use_mfp_txns_in_load_initial_object_debts = true;
4180 cfg.feature_flags.cancel_for_failed_dkg_early = true;
4181 cfg.feature_flags.enable_coin_registry = true;
4182
4183 cfg.feature_flags.mysticeti_fastpath = true;
4185 }
4186 97 => {
4187 cfg.feature_flags.additional_borrow_checks = true;
4188 }
4189 98 => {
4190 cfg.event_emit_auth_stream_cost = Some(52);
4191 cfg.feature_flags.better_loader_errors = true;
4192 cfg.feature_flags.generate_df_type_layouts = true;
4193 }
4194 99 => {
4195 cfg.feature_flags.use_new_commit_handler = true;
4196 }
4197 100 => {
4198 cfg.feature_flags.private_generics_verifier_v2 = true;
4199 }
4200 101 => {
4201 cfg.feature_flags.create_root_accumulator_object = true;
4202 cfg.max_updates_per_settlement_txn = Some(100);
4203 if chain != Chain::Mainnet {
4204 cfg.feature_flags.enable_poseidon = true;
4205 }
4206 }
4207 _ => panic!("unsupported version {:?}", version),
4218 }
4219 }
4220
4221 if cfg!(msim) {
4223 cfg.consensus_gc_depth = Some(5);
4225
4226 }
4231
4232 cfg
4233 }
4234
4235 pub fn verifier_config(&self, signing_limits: Option<(usize, usize)>) -> VerifierConfig {
4238 let (max_back_edges_per_function, max_back_edges_per_module) = if let Some((
4239 max_back_edges_per_function,
4240 max_back_edges_per_module,
4241 )) = signing_limits
4242 {
4243 (
4244 Some(max_back_edges_per_function),
4245 Some(max_back_edges_per_module),
4246 )
4247 } else {
4248 (None, None)
4249 };
4250
4251 let additional_borrow_checks = if signing_limits.is_some() {
4252 true
4254 } else {
4255 self.additional_borrow_checks()
4256 };
4257
4258 VerifierConfig {
4259 max_loop_depth: Some(self.max_loop_depth() as usize),
4260 max_generic_instantiation_length: Some(self.max_generic_instantiation_length() as usize),
4261 max_function_parameters: Some(self.max_function_parameters() as usize),
4262 max_basic_blocks: Some(self.max_basic_blocks() as usize),
4263 max_value_stack_size: self.max_value_stack_size() as usize,
4264 max_type_nodes: Some(self.max_type_nodes() as usize),
4265 max_push_size: Some(self.max_push_size() as usize),
4266 max_dependency_depth: Some(self.max_dependency_depth() as usize),
4267 max_fields_in_struct: Some(self.max_fields_in_struct() as usize),
4268 max_function_definitions: Some(self.max_function_definitions() as usize),
4269 max_data_definitions: Some(self.max_struct_definitions() as usize),
4270 max_constant_vector_len: Some(self.max_move_vector_len()),
4271 max_back_edges_per_function,
4272 max_back_edges_per_module,
4273 max_basic_blocks_in_script: None,
4274 max_identifier_len: self.max_move_identifier_len_as_option(), disallow_self_identifier: self.feature_flags.disallow_self_identifier,
4276 allow_receiving_object_id: self.allow_receiving_object_id(),
4277 reject_mutable_random_on_entry_functions: self
4278 .reject_mutable_random_on_entry_functions(),
4279 bytecode_version: self.move_binary_format_version(),
4280 max_variants_in_enum: self.max_move_enum_variants_as_option(),
4281 additional_borrow_checks,
4282 better_loader_errors: self.better_loader_errors(),
4283 private_generics_verifier_v2: self.private_generics_verifier_v2(),
4284 }
4285 }
4286
4287 pub fn binary_config(
4288 &self,
4289 override_deprecate_global_storage_ops_during_deserialization: Option<bool>,
4290 ) -> BinaryConfig {
4291 let deprecate_global_storage_ops_during_deserialization =
4292 override_deprecate_global_storage_ops_during_deserialization
4293 .unwrap_or_else(|| self.deprecate_global_storage_ops_during_deserialization());
4294 BinaryConfig::new(
4295 self.move_binary_format_version(),
4296 self.min_move_binary_format_version_as_option()
4297 .unwrap_or(VERSION_1),
4298 self.no_extraneous_module_bytes(),
4299 deprecate_global_storage_ops_during_deserialization,
4300 TableConfig {
4301 module_handles: self.binary_module_handles_as_option().unwrap_or(u16::MAX),
4302 datatype_handles: self.binary_struct_handles_as_option().unwrap_or(u16::MAX),
4303 function_handles: self.binary_function_handles_as_option().unwrap_or(u16::MAX),
4304 function_instantiations: self
4305 .binary_function_instantiations_as_option()
4306 .unwrap_or(u16::MAX),
4307 signatures: self.binary_signatures_as_option().unwrap_or(u16::MAX),
4308 constant_pool: self.binary_constant_pool_as_option().unwrap_or(u16::MAX),
4309 identifiers: self.binary_identifiers_as_option().unwrap_or(u16::MAX),
4310 address_identifiers: self
4311 .binary_address_identifiers_as_option()
4312 .unwrap_or(u16::MAX),
4313 struct_defs: self.binary_struct_defs_as_option().unwrap_or(u16::MAX),
4314 struct_def_instantiations: self
4315 .binary_struct_def_instantiations_as_option()
4316 .unwrap_or(u16::MAX),
4317 function_defs: self.binary_function_defs_as_option().unwrap_or(u16::MAX),
4318 field_handles: self.binary_field_handles_as_option().unwrap_or(u16::MAX),
4319 field_instantiations: self
4320 .binary_field_instantiations_as_option()
4321 .unwrap_or(u16::MAX),
4322 friend_decls: self.binary_friend_decls_as_option().unwrap_or(u16::MAX),
4323 enum_defs: self.binary_enum_defs_as_option().unwrap_or(u16::MAX),
4324 enum_def_instantiations: self
4325 .binary_enum_def_instantiations_as_option()
4326 .unwrap_or(u16::MAX),
4327 variant_handles: self.binary_variant_handles_as_option().unwrap_or(u16::MAX),
4328 variant_instantiation_handles: self
4329 .binary_variant_instantiation_handles_as_option()
4330 .unwrap_or(u16::MAX),
4331 },
4332 )
4333 }
4334
4335 pub fn apply_overrides_for_testing(
4339 override_fn: impl Fn(ProtocolVersion, Self) -> Self + Send + 'static,
4340 ) -> OverrideGuard {
4341 CONFIG_OVERRIDE.with(|ovr| {
4342 let mut cur = ovr.borrow_mut();
4343 assert!(cur.is_none(), "config override already present");
4344 *cur = Some(Box::new(override_fn));
4345 OverrideGuard
4346 })
4347 }
4348}
4349
4350impl ProtocolConfig {
4354 pub fn set_advance_to_highest_supported_protocol_version_for_testing(&mut self, val: bool) {
4355 self.feature_flags
4356 .advance_to_highest_supported_protocol_version = val
4357 }
4358 pub fn set_commit_root_state_digest_supported_for_testing(&mut self, val: bool) {
4359 self.feature_flags.commit_root_state_digest = val
4360 }
4361 pub fn set_zklogin_auth_for_testing(&mut self, val: bool) {
4362 self.feature_flags.zklogin_auth = val
4363 }
4364 pub fn set_enable_jwk_consensus_updates_for_testing(&mut self, val: bool) {
4365 self.feature_flags.enable_jwk_consensus_updates = val
4366 }
4367 pub fn set_random_beacon_for_testing(&mut self, val: bool) {
4368 self.feature_flags.random_beacon = val
4369 }
4370
4371 pub fn set_upgraded_multisig_for_testing(&mut self, val: bool) {
4372 self.feature_flags.upgraded_multisig_supported = val
4373 }
4374 pub fn set_accept_zklogin_in_multisig_for_testing(&mut self, val: bool) {
4375 self.feature_flags.accept_zklogin_in_multisig = val
4376 }
4377
4378 pub fn set_shared_object_deletion_for_testing(&mut self, val: bool) {
4379 self.feature_flags.shared_object_deletion = val;
4380 }
4381
4382 pub fn set_narwhal_new_leader_election_schedule_for_testing(&mut self, val: bool) {
4383 self.feature_flags.narwhal_new_leader_election_schedule = val;
4384 }
4385
4386 pub fn set_receive_object_for_testing(&mut self, val: bool) {
4387 self.feature_flags.receive_objects = val
4388 }
4389 pub fn set_narwhal_certificate_v2_for_testing(&mut self, val: bool) {
4390 self.feature_flags.narwhal_certificate_v2 = val
4391 }
4392 pub fn set_verify_legacy_zklogin_address_for_testing(&mut self, val: bool) {
4393 self.feature_flags.verify_legacy_zklogin_address = val
4394 }
4395
4396 pub fn set_per_object_congestion_control_mode_for_testing(
4397 &mut self,
4398 val: PerObjectCongestionControlMode,
4399 ) {
4400 self.feature_flags.per_object_congestion_control_mode = val;
4401 }
4402
4403 pub fn set_consensus_choice_for_testing(&mut self, val: ConsensusChoice) {
4404 self.feature_flags.consensus_choice = val;
4405 }
4406
4407 pub fn set_consensus_network_for_testing(&mut self, val: ConsensusNetwork) {
4408 self.feature_flags.consensus_network = val;
4409 }
4410
4411 pub fn set_zklogin_max_epoch_upper_bound_delta_for_testing(&mut self, val: Option<u64>) {
4412 self.feature_flags.zklogin_max_epoch_upper_bound_delta = val
4413 }
4414
4415 pub fn set_disable_bridge_for_testing(&mut self) {
4416 self.feature_flags.bridge = false
4417 }
4418
4419 pub fn set_mysticeti_num_leaders_per_round_for_testing(&mut self, val: Option<usize>) {
4420 self.feature_flags.mysticeti_num_leaders_per_round = val;
4421 }
4422
4423 pub fn set_enable_soft_bundle_for_testing(&mut self, val: bool) {
4424 self.feature_flags.soft_bundle = val;
4425 }
4426
4427 pub fn set_passkey_auth_for_testing(&mut self, val: bool) {
4428 self.feature_flags.passkey_auth = val
4429 }
4430
4431 pub fn set_enable_party_transfer_for_testing(&mut self, val: bool) {
4432 self.feature_flags.enable_party_transfer = val
4433 }
4434
4435 pub fn set_consensus_distributed_vote_scoring_strategy_for_testing(&mut self, val: bool) {
4436 self.feature_flags
4437 .consensus_distributed_vote_scoring_strategy = val;
4438 }
4439
4440 pub fn set_consensus_round_prober_for_testing(&mut self, val: bool) {
4441 self.feature_flags.consensus_round_prober = val;
4442 }
4443
4444 pub fn set_disallow_new_modules_in_deps_only_packages_for_testing(&mut self, val: bool) {
4445 self.feature_flags
4446 .disallow_new_modules_in_deps_only_packages = val;
4447 }
4448
4449 pub fn set_correct_gas_payment_limit_check_for_testing(&mut self, val: bool) {
4450 self.feature_flags.correct_gas_payment_limit_check = val;
4451 }
4452
4453 pub fn set_consensus_round_prober_probe_accepted_rounds(&mut self, val: bool) {
4454 self.feature_flags
4455 .consensus_round_prober_probe_accepted_rounds = val;
4456 }
4457
4458 pub fn set_mysticeti_fastpath_for_testing(&mut self, val: bool) {
4459 self.feature_flags.mysticeti_fastpath = val;
4460 }
4461
4462 pub fn set_accept_passkey_in_multisig_for_testing(&mut self, val: bool) {
4463 self.feature_flags.accept_passkey_in_multisig = val;
4464 }
4465
4466 pub fn set_consensus_batched_block_sync_for_testing(&mut self, val: bool) {
4467 self.feature_flags.consensus_batched_block_sync = val;
4468 }
4469
4470 pub fn set_enable_ptb_execution_v2_for_testing(&mut self, val: bool) {
4471 self.feature_flags.enable_ptb_execution_v2 = val;
4472 if val {
4475 self.translation_per_command_base_charge = Some(1);
4476 self.translation_per_input_base_charge = Some(1);
4477 self.translation_pure_input_per_byte_charge = Some(1);
4478 self.translation_per_type_node_charge = Some(1);
4479 self.translation_per_reference_node_charge = Some(1);
4480 self.translation_metering_step_resolution = Some(1000);
4481 self.translation_per_linkage_entry_charge = Some(10);
4482 }
4483 }
4484
4485 pub fn set_record_time_estimate_processed_for_testing(&mut self, val: bool) {
4486 self.feature_flags.record_time_estimate_processed = val;
4487 }
4488
4489 pub fn set_prepend_prologue_tx_in_consensus_commit_in_checkpoints_for_testing(
4490 &mut self,
4491 val: bool,
4492 ) {
4493 self.feature_flags
4494 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = val;
4495 }
4496
4497 pub fn enable_accumulators_for_testing(&mut self) {
4498 self.feature_flags.enable_accumulators = true;
4499 }
4500
4501 pub fn create_root_accumulator_object_for_testing(&mut self) {
4502 self.feature_flags.create_root_accumulator_object = true;
4503 }
4504
4505 pub fn enable_address_balance_gas_payments_for_testing(&mut self) {
4506 self.feature_flags.enable_accumulators = true;
4507 self.feature_flags.allow_private_accumulator_entrypoints = true;
4508 self.feature_flags.enable_address_balance_gas_payments = true;
4509 }
4510
4511 pub fn enable_authenticated_event_streams_for_testing(&mut self) {
4512 self.enable_accumulators_for_testing();
4513 self.feature_flags.enable_authenticated_event_streams = true;
4514 }
4515
4516 pub fn enable_non_exclusive_writes_for_testing(&mut self) {
4517 self.feature_flags.enable_non_exclusive_writes = true;
4518 }
4519
4520 pub fn set_ignore_execution_time_observations_after_certs_closed_for_testing(
4521 &mut self,
4522 val: bool,
4523 ) {
4524 self.feature_flags
4525 .ignore_execution_time_observations_after_certs_closed = val;
4526 }
4527
4528 pub fn set_consensus_checkpoint_signature_key_includes_digest_for_testing(
4529 &mut self,
4530 val: bool,
4531 ) {
4532 self.feature_flags
4533 .consensus_checkpoint_signature_key_includes_digest = val;
4534 }
4535
4536 pub fn set_cancel_for_failed_dkg_early_for_testing(&mut self, val: bool) {
4537 self.feature_flags.cancel_for_failed_dkg_early = val;
4538 }
4539
4540 pub fn set_use_mfp_txns_in_load_initial_object_debts_for_testing(&mut self, val: bool) {
4541 self.feature_flags.use_mfp_txns_in_load_initial_object_debts = val;
4542 }
4543
4544 pub fn set_authority_capabilities_v2_for_testing(&mut self, val: bool) {
4545 self.feature_flags.authority_capabilities_v2 = val;
4546 }
4547
4548 pub fn allow_references_in_ptbs_for_testing(&mut self) {
4549 self.feature_flags.allow_references_in_ptbs = true;
4550 }
4551}
4552
4553type OverrideFn = dyn Fn(ProtocolVersion, ProtocolConfig) -> ProtocolConfig + Send;
4554
4555thread_local! {
4556 static CONFIG_OVERRIDE: RefCell<Option<Box<OverrideFn>>> = RefCell::new(None);
4557}
4558
4559#[must_use]
4560pub struct OverrideGuard;
4561
4562impl Drop for OverrideGuard {
4563 fn drop(&mut self) {
4564 info!("restoring override fn");
4565 CONFIG_OVERRIDE.with(|ovr| {
4566 *ovr.borrow_mut() = None;
4567 });
4568 }
4569}
4570
4571#[derive(PartialEq, Eq)]
4574pub enum LimitThresholdCrossed {
4575 None,
4576 Soft(u128, u128),
4577 Hard(u128, u128),
4578}
4579
4580pub fn check_limit_in_range<T: Into<V>, U: Into<V>, V: PartialOrd + Into<u128>>(
4583 x: T,
4584 soft_limit: U,
4585 hard_limit: V,
4586) -> LimitThresholdCrossed {
4587 let x: V = x.into();
4588 let soft_limit: V = soft_limit.into();
4589
4590 debug_assert!(soft_limit <= hard_limit);
4591
4592 if x >= hard_limit {
4595 LimitThresholdCrossed::Hard(x.into(), hard_limit.into())
4596 } else if x < soft_limit {
4597 LimitThresholdCrossed::None
4598 } else {
4599 LimitThresholdCrossed::Soft(x.into(), soft_limit.into())
4600 }
4601}
4602
4603#[macro_export]
4604macro_rules! check_limit {
4605 ($x:expr, $hard:expr) => {
4606 check_limit!($x, $hard, $hard)
4607 };
4608 ($x:expr, $soft:expr, $hard:expr) => {
4609 check_limit_in_range($x as u64, $soft, $hard)
4610 };
4611}
4612
4613#[macro_export]
4617macro_rules! check_limit_by_meter {
4618 ($is_metered:expr, $x:expr, $metered_limit:expr, $unmetered_hard_limit:expr, $metric:expr) => {{
4619 let (h, metered_str) = if $is_metered {
4621 ($metered_limit, "metered")
4622 } else {
4623 ($unmetered_hard_limit, "unmetered")
4625 };
4626 use sui_protocol_config::check_limit_in_range;
4627 let result = check_limit_in_range($x as u64, $metered_limit, h);
4628 match result {
4629 LimitThresholdCrossed::None => {}
4630 LimitThresholdCrossed::Soft(_, _) => {
4631 $metric.with_label_values(&[metered_str, "soft"]).inc();
4632 }
4633 LimitThresholdCrossed::Hard(_, _) => {
4634 $metric.with_label_values(&[metered_str, "hard"]).inc();
4635 }
4636 };
4637 result
4638 }};
4639}
4640
4641pub fn is_mysticeti_fpc_enabled_in_env() -> Option<bool> {
4642 if let Ok(v) = std::env::var("CONSENSUS") {
4643 if v == "mysticeti_fpc" {
4644 return Some(true);
4645 } else if v == "mysticeti" {
4646 return Some(false);
4647 }
4648 }
4649 None
4650}
4651
4652#[cfg(all(test, not(msim)))]
4653mod test {
4654 use insta::assert_yaml_snapshot;
4655
4656 use super::*;
4657
4658 #[test]
4659 fn snapshot_tests() {
4660 println!("\n============================================================================");
4661 println!("! !");
4662 println!("! IMPORTANT: never update snapshots from this test. only add new versions! !");
4663 println!("! !");
4664 println!("============================================================================\n");
4665 for chain_id in &[Chain::Unknown, Chain::Mainnet, Chain::Testnet] {
4666 let chain_str = match chain_id {
4670 Chain::Unknown => "".to_string(),
4671 _ => format!("{:?}_", chain_id),
4672 };
4673 for i in MIN_PROTOCOL_VERSION..=MAX_PROTOCOL_VERSION {
4674 let cur = ProtocolVersion::new(i);
4675 assert_yaml_snapshot!(
4676 format!("{}version_{}", chain_str, cur.as_u64()),
4677 ProtocolConfig::get_for_version(cur, *chain_id)
4678 );
4679 }
4680 }
4681 }
4682
4683 #[test]
4684 fn test_getters() {
4685 let prot: ProtocolConfig =
4686 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
4687 assert_eq!(
4688 prot.max_arguments(),
4689 prot.max_arguments_as_option().unwrap()
4690 );
4691 }
4692
4693 #[test]
4694 fn test_setters() {
4695 let mut prot: ProtocolConfig =
4696 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
4697 prot.set_max_arguments_for_testing(123);
4698 assert_eq!(prot.max_arguments(), 123);
4699
4700 prot.set_max_arguments_from_str_for_testing("321".to_string());
4701 assert_eq!(prot.max_arguments(), 321);
4702
4703 prot.disable_max_arguments_for_testing();
4704 assert_eq!(prot.max_arguments_as_option(), None);
4705
4706 prot.set_attr_for_testing("max_arguments".to_string(), "456".to_string());
4707 assert_eq!(prot.max_arguments(), 456);
4708 }
4709
4710 #[test]
4711 #[should_panic(expected = "unsupported version")]
4712 fn max_version_test() {
4713 let _ = ProtocolConfig::get_for_version_impl(
4716 ProtocolVersion::new(MAX_PROTOCOL_VERSION + 1),
4717 Chain::Unknown,
4718 );
4719 }
4720
4721 #[test]
4722 fn lookup_by_string_test() {
4723 let prot: ProtocolConfig =
4724 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
4725 assert!(prot.lookup_attr("some random string".to_string()).is_none());
4727
4728 assert!(
4729 prot.lookup_attr("max_arguments".to_string())
4730 == Some(ProtocolConfigValue::u32(prot.max_arguments())),
4731 );
4732
4733 assert!(
4735 prot.lookup_attr("max_move_identifier_len".to_string())
4736 .is_none()
4737 );
4738
4739 let prot: ProtocolConfig =
4741 ProtocolConfig::get_for_version(ProtocolVersion::new(9), Chain::Unknown);
4742 assert!(
4743 prot.lookup_attr("max_move_identifier_len".to_string())
4744 == Some(ProtocolConfigValue::u64(prot.max_move_identifier_len()))
4745 );
4746
4747 let prot: ProtocolConfig =
4748 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
4749 assert!(
4751 prot.attr_map()
4752 .get("max_move_identifier_len")
4753 .unwrap()
4754 .is_none()
4755 );
4756 assert!(
4758 prot.attr_map().get("max_arguments").unwrap()
4759 == &Some(ProtocolConfigValue::u32(prot.max_arguments()))
4760 );
4761
4762 let prot: ProtocolConfig =
4764 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
4765 assert!(
4767 prot.feature_flags
4768 .lookup_attr("some random string".to_owned())
4769 .is_none()
4770 );
4771 assert!(
4772 !prot
4773 .feature_flags
4774 .attr_map()
4775 .contains_key("some random string")
4776 );
4777
4778 assert!(
4780 prot.feature_flags
4781 .lookup_attr("package_upgrades".to_owned())
4782 == Some(false)
4783 );
4784 assert!(
4785 prot.feature_flags
4786 .attr_map()
4787 .get("package_upgrades")
4788 .unwrap()
4789 == &false
4790 );
4791 let prot: ProtocolConfig =
4792 ProtocolConfig::get_for_version(ProtocolVersion::new(4), Chain::Unknown);
4793 assert!(
4795 prot.feature_flags
4796 .lookup_attr("package_upgrades".to_owned())
4797 == Some(true)
4798 );
4799 assert!(
4800 prot.feature_flags
4801 .attr_map()
4802 .get("package_upgrades")
4803 .unwrap()
4804 == &true
4805 );
4806 }
4807
4808 #[test]
4809 fn limit_range_fn_test() {
4810 let low = 100u32;
4811 let high = 10000u64;
4812
4813 assert!(check_limit!(1u8, low, high) == LimitThresholdCrossed::None);
4814 assert!(matches!(
4815 check_limit!(255u16, low, high),
4816 LimitThresholdCrossed::Soft(255u128, 100)
4817 ));
4818 assert!(matches!(
4824 check_limit!(2550000u64, low, high),
4825 LimitThresholdCrossed::Hard(2550000, 10000)
4826 ));
4827
4828 assert!(matches!(
4829 check_limit!(2550000u64, high, high),
4830 LimitThresholdCrossed::Hard(2550000, 10000)
4831 ));
4832
4833 assert!(matches!(
4834 check_limit!(1u8, high),
4835 LimitThresholdCrossed::None
4836 ));
4837
4838 assert!(check_limit!(255u16, high) == LimitThresholdCrossed::None);
4839
4840 assert!(matches!(
4841 check_limit!(2550000u64, high),
4842 LimitThresholdCrossed::Hard(2550000, 10000)
4843 ));
4844 }
4845}