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 = 127;
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)]
360pub struct ProtocolVersion(u64);
361
362impl ProtocolVersion {
363 pub const MIN: Self = Self(MIN_PROTOCOL_VERSION);
368
369 pub const MAX: Self = Self(MAX_PROTOCOL_VERSION);
370
371 #[cfg(not(msim))]
372 pub const MAX_ALLOWED: Self = Self::MAX;
373
374 #[cfg(msim)]
376 pub const MAX_ALLOWED: Self = Self(MAX_PROTOCOL_VERSION + 1);
377
378 pub fn new(v: u64) -> Self {
379 Self(v)
380 }
381
382 pub const fn as_u64(&self) -> u64 {
383 self.0
384 }
385
386 pub fn max() -> Self {
389 Self::MAX
390 }
391
392 pub fn prev(self) -> Self {
393 Self(self.0.checked_sub(1).unwrap())
394 }
395}
396
397impl From<u64> for ProtocolVersion {
398 fn from(v: u64) -> Self {
399 Self::new(v)
400 }
401}
402
403impl std::ops::Sub<u64> for ProtocolVersion {
404 type Output = Self;
405 fn sub(self, rhs: u64) -> Self::Output {
406 Self::new(self.0 - rhs)
407 }
408}
409
410impl std::ops::Add<u64> for ProtocolVersion {
411 type Output = Self;
412 fn add(self, rhs: u64) -> Self::Output {
413 Self::new(self.0 + rhs)
414 }
415}
416
417#[derive(
418 Clone, Serialize, Deserialize, Debug, Default, PartialEq, Copy, PartialOrd, Ord, Eq, ValueEnum,
419)]
420pub enum Chain {
421 Mainnet,
422 Testnet,
423 #[default]
424 Unknown,
425}
426
427impl Chain {
428 pub fn as_str(self) -> &'static str {
429 match self {
430 Chain::Mainnet => "mainnet",
431 Chain::Testnet => "testnet",
432 Chain::Unknown => "unknown",
433 }
434 }
435}
436
437pub struct Error(pub String);
438
439#[derive(Default, Clone, Serialize, Deserialize, Debug, ProtocolConfigFeatureFlagsGetters)]
442struct FeatureFlags {
443 #[serde(skip_serializing_if = "is_false")]
446 package_upgrades: bool,
447 #[serde(skip_serializing_if = "is_false")]
450 commit_root_state_digest: bool,
451 #[serde(skip_serializing_if = "is_false")]
453 advance_epoch_start_time_in_safe_mode: bool,
454 #[serde(skip_serializing_if = "is_false")]
457 loaded_child_objects_fixed: bool,
458 #[serde(skip_serializing_if = "is_false")]
461 missing_type_is_compatibility_error: bool,
462 #[serde(skip_serializing_if = "is_false")]
465 scoring_decision_with_validity_cutoff: bool,
466
467 #[serde(skip_serializing_if = "is_false")]
470 consensus_order_end_of_epoch_last: bool,
471
472 #[serde(skip_serializing_if = "is_false")]
474 disallow_adding_abilities_on_upgrade: bool,
475 #[serde(skip_serializing_if = "is_false")]
477 disable_invariant_violation_check_in_swap_loc: bool,
478 #[serde(skip_serializing_if = "is_false")]
481 advance_to_highest_supported_protocol_version: bool,
482 #[serde(skip_serializing_if = "is_false")]
484 ban_entry_init: bool,
485 #[serde(skip_serializing_if = "is_false")]
487 package_digest_hash_module: bool,
488 #[serde(skip_serializing_if = "is_false")]
490 disallow_change_struct_type_params_on_upgrade: bool,
491 #[serde(skip_serializing_if = "is_false")]
493 no_extraneous_module_bytes: bool,
494 #[serde(skip_serializing_if = "is_false")]
496 narwhal_versioned_metadata: bool,
497
498 #[serde(skip_serializing_if = "is_false")]
500 zklogin_auth: bool,
501 #[serde(skip_serializing_if = "ConsensusTransactionOrdering::is_none")]
503 consensus_transaction_ordering: ConsensusTransactionOrdering,
504
505 #[serde(skip_serializing_if = "is_false")]
513 simplified_unwrap_then_delete: bool,
514 #[serde(skip_serializing_if = "is_false")]
516 upgraded_multisig_supported: bool,
517 #[serde(skip_serializing_if = "is_false")]
519 txn_base_cost_as_multiplier: bool,
520
521 #[serde(skip_serializing_if = "is_false")]
523 shared_object_deletion: bool,
524
525 #[serde(skip_serializing_if = "is_false")]
527 narwhal_new_leader_election_schedule: bool,
528
529 #[serde(skip_serializing_if = "is_empty")]
531 zklogin_supported_providers: BTreeSet<String>,
532
533 #[serde(skip_serializing_if = "is_false")]
535 loaded_child_object_format: bool,
536
537 #[serde(skip_serializing_if = "is_false")]
538 enable_jwk_consensus_updates: bool,
539
540 #[serde(skip_serializing_if = "is_false")]
541 end_of_epoch_transaction_supported: bool,
542
543 #[serde(skip_serializing_if = "is_false")]
546 simple_conservation_checks: bool,
547
548 #[serde(skip_serializing_if = "is_false")]
550 loaded_child_object_format_type: bool,
551
552 #[serde(skip_serializing_if = "is_false")]
554 receive_objects: bool,
555
556 #[serde(skip_serializing_if = "is_false")]
558 consensus_checkpoint_signature_key_includes_digest: bool,
559
560 #[serde(skip_serializing_if = "is_false")]
562 random_beacon: bool,
563
564 #[serde(skip_serializing_if = "is_false")]
566 bridge: bool,
567
568 #[serde(skip_serializing_if = "is_false")]
569 enable_effects_v2: bool,
570
571 #[serde(skip_serializing_if = "is_false")]
573 narwhal_certificate_v2: bool,
574
575 #[serde(skip_serializing_if = "is_false")]
577 verify_legacy_zklogin_address: bool,
578
579 #[serde(skip_serializing_if = "is_false")]
581 throughput_aware_consensus_submission: bool,
582
583 #[serde(skip_serializing_if = "is_false")]
585 recompute_has_public_transfer_in_execution: bool,
586
587 #[serde(skip_serializing_if = "is_false")]
589 accept_zklogin_in_multisig: bool,
590
591 #[serde(skip_serializing_if = "is_false")]
593 accept_passkey_in_multisig: bool,
594
595 #[serde(skip_serializing_if = "is_false")]
597 validate_zklogin_public_identifier: bool,
598
599 #[serde(skip_serializing_if = "is_false")]
602 include_consensus_digest_in_prologue: bool,
603
604 #[serde(skip_serializing_if = "is_false")]
606 hardened_otw_check: bool,
607
608 #[serde(skip_serializing_if = "is_false")]
610 allow_receiving_object_id: bool,
611
612 #[serde(skip_serializing_if = "is_false")]
614 enable_poseidon: bool,
615
616 #[serde(skip_serializing_if = "is_false")]
618 enable_coin_deny_list: bool,
619
620 #[serde(skip_serializing_if = "is_false")]
622 enable_group_ops_native_functions: bool,
623
624 #[serde(skip_serializing_if = "is_false")]
626 enable_group_ops_native_function_msm: bool,
627
628 #[serde(skip_serializing_if = "is_false")]
630 enable_ristretto255_group_ops: bool,
631
632 #[serde(skip_serializing_if = "is_false")]
634 enable_verify_bulletproofs_ristretto255: bool,
635
636 #[serde(skip_serializing_if = "is_false")]
638 enable_nitro_attestation: bool,
639
640 #[serde(skip_serializing_if = "is_false")]
642 enable_nitro_attestation_upgraded_parsing: bool,
643
644 #[serde(skip_serializing_if = "is_false")]
646 enable_nitro_attestation_all_nonzero_pcrs_parsing: bool,
647
648 #[serde(skip_serializing_if = "is_false")]
650 enable_nitro_attestation_always_include_required_pcrs_parsing: bool,
651
652 #[serde(skip_serializing_if = "is_false")]
654 reject_mutable_random_on_entry_functions: bool,
655
656 #[serde(skip_serializing_if = "PerObjectCongestionControlMode::is_none")]
658 per_object_congestion_control_mode: PerObjectCongestionControlMode,
659
660 #[serde(skip_serializing_if = "ConsensusChoice::is_narwhal")]
662 consensus_choice: ConsensusChoice,
663
664 #[serde(skip_serializing_if = "ConsensusNetwork::is_anemo")]
666 consensus_network: ConsensusNetwork,
667
668 #[serde(skip_serializing_if = "is_false")]
670 correct_gas_payment_limit_check: bool,
671
672 #[serde(skip_serializing_if = "Option::is_none")]
674 zklogin_max_epoch_upper_bound_delta: Option<u64>,
675
676 #[serde(skip_serializing_if = "is_false")]
678 mysticeti_leader_scoring_and_schedule: bool,
679
680 #[serde(skip_serializing_if = "is_false")]
682 reshare_at_same_initial_version: bool,
683
684 #[serde(skip_serializing_if = "is_false")]
686 resolve_abort_locations_to_package_id: bool,
687
688 #[serde(skip_serializing_if = "is_false")]
692 mysticeti_use_committed_subdag_digest: bool,
693
694 #[serde(skip_serializing_if = "is_false")]
696 enable_vdf: bool,
697
698 #[serde(skip_serializing_if = "is_false")]
703 record_consensus_determined_version_assignments_in_prologue: bool,
704 #[serde(skip_serializing_if = "is_false")]
705 record_consensus_determined_version_assignments_in_prologue_v2: bool,
706
707 #[serde(skip_serializing_if = "is_false")]
709 fresh_vm_on_framework_upgrade: bool,
710
711 #[serde(skip_serializing_if = "is_false")]
719 prepend_prologue_tx_in_consensus_commit_in_checkpoints: bool,
720
721 #[serde(skip_serializing_if = "Option::is_none")]
723 mysticeti_num_leaders_per_round: Option<usize>,
724
725 #[serde(skip_serializing_if = "is_false")]
727 soft_bundle: bool,
728
729 #[serde(skip_serializing_if = "is_false")]
731 enable_coin_deny_list_v2: bool,
732
733 #[serde(skip_serializing_if = "is_false")]
735 passkey_auth: bool,
736
737 #[serde(skip_serializing_if = "is_false")]
739 authority_capabilities_v2: bool,
740
741 #[serde(skip_serializing_if = "is_false")]
743 rethrow_serialization_type_layout_errors: bool,
744
745 #[serde(skip_serializing_if = "is_false")]
747 consensus_distributed_vote_scoring_strategy: bool,
748
749 #[serde(skip_serializing_if = "is_false")]
751 consensus_round_prober: bool,
752
753 #[serde(skip_serializing_if = "is_false")]
755 validate_identifier_inputs: bool,
756
757 #[serde(skip_serializing_if = "is_false")]
759 disallow_self_identifier: bool,
760
761 #[serde(skip_serializing_if = "is_false")]
763 mysticeti_fastpath: bool,
764
765 #[serde(skip_serializing_if = "is_false")]
769 disable_preconsensus_locking: bool,
770
771 #[serde(skip_serializing_if = "is_false")]
773 relocate_event_module: bool,
774
775 #[serde(skip_serializing_if = "is_false")]
777 uncompressed_g1_group_elements: bool,
778
779 #[serde(skip_serializing_if = "is_false")]
780 disallow_new_modules_in_deps_only_packages: bool,
781
782 #[serde(skip_serializing_if = "is_false")]
784 consensus_smart_ancestor_selection: bool,
785
786 #[serde(skip_serializing_if = "is_false")]
788 consensus_round_prober_probe_accepted_rounds: bool,
789
790 #[serde(skip_serializing_if = "is_false")]
792 native_charging_v2: bool,
793
794 #[serde(skip_serializing_if = "is_false")]
797 consensus_linearize_subdag_v2: bool,
798
799 #[serde(skip_serializing_if = "is_false")]
801 convert_type_argument_error: bool,
802
803 #[serde(skip_serializing_if = "is_false")]
805 variant_nodes: bool,
806
807 #[serde(skip_serializing_if = "is_false")]
809 consensus_zstd_compression: bool,
810
811 #[serde(skip_serializing_if = "is_false")]
813 minimize_child_object_mutations: bool,
814
815 #[serde(skip_serializing_if = "is_false")]
817 record_additional_state_digest_in_prologue: bool,
818
819 #[serde(skip_serializing_if = "is_false")]
821 move_native_context: bool,
822
823 #[serde(skip_serializing_if = "is_false")]
826 consensus_median_based_commit_timestamp: bool,
827
828 #[serde(skip_serializing_if = "is_false")]
831 normalize_ptb_arguments: bool,
832
833 #[serde(skip_serializing_if = "is_false")]
835 consensus_batched_block_sync: bool,
836
837 #[serde(skip_serializing_if = "is_false")]
839 enforce_checkpoint_timestamp_monotonicity: bool,
840
841 #[serde(skip_serializing_if = "is_false")]
843 max_ptb_value_size_v2: bool,
844
845 #[serde(skip_serializing_if = "is_false")]
847 resolve_type_input_ids_to_defining_id: bool,
848
849 #[serde(skip_serializing_if = "is_false")]
851 enable_party_transfer: bool,
852
853 #[serde(skip_serializing_if = "is_false")]
855 allow_unbounded_system_objects: bool,
856
857 #[serde(skip_serializing_if = "is_false")]
859 type_tags_in_object_runtime: bool,
860
861 #[serde(skip_serializing_if = "is_false")]
863 enable_accumulators: bool,
864
865 #[serde(skip_serializing_if = "is_false")]
867 enable_coin_reservation_obj_refs: bool,
868
869 #[serde(skip_serializing_if = "is_false")]
872 create_root_accumulator_object: bool,
873
874 #[serde(skip_serializing_if = "is_false")]
876 enable_authenticated_event_streams: bool,
877
878 #[serde(skip_serializing_if = "is_false")]
880 enable_address_balance_gas_payments: bool,
881
882 #[serde(skip_serializing_if = "is_false")]
884 address_balance_gas_check_rgp_at_signing: bool,
885
886 #[serde(skip_serializing_if = "is_false")]
887 address_balance_gas_reject_gas_coin_arg: bool,
888
889 #[serde(skip_serializing_if = "is_false")]
891 enable_multi_epoch_transaction_expiration: bool,
892
893 #[serde(skip_serializing_if = "is_false")]
895 relax_valid_during_for_owned_inputs: bool,
896
897 #[serde(skip_serializing_if = "is_false")]
899 enable_ptb_execution_v2: bool,
900
901 #[serde(skip_serializing_if = "is_false")]
903 better_adapter_type_resolution_errors: bool,
904
905 #[serde(skip_serializing_if = "is_false")]
907 record_time_estimate_processed: bool,
908
909 #[serde(skip_serializing_if = "is_false")]
911 dependency_linkage_error: bool,
912
913 #[serde(skip_serializing_if = "is_false")]
915 additional_multisig_checks: bool,
916
917 #[serde(skip_serializing_if = "is_false")]
919 ignore_execution_time_observations_after_certs_closed: bool,
920
921 #[serde(skip_serializing_if = "is_false")]
925 debug_fatal_on_move_invariant_violation: bool,
926
927 #[serde(skip_serializing_if = "is_false")]
930 allow_private_accumulator_entrypoints: bool,
931
932 #[serde(skip_serializing_if = "is_false")]
934 additional_consensus_digest_indirect_state: bool,
935
936 #[serde(skip_serializing_if = "is_false")]
938 check_for_init_during_upgrade: bool,
939
940 #[serde(skip_serializing_if = "is_false")]
942 per_command_shared_object_transfer_rules: bool,
943
944 #[serde(skip_serializing_if = "is_false")]
946 include_checkpoint_artifacts_digest_in_summary: bool,
947
948 #[serde(skip_serializing_if = "is_false")]
950 use_mfp_txns_in_load_initial_object_debts: bool,
951
952 #[serde(skip_serializing_if = "is_false")]
954 cancel_for_failed_dkg_early: bool,
955
956 #[serde(skip_serializing_if = "is_false")]
958 always_advance_dkg_to_resolution: bool,
959
960 #[serde(skip_serializing_if = "is_false")]
962 enable_coin_registry: bool,
963
964 #[serde(skip_serializing_if = "is_false")]
966 abstract_size_in_object_runtime: bool,
967
968 #[serde(skip_serializing_if = "is_false")]
970 object_runtime_charge_cache_load_gas: bool,
971
972 #[serde(skip_serializing_if = "is_false")]
974 additional_borrow_checks: bool,
975
976 #[serde(skip_serializing_if = "is_false")]
978 use_new_commit_handler: bool,
979
980 #[serde(skip_serializing_if = "is_false")]
982 better_loader_errors: bool,
983
984 #[serde(skip_serializing_if = "is_false")]
986 generate_df_type_layouts: bool,
987
988 #[serde(skip_serializing_if = "is_false")]
990 allow_references_in_ptbs: bool,
991
992 #[serde(skip_serializing_if = "is_false")]
994 enable_display_registry: bool,
995
996 #[serde(skip_serializing_if = "is_false")]
998 private_generics_verifier_v2: bool,
999
1000 #[serde(skip_serializing_if = "is_false")]
1002 deprecate_global_storage_ops_during_deserialization: bool,
1003
1004 #[serde(skip_serializing_if = "is_false")]
1007 enable_non_exclusive_writes: bool,
1008
1009 #[serde(skip_serializing_if = "is_false")]
1011 deprecate_global_storage_ops: bool,
1012
1013 #[serde(skip_serializing_if = "is_false")]
1015 normalize_depth_formula: bool,
1016
1017 #[serde(skip_serializing_if = "is_false")]
1019 consensus_skip_gced_accept_votes: bool,
1020
1021 #[serde(skip_serializing_if = "is_false")]
1023 include_cancelled_randomness_txns_in_prologue: bool,
1024
1025 #[serde(skip_serializing_if = "is_false")]
1027 address_aliases: bool,
1028
1029 #[serde(skip_serializing_if = "is_false")]
1032 fix_checkpoint_signature_mapping: bool,
1033
1034 #[serde(skip_serializing_if = "is_false")]
1036 enable_object_funds_withdraw: bool,
1037
1038 #[serde(skip_serializing_if = "is_false")]
1040 consensus_skip_gced_blocks_in_direct_finalization: bool,
1041
1042 #[serde(skip_serializing_if = "is_false")]
1044 gas_rounding_halve_digits: bool,
1045
1046 #[serde(skip_serializing_if = "is_false")]
1048 flexible_tx_context_positions: bool,
1049
1050 #[serde(skip_serializing_if = "is_false")]
1052 disable_entry_point_signature_check: bool,
1053
1054 #[serde(skip_serializing_if = "is_false")]
1056 convert_withdrawal_compatibility_ptb_arguments: bool,
1057
1058 #[serde(skip_serializing_if = "is_false")]
1060 restrict_hot_or_not_entry_functions: bool,
1061
1062 #[serde(skip_serializing_if = "is_false")]
1064 split_checkpoints_in_consensus_handler: bool,
1065
1066 #[serde(skip_serializing_if = "is_false")]
1068 consensus_always_accept_system_transactions: bool,
1069
1070 #[serde(skip_serializing_if = "is_false")]
1072 validator_metadata_verify_v2: bool,
1073
1074 #[serde(skip_serializing_if = "is_false")]
1077 defer_unpaid_amplification: bool,
1078
1079 #[serde(skip_serializing_if = "is_false")]
1080 randomize_checkpoint_tx_limit_in_tests: bool,
1081
1082 #[serde(skip_serializing_if = "is_false")]
1084 gasless_transaction_drop_safety: bool,
1085
1086 #[serde(skip_serializing_if = "is_false")]
1088 merge_randomness_into_checkpoint: bool,
1089
1090 #[serde(skip_serializing_if = "is_false")]
1092 use_coin_party_owner: bool,
1093
1094 #[serde(skip_serializing_if = "is_false")]
1095 enable_gasless: bool,
1096
1097 #[serde(skip_serializing_if = "is_false")]
1098 gasless_verify_remaining_balance: bool,
1099
1100 #[serde(skip_serializing_if = "is_false")]
1101 disallow_jump_orphans: bool,
1102
1103 #[serde(skip_serializing_if = "is_false")]
1105 early_return_receive_object_mismatched_type: bool,
1106
1107 #[serde(skip_serializing_if = "is_false")]
1112 timestamp_based_epoch_close: bool,
1113
1114 #[serde(skip_serializing_if = "is_false")]
1117 limit_groth16_pvk_inputs: bool,
1118
1119 #[serde(skip_serializing_if = "is_false")]
1124 enforce_address_balance_change_invariant: bool,
1125
1126 #[serde(skip_serializing_if = "is_false")]
1128 granular_post_execution_checks: bool,
1129
1130 #[serde(skip_serializing_if = "is_false")]
1132 early_exit_on_iffw: bool,
1133}
1134
1135fn is_false(b: &bool) -> bool {
1136 !b
1137}
1138
1139fn is_empty(b: &BTreeSet<String>) -> bool {
1140 b.is_empty()
1141}
1142
1143fn is_zero(val: &u64) -> bool {
1144 *val == 0
1145}
1146
1147#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1149pub enum ConsensusTransactionOrdering {
1150 #[default]
1152 None,
1153 ByGasPrice,
1155}
1156
1157impl ConsensusTransactionOrdering {
1158 pub fn is_none(&self) -> bool {
1159 matches!(self, ConsensusTransactionOrdering::None)
1160 }
1161}
1162
1163#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1164pub struct ExecutionTimeEstimateParams {
1165 pub target_utilization: u64,
1167 pub allowed_txn_cost_overage_burst_limit_us: u64,
1171
1172 pub randomness_scalar: u64,
1175
1176 pub max_estimate_us: u64,
1178
1179 pub stored_observations_num_included_checkpoints: u64,
1182
1183 pub stored_observations_limit: u64,
1185
1186 #[serde(skip_serializing_if = "is_zero")]
1189 pub stake_weighted_median_threshold: u64,
1190
1191 #[serde(skip_serializing_if = "is_false")]
1195 pub default_none_duration_for_new_keys: bool,
1196
1197 #[serde(skip_serializing_if = "Option::is_none")]
1199 pub observations_chunk_size: Option<u64>,
1200}
1201
1202#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1204pub enum PerObjectCongestionControlMode {
1205 #[default]
1206 None, TotalGasBudget, TotalTxCount, TotalGasBudgetWithCap, ExecutionTimeEstimate(ExecutionTimeEstimateParams), }
1212
1213impl PerObjectCongestionControlMode {
1214 pub fn is_none(&self) -> bool {
1215 matches!(self, PerObjectCongestionControlMode::None)
1216 }
1217}
1218
1219#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1221pub enum ConsensusChoice {
1222 #[default]
1223 Narwhal,
1224 SwapEachEpoch,
1225 Mysticeti,
1226}
1227
1228impl ConsensusChoice {
1229 pub fn is_narwhal(&self) -> bool {
1230 matches!(self, ConsensusChoice::Narwhal)
1231 }
1232}
1233
1234#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1236pub enum ConsensusNetwork {
1237 #[default]
1238 Anemo,
1239 Tonic,
1240}
1241
1242impl ConsensusNetwork {
1243 pub fn is_anemo(&self) -> bool {
1244 matches!(self, ConsensusNetwork::Anemo)
1245 }
1246}
1247
1248#[skip_serializing_none]
1280#[derive(Clone, Serialize, Debug, ProtocolConfigAccessors, ProtocolConfigOverride)]
1281pub struct ProtocolConfig {
1282 pub version: ProtocolVersion,
1283
1284 feature_flags: FeatureFlags,
1285
1286 max_tx_size_bytes: Option<u64>,
1289
1290 max_input_objects: Option<u64>,
1292
1293 max_size_written_objects: Option<u64>,
1297 max_size_written_objects_system_tx: Option<u64>,
1300
1301 max_serialized_tx_effects_size_bytes: Option<u64>,
1303
1304 max_serialized_tx_effects_size_bytes_system_tx: Option<u64>,
1306
1307 max_gas_payment_objects: Option<u32>,
1309
1310 max_modules_in_publish: Option<u32>,
1312
1313 max_package_dependencies: Option<u32>,
1315
1316 max_arguments: Option<u32>,
1319
1320 max_type_arguments: Option<u32>,
1322
1323 max_type_argument_depth: Option<u32>,
1325
1326 max_pure_argument_size: Option<u32>,
1328
1329 max_programmable_tx_commands: Option<u32>,
1331
1332 move_binary_format_version: Option<u32>,
1335 min_move_binary_format_version: Option<u32>,
1336
1337 binary_module_handles: Option<u16>,
1339 binary_struct_handles: Option<u16>,
1340 binary_function_handles: Option<u16>,
1341 binary_function_instantiations: Option<u16>,
1342 binary_signatures: Option<u16>,
1343 binary_constant_pool: Option<u16>,
1344 binary_identifiers: Option<u16>,
1345 binary_address_identifiers: Option<u16>,
1346 binary_struct_defs: Option<u16>,
1347 binary_struct_def_instantiations: Option<u16>,
1348 binary_function_defs: Option<u16>,
1349 binary_field_handles: Option<u16>,
1350 binary_field_instantiations: Option<u16>,
1351 binary_friend_decls: Option<u16>,
1352 binary_enum_defs: Option<u16>,
1353 binary_enum_def_instantiations: Option<u16>,
1354 binary_variant_handles: Option<u16>,
1355 binary_variant_instantiation_handles: Option<u16>,
1356
1357 max_move_object_size: Option<u64>,
1359
1360 max_move_package_size: Option<u64>,
1363
1364 max_publish_or_upgrade_per_ptb: Option<u64>,
1366
1367 max_tx_gas: Option<u64>,
1369
1370 max_gas_price: Option<u64>,
1372
1373 max_gas_price_rgp_factor_for_aborted_transactions: Option<u64>,
1376
1377 max_gas_computation_bucket: Option<u64>,
1379
1380 gas_rounding_step: Option<u64>,
1382
1383 max_loop_depth: Option<u64>,
1385
1386 max_generic_instantiation_length: Option<u64>,
1388
1389 max_function_parameters: Option<u64>,
1391
1392 max_basic_blocks: Option<u64>,
1394
1395 max_value_stack_size: Option<u64>,
1397
1398 max_type_nodes: Option<u64>,
1400
1401 max_push_size: Option<u64>,
1403
1404 max_struct_definitions: Option<u64>,
1406
1407 max_function_definitions: Option<u64>,
1409
1410 max_fields_in_struct: Option<u64>,
1412
1413 max_dependency_depth: Option<u64>,
1415
1416 max_num_event_emit: Option<u64>,
1418
1419 max_num_new_move_object_ids: Option<u64>,
1421
1422 max_num_new_move_object_ids_system_tx: Option<u64>,
1424
1425 max_num_deleted_move_object_ids: Option<u64>,
1427
1428 max_num_deleted_move_object_ids_system_tx: Option<u64>,
1430
1431 max_num_transferred_move_object_ids: Option<u64>,
1433
1434 max_num_transferred_move_object_ids_system_tx: Option<u64>,
1436
1437 max_event_emit_size: Option<u64>,
1439
1440 max_event_emit_size_total: Option<u64>,
1442
1443 max_move_vector_len: Option<u64>,
1445
1446 max_move_identifier_len: Option<u64>,
1448
1449 max_move_value_depth: Option<u64>,
1451
1452 max_move_enum_variants: Option<u64>,
1454
1455 max_back_edges_per_function: Option<u64>,
1457
1458 max_back_edges_per_module: Option<u64>,
1460
1461 max_verifier_meter_ticks_per_function: Option<u64>,
1463
1464 max_meter_ticks_per_module: Option<u64>,
1466
1467 max_meter_ticks_per_package: Option<u64>,
1469
1470 object_runtime_max_num_cached_objects: Option<u64>,
1474
1475 object_runtime_max_num_cached_objects_system_tx: Option<u64>,
1477
1478 object_runtime_max_num_store_entries: Option<u64>,
1480
1481 object_runtime_max_num_store_entries_system_tx: Option<u64>,
1483
1484 base_tx_cost_fixed: Option<u64>,
1487
1488 package_publish_cost_fixed: Option<u64>,
1491
1492 base_tx_cost_per_byte: Option<u64>,
1495
1496 package_publish_cost_per_byte: Option<u64>,
1498
1499 obj_access_cost_read_per_byte: Option<u64>,
1501
1502 obj_access_cost_mutate_per_byte: Option<u64>,
1504
1505 obj_access_cost_delete_per_byte: Option<u64>,
1507
1508 obj_access_cost_verify_per_byte: Option<u64>,
1518
1519 max_type_to_layout_nodes: Option<u64>,
1521
1522 max_ptb_value_size: Option<u64>,
1524
1525 gas_model_version: Option<u64>,
1528
1529 obj_data_cost_refundable: Option<u64>,
1532
1533 obj_metadata_cost_non_refundable: Option<u64>,
1537
1538 storage_rebate_rate: Option<u64>,
1544
1545 storage_fund_reinvest_rate: Option<u64>,
1548
1549 reward_slashing_rate: Option<u64>,
1552
1553 storage_gas_price: Option<u64>,
1555
1556 accumulator_object_storage_cost: Option<u64>,
1558
1559 max_transactions_per_checkpoint: Option<u64>,
1564
1565 max_checkpoint_size_bytes: Option<u64>,
1569
1570 buffer_stake_for_protocol_upgrade_bps: Option<u64>,
1575
1576 address_from_bytes_cost_base: Option<u64>,
1581 address_to_u256_cost_base: Option<u64>,
1583 address_from_u256_cost_base: Option<u64>,
1585
1586 config_read_setting_impl_cost_base: Option<u64>,
1591 config_read_setting_impl_cost_per_byte: Option<u64>,
1592
1593 dynamic_field_hash_type_and_key_cost_base: Option<u64>,
1596 dynamic_field_hash_type_and_key_type_cost_per_byte: Option<u64>,
1597 dynamic_field_hash_type_and_key_value_cost_per_byte: Option<u64>,
1598 dynamic_field_hash_type_and_key_type_tag_cost_per_byte: Option<u64>,
1599 dynamic_field_add_child_object_cost_base: Option<u64>,
1601 dynamic_field_add_child_object_type_cost_per_byte: Option<u64>,
1602 dynamic_field_add_child_object_value_cost_per_byte: Option<u64>,
1603 dynamic_field_add_child_object_struct_tag_cost_per_byte: Option<u64>,
1604 dynamic_field_borrow_child_object_cost_base: Option<u64>,
1606 dynamic_field_borrow_child_object_child_ref_cost_per_byte: Option<u64>,
1607 dynamic_field_borrow_child_object_type_cost_per_byte: Option<u64>,
1608 dynamic_field_remove_child_object_cost_base: Option<u64>,
1610 dynamic_field_remove_child_object_child_cost_per_byte: Option<u64>,
1611 dynamic_field_remove_child_object_type_cost_per_byte: Option<u64>,
1612 dynamic_field_has_child_object_cost_base: Option<u64>,
1614 dynamic_field_has_child_object_with_ty_cost_base: Option<u64>,
1616 dynamic_field_has_child_object_with_ty_type_cost_per_byte: Option<u64>,
1617 dynamic_field_has_child_object_with_ty_type_tag_cost_per_byte: Option<u64>,
1618
1619 event_emit_cost_base: Option<u64>,
1622 event_emit_value_size_derivation_cost_per_byte: Option<u64>,
1623 event_emit_tag_size_derivation_cost_per_byte: Option<u64>,
1624 event_emit_output_cost_per_byte: Option<u64>,
1625 event_emit_auth_stream_cost: Option<u64>,
1626
1627 object_borrow_uid_cost_base: Option<u64>,
1630 object_delete_impl_cost_base: Option<u64>,
1632 object_record_new_uid_cost_base: Option<u64>,
1634
1635 transfer_transfer_internal_cost_base: Option<u64>,
1638 transfer_party_transfer_internal_cost_base: Option<u64>,
1640 transfer_freeze_object_cost_base: Option<u64>,
1642 transfer_share_object_cost_base: Option<u64>,
1644 transfer_receive_object_cost_base: Option<u64>,
1647 transfer_receive_object_cost_per_byte: Option<u64>,
1648 transfer_receive_object_type_cost_per_byte: Option<u64>,
1649
1650 tx_context_derive_id_cost_base: Option<u64>,
1653 tx_context_fresh_id_cost_base: Option<u64>,
1654 tx_context_sender_cost_base: Option<u64>,
1655 tx_context_epoch_cost_base: Option<u64>,
1656 tx_context_epoch_timestamp_ms_cost_base: Option<u64>,
1657 tx_context_sponsor_cost_base: Option<u64>,
1658 tx_context_rgp_cost_base: Option<u64>,
1659 tx_context_gas_price_cost_base: Option<u64>,
1660 tx_context_gas_budget_cost_base: Option<u64>,
1661 tx_context_ids_created_cost_base: Option<u64>,
1662 tx_context_replace_cost_base: Option<u64>,
1663
1664 types_is_one_time_witness_cost_base: Option<u64>,
1667 types_is_one_time_witness_type_tag_cost_per_byte: Option<u64>,
1668 types_is_one_time_witness_type_cost_per_byte: Option<u64>,
1669
1670 validator_validate_metadata_cost_base: Option<u64>,
1673 validator_validate_metadata_data_cost_per_byte: Option<u64>,
1674
1675 crypto_invalid_arguments_cost: Option<u64>,
1677 bls12381_bls12381_min_sig_verify_cost_base: Option<u64>,
1679 bls12381_bls12381_min_sig_verify_msg_cost_per_byte: Option<u64>,
1680 bls12381_bls12381_min_sig_verify_msg_cost_per_block: Option<u64>,
1681
1682 bls12381_bls12381_min_pk_verify_cost_base: Option<u64>,
1684 bls12381_bls12381_min_pk_verify_msg_cost_per_byte: Option<u64>,
1685 bls12381_bls12381_min_pk_verify_msg_cost_per_block: Option<u64>,
1686
1687 ecdsa_k1_ecrecover_keccak256_cost_base: Option<u64>,
1689 ecdsa_k1_ecrecover_keccak256_msg_cost_per_byte: Option<u64>,
1690 ecdsa_k1_ecrecover_keccak256_msg_cost_per_block: Option<u64>,
1691 ecdsa_k1_ecrecover_sha256_cost_base: Option<u64>,
1692 ecdsa_k1_ecrecover_sha256_msg_cost_per_byte: Option<u64>,
1693 ecdsa_k1_ecrecover_sha256_msg_cost_per_block: Option<u64>,
1694
1695 ecdsa_k1_decompress_pubkey_cost_base: Option<u64>,
1697
1698 ecdsa_k1_secp256k1_verify_keccak256_cost_base: Option<u64>,
1700 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_byte: Option<u64>,
1701 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_block: Option<u64>,
1702 ecdsa_k1_secp256k1_verify_sha256_cost_base: Option<u64>,
1703 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_byte: Option<u64>,
1704 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_block: Option<u64>,
1705
1706 ecdsa_r1_ecrecover_keccak256_cost_base: Option<u64>,
1708 ecdsa_r1_ecrecover_keccak256_msg_cost_per_byte: Option<u64>,
1709 ecdsa_r1_ecrecover_keccak256_msg_cost_per_block: Option<u64>,
1710 ecdsa_r1_ecrecover_sha256_cost_base: Option<u64>,
1711 ecdsa_r1_ecrecover_sha256_msg_cost_per_byte: Option<u64>,
1712 ecdsa_r1_ecrecover_sha256_msg_cost_per_block: Option<u64>,
1713
1714 ecdsa_r1_secp256r1_verify_keccak256_cost_base: Option<u64>,
1716 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_byte: Option<u64>,
1717 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_block: Option<u64>,
1718 ecdsa_r1_secp256r1_verify_sha256_cost_base: Option<u64>,
1719 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_byte: Option<u64>,
1720 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_block: Option<u64>,
1721
1722 ecvrf_ecvrf_verify_cost_base: Option<u64>,
1724 ecvrf_ecvrf_verify_alpha_string_cost_per_byte: Option<u64>,
1725 ecvrf_ecvrf_verify_alpha_string_cost_per_block: Option<u64>,
1726
1727 ed25519_ed25519_verify_cost_base: Option<u64>,
1729 ed25519_ed25519_verify_msg_cost_per_byte: Option<u64>,
1730 ed25519_ed25519_verify_msg_cost_per_block: Option<u64>,
1731
1732 groth16_prepare_verifying_key_bls12381_cost_base: Option<u64>,
1734 groth16_prepare_verifying_key_bn254_cost_base: Option<u64>,
1735
1736 groth16_verify_groth16_proof_internal_bls12381_cost_base: Option<u64>,
1738 groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input: Option<u64>,
1739 groth16_verify_groth16_proof_internal_bn254_cost_base: Option<u64>,
1740 groth16_verify_groth16_proof_internal_bn254_cost_per_public_input: Option<u64>,
1741 groth16_verify_groth16_proof_internal_public_input_cost_per_byte: Option<u64>,
1742
1743 hash_blake2b256_cost_base: Option<u64>,
1745 hash_blake2b256_data_cost_per_byte: Option<u64>,
1746 hash_blake2b256_data_cost_per_block: Option<u64>,
1747
1748 hash_keccak256_cost_base: Option<u64>,
1750 hash_keccak256_data_cost_per_byte: Option<u64>,
1751 hash_keccak256_data_cost_per_block: Option<u64>,
1752
1753 poseidon_bn254_cost_base: Option<u64>,
1755 poseidon_bn254_cost_per_block: Option<u64>,
1756
1757 group_ops_bls12381_decode_scalar_cost: Option<u64>,
1759 group_ops_bls12381_decode_g1_cost: Option<u64>,
1760 group_ops_bls12381_decode_g2_cost: Option<u64>,
1761 group_ops_bls12381_decode_gt_cost: Option<u64>,
1762 group_ops_bls12381_scalar_add_cost: Option<u64>,
1763 group_ops_bls12381_g1_add_cost: Option<u64>,
1764 group_ops_bls12381_g2_add_cost: Option<u64>,
1765 group_ops_bls12381_gt_add_cost: Option<u64>,
1766 group_ops_bls12381_scalar_sub_cost: Option<u64>,
1767 group_ops_bls12381_g1_sub_cost: Option<u64>,
1768 group_ops_bls12381_g2_sub_cost: Option<u64>,
1769 group_ops_bls12381_gt_sub_cost: Option<u64>,
1770 group_ops_bls12381_scalar_mul_cost: Option<u64>,
1771 group_ops_bls12381_g1_mul_cost: Option<u64>,
1772 group_ops_bls12381_g2_mul_cost: Option<u64>,
1773 group_ops_bls12381_gt_mul_cost: Option<u64>,
1774 group_ops_bls12381_scalar_div_cost: Option<u64>,
1775 group_ops_bls12381_g1_div_cost: Option<u64>,
1776 group_ops_bls12381_g2_div_cost: Option<u64>,
1777 group_ops_bls12381_gt_div_cost: Option<u64>,
1778 group_ops_bls12381_g1_hash_to_base_cost: Option<u64>,
1779 group_ops_bls12381_g2_hash_to_base_cost: Option<u64>,
1780 group_ops_bls12381_g1_hash_to_cost_per_byte: Option<u64>,
1781 group_ops_bls12381_g2_hash_to_cost_per_byte: Option<u64>,
1782 group_ops_bls12381_g1_msm_base_cost: Option<u64>,
1783 group_ops_bls12381_g2_msm_base_cost: Option<u64>,
1784 group_ops_bls12381_g1_msm_base_cost_per_input: Option<u64>,
1785 group_ops_bls12381_g2_msm_base_cost_per_input: Option<u64>,
1786 group_ops_bls12381_msm_max_len: Option<u32>,
1787 group_ops_bls12381_pairing_cost: Option<u64>,
1788 group_ops_bls12381_g1_to_uncompressed_g1_cost: Option<u64>,
1789 group_ops_bls12381_uncompressed_g1_to_g1_cost: Option<u64>,
1790 group_ops_bls12381_uncompressed_g1_sum_base_cost: Option<u64>,
1791 group_ops_bls12381_uncompressed_g1_sum_cost_per_term: Option<u64>,
1792 group_ops_bls12381_uncompressed_g1_sum_max_terms: Option<u64>,
1793
1794 group_ops_ristretto_decode_scalar_cost: Option<u64>,
1795 group_ops_ristretto_decode_point_cost: Option<u64>,
1796 group_ops_ristretto_scalar_add_cost: Option<u64>,
1797 group_ops_ristretto_point_add_cost: Option<u64>,
1798 group_ops_ristretto_scalar_sub_cost: Option<u64>,
1799 group_ops_ristretto_point_sub_cost: Option<u64>,
1800 group_ops_ristretto_scalar_mul_cost: Option<u64>,
1801 group_ops_ristretto_point_mul_cost: Option<u64>,
1802 group_ops_ristretto_scalar_div_cost: Option<u64>,
1803 group_ops_ristretto_point_div_cost: Option<u64>,
1804
1805 verify_bulletproofs_ristretto255_base_cost: Option<u64>,
1806 verify_bulletproofs_ristretto255_cost_per_bit_and_commitment: Option<u64>,
1807
1808 hmac_hmac_sha3_256_cost_base: Option<u64>,
1810 hmac_hmac_sha3_256_input_cost_per_byte: Option<u64>,
1811 hmac_hmac_sha3_256_input_cost_per_block: Option<u64>,
1812
1813 check_zklogin_id_cost_base: Option<u64>,
1815 check_zklogin_issuer_cost_base: Option<u64>,
1817
1818 vdf_verify_vdf_cost: Option<u64>,
1819 vdf_hash_to_input_cost: Option<u64>,
1820
1821 nitro_attestation_parse_base_cost: Option<u64>,
1823 nitro_attestation_parse_cost_per_byte: Option<u64>,
1824 nitro_attestation_verify_base_cost: Option<u64>,
1825 nitro_attestation_verify_cost_per_cert: Option<u64>,
1826
1827 bcs_per_byte_serialized_cost: Option<u64>,
1829 bcs_legacy_min_output_size_cost: Option<u64>,
1830 bcs_failure_cost: Option<u64>,
1831
1832 hash_sha2_256_base_cost: Option<u64>,
1833 hash_sha2_256_per_byte_cost: Option<u64>,
1834 hash_sha2_256_legacy_min_input_len_cost: Option<u64>,
1835 hash_sha3_256_base_cost: Option<u64>,
1836 hash_sha3_256_per_byte_cost: Option<u64>,
1837 hash_sha3_256_legacy_min_input_len_cost: Option<u64>,
1838 type_name_get_base_cost: Option<u64>,
1839 type_name_get_per_byte_cost: Option<u64>,
1840 type_name_id_base_cost: Option<u64>,
1841
1842 string_check_utf8_base_cost: Option<u64>,
1843 string_check_utf8_per_byte_cost: Option<u64>,
1844 string_is_char_boundary_base_cost: Option<u64>,
1845 string_sub_string_base_cost: Option<u64>,
1846 string_sub_string_per_byte_cost: Option<u64>,
1847 string_index_of_base_cost: Option<u64>,
1848 string_index_of_per_byte_pattern_cost: Option<u64>,
1849 string_index_of_per_byte_searched_cost: Option<u64>,
1850
1851 vector_empty_base_cost: Option<u64>,
1852 vector_length_base_cost: Option<u64>,
1853 vector_push_back_base_cost: Option<u64>,
1854 vector_push_back_legacy_per_abstract_memory_unit_cost: Option<u64>,
1855 vector_borrow_base_cost: Option<u64>,
1856 vector_pop_back_base_cost: Option<u64>,
1857 vector_destroy_empty_base_cost: Option<u64>,
1858 vector_swap_base_cost: Option<u64>,
1859 debug_print_base_cost: Option<u64>,
1860 debug_print_stack_trace_base_cost: Option<u64>,
1861
1862 execution_version: Option<u64>,
1871
1872 consensus_bad_nodes_stake_threshold: Option<u64>,
1876
1877 max_jwk_votes_per_validator_per_epoch: Option<u64>,
1878 max_age_of_jwk_in_epochs: Option<u64>,
1882
1883 random_beacon_reduction_allowed_delta: Option<u16>,
1887
1888 random_beacon_reduction_lower_bound: Option<u32>,
1891
1892 random_beacon_dkg_timeout_round: Option<u32>,
1895
1896 random_beacon_min_round_interval_ms: Option<u64>,
1898
1899 random_beacon_dkg_version: Option<u64>,
1902
1903 consensus_max_transaction_size_bytes: Option<u64>,
1906 consensus_max_transactions_in_block_bytes: Option<u64>,
1908 consensus_max_num_transactions_in_block: Option<u64>,
1910
1911 consensus_voting_rounds: Option<u32>,
1913
1914 max_accumulated_txn_cost_per_object_in_narwhal_commit: Option<u64>,
1916
1917 max_deferral_rounds_for_congestion_control: Option<u64>,
1920
1921 max_txn_cost_overage_per_object_in_commit: Option<u64>,
1923
1924 allowed_txn_cost_overage_burst_per_object_in_commit: Option<u64>,
1926
1927 min_checkpoint_interval_ms: Option<u64>,
1929
1930 checkpoint_summary_version_specific_data: Option<u64>,
1932
1933 max_soft_bundle_size: Option<u64>,
1935
1936 bridge_should_try_to_finalize_committee: Option<bool>,
1940
1941 max_accumulated_txn_cost_per_object_in_mysticeti_commit: Option<u64>,
1947
1948 max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit: Option<u64>,
1951
1952 consensus_gc_depth: Option<u32>,
1955
1956 gas_budget_based_txn_cost_cap_factor: Option<u64>,
1958
1959 gas_budget_based_txn_cost_absolute_cap_commit_count: Option<u64>,
1961
1962 sip_45_consensus_amplification_threshold: Option<u64>,
1965
1966 use_object_per_epoch_marker_table_v2: Option<bool>,
1969
1970 consensus_commit_rate_estimation_window_size: Option<u32>,
1972
1973 #[serde(skip_serializing_if = "Vec::is_empty")]
1977 aliased_addresses: Vec<AliasedAddress>,
1978
1979 translation_per_command_base_charge: Option<u64>,
1982
1983 translation_per_input_base_charge: Option<u64>,
1986
1987 translation_pure_input_per_byte_charge: Option<u64>,
1989
1990 translation_per_type_node_charge: Option<u64>,
1994
1995 translation_per_reference_node_charge: Option<u64>,
1998
1999 translation_per_linkage_entry_charge: Option<u64>,
2002
2003 max_updates_per_settlement_txn: Option<u32>,
2005
2006 gasless_max_computation_units: Option<u64>,
2008
2009 gasless_allowed_token_types: Option<Vec<(String, u64)>>,
2011
2012 gasless_max_unused_inputs: Option<u64>,
2016
2017 gasless_max_pure_input_bytes: Option<u64>,
2020
2021 gasless_max_tps: Option<u64>,
2023
2024 #[serde(skip_serializing_if = "Option::is_none")]
2025 #[skip_accessor]
2026 include_special_package_amendments: Option<Arc<Amendments>>,
2027
2028 gasless_max_tx_size_bytes: Option<u64>,
2031}
2032
2033#[derive(Clone, Serialize, Deserialize, Debug)]
2035pub struct AliasedAddress {
2036 pub original: [u8; 32],
2038 pub aliased: [u8; 32],
2040 pub allowed_tx_digests: Vec<[u8; 32]>,
2042}
2043
2044impl ProtocolConfig {
2046 pub fn check_package_upgrades_supported(&self) -> Result<(), Error> {
2059 if self.feature_flags.package_upgrades {
2060 Ok(())
2061 } else {
2062 Err(Error(format!(
2063 "package upgrades are not supported at {:?}",
2064 self.version
2065 )))
2066 }
2067 }
2068
2069 pub fn allow_receiving_object_id(&self) -> bool {
2070 self.feature_flags.allow_receiving_object_id
2071 }
2072
2073 pub fn receiving_objects_supported(&self) -> bool {
2074 self.feature_flags.receive_objects
2075 }
2076
2077 pub fn package_upgrades_supported(&self) -> bool {
2078 self.feature_flags.package_upgrades
2079 }
2080
2081 pub fn check_commit_root_state_digest_supported(&self) -> bool {
2082 self.feature_flags.commit_root_state_digest
2083 }
2084
2085 pub fn get_advance_epoch_start_time_in_safe_mode(&self) -> bool {
2086 self.feature_flags.advance_epoch_start_time_in_safe_mode
2087 }
2088
2089 pub fn loaded_child_objects_fixed(&self) -> bool {
2090 self.feature_flags.loaded_child_objects_fixed
2091 }
2092
2093 pub fn missing_type_is_compatibility_error(&self) -> bool {
2094 self.feature_flags.missing_type_is_compatibility_error
2095 }
2096
2097 pub fn scoring_decision_with_validity_cutoff(&self) -> bool {
2098 self.feature_flags.scoring_decision_with_validity_cutoff
2099 }
2100
2101 pub fn narwhal_versioned_metadata(&self) -> bool {
2102 self.feature_flags.narwhal_versioned_metadata
2103 }
2104
2105 pub fn consensus_order_end_of_epoch_last(&self) -> bool {
2106 self.feature_flags.consensus_order_end_of_epoch_last
2107 }
2108
2109 pub fn disallow_adding_abilities_on_upgrade(&self) -> bool {
2110 self.feature_flags.disallow_adding_abilities_on_upgrade
2111 }
2112
2113 pub fn disable_invariant_violation_check_in_swap_loc(&self) -> bool {
2114 self.feature_flags
2115 .disable_invariant_violation_check_in_swap_loc
2116 }
2117
2118 pub fn advance_to_highest_supported_protocol_version(&self) -> bool {
2119 self.feature_flags
2120 .advance_to_highest_supported_protocol_version
2121 }
2122
2123 pub fn ban_entry_init(&self) -> bool {
2124 self.feature_flags.ban_entry_init
2125 }
2126
2127 pub fn package_digest_hash_module(&self) -> bool {
2128 self.feature_flags.package_digest_hash_module
2129 }
2130
2131 pub fn disallow_change_struct_type_params_on_upgrade(&self) -> bool {
2132 self.feature_flags
2133 .disallow_change_struct_type_params_on_upgrade
2134 }
2135
2136 pub fn no_extraneous_module_bytes(&self) -> bool {
2137 self.feature_flags.no_extraneous_module_bytes
2138 }
2139
2140 pub fn zklogin_auth(&self) -> bool {
2141 self.feature_flags.zklogin_auth
2142 }
2143
2144 pub fn zklogin_supported_providers(&self) -> &BTreeSet<String> {
2145 &self.feature_flags.zklogin_supported_providers
2146 }
2147
2148 pub fn consensus_transaction_ordering(&self) -> ConsensusTransactionOrdering {
2149 self.feature_flags.consensus_transaction_ordering
2150 }
2151
2152 pub fn simplified_unwrap_then_delete(&self) -> bool {
2153 self.feature_flags.simplified_unwrap_then_delete
2154 }
2155
2156 pub fn supports_upgraded_multisig(&self) -> bool {
2157 self.feature_flags.upgraded_multisig_supported
2158 }
2159
2160 pub fn txn_base_cost_as_multiplier(&self) -> bool {
2161 self.feature_flags.txn_base_cost_as_multiplier
2162 }
2163
2164 pub fn shared_object_deletion(&self) -> bool {
2165 self.feature_flags.shared_object_deletion
2166 }
2167
2168 pub fn narwhal_new_leader_election_schedule(&self) -> bool {
2169 self.feature_flags.narwhal_new_leader_election_schedule
2170 }
2171
2172 pub fn loaded_child_object_format(&self) -> bool {
2173 self.feature_flags.loaded_child_object_format
2174 }
2175
2176 pub fn enable_jwk_consensus_updates(&self) -> bool {
2177 let ret = self.feature_flags.enable_jwk_consensus_updates;
2178 if ret {
2179 assert!(self.feature_flags.end_of_epoch_transaction_supported);
2181 }
2182 ret
2183 }
2184
2185 pub fn simple_conservation_checks(&self) -> bool {
2186 self.feature_flags.simple_conservation_checks
2187 }
2188
2189 pub fn loaded_child_object_format_type(&self) -> bool {
2190 self.feature_flags.loaded_child_object_format_type
2191 }
2192
2193 pub fn end_of_epoch_transaction_supported(&self) -> bool {
2194 let ret = self.feature_flags.end_of_epoch_transaction_supported;
2195 if !ret {
2196 assert!(!self.feature_flags.enable_jwk_consensus_updates);
2198 }
2199 ret
2200 }
2201
2202 pub fn recompute_has_public_transfer_in_execution(&self) -> bool {
2203 self.feature_flags
2204 .recompute_has_public_transfer_in_execution
2205 }
2206
2207 pub fn create_authenticator_state_in_genesis(&self) -> bool {
2209 self.enable_jwk_consensus_updates()
2210 }
2211
2212 pub fn random_beacon(&self) -> bool {
2213 self.feature_flags.random_beacon
2214 }
2215
2216 pub fn dkg_version(&self) -> u64 {
2217 self.random_beacon_dkg_version.unwrap_or(1)
2219 }
2220
2221 pub fn enable_bridge(&self) -> bool {
2222 let ret = self.feature_flags.bridge;
2223 if ret {
2224 assert!(self.feature_flags.end_of_epoch_transaction_supported);
2226 }
2227 ret
2228 }
2229
2230 pub fn should_try_to_finalize_bridge_committee(&self) -> bool {
2231 if !self.enable_bridge() {
2232 return false;
2233 }
2234 self.bridge_should_try_to_finalize_committee.unwrap_or(true)
2236 }
2237
2238 pub fn enable_effects_v2(&self) -> bool {
2239 self.feature_flags.enable_effects_v2
2240 }
2241
2242 pub fn narwhal_certificate_v2(&self) -> bool {
2243 self.feature_flags.narwhal_certificate_v2
2244 }
2245
2246 pub fn verify_legacy_zklogin_address(&self) -> bool {
2247 self.feature_flags.verify_legacy_zklogin_address
2248 }
2249
2250 pub fn accept_zklogin_in_multisig(&self) -> bool {
2251 self.feature_flags.accept_zklogin_in_multisig
2252 }
2253
2254 pub fn accept_passkey_in_multisig(&self) -> bool {
2255 self.feature_flags.accept_passkey_in_multisig
2256 }
2257
2258 pub fn validate_zklogin_public_identifier(&self) -> bool {
2259 self.feature_flags.validate_zklogin_public_identifier
2260 }
2261
2262 pub fn zklogin_max_epoch_upper_bound_delta(&self) -> Option<u64> {
2263 self.feature_flags.zklogin_max_epoch_upper_bound_delta
2264 }
2265
2266 pub fn throughput_aware_consensus_submission(&self) -> bool {
2267 self.feature_flags.throughput_aware_consensus_submission
2268 }
2269
2270 pub fn include_consensus_digest_in_prologue(&self) -> bool {
2271 self.feature_flags.include_consensus_digest_in_prologue
2272 }
2273
2274 pub fn record_consensus_determined_version_assignments_in_prologue(&self) -> bool {
2275 self.feature_flags
2276 .record_consensus_determined_version_assignments_in_prologue
2277 }
2278
2279 pub fn record_additional_state_digest_in_prologue(&self) -> bool {
2280 self.feature_flags
2281 .record_additional_state_digest_in_prologue
2282 }
2283
2284 pub fn record_consensus_determined_version_assignments_in_prologue_v2(&self) -> bool {
2285 self.feature_flags
2286 .record_consensus_determined_version_assignments_in_prologue_v2
2287 }
2288
2289 pub fn prepend_prologue_tx_in_consensus_commit_in_checkpoints(&self) -> bool {
2290 self.feature_flags
2291 .prepend_prologue_tx_in_consensus_commit_in_checkpoints
2292 }
2293
2294 pub fn hardened_otw_check(&self) -> bool {
2295 self.feature_flags.hardened_otw_check
2296 }
2297
2298 pub fn enable_poseidon(&self) -> bool {
2299 self.feature_flags.enable_poseidon
2300 }
2301
2302 pub fn enable_coin_deny_list_v1(&self) -> bool {
2303 self.feature_flags.enable_coin_deny_list
2304 }
2305
2306 pub fn enable_accumulators(&self) -> bool {
2307 self.feature_flags.enable_accumulators
2308 }
2309
2310 pub fn enable_coin_reservation_obj_refs(&self) -> bool {
2311 self.new_vm_enabled() && self.feature_flags.enable_coin_reservation_obj_refs
2312 }
2313
2314 pub fn create_root_accumulator_object(&self) -> bool {
2315 self.feature_flags.create_root_accumulator_object
2316 }
2317
2318 pub fn enable_address_balance_gas_payments(&self) -> bool {
2319 self.feature_flags.enable_address_balance_gas_payments
2320 }
2321
2322 pub fn address_balance_gas_check_rgp_at_signing(&self) -> bool {
2323 self.feature_flags.address_balance_gas_check_rgp_at_signing
2324 }
2325
2326 pub fn address_balance_gas_reject_gas_coin_arg(&self) -> bool {
2327 self.feature_flags.address_balance_gas_reject_gas_coin_arg
2328 }
2329
2330 pub fn enable_multi_epoch_transaction_expiration(&self) -> bool {
2331 self.feature_flags.enable_multi_epoch_transaction_expiration
2332 }
2333
2334 pub fn relax_valid_during_for_owned_inputs(&self) -> bool {
2335 self.feature_flags.relax_valid_during_for_owned_inputs
2336 }
2337
2338 pub fn enable_authenticated_event_streams(&self) -> bool {
2339 self.feature_flags.enable_authenticated_event_streams && self.enable_accumulators()
2340 }
2341
2342 pub fn enable_non_exclusive_writes(&self) -> bool {
2343 self.feature_flags.enable_non_exclusive_writes
2344 }
2345
2346 pub fn enable_coin_registry(&self) -> bool {
2347 self.feature_flags.enable_coin_registry
2348 }
2349
2350 pub fn enable_display_registry(&self) -> bool {
2351 self.feature_flags.enable_display_registry
2352 }
2353
2354 pub fn enable_coin_deny_list_v2(&self) -> bool {
2355 self.feature_flags.enable_coin_deny_list_v2
2356 }
2357
2358 pub fn enable_group_ops_native_functions(&self) -> bool {
2359 self.feature_flags.enable_group_ops_native_functions
2360 }
2361
2362 pub fn enable_group_ops_native_function_msm(&self) -> bool {
2363 self.feature_flags.enable_group_ops_native_function_msm
2364 }
2365
2366 pub fn enable_ristretto255_group_ops(&self) -> bool {
2367 self.feature_flags.enable_ristretto255_group_ops
2368 }
2369
2370 pub fn enable_verify_bulletproofs_ristretto255(&self) -> bool {
2371 self.feature_flags.enable_verify_bulletproofs_ristretto255
2372 }
2373
2374 pub fn reject_mutable_random_on_entry_functions(&self) -> bool {
2375 self.feature_flags.reject_mutable_random_on_entry_functions
2376 }
2377
2378 pub fn per_object_congestion_control_mode(&self) -> PerObjectCongestionControlMode {
2379 self.feature_flags.per_object_congestion_control_mode
2380 }
2381
2382 pub fn consensus_choice(&self) -> ConsensusChoice {
2383 self.feature_flags.consensus_choice
2384 }
2385
2386 pub fn consensus_network(&self) -> ConsensusNetwork {
2387 self.feature_flags.consensus_network
2388 }
2389
2390 pub fn correct_gas_payment_limit_check(&self) -> bool {
2391 self.feature_flags.correct_gas_payment_limit_check
2392 }
2393
2394 pub fn reshare_at_same_initial_version(&self) -> bool {
2395 self.feature_flags.reshare_at_same_initial_version
2396 }
2397
2398 pub fn resolve_abort_locations_to_package_id(&self) -> bool {
2399 self.feature_flags.resolve_abort_locations_to_package_id
2400 }
2401
2402 pub fn mysticeti_use_committed_subdag_digest(&self) -> bool {
2403 self.feature_flags.mysticeti_use_committed_subdag_digest
2404 }
2405
2406 pub fn enable_vdf(&self) -> bool {
2407 self.feature_flags.enable_vdf
2408 }
2409
2410 pub fn fresh_vm_on_framework_upgrade(&self) -> bool {
2411 self.feature_flags.fresh_vm_on_framework_upgrade
2412 }
2413
2414 pub fn mysticeti_num_leaders_per_round(&self) -> Option<usize> {
2415 self.feature_flags.mysticeti_num_leaders_per_round
2416 }
2417
2418 pub fn soft_bundle(&self) -> bool {
2419 self.feature_flags.soft_bundle
2420 }
2421
2422 pub fn passkey_auth(&self) -> bool {
2423 self.feature_flags.passkey_auth
2424 }
2425
2426 pub fn authority_capabilities_v2(&self) -> bool {
2427 self.feature_flags.authority_capabilities_v2
2428 }
2429
2430 pub fn max_transaction_size_bytes(&self) -> u64 {
2431 self.consensus_max_transaction_size_bytes
2433 .unwrap_or(256 * 1024)
2434 }
2435
2436 pub fn max_transactions_in_block_bytes(&self) -> u64 {
2437 if cfg!(msim) {
2438 256 * 1024
2439 } else {
2440 self.consensus_max_transactions_in_block_bytes
2441 .unwrap_or(512 * 1024)
2442 }
2443 }
2444
2445 pub fn max_num_transactions_in_block(&self) -> u64 {
2446 if cfg!(msim) {
2447 8
2448 } else {
2449 self.consensus_max_num_transactions_in_block.unwrap_or(512)
2450 }
2451 }
2452
2453 pub fn rethrow_serialization_type_layout_errors(&self) -> bool {
2454 self.feature_flags.rethrow_serialization_type_layout_errors
2455 }
2456
2457 pub fn consensus_distributed_vote_scoring_strategy(&self) -> bool {
2458 self.feature_flags
2459 .consensus_distributed_vote_scoring_strategy
2460 }
2461
2462 pub fn consensus_round_prober(&self) -> bool {
2463 self.feature_flags.consensus_round_prober
2464 }
2465
2466 pub fn validate_identifier_inputs(&self) -> bool {
2467 self.feature_flags.validate_identifier_inputs
2468 }
2469
2470 pub fn gc_depth(&self) -> u32 {
2471 self.consensus_gc_depth.unwrap_or(0)
2472 }
2473
2474 pub fn mysticeti_fastpath(&self) -> bool {
2475 self.feature_flags.mysticeti_fastpath
2476 }
2477
2478 pub fn relocate_event_module(&self) -> bool {
2479 self.feature_flags.relocate_event_module
2480 }
2481
2482 pub fn uncompressed_g1_group_elements(&self) -> bool {
2483 self.feature_flags.uncompressed_g1_group_elements
2484 }
2485
2486 pub fn disallow_new_modules_in_deps_only_packages(&self) -> bool {
2487 self.feature_flags
2488 .disallow_new_modules_in_deps_only_packages
2489 }
2490
2491 pub fn consensus_smart_ancestor_selection(&self) -> bool {
2492 self.feature_flags.consensus_smart_ancestor_selection
2493 }
2494
2495 pub fn disable_preconsensus_locking(&self) -> bool {
2496 self.feature_flags.disable_preconsensus_locking
2497 }
2498
2499 pub fn consensus_round_prober_probe_accepted_rounds(&self) -> bool {
2500 self.feature_flags
2501 .consensus_round_prober_probe_accepted_rounds
2502 }
2503
2504 pub fn native_charging_v2(&self) -> bool {
2505 self.feature_flags.native_charging_v2
2506 }
2507
2508 pub fn consensus_linearize_subdag_v2(&self) -> bool {
2509 let res = self.feature_flags.consensus_linearize_subdag_v2;
2510 assert!(
2511 !res || self.gc_depth() > 0,
2512 "The consensus linearize sub dag V2 requires GC to be enabled"
2513 );
2514 res
2515 }
2516
2517 pub fn consensus_median_based_commit_timestamp(&self) -> bool {
2518 let res = self.feature_flags.consensus_median_based_commit_timestamp;
2519 assert!(
2520 !res || self.gc_depth() > 0,
2521 "The consensus median based commit timestamp requires GC to be enabled"
2522 );
2523 res
2524 }
2525
2526 pub fn consensus_batched_block_sync(&self) -> bool {
2527 self.feature_flags.consensus_batched_block_sync
2528 }
2529
2530 pub fn convert_type_argument_error(&self) -> bool {
2531 self.feature_flags.convert_type_argument_error
2532 }
2533
2534 pub fn variant_nodes(&self) -> bool {
2535 self.feature_flags.variant_nodes
2536 }
2537
2538 pub fn consensus_zstd_compression(&self) -> bool {
2539 self.feature_flags.consensus_zstd_compression
2540 }
2541
2542 pub fn enable_nitro_attestation(&self) -> bool {
2543 self.feature_flags.enable_nitro_attestation
2544 }
2545
2546 pub fn enable_nitro_attestation_upgraded_parsing(&self) -> bool {
2547 self.feature_flags.enable_nitro_attestation_upgraded_parsing
2548 }
2549
2550 pub fn enable_nitro_attestation_all_nonzero_pcrs_parsing(&self) -> bool {
2551 self.feature_flags
2552 .enable_nitro_attestation_all_nonzero_pcrs_parsing
2553 }
2554
2555 pub fn enable_nitro_attestation_always_include_required_pcrs_parsing(&self) -> bool {
2556 self.feature_flags
2557 .enable_nitro_attestation_always_include_required_pcrs_parsing
2558 }
2559
2560 pub fn get_consensus_commit_rate_estimation_window_size(&self) -> u32 {
2561 self.consensus_commit_rate_estimation_window_size
2562 .unwrap_or(0)
2563 }
2564
2565 pub fn consensus_num_requested_prior_commits_at_startup(&self) -> u32 {
2566 let window_size = self.get_consensus_commit_rate_estimation_window_size();
2570 assert!(window_size == 0 || self.record_additional_state_digest_in_prologue());
2572 window_size
2573 }
2574
2575 pub fn minimize_child_object_mutations(&self) -> bool {
2576 self.feature_flags.minimize_child_object_mutations
2577 }
2578
2579 pub fn move_native_context(&self) -> bool {
2580 self.feature_flags.move_native_context
2581 }
2582
2583 pub fn normalize_ptb_arguments(&self) -> bool {
2584 self.feature_flags.normalize_ptb_arguments
2585 }
2586
2587 pub fn enforce_checkpoint_timestamp_monotonicity(&self) -> bool {
2588 self.feature_flags.enforce_checkpoint_timestamp_monotonicity
2589 }
2590
2591 pub fn max_ptb_value_size_v2(&self) -> bool {
2592 self.feature_flags.max_ptb_value_size_v2
2593 }
2594
2595 pub fn resolve_type_input_ids_to_defining_id(&self) -> bool {
2596 self.feature_flags.resolve_type_input_ids_to_defining_id
2597 }
2598
2599 pub fn enable_party_transfer(&self) -> bool {
2600 self.feature_flags.enable_party_transfer
2601 }
2602
2603 pub fn allow_unbounded_system_objects(&self) -> bool {
2604 self.feature_flags.allow_unbounded_system_objects
2605 }
2606
2607 pub fn type_tags_in_object_runtime(&self) -> bool {
2608 self.feature_flags.type_tags_in_object_runtime
2609 }
2610
2611 pub fn enable_ptb_execution_v2(&self) -> bool {
2612 self.feature_flags.enable_ptb_execution_v2
2613 }
2614
2615 pub fn better_adapter_type_resolution_errors(&self) -> bool {
2616 self.feature_flags.better_adapter_type_resolution_errors
2617 }
2618
2619 pub fn record_time_estimate_processed(&self) -> bool {
2620 self.feature_flags.record_time_estimate_processed
2621 }
2622
2623 pub fn ignore_execution_time_observations_after_certs_closed(&self) -> bool {
2624 self.feature_flags
2625 .ignore_execution_time_observations_after_certs_closed
2626 }
2627
2628 pub fn dependency_linkage_error(&self) -> bool {
2629 self.feature_flags.dependency_linkage_error
2630 }
2631
2632 pub fn additional_multisig_checks(&self) -> bool {
2633 self.feature_flags.additional_multisig_checks
2634 }
2635
2636 pub fn debug_fatal_on_move_invariant_violation(&self) -> bool {
2637 self.feature_flags.debug_fatal_on_move_invariant_violation
2638 }
2639
2640 pub fn allow_private_accumulator_entrypoints(&self) -> bool {
2641 self.feature_flags.allow_private_accumulator_entrypoints
2642 }
2643
2644 pub fn additional_consensus_digest_indirect_state(&self) -> bool {
2645 self.feature_flags
2646 .additional_consensus_digest_indirect_state
2647 }
2648
2649 pub fn check_for_init_during_upgrade(&self) -> bool {
2650 self.feature_flags.check_for_init_during_upgrade
2651 }
2652
2653 pub fn per_command_shared_object_transfer_rules(&self) -> bool {
2654 self.feature_flags.per_command_shared_object_transfer_rules
2655 }
2656
2657 pub fn consensus_checkpoint_signature_key_includes_digest(&self) -> bool {
2658 self.feature_flags
2659 .consensus_checkpoint_signature_key_includes_digest
2660 }
2661
2662 pub fn include_checkpoint_artifacts_digest_in_summary(&self) -> bool {
2663 self.feature_flags
2664 .include_checkpoint_artifacts_digest_in_summary
2665 }
2666
2667 pub fn use_mfp_txns_in_load_initial_object_debts(&self) -> bool {
2668 self.feature_flags.use_mfp_txns_in_load_initial_object_debts
2669 }
2670
2671 pub fn cancel_for_failed_dkg_early(&self) -> bool {
2672 self.feature_flags.cancel_for_failed_dkg_early
2673 }
2674
2675 pub fn always_advance_dkg_to_resolution(&self) -> bool {
2676 self.feature_flags.always_advance_dkg_to_resolution
2677 }
2678
2679 pub fn abstract_size_in_object_runtime(&self) -> bool {
2680 self.feature_flags.abstract_size_in_object_runtime
2681 }
2682
2683 pub fn object_runtime_charge_cache_load_gas(&self) -> bool {
2684 self.feature_flags.object_runtime_charge_cache_load_gas
2685 }
2686
2687 pub fn additional_borrow_checks(&self) -> bool {
2688 self.feature_flags.additional_borrow_checks
2689 }
2690
2691 pub fn use_new_commit_handler(&self) -> bool {
2692 self.feature_flags.use_new_commit_handler
2693 }
2694
2695 pub fn better_loader_errors(&self) -> bool {
2696 self.feature_flags.better_loader_errors
2697 }
2698
2699 pub fn generate_df_type_layouts(&self) -> bool {
2700 self.feature_flags.generate_df_type_layouts
2701 }
2702
2703 pub fn allow_references_in_ptbs(&self) -> bool {
2704 self.feature_flags.allow_references_in_ptbs
2705 }
2706
2707 pub fn private_generics_verifier_v2(&self) -> bool {
2708 self.feature_flags.private_generics_verifier_v2
2709 }
2710
2711 pub fn deprecate_global_storage_ops_during_deserialization(&self) -> bool {
2712 self.feature_flags
2713 .deprecate_global_storage_ops_during_deserialization
2714 }
2715
2716 pub fn enable_observation_chunking(&self) -> bool {
2717 matches!(self.feature_flags.per_object_congestion_control_mode,
2718 PerObjectCongestionControlMode::ExecutionTimeEstimate(ref params)
2719 if params.observations_chunk_size.is_some()
2720 )
2721 }
2722
2723 pub fn deprecate_global_storage_ops(&self) -> bool {
2724 self.feature_flags.deprecate_global_storage_ops
2725 }
2726
2727 pub fn normalize_depth_formula(&self) -> bool {
2728 self.feature_flags.normalize_depth_formula
2729 }
2730
2731 pub fn consensus_skip_gced_accept_votes(&self) -> bool {
2732 self.feature_flags.consensus_skip_gced_accept_votes
2733 }
2734
2735 pub fn include_cancelled_randomness_txns_in_prologue(&self) -> bool {
2736 self.feature_flags
2737 .include_cancelled_randomness_txns_in_prologue
2738 }
2739
2740 pub fn address_aliases(&self) -> bool {
2741 let address_aliases = self.feature_flags.address_aliases;
2742 assert!(
2743 !address_aliases || self.mysticeti_fastpath(),
2744 "Address aliases requires Mysticeti fastpath to be enabled"
2745 );
2746 if address_aliases {
2747 assert!(
2748 self.feature_flags.disable_preconsensus_locking,
2749 "Address aliases requires CertifiedTransaction to be disabled"
2750 );
2751 }
2752 address_aliases
2753 }
2754
2755 pub fn fix_checkpoint_signature_mapping(&self) -> bool {
2756 self.feature_flags.fix_checkpoint_signature_mapping
2757 }
2758
2759 pub fn enable_object_funds_withdraw(&self) -> bool {
2760 self.feature_flags.enable_object_funds_withdraw
2761 }
2762
2763 pub fn gas_rounding_halve_digits(&self) -> bool {
2764 self.feature_flags.gas_rounding_halve_digits
2765 }
2766
2767 pub fn flexible_tx_context_positions(&self) -> bool {
2768 self.feature_flags.flexible_tx_context_positions
2769 }
2770
2771 pub fn disable_entry_point_signature_check(&self) -> bool {
2772 self.feature_flags.disable_entry_point_signature_check
2773 }
2774
2775 pub fn consensus_skip_gced_blocks_in_direct_finalization(&self) -> bool {
2776 self.feature_flags
2777 .consensus_skip_gced_blocks_in_direct_finalization
2778 }
2779
2780 pub fn convert_withdrawal_compatibility_ptb_arguments(&self) -> bool {
2781 self.feature_flags
2782 .convert_withdrawal_compatibility_ptb_arguments
2783 }
2784
2785 pub fn restrict_hot_or_not_entry_functions(&self) -> bool {
2786 self.feature_flags.restrict_hot_or_not_entry_functions
2787 }
2788
2789 pub fn split_checkpoints_in_consensus_handler(&self) -> bool {
2790 self.feature_flags.split_checkpoints_in_consensus_handler
2791 }
2792
2793 pub fn consensus_always_accept_system_transactions(&self) -> bool {
2794 self.feature_flags
2795 .consensus_always_accept_system_transactions
2796 }
2797
2798 pub fn validator_metadata_verify_v2(&self) -> bool {
2799 self.feature_flags.validator_metadata_verify_v2
2800 }
2801
2802 pub fn defer_unpaid_amplification(&self) -> bool {
2803 self.feature_flags.defer_unpaid_amplification
2804 }
2805
2806 pub fn gasless_transaction_drop_safety(&self) -> bool {
2807 self.feature_flags.gasless_transaction_drop_safety
2808 }
2809
2810 pub fn new_vm_enabled(&self) -> bool {
2811 self.execution_version.is_some_and(|v| v >= 4)
2812 }
2813
2814 pub fn merge_randomness_into_checkpoint(&self) -> bool {
2815 self.feature_flags.merge_randomness_into_checkpoint
2816 }
2817
2818 pub fn use_coin_party_owner(&self) -> bool {
2819 self.feature_flags.use_coin_party_owner
2820 }
2821
2822 pub fn enable_gasless(&self) -> bool {
2823 self.feature_flags.enable_gasless
2824 }
2825
2826 pub fn gasless_verify_remaining_balance(&self) -> bool {
2827 self.feature_flags.gasless_verify_remaining_balance
2828 }
2829
2830 pub fn gasless_allowed_token_types(&self) -> &[(String, u64)] {
2831 debug_assert!(self.gasless_allowed_token_types.is_some());
2832 self.gasless_allowed_token_types.as_deref().unwrap_or(&[])
2833 }
2834
2835 pub fn get_gasless_max_unused_inputs(&self) -> u64 {
2836 self.gasless_max_unused_inputs.unwrap_or(u64::MAX)
2837 }
2838
2839 pub fn get_gasless_max_pure_input_bytes(&self) -> u64 {
2840 self.gasless_max_pure_input_bytes.unwrap_or(u64::MAX)
2841 }
2842
2843 pub fn get_gasless_max_tx_size_bytes(&self) -> u64 {
2844 self.gasless_max_tx_size_bytes.unwrap_or(u64::MAX)
2845 }
2846
2847 pub fn disallow_jump_orphans(&self) -> bool {
2848 self.feature_flags.disallow_jump_orphans
2849 }
2850
2851 pub fn early_return_receive_object_mismatched_type(&self) -> bool {
2852 self.feature_flags
2853 .early_return_receive_object_mismatched_type
2854 }
2855
2856 pub fn include_special_package_amendments_as_option(&self) -> &Option<Arc<Amendments>> {
2857 &self.include_special_package_amendments
2858 }
2859
2860 pub fn timestamp_based_epoch_close(&self) -> bool {
2861 self.feature_flags.timestamp_based_epoch_close
2862 }
2863
2864 pub fn limit_groth16_pvk_inputs(&self) -> bool {
2865 self.feature_flags.limit_groth16_pvk_inputs
2866 }
2867
2868 pub fn enforce_address_balance_change_invariant(&self) -> bool {
2869 self.feature_flags.enforce_address_balance_change_invariant
2870 }
2871
2872 pub fn granular_post_execution_checks(&self) -> bool {
2873 self.feature_flags.granular_post_execution_checks
2874 }
2875
2876 pub fn early_exit_on_iffw(&self) -> bool {
2877 self.feature_flags.early_exit_on_iffw
2878 }
2879}
2880
2881#[cfg(not(msim))]
2882static POISON_VERSION_METHODS: AtomicBool = AtomicBool::new(false);
2883
2884#[cfg(msim)]
2886thread_local! {
2887 static POISON_VERSION_METHODS: AtomicBool = AtomicBool::new(false);
2888}
2889
2890impl ProtocolConfig {
2892 pub fn get_for_version(version: ProtocolVersion, chain: Chain) -> Self {
2894 assert!(
2896 version >= ProtocolVersion::MIN,
2897 "Network protocol version is {:?}, but the minimum supported version by the binary is {:?}. Please upgrade the binary.",
2898 version,
2899 ProtocolVersion::MIN.0,
2900 );
2901 assert!(
2902 version <= ProtocolVersion::MAX_ALLOWED,
2903 "Network protocol version is {:?}, but the maximum supported version by the binary is {:?}. Please upgrade the binary.",
2904 version,
2905 ProtocolVersion::MAX_ALLOWED.0,
2906 );
2907
2908 let mut ret = Self::get_for_version_impl(version, chain);
2909 ret.version = version;
2910
2911 ret = Self::apply_config_override(version, ret);
2912
2913 if std::env::var("SUI_PROTOCOL_CONFIG_OVERRIDE_ENABLE").is_ok() {
2914 warn!(
2915 "overriding ProtocolConfig settings with custom settings; this may break non-local networks"
2916 );
2917 let overrides: ProtocolConfigOptional =
2918 serde_env::from_env_with_prefix("SUI_PROTOCOL_CONFIG_OVERRIDE")
2919 .expect("failed to parse ProtocolConfig override env variables");
2920 overrides.apply_to(&mut ret);
2921 }
2922
2923 ret
2924 }
2925
2926 pub fn get_for_version_if_supported(version: ProtocolVersion, chain: Chain) -> Option<Self> {
2929 if version.0 >= ProtocolVersion::MIN.0 && version.0 <= ProtocolVersion::MAX_ALLOWED.0 {
2930 let mut ret = Self::get_for_version_impl(version, chain);
2931 ret.version = version;
2932 ret = Self::apply_config_override(version, ret);
2933 Some(ret)
2934 } else {
2935 None
2936 }
2937 }
2938
2939 #[cfg(not(msim))]
2940 pub fn poison_get_for_min_version() {
2941 POISON_VERSION_METHODS.store(true, Ordering::Relaxed);
2942 }
2943
2944 #[cfg(not(msim))]
2945 fn load_poison_get_for_min_version() -> bool {
2946 POISON_VERSION_METHODS.load(Ordering::Relaxed)
2947 }
2948
2949 #[cfg(msim)]
2950 pub fn poison_get_for_min_version() {
2951 POISON_VERSION_METHODS.with(|p| p.store(true, Ordering::Relaxed));
2952 }
2953
2954 #[cfg(msim)]
2955 fn load_poison_get_for_min_version() -> bool {
2956 POISON_VERSION_METHODS.with(|p| p.load(Ordering::Relaxed))
2957 }
2958
2959 pub fn get_for_min_version() -> Self {
2962 if Self::load_poison_get_for_min_version() {
2963 panic!("get_for_min_version called on validator");
2964 }
2965 ProtocolConfig::get_for_version(ProtocolVersion::MIN, Chain::Unknown)
2966 }
2967
2968 #[allow(non_snake_case)]
2978 pub fn get_for_max_version_UNSAFE() -> Self {
2979 if Self::load_poison_get_for_min_version() {
2980 panic!("get_for_max_version_UNSAFE called on validator");
2981 }
2982 ProtocolConfig::get_for_version(ProtocolVersion::MAX, Chain::Unknown)
2983 }
2984
2985 fn get_for_version_impl(version: ProtocolVersion, chain: Chain) -> Self {
2986 #[cfg(msim)]
2987 {
2988 if version == ProtocolVersion::MAX_ALLOWED {
2990 let mut config = Self::get_for_version_impl(version - 1, Chain::Unknown);
2991 config.base_tx_cost_fixed = Some(config.base_tx_cost_fixed() + 1000);
2992 return config;
2993 }
2994 }
2995
2996 let mut cfg = Self {
2999 version,
3001
3002 feature_flags: Default::default(),
3004
3005 max_tx_size_bytes: Some(128 * 1024),
3006 max_input_objects: Some(2048),
3008 max_serialized_tx_effects_size_bytes: Some(512 * 1024),
3009 max_serialized_tx_effects_size_bytes_system_tx: Some(512 * 1024 * 16),
3010 max_gas_payment_objects: Some(256),
3011 max_modules_in_publish: Some(128),
3012 max_package_dependencies: None,
3013 max_arguments: Some(512),
3014 max_type_arguments: Some(16),
3015 max_type_argument_depth: Some(16),
3016 max_pure_argument_size: Some(16 * 1024),
3017 max_programmable_tx_commands: Some(1024),
3018 move_binary_format_version: Some(6),
3019 min_move_binary_format_version: None,
3020 binary_module_handles: None,
3021 binary_struct_handles: None,
3022 binary_function_handles: None,
3023 binary_function_instantiations: None,
3024 binary_signatures: None,
3025 binary_constant_pool: None,
3026 binary_identifiers: None,
3027 binary_address_identifiers: None,
3028 binary_struct_defs: None,
3029 binary_struct_def_instantiations: None,
3030 binary_function_defs: None,
3031 binary_field_handles: None,
3032 binary_field_instantiations: None,
3033 binary_friend_decls: None,
3034 binary_enum_defs: None,
3035 binary_enum_def_instantiations: None,
3036 binary_variant_handles: None,
3037 binary_variant_instantiation_handles: None,
3038 max_move_object_size: Some(250 * 1024),
3039 max_move_package_size: Some(100 * 1024),
3040 max_publish_or_upgrade_per_ptb: None,
3041 max_tx_gas: Some(10_000_000_000),
3042 max_gas_price: Some(100_000),
3043 max_gas_price_rgp_factor_for_aborted_transactions: None,
3044 max_gas_computation_bucket: Some(5_000_000),
3045 max_loop_depth: Some(5),
3046 max_generic_instantiation_length: Some(32),
3047 max_function_parameters: Some(128),
3048 max_basic_blocks: Some(1024),
3049 max_value_stack_size: Some(1024),
3050 max_type_nodes: Some(256),
3051 max_push_size: Some(10000),
3052 max_struct_definitions: Some(200),
3053 max_function_definitions: Some(1000),
3054 max_fields_in_struct: Some(32),
3055 max_dependency_depth: Some(100),
3056 max_num_event_emit: Some(256),
3057 max_num_new_move_object_ids: Some(2048),
3058 max_num_new_move_object_ids_system_tx: Some(2048 * 16),
3059 max_num_deleted_move_object_ids: Some(2048),
3060 max_num_deleted_move_object_ids_system_tx: Some(2048 * 16),
3061 max_num_transferred_move_object_ids: Some(2048),
3062 max_num_transferred_move_object_ids_system_tx: Some(2048 * 16),
3063 max_event_emit_size: Some(250 * 1024),
3064 max_move_vector_len: Some(256 * 1024),
3065 max_type_to_layout_nodes: None,
3066 max_ptb_value_size: None,
3067
3068 max_back_edges_per_function: Some(10_000),
3069 max_back_edges_per_module: Some(10_000),
3070 max_verifier_meter_ticks_per_function: Some(6_000_000),
3071 max_meter_ticks_per_module: Some(6_000_000),
3072 max_meter_ticks_per_package: None,
3073
3074 object_runtime_max_num_cached_objects: Some(1000),
3075 object_runtime_max_num_cached_objects_system_tx: Some(1000 * 16),
3076 object_runtime_max_num_store_entries: Some(1000),
3077 object_runtime_max_num_store_entries_system_tx: Some(1000 * 16),
3078 base_tx_cost_fixed: Some(110_000),
3079 package_publish_cost_fixed: Some(1_000),
3080 base_tx_cost_per_byte: Some(0),
3081 package_publish_cost_per_byte: Some(80),
3082 obj_access_cost_read_per_byte: Some(15),
3083 obj_access_cost_mutate_per_byte: Some(40),
3084 obj_access_cost_delete_per_byte: Some(40),
3085 obj_access_cost_verify_per_byte: Some(200),
3086 obj_data_cost_refundable: Some(100),
3087 obj_metadata_cost_non_refundable: Some(50),
3088 gas_model_version: Some(1),
3089 storage_rebate_rate: Some(9900),
3090 storage_fund_reinvest_rate: Some(500),
3091 reward_slashing_rate: Some(5000),
3092 storage_gas_price: Some(1),
3093 accumulator_object_storage_cost: None,
3094 max_transactions_per_checkpoint: Some(10_000),
3095 max_checkpoint_size_bytes: Some(30 * 1024 * 1024),
3096
3097 buffer_stake_for_protocol_upgrade_bps: Some(0),
3100
3101 address_from_bytes_cost_base: Some(52),
3105 address_to_u256_cost_base: Some(52),
3107 address_from_u256_cost_base: Some(52),
3109
3110 config_read_setting_impl_cost_base: None,
3113 config_read_setting_impl_cost_per_byte: None,
3114
3115 dynamic_field_hash_type_and_key_cost_base: Some(100),
3118 dynamic_field_hash_type_and_key_type_cost_per_byte: Some(2),
3119 dynamic_field_hash_type_and_key_value_cost_per_byte: Some(2),
3120 dynamic_field_hash_type_and_key_type_tag_cost_per_byte: Some(2),
3121 dynamic_field_add_child_object_cost_base: Some(100),
3123 dynamic_field_add_child_object_type_cost_per_byte: Some(10),
3124 dynamic_field_add_child_object_value_cost_per_byte: Some(10),
3125 dynamic_field_add_child_object_struct_tag_cost_per_byte: Some(10),
3126 dynamic_field_borrow_child_object_cost_base: Some(100),
3128 dynamic_field_borrow_child_object_child_ref_cost_per_byte: Some(10),
3129 dynamic_field_borrow_child_object_type_cost_per_byte: Some(10),
3130 dynamic_field_remove_child_object_cost_base: Some(100),
3132 dynamic_field_remove_child_object_child_cost_per_byte: Some(2),
3133 dynamic_field_remove_child_object_type_cost_per_byte: Some(2),
3134 dynamic_field_has_child_object_cost_base: Some(100),
3136 dynamic_field_has_child_object_with_ty_cost_base: Some(100),
3138 dynamic_field_has_child_object_with_ty_type_cost_per_byte: Some(2),
3139 dynamic_field_has_child_object_with_ty_type_tag_cost_per_byte: Some(2),
3140
3141 event_emit_cost_base: Some(52),
3144 event_emit_value_size_derivation_cost_per_byte: Some(2),
3145 event_emit_tag_size_derivation_cost_per_byte: Some(5),
3146 event_emit_output_cost_per_byte: Some(10),
3147 event_emit_auth_stream_cost: None,
3148
3149 object_borrow_uid_cost_base: Some(52),
3152 object_delete_impl_cost_base: Some(52),
3154 object_record_new_uid_cost_base: Some(52),
3156
3157 transfer_transfer_internal_cost_base: Some(52),
3160 transfer_party_transfer_internal_cost_base: None,
3162 transfer_freeze_object_cost_base: Some(52),
3164 transfer_share_object_cost_base: Some(52),
3166 transfer_receive_object_cost_base: None,
3167 transfer_receive_object_type_cost_per_byte: None,
3168 transfer_receive_object_cost_per_byte: None,
3169
3170 tx_context_derive_id_cost_base: Some(52),
3173 tx_context_fresh_id_cost_base: None,
3174 tx_context_sender_cost_base: None,
3175 tx_context_epoch_cost_base: None,
3176 tx_context_epoch_timestamp_ms_cost_base: None,
3177 tx_context_sponsor_cost_base: None,
3178 tx_context_rgp_cost_base: None,
3179 tx_context_gas_price_cost_base: None,
3180 tx_context_gas_budget_cost_base: None,
3181 tx_context_ids_created_cost_base: None,
3182 tx_context_replace_cost_base: None,
3183
3184 types_is_one_time_witness_cost_base: Some(52),
3187 types_is_one_time_witness_type_tag_cost_per_byte: Some(2),
3188 types_is_one_time_witness_type_cost_per_byte: Some(2),
3189
3190 validator_validate_metadata_cost_base: Some(52),
3193 validator_validate_metadata_data_cost_per_byte: Some(2),
3194
3195 crypto_invalid_arguments_cost: Some(100),
3197 bls12381_bls12381_min_sig_verify_cost_base: Some(52),
3199 bls12381_bls12381_min_sig_verify_msg_cost_per_byte: Some(2),
3200 bls12381_bls12381_min_sig_verify_msg_cost_per_block: Some(2),
3201
3202 bls12381_bls12381_min_pk_verify_cost_base: Some(52),
3204 bls12381_bls12381_min_pk_verify_msg_cost_per_byte: Some(2),
3205 bls12381_bls12381_min_pk_verify_msg_cost_per_block: Some(2),
3206
3207 ecdsa_k1_ecrecover_keccak256_cost_base: Some(52),
3209 ecdsa_k1_ecrecover_keccak256_msg_cost_per_byte: Some(2),
3210 ecdsa_k1_ecrecover_keccak256_msg_cost_per_block: Some(2),
3211 ecdsa_k1_ecrecover_sha256_cost_base: Some(52),
3212 ecdsa_k1_ecrecover_sha256_msg_cost_per_byte: Some(2),
3213 ecdsa_k1_ecrecover_sha256_msg_cost_per_block: Some(2),
3214
3215 ecdsa_k1_decompress_pubkey_cost_base: Some(52),
3217
3218 ecdsa_k1_secp256k1_verify_keccak256_cost_base: Some(52),
3220 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_byte: Some(2),
3221 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_block: Some(2),
3222 ecdsa_k1_secp256k1_verify_sha256_cost_base: Some(52),
3223 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_byte: Some(2),
3224 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_block: Some(2),
3225
3226 ecdsa_r1_ecrecover_keccak256_cost_base: Some(52),
3228 ecdsa_r1_ecrecover_keccak256_msg_cost_per_byte: Some(2),
3229 ecdsa_r1_ecrecover_keccak256_msg_cost_per_block: Some(2),
3230 ecdsa_r1_ecrecover_sha256_cost_base: Some(52),
3231 ecdsa_r1_ecrecover_sha256_msg_cost_per_byte: Some(2),
3232 ecdsa_r1_ecrecover_sha256_msg_cost_per_block: Some(2),
3233
3234 ecdsa_r1_secp256r1_verify_keccak256_cost_base: Some(52),
3236 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_byte: Some(2),
3237 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_block: Some(2),
3238 ecdsa_r1_secp256r1_verify_sha256_cost_base: Some(52),
3239 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_byte: Some(2),
3240 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_block: Some(2),
3241
3242 ecvrf_ecvrf_verify_cost_base: Some(52),
3244 ecvrf_ecvrf_verify_alpha_string_cost_per_byte: Some(2),
3245 ecvrf_ecvrf_verify_alpha_string_cost_per_block: Some(2),
3246
3247 ed25519_ed25519_verify_cost_base: Some(52),
3249 ed25519_ed25519_verify_msg_cost_per_byte: Some(2),
3250 ed25519_ed25519_verify_msg_cost_per_block: Some(2),
3251
3252 groth16_prepare_verifying_key_bls12381_cost_base: Some(52),
3254 groth16_prepare_verifying_key_bn254_cost_base: Some(52),
3255
3256 groth16_verify_groth16_proof_internal_bls12381_cost_base: Some(52),
3258 groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input: Some(2),
3259 groth16_verify_groth16_proof_internal_bn254_cost_base: Some(52),
3260 groth16_verify_groth16_proof_internal_bn254_cost_per_public_input: Some(2),
3261 groth16_verify_groth16_proof_internal_public_input_cost_per_byte: Some(2),
3262
3263 hash_blake2b256_cost_base: Some(52),
3265 hash_blake2b256_data_cost_per_byte: Some(2),
3266 hash_blake2b256_data_cost_per_block: Some(2),
3267
3268 hash_keccak256_cost_base: Some(52),
3270 hash_keccak256_data_cost_per_byte: Some(2),
3271 hash_keccak256_data_cost_per_block: Some(2),
3272
3273 poseidon_bn254_cost_base: None,
3274 poseidon_bn254_cost_per_block: None,
3275
3276 hmac_hmac_sha3_256_cost_base: Some(52),
3278 hmac_hmac_sha3_256_input_cost_per_byte: Some(2),
3279 hmac_hmac_sha3_256_input_cost_per_block: Some(2),
3280
3281 group_ops_bls12381_decode_scalar_cost: None,
3283 group_ops_bls12381_decode_g1_cost: None,
3284 group_ops_bls12381_decode_g2_cost: None,
3285 group_ops_bls12381_decode_gt_cost: None,
3286 group_ops_bls12381_scalar_add_cost: None,
3287 group_ops_bls12381_g1_add_cost: None,
3288 group_ops_bls12381_g2_add_cost: None,
3289 group_ops_bls12381_gt_add_cost: None,
3290 group_ops_bls12381_scalar_sub_cost: None,
3291 group_ops_bls12381_g1_sub_cost: None,
3292 group_ops_bls12381_g2_sub_cost: None,
3293 group_ops_bls12381_gt_sub_cost: None,
3294 group_ops_bls12381_scalar_mul_cost: None,
3295 group_ops_bls12381_g1_mul_cost: None,
3296 group_ops_bls12381_g2_mul_cost: None,
3297 group_ops_bls12381_gt_mul_cost: None,
3298 group_ops_bls12381_scalar_div_cost: None,
3299 group_ops_bls12381_g1_div_cost: None,
3300 group_ops_bls12381_g2_div_cost: None,
3301 group_ops_bls12381_gt_div_cost: None,
3302 group_ops_bls12381_g1_hash_to_base_cost: None,
3303 group_ops_bls12381_g2_hash_to_base_cost: None,
3304 group_ops_bls12381_g1_hash_to_cost_per_byte: None,
3305 group_ops_bls12381_g2_hash_to_cost_per_byte: None,
3306 group_ops_bls12381_g1_msm_base_cost: None,
3307 group_ops_bls12381_g2_msm_base_cost: None,
3308 group_ops_bls12381_g1_msm_base_cost_per_input: None,
3309 group_ops_bls12381_g2_msm_base_cost_per_input: None,
3310 group_ops_bls12381_msm_max_len: None,
3311 group_ops_bls12381_pairing_cost: None,
3312 group_ops_bls12381_g1_to_uncompressed_g1_cost: None,
3313 group_ops_bls12381_uncompressed_g1_to_g1_cost: None,
3314 group_ops_bls12381_uncompressed_g1_sum_base_cost: None,
3315 group_ops_bls12381_uncompressed_g1_sum_cost_per_term: None,
3316 group_ops_bls12381_uncompressed_g1_sum_max_terms: None,
3317
3318 group_ops_ristretto_decode_scalar_cost: None,
3319 group_ops_ristretto_decode_point_cost: None,
3320 group_ops_ristretto_scalar_add_cost: None,
3321 group_ops_ristretto_point_add_cost: None,
3322 group_ops_ristretto_scalar_sub_cost: None,
3323 group_ops_ristretto_point_sub_cost: None,
3324 group_ops_ristretto_scalar_mul_cost: None,
3325 group_ops_ristretto_point_mul_cost: None,
3326 group_ops_ristretto_scalar_div_cost: None,
3327 group_ops_ristretto_point_div_cost: None,
3328
3329 verify_bulletproofs_ristretto255_base_cost: None,
3330 verify_bulletproofs_ristretto255_cost_per_bit_and_commitment: None,
3331
3332 check_zklogin_id_cost_base: None,
3334 check_zklogin_issuer_cost_base: None,
3336
3337 vdf_verify_vdf_cost: None,
3338 vdf_hash_to_input_cost: None,
3339
3340 nitro_attestation_parse_base_cost: None,
3342 nitro_attestation_parse_cost_per_byte: None,
3343 nitro_attestation_verify_base_cost: None,
3344 nitro_attestation_verify_cost_per_cert: None,
3345
3346 bcs_per_byte_serialized_cost: None,
3347 bcs_legacy_min_output_size_cost: None,
3348 bcs_failure_cost: None,
3349 hash_sha2_256_base_cost: None,
3350 hash_sha2_256_per_byte_cost: None,
3351 hash_sha2_256_legacy_min_input_len_cost: None,
3352 hash_sha3_256_base_cost: None,
3353 hash_sha3_256_per_byte_cost: None,
3354 hash_sha3_256_legacy_min_input_len_cost: None,
3355 type_name_get_base_cost: None,
3356 type_name_get_per_byte_cost: None,
3357 type_name_id_base_cost: None,
3358 string_check_utf8_base_cost: None,
3359 string_check_utf8_per_byte_cost: None,
3360 string_is_char_boundary_base_cost: None,
3361 string_sub_string_base_cost: None,
3362 string_sub_string_per_byte_cost: None,
3363 string_index_of_base_cost: None,
3364 string_index_of_per_byte_pattern_cost: None,
3365 string_index_of_per_byte_searched_cost: None,
3366 vector_empty_base_cost: None,
3367 vector_length_base_cost: None,
3368 vector_push_back_base_cost: None,
3369 vector_push_back_legacy_per_abstract_memory_unit_cost: None,
3370 vector_borrow_base_cost: None,
3371 vector_pop_back_base_cost: None,
3372 vector_destroy_empty_base_cost: None,
3373 vector_swap_base_cost: None,
3374 debug_print_base_cost: None,
3375 debug_print_stack_trace_base_cost: None,
3376
3377 max_size_written_objects: None,
3378 max_size_written_objects_system_tx: None,
3379
3380 max_move_identifier_len: None,
3387 max_move_value_depth: None,
3388 max_move_enum_variants: None,
3389
3390 gas_rounding_step: None,
3391
3392 execution_version: None,
3393
3394 max_event_emit_size_total: None,
3395
3396 consensus_bad_nodes_stake_threshold: None,
3397
3398 max_jwk_votes_per_validator_per_epoch: None,
3399
3400 max_age_of_jwk_in_epochs: None,
3401
3402 random_beacon_reduction_allowed_delta: None,
3403
3404 random_beacon_reduction_lower_bound: None,
3405
3406 random_beacon_dkg_timeout_round: None,
3407
3408 random_beacon_min_round_interval_ms: None,
3409
3410 random_beacon_dkg_version: None,
3411
3412 consensus_max_transaction_size_bytes: None,
3413
3414 consensus_max_transactions_in_block_bytes: None,
3415
3416 consensus_max_num_transactions_in_block: None,
3417
3418 consensus_voting_rounds: None,
3419
3420 max_accumulated_txn_cost_per_object_in_narwhal_commit: None,
3421
3422 max_deferral_rounds_for_congestion_control: None,
3423
3424 max_txn_cost_overage_per_object_in_commit: None,
3425
3426 allowed_txn_cost_overage_burst_per_object_in_commit: None,
3427
3428 min_checkpoint_interval_ms: None,
3429
3430 checkpoint_summary_version_specific_data: None,
3431
3432 max_soft_bundle_size: None,
3433
3434 bridge_should_try_to_finalize_committee: None,
3435
3436 max_accumulated_txn_cost_per_object_in_mysticeti_commit: None,
3437
3438 max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit: None,
3439
3440 consensus_gc_depth: None,
3441
3442 gas_budget_based_txn_cost_cap_factor: None,
3443
3444 gas_budget_based_txn_cost_absolute_cap_commit_count: None,
3445
3446 sip_45_consensus_amplification_threshold: None,
3447
3448 use_object_per_epoch_marker_table_v2: None,
3449
3450 consensus_commit_rate_estimation_window_size: None,
3451
3452 aliased_addresses: vec![],
3453
3454 translation_per_command_base_charge: None,
3455 translation_per_input_base_charge: None,
3456 translation_pure_input_per_byte_charge: None,
3457 translation_per_type_node_charge: None,
3458 translation_per_reference_node_charge: None,
3459 translation_per_linkage_entry_charge: None,
3460
3461 max_updates_per_settlement_txn: None,
3462
3463 gasless_max_computation_units: None,
3464 gasless_allowed_token_types: None,
3465 gasless_max_unused_inputs: None,
3466 gasless_max_pure_input_bytes: None,
3467 gasless_max_tps: None,
3468 include_special_package_amendments: None,
3469 gasless_max_tx_size_bytes: None,
3470 };
3473 for cur in 2..=version.0 {
3474 match cur {
3475 1 => unreachable!(),
3476 2 => {
3477 cfg.feature_flags.advance_epoch_start_time_in_safe_mode = true;
3478 }
3479 3 => {
3480 cfg.gas_model_version = Some(2);
3482 cfg.max_tx_gas = Some(50_000_000_000);
3484 cfg.base_tx_cost_fixed = Some(2_000);
3486 cfg.storage_gas_price = Some(76);
3488 cfg.feature_flags.loaded_child_objects_fixed = true;
3489 cfg.max_size_written_objects = Some(5 * 1000 * 1000);
3492 cfg.max_size_written_objects_system_tx = Some(50 * 1000 * 1000);
3495 cfg.feature_flags.package_upgrades = true;
3496 }
3497 4 => {
3502 cfg.reward_slashing_rate = Some(10000);
3504 cfg.gas_model_version = Some(3);
3506 }
3507 5 => {
3508 cfg.feature_flags.missing_type_is_compatibility_error = true;
3509 cfg.gas_model_version = Some(4);
3510 cfg.feature_flags.scoring_decision_with_validity_cutoff = true;
3511 }
3515 6 => {
3516 cfg.gas_model_version = Some(5);
3517 cfg.buffer_stake_for_protocol_upgrade_bps = Some(5000);
3518 cfg.feature_flags.consensus_order_end_of_epoch_last = true;
3519 }
3520 7 => {
3521 cfg.feature_flags.disallow_adding_abilities_on_upgrade = true;
3522 cfg.feature_flags
3523 .disable_invariant_violation_check_in_swap_loc = true;
3524 cfg.feature_flags.ban_entry_init = true;
3525 cfg.feature_flags.package_digest_hash_module = true;
3526 }
3527 8 => {
3528 cfg.feature_flags
3529 .disallow_change_struct_type_params_on_upgrade = true;
3530 }
3531 9 => {
3532 cfg.max_move_identifier_len = Some(128);
3534 cfg.feature_flags.no_extraneous_module_bytes = true;
3535 cfg.feature_flags
3536 .advance_to_highest_supported_protocol_version = true;
3537 }
3538 10 => {
3539 cfg.max_verifier_meter_ticks_per_function = Some(16_000_000);
3540 cfg.max_meter_ticks_per_module = Some(16_000_000);
3541 }
3542 11 => {
3543 cfg.max_move_value_depth = Some(128);
3544 }
3545 12 => {
3546 cfg.feature_flags.narwhal_versioned_metadata = true;
3547 if chain != Chain::Mainnet {
3548 cfg.feature_flags.commit_root_state_digest = true;
3549 }
3550
3551 if chain != Chain::Mainnet && chain != Chain::Testnet {
3552 cfg.feature_flags.zklogin_auth = true;
3553 }
3554 }
3555 13 => {}
3556 14 => {
3557 cfg.gas_rounding_step = Some(1_000);
3558 cfg.gas_model_version = Some(6);
3559 }
3560 15 => {
3561 cfg.feature_flags.consensus_transaction_ordering =
3562 ConsensusTransactionOrdering::ByGasPrice;
3563 }
3564 16 => {
3565 cfg.feature_flags.simplified_unwrap_then_delete = true;
3566 }
3567 17 => {
3568 cfg.feature_flags.upgraded_multisig_supported = true;
3569 }
3570 18 => {
3571 cfg.execution_version = Some(1);
3572 cfg.feature_flags.txn_base_cost_as_multiplier = true;
3581 cfg.base_tx_cost_fixed = Some(1_000);
3583 }
3584 19 => {
3585 cfg.max_num_event_emit = Some(1024);
3586 cfg.max_event_emit_size_total = Some(
3589 256 * 250 * 1024, );
3591 }
3592 20 => {
3593 cfg.feature_flags.commit_root_state_digest = true;
3594
3595 if chain != Chain::Mainnet {
3596 cfg.feature_flags.narwhal_new_leader_election_schedule = true;
3597 cfg.consensus_bad_nodes_stake_threshold = Some(20);
3598 }
3599 }
3600
3601 21 => {
3602 if chain != Chain::Mainnet {
3603 cfg.feature_flags.zklogin_supported_providers = BTreeSet::from([
3604 "Google".to_string(),
3605 "Facebook".to_string(),
3606 "Twitch".to_string(),
3607 ]);
3608 }
3609 }
3610 22 => {
3611 cfg.feature_flags.loaded_child_object_format = true;
3612 }
3613 23 => {
3614 cfg.feature_flags.loaded_child_object_format_type = true;
3615 cfg.feature_flags.narwhal_new_leader_election_schedule = true;
3616 cfg.consensus_bad_nodes_stake_threshold = Some(20);
3622 }
3623 24 => {
3624 cfg.feature_flags.simple_conservation_checks = true;
3625 cfg.max_publish_or_upgrade_per_ptb = Some(5);
3626
3627 cfg.feature_flags.end_of_epoch_transaction_supported = true;
3628
3629 if chain != Chain::Mainnet {
3630 cfg.feature_flags.enable_jwk_consensus_updates = true;
3631 cfg.max_jwk_votes_per_validator_per_epoch = Some(240);
3633 cfg.max_age_of_jwk_in_epochs = Some(1);
3634 }
3635 }
3636 25 => {
3637 cfg.feature_flags.zklogin_supported_providers = BTreeSet::from([
3639 "Google".to_string(),
3640 "Facebook".to_string(),
3641 "Twitch".to_string(),
3642 ]);
3643 cfg.feature_flags.zklogin_auth = true;
3644
3645 cfg.feature_flags.enable_jwk_consensus_updates = true;
3647 cfg.max_jwk_votes_per_validator_per_epoch = Some(240);
3648 cfg.max_age_of_jwk_in_epochs = Some(1);
3649 }
3650 26 => {
3651 cfg.gas_model_version = Some(7);
3652 if chain != Chain::Mainnet && chain != Chain::Testnet {
3654 cfg.transfer_receive_object_cost_base = Some(52);
3655 cfg.feature_flags.receive_objects = true;
3656 }
3657 }
3658 27 => {
3659 cfg.gas_model_version = Some(8);
3660 }
3661 28 => {
3662 cfg.check_zklogin_id_cost_base = Some(200);
3664 cfg.check_zklogin_issuer_cost_base = Some(200);
3666
3667 if chain != Chain::Mainnet && chain != Chain::Testnet {
3669 cfg.feature_flags.enable_effects_v2 = true;
3670 }
3671 }
3672 29 => {
3673 cfg.feature_flags.verify_legacy_zklogin_address = true;
3674 }
3675 30 => {
3676 if chain != Chain::Mainnet {
3678 cfg.feature_flags.narwhal_certificate_v2 = true;
3679 }
3680
3681 cfg.random_beacon_reduction_allowed_delta = Some(800);
3682 if chain != Chain::Mainnet {
3684 cfg.feature_flags.enable_effects_v2 = true;
3685 }
3686
3687 cfg.feature_flags.zklogin_supported_providers = BTreeSet::default();
3691
3692 cfg.feature_flags.recompute_has_public_transfer_in_execution = true;
3693 }
3694 31 => {
3695 cfg.execution_version = Some(2);
3696 if chain != Chain::Mainnet && chain != Chain::Testnet {
3698 cfg.feature_flags.shared_object_deletion = true;
3699 }
3700 }
3701 32 => {
3702 if chain != Chain::Mainnet {
3704 cfg.feature_flags.accept_zklogin_in_multisig = true;
3705 }
3706 if chain != Chain::Mainnet {
3708 cfg.transfer_receive_object_cost_base = Some(52);
3709 cfg.feature_flags.receive_objects = true;
3710 }
3711 if chain != Chain::Mainnet && chain != Chain::Testnet {
3713 cfg.feature_flags.random_beacon = true;
3714 cfg.random_beacon_reduction_lower_bound = Some(1600);
3715 cfg.random_beacon_dkg_timeout_round = Some(3000);
3716 cfg.random_beacon_min_round_interval_ms = Some(150);
3717 }
3718 if chain != Chain::Testnet && chain != Chain::Mainnet {
3720 cfg.feature_flags.include_consensus_digest_in_prologue = true;
3721 }
3722
3723 cfg.feature_flags.narwhal_certificate_v2 = true;
3725 }
3726 33 => {
3727 cfg.feature_flags.hardened_otw_check = true;
3728 cfg.feature_flags.allow_receiving_object_id = true;
3729
3730 cfg.transfer_receive_object_cost_base = Some(52);
3732 cfg.feature_flags.receive_objects = true;
3733
3734 if chain != Chain::Mainnet {
3736 cfg.feature_flags.shared_object_deletion = true;
3737 }
3738
3739 cfg.feature_flags.enable_effects_v2 = true;
3740 }
3741 34 => {}
3742 35 => {
3743 if chain != Chain::Mainnet && chain != Chain::Testnet {
3745 cfg.feature_flags.enable_poseidon = true;
3746 cfg.poseidon_bn254_cost_base = Some(260);
3747 cfg.poseidon_bn254_cost_per_block = Some(10);
3748 }
3749
3750 cfg.feature_flags.enable_coin_deny_list = true;
3751 }
3752 36 => {
3753 if chain != Chain::Mainnet && chain != Chain::Testnet {
3755 cfg.feature_flags.enable_group_ops_native_functions = true;
3756 cfg.feature_flags.enable_group_ops_native_function_msm = true;
3757 cfg.group_ops_bls12381_decode_scalar_cost = Some(52);
3759 cfg.group_ops_bls12381_decode_g1_cost = Some(52);
3760 cfg.group_ops_bls12381_decode_g2_cost = Some(52);
3761 cfg.group_ops_bls12381_decode_gt_cost = Some(52);
3762 cfg.group_ops_bls12381_scalar_add_cost = Some(52);
3763 cfg.group_ops_bls12381_g1_add_cost = Some(52);
3764 cfg.group_ops_bls12381_g2_add_cost = Some(52);
3765 cfg.group_ops_bls12381_gt_add_cost = Some(52);
3766 cfg.group_ops_bls12381_scalar_sub_cost = Some(52);
3767 cfg.group_ops_bls12381_g1_sub_cost = Some(52);
3768 cfg.group_ops_bls12381_g2_sub_cost = Some(52);
3769 cfg.group_ops_bls12381_gt_sub_cost = Some(52);
3770 cfg.group_ops_bls12381_scalar_mul_cost = Some(52);
3771 cfg.group_ops_bls12381_g1_mul_cost = Some(52);
3772 cfg.group_ops_bls12381_g2_mul_cost = Some(52);
3773 cfg.group_ops_bls12381_gt_mul_cost = Some(52);
3774 cfg.group_ops_bls12381_scalar_div_cost = Some(52);
3775 cfg.group_ops_bls12381_g1_div_cost = Some(52);
3776 cfg.group_ops_bls12381_g2_div_cost = Some(52);
3777 cfg.group_ops_bls12381_gt_div_cost = Some(52);
3778 cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(52);
3779 cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(52);
3780 cfg.group_ops_bls12381_g1_hash_to_cost_per_byte = Some(2);
3781 cfg.group_ops_bls12381_g2_hash_to_cost_per_byte = Some(2);
3782 cfg.group_ops_bls12381_g1_msm_base_cost = Some(52);
3783 cfg.group_ops_bls12381_g2_msm_base_cost = Some(52);
3784 cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(52);
3785 cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(52);
3786 cfg.group_ops_bls12381_msm_max_len = Some(32);
3787 cfg.group_ops_bls12381_pairing_cost = Some(52);
3788 }
3789 cfg.feature_flags.shared_object_deletion = true;
3791
3792 cfg.consensus_max_transaction_size_bytes = Some(256 * 1024); cfg.consensus_max_transactions_in_block_bytes = Some(6 * 1_024 * 1024);
3794 }
3796 37 => {
3797 cfg.feature_flags.reject_mutable_random_on_entry_functions = true;
3798
3799 if chain != Chain::Mainnet {
3801 cfg.feature_flags.include_consensus_digest_in_prologue = true;
3802 }
3803 }
3804 38 => {
3805 cfg.binary_module_handles = Some(100);
3806 cfg.binary_struct_handles = Some(300);
3807 cfg.binary_function_handles = Some(1500);
3808 cfg.binary_function_instantiations = Some(750);
3809 cfg.binary_signatures = Some(1000);
3810 cfg.binary_constant_pool = Some(4000);
3814 cfg.binary_identifiers = Some(10000);
3815 cfg.binary_address_identifiers = Some(100);
3816 cfg.binary_struct_defs = Some(200);
3817 cfg.binary_struct_def_instantiations = Some(100);
3818 cfg.binary_function_defs = Some(1000);
3819 cfg.binary_field_handles = Some(500);
3820 cfg.binary_field_instantiations = Some(250);
3821 cfg.binary_friend_decls = Some(100);
3822 cfg.max_package_dependencies = Some(32);
3824 cfg.max_modules_in_publish = Some(64);
3825 cfg.execution_version = Some(3);
3827 }
3828 39 => {
3829 }
3831 40 => {}
3832 41 => {
3833 cfg.feature_flags.enable_group_ops_native_functions = true;
3835 cfg.group_ops_bls12381_decode_scalar_cost = Some(52);
3837 cfg.group_ops_bls12381_decode_g1_cost = Some(52);
3838 cfg.group_ops_bls12381_decode_g2_cost = Some(52);
3839 cfg.group_ops_bls12381_decode_gt_cost = Some(52);
3840 cfg.group_ops_bls12381_scalar_add_cost = Some(52);
3841 cfg.group_ops_bls12381_g1_add_cost = Some(52);
3842 cfg.group_ops_bls12381_g2_add_cost = Some(52);
3843 cfg.group_ops_bls12381_gt_add_cost = Some(52);
3844 cfg.group_ops_bls12381_scalar_sub_cost = Some(52);
3845 cfg.group_ops_bls12381_g1_sub_cost = Some(52);
3846 cfg.group_ops_bls12381_g2_sub_cost = Some(52);
3847 cfg.group_ops_bls12381_gt_sub_cost = Some(52);
3848 cfg.group_ops_bls12381_scalar_mul_cost = Some(52);
3849 cfg.group_ops_bls12381_g1_mul_cost = Some(52);
3850 cfg.group_ops_bls12381_g2_mul_cost = Some(52);
3851 cfg.group_ops_bls12381_gt_mul_cost = Some(52);
3852 cfg.group_ops_bls12381_scalar_div_cost = Some(52);
3853 cfg.group_ops_bls12381_g1_div_cost = Some(52);
3854 cfg.group_ops_bls12381_g2_div_cost = Some(52);
3855 cfg.group_ops_bls12381_gt_div_cost = Some(52);
3856 cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(52);
3857 cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(52);
3858 cfg.group_ops_bls12381_g1_hash_to_cost_per_byte = Some(2);
3859 cfg.group_ops_bls12381_g2_hash_to_cost_per_byte = Some(2);
3860 cfg.group_ops_bls12381_g1_msm_base_cost = Some(52);
3861 cfg.group_ops_bls12381_g2_msm_base_cost = Some(52);
3862 cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(52);
3863 cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(52);
3864 cfg.group_ops_bls12381_msm_max_len = Some(32);
3865 cfg.group_ops_bls12381_pairing_cost = Some(52);
3866 }
3867 42 => {}
3868 43 => {
3869 cfg.feature_flags.zklogin_max_epoch_upper_bound_delta = Some(30);
3870 cfg.max_meter_ticks_per_package = Some(16_000_000);
3871 }
3872 44 => {
3873 cfg.feature_flags.include_consensus_digest_in_prologue = true;
3875 if chain != Chain::Mainnet {
3877 cfg.feature_flags.consensus_choice = ConsensusChoice::SwapEachEpoch;
3878 }
3879 }
3880 45 => {
3881 if chain != Chain::Testnet && chain != Chain::Mainnet {
3883 cfg.feature_flags.consensus_network = ConsensusNetwork::Tonic;
3884 }
3885
3886 if chain != Chain::Mainnet {
3887 cfg.feature_flags.mysticeti_leader_scoring_and_schedule = true;
3889 }
3890 cfg.min_move_binary_format_version = Some(6);
3891 cfg.feature_flags.accept_zklogin_in_multisig = true;
3892
3893 if chain != Chain::Mainnet && chain != Chain::Testnet {
3897 cfg.feature_flags.bridge = true;
3898 }
3899 }
3900 46 => {
3901 if chain != Chain::Mainnet {
3903 cfg.feature_flags.bridge = true;
3904 }
3905
3906 cfg.feature_flags.reshare_at_same_initial_version = true;
3908 }
3909 47 => {}
3910 48 => {
3911 cfg.feature_flags.consensus_network = ConsensusNetwork::Tonic;
3913
3914 cfg.feature_flags.resolve_abort_locations_to_package_id = true;
3916
3917 if chain != Chain::Mainnet {
3919 cfg.feature_flags.random_beacon = true;
3920 cfg.random_beacon_reduction_lower_bound = Some(1600);
3921 cfg.random_beacon_dkg_timeout_round = Some(3000);
3922 cfg.random_beacon_min_round_interval_ms = Some(200);
3923 }
3924
3925 cfg.feature_flags.mysticeti_use_committed_subdag_digest = true;
3927 }
3928 49 => {
3929 if chain != Chain::Testnet && chain != Chain::Mainnet {
3930 cfg.move_binary_format_version = Some(7);
3931 }
3932
3933 if chain != Chain::Mainnet && chain != Chain::Testnet {
3935 cfg.feature_flags.enable_vdf = true;
3936 cfg.vdf_verify_vdf_cost = Some(1500);
3939 cfg.vdf_hash_to_input_cost = Some(100);
3940 }
3941
3942 if chain != Chain::Testnet && chain != Chain::Mainnet {
3944 cfg.feature_flags
3945 .record_consensus_determined_version_assignments_in_prologue = true;
3946 }
3947
3948 if chain != Chain::Mainnet {
3950 cfg.feature_flags.consensus_choice = ConsensusChoice::Mysticeti;
3951 }
3952
3953 cfg.feature_flags.fresh_vm_on_framework_upgrade = true;
3955 }
3956 50 => {
3957 if chain != Chain::Mainnet {
3959 cfg.checkpoint_summary_version_specific_data = Some(1);
3960 cfg.min_checkpoint_interval_ms = Some(200);
3961 }
3962
3963 if chain != Chain::Testnet && chain != Chain::Mainnet {
3965 cfg.feature_flags
3966 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = true;
3967 }
3968
3969 cfg.feature_flags.mysticeti_num_leaders_per_round = Some(1);
3970
3971 cfg.max_deferral_rounds_for_congestion_control = Some(10);
3973 }
3974 51 => {
3975 cfg.random_beacon_dkg_version = Some(1);
3976
3977 if chain != Chain::Testnet && chain != Chain::Mainnet {
3978 cfg.feature_flags.enable_coin_deny_list_v2 = true;
3979 }
3980 }
3981 52 => {
3982 if chain != Chain::Mainnet {
3983 cfg.feature_flags.soft_bundle = true;
3984 cfg.max_soft_bundle_size = Some(5);
3985 }
3986
3987 cfg.config_read_setting_impl_cost_base = Some(100);
3988 cfg.config_read_setting_impl_cost_per_byte = Some(40);
3989
3990 if chain != Chain::Testnet && chain != Chain::Mainnet {
3992 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(100);
3993 cfg.feature_flags.per_object_congestion_control_mode =
3994 PerObjectCongestionControlMode::TotalTxCount;
3995 }
3996
3997 cfg.feature_flags.consensus_choice = ConsensusChoice::Mysticeti;
3999
4000 cfg.feature_flags.mysticeti_leader_scoring_and_schedule = true;
4002
4003 cfg.checkpoint_summary_version_specific_data = Some(1);
4005 cfg.min_checkpoint_interval_ms = Some(200);
4006
4007 if chain != Chain::Mainnet {
4009 cfg.feature_flags
4010 .record_consensus_determined_version_assignments_in_prologue = true;
4011 cfg.feature_flags
4012 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = true;
4013 }
4014 if chain != Chain::Mainnet {
4016 cfg.move_binary_format_version = Some(7);
4017 }
4018
4019 if chain != Chain::Testnet && chain != Chain::Mainnet {
4020 cfg.feature_flags.passkey_auth = true;
4021 }
4022 cfg.feature_flags.enable_coin_deny_list_v2 = true;
4023 }
4024 53 => {
4025 cfg.bridge_should_try_to_finalize_committee = Some(chain != Chain::Mainnet);
4027
4028 cfg.feature_flags
4030 .record_consensus_determined_version_assignments_in_prologue = true;
4031 cfg.feature_flags
4032 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = true;
4033
4034 if chain == Chain::Unknown {
4035 cfg.feature_flags.authority_capabilities_v2 = true;
4036 }
4037
4038 if chain != Chain::Mainnet {
4040 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(100);
4041 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(10);
4042 cfg.feature_flags.per_object_congestion_control_mode =
4043 PerObjectCongestionControlMode::TotalTxCount;
4044 }
4045
4046 cfg.bcs_per_byte_serialized_cost = Some(2);
4048 cfg.bcs_legacy_min_output_size_cost = Some(1);
4049 cfg.bcs_failure_cost = Some(52);
4050 cfg.debug_print_base_cost = Some(52);
4051 cfg.debug_print_stack_trace_base_cost = Some(52);
4052 cfg.hash_sha2_256_base_cost = Some(52);
4053 cfg.hash_sha2_256_per_byte_cost = Some(2);
4054 cfg.hash_sha2_256_legacy_min_input_len_cost = Some(1);
4055 cfg.hash_sha3_256_base_cost = Some(52);
4056 cfg.hash_sha3_256_per_byte_cost = Some(2);
4057 cfg.hash_sha3_256_legacy_min_input_len_cost = Some(1);
4058 cfg.type_name_get_base_cost = Some(52);
4059 cfg.type_name_get_per_byte_cost = Some(2);
4060 cfg.string_check_utf8_base_cost = Some(52);
4061 cfg.string_check_utf8_per_byte_cost = Some(2);
4062 cfg.string_is_char_boundary_base_cost = Some(52);
4063 cfg.string_sub_string_base_cost = Some(52);
4064 cfg.string_sub_string_per_byte_cost = Some(2);
4065 cfg.string_index_of_base_cost = Some(52);
4066 cfg.string_index_of_per_byte_pattern_cost = Some(2);
4067 cfg.string_index_of_per_byte_searched_cost = Some(2);
4068 cfg.vector_empty_base_cost = Some(52);
4069 cfg.vector_length_base_cost = Some(52);
4070 cfg.vector_push_back_base_cost = Some(52);
4071 cfg.vector_push_back_legacy_per_abstract_memory_unit_cost = Some(2);
4072 cfg.vector_borrow_base_cost = Some(52);
4073 cfg.vector_pop_back_base_cost = Some(52);
4074 cfg.vector_destroy_empty_base_cost = Some(52);
4075 cfg.vector_swap_base_cost = Some(52);
4076 }
4077 54 => {
4078 cfg.feature_flags.random_beacon = true;
4080 cfg.random_beacon_reduction_lower_bound = Some(1000);
4081 cfg.random_beacon_dkg_timeout_round = Some(3000);
4082 cfg.random_beacon_min_round_interval_ms = Some(500);
4083
4084 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(100);
4086 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(10);
4087 cfg.feature_flags.per_object_congestion_control_mode =
4088 PerObjectCongestionControlMode::TotalTxCount;
4089
4090 cfg.feature_flags.soft_bundle = true;
4092 cfg.max_soft_bundle_size = Some(5);
4093 }
4094 55 => {
4095 cfg.move_binary_format_version = Some(7);
4097
4098 cfg.consensus_max_transactions_in_block_bytes = Some(512 * 1024);
4100 cfg.consensus_max_num_transactions_in_block = Some(512);
4103
4104 cfg.feature_flags.rethrow_serialization_type_layout_errors = true;
4105 }
4106 56 => {
4107 if chain == Chain::Mainnet {
4108 cfg.feature_flags.bridge = true;
4109 }
4110 }
4111 57 => {
4112 cfg.random_beacon_reduction_lower_bound = Some(800);
4114 }
4115 58 => {
4116 if chain == Chain::Mainnet {
4117 cfg.bridge_should_try_to_finalize_committee = Some(true);
4118 }
4119
4120 if chain != Chain::Mainnet && chain != Chain::Testnet {
4121 cfg.feature_flags
4123 .consensus_distributed_vote_scoring_strategy = true;
4124 }
4125 }
4126 59 => {
4127 cfg.feature_flags.consensus_round_prober = true;
4129 }
4130 60 => {
4131 cfg.max_type_to_layout_nodes = Some(512);
4132 cfg.feature_flags.validate_identifier_inputs = true;
4133 }
4134 61 => {
4135 if chain != Chain::Mainnet {
4136 cfg.feature_flags
4138 .consensus_distributed_vote_scoring_strategy = true;
4139 }
4140 cfg.random_beacon_reduction_lower_bound = Some(700);
4142
4143 if chain != Chain::Mainnet && chain != Chain::Testnet {
4144 cfg.feature_flags.mysticeti_fastpath = true;
4146 }
4147 }
4148 62 => {
4149 cfg.feature_flags.relocate_event_module = true;
4150 }
4151 63 => {
4152 cfg.feature_flags.per_object_congestion_control_mode =
4153 PerObjectCongestionControlMode::TotalGasBudgetWithCap;
4154 cfg.gas_budget_based_txn_cost_cap_factor = Some(400_000);
4155 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(18_500_000);
4156 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(240_000_000);
4157 }
4158 64 => {
4159 cfg.feature_flags.per_object_congestion_control_mode =
4160 PerObjectCongestionControlMode::TotalTxCount;
4161 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(40);
4162 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(3);
4163 }
4164 65 => {
4165 cfg.feature_flags
4167 .consensus_distributed_vote_scoring_strategy = true;
4168 }
4169 66 => {
4170 if chain == Chain::Mainnet {
4171 cfg.feature_flags
4173 .consensus_distributed_vote_scoring_strategy = false;
4174 }
4175 }
4176 67 => {
4177 cfg.feature_flags
4179 .consensus_distributed_vote_scoring_strategy = true;
4180 }
4181 68 => {
4182 cfg.group_ops_bls12381_g1_to_uncompressed_g1_cost = Some(26);
4183 cfg.group_ops_bls12381_uncompressed_g1_to_g1_cost = Some(52);
4184 cfg.group_ops_bls12381_uncompressed_g1_sum_base_cost = Some(26);
4185 cfg.group_ops_bls12381_uncompressed_g1_sum_cost_per_term = Some(13);
4186 cfg.group_ops_bls12381_uncompressed_g1_sum_max_terms = Some(2000);
4187
4188 if chain != Chain::Mainnet && chain != Chain::Testnet {
4189 cfg.feature_flags.uncompressed_g1_group_elements = true;
4190 }
4191
4192 cfg.feature_flags.per_object_congestion_control_mode =
4193 PerObjectCongestionControlMode::TotalGasBudgetWithCap;
4194 cfg.gas_budget_based_txn_cost_cap_factor = Some(400_000);
4195 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(18_500_000);
4196 cfg.max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit =
4197 Some(3_700_000); cfg.max_txn_cost_overage_per_object_in_commit = Some(u64::MAX);
4199 cfg.gas_budget_based_txn_cost_absolute_cap_commit_count = Some(50);
4200
4201 cfg.random_beacon_reduction_lower_bound = Some(500);
4203
4204 cfg.feature_flags.disallow_new_modules_in_deps_only_packages = true;
4205 }
4206 69 => {
4207 cfg.consensus_voting_rounds = Some(40);
4209
4210 if chain != Chain::Mainnet && chain != Chain::Testnet {
4211 cfg.feature_flags.consensus_smart_ancestor_selection = true;
4213 }
4214
4215 if chain != Chain::Mainnet {
4216 cfg.feature_flags.uncompressed_g1_group_elements = true;
4217 }
4218 }
4219 70 => {
4220 if chain != Chain::Mainnet {
4221 cfg.feature_flags.consensus_smart_ancestor_selection = true;
4223 cfg.feature_flags
4225 .consensus_round_prober_probe_accepted_rounds = true;
4226 }
4227
4228 cfg.poseidon_bn254_cost_per_block = Some(388);
4229
4230 cfg.gas_model_version = Some(9);
4231 cfg.feature_flags.native_charging_v2 = true;
4232 cfg.bls12381_bls12381_min_sig_verify_cost_base = Some(44064);
4233 cfg.bls12381_bls12381_min_pk_verify_cost_base = Some(49282);
4234 cfg.ecdsa_k1_secp256k1_verify_keccak256_cost_base = Some(1470);
4235 cfg.ecdsa_k1_secp256k1_verify_sha256_cost_base = Some(1470);
4236 cfg.ecdsa_r1_secp256r1_verify_sha256_cost_base = Some(4225);
4237 cfg.ecdsa_r1_secp256r1_verify_keccak256_cost_base = Some(4225);
4238 cfg.ecvrf_ecvrf_verify_cost_base = Some(4848);
4239 cfg.ed25519_ed25519_verify_cost_base = Some(1802);
4240
4241 cfg.ecdsa_r1_ecrecover_keccak256_cost_base = Some(1173);
4243 cfg.ecdsa_r1_ecrecover_sha256_cost_base = Some(1173);
4244 cfg.ecdsa_k1_ecrecover_keccak256_cost_base = Some(500);
4245 cfg.ecdsa_k1_ecrecover_sha256_cost_base = Some(500);
4246
4247 cfg.groth16_prepare_verifying_key_bls12381_cost_base = Some(53838);
4248 cfg.groth16_prepare_verifying_key_bn254_cost_base = Some(82010);
4249 cfg.groth16_verify_groth16_proof_internal_bls12381_cost_base = Some(72090);
4250 cfg.groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input =
4251 Some(8213);
4252 cfg.groth16_verify_groth16_proof_internal_bn254_cost_base = Some(115502);
4253 cfg.groth16_verify_groth16_proof_internal_bn254_cost_per_public_input =
4254 Some(9484);
4255
4256 cfg.hash_keccak256_cost_base = Some(10);
4257 cfg.hash_blake2b256_cost_base = Some(10);
4258
4259 cfg.group_ops_bls12381_decode_scalar_cost = Some(7);
4261 cfg.group_ops_bls12381_decode_g1_cost = Some(2848);
4262 cfg.group_ops_bls12381_decode_g2_cost = Some(3770);
4263 cfg.group_ops_bls12381_decode_gt_cost = Some(3068);
4264
4265 cfg.group_ops_bls12381_scalar_add_cost = Some(10);
4266 cfg.group_ops_bls12381_g1_add_cost = Some(1556);
4267 cfg.group_ops_bls12381_g2_add_cost = Some(3048);
4268 cfg.group_ops_bls12381_gt_add_cost = Some(188);
4269
4270 cfg.group_ops_bls12381_scalar_sub_cost = Some(10);
4271 cfg.group_ops_bls12381_g1_sub_cost = Some(1550);
4272 cfg.group_ops_bls12381_g2_sub_cost = Some(3019);
4273 cfg.group_ops_bls12381_gt_sub_cost = Some(497);
4274
4275 cfg.group_ops_bls12381_scalar_mul_cost = Some(11);
4276 cfg.group_ops_bls12381_g1_mul_cost = Some(4842);
4277 cfg.group_ops_bls12381_g2_mul_cost = Some(9108);
4278 cfg.group_ops_bls12381_gt_mul_cost = Some(27490);
4279
4280 cfg.group_ops_bls12381_scalar_div_cost = Some(91);
4281 cfg.group_ops_bls12381_g1_div_cost = Some(5091);
4282 cfg.group_ops_bls12381_g2_div_cost = Some(9206);
4283 cfg.group_ops_bls12381_gt_div_cost = Some(27804);
4284
4285 cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(2962);
4286 cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(8688);
4287
4288 cfg.group_ops_bls12381_g1_msm_base_cost = Some(62648);
4289 cfg.group_ops_bls12381_g2_msm_base_cost = Some(131192);
4290 cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(1333);
4291 cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(3216);
4292
4293 cfg.group_ops_bls12381_uncompressed_g1_to_g1_cost = Some(677);
4294 cfg.group_ops_bls12381_g1_to_uncompressed_g1_cost = Some(2099);
4295 cfg.group_ops_bls12381_uncompressed_g1_sum_base_cost = Some(77);
4296 cfg.group_ops_bls12381_uncompressed_g1_sum_cost_per_term = Some(26);
4297
4298 cfg.group_ops_bls12381_pairing_cost = Some(26897);
4299 cfg.group_ops_bls12381_uncompressed_g1_sum_max_terms = Some(1200);
4300
4301 cfg.validator_validate_metadata_cost_base = Some(20000);
4302 }
4303 71 => {
4304 cfg.sip_45_consensus_amplification_threshold = Some(5);
4305
4306 cfg.allowed_txn_cost_overage_burst_per_object_in_commit = Some(185_000_000);
4308 }
4309 72 => {
4310 cfg.feature_flags.convert_type_argument_error = true;
4311
4312 cfg.max_tx_gas = Some(50_000_000_000_000);
4315 cfg.max_gas_price = Some(50_000_000_000);
4317
4318 cfg.feature_flags.variant_nodes = true;
4319 }
4320 73 => {
4321 cfg.use_object_per_epoch_marker_table_v2 = Some(true);
4323
4324 if chain != Chain::Mainnet && chain != Chain::Testnet {
4325 cfg.consensus_gc_depth = Some(60);
4328 }
4329
4330 if chain != Chain::Mainnet {
4331 cfg.feature_flags.consensus_zstd_compression = true;
4333 }
4334
4335 cfg.feature_flags.consensus_smart_ancestor_selection = true;
4337 cfg.feature_flags
4339 .consensus_round_prober_probe_accepted_rounds = true;
4340
4341 cfg.feature_flags.per_object_congestion_control_mode =
4343 PerObjectCongestionControlMode::TotalGasBudgetWithCap;
4344 cfg.gas_budget_based_txn_cost_cap_factor = Some(400_000);
4345 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(37_000_000);
4346 cfg.max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit =
4347 Some(7_400_000); cfg.max_txn_cost_overage_per_object_in_commit = Some(u64::MAX);
4349 cfg.gas_budget_based_txn_cost_absolute_cap_commit_count = Some(50);
4350 cfg.allowed_txn_cost_overage_burst_per_object_in_commit = Some(370_000_000);
4351 }
4352 74 => {
4353 if chain != Chain::Mainnet && chain != Chain::Testnet {
4355 cfg.feature_flags.enable_nitro_attestation = true;
4356 }
4357 cfg.nitro_attestation_parse_base_cost = Some(53 * 50);
4358 cfg.nitro_attestation_parse_cost_per_byte = Some(50);
4359 cfg.nitro_attestation_verify_base_cost = Some(49632 * 50);
4360 cfg.nitro_attestation_verify_cost_per_cert = Some(52369 * 50);
4361
4362 cfg.feature_flags.consensus_zstd_compression = true;
4364
4365 if chain != Chain::Mainnet && chain != Chain::Testnet {
4366 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
4367 }
4368 }
4369 75 => {
4370 if chain != Chain::Mainnet {
4371 cfg.feature_flags.passkey_auth = true;
4372 }
4373 }
4374 76 => {
4375 if chain != Chain::Mainnet && chain != Chain::Testnet {
4376 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
4377 cfg.consensus_commit_rate_estimation_window_size = Some(10);
4378 }
4379 cfg.feature_flags.minimize_child_object_mutations = true;
4380
4381 if chain != Chain::Mainnet {
4382 cfg.feature_flags.accept_passkey_in_multisig = true;
4383 }
4384 }
4385 77 => {
4386 cfg.feature_flags.uncompressed_g1_group_elements = true;
4387
4388 if chain != Chain::Mainnet {
4389 cfg.consensus_gc_depth = Some(60);
4390 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
4391 }
4392 }
4393 78 => {
4394 cfg.feature_flags.move_native_context = true;
4395 cfg.tx_context_fresh_id_cost_base = Some(52);
4396 cfg.tx_context_sender_cost_base = Some(30);
4397 cfg.tx_context_epoch_cost_base = Some(30);
4398 cfg.tx_context_epoch_timestamp_ms_cost_base = Some(30);
4399 cfg.tx_context_sponsor_cost_base = Some(30);
4400 cfg.tx_context_gas_price_cost_base = Some(30);
4401 cfg.tx_context_gas_budget_cost_base = Some(30);
4402 cfg.tx_context_ids_created_cost_base = Some(30);
4403 cfg.tx_context_replace_cost_base = Some(30);
4404 cfg.gas_model_version = Some(10);
4405
4406 if chain != Chain::Mainnet {
4407 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
4408 cfg.consensus_commit_rate_estimation_window_size = Some(10);
4409
4410 cfg.feature_flags.per_object_congestion_control_mode =
4412 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4413 ExecutionTimeEstimateParams {
4414 target_utilization: 30,
4415 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4417 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4419 stored_observations_limit: u64::MAX,
4420 stake_weighted_median_threshold: 0,
4421 default_none_duration_for_new_keys: false,
4422 observations_chunk_size: None,
4423 },
4424 );
4425 }
4426 }
4427 79 => {
4428 if chain != Chain::Mainnet {
4429 cfg.feature_flags.consensus_median_based_commit_timestamp = true;
4430
4431 cfg.consensus_bad_nodes_stake_threshold = Some(30);
4434
4435 cfg.feature_flags.consensus_batched_block_sync = true;
4436
4437 cfg.feature_flags.enable_nitro_attestation = true
4439 }
4440 cfg.feature_flags.normalize_ptb_arguments = true;
4441
4442 cfg.consensus_gc_depth = Some(60);
4443 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
4444 }
4445 80 => {
4446 cfg.max_ptb_value_size = Some(1024 * 1024);
4447 }
4448 81 => {
4449 cfg.feature_flags.consensus_median_based_commit_timestamp = true;
4450 cfg.feature_flags.enforce_checkpoint_timestamp_monotonicity = true;
4451 cfg.consensus_bad_nodes_stake_threshold = Some(30)
4452 }
4453 82 => {
4454 cfg.feature_flags.max_ptb_value_size_v2 = true;
4455 }
4456 83 => {
4457 if chain == Chain::Mainnet {
4458 let aliased: [u8; 32] = Hex::decode(
4460 "0x0b2da327ba6a4cacbe75dddd50e6e8bbf81d6496e92d66af9154c61c77f7332f",
4461 )
4462 .unwrap()
4463 .try_into()
4464 .unwrap();
4465
4466 cfg.aliased_addresses.push(AliasedAddress {
4468 original: Hex::decode("0xcd8962dad278d8b50fa0f9eb0186bfa4cbdecc6d59377214c88d0286a0ac9562").unwrap().try_into().unwrap(),
4469 aliased,
4470 allowed_tx_digests: vec![
4471 Base58::decode("B2eGLFoMHgj93Ni8dAJBfqGzo8EWSTLBesZzhEpTPA4").unwrap().try_into().unwrap(),
4472 ],
4473 });
4474
4475 cfg.aliased_addresses.push(AliasedAddress {
4476 original: Hex::decode("0xe28b50cef1d633ea43d3296a3f6b67ff0312a5f1a99f0af753c85b8b5de8ff06").unwrap().try_into().unwrap(),
4477 aliased,
4478 allowed_tx_digests: vec![
4479 Base58::decode("J4QqSAgp7VrQtQpMy5wDX4QGsCSEZu3U5KuDAkbESAge").unwrap().try_into().unwrap(),
4480 ],
4481 });
4482 }
4483
4484 if chain != Chain::Mainnet {
4487 cfg.feature_flags.resolve_type_input_ids_to_defining_id = true;
4488 cfg.transfer_party_transfer_internal_cost_base = Some(52);
4489
4490 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
4492 cfg.consensus_commit_rate_estimation_window_size = Some(10);
4493 cfg.feature_flags.per_object_congestion_control_mode =
4494 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4495 ExecutionTimeEstimateParams {
4496 target_utilization: 30,
4497 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4499 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4501 stored_observations_limit: u64::MAX,
4502 stake_weighted_median_threshold: 0,
4503 default_none_duration_for_new_keys: false,
4504 observations_chunk_size: None,
4505 },
4506 );
4507
4508 cfg.feature_flags.consensus_batched_block_sync = true;
4510
4511 cfg.feature_flags.enable_nitro_attestation_upgraded_parsing = true;
4514 cfg.feature_flags.enable_nitro_attestation = true;
4515 }
4516 }
4517 84 => {
4518 if chain == Chain::Mainnet {
4519 cfg.feature_flags.resolve_type_input_ids_to_defining_id = true;
4520 cfg.transfer_party_transfer_internal_cost_base = Some(52);
4521
4522 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
4524 cfg.consensus_commit_rate_estimation_window_size = Some(10);
4525 cfg.feature_flags.per_object_congestion_control_mode =
4526 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4527 ExecutionTimeEstimateParams {
4528 target_utilization: 30,
4529 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4531 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4533 stored_observations_limit: u64::MAX,
4534 stake_weighted_median_threshold: 0,
4535 default_none_duration_for_new_keys: false,
4536 observations_chunk_size: None,
4537 },
4538 );
4539
4540 cfg.feature_flags.consensus_batched_block_sync = true;
4542
4543 cfg.feature_flags.enable_nitro_attestation_upgraded_parsing = true;
4546 cfg.feature_flags.enable_nitro_attestation = true;
4547 }
4548
4549 cfg.feature_flags.per_object_congestion_control_mode =
4551 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4552 ExecutionTimeEstimateParams {
4553 target_utilization: 30,
4554 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4556 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4558 stored_observations_limit: 20,
4559 stake_weighted_median_threshold: 0,
4560 default_none_duration_for_new_keys: false,
4561 observations_chunk_size: None,
4562 },
4563 );
4564 cfg.feature_flags.allow_unbounded_system_objects = true;
4565 }
4566 85 => {
4567 if chain != Chain::Mainnet && chain != Chain::Testnet {
4568 cfg.feature_flags.enable_party_transfer = true;
4569 }
4570
4571 cfg.feature_flags
4572 .record_consensus_determined_version_assignments_in_prologue_v2 = true;
4573 cfg.feature_flags.disallow_self_identifier = true;
4574 cfg.feature_flags.per_object_congestion_control_mode =
4575 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4576 ExecutionTimeEstimateParams {
4577 target_utilization: 50,
4578 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4580 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4582 stored_observations_limit: 20,
4583 stake_weighted_median_threshold: 0,
4584 default_none_duration_for_new_keys: false,
4585 observations_chunk_size: None,
4586 },
4587 );
4588 }
4589 86 => {
4590 cfg.feature_flags.type_tags_in_object_runtime = true;
4591 cfg.max_move_enum_variants = Some(move_core_types::VARIANT_COUNT_MAX);
4592
4593 cfg.feature_flags.per_object_congestion_control_mode =
4595 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4596 ExecutionTimeEstimateParams {
4597 target_utilization: 50,
4598 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4600 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4602 stored_observations_limit: 20,
4603 stake_weighted_median_threshold: 3334,
4604 default_none_duration_for_new_keys: false,
4605 observations_chunk_size: None,
4606 },
4607 );
4608 if chain != Chain::Mainnet {
4610 cfg.feature_flags.enable_party_transfer = true;
4611 }
4612 }
4613 87 => {
4614 if chain == Chain::Mainnet {
4615 cfg.feature_flags.record_time_estimate_processed = true;
4616 }
4617 cfg.feature_flags.better_adapter_type_resolution_errors = true;
4618 }
4619 88 => {
4620 cfg.feature_flags.record_time_estimate_processed = true;
4621 cfg.tx_context_rgp_cost_base = Some(30);
4622 cfg.feature_flags
4623 .ignore_execution_time_observations_after_certs_closed = true;
4624
4625 cfg.feature_flags.per_object_congestion_control_mode =
4628 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4629 ExecutionTimeEstimateParams {
4630 target_utilization: 50,
4631 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4633 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4635 stored_observations_limit: 20,
4636 stake_weighted_median_threshold: 3334,
4637 default_none_duration_for_new_keys: true,
4638 observations_chunk_size: None,
4639 },
4640 );
4641 }
4642 89 => {
4643 cfg.feature_flags.dependency_linkage_error = true;
4644 cfg.feature_flags.additional_multisig_checks = true;
4645 }
4646 90 => {
4647 cfg.max_gas_price_rgp_factor_for_aborted_transactions = Some(100);
4649 cfg.feature_flags.debug_fatal_on_move_invariant_violation = true;
4650 cfg.feature_flags.additional_consensus_digest_indirect_state = true;
4651 cfg.feature_flags.accept_passkey_in_multisig = true;
4652 cfg.feature_flags.passkey_auth = true;
4653 cfg.feature_flags.check_for_init_during_upgrade = true;
4654
4655 if chain != Chain::Mainnet {
4657 cfg.feature_flags.mysticeti_fastpath = true;
4658 }
4659 }
4660 91 => {
4661 cfg.feature_flags.per_command_shared_object_transfer_rules = true;
4662 }
4663 92 => {
4664 cfg.feature_flags.per_command_shared_object_transfer_rules = false;
4665 }
4666 93 => {
4667 cfg.feature_flags
4668 .consensus_checkpoint_signature_key_includes_digest = true;
4669 }
4670 94 => {
4671 cfg.feature_flags.per_object_congestion_control_mode =
4673 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4674 ExecutionTimeEstimateParams {
4675 target_utilization: 50,
4676 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4678 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4680 stored_observations_limit: 18,
4681 stake_weighted_median_threshold: 3334,
4682 default_none_duration_for_new_keys: true,
4683 observations_chunk_size: None,
4684 },
4685 );
4686
4687 cfg.feature_flags.enable_party_transfer = true;
4689 }
4690 95 => {
4691 cfg.type_name_id_base_cost = Some(52);
4692
4693 cfg.max_transactions_per_checkpoint = Some(20_000);
4695 }
4696 96 => {
4697 if chain != Chain::Mainnet && chain != Chain::Testnet {
4699 cfg.feature_flags
4700 .include_checkpoint_artifacts_digest_in_summary = true;
4701 }
4702 cfg.feature_flags.correct_gas_payment_limit_check = true;
4703 cfg.feature_flags.authority_capabilities_v2 = true;
4704 cfg.feature_flags.use_mfp_txns_in_load_initial_object_debts = true;
4705 cfg.feature_flags.cancel_for_failed_dkg_early = true;
4706 cfg.feature_flags.enable_coin_registry = true;
4707
4708 cfg.feature_flags.mysticeti_fastpath = true;
4710 }
4711 97 => {
4712 cfg.feature_flags.additional_borrow_checks = true;
4713 }
4714 98 => {
4715 cfg.event_emit_auth_stream_cost = Some(52);
4716 cfg.feature_flags.better_loader_errors = true;
4717 cfg.feature_flags.generate_df_type_layouts = true;
4718 }
4719 99 => {
4720 cfg.feature_flags.use_new_commit_handler = true;
4721 }
4722 100 => {
4723 cfg.feature_flags.private_generics_verifier_v2 = true;
4724 }
4725 101 => {
4726 cfg.feature_flags.create_root_accumulator_object = true;
4727 cfg.max_updates_per_settlement_txn = Some(100);
4728 if chain != Chain::Mainnet {
4729 cfg.feature_flags.enable_poseidon = true;
4730 }
4731 }
4732 102 => {
4733 cfg.feature_flags.per_object_congestion_control_mode =
4737 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4738 ExecutionTimeEstimateParams {
4739 target_utilization: 50,
4740 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4742 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4744 stored_observations_limit: 180,
4745 stake_weighted_median_threshold: 3334,
4746 default_none_duration_for_new_keys: true,
4747 observations_chunk_size: Some(18),
4748 },
4749 );
4750 cfg.feature_flags.deprecate_global_storage_ops = true;
4751 }
4752 103 => {}
4753 104 => {
4754 cfg.translation_per_command_base_charge = Some(1);
4755 cfg.translation_per_input_base_charge = Some(1);
4756 cfg.translation_pure_input_per_byte_charge = Some(1);
4757 cfg.translation_per_type_node_charge = Some(1);
4758 cfg.translation_per_reference_node_charge = Some(1);
4759 cfg.translation_per_linkage_entry_charge = Some(10);
4760 cfg.gas_model_version = Some(11);
4761 cfg.feature_flags.abstract_size_in_object_runtime = true;
4762 cfg.feature_flags.object_runtime_charge_cache_load_gas = true;
4763 cfg.dynamic_field_hash_type_and_key_cost_base = Some(52);
4764 cfg.dynamic_field_add_child_object_cost_base = Some(52);
4765 cfg.dynamic_field_add_child_object_value_cost_per_byte = Some(1);
4766 cfg.dynamic_field_borrow_child_object_cost_base = Some(52);
4767 cfg.dynamic_field_borrow_child_object_child_ref_cost_per_byte = Some(1);
4768 cfg.dynamic_field_remove_child_object_cost_base = Some(52);
4769 cfg.dynamic_field_remove_child_object_child_cost_per_byte = Some(1);
4770 cfg.dynamic_field_has_child_object_cost_base = Some(52);
4771 cfg.dynamic_field_has_child_object_with_ty_cost_base = Some(52);
4772 cfg.feature_flags.enable_ptb_execution_v2 = true;
4773
4774 cfg.poseidon_bn254_cost_base = Some(260);
4775
4776 cfg.feature_flags.consensus_skip_gced_accept_votes = true;
4777
4778 if chain != Chain::Mainnet {
4779 cfg.feature_flags
4780 .enable_nitro_attestation_all_nonzero_pcrs_parsing = true;
4781 }
4782
4783 cfg.feature_flags
4784 .include_cancelled_randomness_txns_in_prologue = true;
4785 }
4786 105 => {
4787 cfg.feature_flags.enable_multi_epoch_transaction_expiration = true;
4788 cfg.feature_flags.disable_preconsensus_locking = true;
4789
4790 if chain != Chain::Mainnet {
4791 cfg.feature_flags
4792 .enable_nitro_attestation_always_include_required_pcrs_parsing = true;
4793 }
4794 }
4795 106 => {
4796 cfg.accumulator_object_storage_cost = Some(7600);
4798
4799 if chain != Chain::Mainnet && chain != Chain::Testnet {
4800 cfg.feature_flags.enable_accumulators = true;
4801 cfg.feature_flags.enable_address_balance_gas_payments = true;
4802 cfg.feature_flags.enable_authenticated_event_streams = true;
4803 cfg.feature_flags.enable_object_funds_withdraw = true;
4804 }
4805 }
4806 107 => {
4807 cfg.feature_flags
4808 .consensus_skip_gced_blocks_in_direct_finalization = true;
4809
4810 if in_integration_test() {
4812 cfg.consensus_gc_depth = Some(6);
4813 cfg.consensus_max_num_transactions_in_block = Some(8);
4814 }
4815 }
4816 108 => {
4817 cfg.feature_flags.gas_rounding_halve_digits = true;
4818 cfg.feature_flags.flexible_tx_context_positions = true;
4819 cfg.feature_flags.disable_entry_point_signature_check = true;
4820
4821 if chain != Chain::Mainnet {
4822 cfg.feature_flags.address_aliases = true;
4823
4824 cfg.feature_flags.enable_accumulators = true;
4825 cfg.feature_flags.enable_address_balance_gas_payments = true;
4826 }
4827
4828 cfg.feature_flags.enable_poseidon = true;
4829 }
4830 109 => {
4831 cfg.binary_variant_handles = Some(1024);
4832 cfg.binary_variant_instantiation_handles = Some(1024);
4833 cfg.feature_flags.restrict_hot_or_not_entry_functions = true;
4834 }
4835 110 => {
4836 cfg.feature_flags
4837 .enable_nitro_attestation_all_nonzero_pcrs_parsing = true;
4838 cfg.feature_flags
4839 .enable_nitro_attestation_always_include_required_pcrs_parsing = true;
4840 if chain != Chain::Mainnet && chain != Chain::Testnet {
4841 cfg.feature_flags.split_checkpoints_in_consensus_handler = true;
4842 }
4843 cfg.feature_flags.validate_zklogin_public_identifier = true;
4844 cfg.feature_flags.fix_checkpoint_signature_mapping = true;
4845 cfg.feature_flags
4846 .consensus_always_accept_system_transactions = true;
4847 if chain != Chain::Mainnet {
4848 cfg.feature_flags.enable_object_funds_withdraw = true;
4849 }
4850 }
4851 111 => {
4852 cfg.feature_flags.validator_metadata_verify_v2 = true;
4853 }
4854 112 => {
4855 cfg.group_ops_ristretto_decode_scalar_cost = Some(7);
4856 cfg.group_ops_ristretto_decode_point_cost = Some(200);
4857 cfg.group_ops_ristretto_scalar_add_cost = Some(10);
4858 cfg.group_ops_ristretto_point_add_cost = Some(500);
4859 cfg.group_ops_ristretto_scalar_sub_cost = Some(10);
4860 cfg.group_ops_ristretto_point_sub_cost = Some(500);
4861 cfg.group_ops_ristretto_scalar_mul_cost = Some(11);
4862 cfg.group_ops_ristretto_point_mul_cost = Some(1200);
4863 cfg.group_ops_ristretto_scalar_div_cost = Some(151);
4864 cfg.group_ops_ristretto_point_div_cost = Some(2500);
4865
4866 if chain != Chain::Mainnet && chain != Chain::Testnet {
4867 cfg.feature_flags.enable_ristretto255_group_ops = true;
4868 }
4869 }
4870 113 => {
4871 cfg.feature_flags.address_balance_gas_check_rgp_at_signing = true;
4872 if chain != Chain::Mainnet && chain != Chain::Testnet {
4873 cfg.feature_flags.defer_unpaid_amplification = true;
4874 }
4875 }
4876 114 => {
4877 cfg.feature_flags.randomize_checkpoint_tx_limit_in_tests = true;
4878 cfg.feature_flags.address_balance_gas_reject_gas_coin_arg = true;
4879 if chain != Chain::Mainnet {
4880 cfg.feature_flags.split_checkpoints_in_consensus_handler = true;
4881 cfg.feature_flags.enable_authenticated_event_streams = true;
4882 cfg.feature_flags
4883 .include_checkpoint_artifacts_digest_in_summary = true;
4884 }
4885 }
4886 115 => {
4887 cfg.feature_flags.normalize_depth_formula = true;
4888 }
4889 116 => {
4890 cfg.feature_flags.gasless_transaction_drop_safety = true;
4891 cfg.feature_flags.address_aliases = true;
4892 cfg.feature_flags.relax_valid_during_for_owned_inputs = true;
4893 cfg.feature_flags.defer_unpaid_amplification = false;
4895 cfg.feature_flags.enable_display_registry = true;
4896 }
4897 117 => {}
4898 118 => {
4899 cfg.feature_flags.use_coin_party_owner = true;
4900 }
4901 119 => {
4902 cfg.execution_version = Some(4);
4904 cfg.feature_flags.address_balance_gas_reject_gas_coin_arg = false;
4905 cfg.feature_flags.merge_randomness_into_checkpoint = true;
4906 if chain != Chain::Mainnet {
4907 cfg.feature_flags.enable_gasless = true;
4908 cfg.gasless_max_computation_units = Some(50_000);
4909 cfg.gasless_allowed_token_types = Some(vec![]);
4910 cfg.feature_flags.enable_coin_reservation_obj_refs = true;
4911 cfg.feature_flags
4912 .convert_withdrawal_compatibility_ptb_arguments = true;
4913 }
4914 cfg.gasless_max_unused_inputs = Some(1);
4915 cfg.gasless_max_pure_input_bytes = Some(32);
4916 if chain == Chain::Testnet {
4917 cfg.gasless_allowed_token_types = Some(vec![(TESTNET_USDC.to_string(), 0)]);
4918 }
4919 cfg.transfer_receive_object_cost_per_byte = Some(1);
4920 cfg.transfer_receive_object_type_cost_per_byte = Some(2);
4921 }
4922 120 => {
4923 cfg.feature_flags.disallow_jump_orphans = true;
4924 }
4925 121 => {
4926 if chain != Chain::Mainnet {
4928 cfg.feature_flags.defer_unpaid_amplification = true;
4929 cfg.gasless_max_tps = Some(50);
4930 }
4931 cfg.feature_flags
4932 .early_return_receive_object_mismatched_type = true;
4933 }
4934 122 => {
4935 cfg.feature_flags.defer_unpaid_amplification = true;
4937 cfg.verify_bulletproofs_ristretto255_base_cost = Some(30000);
4939 cfg.verify_bulletproofs_ristretto255_cost_per_bit_and_commitment = Some(6500);
4940 if chain != Chain::Mainnet && chain != Chain::Testnet {
4941 cfg.feature_flags.enable_verify_bulletproofs_ristretto255 = true;
4942 }
4943 cfg.feature_flags.gasless_verify_remaining_balance = true;
4944 cfg.include_special_package_amendments = match chain {
4945 Chain::Mainnet => Some(MAINNET_LINKAGE_AMENDMENTS.clone()),
4946 Chain::Testnet => Some(TESTNET_LINKAGE_AMENDMENTS.clone()),
4947 Chain::Unknown => None,
4948 };
4949 cfg.gasless_max_tx_size_bytes = Some(16 * 1024);
4950 cfg.gasless_max_tps = Some(300);
4951 cfg.gasless_max_computation_units = Some(5_000);
4952 }
4953 123 => {
4954 cfg.gas_model_version = Some(13);
4955 }
4956 124 => {
4957 if chain != Chain::Mainnet && chain != Chain::Testnet {
4958 cfg.feature_flags.timestamp_based_epoch_close = true;
4959 }
4960 cfg.gas_model_version = Some(14);
4961 cfg.feature_flags.limit_groth16_pvk_inputs = true;
4962
4963 cfg.feature_flags.enable_accumulators = true;
4969 cfg.feature_flags.enable_address_balance_gas_payments = true;
4970 cfg.feature_flags.enable_authenticated_event_streams = true;
4971 cfg.feature_flags.enable_coin_reservation_obj_refs = true;
4972 cfg.feature_flags.enable_object_funds_withdraw = true;
4973 cfg.feature_flags
4974 .convert_withdrawal_compatibility_ptb_arguments = true;
4975 cfg.feature_flags.split_checkpoints_in_consensus_handler = true;
4976 cfg.feature_flags
4977 .include_checkpoint_artifacts_digest_in_summary = true;
4978 cfg.feature_flags.enable_gasless = true;
4979
4980 if chain == Chain::Mainnet {
4985 cfg.gasless_allowed_token_types = Some(vec![
4986 (MAINNET_USDC.to_string(), 10_000),
4987 (MAINNET_USDSUI.to_string(), 10_000),
4988 (MAINNET_SUI_USDE.to_string(), 10_000),
4989 (MAINNET_USDY.to_string(), 10_000),
4990 (MAINNET_FDUSD.to_string(), 10_000),
4991 (MAINNET_AUSD.to_string(), 10_000),
4992 (MAINNET_USDB.to_string(), 10_000),
4993 ]);
4994 }
4995 }
4996 125 => {
4997 cfg.feature_flags.granular_post_execution_checks = true;
4998 if chain != Chain::Mainnet {
4999 cfg.feature_flags.timestamp_based_epoch_close = true;
5000 }
5001 }
5002 126 => {
5003 cfg.feature_flags.early_exit_on_iffw = true;
5004 }
5005 127 => {
5006 cfg.feature_flags.always_advance_dkg_to_resolution = true;
5007 }
5008 _ => panic!("unsupported version {:?}", version),
5019 }
5020 }
5021
5022 cfg
5023 }
5024
5025 pub fn apply_seeded_test_overrides(&mut self, seed: &[u8; 32]) {
5026 if !self.feature_flags.randomize_checkpoint_tx_limit_in_tests
5027 || !self.feature_flags.split_checkpoints_in_consensus_handler
5028 {
5029 return;
5030 }
5031
5032 if !mysten_common::in_test_configuration() {
5033 return;
5034 }
5035
5036 use rand::{Rng, SeedableRng, rngs::StdRng};
5037 let mut rng = StdRng::from_seed(*seed);
5038 let max_txns = rng.gen_range(10..=100u64);
5039 info!("seeded test override: max_transactions_per_checkpoint = {max_txns}");
5040 self.max_transactions_per_checkpoint = Some(max_txns);
5041 }
5042
5043 pub fn verifier_config(&self, signing_limits: Option<(usize, usize, usize)>) -> VerifierConfig {
5049 let (
5050 max_back_edges_per_function,
5051 max_back_edges_per_module,
5052 sanity_check_with_regex_reference_safety,
5053 ) = if let Some((
5054 max_back_edges_per_function,
5055 max_back_edges_per_module,
5056 sanity_check_with_regex_reference_safety,
5057 )) = signing_limits
5058 {
5059 (
5060 Some(max_back_edges_per_function),
5061 Some(max_back_edges_per_module),
5062 Some(sanity_check_with_regex_reference_safety),
5063 )
5064 } else {
5065 (None, None, None)
5066 };
5067
5068 let additional_borrow_checks = if signing_limits.is_some() {
5069 true
5071 } else {
5072 self.additional_borrow_checks()
5073 };
5074 let deprecate_global_storage_ops = if signing_limits.is_some() {
5075 true
5077 } else {
5078 self.deprecate_global_storage_ops()
5079 };
5080
5081 VerifierConfig {
5082 max_loop_depth: Some(self.max_loop_depth() as usize),
5083 max_generic_instantiation_length: Some(self.max_generic_instantiation_length() as usize),
5084 max_function_parameters: Some(self.max_function_parameters() as usize),
5085 max_basic_blocks: Some(self.max_basic_blocks() as usize),
5086 max_value_stack_size: self.max_value_stack_size() as usize,
5087 max_type_nodes: Some(self.max_type_nodes() as usize),
5088 max_push_size: Some(self.max_push_size() as usize),
5089 max_dependency_depth: Some(self.max_dependency_depth() as usize),
5090 max_fields_in_struct: Some(self.max_fields_in_struct() as usize),
5091 max_function_definitions: Some(self.max_function_definitions() as usize),
5092 max_data_definitions: Some(self.max_struct_definitions() as usize),
5093 max_constant_vector_len: Some(self.max_move_vector_len()),
5094 max_back_edges_per_function,
5095 max_back_edges_per_module,
5096 max_basic_blocks_in_script: None,
5097 max_identifier_len: self.max_move_identifier_len_as_option(), disallow_self_identifier: self.feature_flags.disallow_self_identifier,
5099 allow_receiving_object_id: self.allow_receiving_object_id(),
5100 reject_mutable_random_on_entry_functions: self
5101 .reject_mutable_random_on_entry_functions(),
5102 bytecode_version: self.move_binary_format_version(),
5103 max_variants_in_enum: self.max_move_enum_variants_as_option(),
5104 additional_borrow_checks,
5105 better_loader_errors: self.better_loader_errors(),
5106 private_generics_verifier_v2: self.private_generics_verifier_v2(),
5107 sanity_check_with_regex_reference_safety: sanity_check_with_regex_reference_safety
5108 .map(|limit| limit as u128),
5109 deprecate_global_storage_ops,
5110 disable_entry_point_signature_check: self.disable_entry_point_signature_check(),
5111 switch_to_regex_reference_safety: false,
5112 disallow_jump_orphans: self.disallow_jump_orphans(),
5113 }
5114 }
5115
5116 pub fn binary_config(
5117 &self,
5118 override_deprecate_global_storage_ops_during_deserialization: Option<bool>,
5119 ) -> BinaryConfig {
5120 let deprecate_global_storage_ops =
5121 override_deprecate_global_storage_ops_during_deserialization
5122 .unwrap_or_else(|| self.deprecate_global_storage_ops());
5123 BinaryConfig::new(
5124 self.move_binary_format_version(),
5125 self.min_move_binary_format_version_as_option()
5126 .unwrap_or(VERSION_1),
5127 self.no_extraneous_module_bytes(),
5128 deprecate_global_storage_ops,
5129 TableConfig {
5130 module_handles: self.binary_module_handles_as_option().unwrap_or(u16::MAX),
5131 datatype_handles: self.binary_struct_handles_as_option().unwrap_or(u16::MAX),
5132 function_handles: self.binary_function_handles_as_option().unwrap_or(u16::MAX),
5133 function_instantiations: self
5134 .binary_function_instantiations_as_option()
5135 .unwrap_or(u16::MAX),
5136 signatures: self.binary_signatures_as_option().unwrap_or(u16::MAX),
5137 constant_pool: self.binary_constant_pool_as_option().unwrap_or(u16::MAX),
5138 identifiers: self.binary_identifiers_as_option().unwrap_or(u16::MAX),
5139 address_identifiers: self
5140 .binary_address_identifiers_as_option()
5141 .unwrap_or(u16::MAX),
5142 struct_defs: self.binary_struct_defs_as_option().unwrap_or(u16::MAX),
5143 struct_def_instantiations: self
5144 .binary_struct_def_instantiations_as_option()
5145 .unwrap_or(u16::MAX),
5146 function_defs: self.binary_function_defs_as_option().unwrap_or(u16::MAX),
5147 field_handles: self.binary_field_handles_as_option().unwrap_or(u16::MAX),
5148 field_instantiations: self
5149 .binary_field_instantiations_as_option()
5150 .unwrap_or(u16::MAX),
5151 friend_decls: self.binary_friend_decls_as_option().unwrap_or(u16::MAX),
5152 enum_defs: self.binary_enum_defs_as_option().unwrap_or(u16::MAX),
5153 enum_def_instantiations: self
5154 .binary_enum_def_instantiations_as_option()
5155 .unwrap_or(u16::MAX),
5156 variant_handles: self.binary_variant_handles_as_option().unwrap_or(u16::MAX),
5157 variant_instantiation_handles: self
5158 .binary_variant_instantiation_handles_as_option()
5159 .unwrap_or(u16::MAX),
5160 },
5161 )
5162 }
5163
5164 #[cfg(not(msim))]
5168 pub fn apply_overrides_for_testing(
5169 override_fn: impl Fn(ProtocolVersion, Self) -> Self + Send + Sync + 'static,
5170 ) -> OverrideGuard {
5171 let mut cur = CONFIG_OVERRIDE.lock().unwrap();
5172 assert!(cur.is_none(), "config override already present");
5173 *cur = Some(Box::new(override_fn));
5174 OverrideGuard
5175 }
5176
5177 #[cfg(msim)]
5181 pub fn apply_overrides_for_testing(
5182 override_fn: impl Fn(ProtocolVersion, Self) -> Self + Send + 'static,
5183 ) -> OverrideGuard {
5184 CONFIG_OVERRIDE.with(|ovr| {
5185 let mut cur = ovr.borrow_mut();
5186 assert!(cur.is_none(), "config override already present");
5187 *cur = Some(Box::new(override_fn));
5188 OverrideGuard
5189 })
5190 }
5191
5192 #[cfg(not(msim))]
5193 fn apply_config_override(version: ProtocolVersion, mut ret: Self) -> Self {
5194 if let Some(override_fn) = CONFIG_OVERRIDE.lock().unwrap().as_ref() {
5195 warn!(
5196 "overriding ProtocolConfig settings with custom settings (you should not see this log outside of tests)"
5197 );
5198 ret = override_fn(version, ret);
5199 }
5200 ret
5201 }
5202
5203 #[cfg(msim)]
5204 fn apply_config_override(version: ProtocolVersion, ret: Self) -> Self {
5205 CONFIG_OVERRIDE.with(|ovr| {
5206 if let Some(override_fn) = &*ovr.borrow() {
5207 warn!(
5208 "overriding ProtocolConfig settings with custom settings (you should not see this log outside of tests)"
5209 );
5210 override_fn(version, ret)
5211 } else {
5212 ret
5213 }
5214 })
5215 }
5216}
5217
5218impl ProtocolConfig {
5222 pub fn set_advance_to_highest_supported_protocol_version_for_testing(&mut self, val: bool) {
5223 self.feature_flags
5224 .advance_to_highest_supported_protocol_version = val
5225 }
5226 pub fn set_commit_root_state_digest_supported_for_testing(&mut self, val: bool) {
5227 self.feature_flags.commit_root_state_digest = val
5228 }
5229 pub fn set_zklogin_auth_for_testing(&mut self, val: bool) {
5230 self.feature_flags.zklogin_auth = val
5231 }
5232 pub fn set_enable_jwk_consensus_updates_for_testing(&mut self, val: bool) {
5233 self.feature_flags.enable_jwk_consensus_updates = val
5234 }
5235 pub fn set_random_beacon_for_testing(&mut self, val: bool) {
5236 self.feature_flags.random_beacon = val
5237 }
5238
5239 pub fn set_upgraded_multisig_for_testing(&mut self, val: bool) {
5240 self.feature_flags.upgraded_multisig_supported = val
5241 }
5242 pub fn set_accept_zklogin_in_multisig_for_testing(&mut self, val: bool) {
5243 self.feature_flags.accept_zklogin_in_multisig = val
5244 }
5245
5246 pub fn set_shared_object_deletion_for_testing(&mut self, val: bool) {
5247 self.feature_flags.shared_object_deletion = val;
5248 }
5249
5250 pub fn set_narwhal_new_leader_election_schedule_for_testing(&mut self, val: bool) {
5251 self.feature_flags.narwhal_new_leader_election_schedule = val;
5252 }
5253
5254 pub fn set_receive_object_for_testing(&mut self, val: bool) {
5255 self.feature_flags.receive_objects = val
5256 }
5257 pub fn set_narwhal_certificate_v2_for_testing(&mut self, val: bool) {
5258 self.feature_flags.narwhal_certificate_v2 = val
5259 }
5260 pub fn set_verify_legacy_zklogin_address_for_testing(&mut self, val: bool) {
5261 self.feature_flags.verify_legacy_zklogin_address = val
5262 }
5263
5264 pub fn set_per_object_congestion_control_mode_for_testing(
5265 &mut self,
5266 val: PerObjectCongestionControlMode,
5267 ) {
5268 self.feature_flags.per_object_congestion_control_mode = val;
5269 }
5270
5271 pub fn set_consensus_choice_for_testing(&mut self, val: ConsensusChoice) {
5272 self.feature_flags.consensus_choice = val;
5273 }
5274
5275 pub fn set_consensus_network_for_testing(&mut self, val: ConsensusNetwork) {
5276 self.feature_flags.consensus_network = val;
5277 }
5278
5279 pub fn set_zklogin_max_epoch_upper_bound_delta_for_testing(&mut self, val: Option<u64>) {
5280 self.feature_flags.zklogin_max_epoch_upper_bound_delta = val
5281 }
5282
5283 pub fn set_disable_bridge_for_testing(&mut self) {
5284 self.feature_flags.bridge = false
5285 }
5286
5287 pub fn set_mysticeti_num_leaders_per_round_for_testing(&mut self, val: Option<usize>) {
5288 self.feature_flags.mysticeti_num_leaders_per_round = val;
5289 }
5290
5291 pub fn set_enable_soft_bundle_for_testing(&mut self, val: bool) {
5292 self.feature_flags.soft_bundle = val;
5293 }
5294
5295 pub fn set_passkey_auth_for_testing(&mut self, val: bool) {
5296 self.feature_flags.passkey_auth = val
5297 }
5298
5299 pub fn set_enable_party_transfer_for_testing(&mut self, val: bool) {
5300 self.feature_flags.enable_party_transfer = val
5301 }
5302
5303 pub fn set_consensus_distributed_vote_scoring_strategy_for_testing(&mut self, val: bool) {
5304 self.feature_flags
5305 .consensus_distributed_vote_scoring_strategy = val;
5306 }
5307
5308 pub fn set_consensus_round_prober_for_testing(&mut self, val: bool) {
5309 self.feature_flags.consensus_round_prober = val;
5310 }
5311
5312 pub fn set_disallow_new_modules_in_deps_only_packages_for_testing(&mut self, val: bool) {
5313 self.feature_flags
5314 .disallow_new_modules_in_deps_only_packages = val;
5315 }
5316
5317 pub fn set_correct_gas_payment_limit_check_for_testing(&mut self, val: bool) {
5318 self.feature_flags.correct_gas_payment_limit_check = val;
5319 }
5320
5321 pub fn set_address_aliases_for_testing(&mut self, val: bool) {
5322 self.feature_flags.address_aliases = val;
5323 }
5324
5325 pub fn set_consensus_round_prober_probe_accepted_rounds(&mut self, val: bool) {
5326 self.feature_flags
5327 .consensus_round_prober_probe_accepted_rounds = val;
5328 }
5329
5330 pub fn set_mysticeti_fastpath_for_testing(&mut self, val: bool) {
5331 self.feature_flags.mysticeti_fastpath = val;
5332 }
5333
5334 pub fn set_accept_passkey_in_multisig_for_testing(&mut self, val: bool) {
5335 self.feature_flags.accept_passkey_in_multisig = val;
5336 }
5337
5338 pub fn set_consensus_batched_block_sync_for_testing(&mut self, val: bool) {
5339 self.feature_flags.consensus_batched_block_sync = val;
5340 }
5341
5342 pub fn set_record_time_estimate_processed_for_testing(&mut self, val: bool) {
5343 self.feature_flags.record_time_estimate_processed = val;
5344 }
5345
5346 pub fn set_prepend_prologue_tx_in_consensus_commit_in_checkpoints_for_testing(
5347 &mut self,
5348 val: bool,
5349 ) {
5350 self.feature_flags
5351 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = val;
5352 }
5353
5354 pub fn enable_accumulators_for_testing(&mut self) {
5355 self.feature_flags.enable_accumulators = true;
5356 }
5357
5358 pub fn disable_accumulators_for_testing(&mut self) {
5359 self.feature_flags.enable_accumulators = false;
5360 self.feature_flags.enable_address_balance_gas_payments = false;
5361 }
5362
5363 pub fn enable_coin_reservation_for_testing(&mut self) {
5364 self.feature_flags.enable_coin_reservation_obj_refs = true;
5365 self.feature_flags
5366 .convert_withdrawal_compatibility_ptb_arguments = true;
5367 self.execution_version = Some(self.execution_version.map_or(4, |v| v.max(4)));
5370 }
5371
5372 pub fn disable_coin_reservation_for_testing(&mut self) {
5373 self.feature_flags.enable_coin_reservation_obj_refs = false;
5374 self.feature_flags
5375 .convert_withdrawal_compatibility_ptb_arguments = false;
5376 }
5377
5378 pub fn create_root_accumulator_object_for_testing(&mut self) {
5379 self.feature_flags.create_root_accumulator_object = true;
5380 }
5381
5382 pub fn disable_create_root_accumulator_object_for_testing(&mut self) {
5383 self.feature_flags.create_root_accumulator_object = false;
5384 }
5385
5386 pub fn enable_address_balance_gas_payments_for_testing(&mut self) {
5387 self.feature_flags.enable_accumulators = true;
5388 self.feature_flags.allow_private_accumulator_entrypoints = true;
5389 self.feature_flags.enable_address_balance_gas_payments = true;
5390 self.feature_flags.address_balance_gas_check_rgp_at_signing = true;
5391 self.feature_flags.address_balance_gas_reject_gas_coin_arg = false;
5392 self.execution_version = Some(self.execution_version.map_or(4, |v| v.max(4)))
5393 }
5394
5395 pub fn disable_address_balance_gas_payments_for_testing(&mut self) {
5396 self.feature_flags.enable_address_balance_gas_payments = false;
5397 }
5398
5399 pub fn enable_gasless_for_testing(&mut self) {
5400 self.enable_address_balance_gas_payments_for_testing();
5401 self.feature_flags.enable_gasless = true;
5402 self.feature_flags.gasless_verify_remaining_balance = true;
5403 self.gasless_max_computation_units = Some(5_000);
5404 self.gasless_allowed_token_types = Some(vec![]);
5405 self.gasless_max_tps = Some(1000);
5406 self.gasless_max_tx_size_bytes = Some(16 * 1024);
5407 }
5408
5409 pub fn disable_gasless_for_testing(&mut self) {
5410 self.feature_flags.enable_gasless = false;
5411 self.gasless_max_computation_units = None;
5412 self.gasless_allowed_token_types = None;
5413 }
5414
5415 pub fn enable_multi_epoch_transaction_expiration_for_testing(&mut self) {
5416 self.feature_flags.enable_multi_epoch_transaction_expiration = true;
5417 }
5418
5419 pub fn enable_authenticated_event_streams_for_testing(&mut self) {
5420 self.enable_accumulators_for_testing();
5421 self.feature_flags.enable_authenticated_event_streams = true;
5422 self.feature_flags
5423 .include_checkpoint_artifacts_digest_in_summary = true;
5424 self.feature_flags.split_checkpoints_in_consensus_handler = true;
5425 }
5426
5427 pub fn disable_authenticated_event_streams_for_testing(&mut self) {
5428 self.feature_flags.enable_authenticated_event_streams = false;
5429 }
5430
5431 pub fn disable_randomize_checkpoint_tx_limit_for_testing(&mut self) {
5432 self.feature_flags.randomize_checkpoint_tx_limit_in_tests = false;
5433 }
5434
5435 pub fn enable_non_exclusive_writes_for_testing(&mut self) {
5436 self.feature_flags.enable_non_exclusive_writes = true;
5437 }
5438
5439 pub fn set_relax_valid_during_for_owned_inputs_for_testing(&mut self, val: bool) {
5440 self.feature_flags.relax_valid_during_for_owned_inputs = val;
5441 }
5442
5443 pub fn set_ignore_execution_time_observations_after_certs_closed_for_testing(
5444 &mut self,
5445 val: bool,
5446 ) {
5447 self.feature_flags
5448 .ignore_execution_time_observations_after_certs_closed = val;
5449 }
5450
5451 pub fn set_consensus_checkpoint_signature_key_includes_digest_for_testing(
5452 &mut self,
5453 val: bool,
5454 ) {
5455 self.feature_flags
5456 .consensus_checkpoint_signature_key_includes_digest = val;
5457 }
5458
5459 pub fn set_cancel_for_failed_dkg_early_for_testing(&mut self, val: bool) {
5460 self.feature_flags.cancel_for_failed_dkg_early = val;
5461 }
5462
5463 pub fn set_always_advance_dkg_to_resolution_for_testing(&mut self, val: bool) {
5464 self.feature_flags.always_advance_dkg_to_resolution = val;
5465 }
5466
5467 pub fn set_use_mfp_txns_in_load_initial_object_debts_for_testing(&mut self, val: bool) {
5468 self.feature_flags.use_mfp_txns_in_load_initial_object_debts = val;
5469 }
5470
5471 pub fn set_authority_capabilities_v2_for_testing(&mut self, val: bool) {
5472 self.feature_flags.authority_capabilities_v2 = val;
5473 }
5474
5475 pub fn allow_references_in_ptbs_for_testing(&mut self) {
5476 self.feature_flags.allow_references_in_ptbs = true;
5477 }
5478
5479 pub fn set_consensus_skip_gced_accept_votes_for_testing(&mut self, val: bool) {
5480 self.feature_flags.consensus_skip_gced_accept_votes = val;
5481 }
5482
5483 pub fn set_enable_object_funds_withdraw_for_testing(&mut self, val: bool) {
5484 self.feature_flags.enable_object_funds_withdraw = val;
5485 }
5486
5487 pub fn set_split_checkpoints_in_consensus_handler_for_testing(&mut self, val: bool) {
5488 self.feature_flags.split_checkpoints_in_consensus_handler = val;
5489 }
5490
5491 pub fn set_merge_randomness_into_checkpoint_for_testing(&mut self, val: bool) {
5492 self.feature_flags.merge_randomness_into_checkpoint = val;
5493 }
5494}
5495
5496#[cfg(not(msim))]
5497type OverrideFn = dyn Fn(ProtocolVersion, ProtocolConfig) -> ProtocolConfig + Send + Sync;
5498
5499#[cfg(not(msim))]
5500static CONFIG_OVERRIDE: Mutex<Option<Box<OverrideFn>>> = Mutex::new(None);
5501
5502#[cfg(msim)]
5503type OverrideFn = dyn Fn(ProtocolVersion, ProtocolConfig) -> ProtocolConfig + Send;
5504
5505#[cfg(msim)]
5506thread_local! {
5507 static CONFIG_OVERRIDE: RefCell<Option<Box<OverrideFn>>> = RefCell::new(None);
5508}
5509
5510#[must_use]
5511pub struct OverrideGuard;
5512
5513#[cfg(not(msim))]
5514impl Drop for OverrideGuard {
5515 fn drop(&mut self) {
5516 info!("restoring override fn");
5517 *CONFIG_OVERRIDE.lock().unwrap() = None;
5518 }
5519}
5520
5521#[cfg(msim)]
5522impl Drop for OverrideGuard {
5523 fn drop(&mut self) {
5524 info!("restoring override fn");
5525 CONFIG_OVERRIDE.with(|ovr| {
5526 *ovr.borrow_mut() = None;
5527 });
5528 }
5529}
5530
5531#[derive(PartialEq, Eq)]
5534pub enum LimitThresholdCrossed {
5535 None,
5536 Soft(u128, u128),
5537 Hard(u128, u128),
5538}
5539
5540pub fn check_limit_in_range<T: Into<V>, U: Into<V>, V: PartialOrd + Into<u128>>(
5543 x: T,
5544 soft_limit: U,
5545 hard_limit: V,
5546) -> LimitThresholdCrossed {
5547 let x: V = x.into();
5548 let soft_limit: V = soft_limit.into();
5549
5550 debug_assert!(soft_limit <= hard_limit);
5551
5552 if x >= hard_limit {
5555 LimitThresholdCrossed::Hard(x.into(), hard_limit.into())
5556 } else if x < soft_limit {
5557 LimitThresholdCrossed::None
5558 } else {
5559 LimitThresholdCrossed::Soft(x.into(), soft_limit.into())
5560 }
5561}
5562
5563#[macro_export]
5564macro_rules! check_limit {
5565 ($x:expr, $hard:expr) => {
5566 check_limit!($x, $hard, $hard)
5567 };
5568 ($x:expr, $soft:expr, $hard:expr) => {
5569 check_limit_in_range($x as u64, $soft, $hard)
5570 };
5571}
5572
5573#[macro_export]
5577macro_rules! check_limit_by_meter {
5578 ($is_metered:expr, $x:expr, $metered_limit:expr, $unmetered_hard_limit:expr, $metric:expr) => {{
5579 let (h, metered_str) = if $is_metered {
5581 ($metered_limit, "metered")
5582 } else {
5583 ($unmetered_hard_limit, "unmetered")
5585 };
5586 use sui_protocol_config::check_limit_in_range;
5587 let result = check_limit_in_range($x as u64, $metered_limit, h);
5588 match result {
5589 LimitThresholdCrossed::None => {}
5590 LimitThresholdCrossed::Soft(_, _) => {
5591 $metric.with_label_values(&[metered_str, "soft"]).inc();
5592 }
5593 LimitThresholdCrossed::Hard(_, _) => {
5594 $metric.with_label_values(&[metered_str, "hard"]).inc();
5595 }
5596 };
5597 result
5598 }};
5599}
5600
5601pub type Amendments = BTreeMap<AccountAddress, BTreeMap<AccountAddress, AccountAddress>>;
5604
5605static MAINNET_LINKAGE_AMENDMENTS: LazyLock<Arc<Amendments>> =
5606 LazyLock::new(|| parse_amendments(include_str!("mainnet_amendments.json")));
5607
5608static TESTNET_LINKAGE_AMENDMENTS: LazyLock<Arc<Amendments>> =
5609 LazyLock::new(|| parse_amendments(include_str!("testnet_amendments.json")));
5610
5611fn parse_amendments(json: &str) -> Arc<Amendments> {
5612 #[derive(serde::Deserialize)]
5613 struct AmendmentEntry {
5614 root: String,
5615 deps: Vec<DepEntry>,
5616 }
5617
5618 #[derive(serde::Deserialize)]
5619 struct DepEntry {
5620 original_id: String,
5621 version_id: String,
5622 }
5623
5624 let entries: Vec<AmendmentEntry> =
5625 serde_json::from_str(json).expect("Failed to parse amendments JSON");
5626 let mut amendments = BTreeMap::new();
5627 for entry in entries {
5628 let root_id = AccountAddress::from_hex_literal(&entry.root).unwrap();
5629 let mut dep_ids = BTreeMap::new();
5630 for dep in entry.deps {
5631 let orig_id = AccountAddress::from_hex_literal(&dep.original_id).unwrap();
5632 let upgraded_id = AccountAddress::from_hex_literal(&dep.version_id).unwrap();
5633 assert!(
5634 dep_ids.insert(orig_id, upgraded_id).is_none(),
5635 "Duplicate original ID in amendments table"
5636 );
5637 }
5638 assert!(
5639 amendments.insert(root_id, dep_ids).is_none(),
5640 "Duplicate root ID in amendments table"
5641 );
5642 }
5643 Arc::new(amendments)
5644}
5645
5646#[cfg(all(test, not(msim)))]
5647mod test {
5648 use insta::assert_yaml_snapshot;
5649
5650 use super::*;
5651
5652 #[test]
5653 fn snapshot_tests() {
5654 println!("\n============================================================================");
5655 println!("! !");
5656 println!("! IMPORTANT: never update snapshots from this test. only add new versions! !");
5657 println!("! !");
5658 println!("============================================================================\n");
5659 for chain_id in &[Chain::Unknown, Chain::Mainnet, Chain::Testnet] {
5660 let chain_str = match chain_id {
5664 Chain::Unknown => "".to_string(),
5665 _ => format!("{:?}_", chain_id),
5666 };
5667 for i in MIN_PROTOCOL_VERSION..=MAX_PROTOCOL_VERSION {
5668 let cur = ProtocolVersion::new(i);
5669 assert_yaml_snapshot!(
5670 format!("{}version_{}", chain_str, cur.as_u64()),
5671 ProtocolConfig::get_for_version(cur, *chain_id)
5672 );
5673 }
5674 }
5675 }
5676
5677 #[test]
5678 fn test_getters() {
5679 let prot: ProtocolConfig =
5680 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5681 assert_eq!(
5682 prot.max_arguments(),
5683 prot.max_arguments_as_option().unwrap()
5684 );
5685 }
5686
5687 #[test]
5688 fn test_setters() {
5689 let mut prot: ProtocolConfig =
5690 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5691 prot.set_max_arguments_for_testing(123);
5692 assert_eq!(prot.max_arguments(), 123);
5693
5694 prot.set_max_arguments_from_str_for_testing("321".to_string());
5695 assert_eq!(prot.max_arguments(), 321);
5696
5697 prot.disable_max_arguments_for_testing();
5698 assert_eq!(prot.max_arguments_as_option(), None);
5699
5700 prot.set_attr_for_testing("max_arguments".to_string(), "456".to_string());
5701 assert_eq!(prot.max_arguments(), 456);
5702 }
5703
5704 #[test]
5705 fn test_get_for_version_if_supported_applies_test_overrides() {
5706 let before =
5707 ProtocolConfig::get_for_version_if_supported(ProtocolVersion::new(1), Chain::Unknown)
5708 .unwrap();
5709
5710 assert!(!before.enable_coin_reservation_obj_refs());
5711
5712 let _guard = ProtocolConfig::apply_overrides_for_testing(|_, mut cfg| {
5713 cfg.enable_coin_reservation_for_testing();
5714 cfg
5715 });
5716
5717 let after =
5718 ProtocolConfig::get_for_version_if_supported(ProtocolVersion::new(1), Chain::Unknown)
5719 .unwrap();
5720
5721 assert!(after.enable_coin_reservation_obj_refs());
5722 }
5723
5724 #[test]
5725 #[should_panic(expected = "unsupported version")]
5726 fn max_version_test() {
5727 let _ = ProtocolConfig::get_for_version_impl(
5730 ProtocolVersion::new(MAX_PROTOCOL_VERSION + 1),
5731 Chain::Unknown,
5732 );
5733 }
5734
5735 #[test]
5736 fn lookup_by_string_test() {
5737 let prot: ProtocolConfig =
5738 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5739 assert!(prot.lookup_attr("some random string".to_string()).is_none());
5741
5742 assert!(
5743 prot.lookup_attr("max_arguments".to_string())
5744 == Some(ProtocolConfigValue::u32(prot.max_arguments())),
5745 );
5746
5747 assert!(
5749 prot.lookup_attr("max_move_identifier_len".to_string())
5750 .is_none()
5751 );
5752
5753 let prot: ProtocolConfig =
5755 ProtocolConfig::get_for_version(ProtocolVersion::new(9), Chain::Unknown);
5756 assert!(
5757 prot.lookup_attr("max_move_identifier_len".to_string())
5758 == Some(ProtocolConfigValue::u64(prot.max_move_identifier_len()))
5759 );
5760
5761 let prot: ProtocolConfig =
5762 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5763 assert!(
5765 prot.attr_map()
5766 .get("max_move_identifier_len")
5767 .unwrap()
5768 .is_none()
5769 );
5770 assert!(
5772 prot.attr_map().get("max_arguments").unwrap()
5773 == &Some(ProtocolConfigValue::u32(prot.max_arguments()))
5774 );
5775
5776 let prot: ProtocolConfig =
5778 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5779 assert!(
5781 prot.feature_flags
5782 .lookup_attr("some random string".to_owned())
5783 .is_none()
5784 );
5785 assert!(
5786 !prot
5787 .feature_flags
5788 .attr_map()
5789 .contains_key("some random string")
5790 );
5791
5792 assert!(
5794 prot.feature_flags
5795 .lookup_attr("package_upgrades".to_owned())
5796 == Some(false)
5797 );
5798 assert!(
5799 prot.feature_flags
5800 .attr_map()
5801 .get("package_upgrades")
5802 .unwrap()
5803 == &false
5804 );
5805 let prot: ProtocolConfig =
5806 ProtocolConfig::get_for_version(ProtocolVersion::new(4), Chain::Unknown);
5807 assert!(
5809 prot.feature_flags
5810 .lookup_attr("package_upgrades".to_owned())
5811 == Some(true)
5812 );
5813 assert!(
5814 prot.feature_flags
5815 .attr_map()
5816 .get("package_upgrades")
5817 .unwrap()
5818 == &true
5819 );
5820 }
5821
5822 #[test]
5823 fn limit_range_fn_test() {
5824 let low = 100u32;
5825 let high = 10000u64;
5826
5827 assert!(check_limit!(1u8, low, high) == LimitThresholdCrossed::None);
5828 assert!(matches!(
5829 check_limit!(255u16, low, high),
5830 LimitThresholdCrossed::Soft(255u128, 100)
5831 ));
5832 assert!(matches!(
5838 check_limit!(2550000u64, low, high),
5839 LimitThresholdCrossed::Hard(2550000, 10000)
5840 ));
5841
5842 assert!(matches!(
5843 check_limit!(2550000u64, high, high),
5844 LimitThresholdCrossed::Hard(2550000, 10000)
5845 ));
5846
5847 assert!(matches!(
5848 check_limit!(1u8, high),
5849 LimitThresholdCrossed::None
5850 ));
5851
5852 assert!(check_limit!(255u16, high) == LimitThresholdCrossed::None);
5853
5854 assert!(matches!(
5855 check_limit!(2550000u64, high),
5856 LimitThresholdCrossed::Hard(2550000, 10000)
5857 ));
5858 }
5859
5860 #[test]
5861 fn linkage_amendments_load() {
5862 let mainnet = LazyLock::force(&MAINNET_LINKAGE_AMENDMENTS);
5863 let testnet = LazyLock::force(&TESTNET_LINKAGE_AMENDMENTS);
5864 assert!(!mainnet.is_empty(), "mainnet amendments must not be empty");
5865 assert!(!testnet.is_empty(), "testnet amendments must not be empty");
5866 }
5867
5868 #[test]
5869 fn render_scalar_fields_use_precision_safe_encoding() {
5870 use mysten_common::rpc_format::Unmetered;
5871
5872 let config = ProtocolConfig::get_for_max_version_UNSAFE();
5873 let rendered = config
5874 .render::<serde_json::Value>(&mut Unmetered)
5875 .expect("render should succeed");
5876
5877 let max_args = rendered
5878 .get("max_arguments")
5879 .expect("max_arguments set at max version");
5880 assert!(
5881 max_args.is_number(),
5882 "u32 should render as number, got {max_args:?}",
5883 );
5884
5885 let max_tx_size = rendered
5886 .get("max_tx_size_bytes")
5887 .expect("max_tx_size_bytes set at max version");
5888 assert!(
5889 max_tx_size.is_string(),
5890 "u64 should render as string, got {max_tx_size:?}",
5891 );
5892 }
5893
5894 #[test]
5895 fn render_includes_non_scalar_gasless_allowlist_as_json() {
5896 use mysten_common::rpc_format::Unmetered;
5897 use serde_json::json;
5898
5899 let mut config = ProtocolConfig::get_for_max_version_UNSAFE();
5900 config.set_gasless_allowed_token_types_for_testing(vec![
5901 ("0xa::usdc::USDC".to_string(), 10_000),
5902 ("0xb::usdt::USDT".to_string(), 0),
5903 ]);
5904
5905 let rendered = config
5906 .render::<serde_json::Value>(&mut Unmetered)
5907 .expect("render should succeed under Unmetered budget");
5908 let allowlist = rendered
5909 .get("gasless_allowed_token_types")
5910 .expect("entry should be present after the testing setter");
5911
5912 assert_eq!(
5915 allowlist,
5916 &json!([["0xa::usdc::USDC", "10000"], ["0xb::usdt::USDT", "0"],]),
5917 );
5918 }
5919
5920 #[test]
5921 fn render_targets_prost_value_for_grpc() {
5922 use mysten_common::rpc_format::Unmetered;
5923 use prost_types::value::Kind;
5924
5925 let mut config = ProtocolConfig::get_for_max_version_UNSAFE();
5926 config.set_gasless_allowed_token_types_for_testing(vec![(
5927 "0xa::usdc::USDC".to_string(),
5928 10_000,
5929 )]);
5930
5931 let rendered = config
5932 .render::<prost_types::Value>(&mut Unmetered)
5933 .expect("render to prost Value should succeed");
5934 let allowlist = rendered
5935 .get("gasless_allowed_token_types")
5936 .expect("entry should be present after the testing setter");
5937
5938 let Some(Kind::ListValue(outer)) = &allowlist.kind else {
5940 panic!(
5941 "expected ListValue at the top level, got {:?}",
5942 allowlist.kind
5943 );
5944 };
5945 assert_eq!(outer.values.len(), 1, "one allowlisted entry");
5946 let Some(Kind::ListValue(entry)) = &outer.values[0].kind else {
5947 panic!("expected each entry to be a ListValue");
5948 };
5949 assert_eq!(entry.values.len(), 2, "entry has (coin_type, amount)");
5950
5951 let Some(Kind::StringValue(coin_type)) = &entry.values[0].kind else {
5952 panic!("expected coin_type as StringValue");
5953 };
5954 assert_eq!(coin_type, "0xa::usdc::USDC");
5955
5956 let Some(Kind::StringValue(amount)) = &entry.values[1].kind else {
5958 panic!(
5959 "expected minimum_transfer_amount as StringValue (precision-safe u64); got {:?}",
5960 entry.values[1].kind,
5961 );
5962 };
5963 assert_eq!(amount, "10000");
5964 }
5965
5966 #[test]
5967 fn render_emits_null_for_unset_protocol_versions() {
5968 use mysten_common::rpc_format::Unmetered;
5969
5970 let config = ProtocolConfig::get_for_version(1.into(), Chain::Unknown);
5971 let rendered = config
5972 .render::<serde_json::Value>(&mut Unmetered)
5973 .expect("render should succeed");
5974 let entry = rendered
5978 .get("gasless_allowed_token_types")
5979 .expect("key should be present for every protocol version");
5980 assert!(
5981 entry.is_null(),
5982 "value should be null for pre-feature protocol version, got {entry:?}",
5983 );
5984 }
5985}