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::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 = 23;
23
24#[derive(Copy, Clone, Debug, Hash, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)]
137pub struct ProtocolVersion(u64);
138
139impl ProtocolVersion {
140 pub const MIN: Self = Self(MIN_PROTOCOL_VERSION);
146
147 pub const MAX: Self = Self(MAX_PROTOCOL_VERSION);
148
149 #[cfg(not(msim))]
150 const MAX_ALLOWED: Self = Self::MAX;
151
152 #[cfg(msim)]
155 pub const MAX_ALLOWED: Self = Self(MAX_PROTOCOL_VERSION + 1);
156
157 pub fn new(v: u64) -> Self {
158 Self(v)
159 }
160
161 pub const fn as_u64(&self) -> u64 {
162 self.0
163 }
164
165 pub fn max() -> Self {
168 Self::MAX
169 }
170}
171
172impl From<u64> for ProtocolVersion {
173 fn from(v: u64) -> Self {
174 Self::new(v)
175 }
176}
177
178impl std::ops::Sub<u64> for ProtocolVersion {
179 type Output = Self;
180 fn sub(self, rhs: u64) -> Self::Output {
181 Self::new(self.0 - rhs)
182 }
183}
184
185impl std::ops::Add<u64> for ProtocolVersion {
186 type Output = Self;
187 fn add(self, rhs: u64) -> Self::Output {
188 Self::new(self.0 + rhs)
189 }
190}
191
192#[derive(
193 Clone, Serialize, Deserialize, Debug, PartialEq, Copy, PartialOrd, Ord, Eq, ValueEnum, Default,
194)]
195pub enum Chain {
196 Mainnet,
197 Testnet,
198 #[default]
199 Unknown,
200}
201
202impl Chain {
203 pub fn as_str(self) -> &'static str {
204 match self {
205 Chain::Mainnet => "mainnet",
206 Chain::Testnet => "testnet",
207 Chain::Unknown => "unknown",
208 }
209 }
210}
211
212pub struct Error(pub String);
213
214#[derive(Default, Clone, Serialize, Deserialize, Debug, ProtocolConfigFeatureFlagsGetters)]
218struct FeatureFlags {
219 #[serde(skip_serializing_if = "is_true")]
225 disable_invariant_violation_check_in_swap_loc: bool,
226
227 #[serde(skip_serializing_if = "is_true")]
230 no_extraneous_module_bytes: bool,
231
232 #[serde(skip_serializing_if = "is_false")]
234 zklogin_auth: bool,
235
236 #[serde(skip_serializing_if = "ConsensusTransactionOrdering::is_none")]
238 consensus_transaction_ordering: ConsensusTransactionOrdering,
239
240 #[serde(skip_serializing_if = "is_false")]
241 enable_jwk_consensus_updates: bool,
242
243 #[serde(skip_serializing_if = "is_false")]
245 accept_zklogin_in_multisig: bool,
246
247 #[serde(skip_serializing_if = "is_true")]
250 hardened_otw_check: bool,
251
252 #[serde(skip_serializing_if = "is_false")]
254 enable_poseidon: bool,
255
256 #[serde(skip_serializing_if = "is_false")]
258 enable_group_ops_native_function_msm: bool,
259
260 #[serde(skip_serializing_if = "PerObjectCongestionControlMode::is_none")]
262 per_object_congestion_control_mode: PerObjectCongestionControlMode,
263
264 #[serde(skip_serializing_if = "ConsensusChoice::is_mysticeti")]
266 consensus_choice: ConsensusChoice,
267
268 #[serde(skip_serializing_if = "ConsensusNetwork::is_tonic")]
270 consensus_network: ConsensusNetwork,
271
272 #[serde(skip_serializing_if = "Option::is_none")]
274 zklogin_max_epoch_upper_bound_delta: Option<u64>,
275
276 #[serde(skip_serializing_if = "is_false")]
278 enable_vdf: bool,
279
280 #[serde(skip_serializing_if = "is_false")]
282 passkey_auth: bool,
283
284 #[serde(skip_serializing_if = "is_true")]
287 rethrow_serialization_type_layout_errors: bool,
288
289 #[serde(skip_serializing_if = "is_false")]
291 relocate_event_module: bool,
292
293 #[serde(skip_serializing_if = "is_false")]
295 protocol_defined_base_fee: bool,
296
297 #[serde(skip_serializing_if = "is_false")]
299 uncompressed_g1_group_elements: bool,
300
301 #[serde(skip_serializing_if = "is_false")]
303 disallow_new_modules_in_deps_only_packages: bool,
304
305 #[serde(skip_serializing_if = "is_false")]
307 native_charging_v2: bool,
308
309 #[serde(skip_serializing_if = "is_false")]
311 convert_type_argument_error: bool,
312
313 #[serde(skip_serializing_if = "is_false")]
315 consensus_round_prober: bool,
316
317 #[serde(skip_serializing_if = "is_false")]
319 consensus_distributed_vote_scoring_strategy: bool,
320
321 #[serde(skip_serializing_if = "is_false")]
325 consensus_linearize_subdag_v2: bool,
326
327 #[serde(skip_serializing_if = "is_false")]
329 variant_nodes: bool,
330
331 #[serde(skip_serializing_if = "is_false")]
333 consensus_smart_ancestor_selection: bool,
334
335 #[serde(skip_serializing_if = "is_false")]
337 consensus_round_prober_probe_accepted_rounds: bool,
338
339 #[serde(skip_serializing_if = "is_false")]
341 consensus_zstd_compression: bool,
342
343 #[serde(skip_serializing_if = "is_false")]
346 congestion_control_min_free_execution_slot: bool,
347
348 #[serde(skip_serializing_if = "is_false")]
350 accept_passkey_in_multisig: bool,
351
352 #[serde(skip_serializing_if = "is_false")]
354 consensus_batched_block_sync: bool,
355
356 #[serde(skip_serializing_if = "is_false")]
359 congestion_control_gas_price_feedback_mechanism: bool,
360
361 #[serde(skip_serializing_if = "is_false")]
363 validate_identifier_inputs: bool,
364
365 #[serde(skip_serializing_if = "is_false")]
368 minimize_child_object_mutations: bool,
369
370 #[serde(skip_serializing_if = "is_false")]
372 dependency_linkage_error: bool,
373
374 #[serde(skip_serializing_if = "is_false")]
376 additional_multisig_checks: bool,
377
378 #[serde(skip_serializing_if = "is_false")]
381 normalize_ptb_arguments: bool,
382
383 #[serde(skip_serializing_if = "is_false")]
387 select_committee_from_eligible_validators: bool,
388
389 #[serde(skip_serializing_if = "is_false")]
396 track_non_committee_eligible_validators: bool,
397
398 #[serde(skip_serializing_if = "is_false")]
404 select_committee_supporting_next_epoch_version: bool,
405
406 #[serde(skip_serializing_if = "is_false")]
410 consensus_median_timestamp_with_checkpoint_enforcement: bool,
411
412 #[serde(skip_serializing_if = "is_false")]
414 consensus_commit_transactions_only_for_traversed_headers: bool,
415
416 #[serde(skip_serializing_if = "is_false")]
418 congestion_limit_overshoot_in_gas_price_feedback_mechanism: bool,
419
420 #[serde(skip_serializing_if = "is_false")]
423 separate_gas_price_feedback_mechanism_for_randomness: bool,
424
425 #[serde(skip_serializing_if = "is_false")]
428 metadata_in_module_bytes: bool,
429
430 #[serde(skip_serializing_if = "is_false")]
432 publish_package_metadata: bool,
433
434 #[serde(skip_serializing_if = "is_false")]
436 enable_move_authentication: bool,
437
438 #[serde(skip_serializing_if = "is_false")]
440 pass_validator_scores_to_advance_epoch: bool,
441
442 #[serde(skip_serializing_if = "is_false")]
444 calculate_validator_scores: bool,
445
446 #[serde(skip_serializing_if = "is_false")]
448 adjust_rewards_by_score: bool,
449
450 #[serde(skip_serializing_if = "is_false")]
453 pass_calculated_validator_scores_to_advance_epoch: bool,
454
455 #[serde(skip_serializing_if = "is_false")]
460 consensus_fast_commit_sync: bool,
461
462 #[serde(skip_serializing_if = "is_false")]
464 move_native_tx_context: bool,
465}
466
467fn is_true(b: &bool) -> bool {
468 *b
469}
470
471fn is_false(b: &bool) -> bool {
472 !b
473}
474
475#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
477pub enum ConsensusTransactionOrdering {
478 #[default]
481 None,
482 ByGasPrice,
484}
485
486impl ConsensusTransactionOrdering {
487 pub fn is_none(&self) -> bool {
488 matches!(self, ConsensusTransactionOrdering::None)
489 }
490}
491
492#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
494pub enum PerObjectCongestionControlMode {
495 #[default]
496 None, TotalGasBudget, TotalTxCount, }
500
501impl PerObjectCongestionControlMode {
502 pub fn is_none(&self) -> bool {
503 matches!(self, PerObjectCongestionControlMode::None)
504 }
505}
506
507#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
509pub enum ConsensusChoice {
510 #[default]
511 Mysticeti,
512 Starfish,
513}
514
515impl ConsensusChoice {
516 pub fn is_mysticeti(&self) -> bool {
517 matches!(self, ConsensusChoice::Mysticeti)
518 }
519 pub fn is_starfish(&self) -> bool {
520 matches!(self, ConsensusChoice::Starfish)
521 }
522}
523
524#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
526pub enum ConsensusNetwork {
527 #[default]
528 Tonic,
529}
530
531impl ConsensusNetwork {
532 pub fn is_tonic(&self) -> bool {
533 matches!(self, ConsensusNetwork::Tonic)
534 }
535}
536
537#[skip_serializing_none]
571#[derive(Clone, Serialize, Debug, ProtocolConfigAccessors, ProtocolConfigOverride)]
572pub struct ProtocolConfig {
573 pub version: ProtocolVersion,
574
575 feature_flags: FeatureFlags,
576
577 max_tx_size_bytes: Option<u64>,
582
583 max_input_objects: Option<u64>,
586
587 max_size_written_objects: Option<u64>,
592 max_size_written_objects_system_tx: Option<u64>,
596
597 max_serialized_tx_effects_size_bytes: Option<u64>,
599
600 max_serialized_tx_effects_size_bytes_system_tx: Option<u64>,
602
603 max_gas_payment_objects: Option<u32>,
605
606 max_modules_in_publish: Option<u32>,
608
609 max_package_dependencies: Option<u32>,
611
612 max_arguments: Option<u32>,
615
616 max_type_arguments: Option<u32>,
618
619 max_type_argument_depth: Option<u32>,
621
622 max_pure_argument_size: Option<u32>,
624
625 max_programmable_tx_commands: Option<u32>,
627
628 move_binary_format_version: Option<u32>,
634 min_move_binary_format_version: Option<u32>,
635
636 binary_module_handles: Option<u16>,
638 binary_struct_handles: Option<u16>,
639 binary_function_handles: Option<u16>,
640 binary_function_instantiations: Option<u16>,
641 binary_signatures: Option<u16>,
642 binary_constant_pool: Option<u16>,
643 binary_identifiers: Option<u16>,
644 binary_address_identifiers: Option<u16>,
645 binary_struct_defs: Option<u16>,
646 binary_struct_def_instantiations: Option<u16>,
647 binary_function_defs: Option<u16>,
648 binary_field_handles: Option<u16>,
649 binary_field_instantiations: Option<u16>,
650 binary_friend_decls: Option<u16>,
651 binary_enum_defs: Option<u16>,
652 binary_enum_def_instantiations: Option<u16>,
653 binary_variant_handles: Option<u16>,
654 binary_variant_instantiation_handles: Option<u16>,
655
656 max_move_object_size: Option<u64>,
659
660 max_move_package_size: Option<u64>,
665
666 max_publish_or_upgrade_per_ptb: Option<u64>,
669
670 max_tx_gas: Option<u64>,
672
673 max_auth_gas: Option<u64>,
675
676 max_gas_price: Option<u64>,
679
680 max_gas_computation_bucket: Option<u64>,
683
684 gas_rounding_step: Option<u64>,
686
687 max_loop_depth: Option<u64>,
689
690 max_generic_instantiation_length: Option<u64>,
693
694 max_function_parameters: Option<u64>,
697
698 max_basic_blocks: Option<u64>,
701
702 max_value_stack_size: Option<u64>,
704
705 max_type_nodes: Option<u64>,
709
710 max_push_size: Option<u64>,
713
714 max_struct_definitions: Option<u64>,
717
718 max_function_definitions: Option<u64>,
721
722 max_fields_in_struct: Option<u64>,
725
726 max_dependency_depth: Option<u64>,
729
730 max_num_event_emit: Option<u64>,
733
734 max_num_new_move_object_ids: Option<u64>,
737
738 max_num_new_move_object_ids_system_tx: Option<u64>,
741
742 max_num_deleted_move_object_ids: Option<u64>,
745
746 max_num_deleted_move_object_ids_system_tx: Option<u64>,
749
750 max_num_transferred_move_object_ids: Option<u64>,
753
754 max_num_transferred_move_object_ids_system_tx: Option<u64>,
757
758 max_event_emit_size: Option<u64>,
760
761 max_event_emit_size_total: Option<u64>,
763
764 max_move_vector_len: Option<u64>,
767
768 max_move_identifier_len: Option<u64>,
771
772 max_move_value_depth: Option<u64>,
774
775 max_move_enum_variants: Option<u64>,
778
779 max_back_edges_per_function: Option<u64>,
782
783 max_back_edges_per_module: Option<u64>,
786
787 max_verifier_meter_ticks_per_function: Option<u64>,
790
791 max_meter_ticks_per_module: Option<u64>,
794
795 max_meter_ticks_per_package: Option<u64>,
798
799 object_runtime_max_num_cached_objects: Option<u64>,
806
807 object_runtime_max_num_cached_objects_system_tx: Option<u64>,
810
811 object_runtime_max_num_store_entries: Option<u64>,
814
815 object_runtime_max_num_store_entries_system_tx: Option<u64>,
818
819 base_tx_cost_fixed: Option<u64>,
824
825 package_publish_cost_fixed: Option<u64>,
829
830 base_tx_cost_per_byte: Option<u64>,
834
835 package_publish_cost_per_byte: Option<u64>,
837
838 obj_access_cost_read_per_byte: Option<u64>,
840
841 obj_access_cost_mutate_per_byte: Option<u64>,
843
844 obj_access_cost_delete_per_byte: Option<u64>,
846
847 obj_access_cost_verify_per_byte: Option<u64>,
857
858 max_type_to_layout_nodes: Option<u64>,
860
861 max_ptb_value_size: Option<u64>,
863
864 gas_model_version: Option<u64>,
869
870 obj_data_cost_refundable: Option<u64>,
876
877 obj_metadata_cost_non_refundable: Option<u64>,
881
882 storage_rebate_rate: Option<u64>,
888
889 reward_slashing_rate: Option<u64>,
892
893 storage_gas_price: Option<u64>,
895
896 base_gas_price: Option<u64>,
898
899 validator_target_reward: Option<u64>,
901
902 max_transactions_per_checkpoint: Option<u64>,
909
910 max_checkpoint_size_bytes: Option<u64>,
914
915 buffer_stake_for_protocol_upgrade_bps: Option<u64>,
921
922 address_from_bytes_cost_base: Option<u64>,
927 address_to_u256_cost_base: Option<u64>,
929 address_from_u256_cost_base: Option<u64>,
931
932 config_read_setting_impl_cost_base: Option<u64>,
937 config_read_setting_impl_cost_per_byte: Option<u64>,
938
939 dynamic_field_hash_type_and_key_cost_base: Option<u64>,
943 dynamic_field_hash_type_and_key_type_cost_per_byte: Option<u64>,
944 dynamic_field_hash_type_and_key_value_cost_per_byte: Option<u64>,
945 dynamic_field_hash_type_and_key_type_tag_cost_per_byte: Option<u64>,
946 dynamic_field_add_child_object_cost_base: Option<u64>,
949 dynamic_field_add_child_object_type_cost_per_byte: Option<u64>,
950 dynamic_field_add_child_object_value_cost_per_byte: Option<u64>,
951 dynamic_field_add_child_object_struct_tag_cost_per_byte: Option<u64>,
952 dynamic_field_borrow_child_object_cost_base: Option<u64>,
955 dynamic_field_borrow_child_object_child_ref_cost_per_byte: Option<u64>,
956 dynamic_field_borrow_child_object_type_cost_per_byte: Option<u64>,
957 dynamic_field_remove_child_object_cost_base: Option<u64>,
960 dynamic_field_remove_child_object_child_cost_per_byte: Option<u64>,
961 dynamic_field_remove_child_object_type_cost_per_byte: Option<u64>,
962 dynamic_field_has_child_object_cost_base: Option<u64>,
965 dynamic_field_has_child_object_with_ty_cost_base: Option<u64>,
968 dynamic_field_has_child_object_with_ty_type_cost_per_byte: Option<u64>,
969 dynamic_field_has_child_object_with_ty_type_tag_cost_per_byte: Option<u64>,
970
971 event_emit_cost_base: Option<u64>,
974 event_emit_value_size_derivation_cost_per_byte: Option<u64>,
975 event_emit_tag_size_derivation_cost_per_byte: Option<u64>,
976 event_emit_output_cost_per_byte: Option<u64>,
977
978 object_borrow_uid_cost_base: Option<u64>,
981 object_delete_impl_cost_base: Option<u64>,
983 object_record_new_uid_cost_base: Option<u64>,
985
986 transfer_transfer_internal_cost_base: Option<u64>,
989 transfer_freeze_object_cost_base: Option<u64>,
991 transfer_share_object_cost_base: Option<u64>,
993 transfer_receive_object_cost_base: Option<u64>,
996
997 tx_context_derive_id_cost_base: Option<u64>,
1000 tx_context_fresh_id_cost_base: Option<u64>,
1001 tx_context_sender_cost_base: Option<u64>,
1002 tx_context_digest_cost_base: Option<u64>,
1003 tx_context_epoch_cost_base: Option<u64>,
1004 tx_context_epoch_timestamp_ms_cost_base: Option<u64>,
1005 tx_context_sponsor_cost_base: Option<u64>,
1006 tx_context_rgp_cost_base: Option<u64>,
1007 tx_context_gas_price_cost_base: Option<u64>,
1008 tx_context_gas_budget_cost_base: Option<u64>,
1009 tx_context_ids_created_cost_base: Option<u64>,
1010 tx_context_replace_cost_base: Option<u64>,
1011
1012 types_is_one_time_witness_cost_base: Option<u64>,
1015 types_is_one_time_witness_type_tag_cost_per_byte: Option<u64>,
1016 types_is_one_time_witness_type_cost_per_byte: Option<u64>,
1017
1018 validator_validate_metadata_cost_base: Option<u64>,
1021 validator_validate_metadata_data_cost_per_byte: Option<u64>,
1022
1023 crypto_invalid_arguments_cost: Option<u64>,
1025 bls12381_bls12381_min_sig_verify_cost_base: Option<u64>,
1027 bls12381_bls12381_min_sig_verify_msg_cost_per_byte: Option<u64>,
1028 bls12381_bls12381_min_sig_verify_msg_cost_per_block: Option<u64>,
1029
1030 bls12381_bls12381_min_pk_verify_cost_base: Option<u64>,
1032 bls12381_bls12381_min_pk_verify_msg_cost_per_byte: Option<u64>,
1033 bls12381_bls12381_min_pk_verify_msg_cost_per_block: Option<u64>,
1034
1035 ecdsa_k1_ecrecover_keccak256_cost_base: Option<u64>,
1037 ecdsa_k1_ecrecover_keccak256_msg_cost_per_byte: Option<u64>,
1038 ecdsa_k1_ecrecover_keccak256_msg_cost_per_block: Option<u64>,
1039 ecdsa_k1_ecrecover_sha256_cost_base: Option<u64>,
1040 ecdsa_k1_ecrecover_sha256_msg_cost_per_byte: Option<u64>,
1041 ecdsa_k1_ecrecover_sha256_msg_cost_per_block: Option<u64>,
1042
1043 ecdsa_k1_decompress_pubkey_cost_base: Option<u64>,
1045
1046 ecdsa_k1_secp256k1_verify_keccak256_cost_base: Option<u64>,
1048 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_byte: Option<u64>,
1049 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_block: Option<u64>,
1050 ecdsa_k1_secp256k1_verify_sha256_cost_base: Option<u64>,
1051 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_byte: Option<u64>,
1052 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_block: Option<u64>,
1053
1054 ecdsa_r1_ecrecover_keccak256_cost_base: Option<u64>,
1056 ecdsa_r1_ecrecover_keccak256_msg_cost_per_byte: Option<u64>,
1057 ecdsa_r1_ecrecover_keccak256_msg_cost_per_block: Option<u64>,
1058 ecdsa_r1_ecrecover_sha256_cost_base: Option<u64>,
1059 ecdsa_r1_ecrecover_sha256_msg_cost_per_byte: Option<u64>,
1060 ecdsa_r1_ecrecover_sha256_msg_cost_per_block: Option<u64>,
1061
1062 ecdsa_r1_secp256r1_verify_keccak256_cost_base: Option<u64>,
1064 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_byte: Option<u64>,
1065 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_block: Option<u64>,
1066 ecdsa_r1_secp256r1_verify_sha256_cost_base: Option<u64>,
1067 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_byte: Option<u64>,
1068 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_block: Option<u64>,
1069
1070 ecvrf_ecvrf_verify_cost_base: Option<u64>,
1072 ecvrf_ecvrf_verify_alpha_string_cost_per_byte: Option<u64>,
1073 ecvrf_ecvrf_verify_alpha_string_cost_per_block: Option<u64>,
1074
1075 ed25519_ed25519_verify_cost_base: Option<u64>,
1077 ed25519_ed25519_verify_msg_cost_per_byte: Option<u64>,
1078 ed25519_ed25519_verify_msg_cost_per_block: Option<u64>,
1079
1080 groth16_prepare_verifying_key_bls12381_cost_base: Option<u64>,
1082 groth16_prepare_verifying_key_bn254_cost_base: Option<u64>,
1083
1084 groth16_verify_groth16_proof_internal_bls12381_cost_base: Option<u64>,
1086 groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input: Option<u64>,
1087 groth16_verify_groth16_proof_internal_bn254_cost_base: Option<u64>,
1088 groth16_verify_groth16_proof_internal_bn254_cost_per_public_input: Option<u64>,
1089 groth16_verify_groth16_proof_internal_public_input_cost_per_byte: Option<u64>,
1090
1091 hash_blake2b256_cost_base: Option<u64>,
1093 hash_blake2b256_data_cost_per_byte: Option<u64>,
1094 hash_blake2b256_data_cost_per_block: Option<u64>,
1095
1096 hash_keccak256_cost_base: Option<u64>,
1098 hash_keccak256_data_cost_per_byte: Option<u64>,
1099 hash_keccak256_data_cost_per_block: Option<u64>,
1100
1101 poseidon_bn254_cost_base: Option<u64>,
1103 poseidon_bn254_cost_per_block: Option<u64>,
1104
1105 group_ops_bls12381_decode_scalar_cost: Option<u64>,
1107 group_ops_bls12381_decode_g1_cost: Option<u64>,
1108 group_ops_bls12381_decode_g2_cost: Option<u64>,
1109 group_ops_bls12381_decode_gt_cost: Option<u64>,
1110 group_ops_bls12381_scalar_add_cost: Option<u64>,
1111 group_ops_bls12381_g1_add_cost: Option<u64>,
1112 group_ops_bls12381_g2_add_cost: Option<u64>,
1113 group_ops_bls12381_gt_add_cost: Option<u64>,
1114 group_ops_bls12381_scalar_sub_cost: Option<u64>,
1115 group_ops_bls12381_g1_sub_cost: Option<u64>,
1116 group_ops_bls12381_g2_sub_cost: Option<u64>,
1117 group_ops_bls12381_gt_sub_cost: Option<u64>,
1118 group_ops_bls12381_scalar_mul_cost: Option<u64>,
1119 group_ops_bls12381_g1_mul_cost: Option<u64>,
1120 group_ops_bls12381_g2_mul_cost: Option<u64>,
1121 group_ops_bls12381_gt_mul_cost: Option<u64>,
1122 group_ops_bls12381_scalar_div_cost: Option<u64>,
1123 group_ops_bls12381_g1_div_cost: Option<u64>,
1124 group_ops_bls12381_g2_div_cost: Option<u64>,
1125 group_ops_bls12381_gt_div_cost: Option<u64>,
1126 group_ops_bls12381_g1_hash_to_base_cost: Option<u64>,
1127 group_ops_bls12381_g2_hash_to_base_cost: Option<u64>,
1128 group_ops_bls12381_g1_hash_to_cost_per_byte: Option<u64>,
1129 group_ops_bls12381_g2_hash_to_cost_per_byte: Option<u64>,
1130 group_ops_bls12381_g1_msm_base_cost: Option<u64>,
1131 group_ops_bls12381_g2_msm_base_cost: Option<u64>,
1132 group_ops_bls12381_g1_msm_base_cost_per_input: Option<u64>,
1133 group_ops_bls12381_g2_msm_base_cost_per_input: Option<u64>,
1134 group_ops_bls12381_msm_max_len: Option<u32>,
1135 group_ops_bls12381_pairing_cost: Option<u64>,
1136 group_ops_bls12381_g1_to_uncompressed_g1_cost: Option<u64>,
1137 group_ops_bls12381_uncompressed_g1_to_g1_cost: Option<u64>,
1138 group_ops_bls12381_uncompressed_g1_sum_base_cost: Option<u64>,
1139 group_ops_bls12381_uncompressed_g1_sum_cost_per_term: Option<u64>,
1140 group_ops_bls12381_uncompressed_g1_sum_max_terms: Option<u64>,
1141
1142 hmac_hmac_sha3_256_cost_base: Option<u64>,
1144 hmac_hmac_sha3_256_input_cost_per_byte: Option<u64>,
1145 hmac_hmac_sha3_256_input_cost_per_block: Option<u64>,
1146
1147 check_zklogin_id_cost_base: Option<u64>,
1149 check_zklogin_issuer_cost_base: Option<u64>,
1151
1152 vdf_verify_vdf_cost: Option<u64>,
1153 vdf_hash_to_input_cost: Option<u64>,
1154
1155 bcs_per_byte_serialized_cost: Option<u64>,
1157 bcs_legacy_min_output_size_cost: Option<u64>,
1158 bcs_failure_cost: Option<u64>,
1159
1160 hash_sha2_256_base_cost: Option<u64>,
1161 hash_sha2_256_per_byte_cost: Option<u64>,
1162 hash_sha2_256_legacy_min_input_len_cost: Option<u64>,
1163 hash_sha3_256_base_cost: Option<u64>,
1164 hash_sha3_256_per_byte_cost: Option<u64>,
1165 hash_sha3_256_legacy_min_input_len_cost: Option<u64>,
1166 type_name_get_base_cost: Option<u64>,
1167 type_name_get_per_byte_cost: Option<u64>,
1168
1169 string_check_utf8_base_cost: Option<u64>,
1170 string_check_utf8_per_byte_cost: Option<u64>,
1171 string_is_char_boundary_base_cost: Option<u64>,
1172 string_sub_string_base_cost: Option<u64>,
1173 string_sub_string_per_byte_cost: Option<u64>,
1174 string_index_of_base_cost: Option<u64>,
1175 string_index_of_per_byte_pattern_cost: Option<u64>,
1176 string_index_of_per_byte_searched_cost: Option<u64>,
1177
1178 vector_empty_base_cost: Option<u64>,
1179 vector_length_base_cost: Option<u64>,
1180 vector_push_back_base_cost: Option<u64>,
1181 vector_push_back_legacy_per_abstract_memory_unit_cost: Option<u64>,
1182 vector_borrow_base_cost: Option<u64>,
1183 vector_pop_back_base_cost: Option<u64>,
1184 vector_destroy_empty_base_cost: Option<u64>,
1185 vector_swap_base_cost: Option<u64>,
1186 debug_print_base_cost: Option<u64>,
1187 debug_print_stack_trace_base_cost: Option<u64>,
1188
1189 execution_version: Option<u64>,
1191
1192 consensus_bad_nodes_stake_threshold: Option<u64>,
1196
1197 max_jwk_votes_per_validator_per_epoch: Option<u64>,
1198 max_age_of_jwk_in_epochs: Option<u64>,
1202
1203 random_beacon_reduction_allowed_delta: Option<u16>,
1207
1208 random_beacon_reduction_lower_bound: Option<u32>,
1211
1212 random_beacon_dkg_timeout_round: Option<u32>,
1215
1216 random_beacon_min_round_interval_ms: Option<u64>,
1218
1219 random_beacon_dkg_version: Option<u64>,
1223
1224 consensus_max_transaction_size_bytes: Option<u64>,
1229 consensus_max_transactions_in_block_bytes: Option<u64>,
1231 consensus_max_num_transactions_in_block: Option<u64>,
1233
1234 max_deferral_rounds_for_congestion_control: Option<u64>,
1238
1239 min_checkpoint_interval_ms: Option<u64>,
1241
1242 checkpoint_summary_version_specific_data: Option<u64>,
1244
1245 max_soft_bundle_size: Option<u64>,
1248
1249 bridge_should_try_to_finalize_committee: Option<bool>,
1254
1255 max_accumulated_txn_cost_per_object_in_mysticeti_commit: Option<u64>,
1261
1262 max_committee_members_count: Option<u64>,
1266
1267 consensus_gc_depth: Option<u32>,
1270
1271 consensus_max_acknowledgments_per_block: Option<u32>,
1277
1278 max_congestion_limit_overshoot_per_commit: Option<u64>,
1283
1284 scorer_version: Option<u16>,
1291
1292 auth_context_digest_cost_base: Option<u64>,
1295 auth_context_tx_commands_cost_base: Option<u64>,
1297 auth_context_tx_commands_cost_per_byte: Option<u64>,
1298 auth_context_tx_inputs_cost_base: Option<u64>,
1300 auth_context_tx_inputs_cost_per_byte: Option<u64>,
1301 auth_context_replace_cost_base: Option<u64>,
1304 auth_context_replace_cost_per_byte: Option<u64>,
1305}
1306
1307impl ProtocolConfig {
1309 pub fn disable_invariant_violation_check_in_swap_loc(&self) -> bool {
1322 self.feature_flags
1323 .disable_invariant_violation_check_in_swap_loc
1324 }
1325
1326 pub fn no_extraneous_module_bytes(&self) -> bool {
1327 self.feature_flags.no_extraneous_module_bytes
1328 }
1329
1330 pub fn zklogin_auth(&self) -> bool {
1331 self.feature_flags.zklogin_auth
1332 }
1333
1334 pub fn consensus_transaction_ordering(&self) -> ConsensusTransactionOrdering {
1335 self.feature_flags.consensus_transaction_ordering
1336 }
1337
1338 pub fn enable_jwk_consensus_updates(&self) -> bool {
1339 self.feature_flags.enable_jwk_consensus_updates
1340 }
1341
1342 pub fn create_authenticator_state_in_genesis(&self) -> bool {
1344 self.enable_jwk_consensus_updates()
1345 }
1346
1347 pub fn dkg_version(&self) -> u64 {
1348 self.random_beacon_dkg_version.unwrap_or(1)
1350 }
1351
1352 pub fn accept_zklogin_in_multisig(&self) -> bool {
1353 self.feature_flags.accept_zklogin_in_multisig
1354 }
1355
1356 pub fn zklogin_max_epoch_upper_bound_delta(&self) -> Option<u64> {
1357 self.feature_flags.zklogin_max_epoch_upper_bound_delta
1358 }
1359
1360 pub fn hardened_otw_check(&self) -> bool {
1361 self.feature_flags.hardened_otw_check
1362 }
1363
1364 pub fn enable_poseidon(&self) -> bool {
1365 self.feature_flags.enable_poseidon
1366 }
1367
1368 pub fn enable_group_ops_native_function_msm(&self) -> bool {
1369 self.feature_flags.enable_group_ops_native_function_msm
1370 }
1371
1372 pub fn per_object_congestion_control_mode(&self) -> PerObjectCongestionControlMode {
1373 self.feature_flags.per_object_congestion_control_mode
1374 }
1375
1376 pub fn consensus_choice(&self) -> ConsensusChoice {
1377 self.feature_flags.consensus_choice
1378 }
1379
1380 pub fn consensus_network(&self) -> ConsensusNetwork {
1381 self.feature_flags.consensus_network
1382 }
1383
1384 pub fn enable_vdf(&self) -> bool {
1385 self.feature_flags.enable_vdf
1386 }
1387
1388 pub fn passkey_auth(&self) -> bool {
1389 self.feature_flags.passkey_auth
1390 }
1391
1392 pub fn max_transaction_size_bytes(&self) -> u64 {
1393 self.consensus_max_transaction_size_bytes
1395 .unwrap_or(256 * 1024)
1396 }
1397
1398 pub fn max_transactions_in_block_bytes(&self) -> u64 {
1399 if cfg!(msim) {
1400 256 * 1024
1401 } else {
1402 self.consensus_max_transactions_in_block_bytes
1403 .unwrap_or(512 * 1024)
1404 }
1405 }
1406
1407 pub fn max_num_transactions_in_block(&self) -> u64 {
1408 if cfg!(msim) {
1409 8
1410 } else {
1411 self.consensus_max_num_transactions_in_block.unwrap_or(512)
1412 }
1413 }
1414
1415 pub fn rethrow_serialization_type_layout_errors(&self) -> bool {
1416 self.feature_flags.rethrow_serialization_type_layout_errors
1417 }
1418
1419 pub fn relocate_event_module(&self) -> bool {
1420 self.feature_flags.relocate_event_module
1421 }
1422
1423 pub fn protocol_defined_base_fee(&self) -> bool {
1424 self.feature_flags.protocol_defined_base_fee
1425 }
1426
1427 pub fn uncompressed_g1_group_elements(&self) -> bool {
1428 self.feature_flags.uncompressed_g1_group_elements
1429 }
1430
1431 pub fn disallow_new_modules_in_deps_only_packages(&self) -> bool {
1432 self.feature_flags
1433 .disallow_new_modules_in_deps_only_packages
1434 }
1435
1436 pub fn native_charging_v2(&self) -> bool {
1437 self.feature_flags.native_charging_v2
1438 }
1439
1440 pub fn consensus_round_prober(&self) -> bool {
1441 self.feature_flags.consensus_round_prober
1442 }
1443
1444 pub fn consensus_distributed_vote_scoring_strategy(&self) -> bool {
1445 self.feature_flags
1446 .consensus_distributed_vote_scoring_strategy
1447 }
1448
1449 pub fn gc_depth(&self) -> u32 {
1450 if cfg!(msim) {
1451 min(5, self.consensus_gc_depth.unwrap_or(0))
1453 } else {
1454 self.consensus_gc_depth.unwrap_or(0)
1455 }
1456 }
1457
1458 pub fn consensus_linearize_subdag_v2(&self) -> bool {
1459 let res = self.feature_flags.consensus_linearize_subdag_v2;
1460 assert!(
1461 !res || self.gc_depth() > 0,
1462 "The consensus linearize sub dag V2 requires GC to be enabled"
1463 );
1464 res
1465 }
1466
1467 pub fn consensus_max_acknowledgments_per_block_or_default(&self) -> u32 {
1468 self.consensus_max_acknowledgments_per_block.unwrap_or(400)
1469 }
1470
1471 pub fn variant_nodes(&self) -> bool {
1472 self.feature_flags.variant_nodes
1473 }
1474
1475 pub fn consensus_smart_ancestor_selection(&self) -> bool {
1476 self.feature_flags.consensus_smart_ancestor_selection
1477 }
1478
1479 pub fn consensus_round_prober_probe_accepted_rounds(&self) -> bool {
1480 self.feature_flags
1481 .consensus_round_prober_probe_accepted_rounds
1482 }
1483
1484 pub fn consensus_zstd_compression(&self) -> bool {
1485 self.feature_flags.consensus_zstd_compression
1486 }
1487
1488 pub fn congestion_control_min_free_execution_slot(&self) -> bool {
1489 self.feature_flags
1490 .congestion_control_min_free_execution_slot
1491 }
1492
1493 pub fn accept_passkey_in_multisig(&self) -> bool {
1494 self.feature_flags.accept_passkey_in_multisig
1495 }
1496
1497 pub fn consensus_batched_block_sync(&self) -> bool {
1498 self.feature_flags.consensus_batched_block_sync
1499 }
1500
1501 pub fn congestion_control_gas_price_feedback_mechanism(&self) -> bool {
1504 self.feature_flags
1505 .congestion_control_gas_price_feedback_mechanism
1506 }
1507
1508 pub fn validate_identifier_inputs(&self) -> bool {
1509 self.feature_flags.validate_identifier_inputs
1510 }
1511
1512 pub fn minimize_child_object_mutations(&self) -> bool {
1513 self.feature_flags.minimize_child_object_mutations
1514 }
1515
1516 pub fn dependency_linkage_error(&self) -> bool {
1517 self.feature_flags.dependency_linkage_error
1518 }
1519
1520 pub fn additional_multisig_checks(&self) -> bool {
1521 self.feature_flags.additional_multisig_checks
1522 }
1523
1524 pub fn consensus_num_requested_prior_commits_at_startup(&self) -> u32 {
1525 0
1528 }
1529
1530 pub fn normalize_ptb_arguments(&self) -> bool {
1531 self.feature_flags.normalize_ptb_arguments
1532 }
1533
1534 pub fn select_committee_from_eligible_validators(&self) -> bool {
1535 let res = self.feature_flags.select_committee_from_eligible_validators;
1536 assert!(
1537 !res || (self.protocol_defined_base_fee()
1538 && self.max_committee_members_count_as_option().is_some()),
1539 "select_committee_from_eligible_validators requires protocol_defined_base_fee and max_committee_members_count to be set"
1540 );
1541 res
1542 }
1543
1544 pub fn track_non_committee_eligible_validators(&self) -> bool {
1545 self.feature_flags.track_non_committee_eligible_validators
1546 }
1547
1548 pub fn select_committee_supporting_next_epoch_version(&self) -> bool {
1549 let res = self
1550 .feature_flags
1551 .select_committee_supporting_next_epoch_version;
1552 assert!(
1553 !res || (self.track_non_committee_eligible_validators()
1554 && self.select_committee_from_eligible_validators()),
1555 "select_committee_supporting_next_epoch_version requires select_committee_from_eligible_validators to be set"
1556 );
1557 res
1558 }
1559
1560 pub fn consensus_median_timestamp_with_checkpoint_enforcement(&self) -> bool {
1561 let res = self
1562 .feature_flags
1563 .consensus_median_timestamp_with_checkpoint_enforcement;
1564 assert!(
1565 !res || self.gc_depth() > 0,
1566 "The consensus median timestamp with checkpoint enforcement requires GC to be enabled"
1567 );
1568 res
1569 }
1570
1571 pub fn consensus_commit_transactions_only_for_traversed_headers(&self) -> bool {
1572 self.feature_flags
1573 .consensus_commit_transactions_only_for_traversed_headers
1574 }
1575
1576 pub fn congestion_limit_overshoot_in_gas_price_feedback_mechanism(&self) -> bool {
1579 self.feature_flags
1580 .congestion_limit_overshoot_in_gas_price_feedback_mechanism
1581 }
1582
1583 pub fn separate_gas_price_feedback_mechanism_for_randomness(&self) -> bool {
1586 self.feature_flags
1587 .separate_gas_price_feedback_mechanism_for_randomness
1588 }
1589
1590 pub fn metadata_in_module_bytes(&self) -> bool {
1591 self.feature_flags.metadata_in_module_bytes
1592 }
1593
1594 pub fn publish_package_metadata(&self) -> bool {
1595 self.feature_flags.publish_package_metadata
1596 }
1597
1598 pub fn enable_move_authentication(&self) -> bool {
1599 self.feature_flags.enable_move_authentication
1600 }
1601
1602 pub fn pass_validator_scores_to_advance_epoch(&self) -> bool {
1603 self.feature_flags.pass_validator_scores_to_advance_epoch
1604 }
1605
1606 pub fn calculate_validator_scores(&self) -> bool {
1607 let calculate_validator_scores = self.feature_flags.calculate_validator_scores;
1608 assert!(
1609 !calculate_validator_scores || self.scorer_version.is_some(),
1610 "calculate_validator_scores requires scorer_version to be set"
1611 );
1612 calculate_validator_scores
1613 }
1614
1615 pub fn adjust_rewards_by_score(&self) -> bool {
1616 let adjust = self.feature_flags.adjust_rewards_by_score;
1617 assert!(
1618 !adjust || (self.scorer_version.is_some() && self.calculate_validator_scores()),
1619 "adjust_rewards_by_score requires scorer_version to be set"
1620 );
1621 adjust
1622 }
1623
1624 pub fn pass_calculated_validator_scores_to_advance_epoch(&self) -> bool {
1625 let pass = self
1626 .feature_flags
1627 .pass_calculated_validator_scores_to_advance_epoch;
1628 assert!(
1629 !pass
1630 || (self.pass_validator_scores_to_advance_epoch()
1631 && self.calculate_validator_scores()),
1632 "pass_calculated_validator_scores_to_advance_epoch requires pass_validator_scores_to_advance_epoch and calculate_validator_scores to be enabled"
1633 );
1634 pass
1635 }
1636 pub fn consensus_fast_commit_sync(&self) -> bool {
1637 let res = self.feature_flags.consensus_fast_commit_sync;
1638 assert!(
1639 !res || self.consensus_commit_transactions_only_for_traversed_headers(),
1640 "consensus_fast_commit_sync requires consensus_commit_transactions_only_for_traversed_headers to be enabled"
1641 );
1642 res
1643 }
1644
1645 pub fn move_native_tx_context(&self) -> bool {
1646 self.feature_flags.move_native_tx_context
1647 }
1648}
1649
1650#[cfg(not(msim))]
1651static POISON_VERSION_METHODS: AtomicBool = const { AtomicBool::new(false) };
1652
1653#[cfg(msim)]
1655thread_local! {
1656 static POISON_VERSION_METHODS: AtomicBool = const { AtomicBool::new(false) };
1657}
1658
1659impl ProtocolConfig {
1661 pub fn get_for_version(version: ProtocolVersion, chain: Chain) -> Self {
1664 assert!(
1666 version >= ProtocolVersion::MIN,
1667 "Network protocol version is {:?}, but the minimum supported version by the binary is {:?}. Please upgrade the binary.",
1668 version,
1669 ProtocolVersion::MIN.0,
1670 );
1671 assert!(
1672 version <= ProtocolVersion::MAX_ALLOWED,
1673 "Network protocol version is {:?}, but the maximum supported version by the binary is {:?}. Please upgrade the binary.",
1674 version,
1675 ProtocolVersion::MAX_ALLOWED.0,
1676 );
1677
1678 let mut ret = Self::get_for_version_impl(version, chain);
1679 ret.version = version;
1680
1681 ret = CONFIG_OVERRIDE.with(|ovr| {
1682 if let Some(override_fn) = &*ovr.borrow() {
1683 warn!(
1684 "overriding ProtocolConfig settings with custom settings (you should not see this log outside of tests)"
1685 );
1686 override_fn(version, ret)
1687 } else {
1688 ret
1689 }
1690 });
1691
1692 if std::env::var("IOTA_PROTOCOL_CONFIG_OVERRIDE_ENABLE").is_ok() {
1693 warn!(
1694 "overriding ProtocolConfig settings with custom settings; this may break non-local networks"
1695 );
1696 let overrides: ProtocolConfigOptional =
1697 serde_env::from_env_with_prefix("IOTA_PROTOCOL_CONFIG_OVERRIDE")
1698 .expect("failed to parse ProtocolConfig override env variables");
1699 overrides.apply_to(&mut ret);
1700 }
1701
1702 ret
1703 }
1704
1705 pub fn get_for_version_if_supported(version: ProtocolVersion, chain: Chain) -> Option<Self> {
1708 if version.0 >= ProtocolVersion::MIN.0 && version.0 <= ProtocolVersion::MAX_ALLOWED.0 {
1709 let mut ret = Self::get_for_version_impl(version, chain);
1710 ret.version = version;
1711 Some(ret)
1712 } else {
1713 None
1714 }
1715 }
1716
1717 #[cfg(not(msim))]
1718 pub fn poison_get_for_min_version() {
1719 POISON_VERSION_METHODS.store(true, Ordering::Relaxed);
1720 }
1721
1722 #[cfg(not(msim))]
1723 fn load_poison_get_for_min_version() -> bool {
1724 POISON_VERSION_METHODS.load(Ordering::Relaxed)
1725 }
1726
1727 #[cfg(msim)]
1728 pub fn poison_get_for_min_version() {
1729 POISON_VERSION_METHODS.with(|p| p.store(true, Ordering::Relaxed));
1730 }
1731
1732 #[cfg(msim)]
1733 fn load_poison_get_for_min_version() -> bool {
1734 POISON_VERSION_METHODS.with(|p| p.load(Ordering::Relaxed))
1735 }
1736
1737 pub fn convert_type_argument_error(&self) -> bool {
1738 self.feature_flags.convert_type_argument_error
1739 }
1740
1741 pub fn get_for_min_version() -> Self {
1745 if Self::load_poison_get_for_min_version() {
1746 panic!("get_for_min_version called on validator");
1747 }
1748 ProtocolConfig::get_for_version(ProtocolVersion::MIN, Chain::Unknown)
1749 }
1750
1751 #[expect(non_snake_case)]
1762 pub fn get_for_max_version_UNSAFE() -> Self {
1763 if Self::load_poison_get_for_min_version() {
1764 panic!("get_for_max_version_UNSAFE called on validator");
1765 }
1766 ProtocolConfig::get_for_version(ProtocolVersion::MAX, Chain::Unknown)
1767 }
1768
1769 fn get_for_version_impl(version: ProtocolVersion, chain: Chain) -> Self {
1770 #[cfg(msim)]
1771 {
1772 if version > ProtocolVersion::MAX {
1774 let mut config = Self::get_for_version_impl(ProtocolVersion::MAX, Chain::Unknown);
1775 config.base_tx_cost_fixed = Some(config.base_tx_cost_fixed() + 1000);
1776 return config;
1777 }
1778 }
1779
1780 let mut cfg = Self {
1784 version,
1785
1786 feature_flags: Default::default(),
1787
1788 max_tx_size_bytes: Some(128 * 1024),
1789 max_input_objects: Some(2048),
1792 max_serialized_tx_effects_size_bytes: Some(512 * 1024),
1793 max_serialized_tx_effects_size_bytes_system_tx: Some(512 * 1024 * 16),
1794 max_gas_payment_objects: Some(256),
1795 max_modules_in_publish: Some(64),
1796 max_package_dependencies: Some(32),
1797 max_arguments: Some(512),
1798 max_type_arguments: Some(16),
1799 max_type_argument_depth: Some(16),
1800 max_pure_argument_size: Some(16 * 1024),
1801 max_programmable_tx_commands: Some(1024),
1802 move_binary_format_version: Some(7),
1803 min_move_binary_format_version: Some(6),
1804 binary_module_handles: Some(100),
1805 binary_struct_handles: Some(300),
1806 binary_function_handles: Some(1500),
1807 binary_function_instantiations: Some(750),
1808 binary_signatures: Some(1000),
1809 binary_constant_pool: Some(4000),
1810 binary_identifiers: Some(10000),
1811 binary_address_identifiers: Some(100),
1812 binary_struct_defs: Some(200),
1813 binary_struct_def_instantiations: Some(100),
1814 binary_function_defs: Some(1000),
1815 binary_field_handles: Some(500),
1816 binary_field_instantiations: Some(250),
1817 binary_friend_decls: Some(100),
1818 binary_enum_defs: None,
1819 binary_enum_def_instantiations: None,
1820 binary_variant_handles: None,
1821 binary_variant_instantiation_handles: None,
1822 max_move_object_size: Some(250 * 1024),
1823 max_move_package_size: Some(100 * 1024),
1824 max_publish_or_upgrade_per_ptb: Some(5),
1825 max_auth_gas: None,
1827 max_tx_gas: Some(50_000_000_000),
1829 max_gas_price: Some(100_000),
1830 max_gas_computation_bucket: Some(5_000_000),
1831 max_loop_depth: Some(5),
1832 max_generic_instantiation_length: Some(32),
1833 max_function_parameters: Some(128),
1834 max_basic_blocks: Some(1024),
1835 max_value_stack_size: Some(1024),
1836 max_type_nodes: Some(256),
1837 max_push_size: Some(10000),
1838 max_struct_definitions: Some(200),
1839 max_function_definitions: Some(1000),
1840 max_fields_in_struct: Some(32),
1841 max_dependency_depth: Some(100),
1842 max_num_event_emit: Some(1024),
1843 max_num_new_move_object_ids: Some(2048),
1844 max_num_new_move_object_ids_system_tx: Some(2048 * 16),
1845 max_num_deleted_move_object_ids: Some(2048),
1846 max_num_deleted_move_object_ids_system_tx: Some(2048 * 16),
1847 max_num_transferred_move_object_ids: Some(2048),
1848 max_num_transferred_move_object_ids_system_tx: Some(2048 * 16),
1849 max_event_emit_size: Some(250 * 1024),
1850 max_move_vector_len: Some(256 * 1024),
1851 max_type_to_layout_nodes: None,
1852 max_ptb_value_size: None,
1853
1854 max_back_edges_per_function: Some(10_000),
1855 max_back_edges_per_module: Some(10_000),
1856
1857 max_verifier_meter_ticks_per_function: Some(16_000_000),
1858
1859 max_meter_ticks_per_module: Some(16_000_000),
1860 max_meter_ticks_per_package: Some(16_000_000),
1861
1862 object_runtime_max_num_cached_objects: Some(1000),
1863 object_runtime_max_num_cached_objects_system_tx: Some(1000 * 16),
1864 object_runtime_max_num_store_entries: Some(1000),
1865 object_runtime_max_num_store_entries_system_tx: Some(1000 * 16),
1866 base_tx_cost_fixed: Some(1_000),
1868 package_publish_cost_fixed: Some(1_000),
1869 base_tx_cost_per_byte: Some(0),
1870 package_publish_cost_per_byte: Some(80),
1871 obj_access_cost_read_per_byte: Some(15),
1872 obj_access_cost_mutate_per_byte: Some(40),
1873 obj_access_cost_delete_per_byte: Some(40),
1874 obj_access_cost_verify_per_byte: Some(200),
1875 obj_data_cost_refundable: Some(100),
1876 obj_metadata_cost_non_refundable: Some(50),
1877 gas_model_version: Some(1),
1878 storage_rebate_rate: Some(10000),
1879 reward_slashing_rate: Some(10000),
1881 storage_gas_price: Some(76),
1882 base_gas_price: None,
1883 validator_target_reward: Some(767_000 * 1_000_000_000),
1886 max_transactions_per_checkpoint: Some(10_000),
1887 max_checkpoint_size_bytes: Some(30 * 1024 * 1024),
1888
1889 buffer_stake_for_protocol_upgrade_bps: Some(5000),
1891
1892 address_from_bytes_cost_base: Some(52),
1896 address_to_u256_cost_base: Some(52),
1898 address_from_u256_cost_base: Some(52),
1900
1901 config_read_setting_impl_cost_base: Some(100),
1904 config_read_setting_impl_cost_per_byte: Some(40),
1905
1906 dynamic_field_hash_type_and_key_cost_base: Some(100),
1910 dynamic_field_hash_type_and_key_type_cost_per_byte: Some(2),
1911 dynamic_field_hash_type_and_key_value_cost_per_byte: Some(2),
1912 dynamic_field_hash_type_and_key_type_tag_cost_per_byte: Some(2),
1913 dynamic_field_add_child_object_cost_base: Some(100),
1916 dynamic_field_add_child_object_type_cost_per_byte: Some(10),
1917 dynamic_field_add_child_object_value_cost_per_byte: Some(10),
1918 dynamic_field_add_child_object_struct_tag_cost_per_byte: Some(10),
1919 dynamic_field_borrow_child_object_cost_base: Some(100),
1922 dynamic_field_borrow_child_object_child_ref_cost_per_byte: Some(10),
1923 dynamic_field_borrow_child_object_type_cost_per_byte: Some(10),
1924 dynamic_field_remove_child_object_cost_base: Some(100),
1927 dynamic_field_remove_child_object_child_cost_per_byte: Some(2),
1928 dynamic_field_remove_child_object_type_cost_per_byte: Some(2),
1929 dynamic_field_has_child_object_cost_base: Some(100),
1932 dynamic_field_has_child_object_with_ty_cost_base: Some(100),
1935 dynamic_field_has_child_object_with_ty_type_cost_per_byte: Some(2),
1936 dynamic_field_has_child_object_with_ty_type_tag_cost_per_byte: Some(2),
1937
1938 event_emit_cost_base: Some(52),
1941 event_emit_value_size_derivation_cost_per_byte: Some(2),
1942 event_emit_tag_size_derivation_cost_per_byte: Some(5),
1943 event_emit_output_cost_per_byte: Some(10),
1944
1945 object_borrow_uid_cost_base: Some(52),
1948 object_delete_impl_cost_base: Some(52),
1950 object_record_new_uid_cost_base: Some(52),
1952
1953 transfer_transfer_internal_cost_base: Some(52),
1957 transfer_freeze_object_cost_base: Some(52),
1959 transfer_share_object_cost_base: Some(52),
1961 transfer_receive_object_cost_base: Some(52),
1962
1963 tx_context_derive_id_cost_base: Some(52),
1967 tx_context_fresh_id_cost_base: None,
1968 tx_context_sender_cost_base: None,
1969 tx_context_digest_cost_base: None,
1970 tx_context_epoch_cost_base: None,
1971 tx_context_epoch_timestamp_ms_cost_base: None,
1972 tx_context_sponsor_cost_base: None,
1973 tx_context_rgp_cost_base: None,
1974 tx_context_gas_price_cost_base: None,
1975 tx_context_gas_budget_cost_base: None,
1976 tx_context_ids_created_cost_base: None,
1977 tx_context_replace_cost_base: None,
1978
1979 types_is_one_time_witness_cost_base: Some(52),
1982 types_is_one_time_witness_type_tag_cost_per_byte: Some(2),
1983 types_is_one_time_witness_type_cost_per_byte: Some(2),
1984
1985 validator_validate_metadata_cost_base: Some(52),
1989 validator_validate_metadata_data_cost_per_byte: Some(2),
1990
1991 crypto_invalid_arguments_cost: Some(100),
1993 bls12381_bls12381_min_sig_verify_cost_base: Some(52),
1995 bls12381_bls12381_min_sig_verify_msg_cost_per_byte: Some(2),
1996 bls12381_bls12381_min_sig_verify_msg_cost_per_block: Some(2),
1997
1998 bls12381_bls12381_min_pk_verify_cost_base: Some(52),
2000 bls12381_bls12381_min_pk_verify_msg_cost_per_byte: Some(2),
2001 bls12381_bls12381_min_pk_verify_msg_cost_per_block: Some(2),
2002
2003 ecdsa_k1_ecrecover_keccak256_cost_base: Some(52),
2005 ecdsa_k1_ecrecover_keccak256_msg_cost_per_byte: Some(2),
2006 ecdsa_k1_ecrecover_keccak256_msg_cost_per_block: Some(2),
2007 ecdsa_k1_ecrecover_sha256_cost_base: Some(52),
2008 ecdsa_k1_ecrecover_sha256_msg_cost_per_byte: Some(2),
2009 ecdsa_k1_ecrecover_sha256_msg_cost_per_block: Some(2),
2010
2011 ecdsa_k1_decompress_pubkey_cost_base: Some(52),
2013
2014 ecdsa_k1_secp256k1_verify_keccak256_cost_base: Some(52),
2016 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_byte: Some(2),
2017 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_block: Some(2),
2018 ecdsa_k1_secp256k1_verify_sha256_cost_base: Some(52),
2019 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_byte: Some(2),
2020 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_block: Some(2),
2021
2022 ecdsa_r1_ecrecover_keccak256_cost_base: Some(52),
2024 ecdsa_r1_ecrecover_keccak256_msg_cost_per_byte: Some(2),
2025 ecdsa_r1_ecrecover_keccak256_msg_cost_per_block: Some(2),
2026 ecdsa_r1_ecrecover_sha256_cost_base: Some(52),
2027 ecdsa_r1_ecrecover_sha256_msg_cost_per_byte: Some(2),
2028 ecdsa_r1_ecrecover_sha256_msg_cost_per_block: Some(2),
2029
2030 ecdsa_r1_secp256r1_verify_keccak256_cost_base: Some(52),
2032 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_byte: Some(2),
2033 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_block: Some(2),
2034 ecdsa_r1_secp256r1_verify_sha256_cost_base: Some(52),
2035 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_byte: Some(2),
2036 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_block: Some(2),
2037
2038 ecvrf_ecvrf_verify_cost_base: Some(52),
2040 ecvrf_ecvrf_verify_alpha_string_cost_per_byte: Some(2),
2041 ecvrf_ecvrf_verify_alpha_string_cost_per_block: Some(2),
2042
2043 ed25519_ed25519_verify_cost_base: Some(52),
2045 ed25519_ed25519_verify_msg_cost_per_byte: Some(2),
2046 ed25519_ed25519_verify_msg_cost_per_block: Some(2),
2047
2048 groth16_prepare_verifying_key_bls12381_cost_base: Some(52),
2050 groth16_prepare_verifying_key_bn254_cost_base: Some(52),
2051
2052 groth16_verify_groth16_proof_internal_bls12381_cost_base: Some(52),
2054 groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input: Some(2),
2055 groth16_verify_groth16_proof_internal_bn254_cost_base: Some(52),
2056 groth16_verify_groth16_proof_internal_bn254_cost_per_public_input: Some(2),
2057 groth16_verify_groth16_proof_internal_public_input_cost_per_byte: Some(2),
2058
2059 hash_blake2b256_cost_base: Some(52),
2061 hash_blake2b256_data_cost_per_byte: Some(2),
2062 hash_blake2b256_data_cost_per_block: Some(2),
2063 hash_keccak256_cost_base: Some(52),
2065 hash_keccak256_data_cost_per_byte: Some(2),
2066 hash_keccak256_data_cost_per_block: Some(2),
2067
2068 poseidon_bn254_cost_base: None,
2069 poseidon_bn254_cost_per_block: None,
2070
2071 hmac_hmac_sha3_256_cost_base: Some(52),
2073 hmac_hmac_sha3_256_input_cost_per_byte: Some(2),
2074 hmac_hmac_sha3_256_input_cost_per_block: Some(2),
2075
2076 group_ops_bls12381_decode_scalar_cost: Some(52),
2078 group_ops_bls12381_decode_g1_cost: Some(52),
2079 group_ops_bls12381_decode_g2_cost: Some(52),
2080 group_ops_bls12381_decode_gt_cost: Some(52),
2081 group_ops_bls12381_scalar_add_cost: Some(52),
2082 group_ops_bls12381_g1_add_cost: Some(52),
2083 group_ops_bls12381_g2_add_cost: Some(52),
2084 group_ops_bls12381_gt_add_cost: Some(52),
2085 group_ops_bls12381_scalar_sub_cost: Some(52),
2086 group_ops_bls12381_g1_sub_cost: Some(52),
2087 group_ops_bls12381_g2_sub_cost: Some(52),
2088 group_ops_bls12381_gt_sub_cost: Some(52),
2089 group_ops_bls12381_scalar_mul_cost: Some(52),
2090 group_ops_bls12381_g1_mul_cost: Some(52),
2091 group_ops_bls12381_g2_mul_cost: Some(52),
2092 group_ops_bls12381_gt_mul_cost: Some(52),
2093 group_ops_bls12381_scalar_div_cost: Some(52),
2094 group_ops_bls12381_g1_div_cost: Some(52),
2095 group_ops_bls12381_g2_div_cost: Some(52),
2096 group_ops_bls12381_gt_div_cost: Some(52),
2097 group_ops_bls12381_g1_hash_to_base_cost: Some(52),
2098 group_ops_bls12381_g2_hash_to_base_cost: Some(52),
2099 group_ops_bls12381_g1_hash_to_cost_per_byte: Some(2),
2100 group_ops_bls12381_g2_hash_to_cost_per_byte: Some(2),
2101 group_ops_bls12381_g1_msm_base_cost: Some(52),
2102 group_ops_bls12381_g2_msm_base_cost: Some(52),
2103 group_ops_bls12381_g1_msm_base_cost_per_input: Some(52),
2104 group_ops_bls12381_g2_msm_base_cost_per_input: Some(52),
2105 group_ops_bls12381_msm_max_len: Some(32),
2106 group_ops_bls12381_pairing_cost: Some(52),
2107 group_ops_bls12381_g1_to_uncompressed_g1_cost: None,
2108 group_ops_bls12381_uncompressed_g1_to_g1_cost: None,
2109 group_ops_bls12381_uncompressed_g1_sum_base_cost: None,
2110 group_ops_bls12381_uncompressed_g1_sum_cost_per_term: None,
2111 group_ops_bls12381_uncompressed_g1_sum_max_terms: None,
2112
2113 check_zklogin_id_cost_base: Some(200),
2115 check_zklogin_issuer_cost_base: Some(200),
2117
2118 vdf_verify_vdf_cost: None,
2119 vdf_hash_to_input_cost: None,
2120
2121 bcs_per_byte_serialized_cost: Some(2),
2122 bcs_legacy_min_output_size_cost: Some(1),
2123 bcs_failure_cost: Some(52),
2124 hash_sha2_256_base_cost: Some(52),
2125 hash_sha2_256_per_byte_cost: Some(2),
2126 hash_sha2_256_legacy_min_input_len_cost: Some(1),
2127 hash_sha3_256_base_cost: Some(52),
2128 hash_sha3_256_per_byte_cost: Some(2),
2129 hash_sha3_256_legacy_min_input_len_cost: Some(1),
2130 type_name_get_base_cost: Some(52),
2131 type_name_get_per_byte_cost: Some(2),
2132 string_check_utf8_base_cost: Some(52),
2133 string_check_utf8_per_byte_cost: Some(2),
2134 string_is_char_boundary_base_cost: Some(52),
2135 string_sub_string_base_cost: Some(52),
2136 string_sub_string_per_byte_cost: Some(2),
2137 string_index_of_base_cost: Some(52),
2138 string_index_of_per_byte_pattern_cost: Some(2),
2139 string_index_of_per_byte_searched_cost: Some(2),
2140 vector_empty_base_cost: Some(52),
2141 vector_length_base_cost: Some(52),
2142 vector_push_back_base_cost: Some(52),
2143 vector_push_back_legacy_per_abstract_memory_unit_cost: Some(2),
2144 vector_borrow_base_cost: Some(52),
2145 vector_pop_back_base_cost: Some(52),
2146 vector_destroy_empty_base_cost: Some(52),
2147 vector_swap_base_cost: Some(52),
2148 debug_print_base_cost: Some(52),
2149 debug_print_stack_trace_base_cost: Some(52),
2150
2151 max_size_written_objects: Some(5 * 1000 * 1000),
2152 max_size_written_objects_system_tx: Some(50 * 1000 * 1000),
2155
2156 max_move_identifier_len: Some(128),
2158 max_move_value_depth: Some(128),
2159 max_move_enum_variants: None,
2160
2161 gas_rounding_step: Some(1_000),
2162
2163 execution_version: Some(1),
2164
2165 max_event_emit_size_total: Some(
2168 256 * 250 * 1024, ),
2170
2171 consensus_bad_nodes_stake_threshold: Some(20),
2178
2179 max_jwk_votes_per_validator_per_epoch: Some(240),
2181
2182 max_age_of_jwk_in_epochs: Some(1),
2183
2184 consensus_max_transaction_size_bytes: Some(256 * 1024), consensus_max_transactions_in_block_bytes: Some(512 * 1024),
2188
2189 random_beacon_reduction_allowed_delta: Some(800),
2190
2191 random_beacon_reduction_lower_bound: Some(1000),
2192 random_beacon_dkg_timeout_round: Some(3000),
2193 random_beacon_min_round_interval_ms: Some(500),
2194
2195 random_beacon_dkg_version: Some(1),
2196
2197 consensus_max_num_transactions_in_block: Some(512),
2201
2202 max_deferral_rounds_for_congestion_control: Some(10),
2203
2204 min_checkpoint_interval_ms: Some(200),
2205
2206 checkpoint_summary_version_specific_data: Some(1),
2207
2208 max_soft_bundle_size: Some(5),
2209
2210 bridge_should_try_to_finalize_committee: None,
2211
2212 max_accumulated_txn_cost_per_object_in_mysticeti_commit: Some(10),
2213
2214 max_committee_members_count: None,
2215
2216 consensus_gc_depth: None,
2217
2218 consensus_max_acknowledgments_per_block: None,
2219
2220 max_congestion_limit_overshoot_per_commit: None,
2221
2222 scorer_version: None,
2223
2224 auth_context_digest_cost_base: None,
2226 auth_context_tx_commands_cost_base: None,
2227 auth_context_tx_commands_cost_per_byte: None,
2228 auth_context_tx_inputs_cost_base: None,
2229 auth_context_tx_inputs_cost_per_byte: None,
2230 auth_context_replace_cost_base: None,
2231 auth_context_replace_cost_per_byte: None,
2232 };
2235
2236 cfg.feature_flags.consensus_transaction_ordering = ConsensusTransactionOrdering::ByGasPrice;
2237
2238 {
2240 cfg.feature_flags
2241 .disable_invariant_violation_check_in_swap_loc = true;
2242 cfg.feature_flags.no_extraneous_module_bytes = true;
2243 cfg.feature_flags.hardened_otw_check = true;
2244 cfg.feature_flags.rethrow_serialization_type_layout_errors = true;
2245 }
2246
2247 {
2249 cfg.feature_flags.zklogin_max_epoch_upper_bound_delta = Some(30);
2250 }
2251
2252 cfg.feature_flags.consensus_choice = ConsensusChoice::Mysticeti;
2254 cfg.feature_flags.consensus_network = ConsensusNetwork::Tonic;
2256
2257 cfg.feature_flags.per_object_congestion_control_mode =
2258 PerObjectCongestionControlMode::TotalTxCount;
2259
2260 cfg.bridge_should_try_to_finalize_committee = Some(chain != Chain::Mainnet);
2262
2263 if chain != Chain::Mainnet && chain != Chain::Testnet {
2265 cfg.feature_flags.enable_poseidon = true;
2266 cfg.poseidon_bn254_cost_base = Some(260);
2267 cfg.poseidon_bn254_cost_per_block = Some(10);
2268
2269 cfg.feature_flags.enable_group_ops_native_function_msm = true;
2270
2271 cfg.feature_flags.enable_vdf = true;
2272 cfg.vdf_verify_vdf_cost = Some(1500);
2275 cfg.vdf_hash_to_input_cost = Some(100);
2276
2277 cfg.feature_flags.passkey_auth = true;
2278 }
2279
2280 for cur in 2..=version.0 {
2281 match cur {
2282 1 => unreachable!(),
2283 2 => {}
2285 3 => {
2286 cfg.feature_flags.relocate_event_module = true;
2287 }
2288 4 => {
2289 cfg.max_type_to_layout_nodes = Some(512);
2290 }
2291 5 => {
2292 cfg.feature_flags.protocol_defined_base_fee = true;
2293 cfg.base_gas_price = Some(1000);
2294
2295 cfg.feature_flags.disallow_new_modules_in_deps_only_packages = true;
2296 cfg.feature_flags.convert_type_argument_error = true;
2297 cfg.feature_flags.native_charging_v2 = true;
2298
2299 if chain != Chain::Mainnet && chain != Chain::Testnet {
2300 cfg.feature_flags.uncompressed_g1_group_elements = true;
2301 }
2302
2303 cfg.gas_model_version = Some(2);
2304
2305 cfg.poseidon_bn254_cost_per_block = Some(388);
2306
2307 cfg.bls12381_bls12381_min_sig_verify_cost_base = Some(44064);
2308 cfg.bls12381_bls12381_min_pk_verify_cost_base = Some(49282);
2309 cfg.ecdsa_k1_secp256k1_verify_keccak256_cost_base = Some(1470);
2310 cfg.ecdsa_k1_secp256k1_verify_sha256_cost_base = Some(1470);
2311 cfg.ecdsa_r1_secp256r1_verify_sha256_cost_base = Some(4225);
2312 cfg.ecdsa_r1_secp256r1_verify_keccak256_cost_base = Some(4225);
2313 cfg.ecvrf_ecvrf_verify_cost_base = Some(4848);
2314 cfg.ed25519_ed25519_verify_cost_base = Some(1802);
2315
2316 cfg.ecdsa_r1_ecrecover_keccak256_cost_base = Some(1173);
2318 cfg.ecdsa_r1_ecrecover_sha256_cost_base = Some(1173);
2319 cfg.ecdsa_k1_ecrecover_keccak256_cost_base = Some(500);
2320 cfg.ecdsa_k1_ecrecover_sha256_cost_base = Some(500);
2321
2322 cfg.groth16_prepare_verifying_key_bls12381_cost_base = Some(53838);
2323 cfg.groth16_prepare_verifying_key_bn254_cost_base = Some(82010);
2324 cfg.groth16_verify_groth16_proof_internal_bls12381_cost_base = Some(72090);
2325 cfg.groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input =
2326 Some(8213);
2327 cfg.groth16_verify_groth16_proof_internal_bn254_cost_base = Some(115502);
2328 cfg.groth16_verify_groth16_proof_internal_bn254_cost_per_public_input =
2329 Some(9484);
2330
2331 cfg.hash_keccak256_cost_base = Some(10);
2332 cfg.hash_blake2b256_cost_base = Some(10);
2333
2334 cfg.group_ops_bls12381_decode_scalar_cost = Some(7);
2336 cfg.group_ops_bls12381_decode_g1_cost = Some(2848);
2337 cfg.group_ops_bls12381_decode_g2_cost = Some(3770);
2338 cfg.group_ops_bls12381_decode_gt_cost = Some(3068);
2339
2340 cfg.group_ops_bls12381_scalar_add_cost = Some(10);
2341 cfg.group_ops_bls12381_g1_add_cost = Some(1556);
2342 cfg.group_ops_bls12381_g2_add_cost = Some(3048);
2343 cfg.group_ops_bls12381_gt_add_cost = Some(188);
2344
2345 cfg.group_ops_bls12381_scalar_sub_cost = Some(10);
2346 cfg.group_ops_bls12381_g1_sub_cost = Some(1550);
2347 cfg.group_ops_bls12381_g2_sub_cost = Some(3019);
2348 cfg.group_ops_bls12381_gt_sub_cost = Some(497);
2349
2350 cfg.group_ops_bls12381_scalar_mul_cost = Some(11);
2351 cfg.group_ops_bls12381_g1_mul_cost = Some(4842);
2352 cfg.group_ops_bls12381_g2_mul_cost = Some(9108);
2353 cfg.group_ops_bls12381_gt_mul_cost = Some(27490);
2354
2355 cfg.group_ops_bls12381_scalar_div_cost = Some(91);
2356 cfg.group_ops_bls12381_g1_div_cost = Some(5091);
2357 cfg.group_ops_bls12381_g2_div_cost = Some(9206);
2358 cfg.group_ops_bls12381_gt_div_cost = Some(27804);
2359
2360 cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(2962);
2361 cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(8688);
2362
2363 cfg.group_ops_bls12381_g1_msm_base_cost = Some(62648);
2364 cfg.group_ops_bls12381_g2_msm_base_cost = Some(131192);
2365 cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(1333);
2366 cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(3216);
2367
2368 cfg.group_ops_bls12381_uncompressed_g1_to_g1_cost = Some(677);
2369 cfg.group_ops_bls12381_g1_to_uncompressed_g1_cost = Some(2099);
2370 cfg.group_ops_bls12381_uncompressed_g1_sum_base_cost = Some(77);
2371 cfg.group_ops_bls12381_uncompressed_g1_sum_cost_per_term = Some(26);
2372 cfg.group_ops_bls12381_uncompressed_g1_sum_max_terms = Some(1200);
2373
2374 cfg.group_ops_bls12381_pairing_cost = Some(26897);
2375
2376 cfg.validator_validate_metadata_cost_base = Some(20000);
2377
2378 cfg.max_committee_members_count = Some(50);
2379 }
2380 6 => {
2381 cfg.max_ptb_value_size = Some(1024 * 1024);
2382 }
2383 7 => {
2384 }
2387 8 => {
2388 cfg.feature_flags.variant_nodes = true;
2389
2390 if chain != Chain::Mainnet {
2391 cfg.feature_flags.consensus_round_prober = true;
2393 cfg.feature_flags
2395 .consensus_distributed_vote_scoring_strategy = true;
2396 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
2397 cfg.feature_flags.consensus_smart_ancestor_selection = true;
2399 cfg.feature_flags
2401 .consensus_round_prober_probe_accepted_rounds = true;
2402 cfg.feature_flags.consensus_zstd_compression = true;
2404 cfg.consensus_gc_depth = Some(60);
2408 }
2409
2410 if chain != Chain::Testnet && chain != Chain::Mainnet {
2413 cfg.feature_flags.congestion_control_min_free_execution_slot = true;
2414 }
2415 }
2416 9 => {
2417 if chain != Chain::Mainnet {
2418 cfg.feature_flags.consensus_smart_ancestor_selection = false;
2420 }
2421
2422 cfg.feature_flags.consensus_zstd_compression = true;
2424
2425 if chain != Chain::Testnet && chain != Chain::Mainnet {
2427 cfg.feature_flags.accept_passkey_in_multisig = true;
2428 }
2429
2430 cfg.bridge_should_try_to_finalize_committee = None;
2432 }
2433 10 => {
2434 cfg.feature_flags.congestion_control_min_free_execution_slot = true;
2437
2438 cfg.max_committee_members_count = Some(80);
2440
2441 cfg.feature_flags.consensus_round_prober = true;
2443 cfg.feature_flags
2445 .consensus_round_prober_probe_accepted_rounds = true;
2446 cfg.feature_flags
2448 .consensus_distributed_vote_scoring_strategy = true;
2449 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
2451
2452 cfg.consensus_gc_depth = Some(60);
2457
2458 cfg.feature_flags.minimize_child_object_mutations = true;
2460
2461 if chain != Chain::Mainnet {
2462 cfg.feature_flags.consensus_batched_block_sync = true;
2464 }
2465
2466 if chain != Chain::Testnet && chain != Chain::Mainnet {
2467 cfg.feature_flags
2470 .congestion_control_gas_price_feedback_mechanism = true;
2471 }
2472
2473 cfg.feature_flags.validate_identifier_inputs = true;
2474 cfg.feature_flags.dependency_linkage_error = true;
2475 cfg.feature_flags.additional_multisig_checks = true;
2476 }
2477 11 => {
2478 }
2481 12 => {
2482 cfg.feature_flags
2485 .congestion_control_gas_price_feedback_mechanism = true;
2486
2487 cfg.feature_flags.normalize_ptb_arguments = true;
2489 }
2490 13 => {
2491 cfg.feature_flags.select_committee_from_eligible_validators = true;
2494 cfg.feature_flags.track_non_committee_eligible_validators = true;
2497
2498 if chain != Chain::Testnet && chain != Chain::Mainnet {
2499 cfg.feature_flags
2502 .select_committee_supporting_next_epoch_version = true;
2503 }
2504 }
2505 14 => {
2506 cfg.feature_flags.consensus_batched_block_sync = true;
2508
2509 if chain != Chain::Mainnet {
2510 cfg.feature_flags
2513 .consensus_median_timestamp_with_checkpoint_enforcement = true;
2514 cfg.feature_flags
2518 .select_committee_supporting_next_epoch_version = true;
2519 }
2520 if chain != Chain::Testnet && chain != Chain::Mainnet {
2521 cfg.feature_flags.consensus_choice = ConsensusChoice::Starfish;
2523 }
2524 }
2525 15 => {
2526 if chain != Chain::Mainnet && chain != Chain::Testnet {
2527 cfg.max_congestion_limit_overshoot_per_commit = Some(100);
2531 }
2532 }
2533 16 => {
2534 cfg.feature_flags
2537 .select_committee_supporting_next_epoch_version = true;
2538 cfg.feature_flags
2540 .consensus_commit_transactions_only_for_traversed_headers = true;
2541 }
2542 17 => {
2543 cfg.max_committee_members_count = Some(100);
2545 }
2546 18 => {
2547 if chain != Chain::Mainnet {
2548 cfg.feature_flags.passkey_auth = true;
2550 }
2551 }
2552 19 => {
2553 if chain != Chain::Testnet && chain != Chain::Mainnet {
2554 cfg.feature_flags
2557 .congestion_limit_overshoot_in_gas_price_feedback_mechanism = true;
2558 cfg.feature_flags
2561 .separate_gas_price_feedback_mechanism_for_randomness = true;
2562 cfg.feature_flags.metadata_in_module_bytes = true;
2565 cfg.feature_flags.publish_package_metadata = true;
2566 cfg.feature_flags.enable_move_authentication = true;
2568 cfg.max_auth_gas = Some(250_000_000);
2570 cfg.transfer_receive_object_cost_base = Some(100);
2573 cfg.feature_flags.adjust_rewards_by_score = true;
2575 }
2576
2577 if chain != Chain::Mainnet {
2578 cfg.feature_flags.consensus_choice = ConsensusChoice::Starfish;
2580
2581 cfg.feature_flags.calculate_validator_scores = true;
2583 cfg.scorer_version = Some(1);
2584 }
2585
2586 cfg.feature_flags.pass_validator_scores_to_advance_epoch = true;
2588
2589 cfg.feature_flags.passkey_auth = true;
2591 }
2592 20 => {
2593 if chain != Chain::Testnet && chain != Chain::Mainnet {
2594 cfg.feature_flags
2596 .pass_calculated_validator_scores_to_advance_epoch = true;
2597 }
2598 }
2599 21 => {
2600 if chain != Chain::Testnet && chain != Chain::Mainnet {
2601 cfg.feature_flags.consensus_fast_commit_sync = true;
2603 }
2604 if chain != Chain::Mainnet {
2605 cfg.max_congestion_limit_overshoot_per_commit = Some(100);
2610 cfg.feature_flags
2613 .congestion_limit_overshoot_in_gas_price_feedback_mechanism = true;
2614 cfg.feature_flags
2617 .separate_gas_price_feedback_mechanism_for_randomness = true;
2618 }
2619
2620 cfg.auth_context_digest_cost_base = Some(30);
2621 cfg.auth_context_tx_commands_cost_base = Some(30);
2622 cfg.auth_context_tx_commands_cost_per_byte = Some(2);
2623 cfg.auth_context_tx_inputs_cost_base = Some(30);
2624 cfg.auth_context_tx_inputs_cost_per_byte = Some(2);
2625 cfg.auth_context_replace_cost_base = Some(30);
2626 cfg.auth_context_replace_cost_per_byte = Some(2);
2627
2628 if chain != Chain::Testnet && chain != Chain::Mainnet {
2629 cfg.max_auth_gas = Some(250_000);
2631 }
2632 }
2633 22 => {
2634 cfg.max_congestion_limit_overshoot_per_commit = Some(100);
2639 cfg.feature_flags
2642 .congestion_limit_overshoot_in_gas_price_feedback_mechanism = true;
2643 cfg.feature_flags
2646 .separate_gas_price_feedback_mechanism_for_randomness = true;
2647
2648 if chain != Chain::Mainnet {
2649 cfg.feature_flags.metadata_in_module_bytes = true;
2652 cfg.feature_flags.publish_package_metadata = true;
2653 cfg.feature_flags.enable_move_authentication = true;
2655 cfg.max_auth_gas = Some(250_000);
2657 cfg.transfer_receive_object_cost_base = Some(100);
2660 }
2661
2662 if chain != Chain::Mainnet {
2663 cfg.feature_flags.consensus_fast_commit_sync = true;
2665 }
2666 }
2667 23 => {
2668 cfg.feature_flags.move_native_tx_context = true;
2670 cfg.tx_context_fresh_id_cost_base = Some(52);
2671 cfg.tx_context_sender_cost_base = Some(30);
2672 cfg.tx_context_digest_cost_base = Some(30);
2673 cfg.tx_context_epoch_cost_base = Some(30);
2674 cfg.tx_context_epoch_timestamp_ms_cost_base = Some(30);
2675 cfg.tx_context_sponsor_cost_base = Some(30);
2676 cfg.tx_context_rgp_cost_base = Some(30);
2677 cfg.tx_context_gas_price_cost_base = Some(30);
2678 cfg.tx_context_gas_budget_cost_base = Some(30);
2679 cfg.tx_context_ids_created_cost_base = Some(30);
2680 cfg.tx_context_replace_cost_base = Some(30);
2681 }
2682
2683 _ => panic!("unsupported version {version:?}"),
2694 }
2695 }
2696 cfg
2697 }
2698
2699 pub fn verifier_config(&self, signing_limits: Option<(usize, usize)>) -> VerifierConfig {
2703 let (max_back_edges_per_function, max_back_edges_per_module) = if let Some((
2704 max_back_edges_per_function,
2705 max_back_edges_per_module,
2706 )) = signing_limits
2707 {
2708 (
2709 Some(max_back_edges_per_function),
2710 Some(max_back_edges_per_module),
2711 )
2712 } else {
2713 (None, None)
2714 };
2715
2716 VerifierConfig {
2717 max_loop_depth: Some(self.max_loop_depth() as usize),
2718 max_generic_instantiation_length: Some(self.max_generic_instantiation_length() as usize),
2719 max_function_parameters: Some(self.max_function_parameters() as usize),
2720 max_basic_blocks: Some(self.max_basic_blocks() as usize),
2721 max_value_stack_size: self.max_value_stack_size() as usize,
2722 max_type_nodes: Some(self.max_type_nodes() as usize),
2723 max_push_size: Some(self.max_push_size() as usize),
2724 max_dependency_depth: Some(self.max_dependency_depth() as usize),
2725 max_fields_in_struct: Some(self.max_fields_in_struct() as usize),
2726 max_function_definitions: Some(self.max_function_definitions() as usize),
2727 max_data_definitions: Some(self.max_struct_definitions() as usize),
2728 max_constant_vector_len: Some(self.max_move_vector_len()),
2729 max_back_edges_per_function,
2730 max_back_edges_per_module,
2731 max_basic_blocks_in_script: None,
2732 max_identifier_len: self.max_move_identifier_len_as_option(), bytecode_version: self.move_binary_format_version(),
2736 max_variants_in_enum: self.max_move_enum_variants_as_option(),
2737 }
2738 }
2739
2740 pub fn apply_overrides_for_testing(
2745 override_fn: impl Fn(ProtocolVersion, Self) -> Self + Send + Sync + 'static,
2746 ) -> OverrideGuard {
2747 CONFIG_OVERRIDE.with(|ovr| {
2748 let mut cur = ovr.borrow_mut();
2749 assert!(cur.is_none(), "config override already present");
2750 *cur = Some(Box::new(override_fn));
2751 OverrideGuard
2752 })
2753 }
2754}
2755
2756impl ProtocolConfig {
2761 pub fn set_zklogin_auth_for_testing(&mut self, val: bool) {
2762 self.feature_flags.zklogin_auth = val
2763 }
2764 pub fn set_enable_jwk_consensus_updates_for_testing(&mut self, val: bool) {
2765 self.feature_flags.enable_jwk_consensus_updates = val
2766 }
2767
2768 pub fn set_accept_zklogin_in_multisig_for_testing(&mut self, val: bool) {
2769 self.feature_flags.accept_zklogin_in_multisig = val
2770 }
2771
2772 pub fn set_per_object_congestion_control_mode_for_testing(
2773 &mut self,
2774 val: PerObjectCongestionControlMode,
2775 ) {
2776 self.feature_flags.per_object_congestion_control_mode = val;
2777 }
2778
2779 pub fn set_consensus_choice_for_testing(&mut self, val: ConsensusChoice) {
2780 self.feature_flags.consensus_choice = val;
2781 }
2782
2783 pub fn set_consensus_network_for_testing(&mut self, val: ConsensusNetwork) {
2784 self.feature_flags.consensus_network = val;
2785 }
2786
2787 pub fn set_zklogin_max_epoch_upper_bound_delta_for_testing(&mut self, val: Option<u64>) {
2788 self.feature_flags.zklogin_max_epoch_upper_bound_delta = val
2789 }
2790
2791 pub fn set_passkey_auth_for_testing(&mut self, val: bool) {
2792 self.feature_flags.passkey_auth = val
2793 }
2794
2795 pub fn set_disallow_new_modules_in_deps_only_packages_for_testing(&mut self, val: bool) {
2796 self.feature_flags
2797 .disallow_new_modules_in_deps_only_packages = val;
2798 }
2799
2800 pub fn set_consensus_round_prober_for_testing(&mut self, val: bool) {
2801 self.feature_flags.consensus_round_prober = val;
2802 }
2803
2804 pub fn set_consensus_distributed_vote_scoring_strategy_for_testing(&mut self, val: bool) {
2805 self.feature_flags
2806 .consensus_distributed_vote_scoring_strategy = val;
2807 }
2808
2809 pub fn set_gc_depth_for_testing(&mut self, val: u32) {
2810 self.consensus_gc_depth = Some(val);
2811 }
2812
2813 pub fn set_consensus_linearize_subdag_v2_for_testing(&mut self, val: bool) {
2814 self.feature_flags.consensus_linearize_subdag_v2 = val;
2815 }
2816
2817 pub fn set_consensus_round_prober_probe_accepted_rounds(&mut self, val: bool) {
2818 self.feature_flags
2819 .consensus_round_prober_probe_accepted_rounds = val;
2820 }
2821
2822 pub fn set_accept_passkey_in_multisig_for_testing(&mut self, val: bool) {
2823 self.feature_flags.accept_passkey_in_multisig = val;
2824 }
2825
2826 pub fn set_consensus_smart_ancestor_selection_for_testing(&mut self, val: bool) {
2827 self.feature_flags.consensus_smart_ancestor_selection = val;
2828 }
2829
2830 pub fn set_consensus_batched_block_sync_for_testing(&mut self, val: bool) {
2831 self.feature_flags.consensus_batched_block_sync = val;
2832 }
2833
2834 pub fn set_congestion_control_min_free_execution_slot_for_testing(&mut self, val: bool) {
2835 self.feature_flags
2836 .congestion_control_min_free_execution_slot = val;
2837 }
2838
2839 pub fn set_congestion_control_gas_price_feedback_mechanism_for_testing(&mut self, val: bool) {
2840 self.feature_flags
2841 .congestion_control_gas_price_feedback_mechanism = val;
2842 }
2843
2844 pub fn set_select_committee_from_eligible_validators_for_testing(&mut self, val: bool) {
2845 self.feature_flags.select_committee_from_eligible_validators = val;
2846 }
2847
2848 pub fn set_track_non_committee_eligible_validators_for_testing(&mut self, val: bool) {
2849 self.feature_flags.track_non_committee_eligible_validators = val;
2850 }
2851
2852 pub fn set_select_committee_supporting_next_epoch_version(&mut self, val: bool) {
2853 self.feature_flags
2854 .select_committee_supporting_next_epoch_version = val;
2855 }
2856
2857 pub fn set_consensus_median_timestamp_with_checkpoint_enforcement_for_testing(
2858 &mut self,
2859 val: bool,
2860 ) {
2861 self.feature_flags
2862 .consensus_median_timestamp_with_checkpoint_enforcement = val;
2863 }
2864
2865 pub fn set_consensus_commit_transactions_only_for_traversed_headers_for_testing(
2866 &mut self,
2867 val: bool,
2868 ) {
2869 self.feature_flags
2870 .consensus_commit_transactions_only_for_traversed_headers = val;
2871 }
2872
2873 pub fn set_congestion_limit_overshoot_in_gas_price_feedback_mechanism_for_testing(
2874 &mut self,
2875 val: bool,
2876 ) {
2877 self.feature_flags
2878 .congestion_limit_overshoot_in_gas_price_feedback_mechanism = val;
2879 }
2880
2881 pub fn set_separate_gas_price_feedback_mechanism_for_randomness_for_testing(
2882 &mut self,
2883 val: bool,
2884 ) {
2885 self.feature_flags
2886 .separate_gas_price_feedback_mechanism_for_randomness = val;
2887 }
2888
2889 pub fn set_metadata_in_module_bytes_for_testing(&mut self, val: bool) {
2890 self.feature_flags.metadata_in_module_bytes = val;
2891 }
2892
2893 pub fn set_publish_package_metadata_for_testing(&mut self, val: bool) {
2894 self.feature_flags.publish_package_metadata = val;
2895 }
2896
2897 pub fn set_enable_move_authentication_for_testing(&mut self, val: bool) {
2898 self.feature_flags.enable_move_authentication = val;
2899 }
2900 pub fn set_consensus_fast_commit_sync_for_testing(&mut self, val: bool) {
2901 self.feature_flags.consensus_fast_commit_sync = val;
2902 }
2903}
2904
2905type OverrideFn = dyn Fn(ProtocolVersion, ProtocolConfig) -> ProtocolConfig + Send + Sync;
2906
2907thread_local! {
2908 static CONFIG_OVERRIDE: RefCell<Option<Box<OverrideFn>>> = const { RefCell::new(None) };
2909}
2910
2911#[must_use]
2912pub struct OverrideGuard;
2913
2914impl Drop for OverrideGuard {
2915 fn drop(&mut self) {
2916 info!("restoring override fn");
2917 CONFIG_OVERRIDE.with(|ovr| {
2918 *ovr.borrow_mut() = None;
2919 });
2920 }
2921}
2922
2923#[derive(PartialEq, Eq)]
2927pub enum LimitThresholdCrossed {
2928 None,
2929 Soft(u128, u128),
2930 Hard(u128, u128),
2931}
2932
2933pub fn check_limit_in_range<T: Into<V>, U: Into<V>, V: PartialOrd + Into<u128>>(
2936 x: T,
2937 soft_limit: U,
2938 hard_limit: V,
2939) -> LimitThresholdCrossed {
2940 let x: V = x.into();
2941 let soft_limit: V = soft_limit.into();
2942
2943 debug_assert!(soft_limit <= hard_limit);
2944
2945 if x >= hard_limit {
2948 LimitThresholdCrossed::Hard(x.into(), hard_limit.into())
2949 } else if x < soft_limit {
2950 LimitThresholdCrossed::None
2951 } else {
2952 LimitThresholdCrossed::Soft(x.into(), soft_limit.into())
2953 }
2954}
2955
2956#[macro_export]
2957macro_rules! check_limit {
2958 ($x:expr, $hard:expr) => {
2959 check_limit!($x, $hard, $hard)
2960 };
2961 ($x:expr, $soft:expr, $hard:expr) => {
2962 check_limit_in_range($x as u64, $soft, $hard)
2963 };
2964}
2965
2966#[macro_export]
2970macro_rules! check_limit_by_meter {
2971 ($is_metered:expr, $x:expr, $metered_limit:expr, $unmetered_hard_limit:expr, $metric:expr) => {{
2972 let (h, metered_str) = if $is_metered {
2974 ($metered_limit, "metered")
2975 } else {
2976 ($unmetered_hard_limit, "unmetered")
2978 };
2979 use iota_protocol_config::check_limit_in_range;
2980 let result = check_limit_in_range($x as u64, $metered_limit, h);
2981 match result {
2982 LimitThresholdCrossed::None => {}
2983 LimitThresholdCrossed::Soft(_, _) => {
2984 $metric.with_label_values(&[metered_str, "soft"]).inc();
2985 }
2986 LimitThresholdCrossed::Hard(_, _) => {
2987 $metric.with_label_values(&[metered_str, "hard"]).inc();
2988 }
2989 };
2990 result
2991 }};
2992}
2993
2994#[cfg(all(test, not(msim)))]
2995mod test {
2996 use insta::assert_yaml_snapshot;
2997
2998 use super::*;
2999
3000 #[test]
3001 fn snapshot_tests() {
3002 println!("\n============================================================================");
3003 println!("! !");
3004 println!("! IMPORTANT: never update snapshots from this test. only add new versions! !");
3005 println!("! !");
3006 println!("============================================================================\n");
3007 for chain_id in &[Chain::Unknown, Chain::Mainnet, Chain::Testnet] {
3008 let chain_str = match chain_id {
3013 Chain::Unknown => "".to_string(),
3014 _ => format!("{chain_id:?}_"),
3015 };
3016 for i in MIN_PROTOCOL_VERSION..=MAX_PROTOCOL_VERSION {
3017 let cur = ProtocolVersion::new(i);
3018 assert_yaml_snapshot!(
3019 format!("{}version_{}", chain_str, cur.as_u64()),
3020 ProtocolConfig::get_for_version(cur, *chain_id)
3021 );
3022 }
3023 }
3024 }
3025
3026 #[test]
3027 fn test_getters() {
3028 let prot: ProtocolConfig =
3029 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
3030 assert_eq!(
3031 prot.max_arguments(),
3032 prot.max_arguments_as_option().unwrap()
3033 );
3034 }
3035
3036 #[test]
3037 fn test_setters() {
3038 let mut prot: ProtocolConfig =
3039 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
3040 prot.set_max_arguments_for_testing(123);
3041 assert_eq!(prot.max_arguments(), 123);
3042
3043 prot.set_max_arguments_from_str_for_testing("321".to_string());
3044 assert_eq!(prot.max_arguments(), 321);
3045
3046 prot.disable_max_arguments_for_testing();
3047 assert_eq!(prot.max_arguments_as_option(), None);
3048
3049 prot.set_attr_for_testing("max_arguments".to_string(), "456".to_string());
3050 assert_eq!(prot.max_arguments(), 456);
3051 }
3052
3053 #[test]
3054 #[should_panic(expected = "unsupported version")]
3055 fn max_version_test() {
3056 let _ = ProtocolConfig::get_for_version_impl(
3059 ProtocolVersion::new(MAX_PROTOCOL_VERSION + 1),
3060 Chain::Unknown,
3061 );
3062 }
3063
3064 #[test]
3065 fn lookup_by_string_test() {
3066 let prot: ProtocolConfig =
3067 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Mainnet);
3068 assert!(prot.lookup_attr("some random string".to_string()).is_none());
3070
3071 assert!(
3072 prot.lookup_attr("max_arguments".to_string())
3073 == Some(ProtocolConfigValue::u32(prot.max_arguments())),
3074 );
3075
3076 assert!(
3078 prot.lookup_attr("poseidon_bn254_cost_base".to_string())
3079 .is_none()
3080 );
3081 assert!(
3082 prot.attr_map()
3083 .get("poseidon_bn254_cost_base")
3084 .unwrap()
3085 .is_none()
3086 );
3087
3088 let prot: ProtocolConfig =
3090 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
3091
3092 assert!(
3093 prot.lookup_attr("poseidon_bn254_cost_base".to_string())
3094 == Some(ProtocolConfigValue::u64(prot.poseidon_bn254_cost_base()))
3095 );
3096 assert!(
3097 prot.attr_map().get("poseidon_bn254_cost_base").unwrap()
3098 == &Some(ProtocolConfigValue::u64(prot.poseidon_bn254_cost_base()))
3099 );
3100
3101 let prot: ProtocolConfig =
3103 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Mainnet);
3104 assert!(
3106 prot.feature_flags
3107 .lookup_attr("some random string".to_owned())
3108 .is_none()
3109 );
3110 assert!(
3111 !prot
3112 .feature_flags
3113 .attr_map()
3114 .contains_key("some random string")
3115 );
3116
3117 assert!(prot.feature_flags.lookup_attr("enable_poseidon".to_owned()) == Some(false));
3119 assert!(
3120 prot.feature_flags
3121 .attr_map()
3122 .get("enable_poseidon")
3123 .unwrap()
3124 == &false
3125 );
3126 let prot: ProtocolConfig =
3127 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
3128 assert!(prot.feature_flags.lookup_attr("enable_poseidon".to_owned()) == Some(true));
3130 assert!(
3131 prot.feature_flags
3132 .attr_map()
3133 .get("enable_poseidon")
3134 .unwrap()
3135 == &true
3136 );
3137 }
3138
3139 #[test]
3140 fn limit_range_fn_test() {
3141 let low = 100u32;
3142 let high = 10000u64;
3143
3144 assert!(check_limit!(1u8, low, high) == LimitThresholdCrossed::None);
3145 assert!(matches!(
3146 check_limit!(255u16, low, high),
3147 LimitThresholdCrossed::Soft(255u128, 100)
3148 ));
3149 assert!(matches!(
3156 check_limit!(2550000u64, low, high),
3157 LimitThresholdCrossed::Hard(2550000, 10000)
3158 ));
3159
3160 assert!(matches!(
3161 check_limit!(2550000u64, high, high),
3162 LimitThresholdCrossed::Hard(2550000, 10000)
3163 ));
3164
3165 assert!(matches!(
3166 check_limit!(1u8, high),
3167 LimitThresholdCrossed::None
3168 ));
3169
3170 assert!(check_limit!(255u16, high) == LimitThresholdCrossed::None);
3171
3172 assert!(matches!(
3173 check_limit!(2550000u64, high),
3174 LimitThresholdCrossed::Hard(2550000, 10000)
3175 ));
3176 }
3177}