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