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 = 130;
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)]
368pub struct ProtocolVersion(u64);
369
370impl ProtocolVersion {
371 pub const MIN: Self = Self(MIN_PROTOCOL_VERSION);
376
377 pub const MAX: Self = Self(MAX_PROTOCOL_VERSION);
378
379 #[cfg(not(msim))]
380 pub const MAX_ALLOWED: Self = Self::MAX;
381
382 #[cfg(msim)]
384 pub const MAX_ALLOWED: Self = Self(MAX_PROTOCOL_VERSION + 1);
385
386 pub fn new(v: u64) -> Self {
387 Self(v)
388 }
389
390 pub const fn as_u64(&self) -> u64 {
391 self.0
392 }
393
394 pub fn max() -> Self {
397 Self::MAX
398 }
399
400 pub fn prev(self) -> Self {
401 Self(self.0.checked_sub(1).unwrap())
402 }
403}
404
405impl From<u64> for ProtocolVersion {
406 fn from(v: u64) -> Self {
407 Self::new(v)
408 }
409}
410
411impl std::ops::Sub<u64> for ProtocolVersion {
412 type Output = Self;
413 fn sub(self, rhs: u64) -> Self::Output {
414 Self::new(self.0 - rhs)
415 }
416}
417
418impl std::ops::Add<u64> for ProtocolVersion {
419 type Output = Self;
420 fn add(self, rhs: u64) -> Self::Output {
421 Self::new(self.0 + rhs)
422 }
423}
424
425#[derive(
426 Clone, Serialize, Deserialize, Debug, Default, PartialEq, Copy, PartialOrd, Ord, Eq, ValueEnum,
427)]
428pub enum Chain {
429 Mainnet,
430 Testnet,
431 #[default]
432 Unknown,
433}
434
435impl Chain {
436 pub fn as_str(self) -> &'static str {
437 match self {
438 Chain::Mainnet => "mainnet",
439 Chain::Testnet => "testnet",
440 Chain::Unknown => "unknown",
441 }
442 }
443}
444
445pub struct Error(pub String);
446
447#[derive(Default, Clone, Serialize, Deserialize, Debug, ProtocolConfigFeatureFlagsGetters)]
450struct FeatureFlags {
451 #[serde(skip_serializing_if = "is_false")]
454 package_upgrades: bool,
455 #[serde(skip_serializing_if = "is_false")]
458 commit_root_state_digest: bool,
459 #[serde(skip_serializing_if = "is_false")]
461 advance_epoch_start_time_in_safe_mode: bool,
462 #[serde(skip_serializing_if = "is_false")]
465 loaded_child_objects_fixed: bool,
466 #[serde(skip_serializing_if = "is_false")]
469 missing_type_is_compatibility_error: bool,
470 #[serde(skip_serializing_if = "is_false")]
473 scoring_decision_with_validity_cutoff: bool,
474
475 #[serde(skip_serializing_if = "is_false")]
478 consensus_order_end_of_epoch_last: bool,
479
480 #[serde(skip_serializing_if = "is_false")]
482 disallow_adding_abilities_on_upgrade: bool,
483 #[serde(skip_serializing_if = "is_false")]
485 disable_invariant_violation_check_in_swap_loc: bool,
486 #[serde(skip_serializing_if = "is_false")]
489 advance_to_highest_supported_protocol_version: bool,
490 #[serde(skip_serializing_if = "is_false")]
492 ban_entry_init: bool,
493 #[serde(skip_serializing_if = "is_false")]
495 package_digest_hash_module: bool,
496 #[serde(skip_serializing_if = "is_false")]
498 disallow_change_struct_type_params_on_upgrade: bool,
499 #[serde(skip_serializing_if = "is_false")]
501 no_extraneous_module_bytes: bool,
502 #[serde(skip_serializing_if = "is_false")]
504 narwhal_versioned_metadata: bool,
505
506 #[serde(skip_serializing_if = "is_false")]
508 zklogin_auth: bool,
509 #[serde(skip_serializing_if = "ConsensusTransactionOrdering::is_none")]
511 consensus_transaction_ordering: ConsensusTransactionOrdering,
512
513 #[serde(skip_serializing_if = "is_false")]
521 simplified_unwrap_then_delete: bool,
522 #[serde(skip_serializing_if = "is_false")]
524 upgraded_multisig_supported: bool,
525 #[serde(skip_serializing_if = "is_false")]
527 txn_base_cost_as_multiplier: bool,
528
529 #[serde(skip_serializing_if = "is_false")]
531 shared_object_deletion: bool,
532
533 #[serde(skip_serializing_if = "is_false")]
535 narwhal_new_leader_election_schedule: bool,
536
537 #[serde(skip_serializing_if = "is_empty")]
539 zklogin_supported_providers: BTreeSet<String>,
540
541 #[serde(skip_serializing_if = "is_false")]
543 loaded_child_object_format: bool,
544
545 #[serde(skip_serializing_if = "is_false")]
546 #[skip_protocol_config_accessor]
547 enable_jwk_consensus_updates: bool,
548
549 #[serde(skip_serializing_if = "is_false")]
550 #[skip_protocol_config_accessor]
551 end_of_epoch_transaction_supported: bool,
552
553 #[serde(skip_serializing_if = "is_false")]
556 simple_conservation_checks: bool,
557
558 #[serde(skip_serializing_if = "is_false")]
560 loaded_child_object_format_type: bool,
561
562 #[serde(skip_serializing_if = "is_false")]
564 receive_objects: bool,
565
566 #[serde(skip_serializing_if = "is_false")]
568 consensus_checkpoint_signature_key_includes_digest: bool,
569
570 #[serde(skip_serializing_if = "is_false")]
572 random_beacon: bool,
573
574 #[serde(skip_serializing_if = "is_false")]
576 #[skip_protocol_config_accessor]
577 bridge: bool,
578
579 #[serde(skip_serializing_if = "is_false")]
580 enable_effects_v2: bool,
581
582 #[serde(skip_serializing_if = "is_false")]
584 narwhal_certificate_v2: bool,
585
586 #[serde(skip_serializing_if = "is_false")]
588 verify_legacy_zklogin_address: bool,
589
590 #[serde(skip_serializing_if = "is_false")]
592 throughput_aware_consensus_submission: bool,
593
594 #[serde(skip_serializing_if = "is_false")]
596 recompute_has_public_transfer_in_execution: bool,
597
598 #[serde(skip_serializing_if = "is_false")]
600 accept_zklogin_in_multisig: bool,
601
602 #[serde(skip_serializing_if = "is_false")]
604 accept_passkey_in_multisig: bool,
605
606 #[serde(skip_serializing_if = "is_false")]
608 validate_zklogin_public_identifier: bool,
609
610 #[serde(skip_serializing_if = "is_false")]
613 include_consensus_digest_in_prologue: bool,
614
615 #[serde(skip_serializing_if = "is_false")]
617 hardened_otw_check: bool,
618
619 #[serde(skip_serializing_if = "is_false")]
621 allow_receiving_object_id: bool,
622
623 #[serde(skip_serializing_if = "is_false")]
625 enable_poseidon: bool,
626
627 #[serde(skip_serializing_if = "is_false")]
629 enable_coin_deny_list: bool,
630
631 #[serde(skip_serializing_if = "is_false")]
633 enable_group_ops_native_functions: bool,
634
635 #[serde(skip_serializing_if = "is_false")]
637 enable_group_ops_native_function_msm: bool,
638
639 #[serde(skip_serializing_if = "is_false")]
641 enable_ristretto255_group_ops: bool,
642
643 #[serde(skip_serializing_if = "is_false")]
645 enable_verify_bulletproofs_ristretto255: bool,
646
647 #[serde(skip_serializing_if = "is_false")]
649 enable_nitro_attestation: bool,
650
651 #[serde(skip_serializing_if = "is_false")]
653 enable_nitro_attestation_upgraded_parsing: bool,
654
655 #[serde(skip_serializing_if = "is_false")]
657 enable_nitro_attestation_all_nonzero_pcrs_parsing: bool,
658
659 #[serde(skip_serializing_if = "is_false")]
661 enable_nitro_attestation_always_include_required_pcrs_parsing: bool,
662
663 #[serde(skip_serializing_if = "is_false")]
665 reject_mutable_random_on_entry_functions: bool,
666
667 #[serde(skip_serializing_if = "PerObjectCongestionControlMode::is_none")]
669 per_object_congestion_control_mode: PerObjectCongestionControlMode,
670
671 #[serde(skip_serializing_if = "ConsensusChoice::is_narwhal")]
673 consensus_choice: ConsensusChoice,
674
675 #[serde(skip_serializing_if = "ConsensusNetwork::is_anemo")]
677 consensus_network: ConsensusNetwork,
678
679 #[serde(skip_serializing_if = "is_false")]
681 correct_gas_payment_limit_check: bool,
682
683 #[serde(skip_serializing_if = "Option::is_none")]
685 zklogin_max_epoch_upper_bound_delta: Option<u64>,
686
687 #[serde(skip_serializing_if = "is_false")]
689 mysticeti_leader_scoring_and_schedule: bool,
690
691 #[serde(skip_serializing_if = "is_false")]
693 reshare_at_same_initial_version: bool,
694
695 #[serde(skip_serializing_if = "is_false")]
697 resolve_abort_locations_to_package_id: bool,
698
699 #[serde(skip_serializing_if = "is_false")]
703 mysticeti_use_committed_subdag_digest: bool,
704
705 #[serde(skip_serializing_if = "is_false")]
707 enable_vdf: bool,
708
709 #[serde(skip_serializing_if = "is_false")]
714 record_consensus_determined_version_assignments_in_prologue: bool,
715 #[serde(skip_serializing_if = "is_false")]
716 record_consensus_determined_version_assignments_in_prologue_v2: bool,
717
718 #[serde(skip_serializing_if = "is_false")]
720 fresh_vm_on_framework_upgrade: bool,
721
722 #[serde(skip_serializing_if = "is_false")]
730 prepend_prologue_tx_in_consensus_commit_in_checkpoints: bool,
731
732 #[serde(skip_serializing_if = "Option::is_none")]
734 mysticeti_num_leaders_per_round: Option<usize>,
735
736 #[serde(skip_serializing_if = "is_false")]
738 soft_bundle: bool,
739
740 #[serde(skip_serializing_if = "is_false")]
742 enable_coin_deny_list_v2: bool,
743
744 #[serde(skip_serializing_if = "is_false")]
746 passkey_auth: bool,
747
748 #[serde(skip_serializing_if = "is_false")]
750 authority_capabilities_v2: bool,
751
752 #[serde(skip_serializing_if = "is_false")]
754 rethrow_serialization_type_layout_errors: bool,
755
756 #[serde(skip_serializing_if = "is_false")]
758 consensus_distributed_vote_scoring_strategy: bool,
759
760 #[serde(skip_serializing_if = "is_false")]
762 consensus_round_prober: bool,
763
764 #[serde(skip_serializing_if = "is_false")]
766 validate_identifier_inputs: bool,
767
768 #[serde(skip_serializing_if = "is_false")]
770 disallow_self_identifier: bool,
771
772 #[serde(skip_serializing_if = "is_false")]
774 mysticeti_fastpath: bool,
775
776 #[serde(skip_serializing_if = "is_false")]
780 disable_preconsensus_locking: bool,
781
782 #[serde(skip_serializing_if = "is_false")]
784 relocate_event_module: bool,
785
786 #[serde(skip_serializing_if = "is_false")]
788 uncompressed_g1_group_elements: bool,
789
790 #[serde(skip_serializing_if = "is_false")]
791 disallow_new_modules_in_deps_only_packages: bool,
792
793 #[serde(skip_serializing_if = "is_false")]
795 consensus_smart_ancestor_selection: bool,
796
797 #[serde(skip_serializing_if = "is_false")]
799 consensus_round_prober_probe_accepted_rounds: bool,
800
801 #[serde(skip_serializing_if = "is_false")]
803 native_charging_v2: bool,
804
805 #[serde(skip_serializing_if = "is_false")]
808 #[skip_protocol_config_accessor]
809 consensus_linearize_subdag_v2: bool,
810
811 #[serde(skip_serializing_if = "is_false")]
813 convert_type_argument_error: bool,
814
815 #[serde(skip_serializing_if = "is_false")]
817 variant_nodes: bool,
818
819 #[serde(skip_serializing_if = "is_false")]
821 consensus_zstd_compression: bool,
822
823 #[serde(skip_serializing_if = "is_false")]
825 minimize_child_object_mutations: bool,
826
827 #[serde(skip_serializing_if = "is_false")]
829 record_additional_state_digest_in_prologue: bool,
830
831 #[serde(skip_serializing_if = "is_false")]
833 move_native_context: bool,
834
835 #[serde(skip_serializing_if = "is_false")]
838 #[skip_protocol_config_accessor]
839 consensus_median_based_commit_timestamp: bool,
840
841 #[serde(skip_serializing_if = "is_false")]
844 normalize_ptb_arguments: bool,
845
846 #[serde(skip_serializing_if = "is_false")]
848 consensus_batched_block_sync: bool,
849
850 #[serde(skip_serializing_if = "is_false")]
852 enforce_checkpoint_timestamp_monotonicity: bool,
853
854 #[serde(skip_serializing_if = "is_false")]
856 max_ptb_value_size_v2: bool,
857
858 #[serde(skip_serializing_if = "is_false")]
860 resolve_type_input_ids_to_defining_id: bool,
861
862 #[serde(skip_serializing_if = "is_false")]
864 enable_party_transfer: bool,
865
866 #[serde(skip_serializing_if = "is_false")]
868 allow_unbounded_system_objects: bool,
869
870 #[serde(skip_serializing_if = "is_false")]
872 type_tags_in_object_runtime: bool,
873
874 #[serde(skip_serializing_if = "is_false")]
876 enable_accumulators: bool,
877
878 #[serde(skip_serializing_if = "is_false")]
880 #[skip_protocol_config_accessor]
881 enable_coin_reservation_obj_refs: bool,
882
883 #[serde(skip_serializing_if = "is_false")]
886 create_root_accumulator_object: bool,
887
888 #[serde(skip_serializing_if = "is_false")]
890 #[skip_protocol_config_accessor]
891 enable_authenticated_event_streams: bool,
892
893 #[serde(skip_serializing_if = "is_false")]
895 enable_address_balance_gas_payments: bool,
896
897 #[serde(skip_serializing_if = "is_false")]
899 address_balance_gas_check_rgp_at_signing: bool,
900
901 #[serde(skip_serializing_if = "is_false")]
902 address_balance_gas_reject_gas_coin_arg: bool,
903
904 #[serde(skip_serializing_if = "is_false")]
906 enable_multi_epoch_transaction_expiration: bool,
907
908 #[serde(skip_serializing_if = "is_false")]
910 relax_valid_during_for_owned_inputs: bool,
911
912 #[serde(skip_serializing_if = "is_false")]
914 enable_ptb_execution_v2: bool,
915
916 #[serde(skip_serializing_if = "is_false")]
918 better_adapter_type_resolution_errors: bool,
919
920 #[serde(skip_serializing_if = "is_false")]
922 record_time_estimate_processed: bool,
923
924 #[serde(skip_serializing_if = "is_false")]
926 dependency_linkage_error: bool,
927
928 #[serde(skip_serializing_if = "is_false")]
930 additional_multisig_checks: bool,
931
932 #[serde(skip_serializing_if = "is_false")]
934 ignore_execution_time_observations_after_certs_closed: bool,
935
936 #[serde(skip_serializing_if = "is_false")]
940 debug_fatal_on_move_invariant_violation: bool,
941
942 #[serde(skip_serializing_if = "is_false")]
945 allow_private_accumulator_entrypoints: bool,
946
947 #[serde(skip_serializing_if = "is_false")]
949 additional_consensus_digest_indirect_state: bool,
950
951 #[serde(skip_serializing_if = "is_false")]
953 check_for_init_during_upgrade: bool,
954
955 #[serde(skip_serializing_if = "is_false")]
957 per_command_shared_object_transfer_rules: bool,
958
959 #[serde(skip_serializing_if = "is_false")]
961 include_checkpoint_artifacts_digest_in_summary: bool,
962
963 #[serde(skip_serializing_if = "is_false")]
965 use_mfp_txns_in_load_initial_object_debts: bool,
966
967 #[serde(skip_serializing_if = "is_false")]
969 cancel_for_failed_dkg_early: bool,
970
971 #[serde(skip_serializing_if = "is_false")]
973 always_advance_dkg_to_resolution: bool,
974
975 #[serde(skip_serializing_if = "is_false")]
977 enable_coin_registry: bool,
978
979 #[serde(skip_serializing_if = "is_false")]
981 abstract_size_in_object_runtime: bool,
982
983 #[serde(skip_serializing_if = "is_false")]
985 object_runtime_charge_cache_load_gas: bool,
986
987 #[serde(skip_serializing_if = "is_false")]
989 additional_borrow_checks: bool,
990
991 #[serde(skip_serializing_if = "is_false")]
993 use_new_commit_handler: bool,
994
995 #[serde(skip_serializing_if = "is_false")]
997 better_loader_errors: bool,
998
999 #[serde(skip_serializing_if = "is_false")]
1001 generate_df_type_layouts: bool,
1002
1003 #[serde(skip_serializing_if = "is_false")]
1005 allow_references_in_ptbs: bool,
1006
1007 #[serde(skip_serializing_if = "is_false")]
1009 enable_display_registry: bool,
1010
1011 #[serde(skip_serializing_if = "is_false")]
1013 private_generics_verifier_v2: bool,
1014
1015 #[serde(skip_serializing_if = "is_false")]
1017 deprecate_global_storage_ops_during_deserialization: bool,
1018
1019 #[serde(skip_serializing_if = "is_false")]
1022 enable_non_exclusive_writes: bool,
1023
1024 #[serde(skip_serializing_if = "is_false")]
1026 deprecate_global_storage_ops: bool,
1027
1028 #[serde(skip_serializing_if = "is_false")]
1030 normalize_depth_formula: bool,
1031
1032 #[serde(skip_serializing_if = "is_false")]
1034 consensus_skip_gced_accept_votes: bool,
1035
1036 #[serde(skip_serializing_if = "is_false")]
1038 include_cancelled_randomness_txns_in_prologue: bool,
1039
1040 #[serde(skip_serializing_if = "is_false")]
1042 #[skip_protocol_config_accessor]
1043 address_aliases: bool,
1044
1045 #[serde(skip_serializing_if = "is_false")]
1048 fix_checkpoint_signature_mapping: bool,
1049
1050 #[serde(skip_serializing_if = "is_false")]
1052 enable_object_funds_withdraw: bool,
1053
1054 #[serde(skip_serializing_if = "is_false")]
1057 record_net_unsettled_object_withdraws: bool,
1058
1059 #[serde(skip_serializing_if = "is_false")]
1061 consensus_skip_gced_blocks_in_direct_finalization: bool,
1062
1063 #[serde(skip_serializing_if = "is_false")]
1065 gas_rounding_halve_digits: bool,
1066
1067 #[serde(skip_serializing_if = "is_false")]
1069 flexible_tx_context_positions: bool,
1070
1071 #[serde(skip_serializing_if = "is_false")]
1073 disable_entry_point_signature_check: bool,
1074
1075 #[serde(skip_serializing_if = "is_false")]
1077 convert_withdrawal_compatibility_ptb_arguments: bool,
1078
1079 #[serde(skip_serializing_if = "is_false")]
1081 restrict_hot_or_not_entry_functions: bool,
1082
1083 #[serde(skip_serializing_if = "is_false")]
1085 split_checkpoints_in_consensus_handler: bool,
1086
1087 #[serde(skip_serializing_if = "is_false")]
1089 consensus_always_accept_system_transactions: bool,
1090
1091 #[serde(skip_serializing_if = "is_false")]
1093 validator_metadata_verify_v2: bool,
1094
1095 #[serde(skip_serializing_if = "is_false")]
1098 defer_unpaid_amplification: bool,
1099
1100 #[serde(skip_serializing_if = "is_false")]
1101 randomize_checkpoint_tx_limit_in_tests: bool,
1102
1103 #[serde(skip_serializing_if = "is_false")]
1105 gasless_transaction_drop_safety: bool,
1106
1107 #[serde(skip_serializing_if = "is_false")]
1109 merge_randomness_into_checkpoint: bool,
1110
1111 #[serde(skip_serializing_if = "is_false")]
1113 use_coin_party_owner: bool,
1114
1115 #[serde(skip_serializing_if = "is_false")]
1116 enable_gasless: bool,
1117
1118 #[serde(skip_serializing_if = "is_false")]
1119 gasless_verify_remaining_balance: bool,
1120
1121 #[serde(skip_serializing_if = "is_false")]
1122 disallow_jump_orphans: bool,
1123
1124 #[serde(skip_serializing_if = "is_false")]
1126 early_return_receive_object_mismatched_type: bool,
1127
1128 #[serde(skip_serializing_if = "is_false")]
1133 timestamp_based_epoch_close: bool,
1134
1135 #[serde(skip_serializing_if = "is_false")]
1138 limit_groth16_pvk_inputs: bool,
1139
1140 #[serde(skip_serializing_if = "is_false")]
1145 enforce_address_balance_change_invariant: bool,
1146
1147 #[serde(skip_serializing_if = "is_false")]
1149 granular_post_execution_checks: bool,
1150
1151 #[serde(skip_serializing_if = "is_false")]
1153 early_exit_on_iffw: bool,
1154
1155 #[serde(skip_serializing_if = "is_false")]
1157 enable_unified_linkage: bool,
1158}
1159
1160fn is_false(b: &bool) -> bool {
1161 !b
1162}
1163
1164fn is_empty(b: &BTreeSet<String>) -> bool {
1165 b.is_empty()
1166}
1167
1168fn is_zero(val: &u64) -> bool {
1169 *val == 0
1170}
1171
1172#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1174pub enum ConsensusTransactionOrdering {
1175 #[default]
1177 None,
1178 ByGasPrice,
1180}
1181
1182impl ConsensusTransactionOrdering {
1183 pub fn is_none(&self) -> bool {
1184 matches!(self, ConsensusTransactionOrdering::None)
1185 }
1186}
1187
1188#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1189pub struct ExecutionTimeEstimateParams {
1190 pub target_utilization: u64,
1192 pub allowed_txn_cost_overage_burst_limit_us: u64,
1196
1197 pub randomness_scalar: u64,
1200
1201 pub max_estimate_us: u64,
1203
1204 pub stored_observations_num_included_checkpoints: u64,
1207
1208 pub stored_observations_limit: u64,
1210
1211 #[serde(skip_serializing_if = "is_zero")]
1214 pub stake_weighted_median_threshold: u64,
1215
1216 #[serde(skip_serializing_if = "is_false")]
1220 pub default_none_duration_for_new_keys: bool,
1221
1222 #[serde(skip_serializing_if = "Option::is_none")]
1224 pub observations_chunk_size: Option<u64>,
1225}
1226
1227#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1229pub enum PerObjectCongestionControlMode {
1230 #[default]
1231 None, TotalGasBudget, TotalTxCount, TotalGasBudgetWithCap, ExecutionTimeEstimate(ExecutionTimeEstimateParams), }
1237
1238impl PerObjectCongestionControlMode {
1239 pub fn is_none(&self) -> bool {
1240 matches!(self, PerObjectCongestionControlMode::None)
1241 }
1242}
1243
1244#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1246pub enum ConsensusChoice {
1247 #[default]
1248 Narwhal,
1249 SwapEachEpoch,
1250 Mysticeti,
1251}
1252
1253impl ConsensusChoice {
1254 pub fn is_narwhal(&self) -> bool {
1255 matches!(self, ConsensusChoice::Narwhal)
1256 }
1257}
1258
1259#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1261pub enum ConsensusNetwork {
1262 #[default]
1263 Anemo,
1264 Tonic,
1265}
1266
1267impl ConsensusNetwork {
1268 pub fn is_anemo(&self) -> bool {
1269 matches!(self, ConsensusNetwork::Anemo)
1270 }
1271}
1272
1273#[skip_serializing_none]
1305#[derive(Clone, Serialize, Debug, ProtocolConfigAccessors, ProtocolConfigOverride)]
1306pub struct ProtocolConfig {
1307 pub version: ProtocolVersion,
1308
1309 #[serde(skip)]
1314 chain: Chain,
1315
1316 feature_flags: FeatureFlags,
1317
1318 max_tx_size_bytes: Option<u64>,
1321
1322 max_input_objects: Option<u64>,
1324
1325 max_size_written_objects: Option<u64>,
1329 max_size_written_objects_system_tx: Option<u64>,
1332
1333 max_serialized_tx_effects_size_bytes: Option<u64>,
1335
1336 max_serialized_tx_effects_size_bytes_system_tx: Option<u64>,
1338
1339 max_gas_payment_objects: Option<u32>,
1341
1342 max_modules_in_publish: Option<u32>,
1344
1345 max_package_dependencies: Option<u32>,
1347
1348 max_arguments: Option<u32>,
1351
1352 max_type_arguments: Option<u32>,
1354
1355 max_type_argument_depth: Option<u32>,
1357
1358 max_pure_argument_size: Option<u32>,
1360
1361 max_programmable_tx_commands: Option<u32>,
1363
1364 move_binary_format_version: Option<u32>,
1367 min_move_binary_format_version: Option<u32>,
1368
1369 binary_module_handles: Option<u16>,
1371 binary_struct_handles: Option<u16>,
1372 binary_function_handles: Option<u16>,
1373 binary_function_instantiations: Option<u16>,
1374 binary_signatures: Option<u16>,
1375 binary_constant_pool: Option<u16>,
1376 binary_identifiers: Option<u16>,
1377 binary_address_identifiers: Option<u16>,
1378 binary_struct_defs: Option<u16>,
1379 binary_struct_def_instantiations: Option<u16>,
1380 binary_function_defs: Option<u16>,
1381 binary_field_handles: Option<u16>,
1382 binary_field_instantiations: Option<u16>,
1383 binary_friend_decls: Option<u16>,
1384 binary_enum_defs: Option<u16>,
1385 binary_enum_def_instantiations: Option<u16>,
1386 binary_variant_handles: Option<u16>,
1387 binary_variant_instantiation_handles: Option<u16>,
1388
1389 max_move_object_size: Option<u64>,
1391
1392 max_move_package_size: Option<u64>,
1395
1396 max_publish_or_upgrade_per_ptb: Option<u64>,
1398
1399 max_tx_gas: Option<u64>,
1401
1402 max_gas_price: Option<u64>,
1404
1405 max_gas_price_rgp_factor_for_aborted_transactions: Option<u64>,
1408
1409 max_gas_computation_bucket: Option<u64>,
1411
1412 gas_rounding_step: Option<u64>,
1414
1415 max_loop_depth: Option<u64>,
1417
1418 max_generic_instantiation_length: Option<u64>,
1420
1421 max_function_parameters: Option<u64>,
1423
1424 max_basic_blocks: Option<u64>,
1426
1427 max_value_stack_size: Option<u64>,
1429
1430 max_type_nodes: Option<u64>,
1432
1433 max_generic_instantiation_type_nodes_per_function: Option<u64>,
1435
1436 max_generic_instantiation_type_nodes_per_module: Option<u64>,
1438
1439 max_push_size: Option<u64>,
1441
1442 max_struct_definitions: Option<u64>,
1444
1445 max_function_definitions: Option<u64>,
1447
1448 max_fields_in_struct: Option<u64>,
1450
1451 max_dependency_depth: Option<u64>,
1453
1454 max_num_event_emit: Option<u64>,
1456
1457 max_num_new_move_object_ids: Option<u64>,
1459
1460 max_num_new_move_object_ids_system_tx: Option<u64>,
1462
1463 max_num_deleted_move_object_ids: Option<u64>,
1465
1466 max_num_deleted_move_object_ids_system_tx: Option<u64>,
1468
1469 max_num_transferred_move_object_ids: Option<u64>,
1471
1472 max_num_transferred_move_object_ids_system_tx: Option<u64>,
1474
1475 max_event_emit_size: Option<u64>,
1477
1478 max_event_emit_size_total: Option<u64>,
1480
1481 max_move_vector_len: Option<u64>,
1483
1484 max_move_identifier_len: Option<u64>,
1486
1487 max_move_value_depth: Option<u64>,
1489
1490 max_move_enum_variants: Option<u64>,
1492
1493 max_back_edges_per_function: Option<u64>,
1495
1496 max_back_edges_per_module: Option<u64>,
1498
1499 max_verifier_meter_ticks_per_function: Option<u64>,
1501
1502 max_meter_ticks_per_module: Option<u64>,
1504
1505 max_meter_ticks_per_package: Option<u64>,
1507
1508 object_runtime_max_num_cached_objects: Option<u64>,
1512
1513 object_runtime_max_num_cached_objects_system_tx: Option<u64>,
1515
1516 object_runtime_max_num_store_entries: Option<u64>,
1518
1519 object_runtime_max_num_store_entries_system_tx: Option<u64>,
1521
1522 base_tx_cost_fixed: Option<u64>,
1525
1526 package_publish_cost_fixed: Option<u64>,
1529
1530 base_tx_cost_per_byte: Option<u64>,
1533
1534 package_publish_cost_per_byte: Option<u64>,
1536
1537 obj_access_cost_read_per_byte: Option<u64>,
1539
1540 obj_access_cost_mutate_per_byte: Option<u64>,
1542
1543 obj_access_cost_delete_per_byte: Option<u64>,
1545
1546 obj_access_cost_verify_per_byte: Option<u64>,
1556
1557 max_type_to_layout_nodes: Option<u64>,
1559
1560 max_ptb_value_size: Option<u64>,
1562
1563 gas_model_version: Option<u64>,
1566
1567 obj_data_cost_refundable: Option<u64>,
1570
1571 obj_metadata_cost_non_refundable: Option<u64>,
1575
1576 storage_rebate_rate: Option<u64>,
1582
1583 storage_fund_reinvest_rate: Option<u64>,
1586
1587 reward_slashing_rate: Option<u64>,
1590
1591 storage_gas_price: Option<u64>,
1593
1594 accumulator_object_storage_cost: Option<u64>,
1596
1597 max_transactions_per_checkpoint: Option<u64>,
1602
1603 max_checkpoint_size_bytes: Option<u64>,
1607
1608 buffer_stake_for_protocol_upgrade_bps: Option<u64>,
1613
1614 address_from_bytes_cost_base: Option<u64>,
1619 address_to_u256_cost_base: Option<u64>,
1621 address_from_u256_cost_base: Option<u64>,
1623
1624 config_read_setting_impl_cost_base: Option<u64>,
1629 config_read_setting_impl_cost_per_byte: Option<u64>,
1630
1631 dynamic_field_hash_type_and_key_cost_base: Option<u64>,
1634 dynamic_field_hash_type_and_key_type_cost_per_byte: Option<u64>,
1635 dynamic_field_hash_type_and_key_value_cost_per_byte: Option<u64>,
1636 dynamic_field_hash_type_and_key_type_tag_cost_per_byte: Option<u64>,
1637 dynamic_field_add_child_object_cost_base: Option<u64>,
1639 dynamic_field_add_child_object_type_cost_per_byte: Option<u64>,
1640 dynamic_field_add_child_object_value_cost_per_byte: Option<u64>,
1641 dynamic_field_add_child_object_struct_tag_cost_per_byte: Option<u64>,
1642 dynamic_field_borrow_child_object_cost_base: Option<u64>,
1644 dynamic_field_borrow_child_object_child_ref_cost_per_byte: Option<u64>,
1645 dynamic_field_borrow_child_object_type_cost_per_byte: Option<u64>,
1646 dynamic_field_remove_child_object_cost_base: Option<u64>,
1648 dynamic_field_remove_child_object_child_cost_per_byte: Option<u64>,
1649 dynamic_field_remove_child_object_type_cost_per_byte: Option<u64>,
1650 dynamic_field_has_child_object_cost_base: Option<u64>,
1652 dynamic_field_has_child_object_with_ty_cost_base: Option<u64>,
1654 dynamic_field_has_child_object_with_ty_type_cost_per_byte: Option<u64>,
1655 dynamic_field_has_child_object_with_ty_type_tag_cost_per_byte: Option<u64>,
1656
1657 event_emit_cost_base: Option<u64>,
1660 event_emit_value_size_derivation_cost_per_byte: Option<u64>,
1661 event_emit_tag_size_derivation_cost_per_byte: Option<u64>,
1662 event_emit_output_cost_per_byte: Option<u64>,
1663 event_emit_auth_stream_cost: Option<u64>,
1664
1665 object_borrow_uid_cost_base: Option<u64>,
1668 object_delete_impl_cost_base: Option<u64>,
1670 object_record_new_uid_cost_base: Option<u64>,
1672
1673 transfer_transfer_internal_cost_base: Option<u64>,
1676 transfer_party_transfer_internal_cost_base: Option<u64>,
1678 transfer_freeze_object_cost_base: Option<u64>,
1680 transfer_share_object_cost_base: Option<u64>,
1682 transfer_receive_object_cost_base: Option<u64>,
1685 transfer_receive_object_cost_per_byte: Option<u64>,
1686 transfer_receive_object_type_cost_per_byte: Option<u64>,
1687
1688 tx_context_derive_id_cost_base: Option<u64>,
1691 tx_context_fresh_id_cost_base: Option<u64>,
1692 tx_context_sender_cost_base: Option<u64>,
1693 tx_context_epoch_cost_base: Option<u64>,
1694 tx_context_epoch_timestamp_ms_cost_base: Option<u64>,
1695 tx_context_sponsor_cost_base: Option<u64>,
1696 tx_context_rgp_cost_base: Option<u64>,
1697 tx_context_gas_price_cost_base: Option<u64>,
1698 tx_context_gas_budget_cost_base: Option<u64>,
1699 tx_context_ids_created_cost_base: Option<u64>,
1700 tx_context_replace_cost_base: Option<u64>,
1701
1702 types_is_one_time_witness_cost_base: Option<u64>,
1705 types_is_one_time_witness_type_tag_cost_per_byte: Option<u64>,
1706 types_is_one_time_witness_type_cost_per_byte: Option<u64>,
1707
1708 validator_validate_metadata_cost_base: Option<u64>,
1711 validator_validate_metadata_data_cost_per_byte: Option<u64>,
1712
1713 crypto_invalid_arguments_cost: Option<u64>,
1715 bls12381_bls12381_min_sig_verify_cost_base: Option<u64>,
1717 bls12381_bls12381_min_sig_verify_msg_cost_per_byte: Option<u64>,
1718 bls12381_bls12381_min_sig_verify_msg_cost_per_block: Option<u64>,
1719
1720 bls12381_bls12381_min_pk_verify_cost_base: Option<u64>,
1722 bls12381_bls12381_min_pk_verify_msg_cost_per_byte: Option<u64>,
1723 bls12381_bls12381_min_pk_verify_msg_cost_per_block: Option<u64>,
1724
1725 ecdsa_k1_ecrecover_keccak256_cost_base: Option<u64>,
1727 ecdsa_k1_ecrecover_keccak256_msg_cost_per_byte: Option<u64>,
1728 ecdsa_k1_ecrecover_keccak256_msg_cost_per_block: Option<u64>,
1729 ecdsa_k1_ecrecover_sha256_cost_base: Option<u64>,
1730 ecdsa_k1_ecrecover_sha256_msg_cost_per_byte: Option<u64>,
1731 ecdsa_k1_ecrecover_sha256_msg_cost_per_block: Option<u64>,
1732
1733 ecdsa_k1_decompress_pubkey_cost_base: Option<u64>,
1735
1736 ecdsa_k1_secp256k1_verify_keccak256_cost_base: Option<u64>,
1738 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_byte: Option<u64>,
1739 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_block: Option<u64>,
1740 ecdsa_k1_secp256k1_verify_sha256_cost_base: Option<u64>,
1741 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_byte: Option<u64>,
1742 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_block: Option<u64>,
1743
1744 ecdsa_r1_ecrecover_keccak256_cost_base: Option<u64>,
1746 ecdsa_r1_ecrecover_keccak256_msg_cost_per_byte: Option<u64>,
1747 ecdsa_r1_ecrecover_keccak256_msg_cost_per_block: Option<u64>,
1748 ecdsa_r1_ecrecover_sha256_cost_base: Option<u64>,
1749 ecdsa_r1_ecrecover_sha256_msg_cost_per_byte: Option<u64>,
1750 ecdsa_r1_ecrecover_sha256_msg_cost_per_block: Option<u64>,
1751
1752 ecdsa_r1_secp256r1_verify_keccak256_cost_base: Option<u64>,
1754 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_byte: Option<u64>,
1755 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_block: Option<u64>,
1756 ecdsa_r1_secp256r1_verify_sha256_cost_base: Option<u64>,
1757 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_byte: Option<u64>,
1758 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_block: Option<u64>,
1759
1760 ecvrf_ecvrf_verify_cost_base: Option<u64>,
1762 ecvrf_ecvrf_verify_alpha_string_cost_per_byte: Option<u64>,
1763 ecvrf_ecvrf_verify_alpha_string_cost_per_block: Option<u64>,
1764
1765 ed25519_ed25519_verify_cost_base: Option<u64>,
1767 ed25519_ed25519_verify_msg_cost_per_byte: Option<u64>,
1768 ed25519_ed25519_verify_msg_cost_per_block: Option<u64>,
1769
1770 groth16_prepare_verifying_key_bls12381_cost_base: Option<u64>,
1772 groth16_prepare_verifying_key_bn254_cost_base: Option<u64>,
1773
1774 groth16_verify_groth16_proof_internal_bls12381_cost_base: Option<u64>,
1776 groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input: Option<u64>,
1777 groth16_verify_groth16_proof_internal_bn254_cost_base: Option<u64>,
1778 groth16_verify_groth16_proof_internal_bn254_cost_per_public_input: Option<u64>,
1779 groth16_verify_groth16_proof_internal_public_input_cost_per_byte: Option<u64>,
1780
1781 hash_blake2b256_cost_base: Option<u64>,
1783 hash_blake2b256_data_cost_per_byte: Option<u64>,
1784 hash_blake2b256_data_cost_per_block: Option<u64>,
1785
1786 hash_keccak256_cost_base: Option<u64>,
1788 hash_keccak256_data_cost_per_byte: Option<u64>,
1789 hash_keccak256_data_cost_per_block: Option<u64>,
1790
1791 poseidon_bn254_cost_base: Option<u64>,
1793 poseidon_bn254_cost_per_block: Option<u64>,
1794
1795 group_ops_bls12381_decode_scalar_cost: Option<u64>,
1797 group_ops_bls12381_decode_g1_cost: Option<u64>,
1798 group_ops_bls12381_decode_g2_cost: Option<u64>,
1799 group_ops_bls12381_decode_gt_cost: Option<u64>,
1800 group_ops_bls12381_scalar_add_cost: Option<u64>,
1801 group_ops_bls12381_g1_add_cost: Option<u64>,
1802 group_ops_bls12381_g2_add_cost: Option<u64>,
1803 group_ops_bls12381_gt_add_cost: Option<u64>,
1804 group_ops_bls12381_scalar_sub_cost: Option<u64>,
1805 group_ops_bls12381_g1_sub_cost: Option<u64>,
1806 group_ops_bls12381_g2_sub_cost: Option<u64>,
1807 group_ops_bls12381_gt_sub_cost: Option<u64>,
1808 group_ops_bls12381_scalar_mul_cost: Option<u64>,
1809 group_ops_bls12381_g1_mul_cost: Option<u64>,
1810 group_ops_bls12381_g2_mul_cost: Option<u64>,
1811 group_ops_bls12381_gt_mul_cost: Option<u64>,
1812 group_ops_bls12381_scalar_div_cost: Option<u64>,
1813 group_ops_bls12381_g1_div_cost: Option<u64>,
1814 group_ops_bls12381_g2_div_cost: Option<u64>,
1815 group_ops_bls12381_gt_div_cost: Option<u64>,
1816 group_ops_bls12381_g1_hash_to_base_cost: Option<u64>,
1817 group_ops_bls12381_g2_hash_to_base_cost: Option<u64>,
1818 group_ops_bls12381_g1_hash_to_cost_per_byte: Option<u64>,
1819 group_ops_bls12381_g2_hash_to_cost_per_byte: Option<u64>,
1820 group_ops_bls12381_g1_msm_base_cost: Option<u64>,
1821 group_ops_bls12381_g2_msm_base_cost: Option<u64>,
1822 group_ops_bls12381_g1_msm_base_cost_per_input: Option<u64>,
1823 group_ops_bls12381_g2_msm_base_cost_per_input: Option<u64>,
1824 group_ops_bls12381_msm_max_len: Option<u32>,
1825 group_ops_bls12381_pairing_cost: Option<u64>,
1826 group_ops_bls12381_g1_to_uncompressed_g1_cost: Option<u64>,
1827 group_ops_bls12381_uncompressed_g1_to_g1_cost: Option<u64>,
1828 group_ops_bls12381_uncompressed_g1_sum_base_cost: Option<u64>,
1829 group_ops_bls12381_uncompressed_g1_sum_cost_per_term: Option<u64>,
1830 group_ops_bls12381_uncompressed_g1_sum_max_terms: Option<u64>,
1831
1832 group_ops_ristretto_decode_scalar_cost: Option<u64>,
1833 group_ops_ristretto_decode_point_cost: Option<u64>,
1834 group_ops_ristretto_scalar_add_cost: Option<u64>,
1835 group_ops_ristretto_point_add_cost: Option<u64>,
1836 group_ops_ristretto_scalar_sub_cost: Option<u64>,
1837 group_ops_ristretto_point_sub_cost: Option<u64>,
1838 group_ops_ristretto_scalar_mul_cost: Option<u64>,
1839 group_ops_ristretto_point_mul_cost: Option<u64>,
1840 group_ops_ristretto_scalar_div_cost: Option<u64>,
1841 group_ops_ristretto_point_div_cost: Option<u64>,
1842
1843 verify_bulletproofs_ristretto255_base_cost: Option<u64>,
1844 verify_bulletproofs_ristretto255_cost_per_bit_and_commitment: Option<u64>,
1845
1846 hmac_hmac_sha3_256_cost_base: Option<u64>,
1848 hmac_hmac_sha3_256_input_cost_per_byte: Option<u64>,
1849 hmac_hmac_sha3_256_input_cost_per_block: Option<u64>,
1850
1851 check_zklogin_id_cost_base: Option<u64>,
1853 check_zklogin_issuer_cost_base: Option<u64>,
1855
1856 vdf_verify_vdf_cost: Option<u64>,
1857 vdf_hash_to_input_cost: Option<u64>,
1858
1859 nitro_attestation_parse_base_cost: Option<u64>,
1861 nitro_attestation_parse_cost_per_byte: Option<u64>,
1862 nitro_attestation_verify_base_cost: Option<u64>,
1863 nitro_attestation_verify_cost_per_cert: Option<u64>,
1864
1865 bcs_per_byte_serialized_cost: Option<u64>,
1867 bcs_legacy_min_output_size_cost: Option<u64>,
1868 bcs_failure_cost: Option<u64>,
1869
1870 hash_sha2_256_base_cost: Option<u64>,
1871 hash_sha2_256_per_byte_cost: Option<u64>,
1872 hash_sha2_256_legacy_min_input_len_cost: Option<u64>,
1873 hash_sha3_256_base_cost: Option<u64>,
1874 hash_sha3_256_per_byte_cost: Option<u64>,
1875 hash_sha3_256_legacy_min_input_len_cost: Option<u64>,
1876 type_name_get_base_cost: Option<u64>,
1877 type_name_get_per_byte_cost: Option<u64>,
1878 type_name_id_base_cost: Option<u64>,
1879
1880 string_check_utf8_base_cost: Option<u64>,
1881 string_check_utf8_per_byte_cost: Option<u64>,
1882 string_is_char_boundary_base_cost: Option<u64>,
1883 string_sub_string_base_cost: Option<u64>,
1884 string_sub_string_per_byte_cost: Option<u64>,
1885 string_index_of_base_cost: Option<u64>,
1886 string_index_of_per_byte_pattern_cost: Option<u64>,
1887 string_index_of_per_byte_searched_cost: Option<u64>,
1888
1889 vector_empty_base_cost: Option<u64>,
1890 vector_length_base_cost: Option<u64>,
1891 vector_push_back_base_cost: Option<u64>,
1892 vector_push_back_legacy_per_abstract_memory_unit_cost: Option<u64>,
1893 vector_borrow_base_cost: Option<u64>,
1894 vector_pop_back_base_cost: Option<u64>,
1895 vector_destroy_empty_base_cost: Option<u64>,
1896 vector_swap_base_cost: Option<u64>,
1897 debug_print_base_cost: Option<u64>,
1898 debug_print_stack_trace_base_cost: Option<u64>,
1899
1900 execution_version: Option<u64>,
1909
1910 consensus_bad_nodes_stake_threshold: Option<u64>,
1914
1915 max_jwk_votes_per_validator_per_epoch: Option<u64>,
1916 max_age_of_jwk_in_epochs: Option<u64>,
1920
1921 random_beacon_reduction_allowed_delta: Option<u16>,
1925
1926 random_beacon_reduction_lower_bound: Option<u32>,
1929
1930 random_beacon_dkg_timeout_round: Option<u32>,
1933
1934 random_beacon_min_round_interval_ms: Option<u64>,
1936
1937 random_beacon_dkg_version: Option<u64>,
1940
1941 consensus_max_transaction_size_bytes: Option<u64>,
1944 consensus_max_transactions_in_block_bytes: Option<u64>,
1946 consensus_max_num_transactions_in_block: Option<u64>,
1948
1949 consensus_voting_rounds: Option<u32>,
1951
1952 max_accumulated_txn_cost_per_object_in_narwhal_commit: Option<u64>,
1954
1955 max_deferral_rounds_for_congestion_control: Option<u64>,
1958
1959 max_txn_cost_overage_per_object_in_commit: Option<u64>,
1961
1962 allowed_txn_cost_overage_burst_per_object_in_commit: Option<u64>,
1964
1965 min_checkpoint_interval_ms: Option<u64>,
1967
1968 checkpoint_summary_version_specific_data: Option<u64>,
1970
1971 max_soft_bundle_size: Option<u64>,
1973
1974 bridge_should_try_to_finalize_committee: Option<bool>,
1978
1979 max_accumulated_txn_cost_per_object_in_mysticeti_commit: Option<u64>,
1985
1986 max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit: Option<u64>,
1989
1990 consensus_gc_depth: Option<u32>,
1993
1994 gas_budget_based_txn_cost_cap_factor: Option<u64>,
1996
1997 gas_budget_based_txn_cost_absolute_cap_commit_count: Option<u64>,
1999
2000 sip_45_consensus_amplification_threshold: Option<u64>,
2003
2004 use_object_per_epoch_marker_table_v2: Option<bool>,
2007
2008 consensus_commit_rate_estimation_window_size: Option<u32>,
2010
2011 #[serde(skip_serializing_if = "Vec::is_empty")]
2015 aliased_addresses: Vec<AliasedAddress>,
2016
2017 translation_per_command_base_charge: Option<u64>,
2020
2021 translation_per_input_base_charge: Option<u64>,
2024
2025 translation_pure_input_per_byte_charge: Option<u64>,
2027
2028 translation_per_type_node_charge: Option<u64>,
2032
2033 translation_per_reference_node_charge: Option<u64>,
2036
2037 translation_per_linkage_entry_charge: Option<u64>,
2040
2041 max_updates_per_settlement_txn: Option<u32>,
2043
2044 gasless_max_computation_units: Option<u64>,
2046
2047 gasless_allowed_token_types: Option<Vec<(String, u64)>>,
2049
2050 gasless_max_unused_inputs: Option<u64>,
2054
2055 gasless_max_pure_input_bytes: Option<u64>,
2058
2059 gasless_max_tps: Option<u64>,
2061
2062 #[serde(skip_serializing_if = "Option::is_none")]
2063 #[skip_accessor]
2064 include_special_package_amendments: Option<Arc<Amendments>>,
2065
2066 gasless_max_tx_size_bytes: Option<u64>,
2069}
2070
2071#[derive(Clone, Serialize, Deserialize, Debug)]
2073pub struct AliasedAddress {
2074 pub original: [u8; 32],
2076 pub aliased: [u8; 32],
2078 pub allowed_tx_digests: Vec<[u8; 32]>,
2080}
2081
2082impl ProtocolConfig {
2084 pub fn chain(&self) -> Chain {
2086 self.chain
2087 }
2088
2089 pub fn check_package_upgrades_supported(&self) -> Result<(), Error> {
2102 if self.feature_flags.package_upgrades {
2103 Ok(())
2104 } else {
2105 Err(Error(format!(
2106 "package upgrades are not supported at {:?}",
2107 self.version
2108 )))
2109 }
2110 }
2111
2112 pub fn zklogin_supported_providers(&self) -> &BTreeSet<String> {
2113 &self.feature_flags.zklogin_supported_providers
2114 }
2115
2116 pub fn consensus_transaction_ordering(&self) -> ConsensusTransactionOrdering {
2117 self.feature_flags.consensus_transaction_ordering
2118 }
2119
2120 pub fn enable_jwk_consensus_updates(&self) -> bool {
2121 let ret = self.feature_flags.enable_jwk_consensus_updates;
2122 if ret {
2123 assert!(self.feature_flags.end_of_epoch_transaction_supported);
2125 }
2126 ret
2127 }
2128
2129 pub fn end_of_epoch_transaction_supported(&self) -> bool {
2130 let ret = self.feature_flags.end_of_epoch_transaction_supported;
2131 if !ret {
2132 assert!(!self.feature_flags.enable_jwk_consensus_updates);
2134 }
2135 ret
2136 }
2137
2138 pub fn dkg_version(&self) -> u64 {
2139 self.random_beacon_dkg_version.unwrap_or(1)
2141 }
2142
2143 pub fn bridge(&self) -> bool {
2144 let ret = self.feature_flags.bridge;
2145 if ret {
2146 assert!(self.feature_flags.end_of_epoch_transaction_supported);
2148 }
2149 ret
2150 }
2151
2152 pub fn should_try_to_finalize_bridge_committee(&self) -> bool {
2153 if !self.bridge() {
2154 return false;
2155 }
2156 self.bridge_should_try_to_finalize_committee.unwrap_or(true)
2158 }
2159
2160 pub fn zklogin_max_epoch_upper_bound_delta(&self) -> Option<u64> {
2161 self.feature_flags.zklogin_max_epoch_upper_bound_delta
2162 }
2163
2164 pub fn enable_coin_reservation_obj_refs(&self) -> bool {
2165 self.new_vm_enabled() && self.feature_flags.enable_coin_reservation_obj_refs
2166 }
2167
2168 pub fn enable_authenticated_event_streams(&self) -> bool {
2169 self.feature_flags.enable_authenticated_event_streams && self.enable_accumulators()
2170 }
2171
2172 pub fn per_object_congestion_control_mode(&self) -> PerObjectCongestionControlMode {
2173 self.feature_flags.per_object_congestion_control_mode
2174 }
2175
2176 pub fn consensus_choice(&self) -> ConsensusChoice {
2177 self.feature_flags.consensus_choice
2178 }
2179
2180 pub fn consensus_network(&self) -> ConsensusNetwork {
2181 self.feature_flags.consensus_network
2182 }
2183
2184 pub fn mysticeti_num_leaders_per_round(&self) -> Option<usize> {
2185 self.feature_flags.mysticeti_num_leaders_per_round
2186 }
2187
2188 pub fn max_transaction_size_bytes(&self) -> u64 {
2189 self.consensus_max_transaction_size_bytes
2191 .unwrap_or(256 * 1024)
2192 }
2193
2194 pub fn max_transactions_in_block_bytes(&self) -> u64 {
2195 if cfg!(msim) {
2196 256 * 1024
2197 } else {
2198 self.consensus_max_transactions_in_block_bytes
2199 .unwrap_or(512 * 1024)
2200 }
2201 }
2202
2203 pub fn max_num_transactions_in_block(&self) -> u64 {
2204 if cfg!(msim) {
2205 8
2206 } else {
2207 self.consensus_max_num_transactions_in_block.unwrap_or(512)
2208 }
2209 }
2210
2211 pub fn gc_depth(&self) -> u32 {
2212 self.consensus_gc_depth.unwrap_or(0)
2213 }
2214
2215 pub fn consensus_linearize_subdag_v2(&self) -> bool {
2216 let res = self.feature_flags.consensus_linearize_subdag_v2;
2217 assert!(
2218 !res || self.gc_depth() > 0,
2219 "The consensus linearize sub dag V2 requires GC to be enabled"
2220 );
2221 res
2222 }
2223
2224 pub fn consensus_median_based_commit_timestamp(&self) -> bool {
2225 let res = self.feature_flags.consensus_median_based_commit_timestamp;
2226 assert!(
2227 !res || self.gc_depth() > 0,
2228 "The consensus median based commit timestamp requires GC to be enabled"
2229 );
2230 res
2231 }
2232
2233 pub fn get_consensus_commit_rate_estimation_window_size(&self) -> u32 {
2234 self.consensus_commit_rate_estimation_window_size
2235 .unwrap_or(0)
2236 }
2237
2238 pub fn consensus_num_requested_prior_commits_at_startup(&self) -> u32 {
2239 let window_size = self.get_consensus_commit_rate_estimation_window_size();
2243 assert!(window_size == 0 || self.record_additional_state_digest_in_prologue());
2245 window_size
2246 }
2247
2248 pub fn enable_observation_chunking(&self) -> bool {
2249 matches!(self.feature_flags.per_object_congestion_control_mode,
2250 PerObjectCongestionControlMode::ExecutionTimeEstimate(ref params)
2251 if params.observations_chunk_size.is_some()
2252 )
2253 }
2254
2255 pub fn address_aliases(&self) -> bool {
2256 let address_aliases = self.feature_flags.address_aliases;
2257 assert!(
2258 !address_aliases || self.mysticeti_fastpath(),
2259 "Address aliases requires Mysticeti fastpath to be enabled"
2260 );
2261 if address_aliases {
2262 assert!(
2263 self.feature_flags.disable_preconsensus_locking,
2264 "Address aliases requires CertifiedTransaction to be disabled"
2265 );
2266 }
2267 address_aliases
2268 }
2269
2270 pub fn new_vm_enabled(&self) -> bool {
2271 self.execution_version.is_some_and(|v| v >= 4)
2272 }
2273
2274 pub fn gasless_allowed_token_types(&self) -> &[(String, u64)] {
2275 debug_assert!(self.gasless_allowed_token_types.is_some());
2276 self.gasless_allowed_token_types.as_deref().unwrap_or(&[])
2277 }
2278
2279 pub fn get_gasless_max_unused_inputs(&self) -> u64 {
2280 self.gasless_max_unused_inputs.unwrap_or(u64::MAX)
2281 }
2282
2283 pub fn get_gasless_max_pure_input_bytes(&self) -> u64 {
2284 self.gasless_max_pure_input_bytes.unwrap_or(u64::MAX)
2285 }
2286
2287 pub fn get_gasless_max_tx_size_bytes(&self) -> u64 {
2288 self.gasless_max_tx_size_bytes.unwrap_or(u64::MAX)
2289 }
2290
2291 pub fn include_special_package_amendments_as_option(&self) -> &Option<Arc<Amendments>> {
2292 &self.include_special_package_amendments
2293 }
2294}
2295
2296#[cfg(not(msim))]
2297static POISON_VERSION_METHODS: AtomicBool = AtomicBool::new(false);
2298
2299#[cfg(msim)]
2301thread_local! {
2302 static POISON_VERSION_METHODS: AtomicBool = AtomicBool::new(false);
2303}
2304
2305impl ProtocolConfig {
2307 pub fn get_for_version(version: ProtocolVersion, chain: Chain) -> Self {
2309 assert!(
2311 version >= ProtocolVersion::MIN,
2312 "Network protocol version is {:?}, but the minimum supported version by the binary is {:?}. Please upgrade the binary.",
2313 version,
2314 ProtocolVersion::MIN.0,
2315 );
2316 assert!(
2317 version <= ProtocolVersion::MAX_ALLOWED,
2318 "Network protocol version is {:?}, but the maximum supported version by the binary is {:?}. Please upgrade the binary.",
2319 version,
2320 ProtocolVersion::MAX_ALLOWED.0,
2321 );
2322
2323 let mut ret = Self::get_for_version_impl(version, chain);
2324 ret.version = version;
2325 ret.chain = chain;
2326
2327 ret = Self::apply_config_override(version, ret);
2328
2329 if std::env::var("SUI_PROTOCOL_CONFIG_OVERRIDE_ENABLE").is_ok() {
2330 warn!(
2331 "overriding ProtocolConfig settings with custom settings; this may break non-local networks"
2332 );
2333 let overrides: ProtocolConfigOptional =
2334 serde_env::from_env_with_prefix("SUI_PROTOCOL_CONFIG_OVERRIDE")
2335 .expect("failed to parse ProtocolConfig override env variables");
2336 overrides.apply_to(&mut ret);
2337 }
2338
2339 ret
2340 }
2341
2342 pub fn get_for_version_if_supported(version: ProtocolVersion, chain: Chain) -> Option<Self> {
2345 if version.0 >= ProtocolVersion::MIN.0 && version.0 <= ProtocolVersion::MAX_ALLOWED.0 {
2346 let mut ret = Self::get_for_version_impl(version, chain);
2347 ret.version = version;
2348 ret.chain = chain;
2349 ret = Self::apply_config_override(version, ret);
2350 Some(ret)
2351 } else {
2352 None
2353 }
2354 }
2355
2356 #[cfg(not(msim))]
2357 pub fn poison_get_for_min_version() {
2358 POISON_VERSION_METHODS.store(true, Ordering::Relaxed);
2359 }
2360
2361 #[cfg(not(msim))]
2362 fn load_poison_get_for_min_version() -> bool {
2363 POISON_VERSION_METHODS.load(Ordering::Relaxed)
2364 }
2365
2366 #[cfg(msim)]
2367 pub fn poison_get_for_min_version() {
2368 POISON_VERSION_METHODS.with(|p| p.store(true, Ordering::Relaxed));
2369 }
2370
2371 #[cfg(msim)]
2372 fn load_poison_get_for_min_version() -> bool {
2373 POISON_VERSION_METHODS.with(|p| p.load(Ordering::Relaxed))
2374 }
2375
2376 pub fn get_for_min_version() -> Self {
2379 if Self::load_poison_get_for_min_version() {
2380 panic!("get_for_min_version called on validator");
2381 }
2382 ProtocolConfig::get_for_version(ProtocolVersion::MIN, Chain::Unknown)
2383 }
2384
2385 #[allow(non_snake_case)]
2395 pub fn get_for_max_version_UNSAFE() -> Self {
2396 if Self::load_poison_get_for_min_version() {
2397 panic!("get_for_max_version_UNSAFE called on validator");
2398 }
2399 ProtocolConfig::get_for_version(ProtocolVersion::MAX, Chain::Unknown)
2400 }
2401
2402 fn get_for_version_impl(version: ProtocolVersion, chain: Chain) -> Self {
2403 #[cfg(msim)]
2404 {
2405 if version == ProtocolVersion::MAX_ALLOWED {
2407 let mut config = Self::get_for_version_impl(version - 1, Chain::Unknown);
2408 config.base_tx_cost_fixed = Some(config.base_tx_cost_fixed() + 1000);
2409 return config;
2410 }
2411 }
2412
2413 let mut cfg = Self {
2416 version,
2418 chain,
2419
2420 feature_flags: Default::default(),
2422
2423 max_tx_size_bytes: Some(128 * 1024),
2424 max_input_objects: Some(2048),
2426 max_serialized_tx_effects_size_bytes: Some(512 * 1024),
2427 max_serialized_tx_effects_size_bytes_system_tx: Some(512 * 1024 * 16),
2428 max_gas_payment_objects: Some(256),
2429 max_modules_in_publish: Some(128),
2430 max_package_dependencies: None,
2431 max_arguments: Some(512),
2432 max_type_arguments: Some(16),
2433 max_type_argument_depth: Some(16),
2434 max_pure_argument_size: Some(16 * 1024),
2435 max_programmable_tx_commands: Some(1024),
2436 move_binary_format_version: Some(6),
2437 min_move_binary_format_version: None,
2438 binary_module_handles: None,
2439 binary_struct_handles: None,
2440 binary_function_handles: None,
2441 binary_function_instantiations: None,
2442 binary_signatures: None,
2443 binary_constant_pool: None,
2444 binary_identifiers: None,
2445 binary_address_identifiers: None,
2446 binary_struct_defs: None,
2447 binary_struct_def_instantiations: None,
2448 binary_function_defs: None,
2449 binary_field_handles: None,
2450 binary_field_instantiations: None,
2451 binary_friend_decls: None,
2452 binary_enum_defs: None,
2453 binary_enum_def_instantiations: None,
2454 binary_variant_handles: None,
2455 binary_variant_instantiation_handles: None,
2456 max_move_object_size: Some(250 * 1024),
2457 max_move_package_size: Some(100 * 1024),
2458 max_publish_or_upgrade_per_ptb: None,
2459 max_tx_gas: Some(10_000_000_000),
2460 max_gas_price: Some(100_000),
2461 max_gas_price_rgp_factor_for_aborted_transactions: None,
2462 max_gas_computation_bucket: Some(5_000_000),
2463 max_loop_depth: Some(5),
2464 max_generic_instantiation_length: Some(32),
2465 max_function_parameters: Some(128),
2466 max_basic_blocks: Some(1024),
2467 max_value_stack_size: Some(1024),
2468 max_type_nodes: Some(256),
2469 max_generic_instantiation_type_nodes_per_function: None,
2470 max_generic_instantiation_type_nodes_per_module: None,
2471 max_push_size: Some(10000),
2472 max_struct_definitions: Some(200),
2473 max_function_definitions: Some(1000),
2474 max_fields_in_struct: Some(32),
2475 max_dependency_depth: Some(100),
2476 max_num_event_emit: Some(256),
2477 max_num_new_move_object_ids: Some(2048),
2478 max_num_new_move_object_ids_system_tx: Some(2048 * 16),
2479 max_num_deleted_move_object_ids: Some(2048),
2480 max_num_deleted_move_object_ids_system_tx: Some(2048 * 16),
2481 max_num_transferred_move_object_ids: Some(2048),
2482 max_num_transferred_move_object_ids_system_tx: Some(2048 * 16),
2483 max_event_emit_size: Some(250 * 1024),
2484 max_move_vector_len: Some(256 * 1024),
2485 max_type_to_layout_nodes: None,
2486 max_ptb_value_size: None,
2487
2488 max_back_edges_per_function: Some(10_000),
2489 max_back_edges_per_module: Some(10_000),
2490 max_verifier_meter_ticks_per_function: Some(6_000_000),
2491 max_meter_ticks_per_module: Some(6_000_000),
2492 max_meter_ticks_per_package: None,
2493
2494 object_runtime_max_num_cached_objects: Some(1000),
2495 object_runtime_max_num_cached_objects_system_tx: Some(1000 * 16),
2496 object_runtime_max_num_store_entries: Some(1000),
2497 object_runtime_max_num_store_entries_system_tx: Some(1000 * 16),
2498 base_tx_cost_fixed: Some(110_000),
2499 package_publish_cost_fixed: Some(1_000),
2500 base_tx_cost_per_byte: Some(0),
2501 package_publish_cost_per_byte: Some(80),
2502 obj_access_cost_read_per_byte: Some(15),
2503 obj_access_cost_mutate_per_byte: Some(40),
2504 obj_access_cost_delete_per_byte: Some(40),
2505 obj_access_cost_verify_per_byte: Some(200),
2506 obj_data_cost_refundable: Some(100),
2507 obj_metadata_cost_non_refundable: Some(50),
2508 gas_model_version: Some(1),
2509 storage_rebate_rate: Some(9900),
2510 storage_fund_reinvest_rate: Some(500),
2511 reward_slashing_rate: Some(5000),
2512 storage_gas_price: Some(1),
2513 accumulator_object_storage_cost: None,
2514 max_transactions_per_checkpoint: Some(10_000),
2515 max_checkpoint_size_bytes: Some(30 * 1024 * 1024),
2516
2517 buffer_stake_for_protocol_upgrade_bps: Some(0),
2520
2521 address_from_bytes_cost_base: Some(52),
2525 address_to_u256_cost_base: Some(52),
2527 address_from_u256_cost_base: Some(52),
2529
2530 config_read_setting_impl_cost_base: None,
2533 config_read_setting_impl_cost_per_byte: None,
2534
2535 dynamic_field_hash_type_and_key_cost_base: Some(100),
2538 dynamic_field_hash_type_and_key_type_cost_per_byte: Some(2),
2539 dynamic_field_hash_type_and_key_value_cost_per_byte: Some(2),
2540 dynamic_field_hash_type_and_key_type_tag_cost_per_byte: Some(2),
2541 dynamic_field_add_child_object_cost_base: Some(100),
2543 dynamic_field_add_child_object_type_cost_per_byte: Some(10),
2544 dynamic_field_add_child_object_value_cost_per_byte: Some(10),
2545 dynamic_field_add_child_object_struct_tag_cost_per_byte: Some(10),
2546 dynamic_field_borrow_child_object_cost_base: Some(100),
2548 dynamic_field_borrow_child_object_child_ref_cost_per_byte: Some(10),
2549 dynamic_field_borrow_child_object_type_cost_per_byte: Some(10),
2550 dynamic_field_remove_child_object_cost_base: Some(100),
2552 dynamic_field_remove_child_object_child_cost_per_byte: Some(2),
2553 dynamic_field_remove_child_object_type_cost_per_byte: Some(2),
2554 dynamic_field_has_child_object_cost_base: Some(100),
2556 dynamic_field_has_child_object_with_ty_cost_base: Some(100),
2558 dynamic_field_has_child_object_with_ty_type_cost_per_byte: Some(2),
2559 dynamic_field_has_child_object_with_ty_type_tag_cost_per_byte: Some(2),
2560
2561 event_emit_cost_base: Some(52),
2564 event_emit_value_size_derivation_cost_per_byte: Some(2),
2565 event_emit_tag_size_derivation_cost_per_byte: Some(5),
2566 event_emit_output_cost_per_byte: Some(10),
2567 event_emit_auth_stream_cost: None,
2568
2569 object_borrow_uid_cost_base: Some(52),
2572 object_delete_impl_cost_base: Some(52),
2574 object_record_new_uid_cost_base: Some(52),
2576
2577 transfer_transfer_internal_cost_base: Some(52),
2580 transfer_party_transfer_internal_cost_base: None,
2582 transfer_freeze_object_cost_base: Some(52),
2584 transfer_share_object_cost_base: Some(52),
2586 transfer_receive_object_cost_base: None,
2587 transfer_receive_object_type_cost_per_byte: None,
2588 transfer_receive_object_cost_per_byte: None,
2589
2590 tx_context_derive_id_cost_base: Some(52),
2593 tx_context_fresh_id_cost_base: None,
2594 tx_context_sender_cost_base: None,
2595 tx_context_epoch_cost_base: None,
2596 tx_context_epoch_timestamp_ms_cost_base: None,
2597 tx_context_sponsor_cost_base: None,
2598 tx_context_rgp_cost_base: None,
2599 tx_context_gas_price_cost_base: None,
2600 tx_context_gas_budget_cost_base: None,
2601 tx_context_ids_created_cost_base: None,
2602 tx_context_replace_cost_base: None,
2603
2604 types_is_one_time_witness_cost_base: Some(52),
2607 types_is_one_time_witness_type_tag_cost_per_byte: Some(2),
2608 types_is_one_time_witness_type_cost_per_byte: Some(2),
2609
2610 validator_validate_metadata_cost_base: Some(52),
2613 validator_validate_metadata_data_cost_per_byte: Some(2),
2614
2615 crypto_invalid_arguments_cost: Some(100),
2617 bls12381_bls12381_min_sig_verify_cost_base: Some(52),
2619 bls12381_bls12381_min_sig_verify_msg_cost_per_byte: Some(2),
2620 bls12381_bls12381_min_sig_verify_msg_cost_per_block: Some(2),
2621
2622 bls12381_bls12381_min_pk_verify_cost_base: Some(52),
2624 bls12381_bls12381_min_pk_verify_msg_cost_per_byte: Some(2),
2625 bls12381_bls12381_min_pk_verify_msg_cost_per_block: Some(2),
2626
2627 ecdsa_k1_ecrecover_keccak256_cost_base: Some(52),
2629 ecdsa_k1_ecrecover_keccak256_msg_cost_per_byte: Some(2),
2630 ecdsa_k1_ecrecover_keccak256_msg_cost_per_block: Some(2),
2631 ecdsa_k1_ecrecover_sha256_cost_base: Some(52),
2632 ecdsa_k1_ecrecover_sha256_msg_cost_per_byte: Some(2),
2633 ecdsa_k1_ecrecover_sha256_msg_cost_per_block: Some(2),
2634
2635 ecdsa_k1_decompress_pubkey_cost_base: Some(52),
2637
2638 ecdsa_k1_secp256k1_verify_keccak256_cost_base: Some(52),
2640 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_byte: Some(2),
2641 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_block: Some(2),
2642 ecdsa_k1_secp256k1_verify_sha256_cost_base: Some(52),
2643 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_byte: Some(2),
2644 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_block: Some(2),
2645
2646 ecdsa_r1_ecrecover_keccak256_cost_base: Some(52),
2648 ecdsa_r1_ecrecover_keccak256_msg_cost_per_byte: Some(2),
2649 ecdsa_r1_ecrecover_keccak256_msg_cost_per_block: Some(2),
2650 ecdsa_r1_ecrecover_sha256_cost_base: Some(52),
2651 ecdsa_r1_ecrecover_sha256_msg_cost_per_byte: Some(2),
2652 ecdsa_r1_ecrecover_sha256_msg_cost_per_block: Some(2),
2653
2654 ecdsa_r1_secp256r1_verify_keccak256_cost_base: Some(52),
2656 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_byte: Some(2),
2657 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_block: Some(2),
2658 ecdsa_r1_secp256r1_verify_sha256_cost_base: Some(52),
2659 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_byte: Some(2),
2660 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_block: Some(2),
2661
2662 ecvrf_ecvrf_verify_cost_base: Some(52),
2664 ecvrf_ecvrf_verify_alpha_string_cost_per_byte: Some(2),
2665 ecvrf_ecvrf_verify_alpha_string_cost_per_block: Some(2),
2666
2667 ed25519_ed25519_verify_cost_base: Some(52),
2669 ed25519_ed25519_verify_msg_cost_per_byte: Some(2),
2670 ed25519_ed25519_verify_msg_cost_per_block: Some(2),
2671
2672 groth16_prepare_verifying_key_bls12381_cost_base: Some(52),
2674 groth16_prepare_verifying_key_bn254_cost_base: Some(52),
2675
2676 groth16_verify_groth16_proof_internal_bls12381_cost_base: Some(52),
2678 groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input: Some(2),
2679 groth16_verify_groth16_proof_internal_bn254_cost_base: Some(52),
2680 groth16_verify_groth16_proof_internal_bn254_cost_per_public_input: Some(2),
2681 groth16_verify_groth16_proof_internal_public_input_cost_per_byte: Some(2),
2682
2683 hash_blake2b256_cost_base: Some(52),
2685 hash_blake2b256_data_cost_per_byte: Some(2),
2686 hash_blake2b256_data_cost_per_block: Some(2),
2687
2688 hash_keccak256_cost_base: Some(52),
2690 hash_keccak256_data_cost_per_byte: Some(2),
2691 hash_keccak256_data_cost_per_block: Some(2),
2692
2693 poseidon_bn254_cost_base: None,
2694 poseidon_bn254_cost_per_block: None,
2695
2696 hmac_hmac_sha3_256_cost_base: Some(52),
2698 hmac_hmac_sha3_256_input_cost_per_byte: Some(2),
2699 hmac_hmac_sha3_256_input_cost_per_block: Some(2),
2700
2701 group_ops_bls12381_decode_scalar_cost: None,
2703 group_ops_bls12381_decode_g1_cost: None,
2704 group_ops_bls12381_decode_g2_cost: None,
2705 group_ops_bls12381_decode_gt_cost: None,
2706 group_ops_bls12381_scalar_add_cost: None,
2707 group_ops_bls12381_g1_add_cost: None,
2708 group_ops_bls12381_g2_add_cost: None,
2709 group_ops_bls12381_gt_add_cost: None,
2710 group_ops_bls12381_scalar_sub_cost: None,
2711 group_ops_bls12381_g1_sub_cost: None,
2712 group_ops_bls12381_g2_sub_cost: None,
2713 group_ops_bls12381_gt_sub_cost: None,
2714 group_ops_bls12381_scalar_mul_cost: None,
2715 group_ops_bls12381_g1_mul_cost: None,
2716 group_ops_bls12381_g2_mul_cost: None,
2717 group_ops_bls12381_gt_mul_cost: None,
2718 group_ops_bls12381_scalar_div_cost: None,
2719 group_ops_bls12381_g1_div_cost: None,
2720 group_ops_bls12381_g2_div_cost: None,
2721 group_ops_bls12381_gt_div_cost: None,
2722 group_ops_bls12381_g1_hash_to_base_cost: None,
2723 group_ops_bls12381_g2_hash_to_base_cost: None,
2724 group_ops_bls12381_g1_hash_to_cost_per_byte: None,
2725 group_ops_bls12381_g2_hash_to_cost_per_byte: None,
2726 group_ops_bls12381_g1_msm_base_cost: None,
2727 group_ops_bls12381_g2_msm_base_cost: None,
2728 group_ops_bls12381_g1_msm_base_cost_per_input: None,
2729 group_ops_bls12381_g2_msm_base_cost_per_input: None,
2730 group_ops_bls12381_msm_max_len: None,
2731 group_ops_bls12381_pairing_cost: None,
2732 group_ops_bls12381_g1_to_uncompressed_g1_cost: None,
2733 group_ops_bls12381_uncompressed_g1_to_g1_cost: None,
2734 group_ops_bls12381_uncompressed_g1_sum_base_cost: None,
2735 group_ops_bls12381_uncompressed_g1_sum_cost_per_term: None,
2736 group_ops_bls12381_uncompressed_g1_sum_max_terms: None,
2737
2738 group_ops_ristretto_decode_scalar_cost: None,
2739 group_ops_ristretto_decode_point_cost: None,
2740 group_ops_ristretto_scalar_add_cost: None,
2741 group_ops_ristretto_point_add_cost: None,
2742 group_ops_ristretto_scalar_sub_cost: None,
2743 group_ops_ristretto_point_sub_cost: None,
2744 group_ops_ristretto_scalar_mul_cost: None,
2745 group_ops_ristretto_point_mul_cost: None,
2746 group_ops_ristretto_scalar_div_cost: None,
2747 group_ops_ristretto_point_div_cost: None,
2748
2749 verify_bulletproofs_ristretto255_base_cost: None,
2750 verify_bulletproofs_ristretto255_cost_per_bit_and_commitment: None,
2751
2752 check_zklogin_id_cost_base: None,
2754 check_zklogin_issuer_cost_base: None,
2756
2757 vdf_verify_vdf_cost: None,
2758 vdf_hash_to_input_cost: None,
2759
2760 nitro_attestation_parse_base_cost: None,
2762 nitro_attestation_parse_cost_per_byte: None,
2763 nitro_attestation_verify_base_cost: None,
2764 nitro_attestation_verify_cost_per_cert: None,
2765
2766 bcs_per_byte_serialized_cost: None,
2767 bcs_legacy_min_output_size_cost: None,
2768 bcs_failure_cost: None,
2769 hash_sha2_256_base_cost: None,
2770 hash_sha2_256_per_byte_cost: None,
2771 hash_sha2_256_legacy_min_input_len_cost: None,
2772 hash_sha3_256_base_cost: None,
2773 hash_sha3_256_per_byte_cost: None,
2774 hash_sha3_256_legacy_min_input_len_cost: None,
2775 type_name_get_base_cost: None,
2776 type_name_get_per_byte_cost: None,
2777 type_name_id_base_cost: None,
2778 string_check_utf8_base_cost: None,
2779 string_check_utf8_per_byte_cost: None,
2780 string_is_char_boundary_base_cost: None,
2781 string_sub_string_base_cost: None,
2782 string_sub_string_per_byte_cost: None,
2783 string_index_of_base_cost: None,
2784 string_index_of_per_byte_pattern_cost: None,
2785 string_index_of_per_byte_searched_cost: None,
2786 vector_empty_base_cost: None,
2787 vector_length_base_cost: None,
2788 vector_push_back_base_cost: None,
2789 vector_push_back_legacy_per_abstract_memory_unit_cost: None,
2790 vector_borrow_base_cost: None,
2791 vector_pop_back_base_cost: None,
2792 vector_destroy_empty_base_cost: None,
2793 vector_swap_base_cost: None,
2794 debug_print_base_cost: None,
2795 debug_print_stack_trace_base_cost: None,
2796
2797 max_size_written_objects: None,
2798 max_size_written_objects_system_tx: None,
2799
2800 max_move_identifier_len: None,
2807 max_move_value_depth: None,
2808 max_move_enum_variants: None,
2809
2810 gas_rounding_step: None,
2811
2812 execution_version: None,
2813
2814 max_event_emit_size_total: None,
2815
2816 consensus_bad_nodes_stake_threshold: None,
2817
2818 max_jwk_votes_per_validator_per_epoch: None,
2819
2820 max_age_of_jwk_in_epochs: None,
2821
2822 random_beacon_reduction_allowed_delta: None,
2823
2824 random_beacon_reduction_lower_bound: None,
2825
2826 random_beacon_dkg_timeout_round: None,
2827
2828 random_beacon_min_round_interval_ms: None,
2829
2830 random_beacon_dkg_version: None,
2831
2832 consensus_max_transaction_size_bytes: None,
2833
2834 consensus_max_transactions_in_block_bytes: None,
2835
2836 consensus_max_num_transactions_in_block: None,
2837
2838 consensus_voting_rounds: None,
2839
2840 max_accumulated_txn_cost_per_object_in_narwhal_commit: None,
2841
2842 max_deferral_rounds_for_congestion_control: None,
2843
2844 max_txn_cost_overage_per_object_in_commit: None,
2845
2846 allowed_txn_cost_overage_burst_per_object_in_commit: None,
2847
2848 min_checkpoint_interval_ms: None,
2849
2850 checkpoint_summary_version_specific_data: None,
2851
2852 max_soft_bundle_size: None,
2853
2854 bridge_should_try_to_finalize_committee: None,
2855
2856 max_accumulated_txn_cost_per_object_in_mysticeti_commit: None,
2857
2858 max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit: None,
2859
2860 consensus_gc_depth: None,
2861
2862 gas_budget_based_txn_cost_cap_factor: None,
2863
2864 gas_budget_based_txn_cost_absolute_cap_commit_count: None,
2865
2866 sip_45_consensus_amplification_threshold: None,
2867
2868 use_object_per_epoch_marker_table_v2: None,
2869
2870 consensus_commit_rate_estimation_window_size: None,
2871
2872 aliased_addresses: vec![],
2873
2874 translation_per_command_base_charge: None,
2875 translation_per_input_base_charge: None,
2876 translation_pure_input_per_byte_charge: None,
2877 translation_per_type_node_charge: None,
2878 translation_per_reference_node_charge: None,
2879 translation_per_linkage_entry_charge: None,
2880
2881 max_updates_per_settlement_txn: None,
2882
2883 gasless_max_computation_units: None,
2884 gasless_allowed_token_types: None,
2885 gasless_max_unused_inputs: None,
2886 gasless_max_pure_input_bytes: None,
2887 gasless_max_tps: None,
2888 include_special_package_amendments: None,
2889 gasless_max_tx_size_bytes: None,
2890 };
2893 for cur in 2..=version.0 {
2894 match cur {
2895 1 => unreachable!(),
2896 2 => {
2897 cfg.feature_flags.advance_epoch_start_time_in_safe_mode = true;
2898 }
2899 3 => {
2900 cfg.gas_model_version = Some(2);
2902 cfg.max_tx_gas = Some(50_000_000_000);
2904 cfg.base_tx_cost_fixed = Some(2_000);
2906 cfg.storage_gas_price = Some(76);
2908 cfg.feature_flags.loaded_child_objects_fixed = true;
2909 cfg.max_size_written_objects = Some(5 * 1000 * 1000);
2912 cfg.max_size_written_objects_system_tx = Some(50 * 1000 * 1000);
2915 cfg.feature_flags.package_upgrades = true;
2916 }
2917 4 => {
2922 cfg.reward_slashing_rate = Some(10000);
2924 cfg.gas_model_version = Some(3);
2926 }
2927 5 => {
2928 cfg.feature_flags.missing_type_is_compatibility_error = true;
2929 cfg.gas_model_version = Some(4);
2930 cfg.feature_flags.scoring_decision_with_validity_cutoff = true;
2931 }
2935 6 => {
2936 cfg.gas_model_version = Some(5);
2937 cfg.buffer_stake_for_protocol_upgrade_bps = Some(5000);
2938 cfg.feature_flags.consensus_order_end_of_epoch_last = true;
2939 }
2940 7 => {
2941 cfg.feature_flags.disallow_adding_abilities_on_upgrade = true;
2942 cfg.feature_flags
2943 .disable_invariant_violation_check_in_swap_loc = true;
2944 cfg.feature_flags.ban_entry_init = true;
2945 cfg.feature_flags.package_digest_hash_module = true;
2946 }
2947 8 => {
2948 cfg.feature_flags
2949 .disallow_change_struct_type_params_on_upgrade = true;
2950 }
2951 9 => {
2952 cfg.max_move_identifier_len = Some(128);
2954 cfg.feature_flags.no_extraneous_module_bytes = true;
2955 cfg.feature_flags
2956 .advance_to_highest_supported_protocol_version = true;
2957 }
2958 10 => {
2959 cfg.max_verifier_meter_ticks_per_function = Some(16_000_000);
2960 cfg.max_meter_ticks_per_module = Some(16_000_000);
2961 }
2962 11 => {
2963 cfg.max_move_value_depth = Some(128);
2964 }
2965 12 => {
2966 cfg.feature_flags.narwhal_versioned_metadata = true;
2967 if chain != Chain::Mainnet {
2968 cfg.feature_flags.commit_root_state_digest = true;
2969 }
2970
2971 if chain != Chain::Mainnet && chain != Chain::Testnet {
2972 cfg.feature_flags.zklogin_auth = true;
2973 }
2974 }
2975 13 => {}
2976 14 => {
2977 cfg.gas_rounding_step = Some(1_000);
2978 cfg.gas_model_version = Some(6);
2979 }
2980 15 => {
2981 cfg.feature_flags.consensus_transaction_ordering =
2982 ConsensusTransactionOrdering::ByGasPrice;
2983 }
2984 16 => {
2985 cfg.feature_flags.simplified_unwrap_then_delete = true;
2986 }
2987 17 => {
2988 cfg.feature_flags.upgraded_multisig_supported = true;
2989 }
2990 18 => {
2991 cfg.execution_version = Some(1);
2992 cfg.feature_flags.txn_base_cost_as_multiplier = true;
3001 cfg.base_tx_cost_fixed = Some(1_000);
3003 }
3004 19 => {
3005 cfg.max_num_event_emit = Some(1024);
3006 cfg.max_event_emit_size_total = Some(
3009 256 * 250 * 1024, );
3011 }
3012 20 => {
3013 cfg.feature_flags.commit_root_state_digest = true;
3014
3015 if chain != Chain::Mainnet {
3016 cfg.feature_flags.narwhal_new_leader_election_schedule = true;
3017 cfg.consensus_bad_nodes_stake_threshold = Some(20);
3018 }
3019 }
3020
3021 21 => {
3022 if chain != Chain::Mainnet {
3023 cfg.feature_flags.zklogin_supported_providers = BTreeSet::from([
3024 "Google".to_string(),
3025 "Facebook".to_string(),
3026 "Twitch".to_string(),
3027 ]);
3028 }
3029 }
3030 22 => {
3031 cfg.feature_flags.loaded_child_object_format = true;
3032 }
3033 23 => {
3034 cfg.feature_flags.loaded_child_object_format_type = true;
3035 cfg.feature_flags.narwhal_new_leader_election_schedule = true;
3036 cfg.consensus_bad_nodes_stake_threshold = Some(20);
3042 }
3043 24 => {
3044 cfg.feature_flags.simple_conservation_checks = true;
3045 cfg.max_publish_or_upgrade_per_ptb = Some(5);
3046
3047 cfg.feature_flags.end_of_epoch_transaction_supported = true;
3048
3049 if chain != Chain::Mainnet {
3050 cfg.feature_flags.enable_jwk_consensus_updates = true;
3051 cfg.max_jwk_votes_per_validator_per_epoch = Some(240);
3053 cfg.max_age_of_jwk_in_epochs = Some(1);
3054 }
3055 }
3056 25 => {
3057 cfg.feature_flags.zklogin_supported_providers = BTreeSet::from([
3059 "Google".to_string(),
3060 "Facebook".to_string(),
3061 "Twitch".to_string(),
3062 ]);
3063 cfg.feature_flags.zklogin_auth = true;
3064
3065 cfg.feature_flags.enable_jwk_consensus_updates = true;
3067 cfg.max_jwk_votes_per_validator_per_epoch = Some(240);
3068 cfg.max_age_of_jwk_in_epochs = Some(1);
3069 }
3070 26 => {
3071 cfg.gas_model_version = Some(7);
3072 if chain != Chain::Mainnet && chain != Chain::Testnet {
3074 cfg.transfer_receive_object_cost_base = Some(52);
3075 cfg.feature_flags.receive_objects = true;
3076 }
3077 }
3078 27 => {
3079 cfg.gas_model_version = Some(8);
3080 }
3081 28 => {
3082 cfg.check_zklogin_id_cost_base = Some(200);
3084 cfg.check_zklogin_issuer_cost_base = Some(200);
3086
3087 if chain != Chain::Mainnet && chain != Chain::Testnet {
3089 cfg.feature_flags.enable_effects_v2 = true;
3090 }
3091 }
3092 29 => {
3093 cfg.feature_flags.verify_legacy_zklogin_address = true;
3094 }
3095 30 => {
3096 if chain != Chain::Mainnet {
3098 cfg.feature_flags.narwhal_certificate_v2 = true;
3099 }
3100
3101 cfg.random_beacon_reduction_allowed_delta = Some(800);
3102 if chain != Chain::Mainnet {
3104 cfg.feature_flags.enable_effects_v2 = true;
3105 }
3106
3107 cfg.feature_flags.zklogin_supported_providers = BTreeSet::default();
3111
3112 cfg.feature_flags.recompute_has_public_transfer_in_execution = true;
3113 }
3114 31 => {
3115 cfg.execution_version = Some(2);
3116 if chain != Chain::Mainnet && chain != Chain::Testnet {
3118 cfg.feature_flags.shared_object_deletion = true;
3119 }
3120 }
3121 32 => {
3122 if chain != Chain::Mainnet {
3124 cfg.feature_flags.accept_zklogin_in_multisig = true;
3125 }
3126 if chain != Chain::Mainnet {
3128 cfg.transfer_receive_object_cost_base = Some(52);
3129 cfg.feature_flags.receive_objects = true;
3130 }
3131 if chain != Chain::Mainnet && chain != Chain::Testnet {
3133 cfg.feature_flags.random_beacon = true;
3134 cfg.random_beacon_reduction_lower_bound = Some(1600);
3135 cfg.random_beacon_dkg_timeout_round = Some(3000);
3136 cfg.random_beacon_min_round_interval_ms = Some(150);
3137 }
3138 if chain != Chain::Testnet && chain != Chain::Mainnet {
3140 cfg.feature_flags.include_consensus_digest_in_prologue = true;
3141 }
3142
3143 cfg.feature_flags.narwhal_certificate_v2 = true;
3145 }
3146 33 => {
3147 cfg.feature_flags.hardened_otw_check = true;
3148 cfg.feature_flags.allow_receiving_object_id = true;
3149
3150 cfg.transfer_receive_object_cost_base = Some(52);
3152 cfg.feature_flags.receive_objects = true;
3153
3154 if chain != Chain::Mainnet {
3156 cfg.feature_flags.shared_object_deletion = true;
3157 }
3158
3159 cfg.feature_flags.enable_effects_v2 = true;
3160 }
3161 34 => {}
3162 35 => {
3163 if chain != Chain::Mainnet && chain != Chain::Testnet {
3165 cfg.feature_flags.enable_poseidon = true;
3166 cfg.poseidon_bn254_cost_base = Some(260);
3167 cfg.poseidon_bn254_cost_per_block = Some(10);
3168 }
3169
3170 cfg.feature_flags.enable_coin_deny_list = true;
3171 }
3172 36 => {
3173 if chain != Chain::Mainnet && chain != Chain::Testnet {
3175 cfg.feature_flags.enable_group_ops_native_functions = true;
3176 cfg.feature_flags.enable_group_ops_native_function_msm = true;
3177 cfg.group_ops_bls12381_decode_scalar_cost = Some(52);
3179 cfg.group_ops_bls12381_decode_g1_cost = Some(52);
3180 cfg.group_ops_bls12381_decode_g2_cost = Some(52);
3181 cfg.group_ops_bls12381_decode_gt_cost = Some(52);
3182 cfg.group_ops_bls12381_scalar_add_cost = Some(52);
3183 cfg.group_ops_bls12381_g1_add_cost = Some(52);
3184 cfg.group_ops_bls12381_g2_add_cost = Some(52);
3185 cfg.group_ops_bls12381_gt_add_cost = Some(52);
3186 cfg.group_ops_bls12381_scalar_sub_cost = Some(52);
3187 cfg.group_ops_bls12381_g1_sub_cost = Some(52);
3188 cfg.group_ops_bls12381_g2_sub_cost = Some(52);
3189 cfg.group_ops_bls12381_gt_sub_cost = Some(52);
3190 cfg.group_ops_bls12381_scalar_mul_cost = Some(52);
3191 cfg.group_ops_bls12381_g1_mul_cost = Some(52);
3192 cfg.group_ops_bls12381_g2_mul_cost = Some(52);
3193 cfg.group_ops_bls12381_gt_mul_cost = Some(52);
3194 cfg.group_ops_bls12381_scalar_div_cost = Some(52);
3195 cfg.group_ops_bls12381_g1_div_cost = Some(52);
3196 cfg.group_ops_bls12381_g2_div_cost = Some(52);
3197 cfg.group_ops_bls12381_gt_div_cost = Some(52);
3198 cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(52);
3199 cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(52);
3200 cfg.group_ops_bls12381_g1_hash_to_cost_per_byte = Some(2);
3201 cfg.group_ops_bls12381_g2_hash_to_cost_per_byte = Some(2);
3202 cfg.group_ops_bls12381_g1_msm_base_cost = Some(52);
3203 cfg.group_ops_bls12381_g2_msm_base_cost = Some(52);
3204 cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(52);
3205 cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(52);
3206 cfg.group_ops_bls12381_msm_max_len = Some(32);
3207 cfg.group_ops_bls12381_pairing_cost = Some(52);
3208 }
3209 cfg.feature_flags.shared_object_deletion = true;
3211
3212 cfg.consensus_max_transaction_size_bytes = Some(256 * 1024); cfg.consensus_max_transactions_in_block_bytes = Some(6 * 1_024 * 1024);
3214 }
3216 37 => {
3217 cfg.feature_flags.reject_mutable_random_on_entry_functions = true;
3218
3219 if chain != Chain::Mainnet {
3221 cfg.feature_flags.include_consensus_digest_in_prologue = true;
3222 }
3223 }
3224 38 => {
3225 cfg.binary_module_handles = Some(100);
3226 cfg.binary_struct_handles = Some(300);
3227 cfg.binary_function_handles = Some(1500);
3228 cfg.binary_function_instantiations = Some(750);
3229 cfg.binary_signatures = Some(1000);
3230 cfg.binary_constant_pool = Some(4000);
3234 cfg.binary_identifiers = Some(10000);
3235 cfg.binary_address_identifiers = Some(100);
3236 cfg.binary_struct_defs = Some(200);
3237 cfg.binary_struct_def_instantiations = Some(100);
3238 cfg.binary_function_defs = Some(1000);
3239 cfg.binary_field_handles = Some(500);
3240 cfg.binary_field_instantiations = Some(250);
3241 cfg.binary_friend_decls = Some(100);
3242 cfg.max_package_dependencies = Some(32);
3244 cfg.max_modules_in_publish = Some(64);
3245 cfg.execution_version = Some(3);
3247 }
3248 39 => {
3249 }
3251 40 => {}
3252 41 => {
3253 cfg.feature_flags.enable_group_ops_native_functions = true;
3255 cfg.group_ops_bls12381_decode_scalar_cost = Some(52);
3257 cfg.group_ops_bls12381_decode_g1_cost = Some(52);
3258 cfg.group_ops_bls12381_decode_g2_cost = Some(52);
3259 cfg.group_ops_bls12381_decode_gt_cost = Some(52);
3260 cfg.group_ops_bls12381_scalar_add_cost = Some(52);
3261 cfg.group_ops_bls12381_g1_add_cost = Some(52);
3262 cfg.group_ops_bls12381_g2_add_cost = Some(52);
3263 cfg.group_ops_bls12381_gt_add_cost = Some(52);
3264 cfg.group_ops_bls12381_scalar_sub_cost = Some(52);
3265 cfg.group_ops_bls12381_g1_sub_cost = Some(52);
3266 cfg.group_ops_bls12381_g2_sub_cost = Some(52);
3267 cfg.group_ops_bls12381_gt_sub_cost = Some(52);
3268 cfg.group_ops_bls12381_scalar_mul_cost = Some(52);
3269 cfg.group_ops_bls12381_g1_mul_cost = Some(52);
3270 cfg.group_ops_bls12381_g2_mul_cost = Some(52);
3271 cfg.group_ops_bls12381_gt_mul_cost = Some(52);
3272 cfg.group_ops_bls12381_scalar_div_cost = Some(52);
3273 cfg.group_ops_bls12381_g1_div_cost = Some(52);
3274 cfg.group_ops_bls12381_g2_div_cost = Some(52);
3275 cfg.group_ops_bls12381_gt_div_cost = Some(52);
3276 cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(52);
3277 cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(52);
3278 cfg.group_ops_bls12381_g1_hash_to_cost_per_byte = Some(2);
3279 cfg.group_ops_bls12381_g2_hash_to_cost_per_byte = Some(2);
3280 cfg.group_ops_bls12381_g1_msm_base_cost = Some(52);
3281 cfg.group_ops_bls12381_g2_msm_base_cost = Some(52);
3282 cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(52);
3283 cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(52);
3284 cfg.group_ops_bls12381_msm_max_len = Some(32);
3285 cfg.group_ops_bls12381_pairing_cost = Some(52);
3286 }
3287 42 => {}
3288 43 => {
3289 cfg.feature_flags.zklogin_max_epoch_upper_bound_delta = Some(30);
3290 cfg.max_meter_ticks_per_package = Some(16_000_000);
3291 }
3292 44 => {
3293 cfg.feature_flags.include_consensus_digest_in_prologue = true;
3295 if chain != Chain::Mainnet {
3297 cfg.feature_flags.consensus_choice = ConsensusChoice::SwapEachEpoch;
3298 }
3299 }
3300 45 => {
3301 if chain != Chain::Testnet && chain != Chain::Mainnet {
3303 cfg.feature_flags.consensus_network = ConsensusNetwork::Tonic;
3304 }
3305
3306 if chain != Chain::Mainnet {
3307 cfg.feature_flags.mysticeti_leader_scoring_and_schedule = true;
3309 }
3310 cfg.min_move_binary_format_version = Some(6);
3311 cfg.feature_flags.accept_zklogin_in_multisig = true;
3312
3313 if chain != Chain::Mainnet && chain != Chain::Testnet {
3317 cfg.feature_flags.bridge = true;
3318 }
3319 }
3320 46 => {
3321 if chain != Chain::Mainnet {
3323 cfg.feature_flags.bridge = true;
3324 }
3325
3326 cfg.feature_flags.reshare_at_same_initial_version = true;
3328 }
3329 47 => {}
3330 48 => {
3331 cfg.feature_flags.consensus_network = ConsensusNetwork::Tonic;
3333
3334 cfg.feature_flags.resolve_abort_locations_to_package_id = true;
3336
3337 if chain != Chain::Mainnet {
3339 cfg.feature_flags.random_beacon = true;
3340 cfg.random_beacon_reduction_lower_bound = Some(1600);
3341 cfg.random_beacon_dkg_timeout_round = Some(3000);
3342 cfg.random_beacon_min_round_interval_ms = Some(200);
3343 }
3344
3345 cfg.feature_flags.mysticeti_use_committed_subdag_digest = true;
3347 }
3348 49 => {
3349 if chain != Chain::Testnet && chain != Chain::Mainnet {
3350 cfg.move_binary_format_version = Some(7);
3351 }
3352
3353 if chain != Chain::Mainnet && chain != Chain::Testnet {
3355 cfg.feature_flags.enable_vdf = true;
3356 cfg.vdf_verify_vdf_cost = Some(1500);
3359 cfg.vdf_hash_to_input_cost = Some(100);
3360 }
3361
3362 if chain != Chain::Testnet && chain != Chain::Mainnet {
3364 cfg.feature_flags
3365 .record_consensus_determined_version_assignments_in_prologue = true;
3366 }
3367
3368 if chain != Chain::Mainnet {
3370 cfg.feature_flags.consensus_choice = ConsensusChoice::Mysticeti;
3371 }
3372
3373 cfg.feature_flags.fresh_vm_on_framework_upgrade = true;
3375 }
3376 50 => {
3377 if chain != Chain::Mainnet {
3379 cfg.checkpoint_summary_version_specific_data = Some(1);
3380 cfg.min_checkpoint_interval_ms = Some(200);
3381 }
3382
3383 if chain != Chain::Testnet && chain != Chain::Mainnet {
3385 cfg.feature_flags
3386 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = true;
3387 }
3388
3389 cfg.feature_flags.mysticeti_num_leaders_per_round = Some(1);
3390
3391 cfg.max_deferral_rounds_for_congestion_control = Some(10);
3393 }
3394 51 => {
3395 cfg.random_beacon_dkg_version = Some(1);
3396
3397 if chain != Chain::Testnet && chain != Chain::Mainnet {
3398 cfg.feature_flags.enable_coin_deny_list_v2 = true;
3399 }
3400 }
3401 52 => {
3402 if chain != Chain::Mainnet {
3403 cfg.feature_flags.soft_bundle = true;
3404 cfg.max_soft_bundle_size = Some(5);
3405 }
3406
3407 cfg.config_read_setting_impl_cost_base = Some(100);
3408 cfg.config_read_setting_impl_cost_per_byte = Some(40);
3409
3410 if chain != Chain::Testnet && chain != Chain::Mainnet {
3412 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(100);
3413 cfg.feature_flags.per_object_congestion_control_mode =
3414 PerObjectCongestionControlMode::TotalTxCount;
3415 }
3416
3417 cfg.feature_flags.consensus_choice = ConsensusChoice::Mysticeti;
3419
3420 cfg.feature_flags.mysticeti_leader_scoring_and_schedule = true;
3422
3423 cfg.checkpoint_summary_version_specific_data = Some(1);
3425 cfg.min_checkpoint_interval_ms = Some(200);
3426
3427 if chain != Chain::Mainnet {
3429 cfg.feature_flags
3430 .record_consensus_determined_version_assignments_in_prologue = true;
3431 cfg.feature_flags
3432 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = true;
3433 }
3434 if chain != Chain::Mainnet {
3436 cfg.move_binary_format_version = Some(7);
3437 }
3438
3439 if chain != Chain::Testnet && chain != Chain::Mainnet {
3440 cfg.feature_flags.passkey_auth = true;
3441 }
3442 cfg.feature_flags.enable_coin_deny_list_v2 = true;
3443 }
3444 53 => {
3445 cfg.bridge_should_try_to_finalize_committee = Some(chain != Chain::Mainnet);
3447
3448 cfg.feature_flags
3450 .record_consensus_determined_version_assignments_in_prologue = true;
3451 cfg.feature_flags
3452 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = true;
3453
3454 if chain == Chain::Unknown {
3455 cfg.feature_flags.authority_capabilities_v2 = true;
3456 }
3457
3458 if chain != Chain::Mainnet {
3460 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(100);
3461 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(10);
3462 cfg.feature_flags.per_object_congestion_control_mode =
3463 PerObjectCongestionControlMode::TotalTxCount;
3464 }
3465
3466 cfg.bcs_per_byte_serialized_cost = Some(2);
3468 cfg.bcs_legacy_min_output_size_cost = Some(1);
3469 cfg.bcs_failure_cost = Some(52);
3470 cfg.debug_print_base_cost = Some(52);
3471 cfg.debug_print_stack_trace_base_cost = Some(52);
3472 cfg.hash_sha2_256_base_cost = Some(52);
3473 cfg.hash_sha2_256_per_byte_cost = Some(2);
3474 cfg.hash_sha2_256_legacy_min_input_len_cost = Some(1);
3475 cfg.hash_sha3_256_base_cost = Some(52);
3476 cfg.hash_sha3_256_per_byte_cost = Some(2);
3477 cfg.hash_sha3_256_legacy_min_input_len_cost = Some(1);
3478 cfg.type_name_get_base_cost = Some(52);
3479 cfg.type_name_get_per_byte_cost = Some(2);
3480 cfg.string_check_utf8_base_cost = Some(52);
3481 cfg.string_check_utf8_per_byte_cost = Some(2);
3482 cfg.string_is_char_boundary_base_cost = Some(52);
3483 cfg.string_sub_string_base_cost = Some(52);
3484 cfg.string_sub_string_per_byte_cost = Some(2);
3485 cfg.string_index_of_base_cost = Some(52);
3486 cfg.string_index_of_per_byte_pattern_cost = Some(2);
3487 cfg.string_index_of_per_byte_searched_cost = Some(2);
3488 cfg.vector_empty_base_cost = Some(52);
3489 cfg.vector_length_base_cost = Some(52);
3490 cfg.vector_push_back_base_cost = Some(52);
3491 cfg.vector_push_back_legacy_per_abstract_memory_unit_cost = Some(2);
3492 cfg.vector_borrow_base_cost = Some(52);
3493 cfg.vector_pop_back_base_cost = Some(52);
3494 cfg.vector_destroy_empty_base_cost = Some(52);
3495 cfg.vector_swap_base_cost = Some(52);
3496 }
3497 54 => {
3498 cfg.feature_flags.random_beacon = true;
3500 cfg.random_beacon_reduction_lower_bound = Some(1000);
3501 cfg.random_beacon_dkg_timeout_round = Some(3000);
3502 cfg.random_beacon_min_round_interval_ms = Some(500);
3503
3504 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(100);
3506 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(10);
3507 cfg.feature_flags.per_object_congestion_control_mode =
3508 PerObjectCongestionControlMode::TotalTxCount;
3509
3510 cfg.feature_flags.soft_bundle = true;
3512 cfg.max_soft_bundle_size = Some(5);
3513 }
3514 55 => {
3515 cfg.move_binary_format_version = Some(7);
3517
3518 cfg.consensus_max_transactions_in_block_bytes = Some(512 * 1024);
3520 cfg.consensus_max_num_transactions_in_block = Some(512);
3523
3524 cfg.feature_flags.rethrow_serialization_type_layout_errors = true;
3525 }
3526 56 => {
3527 if chain == Chain::Mainnet {
3528 cfg.feature_flags.bridge = true;
3529 }
3530 }
3531 57 => {
3532 cfg.random_beacon_reduction_lower_bound = Some(800);
3534 }
3535 58 => {
3536 if chain == Chain::Mainnet {
3537 cfg.bridge_should_try_to_finalize_committee = Some(true);
3538 }
3539
3540 if chain != Chain::Mainnet && chain != Chain::Testnet {
3541 cfg.feature_flags
3543 .consensus_distributed_vote_scoring_strategy = true;
3544 }
3545 }
3546 59 => {
3547 cfg.feature_flags.consensus_round_prober = true;
3549 }
3550 60 => {
3551 cfg.max_type_to_layout_nodes = Some(512);
3552 cfg.feature_flags.validate_identifier_inputs = true;
3553 }
3554 61 => {
3555 if chain != Chain::Mainnet {
3556 cfg.feature_flags
3558 .consensus_distributed_vote_scoring_strategy = true;
3559 }
3560 cfg.random_beacon_reduction_lower_bound = Some(700);
3562
3563 if chain != Chain::Mainnet && chain != Chain::Testnet {
3564 cfg.feature_flags.mysticeti_fastpath = true;
3566 }
3567 }
3568 62 => {
3569 cfg.feature_flags.relocate_event_module = true;
3570 }
3571 63 => {
3572 cfg.feature_flags.per_object_congestion_control_mode =
3573 PerObjectCongestionControlMode::TotalGasBudgetWithCap;
3574 cfg.gas_budget_based_txn_cost_cap_factor = Some(400_000);
3575 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(18_500_000);
3576 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(240_000_000);
3577 }
3578 64 => {
3579 cfg.feature_flags.per_object_congestion_control_mode =
3580 PerObjectCongestionControlMode::TotalTxCount;
3581 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(40);
3582 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(3);
3583 }
3584 65 => {
3585 cfg.feature_flags
3587 .consensus_distributed_vote_scoring_strategy = true;
3588 }
3589 66 => {
3590 if chain == Chain::Mainnet {
3591 cfg.feature_flags
3593 .consensus_distributed_vote_scoring_strategy = false;
3594 }
3595 }
3596 67 => {
3597 cfg.feature_flags
3599 .consensus_distributed_vote_scoring_strategy = true;
3600 }
3601 68 => {
3602 cfg.group_ops_bls12381_g1_to_uncompressed_g1_cost = Some(26);
3603 cfg.group_ops_bls12381_uncompressed_g1_to_g1_cost = Some(52);
3604 cfg.group_ops_bls12381_uncompressed_g1_sum_base_cost = Some(26);
3605 cfg.group_ops_bls12381_uncompressed_g1_sum_cost_per_term = Some(13);
3606 cfg.group_ops_bls12381_uncompressed_g1_sum_max_terms = Some(2000);
3607
3608 if chain != Chain::Mainnet && chain != Chain::Testnet {
3609 cfg.feature_flags.uncompressed_g1_group_elements = true;
3610 }
3611
3612 cfg.feature_flags.per_object_congestion_control_mode =
3613 PerObjectCongestionControlMode::TotalGasBudgetWithCap;
3614 cfg.gas_budget_based_txn_cost_cap_factor = Some(400_000);
3615 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(18_500_000);
3616 cfg.max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit =
3617 Some(3_700_000); cfg.max_txn_cost_overage_per_object_in_commit = Some(u64::MAX);
3619 cfg.gas_budget_based_txn_cost_absolute_cap_commit_count = Some(50);
3620
3621 cfg.random_beacon_reduction_lower_bound = Some(500);
3623
3624 cfg.feature_flags.disallow_new_modules_in_deps_only_packages = true;
3625 }
3626 69 => {
3627 cfg.consensus_voting_rounds = Some(40);
3629
3630 if chain != Chain::Mainnet && chain != Chain::Testnet {
3631 cfg.feature_flags.consensus_smart_ancestor_selection = true;
3633 }
3634
3635 if chain != Chain::Mainnet {
3636 cfg.feature_flags.uncompressed_g1_group_elements = true;
3637 }
3638 }
3639 70 => {
3640 if chain != Chain::Mainnet {
3641 cfg.feature_flags.consensus_smart_ancestor_selection = true;
3643 cfg.feature_flags
3645 .consensus_round_prober_probe_accepted_rounds = true;
3646 }
3647
3648 cfg.poseidon_bn254_cost_per_block = Some(388);
3649
3650 cfg.gas_model_version = Some(9);
3651 cfg.feature_flags.native_charging_v2 = true;
3652 cfg.bls12381_bls12381_min_sig_verify_cost_base = Some(44064);
3653 cfg.bls12381_bls12381_min_pk_verify_cost_base = Some(49282);
3654 cfg.ecdsa_k1_secp256k1_verify_keccak256_cost_base = Some(1470);
3655 cfg.ecdsa_k1_secp256k1_verify_sha256_cost_base = Some(1470);
3656 cfg.ecdsa_r1_secp256r1_verify_sha256_cost_base = Some(4225);
3657 cfg.ecdsa_r1_secp256r1_verify_keccak256_cost_base = Some(4225);
3658 cfg.ecvrf_ecvrf_verify_cost_base = Some(4848);
3659 cfg.ed25519_ed25519_verify_cost_base = Some(1802);
3660
3661 cfg.ecdsa_r1_ecrecover_keccak256_cost_base = Some(1173);
3663 cfg.ecdsa_r1_ecrecover_sha256_cost_base = Some(1173);
3664 cfg.ecdsa_k1_ecrecover_keccak256_cost_base = Some(500);
3665 cfg.ecdsa_k1_ecrecover_sha256_cost_base = Some(500);
3666
3667 cfg.groth16_prepare_verifying_key_bls12381_cost_base = Some(53838);
3668 cfg.groth16_prepare_verifying_key_bn254_cost_base = Some(82010);
3669 cfg.groth16_verify_groth16_proof_internal_bls12381_cost_base = Some(72090);
3670 cfg.groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input =
3671 Some(8213);
3672 cfg.groth16_verify_groth16_proof_internal_bn254_cost_base = Some(115502);
3673 cfg.groth16_verify_groth16_proof_internal_bn254_cost_per_public_input =
3674 Some(9484);
3675
3676 cfg.hash_keccak256_cost_base = Some(10);
3677 cfg.hash_blake2b256_cost_base = Some(10);
3678
3679 cfg.group_ops_bls12381_decode_scalar_cost = Some(7);
3681 cfg.group_ops_bls12381_decode_g1_cost = Some(2848);
3682 cfg.group_ops_bls12381_decode_g2_cost = Some(3770);
3683 cfg.group_ops_bls12381_decode_gt_cost = Some(3068);
3684
3685 cfg.group_ops_bls12381_scalar_add_cost = Some(10);
3686 cfg.group_ops_bls12381_g1_add_cost = Some(1556);
3687 cfg.group_ops_bls12381_g2_add_cost = Some(3048);
3688 cfg.group_ops_bls12381_gt_add_cost = Some(188);
3689
3690 cfg.group_ops_bls12381_scalar_sub_cost = Some(10);
3691 cfg.group_ops_bls12381_g1_sub_cost = Some(1550);
3692 cfg.group_ops_bls12381_g2_sub_cost = Some(3019);
3693 cfg.group_ops_bls12381_gt_sub_cost = Some(497);
3694
3695 cfg.group_ops_bls12381_scalar_mul_cost = Some(11);
3696 cfg.group_ops_bls12381_g1_mul_cost = Some(4842);
3697 cfg.group_ops_bls12381_g2_mul_cost = Some(9108);
3698 cfg.group_ops_bls12381_gt_mul_cost = Some(27490);
3699
3700 cfg.group_ops_bls12381_scalar_div_cost = Some(91);
3701 cfg.group_ops_bls12381_g1_div_cost = Some(5091);
3702 cfg.group_ops_bls12381_g2_div_cost = Some(9206);
3703 cfg.group_ops_bls12381_gt_div_cost = Some(27804);
3704
3705 cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(2962);
3706 cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(8688);
3707
3708 cfg.group_ops_bls12381_g1_msm_base_cost = Some(62648);
3709 cfg.group_ops_bls12381_g2_msm_base_cost = Some(131192);
3710 cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(1333);
3711 cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(3216);
3712
3713 cfg.group_ops_bls12381_uncompressed_g1_to_g1_cost = Some(677);
3714 cfg.group_ops_bls12381_g1_to_uncompressed_g1_cost = Some(2099);
3715 cfg.group_ops_bls12381_uncompressed_g1_sum_base_cost = Some(77);
3716 cfg.group_ops_bls12381_uncompressed_g1_sum_cost_per_term = Some(26);
3717
3718 cfg.group_ops_bls12381_pairing_cost = Some(26897);
3719 cfg.group_ops_bls12381_uncompressed_g1_sum_max_terms = Some(1200);
3720
3721 cfg.validator_validate_metadata_cost_base = Some(20000);
3722 }
3723 71 => {
3724 cfg.sip_45_consensus_amplification_threshold = Some(5);
3725
3726 cfg.allowed_txn_cost_overage_burst_per_object_in_commit = Some(185_000_000);
3728 }
3729 72 => {
3730 cfg.feature_flags.convert_type_argument_error = true;
3731
3732 cfg.max_tx_gas = Some(50_000_000_000_000);
3735 cfg.max_gas_price = Some(50_000_000_000);
3737
3738 cfg.feature_flags.variant_nodes = true;
3739 }
3740 73 => {
3741 cfg.use_object_per_epoch_marker_table_v2 = Some(true);
3743
3744 if chain != Chain::Mainnet && chain != Chain::Testnet {
3745 cfg.consensus_gc_depth = Some(60);
3748 }
3749
3750 if chain != Chain::Mainnet {
3751 cfg.feature_flags.consensus_zstd_compression = true;
3753 }
3754
3755 cfg.feature_flags.consensus_smart_ancestor_selection = true;
3757 cfg.feature_flags
3759 .consensus_round_prober_probe_accepted_rounds = true;
3760
3761 cfg.feature_flags.per_object_congestion_control_mode =
3763 PerObjectCongestionControlMode::TotalGasBudgetWithCap;
3764 cfg.gas_budget_based_txn_cost_cap_factor = Some(400_000);
3765 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(37_000_000);
3766 cfg.max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit =
3767 Some(7_400_000); cfg.max_txn_cost_overage_per_object_in_commit = Some(u64::MAX);
3769 cfg.gas_budget_based_txn_cost_absolute_cap_commit_count = Some(50);
3770 cfg.allowed_txn_cost_overage_burst_per_object_in_commit = Some(370_000_000);
3771 }
3772 74 => {
3773 if chain != Chain::Mainnet && chain != Chain::Testnet {
3775 cfg.feature_flags.enable_nitro_attestation = true;
3776 }
3777 cfg.nitro_attestation_parse_base_cost = Some(53 * 50);
3778 cfg.nitro_attestation_parse_cost_per_byte = Some(50);
3779 cfg.nitro_attestation_verify_base_cost = Some(49632 * 50);
3780 cfg.nitro_attestation_verify_cost_per_cert = Some(52369 * 50);
3781
3782 cfg.feature_flags.consensus_zstd_compression = true;
3784
3785 if chain != Chain::Mainnet && chain != Chain::Testnet {
3786 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
3787 }
3788 }
3789 75 => {
3790 if chain != Chain::Mainnet {
3791 cfg.feature_flags.passkey_auth = true;
3792 }
3793 }
3794 76 => {
3795 if chain != Chain::Mainnet && chain != Chain::Testnet {
3796 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
3797 cfg.consensus_commit_rate_estimation_window_size = Some(10);
3798 }
3799 cfg.feature_flags.minimize_child_object_mutations = true;
3800
3801 if chain != Chain::Mainnet {
3802 cfg.feature_flags.accept_passkey_in_multisig = true;
3803 }
3804 }
3805 77 => {
3806 cfg.feature_flags.uncompressed_g1_group_elements = true;
3807
3808 if chain != Chain::Mainnet {
3809 cfg.consensus_gc_depth = Some(60);
3810 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
3811 }
3812 }
3813 78 => {
3814 cfg.feature_flags.move_native_context = true;
3815 cfg.tx_context_fresh_id_cost_base = Some(52);
3816 cfg.tx_context_sender_cost_base = Some(30);
3817 cfg.tx_context_epoch_cost_base = Some(30);
3818 cfg.tx_context_epoch_timestamp_ms_cost_base = Some(30);
3819 cfg.tx_context_sponsor_cost_base = Some(30);
3820 cfg.tx_context_gas_price_cost_base = Some(30);
3821 cfg.tx_context_gas_budget_cost_base = Some(30);
3822 cfg.tx_context_ids_created_cost_base = Some(30);
3823 cfg.tx_context_replace_cost_base = Some(30);
3824 cfg.gas_model_version = Some(10);
3825
3826 if chain != Chain::Mainnet {
3827 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
3828 cfg.consensus_commit_rate_estimation_window_size = Some(10);
3829
3830 cfg.feature_flags.per_object_congestion_control_mode =
3832 PerObjectCongestionControlMode::ExecutionTimeEstimate(
3833 ExecutionTimeEstimateParams {
3834 target_utilization: 30,
3835 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
3837 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
3839 stored_observations_limit: u64::MAX,
3840 stake_weighted_median_threshold: 0,
3841 default_none_duration_for_new_keys: false,
3842 observations_chunk_size: None,
3843 },
3844 );
3845 }
3846 }
3847 79 => {
3848 if chain != Chain::Mainnet {
3849 cfg.feature_flags.consensus_median_based_commit_timestamp = true;
3850
3851 cfg.consensus_bad_nodes_stake_threshold = Some(30);
3854
3855 cfg.feature_flags.consensus_batched_block_sync = true;
3856
3857 cfg.feature_flags.enable_nitro_attestation = true
3859 }
3860 cfg.feature_flags.normalize_ptb_arguments = true;
3861
3862 cfg.consensus_gc_depth = Some(60);
3863 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
3864 }
3865 80 => {
3866 cfg.max_ptb_value_size = Some(1024 * 1024);
3867 }
3868 81 => {
3869 cfg.feature_flags.consensus_median_based_commit_timestamp = true;
3870 cfg.feature_flags.enforce_checkpoint_timestamp_monotonicity = true;
3871 cfg.consensus_bad_nodes_stake_threshold = Some(30)
3872 }
3873 82 => {
3874 cfg.feature_flags.max_ptb_value_size_v2 = true;
3875 }
3876 83 => {
3877 if chain == Chain::Mainnet {
3878 let aliased: [u8; 32] = Hex::decode(
3880 "0x0b2da327ba6a4cacbe75dddd50e6e8bbf81d6496e92d66af9154c61c77f7332f",
3881 )
3882 .unwrap()
3883 .try_into()
3884 .unwrap();
3885
3886 cfg.aliased_addresses.push(AliasedAddress {
3888 original: Hex::decode("0xcd8962dad278d8b50fa0f9eb0186bfa4cbdecc6d59377214c88d0286a0ac9562").unwrap().try_into().unwrap(),
3889 aliased,
3890 allowed_tx_digests: vec![
3891 Base58::decode("B2eGLFoMHgj93Ni8dAJBfqGzo8EWSTLBesZzhEpTPA4").unwrap().try_into().unwrap(),
3892 ],
3893 });
3894
3895 cfg.aliased_addresses.push(AliasedAddress {
3896 original: Hex::decode("0xe28b50cef1d633ea43d3296a3f6b67ff0312a5f1a99f0af753c85b8b5de8ff06").unwrap().try_into().unwrap(),
3897 aliased,
3898 allowed_tx_digests: vec![
3899 Base58::decode("J4QqSAgp7VrQtQpMy5wDX4QGsCSEZu3U5KuDAkbESAge").unwrap().try_into().unwrap(),
3900 ],
3901 });
3902 }
3903
3904 if chain != Chain::Mainnet {
3907 cfg.feature_flags.resolve_type_input_ids_to_defining_id = true;
3908 cfg.transfer_party_transfer_internal_cost_base = Some(52);
3909
3910 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
3912 cfg.consensus_commit_rate_estimation_window_size = Some(10);
3913 cfg.feature_flags.per_object_congestion_control_mode =
3914 PerObjectCongestionControlMode::ExecutionTimeEstimate(
3915 ExecutionTimeEstimateParams {
3916 target_utilization: 30,
3917 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
3919 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
3921 stored_observations_limit: u64::MAX,
3922 stake_weighted_median_threshold: 0,
3923 default_none_duration_for_new_keys: false,
3924 observations_chunk_size: None,
3925 },
3926 );
3927
3928 cfg.feature_flags.consensus_batched_block_sync = true;
3930
3931 cfg.feature_flags.enable_nitro_attestation_upgraded_parsing = true;
3934 cfg.feature_flags.enable_nitro_attestation = true;
3935 }
3936 }
3937 84 => {
3938 if chain == Chain::Mainnet {
3939 cfg.feature_flags.resolve_type_input_ids_to_defining_id = true;
3940 cfg.transfer_party_transfer_internal_cost_base = Some(52);
3941
3942 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
3944 cfg.consensus_commit_rate_estimation_window_size = Some(10);
3945 cfg.feature_flags.per_object_congestion_control_mode =
3946 PerObjectCongestionControlMode::ExecutionTimeEstimate(
3947 ExecutionTimeEstimateParams {
3948 target_utilization: 30,
3949 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
3951 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
3953 stored_observations_limit: u64::MAX,
3954 stake_weighted_median_threshold: 0,
3955 default_none_duration_for_new_keys: false,
3956 observations_chunk_size: None,
3957 },
3958 );
3959
3960 cfg.feature_flags.consensus_batched_block_sync = true;
3962
3963 cfg.feature_flags.enable_nitro_attestation_upgraded_parsing = true;
3966 cfg.feature_flags.enable_nitro_attestation = true;
3967 }
3968
3969 cfg.feature_flags.per_object_congestion_control_mode =
3971 PerObjectCongestionControlMode::ExecutionTimeEstimate(
3972 ExecutionTimeEstimateParams {
3973 target_utilization: 30,
3974 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
3976 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
3978 stored_observations_limit: 20,
3979 stake_weighted_median_threshold: 0,
3980 default_none_duration_for_new_keys: false,
3981 observations_chunk_size: None,
3982 },
3983 );
3984 cfg.feature_flags.allow_unbounded_system_objects = true;
3985 }
3986 85 => {
3987 if chain != Chain::Mainnet && chain != Chain::Testnet {
3988 cfg.feature_flags.enable_party_transfer = true;
3989 }
3990
3991 cfg.feature_flags
3992 .record_consensus_determined_version_assignments_in_prologue_v2 = true;
3993 cfg.feature_flags.disallow_self_identifier = true;
3994 cfg.feature_flags.per_object_congestion_control_mode =
3995 PerObjectCongestionControlMode::ExecutionTimeEstimate(
3996 ExecutionTimeEstimateParams {
3997 target_utilization: 50,
3998 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4000 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4002 stored_observations_limit: 20,
4003 stake_weighted_median_threshold: 0,
4004 default_none_duration_for_new_keys: false,
4005 observations_chunk_size: None,
4006 },
4007 );
4008 }
4009 86 => {
4010 cfg.feature_flags.type_tags_in_object_runtime = true;
4011 cfg.max_move_enum_variants = Some(move_core_types::VARIANT_COUNT_MAX);
4012
4013 cfg.feature_flags.per_object_congestion_control_mode =
4015 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4016 ExecutionTimeEstimateParams {
4017 target_utilization: 50,
4018 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4020 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4022 stored_observations_limit: 20,
4023 stake_weighted_median_threshold: 3334,
4024 default_none_duration_for_new_keys: false,
4025 observations_chunk_size: None,
4026 },
4027 );
4028 if chain != Chain::Mainnet {
4030 cfg.feature_flags.enable_party_transfer = true;
4031 }
4032 }
4033 87 => {
4034 if chain == Chain::Mainnet {
4035 cfg.feature_flags.record_time_estimate_processed = true;
4036 }
4037 cfg.feature_flags.better_adapter_type_resolution_errors = true;
4038 }
4039 88 => {
4040 cfg.feature_flags.record_time_estimate_processed = true;
4041 cfg.tx_context_rgp_cost_base = Some(30);
4042 cfg.feature_flags
4043 .ignore_execution_time_observations_after_certs_closed = true;
4044
4045 cfg.feature_flags.per_object_congestion_control_mode =
4048 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4049 ExecutionTimeEstimateParams {
4050 target_utilization: 50,
4051 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4053 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4055 stored_observations_limit: 20,
4056 stake_weighted_median_threshold: 3334,
4057 default_none_duration_for_new_keys: true,
4058 observations_chunk_size: None,
4059 },
4060 );
4061 }
4062 89 => {
4063 cfg.feature_flags.dependency_linkage_error = true;
4064 cfg.feature_flags.additional_multisig_checks = true;
4065 }
4066 90 => {
4067 cfg.max_gas_price_rgp_factor_for_aborted_transactions = Some(100);
4069 cfg.feature_flags.debug_fatal_on_move_invariant_violation = true;
4070 cfg.feature_flags.additional_consensus_digest_indirect_state = true;
4071 cfg.feature_flags.accept_passkey_in_multisig = true;
4072 cfg.feature_flags.passkey_auth = true;
4073 cfg.feature_flags.check_for_init_during_upgrade = true;
4074
4075 if chain != Chain::Mainnet {
4077 cfg.feature_flags.mysticeti_fastpath = true;
4078 }
4079 }
4080 91 => {
4081 cfg.feature_flags.per_command_shared_object_transfer_rules = true;
4082 }
4083 92 => {
4084 cfg.feature_flags.per_command_shared_object_transfer_rules = false;
4085 }
4086 93 => {
4087 cfg.feature_flags
4088 .consensus_checkpoint_signature_key_includes_digest = true;
4089 }
4090 94 => {
4091 cfg.feature_flags.per_object_congestion_control_mode =
4093 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4094 ExecutionTimeEstimateParams {
4095 target_utilization: 50,
4096 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4098 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4100 stored_observations_limit: 18,
4101 stake_weighted_median_threshold: 3334,
4102 default_none_duration_for_new_keys: true,
4103 observations_chunk_size: None,
4104 },
4105 );
4106
4107 cfg.feature_flags.enable_party_transfer = true;
4109 }
4110 95 => {
4111 cfg.type_name_id_base_cost = Some(52);
4112
4113 cfg.max_transactions_per_checkpoint = Some(20_000);
4115 }
4116 96 => {
4117 if chain != Chain::Mainnet && chain != Chain::Testnet {
4119 cfg.feature_flags
4120 .include_checkpoint_artifacts_digest_in_summary = true;
4121 }
4122 cfg.feature_flags.correct_gas_payment_limit_check = true;
4123 cfg.feature_flags.authority_capabilities_v2 = true;
4124 cfg.feature_flags.use_mfp_txns_in_load_initial_object_debts = true;
4125 cfg.feature_flags.cancel_for_failed_dkg_early = true;
4126 cfg.feature_flags.enable_coin_registry = true;
4127
4128 cfg.feature_flags.mysticeti_fastpath = true;
4130 }
4131 97 => {
4132 cfg.feature_flags.additional_borrow_checks = true;
4133 }
4134 98 => {
4135 cfg.event_emit_auth_stream_cost = Some(52);
4136 cfg.feature_flags.better_loader_errors = true;
4137 cfg.feature_flags.generate_df_type_layouts = true;
4138 }
4139 99 => {
4140 cfg.feature_flags.use_new_commit_handler = true;
4141 }
4142 100 => {
4143 cfg.feature_flags.private_generics_verifier_v2 = true;
4144 }
4145 101 => {
4146 cfg.feature_flags.create_root_accumulator_object = true;
4147 cfg.max_updates_per_settlement_txn = Some(100);
4148 if chain != Chain::Mainnet {
4149 cfg.feature_flags.enable_poseidon = true;
4150 }
4151 }
4152 102 => {
4153 cfg.feature_flags.per_object_congestion_control_mode =
4157 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4158 ExecutionTimeEstimateParams {
4159 target_utilization: 50,
4160 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4162 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4164 stored_observations_limit: 180,
4165 stake_weighted_median_threshold: 3334,
4166 default_none_duration_for_new_keys: true,
4167 observations_chunk_size: Some(18),
4168 },
4169 );
4170 cfg.feature_flags.deprecate_global_storage_ops = true;
4171 }
4172 103 => {}
4173 104 => {
4174 cfg.translation_per_command_base_charge = Some(1);
4175 cfg.translation_per_input_base_charge = Some(1);
4176 cfg.translation_pure_input_per_byte_charge = Some(1);
4177 cfg.translation_per_type_node_charge = Some(1);
4178 cfg.translation_per_reference_node_charge = Some(1);
4179 cfg.translation_per_linkage_entry_charge = Some(10);
4180 cfg.gas_model_version = Some(11);
4181 cfg.feature_flags.abstract_size_in_object_runtime = true;
4182 cfg.feature_flags.object_runtime_charge_cache_load_gas = true;
4183 cfg.dynamic_field_hash_type_and_key_cost_base = Some(52);
4184 cfg.dynamic_field_add_child_object_cost_base = Some(52);
4185 cfg.dynamic_field_add_child_object_value_cost_per_byte = Some(1);
4186 cfg.dynamic_field_borrow_child_object_cost_base = Some(52);
4187 cfg.dynamic_field_borrow_child_object_child_ref_cost_per_byte = Some(1);
4188 cfg.dynamic_field_remove_child_object_cost_base = Some(52);
4189 cfg.dynamic_field_remove_child_object_child_cost_per_byte = Some(1);
4190 cfg.dynamic_field_has_child_object_cost_base = Some(52);
4191 cfg.dynamic_field_has_child_object_with_ty_cost_base = Some(52);
4192 cfg.feature_flags.enable_ptb_execution_v2 = true;
4193
4194 cfg.poseidon_bn254_cost_base = Some(260);
4195
4196 cfg.feature_flags.consensus_skip_gced_accept_votes = true;
4197
4198 if chain != Chain::Mainnet {
4199 cfg.feature_flags
4200 .enable_nitro_attestation_all_nonzero_pcrs_parsing = true;
4201 }
4202
4203 cfg.feature_flags
4204 .include_cancelled_randomness_txns_in_prologue = true;
4205 }
4206 105 => {
4207 cfg.feature_flags.enable_multi_epoch_transaction_expiration = true;
4208 cfg.feature_flags.disable_preconsensus_locking = true;
4209
4210 if chain != Chain::Mainnet {
4211 cfg.feature_flags
4212 .enable_nitro_attestation_always_include_required_pcrs_parsing = true;
4213 }
4214 }
4215 106 => {
4216 cfg.accumulator_object_storage_cost = Some(7600);
4218
4219 if chain != Chain::Mainnet && chain != Chain::Testnet {
4220 cfg.feature_flags.enable_accumulators = true;
4221 cfg.feature_flags.enable_address_balance_gas_payments = true;
4222 cfg.feature_flags.enable_authenticated_event_streams = true;
4223 cfg.feature_flags.enable_object_funds_withdraw = true;
4224 }
4225 }
4226 107 => {
4227 cfg.feature_flags
4228 .consensus_skip_gced_blocks_in_direct_finalization = true;
4229
4230 if in_integration_test() {
4232 cfg.consensus_gc_depth = Some(6);
4233 cfg.consensus_max_num_transactions_in_block = Some(8);
4234 }
4235 }
4236 108 => {
4237 cfg.feature_flags.gas_rounding_halve_digits = true;
4238 cfg.feature_flags.flexible_tx_context_positions = true;
4239 cfg.feature_flags.disable_entry_point_signature_check = true;
4240
4241 if chain != Chain::Mainnet {
4242 cfg.feature_flags.address_aliases = true;
4243
4244 cfg.feature_flags.enable_accumulators = true;
4245 cfg.feature_flags.enable_address_balance_gas_payments = true;
4246 }
4247
4248 cfg.feature_flags.enable_poseidon = true;
4249 }
4250 109 => {
4251 cfg.binary_variant_handles = Some(1024);
4252 cfg.binary_variant_instantiation_handles = Some(1024);
4253 cfg.feature_flags.restrict_hot_or_not_entry_functions = true;
4254 }
4255 110 => {
4256 cfg.feature_flags
4257 .enable_nitro_attestation_all_nonzero_pcrs_parsing = true;
4258 cfg.feature_flags
4259 .enable_nitro_attestation_always_include_required_pcrs_parsing = true;
4260 if chain != Chain::Mainnet && chain != Chain::Testnet {
4261 cfg.feature_flags.split_checkpoints_in_consensus_handler = true;
4262 }
4263 cfg.feature_flags.validate_zklogin_public_identifier = true;
4264 cfg.feature_flags.fix_checkpoint_signature_mapping = true;
4265 cfg.feature_flags
4266 .consensus_always_accept_system_transactions = true;
4267 if chain != Chain::Mainnet {
4268 cfg.feature_flags.enable_object_funds_withdraw = true;
4269 }
4270 }
4271 111 => {
4272 cfg.feature_flags.validator_metadata_verify_v2 = true;
4273 }
4274 112 => {
4275 cfg.group_ops_ristretto_decode_scalar_cost = Some(7);
4276 cfg.group_ops_ristretto_decode_point_cost = Some(200);
4277 cfg.group_ops_ristretto_scalar_add_cost = Some(10);
4278 cfg.group_ops_ristretto_point_add_cost = Some(500);
4279 cfg.group_ops_ristretto_scalar_sub_cost = Some(10);
4280 cfg.group_ops_ristretto_point_sub_cost = Some(500);
4281 cfg.group_ops_ristretto_scalar_mul_cost = Some(11);
4282 cfg.group_ops_ristretto_point_mul_cost = Some(1200);
4283 cfg.group_ops_ristretto_scalar_div_cost = Some(151);
4284 cfg.group_ops_ristretto_point_div_cost = Some(2500);
4285
4286 if chain != Chain::Mainnet && chain != Chain::Testnet {
4287 cfg.feature_flags.enable_ristretto255_group_ops = true;
4288 }
4289 }
4290 113 => {
4291 cfg.feature_flags.address_balance_gas_check_rgp_at_signing = true;
4292 if chain != Chain::Mainnet && chain != Chain::Testnet {
4293 cfg.feature_flags.defer_unpaid_amplification = true;
4294 }
4295 }
4296 114 => {
4297 cfg.feature_flags.randomize_checkpoint_tx_limit_in_tests = true;
4298 cfg.feature_flags.address_balance_gas_reject_gas_coin_arg = true;
4299 if chain != Chain::Mainnet {
4300 cfg.feature_flags.split_checkpoints_in_consensus_handler = true;
4301 cfg.feature_flags.enable_authenticated_event_streams = true;
4302 cfg.feature_flags
4303 .include_checkpoint_artifacts_digest_in_summary = true;
4304 }
4305 }
4306 115 => {
4307 cfg.feature_flags.normalize_depth_formula = true;
4308 }
4309 116 => {
4310 cfg.feature_flags.gasless_transaction_drop_safety = true;
4311 cfg.feature_flags.address_aliases = true;
4312 cfg.feature_flags.relax_valid_during_for_owned_inputs = true;
4313 cfg.feature_flags.defer_unpaid_amplification = false;
4315 cfg.feature_flags.enable_display_registry = true;
4316 }
4317 117 => {}
4318 118 => {
4319 cfg.feature_flags.use_coin_party_owner = true;
4320 }
4321 119 => {
4322 cfg.execution_version = Some(4);
4324 cfg.feature_flags.address_balance_gas_reject_gas_coin_arg = false;
4325 cfg.feature_flags.merge_randomness_into_checkpoint = true;
4326 if chain != Chain::Mainnet {
4327 cfg.feature_flags.enable_gasless = true;
4328 cfg.gasless_max_computation_units = Some(50_000);
4329 cfg.gasless_allowed_token_types = Some(vec![]);
4330 cfg.feature_flags.enable_coin_reservation_obj_refs = true;
4331 cfg.feature_flags
4332 .convert_withdrawal_compatibility_ptb_arguments = true;
4333 }
4334 cfg.gasless_max_unused_inputs = Some(1);
4335 cfg.gasless_max_pure_input_bytes = Some(32);
4336 if chain == Chain::Testnet {
4337 cfg.gasless_allowed_token_types = Some(vec![(TESTNET_USDC.to_string(), 0)]);
4338 }
4339 cfg.transfer_receive_object_cost_per_byte = Some(1);
4340 cfg.transfer_receive_object_type_cost_per_byte = Some(2);
4341 }
4342 120 => {
4343 cfg.feature_flags.disallow_jump_orphans = true;
4344 }
4345 121 => {
4346 if chain != Chain::Mainnet {
4348 cfg.feature_flags.defer_unpaid_amplification = true;
4349 cfg.gasless_max_tps = Some(50);
4350 }
4351 cfg.feature_flags
4352 .early_return_receive_object_mismatched_type = true;
4353 }
4354 122 => {
4355 cfg.feature_flags.defer_unpaid_amplification = true;
4357 cfg.verify_bulletproofs_ristretto255_base_cost = Some(30000);
4359 cfg.verify_bulletproofs_ristretto255_cost_per_bit_and_commitment = Some(6500);
4360 if chain != Chain::Mainnet && chain != Chain::Testnet {
4361 cfg.feature_flags.enable_verify_bulletproofs_ristretto255 = true;
4362 }
4363 cfg.feature_flags.gasless_verify_remaining_balance = true;
4364 cfg.include_special_package_amendments = match chain {
4365 Chain::Mainnet => Some(MAINNET_LINKAGE_AMENDMENTS.clone()),
4366 Chain::Testnet => Some(TESTNET_LINKAGE_AMENDMENTS.clone()),
4367 Chain::Unknown => None,
4368 };
4369 cfg.gasless_max_tx_size_bytes = Some(16 * 1024);
4370 cfg.gasless_max_tps = Some(300);
4371 cfg.gasless_max_computation_units = Some(5_000);
4372 }
4373 123 => {
4374 cfg.gas_model_version = Some(13);
4375 }
4376 124 => {
4377 if chain != Chain::Mainnet && chain != Chain::Testnet {
4378 cfg.feature_flags.timestamp_based_epoch_close = true;
4379 }
4380 cfg.gas_model_version = Some(14);
4381 cfg.feature_flags.limit_groth16_pvk_inputs = true;
4382
4383 cfg.feature_flags.enable_accumulators = true;
4389 cfg.feature_flags.enable_address_balance_gas_payments = true;
4390 cfg.feature_flags.enable_authenticated_event_streams = true;
4391 cfg.feature_flags.enable_coin_reservation_obj_refs = true;
4392 cfg.feature_flags.enable_object_funds_withdraw = true;
4393 cfg.feature_flags
4394 .convert_withdrawal_compatibility_ptb_arguments = true;
4395 cfg.feature_flags.split_checkpoints_in_consensus_handler = true;
4396 cfg.feature_flags
4397 .include_checkpoint_artifacts_digest_in_summary = true;
4398 cfg.feature_flags.enable_gasless = true;
4399
4400 if chain == Chain::Mainnet {
4405 cfg.gasless_allowed_token_types = Some(vec![
4406 (MAINNET_USDC.to_string(), 10_000),
4407 (MAINNET_USDSUI.to_string(), 10_000),
4408 (MAINNET_SUI_USDE.to_string(), 10_000),
4409 (MAINNET_USDY.to_string(), 10_000),
4410 (MAINNET_FDUSD.to_string(), 10_000),
4411 (MAINNET_AUSD.to_string(), 10_000),
4412 (MAINNET_USDB.to_string(), 10_000),
4413 ]);
4414 }
4415 }
4416 125 => {
4417 cfg.feature_flags.granular_post_execution_checks = true;
4418 if chain != Chain::Mainnet {
4419 cfg.feature_flags.timestamp_based_epoch_close = true;
4420 }
4421 }
4422 126 => {
4423 cfg.feature_flags.early_exit_on_iffw = true;
4424 }
4425 127 => {
4426 cfg.feature_flags.always_advance_dkg_to_resolution = true;
4427
4428 cfg.verify_bulletproofs_ristretto255_base_cost = Some(23866);
4429 cfg.verify_bulletproofs_ristretto255_cost_per_bit_and_commitment = Some(1324);
4430 cfg.group_ops_ristretto_decode_scalar_cost = Some(5);
4431 cfg.group_ops_ristretto_decode_point_cost = Some(216);
4432 cfg.group_ops_ristretto_scalar_add_cost = Some(2);
4433 cfg.group_ops_ristretto_point_add_cost = Some(8);
4434 cfg.group_ops_ristretto_scalar_sub_cost = Some(2);
4435 cfg.group_ops_ristretto_point_sub_cost = Some(8);
4436 cfg.group_ops_ristretto_scalar_mul_cost = Some(5);
4437 cfg.group_ops_ristretto_point_mul_cost = Some(1763);
4438 cfg.group_ops_ristretto_scalar_div_cost = Some(557);
4439 cfg.group_ops_ristretto_point_div_cost = Some(2244);
4440
4441 if chain != Chain::Mainnet {
4442 cfg.feature_flags.enable_ristretto255_group_ops = true;
4443 cfg.feature_flags.enable_verify_bulletproofs_ristretto255 = true;
4444 }
4445
4446 cfg.feature_flags.timestamp_based_epoch_close = true;
4447 }
4448 128 => {
4449 cfg.max_generic_instantiation_type_nodes_per_function = Some(10_000);
4450 cfg.max_generic_instantiation_type_nodes_per_module = Some(500_000);
4451 cfg.binary_enum_defs = Some(200);
4452 cfg.binary_enum_def_instantiations = Some(100);
4453 }
4454 129 => {
4455 cfg.feature_flags.enable_unified_linkage = true;
4456 }
4457 130 => {
4458 cfg.feature_flags.record_net_unsettled_object_withdraws = true;
4459 }
4460 _ => panic!("unsupported version {:?}", version),
4471 }
4472 }
4473
4474 cfg
4475 }
4476
4477 pub fn apply_seeded_test_overrides(&mut self, seed: &[u8; 32]) {
4478 if !self.feature_flags.randomize_checkpoint_tx_limit_in_tests
4479 || !self.feature_flags.split_checkpoints_in_consensus_handler
4480 {
4481 return;
4482 }
4483
4484 if !mysten_common::in_test_configuration() {
4485 return;
4486 }
4487
4488 use rand::{Rng, SeedableRng, rngs::StdRng};
4489 let mut rng = StdRng::from_seed(*seed);
4490 let max_txns = rng.gen_range(10..=100u64);
4491 info!("seeded test override: max_transactions_per_checkpoint = {max_txns}");
4492 self.max_transactions_per_checkpoint = Some(max_txns);
4493 }
4494
4495 pub fn verifier_config(&self, signing_limits: Option<(usize, usize, usize)>) -> VerifierConfig {
4501 let (
4502 max_back_edges_per_function,
4503 max_back_edges_per_module,
4504 sanity_check_with_regex_reference_safety,
4505 ) = if let Some((
4506 max_back_edges_per_function,
4507 max_back_edges_per_module,
4508 sanity_check_with_regex_reference_safety,
4509 )) = signing_limits
4510 {
4511 (
4512 Some(max_back_edges_per_function),
4513 Some(max_back_edges_per_module),
4514 Some(sanity_check_with_regex_reference_safety),
4515 )
4516 } else {
4517 (None, None, None)
4518 };
4519
4520 let additional_borrow_checks = if signing_limits.is_some() {
4521 true
4523 } else {
4524 self.additional_borrow_checks()
4525 };
4526 let deprecate_global_storage_ops = if signing_limits.is_some() {
4527 true
4529 } else {
4530 self.deprecate_global_storage_ops()
4531 };
4532
4533 VerifierConfig {
4534 max_loop_depth: Some(self.max_loop_depth() as usize),
4535 max_generic_instantiation_length: Some(self.max_generic_instantiation_length() as usize),
4536 max_function_parameters: Some(self.max_function_parameters() as usize),
4537 max_basic_blocks: Some(self.max_basic_blocks() as usize),
4538 max_value_stack_size: self.max_value_stack_size() as usize,
4539 max_type_nodes: Some(self.max_type_nodes() as usize),
4540 max_generic_instantiation_type_nodes_per_function: self
4541 .max_generic_instantiation_type_nodes_per_function_as_option()
4542 .map(|v| v as usize),
4543 max_generic_instantiation_type_nodes_per_module: self
4544 .max_generic_instantiation_type_nodes_per_module_as_option()
4545 .map(|v| v as usize),
4546 max_push_size: Some(self.max_push_size() as usize),
4547 max_dependency_depth: Some(self.max_dependency_depth() as usize),
4548 max_fields_in_struct: Some(self.max_fields_in_struct() as usize),
4549 max_function_definitions: Some(self.max_function_definitions() as usize),
4550 max_data_definitions: Some(self.max_struct_definitions() as usize),
4551 max_constant_vector_len: Some(self.max_move_vector_len()),
4552 max_back_edges_per_function,
4553 max_back_edges_per_module,
4554 max_basic_blocks_in_script: None,
4555 max_identifier_len: self.max_move_identifier_len_as_option(), disallow_self_identifier: self.feature_flags.disallow_self_identifier,
4557 allow_receiving_object_id: self.allow_receiving_object_id(),
4558 reject_mutable_random_on_entry_functions: self
4559 .reject_mutable_random_on_entry_functions(),
4560 bytecode_version: self.move_binary_format_version(),
4561 max_variants_in_enum: self.max_move_enum_variants_as_option(),
4562 additional_borrow_checks,
4563 better_loader_errors: self.better_loader_errors(),
4564 private_generics_verifier_v2: self.private_generics_verifier_v2(),
4565 sanity_check_with_regex_reference_safety: sanity_check_with_regex_reference_safety
4566 .map(|limit| limit as u128),
4567 deprecate_global_storage_ops,
4568 disable_entry_point_signature_check: self.disable_entry_point_signature_check(),
4569 switch_to_regex_reference_safety: false,
4570 disallow_jump_orphans: self.disallow_jump_orphans(),
4571 }
4572 }
4573
4574 pub fn binary_config(
4575 &self,
4576 override_deprecate_global_storage_ops_during_deserialization: Option<bool>,
4577 ) -> BinaryConfig {
4578 let deprecate_global_storage_ops =
4579 override_deprecate_global_storage_ops_during_deserialization
4580 .unwrap_or_else(|| self.deprecate_global_storage_ops());
4581 BinaryConfig::new(
4582 self.move_binary_format_version(),
4583 self.min_move_binary_format_version_as_option()
4584 .unwrap_or(VERSION_1),
4585 self.no_extraneous_module_bytes(),
4586 deprecate_global_storage_ops,
4587 TableConfig {
4588 module_handles: self.binary_module_handles_as_option().unwrap_or(u16::MAX),
4589 datatype_handles: self.binary_struct_handles_as_option().unwrap_or(u16::MAX),
4590 function_handles: self.binary_function_handles_as_option().unwrap_or(u16::MAX),
4591 function_instantiations: self
4592 .binary_function_instantiations_as_option()
4593 .unwrap_or(u16::MAX),
4594 signatures: self.binary_signatures_as_option().unwrap_or(u16::MAX),
4595 constant_pool: self.binary_constant_pool_as_option().unwrap_or(u16::MAX),
4596 identifiers: self.binary_identifiers_as_option().unwrap_or(u16::MAX),
4597 address_identifiers: self
4598 .binary_address_identifiers_as_option()
4599 .unwrap_or(u16::MAX),
4600 struct_defs: self.binary_struct_defs_as_option().unwrap_or(u16::MAX),
4601 struct_def_instantiations: self
4602 .binary_struct_def_instantiations_as_option()
4603 .unwrap_or(u16::MAX),
4604 function_defs: self.binary_function_defs_as_option().unwrap_or(u16::MAX),
4605 field_handles: self.binary_field_handles_as_option().unwrap_or(u16::MAX),
4606 field_instantiations: self
4607 .binary_field_instantiations_as_option()
4608 .unwrap_or(u16::MAX),
4609 friend_decls: self.binary_friend_decls_as_option().unwrap_or(u16::MAX),
4610 enum_defs: self.binary_enum_defs_as_option().unwrap_or(u16::MAX),
4611 enum_def_instantiations: self
4612 .binary_enum_def_instantiations_as_option()
4613 .unwrap_or(u16::MAX),
4614 variant_handles: self.binary_variant_handles_as_option().unwrap_or(u16::MAX),
4615 variant_instantiation_handles: self
4616 .binary_variant_instantiation_handles_as_option()
4617 .unwrap_or(u16::MAX),
4618 },
4619 )
4620 }
4621
4622 #[cfg(not(msim))]
4626 pub fn apply_overrides_for_testing(
4627 override_fn: impl Fn(ProtocolVersion, Self) -> Self + Send + Sync + 'static,
4628 ) -> OverrideGuard {
4629 let mut cur = CONFIG_OVERRIDE.lock().unwrap();
4630 assert!(cur.is_none(), "config override already present");
4631 *cur = Some(Box::new(override_fn));
4632 OverrideGuard
4633 }
4634
4635 #[cfg(msim)]
4639 pub fn apply_overrides_for_testing(
4640 override_fn: impl Fn(ProtocolVersion, Self) -> Self + Send + 'static,
4641 ) -> OverrideGuard {
4642 CONFIG_OVERRIDE.with(|ovr| {
4643 let mut cur = ovr.borrow_mut();
4644 assert!(cur.is_none(), "config override already present");
4645 *cur = Some(Box::new(override_fn));
4646 OverrideGuard
4647 })
4648 }
4649
4650 #[cfg(not(msim))]
4651 fn apply_config_override(version: ProtocolVersion, mut ret: Self) -> Self {
4652 if let Some(override_fn) = CONFIG_OVERRIDE.lock().unwrap().as_ref() {
4653 warn!(
4654 "overriding ProtocolConfig settings with custom settings (you should not see this log outside of tests)"
4655 );
4656 ret = override_fn(version, ret);
4657 }
4658 ret
4659 }
4660
4661 #[cfg(msim)]
4662 fn apply_config_override(version: ProtocolVersion, ret: Self) -> Self {
4663 CONFIG_OVERRIDE.with(|ovr| {
4664 if let Some(override_fn) = &*ovr.borrow() {
4665 warn!(
4666 "overriding ProtocolConfig settings with custom settings (you should not see this log outside of tests)"
4667 );
4668 override_fn(version, ret)
4669 } else {
4670 ret
4671 }
4672 })
4673 }
4674}
4675
4676impl ProtocolConfig {
4680 pub fn set_advance_to_highest_supported_protocol_version_for_testing(&mut self, val: bool) {
4681 self.feature_flags
4682 .advance_to_highest_supported_protocol_version = val
4683 }
4684 pub fn set_commit_root_state_digest_supported_for_testing(&mut self, val: bool) {
4685 self.feature_flags.commit_root_state_digest = val
4686 }
4687 pub fn set_zklogin_auth_for_testing(&mut self, val: bool) {
4688 self.feature_flags.zklogin_auth = val
4689 }
4690 pub fn set_enable_jwk_consensus_updates_for_testing(&mut self, val: bool) {
4691 self.feature_flags.enable_jwk_consensus_updates = val
4692 }
4693 pub fn set_random_beacon_for_testing(&mut self, val: bool) {
4694 self.feature_flags.random_beacon = val
4695 }
4696
4697 pub fn set_upgraded_multisig_for_testing(&mut self, val: bool) {
4698 self.feature_flags.upgraded_multisig_supported = val
4699 }
4700 pub fn set_accept_zklogin_in_multisig_for_testing(&mut self, val: bool) {
4701 self.feature_flags.accept_zklogin_in_multisig = val
4702 }
4703
4704 pub fn set_shared_object_deletion_for_testing(&mut self, val: bool) {
4705 self.feature_flags.shared_object_deletion = val;
4706 }
4707
4708 pub fn set_narwhal_new_leader_election_schedule_for_testing(&mut self, val: bool) {
4709 self.feature_flags.narwhal_new_leader_election_schedule = val;
4710 }
4711
4712 pub fn set_receive_object_for_testing(&mut self, val: bool) {
4713 self.feature_flags.receive_objects = val
4714 }
4715 pub fn set_narwhal_certificate_v2_for_testing(&mut self, val: bool) {
4716 self.feature_flags.narwhal_certificate_v2 = val
4717 }
4718 pub fn set_verify_legacy_zklogin_address_for_testing(&mut self, val: bool) {
4719 self.feature_flags.verify_legacy_zklogin_address = val
4720 }
4721
4722 pub fn set_per_object_congestion_control_mode_for_testing(
4723 &mut self,
4724 val: PerObjectCongestionControlMode,
4725 ) {
4726 self.feature_flags.per_object_congestion_control_mode = val;
4727 }
4728
4729 pub fn set_consensus_choice_for_testing(&mut self, val: ConsensusChoice) {
4730 self.feature_flags.consensus_choice = val;
4731 }
4732
4733 pub fn set_consensus_network_for_testing(&mut self, val: ConsensusNetwork) {
4734 self.feature_flags.consensus_network = val;
4735 }
4736
4737 pub fn set_zklogin_max_epoch_upper_bound_delta_for_testing(&mut self, val: Option<u64>) {
4738 self.feature_flags.zklogin_max_epoch_upper_bound_delta = val
4739 }
4740
4741 pub fn set_disable_bridge_for_testing(&mut self) {
4742 self.feature_flags.bridge = false
4743 }
4744
4745 pub fn set_mysticeti_num_leaders_per_round_for_testing(&mut self, val: Option<usize>) {
4746 self.feature_flags.mysticeti_num_leaders_per_round = val;
4747 }
4748
4749 pub fn set_enable_soft_bundle_for_testing(&mut self, val: bool) {
4750 self.feature_flags.soft_bundle = val;
4751 }
4752
4753 pub fn set_passkey_auth_for_testing(&mut self, val: bool) {
4754 self.feature_flags.passkey_auth = val
4755 }
4756
4757 pub fn set_enable_party_transfer_for_testing(&mut self, val: bool) {
4758 self.feature_flags.enable_party_transfer = val
4759 }
4760
4761 pub fn set_enable_unified_linkage_for_testing(&mut self, val: bool) {
4762 self.feature_flags.enable_unified_linkage = val
4763 }
4764
4765 pub fn set_consensus_distributed_vote_scoring_strategy_for_testing(&mut self, val: bool) {
4766 self.feature_flags
4767 .consensus_distributed_vote_scoring_strategy = val;
4768 }
4769
4770 pub fn set_consensus_round_prober_for_testing(&mut self, val: bool) {
4771 self.feature_flags.consensus_round_prober = val;
4772 }
4773
4774 pub fn set_disallow_new_modules_in_deps_only_packages_for_testing(&mut self, val: bool) {
4775 self.feature_flags
4776 .disallow_new_modules_in_deps_only_packages = val;
4777 }
4778
4779 pub fn set_correct_gas_payment_limit_check_for_testing(&mut self, val: bool) {
4780 self.feature_flags.correct_gas_payment_limit_check = val;
4781 }
4782
4783 pub fn set_address_aliases_for_testing(&mut self, val: bool) {
4784 self.feature_flags.address_aliases = val;
4785 }
4786
4787 pub fn set_consensus_round_prober_probe_accepted_rounds(&mut self, val: bool) {
4788 self.feature_flags
4789 .consensus_round_prober_probe_accepted_rounds = val;
4790 }
4791
4792 pub fn set_mysticeti_fastpath_for_testing(&mut self, val: bool) {
4793 self.feature_flags.mysticeti_fastpath = val;
4794 }
4795
4796 pub fn set_accept_passkey_in_multisig_for_testing(&mut self, val: bool) {
4797 self.feature_flags.accept_passkey_in_multisig = val;
4798 }
4799
4800 pub fn set_consensus_batched_block_sync_for_testing(&mut self, val: bool) {
4801 self.feature_flags.consensus_batched_block_sync = val;
4802 }
4803
4804 pub fn set_record_time_estimate_processed_for_testing(&mut self, val: bool) {
4805 self.feature_flags.record_time_estimate_processed = val;
4806 }
4807
4808 pub fn set_prepend_prologue_tx_in_consensus_commit_in_checkpoints_for_testing(
4809 &mut self,
4810 val: bool,
4811 ) {
4812 self.feature_flags
4813 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = val;
4814 }
4815
4816 pub fn enable_accumulators_for_testing(&mut self) {
4817 self.feature_flags.enable_accumulators = true;
4818 }
4819
4820 pub fn disable_accumulators_for_testing(&mut self) {
4821 self.feature_flags.enable_accumulators = false;
4822 self.feature_flags.enable_address_balance_gas_payments = false;
4823 }
4824
4825 pub fn enable_coin_reservation_for_testing(&mut self) {
4826 self.feature_flags.enable_coin_reservation_obj_refs = true;
4827 self.feature_flags
4828 .convert_withdrawal_compatibility_ptb_arguments = true;
4829 self.execution_version = Some(self.execution_version.map_or(4, |v| v.max(4)));
4832 }
4833
4834 pub fn disable_coin_reservation_for_testing(&mut self) {
4835 self.feature_flags.enable_coin_reservation_obj_refs = false;
4836 self.feature_flags
4837 .convert_withdrawal_compatibility_ptb_arguments = false;
4838 }
4839
4840 pub fn create_root_accumulator_object_for_testing(&mut self) {
4841 self.feature_flags.create_root_accumulator_object = true;
4842 }
4843
4844 pub fn disable_create_root_accumulator_object_for_testing(&mut self) {
4845 self.feature_flags.create_root_accumulator_object = false;
4846 }
4847
4848 pub fn enable_address_balance_gas_payments_for_testing(&mut self) {
4849 self.feature_flags.enable_accumulators = true;
4850 self.feature_flags.allow_private_accumulator_entrypoints = true;
4851 self.feature_flags.enable_address_balance_gas_payments = true;
4852 self.feature_flags.address_balance_gas_check_rgp_at_signing = true;
4853 self.feature_flags.address_balance_gas_reject_gas_coin_arg = false;
4854 self.execution_version = Some(self.execution_version.map_or(4, |v| v.max(4)))
4855 }
4856
4857 pub fn disable_address_balance_gas_payments_for_testing(&mut self) {
4858 self.feature_flags.enable_address_balance_gas_payments = false;
4859 }
4860
4861 pub fn enable_gasless_for_testing(&mut self) {
4862 self.enable_address_balance_gas_payments_for_testing();
4863 self.feature_flags.enable_gasless = true;
4864 self.feature_flags.gasless_verify_remaining_balance = true;
4865 self.gasless_max_computation_units = Some(5_000);
4866 self.gasless_allowed_token_types = Some(vec![]);
4867 self.gasless_max_tps = Some(1000);
4868 self.gasless_max_tx_size_bytes = Some(16 * 1024);
4869 }
4870
4871 pub fn disable_gasless_for_testing(&mut self) {
4872 self.feature_flags.enable_gasless = false;
4873 self.gasless_max_computation_units = None;
4874 self.gasless_allowed_token_types = None;
4875 }
4876
4877 pub fn enable_multi_epoch_transaction_expiration_for_testing(&mut self) {
4878 self.feature_flags.enable_multi_epoch_transaction_expiration = true;
4879 }
4880
4881 pub fn enable_authenticated_event_streams_for_testing(&mut self) {
4882 self.enable_accumulators_for_testing();
4883 self.feature_flags.enable_authenticated_event_streams = true;
4884 self.feature_flags
4885 .include_checkpoint_artifacts_digest_in_summary = true;
4886 self.feature_flags.split_checkpoints_in_consensus_handler = true;
4887 }
4888
4889 pub fn disable_authenticated_event_streams_for_testing(&mut self) {
4890 self.feature_flags.enable_authenticated_event_streams = false;
4891 }
4892
4893 pub fn disable_randomize_checkpoint_tx_limit_for_testing(&mut self) {
4894 self.feature_flags.randomize_checkpoint_tx_limit_in_tests = false;
4895 }
4896
4897 pub fn enable_non_exclusive_writes_for_testing(&mut self) {
4898 self.feature_flags.enable_non_exclusive_writes = true;
4899 }
4900
4901 pub fn set_relax_valid_during_for_owned_inputs_for_testing(&mut self, val: bool) {
4902 self.feature_flags.relax_valid_during_for_owned_inputs = val;
4903 }
4904
4905 pub fn set_ignore_execution_time_observations_after_certs_closed_for_testing(
4906 &mut self,
4907 val: bool,
4908 ) {
4909 self.feature_flags
4910 .ignore_execution_time_observations_after_certs_closed = val;
4911 }
4912
4913 pub fn set_consensus_checkpoint_signature_key_includes_digest_for_testing(
4914 &mut self,
4915 val: bool,
4916 ) {
4917 self.feature_flags
4918 .consensus_checkpoint_signature_key_includes_digest = val;
4919 }
4920
4921 pub fn set_cancel_for_failed_dkg_early_for_testing(&mut self, val: bool) {
4922 self.feature_flags.cancel_for_failed_dkg_early = val;
4923 }
4924
4925 pub fn set_always_advance_dkg_to_resolution_for_testing(&mut self, val: bool) {
4926 self.feature_flags.always_advance_dkg_to_resolution = val;
4927 }
4928
4929 pub fn set_use_mfp_txns_in_load_initial_object_debts_for_testing(&mut self, val: bool) {
4930 self.feature_flags.use_mfp_txns_in_load_initial_object_debts = val;
4931 }
4932
4933 pub fn set_authority_capabilities_v2_for_testing(&mut self, val: bool) {
4934 self.feature_flags.authority_capabilities_v2 = val;
4935 }
4936
4937 pub fn allow_references_in_ptbs_for_testing(&mut self) {
4938 self.feature_flags.allow_references_in_ptbs = true;
4939 }
4940
4941 pub fn set_consensus_skip_gced_accept_votes_for_testing(&mut self, val: bool) {
4942 self.feature_flags.consensus_skip_gced_accept_votes = val;
4943 }
4944
4945 pub fn set_enable_object_funds_withdraw_for_testing(&mut self, val: bool) {
4946 self.feature_flags.enable_object_funds_withdraw = val;
4947 }
4948
4949 pub fn set_record_net_unsettled_object_withdraws_for_testing(&mut self, val: bool) {
4950 self.feature_flags.record_net_unsettled_object_withdraws = val;
4951 }
4952
4953 pub fn set_split_checkpoints_in_consensus_handler_for_testing(&mut self, val: bool) {
4954 self.feature_flags.split_checkpoints_in_consensus_handler = val;
4955 }
4956
4957 pub fn set_merge_randomness_into_checkpoint_for_testing(&mut self, val: bool) {
4958 self.feature_flags.merge_randomness_into_checkpoint = val;
4959 }
4960}
4961
4962#[cfg(not(msim))]
4963type OverrideFn = dyn Fn(ProtocolVersion, ProtocolConfig) -> ProtocolConfig + Send + Sync;
4964
4965#[cfg(not(msim))]
4966static CONFIG_OVERRIDE: Mutex<Option<Box<OverrideFn>>> = Mutex::new(None);
4967
4968#[cfg(msim)]
4969type OverrideFn = dyn Fn(ProtocolVersion, ProtocolConfig) -> ProtocolConfig + Send;
4970
4971#[cfg(msim)]
4972thread_local! {
4973 static CONFIG_OVERRIDE: RefCell<Option<Box<OverrideFn>>> = RefCell::new(None);
4974}
4975
4976#[must_use]
4977pub struct OverrideGuard;
4978
4979#[cfg(not(msim))]
4980impl Drop for OverrideGuard {
4981 fn drop(&mut self) {
4982 info!("restoring override fn");
4983 *CONFIG_OVERRIDE.lock().unwrap() = None;
4984 }
4985}
4986
4987#[cfg(msim)]
4988impl Drop for OverrideGuard {
4989 fn drop(&mut self) {
4990 info!("restoring override fn");
4991 CONFIG_OVERRIDE.with(|ovr| {
4992 *ovr.borrow_mut() = None;
4993 });
4994 }
4995}
4996
4997#[derive(PartialEq, Eq)]
5000pub enum LimitThresholdCrossed {
5001 None,
5002 Soft(u128, u128),
5003 Hard(u128, u128),
5004}
5005
5006pub fn check_limit_in_range<T: Into<V>, U: Into<V>, V: PartialOrd + Into<u128>>(
5009 x: T,
5010 soft_limit: U,
5011 hard_limit: V,
5012) -> LimitThresholdCrossed {
5013 let x: V = x.into();
5014 let soft_limit: V = soft_limit.into();
5015
5016 debug_assert!(soft_limit <= hard_limit);
5017
5018 if x >= hard_limit {
5021 LimitThresholdCrossed::Hard(x.into(), hard_limit.into())
5022 } else if x < soft_limit {
5023 LimitThresholdCrossed::None
5024 } else {
5025 LimitThresholdCrossed::Soft(x.into(), soft_limit.into())
5026 }
5027}
5028
5029#[macro_export]
5030macro_rules! check_limit {
5031 ($x:expr, $hard:expr) => {
5032 check_limit!($x, $hard, $hard)
5033 };
5034 ($x:expr, $soft:expr, $hard:expr) => {
5035 check_limit_in_range($x as u64, $soft, $hard)
5036 };
5037}
5038
5039#[macro_export]
5043macro_rules! check_limit_by_meter {
5044 ($is_metered:expr, $x:expr, $metered_limit:expr, $unmetered_hard_limit:expr, $metric:expr) => {{
5045 let (h, metered_str) = if $is_metered {
5047 ($metered_limit, "metered")
5048 } else {
5049 ($unmetered_hard_limit, "unmetered")
5051 };
5052 use sui_protocol_config::check_limit_in_range;
5053 let result = check_limit_in_range($x as u64, $metered_limit, h);
5054 match result {
5055 LimitThresholdCrossed::None => {}
5056 LimitThresholdCrossed::Soft(_, _) => {
5057 $metric.with_label_values(&[metered_str, "soft"]).inc();
5058 }
5059 LimitThresholdCrossed::Hard(_, _) => {
5060 $metric.with_label_values(&[metered_str, "hard"]).inc();
5061 }
5062 };
5063 result
5064 }};
5065}
5066
5067pub type Amendments = BTreeMap<AccountAddress, BTreeMap<AccountAddress, AccountAddress>>;
5070
5071static MAINNET_LINKAGE_AMENDMENTS: LazyLock<Arc<Amendments>> =
5072 LazyLock::new(|| parse_amendments(include_str!("mainnet_amendments.json")));
5073
5074static TESTNET_LINKAGE_AMENDMENTS: LazyLock<Arc<Amendments>> =
5075 LazyLock::new(|| parse_amendments(include_str!("testnet_amendments.json")));
5076
5077fn parse_amendments(json: &str) -> Arc<Amendments> {
5078 #[derive(serde::Deserialize)]
5079 struct AmendmentEntry {
5080 root: String,
5081 deps: Vec<DepEntry>,
5082 }
5083
5084 #[derive(serde::Deserialize)]
5085 struct DepEntry {
5086 original_id: String,
5087 version_id: String,
5088 }
5089
5090 let entries: Vec<AmendmentEntry> =
5091 serde_json::from_str(json).expect("Failed to parse amendments JSON");
5092 let mut amendments = BTreeMap::new();
5093 for entry in entries {
5094 let root_id = AccountAddress::from_hex_literal(&entry.root).unwrap();
5095 let mut dep_ids = BTreeMap::new();
5096 for dep in entry.deps {
5097 let orig_id = AccountAddress::from_hex_literal(&dep.original_id).unwrap();
5098 let upgraded_id = AccountAddress::from_hex_literal(&dep.version_id).unwrap();
5099 assert!(
5100 dep_ids.insert(orig_id, upgraded_id).is_none(),
5101 "Duplicate original ID in amendments table"
5102 );
5103 }
5104 assert!(
5105 amendments.insert(root_id, dep_ids).is_none(),
5106 "Duplicate root ID in amendments table"
5107 );
5108 }
5109 Arc::new(amendments)
5110}
5111
5112#[cfg(all(test, not(msim)))]
5113mod test {
5114 use insta::assert_yaml_snapshot;
5115
5116 use super::*;
5117
5118 #[test]
5119 fn snapshot_tests() {
5120 println!("\n============================================================================");
5121 println!("! !");
5122 println!("! IMPORTANT: never update snapshots from this test. only add new versions! !");
5123 println!("! !");
5124 println!("============================================================================\n");
5125 for chain_id in &[Chain::Unknown, Chain::Mainnet, Chain::Testnet] {
5126 let chain_str = match chain_id {
5130 Chain::Unknown => "".to_string(),
5131 _ => format!("{:?}_", chain_id),
5132 };
5133 for i in MIN_PROTOCOL_VERSION..=MAX_PROTOCOL_VERSION {
5134 let cur = ProtocolVersion::new(i);
5135 assert_yaml_snapshot!(
5136 format!("{}version_{}", chain_str, cur.as_u64()),
5137 ProtocolConfig::get_for_version(cur, *chain_id)
5138 );
5139 }
5140 }
5141 }
5142
5143 #[test]
5144 fn test_getters() {
5145 let prot: ProtocolConfig =
5146 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5147 assert_eq!(
5148 prot.max_arguments(),
5149 prot.max_arguments_as_option().unwrap()
5150 );
5151 }
5152
5153 #[test]
5154 fn test_setters() {
5155 let mut prot: ProtocolConfig =
5156 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5157 prot.set_max_arguments_for_testing(123);
5158 assert_eq!(prot.max_arguments(), 123);
5159
5160 prot.set_max_arguments_from_str_for_testing("321".to_string());
5161 assert_eq!(prot.max_arguments(), 321);
5162
5163 prot.disable_max_arguments_for_testing();
5164 assert_eq!(prot.max_arguments_as_option(), None);
5165
5166 prot.set_attr_for_testing("max_arguments".to_string(), "456".to_string());
5167 assert_eq!(prot.max_arguments(), 456);
5168 }
5169
5170 #[test]
5171 fn test_feature_flag_setter_by_string() {
5172 let mut prot: ProtocolConfig =
5173 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5174 assert!(!prot.zklogin_auth());
5175 prot.set_feature_flag_for_testing("zklogin_auth".to_string(), true);
5176 assert!(prot.zklogin_auth());
5177 prot.set_feature_flag_for_testing("zklogin_auth".to_string(), false);
5178 assert!(!prot.zklogin_auth());
5179 }
5180
5181 #[test]
5182 #[should_panic(expected = "unknown feature flag")]
5183 fn test_feature_flag_setter_unknown_flag() {
5184 let mut prot: ProtocolConfig =
5185 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5186 prot.set_feature_flag_for_testing("some random string".to_string(), true);
5187 }
5188
5189 #[test]
5190 fn test_get_for_version_if_supported_applies_test_overrides() {
5191 let before =
5192 ProtocolConfig::get_for_version_if_supported(ProtocolVersion::new(1), Chain::Unknown)
5193 .unwrap();
5194
5195 assert!(!before.enable_coin_reservation_obj_refs());
5196
5197 let _guard = ProtocolConfig::apply_overrides_for_testing(|_, mut cfg| {
5198 cfg.enable_coin_reservation_for_testing();
5199 cfg
5200 });
5201
5202 let after =
5203 ProtocolConfig::get_for_version_if_supported(ProtocolVersion::new(1), Chain::Unknown)
5204 .unwrap();
5205
5206 assert!(after.enable_coin_reservation_obj_refs());
5207 }
5208
5209 #[test]
5210 #[should_panic(expected = "unsupported version")]
5211 fn max_version_test() {
5212 let _ = ProtocolConfig::get_for_version_impl(
5215 ProtocolVersion::new(MAX_PROTOCOL_VERSION + 1),
5216 Chain::Unknown,
5217 );
5218 }
5219
5220 #[test]
5221 fn lookup_by_string_test() {
5222 let prot: ProtocolConfig =
5223 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5224 assert!(prot.lookup_attr("some random string".to_string()).is_none());
5226
5227 assert!(
5228 prot.lookup_attr("max_arguments".to_string())
5229 == Some(ProtocolConfigValue::u32(prot.max_arguments())),
5230 );
5231
5232 assert!(
5234 prot.lookup_attr("max_move_identifier_len".to_string())
5235 .is_none()
5236 );
5237
5238 let prot: ProtocolConfig =
5240 ProtocolConfig::get_for_version(ProtocolVersion::new(9), Chain::Unknown);
5241 assert!(
5242 prot.lookup_attr("max_move_identifier_len".to_string())
5243 == Some(ProtocolConfigValue::u64(prot.max_move_identifier_len()))
5244 );
5245
5246 let prot: ProtocolConfig =
5247 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5248 assert!(
5250 prot.attr_map()
5251 .get("max_move_identifier_len")
5252 .unwrap()
5253 .is_none()
5254 );
5255 assert!(
5257 prot.attr_map().get("max_arguments").unwrap()
5258 == &Some(ProtocolConfigValue::u32(prot.max_arguments()))
5259 );
5260
5261 let prot: ProtocolConfig =
5263 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5264 assert!(
5266 prot.feature_flags
5267 .lookup_attr("some random string".to_owned())
5268 .is_none()
5269 );
5270 assert!(
5271 !prot
5272 .feature_flags
5273 .attr_map()
5274 .contains_key("some random string")
5275 );
5276
5277 assert!(
5279 prot.feature_flags
5280 .lookup_attr("package_upgrades".to_owned())
5281 == Some(false)
5282 );
5283 assert!(
5284 prot.feature_flags
5285 .attr_map()
5286 .get("package_upgrades")
5287 .unwrap()
5288 == &false
5289 );
5290 let prot: ProtocolConfig =
5291 ProtocolConfig::get_for_version(ProtocolVersion::new(4), Chain::Unknown);
5292 assert!(
5294 prot.feature_flags
5295 .lookup_attr("package_upgrades".to_owned())
5296 == Some(true)
5297 );
5298 assert!(
5299 prot.feature_flags
5300 .attr_map()
5301 .get("package_upgrades")
5302 .unwrap()
5303 == &true
5304 );
5305 }
5306
5307 #[test]
5308 fn limit_range_fn_test() {
5309 let low = 100u32;
5310 let high = 10000u64;
5311
5312 assert!(check_limit!(1u8, low, high) == LimitThresholdCrossed::None);
5313 assert!(matches!(
5314 check_limit!(255u16, low, high),
5315 LimitThresholdCrossed::Soft(255u128, 100)
5316 ));
5317 assert!(matches!(
5323 check_limit!(2550000u64, low, high),
5324 LimitThresholdCrossed::Hard(2550000, 10000)
5325 ));
5326
5327 assert!(matches!(
5328 check_limit!(2550000u64, high, high),
5329 LimitThresholdCrossed::Hard(2550000, 10000)
5330 ));
5331
5332 assert!(matches!(
5333 check_limit!(1u8, high),
5334 LimitThresholdCrossed::None
5335 ));
5336
5337 assert!(check_limit!(255u16, high) == LimitThresholdCrossed::None);
5338
5339 assert!(matches!(
5340 check_limit!(2550000u64, high),
5341 LimitThresholdCrossed::Hard(2550000, 10000)
5342 ));
5343 }
5344
5345 #[test]
5346 fn linkage_amendments_load() {
5347 let mainnet = LazyLock::force(&MAINNET_LINKAGE_AMENDMENTS);
5348 let testnet = LazyLock::force(&TESTNET_LINKAGE_AMENDMENTS);
5349 assert!(!mainnet.is_empty(), "mainnet amendments must not be empty");
5350 assert!(!testnet.is_empty(), "testnet amendments must not be empty");
5351 }
5352
5353 #[test]
5354 fn render_scalar_fields_use_precision_safe_encoding() {
5355 use mysten_common::rpc_format::Unmetered;
5356
5357 let config = ProtocolConfig::get_for_max_version_UNSAFE();
5358 let rendered = config
5359 .render::<serde_json::Value>(&mut Unmetered)
5360 .expect("render should succeed");
5361
5362 let max_args = rendered
5363 .get("max_arguments")
5364 .expect("max_arguments set at max version");
5365 assert!(
5366 max_args.is_number(),
5367 "u32 should render as number, got {max_args:?}",
5368 );
5369
5370 let max_tx_size = rendered
5371 .get("max_tx_size_bytes")
5372 .expect("max_tx_size_bytes set at max version");
5373 assert!(
5374 max_tx_size.is_string(),
5375 "u64 should render as string, got {max_tx_size:?}",
5376 );
5377 }
5378
5379 #[test]
5380 fn render_includes_non_scalar_gasless_allowlist_as_json() {
5381 use mysten_common::rpc_format::Unmetered;
5382 use serde_json::json;
5383
5384 let mut config = ProtocolConfig::get_for_max_version_UNSAFE();
5385 config.set_gasless_allowed_token_types_for_testing(vec![
5386 ("0xa::usdc::USDC".to_string(), 10_000),
5387 ("0xb::usdt::USDT".to_string(), 0),
5388 ]);
5389
5390 let rendered = config
5391 .render::<serde_json::Value>(&mut Unmetered)
5392 .expect("render should succeed under Unmetered budget");
5393 let allowlist = rendered
5394 .get("gasless_allowed_token_types")
5395 .expect("entry should be present after the testing setter");
5396
5397 assert_eq!(
5400 allowlist,
5401 &json!([["0xa::usdc::USDC", "10000"], ["0xb::usdt::USDT", "0"],]),
5402 );
5403 }
5404
5405 #[test]
5406 fn render_targets_prost_value_for_grpc() {
5407 use mysten_common::rpc_format::Unmetered;
5408 use prost_types::value::Kind;
5409
5410 let mut config = ProtocolConfig::get_for_max_version_UNSAFE();
5411 config.set_gasless_allowed_token_types_for_testing(vec![(
5412 "0xa::usdc::USDC".to_string(),
5413 10_000,
5414 )]);
5415
5416 let rendered = config
5417 .render::<prost_types::Value>(&mut Unmetered)
5418 .expect("render to prost Value should succeed");
5419 let allowlist = rendered
5420 .get("gasless_allowed_token_types")
5421 .expect("entry should be present after the testing setter");
5422
5423 let Some(Kind::ListValue(outer)) = &allowlist.kind else {
5425 panic!(
5426 "expected ListValue at the top level, got {:?}",
5427 allowlist.kind
5428 );
5429 };
5430 assert_eq!(outer.values.len(), 1, "one allowlisted entry");
5431 let Some(Kind::ListValue(entry)) = &outer.values[0].kind else {
5432 panic!("expected each entry to be a ListValue");
5433 };
5434 assert_eq!(entry.values.len(), 2, "entry has (coin_type, amount)");
5435
5436 let Some(Kind::StringValue(coin_type)) = &entry.values[0].kind else {
5437 panic!("expected coin_type as StringValue");
5438 };
5439 assert_eq!(coin_type, "0xa::usdc::USDC");
5440
5441 let Some(Kind::StringValue(amount)) = &entry.values[1].kind else {
5443 panic!(
5444 "expected minimum_transfer_amount as StringValue (precision-safe u64); got {:?}",
5445 entry.values[1].kind,
5446 );
5447 };
5448 assert_eq!(amount, "10000");
5449 }
5450
5451 #[test]
5452 fn render_emits_null_for_unset_protocol_versions() {
5453 use mysten_common::rpc_format::Unmetered;
5454
5455 let config = ProtocolConfig::get_for_version(1.into(), Chain::Unknown);
5456 let rendered = config
5457 .render::<serde_json::Value>(&mut Unmetered)
5458 .expect("render should succeed");
5459 let entry = rendered
5463 .get("gasless_allowed_token_types")
5464 .expect("key should be present for every protocol version");
5465 assert!(
5466 entry.is_null(),
5467 "value should be null for pre-feature protocol version, got {entry:?}",
5468 );
5469 }
5470}