1use std::{
5 collections::{BTreeMap, BTreeSet},
6 sync::{
7 Arc, LazyLock,
8 atomic::{AtomicBool, Ordering},
9 },
10};
11
12#[cfg(msim)]
13use std::cell::RefCell;
14#[cfg(not(msim))]
15use std::sync::Mutex;
16
17use clap::*;
18use fastcrypto::encoding::{Base58, Encoding, Hex};
19use move_binary_format::{
20 binary_config::{BinaryConfig, TableConfig},
21 file_format_common::VERSION_1,
22};
23use move_core_types::account_address::AccountAddress;
24use move_vm_config::verifier::VerifierConfig;
25use mysten_common::in_integration_test;
26use serde::{Deserialize, Serialize};
27use serde_with::skip_serializing_none;
28use sui_protocol_config_macros::{
29 ProtocolConfigAccessors, ProtocolConfigFeatureFlagsGetters, ProtocolConfigOverride,
30};
31use tracing::{info, warn};
32
33const MIN_PROTOCOL_VERSION: u64 = 1;
35const MAX_PROTOCOL_VERSION: u64 = 130;
36
37const TESTNET_USDC: &str =
38 "0xa1ec7fc00a6f40db9693ad1415d0c193ad3906494428cf252621037bd7117e29::usdc::USDC";
39
40const MAINNET_USDC: &str =
41 "0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC";
42const MAINNET_USDSUI: &str =
43 "0x44f838219cf67b058f3b37907b655f226153c18e33dfcd0da559a844fea9b1c1::usdsui::USDSUI";
44const MAINNET_SUI_USDE: &str =
45 "0x41d587e5336f1c86cad50d38a7136db99333bb9bda91cea4ba69115defeb1402::sui_usde::SUI_USDE";
46const MAINNET_USDY: &str =
47 "0x960b531667636f39e85867775f52f6b1f220a058c4de786905bdf761e06a56bb::usdy::USDY";
48const MAINNET_FDUSD: &str =
49 "0xf16e6b723f242ec745dfd7634ad072c42d5c1d9ac9d62a39c381303eaa57693a::fdusd::FDUSD";
50const MAINNET_AUSD: &str =
51 "0x2053d08c1e2bd02791056171aab0fd12bd7cd7efad2ab8f6b9c8902f14df2ff2::ausd::AUSD";
52const MAINNET_USDB: &str =
53 "0xe14726c336e81b32328e92afc37345d159f5b550b09fa92bd43640cfdd0a0cfd::usdb::USDB";
54
55#[derive(Copy, Clone, Debug, Hash, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)]
372pub struct ProtocolVersion(u64);
373
374impl ProtocolVersion {
375 pub const MIN: Self = Self(MIN_PROTOCOL_VERSION);
380
381 pub const MAX: Self = Self(MAX_PROTOCOL_VERSION);
382
383 #[cfg(not(msim))]
384 pub const MAX_ALLOWED: Self = Self::MAX;
385
386 #[cfg(msim)]
388 pub const MAX_ALLOWED: Self = Self(MAX_PROTOCOL_VERSION + 1);
389
390 pub fn new(v: u64) -> Self {
391 Self(v)
392 }
393
394 pub const fn as_u64(&self) -> u64 {
395 self.0
396 }
397
398 pub fn max() -> Self {
401 Self::MAX
402 }
403
404 pub fn prev(self) -> Self {
405 Self(self.0.checked_sub(1).unwrap())
406 }
407}
408
409impl From<u64> for ProtocolVersion {
410 fn from(v: u64) -> Self {
411 Self::new(v)
412 }
413}
414
415impl std::ops::Sub<u64> for ProtocolVersion {
416 type Output = Self;
417 fn sub(self, rhs: u64) -> Self::Output {
418 Self::new(self.0 - rhs)
419 }
420}
421
422impl std::ops::Add<u64> for ProtocolVersion {
423 type Output = Self;
424 fn add(self, rhs: u64) -> Self::Output {
425 Self::new(self.0 + rhs)
426 }
427}
428
429#[derive(
430 Clone, Serialize, Deserialize, Debug, Default, PartialEq, Copy, PartialOrd, Ord, Eq, ValueEnum,
431)]
432pub enum Chain {
433 Mainnet,
434 Testnet,
435 #[default]
436 Unknown,
437}
438
439impl Chain {
440 pub fn as_str(self) -> &'static str {
441 match self {
442 Chain::Mainnet => "mainnet",
443 Chain::Testnet => "testnet",
444 Chain::Unknown => "unknown",
445 }
446 }
447}
448
449pub struct Error(pub String);
450
451#[derive(Default, Clone, Serialize, Deserialize, Debug, ProtocolConfigFeatureFlagsGetters)]
454struct FeatureFlags {
455 #[serde(skip_serializing_if = "is_false")]
458 package_upgrades: bool,
459 #[serde(skip_serializing_if = "is_false")]
462 commit_root_state_digest: bool,
463 #[serde(skip_serializing_if = "is_false")]
465 advance_epoch_start_time_in_safe_mode: bool,
466 #[serde(skip_serializing_if = "is_false")]
469 loaded_child_objects_fixed: bool,
470 #[serde(skip_serializing_if = "is_false")]
473 missing_type_is_compatibility_error: bool,
474 #[serde(skip_serializing_if = "is_false")]
477 scoring_decision_with_validity_cutoff: bool,
478
479 #[serde(skip_serializing_if = "is_false")]
482 consensus_order_end_of_epoch_last: bool,
483
484 #[serde(skip_serializing_if = "is_false")]
486 disallow_adding_abilities_on_upgrade: bool,
487 #[serde(skip_serializing_if = "is_false")]
489 disable_invariant_violation_check_in_swap_loc: bool,
490 #[serde(skip_serializing_if = "is_false")]
493 advance_to_highest_supported_protocol_version: bool,
494 #[serde(skip_serializing_if = "is_false")]
496 ban_entry_init: bool,
497 #[serde(skip_serializing_if = "is_false")]
499 package_digest_hash_module: bool,
500 #[serde(skip_serializing_if = "is_false")]
502 disallow_change_struct_type_params_on_upgrade: bool,
503 #[serde(skip_serializing_if = "is_false")]
505 no_extraneous_module_bytes: bool,
506 #[serde(skip_serializing_if = "is_false")]
508 narwhal_versioned_metadata: bool,
509
510 #[serde(skip_serializing_if = "is_false")]
512 zklogin_auth: bool,
513 #[serde(skip_serializing_if = "is_zero")]
516 zklogin_circuit_mode: u64,
517 #[serde(skip_serializing_if = "ConsensusTransactionOrdering::is_none")]
519 consensus_transaction_ordering: ConsensusTransactionOrdering,
520
521 #[serde(skip_serializing_if = "is_false")]
529 simplified_unwrap_then_delete: bool,
530 #[serde(skip_serializing_if = "is_false")]
532 upgraded_multisig_supported: bool,
533 #[serde(skip_serializing_if = "is_false")]
535 txn_base_cost_as_multiplier: bool,
536
537 #[serde(skip_serializing_if = "is_false")]
539 shared_object_deletion: bool,
540
541 #[serde(skip_serializing_if = "is_false")]
543 narwhal_new_leader_election_schedule: bool,
544
545 #[serde(skip_serializing_if = "is_empty")]
547 zklogin_supported_providers: BTreeSet<String>,
548
549 #[serde(skip_serializing_if = "is_false")]
551 loaded_child_object_format: bool,
552
553 #[serde(skip_serializing_if = "is_false")]
554 #[skip_protocol_config_accessor]
555 enable_jwk_consensus_updates: bool,
556
557 #[serde(skip_serializing_if = "is_false")]
558 #[skip_protocol_config_accessor]
559 end_of_epoch_transaction_supported: bool,
560
561 #[serde(skip_serializing_if = "is_false")]
564 simple_conservation_checks: bool,
565
566 #[serde(skip_serializing_if = "is_false")]
568 loaded_child_object_format_type: bool,
569
570 #[serde(skip_serializing_if = "is_false")]
572 receive_objects: bool,
573
574 #[serde(skip_serializing_if = "is_false")]
576 consensus_checkpoint_signature_key_includes_digest: bool,
577
578 #[serde(skip_serializing_if = "is_false")]
580 random_beacon: bool,
581
582 #[serde(skip_serializing_if = "is_false")]
584 #[skip_protocol_config_accessor]
585 bridge: bool,
586
587 #[serde(skip_serializing_if = "is_false")]
588 enable_effects_v2: bool,
589
590 #[serde(skip_serializing_if = "is_false")]
592 narwhal_certificate_v2: bool,
593
594 #[serde(skip_serializing_if = "is_false")]
596 verify_legacy_zklogin_address: bool,
597
598 #[serde(skip_serializing_if = "is_false")]
600 throughput_aware_consensus_submission: bool,
601
602 #[serde(skip_serializing_if = "is_false")]
604 recompute_has_public_transfer_in_execution: bool,
605
606 #[serde(skip_serializing_if = "is_false")]
608 accept_zklogin_in_multisig: bool,
609
610 #[serde(skip_serializing_if = "is_false")]
612 accept_passkey_in_multisig: bool,
613
614 #[serde(skip_serializing_if = "is_false")]
616 validate_zklogin_public_identifier: bool,
617
618 #[serde(skip_serializing_if = "is_false")]
621 include_consensus_digest_in_prologue: bool,
622
623 #[serde(skip_serializing_if = "is_false")]
625 hardened_otw_check: bool,
626
627 #[serde(skip_serializing_if = "is_false")]
629 allow_receiving_object_id: bool,
630
631 #[serde(skip_serializing_if = "is_false")]
633 enable_poseidon: bool,
634
635 #[serde(skip_serializing_if = "is_false")]
637 enable_coin_deny_list: bool,
638
639 #[serde(skip_serializing_if = "is_false")]
641 enable_group_ops_native_functions: bool,
642
643 #[serde(skip_serializing_if = "is_false")]
645 enable_group_ops_native_function_msm: bool,
646
647 #[serde(skip_serializing_if = "is_false")]
649 enable_ristretto255_group_ops: bool,
650
651 #[serde(skip_serializing_if = "is_false")]
653 enable_verify_bulletproofs_ristretto255: bool,
654
655 #[serde(skip_serializing_if = "is_false")]
657 enable_nitro_attestation: bool,
658
659 #[serde(skip_serializing_if = "is_false")]
661 enable_nitro_attestation_upgraded_parsing: bool,
662
663 #[serde(skip_serializing_if = "is_false")]
665 enable_nitro_attestation_all_nonzero_pcrs_parsing: bool,
666
667 #[serde(skip_serializing_if = "is_false")]
669 enable_nitro_attestation_always_include_required_pcrs_parsing: bool,
670
671 #[serde(skip_serializing_if = "is_false")]
673 reject_mutable_random_on_entry_functions: bool,
674
675 #[serde(skip_serializing_if = "PerObjectCongestionControlMode::is_none")]
677 per_object_congestion_control_mode: PerObjectCongestionControlMode,
678
679 #[serde(skip_serializing_if = "ConsensusChoice::is_narwhal")]
681 consensus_choice: ConsensusChoice,
682
683 #[serde(skip_serializing_if = "ConsensusNetwork::is_anemo")]
685 consensus_network: ConsensusNetwork,
686
687 #[serde(skip_serializing_if = "is_false")]
689 correct_gas_payment_limit_check: bool,
690
691 #[serde(skip_serializing_if = "Option::is_none")]
693 zklogin_max_epoch_upper_bound_delta: Option<u64>,
694
695 #[serde(skip_serializing_if = "is_false")]
697 mysticeti_leader_scoring_and_schedule: bool,
698
699 #[serde(skip_serializing_if = "is_false")]
701 reshare_at_same_initial_version: bool,
702
703 #[serde(skip_serializing_if = "is_false")]
705 resolve_abort_locations_to_package_id: bool,
706
707 #[serde(skip_serializing_if = "is_false")]
711 mysticeti_use_committed_subdag_digest: bool,
712
713 #[serde(skip_serializing_if = "is_false")]
715 enable_vdf: bool,
716
717 #[serde(skip_serializing_if = "is_false")]
721 record_consensus_determined_version_assignments_in_prologue: bool,
722 #[serde(skip_serializing_if = "is_false")]
725 record_consensus_determined_version_assignments_in_prologue_v2: bool,
726
727 #[serde(skip_serializing_if = "is_false")]
729 fresh_vm_on_framework_upgrade: bool,
730
731 #[serde(skip_serializing_if = "is_false")]
739 prepend_prologue_tx_in_consensus_commit_in_checkpoints: bool,
740
741 #[serde(skip_serializing_if = "Option::is_none")]
743 mysticeti_num_leaders_per_round: Option<usize>,
744
745 #[serde(skip_serializing_if = "is_false")]
747 soft_bundle: bool,
748
749 #[serde(skip_serializing_if = "is_false")]
751 enable_coin_deny_list_v2: bool,
752
753 #[serde(skip_serializing_if = "is_false")]
755 passkey_auth: bool,
756
757 #[serde(skip_serializing_if = "is_false")]
759 authority_capabilities_v2: bool,
760
761 #[serde(skip_serializing_if = "is_false")]
763 rethrow_serialization_type_layout_errors: bool,
764
765 #[serde(skip_serializing_if = "is_false")]
767 consensus_distributed_vote_scoring_strategy: bool,
768
769 #[serde(skip_serializing_if = "is_false")]
771 consensus_round_prober: bool,
772
773 #[serde(skip_serializing_if = "is_false")]
775 validate_identifier_inputs: bool,
776
777 #[serde(skip_serializing_if = "is_false")]
779 disallow_self_identifier: bool,
780
781 #[serde(skip_serializing_if = "is_false")]
783 mysticeti_fastpath: bool,
784
785 #[serde(skip_serializing_if = "is_false")]
789 disable_preconsensus_locking: bool,
790
791 #[serde(skip_serializing_if = "is_false")]
793 relocate_event_module: bool,
794
795 #[serde(skip_serializing_if = "is_false")]
797 uncompressed_g1_group_elements: bool,
798
799 #[serde(skip_serializing_if = "is_false")]
800 disallow_new_modules_in_deps_only_packages: bool,
801
802 #[serde(skip_serializing_if = "is_false")]
804 consensus_smart_ancestor_selection: bool,
805
806 #[serde(skip_serializing_if = "is_false")]
808 consensus_round_prober_probe_accepted_rounds: bool,
809
810 #[serde(skip_serializing_if = "is_false")]
812 native_charging_v2: bool,
813
814 #[serde(skip_serializing_if = "is_false")]
817 #[skip_protocol_config_accessor]
818 consensus_linearize_subdag_v2: bool,
819
820 #[serde(skip_serializing_if = "is_false")]
822 convert_type_argument_error: bool,
823
824 #[serde(skip_serializing_if = "is_false")]
826 variant_nodes: bool,
827
828 #[serde(skip_serializing_if = "is_false")]
830 consensus_zstd_compression: bool,
831
832 #[serde(skip_serializing_if = "is_false")]
834 minimize_child_object_mutations: bool,
835
836 #[serde(skip_serializing_if = "is_false")]
839 record_additional_state_digest_in_prologue: bool,
840
841 #[serde(skip_serializing_if = "is_false")]
843 move_native_context: bool,
844
845 #[serde(skip_serializing_if = "is_false")]
848 #[skip_protocol_config_accessor]
849 consensus_median_based_commit_timestamp: bool,
850
851 #[serde(skip_serializing_if = "is_false")]
854 normalize_ptb_arguments: bool,
855
856 #[serde(skip_serializing_if = "is_false")]
858 consensus_batched_block_sync: bool,
859
860 #[serde(skip_serializing_if = "is_false")]
862 enforce_checkpoint_timestamp_monotonicity: bool,
863
864 #[serde(skip_serializing_if = "is_false")]
866 max_ptb_value_size_v2: bool,
867
868 #[serde(skip_serializing_if = "is_false")]
870 resolve_type_input_ids_to_defining_id: bool,
871
872 #[serde(skip_serializing_if = "is_false")]
874 enable_party_transfer: bool,
875
876 #[serde(skip_serializing_if = "is_false")]
878 allow_unbounded_system_objects: bool,
879
880 #[serde(skip_serializing_if = "is_false")]
882 type_tags_in_object_runtime: bool,
883
884 #[serde(skip_serializing_if = "is_false")]
886 enable_accumulators: bool,
887
888 #[serde(skip_serializing_if = "is_false")]
890 #[skip_protocol_config_accessor]
891 enable_coin_reservation_obj_refs: bool,
892
893 #[serde(skip_serializing_if = "is_false")]
896 create_root_accumulator_object: bool,
897
898 #[serde(skip_serializing_if = "is_false")]
900 #[skip_protocol_config_accessor]
901 enable_authenticated_event_streams: bool,
902
903 #[serde(skip_serializing_if = "is_false")]
905 enable_address_balance_gas_payments: bool,
906
907 #[serde(skip_serializing_if = "is_false")]
909 address_balance_gas_check_rgp_at_signing: bool,
910
911 #[serde(skip_serializing_if = "is_false")]
912 address_balance_gas_reject_gas_coin_arg: bool,
913
914 #[serde(skip_serializing_if = "is_false")]
916 enable_multi_epoch_transaction_expiration: bool,
917
918 #[serde(skip_serializing_if = "is_false")]
920 relax_valid_during_for_owned_inputs: bool,
921
922 #[serde(skip_serializing_if = "is_false")]
924 enable_ptb_execution_v2: bool,
925
926 #[serde(skip_serializing_if = "is_false")]
928 better_adapter_type_resolution_errors: bool,
929
930 #[serde(skip_serializing_if = "is_false")]
932 record_time_estimate_processed: bool,
933
934 #[serde(skip_serializing_if = "is_false")]
936 dependency_linkage_error: bool,
937
938 #[serde(skip_serializing_if = "is_false")]
940 additional_multisig_checks: bool,
941
942 #[serde(skip_serializing_if = "is_false")]
944 ignore_execution_time_observations_after_certs_closed: bool,
945
946 #[serde(skip_serializing_if = "is_false")]
950 debug_fatal_on_move_invariant_violation: bool,
951
952 #[serde(skip_serializing_if = "is_false")]
955 allow_private_accumulator_entrypoints: bool,
956
957 #[serde(skip_serializing_if = "is_false")]
960 additional_consensus_digest_indirect_state: bool,
961
962 #[serde(skip_serializing_if = "is_false")]
964 check_for_init_during_upgrade: bool,
965
966 #[serde(skip_serializing_if = "is_false")]
968 enable_init_on_upgrade: bool,
969
970 #[serde(skip_serializing_if = "is_false")]
972 per_command_shared_object_transfer_rules: bool,
973
974 #[serde(skip_serializing_if = "is_false")]
976 include_checkpoint_artifacts_digest_in_summary: bool,
977
978 #[serde(skip_serializing_if = "is_false")]
980 use_mfp_txns_in_load_initial_object_debts: bool,
981
982 #[serde(skip_serializing_if = "is_false")]
984 cancel_for_failed_dkg_early: bool,
985
986 #[serde(skip_serializing_if = "is_false")]
988 always_advance_dkg_to_resolution: bool,
989
990 #[serde(skip_serializing_if = "is_false")]
992 enable_coin_registry: bool,
993
994 #[serde(skip_serializing_if = "is_false")]
996 abstract_size_in_object_runtime: bool,
997
998 #[serde(skip_serializing_if = "is_false")]
1000 object_runtime_charge_cache_load_gas: bool,
1001
1002 #[serde(skip_serializing_if = "is_false")]
1004 additional_borrow_checks: bool,
1005
1006 #[serde(skip_serializing_if = "is_false")]
1008 use_new_commit_handler: bool,
1009
1010 #[serde(skip_serializing_if = "is_false")]
1012 better_loader_errors: bool,
1013
1014 #[serde(skip_serializing_if = "is_false")]
1016 generate_df_type_layouts: bool,
1017
1018 #[serde(skip_serializing_if = "is_false")]
1020 allow_references_in_ptbs: bool,
1021
1022 #[serde(skip_serializing_if = "is_false")]
1024 enable_display_registry: bool,
1025
1026 #[serde(skip_serializing_if = "is_false")]
1028 private_generics_verifier_v2: bool,
1029
1030 #[serde(skip_serializing_if = "is_false")]
1032 deprecate_global_storage_ops_during_deserialization: bool,
1033
1034 #[serde(skip_serializing_if = "is_false")]
1037 enable_non_exclusive_writes: bool,
1038
1039 #[serde(skip_serializing_if = "is_false")]
1041 deprecate_global_storage_ops: bool,
1042
1043 #[serde(skip_serializing_if = "is_false")]
1045 normalize_depth_formula: bool,
1046
1047 #[serde(skip_serializing_if = "is_false")]
1049 consensus_skip_gced_accept_votes: bool,
1050
1051 #[serde(skip_serializing_if = "is_false")]
1054 include_cancelled_randomness_txns_in_prologue: bool,
1055
1056 #[serde(skip_serializing_if = "is_false")]
1058 #[skip_protocol_config_accessor]
1059 address_aliases: bool,
1060
1061 #[serde(skip_serializing_if = "is_false")]
1064 fix_checkpoint_signature_mapping: bool,
1065
1066 #[serde(skip_serializing_if = "is_false")]
1068 enable_object_funds_withdraw: bool,
1069
1070 #[serde(skip_serializing_if = "is_false")]
1073 record_net_unsettled_object_withdraws: bool,
1074
1075 #[serde(skip_serializing_if = "is_false")]
1077 consensus_skip_gced_blocks_in_direct_finalization: bool,
1078
1079 #[serde(skip_serializing_if = "is_false")]
1081 gas_rounding_halve_digits: bool,
1082
1083 #[serde(skip_serializing_if = "is_false")]
1085 flexible_tx_context_positions: bool,
1086
1087 #[serde(skip_serializing_if = "is_false")]
1089 disable_entry_point_signature_check: bool,
1090
1091 #[serde(skip_serializing_if = "is_false")]
1093 convert_withdrawal_compatibility_ptb_arguments: bool,
1094
1095 #[serde(skip_serializing_if = "is_false")]
1097 restrict_hot_or_not_entry_functions: bool,
1098
1099 #[serde(skip_serializing_if = "is_false")]
1101 split_checkpoints_in_consensus_handler: bool,
1102
1103 #[serde(skip_serializing_if = "is_false")]
1105 consensus_always_accept_system_transactions: bool,
1106
1107 #[serde(skip_serializing_if = "is_false")]
1109 validator_metadata_verify_v2: bool,
1110
1111 #[serde(skip_serializing_if = "is_false")]
1114 defer_unpaid_amplification: bool,
1115
1116 #[serde(skip_serializing_if = "is_false")]
1117 randomize_checkpoint_tx_limit_in_tests: bool,
1118
1119 #[serde(skip_serializing_if = "is_false")]
1121 gasless_transaction_drop_safety: bool,
1122
1123 #[serde(skip_serializing_if = "is_false")]
1126 merge_randomness_into_checkpoint: bool,
1127
1128 #[serde(skip_serializing_if = "is_false")]
1130 use_coin_party_owner: bool,
1131
1132 #[serde(skip_serializing_if = "is_false")]
1133 enable_gasless: bool,
1134
1135 #[serde(skip_serializing_if = "is_false")]
1136 gasless_verify_remaining_balance: bool,
1137
1138 #[serde(skip_serializing_if = "is_false")]
1139 disallow_jump_orphans: bool,
1140
1141 #[serde(skip_serializing_if = "is_false")]
1143 early_return_receive_object_mismatched_type: bool,
1144
1145 #[serde(skip_serializing_if = "is_false")]
1150 timestamp_based_epoch_close: bool,
1151
1152 #[serde(skip_serializing_if = "is_false")]
1155 limit_groth16_pvk_inputs: bool,
1156
1157 #[serde(skip_serializing_if = "is_false")]
1162 enforce_address_balance_change_invariant: bool,
1163
1164 #[serde(skip_serializing_if = "is_false")]
1166 granular_post_execution_checks: bool,
1167
1168 #[serde(skip_serializing_if = "is_false")]
1170 early_exit_on_iffw: bool,
1171
1172 #[serde(skip_serializing_if = "is_false")]
1174 enable_unified_linkage: bool,
1175}
1176
1177fn is_false(b: &bool) -> bool {
1178 !b
1179}
1180
1181fn is_empty(b: &BTreeSet<String>) -> bool {
1182 b.is_empty()
1183}
1184
1185fn is_zero(val: &u64) -> bool {
1186 *val == 0
1187}
1188
1189#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1191pub enum ConsensusTransactionOrdering {
1192 #[default]
1194 None,
1195 ByGasPrice,
1197}
1198
1199impl ConsensusTransactionOrdering {
1200 pub fn is_none(&self) -> bool {
1201 matches!(self, ConsensusTransactionOrdering::None)
1202 }
1203}
1204
1205#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1206pub struct ExecutionTimeEstimateParams {
1207 pub target_utilization: u64,
1209 pub allowed_txn_cost_overage_burst_limit_us: u64,
1213
1214 pub randomness_scalar: u64,
1217
1218 pub max_estimate_us: u64,
1220
1221 pub stored_observations_num_included_checkpoints: u64,
1224
1225 pub stored_observations_limit: u64,
1227
1228 #[serde(skip_serializing_if = "is_zero")]
1231 pub stake_weighted_median_threshold: u64,
1232
1233 #[serde(skip_serializing_if = "is_false")]
1237 pub default_none_duration_for_new_keys: bool,
1238
1239 #[serde(skip_serializing_if = "Option::is_none")]
1241 pub observations_chunk_size: Option<u64>,
1242}
1243
1244#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1246pub enum PerObjectCongestionControlMode {
1247 #[default]
1248 None, TotalGasBudget, TotalTxCount, TotalGasBudgetWithCap, ExecutionTimeEstimate(ExecutionTimeEstimateParams), }
1254
1255impl PerObjectCongestionControlMode {
1256 pub fn is_none(&self) -> bool {
1257 matches!(self, PerObjectCongestionControlMode::None)
1258 }
1259}
1260
1261#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1263pub enum ConsensusChoice {
1264 #[default]
1265 Narwhal,
1266 SwapEachEpoch,
1267 Mysticeti,
1268}
1269
1270impl ConsensusChoice {
1271 pub fn is_narwhal(&self) -> bool {
1272 matches!(self, ConsensusChoice::Narwhal)
1273 }
1274}
1275
1276#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1278pub enum ConsensusNetwork {
1279 #[default]
1280 Anemo,
1281 Tonic,
1282}
1283
1284impl ConsensusNetwork {
1285 pub fn is_anemo(&self) -> bool {
1286 matches!(self, ConsensusNetwork::Anemo)
1287 }
1288}
1289
1290#[skip_serializing_none]
1322#[derive(Clone, Serialize, Debug, ProtocolConfigAccessors, ProtocolConfigOverride)]
1323pub struct ProtocolConfig {
1324 pub version: ProtocolVersion,
1325
1326 #[serde(skip)]
1331 chain: Chain,
1332
1333 feature_flags: FeatureFlags,
1334
1335 max_tx_size_bytes: Option<u64>,
1338
1339 max_input_objects: Option<u64>,
1341
1342 max_size_written_objects: Option<u64>,
1346 max_size_written_objects_system_tx: Option<u64>,
1349
1350 max_serialized_tx_effects_size_bytes: Option<u64>,
1352
1353 max_serialized_tx_effects_size_bytes_system_tx: Option<u64>,
1355
1356 max_gas_payment_objects: Option<u32>,
1358
1359 max_modules_in_publish: Option<u32>,
1361
1362 max_package_dependencies: Option<u32>,
1364
1365 max_arguments: Option<u32>,
1368
1369 max_type_arguments: Option<u32>,
1371
1372 max_type_argument_depth: Option<u32>,
1374
1375 max_pure_argument_size: Option<u32>,
1377
1378 max_programmable_tx_commands: Option<u32>,
1380
1381 move_binary_format_version: Option<u32>,
1384 min_move_binary_format_version: Option<u32>,
1385
1386 binary_module_handles: Option<u16>,
1388 binary_struct_handles: Option<u16>,
1389 binary_function_handles: Option<u16>,
1390 binary_function_instantiations: Option<u16>,
1391 binary_signatures: Option<u16>,
1392 binary_constant_pool: Option<u16>,
1393 binary_identifiers: Option<u16>,
1394 binary_address_identifiers: Option<u16>,
1395 binary_struct_defs: Option<u16>,
1396 binary_struct_def_instantiations: Option<u16>,
1397 binary_function_defs: Option<u16>,
1398 binary_field_handles: Option<u16>,
1399 binary_field_instantiations: Option<u16>,
1400 binary_friend_decls: Option<u16>,
1401 binary_enum_defs: Option<u16>,
1402 binary_enum_def_instantiations: Option<u16>,
1403 binary_variant_handles: Option<u16>,
1404 binary_variant_instantiation_handles: Option<u16>,
1405
1406 max_move_object_size: Option<u64>,
1408
1409 max_move_package_size: Option<u64>,
1412
1413 max_publish_or_upgrade_per_ptb: Option<u64>,
1415
1416 max_tx_gas: Option<u64>,
1418
1419 max_gas_price: Option<u64>,
1421
1422 max_gas_price_rgp_factor_for_aborted_transactions: Option<u64>,
1425
1426 max_gas_computation_bucket: Option<u64>,
1428
1429 gas_rounding_step: Option<u64>,
1431
1432 max_loop_depth: Option<u64>,
1434
1435 max_generic_instantiation_length: Option<u64>,
1437
1438 max_function_parameters: Option<u64>,
1440
1441 max_basic_blocks: Option<u64>,
1443
1444 max_value_stack_size: Option<u64>,
1446
1447 max_type_nodes: Option<u64>,
1449
1450 max_generic_instantiation_type_nodes_per_function: Option<u64>,
1452
1453 max_generic_instantiation_type_nodes_per_module: Option<u64>,
1455
1456 max_push_size: Option<u64>,
1458
1459 max_struct_definitions: Option<u64>,
1461
1462 max_function_definitions: Option<u64>,
1464
1465 max_fields_in_struct: Option<u64>,
1467
1468 max_dependency_depth: Option<u64>,
1470
1471 max_num_event_emit: Option<u64>,
1473
1474 max_num_new_move_object_ids: Option<u64>,
1476
1477 max_num_new_move_object_ids_system_tx: Option<u64>,
1479
1480 max_num_deleted_move_object_ids: Option<u64>,
1482
1483 max_num_deleted_move_object_ids_system_tx: Option<u64>,
1485
1486 max_num_transferred_move_object_ids: Option<u64>,
1488
1489 max_num_transferred_move_object_ids_system_tx: Option<u64>,
1491
1492 max_event_emit_size: Option<u64>,
1494
1495 max_event_emit_size_total: Option<u64>,
1497
1498 max_move_vector_len: Option<u64>,
1500
1501 max_move_identifier_len: Option<u64>,
1503
1504 max_move_value_depth: Option<u64>,
1506
1507 max_move_enum_variants: Option<u64>,
1509
1510 max_back_edges_per_function: Option<u64>,
1512
1513 max_back_edges_per_module: Option<u64>,
1515
1516 max_verifier_meter_ticks_per_function: Option<u64>,
1518
1519 max_meter_ticks_per_module: Option<u64>,
1521
1522 max_meter_ticks_per_package: Option<u64>,
1524
1525 object_runtime_max_num_cached_objects: Option<u64>,
1529
1530 object_runtime_max_num_cached_objects_system_tx: Option<u64>,
1532
1533 object_runtime_max_num_store_entries: Option<u64>,
1535
1536 object_runtime_max_num_store_entries_system_tx: Option<u64>,
1538
1539 base_tx_cost_fixed: Option<u64>,
1542
1543 package_publish_cost_fixed: Option<u64>,
1546
1547 base_tx_cost_per_byte: Option<u64>,
1550
1551 package_publish_cost_per_byte: Option<u64>,
1553
1554 obj_access_cost_read_per_byte: Option<u64>,
1556
1557 obj_access_cost_mutate_per_byte: Option<u64>,
1559
1560 obj_access_cost_delete_per_byte: Option<u64>,
1562
1563 obj_access_cost_verify_per_byte: Option<u64>,
1573
1574 max_type_to_layout_nodes: Option<u64>,
1576
1577 max_ptb_value_size: Option<u64>,
1579
1580 gas_model_version: Option<u64>,
1583
1584 obj_data_cost_refundable: Option<u64>,
1587
1588 obj_metadata_cost_non_refundable: Option<u64>,
1592
1593 storage_rebate_rate: Option<u64>,
1599
1600 storage_fund_reinvest_rate: Option<u64>,
1603
1604 reward_slashing_rate: Option<u64>,
1607
1608 storage_gas_price: Option<u64>,
1610
1611 accumulator_object_storage_cost: Option<u64>,
1613
1614 max_transactions_per_checkpoint: Option<u64>,
1619
1620 max_checkpoint_size_bytes: Option<u64>,
1624
1625 buffer_stake_for_protocol_upgrade_bps: Option<u64>,
1630
1631 address_from_bytes_cost_base: Option<u64>,
1636 address_to_u256_cost_base: Option<u64>,
1638 address_from_u256_cost_base: Option<u64>,
1640
1641 config_read_setting_impl_cost_base: Option<u64>,
1646 config_read_setting_impl_cost_per_byte: Option<u64>,
1647
1648 dynamic_field_hash_type_and_key_cost_base: Option<u64>,
1651 dynamic_field_hash_type_and_key_type_cost_per_byte: Option<u64>,
1652 dynamic_field_hash_type_and_key_value_cost_per_byte: Option<u64>,
1653 dynamic_field_hash_type_and_key_type_tag_cost_per_byte: Option<u64>,
1654 dynamic_field_add_child_object_cost_base: Option<u64>,
1656 dynamic_field_add_child_object_type_cost_per_byte: Option<u64>,
1657 dynamic_field_add_child_object_value_cost_per_byte: Option<u64>,
1658 dynamic_field_add_child_object_struct_tag_cost_per_byte: Option<u64>,
1659 dynamic_field_borrow_child_object_cost_base: Option<u64>,
1661 dynamic_field_borrow_child_object_child_ref_cost_per_byte: Option<u64>,
1662 dynamic_field_borrow_child_object_type_cost_per_byte: Option<u64>,
1663 dynamic_field_remove_child_object_cost_base: Option<u64>,
1665 dynamic_field_remove_child_object_child_cost_per_byte: Option<u64>,
1666 dynamic_field_remove_child_object_type_cost_per_byte: Option<u64>,
1667 dynamic_field_has_child_object_cost_base: Option<u64>,
1669 dynamic_field_has_child_object_with_ty_cost_base: Option<u64>,
1671 dynamic_field_has_child_object_with_ty_type_cost_per_byte: Option<u64>,
1672 dynamic_field_has_child_object_with_ty_type_tag_cost_per_byte: Option<u64>,
1673
1674 scratch_add_cost_base: Option<u64>,
1677 scratch_read_cost_base: Option<u64>,
1679 scratch_read_value_cost: Option<u64>,
1680 scratch_remove_cost_base: Option<u64>,
1682 scratch_exists_cost_base: Option<u64>,
1684 scratch_exists_with_type_cost_base: Option<u64>,
1686 scratch_exists_with_type_type_cost: Option<u64>,
1687 max_scratch_pad_size: Option<u64>,
1689
1690 event_emit_cost_base: Option<u64>,
1693 event_emit_value_size_derivation_cost_per_byte: Option<u64>,
1694 event_emit_tag_size_derivation_cost_per_byte: Option<u64>,
1695 event_emit_output_cost_per_byte: Option<u64>,
1696 event_emit_auth_stream_cost: Option<u64>,
1697
1698 object_borrow_uid_cost_base: Option<u64>,
1701 object_delete_impl_cost_base: Option<u64>,
1703 object_record_new_uid_cost_base: Option<u64>,
1705
1706 transfer_transfer_internal_cost_base: Option<u64>,
1709 transfer_party_transfer_internal_cost_base: Option<u64>,
1711 transfer_freeze_object_cost_base: Option<u64>,
1713 transfer_share_object_cost_base: Option<u64>,
1715 transfer_receive_object_cost_base: Option<u64>,
1718 transfer_receive_object_cost_per_byte: Option<u64>,
1719 transfer_receive_object_type_cost_per_byte: Option<u64>,
1720
1721 tx_context_derive_id_cost_base: Option<u64>,
1724 tx_context_fresh_id_cost_base: Option<u64>,
1725 tx_context_sender_cost_base: Option<u64>,
1726 tx_context_epoch_cost_base: Option<u64>,
1727 tx_context_epoch_timestamp_ms_cost_base: Option<u64>,
1728 tx_context_sponsor_cost_base: Option<u64>,
1729 tx_context_rgp_cost_base: Option<u64>,
1730 tx_context_gas_price_cost_base: Option<u64>,
1731 tx_context_gas_budget_cost_base: Option<u64>,
1732 tx_context_ids_created_cost_base: Option<u64>,
1733 tx_context_replace_cost_base: Option<u64>,
1734
1735 types_is_one_time_witness_cost_base: Option<u64>,
1738 types_is_one_time_witness_type_tag_cost_per_byte: Option<u64>,
1739 types_is_one_time_witness_type_cost_per_byte: Option<u64>,
1740
1741 validator_validate_metadata_cost_base: Option<u64>,
1744 validator_validate_metadata_data_cost_per_byte: Option<u64>,
1745
1746 crypto_invalid_arguments_cost: Option<u64>,
1748 bls12381_bls12381_min_sig_verify_cost_base: Option<u64>,
1750 bls12381_bls12381_min_sig_verify_msg_cost_per_byte: Option<u64>,
1751 bls12381_bls12381_min_sig_verify_msg_cost_per_block: Option<u64>,
1752
1753 bls12381_bls12381_min_pk_verify_cost_base: Option<u64>,
1755 bls12381_bls12381_min_pk_verify_msg_cost_per_byte: Option<u64>,
1756 bls12381_bls12381_min_pk_verify_msg_cost_per_block: Option<u64>,
1757
1758 ecdsa_k1_ecrecover_keccak256_cost_base: Option<u64>,
1760 ecdsa_k1_ecrecover_keccak256_msg_cost_per_byte: Option<u64>,
1761 ecdsa_k1_ecrecover_keccak256_msg_cost_per_block: Option<u64>,
1762 ecdsa_k1_ecrecover_sha256_cost_base: Option<u64>,
1763 ecdsa_k1_ecrecover_sha256_msg_cost_per_byte: Option<u64>,
1764 ecdsa_k1_ecrecover_sha256_msg_cost_per_block: Option<u64>,
1765
1766 ecdsa_k1_decompress_pubkey_cost_base: Option<u64>,
1768
1769 ecdsa_k1_secp256k1_verify_keccak256_cost_base: Option<u64>,
1771 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_byte: Option<u64>,
1772 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_block: Option<u64>,
1773 ecdsa_k1_secp256k1_verify_sha256_cost_base: Option<u64>,
1774 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_byte: Option<u64>,
1775 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_block: Option<u64>,
1776
1777 ecdsa_r1_ecrecover_keccak256_cost_base: Option<u64>,
1779 ecdsa_r1_ecrecover_keccak256_msg_cost_per_byte: Option<u64>,
1780 ecdsa_r1_ecrecover_keccak256_msg_cost_per_block: Option<u64>,
1781 ecdsa_r1_ecrecover_sha256_cost_base: Option<u64>,
1782 ecdsa_r1_ecrecover_sha256_msg_cost_per_byte: Option<u64>,
1783 ecdsa_r1_ecrecover_sha256_msg_cost_per_block: Option<u64>,
1784
1785 ecdsa_r1_secp256r1_verify_keccak256_cost_base: Option<u64>,
1787 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_byte: Option<u64>,
1788 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_block: Option<u64>,
1789 ecdsa_r1_secp256r1_verify_sha256_cost_base: Option<u64>,
1790 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_byte: Option<u64>,
1791 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_block: Option<u64>,
1792
1793 ecvrf_ecvrf_verify_cost_base: Option<u64>,
1795 ecvrf_ecvrf_verify_alpha_string_cost_per_byte: Option<u64>,
1796 ecvrf_ecvrf_verify_alpha_string_cost_per_block: Option<u64>,
1797
1798 ed25519_ed25519_verify_cost_base: Option<u64>,
1800 ed25519_ed25519_verify_msg_cost_per_byte: Option<u64>,
1801 ed25519_ed25519_verify_msg_cost_per_block: Option<u64>,
1802
1803 groth16_prepare_verifying_key_bls12381_cost_base: Option<u64>,
1805 groth16_prepare_verifying_key_bn254_cost_base: Option<u64>,
1806
1807 groth16_verify_groth16_proof_internal_bls12381_cost_base: Option<u64>,
1809 groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input: Option<u64>,
1810 groth16_verify_groth16_proof_internal_bn254_cost_base: Option<u64>,
1811 groth16_verify_groth16_proof_internal_bn254_cost_per_public_input: Option<u64>,
1812 groth16_verify_groth16_proof_internal_public_input_cost_per_byte: Option<u64>,
1813
1814 hash_blake2b256_cost_base: Option<u64>,
1816 hash_blake2b256_data_cost_per_byte: Option<u64>,
1817 hash_blake2b256_data_cost_per_block: Option<u64>,
1818
1819 hash_keccak256_cost_base: Option<u64>,
1821 hash_keccak256_data_cost_per_byte: Option<u64>,
1822 hash_keccak256_data_cost_per_block: Option<u64>,
1823
1824 poseidon_bn254_cost_base: Option<u64>,
1826 poseidon_bn254_cost_per_block: Option<u64>,
1827
1828 group_ops_bls12381_decode_scalar_cost: Option<u64>,
1830 group_ops_bls12381_decode_g1_cost: Option<u64>,
1831 group_ops_bls12381_decode_g2_cost: Option<u64>,
1832 group_ops_bls12381_decode_gt_cost: Option<u64>,
1833 group_ops_bls12381_scalar_add_cost: Option<u64>,
1834 group_ops_bls12381_g1_add_cost: Option<u64>,
1835 group_ops_bls12381_g2_add_cost: Option<u64>,
1836 group_ops_bls12381_gt_add_cost: Option<u64>,
1837 group_ops_bls12381_scalar_sub_cost: Option<u64>,
1838 group_ops_bls12381_g1_sub_cost: Option<u64>,
1839 group_ops_bls12381_g2_sub_cost: Option<u64>,
1840 group_ops_bls12381_gt_sub_cost: Option<u64>,
1841 group_ops_bls12381_scalar_mul_cost: Option<u64>,
1842 group_ops_bls12381_g1_mul_cost: Option<u64>,
1843 group_ops_bls12381_g2_mul_cost: Option<u64>,
1844 group_ops_bls12381_gt_mul_cost: Option<u64>,
1845 group_ops_bls12381_scalar_div_cost: Option<u64>,
1846 group_ops_bls12381_g1_div_cost: Option<u64>,
1847 group_ops_bls12381_g2_div_cost: Option<u64>,
1848 group_ops_bls12381_gt_div_cost: Option<u64>,
1849 group_ops_bls12381_g1_hash_to_base_cost: Option<u64>,
1850 group_ops_bls12381_g2_hash_to_base_cost: Option<u64>,
1851 group_ops_bls12381_g1_hash_to_cost_per_byte: Option<u64>,
1852 group_ops_bls12381_g2_hash_to_cost_per_byte: Option<u64>,
1853 group_ops_bls12381_g1_msm_base_cost: Option<u64>,
1854 group_ops_bls12381_g2_msm_base_cost: Option<u64>,
1855 group_ops_bls12381_g1_msm_base_cost_per_input: Option<u64>,
1856 group_ops_bls12381_g2_msm_base_cost_per_input: Option<u64>,
1857 group_ops_bls12381_msm_max_len: Option<u32>,
1858 group_ops_bls12381_pairing_cost: Option<u64>,
1859 group_ops_bls12381_g1_to_uncompressed_g1_cost: Option<u64>,
1860 group_ops_bls12381_uncompressed_g1_to_g1_cost: Option<u64>,
1861 group_ops_bls12381_uncompressed_g1_sum_base_cost: Option<u64>,
1862 group_ops_bls12381_uncompressed_g1_sum_cost_per_term: Option<u64>,
1863 group_ops_bls12381_uncompressed_g1_sum_max_terms: Option<u64>,
1864
1865 group_ops_ristretto_decode_scalar_cost: Option<u64>,
1866 group_ops_ristretto_decode_point_cost: Option<u64>,
1867 group_ops_ristretto_scalar_add_cost: Option<u64>,
1868 group_ops_ristretto_point_add_cost: Option<u64>,
1869 group_ops_ristretto_scalar_sub_cost: Option<u64>,
1870 group_ops_ristretto_point_sub_cost: Option<u64>,
1871 group_ops_ristretto_scalar_mul_cost: Option<u64>,
1872 group_ops_ristretto_point_mul_cost: Option<u64>,
1873 group_ops_ristretto_scalar_div_cost: Option<u64>,
1874 group_ops_ristretto_point_div_cost: Option<u64>,
1875
1876 verify_bulletproofs_ristretto255_base_cost: Option<u64>,
1877 verify_bulletproofs_ristretto255_cost_per_bit_and_commitment: Option<u64>,
1878
1879 hmac_hmac_sha3_256_cost_base: Option<u64>,
1881 hmac_hmac_sha3_256_input_cost_per_byte: Option<u64>,
1882 hmac_hmac_sha3_256_input_cost_per_block: Option<u64>,
1883
1884 check_zklogin_id_cost_base: Option<u64>,
1886 check_zklogin_issuer_cost_base: Option<u64>,
1888
1889 vdf_verify_vdf_cost: Option<u64>,
1890 vdf_hash_to_input_cost: Option<u64>,
1891
1892 nitro_attestation_parse_base_cost: Option<u64>,
1894 nitro_attestation_parse_cost_per_byte: Option<u64>,
1895 nitro_attestation_verify_base_cost: Option<u64>,
1896 nitro_attestation_verify_cost_per_cert: Option<u64>,
1897
1898 bcs_per_byte_serialized_cost: Option<u64>,
1900 bcs_legacy_min_output_size_cost: Option<u64>,
1901 bcs_failure_cost: Option<u64>,
1902
1903 hash_sha2_256_base_cost: Option<u64>,
1904 hash_sha2_256_per_byte_cost: Option<u64>,
1905 hash_sha2_256_legacy_min_input_len_cost: Option<u64>,
1906 hash_sha3_256_base_cost: Option<u64>,
1907 hash_sha3_256_per_byte_cost: Option<u64>,
1908 hash_sha3_256_legacy_min_input_len_cost: Option<u64>,
1909 type_name_get_base_cost: Option<u64>,
1910 type_name_get_per_byte_cost: Option<u64>,
1911 type_name_id_base_cost: Option<u64>,
1912
1913 string_check_utf8_base_cost: Option<u64>,
1914 string_check_utf8_per_byte_cost: Option<u64>,
1915 string_is_char_boundary_base_cost: Option<u64>,
1916 string_sub_string_base_cost: Option<u64>,
1917 string_sub_string_per_byte_cost: Option<u64>,
1918 string_index_of_base_cost: Option<u64>,
1919 string_index_of_per_byte_pattern_cost: Option<u64>,
1920 string_index_of_per_byte_searched_cost: Option<u64>,
1921
1922 vector_empty_base_cost: Option<u64>,
1923 vector_length_base_cost: Option<u64>,
1924 vector_push_back_base_cost: Option<u64>,
1925 vector_push_back_legacy_per_abstract_memory_unit_cost: Option<u64>,
1926 vector_borrow_base_cost: Option<u64>,
1927 vector_pop_back_base_cost: Option<u64>,
1928 vector_destroy_empty_base_cost: Option<u64>,
1929 vector_swap_base_cost: Option<u64>,
1930 debug_print_base_cost: Option<u64>,
1931 debug_print_stack_trace_base_cost: Option<u64>,
1932
1933 execution_version: Option<u64>,
1942
1943 consensus_bad_nodes_stake_threshold: Option<u64>,
1947
1948 max_jwk_votes_per_validator_per_epoch: Option<u64>,
1949 max_age_of_jwk_in_epochs: Option<u64>,
1953
1954 random_beacon_reduction_allowed_delta: Option<u16>,
1958
1959 random_beacon_reduction_lower_bound: Option<u32>,
1962
1963 random_beacon_dkg_timeout_round: Option<u32>,
1966
1967 random_beacon_min_round_interval_ms: Option<u64>,
1969
1970 random_beacon_dkg_version: Option<u64>,
1973
1974 consensus_max_transaction_size_bytes: Option<u64>,
1977 consensus_max_transactions_in_block_bytes: Option<u64>,
1979 consensus_max_num_transactions_in_block: Option<u64>,
1981
1982 consensus_voting_rounds: Option<u32>,
1984
1985 max_accumulated_txn_cost_per_object_in_narwhal_commit: Option<u64>,
1987
1988 max_deferral_rounds_for_congestion_control: Option<u64>,
1991
1992 epoch_close_deadline_ms: Option<u64>,
1997
1998 max_txn_cost_overage_per_object_in_commit: Option<u64>,
2000
2001 allowed_txn_cost_overage_burst_per_object_in_commit: Option<u64>,
2003
2004 min_checkpoint_interval_ms: Option<u64>,
2006
2007 checkpoint_summary_version_specific_data: Option<u64>,
2009
2010 max_soft_bundle_size: Option<u64>,
2012
2013 bridge_should_try_to_finalize_committee: Option<bool>,
2017
2018 max_accumulated_txn_cost_per_object_in_mysticeti_commit: Option<u64>,
2024
2025 max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit: Option<u64>,
2028
2029 consensus_gc_depth: Option<u32>,
2032
2033 gas_budget_based_txn_cost_cap_factor: Option<u64>,
2035
2036 gas_budget_based_txn_cost_absolute_cap_commit_count: Option<u64>,
2038
2039 sip_45_consensus_amplification_threshold: Option<u64>,
2042
2043 use_object_per_epoch_marker_table_v2: Option<bool>,
2046
2047 consensus_commit_rate_estimation_window_size: Option<u32>,
2049
2050 #[serde(skip_serializing_if = "Vec::is_empty")]
2054 aliased_addresses: Vec<AliasedAddress>,
2055
2056 translation_per_command_base_charge: Option<u64>,
2059
2060 translation_per_input_base_charge: Option<u64>,
2063
2064 translation_pure_input_per_byte_charge: Option<u64>,
2066
2067 translation_per_type_node_charge: Option<u64>,
2071
2072 translation_per_reference_node_charge: Option<u64>,
2075
2076 translation_per_linkage_entry_charge: Option<u64>,
2079
2080 max_updates_per_settlement_txn: Option<u32>,
2082
2083 gasless_max_computation_units: Option<u64>,
2085
2086 gasless_allowed_token_types: Option<Vec<(String, u64)>>,
2088
2089 gasless_max_unused_inputs: Option<u64>,
2093
2094 gasless_max_pure_input_bytes: Option<u64>,
2097
2098 gasless_max_tps: Option<u64>,
2100
2101 #[serde(skip_serializing_if = "Option::is_none")]
2102 #[skip_accessor]
2103 include_special_package_amendments: Option<Arc<Amendments>>,
2104
2105 gasless_max_tx_size_bytes: Option<u64>,
2108}
2109
2110#[derive(Clone, Serialize, Deserialize, Debug)]
2112pub struct AliasedAddress {
2113 pub original: [u8; 32],
2115 pub aliased: [u8; 32],
2117 pub allowed_tx_digests: Vec<[u8; 32]>,
2119}
2120
2121impl ProtocolConfig {
2123 pub fn chain(&self) -> Chain {
2125 self.chain
2126 }
2127
2128 pub fn check_package_upgrades_supported(&self) -> Result<(), Error> {
2141 if self.feature_flags.package_upgrades {
2142 Ok(())
2143 } else {
2144 Err(Error(format!(
2145 "package upgrades are not supported at {:?}",
2146 self.version
2147 )))
2148 }
2149 }
2150
2151 pub fn zklogin_supported_providers(&self) -> &BTreeSet<String> {
2152 &self.feature_flags.zklogin_supported_providers
2153 }
2154
2155 pub fn zklogin_circuit_mode(&self) -> u64 {
2158 self.feature_flags.zklogin_circuit_mode
2159 }
2160
2161 pub fn consensus_transaction_ordering(&self) -> ConsensusTransactionOrdering {
2162 self.feature_flags.consensus_transaction_ordering
2163 }
2164
2165 pub fn enable_jwk_consensus_updates(&self) -> bool {
2166 let ret = self.feature_flags.enable_jwk_consensus_updates;
2167 if ret {
2168 assert!(self.feature_flags.end_of_epoch_transaction_supported);
2170 }
2171 ret
2172 }
2173
2174 pub fn end_of_epoch_transaction_supported(&self) -> bool {
2175 let ret = self.feature_flags.end_of_epoch_transaction_supported;
2176 if !ret {
2177 assert!(!self.feature_flags.enable_jwk_consensus_updates);
2179 }
2180 ret
2181 }
2182
2183 pub fn dkg_version(&self) -> u64 {
2184 self.random_beacon_dkg_version.unwrap_or(1)
2186 }
2187
2188 pub fn bridge(&self) -> bool {
2189 let ret = self.feature_flags.bridge;
2190 if ret {
2191 assert!(self.feature_flags.end_of_epoch_transaction_supported);
2193 }
2194 ret
2195 }
2196
2197 pub fn should_try_to_finalize_bridge_committee(&self) -> bool {
2198 if !self.bridge() {
2199 return false;
2200 }
2201 self.bridge_should_try_to_finalize_committee.unwrap_or(true)
2203 }
2204
2205 pub fn zklogin_max_epoch_upper_bound_delta(&self) -> Option<u64> {
2206 self.feature_flags.zklogin_max_epoch_upper_bound_delta
2207 }
2208
2209 pub fn enable_coin_reservation_obj_refs(&self) -> bool {
2210 self.new_vm_enabled() && self.feature_flags.enable_coin_reservation_obj_refs
2211 }
2212
2213 pub fn enable_authenticated_event_streams(&self) -> bool {
2214 self.feature_flags.enable_authenticated_event_streams && self.enable_accumulators()
2215 }
2216
2217 pub fn per_object_congestion_control_mode(&self) -> PerObjectCongestionControlMode {
2218 self.feature_flags.per_object_congestion_control_mode
2219 }
2220
2221 pub fn consensus_choice(&self) -> ConsensusChoice {
2222 self.feature_flags.consensus_choice
2223 }
2224
2225 pub fn consensus_network(&self) -> ConsensusNetwork {
2226 self.feature_flags.consensus_network
2227 }
2228
2229 pub fn mysticeti_num_leaders_per_round(&self) -> Option<usize> {
2230 self.feature_flags.mysticeti_num_leaders_per_round
2231 }
2232
2233 pub fn max_transaction_size_bytes(&self) -> u64 {
2234 self.consensus_max_transaction_size_bytes
2236 .unwrap_or(256 * 1024)
2237 }
2238
2239 pub fn max_transactions_in_block_bytes(&self) -> u64 {
2240 if cfg!(msim) {
2241 256 * 1024
2242 } else {
2243 self.consensus_max_transactions_in_block_bytes
2244 .unwrap_or(512 * 1024)
2245 }
2246 }
2247
2248 pub fn max_num_transactions_in_block(&self) -> u64 {
2249 if cfg!(msim) {
2250 8
2251 } else {
2252 self.consensus_max_num_transactions_in_block.unwrap_or(512)
2253 }
2254 }
2255
2256 pub fn gc_depth(&self) -> u32 {
2257 self.consensus_gc_depth.unwrap_or(0)
2258 }
2259
2260 pub fn consensus_linearize_subdag_v2(&self) -> bool {
2261 let res = self.feature_flags.consensus_linearize_subdag_v2;
2262 assert!(
2263 !res || self.gc_depth() > 0,
2264 "The consensus linearize sub dag V2 requires GC to be enabled"
2265 );
2266 res
2267 }
2268
2269 pub fn consensus_median_based_commit_timestamp(&self) -> bool {
2270 let res = self.feature_flags.consensus_median_based_commit_timestamp;
2271 assert!(
2272 !res || self.gc_depth() > 0,
2273 "The consensus median based commit timestamp requires GC to be enabled"
2274 );
2275 res
2276 }
2277
2278 pub fn get_consensus_commit_rate_estimation_window_size(&self) -> u32 {
2279 self.consensus_commit_rate_estimation_window_size
2280 .unwrap_or(0)
2281 }
2282
2283 pub fn consensus_num_requested_prior_commits_at_startup(&self) -> u32 {
2284 let window_size = self.get_consensus_commit_rate_estimation_window_size();
2288 assert!(window_size == 0 || self.record_additional_state_digest_in_prologue());
2290 window_size
2291 }
2292
2293 pub fn enable_observation_chunking(&self) -> bool {
2294 matches!(self.feature_flags.per_object_congestion_control_mode,
2295 PerObjectCongestionControlMode::ExecutionTimeEstimate(ref params)
2296 if params.observations_chunk_size.is_some()
2297 )
2298 }
2299
2300 pub fn address_aliases(&self) -> bool {
2301 let address_aliases = self.feature_flags.address_aliases;
2302 assert!(
2303 !address_aliases || self.mysticeti_fastpath(),
2304 "Address aliases requires Mysticeti fastpath to be enabled"
2305 );
2306 if address_aliases {
2307 assert!(
2308 self.feature_flags.disable_preconsensus_locking,
2309 "Address aliases requires CertifiedTransaction to be disabled"
2310 );
2311 }
2312 address_aliases
2313 }
2314
2315 pub fn new_vm_enabled(&self) -> bool {
2316 self.execution_version.is_some_and(|v| v >= 4)
2317 }
2318
2319 pub fn gasless_allowed_token_types(&self) -> &[(String, u64)] {
2320 debug_assert!(self.gasless_allowed_token_types.is_some());
2321 self.gasless_allowed_token_types.as_deref().unwrap_or(&[])
2322 }
2323
2324 pub fn get_gasless_max_unused_inputs(&self) -> u64 {
2325 self.gasless_max_unused_inputs.unwrap_or(u64::MAX)
2326 }
2327
2328 pub fn get_gasless_max_pure_input_bytes(&self) -> u64 {
2329 self.gasless_max_pure_input_bytes.unwrap_or(u64::MAX)
2330 }
2331
2332 pub fn get_gasless_max_tx_size_bytes(&self) -> u64 {
2333 self.gasless_max_tx_size_bytes.unwrap_or(u64::MAX)
2334 }
2335
2336 pub fn include_special_package_amendments_as_option(&self) -> &Option<Arc<Amendments>> {
2337 &self.include_special_package_amendments
2338 }
2339}
2340
2341#[cfg(not(msim))]
2342static POISON_VERSION_METHODS: AtomicBool = AtomicBool::new(false);
2343
2344#[cfg(msim)]
2346thread_local! {
2347 static POISON_VERSION_METHODS: AtomicBool = AtomicBool::new(false);
2348}
2349
2350impl ProtocolConfig {
2352 pub fn get_for_version(version: ProtocolVersion, chain: Chain) -> Self {
2354 assert!(
2356 version >= ProtocolVersion::MIN,
2357 "Network protocol version is {:?}, but the minimum supported version by the binary is {:?}. Please upgrade the binary.",
2358 version,
2359 ProtocolVersion::MIN.0,
2360 );
2361 assert!(
2362 version <= ProtocolVersion::MAX_ALLOWED,
2363 "Network protocol version is {:?}, but the maximum supported version by the binary is {:?}. Please upgrade the binary.",
2364 version,
2365 ProtocolVersion::MAX_ALLOWED.0,
2366 );
2367
2368 let mut ret = Self::get_for_version_impl(version, chain);
2369 ret.version = version;
2370 ret.chain = chain;
2371
2372 ret = Self::apply_config_override(version, ret);
2373
2374 if std::env::var("SUI_PROTOCOL_CONFIG_OVERRIDE_ENABLE").is_ok() {
2375 warn!(
2376 "overriding ProtocolConfig settings with custom settings; this may break non-local networks"
2377 );
2378 let overrides: ProtocolConfigOptional =
2379 serde_env::from_env_with_prefix("SUI_PROTOCOL_CONFIG_OVERRIDE")
2380 .expect("failed to parse ProtocolConfig override env variables");
2381 overrides.apply_to(&mut ret);
2382 }
2383
2384 ret
2385 }
2386
2387 pub fn get_for_version_if_supported(version: ProtocolVersion, chain: Chain) -> Option<Self> {
2390 if version.0 >= ProtocolVersion::MIN.0 && version.0 <= ProtocolVersion::MAX_ALLOWED.0 {
2391 let mut ret = Self::get_for_version_impl(version, chain);
2392 ret.version = version;
2393 ret.chain = chain;
2394 ret = Self::apply_config_override(version, ret);
2395 Some(ret)
2396 } else {
2397 None
2398 }
2399 }
2400
2401 #[cfg(not(msim))]
2402 pub fn poison_get_for_min_version() {
2403 POISON_VERSION_METHODS.store(true, Ordering::Relaxed);
2404 }
2405
2406 #[cfg(not(msim))]
2407 fn load_poison_get_for_min_version() -> bool {
2408 POISON_VERSION_METHODS.load(Ordering::Relaxed)
2409 }
2410
2411 #[cfg(msim)]
2412 pub fn poison_get_for_min_version() {
2413 POISON_VERSION_METHODS.with(|p| p.store(true, Ordering::Relaxed));
2414 }
2415
2416 #[cfg(msim)]
2417 fn load_poison_get_for_min_version() -> bool {
2418 POISON_VERSION_METHODS.with(|p| p.load(Ordering::Relaxed))
2419 }
2420
2421 pub fn get_for_min_version() -> Self {
2424 if Self::load_poison_get_for_min_version() {
2425 panic!("get_for_min_version called on validator");
2426 }
2427 ProtocolConfig::get_for_version(ProtocolVersion::MIN, Chain::Unknown)
2428 }
2429
2430 #[allow(non_snake_case)]
2440 pub fn get_for_max_version_UNSAFE() -> Self {
2441 if Self::load_poison_get_for_min_version() {
2442 panic!("get_for_max_version_UNSAFE called on validator");
2443 }
2444 ProtocolConfig::get_for_version(ProtocolVersion::MAX, Chain::Unknown)
2445 }
2446
2447 fn get_for_version_impl(version: ProtocolVersion, chain: Chain) -> Self {
2448 #[cfg(msim)]
2449 {
2450 if version == ProtocolVersion::MAX_ALLOWED {
2452 let mut config = Self::get_for_version_impl(version - 1, Chain::Unknown);
2453 config.base_tx_cost_fixed = Some(config.base_tx_cost_fixed() + 1000);
2454 return config;
2455 }
2456 }
2457
2458 let mut cfg = Self {
2461 version,
2463 chain,
2464
2465 feature_flags: Default::default(),
2467
2468 max_tx_size_bytes: Some(128 * 1024),
2469 max_input_objects: Some(2048),
2471 max_serialized_tx_effects_size_bytes: Some(512 * 1024),
2472 max_serialized_tx_effects_size_bytes_system_tx: Some(512 * 1024 * 16),
2473 max_gas_payment_objects: Some(256),
2474 max_modules_in_publish: Some(128),
2475 max_package_dependencies: None,
2476 max_arguments: Some(512),
2477 max_type_arguments: Some(16),
2478 max_type_argument_depth: Some(16),
2479 max_pure_argument_size: Some(16 * 1024),
2480 max_programmable_tx_commands: Some(1024),
2481 move_binary_format_version: Some(6),
2482 min_move_binary_format_version: None,
2483 binary_module_handles: None,
2484 binary_struct_handles: None,
2485 binary_function_handles: None,
2486 binary_function_instantiations: None,
2487 binary_signatures: None,
2488 binary_constant_pool: None,
2489 binary_identifiers: None,
2490 binary_address_identifiers: None,
2491 binary_struct_defs: None,
2492 binary_struct_def_instantiations: None,
2493 binary_function_defs: None,
2494 binary_field_handles: None,
2495 binary_field_instantiations: None,
2496 binary_friend_decls: None,
2497 binary_enum_defs: None,
2498 binary_enum_def_instantiations: None,
2499 binary_variant_handles: None,
2500 binary_variant_instantiation_handles: None,
2501 max_move_object_size: Some(250 * 1024),
2502 max_move_package_size: Some(100 * 1024),
2503 max_publish_or_upgrade_per_ptb: None,
2504 max_tx_gas: Some(10_000_000_000),
2505 max_gas_price: Some(100_000),
2506 max_gas_price_rgp_factor_for_aborted_transactions: None,
2507 max_gas_computation_bucket: Some(5_000_000),
2508 max_loop_depth: Some(5),
2509 max_generic_instantiation_length: Some(32),
2510 max_function_parameters: Some(128),
2511 max_basic_blocks: Some(1024),
2512 max_value_stack_size: Some(1024),
2513 max_type_nodes: Some(256),
2514 max_generic_instantiation_type_nodes_per_function: None,
2515 max_generic_instantiation_type_nodes_per_module: None,
2516 max_push_size: Some(10000),
2517 max_struct_definitions: Some(200),
2518 max_function_definitions: Some(1000),
2519 max_fields_in_struct: Some(32),
2520 max_dependency_depth: Some(100),
2521 max_num_event_emit: Some(256),
2522 max_num_new_move_object_ids: Some(2048),
2523 max_num_new_move_object_ids_system_tx: Some(2048 * 16),
2524 max_num_deleted_move_object_ids: Some(2048),
2525 max_num_deleted_move_object_ids_system_tx: Some(2048 * 16),
2526 max_num_transferred_move_object_ids: Some(2048),
2527 max_num_transferred_move_object_ids_system_tx: Some(2048 * 16),
2528 max_event_emit_size: Some(250 * 1024),
2529 max_move_vector_len: Some(256 * 1024),
2530 max_type_to_layout_nodes: None,
2531 max_ptb_value_size: None,
2532
2533 max_back_edges_per_function: Some(10_000),
2534 max_back_edges_per_module: Some(10_000),
2535 max_verifier_meter_ticks_per_function: Some(6_000_000),
2536 max_meter_ticks_per_module: Some(6_000_000),
2537 max_meter_ticks_per_package: None,
2538
2539 object_runtime_max_num_cached_objects: Some(1000),
2540 object_runtime_max_num_cached_objects_system_tx: Some(1000 * 16),
2541 object_runtime_max_num_store_entries: Some(1000),
2542 object_runtime_max_num_store_entries_system_tx: Some(1000 * 16),
2543 base_tx_cost_fixed: Some(110_000),
2544 package_publish_cost_fixed: Some(1_000),
2545 base_tx_cost_per_byte: Some(0),
2546 package_publish_cost_per_byte: Some(80),
2547 obj_access_cost_read_per_byte: Some(15),
2548 obj_access_cost_mutate_per_byte: Some(40),
2549 obj_access_cost_delete_per_byte: Some(40),
2550 obj_access_cost_verify_per_byte: Some(200),
2551 obj_data_cost_refundable: Some(100),
2552 obj_metadata_cost_non_refundable: Some(50),
2553 gas_model_version: Some(1),
2554 storage_rebate_rate: Some(9900),
2555 storage_fund_reinvest_rate: Some(500),
2556 reward_slashing_rate: Some(5000),
2557 storage_gas_price: Some(1),
2558 accumulator_object_storage_cost: None,
2559 max_transactions_per_checkpoint: Some(10_000),
2560 max_checkpoint_size_bytes: Some(30 * 1024 * 1024),
2561
2562 buffer_stake_for_protocol_upgrade_bps: Some(0),
2565
2566 address_from_bytes_cost_base: Some(52),
2570 address_to_u256_cost_base: Some(52),
2572 address_from_u256_cost_base: Some(52),
2574
2575 config_read_setting_impl_cost_base: None,
2578 config_read_setting_impl_cost_per_byte: None,
2579
2580 dynamic_field_hash_type_and_key_cost_base: Some(100),
2583 dynamic_field_hash_type_and_key_type_cost_per_byte: Some(2),
2584 dynamic_field_hash_type_and_key_value_cost_per_byte: Some(2),
2585 dynamic_field_hash_type_and_key_type_tag_cost_per_byte: Some(2),
2586 dynamic_field_add_child_object_cost_base: Some(100),
2588 dynamic_field_add_child_object_type_cost_per_byte: Some(10),
2589 dynamic_field_add_child_object_value_cost_per_byte: Some(10),
2590 dynamic_field_add_child_object_struct_tag_cost_per_byte: Some(10),
2591 dynamic_field_borrow_child_object_cost_base: Some(100),
2593 dynamic_field_borrow_child_object_child_ref_cost_per_byte: Some(10),
2594 dynamic_field_borrow_child_object_type_cost_per_byte: Some(10),
2595 dynamic_field_remove_child_object_cost_base: Some(100),
2597 dynamic_field_remove_child_object_child_cost_per_byte: Some(2),
2598 dynamic_field_remove_child_object_type_cost_per_byte: Some(2),
2599 dynamic_field_has_child_object_cost_base: Some(100),
2601 dynamic_field_has_child_object_with_ty_cost_base: Some(100),
2603 dynamic_field_has_child_object_with_ty_type_cost_per_byte: Some(2),
2604 dynamic_field_has_child_object_with_ty_type_tag_cost_per_byte: Some(2),
2605
2606 scratch_add_cost_base: None,
2608 scratch_read_cost_base: None,
2609 scratch_read_value_cost: None,
2610 scratch_remove_cost_base: None,
2611 scratch_exists_cost_base: None,
2612 scratch_exists_with_type_cost_base: None,
2613 scratch_exists_with_type_type_cost: None,
2614 max_scratch_pad_size: None,
2615
2616 event_emit_cost_base: Some(52),
2619 event_emit_value_size_derivation_cost_per_byte: Some(2),
2620 event_emit_tag_size_derivation_cost_per_byte: Some(5),
2621 event_emit_output_cost_per_byte: Some(10),
2622 event_emit_auth_stream_cost: None,
2623
2624 object_borrow_uid_cost_base: Some(52),
2627 object_delete_impl_cost_base: Some(52),
2629 object_record_new_uid_cost_base: Some(52),
2631
2632 transfer_transfer_internal_cost_base: Some(52),
2635 transfer_party_transfer_internal_cost_base: None,
2637 transfer_freeze_object_cost_base: Some(52),
2639 transfer_share_object_cost_base: Some(52),
2641 transfer_receive_object_cost_base: None,
2642 transfer_receive_object_type_cost_per_byte: None,
2643 transfer_receive_object_cost_per_byte: None,
2644
2645 tx_context_derive_id_cost_base: Some(52),
2648 tx_context_fresh_id_cost_base: None,
2649 tx_context_sender_cost_base: None,
2650 tx_context_epoch_cost_base: None,
2651 tx_context_epoch_timestamp_ms_cost_base: None,
2652 tx_context_sponsor_cost_base: None,
2653 tx_context_rgp_cost_base: None,
2654 tx_context_gas_price_cost_base: None,
2655 tx_context_gas_budget_cost_base: None,
2656 tx_context_ids_created_cost_base: None,
2657 tx_context_replace_cost_base: None,
2658
2659 types_is_one_time_witness_cost_base: Some(52),
2662 types_is_one_time_witness_type_tag_cost_per_byte: Some(2),
2663 types_is_one_time_witness_type_cost_per_byte: Some(2),
2664
2665 validator_validate_metadata_cost_base: Some(52),
2668 validator_validate_metadata_data_cost_per_byte: Some(2),
2669
2670 crypto_invalid_arguments_cost: Some(100),
2672 bls12381_bls12381_min_sig_verify_cost_base: Some(52),
2674 bls12381_bls12381_min_sig_verify_msg_cost_per_byte: Some(2),
2675 bls12381_bls12381_min_sig_verify_msg_cost_per_block: Some(2),
2676
2677 bls12381_bls12381_min_pk_verify_cost_base: Some(52),
2679 bls12381_bls12381_min_pk_verify_msg_cost_per_byte: Some(2),
2680 bls12381_bls12381_min_pk_verify_msg_cost_per_block: Some(2),
2681
2682 ecdsa_k1_ecrecover_keccak256_cost_base: Some(52),
2684 ecdsa_k1_ecrecover_keccak256_msg_cost_per_byte: Some(2),
2685 ecdsa_k1_ecrecover_keccak256_msg_cost_per_block: Some(2),
2686 ecdsa_k1_ecrecover_sha256_cost_base: Some(52),
2687 ecdsa_k1_ecrecover_sha256_msg_cost_per_byte: Some(2),
2688 ecdsa_k1_ecrecover_sha256_msg_cost_per_block: Some(2),
2689
2690 ecdsa_k1_decompress_pubkey_cost_base: Some(52),
2692
2693 ecdsa_k1_secp256k1_verify_keccak256_cost_base: Some(52),
2695 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_byte: Some(2),
2696 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_block: Some(2),
2697 ecdsa_k1_secp256k1_verify_sha256_cost_base: Some(52),
2698 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_byte: Some(2),
2699 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_block: Some(2),
2700
2701 ecdsa_r1_ecrecover_keccak256_cost_base: Some(52),
2703 ecdsa_r1_ecrecover_keccak256_msg_cost_per_byte: Some(2),
2704 ecdsa_r1_ecrecover_keccak256_msg_cost_per_block: Some(2),
2705 ecdsa_r1_ecrecover_sha256_cost_base: Some(52),
2706 ecdsa_r1_ecrecover_sha256_msg_cost_per_byte: Some(2),
2707 ecdsa_r1_ecrecover_sha256_msg_cost_per_block: Some(2),
2708
2709 ecdsa_r1_secp256r1_verify_keccak256_cost_base: Some(52),
2711 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_byte: Some(2),
2712 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_block: Some(2),
2713 ecdsa_r1_secp256r1_verify_sha256_cost_base: Some(52),
2714 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_byte: Some(2),
2715 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_block: Some(2),
2716
2717 ecvrf_ecvrf_verify_cost_base: Some(52),
2719 ecvrf_ecvrf_verify_alpha_string_cost_per_byte: Some(2),
2720 ecvrf_ecvrf_verify_alpha_string_cost_per_block: Some(2),
2721
2722 ed25519_ed25519_verify_cost_base: Some(52),
2724 ed25519_ed25519_verify_msg_cost_per_byte: Some(2),
2725 ed25519_ed25519_verify_msg_cost_per_block: Some(2),
2726
2727 groth16_prepare_verifying_key_bls12381_cost_base: Some(52),
2729 groth16_prepare_verifying_key_bn254_cost_base: Some(52),
2730
2731 groth16_verify_groth16_proof_internal_bls12381_cost_base: Some(52),
2733 groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input: Some(2),
2734 groth16_verify_groth16_proof_internal_bn254_cost_base: Some(52),
2735 groth16_verify_groth16_proof_internal_bn254_cost_per_public_input: Some(2),
2736 groth16_verify_groth16_proof_internal_public_input_cost_per_byte: Some(2),
2737
2738 hash_blake2b256_cost_base: Some(52),
2740 hash_blake2b256_data_cost_per_byte: Some(2),
2741 hash_blake2b256_data_cost_per_block: Some(2),
2742
2743 hash_keccak256_cost_base: Some(52),
2745 hash_keccak256_data_cost_per_byte: Some(2),
2746 hash_keccak256_data_cost_per_block: Some(2),
2747
2748 poseidon_bn254_cost_base: None,
2749 poseidon_bn254_cost_per_block: None,
2750
2751 hmac_hmac_sha3_256_cost_base: Some(52),
2753 hmac_hmac_sha3_256_input_cost_per_byte: Some(2),
2754 hmac_hmac_sha3_256_input_cost_per_block: Some(2),
2755
2756 group_ops_bls12381_decode_scalar_cost: None,
2758 group_ops_bls12381_decode_g1_cost: None,
2759 group_ops_bls12381_decode_g2_cost: None,
2760 group_ops_bls12381_decode_gt_cost: None,
2761 group_ops_bls12381_scalar_add_cost: None,
2762 group_ops_bls12381_g1_add_cost: None,
2763 group_ops_bls12381_g2_add_cost: None,
2764 group_ops_bls12381_gt_add_cost: None,
2765 group_ops_bls12381_scalar_sub_cost: None,
2766 group_ops_bls12381_g1_sub_cost: None,
2767 group_ops_bls12381_g2_sub_cost: None,
2768 group_ops_bls12381_gt_sub_cost: None,
2769 group_ops_bls12381_scalar_mul_cost: None,
2770 group_ops_bls12381_g1_mul_cost: None,
2771 group_ops_bls12381_g2_mul_cost: None,
2772 group_ops_bls12381_gt_mul_cost: None,
2773 group_ops_bls12381_scalar_div_cost: None,
2774 group_ops_bls12381_g1_div_cost: None,
2775 group_ops_bls12381_g2_div_cost: None,
2776 group_ops_bls12381_gt_div_cost: None,
2777 group_ops_bls12381_g1_hash_to_base_cost: None,
2778 group_ops_bls12381_g2_hash_to_base_cost: None,
2779 group_ops_bls12381_g1_hash_to_cost_per_byte: None,
2780 group_ops_bls12381_g2_hash_to_cost_per_byte: None,
2781 group_ops_bls12381_g1_msm_base_cost: None,
2782 group_ops_bls12381_g2_msm_base_cost: None,
2783 group_ops_bls12381_g1_msm_base_cost_per_input: None,
2784 group_ops_bls12381_g2_msm_base_cost_per_input: None,
2785 group_ops_bls12381_msm_max_len: None,
2786 group_ops_bls12381_pairing_cost: None,
2787 group_ops_bls12381_g1_to_uncompressed_g1_cost: None,
2788 group_ops_bls12381_uncompressed_g1_to_g1_cost: None,
2789 group_ops_bls12381_uncompressed_g1_sum_base_cost: None,
2790 group_ops_bls12381_uncompressed_g1_sum_cost_per_term: None,
2791 group_ops_bls12381_uncompressed_g1_sum_max_terms: None,
2792
2793 group_ops_ristretto_decode_scalar_cost: None,
2794 group_ops_ristretto_decode_point_cost: None,
2795 group_ops_ristretto_scalar_add_cost: None,
2796 group_ops_ristretto_point_add_cost: None,
2797 group_ops_ristretto_scalar_sub_cost: None,
2798 group_ops_ristretto_point_sub_cost: None,
2799 group_ops_ristretto_scalar_mul_cost: None,
2800 group_ops_ristretto_point_mul_cost: None,
2801 group_ops_ristretto_scalar_div_cost: None,
2802 group_ops_ristretto_point_div_cost: None,
2803
2804 verify_bulletproofs_ristretto255_base_cost: None,
2805 verify_bulletproofs_ristretto255_cost_per_bit_and_commitment: None,
2806
2807 check_zklogin_id_cost_base: None,
2809 check_zklogin_issuer_cost_base: None,
2811
2812 vdf_verify_vdf_cost: None,
2813 vdf_hash_to_input_cost: None,
2814
2815 nitro_attestation_parse_base_cost: None,
2817 nitro_attestation_parse_cost_per_byte: None,
2818 nitro_attestation_verify_base_cost: None,
2819 nitro_attestation_verify_cost_per_cert: None,
2820
2821 bcs_per_byte_serialized_cost: None,
2822 bcs_legacy_min_output_size_cost: None,
2823 bcs_failure_cost: None,
2824 hash_sha2_256_base_cost: None,
2825 hash_sha2_256_per_byte_cost: None,
2826 hash_sha2_256_legacy_min_input_len_cost: None,
2827 hash_sha3_256_base_cost: None,
2828 hash_sha3_256_per_byte_cost: None,
2829 hash_sha3_256_legacy_min_input_len_cost: None,
2830 type_name_get_base_cost: None,
2831 type_name_get_per_byte_cost: None,
2832 type_name_id_base_cost: None,
2833 string_check_utf8_base_cost: None,
2834 string_check_utf8_per_byte_cost: None,
2835 string_is_char_boundary_base_cost: None,
2836 string_sub_string_base_cost: None,
2837 string_sub_string_per_byte_cost: None,
2838 string_index_of_base_cost: None,
2839 string_index_of_per_byte_pattern_cost: None,
2840 string_index_of_per_byte_searched_cost: None,
2841 vector_empty_base_cost: None,
2842 vector_length_base_cost: None,
2843 vector_push_back_base_cost: None,
2844 vector_push_back_legacy_per_abstract_memory_unit_cost: None,
2845 vector_borrow_base_cost: None,
2846 vector_pop_back_base_cost: None,
2847 vector_destroy_empty_base_cost: None,
2848 vector_swap_base_cost: None,
2849 debug_print_base_cost: None,
2850 debug_print_stack_trace_base_cost: None,
2851
2852 max_size_written_objects: None,
2853 max_size_written_objects_system_tx: None,
2854
2855 max_move_identifier_len: None,
2862 max_move_value_depth: None,
2863 max_move_enum_variants: None,
2864
2865 gas_rounding_step: None,
2866
2867 execution_version: None,
2868
2869 max_event_emit_size_total: None,
2870
2871 consensus_bad_nodes_stake_threshold: None,
2872
2873 max_jwk_votes_per_validator_per_epoch: None,
2874
2875 max_age_of_jwk_in_epochs: None,
2876
2877 random_beacon_reduction_allowed_delta: None,
2878
2879 random_beacon_reduction_lower_bound: None,
2880
2881 random_beacon_dkg_timeout_round: None,
2882
2883 random_beacon_min_round_interval_ms: None,
2884
2885 random_beacon_dkg_version: None,
2886
2887 consensus_max_transaction_size_bytes: None,
2888
2889 consensus_max_transactions_in_block_bytes: None,
2890
2891 consensus_max_num_transactions_in_block: None,
2892
2893 consensus_voting_rounds: None,
2894
2895 max_accumulated_txn_cost_per_object_in_narwhal_commit: None,
2896
2897 max_deferral_rounds_for_congestion_control: None,
2898
2899 epoch_close_deadline_ms: None,
2900
2901 max_txn_cost_overage_per_object_in_commit: None,
2902
2903 allowed_txn_cost_overage_burst_per_object_in_commit: None,
2904
2905 min_checkpoint_interval_ms: None,
2906
2907 checkpoint_summary_version_specific_data: None,
2908
2909 max_soft_bundle_size: None,
2910
2911 bridge_should_try_to_finalize_committee: None,
2912
2913 max_accumulated_txn_cost_per_object_in_mysticeti_commit: None,
2914
2915 max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit: None,
2916
2917 consensus_gc_depth: None,
2918
2919 gas_budget_based_txn_cost_cap_factor: None,
2920
2921 gas_budget_based_txn_cost_absolute_cap_commit_count: None,
2922
2923 sip_45_consensus_amplification_threshold: None,
2924
2925 use_object_per_epoch_marker_table_v2: None,
2926
2927 consensus_commit_rate_estimation_window_size: None,
2928
2929 aliased_addresses: vec![],
2930
2931 translation_per_command_base_charge: None,
2932 translation_per_input_base_charge: None,
2933 translation_pure_input_per_byte_charge: None,
2934 translation_per_type_node_charge: None,
2935 translation_per_reference_node_charge: None,
2936 translation_per_linkage_entry_charge: None,
2937
2938 max_updates_per_settlement_txn: None,
2939
2940 gasless_max_computation_units: None,
2941 gasless_allowed_token_types: None,
2942 gasless_max_unused_inputs: None,
2943 gasless_max_pure_input_bytes: None,
2944 gasless_max_tps: None,
2945 include_special_package_amendments: None,
2946 gasless_max_tx_size_bytes: None,
2947 };
2950 for cur in 2..=version.0 {
2951 match cur {
2952 1 => unreachable!(),
2953 2 => {
2954 cfg.feature_flags.advance_epoch_start_time_in_safe_mode = true;
2955 }
2956 3 => {
2957 cfg.gas_model_version = Some(2);
2959 cfg.max_tx_gas = Some(50_000_000_000);
2961 cfg.base_tx_cost_fixed = Some(2_000);
2963 cfg.storage_gas_price = Some(76);
2965 cfg.feature_flags.loaded_child_objects_fixed = true;
2966 cfg.max_size_written_objects = Some(5 * 1000 * 1000);
2969 cfg.max_size_written_objects_system_tx = Some(50 * 1000 * 1000);
2972 cfg.feature_flags.package_upgrades = true;
2973 }
2974 4 => {
2979 cfg.reward_slashing_rate = Some(10000);
2981 cfg.gas_model_version = Some(3);
2983 }
2984 5 => {
2985 cfg.feature_flags.missing_type_is_compatibility_error = true;
2986 cfg.gas_model_version = Some(4);
2987 cfg.feature_flags.scoring_decision_with_validity_cutoff = true;
2988 }
2992 6 => {
2993 cfg.gas_model_version = Some(5);
2994 cfg.buffer_stake_for_protocol_upgrade_bps = Some(5000);
2995 cfg.feature_flags.consensus_order_end_of_epoch_last = true;
2996 }
2997 7 => {
2998 cfg.feature_flags.disallow_adding_abilities_on_upgrade = true;
2999 cfg.feature_flags
3000 .disable_invariant_violation_check_in_swap_loc = true;
3001 cfg.feature_flags.ban_entry_init = true;
3002 cfg.feature_flags.package_digest_hash_module = true;
3003 }
3004 8 => {
3005 cfg.feature_flags
3006 .disallow_change_struct_type_params_on_upgrade = true;
3007 }
3008 9 => {
3009 cfg.max_move_identifier_len = Some(128);
3011 cfg.feature_flags.no_extraneous_module_bytes = true;
3012 cfg.feature_flags
3013 .advance_to_highest_supported_protocol_version = true;
3014 }
3015 10 => {
3016 cfg.max_verifier_meter_ticks_per_function = Some(16_000_000);
3017 cfg.max_meter_ticks_per_module = Some(16_000_000);
3018 }
3019 11 => {
3020 cfg.max_move_value_depth = Some(128);
3021 }
3022 12 => {
3023 cfg.feature_flags.narwhal_versioned_metadata = true;
3024 if chain != Chain::Mainnet {
3025 cfg.feature_flags.commit_root_state_digest = true;
3026 }
3027
3028 if chain != Chain::Mainnet && chain != Chain::Testnet {
3029 cfg.feature_flags.zklogin_auth = true;
3030 }
3031 }
3032 13 => {}
3033 14 => {
3034 cfg.gas_rounding_step = Some(1_000);
3035 cfg.gas_model_version = Some(6);
3036 }
3037 15 => {
3038 cfg.feature_flags.consensus_transaction_ordering =
3039 ConsensusTransactionOrdering::ByGasPrice;
3040 }
3041 16 => {
3042 cfg.feature_flags.simplified_unwrap_then_delete = true;
3043 }
3044 17 => {
3045 cfg.feature_flags.upgraded_multisig_supported = true;
3046 }
3047 18 => {
3048 cfg.execution_version = Some(1);
3049 cfg.feature_flags.txn_base_cost_as_multiplier = true;
3058 cfg.base_tx_cost_fixed = Some(1_000);
3060 }
3061 19 => {
3062 cfg.max_num_event_emit = Some(1024);
3063 cfg.max_event_emit_size_total = Some(
3066 256 * 250 * 1024, );
3068 }
3069 20 => {
3070 cfg.feature_flags.commit_root_state_digest = true;
3071
3072 if chain != Chain::Mainnet {
3073 cfg.feature_flags.narwhal_new_leader_election_schedule = true;
3074 cfg.consensus_bad_nodes_stake_threshold = Some(20);
3075 }
3076 }
3077
3078 21 => {
3079 if chain != Chain::Mainnet {
3080 cfg.feature_flags.zklogin_supported_providers = BTreeSet::from([
3081 "Google".to_string(),
3082 "Facebook".to_string(),
3083 "Twitch".to_string(),
3084 ]);
3085 }
3086 }
3087 22 => {
3088 cfg.feature_flags.loaded_child_object_format = true;
3089 }
3090 23 => {
3091 cfg.feature_flags.loaded_child_object_format_type = true;
3092 cfg.feature_flags.narwhal_new_leader_election_schedule = true;
3093 cfg.consensus_bad_nodes_stake_threshold = Some(20);
3099 }
3100 24 => {
3101 cfg.feature_flags.simple_conservation_checks = true;
3102 cfg.max_publish_or_upgrade_per_ptb = Some(5);
3103
3104 cfg.feature_flags.end_of_epoch_transaction_supported = true;
3105
3106 if chain != Chain::Mainnet {
3107 cfg.feature_flags.enable_jwk_consensus_updates = true;
3108 cfg.max_jwk_votes_per_validator_per_epoch = Some(240);
3110 cfg.max_age_of_jwk_in_epochs = Some(1);
3111 }
3112 }
3113 25 => {
3114 cfg.feature_flags.zklogin_supported_providers = BTreeSet::from([
3116 "Google".to_string(),
3117 "Facebook".to_string(),
3118 "Twitch".to_string(),
3119 ]);
3120 cfg.feature_flags.zklogin_auth = true;
3121
3122 cfg.feature_flags.enable_jwk_consensus_updates = true;
3124 cfg.max_jwk_votes_per_validator_per_epoch = Some(240);
3125 cfg.max_age_of_jwk_in_epochs = Some(1);
3126 }
3127 26 => {
3128 cfg.gas_model_version = Some(7);
3129 if chain != Chain::Mainnet && chain != Chain::Testnet {
3131 cfg.transfer_receive_object_cost_base = Some(52);
3132 cfg.feature_flags.receive_objects = true;
3133 }
3134 }
3135 27 => {
3136 cfg.gas_model_version = Some(8);
3137 }
3138 28 => {
3139 cfg.check_zklogin_id_cost_base = Some(200);
3141 cfg.check_zklogin_issuer_cost_base = Some(200);
3143
3144 if chain != Chain::Mainnet && chain != Chain::Testnet {
3146 cfg.feature_flags.enable_effects_v2 = true;
3147 }
3148 }
3149 29 => {
3150 cfg.feature_flags.verify_legacy_zklogin_address = true;
3151 }
3152 30 => {
3153 if chain != Chain::Mainnet {
3155 cfg.feature_flags.narwhal_certificate_v2 = true;
3156 }
3157
3158 cfg.random_beacon_reduction_allowed_delta = Some(800);
3159 if chain != Chain::Mainnet {
3161 cfg.feature_flags.enable_effects_v2 = true;
3162 }
3163
3164 cfg.feature_flags.zklogin_supported_providers = BTreeSet::default();
3168
3169 cfg.feature_flags.recompute_has_public_transfer_in_execution = true;
3170 }
3171 31 => {
3172 cfg.execution_version = Some(2);
3173 if chain != Chain::Mainnet && chain != Chain::Testnet {
3175 cfg.feature_flags.shared_object_deletion = true;
3176 }
3177 }
3178 32 => {
3179 if chain != Chain::Mainnet {
3181 cfg.feature_flags.accept_zklogin_in_multisig = true;
3182 }
3183 if chain != Chain::Mainnet {
3185 cfg.transfer_receive_object_cost_base = Some(52);
3186 cfg.feature_flags.receive_objects = true;
3187 }
3188 if chain != Chain::Mainnet && chain != Chain::Testnet {
3190 cfg.feature_flags.random_beacon = true;
3191 cfg.random_beacon_reduction_lower_bound = Some(1600);
3192 cfg.random_beacon_dkg_timeout_round = Some(3000);
3193 cfg.random_beacon_min_round_interval_ms = Some(150);
3194 }
3195 if chain != Chain::Testnet && chain != Chain::Mainnet {
3197 cfg.feature_flags.include_consensus_digest_in_prologue = true;
3198 }
3199
3200 cfg.feature_flags.narwhal_certificate_v2 = true;
3202 }
3203 33 => {
3204 cfg.feature_flags.hardened_otw_check = true;
3205 cfg.feature_flags.allow_receiving_object_id = true;
3206
3207 cfg.transfer_receive_object_cost_base = Some(52);
3209 cfg.feature_flags.receive_objects = true;
3210
3211 if chain != Chain::Mainnet {
3213 cfg.feature_flags.shared_object_deletion = true;
3214 }
3215
3216 cfg.feature_flags.enable_effects_v2 = true;
3217 }
3218 34 => {}
3219 35 => {
3220 if chain != Chain::Mainnet && chain != Chain::Testnet {
3222 cfg.feature_flags.enable_poseidon = true;
3223 cfg.poseidon_bn254_cost_base = Some(260);
3224 cfg.poseidon_bn254_cost_per_block = Some(10);
3225 }
3226
3227 cfg.feature_flags.enable_coin_deny_list = true;
3228 }
3229 36 => {
3230 if chain != Chain::Mainnet && chain != Chain::Testnet {
3232 cfg.feature_flags.enable_group_ops_native_functions = true;
3233 cfg.feature_flags.enable_group_ops_native_function_msm = true;
3234 cfg.group_ops_bls12381_decode_scalar_cost = Some(52);
3236 cfg.group_ops_bls12381_decode_g1_cost = Some(52);
3237 cfg.group_ops_bls12381_decode_g2_cost = Some(52);
3238 cfg.group_ops_bls12381_decode_gt_cost = Some(52);
3239 cfg.group_ops_bls12381_scalar_add_cost = Some(52);
3240 cfg.group_ops_bls12381_g1_add_cost = Some(52);
3241 cfg.group_ops_bls12381_g2_add_cost = Some(52);
3242 cfg.group_ops_bls12381_gt_add_cost = Some(52);
3243 cfg.group_ops_bls12381_scalar_sub_cost = Some(52);
3244 cfg.group_ops_bls12381_g1_sub_cost = Some(52);
3245 cfg.group_ops_bls12381_g2_sub_cost = Some(52);
3246 cfg.group_ops_bls12381_gt_sub_cost = Some(52);
3247 cfg.group_ops_bls12381_scalar_mul_cost = Some(52);
3248 cfg.group_ops_bls12381_g1_mul_cost = Some(52);
3249 cfg.group_ops_bls12381_g2_mul_cost = Some(52);
3250 cfg.group_ops_bls12381_gt_mul_cost = Some(52);
3251 cfg.group_ops_bls12381_scalar_div_cost = Some(52);
3252 cfg.group_ops_bls12381_g1_div_cost = Some(52);
3253 cfg.group_ops_bls12381_g2_div_cost = Some(52);
3254 cfg.group_ops_bls12381_gt_div_cost = Some(52);
3255 cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(52);
3256 cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(52);
3257 cfg.group_ops_bls12381_g1_hash_to_cost_per_byte = Some(2);
3258 cfg.group_ops_bls12381_g2_hash_to_cost_per_byte = Some(2);
3259 cfg.group_ops_bls12381_g1_msm_base_cost = Some(52);
3260 cfg.group_ops_bls12381_g2_msm_base_cost = Some(52);
3261 cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(52);
3262 cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(52);
3263 cfg.group_ops_bls12381_msm_max_len = Some(32);
3264 cfg.group_ops_bls12381_pairing_cost = Some(52);
3265 }
3266 cfg.feature_flags.shared_object_deletion = true;
3268
3269 cfg.consensus_max_transaction_size_bytes = Some(256 * 1024); cfg.consensus_max_transactions_in_block_bytes = Some(6 * 1_024 * 1024);
3271 }
3273 37 => {
3274 cfg.feature_flags.reject_mutable_random_on_entry_functions = true;
3275
3276 if chain != Chain::Mainnet {
3278 cfg.feature_flags.include_consensus_digest_in_prologue = true;
3279 }
3280 }
3281 38 => {
3282 cfg.binary_module_handles = Some(100);
3283 cfg.binary_struct_handles = Some(300);
3284 cfg.binary_function_handles = Some(1500);
3285 cfg.binary_function_instantiations = Some(750);
3286 cfg.binary_signatures = Some(1000);
3287 cfg.binary_constant_pool = Some(4000);
3291 cfg.binary_identifiers = Some(10000);
3292 cfg.binary_address_identifiers = Some(100);
3293 cfg.binary_struct_defs = Some(200);
3294 cfg.binary_struct_def_instantiations = Some(100);
3295 cfg.binary_function_defs = Some(1000);
3296 cfg.binary_field_handles = Some(500);
3297 cfg.binary_field_instantiations = Some(250);
3298 cfg.binary_friend_decls = Some(100);
3299 cfg.max_package_dependencies = Some(32);
3301 cfg.max_modules_in_publish = Some(64);
3302 cfg.execution_version = Some(3);
3304 }
3305 39 => {
3306 }
3308 40 => {}
3309 41 => {
3310 cfg.feature_flags.enable_group_ops_native_functions = true;
3312 cfg.group_ops_bls12381_decode_scalar_cost = Some(52);
3314 cfg.group_ops_bls12381_decode_g1_cost = Some(52);
3315 cfg.group_ops_bls12381_decode_g2_cost = Some(52);
3316 cfg.group_ops_bls12381_decode_gt_cost = Some(52);
3317 cfg.group_ops_bls12381_scalar_add_cost = Some(52);
3318 cfg.group_ops_bls12381_g1_add_cost = Some(52);
3319 cfg.group_ops_bls12381_g2_add_cost = Some(52);
3320 cfg.group_ops_bls12381_gt_add_cost = Some(52);
3321 cfg.group_ops_bls12381_scalar_sub_cost = Some(52);
3322 cfg.group_ops_bls12381_g1_sub_cost = Some(52);
3323 cfg.group_ops_bls12381_g2_sub_cost = Some(52);
3324 cfg.group_ops_bls12381_gt_sub_cost = Some(52);
3325 cfg.group_ops_bls12381_scalar_mul_cost = Some(52);
3326 cfg.group_ops_bls12381_g1_mul_cost = Some(52);
3327 cfg.group_ops_bls12381_g2_mul_cost = Some(52);
3328 cfg.group_ops_bls12381_gt_mul_cost = Some(52);
3329 cfg.group_ops_bls12381_scalar_div_cost = Some(52);
3330 cfg.group_ops_bls12381_g1_div_cost = Some(52);
3331 cfg.group_ops_bls12381_g2_div_cost = Some(52);
3332 cfg.group_ops_bls12381_gt_div_cost = Some(52);
3333 cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(52);
3334 cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(52);
3335 cfg.group_ops_bls12381_g1_hash_to_cost_per_byte = Some(2);
3336 cfg.group_ops_bls12381_g2_hash_to_cost_per_byte = Some(2);
3337 cfg.group_ops_bls12381_g1_msm_base_cost = Some(52);
3338 cfg.group_ops_bls12381_g2_msm_base_cost = Some(52);
3339 cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(52);
3340 cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(52);
3341 cfg.group_ops_bls12381_msm_max_len = Some(32);
3342 cfg.group_ops_bls12381_pairing_cost = Some(52);
3343 }
3344 42 => {}
3345 43 => {
3346 cfg.feature_flags.zklogin_max_epoch_upper_bound_delta = Some(30);
3347 cfg.max_meter_ticks_per_package = Some(16_000_000);
3348 }
3349 44 => {
3350 cfg.feature_flags.include_consensus_digest_in_prologue = true;
3352 if chain != Chain::Mainnet {
3354 cfg.feature_flags.consensus_choice = ConsensusChoice::SwapEachEpoch;
3355 }
3356 }
3357 45 => {
3358 if chain != Chain::Testnet && chain != Chain::Mainnet {
3360 cfg.feature_flags.consensus_network = ConsensusNetwork::Tonic;
3361 }
3362
3363 if chain != Chain::Mainnet {
3364 cfg.feature_flags.mysticeti_leader_scoring_and_schedule = true;
3366 }
3367 cfg.min_move_binary_format_version = Some(6);
3368 cfg.feature_flags.accept_zklogin_in_multisig = true;
3369
3370 if chain != Chain::Mainnet && chain != Chain::Testnet {
3374 cfg.feature_flags.bridge = true;
3375 }
3376 }
3377 46 => {
3378 if chain != Chain::Mainnet {
3380 cfg.feature_flags.bridge = true;
3381 }
3382
3383 cfg.feature_flags.reshare_at_same_initial_version = true;
3385 }
3386 47 => {}
3387 48 => {
3388 cfg.feature_flags.consensus_network = ConsensusNetwork::Tonic;
3390
3391 cfg.feature_flags.resolve_abort_locations_to_package_id = true;
3393
3394 if chain != Chain::Mainnet {
3396 cfg.feature_flags.random_beacon = true;
3397 cfg.random_beacon_reduction_lower_bound = Some(1600);
3398 cfg.random_beacon_dkg_timeout_round = Some(3000);
3399 cfg.random_beacon_min_round_interval_ms = Some(200);
3400 }
3401
3402 cfg.feature_flags.mysticeti_use_committed_subdag_digest = true;
3404 }
3405 49 => {
3406 if chain != Chain::Testnet && chain != Chain::Mainnet {
3407 cfg.move_binary_format_version = Some(7);
3408 }
3409
3410 if chain != Chain::Mainnet && chain != Chain::Testnet {
3412 cfg.feature_flags.enable_vdf = true;
3413 cfg.vdf_verify_vdf_cost = Some(1500);
3416 cfg.vdf_hash_to_input_cost = Some(100);
3417 }
3418
3419 if chain != Chain::Testnet && chain != Chain::Mainnet {
3421 cfg.feature_flags
3422 .record_consensus_determined_version_assignments_in_prologue = true;
3423 }
3424
3425 if chain != Chain::Mainnet {
3427 cfg.feature_flags.consensus_choice = ConsensusChoice::Mysticeti;
3428 }
3429
3430 cfg.feature_flags.fresh_vm_on_framework_upgrade = true;
3432 }
3433 50 => {
3434 if chain != Chain::Mainnet {
3436 cfg.checkpoint_summary_version_specific_data = Some(1);
3437 cfg.min_checkpoint_interval_ms = Some(200);
3438 }
3439
3440 if chain != Chain::Testnet && chain != Chain::Mainnet {
3442 cfg.feature_flags
3443 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = true;
3444 }
3445
3446 cfg.feature_flags.mysticeti_num_leaders_per_round = Some(1);
3447
3448 cfg.max_deferral_rounds_for_congestion_control = Some(10);
3450 }
3451 51 => {
3452 cfg.random_beacon_dkg_version = Some(1);
3453
3454 if chain != Chain::Testnet && chain != Chain::Mainnet {
3455 cfg.feature_flags.enable_coin_deny_list_v2 = true;
3456 }
3457 }
3458 52 => {
3459 if chain != Chain::Mainnet {
3460 cfg.feature_flags.soft_bundle = true;
3461 cfg.max_soft_bundle_size = Some(5);
3462 }
3463
3464 cfg.config_read_setting_impl_cost_base = Some(100);
3465 cfg.config_read_setting_impl_cost_per_byte = Some(40);
3466
3467 if chain != Chain::Testnet && chain != Chain::Mainnet {
3469 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(100);
3470 cfg.feature_flags.per_object_congestion_control_mode =
3471 PerObjectCongestionControlMode::TotalTxCount;
3472 }
3473
3474 cfg.feature_flags.consensus_choice = ConsensusChoice::Mysticeti;
3476
3477 cfg.feature_flags.mysticeti_leader_scoring_and_schedule = true;
3479
3480 cfg.checkpoint_summary_version_specific_data = Some(1);
3482 cfg.min_checkpoint_interval_ms = Some(200);
3483
3484 if chain != Chain::Mainnet {
3486 cfg.feature_flags
3487 .record_consensus_determined_version_assignments_in_prologue = true;
3488 cfg.feature_flags
3489 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = true;
3490 }
3491 if chain != Chain::Mainnet {
3493 cfg.move_binary_format_version = Some(7);
3494 }
3495
3496 if chain != Chain::Testnet && chain != Chain::Mainnet {
3497 cfg.feature_flags.passkey_auth = true;
3498 }
3499 cfg.feature_flags.enable_coin_deny_list_v2 = true;
3500 }
3501 53 => {
3502 cfg.bridge_should_try_to_finalize_committee = Some(chain != Chain::Mainnet);
3504
3505 cfg.feature_flags
3507 .record_consensus_determined_version_assignments_in_prologue = true;
3508 cfg.feature_flags
3509 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = true;
3510
3511 if chain == Chain::Unknown {
3512 cfg.feature_flags.authority_capabilities_v2 = true;
3513 }
3514
3515 if chain != Chain::Mainnet {
3517 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(100);
3518 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(10);
3519 cfg.feature_flags.per_object_congestion_control_mode =
3520 PerObjectCongestionControlMode::TotalTxCount;
3521 }
3522
3523 cfg.bcs_per_byte_serialized_cost = Some(2);
3525 cfg.bcs_legacy_min_output_size_cost = Some(1);
3526 cfg.bcs_failure_cost = Some(52);
3527 cfg.debug_print_base_cost = Some(52);
3528 cfg.debug_print_stack_trace_base_cost = Some(52);
3529 cfg.hash_sha2_256_base_cost = Some(52);
3530 cfg.hash_sha2_256_per_byte_cost = Some(2);
3531 cfg.hash_sha2_256_legacy_min_input_len_cost = Some(1);
3532 cfg.hash_sha3_256_base_cost = Some(52);
3533 cfg.hash_sha3_256_per_byte_cost = Some(2);
3534 cfg.hash_sha3_256_legacy_min_input_len_cost = Some(1);
3535 cfg.type_name_get_base_cost = Some(52);
3536 cfg.type_name_get_per_byte_cost = Some(2);
3537 cfg.string_check_utf8_base_cost = Some(52);
3538 cfg.string_check_utf8_per_byte_cost = Some(2);
3539 cfg.string_is_char_boundary_base_cost = Some(52);
3540 cfg.string_sub_string_base_cost = Some(52);
3541 cfg.string_sub_string_per_byte_cost = Some(2);
3542 cfg.string_index_of_base_cost = Some(52);
3543 cfg.string_index_of_per_byte_pattern_cost = Some(2);
3544 cfg.string_index_of_per_byte_searched_cost = Some(2);
3545 cfg.vector_empty_base_cost = Some(52);
3546 cfg.vector_length_base_cost = Some(52);
3547 cfg.vector_push_back_base_cost = Some(52);
3548 cfg.vector_push_back_legacy_per_abstract_memory_unit_cost = Some(2);
3549 cfg.vector_borrow_base_cost = Some(52);
3550 cfg.vector_pop_back_base_cost = Some(52);
3551 cfg.vector_destroy_empty_base_cost = Some(52);
3552 cfg.vector_swap_base_cost = Some(52);
3553 }
3554 54 => {
3555 cfg.feature_flags.random_beacon = true;
3557 cfg.random_beacon_reduction_lower_bound = Some(1000);
3558 cfg.random_beacon_dkg_timeout_round = Some(3000);
3559 cfg.random_beacon_min_round_interval_ms = Some(500);
3560
3561 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(100);
3563 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(10);
3564 cfg.feature_flags.per_object_congestion_control_mode =
3565 PerObjectCongestionControlMode::TotalTxCount;
3566
3567 cfg.feature_flags.soft_bundle = true;
3569 cfg.max_soft_bundle_size = Some(5);
3570 }
3571 55 => {
3572 cfg.move_binary_format_version = Some(7);
3574
3575 cfg.consensus_max_transactions_in_block_bytes = Some(512 * 1024);
3577 cfg.consensus_max_num_transactions_in_block = Some(512);
3580
3581 cfg.feature_flags.rethrow_serialization_type_layout_errors = true;
3582 }
3583 56 => {
3584 if chain == Chain::Mainnet {
3585 cfg.feature_flags.bridge = true;
3586 }
3587 }
3588 57 => {
3589 cfg.random_beacon_reduction_lower_bound = Some(800);
3591 }
3592 58 => {
3593 if chain == Chain::Mainnet {
3594 cfg.bridge_should_try_to_finalize_committee = Some(true);
3595 }
3596
3597 if chain != Chain::Mainnet && chain != Chain::Testnet {
3598 cfg.feature_flags
3600 .consensus_distributed_vote_scoring_strategy = true;
3601 }
3602 }
3603 59 => {
3604 cfg.feature_flags.consensus_round_prober = true;
3606 }
3607 60 => {
3608 cfg.max_type_to_layout_nodes = Some(512);
3609 cfg.feature_flags.validate_identifier_inputs = true;
3610 }
3611 61 => {
3612 if chain != Chain::Mainnet {
3613 cfg.feature_flags
3615 .consensus_distributed_vote_scoring_strategy = true;
3616 }
3617 cfg.random_beacon_reduction_lower_bound = Some(700);
3619
3620 if chain != Chain::Mainnet && chain != Chain::Testnet {
3621 cfg.feature_flags.mysticeti_fastpath = true;
3623 }
3624 }
3625 62 => {
3626 cfg.feature_flags.relocate_event_module = true;
3627 }
3628 63 => {
3629 cfg.feature_flags.per_object_congestion_control_mode =
3630 PerObjectCongestionControlMode::TotalGasBudgetWithCap;
3631 cfg.gas_budget_based_txn_cost_cap_factor = Some(400_000);
3632 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(18_500_000);
3633 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(240_000_000);
3634 }
3635 64 => {
3636 cfg.feature_flags.per_object_congestion_control_mode =
3637 PerObjectCongestionControlMode::TotalTxCount;
3638 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(40);
3639 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(3);
3640 }
3641 65 => {
3642 cfg.feature_flags
3644 .consensus_distributed_vote_scoring_strategy = true;
3645 }
3646 66 => {
3647 if chain == Chain::Mainnet {
3648 cfg.feature_flags
3650 .consensus_distributed_vote_scoring_strategy = false;
3651 }
3652 }
3653 67 => {
3654 cfg.feature_flags
3656 .consensus_distributed_vote_scoring_strategy = true;
3657 }
3658 68 => {
3659 cfg.group_ops_bls12381_g1_to_uncompressed_g1_cost = Some(26);
3660 cfg.group_ops_bls12381_uncompressed_g1_to_g1_cost = Some(52);
3661 cfg.group_ops_bls12381_uncompressed_g1_sum_base_cost = Some(26);
3662 cfg.group_ops_bls12381_uncompressed_g1_sum_cost_per_term = Some(13);
3663 cfg.group_ops_bls12381_uncompressed_g1_sum_max_terms = Some(2000);
3664
3665 if chain != Chain::Mainnet && chain != Chain::Testnet {
3666 cfg.feature_flags.uncompressed_g1_group_elements = true;
3667 }
3668
3669 cfg.feature_flags.per_object_congestion_control_mode =
3670 PerObjectCongestionControlMode::TotalGasBudgetWithCap;
3671 cfg.gas_budget_based_txn_cost_cap_factor = Some(400_000);
3672 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(18_500_000);
3673 cfg.max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit =
3674 Some(3_700_000); cfg.max_txn_cost_overage_per_object_in_commit = Some(u64::MAX);
3676 cfg.gas_budget_based_txn_cost_absolute_cap_commit_count = Some(50);
3677
3678 cfg.random_beacon_reduction_lower_bound = Some(500);
3680
3681 cfg.feature_flags.disallow_new_modules_in_deps_only_packages = true;
3682 }
3683 69 => {
3684 cfg.consensus_voting_rounds = Some(40);
3686
3687 if chain != Chain::Mainnet && chain != Chain::Testnet {
3688 cfg.feature_flags.consensus_smart_ancestor_selection = true;
3690 }
3691
3692 if chain != Chain::Mainnet {
3693 cfg.feature_flags.uncompressed_g1_group_elements = true;
3694 }
3695 }
3696 70 => {
3697 if chain != Chain::Mainnet {
3698 cfg.feature_flags.consensus_smart_ancestor_selection = true;
3700 cfg.feature_flags
3702 .consensus_round_prober_probe_accepted_rounds = true;
3703 }
3704
3705 cfg.poseidon_bn254_cost_per_block = Some(388);
3706
3707 cfg.gas_model_version = Some(9);
3708 cfg.feature_flags.native_charging_v2 = true;
3709 cfg.bls12381_bls12381_min_sig_verify_cost_base = Some(44064);
3710 cfg.bls12381_bls12381_min_pk_verify_cost_base = Some(49282);
3711 cfg.ecdsa_k1_secp256k1_verify_keccak256_cost_base = Some(1470);
3712 cfg.ecdsa_k1_secp256k1_verify_sha256_cost_base = Some(1470);
3713 cfg.ecdsa_r1_secp256r1_verify_sha256_cost_base = Some(4225);
3714 cfg.ecdsa_r1_secp256r1_verify_keccak256_cost_base = Some(4225);
3715 cfg.ecvrf_ecvrf_verify_cost_base = Some(4848);
3716 cfg.ed25519_ed25519_verify_cost_base = Some(1802);
3717
3718 cfg.ecdsa_r1_ecrecover_keccak256_cost_base = Some(1173);
3720 cfg.ecdsa_r1_ecrecover_sha256_cost_base = Some(1173);
3721 cfg.ecdsa_k1_ecrecover_keccak256_cost_base = Some(500);
3722 cfg.ecdsa_k1_ecrecover_sha256_cost_base = Some(500);
3723
3724 cfg.groth16_prepare_verifying_key_bls12381_cost_base = Some(53838);
3725 cfg.groth16_prepare_verifying_key_bn254_cost_base = Some(82010);
3726 cfg.groth16_verify_groth16_proof_internal_bls12381_cost_base = Some(72090);
3727 cfg.groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input =
3728 Some(8213);
3729 cfg.groth16_verify_groth16_proof_internal_bn254_cost_base = Some(115502);
3730 cfg.groth16_verify_groth16_proof_internal_bn254_cost_per_public_input =
3731 Some(9484);
3732
3733 cfg.hash_keccak256_cost_base = Some(10);
3734 cfg.hash_blake2b256_cost_base = Some(10);
3735
3736 cfg.group_ops_bls12381_decode_scalar_cost = Some(7);
3738 cfg.group_ops_bls12381_decode_g1_cost = Some(2848);
3739 cfg.group_ops_bls12381_decode_g2_cost = Some(3770);
3740 cfg.group_ops_bls12381_decode_gt_cost = Some(3068);
3741
3742 cfg.group_ops_bls12381_scalar_add_cost = Some(10);
3743 cfg.group_ops_bls12381_g1_add_cost = Some(1556);
3744 cfg.group_ops_bls12381_g2_add_cost = Some(3048);
3745 cfg.group_ops_bls12381_gt_add_cost = Some(188);
3746
3747 cfg.group_ops_bls12381_scalar_sub_cost = Some(10);
3748 cfg.group_ops_bls12381_g1_sub_cost = Some(1550);
3749 cfg.group_ops_bls12381_g2_sub_cost = Some(3019);
3750 cfg.group_ops_bls12381_gt_sub_cost = Some(497);
3751
3752 cfg.group_ops_bls12381_scalar_mul_cost = Some(11);
3753 cfg.group_ops_bls12381_g1_mul_cost = Some(4842);
3754 cfg.group_ops_bls12381_g2_mul_cost = Some(9108);
3755 cfg.group_ops_bls12381_gt_mul_cost = Some(27490);
3756
3757 cfg.group_ops_bls12381_scalar_div_cost = Some(91);
3758 cfg.group_ops_bls12381_g1_div_cost = Some(5091);
3759 cfg.group_ops_bls12381_g2_div_cost = Some(9206);
3760 cfg.group_ops_bls12381_gt_div_cost = Some(27804);
3761
3762 cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(2962);
3763 cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(8688);
3764
3765 cfg.group_ops_bls12381_g1_msm_base_cost = Some(62648);
3766 cfg.group_ops_bls12381_g2_msm_base_cost = Some(131192);
3767 cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(1333);
3768 cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(3216);
3769
3770 cfg.group_ops_bls12381_uncompressed_g1_to_g1_cost = Some(677);
3771 cfg.group_ops_bls12381_g1_to_uncompressed_g1_cost = Some(2099);
3772 cfg.group_ops_bls12381_uncompressed_g1_sum_base_cost = Some(77);
3773 cfg.group_ops_bls12381_uncompressed_g1_sum_cost_per_term = Some(26);
3774
3775 cfg.group_ops_bls12381_pairing_cost = Some(26897);
3776 cfg.group_ops_bls12381_uncompressed_g1_sum_max_terms = Some(1200);
3777
3778 cfg.validator_validate_metadata_cost_base = Some(20000);
3779 }
3780 71 => {
3781 cfg.sip_45_consensus_amplification_threshold = Some(5);
3782
3783 cfg.allowed_txn_cost_overage_burst_per_object_in_commit = Some(185_000_000);
3785 }
3786 72 => {
3787 cfg.feature_flags.convert_type_argument_error = true;
3788
3789 cfg.max_tx_gas = Some(50_000_000_000_000);
3792 cfg.max_gas_price = Some(50_000_000_000);
3794
3795 cfg.feature_flags.variant_nodes = true;
3796 }
3797 73 => {
3798 cfg.use_object_per_epoch_marker_table_v2 = Some(true);
3800
3801 if chain != Chain::Mainnet && chain != Chain::Testnet {
3802 cfg.consensus_gc_depth = Some(60);
3805 }
3806
3807 if chain != Chain::Mainnet {
3808 cfg.feature_flags.consensus_zstd_compression = true;
3810 }
3811
3812 cfg.feature_flags.consensus_smart_ancestor_selection = true;
3814 cfg.feature_flags
3816 .consensus_round_prober_probe_accepted_rounds = true;
3817
3818 cfg.feature_flags.per_object_congestion_control_mode =
3820 PerObjectCongestionControlMode::TotalGasBudgetWithCap;
3821 cfg.gas_budget_based_txn_cost_cap_factor = Some(400_000);
3822 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(37_000_000);
3823 cfg.max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit =
3824 Some(7_400_000); cfg.max_txn_cost_overage_per_object_in_commit = Some(u64::MAX);
3826 cfg.gas_budget_based_txn_cost_absolute_cap_commit_count = Some(50);
3827 cfg.allowed_txn_cost_overage_burst_per_object_in_commit = Some(370_000_000);
3828 }
3829 74 => {
3830 if chain != Chain::Mainnet && chain != Chain::Testnet {
3832 cfg.feature_flags.enable_nitro_attestation = true;
3833 }
3834 cfg.nitro_attestation_parse_base_cost = Some(53 * 50);
3835 cfg.nitro_attestation_parse_cost_per_byte = Some(50);
3836 cfg.nitro_attestation_verify_base_cost = Some(49632 * 50);
3837 cfg.nitro_attestation_verify_cost_per_cert = Some(52369 * 50);
3838
3839 cfg.feature_flags.consensus_zstd_compression = true;
3841
3842 if chain != Chain::Mainnet && chain != Chain::Testnet {
3843 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
3844 }
3845 }
3846 75 => {
3847 if chain != Chain::Mainnet {
3848 cfg.feature_flags.passkey_auth = true;
3849 }
3850 }
3851 76 => {
3852 if chain != Chain::Mainnet && chain != Chain::Testnet {
3853 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
3854 cfg.consensus_commit_rate_estimation_window_size = Some(10);
3855 }
3856 cfg.feature_flags.minimize_child_object_mutations = true;
3857
3858 if chain != Chain::Mainnet {
3859 cfg.feature_flags.accept_passkey_in_multisig = true;
3860 }
3861 }
3862 77 => {
3863 cfg.feature_flags.uncompressed_g1_group_elements = true;
3864
3865 if chain != Chain::Mainnet {
3866 cfg.consensus_gc_depth = Some(60);
3867 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
3868 }
3869 }
3870 78 => {
3871 cfg.feature_flags.move_native_context = true;
3872 cfg.tx_context_fresh_id_cost_base = Some(52);
3873 cfg.tx_context_sender_cost_base = Some(30);
3874 cfg.tx_context_epoch_cost_base = Some(30);
3875 cfg.tx_context_epoch_timestamp_ms_cost_base = Some(30);
3876 cfg.tx_context_sponsor_cost_base = Some(30);
3877 cfg.tx_context_gas_price_cost_base = Some(30);
3878 cfg.tx_context_gas_budget_cost_base = Some(30);
3879 cfg.tx_context_ids_created_cost_base = Some(30);
3880 cfg.tx_context_replace_cost_base = Some(30);
3881 cfg.gas_model_version = Some(10);
3882
3883 if chain != Chain::Mainnet {
3884 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
3885 cfg.consensus_commit_rate_estimation_window_size = Some(10);
3886
3887 cfg.feature_flags.per_object_congestion_control_mode =
3889 PerObjectCongestionControlMode::ExecutionTimeEstimate(
3890 ExecutionTimeEstimateParams {
3891 target_utilization: 30,
3892 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
3894 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
3896 stored_observations_limit: u64::MAX,
3897 stake_weighted_median_threshold: 0,
3898 default_none_duration_for_new_keys: false,
3899 observations_chunk_size: None,
3900 },
3901 );
3902 }
3903 }
3904 79 => {
3905 if chain != Chain::Mainnet {
3906 cfg.feature_flags.consensus_median_based_commit_timestamp = true;
3907
3908 cfg.consensus_bad_nodes_stake_threshold = Some(30);
3911
3912 cfg.feature_flags.consensus_batched_block_sync = true;
3913
3914 cfg.feature_flags.enable_nitro_attestation = true
3916 }
3917 cfg.feature_flags.normalize_ptb_arguments = true;
3918
3919 cfg.consensus_gc_depth = Some(60);
3920 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
3921 }
3922 80 => {
3923 cfg.max_ptb_value_size = Some(1024 * 1024);
3924 }
3925 81 => {
3926 cfg.feature_flags.consensus_median_based_commit_timestamp = true;
3927 cfg.feature_flags.enforce_checkpoint_timestamp_monotonicity = true;
3928 cfg.consensus_bad_nodes_stake_threshold = Some(30)
3929 }
3930 82 => {
3931 cfg.feature_flags.max_ptb_value_size_v2 = true;
3932 }
3933 83 => {
3934 if chain == Chain::Mainnet {
3935 let aliased: [u8; 32] = Hex::decode(
3937 "0x0b2da327ba6a4cacbe75dddd50e6e8bbf81d6496e92d66af9154c61c77f7332f",
3938 )
3939 .unwrap()
3940 .try_into()
3941 .unwrap();
3942
3943 cfg.aliased_addresses.push(AliasedAddress {
3945 original: Hex::decode("0xcd8962dad278d8b50fa0f9eb0186bfa4cbdecc6d59377214c88d0286a0ac9562").unwrap().try_into().unwrap(),
3946 aliased,
3947 allowed_tx_digests: vec![
3948 Base58::decode("B2eGLFoMHgj93Ni8dAJBfqGzo8EWSTLBesZzhEpTPA4").unwrap().try_into().unwrap(),
3949 ],
3950 });
3951
3952 cfg.aliased_addresses.push(AliasedAddress {
3953 original: Hex::decode("0xe28b50cef1d633ea43d3296a3f6b67ff0312a5f1a99f0af753c85b8b5de8ff06").unwrap().try_into().unwrap(),
3954 aliased,
3955 allowed_tx_digests: vec![
3956 Base58::decode("J4QqSAgp7VrQtQpMy5wDX4QGsCSEZu3U5KuDAkbESAge").unwrap().try_into().unwrap(),
3957 ],
3958 });
3959 }
3960
3961 if chain != Chain::Mainnet {
3964 cfg.feature_flags.resolve_type_input_ids_to_defining_id = true;
3965 cfg.transfer_party_transfer_internal_cost_base = Some(52);
3966
3967 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
3969 cfg.consensus_commit_rate_estimation_window_size = Some(10);
3970 cfg.feature_flags.per_object_congestion_control_mode =
3971 PerObjectCongestionControlMode::ExecutionTimeEstimate(
3972 ExecutionTimeEstimateParams {
3973 target_utilization: 30,
3974 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
3976 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
3978 stored_observations_limit: u64::MAX,
3979 stake_weighted_median_threshold: 0,
3980 default_none_duration_for_new_keys: false,
3981 observations_chunk_size: None,
3982 },
3983 );
3984
3985 cfg.feature_flags.consensus_batched_block_sync = true;
3987
3988 cfg.feature_flags.enable_nitro_attestation_upgraded_parsing = true;
3991 cfg.feature_flags.enable_nitro_attestation = true;
3992 }
3993 }
3994 84 => {
3995 if chain == Chain::Mainnet {
3996 cfg.feature_flags.resolve_type_input_ids_to_defining_id = true;
3997 cfg.transfer_party_transfer_internal_cost_base = Some(52);
3998
3999 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
4001 cfg.consensus_commit_rate_estimation_window_size = Some(10);
4002 cfg.feature_flags.per_object_congestion_control_mode =
4003 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4004 ExecutionTimeEstimateParams {
4005 target_utilization: 30,
4006 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4008 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4010 stored_observations_limit: u64::MAX,
4011 stake_weighted_median_threshold: 0,
4012 default_none_duration_for_new_keys: false,
4013 observations_chunk_size: None,
4014 },
4015 );
4016
4017 cfg.feature_flags.consensus_batched_block_sync = true;
4019
4020 cfg.feature_flags.enable_nitro_attestation_upgraded_parsing = true;
4023 cfg.feature_flags.enable_nitro_attestation = true;
4024 }
4025
4026 cfg.feature_flags.per_object_congestion_control_mode =
4028 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4029 ExecutionTimeEstimateParams {
4030 target_utilization: 30,
4031 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4033 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4035 stored_observations_limit: 20,
4036 stake_weighted_median_threshold: 0,
4037 default_none_duration_for_new_keys: false,
4038 observations_chunk_size: None,
4039 },
4040 );
4041 cfg.feature_flags.allow_unbounded_system_objects = true;
4042 }
4043 85 => {
4044 if chain != Chain::Mainnet && chain != Chain::Testnet {
4045 cfg.feature_flags.enable_party_transfer = true;
4046 }
4047
4048 cfg.feature_flags
4049 .record_consensus_determined_version_assignments_in_prologue_v2 = true;
4050 cfg.feature_flags.disallow_self_identifier = true;
4051 cfg.feature_flags.per_object_congestion_control_mode =
4052 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4053 ExecutionTimeEstimateParams {
4054 target_utilization: 50,
4055 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4057 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4059 stored_observations_limit: 20,
4060 stake_weighted_median_threshold: 0,
4061 default_none_duration_for_new_keys: false,
4062 observations_chunk_size: None,
4063 },
4064 );
4065 }
4066 86 => {
4067 cfg.feature_flags.type_tags_in_object_runtime = true;
4068 cfg.max_move_enum_variants = Some(move_core_types::VARIANT_COUNT_MAX);
4069
4070 cfg.feature_flags.per_object_congestion_control_mode =
4072 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4073 ExecutionTimeEstimateParams {
4074 target_utilization: 50,
4075 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4077 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4079 stored_observations_limit: 20,
4080 stake_weighted_median_threshold: 3334,
4081 default_none_duration_for_new_keys: false,
4082 observations_chunk_size: None,
4083 },
4084 );
4085 if chain != Chain::Mainnet {
4087 cfg.feature_flags.enable_party_transfer = true;
4088 }
4089 }
4090 87 => {
4091 if chain == Chain::Mainnet {
4092 cfg.feature_flags.record_time_estimate_processed = true;
4093 }
4094 cfg.feature_flags.better_adapter_type_resolution_errors = true;
4095 }
4096 88 => {
4097 cfg.feature_flags.record_time_estimate_processed = true;
4098 cfg.tx_context_rgp_cost_base = Some(30);
4099 cfg.feature_flags
4100 .ignore_execution_time_observations_after_certs_closed = true;
4101
4102 cfg.feature_flags.per_object_congestion_control_mode =
4105 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4106 ExecutionTimeEstimateParams {
4107 target_utilization: 50,
4108 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4110 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4112 stored_observations_limit: 20,
4113 stake_weighted_median_threshold: 3334,
4114 default_none_duration_for_new_keys: true,
4115 observations_chunk_size: None,
4116 },
4117 );
4118 }
4119 89 => {
4120 cfg.feature_flags.dependency_linkage_error = true;
4121 cfg.feature_flags.additional_multisig_checks = true;
4122 }
4123 90 => {
4124 cfg.max_gas_price_rgp_factor_for_aborted_transactions = Some(100);
4126 cfg.feature_flags.debug_fatal_on_move_invariant_violation = true;
4127 cfg.feature_flags.additional_consensus_digest_indirect_state = true;
4128 cfg.feature_flags.accept_passkey_in_multisig = true;
4129 cfg.feature_flags.passkey_auth = true;
4130 cfg.feature_flags.check_for_init_during_upgrade = true;
4131
4132 if chain != Chain::Mainnet {
4134 cfg.feature_flags.mysticeti_fastpath = true;
4135 }
4136 }
4137 91 => {
4138 cfg.feature_flags.per_command_shared_object_transfer_rules = true;
4139 }
4140 92 => {
4141 cfg.feature_flags.per_command_shared_object_transfer_rules = false;
4142 }
4143 93 => {
4144 cfg.feature_flags
4145 .consensus_checkpoint_signature_key_includes_digest = true;
4146 }
4147 94 => {
4148 cfg.feature_flags.per_object_congestion_control_mode =
4150 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4151 ExecutionTimeEstimateParams {
4152 target_utilization: 50,
4153 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4155 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4157 stored_observations_limit: 18,
4158 stake_weighted_median_threshold: 3334,
4159 default_none_duration_for_new_keys: true,
4160 observations_chunk_size: None,
4161 },
4162 );
4163
4164 cfg.feature_flags.enable_party_transfer = true;
4166 }
4167 95 => {
4168 cfg.type_name_id_base_cost = Some(52);
4169
4170 cfg.max_transactions_per_checkpoint = Some(20_000);
4172 }
4173 96 => {
4174 if chain != Chain::Mainnet && chain != Chain::Testnet {
4176 cfg.feature_flags
4177 .include_checkpoint_artifacts_digest_in_summary = true;
4178 }
4179 cfg.feature_flags.correct_gas_payment_limit_check = true;
4180 cfg.feature_flags.authority_capabilities_v2 = true;
4181 cfg.feature_flags.use_mfp_txns_in_load_initial_object_debts = true;
4182 cfg.feature_flags.cancel_for_failed_dkg_early = true;
4183 cfg.feature_flags.enable_coin_registry = true;
4184
4185 cfg.feature_flags.mysticeti_fastpath = true;
4187 }
4188 97 => {
4189 cfg.feature_flags.additional_borrow_checks = true;
4190 }
4191 98 => {
4192 cfg.event_emit_auth_stream_cost = Some(52);
4193 cfg.feature_flags.better_loader_errors = true;
4194 cfg.feature_flags.generate_df_type_layouts = true;
4195 }
4196 99 => {
4197 cfg.feature_flags.use_new_commit_handler = true;
4198 }
4199 100 => {
4200 cfg.feature_flags.private_generics_verifier_v2 = true;
4201 }
4202 101 => {
4203 cfg.feature_flags.create_root_accumulator_object = true;
4204 cfg.max_updates_per_settlement_txn = Some(100);
4205 if chain != Chain::Mainnet {
4206 cfg.feature_flags.enable_poseidon = true;
4207 }
4208 }
4209 102 => {
4210 cfg.feature_flags.per_object_congestion_control_mode =
4214 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4215 ExecutionTimeEstimateParams {
4216 target_utilization: 50,
4217 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4219 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4221 stored_observations_limit: 180,
4222 stake_weighted_median_threshold: 3334,
4223 default_none_duration_for_new_keys: true,
4224 observations_chunk_size: Some(18),
4225 },
4226 );
4227 cfg.feature_flags.deprecate_global_storage_ops = true;
4228 }
4229 103 => {}
4230 104 => {
4231 cfg.translation_per_command_base_charge = Some(1);
4232 cfg.translation_per_input_base_charge = Some(1);
4233 cfg.translation_pure_input_per_byte_charge = Some(1);
4234 cfg.translation_per_type_node_charge = Some(1);
4235 cfg.translation_per_reference_node_charge = Some(1);
4236 cfg.translation_per_linkage_entry_charge = Some(10);
4237 cfg.gas_model_version = Some(11);
4238 cfg.feature_flags.abstract_size_in_object_runtime = true;
4239 cfg.feature_flags.object_runtime_charge_cache_load_gas = true;
4240 cfg.dynamic_field_hash_type_and_key_cost_base = Some(52);
4241 cfg.dynamic_field_add_child_object_cost_base = Some(52);
4242 cfg.dynamic_field_add_child_object_value_cost_per_byte = Some(1);
4243 cfg.dynamic_field_borrow_child_object_cost_base = Some(52);
4244 cfg.dynamic_field_borrow_child_object_child_ref_cost_per_byte = Some(1);
4245 cfg.dynamic_field_remove_child_object_cost_base = Some(52);
4246 cfg.dynamic_field_remove_child_object_child_cost_per_byte = Some(1);
4247 cfg.dynamic_field_has_child_object_cost_base = Some(52);
4248 cfg.dynamic_field_has_child_object_with_ty_cost_base = Some(52);
4249 cfg.feature_flags.enable_ptb_execution_v2 = true;
4250
4251 cfg.poseidon_bn254_cost_base = Some(260);
4252
4253 cfg.feature_flags.consensus_skip_gced_accept_votes = true;
4254
4255 if chain != Chain::Mainnet {
4256 cfg.feature_flags
4257 .enable_nitro_attestation_all_nonzero_pcrs_parsing = true;
4258 }
4259
4260 cfg.feature_flags
4261 .include_cancelled_randomness_txns_in_prologue = true;
4262 }
4263 105 => {
4264 cfg.feature_flags.enable_multi_epoch_transaction_expiration = true;
4265 cfg.feature_flags.disable_preconsensus_locking = true;
4266
4267 if chain != Chain::Mainnet {
4268 cfg.feature_flags
4269 .enable_nitro_attestation_always_include_required_pcrs_parsing = true;
4270 }
4271 }
4272 106 => {
4273 cfg.accumulator_object_storage_cost = Some(7600);
4275
4276 if chain != Chain::Mainnet && chain != Chain::Testnet {
4277 cfg.feature_flags.enable_accumulators = true;
4278 cfg.feature_flags.enable_address_balance_gas_payments = true;
4279 cfg.feature_flags.enable_authenticated_event_streams = true;
4280 cfg.feature_flags.enable_object_funds_withdraw = true;
4281 }
4282 }
4283 107 => {
4284 cfg.feature_flags
4285 .consensus_skip_gced_blocks_in_direct_finalization = true;
4286
4287 if in_integration_test() {
4289 cfg.consensus_gc_depth = Some(6);
4290 cfg.consensus_max_num_transactions_in_block = Some(8);
4291 }
4292 }
4293 108 => {
4294 cfg.feature_flags.gas_rounding_halve_digits = true;
4295 cfg.feature_flags.flexible_tx_context_positions = true;
4296 cfg.feature_flags.disable_entry_point_signature_check = true;
4297
4298 if chain != Chain::Mainnet {
4299 cfg.feature_flags.address_aliases = true;
4300
4301 cfg.feature_flags.enable_accumulators = true;
4302 cfg.feature_flags.enable_address_balance_gas_payments = true;
4303 }
4304
4305 cfg.feature_flags.enable_poseidon = true;
4306 }
4307 109 => {
4308 cfg.binary_variant_handles = Some(1024);
4309 cfg.binary_variant_instantiation_handles = Some(1024);
4310 cfg.feature_flags.restrict_hot_or_not_entry_functions = true;
4311 }
4312 110 => {
4313 cfg.feature_flags
4314 .enable_nitro_attestation_all_nonzero_pcrs_parsing = true;
4315 cfg.feature_flags
4316 .enable_nitro_attestation_always_include_required_pcrs_parsing = true;
4317 if chain != Chain::Mainnet && chain != Chain::Testnet {
4318 cfg.feature_flags.split_checkpoints_in_consensus_handler = true;
4319 }
4320 cfg.feature_flags.validate_zklogin_public_identifier = true;
4321 cfg.feature_flags.fix_checkpoint_signature_mapping = true;
4322 cfg.feature_flags
4323 .consensus_always_accept_system_transactions = true;
4324 if chain != Chain::Mainnet {
4325 cfg.feature_flags.enable_object_funds_withdraw = true;
4326 }
4327 }
4328 111 => {
4329 cfg.feature_flags.validator_metadata_verify_v2 = true;
4330 }
4331 112 => {
4332 cfg.group_ops_ristretto_decode_scalar_cost = Some(7);
4333 cfg.group_ops_ristretto_decode_point_cost = Some(200);
4334 cfg.group_ops_ristretto_scalar_add_cost = Some(10);
4335 cfg.group_ops_ristretto_point_add_cost = Some(500);
4336 cfg.group_ops_ristretto_scalar_sub_cost = Some(10);
4337 cfg.group_ops_ristretto_point_sub_cost = Some(500);
4338 cfg.group_ops_ristretto_scalar_mul_cost = Some(11);
4339 cfg.group_ops_ristretto_point_mul_cost = Some(1200);
4340 cfg.group_ops_ristretto_scalar_div_cost = Some(151);
4341 cfg.group_ops_ristretto_point_div_cost = Some(2500);
4342
4343 if chain != Chain::Mainnet && chain != Chain::Testnet {
4344 cfg.feature_flags.enable_ristretto255_group_ops = true;
4345 }
4346 }
4347 113 => {
4348 cfg.feature_flags.address_balance_gas_check_rgp_at_signing = true;
4349 if chain != Chain::Mainnet && chain != Chain::Testnet {
4350 cfg.feature_flags.defer_unpaid_amplification = true;
4351 }
4352 }
4353 114 => {
4354 cfg.feature_flags.randomize_checkpoint_tx_limit_in_tests = true;
4355 cfg.feature_flags.address_balance_gas_reject_gas_coin_arg = true;
4356 if chain != Chain::Mainnet {
4357 cfg.feature_flags.split_checkpoints_in_consensus_handler = true;
4358 cfg.feature_flags.enable_authenticated_event_streams = true;
4359 cfg.feature_flags
4360 .include_checkpoint_artifacts_digest_in_summary = true;
4361 }
4362 }
4363 115 => {
4364 cfg.feature_flags.normalize_depth_formula = true;
4365 }
4366 116 => {
4367 cfg.feature_flags.gasless_transaction_drop_safety = true;
4368 cfg.feature_flags.address_aliases = true;
4369 cfg.feature_flags.relax_valid_during_for_owned_inputs = true;
4370 cfg.feature_flags.defer_unpaid_amplification = false;
4372 cfg.feature_flags.enable_display_registry = true;
4373 }
4374 117 => {}
4375 118 => {
4376 cfg.feature_flags.use_coin_party_owner = true;
4377 }
4378 119 => {
4379 cfg.execution_version = Some(4);
4381 cfg.feature_flags.address_balance_gas_reject_gas_coin_arg = false;
4382 cfg.feature_flags.merge_randomness_into_checkpoint = true;
4383 if chain != Chain::Mainnet {
4384 cfg.feature_flags.enable_gasless = true;
4385 cfg.gasless_max_computation_units = Some(50_000);
4386 cfg.gasless_allowed_token_types = Some(vec![]);
4387 cfg.feature_flags.enable_coin_reservation_obj_refs = true;
4388 cfg.feature_flags
4389 .convert_withdrawal_compatibility_ptb_arguments = true;
4390 }
4391 cfg.gasless_max_unused_inputs = Some(1);
4392 cfg.gasless_max_pure_input_bytes = Some(32);
4393 if chain == Chain::Testnet {
4394 cfg.gasless_allowed_token_types = Some(vec![(TESTNET_USDC.to_string(), 0)]);
4395 }
4396 cfg.transfer_receive_object_cost_per_byte = Some(1);
4397 cfg.transfer_receive_object_type_cost_per_byte = Some(2);
4398 }
4399 120 => {
4400 cfg.feature_flags.disallow_jump_orphans = true;
4401 }
4402 121 => {
4403 if chain != Chain::Mainnet {
4405 cfg.feature_flags.defer_unpaid_amplification = true;
4406 cfg.gasless_max_tps = Some(50);
4407 }
4408 cfg.feature_flags
4409 .early_return_receive_object_mismatched_type = true;
4410 }
4411 122 => {
4412 cfg.feature_flags.defer_unpaid_amplification = true;
4414 cfg.verify_bulletproofs_ristretto255_base_cost = Some(30000);
4416 cfg.verify_bulletproofs_ristretto255_cost_per_bit_and_commitment = Some(6500);
4417 if chain != Chain::Mainnet && chain != Chain::Testnet {
4418 cfg.feature_flags.enable_verify_bulletproofs_ristretto255 = true;
4419 }
4420 cfg.feature_flags.gasless_verify_remaining_balance = true;
4421 cfg.include_special_package_amendments = match chain {
4422 Chain::Mainnet => Some(MAINNET_LINKAGE_AMENDMENTS.clone()),
4423 Chain::Testnet => Some(TESTNET_LINKAGE_AMENDMENTS.clone()),
4424 Chain::Unknown => None,
4425 };
4426 cfg.gasless_max_tx_size_bytes = Some(16 * 1024);
4427 cfg.gasless_max_tps = Some(300);
4428 cfg.gasless_max_computation_units = Some(5_000);
4429 }
4430 123 => {
4431 cfg.gas_model_version = Some(13);
4432 }
4433 124 => {
4434 if chain != Chain::Mainnet && chain != Chain::Testnet {
4435 cfg.feature_flags.timestamp_based_epoch_close = true;
4436 }
4437 cfg.gas_model_version = Some(14);
4438 cfg.feature_flags.limit_groth16_pvk_inputs = true;
4439
4440 cfg.feature_flags.enable_accumulators = true;
4446 cfg.feature_flags.enable_address_balance_gas_payments = true;
4447 cfg.feature_flags.enable_authenticated_event_streams = true;
4448 cfg.feature_flags.enable_coin_reservation_obj_refs = true;
4449 cfg.feature_flags.enable_object_funds_withdraw = true;
4450 cfg.feature_flags
4451 .convert_withdrawal_compatibility_ptb_arguments = true;
4452 cfg.feature_flags.split_checkpoints_in_consensus_handler = true;
4453 cfg.feature_flags
4454 .include_checkpoint_artifacts_digest_in_summary = true;
4455 cfg.feature_flags.enable_gasless = true;
4456
4457 if chain == Chain::Mainnet {
4462 cfg.gasless_allowed_token_types = Some(vec![
4463 (MAINNET_USDC.to_string(), 10_000),
4464 (MAINNET_USDSUI.to_string(), 10_000),
4465 (MAINNET_SUI_USDE.to_string(), 10_000),
4466 (MAINNET_USDY.to_string(), 10_000),
4467 (MAINNET_FDUSD.to_string(), 10_000),
4468 (MAINNET_AUSD.to_string(), 10_000),
4469 (MAINNET_USDB.to_string(), 10_000),
4470 ]);
4471 }
4472 }
4473 125 => {
4474 cfg.feature_flags.granular_post_execution_checks = true;
4475 if chain != Chain::Mainnet {
4476 cfg.feature_flags.timestamp_based_epoch_close = true;
4477 }
4478 }
4479 126 => {
4480 cfg.feature_flags.early_exit_on_iffw = true;
4481 }
4482 127 => {
4483 cfg.feature_flags.always_advance_dkg_to_resolution = true;
4484
4485 cfg.verify_bulletproofs_ristretto255_base_cost = Some(23866);
4486 cfg.verify_bulletproofs_ristretto255_cost_per_bit_and_commitment = Some(1324);
4487 cfg.group_ops_ristretto_decode_scalar_cost = Some(5);
4488 cfg.group_ops_ristretto_decode_point_cost = Some(216);
4489 cfg.group_ops_ristretto_scalar_add_cost = Some(2);
4490 cfg.group_ops_ristretto_point_add_cost = Some(8);
4491 cfg.group_ops_ristretto_scalar_sub_cost = Some(2);
4492 cfg.group_ops_ristretto_point_sub_cost = Some(8);
4493 cfg.group_ops_ristretto_scalar_mul_cost = Some(5);
4494 cfg.group_ops_ristretto_point_mul_cost = Some(1763);
4495 cfg.group_ops_ristretto_scalar_div_cost = Some(557);
4496 cfg.group_ops_ristretto_point_div_cost = Some(2244);
4497
4498 if chain != Chain::Mainnet {
4499 cfg.feature_flags.enable_ristretto255_group_ops = true;
4500 cfg.feature_flags.enable_verify_bulletproofs_ristretto255 = true;
4501 }
4502
4503 cfg.feature_flags.timestamp_based_epoch_close = true;
4504 }
4505 128 => {
4506 cfg.max_generic_instantiation_type_nodes_per_function = Some(10_000);
4507 cfg.max_generic_instantiation_type_nodes_per_module = Some(500_000);
4508 cfg.binary_enum_defs = Some(200);
4509 cfg.binary_enum_def_instantiations = Some(100);
4510 }
4511 129 => {
4512 cfg.feature_flags.enable_unified_linkage = true;
4513 }
4514 130 => {
4515 cfg.feature_flags.record_net_unsettled_object_withdraws = true;
4516 cfg.feature_flags.enable_init_on_upgrade = true;
4517 cfg.epoch_close_deadline_ms = Some(120_000);
4518 cfg.scratch_add_cost_base = Some(13);
4519 cfg.scratch_read_cost_base = Some(13);
4520 cfg.scratch_read_value_cost = Some(1);
4521 cfg.scratch_remove_cost_base = Some(13);
4522 cfg.scratch_exists_cost_base = Some(13);
4523 cfg.scratch_exists_with_type_cost_base = Some(13);
4524 cfg.scratch_exists_with_type_type_cost = Some(1);
4525 let max_commands = cfg.max_programmable_tx_commands() as u64;
4526 cfg.max_scratch_pad_size = Some(16 * max_commands);
4527 if chain != Chain::Mainnet && chain != Chain::Testnet {
4529 cfg.feature_flags.zklogin_circuit_mode = 1;
4530 }
4531 }
4532 _ => panic!("unsupported version {:?}", version),
4543 }
4544 }
4545
4546 cfg
4547 }
4548
4549 pub fn apply_seeded_test_overrides(&mut self, seed: &[u8; 32]) {
4550 if !self.feature_flags.randomize_checkpoint_tx_limit_in_tests
4551 || !self.feature_flags.split_checkpoints_in_consensus_handler
4552 {
4553 return;
4554 }
4555
4556 if !mysten_common::in_test_configuration() {
4557 return;
4558 }
4559
4560 use rand::{Rng, SeedableRng, rngs::StdRng};
4561 let mut rng = StdRng::from_seed(*seed);
4562 let max_txns = rng.gen_range(10..=100u64);
4563 info!("seeded test override: max_transactions_per_checkpoint = {max_txns}");
4564 self.max_transactions_per_checkpoint = Some(max_txns);
4565 }
4566
4567 pub fn verifier_config(&self, signing_limits: Option<(usize, usize, usize)>) -> VerifierConfig {
4573 let (
4574 max_back_edges_per_function,
4575 max_back_edges_per_module,
4576 sanity_check_with_regex_reference_safety,
4577 ) = if let Some((
4578 max_back_edges_per_function,
4579 max_back_edges_per_module,
4580 sanity_check_with_regex_reference_safety,
4581 )) = signing_limits
4582 {
4583 (
4584 Some(max_back_edges_per_function),
4585 Some(max_back_edges_per_module),
4586 Some(sanity_check_with_regex_reference_safety),
4587 )
4588 } else {
4589 (None, None, None)
4590 };
4591
4592 let additional_borrow_checks = if signing_limits.is_some() {
4593 true
4595 } else {
4596 self.additional_borrow_checks()
4597 };
4598 let deprecate_global_storage_ops = if signing_limits.is_some() {
4599 true
4601 } else {
4602 self.deprecate_global_storage_ops()
4603 };
4604
4605 VerifierConfig {
4606 max_loop_depth: Some(self.max_loop_depth() as usize),
4607 max_generic_instantiation_length: Some(self.max_generic_instantiation_length() as usize),
4608 max_function_parameters: Some(self.max_function_parameters() as usize),
4609 max_basic_blocks: Some(self.max_basic_blocks() as usize),
4610 max_value_stack_size: self.max_value_stack_size() as usize,
4611 max_type_nodes: Some(self.max_type_nodes() as usize),
4612 max_generic_instantiation_type_nodes_per_function: self
4613 .max_generic_instantiation_type_nodes_per_function_as_option()
4614 .map(|v| v as usize),
4615 max_generic_instantiation_type_nodes_per_module: self
4616 .max_generic_instantiation_type_nodes_per_module_as_option()
4617 .map(|v| v as usize),
4618 max_push_size: Some(self.max_push_size() as usize),
4619 max_dependency_depth: Some(self.max_dependency_depth() as usize),
4620 max_fields_in_struct: Some(self.max_fields_in_struct() as usize),
4621 max_function_definitions: Some(self.max_function_definitions() as usize),
4622 max_data_definitions: Some(self.max_struct_definitions() as usize),
4623 max_constant_vector_len: Some(self.max_move_vector_len()),
4624 max_back_edges_per_function,
4625 max_back_edges_per_module,
4626 max_basic_blocks_in_script: None,
4627 max_identifier_len: self.max_move_identifier_len_as_option(), disallow_self_identifier: self.feature_flags.disallow_self_identifier,
4629 allow_receiving_object_id: self.allow_receiving_object_id(),
4630 reject_mutable_random_on_entry_functions: self
4631 .reject_mutable_random_on_entry_functions(),
4632 bytecode_version: self.move_binary_format_version(),
4633 max_variants_in_enum: self.max_move_enum_variants_as_option(),
4634 additional_borrow_checks,
4635 better_loader_errors: self.better_loader_errors(),
4636 private_generics_verifier_v2: self.private_generics_verifier_v2(),
4637 sanity_check_with_regex_reference_safety: sanity_check_with_regex_reference_safety
4638 .map(|limit| limit as u128),
4639 deprecate_global_storage_ops,
4640 disable_entry_point_signature_check: self.disable_entry_point_signature_check(),
4641 switch_to_regex_reference_safety: false,
4642 disallow_jump_orphans: self.disallow_jump_orphans(),
4643 }
4644 }
4645
4646 pub fn binary_config(
4647 &self,
4648 override_deprecate_global_storage_ops_during_deserialization: Option<bool>,
4649 ) -> BinaryConfig {
4650 let deprecate_global_storage_ops =
4651 override_deprecate_global_storage_ops_during_deserialization
4652 .unwrap_or_else(|| self.deprecate_global_storage_ops());
4653 BinaryConfig::new(
4654 self.move_binary_format_version(),
4655 self.min_move_binary_format_version_as_option()
4656 .unwrap_or(VERSION_1),
4657 self.no_extraneous_module_bytes(),
4658 deprecate_global_storage_ops,
4659 TableConfig {
4660 module_handles: self.binary_module_handles_as_option().unwrap_or(u16::MAX),
4661 datatype_handles: self.binary_struct_handles_as_option().unwrap_or(u16::MAX),
4662 function_handles: self.binary_function_handles_as_option().unwrap_or(u16::MAX),
4663 function_instantiations: self
4664 .binary_function_instantiations_as_option()
4665 .unwrap_or(u16::MAX),
4666 signatures: self.binary_signatures_as_option().unwrap_or(u16::MAX),
4667 constant_pool: self.binary_constant_pool_as_option().unwrap_or(u16::MAX),
4668 identifiers: self.binary_identifiers_as_option().unwrap_or(u16::MAX),
4669 address_identifiers: self
4670 .binary_address_identifiers_as_option()
4671 .unwrap_or(u16::MAX),
4672 struct_defs: self.binary_struct_defs_as_option().unwrap_or(u16::MAX),
4673 struct_def_instantiations: self
4674 .binary_struct_def_instantiations_as_option()
4675 .unwrap_or(u16::MAX),
4676 function_defs: self.binary_function_defs_as_option().unwrap_or(u16::MAX),
4677 field_handles: self.binary_field_handles_as_option().unwrap_or(u16::MAX),
4678 field_instantiations: self
4679 .binary_field_instantiations_as_option()
4680 .unwrap_or(u16::MAX),
4681 friend_decls: self.binary_friend_decls_as_option().unwrap_or(u16::MAX),
4682 enum_defs: self.binary_enum_defs_as_option().unwrap_or(u16::MAX),
4683 enum_def_instantiations: self
4684 .binary_enum_def_instantiations_as_option()
4685 .unwrap_or(u16::MAX),
4686 variant_handles: self.binary_variant_handles_as_option().unwrap_or(u16::MAX),
4687 variant_instantiation_handles: self
4688 .binary_variant_instantiation_handles_as_option()
4689 .unwrap_or(u16::MAX),
4690 },
4691 )
4692 }
4693
4694 #[cfg(not(msim))]
4698 pub fn apply_overrides_for_testing(
4699 override_fn: impl Fn(ProtocolVersion, Self) -> Self + Send + Sync + 'static,
4700 ) -> OverrideGuard {
4701 let mut cur = CONFIG_OVERRIDE.lock().unwrap();
4702 assert!(cur.is_none(), "config override already present");
4703 *cur = Some(Box::new(override_fn));
4704 OverrideGuard
4705 }
4706
4707 #[cfg(msim)]
4711 pub fn apply_overrides_for_testing(
4712 override_fn: impl Fn(ProtocolVersion, Self) -> Self + Send + 'static,
4713 ) -> OverrideGuard {
4714 CONFIG_OVERRIDE.with(|ovr| {
4715 let mut cur = ovr.borrow_mut();
4716 assert!(cur.is_none(), "config override already present");
4717 *cur = Some(Box::new(override_fn));
4718 OverrideGuard
4719 })
4720 }
4721
4722 #[cfg(not(msim))]
4723 fn apply_config_override(version: ProtocolVersion, mut ret: Self) -> Self {
4724 if let Some(override_fn) = CONFIG_OVERRIDE.lock().unwrap().as_ref() {
4725 warn!(
4726 "overriding ProtocolConfig settings with custom settings (you should not see this log outside of tests)"
4727 );
4728 ret = override_fn(version, ret);
4729 }
4730 ret
4731 }
4732
4733 #[cfg(msim)]
4734 fn apply_config_override(version: ProtocolVersion, ret: Self) -> Self {
4735 CONFIG_OVERRIDE.with(|ovr| {
4736 if let Some(override_fn) = &*ovr.borrow() {
4737 warn!(
4738 "overriding ProtocolConfig settings with custom settings (you should not see this log outside of tests)"
4739 );
4740 override_fn(version, ret)
4741 } else {
4742 ret
4743 }
4744 })
4745 }
4746}
4747
4748impl ProtocolConfig {
4752 pub fn set_zklogin_circuit_mode_for_testing(&mut self, val: u64) {
4755 self.feature_flags.zklogin_circuit_mode = val
4756 }
4757
4758 pub fn set_per_object_congestion_control_mode_for_testing(
4759 &mut self,
4760 val: PerObjectCongestionControlMode,
4761 ) {
4762 self.feature_flags.per_object_congestion_control_mode = val;
4763 }
4764
4765 pub fn set_consensus_choice_for_testing(&mut self, val: ConsensusChoice) {
4766 self.feature_flags.consensus_choice = val;
4767 }
4768
4769 pub fn set_consensus_network_for_testing(&mut self, val: ConsensusNetwork) {
4770 self.feature_flags.consensus_network = val;
4771 }
4772
4773 pub fn set_zklogin_max_epoch_upper_bound_delta_for_testing(&mut self, val: Option<u64>) {
4774 self.feature_flags.zklogin_max_epoch_upper_bound_delta = val
4775 }
4776
4777 pub fn set_mysticeti_num_leaders_per_round_for_testing(&mut self, val: Option<usize>) {
4778 self.feature_flags.mysticeti_num_leaders_per_round = val;
4779 }
4780
4781 pub fn disable_accumulators_for_testing(&mut self) {
4782 self.feature_flags.enable_accumulators = false;
4783 self.feature_flags.enable_address_balance_gas_payments = false;
4784 }
4785
4786 pub fn enable_coin_reservation_for_testing(&mut self) {
4787 self.feature_flags.enable_coin_reservation_obj_refs = true;
4788 self.feature_flags
4789 .convert_withdrawal_compatibility_ptb_arguments = true;
4790 self.execution_version = Some(self.execution_version.map_or(4, |v| v.max(4)));
4793 }
4794
4795 pub fn disable_coin_reservation_for_testing(&mut self) {
4796 self.feature_flags.enable_coin_reservation_obj_refs = false;
4797 self.feature_flags
4798 .convert_withdrawal_compatibility_ptb_arguments = false;
4799 }
4800
4801 pub fn enable_address_balance_gas_payments_for_testing(&mut self) {
4802 self.feature_flags.enable_accumulators = true;
4803 self.feature_flags.allow_private_accumulator_entrypoints = true;
4804 self.feature_flags.enable_address_balance_gas_payments = true;
4805 self.feature_flags.address_balance_gas_check_rgp_at_signing = true;
4806 self.feature_flags.address_balance_gas_reject_gas_coin_arg = false;
4807 self.execution_version = Some(self.execution_version.map_or(4, |v| v.max(4)))
4808 }
4809
4810 pub fn enable_gasless_for_testing(&mut self) {
4811 self.enable_address_balance_gas_payments_for_testing();
4812 self.feature_flags.enable_gasless = true;
4813 self.feature_flags.gasless_verify_remaining_balance = true;
4814 self.gasless_max_computation_units = Some(5_000);
4815 self.gasless_allowed_token_types = Some(vec![]);
4816 self.gasless_max_tps = Some(1000);
4817 self.gasless_max_tx_size_bytes = Some(16 * 1024);
4818 }
4819
4820 pub fn disable_gasless_for_testing(&mut self) {
4821 self.feature_flags.enable_gasless = false;
4822 self.gasless_max_computation_units = None;
4823 self.gasless_allowed_token_types = None;
4824 }
4825
4826 pub fn enable_authenticated_event_streams_for_testing(&mut self) {
4827 self.feature_flags.enable_accumulators = true;
4828 self.feature_flags.enable_authenticated_event_streams = true;
4829 self.feature_flags
4830 .include_checkpoint_artifacts_digest_in_summary = true;
4831 self.feature_flags.split_checkpoints_in_consensus_handler = true;
4832 }
4833}
4834
4835#[cfg(not(msim))]
4836type OverrideFn = dyn Fn(ProtocolVersion, ProtocolConfig) -> ProtocolConfig + Send + Sync;
4837
4838#[cfg(not(msim))]
4839static CONFIG_OVERRIDE: Mutex<Option<Box<OverrideFn>>> = Mutex::new(None);
4840
4841#[cfg(msim)]
4842type OverrideFn = dyn Fn(ProtocolVersion, ProtocolConfig) -> ProtocolConfig + Send;
4843
4844#[cfg(msim)]
4845thread_local! {
4846 static CONFIG_OVERRIDE: RefCell<Option<Box<OverrideFn>>> = RefCell::new(None);
4847}
4848
4849#[must_use]
4850pub struct OverrideGuard;
4851
4852#[cfg(not(msim))]
4853impl Drop for OverrideGuard {
4854 fn drop(&mut self) {
4855 info!("restoring override fn");
4856 *CONFIG_OVERRIDE.lock().unwrap() = None;
4857 }
4858}
4859
4860#[cfg(msim)]
4861impl Drop for OverrideGuard {
4862 fn drop(&mut self) {
4863 info!("restoring override fn");
4864 CONFIG_OVERRIDE.with(|ovr| {
4865 *ovr.borrow_mut() = None;
4866 });
4867 }
4868}
4869
4870#[derive(PartialEq, Eq)]
4873pub enum LimitThresholdCrossed {
4874 None,
4875 Soft(u128, u128),
4876 Hard(u128, u128),
4877}
4878
4879pub fn check_limit_in_range<T: Into<V>, U: Into<V>, V: PartialOrd + Into<u128>>(
4882 x: T,
4883 soft_limit: U,
4884 hard_limit: V,
4885) -> LimitThresholdCrossed {
4886 let x: V = x.into();
4887 let soft_limit: V = soft_limit.into();
4888
4889 debug_assert!(soft_limit <= hard_limit);
4890
4891 if x >= hard_limit {
4894 LimitThresholdCrossed::Hard(x.into(), hard_limit.into())
4895 } else if x < soft_limit {
4896 LimitThresholdCrossed::None
4897 } else {
4898 LimitThresholdCrossed::Soft(x.into(), soft_limit.into())
4899 }
4900}
4901
4902#[macro_export]
4903macro_rules! check_limit {
4904 ($x:expr, $hard:expr) => {
4905 check_limit!($x, $hard, $hard)
4906 };
4907 ($x:expr, $soft:expr, $hard:expr) => {
4908 check_limit_in_range($x as u64, $soft, $hard)
4909 };
4910}
4911
4912#[macro_export]
4916macro_rules! check_limit_by_meter {
4917 ($is_metered:expr, $x:expr, $metered_limit:expr, $unmetered_hard_limit:expr, $metric:expr) => {{
4918 let (h, metered_str) = if $is_metered {
4920 ($metered_limit, "metered")
4921 } else {
4922 ($unmetered_hard_limit, "unmetered")
4924 };
4925 use sui_protocol_config::check_limit_in_range;
4926 let result = check_limit_in_range($x as u64, $metered_limit, h);
4927 match result {
4928 LimitThresholdCrossed::None => {}
4929 LimitThresholdCrossed::Soft(_, _) => {
4930 $metric.with_label_values(&[metered_str, "soft"]).inc();
4931 }
4932 LimitThresholdCrossed::Hard(_, _) => {
4933 $metric.with_label_values(&[metered_str, "hard"]).inc();
4934 }
4935 };
4936 result
4937 }};
4938}
4939
4940pub type Amendments = BTreeMap<AccountAddress, BTreeMap<AccountAddress, AccountAddress>>;
4943
4944static MAINNET_LINKAGE_AMENDMENTS: LazyLock<Arc<Amendments>> =
4945 LazyLock::new(|| parse_amendments(include_str!("mainnet_amendments.json")));
4946
4947static TESTNET_LINKAGE_AMENDMENTS: LazyLock<Arc<Amendments>> =
4948 LazyLock::new(|| parse_amendments(include_str!("testnet_amendments.json")));
4949
4950fn parse_amendments(json: &str) -> Arc<Amendments> {
4951 #[derive(serde::Deserialize)]
4952 struct AmendmentEntry {
4953 root: String,
4954 deps: Vec<DepEntry>,
4955 }
4956
4957 #[derive(serde::Deserialize)]
4958 struct DepEntry {
4959 original_id: String,
4960 version_id: String,
4961 }
4962
4963 let entries: Vec<AmendmentEntry> =
4964 serde_json::from_str(json).expect("Failed to parse amendments JSON");
4965 let mut amendments = BTreeMap::new();
4966 for entry in entries {
4967 let root_id = AccountAddress::from_hex_literal(&entry.root).unwrap();
4968 let mut dep_ids = BTreeMap::new();
4969 for dep in entry.deps {
4970 let orig_id = AccountAddress::from_hex_literal(&dep.original_id).unwrap();
4971 let upgraded_id = AccountAddress::from_hex_literal(&dep.version_id).unwrap();
4972 assert!(
4973 dep_ids.insert(orig_id, upgraded_id).is_none(),
4974 "Duplicate original ID in amendments table"
4975 );
4976 }
4977 assert!(
4978 amendments.insert(root_id, dep_ids).is_none(),
4979 "Duplicate root ID in amendments table"
4980 );
4981 }
4982 Arc::new(amendments)
4983}
4984
4985#[cfg(all(test, not(msim)))]
4986mod test {
4987 use insta::assert_yaml_snapshot;
4988
4989 use super::*;
4990
4991 #[test]
4992 fn snapshot_tests() {
4993 println!("\n============================================================================");
4994 println!("! !");
4995 println!("! IMPORTANT: never update snapshots from this test. only add new versions! !");
4996 println!("! !");
4997 println!("============================================================================\n");
4998 for chain_id in &[Chain::Unknown, Chain::Mainnet, Chain::Testnet] {
4999 let chain_str = match chain_id {
5003 Chain::Unknown => "".to_string(),
5004 _ => format!("{:?}_", chain_id),
5005 };
5006 for i in MIN_PROTOCOL_VERSION..=MAX_PROTOCOL_VERSION {
5007 let cur = ProtocolVersion::new(i);
5008 assert_yaml_snapshot!(
5009 format!("{}version_{}", chain_str, cur.as_u64()),
5010 ProtocolConfig::get_for_version(cur, *chain_id)
5011 );
5012 }
5013 }
5014 }
5015
5016 #[test]
5017 fn test_getters() {
5018 let prot: ProtocolConfig =
5019 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5020 assert_eq!(
5021 prot.max_arguments(),
5022 prot.max_arguments_as_option().unwrap()
5023 );
5024 }
5025
5026 #[test]
5027 fn test_setters() {
5028 let mut prot: ProtocolConfig =
5029 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5030 prot.set_max_arguments_for_testing(123);
5031 assert_eq!(prot.max_arguments(), 123);
5032
5033 prot.set_max_arguments_from_str_for_testing("321".to_string());
5034 assert_eq!(prot.max_arguments(), 321);
5035
5036 prot.disable_max_arguments_for_testing();
5037 assert_eq!(prot.max_arguments_as_option(), None);
5038
5039 prot.set_attr_for_testing("max_arguments".to_string(), "456".to_string());
5040 assert_eq!(prot.max_arguments(), 456);
5041 }
5042
5043 #[test]
5044 fn test_feature_flag_setter_by_string() {
5045 let mut prot: ProtocolConfig =
5046 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5047 assert!(!prot.zklogin_auth());
5048 prot.set_feature_flag_for_testing("zklogin_auth".to_string(), true);
5049 assert!(prot.zklogin_auth());
5050 prot.set_feature_flag_for_testing("zklogin_auth".to_string(), false);
5051 assert!(!prot.zklogin_auth());
5052 }
5053
5054 #[test]
5055 #[should_panic(expected = "unknown feature flag")]
5056 fn test_feature_flag_setter_unknown_flag() {
5057 let mut prot: ProtocolConfig =
5058 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5059 prot.set_feature_flag_for_testing("some random string".to_string(), true);
5060 }
5061
5062 #[test]
5063 fn test_get_for_version_if_supported_applies_test_overrides() {
5064 let before =
5065 ProtocolConfig::get_for_version_if_supported(ProtocolVersion::new(1), Chain::Unknown)
5066 .unwrap();
5067
5068 assert!(!before.enable_coin_reservation_obj_refs());
5069
5070 let _guard = ProtocolConfig::apply_overrides_for_testing(|_, mut cfg| {
5071 cfg.enable_coin_reservation_for_testing();
5072 cfg
5073 });
5074
5075 let after =
5076 ProtocolConfig::get_for_version_if_supported(ProtocolVersion::new(1), Chain::Unknown)
5077 .unwrap();
5078
5079 assert!(after.enable_coin_reservation_obj_refs());
5080 }
5081
5082 #[test]
5083 #[should_panic(expected = "unsupported version")]
5084 fn max_version_test() {
5085 let _ = ProtocolConfig::get_for_version_impl(
5088 ProtocolVersion::new(MAX_PROTOCOL_VERSION + 1),
5089 Chain::Unknown,
5090 );
5091 }
5092
5093 #[test]
5094 fn lookup_by_string_test() {
5095 let prot: ProtocolConfig =
5096 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5097 assert!(prot.lookup_attr("some random string".to_string()).is_none());
5099
5100 assert!(
5101 prot.lookup_attr("max_arguments".to_string())
5102 == Some(ProtocolConfigValue::u32(prot.max_arguments())),
5103 );
5104
5105 assert!(
5107 prot.lookup_attr("max_move_identifier_len".to_string())
5108 .is_none()
5109 );
5110
5111 let prot: ProtocolConfig =
5113 ProtocolConfig::get_for_version(ProtocolVersion::new(9), Chain::Unknown);
5114 assert!(
5115 prot.lookup_attr("max_move_identifier_len".to_string())
5116 == Some(ProtocolConfigValue::u64(prot.max_move_identifier_len()))
5117 );
5118
5119 let prot: ProtocolConfig =
5120 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5121 assert!(
5123 prot.attr_map()
5124 .get("max_move_identifier_len")
5125 .unwrap()
5126 .is_none()
5127 );
5128 assert!(
5130 prot.attr_map().get("max_arguments").unwrap()
5131 == &Some(ProtocolConfigValue::u32(prot.max_arguments()))
5132 );
5133
5134 let prot: ProtocolConfig =
5136 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5137 assert!(
5139 prot.feature_flags
5140 .lookup_attr("some random string".to_owned())
5141 .is_none()
5142 );
5143 assert!(
5144 !prot
5145 .feature_flags
5146 .attr_map()
5147 .contains_key("some random string")
5148 );
5149
5150 assert!(
5152 prot.feature_flags
5153 .lookup_attr("package_upgrades".to_owned())
5154 == Some(false)
5155 );
5156 assert!(
5157 prot.feature_flags
5158 .attr_map()
5159 .get("package_upgrades")
5160 .unwrap()
5161 == &false
5162 );
5163 let prot: ProtocolConfig =
5164 ProtocolConfig::get_for_version(ProtocolVersion::new(4), Chain::Unknown);
5165 assert!(
5167 prot.feature_flags
5168 .lookup_attr("package_upgrades".to_owned())
5169 == Some(true)
5170 );
5171 assert!(
5172 prot.feature_flags
5173 .attr_map()
5174 .get("package_upgrades")
5175 .unwrap()
5176 == &true
5177 );
5178 }
5179
5180 #[test]
5181 fn limit_range_fn_test() {
5182 let low = 100u32;
5183 let high = 10000u64;
5184
5185 assert!(check_limit!(1u8, low, high) == LimitThresholdCrossed::None);
5186 assert!(matches!(
5187 check_limit!(255u16, low, high),
5188 LimitThresholdCrossed::Soft(255u128, 100)
5189 ));
5190 assert!(matches!(
5196 check_limit!(2550000u64, low, high),
5197 LimitThresholdCrossed::Hard(2550000, 10000)
5198 ));
5199
5200 assert!(matches!(
5201 check_limit!(2550000u64, high, high),
5202 LimitThresholdCrossed::Hard(2550000, 10000)
5203 ));
5204
5205 assert!(matches!(
5206 check_limit!(1u8, high),
5207 LimitThresholdCrossed::None
5208 ));
5209
5210 assert!(check_limit!(255u16, high) == LimitThresholdCrossed::None);
5211
5212 assert!(matches!(
5213 check_limit!(2550000u64, high),
5214 LimitThresholdCrossed::Hard(2550000, 10000)
5215 ));
5216 }
5217
5218 #[test]
5219 fn linkage_amendments_load() {
5220 let mainnet = LazyLock::force(&MAINNET_LINKAGE_AMENDMENTS);
5221 let testnet = LazyLock::force(&TESTNET_LINKAGE_AMENDMENTS);
5222 assert!(!mainnet.is_empty(), "mainnet amendments must not be empty");
5223 assert!(!testnet.is_empty(), "testnet amendments must not be empty");
5224 }
5225
5226 #[test]
5227 fn render_scalar_fields_use_precision_safe_encoding() {
5228 use mysten_common::rpc_format::Unmetered;
5229
5230 let config = ProtocolConfig::get_for_max_version_UNSAFE();
5231 let rendered = config
5232 .render::<serde_json::Value>(&mut Unmetered)
5233 .expect("render should succeed");
5234
5235 let max_args = rendered
5236 .get("max_arguments")
5237 .expect("max_arguments set at max version");
5238 assert!(
5239 max_args.is_number(),
5240 "u32 should render as number, got {max_args:?}",
5241 );
5242
5243 let max_tx_size = rendered
5244 .get("max_tx_size_bytes")
5245 .expect("max_tx_size_bytes set at max version");
5246 assert!(
5247 max_tx_size.is_string(),
5248 "u64 should render as string, got {max_tx_size:?}",
5249 );
5250 }
5251
5252 #[test]
5253 fn render_includes_non_scalar_gasless_allowlist_as_json() {
5254 use mysten_common::rpc_format::Unmetered;
5255 use serde_json::json;
5256
5257 let mut config = ProtocolConfig::get_for_max_version_UNSAFE();
5258 config.set_gasless_allowed_token_types_for_testing(vec![
5259 ("0xa::usdc::USDC".to_string(), 10_000),
5260 ("0xb::usdt::USDT".to_string(), 0),
5261 ]);
5262
5263 let rendered = config
5264 .render::<serde_json::Value>(&mut Unmetered)
5265 .expect("render should succeed under Unmetered budget");
5266 let allowlist = rendered
5267 .get("gasless_allowed_token_types")
5268 .expect("entry should be present after the testing setter");
5269
5270 assert_eq!(
5273 allowlist,
5274 &json!([["0xa::usdc::USDC", "10000"], ["0xb::usdt::USDT", "0"],]),
5275 );
5276 }
5277
5278 #[test]
5279 fn render_targets_prost_value_for_grpc() {
5280 use mysten_common::rpc_format::Unmetered;
5281 use prost_types::value::Kind;
5282
5283 let mut config = ProtocolConfig::get_for_max_version_UNSAFE();
5284 config.set_gasless_allowed_token_types_for_testing(vec![(
5285 "0xa::usdc::USDC".to_string(),
5286 10_000,
5287 )]);
5288
5289 let rendered = config
5290 .render::<prost_types::Value>(&mut Unmetered)
5291 .expect("render to prost Value should succeed");
5292 let allowlist = rendered
5293 .get("gasless_allowed_token_types")
5294 .expect("entry should be present after the testing setter");
5295
5296 let Some(Kind::ListValue(outer)) = &allowlist.kind else {
5298 panic!(
5299 "expected ListValue at the top level, got {:?}",
5300 allowlist.kind
5301 );
5302 };
5303 assert_eq!(outer.values.len(), 1, "one allowlisted entry");
5304 let Some(Kind::ListValue(entry)) = &outer.values[0].kind else {
5305 panic!("expected each entry to be a ListValue");
5306 };
5307 assert_eq!(entry.values.len(), 2, "entry has (coin_type, amount)");
5308
5309 let Some(Kind::StringValue(coin_type)) = &entry.values[0].kind else {
5310 panic!("expected coin_type as StringValue");
5311 };
5312 assert_eq!(coin_type, "0xa::usdc::USDC");
5313
5314 let Some(Kind::StringValue(amount)) = &entry.values[1].kind else {
5316 panic!(
5317 "expected minimum_transfer_amount as StringValue (precision-safe u64); got {:?}",
5318 entry.values[1].kind,
5319 );
5320 };
5321 assert_eq!(amount, "10000");
5322 }
5323
5324 #[test]
5325 fn render_emits_null_for_unset_protocol_versions() {
5326 use mysten_common::rpc_format::Unmetered;
5327
5328 let config = ProtocolConfig::get_for_version(1.into(), Chain::Unknown);
5329 let rendered = config
5330 .render::<serde_json::Value>(&mut Unmetered)
5331 .expect("render should succeed");
5332 let entry = rendered
5336 .get("gasless_allowed_token_types")
5337 .expect("key should be present for every protocol version");
5338 assert!(
5339 entry.is_null(),
5340 "value should be null for pre-feature protocol version, got {entry:?}",
5341 );
5342 }
5343}