1use std::{
5 cell::RefCell,
6 collections::BTreeSet,
7 sync::atomic::{AtomicBool, Ordering},
8};
9
10use clap::*;
11use fastcrypto::encoding::{Base58, Encoding, Hex};
12use move_binary_format::{
13 binary_config::{BinaryConfig, TableConfig},
14 file_format_common::VERSION_1,
15};
16use move_vm_config::verifier::VerifierConfig;
17use mysten_common::in_integration_test;
18use serde::{Deserialize, Serialize};
19use serde_with::skip_serializing_none;
20use sui_protocol_config_macros::{
21 ProtocolConfigAccessors, ProtocolConfigFeatureFlagsGetters, ProtocolConfigOverride,
22};
23use tracing::{info, warn};
24
25const MIN_PROTOCOL_VERSION: u64 = 1;
27const MAX_PROTOCOL_VERSION: u64 = 112;
28
29#[derive(Copy, Clone, Debug, Hash, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)]
302pub struct ProtocolVersion(u64);
303
304impl ProtocolVersion {
305 pub const MIN: Self = Self(MIN_PROTOCOL_VERSION);
310
311 pub const MAX: Self = Self(MAX_PROTOCOL_VERSION);
312
313 #[cfg(not(msim))]
314 pub const MAX_ALLOWED: Self = Self::MAX;
315
316 #[cfg(msim)]
318 pub const MAX_ALLOWED: Self = Self(MAX_PROTOCOL_VERSION + 1);
319
320 pub fn new(v: u64) -> Self {
321 Self(v)
322 }
323
324 pub const fn as_u64(&self) -> u64 {
325 self.0
326 }
327
328 pub fn max() -> Self {
331 Self::MAX
332 }
333
334 pub fn prev(self) -> Self {
335 Self(self.0.checked_sub(1).unwrap())
336 }
337}
338
339impl From<u64> for ProtocolVersion {
340 fn from(v: u64) -> Self {
341 Self::new(v)
342 }
343}
344
345impl std::ops::Sub<u64> for ProtocolVersion {
346 type Output = Self;
347 fn sub(self, rhs: u64) -> Self::Output {
348 Self::new(self.0 - rhs)
349 }
350}
351
352impl std::ops::Add<u64> for ProtocolVersion {
353 type Output = Self;
354 fn add(self, rhs: u64) -> Self::Output {
355 Self::new(self.0 + rhs)
356 }
357}
358
359#[derive(
360 Clone, Serialize, Deserialize, Debug, Default, PartialEq, Copy, PartialOrd, Ord, Eq, ValueEnum,
361)]
362pub enum Chain {
363 Mainnet,
364 Testnet,
365 #[default]
366 Unknown,
367}
368
369impl Chain {
370 pub fn as_str(self) -> &'static str {
371 match self {
372 Chain::Mainnet => "mainnet",
373 Chain::Testnet => "testnet",
374 Chain::Unknown => "unknown",
375 }
376 }
377}
378
379pub struct Error(pub String);
380
381#[derive(Default, Clone, Serialize, Deserialize, Debug, ProtocolConfigFeatureFlagsGetters)]
384struct FeatureFlags {
385 #[serde(skip_serializing_if = "is_false")]
388 package_upgrades: bool,
389 #[serde(skip_serializing_if = "is_false")]
392 commit_root_state_digest: bool,
393 #[serde(skip_serializing_if = "is_false")]
395 advance_epoch_start_time_in_safe_mode: bool,
396 #[serde(skip_serializing_if = "is_false")]
399 loaded_child_objects_fixed: bool,
400 #[serde(skip_serializing_if = "is_false")]
403 missing_type_is_compatibility_error: bool,
404 #[serde(skip_serializing_if = "is_false")]
407 scoring_decision_with_validity_cutoff: bool,
408
409 #[serde(skip_serializing_if = "is_false")]
412 consensus_order_end_of_epoch_last: bool,
413
414 #[serde(skip_serializing_if = "is_false")]
416 disallow_adding_abilities_on_upgrade: bool,
417 #[serde(skip_serializing_if = "is_false")]
419 disable_invariant_violation_check_in_swap_loc: bool,
420 #[serde(skip_serializing_if = "is_false")]
423 advance_to_highest_supported_protocol_version: bool,
424 #[serde(skip_serializing_if = "is_false")]
426 ban_entry_init: bool,
427 #[serde(skip_serializing_if = "is_false")]
429 package_digest_hash_module: bool,
430 #[serde(skip_serializing_if = "is_false")]
432 disallow_change_struct_type_params_on_upgrade: bool,
433 #[serde(skip_serializing_if = "is_false")]
435 no_extraneous_module_bytes: bool,
436 #[serde(skip_serializing_if = "is_false")]
438 narwhal_versioned_metadata: bool,
439
440 #[serde(skip_serializing_if = "is_false")]
442 zklogin_auth: bool,
443 #[serde(skip_serializing_if = "ConsensusTransactionOrdering::is_none")]
445 consensus_transaction_ordering: ConsensusTransactionOrdering,
446
447 #[serde(skip_serializing_if = "is_false")]
455 simplified_unwrap_then_delete: bool,
456 #[serde(skip_serializing_if = "is_false")]
458 upgraded_multisig_supported: bool,
459 #[serde(skip_serializing_if = "is_false")]
461 txn_base_cost_as_multiplier: bool,
462
463 #[serde(skip_serializing_if = "is_false")]
465 shared_object_deletion: bool,
466
467 #[serde(skip_serializing_if = "is_false")]
469 narwhal_new_leader_election_schedule: bool,
470
471 #[serde(skip_serializing_if = "is_empty")]
473 zklogin_supported_providers: BTreeSet<String>,
474
475 #[serde(skip_serializing_if = "is_false")]
477 loaded_child_object_format: bool,
478
479 #[serde(skip_serializing_if = "is_false")]
480 enable_jwk_consensus_updates: bool,
481
482 #[serde(skip_serializing_if = "is_false")]
483 end_of_epoch_transaction_supported: bool,
484
485 #[serde(skip_serializing_if = "is_false")]
488 simple_conservation_checks: bool,
489
490 #[serde(skip_serializing_if = "is_false")]
492 loaded_child_object_format_type: bool,
493
494 #[serde(skip_serializing_if = "is_false")]
496 receive_objects: bool,
497
498 #[serde(skip_serializing_if = "is_false")]
500 consensus_checkpoint_signature_key_includes_digest: bool,
501
502 #[serde(skip_serializing_if = "is_false")]
504 random_beacon: bool,
505
506 #[serde(skip_serializing_if = "is_false")]
508 bridge: bool,
509
510 #[serde(skip_serializing_if = "is_false")]
511 enable_effects_v2: bool,
512
513 #[serde(skip_serializing_if = "is_false")]
515 narwhal_certificate_v2: bool,
516
517 #[serde(skip_serializing_if = "is_false")]
519 verify_legacy_zklogin_address: bool,
520
521 #[serde(skip_serializing_if = "is_false")]
523 throughput_aware_consensus_submission: bool,
524
525 #[serde(skip_serializing_if = "is_false")]
527 recompute_has_public_transfer_in_execution: bool,
528
529 #[serde(skip_serializing_if = "is_false")]
531 accept_zklogin_in_multisig: bool,
532
533 #[serde(skip_serializing_if = "is_false")]
535 accept_passkey_in_multisig: bool,
536
537 #[serde(skip_serializing_if = "is_false")]
539 validate_zklogin_public_identifier: bool,
540
541 #[serde(skip_serializing_if = "is_false")]
544 include_consensus_digest_in_prologue: bool,
545
546 #[serde(skip_serializing_if = "is_false")]
548 hardened_otw_check: bool,
549
550 #[serde(skip_serializing_if = "is_false")]
552 allow_receiving_object_id: bool,
553
554 #[serde(skip_serializing_if = "is_false")]
556 enable_poseidon: bool,
557
558 #[serde(skip_serializing_if = "is_false")]
560 enable_coin_deny_list: bool,
561
562 #[serde(skip_serializing_if = "is_false")]
564 enable_group_ops_native_functions: bool,
565
566 #[serde(skip_serializing_if = "is_false")]
568 enable_group_ops_native_function_msm: bool,
569
570 #[serde(skip_serializing_if = "is_false")]
572 enable_ristretto255_group_ops: bool,
573
574 #[serde(skip_serializing_if = "is_false")]
576 enable_nitro_attestation: bool,
577
578 #[serde(skip_serializing_if = "is_false")]
580 enable_nitro_attestation_upgraded_parsing: bool,
581
582 #[serde(skip_serializing_if = "is_false")]
584 enable_nitro_attestation_all_nonzero_pcrs_parsing: bool,
585
586 #[serde(skip_serializing_if = "is_false")]
588 enable_nitro_attestation_always_include_required_pcrs_parsing: bool,
589
590 #[serde(skip_serializing_if = "is_false")]
592 reject_mutable_random_on_entry_functions: bool,
593
594 #[serde(skip_serializing_if = "PerObjectCongestionControlMode::is_none")]
596 per_object_congestion_control_mode: PerObjectCongestionControlMode,
597
598 #[serde(skip_serializing_if = "ConsensusChoice::is_narwhal")]
600 consensus_choice: ConsensusChoice,
601
602 #[serde(skip_serializing_if = "ConsensusNetwork::is_anemo")]
604 consensus_network: ConsensusNetwork,
605
606 #[serde(skip_serializing_if = "is_false")]
608 correct_gas_payment_limit_check: bool,
609
610 #[serde(skip_serializing_if = "Option::is_none")]
612 zklogin_max_epoch_upper_bound_delta: Option<u64>,
613
614 #[serde(skip_serializing_if = "is_false")]
616 mysticeti_leader_scoring_and_schedule: bool,
617
618 #[serde(skip_serializing_if = "is_false")]
620 reshare_at_same_initial_version: bool,
621
622 #[serde(skip_serializing_if = "is_false")]
624 resolve_abort_locations_to_package_id: bool,
625
626 #[serde(skip_serializing_if = "is_false")]
630 mysticeti_use_committed_subdag_digest: bool,
631
632 #[serde(skip_serializing_if = "is_false")]
634 enable_vdf: bool,
635
636 #[serde(skip_serializing_if = "is_false")]
641 record_consensus_determined_version_assignments_in_prologue: bool,
642 #[serde(skip_serializing_if = "is_false")]
643 record_consensus_determined_version_assignments_in_prologue_v2: bool,
644
645 #[serde(skip_serializing_if = "is_false")]
647 fresh_vm_on_framework_upgrade: bool,
648
649 #[serde(skip_serializing_if = "is_false")]
657 prepend_prologue_tx_in_consensus_commit_in_checkpoints: bool,
658
659 #[serde(skip_serializing_if = "Option::is_none")]
661 mysticeti_num_leaders_per_round: Option<usize>,
662
663 #[serde(skip_serializing_if = "is_false")]
665 soft_bundle: bool,
666
667 #[serde(skip_serializing_if = "is_false")]
669 enable_coin_deny_list_v2: bool,
670
671 #[serde(skip_serializing_if = "is_false")]
673 passkey_auth: bool,
674
675 #[serde(skip_serializing_if = "is_false")]
677 authority_capabilities_v2: bool,
678
679 #[serde(skip_serializing_if = "is_false")]
681 rethrow_serialization_type_layout_errors: bool,
682
683 #[serde(skip_serializing_if = "is_false")]
685 consensus_distributed_vote_scoring_strategy: bool,
686
687 #[serde(skip_serializing_if = "is_false")]
689 consensus_round_prober: bool,
690
691 #[serde(skip_serializing_if = "is_false")]
693 validate_identifier_inputs: bool,
694
695 #[serde(skip_serializing_if = "is_false")]
697 disallow_self_identifier: bool,
698
699 #[serde(skip_serializing_if = "is_false")]
701 mysticeti_fastpath: bool,
702
703 #[serde(skip_serializing_if = "is_false")]
707 disable_preconsensus_locking: bool,
708
709 #[serde(skip_serializing_if = "is_false")]
711 relocate_event_module: bool,
712
713 #[serde(skip_serializing_if = "is_false")]
715 uncompressed_g1_group_elements: bool,
716
717 #[serde(skip_serializing_if = "is_false")]
718 disallow_new_modules_in_deps_only_packages: bool,
719
720 #[serde(skip_serializing_if = "is_false")]
722 consensus_smart_ancestor_selection: bool,
723
724 #[serde(skip_serializing_if = "is_false")]
726 consensus_round_prober_probe_accepted_rounds: bool,
727
728 #[serde(skip_serializing_if = "is_false")]
730 native_charging_v2: bool,
731
732 #[serde(skip_serializing_if = "is_false")]
735 consensus_linearize_subdag_v2: bool,
736
737 #[serde(skip_serializing_if = "is_false")]
739 convert_type_argument_error: bool,
740
741 #[serde(skip_serializing_if = "is_false")]
743 variant_nodes: bool,
744
745 #[serde(skip_serializing_if = "is_false")]
747 consensus_zstd_compression: bool,
748
749 #[serde(skip_serializing_if = "is_false")]
751 minimize_child_object_mutations: bool,
752
753 #[serde(skip_serializing_if = "is_false")]
755 record_additional_state_digest_in_prologue: bool,
756
757 #[serde(skip_serializing_if = "is_false")]
759 move_native_context: bool,
760
761 #[serde(skip_serializing_if = "is_false")]
764 consensus_median_based_commit_timestamp: bool,
765
766 #[serde(skip_serializing_if = "is_false")]
769 normalize_ptb_arguments: bool,
770
771 #[serde(skip_serializing_if = "is_false")]
773 consensus_batched_block_sync: bool,
774
775 #[serde(skip_serializing_if = "is_false")]
777 enforce_checkpoint_timestamp_monotonicity: bool,
778
779 #[serde(skip_serializing_if = "is_false")]
781 max_ptb_value_size_v2: bool,
782
783 #[serde(skip_serializing_if = "is_false")]
785 resolve_type_input_ids_to_defining_id: bool,
786
787 #[serde(skip_serializing_if = "is_false")]
789 enable_party_transfer: bool,
790
791 #[serde(skip_serializing_if = "is_false")]
793 allow_unbounded_system_objects: bool,
794
795 #[serde(skip_serializing_if = "is_false")]
797 type_tags_in_object_runtime: bool,
798
799 #[serde(skip_serializing_if = "is_false")]
801 enable_accumulators: bool,
802
803 #[serde(skip_serializing_if = "is_false")]
805 enable_coin_reservation_obj_refs: bool,
806
807 #[serde(skip_serializing_if = "is_false")]
810 create_root_accumulator_object: bool,
811
812 #[serde(skip_serializing_if = "is_false")]
814 enable_authenticated_event_streams: bool,
815
816 #[serde(skip_serializing_if = "is_false")]
818 enable_address_balance_gas_payments: bool,
819
820 #[serde(skip_serializing_if = "is_false")]
822 enable_multi_epoch_transaction_expiration: bool,
823
824 #[serde(skip_serializing_if = "is_false")]
826 enable_ptb_execution_v2: bool,
827
828 #[serde(skip_serializing_if = "is_false")]
830 better_adapter_type_resolution_errors: bool,
831
832 #[serde(skip_serializing_if = "is_false")]
834 record_time_estimate_processed: bool,
835
836 #[serde(skip_serializing_if = "is_false")]
838 dependency_linkage_error: bool,
839
840 #[serde(skip_serializing_if = "is_false")]
842 additional_multisig_checks: bool,
843
844 #[serde(skip_serializing_if = "is_false")]
846 ignore_execution_time_observations_after_certs_closed: bool,
847
848 #[serde(skip_serializing_if = "is_false")]
852 debug_fatal_on_move_invariant_violation: bool,
853
854 #[serde(skip_serializing_if = "is_false")]
857 allow_private_accumulator_entrypoints: bool,
858
859 #[serde(skip_serializing_if = "is_false")]
861 additional_consensus_digest_indirect_state: bool,
862
863 #[serde(skip_serializing_if = "is_false")]
865 check_for_init_during_upgrade: bool,
866
867 #[serde(skip_serializing_if = "is_false")]
869 per_command_shared_object_transfer_rules: bool,
870
871 #[serde(skip_serializing_if = "is_false")]
873 include_checkpoint_artifacts_digest_in_summary: bool,
874
875 #[serde(skip_serializing_if = "is_false")]
877 use_mfp_txns_in_load_initial_object_debts: bool,
878
879 #[serde(skip_serializing_if = "is_false")]
881 cancel_for_failed_dkg_early: bool,
882
883 #[serde(skip_serializing_if = "is_false")]
885 enable_coin_registry: bool,
886
887 #[serde(skip_serializing_if = "is_false")]
889 abstract_size_in_object_runtime: bool,
890
891 #[serde(skip_serializing_if = "is_false")]
893 object_runtime_charge_cache_load_gas: bool,
894
895 #[serde(skip_serializing_if = "is_false")]
897 additional_borrow_checks: bool,
898
899 #[serde(skip_serializing_if = "is_false")]
901 use_new_commit_handler: bool,
902
903 #[serde(skip_serializing_if = "is_false")]
905 better_loader_errors: bool,
906
907 #[serde(skip_serializing_if = "is_false")]
909 generate_df_type_layouts: bool,
910
911 #[serde(skip_serializing_if = "is_false")]
913 allow_references_in_ptbs: bool,
914
915 #[serde(skip_serializing_if = "is_false")]
917 enable_display_registry: bool,
918
919 #[serde(skip_serializing_if = "is_false")]
921 private_generics_verifier_v2: bool,
922
923 #[serde(skip_serializing_if = "is_false")]
925 deprecate_global_storage_ops_during_deserialization: bool,
926
927 #[serde(skip_serializing_if = "is_false")]
930 enable_non_exclusive_writes: bool,
931
932 #[serde(skip_serializing_if = "is_false")]
934 deprecate_global_storage_ops: bool,
935
936 #[serde(skip_serializing_if = "is_false")]
938 consensus_skip_gced_accept_votes: bool,
939
940 #[serde(skip_serializing_if = "is_false")]
942 include_cancelled_randomness_txns_in_prologue: bool,
943
944 #[serde(skip_serializing_if = "is_false")]
946 address_aliases: bool,
947
948 #[serde(skip_serializing_if = "is_false")]
951 fix_checkpoint_signature_mapping: bool,
952
953 #[serde(skip_serializing_if = "is_false")]
955 enable_object_funds_withdraw: bool,
956
957 #[serde(skip_serializing_if = "is_false")]
959 consensus_skip_gced_blocks_in_direct_finalization: bool,
960
961 #[serde(skip_serializing_if = "is_false")]
963 gas_rounding_halve_digits: bool,
964
965 #[serde(skip_serializing_if = "is_false")]
967 flexible_tx_context_positions: bool,
968
969 #[serde(skip_serializing_if = "is_false")]
971 disable_entry_point_signature_check: bool,
972
973 #[serde(skip_serializing_if = "is_false")]
975 convert_withdrawal_compatibility_ptb_arguments: bool,
976
977 #[serde(skip_serializing_if = "is_false")]
979 restrict_hot_or_not_entry_functions: bool,
980
981 #[serde(skip_serializing_if = "is_false")]
983 split_checkpoints_in_consensus_handler: bool,
984
985 #[serde(skip_serializing_if = "is_false")]
987 consensus_always_accept_system_transactions: bool,
988
989 #[serde(skip_serializing_if = "is_false")]
991 validator_metadata_verify_v2: bool,
992}
993
994fn is_false(b: &bool) -> bool {
995 !b
996}
997
998fn is_empty(b: &BTreeSet<String>) -> bool {
999 b.is_empty()
1000}
1001
1002fn is_zero(val: &u64) -> bool {
1003 *val == 0
1004}
1005
1006#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1008pub enum ConsensusTransactionOrdering {
1009 #[default]
1011 None,
1012 ByGasPrice,
1014}
1015
1016impl ConsensusTransactionOrdering {
1017 pub fn is_none(&self) -> bool {
1018 matches!(self, ConsensusTransactionOrdering::None)
1019 }
1020}
1021
1022#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1023pub struct ExecutionTimeEstimateParams {
1024 pub target_utilization: u64,
1026 pub allowed_txn_cost_overage_burst_limit_us: u64,
1030
1031 pub randomness_scalar: u64,
1034
1035 pub max_estimate_us: u64,
1037
1038 pub stored_observations_num_included_checkpoints: u64,
1041
1042 pub stored_observations_limit: u64,
1044
1045 #[serde(skip_serializing_if = "is_zero")]
1048 pub stake_weighted_median_threshold: u64,
1049
1050 #[serde(skip_serializing_if = "is_false")]
1054 pub default_none_duration_for_new_keys: bool,
1055
1056 #[serde(skip_serializing_if = "Option::is_none")]
1058 pub observations_chunk_size: Option<u64>,
1059}
1060
1061#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1063pub enum PerObjectCongestionControlMode {
1064 #[default]
1065 None, TotalGasBudget, TotalTxCount, TotalGasBudgetWithCap, ExecutionTimeEstimate(ExecutionTimeEstimateParams), }
1071
1072impl PerObjectCongestionControlMode {
1073 pub fn is_none(&self) -> bool {
1074 matches!(self, PerObjectCongestionControlMode::None)
1075 }
1076}
1077
1078#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1080pub enum ConsensusChoice {
1081 #[default]
1082 Narwhal,
1083 SwapEachEpoch,
1084 Mysticeti,
1085}
1086
1087impl ConsensusChoice {
1088 pub fn is_narwhal(&self) -> bool {
1089 matches!(self, ConsensusChoice::Narwhal)
1090 }
1091}
1092
1093#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1095pub enum ConsensusNetwork {
1096 #[default]
1097 Anemo,
1098 Tonic,
1099}
1100
1101impl ConsensusNetwork {
1102 pub fn is_anemo(&self) -> bool {
1103 matches!(self, ConsensusNetwork::Anemo)
1104 }
1105}
1106
1107#[skip_serializing_none]
1139#[derive(Clone, Serialize, Debug, ProtocolConfigAccessors, ProtocolConfigOverride)]
1140pub struct ProtocolConfig {
1141 pub version: ProtocolVersion,
1142
1143 feature_flags: FeatureFlags,
1144
1145 max_tx_size_bytes: Option<u64>,
1148
1149 max_input_objects: Option<u64>,
1151
1152 max_size_written_objects: Option<u64>,
1156 max_size_written_objects_system_tx: Option<u64>,
1159
1160 max_serialized_tx_effects_size_bytes: Option<u64>,
1162
1163 max_serialized_tx_effects_size_bytes_system_tx: Option<u64>,
1165
1166 max_gas_payment_objects: Option<u32>,
1168
1169 max_modules_in_publish: Option<u32>,
1171
1172 max_package_dependencies: Option<u32>,
1174
1175 max_arguments: Option<u32>,
1178
1179 max_type_arguments: Option<u32>,
1181
1182 max_type_argument_depth: Option<u32>,
1184
1185 max_pure_argument_size: Option<u32>,
1187
1188 max_programmable_tx_commands: Option<u32>,
1190
1191 move_binary_format_version: Option<u32>,
1194 min_move_binary_format_version: Option<u32>,
1195
1196 binary_module_handles: Option<u16>,
1198 binary_struct_handles: Option<u16>,
1199 binary_function_handles: Option<u16>,
1200 binary_function_instantiations: Option<u16>,
1201 binary_signatures: Option<u16>,
1202 binary_constant_pool: Option<u16>,
1203 binary_identifiers: Option<u16>,
1204 binary_address_identifiers: Option<u16>,
1205 binary_struct_defs: Option<u16>,
1206 binary_struct_def_instantiations: Option<u16>,
1207 binary_function_defs: Option<u16>,
1208 binary_field_handles: Option<u16>,
1209 binary_field_instantiations: Option<u16>,
1210 binary_friend_decls: Option<u16>,
1211 binary_enum_defs: Option<u16>,
1212 binary_enum_def_instantiations: Option<u16>,
1213 binary_variant_handles: Option<u16>,
1214 binary_variant_instantiation_handles: Option<u16>,
1215
1216 max_move_object_size: Option<u64>,
1218
1219 max_move_package_size: Option<u64>,
1222
1223 max_publish_or_upgrade_per_ptb: Option<u64>,
1225
1226 max_tx_gas: Option<u64>,
1228
1229 max_gas_price: Option<u64>,
1231
1232 max_gas_price_rgp_factor_for_aborted_transactions: Option<u64>,
1235
1236 max_gas_computation_bucket: Option<u64>,
1238
1239 gas_rounding_step: Option<u64>,
1241
1242 max_loop_depth: Option<u64>,
1244
1245 max_generic_instantiation_length: Option<u64>,
1247
1248 max_function_parameters: Option<u64>,
1250
1251 max_basic_blocks: Option<u64>,
1253
1254 max_value_stack_size: Option<u64>,
1256
1257 max_type_nodes: Option<u64>,
1259
1260 max_push_size: Option<u64>,
1262
1263 max_struct_definitions: Option<u64>,
1265
1266 max_function_definitions: Option<u64>,
1268
1269 max_fields_in_struct: Option<u64>,
1271
1272 max_dependency_depth: Option<u64>,
1274
1275 max_num_event_emit: Option<u64>,
1277
1278 max_num_new_move_object_ids: Option<u64>,
1280
1281 max_num_new_move_object_ids_system_tx: Option<u64>,
1283
1284 max_num_deleted_move_object_ids: Option<u64>,
1286
1287 max_num_deleted_move_object_ids_system_tx: Option<u64>,
1289
1290 max_num_transferred_move_object_ids: Option<u64>,
1292
1293 max_num_transferred_move_object_ids_system_tx: Option<u64>,
1295
1296 max_event_emit_size: Option<u64>,
1298
1299 max_event_emit_size_total: Option<u64>,
1301
1302 max_move_vector_len: Option<u64>,
1304
1305 max_move_identifier_len: Option<u64>,
1307
1308 max_move_value_depth: Option<u64>,
1310
1311 max_move_enum_variants: Option<u64>,
1313
1314 max_back_edges_per_function: Option<u64>,
1316
1317 max_back_edges_per_module: Option<u64>,
1319
1320 max_verifier_meter_ticks_per_function: Option<u64>,
1322
1323 max_meter_ticks_per_module: Option<u64>,
1325
1326 max_meter_ticks_per_package: Option<u64>,
1328
1329 object_runtime_max_num_cached_objects: Option<u64>,
1333
1334 object_runtime_max_num_cached_objects_system_tx: Option<u64>,
1336
1337 object_runtime_max_num_store_entries: Option<u64>,
1339
1340 object_runtime_max_num_store_entries_system_tx: Option<u64>,
1342
1343 base_tx_cost_fixed: Option<u64>,
1346
1347 package_publish_cost_fixed: Option<u64>,
1350
1351 base_tx_cost_per_byte: Option<u64>,
1354
1355 package_publish_cost_per_byte: Option<u64>,
1357
1358 obj_access_cost_read_per_byte: Option<u64>,
1360
1361 obj_access_cost_mutate_per_byte: Option<u64>,
1363
1364 obj_access_cost_delete_per_byte: Option<u64>,
1366
1367 obj_access_cost_verify_per_byte: Option<u64>,
1377
1378 max_type_to_layout_nodes: Option<u64>,
1380
1381 max_ptb_value_size: Option<u64>,
1383
1384 gas_model_version: Option<u64>,
1387
1388 obj_data_cost_refundable: Option<u64>,
1391
1392 obj_metadata_cost_non_refundable: Option<u64>,
1396
1397 storage_rebate_rate: Option<u64>,
1403
1404 storage_fund_reinvest_rate: Option<u64>,
1407
1408 reward_slashing_rate: Option<u64>,
1411
1412 storage_gas_price: Option<u64>,
1414
1415 accumulator_object_storage_cost: Option<u64>,
1417
1418 max_transactions_per_checkpoint: Option<u64>,
1423
1424 max_checkpoint_size_bytes: Option<u64>,
1428
1429 buffer_stake_for_protocol_upgrade_bps: Option<u64>,
1434
1435 address_from_bytes_cost_base: Option<u64>,
1440 address_to_u256_cost_base: Option<u64>,
1442 address_from_u256_cost_base: Option<u64>,
1444
1445 config_read_setting_impl_cost_base: Option<u64>,
1450 config_read_setting_impl_cost_per_byte: Option<u64>,
1451
1452 dynamic_field_hash_type_and_key_cost_base: Option<u64>,
1455 dynamic_field_hash_type_and_key_type_cost_per_byte: Option<u64>,
1456 dynamic_field_hash_type_and_key_value_cost_per_byte: Option<u64>,
1457 dynamic_field_hash_type_and_key_type_tag_cost_per_byte: Option<u64>,
1458 dynamic_field_add_child_object_cost_base: Option<u64>,
1460 dynamic_field_add_child_object_type_cost_per_byte: Option<u64>,
1461 dynamic_field_add_child_object_value_cost_per_byte: Option<u64>,
1462 dynamic_field_add_child_object_struct_tag_cost_per_byte: Option<u64>,
1463 dynamic_field_borrow_child_object_cost_base: Option<u64>,
1465 dynamic_field_borrow_child_object_child_ref_cost_per_byte: Option<u64>,
1466 dynamic_field_borrow_child_object_type_cost_per_byte: Option<u64>,
1467 dynamic_field_remove_child_object_cost_base: Option<u64>,
1469 dynamic_field_remove_child_object_child_cost_per_byte: Option<u64>,
1470 dynamic_field_remove_child_object_type_cost_per_byte: Option<u64>,
1471 dynamic_field_has_child_object_cost_base: Option<u64>,
1473 dynamic_field_has_child_object_with_ty_cost_base: Option<u64>,
1475 dynamic_field_has_child_object_with_ty_type_cost_per_byte: Option<u64>,
1476 dynamic_field_has_child_object_with_ty_type_tag_cost_per_byte: Option<u64>,
1477
1478 event_emit_cost_base: Option<u64>,
1481 event_emit_value_size_derivation_cost_per_byte: Option<u64>,
1482 event_emit_tag_size_derivation_cost_per_byte: Option<u64>,
1483 event_emit_output_cost_per_byte: Option<u64>,
1484 event_emit_auth_stream_cost: Option<u64>,
1485
1486 object_borrow_uid_cost_base: Option<u64>,
1489 object_delete_impl_cost_base: Option<u64>,
1491 object_record_new_uid_cost_base: Option<u64>,
1493
1494 transfer_transfer_internal_cost_base: Option<u64>,
1497 transfer_party_transfer_internal_cost_base: Option<u64>,
1499 transfer_freeze_object_cost_base: Option<u64>,
1501 transfer_share_object_cost_base: Option<u64>,
1503 transfer_receive_object_cost_base: Option<u64>,
1506
1507 tx_context_derive_id_cost_base: Option<u64>,
1510 tx_context_fresh_id_cost_base: Option<u64>,
1511 tx_context_sender_cost_base: Option<u64>,
1512 tx_context_epoch_cost_base: Option<u64>,
1513 tx_context_epoch_timestamp_ms_cost_base: Option<u64>,
1514 tx_context_sponsor_cost_base: Option<u64>,
1515 tx_context_rgp_cost_base: Option<u64>,
1516 tx_context_gas_price_cost_base: Option<u64>,
1517 tx_context_gas_budget_cost_base: Option<u64>,
1518 tx_context_ids_created_cost_base: Option<u64>,
1519 tx_context_replace_cost_base: Option<u64>,
1520
1521 types_is_one_time_witness_cost_base: Option<u64>,
1524 types_is_one_time_witness_type_tag_cost_per_byte: Option<u64>,
1525 types_is_one_time_witness_type_cost_per_byte: Option<u64>,
1526
1527 validator_validate_metadata_cost_base: Option<u64>,
1530 validator_validate_metadata_data_cost_per_byte: Option<u64>,
1531
1532 crypto_invalid_arguments_cost: Option<u64>,
1534 bls12381_bls12381_min_sig_verify_cost_base: Option<u64>,
1536 bls12381_bls12381_min_sig_verify_msg_cost_per_byte: Option<u64>,
1537 bls12381_bls12381_min_sig_verify_msg_cost_per_block: Option<u64>,
1538
1539 bls12381_bls12381_min_pk_verify_cost_base: Option<u64>,
1541 bls12381_bls12381_min_pk_verify_msg_cost_per_byte: Option<u64>,
1542 bls12381_bls12381_min_pk_verify_msg_cost_per_block: Option<u64>,
1543
1544 ecdsa_k1_ecrecover_keccak256_cost_base: Option<u64>,
1546 ecdsa_k1_ecrecover_keccak256_msg_cost_per_byte: Option<u64>,
1547 ecdsa_k1_ecrecover_keccak256_msg_cost_per_block: Option<u64>,
1548 ecdsa_k1_ecrecover_sha256_cost_base: Option<u64>,
1549 ecdsa_k1_ecrecover_sha256_msg_cost_per_byte: Option<u64>,
1550 ecdsa_k1_ecrecover_sha256_msg_cost_per_block: Option<u64>,
1551
1552 ecdsa_k1_decompress_pubkey_cost_base: Option<u64>,
1554
1555 ecdsa_k1_secp256k1_verify_keccak256_cost_base: Option<u64>,
1557 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_byte: Option<u64>,
1558 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_block: Option<u64>,
1559 ecdsa_k1_secp256k1_verify_sha256_cost_base: Option<u64>,
1560 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_byte: Option<u64>,
1561 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_block: Option<u64>,
1562
1563 ecdsa_r1_ecrecover_keccak256_cost_base: Option<u64>,
1565 ecdsa_r1_ecrecover_keccak256_msg_cost_per_byte: Option<u64>,
1566 ecdsa_r1_ecrecover_keccak256_msg_cost_per_block: Option<u64>,
1567 ecdsa_r1_ecrecover_sha256_cost_base: Option<u64>,
1568 ecdsa_r1_ecrecover_sha256_msg_cost_per_byte: Option<u64>,
1569 ecdsa_r1_ecrecover_sha256_msg_cost_per_block: Option<u64>,
1570
1571 ecdsa_r1_secp256r1_verify_keccak256_cost_base: Option<u64>,
1573 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_byte: Option<u64>,
1574 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_block: Option<u64>,
1575 ecdsa_r1_secp256r1_verify_sha256_cost_base: Option<u64>,
1576 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_byte: Option<u64>,
1577 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_block: Option<u64>,
1578
1579 ecvrf_ecvrf_verify_cost_base: Option<u64>,
1581 ecvrf_ecvrf_verify_alpha_string_cost_per_byte: Option<u64>,
1582 ecvrf_ecvrf_verify_alpha_string_cost_per_block: Option<u64>,
1583
1584 ed25519_ed25519_verify_cost_base: Option<u64>,
1586 ed25519_ed25519_verify_msg_cost_per_byte: Option<u64>,
1587 ed25519_ed25519_verify_msg_cost_per_block: Option<u64>,
1588
1589 groth16_prepare_verifying_key_bls12381_cost_base: Option<u64>,
1591 groth16_prepare_verifying_key_bn254_cost_base: Option<u64>,
1592
1593 groth16_verify_groth16_proof_internal_bls12381_cost_base: Option<u64>,
1595 groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input: Option<u64>,
1596 groth16_verify_groth16_proof_internal_bn254_cost_base: Option<u64>,
1597 groth16_verify_groth16_proof_internal_bn254_cost_per_public_input: Option<u64>,
1598 groth16_verify_groth16_proof_internal_public_input_cost_per_byte: Option<u64>,
1599
1600 hash_blake2b256_cost_base: Option<u64>,
1602 hash_blake2b256_data_cost_per_byte: Option<u64>,
1603 hash_blake2b256_data_cost_per_block: Option<u64>,
1604
1605 hash_keccak256_cost_base: Option<u64>,
1607 hash_keccak256_data_cost_per_byte: Option<u64>,
1608 hash_keccak256_data_cost_per_block: Option<u64>,
1609
1610 poseidon_bn254_cost_base: Option<u64>,
1612 poseidon_bn254_cost_per_block: Option<u64>,
1613
1614 group_ops_bls12381_decode_scalar_cost: Option<u64>,
1616 group_ops_bls12381_decode_g1_cost: Option<u64>,
1617 group_ops_bls12381_decode_g2_cost: Option<u64>,
1618 group_ops_bls12381_decode_gt_cost: Option<u64>,
1619 group_ops_bls12381_scalar_add_cost: Option<u64>,
1620 group_ops_bls12381_g1_add_cost: Option<u64>,
1621 group_ops_bls12381_g2_add_cost: Option<u64>,
1622 group_ops_bls12381_gt_add_cost: Option<u64>,
1623 group_ops_bls12381_scalar_sub_cost: Option<u64>,
1624 group_ops_bls12381_g1_sub_cost: Option<u64>,
1625 group_ops_bls12381_g2_sub_cost: Option<u64>,
1626 group_ops_bls12381_gt_sub_cost: Option<u64>,
1627 group_ops_bls12381_scalar_mul_cost: Option<u64>,
1628 group_ops_bls12381_g1_mul_cost: Option<u64>,
1629 group_ops_bls12381_g2_mul_cost: Option<u64>,
1630 group_ops_bls12381_gt_mul_cost: Option<u64>,
1631 group_ops_bls12381_scalar_div_cost: Option<u64>,
1632 group_ops_bls12381_g1_div_cost: Option<u64>,
1633 group_ops_bls12381_g2_div_cost: Option<u64>,
1634 group_ops_bls12381_gt_div_cost: Option<u64>,
1635 group_ops_bls12381_g1_hash_to_base_cost: Option<u64>,
1636 group_ops_bls12381_g2_hash_to_base_cost: Option<u64>,
1637 group_ops_bls12381_g1_hash_to_cost_per_byte: Option<u64>,
1638 group_ops_bls12381_g2_hash_to_cost_per_byte: Option<u64>,
1639 group_ops_bls12381_g1_msm_base_cost: Option<u64>,
1640 group_ops_bls12381_g2_msm_base_cost: Option<u64>,
1641 group_ops_bls12381_g1_msm_base_cost_per_input: Option<u64>,
1642 group_ops_bls12381_g2_msm_base_cost_per_input: Option<u64>,
1643 group_ops_bls12381_msm_max_len: Option<u32>,
1644 group_ops_bls12381_pairing_cost: Option<u64>,
1645 group_ops_bls12381_g1_to_uncompressed_g1_cost: Option<u64>,
1646 group_ops_bls12381_uncompressed_g1_to_g1_cost: Option<u64>,
1647 group_ops_bls12381_uncompressed_g1_sum_base_cost: Option<u64>,
1648 group_ops_bls12381_uncompressed_g1_sum_cost_per_term: Option<u64>,
1649 group_ops_bls12381_uncompressed_g1_sum_max_terms: Option<u64>,
1650
1651 group_ops_ristretto_decode_scalar_cost: Option<u64>,
1652 group_ops_ristretto_decode_point_cost: Option<u64>,
1653 group_ops_ristretto_scalar_add_cost: Option<u64>,
1654 group_ops_ristretto_point_add_cost: Option<u64>,
1655 group_ops_ristretto_scalar_sub_cost: Option<u64>,
1656 group_ops_ristretto_point_sub_cost: Option<u64>,
1657 group_ops_ristretto_scalar_mul_cost: Option<u64>,
1658 group_ops_ristretto_point_mul_cost: Option<u64>,
1659 group_ops_ristretto_scalar_div_cost: Option<u64>,
1660 group_ops_ristretto_point_div_cost: Option<u64>,
1661
1662 hmac_hmac_sha3_256_cost_base: Option<u64>,
1664 hmac_hmac_sha3_256_input_cost_per_byte: Option<u64>,
1665 hmac_hmac_sha3_256_input_cost_per_block: Option<u64>,
1666
1667 check_zklogin_id_cost_base: Option<u64>,
1669 check_zklogin_issuer_cost_base: Option<u64>,
1671
1672 vdf_verify_vdf_cost: Option<u64>,
1673 vdf_hash_to_input_cost: Option<u64>,
1674
1675 nitro_attestation_parse_base_cost: Option<u64>,
1677 nitro_attestation_parse_cost_per_byte: Option<u64>,
1678 nitro_attestation_verify_base_cost: Option<u64>,
1679 nitro_attestation_verify_cost_per_cert: Option<u64>,
1680
1681 bcs_per_byte_serialized_cost: Option<u64>,
1683 bcs_legacy_min_output_size_cost: Option<u64>,
1684 bcs_failure_cost: Option<u64>,
1685
1686 hash_sha2_256_base_cost: Option<u64>,
1687 hash_sha2_256_per_byte_cost: Option<u64>,
1688 hash_sha2_256_legacy_min_input_len_cost: Option<u64>,
1689 hash_sha3_256_base_cost: Option<u64>,
1690 hash_sha3_256_per_byte_cost: Option<u64>,
1691 hash_sha3_256_legacy_min_input_len_cost: Option<u64>,
1692 type_name_get_base_cost: Option<u64>,
1693 type_name_get_per_byte_cost: Option<u64>,
1694 type_name_id_base_cost: Option<u64>,
1695
1696 string_check_utf8_base_cost: Option<u64>,
1697 string_check_utf8_per_byte_cost: Option<u64>,
1698 string_is_char_boundary_base_cost: Option<u64>,
1699 string_sub_string_base_cost: Option<u64>,
1700 string_sub_string_per_byte_cost: Option<u64>,
1701 string_index_of_base_cost: Option<u64>,
1702 string_index_of_per_byte_pattern_cost: Option<u64>,
1703 string_index_of_per_byte_searched_cost: Option<u64>,
1704
1705 vector_empty_base_cost: Option<u64>,
1706 vector_length_base_cost: Option<u64>,
1707 vector_push_back_base_cost: Option<u64>,
1708 vector_push_back_legacy_per_abstract_memory_unit_cost: Option<u64>,
1709 vector_borrow_base_cost: Option<u64>,
1710 vector_pop_back_base_cost: Option<u64>,
1711 vector_destroy_empty_base_cost: Option<u64>,
1712 vector_swap_base_cost: Option<u64>,
1713 debug_print_base_cost: Option<u64>,
1714 debug_print_stack_trace_base_cost: Option<u64>,
1715
1716 execution_version: Option<u64>,
1725
1726 consensus_bad_nodes_stake_threshold: Option<u64>,
1730
1731 max_jwk_votes_per_validator_per_epoch: Option<u64>,
1732 max_age_of_jwk_in_epochs: Option<u64>,
1736
1737 random_beacon_reduction_allowed_delta: Option<u16>,
1741
1742 random_beacon_reduction_lower_bound: Option<u32>,
1745
1746 random_beacon_dkg_timeout_round: Option<u32>,
1749
1750 random_beacon_min_round_interval_ms: Option<u64>,
1752
1753 random_beacon_dkg_version: Option<u64>,
1756
1757 consensus_max_transaction_size_bytes: Option<u64>,
1760 consensus_max_transactions_in_block_bytes: Option<u64>,
1762 consensus_max_num_transactions_in_block: Option<u64>,
1764
1765 consensus_voting_rounds: Option<u32>,
1767
1768 max_accumulated_txn_cost_per_object_in_narwhal_commit: Option<u64>,
1770
1771 max_deferral_rounds_for_congestion_control: Option<u64>,
1774
1775 max_txn_cost_overage_per_object_in_commit: Option<u64>,
1777
1778 allowed_txn_cost_overage_burst_per_object_in_commit: Option<u64>,
1780
1781 min_checkpoint_interval_ms: Option<u64>,
1783
1784 checkpoint_summary_version_specific_data: Option<u64>,
1786
1787 max_soft_bundle_size: Option<u64>,
1789
1790 bridge_should_try_to_finalize_committee: Option<bool>,
1794
1795 max_accumulated_txn_cost_per_object_in_mysticeti_commit: Option<u64>,
1801
1802 max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit: Option<u64>,
1805
1806 consensus_gc_depth: Option<u32>,
1809
1810 gas_budget_based_txn_cost_cap_factor: Option<u64>,
1812
1813 gas_budget_based_txn_cost_absolute_cap_commit_count: Option<u64>,
1815
1816 sip_45_consensus_amplification_threshold: Option<u64>,
1819
1820 use_object_per_epoch_marker_table_v2: Option<bool>,
1823
1824 consensus_commit_rate_estimation_window_size: Option<u32>,
1826
1827 #[serde(skip_serializing_if = "Vec::is_empty")]
1831 aliased_addresses: Vec<AliasedAddress>,
1832
1833 translation_per_command_base_charge: Option<u64>,
1836
1837 translation_per_input_base_charge: Option<u64>,
1840
1841 translation_pure_input_per_byte_charge: Option<u64>,
1843
1844 translation_per_type_node_charge: Option<u64>,
1848
1849 translation_per_reference_node_charge: Option<u64>,
1852
1853 translation_per_linkage_entry_charge: Option<u64>,
1856
1857 max_updates_per_settlement_txn: Option<u32>,
1859}
1860
1861#[derive(Clone, Serialize, Deserialize, Debug)]
1863pub struct AliasedAddress {
1864 pub original: [u8; 32],
1866 pub aliased: [u8; 32],
1868 pub allowed_tx_digests: Vec<[u8; 32]>,
1870}
1871
1872impl ProtocolConfig {
1874 pub fn check_package_upgrades_supported(&self) -> Result<(), Error> {
1887 if self.feature_flags.package_upgrades {
1888 Ok(())
1889 } else {
1890 Err(Error(format!(
1891 "package upgrades are not supported at {:?}",
1892 self.version
1893 )))
1894 }
1895 }
1896
1897 pub fn allow_receiving_object_id(&self) -> bool {
1898 self.feature_flags.allow_receiving_object_id
1899 }
1900
1901 pub fn receiving_objects_supported(&self) -> bool {
1902 self.feature_flags.receive_objects
1903 }
1904
1905 pub fn package_upgrades_supported(&self) -> bool {
1906 self.feature_flags.package_upgrades
1907 }
1908
1909 pub fn check_commit_root_state_digest_supported(&self) -> bool {
1910 self.feature_flags.commit_root_state_digest
1911 }
1912
1913 pub fn get_advance_epoch_start_time_in_safe_mode(&self) -> bool {
1914 self.feature_flags.advance_epoch_start_time_in_safe_mode
1915 }
1916
1917 pub fn loaded_child_objects_fixed(&self) -> bool {
1918 self.feature_flags.loaded_child_objects_fixed
1919 }
1920
1921 pub fn missing_type_is_compatibility_error(&self) -> bool {
1922 self.feature_flags.missing_type_is_compatibility_error
1923 }
1924
1925 pub fn scoring_decision_with_validity_cutoff(&self) -> bool {
1926 self.feature_flags.scoring_decision_with_validity_cutoff
1927 }
1928
1929 pub fn narwhal_versioned_metadata(&self) -> bool {
1930 self.feature_flags.narwhal_versioned_metadata
1931 }
1932
1933 pub fn consensus_order_end_of_epoch_last(&self) -> bool {
1934 self.feature_flags.consensus_order_end_of_epoch_last
1935 }
1936
1937 pub fn disallow_adding_abilities_on_upgrade(&self) -> bool {
1938 self.feature_flags.disallow_adding_abilities_on_upgrade
1939 }
1940
1941 pub fn disable_invariant_violation_check_in_swap_loc(&self) -> bool {
1942 self.feature_flags
1943 .disable_invariant_violation_check_in_swap_loc
1944 }
1945
1946 pub fn advance_to_highest_supported_protocol_version(&self) -> bool {
1947 self.feature_flags
1948 .advance_to_highest_supported_protocol_version
1949 }
1950
1951 pub fn ban_entry_init(&self) -> bool {
1952 self.feature_flags.ban_entry_init
1953 }
1954
1955 pub fn package_digest_hash_module(&self) -> bool {
1956 self.feature_flags.package_digest_hash_module
1957 }
1958
1959 pub fn disallow_change_struct_type_params_on_upgrade(&self) -> bool {
1960 self.feature_flags
1961 .disallow_change_struct_type_params_on_upgrade
1962 }
1963
1964 pub fn no_extraneous_module_bytes(&self) -> bool {
1965 self.feature_flags.no_extraneous_module_bytes
1966 }
1967
1968 pub fn zklogin_auth(&self) -> bool {
1969 self.feature_flags.zklogin_auth
1970 }
1971
1972 pub fn zklogin_supported_providers(&self) -> &BTreeSet<String> {
1973 &self.feature_flags.zklogin_supported_providers
1974 }
1975
1976 pub fn consensus_transaction_ordering(&self) -> ConsensusTransactionOrdering {
1977 self.feature_flags.consensus_transaction_ordering
1978 }
1979
1980 pub fn simplified_unwrap_then_delete(&self) -> bool {
1981 self.feature_flags.simplified_unwrap_then_delete
1982 }
1983
1984 pub fn supports_upgraded_multisig(&self) -> bool {
1985 self.feature_flags.upgraded_multisig_supported
1986 }
1987
1988 pub fn txn_base_cost_as_multiplier(&self) -> bool {
1989 self.feature_flags.txn_base_cost_as_multiplier
1990 }
1991
1992 pub fn shared_object_deletion(&self) -> bool {
1993 self.feature_flags.shared_object_deletion
1994 }
1995
1996 pub fn narwhal_new_leader_election_schedule(&self) -> bool {
1997 self.feature_flags.narwhal_new_leader_election_schedule
1998 }
1999
2000 pub fn loaded_child_object_format(&self) -> bool {
2001 self.feature_flags.loaded_child_object_format
2002 }
2003
2004 pub fn enable_jwk_consensus_updates(&self) -> bool {
2005 let ret = self.feature_flags.enable_jwk_consensus_updates;
2006 if ret {
2007 assert!(self.feature_flags.end_of_epoch_transaction_supported);
2009 }
2010 ret
2011 }
2012
2013 pub fn simple_conservation_checks(&self) -> bool {
2014 self.feature_flags.simple_conservation_checks
2015 }
2016
2017 pub fn loaded_child_object_format_type(&self) -> bool {
2018 self.feature_flags.loaded_child_object_format_type
2019 }
2020
2021 pub fn end_of_epoch_transaction_supported(&self) -> bool {
2022 let ret = self.feature_flags.end_of_epoch_transaction_supported;
2023 if !ret {
2024 assert!(!self.feature_flags.enable_jwk_consensus_updates);
2026 }
2027 ret
2028 }
2029
2030 pub fn recompute_has_public_transfer_in_execution(&self) -> bool {
2031 self.feature_flags
2032 .recompute_has_public_transfer_in_execution
2033 }
2034
2035 pub fn create_authenticator_state_in_genesis(&self) -> bool {
2037 self.enable_jwk_consensus_updates()
2038 }
2039
2040 pub fn random_beacon(&self) -> bool {
2041 self.feature_flags.random_beacon
2042 }
2043
2044 pub fn dkg_version(&self) -> u64 {
2045 self.random_beacon_dkg_version.unwrap_or(1)
2047 }
2048
2049 pub fn enable_bridge(&self) -> bool {
2050 let ret = self.feature_flags.bridge;
2051 if ret {
2052 assert!(self.feature_flags.end_of_epoch_transaction_supported);
2054 }
2055 ret
2056 }
2057
2058 pub fn should_try_to_finalize_bridge_committee(&self) -> bool {
2059 if !self.enable_bridge() {
2060 return false;
2061 }
2062 self.bridge_should_try_to_finalize_committee.unwrap_or(true)
2064 }
2065
2066 pub fn enable_effects_v2(&self) -> bool {
2067 self.feature_flags.enable_effects_v2
2068 }
2069
2070 pub fn narwhal_certificate_v2(&self) -> bool {
2071 self.feature_flags.narwhal_certificate_v2
2072 }
2073
2074 pub fn verify_legacy_zklogin_address(&self) -> bool {
2075 self.feature_flags.verify_legacy_zklogin_address
2076 }
2077
2078 pub fn accept_zklogin_in_multisig(&self) -> bool {
2079 self.feature_flags.accept_zklogin_in_multisig
2080 }
2081
2082 pub fn accept_passkey_in_multisig(&self) -> bool {
2083 self.feature_flags.accept_passkey_in_multisig
2084 }
2085
2086 pub fn validate_zklogin_public_identifier(&self) -> bool {
2087 self.feature_flags.validate_zklogin_public_identifier
2088 }
2089
2090 pub fn zklogin_max_epoch_upper_bound_delta(&self) -> Option<u64> {
2091 self.feature_flags.zklogin_max_epoch_upper_bound_delta
2092 }
2093
2094 pub fn throughput_aware_consensus_submission(&self) -> bool {
2095 self.feature_flags.throughput_aware_consensus_submission
2096 }
2097
2098 pub fn include_consensus_digest_in_prologue(&self) -> bool {
2099 self.feature_flags.include_consensus_digest_in_prologue
2100 }
2101
2102 pub fn record_consensus_determined_version_assignments_in_prologue(&self) -> bool {
2103 self.feature_flags
2104 .record_consensus_determined_version_assignments_in_prologue
2105 }
2106
2107 pub fn record_additional_state_digest_in_prologue(&self) -> bool {
2108 self.feature_flags
2109 .record_additional_state_digest_in_prologue
2110 }
2111
2112 pub fn record_consensus_determined_version_assignments_in_prologue_v2(&self) -> bool {
2113 self.feature_flags
2114 .record_consensus_determined_version_assignments_in_prologue_v2
2115 }
2116
2117 pub fn prepend_prologue_tx_in_consensus_commit_in_checkpoints(&self) -> bool {
2118 self.feature_flags
2119 .prepend_prologue_tx_in_consensus_commit_in_checkpoints
2120 }
2121
2122 pub fn hardened_otw_check(&self) -> bool {
2123 self.feature_flags.hardened_otw_check
2124 }
2125
2126 pub fn enable_poseidon(&self) -> bool {
2127 self.feature_flags.enable_poseidon
2128 }
2129
2130 pub fn enable_coin_deny_list_v1(&self) -> bool {
2131 self.feature_flags.enable_coin_deny_list
2132 }
2133
2134 pub fn enable_accumulators(&self) -> bool {
2135 self.feature_flags.enable_accumulators
2136 }
2137
2138 pub fn enable_coin_reservation_obj_refs(&self) -> bool {
2139 self.feature_flags.enable_coin_reservation_obj_refs
2140 }
2141
2142 pub fn create_root_accumulator_object(&self) -> bool {
2143 self.feature_flags.create_root_accumulator_object
2144 }
2145
2146 pub fn enable_address_balance_gas_payments(&self) -> bool {
2147 self.feature_flags.enable_address_balance_gas_payments
2148 }
2149
2150 pub fn enable_multi_epoch_transaction_expiration(&self) -> bool {
2151 self.feature_flags.enable_multi_epoch_transaction_expiration
2152 }
2153
2154 pub fn enable_authenticated_event_streams(&self) -> bool {
2155 self.feature_flags.enable_authenticated_event_streams && self.enable_accumulators()
2156 }
2157
2158 pub fn enable_non_exclusive_writes(&self) -> bool {
2159 self.feature_flags.enable_non_exclusive_writes
2160 }
2161
2162 pub fn enable_coin_registry(&self) -> bool {
2163 self.feature_flags.enable_coin_registry
2164 }
2165
2166 pub fn enable_display_registry(&self) -> bool {
2167 self.feature_flags.enable_display_registry
2168 }
2169
2170 pub fn enable_coin_deny_list_v2(&self) -> bool {
2171 self.feature_flags.enable_coin_deny_list_v2
2172 }
2173
2174 pub fn enable_group_ops_native_functions(&self) -> bool {
2175 self.feature_flags.enable_group_ops_native_functions
2176 }
2177
2178 pub fn enable_group_ops_native_function_msm(&self) -> bool {
2179 self.feature_flags.enable_group_ops_native_function_msm
2180 }
2181
2182 pub fn enable_ristretto255_group_ops(&self) -> bool {
2183 self.feature_flags.enable_ristretto255_group_ops
2184 }
2185
2186 pub fn reject_mutable_random_on_entry_functions(&self) -> bool {
2187 self.feature_flags.reject_mutable_random_on_entry_functions
2188 }
2189
2190 pub fn per_object_congestion_control_mode(&self) -> PerObjectCongestionControlMode {
2191 self.feature_flags.per_object_congestion_control_mode
2192 }
2193
2194 pub fn consensus_choice(&self) -> ConsensusChoice {
2195 self.feature_flags.consensus_choice
2196 }
2197
2198 pub fn consensus_network(&self) -> ConsensusNetwork {
2199 self.feature_flags.consensus_network
2200 }
2201
2202 pub fn correct_gas_payment_limit_check(&self) -> bool {
2203 self.feature_flags.correct_gas_payment_limit_check
2204 }
2205
2206 pub fn reshare_at_same_initial_version(&self) -> bool {
2207 self.feature_flags.reshare_at_same_initial_version
2208 }
2209
2210 pub fn resolve_abort_locations_to_package_id(&self) -> bool {
2211 self.feature_flags.resolve_abort_locations_to_package_id
2212 }
2213
2214 pub fn mysticeti_use_committed_subdag_digest(&self) -> bool {
2215 self.feature_flags.mysticeti_use_committed_subdag_digest
2216 }
2217
2218 pub fn enable_vdf(&self) -> bool {
2219 self.feature_flags.enable_vdf
2220 }
2221
2222 pub fn fresh_vm_on_framework_upgrade(&self) -> bool {
2223 self.feature_flags.fresh_vm_on_framework_upgrade
2224 }
2225
2226 pub fn mysticeti_num_leaders_per_round(&self) -> Option<usize> {
2227 self.feature_flags.mysticeti_num_leaders_per_round
2228 }
2229
2230 pub fn soft_bundle(&self) -> bool {
2231 self.feature_flags.soft_bundle
2232 }
2233
2234 pub fn passkey_auth(&self) -> bool {
2235 self.feature_flags.passkey_auth
2236 }
2237
2238 pub fn authority_capabilities_v2(&self) -> bool {
2239 self.feature_flags.authority_capabilities_v2
2240 }
2241
2242 pub fn max_transaction_size_bytes(&self) -> u64 {
2243 self.consensus_max_transaction_size_bytes
2245 .unwrap_or(256 * 1024)
2246 }
2247
2248 pub fn max_transactions_in_block_bytes(&self) -> u64 {
2249 if cfg!(msim) {
2250 256 * 1024
2251 } else {
2252 self.consensus_max_transactions_in_block_bytes
2253 .unwrap_or(512 * 1024)
2254 }
2255 }
2256
2257 pub fn max_num_transactions_in_block(&self) -> u64 {
2258 if cfg!(msim) {
2259 8
2260 } else {
2261 self.consensus_max_num_transactions_in_block.unwrap_or(512)
2262 }
2263 }
2264
2265 pub fn rethrow_serialization_type_layout_errors(&self) -> bool {
2266 self.feature_flags.rethrow_serialization_type_layout_errors
2267 }
2268
2269 pub fn consensus_distributed_vote_scoring_strategy(&self) -> bool {
2270 self.feature_flags
2271 .consensus_distributed_vote_scoring_strategy
2272 }
2273
2274 pub fn consensus_round_prober(&self) -> bool {
2275 self.feature_flags.consensus_round_prober
2276 }
2277
2278 pub fn validate_identifier_inputs(&self) -> bool {
2279 self.feature_flags.validate_identifier_inputs
2280 }
2281
2282 pub fn gc_depth(&self) -> u32 {
2283 self.consensus_gc_depth.unwrap_or(0)
2284 }
2285
2286 pub fn mysticeti_fastpath(&self) -> bool {
2287 self.feature_flags.mysticeti_fastpath
2288 }
2289
2290 pub fn relocate_event_module(&self) -> bool {
2291 self.feature_flags.relocate_event_module
2292 }
2293
2294 pub fn uncompressed_g1_group_elements(&self) -> bool {
2295 self.feature_flags.uncompressed_g1_group_elements
2296 }
2297
2298 pub fn disallow_new_modules_in_deps_only_packages(&self) -> bool {
2299 self.feature_flags
2300 .disallow_new_modules_in_deps_only_packages
2301 }
2302
2303 pub fn consensus_smart_ancestor_selection(&self) -> bool {
2304 self.feature_flags.consensus_smart_ancestor_selection
2305 }
2306
2307 pub fn disable_preconsensus_locking(&self) -> bool {
2308 self.feature_flags.disable_preconsensus_locking
2309 }
2310
2311 pub fn consensus_round_prober_probe_accepted_rounds(&self) -> bool {
2312 self.feature_flags
2313 .consensus_round_prober_probe_accepted_rounds
2314 }
2315
2316 pub fn native_charging_v2(&self) -> bool {
2317 self.feature_flags.native_charging_v2
2318 }
2319
2320 pub fn consensus_linearize_subdag_v2(&self) -> bool {
2321 let res = self.feature_flags.consensus_linearize_subdag_v2;
2322 assert!(
2323 !res || self.gc_depth() > 0,
2324 "The consensus linearize sub dag V2 requires GC to be enabled"
2325 );
2326 res
2327 }
2328
2329 pub fn consensus_median_based_commit_timestamp(&self) -> bool {
2330 let res = self.feature_flags.consensus_median_based_commit_timestamp;
2331 assert!(
2332 !res || self.gc_depth() > 0,
2333 "The consensus median based commit timestamp requires GC to be enabled"
2334 );
2335 res
2336 }
2337
2338 pub fn consensus_batched_block_sync(&self) -> bool {
2339 self.feature_flags.consensus_batched_block_sync
2340 }
2341
2342 pub fn convert_type_argument_error(&self) -> bool {
2343 self.feature_flags.convert_type_argument_error
2344 }
2345
2346 pub fn variant_nodes(&self) -> bool {
2347 self.feature_flags.variant_nodes
2348 }
2349
2350 pub fn consensus_zstd_compression(&self) -> bool {
2351 self.feature_flags.consensus_zstd_compression
2352 }
2353
2354 pub fn enable_nitro_attestation(&self) -> bool {
2355 self.feature_flags.enable_nitro_attestation
2356 }
2357
2358 pub fn enable_nitro_attestation_upgraded_parsing(&self) -> bool {
2359 self.feature_flags.enable_nitro_attestation_upgraded_parsing
2360 }
2361
2362 pub fn enable_nitro_attestation_all_nonzero_pcrs_parsing(&self) -> bool {
2363 self.feature_flags
2364 .enable_nitro_attestation_all_nonzero_pcrs_parsing
2365 }
2366
2367 pub fn enable_nitro_attestation_always_include_required_pcrs_parsing(&self) -> bool {
2368 self.feature_flags
2369 .enable_nitro_attestation_always_include_required_pcrs_parsing
2370 }
2371
2372 pub fn get_consensus_commit_rate_estimation_window_size(&self) -> u32 {
2373 self.consensus_commit_rate_estimation_window_size
2374 .unwrap_or(0)
2375 }
2376
2377 pub fn consensus_num_requested_prior_commits_at_startup(&self) -> u32 {
2378 let window_size = self.get_consensus_commit_rate_estimation_window_size();
2382 assert!(window_size == 0 || self.record_additional_state_digest_in_prologue());
2384 window_size
2385 }
2386
2387 pub fn minimize_child_object_mutations(&self) -> bool {
2388 self.feature_flags.minimize_child_object_mutations
2389 }
2390
2391 pub fn move_native_context(&self) -> bool {
2392 self.feature_flags.move_native_context
2393 }
2394
2395 pub fn normalize_ptb_arguments(&self) -> bool {
2396 self.feature_flags.normalize_ptb_arguments
2397 }
2398
2399 pub fn enforce_checkpoint_timestamp_monotonicity(&self) -> bool {
2400 self.feature_flags.enforce_checkpoint_timestamp_monotonicity
2401 }
2402
2403 pub fn max_ptb_value_size_v2(&self) -> bool {
2404 self.feature_flags.max_ptb_value_size_v2
2405 }
2406
2407 pub fn resolve_type_input_ids_to_defining_id(&self) -> bool {
2408 self.feature_flags.resolve_type_input_ids_to_defining_id
2409 }
2410
2411 pub fn enable_party_transfer(&self) -> bool {
2412 self.feature_flags.enable_party_transfer
2413 }
2414
2415 pub fn allow_unbounded_system_objects(&self) -> bool {
2416 self.feature_flags.allow_unbounded_system_objects
2417 }
2418
2419 pub fn type_tags_in_object_runtime(&self) -> bool {
2420 self.feature_flags.type_tags_in_object_runtime
2421 }
2422
2423 pub fn enable_ptb_execution_v2(&self) -> bool {
2424 self.feature_flags.enable_ptb_execution_v2
2425 }
2426
2427 pub fn better_adapter_type_resolution_errors(&self) -> bool {
2428 self.feature_flags.better_adapter_type_resolution_errors
2429 }
2430
2431 pub fn record_time_estimate_processed(&self) -> bool {
2432 self.feature_flags.record_time_estimate_processed
2433 }
2434
2435 pub fn ignore_execution_time_observations_after_certs_closed(&self) -> bool {
2436 self.feature_flags
2437 .ignore_execution_time_observations_after_certs_closed
2438 }
2439
2440 pub fn dependency_linkage_error(&self) -> bool {
2441 self.feature_flags.dependency_linkage_error
2442 }
2443
2444 pub fn additional_multisig_checks(&self) -> bool {
2445 self.feature_flags.additional_multisig_checks
2446 }
2447
2448 pub fn debug_fatal_on_move_invariant_violation(&self) -> bool {
2449 self.feature_flags.debug_fatal_on_move_invariant_violation
2450 }
2451
2452 pub fn allow_private_accumulator_entrypoints(&self) -> bool {
2453 self.feature_flags.allow_private_accumulator_entrypoints
2454 }
2455
2456 pub fn additional_consensus_digest_indirect_state(&self) -> bool {
2457 self.feature_flags
2458 .additional_consensus_digest_indirect_state
2459 }
2460
2461 pub fn check_for_init_during_upgrade(&self) -> bool {
2462 self.feature_flags.check_for_init_during_upgrade
2463 }
2464
2465 pub fn per_command_shared_object_transfer_rules(&self) -> bool {
2466 self.feature_flags.per_command_shared_object_transfer_rules
2467 }
2468
2469 pub fn consensus_checkpoint_signature_key_includes_digest(&self) -> bool {
2470 self.feature_flags
2471 .consensus_checkpoint_signature_key_includes_digest
2472 }
2473
2474 pub fn include_checkpoint_artifacts_digest_in_summary(&self) -> bool {
2475 self.feature_flags
2476 .include_checkpoint_artifacts_digest_in_summary
2477 }
2478
2479 pub fn use_mfp_txns_in_load_initial_object_debts(&self) -> bool {
2480 self.feature_flags.use_mfp_txns_in_load_initial_object_debts
2481 }
2482
2483 pub fn cancel_for_failed_dkg_early(&self) -> bool {
2484 self.feature_flags.cancel_for_failed_dkg_early
2485 }
2486
2487 pub fn abstract_size_in_object_runtime(&self) -> bool {
2488 self.feature_flags.abstract_size_in_object_runtime
2489 }
2490
2491 pub fn object_runtime_charge_cache_load_gas(&self) -> bool {
2492 self.feature_flags.object_runtime_charge_cache_load_gas
2493 }
2494
2495 pub fn additional_borrow_checks(&self) -> bool {
2496 self.feature_flags.additional_borrow_checks
2497 }
2498
2499 pub fn use_new_commit_handler(&self) -> bool {
2500 self.feature_flags.use_new_commit_handler
2501 }
2502
2503 pub fn better_loader_errors(&self) -> bool {
2504 self.feature_flags.better_loader_errors
2505 }
2506
2507 pub fn generate_df_type_layouts(&self) -> bool {
2508 self.feature_flags.generate_df_type_layouts
2509 }
2510
2511 pub fn allow_references_in_ptbs(&self) -> bool {
2512 self.feature_flags.allow_references_in_ptbs
2513 }
2514
2515 pub fn private_generics_verifier_v2(&self) -> bool {
2516 self.feature_flags.private_generics_verifier_v2
2517 }
2518
2519 pub fn deprecate_global_storage_ops_during_deserialization(&self) -> bool {
2520 self.feature_flags
2521 .deprecate_global_storage_ops_during_deserialization
2522 }
2523
2524 pub fn enable_observation_chunking(&self) -> bool {
2525 matches!(self.feature_flags.per_object_congestion_control_mode,
2526 PerObjectCongestionControlMode::ExecutionTimeEstimate(ref params)
2527 if params.observations_chunk_size.is_some()
2528 )
2529 }
2530
2531 pub fn deprecate_global_storage_ops(&self) -> bool {
2532 self.feature_flags.deprecate_global_storage_ops
2533 }
2534
2535 pub fn consensus_skip_gced_accept_votes(&self) -> bool {
2536 self.feature_flags.consensus_skip_gced_accept_votes
2537 }
2538
2539 pub fn include_cancelled_randomness_txns_in_prologue(&self) -> bool {
2540 self.feature_flags
2541 .include_cancelled_randomness_txns_in_prologue
2542 }
2543
2544 pub fn address_aliases(&self) -> bool {
2545 let address_aliases = self.feature_flags.address_aliases;
2546 assert!(
2547 !address_aliases || self.mysticeti_fastpath(),
2548 "Address aliases requires Mysticeti fastpath to be enabled"
2549 );
2550 if address_aliases {
2551 assert!(
2552 self.feature_flags.disable_preconsensus_locking,
2553 "Address aliases requires CertifiedTransaction to be disabled"
2554 );
2555 }
2556 address_aliases
2557 }
2558
2559 pub fn fix_checkpoint_signature_mapping(&self) -> bool {
2560 self.feature_flags.fix_checkpoint_signature_mapping
2561 }
2562
2563 pub fn enable_object_funds_withdraw(&self) -> bool {
2564 self.feature_flags.enable_object_funds_withdraw
2565 }
2566
2567 pub fn gas_rounding_halve_digits(&self) -> bool {
2568 self.feature_flags.gas_rounding_halve_digits
2569 }
2570
2571 pub fn flexible_tx_context_positions(&self) -> bool {
2572 self.feature_flags.flexible_tx_context_positions
2573 }
2574
2575 pub fn disable_entry_point_signature_check(&self) -> bool {
2576 self.feature_flags.disable_entry_point_signature_check
2577 }
2578
2579 pub fn consensus_skip_gced_blocks_in_direct_finalization(&self) -> bool {
2580 self.feature_flags
2581 .consensus_skip_gced_blocks_in_direct_finalization
2582 }
2583
2584 pub fn convert_withdrawal_compatibility_ptb_arguments(&self) -> bool {
2585 self.feature_flags
2586 .convert_withdrawal_compatibility_ptb_arguments
2587 }
2588
2589 pub fn restrict_hot_or_not_entry_functions(&self) -> bool {
2590 self.feature_flags.restrict_hot_or_not_entry_functions
2591 }
2592
2593 pub fn split_checkpoints_in_consensus_handler(&self) -> bool {
2594 self.feature_flags.split_checkpoints_in_consensus_handler
2595 }
2596
2597 pub fn consensus_always_accept_system_transactions(&self) -> bool {
2598 self.feature_flags
2599 .consensus_always_accept_system_transactions
2600 }
2601
2602 pub fn validator_metadata_verify_v2(&self) -> bool {
2603 self.feature_flags.validator_metadata_verify_v2
2604 }
2605}
2606
2607#[cfg(not(msim))]
2608static POISON_VERSION_METHODS: AtomicBool = AtomicBool::new(false);
2609
2610#[cfg(msim)]
2612thread_local! {
2613 static POISON_VERSION_METHODS: AtomicBool = AtomicBool::new(false);
2614}
2615
2616impl ProtocolConfig {
2618 pub fn get_for_version(version: ProtocolVersion, chain: Chain) -> Self {
2620 assert!(
2622 version >= ProtocolVersion::MIN,
2623 "Network protocol version is {:?}, but the minimum supported version by the binary is {:?}. Please upgrade the binary.",
2624 version,
2625 ProtocolVersion::MIN.0,
2626 );
2627 assert!(
2628 version <= ProtocolVersion::MAX_ALLOWED,
2629 "Network protocol version is {:?}, but the maximum supported version by the binary is {:?}. Please upgrade the binary.",
2630 version,
2631 ProtocolVersion::MAX_ALLOWED.0,
2632 );
2633
2634 let mut ret = Self::get_for_version_impl(version, chain);
2635 ret.version = version;
2636
2637 ret = CONFIG_OVERRIDE.with(|ovr| {
2638 if let Some(override_fn) = &*ovr.borrow() {
2639 warn!(
2640 "overriding ProtocolConfig settings with custom settings (you should not see this log outside of tests)"
2641 );
2642 override_fn(version, ret)
2643 } else {
2644 ret
2645 }
2646 });
2647
2648 if std::env::var("SUI_PROTOCOL_CONFIG_OVERRIDE_ENABLE").is_ok() {
2649 warn!(
2650 "overriding ProtocolConfig settings with custom settings; this may break non-local networks"
2651 );
2652 let overrides: ProtocolConfigOptional =
2653 serde_env::from_env_with_prefix("SUI_PROTOCOL_CONFIG_OVERRIDE")
2654 .expect("failed to parse ProtocolConfig override env variables");
2655 overrides.apply_to(&mut ret);
2656 }
2657
2658 ret
2659 }
2660
2661 pub fn get_for_version_if_supported(version: ProtocolVersion, chain: Chain) -> Option<Self> {
2664 if version.0 >= ProtocolVersion::MIN.0 && version.0 <= ProtocolVersion::MAX_ALLOWED.0 {
2665 let mut ret = Self::get_for_version_impl(version, chain);
2666 ret.version = version;
2667 Some(ret)
2668 } else {
2669 None
2670 }
2671 }
2672
2673 #[cfg(not(msim))]
2674 pub fn poison_get_for_min_version() {
2675 POISON_VERSION_METHODS.store(true, Ordering::Relaxed);
2676 }
2677
2678 #[cfg(not(msim))]
2679 fn load_poison_get_for_min_version() -> bool {
2680 POISON_VERSION_METHODS.load(Ordering::Relaxed)
2681 }
2682
2683 #[cfg(msim)]
2684 pub fn poison_get_for_min_version() {
2685 POISON_VERSION_METHODS.with(|p| p.store(true, Ordering::Relaxed));
2686 }
2687
2688 #[cfg(msim)]
2689 fn load_poison_get_for_min_version() -> bool {
2690 POISON_VERSION_METHODS.with(|p| p.load(Ordering::Relaxed))
2691 }
2692
2693 pub fn get_for_min_version() -> Self {
2696 if Self::load_poison_get_for_min_version() {
2697 panic!("get_for_min_version called on validator");
2698 }
2699 ProtocolConfig::get_for_version(ProtocolVersion::MIN, Chain::Unknown)
2700 }
2701
2702 #[allow(non_snake_case)]
2712 pub fn get_for_max_version_UNSAFE() -> Self {
2713 if Self::load_poison_get_for_min_version() {
2714 panic!("get_for_max_version_UNSAFE called on validator");
2715 }
2716 ProtocolConfig::get_for_version(ProtocolVersion::MAX, Chain::Unknown)
2717 }
2718
2719 fn get_for_version_impl(version: ProtocolVersion, chain: Chain) -> Self {
2720 #[cfg(msim)]
2721 {
2722 if version == ProtocolVersion::MAX_ALLOWED {
2724 let mut config = Self::get_for_version_impl(version - 1, Chain::Unknown);
2725 config.base_tx_cost_fixed = Some(config.base_tx_cost_fixed() + 1000);
2726 return config;
2727 }
2728 }
2729
2730 let mut cfg = Self {
2733 version,
2735
2736 feature_flags: Default::default(),
2738
2739 max_tx_size_bytes: Some(128 * 1024),
2740 max_input_objects: Some(2048),
2742 max_serialized_tx_effects_size_bytes: Some(512 * 1024),
2743 max_serialized_tx_effects_size_bytes_system_tx: Some(512 * 1024 * 16),
2744 max_gas_payment_objects: Some(256),
2745 max_modules_in_publish: Some(128),
2746 max_package_dependencies: None,
2747 max_arguments: Some(512),
2748 max_type_arguments: Some(16),
2749 max_type_argument_depth: Some(16),
2750 max_pure_argument_size: Some(16 * 1024),
2751 max_programmable_tx_commands: Some(1024),
2752 move_binary_format_version: Some(6),
2753 min_move_binary_format_version: None,
2754 binary_module_handles: None,
2755 binary_struct_handles: None,
2756 binary_function_handles: None,
2757 binary_function_instantiations: None,
2758 binary_signatures: None,
2759 binary_constant_pool: None,
2760 binary_identifiers: None,
2761 binary_address_identifiers: None,
2762 binary_struct_defs: None,
2763 binary_struct_def_instantiations: None,
2764 binary_function_defs: None,
2765 binary_field_handles: None,
2766 binary_field_instantiations: None,
2767 binary_friend_decls: None,
2768 binary_enum_defs: None,
2769 binary_enum_def_instantiations: None,
2770 binary_variant_handles: None,
2771 binary_variant_instantiation_handles: None,
2772 max_move_object_size: Some(250 * 1024),
2773 max_move_package_size: Some(100 * 1024),
2774 max_publish_or_upgrade_per_ptb: None,
2775 max_tx_gas: Some(10_000_000_000),
2776 max_gas_price: Some(100_000),
2777 max_gas_price_rgp_factor_for_aborted_transactions: None,
2778 max_gas_computation_bucket: Some(5_000_000),
2779 max_loop_depth: Some(5),
2780 max_generic_instantiation_length: Some(32),
2781 max_function_parameters: Some(128),
2782 max_basic_blocks: Some(1024),
2783 max_value_stack_size: Some(1024),
2784 max_type_nodes: Some(256),
2785 max_push_size: Some(10000),
2786 max_struct_definitions: Some(200),
2787 max_function_definitions: Some(1000),
2788 max_fields_in_struct: Some(32),
2789 max_dependency_depth: Some(100),
2790 max_num_event_emit: Some(256),
2791 max_num_new_move_object_ids: Some(2048),
2792 max_num_new_move_object_ids_system_tx: Some(2048 * 16),
2793 max_num_deleted_move_object_ids: Some(2048),
2794 max_num_deleted_move_object_ids_system_tx: Some(2048 * 16),
2795 max_num_transferred_move_object_ids: Some(2048),
2796 max_num_transferred_move_object_ids_system_tx: Some(2048 * 16),
2797 max_event_emit_size: Some(250 * 1024),
2798 max_move_vector_len: Some(256 * 1024),
2799 max_type_to_layout_nodes: None,
2800 max_ptb_value_size: None,
2801
2802 max_back_edges_per_function: Some(10_000),
2803 max_back_edges_per_module: Some(10_000),
2804 max_verifier_meter_ticks_per_function: Some(6_000_000),
2805 max_meter_ticks_per_module: Some(6_000_000),
2806 max_meter_ticks_per_package: None,
2807
2808 object_runtime_max_num_cached_objects: Some(1000),
2809 object_runtime_max_num_cached_objects_system_tx: Some(1000 * 16),
2810 object_runtime_max_num_store_entries: Some(1000),
2811 object_runtime_max_num_store_entries_system_tx: Some(1000 * 16),
2812 base_tx_cost_fixed: Some(110_000),
2813 package_publish_cost_fixed: Some(1_000),
2814 base_tx_cost_per_byte: Some(0),
2815 package_publish_cost_per_byte: Some(80),
2816 obj_access_cost_read_per_byte: Some(15),
2817 obj_access_cost_mutate_per_byte: Some(40),
2818 obj_access_cost_delete_per_byte: Some(40),
2819 obj_access_cost_verify_per_byte: Some(200),
2820 obj_data_cost_refundable: Some(100),
2821 obj_metadata_cost_non_refundable: Some(50),
2822 gas_model_version: Some(1),
2823 storage_rebate_rate: Some(9900),
2824 storage_fund_reinvest_rate: Some(500),
2825 reward_slashing_rate: Some(5000),
2826 storage_gas_price: Some(1),
2827 accumulator_object_storage_cost: None,
2828 max_transactions_per_checkpoint: Some(10_000),
2829 max_checkpoint_size_bytes: Some(30 * 1024 * 1024),
2830
2831 buffer_stake_for_protocol_upgrade_bps: Some(0),
2834
2835 address_from_bytes_cost_base: Some(52),
2839 address_to_u256_cost_base: Some(52),
2841 address_from_u256_cost_base: Some(52),
2843
2844 config_read_setting_impl_cost_base: None,
2847 config_read_setting_impl_cost_per_byte: None,
2848
2849 dynamic_field_hash_type_and_key_cost_base: Some(100),
2852 dynamic_field_hash_type_and_key_type_cost_per_byte: Some(2),
2853 dynamic_field_hash_type_and_key_value_cost_per_byte: Some(2),
2854 dynamic_field_hash_type_and_key_type_tag_cost_per_byte: Some(2),
2855 dynamic_field_add_child_object_cost_base: Some(100),
2857 dynamic_field_add_child_object_type_cost_per_byte: Some(10),
2858 dynamic_field_add_child_object_value_cost_per_byte: Some(10),
2859 dynamic_field_add_child_object_struct_tag_cost_per_byte: Some(10),
2860 dynamic_field_borrow_child_object_cost_base: Some(100),
2862 dynamic_field_borrow_child_object_child_ref_cost_per_byte: Some(10),
2863 dynamic_field_borrow_child_object_type_cost_per_byte: Some(10),
2864 dynamic_field_remove_child_object_cost_base: Some(100),
2866 dynamic_field_remove_child_object_child_cost_per_byte: Some(2),
2867 dynamic_field_remove_child_object_type_cost_per_byte: Some(2),
2868 dynamic_field_has_child_object_cost_base: Some(100),
2870 dynamic_field_has_child_object_with_ty_cost_base: Some(100),
2872 dynamic_field_has_child_object_with_ty_type_cost_per_byte: Some(2),
2873 dynamic_field_has_child_object_with_ty_type_tag_cost_per_byte: Some(2),
2874
2875 event_emit_cost_base: Some(52),
2878 event_emit_value_size_derivation_cost_per_byte: Some(2),
2879 event_emit_tag_size_derivation_cost_per_byte: Some(5),
2880 event_emit_output_cost_per_byte: Some(10),
2881 event_emit_auth_stream_cost: None,
2882
2883 object_borrow_uid_cost_base: Some(52),
2886 object_delete_impl_cost_base: Some(52),
2888 object_record_new_uid_cost_base: Some(52),
2890
2891 transfer_transfer_internal_cost_base: Some(52),
2894 transfer_party_transfer_internal_cost_base: None,
2896 transfer_freeze_object_cost_base: Some(52),
2898 transfer_share_object_cost_base: Some(52),
2900 transfer_receive_object_cost_base: None,
2901
2902 tx_context_derive_id_cost_base: Some(52),
2905 tx_context_fresh_id_cost_base: None,
2906 tx_context_sender_cost_base: None,
2907 tx_context_epoch_cost_base: None,
2908 tx_context_epoch_timestamp_ms_cost_base: None,
2909 tx_context_sponsor_cost_base: None,
2910 tx_context_rgp_cost_base: None,
2911 tx_context_gas_price_cost_base: None,
2912 tx_context_gas_budget_cost_base: None,
2913 tx_context_ids_created_cost_base: None,
2914 tx_context_replace_cost_base: None,
2915
2916 types_is_one_time_witness_cost_base: Some(52),
2919 types_is_one_time_witness_type_tag_cost_per_byte: Some(2),
2920 types_is_one_time_witness_type_cost_per_byte: Some(2),
2921
2922 validator_validate_metadata_cost_base: Some(52),
2925 validator_validate_metadata_data_cost_per_byte: Some(2),
2926
2927 crypto_invalid_arguments_cost: Some(100),
2929 bls12381_bls12381_min_sig_verify_cost_base: Some(52),
2931 bls12381_bls12381_min_sig_verify_msg_cost_per_byte: Some(2),
2932 bls12381_bls12381_min_sig_verify_msg_cost_per_block: Some(2),
2933
2934 bls12381_bls12381_min_pk_verify_cost_base: Some(52),
2936 bls12381_bls12381_min_pk_verify_msg_cost_per_byte: Some(2),
2937 bls12381_bls12381_min_pk_verify_msg_cost_per_block: Some(2),
2938
2939 ecdsa_k1_ecrecover_keccak256_cost_base: Some(52),
2941 ecdsa_k1_ecrecover_keccak256_msg_cost_per_byte: Some(2),
2942 ecdsa_k1_ecrecover_keccak256_msg_cost_per_block: Some(2),
2943 ecdsa_k1_ecrecover_sha256_cost_base: Some(52),
2944 ecdsa_k1_ecrecover_sha256_msg_cost_per_byte: Some(2),
2945 ecdsa_k1_ecrecover_sha256_msg_cost_per_block: Some(2),
2946
2947 ecdsa_k1_decompress_pubkey_cost_base: Some(52),
2949
2950 ecdsa_k1_secp256k1_verify_keccak256_cost_base: Some(52),
2952 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_byte: Some(2),
2953 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_block: Some(2),
2954 ecdsa_k1_secp256k1_verify_sha256_cost_base: Some(52),
2955 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_byte: Some(2),
2956 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_block: Some(2),
2957
2958 ecdsa_r1_ecrecover_keccak256_cost_base: Some(52),
2960 ecdsa_r1_ecrecover_keccak256_msg_cost_per_byte: Some(2),
2961 ecdsa_r1_ecrecover_keccak256_msg_cost_per_block: Some(2),
2962 ecdsa_r1_ecrecover_sha256_cost_base: Some(52),
2963 ecdsa_r1_ecrecover_sha256_msg_cost_per_byte: Some(2),
2964 ecdsa_r1_ecrecover_sha256_msg_cost_per_block: Some(2),
2965
2966 ecdsa_r1_secp256r1_verify_keccak256_cost_base: Some(52),
2968 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_byte: Some(2),
2969 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_block: Some(2),
2970 ecdsa_r1_secp256r1_verify_sha256_cost_base: Some(52),
2971 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_byte: Some(2),
2972 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_block: Some(2),
2973
2974 ecvrf_ecvrf_verify_cost_base: Some(52),
2976 ecvrf_ecvrf_verify_alpha_string_cost_per_byte: Some(2),
2977 ecvrf_ecvrf_verify_alpha_string_cost_per_block: Some(2),
2978
2979 ed25519_ed25519_verify_cost_base: Some(52),
2981 ed25519_ed25519_verify_msg_cost_per_byte: Some(2),
2982 ed25519_ed25519_verify_msg_cost_per_block: Some(2),
2983
2984 groth16_prepare_verifying_key_bls12381_cost_base: Some(52),
2986 groth16_prepare_verifying_key_bn254_cost_base: Some(52),
2987
2988 groth16_verify_groth16_proof_internal_bls12381_cost_base: Some(52),
2990 groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input: Some(2),
2991 groth16_verify_groth16_proof_internal_bn254_cost_base: Some(52),
2992 groth16_verify_groth16_proof_internal_bn254_cost_per_public_input: Some(2),
2993 groth16_verify_groth16_proof_internal_public_input_cost_per_byte: Some(2),
2994
2995 hash_blake2b256_cost_base: Some(52),
2997 hash_blake2b256_data_cost_per_byte: Some(2),
2998 hash_blake2b256_data_cost_per_block: Some(2),
2999
3000 hash_keccak256_cost_base: Some(52),
3002 hash_keccak256_data_cost_per_byte: Some(2),
3003 hash_keccak256_data_cost_per_block: Some(2),
3004
3005 poseidon_bn254_cost_base: None,
3006 poseidon_bn254_cost_per_block: None,
3007
3008 hmac_hmac_sha3_256_cost_base: Some(52),
3010 hmac_hmac_sha3_256_input_cost_per_byte: Some(2),
3011 hmac_hmac_sha3_256_input_cost_per_block: Some(2),
3012
3013 group_ops_bls12381_decode_scalar_cost: None,
3015 group_ops_bls12381_decode_g1_cost: None,
3016 group_ops_bls12381_decode_g2_cost: None,
3017 group_ops_bls12381_decode_gt_cost: None,
3018 group_ops_bls12381_scalar_add_cost: None,
3019 group_ops_bls12381_g1_add_cost: None,
3020 group_ops_bls12381_g2_add_cost: None,
3021 group_ops_bls12381_gt_add_cost: None,
3022 group_ops_bls12381_scalar_sub_cost: None,
3023 group_ops_bls12381_g1_sub_cost: None,
3024 group_ops_bls12381_g2_sub_cost: None,
3025 group_ops_bls12381_gt_sub_cost: None,
3026 group_ops_bls12381_scalar_mul_cost: None,
3027 group_ops_bls12381_g1_mul_cost: None,
3028 group_ops_bls12381_g2_mul_cost: None,
3029 group_ops_bls12381_gt_mul_cost: None,
3030 group_ops_bls12381_scalar_div_cost: None,
3031 group_ops_bls12381_g1_div_cost: None,
3032 group_ops_bls12381_g2_div_cost: None,
3033 group_ops_bls12381_gt_div_cost: None,
3034 group_ops_bls12381_g1_hash_to_base_cost: None,
3035 group_ops_bls12381_g2_hash_to_base_cost: None,
3036 group_ops_bls12381_g1_hash_to_cost_per_byte: None,
3037 group_ops_bls12381_g2_hash_to_cost_per_byte: None,
3038 group_ops_bls12381_g1_msm_base_cost: None,
3039 group_ops_bls12381_g2_msm_base_cost: None,
3040 group_ops_bls12381_g1_msm_base_cost_per_input: None,
3041 group_ops_bls12381_g2_msm_base_cost_per_input: None,
3042 group_ops_bls12381_msm_max_len: None,
3043 group_ops_bls12381_pairing_cost: None,
3044 group_ops_bls12381_g1_to_uncompressed_g1_cost: None,
3045 group_ops_bls12381_uncompressed_g1_to_g1_cost: None,
3046 group_ops_bls12381_uncompressed_g1_sum_base_cost: None,
3047 group_ops_bls12381_uncompressed_g1_sum_cost_per_term: None,
3048 group_ops_bls12381_uncompressed_g1_sum_max_terms: None,
3049
3050 group_ops_ristretto_decode_scalar_cost: None,
3051 group_ops_ristretto_decode_point_cost: None,
3052 group_ops_ristretto_scalar_add_cost: None,
3053 group_ops_ristretto_point_add_cost: None,
3054 group_ops_ristretto_scalar_sub_cost: None,
3055 group_ops_ristretto_point_sub_cost: None,
3056 group_ops_ristretto_scalar_mul_cost: None,
3057 group_ops_ristretto_point_mul_cost: None,
3058 group_ops_ristretto_scalar_div_cost: None,
3059 group_ops_ristretto_point_div_cost: None,
3060
3061 check_zklogin_id_cost_base: None,
3063 check_zklogin_issuer_cost_base: None,
3065
3066 vdf_verify_vdf_cost: None,
3067 vdf_hash_to_input_cost: None,
3068
3069 nitro_attestation_parse_base_cost: None,
3071 nitro_attestation_parse_cost_per_byte: None,
3072 nitro_attestation_verify_base_cost: None,
3073 nitro_attestation_verify_cost_per_cert: None,
3074
3075 bcs_per_byte_serialized_cost: None,
3076 bcs_legacy_min_output_size_cost: None,
3077 bcs_failure_cost: None,
3078 hash_sha2_256_base_cost: None,
3079 hash_sha2_256_per_byte_cost: None,
3080 hash_sha2_256_legacy_min_input_len_cost: None,
3081 hash_sha3_256_base_cost: None,
3082 hash_sha3_256_per_byte_cost: None,
3083 hash_sha3_256_legacy_min_input_len_cost: None,
3084 type_name_get_base_cost: None,
3085 type_name_get_per_byte_cost: None,
3086 type_name_id_base_cost: None,
3087 string_check_utf8_base_cost: None,
3088 string_check_utf8_per_byte_cost: None,
3089 string_is_char_boundary_base_cost: None,
3090 string_sub_string_base_cost: None,
3091 string_sub_string_per_byte_cost: None,
3092 string_index_of_base_cost: None,
3093 string_index_of_per_byte_pattern_cost: None,
3094 string_index_of_per_byte_searched_cost: None,
3095 vector_empty_base_cost: None,
3096 vector_length_base_cost: None,
3097 vector_push_back_base_cost: None,
3098 vector_push_back_legacy_per_abstract_memory_unit_cost: None,
3099 vector_borrow_base_cost: None,
3100 vector_pop_back_base_cost: None,
3101 vector_destroy_empty_base_cost: None,
3102 vector_swap_base_cost: None,
3103 debug_print_base_cost: None,
3104 debug_print_stack_trace_base_cost: None,
3105
3106 max_size_written_objects: None,
3107 max_size_written_objects_system_tx: None,
3108
3109 max_move_identifier_len: None,
3116 max_move_value_depth: None,
3117 max_move_enum_variants: None,
3118
3119 gas_rounding_step: None,
3120
3121 execution_version: None,
3122
3123 max_event_emit_size_total: None,
3124
3125 consensus_bad_nodes_stake_threshold: None,
3126
3127 max_jwk_votes_per_validator_per_epoch: None,
3128
3129 max_age_of_jwk_in_epochs: None,
3130
3131 random_beacon_reduction_allowed_delta: None,
3132
3133 random_beacon_reduction_lower_bound: None,
3134
3135 random_beacon_dkg_timeout_round: None,
3136
3137 random_beacon_min_round_interval_ms: None,
3138
3139 random_beacon_dkg_version: None,
3140
3141 consensus_max_transaction_size_bytes: None,
3142
3143 consensus_max_transactions_in_block_bytes: None,
3144
3145 consensus_max_num_transactions_in_block: None,
3146
3147 consensus_voting_rounds: None,
3148
3149 max_accumulated_txn_cost_per_object_in_narwhal_commit: None,
3150
3151 max_deferral_rounds_for_congestion_control: None,
3152
3153 max_txn_cost_overage_per_object_in_commit: None,
3154
3155 allowed_txn_cost_overage_burst_per_object_in_commit: None,
3156
3157 min_checkpoint_interval_ms: None,
3158
3159 checkpoint_summary_version_specific_data: None,
3160
3161 max_soft_bundle_size: None,
3162
3163 bridge_should_try_to_finalize_committee: None,
3164
3165 max_accumulated_txn_cost_per_object_in_mysticeti_commit: None,
3166
3167 max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit: None,
3168
3169 consensus_gc_depth: None,
3170
3171 gas_budget_based_txn_cost_cap_factor: None,
3172
3173 gas_budget_based_txn_cost_absolute_cap_commit_count: None,
3174
3175 sip_45_consensus_amplification_threshold: None,
3176
3177 use_object_per_epoch_marker_table_v2: None,
3178
3179 consensus_commit_rate_estimation_window_size: None,
3180
3181 aliased_addresses: vec![],
3182
3183 translation_per_command_base_charge: None,
3184 translation_per_input_base_charge: None,
3185 translation_pure_input_per_byte_charge: None,
3186 translation_per_type_node_charge: None,
3187 translation_per_reference_node_charge: None,
3188 translation_per_linkage_entry_charge: None,
3189
3190 max_updates_per_settlement_txn: None,
3191 };
3194 for cur in 2..=version.0 {
3195 match cur {
3196 1 => unreachable!(),
3197 2 => {
3198 cfg.feature_flags.advance_epoch_start_time_in_safe_mode = true;
3199 }
3200 3 => {
3201 cfg.gas_model_version = Some(2);
3203 cfg.max_tx_gas = Some(50_000_000_000);
3205 cfg.base_tx_cost_fixed = Some(2_000);
3207 cfg.storage_gas_price = Some(76);
3209 cfg.feature_flags.loaded_child_objects_fixed = true;
3210 cfg.max_size_written_objects = Some(5 * 1000 * 1000);
3213 cfg.max_size_written_objects_system_tx = Some(50 * 1000 * 1000);
3216 cfg.feature_flags.package_upgrades = true;
3217 }
3218 4 => {
3223 cfg.reward_slashing_rate = Some(10000);
3225 cfg.gas_model_version = Some(3);
3227 }
3228 5 => {
3229 cfg.feature_flags.missing_type_is_compatibility_error = true;
3230 cfg.gas_model_version = Some(4);
3231 cfg.feature_flags.scoring_decision_with_validity_cutoff = true;
3232 }
3236 6 => {
3237 cfg.gas_model_version = Some(5);
3238 cfg.buffer_stake_for_protocol_upgrade_bps = Some(5000);
3239 cfg.feature_flags.consensus_order_end_of_epoch_last = true;
3240 }
3241 7 => {
3242 cfg.feature_flags.disallow_adding_abilities_on_upgrade = true;
3243 cfg.feature_flags
3244 .disable_invariant_violation_check_in_swap_loc = true;
3245 cfg.feature_flags.ban_entry_init = true;
3246 cfg.feature_flags.package_digest_hash_module = true;
3247 }
3248 8 => {
3249 cfg.feature_flags
3250 .disallow_change_struct_type_params_on_upgrade = true;
3251 }
3252 9 => {
3253 cfg.max_move_identifier_len = Some(128);
3255 cfg.feature_flags.no_extraneous_module_bytes = true;
3256 cfg.feature_flags
3257 .advance_to_highest_supported_protocol_version = true;
3258 }
3259 10 => {
3260 cfg.max_verifier_meter_ticks_per_function = Some(16_000_000);
3261 cfg.max_meter_ticks_per_module = Some(16_000_000);
3262 }
3263 11 => {
3264 cfg.max_move_value_depth = Some(128);
3265 }
3266 12 => {
3267 cfg.feature_flags.narwhal_versioned_metadata = true;
3268 if chain != Chain::Mainnet {
3269 cfg.feature_flags.commit_root_state_digest = true;
3270 }
3271
3272 if chain != Chain::Mainnet && chain != Chain::Testnet {
3273 cfg.feature_flags.zklogin_auth = true;
3274 }
3275 }
3276 13 => {}
3277 14 => {
3278 cfg.gas_rounding_step = Some(1_000);
3279 cfg.gas_model_version = Some(6);
3280 }
3281 15 => {
3282 cfg.feature_flags.consensus_transaction_ordering =
3283 ConsensusTransactionOrdering::ByGasPrice;
3284 }
3285 16 => {
3286 cfg.feature_flags.simplified_unwrap_then_delete = true;
3287 }
3288 17 => {
3289 cfg.feature_flags.upgraded_multisig_supported = true;
3290 }
3291 18 => {
3292 cfg.execution_version = Some(1);
3293 cfg.feature_flags.txn_base_cost_as_multiplier = true;
3302 cfg.base_tx_cost_fixed = Some(1_000);
3304 }
3305 19 => {
3306 cfg.max_num_event_emit = Some(1024);
3307 cfg.max_event_emit_size_total = Some(
3310 256 * 250 * 1024, );
3312 }
3313 20 => {
3314 cfg.feature_flags.commit_root_state_digest = true;
3315
3316 if chain != Chain::Mainnet {
3317 cfg.feature_flags.narwhal_new_leader_election_schedule = true;
3318 cfg.consensus_bad_nodes_stake_threshold = Some(20);
3319 }
3320 }
3321
3322 21 => {
3323 if chain != Chain::Mainnet {
3324 cfg.feature_flags.zklogin_supported_providers = BTreeSet::from([
3325 "Google".to_string(),
3326 "Facebook".to_string(),
3327 "Twitch".to_string(),
3328 ]);
3329 }
3330 }
3331 22 => {
3332 cfg.feature_flags.loaded_child_object_format = true;
3333 }
3334 23 => {
3335 cfg.feature_flags.loaded_child_object_format_type = true;
3336 cfg.feature_flags.narwhal_new_leader_election_schedule = true;
3337 cfg.consensus_bad_nodes_stake_threshold = Some(20);
3343 }
3344 24 => {
3345 cfg.feature_flags.simple_conservation_checks = true;
3346 cfg.max_publish_or_upgrade_per_ptb = Some(5);
3347
3348 cfg.feature_flags.end_of_epoch_transaction_supported = true;
3349
3350 if chain != Chain::Mainnet {
3351 cfg.feature_flags.enable_jwk_consensus_updates = true;
3352 cfg.max_jwk_votes_per_validator_per_epoch = Some(240);
3354 cfg.max_age_of_jwk_in_epochs = Some(1);
3355 }
3356 }
3357 25 => {
3358 cfg.feature_flags.zklogin_supported_providers = BTreeSet::from([
3360 "Google".to_string(),
3361 "Facebook".to_string(),
3362 "Twitch".to_string(),
3363 ]);
3364 cfg.feature_flags.zklogin_auth = true;
3365
3366 cfg.feature_flags.enable_jwk_consensus_updates = true;
3368 cfg.max_jwk_votes_per_validator_per_epoch = Some(240);
3369 cfg.max_age_of_jwk_in_epochs = Some(1);
3370 }
3371 26 => {
3372 cfg.gas_model_version = Some(7);
3373 if chain != Chain::Mainnet && chain != Chain::Testnet {
3375 cfg.transfer_receive_object_cost_base = Some(52);
3376 cfg.feature_flags.receive_objects = true;
3377 }
3378 }
3379 27 => {
3380 cfg.gas_model_version = Some(8);
3381 }
3382 28 => {
3383 cfg.check_zklogin_id_cost_base = Some(200);
3385 cfg.check_zklogin_issuer_cost_base = Some(200);
3387
3388 if chain != Chain::Mainnet && chain != Chain::Testnet {
3390 cfg.feature_flags.enable_effects_v2 = true;
3391 }
3392 }
3393 29 => {
3394 cfg.feature_flags.verify_legacy_zklogin_address = true;
3395 }
3396 30 => {
3397 if chain != Chain::Mainnet {
3399 cfg.feature_flags.narwhal_certificate_v2 = true;
3400 }
3401
3402 cfg.random_beacon_reduction_allowed_delta = Some(800);
3403 if chain != Chain::Mainnet {
3405 cfg.feature_flags.enable_effects_v2 = true;
3406 }
3407
3408 cfg.feature_flags.zklogin_supported_providers = BTreeSet::default();
3412
3413 cfg.feature_flags.recompute_has_public_transfer_in_execution = true;
3414 }
3415 31 => {
3416 cfg.execution_version = Some(2);
3417 if chain != Chain::Mainnet && chain != Chain::Testnet {
3419 cfg.feature_flags.shared_object_deletion = true;
3420 }
3421 }
3422 32 => {
3423 if chain != Chain::Mainnet {
3425 cfg.feature_flags.accept_zklogin_in_multisig = true;
3426 }
3427 if chain != Chain::Mainnet {
3429 cfg.transfer_receive_object_cost_base = Some(52);
3430 cfg.feature_flags.receive_objects = true;
3431 }
3432 if chain != Chain::Mainnet && chain != Chain::Testnet {
3434 cfg.feature_flags.random_beacon = true;
3435 cfg.random_beacon_reduction_lower_bound = Some(1600);
3436 cfg.random_beacon_dkg_timeout_round = Some(3000);
3437 cfg.random_beacon_min_round_interval_ms = Some(150);
3438 }
3439 if chain != Chain::Testnet && chain != Chain::Mainnet {
3441 cfg.feature_flags.include_consensus_digest_in_prologue = true;
3442 }
3443
3444 cfg.feature_flags.narwhal_certificate_v2 = true;
3446 }
3447 33 => {
3448 cfg.feature_flags.hardened_otw_check = true;
3449 cfg.feature_flags.allow_receiving_object_id = true;
3450
3451 cfg.transfer_receive_object_cost_base = Some(52);
3453 cfg.feature_flags.receive_objects = true;
3454
3455 if chain != Chain::Mainnet {
3457 cfg.feature_flags.shared_object_deletion = true;
3458 }
3459
3460 cfg.feature_flags.enable_effects_v2 = true;
3461 }
3462 34 => {}
3463 35 => {
3464 if chain != Chain::Mainnet && chain != Chain::Testnet {
3466 cfg.feature_flags.enable_poseidon = true;
3467 cfg.poseidon_bn254_cost_base = Some(260);
3468 cfg.poseidon_bn254_cost_per_block = Some(10);
3469 }
3470
3471 cfg.feature_flags.enable_coin_deny_list = true;
3472 }
3473 36 => {
3474 if chain != Chain::Mainnet && chain != Chain::Testnet {
3476 cfg.feature_flags.enable_group_ops_native_functions = true;
3477 cfg.feature_flags.enable_group_ops_native_function_msm = true;
3478 cfg.group_ops_bls12381_decode_scalar_cost = Some(52);
3480 cfg.group_ops_bls12381_decode_g1_cost = Some(52);
3481 cfg.group_ops_bls12381_decode_g2_cost = Some(52);
3482 cfg.group_ops_bls12381_decode_gt_cost = Some(52);
3483 cfg.group_ops_bls12381_scalar_add_cost = Some(52);
3484 cfg.group_ops_bls12381_g1_add_cost = Some(52);
3485 cfg.group_ops_bls12381_g2_add_cost = Some(52);
3486 cfg.group_ops_bls12381_gt_add_cost = Some(52);
3487 cfg.group_ops_bls12381_scalar_sub_cost = Some(52);
3488 cfg.group_ops_bls12381_g1_sub_cost = Some(52);
3489 cfg.group_ops_bls12381_g2_sub_cost = Some(52);
3490 cfg.group_ops_bls12381_gt_sub_cost = Some(52);
3491 cfg.group_ops_bls12381_scalar_mul_cost = Some(52);
3492 cfg.group_ops_bls12381_g1_mul_cost = Some(52);
3493 cfg.group_ops_bls12381_g2_mul_cost = Some(52);
3494 cfg.group_ops_bls12381_gt_mul_cost = Some(52);
3495 cfg.group_ops_bls12381_scalar_div_cost = Some(52);
3496 cfg.group_ops_bls12381_g1_div_cost = Some(52);
3497 cfg.group_ops_bls12381_g2_div_cost = Some(52);
3498 cfg.group_ops_bls12381_gt_div_cost = Some(52);
3499 cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(52);
3500 cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(52);
3501 cfg.group_ops_bls12381_g1_hash_to_cost_per_byte = Some(2);
3502 cfg.group_ops_bls12381_g2_hash_to_cost_per_byte = Some(2);
3503 cfg.group_ops_bls12381_g1_msm_base_cost = Some(52);
3504 cfg.group_ops_bls12381_g2_msm_base_cost = Some(52);
3505 cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(52);
3506 cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(52);
3507 cfg.group_ops_bls12381_msm_max_len = Some(32);
3508 cfg.group_ops_bls12381_pairing_cost = Some(52);
3509 }
3510 cfg.feature_flags.shared_object_deletion = true;
3512
3513 cfg.consensus_max_transaction_size_bytes = Some(256 * 1024); cfg.consensus_max_transactions_in_block_bytes = Some(6 * 1_024 * 1024);
3515 }
3517 37 => {
3518 cfg.feature_flags.reject_mutable_random_on_entry_functions = true;
3519
3520 if chain != Chain::Mainnet {
3522 cfg.feature_flags.include_consensus_digest_in_prologue = true;
3523 }
3524 }
3525 38 => {
3526 cfg.binary_module_handles = Some(100);
3527 cfg.binary_struct_handles = Some(300);
3528 cfg.binary_function_handles = Some(1500);
3529 cfg.binary_function_instantiations = Some(750);
3530 cfg.binary_signatures = Some(1000);
3531 cfg.binary_constant_pool = Some(4000);
3535 cfg.binary_identifiers = Some(10000);
3536 cfg.binary_address_identifiers = Some(100);
3537 cfg.binary_struct_defs = Some(200);
3538 cfg.binary_struct_def_instantiations = Some(100);
3539 cfg.binary_function_defs = Some(1000);
3540 cfg.binary_field_handles = Some(500);
3541 cfg.binary_field_instantiations = Some(250);
3542 cfg.binary_friend_decls = Some(100);
3543 cfg.max_package_dependencies = Some(32);
3545 cfg.max_modules_in_publish = Some(64);
3546 cfg.execution_version = Some(3);
3548 }
3549 39 => {
3550 }
3552 40 => {}
3553 41 => {
3554 cfg.feature_flags.enable_group_ops_native_functions = true;
3556 cfg.group_ops_bls12381_decode_scalar_cost = Some(52);
3558 cfg.group_ops_bls12381_decode_g1_cost = Some(52);
3559 cfg.group_ops_bls12381_decode_g2_cost = Some(52);
3560 cfg.group_ops_bls12381_decode_gt_cost = Some(52);
3561 cfg.group_ops_bls12381_scalar_add_cost = Some(52);
3562 cfg.group_ops_bls12381_g1_add_cost = Some(52);
3563 cfg.group_ops_bls12381_g2_add_cost = Some(52);
3564 cfg.group_ops_bls12381_gt_add_cost = Some(52);
3565 cfg.group_ops_bls12381_scalar_sub_cost = Some(52);
3566 cfg.group_ops_bls12381_g1_sub_cost = Some(52);
3567 cfg.group_ops_bls12381_g2_sub_cost = Some(52);
3568 cfg.group_ops_bls12381_gt_sub_cost = Some(52);
3569 cfg.group_ops_bls12381_scalar_mul_cost = Some(52);
3570 cfg.group_ops_bls12381_g1_mul_cost = Some(52);
3571 cfg.group_ops_bls12381_g2_mul_cost = Some(52);
3572 cfg.group_ops_bls12381_gt_mul_cost = Some(52);
3573 cfg.group_ops_bls12381_scalar_div_cost = Some(52);
3574 cfg.group_ops_bls12381_g1_div_cost = Some(52);
3575 cfg.group_ops_bls12381_g2_div_cost = Some(52);
3576 cfg.group_ops_bls12381_gt_div_cost = Some(52);
3577 cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(52);
3578 cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(52);
3579 cfg.group_ops_bls12381_g1_hash_to_cost_per_byte = Some(2);
3580 cfg.group_ops_bls12381_g2_hash_to_cost_per_byte = Some(2);
3581 cfg.group_ops_bls12381_g1_msm_base_cost = Some(52);
3582 cfg.group_ops_bls12381_g2_msm_base_cost = Some(52);
3583 cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(52);
3584 cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(52);
3585 cfg.group_ops_bls12381_msm_max_len = Some(32);
3586 cfg.group_ops_bls12381_pairing_cost = Some(52);
3587 }
3588 42 => {}
3589 43 => {
3590 cfg.feature_flags.zklogin_max_epoch_upper_bound_delta = Some(30);
3591 cfg.max_meter_ticks_per_package = Some(16_000_000);
3592 }
3593 44 => {
3594 cfg.feature_flags.include_consensus_digest_in_prologue = true;
3596 if chain != Chain::Mainnet {
3598 cfg.feature_flags.consensus_choice = ConsensusChoice::SwapEachEpoch;
3599 }
3600 }
3601 45 => {
3602 if chain != Chain::Testnet && chain != Chain::Mainnet {
3604 cfg.feature_flags.consensus_network = ConsensusNetwork::Tonic;
3605 }
3606
3607 if chain != Chain::Mainnet {
3608 cfg.feature_flags.mysticeti_leader_scoring_and_schedule = true;
3610 }
3611 cfg.min_move_binary_format_version = Some(6);
3612 cfg.feature_flags.accept_zklogin_in_multisig = true;
3613
3614 if chain != Chain::Mainnet && chain != Chain::Testnet {
3618 cfg.feature_flags.bridge = true;
3619 }
3620 }
3621 46 => {
3622 if chain != Chain::Mainnet {
3624 cfg.feature_flags.bridge = true;
3625 }
3626
3627 cfg.feature_flags.reshare_at_same_initial_version = true;
3629 }
3630 47 => {}
3631 48 => {
3632 cfg.feature_flags.consensus_network = ConsensusNetwork::Tonic;
3634
3635 cfg.feature_flags.resolve_abort_locations_to_package_id = true;
3637
3638 if chain != Chain::Mainnet {
3640 cfg.feature_flags.random_beacon = true;
3641 cfg.random_beacon_reduction_lower_bound = Some(1600);
3642 cfg.random_beacon_dkg_timeout_round = Some(3000);
3643 cfg.random_beacon_min_round_interval_ms = Some(200);
3644 }
3645
3646 cfg.feature_flags.mysticeti_use_committed_subdag_digest = true;
3648 }
3649 49 => {
3650 if chain != Chain::Testnet && chain != Chain::Mainnet {
3651 cfg.move_binary_format_version = Some(7);
3652 }
3653
3654 if chain != Chain::Mainnet && chain != Chain::Testnet {
3656 cfg.feature_flags.enable_vdf = true;
3657 cfg.vdf_verify_vdf_cost = Some(1500);
3660 cfg.vdf_hash_to_input_cost = Some(100);
3661 }
3662
3663 if chain != Chain::Testnet && chain != Chain::Mainnet {
3665 cfg.feature_flags
3666 .record_consensus_determined_version_assignments_in_prologue = true;
3667 }
3668
3669 if chain != Chain::Mainnet {
3671 cfg.feature_flags.consensus_choice = ConsensusChoice::Mysticeti;
3672 }
3673
3674 cfg.feature_flags.fresh_vm_on_framework_upgrade = true;
3676 }
3677 50 => {
3678 if chain != Chain::Mainnet {
3680 cfg.checkpoint_summary_version_specific_data = Some(1);
3681 cfg.min_checkpoint_interval_ms = Some(200);
3682 }
3683
3684 if chain != Chain::Testnet && chain != Chain::Mainnet {
3686 cfg.feature_flags
3687 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = true;
3688 }
3689
3690 cfg.feature_flags.mysticeti_num_leaders_per_round = Some(1);
3691
3692 cfg.max_deferral_rounds_for_congestion_control = Some(10);
3694 }
3695 51 => {
3696 cfg.random_beacon_dkg_version = Some(1);
3697
3698 if chain != Chain::Testnet && chain != Chain::Mainnet {
3699 cfg.feature_flags.enable_coin_deny_list_v2 = true;
3700 }
3701 }
3702 52 => {
3703 if chain != Chain::Mainnet {
3704 cfg.feature_flags.soft_bundle = true;
3705 cfg.max_soft_bundle_size = Some(5);
3706 }
3707
3708 cfg.config_read_setting_impl_cost_base = Some(100);
3709 cfg.config_read_setting_impl_cost_per_byte = Some(40);
3710
3711 if chain != Chain::Testnet && chain != Chain::Mainnet {
3713 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(100);
3714 cfg.feature_flags.per_object_congestion_control_mode =
3715 PerObjectCongestionControlMode::TotalTxCount;
3716 }
3717
3718 cfg.feature_flags.consensus_choice = ConsensusChoice::Mysticeti;
3720
3721 cfg.feature_flags.mysticeti_leader_scoring_and_schedule = true;
3723
3724 cfg.checkpoint_summary_version_specific_data = Some(1);
3726 cfg.min_checkpoint_interval_ms = Some(200);
3727
3728 if chain != Chain::Mainnet {
3730 cfg.feature_flags
3731 .record_consensus_determined_version_assignments_in_prologue = true;
3732 cfg.feature_flags
3733 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = true;
3734 }
3735 if chain != Chain::Mainnet {
3737 cfg.move_binary_format_version = Some(7);
3738 }
3739
3740 if chain != Chain::Testnet && chain != Chain::Mainnet {
3741 cfg.feature_flags.passkey_auth = true;
3742 }
3743 cfg.feature_flags.enable_coin_deny_list_v2 = true;
3744 }
3745 53 => {
3746 cfg.bridge_should_try_to_finalize_committee = Some(chain != Chain::Mainnet);
3748
3749 cfg.feature_flags
3751 .record_consensus_determined_version_assignments_in_prologue = true;
3752 cfg.feature_flags
3753 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = true;
3754
3755 if chain == Chain::Unknown {
3756 cfg.feature_flags.authority_capabilities_v2 = true;
3757 }
3758
3759 if chain != Chain::Mainnet {
3761 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(100);
3762 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(10);
3763 cfg.feature_flags.per_object_congestion_control_mode =
3764 PerObjectCongestionControlMode::TotalTxCount;
3765 }
3766
3767 cfg.bcs_per_byte_serialized_cost = Some(2);
3769 cfg.bcs_legacy_min_output_size_cost = Some(1);
3770 cfg.bcs_failure_cost = Some(52);
3771 cfg.debug_print_base_cost = Some(52);
3772 cfg.debug_print_stack_trace_base_cost = Some(52);
3773 cfg.hash_sha2_256_base_cost = Some(52);
3774 cfg.hash_sha2_256_per_byte_cost = Some(2);
3775 cfg.hash_sha2_256_legacy_min_input_len_cost = Some(1);
3776 cfg.hash_sha3_256_base_cost = Some(52);
3777 cfg.hash_sha3_256_per_byte_cost = Some(2);
3778 cfg.hash_sha3_256_legacy_min_input_len_cost = Some(1);
3779 cfg.type_name_get_base_cost = Some(52);
3780 cfg.type_name_get_per_byte_cost = Some(2);
3781 cfg.string_check_utf8_base_cost = Some(52);
3782 cfg.string_check_utf8_per_byte_cost = Some(2);
3783 cfg.string_is_char_boundary_base_cost = Some(52);
3784 cfg.string_sub_string_base_cost = Some(52);
3785 cfg.string_sub_string_per_byte_cost = Some(2);
3786 cfg.string_index_of_base_cost = Some(52);
3787 cfg.string_index_of_per_byte_pattern_cost = Some(2);
3788 cfg.string_index_of_per_byte_searched_cost = Some(2);
3789 cfg.vector_empty_base_cost = Some(52);
3790 cfg.vector_length_base_cost = Some(52);
3791 cfg.vector_push_back_base_cost = Some(52);
3792 cfg.vector_push_back_legacy_per_abstract_memory_unit_cost = Some(2);
3793 cfg.vector_borrow_base_cost = Some(52);
3794 cfg.vector_pop_back_base_cost = Some(52);
3795 cfg.vector_destroy_empty_base_cost = Some(52);
3796 cfg.vector_swap_base_cost = Some(52);
3797 }
3798 54 => {
3799 cfg.feature_flags.random_beacon = true;
3801 cfg.random_beacon_reduction_lower_bound = Some(1000);
3802 cfg.random_beacon_dkg_timeout_round = Some(3000);
3803 cfg.random_beacon_min_round_interval_ms = Some(500);
3804
3805 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(100);
3807 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(10);
3808 cfg.feature_flags.per_object_congestion_control_mode =
3809 PerObjectCongestionControlMode::TotalTxCount;
3810
3811 cfg.feature_flags.soft_bundle = true;
3813 cfg.max_soft_bundle_size = Some(5);
3814 }
3815 55 => {
3816 cfg.move_binary_format_version = Some(7);
3818
3819 cfg.consensus_max_transactions_in_block_bytes = Some(512 * 1024);
3821 cfg.consensus_max_num_transactions_in_block = Some(512);
3824
3825 cfg.feature_flags.rethrow_serialization_type_layout_errors = true;
3826 }
3827 56 => {
3828 if chain == Chain::Mainnet {
3829 cfg.feature_flags.bridge = true;
3830 }
3831 }
3832 57 => {
3833 cfg.random_beacon_reduction_lower_bound = Some(800);
3835 }
3836 58 => {
3837 if chain == Chain::Mainnet {
3838 cfg.bridge_should_try_to_finalize_committee = Some(true);
3839 }
3840
3841 if chain != Chain::Mainnet && chain != Chain::Testnet {
3842 cfg.feature_flags
3844 .consensus_distributed_vote_scoring_strategy = true;
3845 }
3846 }
3847 59 => {
3848 cfg.feature_flags.consensus_round_prober = true;
3850 }
3851 60 => {
3852 cfg.max_type_to_layout_nodes = Some(512);
3853 cfg.feature_flags.validate_identifier_inputs = true;
3854 }
3855 61 => {
3856 if chain != Chain::Mainnet {
3857 cfg.feature_flags
3859 .consensus_distributed_vote_scoring_strategy = true;
3860 }
3861 cfg.random_beacon_reduction_lower_bound = Some(700);
3863
3864 if chain != Chain::Mainnet && chain != Chain::Testnet {
3865 cfg.feature_flags.mysticeti_fastpath = true;
3867 }
3868 }
3869 62 => {
3870 cfg.feature_flags.relocate_event_module = true;
3871 }
3872 63 => {
3873 cfg.feature_flags.per_object_congestion_control_mode =
3874 PerObjectCongestionControlMode::TotalGasBudgetWithCap;
3875 cfg.gas_budget_based_txn_cost_cap_factor = Some(400_000);
3876 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(18_500_000);
3877 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(240_000_000);
3878 }
3879 64 => {
3880 cfg.feature_flags.per_object_congestion_control_mode =
3881 PerObjectCongestionControlMode::TotalTxCount;
3882 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(40);
3883 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(3);
3884 }
3885 65 => {
3886 cfg.feature_flags
3888 .consensus_distributed_vote_scoring_strategy = true;
3889 }
3890 66 => {
3891 if chain == Chain::Mainnet {
3892 cfg.feature_flags
3894 .consensus_distributed_vote_scoring_strategy = false;
3895 }
3896 }
3897 67 => {
3898 cfg.feature_flags
3900 .consensus_distributed_vote_scoring_strategy = true;
3901 }
3902 68 => {
3903 cfg.group_ops_bls12381_g1_to_uncompressed_g1_cost = Some(26);
3904 cfg.group_ops_bls12381_uncompressed_g1_to_g1_cost = Some(52);
3905 cfg.group_ops_bls12381_uncompressed_g1_sum_base_cost = Some(26);
3906 cfg.group_ops_bls12381_uncompressed_g1_sum_cost_per_term = Some(13);
3907 cfg.group_ops_bls12381_uncompressed_g1_sum_max_terms = Some(2000);
3908
3909 if chain != Chain::Mainnet && chain != Chain::Testnet {
3910 cfg.feature_flags.uncompressed_g1_group_elements = true;
3911 }
3912
3913 cfg.feature_flags.per_object_congestion_control_mode =
3914 PerObjectCongestionControlMode::TotalGasBudgetWithCap;
3915 cfg.gas_budget_based_txn_cost_cap_factor = Some(400_000);
3916 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(18_500_000);
3917 cfg.max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit =
3918 Some(3_700_000); cfg.max_txn_cost_overage_per_object_in_commit = Some(u64::MAX);
3920 cfg.gas_budget_based_txn_cost_absolute_cap_commit_count = Some(50);
3921
3922 cfg.random_beacon_reduction_lower_bound = Some(500);
3924
3925 cfg.feature_flags.disallow_new_modules_in_deps_only_packages = true;
3926 }
3927 69 => {
3928 cfg.consensus_voting_rounds = Some(40);
3930
3931 if chain != Chain::Mainnet && chain != Chain::Testnet {
3932 cfg.feature_flags.consensus_smart_ancestor_selection = true;
3934 }
3935
3936 if chain != Chain::Mainnet {
3937 cfg.feature_flags.uncompressed_g1_group_elements = true;
3938 }
3939 }
3940 70 => {
3941 if chain != Chain::Mainnet {
3942 cfg.feature_flags.consensus_smart_ancestor_selection = true;
3944 cfg.feature_flags
3946 .consensus_round_prober_probe_accepted_rounds = true;
3947 }
3948
3949 cfg.poseidon_bn254_cost_per_block = Some(388);
3950
3951 cfg.gas_model_version = Some(9);
3952 cfg.feature_flags.native_charging_v2 = true;
3953 cfg.bls12381_bls12381_min_sig_verify_cost_base = Some(44064);
3954 cfg.bls12381_bls12381_min_pk_verify_cost_base = Some(49282);
3955 cfg.ecdsa_k1_secp256k1_verify_keccak256_cost_base = Some(1470);
3956 cfg.ecdsa_k1_secp256k1_verify_sha256_cost_base = Some(1470);
3957 cfg.ecdsa_r1_secp256r1_verify_sha256_cost_base = Some(4225);
3958 cfg.ecdsa_r1_secp256r1_verify_keccak256_cost_base = Some(4225);
3959 cfg.ecvrf_ecvrf_verify_cost_base = Some(4848);
3960 cfg.ed25519_ed25519_verify_cost_base = Some(1802);
3961
3962 cfg.ecdsa_r1_ecrecover_keccak256_cost_base = Some(1173);
3964 cfg.ecdsa_r1_ecrecover_sha256_cost_base = Some(1173);
3965 cfg.ecdsa_k1_ecrecover_keccak256_cost_base = Some(500);
3966 cfg.ecdsa_k1_ecrecover_sha256_cost_base = Some(500);
3967
3968 cfg.groth16_prepare_verifying_key_bls12381_cost_base = Some(53838);
3969 cfg.groth16_prepare_verifying_key_bn254_cost_base = Some(82010);
3970 cfg.groth16_verify_groth16_proof_internal_bls12381_cost_base = Some(72090);
3971 cfg.groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input =
3972 Some(8213);
3973 cfg.groth16_verify_groth16_proof_internal_bn254_cost_base = Some(115502);
3974 cfg.groth16_verify_groth16_proof_internal_bn254_cost_per_public_input =
3975 Some(9484);
3976
3977 cfg.hash_keccak256_cost_base = Some(10);
3978 cfg.hash_blake2b256_cost_base = Some(10);
3979
3980 cfg.group_ops_bls12381_decode_scalar_cost = Some(7);
3982 cfg.group_ops_bls12381_decode_g1_cost = Some(2848);
3983 cfg.group_ops_bls12381_decode_g2_cost = Some(3770);
3984 cfg.group_ops_bls12381_decode_gt_cost = Some(3068);
3985
3986 cfg.group_ops_bls12381_scalar_add_cost = Some(10);
3987 cfg.group_ops_bls12381_g1_add_cost = Some(1556);
3988 cfg.group_ops_bls12381_g2_add_cost = Some(3048);
3989 cfg.group_ops_bls12381_gt_add_cost = Some(188);
3990
3991 cfg.group_ops_bls12381_scalar_sub_cost = Some(10);
3992 cfg.group_ops_bls12381_g1_sub_cost = Some(1550);
3993 cfg.group_ops_bls12381_g2_sub_cost = Some(3019);
3994 cfg.group_ops_bls12381_gt_sub_cost = Some(497);
3995
3996 cfg.group_ops_bls12381_scalar_mul_cost = Some(11);
3997 cfg.group_ops_bls12381_g1_mul_cost = Some(4842);
3998 cfg.group_ops_bls12381_g2_mul_cost = Some(9108);
3999 cfg.group_ops_bls12381_gt_mul_cost = Some(27490);
4000
4001 cfg.group_ops_bls12381_scalar_div_cost = Some(91);
4002 cfg.group_ops_bls12381_g1_div_cost = Some(5091);
4003 cfg.group_ops_bls12381_g2_div_cost = Some(9206);
4004 cfg.group_ops_bls12381_gt_div_cost = Some(27804);
4005
4006 cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(2962);
4007 cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(8688);
4008
4009 cfg.group_ops_bls12381_g1_msm_base_cost = Some(62648);
4010 cfg.group_ops_bls12381_g2_msm_base_cost = Some(131192);
4011 cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(1333);
4012 cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(3216);
4013
4014 cfg.group_ops_bls12381_uncompressed_g1_to_g1_cost = Some(677);
4015 cfg.group_ops_bls12381_g1_to_uncompressed_g1_cost = Some(2099);
4016 cfg.group_ops_bls12381_uncompressed_g1_sum_base_cost = Some(77);
4017 cfg.group_ops_bls12381_uncompressed_g1_sum_cost_per_term = Some(26);
4018
4019 cfg.group_ops_bls12381_pairing_cost = Some(26897);
4020 cfg.group_ops_bls12381_uncompressed_g1_sum_max_terms = Some(1200);
4021
4022 cfg.validator_validate_metadata_cost_base = Some(20000);
4023 }
4024 71 => {
4025 cfg.sip_45_consensus_amplification_threshold = Some(5);
4026
4027 cfg.allowed_txn_cost_overage_burst_per_object_in_commit = Some(185_000_000);
4029 }
4030 72 => {
4031 cfg.feature_flags.convert_type_argument_error = true;
4032
4033 cfg.max_tx_gas = Some(50_000_000_000_000);
4036 cfg.max_gas_price = Some(50_000_000_000);
4038
4039 cfg.feature_flags.variant_nodes = true;
4040 }
4041 73 => {
4042 cfg.use_object_per_epoch_marker_table_v2 = Some(true);
4044
4045 if chain != Chain::Mainnet && chain != Chain::Testnet {
4046 cfg.consensus_gc_depth = Some(60);
4049 }
4050
4051 if chain != Chain::Mainnet {
4052 cfg.feature_flags.consensus_zstd_compression = true;
4054 }
4055
4056 cfg.feature_flags.consensus_smart_ancestor_selection = true;
4058 cfg.feature_flags
4060 .consensus_round_prober_probe_accepted_rounds = true;
4061
4062 cfg.feature_flags.per_object_congestion_control_mode =
4064 PerObjectCongestionControlMode::TotalGasBudgetWithCap;
4065 cfg.gas_budget_based_txn_cost_cap_factor = Some(400_000);
4066 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(37_000_000);
4067 cfg.max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit =
4068 Some(7_400_000); cfg.max_txn_cost_overage_per_object_in_commit = Some(u64::MAX);
4070 cfg.gas_budget_based_txn_cost_absolute_cap_commit_count = Some(50);
4071 cfg.allowed_txn_cost_overage_burst_per_object_in_commit = Some(370_000_000);
4072 }
4073 74 => {
4074 if chain != Chain::Mainnet && chain != Chain::Testnet {
4076 cfg.feature_flags.enable_nitro_attestation = true;
4077 }
4078 cfg.nitro_attestation_parse_base_cost = Some(53 * 50);
4079 cfg.nitro_attestation_parse_cost_per_byte = Some(50);
4080 cfg.nitro_attestation_verify_base_cost = Some(49632 * 50);
4081 cfg.nitro_attestation_verify_cost_per_cert = Some(52369 * 50);
4082
4083 cfg.feature_flags.consensus_zstd_compression = true;
4085
4086 if chain != Chain::Mainnet && chain != Chain::Testnet {
4087 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
4088 }
4089 }
4090 75 => {
4091 if chain != Chain::Mainnet {
4092 cfg.feature_flags.passkey_auth = true;
4093 }
4094 }
4095 76 => {
4096 if chain != Chain::Mainnet && chain != Chain::Testnet {
4097 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
4098 cfg.consensus_commit_rate_estimation_window_size = Some(10);
4099 }
4100 cfg.feature_flags.minimize_child_object_mutations = true;
4101
4102 if chain != Chain::Mainnet {
4103 cfg.feature_flags.accept_passkey_in_multisig = true;
4104 }
4105 }
4106 77 => {
4107 cfg.feature_flags.uncompressed_g1_group_elements = true;
4108
4109 if chain != Chain::Mainnet {
4110 cfg.consensus_gc_depth = Some(60);
4111 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
4112 }
4113 }
4114 78 => {
4115 cfg.feature_flags.move_native_context = true;
4116 cfg.tx_context_fresh_id_cost_base = Some(52);
4117 cfg.tx_context_sender_cost_base = Some(30);
4118 cfg.tx_context_epoch_cost_base = Some(30);
4119 cfg.tx_context_epoch_timestamp_ms_cost_base = Some(30);
4120 cfg.tx_context_sponsor_cost_base = Some(30);
4121 cfg.tx_context_gas_price_cost_base = Some(30);
4122 cfg.tx_context_gas_budget_cost_base = Some(30);
4123 cfg.tx_context_ids_created_cost_base = Some(30);
4124 cfg.tx_context_replace_cost_base = Some(30);
4125 cfg.gas_model_version = Some(10);
4126
4127 if chain != Chain::Mainnet {
4128 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
4129 cfg.consensus_commit_rate_estimation_window_size = Some(10);
4130
4131 cfg.feature_flags.per_object_congestion_control_mode =
4133 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4134 ExecutionTimeEstimateParams {
4135 target_utilization: 30,
4136 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4138 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4140 stored_observations_limit: u64::MAX,
4141 stake_weighted_median_threshold: 0,
4142 default_none_duration_for_new_keys: false,
4143 observations_chunk_size: None,
4144 },
4145 );
4146 }
4147 }
4148 79 => {
4149 if chain != Chain::Mainnet {
4150 cfg.feature_flags.consensus_median_based_commit_timestamp = true;
4151
4152 cfg.consensus_bad_nodes_stake_threshold = Some(30);
4155
4156 cfg.feature_flags.consensus_batched_block_sync = true;
4157
4158 cfg.feature_flags.enable_nitro_attestation = true
4160 }
4161 cfg.feature_flags.normalize_ptb_arguments = true;
4162
4163 cfg.consensus_gc_depth = Some(60);
4164 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
4165 }
4166 80 => {
4167 cfg.max_ptb_value_size = Some(1024 * 1024);
4168 }
4169 81 => {
4170 cfg.feature_flags.consensus_median_based_commit_timestamp = true;
4171 cfg.feature_flags.enforce_checkpoint_timestamp_monotonicity = true;
4172 cfg.consensus_bad_nodes_stake_threshold = Some(30)
4173 }
4174 82 => {
4175 cfg.feature_flags.max_ptb_value_size_v2 = true;
4176 }
4177 83 => {
4178 if chain == Chain::Mainnet {
4179 let aliased: [u8; 32] = Hex::decode(
4181 "0x0b2da327ba6a4cacbe75dddd50e6e8bbf81d6496e92d66af9154c61c77f7332f",
4182 )
4183 .unwrap()
4184 .try_into()
4185 .unwrap();
4186
4187 cfg.aliased_addresses.push(AliasedAddress {
4189 original: Hex::decode("0xcd8962dad278d8b50fa0f9eb0186bfa4cbdecc6d59377214c88d0286a0ac9562").unwrap().try_into().unwrap(),
4190 aliased,
4191 allowed_tx_digests: vec![
4192 Base58::decode("B2eGLFoMHgj93Ni8dAJBfqGzo8EWSTLBesZzhEpTPA4").unwrap().try_into().unwrap(),
4193 ],
4194 });
4195
4196 cfg.aliased_addresses.push(AliasedAddress {
4197 original: Hex::decode("0xe28b50cef1d633ea43d3296a3f6b67ff0312a5f1a99f0af753c85b8b5de8ff06").unwrap().try_into().unwrap(),
4198 aliased,
4199 allowed_tx_digests: vec![
4200 Base58::decode("J4QqSAgp7VrQtQpMy5wDX4QGsCSEZu3U5KuDAkbESAge").unwrap().try_into().unwrap(),
4201 ],
4202 });
4203 }
4204
4205 if chain != Chain::Mainnet {
4208 cfg.feature_flags.resolve_type_input_ids_to_defining_id = true;
4209 cfg.transfer_party_transfer_internal_cost_base = Some(52);
4210
4211 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
4213 cfg.consensus_commit_rate_estimation_window_size = Some(10);
4214 cfg.feature_flags.per_object_congestion_control_mode =
4215 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4216 ExecutionTimeEstimateParams {
4217 target_utilization: 30,
4218 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4220 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4222 stored_observations_limit: u64::MAX,
4223 stake_weighted_median_threshold: 0,
4224 default_none_duration_for_new_keys: false,
4225 observations_chunk_size: None,
4226 },
4227 );
4228
4229 cfg.feature_flags.consensus_batched_block_sync = true;
4231
4232 cfg.feature_flags.enable_nitro_attestation_upgraded_parsing = true;
4235 cfg.feature_flags.enable_nitro_attestation = true;
4236 }
4237 }
4238 84 => {
4239 if chain == Chain::Mainnet {
4240 cfg.feature_flags.resolve_type_input_ids_to_defining_id = true;
4241 cfg.transfer_party_transfer_internal_cost_base = Some(52);
4242
4243 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
4245 cfg.consensus_commit_rate_estimation_window_size = Some(10);
4246 cfg.feature_flags.per_object_congestion_control_mode =
4247 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4248 ExecutionTimeEstimateParams {
4249 target_utilization: 30,
4250 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4252 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4254 stored_observations_limit: u64::MAX,
4255 stake_weighted_median_threshold: 0,
4256 default_none_duration_for_new_keys: false,
4257 observations_chunk_size: None,
4258 },
4259 );
4260
4261 cfg.feature_flags.consensus_batched_block_sync = true;
4263
4264 cfg.feature_flags.enable_nitro_attestation_upgraded_parsing = true;
4267 cfg.feature_flags.enable_nitro_attestation = true;
4268 }
4269
4270 cfg.feature_flags.per_object_congestion_control_mode =
4272 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4273 ExecutionTimeEstimateParams {
4274 target_utilization: 30,
4275 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4277 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4279 stored_observations_limit: 20,
4280 stake_weighted_median_threshold: 0,
4281 default_none_duration_for_new_keys: false,
4282 observations_chunk_size: None,
4283 },
4284 );
4285 cfg.feature_flags.allow_unbounded_system_objects = true;
4286 }
4287 85 => {
4288 if chain != Chain::Mainnet && chain != Chain::Testnet {
4289 cfg.feature_flags.enable_party_transfer = true;
4290 }
4291
4292 cfg.feature_flags
4293 .record_consensus_determined_version_assignments_in_prologue_v2 = true;
4294 cfg.feature_flags.disallow_self_identifier = true;
4295 cfg.feature_flags.per_object_congestion_control_mode =
4296 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4297 ExecutionTimeEstimateParams {
4298 target_utilization: 50,
4299 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4301 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4303 stored_observations_limit: 20,
4304 stake_weighted_median_threshold: 0,
4305 default_none_duration_for_new_keys: false,
4306 observations_chunk_size: None,
4307 },
4308 );
4309 }
4310 86 => {
4311 cfg.feature_flags.type_tags_in_object_runtime = true;
4312 cfg.max_move_enum_variants = Some(move_core_types::VARIANT_COUNT_MAX);
4313
4314 cfg.feature_flags.per_object_congestion_control_mode =
4316 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4317 ExecutionTimeEstimateParams {
4318 target_utilization: 50,
4319 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4321 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4323 stored_observations_limit: 20,
4324 stake_weighted_median_threshold: 3334,
4325 default_none_duration_for_new_keys: false,
4326 observations_chunk_size: None,
4327 },
4328 );
4329 if chain != Chain::Mainnet {
4331 cfg.feature_flags.enable_party_transfer = true;
4332 }
4333 }
4334 87 => {
4335 if chain == Chain::Mainnet {
4336 cfg.feature_flags.record_time_estimate_processed = true;
4337 }
4338 cfg.feature_flags.better_adapter_type_resolution_errors = true;
4339 }
4340 88 => {
4341 cfg.feature_flags.record_time_estimate_processed = true;
4342 cfg.tx_context_rgp_cost_base = Some(30);
4343 cfg.feature_flags
4344 .ignore_execution_time_observations_after_certs_closed = true;
4345
4346 cfg.feature_flags.per_object_congestion_control_mode =
4349 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4350 ExecutionTimeEstimateParams {
4351 target_utilization: 50,
4352 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4354 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4356 stored_observations_limit: 20,
4357 stake_weighted_median_threshold: 3334,
4358 default_none_duration_for_new_keys: true,
4359 observations_chunk_size: None,
4360 },
4361 );
4362 }
4363 89 => {
4364 cfg.feature_flags.dependency_linkage_error = true;
4365 cfg.feature_flags.additional_multisig_checks = true;
4366 }
4367 90 => {
4368 cfg.max_gas_price_rgp_factor_for_aborted_transactions = Some(100);
4370 cfg.feature_flags.debug_fatal_on_move_invariant_violation = true;
4371 cfg.feature_flags.additional_consensus_digest_indirect_state = true;
4372 cfg.feature_flags.accept_passkey_in_multisig = true;
4373 cfg.feature_flags.passkey_auth = true;
4374 cfg.feature_flags.check_for_init_during_upgrade = true;
4375
4376 if chain != Chain::Mainnet {
4378 cfg.feature_flags.mysticeti_fastpath = true;
4379 }
4380 }
4381 91 => {
4382 cfg.feature_flags.per_command_shared_object_transfer_rules = true;
4383 }
4384 92 => {
4385 cfg.feature_flags.per_command_shared_object_transfer_rules = false;
4386 }
4387 93 => {
4388 cfg.feature_flags
4389 .consensus_checkpoint_signature_key_includes_digest = true;
4390 }
4391 94 => {
4392 cfg.feature_flags.per_object_congestion_control_mode =
4394 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4395 ExecutionTimeEstimateParams {
4396 target_utilization: 50,
4397 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4399 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4401 stored_observations_limit: 18,
4402 stake_weighted_median_threshold: 3334,
4403 default_none_duration_for_new_keys: true,
4404 observations_chunk_size: None,
4405 },
4406 );
4407
4408 cfg.feature_flags.enable_party_transfer = true;
4410 }
4411 95 => {
4412 cfg.type_name_id_base_cost = Some(52);
4413
4414 cfg.max_transactions_per_checkpoint = Some(20_000);
4416 }
4417 96 => {
4418 if chain != Chain::Mainnet && chain != Chain::Testnet {
4420 cfg.feature_flags
4421 .include_checkpoint_artifacts_digest_in_summary = true;
4422 }
4423 cfg.feature_flags.correct_gas_payment_limit_check = true;
4424 cfg.feature_flags.authority_capabilities_v2 = true;
4425 cfg.feature_flags.use_mfp_txns_in_load_initial_object_debts = true;
4426 cfg.feature_flags.cancel_for_failed_dkg_early = true;
4427 cfg.feature_flags.enable_coin_registry = true;
4428
4429 cfg.feature_flags.mysticeti_fastpath = true;
4431 }
4432 97 => {
4433 cfg.feature_flags.additional_borrow_checks = true;
4434 }
4435 98 => {
4436 cfg.event_emit_auth_stream_cost = Some(52);
4437 cfg.feature_flags.better_loader_errors = true;
4438 cfg.feature_flags.generate_df_type_layouts = true;
4439 }
4440 99 => {
4441 cfg.feature_flags.use_new_commit_handler = true;
4442 }
4443 100 => {
4444 cfg.feature_flags.private_generics_verifier_v2 = true;
4445 }
4446 101 => {
4447 cfg.feature_flags.create_root_accumulator_object = true;
4448 cfg.max_updates_per_settlement_txn = Some(100);
4449 if chain != Chain::Mainnet {
4450 cfg.feature_flags.enable_poseidon = true;
4451 }
4452 }
4453 102 => {
4454 cfg.feature_flags.per_object_congestion_control_mode =
4458 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4459 ExecutionTimeEstimateParams {
4460 target_utilization: 50,
4461 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4463 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4465 stored_observations_limit: 180,
4466 stake_weighted_median_threshold: 3334,
4467 default_none_duration_for_new_keys: true,
4468 observations_chunk_size: Some(18),
4469 },
4470 );
4471 cfg.feature_flags.deprecate_global_storage_ops = true;
4472 }
4473 103 => {}
4474 104 => {
4475 cfg.translation_per_command_base_charge = Some(1);
4476 cfg.translation_per_input_base_charge = Some(1);
4477 cfg.translation_pure_input_per_byte_charge = Some(1);
4478 cfg.translation_per_type_node_charge = Some(1);
4479 cfg.translation_per_reference_node_charge = Some(1);
4480 cfg.translation_per_linkage_entry_charge = Some(10);
4481 cfg.gas_model_version = Some(11);
4482 cfg.feature_flags.abstract_size_in_object_runtime = true;
4483 cfg.feature_flags.object_runtime_charge_cache_load_gas = true;
4484 cfg.dynamic_field_hash_type_and_key_cost_base = Some(52);
4485 cfg.dynamic_field_add_child_object_cost_base = Some(52);
4486 cfg.dynamic_field_add_child_object_value_cost_per_byte = Some(1);
4487 cfg.dynamic_field_borrow_child_object_cost_base = Some(52);
4488 cfg.dynamic_field_borrow_child_object_child_ref_cost_per_byte = Some(1);
4489 cfg.dynamic_field_remove_child_object_cost_base = Some(52);
4490 cfg.dynamic_field_remove_child_object_child_cost_per_byte = Some(1);
4491 cfg.dynamic_field_has_child_object_cost_base = Some(52);
4492 cfg.dynamic_field_has_child_object_with_ty_cost_base = Some(52);
4493 cfg.feature_flags.enable_ptb_execution_v2 = true;
4494
4495 cfg.poseidon_bn254_cost_base = Some(260);
4496
4497 cfg.feature_flags.consensus_skip_gced_accept_votes = true;
4498
4499 if chain != Chain::Mainnet {
4500 cfg.feature_flags
4501 .enable_nitro_attestation_all_nonzero_pcrs_parsing = true;
4502 }
4503
4504 cfg.feature_flags
4505 .include_cancelled_randomness_txns_in_prologue = true;
4506 }
4507 105 => {
4508 cfg.feature_flags.enable_multi_epoch_transaction_expiration = true;
4509 cfg.feature_flags.disable_preconsensus_locking = true;
4510
4511 if chain != Chain::Mainnet {
4512 cfg.feature_flags
4513 .enable_nitro_attestation_always_include_required_pcrs_parsing = true;
4514 }
4515 }
4516 106 => {
4517 cfg.accumulator_object_storage_cost = Some(7600);
4519
4520 if chain != Chain::Mainnet && chain != Chain::Testnet {
4521 cfg.feature_flags.enable_accumulators = true;
4522 cfg.feature_flags.enable_address_balance_gas_payments = true;
4523 cfg.feature_flags.enable_authenticated_event_streams = true;
4524 cfg.feature_flags.enable_object_funds_withdraw = true;
4525 }
4526 }
4527 107 => {
4528 cfg.feature_flags
4529 .consensus_skip_gced_blocks_in_direct_finalization = true;
4530
4531 if in_integration_test() {
4533 cfg.consensus_gc_depth = Some(6);
4534 cfg.consensus_max_num_transactions_in_block = Some(8);
4535 }
4536 }
4537 108 => {
4538 cfg.feature_flags.gas_rounding_halve_digits = true;
4539 cfg.feature_flags.flexible_tx_context_positions = true;
4540 cfg.feature_flags.disable_entry_point_signature_check = true;
4541
4542 if chain != Chain::Mainnet {
4543 cfg.feature_flags.address_aliases = true;
4544
4545 cfg.feature_flags.enable_accumulators = true;
4546 cfg.feature_flags.enable_address_balance_gas_payments = true;
4547 }
4548
4549 cfg.feature_flags.enable_poseidon = true;
4550 }
4551 109 => {
4552 cfg.binary_variant_handles = Some(1024);
4553 cfg.binary_variant_instantiation_handles = Some(1024);
4554 cfg.feature_flags.restrict_hot_or_not_entry_functions = true;
4555 }
4556 110 => {
4557 cfg.feature_flags
4558 .enable_nitro_attestation_all_nonzero_pcrs_parsing = true;
4559 cfg.feature_flags
4560 .enable_nitro_attestation_always_include_required_pcrs_parsing = true;
4561 if chain != Chain::Mainnet && chain != Chain::Testnet {
4562 cfg.feature_flags.split_checkpoints_in_consensus_handler = true;
4563 }
4564 cfg.feature_flags.validate_zklogin_public_identifier = true;
4565 cfg.feature_flags.fix_checkpoint_signature_mapping = true;
4566 cfg.feature_flags
4567 .consensus_always_accept_system_transactions = true;
4568 if chain != Chain::Mainnet {
4569 cfg.feature_flags.enable_object_funds_withdraw = true;
4570 }
4571 }
4572 111 => {
4573 cfg.feature_flags.validator_metadata_verify_v2 = true;
4574 }
4575 112 => {
4576 cfg.group_ops_ristretto_decode_scalar_cost = Some(7);
4577 cfg.group_ops_ristretto_decode_point_cost = Some(200);
4578 cfg.group_ops_ristretto_scalar_add_cost = Some(10);
4579 cfg.group_ops_ristretto_point_add_cost = Some(500);
4580 cfg.group_ops_ristretto_scalar_sub_cost = Some(10);
4581 cfg.group_ops_ristretto_point_sub_cost = Some(500);
4582 cfg.group_ops_ristretto_scalar_mul_cost = Some(11);
4583 cfg.group_ops_ristretto_point_mul_cost = Some(1200);
4584 cfg.group_ops_ristretto_scalar_div_cost = Some(151);
4585 cfg.group_ops_ristretto_point_div_cost = Some(2500);
4586
4587 if chain != Chain::Mainnet && chain != Chain::Testnet {
4588 cfg.feature_flags.enable_ristretto255_group_ops = true;
4589 }
4590 }
4591 _ => panic!("unsupported version {:?}", version),
4602 }
4603 }
4604
4605 if cfg!(msim) {
4607 }
4612
4613 cfg
4614 }
4615
4616 pub fn verifier_config(&self, signing_limits: Option<(usize, usize, usize)>) -> VerifierConfig {
4622 let (
4623 max_back_edges_per_function,
4624 max_back_edges_per_module,
4625 sanity_check_with_regex_reference_safety,
4626 ) = if let Some((
4627 max_back_edges_per_function,
4628 max_back_edges_per_module,
4629 sanity_check_with_regex_reference_safety,
4630 )) = signing_limits
4631 {
4632 (
4633 Some(max_back_edges_per_function),
4634 Some(max_back_edges_per_module),
4635 Some(sanity_check_with_regex_reference_safety),
4636 )
4637 } else {
4638 (None, None, None)
4639 };
4640
4641 let additional_borrow_checks = if signing_limits.is_some() {
4642 true
4644 } else {
4645 self.additional_borrow_checks()
4646 };
4647 let deprecate_global_storage_ops = if signing_limits.is_some() {
4648 true
4650 } else {
4651 self.deprecate_global_storage_ops()
4652 };
4653
4654 VerifierConfig {
4655 max_loop_depth: Some(self.max_loop_depth() as usize),
4656 max_generic_instantiation_length: Some(self.max_generic_instantiation_length() as usize),
4657 max_function_parameters: Some(self.max_function_parameters() as usize),
4658 max_basic_blocks: Some(self.max_basic_blocks() as usize),
4659 max_value_stack_size: self.max_value_stack_size() as usize,
4660 max_type_nodes: Some(self.max_type_nodes() as usize),
4661 max_push_size: Some(self.max_push_size() as usize),
4662 max_dependency_depth: Some(self.max_dependency_depth() as usize),
4663 max_fields_in_struct: Some(self.max_fields_in_struct() as usize),
4664 max_function_definitions: Some(self.max_function_definitions() as usize),
4665 max_data_definitions: Some(self.max_struct_definitions() as usize),
4666 max_constant_vector_len: Some(self.max_move_vector_len()),
4667 max_back_edges_per_function,
4668 max_back_edges_per_module,
4669 max_basic_blocks_in_script: None,
4670 max_identifier_len: self.max_move_identifier_len_as_option(), disallow_self_identifier: self.feature_flags.disallow_self_identifier,
4672 allow_receiving_object_id: self.allow_receiving_object_id(),
4673 reject_mutable_random_on_entry_functions: self
4674 .reject_mutable_random_on_entry_functions(),
4675 bytecode_version: self.move_binary_format_version(),
4676 max_variants_in_enum: self.max_move_enum_variants_as_option(),
4677 additional_borrow_checks,
4678 better_loader_errors: self.better_loader_errors(),
4679 private_generics_verifier_v2: self.private_generics_verifier_v2(),
4680 sanity_check_with_regex_reference_safety: sanity_check_with_regex_reference_safety
4681 .map(|limit| limit as u128),
4682 deprecate_global_storage_ops,
4683 disable_entry_point_signature_check: self.disable_entry_point_signature_check(),
4684 switch_to_regex_reference_safety: false,
4685 }
4686 }
4687
4688 pub fn binary_config(
4689 &self,
4690 override_deprecate_global_storage_ops_during_deserialization: Option<bool>,
4691 ) -> BinaryConfig {
4692 let deprecate_global_storage_ops =
4693 override_deprecate_global_storage_ops_during_deserialization
4694 .unwrap_or_else(|| self.deprecate_global_storage_ops());
4695 BinaryConfig::new(
4696 self.move_binary_format_version(),
4697 self.min_move_binary_format_version_as_option()
4698 .unwrap_or(VERSION_1),
4699 self.no_extraneous_module_bytes(),
4700 deprecate_global_storage_ops,
4701 TableConfig {
4702 module_handles: self.binary_module_handles_as_option().unwrap_or(u16::MAX),
4703 datatype_handles: self.binary_struct_handles_as_option().unwrap_or(u16::MAX),
4704 function_handles: self.binary_function_handles_as_option().unwrap_or(u16::MAX),
4705 function_instantiations: self
4706 .binary_function_instantiations_as_option()
4707 .unwrap_or(u16::MAX),
4708 signatures: self.binary_signatures_as_option().unwrap_or(u16::MAX),
4709 constant_pool: self.binary_constant_pool_as_option().unwrap_or(u16::MAX),
4710 identifiers: self.binary_identifiers_as_option().unwrap_or(u16::MAX),
4711 address_identifiers: self
4712 .binary_address_identifiers_as_option()
4713 .unwrap_or(u16::MAX),
4714 struct_defs: self.binary_struct_defs_as_option().unwrap_or(u16::MAX),
4715 struct_def_instantiations: self
4716 .binary_struct_def_instantiations_as_option()
4717 .unwrap_or(u16::MAX),
4718 function_defs: self.binary_function_defs_as_option().unwrap_or(u16::MAX),
4719 field_handles: self.binary_field_handles_as_option().unwrap_or(u16::MAX),
4720 field_instantiations: self
4721 .binary_field_instantiations_as_option()
4722 .unwrap_or(u16::MAX),
4723 friend_decls: self.binary_friend_decls_as_option().unwrap_or(u16::MAX),
4724 enum_defs: self.binary_enum_defs_as_option().unwrap_or(u16::MAX),
4725 enum_def_instantiations: self
4726 .binary_enum_def_instantiations_as_option()
4727 .unwrap_or(u16::MAX),
4728 variant_handles: self.binary_variant_handles_as_option().unwrap_or(u16::MAX),
4729 variant_instantiation_handles: self
4730 .binary_variant_instantiation_handles_as_option()
4731 .unwrap_or(u16::MAX),
4732 },
4733 )
4734 }
4735
4736 pub fn apply_overrides_for_testing(
4740 override_fn: impl Fn(ProtocolVersion, Self) -> Self + Send + 'static,
4741 ) -> OverrideGuard {
4742 CONFIG_OVERRIDE.with(|ovr| {
4743 let mut cur = ovr.borrow_mut();
4744 assert!(cur.is_none(), "config override already present");
4745 *cur = Some(Box::new(override_fn));
4746 OverrideGuard
4747 })
4748 }
4749}
4750
4751impl ProtocolConfig {
4755 pub fn set_advance_to_highest_supported_protocol_version_for_testing(&mut self, val: bool) {
4756 self.feature_flags
4757 .advance_to_highest_supported_protocol_version = val
4758 }
4759 pub fn set_commit_root_state_digest_supported_for_testing(&mut self, val: bool) {
4760 self.feature_flags.commit_root_state_digest = val
4761 }
4762 pub fn set_zklogin_auth_for_testing(&mut self, val: bool) {
4763 self.feature_flags.zklogin_auth = val
4764 }
4765 pub fn set_enable_jwk_consensus_updates_for_testing(&mut self, val: bool) {
4766 self.feature_flags.enable_jwk_consensus_updates = val
4767 }
4768 pub fn set_random_beacon_for_testing(&mut self, val: bool) {
4769 self.feature_flags.random_beacon = val
4770 }
4771
4772 pub fn set_upgraded_multisig_for_testing(&mut self, val: bool) {
4773 self.feature_flags.upgraded_multisig_supported = val
4774 }
4775 pub fn set_accept_zklogin_in_multisig_for_testing(&mut self, val: bool) {
4776 self.feature_flags.accept_zklogin_in_multisig = val
4777 }
4778
4779 pub fn set_shared_object_deletion_for_testing(&mut self, val: bool) {
4780 self.feature_flags.shared_object_deletion = val;
4781 }
4782
4783 pub fn set_narwhal_new_leader_election_schedule_for_testing(&mut self, val: bool) {
4784 self.feature_flags.narwhal_new_leader_election_schedule = val;
4785 }
4786
4787 pub fn set_receive_object_for_testing(&mut self, val: bool) {
4788 self.feature_flags.receive_objects = val
4789 }
4790 pub fn set_narwhal_certificate_v2_for_testing(&mut self, val: bool) {
4791 self.feature_flags.narwhal_certificate_v2 = val
4792 }
4793 pub fn set_verify_legacy_zklogin_address_for_testing(&mut self, val: bool) {
4794 self.feature_flags.verify_legacy_zklogin_address = val
4795 }
4796
4797 pub fn set_per_object_congestion_control_mode_for_testing(
4798 &mut self,
4799 val: PerObjectCongestionControlMode,
4800 ) {
4801 self.feature_flags.per_object_congestion_control_mode = val;
4802 }
4803
4804 pub fn set_consensus_choice_for_testing(&mut self, val: ConsensusChoice) {
4805 self.feature_flags.consensus_choice = val;
4806 }
4807
4808 pub fn set_consensus_network_for_testing(&mut self, val: ConsensusNetwork) {
4809 self.feature_flags.consensus_network = val;
4810 }
4811
4812 pub fn set_zklogin_max_epoch_upper_bound_delta_for_testing(&mut self, val: Option<u64>) {
4813 self.feature_flags.zklogin_max_epoch_upper_bound_delta = val
4814 }
4815
4816 pub fn set_disable_bridge_for_testing(&mut self) {
4817 self.feature_flags.bridge = false
4818 }
4819
4820 pub fn set_mysticeti_num_leaders_per_round_for_testing(&mut self, val: Option<usize>) {
4821 self.feature_flags.mysticeti_num_leaders_per_round = val;
4822 }
4823
4824 pub fn set_enable_soft_bundle_for_testing(&mut self, val: bool) {
4825 self.feature_flags.soft_bundle = val;
4826 }
4827
4828 pub fn set_passkey_auth_for_testing(&mut self, val: bool) {
4829 self.feature_flags.passkey_auth = val
4830 }
4831
4832 pub fn set_enable_party_transfer_for_testing(&mut self, val: bool) {
4833 self.feature_flags.enable_party_transfer = val
4834 }
4835
4836 pub fn set_consensus_distributed_vote_scoring_strategy_for_testing(&mut self, val: bool) {
4837 self.feature_flags
4838 .consensus_distributed_vote_scoring_strategy = val;
4839 }
4840
4841 pub fn set_consensus_round_prober_for_testing(&mut self, val: bool) {
4842 self.feature_flags.consensus_round_prober = val;
4843 }
4844
4845 pub fn set_disallow_new_modules_in_deps_only_packages_for_testing(&mut self, val: bool) {
4846 self.feature_flags
4847 .disallow_new_modules_in_deps_only_packages = val;
4848 }
4849
4850 pub fn set_correct_gas_payment_limit_check_for_testing(&mut self, val: bool) {
4851 self.feature_flags.correct_gas_payment_limit_check = val;
4852 }
4853
4854 pub fn set_address_aliases_for_testing(&mut self, val: bool) {
4855 self.feature_flags.address_aliases = val;
4856 }
4857
4858 pub fn set_consensus_round_prober_probe_accepted_rounds(&mut self, val: bool) {
4859 self.feature_flags
4860 .consensus_round_prober_probe_accepted_rounds = val;
4861 }
4862
4863 pub fn set_mysticeti_fastpath_for_testing(&mut self, val: bool) {
4864 self.feature_flags.mysticeti_fastpath = val;
4865 }
4866
4867 pub fn set_accept_passkey_in_multisig_for_testing(&mut self, val: bool) {
4868 self.feature_flags.accept_passkey_in_multisig = val;
4869 }
4870
4871 pub fn set_consensus_batched_block_sync_for_testing(&mut self, val: bool) {
4872 self.feature_flags.consensus_batched_block_sync = val;
4873 }
4874
4875 pub fn set_record_time_estimate_processed_for_testing(&mut self, val: bool) {
4876 self.feature_flags.record_time_estimate_processed = val;
4877 }
4878
4879 pub fn set_prepend_prologue_tx_in_consensus_commit_in_checkpoints_for_testing(
4880 &mut self,
4881 val: bool,
4882 ) {
4883 self.feature_flags
4884 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = val;
4885 }
4886
4887 pub fn enable_accumulators_for_testing(&mut self) {
4888 self.feature_flags.enable_accumulators = true;
4889 }
4890
4891 pub fn disable_accumulators_for_testing(&mut self) {
4892 self.feature_flags.enable_accumulators = false;
4893 self.feature_flags.enable_address_balance_gas_payments = false;
4894 }
4895
4896 pub fn enable_coin_reservation_for_testing(&mut self) {
4897 self.feature_flags.enable_coin_reservation_obj_refs = true;
4898 }
4899
4900 pub fn create_root_accumulator_object_for_testing(&mut self) {
4901 self.feature_flags.create_root_accumulator_object = true;
4902 }
4903
4904 pub fn disable_create_root_accumulator_object_for_testing(&mut self) {
4905 self.feature_flags.create_root_accumulator_object = false;
4906 }
4907
4908 pub fn enable_address_balance_gas_payments_for_testing(&mut self) {
4909 self.feature_flags.enable_accumulators = true;
4910 self.feature_flags.allow_private_accumulator_entrypoints = true;
4911 self.feature_flags.enable_address_balance_gas_payments = true;
4912 }
4913
4914 pub fn disable_address_balance_gas_payments_for_testing(&mut self) {
4915 self.feature_flags.enable_address_balance_gas_payments = false;
4916 }
4917
4918 pub fn enable_multi_epoch_transaction_expiration_for_testing(&mut self) {
4919 self.feature_flags.enable_multi_epoch_transaction_expiration = true;
4920 }
4921
4922 pub fn enable_authenticated_event_streams_for_testing(&mut self) {
4923 self.enable_accumulators_for_testing();
4924 self.feature_flags.enable_authenticated_event_streams = true;
4925 self.feature_flags
4926 .include_checkpoint_artifacts_digest_in_summary = true;
4927 }
4928
4929 pub fn disable_authenticated_event_streams_for_testing(&mut self) {
4930 self.feature_flags.enable_authenticated_event_streams = false;
4931 }
4932
4933 pub fn enable_non_exclusive_writes_for_testing(&mut self) {
4934 self.feature_flags.enable_non_exclusive_writes = true;
4935 }
4936
4937 pub fn set_ignore_execution_time_observations_after_certs_closed_for_testing(
4938 &mut self,
4939 val: bool,
4940 ) {
4941 self.feature_flags
4942 .ignore_execution_time_observations_after_certs_closed = val;
4943 }
4944
4945 pub fn set_consensus_checkpoint_signature_key_includes_digest_for_testing(
4946 &mut self,
4947 val: bool,
4948 ) {
4949 self.feature_flags
4950 .consensus_checkpoint_signature_key_includes_digest = val;
4951 }
4952
4953 pub fn set_cancel_for_failed_dkg_early_for_testing(&mut self, val: bool) {
4954 self.feature_flags.cancel_for_failed_dkg_early = val;
4955 }
4956
4957 pub fn set_use_mfp_txns_in_load_initial_object_debts_for_testing(&mut self, val: bool) {
4958 self.feature_flags.use_mfp_txns_in_load_initial_object_debts = val;
4959 }
4960
4961 pub fn set_authority_capabilities_v2_for_testing(&mut self, val: bool) {
4962 self.feature_flags.authority_capabilities_v2 = val;
4963 }
4964
4965 pub fn allow_references_in_ptbs_for_testing(&mut self) {
4966 self.feature_flags.allow_references_in_ptbs = true;
4967 }
4968
4969 pub fn set_consensus_skip_gced_accept_votes_for_testing(&mut self, val: bool) {
4970 self.feature_flags.consensus_skip_gced_accept_votes = val;
4971 }
4972
4973 pub fn set_enable_object_funds_withdraw_for_testing(&mut self, val: bool) {
4974 self.feature_flags.enable_object_funds_withdraw = val;
4975 }
4976
4977 pub fn set_split_checkpoints_in_consensus_handler_for_testing(&mut self, val: bool) {
4978 self.feature_flags.split_checkpoints_in_consensus_handler = val;
4979 }
4980}
4981
4982type OverrideFn = dyn Fn(ProtocolVersion, ProtocolConfig) -> ProtocolConfig + Send;
4983
4984thread_local! {
4985 static CONFIG_OVERRIDE: RefCell<Option<Box<OverrideFn>>> = RefCell::new(None);
4986}
4987
4988#[must_use]
4989pub struct OverrideGuard;
4990
4991impl Drop for OverrideGuard {
4992 fn drop(&mut self) {
4993 info!("restoring override fn");
4994 CONFIG_OVERRIDE.with(|ovr| {
4995 *ovr.borrow_mut() = None;
4996 });
4997 }
4998}
4999
5000#[derive(PartialEq, Eq)]
5003pub enum LimitThresholdCrossed {
5004 None,
5005 Soft(u128, u128),
5006 Hard(u128, u128),
5007}
5008
5009pub fn check_limit_in_range<T: Into<V>, U: Into<V>, V: PartialOrd + Into<u128>>(
5012 x: T,
5013 soft_limit: U,
5014 hard_limit: V,
5015) -> LimitThresholdCrossed {
5016 let x: V = x.into();
5017 let soft_limit: V = soft_limit.into();
5018
5019 debug_assert!(soft_limit <= hard_limit);
5020
5021 if x >= hard_limit {
5024 LimitThresholdCrossed::Hard(x.into(), hard_limit.into())
5025 } else if x < soft_limit {
5026 LimitThresholdCrossed::None
5027 } else {
5028 LimitThresholdCrossed::Soft(x.into(), soft_limit.into())
5029 }
5030}
5031
5032#[macro_export]
5033macro_rules! check_limit {
5034 ($x:expr, $hard:expr) => {
5035 check_limit!($x, $hard, $hard)
5036 };
5037 ($x:expr, $soft:expr, $hard:expr) => {
5038 check_limit_in_range($x as u64, $soft, $hard)
5039 };
5040}
5041
5042#[macro_export]
5046macro_rules! check_limit_by_meter {
5047 ($is_metered:expr, $x:expr, $metered_limit:expr, $unmetered_hard_limit:expr, $metric:expr) => {{
5048 let (h, metered_str) = if $is_metered {
5050 ($metered_limit, "metered")
5051 } else {
5052 ($unmetered_hard_limit, "unmetered")
5054 };
5055 use sui_protocol_config::check_limit_in_range;
5056 let result = check_limit_in_range($x as u64, $metered_limit, h);
5057 match result {
5058 LimitThresholdCrossed::None => {}
5059 LimitThresholdCrossed::Soft(_, _) => {
5060 $metric.with_label_values(&[metered_str, "soft"]).inc();
5061 }
5062 LimitThresholdCrossed::Hard(_, _) => {
5063 $metric.with_label_values(&[metered_str, "hard"]).inc();
5064 }
5065 };
5066 result
5067 }};
5068}
5069#[cfg(all(test, not(msim)))]
5070mod test {
5071 use insta::assert_yaml_snapshot;
5072
5073 use super::*;
5074
5075 #[test]
5076 fn snapshot_tests() {
5077 println!("\n============================================================================");
5078 println!("! !");
5079 println!("! IMPORTANT: never update snapshots from this test. only add new versions! !");
5080 println!("! !");
5081 println!("============================================================================\n");
5082 for chain_id in &[Chain::Unknown, Chain::Mainnet, Chain::Testnet] {
5083 let chain_str = match chain_id {
5087 Chain::Unknown => "".to_string(),
5088 _ => format!("{:?}_", chain_id),
5089 };
5090 for i in MIN_PROTOCOL_VERSION..=MAX_PROTOCOL_VERSION {
5091 let cur = ProtocolVersion::new(i);
5092 assert_yaml_snapshot!(
5093 format!("{}version_{}", chain_str, cur.as_u64()),
5094 ProtocolConfig::get_for_version(cur, *chain_id)
5095 );
5096 }
5097 }
5098 }
5099
5100 #[test]
5101 fn test_getters() {
5102 let prot: ProtocolConfig =
5103 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5104 assert_eq!(
5105 prot.max_arguments(),
5106 prot.max_arguments_as_option().unwrap()
5107 );
5108 }
5109
5110 #[test]
5111 fn test_setters() {
5112 let mut prot: ProtocolConfig =
5113 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5114 prot.set_max_arguments_for_testing(123);
5115 assert_eq!(prot.max_arguments(), 123);
5116
5117 prot.set_max_arguments_from_str_for_testing("321".to_string());
5118 assert_eq!(prot.max_arguments(), 321);
5119
5120 prot.disable_max_arguments_for_testing();
5121 assert_eq!(prot.max_arguments_as_option(), None);
5122
5123 prot.set_attr_for_testing("max_arguments".to_string(), "456".to_string());
5124 assert_eq!(prot.max_arguments(), 456);
5125 }
5126
5127 #[test]
5128 #[should_panic(expected = "unsupported version")]
5129 fn max_version_test() {
5130 let _ = ProtocolConfig::get_for_version_impl(
5133 ProtocolVersion::new(MAX_PROTOCOL_VERSION + 1),
5134 Chain::Unknown,
5135 );
5136 }
5137
5138 #[test]
5139 fn lookup_by_string_test() {
5140 let prot: ProtocolConfig =
5141 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5142 assert!(prot.lookup_attr("some random string".to_string()).is_none());
5144
5145 assert!(
5146 prot.lookup_attr("max_arguments".to_string())
5147 == Some(ProtocolConfigValue::u32(prot.max_arguments())),
5148 );
5149
5150 assert!(
5152 prot.lookup_attr("max_move_identifier_len".to_string())
5153 .is_none()
5154 );
5155
5156 let prot: ProtocolConfig =
5158 ProtocolConfig::get_for_version(ProtocolVersion::new(9), Chain::Unknown);
5159 assert!(
5160 prot.lookup_attr("max_move_identifier_len".to_string())
5161 == Some(ProtocolConfigValue::u64(prot.max_move_identifier_len()))
5162 );
5163
5164 let prot: ProtocolConfig =
5165 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5166 assert!(
5168 prot.attr_map()
5169 .get("max_move_identifier_len")
5170 .unwrap()
5171 .is_none()
5172 );
5173 assert!(
5175 prot.attr_map().get("max_arguments").unwrap()
5176 == &Some(ProtocolConfigValue::u32(prot.max_arguments()))
5177 );
5178
5179 let prot: ProtocolConfig =
5181 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5182 assert!(
5184 prot.feature_flags
5185 .lookup_attr("some random string".to_owned())
5186 .is_none()
5187 );
5188 assert!(
5189 !prot
5190 .feature_flags
5191 .attr_map()
5192 .contains_key("some random string")
5193 );
5194
5195 assert!(
5197 prot.feature_flags
5198 .lookup_attr("package_upgrades".to_owned())
5199 == Some(false)
5200 );
5201 assert!(
5202 prot.feature_flags
5203 .attr_map()
5204 .get("package_upgrades")
5205 .unwrap()
5206 == &false
5207 );
5208 let prot: ProtocolConfig =
5209 ProtocolConfig::get_for_version(ProtocolVersion::new(4), Chain::Unknown);
5210 assert!(
5212 prot.feature_flags
5213 .lookup_attr("package_upgrades".to_owned())
5214 == Some(true)
5215 );
5216 assert!(
5217 prot.feature_flags
5218 .attr_map()
5219 .get("package_upgrades")
5220 .unwrap()
5221 == &true
5222 );
5223 }
5224
5225 #[test]
5226 fn limit_range_fn_test() {
5227 let low = 100u32;
5228 let high = 10000u64;
5229
5230 assert!(check_limit!(1u8, low, high) == LimitThresholdCrossed::None);
5231 assert!(matches!(
5232 check_limit!(255u16, low, high),
5233 LimitThresholdCrossed::Soft(255u128, 100)
5234 ));
5235 assert!(matches!(
5241 check_limit!(2550000u64, low, high),
5242 LimitThresholdCrossed::Hard(2550000, 10000)
5243 ));
5244
5245 assert!(matches!(
5246 check_limit!(2550000u64, high, high),
5247 LimitThresholdCrossed::Hard(2550000, 10000)
5248 ));
5249
5250 assert!(matches!(
5251 check_limit!(1u8, high),
5252 LimitThresholdCrossed::None
5253 ));
5254
5255 assert!(check_limit!(255u16, high) == LimitThresholdCrossed::None);
5256
5257 assert!(matches!(
5258 check_limit!(2550000u64, high),
5259 LimitThresholdCrossed::Hard(2550000, 10000)
5260 ));
5261 }
5262}