1use std::{
6 cell::RefCell,
7 cmp::min,
8 sync::atomic::{AtomicBool, Ordering},
9};
10
11use clap::*;
12use iota_protocol_config_macros::{
13 ProtocolConfigAccessors, ProtocolConfigFeatureFlagsGetters, ProtocolConfigOverride,
14};
15use move_vm_config::verifier::{MeterConfig, VerifierConfig};
16use serde::{Deserialize, Serialize};
17use serde_with::skip_serializing_none;
18use tracing::{info, warn};
19
20const MIN_PROTOCOL_VERSION: u64 = 1;
22pub const MAX_PROTOCOL_VERSION: u64 = 35;
23
24pub const PROTOCOL_VERSION_IIP8: u64 = 20;
26#[derive(Copy, Clone, Debug, Hash, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)]
231pub struct ProtocolVersion(u64);
232
233impl ProtocolVersion {
234 pub const MIN: Self = Self(MIN_PROTOCOL_VERSION);
240
241 pub const MAX: Self = Self(MAX_PROTOCOL_VERSION);
242
243 #[cfg(not(msim))]
244 const MAX_ALLOWED: Self = Self::MAX;
245
246 #[cfg(msim)]
249 pub const MAX_ALLOWED: Self = Self(MAX_PROTOCOL_VERSION + 1);
250
251 pub fn new(v: u64) -> Self {
252 Self(v)
253 }
254
255 pub const fn as_u64(&self) -> u64 {
256 self.0
257 }
258
259 pub fn max() -> Self {
262 Self::MAX
263 }
264}
265
266impl From<u64> for ProtocolVersion {
267 fn from(v: u64) -> Self {
268 Self::new(v)
269 }
270}
271
272impl std::ops::Sub<u64> for ProtocolVersion {
273 type Output = Self;
274 fn sub(self, rhs: u64) -> Self::Output {
275 Self::new(self.0 - rhs)
276 }
277}
278
279impl std::ops::Add<u64> for ProtocolVersion {
280 type Output = Self;
281 fn add(self, rhs: u64) -> Self::Output {
282 Self::new(self.0 + rhs)
283 }
284}
285
286#[derive(
287 Clone, Serialize, Deserialize, Debug, PartialEq, Copy, PartialOrd, Ord, Eq, ValueEnum, Default,
288)]
289pub enum Chain {
290 Mainnet,
291 Testnet,
292 #[default]
293 Unknown,
294}
295
296impl Chain {
297 pub fn as_str(self) -> &'static str {
298 match self {
299 Chain::Mainnet => "mainnet",
300 Chain::Testnet => "testnet",
301 Chain::Unknown => "unknown",
302 }
303 }
304}
305
306pub struct Error(pub String);
307
308#[derive(
312 Default,
313 Clone,
314 Serialize,
315 Deserialize,
316 Debug,
317 ProtocolConfigFeatureFlagsGetters,
318 ProtocolConfigOverride,
319)]
320struct FeatureFlags {
321 #[serde(skip_serializing_if = "is_true")]
327 disable_invariant_violation_check_in_swap_loc: bool,
328
329 #[serde(skip_serializing_if = "is_true")]
332 no_extraneous_module_bytes: bool,
333
334 #[serde(skip_serializing_if = "ConsensusTransactionOrdering::is_none")]
336 consensus_transaction_ordering: ConsensusTransactionOrdering,
337
338 #[serde(skip_serializing_if = "is_true")]
341 hardened_otw_check: bool,
342
343 #[serde(skip_serializing_if = "is_false")]
345 enable_poseidon: bool,
346
347 #[serde(skip_serializing_if = "is_false")]
349 enable_group_ops_native_function_msm: bool,
350
351 #[serde(skip_serializing_if = "PerObjectCongestionControlMode::is_none")]
353 per_object_congestion_control_mode: PerObjectCongestionControlMode,
354
355 #[serde(
357 default = "ConsensusChoice::mysticeti_deprecated",
358 skip_serializing_if = "ConsensusChoice::is_mysticeti_deprecated"
359 )]
360 consensus_choice: ConsensusChoice,
361
362 #[serde(skip_serializing_if = "ConsensusNetwork::is_tonic")]
364 consensus_network: ConsensusNetwork,
365
366 #[deprecated]
368 #[serde(skip_serializing_if = "Option::is_none")]
369 zklogin_max_epoch_upper_bound_delta: Option<u64>,
370
371 #[serde(skip_serializing_if = "is_false")]
373 enable_vdf: bool,
374
375 #[serde(skip_serializing_if = "is_false")]
377 passkey_auth: bool,
378
379 #[serde(skip_serializing_if = "is_true")]
382 rethrow_serialization_type_layout_errors: bool,
383
384 #[serde(skip_serializing_if = "is_false")]
386 relocate_event_module: bool,
387
388 #[serde(skip_serializing_if = "is_false")]
390 protocol_defined_base_fee: bool,
391
392 #[serde(skip_serializing_if = "is_false")]
394 uncompressed_g1_group_elements: bool,
395
396 #[serde(skip_serializing_if = "is_false")]
398 disallow_new_modules_in_deps_only_packages: bool,
399
400 #[serde(skip_serializing_if = "is_false")]
402 native_charging_v2: bool,
403
404 #[serde(skip_serializing_if = "is_false")]
406 convert_type_argument_error: bool,
407
408 #[serde(skip_serializing_if = "is_false")]
410 consensus_round_prober: bool,
411
412 #[serde(skip_serializing_if = "is_false")]
414 consensus_distributed_vote_scoring_strategy: bool,
415
416 #[serde(skip_serializing_if = "is_false")]
420 consensus_linearize_subdag_v2: bool,
421
422 #[serde(skip_serializing_if = "is_false")]
424 variant_nodes: bool,
425
426 #[serde(skip_serializing_if = "is_false")]
428 consensus_smart_ancestor_selection: bool,
429
430 #[serde(skip_serializing_if = "is_false")]
432 consensus_round_prober_probe_accepted_rounds: bool,
433
434 #[serde(skip_serializing_if = "is_false")]
436 consensus_zstd_compression: bool,
437
438 #[serde(skip_serializing_if = "is_false")]
441 congestion_control_min_free_execution_slot: bool,
442
443 #[serde(skip_serializing_if = "is_false")]
445 accept_passkey_in_multisig: bool,
446
447 #[serde(skip_serializing_if = "is_false")]
449 consensus_batched_block_sync: bool,
450
451 #[serde(skip_serializing_if = "is_false")]
454 congestion_control_gas_price_feedback_mechanism: bool,
455
456 #[serde(skip_serializing_if = "is_false")]
458 validate_identifier_inputs: bool,
459
460 #[serde(skip_serializing_if = "is_false")]
463 minimize_child_object_mutations: bool,
464
465 #[serde(skip_serializing_if = "is_false")]
467 dependency_linkage_error: bool,
468
469 #[serde(skip_serializing_if = "is_false")]
471 additional_multisig_checks: bool,
472
473 #[serde(skip_serializing_if = "is_false")]
476 normalize_ptb_arguments: bool,
477
478 #[serde(skip_serializing_if = "is_false")]
482 select_committee_from_eligible_validators: bool,
483
484 #[serde(skip_serializing_if = "is_false")]
491 track_non_committee_eligible_validators: bool,
492
493 #[serde(skip_serializing_if = "is_false")]
499 select_committee_supporting_next_epoch_version: bool,
500
501 #[serde(skip_serializing_if = "is_false")]
505 consensus_median_timestamp_with_checkpoint_enforcement: bool,
506
507 #[serde(skip_serializing_if = "is_false")]
509 consensus_commit_transactions_only_for_traversed_headers: bool,
510
511 #[serde(skip_serializing_if = "is_false")]
513 congestion_limit_overshoot_in_gas_price_feedback_mechanism: bool,
514
515 #[serde(skip_serializing_if = "is_false")]
518 separate_gas_price_feedback_mechanism_for_randomness: bool,
519
520 #[serde(skip_serializing_if = "is_false")]
523 metadata_in_module_bytes: bool,
524
525 #[serde(skip_serializing_if = "is_false")]
527 publish_package_metadata: bool,
528
529 #[serde(skip_serializing_if = "is_false")]
531 enable_move_authentication: bool,
532
533 #[serde(skip_serializing_if = "is_false")]
535 enable_move_authentication_for_sponsor: bool,
536
537 #[serde(skip_serializing_if = "is_false")]
539 pass_validator_scores_to_advance_epoch: bool,
540
541 #[serde(skip_serializing_if = "is_false")]
543 calculate_validator_scores: bool,
544
545 #[serde(skip_serializing_if = "is_false")]
547 adjust_rewards_by_score: bool,
548
549 #[serde(skip_serializing_if = "is_false")]
552 pass_calculated_validator_scores_to_advance_epoch: bool,
553
554 #[serde(skip_serializing_if = "is_false")]
559 consensus_fast_commit_sync: bool,
560
561 #[serde(skip_serializing_if = "is_false")]
564 consensus_block_restrictions: bool,
565
566 #[serde(skip_serializing_if = "is_false")]
568 move_native_tx_context: bool,
569
570 #[serde(skip_serializing_if = "is_false")]
572 additional_borrow_checks: bool,
573
574 #[serde(skip_serializing_if = "is_false")]
576 pre_consensus_sponsor_only_move_authentication: bool,
577
578 #[serde(skip_serializing_if = "is_false")]
580 consensus_starfish_speed: bool,
581
582 #[serde(skip_serializing_if = "is_false")]
589 always_advance_dkg_to_resolution: bool,
590
591 #[serde(skip_serializing_if = "is_false")]
596 enable_pcool_flow: bool,
597
598 #[serde(skip_serializing_if = "is_false")]
603 pcool_skip_immutable_object_locks: bool,
604
605 #[serde(skip_serializing_if = "is_false")]
610 pcool_verifier_limits_from_protocol_config: bool,
611
612 #[serde(skip_serializing_if = "is_false")]
614 validator_metadata_verify_v2: bool,
615
616 #[serde(skip_serializing_if = "is_false")]
620 deny_rule_governance: bool,
621
622 #[serde(skip_serializing_if = "is_false")]
627 deny_rule_governance_on_chain: bool,
628
629 #[serde(skip_serializing_if = "is_false")]
632 package_metadata_with_dynamic_module_metadata: bool,
633
634 #[serde(skip_serializing_if = "is_false")]
637 report_move_authentication_error: bool,
638
639 #[serde(skip_serializing_if = "is_false")]
644 consensus_enable_sliding_window_leader_schedule: bool,
645
646 #[serde(skip_serializing_if = "is_false")]
651 consensus_enable_absolute_score_leader_schedule: bool,
652
653 #[serde(skip_serializing_if = "is_false")]
655 max_ptb_value_size_v2: bool,
656
657 #[serde(skip_serializing_if = "is_false")]
659 allow_unbounded_system_objects: bool,
660}
661
662fn is_true(b: &bool) -> bool {
663 *b
664}
665
666fn is_false(b: &bool) -> bool {
667 !b
668}
669
670#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
672pub enum ConsensusTransactionOrdering {
673 #[default]
676 None,
677 ByGasPrice,
679}
680
681impl ConsensusTransactionOrdering {
682 pub fn is_none(&self) -> bool {
683 matches!(self, ConsensusTransactionOrdering::None)
684 }
685}
686
687#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
689pub enum PerObjectCongestionControlMode {
690 #[default]
691 None, TotalGasBudget, TotalTxCount, }
695
696impl PerObjectCongestionControlMode {
697 pub fn is_none(&self) -> bool {
698 matches!(self, PerObjectCongestionControlMode::None)
699 }
700}
701
702#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
704pub enum ConsensusChoice {
705 #[deprecated(note = "Mysticeti was replaced by Starfish")]
708 MysticetiDeprecated,
709 #[default]
710 Starfish,
711}
712
713#[expect(deprecated)]
714impl ConsensusChoice {
715 fn mysticeti_deprecated() -> Self {
722 ConsensusChoice::MysticetiDeprecated
723 }
724
725 pub fn is_mysticeti_deprecated(&self) -> bool {
726 matches!(self, ConsensusChoice::MysticetiDeprecated)
727 }
728 pub fn is_starfish(&self) -> bool {
729 matches!(self, ConsensusChoice::Starfish)
730 }
731}
732
733#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
735pub enum ConsensusNetwork {
736 #[default]
737 Tonic,
738}
739
740impl ConsensusNetwork {
741 pub fn is_tonic(&self) -> bool {
742 matches!(self, ConsensusNetwork::Tonic)
743 }
744}
745
746#[skip_serializing_none]
780#[derive(Clone, Serialize, Debug, ProtocolConfigAccessors, ProtocolConfigOverride)]
781pub struct ProtocolConfig {
782 pub version: ProtocolVersion,
783
784 feature_flags: FeatureFlags,
785
786 max_tx_size_bytes: Option<u64>,
791
792 max_input_objects: Option<u64>,
795
796 max_size_written_objects: Option<u64>,
801 max_size_written_objects_system_tx: Option<u64>,
805
806 max_serialized_tx_effects_size_bytes: Option<u64>,
808
809 max_serialized_tx_effects_size_bytes_system_tx: Option<u64>,
811
812 max_gas_payment_objects: Option<u32>,
814
815 max_modules_in_publish: Option<u32>,
817
818 max_package_dependencies: Option<u32>,
820
821 max_arguments: Option<u32>,
824
825 max_type_arguments: Option<u32>,
827
828 max_type_argument_depth: Option<u32>,
830
831 max_pure_argument_size: Option<u32>,
833
834 max_programmable_tx_commands: Option<u32>,
836
837 move_binary_format_version: Option<u32>,
843 min_move_binary_format_version: Option<u32>,
844
845 binary_module_handles: Option<u16>,
847 binary_struct_handles: Option<u16>,
848 binary_function_handles: Option<u16>,
849 binary_function_instantiations: Option<u16>,
850 binary_signatures: Option<u16>,
851 binary_constant_pool: Option<u16>,
852 binary_identifiers: Option<u16>,
853 binary_address_identifiers: Option<u16>,
854 binary_struct_defs: Option<u16>,
855 binary_struct_def_instantiations: Option<u16>,
856 binary_function_defs: Option<u16>,
857 binary_field_handles: Option<u16>,
858 binary_field_instantiations: Option<u16>,
859 binary_friend_decls: Option<u16>,
860 binary_enum_defs: Option<u16>,
861 binary_enum_def_instantiations: Option<u16>,
862 binary_variant_handles: Option<u16>,
863 binary_variant_instantiation_handles: Option<u16>,
864
865 max_move_object_size: Option<u64>,
868
869 max_move_package_size: Option<u64>,
874
875 max_publish_or_upgrade_per_ptb: Option<u64>,
878
879 max_tx_gas: Option<u64>,
881
882 max_auth_gas: Option<u64>,
884
885 max_gas_price: Option<u64>,
888
889 max_gas_computation_bucket: Option<u64>,
892
893 gas_rounding_step: Option<u64>,
895
896 max_loop_depth: Option<u64>,
898
899 max_generic_instantiation_length: Option<u64>,
902
903 max_function_parameters: Option<u64>,
906
907 max_basic_blocks: Option<u64>,
910
911 max_value_stack_size: Option<u64>,
913
914 max_type_nodes: Option<u64>,
918
919 max_push_size: Option<u64>,
922
923 max_struct_definitions: Option<u64>,
926
927 max_function_definitions: Option<u64>,
930
931 max_fields_in_struct: Option<u64>,
934
935 max_dependency_depth: Option<u64>,
938
939 max_num_event_emit: Option<u64>,
942
943 max_num_new_move_object_ids: Option<u64>,
946
947 max_num_new_move_object_ids_system_tx: Option<u64>,
950
951 max_num_deleted_move_object_ids: Option<u64>,
954
955 max_num_deleted_move_object_ids_system_tx: Option<u64>,
958
959 max_num_transferred_move_object_ids: Option<u64>,
962
963 max_num_transferred_move_object_ids_system_tx: Option<u64>,
966
967 max_event_emit_size: Option<u64>,
969
970 max_event_emit_size_total: Option<u64>,
972
973 max_move_vector_len: Option<u64>,
976
977 max_move_identifier_len: Option<u64>,
980
981 max_move_value_depth: Option<u64>,
983
984 max_move_enum_variants: Option<u64>,
987
988 max_back_edges_per_function: Option<u64>,
997
998 max_back_edges_per_module: Option<u64>,
1000
1001 max_verifier_meter_ticks_per_function: Option<u64>,
1003
1004 max_meter_ticks_per_module: Option<u64>,
1006
1007 max_meter_ticks_per_package: Option<u64>,
1009
1010 max_meter_ticks_regex_reference_safety: Option<u64>,
1014
1015 object_runtime_max_num_cached_objects: Option<u64>,
1022
1023 object_runtime_max_num_cached_objects_system_tx: Option<u64>,
1026
1027 object_runtime_max_num_store_entries: Option<u64>,
1030
1031 object_runtime_max_num_store_entries_system_tx: Option<u64>,
1034
1035 base_tx_cost_fixed: Option<u64>,
1040
1041 package_publish_cost_fixed: Option<u64>,
1045
1046 base_tx_cost_per_byte: Option<u64>,
1050
1051 package_publish_cost_per_byte: Option<u64>,
1053
1054 obj_access_cost_read_per_byte: Option<u64>,
1056
1057 obj_access_cost_mutate_per_byte: Option<u64>,
1059
1060 obj_access_cost_delete_per_byte: Option<u64>,
1062
1063 obj_access_cost_verify_per_byte: Option<u64>,
1073
1074 max_type_to_layout_nodes: Option<u64>,
1076
1077 max_ptb_value_size: Option<u64>,
1079
1080 gas_model_version: Option<u64>,
1085
1086 obj_data_cost_refundable: Option<u64>,
1092
1093 obj_metadata_cost_non_refundable: Option<u64>,
1097
1098 storage_rebate_rate: Option<u64>,
1104
1105 reward_slashing_rate: Option<u64>,
1108
1109 storage_gas_price: Option<u64>,
1111
1112 base_gas_price: Option<u64>,
1114
1115 validator_target_reward: Option<u64>,
1117
1118 max_transactions_per_checkpoint: Option<u64>,
1125
1126 max_checkpoint_size_bytes: Option<u64>,
1130
1131 buffer_stake_for_protocol_upgrade_bps: Option<u64>,
1137
1138 address_from_bytes_cost_base: Option<u64>,
1143 address_to_u256_cost_base: Option<u64>,
1145 address_from_u256_cost_base: Option<u64>,
1147
1148 config_read_setting_impl_cost_base: Option<u64>,
1153 config_read_setting_impl_cost_per_byte: Option<u64>,
1154
1155 dynamic_field_hash_type_and_key_cost_base: Option<u64>,
1159 dynamic_field_hash_type_and_key_type_cost_per_byte: Option<u64>,
1160 dynamic_field_hash_type_and_key_value_cost_per_byte: Option<u64>,
1161 dynamic_field_hash_type_and_key_type_tag_cost_per_byte: Option<u64>,
1162 dynamic_field_add_child_object_cost_base: Option<u64>,
1165 dynamic_field_add_child_object_type_cost_per_byte: Option<u64>,
1166 dynamic_field_add_child_object_value_cost_per_byte: Option<u64>,
1167 dynamic_field_add_child_object_struct_tag_cost_per_byte: Option<u64>,
1168 dynamic_field_borrow_child_object_cost_base: Option<u64>,
1171 dynamic_field_borrow_child_object_child_ref_cost_per_byte: Option<u64>,
1172 dynamic_field_borrow_child_object_type_cost_per_byte: Option<u64>,
1173 dynamic_field_remove_child_object_cost_base: Option<u64>,
1176 dynamic_field_remove_child_object_child_cost_per_byte: Option<u64>,
1177 dynamic_field_remove_child_object_type_cost_per_byte: Option<u64>,
1178 dynamic_field_has_child_object_cost_base: Option<u64>,
1181 dynamic_field_has_child_object_with_ty_cost_base: Option<u64>,
1184 dynamic_field_has_child_object_with_ty_type_cost_per_byte: Option<u64>,
1185 dynamic_field_has_child_object_with_ty_type_tag_cost_per_byte: Option<u64>,
1186
1187 event_emit_cost_base: Option<u64>,
1190 event_emit_value_size_derivation_cost_per_byte: Option<u64>,
1191 event_emit_tag_size_derivation_cost_per_byte: Option<u64>,
1192 event_emit_output_cost_per_byte: Option<u64>,
1193
1194 object_borrow_uid_cost_base: Option<u64>,
1197 object_delete_impl_cost_base: Option<u64>,
1199 object_record_new_uid_cost_base: Option<u64>,
1201
1202 transfer_transfer_internal_cost_base: Option<u64>,
1205 transfer_freeze_object_cost_base: Option<u64>,
1207 transfer_share_object_cost_base: Option<u64>,
1209 transfer_receive_object_cost_base: Option<u64>,
1212
1213 tx_context_derive_id_cost_base: Option<u64>,
1216 tx_context_fresh_id_cost_base: Option<u64>,
1217 tx_context_sender_cost_base: Option<u64>,
1218 tx_context_digest_cost_base: Option<u64>,
1219 tx_context_epoch_cost_base: Option<u64>,
1220 tx_context_epoch_timestamp_ms_cost_base: Option<u64>,
1221 tx_context_sponsor_cost_base: Option<u64>,
1222 tx_context_rgp_cost_base: Option<u64>,
1223 tx_context_gas_price_cost_base: Option<u64>,
1224 tx_context_gas_budget_cost_base: Option<u64>,
1225 tx_context_ids_created_cost_base: Option<u64>,
1226 tx_context_replace_cost_base: Option<u64>,
1227
1228 types_is_one_time_witness_cost_base: Option<u64>,
1231 types_is_one_time_witness_type_tag_cost_per_byte: Option<u64>,
1232 types_is_one_time_witness_type_cost_per_byte: Option<u64>,
1233
1234 validator_validate_metadata_cost_base: Option<u64>,
1237 validator_validate_metadata_data_cost_per_byte: Option<u64>,
1238
1239 crypto_invalid_arguments_cost: Option<u64>,
1241 bls12381_bls12381_min_sig_verify_cost_base: Option<u64>,
1243 bls12381_bls12381_min_sig_verify_msg_cost_per_byte: Option<u64>,
1244 bls12381_bls12381_min_sig_verify_msg_cost_per_block: Option<u64>,
1245
1246 bls12381_bls12381_min_pk_verify_cost_base: Option<u64>,
1248 bls12381_bls12381_min_pk_verify_msg_cost_per_byte: Option<u64>,
1249 bls12381_bls12381_min_pk_verify_msg_cost_per_block: Option<u64>,
1250
1251 ecdsa_k1_ecrecover_keccak256_cost_base: Option<u64>,
1253 ecdsa_k1_ecrecover_keccak256_msg_cost_per_byte: Option<u64>,
1254 ecdsa_k1_ecrecover_keccak256_msg_cost_per_block: Option<u64>,
1255 ecdsa_k1_ecrecover_sha256_cost_base: Option<u64>,
1256 ecdsa_k1_ecrecover_sha256_msg_cost_per_byte: Option<u64>,
1257 ecdsa_k1_ecrecover_sha256_msg_cost_per_block: Option<u64>,
1258
1259 ecdsa_k1_decompress_pubkey_cost_base: Option<u64>,
1261
1262 ecdsa_k1_secp256k1_verify_keccak256_cost_base: Option<u64>,
1264 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_byte: Option<u64>,
1265 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_block: Option<u64>,
1266 ecdsa_k1_secp256k1_verify_sha256_cost_base: Option<u64>,
1267 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_byte: Option<u64>,
1268 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_block: Option<u64>,
1269
1270 ecdsa_r1_ecrecover_keccak256_cost_base: Option<u64>,
1272 ecdsa_r1_ecrecover_keccak256_msg_cost_per_byte: Option<u64>,
1273 ecdsa_r1_ecrecover_keccak256_msg_cost_per_block: Option<u64>,
1274 ecdsa_r1_ecrecover_sha256_cost_base: Option<u64>,
1275 ecdsa_r1_ecrecover_sha256_msg_cost_per_byte: Option<u64>,
1276 ecdsa_r1_ecrecover_sha256_msg_cost_per_block: Option<u64>,
1277
1278 ecdsa_r1_secp256r1_verify_keccak256_cost_base: Option<u64>,
1280 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_byte: Option<u64>,
1281 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_block: Option<u64>,
1282 ecdsa_r1_secp256r1_verify_sha256_cost_base: Option<u64>,
1283 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_byte: Option<u64>,
1284 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_block: Option<u64>,
1285
1286 ecvrf_ecvrf_verify_cost_base: Option<u64>,
1288 ecvrf_ecvrf_verify_alpha_string_cost_per_byte: Option<u64>,
1289 ecvrf_ecvrf_verify_alpha_string_cost_per_block: Option<u64>,
1290
1291 ed25519_ed25519_verify_cost_base: Option<u64>,
1293 ed25519_ed25519_verify_msg_cost_per_byte: Option<u64>,
1294 ed25519_ed25519_verify_msg_cost_per_block: Option<u64>,
1295
1296 groth16_prepare_verifying_key_bls12381_cost_base: Option<u64>,
1298 groth16_prepare_verifying_key_bn254_cost_base: Option<u64>,
1299
1300 groth16_verify_groth16_proof_internal_bls12381_cost_base: Option<u64>,
1302 groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input: Option<u64>,
1303 groth16_verify_groth16_proof_internal_bn254_cost_base: Option<u64>,
1304 groth16_verify_groth16_proof_internal_bn254_cost_per_public_input: Option<u64>,
1305 groth16_verify_groth16_proof_internal_public_input_cost_per_byte: Option<u64>,
1306
1307 hash_blake2b256_cost_base: Option<u64>,
1309 hash_blake2b256_data_cost_per_byte: Option<u64>,
1310 hash_blake2b256_data_cost_per_block: Option<u64>,
1311
1312 hash_keccak256_cost_base: Option<u64>,
1314 hash_keccak256_data_cost_per_byte: Option<u64>,
1315 hash_keccak256_data_cost_per_block: Option<u64>,
1316
1317 poseidon_bn254_cost_base: Option<u64>,
1319 poseidon_bn254_cost_per_block: Option<u64>,
1320
1321 group_ops_bls12381_decode_scalar_cost: Option<u64>,
1323 group_ops_bls12381_decode_g1_cost: Option<u64>,
1324 group_ops_bls12381_decode_g2_cost: Option<u64>,
1325 group_ops_bls12381_decode_gt_cost: Option<u64>,
1326 group_ops_bls12381_scalar_add_cost: Option<u64>,
1327 group_ops_bls12381_g1_add_cost: Option<u64>,
1328 group_ops_bls12381_g2_add_cost: Option<u64>,
1329 group_ops_bls12381_gt_add_cost: Option<u64>,
1330 group_ops_bls12381_scalar_sub_cost: Option<u64>,
1331 group_ops_bls12381_g1_sub_cost: Option<u64>,
1332 group_ops_bls12381_g2_sub_cost: Option<u64>,
1333 group_ops_bls12381_gt_sub_cost: Option<u64>,
1334 group_ops_bls12381_scalar_mul_cost: Option<u64>,
1335 group_ops_bls12381_g1_mul_cost: Option<u64>,
1336 group_ops_bls12381_g2_mul_cost: Option<u64>,
1337 group_ops_bls12381_gt_mul_cost: Option<u64>,
1338 group_ops_bls12381_scalar_div_cost: Option<u64>,
1339 group_ops_bls12381_g1_div_cost: Option<u64>,
1340 group_ops_bls12381_g2_div_cost: Option<u64>,
1341 group_ops_bls12381_gt_div_cost: Option<u64>,
1342 group_ops_bls12381_g1_hash_to_base_cost: Option<u64>,
1343 group_ops_bls12381_g2_hash_to_base_cost: Option<u64>,
1344 group_ops_bls12381_g1_hash_to_cost_per_byte: Option<u64>,
1345 group_ops_bls12381_g2_hash_to_cost_per_byte: Option<u64>,
1346 group_ops_bls12381_g1_msm_base_cost: Option<u64>,
1347 group_ops_bls12381_g2_msm_base_cost: Option<u64>,
1348 group_ops_bls12381_g1_msm_base_cost_per_input: Option<u64>,
1349 group_ops_bls12381_g2_msm_base_cost_per_input: Option<u64>,
1350 group_ops_bls12381_msm_max_len: Option<u32>,
1351 group_ops_bls12381_pairing_cost: Option<u64>,
1352 group_ops_bls12381_g1_to_uncompressed_g1_cost: Option<u64>,
1353 group_ops_bls12381_uncompressed_g1_to_g1_cost: Option<u64>,
1354 group_ops_bls12381_uncompressed_g1_sum_base_cost: Option<u64>,
1355 group_ops_bls12381_uncompressed_g1_sum_cost_per_term: Option<u64>,
1356 group_ops_bls12381_uncompressed_g1_sum_max_terms: Option<u64>,
1357
1358 hmac_hmac_sha3_256_cost_base: Option<u64>,
1360 hmac_hmac_sha3_256_input_cost_per_byte: Option<u64>,
1361 hmac_hmac_sha3_256_input_cost_per_block: Option<u64>,
1362
1363 #[deprecated]
1365 check_zklogin_id_cost_base: Option<u64>,
1366 #[deprecated]
1368 check_zklogin_issuer_cost_base: Option<u64>,
1369
1370 vdf_verify_vdf_cost: Option<u64>,
1371 vdf_hash_to_input_cost: Option<u64>,
1372
1373 bcs_per_byte_serialized_cost: Option<u64>,
1375 bcs_legacy_min_output_size_cost: Option<u64>,
1376 bcs_failure_cost: Option<u64>,
1377
1378 hash_sha2_256_base_cost: Option<u64>,
1379 hash_sha2_256_per_byte_cost: Option<u64>,
1380 hash_sha2_256_legacy_min_input_len_cost: Option<u64>,
1381 hash_sha3_256_base_cost: Option<u64>,
1382 hash_sha3_256_per_byte_cost: Option<u64>,
1383 hash_sha3_256_legacy_min_input_len_cost: Option<u64>,
1384 type_name_get_base_cost: Option<u64>,
1385 type_name_get_per_byte_cost: Option<u64>,
1386
1387 string_check_utf8_base_cost: Option<u64>,
1388 string_check_utf8_per_byte_cost: Option<u64>,
1389 string_is_char_boundary_base_cost: Option<u64>,
1390 string_sub_string_base_cost: Option<u64>,
1391 string_sub_string_per_byte_cost: Option<u64>,
1392 string_index_of_base_cost: Option<u64>,
1393 string_index_of_per_byte_pattern_cost: Option<u64>,
1394 string_index_of_per_byte_searched_cost: Option<u64>,
1395
1396 vector_empty_base_cost: Option<u64>,
1397 vector_length_base_cost: Option<u64>,
1398 vector_push_back_base_cost: Option<u64>,
1399 vector_push_back_legacy_per_abstract_memory_unit_cost: Option<u64>,
1400 vector_borrow_base_cost: Option<u64>,
1401 vector_pop_back_base_cost: Option<u64>,
1402 vector_destroy_empty_base_cost: Option<u64>,
1403 vector_swap_base_cost: Option<u64>,
1404 debug_print_base_cost: Option<u64>,
1405 debug_print_stack_trace_base_cost: Option<u64>,
1406
1407 execution_version: Option<u64>,
1409
1410 consensus_bad_nodes_stake_threshold: Option<u64>,
1414
1415 #[deprecated]
1416 max_jwk_votes_per_validator_per_epoch: Option<u64>,
1417 #[deprecated]
1421 max_age_of_jwk_in_epochs: Option<u64>,
1422
1423 random_beacon_reduction_allowed_delta: Option<u16>,
1427
1428 random_beacon_reduction_lower_bound: Option<u32>,
1431
1432 random_beacon_dkg_timeout_round: Option<u32>,
1435
1436 random_beacon_min_round_interval_ms: Option<u64>,
1438
1439 random_beacon_dkg_version: Option<u64>,
1443
1444 consensus_max_transaction_size_bytes: Option<u64>,
1449 consensus_max_transactions_in_block_bytes: Option<u64>,
1451 consensus_max_num_transactions_in_block: Option<u64>,
1453
1454 max_deferral_rounds_for_congestion_control: Option<u64>,
1458
1459 min_checkpoint_interval_ms: Option<u64>,
1461
1462 checkpoint_rate_window_size: Option<u64>,
1472
1473 checkpoint_summary_version_specific_data: Option<u64>,
1475
1476 max_soft_bundle_size: Option<u64>,
1479
1480 bridge_should_try_to_finalize_committee: Option<bool>,
1485
1486 max_accumulated_txn_cost_per_object_in_mysticeti_commit: Option<u64>,
1492
1493 max_committee_members_count: Option<u64>,
1497
1498 deny_rule_update_max_entries_per_tx: Option<u64>,
1503
1504 deny_rule_removal_grace_round_floor: Option<u64>,
1509
1510 consensus_gc_depth: Option<u32>,
1513
1514 consensus_max_acknowledgments_per_block: Option<u32>,
1520
1521 max_congestion_limit_overshoot_per_commit: Option<u64>,
1526
1527 max_concurrent_execution_workers: Option<u16>,
1534
1535 scorer_version: Option<u16>,
1544
1545 auth_context_digest_cost_base: Option<u64>,
1548 auth_context_tx_data_bytes_cost_base: Option<u64>,
1550 auth_context_tx_data_bytes_cost_per_byte: Option<u64>,
1551 auth_context_tx_commands_cost_base: Option<u64>,
1553 auth_context_tx_commands_cost_per_byte: Option<u64>,
1554 auth_context_tx_inputs_cost_base: Option<u64>,
1556 auth_context_tx_inputs_cost_per_byte: Option<u64>,
1557 auth_context_replace_cost_base: Option<u64>,
1560 auth_context_replace_cost_per_byte: Option<u64>,
1561 auth_context_authenticator_function_info_v1_cost_base: Option<u64>,
1565
1566 consensus_commits_per_schedule: Option<u32>,
1569
1570 min_validator_count: Option<u64>,
1573
1574 max_validator_count: Option<u64>,
1578
1579 min_validator_joining_stake: Option<u64>,
1583
1584 validator_low_stake_threshold: Option<u64>,
1589
1590 validator_very_low_stake_threshold: Option<u64>,
1594
1595 validator_low_stake_grace_period: Option<u64>,
1599
1600 consensus_leader_schedule_window_size: Option<u32>,
1604}
1605
1606impl ProtocolConfig {
1608 pub fn disable_invariant_violation_check_in_swap_loc(&self) -> bool {
1621 self.feature_flags
1622 .disable_invariant_violation_check_in_swap_loc
1623 }
1624
1625 pub fn no_extraneous_module_bytes(&self) -> bool {
1626 self.feature_flags.no_extraneous_module_bytes
1627 }
1628
1629 pub fn consensus_transaction_ordering(&self) -> ConsensusTransactionOrdering {
1630 self.feature_flags.consensus_transaction_ordering
1631 }
1632
1633 pub fn dkg_version(&self) -> u64 {
1634 self.random_beacon_dkg_version.unwrap_or(1)
1636 }
1637
1638 pub fn hardened_otw_check(&self) -> bool {
1639 self.feature_flags.hardened_otw_check
1640 }
1641
1642 pub fn enable_poseidon(&self) -> bool {
1643 self.feature_flags.enable_poseidon
1644 }
1645
1646 pub fn enable_group_ops_native_function_msm(&self) -> bool {
1647 self.feature_flags.enable_group_ops_native_function_msm
1648 }
1649
1650 pub fn per_object_congestion_control_mode(&self) -> PerObjectCongestionControlMode {
1651 self.feature_flags.per_object_congestion_control_mode
1652 }
1653
1654 pub fn consensus_choice(&self) -> ConsensusChoice {
1655 self.feature_flags.consensus_choice
1656 }
1657
1658 pub fn consensus_network(&self) -> ConsensusNetwork {
1659 self.feature_flags.consensus_network
1660 }
1661
1662 pub fn enable_vdf(&self) -> bool {
1663 self.feature_flags.enable_vdf
1664 }
1665
1666 pub fn passkey_auth(&self) -> bool {
1667 self.feature_flags.passkey_auth
1668 }
1669
1670 pub fn max_transaction_size_bytes(&self) -> u64 {
1671 self.consensus_max_transaction_size_bytes
1673 .unwrap_or(256 * 1024)
1674 }
1675
1676 pub fn max_transactions_in_block_bytes(&self) -> u64 {
1677 if cfg!(msim) {
1678 256 * 1024
1679 } else {
1680 self.consensus_max_transactions_in_block_bytes
1681 .unwrap_or(512 * 1024)
1682 }
1683 }
1684
1685 pub fn max_num_transactions_in_block(&self) -> u64 {
1686 if cfg!(msim) {
1687 8
1688 } else {
1689 self.consensus_max_num_transactions_in_block.unwrap_or(512)
1690 }
1691 }
1692
1693 pub fn rethrow_serialization_type_layout_errors(&self) -> bool {
1694 self.feature_flags.rethrow_serialization_type_layout_errors
1695 }
1696
1697 pub fn relocate_event_module(&self) -> bool {
1698 self.feature_flags.relocate_event_module
1699 }
1700
1701 pub fn protocol_defined_base_fee(&self) -> bool {
1702 self.feature_flags.protocol_defined_base_fee
1703 }
1704
1705 pub fn uncompressed_g1_group_elements(&self) -> bool {
1706 self.feature_flags.uncompressed_g1_group_elements
1707 }
1708
1709 pub fn disallow_new_modules_in_deps_only_packages(&self) -> bool {
1710 self.feature_flags
1711 .disallow_new_modules_in_deps_only_packages
1712 }
1713
1714 pub fn native_charging_v2(&self) -> bool {
1715 self.feature_flags.native_charging_v2
1716 }
1717
1718 pub fn consensus_round_prober(&self) -> bool {
1719 self.feature_flags.consensus_round_prober
1720 }
1721
1722 pub fn consensus_distributed_vote_scoring_strategy(&self) -> bool {
1723 self.feature_flags
1724 .consensus_distributed_vote_scoring_strategy
1725 }
1726
1727 pub fn gc_depth(&self) -> u32 {
1728 if cfg!(msim) {
1729 min(5, self.consensus_gc_depth.unwrap_or(0))
1731 } else {
1732 self.consensus_gc_depth.unwrap_or(0)
1733 }
1734 }
1735
1736 pub fn consensus_linearize_subdag_v2(&self) -> bool {
1737 let res = self.feature_flags.consensus_linearize_subdag_v2;
1738 assert!(
1739 !res || self.gc_depth() > 0,
1740 "The consensus linearize sub dag V2 requires GC to be enabled"
1741 );
1742 res
1743 }
1744
1745 pub fn consensus_max_acknowledgments_per_block_or_default(&self) -> u32 {
1746 self.consensus_max_acknowledgments_per_block.unwrap_or(400)
1747 }
1748
1749 pub fn max_acknowledgments_per_block(&self, committee_size: usize) -> usize {
1750 2 * committee_size
1751 }
1752
1753 pub fn max_commit_votes_per_block(&self, committee_size: usize) -> usize {
1754 committee_size
1755 }
1756
1757 pub fn variant_nodes(&self) -> bool {
1758 self.feature_flags.variant_nodes
1759 }
1760
1761 pub fn consensus_smart_ancestor_selection(&self) -> bool {
1762 self.feature_flags.consensus_smart_ancestor_selection
1763 }
1764
1765 pub fn consensus_round_prober_probe_accepted_rounds(&self) -> bool {
1766 self.feature_flags
1767 .consensus_round_prober_probe_accepted_rounds
1768 }
1769
1770 pub fn consensus_zstd_compression(&self) -> bool {
1771 self.feature_flags.consensus_zstd_compression
1772 }
1773
1774 pub fn congestion_control_min_free_execution_slot(&self) -> bool {
1775 self.feature_flags
1776 .congestion_control_min_free_execution_slot
1777 }
1778
1779 pub fn accept_passkey_in_multisig(&self) -> bool {
1780 self.feature_flags.accept_passkey_in_multisig
1781 }
1782
1783 pub fn consensus_batched_block_sync(&self) -> bool {
1784 self.feature_flags.consensus_batched_block_sync
1785 }
1786
1787 pub fn congestion_control_gas_price_feedback_mechanism(&self) -> bool {
1790 self.feature_flags
1791 .congestion_control_gas_price_feedback_mechanism
1792 }
1793
1794 pub fn validate_identifier_inputs(&self) -> bool {
1795 self.feature_flags.validate_identifier_inputs
1796 }
1797
1798 pub fn minimize_child_object_mutations(&self) -> bool {
1799 self.feature_flags.minimize_child_object_mutations
1800 }
1801
1802 pub fn dependency_linkage_error(&self) -> bool {
1803 self.feature_flags.dependency_linkage_error
1804 }
1805
1806 pub fn additional_multisig_checks(&self) -> bool {
1807 self.feature_flags.additional_multisig_checks
1808 }
1809
1810 pub fn consensus_num_requested_prior_commits_at_startup(&self) -> u32 {
1811 0
1814 }
1815
1816 pub fn normalize_ptb_arguments(&self) -> bool {
1817 self.feature_flags.normalize_ptb_arguments
1818 }
1819
1820 pub fn select_committee_from_eligible_validators(&self) -> bool {
1821 let res = self.feature_flags.select_committee_from_eligible_validators;
1822 assert!(
1823 !res || (self.protocol_defined_base_fee()
1824 && self.max_committee_members_count_as_option().is_some()),
1825 "select_committee_from_eligible_validators requires protocol_defined_base_fee and max_committee_members_count to be set"
1826 );
1827 res
1828 }
1829
1830 pub fn track_non_committee_eligible_validators(&self) -> bool {
1831 self.feature_flags.track_non_committee_eligible_validators
1832 }
1833
1834 pub fn select_committee_supporting_next_epoch_version(&self) -> bool {
1835 let res = self
1836 .feature_flags
1837 .select_committee_supporting_next_epoch_version;
1838 assert!(
1839 !res || (self.track_non_committee_eligible_validators()
1840 && self.select_committee_from_eligible_validators()),
1841 "select_committee_supporting_next_epoch_version requires select_committee_from_eligible_validators to be set"
1842 );
1843 res
1844 }
1845
1846 pub fn consensus_median_timestamp_with_checkpoint_enforcement(&self) -> bool {
1847 let res = self
1848 .feature_flags
1849 .consensus_median_timestamp_with_checkpoint_enforcement;
1850 assert!(
1851 !res || self.gc_depth() > 0,
1852 "The consensus median timestamp with checkpoint enforcement requires GC to be enabled"
1853 );
1854 res
1855 }
1856
1857 pub fn consensus_commit_transactions_only_for_traversed_headers(&self) -> bool {
1858 self.feature_flags
1859 .consensus_commit_transactions_only_for_traversed_headers
1860 }
1861
1862 pub fn congestion_limit_overshoot_in_gas_price_feedback_mechanism(&self) -> bool {
1865 self.feature_flags
1866 .congestion_limit_overshoot_in_gas_price_feedback_mechanism
1867 }
1868
1869 pub fn separate_gas_price_feedback_mechanism_for_randomness(&self) -> bool {
1872 self.feature_flags
1873 .separate_gas_price_feedback_mechanism_for_randomness
1874 }
1875
1876 pub fn metadata_in_module_bytes(&self) -> bool {
1877 self.feature_flags.metadata_in_module_bytes
1878 }
1879
1880 pub fn publish_package_metadata(&self) -> bool {
1881 self.feature_flags.publish_package_metadata
1882 }
1883
1884 pub fn enable_move_authentication(&self) -> bool {
1885 self.feature_flags.enable_move_authentication
1886 }
1887
1888 pub fn additional_borrow_checks(&self) -> bool {
1889 self.feature_flags.additional_borrow_checks
1890 }
1891
1892 pub fn enable_move_authentication_for_sponsor(&self) -> bool {
1893 let enable_move_authentication_for_sponsor =
1894 self.feature_flags.enable_move_authentication_for_sponsor;
1895 assert!(
1896 !enable_move_authentication_for_sponsor || self.enable_move_authentication(),
1897 "enable_move_authentication_for_sponsor requires enable_move_authentication to be set"
1898 );
1899 enable_move_authentication_for_sponsor
1900 }
1901
1902 pub fn pass_validator_scores_to_advance_epoch(&self) -> bool {
1903 self.feature_flags.pass_validator_scores_to_advance_epoch
1904 }
1905
1906 pub fn calculate_validator_scores(&self) -> bool {
1907 let calculate_validator_scores = self.feature_flags.calculate_validator_scores;
1908 assert!(
1909 !calculate_validator_scores || self.scorer_version.is_some(),
1910 "calculate_validator_scores requires scorer_version to be set"
1911 );
1912 calculate_validator_scores
1913 }
1914
1915 pub fn adjust_rewards_by_score(&self) -> bool {
1916 let adjust = self.feature_flags.adjust_rewards_by_score;
1917 assert!(
1918 !adjust || (self.scorer_version.is_some() && self.calculate_validator_scores()),
1919 "adjust_rewards_by_score requires scorer_version to be set"
1920 );
1921 adjust
1922 }
1923
1924 pub fn pass_calculated_validator_scores_to_advance_epoch(&self) -> bool {
1925 let pass = self
1926 .feature_flags
1927 .pass_calculated_validator_scores_to_advance_epoch;
1928 assert!(
1929 !pass
1930 || (self.pass_validator_scores_to_advance_epoch()
1931 && self.calculate_validator_scores()),
1932 "pass_calculated_validator_scores_to_advance_epoch requires pass_validator_scores_to_advance_epoch and calculate_validator_scores to be enabled"
1933 );
1934 pass
1935 }
1936 pub fn consensus_fast_commit_sync(&self) -> bool {
1937 let res = self.feature_flags.consensus_fast_commit_sync;
1938 assert!(
1939 !res || self.consensus_commit_transactions_only_for_traversed_headers(),
1940 "consensus_fast_commit_sync requires consensus_commit_transactions_only_for_traversed_headers to be enabled"
1941 );
1942 res
1943 }
1944
1945 pub fn consensus_block_restrictions(&self) -> bool {
1946 self.feature_flags.consensus_block_restrictions
1947 }
1948
1949 pub fn move_native_tx_context(&self) -> bool {
1950 self.feature_flags.move_native_tx_context
1951 }
1952
1953 pub fn pre_consensus_sponsor_only_move_authentication(&self) -> bool {
1954 let pre_consensus_sponsor_only_move_authentication = self
1955 .feature_flags
1956 .pre_consensus_sponsor_only_move_authentication;
1957 if pre_consensus_sponsor_only_move_authentication {
1958 assert!(
1959 self.enable_move_authentication(),
1960 "pre_consensus_sponsor_only_move_authentication requires enable_move_authentication to be set"
1961 );
1962 assert!(
1963 self.enable_move_authentication_for_sponsor(),
1964 "pre_consensus_sponsor_only_move_authentication requires enable_move_authentication_for_sponsor to be set"
1965 );
1966 }
1967 pre_consensus_sponsor_only_move_authentication
1968 }
1969
1970 pub fn consensus_starfish_speed(&self) -> bool {
1971 let res = self.feature_flags.consensus_starfish_speed;
1972 assert!(
1973 !res || self.consensus_fast_commit_sync(),
1974 "consensus_starfish_speed requires consensus_fast_commit_sync to be enabled"
1975 );
1976 res
1977 }
1978
1979 pub fn always_advance_dkg_to_resolution(&self) -> bool {
1980 self.feature_flags.always_advance_dkg_to_resolution
1981 }
1982
1983 pub fn enable_pcool_flow(&self) -> bool {
1984 self.feature_flags.enable_pcool_flow
1985 }
1986
1987 pub fn pcool_skip_immutable_object_locks(&self) -> bool {
1988 self.feature_flags.pcool_skip_immutable_object_locks
1989 }
1990
1991 pub fn pcool_verifier_limits_from_protocol_config(&self) -> bool {
1994 self.feature_flags
1995 .pcool_verifier_limits_from_protocol_config
1996 }
1997
1998 pub fn validator_metadata_verify_v2(&self) -> bool {
1999 self.feature_flags.validator_metadata_verify_v2
2000 }
2001
2002 pub fn commits_per_schedule(&self) -> u32 {
2003 let commits_per_schedule = if cfg!(msim) {
2004 min(10, self.consensus_commits_per_schedule.unwrap_or(300))
2006 } else {
2007 self.consensus_commits_per_schedule.unwrap_or(300)
2008 };
2009 assert!(
2010 commits_per_schedule > 0,
2011 "consensus_commits_per_schedule must be greater than 0"
2012 );
2013 commits_per_schedule
2014 }
2015
2016 pub fn leader_schedule_window_size(&self) -> u32 {
2017 if cfg!(msim) {
2018 min(
2021 20,
2022 self.consensus_leader_schedule_window_size.unwrap_or(600),
2023 )
2024 } else {
2025 self.consensus_leader_schedule_window_size.unwrap_or(600)
2026 }
2027 }
2028
2029 pub fn consensus_enable_sliding_window_leader_schedule(&self) -> bool {
2030 let res = self
2031 .feature_flags
2032 .consensus_enable_sliding_window_leader_schedule;
2033 assert!(
2034 !res || self.leader_schedule_window_size() >= self.commits_per_schedule(),
2035 "consensus_enable_sliding_window_leader_schedule requires window_size >= commits_per_schedule"
2036 );
2037 res
2038 }
2039
2040 pub fn consensus_enable_absolute_score_leader_schedule(&self) -> bool {
2041 self.feature_flags
2042 .consensus_enable_absolute_score_leader_schedule
2043 }
2044
2045 pub fn max_ptb_value_size_v2(&self) -> bool {
2046 self.feature_flags.max_ptb_value_size_v2
2047 }
2048
2049 pub fn deny_rule_governance(&self) -> bool {
2050 self.feature_flags.deny_rule_governance
2051 }
2052
2053 pub fn deny_rule_governance_on_chain(&self) -> bool {
2054 self.feature_flags.deny_rule_governance_on_chain
2055 }
2056
2057 pub fn package_metadata_with_dynamic_module_metadata(&self) -> bool {
2058 let res = self
2059 .feature_flags
2060 .package_metadata_with_dynamic_module_metadata;
2061 assert!(
2062 !res || self.publish_package_metadata(),
2063 "package_metadata_with_dynamic_module_metadata requires publish_package_metadata to be enabled"
2064 );
2065 res
2066 }
2067
2068 pub fn report_move_authentication_error(&self) -> bool {
2069 let report_move_authentication_error = self.feature_flags.report_move_authentication_error;
2070 assert!(
2071 !report_move_authentication_error || self.enable_move_authentication(),
2072 "report_move_authentication_error requires enable_move_authentication to be set"
2073 );
2074 report_move_authentication_error
2075 }
2076
2077 pub fn concurrent_execution_workers(&self) -> Option<u16> {
2081 let res = self.max_concurrent_execution_workers;
2082 assert!(
2083 res.is_none() || self.enable_pcool_flow(),
2084 "max_concurrent_execution_workers requires enable_pcool_flow to be enabled"
2085 );
2086 assert!(
2087 res.is_none()
2088 || self
2089 .max_accumulated_txn_cost_per_object_in_mysticeti_commit
2090 .is_some(),
2091 "max_concurrent_execution_workers requires per-object congestion control \
2092 (max_accumulated_txn_cost_per_object_in_mysticeti_commit) to be enabled"
2093 );
2094 assert!(
2095 res.is_none() || self.congestion_control_gas_price_feedback_mechanism(),
2096 "max_concurrent_execution_workers requires the gas price feedback mechanism \
2097 (congestion_control_gas_price_feedback_mechanism), which carries the suggested \
2098 gas price of an execution-worker congestion cancellation"
2099 );
2100 assert!(
2101 res.is_none() || !self.separate_gas_price_feedback_mechanism_for_randomness(),
2102 "max_concurrent_execution_workers implies a single congestion tracker and suggested \
2103 gas price calculator for all transactions, which is incompatible with \
2104 separate_gas_price_feedback_mechanism_for_randomness"
2105 );
2106 assert!(
2107 res != Some(0),
2108 "max_concurrent_execution_workers must be positive when set"
2109 );
2110 res
2111 }
2112
2113 pub fn allow_unbounded_system_objects(&self) -> bool {
2114 self.feature_flags.allow_unbounded_system_objects
2115 }
2116}
2117
2118#[cfg(not(msim))]
2119static POISON_VERSION_METHODS: AtomicBool = const { AtomicBool::new(false) };
2120
2121#[cfg(msim)]
2123thread_local! {
2124 static POISON_VERSION_METHODS: AtomicBool = const { AtomicBool::new(false) };
2125}
2126
2127impl ProtocolConfig {
2129 pub fn get_for_version(version: ProtocolVersion, chain: Chain) -> Self {
2132 assert!(
2134 version >= ProtocolVersion::MIN,
2135 "Network protocol version is {:?}, but the minimum supported version by the binary is {:?}. Please upgrade the binary.",
2136 version,
2137 ProtocolVersion::MIN.0,
2138 );
2139 assert!(
2140 version <= ProtocolVersion::MAX_ALLOWED,
2141 "Network protocol version is {:?}, but the maximum supported version by the binary is {:?}. Please upgrade the binary.",
2142 version,
2143 ProtocolVersion::MAX_ALLOWED.0,
2144 );
2145
2146 let mut ret = Self::get_for_version_impl(version, chain);
2147 ret.version = version;
2148
2149 ret = CONFIG_OVERRIDE.with(|ovr| {
2150 if let Some(override_fn) = &*ovr.borrow() {
2151 warn!(
2152 "overriding ProtocolConfig settings with custom settings (you should not see this log outside of tests)"
2153 );
2154 override_fn(version, ret)
2155 } else {
2156 ret
2157 }
2158 });
2159
2160 if std::env::var("IOTA_PROTOCOL_CONFIG_OVERRIDE_ENABLE").is_ok() {
2161 warn!(
2162 "overriding ProtocolConfig settings with custom settings; this may break non-local networks"
2163 );
2164
2165 let overrides: ProtocolConfigOptional =
2167 serde_env::from_env_with_prefix("IOTA_PROTOCOL_CONFIG_OVERRIDE")
2168 .expect("failed to parse ProtocolConfig override env variables");
2169 overrides.apply_to(&mut ret);
2170
2171 let feature_flag_overrides: FeatureFlagsOptional =
2173 serde_env::from_env_with_prefix("IOTA_PROTOCOL_CONFIG_FEATURE_FLAGS_OVERRIDE")
2174 .expect("failed to parse ProtocolConfig feature flags override env variables");
2175
2176 feature_flag_overrides.apply_to(&mut ret.feature_flags);
2177 }
2178
2179 assert!(
2181 !ret.feature_flags.deny_rule_governance_on_chain
2182 || ret.feature_flags.deny_rule_governance,
2183 "deny_rule_governance_on_chain requires deny_rule_governance"
2184 );
2185 assert!(
2190 !ret.feature_flags.pcool_verifier_limits_from_protocol_config
2191 || ret.max_meter_ticks_regex_reference_safety.is_some(),
2192 "pcool_verifier_limits_from_protocol_config requires \
2193 max_meter_ticks_regex_reference_safety"
2194 );
2195 assert!(
2198 !ret.feature_flags.deny_rule_governance_on_chain
2199 || (ret.deny_rule_update_max_entries_per_tx.is_some()
2200 && ret.deny_rule_removal_grace_round_floor.is_some()),
2201 "deny_rule_governance_on_chain requires deny_rule_update_max_entries_per_tx and deny_rule_removal_grace_round_floor"
2202 );
2203 const DENY_RULE_UPDATE_MAX_ENTRIES_PER_TX_CEILING: u64 = 2048;
2211 assert!(
2212 ret.deny_rule_update_max_entries_per_tx
2213 .is_none_or(|max_entries| {
2214 max_entries > 0
2215 && max_entries <= DENY_RULE_UPDATE_MAX_ENTRIES_PER_TX_CEILING
2216 && [
2217 ret.max_num_new_move_object_ids_system_tx,
2218 ret.max_num_deleted_move_object_ids_system_tx,
2219 ret.object_runtime_max_num_cached_objects_system_tx,
2220 ret.object_runtime_max_num_store_entries_system_tx,
2221 ]
2222 .iter()
2223 .all(|limit| limit.is_none_or(|limit| max_entries <= limit))
2224 }),
2225 "deny_rule_update_max_entries_per_tx must be positive, at most {DENY_RULE_UPDATE_MAX_ENTRIES_PER_TX_CEILING}, and within the system transaction object limits"
2226 );
2227
2228 ret
2229 }
2230
2231 pub fn get_for_version_if_supported(version: ProtocolVersion, chain: Chain) -> Option<Self> {
2234 if version.0 >= ProtocolVersion::MIN.0 && version.0 <= ProtocolVersion::MAX_ALLOWED.0 {
2235 let mut ret = Self::get_for_version_impl(version, chain);
2236 ret.version = version;
2237 Some(ret)
2238 } else {
2239 None
2240 }
2241 }
2242
2243 #[cfg(not(msim))]
2244 pub fn poison_get_for_min_version() {
2245 POISON_VERSION_METHODS.store(true, Ordering::Relaxed);
2246 }
2247
2248 #[cfg(not(msim))]
2249 fn load_poison_get_for_min_version() -> bool {
2250 POISON_VERSION_METHODS.load(Ordering::Relaxed)
2251 }
2252
2253 #[cfg(msim)]
2254 pub fn poison_get_for_min_version() {
2255 POISON_VERSION_METHODS.with(|p| p.store(true, Ordering::Relaxed));
2256 }
2257
2258 #[cfg(msim)]
2259 fn load_poison_get_for_min_version() -> bool {
2260 POISON_VERSION_METHODS.with(|p| p.load(Ordering::Relaxed))
2261 }
2262
2263 pub fn convert_type_argument_error(&self) -> bool {
2264 self.feature_flags.convert_type_argument_error
2265 }
2266
2267 pub fn get_for_min_version() -> Self {
2271 if Self::load_poison_get_for_min_version() {
2272 panic!("get_for_min_version called on validator");
2273 }
2274 ProtocolConfig::get_for_version(ProtocolVersion::MIN, Chain::Unknown)
2275 }
2276
2277 #[expect(non_snake_case)]
2288 pub fn get_for_max_version_UNSAFE() -> Self {
2289 if Self::load_poison_get_for_min_version() {
2290 panic!("get_for_max_version_UNSAFE called on validator");
2291 }
2292 ProtocolConfig::get_for_version(ProtocolVersion::MAX, Chain::Unknown)
2293 }
2294
2295 fn get_for_version_impl(version: ProtocolVersion, chain: Chain) -> Self {
2296 #[cfg(msim)]
2297 {
2298 if version > ProtocolVersion::MAX {
2300 let mut config = Self::get_for_version_impl(ProtocolVersion::MAX, Chain::Unknown);
2301 config.base_tx_cost_fixed = Some(config.base_tx_cost_fixed() + 1000);
2302 return config;
2303 }
2304 }
2305
2306 let mut cfg = Self {
2310 version,
2311
2312 feature_flags: Default::default(),
2313
2314 max_tx_size_bytes: Some(128 * 1024),
2315 max_input_objects: Some(2048),
2318 max_serialized_tx_effects_size_bytes: Some(512 * 1024),
2319 max_serialized_tx_effects_size_bytes_system_tx: Some(512 * 1024 * 16),
2320 max_gas_payment_objects: Some(256),
2321 max_modules_in_publish: Some(64),
2322 max_package_dependencies: Some(32),
2323 max_arguments: Some(512),
2324 max_type_arguments: Some(16),
2325 max_type_argument_depth: Some(16),
2326 max_pure_argument_size: Some(16 * 1024),
2327 max_programmable_tx_commands: Some(1024),
2328 move_binary_format_version: Some(7),
2329 min_move_binary_format_version: Some(6),
2330 binary_module_handles: Some(100),
2331 binary_struct_handles: Some(300),
2332 binary_function_handles: Some(1500),
2333 binary_function_instantiations: Some(750),
2334 binary_signatures: Some(1000),
2335 binary_constant_pool: Some(4000),
2336 binary_identifiers: Some(10000),
2337 binary_address_identifiers: Some(100),
2338 binary_struct_defs: Some(200),
2339 binary_struct_def_instantiations: Some(100),
2340 binary_function_defs: Some(1000),
2341 binary_field_handles: Some(500),
2342 binary_field_instantiations: Some(250),
2343 binary_friend_decls: Some(100),
2344 binary_enum_defs: None,
2345 binary_enum_def_instantiations: None,
2346 binary_variant_handles: None,
2347 binary_variant_instantiation_handles: None,
2348 max_move_object_size: Some(250 * 1024),
2349 max_move_package_size: Some(100 * 1024),
2350 max_publish_or_upgrade_per_ptb: Some(5),
2351 max_auth_gas: None,
2353 max_tx_gas: Some(50_000_000_000),
2355 max_gas_price: Some(100_000),
2356 max_gas_computation_bucket: Some(5_000_000),
2357 max_loop_depth: Some(5),
2358 max_generic_instantiation_length: Some(32),
2359 max_function_parameters: Some(128),
2360 max_basic_blocks: Some(1024),
2361 max_value_stack_size: Some(1024),
2362 max_type_nodes: Some(256),
2363 max_push_size: Some(10000),
2364 max_struct_definitions: Some(200),
2365 max_function_definitions: Some(1000),
2366 max_fields_in_struct: Some(32),
2367 max_dependency_depth: Some(100),
2368 max_num_event_emit: Some(1024),
2369 max_num_new_move_object_ids: Some(2048),
2370 max_num_new_move_object_ids_system_tx: Some(2048 * 16),
2371 max_num_deleted_move_object_ids: Some(2048),
2372 max_num_deleted_move_object_ids_system_tx: Some(2048 * 16),
2373 max_num_transferred_move_object_ids: Some(2048),
2374 max_num_transferred_move_object_ids_system_tx: Some(2048 * 16),
2375 max_event_emit_size: Some(250 * 1024),
2376 max_move_vector_len: Some(256 * 1024),
2377 max_type_to_layout_nodes: None,
2378 max_ptb_value_size: None,
2379
2380 max_back_edges_per_function: Some(10_000),
2381 max_back_edges_per_module: Some(10_000),
2382
2383 max_verifier_meter_ticks_per_function: Some(16_000_000),
2384
2385 max_meter_ticks_per_module: Some(16_000_000),
2386 max_meter_ticks_per_package: Some(16_000_000),
2387 max_meter_ticks_regex_reference_safety: None,
2388
2389 object_runtime_max_num_cached_objects: Some(1000),
2390 object_runtime_max_num_cached_objects_system_tx: Some(1000 * 16),
2391 object_runtime_max_num_store_entries: Some(1000),
2392 object_runtime_max_num_store_entries_system_tx: Some(1000 * 16),
2393 base_tx_cost_fixed: Some(1_000),
2395 package_publish_cost_fixed: Some(1_000),
2396 base_tx_cost_per_byte: Some(0),
2397 package_publish_cost_per_byte: Some(80),
2398 obj_access_cost_read_per_byte: Some(15),
2399 obj_access_cost_mutate_per_byte: Some(40),
2400 obj_access_cost_delete_per_byte: Some(40),
2401 obj_access_cost_verify_per_byte: Some(200),
2402 obj_data_cost_refundable: Some(100),
2403 obj_metadata_cost_non_refundable: Some(50),
2404 gas_model_version: Some(1),
2405 storage_rebate_rate: Some(10000),
2406 reward_slashing_rate: Some(10000),
2408 storage_gas_price: Some(76),
2409 base_gas_price: None,
2410 validator_target_reward: Some(767_000 * 1_000_000_000),
2413 max_transactions_per_checkpoint: Some(10_000),
2414 max_checkpoint_size_bytes: Some(30 * 1024 * 1024),
2415
2416 buffer_stake_for_protocol_upgrade_bps: Some(5000),
2418
2419 address_from_bytes_cost_base: Some(52),
2423 address_to_u256_cost_base: Some(52),
2425 address_from_u256_cost_base: Some(52),
2427
2428 config_read_setting_impl_cost_base: Some(100),
2431 config_read_setting_impl_cost_per_byte: Some(40),
2432
2433 dynamic_field_hash_type_and_key_cost_base: Some(100),
2437 dynamic_field_hash_type_and_key_type_cost_per_byte: Some(2),
2438 dynamic_field_hash_type_and_key_value_cost_per_byte: Some(2),
2439 dynamic_field_hash_type_and_key_type_tag_cost_per_byte: Some(2),
2440 dynamic_field_add_child_object_cost_base: Some(100),
2443 dynamic_field_add_child_object_type_cost_per_byte: Some(10),
2444 dynamic_field_add_child_object_value_cost_per_byte: Some(10),
2445 dynamic_field_add_child_object_struct_tag_cost_per_byte: Some(10),
2446 dynamic_field_borrow_child_object_cost_base: Some(100),
2449 dynamic_field_borrow_child_object_child_ref_cost_per_byte: Some(10),
2450 dynamic_field_borrow_child_object_type_cost_per_byte: Some(10),
2451 dynamic_field_remove_child_object_cost_base: Some(100),
2454 dynamic_field_remove_child_object_child_cost_per_byte: Some(2),
2455 dynamic_field_remove_child_object_type_cost_per_byte: Some(2),
2456 dynamic_field_has_child_object_cost_base: Some(100),
2459 dynamic_field_has_child_object_with_ty_cost_base: Some(100),
2462 dynamic_field_has_child_object_with_ty_type_cost_per_byte: Some(2),
2463 dynamic_field_has_child_object_with_ty_type_tag_cost_per_byte: Some(2),
2464
2465 event_emit_cost_base: Some(52),
2468 event_emit_value_size_derivation_cost_per_byte: Some(2),
2469 event_emit_tag_size_derivation_cost_per_byte: Some(5),
2470 event_emit_output_cost_per_byte: Some(10),
2471
2472 object_borrow_uid_cost_base: Some(52),
2475 object_delete_impl_cost_base: Some(52),
2477 object_record_new_uid_cost_base: Some(52),
2479
2480 transfer_transfer_internal_cost_base: Some(52),
2484 transfer_freeze_object_cost_base: Some(52),
2486 transfer_share_object_cost_base: Some(52),
2488 transfer_receive_object_cost_base: Some(52),
2489
2490 tx_context_derive_id_cost_base: Some(52),
2494 tx_context_fresh_id_cost_base: None,
2495 tx_context_sender_cost_base: None,
2496 tx_context_digest_cost_base: None,
2497 tx_context_epoch_cost_base: None,
2498 tx_context_epoch_timestamp_ms_cost_base: None,
2499 tx_context_sponsor_cost_base: None,
2500 tx_context_rgp_cost_base: None,
2501 tx_context_gas_price_cost_base: None,
2502 tx_context_gas_budget_cost_base: None,
2503 tx_context_ids_created_cost_base: None,
2504 tx_context_replace_cost_base: None,
2505
2506 types_is_one_time_witness_cost_base: Some(52),
2509 types_is_one_time_witness_type_tag_cost_per_byte: Some(2),
2510 types_is_one_time_witness_type_cost_per_byte: Some(2),
2511
2512 validator_validate_metadata_cost_base: Some(52),
2516 validator_validate_metadata_data_cost_per_byte: Some(2),
2517
2518 crypto_invalid_arguments_cost: Some(100),
2520 bls12381_bls12381_min_sig_verify_cost_base: Some(52),
2522 bls12381_bls12381_min_sig_verify_msg_cost_per_byte: Some(2),
2523 bls12381_bls12381_min_sig_verify_msg_cost_per_block: Some(2),
2524
2525 bls12381_bls12381_min_pk_verify_cost_base: Some(52),
2527 bls12381_bls12381_min_pk_verify_msg_cost_per_byte: Some(2),
2528 bls12381_bls12381_min_pk_verify_msg_cost_per_block: Some(2),
2529
2530 ecdsa_k1_ecrecover_keccak256_cost_base: Some(52),
2532 ecdsa_k1_ecrecover_keccak256_msg_cost_per_byte: Some(2),
2533 ecdsa_k1_ecrecover_keccak256_msg_cost_per_block: Some(2),
2534 ecdsa_k1_ecrecover_sha256_cost_base: Some(52),
2535 ecdsa_k1_ecrecover_sha256_msg_cost_per_byte: Some(2),
2536 ecdsa_k1_ecrecover_sha256_msg_cost_per_block: Some(2),
2537
2538 ecdsa_k1_decompress_pubkey_cost_base: Some(52),
2540
2541 ecdsa_k1_secp256k1_verify_keccak256_cost_base: Some(52),
2543 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_byte: Some(2),
2544 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_block: Some(2),
2545 ecdsa_k1_secp256k1_verify_sha256_cost_base: Some(52),
2546 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_byte: Some(2),
2547 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_block: Some(2),
2548
2549 ecdsa_r1_ecrecover_keccak256_cost_base: Some(52),
2551 ecdsa_r1_ecrecover_keccak256_msg_cost_per_byte: Some(2),
2552 ecdsa_r1_ecrecover_keccak256_msg_cost_per_block: Some(2),
2553 ecdsa_r1_ecrecover_sha256_cost_base: Some(52),
2554 ecdsa_r1_ecrecover_sha256_msg_cost_per_byte: Some(2),
2555 ecdsa_r1_ecrecover_sha256_msg_cost_per_block: Some(2),
2556
2557 ecdsa_r1_secp256r1_verify_keccak256_cost_base: Some(52),
2559 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_byte: Some(2),
2560 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_block: Some(2),
2561 ecdsa_r1_secp256r1_verify_sha256_cost_base: Some(52),
2562 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_byte: Some(2),
2563 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_block: Some(2),
2564
2565 ecvrf_ecvrf_verify_cost_base: Some(52),
2567 ecvrf_ecvrf_verify_alpha_string_cost_per_byte: Some(2),
2568 ecvrf_ecvrf_verify_alpha_string_cost_per_block: Some(2),
2569
2570 ed25519_ed25519_verify_cost_base: Some(52),
2572 ed25519_ed25519_verify_msg_cost_per_byte: Some(2),
2573 ed25519_ed25519_verify_msg_cost_per_block: Some(2),
2574
2575 groth16_prepare_verifying_key_bls12381_cost_base: Some(52),
2577 groth16_prepare_verifying_key_bn254_cost_base: Some(52),
2578
2579 groth16_verify_groth16_proof_internal_bls12381_cost_base: Some(52),
2581 groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input: Some(2),
2582 groth16_verify_groth16_proof_internal_bn254_cost_base: Some(52),
2583 groth16_verify_groth16_proof_internal_bn254_cost_per_public_input: Some(2),
2584 groth16_verify_groth16_proof_internal_public_input_cost_per_byte: Some(2),
2585
2586 hash_blake2b256_cost_base: Some(52),
2588 hash_blake2b256_data_cost_per_byte: Some(2),
2589 hash_blake2b256_data_cost_per_block: Some(2),
2590 hash_keccak256_cost_base: Some(52),
2592 hash_keccak256_data_cost_per_byte: Some(2),
2593 hash_keccak256_data_cost_per_block: Some(2),
2594
2595 poseidon_bn254_cost_base: None,
2596 poseidon_bn254_cost_per_block: None,
2597
2598 hmac_hmac_sha3_256_cost_base: Some(52),
2600 hmac_hmac_sha3_256_input_cost_per_byte: Some(2),
2601 hmac_hmac_sha3_256_input_cost_per_block: Some(2),
2602
2603 group_ops_bls12381_decode_scalar_cost: Some(52),
2605 group_ops_bls12381_decode_g1_cost: Some(52),
2606 group_ops_bls12381_decode_g2_cost: Some(52),
2607 group_ops_bls12381_decode_gt_cost: Some(52),
2608 group_ops_bls12381_scalar_add_cost: Some(52),
2609 group_ops_bls12381_g1_add_cost: Some(52),
2610 group_ops_bls12381_g2_add_cost: Some(52),
2611 group_ops_bls12381_gt_add_cost: Some(52),
2612 group_ops_bls12381_scalar_sub_cost: Some(52),
2613 group_ops_bls12381_g1_sub_cost: Some(52),
2614 group_ops_bls12381_g2_sub_cost: Some(52),
2615 group_ops_bls12381_gt_sub_cost: Some(52),
2616 group_ops_bls12381_scalar_mul_cost: Some(52),
2617 group_ops_bls12381_g1_mul_cost: Some(52),
2618 group_ops_bls12381_g2_mul_cost: Some(52),
2619 group_ops_bls12381_gt_mul_cost: Some(52),
2620 group_ops_bls12381_scalar_div_cost: Some(52),
2621 group_ops_bls12381_g1_div_cost: Some(52),
2622 group_ops_bls12381_g2_div_cost: Some(52),
2623 group_ops_bls12381_gt_div_cost: Some(52),
2624 group_ops_bls12381_g1_hash_to_base_cost: Some(52),
2625 group_ops_bls12381_g2_hash_to_base_cost: Some(52),
2626 group_ops_bls12381_g1_hash_to_cost_per_byte: Some(2),
2627 group_ops_bls12381_g2_hash_to_cost_per_byte: Some(2),
2628 group_ops_bls12381_g1_msm_base_cost: Some(52),
2629 group_ops_bls12381_g2_msm_base_cost: Some(52),
2630 group_ops_bls12381_g1_msm_base_cost_per_input: Some(52),
2631 group_ops_bls12381_g2_msm_base_cost_per_input: Some(52),
2632 group_ops_bls12381_msm_max_len: Some(32),
2633 group_ops_bls12381_pairing_cost: Some(52),
2634 group_ops_bls12381_g1_to_uncompressed_g1_cost: None,
2635 group_ops_bls12381_uncompressed_g1_to_g1_cost: None,
2636 group_ops_bls12381_uncompressed_g1_sum_base_cost: None,
2637 group_ops_bls12381_uncompressed_g1_sum_cost_per_term: None,
2638 group_ops_bls12381_uncompressed_g1_sum_max_terms: None,
2639
2640 #[allow(deprecated)]
2642 check_zklogin_id_cost_base: Some(200),
2643 #[allow(deprecated)]
2644 check_zklogin_issuer_cost_base: Some(200),
2646
2647 vdf_verify_vdf_cost: None,
2648 vdf_hash_to_input_cost: None,
2649
2650 bcs_per_byte_serialized_cost: Some(2),
2651 bcs_legacy_min_output_size_cost: Some(1),
2652 bcs_failure_cost: Some(52),
2653 hash_sha2_256_base_cost: Some(52),
2654 hash_sha2_256_per_byte_cost: Some(2),
2655 hash_sha2_256_legacy_min_input_len_cost: Some(1),
2656 hash_sha3_256_base_cost: Some(52),
2657 hash_sha3_256_per_byte_cost: Some(2),
2658 hash_sha3_256_legacy_min_input_len_cost: Some(1),
2659 type_name_get_base_cost: Some(52),
2660 type_name_get_per_byte_cost: Some(2),
2661 string_check_utf8_base_cost: Some(52),
2662 string_check_utf8_per_byte_cost: Some(2),
2663 string_is_char_boundary_base_cost: Some(52),
2664 string_sub_string_base_cost: Some(52),
2665 string_sub_string_per_byte_cost: Some(2),
2666 string_index_of_base_cost: Some(52),
2667 string_index_of_per_byte_pattern_cost: Some(2),
2668 string_index_of_per_byte_searched_cost: Some(2),
2669 vector_empty_base_cost: Some(52),
2670 vector_length_base_cost: Some(52),
2671 vector_push_back_base_cost: Some(52),
2672 vector_push_back_legacy_per_abstract_memory_unit_cost: Some(2),
2673 vector_borrow_base_cost: Some(52),
2674 vector_pop_back_base_cost: Some(52),
2675 vector_destroy_empty_base_cost: Some(52),
2676 vector_swap_base_cost: Some(52),
2677 debug_print_base_cost: Some(52),
2678 debug_print_stack_trace_base_cost: Some(52),
2679
2680 max_size_written_objects: Some(5 * 1000 * 1000),
2681 max_size_written_objects_system_tx: Some(50 * 1000 * 1000),
2684
2685 max_move_identifier_len: Some(128),
2687 max_move_value_depth: Some(128),
2688 max_move_enum_variants: None,
2689
2690 gas_rounding_step: Some(1_000),
2691
2692 execution_version: Some(1),
2693
2694 max_event_emit_size_total: Some(
2697 256 * 250 * 1024, ),
2699
2700 consensus_bad_nodes_stake_threshold: Some(20),
2707
2708 #[allow(deprecated)]
2710 max_jwk_votes_per_validator_per_epoch: Some(240),
2711
2712 #[allow(deprecated)]
2713 max_age_of_jwk_in_epochs: Some(1),
2714
2715 consensus_max_transaction_size_bytes: Some(256 * 1024), consensus_max_transactions_in_block_bytes: Some(512 * 1024),
2719
2720 random_beacon_reduction_allowed_delta: Some(800),
2721
2722 random_beacon_reduction_lower_bound: Some(1000),
2723 random_beacon_dkg_timeout_round: Some(3000),
2724 random_beacon_min_round_interval_ms: Some(500),
2725
2726 random_beacon_dkg_version: Some(1),
2727
2728 consensus_max_num_transactions_in_block: Some(512),
2732
2733 max_deferral_rounds_for_congestion_control: Some(10),
2734
2735 min_checkpoint_interval_ms: Some(200),
2736
2737 checkpoint_rate_window_size: None,
2738
2739 checkpoint_summary_version_specific_data: Some(1),
2740
2741 max_soft_bundle_size: Some(5),
2742
2743 bridge_should_try_to_finalize_committee: None,
2744
2745 max_accumulated_txn_cost_per_object_in_mysticeti_commit: Some(10),
2746
2747 max_committee_members_count: None,
2748 deny_rule_update_max_entries_per_tx: None,
2749 deny_rule_removal_grace_round_floor: None,
2750
2751 consensus_gc_depth: None,
2752
2753 consensus_max_acknowledgments_per_block: None,
2754
2755 max_congestion_limit_overshoot_per_commit: None,
2756
2757 max_concurrent_execution_workers: None,
2758
2759 scorer_version: None,
2760
2761 auth_context_digest_cost_base: None,
2763 auth_context_tx_data_bytes_cost_base: None,
2764 auth_context_tx_data_bytes_cost_per_byte: None,
2765 auth_context_tx_commands_cost_base: None,
2766 auth_context_tx_commands_cost_per_byte: None,
2767 auth_context_tx_inputs_cost_base: None,
2768 auth_context_tx_inputs_cost_per_byte: None,
2769 auth_context_replace_cost_base: None,
2770 auth_context_replace_cost_per_byte: None,
2771 auth_context_authenticator_function_info_v1_cost_base: None,
2772 consensus_commits_per_schedule: None,
2773 min_validator_count: None,
2774 max_validator_count: None,
2775 min_validator_joining_stake: None,
2776 validator_low_stake_threshold: None,
2777 validator_very_low_stake_threshold: None,
2778 validator_low_stake_grace_period: None,
2779 consensus_leader_schedule_window_size: None,
2780 };
2783
2784 cfg.feature_flags.consensus_transaction_ordering = ConsensusTransactionOrdering::ByGasPrice;
2785
2786 {
2788 cfg.feature_flags
2789 .disable_invariant_violation_check_in_swap_loc = true;
2790 cfg.feature_flags.no_extraneous_module_bytes = true;
2791 cfg.feature_flags.hardened_otw_check = true;
2792 cfg.feature_flags.rethrow_serialization_type_layout_errors = true;
2793 }
2794
2795 {
2797 #[allow(deprecated)]
2798 {
2799 cfg.feature_flags.zklogin_max_epoch_upper_bound_delta = Some(30);
2800 }
2801 }
2802
2803 #[expect(deprecated)]
2807 {
2808 cfg.feature_flags.consensus_choice = ConsensusChoice::MysticetiDeprecated;
2809 }
2810 cfg.feature_flags.consensus_network = ConsensusNetwork::Tonic;
2812
2813 cfg.feature_flags.per_object_congestion_control_mode =
2814 PerObjectCongestionControlMode::TotalTxCount;
2815
2816 cfg.bridge_should_try_to_finalize_committee = Some(chain != Chain::Mainnet);
2818
2819 if chain != Chain::Mainnet && chain != Chain::Testnet {
2821 cfg.feature_flags.enable_poseidon = true;
2822 cfg.poseidon_bn254_cost_base = Some(260);
2823 cfg.poseidon_bn254_cost_per_block = Some(10);
2824
2825 cfg.feature_flags.enable_group_ops_native_function_msm = true;
2826
2827 cfg.feature_flags.enable_vdf = true;
2828 cfg.vdf_verify_vdf_cost = Some(1500);
2831 cfg.vdf_hash_to_input_cost = Some(100);
2832
2833 cfg.feature_flags.passkey_auth = true;
2834 }
2835
2836 for cur in 2..=version.0 {
2837 match cur {
2838 1 => unreachable!(),
2839 2 => {}
2841 3 => {
2842 cfg.feature_flags.relocate_event_module = true;
2843 }
2844 4 => {
2845 cfg.max_type_to_layout_nodes = Some(512);
2846 }
2847 5 => {
2848 cfg.feature_flags.protocol_defined_base_fee = true;
2849 cfg.base_gas_price = Some(1000);
2850
2851 cfg.feature_flags.disallow_new_modules_in_deps_only_packages = true;
2852 cfg.feature_flags.convert_type_argument_error = true;
2853 cfg.feature_flags.native_charging_v2 = true;
2854
2855 if chain != Chain::Mainnet && chain != Chain::Testnet {
2856 cfg.feature_flags.uncompressed_g1_group_elements = true;
2857 }
2858
2859 cfg.gas_model_version = Some(2);
2860
2861 cfg.poseidon_bn254_cost_per_block = Some(388);
2862
2863 cfg.bls12381_bls12381_min_sig_verify_cost_base = Some(44064);
2864 cfg.bls12381_bls12381_min_pk_verify_cost_base = Some(49282);
2865 cfg.ecdsa_k1_secp256k1_verify_keccak256_cost_base = Some(1470);
2866 cfg.ecdsa_k1_secp256k1_verify_sha256_cost_base = Some(1470);
2867 cfg.ecdsa_r1_secp256r1_verify_sha256_cost_base = Some(4225);
2868 cfg.ecdsa_r1_secp256r1_verify_keccak256_cost_base = Some(4225);
2869 cfg.ecvrf_ecvrf_verify_cost_base = Some(4848);
2870 cfg.ed25519_ed25519_verify_cost_base = Some(1802);
2871
2872 cfg.ecdsa_r1_ecrecover_keccak256_cost_base = Some(1173);
2874 cfg.ecdsa_r1_ecrecover_sha256_cost_base = Some(1173);
2875 cfg.ecdsa_k1_ecrecover_keccak256_cost_base = Some(500);
2876 cfg.ecdsa_k1_ecrecover_sha256_cost_base = Some(500);
2877
2878 cfg.groth16_prepare_verifying_key_bls12381_cost_base = Some(53838);
2879 cfg.groth16_prepare_verifying_key_bn254_cost_base = Some(82010);
2880 cfg.groth16_verify_groth16_proof_internal_bls12381_cost_base = Some(72090);
2881 cfg.groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input =
2882 Some(8213);
2883 cfg.groth16_verify_groth16_proof_internal_bn254_cost_base = Some(115502);
2884 cfg.groth16_verify_groth16_proof_internal_bn254_cost_per_public_input =
2885 Some(9484);
2886
2887 cfg.hash_keccak256_cost_base = Some(10);
2888 cfg.hash_blake2b256_cost_base = Some(10);
2889
2890 cfg.group_ops_bls12381_decode_scalar_cost = Some(7);
2892 cfg.group_ops_bls12381_decode_g1_cost = Some(2848);
2893 cfg.group_ops_bls12381_decode_g2_cost = Some(3770);
2894 cfg.group_ops_bls12381_decode_gt_cost = Some(3068);
2895
2896 cfg.group_ops_bls12381_scalar_add_cost = Some(10);
2897 cfg.group_ops_bls12381_g1_add_cost = Some(1556);
2898 cfg.group_ops_bls12381_g2_add_cost = Some(3048);
2899 cfg.group_ops_bls12381_gt_add_cost = Some(188);
2900
2901 cfg.group_ops_bls12381_scalar_sub_cost = Some(10);
2902 cfg.group_ops_bls12381_g1_sub_cost = Some(1550);
2903 cfg.group_ops_bls12381_g2_sub_cost = Some(3019);
2904 cfg.group_ops_bls12381_gt_sub_cost = Some(497);
2905
2906 cfg.group_ops_bls12381_scalar_mul_cost = Some(11);
2907 cfg.group_ops_bls12381_g1_mul_cost = Some(4842);
2908 cfg.group_ops_bls12381_g2_mul_cost = Some(9108);
2909 cfg.group_ops_bls12381_gt_mul_cost = Some(27490);
2910
2911 cfg.group_ops_bls12381_scalar_div_cost = Some(91);
2912 cfg.group_ops_bls12381_g1_div_cost = Some(5091);
2913 cfg.group_ops_bls12381_g2_div_cost = Some(9206);
2914 cfg.group_ops_bls12381_gt_div_cost = Some(27804);
2915
2916 cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(2962);
2917 cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(8688);
2918
2919 cfg.group_ops_bls12381_g1_msm_base_cost = Some(62648);
2920 cfg.group_ops_bls12381_g2_msm_base_cost = Some(131192);
2921 cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(1333);
2922 cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(3216);
2923
2924 cfg.group_ops_bls12381_uncompressed_g1_to_g1_cost = Some(677);
2925 cfg.group_ops_bls12381_g1_to_uncompressed_g1_cost = Some(2099);
2926 cfg.group_ops_bls12381_uncompressed_g1_sum_base_cost = Some(77);
2927 cfg.group_ops_bls12381_uncompressed_g1_sum_cost_per_term = Some(26);
2928 cfg.group_ops_bls12381_uncompressed_g1_sum_max_terms = Some(1200);
2929
2930 cfg.group_ops_bls12381_pairing_cost = Some(26897);
2931
2932 cfg.validator_validate_metadata_cost_base = Some(20000);
2933
2934 cfg.max_committee_members_count = Some(50);
2935 }
2936 6 => {
2937 cfg.max_ptb_value_size = Some(1024 * 1024);
2938 }
2939 7 => {
2940 }
2943 8 => {
2944 cfg.feature_flags.variant_nodes = true;
2945
2946 if chain != Chain::Mainnet {
2947 cfg.feature_flags.consensus_round_prober = true;
2949 cfg.feature_flags
2951 .consensus_distributed_vote_scoring_strategy = true;
2952 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
2953 cfg.feature_flags.consensus_smart_ancestor_selection = true;
2955 cfg.feature_flags
2957 .consensus_round_prober_probe_accepted_rounds = true;
2958 cfg.feature_flags.consensus_zstd_compression = true;
2960 cfg.consensus_gc_depth = Some(60);
2964 }
2965
2966 if chain != Chain::Testnet && chain != Chain::Mainnet {
2969 cfg.feature_flags.congestion_control_min_free_execution_slot = true;
2970 }
2971 }
2972 9 => {
2973 if chain != Chain::Mainnet {
2974 cfg.feature_flags.consensus_smart_ancestor_selection = false;
2976 }
2977
2978 cfg.feature_flags.consensus_zstd_compression = true;
2980
2981 if chain != Chain::Testnet && chain != Chain::Mainnet {
2983 cfg.feature_flags.accept_passkey_in_multisig = true;
2984 }
2985
2986 cfg.bridge_should_try_to_finalize_committee = None;
2988 }
2989 10 => {
2990 cfg.feature_flags.congestion_control_min_free_execution_slot = true;
2993
2994 cfg.max_committee_members_count = Some(80);
2996
2997 cfg.feature_flags.consensus_round_prober = true;
2999 cfg.feature_flags
3001 .consensus_round_prober_probe_accepted_rounds = true;
3002 cfg.feature_flags
3004 .consensus_distributed_vote_scoring_strategy = true;
3005 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
3007
3008 cfg.consensus_gc_depth = Some(60);
3013
3014 cfg.feature_flags.minimize_child_object_mutations = true;
3016
3017 if chain != Chain::Mainnet {
3018 cfg.feature_flags.consensus_batched_block_sync = true;
3020 }
3021
3022 if chain != Chain::Testnet && chain != Chain::Mainnet {
3023 cfg.feature_flags
3026 .congestion_control_gas_price_feedback_mechanism = true;
3027 }
3028
3029 cfg.feature_flags.validate_identifier_inputs = true;
3030 cfg.feature_flags.dependency_linkage_error = true;
3031 cfg.feature_flags.additional_multisig_checks = true;
3032 }
3033 11 => {
3034 }
3037 12 => {
3038 cfg.feature_flags
3041 .congestion_control_gas_price_feedback_mechanism = true;
3042
3043 cfg.feature_flags.normalize_ptb_arguments = true;
3045 }
3046 13 => {
3047 cfg.feature_flags.select_committee_from_eligible_validators = true;
3050 cfg.feature_flags.track_non_committee_eligible_validators = true;
3053
3054 if chain != Chain::Testnet && chain != Chain::Mainnet {
3055 cfg.feature_flags
3058 .select_committee_supporting_next_epoch_version = true;
3059 }
3060 }
3061 14 => {
3062 cfg.feature_flags.consensus_batched_block_sync = true;
3064
3065 if chain != Chain::Mainnet {
3066 cfg.feature_flags
3069 .consensus_median_timestamp_with_checkpoint_enforcement = true;
3070 cfg.feature_flags
3074 .select_committee_supporting_next_epoch_version = true;
3075 }
3076 if chain != Chain::Testnet && chain != Chain::Mainnet {
3077 cfg.feature_flags.consensus_choice = ConsensusChoice::Starfish;
3079 }
3080 }
3081 15 => {
3082 if chain != Chain::Mainnet && chain != Chain::Testnet {
3083 cfg.max_congestion_limit_overshoot_per_commit = Some(100);
3087 }
3088 }
3089 16 => {
3090 cfg.feature_flags
3093 .select_committee_supporting_next_epoch_version = true;
3094 cfg.feature_flags
3096 .consensus_commit_transactions_only_for_traversed_headers = true;
3097 }
3098 17 => {
3099 cfg.max_committee_members_count = Some(100);
3101 }
3102 18 => {
3103 if chain != Chain::Mainnet {
3104 cfg.feature_flags.passkey_auth = true;
3106 }
3107 }
3108 19 => {
3109 if chain != Chain::Testnet && chain != Chain::Mainnet {
3110 cfg.feature_flags
3113 .congestion_limit_overshoot_in_gas_price_feedback_mechanism = true;
3114 cfg.feature_flags
3117 .separate_gas_price_feedback_mechanism_for_randomness = true;
3118 cfg.feature_flags.metadata_in_module_bytes = true;
3121 cfg.feature_flags.publish_package_metadata = true;
3122 cfg.feature_flags.enable_move_authentication = true;
3124 cfg.max_auth_gas = Some(250_000_000);
3126 cfg.transfer_receive_object_cost_base = Some(100);
3129 cfg.feature_flags.adjust_rewards_by_score = true;
3131 }
3132
3133 if chain != Chain::Mainnet {
3134 cfg.feature_flags.consensus_choice = ConsensusChoice::Starfish;
3136
3137 cfg.feature_flags.calculate_validator_scores = true;
3139 cfg.scorer_version = Some(1);
3140 }
3141
3142 cfg.feature_flags.pass_validator_scores_to_advance_epoch = true;
3144
3145 cfg.feature_flags.passkey_auth = true;
3147 }
3148 20 => {
3149 if chain != Chain::Testnet && chain != Chain::Mainnet {
3150 cfg.feature_flags
3152 .pass_calculated_validator_scores_to_advance_epoch = true;
3153 }
3154 }
3155 21 => {
3156 if chain != Chain::Testnet && chain != Chain::Mainnet {
3157 cfg.feature_flags.consensus_fast_commit_sync = true;
3159 }
3160 if chain != Chain::Mainnet {
3161 cfg.max_congestion_limit_overshoot_per_commit = Some(100);
3166 cfg.feature_flags
3169 .congestion_limit_overshoot_in_gas_price_feedback_mechanism = true;
3170 cfg.feature_flags
3173 .separate_gas_price_feedback_mechanism_for_randomness = true;
3174 }
3175
3176 cfg.auth_context_digest_cost_base = Some(30);
3177 cfg.auth_context_tx_commands_cost_base = Some(30);
3178 cfg.auth_context_tx_commands_cost_per_byte = Some(2);
3179 cfg.auth_context_tx_inputs_cost_base = Some(30);
3180 cfg.auth_context_tx_inputs_cost_per_byte = Some(2);
3181 cfg.auth_context_replace_cost_base = Some(30);
3182 cfg.auth_context_replace_cost_per_byte = Some(2);
3183
3184 if chain != Chain::Testnet && chain != Chain::Mainnet {
3185 cfg.max_auth_gas = Some(250_000);
3187 }
3188 }
3189 22 => {
3190 cfg.max_congestion_limit_overshoot_per_commit = Some(100);
3195 cfg.feature_flags
3198 .congestion_limit_overshoot_in_gas_price_feedback_mechanism = true;
3199 cfg.feature_flags
3202 .separate_gas_price_feedback_mechanism_for_randomness = true;
3203
3204 if chain != Chain::Mainnet {
3205 cfg.feature_flags.metadata_in_module_bytes = true;
3208 cfg.feature_flags.publish_package_metadata = true;
3209 cfg.feature_flags.enable_move_authentication = true;
3211 cfg.max_auth_gas = Some(250_000);
3213 cfg.transfer_receive_object_cost_base = Some(100);
3216 }
3217
3218 if chain != Chain::Mainnet {
3219 cfg.feature_flags.consensus_fast_commit_sync = true;
3221 }
3222 }
3223 23 => {
3224 cfg.feature_flags.move_native_tx_context = true;
3226 cfg.tx_context_fresh_id_cost_base = Some(52);
3227 cfg.tx_context_sender_cost_base = Some(30);
3228 cfg.tx_context_digest_cost_base = Some(30);
3229 cfg.tx_context_epoch_cost_base = Some(30);
3230 cfg.tx_context_epoch_timestamp_ms_cost_base = Some(30);
3231 cfg.tx_context_sponsor_cost_base = Some(30);
3232 cfg.tx_context_rgp_cost_base = Some(30);
3233 cfg.tx_context_gas_price_cost_base = Some(30);
3234 cfg.tx_context_gas_budget_cost_base = Some(30);
3235 cfg.tx_context_ids_created_cost_base = Some(30);
3236 cfg.tx_context_replace_cost_base = Some(30);
3237 }
3238 24 => {
3239 cfg.feature_flags.consensus_choice = ConsensusChoice::Starfish;
3241
3242 if chain != Chain::Testnet && chain != Chain::Mainnet {
3243 cfg.feature_flags.enable_move_authentication_for_sponsor = true;
3245 }
3246
3247 cfg.auth_context_tx_data_bytes_cost_base = Some(30);
3250 cfg.auth_context_tx_data_bytes_cost_per_byte = Some(2);
3251
3252 cfg.feature_flags.additional_borrow_checks = true;
3254 }
3255 #[allow(deprecated)]
3256 25 => {
3257 cfg.feature_flags.zklogin_max_epoch_upper_bound_delta = None;
3260 cfg.check_zklogin_id_cost_base = None;
3261 cfg.check_zklogin_issuer_cost_base = None;
3262 cfg.max_jwk_votes_per_validator_per_epoch = None;
3263 cfg.max_age_of_jwk_in_epochs = None;
3264 }
3265 26 => {
3266 }
3269 27 => {
3270 if chain != Chain::Mainnet {
3271 cfg.feature_flags.consensus_block_restrictions = true;
3274 }
3275
3276 if chain != Chain::Testnet && chain != Chain::Mainnet {
3277 cfg.feature_flags
3279 .pre_consensus_sponsor_only_move_authentication = true;
3280 }
3281 }
3282 28 => {
3283 cfg.auth_context_authenticator_function_info_v1_cost_base = Some(270);
3288
3289 cfg.feature_flags.metadata_in_module_bytes = true;
3292 cfg.feature_flags.publish_package_metadata = true;
3293 cfg.feature_flags.enable_move_authentication = true;
3295 cfg.transfer_receive_object_cost_base = Some(100);
3298
3299 if chain != Chain::Unknown {
3300 cfg.max_auth_gas = Some(20_000);
3302 }
3303
3304 if chain != Chain::Mainnet {
3305 cfg.feature_flags.enable_move_authentication_for_sponsor = true;
3307 cfg.feature_flags
3309 .pre_consensus_sponsor_only_move_authentication = true;
3310 }
3311 }
3312 29 => {
3313 cfg.feature_flags.always_advance_dkg_to_resolution = true;
3319
3320 cfg.feature_flags
3323 .consensus_median_timestamp_with_checkpoint_enforcement = true;
3324
3325 cfg.feature_flags.consensus_fast_commit_sync = true;
3327 cfg.feature_flags.consensus_block_restrictions = true;
3331 }
3332 30 => {
3333 }
3341 31 => {
3342 cfg.feature_flags.validator_metadata_verify_v2 = true;
3343
3344 if chain != Chain::Mainnet && chain != Chain::Testnet {
3345 cfg.checkpoint_rate_window_size = Some(20);
3348 cfg.feature_flags
3351 .package_metadata_with_dynamic_module_metadata = true;
3352 cfg.feature_flags.consensus_starfish_speed = true;
3355 }
3356
3357 cfg.feature_flags.report_move_authentication_error = true;
3358 }
3359 32 => {
3360 cfg.min_validator_count = Some(4);
3364 cfg.max_validator_count = Some(150);
3365 cfg.min_validator_joining_stake = Some(2_000_000_000_000_000);
3366 cfg.validator_low_stake_threshold = Some(1_500_000_000_000_000);
3367 cfg.validator_very_low_stake_threshold = Some(1_000_000_000_000_000);
3368 cfg.validator_low_stake_grace_period = Some(7);
3369
3370 cfg.feature_flags.enable_move_authentication_for_sponsor = true;
3372 cfg.feature_flags
3374 .pre_consensus_sponsor_only_move_authentication = true;
3375
3376 if chain != Chain::Mainnet {
3377 cfg.feature_flags.consensus_starfish_speed = true;
3380 cfg.checkpoint_rate_window_size = Some(20);
3383 cfg.feature_flags
3386 .package_metadata_with_dynamic_module_metadata = true;
3387 }
3388
3389 if chain != Chain::Mainnet && chain != Chain::Testnet {
3390 cfg.feature_flags
3394 .consensus_enable_sliding_window_leader_schedule = true;
3395 cfg.feature_flags
3396 .consensus_enable_absolute_score_leader_schedule = true;
3397 cfg.feature_flags.enable_pcool_flow = true;
3401 }
3402 }
3403 33 => {
3404 cfg.checkpoint_rate_window_size = Some(20);
3407 if chain != Chain::Mainnet {
3411 cfg.feature_flags
3412 .consensus_enable_sliding_window_leader_schedule = true;
3413 cfg.feature_flags
3414 .consensus_enable_absolute_score_leader_schedule = true;
3415 }
3416 }
3417 34 => {
3418 if chain != Chain::Testnet && chain != Chain::Mainnet {
3419 cfg.scorer_version = Some(2);
3423 }
3424 cfg.feature_flags.pcool_skip_immutable_object_locks = true;
3428
3429 if chain == Chain::Mainnet {
3430 cfg.feature_flags.enable_move_authentication_for_sponsor = false;
3432 cfg.feature_flags
3435 .pre_consensus_sponsor_only_move_authentication = false;
3436 }
3437 }
3438 35 => {
3439 cfg.feature_flags.max_ptb_value_size_v2 = true;
3441 cfg.feature_flags.allow_unbounded_system_objects = true;
3443
3444 cfg.feature_flags.consensus_starfish_speed = true;
3447
3448 cfg.max_verifier_meter_ticks_per_function = Some(2_200_000);
3455 cfg.max_meter_ticks_per_module = Some(2_200_000);
3456 cfg.max_meter_ticks_per_package = Some(2_200_000);
3457 cfg.max_meter_ticks_regex_reference_safety = Some(2_200_000);
3458 cfg.feature_flags.pcool_verifier_limits_from_protocol_config = true;
3459 cfg.feature_flags
3462 .package_metadata_with_dynamic_module_metadata = true;
3463 cfg.feature_flags
3467 .consensus_enable_sliding_window_leader_schedule = true;
3468 cfg.feature_flags
3469 .consensus_enable_absolute_score_leader_schedule = true;
3470
3471 cfg.feature_flags.enable_move_authentication_for_sponsor = true;
3474 cfg.feature_flags
3477 .pre_consensus_sponsor_only_move_authentication = false;
3478 }
3479 _ => panic!("unsupported version {version:?}"),
3490 }
3491 }
3492 cfg
3493 }
3494
3495 pub fn verifier_config(&self, signing_limits: Option<(usize, usize, usize)>) -> VerifierConfig {
3501 let (
3502 max_back_edges_per_function,
3503 max_back_edges_per_module,
3504 sanity_check_with_regex_reference_safety,
3505 ) = if let Some((
3506 max_back_edges_per_function,
3507 max_back_edges_per_module,
3508 sanity_check_with_regex_reference_safety,
3509 )) = signing_limits
3510 {
3511 (
3512 Some(max_back_edges_per_function),
3513 Some(max_back_edges_per_module),
3514 Some(sanity_check_with_regex_reference_safety),
3515 )
3516 } else {
3517 (None, None, None)
3518 };
3519
3520 let additional_borrow_checks = if signing_limits.is_some() {
3521 true
3524 } else {
3525 self.additional_borrow_checks()
3526 };
3527
3528 VerifierConfig {
3529 max_loop_depth: Some(self.max_loop_depth() as usize),
3530 max_generic_instantiation_length: Some(self.max_generic_instantiation_length() as usize),
3531 max_function_parameters: Some(self.max_function_parameters() as usize),
3532 max_basic_blocks: Some(self.max_basic_blocks() as usize),
3533 max_value_stack_size: self.max_value_stack_size() as usize,
3534 max_type_nodes: Some(self.max_type_nodes() as usize),
3535 max_push_size: Some(self.max_push_size() as usize),
3536 max_dependency_depth: Some(self.max_dependency_depth() as usize),
3537 max_fields_in_struct: Some(self.max_fields_in_struct() as usize),
3538 max_function_definitions: Some(self.max_function_definitions() as usize),
3539 max_data_definitions: Some(self.max_struct_definitions() as usize),
3540 max_constant_vector_len: Some(self.max_move_vector_len()),
3541 max_back_edges_per_function,
3542 max_back_edges_per_module,
3543 max_basic_blocks_in_script: None,
3544 max_identifier_len: self.max_move_identifier_len_as_option(), bytecode_version: self.move_binary_format_version(),
3548 max_variants_in_enum: self.max_move_enum_variants_as_option(),
3549 additional_borrow_checks,
3550 sanity_check_with_regex_reference_safety: sanity_check_with_regex_reference_safety
3551 .map(|limit| limit as u128),
3552 }
3553 }
3554
3555 pub fn verifier_signing_limits(&self) -> (usize, usize, usize) {
3562 (
3563 self.max_back_edges_per_function() as usize,
3564 self.max_back_edges_per_module() as usize,
3565 self.max_meter_ticks_regex_reference_safety() as usize,
3566 )
3567 }
3568
3569 pub fn meter_config(&self) -> MeterConfig {
3573 MeterConfig {
3574 max_per_fun_meter_units: Some(self.max_verifier_meter_ticks_per_function() as u128),
3575 max_per_mod_meter_units: Some(self.max_meter_ticks_per_module() as u128),
3576 max_per_pkg_meter_units: Some(self.max_meter_ticks_per_package() as u128),
3577 }
3578 }
3579
3580 pub fn apply_overrides_for_testing(
3585 override_fn: impl Fn(ProtocolVersion, Self) -> Self + Send + Sync + 'static,
3586 ) -> OverrideGuard {
3587 CONFIG_OVERRIDE.with(|ovr| {
3588 let mut cur = ovr.borrow_mut();
3589 assert!(cur.is_none(), "config override already present");
3590 *cur = Some(Box::new(override_fn));
3591 OverrideGuard
3592 })
3593 }
3594}
3595
3596impl ProtocolConfig {
3601 pub fn set_per_object_congestion_control_mode_for_testing(
3602 &mut self,
3603 val: PerObjectCongestionControlMode,
3604 ) {
3605 self.feature_flags.per_object_congestion_control_mode = val;
3606 }
3607
3608 pub fn set_consensus_choice_for_testing(&mut self, val: ConsensusChoice) {
3609 self.feature_flags.consensus_choice = val;
3610 }
3611
3612 pub fn set_consensus_network_for_testing(&mut self, val: ConsensusNetwork) {
3613 self.feature_flags.consensus_network = val;
3614 }
3615
3616 pub fn set_passkey_auth_for_testing(&mut self, val: bool) {
3617 self.feature_flags.passkey_auth = val
3618 }
3619
3620 pub fn set_disallow_new_modules_in_deps_only_packages_for_testing(&mut self, val: bool) {
3621 self.feature_flags
3622 .disallow_new_modules_in_deps_only_packages = val;
3623 }
3624
3625 pub fn set_consensus_round_prober_for_testing(&mut self, val: bool) {
3626 self.feature_flags.consensus_round_prober = val;
3627 }
3628
3629 pub fn set_consensus_distributed_vote_scoring_strategy_for_testing(&mut self, val: bool) {
3630 self.feature_flags
3631 .consensus_distributed_vote_scoring_strategy = val;
3632 }
3633
3634 pub fn set_gc_depth_for_testing(&mut self, val: u32) {
3635 self.consensus_gc_depth = Some(val);
3636 }
3637
3638 pub fn set_consensus_linearize_subdag_v2_for_testing(&mut self, val: bool) {
3639 self.feature_flags.consensus_linearize_subdag_v2 = val;
3640 }
3641
3642 pub fn set_consensus_round_prober_probe_accepted_rounds(&mut self, val: bool) {
3643 self.feature_flags
3644 .consensus_round_prober_probe_accepted_rounds = val;
3645 }
3646
3647 pub fn set_accept_passkey_in_multisig_for_testing(&mut self, val: bool) {
3648 self.feature_flags.accept_passkey_in_multisig = val;
3649 }
3650
3651 pub fn set_consensus_smart_ancestor_selection_for_testing(&mut self, val: bool) {
3652 self.feature_flags.consensus_smart_ancestor_selection = val;
3653 }
3654
3655 pub fn set_consensus_batched_block_sync_for_testing(&mut self, val: bool) {
3656 self.feature_flags.consensus_batched_block_sync = val;
3657 }
3658
3659 pub fn set_congestion_control_min_free_execution_slot_for_testing(&mut self, val: bool) {
3660 self.feature_flags
3661 .congestion_control_min_free_execution_slot = val;
3662 }
3663
3664 pub fn set_congestion_control_gas_price_feedback_mechanism_for_testing(&mut self, val: bool) {
3665 self.feature_flags
3666 .congestion_control_gas_price_feedback_mechanism = val;
3667 }
3668
3669 pub fn set_select_committee_from_eligible_validators_for_testing(&mut self, val: bool) {
3670 self.feature_flags.select_committee_from_eligible_validators = val;
3671 }
3672
3673 pub fn set_track_non_committee_eligible_validators_for_testing(&mut self, val: bool) {
3674 self.feature_flags.track_non_committee_eligible_validators = val;
3675 }
3676
3677 pub fn set_select_committee_supporting_next_epoch_version(&mut self, val: bool) {
3678 self.feature_flags
3679 .select_committee_supporting_next_epoch_version = val;
3680 }
3681
3682 pub fn set_consensus_median_timestamp_with_checkpoint_enforcement_for_testing(
3683 &mut self,
3684 val: bool,
3685 ) {
3686 self.feature_flags
3687 .consensus_median_timestamp_with_checkpoint_enforcement = val;
3688 }
3689
3690 pub fn set_consensus_commit_transactions_only_for_traversed_headers_for_testing(
3691 &mut self,
3692 val: bool,
3693 ) {
3694 self.feature_flags
3695 .consensus_commit_transactions_only_for_traversed_headers = val;
3696 }
3697
3698 pub fn set_congestion_limit_overshoot_in_gas_price_feedback_mechanism_for_testing(
3699 &mut self,
3700 val: bool,
3701 ) {
3702 self.feature_flags
3703 .congestion_limit_overshoot_in_gas_price_feedback_mechanism = val;
3704 }
3705
3706 pub fn set_separate_gas_price_feedback_mechanism_for_randomness_for_testing(
3707 &mut self,
3708 val: bool,
3709 ) {
3710 self.feature_flags
3711 .separate_gas_price_feedback_mechanism_for_randomness = val;
3712 }
3713
3714 pub fn set_metadata_in_module_bytes_for_testing(&mut self, val: bool) {
3715 self.feature_flags.metadata_in_module_bytes = val;
3716 }
3717
3718 pub fn set_publish_package_metadata_for_testing(&mut self, val: bool) {
3719 self.feature_flags.publish_package_metadata = val;
3720 }
3721
3722 pub fn set_enable_move_authentication_for_testing(&mut self, val: bool) {
3723 self.feature_flags.enable_move_authentication = val;
3724 }
3725
3726 pub fn set_enable_move_authentication_for_sponsor_for_testing(&mut self, val: bool) {
3727 self.feature_flags.enable_move_authentication_for_sponsor = val;
3728 }
3729
3730 pub fn set_consensus_fast_commit_sync_for_testing(&mut self, val: bool) {
3731 self.feature_flags.consensus_fast_commit_sync = val;
3732 }
3733
3734 pub fn set_consensus_block_restrictions_for_testing(&mut self, val: bool) {
3735 self.feature_flags.consensus_block_restrictions = val;
3736 }
3737
3738 pub fn set_pre_consensus_sponsor_only_move_authentication_for_testing(&mut self, val: bool) {
3739 self.feature_flags
3740 .pre_consensus_sponsor_only_move_authentication = val;
3741 }
3742
3743 pub fn set_consensus_starfish_speed_for_testing(&mut self, val: bool) {
3744 self.feature_flags.consensus_starfish_speed = val;
3745 }
3746
3747 pub fn set_always_advance_dkg_to_resolution_for_testing(&mut self, val: bool) {
3748 self.feature_flags.always_advance_dkg_to_resolution = val;
3749 }
3750
3751 pub fn set_enable_pcool_flow_for_testing(&mut self, val: bool) {
3752 self.feature_flags.enable_pcool_flow = val;
3753 }
3754
3755 pub fn set_pcool_skip_immutable_object_locks_for_testing(&mut self, val: bool) {
3756 self.feature_flags.pcool_skip_immutable_object_locks = val;
3757 }
3758
3759 pub fn set_pcool_verifier_limits_from_protocol_config_for_testing(&mut self, val: bool) {
3760 self.feature_flags
3761 .pcool_verifier_limits_from_protocol_config = val;
3762 }
3763
3764 pub fn set_commits_per_schedule_for_testing(&mut self, val: u32) {
3765 self.consensus_commits_per_schedule = Some(val);
3766 }
3767
3768 pub fn set_deny_rule_governance_for_testing(&mut self, val: bool) {
3769 self.feature_flags.deny_rule_governance = val;
3770 }
3771
3772 pub fn set_deny_rule_governance_on_chain_for_testing(&mut self, val: bool) {
3773 self.feature_flags.deny_rule_governance_on_chain = val;
3774 }
3775
3776 pub fn set_package_metadata_with_dynamic_module_metadata_for_testing(&mut self, val: bool) {
3777 self.feature_flags
3778 .package_metadata_with_dynamic_module_metadata = val;
3779 }
3780
3781 pub fn set_report_move_authentication_error_for_testing(&mut self, val: bool) {
3782 self.feature_flags.report_move_authentication_error = val;
3783 }
3784
3785 pub fn set_leader_schedule_window_size_for_testing(&mut self, val: u32) {
3786 self.consensus_leader_schedule_window_size = Some(val);
3787 }
3788
3789 pub fn set_consensus_enable_sliding_window_leader_schedule_for_testing(&mut self, val: bool) {
3790 self.feature_flags
3791 .consensus_enable_sliding_window_leader_schedule = val;
3792 }
3793
3794 pub fn set_consensus_enable_absolute_score_leader_schedule_for_testing(&mut self, val: bool) {
3795 self.feature_flags
3796 .consensus_enable_absolute_score_leader_schedule = val;
3797 }
3798}
3799
3800type OverrideFn = dyn Fn(ProtocolVersion, ProtocolConfig) -> ProtocolConfig + Send + Sync;
3801
3802thread_local! {
3803 static CONFIG_OVERRIDE: RefCell<Option<Box<OverrideFn>>> = const { RefCell::new(None) };
3804}
3805
3806#[must_use]
3807pub struct OverrideGuard;
3808
3809impl Drop for OverrideGuard {
3810 fn drop(&mut self) {
3811 info!("restoring override fn");
3812 CONFIG_OVERRIDE.with(|ovr| {
3813 *ovr.borrow_mut() = None;
3814 });
3815 }
3816}
3817
3818#[derive(PartialEq, Eq)]
3822pub enum LimitThresholdCrossed {
3823 None,
3824 Soft(u128, u128),
3825 Hard(u128, u128),
3826}
3827
3828pub fn check_limit_in_range<T: Into<V>, U: Into<V>, V: PartialOrd + Into<u128>>(
3831 x: T,
3832 soft_limit: U,
3833 hard_limit: V,
3834) -> LimitThresholdCrossed {
3835 let x: V = x.into();
3836 let soft_limit: V = soft_limit.into();
3837
3838 debug_assert!(soft_limit <= hard_limit);
3839
3840 if x >= hard_limit {
3843 LimitThresholdCrossed::Hard(x.into(), hard_limit.into())
3844 } else if x < soft_limit {
3845 LimitThresholdCrossed::None
3846 } else {
3847 LimitThresholdCrossed::Soft(x.into(), soft_limit.into())
3848 }
3849}
3850
3851#[macro_export]
3852macro_rules! check_limit {
3853 ($x:expr, $hard:expr) => {
3854 check_limit!($x, $hard, $hard)
3855 };
3856 ($x:expr, $soft:expr, $hard:expr) => {
3857 check_limit_in_range($x as u64, $soft, $hard)
3858 };
3859}
3860
3861#[macro_export]
3865macro_rules! check_limit_by_meter {
3866 ($is_metered:expr, $x:expr, $metered_limit:expr, $unmetered_hard_limit:expr, $metric:expr) => {{
3867 let (h, metered_str) = if $is_metered {
3869 ($metered_limit, "metered")
3870 } else {
3871 ($unmetered_hard_limit, "unmetered")
3873 };
3874 use iota_protocol_config::check_limit_in_range;
3875 let result = check_limit_in_range($x as u64, $metered_limit, h);
3876 match result {
3877 LimitThresholdCrossed::None => {}
3878 LimitThresholdCrossed::Soft(_, _) => {
3879 $metric.with_label_values(&[metered_str, "soft"]).inc();
3880 }
3881 LimitThresholdCrossed::Hard(_, _) => {
3882 $metric.with_label_values(&[metered_str, "hard"]).inc();
3883 }
3884 };
3885 result
3886 }};
3887}
3888
3889#[cfg(all(test, not(msim)))]
3890mod test {
3891 use insta::assert_yaml_snapshot;
3892
3893 use super::*;
3894
3895 #[test]
3896 fn snapshot_tests() {
3897 println!("\n============================================================================");
3898 println!("! !");
3899 println!("! IMPORTANT: never update snapshots from this test. only add new versions! !");
3900 println!("! !");
3901 println!("============================================================================\n");
3902 for chain_id in &[Chain::Unknown, Chain::Mainnet, Chain::Testnet] {
3903 let chain_str = match chain_id {
3908 Chain::Unknown => "".to_string(),
3909 _ => format!("{chain_id:?}_"),
3910 };
3911 for i in MIN_PROTOCOL_VERSION..=MAX_PROTOCOL_VERSION {
3912 let cur = ProtocolVersion::new(i);
3913 assert_yaml_snapshot!(
3914 format!("{}version_{}", chain_str, cur.as_u64()),
3915 ProtocolConfig::get_for_version(cur, *chain_id)
3916 );
3917 }
3918 }
3919 }
3920
3921 #[test]
3922 fn test_getters() {
3923 let prot: ProtocolConfig =
3924 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
3925 assert_eq!(
3926 prot.max_arguments(),
3927 prot.max_arguments_as_option().unwrap()
3928 );
3929 }
3930
3931 #[test]
3932 fn test_setters() {
3933 let mut prot: ProtocolConfig =
3934 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
3935 prot.set_max_arguments_for_testing(123);
3936 assert_eq!(prot.max_arguments(), 123);
3937
3938 prot.set_max_arguments_from_str_for_testing("321".to_string());
3939 assert_eq!(prot.max_arguments(), 321);
3940
3941 prot.disable_max_arguments_for_testing();
3942 assert_eq!(prot.max_arguments_as_option(), None);
3943
3944 prot.set_attr_for_testing("max_arguments".to_string(), "456".to_string());
3945 assert_eq!(prot.max_arguments(), 456);
3946 }
3947
3948 #[test]
3949 #[should_panic(expected = "unsupported version")]
3950 fn max_version_test() {
3951 let _ = ProtocolConfig::get_for_version_impl(
3954 ProtocolVersion::new(MAX_PROTOCOL_VERSION + 1),
3955 Chain::Unknown,
3956 );
3957 }
3958
3959 #[test]
3960 fn lookup_by_string_test() {
3961 let prot: ProtocolConfig =
3962 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Mainnet);
3963 assert!(prot.lookup_attr("some random string".to_string()).is_none());
3965
3966 assert!(
3967 prot.lookup_attr("max_arguments".to_string())
3968 == Some(ProtocolConfigValue::u32(prot.max_arguments())),
3969 );
3970
3971 assert!(
3973 prot.lookup_attr("poseidon_bn254_cost_base".to_string())
3974 .is_none()
3975 );
3976 assert!(
3977 prot.attr_map()
3978 .get("poseidon_bn254_cost_base")
3979 .unwrap()
3980 .is_none()
3981 );
3982
3983 let prot: ProtocolConfig =
3985 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
3986
3987 assert!(
3988 prot.lookup_attr("poseidon_bn254_cost_base".to_string())
3989 == Some(ProtocolConfigValue::u64(prot.poseidon_bn254_cost_base()))
3990 );
3991 assert!(
3992 prot.attr_map().get("poseidon_bn254_cost_base").unwrap()
3993 == &Some(ProtocolConfigValue::u64(prot.poseidon_bn254_cost_base()))
3994 );
3995
3996 let prot: ProtocolConfig =
3998 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Mainnet);
3999 assert!(
4001 prot.feature_flags
4002 .lookup_attr("some random string".to_owned())
4003 .is_none()
4004 );
4005 assert!(
4006 !prot
4007 .feature_flags
4008 .attr_map()
4009 .contains_key("some random string")
4010 );
4011
4012 assert!(prot.feature_flags.lookup_attr("enable_poseidon".to_owned()) == Some(false));
4014 assert!(
4015 prot.feature_flags
4016 .attr_map()
4017 .get("enable_poseidon")
4018 .unwrap()
4019 == &false
4020 );
4021 let prot: ProtocolConfig =
4022 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
4023 assert!(prot.feature_flags.lookup_attr("enable_poseidon".to_owned()) == Some(true));
4025 assert!(
4026 prot.feature_flags
4027 .attr_map()
4028 .get("enable_poseidon")
4029 .unwrap()
4030 == &true
4031 );
4032 }
4033
4034 #[test]
4038 #[should_panic(expected = "deny_rule_update_max_entries_per_tx must be positive")]
4039 fn deny_rule_chunk_limit_above_the_ceiling_is_rejected() {
4040 let _guard = ProtocolConfig::apply_overrides_for_testing(|_, mut config| {
4041 config.set_deny_rule_governance_for_testing(true);
4042 config.set_deny_rule_governance_on_chain_for_testing(true);
4043 config.set_deny_rule_removal_grace_round_floor_for_testing(0);
4044 config.set_deny_rule_update_max_entries_per_tx_for_testing(2048 + 1);
4045 config
4046 });
4047 let _ = ProtocolConfig::get_for_version(ProtocolVersion::max(), Chain::Unknown);
4048 }
4049
4050 #[test]
4053 #[should_panic(expected = "deny_rule_update_max_entries_per_tx must be positive")]
4054 fn deny_rule_chunk_limit_of_zero_is_rejected() {
4055 let _guard = ProtocolConfig::apply_overrides_for_testing(|_, mut config| {
4056 config.set_deny_rule_governance_for_testing(true);
4057 config.set_deny_rule_governance_on_chain_for_testing(true);
4058 config.set_deny_rule_removal_grace_round_floor_for_testing(0);
4059 config.set_deny_rule_update_max_entries_per_tx_for_testing(0);
4060 config
4061 });
4062 let _ = ProtocolConfig::get_for_version(ProtocolVersion::max(), Chain::Unknown);
4063 }
4064
4065 #[test]
4067 fn deny_rule_chunk_limit_within_system_tx_object_id_limit_is_accepted() {
4068 let _guard = ProtocolConfig::apply_overrides_for_testing(|_, mut config| {
4069 config.set_deny_rule_governance_for_testing(true);
4070 config.set_deny_rule_governance_on_chain_for_testing(true);
4071 config.set_deny_rule_removal_grace_round_floor_for_testing(0);
4072 config.set_deny_rule_update_max_entries_per_tx_for_testing(1000);
4073 config
4074 });
4075 let config = ProtocolConfig::get_for_version(ProtocolVersion::max(), Chain::Unknown);
4076 assert_eq!(config.deny_rule_update_max_entries_per_tx(), 1000);
4077 }
4078
4079 #[test]
4080 fn limit_range_fn_test() {
4081 let low = 100u32;
4082 let high = 10000u64;
4083
4084 assert!(check_limit!(1u8, low, high) == LimitThresholdCrossed::None);
4085 assert!(matches!(
4086 check_limit!(255u16, low, high),
4087 LimitThresholdCrossed::Soft(255u128, 100)
4088 ));
4089 assert!(matches!(
4096 check_limit!(2550000u64, low, high),
4097 LimitThresholdCrossed::Hard(2550000, 10000)
4098 ));
4099
4100 assert!(matches!(
4101 check_limit!(2550000u64, high, high),
4102 LimitThresholdCrossed::Hard(2550000, 10000)
4103 ));
4104
4105 assert!(matches!(
4106 check_limit!(1u8, high),
4107 LimitThresholdCrossed::None
4108 ));
4109
4110 assert!(check_limit!(255u16, high) == LimitThresholdCrossed::None);
4111
4112 assert!(matches!(
4113 check_limit!(2550000u64, high),
4114 LimitThresholdCrossed::Hard(2550000, 10000)
4115 ));
4116 }
4117}