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