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 = 124;
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)]
355pub struct ProtocolVersion(u64);
356
357impl ProtocolVersion {
358 pub const MIN: Self = Self(MIN_PROTOCOL_VERSION);
363
364 pub const MAX: Self = Self(MAX_PROTOCOL_VERSION);
365
366 #[cfg(not(msim))]
367 pub const MAX_ALLOWED: Self = Self::MAX;
368
369 #[cfg(msim)]
371 pub const MAX_ALLOWED: Self = Self(MAX_PROTOCOL_VERSION + 1);
372
373 pub fn new(v: u64) -> Self {
374 Self(v)
375 }
376
377 pub const fn as_u64(&self) -> u64 {
378 self.0
379 }
380
381 pub fn max() -> Self {
384 Self::MAX
385 }
386
387 pub fn prev(self) -> Self {
388 Self(self.0.checked_sub(1).unwrap())
389 }
390}
391
392impl From<u64> for ProtocolVersion {
393 fn from(v: u64) -> Self {
394 Self::new(v)
395 }
396}
397
398impl std::ops::Sub<u64> for ProtocolVersion {
399 type Output = Self;
400 fn sub(self, rhs: u64) -> Self::Output {
401 Self::new(self.0 - rhs)
402 }
403}
404
405impl std::ops::Add<u64> for ProtocolVersion {
406 type Output = Self;
407 fn add(self, rhs: u64) -> Self::Output {
408 Self::new(self.0 + rhs)
409 }
410}
411
412#[derive(
413 Clone, Serialize, Deserialize, Debug, Default, PartialEq, Copy, PartialOrd, Ord, Eq, ValueEnum,
414)]
415pub enum Chain {
416 Mainnet,
417 Testnet,
418 #[default]
419 Unknown,
420}
421
422impl Chain {
423 pub fn as_str(self) -> &'static str {
424 match self {
425 Chain::Mainnet => "mainnet",
426 Chain::Testnet => "testnet",
427 Chain::Unknown => "unknown",
428 }
429 }
430}
431
432pub struct Error(pub String);
433
434#[derive(Default, Clone, Serialize, Deserialize, Debug, ProtocolConfigFeatureFlagsGetters)]
437struct FeatureFlags {
438 #[serde(skip_serializing_if = "is_false")]
441 package_upgrades: bool,
442 #[serde(skip_serializing_if = "is_false")]
445 commit_root_state_digest: bool,
446 #[serde(skip_serializing_if = "is_false")]
448 advance_epoch_start_time_in_safe_mode: bool,
449 #[serde(skip_serializing_if = "is_false")]
452 loaded_child_objects_fixed: bool,
453 #[serde(skip_serializing_if = "is_false")]
456 missing_type_is_compatibility_error: bool,
457 #[serde(skip_serializing_if = "is_false")]
460 scoring_decision_with_validity_cutoff: bool,
461
462 #[serde(skip_serializing_if = "is_false")]
465 consensus_order_end_of_epoch_last: bool,
466
467 #[serde(skip_serializing_if = "is_false")]
469 disallow_adding_abilities_on_upgrade: bool,
470 #[serde(skip_serializing_if = "is_false")]
472 disable_invariant_violation_check_in_swap_loc: bool,
473 #[serde(skip_serializing_if = "is_false")]
476 advance_to_highest_supported_protocol_version: bool,
477 #[serde(skip_serializing_if = "is_false")]
479 ban_entry_init: bool,
480 #[serde(skip_serializing_if = "is_false")]
482 package_digest_hash_module: bool,
483 #[serde(skip_serializing_if = "is_false")]
485 disallow_change_struct_type_params_on_upgrade: bool,
486 #[serde(skip_serializing_if = "is_false")]
488 no_extraneous_module_bytes: bool,
489 #[serde(skip_serializing_if = "is_false")]
491 narwhal_versioned_metadata: bool,
492
493 #[serde(skip_serializing_if = "is_false")]
495 zklogin_auth: bool,
496 #[serde(skip_serializing_if = "ConsensusTransactionOrdering::is_none")]
498 consensus_transaction_ordering: ConsensusTransactionOrdering,
499
500 #[serde(skip_serializing_if = "is_false")]
508 simplified_unwrap_then_delete: bool,
509 #[serde(skip_serializing_if = "is_false")]
511 upgraded_multisig_supported: bool,
512 #[serde(skip_serializing_if = "is_false")]
514 txn_base_cost_as_multiplier: bool,
515
516 #[serde(skip_serializing_if = "is_false")]
518 shared_object_deletion: bool,
519
520 #[serde(skip_serializing_if = "is_false")]
522 narwhal_new_leader_election_schedule: bool,
523
524 #[serde(skip_serializing_if = "is_empty")]
526 zklogin_supported_providers: BTreeSet<String>,
527
528 #[serde(skip_serializing_if = "is_false")]
530 loaded_child_object_format: bool,
531
532 #[serde(skip_serializing_if = "is_false")]
533 enable_jwk_consensus_updates: bool,
534
535 #[serde(skip_serializing_if = "is_false")]
536 end_of_epoch_transaction_supported: bool,
537
538 #[serde(skip_serializing_if = "is_false")]
541 simple_conservation_checks: bool,
542
543 #[serde(skip_serializing_if = "is_false")]
545 loaded_child_object_format_type: bool,
546
547 #[serde(skip_serializing_if = "is_false")]
549 receive_objects: bool,
550
551 #[serde(skip_serializing_if = "is_false")]
553 consensus_checkpoint_signature_key_includes_digest: bool,
554
555 #[serde(skip_serializing_if = "is_false")]
557 random_beacon: bool,
558
559 #[serde(skip_serializing_if = "is_false")]
561 bridge: bool,
562
563 #[serde(skip_serializing_if = "is_false")]
564 enable_effects_v2: bool,
565
566 #[serde(skip_serializing_if = "is_false")]
568 narwhal_certificate_v2: bool,
569
570 #[serde(skip_serializing_if = "is_false")]
572 verify_legacy_zklogin_address: bool,
573
574 #[serde(skip_serializing_if = "is_false")]
576 throughput_aware_consensus_submission: bool,
577
578 #[serde(skip_serializing_if = "is_false")]
580 recompute_has_public_transfer_in_execution: bool,
581
582 #[serde(skip_serializing_if = "is_false")]
584 accept_zklogin_in_multisig: bool,
585
586 #[serde(skip_serializing_if = "is_false")]
588 accept_passkey_in_multisig: bool,
589
590 #[serde(skip_serializing_if = "is_false")]
592 validate_zklogin_public_identifier: bool,
593
594 #[serde(skip_serializing_if = "is_false")]
597 include_consensus_digest_in_prologue: bool,
598
599 #[serde(skip_serializing_if = "is_false")]
601 hardened_otw_check: bool,
602
603 #[serde(skip_serializing_if = "is_false")]
605 allow_receiving_object_id: bool,
606
607 #[serde(skip_serializing_if = "is_false")]
609 enable_poseidon: bool,
610
611 #[serde(skip_serializing_if = "is_false")]
613 enable_coin_deny_list: bool,
614
615 #[serde(skip_serializing_if = "is_false")]
617 enable_group_ops_native_functions: bool,
618
619 #[serde(skip_serializing_if = "is_false")]
621 enable_group_ops_native_function_msm: bool,
622
623 #[serde(skip_serializing_if = "is_false")]
625 enable_ristretto255_group_ops: bool,
626
627 #[serde(skip_serializing_if = "is_false")]
629 enable_verify_bulletproofs_ristretto255: bool,
630
631 #[serde(skip_serializing_if = "is_false")]
633 enable_nitro_attestation: bool,
634
635 #[serde(skip_serializing_if = "is_false")]
637 enable_nitro_attestation_upgraded_parsing: bool,
638
639 #[serde(skip_serializing_if = "is_false")]
641 enable_nitro_attestation_all_nonzero_pcrs_parsing: bool,
642
643 #[serde(skip_serializing_if = "is_false")]
645 enable_nitro_attestation_always_include_required_pcrs_parsing: bool,
646
647 #[serde(skip_serializing_if = "is_false")]
649 reject_mutable_random_on_entry_functions: bool,
650
651 #[serde(skip_serializing_if = "PerObjectCongestionControlMode::is_none")]
653 per_object_congestion_control_mode: PerObjectCongestionControlMode,
654
655 #[serde(skip_serializing_if = "ConsensusChoice::is_narwhal")]
657 consensus_choice: ConsensusChoice,
658
659 #[serde(skip_serializing_if = "ConsensusNetwork::is_anemo")]
661 consensus_network: ConsensusNetwork,
662
663 #[serde(skip_serializing_if = "is_false")]
665 correct_gas_payment_limit_check: bool,
666
667 #[serde(skip_serializing_if = "Option::is_none")]
669 zklogin_max_epoch_upper_bound_delta: Option<u64>,
670
671 #[serde(skip_serializing_if = "is_false")]
673 mysticeti_leader_scoring_and_schedule: bool,
674
675 #[serde(skip_serializing_if = "is_false")]
677 reshare_at_same_initial_version: bool,
678
679 #[serde(skip_serializing_if = "is_false")]
681 resolve_abort_locations_to_package_id: bool,
682
683 #[serde(skip_serializing_if = "is_false")]
687 mysticeti_use_committed_subdag_digest: bool,
688
689 #[serde(skip_serializing_if = "is_false")]
691 enable_vdf: bool,
692
693 #[serde(skip_serializing_if = "is_false")]
698 record_consensus_determined_version_assignments_in_prologue: bool,
699 #[serde(skip_serializing_if = "is_false")]
700 record_consensus_determined_version_assignments_in_prologue_v2: bool,
701
702 #[serde(skip_serializing_if = "is_false")]
704 fresh_vm_on_framework_upgrade: bool,
705
706 #[serde(skip_serializing_if = "is_false")]
714 prepend_prologue_tx_in_consensus_commit_in_checkpoints: bool,
715
716 #[serde(skip_serializing_if = "Option::is_none")]
718 mysticeti_num_leaders_per_round: Option<usize>,
719
720 #[serde(skip_serializing_if = "is_false")]
722 soft_bundle: bool,
723
724 #[serde(skip_serializing_if = "is_false")]
726 enable_coin_deny_list_v2: bool,
727
728 #[serde(skip_serializing_if = "is_false")]
730 passkey_auth: bool,
731
732 #[serde(skip_serializing_if = "is_false")]
734 authority_capabilities_v2: bool,
735
736 #[serde(skip_serializing_if = "is_false")]
738 rethrow_serialization_type_layout_errors: bool,
739
740 #[serde(skip_serializing_if = "is_false")]
742 consensus_distributed_vote_scoring_strategy: bool,
743
744 #[serde(skip_serializing_if = "is_false")]
746 consensus_round_prober: bool,
747
748 #[serde(skip_serializing_if = "is_false")]
750 validate_identifier_inputs: bool,
751
752 #[serde(skip_serializing_if = "is_false")]
754 disallow_self_identifier: bool,
755
756 #[serde(skip_serializing_if = "is_false")]
758 mysticeti_fastpath: bool,
759
760 #[serde(skip_serializing_if = "is_false")]
764 disable_preconsensus_locking: bool,
765
766 #[serde(skip_serializing_if = "is_false")]
768 relocate_event_module: bool,
769
770 #[serde(skip_serializing_if = "is_false")]
772 uncompressed_g1_group_elements: bool,
773
774 #[serde(skip_serializing_if = "is_false")]
775 disallow_new_modules_in_deps_only_packages: bool,
776
777 #[serde(skip_serializing_if = "is_false")]
779 consensus_smart_ancestor_selection: bool,
780
781 #[serde(skip_serializing_if = "is_false")]
783 consensus_round_prober_probe_accepted_rounds: bool,
784
785 #[serde(skip_serializing_if = "is_false")]
787 native_charging_v2: bool,
788
789 #[serde(skip_serializing_if = "is_false")]
792 consensus_linearize_subdag_v2: bool,
793
794 #[serde(skip_serializing_if = "is_false")]
796 convert_type_argument_error: bool,
797
798 #[serde(skip_serializing_if = "is_false")]
800 variant_nodes: bool,
801
802 #[serde(skip_serializing_if = "is_false")]
804 consensus_zstd_compression: bool,
805
806 #[serde(skip_serializing_if = "is_false")]
808 minimize_child_object_mutations: bool,
809
810 #[serde(skip_serializing_if = "is_false")]
812 record_additional_state_digest_in_prologue: bool,
813
814 #[serde(skip_serializing_if = "is_false")]
816 move_native_context: bool,
817
818 #[serde(skip_serializing_if = "is_false")]
821 consensus_median_based_commit_timestamp: bool,
822
823 #[serde(skip_serializing_if = "is_false")]
826 normalize_ptb_arguments: bool,
827
828 #[serde(skip_serializing_if = "is_false")]
830 consensus_batched_block_sync: bool,
831
832 #[serde(skip_serializing_if = "is_false")]
834 enforce_checkpoint_timestamp_monotonicity: bool,
835
836 #[serde(skip_serializing_if = "is_false")]
838 max_ptb_value_size_v2: bool,
839
840 #[serde(skip_serializing_if = "is_false")]
842 resolve_type_input_ids_to_defining_id: bool,
843
844 #[serde(skip_serializing_if = "is_false")]
846 enable_party_transfer: bool,
847
848 #[serde(skip_serializing_if = "is_false")]
850 allow_unbounded_system_objects: bool,
851
852 #[serde(skip_serializing_if = "is_false")]
854 type_tags_in_object_runtime: bool,
855
856 #[serde(skip_serializing_if = "is_false")]
858 enable_accumulators: bool,
859
860 #[serde(skip_serializing_if = "is_false")]
862 enable_coin_reservation_obj_refs: bool,
863
864 #[serde(skip_serializing_if = "is_false")]
867 create_root_accumulator_object: bool,
868
869 #[serde(skip_serializing_if = "is_false")]
871 enable_authenticated_event_streams: bool,
872
873 #[serde(skip_serializing_if = "is_false")]
875 enable_address_balance_gas_payments: bool,
876
877 #[serde(skip_serializing_if = "is_false")]
879 address_balance_gas_check_rgp_at_signing: bool,
880
881 #[serde(skip_serializing_if = "is_false")]
882 address_balance_gas_reject_gas_coin_arg: bool,
883
884 #[serde(skip_serializing_if = "is_false")]
886 enable_multi_epoch_transaction_expiration: bool,
887
888 #[serde(skip_serializing_if = "is_false")]
890 relax_valid_during_for_owned_inputs: bool,
891
892 #[serde(skip_serializing_if = "is_false")]
894 enable_ptb_execution_v2: bool,
895
896 #[serde(skip_serializing_if = "is_false")]
898 better_adapter_type_resolution_errors: bool,
899
900 #[serde(skip_serializing_if = "is_false")]
902 record_time_estimate_processed: bool,
903
904 #[serde(skip_serializing_if = "is_false")]
906 dependency_linkage_error: bool,
907
908 #[serde(skip_serializing_if = "is_false")]
910 additional_multisig_checks: bool,
911
912 #[serde(skip_serializing_if = "is_false")]
914 ignore_execution_time_observations_after_certs_closed: bool,
915
916 #[serde(skip_serializing_if = "is_false")]
920 debug_fatal_on_move_invariant_violation: bool,
921
922 #[serde(skip_serializing_if = "is_false")]
925 allow_private_accumulator_entrypoints: bool,
926
927 #[serde(skip_serializing_if = "is_false")]
929 additional_consensus_digest_indirect_state: bool,
930
931 #[serde(skip_serializing_if = "is_false")]
933 check_for_init_during_upgrade: bool,
934
935 #[serde(skip_serializing_if = "is_false")]
937 per_command_shared_object_transfer_rules: bool,
938
939 #[serde(skip_serializing_if = "is_false")]
941 include_checkpoint_artifacts_digest_in_summary: bool,
942
943 #[serde(skip_serializing_if = "is_false")]
945 use_mfp_txns_in_load_initial_object_debts: bool,
946
947 #[serde(skip_serializing_if = "is_false")]
949 cancel_for_failed_dkg_early: bool,
950
951 #[serde(skip_serializing_if = "is_false")]
953 enable_coin_registry: bool,
954
955 #[serde(skip_serializing_if = "is_false")]
957 abstract_size_in_object_runtime: bool,
958
959 #[serde(skip_serializing_if = "is_false")]
961 object_runtime_charge_cache_load_gas: bool,
962
963 #[serde(skip_serializing_if = "is_false")]
965 additional_borrow_checks: bool,
966
967 #[serde(skip_serializing_if = "is_false")]
969 use_new_commit_handler: bool,
970
971 #[serde(skip_serializing_if = "is_false")]
973 better_loader_errors: bool,
974
975 #[serde(skip_serializing_if = "is_false")]
977 generate_df_type_layouts: bool,
978
979 #[serde(skip_serializing_if = "is_false")]
981 allow_references_in_ptbs: bool,
982
983 #[serde(skip_serializing_if = "is_false")]
985 enable_display_registry: bool,
986
987 #[serde(skip_serializing_if = "is_false")]
989 private_generics_verifier_v2: bool,
990
991 #[serde(skip_serializing_if = "is_false")]
993 deprecate_global_storage_ops_during_deserialization: bool,
994
995 #[serde(skip_serializing_if = "is_false")]
998 enable_non_exclusive_writes: bool,
999
1000 #[serde(skip_serializing_if = "is_false")]
1002 deprecate_global_storage_ops: bool,
1003
1004 #[serde(skip_serializing_if = "is_false")]
1006 normalize_depth_formula: bool,
1007
1008 #[serde(skip_serializing_if = "is_false")]
1010 consensus_skip_gced_accept_votes: bool,
1011
1012 #[serde(skip_serializing_if = "is_false")]
1014 include_cancelled_randomness_txns_in_prologue: bool,
1015
1016 #[serde(skip_serializing_if = "is_false")]
1018 address_aliases: bool,
1019
1020 #[serde(skip_serializing_if = "is_false")]
1023 fix_checkpoint_signature_mapping: bool,
1024
1025 #[serde(skip_serializing_if = "is_false")]
1027 enable_object_funds_withdraw: bool,
1028
1029 #[serde(skip_serializing_if = "is_false")]
1031 consensus_skip_gced_blocks_in_direct_finalization: bool,
1032
1033 #[serde(skip_serializing_if = "is_false")]
1035 gas_rounding_halve_digits: bool,
1036
1037 #[serde(skip_serializing_if = "is_false")]
1039 flexible_tx_context_positions: bool,
1040
1041 #[serde(skip_serializing_if = "is_false")]
1043 disable_entry_point_signature_check: bool,
1044
1045 #[serde(skip_serializing_if = "is_false")]
1047 convert_withdrawal_compatibility_ptb_arguments: bool,
1048
1049 #[serde(skip_serializing_if = "is_false")]
1051 restrict_hot_or_not_entry_functions: bool,
1052
1053 #[serde(skip_serializing_if = "is_false")]
1055 split_checkpoints_in_consensus_handler: bool,
1056
1057 #[serde(skip_serializing_if = "is_false")]
1059 consensus_always_accept_system_transactions: bool,
1060
1061 #[serde(skip_serializing_if = "is_false")]
1063 validator_metadata_verify_v2: bool,
1064
1065 #[serde(skip_serializing_if = "is_false")]
1068 defer_unpaid_amplification: bool,
1069
1070 #[serde(skip_serializing_if = "is_false")]
1071 randomize_checkpoint_tx_limit_in_tests: bool,
1072
1073 #[serde(skip_serializing_if = "is_false")]
1075 gasless_transaction_drop_safety: bool,
1076
1077 #[serde(skip_serializing_if = "is_false")]
1079 merge_randomness_into_checkpoint: bool,
1080
1081 #[serde(skip_serializing_if = "is_false")]
1083 use_coin_party_owner: bool,
1084
1085 #[serde(skip_serializing_if = "is_false")]
1086 enable_gasless: bool,
1087
1088 #[serde(skip_serializing_if = "is_false")]
1089 gasless_verify_remaining_balance: bool,
1090
1091 #[serde(skip_serializing_if = "is_false")]
1092 disallow_jump_orphans: bool,
1093
1094 #[serde(skip_serializing_if = "is_false")]
1096 early_return_receive_object_mismatched_type: bool,
1097
1098 #[serde(skip_serializing_if = "is_false")]
1103 timestamp_based_epoch_close: bool,
1104
1105 #[serde(skip_serializing_if = "is_false")]
1108 limit_groth16_pvk_inputs: bool,
1109
1110 #[serde(skip_serializing_if = "is_false")]
1115 enforce_address_balance_change_invariant: bool,
1116}
1117
1118fn is_false(b: &bool) -> bool {
1119 !b
1120}
1121
1122fn is_empty(b: &BTreeSet<String>) -> bool {
1123 b.is_empty()
1124}
1125
1126fn is_zero(val: &u64) -> bool {
1127 *val == 0
1128}
1129
1130#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1132pub enum ConsensusTransactionOrdering {
1133 #[default]
1135 None,
1136 ByGasPrice,
1138}
1139
1140impl ConsensusTransactionOrdering {
1141 pub fn is_none(&self) -> bool {
1142 matches!(self, ConsensusTransactionOrdering::None)
1143 }
1144}
1145
1146#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1147pub struct ExecutionTimeEstimateParams {
1148 pub target_utilization: u64,
1150 pub allowed_txn_cost_overage_burst_limit_us: u64,
1154
1155 pub randomness_scalar: u64,
1158
1159 pub max_estimate_us: u64,
1161
1162 pub stored_observations_num_included_checkpoints: u64,
1165
1166 pub stored_observations_limit: u64,
1168
1169 #[serde(skip_serializing_if = "is_zero")]
1172 pub stake_weighted_median_threshold: u64,
1173
1174 #[serde(skip_serializing_if = "is_false")]
1178 pub default_none_duration_for_new_keys: bool,
1179
1180 #[serde(skip_serializing_if = "Option::is_none")]
1182 pub observations_chunk_size: Option<u64>,
1183}
1184
1185#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1187pub enum PerObjectCongestionControlMode {
1188 #[default]
1189 None, TotalGasBudget, TotalTxCount, TotalGasBudgetWithCap, ExecutionTimeEstimate(ExecutionTimeEstimateParams), }
1195
1196impl PerObjectCongestionControlMode {
1197 pub fn is_none(&self) -> bool {
1198 matches!(self, PerObjectCongestionControlMode::None)
1199 }
1200}
1201
1202#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1204pub enum ConsensusChoice {
1205 #[default]
1206 Narwhal,
1207 SwapEachEpoch,
1208 Mysticeti,
1209}
1210
1211impl ConsensusChoice {
1212 pub fn is_narwhal(&self) -> bool {
1213 matches!(self, ConsensusChoice::Narwhal)
1214 }
1215}
1216
1217#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1219pub enum ConsensusNetwork {
1220 #[default]
1221 Anemo,
1222 Tonic,
1223}
1224
1225impl ConsensusNetwork {
1226 pub fn is_anemo(&self) -> bool {
1227 matches!(self, ConsensusNetwork::Anemo)
1228 }
1229}
1230
1231#[skip_serializing_none]
1263#[derive(Clone, Serialize, Debug, ProtocolConfigAccessors, ProtocolConfigOverride)]
1264pub struct ProtocolConfig {
1265 pub version: ProtocolVersion,
1266
1267 feature_flags: FeatureFlags,
1268
1269 max_tx_size_bytes: Option<u64>,
1272
1273 max_input_objects: Option<u64>,
1275
1276 max_size_written_objects: Option<u64>,
1280 max_size_written_objects_system_tx: Option<u64>,
1283
1284 max_serialized_tx_effects_size_bytes: Option<u64>,
1286
1287 max_serialized_tx_effects_size_bytes_system_tx: Option<u64>,
1289
1290 max_gas_payment_objects: Option<u32>,
1292
1293 max_modules_in_publish: Option<u32>,
1295
1296 max_package_dependencies: Option<u32>,
1298
1299 max_arguments: Option<u32>,
1302
1303 max_type_arguments: Option<u32>,
1305
1306 max_type_argument_depth: Option<u32>,
1308
1309 max_pure_argument_size: Option<u32>,
1311
1312 max_programmable_tx_commands: Option<u32>,
1314
1315 move_binary_format_version: Option<u32>,
1318 min_move_binary_format_version: Option<u32>,
1319
1320 binary_module_handles: Option<u16>,
1322 binary_struct_handles: Option<u16>,
1323 binary_function_handles: Option<u16>,
1324 binary_function_instantiations: Option<u16>,
1325 binary_signatures: Option<u16>,
1326 binary_constant_pool: Option<u16>,
1327 binary_identifiers: Option<u16>,
1328 binary_address_identifiers: Option<u16>,
1329 binary_struct_defs: Option<u16>,
1330 binary_struct_def_instantiations: Option<u16>,
1331 binary_function_defs: Option<u16>,
1332 binary_field_handles: Option<u16>,
1333 binary_field_instantiations: Option<u16>,
1334 binary_friend_decls: Option<u16>,
1335 binary_enum_defs: Option<u16>,
1336 binary_enum_def_instantiations: Option<u16>,
1337 binary_variant_handles: Option<u16>,
1338 binary_variant_instantiation_handles: Option<u16>,
1339
1340 max_move_object_size: Option<u64>,
1342
1343 max_move_package_size: Option<u64>,
1346
1347 max_publish_or_upgrade_per_ptb: Option<u64>,
1349
1350 max_tx_gas: Option<u64>,
1352
1353 max_gas_price: Option<u64>,
1355
1356 max_gas_price_rgp_factor_for_aborted_transactions: Option<u64>,
1359
1360 max_gas_computation_bucket: Option<u64>,
1362
1363 gas_rounding_step: Option<u64>,
1365
1366 max_loop_depth: Option<u64>,
1368
1369 max_generic_instantiation_length: Option<u64>,
1371
1372 max_function_parameters: Option<u64>,
1374
1375 max_basic_blocks: Option<u64>,
1377
1378 max_value_stack_size: Option<u64>,
1380
1381 max_type_nodes: Option<u64>,
1383
1384 max_push_size: Option<u64>,
1386
1387 max_struct_definitions: Option<u64>,
1389
1390 max_function_definitions: Option<u64>,
1392
1393 max_fields_in_struct: Option<u64>,
1395
1396 max_dependency_depth: Option<u64>,
1398
1399 max_num_event_emit: Option<u64>,
1401
1402 max_num_new_move_object_ids: Option<u64>,
1404
1405 max_num_new_move_object_ids_system_tx: Option<u64>,
1407
1408 max_num_deleted_move_object_ids: Option<u64>,
1410
1411 max_num_deleted_move_object_ids_system_tx: Option<u64>,
1413
1414 max_num_transferred_move_object_ids: Option<u64>,
1416
1417 max_num_transferred_move_object_ids_system_tx: Option<u64>,
1419
1420 max_event_emit_size: Option<u64>,
1422
1423 max_event_emit_size_total: Option<u64>,
1425
1426 max_move_vector_len: Option<u64>,
1428
1429 max_move_identifier_len: Option<u64>,
1431
1432 max_move_value_depth: Option<u64>,
1434
1435 max_move_enum_variants: Option<u64>,
1437
1438 max_back_edges_per_function: Option<u64>,
1440
1441 max_back_edges_per_module: Option<u64>,
1443
1444 max_verifier_meter_ticks_per_function: Option<u64>,
1446
1447 max_meter_ticks_per_module: Option<u64>,
1449
1450 max_meter_ticks_per_package: Option<u64>,
1452
1453 object_runtime_max_num_cached_objects: Option<u64>,
1457
1458 object_runtime_max_num_cached_objects_system_tx: Option<u64>,
1460
1461 object_runtime_max_num_store_entries: Option<u64>,
1463
1464 object_runtime_max_num_store_entries_system_tx: Option<u64>,
1466
1467 base_tx_cost_fixed: Option<u64>,
1470
1471 package_publish_cost_fixed: Option<u64>,
1474
1475 base_tx_cost_per_byte: Option<u64>,
1478
1479 package_publish_cost_per_byte: Option<u64>,
1481
1482 obj_access_cost_read_per_byte: Option<u64>,
1484
1485 obj_access_cost_mutate_per_byte: Option<u64>,
1487
1488 obj_access_cost_delete_per_byte: Option<u64>,
1490
1491 obj_access_cost_verify_per_byte: Option<u64>,
1501
1502 max_type_to_layout_nodes: Option<u64>,
1504
1505 max_ptb_value_size: Option<u64>,
1507
1508 gas_model_version: Option<u64>,
1511
1512 obj_data_cost_refundable: Option<u64>,
1515
1516 obj_metadata_cost_non_refundable: Option<u64>,
1520
1521 storage_rebate_rate: Option<u64>,
1527
1528 storage_fund_reinvest_rate: Option<u64>,
1531
1532 reward_slashing_rate: Option<u64>,
1535
1536 storage_gas_price: Option<u64>,
1538
1539 accumulator_object_storage_cost: Option<u64>,
1541
1542 max_transactions_per_checkpoint: Option<u64>,
1547
1548 max_checkpoint_size_bytes: Option<u64>,
1552
1553 buffer_stake_for_protocol_upgrade_bps: Option<u64>,
1558
1559 address_from_bytes_cost_base: Option<u64>,
1564 address_to_u256_cost_base: Option<u64>,
1566 address_from_u256_cost_base: Option<u64>,
1568
1569 config_read_setting_impl_cost_base: Option<u64>,
1574 config_read_setting_impl_cost_per_byte: Option<u64>,
1575
1576 dynamic_field_hash_type_and_key_cost_base: Option<u64>,
1579 dynamic_field_hash_type_and_key_type_cost_per_byte: Option<u64>,
1580 dynamic_field_hash_type_and_key_value_cost_per_byte: Option<u64>,
1581 dynamic_field_hash_type_and_key_type_tag_cost_per_byte: Option<u64>,
1582 dynamic_field_add_child_object_cost_base: Option<u64>,
1584 dynamic_field_add_child_object_type_cost_per_byte: Option<u64>,
1585 dynamic_field_add_child_object_value_cost_per_byte: Option<u64>,
1586 dynamic_field_add_child_object_struct_tag_cost_per_byte: Option<u64>,
1587 dynamic_field_borrow_child_object_cost_base: Option<u64>,
1589 dynamic_field_borrow_child_object_child_ref_cost_per_byte: Option<u64>,
1590 dynamic_field_borrow_child_object_type_cost_per_byte: Option<u64>,
1591 dynamic_field_remove_child_object_cost_base: Option<u64>,
1593 dynamic_field_remove_child_object_child_cost_per_byte: Option<u64>,
1594 dynamic_field_remove_child_object_type_cost_per_byte: Option<u64>,
1595 dynamic_field_has_child_object_cost_base: Option<u64>,
1597 dynamic_field_has_child_object_with_ty_cost_base: Option<u64>,
1599 dynamic_field_has_child_object_with_ty_type_cost_per_byte: Option<u64>,
1600 dynamic_field_has_child_object_with_ty_type_tag_cost_per_byte: Option<u64>,
1601
1602 event_emit_cost_base: Option<u64>,
1605 event_emit_value_size_derivation_cost_per_byte: Option<u64>,
1606 event_emit_tag_size_derivation_cost_per_byte: Option<u64>,
1607 event_emit_output_cost_per_byte: Option<u64>,
1608 event_emit_auth_stream_cost: Option<u64>,
1609
1610 object_borrow_uid_cost_base: Option<u64>,
1613 object_delete_impl_cost_base: Option<u64>,
1615 object_record_new_uid_cost_base: Option<u64>,
1617
1618 transfer_transfer_internal_cost_base: Option<u64>,
1621 transfer_party_transfer_internal_cost_base: Option<u64>,
1623 transfer_freeze_object_cost_base: Option<u64>,
1625 transfer_share_object_cost_base: Option<u64>,
1627 transfer_receive_object_cost_base: Option<u64>,
1630 transfer_receive_object_cost_per_byte: Option<u64>,
1631 transfer_receive_object_type_cost_per_byte: Option<u64>,
1632
1633 tx_context_derive_id_cost_base: Option<u64>,
1636 tx_context_fresh_id_cost_base: Option<u64>,
1637 tx_context_sender_cost_base: Option<u64>,
1638 tx_context_epoch_cost_base: Option<u64>,
1639 tx_context_epoch_timestamp_ms_cost_base: Option<u64>,
1640 tx_context_sponsor_cost_base: Option<u64>,
1641 tx_context_rgp_cost_base: Option<u64>,
1642 tx_context_gas_price_cost_base: Option<u64>,
1643 tx_context_gas_budget_cost_base: Option<u64>,
1644 tx_context_ids_created_cost_base: Option<u64>,
1645 tx_context_replace_cost_base: Option<u64>,
1646
1647 types_is_one_time_witness_cost_base: Option<u64>,
1650 types_is_one_time_witness_type_tag_cost_per_byte: Option<u64>,
1651 types_is_one_time_witness_type_cost_per_byte: Option<u64>,
1652
1653 validator_validate_metadata_cost_base: Option<u64>,
1656 validator_validate_metadata_data_cost_per_byte: Option<u64>,
1657
1658 crypto_invalid_arguments_cost: Option<u64>,
1660 bls12381_bls12381_min_sig_verify_cost_base: Option<u64>,
1662 bls12381_bls12381_min_sig_verify_msg_cost_per_byte: Option<u64>,
1663 bls12381_bls12381_min_sig_verify_msg_cost_per_block: Option<u64>,
1664
1665 bls12381_bls12381_min_pk_verify_cost_base: Option<u64>,
1667 bls12381_bls12381_min_pk_verify_msg_cost_per_byte: Option<u64>,
1668 bls12381_bls12381_min_pk_verify_msg_cost_per_block: Option<u64>,
1669
1670 ecdsa_k1_ecrecover_keccak256_cost_base: Option<u64>,
1672 ecdsa_k1_ecrecover_keccak256_msg_cost_per_byte: Option<u64>,
1673 ecdsa_k1_ecrecover_keccak256_msg_cost_per_block: Option<u64>,
1674 ecdsa_k1_ecrecover_sha256_cost_base: Option<u64>,
1675 ecdsa_k1_ecrecover_sha256_msg_cost_per_byte: Option<u64>,
1676 ecdsa_k1_ecrecover_sha256_msg_cost_per_block: Option<u64>,
1677
1678 ecdsa_k1_decompress_pubkey_cost_base: Option<u64>,
1680
1681 ecdsa_k1_secp256k1_verify_keccak256_cost_base: Option<u64>,
1683 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_byte: Option<u64>,
1684 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_block: Option<u64>,
1685 ecdsa_k1_secp256k1_verify_sha256_cost_base: Option<u64>,
1686 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_byte: Option<u64>,
1687 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_block: Option<u64>,
1688
1689 ecdsa_r1_ecrecover_keccak256_cost_base: Option<u64>,
1691 ecdsa_r1_ecrecover_keccak256_msg_cost_per_byte: Option<u64>,
1692 ecdsa_r1_ecrecover_keccak256_msg_cost_per_block: Option<u64>,
1693 ecdsa_r1_ecrecover_sha256_cost_base: Option<u64>,
1694 ecdsa_r1_ecrecover_sha256_msg_cost_per_byte: Option<u64>,
1695 ecdsa_r1_ecrecover_sha256_msg_cost_per_block: Option<u64>,
1696
1697 ecdsa_r1_secp256r1_verify_keccak256_cost_base: Option<u64>,
1699 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_byte: Option<u64>,
1700 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_block: Option<u64>,
1701 ecdsa_r1_secp256r1_verify_sha256_cost_base: Option<u64>,
1702 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_byte: Option<u64>,
1703 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_block: Option<u64>,
1704
1705 ecvrf_ecvrf_verify_cost_base: Option<u64>,
1707 ecvrf_ecvrf_verify_alpha_string_cost_per_byte: Option<u64>,
1708 ecvrf_ecvrf_verify_alpha_string_cost_per_block: Option<u64>,
1709
1710 ed25519_ed25519_verify_cost_base: Option<u64>,
1712 ed25519_ed25519_verify_msg_cost_per_byte: Option<u64>,
1713 ed25519_ed25519_verify_msg_cost_per_block: Option<u64>,
1714
1715 groth16_prepare_verifying_key_bls12381_cost_base: Option<u64>,
1717 groth16_prepare_verifying_key_bn254_cost_base: Option<u64>,
1718
1719 groth16_verify_groth16_proof_internal_bls12381_cost_base: Option<u64>,
1721 groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input: Option<u64>,
1722 groth16_verify_groth16_proof_internal_bn254_cost_base: Option<u64>,
1723 groth16_verify_groth16_proof_internal_bn254_cost_per_public_input: Option<u64>,
1724 groth16_verify_groth16_proof_internal_public_input_cost_per_byte: Option<u64>,
1725
1726 hash_blake2b256_cost_base: Option<u64>,
1728 hash_blake2b256_data_cost_per_byte: Option<u64>,
1729 hash_blake2b256_data_cost_per_block: Option<u64>,
1730
1731 hash_keccak256_cost_base: Option<u64>,
1733 hash_keccak256_data_cost_per_byte: Option<u64>,
1734 hash_keccak256_data_cost_per_block: Option<u64>,
1735
1736 poseidon_bn254_cost_base: Option<u64>,
1738 poseidon_bn254_cost_per_block: Option<u64>,
1739
1740 group_ops_bls12381_decode_scalar_cost: Option<u64>,
1742 group_ops_bls12381_decode_g1_cost: Option<u64>,
1743 group_ops_bls12381_decode_g2_cost: Option<u64>,
1744 group_ops_bls12381_decode_gt_cost: Option<u64>,
1745 group_ops_bls12381_scalar_add_cost: Option<u64>,
1746 group_ops_bls12381_g1_add_cost: Option<u64>,
1747 group_ops_bls12381_g2_add_cost: Option<u64>,
1748 group_ops_bls12381_gt_add_cost: Option<u64>,
1749 group_ops_bls12381_scalar_sub_cost: Option<u64>,
1750 group_ops_bls12381_g1_sub_cost: Option<u64>,
1751 group_ops_bls12381_g2_sub_cost: Option<u64>,
1752 group_ops_bls12381_gt_sub_cost: Option<u64>,
1753 group_ops_bls12381_scalar_mul_cost: Option<u64>,
1754 group_ops_bls12381_g1_mul_cost: Option<u64>,
1755 group_ops_bls12381_g2_mul_cost: Option<u64>,
1756 group_ops_bls12381_gt_mul_cost: Option<u64>,
1757 group_ops_bls12381_scalar_div_cost: Option<u64>,
1758 group_ops_bls12381_g1_div_cost: Option<u64>,
1759 group_ops_bls12381_g2_div_cost: Option<u64>,
1760 group_ops_bls12381_gt_div_cost: Option<u64>,
1761 group_ops_bls12381_g1_hash_to_base_cost: Option<u64>,
1762 group_ops_bls12381_g2_hash_to_base_cost: Option<u64>,
1763 group_ops_bls12381_g1_hash_to_cost_per_byte: Option<u64>,
1764 group_ops_bls12381_g2_hash_to_cost_per_byte: Option<u64>,
1765 group_ops_bls12381_g1_msm_base_cost: Option<u64>,
1766 group_ops_bls12381_g2_msm_base_cost: Option<u64>,
1767 group_ops_bls12381_g1_msm_base_cost_per_input: Option<u64>,
1768 group_ops_bls12381_g2_msm_base_cost_per_input: Option<u64>,
1769 group_ops_bls12381_msm_max_len: Option<u32>,
1770 group_ops_bls12381_pairing_cost: Option<u64>,
1771 group_ops_bls12381_g1_to_uncompressed_g1_cost: Option<u64>,
1772 group_ops_bls12381_uncompressed_g1_to_g1_cost: Option<u64>,
1773 group_ops_bls12381_uncompressed_g1_sum_base_cost: Option<u64>,
1774 group_ops_bls12381_uncompressed_g1_sum_cost_per_term: Option<u64>,
1775 group_ops_bls12381_uncompressed_g1_sum_max_terms: Option<u64>,
1776
1777 group_ops_ristretto_decode_scalar_cost: Option<u64>,
1778 group_ops_ristretto_decode_point_cost: Option<u64>,
1779 group_ops_ristretto_scalar_add_cost: Option<u64>,
1780 group_ops_ristretto_point_add_cost: Option<u64>,
1781 group_ops_ristretto_scalar_sub_cost: Option<u64>,
1782 group_ops_ristretto_point_sub_cost: Option<u64>,
1783 group_ops_ristretto_scalar_mul_cost: Option<u64>,
1784 group_ops_ristretto_point_mul_cost: Option<u64>,
1785 group_ops_ristretto_scalar_div_cost: Option<u64>,
1786 group_ops_ristretto_point_div_cost: Option<u64>,
1787
1788 verify_bulletproofs_ristretto255_base_cost: Option<u64>,
1789 verify_bulletproofs_ristretto255_cost_per_bit_and_commitment: Option<u64>,
1790
1791 hmac_hmac_sha3_256_cost_base: Option<u64>,
1793 hmac_hmac_sha3_256_input_cost_per_byte: Option<u64>,
1794 hmac_hmac_sha3_256_input_cost_per_block: Option<u64>,
1795
1796 check_zklogin_id_cost_base: Option<u64>,
1798 check_zklogin_issuer_cost_base: Option<u64>,
1800
1801 vdf_verify_vdf_cost: Option<u64>,
1802 vdf_hash_to_input_cost: Option<u64>,
1803
1804 nitro_attestation_parse_base_cost: Option<u64>,
1806 nitro_attestation_parse_cost_per_byte: Option<u64>,
1807 nitro_attestation_verify_base_cost: Option<u64>,
1808 nitro_attestation_verify_cost_per_cert: Option<u64>,
1809
1810 bcs_per_byte_serialized_cost: Option<u64>,
1812 bcs_legacy_min_output_size_cost: Option<u64>,
1813 bcs_failure_cost: Option<u64>,
1814
1815 hash_sha2_256_base_cost: Option<u64>,
1816 hash_sha2_256_per_byte_cost: Option<u64>,
1817 hash_sha2_256_legacy_min_input_len_cost: Option<u64>,
1818 hash_sha3_256_base_cost: Option<u64>,
1819 hash_sha3_256_per_byte_cost: Option<u64>,
1820 hash_sha3_256_legacy_min_input_len_cost: Option<u64>,
1821 type_name_get_base_cost: Option<u64>,
1822 type_name_get_per_byte_cost: Option<u64>,
1823 type_name_id_base_cost: Option<u64>,
1824
1825 string_check_utf8_base_cost: Option<u64>,
1826 string_check_utf8_per_byte_cost: Option<u64>,
1827 string_is_char_boundary_base_cost: Option<u64>,
1828 string_sub_string_base_cost: Option<u64>,
1829 string_sub_string_per_byte_cost: Option<u64>,
1830 string_index_of_base_cost: Option<u64>,
1831 string_index_of_per_byte_pattern_cost: Option<u64>,
1832 string_index_of_per_byte_searched_cost: Option<u64>,
1833
1834 vector_empty_base_cost: Option<u64>,
1835 vector_length_base_cost: Option<u64>,
1836 vector_push_back_base_cost: Option<u64>,
1837 vector_push_back_legacy_per_abstract_memory_unit_cost: Option<u64>,
1838 vector_borrow_base_cost: Option<u64>,
1839 vector_pop_back_base_cost: Option<u64>,
1840 vector_destroy_empty_base_cost: Option<u64>,
1841 vector_swap_base_cost: Option<u64>,
1842 debug_print_base_cost: Option<u64>,
1843 debug_print_stack_trace_base_cost: Option<u64>,
1844
1845 execution_version: Option<u64>,
1854
1855 consensus_bad_nodes_stake_threshold: Option<u64>,
1859
1860 max_jwk_votes_per_validator_per_epoch: Option<u64>,
1861 max_age_of_jwk_in_epochs: Option<u64>,
1865
1866 random_beacon_reduction_allowed_delta: Option<u16>,
1870
1871 random_beacon_reduction_lower_bound: Option<u32>,
1874
1875 random_beacon_dkg_timeout_round: Option<u32>,
1878
1879 random_beacon_min_round_interval_ms: Option<u64>,
1881
1882 random_beacon_dkg_version: Option<u64>,
1885
1886 consensus_max_transaction_size_bytes: Option<u64>,
1889 consensus_max_transactions_in_block_bytes: Option<u64>,
1891 consensus_max_num_transactions_in_block: Option<u64>,
1893
1894 consensus_voting_rounds: Option<u32>,
1896
1897 max_accumulated_txn_cost_per_object_in_narwhal_commit: Option<u64>,
1899
1900 max_deferral_rounds_for_congestion_control: Option<u64>,
1903
1904 max_txn_cost_overage_per_object_in_commit: Option<u64>,
1906
1907 allowed_txn_cost_overage_burst_per_object_in_commit: Option<u64>,
1909
1910 min_checkpoint_interval_ms: Option<u64>,
1912
1913 checkpoint_summary_version_specific_data: Option<u64>,
1915
1916 max_soft_bundle_size: Option<u64>,
1918
1919 bridge_should_try_to_finalize_committee: Option<bool>,
1923
1924 max_accumulated_txn_cost_per_object_in_mysticeti_commit: Option<u64>,
1930
1931 max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit: Option<u64>,
1934
1935 consensus_gc_depth: Option<u32>,
1938
1939 gas_budget_based_txn_cost_cap_factor: Option<u64>,
1941
1942 gas_budget_based_txn_cost_absolute_cap_commit_count: Option<u64>,
1944
1945 sip_45_consensus_amplification_threshold: Option<u64>,
1948
1949 use_object_per_epoch_marker_table_v2: Option<bool>,
1952
1953 consensus_commit_rate_estimation_window_size: Option<u32>,
1955
1956 #[serde(skip_serializing_if = "Vec::is_empty")]
1960 aliased_addresses: Vec<AliasedAddress>,
1961
1962 translation_per_command_base_charge: Option<u64>,
1965
1966 translation_per_input_base_charge: Option<u64>,
1969
1970 translation_pure_input_per_byte_charge: Option<u64>,
1972
1973 translation_per_type_node_charge: Option<u64>,
1977
1978 translation_per_reference_node_charge: Option<u64>,
1981
1982 translation_per_linkage_entry_charge: Option<u64>,
1985
1986 max_updates_per_settlement_txn: Option<u32>,
1988
1989 gasless_max_computation_units: Option<u64>,
1991
1992 #[skip_accessor]
1994 gasless_allowed_token_types: Option<Vec<(String, u64)>>,
1995
1996 gasless_max_unused_inputs: Option<u64>,
2000
2001 gasless_max_pure_input_bytes: Option<u64>,
2004
2005 gasless_max_tps: Option<u64>,
2007
2008 #[serde(skip_serializing_if = "Option::is_none")]
2009 #[skip_accessor]
2010 include_special_package_amendments: Option<Arc<Amendments>>,
2011
2012 gasless_max_tx_size_bytes: Option<u64>,
2015}
2016
2017#[derive(Clone, Serialize, Deserialize, Debug)]
2019pub struct AliasedAddress {
2020 pub original: [u8; 32],
2022 pub aliased: [u8; 32],
2024 pub allowed_tx_digests: Vec<[u8; 32]>,
2026}
2027
2028impl ProtocolConfig {
2030 pub fn check_package_upgrades_supported(&self) -> Result<(), Error> {
2043 if self.feature_flags.package_upgrades {
2044 Ok(())
2045 } else {
2046 Err(Error(format!(
2047 "package upgrades are not supported at {:?}",
2048 self.version
2049 )))
2050 }
2051 }
2052
2053 pub fn allow_receiving_object_id(&self) -> bool {
2054 self.feature_flags.allow_receiving_object_id
2055 }
2056
2057 pub fn receiving_objects_supported(&self) -> bool {
2058 self.feature_flags.receive_objects
2059 }
2060
2061 pub fn package_upgrades_supported(&self) -> bool {
2062 self.feature_flags.package_upgrades
2063 }
2064
2065 pub fn check_commit_root_state_digest_supported(&self) -> bool {
2066 self.feature_flags.commit_root_state_digest
2067 }
2068
2069 pub fn get_advance_epoch_start_time_in_safe_mode(&self) -> bool {
2070 self.feature_flags.advance_epoch_start_time_in_safe_mode
2071 }
2072
2073 pub fn loaded_child_objects_fixed(&self) -> bool {
2074 self.feature_flags.loaded_child_objects_fixed
2075 }
2076
2077 pub fn missing_type_is_compatibility_error(&self) -> bool {
2078 self.feature_flags.missing_type_is_compatibility_error
2079 }
2080
2081 pub fn scoring_decision_with_validity_cutoff(&self) -> bool {
2082 self.feature_flags.scoring_decision_with_validity_cutoff
2083 }
2084
2085 pub fn narwhal_versioned_metadata(&self) -> bool {
2086 self.feature_flags.narwhal_versioned_metadata
2087 }
2088
2089 pub fn consensus_order_end_of_epoch_last(&self) -> bool {
2090 self.feature_flags.consensus_order_end_of_epoch_last
2091 }
2092
2093 pub fn disallow_adding_abilities_on_upgrade(&self) -> bool {
2094 self.feature_flags.disallow_adding_abilities_on_upgrade
2095 }
2096
2097 pub fn disable_invariant_violation_check_in_swap_loc(&self) -> bool {
2098 self.feature_flags
2099 .disable_invariant_violation_check_in_swap_loc
2100 }
2101
2102 pub fn advance_to_highest_supported_protocol_version(&self) -> bool {
2103 self.feature_flags
2104 .advance_to_highest_supported_protocol_version
2105 }
2106
2107 pub fn ban_entry_init(&self) -> bool {
2108 self.feature_flags.ban_entry_init
2109 }
2110
2111 pub fn package_digest_hash_module(&self) -> bool {
2112 self.feature_flags.package_digest_hash_module
2113 }
2114
2115 pub fn disallow_change_struct_type_params_on_upgrade(&self) -> bool {
2116 self.feature_flags
2117 .disallow_change_struct_type_params_on_upgrade
2118 }
2119
2120 pub fn no_extraneous_module_bytes(&self) -> bool {
2121 self.feature_flags.no_extraneous_module_bytes
2122 }
2123
2124 pub fn zklogin_auth(&self) -> bool {
2125 self.feature_flags.zklogin_auth
2126 }
2127
2128 pub fn zklogin_supported_providers(&self) -> &BTreeSet<String> {
2129 &self.feature_flags.zklogin_supported_providers
2130 }
2131
2132 pub fn consensus_transaction_ordering(&self) -> ConsensusTransactionOrdering {
2133 self.feature_flags.consensus_transaction_ordering
2134 }
2135
2136 pub fn simplified_unwrap_then_delete(&self) -> bool {
2137 self.feature_flags.simplified_unwrap_then_delete
2138 }
2139
2140 pub fn supports_upgraded_multisig(&self) -> bool {
2141 self.feature_flags.upgraded_multisig_supported
2142 }
2143
2144 pub fn txn_base_cost_as_multiplier(&self) -> bool {
2145 self.feature_flags.txn_base_cost_as_multiplier
2146 }
2147
2148 pub fn shared_object_deletion(&self) -> bool {
2149 self.feature_flags.shared_object_deletion
2150 }
2151
2152 pub fn narwhal_new_leader_election_schedule(&self) -> bool {
2153 self.feature_flags.narwhal_new_leader_election_schedule
2154 }
2155
2156 pub fn loaded_child_object_format(&self) -> bool {
2157 self.feature_flags.loaded_child_object_format
2158 }
2159
2160 pub fn enable_jwk_consensus_updates(&self) -> bool {
2161 let ret = self.feature_flags.enable_jwk_consensus_updates;
2162 if ret {
2163 assert!(self.feature_flags.end_of_epoch_transaction_supported);
2165 }
2166 ret
2167 }
2168
2169 pub fn simple_conservation_checks(&self) -> bool {
2170 self.feature_flags.simple_conservation_checks
2171 }
2172
2173 pub fn loaded_child_object_format_type(&self) -> bool {
2174 self.feature_flags.loaded_child_object_format_type
2175 }
2176
2177 pub fn end_of_epoch_transaction_supported(&self) -> bool {
2178 let ret = self.feature_flags.end_of_epoch_transaction_supported;
2179 if !ret {
2180 assert!(!self.feature_flags.enable_jwk_consensus_updates);
2182 }
2183 ret
2184 }
2185
2186 pub fn recompute_has_public_transfer_in_execution(&self) -> bool {
2187 self.feature_flags
2188 .recompute_has_public_transfer_in_execution
2189 }
2190
2191 pub fn create_authenticator_state_in_genesis(&self) -> bool {
2193 self.enable_jwk_consensus_updates()
2194 }
2195
2196 pub fn random_beacon(&self) -> bool {
2197 self.feature_flags.random_beacon
2198 }
2199
2200 pub fn dkg_version(&self) -> u64 {
2201 self.random_beacon_dkg_version.unwrap_or(1)
2203 }
2204
2205 pub fn enable_bridge(&self) -> bool {
2206 let ret = self.feature_flags.bridge;
2207 if ret {
2208 assert!(self.feature_flags.end_of_epoch_transaction_supported);
2210 }
2211 ret
2212 }
2213
2214 pub fn should_try_to_finalize_bridge_committee(&self) -> bool {
2215 if !self.enable_bridge() {
2216 return false;
2217 }
2218 self.bridge_should_try_to_finalize_committee.unwrap_or(true)
2220 }
2221
2222 pub fn enable_effects_v2(&self) -> bool {
2223 self.feature_flags.enable_effects_v2
2224 }
2225
2226 pub fn narwhal_certificate_v2(&self) -> bool {
2227 self.feature_flags.narwhal_certificate_v2
2228 }
2229
2230 pub fn verify_legacy_zklogin_address(&self) -> bool {
2231 self.feature_flags.verify_legacy_zklogin_address
2232 }
2233
2234 pub fn accept_zklogin_in_multisig(&self) -> bool {
2235 self.feature_flags.accept_zklogin_in_multisig
2236 }
2237
2238 pub fn accept_passkey_in_multisig(&self) -> bool {
2239 self.feature_flags.accept_passkey_in_multisig
2240 }
2241
2242 pub fn validate_zklogin_public_identifier(&self) -> bool {
2243 self.feature_flags.validate_zklogin_public_identifier
2244 }
2245
2246 pub fn zklogin_max_epoch_upper_bound_delta(&self) -> Option<u64> {
2247 self.feature_flags.zklogin_max_epoch_upper_bound_delta
2248 }
2249
2250 pub fn throughput_aware_consensus_submission(&self) -> bool {
2251 self.feature_flags.throughput_aware_consensus_submission
2252 }
2253
2254 pub fn include_consensus_digest_in_prologue(&self) -> bool {
2255 self.feature_flags.include_consensus_digest_in_prologue
2256 }
2257
2258 pub fn record_consensus_determined_version_assignments_in_prologue(&self) -> bool {
2259 self.feature_flags
2260 .record_consensus_determined_version_assignments_in_prologue
2261 }
2262
2263 pub fn record_additional_state_digest_in_prologue(&self) -> bool {
2264 self.feature_flags
2265 .record_additional_state_digest_in_prologue
2266 }
2267
2268 pub fn record_consensus_determined_version_assignments_in_prologue_v2(&self) -> bool {
2269 self.feature_flags
2270 .record_consensus_determined_version_assignments_in_prologue_v2
2271 }
2272
2273 pub fn prepend_prologue_tx_in_consensus_commit_in_checkpoints(&self) -> bool {
2274 self.feature_flags
2275 .prepend_prologue_tx_in_consensus_commit_in_checkpoints
2276 }
2277
2278 pub fn hardened_otw_check(&self) -> bool {
2279 self.feature_flags.hardened_otw_check
2280 }
2281
2282 pub fn enable_poseidon(&self) -> bool {
2283 self.feature_flags.enable_poseidon
2284 }
2285
2286 pub fn enable_coin_deny_list_v1(&self) -> bool {
2287 self.feature_flags.enable_coin_deny_list
2288 }
2289
2290 pub fn enable_accumulators(&self) -> bool {
2291 self.feature_flags.enable_accumulators
2292 }
2293
2294 pub fn enable_coin_reservation_obj_refs(&self) -> bool {
2295 self.new_vm_enabled() && self.feature_flags.enable_coin_reservation_obj_refs
2296 }
2297
2298 pub fn create_root_accumulator_object(&self) -> bool {
2299 self.feature_flags.create_root_accumulator_object
2300 }
2301
2302 pub fn enable_address_balance_gas_payments(&self) -> bool {
2303 self.feature_flags.enable_address_balance_gas_payments
2304 }
2305
2306 pub fn address_balance_gas_check_rgp_at_signing(&self) -> bool {
2307 self.feature_flags.address_balance_gas_check_rgp_at_signing
2308 }
2309
2310 pub fn address_balance_gas_reject_gas_coin_arg(&self) -> bool {
2311 self.feature_flags.address_balance_gas_reject_gas_coin_arg
2312 }
2313
2314 pub fn enable_multi_epoch_transaction_expiration(&self) -> bool {
2315 self.feature_flags.enable_multi_epoch_transaction_expiration
2316 }
2317
2318 pub fn relax_valid_during_for_owned_inputs(&self) -> bool {
2319 self.feature_flags.relax_valid_during_for_owned_inputs
2320 }
2321
2322 pub fn enable_authenticated_event_streams(&self) -> bool {
2323 self.feature_flags.enable_authenticated_event_streams && self.enable_accumulators()
2324 }
2325
2326 pub fn enable_non_exclusive_writes(&self) -> bool {
2327 self.feature_flags.enable_non_exclusive_writes
2328 }
2329
2330 pub fn enable_coin_registry(&self) -> bool {
2331 self.feature_flags.enable_coin_registry
2332 }
2333
2334 pub fn enable_display_registry(&self) -> bool {
2335 self.feature_flags.enable_display_registry
2336 }
2337
2338 pub fn enable_coin_deny_list_v2(&self) -> bool {
2339 self.feature_flags.enable_coin_deny_list_v2
2340 }
2341
2342 pub fn enable_group_ops_native_functions(&self) -> bool {
2343 self.feature_flags.enable_group_ops_native_functions
2344 }
2345
2346 pub fn enable_group_ops_native_function_msm(&self) -> bool {
2347 self.feature_flags.enable_group_ops_native_function_msm
2348 }
2349
2350 pub fn enable_ristretto255_group_ops(&self) -> bool {
2351 self.feature_flags.enable_ristretto255_group_ops
2352 }
2353
2354 pub fn enable_verify_bulletproofs_ristretto255(&self) -> bool {
2355 self.feature_flags.enable_verify_bulletproofs_ristretto255
2356 }
2357
2358 pub fn reject_mutable_random_on_entry_functions(&self) -> bool {
2359 self.feature_flags.reject_mutable_random_on_entry_functions
2360 }
2361
2362 pub fn per_object_congestion_control_mode(&self) -> PerObjectCongestionControlMode {
2363 self.feature_flags.per_object_congestion_control_mode
2364 }
2365
2366 pub fn consensus_choice(&self) -> ConsensusChoice {
2367 self.feature_flags.consensus_choice
2368 }
2369
2370 pub fn consensus_network(&self) -> ConsensusNetwork {
2371 self.feature_flags.consensus_network
2372 }
2373
2374 pub fn correct_gas_payment_limit_check(&self) -> bool {
2375 self.feature_flags.correct_gas_payment_limit_check
2376 }
2377
2378 pub fn reshare_at_same_initial_version(&self) -> bool {
2379 self.feature_flags.reshare_at_same_initial_version
2380 }
2381
2382 pub fn resolve_abort_locations_to_package_id(&self) -> bool {
2383 self.feature_flags.resolve_abort_locations_to_package_id
2384 }
2385
2386 pub fn mysticeti_use_committed_subdag_digest(&self) -> bool {
2387 self.feature_flags.mysticeti_use_committed_subdag_digest
2388 }
2389
2390 pub fn enable_vdf(&self) -> bool {
2391 self.feature_flags.enable_vdf
2392 }
2393
2394 pub fn fresh_vm_on_framework_upgrade(&self) -> bool {
2395 self.feature_flags.fresh_vm_on_framework_upgrade
2396 }
2397
2398 pub fn mysticeti_num_leaders_per_round(&self) -> Option<usize> {
2399 self.feature_flags.mysticeti_num_leaders_per_round
2400 }
2401
2402 pub fn soft_bundle(&self) -> bool {
2403 self.feature_flags.soft_bundle
2404 }
2405
2406 pub fn passkey_auth(&self) -> bool {
2407 self.feature_flags.passkey_auth
2408 }
2409
2410 pub fn authority_capabilities_v2(&self) -> bool {
2411 self.feature_flags.authority_capabilities_v2
2412 }
2413
2414 pub fn max_transaction_size_bytes(&self) -> u64 {
2415 self.consensus_max_transaction_size_bytes
2417 .unwrap_or(256 * 1024)
2418 }
2419
2420 pub fn max_transactions_in_block_bytes(&self) -> u64 {
2421 if cfg!(msim) {
2422 256 * 1024
2423 } else {
2424 self.consensus_max_transactions_in_block_bytes
2425 .unwrap_or(512 * 1024)
2426 }
2427 }
2428
2429 pub fn max_num_transactions_in_block(&self) -> u64 {
2430 if cfg!(msim) {
2431 8
2432 } else {
2433 self.consensus_max_num_transactions_in_block.unwrap_or(512)
2434 }
2435 }
2436
2437 pub fn rethrow_serialization_type_layout_errors(&self) -> bool {
2438 self.feature_flags.rethrow_serialization_type_layout_errors
2439 }
2440
2441 pub fn consensus_distributed_vote_scoring_strategy(&self) -> bool {
2442 self.feature_flags
2443 .consensus_distributed_vote_scoring_strategy
2444 }
2445
2446 pub fn consensus_round_prober(&self) -> bool {
2447 self.feature_flags.consensus_round_prober
2448 }
2449
2450 pub fn validate_identifier_inputs(&self) -> bool {
2451 self.feature_flags.validate_identifier_inputs
2452 }
2453
2454 pub fn gc_depth(&self) -> u32 {
2455 self.consensus_gc_depth.unwrap_or(0)
2456 }
2457
2458 pub fn mysticeti_fastpath(&self) -> bool {
2459 self.feature_flags.mysticeti_fastpath
2460 }
2461
2462 pub fn relocate_event_module(&self) -> bool {
2463 self.feature_flags.relocate_event_module
2464 }
2465
2466 pub fn uncompressed_g1_group_elements(&self) -> bool {
2467 self.feature_flags.uncompressed_g1_group_elements
2468 }
2469
2470 pub fn disallow_new_modules_in_deps_only_packages(&self) -> bool {
2471 self.feature_flags
2472 .disallow_new_modules_in_deps_only_packages
2473 }
2474
2475 pub fn consensus_smart_ancestor_selection(&self) -> bool {
2476 self.feature_flags.consensus_smart_ancestor_selection
2477 }
2478
2479 pub fn disable_preconsensus_locking(&self) -> bool {
2480 self.feature_flags.disable_preconsensus_locking
2481 }
2482
2483 pub fn consensus_round_prober_probe_accepted_rounds(&self) -> bool {
2484 self.feature_flags
2485 .consensus_round_prober_probe_accepted_rounds
2486 }
2487
2488 pub fn native_charging_v2(&self) -> bool {
2489 self.feature_flags.native_charging_v2
2490 }
2491
2492 pub fn consensus_linearize_subdag_v2(&self) -> bool {
2493 let res = self.feature_flags.consensus_linearize_subdag_v2;
2494 assert!(
2495 !res || self.gc_depth() > 0,
2496 "The consensus linearize sub dag V2 requires GC to be enabled"
2497 );
2498 res
2499 }
2500
2501 pub fn consensus_median_based_commit_timestamp(&self) -> bool {
2502 let res = self.feature_flags.consensus_median_based_commit_timestamp;
2503 assert!(
2504 !res || self.gc_depth() > 0,
2505 "The consensus median based commit timestamp requires GC to be enabled"
2506 );
2507 res
2508 }
2509
2510 pub fn consensus_batched_block_sync(&self) -> bool {
2511 self.feature_flags.consensus_batched_block_sync
2512 }
2513
2514 pub fn convert_type_argument_error(&self) -> bool {
2515 self.feature_flags.convert_type_argument_error
2516 }
2517
2518 pub fn variant_nodes(&self) -> bool {
2519 self.feature_flags.variant_nodes
2520 }
2521
2522 pub fn consensus_zstd_compression(&self) -> bool {
2523 self.feature_flags.consensus_zstd_compression
2524 }
2525
2526 pub fn enable_nitro_attestation(&self) -> bool {
2527 self.feature_flags.enable_nitro_attestation
2528 }
2529
2530 pub fn enable_nitro_attestation_upgraded_parsing(&self) -> bool {
2531 self.feature_flags.enable_nitro_attestation_upgraded_parsing
2532 }
2533
2534 pub fn enable_nitro_attestation_all_nonzero_pcrs_parsing(&self) -> bool {
2535 self.feature_flags
2536 .enable_nitro_attestation_all_nonzero_pcrs_parsing
2537 }
2538
2539 pub fn enable_nitro_attestation_always_include_required_pcrs_parsing(&self) -> bool {
2540 self.feature_flags
2541 .enable_nitro_attestation_always_include_required_pcrs_parsing
2542 }
2543
2544 pub fn get_consensus_commit_rate_estimation_window_size(&self) -> u32 {
2545 self.consensus_commit_rate_estimation_window_size
2546 .unwrap_or(0)
2547 }
2548
2549 pub fn consensus_num_requested_prior_commits_at_startup(&self) -> u32 {
2550 let window_size = self.get_consensus_commit_rate_estimation_window_size();
2554 assert!(window_size == 0 || self.record_additional_state_digest_in_prologue());
2556 window_size
2557 }
2558
2559 pub fn minimize_child_object_mutations(&self) -> bool {
2560 self.feature_flags.minimize_child_object_mutations
2561 }
2562
2563 pub fn move_native_context(&self) -> bool {
2564 self.feature_flags.move_native_context
2565 }
2566
2567 pub fn normalize_ptb_arguments(&self) -> bool {
2568 self.feature_flags.normalize_ptb_arguments
2569 }
2570
2571 pub fn enforce_checkpoint_timestamp_monotonicity(&self) -> bool {
2572 self.feature_flags.enforce_checkpoint_timestamp_monotonicity
2573 }
2574
2575 pub fn max_ptb_value_size_v2(&self) -> bool {
2576 self.feature_flags.max_ptb_value_size_v2
2577 }
2578
2579 pub fn resolve_type_input_ids_to_defining_id(&self) -> bool {
2580 self.feature_flags.resolve_type_input_ids_to_defining_id
2581 }
2582
2583 pub fn enable_party_transfer(&self) -> bool {
2584 self.feature_flags.enable_party_transfer
2585 }
2586
2587 pub fn allow_unbounded_system_objects(&self) -> bool {
2588 self.feature_flags.allow_unbounded_system_objects
2589 }
2590
2591 pub fn type_tags_in_object_runtime(&self) -> bool {
2592 self.feature_flags.type_tags_in_object_runtime
2593 }
2594
2595 pub fn enable_ptb_execution_v2(&self) -> bool {
2596 self.feature_flags.enable_ptb_execution_v2
2597 }
2598
2599 pub fn better_adapter_type_resolution_errors(&self) -> bool {
2600 self.feature_flags.better_adapter_type_resolution_errors
2601 }
2602
2603 pub fn record_time_estimate_processed(&self) -> bool {
2604 self.feature_flags.record_time_estimate_processed
2605 }
2606
2607 pub fn ignore_execution_time_observations_after_certs_closed(&self) -> bool {
2608 self.feature_flags
2609 .ignore_execution_time_observations_after_certs_closed
2610 }
2611
2612 pub fn dependency_linkage_error(&self) -> bool {
2613 self.feature_flags.dependency_linkage_error
2614 }
2615
2616 pub fn additional_multisig_checks(&self) -> bool {
2617 self.feature_flags.additional_multisig_checks
2618 }
2619
2620 pub fn debug_fatal_on_move_invariant_violation(&self) -> bool {
2621 self.feature_flags.debug_fatal_on_move_invariant_violation
2622 }
2623
2624 pub fn allow_private_accumulator_entrypoints(&self) -> bool {
2625 self.feature_flags.allow_private_accumulator_entrypoints
2626 }
2627
2628 pub fn additional_consensus_digest_indirect_state(&self) -> bool {
2629 self.feature_flags
2630 .additional_consensus_digest_indirect_state
2631 }
2632
2633 pub fn check_for_init_during_upgrade(&self) -> bool {
2634 self.feature_flags.check_for_init_during_upgrade
2635 }
2636
2637 pub fn per_command_shared_object_transfer_rules(&self) -> bool {
2638 self.feature_flags.per_command_shared_object_transfer_rules
2639 }
2640
2641 pub fn consensus_checkpoint_signature_key_includes_digest(&self) -> bool {
2642 self.feature_flags
2643 .consensus_checkpoint_signature_key_includes_digest
2644 }
2645
2646 pub fn include_checkpoint_artifacts_digest_in_summary(&self) -> bool {
2647 self.feature_flags
2648 .include_checkpoint_artifacts_digest_in_summary
2649 }
2650
2651 pub fn use_mfp_txns_in_load_initial_object_debts(&self) -> bool {
2652 self.feature_flags.use_mfp_txns_in_load_initial_object_debts
2653 }
2654
2655 pub fn cancel_for_failed_dkg_early(&self) -> bool {
2656 self.feature_flags.cancel_for_failed_dkg_early
2657 }
2658
2659 pub fn abstract_size_in_object_runtime(&self) -> bool {
2660 self.feature_flags.abstract_size_in_object_runtime
2661 }
2662
2663 pub fn object_runtime_charge_cache_load_gas(&self) -> bool {
2664 self.feature_flags.object_runtime_charge_cache_load_gas
2665 }
2666
2667 pub fn additional_borrow_checks(&self) -> bool {
2668 self.feature_flags.additional_borrow_checks
2669 }
2670
2671 pub fn use_new_commit_handler(&self) -> bool {
2672 self.feature_flags.use_new_commit_handler
2673 }
2674
2675 pub fn better_loader_errors(&self) -> bool {
2676 self.feature_flags.better_loader_errors
2677 }
2678
2679 pub fn generate_df_type_layouts(&self) -> bool {
2680 self.feature_flags.generate_df_type_layouts
2681 }
2682
2683 pub fn allow_references_in_ptbs(&self) -> bool {
2684 self.feature_flags.allow_references_in_ptbs
2685 }
2686
2687 pub fn private_generics_verifier_v2(&self) -> bool {
2688 self.feature_flags.private_generics_verifier_v2
2689 }
2690
2691 pub fn deprecate_global_storage_ops_during_deserialization(&self) -> bool {
2692 self.feature_flags
2693 .deprecate_global_storage_ops_during_deserialization
2694 }
2695
2696 pub fn enable_observation_chunking(&self) -> bool {
2697 matches!(self.feature_flags.per_object_congestion_control_mode,
2698 PerObjectCongestionControlMode::ExecutionTimeEstimate(ref params)
2699 if params.observations_chunk_size.is_some()
2700 )
2701 }
2702
2703 pub fn deprecate_global_storage_ops(&self) -> bool {
2704 self.feature_flags.deprecate_global_storage_ops
2705 }
2706
2707 pub fn normalize_depth_formula(&self) -> bool {
2708 self.feature_flags.normalize_depth_formula
2709 }
2710
2711 pub fn consensus_skip_gced_accept_votes(&self) -> bool {
2712 self.feature_flags.consensus_skip_gced_accept_votes
2713 }
2714
2715 pub fn include_cancelled_randomness_txns_in_prologue(&self) -> bool {
2716 self.feature_flags
2717 .include_cancelled_randomness_txns_in_prologue
2718 }
2719
2720 pub fn address_aliases(&self) -> bool {
2721 let address_aliases = self.feature_flags.address_aliases;
2722 assert!(
2723 !address_aliases || self.mysticeti_fastpath(),
2724 "Address aliases requires Mysticeti fastpath to be enabled"
2725 );
2726 if address_aliases {
2727 assert!(
2728 self.feature_flags.disable_preconsensus_locking,
2729 "Address aliases requires CertifiedTransaction to be disabled"
2730 );
2731 }
2732 address_aliases
2733 }
2734
2735 pub fn fix_checkpoint_signature_mapping(&self) -> bool {
2736 self.feature_flags.fix_checkpoint_signature_mapping
2737 }
2738
2739 pub fn enable_object_funds_withdraw(&self) -> bool {
2740 self.feature_flags.enable_object_funds_withdraw
2741 }
2742
2743 pub fn gas_rounding_halve_digits(&self) -> bool {
2744 self.feature_flags.gas_rounding_halve_digits
2745 }
2746
2747 pub fn flexible_tx_context_positions(&self) -> bool {
2748 self.feature_flags.flexible_tx_context_positions
2749 }
2750
2751 pub fn disable_entry_point_signature_check(&self) -> bool {
2752 self.feature_flags.disable_entry_point_signature_check
2753 }
2754
2755 pub fn consensus_skip_gced_blocks_in_direct_finalization(&self) -> bool {
2756 self.feature_flags
2757 .consensus_skip_gced_blocks_in_direct_finalization
2758 }
2759
2760 pub fn convert_withdrawal_compatibility_ptb_arguments(&self) -> bool {
2761 self.feature_flags
2762 .convert_withdrawal_compatibility_ptb_arguments
2763 }
2764
2765 pub fn restrict_hot_or_not_entry_functions(&self) -> bool {
2766 self.feature_flags.restrict_hot_or_not_entry_functions
2767 }
2768
2769 pub fn split_checkpoints_in_consensus_handler(&self) -> bool {
2770 self.feature_flags.split_checkpoints_in_consensus_handler
2771 }
2772
2773 pub fn consensus_always_accept_system_transactions(&self) -> bool {
2774 self.feature_flags
2775 .consensus_always_accept_system_transactions
2776 }
2777
2778 pub fn validator_metadata_verify_v2(&self) -> bool {
2779 self.feature_flags.validator_metadata_verify_v2
2780 }
2781
2782 pub fn defer_unpaid_amplification(&self) -> bool {
2783 self.feature_flags.defer_unpaid_amplification
2784 }
2785
2786 pub fn gasless_transaction_drop_safety(&self) -> bool {
2787 self.feature_flags.gasless_transaction_drop_safety
2788 }
2789
2790 pub fn new_vm_enabled(&self) -> bool {
2791 self.execution_version.is_some_and(|v| v >= 4)
2792 }
2793
2794 pub fn merge_randomness_into_checkpoint(&self) -> bool {
2795 self.feature_flags.merge_randomness_into_checkpoint
2796 }
2797
2798 pub fn use_coin_party_owner(&self) -> bool {
2799 self.feature_flags.use_coin_party_owner
2800 }
2801
2802 pub fn enable_gasless(&self) -> bool {
2803 self.feature_flags.enable_gasless
2804 }
2805
2806 pub fn gasless_verify_remaining_balance(&self) -> bool {
2807 self.feature_flags.gasless_verify_remaining_balance
2808 }
2809
2810 pub fn gasless_allowed_token_types(&self) -> &[(String, u64)] {
2811 debug_assert!(self.gasless_allowed_token_types.is_some());
2812 self.gasless_allowed_token_types.as_deref().unwrap_or(&[])
2813 }
2814
2815 pub fn get_gasless_max_unused_inputs(&self) -> u64 {
2816 self.gasless_max_unused_inputs.unwrap_or(u64::MAX)
2817 }
2818
2819 pub fn get_gasless_max_pure_input_bytes(&self) -> u64 {
2820 self.gasless_max_pure_input_bytes.unwrap_or(u64::MAX)
2821 }
2822
2823 pub fn get_gasless_max_tx_size_bytes(&self) -> u64 {
2824 self.gasless_max_tx_size_bytes.unwrap_or(u64::MAX)
2825 }
2826
2827 pub fn disallow_jump_orphans(&self) -> bool {
2828 self.feature_flags.disallow_jump_orphans
2829 }
2830
2831 pub fn early_return_receive_object_mismatched_type(&self) -> bool {
2832 self.feature_flags
2833 .early_return_receive_object_mismatched_type
2834 }
2835
2836 pub fn include_special_package_amendments_as_option(&self) -> &Option<Arc<Amendments>> {
2837 &self.include_special_package_amendments
2838 }
2839
2840 pub fn timestamp_based_epoch_close(&self) -> bool {
2841 self.feature_flags.timestamp_based_epoch_close
2842 }
2843
2844 pub fn limit_groth16_pvk_inputs(&self) -> bool {
2845 self.feature_flags.limit_groth16_pvk_inputs
2846 }
2847
2848 pub fn enforce_address_balance_change_invariant(&self) -> bool {
2849 self.feature_flags.enforce_address_balance_change_invariant
2850 }
2851}
2852
2853#[cfg(not(msim))]
2854static POISON_VERSION_METHODS: AtomicBool = AtomicBool::new(false);
2855
2856#[cfg(msim)]
2858thread_local! {
2859 static POISON_VERSION_METHODS: AtomicBool = AtomicBool::new(false);
2860}
2861
2862impl ProtocolConfig {
2864 pub fn get_for_version(version: ProtocolVersion, chain: Chain) -> Self {
2866 assert!(
2868 version >= ProtocolVersion::MIN,
2869 "Network protocol version is {:?}, but the minimum supported version by the binary is {:?}. Please upgrade the binary.",
2870 version,
2871 ProtocolVersion::MIN.0,
2872 );
2873 assert!(
2874 version <= ProtocolVersion::MAX_ALLOWED,
2875 "Network protocol version is {:?}, but the maximum supported version by the binary is {:?}. Please upgrade the binary.",
2876 version,
2877 ProtocolVersion::MAX_ALLOWED.0,
2878 );
2879
2880 let mut ret = Self::get_for_version_impl(version, chain);
2881 ret.version = version;
2882
2883 ret = Self::apply_config_override(version, ret);
2884
2885 if std::env::var("SUI_PROTOCOL_CONFIG_OVERRIDE_ENABLE").is_ok() {
2886 warn!(
2887 "overriding ProtocolConfig settings with custom settings; this may break non-local networks"
2888 );
2889 let overrides: ProtocolConfigOptional =
2890 serde_env::from_env_with_prefix("SUI_PROTOCOL_CONFIG_OVERRIDE")
2891 .expect("failed to parse ProtocolConfig override env variables");
2892 overrides.apply_to(&mut ret);
2893 }
2894
2895 ret
2896 }
2897
2898 pub fn get_for_version_if_supported(version: ProtocolVersion, chain: Chain) -> Option<Self> {
2901 if version.0 >= ProtocolVersion::MIN.0 && version.0 <= ProtocolVersion::MAX_ALLOWED.0 {
2902 let mut ret = Self::get_for_version_impl(version, chain);
2903 ret.version = version;
2904 ret = Self::apply_config_override(version, ret);
2905 Some(ret)
2906 } else {
2907 None
2908 }
2909 }
2910
2911 #[cfg(not(msim))]
2912 pub fn poison_get_for_min_version() {
2913 POISON_VERSION_METHODS.store(true, Ordering::Relaxed);
2914 }
2915
2916 #[cfg(not(msim))]
2917 fn load_poison_get_for_min_version() -> bool {
2918 POISON_VERSION_METHODS.load(Ordering::Relaxed)
2919 }
2920
2921 #[cfg(msim)]
2922 pub fn poison_get_for_min_version() {
2923 POISON_VERSION_METHODS.with(|p| p.store(true, Ordering::Relaxed));
2924 }
2925
2926 #[cfg(msim)]
2927 fn load_poison_get_for_min_version() -> bool {
2928 POISON_VERSION_METHODS.with(|p| p.load(Ordering::Relaxed))
2929 }
2930
2931 pub fn get_for_min_version() -> Self {
2934 if Self::load_poison_get_for_min_version() {
2935 panic!("get_for_min_version called on validator");
2936 }
2937 ProtocolConfig::get_for_version(ProtocolVersion::MIN, Chain::Unknown)
2938 }
2939
2940 #[allow(non_snake_case)]
2950 pub fn get_for_max_version_UNSAFE() -> Self {
2951 if Self::load_poison_get_for_min_version() {
2952 panic!("get_for_max_version_UNSAFE called on validator");
2953 }
2954 ProtocolConfig::get_for_version(ProtocolVersion::MAX, Chain::Unknown)
2955 }
2956
2957 fn get_for_version_impl(version: ProtocolVersion, chain: Chain) -> Self {
2958 #[cfg(msim)]
2959 {
2960 if version == ProtocolVersion::MAX_ALLOWED {
2962 let mut config = Self::get_for_version_impl(version - 1, Chain::Unknown);
2963 config.base_tx_cost_fixed = Some(config.base_tx_cost_fixed() + 1000);
2964 return config;
2965 }
2966 }
2967
2968 let mut cfg = Self {
2971 version,
2973
2974 feature_flags: Default::default(),
2976
2977 max_tx_size_bytes: Some(128 * 1024),
2978 max_input_objects: Some(2048),
2980 max_serialized_tx_effects_size_bytes: Some(512 * 1024),
2981 max_serialized_tx_effects_size_bytes_system_tx: Some(512 * 1024 * 16),
2982 max_gas_payment_objects: Some(256),
2983 max_modules_in_publish: Some(128),
2984 max_package_dependencies: None,
2985 max_arguments: Some(512),
2986 max_type_arguments: Some(16),
2987 max_type_argument_depth: Some(16),
2988 max_pure_argument_size: Some(16 * 1024),
2989 max_programmable_tx_commands: Some(1024),
2990 move_binary_format_version: Some(6),
2991 min_move_binary_format_version: None,
2992 binary_module_handles: None,
2993 binary_struct_handles: None,
2994 binary_function_handles: None,
2995 binary_function_instantiations: None,
2996 binary_signatures: None,
2997 binary_constant_pool: None,
2998 binary_identifiers: None,
2999 binary_address_identifiers: None,
3000 binary_struct_defs: None,
3001 binary_struct_def_instantiations: None,
3002 binary_function_defs: None,
3003 binary_field_handles: None,
3004 binary_field_instantiations: None,
3005 binary_friend_decls: None,
3006 binary_enum_defs: None,
3007 binary_enum_def_instantiations: None,
3008 binary_variant_handles: None,
3009 binary_variant_instantiation_handles: None,
3010 max_move_object_size: Some(250 * 1024),
3011 max_move_package_size: Some(100 * 1024),
3012 max_publish_or_upgrade_per_ptb: None,
3013 max_tx_gas: Some(10_000_000_000),
3014 max_gas_price: Some(100_000),
3015 max_gas_price_rgp_factor_for_aborted_transactions: None,
3016 max_gas_computation_bucket: Some(5_000_000),
3017 max_loop_depth: Some(5),
3018 max_generic_instantiation_length: Some(32),
3019 max_function_parameters: Some(128),
3020 max_basic_blocks: Some(1024),
3021 max_value_stack_size: Some(1024),
3022 max_type_nodes: Some(256),
3023 max_push_size: Some(10000),
3024 max_struct_definitions: Some(200),
3025 max_function_definitions: Some(1000),
3026 max_fields_in_struct: Some(32),
3027 max_dependency_depth: Some(100),
3028 max_num_event_emit: Some(256),
3029 max_num_new_move_object_ids: Some(2048),
3030 max_num_new_move_object_ids_system_tx: Some(2048 * 16),
3031 max_num_deleted_move_object_ids: Some(2048),
3032 max_num_deleted_move_object_ids_system_tx: Some(2048 * 16),
3033 max_num_transferred_move_object_ids: Some(2048),
3034 max_num_transferred_move_object_ids_system_tx: Some(2048 * 16),
3035 max_event_emit_size: Some(250 * 1024),
3036 max_move_vector_len: Some(256 * 1024),
3037 max_type_to_layout_nodes: None,
3038 max_ptb_value_size: None,
3039
3040 max_back_edges_per_function: Some(10_000),
3041 max_back_edges_per_module: Some(10_000),
3042 max_verifier_meter_ticks_per_function: Some(6_000_000),
3043 max_meter_ticks_per_module: Some(6_000_000),
3044 max_meter_ticks_per_package: None,
3045
3046 object_runtime_max_num_cached_objects: Some(1000),
3047 object_runtime_max_num_cached_objects_system_tx: Some(1000 * 16),
3048 object_runtime_max_num_store_entries: Some(1000),
3049 object_runtime_max_num_store_entries_system_tx: Some(1000 * 16),
3050 base_tx_cost_fixed: Some(110_000),
3051 package_publish_cost_fixed: Some(1_000),
3052 base_tx_cost_per_byte: Some(0),
3053 package_publish_cost_per_byte: Some(80),
3054 obj_access_cost_read_per_byte: Some(15),
3055 obj_access_cost_mutate_per_byte: Some(40),
3056 obj_access_cost_delete_per_byte: Some(40),
3057 obj_access_cost_verify_per_byte: Some(200),
3058 obj_data_cost_refundable: Some(100),
3059 obj_metadata_cost_non_refundable: Some(50),
3060 gas_model_version: Some(1),
3061 storage_rebate_rate: Some(9900),
3062 storage_fund_reinvest_rate: Some(500),
3063 reward_slashing_rate: Some(5000),
3064 storage_gas_price: Some(1),
3065 accumulator_object_storage_cost: None,
3066 max_transactions_per_checkpoint: Some(10_000),
3067 max_checkpoint_size_bytes: Some(30 * 1024 * 1024),
3068
3069 buffer_stake_for_protocol_upgrade_bps: Some(0),
3072
3073 address_from_bytes_cost_base: Some(52),
3077 address_to_u256_cost_base: Some(52),
3079 address_from_u256_cost_base: Some(52),
3081
3082 config_read_setting_impl_cost_base: None,
3085 config_read_setting_impl_cost_per_byte: None,
3086
3087 dynamic_field_hash_type_and_key_cost_base: Some(100),
3090 dynamic_field_hash_type_and_key_type_cost_per_byte: Some(2),
3091 dynamic_field_hash_type_and_key_value_cost_per_byte: Some(2),
3092 dynamic_field_hash_type_and_key_type_tag_cost_per_byte: Some(2),
3093 dynamic_field_add_child_object_cost_base: Some(100),
3095 dynamic_field_add_child_object_type_cost_per_byte: Some(10),
3096 dynamic_field_add_child_object_value_cost_per_byte: Some(10),
3097 dynamic_field_add_child_object_struct_tag_cost_per_byte: Some(10),
3098 dynamic_field_borrow_child_object_cost_base: Some(100),
3100 dynamic_field_borrow_child_object_child_ref_cost_per_byte: Some(10),
3101 dynamic_field_borrow_child_object_type_cost_per_byte: Some(10),
3102 dynamic_field_remove_child_object_cost_base: Some(100),
3104 dynamic_field_remove_child_object_child_cost_per_byte: Some(2),
3105 dynamic_field_remove_child_object_type_cost_per_byte: Some(2),
3106 dynamic_field_has_child_object_cost_base: Some(100),
3108 dynamic_field_has_child_object_with_ty_cost_base: Some(100),
3110 dynamic_field_has_child_object_with_ty_type_cost_per_byte: Some(2),
3111 dynamic_field_has_child_object_with_ty_type_tag_cost_per_byte: Some(2),
3112
3113 event_emit_cost_base: Some(52),
3116 event_emit_value_size_derivation_cost_per_byte: Some(2),
3117 event_emit_tag_size_derivation_cost_per_byte: Some(5),
3118 event_emit_output_cost_per_byte: Some(10),
3119 event_emit_auth_stream_cost: None,
3120
3121 object_borrow_uid_cost_base: Some(52),
3124 object_delete_impl_cost_base: Some(52),
3126 object_record_new_uid_cost_base: Some(52),
3128
3129 transfer_transfer_internal_cost_base: Some(52),
3132 transfer_party_transfer_internal_cost_base: None,
3134 transfer_freeze_object_cost_base: Some(52),
3136 transfer_share_object_cost_base: Some(52),
3138 transfer_receive_object_cost_base: None,
3139 transfer_receive_object_type_cost_per_byte: None,
3140 transfer_receive_object_cost_per_byte: None,
3141
3142 tx_context_derive_id_cost_base: Some(52),
3145 tx_context_fresh_id_cost_base: None,
3146 tx_context_sender_cost_base: None,
3147 tx_context_epoch_cost_base: None,
3148 tx_context_epoch_timestamp_ms_cost_base: None,
3149 tx_context_sponsor_cost_base: None,
3150 tx_context_rgp_cost_base: None,
3151 tx_context_gas_price_cost_base: None,
3152 tx_context_gas_budget_cost_base: None,
3153 tx_context_ids_created_cost_base: None,
3154 tx_context_replace_cost_base: None,
3155
3156 types_is_one_time_witness_cost_base: Some(52),
3159 types_is_one_time_witness_type_tag_cost_per_byte: Some(2),
3160 types_is_one_time_witness_type_cost_per_byte: Some(2),
3161
3162 validator_validate_metadata_cost_base: Some(52),
3165 validator_validate_metadata_data_cost_per_byte: Some(2),
3166
3167 crypto_invalid_arguments_cost: Some(100),
3169 bls12381_bls12381_min_sig_verify_cost_base: Some(52),
3171 bls12381_bls12381_min_sig_verify_msg_cost_per_byte: Some(2),
3172 bls12381_bls12381_min_sig_verify_msg_cost_per_block: Some(2),
3173
3174 bls12381_bls12381_min_pk_verify_cost_base: Some(52),
3176 bls12381_bls12381_min_pk_verify_msg_cost_per_byte: Some(2),
3177 bls12381_bls12381_min_pk_verify_msg_cost_per_block: Some(2),
3178
3179 ecdsa_k1_ecrecover_keccak256_cost_base: Some(52),
3181 ecdsa_k1_ecrecover_keccak256_msg_cost_per_byte: Some(2),
3182 ecdsa_k1_ecrecover_keccak256_msg_cost_per_block: Some(2),
3183 ecdsa_k1_ecrecover_sha256_cost_base: Some(52),
3184 ecdsa_k1_ecrecover_sha256_msg_cost_per_byte: Some(2),
3185 ecdsa_k1_ecrecover_sha256_msg_cost_per_block: Some(2),
3186
3187 ecdsa_k1_decompress_pubkey_cost_base: Some(52),
3189
3190 ecdsa_k1_secp256k1_verify_keccak256_cost_base: Some(52),
3192 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_byte: Some(2),
3193 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_block: Some(2),
3194 ecdsa_k1_secp256k1_verify_sha256_cost_base: Some(52),
3195 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_byte: Some(2),
3196 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_block: Some(2),
3197
3198 ecdsa_r1_ecrecover_keccak256_cost_base: Some(52),
3200 ecdsa_r1_ecrecover_keccak256_msg_cost_per_byte: Some(2),
3201 ecdsa_r1_ecrecover_keccak256_msg_cost_per_block: Some(2),
3202 ecdsa_r1_ecrecover_sha256_cost_base: Some(52),
3203 ecdsa_r1_ecrecover_sha256_msg_cost_per_byte: Some(2),
3204 ecdsa_r1_ecrecover_sha256_msg_cost_per_block: Some(2),
3205
3206 ecdsa_r1_secp256r1_verify_keccak256_cost_base: Some(52),
3208 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_byte: Some(2),
3209 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_block: Some(2),
3210 ecdsa_r1_secp256r1_verify_sha256_cost_base: Some(52),
3211 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_byte: Some(2),
3212 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_block: Some(2),
3213
3214 ecvrf_ecvrf_verify_cost_base: Some(52),
3216 ecvrf_ecvrf_verify_alpha_string_cost_per_byte: Some(2),
3217 ecvrf_ecvrf_verify_alpha_string_cost_per_block: Some(2),
3218
3219 ed25519_ed25519_verify_cost_base: Some(52),
3221 ed25519_ed25519_verify_msg_cost_per_byte: Some(2),
3222 ed25519_ed25519_verify_msg_cost_per_block: Some(2),
3223
3224 groth16_prepare_verifying_key_bls12381_cost_base: Some(52),
3226 groth16_prepare_verifying_key_bn254_cost_base: Some(52),
3227
3228 groth16_verify_groth16_proof_internal_bls12381_cost_base: Some(52),
3230 groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input: Some(2),
3231 groth16_verify_groth16_proof_internal_bn254_cost_base: Some(52),
3232 groth16_verify_groth16_proof_internal_bn254_cost_per_public_input: Some(2),
3233 groth16_verify_groth16_proof_internal_public_input_cost_per_byte: Some(2),
3234
3235 hash_blake2b256_cost_base: Some(52),
3237 hash_blake2b256_data_cost_per_byte: Some(2),
3238 hash_blake2b256_data_cost_per_block: Some(2),
3239
3240 hash_keccak256_cost_base: Some(52),
3242 hash_keccak256_data_cost_per_byte: Some(2),
3243 hash_keccak256_data_cost_per_block: Some(2),
3244
3245 poseidon_bn254_cost_base: None,
3246 poseidon_bn254_cost_per_block: None,
3247
3248 hmac_hmac_sha3_256_cost_base: Some(52),
3250 hmac_hmac_sha3_256_input_cost_per_byte: Some(2),
3251 hmac_hmac_sha3_256_input_cost_per_block: Some(2),
3252
3253 group_ops_bls12381_decode_scalar_cost: None,
3255 group_ops_bls12381_decode_g1_cost: None,
3256 group_ops_bls12381_decode_g2_cost: None,
3257 group_ops_bls12381_decode_gt_cost: None,
3258 group_ops_bls12381_scalar_add_cost: None,
3259 group_ops_bls12381_g1_add_cost: None,
3260 group_ops_bls12381_g2_add_cost: None,
3261 group_ops_bls12381_gt_add_cost: None,
3262 group_ops_bls12381_scalar_sub_cost: None,
3263 group_ops_bls12381_g1_sub_cost: None,
3264 group_ops_bls12381_g2_sub_cost: None,
3265 group_ops_bls12381_gt_sub_cost: None,
3266 group_ops_bls12381_scalar_mul_cost: None,
3267 group_ops_bls12381_g1_mul_cost: None,
3268 group_ops_bls12381_g2_mul_cost: None,
3269 group_ops_bls12381_gt_mul_cost: None,
3270 group_ops_bls12381_scalar_div_cost: None,
3271 group_ops_bls12381_g1_div_cost: None,
3272 group_ops_bls12381_g2_div_cost: None,
3273 group_ops_bls12381_gt_div_cost: None,
3274 group_ops_bls12381_g1_hash_to_base_cost: None,
3275 group_ops_bls12381_g2_hash_to_base_cost: None,
3276 group_ops_bls12381_g1_hash_to_cost_per_byte: None,
3277 group_ops_bls12381_g2_hash_to_cost_per_byte: None,
3278 group_ops_bls12381_g1_msm_base_cost: None,
3279 group_ops_bls12381_g2_msm_base_cost: None,
3280 group_ops_bls12381_g1_msm_base_cost_per_input: None,
3281 group_ops_bls12381_g2_msm_base_cost_per_input: None,
3282 group_ops_bls12381_msm_max_len: None,
3283 group_ops_bls12381_pairing_cost: None,
3284 group_ops_bls12381_g1_to_uncompressed_g1_cost: None,
3285 group_ops_bls12381_uncompressed_g1_to_g1_cost: None,
3286 group_ops_bls12381_uncompressed_g1_sum_base_cost: None,
3287 group_ops_bls12381_uncompressed_g1_sum_cost_per_term: None,
3288 group_ops_bls12381_uncompressed_g1_sum_max_terms: None,
3289
3290 group_ops_ristretto_decode_scalar_cost: None,
3291 group_ops_ristretto_decode_point_cost: None,
3292 group_ops_ristretto_scalar_add_cost: None,
3293 group_ops_ristretto_point_add_cost: None,
3294 group_ops_ristretto_scalar_sub_cost: None,
3295 group_ops_ristretto_point_sub_cost: None,
3296 group_ops_ristretto_scalar_mul_cost: None,
3297 group_ops_ristretto_point_mul_cost: None,
3298 group_ops_ristretto_scalar_div_cost: None,
3299 group_ops_ristretto_point_div_cost: None,
3300
3301 verify_bulletproofs_ristretto255_base_cost: None,
3302 verify_bulletproofs_ristretto255_cost_per_bit_and_commitment: None,
3303
3304 check_zklogin_id_cost_base: None,
3306 check_zklogin_issuer_cost_base: None,
3308
3309 vdf_verify_vdf_cost: None,
3310 vdf_hash_to_input_cost: None,
3311
3312 nitro_attestation_parse_base_cost: None,
3314 nitro_attestation_parse_cost_per_byte: None,
3315 nitro_attestation_verify_base_cost: None,
3316 nitro_attestation_verify_cost_per_cert: None,
3317
3318 bcs_per_byte_serialized_cost: None,
3319 bcs_legacy_min_output_size_cost: None,
3320 bcs_failure_cost: None,
3321 hash_sha2_256_base_cost: None,
3322 hash_sha2_256_per_byte_cost: None,
3323 hash_sha2_256_legacy_min_input_len_cost: None,
3324 hash_sha3_256_base_cost: None,
3325 hash_sha3_256_per_byte_cost: None,
3326 hash_sha3_256_legacy_min_input_len_cost: None,
3327 type_name_get_base_cost: None,
3328 type_name_get_per_byte_cost: None,
3329 type_name_id_base_cost: None,
3330 string_check_utf8_base_cost: None,
3331 string_check_utf8_per_byte_cost: None,
3332 string_is_char_boundary_base_cost: None,
3333 string_sub_string_base_cost: None,
3334 string_sub_string_per_byte_cost: None,
3335 string_index_of_base_cost: None,
3336 string_index_of_per_byte_pattern_cost: None,
3337 string_index_of_per_byte_searched_cost: None,
3338 vector_empty_base_cost: None,
3339 vector_length_base_cost: None,
3340 vector_push_back_base_cost: None,
3341 vector_push_back_legacy_per_abstract_memory_unit_cost: None,
3342 vector_borrow_base_cost: None,
3343 vector_pop_back_base_cost: None,
3344 vector_destroy_empty_base_cost: None,
3345 vector_swap_base_cost: None,
3346 debug_print_base_cost: None,
3347 debug_print_stack_trace_base_cost: None,
3348
3349 max_size_written_objects: None,
3350 max_size_written_objects_system_tx: None,
3351
3352 max_move_identifier_len: None,
3359 max_move_value_depth: None,
3360 max_move_enum_variants: None,
3361
3362 gas_rounding_step: None,
3363
3364 execution_version: None,
3365
3366 max_event_emit_size_total: None,
3367
3368 consensus_bad_nodes_stake_threshold: None,
3369
3370 max_jwk_votes_per_validator_per_epoch: None,
3371
3372 max_age_of_jwk_in_epochs: None,
3373
3374 random_beacon_reduction_allowed_delta: None,
3375
3376 random_beacon_reduction_lower_bound: None,
3377
3378 random_beacon_dkg_timeout_round: None,
3379
3380 random_beacon_min_round_interval_ms: None,
3381
3382 random_beacon_dkg_version: None,
3383
3384 consensus_max_transaction_size_bytes: None,
3385
3386 consensus_max_transactions_in_block_bytes: None,
3387
3388 consensus_max_num_transactions_in_block: None,
3389
3390 consensus_voting_rounds: None,
3391
3392 max_accumulated_txn_cost_per_object_in_narwhal_commit: None,
3393
3394 max_deferral_rounds_for_congestion_control: None,
3395
3396 max_txn_cost_overage_per_object_in_commit: None,
3397
3398 allowed_txn_cost_overage_burst_per_object_in_commit: None,
3399
3400 min_checkpoint_interval_ms: None,
3401
3402 checkpoint_summary_version_specific_data: None,
3403
3404 max_soft_bundle_size: None,
3405
3406 bridge_should_try_to_finalize_committee: None,
3407
3408 max_accumulated_txn_cost_per_object_in_mysticeti_commit: None,
3409
3410 max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit: None,
3411
3412 consensus_gc_depth: None,
3413
3414 gas_budget_based_txn_cost_cap_factor: None,
3415
3416 gas_budget_based_txn_cost_absolute_cap_commit_count: None,
3417
3418 sip_45_consensus_amplification_threshold: None,
3419
3420 use_object_per_epoch_marker_table_v2: None,
3421
3422 consensus_commit_rate_estimation_window_size: None,
3423
3424 aliased_addresses: vec![],
3425
3426 translation_per_command_base_charge: None,
3427 translation_per_input_base_charge: None,
3428 translation_pure_input_per_byte_charge: None,
3429 translation_per_type_node_charge: None,
3430 translation_per_reference_node_charge: None,
3431 translation_per_linkage_entry_charge: None,
3432
3433 max_updates_per_settlement_txn: None,
3434
3435 gasless_max_computation_units: None,
3436 gasless_allowed_token_types: None,
3437 gasless_max_unused_inputs: None,
3438 gasless_max_pure_input_bytes: None,
3439 gasless_max_tps: None,
3440 include_special_package_amendments: None,
3441 gasless_max_tx_size_bytes: None,
3442 };
3445 for cur in 2..=version.0 {
3446 match cur {
3447 1 => unreachable!(),
3448 2 => {
3449 cfg.feature_flags.advance_epoch_start_time_in_safe_mode = true;
3450 }
3451 3 => {
3452 cfg.gas_model_version = Some(2);
3454 cfg.max_tx_gas = Some(50_000_000_000);
3456 cfg.base_tx_cost_fixed = Some(2_000);
3458 cfg.storage_gas_price = Some(76);
3460 cfg.feature_flags.loaded_child_objects_fixed = true;
3461 cfg.max_size_written_objects = Some(5 * 1000 * 1000);
3464 cfg.max_size_written_objects_system_tx = Some(50 * 1000 * 1000);
3467 cfg.feature_flags.package_upgrades = true;
3468 }
3469 4 => {
3474 cfg.reward_slashing_rate = Some(10000);
3476 cfg.gas_model_version = Some(3);
3478 }
3479 5 => {
3480 cfg.feature_flags.missing_type_is_compatibility_error = true;
3481 cfg.gas_model_version = Some(4);
3482 cfg.feature_flags.scoring_decision_with_validity_cutoff = true;
3483 }
3487 6 => {
3488 cfg.gas_model_version = Some(5);
3489 cfg.buffer_stake_for_protocol_upgrade_bps = Some(5000);
3490 cfg.feature_flags.consensus_order_end_of_epoch_last = true;
3491 }
3492 7 => {
3493 cfg.feature_flags.disallow_adding_abilities_on_upgrade = true;
3494 cfg.feature_flags
3495 .disable_invariant_violation_check_in_swap_loc = true;
3496 cfg.feature_flags.ban_entry_init = true;
3497 cfg.feature_flags.package_digest_hash_module = true;
3498 }
3499 8 => {
3500 cfg.feature_flags
3501 .disallow_change_struct_type_params_on_upgrade = true;
3502 }
3503 9 => {
3504 cfg.max_move_identifier_len = Some(128);
3506 cfg.feature_flags.no_extraneous_module_bytes = true;
3507 cfg.feature_flags
3508 .advance_to_highest_supported_protocol_version = true;
3509 }
3510 10 => {
3511 cfg.max_verifier_meter_ticks_per_function = Some(16_000_000);
3512 cfg.max_meter_ticks_per_module = Some(16_000_000);
3513 }
3514 11 => {
3515 cfg.max_move_value_depth = Some(128);
3516 }
3517 12 => {
3518 cfg.feature_flags.narwhal_versioned_metadata = true;
3519 if chain != Chain::Mainnet {
3520 cfg.feature_flags.commit_root_state_digest = true;
3521 }
3522
3523 if chain != Chain::Mainnet && chain != Chain::Testnet {
3524 cfg.feature_flags.zklogin_auth = true;
3525 }
3526 }
3527 13 => {}
3528 14 => {
3529 cfg.gas_rounding_step = Some(1_000);
3530 cfg.gas_model_version = Some(6);
3531 }
3532 15 => {
3533 cfg.feature_flags.consensus_transaction_ordering =
3534 ConsensusTransactionOrdering::ByGasPrice;
3535 }
3536 16 => {
3537 cfg.feature_flags.simplified_unwrap_then_delete = true;
3538 }
3539 17 => {
3540 cfg.feature_flags.upgraded_multisig_supported = true;
3541 }
3542 18 => {
3543 cfg.execution_version = Some(1);
3544 cfg.feature_flags.txn_base_cost_as_multiplier = true;
3553 cfg.base_tx_cost_fixed = Some(1_000);
3555 }
3556 19 => {
3557 cfg.max_num_event_emit = Some(1024);
3558 cfg.max_event_emit_size_total = Some(
3561 256 * 250 * 1024, );
3563 }
3564 20 => {
3565 cfg.feature_flags.commit_root_state_digest = true;
3566
3567 if chain != Chain::Mainnet {
3568 cfg.feature_flags.narwhal_new_leader_election_schedule = true;
3569 cfg.consensus_bad_nodes_stake_threshold = Some(20);
3570 }
3571 }
3572
3573 21 => {
3574 if chain != Chain::Mainnet {
3575 cfg.feature_flags.zklogin_supported_providers = BTreeSet::from([
3576 "Google".to_string(),
3577 "Facebook".to_string(),
3578 "Twitch".to_string(),
3579 ]);
3580 }
3581 }
3582 22 => {
3583 cfg.feature_flags.loaded_child_object_format = true;
3584 }
3585 23 => {
3586 cfg.feature_flags.loaded_child_object_format_type = true;
3587 cfg.feature_flags.narwhal_new_leader_election_schedule = true;
3588 cfg.consensus_bad_nodes_stake_threshold = Some(20);
3594 }
3595 24 => {
3596 cfg.feature_flags.simple_conservation_checks = true;
3597 cfg.max_publish_or_upgrade_per_ptb = Some(5);
3598
3599 cfg.feature_flags.end_of_epoch_transaction_supported = true;
3600
3601 if chain != Chain::Mainnet {
3602 cfg.feature_flags.enable_jwk_consensus_updates = true;
3603 cfg.max_jwk_votes_per_validator_per_epoch = Some(240);
3605 cfg.max_age_of_jwk_in_epochs = Some(1);
3606 }
3607 }
3608 25 => {
3609 cfg.feature_flags.zklogin_supported_providers = BTreeSet::from([
3611 "Google".to_string(),
3612 "Facebook".to_string(),
3613 "Twitch".to_string(),
3614 ]);
3615 cfg.feature_flags.zklogin_auth = true;
3616
3617 cfg.feature_flags.enable_jwk_consensus_updates = true;
3619 cfg.max_jwk_votes_per_validator_per_epoch = Some(240);
3620 cfg.max_age_of_jwk_in_epochs = Some(1);
3621 }
3622 26 => {
3623 cfg.gas_model_version = Some(7);
3624 if chain != Chain::Mainnet && chain != Chain::Testnet {
3626 cfg.transfer_receive_object_cost_base = Some(52);
3627 cfg.feature_flags.receive_objects = true;
3628 }
3629 }
3630 27 => {
3631 cfg.gas_model_version = Some(8);
3632 }
3633 28 => {
3634 cfg.check_zklogin_id_cost_base = Some(200);
3636 cfg.check_zklogin_issuer_cost_base = Some(200);
3638
3639 if chain != Chain::Mainnet && chain != Chain::Testnet {
3641 cfg.feature_flags.enable_effects_v2 = true;
3642 }
3643 }
3644 29 => {
3645 cfg.feature_flags.verify_legacy_zklogin_address = true;
3646 }
3647 30 => {
3648 if chain != Chain::Mainnet {
3650 cfg.feature_flags.narwhal_certificate_v2 = true;
3651 }
3652
3653 cfg.random_beacon_reduction_allowed_delta = Some(800);
3654 if chain != Chain::Mainnet {
3656 cfg.feature_flags.enable_effects_v2 = true;
3657 }
3658
3659 cfg.feature_flags.zklogin_supported_providers = BTreeSet::default();
3663
3664 cfg.feature_flags.recompute_has_public_transfer_in_execution = true;
3665 }
3666 31 => {
3667 cfg.execution_version = Some(2);
3668 if chain != Chain::Mainnet && chain != Chain::Testnet {
3670 cfg.feature_flags.shared_object_deletion = true;
3671 }
3672 }
3673 32 => {
3674 if chain != Chain::Mainnet {
3676 cfg.feature_flags.accept_zklogin_in_multisig = true;
3677 }
3678 if chain != Chain::Mainnet {
3680 cfg.transfer_receive_object_cost_base = Some(52);
3681 cfg.feature_flags.receive_objects = true;
3682 }
3683 if chain != Chain::Mainnet && chain != Chain::Testnet {
3685 cfg.feature_flags.random_beacon = true;
3686 cfg.random_beacon_reduction_lower_bound = Some(1600);
3687 cfg.random_beacon_dkg_timeout_round = Some(3000);
3688 cfg.random_beacon_min_round_interval_ms = Some(150);
3689 }
3690 if chain != Chain::Testnet && chain != Chain::Mainnet {
3692 cfg.feature_flags.include_consensus_digest_in_prologue = true;
3693 }
3694
3695 cfg.feature_flags.narwhal_certificate_v2 = true;
3697 }
3698 33 => {
3699 cfg.feature_flags.hardened_otw_check = true;
3700 cfg.feature_flags.allow_receiving_object_id = true;
3701
3702 cfg.transfer_receive_object_cost_base = Some(52);
3704 cfg.feature_flags.receive_objects = true;
3705
3706 if chain != Chain::Mainnet {
3708 cfg.feature_flags.shared_object_deletion = true;
3709 }
3710
3711 cfg.feature_flags.enable_effects_v2 = true;
3712 }
3713 34 => {}
3714 35 => {
3715 if chain != Chain::Mainnet && chain != Chain::Testnet {
3717 cfg.feature_flags.enable_poseidon = true;
3718 cfg.poseidon_bn254_cost_base = Some(260);
3719 cfg.poseidon_bn254_cost_per_block = Some(10);
3720 }
3721
3722 cfg.feature_flags.enable_coin_deny_list = true;
3723 }
3724 36 => {
3725 if chain != Chain::Mainnet && chain != Chain::Testnet {
3727 cfg.feature_flags.enable_group_ops_native_functions = true;
3728 cfg.feature_flags.enable_group_ops_native_function_msm = true;
3729 cfg.group_ops_bls12381_decode_scalar_cost = Some(52);
3731 cfg.group_ops_bls12381_decode_g1_cost = Some(52);
3732 cfg.group_ops_bls12381_decode_g2_cost = Some(52);
3733 cfg.group_ops_bls12381_decode_gt_cost = Some(52);
3734 cfg.group_ops_bls12381_scalar_add_cost = Some(52);
3735 cfg.group_ops_bls12381_g1_add_cost = Some(52);
3736 cfg.group_ops_bls12381_g2_add_cost = Some(52);
3737 cfg.group_ops_bls12381_gt_add_cost = Some(52);
3738 cfg.group_ops_bls12381_scalar_sub_cost = Some(52);
3739 cfg.group_ops_bls12381_g1_sub_cost = Some(52);
3740 cfg.group_ops_bls12381_g2_sub_cost = Some(52);
3741 cfg.group_ops_bls12381_gt_sub_cost = Some(52);
3742 cfg.group_ops_bls12381_scalar_mul_cost = Some(52);
3743 cfg.group_ops_bls12381_g1_mul_cost = Some(52);
3744 cfg.group_ops_bls12381_g2_mul_cost = Some(52);
3745 cfg.group_ops_bls12381_gt_mul_cost = Some(52);
3746 cfg.group_ops_bls12381_scalar_div_cost = Some(52);
3747 cfg.group_ops_bls12381_g1_div_cost = Some(52);
3748 cfg.group_ops_bls12381_g2_div_cost = Some(52);
3749 cfg.group_ops_bls12381_gt_div_cost = Some(52);
3750 cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(52);
3751 cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(52);
3752 cfg.group_ops_bls12381_g1_hash_to_cost_per_byte = Some(2);
3753 cfg.group_ops_bls12381_g2_hash_to_cost_per_byte = Some(2);
3754 cfg.group_ops_bls12381_g1_msm_base_cost = Some(52);
3755 cfg.group_ops_bls12381_g2_msm_base_cost = Some(52);
3756 cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(52);
3757 cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(52);
3758 cfg.group_ops_bls12381_msm_max_len = Some(32);
3759 cfg.group_ops_bls12381_pairing_cost = Some(52);
3760 }
3761 cfg.feature_flags.shared_object_deletion = true;
3763
3764 cfg.consensus_max_transaction_size_bytes = Some(256 * 1024); cfg.consensus_max_transactions_in_block_bytes = Some(6 * 1_024 * 1024);
3766 }
3768 37 => {
3769 cfg.feature_flags.reject_mutable_random_on_entry_functions = true;
3770
3771 if chain != Chain::Mainnet {
3773 cfg.feature_flags.include_consensus_digest_in_prologue = true;
3774 }
3775 }
3776 38 => {
3777 cfg.binary_module_handles = Some(100);
3778 cfg.binary_struct_handles = Some(300);
3779 cfg.binary_function_handles = Some(1500);
3780 cfg.binary_function_instantiations = Some(750);
3781 cfg.binary_signatures = Some(1000);
3782 cfg.binary_constant_pool = Some(4000);
3786 cfg.binary_identifiers = Some(10000);
3787 cfg.binary_address_identifiers = Some(100);
3788 cfg.binary_struct_defs = Some(200);
3789 cfg.binary_struct_def_instantiations = Some(100);
3790 cfg.binary_function_defs = Some(1000);
3791 cfg.binary_field_handles = Some(500);
3792 cfg.binary_field_instantiations = Some(250);
3793 cfg.binary_friend_decls = Some(100);
3794 cfg.max_package_dependencies = Some(32);
3796 cfg.max_modules_in_publish = Some(64);
3797 cfg.execution_version = Some(3);
3799 }
3800 39 => {
3801 }
3803 40 => {}
3804 41 => {
3805 cfg.feature_flags.enable_group_ops_native_functions = true;
3807 cfg.group_ops_bls12381_decode_scalar_cost = Some(52);
3809 cfg.group_ops_bls12381_decode_g1_cost = Some(52);
3810 cfg.group_ops_bls12381_decode_g2_cost = Some(52);
3811 cfg.group_ops_bls12381_decode_gt_cost = Some(52);
3812 cfg.group_ops_bls12381_scalar_add_cost = Some(52);
3813 cfg.group_ops_bls12381_g1_add_cost = Some(52);
3814 cfg.group_ops_bls12381_g2_add_cost = Some(52);
3815 cfg.group_ops_bls12381_gt_add_cost = Some(52);
3816 cfg.group_ops_bls12381_scalar_sub_cost = Some(52);
3817 cfg.group_ops_bls12381_g1_sub_cost = Some(52);
3818 cfg.group_ops_bls12381_g2_sub_cost = Some(52);
3819 cfg.group_ops_bls12381_gt_sub_cost = Some(52);
3820 cfg.group_ops_bls12381_scalar_mul_cost = Some(52);
3821 cfg.group_ops_bls12381_g1_mul_cost = Some(52);
3822 cfg.group_ops_bls12381_g2_mul_cost = Some(52);
3823 cfg.group_ops_bls12381_gt_mul_cost = Some(52);
3824 cfg.group_ops_bls12381_scalar_div_cost = Some(52);
3825 cfg.group_ops_bls12381_g1_div_cost = Some(52);
3826 cfg.group_ops_bls12381_g2_div_cost = Some(52);
3827 cfg.group_ops_bls12381_gt_div_cost = Some(52);
3828 cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(52);
3829 cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(52);
3830 cfg.group_ops_bls12381_g1_hash_to_cost_per_byte = Some(2);
3831 cfg.group_ops_bls12381_g2_hash_to_cost_per_byte = Some(2);
3832 cfg.group_ops_bls12381_g1_msm_base_cost = Some(52);
3833 cfg.group_ops_bls12381_g2_msm_base_cost = Some(52);
3834 cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(52);
3835 cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(52);
3836 cfg.group_ops_bls12381_msm_max_len = Some(32);
3837 cfg.group_ops_bls12381_pairing_cost = Some(52);
3838 }
3839 42 => {}
3840 43 => {
3841 cfg.feature_flags.zklogin_max_epoch_upper_bound_delta = Some(30);
3842 cfg.max_meter_ticks_per_package = Some(16_000_000);
3843 }
3844 44 => {
3845 cfg.feature_flags.include_consensus_digest_in_prologue = true;
3847 if chain != Chain::Mainnet {
3849 cfg.feature_flags.consensus_choice = ConsensusChoice::SwapEachEpoch;
3850 }
3851 }
3852 45 => {
3853 if chain != Chain::Testnet && chain != Chain::Mainnet {
3855 cfg.feature_flags.consensus_network = ConsensusNetwork::Tonic;
3856 }
3857
3858 if chain != Chain::Mainnet {
3859 cfg.feature_flags.mysticeti_leader_scoring_and_schedule = true;
3861 }
3862 cfg.min_move_binary_format_version = Some(6);
3863 cfg.feature_flags.accept_zklogin_in_multisig = true;
3864
3865 if chain != Chain::Mainnet && chain != Chain::Testnet {
3869 cfg.feature_flags.bridge = true;
3870 }
3871 }
3872 46 => {
3873 if chain != Chain::Mainnet {
3875 cfg.feature_flags.bridge = true;
3876 }
3877
3878 cfg.feature_flags.reshare_at_same_initial_version = true;
3880 }
3881 47 => {}
3882 48 => {
3883 cfg.feature_flags.consensus_network = ConsensusNetwork::Tonic;
3885
3886 cfg.feature_flags.resolve_abort_locations_to_package_id = true;
3888
3889 if chain != Chain::Mainnet {
3891 cfg.feature_flags.random_beacon = true;
3892 cfg.random_beacon_reduction_lower_bound = Some(1600);
3893 cfg.random_beacon_dkg_timeout_round = Some(3000);
3894 cfg.random_beacon_min_round_interval_ms = Some(200);
3895 }
3896
3897 cfg.feature_flags.mysticeti_use_committed_subdag_digest = true;
3899 }
3900 49 => {
3901 if chain != Chain::Testnet && chain != Chain::Mainnet {
3902 cfg.move_binary_format_version = Some(7);
3903 }
3904
3905 if chain != Chain::Mainnet && chain != Chain::Testnet {
3907 cfg.feature_flags.enable_vdf = true;
3908 cfg.vdf_verify_vdf_cost = Some(1500);
3911 cfg.vdf_hash_to_input_cost = Some(100);
3912 }
3913
3914 if chain != Chain::Testnet && chain != Chain::Mainnet {
3916 cfg.feature_flags
3917 .record_consensus_determined_version_assignments_in_prologue = true;
3918 }
3919
3920 if chain != Chain::Mainnet {
3922 cfg.feature_flags.consensus_choice = ConsensusChoice::Mysticeti;
3923 }
3924
3925 cfg.feature_flags.fresh_vm_on_framework_upgrade = true;
3927 }
3928 50 => {
3929 if chain != Chain::Mainnet {
3931 cfg.checkpoint_summary_version_specific_data = Some(1);
3932 cfg.min_checkpoint_interval_ms = Some(200);
3933 }
3934
3935 if chain != Chain::Testnet && chain != Chain::Mainnet {
3937 cfg.feature_flags
3938 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = true;
3939 }
3940
3941 cfg.feature_flags.mysticeti_num_leaders_per_round = Some(1);
3942
3943 cfg.max_deferral_rounds_for_congestion_control = Some(10);
3945 }
3946 51 => {
3947 cfg.random_beacon_dkg_version = Some(1);
3948
3949 if chain != Chain::Testnet && chain != Chain::Mainnet {
3950 cfg.feature_flags.enable_coin_deny_list_v2 = true;
3951 }
3952 }
3953 52 => {
3954 if chain != Chain::Mainnet {
3955 cfg.feature_flags.soft_bundle = true;
3956 cfg.max_soft_bundle_size = Some(5);
3957 }
3958
3959 cfg.config_read_setting_impl_cost_base = Some(100);
3960 cfg.config_read_setting_impl_cost_per_byte = Some(40);
3961
3962 if chain != Chain::Testnet && chain != Chain::Mainnet {
3964 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(100);
3965 cfg.feature_flags.per_object_congestion_control_mode =
3966 PerObjectCongestionControlMode::TotalTxCount;
3967 }
3968
3969 cfg.feature_flags.consensus_choice = ConsensusChoice::Mysticeti;
3971
3972 cfg.feature_flags.mysticeti_leader_scoring_and_schedule = true;
3974
3975 cfg.checkpoint_summary_version_specific_data = Some(1);
3977 cfg.min_checkpoint_interval_ms = Some(200);
3978
3979 if chain != Chain::Mainnet {
3981 cfg.feature_flags
3982 .record_consensus_determined_version_assignments_in_prologue = true;
3983 cfg.feature_flags
3984 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = true;
3985 }
3986 if chain != Chain::Mainnet {
3988 cfg.move_binary_format_version = Some(7);
3989 }
3990
3991 if chain != Chain::Testnet && chain != Chain::Mainnet {
3992 cfg.feature_flags.passkey_auth = true;
3993 }
3994 cfg.feature_flags.enable_coin_deny_list_v2 = true;
3995 }
3996 53 => {
3997 cfg.bridge_should_try_to_finalize_committee = Some(chain != Chain::Mainnet);
3999
4000 cfg.feature_flags
4002 .record_consensus_determined_version_assignments_in_prologue = true;
4003 cfg.feature_flags
4004 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = true;
4005
4006 if chain == Chain::Unknown {
4007 cfg.feature_flags.authority_capabilities_v2 = true;
4008 }
4009
4010 if chain != Chain::Mainnet {
4012 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(100);
4013 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(10);
4014 cfg.feature_flags.per_object_congestion_control_mode =
4015 PerObjectCongestionControlMode::TotalTxCount;
4016 }
4017
4018 cfg.bcs_per_byte_serialized_cost = Some(2);
4020 cfg.bcs_legacy_min_output_size_cost = Some(1);
4021 cfg.bcs_failure_cost = Some(52);
4022 cfg.debug_print_base_cost = Some(52);
4023 cfg.debug_print_stack_trace_base_cost = Some(52);
4024 cfg.hash_sha2_256_base_cost = Some(52);
4025 cfg.hash_sha2_256_per_byte_cost = Some(2);
4026 cfg.hash_sha2_256_legacy_min_input_len_cost = Some(1);
4027 cfg.hash_sha3_256_base_cost = Some(52);
4028 cfg.hash_sha3_256_per_byte_cost = Some(2);
4029 cfg.hash_sha3_256_legacy_min_input_len_cost = Some(1);
4030 cfg.type_name_get_base_cost = Some(52);
4031 cfg.type_name_get_per_byte_cost = Some(2);
4032 cfg.string_check_utf8_base_cost = Some(52);
4033 cfg.string_check_utf8_per_byte_cost = Some(2);
4034 cfg.string_is_char_boundary_base_cost = Some(52);
4035 cfg.string_sub_string_base_cost = Some(52);
4036 cfg.string_sub_string_per_byte_cost = Some(2);
4037 cfg.string_index_of_base_cost = Some(52);
4038 cfg.string_index_of_per_byte_pattern_cost = Some(2);
4039 cfg.string_index_of_per_byte_searched_cost = Some(2);
4040 cfg.vector_empty_base_cost = Some(52);
4041 cfg.vector_length_base_cost = Some(52);
4042 cfg.vector_push_back_base_cost = Some(52);
4043 cfg.vector_push_back_legacy_per_abstract_memory_unit_cost = Some(2);
4044 cfg.vector_borrow_base_cost = Some(52);
4045 cfg.vector_pop_back_base_cost = Some(52);
4046 cfg.vector_destroy_empty_base_cost = Some(52);
4047 cfg.vector_swap_base_cost = Some(52);
4048 }
4049 54 => {
4050 cfg.feature_flags.random_beacon = true;
4052 cfg.random_beacon_reduction_lower_bound = Some(1000);
4053 cfg.random_beacon_dkg_timeout_round = Some(3000);
4054 cfg.random_beacon_min_round_interval_ms = Some(500);
4055
4056 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(100);
4058 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(10);
4059 cfg.feature_flags.per_object_congestion_control_mode =
4060 PerObjectCongestionControlMode::TotalTxCount;
4061
4062 cfg.feature_flags.soft_bundle = true;
4064 cfg.max_soft_bundle_size = Some(5);
4065 }
4066 55 => {
4067 cfg.move_binary_format_version = Some(7);
4069
4070 cfg.consensus_max_transactions_in_block_bytes = Some(512 * 1024);
4072 cfg.consensus_max_num_transactions_in_block = Some(512);
4075
4076 cfg.feature_flags.rethrow_serialization_type_layout_errors = true;
4077 }
4078 56 => {
4079 if chain == Chain::Mainnet {
4080 cfg.feature_flags.bridge = true;
4081 }
4082 }
4083 57 => {
4084 cfg.random_beacon_reduction_lower_bound = Some(800);
4086 }
4087 58 => {
4088 if chain == Chain::Mainnet {
4089 cfg.bridge_should_try_to_finalize_committee = Some(true);
4090 }
4091
4092 if chain != Chain::Mainnet && chain != Chain::Testnet {
4093 cfg.feature_flags
4095 .consensus_distributed_vote_scoring_strategy = true;
4096 }
4097 }
4098 59 => {
4099 cfg.feature_flags.consensus_round_prober = true;
4101 }
4102 60 => {
4103 cfg.max_type_to_layout_nodes = Some(512);
4104 cfg.feature_flags.validate_identifier_inputs = true;
4105 }
4106 61 => {
4107 if chain != Chain::Mainnet {
4108 cfg.feature_flags
4110 .consensus_distributed_vote_scoring_strategy = true;
4111 }
4112 cfg.random_beacon_reduction_lower_bound = Some(700);
4114
4115 if chain != Chain::Mainnet && chain != Chain::Testnet {
4116 cfg.feature_flags.mysticeti_fastpath = true;
4118 }
4119 }
4120 62 => {
4121 cfg.feature_flags.relocate_event_module = true;
4122 }
4123 63 => {
4124 cfg.feature_flags.per_object_congestion_control_mode =
4125 PerObjectCongestionControlMode::TotalGasBudgetWithCap;
4126 cfg.gas_budget_based_txn_cost_cap_factor = Some(400_000);
4127 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(18_500_000);
4128 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(240_000_000);
4129 }
4130 64 => {
4131 cfg.feature_flags.per_object_congestion_control_mode =
4132 PerObjectCongestionControlMode::TotalTxCount;
4133 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(40);
4134 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(3);
4135 }
4136 65 => {
4137 cfg.feature_flags
4139 .consensus_distributed_vote_scoring_strategy = true;
4140 }
4141 66 => {
4142 if chain == Chain::Mainnet {
4143 cfg.feature_flags
4145 .consensus_distributed_vote_scoring_strategy = false;
4146 }
4147 }
4148 67 => {
4149 cfg.feature_flags
4151 .consensus_distributed_vote_scoring_strategy = true;
4152 }
4153 68 => {
4154 cfg.group_ops_bls12381_g1_to_uncompressed_g1_cost = Some(26);
4155 cfg.group_ops_bls12381_uncompressed_g1_to_g1_cost = Some(52);
4156 cfg.group_ops_bls12381_uncompressed_g1_sum_base_cost = Some(26);
4157 cfg.group_ops_bls12381_uncompressed_g1_sum_cost_per_term = Some(13);
4158 cfg.group_ops_bls12381_uncompressed_g1_sum_max_terms = Some(2000);
4159
4160 if chain != Chain::Mainnet && chain != Chain::Testnet {
4161 cfg.feature_flags.uncompressed_g1_group_elements = true;
4162 }
4163
4164 cfg.feature_flags.per_object_congestion_control_mode =
4165 PerObjectCongestionControlMode::TotalGasBudgetWithCap;
4166 cfg.gas_budget_based_txn_cost_cap_factor = Some(400_000);
4167 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(18_500_000);
4168 cfg.max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit =
4169 Some(3_700_000); cfg.max_txn_cost_overage_per_object_in_commit = Some(u64::MAX);
4171 cfg.gas_budget_based_txn_cost_absolute_cap_commit_count = Some(50);
4172
4173 cfg.random_beacon_reduction_lower_bound = Some(500);
4175
4176 cfg.feature_flags.disallow_new_modules_in_deps_only_packages = true;
4177 }
4178 69 => {
4179 cfg.consensus_voting_rounds = Some(40);
4181
4182 if chain != Chain::Mainnet && chain != Chain::Testnet {
4183 cfg.feature_flags.consensus_smart_ancestor_selection = true;
4185 }
4186
4187 if chain != Chain::Mainnet {
4188 cfg.feature_flags.uncompressed_g1_group_elements = true;
4189 }
4190 }
4191 70 => {
4192 if chain != Chain::Mainnet {
4193 cfg.feature_flags.consensus_smart_ancestor_selection = true;
4195 cfg.feature_flags
4197 .consensus_round_prober_probe_accepted_rounds = true;
4198 }
4199
4200 cfg.poseidon_bn254_cost_per_block = Some(388);
4201
4202 cfg.gas_model_version = Some(9);
4203 cfg.feature_flags.native_charging_v2 = true;
4204 cfg.bls12381_bls12381_min_sig_verify_cost_base = Some(44064);
4205 cfg.bls12381_bls12381_min_pk_verify_cost_base = Some(49282);
4206 cfg.ecdsa_k1_secp256k1_verify_keccak256_cost_base = Some(1470);
4207 cfg.ecdsa_k1_secp256k1_verify_sha256_cost_base = Some(1470);
4208 cfg.ecdsa_r1_secp256r1_verify_sha256_cost_base = Some(4225);
4209 cfg.ecdsa_r1_secp256r1_verify_keccak256_cost_base = Some(4225);
4210 cfg.ecvrf_ecvrf_verify_cost_base = Some(4848);
4211 cfg.ed25519_ed25519_verify_cost_base = Some(1802);
4212
4213 cfg.ecdsa_r1_ecrecover_keccak256_cost_base = Some(1173);
4215 cfg.ecdsa_r1_ecrecover_sha256_cost_base = Some(1173);
4216 cfg.ecdsa_k1_ecrecover_keccak256_cost_base = Some(500);
4217 cfg.ecdsa_k1_ecrecover_sha256_cost_base = Some(500);
4218
4219 cfg.groth16_prepare_verifying_key_bls12381_cost_base = Some(53838);
4220 cfg.groth16_prepare_verifying_key_bn254_cost_base = Some(82010);
4221 cfg.groth16_verify_groth16_proof_internal_bls12381_cost_base = Some(72090);
4222 cfg.groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input =
4223 Some(8213);
4224 cfg.groth16_verify_groth16_proof_internal_bn254_cost_base = Some(115502);
4225 cfg.groth16_verify_groth16_proof_internal_bn254_cost_per_public_input =
4226 Some(9484);
4227
4228 cfg.hash_keccak256_cost_base = Some(10);
4229 cfg.hash_blake2b256_cost_base = Some(10);
4230
4231 cfg.group_ops_bls12381_decode_scalar_cost = Some(7);
4233 cfg.group_ops_bls12381_decode_g1_cost = Some(2848);
4234 cfg.group_ops_bls12381_decode_g2_cost = Some(3770);
4235 cfg.group_ops_bls12381_decode_gt_cost = Some(3068);
4236
4237 cfg.group_ops_bls12381_scalar_add_cost = Some(10);
4238 cfg.group_ops_bls12381_g1_add_cost = Some(1556);
4239 cfg.group_ops_bls12381_g2_add_cost = Some(3048);
4240 cfg.group_ops_bls12381_gt_add_cost = Some(188);
4241
4242 cfg.group_ops_bls12381_scalar_sub_cost = Some(10);
4243 cfg.group_ops_bls12381_g1_sub_cost = Some(1550);
4244 cfg.group_ops_bls12381_g2_sub_cost = Some(3019);
4245 cfg.group_ops_bls12381_gt_sub_cost = Some(497);
4246
4247 cfg.group_ops_bls12381_scalar_mul_cost = Some(11);
4248 cfg.group_ops_bls12381_g1_mul_cost = Some(4842);
4249 cfg.group_ops_bls12381_g2_mul_cost = Some(9108);
4250 cfg.group_ops_bls12381_gt_mul_cost = Some(27490);
4251
4252 cfg.group_ops_bls12381_scalar_div_cost = Some(91);
4253 cfg.group_ops_bls12381_g1_div_cost = Some(5091);
4254 cfg.group_ops_bls12381_g2_div_cost = Some(9206);
4255 cfg.group_ops_bls12381_gt_div_cost = Some(27804);
4256
4257 cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(2962);
4258 cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(8688);
4259
4260 cfg.group_ops_bls12381_g1_msm_base_cost = Some(62648);
4261 cfg.group_ops_bls12381_g2_msm_base_cost = Some(131192);
4262 cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(1333);
4263 cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(3216);
4264
4265 cfg.group_ops_bls12381_uncompressed_g1_to_g1_cost = Some(677);
4266 cfg.group_ops_bls12381_g1_to_uncompressed_g1_cost = Some(2099);
4267 cfg.group_ops_bls12381_uncompressed_g1_sum_base_cost = Some(77);
4268 cfg.group_ops_bls12381_uncompressed_g1_sum_cost_per_term = Some(26);
4269
4270 cfg.group_ops_bls12381_pairing_cost = Some(26897);
4271 cfg.group_ops_bls12381_uncompressed_g1_sum_max_terms = Some(1200);
4272
4273 cfg.validator_validate_metadata_cost_base = Some(20000);
4274 }
4275 71 => {
4276 cfg.sip_45_consensus_amplification_threshold = Some(5);
4277
4278 cfg.allowed_txn_cost_overage_burst_per_object_in_commit = Some(185_000_000);
4280 }
4281 72 => {
4282 cfg.feature_flags.convert_type_argument_error = true;
4283
4284 cfg.max_tx_gas = Some(50_000_000_000_000);
4287 cfg.max_gas_price = Some(50_000_000_000);
4289
4290 cfg.feature_flags.variant_nodes = true;
4291 }
4292 73 => {
4293 cfg.use_object_per_epoch_marker_table_v2 = Some(true);
4295
4296 if chain != Chain::Mainnet && chain != Chain::Testnet {
4297 cfg.consensus_gc_depth = Some(60);
4300 }
4301
4302 if chain != Chain::Mainnet {
4303 cfg.feature_flags.consensus_zstd_compression = true;
4305 }
4306
4307 cfg.feature_flags.consensus_smart_ancestor_selection = true;
4309 cfg.feature_flags
4311 .consensus_round_prober_probe_accepted_rounds = true;
4312
4313 cfg.feature_flags.per_object_congestion_control_mode =
4315 PerObjectCongestionControlMode::TotalGasBudgetWithCap;
4316 cfg.gas_budget_based_txn_cost_cap_factor = Some(400_000);
4317 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(37_000_000);
4318 cfg.max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit =
4319 Some(7_400_000); cfg.max_txn_cost_overage_per_object_in_commit = Some(u64::MAX);
4321 cfg.gas_budget_based_txn_cost_absolute_cap_commit_count = Some(50);
4322 cfg.allowed_txn_cost_overage_burst_per_object_in_commit = Some(370_000_000);
4323 }
4324 74 => {
4325 if chain != Chain::Mainnet && chain != Chain::Testnet {
4327 cfg.feature_flags.enable_nitro_attestation = true;
4328 }
4329 cfg.nitro_attestation_parse_base_cost = Some(53 * 50);
4330 cfg.nitro_attestation_parse_cost_per_byte = Some(50);
4331 cfg.nitro_attestation_verify_base_cost = Some(49632 * 50);
4332 cfg.nitro_attestation_verify_cost_per_cert = Some(52369 * 50);
4333
4334 cfg.feature_flags.consensus_zstd_compression = true;
4336
4337 if chain != Chain::Mainnet && chain != Chain::Testnet {
4338 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
4339 }
4340 }
4341 75 => {
4342 if chain != Chain::Mainnet {
4343 cfg.feature_flags.passkey_auth = true;
4344 }
4345 }
4346 76 => {
4347 if chain != Chain::Mainnet && chain != Chain::Testnet {
4348 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
4349 cfg.consensus_commit_rate_estimation_window_size = Some(10);
4350 }
4351 cfg.feature_flags.minimize_child_object_mutations = true;
4352
4353 if chain != Chain::Mainnet {
4354 cfg.feature_flags.accept_passkey_in_multisig = true;
4355 }
4356 }
4357 77 => {
4358 cfg.feature_flags.uncompressed_g1_group_elements = true;
4359
4360 if chain != Chain::Mainnet {
4361 cfg.consensus_gc_depth = Some(60);
4362 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
4363 }
4364 }
4365 78 => {
4366 cfg.feature_flags.move_native_context = true;
4367 cfg.tx_context_fresh_id_cost_base = Some(52);
4368 cfg.tx_context_sender_cost_base = Some(30);
4369 cfg.tx_context_epoch_cost_base = Some(30);
4370 cfg.tx_context_epoch_timestamp_ms_cost_base = Some(30);
4371 cfg.tx_context_sponsor_cost_base = Some(30);
4372 cfg.tx_context_gas_price_cost_base = Some(30);
4373 cfg.tx_context_gas_budget_cost_base = Some(30);
4374 cfg.tx_context_ids_created_cost_base = Some(30);
4375 cfg.tx_context_replace_cost_base = Some(30);
4376 cfg.gas_model_version = Some(10);
4377
4378 if chain != Chain::Mainnet {
4379 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
4380 cfg.consensus_commit_rate_estimation_window_size = Some(10);
4381
4382 cfg.feature_flags.per_object_congestion_control_mode =
4384 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4385 ExecutionTimeEstimateParams {
4386 target_utilization: 30,
4387 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4389 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4391 stored_observations_limit: u64::MAX,
4392 stake_weighted_median_threshold: 0,
4393 default_none_duration_for_new_keys: false,
4394 observations_chunk_size: None,
4395 },
4396 );
4397 }
4398 }
4399 79 => {
4400 if chain != Chain::Mainnet {
4401 cfg.feature_flags.consensus_median_based_commit_timestamp = true;
4402
4403 cfg.consensus_bad_nodes_stake_threshold = Some(30);
4406
4407 cfg.feature_flags.consensus_batched_block_sync = true;
4408
4409 cfg.feature_flags.enable_nitro_attestation = true
4411 }
4412 cfg.feature_flags.normalize_ptb_arguments = true;
4413
4414 cfg.consensus_gc_depth = Some(60);
4415 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
4416 }
4417 80 => {
4418 cfg.max_ptb_value_size = Some(1024 * 1024);
4419 }
4420 81 => {
4421 cfg.feature_flags.consensus_median_based_commit_timestamp = true;
4422 cfg.feature_flags.enforce_checkpoint_timestamp_monotonicity = true;
4423 cfg.consensus_bad_nodes_stake_threshold = Some(30)
4424 }
4425 82 => {
4426 cfg.feature_flags.max_ptb_value_size_v2 = true;
4427 }
4428 83 => {
4429 if chain == Chain::Mainnet {
4430 let aliased: [u8; 32] = Hex::decode(
4432 "0x0b2da327ba6a4cacbe75dddd50e6e8bbf81d6496e92d66af9154c61c77f7332f",
4433 )
4434 .unwrap()
4435 .try_into()
4436 .unwrap();
4437
4438 cfg.aliased_addresses.push(AliasedAddress {
4440 original: Hex::decode("0xcd8962dad278d8b50fa0f9eb0186bfa4cbdecc6d59377214c88d0286a0ac9562").unwrap().try_into().unwrap(),
4441 aliased,
4442 allowed_tx_digests: vec![
4443 Base58::decode("B2eGLFoMHgj93Ni8dAJBfqGzo8EWSTLBesZzhEpTPA4").unwrap().try_into().unwrap(),
4444 ],
4445 });
4446
4447 cfg.aliased_addresses.push(AliasedAddress {
4448 original: Hex::decode("0xe28b50cef1d633ea43d3296a3f6b67ff0312a5f1a99f0af753c85b8b5de8ff06").unwrap().try_into().unwrap(),
4449 aliased,
4450 allowed_tx_digests: vec![
4451 Base58::decode("J4QqSAgp7VrQtQpMy5wDX4QGsCSEZu3U5KuDAkbESAge").unwrap().try_into().unwrap(),
4452 ],
4453 });
4454 }
4455
4456 if chain != Chain::Mainnet {
4459 cfg.feature_flags.resolve_type_input_ids_to_defining_id = true;
4460 cfg.transfer_party_transfer_internal_cost_base = Some(52);
4461
4462 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
4464 cfg.consensus_commit_rate_estimation_window_size = Some(10);
4465 cfg.feature_flags.per_object_congestion_control_mode =
4466 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4467 ExecutionTimeEstimateParams {
4468 target_utilization: 30,
4469 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4471 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4473 stored_observations_limit: u64::MAX,
4474 stake_weighted_median_threshold: 0,
4475 default_none_duration_for_new_keys: false,
4476 observations_chunk_size: None,
4477 },
4478 );
4479
4480 cfg.feature_flags.consensus_batched_block_sync = true;
4482
4483 cfg.feature_flags.enable_nitro_attestation_upgraded_parsing = true;
4486 cfg.feature_flags.enable_nitro_attestation = true;
4487 }
4488 }
4489 84 => {
4490 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 cfg.feature_flags.per_object_congestion_control_mode =
4523 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4524 ExecutionTimeEstimateParams {
4525 target_utilization: 30,
4526 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4528 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4530 stored_observations_limit: 20,
4531 stake_weighted_median_threshold: 0,
4532 default_none_duration_for_new_keys: false,
4533 observations_chunk_size: None,
4534 },
4535 );
4536 cfg.feature_flags.allow_unbounded_system_objects = true;
4537 }
4538 85 => {
4539 if chain != Chain::Mainnet && chain != Chain::Testnet {
4540 cfg.feature_flags.enable_party_transfer = true;
4541 }
4542
4543 cfg.feature_flags
4544 .record_consensus_determined_version_assignments_in_prologue_v2 = true;
4545 cfg.feature_flags.disallow_self_identifier = true;
4546 cfg.feature_flags.per_object_congestion_control_mode =
4547 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4548 ExecutionTimeEstimateParams {
4549 target_utilization: 50,
4550 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4552 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4554 stored_observations_limit: 20,
4555 stake_weighted_median_threshold: 0,
4556 default_none_duration_for_new_keys: false,
4557 observations_chunk_size: None,
4558 },
4559 );
4560 }
4561 86 => {
4562 cfg.feature_flags.type_tags_in_object_runtime = true;
4563 cfg.max_move_enum_variants = Some(move_core_types::VARIANT_COUNT_MAX);
4564
4565 cfg.feature_flags.per_object_congestion_control_mode =
4567 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4568 ExecutionTimeEstimateParams {
4569 target_utilization: 50,
4570 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4572 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4574 stored_observations_limit: 20,
4575 stake_weighted_median_threshold: 3334,
4576 default_none_duration_for_new_keys: false,
4577 observations_chunk_size: None,
4578 },
4579 );
4580 if chain != Chain::Mainnet {
4582 cfg.feature_flags.enable_party_transfer = true;
4583 }
4584 }
4585 87 => {
4586 if chain == Chain::Mainnet {
4587 cfg.feature_flags.record_time_estimate_processed = true;
4588 }
4589 cfg.feature_flags.better_adapter_type_resolution_errors = true;
4590 }
4591 88 => {
4592 cfg.feature_flags.record_time_estimate_processed = true;
4593 cfg.tx_context_rgp_cost_base = Some(30);
4594 cfg.feature_flags
4595 .ignore_execution_time_observations_after_certs_closed = true;
4596
4597 cfg.feature_flags.per_object_congestion_control_mode =
4600 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4601 ExecutionTimeEstimateParams {
4602 target_utilization: 50,
4603 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4605 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4607 stored_observations_limit: 20,
4608 stake_weighted_median_threshold: 3334,
4609 default_none_duration_for_new_keys: true,
4610 observations_chunk_size: None,
4611 },
4612 );
4613 }
4614 89 => {
4615 cfg.feature_flags.dependency_linkage_error = true;
4616 cfg.feature_flags.additional_multisig_checks = true;
4617 }
4618 90 => {
4619 cfg.max_gas_price_rgp_factor_for_aborted_transactions = Some(100);
4621 cfg.feature_flags.debug_fatal_on_move_invariant_violation = true;
4622 cfg.feature_flags.additional_consensus_digest_indirect_state = true;
4623 cfg.feature_flags.accept_passkey_in_multisig = true;
4624 cfg.feature_flags.passkey_auth = true;
4625 cfg.feature_flags.check_for_init_during_upgrade = true;
4626
4627 if chain != Chain::Mainnet {
4629 cfg.feature_flags.mysticeti_fastpath = true;
4630 }
4631 }
4632 91 => {
4633 cfg.feature_flags.per_command_shared_object_transfer_rules = true;
4634 }
4635 92 => {
4636 cfg.feature_flags.per_command_shared_object_transfer_rules = false;
4637 }
4638 93 => {
4639 cfg.feature_flags
4640 .consensus_checkpoint_signature_key_includes_digest = true;
4641 }
4642 94 => {
4643 cfg.feature_flags.per_object_congestion_control_mode =
4645 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4646 ExecutionTimeEstimateParams {
4647 target_utilization: 50,
4648 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4650 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4652 stored_observations_limit: 18,
4653 stake_weighted_median_threshold: 3334,
4654 default_none_duration_for_new_keys: true,
4655 observations_chunk_size: None,
4656 },
4657 );
4658
4659 cfg.feature_flags.enable_party_transfer = true;
4661 }
4662 95 => {
4663 cfg.type_name_id_base_cost = Some(52);
4664
4665 cfg.max_transactions_per_checkpoint = Some(20_000);
4667 }
4668 96 => {
4669 if chain != Chain::Mainnet && chain != Chain::Testnet {
4671 cfg.feature_flags
4672 .include_checkpoint_artifacts_digest_in_summary = true;
4673 }
4674 cfg.feature_flags.correct_gas_payment_limit_check = true;
4675 cfg.feature_flags.authority_capabilities_v2 = true;
4676 cfg.feature_flags.use_mfp_txns_in_load_initial_object_debts = true;
4677 cfg.feature_flags.cancel_for_failed_dkg_early = true;
4678 cfg.feature_flags.enable_coin_registry = true;
4679
4680 cfg.feature_flags.mysticeti_fastpath = true;
4682 }
4683 97 => {
4684 cfg.feature_flags.additional_borrow_checks = true;
4685 }
4686 98 => {
4687 cfg.event_emit_auth_stream_cost = Some(52);
4688 cfg.feature_flags.better_loader_errors = true;
4689 cfg.feature_flags.generate_df_type_layouts = true;
4690 }
4691 99 => {
4692 cfg.feature_flags.use_new_commit_handler = true;
4693 }
4694 100 => {
4695 cfg.feature_flags.private_generics_verifier_v2 = true;
4696 }
4697 101 => {
4698 cfg.feature_flags.create_root_accumulator_object = true;
4699 cfg.max_updates_per_settlement_txn = Some(100);
4700 if chain != Chain::Mainnet {
4701 cfg.feature_flags.enable_poseidon = true;
4702 }
4703 }
4704 102 => {
4705 cfg.feature_flags.per_object_congestion_control_mode =
4709 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4710 ExecutionTimeEstimateParams {
4711 target_utilization: 50,
4712 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4714 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4716 stored_observations_limit: 180,
4717 stake_weighted_median_threshold: 3334,
4718 default_none_duration_for_new_keys: true,
4719 observations_chunk_size: Some(18),
4720 },
4721 );
4722 cfg.feature_flags.deprecate_global_storage_ops = true;
4723 }
4724 103 => {}
4725 104 => {
4726 cfg.translation_per_command_base_charge = Some(1);
4727 cfg.translation_per_input_base_charge = Some(1);
4728 cfg.translation_pure_input_per_byte_charge = Some(1);
4729 cfg.translation_per_type_node_charge = Some(1);
4730 cfg.translation_per_reference_node_charge = Some(1);
4731 cfg.translation_per_linkage_entry_charge = Some(10);
4732 cfg.gas_model_version = Some(11);
4733 cfg.feature_flags.abstract_size_in_object_runtime = true;
4734 cfg.feature_flags.object_runtime_charge_cache_load_gas = true;
4735 cfg.dynamic_field_hash_type_and_key_cost_base = Some(52);
4736 cfg.dynamic_field_add_child_object_cost_base = Some(52);
4737 cfg.dynamic_field_add_child_object_value_cost_per_byte = Some(1);
4738 cfg.dynamic_field_borrow_child_object_cost_base = Some(52);
4739 cfg.dynamic_field_borrow_child_object_child_ref_cost_per_byte = Some(1);
4740 cfg.dynamic_field_remove_child_object_cost_base = Some(52);
4741 cfg.dynamic_field_remove_child_object_child_cost_per_byte = Some(1);
4742 cfg.dynamic_field_has_child_object_cost_base = Some(52);
4743 cfg.dynamic_field_has_child_object_with_ty_cost_base = Some(52);
4744 cfg.feature_flags.enable_ptb_execution_v2 = true;
4745
4746 cfg.poseidon_bn254_cost_base = Some(260);
4747
4748 cfg.feature_flags.consensus_skip_gced_accept_votes = true;
4749
4750 if chain != Chain::Mainnet {
4751 cfg.feature_flags
4752 .enable_nitro_attestation_all_nonzero_pcrs_parsing = true;
4753 }
4754
4755 cfg.feature_flags
4756 .include_cancelled_randomness_txns_in_prologue = true;
4757 }
4758 105 => {
4759 cfg.feature_flags.enable_multi_epoch_transaction_expiration = true;
4760 cfg.feature_flags.disable_preconsensus_locking = true;
4761
4762 if chain != Chain::Mainnet {
4763 cfg.feature_flags
4764 .enable_nitro_attestation_always_include_required_pcrs_parsing = true;
4765 }
4766 }
4767 106 => {
4768 cfg.accumulator_object_storage_cost = Some(7600);
4770
4771 if chain != Chain::Mainnet && chain != Chain::Testnet {
4772 cfg.feature_flags.enable_accumulators = true;
4773 cfg.feature_flags.enable_address_balance_gas_payments = true;
4774 cfg.feature_flags.enable_authenticated_event_streams = true;
4775 cfg.feature_flags.enable_object_funds_withdraw = true;
4776 }
4777 }
4778 107 => {
4779 cfg.feature_flags
4780 .consensus_skip_gced_blocks_in_direct_finalization = true;
4781
4782 if in_integration_test() {
4784 cfg.consensus_gc_depth = Some(6);
4785 cfg.consensus_max_num_transactions_in_block = Some(8);
4786 }
4787 }
4788 108 => {
4789 cfg.feature_flags.gas_rounding_halve_digits = true;
4790 cfg.feature_flags.flexible_tx_context_positions = true;
4791 cfg.feature_flags.disable_entry_point_signature_check = true;
4792
4793 if chain != Chain::Mainnet {
4794 cfg.feature_flags.address_aliases = true;
4795
4796 cfg.feature_flags.enable_accumulators = true;
4797 cfg.feature_flags.enable_address_balance_gas_payments = true;
4798 }
4799
4800 cfg.feature_flags.enable_poseidon = true;
4801 }
4802 109 => {
4803 cfg.binary_variant_handles = Some(1024);
4804 cfg.binary_variant_instantiation_handles = Some(1024);
4805 cfg.feature_flags.restrict_hot_or_not_entry_functions = true;
4806 }
4807 110 => {
4808 cfg.feature_flags
4809 .enable_nitro_attestation_all_nonzero_pcrs_parsing = true;
4810 cfg.feature_flags
4811 .enable_nitro_attestation_always_include_required_pcrs_parsing = true;
4812 if chain != Chain::Mainnet && chain != Chain::Testnet {
4813 cfg.feature_flags.split_checkpoints_in_consensus_handler = true;
4814 }
4815 cfg.feature_flags.validate_zklogin_public_identifier = true;
4816 cfg.feature_flags.fix_checkpoint_signature_mapping = true;
4817 cfg.feature_flags
4818 .consensus_always_accept_system_transactions = true;
4819 if chain != Chain::Mainnet {
4820 cfg.feature_flags.enable_object_funds_withdraw = true;
4821 }
4822 }
4823 111 => {
4824 cfg.feature_flags.validator_metadata_verify_v2 = true;
4825 }
4826 112 => {
4827 cfg.group_ops_ristretto_decode_scalar_cost = Some(7);
4828 cfg.group_ops_ristretto_decode_point_cost = Some(200);
4829 cfg.group_ops_ristretto_scalar_add_cost = Some(10);
4830 cfg.group_ops_ristretto_point_add_cost = Some(500);
4831 cfg.group_ops_ristretto_scalar_sub_cost = Some(10);
4832 cfg.group_ops_ristretto_point_sub_cost = Some(500);
4833 cfg.group_ops_ristretto_scalar_mul_cost = Some(11);
4834 cfg.group_ops_ristretto_point_mul_cost = Some(1200);
4835 cfg.group_ops_ristretto_scalar_div_cost = Some(151);
4836 cfg.group_ops_ristretto_point_div_cost = Some(2500);
4837
4838 if chain != Chain::Mainnet && chain != Chain::Testnet {
4839 cfg.feature_flags.enable_ristretto255_group_ops = true;
4840 }
4841 }
4842 113 => {
4843 cfg.feature_flags.address_balance_gas_check_rgp_at_signing = true;
4844 if chain != Chain::Mainnet && chain != Chain::Testnet {
4845 cfg.feature_flags.defer_unpaid_amplification = true;
4846 }
4847 }
4848 114 => {
4849 cfg.feature_flags.randomize_checkpoint_tx_limit_in_tests = true;
4850 cfg.feature_flags.address_balance_gas_reject_gas_coin_arg = true;
4851 if chain != Chain::Mainnet {
4852 cfg.feature_flags.split_checkpoints_in_consensus_handler = true;
4853 cfg.feature_flags.enable_authenticated_event_streams = true;
4854 cfg.feature_flags
4855 .include_checkpoint_artifacts_digest_in_summary = true;
4856 }
4857 }
4858 115 => {
4859 cfg.feature_flags.normalize_depth_formula = true;
4860 }
4861 116 => {
4862 cfg.feature_flags.gasless_transaction_drop_safety = true;
4863 cfg.feature_flags.address_aliases = true;
4864 cfg.feature_flags.relax_valid_during_for_owned_inputs = true;
4865 cfg.feature_flags.defer_unpaid_amplification = false;
4867 cfg.feature_flags.enable_display_registry = true;
4868 }
4869 117 => {}
4870 118 => {
4871 cfg.feature_flags.use_coin_party_owner = true;
4872 }
4873 119 => {
4874 cfg.execution_version = Some(4);
4876 cfg.feature_flags.address_balance_gas_reject_gas_coin_arg = false;
4877 cfg.feature_flags.merge_randomness_into_checkpoint = true;
4878 if chain != Chain::Mainnet {
4879 cfg.feature_flags.enable_gasless = true;
4880 cfg.gasless_max_computation_units = Some(50_000);
4881 cfg.gasless_allowed_token_types = Some(vec![]);
4882 cfg.feature_flags.enable_coin_reservation_obj_refs = true;
4883 cfg.feature_flags
4884 .convert_withdrawal_compatibility_ptb_arguments = true;
4885 }
4886 cfg.gasless_max_unused_inputs = Some(1);
4887 cfg.gasless_max_pure_input_bytes = Some(32);
4888 if chain == Chain::Testnet {
4889 cfg.gasless_allowed_token_types = Some(vec![(TESTNET_USDC.to_string(), 0)]);
4890 }
4891 cfg.transfer_receive_object_cost_per_byte = Some(1);
4892 cfg.transfer_receive_object_type_cost_per_byte = Some(2);
4893 }
4894 120 => {
4895 cfg.feature_flags.disallow_jump_orphans = true;
4896 }
4897 121 => {
4898 if chain != Chain::Mainnet {
4900 cfg.feature_flags.defer_unpaid_amplification = true;
4901 cfg.gasless_max_tps = Some(50);
4902 }
4903 cfg.feature_flags
4904 .early_return_receive_object_mismatched_type = true;
4905 }
4906 122 => {
4907 cfg.feature_flags.defer_unpaid_amplification = true;
4909 cfg.verify_bulletproofs_ristretto255_base_cost = Some(30000);
4911 cfg.verify_bulletproofs_ristretto255_cost_per_bit_and_commitment = Some(6500);
4912 if chain != Chain::Mainnet && chain != Chain::Testnet {
4913 cfg.feature_flags.enable_verify_bulletproofs_ristretto255 = true;
4914 }
4915 cfg.feature_flags.gasless_verify_remaining_balance = true;
4916 cfg.include_special_package_amendments = match chain {
4917 Chain::Mainnet => Some(MAINNET_LINKAGE_AMENDMENTS.clone()),
4918 Chain::Testnet => Some(TESTNET_LINKAGE_AMENDMENTS.clone()),
4919 Chain::Unknown => None,
4920 };
4921 cfg.gasless_max_tx_size_bytes = Some(16 * 1024);
4922 cfg.gasless_max_tps = Some(300);
4923 cfg.gasless_max_computation_units = Some(5_000);
4924 }
4925 123 => {
4926 cfg.gas_model_version = Some(13);
4927 }
4928 124 => {
4929 if chain != Chain::Mainnet && chain != Chain::Testnet {
4930 cfg.feature_flags.timestamp_based_epoch_close = true;
4931 }
4932 cfg.gas_model_version = Some(14);
4933 cfg.feature_flags.limit_groth16_pvk_inputs = true;
4934
4935 cfg.feature_flags.enable_accumulators = true;
4941 cfg.feature_flags.enable_address_balance_gas_payments = true;
4942 cfg.feature_flags.enable_authenticated_event_streams = true;
4943 cfg.feature_flags.enable_coin_reservation_obj_refs = true;
4944 cfg.feature_flags.enable_object_funds_withdraw = true;
4945 cfg.feature_flags
4946 .convert_withdrawal_compatibility_ptb_arguments = true;
4947 cfg.feature_flags.split_checkpoints_in_consensus_handler = true;
4948 cfg.feature_flags
4949 .include_checkpoint_artifacts_digest_in_summary = true;
4950 cfg.feature_flags.enable_gasless = true;
4951
4952 if chain == Chain::Mainnet {
4957 cfg.gasless_allowed_token_types = Some(vec![
4958 (MAINNET_USDC.to_string(), 10_000),
4959 (MAINNET_USDSUI.to_string(), 10_000),
4960 (MAINNET_SUI_USDE.to_string(), 10_000),
4961 (MAINNET_USDY.to_string(), 10_000),
4962 (MAINNET_FDUSD.to_string(), 10_000),
4963 (MAINNET_AUSD.to_string(), 10_000),
4964 (MAINNET_USDB.to_string(), 10_000),
4965 ]);
4966 }
4967 }
4968 _ => panic!("unsupported version {:?}", version),
4979 }
4980 }
4981
4982 cfg
4983 }
4984
4985 pub fn apply_seeded_test_overrides(&mut self, seed: &[u8; 32]) {
4986 if !self.feature_flags.randomize_checkpoint_tx_limit_in_tests
4987 || !self.feature_flags.split_checkpoints_in_consensus_handler
4988 {
4989 return;
4990 }
4991
4992 if !mysten_common::in_test_configuration() {
4993 return;
4994 }
4995
4996 use rand::{Rng, SeedableRng, rngs::StdRng};
4997 let mut rng = StdRng::from_seed(*seed);
4998 let max_txns = rng.gen_range(10..=100u64);
4999 info!("seeded test override: max_transactions_per_checkpoint = {max_txns}");
5000 self.max_transactions_per_checkpoint = Some(max_txns);
5001 }
5002
5003 pub fn verifier_config(&self, signing_limits: Option<(usize, usize, usize)>) -> VerifierConfig {
5009 let (
5010 max_back_edges_per_function,
5011 max_back_edges_per_module,
5012 sanity_check_with_regex_reference_safety,
5013 ) = if let Some((
5014 max_back_edges_per_function,
5015 max_back_edges_per_module,
5016 sanity_check_with_regex_reference_safety,
5017 )) = signing_limits
5018 {
5019 (
5020 Some(max_back_edges_per_function),
5021 Some(max_back_edges_per_module),
5022 Some(sanity_check_with_regex_reference_safety),
5023 )
5024 } else {
5025 (None, None, None)
5026 };
5027
5028 let additional_borrow_checks = if signing_limits.is_some() {
5029 true
5031 } else {
5032 self.additional_borrow_checks()
5033 };
5034 let deprecate_global_storage_ops = if signing_limits.is_some() {
5035 true
5037 } else {
5038 self.deprecate_global_storage_ops()
5039 };
5040
5041 VerifierConfig {
5042 max_loop_depth: Some(self.max_loop_depth() as usize),
5043 max_generic_instantiation_length: Some(self.max_generic_instantiation_length() as usize),
5044 max_function_parameters: Some(self.max_function_parameters() as usize),
5045 max_basic_blocks: Some(self.max_basic_blocks() as usize),
5046 max_value_stack_size: self.max_value_stack_size() as usize,
5047 max_type_nodes: Some(self.max_type_nodes() as usize),
5048 max_push_size: Some(self.max_push_size() as usize),
5049 max_dependency_depth: Some(self.max_dependency_depth() as usize),
5050 max_fields_in_struct: Some(self.max_fields_in_struct() as usize),
5051 max_function_definitions: Some(self.max_function_definitions() as usize),
5052 max_data_definitions: Some(self.max_struct_definitions() as usize),
5053 max_constant_vector_len: Some(self.max_move_vector_len()),
5054 max_back_edges_per_function,
5055 max_back_edges_per_module,
5056 max_basic_blocks_in_script: None,
5057 max_identifier_len: self.max_move_identifier_len_as_option(), disallow_self_identifier: self.feature_flags.disallow_self_identifier,
5059 allow_receiving_object_id: self.allow_receiving_object_id(),
5060 reject_mutable_random_on_entry_functions: self
5061 .reject_mutable_random_on_entry_functions(),
5062 bytecode_version: self.move_binary_format_version(),
5063 max_variants_in_enum: self.max_move_enum_variants_as_option(),
5064 additional_borrow_checks,
5065 better_loader_errors: self.better_loader_errors(),
5066 private_generics_verifier_v2: self.private_generics_verifier_v2(),
5067 sanity_check_with_regex_reference_safety: sanity_check_with_regex_reference_safety
5068 .map(|limit| limit as u128),
5069 deprecate_global_storage_ops,
5070 disable_entry_point_signature_check: self.disable_entry_point_signature_check(),
5071 switch_to_regex_reference_safety: false,
5072 disallow_jump_orphans: self.disallow_jump_orphans(),
5073 }
5074 }
5075
5076 pub fn binary_config(
5077 &self,
5078 override_deprecate_global_storage_ops_during_deserialization: Option<bool>,
5079 ) -> BinaryConfig {
5080 let deprecate_global_storage_ops =
5081 override_deprecate_global_storage_ops_during_deserialization
5082 .unwrap_or_else(|| self.deprecate_global_storage_ops());
5083 BinaryConfig::new(
5084 self.move_binary_format_version(),
5085 self.min_move_binary_format_version_as_option()
5086 .unwrap_or(VERSION_1),
5087 self.no_extraneous_module_bytes(),
5088 deprecate_global_storage_ops,
5089 TableConfig {
5090 module_handles: self.binary_module_handles_as_option().unwrap_or(u16::MAX),
5091 datatype_handles: self.binary_struct_handles_as_option().unwrap_or(u16::MAX),
5092 function_handles: self.binary_function_handles_as_option().unwrap_or(u16::MAX),
5093 function_instantiations: self
5094 .binary_function_instantiations_as_option()
5095 .unwrap_or(u16::MAX),
5096 signatures: self.binary_signatures_as_option().unwrap_or(u16::MAX),
5097 constant_pool: self.binary_constant_pool_as_option().unwrap_or(u16::MAX),
5098 identifiers: self.binary_identifiers_as_option().unwrap_or(u16::MAX),
5099 address_identifiers: self
5100 .binary_address_identifiers_as_option()
5101 .unwrap_or(u16::MAX),
5102 struct_defs: self.binary_struct_defs_as_option().unwrap_or(u16::MAX),
5103 struct_def_instantiations: self
5104 .binary_struct_def_instantiations_as_option()
5105 .unwrap_or(u16::MAX),
5106 function_defs: self.binary_function_defs_as_option().unwrap_or(u16::MAX),
5107 field_handles: self.binary_field_handles_as_option().unwrap_or(u16::MAX),
5108 field_instantiations: self
5109 .binary_field_instantiations_as_option()
5110 .unwrap_or(u16::MAX),
5111 friend_decls: self.binary_friend_decls_as_option().unwrap_or(u16::MAX),
5112 enum_defs: self.binary_enum_defs_as_option().unwrap_or(u16::MAX),
5113 enum_def_instantiations: self
5114 .binary_enum_def_instantiations_as_option()
5115 .unwrap_or(u16::MAX),
5116 variant_handles: self.binary_variant_handles_as_option().unwrap_or(u16::MAX),
5117 variant_instantiation_handles: self
5118 .binary_variant_instantiation_handles_as_option()
5119 .unwrap_or(u16::MAX),
5120 },
5121 )
5122 }
5123
5124 #[cfg(not(msim))]
5128 pub fn apply_overrides_for_testing(
5129 override_fn: impl Fn(ProtocolVersion, Self) -> Self + Send + Sync + 'static,
5130 ) -> OverrideGuard {
5131 let mut cur = CONFIG_OVERRIDE.lock().unwrap();
5132 assert!(cur.is_none(), "config override already present");
5133 *cur = Some(Box::new(override_fn));
5134 OverrideGuard
5135 }
5136
5137 #[cfg(msim)]
5141 pub fn apply_overrides_for_testing(
5142 override_fn: impl Fn(ProtocolVersion, Self) -> Self + Send + 'static,
5143 ) -> OverrideGuard {
5144 CONFIG_OVERRIDE.with(|ovr| {
5145 let mut cur = ovr.borrow_mut();
5146 assert!(cur.is_none(), "config override already present");
5147 *cur = Some(Box::new(override_fn));
5148 OverrideGuard
5149 })
5150 }
5151
5152 #[cfg(not(msim))]
5153 fn apply_config_override(version: ProtocolVersion, mut ret: Self) -> Self {
5154 if let Some(override_fn) = CONFIG_OVERRIDE.lock().unwrap().as_ref() {
5155 warn!(
5156 "overriding ProtocolConfig settings with custom settings (you should not see this log outside of tests)"
5157 );
5158 ret = override_fn(version, ret);
5159 }
5160 ret
5161 }
5162
5163 #[cfg(msim)]
5164 fn apply_config_override(version: ProtocolVersion, ret: Self) -> Self {
5165 CONFIG_OVERRIDE.with(|ovr| {
5166 if let Some(override_fn) = &*ovr.borrow() {
5167 warn!(
5168 "overriding ProtocolConfig settings with custom settings (you should not see this log outside of tests)"
5169 );
5170 override_fn(version, ret)
5171 } else {
5172 ret
5173 }
5174 })
5175 }
5176}
5177
5178impl ProtocolConfig {
5182 pub fn set_advance_to_highest_supported_protocol_version_for_testing(&mut self, val: bool) {
5183 self.feature_flags
5184 .advance_to_highest_supported_protocol_version = val
5185 }
5186 pub fn set_commit_root_state_digest_supported_for_testing(&mut self, val: bool) {
5187 self.feature_flags.commit_root_state_digest = val
5188 }
5189 pub fn set_zklogin_auth_for_testing(&mut self, val: bool) {
5190 self.feature_flags.zklogin_auth = val
5191 }
5192 pub fn set_enable_jwk_consensus_updates_for_testing(&mut self, val: bool) {
5193 self.feature_flags.enable_jwk_consensus_updates = val
5194 }
5195 pub fn set_random_beacon_for_testing(&mut self, val: bool) {
5196 self.feature_flags.random_beacon = val
5197 }
5198
5199 pub fn set_upgraded_multisig_for_testing(&mut self, val: bool) {
5200 self.feature_flags.upgraded_multisig_supported = val
5201 }
5202 pub fn set_accept_zklogin_in_multisig_for_testing(&mut self, val: bool) {
5203 self.feature_flags.accept_zklogin_in_multisig = val
5204 }
5205
5206 pub fn set_shared_object_deletion_for_testing(&mut self, val: bool) {
5207 self.feature_flags.shared_object_deletion = val;
5208 }
5209
5210 pub fn set_narwhal_new_leader_election_schedule_for_testing(&mut self, val: bool) {
5211 self.feature_flags.narwhal_new_leader_election_schedule = val;
5212 }
5213
5214 pub fn set_receive_object_for_testing(&mut self, val: bool) {
5215 self.feature_flags.receive_objects = val
5216 }
5217 pub fn set_narwhal_certificate_v2_for_testing(&mut self, val: bool) {
5218 self.feature_flags.narwhal_certificate_v2 = val
5219 }
5220 pub fn set_verify_legacy_zklogin_address_for_testing(&mut self, val: bool) {
5221 self.feature_flags.verify_legacy_zklogin_address = val
5222 }
5223
5224 pub fn set_per_object_congestion_control_mode_for_testing(
5225 &mut self,
5226 val: PerObjectCongestionControlMode,
5227 ) {
5228 self.feature_flags.per_object_congestion_control_mode = val;
5229 }
5230
5231 pub fn set_consensus_choice_for_testing(&mut self, val: ConsensusChoice) {
5232 self.feature_flags.consensus_choice = val;
5233 }
5234
5235 pub fn set_consensus_network_for_testing(&mut self, val: ConsensusNetwork) {
5236 self.feature_flags.consensus_network = val;
5237 }
5238
5239 pub fn set_zklogin_max_epoch_upper_bound_delta_for_testing(&mut self, val: Option<u64>) {
5240 self.feature_flags.zklogin_max_epoch_upper_bound_delta = val
5241 }
5242
5243 pub fn set_disable_bridge_for_testing(&mut self) {
5244 self.feature_flags.bridge = false
5245 }
5246
5247 pub fn set_mysticeti_num_leaders_per_round_for_testing(&mut self, val: Option<usize>) {
5248 self.feature_flags.mysticeti_num_leaders_per_round = val;
5249 }
5250
5251 pub fn set_enable_soft_bundle_for_testing(&mut self, val: bool) {
5252 self.feature_flags.soft_bundle = val;
5253 }
5254
5255 pub fn set_passkey_auth_for_testing(&mut self, val: bool) {
5256 self.feature_flags.passkey_auth = val
5257 }
5258
5259 pub fn set_enable_party_transfer_for_testing(&mut self, val: bool) {
5260 self.feature_flags.enable_party_transfer = val
5261 }
5262
5263 pub fn set_consensus_distributed_vote_scoring_strategy_for_testing(&mut self, val: bool) {
5264 self.feature_flags
5265 .consensus_distributed_vote_scoring_strategy = val;
5266 }
5267
5268 pub fn set_consensus_round_prober_for_testing(&mut self, val: bool) {
5269 self.feature_flags.consensus_round_prober = val;
5270 }
5271
5272 pub fn set_disallow_new_modules_in_deps_only_packages_for_testing(&mut self, val: bool) {
5273 self.feature_flags
5274 .disallow_new_modules_in_deps_only_packages = val;
5275 }
5276
5277 pub fn set_correct_gas_payment_limit_check_for_testing(&mut self, val: bool) {
5278 self.feature_flags.correct_gas_payment_limit_check = val;
5279 }
5280
5281 pub fn set_address_aliases_for_testing(&mut self, val: bool) {
5282 self.feature_flags.address_aliases = val;
5283 }
5284
5285 pub fn set_consensus_round_prober_probe_accepted_rounds(&mut self, val: bool) {
5286 self.feature_flags
5287 .consensus_round_prober_probe_accepted_rounds = val;
5288 }
5289
5290 pub fn set_mysticeti_fastpath_for_testing(&mut self, val: bool) {
5291 self.feature_flags.mysticeti_fastpath = val;
5292 }
5293
5294 pub fn set_accept_passkey_in_multisig_for_testing(&mut self, val: bool) {
5295 self.feature_flags.accept_passkey_in_multisig = val;
5296 }
5297
5298 pub fn set_consensus_batched_block_sync_for_testing(&mut self, val: bool) {
5299 self.feature_flags.consensus_batched_block_sync = val;
5300 }
5301
5302 pub fn set_record_time_estimate_processed_for_testing(&mut self, val: bool) {
5303 self.feature_flags.record_time_estimate_processed = val;
5304 }
5305
5306 pub fn set_prepend_prologue_tx_in_consensus_commit_in_checkpoints_for_testing(
5307 &mut self,
5308 val: bool,
5309 ) {
5310 self.feature_flags
5311 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = val;
5312 }
5313
5314 pub fn enable_accumulators_for_testing(&mut self) {
5315 self.feature_flags.enable_accumulators = true;
5316 }
5317
5318 pub fn disable_accumulators_for_testing(&mut self) {
5319 self.feature_flags.enable_accumulators = false;
5320 self.feature_flags.enable_address_balance_gas_payments = false;
5321 }
5322
5323 pub fn enable_coin_reservation_for_testing(&mut self) {
5324 self.feature_flags.enable_coin_reservation_obj_refs = true;
5325 self.feature_flags
5326 .convert_withdrawal_compatibility_ptb_arguments = true;
5327 self.execution_version = Some(self.execution_version.map_or(4, |v| v.max(4)));
5330 }
5331
5332 pub fn disable_coin_reservation_for_testing(&mut self) {
5333 self.feature_flags.enable_coin_reservation_obj_refs = false;
5334 self.feature_flags
5335 .convert_withdrawal_compatibility_ptb_arguments = false;
5336 }
5337
5338 pub fn create_root_accumulator_object_for_testing(&mut self) {
5339 self.feature_flags.create_root_accumulator_object = true;
5340 }
5341
5342 pub fn disable_create_root_accumulator_object_for_testing(&mut self) {
5343 self.feature_flags.create_root_accumulator_object = false;
5344 }
5345
5346 pub fn enable_address_balance_gas_payments_for_testing(&mut self) {
5347 self.feature_flags.enable_accumulators = true;
5348 self.feature_flags.allow_private_accumulator_entrypoints = true;
5349 self.feature_flags.enable_address_balance_gas_payments = true;
5350 self.feature_flags.address_balance_gas_check_rgp_at_signing = true;
5351 self.feature_flags.address_balance_gas_reject_gas_coin_arg = false;
5352 self.execution_version = Some(self.execution_version.map_or(4, |v| v.max(4)))
5353 }
5354
5355 pub fn disable_address_balance_gas_payments_for_testing(&mut self) {
5356 self.feature_flags.enable_address_balance_gas_payments = false;
5357 }
5358
5359 pub fn enable_gasless_for_testing(&mut self) {
5360 self.enable_address_balance_gas_payments_for_testing();
5361 self.feature_flags.enable_gasless = true;
5362 self.feature_flags.gasless_verify_remaining_balance = true;
5363 self.gasless_max_computation_units = Some(5_000);
5364 self.gasless_allowed_token_types = Some(vec![]);
5365 self.gasless_max_tps = Some(1000);
5366 self.gasless_max_tx_size_bytes = Some(16 * 1024);
5367 }
5368
5369 pub fn disable_gasless_for_testing(&mut self) {
5370 self.feature_flags.enable_gasless = false;
5371 self.gasless_max_computation_units = None;
5372 self.gasless_allowed_token_types = None;
5373 }
5374
5375 pub fn set_gasless_allowed_token_types_for_testing(&mut self, types: Vec<(String, u64)>) {
5376 self.gasless_allowed_token_types = Some(types);
5377 }
5378
5379 pub fn enable_multi_epoch_transaction_expiration_for_testing(&mut self) {
5380 self.feature_flags.enable_multi_epoch_transaction_expiration = true;
5381 }
5382
5383 pub fn enable_authenticated_event_streams_for_testing(&mut self) {
5384 self.enable_accumulators_for_testing();
5385 self.feature_flags.enable_authenticated_event_streams = true;
5386 self.feature_flags
5387 .include_checkpoint_artifacts_digest_in_summary = true;
5388 self.feature_flags.split_checkpoints_in_consensus_handler = true;
5389 }
5390
5391 pub fn disable_authenticated_event_streams_for_testing(&mut self) {
5392 self.feature_flags.enable_authenticated_event_streams = false;
5393 }
5394
5395 pub fn disable_randomize_checkpoint_tx_limit_for_testing(&mut self) {
5396 self.feature_flags.randomize_checkpoint_tx_limit_in_tests = false;
5397 }
5398
5399 pub fn enable_non_exclusive_writes_for_testing(&mut self) {
5400 self.feature_flags.enable_non_exclusive_writes = true;
5401 }
5402
5403 pub fn set_relax_valid_during_for_owned_inputs_for_testing(&mut self, val: bool) {
5404 self.feature_flags.relax_valid_during_for_owned_inputs = val;
5405 }
5406
5407 pub fn set_ignore_execution_time_observations_after_certs_closed_for_testing(
5408 &mut self,
5409 val: bool,
5410 ) {
5411 self.feature_flags
5412 .ignore_execution_time_observations_after_certs_closed = val;
5413 }
5414
5415 pub fn set_consensus_checkpoint_signature_key_includes_digest_for_testing(
5416 &mut self,
5417 val: bool,
5418 ) {
5419 self.feature_flags
5420 .consensus_checkpoint_signature_key_includes_digest = val;
5421 }
5422
5423 pub fn set_cancel_for_failed_dkg_early_for_testing(&mut self, val: bool) {
5424 self.feature_flags.cancel_for_failed_dkg_early = val;
5425 }
5426
5427 pub fn set_use_mfp_txns_in_load_initial_object_debts_for_testing(&mut self, val: bool) {
5428 self.feature_flags.use_mfp_txns_in_load_initial_object_debts = val;
5429 }
5430
5431 pub fn set_authority_capabilities_v2_for_testing(&mut self, val: bool) {
5432 self.feature_flags.authority_capabilities_v2 = val;
5433 }
5434
5435 pub fn allow_references_in_ptbs_for_testing(&mut self) {
5436 self.feature_flags.allow_references_in_ptbs = true;
5437 }
5438
5439 pub fn set_consensus_skip_gced_accept_votes_for_testing(&mut self, val: bool) {
5440 self.feature_flags.consensus_skip_gced_accept_votes = val;
5441 }
5442
5443 pub fn set_enable_object_funds_withdraw_for_testing(&mut self, val: bool) {
5444 self.feature_flags.enable_object_funds_withdraw = val;
5445 }
5446
5447 pub fn set_split_checkpoints_in_consensus_handler_for_testing(&mut self, val: bool) {
5448 self.feature_flags.split_checkpoints_in_consensus_handler = val;
5449 }
5450
5451 pub fn set_merge_randomness_into_checkpoint_for_testing(&mut self, val: bool) {
5452 self.feature_flags.merge_randomness_into_checkpoint = val;
5453 }
5454}
5455
5456#[cfg(not(msim))]
5457type OverrideFn = dyn Fn(ProtocolVersion, ProtocolConfig) -> ProtocolConfig + Send + Sync;
5458
5459#[cfg(not(msim))]
5460static CONFIG_OVERRIDE: Mutex<Option<Box<OverrideFn>>> = Mutex::new(None);
5461
5462#[cfg(msim)]
5463type OverrideFn = dyn Fn(ProtocolVersion, ProtocolConfig) -> ProtocolConfig + Send;
5464
5465#[cfg(msim)]
5466thread_local! {
5467 static CONFIG_OVERRIDE: RefCell<Option<Box<OverrideFn>>> = RefCell::new(None);
5468}
5469
5470#[must_use]
5471pub struct OverrideGuard;
5472
5473#[cfg(not(msim))]
5474impl Drop for OverrideGuard {
5475 fn drop(&mut self) {
5476 info!("restoring override fn");
5477 *CONFIG_OVERRIDE.lock().unwrap() = None;
5478 }
5479}
5480
5481#[cfg(msim)]
5482impl Drop for OverrideGuard {
5483 fn drop(&mut self) {
5484 info!("restoring override fn");
5485 CONFIG_OVERRIDE.with(|ovr| {
5486 *ovr.borrow_mut() = None;
5487 });
5488 }
5489}
5490
5491#[derive(PartialEq, Eq)]
5494pub enum LimitThresholdCrossed {
5495 None,
5496 Soft(u128, u128),
5497 Hard(u128, u128),
5498}
5499
5500pub fn check_limit_in_range<T: Into<V>, U: Into<V>, V: PartialOrd + Into<u128>>(
5503 x: T,
5504 soft_limit: U,
5505 hard_limit: V,
5506) -> LimitThresholdCrossed {
5507 let x: V = x.into();
5508 let soft_limit: V = soft_limit.into();
5509
5510 debug_assert!(soft_limit <= hard_limit);
5511
5512 if x >= hard_limit {
5515 LimitThresholdCrossed::Hard(x.into(), hard_limit.into())
5516 } else if x < soft_limit {
5517 LimitThresholdCrossed::None
5518 } else {
5519 LimitThresholdCrossed::Soft(x.into(), soft_limit.into())
5520 }
5521}
5522
5523#[macro_export]
5524macro_rules! check_limit {
5525 ($x:expr, $hard:expr) => {
5526 check_limit!($x, $hard, $hard)
5527 };
5528 ($x:expr, $soft:expr, $hard:expr) => {
5529 check_limit_in_range($x as u64, $soft, $hard)
5530 };
5531}
5532
5533#[macro_export]
5537macro_rules! check_limit_by_meter {
5538 ($is_metered:expr, $x:expr, $metered_limit:expr, $unmetered_hard_limit:expr, $metric:expr) => {{
5539 let (h, metered_str) = if $is_metered {
5541 ($metered_limit, "metered")
5542 } else {
5543 ($unmetered_hard_limit, "unmetered")
5545 };
5546 use sui_protocol_config::check_limit_in_range;
5547 let result = check_limit_in_range($x as u64, $metered_limit, h);
5548 match result {
5549 LimitThresholdCrossed::None => {}
5550 LimitThresholdCrossed::Soft(_, _) => {
5551 $metric.with_label_values(&[metered_str, "soft"]).inc();
5552 }
5553 LimitThresholdCrossed::Hard(_, _) => {
5554 $metric.with_label_values(&[metered_str, "hard"]).inc();
5555 }
5556 };
5557 result
5558 }};
5559}
5560
5561pub type Amendments = BTreeMap<AccountAddress, BTreeMap<AccountAddress, AccountAddress>>;
5564
5565static MAINNET_LINKAGE_AMENDMENTS: LazyLock<Arc<Amendments>> =
5566 LazyLock::new(|| parse_amendments(include_str!("mainnet_amendments.json")));
5567
5568static TESTNET_LINKAGE_AMENDMENTS: LazyLock<Arc<Amendments>> =
5569 LazyLock::new(|| parse_amendments(include_str!("testnet_amendments.json")));
5570
5571fn parse_amendments(json: &str) -> Arc<Amendments> {
5572 #[derive(serde::Deserialize)]
5573 struct AmendmentEntry {
5574 root: String,
5575 deps: Vec<DepEntry>,
5576 }
5577
5578 #[derive(serde::Deserialize)]
5579 struct DepEntry {
5580 original_id: String,
5581 version_id: String,
5582 }
5583
5584 let entries: Vec<AmendmentEntry> =
5585 serde_json::from_str(json).expect("Failed to parse amendments JSON");
5586 let mut amendments = BTreeMap::new();
5587 for entry in entries {
5588 let root_id = AccountAddress::from_hex_literal(&entry.root).unwrap();
5589 let mut dep_ids = BTreeMap::new();
5590 for dep in entry.deps {
5591 let orig_id = AccountAddress::from_hex_literal(&dep.original_id).unwrap();
5592 let upgraded_id = AccountAddress::from_hex_literal(&dep.version_id).unwrap();
5593 assert!(
5594 dep_ids.insert(orig_id, upgraded_id).is_none(),
5595 "Duplicate original ID in amendments table"
5596 );
5597 }
5598 assert!(
5599 amendments.insert(root_id, dep_ids).is_none(),
5600 "Duplicate root ID in amendments table"
5601 );
5602 }
5603 Arc::new(amendments)
5604}
5605
5606#[cfg(all(test, not(msim)))]
5607mod test {
5608 use insta::assert_yaml_snapshot;
5609
5610 use super::*;
5611
5612 #[test]
5613 fn snapshot_tests() {
5614 println!("\n============================================================================");
5615 println!("! !");
5616 println!("! IMPORTANT: never update snapshots from this test. only add new versions! !");
5617 println!("! !");
5618 println!("============================================================================\n");
5619 for chain_id in &[Chain::Unknown, Chain::Mainnet, Chain::Testnet] {
5620 let chain_str = match chain_id {
5624 Chain::Unknown => "".to_string(),
5625 _ => format!("{:?}_", chain_id),
5626 };
5627 for i in MIN_PROTOCOL_VERSION..=MAX_PROTOCOL_VERSION {
5628 let cur = ProtocolVersion::new(i);
5629 assert_yaml_snapshot!(
5630 format!("{}version_{}", chain_str, cur.as_u64()),
5631 ProtocolConfig::get_for_version(cur, *chain_id)
5632 );
5633 }
5634 }
5635 }
5636
5637 #[test]
5638 fn test_getters() {
5639 let prot: ProtocolConfig =
5640 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5641 assert_eq!(
5642 prot.max_arguments(),
5643 prot.max_arguments_as_option().unwrap()
5644 );
5645 }
5646
5647 #[test]
5648 fn test_setters() {
5649 let mut prot: ProtocolConfig =
5650 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5651 prot.set_max_arguments_for_testing(123);
5652 assert_eq!(prot.max_arguments(), 123);
5653
5654 prot.set_max_arguments_from_str_for_testing("321".to_string());
5655 assert_eq!(prot.max_arguments(), 321);
5656
5657 prot.disable_max_arguments_for_testing();
5658 assert_eq!(prot.max_arguments_as_option(), None);
5659
5660 prot.set_attr_for_testing("max_arguments".to_string(), "456".to_string());
5661 assert_eq!(prot.max_arguments(), 456);
5662 }
5663
5664 #[test]
5665 fn test_get_for_version_if_supported_applies_test_overrides() {
5666 let before =
5667 ProtocolConfig::get_for_version_if_supported(ProtocolVersion::new(1), Chain::Unknown)
5668 .unwrap();
5669
5670 assert!(!before.enable_coin_reservation_obj_refs());
5671
5672 let _guard = ProtocolConfig::apply_overrides_for_testing(|_, mut cfg| {
5673 cfg.enable_coin_reservation_for_testing();
5674 cfg
5675 });
5676
5677 let after =
5678 ProtocolConfig::get_for_version_if_supported(ProtocolVersion::new(1), Chain::Unknown)
5679 .unwrap();
5680
5681 assert!(after.enable_coin_reservation_obj_refs());
5682 }
5683
5684 #[test]
5685 #[should_panic(expected = "unsupported version")]
5686 fn max_version_test() {
5687 let _ = ProtocolConfig::get_for_version_impl(
5690 ProtocolVersion::new(MAX_PROTOCOL_VERSION + 1),
5691 Chain::Unknown,
5692 );
5693 }
5694
5695 #[test]
5696 fn lookup_by_string_test() {
5697 let prot: ProtocolConfig =
5698 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5699 assert!(prot.lookup_attr("some random string".to_string()).is_none());
5701
5702 assert!(
5703 prot.lookup_attr("max_arguments".to_string())
5704 == Some(ProtocolConfigValue::u32(prot.max_arguments())),
5705 );
5706
5707 assert!(
5709 prot.lookup_attr("max_move_identifier_len".to_string())
5710 .is_none()
5711 );
5712
5713 let prot: ProtocolConfig =
5715 ProtocolConfig::get_for_version(ProtocolVersion::new(9), Chain::Unknown);
5716 assert!(
5717 prot.lookup_attr("max_move_identifier_len".to_string())
5718 == Some(ProtocolConfigValue::u64(prot.max_move_identifier_len()))
5719 );
5720
5721 let prot: ProtocolConfig =
5722 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5723 assert!(
5725 prot.attr_map()
5726 .get("max_move_identifier_len")
5727 .unwrap()
5728 .is_none()
5729 );
5730 assert!(
5732 prot.attr_map().get("max_arguments").unwrap()
5733 == &Some(ProtocolConfigValue::u32(prot.max_arguments()))
5734 );
5735
5736 let prot: ProtocolConfig =
5738 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5739 assert!(
5741 prot.feature_flags
5742 .lookup_attr("some random string".to_owned())
5743 .is_none()
5744 );
5745 assert!(
5746 !prot
5747 .feature_flags
5748 .attr_map()
5749 .contains_key("some random string")
5750 );
5751
5752 assert!(
5754 prot.feature_flags
5755 .lookup_attr("package_upgrades".to_owned())
5756 == Some(false)
5757 );
5758 assert!(
5759 prot.feature_flags
5760 .attr_map()
5761 .get("package_upgrades")
5762 .unwrap()
5763 == &false
5764 );
5765 let prot: ProtocolConfig =
5766 ProtocolConfig::get_for_version(ProtocolVersion::new(4), Chain::Unknown);
5767 assert!(
5769 prot.feature_flags
5770 .lookup_attr("package_upgrades".to_owned())
5771 == Some(true)
5772 );
5773 assert!(
5774 prot.feature_flags
5775 .attr_map()
5776 .get("package_upgrades")
5777 .unwrap()
5778 == &true
5779 );
5780 }
5781
5782 #[test]
5783 fn limit_range_fn_test() {
5784 let low = 100u32;
5785 let high = 10000u64;
5786
5787 assert!(check_limit!(1u8, low, high) == LimitThresholdCrossed::None);
5788 assert!(matches!(
5789 check_limit!(255u16, low, high),
5790 LimitThresholdCrossed::Soft(255u128, 100)
5791 ));
5792 assert!(matches!(
5798 check_limit!(2550000u64, low, high),
5799 LimitThresholdCrossed::Hard(2550000, 10000)
5800 ));
5801
5802 assert!(matches!(
5803 check_limit!(2550000u64, high, high),
5804 LimitThresholdCrossed::Hard(2550000, 10000)
5805 ));
5806
5807 assert!(matches!(
5808 check_limit!(1u8, high),
5809 LimitThresholdCrossed::None
5810 ));
5811
5812 assert!(check_limit!(255u16, high) == LimitThresholdCrossed::None);
5813
5814 assert!(matches!(
5815 check_limit!(2550000u64, high),
5816 LimitThresholdCrossed::Hard(2550000, 10000)
5817 ));
5818 }
5819
5820 #[test]
5821 fn linkage_amendments_load() {
5822 let mainnet = LazyLock::force(&MAINNET_LINKAGE_AMENDMENTS);
5823 let testnet = LazyLock::force(&TESTNET_LINKAGE_AMENDMENTS);
5824 assert!(!mainnet.is_empty(), "mainnet amendments must not be empty");
5825 assert!(!testnet.is_empty(), "testnet amendments must not be empty");
5826 }
5827}