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