1use std::{
5 collections::{BTreeMap, BTreeSet},
6 sync::{
7 Arc, LazyLock,
8 atomic::{AtomicBool, Ordering},
9 },
10};
11
12use std::sync::Mutex;
13
14use clap::*;
15use fastcrypto::encoding::{Base58, Encoding, Hex};
16use move_binary_format::{
17 binary_config::{BinaryConfig, TableConfig},
18 file_format_common::VERSION_1,
19};
20use move_core_types::account_address::AccountAddress;
21use move_vm_config::verifier::VerifierConfig;
22use mysten_common::in_integration_test;
23use serde::{Deserialize, Serialize};
24use serde_with::skip_serializing_none;
25use sui_protocol_config_macros::{
26 ProtocolConfigAccessors, ProtocolConfigFeatureFlagsGetters, ProtocolConfigOverride,
27};
28use tracing::{info, warn};
29
30const MIN_PROTOCOL_VERSION: u64 = 1;
32const MAX_PROTOCOL_VERSION: u64 = 133;
33
34const TESTNET_USDC: &str =
35 "0xa1ec7fc00a6f40db9693ad1415d0c193ad3906494428cf252621037bd7117e29::usdc::USDC";
36
37const MAINNET_USDC: &str =
38 "0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC";
39const MAINNET_USDSUI: &str =
40 "0x44f838219cf67b058f3b37907b655f226153c18e33dfcd0da559a844fea9b1c1::usdsui::USDSUI";
41const MAINNET_SUI_USDE: &str =
42 "0x41d587e5336f1c86cad50d38a7136db99333bb9bda91cea4ba69115defeb1402::sui_usde::SUI_USDE";
43const MAINNET_USDY: &str =
44 "0x960b531667636f39e85867775f52f6b1f220a058c4de786905bdf761e06a56bb::usdy::USDY";
45const MAINNET_FDUSD: &str =
46 "0xf16e6b723f242ec745dfd7634ad072c42d5c1d9ac9d62a39c381303eaa57693a::fdusd::FDUSD";
47const MAINNET_AUSD: &str =
48 "0x2053d08c1e2bd02791056171aab0fd12bd7cd7efad2ab8f6b9c8902f14df2ff2::ausd::AUSD";
49const MAINNET_USDB: &str =
50 "0xe14726c336e81b32328e92afc37345d159f5b550b09fa92bd43640cfdd0a0cfd::usdb::USDB";
51
52#[derive(Copy, Clone, Debug, Hash, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)]
379pub struct ProtocolVersion(u64);
380
381impl ProtocolVersion {
382 pub const MIN: Self = Self(MIN_PROTOCOL_VERSION);
387
388 pub const MAX: Self = Self(MAX_PROTOCOL_VERSION);
389
390 #[cfg(not(msim))]
391 pub const MAX_ALLOWED: Self = Self::MAX;
392
393 #[cfg(msim)]
395 pub const MAX_ALLOWED: Self = Self(MAX_PROTOCOL_VERSION + 1);
396
397 pub fn new(v: u64) -> Self {
398 Self(v)
399 }
400
401 pub const fn as_u64(&self) -> u64 {
402 self.0
403 }
404
405 pub fn max() -> Self {
408 Self::MAX
409 }
410
411 pub fn prev(self) -> Self {
412 Self(self.0.checked_sub(1).unwrap())
413 }
414}
415
416impl From<u64> for ProtocolVersion {
417 fn from(v: u64) -> Self {
418 Self::new(v)
419 }
420}
421
422impl std::ops::Sub<u64> for ProtocolVersion {
423 type Output = Self;
424 fn sub(self, rhs: u64) -> Self::Output {
425 Self::new(self.0 - rhs)
426 }
427}
428
429impl std::ops::Add<u64> for ProtocolVersion {
430 type Output = Self;
431 fn add(self, rhs: u64) -> Self::Output {
432 Self::new(self.0 + rhs)
433 }
434}
435
436#[derive(
437 Clone, Serialize, Deserialize, Debug, Default, PartialEq, Copy, PartialOrd, Ord, Eq, ValueEnum,
438)]
439pub enum Chain {
440 Mainnet,
441 Testnet,
442 #[default]
443 Unknown,
444}
445
446impl Chain {
447 pub fn as_str(self) -> &'static str {
448 match self {
449 Chain::Mainnet => "mainnet",
450 Chain::Testnet => "testnet",
451 Chain::Unknown => "unknown",
452 }
453 }
454}
455
456pub struct Error(pub String);
457
458#[derive(Default, Clone, Serialize, Deserialize, Debug, ProtocolConfigFeatureFlagsGetters)]
461struct FeatureFlags {
462 #[serde(skip_serializing_if = "is_false")]
465 package_upgrades: bool,
466 #[serde(skip_serializing_if = "is_false")]
469 commit_root_state_digest: bool,
470 #[serde(skip_serializing_if = "is_false")]
472 advance_epoch_start_time_in_safe_mode: bool,
473 #[serde(skip_serializing_if = "is_false")]
476 loaded_child_objects_fixed: bool,
477 #[serde(skip_serializing_if = "is_false")]
480 missing_type_is_compatibility_error: bool,
481 #[serde(skip_serializing_if = "is_false")]
484 scoring_decision_with_validity_cutoff: bool,
485
486 #[serde(skip_serializing_if = "is_false")]
489 consensus_order_end_of_epoch_last: bool,
490
491 #[serde(skip_serializing_if = "is_false")]
493 disallow_adding_abilities_on_upgrade: bool,
494 #[serde(skip_serializing_if = "is_false")]
496 disable_invariant_violation_check_in_swap_loc: bool,
497 #[serde(skip_serializing_if = "is_false")]
500 advance_to_highest_supported_protocol_version: bool,
501 #[serde(skip_serializing_if = "is_false")]
503 ban_entry_init: bool,
504 #[serde(skip_serializing_if = "is_false")]
506 package_digest_hash_module: bool,
507 #[serde(skip_serializing_if = "is_false")]
509 disallow_change_struct_type_params_on_upgrade: bool,
510 #[serde(skip_serializing_if = "is_false")]
512 no_extraneous_module_bytes: bool,
513 #[serde(skip_serializing_if = "is_false")]
515 narwhal_versioned_metadata: bool,
516
517 #[serde(skip_serializing_if = "is_false")]
519 zklogin_auth: bool,
520 #[serde(skip_serializing_if = "is_zero")]
523 zklogin_circuit_mode: u64,
524 #[serde(skip_serializing_if = "ConsensusTransactionOrdering::is_none")]
526 consensus_transaction_ordering: ConsensusTransactionOrdering,
527
528 #[serde(skip_serializing_if = "is_false")]
536 simplified_unwrap_then_delete: bool,
537 #[serde(skip_serializing_if = "is_false")]
539 upgraded_multisig_supported: bool,
540 #[serde(skip_serializing_if = "is_false")]
542 txn_base_cost_as_multiplier: bool,
543
544 #[serde(skip_serializing_if = "is_false")]
546 shared_object_deletion: bool,
547
548 #[serde(skip_serializing_if = "is_false")]
550 narwhal_new_leader_election_schedule: bool,
551
552 #[serde(skip_serializing_if = "is_empty")]
554 zklogin_supported_providers: BTreeSet<String>,
555
556 #[serde(skip_serializing_if = "is_false")]
558 loaded_child_object_format: bool,
559
560 #[serde(skip_serializing_if = "is_false")]
561 #[skip_protocol_config_accessor]
562 enable_jwk_consensus_updates: bool,
563
564 #[serde(skip_serializing_if = "is_false")]
565 #[skip_protocol_config_accessor]
566 end_of_epoch_transaction_supported: bool,
567
568 #[serde(skip_serializing_if = "is_false")]
571 simple_conservation_checks: bool,
572
573 #[serde(skip_serializing_if = "is_false")]
575 loaded_child_object_format_type: bool,
576
577 #[serde(skip_serializing_if = "is_false")]
579 receive_objects: bool,
580
581 #[serde(skip_serializing_if = "is_false")]
583 consensus_checkpoint_signature_key_includes_digest: bool,
584
585 #[serde(skip_serializing_if = "is_false")]
587 random_beacon: bool,
588
589 #[serde(skip_serializing_if = "is_false")]
591 #[skip_protocol_config_accessor]
592 bridge: bool,
593
594 #[serde(skip_serializing_if = "is_false")]
595 enable_effects_v2: bool,
596
597 #[serde(skip_serializing_if = "is_false")]
599 narwhal_certificate_v2: bool,
600
601 #[serde(skip_serializing_if = "is_false")]
603 verify_legacy_zklogin_address: bool,
604
605 #[serde(skip_serializing_if = "is_false")]
607 throughput_aware_consensus_submission: bool,
608
609 #[serde(skip_serializing_if = "is_false")]
611 recompute_has_public_transfer_in_execution: bool,
612
613 #[serde(skip_serializing_if = "is_false")]
615 accept_zklogin_in_multisig: bool,
616
617 #[serde(skip_serializing_if = "is_false")]
619 accept_passkey_in_multisig: bool,
620
621 #[serde(skip_serializing_if = "is_false")]
623 validate_zklogin_public_identifier: bool,
624
625 #[serde(skip_serializing_if = "is_false")]
628 include_consensus_digest_in_prologue: bool,
629
630 #[serde(skip_serializing_if = "is_false")]
632 hardened_otw_check: bool,
633
634 #[serde(skip_serializing_if = "is_false")]
636 allow_receiving_object_id: bool,
637
638 #[serde(skip_serializing_if = "is_false")]
640 enable_poseidon: bool,
641
642 #[serde(skip_serializing_if = "is_false")]
644 enable_coin_deny_list: bool,
645
646 #[serde(skip_serializing_if = "is_false")]
648 enable_group_ops_native_functions: bool,
649
650 #[serde(skip_serializing_if = "is_false")]
652 enable_group_ops_native_function_msm: bool,
653
654 #[serde(skip_serializing_if = "is_false")]
656 enable_ristretto255_group_ops: bool,
657
658 #[serde(skip_serializing_if = "is_false")]
660 enable_verify_bulletproofs_ristretto255: bool,
661
662 #[serde(skip_serializing_if = "is_false")]
664 enable_nitro_attestation: bool,
665
666 #[serde(skip_serializing_if = "is_false")]
668 enable_nitro_attestation_upgraded_parsing: bool,
669
670 #[serde(skip_serializing_if = "is_false")]
672 enable_nitro_attestation_all_nonzero_pcrs_parsing: bool,
673
674 #[serde(skip_serializing_if = "is_false")]
676 enable_nitro_attestation_always_include_required_pcrs_parsing: bool,
677
678 #[serde(skip_serializing_if = "is_false")]
680 reject_mutable_random_on_entry_functions: bool,
681
682 #[serde(skip_serializing_if = "PerObjectCongestionControlMode::is_none")]
684 per_object_congestion_control_mode: PerObjectCongestionControlMode,
685
686 #[serde(skip_serializing_if = "ConsensusChoice::is_narwhal")]
688 consensus_choice: ConsensusChoice,
689
690 #[serde(skip_serializing_if = "ConsensusNetwork::is_anemo")]
692 consensus_network: ConsensusNetwork,
693
694 #[serde(skip_serializing_if = "is_false")]
696 correct_gas_payment_limit_check: bool,
697
698 #[serde(skip_serializing_if = "Option::is_none")]
700 zklogin_max_epoch_upper_bound_delta: Option<u64>,
701
702 #[serde(skip_serializing_if = "is_false")]
704 mysticeti_leader_scoring_and_schedule: bool,
705
706 #[serde(skip_serializing_if = "is_false")]
708 reshare_at_same_initial_version: bool,
709
710 #[serde(skip_serializing_if = "is_false")]
712 resolve_abort_locations_to_package_id: bool,
713
714 #[serde(skip_serializing_if = "is_false")]
718 mysticeti_use_committed_subdag_digest: bool,
719
720 #[serde(skip_serializing_if = "is_false")]
722 enable_vdf: bool,
723
724 #[serde(skip_serializing_if = "is_false")]
728 record_consensus_determined_version_assignments_in_prologue: bool,
729 #[serde(skip_serializing_if = "is_false")]
732 record_consensus_determined_version_assignments_in_prologue_v2: bool,
733
734 #[serde(skip_serializing_if = "is_false")]
736 fresh_vm_on_framework_upgrade: bool,
737
738 #[serde(skip_serializing_if = "is_false")]
746 prepend_prologue_tx_in_consensus_commit_in_checkpoints: bool,
747
748 #[serde(skip_serializing_if = "Option::is_none")]
750 mysticeti_num_leaders_per_round: Option<usize>,
751
752 #[serde(skip_serializing_if = "is_false")]
754 soft_bundle: bool,
755
756 #[serde(skip_serializing_if = "is_false")]
758 enable_coin_deny_list_v2: bool,
759
760 #[serde(skip_serializing_if = "is_false")]
762 passkey_auth: bool,
763
764 #[serde(skip_serializing_if = "is_false")]
766 authority_capabilities_v2: bool,
767
768 #[serde(skip_serializing_if = "is_false")]
770 rethrow_serialization_type_layout_errors: bool,
771
772 #[serde(skip_serializing_if = "is_false")]
774 consensus_distributed_vote_scoring_strategy: bool,
775
776 #[serde(skip_serializing_if = "is_false")]
778 consensus_round_prober: bool,
779
780 #[serde(skip_serializing_if = "is_false")]
782 validate_identifier_inputs: bool,
783
784 #[serde(skip_serializing_if = "is_false")]
786 disallow_self_identifier: bool,
787
788 #[serde(skip_serializing_if = "is_false")]
790 mysticeti_fastpath: bool,
791
792 #[serde(skip_serializing_if = "is_false")]
796 disable_preconsensus_locking: bool,
797
798 #[serde(skip_serializing_if = "is_false")]
800 relocate_event_module: bool,
801
802 #[serde(skip_serializing_if = "is_false")]
804 uncompressed_g1_group_elements: bool,
805
806 #[serde(skip_serializing_if = "is_false")]
807 disallow_new_modules_in_deps_only_packages: bool,
808
809 #[serde(skip_serializing_if = "is_false")]
811 consensus_smart_ancestor_selection: bool,
812
813 #[serde(skip_serializing_if = "is_false")]
815 consensus_round_prober_probe_accepted_rounds: bool,
816
817 #[serde(skip_serializing_if = "is_false")]
819 native_charging_v2: bool,
820
821 #[serde(skip_serializing_if = "is_false")]
824 #[skip_protocol_config_accessor]
825 consensus_linearize_subdag_v2: bool,
826
827 #[serde(skip_serializing_if = "is_false")]
829 convert_type_argument_error: bool,
830
831 #[serde(skip_serializing_if = "is_false")]
833 variant_nodes: bool,
834
835 #[serde(skip_serializing_if = "is_false")]
837 consensus_zstd_compression: bool,
838
839 #[serde(skip_serializing_if = "is_false")]
841 minimize_child_object_mutations: bool,
842
843 #[serde(skip_serializing_if = "is_false")]
846 record_additional_state_digest_in_prologue: bool,
847
848 #[serde(skip_serializing_if = "is_false")]
850 move_native_context: bool,
851
852 #[serde(skip_serializing_if = "is_false")]
855 #[skip_protocol_config_accessor]
856 consensus_median_based_commit_timestamp: bool,
857
858 #[serde(skip_serializing_if = "is_false")]
861 normalize_ptb_arguments: bool,
862
863 #[serde(skip_serializing_if = "is_false")]
865 consensus_batched_block_sync: bool,
866
867 #[serde(skip_serializing_if = "is_false")]
869 enforce_checkpoint_timestamp_monotonicity: bool,
870
871 #[serde(skip_serializing_if = "is_false")]
873 max_ptb_value_size_v2: bool,
874
875 #[serde(skip_serializing_if = "is_false")]
877 resolve_type_input_ids_to_defining_id: bool,
878
879 #[serde(skip_serializing_if = "is_false")]
881 enable_party_transfer: bool,
882
883 #[serde(skip_serializing_if = "is_false")]
885 allow_unbounded_system_objects: bool,
886
887 #[serde(skip_serializing_if = "is_false")]
889 type_tags_in_object_runtime: bool,
890
891 #[serde(skip_serializing_if = "is_false")]
893 enable_accumulators: bool,
894
895 #[serde(skip_serializing_if = "is_false")]
897 #[skip_protocol_config_accessor]
898 enable_coin_reservation_obj_refs: bool,
899
900 #[serde(skip_serializing_if = "is_false")]
903 create_root_accumulator_object: bool,
904
905 #[serde(skip_serializing_if = "is_false")]
907 #[skip_protocol_config_accessor]
908 enable_authenticated_event_streams: bool,
909
910 #[serde(skip_serializing_if = "is_false")]
912 enable_address_balance_gas_payments: bool,
913
914 #[serde(skip_serializing_if = "is_false")]
916 address_balance_gas_check_rgp_at_signing: bool,
917
918 #[serde(skip_serializing_if = "is_false")]
919 address_balance_gas_reject_gas_coin_arg: bool,
920
921 #[serde(skip_serializing_if = "is_false")]
923 enable_multi_epoch_transaction_expiration: bool,
924
925 #[serde(skip_serializing_if = "is_false")]
927 relax_valid_during_for_owned_inputs: bool,
928
929 #[serde(skip_serializing_if = "is_false")]
931 enable_ptb_execution_v2: bool,
932
933 #[serde(skip_serializing_if = "is_false")]
935 better_adapter_type_resolution_errors: bool,
936
937 #[serde(skip_serializing_if = "is_false")]
939 record_time_estimate_processed: bool,
940
941 #[serde(skip_serializing_if = "is_false")]
943 dependency_linkage_error: bool,
944
945 #[serde(skip_serializing_if = "is_false")]
947 additional_multisig_checks: bool,
948
949 #[serde(skip_serializing_if = "is_false")]
951 ignore_execution_time_observations_after_certs_closed: bool,
952
953 #[serde(skip_serializing_if = "is_false")]
957 debug_fatal_on_move_invariant_violation: bool,
958
959 #[serde(skip_serializing_if = "is_false")]
962 allow_private_accumulator_entrypoints: bool,
963
964 #[serde(skip_serializing_if = "is_false")]
967 additional_consensus_digest_indirect_state: bool,
968
969 #[serde(skip_serializing_if = "is_false")]
971 check_for_init_during_upgrade: bool,
972
973 #[serde(skip_serializing_if = "is_false")]
975 enable_init_on_upgrade: bool,
976
977 #[serde(skip_serializing_if = "is_false")]
979 enable_order_independent_upgrade_init_linkage: bool,
980
981 #[serde(skip_serializing_if = "is_false")]
983 per_command_shared_object_transfer_rules: bool,
984
985 #[serde(skip_serializing_if = "is_false")]
987 include_checkpoint_artifacts_digest_in_summary: bool,
988
989 #[serde(skip_serializing_if = "is_false")]
991 use_mfp_txns_in_load_initial_object_debts: bool,
992
993 #[serde(skip_serializing_if = "is_false")]
995 cancel_for_failed_dkg_early: bool,
996
997 #[serde(skip_serializing_if = "is_false")]
999 always_advance_dkg_to_resolution: bool,
1000
1001 #[serde(skip_serializing_if = "is_false")]
1003 enable_coin_registry: bool,
1004
1005 #[serde(skip_serializing_if = "is_false")]
1007 abstract_size_in_object_runtime: bool,
1008
1009 #[serde(skip_serializing_if = "is_false")]
1011 object_runtime_charge_cache_load_gas: bool,
1012
1013 #[serde(skip_serializing_if = "is_false")]
1015 additional_borrow_checks: bool,
1016
1017 #[serde(skip_serializing_if = "is_false")]
1019 use_new_commit_handler: bool,
1020
1021 #[serde(skip_serializing_if = "is_false")]
1023 better_loader_errors: bool,
1024
1025 #[serde(skip_serializing_if = "is_false")]
1027 generate_df_type_layouts: bool,
1028
1029 #[serde(skip_serializing_if = "is_false")]
1031 allow_references_in_ptbs: bool,
1032
1033 #[serde(skip_serializing_if = "is_false")]
1040 framework_tx_context_mut_restrictions: bool,
1041
1042 #[serde(skip_serializing_if = "is_false")]
1044 enable_display_registry: bool,
1045
1046 #[serde(skip_serializing_if = "is_false")]
1048 private_generics_verifier_v2: bool,
1049
1050 #[serde(skip_serializing_if = "is_false")]
1052 deprecate_global_storage_ops_during_deserialization: bool,
1053
1054 #[serde(skip_serializing_if = "is_false")]
1057 enable_non_exclusive_writes: bool,
1058
1059 #[serde(skip_serializing_if = "is_false")]
1061 deprecate_global_storage_ops: bool,
1062
1063 #[serde(skip_serializing_if = "is_false")]
1065 normalize_depth_formula: bool,
1066
1067 #[serde(skip_serializing_if = "is_false")]
1069 consensus_skip_gced_accept_votes: bool,
1070
1071 #[serde(skip_serializing_if = "is_false")]
1074 include_cancelled_randomness_txns_in_prologue: bool,
1075
1076 #[serde(skip_serializing_if = "is_false")]
1078 #[skip_protocol_config_accessor]
1079 address_aliases: bool,
1080
1081 #[serde(skip_serializing_if = "is_false")]
1083 create_forwarding_address_registry: bool,
1084
1085 #[serde(skip_serializing_if = "is_false")]
1088 fix_checkpoint_signature_mapping: bool,
1089
1090 #[serde(skip_serializing_if = "is_false")]
1092 enable_object_funds_withdraw: bool,
1093
1094 #[serde(skip_serializing_if = "is_false")]
1097 record_net_unsettled_object_withdraws: bool,
1098
1099 #[serde(skip_serializing_if = "is_false")]
1101 consensus_skip_gced_blocks_in_direct_finalization: bool,
1102
1103 #[serde(skip_serializing_if = "is_false")]
1105 gas_rounding_halve_digits: bool,
1106
1107 #[serde(skip_serializing_if = "is_false")]
1109 flexible_tx_context_positions: bool,
1110
1111 #[serde(skip_serializing_if = "is_false")]
1113 disable_entry_point_signature_check: bool,
1114
1115 #[serde(skip_serializing_if = "is_false")]
1117 convert_withdrawal_compatibility_ptb_arguments: bool,
1118
1119 #[serde(skip_serializing_if = "is_false")]
1121 restrict_hot_or_not_entry_functions: bool,
1122
1123 #[serde(skip_serializing_if = "is_false")]
1125 split_checkpoints_in_consensus_handler: bool,
1126
1127 #[serde(skip_serializing_if = "is_false")]
1129 consensus_always_accept_system_transactions: bool,
1130
1131 #[serde(skip_serializing_if = "is_false")]
1133 validator_metadata_verify_v2: bool,
1134
1135 #[serde(skip_serializing_if = "is_false")]
1138 defer_unpaid_amplification: bool,
1139
1140 #[serde(skip_serializing_if = "is_false")]
1143 defer_owned_object_double_spend: bool,
1144
1145 #[serde(skip_serializing_if = "is_false")]
1146 randomize_checkpoint_tx_limit_in_tests: bool,
1147
1148 #[serde(skip_serializing_if = "is_false")]
1150 gasless_transaction_drop_safety: bool,
1151
1152 #[serde(skip_serializing_if = "is_false")]
1155 merge_randomness_into_checkpoint: bool,
1156
1157 #[serde(skip_serializing_if = "is_false")]
1159 use_coin_party_owner: bool,
1160
1161 #[serde(skip_serializing_if = "is_false")]
1162 enable_gasless: bool,
1163
1164 #[serde(skip_serializing_if = "is_false")]
1165 gasless_verify_remaining_balance: bool,
1166
1167 #[serde(skip_serializing_if = "is_false")]
1168 disallow_jump_orphans: bool,
1169
1170 #[serde(skip_serializing_if = "is_false")]
1172 early_return_receive_object_mismatched_type: bool,
1173
1174 #[serde(skip_serializing_if = "is_false")]
1179 timestamp_based_epoch_close: bool,
1180
1181 #[serde(skip_serializing_if = "is_false")]
1184 limit_groth16_pvk_inputs: bool,
1185
1186 #[serde(skip_serializing_if = "is_false")]
1191 enforce_address_balance_change_invariant: bool,
1192
1193 #[serde(skip_serializing_if = "is_false")]
1195 share_transaction_deny_config_in_consensus: bool,
1196
1197 #[serde(skip_serializing_if = "is_false")]
1199 granular_post_execution_checks: bool,
1200
1201 #[serde(skip_serializing_if = "is_false")]
1203 early_exit_on_iffw: bool,
1204
1205 #[serde(skip_serializing_if = "is_false")]
1207 enable_unified_linkage: bool,
1208}
1209
1210fn is_false(b: &bool) -> bool {
1211 !b
1212}
1213
1214fn is_empty(b: &BTreeSet<String>) -> bool {
1215 b.is_empty()
1216}
1217
1218fn is_zero(val: &u64) -> bool {
1219 *val == 0
1220}
1221
1222#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1224pub enum ConsensusTransactionOrdering {
1225 #[default]
1227 None,
1228 ByGasPrice,
1230}
1231
1232impl ConsensusTransactionOrdering {
1233 pub fn is_none(&self) -> bool {
1234 matches!(self, ConsensusTransactionOrdering::None)
1235 }
1236}
1237
1238#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1239pub struct ExecutionTimeEstimateParams {
1240 pub target_utilization: u64,
1242 pub allowed_txn_cost_overage_burst_limit_us: u64,
1246
1247 pub randomness_scalar: u64,
1250
1251 pub max_estimate_us: u64,
1253
1254 pub stored_observations_num_included_checkpoints: u64,
1257
1258 pub stored_observations_limit: u64,
1260
1261 #[serde(skip_serializing_if = "is_zero")]
1264 pub stake_weighted_median_threshold: u64,
1265
1266 #[serde(skip_serializing_if = "is_false")]
1270 pub default_none_duration_for_new_keys: bool,
1271
1272 #[serde(skip_serializing_if = "Option::is_none")]
1274 pub observations_chunk_size: Option<u64>,
1275}
1276
1277#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1279pub enum PerObjectCongestionControlMode {
1280 #[default]
1281 None, TotalGasBudget, TotalTxCount, TotalGasBudgetWithCap, ExecutionTimeEstimate(ExecutionTimeEstimateParams), }
1287
1288impl PerObjectCongestionControlMode {
1289 pub fn is_none(&self) -> bool {
1290 matches!(self, PerObjectCongestionControlMode::None)
1291 }
1292}
1293
1294#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1296pub enum ConsensusChoice {
1297 #[default]
1298 Narwhal,
1299 SwapEachEpoch,
1300 Mysticeti,
1301}
1302
1303impl ConsensusChoice {
1304 pub fn is_narwhal(&self) -> bool {
1305 matches!(self, ConsensusChoice::Narwhal)
1306 }
1307}
1308
1309#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1311pub enum ConsensusNetwork {
1312 #[default]
1313 Anemo,
1314 Tonic,
1315}
1316
1317impl ConsensusNetwork {
1318 pub fn is_anemo(&self) -> bool {
1319 matches!(self, ConsensusNetwork::Anemo)
1320 }
1321}
1322
1323#[skip_serializing_none]
1355#[derive(Clone, Serialize, Debug, ProtocolConfigAccessors, ProtocolConfigOverride)]
1356pub struct ProtocolConfig {
1357 pub version: ProtocolVersion,
1358
1359 #[serde(skip)]
1364 chain: Chain,
1365
1366 feature_flags: FeatureFlags,
1367
1368 max_tx_size_bytes: Option<u64>,
1371
1372 max_input_objects: Option<u64>,
1374
1375 max_size_written_objects: Option<u64>,
1379 max_size_written_objects_system_tx: Option<u64>,
1382
1383 max_serialized_tx_effects_size_bytes: Option<u64>,
1385
1386 max_serialized_tx_effects_size_bytes_system_tx: Option<u64>,
1388
1389 max_gas_payment_objects: Option<u32>,
1391
1392 max_modules_in_publish: Option<u32>,
1394
1395 max_package_dependencies: Option<u32>,
1397
1398 max_arguments: Option<u32>,
1401
1402 max_type_arguments: Option<u32>,
1404
1405 max_type_argument_depth: Option<u32>,
1407
1408 max_pure_argument_size: Option<u32>,
1410
1411 max_programmable_tx_commands: Option<u32>,
1413
1414 move_binary_format_version: Option<u32>,
1417 min_move_binary_format_version: Option<u32>,
1418
1419 binary_module_handles: Option<u16>,
1421 binary_struct_handles: Option<u16>,
1422 binary_function_handles: Option<u16>,
1423 binary_function_instantiations: Option<u16>,
1424 binary_signatures: Option<u16>,
1425 binary_constant_pool: Option<u16>,
1426 binary_identifiers: Option<u16>,
1427 binary_address_identifiers: Option<u16>,
1428 binary_struct_defs: Option<u16>,
1429 binary_struct_def_instantiations: Option<u16>,
1430 binary_function_defs: Option<u16>,
1431 binary_field_handles: Option<u16>,
1432 binary_field_instantiations: Option<u16>,
1433 binary_friend_decls: Option<u16>,
1434 binary_enum_defs: Option<u16>,
1435 binary_enum_def_instantiations: Option<u16>,
1436 binary_variant_handles: Option<u16>,
1437 binary_variant_instantiation_handles: Option<u16>,
1438
1439 max_move_object_size: Option<u64>,
1441
1442 max_move_package_size: Option<u64>,
1445
1446 max_publish_or_upgrade_per_ptb: Option<u64>,
1448
1449 max_tx_gas: Option<u64>,
1451
1452 max_gas_price: Option<u64>,
1454
1455 max_gas_price_rgp_factor_for_aborted_transactions: Option<u64>,
1458
1459 max_gas_computation_bucket: Option<u64>,
1461
1462 gas_rounding_step: Option<u64>,
1464
1465 max_loop_depth: Option<u64>,
1467
1468 max_generic_instantiation_length: Option<u64>,
1470
1471 max_function_parameters: Option<u64>,
1473
1474 max_basic_blocks: Option<u64>,
1476
1477 max_value_stack_size: Option<u64>,
1479
1480 max_type_nodes: Option<u64>,
1482
1483 max_generic_instantiation_type_nodes_per_function: Option<u64>,
1485
1486 max_generic_instantiation_type_nodes_per_module: Option<u64>,
1488
1489 max_push_size: Option<u64>,
1491
1492 max_struct_definitions: Option<u64>,
1494
1495 max_function_definitions: Option<u64>,
1497
1498 max_fields_in_struct: Option<u64>,
1500
1501 max_dependency_depth: Option<u64>,
1503
1504 max_num_event_emit: Option<u64>,
1506
1507 max_num_new_move_object_ids: Option<u64>,
1509
1510 max_num_new_move_object_ids_system_tx: Option<u64>,
1512
1513 max_num_deleted_move_object_ids: Option<u64>,
1515
1516 max_num_deleted_move_object_ids_system_tx: Option<u64>,
1518
1519 max_num_transferred_move_object_ids: Option<u64>,
1521
1522 max_num_transferred_move_object_ids_system_tx: Option<u64>,
1524
1525 max_event_emit_size: Option<u64>,
1527
1528 max_event_emit_size_total: Option<u64>,
1530
1531 max_move_vector_len: Option<u64>,
1533
1534 max_move_identifier_len: Option<u64>,
1536
1537 max_move_value_depth: Option<u64>,
1539
1540 max_move_enum_variants: Option<u64>,
1542
1543 max_back_edges_per_function: Option<u64>,
1545
1546 max_back_edges_per_module: Option<u64>,
1548
1549 max_verifier_meter_ticks_per_function: Option<u64>,
1551
1552 max_meter_ticks_per_module: Option<u64>,
1554
1555 max_meter_ticks_per_package: Option<u64>,
1557
1558 object_runtime_max_num_cached_objects: Option<u64>,
1562
1563 object_runtime_max_num_cached_objects_system_tx: Option<u64>,
1565
1566 object_runtime_max_num_store_entries: Option<u64>,
1568
1569 object_runtime_max_num_store_entries_system_tx: Option<u64>,
1571
1572 base_tx_cost_fixed: Option<u64>,
1575
1576 package_publish_cost_fixed: Option<u64>,
1579
1580 base_tx_cost_per_byte: Option<u64>,
1583
1584 package_publish_cost_per_byte: Option<u64>,
1586
1587 obj_access_cost_read_per_byte: Option<u64>,
1589
1590 obj_access_cost_mutate_per_byte: Option<u64>,
1592
1593 obj_access_cost_delete_per_byte: Option<u64>,
1595
1596 obj_access_cost_verify_per_byte: Option<u64>,
1606
1607 max_type_to_layout_nodes: Option<u64>,
1609
1610 max_ptb_value_size: Option<u64>,
1612
1613 gas_model_version: Option<u64>,
1616
1617 obj_data_cost_refundable: Option<u64>,
1620
1621 obj_metadata_cost_non_refundable: Option<u64>,
1625
1626 storage_rebate_rate: Option<u64>,
1632
1633 storage_fund_reinvest_rate: Option<u64>,
1636
1637 reward_slashing_rate: Option<u64>,
1640
1641 storage_gas_price: Option<u64>,
1643
1644 accumulator_object_storage_cost: Option<u64>,
1646
1647 max_transactions_per_checkpoint: Option<u64>,
1652
1653 max_checkpoint_size_bytes: Option<u64>,
1657
1658 buffer_stake_for_protocol_upgrade_bps: Option<u64>,
1663
1664 address_from_bytes_cost_base: Option<u64>,
1669 address_to_u256_cost_base: Option<u64>,
1671 address_from_u256_cost_base: Option<u64>,
1673
1674 config_read_setting_impl_cost_base: Option<u64>,
1679 config_read_setting_impl_cost_per_byte: Option<u64>,
1680
1681 package_original_package_id_impl_cost_base: Option<u64>,
1682 package_original_package_id_impl_cost_per_byte: Option<u64>,
1683
1684 dynamic_field_hash_type_and_key_cost_base: Option<u64>,
1687 dynamic_field_hash_type_and_key_type_cost_per_byte: Option<u64>,
1688 dynamic_field_hash_type_and_key_value_cost_per_byte: Option<u64>,
1689 dynamic_field_hash_type_and_key_type_tag_cost_per_byte: Option<u64>,
1690 dynamic_field_add_child_object_cost_base: Option<u64>,
1692 dynamic_field_add_child_object_type_cost_per_byte: Option<u64>,
1693 dynamic_field_add_child_object_value_cost_per_byte: Option<u64>,
1694 dynamic_field_add_child_object_struct_tag_cost_per_byte: Option<u64>,
1695 dynamic_field_borrow_child_object_cost_base: Option<u64>,
1697 dynamic_field_borrow_child_object_child_ref_cost_per_byte: Option<u64>,
1698 dynamic_field_borrow_child_object_type_cost_per_byte: Option<u64>,
1699 dynamic_field_remove_child_object_cost_base: Option<u64>,
1701 dynamic_field_remove_child_object_child_cost_per_byte: Option<u64>,
1702 dynamic_field_remove_child_object_type_cost_per_byte: Option<u64>,
1703 dynamic_field_has_child_object_cost_base: Option<u64>,
1705 dynamic_field_has_child_object_with_ty_cost_base: Option<u64>,
1707 dynamic_field_has_child_object_with_ty_type_cost_per_byte: Option<u64>,
1708 dynamic_field_has_child_object_with_ty_type_tag_cost_per_byte: Option<u64>,
1709
1710 scratch_add_cost_base: Option<u64>,
1713 scratch_read_cost_base: Option<u64>,
1715 scratch_read_value_cost: Option<u64>,
1716 scratch_remove_cost_base: Option<u64>,
1718 scratch_exists_cost_base: Option<u64>,
1720 scratch_exists_with_type_cost_base: Option<u64>,
1722 scratch_exists_with_type_type_cost: Option<u64>,
1723 max_scratch_pad_size: Option<u64>,
1725
1726 event_emit_cost_base: Option<u64>,
1729 event_emit_value_size_derivation_cost_per_byte: Option<u64>,
1730 event_emit_tag_size_derivation_cost_per_byte: Option<u64>,
1731 event_emit_output_cost_per_byte: Option<u64>,
1732 event_emit_auth_stream_cost: Option<u64>,
1733
1734 object_borrow_uid_cost_base: Option<u64>,
1737 object_delete_impl_cost_base: Option<u64>,
1739 object_record_new_uid_cost_base: Option<u64>,
1741 object_record_new_uid_from_hash_cost_base: Option<u64>,
1744
1745 transfer_transfer_internal_cost_base: Option<u64>,
1748 transfer_party_transfer_internal_cost_base: Option<u64>,
1750 transfer_freeze_object_cost_base: Option<u64>,
1752 transfer_share_object_cost_base: Option<u64>,
1754 transfer_receive_object_cost_base: Option<u64>,
1757 transfer_receive_object_cost_per_byte: Option<u64>,
1758 transfer_receive_object_type_cost_per_byte: Option<u64>,
1759
1760 tx_context_derive_id_cost_base: Option<u64>,
1763 tx_context_fresh_id_cost_base: Option<u64>,
1764 tx_context_sender_cost_base: Option<u64>,
1765 tx_context_epoch_cost_base: Option<u64>,
1766 tx_context_epoch_timestamp_ms_cost_base: Option<u64>,
1767 tx_context_sponsor_cost_base: Option<u64>,
1768 tx_context_rgp_cost_base: Option<u64>,
1769 tx_context_gas_price_cost_base: Option<u64>,
1770 tx_context_gas_budget_cost_base: Option<u64>,
1771 tx_context_ids_created_cost_base: Option<u64>,
1772 tx_context_replace_cost_base: Option<u64>,
1773
1774 types_is_one_time_witness_cost_base: Option<u64>,
1777 types_is_one_time_witness_type_tag_cost_per_byte: Option<u64>,
1778 types_is_one_time_witness_type_cost_per_byte: Option<u64>,
1779
1780 validator_validate_metadata_cost_base: Option<u64>,
1783 validator_validate_metadata_data_cost_per_byte: Option<u64>,
1784
1785 crypto_invalid_arguments_cost: Option<u64>,
1787 bls12381_bls12381_min_sig_verify_cost_base: Option<u64>,
1789 bls12381_bls12381_min_sig_verify_msg_cost_per_byte: Option<u64>,
1790 bls12381_bls12381_min_sig_verify_msg_cost_per_block: Option<u64>,
1791
1792 bls12381_bls12381_min_pk_verify_cost_base: Option<u64>,
1794 bls12381_bls12381_min_pk_verify_msg_cost_per_byte: Option<u64>,
1795 bls12381_bls12381_min_pk_verify_msg_cost_per_block: Option<u64>,
1796
1797 ecdsa_k1_ecrecover_keccak256_cost_base: Option<u64>,
1799 ecdsa_k1_ecrecover_keccak256_msg_cost_per_byte: Option<u64>,
1800 ecdsa_k1_ecrecover_keccak256_msg_cost_per_block: Option<u64>,
1801 ecdsa_k1_ecrecover_sha256_cost_base: Option<u64>,
1802 ecdsa_k1_ecrecover_sha256_msg_cost_per_byte: Option<u64>,
1803 ecdsa_k1_ecrecover_sha256_msg_cost_per_block: Option<u64>,
1804
1805 ecdsa_k1_decompress_pubkey_cost_base: Option<u64>,
1807
1808 ecdsa_k1_secp256k1_verify_keccak256_cost_base: Option<u64>,
1810 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_byte: Option<u64>,
1811 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_block: Option<u64>,
1812 ecdsa_k1_secp256k1_verify_sha256_cost_base: Option<u64>,
1813 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_byte: Option<u64>,
1814 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_block: Option<u64>,
1815
1816 ecdsa_r1_ecrecover_keccak256_cost_base: Option<u64>,
1818 ecdsa_r1_ecrecover_keccak256_msg_cost_per_byte: Option<u64>,
1819 ecdsa_r1_ecrecover_keccak256_msg_cost_per_block: Option<u64>,
1820 ecdsa_r1_ecrecover_sha256_cost_base: Option<u64>,
1821 ecdsa_r1_ecrecover_sha256_msg_cost_per_byte: Option<u64>,
1822 ecdsa_r1_ecrecover_sha256_msg_cost_per_block: Option<u64>,
1823
1824 ecdsa_r1_secp256r1_verify_keccak256_cost_base: Option<u64>,
1826 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_byte: Option<u64>,
1827 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_block: Option<u64>,
1828 ecdsa_r1_secp256r1_verify_sha256_cost_base: Option<u64>,
1829 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_byte: Option<u64>,
1830 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_block: Option<u64>,
1831
1832 ecvrf_ecvrf_verify_cost_base: Option<u64>,
1834 ecvrf_ecvrf_verify_alpha_string_cost_per_byte: Option<u64>,
1835 ecvrf_ecvrf_verify_alpha_string_cost_per_block: Option<u64>,
1836
1837 ed25519_ed25519_verify_cost_base: Option<u64>,
1839 ed25519_ed25519_verify_msg_cost_per_byte: Option<u64>,
1840 ed25519_ed25519_verify_msg_cost_per_block: Option<u64>,
1841
1842 groth16_prepare_verifying_key_bls12381_cost_base: Option<u64>,
1844 groth16_prepare_verifying_key_bn254_cost_base: Option<u64>,
1845
1846 groth16_verify_groth16_proof_internal_bls12381_cost_base: Option<u64>,
1848 groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input: Option<u64>,
1849 groth16_verify_groth16_proof_internal_bn254_cost_base: Option<u64>,
1850 groth16_verify_groth16_proof_internal_bn254_cost_per_public_input: Option<u64>,
1851 groth16_verify_groth16_proof_internal_public_input_cost_per_byte: Option<u64>,
1852
1853 hash_blake2b256_cost_base: Option<u64>,
1855 hash_blake2b256_data_cost_per_byte: Option<u64>,
1856 hash_blake2b256_data_cost_per_block: Option<u64>,
1857
1858 hash_keccak256_cost_base: Option<u64>,
1860 hash_keccak256_data_cost_per_byte: Option<u64>,
1861 hash_keccak256_data_cost_per_block: Option<u64>,
1862
1863 poseidon_bn254_cost_base: Option<u64>,
1865 poseidon_bn254_cost_per_block: Option<u64>,
1866
1867 group_ops_bls12381_decode_scalar_cost: Option<u64>,
1869 group_ops_bls12381_decode_g1_cost: Option<u64>,
1870 group_ops_bls12381_decode_g2_cost: Option<u64>,
1871 group_ops_bls12381_decode_gt_cost: Option<u64>,
1872 group_ops_bls12381_scalar_add_cost: Option<u64>,
1873 group_ops_bls12381_g1_add_cost: Option<u64>,
1874 group_ops_bls12381_g2_add_cost: Option<u64>,
1875 group_ops_bls12381_gt_add_cost: Option<u64>,
1876 group_ops_bls12381_scalar_sub_cost: Option<u64>,
1877 group_ops_bls12381_g1_sub_cost: Option<u64>,
1878 group_ops_bls12381_g2_sub_cost: Option<u64>,
1879 group_ops_bls12381_gt_sub_cost: Option<u64>,
1880 group_ops_bls12381_scalar_mul_cost: Option<u64>,
1881 group_ops_bls12381_g1_mul_cost: Option<u64>,
1882 group_ops_bls12381_g2_mul_cost: Option<u64>,
1883 group_ops_bls12381_gt_mul_cost: Option<u64>,
1884 group_ops_bls12381_scalar_div_cost: Option<u64>,
1885 group_ops_bls12381_g1_div_cost: Option<u64>,
1886 group_ops_bls12381_g2_div_cost: Option<u64>,
1887 group_ops_bls12381_gt_div_cost: Option<u64>,
1888 group_ops_bls12381_g1_hash_to_base_cost: Option<u64>,
1889 group_ops_bls12381_g2_hash_to_base_cost: Option<u64>,
1890 group_ops_bls12381_g1_hash_to_cost_per_byte: Option<u64>,
1891 group_ops_bls12381_g2_hash_to_cost_per_byte: Option<u64>,
1892 group_ops_bls12381_g1_msm_base_cost: Option<u64>,
1893 group_ops_bls12381_g2_msm_base_cost: Option<u64>,
1894 group_ops_bls12381_g1_msm_base_cost_per_input: Option<u64>,
1895 group_ops_bls12381_g2_msm_base_cost_per_input: Option<u64>,
1896 group_ops_bls12381_msm_max_len: Option<u32>,
1897 group_ops_bls12381_pairing_cost: Option<u64>,
1898 group_ops_bls12381_g1_to_uncompressed_g1_cost: Option<u64>,
1899 group_ops_bls12381_uncompressed_g1_to_g1_cost: Option<u64>,
1900 group_ops_bls12381_uncompressed_g1_sum_base_cost: Option<u64>,
1901 group_ops_bls12381_uncompressed_g1_sum_cost_per_term: Option<u64>,
1902 group_ops_bls12381_uncompressed_g1_sum_max_terms: Option<u64>,
1903
1904 group_ops_ristretto_decode_scalar_cost: Option<u64>,
1905 group_ops_ristretto_decode_point_cost: Option<u64>,
1906 group_ops_ristretto_scalar_add_cost: Option<u64>,
1907 group_ops_ristretto_point_add_cost: Option<u64>,
1908 group_ops_ristretto_scalar_sub_cost: Option<u64>,
1909 group_ops_ristretto_point_sub_cost: Option<u64>,
1910 group_ops_ristretto_scalar_mul_cost: Option<u64>,
1911 group_ops_ristretto_point_mul_cost: Option<u64>,
1912 group_ops_ristretto_scalar_div_cost: Option<u64>,
1913 group_ops_ristretto_point_div_cost: Option<u64>,
1914
1915 verify_bulletproofs_ristretto255_base_cost: Option<u64>,
1916 verify_bulletproofs_ristretto255_cost_per_bit_and_commitment: Option<u64>,
1917
1918 hmac_hmac_sha3_256_cost_base: Option<u64>,
1920 hmac_hmac_sha3_256_input_cost_per_byte: Option<u64>,
1921 hmac_hmac_sha3_256_input_cost_per_block: Option<u64>,
1922
1923 check_zklogin_id_cost_base: Option<u64>,
1925 check_zklogin_issuer_cost_base: Option<u64>,
1927
1928 vdf_verify_vdf_cost: Option<u64>,
1929 vdf_hash_to_input_cost: Option<u64>,
1930
1931 nitro_attestation_parse_base_cost: Option<u64>,
1933 nitro_attestation_parse_cost_per_byte: Option<u64>,
1934 nitro_attestation_verify_base_cost: Option<u64>,
1935 nitro_attestation_verify_cost_per_cert: Option<u64>,
1936
1937 bcs_per_byte_serialized_cost: Option<u64>,
1939 bcs_legacy_min_output_size_cost: Option<u64>,
1940 bcs_failure_cost: Option<u64>,
1941
1942 hash_sha2_256_base_cost: Option<u64>,
1943 hash_sha2_256_per_byte_cost: Option<u64>,
1944 hash_sha2_256_legacy_min_input_len_cost: Option<u64>,
1945 hash_sha3_256_base_cost: Option<u64>,
1946 hash_sha3_256_per_byte_cost: Option<u64>,
1947 hash_sha3_256_legacy_min_input_len_cost: Option<u64>,
1948 type_name_get_base_cost: Option<u64>,
1949 type_name_get_per_byte_cost: Option<u64>,
1950 type_name_id_base_cost: Option<u64>,
1951
1952 string_check_utf8_base_cost: Option<u64>,
1953 string_check_utf8_per_byte_cost: Option<u64>,
1954 string_is_char_boundary_base_cost: Option<u64>,
1955 string_sub_string_base_cost: Option<u64>,
1956 string_sub_string_per_byte_cost: Option<u64>,
1957 string_index_of_base_cost: Option<u64>,
1958 string_index_of_per_byte_pattern_cost: Option<u64>,
1959 string_index_of_per_byte_searched_cost: Option<u64>,
1960
1961 vector_empty_base_cost: Option<u64>,
1962 vector_length_base_cost: Option<u64>,
1963 vector_push_back_base_cost: Option<u64>,
1964 vector_push_back_legacy_per_abstract_memory_unit_cost: Option<u64>,
1965 vector_borrow_base_cost: Option<u64>,
1966 vector_pop_back_base_cost: Option<u64>,
1967 vector_destroy_empty_base_cost: Option<u64>,
1968 vector_swap_base_cost: Option<u64>,
1969 debug_print_base_cost: Option<u64>,
1970 debug_print_stack_trace_base_cost: Option<u64>,
1971
1972 #[custom_setter]
1982 execution_version: Option<u64>,
1983
1984 consensus_bad_nodes_stake_threshold: Option<u64>,
1988
1989 max_jwk_votes_per_validator_per_epoch: Option<u64>,
1990 max_age_of_jwk_in_epochs: Option<u64>,
1994
1995 random_beacon_reduction_allowed_delta: Option<u16>,
1999
2000 random_beacon_reduction_lower_bound: Option<u32>,
2003
2004 random_beacon_dkg_timeout_round: Option<u32>,
2007
2008 random_beacon_min_round_interval_ms: Option<u64>,
2010
2011 random_beacon_dkg_version: Option<u64>,
2014
2015 consensus_max_transaction_size_bytes: Option<u64>,
2018 consensus_max_transactions_in_block_bytes: Option<u64>,
2020 consensus_max_num_transactions_in_block: Option<u64>,
2022
2023 consensus_voting_rounds: Option<u32>,
2025
2026 max_accumulated_txn_cost_per_object_in_narwhal_commit: Option<u64>,
2028
2029 max_deferral_rounds_for_congestion_control: Option<u64>,
2032
2033 epoch_close_deadline_ms: Option<u64>,
2038
2039 max_txn_cost_overage_per_object_in_commit: Option<u64>,
2041
2042 allowed_txn_cost_overage_burst_per_object_in_commit: Option<u64>,
2044
2045 min_checkpoint_interval_ms: Option<u64>,
2047
2048 checkpoint_summary_version_specific_data: Option<u64>,
2050
2051 max_soft_bundle_size: Option<u64>,
2053
2054 bridge_should_try_to_finalize_committee: Option<bool>,
2058
2059 max_accumulated_txn_cost_per_object_in_mysticeti_commit: Option<u64>,
2065
2066 max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit: Option<u64>,
2069
2070 consensus_gc_depth: Option<u32>,
2073
2074 gas_budget_based_txn_cost_cap_factor: Option<u64>,
2076
2077 gas_budget_based_txn_cost_absolute_cap_commit_count: Option<u64>,
2079
2080 sip_45_consensus_amplification_threshold: Option<u64>,
2083
2084 use_object_per_epoch_marker_table_v2: Option<bool>,
2087
2088 consensus_commit_rate_estimation_window_size: Option<u32>,
2090
2091 #[serde(skip_serializing_if = "Vec::is_empty")]
2095 aliased_addresses: Vec<AliasedAddress>,
2096
2097 translation_per_command_base_charge: Option<u64>,
2100
2101 translation_per_input_base_charge: Option<u64>,
2104
2105 translation_pure_input_per_byte_charge: Option<u64>,
2107
2108 translation_per_type_node_charge: Option<u64>,
2112
2113 translation_per_reference_node_charge: Option<u64>,
2116
2117 translation_per_linkage_entry_charge: Option<u64>,
2120
2121 max_updates_per_settlement_txn: Option<u32>,
2123
2124 gasless_max_computation_units: Option<u64>,
2126
2127 gasless_allowed_token_types: Option<Vec<(String, u64)>>,
2129
2130 gasless_max_unused_inputs: Option<u64>,
2134
2135 gasless_max_pure_input_bytes: Option<u64>,
2138
2139 gasless_max_tps: Option<u64>,
2141
2142 #[serde(skip_serializing_if = "Option::is_none")]
2143 #[skip_accessor]
2144 include_special_package_amendments: Option<Arc<Amendments>>,
2145
2146 gasless_max_tx_size_bytes: Option<u64>,
2149}
2150
2151#[derive(Clone, Serialize, Deserialize, Debug)]
2153pub struct AliasedAddress {
2154 pub original: [u8; 32],
2156 pub aliased: [u8; 32],
2158 pub allowed_tx_digests: Vec<[u8; 32]>,
2160}
2161
2162impl ProtocolConfig {
2164 pub fn chain(&self) -> Chain {
2166 self.chain
2167 }
2168
2169 pub fn check_package_upgrades_supported(&self) -> Result<(), Error> {
2182 if self.feature_flags.package_upgrades {
2183 Ok(())
2184 } else {
2185 Err(Error(format!(
2186 "package upgrades are not supported at {:?}",
2187 self.version
2188 )))
2189 }
2190 }
2191
2192 pub fn zklogin_supported_providers(&self) -> &BTreeSet<String> {
2193 &self.feature_flags.zklogin_supported_providers
2194 }
2195
2196 pub fn zklogin_circuit_mode(&self) -> u64 {
2199 self.feature_flags.zklogin_circuit_mode
2200 }
2201
2202 pub fn consensus_transaction_ordering(&self) -> ConsensusTransactionOrdering {
2203 self.feature_flags.consensus_transaction_ordering
2204 }
2205
2206 pub fn enable_jwk_consensus_updates(&self) -> bool {
2207 let ret = self.feature_flags.enable_jwk_consensus_updates;
2208 if ret {
2209 assert!(self.feature_flags.end_of_epoch_transaction_supported);
2211 }
2212 ret
2213 }
2214
2215 pub fn end_of_epoch_transaction_supported(&self) -> bool {
2216 let ret = self.feature_flags.end_of_epoch_transaction_supported;
2217 if !ret {
2218 assert!(!self.feature_flags.enable_jwk_consensus_updates);
2220 }
2221 ret
2222 }
2223
2224 pub fn dkg_version(&self) -> u64 {
2225 self.random_beacon_dkg_version.unwrap_or(1)
2227 }
2228
2229 pub fn bridge(&self) -> bool {
2230 let ret = self.feature_flags.bridge;
2231 if ret {
2232 assert!(self.feature_flags.end_of_epoch_transaction_supported);
2234 }
2235 ret
2236 }
2237
2238 pub fn should_try_to_finalize_bridge_committee(&self) -> bool {
2239 if !self.bridge() {
2240 return false;
2241 }
2242 self.bridge_should_try_to_finalize_committee.unwrap_or(true)
2244 }
2245
2246 pub fn zklogin_max_epoch_upper_bound_delta(&self) -> Option<u64> {
2247 self.feature_flags.zklogin_max_epoch_upper_bound_delta
2248 }
2249
2250 pub fn enable_coin_reservation_obj_refs(&self) -> bool {
2251 self.new_vm_enabled() && self.feature_flags.enable_coin_reservation_obj_refs
2252 }
2253
2254 pub fn enable_authenticated_event_streams(&self) -> bool {
2255 self.feature_flags.enable_authenticated_event_streams && self.enable_accumulators()
2256 }
2257
2258 pub fn per_object_congestion_control_mode(&self) -> PerObjectCongestionControlMode {
2259 self.feature_flags.per_object_congestion_control_mode
2260 }
2261
2262 pub fn consensus_choice(&self) -> ConsensusChoice {
2263 self.feature_flags.consensus_choice
2264 }
2265
2266 pub fn consensus_network(&self) -> ConsensusNetwork {
2267 self.feature_flags.consensus_network
2268 }
2269
2270 pub fn mysticeti_num_leaders_per_round(&self) -> Option<usize> {
2271 self.feature_flags.mysticeti_num_leaders_per_round
2272 }
2273
2274 pub fn max_transaction_size_bytes(&self) -> u64 {
2275 self.consensus_max_transaction_size_bytes
2277 .unwrap_or(256 * 1024)
2278 }
2279
2280 pub fn max_transactions_in_block_bytes(&self) -> u64 {
2281 if cfg!(msim) {
2282 256 * 1024
2283 } else {
2284 self.consensus_max_transactions_in_block_bytes
2285 .unwrap_or(512 * 1024)
2286 }
2287 }
2288
2289 pub fn max_num_transactions_in_block(&self) -> u64 {
2290 if cfg!(msim) {
2291 8
2292 } else {
2293 self.consensus_max_num_transactions_in_block.unwrap_or(512)
2294 }
2295 }
2296
2297 pub fn gc_depth(&self) -> u32 {
2298 self.consensus_gc_depth.unwrap_or(0)
2299 }
2300
2301 pub fn consensus_linearize_subdag_v2(&self) -> bool {
2302 let res = self.feature_flags.consensus_linearize_subdag_v2;
2303 assert!(
2304 !res || self.gc_depth() > 0,
2305 "The consensus linearize sub dag V2 requires GC to be enabled"
2306 );
2307 res
2308 }
2309
2310 pub fn consensus_median_based_commit_timestamp(&self) -> bool {
2311 let res = self.feature_flags.consensus_median_based_commit_timestamp;
2312 assert!(
2313 !res || self.gc_depth() > 0,
2314 "The consensus median based commit timestamp requires GC to be enabled"
2315 );
2316 res
2317 }
2318
2319 pub fn get_consensus_commit_rate_estimation_window_size(&self) -> u32 {
2320 self.consensus_commit_rate_estimation_window_size
2321 .unwrap_or(0)
2322 }
2323
2324 pub fn consensus_num_requested_prior_commits_at_startup(&self) -> u32 {
2325 let window_size = self.get_consensus_commit_rate_estimation_window_size();
2329 assert!(window_size == 0 || self.record_additional_state_digest_in_prologue());
2331 window_size
2332 }
2333
2334 pub fn address_aliases(&self) -> bool {
2335 let address_aliases = self.feature_flags.address_aliases;
2336 assert!(
2337 !address_aliases || self.mysticeti_fastpath(),
2338 "Address aliases requires Mysticeti fastpath to be enabled"
2339 );
2340 if address_aliases {
2341 assert!(
2342 self.feature_flags.disable_preconsensus_locking,
2343 "Address aliases requires CertifiedTransaction to be disabled"
2344 );
2345 }
2346 address_aliases
2347 }
2348
2349 pub fn new_vm_enabled(&self) -> bool {
2350 self.execution_version.is_some_and(|v| v >= 4)
2351 }
2352
2353 pub fn gasless_allowed_token_types(&self) -> &[(String, u64)] {
2354 debug_assert!(self.gasless_allowed_token_types.is_some());
2355 self.gasless_allowed_token_types.as_deref().unwrap_or(&[])
2356 }
2357
2358 pub fn get_gasless_max_unused_inputs(&self) -> u64 {
2359 self.gasless_max_unused_inputs.unwrap_or(u64::MAX)
2360 }
2361
2362 pub fn get_gasless_max_pure_input_bytes(&self) -> u64 {
2363 self.gasless_max_pure_input_bytes.unwrap_or(u64::MAX)
2364 }
2365
2366 pub fn get_gasless_max_tx_size_bytes(&self) -> u64 {
2367 self.gasless_max_tx_size_bytes.unwrap_or(u64::MAX)
2368 }
2369
2370 pub fn include_special_package_amendments_as_option(&self) -> &Option<Arc<Amendments>> {
2371 &self.include_special_package_amendments
2372 }
2373}
2374
2375static POISON_VERSION_METHODS: AtomicBool = AtomicBool::new(false);
2376
2377impl ProtocolConfig {
2379 pub fn get_for_version(version: ProtocolVersion, chain: Chain) -> Self {
2381 assert!(
2383 version >= ProtocolVersion::MIN,
2384 "Network protocol version is {:?}, but the minimum supported version by the binary is {:?}. Please upgrade the binary.",
2385 version,
2386 ProtocolVersion::MIN.0,
2387 );
2388 assert!(
2389 version <= ProtocolVersion::MAX_ALLOWED,
2390 "Network protocol version is {:?}, but the maximum supported version by the binary is {:?}. Please upgrade the binary.",
2391 version,
2392 ProtocolVersion::MAX_ALLOWED.0,
2393 );
2394
2395 let mut ret = Self::get_for_version_impl(version, chain);
2396 ret.version = version;
2397 ret.chain = chain;
2398
2399 ret = Self::apply_config_override(version, ret);
2400
2401 if std::env::var("SUI_PROTOCOL_CONFIG_OVERRIDE_ENABLE").is_ok() {
2402 warn!(
2403 "overriding ProtocolConfig settings with custom settings; this may break non-local networks"
2404 );
2405 let overrides: ProtocolConfigOptional =
2406 serde_env::from_env_with_prefix("SUI_PROTOCOL_CONFIG_OVERRIDE")
2407 .expect("failed to parse ProtocolConfig override env variables");
2408 overrides.apply_to(&mut ret);
2409 }
2410
2411 ret
2412 }
2413
2414 pub fn get_for_version_if_supported(version: ProtocolVersion, chain: Chain) -> Option<Self> {
2417 if version.0 >= ProtocolVersion::MIN.0 && version.0 <= ProtocolVersion::MAX_ALLOWED.0 {
2418 let mut ret = Self::get_for_version_impl(version, chain);
2419 ret.version = version;
2420 ret.chain = chain;
2421 ret = Self::apply_config_override(version, ret);
2422 Some(ret)
2423 } else {
2424 None
2425 }
2426 }
2427
2428 pub fn poison_get_for_min_version() {
2429 POISON_VERSION_METHODS.store(true, Ordering::Relaxed);
2430 }
2431
2432 fn load_poison_get_for_min_version() -> bool {
2433 POISON_VERSION_METHODS.load(Ordering::Relaxed)
2434 }
2435
2436 pub fn get_for_min_version() -> Self {
2439 if Self::load_poison_get_for_min_version() {
2440 panic!("get_for_min_version called on validator");
2441 }
2442 ProtocolConfig::get_for_version(ProtocolVersion::MIN, Chain::Unknown)
2443 }
2444
2445 #[allow(non_snake_case)]
2455 pub fn get_for_max_version_UNSAFE() -> Self {
2456 if Self::load_poison_get_for_min_version() {
2457 panic!("get_for_max_version_UNSAFE called on validator");
2458 }
2459 ProtocolConfig::get_for_version(ProtocolVersion::MAX, Chain::Unknown)
2460 }
2461
2462 fn get_for_version_impl(version: ProtocolVersion, chain: Chain) -> Self {
2463 #[cfg(msim)]
2464 {
2465 if version == ProtocolVersion::MAX_ALLOWED {
2467 let mut config = Self::get_for_version_impl(version - 1, Chain::Unknown);
2468 config.base_tx_cost_fixed = Some(config.base_tx_cost_fixed() + 1000);
2469 return config;
2470 }
2471 }
2472
2473 let mut cfg = Self {
2476 version,
2478 chain,
2479
2480 feature_flags: Default::default(),
2482
2483 max_tx_size_bytes: Some(128 * 1024),
2484 max_input_objects: Some(2048),
2486 max_serialized_tx_effects_size_bytes: Some(512 * 1024),
2487 max_serialized_tx_effects_size_bytes_system_tx: Some(512 * 1024 * 16),
2488 max_gas_payment_objects: Some(256),
2489 max_modules_in_publish: Some(128),
2490 max_package_dependencies: None,
2491 max_arguments: Some(512),
2492 max_type_arguments: Some(16),
2493 max_type_argument_depth: Some(16),
2494 max_pure_argument_size: Some(16 * 1024),
2495 max_programmable_tx_commands: Some(1024),
2496 move_binary_format_version: Some(6),
2497 min_move_binary_format_version: None,
2498 binary_module_handles: None,
2499 binary_struct_handles: None,
2500 binary_function_handles: None,
2501 binary_function_instantiations: None,
2502 binary_signatures: None,
2503 binary_constant_pool: None,
2504 binary_identifiers: None,
2505 binary_address_identifiers: None,
2506 binary_struct_defs: None,
2507 binary_struct_def_instantiations: None,
2508 binary_function_defs: None,
2509 binary_field_handles: None,
2510 binary_field_instantiations: None,
2511 binary_friend_decls: None,
2512 binary_enum_defs: None,
2513 binary_enum_def_instantiations: None,
2514 binary_variant_handles: None,
2515 binary_variant_instantiation_handles: None,
2516 max_move_object_size: Some(250 * 1024),
2517 max_move_package_size: Some(100 * 1024),
2518 max_publish_or_upgrade_per_ptb: None,
2519 max_tx_gas: Some(10_000_000_000),
2520 max_gas_price: Some(100_000),
2521 max_gas_price_rgp_factor_for_aborted_transactions: None,
2522 max_gas_computation_bucket: Some(5_000_000),
2523 max_loop_depth: Some(5),
2524 max_generic_instantiation_length: Some(32),
2525 max_function_parameters: Some(128),
2526 max_basic_blocks: Some(1024),
2527 max_value_stack_size: Some(1024),
2528 max_type_nodes: Some(256),
2529 max_generic_instantiation_type_nodes_per_function: None,
2530 max_generic_instantiation_type_nodes_per_module: None,
2531 max_push_size: Some(10000),
2532 max_struct_definitions: Some(200),
2533 max_function_definitions: Some(1000),
2534 max_fields_in_struct: Some(32),
2535 max_dependency_depth: Some(100),
2536 max_num_event_emit: Some(256),
2537 max_num_new_move_object_ids: Some(2048),
2538 max_num_new_move_object_ids_system_tx: Some(2048 * 16),
2539 max_num_deleted_move_object_ids: Some(2048),
2540 max_num_deleted_move_object_ids_system_tx: Some(2048 * 16),
2541 max_num_transferred_move_object_ids: Some(2048),
2542 max_num_transferred_move_object_ids_system_tx: Some(2048 * 16),
2543 max_event_emit_size: Some(250 * 1024),
2544 max_move_vector_len: Some(256 * 1024),
2545 max_type_to_layout_nodes: None,
2546 max_ptb_value_size: None,
2547
2548 max_back_edges_per_function: Some(10_000),
2549 max_back_edges_per_module: Some(10_000),
2550 max_verifier_meter_ticks_per_function: Some(6_000_000),
2551 max_meter_ticks_per_module: Some(6_000_000),
2552 max_meter_ticks_per_package: None,
2553
2554 object_runtime_max_num_cached_objects: Some(1000),
2555 object_runtime_max_num_cached_objects_system_tx: Some(1000 * 16),
2556 object_runtime_max_num_store_entries: Some(1000),
2557 object_runtime_max_num_store_entries_system_tx: Some(1000 * 16),
2558 base_tx_cost_fixed: Some(110_000),
2559 package_publish_cost_fixed: Some(1_000),
2560 base_tx_cost_per_byte: Some(0),
2561 package_publish_cost_per_byte: Some(80),
2562 obj_access_cost_read_per_byte: Some(15),
2563 obj_access_cost_mutate_per_byte: Some(40),
2564 obj_access_cost_delete_per_byte: Some(40),
2565 obj_access_cost_verify_per_byte: Some(200),
2566 obj_data_cost_refundable: Some(100),
2567 obj_metadata_cost_non_refundable: Some(50),
2568 gas_model_version: Some(1),
2569 storage_rebate_rate: Some(9900),
2570 storage_fund_reinvest_rate: Some(500),
2571 reward_slashing_rate: Some(5000),
2572 storage_gas_price: Some(1),
2573 accumulator_object_storage_cost: None,
2574 max_transactions_per_checkpoint: Some(10_000),
2575 max_checkpoint_size_bytes: Some(30 * 1024 * 1024),
2576
2577 buffer_stake_for_protocol_upgrade_bps: Some(0),
2580
2581 address_from_bytes_cost_base: Some(52),
2585 address_to_u256_cost_base: Some(52),
2587 address_from_u256_cost_base: Some(52),
2589
2590 config_read_setting_impl_cost_base: None,
2593 config_read_setting_impl_cost_per_byte: None,
2594
2595 package_original_package_id_impl_cost_base: None,
2596 package_original_package_id_impl_cost_per_byte: None,
2597
2598 dynamic_field_hash_type_and_key_cost_base: Some(100),
2601 dynamic_field_hash_type_and_key_type_cost_per_byte: Some(2),
2602 dynamic_field_hash_type_and_key_value_cost_per_byte: Some(2),
2603 dynamic_field_hash_type_and_key_type_tag_cost_per_byte: Some(2),
2604 dynamic_field_add_child_object_cost_base: Some(100),
2606 dynamic_field_add_child_object_type_cost_per_byte: Some(10),
2607 dynamic_field_add_child_object_value_cost_per_byte: Some(10),
2608 dynamic_field_add_child_object_struct_tag_cost_per_byte: Some(10),
2609 dynamic_field_borrow_child_object_cost_base: Some(100),
2611 dynamic_field_borrow_child_object_child_ref_cost_per_byte: Some(10),
2612 dynamic_field_borrow_child_object_type_cost_per_byte: Some(10),
2613 dynamic_field_remove_child_object_cost_base: Some(100),
2615 dynamic_field_remove_child_object_child_cost_per_byte: Some(2),
2616 dynamic_field_remove_child_object_type_cost_per_byte: Some(2),
2617 dynamic_field_has_child_object_cost_base: Some(100),
2619 dynamic_field_has_child_object_with_ty_cost_base: Some(100),
2621 dynamic_field_has_child_object_with_ty_type_cost_per_byte: Some(2),
2622 dynamic_field_has_child_object_with_ty_type_tag_cost_per_byte: Some(2),
2623
2624 scratch_add_cost_base: None,
2626 scratch_read_cost_base: None,
2627 scratch_read_value_cost: None,
2628 scratch_remove_cost_base: None,
2629 scratch_exists_cost_base: None,
2630 scratch_exists_with_type_cost_base: None,
2631 scratch_exists_with_type_type_cost: None,
2632 max_scratch_pad_size: None,
2633
2634 event_emit_cost_base: Some(52),
2637 event_emit_value_size_derivation_cost_per_byte: Some(2),
2638 event_emit_tag_size_derivation_cost_per_byte: Some(5),
2639 event_emit_output_cost_per_byte: Some(10),
2640 event_emit_auth_stream_cost: None,
2641
2642 object_borrow_uid_cost_base: Some(52),
2645 object_delete_impl_cost_base: Some(52),
2647 object_record_new_uid_cost_base: Some(52),
2649 object_record_new_uid_from_hash_cost_base: None,
2652
2653 transfer_transfer_internal_cost_base: Some(52),
2656 transfer_party_transfer_internal_cost_base: None,
2658 transfer_freeze_object_cost_base: Some(52),
2660 transfer_share_object_cost_base: Some(52),
2662 transfer_receive_object_cost_base: None,
2663 transfer_receive_object_type_cost_per_byte: None,
2664 transfer_receive_object_cost_per_byte: None,
2665
2666 tx_context_derive_id_cost_base: Some(52),
2669 tx_context_fresh_id_cost_base: None,
2670 tx_context_sender_cost_base: None,
2671 tx_context_epoch_cost_base: None,
2672 tx_context_epoch_timestamp_ms_cost_base: None,
2673 tx_context_sponsor_cost_base: None,
2674 tx_context_rgp_cost_base: None,
2675 tx_context_gas_price_cost_base: None,
2676 tx_context_gas_budget_cost_base: None,
2677 tx_context_ids_created_cost_base: None,
2678 tx_context_replace_cost_base: None,
2679
2680 types_is_one_time_witness_cost_base: Some(52),
2683 types_is_one_time_witness_type_tag_cost_per_byte: Some(2),
2684 types_is_one_time_witness_type_cost_per_byte: Some(2),
2685
2686 validator_validate_metadata_cost_base: Some(52),
2689 validator_validate_metadata_data_cost_per_byte: Some(2),
2690
2691 crypto_invalid_arguments_cost: Some(100),
2693 bls12381_bls12381_min_sig_verify_cost_base: Some(52),
2695 bls12381_bls12381_min_sig_verify_msg_cost_per_byte: Some(2),
2696 bls12381_bls12381_min_sig_verify_msg_cost_per_block: Some(2),
2697
2698 bls12381_bls12381_min_pk_verify_cost_base: Some(52),
2700 bls12381_bls12381_min_pk_verify_msg_cost_per_byte: Some(2),
2701 bls12381_bls12381_min_pk_verify_msg_cost_per_block: Some(2),
2702
2703 ecdsa_k1_ecrecover_keccak256_cost_base: Some(52),
2705 ecdsa_k1_ecrecover_keccak256_msg_cost_per_byte: Some(2),
2706 ecdsa_k1_ecrecover_keccak256_msg_cost_per_block: Some(2),
2707 ecdsa_k1_ecrecover_sha256_cost_base: Some(52),
2708 ecdsa_k1_ecrecover_sha256_msg_cost_per_byte: Some(2),
2709 ecdsa_k1_ecrecover_sha256_msg_cost_per_block: Some(2),
2710
2711 ecdsa_k1_decompress_pubkey_cost_base: Some(52),
2713
2714 ecdsa_k1_secp256k1_verify_keccak256_cost_base: Some(52),
2716 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_byte: Some(2),
2717 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_block: Some(2),
2718 ecdsa_k1_secp256k1_verify_sha256_cost_base: Some(52),
2719 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_byte: Some(2),
2720 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_block: Some(2),
2721
2722 ecdsa_r1_ecrecover_keccak256_cost_base: Some(52),
2724 ecdsa_r1_ecrecover_keccak256_msg_cost_per_byte: Some(2),
2725 ecdsa_r1_ecrecover_keccak256_msg_cost_per_block: Some(2),
2726 ecdsa_r1_ecrecover_sha256_cost_base: Some(52),
2727 ecdsa_r1_ecrecover_sha256_msg_cost_per_byte: Some(2),
2728 ecdsa_r1_ecrecover_sha256_msg_cost_per_block: Some(2),
2729
2730 ecdsa_r1_secp256r1_verify_keccak256_cost_base: Some(52),
2732 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_byte: Some(2),
2733 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_block: Some(2),
2734 ecdsa_r1_secp256r1_verify_sha256_cost_base: Some(52),
2735 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_byte: Some(2),
2736 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_block: Some(2),
2737
2738 ecvrf_ecvrf_verify_cost_base: Some(52),
2740 ecvrf_ecvrf_verify_alpha_string_cost_per_byte: Some(2),
2741 ecvrf_ecvrf_verify_alpha_string_cost_per_block: Some(2),
2742
2743 ed25519_ed25519_verify_cost_base: Some(52),
2745 ed25519_ed25519_verify_msg_cost_per_byte: Some(2),
2746 ed25519_ed25519_verify_msg_cost_per_block: Some(2),
2747
2748 groth16_prepare_verifying_key_bls12381_cost_base: Some(52),
2750 groth16_prepare_verifying_key_bn254_cost_base: Some(52),
2751
2752 groth16_verify_groth16_proof_internal_bls12381_cost_base: Some(52),
2754 groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input: Some(2),
2755 groth16_verify_groth16_proof_internal_bn254_cost_base: Some(52),
2756 groth16_verify_groth16_proof_internal_bn254_cost_per_public_input: Some(2),
2757 groth16_verify_groth16_proof_internal_public_input_cost_per_byte: Some(2),
2758
2759 hash_blake2b256_cost_base: Some(52),
2761 hash_blake2b256_data_cost_per_byte: Some(2),
2762 hash_blake2b256_data_cost_per_block: Some(2),
2763
2764 hash_keccak256_cost_base: Some(52),
2766 hash_keccak256_data_cost_per_byte: Some(2),
2767 hash_keccak256_data_cost_per_block: Some(2),
2768
2769 poseidon_bn254_cost_base: None,
2770 poseidon_bn254_cost_per_block: None,
2771
2772 hmac_hmac_sha3_256_cost_base: Some(52),
2774 hmac_hmac_sha3_256_input_cost_per_byte: Some(2),
2775 hmac_hmac_sha3_256_input_cost_per_block: Some(2),
2776
2777 group_ops_bls12381_decode_scalar_cost: None,
2779 group_ops_bls12381_decode_g1_cost: None,
2780 group_ops_bls12381_decode_g2_cost: None,
2781 group_ops_bls12381_decode_gt_cost: None,
2782 group_ops_bls12381_scalar_add_cost: None,
2783 group_ops_bls12381_g1_add_cost: None,
2784 group_ops_bls12381_g2_add_cost: None,
2785 group_ops_bls12381_gt_add_cost: None,
2786 group_ops_bls12381_scalar_sub_cost: None,
2787 group_ops_bls12381_g1_sub_cost: None,
2788 group_ops_bls12381_g2_sub_cost: None,
2789 group_ops_bls12381_gt_sub_cost: None,
2790 group_ops_bls12381_scalar_mul_cost: None,
2791 group_ops_bls12381_g1_mul_cost: None,
2792 group_ops_bls12381_g2_mul_cost: None,
2793 group_ops_bls12381_gt_mul_cost: None,
2794 group_ops_bls12381_scalar_div_cost: None,
2795 group_ops_bls12381_g1_div_cost: None,
2796 group_ops_bls12381_g2_div_cost: None,
2797 group_ops_bls12381_gt_div_cost: None,
2798 group_ops_bls12381_g1_hash_to_base_cost: None,
2799 group_ops_bls12381_g2_hash_to_base_cost: None,
2800 group_ops_bls12381_g1_hash_to_cost_per_byte: None,
2801 group_ops_bls12381_g2_hash_to_cost_per_byte: None,
2802 group_ops_bls12381_g1_msm_base_cost: None,
2803 group_ops_bls12381_g2_msm_base_cost: None,
2804 group_ops_bls12381_g1_msm_base_cost_per_input: None,
2805 group_ops_bls12381_g2_msm_base_cost_per_input: None,
2806 group_ops_bls12381_msm_max_len: None,
2807 group_ops_bls12381_pairing_cost: None,
2808 group_ops_bls12381_g1_to_uncompressed_g1_cost: None,
2809 group_ops_bls12381_uncompressed_g1_to_g1_cost: None,
2810 group_ops_bls12381_uncompressed_g1_sum_base_cost: None,
2811 group_ops_bls12381_uncompressed_g1_sum_cost_per_term: None,
2812 group_ops_bls12381_uncompressed_g1_sum_max_terms: None,
2813
2814 group_ops_ristretto_decode_scalar_cost: None,
2815 group_ops_ristretto_decode_point_cost: None,
2816 group_ops_ristretto_scalar_add_cost: None,
2817 group_ops_ristretto_point_add_cost: None,
2818 group_ops_ristretto_scalar_sub_cost: None,
2819 group_ops_ristretto_point_sub_cost: None,
2820 group_ops_ristretto_scalar_mul_cost: None,
2821 group_ops_ristretto_point_mul_cost: None,
2822 group_ops_ristretto_scalar_div_cost: None,
2823 group_ops_ristretto_point_div_cost: None,
2824
2825 verify_bulletproofs_ristretto255_base_cost: None,
2826 verify_bulletproofs_ristretto255_cost_per_bit_and_commitment: None,
2827
2828 check_zklogin_id_cost_base: None,
2830 check_zklogin_issuer_cost_base: None,
2832
2833 vdf_verify_vdf_cost: None,
2834 vdf_hash_to_input_cost: None,
2835
2836 nitro_attestation_parse_base_cost: None,
2838 nitro_attestation_parse_cost_per_byte: None,
2839 nitro_attestation_verify_base_cost: None,
2840 nitro_attestation_verify_cost_per_cert: None,
2841
2842 bcs_per_byte_serialized_cost: None,
2843 bcs_legacy_min_output_size_cost: None,
2844 bcs_failure_cost: None,
2845 hash_sha2_256_base_cost: None,
2846 hash_sha2_256_per_byte_cost: None,
2847 hash_sha2_256_legacy_min_input_len_cost: None,
2848 hash_sha3_256_base_cost: None,
2849 hash_sha3_256_per_byte_cost: None,
2850 hash_sha3_256_legacy_min_input_len_cost: None,
2851 type_name_get_base_cost: None,
2852 type_name_get_per_byte_cost: None,
2853 type_name_id_base_cost: None,
2854 string_check_utf8_base_cost: None,
2855 string_check_utf8_per_byte_cost: None,
2856 string_is_char_boundary_base_cost: None,
2857 string_sub_string_base_cost: None,
2858 string_sub_string_per_byte_cost: None,
2859 string_index_of_base_cost: None,
2860 string_index_of_per_byte_pattern_cost: None,
2861 string_index_of_per_byte_searched_cost: None,
2862 vector_empty_base_cost: None,
2863 vector_length_base_cost: None,
2864 vector_push_back_base_cost: None,
2865 vector_push_back_legacy_per_abstract_memory_unit_cost: None,
2866 vector_borrow_base_cost: None,
2867 vector_pop_back_base_cost: None,
2868 vector_destroy_empty_base_cost: None,
2869 vector_swap_base_cost: None,
2870 debug_print_base_cost: None,
2871 debug_print_stack_trace_base_cost: None,
2872
2873 max_size_written_objects: None,
2874 max_size_written_objects_system_tx: None,
2875
2876 max_move_identifier_len: None,
2883 max_move_value_depth: None,
2884 max_move_enum_variants: None,
2885
2886 gas_rounding_step: None,
2887
2888 execution_version: None,
2889
2890 max_event_emit_size_total: None,
2891
2892 consensus_bad_nodes_stake_threshold: None,
2893
2894 max_jwk_votes_per_validator_per_epoch: None,
2895
2896 max_age_of_jwk_in_epochs: None,
2897
2898 random_beacon_reduction_allowed_delta: None,
2899
2900 random_beacon_reduction_lower_bound: None,
2901
2902 random_beacon_dkg_timeout_round: None,
2903
2904 random_beacon_min_round_interval_ms: None,
2905
2906 random_beacon_dkg_version: None,
2907
2908 consensus_max_transaction_size_bytes: None,
2909
2910 consensus_max_transactions_in_block_bytes: None,
2911
2912 consensus_max_num_transactions_in_block: None,
2913
2914 consensus_voting_rounds: None,
2915
2916 max_accumulated_txn_cost_per_object_in_narwhal_commit: None,
2917
2918 max_deferral_rounds_for_congestion_control: None,
2919
2920 epoch_close_deadline_ms: None,
2921
2922 max_txn_cost_overage_per_object_in_commit: None,
2923
2924 allowed_txn_cost_overage_burst_per_object_in_commit: None,
2925
2926 min_checkpoint_interval_ms: None,
2927
2928 checkpoint_summary_version_specific_data: None,
2929
2930 max_soft_bundle_size: None,
2931
2932 bridge_should_try_to_finalize_committee: None,
2933
2934 max_accumulated_txn_cost_per_object_in_mysticeti_commit: None,
2935
2936 max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit: None,
2937
2938 consensus_gc_depth: None,
2939
2940 gas_budget_based_txn_cost_cap_factor: None,
2941
2942 gas_budget_based_txn_cost_absolute_cap_commit_count: None,
2943
2944 sip_45_consensus_amplification_threshold: None,
2945
2946 use_object_per_epoch_marker_table_v2: None,
2947
2948 consensus_commit_rate_estimation_window_size: None,
2949
2950 aliased_addresses: vec![],
2951
2952 translation_per_command_base_charge: None,
2953 translation_per_input_base_charge: None,
2954 translation_pure_input_per_byte_charge: None,
2955 translation_per_type_node_charge: None,
2956 translation_per_reference_node_charge: None,
2957 translation_per_linkage_entry_charge: None,
2958
2959 max_updates_per_settlement_txn: None,
2960
2961 gasless_max_computation_units: None,
2962 gasless_allowed_token_types: None,
2963 gasless_max_unused_inputs: None,
2964 gasless_max_pure_input_bytes: None,
2965 gasless_max_tps: None,
2966 include_special_package_amendments: None,
2967 gasless_max_tx_size_bytes: None,
2968 };
2971 for cur in 2..=version.0 {
2972 match cur {
2973 1 => unreachable!(),
2974 2 => {
2975 cfg.feature_flags.advance_epoch_start_time_in_safe_mode = true;
2976 }
2977 3 => {
2978 cfg.gas_model_version = Some(2);
2980 cfg.max_tx_gas = Some(50_000_000_000);
2982 cfg.base_tx_cost_fixed = Some(2_000);
2984 cfg.storage_gas_price = Some(76);
2986 cfg.feature_flags.loaded_child_objects_fixed = true;
2987 cfg.max_size_written_objects = Some(5 * 1000 * 1000);
2990 cfg.max_size_written_objects_system_tx = Some(50 * 1000 * 1000);
2993 cfg.feature_flags.package_upgrades = true;
2994 }
2995 4 => {
3000 cfg.reward_slashing_rate = Some(10000);
3002 cfg.gas_model_version = Some(3);
3004 }
3005 5 => {
3006 cfg.feature_flags.missing_type_is_compatibility_error = true;
3007 cfg.gas_model_version = Some(4);
3008 cfg.feature_flags.scoring_decision_with_validity_cutoff = true;
3009 }
3013 6 => {
3014 cfg.gas_model_version = Some(5);
3015 cfg.buffer_stake_for_protocol_upgrade_bps = Some(5000);
3016 cfg.feature_flags.consensus_order_end_of_epoch_last = true;
3017 }
3018 7 => {
3019 cfg.feature_flags.disallow_adding_abilities_on_upgrade = true;
3020 cfg.feature_flags
3021 .disable_invariant_violation_check_in_swap_loc = true;
3022 cfg.feature_flags.ban_entry_init = true;
3023 cfg.feature_flags.package_digest_hash_module = true;
3024 }
3025 8 => {
3026 cfg.feature_flags
3027 .disallow_change_struct_type_params_on_upgrade = true;
3028 }
3029 9 => {
3030 cfg.max_move_identifier_len = Some(128);
3032 cfg.feature_flags.no_extraneous_module_bytes = true;
3033 cfg.feature_flags
3034 .advance_to_highest_supported_protocol_version = true;
3035 }
3036 10 => {
3037 cfg.max_verifier_meter_ticks_per_function = Some(16_000_000);
3038 cfg.max_meter_ticks_per_module = Some(16_000_000);
3039 }
3040 11 => {
3041 cfg.max_move_value_depth = Some(128);
3042 }
3043 12 => {
3044 cfg.feature_flags.narwhal_versioned_metadata = true;
3045 if chain != Chain::Mainnet {
3046 cfg.feature_flags.commit_root_state_digest = true;
3047 }
3048
3049 if chain != Chain::Mainnet && chain != Chain::Testnet {
3050 cfg.feature_flags.zklogin_auth = true;
3051 }
3052 }
3053 13 => {}
3054 14 => {
3055 cfg.gas_rounding_step = Some(1_000);
3056 cfg.gas_model_version = Some(6);
3057 }
3058 15 => {
3059 cfg.feature_flags.consensus_transaction_ordering =
3060 ConsensusTransactionOrdering::ByGasPrice;
3061 }
3062 16 => {
3063 cfg.feature_flags.simplified_unwrap_then_delete = true;
3064 }
3065 17 => {
3066 cfg.feature_flags.upgraded_multisig_supported = true;
3067 }
3068 18 => {
3069 cfg.execution_version = Some(1);
3070 cfg.feature_flags.txn_base_cost_as_multiplier = true;
3079 cfg.base_tx_cost_fixed = Some(1_000);
3081 }
3082 19 => {
3083 cfg.max_num_event_emit = Some(1024);
3084 cfg.max_event_emit_size_total = Some(
3087 256 * 250 * 1024, );
3089 }
3090 20 => {
3091 cfg.feature_flags.commit_root_state_digest = true;
3092
3093 if chain != Chain::Mainnet {
3094 cfg.feature_flags.narwhal_new_leader_election_schedule = true;
3095 cfg.consensus_bad_nodes_stake_threshold = Some(20);
3096 }
3097 }
3098
3099 21 => {
3100 if chain != Chain::Mainnet {
3101 cfg.feature_flags.zklogin_supported_providers = BTreeSet::from([
3102 "Google".to_string(),
3103 "Facebook".to_string(),
3104 "Twitch".to_string(),
3105 ]);
3106 }
3107 }
3108 22 => {
3109 cfg.feature_flags.loaded_child_object_format = true;
3110 }
3111 23 => {
3112 cfg.feature_flags.loaded_child_object_format_type = true;
3113 cfg.feature_flags.narwhal_new_leader_election_schedule = true;
3114 cfg.consensus_bad_nodes_stake_threshold = Some(20);
3120 }
3121 24 => {
3122 cfg.feature_flags.simple_conservation_checks = true;
3123 cfg.max_publish_or_upgrade_per_ptb = Some(5);
3124
3125 cfg.feature_flags.end_of_epoch_transaction_supported = true;
3126
3127 if chain != Chain::Mainnet {
3128 cfg.feature_flags.enable_jwk_consensus_updates = true;
3129 cfg.max_jwk_votes_per_validator_per_epoch = Some(240);
3131 cfg.max_age_of_jwk_in_epochs = Some(1);
3132 }
3133 }
3134 25 => {
3135 cfg.feature_flags.zklogin_supported_providers = BTreeSet::from([
3137 "Google".to_string(),
3138 "Facebook".to_string(),
3139 "Twitch".to_string(),
3140 ]);
3141 cfg.feature_flags.zklogin_auth = true;
3142
3143 cfg.feature_flags.enable_jwk_consensus_updates = true;
3145 cfg.max_jwk_votes_per_validator_per_epoch = Some(240);
3146 cfg.max_age_of_jwk_in_epochs = Some(1);
3147 }
3148 26 => {
3149 cfg.gas_model_version = Some(7);
3150 if chain != Chain::Mainnet && chain != Chain::Testnet {
3152 cfg.transfer_receive_object_cost_base = Some(52);
3153 cfg.feature_flags.receive_objects = true;
3154 }
3155 }
3156 27 => {
3157 cfg.gas_model_version = Some(8);
3158 }
3159 28 => {
3160 cfg.check_zklogin_id_cost_base = Some(200);
3162 cfg.check_zklogin_issuer_cost_base = Some(200);
3164
3165 if chain != Chain::Mainnet && chain != Chain::Testnet {
3167 cfg.feature_flags.enable_effects_v2 = true;
3168 }
3169 }
3170 29 => {
3171 cfg.feature_flags.verify_legacy_zklogin_address = true;
3172 }
3173 30 => {
3174 if chain != Chain::Mainnet {
3176 cfg.feature_flags.narwhal_certificate_v2 = true;
3177 }
3178
3179 cfg.random_beacon_reduction_allowed_delta = Some(800);
3180 if chain != Chain::Mainnet {
3182 cfg.feature_flags.enable_effects_v2 = true;
3183 }
3184
3185 cfg.feature_flags.zklogin_supported_providers = BTreeSet::default();
3189
3190 cfg.feature_flags.recompute_has_public_transfer_in_execution = true;
3191 }
3192 31 => {
3193 cfg.execution_version = Some(2);
3194 if chain != Chain::Mainnet && chain != Chain::Testnet {
3196 cfg.feature_flags.shared_object_deletion = true;
3197 }
3198 }
3199 32 => {
3200 if chain != Chain::Mainnet {
3202 cfg.feature_flags.accept_zklogin_in_multisig = true;
3203 }
3204 if chain != Chain::Mainnet {
3206 cfg.transfer_receive_object_cost_base = Some(52);
3207 cfg.feature_flags.receive_objects = true;
3208 }
3209 if chain != Chain::Mainnet && chain != Chain::Testnet {
3211 cfg.feature_flags.random_beacon = true;
3212 cfg.random_beacon_reduction_lower_bound = Some(1600);
3213 cfg.random_beacon_dkg_timeout_round = Some(3000);
3214 cfg.random_beacon_min_round_interval_ms = Some(150);
3215 }
3216 if chain != Chain::Testnet && chain != Chain::Mainnet {
3218 cfg.feature_flags.include_consensus_digest_in_prologue = true;
3219 }
3220
3221 cfg.feature_flags.narwhal_certificate_v2 = true;
3223 }
3224 33 => {
3225 cfg.feature_flags.hardened_otw_check = true;
3226 cfg.feature_flags.allow_receiving_object_id = true;
3227
3228 cfg.transfer_receive_object_cost_base = Some(52);
3230 cfg.feature_flags.receive_objects = true;
3231
3232 if chain != Chain::Mainnet {
3234 cfg.feature_flags.shared_object_deletion = true;
3235 }
3236
3237 cfg.feature_flags.enable_effects_v2 = true;
3238 }
3239 34 => {}
3240 35 => {
3241 if chain != Chain::Mainnet && chain != Chain::Testnet {
3243 cfg.feature_flags.enable_poseidon = true;
3244 cfg.poseidon_bn254_cost_base = Some(260);
3245 cfg.poseidon_bn254_cost_per_block = Some(10);
3246 }
3247
3248 cfg.feature_flags.enable_coin_deny_list = true;
3249 }
3250 36 => {
3251 if chain != Chain::Mainnet && chain != Chain::Testnet {
3253 cfg.feature_flags.enable_group_ops_native_functions = true;
3254 cfg.feature_flags.enable_group_ops_native_function_msm = 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 cfg.feature_flags.shared_object_deletion = true;
3289
3290 cfg.consensus_max_transaction_size_bytes = Some(256 * 1024); cfg.consensus_max_transactions_in_block_bytes = Some(6 * 1_024 * 1024);
3292 }
3294 37 => {
3295 cfg.feature_flags.reject_mutable_random_on_entry_functions = true;
3296
3297 if chain != Chain::Mainnet {
3299 cfg.feature_flags.include_consensus_digest_in_prologue = true;
3300 }
3301 }
3302 38 => {
3303 cfg.binary_module_handles = Some(100);
3304 cfg.binary_struct_handles = Some(300);
3305 cfg.binary_function_handles = Some(1500);
3306 cfg.binary_function_instantiations = Some(750);
3307 cfg.binary_signatures = Some(1000);
3308 cfg.binary_constant_pool = Some(4000);
3312 cfg.binary_identifiers = Some(10000);
3313 cfg.binary_address_identifiers = Some(100);
3314 cfg.binary_struct_defs = Some(200);
3315 cfg.binary_struct_def_instantiations = Some(100);
3316 cfg.binary_function_defs = Some(1000);
3317 cfg.binary_field_handles = Some(500);
3318 cfg.binary_field_instantiations = Some(250);
3319 cfg.binary_friend_decls = Some(100);
3320 cfg.max_package_dependencies = Some(32);
3322 cfg.max_modules_in_publish = Some(64);
3323 cfg.execution_version = Some(3);
3325 }
3326 39 => {
3327 }
3329 40 => {}
3330 41 => {
3331 cfg.feature_flags.enable_group_ops_native_functions = true;
3333 cfg.group_ops_bls12381_decode_scalar_cost = Some(52);
3335 cfg.group_ops_bls12381_decode_g1_cost = Some(52);
3336 cfg.group_ops_bls12381_decode_g2_cost = Some(52);
3337 cfg.group_ops_bls12381_decode_gt_cost = Some(52);
3338 cfg.group_ops_bls12381_scalar_add_cost = Some(52);
3339 cfg.group_ops_bls12381_g1_add_cost = Some(52);
3340 cfg.group_ops_bls12381_g2_add_cost = Some(52);
3341 cfg.group_ops_bls12381_gt_add_cost = Some(52);
3342 cfg.group_ops_bls12381_scalar_sub_cost = Some(52);
3343 cfg.group_ops_bls12381_g1_sub_cost = Some(52);
3344 cfg.group_ops_bls12381_g2_sub_cost = Some(52);
3345 cfg.group_ops_bls12381_gt_sub_cost = Some(52);
3346 cfg.group_ops_bls12381_scalar_mul_cost = Some(52);
3347 cfg.group_ops_bls12381_g1_mul_cost = Some(52);
3348 cfg.group_ops_bls12381_g2_mul_cost = Some(52);
3349 cfg.group_ops_bls12381_gt_mul_cost = Some(52);
3350 cfg.group_ops_bls12381_scalar_div_cost = Some(52);
3351 cfg.group_ops_bls12381_g1_div_cost = Some(52);
3352 cfg.group_ops_bls12381_g2_div_cost = Some(52);
3353 cfg.group_ops_bls12381_gt_div_cost = Some(52);
3354 cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(52);
3355 cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(52);
3356 cfg.group_ops_bls12381_g1_hash_to_cost_per_byte = Some(2);
3357 cfg.group_ops_bls12381_g2_hash_to_cost_per_byte = Some(2);
3358 cfg.group_ops_bls12381_g1_msm_base_cost = Some(52);
3359 cfg.group_ops_bls12381_g2_msm_base_cost = Some(52);
3360 cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(52);
3361 cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(52);
3362 cfg.group_ops_bls12381_msm_max_len = Some(32);
3363 cfg.group_ops_bls12381_pairing_cost = Some(52);
3364 }
3365 42 => {}
3366 43 => {
3367 cfg.feature_flags.zklogin_max_epoch_upper_bound_delta = Some(30);
3368 cfg.max_meter_ticks_per_package = Some(16_000_000);
3369 }
3370 44 => {
3371 cfg.feature_flags.include_consensus_digest_in_prologue = true;
3373 if chain != Chain::Mainnet {
3375 cfg.feature_flags.consensus_choice = ConsensusChoice::SwapEachEpoch;
3376 }
3377 }
3378 45 => {
3379 if chain != Chain::Testnet && chain != Chain::Mainnet {
3381 cfg.feature_flags.consensus_network = ConsensusNetwork::Tonic;
3382 }
3383
3384 if chain != Chain::Mainnet {
3385 cfg.feature_flags.mysticeti_leader_scoring_and_schedule = true;
3387 }
3388 cfg.min_move_binary_format_version = Some(6);
3389 cfg.feature_flags.accept_zklogin_in_multisig = true;
3390
3391 if chain != Chain::Mainnet && chain != Chain::Testnet {
3395 cfg.feature_flags.bridge = true;
3396 }
3397 }
3398 46 => {
3399 if chain != Chain::Mainnet {
3401 cfg.feature_flags.bridge = true;
3402 }
3403
3404 cfg.feature_flags.reshare_at_same_initial_version = true;
3406 }
3407 47 => {}
3408 48 => {
3409 cfg.feature_flags.consensus_network = ConsensusNetwork::Tonic;
3411
3412 cfg.feature_flags.resolve_abort_locations_to_package_id = true;
3414
3415 if chain != Chain::Mainnet {
3417 cfg.feature_flags.random_beacon = true;
3418 cfg.random_beacon_reduction_lower_bound = Some(1600);
3419 cfg.random_beacon_dkg_timeout_round = Some(3000);
3420 cfg.random_beacon_min_round_interval_ms = Some(200);
3421 }
3422
3423 cfg.feature_flags.mysticeti_use_committed_subdag_digest = true;
3425 }
3426 49 => {
3427 if chain != Chain::Testnet && chain != Chain::Mainnet {
3428 cfg.move_binary_format_version = Some(7);
3429 }
3430
3431 if chain != Chain::Mainnet && chain != Chain::Testnet {
3433 cfg.feature_flags.enable_vdf = true;
3434 cfg.vdf_verify_vdf_cost = Some(1500);
3437 cfg.vdf_hash_to_input_cost = Some(100);
3438 }
3439
3440 if chain != Chain::Testnet && chain != Chain::Mainnet {
3442 cfg.feature_flags
3443 .record_consensus_determined_version_assignments_in_prologue = true;
3444 }
3445
3446 if chain != Chain::Mainnet {
3448 cfg.feature_flags.consensus_choice = ConsensusChoice::Mysticeti;
3449 }
3450
3451 cfg.feature_flags.fresh_vm_on_framework_upgrade = true;
3453 }
3454 50 => {
3455 if chain != Chain::Mainnet {
3457 cfg.checkpoint_summary_version_specific_data = Some(1);
3458 cfg.min_checkpoint_interval_ms = Some(200);
3459 }
3460
3461 if chain != Chain::Testnet && chain != Chain::Mainnet {
3463 cfg.feature_flags
3464 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = true;
3465 }
3466
3467 cfg.feature_flags.mysticeti_num_leaders_per_round = Some(1);
3468
3469 cfg.max_deferral_rounds_for_congestion_control = Some(10);
3471 }
3472 51 => {
3473 cfg.random_beacon_dkg_version = Some(1);
3474
3475 if chain != Chain::Testnet && chain != Chain::Mainnet {
3476 cfg.feature_flags.enable_coin_deny_list_v2 = true;
3477 }
3478 }
3479 52 => {
3480 if chain != Chain::Mainnet {
3481 cfg.feature_flags.soft_bundle = true;
3482 cfg.max_soft_bundle_size = Some(5);
3483 }
3484
3485 cfg.config_read_setting_impl_cost_base = Some(100);
3486 cfg.config_read_setting_impl_cost_per_byte = Some(40);
3487
3488 if chain != Chain::Testnet && chain != Chain::Mainnet {
3490 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(100);
3491 cfg.feature_flags.per_object_congestion_control_mode =
3492 PerObjectCongestionControlMode::TotalTxCount;
3493 }
3494
3495 cfg.feature_flags.consensus_choice = ConsensusChoice::Mysticeti;
3497
3498 cfg.feature_flags.mysticeti_leader_scoring_and_schedule = true;
3500
3501 cfg.checkpoint_summary_version_specific_data = Some(1);
3503 cfg.min_checkpoint_interval_ms = Some(200);
3504
3505 if chain != Chain::Mainnet {
3507 cfg.feature_flags
3508 .record_consensus_determined_version_assignments_in_prologue = true;
3509 cfg.feature_flags
3510 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = true;
3511 }
3512 if chain != Chain::Mainnet {
3514 cfg.move_binary_format_version = Some(7);
3515 }
3516
3517 if chain != Chain::Testnet && chain != Chain::Mainnet {
3518 cfg.feature_flags.passkey_auth = true;
3519 }
3520 cfg.feature_flags.enable_coin_deny_list_v2 = true;
3521 }
3522 53 => {
3523 cfg.bridge_should_try_to_finalize_committee = Some(chain != Chain::Mainnet);
3525
3526 cfg.feature_flags
3528 .record_consensus_determined_version_assignments_in_prologue = true;
3529 cfg.feature_flags
3530 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = true;
3531
3532 if chain == Chain::Unknown {
3533 cfg.feature_flags.authority_capabilities_v2 = true;
3534 }
3535
3536 if chain != Chain::Mainnet {
3538 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(100);
3539 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(10);
3540 cfg.feature_flags.per_object_congestion_control_mode =
3541 PerObjectCongestionControlMode::TotalTxCount;
3542 }
3543
3544 cfg.bcs_per_byte_serialized_cost = Some(2);
3546 cfg.bcs_legacy_min_output_size_cost = Some(1);
3547 cfg.bcs_failure_cost = Some(52);
3548 cfg.debug_print_base_cost = Some(52);
3549 cfg.debug_print_stack_trace_base_cost = Some(52);
3550 cfg.hash_sha2_256_base_cost = Some(52);
3551 cfg.hash_sha2_256_per_byte_cost = Some(2);
3552 cfg.hash_sha2_256_legacy_min_input_len_cost = Some(1);
3553 cfg.hash_sha3_256_base_cost = Some(52);
3554 cfg.hash_sha3_256_per_byte_cost = Some(2);
3555 cfg.hash_sha3_256_legacy_min_input_len_cost = Some(1);
3556 cfg.type_name_get_base_cost = Some(52);
3557 cfg.type_name_get_per_byte_cost = Some(2);
3558 cfg.string_check_utf8_base_cost = Some(52);
3559 cfg.string_check_utf8_per_byte_cost = Some(2);
3560 cfg.string_is_char_boundary_base_cost = Some(52);
3561 cfg.string_sub_string_base_cost = Some(52);
3562 cfg.string_sub_string_per_byte_cost = Some(2);
3563 cfg.string_index_of_base_cost = Some(52);
3564 cfg.string_index_of_per_byte_pattern_cost = Some(2);
3565 cfg.string_index_of_per_byte_searched_cost = Some(2);
3566 cfg.vector_empty_base_cost = Some(52);
3567 cfg.vector_length_base_cost = Some(52);
3568 cfg.vector_push_back_base_cost = Some(52);
3569 cfg.vector_push_back_legacy_per_abstract_memory_unit_cost = Some(2);
3570 cfg.vector_borrow_base_cost = Some(52);
3571 cfg.vector_pop_back_base_cost = Some(52);
3572 cfg.vector_destroy_empty_base_cost = Some(52);
3573 cfg.vector_swap_base_cost = Some(52);
3574 }
3575 54 => {
3576 cfg.feature_flags.random_beacon = true;
3578 cfg.random_beacon_reduction_lower_bound = Some(1000);
3579 cfg.random_beacon_dkg_timeout_round = Some(3000);
3580 cfg.random_beacon_min_round_interval_ms = Some(500);
3581
3582 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(100);
3584 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(10);
3585 cfg.feature_flags.per_object_congestion_control_mode =
3586 PerObjectCongestionControlMode::TotalTxCount;
3587
3588 cfg.feature_flags.soft_bundle = true;
3590 cfg.max_soft_bundle_size = Some(5);
3591 }
3592 55 => {
3593 cfg.move_binary_format_version = Some(7);
3595
3596 cfg.consensus_max_transactions_in_block_bytes = Some(512 * 1024);
3598 cfg.consensus_max_num_transactions_in_block = Some(512);
3601
3602 cfg.feature_flags.rethrow_serialization_type_layout_errors = true;
3603 }
3604 56 => {
3605 if chain == Chain::Mainnet {
3606 cfg.feature_flags.bridge = true;
3607 }
3608 }
3609 57 => {
3610 cfg.random_beacon_reduction_lower_bound = Some(800);
3612 }
3613 58 => {
3614 if chain == Chain::Mainnet {
3615 cfg.bridge_should_try_to_finalize_committee = Some(true);
3616 }
3617
3618 if chain != Chain::Mainnet && chain != Chain::Testnet {
3619 cfg.feature_flags
3621 .consensus_distributed_vote_scoring_strategy = true;
3622 }
3623 }
3624 59 => {
3625 cfg.feature_flags.consensus_round_prober = true;
3627 }
3628 60 => {
3629 cfg.max_type_to_layout_nodes = Some(512);
3630 cfg.feature_flags.validate_identifier_inputs = true;
3631 }
3632 61 => {
3633 if chain != Chain::Mainnet {
3634 cfg.feature_flags
3636 .consensus_distributed_vote_scoring_strategy = true;
3637 }
3638 cfg.random_beacon_reduction_lower_bound = Some(700);
3640
3641 if chain != Chain::Mainnet && chain != Chain::Testnet {
3642 cfg.feature_flags.mysticeti_fastpath = true;
3644 }
3645 }
3646 62 => {
3647 cfg.feature_flags.relocate_event_module = true;
3648 }
3649 63 => {
3650 cfg.feature_flags.per_object_congestion_control_mode =
3651 PerObjectCongestionControlMode::TotalGasBudgetWithCap;
3652 cfg.gas_budget_based_txn_cost_cap_factor = Some(400_000);
3653 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(18_500_000);
3654 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(240_000_000);
3655 }
3656 64 => {
3657 cfg.feature_flags.per_object_congestion_control_mode =
3658 PerObjectCongestionControlMode::TotalTxCount;
3659 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(40);
3660 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(3);
3661 }
3662 65 => {
3663 cfg.feature_flags
3665 .consensus_distributed_vote_scoring_strategy = true;
3666 }
3667 66 => {
3668 if chain == Chain::Mainnet {
3669 cfg.feature_flags
3671 .consensus_distributed_vote_scoring_strategy = false;
3672 }
3673 }
3674 67 => {
3675 cfg.feature_flags
3677 .consensus_distributed_vote_scoring_strategy = true;
3678 }
3679 68 => {
3680 cfg.group_ops_bls12381_g1_to_uncompressed_g1_cost = Some(26);
3681 cfg.group_ops_bls12381_uncompressed_g1_to_g1_cost = Some(52);
3682 cfg.group_ops_bls12381_uncompressed_g1_sum_base_cost = Some(26);
3683 cfg.group_ops_bls12381_uncompressed_g1_sum_cost_per_term = Some(13);
3684 cfg.group_ops_bls12381_uncompressed_g1_sum_max_terms = Some(2000);
3685
3686 if chain != Chain::Mainnet && chain != Chain::Testnet {
3687 cfg.feature_flags.uncompressed_g1_group_elements = true;
3688 }
3689
3690 cfg.feature_flags.per_object_congestion_control_mode =
3691 PerObjectCongestionControlMode::TotalGasBudgetWithCap;
3692 cfg.gas_budget_based_txn_cost_cap_factor = Some(400_000);
3693 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(18_500_000);
3694 cfg.max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit =
3695 Some(3_700_000); cfg.max_txn_cost_overage_per_object_in_commit = Some(u64::MAX);
3697 cfg.gas_budget_based_txn_cost_absolute_cap_commit_count = Some(50);
3698
3699 cfg.random_beacon_reduction_lower_bound = Some(500);
3701
3702 cfg.feature_flags.disallow_new_modules_in_deps_only_packages = true;
3703 }
3704 69 => {
3705 cfg.consensus_voting_rounds = Some(40);
3707
3708 if chain != Chain::Mainnet && chain != Chain::Testnet {
3709 cfg.feature_flags.consensus_smart_ancestor_selection = true;
3711 }
3712
3713 if chain != Chain::Mainnet {
3714 cfg.feature_flags.uncompressed_g1_group_elements = true;
3715 }
3716 }
3717 70 => {
3718 if chain != Chain::Mainnet {
3719 cfg.feature_flags.consensus_smart_ancestor_selection = true;
3721 cfg.feature_flags
3723 .consensus_round_prober_probe_accepted_rounds = true;
3724 }
3725
3726 cfg.poseidon_bn254_cost_per_block = Some(388);
3727
3728 cfg.gas_model_version = Some(9);
3729 cfg.feature_flags.native_charging_v2 = true;
3730 cfg.bls12381_bls12381_min_sig_verify_cost_base = Some(44064);
3731 cfg.bls12381_bls12381_min_pk_verify_cost_base = Some(49282);
3732 cfg.ecdsa_k1_secp256k1_verify_keccak256_cost_base = Some(1470);
3733 cfg.ecdsa_k1_secp256k1_verify_sha256_cost_base = Some(1470);
3734 cfg.ecdsa_r1_secp256r1_verify_sha256_cost_base = Some(4225);
3735 cfg.ecdsa_r1_secp256r1_verify_keccak256_cost_base = Some(4225);
3736 cfg.ecvrf_ecvrf_verify_cost_base = Some(4848);
3737 cfg.ed25519_ed25519_verify_cost_base = Some(1802);
3738
3739 cfg.ecdsa_r1_ecrecover_keccak256_cost_base = Some(1173);
3741 cfg.ecdsa_r1_ecrecover_sha256_cost_base = Some(1173);
3742 cfg.ecdsa_k1_ecrecover_keccak256_cost_base = Some(500);
3743 cfg.ecdsa_k1_ecrecover_sha256_cost_base = Some(500);
3744
3745 cfg.groth16_prepare_verifying_key_bls12381_cost_base = Some(53838);
3746 cfg.groth16_prepare_verifying_key_bn254_cost_base = Some(82010);
3747 cfg.groth16_verify_groth16_proof_internal_bls12381_cost_base = Some(72090);
3748 cfg.groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input =
3749 Some(8213);
3750 cfg.groth16_verify_groth16_proof_internal_bn254_cost_base = Some(115502);
3751 cfg.groth16_verify_groth16_proof_internal_bn254_cost_per_public_input =
3752 Some(9484);
3753
3754 cfg.hash_keccak256_cost_base = Some(10);
3755 cfg.hash_blake2b256_cost_base = Some(10);
3756
3757 cfg.group_ops_bls12381_decode_scalar_cost = Some(7);
3759 cfg.group_ops_bls12381_decode_g1_cost = Some(2848);
3760 cfg.group_ops_bls12381_decode_g2_cost = Some(3770);
3761 cfg.group_ops_bls12381_decode_gt_cost = Some(3068);
3762
3763 cfg.group_ops_bls12381_scalar_add_cost = Some(10);
3764 cfg.group_ops_bls12381_g1_add_cost = Some(1556);
3765 cfg.group_ops_bls12381_g2_add_cost = Some(3048);
3766 cfg.group_ops_bls12381_gt_add_cost = Some(188);
3767
3768 cfg.group_ops_bls12381_scalar_sub_cost = Some(10);
3769 cfg.group_ops_bls12381_g1_sub_cost = Some(1550);
3770 cfg.group_ops_bls12381_g2_sub_cost = Some(3019);
3771 cfg.group_ops_bls12381_gt_sub_cost = Some(497);
3772
3773 cfg.group_ops_bls12381_scalar_mul_cost = Some(11);
3774 cfg.group_ops_bls12381_g1_mul_cost = Some(4842);
3775 cfg.group_ops_bls12381_g2_mul_cost = Some(9108);
3776 cfg.group_ops_bls12381_gt_mul_cost = Some(27490);
3777
3778 cfg.group_ops_bls12381_scalar_div_cost = Some(91);
3779 cfg.group_ops_bls12381_g1_div_cost = Some(5091);
3780 cfg.group_ops_bls12381_g2_div_cost = Some(9206);
3781 cfg.group_ops_bls12381_gt_div_cost = Some(27804);
3782
3783 cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(2962);
3784 cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(8688);
3785
3786 cfg.group_ops_bls12381_g1_msm_base_cost = Some(62648);
3787 cfg.group_ops_bls12381_g2_msm_base_cost = Some(131192);
3788 cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(1333);
3789 cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(3216);
3790
3791 cfg.group_ops_bls12381_uncompressed_g1_to_g1_cost = Some(677);
3792 cfg.group_ops_bls12381_g1_to_uncompressed_g1_cost = Some(2099);
3793 cfg.group_ops_bls12381_uncompressed_g1_sum_base_cost = Some(77);
3794 cfg.group_ops_bls12381_uncompressed_g1_sum_cost_per_term = Some(26);
3795
3796 cfg.group_ops_bls12381_pairing_cost = Some(26897);
3797 cfg.group_ops_bls12381_uncompressed_g1_sum_max_terms = Some(1200);
3798
3799 cfg.validator_validate_metadata_cost_base = Some(20000);
3800 }
3801 71 => {
3802 cfg.sip_45_consensus_amplification_threshold = Some(5);
3803
3804 cfg.allowed_txn_cost_overage_burst_per_object_in_commit = Some(185_000_000);
3806 }
3807 72 => {
3808 cfg.feature_flags.convert_type_argument_error = true;
3809
3810 cfg.max_tx_gas = Some(50_000_000_000_000);
3813 cfg.max_gas_price = Some(50_000_000_000);
3815
3816 cfg.feature_flags.variant_nodes = true;
3817 }
3818 73 => {
3819 cfg.use_object_per_epoch_marker_table_v2 = Some(true);
3821
3822 if chain != Chain::Mainnet && chain != Chain::Testnet {
3823 cfg.consensus_gc_depth = Some(60);
3826 }
3827
3828 if chain != Chain::Mainnet {
3829 cfg.feature_flags.consensus_zstd_compression = true;
3831 }
3832
3833 cfg.feature_flags.consensus_smart_ancestor_selection = true;
3835 cfg.feature_flags
3837 .consensus_round_prober_probe_accepted_rounds = true;
3838
3839 cfg.feature_flags.per_object_congestion_control_mode =
3841 PerObjectCongestionControlMode::TotalGasBudgetWithCap;
3842 cfg.gas_budget_based_txn_cost_cap_factor = Some(400_000);
3843 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(37_000_000);
3844 cfg.max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit =
3845 Some(7_400_000); cfg.max_txn_cost_overage_per_object_in_commit = Some(u64::MAX);
3847 cfg.gas_budget_based_txn_cost_absolute_cap_commit_count = Some(50);
3848 cfg.allowed_txn_cost_overage_burst_per_object_in_commit = Some(370_000_000);
3849 }
3850 74 => {
3851 if chain != Chain::Mainnet && chain != Chain::Testnet {
3853 cfg.feature_flags.enable_nitro_attestation = true;
3854 }
3855 cfg.nitro_attestation_parse_base_cost = Some(53 * 50);
3856 cfg.nitro_attestation_parse_cost_per_byte = Some(50);
3857 cfg.nitro_attestation_verify_base_cost = Some(49632 * 50);
3858 cfg.nitro_attestation_verify_cost_per_cert = Some(52369 * 50);
3859
3860 cfg.feature_flags.consensus_zstd_compression = true;
3862
3863 if chain != Chain::Mainnet && chain != Chain::Testnet {
3864 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
3865 }
3866 }
3867 75 => {
3868 if chain != Chain::Mainnet {
3869 cfg.feature_flags.passkey_auth = true;
3870 }
3871 }
3872 76 => {
3873 if chain != Chain::Mainnet && chain != Chain::Testnet {
3874 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
3875 cfg.consensus_commit_rate_estimation_window_size = Some(10);
3876 }
3877 cfg.feature_flags.minimize_child_object_mutations = true;
3878
3879 if chain != Chain::Mainnet {
3880 cfg.feature_flags.accept_passkey_in_multisig = true;
3881 }
3882 }
3883 77 => {
3884 cfg.feature_flags.uncompressed_g1_group_elements = true;
3885
3886 if chain != Chain::Mainnet {
3887 cfg.consensus_gc_depth = Some(60);
3888 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
3889 }
3890 }
3891 78 => {
3892 cfg.feature_flags.move_native_context = true;
3893 cfg.tx_context_fresh_id_cost_base = Some(52);
3894 cfg.tx_context_sender_cost_base = Some(30);
3895 cfg.tx_context_epoch_cost_base = Some(30);
3896 cfg.tx_context_epoch_timestamp_ms_cost_base = Some(30);
3897 cfg.tx_context_sponsor_cost_base = Some(30);
3898 cfg.tx_context_gas_price_cost_base = Some(30);
3899 cfg.tx_context_gas_budget_cost_base = Some(30);
3900 cfg.tx_context_ids_created_cost_base = Some(30);
3901 cfg.tx_context_replace_cost_base = Some(30);
3902 cfg.gas_model_version = Some(10);
3903
3904 if chain != Chain::Mainnet {
3905 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
3906 cfg.consensus_commit_rate_estimation_window_size = Some(10);
3907
3908 cfg.feature_flags.per_object_congestion_control_mode =
3910 PerObjectCongestionControlMode::ExecutionTimeEstimate(
3911 ExecutionTimeEstimateParams {
3912 target_utilization: 30,
3913 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
3915 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
3917 stored_observations_limit: u64::MAX,
3918 stake_weighted_median_threshold: 0,
3919 default_none_duration_for_new_keys: false,
3920 observations_chunk_size: None,
3921 },
3922 );
3923 }
3924 }
3925 79 => {
3926 if chain != Chain::Mainnet {
3927 cfg.feature_flags.consensus_median_based_commit_timestamp = true;
3928
3929 cfg.consensus_bad_nodes_stake_threshold = Some(30);
3932
3933 cfg.feature_flags.consensus_batched_block_sync = true;
3934
3935 cfg.feature_flags.enable_nitro_attestation = true
3937 }
3938 cfg.feature_flags.normalize_ptb_arguments = true;
3939
3940 cfg.consensus_gc_depth = Some(60);
3941 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
3942 }
3943 80 => {
3944 cfg.max_ptb_value_size = Some(1024 * 1024);
3945 }
3946 81 => {
3947 cfg.feature_flags.consensus_median_based_commit_timestamp = true;
3948 cfg.feature_flags.enforce_checkpoint_timestamp_monotonicity = true;
3949 cfg.consensus_bad_nodes_stake_threshold = Some(30)
3950 }
3951 82 => {
3952 cfg.feature_flags.max_ptb_value_size_v2 = true;
3953 }
3954 83 => {
3955 if chain == Chain::Mainnet {
3956 let aliased: [u8; 32] = Hex::decode(
3958 "0x0b2da327ba6a4cacbe75dddd50e6e8bbf81d6496e92d66af9154c61c77f7332f",
3959 )
3960 .unwrap()
3961 .try_into()
3962 .unwrap();
3963
3964 cfg.aliased_addresses.push(AliasedAddress {
3966 original: Hex::decode("0xcd8962dad278d8b50fa0f9eb0186bfa4cbdecc6d59377214c88d0286a0ac9562").unwrap().try_into().unwrap(),
3967 aliased,
3968 allowed_tx_digests: vec![
3969 Base58::decode("B2eGLFoMHgj93Ni8dAJBfqGzo8EWSTLBesZzhEpTPA4").unwrap().try_into().unwrap(),
3970 ],
3971 });
3972
3973 cfg.aliased_addresses.push(AliasedAddress {
3974 original: Hex::decode("0xe28b50cef1d633ea43d3296a3f6b67ff0312a5f1a99f0af753c85b8b5de8ff06").unwrap().try_into().unwrap(),
3975 aliased,
3976 allowed_tx_digests: vec![
3977 Base58::decode("J4QqSAgp7VrQtQpMy5wDX4QGsCSEZu3U5KuDAkbESAge").unwrap().try_into().unwrap(),
3978 ],
3979 });
3980 }
3981
3982 if chain != Chain::Mainnet {
3985 cfg.feature_flags.resolve_type_input_ids_to_defining_id = true;
3986 cfg.transfer_party_transfer_internal_cost_base = Some(52);
3987
3988 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
3990 cfg.consensus_commit_rate_estimation_window_size = Some(10);
3991 cfg.feature_flags.per_object_congestion_control_mode =
3992 PerObjectCongestionControlMode::ExecutionTimeEstimate(
3993 ExecutionTimeEstimateParams {
3994 target_utilization: 30,
3995 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
3997 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
3999 stored_observations_limit: u64::MAX,
4000 stake_weighted_median_threshold: 0,
4001 default_none_duration_for_new_keys: false,
4002 observations_chunk_size: None,
4003 },
4004 );
4005
4006 cfg.feature_flags.consensus_batched_block_sync = true;
4008
4009 cfg.feature_flags.enable_nitro_attestation_upgraded_parsing = true;
4012 cfg.feature_flags.enable_nitro_attestation = true;
4013 }
4014 }
4015 84 => {
4016 if chain == Chain::Mainnet {
4017 cfg.feature_flags.resolve_type_input_ids_to_defining_id = true;
4018 cfg.transfer_party_transfer_internal_cost_base = Some(52);
4019
4020 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
4022 cfg.consensus_commit_rate_estimation_window_size = Some(10);
4023 cfg.feature_flags.per_object_congestion_control_mode =
4024 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4025 ExecutionTimeEstimateParams {
4026 target_utilization: 30,
4027 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4029 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4031 stored_observations_limit: u64::MAX,
4032 stake_weighted_median_threshold: 0,
4033 default_none_duration_for_new_keys: false,
4034 observations_chunk_size: None,
4035 },
4036 );
4037
4038 cfg.feature_flags.consensus_batched_block_sync = true;
4040
4041 cfg.feature_flags.enable_nitro_attestation_upgraded_parsing = true;
4044 cfg.feature_flags.enable_nitro_attestation = true;
4045 }
4046
4047 cfg.feature_flags.per_object_congestion_control_mode =
4049 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4050 ExecutionTimeEstimateParams {
4051 target_utilization: 30,
4052 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4054 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4056 stored_observations_limit: 20,
4057 stake_weighted_median_threshold: 0,
4058 default_none_duration_for_new_keys: false,
4059 observations_chunk_size: None,
4060 },
4061 );
4062 cfg.feature_flags.allow_unbounded_system_objects = true;
4063 }
4064 85 => {
4065 if chain != Chain::Mainnet && chain != Chain::Testnet {
4066 cfg.feature_flags.enable_party_transfer = true;
4067 }
4068
4069 cfg.feature_flags
4070 .record_consensus_determined_version_assignments_in_prologue_v2 = true;
4071 cfg.feature_flags.disallow_self_identifier = true;
4072 cfg.feature_flags.per_object_congestion_control_mode =
4073 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4074 ExecutionTimeEstimateParams {
4075 target_utilization: 50,
4076 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4078 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4080 stored_observations_limit: 20,
4081 stake_weighted_median_threshold: 0,
4082 default_none_duration_for_new_keys: false,
4083 observations_chunk_size: None,
4084 },
4085 );
4086 }
4087 86 => {
4088 cfg.feature_flags.type_tags_in_object_runtime = true;
4089 cfg.max_move_enum_variants = Some(move_core_types::VARIANT_COUNT_MAX);
4090
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: 20,
4101 stake_weighted_median_threshold: 3334,
4102 default_none_duration_for_new_keys: false,
4103 observations_chunk_size: None,
4104 },
4105 );
4106 if chain != Chain::Mainnet {
4108 cfg.feature_flags.enable_party_transfer = true;
4109 }
4110 }
4111 87 => {
4112 if chain == Chain::Mainnet {
4113 cfg.feature_flags.record_time_estimate_processed = true;
4114 }
4115 cfg.feature_flags.better_adapter_type_resolution_errors = true;
4116 }
4117 88 => {
4118 cfg.feature_flags.record_time_estimate_processed = true;
4119 cfg.tx_context_rgp_cost_base = Some(30);
4120 cfg.feature_flags
4121 .ignore_execution_time_observations_after_certs_closed = true;
4122
4123 cfg.feature_flags.per_object_congestion_control_mode =
4126 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4127 ExecutionTimeEstimateParams {
4128 target_utilization: 50,
4129 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4131 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4133 stored_observations_limit: 20,
4134 stake_weighted_median_threshold: 3334,
4135 default_none_duration_for_new_keys: true,
4136 observations_chunk_size: None,
4137 },
4138 );
4139 }
4140 89 => {
4141 cfg.feature_flags.dependency_linkage_error = true;
4142 cfg.feature_flags.additional_multisig_checks = true;
4143 }
4144 90 => {
4145 cfg.max_gas_price_rgp_factor_for_aborted_transactions = Some(100);
4147 cfg.feature_flags.debug_fatal_on_move_invariant_violation = true;
4148 cfg.feature_flags.additional_consensus_digest_indirect_state = true;
4149 cfg.feature_flags.accept_passkey_in_multisig = true;
4150 cfg.feature_flags.passkey_auth = true;
4151 cfg.feature_flags.check_for_init_during_upgrade = true;
4152
4153 if chain != Chain::Mainnet {
4155 cfg.feature_flags.mysticeti_fastpath = true;
4156 }
4157 }
4158 91 => {
4159 cfg.feature_flags.per_command_shared_object_transfer_rules = true;
4160 }
4161 92 => {
4162 cfg.feature_flags.per_command_shared_object_transfer_rules = false;
4163 }
4164 93 => {
4165 cfg.feature_flags
4166 .consensus_checkpoint_signature_key_includes_digest = true;
4167 }
4168 94 => {
4169 cfg.feature_flags.per_object_congestion_control_mode =
4171 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4172 ExecutionTimeEstimateParams {
4173 target_utilization: 50,
4174 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4176 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4178 stored_observations_limit: 18,
4179 stake_weighted_median_threshold: 3334,
4180 default_none_duration_for_new_keys: true,
4181 observations_chunk_size: None,
4182 },
4183 );
4184
4185 cfg.feature_flags.enable_party_transfer = true;
4187 }
4188 95 => {
4189 cfg.type_name_id_base_cost = Some(52);
4190
4191 cfg.max_transactions_per_checkpoint = Some(20_000);
4193 }
4194 96 => {
4195 if chain != Chain::Mainnet && chain != Chain::Testnet {
4197 cfg.feature_flags
4198 .include_checkpoint_artifacts_digest_in_summary = true;
4199 }
4200 cfg.feature_flags.correct_gas_payment_limit_check = true;
4201 cfg.feature_flags.authority_capabilities_v2 = true;
4202 cfg.feature_flags.use_mfp_txns_in_load_initial_object_debts = true;
4203 cfg.feature_flags.cancel_for_failed_dkg_early = true;
4204 cfg.feature_flags.enable_coin_registry = true;
4205
4206 cfg.feature_flags.mysticeti_fastpath = true;
4208 }
4209 97 => {
4210 cfg.feature_flags.additional_borrow_checks = true;
4211 }
4212 98 => {
4213 cfg.event_emit_auth_stream_cost = Some(52);
4214 cfg.feature_flags.better_loader_errors = true;
4215 cfg.feature_flags.generate_df_type_layouts = true;
4216 }
4217 99 => {
4218 cfg.feature_flags.use_new_commit_handler = true;
4219 }
4220 100 => {
4221 cfg.feature_flags.private_generics_verifier_v2 = true;
4222 }
4223 101 => {
4224 cfg.feature_flags.create_root_accumulator_object = true;
4225 cfg.max_updates_per_settlement_txn = Some(100);
4226 if chain != Chain::Mainnet {
4227 cfg.feature_flags.enable_poseidon = true;
4228 }
4229 }
4230 102 => {
4231 cfg.feature_flags.per_object_congestion_control_mode =
4235 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4236 ExecutionTimeEstimateParams {
4237 target_utilization: 50,
4238 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4240 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4242 stored_observations_limit: 180,
4243 stake_weighted_median_threshold: 3334,
4244 default_none_duration_for_new_keys: true,
4245 observations_chunk_size: Some(18),
4246 },
4247 );
4248 cfg.feature_flags.deprecate_global_storage_ops = true;
4249 }
4250 103 => {}
4251 104 => {
4252 cfg.translation_per_command_base_charge = Some(1);
4253 cfg.translation_per_input_base_charge = Some(1);
4254 cfg.translation_pure_input_per_byte_charge = Some(1);
4255 cfg.translation_per_type_node_charge = Some(1);
4256 cfg.translation_per_reference_node_charge = Some(1);
4257 cfg.translation_per_linkage_entry_charge = Some(10);
4258 cfg.gas_model_version = Some(11);
4259 cfg.feature_flags.abstract_size_in_object_runtime = true;
4260 cfg.feature_flags.object_runtime_charge_cache_load_gas = true;
4261 cfg.dynamic_field_hash_type_and_key_cost_base = Some(52);
4262 cfg.dynamic_field_add_child_object_cost_base = Some(52);
4263 cfg.dynamic_field_add_child_object_value_cost_per_byte = Some(1);
4264 cfg.dynamic_field_borrow_child_object_cost_base = Some(52);
4265 cfg.dynamic_field_borrow_child_object_child_ref_cost_per_byte = Some(1);
4266 cfg.dynamic_field_remove_child_object_cost_base = Some(52);
4267 cfg.dynamic_field_remove_child_object_child_cost_per_byte = Some(1);
4268 cfg.dynamic_field_has_child_object_cost_base = Some(52);
4269 cfg.dynamic_field_has_child_object_with_ty_cost_base = Some(52);
4270 cfg.feature_flags.enable_ptb_execution_v2 = true;
4271
4272 cfg.poseidon_bn254_cost_base = Some(260);
4273
4274 cfg.feature_flags.consensus_skip_gced_accept_votes = true;
4275
4276 if chain != Chain::Mainnet {
4277 cfg.feature_flags
4278 .enable_nitro_attestation_all_nonzero_pcrs_parsing = true;
4279 }
4280
4281 cfg.feature_flags
4282 .include_cancelled_randomness_txns_in_prologue = true;
4283 }
4284 105 => {
4285 cfg.feature_flags.enable_multi_epoch_transaction_expiration = true;
4286 cfg.feature_flags.disable_preconsensus_locking = true;
4287
4288 if chain != Chain::Mainnet {
4289 cfg.feature_flags
4290 .enable_nitro_attestation_always_include_required_pcrs_parsing = true;
4291 }
4292 }
4293 106 => {
4294 cfg.accumulator_object_storage_cost = Some(7600);
4296
4297 if chain != Chain::Mainnet && chain != Chain::Testnet {
4298 cfg.feature_flags.enable_accumulators = true;
4299 cfg.feature_flags.enable_address_balance_gas_payments = true;
4300 cfg.feature_flags.enable_authenticated_event_streams = true;
4301 cfg.feature_flags.enable_object_funds_withdraw = true;
4302 }
4303 }
4304 107 => {
4305 cfg.feature_flags
4306 .consensus_skip_gced_blocks_in_direct_finalization = true;
4307
4308 if in_integration_test() {
4310 cfg.consensus_gc_depth = Some(6);
4311 cfg.consensus_max_num_transactions_in_block = Some(8);
4312 }
4313 }
4314 108 => {
4315 cfg.feature_flags.gas_rounding_halve_digits = true;
4316 cfg.feature_flags.flexible_tx_context_positions = true;
4317 cfg.feature_flags.disable_entry_point_signature_check = true;
4318
4319 if chain != Chain::Mainnet {
4320 cfg.feature_flags.address_aliases = true;
4321
4322 cfg.feature_flags.enable_accumulators = true;
4323 cfg.feature_flags.enable_address_balance_gas_payments = true;
4324 }
4325
4326 cfg.feature_flags.enable_poseidon = true;
4327 }
4328 109 => {
4329 cfg.binary_variant_handles = Some(1024);
4330 cfg.binary_variant_instantiation_handles = Some(1024);
4331 cfg.feature_flags.restrict_hot_or_not_entry_functions = true;
4332 }
4333 110 => {
4334 cfg.feature_flags
4335 .enable_nitro_attestation_all_nonzero_pcrs_parsing = true;
4336 cfg.feature_flags
4337 .enable_nitro_attestation_always_include_required_pcrs_parsing = true;
4338 if chain != Chain::Mainnet && chain != Chain::Testnet {
4339 cfg.feature_flags.split_checkpoints_in_consensus_handler = true;
4340 }
4341 cfg.feature_flags.validate_zklogin_public_identifier = true;
4342 cfg.feature_flags.fix_checkpoint_signature_mapping = true;
4343 cfg.feature_flags
4344 .consensus_always_accept_system_transactions = true;
4345 if chain != Chain::Mainnet {
4346 cfg.feature_flags.enable_object_funds_withdraw = true;
4347 }
4348 }
4349 111 => {
4350 cfg.feature_flags.validator_metadata_verify_v2 = true;
4351 }
4352 112 => {
4353 cfg.group_ops_ristretto_decode_scalar_cost = Some(7);
4354 cfg.group_ops_ristretto_decode_point_cost = Some(200);
4355 cfg.group_ops_ristretto_scalar_add_cost = Some(10);
4356 cfg.group_ops_ristretto_point_add_cost = Some(500);
4357 cfg.group_ops_ristretto_scalar_sub_cost = Some(10);
4358 cfg.group_ops_ristretto_point_sub_cost = Some(500);
4359 cfg.group_ops_ristretto_scalar_mul_cost = Some(11);
4360 cfg.group_ops_ristretto_point_mul_cost = Some(1200);
4361 cfg.group_ops_ristretto_scalar_div_cost = Some(151);
4362 cfg.group_ops_ristretto_point_div_cost = Some(2500);
4363
4364 if chain != Chain::Mainnet && chain != Chain::Testnet {
4365 cfg.feature_flags.enable_ristretto255_group_ops = true;
4366 }
4367 }
4368 113 => {
4369 cfg.feature_flags.address_balance_gas_check_rgp_at_signing = true;
4370 if chain != Chain::Mainnet && chain != Chain::Testnet {
4371 cfg.feature_flags.defer_unpaid_amplification = true;
4372 }
4373 }
4374 114 => {
4375 cfg.feature_flags.randomize_checkpoint_tx_limit_in_tests = true;
4376 cfg.feature_flags.address_balance_gas_reject_gas_coin_arg = true;
4377 if chain != Chain::Mainnet {
4378 cfg.feature_flags.split_checkpoints_in_consensus_handler = true;
4379 cfg.feature_flags.enable_authenticated_event_streams = true;
4380 cfg.feature_flags
4381 .include_checkpoint_artifacts_digest_in_summary = true;
4382 }
4383 }
4384 115 => {
4385 cfg.feature_flags.normalize_depth_formula = true;
4386 }
4387 116 => {
4388 cfg.feature_flags.gasless_transaction_drop_safety = true;
4389 cfg.feature_flags.address_aliases = true;
4390 cfg.feature_flags.relax_valid_during_for_owned_inputs = true;
4391 cfg.feature_flags.defer_unpaid_amplification = false;
4393 cfg.feature_flags.enable_display_registry = true;
4394 }
4395 117 => {}
4396 118 => {
4397 cfg.feature_flags.use_coin_party_owner = true;
4398 }
4399 119 => {
4400 cfg.execution_version = Some(4);
4402 cfg.feature_flags.address_balance_gas_reject_gas_coin_arg = false;
4403 cfg.feature_flags.merge_randomness_into_checkpoint = true;
4404 if chain != Chain::Mainnet {
4405 cfg.feature_flags.enable_gasless = true;
4406 cfg.gasless_max_computation_units = Some(50_000);
4407 cfg.gasless_allowed_token_types = Some(vec![]);
4408 cfg.feature_flags.enable_coin_reservation_obj_refs = true;
4409 cfg.feature_flags
4410 .convert_withdrawal_compatibility_ptb_arguments = true;
4411 }
4412 cfg.gasless_max_unused_inputs = Some(1);
4413 cfg.gasless_max_pure_input_bytes = Some(32);
4414 if chain == Chain::Testnet {
4415 cfg.gasless_allowed_token_types = Some(vec![(TESTNET_USDC.to_string(), 0)]);
4416 }
4417 cfg.transfer_receive_object_cost_per_byte = Some(1);
4418 cfg.transfer_receive_object_type_cost_per_byte = Some(2);
4419 }
4420 120 => {
4421 cfg.feature_flags.disallow_jump_orphans = true;
4422 }
4423 121 => {
4424 if chain != Chain::Mainnet {
4426 cfg.feature_flags.defer_unpaid_amplification = true;
4427 cfg.gasless_max_tps = Some(50);
4428 }
4429 cfg.feature_flags
4430 .early_return_receive_object_mismatched_type = true;
4431 }
4432 122 => {
4433 cfg.feature_flags.defer_unpaid_amplification = true;
4435 cfg.verify_bulletproofs_ristretto255_base_cost = Some(30000);
4437 cfg.verify_bulletproofs_ristretto255_cost_per_bit_and_commitment = Some(6500);
4438 if chain != Chain::Mainnet && chain != Chain::Testnet {
4439 cfg.feature_flags.enable_verify_bulletproofs_ristretto255 = true;
4440 }
4441 cfg.feature_flags.gasless_verify_remaining_balance = true;
4442 cfg.include_special_package_amendments = match chain {
4443 Chain::Mainnet => Some(MAINNET_LINKAGE_AMENDMENTS.clone()),
4444 Chain::Testnet => Some(TESTNET_LINKAGE_AMENDMENTS.clone()),
4445 Chain::Unknown => None,
4446 };
4447 cfg.gasless_max_tx_size_bytes = Some(16 * 1024);
4448 cfg.gasless_max_tps = Some(300);
4449 cfg.gasless_max_computation_units = Some(5_000);
4450 }
4451 123 => {
4452 cfg.gas_model_version = Some(13);
4453 }
4454 124 => {
4455 if chain != Chain::Mainnet && chain != Chain::Testnet {
4456 cfg.feature_flags.timestamp_based_epoch_close = true;
4457 }
4458 cfg.gas_model_version = Some(14);
4459 cfg.feature_flags.limit_groth16_pvk_inputs = true;
4460
4461 cfg.feature_flags.enable_accumulators = true;
4467 cfg.feature_flags.enable_address_balance_gas_payments = true;
4468 cfg.feature_flags.enable_authenticated_event_streams = true;
4469 cfg.feature_flags.enable_coin_reservation_obj_refs = true;
4470 cfg.feature_flags.enable_object_funds_withdraw = true;
4471 cfg.feature_flags
4472 .convert_withdrawal_compatibility_ptb_arguments = true;
4473 cfg.feature_flags.split_checkpoints_in_consensus_handler = true;
4474 cfg.feature_flags
4475 .include_checkpoint_artifacts_digest_in_summary = true;
4476 cfg.feature_flags.enable_gasless = true;
4477
4478 if chain == Chain::Mainnet {
4483 cfg.gasless_allowed_token_types = Some(vec![
4484 (MAINNET_USDC.to_string(), 10_000),
4485 (MAINNET_USDSUI.to_string(), 10_000),
4486 (MAINNET_SUI_USDE.to_string(), 10_000),
4487 (MAINNET_USDY.to_string(), 10_000),
4488 (MAINNET_FDUSD.to_string(), 10_000),
4489 (MAINNET_AUSD.to_string(), 10_000),
4490 (MAINNET_USDB.to_string(), 10_000),
4491 ]);
4492 }
4493 }
4494 125 => {
4495 cfg.feature_flags.granular_post_execution_checks = true;
4496 if chain != Chain::Mainnet {
4497 cfg.feature_flags.timestamp_based_epoch_close = true;
4498 }
4499 }
4500 126 => {
4501 cfg.feature_flags.early_exit_on_iffw = true;
4502 }
4503 127 => {
4504 cfg.feature_flags.always_advance_dkg_to_resolution = true;
4505
4506 cfg.verify_bulletproofs_ristretto255_base_cost = Some(23866);
4507 cfg.verify_bulletproofs_ristretto255_cost_per_bit_and_commitment = Some(1324);
4508 cfg.group_ops_ristretto_decode_scalar_cost = Some(5);
4509 cfg.group_ops_ristretto_decode_point_cost = Some(216);
4510 cfg.group_ops_ristretto_scalar_add_cost = Some(2);
4511 cfg.group_ops_ristretto_point_add_cost = Some(8);
4512 cfg.group_ops_ristretto_scalar_sub_cost = Some(2);
4513 cfg.group_ops_ristretto_point_sub_cost = Some(8);
4514 cfg.group_ops_ristretto_scalar_mul_cost = Some(5);
4515 cfg.group_ops_ristretto_point_mul_cost = Some(1763);
4516 cfg.group_ops_ristretto_scalar_div_cost = Some(557);
4517 cfg.group_ops_ristretto_point_div_cost = Some(2244);
4518
4519 if chain != Chain::Mainnet {
4520 cfg.feature_flags.enable_ristretto255_group_ops = true;
4521 cfg.feature_flags.enable_verify_bulletproofs_ristretto255 = true;
4522 }
4523
4524 cfg.feature_flags.timestamp_based_epoch_close = true;
4525 }
4526 128 => {
4527 cfg.max_generic_instantiation_type_nodes_per_function = Some(10_000);
4528 cfg.max_generic_instantiation_type_nodes_per_module = Some(500_000);
4529 cfg.binary_enum_defs = Some(200);
4530 cfg.binary_enum_def_instantiations = Some(100);
4531 }
4532 129 => {
4533 cfg.feature_flags.enable_unified_linkage = true;
4534 }
4535 130 => {
4536 cfg.feature_flags.record_net_unsettled_object_withdraws = true;
4537 cfg.feature_flags.enable_init_on_upgrade = true;
4538 cfg.epoch_close_deadline_ms = Some(120_000);
4539 cfg.scratch_add_cost_base = Some(13);
4540 cfg.scratch_read_cost_base = Some(13);
4541 cfg.scratch_read_value_cost = Some(1);
4542 cfg.scratch_remove_cost_base = Some(13);
4543 cfg.scratch_exists_cost_base = Some(13);
4544 cfg.scratch_exists_with_type_cost_base = Some(13);
4545 cfg.scratch_exists_with_type_type_cost = Some(1);
4546 let max_commands = cfg.max_programmable_tx_commands() as u64;
4547 cfg.max_scratch_pad_size = Some(16 * max_commands);
4548 if chain != Chain::Mainnet && chain != Chain::Testnet {
4550 cfg.feature_flags.zklogin_circuit_mode = 1;
4551 }
4552 }
4553 131 => {
4554 cfg.feature_flags.share_transaction_deny_config_in_consensus = true;
4555 cfg.feature_flags.framework_tx_context_mut_restrictions = true;
4556 }
4557 132 => {
4558 if chain != Chain::Mainnet && chain != Chain::Testnet {
4559 cfg.feature_flags.defer_owned_object_double_spend = true;
4560 cfg.feature_flags.create_forwarding_address_registry = true;
4561 }
4562 cfg.object_record_new_uid_from_hash_cost_base = Some(1);
4563 cfg.feature_flags
4564 .enable_order_independent_upgrade_init_linkage = true;
4565 }
4566 133 => {
4567 cfg.package_original_package_id_impl_cost_base = Some(52);
4568 let package_read_cost_per_byte = cfg.obj_access_cost_read_per_byte();
4569 cfg.package_original_package_id_impl_cost_per_byte =
4570 Some(package_read_cost_per_byte);
4571 }
4572 _ => panic!("unsupported version {:?}", version),
4583 }
4584 }
4585
4586 cfg
4587 }
4588
4589 pub fn apply_seeded_test_overrides(&mut self, seed: &[u8; 32]) {
4590 if !self.feature_flags.randomize_checkpoint_tx_limit_in_tests
4591 || !self.feature_flags.split_checkpoints_in_consensus_handler
4592 {
4593 return;
4594 }
4595
4596 if !mysten_common::in_test_configuration() {
4597 return;
4598 }
4599
4600 use rand::{Rng, SeedableRng, rngs::StdRng};
4601 let mut rng = StdRng::from_seed(*seed);
4602 let max_txns = rng.gen_range(10..=100u64);
4603 info!("seeded test override: max_transactions_per_checkpoint = {max_txns}");
4604 self.max_transactions_per_checkpoint = Some(max_txns);
4605 }
4606
4607 pub fn verifier_config(&self, signing_limits: Option<(usize, usize, usize)>) -> VerifierConfig {
4613 let (
4614 max_back_edges_per_function,
4615 max_back_edges_per_module,
4616 sanity_check_with_regex_reference_safety,
4617 ) = if let Some((
4618 max_back_edges_per_function,
4619 max_back_edges_per_module,
4620 sanity_check_with_regex_reference_safety,
4621 )) = signing_limits
4622 {
4623 (
4624 Some(max_back_edges_per_function),
4625 Some(max_back_edges_per_module),
4626 Some(sanity_check_with_regex_reference_safety),
4627 )
4628 } else {
4629 (None, None, None)
4630 };
4631
4632 let additional_borrow_checks = if signing_limits.is_some() {
4633 true
4635 } else {
4636 self.additional_borrow_checks()
4637 };
4638 let deprecate_global_storage_ops = if signing_limits.is_some() {
4639 true
4641 } else {
4642 self.deprecate_global_storage_ops()
4643 };
4644
4645 VerifierConfig {
4646 max_loop_depth: Some(self.max_loop_depth() as usize),
4647 max_generic_instantiation_length: Some(self.max_generic_instantiation_length() as usize),
4648 max_function_parameters: Some(self.max_function_parameters() as usize),
4649 max_basic_blocks: Some(self.max_basic_blocks() as usize),
4650 max_value_stack_size: self.max_value_stack_size() as usize,
4651 max_type_nodes: Some(self.max_type_nodes() as usize),
4652 max_generic_instantiation_type_nodes_per_function: self
4653 .max_generic_instantiation_type_nodes_per_function_as_option()
4654 .map(|v| v as usize),
4655 max_generic_instantiation_type_nodes_per_module: self
4656 .max_generic_instantiation_type_nodes_per_module_as_option()
4657 .map(|v| v as usize),
4658 max_push_size: Some(self.max_push_size() as usize),
4659 max_dependency_depth: Some(self.max_dependency_depth() as usize),
4660 max_fields_in_struct: Some(self.max_fields_in_struct() as usize),
4661 max_function_definitions: Some(self.max_function_definitions() as usize),
4662 max_data_definitions: Some(self.max_struct_definitions() as usize),
4663 max_constant_vector_len: Some(self.max_move_vector_len()),
4664 max_back_edges_per_function,
4665 max_back_edges_per_module,
4666 max_basic_blocks_in_script: None,
4667 max_identifier_len: self.max_move_identifier_len_as_option(), disallow_self_identifier: self.feature_flags.disallow_self_identifier,
4669 allow_receiving_object_id: self.allow_receiving_object_id(),
4670 reject_mutable_random_on_entry_functions: self
4671 .reject_mutable_random_on_entry_functions(),
4672 bytecode_version: self.move_binary_format_version(),
4673 max_variants_in_enum: self.max_move_enum_variants_as_option(),
4674 additional_borrow_checks,
4675 better_loader_errors: self.better_loader_errors(),
4676 private_generics_verifier_v2: self.private_generics_verifier_v2(),
4677 sanity_check_with_regex_reference_safety: sanity_check_with_regex_reference_safety
4678 .map(|limit| limit as u128),
4679 deprecate_global_storage_ops,
4680 disable_entry_point_signature_check: self.disable_entry_point_signature_check(),
4681 switch_to_regex_reference_safety: false,
4682 framework_tx_context_mut_restrictions: self.framework_tx_context_mut_restrictions(),
4683 disallow_jump_orphans: self.disallow_jump_orphans(),
4684 }
4685 }
4686
4687 pub fn binary_config(
4688 &self,
4689 override_deprecate_global_storage_ops_during_deserialization: Option<bool>,
4690 ) -> BinaryConfig {
4691 let deprecate_global_storage_ops =
4692 override_deprecate_global_storage_ops_during_deserialization
4693 .unwrap_or_else(|| self.deprecate_global_storage_ops());
4694 BinaryConfig::new(
4695 self.move_binary_format_version(),
4696 self.min_move_binary_format_version_as_option()
4697 .unwrap_or(VERSION_1),
4698 self.no_extraneous_module_bytes(),
4699 deprecate_global_storage_ops,
4700 TableConfig {
4701 module_handles: self.binary_module_handles_as_option().unwrap_or(u16::MAX),
4702 datatype_handles: self.binary_struct_handles_as_option().unwrap_or(u16::MAX),
4703 function_handles: self.binary_function_handles_as_option().unwrap_or(u16::MAX),
4704 function_instantiations: self
4705 .binary_function_instantiations_as_option()
4706 .unwrap_or(u16::MAX),
4707 signatures: self.binary_signatures_as_option().unwrap_or(u16::MAX),
4708 constant_pool: self.binary_constant_pool_as_option().unwrap_or(u16::MAX),
4709 identifiers: self.binary_identifiers_as_option().unwrap_or(u16::MAX),
4710 address_identifiers: self
4711 .binary_address_identifiers_as_option()
4712 .unwrap_or(u16::MAX),
4713 struct_defs: self.binary_struct_defs_as_option().unwrap_or(u16::MAX),
4714 struct_def_instantiations: self
4715 .binary_struct_def_instantiations_as_option()
4716 .unwrap_or(u16::MAX),
4717 function_defs: self.binary_function_defs_as_option().unwrap_or(u16::MAX),
4718 field_handles: self.binary_field_handles_as_option().unwrap_or(u16::MAX),
4719 field_instantiations: self
4720 .binary_field_instantiations_as_option()
4721 .unwrap_or(u16::MAX),
4722 friend_decls: self.binary_friend_decls_as_option().unwrap_or(u16::MAX),
4723 enum_defs: self.binary_enum_defs_as_option().unwrap_or(u16::MAX),
4724 enum_def_instantiations: self
4725 .binary_enum_def_instantiations_as_option()
4726 .unwrap_or(u16::MAX),
4727 variant_handles: self.binary_variant_handles_as_option().unwrap_or(u16::MAX),
4728 variant_instantiation_handles: self
4729 .binary_variant_instantiation_handles_as_option()
4730 .unwrap_or(u16::MAX),
4731 },
4732 )
4733 }
4734
4735 pub fn apply_overrides_for_testing(
4739 override_fn: impl Fn(ProtocolVersion, Self) -> Self + Send + Sync + 'static,
4740 ) -> OverrideGuard {
4741 let mut cur = CONFIG_OVERRIDE.lock().unwrap();
4742 assert!(cur.is_none(), "config override already present");
4743 *cur = Some(Box::new(override_fn));
4744 OverrideGuard
4745 }
4746
4747 fn apply_config_override(version: ProtocolVersion, mut ret: Self) -> Self {
4748 if let Some(override_fn) = CONFIG_OVERRIDE.lock().unwrap().as_ref() {
4749 warn!(
4750 "overriding ProtocolConfig settings with custom settings (you should not see this log outside of tests)"
4751 );
4752 ret = override_fn(version, ret);
4753 }
4754 ret
4755 }
4756}
4757
4758impl ProtocolConfig {
4762 pub fn set_execution_version_for_testing(&mut self, val: u64) {
4766 let current = self.execution_version.unwrap_or(0);
4767 assert!(
4768 val >= current,
4769 "cannot downgrade execution_version from {current} to {val}: running an old \
4770 executor against a newer protocol config/framework is unsupported. To test \
4771 frozen executor behavior, start from the last protocol version of that executor \
4772 instead, so genesis loads the matching framework snapshot (see \
4773 test_address_balance_gas_v3_accumulator_sign)."
4774 );
4775 self.execution_version = Some(val);
4776 }
4777
4778 pub fn set_zklogin_circuit_mode_for_testing(&mut self, val: u64) {
4781 self.feature_flags.zklogin_circuit_mode = val
4782 }
4783
4784 pub fn set_per_object_congestion_control_mode_for_testing(
4785 &mut self,
4786 val: PerObjectCongestionControlMode,
4787 ) {
4788 self.feature_flags.per_object_congestion_control_mode = val;
4789 }
4790
4791 pub fn set_consensus_choice_for_testing(&mut self, val: ConsensusChoice) {
4792 self.feature_flags.consensus_choice = val;
4793 }
4794
4795 pub fn set_consensus_network_for_testing(&mut self, val: ConsensusNetwork) {
4796 self.feature_flags.consensus_network = val;
4797 }
4798
4799 pub fn set_zklogin_max_epoch_upper_bound_delta_for_testing(&mut self, val: Option<u64>) {
4800 self.feature_flags.zklogin_max_epoch_upper_bound_delta = val
4801 }
4802
4803 pub fn set_mysticeti_num_leaders_per_round_for_testing(&mut self, val: Option<usize>) {
4804 self.feature_flags.mysticeti_num_leaders_per_round = val;
4805 }
4806
4807 pub fn disable_accumulators_for_testing(&mut self) {
4808 self.feature_flags.enable_accumulators = false;
4809 self.feature_flags.enable_address_balance_gas_payments = false;
4810 }
4811
4812 pub fn enable_coin_reservation_for_testing(&mut self) {
4813 self.feature_flags.enable_coin_reservation_obj_refs = true;
4814 self.feature_flags
4815 .convert_withdrawal_compatibility_ptb_arguments = true;
4816 self.execution_version = Some(self.execution_version.map_or(4, |v| v.max(4)));
4819 }
4820
4821 pub fn disable_coin_reservation_for_testing(&mut self) {
4822 self.feature_flags.enable_coin_reservation_obj_refs = false;
4823 self.feature_flags
4824 .convert_withdrawal_compatibility_ptb_arguments = false;
4825 }
4826
4827 pub fn enable_address_balance_gas_payments_for_testing(&mut self) {
4828 self.feature_flags.enable_accumulators = true;
4829 self.feature_flags.allow_private_accumulator_entrypoints = true;
4830 self.feature_flags.enable_address_balance_gas_payments = true;
4831 self.feature_flags.address_balance_gas_check_rgp_at_signing = true;
4832 self.feature_flags.address_balance_gas_reject_gas_coin_arg = false;
4833 self.execution_version = Some(self.execution_version.map_or(4, |v| v.max(4)))
4834 }
4835
4836 pub fn enable_gasless_for_testing(&mut self) {
4837 self.enable_address_balance_gas_payments_for_testing();
4838 self.feature_flags.enable_gasless = true;
4839 self.feature_flags.gasless_verify_remaining_balance = true;
4840 self.gasless_max_computation_units = Some(5_000);
4841 self.gasless_allowed_token_types = Some(vec![]);
4842 self.gasless_max_tps = Some(1000);
4843 self.gasless_max_tx_size_bytes = Some(16 * 1024);
4844 }
4845
4846 pub fn disable_gasless_for_testing(&mut self) {
4847 self.feature_flags.enable_gasless = false;
4848 self.gasless_max_computation_units = None;
4849 self.gasless_allowed_token_types = None;
4850 }
4851
4852 pub fn enable_authenticated_event_streams_for_testing(&mut self) {
4853 self.feature_flags.enable_accumulators = true;
4854 self.feature_flags.enable_authenticated_event_streams = true;
4855 self.feature_flags
4856 .include_checkpoint_artifacts_digest_in_summary = true;
4857 self.feature_flags.split_checkpoints_in_consensus_handler = true;
4858 }
4859}
4860
4861type OverrideFn = dyn Fn(ProtocolVersion, ProtocolConfig) -> ProtocolConfig + Send + Sync;
4862
4863static CONFIG_OVERRIDE: Mutex<Option<Box<OverrideFn>>> = Mutex::new(None);
4864
4865#[must_use]
4866pub struct OverrideGuard;
4867
4868impl Drop for OverrideGuard {
4869 fn drop(&mut self) {
4870 info!("restoring override fn");
4871 *CONFIG_OVERRIDE.lock().unwrap() = None;
4872 }
4873}
4874
4875#[derive(PartialEq, Eq)]
4878pub enum LimitThresholdCrossed {
4879 None,
4880 Soft(u128, u128),
4881 Hard(u128, u128),
4882}
4883
4884pub fn check_limit_in_range<T: Into<V>, U: Into<V>, V: PartialOrd + Into<u128>>(
4887 x: T,
4888 soft_limit: U,
4889 hard_limit: V,
4890) -> LimitThresholdCrossed {
4891 let x: V = x.into();
4892 let soft_limit: V = soft_limit.into();
4893
4894 debug_assert!(soft_limit <= hard_limit);
4895
4896 if x >= hard_limit {
4899 LimitThresholdCrossed::Hard(x.into(), hard_limit.into())
4900 } else if x < soft_limit {
4901 LimitThresholdCrossed::None
4902 } else {
4903 LimitThresholdCrossed::Soft(x.into(), soft_limit.into())
4904 }
4905}
4906
4907#[macro_export]
4908macro_rules! check_limit {
4909 ($x:expr, $hard:expr) => {
4910 check_limit!($x, $hard, $hard)
4911 };
4912 ($x:expr, $soft:expr, $hard:expr) => {
4913 check_limit_in_range($x as u64, $soft, $hard)
4914 };
4915}
4916
4917#[macro_export]
4921macro_rules! check_limit_by_meter {
4922 ($is_metered:expr, $x:expr, $metered_limit:expr, $unmetered_hard_limit:expr, $metric:expr) => {{
4923 let (h, metered_str) = if $is_metered {
4925 ($metered_limit, "metered")
4926 } else {
4927 ($unmetered_hard_limit, "unmetered")
4929 };
4930 use sui_protocol_config::check_limit_in_range;
4931 let result = check_limit_in_range($x as u64, $metered_limit, h);
4932 match result {
4933 LimitThresholdCrossed::None => {}
4934 LimitThresholdCrossed::Soft(_, _) => {
4935 $metric.with_label_values(&[metered_str, "soft"]).inc();
4936 }
4937 LimitThresholdCrossed::Hard(_, _) => {
4938 $metric.with_label_values(&[metered_str, "hard"]).inc();
4939 }
4940 };
4941 result
4942 }};
4943}
4944
4945pub type Amendments = BTreeMap<AccountAddress, BTreeMap<AccountAddress, AccountAddress>>;
4948
4949static MAINNET_LINKAGE_AMENDMENTS: LazyLock<Arc<Amendments>> =
4950 LazyLock::new(|| parse_amendments(include_str!("mainnet_amendments.json")));
4951
4952static TESTNET_LINKAGE_AMENDMENTS: LazyLock<Arc<Amendments>> =
4953 LazyLock::new(|| parse_amendments(include_str!("testnet_amendments.json")));
4954
4955fn parse_amendments(json: &str) -> Arc<Amendments> {
4956 #[derive(serde::Deserialize)]
4957 struct AmendmentEntry {
4958 root: String,
4959 deps: Vec<DepEntry>,
4960 }
4961
4962 #[derive(serde::Deserialize)]
4963 struct DepEntry {
4964 original_id: String,
4965 version_id: String,
4966 }
4967
4968 let entries: Vec<AmendmentEntry> =
4969 serde_json::from_str(json).expect("Failed to parse amendments JSON");
4970 let mut amendments = BTreeMap::new();
4971 for entry in entries {
4972 let root_id = AccountAddress::from_hex_literal(&entry.root).unwrap();
4973 let mut dep_ids = BTreeMap::new();
4974 for dep in entry.deps {
4975 let orig_id = AccountAddress::from_hex_literal(&dep.original_id).unwrap();
4976 let upgraded_id = AccountAddress::from_hex_literal(&dep.version_id).unwrap();
4977 assert!(
4978 dep_ids.insert(orig_id, upgraded_id).is_none(),
4979 "Duplicate original ID in amendments table"
4980 );
4981 }
4982 assert!(
4983 amendments.insert(root_id, dep_ids).is_none(),
4984 "Duplicate root ID in amendments table"
4985 );
4986 }
4987 Arc::new(amendments)
4988}
4989
4990#[cfg(all(test, not(msim)))]
4991mod test {
4992 use insta::assert_yaml_snapshot;
4993
4994 use super::*;
4995
4996 #[test]
4997 fn snapshot_tests() {
4998 println!("\n============================================================================");
4999 println!("! !");
5000 println!("! IMPORTANT: never update snapshots from this test. only add new versions! !");
5001 println!("! !");
5002 println!("============================================================================\n");
5003 for chain_id in &[Chain::Unknown, Chain::Mainnet, Chain::Testnet] {
5004 let chain_str = match chain_id {
5008 Chain::Unknown => "".to_string(),
5009 _ => format!("{:?}_", chain_id),
5010 };
5011 for i in MIN_PROTOCOL_VERSION..=MAX_PROTOCOL_VERSION {
5012 let cur = ProtocolVersion::new(i);
5013 assert_yaml_snapshot!(
5014 format!("{}version_{}", chain_str, cur.as_u64()),
5015 ProtocolConfig::get_for_version(cur, *chain_id)
5016 );
5017 }
5018 }
5019 }
5020
5021 #[test]
5022 fn test_getters() {
5023 let prot: ProtocolConfig =
5024 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5025 assert_eq!(
5026 prot.max_arguments(),
5027 prot.max_arguments_as_option().unwrap()
5028 );
5029 }
5030
5031 #[test]
5032 fn test_setters() {
5033 let mut prot: ProtocolConfig =
5034 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5035 prot.set_max_arguments_for_testing(123);
5036 assert_eq!(prot.max_arguments(), 123);
5037
5038 prot.set_max_arguments_from_str_for_testing("321".to_string());
5039 assert_eq!(prot.max_arguments(), 321);
5040
5041 prot.disable_max_arguments_for_testing();
5042 assert_eq!(prot.max_arguments_as_option(), None);
5043
5044 prot.set_attr_for_testing("max_arguments".to_string(), "456".to_string());
5045 assert_eq!(prot.max_arguments(), 456);
5046 }
5047
5048 #[test]
5049 fn test_execution_version_setter_allows_upgrade() {
5050 let mut prot = ProtocolConfig::get_for_max_version_UNSAFE();
5051 let current = prot.execution_version();
5052 prot.set_execution_version_for_testing(current);
5053 prot.set_execution_version_for_testing(current + 1);
5054 assert_eq!(prot.execution_version(), current + 1);
5055 }
5056
5057 #[test]
5058 #[should_panic(expected = "cannot downgrade execution_version")]
5059 fn test_execution_version_setter_panics_on_downgrade() {
5060 let mut prot = ProtocolConfig::get_for_max_version_UNSAFE();
5061 let current = prot.execution_version();
5062 prot.set_execution_version_for_testing(current - 1);
5063 }
5064
5065 #[test]
5066 fn test_feature_flag_setter_by_string() {
5067 let mut prot: ProtocolConfig =
5068 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5069 assert!(!prot.zklogin_auth());
5070 prot.set_feature_flag_for_testing("zklogin_auth".to_string(), true);
5071 assert!(prot.zklogin_auth());
5072 prot.set_feature_flag_for_testing("zklogin_auth".to_string(), false);
5073 assert!(!prot.zklogin_auth());
5074 }
5075
5076 #[test]
5077 #[should_panic(expected = "unknown feature flag")]
5078 fn test_feature_flag_setter_unknown_flag() {
5079 let mut prot: ProtocolConfig =
5080 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5081 prot.set_feature_flag_for_testing("some random string".to_string(), true);
5082 }
5083
5084 #[test]
5085 fn test_get_for_version_if_supported_applies_test_overrides() {
5086 let before =
5087 ProtocolConfig::get_for_version_if_supported(ProtocolVersion::new(1), Chain::Unknown)
5088 .unwrap();
5089
5090 assert!(!before.enable_coin_reservation_obj_refs());
5091
5092 let _guard = ProtocolConfig::apply_overrides_for_testing(|_, mut cfg| {
5093 cfg.enable_coin_reservation_for_testing();
5094 cfg
5095 });
5096
5097 let after =
5098 ProtocolConfig::get_for_version_if_supported(ProtocolVersion::new(1), Chain::Unknown)
5099 .unwrap();
5100
5101 assert!(after.enable_coin_reservation_obj_refs());
5102 }
5103
5104 #[test]
5105 #[should_panic(expected = "unsupported version")]
5106 fn max_version_test() {
5107 let _ = ProtocolConfig::get_for_version_impl(
5110 ProtocolVersion::new(MAX_PROTOCOL_VERSION + 1),
5111 Chain::Unknown,
5112 );
5113 }
5114
5115 #[test]
5116 fn lookup_by_string_test() {
5117 let prot: ProtocolConfig =
5118 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5119 assert!(prot.lookup_attr("some random string".to_string()).is_none());
5121
5122 assert!(
5123 prot.lookup_attr("max_arguments".to_string())
5124 == Some(ProtocolConfigValue::u32(prot.max_arguments())),
5125 );
5126
5127 assert!(
5129 prot.lookup_attr("max_move_identifier_len".to_string())
5130 .is_none()
5131 );
5132
5133 let prot: ProtocolConfig =
5135 ProtocolConfig::get_for_version(ProtocolVersion::new(9), Chain::Unknown);
5136 assert!(
5137 prot.lookup_attr("max_move_identifier_len".to_string())
5138 == Some(ProtocolConfigValue::u64(prot.max_move_identifier_len()))
5139 );
5140
5141 let prot: ProtocolConfig =
5142 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5143 assert!(
5145 prot.attr_map()
5146 .get("max_move_identifier_len")
5147 .unwrap()
5148 .is_none()
5149 );
5150 assert!(
5152 prot.attr_map().get("max_arguments").unwrap()
5153 == &Some(ProtocolConfigValue::u32(prot.max_arguments()))
5154 );
5155
5156 let prot: ProtocolConfig =
5158 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5159 assert!(
5161 prot.feature_flags
5162 .lookup_attr("some random string".to_owned())
5163 .is_none()
5164 );
5165 assert!(
5166 !prot
5167 .feature_flags
5168 .attr_map()
5169 .contains_key("some random string")
5170 );
5171
5172 assert!(
5174 prot.feature_flags
5175 .lookup_attr("package_upgrades".to_owned())
5176 == Some(false)
5177 );
5178 assert!(
5179 prot.feature_flags
5180 .attr_map()
5181 .get("package_upgrades")
5182 .unwrap()
5183 == &false
5184 );
5185 let prot: ProtocolConfig =
5186 ProtocolConfig::get_for_version(ProtocolVersion::new(4), Chain::Unknown);
5187 assert!(
5189 prot.feature_flags
5190 .lookup_attr("package_upgrades".to_owned())
5191 == Some(true)
5192 );
5193 assert!(
5194 prot.feature_flags
5195 .attr_map()
5196 .get("package_upgrades")
5197 .unwrap()
5198 == &true
5199 );
5200 }
5201
5202 #[test]
5203 fn limit_range_fn_test() {
5204 let low = 100u32;
5205 let high = 10000u64;
5206
5207 assert!(check_limit!(1u8, low, high) == LimitThresholdCrossed::None);
5208 assert!(matches!(
5209 check_limit!(255u16, low, high),
5210 LimitThresholdCrossed::Soft(255u128, 100)
5211 ));
5212 assert!(matches!(
5218 check_limit!(2550000u64, low, high),
5219 LimitThresholdCrossed::Hard(2550000, 10000)
5220 ));
5221
5222 assert!(matches!(
5223 check_limit!(2550000u64, high, high),
5224 LimitThresholdCrossed::Hard(2550000, 10000)
5225 ));
5226
5227 assert!(matches!(
5228 check_limit!(1u8, high),
5229 LimitThresholdCrossed::None
5230 ));
5231
5232 assert!(check_limit!(255u16, high) == LimitThresholdCrossed::None);
5233
5234 assert!(matches!(
5235 check_limit!(2550000u64, high),
5236 LimitThresholdCrossed::Hard(2550000, 10000)
5237 ));
5238 }
5239
5240 #[test]
5241 fn linkage_amendments_load() {
5242 let mainnet = LazyLock::force(&MAINNET_LINKAGE_AMENDMENTS);
5243 let testnet = LazyLock::force(&TESTNET_LINKAGE_AMENDMENTS);
5244 assert!(!mainnet.is_empty(), "mainnet amendments must not be empty");
5245 assert!(!testnet.is_empty(), "testnet amendments must not be empty");
5246 }
5247
5248 #[test]
5249 fn render_scalar_fields_use_precision_safe_encoding() {
5250 use mysten_common::rpc_format::Unmetered;
5251
5252 let config = ProtocolConfig::get_for_max_version_UNSAFE();
5253 let rendered = config
5254 .render::<serde_json::Value>(&mut Unmetered)
5255 .expect("render should succeed");
5256
5257 let max_args = rendered
5258 .get("max_arguments")
5259 .expect("max_arguments set at max version");
5260 assert!(
5261 max_args.is_number(),
5262 "u32 should render as number, got {max_args:?}",
5263 );
5264
5265 let max_tx_size = rendered
5266 .get("max_tx_size_bytes")
5267 .expect("max_tx_size_bytes set at max version");
5268 assert!(
5269 max_tx_size.is_string(),
5270 "u64 should render as string, got {max_tx_size:?}",
5271 );
5272 }
5273
5274 #[test]
5275 fn render_includes_non_scalar_gasless_allowlist_as_json() {
5276 use mysten_common::rpc_format::Unmetered;
5277 use serde_json::json;
5278
5279 let mut config = ProtocolConfig::get_for_max_version_UNSAFE();
5280 config.set_gasless_allowed_token_types_for_testing(vec![
5281 ("0xa::usdc::USDC".to_string(), 10_000),
5282 ("0xb::usdt::USDT".to_string(), 0),
5283 ]);
5284
5285 let rendered = config
5286 .render::<serde_json::Value>(&mut Unmetered)
5287 .expect("render should succeed under Unmetered budget");
5288 let allowlist = rendered
5289 .get("gasless_allowed_token_types")
5290 .expect("entry should be present after the testing setter");
5291
5292 assert_eq!(
5295 allowlist,
5296 &json!([["0xa::usdc::USDC", "10000"], ["0xb::usdt::USDT", "0"],]),
5297 );
5298 }
5299
5300 #[test]
5301 fn render_targets_prost_value_for_grpc() {
5302 use mysten_common::rpc_format::Unmetered;
5303 use prost_types::value::Kind;
5304
5305 let mut config = ProtocolConfig::get_for_max_version_UNSAFE();
5306 config.set_gasless_allowed_token_types_for_testing(vec![(
5307 "0xa::usdc::USDC".to_string(),
5308 10_000,
5309 )]);
5310
5311 let rendered = config
5312 .render::<prost_types::Value>(&mut Unmetered)
5313 .expect("render to prost Value should succeed");
5314 let allowlist = rendered
5315 .get("gasless_allowed_token_types")
5316 .expect("entry should be present after the testing setter");
5317
5318 let Some(Kind::ListValue(outer)) = &allowlist.kind else {
5320 panic!(
5321 "expected ListValue at the top level, got {:?}",
5322 allowlist.kind
5323 );
5324 };
5325 assert_eq!(outer.values.len(), 1, "one allowlisted entry");
5326 let Some(Kind::ListValue(entry)) = &outer.values[0].kind else {
5327 panic!("expected each entry to be a ListValue");
5328 };
5329 assert_eq!(entry.values.len(), 2, "entry has (coin_type, amount)");
5330
5331 let Some(Kind::StringValue(coin_type)) = &entry.values[0].kind else {
5332 panic!("expected coin_type as StringValue");
5333 };
5334 assert_eq!(coin_type, "0xa::usdc::USDC");
5335
5336 let Some(Kind::StringValue(amount)) = &entry.values[1].kind else {
5338 panic!(
5339 "expected minimum_transfer_amount as StringValue (precision-safe u64); got {:?}",
5340 entry.values[1].kind,
5341 );
5342 };
5343 assert_eq!(amount, "10000");
5344 }
5345
5346 #[test]
5347 fn render_emits_null_for_unset_protocol_versions() {
5348 use mysten_common::rpc_format::Unmetered;
5349
5350 let config = ProtocolConfig::get_for_version(1.into(), Chain::Unknown);
5351 let rendered = config
5352 .render::<serde_json::Value>(&mut Unmetered)
5353 .expect("render should succeed");
5354 let entry = rendered
5358 .get("gasless_allowed_token_types")
5359 .expect("key should be present for every protocol version");
5360 assert!(
5361 entry.is_null(),
5362 "value should be null for pre-feature protocol version, got {entry:?}",
5363 );
5364 }
5365}