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 serde::{Deserialize, Serialize};
18use serde_with::skip_serializing_none;
19use sui_protocol_config_macros::{
20 ProtocolConfigAccessors, ProtocolConfigFeatureFlagsGetters, ProtocolConfigOverride,
21};
22use tracing::{info, warn};
23
24const MIN_PROTOCOL_VERSION: u64 = 1;
26const MAX_PROTOCOL_VERSION: u64 = 104;
27
28#[derive(Copy, Clone, Debug, Hash, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)]
283pub struct ProtocolVersion(u64);
284
285impl ProtocolVersion {
286 pub const MIN: Self = Self(MIN_PROTOCOL_VERSION);
291
292 pub const MAX: Self = Self(MAX_PROTOCOL_VERSION);
293
294 #[cfg(not(msim))]
295 pub const MAX_ALLOWED: Self = Self::MAX;
296
297 #[cfg(msim)]
299 pub const MAX_ALLOWED: Self = Self(MAX_PROTOCOL_VERSION + 1);
300
301 pub fn new(v: u64) -> Self {
302 Self(v)
303 }
304
305 pub const fn as_u64(&self) -> u64 {
306 self.0
307 }
308
309 pub fn max() -> Self {
312 Self::MAX
313 }
314
315 pub fn prev(self) -> Self {
316 Self(self.0.checked_sub(1).unwrap())
317 }
318}
319
320impl From<u64> for ProtocolVersion {
321 fn from(v: u64) -> Self {
322 Self::new(v)
323 }
324}
325
326impl std::ops::Sub<u64> for ProtocolVersion {
327 type Output = Self;
328 fn sub(self, rhs: u64) -> Self::Output {
329 Self::new(self.0 - rhs)
330 }
331}
332
333impl std::ops::Add<u64> for ProtocolVersion {
334 type Output = Self;
335 fn add(self, rhs: u64) -> Self::Output {
336 Self::new(self.0 + rhs)
337 }
338}
339
340#[derive(Clone, Serialize, Deserialize, Debug, PartialEq, Copy, PartialOrd, Ord, Eq, ValueEnum)]
341pub enum Chain {
342 Mainnet,
343 Testnet,
344 Unknown,
345}
346
347impl Default for Chain {
348 fn default() -> Self {
349 Self::Unknown
350 }
351}
352
353impl Chain {
354 pub fn as_str(self) -> &'static str {
355 match self {
356 Chain::Mainnet => "mainnet",
357 Chain::Testnet => "testnet",
358 Chain::Unknown => "unknown",
359 }
360 }
361}
362
363pub struct Error(pub String);
364
365#[derive(Default, Clone, Serialize, Deserialize, Debug, ProtocolConfigFeatureFlagsGetters)]
368struct FeatureFlags {
369 #[serde(skip_serializing_if = "is_false")]
372 package_upgrades: bool,
373 #[serde(skip_serializing_if = "is_false")]
376 commit_root_state_digest: bool,
377 #[serde(skip_serializing_if = "is_false")]
379 advance_epoch_start_time_in_safe_mode: bool,
380 #[serde(skip_serializing_if = "is_false")]
383 loaded_child_objects_fixed: bool,
384 #[serde(skip_serializing_if = "is_false")]
387 missing_type_is_compatibility_error: bool,
388 #[serde(skip_serializing_if = "is_false")]
391 scoring_decision_with_validity_cutoff: bool,
392
393 #[serde(skip_serializing_if = "is_false")]
396 consensus_order_end_of_epoch_last: bool,
397
398 #[serde(skip_serializing_if = "is_false")]
400 disallow_adding_abilities_on_upgrade: bool,
401 #[serde(skip_serializing_if = "is_false")]
403 disable_invariant_violation_check_in_swap_loc: bool,
404 #[serde(skip_serializing_if = "is_false")]
407 advance_to_highest_supported_protocol_version: bool,
408 #[serde(skip_serializing_if = "is_false")]
410 ban_entry_init: bool,
411 #[serde(skip_serializing_if = "is_false")]
413 package_digest_hash_module: bool,
414 #[serde(skip_serializing_if = "is_false")]
416 disallow_change_struct_type_params_on_upgrade: bool,
417 #[serde(skip_serializing_if = "is_false")]
419 no_extraneous_module_bytes: bool,
420 #[serde(skip_serializing_if = "is_false")]
422 narwhal_versioned_metadata: bool,
423
424 #[serde(skip_serializing_if = "is_false")]
426 zklogin_auth: bool,
427 #[serde(skip_serializing_if = "ConsensusTransactionOrdering::is_none")]
429 consensus_transaction_ordering: ConsensusTransactionOrdering,
430
431 #[serde(skip_serializing_if = "is_false")]
439 simplified_unwrap_then_delete: bool,
440 #[serde(skip_serializing_if = "is_false")]
442 upgraded_multisig_supported: bool,
443 #[serde(skip_serializing_if = "is_false")]
445 txn_base_cost_as_multiplier: bool,
446
447 #[serde(skip_serializing_if = "is_false")]
449 shared_object_deletion: bool,
450
451 #[serde(skip_serializing_if = "is_false")]
453 narwhal_new_leader_election_schedule: bool,
454
455 #[serde(skip_serializing_if = "is_empty")]
457 zklogin_supported_providers: BTreeSet<String>,
458
459 #[serde(skip_serializing_if = "is_false")]
461 loaded_child_object_format: bool,
462
463 #[serde(skip_serializing_if = "is_false")]
464 enable_jwk_consensus_updates: bool,
465
466 #[serde(skip_serializing_if = "is_false")]
467 end_of_epoch_transaction_supported: bool,
468
469 #[serde(skip_serializing_if = "is_false")]
472 simple_conservation_checks: bool,
473
474 #[serde(skip_serializing_if = "is_false")]
476 loaded_child_object_format_type: bool,
477
478 #[serde(skip_serializing_if = "is_false")]
480 receive_objects: bool,
481
482 #[serde(skip_serializing_if = "is_false")]
484 consensus_checkpoint_signature_key_includes_digest: bool,
485
486 #[serde(skip_serializing_if = "is_false")]
488 random_beacon: bool,
489
490 #[serde(skip_serializing_if = "is_false")]
492 bridge: bool,
493
494 #[serde(skip_serializing_if = "is_false")]
495 enable_effects_v2: bool,
496
497 #[serde(skip_serializing_if = "is_false")]
499 narwhal_certificate_v2: bool,
500
501 #[serde(skip_serializing_if = "is_false")]
503 verify_legacy_zklogin_address: bool,
504
505 #[serde(skip_serializing_if = "is_false")]
507 throughput_aware_consensus_submission: bool,
508
509 #[serde(skip_serializing_if = "is_false")]
511 recompute_has_public_transfer_in_execution: bool,
512
513 #[serde(skip_serializing_if = "is_false")]
515 accept_zklogin_in_multisig: bool,
516
517 #[serde(skip_serializing_if = "is_false")]
519 accept_passkey_in_multisig: bool,
520
521 #[serde(skip_serializing_if = "is_false")]
524 include_consensus_digest_in_prologue: bool,
525
526 #[serde(skip_serializing_if = "is_false")]
528 hardened_otw_check: bool,
529
530 #[serde(skip_serializing_if = "is_false")]
532 allow_receiving_object_id: bool,
533
534 #[serde(skip_serializing_if = "is_false")]
536 enable_poseidon: bool,
537
538 #[serde(skip_serializing_if = "is_false")]
540 enable_coin_deny_list: bool,
541
542 #[serde(skip_serializing_if = "is_false")]
544 enable_group_ops_native_functions: bool,
545
546 #[serde(skip_serializing_if = "is_false")]
548 enable_group_ops_native_function_msm: bool,
549
550 #[serde(skip_serializing_if = "is_false")]
552 enable_nitro_attestation: bool,
553
554 #[serde(skip_serializing_if = "is_false")]
556 enable_nitro_attestation_upgraded_parsing: bool,
557
558 #[serde(skip_serializing_if = "is_false")]
560 enable_nitro_attestation_all_nonzero_pcrs_parsing: bool,
561
562 #[serde(skip_serializing_if = "is_false")]
564 reject_mutable_random_on_entry_functions: bool,
565
566 #[serde(skip_serializing_if = "PerObjectCongestionControlMode::is_none")]
568 per_object_congestion_control_mode: PerObjectCongestionControlMode,
569
570 #[serde(skip_serializing_if = "ConsensusChoice::is_narwhal")]
572 consensus_choice: ConsensusChoice,
573
574 #[serde(skip_serializing_if = "ConsensusNetwork::is_anemo")]
576 consensus_network: ConsensusNetwork,
577
578 #[serde(skip_serializing_if = "is_false")]
580 correct_gas_payment_limit_check: bool,
581
582 #[serde(skip_serializing_if = "Option::is_none")]
584 zklogin_max_epoch_upper_bound_delta: Option<u64>,
585
586 #[serde(skip_serializing_if = "is_false")]
588 mysticeti_leader_scoring_and_schedule: bool,
589
590 #[serde(skip_serializing_if = "is_false")]
592 reshare_at_same_initial_version: bool,
593
594 #[serde(skip_serializing_if = "is_false")]
596 resolve_abort_locations_to_package_id: bool,
597
598 #[serde(skip_serializing_if = "is_false")]
602 mysticeti_use_committed_subdag_digest: bool,
603
604 #[serde(skip_serializing_if = "is_false")]
606 enable_vdf: bool,
607
608 #[serde(skip_serializing_if = "is_false")]
613 record_consensus_determined_version_assignments_in_prologue: bool,
614 #[serde(skip_serializing_if = "is_false")]
615 record_consensus_determined_version_assignments_in_prologue_v2: bool,
616
617 #[serde(skip_serializing_if = "is_false")]
619 fresh_vm_on_framework_upgrade: bool,
620
621 #[serde(skip_serializing_if = "is_false")]
629 prepend_prologue_tx_in_consensus_commit_in_checkpoints: bool,
630
631 #[serde(skip_serializing_if = "Option::is_none")]
633 mysticeti_num_leaders_per_round: Option<usize>,
634
635 #[serde(skip_serializing_if = "is_false")]
637 soft_bundle: bool,
638
639 #[serde(skip_serializing_if = "is_false")]
641 enable_coin_deny_list_v2: bool,
642
643 #[serde(skip_serializing_if = "is_false")]
645 passkey_auth: bool,
646
647 #[serde(skip_serializing_if = "is_false")]
649 authority_capabilities_v2: bool,
650
651 #[serde(skip_serializing_if = "is_false")]
653 rethrow_serialization_type_layout_errors: bool,
654
655 #[serde(skip_serializing_if = "is_false")]
657 consensus_distributed_vote_scoring_strategy: bool,
658
659 #[serde(skip_serializing_if = "is_false")]
661 consensus_round_prober: bool,
662
663 #[serde(skip_serializing_if = "is_false")]
665 validate_identifier_inputs: bool,
666
667 #[serde(skip_serializing_if = "is_false")]
669 disallow_self_identifier: bool,
670
671 #[serde(skip_serializing_if = "is_false")]
673 mysticeti_fastpath: bool,
674
675 #[serde(skip_serializing_if = "is_false")]
677 relocate_event_module: bool,
678
679 #[serde(skip_serializing_if = "is_false")]
681 uncompressed_g1_group_elements: bool,
682
683 #[serde(skip_serializing_if = "is_false")]
684 disallow_new_modules_in_deps_only_packages: bool,
685
686 #[serde(skip_serializing_if = "is_false")]
688 consensus_smart_ancestor_selection: bool,
689
690 #[serde(skip_serializing_if = "is_false")]
692 consensus_round_prober_probe_accepted_rounds: bool,
693
694 #[serde(skip_serializing_if = "is_false")]
696 native_charging_v2: bool,
697
698 #[serde(skip_serializing_if = "is_false")]
701 consensus_linearize_subdag_v2: bool,
702
703 #[serde(skip_serializing_if = "is_false")]
705 convert_type_argument_error: bool,
706
707 #[serde(skip_serializing_if = "is_false")]
709 variant_nodes: bool,
710
711 #[serde(skip_serializing_if = "is_false")]
713 consensus_zstd_compression: bool,
714
715 #[serde(skip_serializing_if = "is_false")]
717 minimize_child_object_mutations: bool,
718
719 #[serde(skip_serializing_if = "is_false")]
721 record_additional_state_digest_in_prologue: bool,
722
723 #[serde(skip_serializing_if = "is_false")]
725 move_native_context: bool,
726
727 #[serde(skip_serializing_if = "is_false")]
730 consensus_median_based_commit_timestamp: bool,
731
732 #[serde(skip_serializing_if = "is_false")]
735 normalize_ptb_arguments: bool,
736
737 #[serde(skip_serializing_if = "is_false")]
739 consensus_batched_block_sync: bool,
740
741 #[serde(skip_serializing_if = "is_false")]
743 enforce_checkpoint_timestamp_monotonicity: bool,
744
745 #[serde(skip_serializing_if = "is_false")]
747 max_ptb_value_size_v2: bool,
748
749 #[serde(skip_serializing_if = "is_false")]
751 resolve_type_input_ids_to_defining_id: bool,
752
753 #[serde(skip_serializing_if = "is_false")]
755 enable_party_transfer: bool,
756
757 #[serde(skip_serializing_if = "is_false")]
759 allow_unbounded_system_objects: bool,
760
761 #[serde(skip_serializing_if = "is_false")]
763 type_tags_in_object_runtime: bool,
764
765 #[serde(skip_serializing_if = "is_false")]
767 enable_accumulators: bool,
768
769 #[serde(skip_serializing_if = "is_false")]
772 create_root_accumulator_object: bool,
773
774 #[serde(skip_serializing_if = "is_false")]
776 enable_authenticated_event_streams: bool,
777
778 #[serde(skip_serializing_if = "is_false")]
780 enable_address_balance_gas_payments: bool,
781
782 #[serde(skip_serializing_if = "is_false")]
784 enable_ptb_execution_v2: bool,
785
786 #[serde(skip_serializing_if = "is_false")]
788 better_adapter_type_resolution_errors: bool,
789
790 #[serde(skip_serializing_if = "is_false")]
792 record_time_estimate_processed: bool,
793
794 #[serde(skip_serializing_if = "is_false")]
796 dependency_linkage_error: bool,
797
798 #[serde(skip_serializing_if = "is_false")]
800 additional_multisig_checks: bool,
801
802 #[serde(skip_serializing_if = "is_false")]
804 ignore_execution_time_observations_after_certs_closed: bool,
805
806 #[serde(skip_serializing_if = "is_false")]
810 debug_fatal_on_move_invariant_violation: bool,
811
812 #[serde(skip_serializing_if = "is_false")]
815 allow_private_accumulator_entrypoints: bool,
816
817 #[serde(skip_serializing_if = "is_false")]
819 additional_consensus_digest_indirect_state: bool,
820
821 #[serde(skip_serializing_if = "is_false")]
823 check_for_init_during_upgrade: bool,
824
825 #[serde(skip_serializing_if = "is_false")]
827 per_command_shared_object_transfer_rules: bool,
828
829 #[serde(skip_serializing_if = "is_false")]
831 include_checkpoint_artifacts_digest_in_summary: bool,
832
833 #[serde(skip_serializing_if = "is_false")]
835 use_mfp_txns_in_load_initial_object_debts: bool,
836
837 #[serde(skip_serializing_if = "is_false")]
839 cancel_for_failed_dkg_early: bool,
840
841 #[serde(skip_serializing_if = "is_false")]
843 enable_coin_registry: bool,
844
845 #[serde(skip_serializing_if = "is_false")]
847 abstract_size_in_object_runtime: bool,
848
849 #[serde(skip_serializing_if = "is_false")]
851 object_runtime_charge_cache_load_gas: bool,
852
853 #[serde(skip_serializing_if = "is_false")]
855 additional_borrow_checks: bool,
856
857 #[serde(skip_serializing_if = "is_false")]
859 use_new_commit_handler: bool,
860
861 #[serde(skip_serializing_if = "is_false")]
863 better_loader_errors: bool,
864
865 #[serde(skip_serializing_if = "is_false")]
867 generate_df_type_layouts: bool,
868
869 #[serde(skip_serializing_if = "is_false")]
871 allow_references_in_ptbs: bool,
872
873 #[serde(skip_serializing_if = "is_false")]
875 enable_display_registry: bool,
876
877 #[serde(skip_serializing_if = "is_false")]
879 private_generics_verifier_v2: bool,
880
881 #[serde(skip_serializing_if = "is_false")]
883 deprecate_global_storage_ops_during_deserialization: bool,
884
885 #[serde(skip_serializing_if = "is_false")]
888 enable_non_exclusive_writes: bool,
889
890 #[serde(skip_serializing_if = "is_false")]
892 deprecate_global_storage_ops: bool,
893
894 #[serde(skip_serializing_if = "is_false")]
896 consensus_skip_gced_accept_votes: bool,
897}
898
899fn is_false(b: &bool) -> bool {
900 !b
901}
902
903fn is_empty(b: &BTreeSet<String>) -> bool {
904 b.is_empty()
905}
906
907fn is_zero(val: &u64) -> bool {
908 *val == 0
909}
910
911#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
913pub enum ConsensusTransactionOrdering {
914 #[default]
916 None,
917 ByGasPrice,
919}
920
921impl ConsensusTransactionOrdering {
922 pub fn is_none(&self) -> bool {
923 matches!(self, ConsensusTransactionOrdering::None)
924 }
925}
926
927#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
928pub struct ExecutionTimeEstimateParams {
929 pub target_utilization: u64,
931 pub allowed_txn_cost_overage_burst_limit_us: u64,
935
936 pub randomness_scalar: u64,
939
940 pub max_estimate_us: u64,
942
943 pub stored_observations_num_included_checkpoints: u64,
946
947 pub stored_observations_limit: u64,
949
950 #[serde(skip_serializing_if = "is_zero")]
953 pub stake_weighted_median_threshold: u64,
954
955 #[serde(skip_serializing_if = "is_false")]
959 pub default_none_duration_for_new_keys: bool,
960
961 #[serde(skip_serializing_if = "Option::is_none")]
963 pub observations_chunk_size: Option<u64>,
964}
965
966#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
968pub enum PerObjectCongestionControlMode {
969 #[default]
970 None, TotalGasBudget, TotalTxCount, TotalGasBudgetWithCap, ExecutionTimeEstimate(ExecutionTimeEstimateParams), }
976
977impl PerObjectCongestionControlMode {
978 pub fn is_none(&self) -> bool {
979 matches!(self, PerObjectCongestionControlMode::None)
980 }
981}
982
983#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
985pub enum ConsensusChoice {
986 #[default]
987 Narwhal,
988 SwapEachEpoch,
989 Mysticeti,
990}
991
992impl ConsensusChoice {
993 pub fn is_narwhal(&self) -> bool {
994 matches!(self, ConsensusChoice::Narwhal)
995 }
996}
997
998#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1000pub enum ConsensusNetwork {
1001 #[default]
1002 Anemo,
1003 Tonic,
1004}
1005
1006impl ConsensusNetwork {
1007 pub fn is_anemo(&self) -> bool {
1008 matches!(self, ConsensusNetwork::Anemo)
1009 }
1010}
1011
1012#[skip_serializing_none]
1044#[derive(Clone, Serialize, Debug, ProtocolConfigAccessors, ProtocolConfigOverride)]
1045pub struct ProtocolConfig {
1046 pub version: ProtocolVersion,
1047
1048 feature_flags: FeatureFlags,
1049
1050 max_tx_size_bytes: Option<u64>,
1053
1054 max_input_objects: Option<u64>,
1056
1057 max_size_written_objects: Option<u64>,
1061 max_size_written_objects_system_tx: Option<u64>,
1064
1065 max_serialized_tx_effects_size_bytes: Option<u64>,
1067
1068 max_serialized_tx_effects_size_bytes_system_tx: Option<u64>,
1070
1071 max_gas_payment_objects: Option<u32>,
1073
1074 max_modules_in_publish: Option<u32>,
1076
1077 max_package_dependencies: Option<u32>,
1079
1080 max_arguments: Option<u32>,
1083
1084 max_type_arguments: Option<u32>,
1086
1087 max_type_argument_depth: Option<u32>,
1089
1090 max_pure_argument_size: Option<u32>,
1092
1093 max_programmable_tx_commands: Option<u32>,
1095
1096 move_binary_format_version: Option<u32>,
1099 min_move_binary_format_version: Option<u32>,
1100
1101 binary_module_handles: Option<u16>,
1103 binary_struct_handles: Option<u16>,
1104 binary_function_handles: Option<u16>,
1105 binary_function_instantiations: Option<u16>,
1106 binary_signatures: Option<u16>,
1107 binary_constant_pool: Option<u16>,
1108 binary_identifiers: Option<u16>,
1109 binary_address_identifiers: Option<u16>,
1110 binary_struct_defs: Option<u16>,
1111 binary_struct_def_instantiations: Option<u16>,
1112 binary_function_defs: Option<u16>,
1113 binary_field_handles: Option<u16>,
1114 binary_field_instantiations: Option<u16>,
1115 binary_friend_decls: Option<u16>,
1116 binary_enum_defs: Option<u16>,
1117 binary_enum_def_instantiations: Option<u16>,
1118 binary_variant_handles: Option<u16>,
1119 binary_variant_instantiation_handles: Option<u16>,
1120
1121 max_move_object_size: Option<u64>,
1123
1124 max_move_package_size: Option<u64>,
1127
1128 max_publish_or_upgrade_per_ptb: Option<u64>,
1130
1131 max_tx_gas: Option<u64>,
1133
1134 max_gas_price: Option<u64>,
1136
1137 max_gas_price_rgp_factor_for_aborted_transactions: Option<u64>,
1140
1141 max_gas_computation_bucket: Option<u64>,
1143
1144 gas_rounding_step: Option<u64>,
1146
1147 max_loop_depth: Option<u64>,
1149
1150 max_generic_instantiation_length: Option<u64>,
1152
1153 max_function_parameters: Option<u64>,
1155
1156 max_basic_blocks: Option<u64>,
1158
1159 max_value_stack_size: Option<u64>,
1161
1162 max_type_nodes: Option<u64>,
1164
1165 max_push_size: Option<u64>,
1167
1168 max_struct_definitions: Option<u64>,
1170
1171 max_function_definitions: Option<u64>,
1173
1174 max_fields_in_struct: Option<u64>,
1176
1177 max_dependency_depth: Option<u64>,
1179
1180 max_num_event_emit: Option<u64>,
1182
1183 max_num_new_move_object_ids: Option<u64>,
1185
1186 max_num_new_move_object_ids_system_tx: Option<u64>,
1188
1189 max_num_deleted_move_object_ids: Option<u64>,
1191
1192 max_num_deleted_move_object_ids_system_tx: Option<u64>,
1194
1195 max_num_transferred_move_object_ids: Option<u64>,
1197
1198 max_num_transferred_move_object_ids_system_tx: Option<u64>,
1200
1201 max_event_emit_size: Option<u64>,
1203
1204 max_event_emit_size_total: Option<u64>,
1206
1207 max_move_vector_len: Option<u64>,
1209
1210 max_move_identifier_len: Option<u64>,
1212
1213 max_move_value_depth: Option<u64>,
1215
1216 max_move_enum_variants: Option<u64>,
1218
1219 max_back_edges_per_function: Option<u64>,
1221
1222 max_back_edges_per_module: Option<u64>,
1224
1225 max_verifier_meter_ticks_per_function: Option<u64>,
1227
1228 max_meter_ticks_per_module: Option<u64>,
1230
1231 max_meter_ticks_per_package: Option<u64>,
1233
1234 object_runtime_max_num_cached_objects: Option<u64>,
1238
1239 object_runtime_max_num_cached_objects_system_tx: Option<u64>,
1241
1242 object_runtime_max_num_store_entries: Option<u64>,
1244
1245 object_runtime_max_num_store_entries_system_tx: Option<u64>,
1247
1248 base_tx_cost_fixed: Option<u64>,
1251
1252 package_publish_cost_fixed: Option<u64>,
1255
1256 base_tx_cost_per_byte: Option<u64>,
1259
1260 package_publish_cost_per_byte: Option<u64>,
1262
1263 obj_access_cost_read_per_byte: Option<u64>,
1265
1266 obj_access_cost_mutate_per_byte: Option<u64>,
1268
1269 obj_access_cost_delete_per_byte: Option<u64>,
1271
1272 obj_access_cost_verify_per_byte: Option<u64>,
1282
1283 max_type_to_layout_nodes: Option<u64>,
1285
1286 max_ptb_value_size: Option<u64>,
1288
1289 gas_model_version: Option<u64>,
1292
1293 obj_data_cost_refundable: Option<u64>,
1296
1297 obj_metadata_cost_non_refundable: Option<u64>,
1301
1302 storage_rebate_rate: Option<u64>,
1308
1309 storage_fund_reinvest_rate: Option<u64>,
1312
1313 reward_slashing_rate: Option<u64>,
1316
1317 storage_gas_price: Option<u64>,
1319
1320 max_transactions_per_checkpoint: Option<u64>,
1325
1326 max_checkpoint_size_bytes: Option<u64>,
1330
1331 buffer_stake_for_protocol_upgrade_bps: Option<u64>,
1336
1337 address_from_bytes_cost_base: Option<u64>,
1342 address_to_u256_cost_base: Option<u64>,
1344 address_from_u256_cost_base: Option<u64>,
1346
1347 config_read_setting_impl_cost_base: Option<u64>,
1352 config_read_setting_impl_cost_per_byte: Option<u64>,
1353
1354 dynamic_field_hash_type_and_key_cost_base: Option<u64>,
1357 dynamic_field_hash_type_and_key_type_cost_per_byte: Option<u64>,
1358 dynamic_field_hash_type_and_key_value_cost_per_byte: Option<u64>,
1359 dynamic_field_hash_type_and_key_type_tag_cost_per_byte: Option<u64>,
1360 dynamic_field_add_child_object_cost_base: Option<u64>,
1362 dynamic_field_add_child_object_type_cost_per_byte: Option<u64>,
1363 dynamic_field_add_child_object_value_cost_per_byte: Option<u64>,
1364 dynamic_field_add_child_object_struct_tag_cost_per_byte: Option<u64>,
1365 dynamic_field_borrow_child_object_cost_base: Option<u64>,
1367 dynamic_field_borrow_child_object_child_ref_cost_per_byte: Option<u64>,
1368 dynamic_field_borrow_child_object_type_cost_per_byte: Option<u64>,
1369 dynamic_field_remove_child_object_cost_base: Option<u64>,
1371 dynamic_field_remove_child_object_child_cost_per_byte: Option<u64>,
1372 dynamic_field_remove_child_object_type_cost_per_byte: Option<u64>,
1373 dynamic_field_has_child_object_cost_base: Option<u64>,
1375 dynamic_field_has_child_object_with_ty_cost_base: Option<u64>,
1377 dynamic_field_has_child_object_with_ty_type_cost_per_byte: Option<u64>,
1378 dynamic_field_has_child_object_with_ty_type_tag_cost_per_byte: Option<u64>,
1379
1380 event_emit_cost_base: Option<u64>,
1383 event_emit_value_size_derivation_cost_per_byte: Option<u64>,
1384 event_emit_tag_size_derivation_cost_per_byte: Option<u64>,
1385 event_emit_output_cost_per_byte: Option<u64>,
1386 event_emit_auth_stream_cost: Option<u64>,
1387
1388 object_borrow_uid_cost_base: Option<u64>,
1391 object_delete_impl_cost_base: Option<u64>,
1393 object_record_new_uid_cost_base: Option<u64>,
1395
1396 transfer_transfer_internal_cost_base: Option<u64>,
1399 transfer_party_transfer_internal_cost_base: Option<u64>,
1401 transfer_freeze_object_cost_base: Option<u64>,
1403 transfer_share_object_cost_base: Option<u64>,
1405 transfer_receive_object_cost_base: Option<u64>,
1408
1409 tx_context_derive_id_cost_base: Option<u64>,
1412 tx_context_fresh_id_cost_base: Option<u64>,
1413 tx_context_sender_cost_base: Option<u64>,
1414 tx_context_epoch_cost_base: Option<u64>,
1415 tx_context_epoch_timestamp_ms_cost_base: Option<u64>,
1416 tx_context_sponsor_cost_base: Option<u64>,
1417 tx_context_rgp_cost_base: Option<u64>,
1418 tx_context_gas_price_cost_base: Option<u64>,
1419 tx_context_gas_budget_cost_base: Option<u64>,
1420 tx_context_ids_created_cost_base: Option<u64>,
1421 tx_context_replace_cost_base: Option<u64>,
1422
1423 types_is_one_time_witness_cost_base: Option<u64>,
1426 types_is_one_time_witness_type_tag_cost_per_byte: Option<u64>,
1427 types_is_one_time_witness_type_cost_per_byte: Option<u64>,
1428
1429 validator_validate_metadata_cost_base: Option<u64>,
1432 validator_validate_metadata_data_cost_per_byte: Option<u64>,
1433
1434 crypto_invalid_arguments_cost: Option<u64>,
1436 bls12381_bls12381_min_sig_verify_cost_base: Option<u64>,
1438 bls12381_bls12381_min_sig_verify_msg_cost_per_byte: Option<u64>,
1439 bls12381_bls12381_min_sig_verify_msg_cost_per_block: Option<u64>,
1440
1441 bls12381_bls12381_min_pk_verify_cost_base: Option<u64>,
1443 bls12381_bls12381_min_pk_verify_msg_cost_per_byte: Option<u64>,
1444 bls12381_bls12381_min_pk_verify_msg_cost_per_block: Option<u64>,
1445
1446 ecdsa_k1_ecrecover_keccak256_cost_base: Option<u64>,
1448 ecdsa_k1_ecrecover_keccak256_msg_cost_per_byte: Option<u64>,
1449 ecdsa_k1_ecrecover_keccak256_msg_cost_per_block: Option<u64>,
1450 ecdsa_k1_ecrecover_sha256_cost_base: Option<u64>,
1451 ecdsa_k1_ecrecover_sha256_msg_cost_per_byte: Option<u64>,
1452 ecdsa_k1_ecrecover_sha256_msg_cost_per_block: Option<u64>,
1453
1454 ecdsa_k1_decompress_pubkey_cost_base: Option<u64>,
1456
1457 ecdsa_k1_secp256k1_verify_keccak256_cost_base: Option<u64>,
1459 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_byte: Option<u64>,
1460 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_block: Option<u64>,
1461 ecdsa_k1_secp256k1_verify_sha256_cost_base: Option<u64>,
1462 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_byte: Option<u64>,
1463 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_block: Option<u64>,
1464
1465 ecdsa_r1_ecrecover_keccak256_cost_base: Option<u64>,
1467 ecdsa_r1_ecrecover_keccak256_msg_cost_per_byte: Option<u64>,
1468 ecdsa_r1_ecrecover_keccak256_msg_cost_per_block: Option<u64>,
1469 ecdsa_r1_ecrecover_sha256_cost_base: Option<u64>,
1470 ecdsa_r1_ecrecover_sha256_msg_cost_per_byte: Option<u64>,
1471 ecdsa_r1_ecrecover_sha256_msg_cost_per_block: Option<u64>,
1472
1473 ecdsa_r1_secp256r1_verify_keccak256_cost_base: Option<u64>,
1475 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_byte: Option<u64>,
1476 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_block: Option<u64>,
1477 ecdsa_r1_secp256r1_verify_sha256_cost_base: Option<u64>,
1478 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_byte: Option<u64>,
1479 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_block: Option<u64>,
1480
1481 ecvrf_ecvrf_verify_cost_base: Option<u64>,
1483 ecvrf_ecvrf_verify_alpha_string_cost_per_byte: Option<u64>,
1484 ecvrf_ecvrf_verify_alpha_string_cost_per_block: Option<u64>,
1485
1486 ed25519_ed25519_verify_cost_base: Option<u64>,
1488 ed25519_ed25519_verify_msg_cost_per_byte: Option<u64>,
1489 ed25519_ed25519_verify_msg_cost_per_block: Option<u64>,
1490
1491 groth16_prepare_verifying_key_bls12381_cost_base: Option<u64>,
1493 groth16_prepare_verifying_key_bn254_cost_base: Option<u64>,
1494
1495 groth16_verify_groth16_proof_internal_bls12381_cost_base: Option<u64>,
1497 groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input: Option<u64>,
1498 groth16_verify_groth16_proof_internal_bn254_cost_base: Option<u64>,
1499 groth16_verify_groth16_proof_internal_bn254_cost_per_public_input: Option<u64>,
1500 groth16_verify_groth16_proof_internal_public_input_cost_per_byte: Option<u64>,
1501
1502 hash_blake2b256_cost_base: Option<u64>,
1504 hash_blake2b256_data_cost_per_byte: Option<u64>,
1505 hash_blake2b256_data_cost_per_block: Option<u64>,
1506
1507 hash_keccak256_cost_base: Option<u64>,
1509 hash_keccak256_data_cost_per_byte: Option<u64>,
1510 hash_keccak256_data_cost_per_block: Option<u64>,
1511
1512 poseidon_bn254_cost_base: Option<u64>,
1514 poseidon_bn254_cost_per_block: Option<u64>,
1515
1516 group_ops_bls12381_decode_scalar_cost: Option<u64>,
1518 group_ops_bls12381_decode_g1_cost: Option<u64>,
1519 group_ops_bls12381_decode_g2_cost: Option<u64>,
1520 group_ops_bls12381_decode_gt_cost: Option<u64>,
1521 group_ops_bls12381_scalar_add_cost: Option<u64>,
1522 group_ops_bls12381_g1_add_cost: Option<u64>,
1523 group_ops_bls12381_g2_add_cost: Option<u64>,
1524 group_ops_bls12381_gt_add_cost: Option<u64>,
1525 group_ops_bls12381_scalar_sub_cost: Option<u64>,
1526 group_ops_bls12381_g1_sub_cost: Option<u64>,
1527 group_ops_bls12381_g2_sub_cost: Option<u64>,
1528 group_ops_bls12381_gt_sub_cost: Option<u64>,
1529 group_ops_bls12381_scalar_mul_cost: Option<u64>,
1530 group_ops_bls12381_g1_mul_cost: Option<u64>,
1531 group_ops_bls12381_g2_mul_cost: Option<u64>,
1532 group_ops_bls12381_gt_mul_cost: Option<u64>,
1533 group_ops_bls12381_scalar_div_cost: Option<u64>,
1534 group_ops_bls12381_g1_div_cost: Option<u64>,
1535 group_ops_bls12381_g2_div_cost: Option<u64>,
1536 group_ops_bls12381_gt_div_cost: Option<u64>,
1537 group_ops_bls12381_g1_hash_to_base_cost: Option<u64>,
1538 group_ops_bls12381_g2_hash_to_base_cost: Option<u64>,
1539 group_ops_bls12381_g1_hash_to_cost_per_byte: Option<u64>,
1540 group_ops_bls12381_g2_hash_to_cost_per_byte: Option<u64>,
1541 group_ops_bls12381_g1_msm_base_cost: Option<u64>,
1542 group_ops_bls12381_g2_msm_base_cost: Option<u64>,
1543 group_ops_bls12381_g1_msm_base_cost_per_input: Option<u64>,
1544 group_ops_bls12381_g2_msm_base_cost_per_input: Option<u64>,
1545 group_ops_bls12381_msm_max_len: Option<u32>,
1546 group_ops_bls12381_pairing_cost: Option<u64>,
1547 group_ops_bls12381_g1_to_uncompressed_g1_cost: Option<u64>,
1548 group_ops_bls12381_uncompressed_g1_to_g1_cost: Option<u64>,
1549 group_ops_bls12381_uncompressed_g1_sum_base_cost: Option<u64>,
1550 group_ops_bls12381_uncompressed_g1_sum_cost_per_term: Option<u64>,
1551 group_ops_bls12381_uncompressed_g1_sum_max_terms: Option<u64>,
1552
1553 hmac_hmac_sha3_256_cost_base: Option<u64>,
1555 hmac_hmac_sha3_256_input_cost_per_byte: Option<u64>,
1556 hmac_hmac_sha3_256_input_cost_per_block: Option<u64>,
1557
1558 check_zklogin_id_cost_base: Option<u64>,
1560 check_zklogin_issuer_cost_base: Option<u64>,
1562
1563 vdf_verify_vdf_cost: Option<u64>,
1564 vdf_hash_to_input_cost: Option<u64>,
1565
1566 nitro_attestation_parse_base_cost: Option<u64>,
1568 nitro_attestation_parse_cost_per_byte: Option<u64>,
1569 nitro_attestation_verify_base_cost: Option<u64>,
1570 nitro_attestation_verify_cost_per_cert: Option<u64>,
1571
1572 bcs_per_byte_serialized_cost: Option<u64>,
1574 bcs_legacy_min_output_size_cost: Option<u64>,
1575 bcs_failure_cost: Option<u64>,
1576
1577 hash_sha2_256_base_cost: Option<u64>,
1578 hash_sha2_256_per_byte_cost: Option<u64>,
1579 hash_sha2_256_legacy_min_input_len_cost: Option<u64>,
1580 hash_sha3_256_base_cost: Option<u64>,
1581 hash_sha3_256_per_byte_cost: Option<u64>,
1582 hash_sha3_256_legacy_min_input_len_cost: Option<u64>,
1583 type_name_get_base_cost: Option<u64>,
1584 type_name_get_per_byte_cost: Option<u64>,
1585 type_name_id_base_cost: Option<u64>,
1586
1587 string_check_utf8_base_cost: Option<u64>,
1588 string_check_utf8_per_byte_cost: Option<u64>,
1589 string_is_char_boundary_base_cost: Option<u64>,
1590 string_sub_string_base_cost: Option<u64>,
1591 string_sub_string_per_byte_cost: Option<u64>,
1592 string_index_of_base_cost: Option<u64>,
1593 string_index_of_per_byte_pattern_cost: Option<u64>,
1594 string_index_of_per_byte_searched_cost: Option<u64>,
1595
1596 vector_empty_base_cost: Option<u64>,
1597 vector_length_base_cost: Option<u64>,
1598 vector_push_back_base_cost: Option<u64>,
1599 vector_push_back_legacy_per_abstract_memory_unit_cost: Option<u64>,
1600 vector_borrow_base_cost: Option<u64>,
1601 vector_pop_back_base_cost: Option<u64>,
1602 vector_destroy_empty_base_cost: Option<u64>,
1603 vector_swap_base_cost: Option<u64>,
1604 debug_print_base_cost: Option<u64>,
1605 debug_print_stack_trace_base_cost: Option<u64>,
1606
1607 execution_version: Option<u64>,
1616
1617 consensus_bad_nodes_stake_threshold: Option<u64>,
1621
1622 max_jwk_votes_per_validator_per_epoch: Option<u64>,
1623 max_age_of_jwk_in_epochs: Option<u64>,
1627
1628 random_beacon_reduction_allowed_delta: Option<u16>,
1632
1633 random_beacon_reduction_lower_bound: Option<u32>,
1636
1637 random_beacon_dkg_timeout_round: Option<u32>,
1640
1641 random_beacon_min_round_interval_ms: Option<u64>,
1643
1644 random_beacon_dkg_version: Option<u64>,
1647
1648 consensus_max_transaction_size_bytes: Option<u64>,
1651 consensus_max_transactions_in_block_bytes: Option<u64>,
1653 consensus_max_num_transactions_in_block: Option<u64>,
1655
1656 consensus_voting_rounds: Option<u32>,
1658
1659 max_accumulated_txn_cost_per_object_in_narwhal_commit: Option<u64>,
1661
1662 max_deferral_rounds_for_congestion_control: Option<u64>,
1665
1666 max_txn_cost_overage_per_object_in_commit: Option<u64>,
1670
1671 allowed_txn_cost_overage_burst_per_object_in_commit: Option<u64>,
1675
1676 min_checkpoint_interval_ms: Option<u64>,
1678
1679 checkpoint_summary_version_specific_data: Option<u64>,
1681
1682 max_soft_bundle_size: Option<u64>,
1684
1685 bridge_should_try_to_finalize_committee: Option<bool>,
1689
1690 max_accumulated_txn_cost_per_object_in_mysticeti_commit: Option<u64>,
1696
1697 max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit: Option<u64>,
1700
1701 consensus_gc_depth: Option<u32>,
1704
1705 gas_budget_based_txn_cost_cap_factor: Option<u64>,
1709
1710 gas_budget_based_txn_cost_absolute_cap_commit_count: Option<u64>,
1713
1714 sip_45_consensus_amplification_threshold: Option<u64>,
1717
1718 use_object_per_epoch_marker_table_v2: Option<bool>,
1721
1722 consensus_commit_rate_estimation_window_size: Option<u32>,
1724
1725 #[serde(skip_serializing_if = "Vec::is_empty")]
1729 aliased_addresses: Vec<AliasedAddress>,
1730
1731 translation_per_command_base_charge: Option<u64>,
1734
1735 translation_per_input_base_charge: Option<u64>,
1738
1739 translation_pure_input_per_byte_charge: Option<u64>,
1741
1742 translation_per_type_node_charge: Option<u64>,
1746
1747 translation_per_reference_node_charge: Option<u64>,
1750
1751 translation_per_linkage_entry_charge: Option<u64>,
1754
1755 max_updates_per_settlement_txn: Option<u32>,
1757}
1758
1759#[derive(Clone, Serialize, Deserialize, Debug)]
1761pub struct AliasedAddress {
1762 pub original: [u8; 32],
1764 pub aliased: [u8; 32],
1766 pub allowed_tx_digests: Vec<[u8; 32]>,
1768}
1769
1770impl ProtocolConfig {
1772 pub fn check_package_upgrades_supported(&self) -> Result<(), Error> {
1785 if self.feature_flags.package_upgrades {
1786 Ok(())
1787 } else {
1788 Err(Error(format!(
1789 "package upgrades are not supported at {:?}",
1790 self.version
1791 )))
1792 }
1793 }
1794
1795 pub fn allow_receiving_object_id(&self) -> bool {
1796 self.feature_flags.allow_receiving_object_id
1797 }
1798
1799 pub fn receiving_objects_supported(&self) -> bool {
1800 self.feature_flags.receive_objects
1801 }
1802
1803 pub fn package_upgrades_supported(&self) -> bool {
1804 self.feature_flags.package_upgrades
1805 }
1806
1807 pub fn check_commit_root_state_digest_supported(&self) -> bool {
1808 self.feature_flags.commit_root_state_digest
1809 }
1810
1811 pub fn get_advance_epoch_start_time_in_safe_mode(&self) -> bool {
1812 self.feature_flags.advance_epoch_start_time_in_safe_mode
1813 }
1814
1815 pub fn loaded_child_objects_fixed(&self) -> bool {
1816 self.feature_flags.loaded_child_objects_fixed
1817 }
1818
1819 pub fn missing_type_is_compatibility_error(&self) -> bool {
1820 self.feature_flags.missing_type_is_compatibility_error
1821 }
1822
1823 pub fn scoring_decision_with_validity_cutoff(&self) -> bool {
1824 self.feature_flags.scoring_decision_with_validity_cutoff
1825 }
1826
1827 pub fn narwhal_versioned_metadata(&self) -> bool {
1828 self.feature_flags.narwhal_versioned_metadata
1829 }
1830
1831 pub fn consensus_order_end_of_epoch_last(&self) -> bool {
1832 self.feature_flags.consensus_order_end_of_epoch_last
1833 }
1834
1835 pub fn disallow_adding_abilities_on_upgrade(&self) -> bool {
1836 self.feature_flags.disallow_adding_abilities_on_upgrade
1837 }
1838
1839 pub fn disable_invariant_violation_check_in_swap_loc(&self) -> bool {
1840 self.feature_flags
1841 .disable_invariant_violation_check_in_swap_loc
1842 }
1843
1844 pub fn advance_to_highest_supported_protocol_version(&self) -> bool {
1845 self.feature_flags
1846 .advance_to_highest_supported_protocol_version
1847 }
1848
1849 pub fn ban_entry_init(&self) -> bool {
1850 self.feature_flags.ban_entry_init
1851 }
1852
1853 pub fn package_digest_hash_module(&self) -> bool {
1854 self.feature_flags.package_digest_hash_module
1855 }
1856
1857 pub fn disallow_change_struct_type_params_on_upgrade(&self) -> bool {
1858 self.feature_flags
1859 .disallow_change_struct_type_params_on_upgrade
1860 }
1861
1862 pub fn no_extraneous_module_bytes(&self) -> bool {
1863 self.feature_flags.no_extraneous_module_bytes
1864 }
1865
1866 pub fn zklogin_auth(&self) -> bool {
1867 self.feature_flags.zklogin_auth
1868 }
1869
1870 pub fn zklogin_supported_providers(&self) -> &BTreeSet<String> {
1871 &self.feature_flags.zklogin_supported_providers
1872 }
1873
1874 pub fn consensus_transaction_ordering(&self) -> ConsensusTransactionOrdering {
1875 self.feature_flags.consensus_transaction_ordering
1876 }
1877
1878 pub fn simplified_unwrap_then_delete(&self) -> bool {
1879 self.feature_flags.simplified_unwrap_then_delete
1880 }
1881
1882 pub fn supports_upgraded_multisig(&self) -> bool {
1883 self.feature_flags.upgraded_multisig_supported
1884 }
1885
1886 pub fn txn_base_cost_as_multiplier(&self) -> bool {
1887 self.feature_flags.txn_base_cost_as_multiplier
1888 }
1889
1890 pub fn shared_object_deletion(&self) -> bool {
1891 self.feature_flags.shared_object_deletion
1892 }
1893
1894 pub fn narwhal_new_leader_election_schedule(&self) -> bool {
1895 self.feature_flags.narwhal_new_leader_election_schedule
1896 }
1897
1898 pub fn loaded_child_object_format(&self) -> bool {
1899 self.feature_flags.loaded_child_object_format
1900 }
1901
1902 pub fn enable_jwk_consensus_updates(&self) -> bool {
1903 let ret = self.feature_flags.enable_jwk_consensus_updates;
1904 if ret {
1905 assert!(self.feature_flags.end_of_epoch_transaction_supported);
1907 }
1908 ret
1909 }
1910
1911 pub fn simple_conservation_checks(&self) -> bool {
1912 self.feature_flags.simple_conservation_checks
1913 }
1914
1915 pub fn loaded_child_object_format_type(&self) -> bool {
1916 self.feature_flags.loaded_child_object_format_type
1917 }
1918
1919 pub fn end_of_epoch_transaction_supported(&self) -> bool {
1920 let ret = self.feature_flags.end_of_epoch_transaction_supported;
1921 if !ret {
1922 assert!(!self.feature_flags.enable_jwk_consensus_updates);
1924 }
1925 ret
1926 }
1927
1928 pub fn recompute_has_public_transfer_in_execution(&self) -> bool {
1929 self.feature_flags
1930 .recompute_has_public_transfer_in_execution
1931 }
1932
1933 pub fn create_authenticator_state_in_genesis(&self) -> bool {
1935 self.enable_jwk_consensus_updates()
1936 }
1937
1938 pub fn random_beacon(&self) -> bool {
1939 self.feature_flags.random_beacon
1940 }
1941
1942 pub fn dkg_version(&self) -> u64 {
1943 self.random_beacon_dkg_version.unwrap_or(1)
1945 }
1946
1947 pub fn enable_bridge(&self) -> bool {
1948 let ret = self.feature_flags.bridge;
1949 if ret {
1950 assert!(self.feature_flags.end_of_epoch_transaction_supported);
1952 }
1953 ret
1954 }
1955
1956 pub fn should_try_to_finalize_bridge_committee(&self) -> bool {
1957 if !self.enable_bridge() {
1958 return false;
1959 }
1960 self.bridge_should_try_to_finalize_committee.unwrap_or(true)
1962 }
1963
1964 pub fn enable_effects_v2(&self) -> bool {
1965 self.feature_flags.enable_effects_v2
1966 }
1967
1968 pub fn narwhal_certificate_v2(&self) -> bool {
1969 self.feature_flags.narwhal_certificate_v2
1970 }
1971
1972 pub fn verify_legacy_zklogin_address(&self) -> bool {
1973 self.feature_flags.verify_legacy_zklogin_address
1974 }
1975
1976 pub fn accept_zklogin_in_multisig(&self) -> bool {
1977 self.feature_flags.accept_zklogin_in_multisig
1978 }
1979
1980 pub fn accept_passkey_in_multisig(&self) -> bool {
1981 self.feature_flags.accept_passkey_in_multisig
1982 }
1983
1984 pub fn zklogin_max_epoch_upper_bound_delta(&self) -> Option<u64> {
1985 self.feature_flags.zklogin_max_epoch_upper_bound_delta
1986 }
1987
1988 pub fn throughput_aware_consensus_submission(&self) -> bool {
1989 self.feature_flags.throughput_aware_consensus_submission
1990 }
1991
1992 pub fn include_consensus_digest_in_prologue(&self) -> bool {
1993 self.feature_flags.include_consensus_digest_in_prologue
1994 }
1995
1996 pub fn record_consensus_determined_version_assignments_in_prologue(&self) -> bool {
1997 self.feature_flags
1998 .record_consensus_determined_version_assignments_in_prologue
1999 }
2000
2001 pub fn record_additional_state_digest_in_prologue(&self) -> bool {
2002 self.feature_flags
2003 .record_additional_state_digest_in_prologue
2004 }
2005
2006 pub fn record_consensus_determined_version_assignments_in_prologue_v2(&self) -> bool {
2007 self.feature_flags
2008 .record_consensus_determined_version_assignments_in_prologue_v2
2009 }
2010
2011 pub fn prepend_prologue_tx_in_consensus_commit_in_checkpoints(&self) -> bool {
2012 self.feature_flags
2013 .prepend_prologue_tx_in_consensus_commit_in_checkpoints
2014 }
2015
2016 pub fn hardened_otw_check(&self) -> bool {
2017 self.feature_flags.hardened_otw_check
2018 }
2019
2020 pub fn enable_poseidon(&self) -> bool {
2021 self.feature_flags.enable_poseidon
2022 }
2023
2024 pub fn enable_coin_deny_list_v1(&self) -> bool {
2025 self.feature_flags.enable_coin_deny_list
2026 }
2027
2028 pub fn enable_accumulators(&self) -> bool {
2029 self.feature_flags.enable_accumulators
2030 }
2031
2032 pub fn create_root_accumulator_object(&self) -> bool {
2033 self.feature_flags.create_root_accumulator_object
2034 }
2035
2036 pub fn enable_address_balance_gas_payments(&self) -> bool {
2037 self.feature_flags.enable_address_balance_gas_payments
2038 }
2039
2040 pub fn enable_authenticated_event_streams(&self) -> bool {
2041 self.feature_flags.enable_authenticated_event_streams && self.enable_accumulators()
2042 }
2043
2044 pub fn enable_non_exclusive_writes(&self) -> bool {
2045 self.feature_flags.enable_non_exclusive_writes
2046 }
2047
2048 pub fn enable_coin_registry(&self) -> bool {
2049 self.feature_flags.enable_coin_registry
2050 }
2051
2052 pub fn enable_display_registry(&self) -> bool {
2053 self.feature_flags.enable_display_registry
2054 }
2055
2056 pub fn enable_coin_deny_list_v2(&self) -> bool {
2057 self.feature_flags.enable_coin_deny_list_v2
2058 }
2059
2060 pub fn enable_group_ops_native_functions(&self) -> bool {
2061 self.feature_flags.enable_group_ops_native_functions
2062 }
2063
2064 pub fn enable_group_ops_native_function_msm(&self) -> bool {
2065 self.feature_flags.enable_group_ops_native_function_msm
2066 }
2067
2068 pub fn reject_mutable_random_on_entry_functions(&self) -> bool {
2069 self.feature_flags.reject_mutable_random_on_entry_functions
2070 }
2071
2072 pub fn per_object_congestion_control_mode(&self) -> PerObjectCongestionControlMode {
2073 self.feature_flags.per_object_congestion_control_mode
2074 }
2075
2076 pub fn consensus_choice(&self) -> ConsensusChoice {
2077 self.feature_flags.consensus_choice
2078 }
2079
2080 pub fn consensus_network(&self) -> ConsensusNetwork {
2081 self.feature_flags.consensus_network
2082 }
2083
2084 pub fn correct_gas_payment_limit_check(&self) -> bool {
2085 self.feature_flags.correct_gas_payment_limit_check
2086 }
2087
2088 pub fn reshare_at_same_initial_version(&self) -> bool {
2089 self.feature_flags.reshare_at_same_initial_version
2090 }
2091
2092 pub fn resolve_abort_locations_to_package_id(&self) -> bool {
2093 self.feature_flags.resolve_abort_locations_to_package_id
2094 }
2095
2096 pub fn mysticeti_use_committed_subdag_digest(&self) -> bool {
2097 self.feature_flags.mysticeti_use_committed_subdag_digest
2098 }
2099
2100 pub fn enable_vdf(&self) -> bool {
2101 self.feature_flags.enable_vdf
2102 }
2103
2104 pub fn fresh_vm_on_framework_upgrade(&self) -> bool {
2105 self.feature_flags.fresh_vm_on_framework_upgrade
2106 }
2107
2108 pub fn mysticeti_num_leaders_per_round(&self) -> Option<usize> {
2109 self.feature_flags.mysticeti_num_leaders_per_round
2110 }
2111
2112 pub fn soft_bundle(&self) -> bool {
2113 self.feature_flags.soft_bundle
2114 }
2115
2116 pub fn passkey_auth(&self) -> bool {
2117 self.feature_flags.passkey_auth
2118 }
2119
2120 pub fn authority_capabilities_v2(&self) -> bool {
2121 self.feature_flags.authority_capabilities_v2
2122 }
2123
2124 pub fn max_transaction_size_bytes(&self) -> u64 {
2125 self.consensus_max_transaction_size_bytes
2127 .unwrap_or(256 * 1024)
2128 }
2129
2130 pub fn max_transactions_in_block_bytes(&self) -> u64 {
2131 if cfg!(msim) {
2132 256 * 1024
2133 } else {
2134 self.consensus_max_transactions_in_block_bytes
2135 .unwrap_or(512 * 1024)
2136 }
2137 }
2138
2139 pub fn max_num_transactions_in_block(&self) -> u64 {
2140 if cfg!(msim) {
2141 8
2142 } else {
2143 self.consensus_max_num_transactions_in_block.unwrap_or(512)
2144 }
2145 }
2146
2147 pub fn rethrow_serialization_type_layout_errors(&self) -> bool {
2148 self.feature_flags.rethrow_serialization_type_layout_errors
2149 }
2150
2151 pub fn consensus_distributed_vote_scoring_strategy(&self) -> bool {
2152 self.feature_flags
2153 .consensus_distributed_vote_scoring_strategy
2154 }
2155
2156 pub fn consensus_round_prober(&self) -> bool {
2157 self.feature_flags.consensus_round_prober
2158 }
2159
2160 pub fn validate_identifier_inputs(&self) -> bool {
2161 self.feature_flags.validate_identifier_inputs
2162 }
2163
2164 pub fn gc_depth(&self) -> u32 {
2165 self.consensus_gc_depth.unwrap_or(0)
2166 }
2167
2168 pub fn mysticeti_fastpath(&self) -> bool {
2169 self.feature_flags.mysticeti_fastpath
2170 }
2171
2172 pub fn relocate_event_module(&self) -> bool {
2173 self.feature_flags.relocate_event_module
2174 }
2175
2176 pub fn uncompressed_g1_group_elements(&self) -> bool {
2177 self.feature_flags.uncompressed_g1_group_elements
2178 }
2179
2180 pub fn disallow_new_modules_in_deps_only_packages(&self) -> bool {
2181 self.feature_flags
2182 .disallow_new_modules_in_deps_only_packages
2183 }
2184
2185 pub fn consensus_smart_ancestor_selection(&self) -> bool {
2186 self.feature_flags.consensus_smart_ancestor_selection
2187 }
2188
2189 pub fn consensus_round_prober_probe_accepted_rounds(&self) -> bool {
2190 self.feature_flags
2191 .consensus_round_prober_probe_accepted_rounds
2192 }
2193
2194 pub fn native_charging_v2(&self) -> bool {
2195 self.feature_flags.native_charging_v2
2196 }
2197
2198 pub fn consensus_linearize_subdag_v2(&self) -> bool {
2199 let res = self.feature_flags.consensus_linearize_subdag_v2;
2200 assert!(
2201 !res || self.gc_depth() > 0,
2202 "The consensus linearize sub dag V2 requires GC to be enabled"
2203 );
2204 res
2205 }
2206
2207 pub fn consensus_median_based_commit_timestamp(&self) -> bool {
2208 let res = self.feature_flags.consensus_median_based_commit_timestamp;
2209 assert!(
2210 !res || self.gc_depth() > 0,
2211 "The consensus median based commit timestamp requires GC to be enabled"
2212 );
2213 res
2214 }
2215
2216 pub fn consensus_batched_block_sync(&self) -> bool {
2217 self.feature_flags.consensus_batched_block_sync
2218 }
2219
2220 pub fn convert_type_argument_error(&self) -> bool {
2221 self.feature_flags.convert_type_argument_error
2222 }
2223
2224 pub fn variant_nodes(&self) -> bool {
2225 self.feature_flags.variant_nodes
2226 }
2227
2228 pub fn consensus_zstd_compression(&self) -> bool {
2229 self.feature_flags.consensus_zstd_compression
2230 }
2231
2232 pub fn enable_nitro_attestation(&self) -> bool {
2233 self.feature_flags.enable_nitro_attestation
2234 }
2235
2236 pub fn enable_nitro_attestation_upgraded_parsing(&self) -> bool {
2237 self.feature_flags.enable_nitro_attestation_upgraded_parsing
2238 }
2239
2240 pub fn enable_nitro_attestation_all_nonzero_pcrs_parsing(&self) -> bool {
2241 self.feature_flags
2242 .enable_nitro_attestation_all_nonzero_pcrs_parsing
2243 }
2244
2245 pub fn get_consensus_commit_rate_estimation_window_size(&self) -> u32 {
2246 self.consensus_commit_rate_estimation_window_size
2247 .unwrap_or(0)
2248 }
2249
2250 pub fn consensus_num_requested_prior_commits_at_startup(&self) -> u32 {
2251 let window_size = self.get_consensus_commit_rate_estimation_window_size();
2255 assert!(window_size == 0 || self.record_additional_state_digest_in_prologue());
2257 window_size
2258 }
2259
2260 pub fn minimize_child_object_mutations(&self) -> bool {
2261 self.feature_flags.minimize_child_object_mutations
2262 }
2263
2264 pub fn move_native_context(&self) -> bool {
2265 self.feature_flags.move_native_context
2266 }
2267
2268 pub fn normalize_ptb_arguments(&self) -> bool {
2269 self.feature_flags.normalize_ptb_arguments
2270 }
2271
2272 pub fn enforce_checkpoint_timestamp_monotonicity(&self) -> bool {
2273 self.feature_flags.enforce_checkpoint_timestamp_monotonicity
2274 }
2275
2276 pub fn max_ptb_value_size_v2(&self) -> bool {
2277 self.feature_flags.max_ptb_value_size_v2
2278 }
2279
2280 pub fn resolve_type_input_ids_to_defining_id(&self) -> bool {
2281 self.feature_flags.resolve_type_input_ids_to_defining_id
2282 }
2283
2284 pub fn enable_party_transfer(&self) -> bool {
2285 self.feature_flags.enable_party_transfer
2286 }
2287
2288 pub fn allow_unbounded_system_objects(&self) -> bool {
2289 self.feature_flags.allow_unbounded_system_objects
2290 }
2291
2292 pub fn type_tags_in_object_runtime(&self) -> bool {
2293 self.feature_flags.type_tags_in_object_runtime
2294 }
2295
2296 pub fn enable_ptb_execution_v2(&self) -> bool {
2297 self.feature_flags.enable_ptb_execution_v2
2298 }
2299
2300 pub fn better_adapter_type_resolution_errors(&self) -> bool {
2301 self.feature_flags.better_adapter_type_resolution_errors
2302 }
2303
2304 pub fn record_time_estimate_processed(&self) -> bool {
2305 self.feature_flags.record_time_estimate_processed
2306 }
2307
2308 pub fn ignore_execution_time_observations_after_certs_closed(&self) -> bool {
2309 self.feature_flags
2310 .ignore_execution_time_observations_after_certs_closed
2311 }
2312
2313 pub fn dependency_linkage_error(&self) -> bool {
2314 self.feature_flags.dependency_linkage_error
2315 }
2316
2317 pub fn additional_multisig_checks(&self) -> bool {
2318 self.feature_flags.additional_multisig_checks
2319 }
2320
2321 pub fn debug_fatal_on_move_invariant_violation(&self) -> bool {
2322 self.feature_flags.debug_fatal_on_move_invariant_violation
2323 }
2324
2325 pub fn allow_private_accumulator_entrypoints(&self) -> bool {
2326 self.feature_flags.allow_private_accumulator_entrypoints
2327 }
2328
2329 pub fn additional_consensus_digest_indirect_state(&self) -> bool {
2330 self.feature_flags
2331 .additional_consensus_digest_indirect_state
2332 }
2333
2334 pub fn check_for_init_during_upgrade(&self) -> bool {
2335 self.feature_flags.check_for_init_during_upgrade
2336 }
2337
2338 pub fn per_command_shared_object_transfer_rules(&self) -> bool {
2339 self.feature_flags.per_command_shared_object_transfer_rules
2340 }
2341
2342 pub fn consensus_checkpoint_signature_key_includes_digest(&self) -> bool {
2343 self.feature_flags
2344 .consensus_checkpoint_signature_key_includes_digest
2345 }
2346
2347 pub fn include_checkpoint_artifacts_digest_in_summary(&self) -> bool {
2348 self.feature_flags
2349 .include_checkpoint_artifacts_digest_in_summary
2350 }
2351
2352 pub fn use_mfp_txns_in_load_initial_object_debts(&self) -> bool {
2353 self.feature_flags.use_mfp_txns_in_load_initial_object_debts
2354 }
2355
2356 pub fn cancel_for_failed_dkg_early(&self) -> bool {
2357 self.feature_flags.cancel_for_failed_dkg_early
2358 }
2359
2360 pub fn abstract_size_in_object_runtime(&self) -> bool {
2361 self.feature_flags.abstract_size_in_object_runtime
2362 }
2363
2364 pub fn object_runtime_charge_cache_load_gas(&self) -> bool {
2365 self.feature_flags.object_runtime_charge_cache_load_gas
2366 }
2367
2368 pub fn additional_borrow_checks(&self) -> bool {
2369 self.feature_flags.additional_borrow_checks
2370 }
2371
2372 pub fn use_new_commit_handler(&self) -> bool {
2373 self.feature_flags.use_new_commit_handler
2374 }
2375
2376 pub fn better_loader_errors(&self) -> bool {
2377 self.feature_flags.better_loader_errors
2378 }
2379
2380 pub fn generate_df_type_layouts(&self) -> bool {
2381 self.feature_flags.generate_df_type_layouts
2382 }
2383
2384 pub fn allow_references_in_ptbs(&self) -> bool {
2385 self.feature_flags.allow_references_in_ptbs
2386 }
2387
2388 pub fn private_generics_verifier_v2(&self) -> bool {
2389 self.feature_flags.private_generics_verifier_v2
2390 }
2391
2392 pub fn deprecate_global_storage_ops_during_deserialization(&self) -> bool {
2393 self.feature_flags
2394 .deprecate_global_storage_ops_during_deserialization
2395 }
2396
2397 pub fn enable_observation_chunking(&self) -> bool {
2398 matches!(self.feature_flags.per_object_congestion_control_mode,
2399 PerObjectCongestionControlMode::ExecutionTimeEstimate(ref params)
2400 if params.observations_chunk_size.is_some()
2401 )
2402 }
2403
2404 pub fn deprecate_global_storage_ops(&self) -> bool {
2405 self.feature_flags.deprecate_global_storage_ops
2406 }
2407
2408 pub fn consensus_skip_gced_accept_votes(&self) -> bool {
2409 self.feature_flags.consensus_skip_gced_accept_votes
2410 }
2411}
2412
2413#[cfg(not(msim))]
2414static POISON_VERSION_METHODS: AtomicBool = AtomicBool::new(false);
2415
2416#[cfg(msim)]
2418thread_local! {
2419 static POISON_VERSION_METHODS: AtomicBool = AtomicBool::new(false);
2420}
2421
2422impl ProtocolConfig {
2424 pub fn get_for_version(version: ProtocolVersion, chain: Chain) -> Self {
2426 assert!(
2428 version >= ProtocolVersion::MIN,
2429 "Network protocol version is {:?}, but the minimum supported version by the binary is {:?}. Please upgrade the binary.",
2430 version,
2431 ProtocolVersion::MIN.0,
2432 );
2433 assert!(
2434 version <= ProtocolVersion::MAX_ALLOWED,
2435 "Network protocol version is {:?}, but the maximum supported version by the binary is {:?}. Please upgrade the binary.",
2436 version,
2437 ProtocolVersion::MAX_ALLOWED.0,
2438 );
2439
2440 let mut ret = Self::get_for_version_impl(version, chain);
2441 ret.version = version;
2442
2443 ret = CONFIG_OVERRIDE.with(|ovr| {
2444 if let Some(override_fn) = &*ovr.borrow() {
2445 warn!(
2446 "overriding ProtocolConfig settings with custom settings (you should not see this log outside of tests)"
2447 );
2448 override_fn(version, ret)
2449 } else {
2450 ret
2451 }
2452 });
2453
2454 if std::env::var("SUI_PROTOCOL_CONFIG_OVERRIDE_ENABLE").is_ok() {
2455 warn!(
2456 "overriding ProtocolConfig settings with custom settings; this may break non-local networks"
2457 );
2458 let overrides: ProtocolConfigOptional =
2459 serde_env::from_env_with_prefix("SUI_PROTOCOL_CONFIG_OVERRIDE")
2460 .expect("failed to parse ProtocolConfig override env variables");
2461 overrides.apply_to(&mut ret);
2462 }
2463
2464 ret
2465 }
2466
2467 pub fn get_for_version_if_supported(version: ProtocolVersion, chain: Chain) -> Option<Self> {
2470 if version.0 >= ProtocolVersion::MIN.0 && version.0 <= ProtocolVersion::MAX_ALLOWED.0 {
2471 let mut ret = Self::get_for_version_impl(version, chain);
2472 ret.version = version;
2473 Some(ret)
2474 } else {
2475 None
2476 }
2477 }
2478
2479 #[cfg(not(msim))]
2480 pub fn poison_get_for_min_version() {
2481 POISON_VERSION_METHODS.store(true, Ordering::Relaxed);
2482 }
2483
2484 #[cfg(not(msim))]
2485 fn load_poison_get_for_min_version() -> bool {
2486 POISON_VERSION_METHODS.load(Ordering::Relaxed)
2487 }
2488
2489 #[cfg(msim)]
2490 pub fn poison_get_for_min_version() {
2491 POISON_VERSION_METHODS.with(|p| p.store(true, Ordering::Relaxed));
2492 }
2493
2494 #[cfg(msim)]
2495 fn load_poison_get_for_min_version() -> bool {
2496 POISON_VERSION_METHODS.with(|p| p.load(Ordering::Relaxed))
2497 }
2498
2499 pub fn get_for_min_version() -> Self {
2502 if Self::load_poison_get_for_min_version() {
2503 panic!("get_for_min_version called on validator");
2504 }
2505 ProtocolConfig::get_for_version(ProtocolVersion::MIN, Chain::Unknown)
2506 }
2507
2508 #[allow(non_snake_case)]
2518 pub fn get_for_max_version_UNSAFE() -> Self {
2519 if Self::load_poison_get_for_min_version() {
2520 panic!("get_for_max_version_UNSAFE called on validator");
2521 }
2522 ProtocolConfig::get_for_version(ProtocolVersion::MAX, Chain::Unknown)
2523 }
2524
2525 fn get_for_version_impl(version: ProtocolVersion, chain: Chain) -> Self {
2526 #[cfg(msim)]
2527 {
2528 if version == ProtocolVersion::MAX_ALLOWED {
2530 let mut config = Self::get_for_version_impl(version - 1, Chain::Unknown);
2531 config.base_tx_cost_fixed = Some(config.base_tx_cost_fixed() + 1000);
2532 return config;
2533 }
2534 }
2535
2536 let mut cfg = Self {
2539 version,
2541
2542 feature_flags: Default::default(),
2544
2545 max_tx_size_bytes: Some(128 * 1024),
2546 max_input_objects: Some(2048),
2548 max_serialized_tx_effects_size_bytes: Some(512 * 1024),
2549 max_serialized_tx_effects_size_bytes_system_tx: Some(512 * 1024 * 16),
2550 max_gas_payment_objects: Some(256),
2551 max_modules_in_publish: Some(128),
2552 max_package_dependencies: None,
2553 max_arguments: Some(512),
2554 max_type_arguments: Some(16),
2555 max_type_argument_depth: Some(16),
2556 max_pure_argument_size: Some(16 * 1024),
2557 max_programmable_tx_commands: Some(1024),
2558 move_binary_format_version: Some(6),
2559 min_move_binary_format_version: None,
2560 binary_module_handles: None,
2561 binary_struct_handles: None,
2562 binary_function_handles: None,
2563 binary_function_instantiations: None,
2564 binary_signatures: None,
2565 binary_constant_pool: None,
2566 binary_identifiers: None,
2567 binary_address_identifiers: None,
2568 binary_struct_defs: None,
2569 binary_struct_def_instantiations: None,
2570 binary_function_defs: None,
2571 binary_field_handles: None,
2572 binary_field_instantiations: None,
2573 binary_friend_decls: None,
2574 binary_enum_defs: None,
2575 binary_enum_def_instantiations: None,
2576 binary_variant_handles: None,
2577 binary_variant_instantiation_handles: None,
2578 max_move_object_size: Some(250 * 1024),
2579 max_move_package_size: Some(100 * 1024),
2580 max_publish_or_upgrade_per_ptb: None,
2581 max_tx_gas: Some(10_000_000_000),
2582 max_gas_price: Some(100_000),
2583 max_gas_price_rgp_factor_for_aborted_transactions: None,
2584 max_gas_computation_bucket: Some(5_000_000),
2585 max_loop_depth: Some(5),
2586 max_generic_instantiation_length: Some(32),
2587 max_function_parameters: Some(128),
2588 max_basic_blocks: Some(1024),
2589 max_value_stack_size: Some(1024),
2590 max_type_nodes: Some(256),
2591 max_push_size: Some(10000),
2592 max_struct_definitions: Some(200),
2593 max_function_definitions: Some(1000),
2594 max_fields_in_struct: Some(32),
2595 max_dependency_depth: Some(100),
2596 max_num_event_emit: Some(256),
2597 max_num_new_move_object_ids: Some(2048),
2598 max_num_new_move_object_ids_system_tx: Some(2048 * 16),
2599 max_num_deleted_move_object_ids: Some(2048),
2600 max_num_deleted_move_object_ids_system_tx: Some(2048 * 16),
2601 max_num_transferred_move_object_ids: Some(2048),
2602 max_num_transferred_move_object_ids_system_tx: Some(2048 * 16),
2603 max_event_emit_size: Some(250 * 1024),
2604 max_move_vector_len: Some(256 * 1024),
2605 max_type_to_layout_nodes: None,
2606 max_ptb_value_size: None,
2607
2608 max_back_edges_per_function: Some(10_000),
2609 max_back_edges_per_module: Some(10_000),
2610 max_verifier_meter_ticks_per_function: Some(6_000_000),
2611 max_meter_ticks_per_module: Some(6_000_000),
2612 max_meter_ticks_per_package: None,
2613
2614 object_runtime_max_num_cached_objects: Some(1000),
2615 object_runtime_max_num_cached_objects_system_tx: Some(1000 * 16),
2616 object_runtime_max_num_store_entries: Some(1000),
2617 object_runtime_max_num_store_entries_system_tx: Some(1000 * 16),
2618 base_tx_cost_fixed: Some(110_000),
2619 package_publish_cost_fixed: Some(1_000),
2620 base_tx_cost_per_byte: Some(0),
2621 package_publish_cost_per_byte: Some(80),
2622 obj_access_cost_read_per_byte: Some(15),
2623 obj_access_cost_mutate_per_byte: Some(40),
2624 obj_access_cost_delete_per_byte: Some(40),
2625 obj_access_cost_verify_per_byte: Some(200),
2626 obj_data_cost_refundable: Some(100),
2627 obj_metadata_cost_non_refundable: Some(50),
2628 gas_model_version: Some(1),
2629 storage_rebate_rate: Some(9900),
2630 storage_fund_reinvest_rate: Some(500),
2631 reward_slashing_rate: Some(5000),
2632 storage_gas_price: Some(1),
2633 max_transactions_per_checkpoint: Some(10_000),
2634 max_checkpoint_size_bytes: Some(30 * 1024 * 1024),
2635
2636 buffer_stake_for_protocol_upgrade_bps: Some(0),
2639
2640 address_from_bytes_cost_base: Some(52),
2644 address_to_u256_cost_base: Some(52),
2646 address_from_u256_cost_base: Some(52),
2648
2649 config_read_setting_impl_cost_base: None,
2652 config_read_setting_impl_cost_per_byte: None,
2653
2654 dynamic_field_hash_type_and_key_cost_base: Some(100),
2657 dynamic_field_hash_type_and_key_type_cost_per_byte: Some(2),
2658 dynamic_field_hash_type_and_key_value_cost_per_byte: Some(2),
2659 dynamic_field_hash_type_and_key_type_tag_cost_per_byte: Some(2),
2660 dynamic_field_add_child_object_cost_base: Some(100),
2662 dynamic_field_add_child_object_type_cost_per_byte: Some(10),
2663 dynamic_field_add_child_object_value_cost_per_byte: Some(10),
2664 dynamic_field_add_child_object_struct_tag_cost_per_byte: Some(10),
2665 dynamic_field_borrow_child_object_cost_base: Some(100),
2667 dynamic_field_borrow_child_object_child_ref_cost_per_byte: Some(10),
2668 dynamic_field_borrow_child_object_type_cost_per_byte: Some(10),
2669 dynamic_field_remove_child_object_cost_base: Some(100),
2671 dynamic_field_remove_child_object_child_cost_per_byte: Some(2),
2672 dynamic_field_remove_child_object_type_cost_per_byte: Some(2),
2673 dynamic_field_has_child_object_cost_base: Some(100),
2675 dynamic_field_has_child_object_with_ty_cost_base: Some(100),
2677 dynamic_field_has_child_object_with_ty_type_cost_per_byte: Some(2),
2678 dynamic_field_has_child_object_with_ty_type_tag_cost_per_byte: Some(2),
2679
2680 event_emit_cost_base: Some(52),
2683 event_emit_value_size_derivation_cost_per_byte: Some(2),
2684 event_emit_tag_size_derivation_cost_per_byte: Some(5),
2685 event_emit_output_cost_per_byte: Some(10),
2686 event_emit_auth_stream_cost: None,
2687
2688 object_borrow_uid_cost_base: Some(52),
2691 object_delete_impl_cost_base: Some(52),
2693 object_record_new_uid_cost_base: Some(52),
2695
2696 transfer_transfer_internal_cost_base: Some(52),
2699 transfer_party_transfer_internal_cost_base: None,
2701 transfer_freeze_object_cost_base: Some(52),
2703 transfer_share_object_cost_base: Some(52),
2705 transfer_receive_object_cost_base: None,
2706
2707 tx_context_derive_id_cost_base: Some(52),
2710 tx_context_fresh_id_cost_base: None,
2711 tx_context_sender_cost_base: None,
2712 tx_context_epoch_cost_base: None,
2713 tx_context_epoch_timestamp_ms_cost_base: None,
2714 tx_context_sponsor_cost_base: None,
2715 tx_context_rgp_cost_base: None,
2716 tx_context_gas_price_cost_base: None,
2717 tx_context_gas_budget_cost_base: None,
2718 tx_context_ids_created_cost_base: None,
2719 tx_context_replace_cost_base: None,
2720
2721 types_is_one_time_witness_cost_base: Some(52),
2724 types_is_one_time_witness_type_tag_cost_per_byte: Some(2),
2725 types_is_one_time_witness_type_cost_per_byte: Some(2),
2726
2727 validator_validate_metadata_cost_base: Some(52),
2730 validator_validate_metadata_data_cost_per_byte: Some(2),
2731
2732 crypto_invalid_arguments_cost: Some(100),
2734 bls12381_bls12381_min_sig_verify_cost_base: Some(52),
2736 bls12381_bls12381_min_sig_verify_msg_cost_per_byte: Some(2),
2737 bls12381_bls12381_min_sig_verify_msg_cost_per_block: Some(2),
2738
2739 bls12381_bls12381_min_pk_verify_cost_base: Some(52),
2741 bls12381_bls12381_min_pk_verify_msg_cost_per_byte: Some(2),
2742 bls12381_bls12381_min_pk_verify_msg_cost_per_block: Some(2),
2743
2744 ecdsa_k1_ecrecover_keccak256_cost_base: Some(52),
2746 ecdsa_k1_ecrecover_keccak256_msg_cost_per_byte: Some(2),
2747 ecdsa_k1_ecrecover_keccak256_msg_cost_per_block: Some(2),
2748 ecdsa_k1_ecrecover_sha256_cost_base: Some(52),
2749 ecdsa_k1_ecrecover_sha256_msg_cost_per_byte: Some(2),
2750 ecdsa_k1_ecrecover_sha256_msg_cost_per_block: Some(2),
2751
2752 ecdsa_k1_decompress_pubkey_cost_base: Some(52),
2754
2755 ecdsa_k1_secp256k1_verify_keccak256_cost_base: Some(52),
2757 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_byte: Some(2),
2758 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_block: Some(2),
2759 ecdsa_k1_secp256k1_verify_sha256_cost_base: Some(52),
2760 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_byte: Some(2),
2761 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_block: Some(2),
2762
2763 ecdsa_r1_ecrecover_keccak256_cost_base: Some(52),
2765 ecdsa_r1_ecrecover_keccak256_msg_cost_per_byte: Some(2),
2766 ecdsa_r1_ecrecover_keccak256_msg_cost_per_block: Some(2),
2767 ecdsa_r1_ecrecover_sha256_cost_base: Some(52),
2768 ecdsa_r1_ecrecover_sha256_msg_cost_per_byte: Some(2),
2769 ecdsa_r1_ecrecover_sha256_msg_cost_per_block: Some(2),
2770
2771 ecdsa_r1_secp256r1_verify_keccak256_cost_base: Some(52),
2773 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_byte: Some(2),
2774 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_block: Some(2),
2775 ecdsa_r1_secp256r1_verify_sha256_cost_base: Some(52),
2776 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_byte: Some(2),
2777 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_block: Some(2),
2778
2779 ecvrf_ecvrf_verify_cost_base: Some(52),
2781 ecvrf_ecvrf_verify_alpha_string_cost_per_byte: Some(2),
2782 ecvrf_ecvrf_verify_alpha_string_cost_per_block: Some(2),
2783
2784 ed25519_ed25519_verify_cost_base: Some(52),
2786 ed25519_ed25519_verify_msg_cost_per_byte: Some(2),
2787 ed25519_ed25519_verify_msg_cost_per_block: Some(2),
2788
2789 groth16_prepare_verifying_key_bls12381_cost_base: Some(52),
2791 groth16_prepare_verifying_key_bn254_cost_base: Some(52),
2792
2793 groth16_verify_groth16_proof_internal_bls12381_cost_base: Some(52),
2795 groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input: Some(2),
2796 groth16_verify_groth16_proof_internal_bn254_cost_base: Some(52),
2797 groth16_verify_groth16_proof_internal_bn254_cost_per_public_input: Some(2),
2798 groth16_verify_groth16_proof_internal_public_input_cost_per_byte: Some(2),
2799
2800 hash_blake2b256_cost_base: Some(52),
2802 hash_blake2b256_data_cost_per_byte: Some(2),
2803 hash_blake2b256_data_cost_per_block: Some(2),
2804 hash_keccak256_cost_base: Some(52),
2806 hash_keccak256_data_cost_per_byte: Some(2),
2807 hash_keccak256_data_cost_per_block: Some(2),
2808
2809 poseidon_bn254_cost_base: None,
2810 poseidon_bn254_cost_per_block: None,
2811
2812 hmac_hmac_sha3_256_cost_base: Some(52),
2814 hmac_hmac_sha3_256_input_cost_per_byte: Some(2),
2815 hmac_hmac_sha3_256_input_cost_per_block: Some(2),
2816
2817 group_ops_bls12381_decode_scalar_cost: None,
2819 group_ops_bls12381_decode_g1_cost: None,
2820 group_ops_bls12381_decode_g2_cost: None,
2821 group_ops_bls12381_decode_gt_cost: None,
2822 group_ops_bls12381_scalar_add_cost: None,
2823 group_ops_bls12381_g1_add_cost: None,
2824 group_ops_bls12381_g2_add_cost: None,
2825 group_ops_bls12381_gt_add_cost: None,
2826 group_ops_bls12381_scalar_sub_cost: None,
2827 group_ops_bls12381_g1_sub_cost: None,
2828 group_ops_bls12381_g2_sub_cost: None,
2829 group_ops_bls12381_gt_sub_cost: None,
2830 group_ops_bls12381_scalar_mul_cost: None,
2831 group_ops_bls12381_g1_mul_cost: None,
2832 group_ops_bls12381_g2_mul_cost: None,
2833 group_ops_bls12381_gt_mul_cost: None,
2834 group_ops_bls12381_scalar_div_cost: None,
2835 group_ops_bls12381_g1_div_cost: None,
2836 group_ops_bls12381_g2_div_cost: None,
2837 group_ops_bls12381_gt_div_cost: None,
2838 group_ops_bls12381_g1_hash_to_base_cost: None,
2839 group_ops_bls12381_g2_hash_to_base_cost: None,
2840 group_ops_bls12381_g1_hash_to_cost_per_byte: None,
2841 group_ops_bls12381_g2_hash_to_cost_per_byte: None,
2842 group_ops_bls12381_g1_msm_base_cost: None,
2843 group_ops_bls12381_g2_msm_base_cost: None,
2844 group_ops_bls12381_g1_msm_base_cost_per_input: None,
2845 group_ops_bls12381_g2_msm_base_cost_per_input: None,
2846 group_ops_bls12381_msm_max_len: None,
2847 group_ops_bls12381_pairing_cost: None,
2848 group_ops_bls12381_g1_to_uncompressed_g1_cost: None,
2849 group_ops_bls12381_uncompressed_g1_to_g1_cost: None,
2850 group_ops_bls12381_uncompressed_g1_sum_base_cost: None,
2851 group_ops_bls12381_uncompressed_g1_sum_cost_per_term: None,
2852 group_ops_bls12381_uncompressed_g1_sum_max_terms: None,
2853
2854 check_zklogin_id_cost_base: None,
2856 check_zklogin_issuer_cost_base: None,
2858
2859 vdf_verify_vdf_cost: None,
2860 vdf_hash_to_input_cost: None,
2861
2862 nitro_attestation_parse_base_cost: None,
2864 nitro_attestation_parse_cost_per_byte: None,
2865 nitro_attestation_verify_base_cost: None,
2866 nitro_attestation_verify_cost_per_cert: None,
2867
2868 bcs_per_byte_serialized_cost: None,
2869 bcs_legacy_min_output_size_cost: None,
2870 bcs_failure_cost: None,
2871 hash_sha2_256_base_cost: None,
2872 hash_sha2_256_per_byte_cost: None,
2873 hash_sha2_256_legacy_min_input_len_cost: None,
2874 hash_sha3_256_base_cost: None,
2875 hash_sha3_256_per_byte_cost: None,
2876 hash_sha3_256_legacy_min_input_len_cost: None,
2877 type_name_get_base_cost: None,
2878 type_name_get_per_byte_cost: None,
2879 type_name_id_base_cost: None,
2880 string_check_utf8_base_cost: None,
2881 string_check_utf8_per_byte_cost: None,
2882 string_is_char_boundary_base_cost: None,
2883 string_sub_string_base_cost: None,
2884 string_sub_string_per_byte_cost: None,
2885 string_index_of_base_cost: None,
2886 string_index_of_per_byte_pattern_cost: None,
2887 string_index_of_per_byte_searched_cost: None,
2888 vector_empty_base_cost: None,
2889 vector_length_base_cost: None,
2890 vector_push_back_base_cost: None,
2891 vector_push_back_legacy_per_abstract_memory_unit_cost: None,
2892 vector_borrow_base_cost: None,
2893 vector_pop_back_base_cost: None,
2894 vector_destroy_empty_base_cost: None,
2895 vector_swap_base_cost: None,
2896 debug_print_base_cost: None,
2897 debug_print_stack_trace_base_cost: None,
2898
2899 max_size_written_objects: None,
2900 max_size_written_objects_system_tx: None,
2901
2902 max_move_identifier_len: None,
2909 max_move_value_depth: None,
2910 max_move_enum_variants: None,
2911
2912 gas_rounding_step: None,
2913
2914 execution_version: None,
2915
2916 max_event_emit_size_total: None,
2917
2918 consensus_bad_nodes_stake_threshold: None,
2919
2920 max_jwk_votes_per_validator_per_epoch: None,
2921
2922 max_age_of_jwk_in_epochs: None,
2923
2924 random_beacon_reduction_allowed_delta: None,
2925
2926 random_beacon_reduction_lower_bound: None,
2927
2928 random_beacon_dkg_timeout_round: None,
2929
2930 random_beacon_min_round_interval_ms: None,
2931
2932 random_beacon_dkg_version: None,
2933
2934 consensus_max_transaction_size_bytes: None,
2935
2936 consensus_max_transactions_in_block_bytes: None,
2937
2938 consensus_max_num_transactions_in_block: None,
2939
2940 consensus_voting_rounds: None,
2941
2942 max_accumulated_txn_cost_per_object_in_narwhal_commit: None,
2943
2944 max_deferral_rounds_for_congestion_control: None,
2945
2946 max_txn_cost_overage_per_object_in_commit: None,
2947
2948 allowed_txn_cost_overage_burst_per_object_in_commit: None,
2949
2950 min_checkpoint_interval_ms: None,
2951
2952 checkpoint_summary_version_specific_data: None,
2953
2954 max_soft_bundle_size: None,
2955
2956 bridge_should_try_to_finalize_committee: None,
2957
2958 max_accumulated_txn_cost_per_object_in_mysticeti_commit: None,
2959
2960 max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit: None,
2961
2962 consensus_gc_depth: None,
2963
2964 gas_budget_based_txn_cost_cap_factor: None,
2965
2966 gas_budget_based_txn_cost_absolute_cap_commit_count: None,
2967
2968 sip_45_consensus_amplification_threshold: None,
2969
2970 use_object_per_epoch_marker_table_v2: None,
2971
2972 consensus_commit_rate_estimation_window_size: None,
2973
2974 aliased_addresses: vec![],
2975
2976 translation_per_command_base_charge: None,
2977 translation_per_input_base_charge: None,
2978 translation_pure_input_per_byte_charge: None,
2979 translation_per_type_node_charge: None,
2980 translation_per_reference_node_charge: None,
2981 translation_per_linkage_entry_charge: None,
2982
2983 max_updates_per_settlement_txn: None,
2984 };
2987 for cur in 2..=version.0 {
2988 match cur {
2989 1 => unreachable!(),
2990 2 => {
2991 cfg.feature_flags.advance_epoch_start_time_in_safe_mode = true;
2992 }
2993 3 => {
2994 cfg.gas_model_version = Some(2);
2996 cfg.max_tx_gas = Some(50_000_000_000);
2998 cfg.base_tx_cost_fixed = Some(2_000);
3000 cfg.storage_gas_price = Some(76);
3002 cfg.feature_flags.loaded_child_objects_fixed = true;
3003 cfg.max_size_written_objects = Some(5 * 1000 * 1000);
3006 cfg.max_size_written_objects_system_tx = Some(50 * 1000 * 1000);
3009 cfg.feature_flags.package_upgrades = true;
3010 }
3011 4 => {
3016 cfg.reward_slashing_rate = Some(10000);
3018 cfg.gas_model_version = Some(3);
3020 }
3021 5 => {
3022 cfg.feature_flags.missing_type_is_compatibility_error = true;
3023 cfg.gas_model_version = Some(4);
3024 cfg.feature_flags.scoring_decision_with_validity_cutoff = true;
3025 }
3029 6 => {
3030 cfg.gas_model_version = Some(5);
3031 cfg.buffer_stake_for_protocol_upgrade_bps = Some(5000);
3032 cfg.feature_flags.consensus_order_end_of_epoch_last = true;
3033 }
3034 7 => {
3035 cfg.feature_flags.disallow_adding_abilities_on_upgrade = true;
3036 cfg.feature_flags
3037 .disable_invariant_violation_check_in_swap_loc = true;
3038 cfg.feature_flags.ban_entry_init = true;
3039 cfg.feature_flags.package_digest_hash_module = true;
3040 }
3041 8 => {
3042 cfg.feature_flags
3043 .disallow_change_struct_type_params_on_upgrade = true;
3044 }
3045 9 => {
3046 cfg.max_move_identifier_len = Some(128);
3048 cfg.feature_flags.no_extraneous_module_bytes = true;
3049 cfg.feature_flags
3050 .advance_to_highest_supported_protocol_version = true;
3051 }
3052 10 => {
3053 cfg.max_verifier_meter_ticks_per_function = Some(16_000_000);
3054 cfg.max_meter_ticks_per_module = Some(16_000_000);
3055 }
3056 11 => {
3057 cfg.max_move_value_depth = Some(128);
3058 }
3059 12 => {
3060 cfg.feature_flags.narwhal_versioned_metadata = true;
3061 if chain != Chain::Mainnet {
3062 cfg.feature_flags.commit_root_state_digest = true;
3063 }
3064
3065 if chain != Chain::Mainnet && chain != Chain::Testnet {
3066 cfg.feature_flags.zklogin_auth = true;
3067 }
3068 }
3069 13 => {}
3070 14 => {
3071 cfg.gas_rounding_step = Some(1_000);
3072 cfg.gas_model_version = Some(6);
3073 }
3074 15 => {
3075 cfg.feature_flags.consensus_transaction_ordering =
3076 ConsensusTransactionOrdering::ByGasPrice;
3077 }
3078 16 => {
3079 cfg.feature_flags.simplified_unwrap_then_delete = true;
3080 }
3081 17 => {
3082 cfg.feature_flags.upgraded_multisig_supported = true;
3083 }
3084 18 => {
3085 cfg.execution_version = Some(1);
3086 cfg.feature_flags.txn_base_cost_as_multiplier = true;
3095 cfg.base_tx_cost_fixed = Some(1_000);
3097 }
3098 19 => {
3099 cfg.max_num_event_emit = Some(1024);
3100 cfg.max_event_emit_size_total = Some(
3103 256 * 250 * 1024, );
3105 }
3106 20 => {
3107 cfg.feature_flags.commit_root_state_digest = true;
3108
3109 if chain != Chain::Mainnet {
3110 cfg.feature_flags.narwhal_new_leader_election_schedule = true;
3111 cfg.consensus_bad_nodes_stake_threshold = Some(20);
3112 }
3113 }
3114
3115 21 => {
3116 if chain != Chain::Mainnet {
3117 cfg.feature_flags.zklogin_supported_providers = BTreeSet::from([
3118 "Google".to_string(),
3119 "Facebook".to_string(),
3120 "Twitch".to_string(),
3121 ]);
3122 }
3123 }
3124 22 => {
3125 cfg.feature_flags.loaded_child_object_format = true;
3126 }
3127 23 => {
3128 cfg.feature_flags.loaded_child_object_format_type = true;
3129 cfg.feature_flags.narwhal_new_leader_election_schedule = true;
3130 cfg.consensus_bad_nodes_stake_threshold = Some(20);
3136 }
3137 24 => {
3138 cfg.feature_flags.simple_conservation_checks = true;
3139 cfg.max_publish_or_upgrade_per_ptb = Some(5);
3140
3141 cfg.feature_flags.end_of_epoch_transaction_supported = true;
3142
3143 if chain != Chain::Mainnet {
3144 cfg.feature_flags.enable_jwk_consensus_updates = true;
3145 cfg.max_jwk_votes_per_validator_per_epoch = Some(240);
3147 cfg.max_age_of_jwk_in_epochs = Some(1);
3148 }
3149 }
3150 25 => {
3151 cfg.feature_flags.zklogin_supported_providers = BTreeSet::from([
3153 "Google".to_string(),
3154 "Facebook".to_string(),
3155 "Twitch".to_string(),
3156 ]);
3157 cfg.feature_flags.zklogin_auth = true;
3158
3159 cfg.feature_flags.enable_jwk_consensus_updates = true;
3161 cfg.max_jwk_votes_per_validator_per_epoch = Some(240);
3162 cfg.max_age_of_jwk_in_epochs = Some(1);
3163 }
3164 26 => {
3165 cfg.gas_model_version = Some(7);
3166 if chain != Chain::Mainnet && chain != Chain::Testnet {
3168 cfg.transfer_receive_object_cost_base = Some(52);
3169 cfg.feature_flags.receive_objects = true;
3170 }
3171 }
3172 27 => {
3173 cfg.gas_model_version = Some(8);
3174 }
3175 28 => {
3176 cfg.check_zklogin_id_cost_base = Some(200);
3178 cfg.check_zklogin_issuer_cost_base = Some(200);
3180
3181 if chain != Chain::Mainnet && chain != Chain::Testnet {
3183 cfg.feature_flags.enable_effects_v2 = true;
3184 }
3185 }
3186 29 => {
3187 cfg.feature_flags.verify_legacy_zklogin_address = true;
3188 }
3189 30 => {
3190 if chain != Chain::Mainnet {
3192 cfg.feature_flags.narwhal_certificate_v2 = true;
3193 }
3194
3195 cfg.random_beacon_reduction_allowed_delta = Some(800);
3196 if chain != Chain::Mainnet {
3198 cfg.feature_flags.enable_effects_v2 = true;
3199 }
3200
3201 cfg.feature_flags.zklogin_supported_providers = BTreeSet::default();
3205
3206 cfg.feature_flags.recompute_has_public_transfer_in_execution = true;
3207 }
3208 31 => {
3209 cfg.execution_version = Some(2);
3210 if chain != Chain::Mainnet && chain != Chain::Testnet {
3212 cfg.feature_flags.shared_object_deletion = true;
3213 }
3214 }
3215 32 => {
3216 if chain != Chain::Mainnet {
3218 cfg.feature_flags.accept_zklogin_in_multisig = true;
3219 }
3220 if chain != Chain::Mainnet {
3222 cfg.transfer_receive_object_cost_base = Some(52);
3223 cfg.feature_flags.receive_objects = true;
3224 }
3225 if chain != Chain::Mainnet && chain != Chain::Testnet {
3227 cfg.feature_flags.random_beacon = true;
3228 cfg.random_beacon_reduction_lower_bound = Some(1600);
3229 cfg.random_beacon_dkg_timeout_round = Some(3000);
3230 cfg.random_beacon_min_round_interval_ms = Some(150);
3231 }
3232 if chain != Chain::Testnet && chain != Chain::Mainnet {
3234 cfg.feature_flags.include_consensus_digest_in_prologue = true;
3235 }
3236
3237 cfg.feature_flags.narwhal_certificate_v2 = true;
3239 }
3240 33 => {
3241 cfg.feature_flags.hardened_otw_check = true;
3242 cfg.feature_flags.allow_receiving_object_id = true;
3243
3244 cfg.transfer_receive_object_cost_base = Some(52);
3246 cfg.feature_flags.receive_objects = true;
3247
3248 if chain != Chain::Mainnet {
3250 cfg.feature_flags.shared_object_deletion = true;
3251 }
3252
3253 cfg.feature_flags.enable_effects_v2 = true;
3254 }
3255 34 => {}
3256 35 => {
3257 if chain != Chain::Mainnet && chain != Chain::Testnet {
3259 cfg.feature_flags.enable_poseidon = true;
3260 cfg.poseidon_bn254_cost_base = Some(260);
3261 cfg.poseidon_bn254_cost_per_block = Some(10);
3262 }
3263
3264 cfg.feature_flags.enable_coin_deny_list = true;
3265 }
3266 36 => {
3267 if chain != Chain::Mainnet && chain != Chain::Testnet {
3269 cfg.feature_flags.enable_group_ops_native_functions = true;
3270 cfg.feature_flags.enable_group_ops_native_function_msm = true;
3271 cfg.group_ops_bls12381_decode_scalar_cost = Some(52);
3273 cfg.group_ops_bls12381_decode_g1_cost = Some(52);
3274 cfg.group_ops_bls12381_decode_g2_cost = Some(52);
3275 cfg.group_ops_bls12381_decode_gt_cost = Some(52);
3276 cfg.group_ops_bls12381_scalar_add_cost = Some(52);
3277 cfg.group_ops_bls12381_g1_add_cost = Some(52);
3278 cfg.group_ops_bls12381_g2_add_cost = Some(52);
3279 cfg.group_ops_bls12381_gt_add_cost = Some(52);
3280 cfg.group_ops_bls12381_scalar_sub_cost = Some(52);
3281 cfg.group_ops_bls12381_g1_sub_cost = Some(52);
3282 cfg.group_ops_bls12381_g2_sub_cost = Some(52);
3283 cfg.group_ops_bls12381_gt_sub_cost = Some(52);
3284 cfg.group_ops_bls12381_scalar_mul_cost = Some(52);
3285 cfg.group_ops_bls12381_g1_mul_cost = Some(52);
3286 cfg.group_ops_bls12381_g2_mul_cost = Some(52);
3287 cfg.group_ops_bls12381_gt_mul_cost = Some(52);
3288 cfg.group_ops_bls12381_scalar_div_cost = Some(52);
3289 cfg.group_ops_bls12381_g1_div_cost = Some(52);
3290 cfg.group_ops_bls12381_g2_div_cost = Some(52);
3291 cfg.group_ops_bls12381_gt_div_cost = Some(52);
3292 cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(52);
3293 cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(52);
3294 cfg.group_ops_bls12381_g1_hash_to_cost_per_byte = Some(2);
3295 cfg.group_ops_bls12381_g2_hash_to_cost_per_byte = Some(2);
3296 cfg.group_ops_bls12381_g1_msm_base_cost = Some(52);
3297 cfg.group_ops_bls12381_g2_msm_base_cost = Some(52);
3298 cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(52);
3299 cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(52);
3300 cfg.group_ops_bls12381_msm_max_len = Some(32);
3301 cfg.group_ops_bls12381_pairing_cost = Some(52);
3302 }
3303 cfg.feature_flags.shared_object_deletion = true;
3305
3306 cfg.consensus_max_transaction_size_bytes = Some(256 * 1024); cfg.consensus_max_transactions_in_block_bytes = Some(6 * 1_024 * 1024);
3308 }
3310 37 => {
3311 cfg.feature_flags.reject_mutable_random_on_entry_functions = true;
3312
3313 if chain != Chain::Mainnet {
3315 cfg.feature_flags.include_consensus_digest_in_prologue = true;
3316 }
3317 }
3318 38 => {
3319 cfg.binary_module_handles = Some(100);
3320 cfg.binary_struct_handles = Some(300);
3321 cfg.binary_function_handles = Some(1500);
3322 cfg.binary_function_instantiations = Some(750);
3323 cfg.binary_signatures = Some(1000);
3324 cfg.binary_constant_pool = Some(4000);
3328 cfg.binary_identifiers = Some(10000);
3329 cfg.binary_address_identifiers = Some(100);
3330 cfg.binary_struct_defs = Some(200);
3331 cfg.binary_struct_def_instantiations = Some(100);
3332 cfg.binary_function_defs = Some(1000);
3333 cfg.binary_field_handles = Some(500);
3334 cfg.binary_field_instantiations = Some(250);
3335 cfg.binary_friend_decls = Some(100);
3336 cfg.max_package_dependencies = Some(32);
3338 cfg.max_modules_in_publish = Some(64);
3339 cfg.execution_version = Some(3);
3341 }
3342 39 => {
3343 }
3345 40 => {}
3346 41 => {
3347 cfg.feature_flags.enable_group_ops_native_functions = true;
3349 cfg.group_ops_bls12381_decode_scalar_cost = Some(52);
3351 cfg.group_ops_bls12381_decode_g1_cost = Some(52);
3352 cfg.group_ops_bls12381_decode_g2_cost = Some(52);
3353 cfg.group_ops_bls12381_decode_gt_cost = Some(52);
3354 cfg.group_ops_bls12381_scalar_add_cost = Some(52);
3355 cfg.group_ops_bls12381_g1_add_cost = Some(52);
3356 cfg.group_ops_bls12381_g2_add_cost = Some(52);
3357 cfg.group_ops_bls12381_gt_add_cost = Some(52);
3358 cfg.group_ops_bls12381_scalar_sub_cost = Some(52);
3359 cfg.group_ops_bls12381_g1_sub_cost = Some(52);
3360 cfg.group_ops_bls12381_g2_sub_cost = Some(52);
3361 cfg.group_ops_bls12381_gt_sub_cost = Some(52);
3362 cfg.group_ops_bls12381_scalar_mul_cost = Some(52);
3363 cfg.group_ops_bls12381_g1_mul_cost = Some(52);
3364 cfg.group_ops_bls12381_g2_mul_cost = Some(52);
3365 cfg.group_ops_bls12381_gt_mul_cost = Some(52);
3366 cfg.group_ops_bls12381_scalar_div_cost = Some(52);
3367 cfg.group_ops_bls12381_g1_div_cost = Some(52);
3368 cfg.group_ops_bls12381_g2_div_cost = Some(52);
3369 cfg.group_ops_bls12381_gt_div_cost = Some(52);
3370 cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(52);
3371 cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(52);
3372 cfg.group_ops_bls12381_g1_hash_to_cost_per_byte = Some(2);
3373 cfg.group_ops_bls12381_g2_hash_to_cost_per_byte = Some(2);
3374 cfg.group_ops_bls12381_g1_msm_base_cost = Some(52);
3375 cfg.group_ops_bls12381_g2_msm_base_cost = Some(52);
3376 cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(52);
3377 cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(52);
3378 cfg.group_ops_bls12381_msm_max_len = Some(32);
3379 cfg.group_ops_bls12381_pairing_cost = Some(52);
3380 }
3381 42 => {}
3382 43 => {
3383 cfg.feature_flags.zklogin_max_epoch_upper_bound_delta = Some(30);
3384 cfg.max_meter_ticks_per_package = Some(16_000_000);
3385 }
3386 44 => {
3387 cfg.feature_flags.include_consensus_digest_in_prologue = true;
3389 if chain != Chain::Mainnet {
3391 cfg.feature_flags.consensus_choice = ConsensusChoice::SwapEachEpoch;
3392 }
3393 }
3394 45 => {
3395 if chain != Chain::Testnet && chain != Chain::Mainnet {
3397 cfg.feature_flags.consensus_network = ConsensusNetwork::Tonic;
3398 }
3399
3400 if chain != Chain::Mainnet {
3401 cfg.feature_flags.mysticeti_leader_scoring_and_schedule = true;
3403 }
3404 cfg.min_move_binary_format_version = Some(6);
3405 cfg.feature_flags.accept_zklogin_in_multisig = true;
3406
3407 if chain != Chain::Mainnet && chain != Chain::Testnet {
3411 cfg.feature_flags.bridge = true;
3412 }
3413 }
3414 46 => {
3415 if chain != Chain::Mainnet {
3417 cfg.feature_flags.bridge = true;
3418 }
3419
3420 cfg.feature_flags.reshare_at_same_initial_version = true;
3422 }
3423 47 => {}
3424 48 => {
3425 cfg.feature_flags.consensus_network = ConsensusNetwork::Tonic;
3427
3428 cfg.feature_flags.resolve_abort_locations_to_package_id = true;
3430
3431 if chain != Chain::Mainnet {
3433 cfg.feature_flags.random_beacon = true;
3434 cfg.random_beacon_reduction_lower_bound = Some(1600);
3435 cfg.random_beacon_dkg_timeout_round = Some(3000);
3436 cfg.random_beacon_min_round_interval_ms = Some(200);
3437 }
3438
3439 cfg.feature_flags.mysticeti_use_committed_subdag_digest = true;
3441 }
3442 49 => {
3443 if chain != Chain::Testnet && chain != Chain::Mainnet {
3444 cfg.move_binary_format_version = Some(7);
3445 }
3446
3447 if chain != Chain::Mainnet && chain != Chain::Testnet {
3449 cfg.feature_flags.enable_vdf = true;
3450 cfg.vdf_verify_vdf_cost = Some(1500);
3453 cfg.vdf_hash_to_input_cost = Some(100);
3454 }
3455
3456 if chain != Chain::Testnet && chain != Chain::Mainnet {
3458 cfg.feature_flags
3459 .record_consensus_determined_version_assignments_in_prologue = true;
3460 }
3461
3462 if chain != Chain::Mainnet {
3464 cfg.feature_flags.consensus_choice = ConsensusChoice::Mysticeti;
3465 }
3466
3467 cfg.feature_flags.fresh_vm_on_framework_upgrade = true;
3469 }
3470 50 => {
3471 if chain != Chain::Mainnet {
3473 cfg.checkpoint_summary_version_specific_data = Some(1);
3474 cfg.min_checkpoint_interval_ms = Some(200);
3475 }
3476
3477 if chain != Chain::Testnet && chain != Chain::Mainnet {
3479 cfg.feature_flags
3480 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = true;
3481 }
3482
3483 cfg.feature_flags.mysticeti_num_leaders_per_round = Some(1);
3484
3485 cfg.max_deferral_rounds_for_congestion_control = Some(10);
3487 }
3488 51 => {
3489 cfg.random_beacon_dkg_version = Some(1);
3490
3491 if chain != Chain::Testnet && chain != Chain::Mainnet {
3492 cfg.feature_flags.enable_coin_deny_list_v2 = true;
3493 }
3494 }
3495 52 => {
3496 if chain != Chain::Mainnet {
3497 cfg.feature_flags.soft_bundle = true;
3498 cfg.max_soft_bundle_size = Some(5);
3499 }
3500
3501 cfg.config_read_setting_impl_cost_base = Some(100);
3502 cfg.config_read_setting_impl_cost_per_byte = Some(40);
3503
3504 if chain != Chain::Testnet && chain != Chain::Mainnet {
3506 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(100);
3507 cfg.feature_flags.per_object_congestion_control_mode =
3508 PerObjectCongestionControlMode::TotalTxCount;
3509 }
3510
3511 cfg.feature_flags.consensus_choice = ConsensusChoice::Mysticeti;
3513
3514 cfg.feature_flags.mysticeti_leader_scoring_and_schedule = true;
3516
3517 cfg.checkpoint_summary_version_specific_data = Some(1);
3519 cfg.min_checkpoint_interval_ms = Some(200);
3520
3521 if chain != Chain::Mainnet {
3523 cfg.feature_flags
3524 .record_consensus_determined_version_assignments_in_prologue = true;
3525 cfg.feature_flags
3526 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = true;
3527 }
3528 if chain != Chain::Mainnet {
3530 cfg.move_binary_format_version = Some(7);
3531 }
3532
3533 if chain != Chain::Testnet && chain != Chain::Mainnet {
3534 cfg.feature_flags.passkey_auth = true;
3535 }
3536 cfg.feature_flags.enable_coin_deny_list_v2 = true;
3537 }
3538 53 => {
3539 cfg.bridge_should_try_to_finalize_committee = Some(chain != Chain::Mainnet);
3541
3542 cfg.feature_flags
3544 .record_consensus_determined_version_assignments_in_prologue = true;
3545 cfg.feature_flags
3546 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = true;
3547
3548 if chain == Chain::Unknown {
3549 cfg.feature_flags.authority_capabilities_v2 = true;
3550 }
3551
3552 if chain != Chain::Mainnet {
3554 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(100);
3555 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(10);
3556 cfg.feature_flags.per_object_congestion_control_mode =
3557 PerObjectCongestionControlMode::TotalTxCount;
3558 }
3559
3560 cfg.bcs_per_byte_serialized_cost = Some(2);
3562 cfg.bcs_legacy_min_output_size_cost = Some(1);
3563 cfg.bcs_failure_cost = Some(52);
3564 cfg.debug_print_base_cost = Some(52);
3565 cfg.debug_print_stack_trace_base_cost = Some(52);
3566 cfg.hash_sha2_256_base_cost = Some(52);
3567 cfg.hash_sha2_256_per_byte_cost = Some(2);
3568 cfg.hash_sha2_256_legacy_min_input_len_cost = Some(1);
3569 cfg.hash_sha3_256_base_cost = Some(52);
3570 cfg.hash_sha3_256_per_byte_cost = Some(2);
3571 cfg.hash_sha3_256_legacy_min_input_len_cost = Some(1);
3572 cfg.type_name_get_base_cost = Some(52);
3573 cfg.type_name_get_per_byte_cost = Some(2);
3574 cfg.string_check_utf8_base_cost = Some(52);
3575 cfg.string_check_utf8_per_byte_cost = Some(2);
3576 cfg.string_is_char_boundary_base_cost = Some(52);
3577 cfg.string_sub_string_base_cost = Some(52);
3578 cfg.string_sub_string_per_byte_cost = Some(2);
3579 cfg.string_index_of_base_cost = Some(52);
3580 cfg.string_index_of_per_byte_pattern_cost = Some(2);
3581 cfg.string_index_of_per_byte_searched_cost = Some(2);
3582 cfg.vector_empty_base_cost = Some(52);
3583 cfg.vector_length_base_cost = Some(52);
3584 cfg.vector_push_back_base_cost = Some(52);
3585 cfg.vector_push_back_legacy_per_abstract_memory_unit_cost = Some(2);
3586 cfg.vector_borrow_base_cost = Some(52);
3587 cfg.vector_pop_back_base_cost = Some(52);
3588 cfg.vector_destroy_empty_base_cost = Some(52);
3589 cfg.vector_swap_base_cost = Some(52);
3590 }
3591 54 => {
3592 cfg.feature_flags.random_beacon = true;
3594 cfg.random_beacon_reduction_lower_bound = Some(1000);
3595 cfg.random_beacon_dkg_timeout_round = Some(3000);
3596 cfg.random_beacon_min_round_interval_ms = Some(500);
3597
3598 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(100);
3600 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(10);
3601 cfg.feature_flags.per_object_congestion_control_mode =
3602 PerObjectCongestionControlMode::TotalTxCount;
3603
3604 cfg.feature_flags.soft_bundle = true;
3606 cfg.max_soft_bundle_size = Some(5);
3607 }
3608 55 => {
3609 cfg.move_binary_format_version = Some(7);
3611
3612 cfg.consensus_max_transactions_in_block_bytes = Some(512 * 1024);
3614 cfg.consensus_max_num_transactions_in_block = Some(512);
3617
3618 cfg.feature_flags.rethrow_serialization_type_layout_errors = true;
3619 }
3620 56 => {
3621 if chain == Chain::Mainnet {
3622 cfg.feature_flags.bridge = true;
3623 }
3624 }
3625 57 => {
3626 cfg.random_beacon_reduction_lower_bound = Some(800);
3628 }
3629 58 => {
3630 if chain == Chain::Mainnet {
3631 cfg.bridge_should_try_to_finalize_committee = Some(true);
3632 }
3633
3634 if chain != Chain::Mainnet && chain != Chain::Testnet {
3635 cfg.feature_flags
3637 .consensus_distributed_vote_scoring_strategy = true;
3638 }
3639 }
3640 59 => {
3641 cfg.feature_flags.consensus_round_prober = true;
3643 }
3644 60 => {
3645 cfg.max_type_to_layout_nodes = Some(512);
3646 cfg.feature_flags.validate_identifier_inputs = true;
3647 }
3648 61 => {
3649 if chain != Chain::Mainnet {
3650 cfg.feature_flags
3652 .consensus_distributed_vote_scoring_strategy = true;
3653 }
3654 cfg.random_beacon_reduction_lower_bound = Some(700);
3656
3657 if chain != Chain::Mainnet && chain != Chain::Testnet {
3658 cfg.feature_flags.mysticeti_fastpath = true;
3660 }
3661 }
3662 62 => {
3663 cfg.feature_flags.relocate_event_module = true;
3664 }
3665 63 => {
3666 cfg.feature_flags.per_object_congestion_control_mode =
3667 PerObjectCongestionControlMode::TotalGasBudgetWithCap;
3668 cfg.gas_budget_based_txn_cost_cap_factor = Some(400_000);
3669 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(18_500_000);
3670 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(240_000_000);
3671 }
3672 64 => {
3673 cfg.feature_flags.per_object_congestion_control_mode =
3674 PerObjectCongestionControlMode::TotalTxCount;
3675 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(40);
3676 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(3);
3677 }
3678 65 => {
3679 cfg.feature_flags
3681 .consensus_distributed_vote_scoring_strategy = true;
3682 }
3683 66 => {
3684 if chain == Chain::Mainnet {
3685 cfg.feature_flags
3687 .consensus_distributed_vote_scoring_strategy = false;
3688 }
3689 }
3690 67 => {
3691 cfg.feature_flags
3693 .consensus_distributed_vote_scoring_strategy = true;
3694 }
3695 68 => {
3696 cfg.group_ops_bls12381_g1_to_uncompressed_g1_cost = Some(26);
3697 cfg.group_ops_bls12381_uncompressed_g1_to_g1_cost = Some(52);
3698 cfg.group_ops_bls12381_uncompressed_g1_sum_base_cost = Some(26);
3699 cfg.group_ops_bls12381_uncompressed_g1_sum_cost_per_term = Some(13);
3700 cfg.group_ops_bls12381_uncompressed_g1_sum_max_terms = Some(2000);
3701
3702 if chain != Chain::Mainnet && chain != Chain::Testnet {
3703 cfg.feature_flags.uncompressed_g1_group_elements = true;
3704 }
3705
3706 cfg.feature_flags.per_object_congestion_control_mode =
3707 PerObjectCongestionControlMode::TotalGasBudgetWithCap;
3708 cfg.gas_budget_based_txn_cost_cap_factor = Some(400_000);
3709 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(18_500_000);
3710 cfg.max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit =
3711 Some(3_700_000); cfg.max_txn_cost_overage_per_object_in_commit = Some(u64::MAX);
3713 cfg.gas_budget_based_txn_cost_absolute_cap_commit_count = Some(50);
3714
3715 cfg.random_beacon_reduction_lower_bound = Some(500);
3717
3718 cfg.feature_flags.disallow_new_modules_in_deps_only_packages = true;
3719 }
3720 69 => {
3721 cfg.consensus_voting_rounds = Some(40);
3723
3724 if chain != Chain::Mainnet && chain != Chain::Testnet {
3725 cfg.feature_flags.consensus_smart_ancestor_selection = true;
3727 }
3728
3729 if chain != Chain::Mainnet {
3730 cfg.feature_flags.uncompressed_g1_group_elements = true;
3731 }
3732 }
3733 70 => {
3734 if chain != Chain::Mainnet {
3735 cfg.feature_flags.consensus_smart_ancestor_selection = true;
3737 cfg.feature_flags
3739 .consensus_round_prober_probe_accepted_rounds = true;
3740 }
3741
3742 cfg.poseidon_bn254_cost_per_block = Some(388);
3743
3744 cfg.gas_model_version = Some(9);
3745 cfg.feature_flags.native_charging_v2 = true;
3746 cfg.bls12381_bls12381_min_sig_verify_cost_base = Some(44064);
3747 cfg.bls12381_bls12381_min_pk_verify_cost_base = Some(49282);
3748 cfg.ecdsa_k1_secp256k1_verify_keccak256_cost_base = Some(1470);
3749 cfg.ecdsa_k1_secp256k1_verify_sha256_cost_base = Some(1470);
3750 cfg.ecdsa_r1_secp256r1_verify_sha256_cost_base = Some(4225);
3751 cfg.ecdsa_r1_secp256r1_verify_keccak256_cost_base = Some(4225);
3752 cfg.ecvrf_ecvrf_verify_cost_base = Some(4848);
3753 cfg.ed25519_ed25519_verify_cost_base = Some(1802);
3754
3755 cfg.ecdsa_r1_ecrecover_keccak256_cost_base = Some(1173);
3757 cfg.ecdsa_r1_ecrecover_sha256_cost_base = Some(1173);
3758 cfg.ecdsa_k1_ecrecover_keccak256_cost_base = Some(500);
3759 cfg.ecdsa_k1_ecrecover_sha256_cost_base = Some(500);
3760
3761 cfg.groth16_prepare_verifying_key_bls12381_cost_base = Some(53838);
3762 cfg.groth16_prepare_verifying_key_bn254_cost_base = Some(82010);
3763 cfg.groth16_verify_groth16_proof_internal_bls12381_cost_base = Some(72090);
3764 cfg.groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input =
3765 Some(8213);
3766 cfg.groth16_verify_groth16_proof_internal_bn254_cost_base = Some(115502);
3767 cfg.groth16_verify_groth16_proof_internal_bn254_cost_per_public_input =
3768 Some(9484);
3769
3770 cfg.hash_keccak256_cost_base = Some(10);
3771 cfg.hash_blake2b256_cost_base = Some(10);
3772
3773 cfg.group_ops_bls12381_decode_scalar_cost = Some(7);
3775 cfg.group_ops_bls12381_decode_g1_cost = Some(2848);
3776 cfg.group_ops_bls12381_decode_g2_cost = Some(3770);
3777 cfg.group_ops_bls12381_decode_gt_cost = Some(3068);
3778
3779 cfg.group_ops_bls12381_scalar_add_cost = Some(10);
3780 cfg.group_ops_bls12381_g1_add_cost = Some(1556);
3781 cfg.group_ops_bls12381_g2_add_cost = Some(3048);
3782 cfg.group_ops_bls12381_gt_add_cost = Some(188);
3783
3784 cfg.group_ops_bls12381_scalar_sub_cost = Some(10);
3785 cfg.group_ops_bls12381_g1_sub_cost = Some(1550);
3786 cfg.group_ops_bls12381_g2_sub_cost = Some(3019);
3787 cfg.group_ops_bls12381_gt_sub_cost = Some(497);
3788
3789 cfg.group_ops_bls12381_scalar_mul_cost = Some(11);
3790 cfg.group_ops_bls12381_g1_mul_cost = Some(4842);
3791 cfg.group_ops_bls12381_g2_mul_cost = Some(9108);
3792 cfg.group_ops_bls12381_gt_mul_cost = Some(27490);
3793
3794 cfg.group_ops_bls12381_scalar_div_cost = Some(91);
3795 cfg.group_ops_bls12381_g1_div_cost = Some(5091);
3796 cfg.group_ops_bls12381_g2_div_cost = Some(9206);
3797 cfg.group_ops_bls12381_gt_div_cost = Some(27804);
3798
3799 cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(2962);
3800 cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(8688);
3801
3802 cfg.group_ops_bls12381_g1_msm_base_cost = Some(62648);
3803 cfg.group_ops_bls12381_g2_msm_base_cost = Some(131192);
3804 cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(1333);
3805 cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(3216);
3806
3807 cfg.group_ops_bls12381_uncompressed_g1_to_g1_cost = Some(677);
3808 cfg.group_ops_bls12381_g1_to_uncompressed_g1_cost = Some(2099);
3809 cfg.group_ops_bls12381_uncompressed_g1_sum_base_cost = Some(77);
3810 cfg.group_ops_bls12381_uncompressed_g1_sum_cost_per_term = Some(26);
3811
3812 cfg.group_ops_bls12381_pairing_cost = Some(26897);
3813 cfg.group_ops_bls12381_uncompressed_g1_sum_max_terms = Some(1200);
3814
3815 cfg.validator_validate_metadata_cost_base = Some(20000);
3816 }
3817 71 => {
3818 cfg.sip_45_consensus_amplification_threshold = Some(5);
3819
3820 cfg.allowed_txn_cost_overage_burst_per_object_in_commit = Some(185_000_000);
3822 }
3823 72 => {
3824 cfg.feature_flags.convert_type_argument_error = true;
3825
3826 cfg.max_tx_gas = Some(50_000_000_000_000);
3829 cfg.max_gas_price = Some(50_000_000_000);
3831
3832 cfg.feature_flags.variant_nodes = true;
3833 }
3834 73 => {
3835 cfg.use_object_per_epoch_marker_table_v2 = Some(true);
3837
3838 if chain != Chain::Mainnet && chain != Chain::Testnet {
3839 cfg.consensus_gc_depth = Some(60);
3842 }
3843
3844 if chain != Chain::Mainnet {
3845 cfg.feature_flags.consensus_zstd_compression = true;
3847 }
3848
3849 cfg.feature_flags.consensus_smart_ancestor_selection = true;
3851 cfg.feature_flags
3853 .consensus_round_prober_probe_accepted_rounds = true;
3854
3855 cfg.feature_flags.per_object_congestion_control_mode =
3857 PerObjectCongestionControlMode::TotalGasBudgetWithCap;
3858 cfg.gas_budget_based_txn_cost_cap_factor = Some(400_000);
3859 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(37_000_000);
3860 cfg.max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit =
3861 Some(7_400_000); cfg.max_txn_cost_overage_per_object_in_commit = Some(u64::MAX);
3863 cfg.gas_budget_based_txn_cost_absolute_cap_commit_count = Some(50);
3864 cfg.allowed_txn_cost_overage_burst_per_object_in_commit = Some(370_000_000);
3865 }
3866 74 => {
3867 if chain != Chain::Mainnet && chain != Chain::Testnet {
3869 cfg.feature_flags.enable_nitro_attestation = true;
3870 }
3871 cfg.nitro_attestation_parse_base_cost = Some(53 * 50);
3872 cfg.nitro_attestation_parse_cost_per_byte = Some(50);
3873 cfg.nitro_attestation_verify_base_cost = Some(49632 * 50);
3874 cfg.nitro_attestation_verify_cost_per_cert = Some(52369 * 50);
3875
3876 cfg.feature_flags.consensus_zstd_compression = true;
3878
3879 if chain != Chain::Mainnet && chain != Chain::Testnet {
3880 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
3881 }
3882 }
3883 75 => {
3884 if chain != Chain::Mainnet {
3885 cfg.feature_flags.passkey_auth = true;
3886 }
3887 }
3888 76 => {
3889 if chain != Chain::Mainnet && chain != Chain::Testnet {
3890 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
3891 cfg.consensus_commit_rate_estimation_window_size = Some(10);
3892 }
3893 cfg.feature_flags.minimize_child_object_mutations = true;
3894
3895 if chain != Chain::Mainnet {
3896 cfg.feature_flags.accept_passkey_in_multisig = true;
3897 }
3898 }
3899 77 => {
3900 cfg.feature_flags.uncompressed_g1_group_elements = true;
3901
3902 if chain != Chain::Mainnet {
3903 cfg.consensus_gc_depth = Some(60);
3904 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
3905 }
3906 }
3907 78 => {
3908 cfg.feature_flags.move_native_context = true;
3909 cfg.tx_context_fresh_id_cost_base = Some(52);
3910 cfg.tx_context_sender_cost_base = Some(30);
3911 cfg.tx_context_epoch_cost_base = Some(30);
3912 cfg.tx_context_epoch_timestamp_ms_cost_base = Some(30);
3913 cfg.tx_context_sponsor_cost_base = Some(30);
3914 cfg.tx_context_gas_price_cost_base = Some(30);
3915 cfg.tx_context_gas_budget_cost_base = Some(30);
3916 cfg.tx_context_ids_created_cost_base = Some(30);
3917 cfg.tx_context_replace_cost_base = Some(30);
3918 cfg.gas_model_version = Some(10);
3919
3920 if chain != Chain::Mainnet {
3921 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
3922 cfg.consensus_commit_rate_estimation_window_size = Some(10);
3923
3924 cfg.feature_flags.per_object_congestion_control_mode =
3926 PerObjectCongestionControlMode::ExecutionTimeEstimate(
3927 ExecutionTimeEstimateParams {
3928 target_utilization: 30,
3929 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
3931 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
3933 stored_observations_limit: u64::MAX,
3934 stake_weighted_median_threshold: 0,
3935 default_none_duration_for_new_keys: false,
3936 observations_chunk_size: None,
3937 },
3938 );
3939 }
3940 }
3941 79 => {
3942 if chain != Chain::Mainnet {
3943 cfg.feature_flags.consensus_median_based_commit_timestamp = true;
3944
3945 cfg.consensus_bad_nodes_stake_threshold = Some(30);
3948
3949 cfg.feature_flags.consensus_batched_block_sync = true;
3950
3951 cfg.feature_flags.enable_nitro_attestation = true
3953 }
3954 cfg.feature_flags.normalize_ptb_arguments = true;
3955
3956 cfg.consensus_gc_depth = Some(60);
3957 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
3958 }
3959 80 => {
3960 cfg.max_ptb_value_size = Some(1024 * 1024);
3961 }
3962 81 => {
3963 cfg.feature_flags.consensus_median_based_commit_timestamp = true;
3964 cfg.feature_flags.enforce_checkpoint_timestamp_monotonicity = true;
3965 cfg.consensus_bad_nodes_stake_threshold = Some(30)
3966 }
3967 82 => {
3968 cfg.feature_flags.max_ptb_value_size_v2 = true;
3969 }
3970 83 => {
3971 if chain == Chain::Mainnet {
3972 let aliased: [u8; 32] = Hex::decode(
3974 "0x0b2da327ba6a4cacbe75dddd50e6e8bbf81d6496e92d66af9154c61c77f7332f",
3975 )
3976 .unwrap()
3977 .try_into()
3978 .unwrap();
3979
3980 cfg.aliased_addresses.push(AliasedAddress {
3982 original: Hex::decode("0xcd8962dad278d8b50fa0f9eb0186bfa4cbdecc6d59377214c88d0286a0ac9562").unwrap().try_into().unwrap(),
3983 aliased,
3984 allowed_tx_digests: vec![
3985 Base58::decode("B2eGLFoMHgj93Ni8dAJBfqGzo8EWSTLBesZzhEpTPA4").unwrap().try_into().unwrap(),
3986 ],
3987 });
3988
3989 cfg.aliased_addresses.push(AliasedAddress {
3990 original: Hex::decode("0xe28b50cef1d633ea43d3296a3f6b67ff0312a5f1a99f0af753c85b8b5de8ff06").unwrap().try_into().unwrap(),
3991 aliased,
3992 allowed_tx_digests: vec![
3993 Base58::decode("J4QqSAgp7VrQtQpMy5wDX4QGsCSEZu3U5KuDAkbESAge").unwrap().try_into().unwrap(),
3994 ],
3995 });
3996 }
3997
3998 if chain != Chain::Mainnet {
4001 cfg.feature_flags.resolve_type_input_ids_to_defining_id = true;
4002 cfg.transfer_party_transfer_internal_cost_base = Some(52);
4003
4004 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
4006 cfg.consensus_commit_rate_estimation_window_size = Some(10);
4007 cfg.feature_flags.per_object_congestion_control_mode =
4008 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4009 ExecutionTimeEstimateParams {
4010 target_utilization: 30,
4011 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4013 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4015 stored_observations_limit: u64::MAX,
4016 stake_weighted_median_threshold: 0,
4017 default_none_duration_for_new_keys: false,
4018 observations_chunk_size: None,
4019 },
4020 );
4021
4022 cfg.feature_flags.consensus_batched_block_sync = true;
4024
4025 cfg.feature_flags.enable_nitro_attestation_upgraded_parsing = true;
4028 cfg.feature_flags.enable_nitro_attestation = true;
4029 }
4030 }
4031 84 => {
4032 if chain == Chain::Mainnet {
4033 cfg.feature_flags.resolve_type_input_ids_to_defining_id = true;
4034 cfg.transfer_party_transfer_internal_cost_base = Some(52);
4035
4036 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
4038 cfg.consensus_commit_rate_estimation_window_size = Some(10);
4039 cfg.feature_flags.per_object_congestion_control_mode =
4040 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4041 ExecutionTimeEstimateParams {
4042 target_utilization: 30,
4043 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4045 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4047 stored_observations_limit: u64::MAX,
4048 stake_weighted_median_threshold: 0,
4049 default_none_duration_for_new_keys: false,
4050 observations_chunk_size: None,
4051 },
4052 );
4053
4054 cfg.feature_flags.consensus_batched_block_sync = true;
4056
4057 cfg.feature_flags.enable_nitro_attestation_upgraded_parsing = true;
4060 cfg.feature_flags.enable_nitro_attestation = true;
4061 }
4062
4063 cfg.feature_flags.per_object_congestion_control_mode =
4065 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4066 ExecutionTimeEstimateParams {
4067 target_utilization: 30,
4068 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4070 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4072 stored_observations_limit: 20,
4073 stake_weighted_median_threshold: 0,
4074 default_none_duration_for_new_keys: false,
4075 observations_chunk_size: None,
4076 },
4077 );
4078 cfg.feature_flags.allow_unbounded_system_objects = true;
4079 }
4080 85 => {
4081 if chain != Chain::Mainnet && chain != Chain::Testnet {
4082 cfg.feature_flags.enable_party_transfer = true;
4083 }
4084
4085 cfg.feature_flags
4086 .record_consensus_determined_version_assignments_in_prologue_v2 = true;
4087 cfg.feature_flags.disallow_self_identifier = true;
4088 cfg.feature_flags.per_object_congestion_control_mode =
4089 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4090 ExecutionTimeEstimateParams {
4091 target_utilization: 50,
4092 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4094 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4096 stored_observations_limit: 20,
4097 stake_weighted_median_threshold: 0,
4098 default_none_duration_for_new_keys: false,
4099 observations_chunk_size: None,
4100 },
4101 );
4102 }
4103 86 => {
4104 cfg.feature_flags.type_tags_in_object_runtime = true;
4105 cfg.max_move_enum_variants = Some(move_core_types::VARIANT_COUNT_MAX);
4106
4107 cfg.feature_flags.per_object_congestion_control_mode =
4109 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4110 ExecutionTimeEstimateParams {
4111 target_utilization: 50,
4112 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4114 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4116 stored_observations_limit: 20,
4117 stake_weighted_median_threshold: 3334,
4118 default_none_duration_for_new_keys: false,
4119 observations_chunk_size: None,
4120 },
4121 );
4122 if chain != Chain::Mainnet {
4124 cfg.feature_flags.enable_party_transfer = true;
4125 }
4126 }
4127 87 => {
4128 if chain == Chain::Mainnet {
4129 cfg.feature_flags.record_time_estimate_processed = true;
4130 }
4131 cfg.feature_flags.better_adapter_type_resolution_errors = true;
4132 }
4133 88 => {
4134 cfg.feature_flags.record_time_estimate_processed = true;
4135 cfg.tx_context_rgp_cost_base = Some(30);
4136 cfg.feature_flags
4137 .ignore_execution_time_observations_after_certs_closed = true;
4138
4139 cfg.feature_flags.per_object_congestion_control_mode =
4142 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4143 ExecutionTimeEstimateParams {
4144 target_utilization: 50,
4145 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4147 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4149 stored_observations_limit: 20,
4150 stake_weighted_median_threshold: 3334,
4151 default_none_duration_for_new_keys: true,
4152 observations_chunk_size: None,
4153 },
4154 );
4155 }
4156 89 => {
4157 cfg.feature_flags.dependency_linkage_error = true;
4158 cfg.feature_flags.additional_multisig_checks = true;
4159 }
4160 90 => {
4161 cfg.max_gas_price_rgp_factor_for_aborted_transactions = Some(100);
4163 cfg.feature_flags.debug_fatal_on_move_invariant_violation = true;
4164 cfg.feature_flags.additional_consensus_digest_indirect_state = true;
4165 cfg.feature_flags.accept_passkey_in_multisig = true;
4166 cfg.feature_flags.passkey_auth = true;
4167 cfg.feature_flags.check_for_init_during_upgrade = true;
4168
4169 if chain != Chain::Mainnet {
4171 cfg.feature_flags.mysticeti_fastpath = true;
4172 }
4173 }
4174 91 => {
4175 cfg.feature_flags.per_command_shared_object_transfer_rules = true;
4176 }
4177 92 => {
4178 cfg.feature_flags.per_command_shared_object_transfer_rules = false;
4179 }
4180 93 => {
4181 cfg.feature_flags
4182 .consensus_checkpoint_signature_key_includes_digest = true;
4183 }
4184 94 => {
4185 cfg.feature_flags.per_object_congestion_control_mode =
4187 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4188 ExecutionTimeEstimateParams {
4189 target_utilization: 50,
4190 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4192 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4194 stored_observations_limit: 18,
4195 stake_weighted_median_threshold: 3334,
4196 default_none_duration_for_new_keys: true,
4197 observations_chunk_size: None,
4198 },
4199 );
4200
4201 cfg.feature_flags.enable_party_transfer = true;
4203 }
4204 95 => {
4205 cfg.type_name_id_base_cost = Some(52);
4206
4207 cfg.max_transactions_per_checkpoint = Some(20_000);
4209 }
4210 96 => {
4211 if chain != Chain::Mainnet && chain != Chain::Testnet {
4213 cfg.feature_flags
4214 .include_checkpoint_artifacts_digest_in_summary = true;
4215 }
4216 cfg.feature_flags.correct_gas_payment_limit_check = true;
4217 cfg.feature_flags.authority_capabilities_v2 = true;
4218 cfg.feature_flags.use_mfp_txns_in_load_initial_object_debts = true;
4219 cfg.feature_flags.cancel_for_failed_dkg_early = true;
4220 cfg.feature_flags.enable_coin_registry = true;
4221
4222 cfg.feature_flags.mysticeti_fastpath = true;
4224 }
4225 97 => {
4226 cfg.feature_flags.additional_borrow_checks = true;
4227 }
4228 98 => {
4229 cfg.event_emit_auth_stream_cost = Some(52);
4230 cfg.feature_flags.better_loader_errors = true;
4231 cfg.feature_flags.generate_df_type_layouts = true;
4232 }
4233 99 => {
4234 cfg.feature_flags.use_new_commit_handler = true;
4235 }
4236 100 => {
4237 cfg.feature_flags.private_generics_verifier_v2 = true;
4238 }
4239 101 => {
4240 cfg.feature_flags.create_root_accumulator_object = true;
4241 cfg.max_updates_per_settlement_txn = Some(100);
4242 if chain != Chain::Mainnet {
4243 cfg.feature_flags.enable_poseidon = true;
4244 }
4245 }
4246 102 => {
4247 cfg.feature_flags.per_object_congestion_control_mode =
4251 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4252 ExecutionTimeEstimateParams {
4253 target_utilization: 50,
4254 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4256 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4258 stored_observations_limit: 180,
4259 stake_weighted_median_threshold: 3334,
4260 default_none_duration_for_new_keys: true,
4261 observations_chunk_size: Some(18),
4262 },
4263 );
4264 cfg.feature_flags.deprecate_global_storage_ops = true;
4265 }
4266 103 => {}
4267 104 => {
4268 cfg.translation_per_command_base_charge = Some(1);
4269 cfg.translation_per_input_base_charge = Some(1);
4270 cfg.translation_pure_input_per_byte_charge = Some(1);
4271 cfg.translation_per_type_node_charge = Some(1);
4272 cfg.translation_per_reference_node_charge = Some(1);
4273 cfg.translation_per_linkage_entry_charge = Some(10);
4274 cfg.gas_model_version = Some(11);
4275 cfg.feature_flags.abstract_size_in_object_runtime = true;
4276 cfg.feature_flags.object_runtime_charge_cache_load_gas = true;
4277 cfg.dynamic_field_hash_type_and_key_cost_base = Some(52);
4278 cfg.dynamic_field_add_child_object_cost_base = Some(52);
4279 cfg.dynamic_field_add_child_object_value_cost_per_byte = Some(1);
4280 cfg.dynamic_field_borrow_child_object_cost_base = Some(52);
4281 cfg.dynamic_field_borrow_child_object_child_ref_cost_per_byte = Some(1);
4282 cfg.dynamic_field_remove_child_object_cost_base = Some(52);
4283 cfg.dynamic_field_remove_child_object_child_cost_per_byte = Some(1);
4284 cfg.dynamic_field_has_child_object_cost_base = Some(52);
4285 cfg.dynamic_field_has_child_object_with_ty_cost_base = Some(52);
4286 cfg.feature_flags.enable_ptb_execution_v2 = true;
4287
4288 cfg.poseidon_bn254_cost_base = Some(260);
4289
4290 cfg.feature_flags.consensus_skip_gced_accept_votes = true;
4291 if chain != Chain::Mainnet {
4292 cfg.feature_flags
4293 .enable_nitro_attestation_all_nonzero_pcrs_parsing = true;
4294 }
4295 }
4296 _ => panic!("unsupported version {:?}", version),
4307 }
4308 }
4309
4310 if cfg!(msim) {
4312 cfg.consensus_gc_depth = Some(5);
4314
4315 }
4320
4321 cfg
4322 }
4323
4324 pub fn verifier_config(&self, signing_limits: Option<(usize, usize, usize)>) -> VerifierConfig {
4330 let (
4331 max_back_edges_per_function,
4332 max_back_edges_per_module,
4333 sanity_check_with_regex_reference_safety,
4334 ) = if let Some((
4335 max_back_edges_per_function,
4336 max_back_edges_per_module,
4337 sanity_check_with_regex_reference_safety,
4338 )) = signing_limits
4339 {
4340 (
4341 Some(max_back_edges_per_function),
4342 Some(max_back_edges_per_module),
4343 Some(sanity_check_with_regex_reference_safety),
4344 )
4345 } else {
4346 (None, None, None)
4347 };
4348
4349 let additional_borrow_checks = if signing_limits.is_some() {
4350 true
4352 } else {
4353 self.additional_borrow_checks()
4354 };
4355 let deprecate_global_storage_ops = if signing_limits.is_some() {
4356 true
4358 } else {
4359 self.deprecate_global_storage_ops()
4360 };
4361
4362 VerifierConfig {
4363 max_loop_depth: Some(self.max_loop_depth() as usize),
4364 max_generic_instantiation_length: Some(self.max_generic_instantiation_length() as usize),
4365 max_function_parameters: Some(self.max_function_parameters() as usize),
4366 max_basic_blocks: Some(self.max_basic_blocks() as usize),
4367 max_value_stack_size: self.max_value_stack_size() as usize,
4368 max_type_nodes: Some(self.max_type_nodes() as usize),
4369 max_push_size: Some(self.max_push_size() as usize),
4370 max_dependency_depth: Some(self.max_dependency_depth() as usize),
4371 max_fields_in_struct: Some(self.max_fields_in_struct() as usize),
4372 max_function_definitions: Some(self.max_function_definitions() as usize),
4373 max_data_definitions: Some(self.max_struct_definitions() as usize),
4374 max_constant_vector_len: Some(self.max_move_vector_len()),
4375 max_back_edges_per_function,
4376 max_back_edges_per_module,
4377 max_basic_blocks_in_script: None,
4378 max_identifier_len: self.max_move_identifier_len_as_option(), disallow_self_identifier: self.feature_flags.disallow_self_identifier,
4380 allow_receiving_object_id: self.allow_receiving_object_id(),
4381 reject_mutable_random_on_entry_functions: self
4382 .reject_mutable_random_on_entry_functions(),
4383 bytecode_version: self.move_binary_format_version(),
4384 max_variants_in_enum: self.max_move_enum_variants_as_option(),
4385 additional_borrow_checks,
4386 better_loader_errors: self.better_loader_errors(),
4387 private_generics_verifier_v2: self.private_generics_verifier_v2(),
4388 sanity_check_with_regex_reference_safety: sanity_check_with_regex_reference_safety
4389 .map(|limit| limit as u128),
4390 deprecate_global_storage_ops,
4391 }
4392 }
4393
4394 pub fn binary_config(
4395 &self,
4396 override_deprecate_global_storage_ops_during_deserialization: Option<bool>,
4397 ) -> BinaryConfig {
4398 let deprecate_global_storage_ops =
4399 override_deprecate_global_storage_ops_during_deserialization
4400 .unwrap_or_else(|| self.deprecate_global_storage_ops());
4401 BinaryConfig::new(
4402 self.move_binary_format_version(),
4403 self.min_move_binary_format_version_as_option()
4404 .unwrap_or(VERSION_1),
4405 self.no_extraneous_module_bytes(),
4406 deprecate_global_storage_ops,
4407 TableConfig {
4408 module_handles: self.binary_module_handles_as_option().unwrap_or(u16::MAX),
4409 datatype_handles: self.binary_struct_handles_as_option().unwrap_or(u16::MAX),
4410 function_handles: self.binary_function_handles_as_option().unwrap_or(u16::MAX),
4411 function_instantiations: self
4412 .binary_function_instantiations_as_option()
4413 .unwrap_or(u16::MAX),
4414 signatures: self.binary_signatures_as_option().unwrap_or(u16::MAX),
4415 constant_pool: self.binary_constant_pool_as_option().unwrap_or(u16::MAX),
4416 identifiers: self.binary_identifiers_as_option().unwrap_or(u16::MAX),
4417 address_identifiers: self
4418 .binary_address_identifiers_as_option()
4419 .unwrap_or(u16::MAX),
4420 struct_defs: self.binary_struct_defs_as_option().unwrap_or(u16::MAX),
4421 struct_def_instantiations: self
4422 .binary_struct_def_instantiations_as_option()
4423 .unwrap_or(u16::MAX),
4424 function_defs: self.binary_function_defs_as_option().unwrap_or(u16::MAX),
4425 field_handles: self.binary_field_handles_as_option().unwrap_or(u16::MAX),
4426 field_instantiations: self
4427 .binary_field_instantiations_as_option()
4428 .unwrap_or(u16::MAX),
4429 friend_decls: self.binary_friend_decls_as_option().unwrap_or(u16::MAX),
4430 enum_defs: self.binary_enum_defs_as_option().unwrap_or(u16::MAX),
4431 enum_def_instantiations: self
4432 .binary_enum_def_instantiations_as_option()
4433 .unwrap_or(u16::MAX),
4434 variant_handles: self.binary_variant_handles_as_option().unwrap_or(u16::MAX),
4435 variant_instantiation_handles: self
4436 .binary_variant_instantiation_handles_as_option()
4437 .unwrap_or(u16::MAX),
4438 },
4439 )
4440 }
4441
4442 pub fn apply_overrides_for_testing(
4446 override_fn: impl Fn(ProtocolVersion, Self) -> Self + Send + 'static,
4447 ) -> OverrideGuard {
4448 CONFIG_OVERRIDE.with(|ovr| {
4449 let mut cur = ovr.borrow_mut();
4450 assert!(cur.is_none(), "config override already present");
4451 *cur = Some(Box::new(override_fn));
4452 OverrideGuard
4453 })
4454 }
4455}
4456
4457impl ProtocolConfig {
4461 pub fn set_advance_to_highest_supported_protocol_version_for_testing(&mut self, val: bool) {
4462 self.feature_flags
4463 .advance_to_highest_supported_protocol_version = val
4464 }
4465 pub fn set_commit_root_state_digest_supported_for_testing(&mut self, val: bool) {
4466 self.feature_flags.commit_root_state_digest = val
4467 }
4468 pub fn set_zklogin_auth_for_testing(&mut self, val: bool) {
4469 self.feature_flags.zklogin_auth = val
4470 }
4471 pub fn set_enable_jwk_consensus_updates_for_testing(&mut self, val: bool) {
4472 self.feature_flags.enable_jwk_consensus_updates = val
4473 }
4474 pub fn set_random_beacon_for_testing(&mut self, val: bool) {
4475 self.feature_flags.random_beacon = val
4476 }
4477
4478 pub fn set_upgraded_multisig_for_testing(&mut self, val: bool) {
4479 self.feature_flags.upgraded_multisig_supported = val
4480 }
4481 pub fn set_accept_zklogin_in_multisig_for_testing(&mut self, val: bool) {
4482 self.feature_flags.accept_zklogin_in_multisig = val
4483 }
4484
4485 pub fn set_shared_object_deletion_for_testing(&mut self, val: bool) {
4486 self.feature_flags.shared_object_deletion = val;
4487 }
4488
4489 pub fn set_narwhal_new_leader_election_schedule_for_testing(&mut self, val: bool) {
4490 self.feature_flags.narwhal_new_leader_election_schedule = val;
4491 }
4492
4493 pub fn set_receive_object_for_testing(&mut self, val: bool) {
4494 self.feature_flags.receive_objects = val
4495 }
4496 pub fn set_narwhal_certificate_v2_for_testing(&mut self, val: bool) {
4497 self.feature_flags.narwhal_certificate_v2 = val
4498 }
4499 pub fn set_verify_legacy_zklogin_address_for_testing(&mut self, val: bool) {
4500 self.feature_flags.verify_legacy_zklogin_address = val
4501 }
4502
4503 pub fn set_per_object_congestion_control_mode_for_testing(
4504 &mut self,
4505 val: PerObjectCongestionControlMode,
4506 ) {
4507 self.feature_flags.per_object_congestion_control_mode = val;
4508 }
4509
4510 pub fn set_consensus_choice_for_testing(&mut self, val: ConsensusChoice) {
4511 self.feature_flags.consensus_choice = val;
4512 }
4513
4514 pub fn set_consensus_network_for_testing(&mut self, val: ConsensusNetwork) {
4515 self.feature_flags.consensus_network = val;
4516 }
4517
4518 pub fn set_zklogin_max_epoch_upper_bound_delta_for_testing(&mut self, val: Option<u64>) {
4519 self.feature_flags.zklogin_max_epoch_upper_bound_delta = val
4520 }
4521
4522 pub fn set_disable_bridge_for_testing(&mut self) {
4523 self.feature_flags.bridge = false
4524 }
4525
4526 pub fn set_mysticeti_num_leaders_per_round_for_testing(&mut self, val: Option<usize>) {
4527 self.feature_flags.mysticeti_num_leaders_per_round = val;
4528 }
4529
4530 pub fn set_enable_soft_bundle_for_testing(&mut self, val: bool) {
4531 self.feature_flags.soft_bundle = val;
4532 }
4533
4534 pub fn set_passkey_auth_for_testing(&mut self, val: bool) {
4535 self.feature_flags.passkey_auth = val
4536 }
4537
4538 pub fn set_enable_party_transfer_for_testing(&mut self, val: bool) {
4539 self.feature_flags.enable_party_transfer = val
4540 }
4541
4542 pub fn set_consensus_distributed_vote_scoring_strategy_for_testing(&mut self, val: bool) {
4543 self.feature_flags
4544 .consensus_distributed_vote_scoring_strategy = val;
4545 }
4546
4547 pub fn set_consensus_round_prober_for_testing(&mut self, val: bool) {
4548 self.feature_flags.consensus_round_prober = val;
4549 }
4550
4551 pub fn set_disallow_new_modules_in_deps_only_packages_for_testing(&mut self, val: bool) {
4552 self.feature_flags
4553 .disallow_new_modules_in_deps_only_packages = val;
4554 }
4555
4556 pub fn set_correct_gas_payment_limit_check_for_testing(&mut self, val: bool) {
4557 self.feature_flags.correct_gas_payment_limit_check = val;
4558 }
4559
4560 pub fn set_consensus_round_prober_probe_accepted_rounds(&mut self, val: bool) {
4561 self.feature_flags
4562 .consensus_round_prober_probe_accepted_rounds = val;
4563 }
4564
4565 pub fn set_mysticeti_fastpath_for_testing(&mut self, val: bool) {
4566 self.feature_flags.mysticeti_fastpath = val;
4567 }
4568
4569 pub fn set_accept_passkey_in_multisig_for_testing(&mut self, val: bool) {
4570 self.feature_flags.accept_passkey_in_multisig = val;
4571 }
4572
4573 pub fn set_consensus_batched_block_sync_for_testing(&mut self, val: bool) {
4574 self.feature_flags.consensus_batched_block_sync = val;
4575 }
4576
4577 pub fn set_record_time_estimate_processed_for_testing(&mut self, val: bool) {
4578 self.feature_flags.record_time_estimate_processed = val;
4579 }
4580
4581 pub fn set_prepend_prologue_tx_in_consensus_commit_in_checkpoints_for_testing(
4582 &mut self,
4583 val: bool,
4584 ) {
4585 self.feature_flags
4586 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = val;
4587 }
4588
4589 pub fn enable_accumulators_for_testing(&mut self) {
4590 self.feature_flags.enable_accumulators = true;
4591 }
4592
4593 pub fn create_root_accumulator_object_for_testing(&mut self) {
4594 self.feature_flags.create_root_accumulator_object = true;
4595 }
4596
4597 pub fn enable_address_balance_gas_payments_for_testing(&mut self) {
4598 self.feature_flags.enable_accumulators = true;
4599 self.feature_flags.allow_private_accumulator_entrypoints = true;
4600 self.feature_flags.enable_address_balance_gas_payments = true;
4601 }
4602
4603 pub fn enable_authenticated_event_streams_for_testing(&mut self) {
4604 self.enable_accumulators_for_testing();
4605 self.feature_flags.enable_authenticated_event_streams = true;
4606 self.feature_flags
4607 .include_checkpoint_artifacts_digest_in_summary = true;
4608 }
4609
4610 pub fn enable_non_exclusive_writes_for_testing(&mut self) {
4611 self.feature_flags.enable_non_exclusive_writes = true;
4612 }
4613
4614 pub fn set_ignore_execution_time_observations_after_certs_closed_for_testing(
4615 &mut self,
4616 val: bool,
4617 ) {
4618 self.feature_flags
4619 .ignore_execution_time_observations_after_certs_closed = val;
4620 }
4621
4622 pub fn set_consensus_checkpoint_signature_key_includes_digest_for_testing(
4623 &mut self,
4624 val: bool,
4625 ) {
4626 self.feature_flags
4627 .consensus_checkpoint_signature_key_includes_digest = val;
4628 }
4629
4630 pub fn set_cancel_for_failed_dkg_early_for_testing(&mut self, val: bool) {
4631 self.feature_flags.cancel_for_failed_dkg_early = val;
4632 }
4633
4634 pub fn set_use_mfp_txns_in_load_initial_object_debts_for_testing(&mut self, val: bool) {
4635 self.feature_flags.use_mfp_txns_in_load_initial_object_debts = val;
4636 }
4637
4638 pub fn set_authority_capabilities_v2_for_testing(&mut self, val: bool) {
4639 self.feature_flags.authority_capabilities_v2 = val;
4640 }
4641
4642 pub fn allow_references_in_ptbs_for_testing(&mut self) {
4643 self.feature_flags.allow_references_in_ptbs = true;
4644 }
4645
4646 pub fn set_consensus_skip_gced_accept_votes_for_testing(&mut self, val: bool) {
4647 self.feature_flags.consensus_skip_gced_accept_votes = val;
4648 }
4649}
4650
4651type OverrideFn = dyn Fn(ProtocolVersion, ProtocolConfig) -> ProtocolConfig + Send;
4652
4653thread_local! {
4654 static CONFIG_OVERRIDE: RefCell<Option<Box<OverrideFn>>> = RefCell::new(None);
4655}
4656
4657#[must_use]
4658pub struct OverrideGuard;
4659
4660impl Drop for OverrideGuard {
4661 fn drop(&mut self) {
4662 info!("restoring override fn");
4663 CONFIG_OVERRIDE.with(|ovr| {
4664 *ovr.borrow_mut() = None;
4665 });
4666 }
4667}
4668
4669#[derive(PartialEq, Eq)]
4672pub enum LimitThresholdCrossed {
4673 None,
4674 Soft(u128, u128),
4675 Hard(u128, u128),
4676}
4677
4678pub fn check_limit_in_range<T: Into<V>, U: Into<V>, V: PartialOrd + Into<u128>>(
4681 x: T,
4682 soft_limit: U,
4683 hard_limit: V,
4684) -> LimitThresholdCrossed {
4685 let x: V = x.into();
4686 let soft_limit: V = soft_limit.into();
4687
4688 debug_assert!(soft_limit <= hard_limit);
4689
4690 if x >= hard_limit {
4693 LimitThresholdCrossed::Hard(x.into(), hard_limit.into())
4694 } else if x < soft_limit {
4695 LimitThresholdCrossed::None
4696 } else {
4697 LimitThresholdCrossed::Soft(x.into(), soft_limit.into())
4698 }
4699}
4700
4701#[macro_export]
4702macro_rules! check_limit {
4703 ($x:expr, $hard:expr) => {
4704 check_limit!($x, $hard, $hard)
4705 };
4706 ($x:expr, $soft:expr, $hard:expr) => {
4707 check_limit_in_range($x as u64, $soft, $hard)
4708 };
4709}
4710
4711#[macro_export]
4715macro_rules! check_limit_by_meter {
4716 ($is_metered:expr, $x:expr, $metered_limit:expr, $unmetered_hard_limit:expr, $metric:expr) => {{
4717 let (h, metered_str) = if $is_metered {
4719 ($metered_limit, "metered")
4720 } else {
4721 ($unmetered_hard_limit, "unmetered")
4723 };
4724 use sui_protocol_config::check_limit_in_range;
4725 let result = check_limit_in_range($x as u64, $metered_limit, h);
4726 match result {
4727 LimitThresholdCrossed::None => {}
4728 LimitThresholdCrossed::Soft(_, _) => {
4729 $metric.with_label_values(&[metered_str, "soft"]).inc();
4730 }
4731 LimitThresholdCrossed::Hard(_, _) => {
4732 $metric.with_label_values(&[metered_str, "hard"]).inc();
4733 }
4734 };
4735 result
4736 }};
4737}
4738#[cfg(all(test, not(msim)))]
4739mod test {
4740 use insta::assert_yaml_snapshot;
4741
4742 use super::*;
4743
4744 #[test]
4745 fn snapshot_tests() {
4746 println!("\n============================================================================");
4747 println!("! !");
4748 println!("! IMPORTANT: never update snapshots from this test. only add new versions! !");
4749 println!("! !");
4750 println!("============================================================================\n");
4751 for chain_id in &[Chain::Unknown, Chain::Mainnet, Chain::Testnet] {
4752 let chain_str = match chain_id {
4756 Chain::Unknown => "".to_string(),
4757 _ => format!("{:?}_", chain_id),
4758 };
4759 for i in MIN_PROTOCOL_VERSION..=MAX_PROTOCOL_VERSION {
4760 let cur = ProtocolVersion::new(i);
4761 assert_yaml_snapshot!(
4762 format!("{}version_{}", chain_str, cur.as_u64()),
4763 ProtocolConfig::get_for_version(cur, *chain_id)
4764 );
4765 }
4766 }
4767 }
4768
4769 #[test]
4770 fn test_getters() {
4771 let prot: ProtocolConfig =
4772 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
4773 assert_eq!(
4774 prot.max_arguments(),
4775 prot.max_arguments_as_option().unwrap()
4776 );
4777 }
4778
4779 #[test]
4780 fn test_setters() {
4781 let mut prot: ProtocolConfig =
4782 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
4783 prot.set_max_arguments_for_testing(123);
4784 assert_eq!(prot.max_arguments(), 123);
4785
4786 prot.set_max_arguments_from_str_for_testing("321".to_string());
4787 assert_eq!(prot.max_arguments(), 321);
4788
4789 prot.disable_max_arguments_for_testing();
4790 assert_eq!(prot.max_arguments_as_option(), None);
4791
4792 prot.set_attr_for_testing("max_arguments".to_string(), "456".to_string());
4793 assert_eq!(prot.max_arguments(), 456);
4794 }
4795
4796 #[test]
4797 #[should_panic(expected = "unsupported version")]
4798 fn max_version_test() {
4799 let _ = ProtocolConfig::get_for_version_impl(
4802 ProtocolVersion::new(MAX_PROTOCOL_VERSION + 1),
4803 Chain::Unknown,
4804 );
4805 }
4806
4807 #[test]
4808 fn lookup_by_string_test() {
4809 let prot: ProtocolConfig =
4810 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
4811 assert!(prot.lookup_attr("some random string".to_string()).is_none());
4813
4814 assert!(
4815 prot.lookup_attr("max_arguments".to_string())
4816 == Some(ProtocolConfigValue::u32(prot.max_arguments())),
4817 );
4818
4819 assert!(
4821 prot.lookup_attr("max_move_identifier_len".to_string())
4822 .is_none()
4823 );
4824
4825 let prot: ProtocolConfig =
4827 ProtocolConfig::get_for_version(ProtocolVersion::new(9), Chain::Unknown);
4828 assert!(
4829 prot.lookup_attr("max_move_identifier_len".to_string())
4830 == Some(ProtocolConfigValue::u64(prot.max_move_identifier_len()))
4831 );
4832
4833 let prot: ProtocolConfig =
4834 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
4835 assert!(
4837 prot.attr_map()
4838 .get("max_move_identifier_len")
4839 .unwrap()
4840 .is_none()
4841 );
4842 assert!(
4844 prot.attr_map().get("max_arguments").unwrap()
4845 == &Some(ProtocolConfigValue::u32(prot.max_arguments()))
4846 );
4847
4848 let prot: ProtocolConfig =
4850 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
4851 assert!(
4853 prot.feature_flags
4854 .lookup_attr("some random string".to_owned())
4855 .is_none()
4856 );
4857 assert!(
4858 !prot
4859 .feature_flags
4860 .attr_map()
4861 .contains_key("some random string")
4862 );
4863
4864 assert!(
4866 prot.feature_flags
4867 .lookup_attr("package_upgrades".to_owned())
4868 == Some(false)
4869 );
4870 assert!(
4871 prot.feature_flags
4872 .attr_map()
4873 .get("package_upgrades")
4874 .unwrap()
4875 == &false
4876 );
4877 let prot: ProtocolConfig =
4878 ProtocolConfig::get_for_version(ProtocolVersion::new(4), Chain::Unknown);
4879 assert!(
4881 prot.feature_flags
4882 .lookup_attr("package_upgrades".to_owned())
4883 == Some(true)
4884 );
4885 assert!(
4886 prot.feature_flags
4887 .attr_map()
4888 .get("package_upgrades")
4889 .unwrap()
4890 == &true
4891 );
4892 }
4893
4894 #[test]
4895 fn limit_range_fn_test() {
4896 let low = 100u32;
4897 let high = 10000u64;
4898
4899 assert!(check_limit!(1u8, low, high) == LimitThresholdCrossed::None);
4900 assert!(matches!(
4901 check_limit!(255u16, low, high),
4902 LimitThresholdCrossed::Soft(255u128, 100)
4903 ));
4904 assert!(matches!(
4910 check_limit!(2550000u64, low, high),
4911 LimitThresholdCrossed::Hard(2550000, 10000)
4912 ));
4913
4914 assert!(matches!(
4915 check_limit!(2550000u64, high, high),
4916 LimitThresholdCrossed::Hard(2550000, 10000)
4917 ));
4918
4919 assert!(matches!(
4920 check_limit!(1u8, high),
4921 LimitThresholdCrossed::None
4922 ));
4923
4924 assert!(check_limit!(255u16, high) == LimitThresholdCrossed::None);
4925
4926 assert!(matches!(
4927 check_limit!(2550000u64, high),
4928 LimitThresholdCrossed::Hard(2550000, 10000)
4929 ));
4930 }
4931}