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 = 115;
28
29#[derive(Copy, Clone, Debug, Hash, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)]
307pub struct ProtocolVersion(u64);
308
309impl ProtocolVersion {
310 pub const MIN: Self = Self(MIN_PROTOCOL_VERSION);
315
316 pub const MAX: Self = Self(MAX_PROTOCOL_VERSION);
317
318 #[cfg(not(msim))]
319 pub const MAX_ALLOWED: Self = Self::MAX;
320
321 #[cfg(msim)]
323 pub const MAX_ALLOWED: Self = Self(MAX_PROTOCOL_VERSION + 1);
324
325 pub fn new(v: u64) -> Self {
326 Self(v)
327 }
328
329 pub const fn as_u64(&self) -> u64 {
330 self.0
331 }
332
333 pub fn max() -> Self {
336 Self::MAX
337 }
338
339 pub fn prev(self) -> Self {
340 Self(self.0.checked_sub(1).unwrap())
341 }
342}
343
344impl From<u64> for ProtocolVersion {
345 fn from(v: u64) -> Self {
346 Self::new(v)
347 }
348}
349
350impl std::ops::Sub<u64> for ProtocolVersion {
351 type Output = Self;
352 fn sub(self, rhs: u64) -> Self::Output {
353 Self::new(self.0 - rhs)
354 }
355}
356
357impl std::ops::Add<u64> for ProtocolVersion {
358 type Output = Self;
359 fn add(self, rhs: u64) -> Self::Output {
360 Self::new(self.0 + rhs)
361 }
362}
363
364#[derive(
365 Clone, Serialize, Deserialize, Debug, Default, PartialEq, Copy, PartialOrd, Ord, Eq, ValueEnum,
366)]
367pub enum Chain {
368 Mainnet,
369 Testnet,
370 #[default]
371 Unknown,
372}
373
374impl Chain {
375 pub fn as_str(self) -> &'static str {
376 match self {
377 Chain::Mainnet => "mainnet",
378 Chain::Testnet => "testnet",
379 Chain::Unknown => "unknown",
380 }
381 }
382}
383
384pub struct Error(pub String);
385
386#[derive(Default, Clone, Serialize, Deserialize, Debug, ProtocolConfigFeatureFlagsGetters)]
389struct FeatureFlags {
390 #[serde(skip_serializing_if = "is_false")]
393 package_upgrades: bool,
394 #[serde(skip_serializing_if = "is_false")]
397 commit_root_state_digest: bool,
398 #[serde(skip_serializing_if = "is_false")]
400 advance_epoch_start_time_in_safe_mode: bool,
401 #[serde(skip_serializing_if = "is_false")]
404 loaded_child_objects_fixed: bool,
405 #[serde(skip_serializing_if = "is_false")]
408 missing_type_is_compatibility_error: bool,
409 #[serde(skip_serializing_if = "is_false")]
412 scoring_decision_with_validity_cutoff: bool,
413
414 #[serde(skip_serializing_if = "is_false")]
417 consensus_order_end_of_epoch_last: bool,
418
419 #[serde(skip_serializing_if = "is_false")]
421 disallow_adding_abilities_on_upgrade: bool,
422 #[serde(skip_serializing_if = "is_false")]
424 disable_invariant_violation_check_in_swap_loc: bool,
425 #[serde(skip_serializing_if = "is_false")]
428 advance_to_highest_supported_protocol_version: bool,
429 #[serde(skip_serializing_if = "is_false")]
431 ban_entry_init: bool,
432 #[serde(skip_serializing_if = "is_false")]
434 package_digest_hash_module: bool,
435 #[serde(skip_serializing_if = "is_false")]
437 disallow_change_struct_type_params_on_upgrade: bool,
438 #[serde(skip_serializing_if = "is_false")]
440 no_extraneous_module_bytes: bool,
441 #[serde(skip_serializing_if = "is_false")]
443 narwhal_versioned_metadata: bool,
444
445 #[serde(skip_serializing_if = "is_false")]
447 zklogin_auth: bool,
448 #[serde(skip_serializing_if = "ConsensusTransactionOrdering::is_none")]
450 consensus_transaction_ordering: ConsensusTransactionOrdering,
451
452 #[serde(skip_serializing_if = "is_false")]
460 simplified_unwrap_then_delete: bool,
461 #[serde(skip_serializing_if = "is_false")]
463 upgraded_multisig_supported: bool,
464 #[serde(skip_serializing_if = "is_false")]
466 txn_base_cost_as_multiplier: bool,
467
468 #[serde(skip_serializing_if = "is_false")]
470 shared_object_deletion: bool,
471
472 #[serde(skip_serializing_if = "is_false")]
474 narwhal_new_leader_election_schedule: bool,
475
476 #[serde(skip_serializing_if = "is_empty")]
478 zklogin_supported_providers: BTreeSet<String>,
479
480 #[serde(skip_serializing_if = "is_false")]
482 loaded_child_object_format: bool,
483
484 #[serde(skip_serializing_if = "is_false")]
485 enable_jwk_consensus_updates: bool,
486
487 #[serde(skip_serializing_if = "is_false")]
488 end_of_epoch_transaction_supported: bool,
489
490 #[serde(skip_serializing_if = "is_false")]
493 simple_conservation_checks: bool,
494
495 #[serde(skip_serializing_if = "is_false")]
497 loaded_child_object_format_type: bool,
498
499 #[serde(skip_serializing_if = "is_false")]
501 receive_objects: bool,
502
503 #[serde(skip_serializing_if = "is_false")]
505 consensus_checkpoint_signature_key_includes_digest: bool,
506
507 #[serde(skip_serializing_if = "is_false")]
509 random_beacon: bool,
510
511 #[serde(skip_serializing_if = "is_false")]
513 bridge: bool,
514
515 #[serde(skip_serializing_if = "is_false")]
516 enable_effects_v2: bool,
517
518 #[serde(skip_serializing_if = "is_false")]
520 narwhal_certificate_v2: bool,
521
522 #[serde(skip_serializing_if = "is_false")]
524 verify_legacy_zklogin_address: bool,
525
526 #[serde(skip_serializing_if = "is_false")]
528 throughput_aware_consensus_submission: bool,
529
530 #[serde(skip_serializing_if = "is_false")]
532 recompute_has_public_transfer_in_execution: bool,
533
534 #[serde(skip_serializing_if = "is_false")]
536 accept_zklogin_in_multisig: bool,
537
538 #[serde(skip_serializing_if = "is_false")]
540 accept_passkey_in_multisig: bool,
541
542 #[serde(skip_serializing_if = "is_false")]
544 validate_zklogin_public_identifier: bool,
545
546 #[serde(skip_serializing_if = "is_false")]
549 include_consensus_digest_in_prologue: bool,
550
551 #[serde(skip_serializing_if = "is_false")]
553 hardened_otw_check: bool,
554
555 #[serde(skip_serializing_if = "is_false")]
557 allow_receiving_object_id: bool,
558
559 #[serde(skip_serializing_if = "is_false")]
561 enable_poseidon: bool,
562
563 #[serde(skip_serializing_if = "is_false")]
565 enable_coin_deny_list: bool,
566
567 #[serde(skip_serializing_if = "is_false")]
569 enable_group_ops_native_functions: bool,
570
571 #[serde(skip_serializing_if = "is_false")]
573 enable_group_ops_native_function_msm: bool,
574
575 #[serde(skip_serializing_if = "is_false")]
577 enable_ristretto255_group_ops: bool,
578
579 #[serde(skip_serializing_if = "is_false")]
581 enable_nitro_attestation: bool,
582
583 #[serde(skip_serializing_if = "is_false")]
585 enable_nitro_attestation_upgraded_parsing: bool,
586
587 #[serde(skip_serializing_if = "is_false")]
589 enable_nitro_attestation_all_nonzero_pcrs_parsing: bool,
590
591 #[serde(skip_serializing_if = "is_false")]
593 enable_nitro_attestation_always_include_required_pcrs_parsing: bool,
594
595 #[serde(skip_serializing_if = "is_false")]
597 reject_mutable_random_on_entry_functions: bool,
598
599 #[serde(skip_serializing_if = "PerObjectCongestionControlMode::is_none")]
601 per_object_congestion_control_mode: PerObjectCongestionControlMode,
602
603 #[serde(skip_serializing_if = "ConsensusChoice::is_narwhal")]
605 consensus_choice: ConsensusChoice,
606
607 #[serde(skip_serializing_if = "ConsensusNetwork::is_anemo")]
609 consensus_network: ConsensusNetwork,
610
611 #[serde(skip_serializing_if = "is_false")]
613 correct_gas_payment_limit_check: bool,
614
615 #[serde(skip_serializing_if = "Option::is_none")]
617 zklogin_max_epoch_upper_bound_delta: Option<u64>,
618
619 #[serde(skip_serializing_if = "is_false")]
621 mysticeti_leader_scoring_and_schedule: bool,
622
623 #[serde(skip_serializing_if = "is_false")]
625 reshare_at_same_initial_version: bool,
626
627 #[serde(skip_serializing_if = "is_false")]
629 resolve_abort_locations_to_package_id: bool,
630
631 #[serde(skip_serializing_if = "is_false")]
635 mysticeti_use_committed_subdag_digest: bool,
636
637 #[serde(skip_serializing_if = "is_false")]
639 enable_vdf: bool,
640
641 #[serde(skip_serializing_if = "is_false")]
646 record_consensus_determined_version_assignments_in_prologue: bool,
647 #[serde(skip_serializing_if = "is_false")]
648 record_consensus_determined_version_assignments_in_prologue_v2: bool,
649
650 #[serde(skip_serializing_if = "is_false")]
652 fresh_vm_on_framework_upgrade: bool,
653
654 #[serde(skip_serializing_if = "is_false")]
662 prepend_prologue_tx_in_consensus_commit_in_checkpoints: bool,
663
664 #[serde(skip_serializing_if = "Option::is_none")]
666 mysticeti_num_leaders_per_round: Option<usize>,
667
668 #[serde(skip_serializing_if = "is_false")]
670 soft_bundle: bool,
671
672 #[serde(skip_serializing_if = "is_false")]
674 enable_coin_deny_list_v2: bool,
675
676 #[serde(skip_serializing_if = "is_false")]
678 passkey_auth: bool,
679
680 #[serde(skip_serializing_if = "is_false")]
682 authority_capabilities_v2: bool,
683
684 #[serde(skip_serializing_if = "is_false")]
686 rethrow_serialization_type_layout_errors: bool,
687
688 #[serde(skip_serializing_if = "is_false")]
690 consensus_distributed_vote_scoring_strategy: bool,
691
692 #[serde(skip_serializing_if = "is_false")]
694 consensus_round_prober: bool,
695
696 #[serde(skip_serializing_if = "is_false")]
698 validate_identifier_inputs: bool,
699
700 #[serde(skip_serializing_if = "is_false")]
702 disallow_self_identifier: bool,
703
704 #[serde(skip_serializing_if = "is_false")]
706 mysticeti_fastpath: bool,
707
708 #[serde(skip_serializing_if = "is_false")]
712 disable_preconsensus_locking: bool,
713
714 #[serde(skip_serializing_if = "is_false")]
716 relocate_event_module: bool,
717
718 #[serde(skip_serializing_if = "is_false")]
720 uncompressed_g1_group_elements: bool,
721
722 #[serde(skip_serializing_if = "is_false")]
723 disallow_new_modules_in_deps_only_packages: bool,
724
725 #[serde(skip_serializing_if = "is_false")]
727 consensus_smart_ancestor_selection: bool,
728
729 #[serde(skip_serializing_if = "is_false")]
731 consensus_round_prober_probe_accepted_rounds: bool,
732
733 #[serde(skip_serializing_if = "is_false")]
735 native_charging_v2: bool,
736
737 #[serde(skip_serializing_if = "is_false")]
740 consensus_linearize_subdag_v2: bool,
741
742 #[serde(skip_serializing_if = "is_false")]
744 convert_type_argument_error: bool,
745
746 #[serde(skip_serializing_if = "is_false")]
748 variant_nodes: bool,
749
750 #[serde(skip_serializing_if = "is_false")]
752 consensus_zstd_compression: bool,
753
754 #[serde(skip_serializing_if = "is_false")]
756 minimize_child_object_mutations: bool,
757
758 #[serde(skip_serializing_if = "is_false")]
760 record_additional_state_digest_in_prologue: bool,
761
762 #[serde(skip_serializing_if = "is_false")]
764 move_native_context: bool,
765
766 #[serde(skip_serializing_if = "is_false")]
769 consensus_median_based_commit_timestamp: bool,
770
771 #[serde(skip_serializing_if = "is_false")]
774 normalize_ptb_arguments: bool,
775
776 #[serde(skip_serializing_if = "is_false")]
778 consensus_batched_block_sync: bool,
779
780 #[serde(skip_serializing_if = "is_false")]
782 enforce_checkpoint_timestamp_monotonicity: bool,
783
784 #[serde(skip_serializing_if = "is_false")]
786 max_ptb_value_size_v2: bool,
787
788 #[serde(skip_serializing_if = "is_false")]
790 resolve_type_input_ids_to_defining_id: bool,
791
792 #[serde(skip_serializing_if = "is_false")]
794 enable_party_transfer: bool,
795
796 #[serde(skip_serializing_if = "is_false")]
798 allow_unbounded_system_objects: bool,
799
800 #[serde(skip_serializing_if = "is_false")]
802 type_tags_in_object_runtime: bool,
803
804 #[serde(skip_serializing_if = "is_false")]
806 enable_accumulators: bool,
807
808 #[serde(skip_serializing_if = "is_false")]
810 enable_coin_reservation_obj_refs: bool,
811
812 #[serde(skip_serializing_if = "is_false")]
815 create_root_accumulator_object: bool,
816
817 #[serde(skip_serializing_if = "is_false")]
819 enable_authenticated_event_streams: bool,
820
821 #[serde(skip_serializing_if = "is_false")]
823 enable_address_balance_gas_payments: bool,
824
825 #[serde(skip_serializing_if = "is_false")]
827 address_balance_gas_check_rgp_at_signing: bool,
828
829 #[serde(skip_serializing_if = "is_false")]
830 address_balance_gas_reject_gas_coin_arg: bool,
831
832 #[serde(skip_serializing_if = "is_false")]
834 enable_multi_epoch_transaction_expiration: bool,
835
836 #[serde(skip_serializing_if = "is_false")]
838 relax_valid_during_for_owned_inputs: bool,
839
840 #[serde(skip_serializing_if = "is_false")]
842 enable_ptb_execution_v2: bool,
843
844 #[serde(skip_serializing_if = "is_false")]
846 better_adapter_type_resolution_errors: bool,
847
848 #[serde(skip_serializing_if = "is_false")]
850 record_time_estimate_processed: bool,
851
852 #[serde(skip_serializing_if = "is_false")]
854 dependency_linkage_error: bool,
855
856 #[serde(skip_serializing_if = "is_false")]
858 additional_multisig_checks: bool,
859
860 #[serde(skip_serializing_if = "is_false")]
862 ignore_execution_time_observations_after_certs_closed: bool,
863
864 #[serde(skip_serializing_if = "is_false")]
868 debug_fatal_on_move_invariant_violation: bool,
869
870 #[serde(skip_serializing_if = "is_false")]
873 allow_private_accumulator_entrypoints: bool,
874
875 #[serde(skip_serializing_if = "is_false")]
877 additional_consensus_digest_indirect_state: bool,
878
879 #[serde(skip_serializing_if = "is_false")]
881 check_for_init_during_upgrade: bool,
882
883 #[serde(skip_serializing_if = "is_false")]
885 per_command_shared_object_transfer_rules: bool,
886
887 #[serde(skip_serializing_if = "is_false")]
889 include_checkpoint_artifacts_digest_in_summary: bool,
890
891 #[serde(skip_serializing_if = "is_false")]
893 use_mfp_txns_in_load_initial_object_debts: bool,
894
895 #[serde(skip_serializing_if = "is_false")]
897 cancel_for_failed_dkg_early: bool,
898
899 #[serde(skip_serializing_if = "is_false")]
901 enable_coin_registry: bool,
902
903 #[serde(skip_serializing_if = "is_false")]
905 abstract_size_in_object_runtime: bool,
906
907 #[serde(skip_serializing_if = "is_false")]
909 object_runtime_charge_cache_load_gas: bool,
910
911 #[serde(skip_serializing_if = "is_false")]
913 additional_borrow_checks: bool,
914
915 #[serde(skip_serializing_if = "is_false")]
917 use_new_commit_handler: bool,
918
919 #[serde(skip_serializing_if = "is_false")]
921 better_loader_errors: bool,
922
923 #[serde(skip_serializing_if = "is_false")]
925 generate_df_type_layouts: bool,
926
927 #[serde(skip_serializing_if = "is_false")]
929 allow_references_in_ptbs: bool,
930
931 #[serde(skip_serializing_if = "is_false")]
933 enable_display_registry: bool,
934
935 #[serde(skip_serializing_if = "is_false")]
937 private_generics_verifier_v2: bool,
938
939 #[serde(skip_serializing_if = "is_false")]
941 deprecate_global_storage_ops_during_deserialization: bool,
942
943 #[serde(skip_serializing_if = "is_false")]
946 enable_non_exclusive_writes: bool,
947
948 #[serde(skip_serializing_if = "is_false")]
950 deprecate_global_storage_ops: bool,
951
952 #[serde(skip_serializing_if = "is_false")]
954 consensus_skip_gced_accept_votes: bool,
955
956 #[serde(skip_serializing_if = "is_false")]
958 include_cancelled_randomness_txns_in_prologue: bool,
959
960 #[serde(skip_serializing_if = "is_false")]
962 address_aliases: bool,
963
964 #[serde(skip_serializing_if = "is_false")]
967 fix_checkpoint_signature_mapping: bool,
968
969 #[serde(skip_serializing_if = "is_false")]
971 enable_object_funds_withdraw: bool,
972
973 #[serde(skip_serializing_if = "is_false")]
975 consensus_skip_gced_blocks_in_direct_finalization: bool,
976
977 #[serde(skip_serializing_if = "is_false")]
979 gas_rounding_halve_digits: bool,
980
981 #[serde(skip_serializing_if = "is_false")]
983 flexible_tx_context_positions: bool,
984
985 #[serde(skip_serializing_if = "is_false")]
987 disable_entry_point_signature_check: bool,
988
989 #[serde(skip_serializing_if = "is_false")]
991 convert_withdrawal_compatibility_ptb_arguments: bool,
992
993 #[serde(skip_serializing_if = "is_false")]
995 restrict_hot_or_not_entry_functions: bool,
996
997 #[serde(skip_serializing_if = "is_false")]
999 split_checkpoints_in_consensus_handler: bool,
1000
1001 #[serde(skip_serializing_if = "is_false")]
1003 consensus_always_accept_system_transactions: bool,
1004
1005 #[serde(skip_serializing_if = "is_false")]
1007 validator_metadata_verify_v2: bool,
1008
1009 #[serde(skip_serializing_if = "is_false")]
1012 defer_unpaid_amplification: bool,
1013
1014 #[serde(skip_serializing_if = "is_false")]
1015 randomize_checkpoint_tx_limit_in_tests: bool,
1016
1017 #[serde(skip_serializing_if = "is_false")]
1019 gasless_transaction_drop_safety: bool,
1020}
1021
1022fn is_false(b: &bool) -> bool {
1023 !b
1024}
1025
1026fn is_empty(b: &BTreeSet<String>) -> bool {
1027 b.is_empty()
1028}
1029
1030fn is_zero(val: &u64) -> bool {
1031 *val == 0
1032}
1033
1034#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1036pub enum ConsensusTransactionOrdering {
1037 #[default]
1039 None,
1040 ByGasPrice,
1042}
1043
1044impl ConsensusTransactionOrdering {
1045 pub fn is_none(&self) -> bool {
1046 matches!(self, ConsensusTransactionOrdering::None)
1047 }
1048}
1049
1050#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1051pub struct ExecutionTimeEstimateParams {
1052 pub target_utilization: u64,
1054 pub allowed_txn_cost_overage_burst_limit_us: u64,
1058
1059 pub randomness_scalar: u64,
1062
1063 pub max_estimate_us: u64,
1065
1066 pub stored_observations_num_included_checkpoints: u64,
1069
1070 pub stored_observations_limit: u64,
1072
1073 #[serde(skip_serializing_if = "is_zero")]
1076 pub stake_weighted_median_threshold: u64,
1077
1078 #[serde(skip_serializing_if = "is_false")]
1082 pub default_none_duration_for_new_keys: bool,
1083
1084 #[serde(skip_serializing_if = "Option::is_none")]
1086 pub observations_chunk_size: Option<u64>,
1087}
1088
1089#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1091pub enum PerObjectCongestionControlMode {
1092 #[default]
1093 None, TotalGasBudget, TotalTxCount, TotalGasBudgetWithCap, ExecutionTimeEstimate(ExecutionTimeEstimateParams), }
1099
1100impl PerObjectCongestionControlMode {
1101 pub fn is_none(&self) -> bool {
1102 matches!(self, PerObjectCongestionControlMode::None)
1103 }
1104}
1105
1106#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1108pub enum ConsensusChoice {
1109 #[default]
1110 Narwhal,
1111 SwapEachEpoch,
1112 Mysticeti,
1113}
1114
1115impl ConsensusChoice {
1116 pub fn is_narwhal(&self) -> bool {
1117 matches!(self, ConsensusChoice::Narwhal)
1118 }
1119}
1120
1121#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1123pub enum ConsensusNetwork {
1124 #[default]
1125 Anemo,
1126 Tonic,
1127}
1128
1129impl ConsensusNetwork {
1130 pub fn is_anemo(&self) -> bool {
1131 matches!(self, ConsensusNetwork::Anemo)
1132 }
1133}
1134
1135#[skip_serializing_none]
1167#[derive(Clone, Serialize, Debug, ProtocolConfigAccessors, ProtocolConfigOverride)]
1168pub struct ProtocolConfig {
1169 pub version: ProtocolVersion,
1170
1171 feature_flags: FeatureFlags,
1172
1173 max_tx_size_bytes: Option<u64>,
1176
1177 max_input_objects: Option<u64>,
1179
1180 max_size_written_objects: Option<u64>,
1184 max_size_written_objects_system_tx: Option<u64>,
1187
1188 max_serialized_tx_effects_size_bytes: Option<u64>,
1190
1191 max_serialized_tx_effects_size_bytes_system_tx: Option<u64>,
1193
1194 max_gas_payment_objects: Option<u32>,
1196
1197 max_modules_in_publish: Option<u32>,
1199
1200 max_package_dependencies: Option<u32>,
1202
1203 max_arguments: Option<u32>,
1206
1207 max_type_arguments: Option<u32>,
1209
1210 max_type_argument_depth: Option<u32>,
1212
1213 max_pure_argument_size: Option<u32>,
1215
1216 max_programmable_tx_commands: Option<u32>,
1218
1219 move_binary_format_version: Option<u32>,
1222 min_move_binary_format_version: Option<u32>,
1223
1224 binary_module_handles: Option<u16>,
1226 binary_struct_handles: Option<u16>,
1227 binary_function_handles: Option<u16>,
1228 binary_function_instantiations: Option<u16>,
1229 binary_signatures: Option<u16>,
1230 binary_constant_pool: Option<u16>,
1231 binary_identifiers: Option<u16>,
1232 binary_address_identifiers: Option<u16>,
1233 binary_struct_defs: Option<u16>,
1234 binary_struct_def_instantiations: Option<u16>,
1235 binary_function_defs: Option<u16>,
1236 binary_field_handles: Option<u16>,
1237 binary_field_instantiations: Option<u16>,
1238 binary_friend_decls: Option<u16>,
1239 binary_enum_defs: Option<u16>,
1240 binary_enum_def_instantiations: Option<u16>,
1241 binary_variant_handles: Option<u16>,
1242 binary_variant_instantiation_handles: Option<u16>,
1243
1244 max_move_object_size: Option<u64>,
1246
1247 max_move_package_size: Option<u64>,
1250
1251 max_publish_or_upgrade_per_ptb: Option<u64>,
1253
1254 max_tx_gas: Option<u64>,
1256
1257 max_gas_price: Option<u64>,
1259
1260 max_gas_price_rgp_factor_for_aborted_transactions: Option<u64>,
1263
1264 max_gas_computation_bucket: Option<u64>,
1266
1267 gas_rounding_step: Option<u64>,
1269
1270 max_loop_depth: Option<u64>,
1272
1273 max_generic_instantiation_length: Option<u64>,
1275
1276 max_function_parameters: Option<u64>,
1278
1279 max_basic_blocks: Option<u64>,
1281
1282 max_value_stack_size: Option<u64>,
1284
1285 max_type_nodes: Option<u64>,
1287
1288 max_push_size: Option<u64>,
1290
1291 max_struct_definitions: Option<u64>,
1293
1294 max_function_definitions: Option<u64>,
1296
1297 max_fields_in_struct: Option<u64>,
1299
1300 max_dependency_depth: Option<u64>,
1302
1303 max_num_event_emit: Option<u64>,
1305
1306 max_num_new_move_object_ids: Option<u64>,
1308
1309 max_num_new_move_object_ids_system_tx: Option<u64>,
1311
1312 max_num_deleted_move_object_ids: Option<u64>,
1314
1315 max_num_deleted_move_object_ids_system_tx: Option<u64>,
1317
1318 max_num_transferred_move_object_ids: Option<u64>,
1320
1321 max_num_transferred_move_object_ids_system_tx: Option<u64>,
1323
1324 max_event_emit_size: Option<u64>,
1326
1327 max_event_emit_size_total: Option<u64>,
1329
1330 max_move_vector_len: Option<u64>,
1332
1333 max_move_identifier_len: Option<u64>,
1335
1336 max_move_value_depth: Option<u64>,
1338
1339 max_move_enum_variants: Option<u64>,
1341
1342 max_back_edges_per_function: Option<u64>,
1344
1345 max_back_edges_per_module: Option<u64>,
1347
1348 max_verifier_meter_ticks_per_function: Option<u64>,
1350
1351 max_meter_ticks_per_module: Option<u64>,
1353
1354 max_meter_ticks_per_package: Option<u64>,
1356
1357 object_runtime_max_num_cached_objects: Option<u64>,
1361
1362 object_runtime_max_num_cached_objects_system_tx: Option<u64>,
1364
1365 object_runtime_max_num_store_entries: Option<u64>,
1367
1368 object_runtime_max_num_store_entries_system_tx: Option<u64>,
1370
1371 base_tx_cost_fixed: Option<u64>,
1374
1375 package_publish_cost_fixed: Option<u64>,
1378
1379 base_tx_cost_per_byte: Option<u64>,
1382
1383 package_publish_cost_per_byte: Option<u64>,
1385
1386 obj_access_cost_read_per_byte: Option<u64>,
1388
1389 obj_access_cost_mutate_per_byte: Option<u64>,
1391
1392 obj_access_cost_delete_per_byte: Option<u64>,
1394
1395 obj_access_cost_verify_per_byte: Option<u64>,
1405
1406 max_type_to_layout_nodes: Option<u64>,
1408
1409 max_ptb_value_size: Option<u64>,
1411
1412 gas_model_version: Option<u64>,
1415
1416 obj_data_cost_refundable: Option<u64>,
1419
1420 obj_metadata_cost_non_refundable: Option<u64>,
1424
1425 storage_rebate_rate: Option<u64>,
1431
1432 storage_fund_reinvest_rate: Option<u64>,
1435
1436 reward_slashing_rate: Option<u64>,
1439
1440 storage_gas_price: Option<u64>,
1442
1443 accumulator_object_storage_cost: Option<u64>,
1445
1446 max_transactions_per_checkpoint: Option<u64>,
1451
1452 max_checkpoint_size_bytes: Option<u64>,
1456
1457 buffer_stake_for_protocol_upgrade_bps: Option<u64>,
1462
1463 address_from_bytes_cost_base: Option<u64>,
1468 address_to_u256_cost_base: Option<u64>,
1470 address_from_u256_cost_base: Option<u64>,
1472
1473 config_read_setting_impl_cost_base: Option<u64>,
1478 config_read_setting_impl_cost_per_byte: Option<u64>,
1479
1480 dynamic_field_hash_type_and_key_cost_base: Option<u64>,
1483 dynamic_field_hash_type_and_key_type_cost_per_byte: Option<u64>,
1484 dynamic_field_hash_type_and_key_value_cost_per_byte: Option<u64>,
1485 dynamic_field_hash_type_and_key_type_tag_cost_per_byte: Option<u64>,
1486 dynamic_field_add_child_object_cost_base: Option<u64>,
1488 dynamic_field_add_child_object_type_cost_per_byte: Option<u64>,
1489 dynamic_field_add_child_object_value_cost_per_byte: Option<u64>,
1490 dynamic_field_add_child_object_struct_tag_cost_per_byte: Option<u64>,
1491 dynamic_field_borrow_child_object_cost_base: Option<u64>,
1493 dynamic_field_borrow_child_object_child_ref_cost_per_byte: Option<u64>,
1494 dynamic_field_borrow_child_object_type_cost_per_byte: Option<u64>,
1495 dynamic_field_remove_child_object_cost_base: Option<u64>,
1497 dynamic_field_remove_child_object_child_cost_per_byte: Option<u64>,
1498 dynamic_field_remove_child_object_type_cost_per_byte: Option<u64>,
1499 dynamic_field_has_child_object_cost_base: Option<u64>,
1501 dynamic_field_has_child_object_with_ty_cost_base: Option<u64>,
1503 dynamic_field_has_child_object_with_ty_type_cost_per_byte: Option<u64>,
1504 dynamic_field_has_child_object_with_ty_type_tag_cost_per_byte: Option<u64>,
1505
1506 event_emit_cost_base: Option<u64>,
1509 event_emit_value_size_derivation_cost_per_byte: Option<u64>,
1510 event_emit_tag_size_derivation_cost_per_byte: Option<u64>,
1511 event_emit_output_cost_per_byte: Option<u64>,
1512 event_emit_auth_stream_cost: Option<u64>,
1513
1514 object_borrow_uid_cost_base: Option<u64>,
1517 object_delete_impl_cost_base: Option<u64>,
1519 object_record_new_uid_cost_base: Option<u64>,
1521
1522 transfer_transfer_internal_cost_base: Option<u64>,
1525 transfer_party_transfer_internal_cost_base: Option<u64>,
1527 transfer_freeze_object_cost_base: Option<u64>,
1529 transfer_share_object_cost_base: Option<u64>,
1531 transfer_receive_object_cost_base: Option<u64>,
1534
1535 tx_context_derive_id_cost_base: Option<u64>,
1538 tx_context_fresh_id_cost_base: Option<u64>,
1539 tx_context_sender_cost_base: Option<u64>,
1540 tx_context_epoch_cost_base: Option<u64>,
1541 tx_context_epoch_timestamp_ms_cost_base: Option<u64>,
1542 tx_context_sponsor_cost_base: Option<u64>,
1543 tx_context_rgp_cost_base: Option<u64>,
1544 tx_context_gas_price_cost_base: Option<u64>,
1545 tx_context_gas_budget_cost_base: Option<u64>,
1546 tx_context_ids_created_cost_base: Option<u64>,
1547 tx_context_replace_cost_base: Option<u64>,
1548
1549 types_is_one_time_witness_cost_base: Option<u64>,
1552 types_is_one_time_witness_type_tag_cost_per_byte: Option<u64>,
1553 types_is_one_time_witness_type_cost_per_byte: Option<u64>,
1554
1555 validator_validate_metadata_cost_base: Option<u64>,
1558 validator_validate_metadata_data_cost_per_byte: Option<u64>,
1559
1560 crypto_invalid_arguments_cost: Option<u64>,
1562 bls12381_bls12381_min_sig_verify_cost_base: Option<u64>,
1564 bls12381_bls12381_min_sig_verify_msg_cost_per_byte: Option<u64>,
1565 bls12381_bls12381_min_sig_verify_msg_cost_per_block: Option<u64>,
1566
1567 bls12381_bls12381_min_pk_verify_cost_base: Option<u64>,
1569 bls12381_bls12381_min_pk_verify_msg_cost_per_byte: Option<u64>,
1570 bls12381_bls12381_min_pk_verify_msg_cost_per_block: Option<u64>,
1571
1572 ecdsa_k1_ecrecover_keccak256_cost_base: Option<u64>,
1574 ecdsa_k1_ecrecover_keccak256_msg_cost_per_byte: Option<u64>,
1575 ecdsa_k1_ecrecover_keccak256_msg_cost_per_block: Option<u64>,
1576 ecdsa_k1_ecrecover_sha256_cost_base: Option<u64>,
1577 ecdsa_k1_ecrecover_sha256_msg_cost_per_byte: Option<u64>,
1578 ecdsa_k1_ecrecover_sha256_msg_cost_per_block: Option<u64>,
1579
1580 ecdsa_k1_decompress_pubkey_cost_base: Option<u64>,
1582
1583 ecdsa_k1_secp256k1_verify_keccak256_cost_base: Option<u64>,
1585 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_byte: Option<u64>,
1586 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_block: Option<u64>,
1587 ecdsa_k1_secp256k1_verify_sha256_cost_base: Option<u64>,
1588 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_byte: Option<u64>,
1589 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_block: Option<u64>,
1590
1591 ecdsa_r1_ecrecover_keccak256_cost_base: Option<u64>,
1593 ecdsa_r1_ecrecover_keccak256_msg_cost_per_byte: Option<u64>,
1594 ecdsa_r1_ecrecover_keccak256_msg_cost_per_block: Option<u64>,
1595 ecdsa_r1_ecrecover_sha256_cost_base: Option<u64>,
1596 ecdsa_r1_ecrecover_sha256_msg_cost_per_byte: Option<u64>,
1597 ecdsa_r1_ecrecover_sha256_msg_cost_per_block: Option<u64>,
1598
1599 ecdsa_r1_secp256r1_verify_keccak256_cost_base: Option<u64>,
1601 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_byte: Option<u64>,
1602 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_block: Option<u64>,
1603 ecdsa_r1_secp256r1_verify_sha256_cost_base: Option<u64>,
1604 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_byte: Option<u64>,
1605 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_block: Option<u64>,
1606
1607 ecvrf_ecvrf_verify_cost_base: Option<u64>,
1609 ecvrf_ecvrf_verify_alpha_string_cost_per_byte: Option<u64>,
1610 ecvrf_ecvrf_verify_alpha_string_cost_per_block: Option<u64>,
1611
1612 ed25519_ed25519_verify_cost_base: Option<u64>,
1614 ed25519_ed25519_verify_msg_cost_per_byte: Option<u64>,
1615 ed25519_ed25519_verify_msg_cost_per_block: Option<u64>,
1616
1617 groth16_prepare_verifying_key_bls12381_cost_base: Option<u64>,
1619 groth16_prepare_verifying_key_bn254_cost_base: Option<u64>,
1620
1621 groth16_verify_groth16_proof_internal_bls12381_cost_base: Option<u64>,
1623 groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input: Option<u64>,
1624 groth16_verify_groth16_proof_internal_bn254_cost_base: Option<u64>,
1625 groth16_verify_groth16_proof_internal_bn254_cost_per_public_input: Option<u64>,
1626 groth16_verify_groth16_proof_internal_public_input_cost_per_byte: Option<u64>,
1627
1628 hash_blake2b256_cost_base: Option<u64>,
1630 hash_blake2b256_data_cost_per_byte: Option<u64>,
1631 hash_blake2b256_data_cost_per_block: Option<u64>,
1632
1633 hash_keccak256_cost_base: Option<u64>,
1635 hash_keccak256_data_cost_per_byte: Option<u64>,
1636 hash_keccak256_data_cost_per_block: Option<u64>,
1637
1638 poseidon_bn254_cost_base: Option<u64>,
1640 poseidon_bn254_cost_per_block: Option<u64>,
1641
1642 group_ops_bls12381_decode_scalar_cost: Option<u64>,
1644 group_ops_bls12381_decode_g1_cost: Option<u64>,
1645 group_ops_bls12381_decode_g2_cost: Option<u64>,
1646 group_ops_bls12381_decode_gt_cost: Option<u64>,
1647 group_ops_bls12381_scalar_add_cost: Option<u64>,
1648 group_ops_bls12381_g1_add_cost: Option<u64>,
1649 group_ops_bls12381_g2_add_cost: Option<u64>,
1650 group_ops_bls12381_gt_add_cost: Option<u64>,
1651 group_ops_bls12381_scalar_sub_cost: Option<u64>,
1652 group_ops_bls12381_g1_sub_cost: Option<u64>,
1653 group_ops_bls12381_g2_sub_cost: Option<u64>,
1654 group_ops_bls12381_gt_sub_cost: Option<u64>,
1655 group_ops_bls12381_scalar_mul_cost: Option<u64>,
1656 group_ops_bls12381_g1_mul_cost: Option<u64>,
1657 group_ops_bls12381_g2_mul_cost: Option<u64>,
1658 group_ops_bls12381_gt_mul_cost: Option<u64>,
1659 group_ops_bls12381_scalar_div_cost: Option<u64>,
1660 group_ops_bls12381_g1_div_cost: Option<u64>,
1661 group_ops_bls12381_g2_div_cost: Option<u64>,
1662 group_ops_bls12381_gt_div_cost: Option<u64>,
1663 group_ops_bls12381_g1_hash_to_base_cost: Option<u64>,
1664 group_ops_bls12381_g2_hash_to_base_cost: Option<u64>,
1665 group_ops_bls12381_g1_hash_to_cost_per_byte: Option<u64>,
1666 group_ops_bls12381_g2_hash_to_cost_per_byte: Option<u64>,
1667 group_ops_bls12381_g1_msm_base_cost: Option<u64>,
1668 group_ops_bls12381_g2_msm_base_cost: Option<u64>,
1669 group_ops_bls12381_g1_msm_base_cost_per_input: Option<u64>,
1670 group_ops_bls12381_g2_msm_base_cost_per_input: Option<u64>,
1671 group_ops_bls12381_msm_max_len: Option<u32>,
1672 group_ops_bls12381_pairing_cost: Option<u64>,
1673 group_ops_bls12381_g1_to_uncompressed_g1_cost: Option<u64>,
1674 group_ops_bls12381_uncompressed_g1_to_g1_cost: Option<u64>,
1675 group_ops_bls12381_uncompressed_g1_sum_base_cost: Option<u64>,
1676 group_ops_bls12381_uncompressed_g1_sum_cost_per_term: Option<u64>,
1677 group_ops_bls12381_uncompressed_g1_sum_max_terms: Option<u64>,
1678
1679 group_ops_ristretto_decode_scalar_cost: Option<u64>,
1680 group_ops_ristretto_decode_point_cost: Option<u64>,
1681 group_ops_ristretto_scalar_add_cost: Option<u64>,
1682 group_ops_ristretto_point_add_cost: Option<u64>,
1683 group_ops_ristretto_scalar_sub_cost: Option<u64>,
1684 group_ops_ristretto_point_sub_cost: Option<u64>,
1685 group_ops_ristretto_scalar_mul_cost: Option<u64>,
1686 group_ops_ristretto_point_mul_cost: Option<u64>,
1687 group_ops_ristretto_scalar_div_cost: Option<u64>,
1688 group_ops_ristretto_point_div_cost: Option<u64>,
1689
1690 hmac_hmac_sha3_256_cost_base: Option<u64>,
1692 hmac_hmac_sha3_256_input_cost_per_byte: Option<u64>,
1693 hmac_hmac_sha3_256_input_cost_per_block: Option<u64>,
1694
1695 check_zklogin_id_cost_base: Option<u64>,
1697 check_zklogin_issuer_cost_base: Option<u64>,
1699
1700 vdf_verify_vdf_cost: Option<u64>,
1701 vdf_hash_to_input_cost: Option<u64>,
1702
1703 nitro_attestation_parse_base_cost: Option<u64>,
1705 nitro_attestation_parse_cost_per_byte: Option<u64>,
1706 nitro_attestation_verify_base_cost: Option<u64>,
1707 nitro_attestation_verify_cost_per_cert: Option<u64>,
1708
1709 bcs_per_byte_serialized_cost: Option<u64>,
1711 bcs_legacy_min_output_size_cost: Option<u64>,
1712 bcs_failure_cost: Option<u64>,
1713
1714 hash_sha2_256_base_cost: Option<u64>,
1715 hash_sha2_256_per_byte_cost: Option<u64>,
1716 hash_sha2_256_legacy_min_input_len_cost: Option<u64>,
1717 hash_sha3_256_base_cost: Option<u64>,
1718 hash_sha3_256_per_byte_cost: Option<u64>,
1719 hash_sha3_256_legacy_min_input_len_cost: Option<u64>,
1720 type_name_get_base_cost: Option<u64>,
1721 type_name_get_per_byte_cost: Option<u64>,
1722 type_name_id_base_cost: Option<u64>,
1723
1724 string_check_utf8_base_cost: Option<u64>,
1725 string_check_utf8_per_byte_cost: Option<u64>,
1726 string_is_char_boundary_base_cost: Option<u64>,
1727 string_sub_string_base_cost: Option<u64>,
1728 string_sub_string_per_byte_cost: Option<u64>,
1729 string_index_of_base_cost: Option<u64>,
1730 string_index_of_per_byte_pattern_cost: Option<u64>,
1731 string_index_of_per_byte_searched_cost: Option<u64>,
1732
1733 vector_empty_base_cost: Option<u64>,
1734 vector_length_base_cost: Option<u64>,
1735 vector_push_back_base_cost: Option<u64>,
1736 vector_push_back_legacy_per_abstract_memory_unit_cost: Option<u64>,
1737 vector_borrow_base_cost: Option<u64>,
1738 vector_pop_back_base_cost: Option<u64>,
1739 vector_destroy_empty_base_cost: Option<u64>,
1740 vector_swap_base_cost: Option<u64>,
1741 debug_print_base_cost: Option<u64>,
1742 debug_print_stack_trace_base_cost: Option<u64>,
1743
1744 execution_version: Option<u64>,
1753
1754 consensus_bad_nodes_stake_threshold: Option<u64>,
1758
1759 max_jwk_votes_per_validator_per_epoch: Option<u64>,
1760 max_age_of_jwk_in_epochs: Option<u64>,
1764
1765 random_beacon_reduction_allowed_delta: Option<u16>,
1769
1770 random_beacon_reduction_lower_bound: Option<u32>,
1773
1774 random_beacon_dkg_timeout_round: Option<u32>,
1777
1778 random_beacon_min_round_interval_ms: Option<u64>,
1780
1781 random_beacon_dkg_version: Option<u64>,
1784
1785 consensus_max_transaction_size_bytes: Option<u64>,
1788 consensus_max_transactions_in_block_bytes: Option<u64>,
1790 consensus_max_num_transactions_in_block: Option<u64>,
1792
1793 consensus_voting_rounds: Option<u32>,
1795
1796 max_accumulated_txn_cost_per_object_in_narwhal_commit: Option<u64>,
1798
1799 max_deferral_rounds_for_congestion_control: Option<u64>,
1802
1803 max_txn_cost_overage_per_object_in_commit: Option<u64>,
1805
1806 allowed_txn_cost_overage_burst_per_object_in_commit: Option<u64>,
1808
1809 min_checkpoint_interval_ms: Option<u64>,
1811
1812 checkpoint_summary_version_specific_data: Option<u64>,
1814
1815 max_soft_bundle_size: Option<u64>,
1817
1818 bridge_should_try_to_finalize_committee: Option<bool>,
1822
1823 max_accumulated_txn_cost_per_object_in_mysticeti_commit: Option<u64>,
1829
1830 max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit: Option<u64>,
1833
1834 consensus_gc_depth: Option<u32>,
1837
1838 gas_budget_based_txn_cost_cap_factor: Option<u64>,
1840
1841 gas_budget_based_txn_cost_absolute_cap_commit_count: Option<u64>,
1843
1844 sip_45_consensus_amplification_threshold: Option<u64>,
1847
1848 use_object_per_epoch_marker_table_v2: Option<bool>,
1851
1852 consensus_commit_rate_estimation_window_size: Option<u32>,
1854
1855 #[serde(skip_serializing_if = "Vec::is_empty")]
1859 aliased_addresses: Vec<AliasedAddress>,
1860
1861 translation_per_command_base_charge: Option<u64>,
1864
1865 translation_per_input_base_charge: Option<u64>,
1868
1869 translation_pure_input_per_byte_charge: Option<u64>,
1871
1872 translation_per_type_node_charge: Option<u64>,
1876
1877 translation_per_reference_node_charge: Option<u64>,
1880
1881 translation_per_linkage_entry_charge: Option<u64>,
1884
1885 max_updates_per_settlement_txn: Option<u32>,
1887}
1888
1889#[derive(Clone, Serialize, Deserialize, Debug)]
1891pub struct AliasedAddress {
1892 pub original: [u8; 32],
1894 pub aliased: [u8; 32],
1896 pub allowed_tx_digests: Vec<[u8; 32]>,
1898}
1899
1900impl ProtocolConfig {
1902 pub fn check_package_upgrades_supported(&self) -> Result<(), Error> {
1915 if self.feature_flags.package_upgrades {
1916 Ok(())
1917 } else {
1918 Err(Error(format!(
1919 "package upgrades are not supported at {:?}",
1920 self.version
1921 )))
1922 }
1923 }
1924
1925 pub fn allow_receiving_object_id(&self) -> bool {
1926 self.feature_flags.allow_receiving_object_id
1927 }
1928
1929 pub fn receiving_objects_supported(&self) -> bool {
1930 self.feature_flags.receive_objects
1931 }
1932
1933 pub fn package_upgrades_supported(&self) -> bool {
1934 self.feature_flags.package_upgrades
1935 }
1936
1937 pub fn check_commit_root_state_digest_supported(&self) -> bool {
1938 self.feature_flags.commit_root_state_digest
1939 }
1940
1941 pub fn get_advance_epoch_start_time_in_safe_mode(&self) -> bool {
1942 self.feature_flags.advance_epoch_start_time_in_safe_mode
1943 }
1944
1945 pub fn loaded_child_objects_fixed(&self) -> bool {
1946 self.feature_flags.loaded_child_objects_fixed
1947 }
1948
1949 pub fn missing_type_is_compatibility_error(&self) -> bool {
1950 self.feature_flags.missing_type_is_compatibility_error
1951 }
1952
1953 pub fn scoring_decision_with_validity_cutoff(&self) -> bool {
1954 self.feature_flags.scoring_decision_with_validity_cutoff
1955 }
1956
1957 pub fn narwhal_versioned_metadata(&self) -> bool {
1958 self.feature_flags.narwhal_versioned_metadata
1959 }
1960
1961 pub fn consensus_order_end_of_epoch_last(&self) -> bool {
1962 self.feature_flags.consensus_order_end_of_epoch_last
1963 }
1964
1965 pub fn disallow_adding_abilities_on_upgrade(&self) -> bool {
1966 self.feature_flags.disallow_adding_abilities_on_upgrade
1967 }
1968
1969 pub fn disable_invariant_violation_check_in_swap_loc(&self) -> bool {
1970 self.feature_flags
1971 .disable_invariant_violation_check_in_swap_loc
1972 }
1973
1974 pub fn advance_to_highest_supported_protocol_version(&self) -> bool {
1975 self.feature_flags
1976 .advance_to_highest_supported_protocol_version
1977 }
1978
1979 pub fn ban_entry_init(&self) -> bool {
1980 self.feature_flags.ban_entry_init
1981 }
1982
1983 pub fn package_digest_hash_module(&self) -> bool {
1984 self.feature_flags.package_digest_hash_module
1985 }
1986
1987 pub fn disallow_change_struct_type_params_on_upgrade(&self) -> bool {
1988 self.feature_flags
1989 .disallow_change_struct_type_params_on_upgrade
1990 }
1991
1992 pub fn no_extraneous_module_bytes(&self) -> bool {
1993 self.feature_flags.no_extraneous_module_bytes
1994 }
1995
1996 pub fn zklogin_auth(&self) -> bool {
1997 self.feature_flags.zklogin_auth
1998 }
1999
2000 pub fn zklogin_supported_providers(&self) -> &BTreeSet<String> {
2001 &self.feature_flags.zklogin_supported_providers
2002 }
2003
2004 pub fn consensus_transaction_ordering(&self) -> ConsensusTransactionOrdering {
2005 self.feature_flags.consensus_transaction_ordering
2006 }
2007
2008 pub fn simplified_unwrap_then_delete(&self) -> bool {
2009 self.feature_flags.simplified_unwrap_then_delete
2010 }
2011
2012 pub fn supports_upgraded_multisig(&self) -> bool {
2013 self.feature_flags.upgraded_multisig_supported
2014 }
2015
2016 pub fn txn_base_cost_as_multiplier(&self) -> bool {
2017 self.feature_flags.txn_base_cost_as_multiplier
2018 }
2019
2020 pub fn shared_object_deletion(&self) -> bool {
2021 self.feature_flags.shared_object_deletion
2022 }
2023
2024 pub fn narwhal_new_leader_election_schedule(&self) -> bool {
2025 self.feature_flags.narwhal_new_leader_election_schedule
2026 }
2027
2028 pub fn loaded_child_object_format(&self) -> bool {
2029 self.feature_flags.loaded_child_object_format
2030 }
2031
2032 pub fn enable_jwk_consensus_updates(&self) -> bool {
2033 let ret = self.feature_flags.enable_jwk_consensus_updates;
2034 if ret {
2035 assert!(self.feature_flags.end_of_epoch_transaction_supported);
2037 }
2038 ret
2039 }
2040
2041 pub fn simple_conservation_checks(&self) -> bool {
2042 self.feature_flags.simple_conservation_checks
2043 }
2044
2045 pub fn loaded_child_object_format_type(&self) -> bool {
2046 self.feature_flags.loaded_child_object_format_type
2047 }
2048
2049 pub fn end_of_epoch_transaction_supported(&self) -> bool {
2050 let ret = self.feature_flags.end_of_epoch_transaction_supported;
2051 if !ret {
2052 assert!(!self.feature_flags.enable_jwk_consensus_updates);
2054 }
2055 ret
2056 }
2057
2058 pub fn recompute_has_public_transfer_in_execution(&self) -> bool {
2059 self.feature_flags
2060 .recompute_has_public_transfer_in_execution
2061 }
2062
2063 pub fn create_authenticator_state_in_genesis(&self) -> bool {
2065 self.enable_jwk_consensus_updates()
2066 }
2067
2068 pub fn random_beacon(&self) -> bool {
2069 self.feature_flags.random_beacon
2070 }
2071
2072 pub fn dkg_version(&self) -> u64 {
2073 self.random_beacon_dkg_version.unwrap_or(1)
2075 }
2076
2077 pub fn enable_bridge(&self) -> bool {
2078 let ret = self.feature_flags.bridge;
2079 if ret {
2080 assert!(self.feature_flags.end_of_epoch_transaction_supported);
2082 }
2083 ret
2084 }
2085
2086 pub fn should_try_to_finalize_bridge_committee(&self) -> bool {
2087 if !self.enable_bridge() {
2088 return false;
2089 }
2090 self.bridge_should_try_to_finalize_committee.unwrap_or(true)
2092 }
2093
2094 pub fn enable_effects_v2(&self) -> bool {
2095 self.feature_flags.enable_effects_v2
2096 }
2097
2098 pub fn narwhal_certificate_v2(&self) -> bool {
2099 self.feature_flags.narwhal_certificate_v2
2100 }
2101
2102 pub fn verify_legacy_zklogin_address(&self) -> bool {
2103 self.feature_flags.verify_legacy_zklogin_address
2104 }
2105
2106 pub fn accept_zklogin_in_multisig(&self) -> bool {
2107 self.feature_flags.accept_zklogin_in_multisig
2108 }
2109
2110 pub fn accept_passkey_in_multisig(&self) -> bool {
2111 self.feature_flags.accept_passkey_in_multisig
2112 }
2113
2114 pub fn validate_zklogin_public_identifier(&self) -> bool {
2115 self.feature_flags.validate_zklogin_public_identifier
2116 }
2117
2118 pub fn zklogin_max_epoch_upper_bound_delta(&self) -> Option<u64> {
2119 self.feature_flags.zklogin_max_epoch_upper_bound_delta
2120 }
2121
2122 pub fn throughput_aware_consensus_submission(&self) -> bool {
2123 self.feature_flags.throughput_aware_consensus_submission
2124 }
2125
2126 pub fn include_consensus_digest_in_prologue(&self) -> bool {
2127 self.feature_flags.include_consensus_digest_in_prologue
2128 }
2129
2130 pub fn record_consensus_determined_version_assignments_in_prologue(&self) -> bool {
2131 self.feature_flags
2132 .record_consensus_determined_version_assignments_in_prologue
2133 }
2134
2135 pub fn record_additional_state_digest_in_prologue(&self) -> bool {
2136 self.feature_flags
2137 .record_additional_state_digest_in_prologue
2138 }
2139
2140 pub fn record_consensus_determined_version_assignments_in_prologue_v2(&self) -> bool {
2141 self.feature_flags
2142 .record_consensus_determined_version_assignments_in_prologue_v2
2143 }
2144
2145 pub fn prepend_prologue_tx_in_consensus_commit_in_checkpoints(&self) -> bool {
2146 self.feature_flags
2147 .prepend_prologue_tx_in_consensus_commit_in_checkpoints
2148 }
2149
2150 pub fn hardened_otw_check(&self) -> bool {
2151 self.feature_flags.hardened_otw_check
2152 }
2153
2154 pub fn enable_poseidon(&self) -> bool {
2155 self.feature_flags.enable_poseidon
2156 }
2157
2158 pub fn enable_coin_deny_list_v1(&self) -> bool {
2159 self.feature_flags.enable_coin_deny_list
2160 }
2161
2162 pub fn enable_accumulators(&self) -> bool {
2163 self.feature_flags.enable_accumulators
2164 }
2165
2166 pub fn enable_coin_reservation_obj_refs(&self) -> bool {
2167 self.feature_flags.enable_coin_reservation_obj_refs
2168 }
2169
2170 pub fn create_root_accumulator_object(&self) -> bool {
2171 self.feature_flags.create_root_accumulator_object
2172 }
2173
2174 pub fn enable_address_balance_gas_payments(&self) -> bool {
2175 self.feature_flags.enable_address_balance_gas_payments
2176 }
2177
2178 pub fn address_balance_gas_check_rgp_at_signing(&self) -> bool {
2179 self.feature_flags.address_balance_gas_check_rgp_at_signing
2180 }
2181
2182 pub fn address_balance_gas_reject_gas_coin_arg(&self) -> bool {
2183 self.feature_flags.address_balance_gas_reject_gas_coin_arg
2184 }
2185
2186 pub fn enable_multi_epoch_transaction_expiration(&self) -> bool {
2187 self.feature_flags.enable_multi_epoch_transaction_expiration
2188 }
2189
2190 pub fn relax_valid_during_for_owned_inputs(&self) -> bool {
2191 self.feature_flags.relax_valid_during_for_owned_inputs
2192 }
2193
2194 pub fn enable_authenticated_event_streams(&self) -> bool {
2195 self.feature_flags.enable_authenticated_event_streams && self.enable_accumulators()
2196 }
2197
2198 pub fn enable_non_exclusive_writes(&self) -> bool {
2199 self.feature_flags.enable_non_exclusive_writes
2200 }
2201
2202 pub fn enable_coin_registry(&self) -> bool {
2203 self.feature_flags.enable_coin_registry
2204 }
2205
2206 pub fn enable_display_registry(&self) -> bool {
2207 self.feature_flags.enable_display_registry
2208 }
2209
2210 pub fn enable_coin_deny_list_v2(&self) -> bool {
2211 self.feature_flags.enable_coin_deny_list_v2
2212 }
2213
2214 pub fn enable_group_ops_native_functions(&self) -> bool {
2215 self.feature_flags.enable_group_ops_native_functions
2216 }
2217
2218 pub fn enable_group_ops_native_function_msm(&self) -> bool {
2219 self.feature_flags.enable_group_ops_native_function_msm
2220 }
2221
2222 pub fn enable_ristretto255_group_ops(&self) -> bool {
2223 self.feature_flags.enable_ristretto255_group_ops
2224 }
2225
2226 pub fn reject_mutable_random_on_entry_functions(&self) -> bool {
2227 self.feature_flags.reject_mutable_random_on_entry_functions
2228 }
2229
2230 pub fn per_object_congestion_control_mode(&self) -> PerObjectCongestionControlMode {
2231 self.feature_flags.per_object_congestion_control_mode
2232 }
2233
2234 pub fn consensus_choice(&self) -> ConsensusChoice {
2235 self.feature_flags.consensus_choice
2236 }
2237
2238 pub fn consensus_network(&self) -> ConsensusNetwork {
2239 self.feature_flags.consensus_network
2240 }
2241
2242 pub fn correct_gas_payment_limit_check(&self) -> bool {
2243 self.feature_flags.correct_gas_payment_limit_check
2244 }
2245
2246 pub fn reshare_at_same_initial_version(&self) -> bool {
2247 self.feature_flags.reshare_at_same_initial_version
2248 }
2249
2250 pub fn resolve_abort_locations_to_package_id(&self) -> bool {
2251 self.feature_flags.resolve_abort_locations_to_package_id
2252 }
2253
2254 pub fn mysticeti_use_committed_subdag_digest(&self) -> bool {
2255 self.feature_flags.mysticeti_use_committed_subdag_digest
2256 }
2257
2258 pub fn enable_vdf(&self) -> bool {
2259 self.feature_flags.enable_vdf
2260 }
2261
2262 pub fn fresh_vm_on_framework_upgrade(&self) -> bool {
2263 self.feature_flags.fresh_vm_on_framework_upgrade
2264 }
2265
2266 pub fn mysticeti_num_leaders_per_round(&self) -> Option<usize> {
2267 self.feature_flags.mysticeti_num_leaders_per_round
2268 }
2269
2270 pub fn soft_bundle(&self) -> bool {
2271 self.feature_flags.soft_bundle
2272 }
2273
2274 pub fn passkey_auth(&self) -> bool {
2275 self.feature_flags.passkey_auth
2276 }
2277
2278 pub fn authority_capabilities_v2(&self) -> bool {
2279 self.feature_flags.authority_capabilities_v2
2280 }
2281
2282 pub fn max_transaction_size_bytes(&self) -> u64 {
2283 self.consensus_max_transaction_size_bytes
2285 .unwrap_or(256 * 1024)
2286 }
2287
2288 pub fn max_transactions_in_block_bytes(&self) -> u64 {
2289 if cfg!(msim) {
2290 256 * 1024
2291 } else {
2292 self.consensus_max_transactions_in_block_bytes
2293 .unwrap_or(512 * 1024)
2294 }
2295 }
2296
2297 pub fn max_num_transactions_in_block(&self) -> u64 {
2298 if cfg!(msim) {
2299 8
2300 } else {
2301 self.consensus_max_num_transactions_in_block.unwrap_or(512)
2302 }
2303 }
2304
2305 pub fn rethrow_serialization_type_layout_errors(&self) -> bool {
2306 self.feature_flags.rethrow_serialization_type_layout_errors
2307 }
2308
2309 pub fn consensus_distributed_vote_scoring_strategy(&self) -> bool {
2310 self.feature_flags
2311 .consensus_distributed_vote_scoring_strategy
2312 }
2313
2314 pub fn consensus_round_prober(&self) -> bool {
2315 self.feature_flags.consensus_round_prober
2316 }
2317
2318 pub fn validate_identifier_inputs(&self) -> bool {
2319 self.feature_flags.validate_identifier_inputs
2320 }
2321
2322 pub fn gc_depth(&self) -> u32 {
2323 self.consensus_gc_depth.unwrap_or(0)
2324 }
2325
2326 pub fn mysticeti_fastpath(&self) -> bool {
2327 self.feature_flags.mysticeti_fastpath
2328 }
2329
2330 pub fn relocate_event_module(&self) -> bool {
2331 self.feature_flags.relocate_event_module
2332 }
2333
2334 pub fn uncompressed_g1_group_elements(&self) -> bool {
2335 self.feature_flags.uncompressed_g1_group_elements
2336 }
2337
2338 pub fn disallow_new_modules_in_deps_only_packages(&self) -> bool {
2339 self.feature_flags
2340 .disallow_new_modules_in_deps_only_packages
2341 }
2342
2343 pub fn consensus_smart_ancestor_selection(&self) -> bool {
2344 self.feature_flags.consensus_smart_ancestor_selection
2345 }
2346
2347 pub fn disable_preconsensus_locking(&self) -> bool {
2348 self.feature_flags.disable_preconsensus_locking
2349 }
2350
2351 pub fn consensus_round_prober_probe_accepted_rounds(&self) -> bool {
2352 self.feature_flags
2353 .consensus_round_prober_probe_accepted_rounds
2354 }
2355
2356 pub fn native_charging_v2(&self) -> bool {
2357 self.feature_flags.native_charging_v2
2358 }
2359
2360 pub fn consensus_linearize_subdag_v2(&self) -> bool {
2361 let res = self.feature_flags.consensus_linearize_subdag_v2;
2362 assert!(
2363 !res || self.gc_depth() > 0,
2364 "The consensus linearize sub dag V2 requires GC to be enabled"
2365 );
2366 res
2367 }
2368
2369 pub fn consensus_median_based_commit_timestamp(&self) -> bool {
2370 let res = self.feature_flags.consensus_median_based_commit_timestamp;
2371 assert!(
2372 !res || self.gc_depth() > 0,
2373 "The consensus median based commit timestamp requires GC to be enabled"
2374 );
2375 res
2376 }
2377
2378 pub fn consensus_batched_block_sync(&self) -> bool {
2379 self.feature_flags.consensus_batched_block_sync
2380 }
2381
2382 pub fn convert_type_argument_error(&self) -> bool {
2383 self.feature_flags.convert_type_argument_error
2384 }
2385
2386 pub fn variant_nodes(&self) -> bool {
2387 self.feature_flags.variant_nodes
2388 }
2389
2390 pub fn consensus_zstd_compression(&self) -> bool {
2391 self.feature_flags.consensus_zstd_compression
2392 }
2393
2394 pub fn enable_nitro_attestation(&self) -> bool {
2395 self.feature_flags.enable_nitro_attestation
2396 }
2397
2398 pub fn enable_nitro_attestation_upgraded_parsing(&self) -> bool {
2399 self.feature_flags.enable_nitro_attestation_upgraded_parsing
2400 }
2401
2402 pub fn enable_nitro_attestation_all_nonzero_pcrs_parsing(&self) -> bool {
2403 self.feature_flags
2404 .enable_nitro_attestation_all_nonzero_pcrs_parsing
2405 }
2406
2407 pub fn enable_nitro_attestation_always_include_required_pcrs_parsing(&self) -> bool {
2408 self.feature_flags
2409 .enable_nitro_attestation_always_include_required_pcrs_parsing
2410 }
2411
2412 pub fn get_consensus_commit_rate_estimation_window_size(&self) -> u32 {
2413 self.consensus_commit_rate_estimation_window_size
2414 .unwrap_or(0)
2415 }
2416
2417 pub fn consensus_num_requested_prior_commits_at_startup(&self) -> u32 {
2418 let window_size = self.get_consensus_commit_rate_estimation_window_size();
2422 assert!(window_size == 0 || self.record_additional_state_digest_in_prologue());
2424 window_size
2425 }
2426
2427 pub fn minimize_child_object_mutations(&self) -> bool {
2428 self.feature_flags.minimize_child_object_mutations
2429 }
2430
2431 pub fn move_native_context(&self) -> bool {
2432 self.feature_flags.move_native_context
2433 }
2434
2435 pub fn normalize_ptb_arguments(&self) -> bool {
2436 self.feature_flags.normalize_ptb_arguments
2437 }
2438
2439 pub fn enforce_checkpoint_timestamp_monotonicity(&self) -> bool {
2440 self.feature_flags.enforce_checkpoint_timestamp_monotonicity
2441 }
2442
2443 pub fn max_ptb_value_size_v2(&self) -> bool {
2444 self.feature_flags.max_ptb_value_size_v2
2445 }
2446
2447 pub fn resolve_type_input_ids_to_defining_id(&self) -> bool {
2448 self.feature_flags.resolve_type_input_ids_to_defining_id
2449 }
2450
2451 pub fn enable_party_transfer(&self) -> bool {
2452 self.feature_flags.enable_party_transfer
2453 }
2454
2455 pub fn allow_unbounded_system_objects(&self) -> bool {
2456 self.feature_flags.allow_unbounded_system_objects
2457 }
2458
2459 pub fn type_tags_in_object_runtime(&self) -> bool {
2460 self.feature_flags.type_tags_in_object_runtime
2461 }
2462
2463 pub fn enable_ptb_execution_v2(&self) -> bool {
2464 self.feature_flags.enable_ptb_execution_v2
2465 }
2466
2467 pub fn better_adapter_type_resolution_errors(&self) -> bool {
2468 self.feature_flags.better_adapter_type_resolution_errors
2469 }
2470
2471 pub fn record_time_estimate_processed(&self) -> bool {
2472 self.feature_flags.record_time_estimate_processed
2473 }
2474
2475 pub fn ignore_execution_time_observations_after_certs_closed(&self) -> bool {
2476 self.feature_flags
2477 .ignore_execution_time_observations_after_certs_closed
2478 }
2479
2480 pub fn dependency_linkage_error(&self) -> bool {
2481 self.feature_flags.dependency_linkage_error
2482 }
2483
2484 pub fn additional_multisig_checks(&self) -> bool {
2485 self.feature_flags.additional_multisig_checks
2486 }
2487
2488 pub fn debug_fatal_on_move_invariant_violation(&self) -> bool {
2489 self.feature_flags.debug_fatal_on_move_invariant_violation
2490 }
2491
2492 pub fn allow_private_accumulator_entrypoints(&self) -> bool {
2493 self.feature_flags.allow_private_accumulator_entrypoints
2494 }
2495
2496 pub fn additional_consensus_digest_indirect_state(&self) -> bool {
2497 self.feature_flags
2498 .additional_consensus_digest_indirect_state
2499 }
2500
2501 pub fn check_for_init_during_upgrade(&self) -> bool {
2502 self.feature_flags.check_for_init_during_upgrade
2503 }
2504
2505 pub fn per_command_shared_object_transfer_rules(&self) -> bool {
2506 self.feature_flags.per_command_shared_object_transfer_rules
2507 }
2508
2509 pub fn consensus_checkpoint_signature_key_includes_digest(&self) -> bool {
2510 self.feature_flags
2511 .consensus_checkpoint_signature_key_includes_digest
2512 }
2513
2514 pub fn include_checkpoint_artifacts_digest_in_summary(&self) -> bool {
2515 self.feature_flags
2516 .include_checkpoint_artifacts_digest_in_summary
2517 }
2518
2519 pub fn use_mfp_txns_in_load_initial_object_debts(&self) -> bool {
2520 self.feature_flags.use_mfp_txns_in_load_initial_object_debts
2521 }
2522
2523 pub fn cancel_for_failed_dkg_early(&self) -> bool {
2524 self.feature_flags.cancel_for_failed_dkg_early
2525 }
2526
2527 pub fn abstract_size_in_object_runtime(&self) -> bool {
2528 self.feature_flags.abstract_size_in_object_runtime
2529 }
2530
2531 pub fn object_runtime_charge_cache_load_gas(&self) -> bool {
2532 self.feature_flags.object_runtime_charge_cache_load_gas
2533 }
2534
2535 pub fn additional_borrow_checks(&self) -> bool {
2536 self.feature_flags.additional_borrow_checks
2537 }
2538
2539 pub fn use_new_commit_handler(&self) -> bool {
2540 self.feature_flags.use_new_commit_handler
2541 }
2542
2543 pub fn better_loader_errors(&self) -> bool {
2544 self.feature_flags.better_loader_errors
2545 }
2546
2547 pub fn generate_df_type_layouts(&self) -> bool {
2548 self.feature_flags.generate_df_type_layouts
2549 }
2550
2551 pub fn allow_references_in_ptbs(&self) -> bool {
2552 self.feature_flags.allow_references_in_ptbs
2553 }
2554
2555 pub fn private_generics_verifier_v2(&self) -> bool {
2556 self.feature_flags.private_generics_verifier_v2
2557 }
2558
2559 pub fn deprecate_global_storage_ops_during_deserialization(&self) -> bool {
2560 self.feature_flags
2561 .deprecate_global_storage_ops_during_deserialization
2562 }
2563
2564 pub fn enable_observation_chunking(&self) -> bool {
2565 matches!(self.feature_flags.per_object_congestion_control_mode,
2566 PerObjectCongestionControlMode::ExecutionTimeEstimate(ref params)
2567 if params.observations_chunk_size.is_some()
2568 )
2569 }
2570
2571 pub fn deprecate_global_storage_ops(&self) -> bool {
2572 self.feature_flags.deprecate_global_storage_ops
2573 }
2574
2575 pub fn consensus_skip_gced_accept_votes(&self) -> bool {
2576 self.feature_flags.consensus_skip_gced_accept_votes
2577 }
2578
2579 pub fn include_cancelled_randomness_txns_in_prologue(&self) -> bool {
2580 self.feature_flags
2581 .include_cancelled_randomness_txns_in_prologue
2582 }
2583
2584 pub fn address_aliases(&self) -> bool {
2585 let address_aliases = self.feature_flags.address_aliases;
2586 assert!(
2587 !address_aliases || self.mysticeti_fastpath(),
2588 "Address aliases requires Mysticeti fastpath to be enabled"
2589 );
2590 if address_aliases {
2591 assert!(
2592 self.feature_flags.disable_preconsensus_locking,
2593 "Address aliases requires CertifiedTransaction to be disabled"
2594 );
2595 }
2596 address_aliases
2597 }
2598
2599 pub fn fix_checkpoint_signature_mapping(&self) -> bool {
2600 self.feature_flags.fix_checkpoint_signature_mapping
2601 }
2602
2603 pub fn enable_object_funds_withdraw(&self) -> bool {
2604 self.feature_flags.enable_object_funds_withdraw
2605 }
2606
2607 pub fn gas_rounding_halve_digits(&self) -> bool {
2608 self.feature_flags.gas_rounding_halve_digits
2609 }
2610
2611 pub fn flexible_tx_context_positions(&self) -> bool {
2612 self.feature_flags.flexible_tx_context_positions
2613 }
2614
2615 pub fn disable_entry_point_signature_check(&self) -> bool {
2616 self.feature_flags.disable_entry_point_signature_check
2617 }
2618
2619 pub fn consensus_skip_gced_blocks_in_direct_finalization(&self) -> bool {
2620 self.feature_flags
2621 .consensus_skip_gced_blocks_in_direct_finalization
2622 }
2623
2624 pub fn convert_withdrawal_compatibility_ptb_arguments(&self) -> bool {
2625 self.feature_flags
2626 .convert_withdrawal_compatibility_ptb_arguments
2627 }
2628
2629 pub fn restrict_hot_or_not_entry_functions(&self) -> bool {
2630 self.feature_flags.restrict_hot_or_not_entry_functions
2631 }
2632
2633 pub fn split_checkpoints_in_consensus_handler(&self) -> bool {
2634 self.feature_flags.split_checkpoints_in_consensus_handler
2635 }
2636
2637 pub fn consensus_always_accept_system_transactions(&self) -> bool {
2638 self.feature_flags
2639 .consensus_always_accept_system_transactions
2640 }
2641
2642 pub fn validator_metadata_verify_v2(&self) -> bool {
2643 self.feature_flags.validator_metadata_verify_v2
2644 }
2645
2646 pub fn defer_unpaid_amplification(&self) -> bool {
2647 self.feature_flags.defer_unpaid_amplification
2648 }
2649
2650 pub fn gasless_transaction_drop_safety(&self) -> bool {
2651 self.feature_flags.gasless_transaction_drop_safety
2652 }
2653}
2654
2655#[cfg(not(msim))]
2656static POISON_VERSION_METHODS: AtomicBool = AtomicBool::new(false);
2657
2658#[cfg(msim)]
2660thread_local! {
2661 static POISON_VERSION_METHODS: AtomicBool = AtomicBool::new(false);
2662}
2663
2664impl ProtocolConfig {
2666 pub fn get_for_version(version: ProtocolVersion, chain: Chain) -> Self {
2668 assert!(
2670 version >= ProtocolVersion::MIN,
2671 "Network protocol version is {:?}, but the minimum supported version by the binary is {:?}. Please upgrade the binary.",
2672 version,
2673 ProtocolVersion::MIN.0,
2674 );
2675 assert!(
2676 version <= ProtocolVersion::MAX_ALLOWED,
2677 "Network protocol version is {:?}, but the maximum supported version by the binary is {:?}. Please upgrade the binary.",
2678 version,
2679 ProtocolVersion::MAX_ALLOWED.0,
2680 );
2681
2682 let mut ret = Self::get_for_version_impl(version, chain);
2683 ret.version = version;
2684
2685 ret = CONFIG_OVERRIDE.with(|ovr| {
2686 if let Some(override_fn) = &*ovr.borrow() {
2687 warn!(
2688 "overriding ProtocolConfig settings with custom settings (you should not see this log outside of tests)"
2689 );
2690 override_fn(version, ret)
2691 } else {
2692 ret
2693 }
2694 });
2695
2696 if std::env::var("SUI_PROTOCOL_CONFIG_OVERRIDE_ENABLE").is_ok() {
2697 warn!(
2698 "overriding ProtocolConfig settings with custom settings; this may break non-local networks"
2699 );
2700 let overrides: ProtocolConfigOptional =
2701 serde_env::from_env_with_prefix("SUI_PROTOCOL_CONFIG_OVERRIDE")
2702 .expect("failed to parse ProtocolConfig override env variables");
2703 overrides.apply_to(&mut ret);
2704 }
2705
2706 ret
2707 }
2708
2709 pub fn get_for_version_if_supported(version: ProtocolVersion, chain: Chain) -> Option<Self> {
2712 if version.0 >= ProtocolVersion::MIN.0 && version.0 <= ProtocolVersion::MAX_ALLOWED.0 {
2713 let mut ret = Self::get_for_version_impl(version, chain);
2714 ret.version = version;
2715 Some(ret)
2716 } else {
2717 None
2718 }
2719 }
2720
2721 #[cfg(not(msim))]
2722 pub fn poison_get_for_min_version() {
2723 POISON_VERSION_METHODS.store(true, Ordering::Relaxed);
2724 }
2725
2726 #[cfg(not(msim))]
2727 fn load_poison_get_for_min_version() -> bool {
2728 POISON_VERSION_METHODS.load(Ordering::Relaxed)
2729 }
2730
2731 #[cfg(msim)]
2732 pub fn poison_get_for_min_version() {
2733 POISON_VERSION_METHODS.with(|p| p.store(true, Ordering::Relaxed));
2734 }
2735
2736 #[cfg(msim)]
2737 fn load_poison_get_for_min_version() -> bool {
2738 POISON_VERSION_METHODS.with(|p| p.load(Ordering::Relaxed))
2739 }
2740
2741 pub fn get_for_min_version() -> Self {
2744 if Self::load_poison_get_for_min_version() {
2745 panic!("get_for_min_version called on validator");
2746 }
2747 ProtocolConfig::get_for_version(ProtocolVersion::MIN, Chain::Unknown)
2748 }
2749
2750 #[allow(non_snake_case)]
2760 pub fn get_for_max_version_UNSAFE() -> Self {
2761 if Self::load_poison_get_for_min_version() {
2762 panic!("get_for_max_version_UNSAFE called on validator");
2763 }
2764 ProtocolConfig::get_for_version(ProtocolVersion::MAX, Chain::Unknown)
2765 }
2766
2767 fn get_for_version_impl(version: ProtocolVersion, chain: Chain) -> Self {
2768 #[cfg(msim)]
2769 {
2770 if version == ProtocolVersion::MAX_ALLOWED {
2772 let mut config = Self::get_for_version_impl(version - 1, Chain::Unknown);
2773 config.base_tx_cost_fixed = Some(config.base_tx_cost_fixed() + 1000);
2774 return config;
2775 }
2776 }
2777
2778 let mut cfg = Self {
2781 version,
2783
2784 feature_flags: Default::default(),
2786
2787 max_tx_size_bytes: Some(128 * 1024),
2788 max_input_objects: Some(2048),
2790 max_serialized_tx_effects_size_bytes: Some(512 * 1024),
2791 max_serialized_tx_effects_size_bytes_system_tx: Some(512 * 1024 * 16),
2792 max_gas_payment_objects: Some(256),
2793 max_modules_in_publish: Some(128),
2794 max_package_dependencies: None,
2795 max_arguments: Some(512),
2796 max_type_arguments: Some(16),
2797 max_type_argument_depth: Some(16),
2798 max_pure_argument_size: Some(16 * 1024),
2799 max_programmable_tx_commands: Some(1024),
2800 move_binary_format_version: Some(6),
2801 min_move_binary_format_version: None,
2802 binary_module_handles: None,
2803 binary_struct_handles: None,
2804 binary_function_handles: None,
2805 binary_function_instantiations: None,
2806 binary_signatures: None,
2807 binary_constant_pool: None,
2808 binary_identifiers: None,
2809 binary_address_identifiers: None,
2810 binary_struct_defs: None,
2811 binary_struct_def_instantiations: None,
2812 binary_function_defs: None,
2813 binary_field_handles: None,
2814 binary_field_instantiations: None,
2815 binary_friend_decls: None,
2816 binary_enum_defs: None,
2817 binary_enum_def_instantiations: None,
2818 binary_variant_handles: None,
2819 binary_variant_instantiation_handles: None,
2820 max_move_object_size: Some(250 * 1024),
2821 max_move_package_size: Some(100 * 1024),
2822 max_publish_or_upgrade_per_ptb: None,
2823 max_tx_gas: Some(10_000_000_000),
2824 max_gas_price: Some(100_000),
2825 max_gas_price_rgp_factor_for_aborted_transactions: None,
2826 max_gas_computation_bucket: Some(5_000_000),
2827 max_loop_depth: Some(5),
2828 max_generic_instantiation_length: Some(32),
2829 max_function_parameters: Some(128),
2830 max_basic_blocks: Some(1024),
2831 max_value_stack_size: Some(1024),
2832 max_type_nodes: Some(256),
2833 max_push_size: Some(10000),
2834 max_struct_definitions: Some(200),
2835 max_function_definitions: Some(1000),
2836 max_fields_in_struct: Some(32),
2837 max_dependency_depth: Some(100),
2838 max_num_event_emit: Some(256),
2839 max_num_new_move_object_ids: Some(2048),
2840 max_num_new_move_object_ids_system_tx: Some(2048 * 16),
2841 max_num_deleted_move_object_ids: Some(2048),
2842 max_num_deleted_move_object_ids_system_tx: Some(2048 * 16),
2843 max_num_transferred_move_object_ids: Some(2048),
2844 max_num_transferred_move_object_ids_system_tx: Some(2048 * 16),
2845 max_event_emit_size: Some(250 * 1024),
2846 max_move_vector_len: Some(256 * 1024),
2847 max_type_to_layout_nodes: None,
2848 max_ptb_value_size: None,
2849
2850 max_back_edges_per_function: Some(10_000),
2851 max_back_edges_per_module: Some(10_000),
2852 max_verifier_meter_ticks_per_function: Some(6_000_000),
2853 max_meter_ticks_per_module: Some(6_000_000),
2854 max_meter_ticks_per_package: None,
2855
2856 object_runtime_max_num_cached_objects: Some(1000),
2857 object_runtime_max_num_cached_objects_system_tx: Some(1000 * 16),
2858 object_runtime_max_num_store_entries: Some(1000),
2859 object_runtime_max_num_store_entries_system_tx: Some(1000 * 16),
2860 base_tx_cost_fixed: Some(110_000),
2861 package_publish_cost_fixed: Some(1_000),
2862 base_tx_cost_per_byte: Some(0),
2863 package_publish_cost_per_byte: Some(80),
2864 obj_access_cost_read_per_byte: Some(15),
2865 obj_access_cost_mutate_per_byte: Some(40),
2866 obj_access_cost_delete_per_byte: Some(40),
2867 obj_access_cost_verify_per_byte: Some(200),
2868 obj_data_cost_refundable: Some(100),
2869 obj_metadata_cost_non_refundable: Some(50),
2870 gas_model_version: Some(1),
2871 storage_rebate_rate: Some(9900),
2872 storage_fund_reinvest_rate: Some(500),
2873 reward_slashing_rate: Some(5000),
2874 storage_gas_price: Some(1),
2875 accumulator_object_storage_cost: None,
2876 max_transactions_per_checkpoint: Some(10_000),
2877 max_checkpoint_size_bytes: Some(30 * 1024 * 1024),
2878
2879 buffer_stake_for_protocol_upgrade_bps: Some(0),
2882
2883 address_from_bytes_cost_base: Some(52),
2887 address_to_u256_cost_base: Some(52),
2889 address_from_u256_cost_base: Some(52),
2891
2892 config_read_setting_impl_cost_base: None,
2895 config_read_setting_impl_cost_per_byte: None,
2896
2897 dynamic_field_hash_type_and_key_cost_base: Some(100),
2900 dynamic_field_hash_type_and_key_type_cost_per_byte: Some(2),
2901 dynamic_field_hash_type_and_key_value_cost_per_byte: Some(2),
2902 dynamic_field_hash_type_and_key_type_tag_cost_per_byte: Some(2),
2903 dynamic_field_add_child_object_cost_base: Some(100),
2905 dynamic_field_add_child_object_type_cost_per_byte: Some(10),
2906 dynamic_field_add_child_object_value_cost_per_byte: Some(10),
2907 dynamic_field_add_child_object_struct_tag_cost_per_byte: Some(10),
2908 dynamic_field_borrow_child_object_cost_base: Some(100),
2910 dynamic_field_borrow_child_object_child_ref_cost_per_byte: Some(10),
2911 dynamic_field_borrow_child_object_type_cost_per_byte: Some(10),
2912 dynamic_field_remove_child_object_cost_base: Some(100),
2914 dynamic_field_remove_child_object_child_cost_per_byte: Some(2),
2915 dynamic_field_remove_child_object_type_cost_per_byte: Some(2),
2916 dynamic_field_has_child_object_cost_base: Some(100),
2918 dynamic_field_has_child_object_with_ty_cost_base: Some(100),
2920 dynamic_field_has_child_object_with_ty_type_cost_per_byte: Some(2),
2921 dynamic_field_has_child_object_with_ty_type_tag_cost_per_byte: Some(2),
2922
2923 event_emit_cost_base: Some(52),
2926 event_emit_value_size_derivation_cost_per_byte: Some(2),
2927 event_emit_tag_size_derivation_cost_per_byte: Some(5),
2928 event_emit_output_cost_per_byte: Some(10),
2929 event_emit_auth_stream_cost: None,
2930
2931 object_borrow_uid_cost_base: Some(52),
2934 object_delete_impl_cost_base: Some(52),
2936 object_record_new_uid_cost_base: Some(52),
2938
2939 transfer_transfer_internal_cost_base: Some(52),
2942 transfer_party_transfer_internal_cost_base: None,
2944 transfer_freeze_object_cost_base: Some(52),
2946 transfer_share_object_cost_base: Some(52),
2948 transfer_receive_object_cost_base: None,
2949
2950 tx_context_derive_id_cost_base: Some(52),
2953 tx_context_fresh_id_cost_base: None,
2954 tx_context_sender_cost_base: None,
2955 tx_context_epoch_cost_base: None,
2956 tx_context_epoch_timestamp_ms_cost_base: None,
2957 tx_context_sponsor_cost_base: None,
2958 tx_context_rgp_cost_base: None,
2959 tx_context_gas_price_cost_base: None,
2960 tx_context_gas_budget_cost_base: None,
2961 tx_context_ids_created_cost_base: None,
2962 tx_context_replace_cost_base: None,
2963
2964 types_is_one_time_witness_cost_base: Some(52),
2967 types_is_one_time_witness_type_tag_cost_per_byte: Some(2),
2968 types_is_one_time_witness_type_cost_per_byte: Some(2),
2969
2970 validator_validate_metadata_cost_base: Some(52),
2973 validator_validate_metadata_data_cost_per_byte: Some(2),
2974
2975 crypto_invalid_arguments_cost: Some(100),
2977 bls12381_bls12381_min_sig_verify_cost_base: Some(52),
2979 bls12381_bls12381_min_sig_verify_msg_cost_per_byte: Some(2),
2980 bls12381_bls12381_min_sig_verify_msg_cost_per_block: Some(2),
2981
2982 bls12381_bls12381_min_pk_verify_cost_base: Some(52),
2984 bls12381_bls12381_min_pk_verify_msg_cost_per_byte: Some(2),
2985 bls12381_bls12381_min_pk_verify_msg_cost_per_block: Some(2),
2986
2987 ecdsa_k1_ecrecover_keccak256_cost_base: Some(52),
2989 ecdsa_k1_ecrecover_keccak256_msg_cost_per_byte: Some(2),
2990 ecdsa_k1_ecrecover_keccak256_msg_cost_per_block: Some(2),
2991 ecdsa_k1_ecrecover_sha256_cost_base: Some(52),
2992 ecdsa_k1_ecrecover_sha256_msg_cost_per_byte: Some(2),
2993 ecdsa_k1_ecrecover_sha256_msg_cost_per_block: Some(2),
2994
2995 ecdsa_k1_decompress_pubkey_cost_base: Some(52),
2997
2998 ecdsa_k1_secp256k1_verify_keccak256_cost_base: Some(52),
3000 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_byte: Some(2),
3001 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_block: Some(2),
3002 ecdsa_k1_secp256k1_verify_sha256_cost_base: Some(52),
3003 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_byte: Some(2),
3004 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_block: Some(2),
3005
3006 ecdsa_r1_ecrecover_keccak256_cost_base: Some(52),
3008 ecdsa_r1_ecrecover_keccak256_msg_cost_per_byte: Some(2),
3009 ecdsa_r1_ecrecover_keccak256_msg_cost_per_block: Some(2),
3010 ecdsa_r1_ecrecover_sha256_cost_base: Some(52),
3011 ecdsa_r1_ecrecover_sha256_msg_cost_per_byte: Some(2),
3012 ecdsa_r1_ecrecover_sha256_msg_cost_per_block: Some(2),
3013
3014 ecdsa_r1_secp256r1_verify_keccak256_cost_base: Some(52),
3016 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_byte: Some(2),
3017 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_block: Some(2),
3018 ecdsa_r1_secp256r1_verify_sha256_cost_base: Some(52),
3019 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_byte: Some(2),
3020 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_block: Some(2),
3021
3022 ecvrf_ecvrf_verify_cost_base: Some(52),
3024 ecvrf_ecvrf_verify_alpha_string_cost_per_byte: Some(2),
3025 ecvrf_ecvrf_verify_alpha_string_cost_per_block: Some(2),
3026
3027 ed25519_ed25519_verify_cost_base: Some(52),
3029 ed25519_ed25519_verify_msg_cost_per_byte: Some(2),
3030 ed25519_ed25519_verify_msg_cost_per_block: Some(2),
3031
3032 groth16_prepare_verifying_key_bls12381_cost_base: Some(52),
3034 groth16_prepare_verifying_key_bn254_cost_base: Some(52),
3035
3036 groth16_verify_groth16_proof_internal_bls12381_cost_base: Some(52),
3038 groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input: Some(2),
3039 groth16_verify_groth16_proof_internal_bn254_cost_base: Some(52),
3040 groth16_verify_groth16_proof_internal_bn254_cost_per_public_input: Some(2),
3041 groth16_verify_groth16_proof_internal_public_input_cost_per_byte: Some(2),
3042
3043 hash_blake2b256_cost_base: Some(52),
3045 hash_blake2b256_data_cost_per_byte: Some(2),
3046 hash_blake2b256_data_cost_per_block: Some(2),
3047
3048 hash_keccak256_cost_base: Some(52),
3050 hash_keccak256_data_cost_per_byte: Some(2),
3051 hash_keccak256_data_cost_per_block: Some(2),
3052
3053 poseidon_bn254_cost_base: None,
3054 poseidon_bn254_cost_per_block: None,
3055
3056 hmac_hmac_sha3_256_cost_base: Some(52),
3058 hmac_hmac_sha3_256_input_cost_per_byte: Some(2),
3059 hmac_hmac_sha3_256_input_cost_per_block: Some(2),
3060
3061 group_ops_bls12381_decode_scalar_cost: None,
3063 group_ops_bls12381_decode_g1_cost: None,
3064 group_ops_bls12381_decode_g2_cost: None,
3065 group_ops_bls12381_decode_gt_cost: None,
3066 group_ops_bls12381_scalar_add_cost: None,
3067 group_ops_bls12381_g1_add_cost: None,
3068 group_ops_bls12381_g2_add_cost: None,
3069 group_ops_bls12381_gt_add_cost: None,
3070 group_ops_bls12381_scalar_sub_cost: None,
3071 group_ops_bls12381_g1_sub_cost: None,
3072 group_ops_bls12381_g2_sub_cost: None,
3073 group_ops_bls12381_gt_sub_cost: None,
3074 group_ops_bls12381_scalar_mul_cost: None,
3075 group_ops_bls12381_g1_mul_cost: None,
3076 group_ops_bls12381_g2_mul_cost: None,
3077 group_ops_bls12381_gt_mul_cost: None,
3078 group_ops_bls12381_scalar_div_cost: None,
3079 group_ops_bls12381_g1_div_cost: None,
3080 group_ops_bls12381_g2_div_cost: None,
3081 group_ops_bls12381_gt_div_cost: None,
3082 group_ops_bls12381_g1_hash_to_base_cost: None,
3083 group_ops_bls12381_g2_hash_to_base_cost: None,
3084 group_ops_bls12381_g1_hash_to_cost_per_byte: None,
3085 group_ops_bls12381_g2_hash_to_cost_per_byte: None,
3086 group_ops_bls12381_g1_msm_base_cost: None,
3087 group_ops_bls12381_g2_msm_base_cost: None,
3088 group_ops_bls12381_g1_msm_base_cost_per_input: None,
3089 group_ops_bls12381_g2_msm_base_cost_per_input: None,
3090 group_ops_bls12381_msm_max_len: None,
3091 group_ops_bls12381_pairing_cost: None,
3092 group_ops_bls12381_g1_to_uncompressed_g1_cost: None,
3093 group_ops_bls12381_uncompressed_g1_to_g1_cost: None,
3094 group_ops_bls12381_uncompressed_g1_sum_base_cost: None,
3095 group_ops_bls12381_uncompressed_g1_sum_cost_per_term: None,
3096 group_ops_bls12381_uncompressed_g1_sum_max_terms: None,
3097
3098 group_ops_ristretto_decode_scalar_cost: None,
3099 group_ops_ristretto_decode_point_cost: None,
3100 group_ops_ristretto_scalar_add_cost: None,
3101 group_ops_ristretto_point_add_cost: None,
3102 group_ops_ristretto_scalar_sub_cost: None,
3103 group_ops_ristretto_point_sub_cost: None,
3104 group_ops_ristretto_scalar_mul_cost: None,
3105 group_ops_ristretto_point_mul_cost: None,
3106 group_ops_ristretto_scalar_div_cost: None,
3107 group_ops_ristretto_point_div_cost: None,
3108
3109 check_zklogin_id_cost_base: None,
3111 check_zklogin_issuer_cost_base: None,
3113
3114 vdf_verify_vdf_cost: None,
3115 vdf_hash_to_input_cost: None,
3116
3117 nitro_attestation_parse_base_cost: None,
3119 nitro_attestation_parse_cost_per_byte: None,
3120 nitro_attestation_verify_base_cost: None,
3121 nitro_attestation_verify_cost_per_cert: None,
3122
3123 bcs_per_byte_serialized_cost: None,
3124 bcs_legacy_min_output_size_cost: None,
3125 bcs_failure_cost: None,
3126 hash_sha2_256_base_cost: None,
3127 hash_sha2_256_per_byte_cost: None,
3128 hash_sha2_256_legacy_min_input_len_cost: None,
3129 hash_sha3_256_base_cost: None,
3130 hash_sha3_256_per_byte_cost: None,
3131 hash_sha3_256_legacy_min_input_len_cost: None,
3132 type_name_get_base_cost: None,
3133 type_name_get_per_byte_cost: None,
3134 type_name_id_base_cost: None,
3135 string_check_utf8_base_cost: None,
3136 string_check_utf8_per_byte_cost: None,
3137 string_is_char_boundary_base_cost: None,
3138 string_sub_string_base_cost: None,
3139 string_sub_string_per_byte_cost: None,
3140 string_index_of_base_cost: None,
3141 string_index_of_per_byte_pattern_cost: None,
3142 string_index_of_per_byte_searched_cost: None,
3143 vector_empty_base_cost: None,
3144 vector_length_base_cost: None,
3145 vector_push_back_base_cost: None,
3146 vector_push_back_legacy_per_abstract_memory_unit_cost: None,
3147 vector_borrow_base_cost: None,
3148 vector_pop_back_base_cost: None,
3149 vector_destroy_empty_base_cost: None,
3150 vector_swap_base_cost: None,
3151 debug_print_base_cost: None,
3152 debug_print_stack_trace_base_cost: None,
3153
3154 max_size_written_objects: None,
3155 max_size_written_objects_system_tx: None,
3156
3157 max_move_identifier_len: None,
3164 max_move_value_depth: None,
3165 max_move_enum_variants: None,
3166
3167 gas_rounding_step: None,
3168
3169 execution_version: None,
3170
3171 max_event_emit_size_total: None,
3172
3173 consensus_bad_nodes_stake_threshold: None,
3174
3175 max_jwk_votes_per_validator_per_epoch: None,
3176
3177 max_age_of_jwk_in_epochs: None,
3178
3179 random_beacon_reduction_allowed_delta: None,
3180
3181 random_beacon_reduction_lower_bound: None,
3182
3183 random_beacon_dkg_timeout_round: None,
3184
3185 random_beacon_min_round_interval_ms: None,
3186
3187 random_beacon_dkg_version: None,
3188
3189 consensus_max_transaction_size_bytes: None,
3190
3191 consensus_max_transactions_in_block_bytes: None,
3192
3193 consensus_max_num_transactions_in_block: None,
3194
3195 consensus_voting_rounds: None,
3196
3197 max_accumulated_txn_cost_per_object_in_narwhal_commit: None,
3198
3199 max_deferral_rounds_for_congestion_control: None,
3200
3201 max_txn_cost_overage_per_object_in_commit: None,
3202
3203 allowed_txn_cost_overage_burst_per_object_in_commit: None,
3204
3205 min_checkpoint_interval_ms: None,
3206
3207 checkpoint_summary_version_specific_data: None,
3208
3209 max_soft_bundle_size: None,
3210
3211 bridge_should_try_to_finalize_committee: None,
3212
3213 max_accumulated_txn_cost_per_object_in_mysticeti_commit: None,
3214
3215 max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit: None,
3216
3217 consensus_gc_depth: None,
3218
3219 gas_budget_based_txn_cost_cap_factor: None,
3220
3221 gas_budget_based_txn_cost_absolute_cap_commit_count: None,
3222
3223 sip_45_consensus_amplification_threshold: None,
3224
3225 use_object_per_epoch_marker_table_v2: None,
3226
3227 consensus_commit_rate_estimation_window_size: None,
3228
3229 aliased_addresses: vec![],
3230
3231 translation_per_command_base_charge: None,
3232 translation_per_input_base_charge: None,
3233 translation_pure_input_per_byte_charge: None,
3234 translation_per_type_node_charge: None,
3235 translation_per_reference_node_charge: None,
3236 translation_per_linkage_entry_charge: None,
3237
3238 max_updates_per_settlement_txn: None,
3239 };
3242 for cur in 2..=version.0 {
3243 match cur {
3244 1 => unreachable!(),
3245 2 => {
3246 cfg.feature_flags.advance_epoch_start_time_in_safe_mode = true;
3247 }
3248 3 => {
3249 cfg.gas_model_version = Some(2);
3251 cfg.max_tx_gas = Some(50_000_000_000);
3253 cfg.base_tx_cost_fixed = Some(2_000);
3255 cfg.storage_gas_price = Some(76);
3257 cfg.feature_flags.loaded_child_objects_fixed = true;
3258 cfg.max_size_written_objects = Some(5 * 1000 * 1000);
3261 cfg.max_size_written_objects_system_tx = Some(50 * 1000 * 1000);
3264 cfg.feature_flags.package_upgrades = true;
3265 }
3266 4 => {
3271 cfg.reward_slashing_rate = Some(10000);
3273 cfg.gas_model_version = Some(3);
3275 }
3276 5 => {
3277 cfg.feature_flags.missing_type_is_compatibility_error = true;
3278 cfg.gas_model_version = Some(4);
3279 cfg.feature_flags.scoring_decision_with_validity_cutoff = true;
3280 }
3284 6 => {
3285 cfg.gas_model_version = Some(5);
3286 cfg.buffer_stake_for_protocol_upgrade_bps = Some(5000);
3287 cfg.feature_flags.consensus_order_end_of_epoch_last = true;
3288 }
3289 7 => {
3290 cfg.feature_flags.disallow_adding_abilities_on_upgrade = true;
3291 cfg.feature_flags
3292 .disable_invariant_violation_check_in_swap_loc = true;
3293 cfg.feature_flags.ban_entry_init = true;
3294 cfg.feature_flags.package_digest_hash_module = true;
3295 }
3296 8 => {
3297 cfg.feature_flags
3298 .disallow_change_struct_type_params_on_upgrade = true;
3299 }
3300 9 => {
3301 cfg.max_move_identifier_len = Some(128);
3303 cfg.feature_flags.no_extraneous_module_bytes = true;
3304 cfg.feature_flags
3305 .advance_to_highest_supported_protocol_version = true;
3306 }
3307 10 => {
3308 cfg.max_verifier_meter_ticks_per_function = Some(16_000_000);
3309 cfg.max_meter_ticks_per_module = Some(16_000_000);
3310 }
3311 11 => {
3312 cfg.max_move_value_depth = Some(128);
3313 }
3314 12 => {
3315 cfg.feature_flags.narwhal_versioned_metadata = true;
3316 if chain != Chain::Mainnet {
3317 cfg.feature_flags.commit_root_state_digest = true;
3318 }
3319
3320 if chain != Chain::Mainnet && chain != Chain::Testnet {
3321 cfg.feature_flags.zklogin_auth = true;
3322 }
3323 }
3324 13 => {}
3325 14 => {
3326 cfg.gas_rounding_step = Some(1_000);
3327 cfg.gas_model_version = Some(6);
3328 }
3329 15 => {
3330 cfg.feature_flags.consensus_transaction_ordering =
3331 ConsensusTransactionOrdering::ByGasPrice;
3332 }
3333 16 => {
3334 cfg.feature_flags.simplified_unwrap_then_delete = true;
3335 }
3336 17 => {
3337 cfg.feature_flags.upgraded_multisig_supported = true;
3338 }
3339 18 => {
3340 cfg.execution_version = Some(1);
3341 cfg.feature_flags.txn_base_cost_as_multiplier = true;
3350 cfg.base_tx_cost_fixed = Some(1_000);
3352 }
3353 19 => {
3354 cfg.max_num_event_emit = Some(1024);
3355 cfg.max_event_emit_size_total = Some(
3358 256 * 250 * 1024, );
3360 }
3361 20 => {
3362 cfg.feature_flags.commit_root_state_digest = true;
3363
3364 if chain != Chain::Mainnet {
3365 cfg.feature_flags.narwhal_new_leader_election_schedule = true;
3366 cfg.consensus_bad_nodes_stake_threshold = Some(20);
3367 }
3368 }
3369
3370 21 => {
3371 if chain != Chain::Mainnet {
3372 cfg.feature_flags.zklogin_supported_providers = BTreeSet::from([
3373 "Google".to_string(),
3374 "Facebook".to_string(),
3375 "Twitch".to_string(),
3376 ]);
3377 }
3378 }
3379 22 => {
3380 cfg.feature_flags.loaded_child_object_format = true;
3381 }
3382 23 => {
3383 cfg.feature_flags.loaded_child_object_format_type = true;
3384 cfg.feature_flags.narwhal_new_leader_election_schedule = true;
3385 cfg.consensus_bad_nodes_stake_threshold = Some(20);
3391 }
3392 24 => {
3393 cfg.feature_flags.simple_conservation_checks = true;
3394 cfg.max_publish_or_upgrade_per_ptb = Some(5);
3395
3396 cfg.feature_flags.end_of_epoch_transaction_supported = true;
3397
3398 if chain != Chain::Mainnet {
3399 cfg.feature_flags.enable_jwk_consensus_updates = true;
3400 cfg.max_jwk_votes_per_validator_per_epoch = Some(240);
3402 cfg.max_age_of_jwk_in_epochs = Some(1);
3403 }
3404 }
3405 25 => {
3406 cfg.feature_flags.zklogin_supported_providers = BTreeSet::from([
3408 "Google".to_string(),
3409 "Facebook".to_string(),
3410 "Twitch".to_string(),
3411 ]);
3412 cfg.feature_flags.zklogin_auth = true;
3413
3414 cfg.feature_flags.enable_jwk_consensus_updates = true;
3416 cfg.max_jwk_votes_per_validator_per_epoch = Some(240);
3417 cfg.max_age_of_jwk_in_epochs = Some(1);
3418 }
3419 26 => {
3420 cfg.gas_model_version = Some(7);
3421 if chain != Chain::Mainnet && chain != Chain::Testnet {
3423 cfg.transfer_receive_object_cost_base = Some(52);
3424 cfg.feature_flags.receive_objects = true;
3425 }
3426 }
3427 27 => {
3428 cfg.gas_model_version = Some(8);
3429 }
3430 28 => {
3431 cfg.check_zklogin_id_cost_base = Some(200);
3433 cfg.check_zklogin_issuer_cost_base = Some(200);
3435
3436 if chain != Chain::Mainnet && chain != Chain::Testnet {
3438 cfg.feature_flags.enable_effects_v2 = true;
3439 }
3440 }
3441 29 => {
3442 cfg.feature_flags.verify_legacy_zklogin_address = true;
3443 }
3444 30 => {
3445 if chain != Chain::Mainnet {
3447 cfg.feature_flags.narwhal_certificate_v2 = true;
3448 }
3449
3450 cfg.random_beacon_reduction_allowed_delta = Some(800);
3451 if chain != Chain::Mainnet {
3453 cfg.feature_flags.enable_effects_v2 = true;
3454 }
3455
3456 cfg.feature_flags.zklogin_supported_providers = BTreeSet::default();
3460
3461 cfg.feature_flags.recompute_has_public_transfer_in_execution = true;
3462 }
3463 31 => {
3464 cfg.execution_version = Some(2);
3465 if chain != Chain::Mainnet && chain != Chain::Testnet {
3467 cfg.feature_flags.shared_object_deletion = true;
3468 }
3469 }
3470 32 => {
3471 if chain != Chain::Mainnet {
3473 cfg.feature_flags.accept_zklogin_in_multisig = true;
3474 }
3475 if chain != Chain::Mainnet {
3477 cfg.transfer_receive_object_cost_base = Some(52);
3478 cfg.feature_flags.receive_objects = true;
3479 }
3480 if chain != Chain::Mainnet && chain != Chain::Testnet {
3482 cfg.feature_flags.random_beacon = true;
3483 cfg.random_beacon_reduction_lower_bound = Some(1600);
3484 cfg.random_beacon_dkg_timeout_round = Some(3000);
3485 cfg.random_beacon_min_round_interval_ms = Some(150);
3486 }
3487 if chain != Chain::Testnet && chain != Chain::Mainnet {
3489 cfg.feature_flags.include_consensus_digest_in_prologue = true;
3490 }
3491
3492 cfg.feature_flags.narwhal_certificate_v2 = true;
3494 }
3495 33 => {
3496 cfg.feature_flags.hardened_otw_check = true;
3497 cfg.feature_flags.allow_receiving_object_id = true;
3498
3499 cfg.transfer_receive_object_cost_base = Some(52);
3501 cfg.feature_flags.receive_objects = true;
3502
3503 if chain != Chain::Mainnet {
3505 cfg.feature_flags.shared_object_deletion = true;
3506 }
3507
3508 cfg.feature_flags.enable_effects_v2 = true;
3509 }
3510 34 => {}
3511 35 => {
3512 if chain != Chain::Mainnet && chain != Chain::Testnet {
3514 cfg.feature_flags.enable_poseidon = true;
3515 cfg.poseidon_bn254_cost_base = Some(260);
3516 cfg.poseidon_bn254_cost_per_block = Some(10);
3517 }
3518
3519 cfg.feature_flags.enable_coin_deny_list = true;
3520 }
3521 36 => {
3522 if chain != Chain::Mainnet && chain != Chain::Testnet {
3524 cfg.feature_flags.enable_group_ops_native_functions = true;
3525 cfg.feature_flags.enable_group_ops_native_function_msm = true;
3526 cfg.group_ops_bls12381_decode_scalar_cost = Some(52);
3528 cfg.group_ops_bls12381_decode_g1_cost = Some(52);
3529 cfg.group_ops_bls12381_decode_g2_cost = Some(52);
3530 cfg.group_ops_bls12381_decode_gt_cost = Some(52);
3531 cfg.group_ops_bls12381_scalar_add_cost = Some(52);
3532 cfg.group_ops_bls12381_g1_add_cost = Some(52);
3533 cfg.group_ops_bls12381_g2_add_cost = Some(52);
3534 cfg.group_ops_bls12381_gt_add_cost = Some(52);
3535 cfg.group_ops_bls12381_scalar_sub_cost = Some(52);
3536 cfg.group_ops_bls12381_g1_sub_cost = Some(52);
3537 cfg.group_ops_bls12381_g2_sub_cost = Some(52);
3538 cfg.group_ops_bls12381_gt_sub_cost = Some(52);
3539 cfg.group_ops_bls12381_scalar_mul_cost = Some(52);
3540 cfg.group_ops_bls12381_g1_mul_cost = Some(52);
3541 cfg.group_ops_bls12381_g2_mul_cost = Some(52);
3542 cfg.group_ops_bls12381_gt_mul_cost = Some(52);
3543 cfg.group_ops_bls12381_scalar_div_cost = Some(52);
3544 cfg.group_ops_bls12381_g1_div_cost = Some(52);
3545 cfg.group_ops_bls12381_g2_div_cost = Some(52);
3546 cfg.group_ops_bls12381_gt_div_cost = Some(52);
3547 cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(52);
3548 cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(52);
3549 cfg.group_ops_bls12381_g1_hash_to_cost_per_byte = Some(2);
3550 cfg.group_ops_bls12381_g2_hash_to_cost_per_byte = Some(2);
3551 cfg.group_ops_bls12381_g1_msm_base_cost = Some(52);
3552 cfg.group_ops_bls12381_g2_msm_base_cost = Some(52);
3553 cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(52);
3554 cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(52);
3555 cfg.group_ops_bls12381_msm_max_len = Some(32);
3556 cfg.group_ops_bls12381_pairing_cost = Some(52);
3557 }
3558 cfg.feature_flags.shared_object_deletion = true;
3560
3561 cfg.consensus_max_transaction_size_bytes = Some(256 * 1024); cfg.consensus_max_transactions_in_block_bytes = Some(6 * 1_024 * 1024);
3563 }
3565 37 => {
3566 cfg.feature_flags.reject_mutable_random_on_entry_functions = true;
3567
3568 if chain != Chain::Mainnet {
3570 cfg.feature_flags.include_consensus_digest_in_prologue = true;
3571 }
3572 }
3573 38 => {
3574 cfg.binary_module_handles = Some(100);
3575 cfg.binary_struct_handles = Some(300);
3576 cfg.binary_function_handles = Some(1500);
3577 cfg.binary_function_instantiations = Some(750);
3578 cfg.binary_signatures = Some(1000);
3579 cfg.binary_constant_pool = Some(4000);
3583 cfg.binary_identifiers = Some(10000);
3584 cfg.binary_address_identifiers = Some(100);
3585 cfg.binary_struct_defs = Some(200);
3586 cfg.binary_struct_def_instantiations = Some(100);
3587 cfg.binary_function_defs = Some(1000);
3588 cfg.binary_field_handles = Some(500);
3589 cfg.binary_field_instantiations = Some(250);
3590 cfg.binary_friend_decls = Some(100);
3591 cfg.max_package_dependencies = Some(32);
3593 cfg.max_modules_in_publish = Some(64);
3594 cfg.execution_version = Some(3);
3596 }
3597 39 => {
3598 }
3600 40 => {}
3601 41 => {
3602 cfg.feature_flags.enable_group_ops_native_functions = true;
3604 cfg.group_ops_bls12381_decode_scalar_cost = Some(52);
3606 cfg.group_ops_bls12381_decode_g1_cost = Some(52);
3607 cfg.group_ops_bls12381_decode_g2_cost = Some(52);
3608 cfg.group_ops_bls12381_decode_gt_cost = Some(52);
3609 cfg.group_ops_bls12381_scalar_add_cost = Some(52);
3610 cfg.group_ops_bls12381_g1_add_cost = Some(52);
3611 cfg.group_ops_bls12381_g2_add_cost = Some(52);
3612 cfg.group_ops_bls12381_gt_add_cost = Some(52);
3613 cfg.group_ops_bls12381_scalar_sub_cost = Some(52);
3614 cfg.group_ops_bls12381_g1_sub_cost = Some(52);
3615 cfg.group_ops_bls12381_g2_sub_cost = Some(52);
3616 cfg.group_ops_bls12381_gt_sub_cost = Some(52);
3617 cfg.group_ops_bls12381_scalar_mul_cost = Some(52);
3618 cfg.group_ops_bls12381_g1_mul_cost = Some(52);
3619 cfg.group_ops_bls12381_g2_mul_cost = Some(52);
3620 cfg.group_ops_bls12381_gt_mul_cost = Some(52);
3621 cfg.group_ops_bls12381_scalar_div_cost = Some(52);
3622 cfg.group_ops_bls12381_g1_div_cost = Some(52);
3623 cfg.group_ops_bls12381_g2_div_cost = Some(52);
3624 cfg.group_ops_bls12381_gt_div_cost = Some(52);
3625 cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(52);
3626 cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(52);
3627 cfg.group_ops_bls12381_g1_hash_to_cost_per_byte = Some(2);
3628 cfg.group_ops_bls12381_g2_hash_to_cost_per_byte = Some(2);
3629 cfg.group_ops_bls12381_g1_msm_base_cost = Some(52);
3630 cfg.group_ops_bls12381_g2_msm_base_cost = Some(52);
3631 cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(52);
3632 cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(52);
3633 cfg.group_ops_bls12381_msm_max_len = Some(32);
3634 cfg.group_ops_bls12381_pairing_cost = Some(52);
3635 }
3636 42 => {}
3637 43 => {
3638 cfg.feature_flags.zklogin_max_epoch_upper_bound_delta = Some(30);
3639 cfg.max_meter_ticks_per_package = Some(16_000_000);
3640 }
3641 44 => {
3642 cfg.feature_flags.include_consensus_digest_in_prologue = true;
3644 if chain != Chain::Mainnet {
3646 cfg.feature_flags.consensus_choice = ConsensusChoice::SwapEachEpoch;
3647 }
3648 }
3649 45 => {
3650 if chain != Chain::Testnet && chain != Chain::Mainnet {
3652 cfg.feature_flags.consensus_network = ConsensusNetwork::Tonic;
3653 }
3654
3655 if chain != Chain::Mainnet {
3656 cfg.feature_flags.mysticeti_leader_scoring_and_schedule = true;
3658 }
3659 cfg.min_move_binary_format_version = Some(6);
3660 cfg.feature_flags.accept_zklogin_in_multisig = true;
3661
3662 if chain != Chain::Mainnet && chain != Chain::Testnet {
3666 cfg.feature_flags.bridge = true;
3667 }
3668 }
3669 46 => {
3670 if chain != Chain::Mainnet {
3672 cfg.feature_flags.bridge = true;
3673 }
3674
3675 cfg.feature_flags.reshare_at_same_initial_version = true;
3677 }
3678 47 => {}
3679 48 => {
3680 cfg.feature_flags.consensus_network = ConsensusNetwork::Tonic;
3682
3683 cfg.feature_flags.resolve_abort_locations_to_package_id = true;
3685
3686 if chain != Chain::Mainnet {
3688 cfg.feature_flags.random_beacon = true;
3689 cfg.random_beacon_reduction_lower_bound = Some(1600);
3690 cfg.random_beacon_dkg_timeout_round = Some(3000);
3691 cfg.random_beacon_min_round_interval_ms = Some(200);
3692 }
3693
3694 cfg.feature_flags.mysticeti_use_committed_subdag_digest = true;
3696 }
3697 49 => {
3698 if chain != Chain::Testnet && chain != Chain::Mainnet {
3699 cfg.move_binary_format_version = Some(7);
3700 }
3701
3702 if chain != Chain::Mainnet && chain != Chain::Testnet {
3704 cfg.feature_flags.enable_vdf = true;
3705 cfg.vdf_verify_vdf_cost = Some(1500);
3708 cfg.vdf_hash_to_input_cost = Some(100);
3709 }
3710
3711 if chain != Chain::Testnet && chain != Chain::Mainnet {
3713 cfg.feature_flags
3714 .record_consensus_determined_version_assignments_in_prologue = true;
3715 }
3716
3717 if chain != Chain::Mainnet {
3719 cfg.feature_flags.consensus_choice = ConsensusChoice::Mysticeti;
3720 }
3721
3722 cfg.feature_flags.fresh_vm_on_framework_upgrade = true;
3724 }
3725 50 => {
3726 if chain != Chain::Mainnet {
3728 cfg.checkpoint_summary_version_specific_data = Some(1);
3729 cfg.min_checkpoint_interval_ms = Some(200);
3730 }
3731
3732 if chain != Chain::Testnet && chain != Chain::Mainnet {
3734 cfg.feature_flags
3735 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = true;
3736 }
3737
3738 cfg.feature_flags.mysticeti_num_leaders_per_round = Some(1);
3739
3740 cfg.max_deferral_rounds_for_congestion_control = Some(10);
3742 }
3743 51 => {
3744 cfg.random_beacon_dkg_version = Some(1);
3745
3746 if chain != Chain::Testnet && chain != Chain::Mainnet {
3747 cfg.feature_flags.enable_coin_deny_list_v2 = true;
3748 }
3749 }
3750 52 => {
3751 if chain != Chain::Mainnet {
3752 cfg.feature_flags.soft_bundle = true;
3753 cfg.max_soft_bundle_size = Some(5);
3754 }
3755
3756 cfg.config_read_setting_impl_cost_base = Some(100);
3757 cfg.config_read_setting_impl_cost_per_byte = Some(40);
3758
3759 if chain != Chain::Testnet && chain != Chain::Mainnet {
3761 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(100);
3762 cfg.feature_flags.per_object_congestion_control_mode =
3763 PerObjectCongestionControlMode::TotalTxCount;
3764 }
3765
3766 cfg.feature_flags.consensus_choice = ConsensusChoice::Mysticeti;
3768
3769 cfg.feature_flags.mysticeti_leader_scoring_and_schedule = true;
3771
3772 cfg.checkpoint_summary_version_specific_data = Some(1);
3774 cfg.min_checkpoint_interval_ms = Some(200);
3775
3776 if chain != Chain::Mainnet {
3778 cfg.feature_flags
3779 .record_consensus_determined_version_assignments_in_prologue = true;
3780 cfg.feature_flags
3781 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = true;
3782 }
3783 if chain != Chain::Mainnet {
3785 cfg.move_binary_format_version = Some(7);
3786 }
3787
3788 if chain != Chain::Testnet && chain != Chain::Mainnet {
3789 cfg.feature_flags.passkey_auth = true;
3790 }
3791 cfg.feature_flags.enable_coin_deny_list_v2 = true;
3792 }
3793 53 => {
3794 cfg.bridge_should_try_to_finalize_committee = Some(chain != Chain::Mainnet);
3796
3797 cfg.feature_flags
3799 .record_consensus_determined_version_assignments_in_prologue = true;
3800 cfg.feature_flags
3801 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = true;
3802
3803 if chain == Chain::Unknown {
3804 cfg.feature_flags.authority_capabilities_v2 = true;
3805 }
3806
3807 if chain != Chain::Mainnet {
3809 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(100);
3810 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(10);
3811 cfg.feature_flags.per_object_congestion_control_mode =
3812 PerObjectCongestionControlMode::TotalTxCount;
3813 }
3814
3815 cfg.bcs_per_byte_serialized_cost = Some(2);
3817 cfg.bcs_legacy_min_output_size_cost = Some(1);
3818 cfg.bcs_failure_cost = Some(52);
3819 cfg.debug_print_base_cost = Some(52);
3820 cfg.debug_print_stack_trace_base_cost = Some(52);
3821 cfg.hash_sha2_256_base_cost = Some(52);
3822 cfg.hash_sha2_256_per_byte_cost = Some(2);
3823 cfg.hash_sha2_256_legacy_min_input_len_cost = Some(1);
3824 cfg.hash_sha3_256_base_cost = Some(52);
3825 cfg.hash_sha3_256_per_byte_cost = Some(2);
3826 cfg.hash_sha3_256_legacy_min_input_len_cost = Some(1);
3827 cfg.type_name_get_base_cost = Some(52);
3828 cfg.type_name_get_per_byte_cost = Some(2);
3829 cfg.string_check_utf8_base_cost = Some(52);
3830 cfg.string_check_utf8_per_byte_cost = Some(2);
3831 cfg.string_is_char_boundary_base_cost = Some(52);
3832 cfg.string_sub_string_base_cost = Some(52);
3833 cfg.string_sub_string_per_byte_cost = Some(2);
3834 cfg.string_index_of_base_cost = Some(52);
3835 cfg.string_index_of_per_byte_pattern_cost = Some(2);
3836 cfg.string_index_of_per_byte_searched_cost = Some(2);
3837 cfg.vector_empty_base_cost = Some(52);
3838 cfg.vector_length_base_cost = Some(52);
3839 cfg.vector_push_back_base_cost = Some(52);
3840 cfg.vector_push_back_legacy_per_abstract_memory_unit_cost = Some(2);
3841 cfg.vector_borrow_base_cost = Some(52);
3842 cfg.vector_pop_back_base_cost = Some(52);
3843 cfg.vector_destroy_empty_base_cost = Some(52);
3844 cfg.vector_swap_base_cost = Some(52);
3845 }
3846 54 => {
3847 cfg.feature_flags.random_beacon = true;
3849 cfg.random_beacon_reduction_lower_bound = Some(1000);
3850 cfg.random_beacon_dkg_timeout_round = Some(3000);
3851 cfg.random_beacon_min_round_interval_ms = Some(500);
3852
3853 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(100);
3855 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(10);
3856 cfg.feature_flags.per_object_congestion_control_mode =
3857 PerObjectCongestionControlMode::TotalTxCount;
3858
3859 cfg.feature_flags.soft_bundle = true;
3861 cfg.max_soft_bundle_size = Some(5);
3862 }
3863 55 => {
3864 cfg.move_binary_format_version = Some(7);
3866
3867 cfg.consensus_max_transactions_in_block_bytes = Some(512 * 1024);
3869 cfg.consensus_max_num_transactions_in_block = Some(512);
3872
3873 cfg.feature_flags.rethrow_serialization_type_layout_errors = true;
3874 }
3875 56 => {
3876 if chain == Chain::Mainnet {
3877 cfg.feature_flags.bridge = true;
3878 }
3879 }
3880 57 => {
3881 cfg.random_beacon_reduction_lower_bound = Some(800);
3883 }
3884 58 => {
3885 if chain == Chain::Mainnet {
3886 cfg.bridge_should_try_to_finalize_committee = Some(true);
3887 }
3888
3889 if chain != Chain::Mainnet && chain != Chain::Testnet {
3890 cfg.feature_flags
3892 .consensus_distributed_vote_scoring_strategy = true;
3893 }
3894 }
3895 59 => {
3896 cfg.feature_flags.consensus_round_prober = true;
3898 }
3899 60 => {
3900 cfg.max_type_to_layout_nodes = Some(512);
3901 cfg.feature_flags.validate_identifier_inputs = true;
3902 }
3903 61 => {
3904 if chain != Chain::Mainnet {
3905 cfg.feature_flags
3907 .consensus_distributed_vote_scoring_strategy = true;
3908 }
3909 cfg.random_beacon_reduction_lower_bound = Some(700);
3911
3912 if chain != Chain::Mainnet && chain != Chain::Testnet {
3913 cfg.feature_flags.mysticeti_fastpath = true;
3915 }
3916 }
3917 62 => {
3918 cfg.feature_flags.relocate_event_module = true;
3919 }
3920 63 => {
3921 cfg.feature_flags.per_object_congestion_control_mode =
3922 PerObjectCongestionControlMode::TotalGasBudgetWithCap;
3923 cfg.gas_budget_based_txn_cost_cap_factor = Some(400_000);
3924 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(18_500_000);
3925 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(240_000_000);
3926 }
3927 64 => {
3928 cfg.feature_flags.per_object_congestion_control_mode =
3929 PerObjectCongestionControlMode::TotalTxCount;
3930 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(40);
3931 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(3);
3932 }
3933 65 => {
3934 cfg.feature_flags
3936 .consensus_distributed_vote_scoring_strategy = true;
3937 }
3938 66 => {
3939 if chain == Chain::Mainnet {
3940 cfg.feature_flags
3942 .consensus_distributed_vote_scoring_strategy = false;
3943 }
3944 }
3945 67 => {
3946 cfg.feature_flags
3948 .consensus_distributed_vote_scoring_strategy = true;
3949 }
3950 68 => {
3951 cfg.group_ops_bls12381_g1_to_uncompressed_g1_cost = Some(26);
3952 cfg.group_ops_bls12381_uncompressed_g1_to_g1_cost = Some(52);
3953 cfg.group_ops_bls12381_uncompressed_g1_sum_base_cost = Some(26);
3954 cfg.group_ops_bls12381_uncompressed_g1_sum_cost_per_term = Some(13);
3955 cfg.group_ops_bls12381_uncompressed_g1_sum_max_terms = Some(2000);
3956
3957 if chain != Chain::Mainnet && chain != Chain::Testnet {
3958 cfg.feature_flags.uncompressed_g1_group_elements = true;
3959 }
3960
3961 cfg.feature_flags.per_object_congestion_control_mode =
3962 PerObjectCongestionControlMode::TotalGasBudgetWithCap;
3963 cfg.gas_budget_based_txn_cost_cap_factor = Some(400_000);
3964 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(18_500_000);
3965 cfg.max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit =
3966 Some(3_700_000); cfg.max_txn_cost_overage_per_object_in_commit = Some(u64::MAX);
3968 cfg.gas_budget_based_txn_cost_absolute_cap_commit_count = Some(50);
3969
3970 cfg.random_beacon_reduction_lower_bound = Some(500);
3972
3973 cfg.feature_flags.disallow_new_modules_in_deps_only_packages = true;
3974 }
3975 69 => {
3976 cfg.consensus_voting_rounds = Some(40);
3978
3979 if chain != Chain::Mainnet && chain != Chain::Testnet {
3980 cfg.feature_flags.consensus_smart_ancestor_selection = true;
3982 }
3983
3984 if chain != Chain::Mainnet {
3985 cfg.feature_flags.uncompressed_g1_group_elements = true;
3986 }
3987 }
3988 70 => {
3989 if chain != Chain::Mainnet {
3990 cfg.feature_flags.consensus_smart_ancestor_selection = true;
3992 cfg.feature_flags
3994 .consensus_round_prober_probe_accepted_rounds = true;
3995 }
3996
3997 cfg.poseidon_bn254_cost_per_block = Some(388);
3998
3999 cfg.gas_model_version = Some(9);
4000 cfg.feature_flags.native_charging_v2 = true;
4001 cfg.bls12381_bls12381_min_sig_verify_cost_base = Some(44064);
4002 cfg.bls12381_bls12381_min_pk_verify_cost_base = Some(49282);
4003 cfg.ecdsa_k1_secp256k1_verify_keccak256_cost_base = Some(1470);
4004 cfg.ecdsa_k1_secp256k1_verify_sha256_cost_base = Some(1470);
4005 cfg.ecdsa_r1_secp256r1_verify_sha256_cost_base = Some(4225);
4006 cfg.ecdsa_r1_secp256r1_verify_keccak256_cost_base = Some(4225);
4007 cfg.ecvrf_ecvrf_verify_cost_base = Some(4848);
4008 cfg.ed25519_ed25519_verify_cost_base = Some(1802);
4009
4010 cfg.ecdsa_r1_ecrecover_keccak256_cost_base = Some(1173);
4012 cfg.ecdsa_r1_ecrecover_sha256_cost_base = Some(1173);
4013 cfg.ecdsa_k1_ecrecover_keccak256_cost_base = Some(500);
4014 cfg.ecdsa_k1_ecrecover_sha256_cost_base = Some(500);
4015
4016 cfg.groth16_prepare_verifying_key_bls12381_cost_base = Some(53838);
4017 cfg.groth16_prepare_verifying_key_bn254_cost_base = Some(82010);
4018 cfg.groth16_verify_groth16_proof_internal_bls12381_cost_base = Some(72090);
4019 cfg.groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input =
4020 Some(8213);
4021 cfg.groth16_verify_groth16_proof_internal_bn254_cost_base = Some(115502);
4022 cfg.groth16_verify_groth16_proof_internal_bn254_cost_per_public_input =
4023 Some(9484);
4024
4025 cfg.hash_keccak256_cost_base = Some(10);
4026 cfg.hash_blake2b256_cost_base = Some(10);
4027
4028 cfg.group_ops_bls12381_decode_scalar_cost = Some(7);
4030 cfg.group_ops_bls12381_decode_g1_cost = Some(2848);
4031 cfg.group_ops_bls12381_decode_g2_cost = Some(3770);
4032 cfg.group_ops_bls12381_decode_gt_cost = Some(3068);
4033
4034 cfg.group_ops_bls12381_scalar_add_cost = Some(10);
4035 cfg.group_ops_bls12381_g1_add_cost = Some(1556);
4036 cfg.group_ops_bls12381_g2_add_cost = Some(3048);
4037 cfg.group_ops_bls12381_gt_add_cost = Some(188);
4038
4039 cfg.group_ops_bls12381_scalar_sub_cost = Some(10);
4040 cfg.group_ops_bls12381_g1_sub_cost = Some(1550);
4041 cfg.group_ops_bls12381_g2_sub_cost = Some(3019);
4042 cfg.group_ops_bls12381_gt_sub_cost = Some(497);
4043
4044 cfg.group_ops_bls12381_scalar_mul_cost = Some(11);
4045 cfg.group_ops_bls12381_g1_mul_cost = Some(4842);
4046 cfg.group_ops_bls12381_g2_mul_cost = Some(9108);
4047 cfg.group_ops_bls12381_gt_mul_cost = Some(27490);
4048
4049 cfg.group_ops_bls12381_scalar_div_cost = Some(91);
4050 cfg.group_ops_bls12381_g1_div_cost = Some(5091);
4051 cfg.group_ops_bls12381_g2_div_cost = Some(9206);
4052 cfg.group_ops_bls12381_gt_div_cost = Some(27804);
4053
4054 cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(2962);
4055 cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(8688);
4056
4057 cfg.group_ops_bls12381_g1_msm_base_cost = Some(62648);
4058 cfg.group_ops_bls12381_g2_msm_base_cost = Some(131192);
4059 cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(1333);
4060 cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(3216);
4061
4062 cfg.group_ops_bls12381_uncompressed_g1_to_g1_cost = Some(677);
4063 cfg.group_ops_bls12381_g1_to_uncompressed_g1_cost = Some(2099);
4064 cfg.group_ops_bls12381_uncompressed_g1_sum_base_cost = Some(77);
4065 cfg.group_ops_bls12381_uncompressed_g1_sum_cost_per_term = Some(26);
4066
4067 cfg.group_ops_bls12381_pairing_cost = Some(26897);
4068 cfg.group_ops_bls12381_uncompressed_g1_sum_max_terms = Some(1200);
4069
4070 cfg.validator_validate_metadata_cost_base = Some(20000);
4071 }
4072 71 => {
4073 cfg.sip_45_consensus_amplification_threshold = Some(5);
4074
4075 cfg.allowed_txn_cost_overage_burst_per_object_in_commit = Some(185_000_000);
4077 }
4078 72 => {
4079 cfg.feature_flags.convert_type_argument_error = true;
4080
4081 cfg.max_tx_gas = Some(50_000_000_000_000);
4084 cfg.max_gas_price = Some(50_000_000_000);
4086
4087 cfg.feature_flags.variant_nodes = true;
4088 }
4089 73 => {
4090 cfg.use_object_per_epoch_marker_table_v2 = Some(true);
4092
4093 if chain != Chain::Mainnet && chain != Chain::Testnet {
4094 cfg.consensus_gc_depth = Some(60);
4097 }
4098
4099 if chain != Chain::Mainnet {
4100 cfg.feature_flags.consensus_zstd_compression = true;
4102 }
4103
4104 cfg.feature_flags.consensus_smart_ancestor_selection = true;
4106 cfg.feature_flags
4108 .consensus_round_prober_probe_accepted_rounds = true;
4109
4110 cfg.feature_flags.per_object_congestion_control_mode =
4112 PerObjectCongestionControlMode::TotalGasBudgetWithCap;
4113 cfg.gas_budget_based_txn_cost_cap_factor = Some(400_000);
4114 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(37_000_000);
4115 cfg.max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit =
4116 Some(7_400_000); cfg.max_txn_cost_overage_per_object_in_commit = Some(u64::MAX);
4118 cfg.gas_budget_based_txn_cost_absolute_cap_commit_count = Some(50);
4119 cfg.allowed_txn_cost_overage_burst_per_object_in_commit = Some(370_000_000);
4120 }
4121 74 => {
4122 if chain != Chain::Mainnet && chain != Chain::Testnet {
4124 cfg.feature_flags.enable_nitro_attestation = true;
4125 }
4126 cfg.nitro_attestation_parse_base_cost = Some(53 * 50);
4127 cfg.nitro_attestation_parse_cost_per_byte = Some(50);
4128 cfg.nitro_attestation_verify_base_cost = Some(49632 * 50);
4129 cfg.nitro_attestation_verify_cost_per_cert = Some(52369 * 50);
4130
4131 cfg.feature_flags.consensus_zstd_compression = true;
4133
4134 if chain != Chain::Mainnet && chain != Chain::Testnet {
4135 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
4136 }
4137 }
4138 75 => {
4139 if chain != Chain::Mainnet {
4140 cfg.feature_flags.passkey_auth = true;
4141 }
4142 }
4143 76 => {
4144 if chain != Chain::Mainnet && chain != Chain::Testnet {
4145 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
4146 cfg.consensus_commit_rate_estimation_window_size = Some(10);
4147 }
4148 cfg.feature_flags.minimize_child_object_mutations = true;
4149
4150 if chain != Chain::Mainnet {
4151 cfg.feature_flags.accept_passkey_in_multisig = true;
4152 }
4153 }
4154 77 => {
4155 cfg.feature_flags.uncompressed_g1_group_elements = true;
4156
4157 if chain != Chain::Mainnet {
4158 cfg.consensus_gc_depth = Some(60);
4159 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
4160 }
4161 }
4162 78 => {
4163 cfg.feature_flags.move_native_context = true;
4164 cfg.tx_context_fresh_id_cost_base = Some(52);
4165 cfg.tx_context_sender_cost_base = Some(30);
4166 cfg.tx_context_epoch_cost_base = Some(30);
4167 cfg.tx_context_epoch_timestamp_ms_cost_base = Some(30);
4168 cfg.tx_context_sponsor_cost_base = Some(30);
4169 cfg.tx_context_gas_price_cost_base = Some(30);
4170 cfg.tx_context_gas_budget_cost_base = Some(30);
4171 cfg.tx_context_ids_created_cost_base = Some(30);
4172 cfg.tx_context_replace_cost_base = Some(30);
4173 cfg.gas_model_version = Some(10);
4174
4175 if chain != Chain::Mainnet {
4176 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
4177 cfg.consensus_commit_rate_estimation_window_size = Some(10);
4178
4179 cfg.feature_flags.per_object_congestion_control_mode =
4181 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4182 ExecutionTimeEstimateParams {
4183 target_utilization: 30,
4184 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4186 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4188 stored_observations_limit: u64::MAX,
4189 stake_weighted_median_threshold: 0,
4190 default_none_duration_for_new_keys: false,
4191 observations_chunk_size: None,
4192 },
4193 );
4194 }
4195 }
4196 79 => {
4197 if chain != Chain::Mainnet {
4198 cfg.feature_flags.consensus_median_based_commit_timestamp = true;
4199
4200 cfg.consensus_bad_nodes_stake_threshold = Some(30);
4203
4204 cfg.feature_flags.consensus_batched_block_sync = true;
4205
4206 cfg.feature_flags.enable_nitro_attestation = true
4208 }
4209 cfg.feature_flags.normalize_ptb_arguments = true;
4210
4211 cfg.consensus_gc_depth = Some(60);
4212 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
4213 }
4214 80 => {
4215 cfg.max_ptb_value_size = Some(1024 * 1024);
4216 }
4217 81 => {
4218 cfg.feature_flags.consensus_median_based_commit_timestamp = true;
4219 cfg.feature_flags.enforce_checkpoint_timestamp_monotonicity = true;
4220 cfg.consensus_bad_nodes_stake_threshold = Some(30)
4221 }
4222 82 => {
4223 cfg.feature_flags.max_ptb_value_size_v2 = true;
4224 }
4225 83 => {
4226 if chain == Chain::Mainnet {
4227 let aliased: [u8; 32] = Hex::decode(
4229 "0x0b2da327ba6a4cacbe75dddd50e6e8bbf81d6496e92d66af9154c61c77f7332f",
4230 )
4231 .unwrap()
4232 .try_into()
4233 .unwrap();
4234
4235 cfg.aliased_addresses.push(AliasedAddress {
4237 original: Hex::decode("0xcd8962dad278d8b50fa0f9eb0186bfa4cbdecc6d59377214c88d0286a0ac9562").unwrap().try_into().unwrap(),
4238 aliased,
4239 allowed_tx_digests: vec![
4240 Base58::decode("B2eGLFoMHgj93Ni8dAJBfqGzo8EWSTLBesZzhEpTPA4").unwrap().try_into().unwrap(),
4241 ],
4242 });
4243
4244 cfg.aliased_addresses.push(AliasedAddress {
4245 original: Hex::decode("0xe28b50cef1d633ea43d3296a3f6b67ff0312a5f1a99f0af753c85b8b5de8ff06").unwrap().try_into().unwrap(),
4246 aliased,
4247 allowed_tx_digests: vec![
4248 Base58::decode("J4QqSAgp7VrQtQpMy5wDX4QGsCSEZu3U5KuDAkbESAge").unwrap().try_into().unwrap(),
4249 ],
4250 });
4251 }
4252
4253 if chain != Chain::Mainnet {
4256 cfg.feature_flags.resolve_type_input_ids_to_defining_id = true;
4257 cfg.transfer_party_transfer_internal_cost_base = Some(52);
4258
4259 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
4261 cfg.consensus_commit_rate_estimation_window_size = Some(10);
4262 cfg.feature_flags.per_object_congestion_control_mode =
4263 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4264 ExecutionTimeEstimateParams {
4265 target_utilization: 30,
4266 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4268 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4270 stored_observations_limit: u64::MAX,
4271 stake_weighted_median_threshold: 0,
4272 default_none_duration_for_new_keys: false,
4273 observations_chunk_size: None,
4274 },
4275 );
4276
4277 cfg.feature_flags.consensus_batched_block_sync = true;
4279
4280 cfg.feature_flags.enable_nitro_attestation_upgraded_parsing = true;
4283 cfg.feature_flags.enable_nitro_attestation = true;
4284 }
4285 }
4286 84 => {
4287 if chain == Chain::Mainnet {
4288 cfg.feature_flags.resolve_type_input_ids_to_defining_id = true;
4289 cfg.transfer_party_transfer_internal_cost_base = Some(52);
4290
4291 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
4293 cfg.consensus_commit_rate_estimation_window_size = Some(10);
4294 cfg.feature_flags.per_object_congestion_control_mode =
4295 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4296 ExecutionTimeEstimateParams {
4297 target_utilization: 30,
4298 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4300 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4302 stored_observations_limit: u64::MAX,
4303 stake_weighted_median_threshold: 0,
4304 default_none_duration_for_new_keys: false,
4305 observations_chunk_size: None,
4306 },
4307 );
4308
4309 cfg.feature_flags.consensus_batched_block_sync = true;
4311
4312 cfg.feature_flags.enable_nitro_attestation_upgraded_parsing = true;
4315 cfg.feature_flags.enable_nitro_attestation = true;
4316 }
4317
4318 cfg.feature_flags.per_object_congestion_control_mode =
4320 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4321 ExecutionTimeEstimateParams {
4322 target_utilization: 30,
4323 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4325 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4327 stored_observations_limit: 20,
4328 stake_weighted_median_threshold: 0,
4329 default_none_duration_for_new_keys: false,
4330 observations_chunk_size: None,
4331 },
4332 );
4333 cfg.feature_flags.allow_unbounded_system_objects = true;
4334 }
4335 85 => {
4336 if chain != Chain::Mainnet && chain != Chain::Testnet {
4337 cfg.feature_flags.enable_party_transfer = true;
4338 }
4339
4340 cfg.feature_flags
4341 .record_consensus_determined_version_assignments_in_prologue_v2 = true;
4342 cfg.feature_flags.disallow_self_identifier = true;
4343 cfg.feature_flags.per_object_congestion_control_mode =
4344 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4345 ExecutionTimeEstimateParams {
4346 target_utilization: 50,
4347 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4349 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4351 stored_observations_limit: 20,
4352 stake_weighted_median_threshold: 0,
4353 default_none_duration_for_new_keys: false,
4354 observations_chunk_size: None,
4355 },
4356 );
4357 }
4358 86 => {
4359 cfg.feature_flags.type_tags_in_object_runtime = true;
4360 cfg.max_move_enum_variants = Some(move_core_types::VARIANT_COUNT_MAX);
4361
4362 cfg.feature_flags.per_object_congestion_control_mode =
4364 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4365 ExecutionTimeEstimateParams {
4366 target_utilization: 50,
4367 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4369 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4371 stored_observations_limit: 20,
4372 stake_weighted_median_threshold: 3334,
4373 default_none_duration_for_new_keys: false,
4374 observations_chunk_size: None,
4375 },
4376 );
4377 if chain != Chain::Mainnet {
4379 cfg.feature_flags.enable_party_transfer = true;
4380 }
4381 }
4382 87 => {
4383 if chain == Chain::Mainnet {
4384 cfg.feature_flags.record_time_estimate_processed = true;
4385 }
4386 cfg.feature_flags.better_adapter_type_resolution_errors = true;
4387 }
4388 88 => {
4389 cfg.feature_flags.record_time_estimate_processed = true;
4390 cfg.tx_context_rgp_cost_base = Some(30);
4391 cfg.feature_flags
4392 .ignore_execution_time_observations_after_certs_closed = true;
4393
4394 cfg.feature_flags.per_object_congestion_control_mode =
4397 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4398 ExecutionTimeEstimateParams {
4399 target_utilization: 50,
4400 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4402 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4404 stored_observations_limit: 20,
4405 stake_weighted_median_threshold: 3334,
4406 default_none_duration_for_new_keys: true,
4407 observations_chunk_size: None,
4408 },
4409 );
4410 }
4411 89 => {
4412 cfg.feature_flags.dependency_linkage_error = true;
4413 cfg.feature_flags.additional_multisig_checks = true;
4414 }
4415 90 => {
4416 cfg.max_gas_price_rgp_factor_for_aborted_transactions = Some(100);
4418 cfg.feature_flags.debug_fatal_on_move_invariant_violation = true;
4419 cfg.feature_flags.additional_consensus_digest_indirect_state = true;
4420 cfg.feature_flags.accept_passkey_in_multisig = true;
4421 cfg.feature_flags.passkey_auth = true;
4422 cfg.feature_flags.check_for_init_during_upgrade = true;
4423
4424 if chain != Chain::Mainnet {
4426 cfg.feature_flags.mysticeti_fastpath = true;
4427 }
4428 }
4429 91 => {
4430 cfg.feature_flags.per_command_shared_object_transfer_rules = true;
4431 }
4432 92 => {
4433 cfg.feature_flags.per_command_shared_object_transfer_rules = false;
4434 }
4435 93 => {
4436 cfg.feature_flags
4437 .consensus_checkpoint_signature_key_includes_digest = true;
4438 }
4439 94 => {
4440 cfg.feature_flags.per_object_congestion_control_mode =
4442 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4443 ExecutionTimeEstimateParams {
4444 target_utilization: 50,
4445 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4447 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4449 stored_observations_limit: 18,
4450 stake_weighted_median_threshold: 3334,
4451 default_none_duration_for_new_keys: true,
4452 observations_chunk_size: None,
4453 },
4454 );
4455
4456 cfg.feature_flags.enable_party_transfer = true;
4458 }
4459 95 => {
4460 cfg.type_name_id_base_cost = Some(52);
4461
4462 cfg.max_transactions_per_checkpoint = Some(20_000);
4464 }
4465 96 => {
4466 if chain != Chain::Mainnet && chain != Chain::Testnet {
4468 cfg.feature_flags
4469 .include_checkpoint_artifacts_digest_in_summary = true;
4470 }
4471 cfg.feature_flags.correct_gas_payment_limit_check = true;
4472 cfg.feature_flags.authority_capabilities_v2 = true;
4473 cfg.feature_flags.use_mfp_txns_in_load_initial_object_debts = true;
4474 cfg.feature_flags.cancel_for_failed_dkg_early = true;
4475 cfg.feature_flags.enable_coin_registry = true;
4476
4477 cfg.feature_flags.mysticeti_fastpath = true;
4479 }
4480 97 => {
4481 cfg.feature_flags.additional_borrow_checks = true;
4482 }
4483 98 => {
4484 cfg.event_emit_auth_stream_cost = Some(52);
4485 cfg.feature_flags.better_loader_errors = true;
4486 cfg.feature_flags.generate_df_type_layouts = true;
4487 }
4488 99 => {
4489 cfg.feature_flags.use_new_commit_handler = true;
4490 }
4491 100 => {
4492 cfg.feature_flags.private_generics_verifier_v2 = true;
4493 }
4494 101 => {
4495 cfg.feature_flags.create_root_accumulator_object = true;
4496 cfg.max_updates_per_settlement_txn = Some(100);
4497 if chain != Chain::Mainnet {
4498 cfg.feature_flags.enable_poseidon = true;
4499 }
4500 }
4501 102 => {
4502 cfg.feature_flags.per_object_congestion_control_mode =
4506 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4507 ExecutionTimeEstimateParams {
4508 target_utilization: 50,
4509 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4511 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4513 stored_observations_limit: 180,
4514 stake_weighted_median_threshold: 3334,
4515 default_none_duration_for_new_keys: true,
4516 observations_chunk_size: Some(18),
4517 },
4518 );
4519 cfg.feature_flags.deprecate_global_storage_ops = true;
4520 }
4521 103 => {}
4522 104 => {
4523 cfg.translation_per_command_base_charge = Some(1);
4524 cfg.translation_per_input_base_charge = Some(1);
4525 cfg.translation_pure_input_per_byte_charge = Some(1);
4526 cfg.translation_per_type_node_charge = Some(1);
4527 cfg.translation_per_reference_node_charge = Some(1);
4528 cfg.translation_per_linkage_entry_charge = Some(10);
4529 cfg.gas_model_version = Some(11);
4530 cfg.feature_flags.abstract_size_in_object_runtime = true;
4531 cfg.feature_flags.object_runtime_charge_cache_load_gas = true;
4532 cfg.dynamic_field_hash_type_and_key_cost_base = Some(52);
4533 cfg.dynamic_field_add_child_object_cost_base = Some(52);
4534 cfg.dynamic_field_add_child_object_value_cost_per_byte = Some(1);
4535 cfg.dynamic_field_borrow_child_object_cost_base = Some(52);
4536 cfg.dynamic_field_borrow_child_object_child_ref_cost_per_byte = Some(1);
4537 cfg.dynamic_field_remove_child_object_cost_base = Some(52);
4538 cfg.dynamic_field_remove_child_object_child_cost_per_byte = Some(1);
4539 cfg.dynamic_field_has_child_object_cost_base = Some(52);
4540 cfg.dynamic_field_has_child_object_with_ty_cost_base = Some(52);
4541 cfg.feature_flags.enable_ptb_execution_v2 = true;
4542
4543 cfg.poseidon_bn254_cost_base = Some(260);
4544
4545 cfg.feature_flags.consensus_skip_gced_accept_votes = true;
4546
4547 if chain != Chain::Mainnet {
4548 cfg.feature_flags
4549 .enable_nitro_attestation_all_nonzero_pcrs_parsing = true;
4550 }
4551
4552 cfg.feature_flags
4553 .include_cancelled_randomness_txns_in_prologue = true;
4554 }
4555 105 => {
4556 cfg.feature_flags.enable_multi_epoch_transaction_expiration = true;
4557 cfg.feature_flags.disable_preconsensus_locking = true;
4558
4559 if chain != Chain::Mainnet {
4560 cfg.feature_flags
4561 .enable_nitro_attestation_always_include_required_pcrs_parsing = true;
4562 }
4563 }
4564 106 => {
4565 cfg.accumulator_object_storage_cost = Some(7600);
4567
4568 if chain != Chain::Mainnet && chain != Chain::Testnet {
4569 cfg.feature_flags.enable_accumulators = true;
4570 cfg.feature_flags.enable_address_balance_gas_payments = true;
4571 cfg.feature_flags.enable_authenticated_event_streams = true;
4572 cfg.feature_flags.enable_object_funds_withdraw = true;
4573 }
4574 }
4575 107 => {
4576 cfg.feature_flags
4577 .consensus_skip_gced_blocks_in_direct_finalization = true;
4578
4579 if in_integration_test() {
4581 cfg.consensus_gc_depth = Some(6);
4582 cfg.consensus_max_num_transactions_in_block = Some(8);
4583 }
4584 }
4585 108 => {
4586 cfg.feature_flags.gas_rounding_halve_digits = true;
4587 cfg.feature_flags.flexible_tx_context_positions = true;
4588 cfg.feature_flags.disable_entry_point_signature_check = true;
4589
4590 if chain != Chain::Mainnet {
4591 cfg.feature_flags.address_aliases = true;
4592
4593 cfg.feature_flags.enable_accumulators = true;
4594 cfg.feature_flags.enable_address_balance_gas_payments = true;
4595 }
4596
4597 cfg.feature_flags.enable_poseidon = true;
4598 }
4599 109 => {
4600 cfg.binary_variant_handles = Some(1024);
4601 cfg.binary_variant_instantiation_handles = Some(1024);
4602 cfg.feature_flags.restrict_hot_or_not_entry_functions = true;
4603 }
4604 110 => {
4605 cfg.feature_flags
4606 .enable_nitro_attestation_all_nonzero_pcrs_parsing = true;
4607 cfg.feature_flags
4608 .enable_nitro_attestation_always_include_required_pcrs_parsing = true;
4609 if chain != Chain::Mainnet && chain != Chain::Testnet {
4610 cfg.feature_flags.split_checkpoints_in_consensus_handler = true;
4611 }
4612 cfg.feature_flags.validate_zklogin_public_identifier = true;
4613 cfg.feature_flags.fix_checkpoint_signature_mapping = true;
4614 cfg.feature_flags
4615 .consensus_always_accept_system_transactions = true;
4616 if chain != Chain::Mainnet {
4617 cfg.feature_flags.enable_object_funds_withdraw = true;
4618 }
4619 }
4620 111 => {
4621 cfg.feature_flags.validator_metadata_verify_v2 = true;
4622 }
4623 112 => {
4624 cfg.group_ops_ristretto_decode_scalar_cost = Some(7);
4625 cfg.group_ops_ristretto_decode_point_cost = Some(200);
4626 cfg.group_ops_ristretto_scalar_add_cost = Some(10);
4627 cfg.group_ops_ristretto_point_add_cost = Some(500);
4628 cfg.group_ops_ristretto_scalar_sub_cost = Some(10);
4629 cfg.group_ops_ristretto_point_sub_cost = Some(500);
4630 cfg.group_ops_ristretto_scalar_mul_cost = Some(11);
4631 cfg.group_ops_ristretto_point_mul_cost = Some(1200);
4632 cfg.group_ops_ristretto_scalar_div_cost = Some(151);
4633 cfg.group_ops_ristretto_point_div_cost = Some(2500);
4634
4635 if chain != Chain::Mainnet && chain != Chain::Testnet {
4636 cfg.feature_flags.enable_ristretto255_group_ops = true;
4637 }
4638 }
4639 113 => {
4640 cfg.feature_flags.address_balance_gas_check_rgp_at_signing = true;
4641 if chain != Chain::Mainnet && chain != Chain::Testnet {
4642 cfg.feature_flags.defer_unpaid_amplification = true;
4643 }
4644 }
4645 114 => {
4646 cfg.feature_flags.randomize_checkpoint_tx_limit_in_tests = true;
4647 cfg.feature_flags.address_balance_gas_reject_gas_coin_arg = true;
4648 if chain != Chain::Mainnet {
4649 cfg.feature_flags.split_checkpoints_in_consensus_handler = true;
4650 cfg.feature_flags.enable_authenticated_event_streams = true;
4651 cfg.feature_flags
4652 .include_checkpoint_artifacts_digest_in_summary = true;
4653 }
4654 cfg.feature_flags.defer_unpaid_amplification = false;
4656 }
4657 115 => {
4658 cfg.feature_flags.gasless_transaction_drop_safety = true;
4659 cfg.feature_flags.address_aliases = true;
4660 cfg.feature_flags.relax_valid_during_for_owned_inputs = true;
4661 }
4662 _ => panic!("unsupported version {:?}", version),
4673 }
4674 }
4675
4676 cfg
4677 }
4678
4679 pub fn apply_seeded_test_overrides(&mut self, seed: &[u8; 32]) {
4680 if !self.feature_flags.randomize_checkpoint_tx_limit_in_tests
4681 || !self.feature_flags.split_checkpoints_in_consensus_handler
4682 {
4683 return;
4684 }
4685
4686 if !mysten_common::in_test_configuration() {
4687 return;
4688 }
4689
4690 use rand::{Rng, SeedableRng, rngs::StdRng};
4691 let mut rng = StdRng::from_seed(*seed);
4692 let max_txns = rng.gen_range(10..=100u64);
4693 info!("seeded test override: max_transactions_per_checkpoint = {max_txns}");
4694 self.max_transactions_per_checkpoint = Some(max_txns);
4695 }
4696
4697 pub fn verifier_config(&self, signing_limits: Option<(usize, usize, usize)>) -> VerifierConfig {
4703 let (
4704 max_back_edges_per_function,
4705 max_back_edges_per_module,
4706 sanity_check_with_regex_reference_safety,
4707 ) = if let Some((
4708 max_back_edges_per_function,
4709 max_back_edges_per_module,
4710 sanity_check_with_regex_reference_safety,
4711 )) = signing_limits
4712 {
4713 (
4714 Some(max_back_edges_per_function),
4715 Some(max_back_edges_per_module),
4716 Some(sanity_check_with_regex_reference_safety),
4717 )
4718 } else {
4719 (None, None, None)
4720 };
4721
4722 let additional_borrow_checks = if signing_limits.is_some() {
4723 true
4725 } else {
4726 self.additional_borrow_checks()
4727 };
4728 let deprecate_global_storage_ops = if signing_limits.is_some() {
4729 true
4731 } else {
4732 self.deprecate_global_storage_ops()
4733 };
4734
4735 VerifierConfig {
4736 max_loop_depth: Some(self.max_loop_depth() as usize),
4737 max_generic_instantiation_length: Some(self.max_generic_instantiation_length() as usize),
4738 max_function_parameters: Some(self.max_function_parameters() as usize),
4739 max_basic_blocks: Some(self.max_basic_blocks() as usize),
4740 max_value_stack_size: self.max_value_stack_size() as usize,
4741 max_type_nodes: Some(self.max_type_nodes() as usize),
4742 max_push_size: Some(self.max_push_size() as usize),
4743 max_dependency_depth: Some(self.max_dependency_depth() as usize),
4744 max_fields_in_struct: Some(self.max_fields_in_struct() as usize),
4745 max_function_definitions: Some(self.max_function_definitions() as usize),
4746 max_data_definitions: Some(self.max_struct_definitions() as usize),
4747 max_constant_vector_len: Some(self.max_move_vector_len()),
4748 max_back_edges_per_function,
4749 max_back_edges_per_module,
4750 max_basic_blocks_in_script: None,
4751 max_identifier_len: self.max_move_identifier_len_as_option(), disallow_self_identifier: self.feature_flags.disallow_self_identifier,
4753 allow_receiving_object_id: self.allow_receiving_object_id(),
4754 reject_mutable_random_on_entry_functions: self
4755 .reject_mutable_random_on_entry_functions(),
4756 bytecode_version: self.move_binary_format_version(),
4757 max_variants_in_enum: self.max_move_enum_variants_as_option(),
4758 additional_borrow_checks,
4759 better_loader_errors: self.better_loader_errors(),
4760 private_generics_verifier_v2: self.private_generics_verifier_v2(),
4761 sanity_check_with_regex_reference_safety: sanity_check_with_regex_reference_safety
4762 .map(|limit| limit as u128),
4763 deprecate_global_storage_ops,
4764 disable_entry_point_signature_check: self.disable_entry_point_signature_check(),
4765 switch_to_regex_reference_safety: false,
4766 }
4767 }
4768
4769 pub fn binary_config(
4770 &self,
4771 override_deprecate_global_storage_ops_during_deserialization: Option<bool>,
4772 ) -> BinaryConfig {
4773 let deprecate_global_storage_ops =
4774 override_deprecate_global_storage_ops_during_deserialization
4775 .unwrap_or_else(|| self.deprecate_global_storage_ops());
4776 BinaryConfig::new(
4777 self.move_binary_format_version(),
4778 self.min_move_binary_format_version_as_option()
4779 .unwrap_or(VERSION_1),
4780 self.no_extraneous_module_bytes(),
4781 deprecate_global_storage_ops,
4782 TableConfig {
4783 module_handles: self.binary_module_handles_as_option().unwrap_or(u16::MAX),
4784 datatype_handles: self.binary_struct_handles_as_option().unwrap_or(u16::MAX),
4785 function_handles: self.binary_function_handles_as_option().unwrap_or(u16::MAX),
4786 function_instantiations: self
4787 .binary_function_instantiations_as_option()
4788 .unwrap_or(u16::MAX),
4789 signatures: self.binary_signatures_as_option().unwrap_or(u16::MAX),
4790 constant_pool: self.binary_constant_pool_as_option().unwrap_or(u16::MAX),
4791 identifiers: self.binary_identifiers_as_option().unwrap_or(u16::MAX),
4792 address_identifiers: self
4793 .binary_address_identifiers_as_option()
4794 .unwrap_or(u16::MAX),
4795 struct_defs: self.binary_struct_defs_as_option().unwrap_or(u16::MAX),
4796 struct_def_instantiations: self
4797 .binary_struct_def_instantiations_as_option()
4798 .unwrap_or(u16::MAX),
4799 function_defs: self.binary_function_defs_as_option().unwrap_or(u16::MAX),
4800 field_handles: self.binary_field_handles_as_option().unwrap_or(u16::MAX),
4801 field_instantiations: self
4802 .binary_field_instantiations_as_option()
4803 .unwrap_or(u16::MAX),
4804 friend_decls: self.binary_friend_decls_as_option().unwrap_or(u16::MAX),
4805 enum_defs: self.binary_enum_defs_as_option().unwrap_or(u16::MAX),
4806 enum_def_instantiations: self
4807 .binary_enum_def_instantiations_as_option()
4808 .unwrap_or(u16::MAX),
4809 variant_handles: self.binary_variant_handles_as_option().unwrap_or(u16::MAX),
4810 variant_instantiation_handles: self
4811 .binary_variant_instantiation_handles_as_option()
4812 .unwrap_or(u16::MAX),
4813 },
4814 )
4815 }
4816
4817 pub fn apply_overrides_for_testing(
4821 override_fn: impl Fn(ProtocolVersion, Self) -> Self + Send + 'static,
4822 ) -> OverrideGuard {
4823 CONFIG_OVERRIDE.with(|ovr| {
4824 let mut cur = ovr.borrow_mut();
4825 assert!(cur.is_none(), "config override already present");
4826 *cur = Some(Box::new(override_fn));
4827 OverrideGuard
4828 })
4829 }
4830}
4831
4832impl ProtocolConfig {
4836 pub fn set_advance_to_highest_supported_protocol_version_for_testing(&mut self, val: bool) {
4837 self.feature_flags
4838 .advance_to_highest_supported_protocol_version = val
4839 }
4840 pub fn set_commit_root_state_digest_supported_for_testing(&mut self, val: bool) {
4841 self.feature_flags.commit_root_state_digest = val
4842 }
4843 pub fn set_zklogin_auth_for_testing(&mut self, val: bool) {
4844 self.feature_flags.zklogin_auth = val
4845 }
4846 pub fn set_enable_jwk_consensus_updates_for_testing(&mut self, val: bool) {
4847 self.feature_flags.enable_jwk_consensus_updates = val
4848 }
4849 pub fn set_random_beacon_for_testing(&mut self, val: bool) {
4850 self.feature_flags.random_beacon = val
4851 }
4852
4853 pub fn set_upgraded_multisig_for_testing(&mut self, val: bool) {
4854 self.feature_flags.upgraded_multisig_supported = val
4855 }
4856 pub fn set_accept_zklogin_in_multisig_for_testing(&mut self, val: bool) {
4857 self.feature_flags.accept_zklogin_in_multisig = val
4858 }
4859
4860 pub fn set_shared_object_deletion_for_testing(&mut self, val: bool) {
4861 self.feature_flags.shared_object_deletion = val;
4862 }
4863
4864 pub fn set_narwhal_new_leader_election_schedule_for_testing(&mut self, val: bool) {
4865 self.feature_flags.narwhal_new_leader_election_schedule = val;
4866 }
4867
4868 pub fn set_receive_object_for_testing(&mut self, val: bool) {
4869 self.feature_flags.receive_objects = val
4870 }
4871 pub fn set_narwhal_certificate_v2_for_testing(&mut self, val: bool) {
4872 self.feature_flags.narwhal_certificate_v2 = val
4873 }
4874 pub fn set_verify_legacy_zklogin_address_for_testing(&mut self, val: bool) {
4875 self.feature_flags.verify_legacy_zklogin_address = val
4876 }
4877
4878 pub fn set_per_object_congestion_control_mode_for_testing(
4879 &mut self,
4880 val: PerObjectCongestionControlMode,
4881 ) {
4882 self.feature_flags.per_object_congestion_control_mode = val;
4883 }
4884
4885 pub fn set_consensus_choice_for_testing(&mut self, val: ConsensusChoice) {
4886 self.feature_flags.consensus_choice = val;
4887 }
4888
4889 pub fn set_consensus_network_for_testing(&mut self, val: ConsensusNetwork) {
4890 self.feature_flags.consensus_network = val;
4891 }
4892
4893 pub fn set_zklogin_max_epoch_upper_bound_delta_for_testing(&mut self, val: Option<u64>) {
4894 self.feature_flags.zklogin_max_epoch_upper_bound_delta = val
4895 }
4896
4897 pub fn set_disable_bridge_for_testing(&mut self) {
4898 self.feature_flags.bridge = false
4899 }
4900
4901 pub fn set_mysticeti_num_leaders_per_round_for_testing(&mut self, val: Option<usize>) {
4902 self.feature_flags.mysticeti_num_leaders_per_round = val;
4903 }
4904
4905 pub fn set_enable_soft_bundle_for_testing(&mut self, val: bool) {
4906 self.feature_flags.soft_bundle = val;
4907 }
4908
4909 pub fn set_passkey_auth_for_testing(&mut self, val: bool) {
4910 self.feature_flags.passkey_auth = val
4911 }
4912
4913 pub fn set_enable_party_transfer_for_testing(&mut self, val: bool) {
4914 self.feature_flags.enable_party_transfer = val
4915 }
4916
4917 pub fn set_consensus_distributed_vote_scoring_strategy_for_testing(&mut self, val: bool) {
4918 self.feature_flags
4919 .consensus_distributed_vote_scoring_strategy = val;
4920 }
4921
4922 pub fn set_consensus_round_prober_for_testing(&mut self, val: bool) {
4923 self.feature_flags.consensus_round_prober = val;
4924 }
4925
4926 pub fn set_disallow_new_modules_in_deps_only_packages_for_testing(&mut self, val: bool) {
4927 self.feature_flags
4928 .disallow_new_modules_in_deps_only_packages = val;
4929 }
4930
4931 pub fn set_correct_gas_payment_limit_check_for_testing(&mut self, val: bool) {
4932 self.feature_flags.correct_gas_payment_limit_check = val;
4933 }
4934
4935 pub fn set_address_aliases_for_testing(&mut self, val: bool) {
4936 self.feature_flags.address_aliases = val;
4937 }
4938
4939 pub fn set_consensus_round_prober_probe_accepted_rounds(&mut self, val: bool) {
4940 self.feature_flags
4941 .consensus_round_prober_probe_accepted_rounds = val;
4942 }
4943
4944 pub fn set_mysticeti_fastpath_for_testing(&mut self, val: bool) {
4945 self.feature_flags.mysticeti_fastpath = val;
4946 }
4947
4948 pub fn set_accept_passkey_in_multisig_for_testing(&mut self, val: bool) {
4949 self.feature_flags.accept_passkey_in_multisig = val;
4950 }
4951
4952 pub fn set_consensus_batched_block_sync_for_testing(&mut self, val: bool) {
4953 self.feature_flags.consensus_batched_block_sync = val;
4954 }
4955
4956 pub fn set_record_time_estimate_processed_for_testing(&mut self, val: bool) {
4957 self.feature_flags.record_time_estimate_processed = val;
4958 }
4959
4960 pub fn set_prepend_prologue_tx_in_consensus_commit_in_checkpoints_for_testing(
4961 &mut self,
4962 val: bool,
4963 ) {
4964 self.feature_flags
4965 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = val;
4966 }
4967
4968 pub fn enable_accumulators_for_testing(&mut self) {
4969 self.feature_flags.enable_accumulators = true;
4970 }
4971
4972 pub fn disable_accumulators_for_testing(&mut self) {
4973 self.feature_flags.enable_accumulators = false;
4974 self.feature_flags.enable_address_balance_gas_payments = false;
4975 }
4976
4977 pub fn enable_coin_reservation_for_testing(&mut self) {
4978 self.feature_flags.enable_coin_reservation_obj_refs = true;
4979 }
4980
4981 pub fn create_root_accumulator_object_for_testing(&mut self) {
4982 self.feature_flags.create_root_accumulator_object = true;
4983 }
4984
4985 pub fn disable_create_root_accumulator_object_for_testing(&mut self) {
4986 self.feature_flags.create_root_accumulator_object = false;
4987 }
4988
4989 pub fn enable_address_balance_gas_payments_for_testing(&mut self) {
4990 self.feature_flags.enable_accumulators = true;
4991 self.feature_flags.allow_private_accumulator_entrypoints = true;
4992 self.feature_flags.enable_address_balance_gas_payments = true;
4993 self.feature_flags.address_balance_gas_check_rgp_at_signing = true;
4994 self.feature_flags.address_balance_gas_reject_gas_coin_arg = true;
4995 }
4996
4997 pub fn disable_address_balance_gas_payments_for_testing(&mut self) {
4998 self.feature_flags.enable_address_balance_gas_payments = false;
4999 }
5000
5001 pub fn enable_multi_epoch_transaction_expiration_for_testing(&mut self) {
5002 self.feature_flags.enable_multi_epoch_transaction_expiration = true;
5003 }
5004
5005 pub fn enable_authenticated_event_streams_for_testing(&mut self) {
5006 self.enable_accumulators_for_testing();
5007 self.feature_flags.enable_authenticated_event_streams = true;
5008 self.feature_flags
5009 .include_checkpoint_artifacts_digest_in_summary = true;
5010 self.feature_flags.split_checkpoints_in_consensus_handler = true;
5011 }
5012
5013 pub fn disable_authenticated_event_streams_for_testing(&mut self) {
5014 self.feature_flags.enable_authenticated_event_streams = false;
5015 }
5016
5017 pub fn disable_randomize_checkpoint_tx_limit_for_testing(&mut self) {
5018 self.feature_flags.randomize_checkpoint_tx_limit_in_tests = false;
5019 }
5020
5021 pub fn enable_non_exclusive_writes_for_testing(&mut self) {
5022 self.feature_flags.enable_non_exclusive_writes = true;
5023 }
5024
5025 pub fn set_relax_valid_during_for_owned_inputs_for_testing(&mut self, val: bool) {
5026 self.feature_flags.relax_valid_during_for_owned_inputs = val;
5027 }
5028
5029 pub fn set_ignore_execution_time_observations_after_certs_closed_for_testing(
5030 &mut self,
5031 val: bool,
5032 ) {
5033 self.feature_flags
5034 .ignore_execution_time_observations_after_certs_closed = val;
5035 }
5036
5037 pub fn set_consensus_checkpoint_signature_key_includes_digest_for_testing(
5038 &mut self,
5039 val: bool,
5040 ) {
5041 self.feature_flags
5042 .consensus_checkpoint_signature_key_includes_digest = val;
5043 }
5044
5045 pub fn set_cancel_for_failed_dkg_early_for_testing(&mut self, val: bool) {
5046 self.feature_flags.cancel_for_failed_dkg_early = val;
5047 }
5048
5049 pub fn set_use_mfp_txns_in_load_initial_object_debts_for_testing(&mut self, val: bool) {
5050 self.feature_flags.use_mfp_txns_in_load_initial_object_debts = val;
5051 }
5052
5053 pub fn set_authority_capabilities_v2_for_testing(&mut self, val: bool) {
5054 self.feature_flags.authority_capabilities_v2 = val;
5055 }
5056
5057 pub fn allow_references_in_ptbs_for_testing(&mut self) {
5058 self.feature_flags.allow_references_in_ptbs = true;
5059 }
5060
5061 pub fn set_consensus_skip_gced_accept_votes_for_testing(&mut self, val: bool) {
5062 self.feature_flags.consensus_skip_gced_accept_votes = val;
5063 }
5064
5065 pub fn set_enable_object_funds_withdraw_for_testing(&mut self, val: bool) {
5066 self.feature_flags.enable_object_funds_withdraw = val;
5067 }
5068
5069 pub fn set_split_checkpoints_in_consensus_handler_for_testing(&mut self, val: bool) {
5070 self.feature_flags.split_checkpoints_in_consensus_handler = val;
5071 }
5072}
5073
5074type OverrideFn = dyn Fn(ProtocolVersion, ProtocolConfig) -> ProtocolConfig + Send;
5075
5076thread_local! {
5077 static CONFIG_OVERRIDE: RefCell<Option<Box<OverrideFn>>> = RefCell::new(None);
5078}
5079
5080#[must_use]
5081pub struct OverrideGuard;
5082
5083impl Drop for OverrideGuard {
5084 fn drop(&mut self) {
5085 info!("restoring override fn");
5086 CONFIG_OVERRIDE.with(|ovr| {
5087 *ovr.borrow_mut() = None;
5088 });
5089 }
5090}
5091
5092#[derive(PartialEq, Eq)]
5095pub enum LimitThresholdCrossed {
5096 None,
5097 Soft(u128, u128),
5098 Hard(u128, u128),
5099}
5100
5101pub fn check_limit_in_range<T: Into<V>, U: Into<V>, V: PartialOrd + Into<u128>>(
5104 x: T,
5105 soft_limit: U,
5106 hard_limit: V,
5107) -> LimitThresholdCrossed {
5108 let x: V = x.into();
5109 let soft_limit: V = soft_limit.into();
5110
5111 debug_assert!(soft_limit <= hard_limit);
5112
5113 if x >= hard_limit {
5116 LimitThresholdCrossed::Hard(x.into(), hard_limit.into())
5117 } else if x < soft_limit {
5118 LimitThresholdCrossed::None
5119 } else {
5120 LimitThresholdCrossed::Soft(x.into(), soft_limit.into())
5121 }
5122}
5123
5124#[macro_export]
5125macro_rules! check_limit {
5126 ($x:expr, $hard:expr) => {
5127 check_limit!($x, $hard, $hard)
5128 };
5129 ($x:expr, $soft:expr, $hard:expr) => {
5130 check_limit_in_range($x as u64, $soft, $hard)
5131 };
5132}
5133
5134#[macro_export]
5138macro_rules! check_limit_by_meter {
5139 ($is_metered:expr, $x:expr, $metered_limit:expr, $unmetered_hard_limit:expr, $metric:expr) => {{
5140 let (h, metered_str) = if $is_metered {
5142 ($metered_limit, "metered")
5143 } else {
5144 ($unmetered_hard_limit, "unmetered")
5146 };
5147 use sui_protocol_config::check_limit_in_range;
5148 let result = check_limit_in_range($x as u64, $metered_limit, h);
5149 match result {
5150 LimitThresholdCrossed::None => {}
5151 LimitThresholdCrossed::Soft(_, _) => {
5152 $metric.with_label_values(&[metered_str, "soft"]).inc();
5153 }
5154 LimitThresholdCrossed::Hard(_, _) => {
5155 $metric.with_label_values(&[metered_str, "hard"]).inc();
5156 }
5157 };
5158 result
5159 }};
5160}
5161#[cfg(all(test, not(msim)))]
5162mod test {
5163 use insta::assert_yaml_snapshot;
5164
5165 use super::*;
5166
5167 #[test]
5168 fn snapshot_tests() {
5169 println!("\n============================================================================");
5170 println!("! !");
5171 println!("! IMPORTANT: never update snapshots from this test. only add new versions! !");
5172 println!("! !");
5173 println!("============================================================================\n");
5174 for chain_id in &[Chain::Unknown, Chain::Mainnet, Chain::Testnet] {
5175 let chain_str = match chain_id {
5179 Chain::Unknown => "".to_string(),
5180 _ => format!("{:?}_", chain_id),
5181 };
5182 for i in MIN_PROTOCOL_VERSION..=MAX_PROTOCOL_VERSION {
5183 let cur = ProtocolVersion::new(i);
5184 assert_yaml_snapshot!(
5185 format!("{}version_{}", chain_str, cur.as_u64()),
5186 ProtocolConfig::get_for_version(cur, *chain_id)
5187 );
5188 }
5189 }
5190 }
5191
5192 #[test]
5193 fn test_getters() {
5194 let prot: ProtocolConfig =
5195 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5196 assert_eq!(
5197 prot.max_arguments(),
5198 prot.max_arguments_as_option().unwrap()
5199 );
5200 }
5201
5202 #[test]
5203 fn test_setters() {
5204 let mut prot: ProtocolConfig =
5205 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5206 prot.set_max_arguments_for_testing(123);
5207 assert_eq!(prot.max_arguments(), 123);
5208
5209 prot.set_max_arguments_from_str_for_testing("321".to_string());
5210 assert_eq!(prot.max_arguments(), 321);
5211
5212 prot.disable_max_arguments_for_testing();
5213 assert_eq!(prot.max_arguments_as_option(), None);
5214
5215 prot.set_attr_for_testing("max_arguments".to_string(), "456".to_string());
5216 assert_eq!(prot.max_arguments(), 456);
5217 }
5218
5219 #[test]
5220 #[should_panic(expected = "unsupported version")]
5221 fn max_version_test() {
5222 let _ = ProtocolConfig::get_for_version_impl(
5225 ProtocolVersion::new(MAX_PROTOCOL_VERSION + 1),
5226 Chain::Unknown,
5227 );
5228 }
5229
5230 #[test]
5231 fn lookup_by_string_test() {
5232 let prot: ProtocolConfig =
5233 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5234 assert!(prot.lookup_attr("some random string".to_string()).is_none());
5236
5237 assert!(
5238 prot.lookup_attr("max_arguments".to_string())
5239 == Some(ProtocolConfigValue::u32(prot.max_arguments())),
5240 );
5241
5242 assert!(
5244 prot.lookup_attr("max_move_identifier_len".to_string())
5245 .is_none()
5246 );
5247
5248 let prot: ProtocolConfig =
5250 ProtocolConfig::get_for_version(ProtocolVersion::new(9), Chain::Unknown);
5251 assert!(
5252 prot.lookup_attr("max_move_identifier_len".to_string())
5253 == Some(ProtocolConfigValue::u64(prot.max_move_identifier_len()))
5254 );
5255
5256 let prot: ProtocolConfig =
5257 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5258 assert!(
5260 prot.attr_map()
5261 .get("max_move_identifier_len")
5262 .unwrap()
5263 .is_none()
5264 );
5265 assert!(
5267 prot.attr_map().get("max_arguments").unwrap()
5268 == &Some(ProtocolConfigValue::u32(prot.max_arguments()))
5269 );
5270
5271 let prot: ProtocolConfig =
5273 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5274 assert!(
5276 prot.feature_flags
5277 .lookup_attr("some random string".to_owned())
5278 .is_none()
5279 );
5280 assert!(
5281 !prot
5282 .feature_flags
5283 .attr_map()
5284 .contains_key("some random string")
5285 );
5286
5287 assert!(
5289 prot.feature_flags
5290 .lookup_attr("package_upgrades".to_owned())
5291 == Some(false)
5292 );
5293 assert!(
5294 prot.feature_flags
5295 .attr_map()
5296 .get("package_upgrades")
5297 .unwrap()
5298 == &false
5299 );
5300 let prot: ProtocolConfig =
5301 ProtocolConfig::get_for_version(ProtocolVersion::new(4), Chain::Unknown);
5302 assert!(
5304 prot.feature_flags
5305 .lookup_attr("package_upgrades".to_owned())
5306 == Some(true)
5307 );
5308 assert!(
5309 prot.feature_flags
5310 .attr_map()
5311 .get("package_upgrades")
5312 .unwrap()
5313 == &true
5314 );
5315 }
5316
5317 #[test]
5318 fn limit_range_fn_test() {
5319 let low = 100u32;
5320 let high = 10000u64;
5321
5322 assert!(check_limit!(1u8, low, high) == LimitThresholdCrossed::None);
5323 assert!(matches!(
5324 check_limit!(255u16, low, high),
5325 LimitThresholdCrossed::Soft(255u128, 100)
5326 ));
5327 assert!(matches!(
5333 check_limit!(2550000u64, low, high),
5334 LimitThresholdCrossed::Hard(2550000, 10000)
5335 ));
5336
5337 assert!(matches!(
5338 check_limit!(2550000u64, high, high),
5339 LimitThresholdCrossed::Hard(2550000, 10000)
5340 ));
5341
5342 assert!(matches!(
5343 check_limit!(1u8, high),
5344 LimitThresholdCrossed::None
5345 ));
5346
5347 assert!(check_limit!(255u16, high) == LimitThresholdCrossed::None);
5348
5349 assert!(matches!(
5350 check_limit!(2550000u64, high),
5351 LimitThresholdCrossed::Hard(2550000, 10000)
5352 ));
5353 }
5354}