1use std::{
5 collections::{BTreeMap, BTreeSet},
6 sync::{
7 Arc, LazyLock,
8 atomic::{AtomicBool, Ordering},
9 },
10};
11
12#[cfg(msim)]
13use std::cell::RefCell;
14#[cfg(not(msim))]
15use std::sync::Mutex;
16
17use clap::*;
18use fastcrypto::encoding::{Base58, Encoding, Hex};
19use move_binary_format::{
20 binary_config::{BinaryConfig, TableConfig},
21 file_format_common::VERSION_1,
22};
23use move_core_types::account_address::AccountAddress;
24use move_vm_config::verifier::VerifierConfig;
25use mysten_common::in_integration_test;
26use serde::{Deserialize, Serialize};
27use serde_with::skip_serializing_none;
28use sui_protocol_config_macros::{
29 ProtocolConfigAccessors, ProtocolConfigFeatureFlagsGetters, ProtocolConfigOverride,
30};
31use tracing::{info, warn};
32
33const MIN_PROTOCOL_VERSION: u64 = 1;
35const MAX_PROTOCOL_VERSION: u64 = 129;
36
37const TESTNET_USDC: &str =
38 "0xa1ec7fc00a6f40db9693ad1415d0c193ad3906494428cf252621037bd7117e29::usdc::USDC";
39
40const MAINNET_USDC: &str =
41 "0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC";
42const MAINNET_USDSUI: &str =
43 "0x44f838219cf67b058f3b37907b655f226153c18e33dfcd0da559a844fea9b1c1::usdsui::USDSUI";
44const MAINNET_SUI_USDE: &str =
45 "0x41d587e5336f1c86cad50d38a7136db99333bb9bda91cea4ba69115defeb1402::sui_usde::SUI_USDE";
46const MAINNET_USDY: &str =
47 "0x960b531667636f39e85867775f52f6b1f220a058c4de786905bdf761e06a56bb::usdy::USDY";
48const MAINNET_FDUSD: &str =
49 "0xf16e6b723f242ec745dfd7634ad072c42d5c1d9ac9d62a39c381303eaa57693a::fdusd::FDUSD";
50const MAINNET_AUSD: &str =
51 "0x2053d08c1e2bd02791056171aab0fd12bd7cd7efad2ab8f6b9c8902f14df2ff2::ausd::AUSD";
52const MAINNET_USDB: &str =
53 "0xe14726c336e81b32328e92afc37345d159f5b550b09fa92bd43640cfdd0a0cfd::usdb::USDB";
54
55#[derive(Copy, Clone, Debug, Hash, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)]
365pub struct ProtocolVersion(u64);
366
367impl ProtocolVersion {
368 pub const MIN: Self = Self(MIN_PROTOCOL_VERSION);
373
374 pub const MAX: Self = Self(MAX_PROTOCOL_VERSION);
375
376 #[cfg(not(msim))]
377 pub const MAX_ALLOWED: Self = Self::MAX;
378
379 #[cfg(msim)]
381 pub const MAX_ALLOWED: Self = Self(MAX_PROTOCOL_VERSION + 1);
382
383 pub fn new(v: u64) -> Self {
384 Self(v)
385 }
386
387 pub const fn as_u64(&self) -> u64 {
388 self.0
389 }
390
391 pub fn max() -> Self {
394 Self::MAX
395 }
396
397 pub fn prev(self) -> Self {
398 Self(self.0.checked_sub(1).unwrap())
399 }
400}
401
402impl From<u64> for ProtocolVersion {
403 fn from(v: u64) -> Self {
404 Self::new(v)
405 }
406}
407
408impl std::ops::Sub<u64> for ProtocolVersion {
409 type Output = Self;
410 fn sub(self, rhs: u64) -> Self::Output {
411 Self::new(self.0 - rhs)
412 }
413}
414
415impl std::ops::Add<u64> for ProtocolVersion {
416 type Output = Self;
417 fn add(self, rhs: u64) -> Self::Output {
418 Self::new(self.0 + rhs)
419 }
420}
421
422#[derive(
423 Clone, Serialize, Deserialize, Debug, Default, PartialEq, Copy, PartialOrd, Ord, Eq, ValueEnum,
424)]
425pub enum Chain {
426 Mainnet,
427 Testnet,
428 #[default]
429 Unknown,
430}
431
432impl Chain {
433 pub fn as_str(self) -> &'static str {
434 match self {
435 Chain::Mainnet => "mainnet",
436 Chain::Testnet => "testnet",
437 Chain::Unknown => "unknown",
438 }
439 }
440}
441
442pub struct Error(pub String);
443
444#[derive(Default, Clone, Serialize, Deserialize, Debug, ProtocolConfigFeatureFlagsGetters)]
447struct FeatureFlags {
448 #[serde(skip_serializing_if = "is_false")]
451 package_upgrades: bool,
452 #[serde(skip_serializing_if = "is_false")]
455 commit_root_state_digest: bool,
456 #[serde(skip_serializing_if = "is_false")]
458 advance_epoch_start_time_in_safe_mode: bool,
459 #[serde(skip_serializing_if = "is_false")]
462 loaded_child_objects_fixed: bool,
463 #[serde(skip_serializing_if = "is_false")]
466 missing_type_is_compatibility_error: bool,
467 #[serde(skip_serializing_if = "is_false")]
470 scoring_decision_with_validity_cutoff: bool,
471
472 #[serde(skip_serializing_if = "is_false")]
475 consensus_order_end_of_epoch_last: bool,
476
477 #[serde(skip_serializing_if = "is_false")]
479 disallow_adding_abilities_on_upgrade: bool,
480 #[serde(skip_serializing_if = "is_false")]
482 disable_invariant_violation_check_in_swap_loc: bool,
483 #[serde(skip_serializing_if = "is_false")]
486 advance_to_highest_supported_protocol_version: bool,
487 #[serde(skip_serializing_if = "is_false")]
489 ban_entry_init: bool,
490 #[serde(skip_serializing_if = "is_false")]
492 package_digest_hash_module: bool,
493 #[serde(skip_serializing_if = "is_false")]
495 disallow_change_struct_type_params_on_upgrade: bool,
496 #[serde(skip_serializing_if = "is_false")]
498 no_extraneous_module_bytes: bool,
499 #[serde(skip_serializing_if = "is_false")]
501 narwhal_versioned_metadata: bool,
502
503 #[serde(skip_serializing_if = "is_false")]
505 zklogin_auth: bool,
506 #[serde(skip_serializing_if = "ConsensusTransactionOrdering::is_none")]
508 consensus_transaction_ordering: ConsensusTransactionOrdering,
509
510 #[serde(skip_serializing_if = "is_false")]
518 simplified_unwrap_then_delete: bool,
519 #[serde(skip_serializing_if = "is_false")]
521 upgraded_multisig_supported: bool,
522 #[serde(skip_serializing_if = "is_false")]
524 txn_base_cost_as_multiplier: bool,
525
526 #[serde(skip_serializing_if = "is_false")]
528 shared_object_deletion: bool,
529
530 #[serde(skip_serializing_if = "is_false")]
532 narwhal_new_leader_election_schedule: bool,
533
534 #[serde(skip_serializing_if = "is_empty")]
536 zklogin_supported_providers: BTreeSet<String>,
537
538 #[serde(skip_serializing_if = "is_false")]
540 loaded_child_object_format: bool,
541
542 #[serde(skip_serializing_if = "is_false")]
543 enable_jwk_consensus_updates: bool,
544
545 #[serde(skip_serializing_if = "is_false")]
546 end_of_epoch_transaction_supported: bool,
547
548 #[serde(skip_serializing_if = "is_false")]
551 simple_conservation_checks: bool,
552
553 #[serde(skip_serializing_if = "is_false")]
555 loaded_child_object_format_type: bool,
556
557 #[serde(skip_serializing_if = "is_false")]
559 receive_objects: bool,
560
561 #[serde(skip_serializing_if = "is_false")]
563 consensus_checkpoint_signature_key_includes_digest: bool,
564
565 #[serde(skip_serializing_if = "is_false")]
567 random_beacon: bool,
568
569 #[serde(skip_serializing_if = "is_false")]
571 bridge: bool,
572
573 #[serde(skip_serializing_if = "is_false")]
574 enable_effects_v2: bool,
575
576 #[serde(skip_serializing_if = "is_false")]
578 narwhal_certificate_v2: bool,
579
580 #[serde(skip_serializing_if = "is_false")]
582 verify_legacy_zklogin_address: bool,
583
584 #[serde(skip_serializing_if = "is_false")]
586 throughput_aware_consensus_submission: bool,
587
588 #[serde(skip_serializing_if = "is_false")]
590 recompute_has_public_transfer_in_execution: bool,
591
592 #[serde(skip_serializing_if = "is_false")]
594 accept_zklogin_in_multisig: bool,
595
596 #[serde(skip_serializing_if = "is_false")]
598 accept_passkey_in_multisig: bool,
599
600 #[serde(skip_serializing_if = "is_false")]
602 validate_zklogin_public_identifier: bool,
603
604 #[serde(skip_serializing_if = "is_false")]
607 include_consensus_digest_in_prologue: bool,
608
609 #[serde(skip_serializing_if = "is_false")]
611 hardened_otw_check: bool,
612
613 #[serde(skip_serializing_if = "is_false")]
615 allow_receiving_object_id: bool,
616
617 #[serde(skip_serializing_if = "is_false")]
619 enable_poseidon: bool,
620
621 #[serde(skip_serializing_if = "is_false")]
623 enable_coin_deny_list: bool,
624
625 #[serde(skip_serializing_if = "is_false")]
627 enable_group_ops_native_functions: bool,
628
629 #[serde(skip_serializing_if = "is_false")]
631 enable_group_ops_native_function_msm: bool,
632
633 #[serde(skip_serializing_if = "is_false")]
635 enable_ristretto255_group_ops: bool,
636
637 #[serde(skip_serializing_if = "is_false")]
639 enable_verify_bulletproofs_ristretto255: bool,
640
641 #[serde(skip_serializing_if = "is_false")]
643 enable_nitro_attestation: bool,
644
645 #[serde(skip_serializing_if = "is_false")]
647 enable_nitro_attestation_upgraded_parsing: bool,
648
649 #[serde(skip_serializing_if = "is_false")]
651 enable_nitro_attestation_all_nonzero_pcrs_parsing: bool,
652
653 #[serde(skip_serializing_if = "is_false")]
655 enable_nitro_attestation_always_include_required_pcrs_parsing: bool,
656
657 #[serde(skip_serializing_if = "is_false")]
659 reject_mutable_random_on_entry_functions: bool,
660
661 #[serde(skip_serializing_if = "PerObjectCongestionControlMode::is_none")]
663 per_object_congestion_control_mode: PerObjectCongestionControlMode,
664
665 #[serde(skip_serializing_if = "ConsensusChoice::is_narwhal")]
667 consensus_choice: ConsensusChoice,
668
669 #[serde(skip_serializing_if = "ConsensusNetwork::is_anemo")]
671 consensus_network: ConsensusNetwork,
672
673 #[serde(skip_serializing_if = "is_false")]
675 correct_gas_payment_limit_check: bool,
676
677 #[serde(skip_serializing_if = "Option::is_none")]
679 zklogin_max_epoch_upper_bound_delta: Option<u64>,
680
681 #[serde(skip_serializing_if = "is_false")]
683 mysticeti_leader_scoring_and_schedule: bool,
684
685 #[serde(skip_serializing_if = "is_false")]
687 reshare_at_same_initial_version: bool,
688
689 #[serde(skip_serializing_if = "is_false")]
691 resolve_abort_locations_to_package_id: bool,
692
693 #[serde(skip_serializing_if = "is_false")]
697 mysticeti_use_committed_subdag_digest: bool,
698
699 #[serde(skip_serializing_if = "is_false")]
701 enable_vdf: bool,
702
703 #[serde(skip_serializing_if = "is_false")]
708 record_consensus_determined_version_assignments_in_prologue: bool,
709 #[serde(skip_serializing_if = "is_false")]
710 record_consensus_determined_version_assignments_in_prologue_v2: bool,
711
712 #[serde(skip_serializing_if = "is_false")]
714 fresh_vm_on_framework_upgrade: bool,
715
716 #[serde(skip_serializing_if = "is_false")]
724 prepend_prologue_tx_in_consensus_commit_in_checkpoints: bool,
725
726 #[serde(skip_serializing_if = "Option::is_none")]
728 mysticeti_num_leaders_per_round: Option<usize>,
729
730 #[serde(skip_serializing_if = "is_false")]
732 soft_bundle: bool,
733
734 #[serde(skip_serializing_if = "is_false")]
736 enable_coin_deny_list_v2: bool,
737
738 #[serde(skip_serializing_if = "is_false")]
740 passkey_auth: bool,
741
742 #[serde(skip_serializing_if = "is_false")]
744 authority_capabilities_v2: bool,
745
746 #[serde(skip_serializing_if = "is_false")]
748 rethrow_serialization_type_layout_errors: bool,
749
750 #[serde(skip_serializing_if = "is_false")]
752 consensus_distributed_vote_scoring_strategy: bool,
753
754 #[serde(skip_serializing_if = "is_false")]
756 consensus_round_prober: bool,
757
758 #[serde(skip_serializing_if = "is_false")]
760 validate_identifier_inputs: bool,
761
762 #[serde(skip_serializing_if = "is_false")]
764 disallow_self_identifier: bool,
765
766 #[serde(skip_serializing_if = "is_false")]
768 mysticeti_fastpath: bool,
769
770 #[serde(skip_serializing_if = "is_false")]
774 disable_preconsensus_locking: bool,
775
776 #[serde(skip_serializing_if = "is_false")]
778 relocate_event_module: bool,
779
780 #[serde(skip_serializing_if = "is_false")]
782 uncompressed_g1_group_elements: bool,
783
784 #[serde(skip_serializing_if = "is_false")]
785 disallow_new_modules_in_deps_only_packages: bool,
786
787 #[serde(skip_serializing_if = "is_false")]
789 consensus_smart_ancestor_selection: bool,
790
791 #[serde(skip_serializing_if = "is_false")]
793 consensus_round_prober_probe_accepted_rounds: bool,
794
795 #[serde(skip_serializing_if = "is_false")]
797 native_charging_v2: bool,
798
799 #[serde(skip_serializing_if = "is_false")]
802 consensus_linearize_subdag_v2: bool,
803
804 #[serde(skip_serializing_if = "is_false")]
806 convert_type_argument_error: bool,
807
808 #[serde(skip_serializing_if = "is_false")]
810 variant_nodes: bool,
811
812 #[serde(skip_serializing_if = "is_false")]
814 consensus_zstd_compression: bool,
815
816 #[serde(skip_serializing_if = "is_false")]
818 minimize_child_object_mutations: bool,
819
820 #[serde(skip_serializing_if = "is_false")]
822 record_additional_state_digest_in_prologue: bool,
823
824 #[serde(skip_serializing_if = "is_false")]
826 move_native_context: bool,
827
828 #[serde(skip_serializing_if = "is_false")]
831 consensus_median_based_commit_timestamp: bool,
832
833 #[serde(skip_serializing_if = "is_false")]
836 normalize_ptb_arguments: bool,
837
838 #[serde(skip_serializing_if = "is_false")]
840 consensus_batched_block_sync: bool,
841
842 #[serde(skip_serializing_if = "is_false")]
844 enforce_checkpoint_timestamp_monotonicity: bool,
845
846 #[serde(skip_serializing_if = "is_false")]
848 max_ptb_value_size_v2: bool,
849
850 #[serde(skip_serializing_if = "is_false")]
852 resolve_type_input_ids_to_defining_id: bool,
853
854 #[serde(skip_serializing_if = "is_false")]
856 enable_party_transfer: bool,
857
858 #[serde(skip_serializing_if = "is_false")]
860 allow_unbounded_system_objects: bool,
861
862 #[serde(skip_serializing_if = "is_false")]
864 type_tags_in_object_runtime: bool,
865
866 #[serde(skip_serializing_if = "is_false")]
868 enable_accumulators: bool,
869
870 #[serde(skip_serializing_if = "is_false")]
872 enable_coin_reservation_obj_refs: bool,
873
874 #[serde(skip_serializing_if = "is_false")]
877 create_root_accumulator_object: bool,
878
879 #[serde(skip_serializing_if = "is_false")]
881 enable_authenticated_event_streams: bool,
882
883 #[serde(skip_serializing_if = "is_false")]
885 enable_address_balance_gas_payments: bool,
886
887 #[serde(skip_serializing_if = "is_false")]
889 address_balance_gas_check_rgp_at_signing: bool,
890
891 #[serde(skip_serializing_if = "is_false")]
892 address_balance_gas_reject_gas_coin_arg: bool,
893
894 #[serde(skip_serializing_if = "is_false")]
896 enable_multi_epoch_transaction_expiration: bool,
897
898 #[serde(skip_serializing_if = "is_false")]
900 relax_valid_during_for_owned_inputs: bool,
901
902 #[serde(skip_serializing_if = "is_false")]
904 enable_ptb_execution_v2: bool,
905
906 #[serde(skip_serializing_if = "is_false")]
908 better_adapter_type_resolution_errors: bool,
909
910 #[serde(skip_serializing_if = "is_false")]
912 record_time_estimate_processed: bool,
913
914 #[serde(skip_serializing_if = "is_false")]
916 dependency_linkage_error: bool,
917
918 #[serde(skip_serializing_if = "is_false")]
920 additional_multisig_checks: bool,
921
922 #[serde(skip_serializing_if = "is_false")]
924 ignore_execution_time_observations_after_certs_closed: bool,
925
926 #[serde(skip_serializing_if = "is_false")]
930 debug_fatal_on_move_invariant_violation: bool,
931
932 #[serde(skip_serializing_if = "is_false")]
935 allow_private_accumulator_entrypoints: bool,
936
937 #[serde(skip_serializing_if = "is_false")]
939 additional_consensus_digest_indirect_state: bool,
940
941 #[serde(skip_serializing_if = "is_false")]
943 check_for_init_during_upgrade: bool,
944
945 #[serde(skip_serializing_if = "is_false")]
947 per_command_shared_object_transfer_rules: bool,
948
949 #[serde(skip_serializing_if = "is_false")]
951 include_checkpoint_artifacts_digest_in_summary: bool,
952
953 #[serde(skip_serializing_if = "is_false")]
955 use_mfp_txns_in_load_initial_object_debts: bool,
956
957 #[serde(skip_serializing_if = "is_false")]
959 cancel_for_failed_dkg_early: bool,
960
961 #[serde(skip_serializing_if = "is_false")]
963 always_advance_dkg_to_resolution: bool,
964
965 #[serde(skip_serializing_if = "is_false")]
967 enable_coin_registry: bool,
968
969 #[serde(skip_serializing_if = "is_false")]
971 abstract_size_in_object_runtime: bool,
972
973 #[serde(skip_serializing_if = "is_false")]
975 object_runtime_charge_cache_load_gas: bool,
976
977 #[serde(skip_serializing_if = "is_false")]
979 additional_borrow_checks: bool,
980
981 #[serde(skip_serializing_if = "is_false")]
983 use_new_commit_handler: bool,
984
985 #[serde(skip_serializing_if = "is_false")]
987 better_loader_errors: bool,
988
989 #[serde(skip_serializing_if = "is_false")]
991 generate_df_type_layouts: bool,
992
993 #[serde(skip_serializing_if = "is_false")]
995 allow_references_in_ptbs: bool,
996
997 #[serde(skip_serializing_if = "is_false")]
999 enable_display_registry: bool,
1000
1001 #[serde(skip_serializing_if = "is_false")]
1003 private_generics_verifier_v2: bool,
1004
1005 #[serde(skip_serializing_if = "is_false")]
1007 deprecate_global_storage_ops_during_deserialization: bool,
1008
1009 #[serde(skip_serializing_if = "is_false")]
1012 enable_non_exclusive_writes: bool,
1013
1014 #[serde(skip_serializing_if = "is_false")]
1016 deprecate_global_storage_ops: bool,
1017
1018 #[serde(skip_serializing_if = "is_false")]
1020 normalize_depth_formula: bool,
1021
1022 #[serde(skip_serializing_if = "is_false")]
1024 consensus_skip_gced_accept_votes: bool,
1025
1026 #[serde(skip_serializing_if = "is_false")]
1028 include_cancelled_randomness_txns_in_prologue: bool,
1029
1030 #[serde(skip_serializing_if = "is_false")]
1032 address_aliases: bool,
1033
1034 #[serde(skip_serializing_if = "is_false")]
1037 fix_checkpoint_signature_mapping: bool,
1038
1039 #[serde(skip_serializing_if = "is_false")]
1041 enable_object_funds_withdraw: bool,
1042
1043 #[serde(skip_serializing_if = "is_false")]
1045 consensus_skip_gced_blocks_in_direct_finalization: bool,
1046
1047 #[serde(skip_serializing_if = "is_false")]
1049 gas_rounding_halve_digits: bool,
1050
1051 #[serde(skip_serializing_if = "is_false")]
1053 flexible_tx_context_positions: bool,
1054
1055 #[serde(skip_serializing_if = "is_false")]
1057 disable_entry_point_signature_check: bool,
1058
1059 #[serde(skip_serializing_if = "is_false")]
1061 convert_withdrawal_compatibility_ptb_arguments: bool,
1062
1063 #[serde(skip_serializing_if = "is_false")]
1065 restrict_hot_or_not_entry_functions: bool,
1066
1067 #[serde(skip_serializing_if = "is_false")]
1069 split_checkpoints_in_consensus_handler: bool,
1070
1071 #[serde(skip_serializing_if = "is_false")]
1073 consensus_always_accept_system_transactions: bool,
1074
1075 #[serde(skip_serializing_if = "is_false")]
1077 validator_metadata_verify_v2: bool,
1078
1079 #[serde(skip_serializing_if = "is_false")]
1082 defer_unpaid_amplification: bool,
1083
1084 #[serde(skip_serializing_if = "is_false")]
1085 randomize_checkpoint_tx_limit_in_tests: bool,
1086
1087 #[serde(skip_serializing_if = "is_false")]
1089 gasless_transaction_drop_safety: bool,
1090
1091 #[serde(skip_serializing_if = "is_false")]
1093 merge_randomness_into_checkpoint: bool,
1094
1095 #[serde(skip_serializing_if = "is_false")]
1097 use_coin_party_owner: bool,
1098
1099 #[serde(skip_serializing_if = "is_false")]
1100 enable_gasless: bool,
1101
1102 #[serde(skip_serializing_if = "is_false")]
1103 gasless_verify_remaining_balance: bool,
1104
1105 #[serde(skip_serializing_if = "is_false")]
1106 disallow_jump_orphans: bool,
1107
1108 #[serde(skip_serializing_if = "is_false")]
1110 early_return_receive_object_mismatched_type: bool,
1111
1112 #[serde(skip_serializing_if = "is_false")]
1117 timestamp_based_epoch_close: bool,
1118
1119 #[serde(skip_serializing_if = "is_false")]
1122 limit_groth16_pvk_inputs: bool,
1123
1124 #[serde(skip_serializing_if = "is_false")]
1129 enforce_address_balance_change_invariant: bool,
1130
1131 #[serde(skip_serializing_if = "is_false")]
1133 granular_post_execution_checks: bool,
1134
1135 #[serde(skip_serializing_if = "is_false")]
1137 early_exit_on_iffw: bool,
1138}
1139
1140fn is_false(b: &bool) -> bool {
1141 !b
1142}
1143
1144fn is_empty(b: &BTreeSet<String>) -> bool {
1145 b.is_empty()
1146}
1147
1148fn is_zero(val: &u64) -> bool {
1149 *val == 0
1150}
1151
1152#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1154pub enum ConsensusTransactionOrdering {
1155 #[default]
1157 None,
1158 ByGasPrice,
1160}
1161
1162impl ConsensusTransactionOrdering {
1163 pub fn is_none(&self) -> bool {
1164 matches!(self, ConsensusTransactionOrdering::None)
1165 }
1166}
1167
1168#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1169pub struct ExecutionTimeEstimateParams {
1170 pub target_utilization: u64,
1172 pub allowed_txn_cost_overage_burst_limit_us: u64,
1176
1177 pub randomness_scalar: u64,
1180
1181 pub max_estimate_us: u64,
1183
1184 pub stored_observations_num_included_checkpoints: u64,
1187
1188 pub stored_observations_limit: u64,
1190
1191 #[serde(skip_serializing_if = "is_zero")]
1194 pub stake_weighted_median_threshold: u64,
1195
1196 #[serde(skip_serializing_if = "is_false")]
1200 pub default_none_duration_for_new_keys: bool,
1201
1202 #[serde(skip_serializing_if = "Option::is_none")]
1204 pub observations_chunk_size: Option<u64>,
1205}
1206
1207#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1209pub enum PerObjectCongestionControlMode {
1210 #[default]
1211 None, TotalGasBudget, TotalTxCount, TotalGasBudgetWithCap, ExecutionTimeEstimate(ExecutionTimeEstimateParams), }
1217
1218impl PerObjectCongestionControlMode {
1219 pub fn is_none(&self) -> bool {
1220 matches!(self, PerObjectCongestionControlMode::None)
1221 }
1222}
1223
1224#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1226pub enum ConsensusChoice {
1227 #[default]
1228 Narwhal,
1229 SwapEachEpoch,
1230 Mysticeti,
1231}
1232
1233impl ConsensusChoice {
1234 pub fn is_narwhal(&self) -> bool {
1235 matches!(self, ConsensusChoice::Narwhal)
1236 }
1237}
1238
1239#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1241pub enum ConsensusNetwork {
1242 #[default]
1243 Anemo,
1244 Tonic,
1245}
1246
1247impl ConsensusNetwork {
1248 pub fn is_anemo(&self) -> bool {
1249 matches!(self, ConsensusNetwork::Anemo)
1250 }
1251}
1252
1253#[skip_serializing_none]
1285#[derive(Clone, Serialize, Debug, ProtocolConfigAccessors, ProtocolConfigOverride)]
1286pub struct ProtocolConfig {
1287 pub version: ProtocolVersion,
1288
1289 #[serde(skip)]
1294 chain: Chain,
1295
1296 feature_flags: FeatureFlags,
1297
1298 max_tx_size_bytes: Option<u64>,
1301
1302 max_input_objects: Option<u64>,
1304
1305 max_size_written_objects: Option<u64>,
1309 max_size_written_objects_system_tx: Option<u64>,
1312
1313 max_serialized_tx_effects_size_bytes: Option<u64>,
1315
1316 max_serialized_tx_effects_size_bytes_system_tx: Option<u64>,
1318
1319 max_gas_payment_objects: Option<u32>,
1321
1322 max_modules_in_publish: Option<u32>,
1324
1325 max_package_dependencies: Option<u32>,
1327
1328 max_arguments: Option<u32>,
1331
1332 max_type_arguments: Option<u32>,
1334
1335 max_type_argument_depth: Option<u32>,
1337
1338 max_pure_argument_size: Option<u32>,
1340
1341 max_programmable_tx_commands: Option<u32>,
1343
1344 move_binary_format_version: Option<u32>,
1347 min_move_binary_format_version: Option<u32>,
1348
1349 binary_module_handles: Option<u16>,
1351 binary_struct_handles: Option<u16>,
1352 binary_function_handles: Option<u16>,
1353 binary_function_instantiations: Option<u16>,
1354 binary_signatures: Option<u16>,
1355 binary_constant_pool: Option<u16>,
1356 binary_identifiers: Option<u16>,
1357 binary_address_identifiers: Option<u16>,
1358 binary_struct_defs: Option<u16>,
1359 binary_struct_def_instantiations: Option<u16>,
1360 binary_function_defs: Option<u16>,
1361 binary_field_handles: Option<u16>,
1362 binary_field_instantiations: Option<u16>,
1363 binary_friend_decls: Option<u16>,
1364 binary_enum_defs: Option<u16>,
1365 binary_enum_def_instantiations: Option<u16>,
1366 binary_variant_handles: Option<u16>,
1367 binary_variant_instantiation_handles: Option<u16>,
1368
1369 max_move_object_size: Option<u64>,
1371
1372 max_move_package_size: Option<u64>,
1375
1376 max_publish_or_upgrade_per_ptb: Option<u64>,
1378
1379 max_tx_gas: Option<u64>,
1381
1382 max_gas_price: Option<u64>,
1384
1385 max_gas_price_rgp_factor_for_aborted_transactions: Option<u64>,
1388
1389 max_gas_computation_bucket: Option<u64>,
1391
1392 gas_rounding_step: Option<u64>,
1394
1395 max_loop_depth: Option<u64>,
1397
1398 max_generic_instantiation_length: Option<u64>,
1400
1401 max_function_parameters: Option<u64>,
1403
1404 max_basic_blocks: Option<u64>,
1406
1407 max_value_stack_size: Option<u64>,
1409
1410 max_type_nodes: Option<u64>,
1412
1413 max_generic_instantiation_type_nodes_per_function: Option<u64>,
1415
1416 max_generic_instantiation_type_nodes_per_module: Option<u64>,
1418
1419 max_push_size: Option<u64>,
1421
1422 max_struct_definitions: Option<u64>,
1424
1425 max_function_definitions: Option<u64>,
1427
1428 max_fields_in_struct: Option<u64>,
1430
1431 max_dependency_depth: Option<u64>,
1433
1434 max_num_event_emit: Option<u64>,
1436
1437 max_num_new_move_object_ids: Option<u64>,
1439
1440 max_num_new_move_object_ids_system_tx: Option<u64>,
1442
1443 max_num_deleted_move_object_ids: Option<u64>,
1445
1446 max_num_deleted_move_object_ids_system_tx: Option<u64>,
1448
1449 max_num_transferred_move_object_ids: Option<u64>,
1451
1452 max_num_transferred_move_object_ids_system_tx: Option<u64>,
1454
1455 max_event_emit_size: Option<u64>,
1457
1458 max_event_emit_size_total: Option<u64>,
1460
1461 max_move_vector_len: Option<u64>,
1463
1464 max_move_identifier_len: Option<u64>,
1466
1467 max_move_value_depth: Option<u64>,
1469
1470 max_move_enum_variants: Option<u64>,
1472
1473 max_back_edges_per_function: Option<u64>,
1475
1476 max_back_edges_per_module: Option<u64>,
1478
1479 max_verifier_meter_ticks_per_function: Option<u64>,
1481
1482 max_meter_ticks_per_module: Option<u64>,
1484
1485 max_meter_ticks_per_package: Option<u64>,
1487
1488 object_runtime_max_num_cached_objects: Option<u64>,
1492
1493 object_runtime_max_num_cached_objects_system_tx: Option<u64>,
1495
1496 object_runtime_max_num_store_entries: Option<u64>,
1498
1499 object_runtime_max_num_store_entries_system_tx: Option<u64>,
1501
1502 base_tx_cost_fixed: Option<u64>,
1505
1506 package_publish_cost_fixed: Option<u64>,
1509
1510 base_tx_cost_per_byte: Option<u64>,
1513
1514 package_publish_cost_per_byte: Option<u64>,
1516
1517 obj_access_cost_read_per_byte: Option<u64>,
1519
1520 obj_access_cost_mutate_per_byte: Option<u64>,
1522
1523 obj_access_cost_delete_per_byte: Option<u64>,
1525
1526 obj_access_cost_verify_per_byte: Option<u64>,
1536
1537 max_type_to_layout_nodes: Option<u64>,
1539
1540 max_ptb_value_size: Option<u64>,
1542
1543 gas_model_version: Option<u64>,
1546
1547 obj_data_cost_refundable: Option<u64>,
1550
1551 obj_metadata_cost_non_refundable: Option<u64>,
1555
1556 storage_rebate_rate: Option<u64>,
1562
1563 storage_fund_reinvest_rate: Option<u64>,
1566
1567 reward_slashing_rate: Option<u64>,
1570
1571 storage_gas_price: Option<u64>,
1573
1574 accumulator_object_storage_cost: Option<u64>,
1576
1577 max_transactions_per_checkpoint: Option<u64>,
1582
1583 max_checkpoint_size_bytes: Option<u64>,
1587
1588 buffer_stake_for_protocol_upgrade_bps: Option<u64>,
1593
1594 address_from_bytes_cost_base: Option<u64>,
1599 address_to_u256_cost_base: Option<u64>,
1601 address_from_u256_cost_base: Option<u64>,
1603
1604 config_read_setting_impl_cost_base: Option<u64>,
1609 config_read_setting_impl_cost_per_byte: Option<u64>,
1610
1611 dynamic_field_hash_type_and_key_cost_base: Option<u64>,
1614 dynamic_field_hash_type_and_key_type_cost_per_byte: Option<u64>,
1615 dynamic_field_hash_type_and_key_value_cost_per_byte: Option<u64>,
1616 dynamic_field_hash_type_and_key_type_tag_cost_per_byte: Option<u64>,
1617 dynamic_field_add_child_object_cost_base: Option<u64>,
1619 dynamic_field_add_child_object_type_cost_per_byte: Option<u64>,
1620 dynamic_field_add_child_object_value_cost_per_byte: Option<u64>,
1621 dynamic_field_add_child_object_struct_tag_cost_per_byte: Option<u64>,
1622 dynamic_field_borrow_child_object_cost_base: Option<u64>,
1624 dynamic_field_borrow_child_object_child_ref_cost_per_byte: Option<u64>,
1625 dynamic_field_borrow_child_object_type_cost_per_byte: Option<u64>,
1626 dynamic_field_remove_child_object_cost_base: Option<u64>,
1628 dynamic_field_remove_child_object_child_cost_per_byte: Option<u64>,
1629 dynamic_field_remove_child_object_type_cost_per_byte: Option<u64>,
1630 dynamic_field_has_child_object_cost_base: Option<u64>,
1632 dynamic_field_has_child_object_with_ty_cost_base: Option<u64>,
1634 dynamic_field_has_child_object_with_ty_type_cost_per_byte: Option<u64>,
1635 dynamic_field_has_child_object_with_ty_type_tag_cost_per_byte: Option<u64>,
1636
1637 event_emit_cost_base: Option<u64>,
1640 event_emit_value_size_derivation_cost_per_byte: Option<u64>,
1641 event_emit_tag_size_derivation_cost_per_byte: Option<u64>,
1642 event_emit_output_cost_per_byte: Option<u64>,
1643 event_emit_auth_stream_cost: Option<u64>,
1644
1645 object_borrow_uid_cost_base: Option<u64>,
1648 object_delete_impl_cost_base: Option<u64>,
1650 object_record_new_uid_cost_base: Option<u64>,
1652
1653 transfer_transfer_internal_cost_base: Option<u64>,
1656 transfer_party_transfer_internal_cost_base: Option<u64>,
1658 transfer_freeze_object_cost_base: Option<u64>,
1660 transfer_share_object_cost_base: Option<u64>,
1662 transfer_receive_object_cost_base: Option<u64>,
1665 transfer_receive_object_cost_per_byte: Option<u64>,
1666 transfer_receive_object_type_cost_per_byte: Option<u64>,
1667
1668 tx_context_derive_id_cost_base: Option<u64>,
1671 tx_context_fresh_id_cost_base: Option<u64>,
1672 tx_context_sender_cost_base: Option<u64>,
1673 tx_context_epoch_cost_base: Option<u64>,
1674 tx_context_epoch_timestamp_ms_cost_base: Option<u64>,
1675 tx_context_sponsor_cost_base: Option<u64>,
1676 tx_context_rgp_cost_base: Option<u64>,
1677 tx_context_gas_price_cost_base: Option<u64>,
1678 tx_context_gas_budget_cost_base: Option<u64>,
1679 tx_context_ids_created_cost_base: Option<u64>,
1680 tx_context_replace_cost_base: Option<u64>,
1681
1682 types_is_one_time_witness_cost_base: Option<u64>,
1685 types_is_one_time_witness_type_tag_cost_per_byte: Option<u64>,
1686 types_is_one_time_witness_type_cost_per_byte: Option<u64>,
1687
1688 validator_validate_metadata_cost_base: Option<u64>,
1691 validator_validate_metadata_data_cost_per_byte: Option<u64>,
1692
1693 crypto_invalid_arguments_cost: Option<u64>,
1695 bls12381_bls12381_min_sig_verify_cost_base: Option<u64>,
1697 bls12381_bls12381_min_sig_verify_msg_cost_per_byte: Option<u64>,
1698 bls12381_bls12381_min_sig_verify_msg_cost_per_block: Option<u64>,
1699
1700 bls12381_bls12381_min_pk_verify_cost_base: Option<u64>,
1702 bls12381_bls12381_min_pk_verify_msg_cost_per_byte: Option<u64>,
1703 bls12381_bls12381_min_pk_verify_msg_cost_per_block: Option<u64>,
1704
1705 ecdsa_k1_ecrecover_keccak256_cost_base: Option<u64>,
1707 ecdsa_k1_ecrecover_keccak256_msg_cost_per_byte: Option<u64>,
1708 ecdsa_k1_ecrecover_keccak256_msg_cost_per_block: Option<u64>,
1709 ecdsa_k1_ecrecover_sha256_cost_base: Option<u64>,
1710 ecdsa_k1_ecrecover_sha256_msg_cost_per_byte: Option<u64>,
1711 ecdsa_k1_ecrecover_sha256_msg_cost_per_block: Option<u64>,
1712
1713 ecdsa_k1_decompress_pubkey_cost_base: Option<u64>,
1715
1716 ecdsa_k1_secp256k1_verify_keccak256_cost_base: Option<u64>,
1718 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_byte: Option<u64>,
1719 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_block: Option<u64>,
1720 ecdsa_k1_secp256k1_verify_sha256_cost_base: Option<u64>,
1721 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_byte: Option<u64>,
1722 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_block: Option<u64>,
1723
1724 ecdsa_r1_ecrecover_keccak256_cost_base: Option<u64>,
1726 ecdsa_r1_ecrecover_keccak256_msg_cost_per_byte: Option<u64>,
1727 ecdsa_r1_ecrecover_keccak256_msg_cost_per_block: Option<u64>,
1728 ecdsa_r1_ecrecover_sha256_cost_base: Option<u64>,
1729 ecdsa_r1_ecrecover_sha256_msg_cost_per_byte: Option<u64>,
1730 ecdsa_r1_ecrecover_sha256_msg_cost_per_block: Option<u64>,
1731
1732 ecdsa_r1_secp256r1_verify_keccak256_cost_base: Option<u64>,
1734 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_byte: Option<u64>,
1735 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_block: Option<u64>,
1736 ecdsa_r1_secp256r1_verify_sha256_cost_base: Option<u64>,
1737 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_byte: Option<u64>,
1738 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_block: Option<u64>,
1739
1740 ecvrf_ecvrf_verify_cost_base: Option<u64>,
1742 ecvrf_ecvrf_verify_alpha_string_cost_per_byte: Option<u64>,
1743 ecvrf_ecvrf_verify_alpha_string_cost_per_block: Option<u64>,
1744
1745 ed25519_ed25519_verify_cost_base: Option<u64>,
1747 ed25519_ed25519_verify_msg_cost_per_byte: Option<u64>,
1748 ed25519_ed25519_verify_msg_cost_per_block: Option<u64>,
1749
1750 groth16_prepare_verifying_key_bls12381_cost_base: Option<u64>,
1752 groth16_prepare_verifying_key_bn254_cost_base: Option<u64>,
1753
1754 groth16_verify_groth16_proof_internal_bls12381_cost_base: Option<u64>,
1756 groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input: Option<u64>,
1757 groth16_verify_groth16_proof_internal_bn254_cost_base: Option<u64>,
1758 groth16_verify_groth16_proof_internal_bn254_cost_per_public_input: Option<u64>,
1759 groth16_verify_groth16_proof_internal_public_input_cost_per_byte: Option<u64>,
1760
1761 hash_blake2b256_cost_base: Option<u64>,
1763 hash_blake2b256_data_cost_per_byte: Option<u64>,
1764 hash_blake2b256_data_cost_per_block: Option<u64>,
1765
1766 hash_keccak256_cost_base: Option<u64>,
1768 hash_keccak256_data_cost_per_byte: Option<u64>,
1769 hash_keccak256_data_cost_per_block: Option<u64>,
1770
1771 poseidon_bn254_cost_base: Option<u64>,
1773 poseidon_bn254_cost_per_block: Option<u64>,
1774
1775 group_ops_bls12381_decode_scalar_cost: Option<u64>,
1777 group_ops_bls12381_decode_g1_cost: Option<u64>,
1778 group_ops_bls12381_decode_g2_cost: Option<u64>,
1779 group_ops_bls12381_decode_gt_cost: Option<u64>,
1780 group_ops_bls12381_scalar_add_cost: Option<u64>,
1781 group_ops_bls12381_g1_add_cost: Option<u64>,
1782 group_ops_bls12381_g2_add_cost: Option<u64>,
1783 group_ops_bls12381_gt_add_cost: Option<u64>,
1784 group_ops_bls12381_scalar_sub_cost: Option<u64>,
1785 group_ops_bls12381_g1_sub_cost: Option<u64>,
1786 group_ops_bls12381_g2_sub_cost: Option<u64>,
1787 group_ops_bls12381_gt_sub_cost: Option<u64>,
1788 group_ops_bls12381_scalar_mul_cost: Option<u64>,
1789 group_ops_bls12381_g1_mul_cost: Option<u64>,
1790 group_ops_bls12381_g2_mul_cost: Option<u64>,
1791 group_ops_bls12381_gt_mul_cost: Option<u64>,
1792 group_ops_bls12381_scalar_div_cost: Option<u64>,
1793 group_ops_bls12381_g1_div_cost: Option<u64>,
1794 group_ops_bls12381_g2_div_cost: Option<u64>,
1795 group_ops_bls12381_gt_div_cost: Option<u64>,
1796 group_ops_bls12381_g1_hash_to_base_cost: Option<u64>,
1797 group_ops_bls12381_g2_hash_to_base_cost: Option<u64>,
1798 group_ops_bls12381_g1_hash_to_cost_per_byte: Option<u64>,
1799 group_ops_bls12381_g2_hash_to_cost_per_byte: Option<u64>,
1800 group_ops_bls12381_g1_msm_base_cost: Option<u64>,
1801 group_ops_bls12381_g2_msm_base_cost: Option<u64>,
1802 group_ops_bls12381_g1_msm_base_cost_per_input: Option<u64>,
1803 group_ops_bls12381_g2_msm_base_cost_per_input: Option<u64>,
1804 group_ops_bls12381_msm_max_len: Option<u32>,
1805 group_ops_bls12381_pairing_cost: Option<u64>,
1806 group_ops_bls12381_g1_to_uncompressed_g1_cost: Option<u64>,
1807 group_ops_bls12381_uncompressed_g1_to_g1_cost: Option<u64>,
1808 group_ops_bls12381_uncompressed_g1_sum_base_cost: Option<u64>,
1809 group_ops_bls12381_uncompressed_g1_sum_cost_per_term: Option<u64>,
1810 group_ops_bls12381_uncompressed_g1_sum_max_terms: Option<u64>,
1811
1812 group_ops_ristretto_decode_scalar_cost: Option<u64>,
1813 group_ops_ristretto_decode_point_cost: Option<u64>,
1814 group_ops_ristretto_scalar_add_cost: Option<u64>,
1815 group_ops_ristretto_point_add_cost: Option<u64>,
1816 group_ops_ristretto_scalar_sub_cost: Option<u64>,
1817 group_ops_ristretto_point_sub_cost: Option<u64>,
1818 group_ops_ristretto_scalar_mul_cost: Option<u64>,
1819 group_ops_ristretto_point_mul_cost: Option<u64>,
1820 group_ops_ristretto_scalar_div_cost: Option<u64>,
1821 group_ops_ristretto_point_div_cost: Option<u64>,
1822
1823 verify_bulletproofs_ristretto255_base_cost: Option<u64>,
1824 verify_bulletproofs_ristretto255_cost_per_bit_and_commitment: Option<u64>,
1825
1826 hmac_hmac_sha3_256_cost_base: Option<u64>,
1828 hmac_hmac_sha3_256_input_cost_per_byte: Option<u64>,
1829 hmac_hmac_sha3_256_input_cost_per_block: Option<u64>,
1830
1831 check_zklogin_id_cost_base: Option<u64>,
1833 check_zklogin_issuer_cost_base: Option<u64>,
1835
1836 vdf_verify_vdf_cost: Option<u64>,
1837 vdf_hash_to_input_cost: Option<u64>,
1838
1839 nitro_attestation_parse_base_cost: Option<u64>,
1841 nitro_attestation_parse_cost_per_byte: Option<u64>,
1842 nitro_attestation_verify_base_cost: Option<u64>,
1843 nitro_attestation_verify_cost_per_cert: Option<u64>,
1844
1845 bcs_per_byte_serialized_cost: Option<u64>,
1847 bcs_legacy_min_output_size_cost: Option<u64>,
1848 bcs_failure_cost: Option<u64>,
1849
1850 hash_sha2_256_base_cost: Option<u64>,
1851 hash_sha2_256_per_byte_cost: Option<u64>,
1852 hash_sha2_256_legacy_min_input_len_cost: Option<u64>,
1853 hash_sha3_256_base_cost: Option<u64>,
1854 hash_sha3_256_per_byte_cost: Option<u64>,
1855 hash_sha3_256_legacy_min_input_len_cost: Option<u64>,
1856 type_name_get_base_cost: Option<u64>,
1857 type_name_get_per_byte_cost: Option<u64>,
1858 type_name_id_base_cost: Option<u64>,
1859
1860 string_check_utf8_base_cost: Option<u64>,
1861 string_check_utf8_per_byte_cost: Option<u64>,
1862 string_is_char_boundary_base_cost: Option<u64>,
1863 string_sub_string_base_cost: Option<u64>,
1864 string_sub_string_per_byte_cost: Option<u64>,
1865 string_index_of_base_cost: Option<u64>,
1866 string_index_of_per_byte_pattern_cost: Option<u64>,
1867 string_index_of_per_byte_searched_cost: Option<u64>,
1868
1869 vector_empty_base_cost: Option<u64>,
1870 vector_length_base_cost: Option<u64>,
1871 vector_push_back_base_cost: Option<u64>,
1872 vector_push_back_legacy_per_abstract_memory_unit_cost: Option<u64>,
1873 vector_borrow_base_cost: Option<u64>,
1874 vector_pop_back_base_cost: Option<u64>,
1875 vector_destroy_empty_base_cost: Option<u64>,
1876 vector_swap_base_cost: Option<u64>,
1877 debug_print_base_cost: Option<u64>,
1878 debug_print_stack_trace_base_cost: Option<u64>,
1879
1880 execution_version: Option<u64>,
1889
1890 consensus_bad_nodes_stake_threshold: Option<u64>,
1894
1895 max_jwk_votes_per_validator_per_epoch: Option<u64>,
1896 max_age_of_jwk_in_epochs: Option<u64>,
1900
1901 random_beacon_reduction_allowed_delta: Option<u16>,
1905
1906 random_beacon_reduction_lower_bound: Option<u32>,
1909
1910 random_beacon_dkg_timeout_round: Option<u32>,
1913
1914 random_beacon_min_round_interval_ms: Option<u64>,
1916
1917 random_beacon_dkg_version: Option<u64>,
1920
1921 consensus_max_transaction_size_bytes: Option<u64>,
1924 consensus_max_transactions_in_block_bytes: Option<u64>,
1926 consensus_max_num_transactions_in_block: Option<u64>,
1928
1929 consensus_voting_rounds: Option<u32>,
1931
1932 max_accumulated_txn_cost_per_object_in_narwhal_commit: Option<u64>,
1934
1935 max_deferral_rounds_for_congestion_control: Option<u64>,
1938
1939 max_txn_cost_overage_per_object_in_commit: Option<u64>,
1941
1942 allowed_txn_cost_overage_burst_per_object_in_commit: Option<u64>,
1944
1945 min_checkpoint_interval_ms: Option<u64>,
1947
1948 checkpoint_summary_version_specific_data: Option<u64>,
1950
1951 max_soft_bundle_size: Option<u64>,
1953
1954 bridge_should_try_to_finalize_committee: Option<bool>,
1958
1959 max_accumulated_txn_cost_per_object_in_mysticeti_commit: Option<u64>,
1965
1966 max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit: Option<u64>,
1969
1970 consensus_gc_depth: Option<u32>,
1973
1974 gas_budget_based_txn_cost_cap_factor: Option<u64>,
1976
1977 gas_budget_based_txn_cost_absolute_cap_commit_count: Option<u64>,
1979
1980 sip_45_consensus_amplification_threshold: Option<u64>,
1983
1984 use_object_per_epoch_marker_table_v2: Option<bool>,
1987
1988 consensus_commit_rate_estimation_window_size: Option<u32>,
1990
1991 #[serde(skip_serializing_if = "Vec::is_empty")]
1995 aliased_addresses: Vec<AliasedAddress>,
1996
1997 translation_per_command_base_charge: Option<u64>,
2000
2001 translation_per_input_base_charge: Option<u64>,
2004
2005 translation_pure_input_per_byte_charge: Option<u64>,
2007
2008 translation_per_type_node_charge: Option<u64>,
2012
2013 translation_per_reference_node_charge: Option<u64>,
2016
2017 translation_per_linkage_entry_charge: Option<u64>,
2020
2021 max_updates_per_settlement_txn: Option<u32>,
2023
2024 gasless_max_computation_units: Option<u64>,
2026
2027 gasless_allowed_token_types: Option<Vec<(String, u64)>>,
2029
2030 gasless_max_unused_inputs: Option<u64>,
2034
2035 gasless_max_pure_input_bytes: Option<u64>,
2038
2039 gasless_max_tps: Option<u64>,
2041
2042 #[serde(skip_serializing_if = "Option::is_none")]
2043 #[skip_accessor]
2044 include_special_package_amendments: Option<Arc<Amendments>>,
2045
2046 gasless_max_tx_size_bytes: Option<u64>,
2049}
2050
2051#[derive(Clone, Serialize, Deserialize, Debug)]
2053pub struct AliasedAddress {
2054 pub original: [u8; 32],
2056 pub aliased: [u8; 32],
2058 pub allowed_tx_digests: Vec<[u8; 32]>,
2060}
2061
2062impl ProtocolConfig {
2064 pub fn chain(&self) -> Chain {
2066 self.chain
2067 }
2068
2069 pub fn check_package_upgrades_supported(&self) -> Result<(), Error> {
2082 if self.feature_flags.package_upgrades {
2083 Ok(())
2084 } else {
2085 Err(Error(format!(
2086 "package upgrades are not supported at {:?}",
2087 self.version
2088 )))
2089 }
2090 }
2091
2092 pub fn allow_receiving_object_id(&self) -> bool {
2093 self.feature_flags.allow_receiving_object_id
2094 }
2095
2096 pub fn receiving_objects_supported(&self) -> bool {
2097 self.feature_flags.receive_objects
2098 }
2099
2100 pub fn package_upgrades_supported(&self) -> bool {
2101 self.feature_flags.package_upgrades
2102 }
2103
2104 pub fn check_commit_root_state_digest_supported(&self) -> bool {
2105 self.feature_flags.commit_root_state_digest
2106 }
2107
2108 pub fn get_advance_epoch_start_time_in_safe_mode(&self) -> bool {
2109 self.feature_flags.advance_epoch_start_time_in_safe_mode
2110 }
2111
2112 pub fn loaded_child_objects_fixed(&self) -> bool {
2113 self.feature_flags.loaded_child_objects_fixed
2114 }
2115
2116 pub fn missing_type_is_compatibility_error(&self) -> bool {
2117 self.feature_flags.missing_type_is_compatibility_error
2118 }
2119
2120 pub fn scoring_decision_with_validity_cutoff(&self) -> bool {
2121 self.feature_flags.scoring_decision_with_validity_cutoff
2122 }
2123
2124 pub fn narwhal_versioned_metadata(&self) -> bool {
2125 self.feature_flags.narwhal_versioned_metadata
2126 }
2127
2128 pub fn consensus_order_end_of_epoch_last(&self) -> bool {
2129 self.feature_flags.consensus_order_end_of_epoch_last
2130 }
2131
2132 pub fn disallow_adding_abilities_on_upgrade(&self) -> bool {
2133 self.feature_flags.disallow_adding_abilities_on_upgrade
2134 }
2135
2136 pub fn disable_invariant_violation_check_in_swap_loc(&self) -> bool {
2137 self.feature_flags
2138 .disable_invariant_violation_check_in_swap_loc
2139 }
2140
2141 pub fn advance_to_highest_supported_protocol_version(&self) -> bool {
2142 self.feature_flags
2143 .advance_to_highest_supported_protocol_version
2144 }
2145
2146 pub fn ban_entry_init(&self) -> bool {
2147 self.feature_flags.ban_entry_init
2148 }
2149
2150 pub fn package_digest_hash_module(&self) -> bool {
2151 self.feature_flags.package_digest_hash_module
2152 }
2153
2154 pub fn disallow_change_struct_type_params_on_upgrade(&self) -> bool {
2155 self.feature_flags
2156 .disallow_change_struct_type_params_on_upgrade
2157 }
2158
2159 pub fn no_extraneous_module_bytes(&self) -> bool {
2160 self.feature_flags.no_extraneous_module_bytes
2161 }
2162
2163 pub fn zklogin_auth(&self) -> bool {
2164 self.feature_flags.zklogin_auth
2165 }
2166
2167 pub fn zklogin_supported_providers(&self) -> &BTreeSet<String> {
2168 &self.feature_flags.zklogin_supported_providers
2169 }
2170
2171 pub fn consensus_transaction_ordering(&self) -> ConsensusTransactionOrdering {
2172 self.feature_flags.consensus_transaction_ordering
2173 }
2174
2175 pub fn simplified_unwrap_then_delete(&self) -> bool {
2176 self.feature_flags.simplified_unwrap_then_delete
2177 }
2178
2179 pub fn supports_upgraded_multisig(&self) -> bool {
2180 self.feature_flags.upgraded_multisig_supported
2181 }
2182
2183 pub fn txn_base_cost_as_multiplier(&self) -> bool {
2184 self.feature_flags.txn_base_cost_as_multiplier
2185 }
2186
2187 pub fn shared_object_deletion(&self) -> bool {
2188 self.feature_flags.shared_object_deletion
2189 }
2190
2191 pub fn narwhal_new_leader_election_schedule(&self) -> bool {
2192 self.feature_flags.narwhal_new_leader_election_schedule
2193 }
2194
2195 pub fn loaded_child_object_format(&self) -> bool {
2196 self.feature_flags.loaded_child_object_format
2197 }
2198
2199 pub fn enable_jwk_consensus_updates(&self) -> bool {
2200 let ret = self.feature_flags.enable_jwk_consensus_updates;
2201 if ret {
2202 assert!(self.feature_flags.end_of_epoch_transaction_supported);
2204 }
2205 ret
2206 }
2207
2208 pub fn simple_conservation_checks(&self) -> bool {
2209 self.feature_flags.simple_conservation_checks
2210 }
2211
2212 pub fn loaded_child_object_format_type(&self) -> bool {
2213 self.feature_flags.loaded_child_object_format_type
2214 }
2215
2216 pub fn end_of_epoch_transaction_supported(&self) -> bool {
2217 let ret = self.feature_flags.end_of_epoch_transaction_supported;
2218 if !ret {
2219 assert!(!self.feature_flags.enable_jwk_consensus_updates);
2221 }
2222 ret
2223 }
2224
2225 pub fn recompute_has_public_transfer_in_execution(&self) -> bool {
2226 self.feature_flags
2227 .recompute_has_public_transfer_in_execution
2228 }
2229
2230 pub fn create_authenticator_state_in_genesis(&self) -> bool {
2232 self.enable_jwk_consensus_updates()
2233 }
2234
2235 pub fn random_beacon(&self) -> bool {
2236 self.feature_flags.random_beacon
2237 }
2238
2239 pub fn dkg_version(&self) -> u64 {
2240 self.random_beacon_dkg_version.unwrap_or(1)
2242 }
2243
2244 pub fn enable_bridge(&self) -> bool {
2245 let ret = self.feature_flags.bridge;
2246 if ret {
2247 assert!(self.feature_flags.end_of_epoch_transaction_supported);
2249 }
2250 ret
2251 }
2252
2253 pub fn should_try_to_finalize_bridge_committee(&self) -> bool {
2254 if !self.enable_bridge() {
2255 return false;
2256 }
2257 self.bridge_should_try_to_finalize_committee.unwrap_or(true)
2259 }
2260
2261 pub fn enable_effects_v2(&self) -> bool {
2262 self.feature_flags.enable_effects_v2
2263 }
2264
2265 pub fn narwhal_certificate_v2(&self) -> bool {
2266 self.feature_flags.narwhal_certificate_v2
2267 }
2268
2269 pub fn verify_legacy_zklogin_address(&self) -> bool {
2270 self.feature_flags.verify_legacy_zklogin_address
2271 }
2272
2273 pub fn accept_zklogin_in_multisig(&self) -> bool {
2274 self.feature_flags.accept_zklogin_in_multisig
2275 }
2276
2277 pub fn accept_passkey_in_multisig(&self) -> bool {
2278 self.feature_flags.accept_passkey_in_multisig
2279 }
2280
2281 pub fn validate_zklogin_public_identifier(&self) -> bool {
2282 self.feature_flags.validate_zklogin_public_identifier
2283 }
2284
2285 pub fn zklogin_max_epoch_upper_bound_delta(&self) -> Option<u64> {
2286 self.feature_flags.zklogin_max_epoch_upper_bound_delta
2287 }
2288
2289 pub fn throughput_aware_consensus_submission(&self) -> bool {
2290 self.feature_flags.throughput_aware_consensus_submission
2291 }
2292
2293 pub fn include_consensus_digest_in_prologue(&self) -> bool {
2294 self.feature_flags.include_consensus_digest_in_prologue
2295 }
2296
2297 pub fn record_consensus_determined_version_assignments_in_prologue(&self) -> bool {
2298 self.feature_flags
2299 .record_consensus_determined_version_assignments_in_prologue
2300 }
2301
2302 pub fn record_additional_state_digest_in_prologue(&self) -> bool {
2303 self.feature_flags
2304 .record_additional_state_digest_in_prologue
2305 }
2306
2307 pub fn record_consensus_determined_version_assignments_in_prologue_v2(&self) -> bool {
2308 self.feature_flags
2309 .record_consensus_determined_version_assignments_in_prologue_v2
2310 }
2311
2312 pub fn prepend_prologue_tx_in_consensus_commit_in_checkpoints(&self) -> bool {
2313 self.feature_flags
2314 .prepend_prologue_tx_in_consensus_commit_in_checkpoints
2315 }
2316
2317 pub fn hardened_otw_check(&self) -> bool {
2318 self.feature_flags.hardened_otw_check
2319 }
2320
2321 pub fn enable_poseidon(&self) -> bool {
2322 self.feature_flags.enable_poseidon
2323 }
2324
2325 pub fn enable_coin_deny_list_v1(&self) -> bool {
2326 self.feature_flags.enable_coin_deny_list
2327 }
2328
2329 pub fn enable_accumulators(&self) -> bool {
2330 self.feature_flags.enable_accumulators
2331 }
2332
2333 pub fn enable_coin_reservation_obj_refs(&self) -> bool {
2334 self.new_vm_enabled() && self.feature_flags.enable_coin_reservation_obj_refs
2335 }
2336
2337 pub fn create_root_accumulator_object(&self) -> bool {
2338 self.feature_flags.create_root_accumulator_object
2339 }
2340
2341 pub fn enable_address_balance_gas_payments(&self) -> bool {
2342 self.feature_flags.enable_address_balance_gas_payments
2343 }
2344
2345 pub fn address_balance_gas_check_rgp_at_signing(&self) -> bool {
2346 self.feature_flags.address_balance_gas_check_rgp_at_signing
2347 }
2348
2349 pub fn address_balance_gas_reject_gas_coin_arg(&self) -> bool {
2350 self.feature_flags.address_balance_gas_reject_gas_coin_arg
2351 }
2352
2353 pub fn enable_multi_epoch_transaction_expiration(&self) -> bool {
2354 self.feature_flags.enable_multi_epoch_transaction_expiration
2355 }
2356
2357 pub fn relax_valid_during_for_owned_inputs(&self) -> bool {
2358 self.feature_flags.relax_valid_during_for_owned_inputs
2359 }
2360
2361 pub fn enable_authenticated_event_streams(&self) -> bool {
2362 self.feature_flags.enable_authenticated_event_streams && self.enable_accumulators()
2363 }
2364
2365 pub fn enable_non_exclusive_writes(&self) -> bool {
2366 self.feature_flags.enable_non_exclusive_writes
2367 }
2368
2369 pub fn enable_coin_registry(&self) -> bool {
2370 self.feature_flags.enable_coin_registry
2371 }
2372
2373 pub fn enable_display_registry(&self) -> bool {
2374 self.feature_flags.enable_display_registry
2375 }
2376
2377 pub fn enable_coin_deny_list_v2(&self) -> bool {
2378 self.feature_flags.enable_coin_deny_list_v2
2379 }
2380
2381 pub fn enable_group_ops_native_functions(&self) -> bool {
2382 self.feature_flags.enable_group_ops_native_functions
2383 }
2384
2385 pub fn enable_group_ops_native_function_msm(&self) -> bool {
2386 self.feature_flags.enable_group_ops_native_function_msm
2387 }
2388
2389 pub fn enable_ristretto255_group_ops(&self) -> bool {
2390 self.feature_flags.enable_ristretto255_group_ops
2391 }
2392
2393 pub fn enable_verify_bulletproofs_ristretto255(&self) -> bool {
2394 self.feature_flags.enable_verify_bulletproofs_ristretto255
2395 }
2396
2397 pub fn reject_mutable_random_on_entry_functions(&self) -> bool {
2398 self.feature_flags.reject_mutable_random_on_entry_functions
2399 }
2400
2401 pub fn per_object_congestion_control_mode(&self) -> PerObjectCongestionControlMode {
2402 self.feature_flags.per_object_congestion_control_mode
2403 }
2404
2405 pub fn consensus_choice(&self) -> ConsensusChoice {
2406 self.feature_flags.consensus_choice
2407 }
2408
2409 pub fn consensus_network(&self) -> ConsensusNetwork {
2410 self.feature_flags.consensus_network
2411 }
2412
2413 pub fn correct_gas_payment_limit_check(&self) -> bool {
2414 self.feature_flags.correct_gas_payment_limit_check
2415 }
2416
2417 pub fn reshare_at_same_initial_version(&self) -> bool {
2418 self.feature_flags.reshare_at_same_initial_version
2419 }
2420
2421 pub fn resolve_abort_locations_to_package_id(&self) -> bool {
2422 self.feature_flags.resolve_abort_locations_to_package_id
2423 }
2424
2425 pub fn mysticeti_use_committed_subdag_digest(&self) -> bool {
2426 self.feature_flags.mysticeti_use_committed_subdag_digest
2427 }
2428
2429 pub fn enable_vdf(&self) -> bool {
2430 self.feature_flags.enable_vdf
2431 }
2432
2433 pub fn fresh_vm_on_framework_upgrade(&self) -> bool {
2434 self.feature_flags.fresh_vm_on_framework_upgrade
2435 }
2436
2437 pub fn mysticeti_num_leaders_per_round(&self) -> Option<usize> {
2438 self.feature_flags.mysticeti_num_leaders_per_round
2439 }
2440
2441 pub fn soft_bundle(&self) -> bool {
2442 self.feature_flags.soft_bundle
2443 }
2444
2445 pub fn passkey_auth(&self) -> bool {
2446 self.feature_flags.passkey_auth
2447 }
2448
2449 pub fn authority_capabilities_v2(&self) -> bool {
2450 self.feature_flags.authority_capabilities_v2
2451 }
2452
2453 pub fn max_transaction_size_bytes(&self) -> u64 {
2454 self.consensus_max_transaction_size_bytes
2456 .unwrap_or(256 * 1024)
2457 }
2458
2459 pub fn max_transactions_in_block_bytes(&self) -> u64 {
2460 if cfg!(msim) {
2461 256 * 1024
2462 } else {
2463 self.consensus_max_transactions_in_block_bytes
2464 .unwrap_or(512 * 1024)
2465 }
2466 }
2467
2468 pub fn max_num_transactions_in_block(&self) -> u64 {
2469 if cfg!(msim) {
2470 8
2471 } else {
2472 self.consensus_max_num_transactions_in_block.unwrap_or(512)
2473 }
2474 }
2475
2476 pub fn rethrow_serialization_type_layout_errors(&self) -> bool {
2477 self.feature_flags.rethrow_serialization_type_layout_errors
2478 }
2479
2480 pub fn consensus_distributed_vote_scoring_strategy(&self) -> bool {
2481 self.feature_flags
2482 .consensus_distributed_vote_scoring_strategy
2483 }
2484
2485 pub fn consensus_round_prober(&self) -> bool {
2486 self.feature_flags.consensus_round_prober
2487 }
2488
2489 pub fn validate_identifier_inputs(&self) -> bool {
2490 self.feature_flags.validate_identifier_inputs
2491 }
2492
2493 pub fn gc_depth(&self) -> u32 {
2494 self.consensus_gc_depth.unwrap_or(0)
2495 }
2496
2497 pub fn mysticeti_fastpath(&self) -> bool {
2498 self.feature_flags.mysticeti_fastpath
2499 }
2500
2501 pub fn relocate_event_module(&self) -> bool {
2502 self.feature_flags.relocate_event_module
2503 }
2504
2505 pub fn uncompressed_g1_group_elements(&self) -> bool {
2506 self.feature_flags.uncompressed_g1_group_elements
2507 }
2508
2509 pub fn disallow_new_modules_in_deps_only_packages(&self) -> bool {
2510 self.feature_flags
2511 .disallow_new_modules_in_deps_only_packages
2512 }
2513
2514 pub fn consensus_smart_ancestor_selection(&self) -> bool {
2515 self.feature_flags.consensus_smart_ancestor_selection
2516 }
2517
2518 pub fn disable_preconsensus_locking(&self) -> bool {
2519 self.feature_flags.disable_preconsensus_locking
2520 }
2521
2522 pub fn consensus_round_prober_probe_accepted_rounds(&self) -> bool {
2523 self.feature_flags
2524 .consensus_round_prober_probe_accepted_rounds
2525 }
2526
2527 pub fn native_charging_v2(&self) -> bool {
2528 self.feature_flags.native_charging_v2
2529 }
2530
2531 pub fn consensus_linearize_subdag_v2(&self) -> bool {
2532 let res = self.feature_flags.consensus_linearize_subdag_v2;
2533 assert!(
2534 !res || self.gc_depth() > 0,
2535 "The consensus linearize sub dag V2 requires GC to be enabled"
2536 );
2537 res
2538 }
2539
2540 pub fn consensus_median_based_commit_timestamp(&self) -> bool {
2541 let res = self.feature_flags.consensus_median_based_commit_timestamp;
2542 assert!(
2543 !res || self.gc_depth() > 0,
2544 "The consensus median based commit timestamp requires GC to be enabled"
2545 );
2546 res
2547 }
2548
2549 pub fn consensus_batched_block_sync(&self) -> bool {
2550 self.feature_flags.consensus_batched_block_sync
2551 }
2552
2553 pub fn convert_type_argument_error(&self) -> bool {
2554 self.feature_flags.convert_type_argument_error
2555 }
2556
2557 pub fn variant_nodes(&self) -> bool {
2558 self.feature_flags.variant_nodes
2559 }
2560
2561 pub fn consensus_zstd_compression(&self) -> bool {
2562 self.feature_flags.consensus_zstd_compression
2563 }
2564
2565 pub fn enable_nitro_attestation(&self) -> bool {
2566 self.feature_flags.enable_nitro_attestation
2567 }
2568
2569 pub fn enable_nitro_attestation_upgraded_parsing(&self) -> bool {
2570 self.feature_flags.enable_nitro_attestation_upgraded_parsing
2571 }
2572
2573 pub fn enable_nitro_attestation_all_nonzero_pcrs_parsing(&self) -> bool {
2574 self.feature_flags
2575 .enable_nitro_attestation_all_nonzero_pcrs_parsing
2576 }
2577
2578 pub fn enable_nitro_attestation_always_include_required_pcrs_parsing(&self) -> bool {
2579 self.feature_flags
2580 .enable_nitro_attestation_always_include_required_pcrs_parsing
2581 }
2582
2583 pub fn get_consensus_commit_rate_estimation_window_size(&self) -> u32 {
2584 self.consensus_commit_rate_estimation_window_size
2585 .unwrap_or(0)
2586 }
2587
2588 pub fn consensus_num_requested_prior_commits_at_startup(&self) -> u32 {
2589 let window_size = self.get_consensus_commit_rate_estimation_window_size();
2593 assert!(window_size == 0 || self.record_additional_state_digest_in_prologue());
2595 window_size
2596 }
2597
2598 pub fn minimize_child_object_mutations(&self) -> bool {
2599 self.feature_flags.minimize_child_object_mutations
2600 }
2601
2602 pub fn move_native_context(&self) -> bool {
2603 self.feature_flags.move_native_context
2604 }
2605
2606 pub fn normalize_ptb_arguments(&self) -> bool {
2607 self.feature_flags.normalize_ptb_arguments
2608 }
2609
2610 pub fn enforce_checkpoint_timestamp_monotonicity(&self) -> bool {
2611 self.feature_flags.enforce_checkpoint_timestamp_monotonicity
2612 }
2613
2614 pub fn max_ptb_value_size_v2(&self) -> bool {
2615 self.feature_flags.max_ptb_value_size_v2
2616 }
2617
2618 pub fn resolve_type_input_ids_to_defining_id(&self) -> bool {
2619 self.feature_flags.resolve_type_input_ids_to_defining_id
2620 }
2621
2622 pub fn enable_party_transfer(&self) -> bool {
2623 self.feature_flags.enable_party_transfer
2624 }
2625
2626 pub fn allow_unbounded_system_objects(&self) -> bool {
2627 self.feature_flags.allow_unbounded_system_objects
2628 }
2629
2630 pub fn type_tags_in_object_runtime(&self) -> bool {
2631 self.feature_flags.type_tags_in_object_runtime
2632 }
2633
2634 pub fn enable_ptb_execution_v2(&self) -> bool {
2635 self.feature_flags.enable_ptb_execution_v2
2636 }
2637
2638 pub fn better_adapter_type_resolution_errors(&self) -> bool {
2639 self.feature_flags.better_adapter_type_resolution_errors
2640 }
2641
2642 pub fn record_time_estimate_processed(&self) -> bool {
2643 self.feature_flags.record_time_estimate_processed
2644 }
2645
2646 pub fn ignore_execution_time_observations_after_certs_closed(&self) -> bool {
2647 self.feature_flags
2648 .ignore_execution_time_observations_after_certs_closed
2649 }
2650
2651 pub fn dependency_linkage_error(&self) -> bool {
2652 self.feature_flags.dependency_linkage_error
2653 }
2654
2655 pub fn additional_multisig_checks(&self) -> bool {
2656 self.feature_flags.additional_multisig_checks
2657 }
2658
2659 pub fn debug_fatal_on_move_invariant_violation(&self) -> bool {
2660 self.feature_flags.debug_fatal_on_move_invariant_violation
2661 }
2662
2663 pub fn allow_private_accumulator_entrypoints(&self) -> bool {
2664 self.feature_flags.allow_private_accumulator_entrypoints
2665 }
2666
2667 pub fn additional_consensus_digest_indirect_state(&self) -> bool {
2668 self.feature_flags
2669 .additional_consensus_digest_indirect_state
2670 }
2671
2672 pub fn check_for_init_during_upgrade(&self) -> bool {
2673 self.feature_flags.check_for_init_during_upgrade
2674 }
2675
2676 pub fn per_command_shared_object_transfer_rules(&self) -> bool {
2677 self.feature_flags.per_command_shared_object_transfer_rules
2678 }
2679
2680 pub fn consensus_checkpoint_signature_key_includes_digest(&self) -> bool {
2681 self.feature_flags
2682 .consensus_checkpoint_signature_key_includes_digest
2683 }
2684
2685 pub fn include_checkpoint_artifacts_digest_in_summary(&self) -> bool {
2686 self.feature_flags
2687 .include_checkpoint_artifacts_digest_in_summary
2688 }
2689
2690 pub fn use_mfp_txns_in_load_initial_object_debts(&self) -> bool {
2691 self.feature_flags.use_mfp_txns_in_load_initial_object_debts
2692 }
2693
2694 pub fn cancel_for_failed_dkg_early(&self) -> bool {
2695 self.feature_flags.cancel_for_failed_dkg_early
2696 }
2697
2698 pub fn always_advance_dkg_to_resolution(&self) -> bool {
2699 self.feature_flags.always_advance_dkg_to_resolution
2700 }
2701
2702 pub fn abstract_size_in_object_runtime(&self) -> bool {
2703 self.feature_flags.abstract_size_in_object_runtime
2704 }
2705
2706 pub fn object_runtime_charge_cache_load_gas(&self) -> bool {
2707 self.feature_flags.object_runtime_charge_cache_load_gas
2708 }
2709
2710 pub fn additional_borrow_checks(&self) -> bool {
2711 self.feature_flags.additional_borrow_checks
2712 }
2713
2714 pub fn use_new_commit_handler(&self) -> bool {
2715 self.feature_flags.use_new_commit_handler
2716 }
2717
2718 pub fn better_loader_errors(&self) -> bool {
2719 self.feature_flags.better_loader_errors
2720 }
2721
2722 pub fn generate_df_type_layouts(&self) -> bool {
2723 self.feature_flags.generate_df_type_layouts
2724 }
2725
2726 pub fn allow_references_in_ptbs(&self) -> bool {
2727 self.feature_flags.allow_references_in_ptbs
2728 }
2729
2730 pub fn private_generics_verifier_v2(&self) -> bool {
2731 self.feature_flags.private_generics_verifier_v2
2732 }
2733
2734 pub fn deprecate_global_storage_ops_during_deserialization(&self) -> bool {
2735 self.feature_flags
2736 .deprecate_global_storage_ops_during_deserialization
2737 }
2738
2739 pub fn enable_observation_chunking(&self) -> bool {
2740 matches!(self.feature_flags.per_object_congestion_control_mode,
2741 PerObjectCongestionControlMode::ExecutionTimeEstimate(ref params)
2742 if params.observations_chunk_size.is_some()
2743 )
2744 }
2745
2746 pub fn deprecate_global_storage_ops(&self) -> bool {
2747 self.feature_flags.deprecate_global_storage_ops
2748 }
2749
2750 pub fn normalize_depth_formula(&self) -> bool {
2751 self.feature_flags.normalize_depth_formula
2752 }
2753
2754 pub fn consensus_skip_gced_accept_votes(&self) -> bool {
2755 self.feature_flags.consensus_skip_gced_accept_votes
2756 }
2757
2758 pub fn include_cancelled_randomness_txns_in_prologue(&self) -> bool {
2759 self.feature_flags
2760 .include_cancelled_randomness_txns_in_prologue
2761 }
2762
2763 pub fn address_aliases(&self) -> bool {
2764 let address_aliases = self.feature_flags.address_aliases;
2765 assert!(
2766 !address_aliases || self.mysticeti_fastpath(),
2767 "Address aliases requires Mysticeti fastpath to be enabled"
2768 );
2769 if address_aliases {
2770 assert!(
2771 self.feature_flags.disable_preconsensus_locking,
2772 "Address aliases requires CertifiedTransaction to be disabled"
2773 );
2774 }
2775 address_aliases
2776 }
2777
2778 pub fn fix_checkpoint_signature_mapping(&self) -> bool {
2779 self.feature_flags.fix_checkpoint_signature_mapping
2780 }
2781
2782 pub fn enable_object_funds_withdraw(&self) -> bool {
2783 self.feature_flags.enable_object_funds_withdraw
2784 }
2785
2786 pub fn gas_rounding_halve_digits(&self) -> bool {
2787 self.feature_flags.gas_rounding_halve_digits
2788 }
2789
2790 pub fn flexible_tx_context_positions(&self) -> bool {
2791 self.feature_flags.flexible_tx_context_positions
2792 }
2793
2794 pub fn disable_entry_point_signature_check(&self) -> bool {
2795 self.feature_flags.disable_entry_point_signature_check
2796 }
2797
2798 pub fn consensus_skip_gced_blocks_in_direct_finalization(&self) -> bool {
2799 self.feature_flags
2800 .consensus_skip_gced_blocks_in_direct_finalization
2801 }
2802
2803 pub fn convert_withdrawal_compatibility_ptb_arguments(&self) -> bool {
2804 self.feature_flags
2805 .convert_withdrawal_compatibility_ptb_arguments
2806 }
2807
2808 pub fn restrict_hot_or_not_entry_functions(&self) -> bool {
2809 self.feature_flags.restrict_hot_or_not_entry_functions
2810 }
2811
2812 pub fn split_checkpoints_in_consensus_handler(&self) -> bool {
2813 self.feature_flags.split_checkpoints_in_consensus_handler
2814 }
2815
2816 pub fn consensus_always_accept_system_transactions(&self) -> bool {
2817 self.feature_flags
2818 .consensus_always_accept_system_transactions
2819 }
2820
2821 pub fn validator_metadata_verify_v2(&self) -> bool {
2822 self.feature_flags.validator_metadata_verify_v2
2823 }
2824
2825 pub fn defer_unpaid_amplification(&self) -> bool {
2826 self.feature_flags.defer_unpaid_amplification
2827 }
2828
2829 pub fn gasless_transaction_drop_safety(&self) -> bool {
2830 self.feature_flags.gasless_transaction_drop_safety
2831 }
2832
2833 pub fn new_vm_enabled(&self) -> bool {
2834 self.execution_version.is_some_and(|v| v >= 4)
2835 }
2836
2837 pub fn merge_randomness_into_checkpoint(&self) -> bool {
2838 self.feature_flags.merge_randomness_into_checkpoint
2839 }
2840
2841 pub fn use_coin_party_owner(&self) -> bool {
2842 self.feature_flags.use_coin_party_owner
2843 }
2844
2845 pub fn enable_gasless(&self) -> bool {
2846 self.feature_flags.enable_gasless
2847 }
2848
2849 pub fn gasless_verify_remaining_balance(&self) -> bool {
2850 self.feature_flags.gasless_verify_remaining_balance
2851 }
2852
2853 pub fn gasless_allowed_token_types(&self) -> &[(String, u64)] {
2854 debug_assert!(self.gasless_allowed_token_types.is_some());
2855 self.gasless_allowed_token_types.as_deref().unwrap_or(&[])
2856 }
2857
2858 pub fn get_gasless_max_unused_inputs(&self) -> u64 {
2859 self.gasless_max_unused_inputs.unwrap_or(u64::MAX)
2860 }
2861
2862 pub fn get_gasless_max_pure_input_bytes(&self) -> u64 {
2863 self.gasless_max_pure_input_bytes.unwrap_or(u64::MAX)
2864 }
2865
2866 pub fn get_gasless_max_tx_size_bytes(&self) -> u64 {
2867 self.gasless_max_tx_size_bytes.unwrap_or(u64::MAX)
2868 }
2869
2870 pub fn disallow_jump_orphans(&self) -> bool {
2871 self.feature_flags.disallow_jump_orphans
2872 }
2873
2874 pub fn early_return_receive_object_mismatched_type(&self) -> bool {
2875 self.feature_flags
2876 .early_return_receive_object_mismatched_type
2877 }
2878
2879 pub fn include_special_package_amendments_as_option(&self) -> &Option<Arc<Amendments>> {
2880 &self.include_special_package_amendments
2881 }
2882
2883 pub fn timestamp_based_epoch_close(&self) -> bool {
2884 self.feature_flags.timestamp_based_epoch_close
2885 }
2886
2887 pub fn limit_groth16_pvk_inputs(&self) -> bool {
2888 self.feature_flags.limit_groth16_pvk_inputs
2889 }
2890
2891 pub fn enforce_address_balance_change_invariant(&self) -> bool {
2892 self.feature_flags.enforce_address_balance_change_invariant
2893 }
2894
2895 pub fn granular_post_execution_checks(&self) -> bool {
2896 self.feature_flags.granular_post_execution_checks
2897 }
2898
2899 pub fn early_exit_on_iffw(&self) -> bool {
2900 self.feature_flags.early_exit_on_iffw
2901 }
2902}
2903
2904#[cfg(not(msim))]
2905static POISON_VERSION_METHODS: AtomicBool = AtomicBool::new(false);
2906
2907#[cfg(msim)]
2909thread_local! {
2910 static POISON_VERSION_METHODS: AtomicBool = AtomicBool::new(false);
2911}
2912
2913impl ProtocolConfig {
2915 pub fn get_for_version(version: ProtocolVersion, chain: Chain) -> Self {
2917 assert!(
2919 version >= ProtocolVersion::MIN,
2920 "Network protocol version is {:?}, but the minimum supported version by the binary is {:?}. Please upgrade the binary.",
2921 version,
2922 ProtocolVersion::MIN.0,
2923 );
2924 assert!(
2925 version <= ProtocolVersion::MAX_ALLOWED,
2926 "Network protocol version is {:?}, but the maximum supported version by the binary is {:?}. Please upgrade the binary.",
2927 version,
2928 ProtocolVersion::MAX_ALLOWED.0,
2929 );
2930
2931 let mut ret = Self::get_for_version_impl(version, chain);
2932 ret.version = version;
2933 ret.chain = chain;
2934
2935 ret = Self::apply_config_override(version, ret);
2936
2937 if std::env::var("SUI_PROTOCOL_CONFIG_OVERRIDE_ENABLE").is_ok() {
2938 warn!(
2939 "overriding ProtocolConfig settings with custom settings; this may break non-local networks"
2940 );
2941 let overrides: ProtocolConfigOptional =
2942 serde_env::from_env_with_prefix("SUI_PROTOCOL_CONFIG_OVERRIDE")
2943 .expect("failed to parse ProtocolConfig override env variables");
2944 overrides.apply_to(&mut ret);
2945 }
2946
2947 ret
2948 }
2949
2950 pub fn get_for_version_if_supported(version: ProtocolVersion, chain: Chain) -> Option<Self> {
2953 if version.0 >= ProtocolVersion::MIN.0 && version.0 <= ProtocolVersion::MAX_ALLOWED.0 {
2954 let mut ret = Self::get_for_version_impl(version, chain);
2955 ret.version = version;
2956 ret.chain = chain;
2957 ret = Self::apply_config_override(version, ret);
2958 Some(ret)
2959 } else {
2960 None
2961 }
2962 }
2963
2964 #[cfg(not(msim))]
2965 pub fn poison_get_for_min_version() {
2966 POISON_VERSION_METHODS.store(true, Ordering::Relaxed);
2967 }
2968
2969 #[cfg(not(msim))]
2970 fn load_poison_get_for_min_version() -> bool {
2971 POISON_VERSION_METHODS.load(Ordering::Relaxed)
2972 }
2973
2974 #[cfg(msim)]
2975 pub fn poison_get_for_min_version() {
2976 POISON_VERSION_METHODS.with(|p| p.store(true, Ordering::Relaxed));
2977 }
2978
2979 #[cfg(msim)]
2980 fn load_poison_get_for_min_version() -> bool {
2981 POISON_VERSION_METHODS.with(|p| p.load(Ordering::Relaxed))
2982 }
2983
2984 pub fn get_for_min_version() -> Self {
2987 if Self::load_poison_get_for_min_version() {
2988 panic!("get_for_min_version called on validator");
2989 }
2990 ProtocolConfig::get_for_version(ProtocolVersion::MIN, Chain::Unknown)
2991 }
2992
2993 #[allow(non_snake_case)]
3003 pub fn get_for_max_version_UNSAFE() -> Self {
3004 if Self::load_poison_get_for_min_version() {
3005 panic!("get_for_max_version_UNSAFE called on validator");
3006 }
3007 ProtocolConfig::get_for_version(ProtocolVersion::MAX, Chain::Unknown)
3008 }
3009
3010 fn get_for_version_impl(version: ProtocolVersion, chain: Chain) -> Self {
3011 #[cfg(msim)]
3012 {
3013 if version == ProtocolVersion::MAX_ALLOWED {
3015 let mut config = Self::get_for_version_impl(version - 1, Chain::Unknown);
3016 config.base_tx_cost_fixed = Some(config.base_tx_cost_fixed() + 1000);
3017 return config;
3018 }
3019 }
3020
3021 let mut cfg = Self {
3024 version,
3026 chain,
3027
3028 feature_flags: Default::default(),
3030
3031 max_tx_size_bytes: Some(128 * 1024),
3032 max_input_objects: Some(2048),
3034 max_serialized_tx_effects_size_bytes: Some(512 * 1024),
3035 max_serialized_tx_effects_size_bytes_system_tx: Some(512 * 1024 * 16),
3036 max_gas_payment_objects: Some(256),
3037 max_modules_in_publish: Some(128),
3038 max_package_dependencies: None,
3039 max_arguments: Some(512),
3040 max_type_arguments: Some(16),
3041 max_type_argument_depth: Some(16),
3042 max_pure_argument_size: Some(16 * 1024),
3043 max_programmable_tx_commands: Some(1024),
3044 move_binary_format_version: Some(6),
3045 min_move_binary_format_version: None,
3046 binary_module_handles: None,
3047 binary_struct_handles: None,
3048 binary_function_handles: None,
3049 binary_function_instantiations: None,
3050 binary_signatures: None,
3051 binary_constant_pool: None,
3052 binary_identifiers: None,
3053 binary_address_identifiers: None,
3054 binary_struct_defs: None,
3055 binary_struct_def_instantiations: None,
3056 binary_function_defs: None,
3057 binary_field_handles: None,
3058 binary_field_instantiations: None,
3059 binary_friend_decls: None,
3060 binary_enum_defs: None,
3061 binary_enum_def_instantiations: None,
3062 binary_variant_handles: None,
3063 binary_variant_instantiation_handles: None,
3064 max_move_object_size: Some(250 * 1024),
3065 max_move_package_size: Some(100 * 1024),
3066 max_publish_or_upgrade_per_ptb: None,
3067 max_tx_gas: Some(10_000_000_000),
3068 max_gas_price: Some(100_000),
3069 max_gas_price_rgp_factor_for_aborted_transactions: None,
3070 max_gas_computation_bucket: Some(5_000_000),
3071 max_loop_depth: Some(5),
3072 max_generic_instantiation_length: Some(32),
3073 max_function_parameters: Some(128),
3074 max_basic_blocks: Some(1024),
3075 max_value_stack_size: Some(1024),
3076 max_type_nodes: Some(256),
3077 max_generic_instantiation_type_nodes_per_function: None,
3078 max_generic_instantiation_type_nodes_per_module: None,
3079 max_push_size: Some(10000),
3080 max_struct_definitions: Some(200),
3081 max_function_definitions: Some(1000),
3082 max_fields_in_struct: Some(32),
3083 max_dependency_depth: Some(100),
3084 max_num_event_emit: Some(256),
3085 max_num_new_move_object_ids: Some(2048),
3086 max_num_new_move_object_ids_system_tx: Some(2048 * 16),
3087 max_num_deleted_move_object_ids: Some(2048),
3088 max_num_deleted_move_object_ids_system_tx: Some(2048 * 16),
3089 max_num_transferred_move_object_ids: Some(2048),
3090 max_num_transferred_move_object_ids_system_tx: Some(2048 * 16),
3091 max_event_emit_size: Some(250 * 1024),
3092 max_move_vector_len: Some(256 * 1024),
3093 max_type_to_layout_nodes: None,
3094 max_ptb_value_size: None,
3095
3096 max_back_edges_per_function: Some(10_000),
3097 max_back_edges_per_module: Some(10_000),
3098 max_verifier_meter_ticks_per_function: Some(6_000_000),
3099 max_meter_ticks_per_module: Some(6_000_000),
3100 max_meter_ticks_per_package: None,
3101
3102 object_runtime_max_num_cached_objects: Some(1000),
3103 object_runtime_max_num_cached_objects_system_tx: Some(1000 * 16),
3104 object_runtime_max_num_store_entries: Some(1000),
3105 object_runtime_max_num_store_entries_system_tx: Some(1000 * 16),
3106 base_tx_cost_fixed: Some(110_000),
3107 package_publish_cost_fixed: Some(1_000),
3108 base_tx_cost_per_byte: Some(0),
3109 package_publish_cost_per_byte: Some(80),
3110 obj_access_cost_read_per_byte: Some(15),
3111 obj_access_cost_mutate_per_byte: Some(40),
3112 obj_access_cost_delete_per_byte: Some(40),
3113 obj_access_cost_verify_per_byte: Some(200),
3114 obj_data_cost_refundable: Some(100),
3115 obj_metadata_cost_non_refundable: Some(50),
3116 gas_model_version: Some(1),
3117 storage_rebate_rate: Some(9900),
3118 storage_fund_reinvest_rate: Some(500),
3119 reward_slashing_rate: Some(5000),
3120 storage_gas_price: Some(1),
3121 accumulator_object_storage_cost: None,
3122 max_transactions_per_checkpoint: Some(10_000),
3123 max_checkpoint_size_bytes: Some(30 * 1024 * 1024),
3124
3125 buffer_stake_for_protocol_upgrade_bps: Some(0),
3128
3129 address_from_bytes_cost_base: Some(52),
3133 address_to_u256_cost_base: Some(52),
3135 address_from_u256_cost_base: Some(52),
3137
3138 config_read_setting_impl_cost_base: None,
3141 config_read_setting_impl_cost_per_byte: None,
3142
3143 dynamic_field_hash_type_and_key_cost_base: Some(100),
3146 dynamic_field_hash_type_and_key_type_cost_per_byte: Some(2),
3147 dynamic_field_hash_type_and_key_value_cost_per_byte: Some(2),
3148 dynamic_field_hash_type_and_key_type_tag_cost_per_byte: Some(2),
3149 dynamic_field_add_child_object_cost_base: Some(100),
3151 dynamic_field_add_child_object_type_cost_per_byte: Some(10),
3152 dynamic_field_add_child_object_value_cost_per_byte: Some(10),
3153 dynamic_field_add_child_object_struct_tag_cost_per_byte: Some(10),
3154 dynamic_field_borrow_child_object_cost_base: Some(100),
3156 dynamic_field_borrow_child_object_child_ref_cost_per_byte: Some(10),
3157 dynamic_field_borrow_child_object_type_cost_per_byte: Some(10),
3158 dynamic_field_remove_child_object_cost_base: Some(100),
3160 dynamic_field_remove_child_object_child_cost_per_byte: Some(2),
3161 dynamic_field_remove_child_object_type_cost_per_byte: Some(2),
3162 dynamic_field_has_child_object_cost_base: Some(100),
3164 dynamic_field_has_child_object_with_ty_cost_base: Some(100),
3166 dynamic_field_has_child_object_with_ty_type_cost_per_byte: Some(2),
3167 dynamic_field_has_child_object_with_ty_type_tag_cost_per_byte: Some(2),
3168
3169 event_emit_cost_base: Some(52),
3172 event_emit_value_size_derivation_cost_per_byte: Some(2),
3173 event_emit_tag_size_derivation_cost_per_byte: Some(5),
3174 event_emit_output_cost_per_byte: Some(10),
3175 event_emit_auth_stream_cost: None,
3176
3177 object_borrow_uid_cost_base: Some(52),
3180 object_delete_impl_cost_base: Some(52),
3182 object_record_new_uid_cost_base: Some(52),
3184
3185 transfer_transfer_internal_cost_base: Some(52),
3188 transfer_party_transfer_internal_cost_base: None,
3190 transfer_freeze_object_cost_base: Some(52),
3192 transfer_share_object_cost_base: Some(52),
3194 transfer_receive_object_cost_base: None,
3195 transfer_receive_object_type_cost_per_byte: None,
3196 transfer_receive_object_cost_per_byte: None,
3197
3198 tx_context_derive_id_cost_base: Some(52),
3201 tx_context_fresh_id_cost_base: None,
3202 tx_context_sender_cost_base: None,
3203 tx_context_epoch_cost_base: None,
3204 tx_context_epoch_timestamp_ms_cost_base: None,
3205 tx_context_sponsor_cost_base: None,
3206 tx_context_rgp_cost_base: None,
3207 tx_context_gas_price_cost_base: None,
3208 tx_context_gas_budget_cost_base: None,
3209 tx_context_ids_created_cost_base: None,
3210 tx_context_replace_cost_base: None,
3211
3212 types_is_one_time_witness_cost_base: Some(52),
3215 types_is_one_time_witness_type_tag_cost_per_byte: Some(2),
3216 types_is_one_time_witness_type_cost_per_byte: Some(2),
3217
3218 validator_validate_metadata_cost_base: Some(52),
3221 validator_validate_metadata_data_cost_per_byte: Some(2),
3222
3223 crypto_invalid_arguments_cost: Some(100),
3225 bls12381_bls12381_min_sig_verify_cost_base: Some(52),
3227 bls12381_bls12381_min_sig_verify_msg_cost_per_byte: Some(2),
3228 bls12381_bls12381_min_sig_verify_msg_cost_per_block: Some(2),
3229
3230 bls12381_bls12381_min_pk_verify_cost_base: Some(52),
3232 bls12381_bls12381_min_pk_verify_msg_cost_per_byte: Some(2),
3233 bls12381_bls12381_min_pk_verify_msg_cost_per_block: Some(2),
3234
3235 ecdsa_k1_ecrecover_keccak256_cost_base: Some(52),
3237 ecdsa_k1_ecrecover_keccak256_msg_cost_per_byte: Some(2),
3238 ecdsa_k1_ecrecover_keccak256_msg_cost_per_block: Some(2),
3239 ecdsa_k1_ecrecover_sha256_cost_base: Some(52),
3240 ecdsa_k1_ecrecover_sha256_msg_cost_per_byte: Some(2),
3241 ecdsa_k1_ecrecover_sha256_msg_cost_per_block: Some(2),
3242
3243 ecdsa_k1_decompress_pubkey_cost_base: Some(52),
3245
3246 ecdsa_k1_secp256k1_verify_keccak256_cost_base: Some(52),
3248 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_byte: Some(2),
3249 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_block: Some(2),
3250 ecdsa_k1_secp256k1_verify_sha256_cost_base: Some(52),
3251 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_byte: Some(2),
3252 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_block: Some(2),
3253
3254 ecdsa_r1_ecrecover_keccak256_cost_base: Some(52),
3256 ecdsa_r1_ecrecover_keccak256_msg_cost_per_byte: Some(2),
3257 ecdsa_r1_ecrecover_keccak256_msg_cost_per_block: Some(2),
3258 ecdsa_r1_ecrecover_sha256_cost_base: Some(52),
3259 ecdsa_r1_ecrecover_sha256_msg_cost_per_byte: Some(2),
3260 ecdsa_r1_ecrecover_sha256_msg_cost_per_block: Some(2),
3261
3262 ecdsa_r1_secp256r1_verify_keccak256_cost_base: Some(52),
3264 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_byte: Some(2),
3265 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_block: Some(2),
3266 ecdsa_r1_secp256r1_verify_sha256_cost_base: Some(52),
3267 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_byte: Some(2),
3268 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_block: Some(2),
3269
3270 ecvrf_ecvrf_verify_cost_base: Some(52),
3272 ecvrf_ecvrf_verify_alpha_string_cost_per_byte: Some(2),
3273 ecvrf_ecvrf_verify_alpha_string_cost_per_block: Some(2),
3274
3275 ed25519_ed25519_verify_cost_base: Some(52),
3277 ed25519_ed25519_verify_msg_cost_per_byte: Some(2),
3278 ed25519_ed25519_verify_msg_cost_per_block: Some(2),
3279
3280 groth16_prepare_verifying_key_bls12381_cost_base: Some(52),
3282 groth16_prepare_verifying_key_bn254_cost_base: Some(52),
3283
3284 groth16_verify_groth16_proof_internal_bls12381_cost_base: Some(52),
3286 groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input: Some(2),
3287 groth16_verify_groth16_proof_internal_bn254_cost_base: Some(52),
3288 groth16_verify_groth16_proof_internal_bn254_cost_per_public_input: Some(2),
3289 groth16_verify_groth16_proof_internal_public_input_cost_per_byte: Some(2),
3290
3291 hash_blake2b256_cost_base: Some(52),
3293 hash_blake2b256_data_cost_per_byte: Some(2),
3294 hash_blake2b256_data_cost_per_block: Some(2),
3295
3296 hash_keccak256_cost_base: Some(52),
3298 hash_keccak256_data_cost_per_byte: Some(2),
3299 hash_keccak256_data_cost_per_block: Some(2),
3300
3301 poseidon_bn254_cost_base: None,
3302 poseidon_bn254_cost_per_block: None,
3303
3304 hmac_hmac_sha3_256_cost_base: Some(52),
3306 hmac_hmac_sha3_256_input_cost_per_byte: Some(2),
3307 hmac_hmac_sha3_256_input_cost_per_block: Some(2),
3308
3309 group_ops_bls12381_decode_scalar_cost: None,
3311 group_ops_bls12381_decode_g1_cost: None,
3312 group_ops_bls12381_decode_g2_cost: None,
3313 group_ops_bls12381_decode_gt_cost: None,
3314 group_ops_bls12381_scalar_add_cost: None,
3315 group_ops_bls12381_g1_add_cost: None,
3316 group_ops_bls12381_g2_add_cost: None,
3317 group_ops_bls12381_gt_add_cost: None,
3318 group_ops_bls12381_scalar_sub_cost: None,
3319 group_ops_bls12381_g1_sub_cost: None,
3320 group_ops_bls12381_g2_sub_cost: None,
3321 group_ops_bls12381_gt_sub_cost: None,
3322 group_ops_bls12381_scalar_mul_cost: None,
3323 group_ops_bls12381_g1_mul_cost: None,
3324 group_ops_bls12381_g2_mul_cost: None,
3325 group_ops_bls12381_gt_mul_cost: None,
3326 group_ops_bls12381_scalar_div_cost: None,
3327 group_ops_bls12381_g1_div_cost: None,
3328 group_ops_bls12381_g2_div_cost: None,
3329 group_ops_bls12381_gt_div_cost: None,
3330 group_ops_bls12381_g1_hash_to_base_cost: None,
3331 group_ops_bls12381_g2_hash_to_base_cost: None,
3332 group_ops_bls12381_g1_hash_to_cost_per_byte: None,
3333 group_ops_bls12381_g2_hash_to_cost_per_byte: None,
3334 group_ops_bls12381_g1_msm_base_cost: None,
3335 group_ops_bls12381_g2_msm_base_cost: None,
3336 group_ops_bls12381_g1_msm_base_cost_per_input: None,
3337 group_ops_bls12381_g2_msm_base_cost_per_input: None,
3338 group_ops_bls12381_msm_max_len: None,
3339 group_ops_bls12381_pairing_cost: None,
3340 group_ops_bls12381_g1_to_uncompressed_g1_cost: None,
3341 group_ops_bls12381_uncompressed_g1_to_g1_cost: None,
3342 group_ops_bls12381_uncompressed_g1_sum_base_cost: None,
3343 group_ops_bls12381_uncompressed_g1_sum_cost_per_term: None,
3344 group_ops_bls12381_uncompressed_g1_sum_max_terms: None,
3345
3346 group_ops_ristretto_decode_scalar_cost: None,
3347 group_ops_ristretto_decode_point_cost: None,
3348 group_ops_ristretto_scalar_add_cost: None,
3349 group_ops_ristretto_point_add_cost: None,
3350 group_ops_ristretto_scalar_sub_cost: None,
3351 group_ops_ristretto_point_sub_cost: None,
3352 group_ops_ristretto_scalar_mul_cost: None,
3353 group_ops_ristretto_point_mul_cost: None,
3354 group_ops_ristretto_scalar_div_cost: None,
3355 group_ops_ristretto_point_div_cost: None,
3356
3357 verify_bulletproofs_ristretto255_base_cost: None,
3358 verify_bulletproofs_ristretto255_cost_per_bit_and_commitment: None,
3359
3360 check_zklogin_id_cost_base: None,
3362 check_zklogin_issuer_cost_base: None,
3364
3365 vdf_verify_vdf_cost: None,
3366 vdf_hash_to_input_cost: None,
3367
3368 nitro_attestation_parse_base_cost: None,
3370 nitro_attestation_parse_cost_per_byte: None,
3371 nitro_attestation_verify_base_cost: None,
3372 nitro_attestation_verify_cost_per_cert: None,
3373
3374 bcs_per_byte_serialized_cost: None,
3375 bcs_legacy_min_output_size_cost: None,
3376 bcs_failure_cost: None,
3377 hash_sha2_256_base_cost: None,
3378 hash_sha2_256_per_byte_cost: None,
3379 hash_sha2_256_legacy_min_input_len_cost: None,
3380 hash_sha3_256_base_cost: None,
3381 hash_sha3_256_per_byte_cost: None,
3382 hash_sha3_256_legacy_min_input_len_cost: None,
3383 type_name_get_base_cost: None,
3384 type_name_get_per_byte_cost: None,
3385 type_name_id_base_cost: None,
3386 string_check_utf8_base_cost: None,
3387 string_check_utf8_per_byte_cost: None,
3388 string_is_char_boundary_base_cost: None,
3389 string_sub_string_base_cost: None,
3390 string_sub_string_per_byte_cost: None,
3391 string_index_of_base_cost: None,
3392 string_index_of_per_byte_pattern_cost: None,
3393 string_index_of_per_byte_searched_cost: None,
3394 vector_empty_base_cost: None,
3395 vector_length_base_cost: None,
3396 vector_push_back_base_cost: None,
3397 vector_push_back_legacy_per_abstract_memory_unit_cost: None,
3398 vector_borrow_base_cost: None,
3399 vector_pop_back_base_cost: None,
3400 vector_destroy_empty_base_cost: None,
3401 vector_swap_base_cost: None,
3402 debug_print_base_cost: None,
3403 debug_print_stack_trace_base_cost: None,
3404
3405 max_size_written_objects: None,
3406 max_size_written_objects_system_tx: None,
3407
3408 max_move_identifier_len: None,
3415 max_move_value_depth: None,
3416 max_move_enum_variants: None,
3417
3418 gas_rounding_step: None,
3419
3420 execution_version: None,
3421
3422 max_event_emit_size_total: None,
3423
3424 consensus_bad_nodes_stake_threshold: None,
3425
3426 max_jwk_votes_per_validator_per_epoch: None,
3427
3428 max_age_of_jwk_in_epochs: None,
3429
3430 random_beacon_reduction_allowed_delta: None,
3431
3432 random_beacon_reduction_lower_bound: None,
3433
3434 random_beacon_dkg_timeout_round: None,
3435
3436 random_beacon_min_round_interval_ms: None,
3437
3438 random_beacon_dkg_version: None,
3439
3440 consensus_max_transaction_size_bytes: None,
3441
3442 consensus_max_transactions_in_block_bytes: None,
3443
3444 consensus_max_num_transactions_in_block: None,
3445
3446 consensus_voting_rounds: None,
3447
3448 max_accumulated_txn_cost_per_object_in_narwhal_commit: None,
3449
3450 max_deferral_rounds_for_congestion_control: None,
3451
3452 max_txn_cost_overage_per_object_in_commit: None,
3453
3454 allowed_txn_cost_overage_burst_per_object_in_commit: None,
3455
3456 min_checkpoint_interval_ms: None,
3457
3458 checkpoint_summary_version_specific_data: None,
3459
3460 max_soft_bundle_size: None,
3461
3462 bridge_should_try_to_finalize_committee: None,
3463
3464 max_accumulated_txn_cost_per_object_in_mysticeti_commit: None,
3465
3466 max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit: None,
3467
3468 consensus_gc_depth: None,
3469
3470 gas_budget_based_txn_cost_cap_factor: None,
3471
3472 gas_budget_based_txn_cost_absolute_cap_commit_count: None,
3473
3474 sip_45_consensus_amplification_threshold: None,
3475
3476 use_object_per_epoch_marker_table_v2: None,
3477
3478 consensus_commit_rate_estimation_window_size: None,
3479
3480 aliased_addresses: vec![],
3481
3482 translation_per_command_base_charge: None,
3483 translation_per_input_base_charge: None,
3484 translation_pure_input_per_byte_charge: None,
3485 translation_per_type_node_charge: None,
3486 translation_per_reference_node_charge: None,
3487 translation_per_linkage_entry_charge: None,
3488
3489 max_updates_per_settlement_txn: None,
3490
3491 gasless_max_computation_units: None,
3492 gasless_allowed_token_types: None,
3493 gasless_max_unused_inputs: None,
3494 gasless_max_pure_input_bytes: None,
3495 gasless_max_tps: None,
3496 include_special_package_amendments: None,
3497 gasless_max_tx_size_bytes: None,
3498 };
3501 for cur in 2..=version.0 {
3502 match cur {
3503 1 => unreachable!(),
3504 2 => {
3505 cfg.feature_flags.advance_epoch_start_time_in_safe_mode = true;
3506 }
3507 3 => {
3508 cfg.gas_model_version = Some(2);
3510 cfg.max_tx_gas = Some(50_000_000_000);
3512 cfg.base_tx_cost_fixed = Some(2_000);
3514 cfg.storage_gas_price = Some(76);
3516 cfg.feature_flags.loaded_child_objects_fixed = true;
3517 cfg.max_size_written_objects = Some(5 * 1000 * 1000);
3520 cfg.max_size_written_objects_system_tx = Some(50 * 1000 * 1000);
3523 cfg.feature_flags.package_upgrades = true;
3524 }
3525 4 => {
3530 cfg.reward_slashing_rate = Some(10000);
3532 cfg.gas_model_version = Some(3);
3534 }
3535 5 => {
3536 cfg.feature_flags.missing_type_is_compatibility_error = true;
3537 cfg.gas_model_version = Some(4);
3538 cfg.feature_flags.scoring_decision_with_validity_cutoff = true;
3539 }
3543 6 => {
3544 cfg.gas_model_version = Some(5);
3545 cfg.buffer_stake_for_protocol_upgrade_bps = Some(5000);
3546 cfg.feature_flags.consensus_order_end_of_epoch_last = true;
3547 }
3548 7 => {
3549 cfg.feature_flags.disallow_adding_abilities_on_upgrade = true;
3550 cfg.feature_flags
3551 .disable_invariant_violation_check_in_swap_loc = true;
3552 cfg.feature_flags.ban_entry_init = true;
3553 cfg.feature_flags.package_digest_hash_module = true;
3554 }
3555 8 => {
3556 cfg.feature_flags
3557 .disallow_change_struct_type_params_on_upgrade = true;
3558 }
3559 9 => {
3560 cfg.max_move_identifier_len = Some(128);
3562 cfg.feature_flags.no_extraneous_module_bytes = true;
3563 cfg.feature_flags
3564 .advance_to_highest_supported_protocol_version = true;
3565 }
3566 10 => {
3567 cfg.max_verifier_meter_ticks_per_function = Some(16_000_000);
3568 cfg.max_meter_ticks_per_module = Some(16_000_000);
3569 }
3570 11 => {
3571 cfg.max_move_value_depth = Some(128);
3572 }
3573 12 => {
3574 cfg.feature_flags.narwhal_versioned_metadata = true;
3575 if chain != Chain::Mainnet {
3576 cfg.feature_flags.commit_root_state_digest = true;
3577 }
3578
3579 if chain != Chain::Mainnet && chain != Chain::Testnet {
3580 cfg.feature_flags.zklogin_auth = true;
3581 }
3582 }
3583 13 => {}
3584 14 => {
3585 cfg.gas_rounding_step = Some(1_000);
3586 cfg.gas_model_version = Some(6);
3587 }
3588 15 => {
3589 cfg.feature_flags.consensus_transaction_ordering =
3590 ConsensusTransactionOrdering::ByGasPrice;
3591 }
3592 16 => {
3593 cfg.feature_flags.simplified_unwrap_then_delete = true;
3594 }
3595 17 => {
3596 cfg.feature_flags.upgraded_multisig_supported = true;
3597 }
3598 18 => {
3599 cfg.execution_version = Some(1);
3600 cfg.feature_flags.txn_base_cost_as_multiplier = true;
3609 cfg.base_tx_cost_fixed = Some(1_000);
3611 }
3612 19 => {
3613 cfg.max_num_event_emit = Some(1024);
3614 cfg.max_event_emit_size_total = Some(
3617 256 * 250 * 1024, );
3619 }
3620 20 => {
3621 cfg.feature_flags.commit_root_state_digest = true;
3622
3623 if chain != Chain::Mainnet {
3624 cfg.feature_flags.narwhal_new_leader_election_schedule = true;
3625 cfg.consensus_bad_nodes_stake_threshold = Some(20);
3626 }
3627 }
3628
3629 21 => {
3630 if chain != Chain::Mainnet {
3631 cfg.feature_flags.zklogin_supported_providers = BTreeSet::from([
3632 "Google".to_string(),
3633 "Facebook".to_string(),
3634 "Twitch".to_string(),
3635 ]);
3636 }
3637 }
3638 22 => {
3639 cfg.feature_flags.loaded_child_object_format = true;
3640 }
3641 23 => {
3642 cfg.feature_flags.loaded_child_object_format_type = true;
3643 cfg.feature_flags.narwhal_new_leader_election_schedule = true;
3644 cfg.consensus_bad_nodes_stake_threshold = Some(20);
3650 }
3651 24 => {
3652 cfg.feature_flags.simple_conservation_checks = true;
3653 cfg.max_publish_or_upgrade_per_ptb = Some(5);
3654
3655 cfg.feature_flags.end_of_epoch_transaction_supported = true;
3656
3657 if chain != Chain::Mainnet {
3658 cfg.feature_flags.enable_jwk_consensus_updates = true;
3659 cfg.max_jwk_votes_per_validator_per_epoch = Some(240);
3661 cfg.max_age_of_jwk_in_epochs = Some(1);
3662 }
3663 }
3664 25 => {
3665 cfg.feature_flags.zklogin_supported_providers = BTreeSet::from([
3667 "Google".to_string(),
3668 "Facebook".to_string(),
3669 "Twitch".to_string(),
3670 ]);
3671 cfg.feature_flags.zklogin_auth = true;
3672
3673 cfg.feature_flags.enable_jwk_consensus_updates = true;
3675 cfg.max_jwk_votes_per_validator_per_epoch = Some(240);
3676 cfg.max_age_of_jwk_in_epochs = Some(1);
3677 }
3678 26 => {
3679 cfg.gas_model_version = Some(7);
3680 if chain != Chain::Mainnet && chain != Chain::Testnet {
3682 cfg.transfer_receive_object_cost_base = Some(52);
3683 cfg.feature_flags.receive_objects = true;
3684 }
3685 }
3686 27 => {
3687 cfg.gas_model_version = Some(8);
3688 }
3689 28 => {
3690 cfg.check_zklogin_id_cost_base = Some(200);
3692 cfg.check_zklogin_issuer_cost_base = Some(200);
3694
3695 if chain != Chain::Mainnet && chain != Chain::Testnet {
3697 cfg.feature_flags.enable_effects_v2 = true;
3698 }
3699 }
3700 29 => {
3701 cfg.feature_flags.verify_legacy_zklogin_address = true;
3702 }
3703 30 => {
3704 if chain != Chain::Mainnet {
3706 cfg.feature_flags.narwhal_certificate_v2 = true;
3707 }
3708
3709 cfg.random_beacon_reduction_allowed_delta = Some(800);
3710 if chain != Chain::Mainnet {
3712 cfg.feature_flags.enable_effects_v2 = true;
3713 }
3714
3715 cfg.feature_flags.zklogin_supported_providers = BTreeSet::default();
3719
3720 cfg.feature_flags.recompute_has_public_transfer_in_execution = true;
3721 }
3722 31 => {
3723 cfg.execution_version = Some(2);
3724 if chain != Chain::Mainnet && chain != Chain::Testnet {
3726 cfg.feature_flags.shared_object_deletion = true;
3727 }
3728 }
3729 32 => {
3730 if chain != Chain::Mainnet {
3732 cfg.feature_flags.accept_zklogin_in_multisig = true;
3733 }
3734 if chain != Chain::Mainnet {
3736 cfg.transfer_receive_object_cost_base = Some(52);
3737 cfg.feature_flags.receive_objects = true;
3738 }
3739 if chain != Chain::Mainnet && chain != Chain::Testnet {
3741 cfg.feature_flags.random_beacon = true;
3742 cfg.random_beacon_reduction_lower_bound = Some(1600);
3743 cfg.random_beacon_dkg_timeout_round = Some(3000);
3744 cfg.random_beacon_min_round_interval_ms = Some(150);
3745 }
3746 if chain != Chain::Testnet && chain != Chain::Mainnet {
3748 cfg.feature_flags.include_consensus_digest_in_prologue = true;
3749 }
3750
3751 cfg.feature_flags.narwhal_certificate_v2 = true;
3753 }
3754 33 => {
3755 cfg.feature_flags.hardened_otw_check = true;
3756 cfg.feature_flags.allow_receiving_object_id = true;
3757
3758 cfg.transfer_receive_object_cost_base = Some(52);
3760 cfg.feature_flags.receive_objects = true;
3761
3762 if chain != Chain::Mainnet {
3764 cfg.feature_flags.shared_object_deletion = true;
3765 }
3766
3767 cfg.feature_flags.enable_effects_v2 = true;
3768 }
3769 34 => {}
3770 35 => {
3771 if chain != Chain::Mainnet && chain != Chain::Testnet {
3773 cfg.feature_flags.enable_poseidon = true;
3774 cfg.poseidon_bn254_cost_base = Some(260);
3775 cfg.poseidon_bn254_cost_per_block = Some(10);
3776 }
3777
3778 cfg.feature_flags.enable_coin_deny_list = true;
3779 }
3780 36 => {
3781 if chain != Chain::Mainnet && chain != Chain::Testnet {
3783 cfg.feature_flags.enable_group_ops_native_functions = true;
3784 cfg.feature_flags.enable_group_ops_native_function_msm = true;
3785 cfg.group_ops_bls12381_decode_scalar_cost = Some(52);
3787 cfg.group_ops_bls12381_decode_g1_cost = Some(52);
3788 cfg.group_ops_bls12381_decode_g2_cost = Some(52);
3789 cfg.group_ops_bls12381_decode_gt_cost = Some(52);
3790 cfg.group_ops_bls12381_scalar_add_cost = Some(52);
3791 cfg.group_ops_bls12381_g1_add_cost = Some(52);
3792 cfg.group_ops_bls12381_g2_add_cost = Some(52);
3793 cfg.group_ops_bls12381_gt_add_cost = Some(52);
3794 cfg.group_ops_bls12381_scalar_sub_cost = Some(52);
3795 cfg.group_ops_bls12381_g1_sub_cost = Some(52);
3796 cfg.group_ops_bls12381_g2_sub_cost = Some(52);
3797 cfg.group_ops_bls12381_gt_sub_cost = Some(52);
3798 cfg.group_ops_bls12381_scalar_mul_cost = Some(52);
3799 cfg.group_ops_bls12381_g1_mul_cost = Some(52);
3800 cfg.group_ops_bls12381_g2_mul_cost = Some(52);
3801 cfg.group_ops_bls12381_gt_mul_cost = Some(52);
3802 cfg.group_ops_bls12381_scalar_div_cost = Some(52);
3803 cfg.group_ops_bls12381_g1_div_cost = Some(52);
3804 cfg.group_ops_bls12381_g2_div_cost = Some(52);
3805 cfg.group_ops_bls12381_gt_div_cost = Some(52);
3806 cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(52);
3807 cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(52);
3808 cfg.group_ops_bls12381_g1_hash_to_cost_per_byte = Some(2);
3809 cfg.group_ops_bls12381_g2_hash_to_cost_per_byte = Some(2);
3810 cfg.group_ops_bls12381_g1_msm_base_cost = Some(52);
3811 cfg.group_ops_bls12381_g2_msm_base_cost = Some(52);
3812 cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(52);
3813 cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(52);
3814 cfg.group_ops_bls12381_msm_max_len = Some(32);
3815 cfg.group_ops_bls12381_pairing_cost = Some(52);
3816 }
3817 cfg.feature_flags.shared_object_deletion = true;
3819
3820 cfg.consensus_max_transaction_size_bytes = Some(256 * 1024); cfg.consensus_max_transactions_in_block_bytes = Some(6 * 1_024 * 1024);
3822 }
3824 37 => {
3825 cfg.feature_flags.reject_mutable_random_on_entry_functions = true;
3826
3827 if chain != Chain::Mainnet {
3829 cfg.feature_flags.include_consensus_digest_in_prologue = true;
3830 }
3831 }
3832 38 => {
3833 cfg.binary_module_handles = Some(100);
3834 cfg.binary_struct_handles = Some(300);
3835 cfg.binary_function_handles = Some(1500);
3836 cfg.binary_function_instantiations = Some(750);
3837 cfg.binary_signatures = Some(1000);
3838 cfg.binary_constant_pool = Some(4000);
3842 cfg.binary_identifiers = Some(10000);
3843 cfg.binary_address_identifiers = Some(100);
3844 cfg.binary_struct_defs = Some(200);
3845 cfg.binary_struct_def_instantiations = Some(100);
3846 cfg.binary_function_defs = Some(1000);
3847 cfg.binary_field_handles = Some(500);
3848 cfg.binary_field_instantiations = Some(250);
3849 cfg.binary_friend_decls = Some(100);
3850 cfg.max_package_dependencies = Some(32);
3852 cfg.max_modules_in_publish = Some(64);
3853 cfg.execution_version = Some(3);
3855 }
3856 39 => {
3857 }
3859 40 => {}
3860 41 => {
3861 cfg.feature_flags.enable_group_ops_native_functions = true;
3863 cfg.group_ops_bls12381_decode_scalar_cost = Some(52);
3865 cfg.group_ops_bls12381_decode_g1_cost = Some(52);
3866 cfg.group_ops_bls12381_decode_g2_cost = Some(52);
3867 cfg.group_ops_bls12381_decode_gt_cost = Some(52);
3868 cfg.group_ops_bls12381_scalar_add_cost = Some(52);
3869 cfg.group_ops_bls12381_g1_add_cost = Some(52);
3870 cfg.group_ops_bls12381_g2_add_cost = Some(52);
3871 cfg.group_ops_bls12381_gt_add_cost = Some(52);
3872 cfg.group_ops_bls12381_scalar_sub_cost = Some(52);
3873 cfg.group_ops_bls12381_g1_sub_cost = Some(52);
3874 cfg.group_ops_bls12381_g2_sub_cost = Some(52);
3875 cfg.group_ops_bls12381_gt_sub_cost = Some(52);
3876 cfg.group_ops_bls12381_scalar_mul_cost = Some(52);
3877 cfg.group_ops_bls12381_g1_mul_cost = Some(52);
3878 cfg.group_ops_bls12381_g2_mul_cost = Some(52);
3879 cfg.group_ops_bls12381_gt_mul_cost = Some(52);
3880 cfg.group_ops_bls12381_scalar_div_cost = Some(52);
3881 cfg.group_ops_bls12381_g1_div_cost = Some(52);
3882 cfg.group_ops_bls12381_g2_div_cost = Some(52);
3883 cfg.group_ops_bls12381_gt_div_cost = Some(52);
3884 cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(52);
3885 cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(52);
3886 cfg.group_ops_bls12381_g1_hash_to_cost_per_byte = Some(2);
3887 cfg.group_ops_bls12381_g2_hash_to_cost_per_byte = Some(2);
3888 cfg.group_ops_bls12381_g1_msm_base_cost = Some(52);
3889 cfg.group_ops_bls12381_g2_msm_base_cost = Some(52);
3890 cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(52);
3891 cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(52);
3892 cfg.group_ops_bls12381_msm_max_len = Some(32);
3893 cfg.group_ops_bls12381_pairing_cost = Some(52);
3894 }
3895 42 => {}
3896 43 => {
3897 cfg.feature_flags.zklogin_max_epoch_upper_bound_delta = Some(30);
3898 cfg.max_meter_ticks_per_package = Some(16_000_000);
3899 }
3900 44 => {
3901 cfg.feature_flags.include_consensus_digest_in_prologue = true;
3903 if chain != Chain::Mainnet {
3905 cfg.feature_flags.consensus_choice = ConsensusChoice::SwapEachEpoch;
3906 }
3907 }
3908 45 => {
3909 if chain != Chain::Testnet && chain != Chain::Mainnet {
3911 cfg.feature_flags.consensus_network = ConsensusNetwork::Tonic;
3912 }
3913
3914 if chain != Chain::Mainnet {
3915 cfg.feature_flags.mysticeti_leader_scoring_and_schedule = true;
3917 }
3918 cfg.min_move_binary_format_version = Some(6);
3919 cfg.feature_flags.accept_zklogin_in_multisig = true;
3920
3921 if chain != Chain::Mainnet && chain != Chain::Testnet {
3925 cfg.feature_flags.bridge = true;
3926 }
3927 }
3928 46 => {
3929 if chain != Chain::Mainnet {
3931 cfg.feature_flags.bridge = true;
3932 }
3933
3934 cfg.feature_flags.reshare_at_same_initial_version = true;
3936 }
3937 47 => {}
3938 48 => {
3939 cfg.feature_flags.consensus_network = ConsensusNetwork::Tonic;
3941
3942 cfg.feature_flags.resolve_abort_locations_to_package_id = true;
3944
3945 if chain != Chain::Mainnet {
3947 cfg.feature_flags.random_beacon = true;
3948 cfg.random_beacon_reduction_lower_bound = Some(1600);
3949 cfg.random_beacon_dkg_timeout_round = Some(3000);
3950 cfg.random_beacon_min_round_interval_ms = Some(200);
3951 }
3952
3953 cfg.feature_flags.mysticeti_use_committed_subdag_digest = true;
3955 }
3956 49 => {
3957 if chain != Chain::Testnet && chain != Chain::Mainnet {
3958 cfg.move_binary_format_version = Some(7);
3959 }
3960
3961 if chain != Chain::Mainnet && chain != Chain::Testnet {
3963 cfg.feature_flags.enable_vdf = true;
3964 cfg.vdf_verify_vdf_cost = Some(1500);
3967 cfg.vdf_hash_to_input_cost = Some(100);
3968 }
3969
3970 if chain != Chain::Testnet && chain != Chain::Mainnet {
3972 cfg.feature_flags
3973 .record_consensus_determined_version_assignments_in_prologue = true;
3974 }
3975
3976 if chain != Chain::Mainnet {
3978 cfg.feature_flags.consensus_choice = ConsensusChoice::Mysticeti;
3979 }
3980
3981 cfg.feature_flags.fresh_vm_on_framework_upgrade = true;
3983 }
3984 50 => {
3985 if chain != Chain::Mainnet {
3987 cfg.checkpoint_summary_version_specific_data = Some(1);
3988 cfg.min_checkpoint_interval_ms = Some(200);
3989 }
3990
3991 if chain != Chain::Testnet && chain != Chain::Mainnet {
3993 cfg.feature_flags
3994 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = true;
3995 }
3996
3997 cfg.feature_flags.mysticeti_num_leaders_per_round = Some(1);
3998
3999 cfg.max_deferral_rounds_for_congestion_control = Some(10);
4001 }
4002 51 => {
4003 cfg.random_beacon_dkg_version = Some(1);
4004
4005 if chain != Chain::Testnet && chain != Chain::Mainnet {
4006 cfg.feature_flags.enable_coin_deny_list_v2 = true;
4007 }
4008 }
4009 52 => {
4010 if chain != Chain::Mainnet {
4011 cfg.feature_flags.soft_bundle = true;
4012 cfg.max_soft_bundle_size = Some(5);
4013 }
4014
4015 cfg.config_read_setting_impl_cost_base = Some(100);
4016 cfg.config_read_setting_impl_cost_per_byte = Some(40);
4017
4018 if chain != Chain::Testnet && chain != Chain::Mainnet {
4020 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(100);
4021 cfg.feature_flags.per_object_congestion_control_mode =
4022 PerObjectCongestionControlMode::TotalTxCount;
4023 }
4024
4025 cfg.feature_flags.consensus_choice = ConsensusChoice::Mysticeti;
4027
4028 cfg.feature_flags.mysticeti_leader_scoring_and_schedule = true;
4030
4031 cfg.checkpoint_summary_version_specific_data = Some(1);
4033 cfg.min_checkpoint_interval_ms = Some(200);
4034
4035 if chain != Chain::Mainnet {
4037 cfg.feature_flags
4038 .record_consensus_determined_version_assignments_in_prologue = true;
4039 cfg.feature_flags
4040 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = true;
4041 }
4042 if chain != Chain::Mainnet {
4044 cfg.move_binary_format_version = Some(7);
4045 }
4046
4047 if chain != Chain::Testnet && chain != Chain::Mainnet {
4048 cfg.feature_flags.passkey_auth = true;
4049 }
4050 cfg.feature_flags.enable_coin_deny_list_v2 = true;
4051 }
4052 53 => {
4053 cfg.bridge_should_try_to_finalize_committee = Some(chain != Chain::Mainnet);
4055
4056 cfg.feature_flags
4058 .record_consensus_determined_version_assignments_in_prologue = true;
4059 cfg.feature_flags
4060 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = true;
4061
4062 if chain == Chain::Unknown {
4063 cfg.feature_flags.authority_capabilities_v2 = true;
4064 }
4065
4066 if chain != Chain::Mainnet {
4068 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(100);
4069 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(10);
4070 cfg.feature_flags.per_object_congestion_control_mode =
4071 PerObjectCongestionControlMode::TotalTxCount;
4072 }
4073
4074 cfg.bcs_per_byte_serialized_cost = Some(2);
4076 cfg.bcs_legacy_min_output_size_cost = Some(1);
4077 cfg.bcs_failure_cost = Some(52);
4078 cfg.debug_print_base_cost = Some(52);
4079 cfg.debug_print_stack_trace_base_cost = Some(52);
4080 cfg.hash_sha2_256_base_cost = Some(52);
4081 cfg.hash_sha2_256_per_byte_cost = Some(2);
4082 cfg.hash_sha2_256_legacy_min_input_len_cost = Some(1);
4083 cfg.hash_sha3_256_base_cost = Some(52);
4084 cfg.hash_sha3_256_per_byte_cost = Some(2);
4085 cfg.hash_sha3_256_legacy_min_input_len_cost = Some(1);
4086 cfg.type_name_get_base_cost = Some(52);
4087 cfg.type_name_get_per_byte_cost = Some(2);
4088 cfg.string_check_utf8_base_cost = Some(52);
4089 cfg.string_check_utf8_per_byte_cost = Some(2);
4090 cfg.string_is_char_boundary_base_cost = Some(52);
4091 cfg.string_sub_string_base_cost = Some(52);
4092 cfg.string_sub_string_per_byte_cost = Some(2);
4093 cfg.string_index_of_base_cost = Some(52);
4094 cfg.string_index_of_per_byte_pattern_cost = Some(2);
4095 cfg.string_index_of_per_byte_searched_cost = Some(2);
4096 cfg.vector_empty_base_cost = Some(52);
4097 cfg.vector_length_base_cost = Some(52);
4098 cfg.vector_push_back_base_cost = Some(52);
4099 cfg.vector_push_back_legacy_per_abstract_memory_unit_cost = Some(2);
4100 cfg.vector_borrow_base_cost = Some(52);
4101 cfg.vector_pop_back_base_cost = Some(52);
4102 cfg.vector_destroy_empty_base_cost = Some(52);
4103 cfg.vector_swap_base_cost = Some(52);
4104 }
4105 54 => {
4106 cfg.feature_flags.random_beacon = true;
4108 cfg.random_beacon_reduction_lower_bound = Some(1000);
4109 cfg.random_beacon_dkg_timeout_round = Some(3000);
4110 cfg.random_beacon_min_round_interval_ms = Some(500);
4111
4112 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(100);
4114 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(10);
4115 cfg.feature_flags.per_object_congestion_control_mode =
4116 PerObjectCongestionControlMode::TotalTxCount;
4117
4118 cfg.feature_flags.soft_bundle = true;
4120 cfg.max_soft_bundle_size = Some(5);
4121 }
4122 55 => {
4123 cfg.move_binary_format_version = Some(7);
4125
4126 cfg.consensus_max_transactions_in_block_bytes = Some(512 * 1024);
4128 cfg.consensus_max_num_transactions_in_block = Some(512);
4131
4132 cfg.feature_flags.rethrow_serialization_type_layout_errors = true;
4133 }
4134 56 => {
4135 if chain == Chain::Mainnet {
4136 cfg.feature_flags.bridge = true;
4137 }
4138 }
4139 57 => {
4140 cfg.random_beacon_reduction_lower_bound = Some(800);
4142 }
4143 58 => {
4144 if chain == Chain::Mainnet {
4145 cfg.bridge_should_try_to_finalize_committee = Some(true);
4146 }
4147
4148 if chain != Chain::Mainnet && chain != Chain::Testnet {
4149 cfg.feature_flags
4151 .consensus_distributed_vote_scoring_strategy = true;
4152 }
4153 }
4154 59 => {
4155 cfg.feature_flags.consensus_round_prober = true;
4157 }
4158 60 => {
4159 cfg.max_type_to_layout_nodes = Some(512);
4160 cfg.feature_flags.validate_identifier_inputs = true;
4161 }
4162 61 => {
4163 if chain != Chain::Mainnet {
4164 cfg.feature_flags
4166 .consensus_distributed_vote_scoring_strategy = true;
4167 }
4168 cfg.random_beacon_reduction_lower_bound = Some(700);
4170
4171 if chain != Chain::Mainnet && chain != Chain::Testnet {
4172 cfg.feature_flags.mysticeti_fastpath = true;
4174 }
4175 }
4176 62 => {
4177 cfg.feature_flags.relocate_event_module = true;
4178 }
4179 63 => {
4180 cfg.feature_flags.per_object_congestion_control_mode =
4181 PerObjectCongestionControlMode::TotalGasBudgetWithCap;
4182 cfg.gas_budget_based_txn_cost_cap_factor = Some(400_000);
4183 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(18_500_000);
4184 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(240_000_000);
4185 }
4186 64 => {
4187 cfg.feature_flags.per_object_congestion_control_mode =
4188 PerObjectCongestionControlMode::TotalTxCount;
4189 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(40);
4190 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(3);
4191 }
4192 65 => {
4193 cfg.feature_flags
4195 .consensus_distributed_vote_scoring_strategy = true;
4196 }
4197 66 => {
4198 if chain == Chain::Mainnet {
4199 cfg.feature_flags
4201 .consensus_distributed_vote_scoring_strategy = false;
4202 }
4203 }
4204 67 => {
4205 cfg.feature_flags
4207 .consensus_distributed_vote_scoring_strategy = true;
4208 }
4209 68 => {
4210 cfg.group_ops_bls12381_g1_to_uncompressed_g1_cost = Some(26);
4211 cfg.group_ops_bls12381_uncompressed_g1_to_g1_cost = Some(52);
4212 cfg.group_ops_bls12381_uncompressed_g1_sum_base_cost = Some(26);
4213 cfg.group_ops_bls12381_uncompressed_g1_sum_cost_per_term = Some(13);
4214 cfg.group_ops_bls12381_uncompressed_g1_sum_max_terms = Some(2000);
4215
4216 if chain != Chain::Mainnet && chain != Chain::Testnet {
4217 cfg.feature_flags.uncompressed_g1_group_elements = true;
4218 }
4219
4220 cfg.feature_flags.per_object_congestion_control_mode =
4221 PerObjectCongestionControlMode::TotalGasBudgetWithCap;
4222 cfg.gas_budget_based_txn_cost_cap_factor = Some(400_000);
4223 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(18_500_000);
4224 cfg.max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit =
4225 Some(3_700_000); cfg.max_txn_cost_overage_per_object_in_commit = Some(u64::MAX);
4227 cfg.gas_budget_based_txn_cost_absolute_cap_commit_count = Some(50);
4228
4229 cfg.random_beacon_reduction_lower_bound = Some(500);
4231
4232 cfg.feature_flags.disallow_new_modules_in_deps_only_packages = true;
4233 }
4234 69 => {
4235 cfg.consensus_voting_rounds = Some(40);
4237
4238 if chain != Chain::Mainnet && chain != Chain::Testnet {
4239 cfg.feature_flags.consensus_smart_ancestor_selection = true;
4241 }
4242
4243 if chain != Chain::Mainnet {
4244 cfg.feature_flags.uncompressed_g1_group_elements = true;
4245 }
4246 }
4247 70 => {
4248 if chain != Chain::Mainnet {
4249 cfg.feature_flags.consensus_smart_ancestor_selection = true;
4251 cfg.feature_flags
4253 .consensus_round_prober_probe_accepted_rounds = true;
4254 }
4255
4256 cfg.poseidon_bn254_cost_per_block = Some(388);
4257
4258 cfg.gas_model_version = Some(9);
4259 cfg.feature_flags.native_charging_v2 = true;
4260 cfg.bls12381_bls12381_min_sig_verify_cost_base = Some(44064);
4261 cfg.bls12381_bls12381_min_pk_verify_cost_base = Some(49282);
4262 cfg.ecdsa_k1_secp256k1_verify_keccak256_cost_base = Some(1470);
4263 cfg.ecdsa_k1_secp256k1_verify_sha256_cost_base = Some(1470);
4264 cfg.ecdsa_r1_secp256r1_verify_sha256_cost_base = Some(4225);
4265 cfg.ecdsa_r1_secp256r1_verify_keccak256_cost_base = Some(4225);
4266 cfg.ecvrf_ecvrf_verify_cost_base = Some(4848);
4267 cfg.ed25519_ed25519_verify_cost_base = Some(1802);
4268
4269 cfg.ecdsa_r1_ecrecover_keccak256_cost_base = Some(1173);
4271 cfg.ecdsa_r1_ecrecover_sha256_cost_base = Some(1173);
4272 cfg.ecdsa_k1_ecrecover_keccak256_cost_base = Some(500);
4273 cfg.ecdsa_k1_ecrecover_sha256_cost_base = Some(500);
4274
4275 cfg.groth16_prepare_verifying_key_bls12381_cost_base = Some(53838);
4276 cfg.groth16_prepare_verifying_key_bn254_cost_base = Some(82010);
4277 cfg.groth16_verify_groth16_proof_internal_bls12381_cost_base = Some(72090);
4278 cfg.groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input =
4279 Some(8213);
4280 cfg.groth16_verify_groth16_proof_internal_bn254_cost_base = Some(115502);
4281 cfg.groth16_verify_groth16_proof_internal_bn254_cost_per_public_input =
4282 Some(9484);
4283
4284 cfg.hash_keccak256_cost_base = Some(10);
4285 cfg.hash_blake2b256_cost_base = Some(10);
4286
4287 cfg.group_ops_bls12381_decode_scalar_cost = Some(7);
4289 cfg.group_ops_bls12381_decode_g1_cost = Some(2848);
4290 cfg.group_ops_bls12381_decode_g2_cost = Some(3770);
4291 cfg.group_ops_bls12381_decode_gt_cost = Some(3068);
4292
4293 cfg.group_ops_bls12381_scalar_add_cost = Some(10);
4294 cfg.group_ops_bls12381_g1_add_cost = Some(1556);
4295 cfg.group_ops_bls12381_g2_add_cost = Some(3048);
4296 cfg.group_ops_bls12381_gt_add_cost = Some(188);
4297
4298 cfg.group_ops_bls12381_scalar_sub_cost = Some(10);
4299 cfg.group_ops_bls12381_g1_sub_cost = Some(1550);
4300 cfg.group_ops_bls12381_g2_sub_cost = Some(3019);
4301 cfg.group_ops_bls12381_gt_sub_cost = Some(497);
4302
4303 cfg.group_ops_bls12381_scalar_mul_cost = Some(11);
4304 cfg.group_ops_bls12381_g1_mul_cost = Some(4842);
4305 cfg.group_ops_bls12381_g2_mul_cost = Some(9108);
4306 cfg.group_ops_bls12381_gt_mul_cost = Some(27490);
4307
4308 cfg.group_ops_bls12381_scalar_div_cost = Some(91);
4309 cfg.group_ops_bls12381_g1_div_cost = Some(5091);
4310 cfg.group_ops_bls12381_g2_div_cost = Some(9206);
4311 cfg.group_ops_bls12381_gt_div_cost = Some(27804);
4312
4313 cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(2962);
4314 cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(8688);
4315
4316 cfg.group_ops_bls12381_g1_msm_base_cost = Some(62648);
4317 cfg.group_ops_bls12381_g2_msm_base_cost = Some(131192);
4318 cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(1333);
4319 cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(3216);
4320
4321 cfg.group_ops_bls12381_uncompressed_g1_to_g1_cost = Some(677);
4322 cfg.group_ops_bls12381_g1_to_uncompressed_g1_cost = Some(2099);
4323 cfg.group_ops_bls12381_uncompressed_g1_sum_base_cost = Some(77);
4324 cfg.group_ops_bls12381_uncompressed_g1_sum_cost_per_term = Some(26);
4325
4326 cfg.group_ops_bls12381_pairing_cost = Some(26897);
4327 cfg.group_ops_bls12381_uncompressed_g1_sum_max_terms = Some(1200);
4328
4329 cfg.validator_validate_metadata_cost_base = Some(20000);
4330 }
4331 71 => {
4332 cfg.sip_45_consensus_amplification_threshold = Some(5);
4333
4334 cfg.allowed_txn_cost_overage_burst_per_object_in_commit = Some(185_000_000);
4336 }
4337 72 => {
4338 cfg.feature_flags.convert_type_argument_error = true;
4339
4340 cfg.max_tx_gas = Some(50_000_000_000_000);
4343 cfg.max_gas_price = Some(50_000_000_000);
4345
4346 cfg.feature_flags.variant_nodes = true;
4347 }
4348 73 => {
4349 cfg.use_object_per_epoch_marker_table_v2 = Some(true);
4351
4352 if chain != Chain::Mainnet && chain != Chain::Testnet {
4353 cfg.consensus_gc_depth = Some(60);
4356 }
4357
4358 if chain != Chain::Mainnet {
4359 cfg.feature_flags.consensus_zstd_compression = true;
4361 }
4362
4363 cfg.feature_flags.consensus_smart_ancestor_selection = true;
4365 cfg.feature_flags
4367 .consensus_round_prober_probe_accepted_rounds = true;
4368
4369 cfg.feature_flags.per_object_congestion_control_mode =
4371 PerObjectCongestionControlMode::TotalGasBudgetWithCap;
4372 cfg.gas_budget_based_txn_cost_cap_factor = Some(400_000);
4373 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(37_000_000);
4374 cfg.max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit =
4375 Some(7_400_000); cfg.max_txn_cost_overage_per_object_in_commit = Some(u64::MAX);
4377 cfg.gas_budget_based_txn_cost_absolute_cap_commit_count = Some(50);
4378 cfg.allowed_txn_cost_overage_burst_per_object_in_commit = Some(370_000_000);
4379 }
4380 74 => {
4381 if chain != Chain::Mainnet && chain != Chain::Testnet {
4383 cfg.feature_flags.enable_nitro_attestation = true;
4384 }
4385 cfg.nitro_attestation_parse_base_cost = Some(53 * 50);
4386 cfg.nitro_attestation_parse_cost_per_byte = Some(50);
4387 cfg.nitro_attestation_verify_base_cost = Some(49632 * 50);
4388 cfg.nitro_attestation_verify_cost_per_cert = Some(52369 * 50);
4389
4390 cfg.feature_flags.consensus_zstd_compression = true;
4392
4393 if chain != Chain::Mainnet && chain != Chain::Testnet {
4394 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
4395 }
4396 }
4397 75 => {
4398 if chain != Chain::Mainnet {
4399 cfg.feature_flags.passkey_auth = true;
4400 }
4401 }
4402 76 => {
4403 if chain != Chain::Mainnet && chain != Chain::Testnet {
4404 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
4405 cfg.consensus_commit_rate_estimation_window_size = Some(10);
4406 }
4407 cfg.feature_flags.minimize_child_object_mutations = true;
4408
4409 if chain != Chain::Mainnet {
4410 cfg.feature_flags.accept_passkey_in_multisig = true;
4411 }
4412 }
4413 77 => {
4414 cfg.feature_flags.uncompressed_g1_group_elements = true;
4415
4416 if chain != Chain::Mainnet {
4417 cfg.consensus_gc_depth = Some(60);
4418 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
4419 }
4420 }
4421 78 => {
4422 cfg.feature_flags.move_native_context = true;
4423 cfg.tx_context_fresh_id_cost_base = Some(52);
4424 cfg.tx_context_sender_cost_base = Some(30);
4425 cfg.tx_context_epoch_cost_base = Some(30);
4426 cfg.tx_context_epoch_timestamp_ms_cost_base = Some(30);
4427 cfg.tx_context_sponsor_cost_base = Some(30);
4428 cfg.tx_context_gas_price_cost_base = Some(30);
4429 cfg.tx_context_gas_budget_cost_base = Some(30);
4430 cfg.tx_context_ids_created_cost_base = Some(30);
4431 cfg.tx_context_replace_cost_base = Some(30);
4432 cfg.gas_model_version = Some(10);
4433
4434 if chain != Chain::Mainnet {
4435 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
4436 cfg.consensus_commit_rate_estimation_window_size = Some(10);
4437
4438 cfg.feature_flags.per_object_congestion_control_mode =
4440 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4441 ExecutionTimeEstimateParams {
4442 target_utilization: 30,
4443 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4445 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4447 stored_observations_limit: u64::MAX,
4448 stake_weighted_median_threshold: 0,
4449 default_none_duration_for_new_keys: false,
4450 observations_chunk_size: None,
4451 },
4452 );
4453 }
4454 }
4455 79 => {
4456 if chain != Chain::Mainnet {
4457 cfg.feature_flags.consensus_median_based_commit_timestamp = true;
4458
4459 cfg.consensus_bad_nodes_stake_threshold = Some(30);
4462
4463 cfg.feature_flags.consensus_batched_block_sync = true;
4464
4465 cfg.feature_flags.enable_nitro_attestation = true
4467 }
4468 cfg.feature_flags.normalize_ptb_arguments = true;
4469
4470 cfg.consensus_gc_depth = Some(60);
4471 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
4472 }
4473 80 => {
4474 cfg.max_ptb_value_size = Some(1024 * 1024);
4475 }
4476 81 => {
4477 cfg.feature_flags.consensus_median_based_commit_timestamp = true;
4478 cfg.feature_flags.enforce_checkpoint_timestamp_monotonicity = true;
4479 cfg.consensus_bad_nodes_stake_threshold = Some(30)
4480 }
4481 82 => {
4482 cfg.feature_flags.max_ptb_value_size_v2 = true;
4483 }
4484 83 => {
4485 if chain == Chain::Mainnet {
4486 let aliased: [u8; 32] = Hex::decode(
4488 "0x0b2da327ba6a4cacbe75dddd50e6e8bbf81d6496e92d66af9154c61c77f7332f",
4489 )
4490 .unwrap()
4491 .try_into()
4492 .unwrap();
4493
4494 cfg.aliased_addresses.push(AliasedAddress {
4496 original: Hex::decode("0xcd8962dad278d8b50fa0f9eb0186bfa4cbdecc6d59377214c88d0286a0ac9562").unwrap().try_into().unwrap(),
4497 aliased,
4498 allowed_tx_digests: vec![
4499 Base58::decode("B2eGLFoMHgj93Ni8dAJBfqGzo8EWSTLBesZzhEpTPA4").unwrap().try_into().unwrap(),
4500 ],
4501 });
4502
4503 cfg.aliased_addresses.push(AliasedAddress {
4504 original: Hex::decode("0xe28b50cef1d633ea43d3296a3f6b67ff0312a5f1a99f0af753c85b8b5de8ff06").unwrap().try_into().unwrap(),
4505 aliased,
4506 allowed_tx_digests: vec![
4507 Base58::decode("J4QqSAgp7VrQtQpMy5wDX4QGsCSEZu3U5KuDAkbESAge").unwrap().try_into().unwrap(),
4508 ],
4509 });
4510 }
4511
4512 if chain != Chain::Mainnet {
4515 cfg.feature_flags.resolve_type_input_ids_to_defining_id = true;
4516 cfg.transfer_party_transfer_internal_cost_base = Some(52);
4517
4518 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
4520 cfg.consensus_commit_rate_estimation_window_size = Some(10);
4521 cfg.feature_flags.per_object_congestion_control_mode =
4522 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4523 ExecutionTimeEstimateParams {
4524 target_utilization: 30,
4525 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4527 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4529 stored_observations_limit: u64::MAX,
4530 stake_weighted_median_threshold: 0,
4531 default_none_duration_for_new_keys: false,
4532 observations_chunk_size: None,
4533 },
4534 );
4535
4536 cfg.feature_flags.consensus_batched_block_sync = true;
4538
4539 cfg.feature_flags.enable_nitro_attestation_upgraded_parsing = true;
4542 cfg.feature_flags.enable_nitro_attestation = true;
4543 }
4544 }
4545 84 => {
4546 if chain == Chain::Mainnet {
4547 cfg.feature_flags.resolve_type_input_ids_to_defining_id = true;
4548 cfg.transfer_party_transfer_internal_cost_base = Some(52);
4549
4550 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
4552 cfg.consensus_commit_rate_estimation_window_size = Some(10);
4553 cfg.feature_flags.per_object_congestion_control_mode =
4554 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4555 ExecutionTimeEstimateParams {
4556 target_utilization: 30,
4557 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4559 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4561 stored_observations_limit: u64::MAX,
4562 stake_weighted_median_threshold: 0,
4563 default_none_duration_for_new_keys: false,
4564 observations_chunk_size: None,
4565 },
4566 );
4567
4568 cfg.feature_flags.consensus_batched_block_sync = true;
4570
4571 cfg.feature_flags.enable_nitro_attestation_upgraded_parsing = true;
4574 cfg.feature_flags.enable_nitro_attestation = true;
4575 }
4576
4577 cfg.feature_flags.per_object_congestion_control_mode =
4579 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4580 ExecutionTimeEstimateParams {
4581 target_utilization: 30,
4582 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4584 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4586 stored_observations_limit: 20,
4587 stake_weighted_median_threshold: 0,
4588 default_none_duration_for_new_keys: false,
4589 observations_chunk_size: None,
4590 },
4591 );
4592 cfg.feature_flags.allow_unbounded_system_objects = true;
4593 }
4594 85 => {
4595 if chain != Chain::Mainnet && chain != Chain::Testnet {
4596 cfg.feature_flags.enable_party_transfer = true;
4597 }
4598
4599 cfg.feature_flags
4600 .record_consensus_determined_version_assignments_in_prologue_v2 = true;
4601 cfg.feature_flags.disallow_self_identifier = true;
4602 cfg.feature_flags.per_object_congestion_control_mode =
4603 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4604 ExecutionTimeEstimateParams {
4605 target_utilization: 50,
4606 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4608 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4610 stored_observations_limit: 20,
4611 stake_weighted_median_threshold: 0,
4612 default_none_duration_for_new_keys: false,
4613 observations_chunk_size: None,
4614 },
4615 );
4616 }
4617 86 => {
4618 cfg.feature_flags.type_tags_in_object_runtime = true;
4619 cfg.max_move_enum_variants = Some(move_core_types::VARIANT_COUNT_MAX);
4620
4621 cfg.feature_flags.per_object_congestion_control_mode =
4623 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4624 ExecutionTimeEstimateParams {
4625 target_utilization: 50,
4626 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4628 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4630 stored_observations_limit: 20,
4631 stake_weighted_median_threshold: 3334,
4632 default_none_duration_for_new_keys: false,
4633 observations_chunk_size: None,
4634 },
4635 );
4636 if chain != Chain::Mainnet {
4638 cfg.feature_flags.enable_party_transfer = true;
4639 }
4640 }
4641 87 => {
4642 if chain == Chain::Mainnet {
4643 cfg.feature_flags.record_time_estimate_processed = true;
4644 }
4645 cfg.feature_flags.better_adapter_type_resolution_errors = true;
4646 }
4647 88 => {
4648 cfg.feature_flags.record_time_estimate_processed = true;
4649 cfg.tx_context_rgp_cost_base = Some(30);
4650 cfg.feature_flags
4651 .ignore_execution_time_observations_after_certs_closed = true;
4652
4653 cfg.feature_flags.per_object_congestion_control_mode =
4656 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4657 ExecutionTimeEstimateParams {
4658 target_utilization: 50,
4659 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4661 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4663 stored_observations_limit: 20,
4664 stake_weighted_median_threshold: 3334,
4665 default_none_duration_for_new_keys: true,
4666 observations_chunk_size: None,
4667 },
4668 );
4669 }
4670 89 => {
4671 cfg.feature_flags.dependency_linkage_error = true;
4672 cfg.feature_flags.additional_multisig_checks = true;
4673 }
4674 90 => {
4675 cfg.max_gas_price_rgp_factor_for_aborted_transactions = Some(100);
4677 cfg.feature_flags.debug_fatal_on_move_invariant_violation = true;
4678 cfg.feature_flags.additional_consensus_digest_indirect_state = true;
4679 cfg.feature_flags.accept_passkey_in_multisig = true;
4680 cfg.feature_flags.passkey_auth = true;
4681 cfg.feature_flags.check_for_init_during_upgrade = true;
4682
4683 if chain != Chain::Mainnet {
4685 cfg.feature_flags.mysticeti_fastpath = true;
4686 }
4687 }
4688 91 => {
4689 cfg.feature_flags.per_command_shared_object_transfer_rules = true;
4690 }
4691 92 => {
4692 cfg.feature_flags.per_command_shared_object_transfer_rules = false;
4693 }
4694 93 => {
4695 cfg.feature_flags
4696 .consensus_checkpoint_signature_key_includes_digest = true;
4697 }
4698 94 => {
4699 cfg.feature_flags.per_object_congestion_control_mode =
4701 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4702 ExecutionTimeEstimateParams {
4703 target_utilization: 50,
4704 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4706 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4708 stored_observations_limit: 18,
4709 stake_weighted_median_threshold: 3334,
4710 default_none_duration_for_new_keys: true,
4711 observations_chunk_size: None,
4712 },
4713 );
4714
4715 cfg.feature_flags.enable_party_transfer = true;
4717 }
4718 95 => {
4719 cfg.type_name_id_base_cost = Some(52);
4720
4721 cfg.max_transactions_per_checkpoint = Some(20_000);
4723 }
4724 96 => {
4725 if chain != Chain::Mainnet && chain != Chain::Testnet {
4727 cfg.feature_flags
4728 .include_checkpoint_artifacts_digest_in_summary = true;
4729 }
4730 cfg.feature_flags.correct_gas_payment_limit_check = true;
4731 cfg.feature_flags.authority_capabilities_v2 = true;
4732 cfg.feature_flags.use_mfp_txns_in_load_initial_object_debts = true;
4733 cfg.feature_flags.cancel_for_failed_dkg_early = true;
4734 cfg.feature_flags.enable_coin_registry = true;
4735
4736 cfg.feature_flags.mysticeti_fastpath = true;
4738 }
4739 97 => {
4740 cfg.feature_flags.additional_borrow_checks = true;
4741 }
4742 98 => {
4743 cfg.event_emit_auth_stream_cost = Some(52);
4744 cfg.feature_flags.better_loader_errors = true;
4745 cfg.feature_flags.generate_df_type_layouts = true;
4746 }
4747 99 => {
4748 cfg.feature_flags.use_new_commit_handler = true;
4749 }
4750 100 => {
4751 cfg.feature_flags.private_generics_verifier_v2 = true;
4752 }
4753 101 => {
4754 cfg.feature_flags.create_root_accumulator_object = true;
4755 cfg.max_updates_per_settlement_txn = Some(100);
4756 if chain != Chain::Mainnet {
4757 cfg.feature_flags.enable_poseidon = true;
4758 }
4759 }
4760 102 => {
4761 cfg.feature_flags.per_object_congestion_control_mode =
4765 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4766 ExecutionTimeEstimateParams {
4767 target_utilization: 50,
4768 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4770 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4772 stored_observations_limit: 180,
4773 stake_weighted_median_threshold: 3334,
4774 default_none_duration_for_new_keys: true,
4775 observations_chunk_size: Some(18),
4776 },
4777 );
4778 cfg.feature_flags.deprecate_global_storage_ops = true;
4779 }
4780 103 => {}
4781 104 => {
4782 cfg.translation_per_command_base_charge = Some(1);
4783 cfg.translation_per_input_base_charge = Some(1);
4784 cfg.translation_pure_input_per_byte_charge = Some(1);
4785 cfg.translation_per_type_node_charge = Some(1);
4786 cfg.translation_per_reference_node_charge = Some(1);
4787 cfg.translation_per_linkage_entry_charge = Some(10);
4788 cfg.gas_model_version = Some(11);
4789 cfg.feature_flags.abstract_size_in_object_runtime = true;
4790 cfg.feature_flags.object_runtime_charge_cache_load_gas = true;
4791 cfg.dynamic_field_hash_type_and_key_cost_base = Some(52);
4792 cfg.dynamic_field_add_child_object_cost_base = Some(52);
4793 cfg.dynamic_field_add_child_object_value_cost_per_byte = Some(1);
4794 cfg.dynamic_field_borrow_child_object_cost_base = Some(52);
4795 cfg.dynamic_field_borrow_child_object_child_ref_cost_per_byte = Some(1);
4796 cfg.dynamic_field_remove_child_object_cost_base = Some(52);
4797 cfg.dynamic_field_remove_child_object_child_cost_per_byte = Some(1);
4798 cfg.dynamic_field_has_child_object_cost_base = Some(52);
4799 cfg.dynamic_field_has_child_object_with_ty_cost_base = Some(52);
4800 cfg.feature_flags.enable_ptb_execution_v2 = true;
4801
4802 cfg.poseidon_bn254_cost_base = Some(260);
4803
4804 cfg.feature_flags.consensus_skip_gced_accept_votes = true;
4805
4806 if chain != Chain::Mainnet {
4807 cfg.feature_flags
4808 .enable_nitro_attestation_all_nonzero_pcrs_parsing = true;
4809 }
4810
4811 cfg.feature_flags
4812 .include_cancelled_randomness_txns_in_prologue = true;
4813 }
4814 105 => {
4815 cfg.feature_flags.enable_multi_epoch_transaction_expiration = true;
4816 cfg.feature_flags.disable_preconsensus_locking = true;
4817
4818 if chain != Chain::Mainnet {
4819 cfg.feature_flags
4820 .enable_nitro_attestation_always_include_required_pcrs_parsing = true;
4821 }
4822 }
4823 106 => {
4824 cfg.accumulator_object_storage_cost = Some(7600);
4826
4827 if chain != Chain::Mainnet && chain != Chain::Testnet {
4828 cfg.feature_flags.enable_accumulators = true;
4829 cfg.feature_flags.enable_address_balance_gas_payments = true;
4830 cfg.feature_flags.enable_authenticated_event_streams = true;
4831 cfg.feature_flags.enable_object_funds_withdraw = true;
4832 }
4833 }
4834 107 => {
4835 cfg.feature_flags
4836 .consensus_skip_gced_blocks_in_direct_finalization = true;
4837
4838 if in_integration_test() {
4840 cfg.consensus_gc_depth = Some(6);
4841 cfg.consensus_max_num_transactions_in_block = Some(8);
4842 }
4843 }
4844 108 => {
4845 cfg.feature_flags.gas_rounding_halve_digits = true;
4846 cfg.feature_flags.flexible_tx_context_positions = true;
4847 cfg.feature_flags.disable_entry_point_signature_check = true;
4848
4849 if chain != Chain::Mainnet {
4850 cfg.feature_flags.address_aliases = true;
4851
4852 cfg.feature_flags.enable_accumulators = true;
4853 cfg.feature_flags.enable_address_balance_gas_payments = true;
4854 }
4855
4856 cfg.feature_flags.enable_poseidon = true;
4857 }
4858 109 => {
4859 cfg.binary_variant_handles = Some(1024);
4860 cfg.binary_variant_instantiation_handles = Some(1024);
4861 cfg.feature_flags.restrict_hot_or_not_entry_functions = true;
4862 }
4863 110 => {
4864 cfg.feature_flags
4865 .enable_nitro_attestation_all_nonzero_pcrs_parsing = true;
4866 cfg.feature_flags
4867 .enable_nitro_attestation_always_include_required_pcrs_parsing = true;
4868 if chain != Chain::Mainnet && chain != Chain::Testnet {
4869 cfg.feature_flags.split_checkpoints_in_consensus_handler = true;
4870 }
4871 cfg.feature_flags.validate_zklogin_public_identifier = true;
4872 cfg.feature_flags.fix_checkpoint_signature_mapping = true;
4873 cfg.feature_flags
4874 .consensus_always_accept_system_transactions = true;
4875 if chain != Chain::Mainnet {
4876 cfg.feature_flags.enable_object_funds_withdraw = true;
4877 }
4878 }
4879 111 => {
4880 cfg.feature_flags.validator_metadata_verify_v2 = true;
4881 }
4882 112 => {
4883 cfg.group_ops_ristretto_decode_scalar_cost = Some(7);
4884 cfg.group_ops_ristretto_decode_point_cost = Some(200);
4885 cfg.group_ops_ristretto_scalar_add_cost = Some(10);
4886 cfg.group_ops_ristretto_point_add_cost = Some(500);
4887 cfg.group_ops_ristretto_scalar_sub_cost = Some(10);
4888 cfg.group_ops_ristretto_point_sub_cost = Some(500);
4889 cfg.group_ops_ristretto_scalar_mul_cost = Some(11);
4890 cfg.group_ops_ristretto_point_mul_cost = Some(1200);
4891 cfg.group_ops_ristretto_scalar_div_cost = Some(151);
4892 cfg.group_ops_ristretto_point_div_cost = Some(2500);
4893
4894 if chain != Chain::Mainnet && chain != Chain::Testnet {
4895 cfg.feature_flags.enable_ristretto255_group_ops = true;
4896 }
4897 }
4898 113 => {
4899 cfg.feature_flags.address_balance_gas_check_rgp_at_signing = true;
4900 if chain != Chain::Mainnet && chain != Chain::Testnet {
4901 cfg.feature_flags.defer_unpaid_amplification = true;
4902 }
4903 }
4904 114 => {
4905 cfg.feature_flags.randomize_checkpoint_tx_limit_in_tests = true;
4906 cfg.feature_flags.address_balance_gas_reject_gas_coin_arg = true;
4907 if chain != Chain::Mainnet {
4908 cfg.feature_flags.split_checkpoints_in_consensus_handler = true;
4909 cfg.feature_flags.enable_authenticated_event_streams = true;
4910 cfg.feature_flags
4911 .include_checkpoint_artifacts_digest_in_summary = true;
4912 }
4913 }
4914 115 => {
4915 cfg.feature_flags.normalize_depth_formula = true;
4916 }
4917 116 => {
4918 cfg.feature_flags.gasless_transaction_drop_safety = true;
4919 cfg.feature_flags.address_aliases = true;
4920 cfg.feature_flags.relax_valid_during_for_owned_inputs = true;
4921 cfg.feature_flags.defer_unpaid_amplification = false;
4923 cfg.feature_flags.enable_display_registry = true;
4924 }
4925 117 => {}
4926 118 => {
4927 cfg.feature_flags.use_coin_party_owner = true;
4928 }
4929 119 => {
4930 cfg.execution_version = Some(4);
4932 cfg.feature_flags.address_balance_gas_reject_gas_coin_arg = false;
4933 cfg.feature_flags.merge_randomness_into_checkpoint = true;
4934 if chain != Chain::Mainnet {
4935 cfg.feature_flags.enable_gasless = true;
4936 cfg.gasless_max_computation_units = Some(50_000);
4937 cfg.gasless_allowed_token_types = Some(vec![]);
4938 cfg.feature_flags.enable_coin_reservation_obj_refs = true;
4939 cfg.feature_flags
4940 .convert_withdrawal_compatibility_ptb_arguments = true;
4941 }
4942 cfg.gasless_max_unused_inputs = Some(1);
4943 cfg.gasless_max_pure_input_bytes = Some(32);
4944 if chain == Chain::Testnet {
4945 cfg.gasless_allowed_token_types = Some(vec![(TESTNET_USDC.to_string(), 0)]);
4946 }
4947 cfg.transfer_receive_object_cost_per_byte = Some(1);
4948 cfg.transfer_receive_object_type_cost_per_byte = Some(2);
4949 }
4950 120 => {
4951 cfg.feature_flags.disallow_jump_orphans = true;
4952 }
4953 121 => {
4954 if chain != Chain::Mainnet {
4956 cfg.feature_flags.defer_unpaid_amplification = true;
4957 cfg.gasless_max_tps = Some(50);
4958 }
4959 cfg.feature_flags
4960 .early_return_receive_object_mismatched_type = true;
4961 }
4962 122 => {
4963 cfg.feature_flags.defer_unpaid_amplification = true;
4965 cfg.verify_bulletproofs_ristretto255_base_cost = Some(30000);
4967 cfg.verify_bulletproofs_ristretto255_cost_per_bit_and_commitment = Some(6500);
4968 if chain != Chain::Mainnet && chain != Chain::Testnet {
4969 cfg.feature_flags.enable_verify_bulletproofs_ristretto255 = true;
4970 }
4971 cfg.feature_flags.gasless_verify_remaining_balance = true;
4972 cfg.include_special_package_amendments = match chain {
4973 Chain::Mainnet => Some(MAINNET_LINKAGE_AMENDMENTS.clone()),
4974 Chain::Testnet => Some(TESTNET_LINKAGE_AMENDMENTS.clone()),
4975 Chain::Unknown => None,
4976 };
4977 cfg.gasless_max_tx_size_bytes = Some(16 * 1024);
4978 cfg.gasless_max_tps = Some(300);
4979 cfg.gasless_max_computation_units = Some(5_000);
4980 }
4981 123 => {
4982 cfg.gas_model_version = Some(13);
4983 }
4984 124 => {
4985 if chain != Chain::Mainnet && chain != Chain::Testnet {
4986 cfg.feature_flags.timestamp_based_epoch_close = true;
4987 }
4988 cfg.gas_model_version = Some(14);
4989 cfg.feature_flags.limit_groth16_pvk_inputs = true;
4990
4991 cfg.feature_flags.enable_accumulators = true;
4997 cfg.feature_flags.enable_address_balance_gas_payments = true;
4998 cfg.feature_flags.enable_authenticated_event_streams = true;
4999 cfg.feature_flags.enable_coin_reservation_obj_refs = true;
5000 cfg.feature_flags.enable_object_funds_withdraw = true;
5001 cfg.feature_flags
5002 .convert_withdrawal_compatibility_ptb_arguments = true;
5003 cfg.feature_flags.split_checkpoints_in_consensus_handler = true;
5004 cfg.feature_flags
5005 .include_checkpoint_artifacts_digest_in_summary = true;
5006 cfg.feature_flags.enable_gasless = true;
5007
5008 if chain == Chain::Mainnet {
5013 cfg.gasless_allowed_token_types = Some(vec![
5014 (MAINNET_USDC.to_string(), 10_000),
5015 (MAINNET_USDSUI.to_string(), 10_000),
5016 (MAINNET_SUI_USDE.to_string(), 10_000),
5017 (MAINNET_USDY.to_string(), 10_000),
5018 (MAINNET_FDUSD.to_string(), 10_000),
5019 (MAINNET_AUSD.to_string(), 10_000),
5020 (MAINNET_USDB.to_string(), 10_000),
5021 ]);
5022 }
5023 }
5024 125 => {
5025 cfg.feature_flags.granular_post_execution_checks = true;
5026 if chain != Chain::Mainnet {
5027 cfg.feature_flags.timestamp_based_epoch_close = true;
5028 }
5029 }
5030 126 => {
5031 cfg.feature_flags.early_exit_on_iffw = true;
5032 }
5033 127 => {
5034 cfg.feature_flags.always_advance_dkg_to_resolution = true;
5035
5036 cfg.verify_bulletproofs_ristretto255_base_cost = Some(23866);
5037 cfg.verify_bulletproofs_ristretto255_cost_per_bit_and_commitment = Some(1324);
5038 cfg.group_ops_ristretto_decode_scalar_cost = Some(5);
5039 cfg.group_ops_ristretto_decode_point_cost = Some(216);
5040 cfg.group_ops_ristretto_scalar_add_cost = Some(2);
5041 cfg.group_ops_ristretto_point_add_cost = Some(8);
5042 cfg.group_ops_ristretto_scalar_sub_cost = Some(2);
5043 cfg.group_ops_ristretto_point_sub_cost = Some(8);
5044 cfg.group_ops_ristretto_scalar_mul_cost = Some(5);
5045 cfg.group_ops_ristretto_point_mul_cost = Some(1763);
5046 cfg.group_ops_ristretto_scalar_div_cost = Some(557);
5047 cfg.group_ops_ristretto_point_div_cost = Some(2244);
5048
5049 if chain != Chain::Mainnet {
5050 cfg.feature_flags.enable_ristretto255_group_ops = true;
5051 cfg.feature_flags.enable_verify_bulletproofs_ristretto255 = true;
5052 }
5053
5054 cfg.feature_flags.timestamp_based_epoch_close = true;
5055 }
5056 128 => {
5057 cfg.max_generic_instantiation_type_nodes_per_function = Some(10_000);
5058 cfg.max_generic_instantiation_type_nodes_per_module = Some(500_000);
5059 cfg.binary_enum_defs = Some(200);
5060 cfg.binary_enum_def_instantiations = Some(100);
5061 }
5062 129 => {}
5063 _ => panic!("unsupported version {:?}", version),
5074 }
5075 }
5076
5077 cfg
5078 }
5079
5080 pub fn apply_seeded_test_overrides(&mut self, seed: &[u8; 32]) {
5081 if !self.feature_flags.randomize_checkpoint_tx_limit_in_tests
5082 || !self.feature_flags.split_checkpoints_in_consensus_handler
5083 {
5084 return;
5085 }
5086
5087 if !mysten_common::in_test_configuration() {
5088 return;
5089 }
5090
5091 use rand::{Rng, SeedableRng, rngs::StdRng};
5092 let mut rng = StdRng::from_seed(*seed);
5093 let max_txns = rng.gen_range(10..=100u64);
5094 info!("seeded test override: max_transactions_per_checkpoint = {max_txns}");
5095 self.max_transactions_per_checkpoint = Some(max_txns);
5096 }
5097
5098 pub fn verifier_config(&self, signing_limits: Option<(usize, usize, usize)>) -> VerifierConfig {
5104 let (
5105 max_back_edges_per_function,
5106 max_back_edges_per_module,
5107 sanity_check_with_regex_reference_safety,
5108 ) = if let Some((
5109 max_back_edges_per_function,
5110 max_back_edges_per_module,
5111 sanity_check_with_regex_reference_safety,
5112 )) = signing_limits
5113 {
5114 (
5115 Some(max_back_edges_per_function),
5116 Some(max_back_edges_per_module),
5117 Some(sanity_check_with_regex_reference_safety),
5118 )
5119 } else {
5120 (None, None, None)
5121 };
5122
5123 let additional_borrow_checks = if signing_limits.is_some() {
5124 true
5126 } else {
5127 self.additional_borrow_checks()
5128 };
5129 let deprecate_global_storage_ops = if signing_limits.is_some() {
5130 true
5132 } else {
5133 self.deprecate_global_storage_ops()
5134 };
5135
5136 VerifierConfig {
5137 max_loop_depth: Some(self.max_loop_depth() as usize),
5138 max_generic_instantiation_length: Some(self.max_generic_instantiation_length() as usize),
5139 max_function_parameters: Some(self.max_function_parameters() as usize),
5140 max_basic_blocks: Some(self.max_basic_blocks() as usize),
5141 max_value_stack_size: self.max_value_stack_size() as usize,
5142 max_type_nodes: Some(self.max_type_nodes() as usize),
5143 max_generic_instantiation_type_nodes_per_function: self
5144 .max_generic_instantiation_type_nodes_per_function_as_option()
5145 .map(|v| v as usize),
5146 max_generic_instantiation_type_nodes_per_module: self
5147 .max_generic_instantiation_type_nodes_per_module_as_option()
5148 .map(|v| v as usize),
5149 max_push_size: Some(self.max_push_size() as usize),
5150 max_dependency_depth: Some(self.max_dependency_depth() as usize),
5151 max_fields_in_struct: Some(self.max_fields_in_struct() as usize),
5152 max_function_definitions: Some(self.max_function_definitions() as usize),
5153 max_data_definitions: Some(self.max_struct_definitions() as usize),
5154 max_constant_vector_len: Some(self.max_move_vector_len()),
5155 max_back_edges_per_function,
5156 max_back_edges_per_module,
5157 max_basic_blocks_in_script: None,
5158 max_identifier_len: self.max_move_identifier_len_as_option(), disallow_self_identifier: self.feature_flags.disallow_self_identifier,
5160 allow_receiving_object_id: self.allow_receiving_object_id(),
5161 reject_mutable_random_on_entry_functions: self
5162 .reject_mutable_random_on_entry_functions(),
5163 bytecode_version: self.move_binary_format_version(),
5164 max_variants_in_enum: self.max_move_enum_variants_as_option(),
5165 additional_borrow_checks,
5166 better_loader_errors: self.better_loader_errors(),
5167 private_generics_verifier_v2: self.private_generics_verifier_v2(),
5168 sanity_check_with_regex_reference_safety: sanity_check_with_regex_reference_safety
5169 .map(|limit| limit as u128),
5170 deprecate_global_storage_ops,
5171 disable_entry_point_signature_check: self.disable_entry_point_signature_check(),
5172 switch_to_regex_reference_safety: false,
5173 disallow_jump_orphans: self.disallow_jump_orphans(),
5174 }
5175 }
5176
5177 pub fn binary_config(
5178 &self,
5179 override_deprecate_global_storage_ops_during_deserialization: Option<bool>,
5180 ) -> BinaryConfig {
5181 let deprecate_global_storage_ops =
5182 override_deprecate_global_storage_ops_during_deserialization
5183 .unwrap_or_else(|| self.deprecate_global_storage_ops());
5184 BinaryConfig::new(
5185 self.move_binary_format_version(),
5186 self.min_move_binary_format_version_as_option()
5187 .unwrap_or(VERSION_1),
5188 self.no_extraneous_module_bytes(),
5189 deprecate_global_storage_ops,
5190 TableConfig {
5191 module_handles: self.binary_module_handles_as_option().unwrap_or(u16::MAX),
5192 datatype_handles: self.binary_struct_handles_as_option().unwrap_or(u16::MAX),
5193 function_handles: self.binary_function_handles_as_option().unwrap_or(u16::MAX),
5194 function_instantiations: self
5195 .binary_function_instantiations_as_option()
5196 .unwrap_or(u16::MAX),
5197 signatures: self.binary_signatures_as_option().unwrap_or(u16::MAX),
5198 constant_pool: self.binary_constant_pool_as_option().unwrap_or(u16::MAX),
5199 identifiers: self.binary_identifiers_as_option().unwrap_or(u16::MAX),
5200 address_identifiers: self
5201 .binary_address_identifiers_as_option()
5202 .unwrap_or(u16::MAX),
5203 struct_defs: self.binary_struct_defs_as_option().unwrap_or(u16::MAX),
5204 struct_def_instantiations: self
5205 .binary_struct_def_instantiations_as_option()
5206 .unwrap_or(u16::MAX),
5207 function_defs: self.binary_function_defs_as_option().unwrap_or(u16::MAX),
5208 field_handles: self.binary_field_handles_as_option().unwrap_or(u16::MAX),
5209 field_instantiations: self
5210 .binary_field_instantiations_as_option()
5211 .unwrap_or(u16::MAX),
5212 friend_decls: self.binary_friend_decls_as_option().unwrap_or(u16::MAX),
5213 enum_defs: self.binary_enum_defs_as_option().unwrap_or(u16::MAX),
5214 enum_def_instantiations: self
5215 .binary_enum_def_instantiations_as_option()
5216 .unwrap_or(u16::MAX),
5217 variant_handles: self.binary_variant_handles_as_option().unwrap_or(u16::MAX),
5218 variant_instantiation_handles: self
5219 .binary_variant_instantiation_handles_as_option()
5220 .unwrap_or(u16::MAX),
5221 },
5222 )
5223 }
5224
5225 #[cfg(not(msim))]
5229 pub fn apply_overrides_for_testing(
5230 override_fn: impl Fn(ProtocolVersion, Self) -> Self + Send + Sync + 'static,
5231 ) -> OverrideGuard {
5232 let mut cur = CONFIG_OVERRIDE.lock().unwrap();
5233 assert!(cur.is_none(), "config override already present");
5234 *cur = Some(Box::new(override_fn));
5235 OverrideGuard
5236 }
5237
5238 #[cfg(msim)]
5242 pub fn apply_overrides_for_testing(
5243 override_fn: impl Fn(ProtocolVersion, Self) -> Self + Send + 'static,
5244 ) -> OverrideGuard {
5245 CONFIG_OVERRIDE.with(|ovr| {
5246 let mut cur = ovr.borrow_mut();
5247 assert!(cur.is_none(), "config override already present");
5248 *cur = Some(Box::new(override_fn));
5249 OverrideGuard
5250 })
5251 }
5252
5253 #[cfg(not(msim))]
5254 fn apply_config_override(version: ProtocolVersion, mut ret: Self) -> Self {
5255 if let Some(override_fn) = CONFIG_OVERRIDE.lock().unwrap().as_ref() {
5256 warn!(
5257 "overriding ProtocolConfig settings with custom settings (you should not see this log outside of tests)"
5258 );
5259 ret = override_fn(version, ret);
5260 }
5261 ret
5262 }
5263
5264 #[cfg(msim)]
5265 fn apply_config_override(version: ProtocolVersion, ret: Self) -> Self {
5266 CONFIG_OVERRIDE.with(|ovr| {
5267 if let Some(override_fn) = &*ovr.borrow() {
5268 warn!(
5269 "overriding ProtocolConfig settings with custom settings (you should not see this log outside of tests)"
5270 );
5271 override_fn(version, ret)
5272 } else {
5273 ret
5274 }
5275 })
5276 }
5277}
5278
5279impl ProtocolConfig {
5283 pub fn set_advance_to_highest_supported_protocol_version_for_testing(&mut self, val: bool) {
5284 self.feature_flags
5285 .advance_to_highest_supported_protocol_version = val
5286 }
5287 pub fn set_commit_root_state_digest_supported_for_testing(&mut self, val: bool) {
5288 self.feature_flags.commit_root_state_digest = val
5289 }
5290 pub fn set_zklogin_auth_for_testing(&mut self, val: bool) {
5291 self.feature_flags.zklogin_auth = val
5292 }
5293 pub fn set_enable_jwk_consensus_updates_for_testing(&mut self, val: bool) {
5294 self.feature_flags.enable_jwk_consensus_updates = val
5295 }
5296 pub fn set_random_beacon_for_testing(&mut self, val: bool) {
5297 self.feature_flags.random_beacon = val
5298 }
5299
5300 pub fn set_upgraded_multisig_for_testing(&mut self, val: bool) {
5301 self.feature_flags.upgraded_multisig_supported = val
5302 }
5303 pub fn set_accept_zklogin_in_multisig_for_testing(&mut self, val: bool) {
5304 self.feature_flags.accept_zklogin_in_multisig = val
5305 }
5306
5307 pub fn set_shared_object_deletion_for_testing(&mut self, val: bool) {
5308 self.feature_flags.shared_object_deletion = val;
5309 }
5310
5311 pub fn set_narwhal_new_leader_election_schedule_for_testing(&mut self, val: bool) {
5312 self.feature_flags.narwhal_new_leader_election_schedule = val;
5313 }
5314
5315 pub fn set_receive_object_for_testing(&mut self, val: bool) {
5316 self.feature_flags.receive_objects = val
5317 }
5318 pub fn set_narwhal_certificate_v2_for_testing(&mut self, val: bool) {
5319 self.feature_flags.narwhal_certificate_v2 = val
5320 }
5321 pub fn set_verify_legacy_zklogin_address_for_testing(&mut self, val: bool) {
5322 self.feature_flags.verify_legacy_zklogin_address = val
5323 }
5324
5325 pub fn set_per_object_congestion_control_mode_for_testing(
5326 &mut self,
5327 val: PerObjectCongestionControlMode,
5328 ) {
5329 self.feature_flags.per_object_congestion_control_mode = val;
5330 }
5331
5332 pub fn set_consensus_choice_for_testing(&mut self, val: ConsensusChoice) {
5333 self.feature_flags.consensus_choice = val;
5334 }
5335
5336 pub fn set_consensus_network_for_testing(&mut self, val: ConsensusNetwork) {
5337 self.feature_flags.consensus_network = val;
5338 }
5339
5340 pub fn set_zklogin_max_epoch_upper_bound_delta_for_testing(&mut self, val: Option<u64>) {
5341 self.feature_flags.zklogin_max_epoch_upper_bound_delta = val
5342 }
5343
5344 pub fn set_disable_bridge_for_testing(&mut self) {
5345 self.feature_flags.bridge = false
5346 }
5347
5348 pub fn set_mysticeti_num_leaders_per_round_for_testing(&mut self, val: Option<usize>) {
5349 self.feature_flags.mysticeti_num_leaders_per_round = val;
5350 }
5351
5352 pub fn set_enable_soft_bundle_for_testing(&mut self, val: bool) {
5353 self.feature_flags.soft_bundle = val;
5354 }
5355
5356 pub fn set_passkey_auth_for_testing(&mut self, val: bool) {
5357 self.feature_flags.passkey_auth = val
5358 }
5359
5360 pub fn set_enable_party_transfer_for_testing(&mut self, val: bool) {
5361 self.feature_flags.enable_party_transfer = val
5362 }
5363
5364 pub fn set_consensus_distributed_vote_scoring_strategy_for_testing(&mut self, val: bool) {
5365 self.feature_flags
5366 .consensus_distributed_vote_scoring_strategy = val;
5367 }
5368
5369 pub fn set_consensus_round_prober_for_testing(&mut self, val: bool) {
5370 self.feature_flags.consensus_round_prober = val;
5371 }
5372
5373 pub fn set_disallow_new_modules_in_deps_only_packages_for_testing(&mut self, val: bool) {
5374 self.feature_flags
5375 .disallow_new_modules_in_deps_only_packages = val;
5376 }
5377
5378 pub fn set_correct_gas_payment_limit_check_for_testing(&mut self, val: bool) {
5379 self.feature_flags.correct_gas_payment_limit_check = val;
5380 }
5381
5382 pub fn set_address_aliases_for_testing(&mut self, val: bool) {
5383 self.feature_flags.address_aliases = val;
5384 }
5385
5386 pub fn set_consensus_round_prober_probe_accepted_rounds(&mut self, val: bool) {
5387 self.feature_flags
5388 .consensus_round_prober_probe_accepted_rounds = val;
5389 }
5390
5391 pub fn set_mysticeti_fastpath_for_testing(&mut self, val: bool) {
5392 self.feature_flags.mysticeti_fastpath = val;
5393 }
5394
5395 pub fn set_accept_passkey_in_multisig_for_testing(&mut self, val: bool) {
5396 self.feature_flags.accept_passkey_in_multisig = val;
5397 }
5398
5399 pub fn set_consensus_batched_block_sync_for_testing(&mut self, val: bool) {
5400 self.feature_flags.consensus_batched_block_sync = val;
5401 }
5402
5403 pub fn set_record_time_estimate_processed_for_testing(&mut self, val: bool) {
5404 self.feature_flags.record_time_estimate_processed = val;
5405 }
5406
5407 pub fn set_prepend_prologue_tx_in_consensus_commit_in_checkpoints_for_testing(
5408 &mut self,
5409 val: bool,
5410 ) {
5411 self.feature_flags
5412 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = val;
5413 }
5414
5415 pub fn enable_accumulators_for_testing(&mut self) {
5416 self.feature_flags.enable_accumulators = true;
5417 }
5418
5419 pub fn disable_accumulators_for_testing(&mut self) {
5420 self.feature_flags.enable_accumulators = false;
5421 self.feature_flags.enable_address_balance_gas_payments = false;
5422 }
5423
5424 pub fn enable_coin_reservation_for_testing(&mut self) {
5425 self.feature_flags.enable_coin_reservation_obj_refs = true;
5426 self.feature_flags
5427 .convert_withdrawal_compatibility_ptb_arguments = true;
5428 self.execution_version = Some(self.execution_version.map_or(4, |v| v.max(4)));
5431 }
5432
5433 pub fn disable_coin_reservation_for_testing(&mut self) {
5434 self.feature_flags.enable_coin_reservation_obj_refs = false;
5435 self.feature_flags
5436 .convert_withdrawal_compatibility_ptb_arguments = false;
5437 }
5438
5439 pub fn create_root_accumulator_object_for_testing(&mut self) {
5440 self.feature_flags.create_root_accumulator_object = true;
5441 }
5442
5443 pub fn disable_create_root_accumulator_object_for_testing(&mut self) {
5444 self.feature_flags.create_root_accumulator_object = false;
5445 }
5446
5447 pub fn enable_address_balance_gas_payments_for_testing(&mut self) {
5448 self.feature_flags.enable_accumulators = true;
5449 self.feature_flags.allow_private_accumulator_entrypoints = true;
5450 self.feature_flags.enable_address_balance_gas_payments = true;
5451 self.feature_flags.address_balance_gas_check_rgp_at_signing = true;
5452 self.feature_flags.address_balance_gas_reject_gas_coin_arg = false;
5453 self.execution_version = Some(self.execution_version.map_or(4, |v| v.max(4)))
5454 }
5455
5456 pub fn disable_address_balance_gas_payments_for_testing(&mut self) {
5457 self.feature_flags.enable_address_balance_gas_payments = false;
5458 }
5459
5460 pub fn enable_gasless_for_testing(&mut self) {
5461 self.enable_address_balance_gas_payments_for_testing();
5462 self.feature_flags.enable_gasless = true;
5463 self.feature_flags.gasless_verify_remaining_balance = true;
5464 self.gasless_max_computation_units = Some(5_000);
5465 self.gasless_allowed_token_types = Some(vec![]);
5466 self.gasless_max_tps = Some(1000);
5467 self.gasless_max_tx_size_bytes = Some(16 * 1024);
5468 }
5469
5470 pub fn disable_gasless_for_testing(&mut self) {
5471 self.feature_flags.enable_gasless = false;
5472 self.gasless_max_computation_units = None;
5473 self.gasless_allowed_token_types = None;
5474 }
5475
5476 pub fn enable_multi_epoch_transaction_expiration_for_testing(&mut self) {
5477 self.feature_flags.enable_multi_epoch_transaction_expiration = true;
5478 }
5479
5480 pub fn enable_authenticated_event_streams_for_testing(&mut self) {
5481 self.enable_accumulators_for_testing();
5482 self.feature_flags.enable_authenticated_event_streams = true;
5483 self.feature_flags
5484 .include_checkpoint_artifacts_digest_in_summary = true;
5485 self.feature_flags.split_checkpoints_in_consensus_handler = true;
5486 }
5487
5488 pub fn disable_authenticated_event_streams_for_testing(&mut self) {
5489 self.feature_flags.enable_authenticated_event_streams = false;
5490 }
5491
5492 pub fn disable_randomize_checkpoint_tx_limit_for_testing(&mut self) {
5493 self.feature_flags.randomize_checkpoint_tx_limit_in_tests = false;
5494 }
5495
5496 pub fn enable_non_exclusive_writes_for_testing(&mut self) {
5497 self.feature_flags.enable_non_exclusive_writes = true;
5498 }
5499
5500 pub fn set_relax_valid_during_for_owned_inputs_for_testing(&mut self, val: bool) {
5501 self.feature_flags.relax_valid_during_for_owned_inputs = val;
5502 }
5503
5504 pub fn set_ignore_execution_time_observations_after_certs_closed_for_testing(
5505 &mut self,
5506 val: bool,
5507 ) {
5508 self.feature_flags
5509 .ignore_execution_time_observations_after_certs_closed = val;
5510 }
5511
5512 pub fn set_consensus_checkpoint_signature_key_includes_digest_for_testing(
5513 &mut self,
5514 val: bool,
5515 ) {
5516 self.feature_flags
5517 .consensus_checkpoint_signature_key_includes_digest = val;
5518 }
5519
5520 pub fn set_cancel_for_failed_dkg_early_for_testing(&mut self, val: bool) {
5521 self.feature_flags.cancel_for_failed_dkg_early = val;
5522 }
5523
5524 pub fn set_always_advance_dkg_to_resolution_for_testing(&mut self, val: bool) {
5525 self.feature_flags.always_advance_dkg_to_resolution = val;
5526 }
5527
5528 pub fn set_use_mfp_txns_in_load_initial_object_debts_for_testing(&mut self, val: bool) {
5529 self.feature_flags.use_mfp_txns_in_load_initial_object_debts = val;
5530 }
5531
5532 pub fn set_authority_capabilities_v2_for_testing(&mut self, val: bool) {
5533 self.feature_flags.authority_capabilities_v2 = val;
5534 }
5535
5536 pub fn allow_references_in_ptbs_for_testing(&mut self) {
5537 self.feature_flags.allow_references_in_ptbs = true;
5538 }
5539
5540 pub fn set_consensus_skip_gced_accept_votes_for_testing(&mut self, val: bool) {
5541 self.feature_flags.consensus_skip_gced_accept_votes = val;
5542 }
5543
5544 pub fn set_enable_object_funds_withdraw_for_testing(&mut self, val: bool) {
5545 self.feature_flags.enable_object_funds_withdraw = val;
5546 }
5547
5548 pub fn set_split_checkpoints_in_consensus_handler_for_testing(&mut self, val: bool) {
5549 self.feature_flags.split_checkpoints_in_consensus_handler = val;
5550 }
5551
5552 pub fn set_merge_randomness_into_checkpoint_for_testing(&mut self, val: bool) {
5553 self.feature_flags.merge_randomness_into_checkpoint = val;
5554 }
5555}
5556
5557#[cfg(not(msim))]
5558type OverrideFn = dyn Fn(ProtocolVersion, ProtocolConfig) -> ProtocolConfig + Send + Sync;
5559
5560#[cfg(not(msim))]
5561static CONFIG_OVERRIDE: Mutex<Option<Box<OverrideFn>>> = Mutex::new(None);
5562
5563#[cfg(msim)]
5564type OverrideFn = dyn Fn(ProtocolVersion, ProtocolConfig) -> ProtocolConfig + Send;
5565
5566#[cfg(msim)]
5567thread_local! {
5568 static CONFIG_OVERRIDE: RefCell<Option<Box<OverrideFn>>> = RefCell::new(None);
5569}
5570
5571#[must_use]
5572pub struct OverrideGuard;
5573
5574#[cfg(not(msim))]
5575impl Drop for OverrideGuard {
5576 fn drop(&mut self) {
5577 info!("restoring override fn");
5578 *CONFIG_OVERRIDE.lock().unwrap() = None;
5579 }
5580}
5581
5582#[cfg(msim)]
5583impl Drop for OverrideGuard {
5584 fn drop(&mut self) {
5585 info!("restoring override fn");
5586 CONFIG_OVERRIDE.with(|ovr| {
5587 *ovr.borrow_mut() = None;
5588 });
5589 }
5590}
5591
5592#[derive(PartialEq, Eq)]
5595pub enum LimitThresholdCrossed {
5596 None,
5597 Soft(u128, u128),
5598 Hard(u128, u128),
5599}
5600
5601pub fn check_limit_in_range<T: Into<V>, U: Into<V>, V: PartialOrd + Into<u128>>(
5604 x: T,
5605 soft_limit: U,
5606 hard_limit: V,
5607) -> LimitThresholdCrossed {
5608 let x: V = x.into();
5609 let soft_limit: V = soft_limit.into();
5610
5611 debug_assert!(soft_limit <= hard_limit);
5612
5613 if x >= hard_limit {
5616 LimitThresholdCrossed::Hard(x.into(), hard_limit.into())
5617 } else if x < soft_limit {
5618 LimitThresholdCrossed::None
5619 } else {
5620 LimitThresholdCrossed::Soft(x.into(), soft_limit.into())
5621 }
5622}
5623
5624#[macro_export]
5625macro_rules! check_limit {
5626 ($x:expr, $hard:expr) => {
5627 check_limit!($x, $hard, $hard)
5628 };
5629 ($x:expr, $soft:expr, $hard:expr) => {
5630 check_limit_in_range($x as u64, $soft, $hard)
5631 };
5632}
5633
5634#[macro_export]
5638macro_rules! check_limit_by_meter {
5639 ($is_metered:expr, $x:expr, $metered_limit:expr, $unmetered_hard_limit:expr, $metric:expr) => {{
5640 let (h, metered_str) = if $is_metered {
5642 ($metered_limit, "metered")
5643 } else {
5644 ($unmetered_hard_limit, "unmetered")
5646 };
5647 use sui_protocol_config::check_limit_in_range;
5648 let result = check_limit_in_range($x as u64, $metered_limit, h);
5649 match result {
5650 LimitThresholdCrossed::None => {}
5651 LimitThresholdCrossed::Soft(_, _) => {
5652 $metric.with_label_values(&[metered_str, "soft"]).inc();
5653 }
5654 LimitThresholdCrossed::Hard(_, _) => {
5655 $metric.with_label_values(&[metered_str, "hard"]).inc();
5656 }
5657 };
5658 result
5659 }};
5660}
5661
5662pub type Amendments = BTreeMap<AccountAddress, BTreeMap<AccountAddress, AccountAddress>>;
5665
5666static MAINNET_LINKAGE_AMENDMENTS: LazyLock<Arc<Amendments>> =
5667 LazyLock::new(|| parse_amendments(include_str!("mainnet_amendments.json")));
5668
5669static TESTNET_LINKAGE_AMENDMENTS: LazyLock<Arc<Amendments>> =
5670 LazyLock::new(|| parse_amendments(include_str!("testnet_amendments.json")));
5671
5672fn parse_amendments(json: &str) -> Arc<Amendments> {
5673 #[derive(serde::Deserialize)]
5674 struct AmendmentEntry {
5675 root: String,
5676 deps: Vec<DepEntry>,
5677 }
5678
5679 #[derive(serde::Deserialize)]
5680 struct DepEntry {
5681 original_id: String,
5682 version_id: String,
5683 }
5684
5685 let entries: Vec<AmendmentEntry> =
5686 serde_json::from_str(json).expect("Failed to parse amendments JSON");
5687 let mut amendments = BTreeMap::new();
5688 for entry in entries {
5689 let root_id = AccountAddress::from_hex_literal(&entry.root).unwrap();
5690 let mut dep_ids = BTreeMap::new();
5691 for dep in entry.deps {
5692 let orig_id = AccountAddress::from_hex_literal(&dep.original_id).unwrap();
5693 let upgraded_id = AccountAddress::from_hex_literal(&dep.version_id).unwrap();
5694 assert!(
5695 dep_ids.insert(orig_id, upgraded_id).is_none(),
5696 "Duplicate original ID in amendments table"
5697 );
5698 }
5699 assert!(
5700 amendments.insert(root_id, dep_ids).is_none(),
5701 "Duplicate root ID in amendments table"
5702 );
5703 }
5704 Arc::new(amendments)
5705}
5706
5707#[cfg(all(test, not(msim)))]
5708mod test {
5709 use insta::assert_yaml_snapshot;
5710
5711 use super::*;
5712
5713 #[test]
5714 fn snapshot_tests() {
5715 println!("\n============================================================================");
5716 println!("! !");
5717 println!("! IMPORTANT: never update snapshots from this test. only add new versions! !");
5718 println!("! !");
5719 println!("============================================================================\n");
5720 for chain_id in &[Chain::Unknown, Chain::Mainnet, Chain::Testnet] {
5721 let chain_str = match chain_id {
5725 Chain::Unknown => "".to_string(),
5726 _ => format!("{:?}_", chain_id),
5727 };
5728 for i in MIN_PROTOCOL_VERSION..=MAX_PROTOCOL_VERSION {
5729 let cur = ProtocolVersion::new(i);
5730 assert_yaml_snapshot!(
5731 format!("{}version_{}", chain_str, cur.as_u64()),
5732 ProtocolConfig::get_for_version(cur, *chain_id)
5733 );
5734 }
5735 }
5736 }
5737
5738 #[test]
5739 fn test_getters() {
5740 let prot: ProtocolConfig =
5741 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5742 assert_eq!(
5743 prot.max_arguments(),
5744 prot.max_arguments_as_option().unwrap()
5745 );
5746 }
5747
5748 #[test]
5749 fn test_setters() {
5750 let mut prot: ProtocolConfig =
5751 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5752 prot.set_max_arguments_for_testing(123);
5753 assert_eq!(prot.max_arguments(), 123);
5754
5755 prot.set_max_arguments_from_str_for_testing("321".to_string());
5756 assert_eq!(prot.max_arguments(), 321);
5757
5758 prot.disable_max_arguments_for_testing();
5759 assert_eq!(prot.max_arguments_as_option(), None);
5760
5761 prot.set_attr_for_testing("max_arguments".to_string(), "456".to_string());
5762 assert_eq!(prot.max_arguments(), 456);
5763 }
5764
5765 #[test]
5766 fn test_get_for_version_if_supported_applies_test_overrides() {
5767 let before =
5768 ProtocolConfig::get_for_version_if_supported(ProtocolVersion::new(1), Chain::Unknown)
5769 .unwrap();
5770
5771 assert!(!before.enable_coin_reservation_obj_refs());
5772
5773 let _guard = ProtocolConfig::apply_overrides_for_testing(|_, mut cfg| {
5774 cfg.enable_coin_reservation_for_testing();
5775 cfg
5776 });
5777
5778 let after =
5779 ProtocolConfig::get_for_version_if_supported(ProtocolVersion::new(1), Chain::Unknown)
5780 .unwrap();
5781
5782 assert!(after.enable_coin_reservation_obj_refs());
5783 }
5784
5785 #[test]
5786 #[should_panic(expected = "unsupported version")]
5787 fn max_version_test() {
5788 let _ = ProtocolConfig::get_for_version_impl(
5791 ProtocolVersion::new(MAX_PROTOCOL_VERSION + 1),
5792 Chain::Unknown,
5793 );
5794 }
5795
5796 #[test]
5797 fn lookup_by_string_test() {
5798 let prot: ProtocolConfig =
5799 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5800 assert!(prot.lookup_attr("some random string".to_string()).is_none());
5802
5803 assert!(
5804 prot.lookup_attr("max_arguments".to_string())
5805 == Some(ProtocolConfigValue::u32(prot.max_arguments())),
5806 );
5807
5808 assert!(
5810 prot.lookup_attr("max_move_identifier_len".to_string())
5811 .is_none()
5812 );
5813
5814 let prot: ProtocolConfig =
5816 ProtocolConfig::get_for_version(ProtocolVersion::new(9), Chain::Unknown);
5817 assert!(
5818 prot.lookup_attr("max_move_identifier_len".to_string())
5819 == Some(ProtocolConfigValue::u64(prot.max_move_identifier_len()))
5820 );
5821
5822 let prot: ProtocolConfig =
5823 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5824 assert!(
5826 prot.attr_map()
5827 .get("max_move_identifier_len")
5828 .unwrap()
5829 .is_none()
5830 );
5831 assert!(
5833 prot.attr_map().get("max_arguments").unwrap()
5834 == &Some(ProtocolConfigValue::u32(prot.max_arguments()))
5835 );
5836
5837 let prot: ProtocolConfig =
5839 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5840 assert!(
5842 prot.feature_flags
5843 .lookup_attr("some random string".to_owned())
5844 .is_none()
5845 );
5846 assert!(
5847 !prot
5848 .feature_flags
5849 .attr_map()
5850 .contains_key("some random string")
5851 );
5852
5853 assert!(
5855 prot.feature_flags
5856 .lookup_attr("package_upgrades".to_owned())
5857 == Some(false)
5858 );
5859 assert!(
5860 prot.feature_flags
5861 .attr_map()
5862 .get("package_upgrades")
5863 .unwrap()
5864 == &false
5865 );
5866 let prot: ProtocolConfig =
5867 ProtocolConfig::get_for_version(ProtocolVersion::new(4), Chain::Unknown);
5868 assert!(
5870 prot.feature_flags
5871 .lookup_attr("package_upgrades".to_owned())
5872 == Some(true)
5873 );
5874 assert!(
5875 prot.feature_flags
5876 .attr_map()
5877 .get("package_upgrades")
5878 .unwrap()
5879 == &true
5880 );
5881 }
5882
5883 #[test]
5884 fn limit_range_fn_test() {
5885 let low = 100u32;
5886 let high = 10000u64;
5887
5888 assert!(check_limit!(1u8, low, high) == LimitThresholdCrossed::None);
5889 assert!(matches!(
5890 check_limit!(255u16, low, high),
5891 LimitThresholdCrossed::Soft(255u128, 100)
5892 ));
5893 assert!(matches!(
5899 check_limit!(2550000u64, low, high),
5900 LimitThresholdCrossed::Hard(2550000, 10000)
5901 ));
5902
5903 assert!(matches!(
5904 check_limit!(2550000u64, high, high),
5905 LimitThresholdCrossed::Hard(2550000, 10000)
5906 ));
5907
5908 assert!(matches!(
5909 check_limit!(1u8, high),
5910 LimitThresholdCrossed::None
5911 ));
5912
5913 assert!(check_limit!(255u16, high) == LimitThresholdCrossed::None);
5914
5915 assert!(matches!(
5916 check_limit!(2550000u64, high),
5917 LimitThresholdCrossed::Hard(2550000, 10000)
5918 ));
5919 }
5920
5921 #[test]
5922 fn linkage_amendments_load() {
5923 let mainnet = LazyLock::force(&MAINNET_LINKAGE_AMENDMENTS);
5924 let testnet = LazyLock::force(&TESTNET_LINKAGE_AMENDMENTS);
5925 assert!(!mainnet.is_empty(), "mainnet amendments must not be empty");
5926 assert!(!testnet.is_empty(), "testnet amendments must not be empty");
5927 }
5928
5929 #[test]
5930 fn render_scalar_fields_use_precision_safe_encoding() {
5931 use mysten_common::rpc_format::Unmetered;
5932
5933 let config = ProtocolConfig::get_for_max_version_UNSAFE();
5934 let rendered = config
5935 .render::<serde_json::Value>(&mut Unmetered)
5936 .expect("render should succeed");
5937
5938 let max_args = rendered
5939 .get("max_arguments")
5940 .expect("max_arguments set at max version");
5941 assert!(
5942 max_args.is_number(),
5943 "u32 should render as number, got {max_args:?}",
5944 );
5945
5946 let max_tx_size = rendered
5947 .get("max_tx_size_bytes")
5948 .expect("max_tx_size_bytes set at max version");
5949 assert!(
5950 max_tx_size.is_string(),
5951 "u64 should render as string, got {max_tx_size:?}",
5952 );
5953 }
5954
5955 #[test]
5956 fn render_includes_non_scalar_gasless_allowlist_as_json() {
5957 use mysten_common::rpc_format::Unmetered;
5958 use serde_json::json;
5959
5960 let mut config = ProtocolConfig::get_for_max_version_UNSAFE();
5961 config.set_gasless_allowed_token_types_for_testing(vec![
5962 ("0xa::usdc::USDC".to_string(), 10_000),
5963 ("0xb::usdt::USDT".to_string(), 0),
5964 ]);
5965
5966 let rendered = config
5967 .render::<serde_json::Value>(&mut Unmetered)
5968 .expect("render should succeed under Unmetered budget");
5969 let allowlist = rendered
5970 .get("gasless_allowed_token_types")
5971 .expect("entry should be present after the testing setter");
5972
5973 assert_eq!(
5976 allowlist,
5977 &json!([["0xa::usdc::USDC", "10000"], ["0xb::usdt::USDT", "0"],]),
5978 );
5979 }
5980
5981 #[test]
5982 fn render_targets_prost_value_for_grpc() {
5983 use mysten_common::rpc_format::Unmetered;
5984 use prost_types::value::Kind;
5985
5986 let mut config = ProtocolConfig::get_for_max_version_UNSAFE();
5987 config.set_gasless_allowed_token_types_for_testing(vec![(
5988 "0xa::usdc::USDC".to_string(),
5989 10_000,
5990 )]);
5991
5992 let rendered = config
5993 .render::<prost_types::Value>(&mut Unmetered)
5994 .expect("render to prost Value should succeed");
5995 let allowlist = rendered
5996 .get("gasless_allowed_token_types")
5997 .expect("entry should be present after the testing setter");
5998
5999 let Some(Kind::ListValue(outer)) = &allowlist.kind else {
6001 panic!(
6002 "expected ListValue at the top level, got {:?}",
6003 allowlist.kind
6004 );
6005 };
6006 assert_eq!(outer.values.len(), 1, "one allowlisted entry");
6007 let Some(Kind::ListValue(entry)) = &outer.values[0].kind else {
6008 panic!("expected each entry to be a ListValue");
6009 };
6010 assert_eq!(entry.values.len(), 2, "entry has (coin_type, amount)");
6011
6012 let Some(Kind::StringValue(coin_type)) = &entry.values[0].kind else {
6013 panic!("expected coin_type as StringValue");
6014 };
6015 assert_eq!(coin_type, "0xa::usdc::USDC");
6016
6017 let Some(Kind::StringValue(amount)) = &entry.values[1].kind else {
6019 panic!(
6020 "expected minimum_transfer_amount as StringValue (precision-safe u64); got {:?}",
6021 entry.values[1].kind,
6022 );
6023 };
6024 assert_eq!(amount, "10000");
6025 }
6026
6027 #[test]
6028 fn render_emits_null_for_unset_protocol_versions() {
6029 use mysten_common::rpc_format::Unmetered;
6030
6031 let config = ProtocolConfig::get_for_version(1.into(), Chain::Unknown);
6032 let rendered = config
6033 .render::<serde_json::Value>(&mut Unmetered)
6034 .expect("render should succeed");
6035 let entry = rendered
6039 .get("gasless_allowed_token_types")
6040 .expect("key should be present for every protocol version");
6041 assert!(
6042 entry.is_null(),
6043 "value should be null for pre-feature protocol version, got {entry:?}",
6044 );
6045 }
6046}