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 = 36;
23
24pub const PROTOCOL_VERSION_IIP8: u64 = 20;
26#[derive(Copy, Clone, Debug, Hash, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)]
237pub struct ProtocolVersion(u64);
238
239impl ProtocolVersion {
240 pub const MIN: Self = Self(MIN_PROTOCOL_VERSION);
246
247 pub const MAX: Self = Self(MAX_PROTOCOL_VERSION);
248
249 #[cfg(not(msim))]
250 const MAX_ALLOWED: Self = Self::MAX;
251
252 #[cfg(msim)]
255 pub const MAX_ALLOWED: Self = Self(MAX_PROTOCOL_VERSION + 1);
256
257 pub fn new(v: u64) -> Self {
258 Self(v)
259 }
260
261 pub const fn as_u64(&self) -> u64 {
262 self.0
263 }
264
265 pub fn max() -> Self {
268 Self::MAX
269 }
270}
271
272impl From<u64> for ProtocolVersion {
273 fn from(v: u64) -> Self {
274 Self::new(v)
275 }
276}
277
278impl std::ops::Sub<u64> for ProtocolVersion {
279 type Output = Self;
280 fn sub(self, rhs: u64) -> Self::Output {
281 Self::new(self.0 - rhs)
282 }
283}
284
285impl std::ops::Add<u64> for ProtocolVersion {
286 type Output = Self;
287 fn add(self, rhs: u64) -> Self::Output {
288 Self::new(self.0 + rhs)
289 }
290}
291
292#[derive(
293 Clone, Serialize, Deserialize, Debug, PartialEq, Copy, PartialOrd, Ord, Eq, ValueEnum, Default,
294)]
295pub enum Chain {
296 Mainnet,
297 Testnet,
298 #[default]
299 Unknown,
300}
301
302impl Chain {
303 pub fn as_str(self) -> &'static str {
304 match self {
305 Chain::Mainnet => "mainnet",
306 Chain::Testnet => "testnet",
307 Chain::Unknown => "unknown",
308 }
309 }
310}
311
312pub struct Error(pub String);
313
314#[derive(
318 Default,
319 Clone,
320 Serialize,
321 Deserialize,
322 Debug,
323 ProtocolConfigFeatureFlagsGetters,
324 ProtocolConfigOverride,
325)]
326struct FeatureFlags {
327 #[serde(skip_serializing_if = "is_true")]
333 disable_invariant_violation_check_in_swap_loc: bool,
334
335 #[serde(skip_serializing_if = "is_true")]
338 no_extraneous_module_bytes: bool,
339
340 #[serde(skip_serializing_if = "ConsensusTransactionOrdering::is_none")]
342 consensus_transaction_ordering: ConsensusTransactionOrdering,
343
344 #[serde(skip_serializing_if = "is_true")]
347 hardened_otw_check: bool,
348
349 #[serde(skip_serializing_if = "is_false")]
351 enable_poseidon: bool,
352
353 #[serde(skip_serializing_if = "is_false")]
355 enable_group_ops_native_function_msm: bool,
356
357 #[serde(skip_serializing_if = "PerObjectCongestionControlMode::is_none")]
359 per_object_congestion_control_mode: PerObjectCongestionControlMode,
360
361 #[serde(
363 default = "ConsensusChoice::mysticeti_deprecated",
364 skip_serializing_if = "ConsensusChoice::is_mysticeti_deprecated"
365 )]
366 consensus_choice: ConsensusChoice,
367
368 #[serde(skip_serializing_if = "ConsensusNetwork::is_tonic")]
370 consensus_network: ConsensusNetwork,
371
372 #[deprecated]
374 #[serde(skip_serializing_if = "Option::is_none")]
375 zklogin_max_epoch_upper_bound_delta: Option<u64>,
376
377 #[serde(skip_serializing_if = "is_false")]
379 enable_vdf: bool,
380
381 #[serde(skip_serializing_if = "is_false")]
383 passkey_auth: bool,
384
385 #[serde(skip_serializing_if = "is_true")]
388 rethrow_serialization_type_layout_errors: bool,
389
390 #[serde(skip_serializing_if = "is_false")]
392 relocate_event_module: bool,
393
394 #[serde(skip_serializing_if = "is_false")]
396 protocol_defined_base_fee: bool,
397
398 #[serde(skip_serializing_if = "is_false")]
400 uncompressed_g1_group_elements: bool,
401
402 #[serde(skip_serializing_if = "is_false")]
404 disallow_new_modules_in_deps_only_packages: bool,
405
406 #[serde(skip_serializing_if = "is_false")]
408 native_charging_v2: bool,
409
410 #[serde(skip_serializing_if = "is_false")]
412 convert_type_argument_error: bool,
413
414 #[serde(skip_serializing_if = "is_false")]
416 consensus_round_prober: bool,
417
418 #[serde(skip_serializing_if = "is_false")]
420 consensus_distributed_vote_scoring_strategy: bool,
421
422 #[serde(skip_serializing_if = "is_false")]
426 consensus_linearize_subdag_v2: bool,
427
428 #[serde(skip_serializing_if = "is_false")]
430 variant_nodes: bool,
431
432 #[serde(skip_serializing_if = "is_false")]
434 consensus_smart_ancestor_selection: bool,
435
436 #[serde(skip_serializing_if = "is_false")]
438 consensus_round_prober_probe_accepted_rounds: bool,
439
440 #[serde(skip_serializing_if = "is_false")]
442 consensus_zstd_compression: bool,
443
444 #[serde(skip_serializing_if = "is_false")]
447 congestion_control_min_free_execution_slot: bool,
448
449 #[serde(skip_serializing_if = "is_false")]
451 accept_passkey_in_multisig: bool,
452
453 #[serde(skip_serializing_if = "is_false")]
455 consensus_batched_block_sync: bool,
456
457 #[serde(skip_serializing_if = "is_false")]
460 congestion_control_gas_price_feedback_mechanism: bool,
461
462 #[serde(skip_serializing_if = "is_false")]
464 validate_identifier_inputs: bool,
465
466 #[serde(skip_serializing_if = "is_false")]
469 minimize_child_object_mutations: bool,
470
471 #[serde(skip_serializing_if = "is_false")]
473 dependency_linkage_error: bool,
474
475 #[serde(skip_serializing_if = "is_false")]
477 additional_multisig_checks: bool,
478
479 #[serde(skip_serializing_if = "is_false")]
482 normalize_ptb_arguments: bool,
483
484 #[serde(skip_serializing_if = "is_false")]
488 select_committee_from_eligible_validators: bool,
489
490 #[serde(skip_serializing_if = "is_false")]
497 track_non_committee_eligible_validators: bool,
498
499 #[serde(skip_serializing_if = "is_false")]
505 select_committee_supporting_next_epoch_version: bool,
506
507 #[serde(skip_serializing_if = "is_false")]
511 consensus_median_timestamp_with_checkpoint_enforcement: bool,
512
513 #[serde(skip_serializing_if = "is_false")]
515 consensus_commit_transactions_only_for_traversed_headers: bool,
516
517 #[serde(skip_serializing_if = "is_false")]
519 congestion_limit_overshoot_in_gas_price_feedback_mechanism: bool,
520
521 #[serde(skip_serializing_if = "is_false")]
524 separate_gas_price_feedback_mechanism_for_randomness: bool,
525
526 #[serde(skip_serializing_if = "is_false")]
529 metadata_in_module_bytes: bool,
530
531 #[serde(skip_serializing_if = "is_false")]
533 publish_package_metadata: bool,
534
535 #[serde(skip_serializing_if = "is_false")]
537 enable_move_authentication: bool,
538
539 #[serde(skip_serializing_if = "is_false")]
541 enable_move_authentication_for_sponsor: bool,
542
543 #[serde(skip_serializing_if = "is_false")]
545 pass_validator_scores_to_advance_epoch: bool,
546
547 #[serde(skip_serializing_if = "is_false")]
549 calculate_validator_scores: bool,
550
551 #[serde(skip_serializing_if = "is_false")]
553 adjust_rewards_by_score: bool,
554
555 #[serde(skip_serializing_if = "is_false")]
558 pass_calculated_validator_scores_to_advance_epoch: bool,
559
560 #[serde(skip_serializing_if = "is_false")]
565 consensus_fast_commit_sync: bool,
566
567 #[serde(skip_serializing_if = "is_false")]
570 consensus_block_restrictions: bool,
571
572 #[serde(skip_serializing_if = "is_false")]
574 move_native_tx_context: bool,
575
576 #[serde(skip_serializing_if = "is_false")]
578 additional_borrow_checks: bool,
579
580 #[serde(skip_serializing_if = "is_false")]
582 pre_consensus_sponsor_only_move_authentication: bool,
583
584 #[serde(skip_serializing_if = "is_false")]
586 consensus_starfish_speed: bool,
587
588 #[serde(skip_serializing_if = "is_false")]
595 always_advance_dkg_to_resolution: bool,
596
597 #[serde(skip_serializing_if = "is_false")]
602 enable_pcool_flow: bool,
603
604 #[serde(skip_serializing_if = "is_false")]
609 pcool_skip_immutable_object_locks: bool,
610
611 #[serde(skip_serializing_if = "is_false")]
616 pcool_verifier_limits_from_protocol_config: bool,
617
618 #[serde(skip_serializing_if = "is_false")]
620 validator_metadata_verify_v2: bool,
621
622 #[serde(skip_serializing_if = "is_false")]
626 deny_rule_governance: bool,
627
628 #[serde(skip_serializing_if = "is_false")]
633 deny_rule_governance_on_chain: bool,
634
635 #[serde(skip_serializing_if = "is_false")]
638 package_metadata_with_dynamic_module_metadata: bool,
639
640 #[serde(skip_serializing_if = "is_false")]
643 report_move_authentication_error: bool,
644
645 #[serde(skip_serializing_if = "is_false")]
650 consensus_enable_sliding_window_leader_schedule: bool,
651
652 #[serde(skip_serializing_if = "is_false")]
657 consensus_enable_absolute_score_leader_schedule: bool,
658
659 #[serde(skip_serializing_if = "is_false")]
661 max_ptb_value_size_v2: bool,
662
663 #[serde(skip_serializing_if = "is_false")]
665 allow_unbounded_system_objects: bool,
666
667 #[serde(skip_serializing_if = "is_false")]
673 validate_input_object_versions: bool,
674
675 #[serde(skip_serializing_if = "is_false")]
677 disallow_self_identifier: bool,
678}
679
680fn is_true(b: &bool) -> bool {
681 *b
682}
683
684fn is_false(b: &bool) -> bool {
685 !b
686}
687
688#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
690pub enum ConsensusTransactionOrdering {
691 #[default]
694 None,
695 ByGasPrice,
697}
698
699impl ConsensusTransactionOrdering {
700 pub fn is_none(&self) -> bool {
701 matches!(self, ConsensusTransactionOrdering::None)
702 }
703}
704
705#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
707pub enum PerObjectCongestionControlMode {
708 #[default]
709 None, TotalGasBudget, TotalTxCount, }
713
714impl PerObjectCongestionControlMode {
715 pub fn is_none(&self) -> bool {
716 matches!(self, PerObjectCongestionControlMode::None)
717 }
718}
719
720#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
722pub enum ConsensusChoice {
723 #[deprecated(note = "Mysticeti was replaced by Starfish")]
726 MysticetiDeprecated,
727 #[default]
728 Starfish,
729}
730
731#[expect(deprecated)]
732impl ConsensusChoice {
733 fn mysticeti_deprecated() -> Self {
740 ConsensusChoice::MysticetiDeprecated
741 }
742
743 pub fn is_mysticeti_deprecated(&self) -> bool {
744 matches!(self, ConsensusChoice::MysticetiDeprecated)
745 }
746 pub fn is_starfish(&self) -> bool {
747 matches!(self, ConsensusChoice::Starfish)
748 }
749}
750
751#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
753pub enum ConsensusNetwork {
754 #[default]
755 Tonic,
756}
757
758impl ConsensusNetwork {
759 pub fn is_tonic(&self) -> bool {
760 matches!(self, ConsensusNetwork::Tonic)
761 }
762}
763
764#[skip_serializing_none]
798#[derive(Clone, Serialize, Debug, ProtocolConfigAccessors, ProtocolConfigOverride)]
799pub struct ProtocolConfig {
800 pub version: ProtocolVersion,
801
802 feature_flags: FeatureFlags,
803
804 max_tx_size_bytes: Option<u64>,
809
810 max_input_objects: Option<u64>,
813
814 max_size_written_objects: Option<u64>,
819 max_size_written_objects_system_tx: Option<u64>,
823
824 max_serialized_tx_effects_size_bytes: Option<u64>,
826
827 max_serialized_tx_effects_size_bytes_system_tx: Option<u64>,
829
830 max_gas_payment_objects: Option<u32>,
832
833 max_modules_in_publish: Option<u32>,
835
836 max_package_dependencies: Option<u32>,
838
839 max_arguments: Option<u32>,
842
843 max_type_arguments: Option<u32>,
845
846 max_type_argument_depth: Option<u32>,
848
849 max_pure_argument_size: Option<u32>,
851
852 max_programmable_tx_commands: Option<u32>,
854
855 move_binary_format_version: Option<u32>,
861 min_move_binary_format_version: Option<u32>,
862
863 binary_module_handles: Option<u16>,
865 binary_struct_handles: Option<u16>,
866 binary_function_handles: Option<u16>,
867 binary_function_instantiations: Option<u16>,
868 binary_signatures: Option<u16>,
869 binary_constant_pool: Option<u16>,
870 binary_identifiers: Option<u16>,
871 binary_address_identifiers: Option<u16>,
872 binary_struct_defs: Option<u16>,
873 binary_struct_def_instantiations: Option<u16>,
874 binary_function_defs: Option<u16>,
875 binary_field_handles: Option<u16>,
876 binary_field_instantiations: Option<u16>,
877 binary_friend_decls: Option<u16>,
878 binary_enum_defs: Option<u16>,
879 binary_enum_def_instantiations: Option<u16>,
880 binary_variant_handles: Option<u16>,
881 binary_variant_instantiation_handles: Option<u16>,
882
883 max_move_object_size: Option<u64>,
886
887 max_move_package_size: Option<u64>,
892
893 max_publish_or_upgrade_per_ptb: Option<u64>,
896
897 max_tx_gas: Option<u64>,
899
900 max_auth_gas: Option<u64>,
902
903 max_gas_price: Option<u64>,
906
907 max_gas_computation_bucket: Option<u64>,
910
911 gas_rounding_step: Option<u64>,
913
914 max_loop_depth: Option<u64>,
916
917 max_generic_instantiation_length: Option<u64>,
920
921 max_function_parameters: Option<u64>,
924
925 max_basic_blocks: Option<u64>,
928
929 max_value_stack_size: Option<u64>,
931
932 max_type_nodes: Option<u64>,
936
937 max_push_size: Option<u64>,
940
941 max_struct_definitions: Option<u64>,
944
945 max_function_definitions: Option<u64>,
948
949 max_fields_in_struct: Option<u64>,
952
953 max_dependency_depth: Option<u64>,
956
957 max_num_event_emit: Option<u64>,
960
961 max_num_new_move_object_ids: Option<u64>,
964
965 max_num_new_move_object_ids_system_tx: Option<u64>,
968
969 max_num_deleted_move_object_ids: Option<u64>,
972
973 max_num_deleted_move_object_ids_system_tx: Option<u64>,
976
977 max_num_transferred_move_object_ids: Option<u64>,
980
981 max_num_transferred_move_object_ids_system_tx: Option<u64>,
984
985 max_event_emit_size: Option<u64>,
987
988 max_event_emit_size_total: Option<u64>,
990
991 max_move_vector_len: Option<u64>,
994
995 max_move_identifier_len: Option<u64>,
998
999 max_move_value_depth: Option<u64>,
1001
1002 max_move_enum_variants: Option<u64>,
1005
1006 max_back_edges_per_function: Option<u64>,
1015
1016 max_back_edges_per_module: Option<u64>,
1018
1019 max_verifier_meter_ticks_per_function: Option<u64>,
1021
1022 max_meter_ticks_per_module: Option<u64>,
1024
1025 max_meter_ticks_per_package: Option<u64>,
1027
1028 max_meter_ticks_regex_reference_safety: Option<u64>,
1032
1033 object_runtime_max_num_cached_objects: Option<u64>,
1040
1041 object_runtime_max_num_cached_objects_system_tx: Option<u64>,
1044
1045 object_runtime_max_num_store_entries: Option<u64>,
1048
1049 object_runtime_max_num_store_entries_system_tx: Option<u64>,
1052
1053 base_tx_cost_fixed: Option<u64>,
1058
1059 package_publish_cost_fixed: Option<u64>,
1063
1064 base_tx_cost_per_byte: Option<u64>,
1068
1069 package_publish_cost_per_byte: Option<u64>,
1071
1072 obj_access_cost_read_per_byte: Option<u64>,
1074
1075 obj_access_cost_mutate_per_byte: Option<u64>,
1077
1078 obj_access_cost_delete_per_byte: Option<u64>,
1080
1081 obj_access_cost_verify_per_byte: Option<u64>,
1091
1092 max_type_to_layout_nodes: Option<u64>,
1094
1095 max_ptb_value_size: Option<u64>,
1097
1098 gas_model_version: Option<u64>,
1103
1104 obj_data_cost_refundable: Option<u64>,
1110
1111 obj_metadata_cost_non_refundable: Option<u64>,
1115
1116 storage_rebate_rate: Option<u64>,
1122
1123 reward_slashing_rate: Option<u64>,
1126
1127 storage_gas_price: Option<u64>,
1129
1130 base_gas_price: Option<u64>,
1132
1133 validator_target_reward: Option<u64>,
1135
1136 max_transactions_per_checkpoint: Option<u64>,
1143
1144 max_checkpoint_size_bytes: Option<u64>,
1148
1149 buffer_stake_for_protocol_upgrade_bps: Option<u64>,
1155
1156 address_from_bytes_cost_base: Option<u64>,
1161 address_to_u256_cost_base: Option<u64>,
1163 address_from_u256_cost_base: Option<u64>,
1165
1166 config_read_setting_impl_cost_base: Option<u64>,
1171 config_read_setting_impl_cost_per_byte: Option<u64>,
1172
1173 dynamic_field_hash_type_and_key_cost_base: Option<u64>,
1177 dynamic_field_hash_type_and_key_type_cost_per_byte: Option<u64>,
1178 dynamic_field_hash_type_and_key_value_cost_per_byte: Option<u64>,
1179 dynamic_field_hash_type_and_key_type_tag_cost_per_byte: Option<u64>,
1180 dynamic_field_add_child_object_cost_base: Option<u64>,
1183 dynamic_field_add_child_object_type_cost_per_byte: Option<u64>,
1184 dynamic_field_add_child_object_value_cost_per_byte: Option<u64>,
1185 dynamic_field_add_child_object_struct_tag_cost_per_byte: Option<u64>,
1186 dynamic_field_borrow_child_object_cost_base: Option<u64>,
1189 dynamic_field_borrow_child_object_child_ref_cost_per_byte: Option<u64>,
1190 dynamic_field_borrow_child_object_type_cost_per_byte: Option<u64>,
1191 dynamic_field_remove_child_object_cost_base: Option<u64>,
1194 dynamic_field_remove_child_object_child_cost_per_byte: Option<u64>,
1195 dynamic_field_remove_child_object_type_cost_per_byte: Option<u64>,
1196 dynamic_field_has_child_object_cost_base: Option<u64>,
1199 dynamic_field_has_child_object_with_ty_cost_base: Option<u64>,
1202 dynamic_field_has_child_object_with_ty_type_cost_per_byte: Option<u64>,
1203 dynamic_field_has_child_object_with_ty_type_tag_cost_per_byte: Option<u64>,
1204
1205 event_emit_cost_base: Option<u64>,
1208 event_emit_value_size_derivation_cost_per_byte: Option<u64>,
1209 event_emit_tag_size_derivation_cost_per_byte: Option<u64>,
1210 event_emit_output_cost_per_byte: Option<u64>,
1211
1212 object_borrow_uid_cost_base: Option<u64>,
1215 object_delete_impl_cost_base: Option<u64>,
1217 object_record_new_uid_cost_base: Option<u64>,
1219
1220 transfer_transfer_internal_cost_base: Option<u64>,
1223 transfer_freeze_object_cost_base: Option<u64>,
1225 transfer_share_object_cost_base: Option<u64>,
1227 transfer_receive_object_cost_base: Option<u64>,
1230
1231 tx_context_derive_id_cost_base: Option<u64>,
1234 tx_context_fresh_id_cost_base: Option<u64>,
1235 tx_context_sender_cost_base: Option<u64>,
1236 tx_context_digest_cost_base: Option<u64>,
1237 tx_context_epoch_cost_base: Option<u64>,
1238 tx_context_epoch_timestamp_ms_cost_base: Option<u64>,
1239 tx_context_sponsor_cost_base: Option<u64>,
1240 tx_context_rgp_cost_base: Option<u64>,
1241 tx_context_gas_price_cost_base: Option<u64>,
1242 tx_context_gas_budget_cost_base: Option<u64>,
1243 tx_context_ids_created_cost_base: Option<u64>,
1244 tx_context_replace_cost_base: Option<u64>,
1245
1246 types_is_one_time_witness_cost_base: Option<u64>,
1249 types_is_one_time_witness_type_tag_cost_per_byte: Option<u64>,
1250 types_is_one_time_witness_type_cost_per_byte: Option<u64>,
1251
1252 validator_validate_metadata_cost_base: Option<u64>,
1255 validator_validate_metadata_data_cost_per_byte: Option<u64>,
1256
1257 crypto_invalid_arguments_cost: Option<u64>,
1259 bls12381_bls12381_min_sig_verify_cost_base: Option<u64>,
1261 bls12381_bls12381_min_sig_verify_msg_cost_per_byte: Option<u64>,
1262 bls12381_bls12381_min_sig_verify_msg_cost_per_block: Option<u64>,
1263
1264 bls12381_bls12381_min_pk_verify_cost_base: Option<u64>,
1266 bls12381_bls12381_min_pk_verify_msg_cost_per_byte: Option<u64>,
1267 bls12381_bls12381_min_pk_verify_msg_cost_per_block: Option<u64>,
1268
1269 ecdsa_k1_ecrecover_keccak256_cost_base: Option<u64>,
1271 ecdsa_k1_ecrecover_keccak256_msg_cost_per_byte: Option<u64>,
1272 ecdsa_k1_ecrecover_keccak256_msg_cost_per_block: Option<u64>,
1273 ecdsa_k1_ecrecover_sha256_cost_base: Option<u64>,
1274 ecdsa_k1_ecrecover_sha256_msg_cost_per_byte: Option<u64>,
1275 ecdsa_k1_ecrecover_sha256_msg_cost_per_block: Option<u64>,
1276
1277 ecdsa_k1_decompress_pubkey_cost_base: Option<u64>,
1279
1280 ecdsa_k1_secp256k1_verify_keccak256_cost_base: Option<u64>,
1282 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_byte: Option<u64>,
1283 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_block: Option<u64>,
1284 ecdsa_k1_secp256k1_verify_sha256_cost_base: Option<u64>,
1285 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_byte: Option<u64>,
1286 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_block: Option<u64>,
1287
1288 ecdsa_r1_ecrecover_keccak256_cost_base: Option<u64>,
1290 ecdsa_r1_ecrecover_keccak256_msg_cost_per_byte: Option<u64>,
1291 ecdsa_r1_ecrecover_keccak256_msg_cost_per_block: Option<u64>,
1292 ecdsa_r1_ecrecover_sha256_cost_base: Option<u64>,
1293 ecdsa_r1_ecrecover_sha256_msg_cost_per_byte: Option<u64>,
1294 ecdsa_r1_ecrecover_sha256_msg_cost_per_block: Option<u64>,
1295
1296 ecdsa_r1_secp256r1_verify_keccak256_cost_base: Option<u64>,
1298 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_byte: Option<u64>,
1299 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_block: Option<u64>,
1300 ecdsa_r1_secp256r1_verify_sha256_cost_base: Option<u64>,
1301 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_byte: Option<u64>,
1302 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_block: Option<u64>,
1303
1304 ecvrf_ecvrf_verify_cost_base: Option<u64>,
1306 ecvrf_ecvrf_verify_alpha_string_cost_per_byte: Option<u64>,
1307 ecvrf_ecvrf_verify_alpha_string_cost_per_block: Option<u64>,
1308
1309 ed25519_ed25519_verify_cost_base: Option<u64>,
1311 ed25519_ed25519_verify_msg_cost_per_byte: Option<u64>,
1312 ed25519_ed25519_verify_msg_cost_per_block: Option<u64>,
1313
1314 groth16_prepare_verifying_key_bls12381_cost_base: Option<u64>,
1316 groth16_prepare_verifying_key_bn254_cost_base: Option<u64>,
1317
1318 groth16_verify_groth16_proof_internal_bls12381_cost_base: Option<u64>,
1320 groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input: Option<u64>,
1321 groth16_verify_groth16_proof_internal_bn254_cost_base: Option<u64>,
1322 groth16_verify_groth16_proof_internal_bn254_cost_per_public_input: Option<u64>,
1323 groth16_verify_groth16_proof_internal_public_input_cost_per_byte: Option<u64>,
1324
1325 hash_blake2b256_cost_base: Option<u64>,
1327 hash_blake2b256_data_cost_per_byte: Option<u64>,
1328 hash_blake2b256_data_cost_per_block: Option<u64>,
1329
1330 hash_keccak256_cost_base: Option<u64>,
1332 hash_keccak256_data_cost_per_byte: Option<u64>,
1333 hash_keccak256_data_cost_per_block: Option<u64>,
1334
1335 poseidon_bn254_cost_base: Option<u64>,
1337 poseidon_bn254_cost_per_block: Option<u64>,
1338
1339 group_ops_bls12381_decode_scalar_cost: Option<u64>,
1341 group_ops_bls12381_decode_g1_cost: Option<u64>,
1342 group_ops_bls12381_decode_g2_cost: Option<u64>,
1343 group_ops_bls12381_decode_gt_cost: Option<u64>,
1344 group_ops_bls12381_scalar_add_cost: Option<u64>,
1345 group_ops_bls12381_g1_add_cost: Option<u64>,
1346 group_ops_bls12381_g2_add_cost: Option<u64>,
1347 group_ops_bls12381_gt_add_cost: Option<u64>,
1348 group_ops_bls12381_scalar_sub_cost: Option<u64>,
1349 group_ops_bls12381_g1_sub_cost: Option<u64>,
1350 group_ops_bls12381_g2_sub_cost: Option<u64>,
1351 group_ops_bls12381_gt_sub_cost: Option<u64>,
1352 group_ops_bls12381_scalar_mul_cost: Option<u64>,
1353 group_ops_bls12381_g1_mul_cost: Option<u64>,
1354 group_ops_bls12381_g2_mul_cost: Option<u64>,
1355 group_ops_bls12381_gt_mul_cost: Option<u64>,
1356 group_ops_bls12381_scalar_div_cost: Option<u64>,
1357 group_ops_bls12381_g1_div_cost: Option<u64>,
1358 group_ops_bls12381_g2_div_cost: Option<u64>,
1359 group_ops_bls12381_gt_div_cost: Option<u64>,
1360 group_ops_bls12381_g1_hash_to_base_cost: Option<u64>,
1361 group_ops_bls12381_g2_hash_to_base_cost: Option<u64>,
1362 group_ops_bls12381_g1_hash_to_cost_per_byte: Option<u64>,
1363 group_ops_bls12381_g2_hash_to_cost_per_byte: Option<u64>,
1364 group_ops_bls12381_g1_msm_base_cost: Option<u64>,
1365 group_ops_bls12381_g2_msm_base_cost: Option<u64>,
1366 group_ops_bls12381_g1_msm_base_cost_per_input: Option<u64>,
1367 group_ops_bls12381_g2_msm_base_cost_per_input: Option<u64>,
1368 group_ops_bls12381_msm_max_len: Option<u32>,
1369 group_ops_bls12381_pairing_cost: Option<u64>,
1370 group_ops_bls12381_g1_to_uncompressed_g1_cost: Option<u64>,
1371 group_ops_bls12381_uncompressed_g1_to_g1_cost: Option<u64>,
1372 group_ops_bls12381_uncompressed_g1_sum_base_cost: Option<u64>,
1373 group_ops_bls12381_uncompressed_g1_sum_cost_per_term: Option<u64>,
1374 group_ops_bls12381_uncompressed_g1_sum_max_terms: Option<u64>,
1375
1376 hmac_hmac_sha3_256_cost_base: Option<u64>,
1378 hmac_hmac_sha3_256_input_cost_per_byte: Option<u64>,
1379 hmac_hmac_sha3_256_input_cost_per_block: Option<u64>,
1380
1381 #[deprecated]
1383 check_zklogin_id_cost_base: Option<u64>,
1384 #[deprecated]
1386 check_zklogin_issuer_cost_base: Option<u64>,
1387
1388 vdf_verify_vdf_cost: Option<u64>,
1389 vdf_hash_to_input_cost: Option<u64>,
1390
1391 bcs_per_byte_serialized_cost: Option<u64>,
1393 bcs_legacy_min_output_size_cost: Option<u64>,
1394 bcs_failure_cost: Option<u64>,
1395
1396 hash_sha2_256_base_cost: Option<u64>,
1397 hash_sha2_256_per_byte_cost: Option<u64>,
1398 hash_sha2_256_legacy_min_input_len_cost: Option<u64>,
1399 hash_sha3_256_base_cost: Option<u64>,
1400 hash_sha3_256_per_byte_cost: Option<u64>,
1401 hash_sha3_256_legacy_min_input_len_cost: Option<u64>,
1402 type_name_get_base_cost: Option<u64>,
1403 type_name_get_per_byte_cost: Option<u64>,
1404
1405 string_check_utf8_base_cost: Option<u64>,
1406 string_check_utf8_per_byte_cost: Option<u64>,
1407 string_is_char_boundary_base_cost: Option<u64>,
1408 string_sub_string_base_cost: Option<u64>,
1409 string_sub_string_per_byte_cost: Option<u64>,
1410 string_index_of_base_cost: Option<u64>,
1411 string_index_of_per_byte_pattern_cost: Option<u64>,
1412 string_index_of_per_byte_searched_cost: Option<u64>,
1413
1414 vector_empty_base_cost: Option<u64>,
1415 vector_length_base_cost: Option<u64>,
1416 vector_push_back_base_cost: Option<u64>,
1417 vector_push_back_legacy_per_abstract_memory_unit_cost: Option<u64>,
1418 vector_borrow_base_cost: Option<u64>,
1419 vector_pop_back_base_cost: Option<u64>,
1420 vector_destroy_empty_base_cost: Option<u64>,
1421 vector_swap_base_cost: Option<u64>,
1422 debug_print_base_cost: Option<u64>,
1423 debug_print_stack_trace_base_cost: Option<u64>,
1424
1425 execution_version: Option<u64>,
1427
1428 consensus_bad_nodes_stake_threshold: Option<u64>,
1432
1433 #[deprecated]
1434 max_jwk_votes_per_validator_per_epoch: Option<u64>,
1435 #[deprecated]
1439 max_age_of_jwk_in_epochs: Option<u64>,
1440
1441 random_beacon_reduction_allowed_delta: Option<u16>,
1445
1446 random_beacon_reduction_lower_bound: Option<u32>,
1449
1450 random_beacon_dkg_timeout_round: Option<u32>,
1453
1454 random_beacon_min_round_interval_ms: Option<u64>,
1456
1457 random_beacon_dkg_version: Option<u64>,
1461
1462 consensus_max_transaction_size_bytes: Option<u64>,
1467 consensus_max_transactions_in_block_bytes: Option<u64>,
1469 consensus_max_num_transactions_in_block: Option<u64>,
1471
1472 max_deferral_rounds_for_congestion_control: Option<u64>,
1476
1477 min_checkpoint_interval_ms: Option<u64>,
1479
1480 checkpoint_rate_window_size: Option<u64>,
1490
1491 checkpoint_summary_version_specific_data: Option<u64>,
1493
1494 max_soft_bundle_size: Option<u64>,
1497
1498 bridge_should_try_to_finalize_committee: Option<bool>,
1503
1504 max_accumulated_txn_cost_per_object_in_mysticeti_commit: Option<u64>,
1510
1511 max_committee_members_count: Option<u64>,
1515
1516 deny_rule_update_max_entries_per_tx: Option<u64>,
1521
1522 deny_rule_removal_grace_round_floor: Option<u64>,
1527
1528 consensus_gc_depth: Option<u32>,
1531
1532 consensus_max_acknowledgments_per_block: Option<u32>,
1538
1539 max_congestion_limit_overshoot_per_commit: Option<u64>,
1544
1545 max_concurrent_execution_workers: Option<u16>,
1552
1553 scorer_version: Option<u16>,
1562
1563 auth_context_digest_cost_base: Option<u64>,
1566 auth_context_tx_data_bytes_cost_base: Option<u64>,
1568 auth_context_tx_data_bytes_cost_per_byte: Option<u64>,
1569 auth_context_tx_commands_cost_base: Option<u64>,
1571 auth_context_tx_commands_cost_per_byte: Option<u64>,
1572 auth_context_tx_inputs_cost_base: Option<u64>,
1574 auth_context_tx_inputs_cost_per_byte: Option<u64>,
1575 auth_context_replace_cost_base: Option<u64>,
1578 auth_context_replace_cost_per_byte: Option<u64>,
1579 auth_context_authenticator_function_info_v1_cost_base: Option<u64>,
1583
1584 consensus_commits_per_schedule: Option<u32>,
1587
1588 min_validator_count: Option<u64>,
1591
1592 max_validator_count: Option<u64>,
1596
1597 min_validator_joining_stake: Option<u64>,
1601
1602 validator_low_stake_threshold: Option<u64>,
1607
1608 validator_very_low_stake_threshold: Option<u64>,
1612
1613 validator_low_stake_grace_period: Option<u64>,
1617
1618 consensus_leader_schedule_window_size: Option<u32>,
1622}
1623
1624impl ProtocolConfig {
1626 pub fn disable_invariant_violation_check_in_swap_loc(&self) -> bool {
1639 self.feature_flags
1640 .disable_invariant_violation_check_in_swap_loc
1641 }
1642
1643 pub fn no_extraneous_module_bytes(&self) -> bool {
1644 self.feature_flags.no_extraneous_module_bytes
1645 }
1646
1647 pub fn consensus_transaction_ordering(&self) -> ConsensusTransactionOrdering {
1648 self.feature_flags.consensus_transaction_ordering
1649 }
1650
1651 pub fn dkg_version(&self) -> u64 {
1652 self.random_beacon_dkg_version.unwrap_or(1)
1654 }
1655
1656 pub fn hardened_otw_check(&self) -> bool {
1657 self.feature_flags.hardened_otw_check
1658 }
1659
1660 pub fn enable_poseidon(&self) -> bool {
1661 self.feature_flags.enable_poseidon
1662 }
1663
1664 pub fn enable_group_ops_native_function_msm(&self) -> bool {
1665 self.feature_flags.enable_group_ops_native_function_msm
1666 }
1667
1668 pub fn per_object_congestion_control_mode(&self) -> PerObjectCongestionControlMode {
1669 self.feature_flags.per_object_congestion_control_mode
1670 }
1671
1672 pub fn consensus_choice(&self) -> ConsensusChoice {
1673 self.feature_flags.consensus_choice
1674 }
1675
1676 pub fn consensus_network(&self) -> ConsensusNetwork {
1677 self.feature_flags.consensus_network
1678 }
1679
1680 pub fn enable_vdf(&self) -> bool {
1681 self.feature_flags.enable_vdf
1682 }
1683
1684 pub fn passkey_auth(&self) -> bool {
1685 self.feature_flags.passkey_auth
1686 }
1687
1688 pub fn max_transaction_size_bytes(&self) -> u64 {
1689 self.consensus_max_transaction_size_bytes
1691 .unwrap_or(256 * 1024)
1692 }
1693
1694 pub fn max_transactions_in_block_bytes(&self) -> u64 {
1695 if cfg!(msim) {
1696 256 * 1024
1697 } else {
1698 self.consensus_max_transactions_in_block_bytes
1699 .unwrap_or(512 * 1024)
1700 }
1701 }
1702
1703 pub fn max_num_transactions_in_block(&self) -> u64 {
1704 if cfg!(msim) {
1705 8
1706 } else {
1707 self.consensus_max_num_transactions_in_block.unwrap_or(512)
1708 }
1709 }
1710
1711 pub fn rethrow_serialization_type_layout_errors(&self) -> bool {
1712 self.feature_flags.rethrow_serialization_type_layout_errors
1713 }
1714
1715 pub fn relocate_event_module(&self) -> bool {
1716 self.feature_flags.relocate_event_module
1717 }
1718
1719 pub fn protocol_defined_base_fee(&self) -> bool {
1720 self.feature_flags.protocol_defined_base_fee
1721 }
1722
1723 pub fn uncompressed_g1_group_elements(&self) -> bool {
1724 self.feature_flags.uncompressed_g1_group_elements
1725 }
1726
1727 pub fn disallow_new_modules_in_deps_only_packages(&self) -> bool {
1728 self.feature_flags
1729 .disallow_new_modules_in_deps_only_packages
1730 }
1731
1732 pub fn native_charging_v2(&self) -> bool {
1733 self.feature_flags.native_charging_v2
1734 }
1735
1736 pub fn consensus_round_prober(&self) -> bool {
1737 self.feature_flags.consensus_round_prober
1738 }
1739
1740 pub fn consensus_distributed_vote_scoring_strategy(&self) -> bool {
1741 self.feature_flags
1742 .consensus_distributed_vote_scoring_strategy
1743 }
1744
1745 pub fn gc_depth(&self) -> u32 {
1746 if cfg!(msim) {
1747 min(5, self.consensus_gc_depth.unwrap_or(0))
1749 } else {
1750 self.consensus_gc_depth.unwrap_or(0)
1751 }
1752 }
1753
1754 pub fn consensus_linearize_subdag_v2(&self) -> bool {
1755 let res = self.feature_flags.consensus_linearize_subdag_v2;
1756 assert!(
1757 !res || self.gc_depth() > 0,
1758 "The consensus linearize sub dag V2 requires GC to be enabled"
1759 );
1760 res
1761 }
1762
1763 pub fn consensus_max_acknowledgments_per_block_or_default(&self) -> u32 {
1764 self.consensus_max_acknowledgments_per_block.unwrap_or(400)
1765 }
1766
1767 pub fn max_acknowledgments_per_block(&self, committee_size: usize) -> usize {
1768 2 * committee_size
1769 }
1770
1771 pub fn max_commit_votes_per_block(&self, committee_size: usize) -> usize {
1772 committee_size
1773 }
1774
1775 pub fn variant_nodes(&self) -> bool {
1776 self.feature_flags.variant_nodes
1777 }
1778
1779 pub fn consensus_smart_ancestor_selection(&self) -> bool {
1780 self.feature_flags.consensus_smart_ancestor_selection
1781 }
1782
1783 pub fn consensus_round_prober_probe_accepted_rounds(&self) -> bool {
1784 self.feature_flags
1785 .consensus_round_prober_probe_accepted_rounds
1786 }
1787
1788 pub fn consensus_zstd_compression(&self) -> bool {
1789 self.feature_flags.consensus_zstd_compression
1790 }
1791
1792 pub fn congestion_control_min_free_execution_slot(&self) -> bool {
1793 self.feature_flags
1794 .congestion_control_min_free_execution_slot
1795 }
1796
1797 pub fn accept_passkey_in_multisig(&self) -> bool {
1798 self.feature_flags.accept_passkey_in_multisig
1799 }
1800
1801 pub fn consensus_batched_block_sync(&self) -> bool {
1802 self.feature_flags.consensus_batched_block_sync
1803 }
1804
1805 pub fn congestion_control_gas_price_feedback_mechanism(&self) -> bool {
1808 self.feature_flags
1809 .congestion_control_gas_price_feedback_mechanism
1810 }
1811
1812 pub fn validate_identifier_inputs(&self) -> bool {
1813 self.feature_flags.validate_identifier_inputs
1814 }
1815
1816 pub fn minimize_child_object_mutations(&self) -> bool {
1817 self.feature_flags.minimize_child_object_mutations
1818 }
1819
1820 pub fn dependency_linkage_error(&self) -> bool {
1821 self.feature_flags.dependency_linkage_error
1822 }
1823
1824 pub fn additional_multisig_checks(&self) -> bool {
1825 self.feature_flags.additional_multisig_checks
1826 }
1827
1828 pub fn consensus_num_requested_prior_commits_at_startup(&self) -> u32 {
1829 0
1832 }
1833
1834 pub fn normalize_ptb_arguments(&self) -> bool {
1835 self.feature_flags.normalize_ptb_arguments
1836 }
1837
1838 pub fn select_committee_from_eligible_validators(&self) -> bool {
1839 let res = self.feature_flags.select_committee_from_eligible_validators;
1840 assert!(
1841 !res || (self.protocol_defined_base_fee()
1842 && self.max_committee_members_count_as_option().is_some()),
1843 "select_committee_from_eligible_validators requires protocol_defined_base_fee and max_committee_members_count to be set"
1844 );
1845 res
1846 }
1847
1848 pub fn track_non_committee_eligible_validators(&self) -> bool {
1849 self.feature_flags.track_non_committee_eligible_validators
1850 }
1851
1852 pub fn select_committee_supporting_next_epoch_version(&self) -> bool {
1853 let res = self
1854 .feature_flags
1855 .select_committee_supporting_next_epoch_version;
1856 assert!(
1857 !res || (self.track_non_committee_eligible_validators()
1858 && self.select_committee_from_eligible_validators()),
1859 "select_committee_supporting_next_epoch_version requires select_committee_from_eligible_validators to be set"
1860 );
1861 res
1862 }
1863
1864 pub fn consensus_median_timestamp_with_checkpoint_enforcement(&self) -> bool {
1865 let res = self
1866 .feature_flags
1867 .consensus_median_timestamp_with_checkpoint_enforcement;
1868 assert!(
1869 !res || self.gc_depth() > 0,
1870 "The consensus median timestamp with checkpoint enforcement requires GC to be enabled"
1871 );
1872 res
1873 }
1874
1875 pub fn consensus_commit_transactions_only_for_traversed_headers(&self) -> bool {
1876 self.feature_flags
1877 .consensus_commit_transactions_only_for_traversed_headers
1878 }
1879
1880 pub fn congestion_limit_overshoot_in_gas_price_feedback_mechanism(&self) -> bool {
1883 self.feature_flags
1884 .congestion_limit_overshoot_in_gas_price_feedback_mechanism
1885 }
1886
1887 pub fn separate_gas_price_feedback_mechanism_for_randomness(&self) -> bool {
1890 self.feature_flags
1891 .separate_gas_price_feedback_mechanism_for_randomness
1892 }
1893
1894 pub fn metadata_in_module_bytes(&self) -> bool {
1895 self.feature_flags.metadata_in_module_bytes
1896 }
1897
1898 pub fn publish_package_metadata(&self) -> bool {
1899 self.feature_flags.publish_package_metadata
1900 }
1901
1902 pub fn enable_move_authentication(&self) -> bool {
1903 self.feature_flags.enable_move_authentication
1904 }
1905
1906 pub fn additional_borrow_checks(&self) -> bool {
1907 self.feature_flags.additional_borrow_checks
1908 }
1909
1910 pub fn enable_move_authentication_for_sponsor(&self) -> bool {
1911 let enable_move_authentication_for_sponsor =
1912 self.feature_flags.enable_move_authentication_for_sponsor;
1913 assert!(
1914 !enable_move_authentication_for_sponsor || self.enable_move_authentication(),
1915 "enable_move_authentication_for_sponsor requires enable_move_authentication to be set"
1916 );
1917 enable_move_authentication_for_sponsor
1918 }
1919
1920 pub fn pass_validator_scores_to_advance_epoch(&self) -> bool {
1921 self.feature_flags.pass_validator_scores_to_advance_epoch
1922 }
1923
1924 pub fn calculate_validator_scores(&self) -> bool {
1925 let calculate_validator_scores = self.feature_flags.calculate_validator_scores;
1926 assert!(
1927 !calculate_validator_scores || self.scorer_version.is_some(),
1928 "calculate_validator_scores requires scorer_version to be set"
1929 );
1930 calculate_validator_scores
1931 }
1932
1933 pub fn adjust_rewards_by_score(&self) -> bool {
1934 let adjust = self.feature_flags.adjust_rewards_by_score;
1935 assert!(
1936 !adjust || (self.scorer_version.is_some() && self.calculate_validator_scores()),
1937 "adjust_rewards_by_score requires scorer_version to be set"
1938 );
1939 adjust
1940 }
1941
1942 pub fn pass_calculated_validator_scores_to_advance_epoch(&self) -> bool {
1943 let pass = self
1944 .feature_flags
1945 .pass_calculated_validator_scores_to_advance_epoch;
1946 assert!(
1947 !pass
1948 || (self.pass_validator_scores_to_advance_epoch()
1949 && self.calculate_validator_scores()),
1950 "pass_calculated_validator_scores_to_advance_epoch requires pass_validator_scores_to_advance_epoch and calculate_validator_scores to be enabled"
1951 );
1952 pass
1953 }
1954 pub fn consensus_fast_commit_sync(&self) -> bool {
1955 let res = self.feature_flags.consensus_fast_commit_sync;
1956 assert!(
1957 !res || self.consensus_commit_transactions_only_for_traversed_headers(),
1958 "consensus_fast_commit_sync requires consensus_commit_transactions_only_for_traversed_headers to be enabled"
1959 );
1960 res
1961 }
1962
1963 pub fn consensus_block_restrictions(&self) -> bool {
1964 self.feature_flags.consensus_block_restrictions
1965 }
1966
1967 pub fn move_native_tx_context(&self) -> bool {
1968 self.feature_flags.move_native_tx_context
1969 }
1970
1971 pub fn pre_consensus_sponsor_only_move_authentication(&self) -> bool {
1972 let pre_consensus_sponsor_only_move_authentication = self
1973 .feature_flags
1974 .pre_consensus_sponsor_only_move_authentication;
1975 if pre_consensus_sponsor_only_move_authentication {
1976 assert!(
1977 self.enable_move_authentication(),
1978 "pre_consensus_sponsor_only_move_authentication requires enable_move_authentication to be set"
1979 );
1980 assert!(
1981 self.enable_move_authentication_for_sponsor(),
1982 "pre_consensus_sponsor_only_move_authentication requires enable_move_authentication_for_sponsor to be set"
1983 );
1984 }
1985 pre_consensus_sponsor_only_move_authentication
1986 }
1987
1988 pub fn consensus_starfish_speed(&self) -> bool {
1989 let res = self.feature_flags.consensus_starfish_speed;
1990 assert!(
1991 !res || self.consensus_fast_commit_sync(),
1992 "consensus_starfish_speed requires consensus_fast_commit_sync to be enabled"
1993 );
1994 res
1995 }
1996
1997 pub fn always_advance_dkg_to_resolution(&self) -> bool {
1998 self.feature_flags.always_advance_dkg_to_resolution
1999 }
2000
2001 pub fn enable_pcool_flow(&self) -> bool {
2002 self.feature_flags.enable_pcool_flow
2003 }
2004
2005 pub fn pcool_skip_immutable_object_locks(&self) -> bool {
2006 self.feature_flags.pcool_skip_immutable_object_locks
2007 }
2008
2009 pub fn pcool_verifier_limits_from_protocol_config(&self) -> bool {
2012 self.feature_flags
2013 .pcool_verifier_limits_from_protocol_config
2014 }
2015
2016 pub fn validator_metadata_verify_v2(&self) -> bool {
2017 self.feature_flags.validator_metadata_verify_v2
2018 }
2019
2020 pub fn commits_per_schedule(&self) -> u32 {
2021 let commits_per_schedule = if cfg!(msim) {
2022 min(10, self.consensus_commits_per_schedule.unwrap_or(300))
2024 } else {
2025 self.consensus_commits_per_schedule.unwrap_or(300)
2026 };
2027 assert!(
2028 commits_per_schedule > 0,
2029 "consensus_commits_per_schedule must be greater than 0"
2030 );
2031 commits_per_schedule
2032 }
2033
2034 pub fn leader_schedule_window_size(&self) -> u32 {
2035 if cfg!(msim) {
2036 min(
2039 20,
2040 self.consensus_leader_schedule_window_size.unwrap_or(600),
2041 )
2042 } else {
2043 self.consensus_leader_schedule_window_size.unwrap_or(600)
2044 }
2045 }
2046
2047 pub fn consensus_enable_sliding_window_leader_schedule(&self) -> bool {
2048 let res = self
2049 .feature_flags
2050 .consensus_enable_sliding_window_leader_schedule;
2051 assert!(
2052 !res || self.leader_schedule_window_size() >= self.commits_per_schedule(),
2053 "consensus_enable_sliding_window_leader_schedule requires window_size >= commits_per_schedule"
2054 );
2055 res
2056 }
2057
2058 pub fn consensus_enable_absolute_score_leader_schedule(&self) -> bool {
2059 self.feature_flags
2060 .consensus_enable_absolute_score_leader_schedule
2061 }
2062
2063 pub fn max_ptb_value_size_v2(&self) -> bool {
2064 self.feature_flags.max_ptb_value_size_v2
2065 }
2066
2067 pub fn deny_rule_governance(&self) -> bool {
2068 self.feature_flags.deny_rule_governance
2069 }
2070
2071 pub fn deny_rule_governance_on_chain(&self) -> bool {
2072 self.feature_flags.deny_rule_governance_on_chain
2073 }
2074
2075 pub fn package_metadata_with_dynamic_module_metadata(&self) -> bool {
2076 let res = self
2077 .feature_flags
2078 .package_metadata_with_dynamic_module_metadata;
2079 assert!(
2080 !res || self.publish_package_metadata(),
2081 "package_metadata_with_dynamic_module_metadata requires publish_package_metadata to be enabled"
2082 );
2083 res
2084 }
2085
2086 pub fn report_move_authentication_error(&self) -> bool {
2087 let report_move_authentication_error = self.feature_flags.report_move_authentication_error;
2088 assert!(
2089 !report_move_authentication_error || self.enable_move_authentication(),
2090 "report_move_authentication_error requires enable_move_authentication to be set"
2091 );
2092 report_move_authentication_error
2093 }
2094
2095 pub fn concurrent_execution_workers(&self) -> Option<u16> {
2099 let res = self.max_concurrent_execution_workers;
2100 assert!(
2101 res.is_none() || self.enable_pcool_flow(),
2102 "max_concurrent_execution_workers requires enable_pcool_flow to be enabled"
2103 );
2104 assert!(
2105 res.is_none()
2106 || self
2107 .max_accumulated_txn_cost_per_object_in_mysticeti_commit
2108 .is_some(),
2109 "max_concurrent_execution_workers requires per-object congestion control \
2110 (max_accumulated_txn_cost_per_object_in_mysticeti_commit) to be enabled"
2111 );
2112 assert!(
2113 res.is_none() || self.congestion_control_gas_price_feedback_mechanism(),
2114 "max_concurrent_execution_workers requires the gas price feedback mechanism \
2115 (congestion_control_gas_price_feedback_mechanism), which carries the suggested \
2116 gas price of an execution-worker congestion cancellation"
2117 );
2118 assert!(
2119 res.is_none() || !self.separate_gas_price_feedback_mechanism_for_randomness(),
2120 "max_concurrent_execution_workers implies a single congestion tracker and suggested \
2121 gas price calculator for all transactions, which is incompatible with \
2122 separate_gas_price_feedback_mechanism_for_randomness"
2123 );
2124 assert!(
2125 res != Some(0),
2126 "max_concurrent_execution_workers must be positive when set"
2127 );
2128 res
2129 }
2130
2131 pub fn allow_unbounded_system_objects(&self) -> bool {
2132 self.feature_flags.allow_unbounded_system_objects
2133 }
2134
2135 pub fn validate_input_object_versions(&self) -> bool {
2136 self.feature_flags.validate_input_object_versions
2137 }
2138}
2139
2140#[cfg(not(msim))]
2141static POISON_VERSION_METHODS: AtomicBool = const { AtomicBool::new(false) };
2142
2143#[cfg(msim)]
2145thread_local! {
2146 static POISON_VERSION_METHODS: AtomicBool = const { AtomicBool::new(false) };
2147}
2148
2149impl ProtocolConfig {
2151 pub fn get_for_version(version: ProtocolVersion, chain: Chain) -> Self {
2154 assert!(
2156 version >= ProtocolVersion::MIN,
2157 "Network protocol version is {:?}, but the minimum supported version by the binary is {:?}. Please upgrade the binary.",
2158 version,
2159 ProtocolVersion::MIN.0,
2160 );
2161 assert!(
2162 version <= ProtocolVersion::MAX_ALLOWED,
2163 "Network protocol version is {:?}, but the maximum supported version by the binary is {:?}. Please upgrade the binary.",
2164 version,
2165 ProtocolVersion::MAX_ALLOWED.0,
2166 );
2167
2168 let mut ret = Self::get_for_version_impl(version, chain);
2169 ret.version = version;
2170
2171 ret = CONFIG_OVERRIDE.with(|ovr| {
2172 if let Some(override_fn) = &*ovr.borrow() {
2173 warn!(
2174 "overriding ProtocolConfig settings with custom settings (you should not see this log outside of tests)"
2175 );
2176 override_fn(version, ret)
2177 } else {
2178 ret
2179 }
2180 });
2181
2182 if std::env::var("IOTA_PROTOCOL_CONFIG_OVERRIDE_ENABLE").is_ok() {
2183 warn!(
2184 "overriding ProtocolConfig settings with custom settings; this may break non-local networks"
2185 );
2186
2187 let overrides: ProtocolConfigOptional =
2189 serde_env::from_env_with_prefix("IOTA_PROTOCOL_CONFIG_OVERRIDE")
2190 .expect("failed to parse ProtocolConfig override env variables");
2191 overrides.apply_to(&mut ret);
2192
2193 let feature_flag_overrides: FeatureFlagsOptional =
2195 serde_env::from_env_with_prefix("IOTA_PROTOCOL_CONFIG_FEATURE_FLAGS_OVERRIDE")
2196 .expect("failed to parse ProtocolConfig feature flags override env variables");
2197
2198 feature_flag_overrides.apply_to(&mut ret.feature_flags);
2199 }
2200
2201 assert!(
2203 !ret.feature_flags.deny_rule_governance_on_chain
2204 || ret.feature_flags.deny_rule_governance,
2205 "deny_rule_governance_on_chain requires deny_rule_governance"
2206 );
2207 assert!(
2212 !ret.feature_flags.pcool_verifier_limits_from_protocol_config
2213 || ret.max_meter_ticks_regex_reference_safety.is_some(),
2214 "pcool_verifier_limits_from_protocol_config requires \
2215 max_meter_ticks_regex_reference_safety"
2216 );
2217 assert!(
2220 !ret.feature_flags.deny_rule_governance_on_chain
2221 || (ret.deny_rule_update_max_entries_per_tx.is_some()
2222 && ret.deny_rule_removal_grace_round_floor.is_some()),
2223 "deny_rule_governance_on_chain requires deny_rule_update_max_entries_per_tx and deny_rule_removal_grace_round_floor"
2224 );
2225 const DENY_RULE_UPDATE_MAX_ENTRIES_PER_TX_CEILING: u64 = 2048;
2233 assert!(
2234 ret.deny_rule_update_max_entries_per_tx
2235 .is_none_or(|max_entries| {
2236 max_entries > 0
2237 && max_entries <= DENY_RULE_UPDATE_MAX_ENTRIES_PER_TX_CEILING
2238 && [
2239 ret.max_num_new_move_object_ids_system_tx,
2240 ret.max_num_deleted_move_object_ids_system_tx,
2241 ret.object_runtime_max_num_cached_objects_system_tx,
2242 ret.object_runtime_max_num_store_entries_system_tx,
2243 ]
2244 .iter()
2245 .all(|limit| limit.is_none_or(|limit| max_entries <= limit))
2246 }),
2247 "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"
2248 );
2249
2250 ret
2251 }
2252
2253 pub fn get_for_version_if_supported(version: ProtocolVersion, chain: Chain) -> Option<Self> {
2256 if version.0 >= ProtocolVersion::MIN.0 && version.0 <= ProtocolVersion::MAX_ALLOWED.0 {
2257 let mut ret = Self::get_for_version_impl(version, chain);
2258 ret.version = version;
2259 Some(ret)
2260 } else {
2261 None
2262 }
2263 }
2264
2265 #[cfg(not(msim))]
2266 pub fn poison_get_for_min_version() {
2267 POISON_VERSION_METHODS.store(true, Ordering::Relaxed);
2268 }
2269
2270 #[cfg(not(msim))]
2271 fn load_poison_get_for_min_version() -> bool {
2272 POISON_VERSION_METHODS.load(Ordering::Relaxed)
2273 }
2274
2275 #[cfg(msim)]
2276 pub fn poison_get_for_min_version() {
2277 POISON_VERSION_METHODS.with(|p| p.store(true, Ordering::Relaxed));
2278 }
2279
2280 #[cfg(msim)]
2281 fn load_poison_get_for_min_version() -> bool {
2282 POISON_VERSION_METHODS.with(|p| p.load(Ordering::Relaxed))
2283 }
2284
2285 pub fn convert_type_argument_error(&self) -> bool {
2286 self.feature_flags.convert_type_argument_error
2287 }
2288
2289 pub fn get_for_min_version() -> Self {
2293 if Self::load_poison_get_for_min_version() {
2294 panic!("get_for_min_version called on validator");
2295 }
2296 ProtocolConfig::get_for_version(ProtocolVersion::MIN, Chain::Unknown)
2297 }
2298
2299 #[expect(non_snake_case)]
2310 pub fn get_for_max_version_UNSAFE() -> Self {
2311 if Self::load_poison_get_for_min_version() {
2312 panic!("get_for_max_version_UNSAFE called on validator");
2313 }
2314 ProtocolConfig::get_for_version(ProtocolVersion::MAX, Chain::Unknown)
2315 }
2316
2317 fn get_for_version_impl(version: ProtocolVersion, chain: Chain) -> Self {
2318 #[cfg(msim)]
2319 {
2320 if version > ProtocolVersion::MAX {
2322 let mut config = Self::get_for_version_impl(ProtocolVersion::MAX, Chain::Unknown);
2323 config.base_tx_cost_fixed = Some(config.base_tx_cost_fixed() + 1000);
2324 return config;
2325 }
2326 }
2327
2328 let mut cfg = Self {
2332 version,
2333
2334 feature_flags: Default::default(),
2335
2336 max_tx_size_bytes: Some(128 * 1024),
2337 max_input_objects: Some(2048),
2340 max_serialized_tx_effects_size_bytes: Some(512 * 1024),
2341 max_serialized_tx_effects_size_bytes_system_tx: Some(512 * 1024 * 16),
2342 max_gas_payment_objects: Some(256),
2343 max_modules_in_publish: Some(64),
2344 max_package_dependencies: Some(32),
2345 max_arguments: Some(512),
2346 max_type_arguments: Some(16),
2347 max_type_argument_depth: Some(16),
2348 max_pure_argument_size: Some(16 * 1024),
2349 max_programmable_tx_commands: Some(1024),
2350 move_binary_format_version: Some(7),
2351 min_move_binary_format_version: Some(6),
2352 binary_module_handles: Some(100),
2353 binary_struct_handles: Some(300),
2354 binary_function_handles: Some(1500),
2355 binary_function_instantiations: Some(750),
2356 binary_signatures: Some(1000),
2357 binary_constant_pool: Some(4000),
2358 binary_identifiers: Some(10000),
2359 binary_address_identifiers: Some(100),
2360 binary_struct_defs: Some(200),
2361 binary_struct_def_instantiations: Some(100),
2362 binary_function_defs: Some(1000),
2363 binary_field_handles: Some(500),
2364 binary_field_instantiations: Some(250),
2365 binary_friend_decls: Some(100),
2366 binary_enum_defs: None,
2367 binary_enum_def_instantiations: None,
2368 binary_variant_handles: None,
2369 binary_variant_instantiation_handles: None,
2370 max_move_object_size: Some(250 * 1024),
2371 max_move_package_size: Some(100 * 1024),
2372 max_publish_or_upgrade_per_ptb: Some(5),
2373 max_auth_gas: None,
2375 max_tx_gas: Some(50_000_000_000),
2377 max_gas_price: Some(100_000),
2378 max_gas_computation_bucket: Some(5_000_000),
2379 max_loop_depth: Some(5),
2380 max_generic_instantiation_length: Some(32),
2381 max_function_parameters: Some(128),
2382 max_basic_blocks: Some(1024),
2383 max_value_stack_size: Some(1024),
2384 max_type_nodes: Some(256),
2385 max_push_size: Some(10000),
2386 max_struct_definitions: Some(200),
2387 max_function_definitions: Some(1000),
2388 max_fields_in_struct: Some(32),
2389 max_dependency_depth: Some(100),
2390 max_num_event_emit: Some(1024),
2391 max_num_new_move_object_ids: Some(2048),
2392 max_num_new_move_object_ids_system_tx: Some(2048 * 16),
2393 max_num_deleted_move_object_ids: Some(2048),
2394 max_num_deleted_move_object_ids_system_tx: Some(2048 * 16),
2395 max_num_transferred_move_object_ids: Some(2048),
2396 max_num_transferred_move_object_ids_system_tx: Some(2048 * 16),
2397 max_event_emit_size: Some(250 * 1024),
2398 max_move_vector_len: Some(256 * 1024),
2399 max_type_to_layout_nodes: None,
2400 max_ptb_value_size: None,
2401
2402 max_back_edges_per_function: Some(10_000),
2403 max_back_edges_per_module: Some(10_000),
2404
2405 max_verifier_meter_ticks_per_function: Some(16_000_000),
2406
2407 max_meter_ticks_per_module: Some(16_000_000),
2408 max_meter_ticks_per_package: Some(16_000_000),
2409 max_meter_ticks_regex_reference_safety: None,
2410
2411 object_runtime_max_num_cached_objects: Some(1000),
2412 object_runtime_max_num_cached_objects_system_tx: Some(1000 * 16),
2413 object_runtime_max_num_store_entries: Some(1000),
2414 object_runtime_max_num_store_entries_system_tx: Some(1000 * 16),
2415 base_tx_cost_fixed: Some(1_000),
2417 package_publish_cost_fixed: Some(1_000),
2418 base_tx_cost_per_byte: Some(0),
2419 package_publish_cost_per_byte: Some(80),
2420 obj_access_cost_read_per_byte: Some(15),
2421 obj_access_cost_mutate_per_byte: Some(40),
2422 obj_access_cost_delete_per_byte: Some(40),
2423 obj_access_cost_verify_per_byte: Some(200),
2424 obj_data_cost_refundable: Some(100),
2425 obj_metadata_cost_non_refundable: Some(50),
2426 gas_model_version: Some(1),
2427 storage_rebate_rate: Some(10000),
2428 reward_slashing_rate: Some(10000),
2430 storage_gas_price: Some(76),
2431 base_gas_price: None,
2432 validator_target_reward: Some(767_000 * 1_000_000_000),
2435 max_transactions_per_checkpoint: Some(10_000),
2436 max_checkpoint_size_bytes: Some(30 * 1024 * 1024),
2437
2438 buffer_stake_for_protocol_upgrade_bps: Some(5000),
2440
2441 address_from_bytes_cost_base: Some(52),
2445 address_to_u256_cost_base: Some(52),
2447 address_from_u256_cost_base: Some(52),
2449
2450 config_read_setting_impl_cost_base: Some(100),
2453 config_read_setting_impl_cost_per_byte: Some(40),
2454
2455 dynamic_field_hash_type_and_key_cost_base: Some(100),
2459 dynamic_field_hash_type_and_key_type_cost_per_byte: Some(2),
2460 dynamic_field_hash_type_and_key_value_cost_per_byte: Some(2),
2461 dynamic_field_hash_type_and_key_type_tag_cost_per_byte: Some(2),
2462 dynamic_field_add_child_object_cost_base: Some(100),
2465 dynamic_field_add_child_object_type_cost_per_byte: Some(10),
2466 dynamic_field_add_child_object_value_cost_per_byte: Some(10),
2467 dynamic_field_add_child_object_struct_tag_cost_per_byte: Some(10),
2468 dynamic_field_borrow_child_object_cost_base: Some(100),
2471 dynamic_field_borrow_child_object_child_ref_cost_per_byte: Some(10),
2472 dynamic_field_borrow_child_object_type_cost_per_byte: Some(10),
2473 dynamic_field_remove_child_object_cost_base: Some(100),
2476 dynamic_field_remove_child_object_child_cost_per_byte: Some(2),
2477 dynamic_field_remove_child_object_type_cost_per_byte: Some(2),
2478 dynamic_field_has_child_object_cost_base: Some(100),
2481 dynamic_field_has_child_object_with_ty_cost_base: Some(100),
2484 dynamic_field_has_child_object_with_ty_type_cost_per_byte: Some(2),
2485 dynamic_field_has_child_object_with_ty_type_tag_cost_per_byte: Some(2),
2486
2487 event_emit_cost_base: Some(52),
2490 event_emit_value_size_derivation_cost_per_byte: Some(2),
2491 event_emit_tag_size_derivation_cost_per_byte: Some(5),
2492 event_emit_output_cost_per_byte: Some(10),
2493
2494 object_borrow_uid_cost_base: Some(52),
2497 object_delete_impl_cost_base: Some(52),
2499 object_record_new_uid_cost_base: Some(52),
2501
2502 transfer_transfer_internal_cost_base: Some(52),
2506 transfer_freeze_object_cost_base: Some(52),
2508 transfer_share_object_cost_base: Some(52),
2510 transfer_receive_object_cost_base: Some(52),
2511
2512 tx_context_derive_id_cost_base: Some(52),
2516 tx_context_fresh_id_cost_base: None,
2517 tx_context_sender_cost_base: None,
2518 tx_context_digest_cost_base: None,
2519 tx_context_epoch_cost_base: None,
2520 tx_context_epoch_timestamp_ms_cost_base: None,
2521 tx_context_sponsor_cost_base: None,
2522 tx_context_rgp_cost_base: None,
2523 tx_context_gas_price_cost_base: None,
2524 tx_context_gas_budget_cost_base: None,
2525 tx_context_ids_created_cost_base: None,
2526 tx_context_replace_cost_base: None,
2527
2528 types_is_one_time_witness_cost_base: Some(52),
2531 types_is_one_time_witness_type_tag_cost_per_byte: Some(2),
2532 types_is_one_time_witness_type_cost_per_byte: Some(2),
2533
2534 validator_validate_metadata_cost_base: Some(52),
2538 validator_validate_metadata_data_cost_per_byte: Some(2),
2539
2540 crypto_invalid_arguments_cost: Some(100),
2542 bls12381_bls12381_min_sig_verify_cost_base: Some(52),
2544 bls12381_bls12381_min_sig_verify_msg_cost_per_byte: Some(2),
2545 bls12381_bls12381_min_sig_verify_msg_cost_per_block: Some(2),
2546
2547 bls12381_bls12381_min_pk_verify_cost_base: Some(52),
2549 bls12381_bls12381_min_pk_verify_msg_cost_per_byte: Some(2),
2550 bls12381_bls12381_min_pk_verify_msg_cost_per_block: Some(2),
2551
2552 ecdsa_k1_ecrecover_keccak256_cost_base: Some(52),
2554 ecdsa_k1_ecrecover_keccak256_msg_cost_per_byte: Some(2),
2555 ecdsa_k1_ecrecover_keccak256_msg_cost_per_block: Some(2),
2556 ecdsa_k1_ecrecover_sha256_cost_base: Some(52),
2557 ecdsa_k1_ecrecover_sha256_msg_cost_per_byte: Some(2),
2558 ecdsa_k1_ecrecover_sha256_msg_cost_per_block: Some(2),
2559
2560 ecdsa_k1_decompress_pubkey_cost_base: Some(52),
2562
2563 ecdsa_k1_secp256k1_verify_keccak256_cost_base: Some(52),
2565 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_byte: Some(2),
2566 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_block: Some(2),
2567 ecdsa_k1_secp256k1_verify_sha256_cost_base: Some(52),
2568 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_byte: Some(2),
2569 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_block: Some(2),
2570
2571 ecdsa_r1_ecrecover_keccak256_cost_base: Some(52),
2573 ecdsa_r1_ecrecover_keccak256_msg_cost_per_byte: Some(2),
2574 ecdsa_r1_ecrecover_keccak256_msg_cost_per_block: Some(2),
2575 ecdsa_r1_ecrecover_sha256_cost_base: Some(52),
2576 ecdsa_r1_ecrecover_sha256_msg_cost_per_byte: Some(2),
2577 ecdsa_r1_ecrecover_sha256_msg_cost_per_block: Some(2),
2578
2579 ecdsa_r1_secp256r1_verify_keccak256_cost_base: Some(52),
2581 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_byte: Some(2),
2582 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_block: Some(2),
2583 ecdsa_r1_secp256r1_verify_sha256_cost_base: Some(52),
2584 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_byte: Some(2),
2585 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_block: Some(2),
2586
2587 ecvrf_ecvrf_verify_cost_base: Some(52),
2589 ecvrf_ecvrf_verify_alpha_string_cost_per_byte: Some(2),
2590 ecvrf_ecvrf_verify_alpha_string_cost_per_block: Some(2),
2591
2592 ed25519_ed25519_verify_cost_base: Some(52),
2594 ed25519_ed25519_verify_msg_cost_per_byte: Some(2),
2595 ed25519_ed25519_verify_msg_cost_per_block: Some(2),
2596
2597 groth16_prepare_verifying_key_bls12381_cost_base: Some(52),
2599 groth16_prepare_verifying_key_bn254_cost_base: Some(52),
2600
2601 groth16_verify_groth16_proof_internal_bls12381_cost_base: Some(52),
2603 groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input: Some(2),
2604 groth16_verify_groth16_proof_internal_bn254_cost_base: Some(52),
2605 groth16_verify_groth16_proof_internal_bn254_cost_per_public_input: Some(2),
2606 groth16_verify_groth16_proof_internal_public_input_cost_per_byte: Some(2),
2607
2608 hash_blake2b256_cost_base: Some(52),
2610 hash_blake2b256_data_cost_per_byte: Some(2),
2611 hash_blake2b256_data_cost_per_block: Some(2),
2612 hash_keccak256_cost_base: Some(52),
2614 hash_keccak256_data_cost_per_byte: Some(2),
2615 hash_keccak256_data_cost_per_block: Some(2),
2616
2617 poseidon_bn254_cost_base: None,
2618 poseidon_bn254_cost_per_block: None,
2619
2620 hmac_hmac_sha3_256_cost_base: Some(52),
2622 hmac_hmac_sha3_256_input_cost_per_byte: Some(2),
2623 hmac_hmac_sha3_256_input_cost_per_block: Some(2),
2624
2625 group_ops_bls12381_decode_scalar_cost: Some(52),
2627 group_ops_bls12381_decode_g1_cost: Some(52),
2628 group_ops_bls12381_decode_g2_cost: Some(52),
2629 group_ops_bls12381_decode_gt_cost: Some(52),
2630 group_ops_bls12381_scalar_add_cost: Some(52),
2631 group_ops_bls12381_g1_add_cost: Some(52),
2632 group_ops_bls12381_g2_add_cost: Some(52),
2633 group_ops_bls12381_gt_add_cost: Some(52),
2634 group_ops_bls12381_scalar_sub_cost: Some(52),
2635 group_ops_bls12381_g1_sub_cost: Some(52),
2636 group_ops_bls12381_g2_sub_cost: Some(52),
2637 group_ops_bls12381_gt_sub_cost: Some(52),
2638 group_ops_bls12381_scalar_mul_cost: Some(52),
2639 group_ops_bls12381_g1_mul_cost: Some(52),
2640 group_ops_bls12381_g2_mul_cost: Some(52),
2641 group_ops_bls12381_gt_mul_cost: Some(52),
2642 group_ops_bls12381_scalar_div_cost: Some(52),
2643 group_ops_bls12381_g1_div_cost: Some(52),
2644 group_ops_bls12381_g2_div_cost: Some(52),
2645 group_ops_bls12381_gt_div_cost: Some(52),
2646 group_ops_bls12381_g1_hash_to_base_cost: Some(52),
2647 group_ops_bls12381_g2_hash_to_base_cost: Some(52),
2648 group_ops_bls12381_g1_hash_to_cost_per_byte: Some(2),
2649 group_ops_bls12381_g2_hash_to_cost_per_byte: Some(2),
2650 group_ops_bls12381_g1_msm_base_cost: Some(52),
2651 group_ops_bls12381_g2_msm_base_cost: Some(52),
2652 group_ops_bls12381_g1_msm_base_cost_per_input: Some(52),
2653 group_ops_bls12381_g2_msm_base_cost_per_input: Some(52),
2654 group_ops_bls12381_msm_max_len: Some(32),
2655 group_ops_bls12381_pairing_cost: Some(52),
2656 group_ops_bls12381_g1_to_uncompressed_g1_cost: None,
2657 group_ops_bls12381_uncompressed_g1_to_g1_cost: None,
2658 group_ops_bls12381_uncompressed_g1_sum_base_cost: None,
2659 group_ops_bls12381_uncompressed_g1_sum_cost_per_term: None,
2660 group_ops_bls12381_uncompressed_g1_sum_max_terms: None,
2661
2662 #[allow(deprecated)]
2664 check_zklogin_id_cost_base: Some(200),
2665 #[allow(deprecated)]
2666 check_zklogin_issuer_cost_base: Some(200),
2668
2669 vdf_verify_vdf_cost: None,
2670 vdf_hash_to_input_cost: None,
2671
2672 bcs_per_byte_serialized_cost: Some(2),
2673 bcs_legacy_min_output_size_cost: Some(1),
2674 bcs_failure_cost: Some(52),
2675 hash_sha2_256_base_cost: Some(52),
2676 hash_sha2_256_per_byte_cost: Some(2),
2677 hash_sha2_256_legacy_min_input_len_cost: Some(1),
2678 hash_sha3_256_base_cost: Some(52),
2679 hash_sha3_256_per_byte_cost: Some(2),
2680 hash_sha3_256_legacy_min_input_len_cost: Some(1),
2681 type_name_get_base_cost: Some(52),
2682 type_name_get_per_byte_cost: Some(2),
2683 string_check_utf8_base_cost: Some(52),
2684 string_check_utf8_per_byte_cost: Some(2),
2685 string_is_char_boundary_base_cost: Some(52),
2686 string_sub_string_base_cost: Some(52),
2687 string_sub_string_per_byte_cost: Some(2),
2688 string_index_of_base_cost: Some(52),
2689 string_index_of_per_byte_pattern_cost: Some(2),
2690 string_index_of_per_byte_searched_cost: Some(2),
2691 vector_empty_base_cost: Some(52),
2692 vector_length_base_cost: Some(52),
2693 vector_push_back_base_cost: Some(52),
2694 vector_push_back_legacy_per_abstract_memory_unit_cost: Some(2),
2695 vector_borrow_base_cost: Some(52),
2696 vector_pop_back_base_cost: Some(52),
2697 vector_destroy_empty_base_cost: Some(52),
2698 vector_swap_base_cost: Some(52),
2699 debug_print_base_cost: Some(52),
2700 debug_print_stack_trace_base_cost: Some(52),
2701
2702 max_size_written_objects: Some(5 * 1000 * 1000),
2703 max_size_written_objects_system_tx: Some(50 * 1000 * 1000),
2706
2707 max_move_identifier_len: Some(128),
2709 max_move_value_depth: Some(128),
2710 max_move_enum_variants: None,
2711
2712 gas_rounding_step: Some(1_000),
2713
2714 execution_version: Some(1),
2715
2716 max_event_emit_size_total: Some(
2719 256 * 250 * 1024, ),
2721
2722 consensus_bad_nodes_stake_threshold: Some(20),
2729
2730 #[allow(deprecated)]
2732 max_jwk_votes_per_validator_per_epoch: Some(240),
2733
2734 #[allow(deprecated)]
2735 max_age_of_jwk_in_epochs: Some(1),
2736
2737 consensus_max_transaction_size_bytes: Some(256 * 1024), consensus_max_transactions_in_block_bytes: Some(512 * 1024),
2741
2742 random_beacon_reduction_allowed_delta: Some(800),
2743
2744 random_beacon_reduction_lower_bound: Some(1000),
2745 random_beacon_dkg_timeout_round: Some(3000),
2746 random_beacon_min_round_interval_ms: Some(500),
2747
2748 random_beacon_dkg_version: Some(1),
2749
2750 consensus_max_num_transactions_in_block: Some(512),
2754
2755 max_deferral_rounds_for_congestion_control: Some(10),
2756
2757 min_checkpoint_interval_ms: Some(200),
2758
2759 checkpoint_rate_window_size: None,
2760
2761 checkpoint_summary_version_specific_data: Some(1),
2762
2763 max_soft_bundle_size: Some(5),
2764
2765 bridge_should_try_to_finalize_committee: None,
2766
2767 max_accumulated_txn_cost_per_object_in_mysticeti_commit: Some(10),
2768
2769 max_committee_members_count: None,
2770 deny_rule_update_max_entries_per_tx: None,
2771 deny_rule_removal_grace_round_floor: None,
2772
2773 consensus_gc_depth: None,
2774
2775 consensus_max_acknowledgments_per_block: None,
2776
2777 max_congestion_limit_overshoot_per_commit: None,
2778
2779 max_concurrent_execution_workers: None,
2780
2781 scorer_version: None,
2782
2783 auth_context_digest_cost_base: None,
2785 auth_context_tx_data_bytes_cost_base: None,
2786 auth_context_tx_data_bytes_cost_per_byte: None,
2787 auth_context_tx_commands_cost_base: None,
2788 auth_context_tx_commands_cost_per_byte: None,
2789 auth_context_tx_inputs_cost_base: None,
2790 auth_context_tx_inputs_cost_per_byte: None,
2791 auth_context_replace_cost_base: None,
2792 auth_context_replace_cost_per_byte: None,
2793 auth_context_authenticator_function_info_v1_cost_base: None,
2794 consensus_commits_per_schedule: None,
2795 min_validator_count: None,
2796 max_validator_count: None,
2797 min_validator_joining_stake: None,
2798 validator_low_stake_threshold: None,
2799 validator_very_low_stake_threshold: None,
2800 validator_low_stake_grace_period: None,
2801 consensus_leader_schedule_window_size: None,
2802 };
2805
2806 cfg.feature_flags.consensus_transaction_ordering = ConsensusTransactionOrdering::ByGasPrice;
2807
2808 {
2810 cfg.feature_flags
2811 .disable_invariant_violation_check_in_swap_loc = true;
2812 cfg.feature_flags.no_extraneous_module_bytes = true;
2813 cfg.feature_flags.hardened_otw_check = true;
2814 cfg.feature_flags.rethrow_serialization_type_layout_errors = true;
2815 }
2816
2817 {
2819 #[allow(deprecated)]
2820 {
2821 cfg.feature_flags.zklogin_max_epoch_upper_bound_delta = Some(30);
2822 }
2823 }
2824
2825 #[expect(deprecated)]
2829 {
2830 cfg.feature_flags.consensus_choice = ConsensusChoice::MysticetiDeprecated;
2831 }
2832 cfg.feature_flags.consensus_network = ConsensusNetwork::Tonic;
2834
2835 cfg.feature_flags.per_object_congestion_control_mode =
2836 PerObjectCongestionControlMode::TotalTxCount;
2837
2838 cfg.bridge_should_try_to_finalize_committee = Some(chain != Chain::Mainnet);
2840
2841 if chain != Chain::Mainnet && chain != Chain::Testnet {
2843 cfg.feature_flags.enable_poseidon = true;
2844 cfg.poseidon_bn254_cost_base = Some(260);
2845 cfg.poseidon_bn254_cost_per_block = Some(10);
2846
2847 cfg.feature_flags.enable_group_ops_native_function_msm = true;
2848
2849 cfg.feature_flags.enable_vdf = true;
2850 cfg.vdf_verify_vdf_cost = Some(1500);
2853 cfg.vdf_hash_to_input_cost = Some(100);
2854
2855 cfg.feature_flags.passkey_auth = true;
2856 }
2857
2858 for cur in 2..=version.0 {
2859 match cur {
2860 1 => unreachable!(),
2861 2 => {}
2863 3 => {
2864 cfg.feature_flags.relocate_event_module = true;
2865 }
2866 4 => {
2867 cfg.max_type_to_layout_nodes = Some(512);
2868 }
2869 5 => {
2870 cfg.feature_flags.protocol_defined_base_fee = true;
2871 cfg.base_gas_price = Some(1000);
2872
2873 cfg.feature_flags.disallow_new_modules_in_deps_only_packages = true;
2874 cfg.feature_flags.convert_type_argument_error = true;
2875 cfg.feature_flags.native_charging_v2 = true;
2876
2877 if chain != Chain::Mainnet && chain != Chain::Testnet {
2878 cfg.feature_flags.uncompressed_g1_group_elements = true;
2879 }
2880
2881 cfg.gas_model_version = Some(2);
2882
2883 cfg.poseidon_bn254_cost_per_block = Some(388);
2884
2885 cfg.bls12381_bls12381_min_sig_verify_cost_base = Some(44064);
2886 cfg.bls12381_bls12381_min_pk_verify_cost_base = Some(49282);
2887 cfg.ecdsa_k1_secp256k1_verify_keccak256_cost_base = Some(1470);
2888 cfg.ecdsa_k1_secp256k1_verify_sha256_cost_base = Some(1470);
2889 cfg.ecdsa_r1_secp256r1_verify_sha256_cost_base = Some(4225);
2890 cfg.ecdsa_r1_secp256r1_verify_keccak256_cost_base = Some(4225);
2891 cfg.ecvrf_ecvrf_verify_cost_base = Some(4848);
2892 cfg.ed25519_ed25519_verify_cost_base = Some(1802);
2893
2894 cfg.ecdsa_r1_ecrecover_keccak256_cost_base = Some(1173);
2896 cfg.ecdsa_r1_ecrecover_sha256_cost_base = Some(1173);
2897 cfg.ecdsa_k1_ecrecover_keccak256_cost_base = Some(500);
2898 cfg.ecdsa_k1_ecrecover_sha256_cost_base = Some(500);
2899
2900 cfg.groth16_prepare_verifying_key_bls12381_cost_base = Some(53838);
2901 cfg.groth16_prepare_verifying_key_bn254_cost_base = Some(82010);
2902 cfg.groth16_verify_groth16_proof_internal_bls12381_cost_base = Some(72090);
2903 cfg.groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input =
2904 Some(8213);
2905 cfg.groth16_verify_groth16_proof_internal_bn254_cost_base = Some(115502);
2906 cfg.groth16_verify_groth16_proof_internal_bn254_cost_per_public_input =
2907 Some(9484);
2908
2909 cfg.hash_keccak256_cost_base = Some(10);
2910 cfg.hash_blake2b256_cost_base = Some(10);
2911
2912 cfg.group_ops_bls12381_decode_scalar_cost = Some(7);
2914 cfg.group_ops_bls12381_decode_g1_cost = Some(2848);
2915 cfg.group_ops_bls12381_decode_g2_cost = Some(3770);
2916 cfg.group_ops_bls12381_decode_gt_cost = Some(3068);
2917
2918 cfg.group_ops_bls12381_scalar_add_cost = Some(10);
2919 cfg.group_ops_bls12381_g1_add_cost = Some(1556);
2920 cfg.group_ops_bls12381_g2_add_cost = Some(3048);
2921 cfg.group_ops_bls12381_gt_add_cost = Some(188);
2922
2923 cfg.group_ops_bls12381_scalar_sub_cost = Some(10);
2924 cfg.group_ops_bls12381_g1_sub_cost = Some(1550);
2925 cfg.group_ops_bls12381_g2_sub_cost = Some(3019);
2926 cfg.group_ops_bls12381_gt_sub_cost = Some(497);
2927
2928 cfg.group_ops_bls12381_scalar_mul_cost = Some(11);
2929 cfg.group_ops_bls12381_g1_mul_cost = Some(4842);
2930 cfg.group_ops_bls12381_g2_mul_cost = Some(9108);
2931 cfg.group_ops_bls12381_gt_mul_cost = Some(27490);
2932
2933 cfg.group_ops_bls12381_scalar_div_cost = Some(91);
2934 cfg.group_ops_bls12381_g1_div_cost = Some(5091);
2935 cfg.group_ops_bls12381_g2_div_cost = Some(9206);
2936 cfg.group_ops_bls12381_gt_div_cost = Some(27804);
2937
2938 cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(2962);
2939 cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(8688);
2940
2941 cfg.group_ops_bls12381_g1_msm_base_cost = Some(62648);
2942 cfg.group_ops_bls12381_g2_msm_base_cost = Some(131192);
2943 cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(1333);
2944 cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(3216);
2945
2946 cfg.group_ops_bls12381_uncompressed_g1_to_g1_cost = Some(677);
2947 cfg.group_ops_bls12381_g1_to_uncompressed_g1_cost = Some(2099);
2948 cfg.group_ops_bls12381_uncompressed_g1_sum_base_cost = Some(77);
2949 cfg.group_ops_bls12381_uncompressed_g1_sum_cost_per_term = Some(26);
2950 cfg.group_ops_bls12381_uncompressed_g1_sum_max_terms = Some(1200);
2951
2952 cfg.group_ops_bls12381_pairing_cost = Some(26897);
2953
2954 cfg.validator_validate_metadata_cost_base = Some(20000);
2955
2956 cfg.max_committee_members_count = Some(50);
2957 }
2958 6 => {
2959 cfg.max_ptb_value_size = Some(1024 * 1024);
2960 }
2961 7 => {
2962 }
2965 8 => {
2966 cfg.feature_flags.variant_nodes = true;
2967
2968 if chain != Chain::Mainnet {
2969 cfg.feature_flags.consensus_round_prober = true;
2971 cfg.feature_flags
2973 .consensus_distributed_vote_scoring_strategy = true;
2974 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
2975 cfg.feature_flags.consensus_smart_ancestor_selection = true;
2977 cfg.feature_flags
2979 .consensus_round_prober_probe_accepted_rounds = true;
2980 cfg.feature_flags.consensus_zstd_compression = true;
2982 cfg.consensus_gc_depth = Some(60);
2986 }
2987
2988 if chain != Chain::Testnet && chain != Chain::Mainnet {
2991 cfg.feature_flags.congestion_control_min_free_execution_slot = true;
2992 }
2993 }
2994 9 => {
2995 if chain != Chain::Mainnet {
2996 cfg.feature_flags.consensus_smart_ancestor_selection = false;
2998 }
2999
3000 cfg.feature_flags.consensus_zstd_compression = true;
3002
3003 if chain != Chain::Testnet && chain != Chain::Mainnet {
3005 cfg.feature_flags.accept_passkey_in_multisig = true;
3006 }
3007
3008 cfg.bridge_should_try_to_finalize_committee = None;
3010 }
3011 10 => {
3012 cfg.feature_flags.congestion_control_min_free_execution_slot = true;
3015
3016 cfg.max_committee_members_count = Some(80);
3018
3019 cfg.feature_flags.consensus_round_prober = true;
3021 cfg.feature_flags
3023 .consensus_round_prober_probe_accepted_rounds = true;
3024 cfg.feature_flags
3026 .consensus_distributed_vote_scoring_strategy = true;
3027 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
3029
3030 cfg.consensus_gc_depth = Some(60);
3035
3036 cfg.feature_flags.minimize_child_object_mutations = true;
3038
3039 if chain != Chain::Mainnet {
3040 cfg.feature_flags.consensus_batched_block_sync = true;
3042 }
3043
3044 if chain != Chain::Testnet && chain != Chain::Mainnet {
3045 cfg.feature_flags
3048 .congestion_control_gas_price_feedback_mechanism = true;
3049 }
3050
3051 cfg.feature_flags.validate_identifier_inputs = true;
3052 cfg.feature_flags.dependency_linkage_error = true;
3053 cfg.feature_flags.additional_multisig_checks = true;
3054 }
3055 11 => {
3056 }
3059 12 => {
3060 cfg.feature_flags
3063 .congestion_control_gas_price_feedback_mechanism = true;
3064
3065 cfg.feature_flags.normalize_ptb_arguments = true;
3067 }
3068 13 => {
3069 cfg.feature_flags.select_committee_from_eligible_validators = true;
3072 cfg.feature_flags.track_non_committee_eligible_validators = true;
3075
3076 if chain != Chain::Testnet && chain != Chain::Mainnet {
3077 cfg.feature_flags
3080 .select_committee_supporting_next_epoch_version = true;
3081 }
3082 }
3083 14 => {
3084 cfg.feature_flags.consensus_batched_block_sync = true;
3086
3087 if chain != Chain::Mainnet {
3088 cfg.feature_flags
3091 .consensus_median_timestamp_with_checkpoint_enforcement = true;
3092 cfg.feature_flags
3096 .select_committee_supporting_next_epoch_version = true;
3097 }
3098 if chain != Chain::Testnet && chain != Chain::Mainnet {
3099 cfg.feature_flags.consensus_choice = ConsensusChoice::Starfish;
3101 }
3102 }
3103 15 => {
3104 if chain != Chain::Mainnet && chain != Chain::Testnet {
3105 cfg.max_congestion_limit_overshoot_per_commit = Some(100);
3109 }
3110 }
3111 16 => {
3112 cfg.feature_flags
3115 .select_committee_supporting_next_epoch_version = true;
3116 cfg.feature_flags
3118 .consensus_commit_transactions_only_for_traversed_headers = true;
3119 }
3120 17 => {
3121 cfg.max_committee_members_count = Some(100);
3123 }
3124 18 => {
3125 if chain != Chain::Mainnet {
3126 cfg.feature_flags.passkey_auth = true;
3128 }
3129 }
3130 19 => {
3131 if chain != Chain::Testnet && chain != Chain::Mainnet {
3132 cfg.feature_flags
3135 .congestion_limit_overshoot_in_gas_price_feedback_mechanism = true;
3136 cfg.feature_flags
3139 .separate_gas_price_feedback_mechanism_for_randomness = true;
3140 cfg.feature_flags.metadata_in_module_bytes = true;
3143 cfg.feature_flags.publish_package_metadata = true;
3144 cfg.feature_flags.enable_move_authentication = true;
3146 cfg.max_auth_gas = Some(250_000_000);
3148 cfg.transfer_receive_object_cost_base = Some(100);
3151 cfg.feature_flags.adjust_rewards_by_score = true;
3153 }
3154
3155 if chain != Chain::Mainnet {
3156 cfg.feature_flags.consensus_choice = ConsensusChoice::Starfish;
3158
3159 cfg.feature_flags.calculate_validator_scores = true;
3161 cfg.scorer_version = Some(1);
3162 }
3163
3164 cfg.feature_flags.pass_validator_scores_to_advance_epoch = true;
3166
3167 cfg.feature_flags.passkey_auth = true;
3169 }
3170 20 => {
3171 if chain != Chain::Testnet && chain != Chain::Mainnet {
3172 cfg.feature_flags
3174 .pass_calculated_validator_scores_to_advance_epoch = true;
3175 }
3176 }
3177 21 => {
3178 if chain != Chain::Testnet && chain != Chain::Mainnet {
3179 cfg.feature_flags.consensus_fast_commit_sync = true;
3181 }
3182 if chain != Chain::Mainnet {
3183 cfg.max_congestion_limit_overshoot_per_commit = Some(100);
3188 cfg.feature_flags
3191 .congestion_limit_overshoot_in_gas_price_feedback_mechanism = true;
3192 cfg.feature_flags
3195 .separate_gas_price_feedback_mechanism_for_randomness = true;
3196 }
3197
3198 cfg.auth_context_digest_cost_base = Some(30);
3199 cfg.auth_context_tx_commands_cost_base = Some(30);
3200 cfg.auth_context_tx_commands_cost_per_byte = Some(2);
3201 cfg.auth_context_tx_inputs_cost_base = Some(30);
3202 cfg.auth_context_tx_inputs_cost_per_byte = Some(2);
3203 cfg.auth_context_replace_cost_base = Some(30);
3204 cfg.auth_context_replace_cost_per_byte = Some(2);
3205
3206 if chain != Chain::Testnet && chain != Chain::Mainnet {
3207 cfg.max_auth_gas = Some(250_000);
3209 }
3210 }
3211 22 => {
3212 cfg.max_congestion_limit_overshoot_per_commit = Some(100);
3217 cfg.feature_flags
3220 .congestion_limit_overshoot_in_gas_price_feedback_mechanism = true;
3221 cfg.feature_flags
3224 .separate_gas_price_feedback_mechanism_for_randomness = true;
3225
3226 if chain != Chain::Mainnet {
3227 cfg.feature_flags.metadata_in_module_bytes = true;
3230 cfg.feature_flags.publish_package_metadata = true;
3231 cfg.feature_flags.enable_move_authentication = true;
3233 cfg.max_auth_gas = Some(250_000);
3235 cfg.transfer_receive_object_cost_base = Some(100);
3238 }
3239
3240 if chain != Chain::Mainnet {
3241 cfg.feature_flags.consensus_fast_commit_sync = true;
3243 }
3244 }
3245 23 => {
3246 cfg.feature_flags.move_native_tx_context = true;
3248 cfg.tx_context_fresh_id_cost_base = Some(52);
3249 cfg.tx_context_sender_cost_base = Some(30);
3250 cfg.tx_context_digest_cost_base = Some(30);
3251 cfg.tx_context_epoch_cost_base = Some(30);
3252 cfg.tx_context_epoch_timestamp_ms_cost_base = Some(30);
3253 cfg.tx_context_sponsor_cost_base = Some(30);
3254 cfg.tx_context_rgp_cost_base = Some(30);
3255 cfg.tx_context_gas_price_cost_base = Some(30);
3256 cfg.tx_context_gas_budget_cost_base = Some(30);
3257 cfg.tx_context_ids_created_cost_base = Some(30);
3258 cfg.tx_context_replace_cost_base = Some(30);
3259 }
3260 24 => {
3261 cfg.feature_flags.consensus_choice = ConsensusChoice::Starfish;
3263
3264 if chain != Chain::Testnet && chain != Chain::Mainnet {
3265 cfg.feature_flags.enable_move_authentication_for_sponsor = true;
3267 }
3268
3269 cfg.auth_context_tx_data_bytes_cost_base = Some(30);
3272 cfg.auth_context_tx_data_bytes_cost_per_byte = Some(2);
3273
3274 cfg.feature_flags.additional_borrow_checks = true;
3276 }
3277 #[allow(deprecated)]
3278 25 => {
3279 cfg.feature_flags.zklogin_max_epoch_upper_bound_delta = None;
3282 cfg.check_zklogin_id_cost_base = None;
3283 cfg.check_zklogin_issuer_cost_base = None;
3284 cfg.max_jwk_votes_per_validator_per_epoch = None;
3285 cfg.max_age_of_jwk_in_epochs = None;
3286 }
3287 26 => {
3288 }
3291 27 => {
3292 if chain != Chain::Mainnet {
3293 cfg.feature_flags.consensus_block_restrictions = true;
3296 }
3297
3298 if chain != Chain::Testnet && chain != Chain::Mainnet {
3299 cfg.feature_flags
3301 .pre_consensus_sponsor_only_move_authentication = true;
3302 }
3303 }
3304 28 => {
3305 cfg.auth_context_authenticator_function_info_v1_cost_base = Some(270);
3310
3311 cfg.feature_flags.metadata_in_module_bytes = true;
3314 cfg.feature_flags.publish_package_metadata = true;
3315 cfg.feature_flags.enable_move_authentication = true;
3317 cfg.transfer_receive_object_cost_base = Some(100);
3320
3321 if chain != Chain::Unknown {
3322 cfg.max_auth_gas = Some(20_000);
3324 }
3325
3326 if chain != Chain::Mainnet {
3327 cfg.feature_flags.enable_move_authentication_for_sponsor = true;
3329 cfg.feature_flags
3331 .pre_consensus_sponsor_only_move_authentication = true;
3332 }
3333 }
3334 29 => {
3335 cfg.feature_flags.always_advance_dkg_to_resolution = true;
3341
3342 cfg.feature_flags
3345 .consensus_median_timestamp_with_checkpoint_enforcement = true;
3346
3347 cfg.feature_flags.consensus_fast_commit_sync = true;
3349 cfg.feature_flags.consensus_block_restrictions = true;
3353 }
3354 30 => {
3355 }
3363 31 => {
3364 cfg.feature_flags.validator_metadata_verify_v2 = true;
3365
3366 if chain != Chain::Mainnet && chain != Chain::Testnet {
3367 cfg.checkpoint_rate_window_size = Some(20);
3370 cfg.feature_flags
3373 .package_metadata_with_dynamic_module_metadata = true;
3374 cfg.feature_flags.consensus_starfish_speed = true;
3377 }
3378
3379 cfg.feature_flags.report_move_authentication_error = true;
3380 }
3381 32 => {
3382 cfg.min_validator_count = Some(4);
3386 cfg.max_validator_count = Some(150);
3387 cfg.min_validator_joining_stake = Some(2_000_000_000_000_000);
3388 cfg.validator_low_stake_threshold = Some(1_500_000_000_000_000);
3389 cfg.validator_very_low_stake_threshold = Some(1_000_000_000_000_000);
3390 cfg.validator_low_stake_grace_period = Some(7);
3391
3392 cfg.feature_flags.enable_move_authentication_for_sponsor = true;
3394 cfg.feature_flags
3396 .pre_consensus_sponsor_only_move_authentication = true;
3397
3398 if chain != Chain::Mainnet {
3399 cfg.feature_flags.consensus_starfish_speed = true;
3402 cfg.checkpoint_rate_window_size = Some(20);
3405 cfg.feature_flags
3408 .package_metadata_with_dynamic_module_metadata = true;
3409 }
3410
3411 if chain != Chain::Mainnet && chain != Chain::Testnet {
3412 cfg.feature_flags
3416 .consensus_enable_sliding_window_leader_schedule = true;
3417 cfg.feature_flags
3418 .consensus_enable_absolute_score_leader_schedule = true;
3419 cfg.feature_flags.enable_pcool_flow = true;
3423 }
3424 }
3425 33 => {
3426 cfg.checkpoint_rate_window_size = Some(20);
3429 if chain != Chain::Mainnet {
3433 cfg.feature_flags
3434 .consensus_enable_sliding_window_leader_schedule = true;
3435 cfg.feature_flags
3436 .consensus_enable_absolute_score_leader_schedule = true;
3437 }
3438 }
3439 34 => {
3440 if chain != Chain::Testnet && chain != Chain::Mainnet {
3441 cfg.scorer_version = Some(2);
3445 }
3446 cfg.feature_flags.pcool_skip_immutable_object_locks = true;
3450
3451 if chain == Chain::Mainnet {
3452 cfg.feature_flags.enable_move_authentication_for_sponsor = false;
3454 cfg.feature_flags
3457 .pre_consensus_sponsor_only_move_authentication = false;
3458 }
3459 }
3460 35 => {
3461 cfg.feature_flags.max_ptb_value_size_v2 = true;
3463 cfg.feature_flags.allow_unbounded_system_objects = true;
3465
3466 cfg.feature_flags.consensus_starfish_speed = true;
3469
3470 cfg.max_verifier_meter_ticks_per_function = Some(2_200_000);
3477 cfg.max_meter_ticks_per_module = Some(2_200_000);
3478 cfg.max_meter_ticks_per_package = Some(2_200_000);
3479 cfg.max_meter_ticks_regex_reference_safety = Some(2_200_000);
3480 cfg.feature_flags.pcool_verifier_limits_from_protocol_config = true;
3481 cfg.feature_flags
3484 .package_metadata_with_dynamic_module_metadata = true;
3485 cfg.feature_flags
3489 .consensus_enable_sliding_window_leader_schedule = true;
3490 cfg.feature_flags
3491 .consensus_enable_absolute_score_leader_schedule = true;
3492
3493 cfg.feature_flags.enable_move_authentication_for_sponsor = true;
3496 cfg.feature_flags
3499 .pre_consensus_sponsor_only_move_authentication = false;
3500 }
3501 36 => {
3502 cfg.feature_flags.validate_input_object_versions = true;
3506 cfg.feature_flags.disallow_self_identifier = true;
3507 cfg.max_move_enum_variants = Some(move_core_types::VARIANT_COUNT_MAX);
3508 }
3509 _ => panic!("unsupported version {version:?}"),
3520 }
3521 }
3522 cfg
3523 }
3524
3525 pub fn verifier_config(&self, signing_limits: Option<(usize, usize, usize)>) -> VerifierConfig {
3531 let (
3532 max_back_edges_per_function,
3533 max_back_edges_per_module,
3534 sanity_check_with_regex_reference_safety,
3535 ) = if let Some((
3536 max_back_edges_per_function,
3537 max_back_edges_per_module,
3538 sanity_check_with_regex_reference_safety,
3539 )) = signing_limits
3540 {
3541 (
3542 Some(max_back_edges_per_function),
3543 Some(max_back_edges_per_module),
3544 Some(sanity_check_with_regex_reference_safety),
3545 )
3546 } else {
3547 (None, None, None)
3548 };
3549
3550 let additional_borrow_checks = if signing_limits.is_some() {
3551 true
3554 } else {
3555 self.additional_borrow_checks()
3556 };
3557
3558 VerifierConfig {
3559 max_loop_depth: Some(self.max_loop_depth() as usize),
3560 max_generic_instantiation_length: Some(self.max_generic_instantiation_length() as usize),
3561 max_function_parameters: Some(self.max_function_parameters() as usize),
3562 max_basic_blocks: Some(self.max_basic_blocks() as usize),
3563 max_value_stack_size: self.max_value_stack_size() as usize,
3564 max_type_nodes: Some(self.max_type_nodes() as usize),
3565 max_push_size: Some(self.max_push_size() as usize),
3566 max_dependency_depth: Some(self.max_dependency_depth() as usize),
3567 max_fields_in_struct: Some(self.max_fields_in_struct() as usize),
3568 max_function_definitions: Some(self.max_function_definitions() as usize),
3569 max_data_definitions: Some(self.max_struct_definitions() as usize),
3570 max_constant_vector_len: Some(self.max_move_vector_len()),
3571 max_back_edges_per_function,
3572 max_back_edges_per_module,
3573 max_basic_blocks_in_script: None,
3574 max_identifier_len: self.max_move_identifier_len_as_option(), disallow_self_identifier: self.feature_flags.disallow_self_identifier,
3578 bytecode_version: self.move_binary_format_version(),
3579 max_variants_in_enum: self.max_move_enum_variants_as_option(),
3580 additional_borrow_checks,
3581 sanity_check_with_regex_reference_safety: sanity_check_with_regex_reference_safety
3582 .map(|limit| limit as u128),
3583 }
3584 }
3585
3586 pub fn verifier_signing_limits(&self) -> (usize, usize, usize) {
3593 (
3594 self.max_back_edges_per_function() as usize,
3595 self.max_back_edges_per_module() as usize,
3596 self.max_meter_ticks_regex_reference_safety() as usize,
3597 )
3598 }
3599
3600 pub fn meter_config(&self) -> MeterConfig {
3604 MeterConfig {
3605 max_per_fun_meter_units: Some(self.max_verifier_meter_ticks_per_function() as u128),
3606 max_per_mod_meter_units: Some(self.max_meter_ticks_per_module() as u128),
3607 max_per_pkg_meter_units: Some(self.max_meter_ticks_per_package() as u128),
3608 }
3609 }
3610
3611 pub fn apply_overrides_for_testing(
3616 override_fn: impl Fn(ProtocolVersion, Self) -> Self + Send + Sync + 'static,
3617 ) -> OverrideGuard {
3618 CONFIG_OVERRIDE.with(|ovr| {
3619 let mut cur = ovr.borrow_mut();
3620 assert!(cur.is_none(), "config override already present");
3621 *cur = Some(Box::new(override_fn));
3622 OverrideGuard
3623 })
3624 }
3625}
3626
3627impl ProtocolConfig {
3632 pub fn set_per_object_congestion_control_mode_for_testing(
3633 &mut self,
3634 val: PerObjectCongestionControlMode,
3635 ) {
3636 self.feature_flags.per_object_congestion_control_mode = val;
3637 }
3638
3639 pub fn set_consensus_choice_for_testing(&mut self, val: ConsensusChoice) {
3640 self.feature_flags.consensus_choice = val;
3641 }
3642
3643 pub fn set_consensus_network_for_testing(&mut self, val: ConsensusNetwork) {
3644 self.feature_flags.consensus_network = val;
3645 }
3646
3647 pub fn set_passkey_auth_for_testing(&mut self, val: bool) {
3648 self.feature_flags.passkey_auth = val
3649 }
3650
3651 pub fn set_disallow_new_modules_in_deps_only_packages_for_testing(&mut self, val: bool) {
3652 self.feature_flags
3653 .disallow_new_modules_in_deps_only_packages = val;
3654 }
3655
3656 pub fn set_consensus_round_prober_for_testing(&mut self, val: bool) {
3657 self.feature_flags.consensus_round_prober = val;
3658 }
3659
3660 pub fn set_consensus_distributed_vote_scoring_strategy_for_testing(&mut self, val: bool) {
3661 self.feature_flags
3662 .consensus_distributed_vote_scoring_strategy = val;
3663 }
3664
3665 pub fn set_gc_depth_for_testing(&mut self, val: u32) {
3666 self.consensus_gc_depth = Some(val);
3667 }
3668
3669 pub fn set_consensus_linearize_subdag_v2_for_testing(&mut self, val: bool) {
3670 self.feature_flags.consensus_linearize_subdag_v2 = val;
3671 }
3672
3673 pub fn set_consensus_round_prober_probe_accepted_rounds(&mut self, val: bool) {
3674 self.feature_flags
3675 .consensus_round_prober_probe_accepted_rounds = val;
3676 }
3677
3678 pub fn set_accept_passkey_in_multisig_for_testing(&mut self, val: bool) {
3679 self.feature_flags.accept_passkey_in_multisig = val;
3680 }
3681
3682 pub fn set_consensus_smart_ancestor_selection_for_testing(&mut self, val: bool) {
3683 self.feature_flags.consensus_smart_ancestor_selection = val;
3684 }
3685
3686 pub fn set_consensus_batched_block_sync_for_testing(&mut self, val: bool) {
3687 self.feature_flags.consensus_batched_block_sync = val;
3688 }
3689
3690 pub fn set_congestion_control_min_free_execution_slot_for_testing(&mut self, val: bool) {
3691 self.feature_flags
3692 .congestion_control_min_free_execution_slot = val;
3693 }
3694
3695 pub fn set_congestion_control_gas_price_feedback_mechanism_for_testing(&mut self, val: bool) {
3696 self.feature_flags
3697 .congestion_control_gas_price_feedback_mechanism = val;
3698 }
3699
3700 pub fn set_select_committee_from_eligible_validators_for_testing(&mut self, val: bool) {
3701 self.feature_flags.select_committee_from_eligible_validators = val;
3702 }
3703
3704 pub fn set_track_non_committee_eligible_validators_for_testing(&mut self, val: bool) {
3705 self.feature_flags.track_non_committee_eligible_validators = val;
3706 }
3707
3708 pub fn set_select_committee_supporting_next_epoch_version(&mut self, val: bool) {
3709 self.feature_flags
3710 .select_committee_supporting_next_epoch_version = val;
3711 }
3712
3713 pub fn set_consensus_median_timestamp_with_checkpoint_enforcement_for_testing(
3714 &mut self,
3715 val: bool,
3716 ) {
3717 self.feature_flags
3718 .consensus_median_timestamp_with_checkpoint_enforcement = val;
3719 }
3720
3721 pub fn set_consensus_commit_transactions_only_for_traversed_headers_for_testing(
3722 &mut self,
3723 val: bool,
3724 ) {
3725 self.feature_flags
3726 .consensus_commit_transactions_only_for_traversed_headers = val;
3727 }
3728
3729 pub fn set_congestion_limit_overshoot_in_gas_price_feedback_mechanism_for_testing(
3730 &mut self,
3731 val: bool,
3732 ) {
3733 self.feature_flags
3734 .congestion_limit_overshoot_in_gas_price_feedback_mechanism = val;
3735 }
3736
3737 pub fn set_separate_gas_price_feedback_mechanism_for_randomness_for_testing(
3738 &mut self,
3739 val: bool,
3740 ) {
3741 self.feature_flags
3742 .separate_gas_price_feedback_mechanism_for_randomness = val;
3743 }
3744
3745 pub fn set_metadata_in_module_bytes_for_testing(&mut self, val: bool) {
3746 self.feature_flags.metadata_in_module_bytes = val;
3747 }
3748
3749 pub fn set_publish_package_metadata_for_testing(&mut self, val: bool) {
3750 self.feature_flags.publish_package_metadata = val;
3751 }
3752
3753 pub fn set_enable_move_authentication_for_testing(&mut self, val: bool) {
3754 self.feature_flags.enable_move_authentication = val;
3755 }
3756
3757 pub fn set_enable_move_authentication_for_sponsor_for_testing(&mut self, val: bool) {
3758 self.feature_flags.enable_move_authentication_for_sponsor = val;
3759 }
3760
3761 pub fn set_consensus_fast_commit_sync_for_testing(&mut self, val: bool) {
3762 self.feature_flags.consensus_fast_commit_sync = val;
3763 }
3764
3765 pub fn set_consensus_block_restrictions_for_testing(&mut self, val: bool) {
3766 self.feature_flags.consensus_block_restrictions = val;
3767 }
3768
3769 pub fn set_pre_consensus_sponsor_only_move_authentication_for_testing(&mut self, val: bool) {
3770 self.feature_flags
3771 .pre_consensus_sponsor_only_move_authentication = val;
3772 }
3773
3774 pub fn set_consensus_starfish_speed_for_testing(&mut self, val: bool) {
3775 self.feature_flags.consensus_starfish_speed = val;
3776 }
3777
3778 pub fn set_always_advance_dkg_to_resolution_for_testing(&mut self, val: bool) {
3779 self.feature_flags.always_advance_dkg_to_resolution = val;
3780 }
3781
3782 pub fn set_enable_pcool_flow_for_testing(&mut self, val: bool) {
3783 self.feature_flags.enable_pcool_flow = val;
3784 }
3785
3786 pub fn set_pcool_skip_immutable_object_locks_for_testing(&mut self, val: bool) {
3787 self.feature_flags.pcool_skip_immutable_object_locks = val;
3788 }
3789
3790 pub fn set_pcool_verifier_limits_from_protocol_config_for_testing(&mut self, val: bool) {
3791 self.feature_flags
3792 .pcool_verifier_limits_from_protocol_config = val;
3793 }
3794
3795 pub fn set_validate_input_object_versions_for_testing(&mut self, val: bool) {
3796 self.feature_flags.validate_input_object_versions = val;
3797 }
3798
3799 pub fn set_commits_per_schedule_for_testing(&mut self, val: u32) {
3800 self.consensus_commits_per_schedule = Some(val);
3801 }
3802
3803 pub fn set_deny_rule_governance_for_testing(&mut self, val: bool) {
3804 self.feature_flags.deny_rule_governance = val;
3805 }
3806
3807 pub fn set_deny_rule_governance_on_chain_for_testing(&mut self, val: bool) {
3808 self.feature_flags.deny_rule_governance_on_chain = val;
3809 }
3810
3811 pub fn set_package_metadata_with_dynamic_module_metadata_for_testing(&mut self, val: bool) {
3812 self.feature_flags
3813 .package_metadata_with_dynamic_module_metadata = val;
3814 }
3815
3816 pub fn set_report_move_authentication_error_for_testing(&mut self, val: bool) {
3817 self.feature_flags.report_move_authentication_error = val;
3818 }
3819
3820 pub fn set_leader_schedule_window_size_for_testing(&mut self, val: u32) {
3821 self.consensus_leader_schedule_window_size = Some(val);
3822 }
3823
3824 pub fn set_consensus_enable_sliding_window_leader_schedule_for_testing(&mut self, val: bool) {
3825 self.feature_flags
3826 .consensus_enable_sliding_window_leader_schedule = val;
3827 }
3828
3829 pub fn set_consensus_enable_absolute_score_leader_schedule_for_testing(&mut self, val: bool) {
3830 self.feature_flags
3831 .consensus_enable_absolute_score_leader_schedule = val;
3832 }
3833}
3834
3835type OverrideFn = dyn Fn(ProtocolVersion, ProtocolConfig) -> ProtocolConfig + Send + Sync;
3836
3837thread_local! {
3838 static CONFIG_OVERRIDE: RefCell<Option<Box<OverrideFn>>> = const { RefCell::new(None) };
3839}
3840
3841#[must_use]
3842pub struct OverrideGuard;
3843
3844impl Drop for OverrideGuard {
3845 fn drop(&mut self) {
3846 info!("restoring override fn");
3847 CONFIG_OVERRIDE.with(|ovr| {
3848 *ovr.borrow_mut() = None;
3849 });
3850 }
3851}
3852
3853#[derive(PartialEq, Eq)]
3857pub enum LimitThresholdCrossed {
3858 None,
3859 Soft(u128, u128),
3860 Hard(u128, u128),
3861}
3862
3863pub fn check_limit_in_range<T: Into<V>, U: Into<V>, V: PartialOrd + Into<u128>>(
3866 x: T,
3867 soft_limit: U,
3868 hard_limit: V,
3869) -> LimitThresholdCrossed {
3870 let x: V = x.into();
3871 let soft_limit: V = soft_limit.into();
3872
3873 debug_assert!(soft_limit <= hard_limit);
3874
3875 if x >= hard_limit {
3878 LimitThresholdCrossed::Hard(x.into(), hard_limit.into())
3879 } else if x < soft_limit {
3880 LimitThresholdCrossed::None
3881 } else {
3882 LimitThresholdCrossed::Soft(x.into(), soft_limit.into())
3883 }
3884}
3885
3886#[macro_export]
3887macro_rules! check_limit {
3888 ($x:expr, $hard:expr) => {
3889 check_limit!($x, $hard, $hard)
3890 };
3891 ($x:expr, $soft:expr, $hard:expr) => {
3892 check_limit_in_range($x as u64, $soft, $hard)
3893 };
3894}
3895
3896#[macro_export]
3900macro_rules! check_limit_by_meter {
3901 ($is_metered:expr, $x:expr, $metered_limit:expr, $unmetered_hard_limit:expr, $metric:expr) => {{
3902 let (h, metered_str) = if $is_metered {
3904 ($metered_limit, "metered")
3905 } else {
3906 ($unmetered_hard_limit, "unmetered")
3908 };
3909 use iota_protocol_config::check_limit_in_range;
3910 let result = check_limit_in_range($x as u64, $metered_limit, h);
3911 match result {
3912 LimitThresholdCrossed::None => {}
3913 LimitThresholdCrossed::Soft(_, _) => {
3914 $metric.with_label_values(&[metered_str, "soft"]).inc();
3915 }
3916 LimitThresholdCrossed::Hard(_, _) => {
3917 $metric.with_label_values(&[metered_str, "hard"]).inc();
3918 }
3919 };
3920 result
3921 }};
3922}
3923
3924#[cfg(all(test, not(msim)))]
3925mod test {
3926 use insta::assert_yaml_snapshot;
3927
3928 use super::*;
3929
3930 #[test]
3931 fn snapshot_tests() {
3932 println!("\n============================================================================");
3933 println!("! !");
3934 println!("! IMPORTANT: never update snapshots from this test. only add new versions! !");
3935 println!("! !");
3936 println!("============================================================================\n");
3937 for chain_id in &[Chain::Unknown, Chain::Mainnet, Chain::Testnet] {
3938 let chain_str = match chain_id {
3943 Chain::Unknown => "".to_string(),
3944 _ => format!("{chain_id:?}_"),
3945 };
3946 for i in MIN_PROTOCOL_VERSION..=MAX_PROTOCOL_VERSION {
3947 let cur = ProtocolVersion::new(i);
3948 assert_yaml_snapshot!(
3949 format!("{}version_{}", chain_str, cur.as_u64()),
3950 ProtocolConfig::get_for_version(cur, *chain_id)
3951 );
3952 }
3953 }
3954 }
3955
3956 #[test]
3957 fn test_getters() {
3958 let prot: ProtocolConfig =
3959 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
3960 assert_eq!(
3961 prot.max_arguments(),
3962 prot.max_arguments_as_option().unwrap()
3963 );
3964 }
3965
3966 #[test]
3967 fn test_setters() {
3968 let mut prot: ProtocolConfig =
3969 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
3970 prot.set_max_arguments_for_testing(123);
3971 assert_eq!(prot.max_arguments(), 123);
3972
3973 prot.set_max_arguments_from_str_for_testing("321".to_string());
3974 assert_eq!(prot.max_arguments(), 321);
3975
3976 prot.disable_max_arguments_for_testing();
3977 assert_eq!(prot.max_arguments_as_option(), None);
3978
3979 prot.set_attr_for_testing("max_arguments".to_string(), "456".to_string());
3980 assert_eq!(prot.max_arguments(), 456);
3981 }
3982
3983 #[test]
3984 #[should_panic(expected = "unsupported version")]
3985 fn max_version_test() {
3986 let _ = ProtocolConfig::get_for_version_impl(
3989 ProtocolVersion::new(MAX_PROTOCOL_VERSION + 1),
3990 Chain::Unknown,
3991 );
3992 }
3993
3994 #[test]
3995 fn lookup_by_string_test() {
3996 let prot: ProtocolConfig =
3997 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Mainnet);
3998 assert!(prot.lookup_attr("some random string".to_string()).is_none());
4000
4001 assert!(
4002 prot.lookup_attr("max_arguments".to_string())
4003 == Some(ProtocolConfigValue::u32(prot.max_arguments())),
4004 );
4005
4006 assert!(
4008 prot.lookup_attr("poseidon_bn254_cost_base".to_string())
4009 .is_none()
4010 );
4011 assert!(
4012 prot.attr_map()
4013 .get("poseidon_bn254_cost_base")
4014 .unwrap()
4015 .is_none()
4016 );
4017
4018 let prot: ProtocolConfig =
4020 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
4021
4022 assert!(
4023 prot.lookup_attr("poseidon_bn254_cost_base".to_string())
4024 == Some(ProtocolConfigValue::u64(prot.poseidon_bn254_cost_base()))
4025 );
4026 assert!(
4027 prot.attr_map().get("poseidon_bn254_cost_base").unwrap()
4028 == &Some(ProtocolConfigValue::u64(prot.poseidon_bn254_cost_base()))
4029 );
4030
4031 let prot: ProtocolConfig =
4033 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Mainnet);
4034 assert!(
4036 prot.feature_flags
4037 .lookup_attr("some random string".to_owned())
4038 .is_none()
4039 );
4040 assert!(
4041 !prot
4042 .feature_flags
4043 .attr_map()
4044 .contains_key("some random string")
4045 );
4046
4047 assert!(prot.feature_flags.lookup_attr("enable_poseidon".to_owned()) == Some(false));
4049 assert!(
4050 prot.feature_flags
4051 .attr_map()
4052 .get("enable_poseidon")
4053 .unwrap()
4054 == &false
4055 );
4056 let prot: ProtocolConfig =
4057 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
4058 assert!(prot.feature_flags.lookup_attr("enable_poseidon".to_owned()) == Some(true));
4060 assert!(
4061 prot.feature_flags
4062 .attr_map()
4063 .get("enable_poseidon")
4064 .unwrap()
4065 == &true
4066 );
4067 }
4068
4069 #[test]
4073 #[should_panic(expected = "deny_rule_update_max_entries_per_tx must be positive")]
4074 fn deny_rule_chunk_limit_above_the_ceiling_is_rejected() {
4075 let _guard = ProtocolConfig::apply_overrides_for_testing(|_, mut config| {
4076 config.set_deny_rule_governance_for_testing(true);
4077 config.set_deny_rule_governance_on_chain_for_testing(true);
4078 config.set_deny_rule_removal_grace_round_floor_for_testing(0);
4079 config.set_deny_rule_update_max_entries_per_tx_for_testing(2048 + 1);
4080 config
4081 });
4082 let _ = ProtocolConfig::get_for_version(ProtocolVersion::max(), Chain::Unknown);
4083 }
4084
4085 #[test]
4088 #[should_panic(expected = "deny_rule_update_max_entries_per_tx must be positive")]
4089 fn deny_rule_chunk_limit_of_zero_is_rejected() {
4090 let _guard = ProtocolConfig::apply_overrides_for_testing(|_, mut config| {
4091 config.set_deny_rule_governance_for_testing(true);
4092 config.set_deny_rule_governance_on_chain_for_testing(true);
4093 config.set_deny_rule_removal_grace_round_floor_for_testing(0);
4094 config.set_deny_rule_update_max_entries_per_tx_for_testing(0);
4095 config
4096 });
4097 let _ = ProtocolConfig::get_for_version(ProtocolVersion::max(), Chain::Unknown);
4098 }
4099
4100 #[test]
4102 fn deny_rule_chunk_limit_within_system_tx_object_id_limit_is_accepted() {
4103 let _guard = ProtocolConfig::apply_overrides_for_testing(|_, mut config| {
4104 config.set_deny_rule_governance_for_testing(true);
4105 config.set_deny_rule_governance_on_chain_for_testing(true);
4106 config.set_deny_rule_removal_grace_round_floor_for_testing(0);
4107 config.set_deny_rule_update_max_entries_per_tx_for_testing(1000);
4108 config
4109 });
4110 let config = ProtocolConfig::get_for_version(ProtocolVersion::max(), Chain::Unknown);
4111 assert_eq!(config.deny_rule_update_max_entries_per_tx(), 1000);
4112 }
4113
4114 #[test]
4115 fn limit_range_fn_test() {
4116 let low = 100u32;
4117 let high = 10000u64;
4118
4119 assert!(check_limit!(1u8, low, high) == LimitThresholdCrossed::None);
4120 assert!(matches!(
4121 check_limit!(255u16, low, high),
4122 LimitThresholdCrossed::Soft(255u128, 100)
4123 ));
4124 assert!(matches!(
4131 check_limit!(2550000u64, low, high),
4132 LimitThresholdCrossed::Hard(2550000, 10000)
4133 ));
4134
4135 assert!(matches!(
4136 check_limit!(2550000u64, high, high),
4137 LimitThresholdCrossed::Hard(2550000, 10000)
4138 ));
4139
4140 assert!(matches!(
4141 check_limit!(1u8, high),
4142 LimitThresholdCrossed::None
4143 ));
4144
4145 assert!(check_limit!(255u16, high) == LimitThresholdCrossed::None);
4146
4147 assert!(matches!(
4148 check_limit!(2550000u64, high),
4149 LimitThresholdCrossed::Hard(2550000, 10000)
4150 ));
4151 }
4152}