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 = 129;
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)]
366pub struct ProtocolVersion(u64);
367
368impl ProtocolVersion {
369 pub const MIN: Self = Self(MIN_PROTOCOL_VERSION);
374
375 pub const MAX: Self = Self(MAX_PROTOCOL_VERSION);
376
377 #[cfg(not(msim))]
378 pub const MAX_ALLOWED: Self = Self::MAX;
379
380 #[cfg(msim)]
382 pub const MAX_ALLOWED: Self = Self(MAX_PROTOCOL_VERSION + 1);
383
384 pub fn new(v: u64) -> Self {
385 Self(v)
386 }
387
388 pub const fn as_u64(&self) -> u64 {
389 self.0
390 }
391
392 pub fn max() -> Self {
395 Self::MAX
396 }
397
398 pub fn prev(self) -> Self {
399 Self(self.0.checked_sub(1).unwrap())
400 }
401}
402
403impl From<u64> for ProtocolVersion {
404 fn from(v: u64) -> Self {
405 Self::new(v)
406 }
407}
408
409impl std::ops::Sub<u64> for ProtocolVersion {
410 type Output = Self;
411 fn sub(self, rhs: u64) -> Self::Output {
412 Self::new(self.0 - rhs)
413 }
414}
415
416impl std::ops::Add<u64> for ProtocolVersion {
417 type Output = Self;
418 fn add(self, rhs: u64) -> Self::Output {
419 Self::new(self.0 + rhs)
420 }
421}
422
423#[derive(
424 Clone, Serialize, Deserialize, Debug, Default, PartialEq, Copy, PartialOrd, Ord, Eq, ValueEnum,
425)]
426pub enum Chain {
427 Mainnet,
428 Testnet,
429 #[default]
430 Unknown,
431}
432
433impl Chain {
434 pub fn as_str(self) -> &'static str {
435 match self {
436 Chain::Mainnet => "mainnet",
437 Chain::Testnet => "testnet",
438 Chain::Unknown => "unknown",
439 }
440 }
441}
442
443pub struct Error(pub String);
444
445#[derive(Default, Clone, Serialize, Deserialize, Debug, ProtocolConfigFeatureFlagsGetters)]
448struct FeatureFlags {
449 #[serde(skip_serializing_if = "is_false")]
452 package_upgrades: bool,
453 #[serde(skip_serializing_if = "is_false")]
456 commit_root_state_digest: bool,
457 #[serde(skip_serializing_if = "is_false")]
459 advance_epoch_start_time_in_safe_mode: bool,
460 #[serde(skip_serializing_if = "is_false")]
463 loaded_child_objects_fixed: bool,
464 #[serde(skip_serializing_if = "is_false")]
467 missing_type_is_compatibility_error: bool,
468 #[serde(skip_serializing_if = "is_false")]
471 scoring_decision_with_validity_cutoff: bool,
472
473 #[serde(skip_serializing_if = "is_false")]
476 consensus_order_end_of_epoch_last: bool,
477
478 #[serde(skip_serializing_if = "is_false")]
480 disallow_adding_abilities_on_upgrade: bool,
481 #[serde(skip_serializing_if = "is_false")]
483 disable_invariant_violation_check_in_swap_loc: bool,
484 #[serde(skip_serializing_if = "is_false")]
487 advance_to_highest_supported_protocol_version: bool,
488 #[serde(skip_serializing_if = "is_false")]
490 ban_entry_init: bool,
491 #[serde(skip_serializing_if = "is_false")]
493 package_digest_hash_module: bool,
494 #[serde(skip_serializing_if = "is_false")]
496 disallow_change_struct_type_params_on_upgrade: bool,
497 #[serde(skip_serializing_if = "is_false")]
499 no_extraneous_module_bytes: bool,
500 #[serde(skip_serializing_if = "is_false")]
502 narwhal_versioned_metadata: bool,
503
504 #[serde(skip_serializing_if = "is_false")]
506 zklogin_auth: bool,
507 #[serde(skip_serializing_if = "ConsensusTransactionOrdering::is_none")]
509 consensus_transaction_ordering: ConsensusTransactionOrdering,
510
511 #[serde(skip_serializing_if = "is_false")]
519 simplified_unwrap_then_delete: bool,
520 #[serde(skip_serializing_if = "is_false")]
522 upgraded_multisig_supported: bool,
523 #[serde(skip_serializing_if = "is_false")]
525 txn_base_cost_as_multiplier: bool,
526
527 #[serde(skip_serializing_if = "is_false")]
529 shared_object_deletion: bool,
530
531 #[serde(skip_serializing_if = "is_false")]
533 narwhal_new_leader_election_schedule: bool,
534
535 #[serde(skip_serializing_if = "is_empty")]
537 zklogin_supported_providers: BTreeSet<String>,
538
539 #[serde(skip_serializing_if = "is_false")]
541 loaded_child_object_format: bool,
542
543 #[serde(skip_serializing_if = "is_false")]
544 enable_jwk_consensus_updates: bool,
545
546 #[serde(skip_serializing_if = "is_false")]
547 end_of_epoch_transaction_supported: bool,
548
549 #[serde(skip_serializing_if = "is_false")]
552 simple_conservation_checks: bool,
553
554 #[serde(skip_serializing_if = "is_false")]
556 loaded_child_object_format_type: bool,
557
558 #[serde(skip_serializing_if = "is_false")]
560 receive_objects: bool,
561
562 #[serde(skip_serializing_if = "is_false")]
564 consensus_checkpoint_signature_key_includes_digest: bool,
565
566 #[serde(skip_serializing_if = "is_false")]
568 random_beacon: bool,
569
570 #[serde(skip_serializing_if = "is_false")]
572 bridge: bool,
573
574 #[serde(skip_serializing_if = "is_false")]
575 enable_effects_v2: bool,
576
577 #[serde(skip_serializing_if = "is_false")]
579 narwhal_certificate_v2: bool,
580
581 #[serde(skip_serializing_if = "is_false")]
583 verify_legacy_zklogin_address: bool,
584
585 #[serde(skip_serializing_if = "is_false")]
587 throughput_aware_consensus_submission: bool,
588
589 #[serde(skip_serializing_if = "is_false")]
591 recompute_has_public_transfer_in_execution: bool,
592
593 #[serde(skip_serializing_if = "is_false")]
595 accept_zklogin_in_multisig: bool,
596
597 #[serde(skip_serializing_if = "is_false")]
599 accept_passkey_in_multisig: bool,
600
601 #[serde(skip_serializing_if = "is_false")]
603 validate_zklogin_public_identifier: bool,
604
605 #[serde(skip_serializing_if = "is_false")]
608 include_consensus_digest_in_prologue: bool,
609
610 #[serde(skip_serializing_if = "is_false")]
612 hardened_otw_check: bool,
613
614 #[serde(skip_serializing_if = "is_false")]
616 allow_receiving_object_id: bool,
617
618 #[serde(skip_serializing_if = "is_false")]
620 enable_poseidon: bool,
621
622 #[serde(skip_serializing_if = "is_false")]
624 enable_coin_deny_list: bool,
625
626 #[serde(skip_serializing_if = "is_false")]
628 enable_group_ops_native_functions: bool,
629
630 #[serde(skip_serializing_if = "is_false")]
632 enable_group_ops_native_function_msm: bool,
633
634 #[serde(skip_serializing_if = "is_false")]
636 enable_ristretto255_group_ops: bool,
637
638 #[serde(skip_serializing_if = "is_false")]
640 enable_verify_bulletproofs_ristretto255: bool,
641
642 #[serde(skip_serializing_if = "is_false")]
644 enable_nitro_attestation: bool,
645
646 #[serde(skip_serializing_if = "is_false")]
648 enable_nitro_attestation_upgraded_parsing: bool,
649
650 #[serde(skip_serializing_if = "is_false")]
652 enable_nitro_attestation_all_nonzero_pcrs_parsing: bool,
653
654 #[serde(skip_serializing_if = "is_false")]
656 enable_nitro_attestation_always_include_required_pcrs_parsing: bool,
657
658 #[serde(skip_serializing_if = "is_false")]
660 reject_mutable_random_on_entry_functions: bool,
661
662 #[serde(skip_serializing_if = "PerObjectCongestionControlMode::is_none")]
664 per_object_congestion_control_mode: PerObjectCongestionControlMode,
665
666 #[serde(skip_serializing_if = "ConsensusChoice::is_narwhal")]
668 consensus_choice: ConsensusChoice,
669
670 #[serde(skip_serializing_if = "ConsensusNetwork::is_anemo")]
672 consensus_network: ConsensusNetwork,
673
674 #[serde(skip_serializing_if = "is_false")]
676 correct_gas_payment_limit_check: bool,
677
678 #[serde(skip_serializing_if = "Option::is_none")]
680 zklogin_max_epoch_upper_bound_delta: Option<u64>,
681
682 #[serde(skip_serializing_if = "is_false")]
684 mysticeti_leader_scoring_and_schedule: bool,
685
686 #[serde(skip_serializing_if = "is_false")]
688 reshare_at_same_initial_version: bool,
689
690 #[serde(skip_serializing_if = "is_false")]
692 resolve_abort_locations_to_package_id: bool,
693
694 #[serde(skip_serializing_if = "is_false")]
698 mysticeti_use_committed_subdag_digest: bool,
699
700 #[serde(skip_serializing_if = "is_false")]
702 enable_vdf: bool,
703
704 #[serde(skip_serializing_if = "is_false")]
709 record_consensus_determined_version_assignments_in_prologue: bool,
710 #[serde(skip_serializing_if = "is_false")]
711 record_consensus_determined_version_assignments_in_prologue_v2: bool,
712
713 #[serde(skip_serializing_if = "is_false")]
715 fresh_vm_on_framework_upgrade: bool,
716
717 #[serde(skip_serializing_if = "is_false")]
725 prepend_prologue_tx_in_consensus_commit_in_checkpoints: bool,
726
727 #[serde(skip_serializing_if = "Option::is_none")]
729 mysticeti_num_leaders_per_round: Option<usize>,
730
731 #[serde(skip_serializing_if = "is_false")]
733 soft_bundle: bool,
734
735 #[serde(skip_serializing_if = "is_false")]
737 enable_coin_deny_list_v2: bool,
738
739 #[serde(skip_serializing_if = "is_false")]
741 passkey_auth: bool,
742
743 #[serde(skip_serializing_if = "is_false")]
745 authority_capabilities_v2: bool,
746
747 #[serde(skip_serializing_if = "is_false")]
749 rethrow_serialization_type_layout_errors: bool,
750
751 #[serde(skip_serializing_if = "is_false")]
753 consensus_distributed_vote_scoring_strategy: bool,
754
755 #[serde(skip_serializing_if = "is_false")]
757 consensus_round_prober: bool,
758
759 #[serde(skip_serializing_if = "is_false")]
761 validate_identifier_inputs: bool,
762
763 #[serde(skip_serializing_if = "is_false")]
765 disallow_self_identifier: bool,
766
767 #[serde(skip_serializing_if = "is_false")]
769 mysticeti_fastpath: bool,
770
771 #[serde(skip_serializing_if = "is_false")]
775 disable_preconsensus_locking: bool,
776
777 #[serde(skip_serializing_if = "is_false")]
779 relocate_event_module: bool,
780
781 #[serde(skip_serializing_if = "is_false")]
783 uncompressed_g1_group_elements: bool,
784
785 #[serde(skip_serializing_if = "is_false")]
786 disallow_new_modules_in_deps_only_packages: bool,
787
788 #[serde(skip_serializing_if = "is_false")]
790 consensus_smart_ancestor_selection: bool,
791
792 #[serde(skip_serializing_if = "is_false")]
794 consensus_round_prober_probe_accepted_rounds: bool,
795
796 #[serde(skip_serializing_if = "is_false")]
798 native_charging_v2: bool,
799
800 #[serde(skip_serializing_if = "is_false")]
803 consensus_linearize_subdag_v2: bool,
804
805 #[serde(skip_serializing_if = "is_false")]
807 convert_type_argument_error: bool,
808
809 #[serde(skip_serializing_if = "is_false")]
811 variant_nodes: bool,
812
813 #[serde(skip_serializing_if = "is_false")]
815 consensus_zstd_compression: bool,
816
817 #[serde(skip_serializing_if = "is_false")]
819 minimize_child_object_mutations: bool,
820
821 #[serde(skip_serializing_if = "is_false")]
823 record_additional_state_digest_in_prologue: bool,
824
825 #[serde(skip_serializing_if = "is_false")]
827 move_native_context: bool,
828
829 #[serde(skip_serializing_if = "is_false")]
832 consensus_median_based_commit_timestamp: bool,
833
834 #[serde(skip_serializing_if = "is_false")]
837 normalize_ptb_arguments: bool,
838
839 #[serde(skip_serializing_if = "is_false")]
841 consensus_batched_block_sync: bool,
842
843 #[serde(skip_serializing_if = "is_false")]
845 enforce_checkpoint_timestamp_monotonicity: bool,
846
847 #[serde(skip_serializing_if = "is_false")]
849 max_ptb_value_size_v2: bool,
850
851 #[serde(skip_serializing_if = "is_false")]
853 resolve_type_input_ids_to_defining_id: bool,
854
855 #[serde(skip_serializing_if = "is_false")]
857 enable_party_transfer: bool,
858
859 #[serde(skip_serializing_if = "is_false")]
861 allow_unbounded_system_objects: bool,
862
863 #[serde(skip_serializing_if = "is_false")]
865 type_tags_in_object_runtime: bool,
866
867 #[serde(skip_serializing_if = "is_false")]
869 enable_accumulators: bool,
870
871 #[serde(skip_serializing_if = "is_false")]
873 enable_coin_reservation_obj_refs: bool,
874
875 #[serde(skip_serializing_if = "is_false")]
878 create_root_accumulator_object: bool,
879
880 #[serde(skip_serializing_if = "is_false")]
882 enable_authenticated_event_streams: bool,
883
884 #[serde(skip_serializing_if = "is_false")]
886 enable_address_balance_gas_payments: bool,
887
888 #[serde(skip_serializing_if = "is_false")]
890 address_balance_gas_check_rgp_at_signing: bool,
891
892 #[serde(skip_serializing_if = "is_false")]
893 address_balance_gas_reject_gas_coin_arg: bool,
894
895 #[serde(skip_serializing_if = "is_false")]
897 enable_multi_epoch_transaction_expiration: bool,
898
899 #[serde(skip_serializing_if = "is_false")]
901 relax_valid_during_for_owned_inputs: bool,
902
903 #[serde(skip_serializing_if = "is_false")]
905 enable_ptb_execution_v2: bool,
906
907 #[serde(skip_serializing_if = "is_false")]
909 better_adapter_type_resolution_errors: bool,
910
911 #[serde(skip_serializing_if = "is_false")]
913 record_time_estimate_processed: bool,
914
915 #[serde(skip_serializing_if = "is_false")]
917 dependency_linkage_error: bool,
918
919 #[serde(skip_serializing_if = "is_false")]
921 additional_multisig_checks: bool,
922
923 #[serde(skip_serializing_if = "is_false")]
925 ignore_execution_time_observations_after_certs_closed: bool,
926
927 #[serde(skip_serializing_if = "is_false")]
931 debug_fatal_on_move_invariant_violation: bool,
932
933 #[serde(skip_serializing_if = "is_false")]
936 allow_private_accumulator_entrypoints: bool,
937
938 #[serde(skip_serializing_if = "is_false")]
940 additional_consensus_digest_indirect_state: bool,
941
942 #[serde(skip_serializing_if = "is_false")]
944 check_for_init_during_upgrade: bool,
945
946 #[serde(skip_serializing_if = "is_false")]
948 per_command_shared_object_transfer_rules: bool,
949
950 #[serde(skip_serializing_if = "is_false")]
952 include_checkpoint_artifacts_digest_in_summary: bool,
953
954 #[serde(skip_serializing_if = "is_false")]
956 use_mfp_txns_in_load_initial_object_debts: bool,
957
958 #[serde(skip_serializing_if = "is_false")]
960 cancel_for_failed_dkg_early: bool,
961
962 #[serde(skip_serializing_if = "is_false")]
964 always_advance_dkg_to_resolution: bool,
965
966 #[serde(skip_serializing_if = "is_false")]
968 enable_coin_registry: bool,
969
970 #[serde(skip_serializing_if = "is_false")]
972 abstract_size_in_object_runtime: bool,
973
974 #[serde(skip_serializing_if = "is_false")]
976 object_runtime_charge_cache_load_gas: bool,
977
978 #[serde(skip_serializing_if = "is_false")]
980 additional_borrow_checks: bool,
981
982 #[serde(skip_serializing_if = "is_false")]
984 use_new_commit_handler: bool,
985
986 #[serde(skip_serializing_if = "is_false")]
988 better_loader_errors: bool,
989
990 #[serde(skip_serializing_if = "is_false")]
992 generate_df_type_layouts: bool,
993
994 #[serde(skip_serializing_if = "is_false")]
996 allow_references_in_ptbs: bool,
997
998 #[serde(skip_serializing_if = "is_false")]
1000 enable_display_registry: bool,
1001
1002 #[serde(skip_serializing_if = "is_false")]
1004 private_generics_verifier_v2: bool,
1005
1006 #[serde(skip_serializing_if = "is_false")]
1008 deprecate_global_storage_ops_during_deserialization: bool,
1009
1010 #[serde(skip_serializing_if = "is_false")]
1013 enable_non_exclusive_writes: bool,
1014
1015 #[serde(skip_serializing_if = "is_false")]
1017 deprecate_global_storage_ops: bool,
1018
1019 #[serde(skip_serializing_if = "is_false")]
1021 normalize_depth_formula: bool,
1022
1023 #[serde(skip_serializing_if = "is_false")]
1025 consensus_skip_gced_accept_votes: bool,
1026
1027 #[serde(skip_serializing_if = "is_false")]
1029 include_cancelled_randomness_txns_in_prologue: bool,
1030
1031 #[serde(skip_serializing_if = "is_false")]
1033 address_aliases: bool,
1034
1035 #[serde(skip_serializing_if = "is_false")]
1038 fix_checkpoint_signature_mapping: bool,
1039
1040 #[serde(skip_serializing_if = "is_false")]
1042 enable_object_funds_withdraw: bool,
1043
1044 #[serde(skip_serializing_if = "is_false")]
1046 consensus_skip_gced_blocks_in_direct_finalization: bool,
1047
1048 #[serde(skip_serializing_if = "is_false")]
1050 gas_rounding_halve_digits: bool,
1051
1052 #[serde(skip_serializing_if = "is_false")]
1054 flexible_tx_context_positions: bool,
1055
1056 #[serde(skip_serializing_if = "is_false")]
1058 disable_entry_point_signature_check: bool,
1059
1060 #[serde(skip_serializing_if = "is_false")]
1062 convert_withdrawal_compatibility_ptb_arguments: bool,
1063
1064 #[serde(skip_serializing_if = "is_false")]
1066 restrict_hot_or_not_entry_functions: bool,
1067
1068 #[serde(skip_serializing_if = "is_false")]
1070 split_checkpoints_in_consensus_handler: bool,
1071
1072 #[serde(skip_serializing_if = "is_false")]
1074 consensus_always_accept_system_transactions: bool,
1075
1076 #[serde(skip_serializing_if = "is_false")]
1078 validator_metadata_verify_v2: bool,
1079
1080 #[serde(skip_serializing_if = "is_false")]
1083 defer_unpaid_amplification: bool,
1084
1085 #[serde(skip_serializing_if = "is_false")]
1086 randomize_checkpoint_tx_limit_in_tests: bool,
1087
1088 #[serde(skip_serializing_if = "is_false")]
1090 gasless_transaction_drop_safety: bool,
1091
1092 #[serde(skip_serializing_if = "is_false")]
1094 merge_randomness_into_checkpoint: bool,
1095
1096 #[serde(skip_serializing_if = "is_false")]
1098 use_coin_party_owner: bool,
1099
1100 #[serde(skip_serializing_if = "is_false")]
1101 enable_gasless: bool,
1102
1103 #[serde(skip_serializing_if = "is_false")]
1104 gasless_verify_remaining_balance: bool,
1105
1106 #[serde(skip_serializing_if = "is_false")]
1107 disallow_jump_orphans: bool,
1108
1109 #[serde(skip_serializing_if = "is_false")]
1111 early_return_receive_object_mismatched_type: bool,
1112
1113 #[serde(skip_serializing_if = "is_false")]
1118 timestamp_based_epoch_close: bool,
1119
1120 #[serde(skip_serializing_if = "is_false")]
1123 limit_groth16_pvk_inputs: bool,
1124
1125 #[serde(skip_serializing_if = "is_false")]
1130 enforce_address_balance_change_invariant: bool,
1131
1132 #[serde(skip_serializing_if = "is_false")]
1134 granular_post_execution_checks: bool,
1135
1136 #[serde(skip_serializing_if = "is_false")]
1138 early_exit_on_iffw: bool,
1139
1140 #[serde(skip_serializing_if = "is_false")]
1142 enable_unified_linkage: bool,
1143}
1144
1145fn is_false(b: &bool) -> bool {
1146 !b
1147}
1148
1149fn is_empty(b: &BTreeSet<String>) -> bool {
1150 b.is_empty()
1151}
1152
1153fn is_zero(val: &u64) -> bool {
1154 *val == 0
1155}
1156
1157#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1159pub enum ConsensusTransactionOrdering {
1160 #[default]
1162 None,
1163 ByGasPrice,
1165}
1166
1167impl ConsensusTransactionOrdering {
1168 pub fn is_none(&self) -> bool {
1169 matches!(self, ConsensusTransactionOrdering::None)
1170 }
1171}
1172
1173#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1174pub struct ExecutionTimeEstimateParams {
1175 pub target_utilization: u64,
1177 pub allowed_txn_cost_overage_burst_limit_us: u64,
1181
1182 pub randomness_scalar: u64,
1185
1186 pub max_estimate_us: u64,
1188
1189 pub stored_observations_num_included_checkpoints: u64,
1192
1193 pub stored_observations_limit: u64,
1195
1196 #[serde(skip_serializing_if = "is_zero")]
1199 pub stake_weighted_median_threshold: u64,
1200
1201 #[serde(skip_serializing_if = "is_false")]
1205 pub default_none_duration_for_new_keys: bool,
1206
1207 #[serde(skip_serializing_if = "Option::is_none")]
1209 pub observations_chunk_size: Option<u64>,
1210}
1211
1212#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1214pub enum PerObjectCongestionControlMode {
1215 #[default]
1216 None, TotalGasBudget, TotalTxCount, TotalGasBudgetWithCap, ExecutionTimeEstimate(ExecutionTimeEstimateParams), }
1222
1223impl PerObjectCongestionControlMode {
1224 pub fn is_none(&self) -> bool {
1225 matches!(self, PerObjectCongestionControlMode::None)
1226 }
1227}
1228
1229#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1231pub enum ConsensusChoice {
1232 #[default]
1233 Narwhal,
1234 SwapEachEpoch,
1235 Mysticeti,
1236}
1237
1238impl ConsensusChoice {
1239 pub fn is_narwhal(&self) -> bool {
1240 matches!(self, ConsensusChoice::Narwhal)
1241 }
1242}
1243
1244#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1246pub enum ConsensusNetwork {
1247 #[default]
1248 Anemo,
1249 Tonic,
1250}
1251
1252impl ConsensusNetwork {
1253 pub fn is_anemo(&self) -> bool {
1254 matches!(self, ConsensusNetwork::Anemo)
1255 }
1256}
1257
1258#[skip_serializing_none]
1290#[derive(Clone, Serialize, Debug, ProtocolConfigAccessors, ProtocolConfigOverride)]
1291pub struct ProtocolConfig {
1292 pub version: ProtocolVersion,
1293
1294 #[serde(skip)]
1299 chain: Chain,
1300
1301 feature_flags: FeatureFlags,
1302
1303 max_tx_size_bytes: Option<u64>,
1306
1307 max_input_objects: Option<u64>,
1309
1310 max_size_written_objects: Option<u64>,
1314 max_size_written_objects_system_tx: Option<u64>,
1317
1318 max_serialized_tx_effects_size_bytes: Option<u64>,
1320
1321 max_serialized_tx_effects_size_bytes_system_tx: Option<u64>,
1323
1324 max_gas_payment_objects: Option<u32>,
1326
1327 max_modules_in_publish: Option<u32>,
1329
1330 max_package_dependencies: Option<u32>,
1332
1333 max_arguments: Option<u32>,
1336
1337 max_type_arguments: Option<u32>,
1339
1340 max_type_argument_depth: Option<u32>,
1342
1343 max_pure_argument_size: Option<u32>,
1345
1346 max_programmable_tx_commands: Option<u32>,
1348
1349 move_binary_format_version: Option<u32>,
1352 min_move_binary_format_version: Option<u32>,
1353
1354 binary_module_handles: Option<u16>,
1356 binary_struct_handles: Option<u16>,
1357 binary_function_handles: Option<u16>,
1358 binary_function_instantiations: Option<u16>,
1359 binary_signatures: Option<u16>,
1360 binary_constant_pool: Option<u16>,
1361 binary_identifiers: Option<u16>,
1362 binary_address_identifiers: Option<u16>,
1363 binary_struct_defs: Option<u16>,
1364 binary_struct_def_instantiations: Option<u16>,
1365 binary_function_defs: Option<u16>,
1366 binary_field_handles: Option<u16>,
1367 binary_field_instantiations: Option<u16>,
1368 binary_friend_decls: Option<u16>,
1369 binary_enum_defs: Option<u16>,
1370 binary_enum_def_instantiations: Option<u16>,
1371 binary_variant_handles: Option<u16>,
1372 binary_variant_instantiation_handles: Option<u16>,
1373
1374 max_move_object_size: Option<u64>,
1376
1377 max_move_package_size: Option<u64>,
1380
1381 max_publish_or_upgrade_per_ptb: Option<u64>,
1383
1384 max_tx_gas: Option<u64>,
1386
1387 max_gas_price: Option<u64>,
1389
1390 max_gas_price_rgp_factor_for_aborted_transactions: Option<u64>,
1393
1394 max_gas_computation_bucket: Option<u64>,
1396
1397 gas_rounding_step: Option<u64>,
1399
1400 max_loop_depth: Option<u64>,
1402
1403 max_generic_instantiation_length: Option<u64>,
1405
1406 max_function_parameters: Option<u64>,
1408
1409 max_basic_blocks: Option<u64>,
1411
1412 max_value_stack_size: Option<u64>,
1414
1415 max_type_nodes: Option<u64>,
1417
1418 max_generic_instantiation_type_nodes_per_function: Option<u64>,
1420
1421 max_generic_instantiation_type_nodes_per_module: Option<u64>,
1423
1424 max_push_size: Option<u64>,
1426
1427 max_struct_definitions: Option<u64>,
1429
1430 max_function_definitions: Option<u64>,
1432
1433 max_fields_in_struct: Option<u64>,
1435
1436 max_dependency_depth: Option<u64>,
1438
1439 max_num_event_emit: Option<u64>,
1441
1442 max_num_new_move_object_ids: Option<u64>,
1444
1445 max_num_new_move_object_ids_system_tx: Option<u64>,
1447
1448 max_num_deleted_move_object_ids: Option<u64>,
1450
1451 max_num_deleted_move_object_ids_system_tx: Option<u64>,
1453
1454 max_num_transferred_move_object_ids: Option<u64>,
1456
1457 max_num_transferred_move_object_ids_system_tx: Option<u64>,
1459
1460 max_event_emit_size: Option<u64>,
1462
1463 max_event_emit_size_total: Option<u64>,
1465
1466 max_move_vector_len: Option<u64>,
1468
1469 max_move_identifier_len: Option<u64>,
1471
1472 max_move_value_depth: Option<u64>,
1474
1475 max_move_enum_variants: Option<u64>,
1477
1478 max_back_edges_per_function: Option<u64>,
1480
1481 max_back_edges_per_module: Option<u64>,
1483
1484 max_verifier_meter_ticks_per_function: Option<u64>,
1486
1487 max_meter_ticks_per_module: Option<u64>,
1489
1490 max_meter_ticks_per_package: Option<u64>,
1492
1493 object_runtime_max_num_cached_objects: Option<u64>,
1497
1498 object_runtime_max_num_cached_objects_system_tx: Option<u64>,
1500
1501 object_runtime_max_num_store_entries: Option<u64>,
1503
1504 object_runtime_max_num_store_entries_system_tx: Option<u64>,
1506
1507 base_tx_cost_fixed: Option<u64>,
1510
1511 package_publish_cost_fixed: Option<u64>,
1514
1515 base_tx_cost_per_byte: Option<u64>,
1518
1519 package_publish_cost_per_byte: Option<u64>,
1521
1522 obj_access_cost_read_per_byte: Option<u64>,
1524
1525 obj_access_cost_mutate_per_byte: Option<u64>,
1527
1528 obj_access_cost_delete_per_byte: Option<u64>,
1530
1531 obj_access_cost_verify_per_byte: Option<u64>,
1541
1542 max_type_to_layout_nodes: Option<u64>,
1544
1545 max_ptb_value_size: Option<u64>,
1547
1548 gas_model_version: Option<u64>,
1551
1552 obj_data_cost_refundable: Option<u64>,
1555
1556 obj_metadata_cost_non_refundable: Option<u64>,
1560
1561 storage_rebate_rate: Option<u64>,
1567
1568 storage_fund_reinvest_rate: Option<u64>,
1571
1572 reward_slashing_rate: Option<u64>,
1575
1576 storage_gas_price: Option<u64>,
1578
1579 accumulator_object_storage_cost: Option<u64>,
1581
1582 max_transactions_per_checkpoint: Option<u64>,
1587
1588 max_checkpoint_size_bytes: Option<u64>,
1592
1593 buffer_stake_for_protocol_upgrade_bps: Option<u64>,
1598
1599 address_from_bytes_cost_base: Option<u64>,
1604 address_to_u256_cost_base: Option<u64>,
1606 address_from_u256_cost_base: Option<u64>,
1608
1609 config_read_setting_impl_cost_base: Option<u64>,
1614 config_read_setting_impl_cost_per_byte: Option<u64>,
1615
1616 dynamic_field_hash_type_and_key_cost_base: Option<u64>,
1619 dynamic_field_hash_type_and_key_type_cost_per_byte: Option<u64>,
1620 dynamic_field_hash_type_and_key_value_cost_per_byte: Option<u64>,
1621 dynamic_field_hash_type_and_key_type_tag_cost_per_byte: Option<u64>,
1622 dynamic_field_add_child_object_cost_base: Option<u64>,
1624 dynamic_field_add_child_object_type_cost_per_byte: Option<u64>,
1625 dynamic_field_add_child_object_value_cost_per_byte: Option<u64>,
1626 dynamic_field_add_child_object_struct_tag_cost_per_byte: Option<u64>,
1627 dynamic_field_borrow_child_object_cost_base: Option<u64>,
1629 dynamic_field_borrow_child_object_child_ref_cost_per_byte: Option<u64>,
1630 dynamic_field_borrow_child_object_type_cost_per_byte: Option<u64>,
1631 dynamic_field_remove_child_object_cost_base: Option<u64>,
1633 dynamic_field_remove_child_object_child_cost_per_byte: Option<u64>,
1634 dynamic_field_remove_child_object_type_cost_per_byte: Option<u64>,
1635 dynamic_field_has_child_object_cost_base: Option<u64>,
1637 dynamic_field_has_child_object_with_ty_cost_base: Option<u64>,
1639 dynamic_field_has_child_object_with_ty_type_cost_per_byte: Option<u64>,
1640 dynamic_field_has_child_object_with_ty_type_tag_cost_per_byte: Option<u64>,
1641
1642 event_emit_cost_base: Option<u64>,
1645 event_emit_value_size_derivation_cost_per_byte: Option<u64>,
1646 event_emit_tag_size_derivation_cost_per_byte: Option<u64>,
1647 event_emit_output_cost_per_byte: Option<u64>,
1648 event_emit_auth_stream_cost: Option<u64>,
1649
1650 object_borrow_uid_cost_base: Option<u64>,
1653 object_delete_impl_cost_base: Option<u64>,
1655 object_record_new_uid_cost_base: Option<u64>,
1657
1658 transfer_transfer_internal_cost_base: Option<u64>,
1661 transfer_party_transfer_internal_cost_base: Option<u64>,
1663 transfer_freeze_object_cost_base: Option<u64>,
1665 transfer_share_object_cost_base: Option<u64>,
1667 transfer_receive_object_cost_base: Option<u64>,
1670 transfer_receive_object_cost_per_byte: Option<u64>,
1671 transfer_receive_object_type_cost_per_byte: Option<u64>,
1672
1673 tx_context_derive_id_cost_base: Option<u64>,
1676 tx_context_fresh_id_cost_base: Option<u64>,
1677 tx_context_sender_cost_base: Option<u64>,
1678 tx_context_epoch_cost_base: Option<u64>,
1679 tx_context_epoch_timestamp_ms_cost_base: Option<u64>,
1680 tx_context_sponsor_cost_base: Option<u64>,
1681 tx_context_rgp_cost_base: Option<u64>,
1682 tx_context_gas_price_cost_base: Option<u64>,
1683 tx_context_gas_budget_cost_base: Option<u64>,
1684 tx_context_ids_created_cost_base: Option<u64>,
1685 tx_context_replace_cost_base: Option<u64>,
1686
1687 types_is_one_time_witness_cost_base: Option<u64>,
1690 types_is_one_time_witness_type_tag_cost_per_byte: Option<u64>,
1691 types_is_one_time_witness_type_cost_per_byte: Option<u64>,
1692
1693 validator_validate_metadata_cost_base: Option<u64>,
1696 validator_validate_metadata_data_cost_per_byte: Option<u64>,
1697
1698 crypto_invalid_arguments_cost: Option<u64>,
1700 bls12381_bls12381_min_sig_verify_cost_base: Option<u64>,
1702 bls12381_bls12381_min_sig_verify_msg_cost_per_byte: Option<u64>,
1703 bls12381_bls12381_min_sig_verify_msg_cost_per_block: Option<u64>,
1704
1705 bls12381_bls12381_min_pk_verify_cost_base: Option<u64>,
1707 bls12381_bls12381_min_pk_verify_msg_cost_per_byte: Option<u64>,
1708 bls12381_bls12381_min_pk_verify_msg_cost_per_block: Option<u64>,
1709
1710 ecdsa_k1_ecrecover_keccak256_cost_base: Option<u64>,
1712 ecdsa_k1_ecrecover_keccak256_msg_cost_per_byte: Option<u64>,
1713 ecdsa_k1_ecrecover_keccak256_msg_cost_per_block: Option<u64>,
1714 ecdsa_k1_ecrecover_sha256_cost_base: Option<u64>,
1715 ecdsa_k1_ecrecover_sha256_msg_cost_per_byte: Option<u64>,
1716 ecdsa_k1_ecrecover_sha256_msg_cost_per_block: Option<u64>,
1717
1718 ecdsa_k1_decompress_pubkey_cost_base: Option<u64>,
1720
1721 ecdsa_k1_secp256k1_verify_keccak256_cost_base: Option<u64>,
1723 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_byte: Option<u64>,
1724 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_block: Option<u64>,
1725 ecdsa_k1_secp256k1_verify_sha256_cost_base: Option<u64>,
1726 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_byte: Option<u64>,
1727 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_block: Option<u64>,
1728
1729 ecdsa_r1_ecrecover_keccak256_cost_base: Option<u64>,
1731 ecdsa_r1_ecrecover_keccak256_msg_cost_per_byte: Option<u64>,
1732 ecdsa_r1_ecrecover_keccak256_msg_cost_per_block: Option<u64>,
1733 ecdsa_r1_ecrecover_sha256_cost_base: Option<u64>,
1734 ecdsa_r1_ecrecover_sha256_msg_cost_per_byte: Option<u64>,
1735 ecdsa_r1_ecrecover_sha256_msg_cost_per_block: Option<u64>,
1736
1737 ecdsa_r1_secp256r1_verify_keccak256_cost_base: Option<u64>,
1739 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_byte: Option<u64>,
1740 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_block: Option<u64>,
1741 ecdsa_r1_secp256r1_verify_sha256_cost_base: Option<u64>,
1742 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_byte: Option<u64>,
1743 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_block: Option<u64>,
1744
1745 ecvrf_ecvrf_verify_cost_base: Option<u64>,
1747 ecvrf_ecvrf_verify_alpha_string_cost_per_byte: Option<u64>,
1748 ecvrf_ecvrf_verify_alpha_string_cost_per_block: Option<u64>,
1749
1750 ed25519_ed25519_verify_cost_base: Option<u64>,
1752 ed25519_ed25519_verify_msg_cost_per_byte: Option<u64>,
1753 ed25519_ed25519_verify_msg_cost_per_block: Option<u64>,
1754
1755 groth16_prepare_verifying_key_bls12381_cost_base: Option<u64>,
1757 groth16_prepare_verifying_key_bn254_cost_base: Option<u64>,
1758
1759 groth16_verify_groth16_proof_internal_bls12381_cost_base: Option<u64>,
1761 groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input: Option<u64>,
1762 groth16_verify_groth16_proof_internal_bn254_cost_base: Option<u64>,
1763 groth16_verify_groth16_proof_internal_bn254_cost_per_public_input: Option<u64>,
1764 groth16_verify_groth16_proof_internal_public_input_cost_per_byte: Option<u64>,
1765
1766 hash_blake2b256_cost_base: Option<u64>,
1768 hash_blake2b256_data_cost_per_byte: Option<u64>,
1769 hash_blake2b256_data_cost_per_block: Option<u64>,
1770
1771 hash_keccak256_cost_base: Option<u64>,
1773 hash_keccak256_data_cost_per_byte: Option<u64>,
1774 hash_keccak256_data_cost_per_block: Option<u64>,
1775
1776 poseidon_bn254_cost_base: Option<u64>,
1778 poseidon_bn254_cost_per_block: Option<u64>,
1779
1780 group_ops_bls12381_decode_scalar_cost: Option<u64>,
1782 group_ops_bls12381_decode_g1_cost: Option<u64>,
1783 group_ops_bls12381_decode_g2_cost: Option<u64>,
1784 group_ops_bls12381_decode_gt_cost: Option<u64>,
1785 group_ops_bls12381_scalar_add_cost: Option<u64>,
1786 group_ops_bls12381_g1_add_cost: Option<u64>,
1787 group_ops_bls12381_g2_add_cost: Option<u64>,
1788 group_ops_bls12381_gt_add_cost: Option<u64>,
1789 group_ops_bls12381_scalar_sub_cost: Option<u64>,
1790 group_ops_bls12381_g1_sub_cost: Option<u64>,
1791 group_ops_bls12381_g2_sub_cost: Option<u64>,
1792 group_ops_bls12381_gt_sub_cost: Option<u64>,
1793 group_ops_bls12381_scalar_mul_cost: Option<u64>,
1794 group_ops_bls12381_g1_mul_cost: Option<u64>,
1795 group_ops_bls12381_g2_mul_cost: Option<u64>,
1796 group_ops_bls12381_gt_mul_cost: Option<u64>,
1797 group_ops_bls12381_scalar_div_cost: Option<u64>,
1798 group_ops_bls12381_g1_div_cost: Option<u64>,
1799 group_ops_bls12381_g2_div_cost: Option<u64>,
1800 group_ops_bls12381_gt_div_cost: Option<u64>,
1801 group_ops_bls12381_g1_hash_to_base_cost: Option<u64>,
1802 group_ops_bls12381_g2_hash_to_base_cost: Option<u64>,
1803 group_ops_bls12381_g1_hash_to_cost_per_byte: Option<u64>,
1804 group_ops_bls12381_g2_hash_to_cost_per_byte: Option<u64>,
1805 group_ops_bls12381_g1_msm_base_cost: Option<u64>,
1806 group_ops_bls12381_g2_msm_base_cost: Option<u64>,
1807 group_ops_bls12381_g1_msm_base_cost_per_input: Option<u64>,
1808 group_ops_bls12381_g2_msm_base_cost_per_input: Option<u64>,
1809 group_ops_bls12381_msm_max_len: Option<u32>,
1810 group_ops_bls12381_pairing_cost: Option<u64>,
1811 group_ops_bls12381_g1_to_uncompressed_g1_cost: Option<u64>,
1812 group_ops_bls12381_uncompressed_g1_to_g1_cost: Option<u64>,
1813 group_ops_bls12381_uncompressed_g1_sum_base_cost: Option<u64>,
1814 group_ops_bls12381_uncompressed_g1_sum_cost_per_term: Option<u64>,
1815 group_ops_bls12381_uncompressed_g1_sum_max_terms: Option<u64>,
1816
1817 group_ops_ristretto_decode_scalar_cost: Option<u64>,
1818 group_ops_ristretto_decode_point_cost: Option<u64>,
1819 group_ops_ristretto_scalar_add_cost: Option<u64>,
1820 group_ops_ristretto_point_add_cost: Option<u64>,
1821 group_ops_ristretto_scalar_sub_cost: Option<u64>,
1822 group_ops_ristretto_point_sub_cost: Option<u64>,
1823 group_ops_ristretto_scalar_mul_cost: Option<u64>,
1824 group_ops_ristretto_point_mul_cost: Option<u64>,
1825 group_ops_ristretto_scalar_div_cost: Option<u64>,
1826 group_ops_ristretto_point_div_cost: Option<u64>,
1827
1828 verify_bulletproofs_ristretto255_base_cost: Option<u64>,
1829 verify_bulletproofs_ristretto255_cost_per_bit_and_commitment: Option<u64>,
1830
1831 hmac_hmac_sha3_256_cost_base: Option<u64>,
1833 hmac_hmac_sha3_256_input_cost_per_byte: Option<u64>,
1834 hmac_hmac_sha3_256_input_cost_per_block: Option<u64>,
1835
1836 check_zklogin_id_cost_base: Option<u64>,
1838 check_zklogin_issuer_cost_base: Option<u64>,
1840
1841 vdf_verify_vdf_cost: Option<u64>,
1842 vdf_hash_to_input_cost: Option<u64>,
1843
1844 nitro_attestation_parse_base_cost: Option<u64>,
1846 nitro_attestation_parse_cost_per_byte: Option<u64>,
1847 nitro_attestation_verify_base_cost: Option<u64>,
1848 nitro_attestation_verify_cost_per_cert: Option<u64>,
1849
1850 bcs_per_byte_serialized_cost: Option<u64>,
1852 bcs_legacy_min_output_size_cost: Option<u64>,
1853 bcs_failure_cost: Option<u64>,
1854
1855 hash_sha2_256_base_cost: Option<u64>,
1856 hash_sha2_256_per_byte_cost: Option<u64>,
1857 hash_sha2_256_legacy_min_input_len_cost: Option<u64>,
1858 hash_sha3_256_base_cost: Option<u64>,
1859 hash_sha3_256_per_byte_cost: Option<u64>,
1860 hash_sha3_256_legacy_min_input_len_cost: Option<u64>,
1861 type_name_get_base_cost: Option<u64>,
1862 type_name_get_per_byte_cost: Option<u64>,
1863 type_name_id_base_cost: Option<u64>,
1864
1865 string_check_utf8_base_cost: Option<u64>,
1866 string_check_utf8_per_byte_cost: Option<u64>,
1867 string_is_char_boundary_base_cost: Option<u64>,
1868 string_sub_string_base_cost: Option<u64>,
1869 string_sub_string_per_byte_cost: Option<u64>,
1870 string_index_of_base_cost: Option<u64>,
1871 string_index_of_per_byte_pattern_cost: Option<u64>,
1872 string_index_of_per_byte_searched_cost: Option<u64>,
1873
1874 vector_empty_base_cost: Option<u64>,
1875 vector_length_base_cost: Option<u64>,
1876 vector_push_back_base_cost: Option<u64>,
1877 vector_push_back_legacy_per_abstract_memory_unit_cost: Option<u64>,
1878 vector_borrow_base_cost: Option<u64>,
1879 vector_pop_back_base_cost: Option<u64>,
1880 vector_destroy_empty_base_cost: Option<u64>,
1881 vector_swap_base_cost: Option<u64>,
1882 debug_print_base_cost: Option<u64>,
1883 debug_print_stack_trace_base_cost: Option<u64>,
1884
1885 execution_version: Option<u64>,
1894
1895 consensus_bad_nodes_stake_threshold: Option<u64>,
1899
1900 max_jwk_votes_per_validator_per_epoch: Option<u64>,
1901 max_age_of_jwk_in_epochs: Option<u64>,
1905
1906 random_beacon_reduction_allowed_delta: Option<u16>,
1910
1911 random_beacon_reduction_lower_bound: Option<u32>,
1914
1915 random_beacon_dkg_timeout_round: Option<u32>,
1918
1919 random_beacon_min_round_interval_ms: Option<u64>,
1921
1922 random_beacon_dkg_version: Option<u64>,
1925
1926 consensus_max_transaction_size_bytes: Option<u64>,
1929 consensus_max_transactions_in_block_bytes: Option<u64>,
1931 consensus_max_num_transactions_in_block: Option<u64>,
1933
1934 consensus_voting_rounds: Option<u32>,
1936
1937 max_accumulated_txn_cost_per_object_in_narwhal_commit: Option<u64>,
1939
1940 max_deferral_rounds_for_congestion_control: Option<u64>,
1943
1944 max_txn_cost_overage_per_object_in_commit: Option<u64>,
1946
1947 allowed_txn_cost_overage_burst_per_object_in_commit: Option<u64>,
1949
1950 min_checkpoint_interval_ms: Option<u64>,
1952
1953 checkpoint_summary_version_specific_data: Option<u64>,
1955
1956 max_soft_bundle_size: Option<u64>,
1958
1959 bridge_should_try_to_finalize_committee: Option<bool>,
1963
1964 max_accumulated_txn_cost_per_object_in_mysticeti_commit: Option<u64>,
1970
1971 max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit: Option<u64>,
1974
1975 consensus_gc_depth: Option<u32>,
1978
1979 gas_budget_based_txn_cost_cap_factor: Option<u64>,
1981
1982 gas_budget_based_txn_cost_absolute_cap_commit_count: Option<u64>,
1984
1985 sip_45_consensus_amplification_threshold: Option<u64>,
1988
1989 use_object_per_epoch_marker_table_v2: Option<bool>,
1992
1993 consensus_commit_rate_estimation_window_size: Option<u32>,
1995
1996 #[serde(skip_serializing_if = "Vec::is_empty")]
2000 aliased_addresses: Vec<AliasedAddress>,
2001
2002 translation_per_command_base_charge: Option<u64>,
2005
2006 translation_per_input_base_charge: Option<u64>,
2009
2010 translation_pure_input_per_byte_charge: Option<u64>,
2012
2013 translation_per_type_node_charge: Option<u64>,
2017
2018 translation_per_reference_node_charge: Option<u64>,
2021
2022 translation_per_linkage_entry_charge: Option<u64>,
2025
2026 max_updates_per_settlement_txn: Option<u32>,
2028
2029 gasless_max_computation_units: Option<u64>,
2031
2032 gasless_allowed_token_types: Option<Vec<(String, u64)>>,
2034
2035 gasless_max_unused_inputs: Option<u64>,
2039
2040 gasless_max_pure_input_bytes: Option<u64>,
2043
2044 gasless_max_tps: Option<u64>,
2046
2047 #[serde(skip_serializing_if = "Option::is_none")]
2048 #[skip_accessor]
2049 include_special_package_amendments: Option<Arc<Amendments>>,
2050
2051 gasless_max_tx_size_bytes: Option<u64>,
2054}
2055
2056#[derive(Clone, Serialize, Deserialize, Debug)]
2058pub struct AliasedAddress {
2059 pub original: [u8; 32],
2061 pub aliased: [u8; 32],
2063 pub allowed_tx_digests: Vec<[u8; 32]>,
2065}
2066
2067impl ProtocolConfig {
2069 pub fn chain(&self) -> Chain {
2071 self.chain
2072 }
2073
2074 pub fn check_package_upgrades_supported(&self) -> Result<(), Error> {
2087 if self.feature_flags.package_upgrades {
2088 Ok(())
2089 } else {
2090 Err(Error(format!(
2091 "package upgrades are not supported at {:?}",
2092 self.version
2093 )))
2094 }
2095 }
2096
2097 pub fn allow_receiving_object_id(&self) -> bool {
2098 self.feature_flags.allow_receiving_object_id
2099 }
2100
2101 pub fn receiving_objects_supported(&self) -> bool {
2102 self.feature_flags.receive_objects
2103 }
2104
2105 pub fn package_upgrades_supported(&self) -> bool {
2106 self.feature_flags.package_upgrades
2107 }
2108
2109 pub fn check_commit_root_state_digest_supported(&self) -> bool {
2110 self.feature_flags.commit_root_state_digest
2111 }
2112
2113 pub fn get_advance_epoch_start_time_in_safe_mode(&self) -> bool {
2114 self.feature_flags.advance_epoch_start_time_in_safe_mode
2115 }
2116
2117 pub fn loaded_child_objects_fixed(&self) -> bool {
2118 self.feature_flags.loaded_child_objects_fixed
2119 }
2120
2121 pub fn missing_type_is_compatibility_error(&self) -> bool {
2122 self.feature_flags.missing_type_is_compatibility_error
2123 }
2124
2125 pub fn scoring_decision_with_validity_cutoff(&self) -> bool {
2126 self.feature_flags.scoring_decision_with_validity_cutoff
2127 }
2128
2129 pub fn narwhal_versioned_metadata(&self) -> bool {
2130 self.feature_flags.narwhal_versioned_metadata
2131 }
2132
2133 pub fn consensus_order_end_of_epoch_last(&self) -> bool {
2134 self.feature_flags.consensus_order_end_of_epoch_last
2135 }
2136
2137 pub fn disallow_adding_abilities_on_upgrade(&self) -> bool {
2138 self.feature_flags.disallow_adding_abilities_on_upgrade
2139 }
2140
2141 pub fn disable_invariant_violation_check_in_swap_loc(&self) -> bool {
2142 self.feature_flags
2143 .disable_invariant_violation_check_in_swap_loc
2144 }
2145
2146 pub fn advance_to_highest_supported_protocol_version(&self) -> bool {
2147 self.feature_flags
2148 .advance_to_highest_supported_protocol_version
2149 }
2150
2151 pub fn ban_entry_init(&self) -> bool {
2152 self.feature_flags.ban_entry_init
2153 }
2154
2155 pub fn package_digest_hash_module(&self) -> bool {
2156 self.feature_flags.package_digest_hash_module
2157 }
2158
2159 pub fn disallow_change_struct_type_params_on_upgrade(&self) -> bool {
2160 self.feature_flags
2161 .disallow_change_struct_type_params_on_upgrade
2162 }
2163
2164 pub fn no_extraneous_module_bytes(&self) -> bool {
2165 self.feature_flags.no_extraneous_module_bytes
2166 }
2167
2168 pub fn zklogin_auth(&self) -> bool {
2169 self.feature_flags.zklogin_auth
2170 }
2171
2172 pub fn zklogin_supported_providers(&self) -> &BTreeSet<String> {
2173 &self.feature_flags.zklogin_supported_providers
2174 }
2175
2176 pub fn consensus_transaction_ordering(&self) -> ConsensusTransactionOrdering {
2177 self.feature_flags.consensus_transaction_ordering
2178 }
2179
2180 pub fn simplified_unwrap_then_delete(&self) -> bool {
2181 self.feature_flags.simplified_unwrap_then_delete
2182 }
2183
2184 pub fn supports_upgraded_multisig(&self) -> bool {
2185 self.feature_flags.upgraded_multisig_supported
2186 }
2187
2188 pub fn txn_base_cost_as_multiplier(&self) -> bool {
2189 self.feature_flags.txn_base_cost_as_multiplier
2190 }
2191
2192 pub fn shared_object_deletion(&self) -> bool {
2193 self.feature_flags.shared_object_deletion
2194 }
2195
2196 pub fn narwhal_new_leader_election_schedule(&self) -> bool {
2197 self.feature_flags.narwhal_new_leader_election_schedule
2198 }
2199
2200 pub fn loaded_child_object_format(&self) -> bool {
2201 self.feature_flags.loaded_child_object_format
2202 }
2203
2204 pub fn enable_jwk_consensus_updates(&self) -> bool {
2205 let ret = self.feature_flags.enable_jwk_consensus_updates;
2206 if ret {
2207 assert!(self.feature_flags.end_of_epoch_transaction_supported);
2209 }
2210 ret
2211 }
2212
2213 pub fn simple_conservation_checks(&self) -> bool {
2214 self.feature_flags.simple_conservation_checks
2215 }
2216
2217 pub fn loaded_child_object_format_type(&self) -> bool {
2218 self.feature_flags.loaded_child_object_format_type
2219 }
2220
2221 pub fn end_of_epoch_transaction_supported(&self) -> bool {
2222 let ret = self.feature_flags.end_of_epoch_transaction_supported;
2223 if !ret {
2224 assert!(!self.feature_flags.enable_jwk_consensus_updates);
2226 }
2227 ret
2228 }
2229
2230 pub fn recompute_has_public_transfer_in_execution(&self) -> bool {
2231 self.feature_flags
2232 .recompute_has_public_transfer_in_execution
2233 }
2234
2235 pub fn create_authenticator_state_in_genesis(&self) -> bool {
2237 self.enable_jwk_consensus_updates()
2238 }
2239
2240 pub fn random_beacon(&self) -> bool {
2241 self.feature_flags.random_beacon
2242 }
2243
2244 pub fn dkg_version(&self) -> u64 {
2245 self.random_beacon_dkg_version.unwrap_or(1)
2247 }
2248
2249 pub fn enable_bridge(&self) -> bool {
2250 let ret = self.feature_flags.bridge;
2251 if ret {
2252 assert!(self.feature_flags.end_of_epoch_transaction_supported);
2254 }
2255 ret
2256 }
2257
2258 pub fn should_try_to_finalize_bridge_committee(&self) -> bool {
2259 if !self.enable_bridge() {
2260 return false;
2261 }
2262 self.bridge_should_try_to_finalize_committee.unwrap_or(true)
2264 }
2265
2266 pub fn enable_effects_v2(&self) -> bool {
2267 self.feature_flags.enable_effects_v2
2268 }
2269
2270 pub fn narwhal_certificate_v2(&self) -> bool {
2271 self.feature_flags.narwhal_certificate_v2
2272 }
2273
2274 pub fn verify_legacy_zklogin_address(&self) -> bool {
2275 self.feature_flags.verify_legacy_zklogin_address
2276 }
2277
2278 pub fn accept_zklogin_in_multisig(&self) -> bool {
2279 self.feature_flags.accept_zklogin_in_multisig
2280 }
2281
2282 pub fn accept_passkey_in_multisig(&self) -> bool {
2283 self.feature_flags.accept_passkey_in_multisig
2284 }
2285
2286 pub fn validate_zklogin_public_identifier(&self) -> bool {
2287 self.feature_flags.validate_zklogin_public_identifier
2288 }
2289
2290 pub fn zklogin_max_epoch_upper_bound_delta(&self) -> Option<u64> {
2291 self.feature_flags.zklogin_max_epoch_upper_bound_delta
2292 }
2293
2294 pub fn throughput_aware_consensus_submission(&self) -> bool {
2295 self.feature_flags.throughput_aware_consensus_submission
2296 }
2297
2298 pub fn include_consensus_digest_in_prologue(&self) -> bool {
2299 self.feature_flags.include_consensus_digest_in_prologue
2300 }
2301
2302 pub fn record_consensus_determined_version_assignments_in_prologue(&self) -> bool {
2303 self.feature_flags
2304 .record_consensus_determined_version_assignments_in_prologue
2305 }
2306
2307 pub fn record_additional_state_digest_in_prologue(&self) -> bool {
2308 self.feature_flags
2309 .record_additional_state_digest_in_prologue
2310 }
2311
2312 pub fn record_consensus_determined_version_assignments_in_prologue_v2(&self) -> bool {
2313 self.feature_flags
2314 .record_consensus_determined_version_assignments_in_prologue_v2
2315 }
2316
2317 pub fn prepend_prologue_tx_in_consensus_commit_in_checkpoints(&self) -> bool {
2318 self.feature_flags
2319 .prepend_prologue_tx_in_consensus_commit_in_checkpoints
2320 }
2321
2322 pub fn hardened_otw_check(&self) -> bool {
2323 self.feature_flags.hardened_otw_check
2324 }
2325
2326 pub fn enable_poseidon(&self) -> bool {
2327 self.feature_flags.enable_poseidon
2328 }
2329
2330 pub fn enable_coin_deny_list_v1(&self) -> bool {
2331 self.feature_flags.enable_coin_deny_list
2332 }
2333
2334 pub fn enable_accumulators(&self) -> bool {
2335 self.feature_flags.enable_accumulators
2336 }
2337
2338 pub fn enable_coin_reservation_obj_refs(&self) -> bool {
2339 self.new_vm_enabled() && self.feature_flags.enable_coin_reservation_obj_refs
2340 }
2341
2342 pub fn create_root_accumulator_object(&self) -> bool {
2343 self.feature_flags.create_root_accumulator_object
2344 }
2345
2346 pub fn enable_address_balance_gas_payments(&self) -> bool {
2347 self.feature_flags.enable_address_balance_gas_payments
2348 }
2349
2350 pub fn address_balance_gas_check_rgp_at_signing(&self) -> bool {
2351 self.feature_flags.address_balance_gas_check_rgp_at_signing
2352 }
2353
2354 pub fn address_balance_gas_reject_gas_coin_arg(&self) -> bool {
2355 self.feature_flags.address_balance_gas_reject_gas_coin_arg
2356 }
2357
2358 pub fn enable_multi_epoch_transaction_expiration(&self) -> bool {
2359 self.feature_flags.enable_multi_epoch_transaction_expiration
2360 }
2361
2362 pub fn relax_valid_during_for_owned_inputs(&self) -> bool {
2363 self.feature_flags.relax_valid_during_for_owned_inputs
2364 }
2365
2366 pub fn enable_authenticated_event_streams(&self) -> bool {
2367 self.feature_flags.enable_authenticated_event_streams && self.enable_accumulators()
2368 }
2369
2370 pub fn enable_non_exclusive_writes(&self) -> bool {
2371 self.feature_flags.enable_non_exclusive_writes
2372 }
2373
2374 pub fn enable_coin_registry(&self) -> bool {
2375 self.feature_flags.enable_coin_registry
2376 }
2377
2378 pub fn enable_display_registry(&self) -> bool {
2379 self.feature_flags.enable_display_registry
2380 }
2381
2382 pub fn enable_coin_deny_list_v2(&self) -> bool {
2383 self.feature_flags.enable_coin_deny_list_v2
2384 }
2385
2386 pub fn enable_group_ops_native_functions(&self) -> bool {
2387 self.feature_flags.enable_group_ops_native_functions
2388 }
2389
2390 pub fn enable_group_ops_native_function_msm(&self) -> bool {
2391 self.feature_flags.enable_group_ops_native_function_msm
2392 }
2393
2394 pub fn enable_ristretto255_group_ops(&self) -> bool {
2395 self.feature_flags.enable_ristretto255_group_ops
2396 }
2397
2398 pub fn enable_verify_bulletproofs_ristretto255(&self) -> bool {
2399 self.feature_flags.enable_verify_bulletproofs_ristretto255
2400 }
2401
2402 pub fn reject_mutable_random_on_entry_functions(&self) -> bool {
2403 self.feature_flags.reject_mutable_random_on_entry_functions
2404 }
2405
2406 pub fn per_object_congestion_control_mode(&self) -> PerObjectCongestionControlMode {
2407 self.feature_flags.per_object_congestion_control_mode
2408 }
2409
2410 pub fn consensus_choice(&self) -> ConsensusChoice {
2411 self.feature_flags.consensus_choice
2412 }
2413
2414 pub fn consensus_network(&self) -> ConsensusNetwork {
2415 self.feature_flags.consensus_network
2416 }
2417
2418 pub fn correct_gas_payment_limit_check(&self) -> bool {
2419 self.feature_flags.correct_gas_payment_limit_check
2420 }
2421
2422 pub fn reshare_at_same_initial_version(&self) -> bool {
2423 self.feature_flags.reshare_at_same_initial_version
2424 }
2425
2426 pub fn resolve_abort_locations_to_package_id(&self) -> bool {
2427 self.feature_flags.resolve_abort_locations_to_package_id
2428 }
2429
2430 pub fn mysticeti_use_committed_subdag_digest(&self) -> bool {
2431 self.feature_flags.mysticeti_use_committed_subdag_digest
2432 }
2433
2434 pub fn enable_vdf(&self) -> bool {
2435 self.feature_flags.enable_vdf
2436 }
2437
2438 pub fn fresh_vm_on_framework_upgrade(&self) -> bool {
2439 self.feature_flags.fresh_vm_on_framework_upgrade
2440 }
2441
2442 pub fn mysticeti_num_leaders_per_round(&self) -> Option<usize> {
2443 self.feature_flags.mysticeti_num_leaders_per_round
2444 }
2445
2446 pub fn soft_bundle(&self) -> bool {
2447 self.feature_flags.soft_bundle
2448 }
2449
2450 pub fn passkey_auth(&self) -> bool {
2451 self.feature_flags.passkey_auth
2452 }
2453
2454 pub fn authority_capabilities_v2(&self) -> bool {
2455 self.feature_flags.authority_capabilities_v2
2456 }
2457
2458 pub fn max_transaction_size_bytes(&self) -> u64 {
2459 self.consensus_max_transaction_size_bytes
2461 .unwrap_or(256 * 1024)
2462 }
2463
2464 pub fn max_transactions_in_block_bytes(&self) -> u64 {
2465 if cfg!(msim) {
2466 256 * 1024
2467 } else {
2468 self.consensus_max_transactions_in_block_bytes
2469 .unwrap_or(512 * 1024)
2470 }
2471 }
2472
2473 pub fn max_num_transactions_in_block(&self) -> u64 {
2474 if cfg!(msim) {
2475 8
2476 } else {
2477 self.consensus_max_num_transactions_in_block.unwrap_or(512)
2478 }
2479 }
2480
2481 pub fn rethrow_serialization_type_layout_errors(&self) -> bool {
2482 self.feature_flags.rethrow_serialization_type_layout_errors
2483 }
2484
2485 pub fn consensus_distributed_vote_scoring_strategy(&self) -> bool {
2486 self.feature_flags
2487 .consensus_distributed_vote_scoring_strategy
2488 }
2489
2490 pub fn consensus_round_prober(&self) -> bool {
2491 self.feature_flags.consensus_round_prober
2492 }
2493
2494 pub fn validate_identifier_inputs(&self) -> bool {
2495 self.feature_flags.validate_identifier_inputs
2496 }
2497
2498 pub fn gc_depth(&self) -> u32 {
2499 self.consensus_gc_depth.unwrap_or(0)
2500 }
2501
2502 pub fn mysticeti_fastpath(&self) -> bool {
2503 self.feature_flags.mysticeti_fastpath
2504 }
2505
2506 pub fn relocate_event_module(&self) -> bool {
2507 self.feature_flags.relocate_event_module
2508 }
2509
2510 pub fn uncompressed_g1_group_elements(&self) -> bool {
2511 self.feature_flags.uncompressed_g1_group_elements
2512 }
2513
2514 pub fn disallow_new_modules_in_deps_only_packages(&self) -> bool {
2515 self.feature_flags
2516 .disallow_new_modules_in_deps_only_packages
2517 }
2518
2519 pub fn consensus_smart_ancestor_selection(&self) -> bool {
2520 self.feature_flags.consensus_smart_ancestor_selection
2521 }
2522
2523 pub fn disable_preconsensus_locking(&self) -> bool {
2524 self.feature_flags.disable_preconsensus_locking
2525 }
2526
2527 pub fn consensus_round_prober_probe_accepted_rounds(&self) -> bool {
2528 self.feature_flags
2529 .consensus_round_prober_probe_accepted_rounds
2530 }
2531
2532 pub fn native_charging_v2(&self) -> bool {
2533 self.feature_flags.native_charging_v2
2534 }
2535
2536 pub fn consensus_linearize_subdag_v2(&self) -> bool {
2537 let res = self.feature_flags.consensus_linearize_subdag_v2;
2538 assert!(
2539 !res || self.gc_depth() > 0,
2540 "The consensus linearize sub dag V2 requires GC to be enabled"
2541 );
2542 res
2543 }
2544
2545 pub fn consensus_median_based_commit_timestamp(&self) -> bool {
2546 let res = self.feature_flags.consensus_median_based_commit_timestamp;
2547 assert!(
2548 !res || self.gc_depth() > 0,
2549 "The consensus median based commit timestamp requires GC to be enabled"
2550 );
2551 res
2552 }
2553
2554 pub fn consensus_batched_block_sync(&self) -> bool {
2555 self.feature_flags.consensus_batched_block_sync
2556 }
2557
2558 pub fn convert_type_argument_error(&self) -> bool {
2559 self.feature_flags.convert_type_argument_error
2560 }
2561
2562 pub fn variant_nodes(&self) -> bool {
2563 self.feature_flags.variant_nodes
2564 }
2565
2566 pub fn consensus_zstd_compression(&self) -> bool {
2567 self.feature_flags.consensus_zstd_compression
2568 }
2569
2570 pub fn enable_nitro_attestation(&self) -> bool {
2571 self.feature_flags.enable_nitro_attestation
2572 }
2573
2574 pub fn enable_nitro_attestation_upgraded_parsing(&self) -> bool {
2575 self.feature_flags.enable_nitro_attestation_upgraded_parsing
2576 }
2577
2578 pub fn enable_nitro_attestation_all_nonzero_pcrs_parsing(&self) -> bool {
2579 self.feature_flags
2580 .enable_nitro_attestation_all_nonzero_pcrs_parsing
2581 }
2582
2583 pub fn enable_nitro_attestation_always_include_required_pcrs_parsing(&self) -> bool {
2584 self.feature_flags
2585 .enable_nitro_attestation_always_include_required_pcrs_parsing
2586 }
2587
2588 pub fn get_consensus_commit_rate_estimation_window_size(&self) -> u32 {
2589 self.consensus_commit_rate_estimation_window_size
2590 .unwrap_or(0)
2591 }
2592
2593 pub fn consensus_num_requested_prior_commits_at_startup(&self) -> u32 {
2594 let window_size = self.get_consensus_commit_rate_estimation_window_size();
2598 assert!(window_size == 0 || self.record_additional_state_digest_in_prologue());
2600 window_size
2601 }
2602
2603 pub fn minimize_child_object_mutations(&self) -> bool {
2604 self.feature_flags.minimize_child_object_mutations
2605 }
2606
2607 pub fn move_native_context(&self) -> bool {
2608 self.feature_flags.move_native_context
2609 }
2610
2611 pub fn normalize_ptb_arguments(&self) -> bool {
2612 self.feature_flags.normalize_ptb_arguments
2613 }
2614
2615 pub fn enforce_checkpoint_timestamp_monotonicity(&self) -> bool {
2616 self.feature_flags.enforce_checkpoint_timestamp_monotonicity
2617 }
2618
2619 pub fn max_ptb_value_size_v2(&self) -> bool {
2620 self.feature_flags.max_ptb_value_size_v2
2621 }
2622
2623 pub fn resolve_type_input_ids_to_defining_id(&self) -> bool {
2624 self.feature_flags.resolve_type_input_ids_to_defining_id
2625 }
2626
2627 pub fn enable_party_transfer(&self) -> bool {
2628 self.feature_flags.enable_party_transfer
2629 }
2630
2631 pub fn allow_unbounded_system_objects(&self) -> bool {
2632 self.feature_flags.allow_unbounded_system_objects
2633 }
2634
2635 pub fn type_tags_in_object_runtime(&self) -> bool {
2636 self.feature_flags.type_tags_in_object_runtime
2637 }
2638
2639 pub fn enable_ptb_execution_v2(&self) -> bool {
2640 self.feature_flags.enable_ptb_execution_v2
2641 }
2642
2643 pub fn better_adapter_type_resolution_errors(&self) -> bool {
2644 self.feature_flags.better_adapter_type_resolution_errors
2645 }
2646
2647 pub fn record_time_estimate_processed(&self) -> bool {
2648 self.feature_flags.record_time_estimate_processed
2649 }
2650
2651 pub fn ignore_execution_time_observations_after_certs_closed(&self) -> bool {
2652 self.feature_flags
2653 .ignore_execution_time_observations_after_certs_closed
2654 }
2655
2656 pub fn dependency_linkage_error(&self) -> bool {
2657 self.feature_flags.dependency_linkage_error
2658 }
2659
2660 pub fn additional_multisig_checks(&self) -> bool {
2661 self.feature_flags.additional_multisig_checks
2662 }
2663
2664 pub fn debug_fatal_on_move_invariant_violation(&self) -> bool {
2665 self.feature_flags.debug_fatal_on_move_invariant_violation
2666 }
2667
2668 pub fn allow_private_accumulator_entrypoints(&self) -> bool {
2669 self.feature_flags.allow_private_accumulator_entrypoints
2670 }
2671
2672 pub fn additional_consensus_digest_indirect_state(&self) -> bool {
2673 self.feature_flags
2674 .additional_consensus_digest_indirect_state
2675 }
2676
2677 pub fn check_for_init_during_upgrade(&self) -> bool {
2678 self.feature_flags.check_for_init_during_upgrade
2679 }
2680
2681 pub fn per_command_shared_object_transfer_rules(&self) -> bool {
2682 self.feature_flags.per_command_shared_object_transfer_rules
2683 }
2684
2685 pub fn consensus_checkpoint_signature_key_includes_digest(&self) -> bool {
2686 self.feature_flags
2687 .consensus_checkpoint_signature_key_includes_digest
2688 }
2689
2690 pub fn include_checkpoint_artifacts_digest_in_summary(&self) -> bool {
2691 self.feature_flags
2692 .include_checkpoint_artifacts_digest_in_summary
2693 }
2694
2695 pub fn use_mfp_txns_in_load_initial_object_debts(&self) -> bool {
2696 self.feature_flags.use_mfp_txns_in_load_initial_object_debts
2697 }
2698
2699 pub fn cancel_for_failed_dkg_early(&self) -> bool {
2700 self.feature_flags.cancel_for_failed_dkg_early
2701 }
2702
2703 pub fn always_advance_dkg_to_resolution(&self) -> bool {
2704 self.feature_flags.always_advance_dkg_to_resolution
2705 }
2706
2707 pub fn abstract_size_in_object_runtime(&self) -> bool {
2708 self.feature_flags.abstract_size_in_object_runtime
2709 }
2710
2711 pub fn object_runtime_charge_cache_load_gas(&self) -> bool {
2712 self.feature_flags.object_runtime_charge_cache_load_gas
2713 }
2714
2715 pub fn additional_borrow_checks(&self) -> bool {
2716 self.feature_flags.additional_borrow_checks
2717 }
2718
2719 pub fn use_new_commit_handler(&self) -> bool {
2720 self.feature_flags.use_new_commit_handler
2721 }
2722
2723 pub fn better_loader_errors(&self) -> bool {
2724 self.feature_flags.better_loader_errors
2725 }
2726
2727 pub fn generate_df_type_layouts(&self) -> bool {
2728 self.feature_flags.generate_df_type_layouts
2729 }
2730
2731 pub fn allow_references_in_ptbs(&self) -> bool {
2732 self.feature_flags.allow_references_in_ptbs
2733 }
2734
2735 pub fn private_generics_verifier_v2(&self) -> bool {
2736 self.feature_flags.private_generics_verifier_v2
2737 }
2738
2739 pub fn deprecate_global_storage_ops_during_deserialization(&self) -> bool {
2740 self.feature_flags
2741 .deprecate_global_storage_ops_during_deserialization
2742 }
2743
2744 pub fn enable_observation_chunking(&self) -> bool {
2745 matches!(self.feature_flags.per_object_congestion_control_mode,
2746 PerObjectCongestionControlMode::ExecutionTimeEstimate(ref params)
2747 if params.observations_chunk_size.is_some()
2748 )
2749 }
2750
2751 pub fn deprecate_global_storage_ops(&self) -> bool {
2752 self.feature_flags.deprecate_global_storage_ops
2753 }
2754
2755 pub fn normalize_depth_formula(&self) -> bool {
2756 self.feature_flags.normalize_depth_formula
2757 }
2758
2759 pub fn consensus_skip_gced_accept_votes(&self) -> bool {
2760 self.feature_flags.consensus_skip_gced_accept_votes
2761 }
2762
2763 pub fn include_cancelled_randomness_txns_in_prologue(&self) -> bool {
2764 self.feature_flags
2765 .include_cancelled_randomness_txns_in_prologue
2766 }
2767
2768 pub fn address_aliases(&self) -> bool {
2769 let address_aliases = self.feature_flags.address_aliases;
2770 assert!(
2771 !address_aliases || self.mysticeti_fastpath(),
2772 "Address aliases requires Mysticeti fastpath to be enabled"
2773 );
2774 if address_aliases {
2775 assert!(
2776 self.feature_flags.disable_preconsensus_locking,
2777 "Address aliases requires CertifiedTransaction to be disabled"
2778 );
2779 }
2780 address_aliases
2781 }
2782
2783 pub fn fix_checkpoint_signature_mapping(&self) -> bool {
2784 self.feature_flags.fix_checkpoint_signature_mapping
2785 }
2786
2787 pub fn enable_object_funds_withdraw(&self) -> bool {
2788 self.feature_flags.enable_object_funds_withdraw
2789 }
2790
2791 pub fn gas_rounding_halve_digits(&self) -> bool {
2792 self.feature_flags.gas_rounding_halve_digits
2793 }
2794
2795 pub fn flexible_tx_context_positions(&self) -> bool {
2796 self.feature_flags.flexible_tx_context_positions
2797 }
2798
2799 pub fn disable_entry_point_signature_check(&self) -> bool {
2800 self.feature_flags.disable_entry_point_signature_check
2801 }
2802
2803 pub fn consensus_skip_gced_blocks_in_direct_finalization(&self) -> bool {
2804 self.feature_flags
2805 .consensus_skip_gced_blocks_in_direct_finalization
2806 }
2807
2808 pub fn convert_withdrawal_compatibility_ptb_arguments(&self) -> bool {
2809 self.feature_flags
2810 .convert_withdrawal_compatibility_ptb_arguments
2811 }
2812
2813 pub fn restrict_hot_or_not_entry_functions(&self) -> bool {
2814 self.feature_flags.restrict_hot_or_not_entry_functions
2815 }
2816
2817 pub fn split_checkpoints_in_consensus_handler(&self) -> bool {
2818 self.feature_flags.split_checkpoints_in_consensus_handler
2819 }
2820
2821 pub fn consensus_always_accept_system_transactions(&self) -> bool {
2822 self.feature_flags
2823 .consensus_always_accept_system_transactions
2824 }
2825
2826 pub fn validator_metadata_verify_v2(&self) -> bool {
2827 self.feature_flags.validator_metadata_verify_v2
2828 }
2829
2830 pub fn defer_unpaid_amplification(&self) -> bool {
2831 self.feature_flags.defer_unpaid_amplification
2832 }
2833
2834 pub fn gasless_transaction_drop_safety(&self) -> bool {
2835 self.feature_flags.gasless_transaction_drop_safety
2836 }
2837
2838 pub fn new_vm_enabled(&self) -> bool {
2839 self.execution_version.is_some_and(|v| v >= 4)
2840 }
2841
2842 pub fn merge_randomness_into_checkpoint(&self) -> bool {
2843 self.feature_flags.merge_randomness_into_checkpoint
2844 }
2845
2846 pub fn use_coin_party_owner(&self) -> bool {
2847 self.feature_flags.use_coin_party_owner
2848 }
2849
2850 pub fn enable_gasless(&self) -> bool {
2851 self.feature_flags.enable_gasless
2852 }
2853
2854 pub fn gasless_verify_remaining_balance(&self) -> bool {
2855 self.feature_flags.gasless_verify_remaining_balance
2856 }
2857
2858 pub fn gasless_allowed_token_types(&self) -> &[(String, u64)] {
2859 debug_assert!(self.gasless_allowed_token_types.is_some());
2860 self.gasless_allowed_token_types.as_deref().unwrap_or(&[])
2861 }
2862
2863 pub fn get_gasless_max_unused_inputs(&self) -> u64 {
2864 self.gasless_max_unused_inputs.unwrap_or(u64::MAX)
2865 }
2866
2867 pub fn get_gasless_max_pure_input_bytes(&self) -> u64 {
2868 self.gasless_max_pure_input_bytes.unwrap_or(u64::MAX)
2869 }
2870
2871 pub fn get_gasless_max_tx_size_bytes(&self) -> u64 {
2872 self.gasless_max_tx_size_bytes.unwrap_or(u64::MAX)
2873 }
2874
2875 pub fn disallow_jump_orphans(&self) -> bool {
2876 self.feature_flags.disallow_jump_orphans
2877 }
2878
2879 pub fn early_return_receive_object_mismatched_type(&self) -> bool {
2880 self.feature_flags
2881 .early_return_receive_object_mismatched_type
2882 }
2883
2884 pub fn include_special_package_amendments_as_option(&self) -> &Option<Arc<Amendments>> {
2885 &self.include_special_package_amendments
2886 }
2887
2888 pub fn timestamp_based_epoch_close(&self) -> bool {
2889 self.feature_flags.timestamp_based_epoch_close
2890 }
2891
2892 pub fn limit_groth16_pvk_inputs(&self) -> bool {
2893 self.feature_flags.limit_groth16_pvk_inputs
2894 }
2895
2896 pub fn enforce_address_balance_change_invariant(&self) -> bool {
2897 self.feature_flags.enforce_address_balance_change_invariant
2898 }
2899
2900 pub fn granular_post_execution_checks(&self) -> bool {
2901 self.feature_flags.granular_post_execution_checks
2902 }
2903
2904 pub fn early_exit_on_iffw(&self) -> bool {
2905 self.feature_flags.early_exit_on_iffw
2906 }
2907
2908 pub fn enable_unified_linkage(&self) -> bool {
2909 self.feature_flags.enable_unified_linkage
2910 }
2911}
2912
2913#[cfg(not(msim))]
2914static POISON_VERSION_METHODS: AtomicBool = AtomicBool::new(false);
2915
2916#[cfg(msim)]
2918thread_local! {
2919 static POISON_VERSION_METHODS: AtomicBool = AtomicBool::new(false);
2920}
2921
2922impl ProtocolConfig {
2924 pub fn get_for_version(version: ProtocolVersion, chain: Chain) -> Self {
2926 assert!(
2928 version >= ProtocolVersion::MIN,
2929 "Network protocol version is {:?}, but the minimum supported version by the binary is {:?}. Please upgrade the binary.",
2930 version,
2931 ProtocolVersion::MIN.0,
2932 );
2933 assert!(
2934 version <= ProtocolVersion::MAX_ALLOWED,
2935 "Network protocol version is {:?}, but the maximum supported version by the binary is {:?}. Please upgrade the binary.",
2936 version,
2937 ProtocolVersion::MAX_ALLOWED.0,
2938 );
2939
2940 let mut ret = Self::get_for_version_impl(version, chain);
2941 ret.version = version;
2942 ret.chain = chain;
2943
2944 ret = Self::apply_config_override(version, ret);
2945
2946 if std::env::var("SUI_PROTOCOL_CONFIG_OVERRIDE_ENABLE").is_ok() {
2947 warn!(
2948 "overriding ProtocolConfig settings with custom settings; this may break non-local networks"
2949 );
2950 let overrides: ProtocolConfigOptional =
2951 serde_env::from_env_with_prefix("SUI_PROTOCOL_CONFIG_OVERRIDE")
2952 .expect("failed to parse ProtocolConfig override env variables");
2953 overrides.apply_to(&mut ret);
2954 }
2955
2956 ret
2957 }
2958
2959 pub fn get_for_version_if_supported(version: ProtocolVersion, chain: Chain) -> Option<Self> {
2962 if version.0 >= ProtocolVersion::MIN.0 && version.0 <= ProtocolVersion::MAX_ALLOWED.0 {
2963 let mut ret = Self::get_for_version_impl(version, chain);
2964 ret.version = version;
2965 ret.chain = chain;
2966 ret = Self::apply_config_override(version, ret);
2967 Some(ret)
2968 } else {
2969 None
2970 }
2971 }
2972
2973 #[cfg(not(msim))]
2974 pub fn poison_get_for_min_version() {
2975 POISON_VERSION_METHODS.store(true, Ordering::Relaxed);
2976 }
2977
2978 #[cfg(not(msim))]
2979 fn load_poison_get_for_min_version() -> bool {
2980 POISON_VERSION_METHODS.load(Ordering::Relaxed)
2981 }
2982
2983 #[cfg(msim)]
2984 pub fn poison_get_for_min_version() {
2985 POISON_VERSION_METHODS.with(|p| p.store(true, Ordering::Relaxed));
2986 }
2987
2988 #[cfg(msim)]
2989 fn load_poison_get_for_min_version() -> bool {
2990 POISON_VERSION_METHODS.with(|p| p.load(Ordering::Relaxed))
2991 }
2992
2993 pub fn get_for_min_version() -> Self {
2996 if Self::load_poison_get_for_min_version() {
2997 panic!("get_for_min_version called on validator");
2998 }
2999 ProtocolConfig::get_for_version(ProtocolVersion::MIN, Chain::Unknown)
3000 }
3001
3002 #[allow(non_snake_case)]
3012 pub fn get_for_max_version_UNSAFE() -> Self {
3013 if Self::load_poison_get_for_min_version() {
3014 panic!("get_for_max_version_UNSAFE called on validator");
3015 }
3016 ProtocolConfig::get_for_version(ProtocolVersion::MAX, Chain::Unknown)
3017 }
3018
3019 fn get_for_version_impl(version: ProtocolVersion, chain: Chain) -> Self {
3020 #[cfg(msim)]
3021 {
3022 if version == ProtocolVersion::MAX_ALLOWED {
3024 let mut config = Self::get_for_version_impl(version - 1, Chain::Unknown);
3025 config.base_tx_cost_fixed = Some(config.base_tx_cost_fixed() + 1000);
3026 return config;
3027 }
3028 }
3029
3030 let mut cfg = Self {
3033 version,
3035 chain,
3036
3037 feature_flags: Default::default(),
3039
3040 max_tx_size_bytes: Some(128 * 1024),
3041 max_input_objects: Some(2048),
3043 max_serialized_tx_effects_size_bytes: Some(512 * 1024),
3044 max_serialized_tx_effects_size_bytes_system_tx: Some(512 * 1024 * 16),
3045 max_gas_payment_objects: Some(256),
3046 max_modules_in_publish: Some(128),
3047 max_package_dependencies: None,
3048 max_arguments: Some(512),
3049 max_type_arguments: Some(16),
3050 max_type_argument_depth: Some(16),
3051 max_pure_argument_size: Some(16 * 1024),
3052 max_programmable_tx_commands: Some(1024),
3053 move_binary_format_version: Some(6),
3054 min_move_binary_format_version: None,
3055 binary_module_handles: None,
3056 binary_struct_handles: None,
3057 binary_function_handles: None,
3058 binary_function_instantiations: None,
3059 binary_signatures: None,
3060 binary_constant_pool: None,
3061 binary_identifiers: None,
3062 binary_address_identifiers: None,
3063 binary_struct_defs: None,
3064 binary_struct_def_instantiations: None,
3065 binary_function_defs: None,
3066 binary_field_handles: None,
3067 binary_field_instantiations: None,
3068 binary_friend_decls: None,
3069 binary_enum_defs: None,
3070 binary_enum_def_instantiations: None,
3071 binary_variant_handles: None,
3072 binary_variant_instantiation_handles: None,
3073 max_move_object_size: Some(250 * 1024),
3074 max_move_package_size: Some(100 * 1024),
3075 max_publish_or_upgrade_per_ptb: None,
3076 max_tx_gas: Some(10_000_000_000),
3077 max_gas_price: Some(100_000),
3078 max_gas_price_rgp_factor_for_aborted_transactions: None,
3079 max_gas_computation_bucket: Some(5_000_000),
3080 max_loop_depth: Some(5),
3081 max_generic_instantiation_length: Some(32),
3082 max_function_parameters: Some(128),
3083 max_basic_blocks: Some(1024),
3084 max_value_stack_size: Some(1024),
3085 max_type_nodes: Some(256),
3086 max_generic_instantiation_type_nodes_per_function: None,
3087 max_generic_instantiation_type_nodes_per_module: None,
3088 max_push_size: Some(10000),
3089 max_struct_definitions: Some(200),
3090 max_function_definitions: Some(1000),
3091 max_fields_in_struct: Some(32),
3092 max_dependency_depth: Some(100),
3093 max_num_event_emit: Some(256),
3094 max_num_new_move_object_ids: Some(2048),
3095 max_num_new_move_object_ids_system_tx: Some(2048 * 16),
3096 max_num_deleted_move_object_ids: Some(2048),
3097 max_num_deleted_move_object_ids_system_tx: Some(2048 * 16),
3098 max_num_transferred_move_object_ids: Some(2048),
3099 max_num_transferred_move_object_ids_system_tx: Some(2048 * 16),
3100 max_event_emit_size: Some(250 * 1024),
3101 max_move_vector_len: Some(256 * 1024),
3102 max_type_to_layout_nodes: None,
3103 max_ptb_value_size: None,
3104
3105 max_back_edges_per_function: Some(10_000),
3106 max_back_edges_per_module: Some(10_000),
3107 max_verifier_meter_ticks_per_function: Some(6_000_000),
3108 max_meter_ticks_per_module: Some(6_000_000),
3109 max_meter_ticks_per_package: None,
3110
3111 object_runtime_max_num_cached_objects: Some(1000),
3112 object_runtime_max_num_cached_objects_system_tx: Some(1000 * 16),
3113 object_runtime_max_num_store_entries: Some(1000),
3114 object_runtime_max_num_store_entries_system_tx: Some(1000 * 16),
3115 base_tx_cost_fixed: Some(110_000),
3116 package_publish_cost_fixed: Some(1_000),
3117 base_tx_cost_per_byte: Some(0),
3118 package_publish_cost_per_byte: Some(80),
3119 obj_access_cost_read_per_byte: Some(15),
3120 obj_access_cost_mutate_per_byte: Some(40),
3121 obj_access_cost_delete_per_byte: Some(40),
3122 obj_access_cost_verify_per_byte: Some(200),
3123 obj_data_cost_refundable: Some(100),
3124 obj_metadata_cost_non_refundable: Some(50),
3125 gas_model_version: Some(1),
3126 storage_rebate_rate: Some(9900),
3127 storage_fund_reinvest_rate: Some(500),
3128 reward_slashing_rate: Some(5000),
3129 storage_gas_price: Some(1),
3130 accumulator_object_storage_cost: None,
3131 max_transactions_per_checkpoint: Some(10_000),
3132 max_checkpoint_size_bytes: Some(30 * 1024 * 1024),
3133
3134 buffer_stake_for_protocol_upgrade_bps: Some(0),
3137
3138 address_from_bytes_cost_base: Some(52),
3142 address_to_u256_cost_base: Some(52),
3144 address_from_u256_cost_base: Some(52),
3146
3147 config_read_setting_impl_cost_base: None,
3150 config_read_setting_impl_cost_per_byte: None,
3151
3152 dynamic_field_hash_type_and_key_cost_base: Some(100),
3155 dynamic_field_hash_type_and_key_type_cost_per_byte: Some(2),
3156 dynamic_field_hash_type_and_key_value_cost_per_byte: Some(2),
3157 dynamic_field_hash_type_and_key_type_tag_cost_per_byte: Some(2),
3158 dynamic_field_add_child_object_cost_base: Some(100),
3160 dynamic_field_add_child_object_type_cost_per_byte: Some(10),
3161 dynamic_field_add_child_object_value_cost_per_byte: Some(10),
3162 dynamic_field_add_child_object_struct_tag_cost_per_byte: Some(10),
3163 dynamic_field_borrow_child_object_cost_base: Some(100),
3165 dynamic_field_borrow_child_object_child_ref_cost_per_byte: Some(10),
3166 dynamic_field_borrow_child_object_type_cost_per_byte: Some(10),
3167 dynamic_field_remove_child_object_cost_base: Some(100),
3169 dynamic_field_remove_child_object_child_cost_per_byte: Some(2),
3170 dynamic_field_remove_child_object_type_cost_per_byte: Some(2),
3171 dynamic_field_has_child_object_cost_base: Some(100),
3173 dynamic_field_has_child_object_with_ty_cost_base: Some(100),
3175 dynamic_field_has_child_object_with_ty_type_cost_per_byte: Some(2),
3176 dynamic_field_has_child_object_with_ty_type_tag_cost_per_byte: Some(2),
3177
3178 event_emit_cost_base: Some(52),
3181 event_emit_value_size_derivation_cost_per_byte: Some(2),
3182 event_emit_tag_size_derivation_cost_per_byte: Some(5),
3183 event_emit_output_cost_per_byte: Some(10),
3184 event_emit_auth_stream_cost: None,
3185
3186 object_borrow_uid_cost_base: Some(52),
3189 object_delete_impl_cost_base: Some(52),
3191 object_record_new_uid_cost_base: Some(52),
3193
3194 transfer_transfer_internal_cost_base: Some(52),
3197 transfer_party_transfer_internal_cost_base: None,
3199 transfer_freeze_object_cost_base: Some(52),
3201 transfer_share_object_cost_base: Some(52),
3203 transfer_receive_object_cost_base: None,
3204 transfer_receive_object_type_cost_per_byte: None,
3205 transfer_receive_object_cost_per_byte: None,
3206
3207 tx_context_derive_id_cost_base: Some(52),
3210 tx_context_fresh_id_cost_base: None,
3211 tx_context_sender_cost_base: None,
3212 tx_context_epoch_cost_base: None,
3213 tx_context_epoch_timestamp_ms_cost_base: None,
3214 tx_context_sponsor_cost_base: None,
3215 tx_context_rgp_cost_base: None,
3216 tx_context_gas_price_cost_base: None,
3217 tx_context_gas_budget_cost_base: None,
3218 tx_context_ids_created_cost_base: None,
3219 tx_context_replace_cost_base: None,
3220
3221 types_is_one_time_witness_cost_base: Some(52),
3224 types_is_one_time_witness_type_tag_cost_per_byte: Some(2),
3225 types_is_one_time_witness_type_cost_per_byte: Some(2),
3226
3227 validator_validate_metadata_cost_base: Some(52),
3230 validator_validate_metadata_data_cost_per_byte: Some(2),
3231
3232 crypto_invalid_arguments_cost: Some(100),
3234 bls12381_bls12381_min_sig_verify_cost_base: Some(52),
3236 bls12381_bls12381_min_sig_verify_msg_cost_per_byte: Some(2),
3237 bls12381_bls12381_min_sig_verify_msg_cost_per_block: Some(2),
3238
3239 bls12381_bls12381_min_pk_verify_cost_base: Some(52),
3241 bls12381_bls12381_min_pk_verify_msg_cost_per_byte: Some(2),
3242 bls12381_bls12381_min_pk_verify_msg_cost_per_block: Some(2),
3243
3244 ecdsa_k1_ecrecover_keccak256_cost_base: Some(52),
3246 ecdsa_k1_ecrecover_keccak256_msg_cost_per_byte: Some(2),
3247 ecdsa_k1_ecrecover_keccak256_msg_cost_per_block: Some(2),
3248 ecdsa_k1_ecrecover_sha256_cost_base: Some(52),
3249 ecdsa_k1_ecrecover_sha256_msg_cost_per_byte: Some(2),
3250 ecdsa_k1_ecrecover_sha256_msg_cost_per_block: Some(2),
3251
3252 ecdsa_k1_decompress_pubkey_cost_base: Some(52),
3254
3255 ecdsa_k1_secp256k1_verify_keccak256_cost_base: Some(52),
3257 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_byte: Some(2),
3258 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_block: Some(2),
3259 ecdsa_k1_secp256k1_verify_sha256_cost_base: Some(52),
3260 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_byte: Some(2),
3261 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_block: Some(2),
3262
3263 ecdsa_r1_ecrecover_keccak256_cost_base: Some(52),
3265 ecdsa_r1_ecrecover_keccak256_msg_cost_per_byte: Some(2),
3266 ecdsa_r1_ecrecover_keccak256_msg_cost_per_block: Some(2),
3267 ecdsa_r1_ecrecover_sha256_cost_base: Some(52),
3268 ecdsa_r1_ecrecover_sha256_msg_cost_per_byte: Some(2),
3269 ecdsa_r1_ecrecover_sha256_msg_cost_per_block: Some(2),
3270
3271 ecdsa_r1_secp256r1_verify_keccak256_cost_base: Some(52),
3273 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_byte: Some(2),
3274 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_block: Some(2),
3275 ecdsa_r1_secp256r1_verify_sha256_cost_base: Some(52),
3276 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_byte: Some(2),
3277 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_block: Some(2),
3278
3279 ecvrf_ecvrf_verify_cost_base: Some(52),
3281 ecvrf_ecvrf_verify_alpha_string_cost_per_byte: Some(2),
3282 ecvrf_ecvrf_verify_alpha_string_cost_per_block: Some(2),
3283
3284 ed25519_ed25519_verify_cost_base: Some(52),
3286 ed25519_ed25519_verify_msg_cost_per_byte: Some(2),
3287 ed25519_ed25519_verify_msg_cost_per_block: Some(2),
3288
3289 groth16_prepare_verifying_key_bls12381_cost_base: Some(52),
3291 groth16_prepare_verifying_key_bn254_cost_base: Some(52),
3292
3293 groth16_verify_groth16_proof_internal_bls12381_cost_base: Some(52),
3295 groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input: Some(2),
3296 groth16_verify_groth16_proof_internal_bn254_cost_base: Some(52),
3297 groth16_verify_groth16_proof_internal_bn254_cost_per_public_input: Some(2),
3298 groth16_verify_groth16_proof_internal_public_input_cost_per_byte: Some(2),
3299
3300 hash_blake2b256_cost_base: Some(52),
3302 hash_blake2b256_data_cost_per_byte: Some(2),
3303 hash_blake2b256_data_cost_per_block: Some(2),
3304
3305 hash_keccak256_cost_base: Some(52),
3307 hash_keccak256_data_cost_per_byte: Some(2),
3308 hash_keccak256_data_cost_per_block: Some(2),
3309
3310 poseidon_bn254_cost_base: None,
3311 poseidon_bn254_cost_per_block: None,
3312
3313 hmac_hmac_sha3_256_cost_base: Some(52),
3315 hmac_hmac_sha3_256_input_cost_per_byte: Some(2),
3316 hmac_hmac_sha3_256_input_cost_per_block: Some(2),
3317
3318 group_ops_bls12381_decode_scalar_cost: None,
3320 group_ops_bls12381_decode_g1_cost: None,
3321 group_ops_bls12381_decode_g2_cost: None,
3322 group_ops_bls12381_decode_gt_cost: None,
3323 group_ops_bls12381_scalar_add_cost: None,
3324 group_ops_bls12381_g1_add_cost: None,
3325 group_ops_bls12381_g2_add_cost: None,
3326 group_ops_bls12381_gt_add_cost: None,
3327 group_ops_bls12381_scalar_sub_cost: None,
3328 group_ops_bls12381_g1_sub_cost: None,
3329 group_ops_bls12381_g2_sub_cost: None,
3330 group_ops_bls12381_gt_sub_cost: None,
3331 group_ops_bls12381_scalar_mul_cost: None,
3332 group_ops_bls12381_g1_mul_cost: None,
3333 group_ops_bls12381_g2_mul_cost: None,
3334 group_ops_bls12381_gt_mul_cost: None,
3335 group_ops_bls12381_scalar_div_cost: None,
3336 group_ops_bls12381_g1_div_cost: None,
3337 group_ops_bls12381_g2_div_cost: None,
3338 group_ops_bls12381_gt_div_cost: None,
3339 group_ops_bls12381_g1_hash_to_base_cost: None,
3340 group_ops_bls12381_g2_hash_to_base_cost: None,
3341 group_ops_bls12381_g1_hash_to_cost_per_byte: None,
3342 group_ops_bls12381_g2_hash_to_cost_per_byte: None,
3343 group_ops_bls12381_g1_msm_base_cost: None,
3344 group_ops_bls12381_g2_msm_base_cost: None,
3345 group_ops_bls12381_g1_msm_base_cost_per_input: None,
3346 group_ops_bls12381_g2_msm_base_cost_per_input: None,
3347 group_ops_bls12381_msm_max_len: None,
3348 group_ops_bls12381_pairing_cost: None,
3349 group_ops_bls12381_g1_to_uncompressed_g1_cost: None,
3350 group_ops_bls12381_uncompressed_g1_to_g1_cost: None,
3351 group_ops_bls12381_uncompressed_g1_sum_base_cost: None,
3352 group_ops_bls12381_uncompressed_g1_sum_cost_per_term: None,
3353 group_ops_bls12381_uncompressed_g1_sum_max_terms: None,
3354
3355 group_ops_ristretto_decode_scalar_cost: None,
3356 group_ops_ristretto_decode_point_cost: None,
3357 group_ops_ristretto_scalar_add_cost: None,
3358 group_ops_ristretto_point_add_cost: None,
3359 group_ops_ristretto_scalar_sub_cost: None,
3360 group_ops_ristretto_point_sub_cost: None,
3361 group_ops_ristretto_scalar_mul_cost: None,
3362 group_ops_ristretto_point_mul_cost: None,
3363 group_ops_ristretto_scalar_div_cost: None,
3364 group_ops_ristretto_point_div_cost: None,
3365
3366 verify_bulletproofs_ristretto255_base_cost: None,
3367 verify_bulletproofs_ristretto255_cost_per_bit_and_commitment: None,
3368
3369 check_zklogin_id_cost_base: None,
3371 check_zklogin_issuer_cost_base: None,
3373
3374 vdf_verify_vdf_cost: None,
3375 vdf_hash_to_input_cost: None,
3376
3377 nitro_attestation_parse_base_cost: None,
3379 nitro_attestation_parse_cost_per_byte: None,
3380 nitro_attestation_verify_base_cost: None,
3381 nitro_attestation_verify_cost_per_cert: None,
3382
3383 bcs_per_byte_serialized_cost: None,
3384 bcs_legacy_min_output_size_cost: None,
3385 bcs_failure_cost: None,
3386 hash_sha2_256_base_cost: None,
3387 hash_sha2_256_per_byte_cost: None,
3388 hash_sha2_256_legacy_min_input_len_cost: None,
3389 hash_sha3_256_base_cost: None,
3390 hash_sha3_256_per_byte_cost: None,
3391 hash_sha3_256_legacy_min_input_len_cost: None,
3392 type_name_get_base_cost: None,
3393 type_name_get_per_byte_cost: None,
3394 type_name_id_base_cost: None,
3395 string_check_utf8_base_cost: None,
3396 string_check_utf8_per_byte_cost: None,
3397 string_is_char_boundary_base_cost: None,
3398 string_sub_string_base_cost: None,
3399 string_sub_string_per_byte_cost: None,
3400 string_index_of_base_cost: None,
3401 string_index_of_per_byte_pattern_cost: None,
3402 string_index_of_per_byte_searched_cost: None,
3403 vector_empty_base_cost: None,
3404 vector_length_base_cost: None,
3405 vector_push_back_base_cost: None,
3406 vector_push_back_legacy_per_abstract_memory_unit_cost: None,
3407 vector_borrow_base_cost: None,
3408 vector_pop_back_base_cost: None,
3409 vector_destroy_empty_base_cost: None,
3410 vector_swap_base_cost: None,
3411 debug_print_base_cost: None,
3412 debug_print_stack_trace_base_cost: None,
3413
3414 max_size_written_objects: None,
3415 max_size_written_objects_system_tx: None,
3416
3417 max_move_identifier_len: None,
3424 max_move_value_depth: None,
3425 max_move_enum_variants: None,
3426
3427 gas_rounding_step: None,
3428
3429 execution_version: None,
3430
3431 max_event_emit_size_total: None,
3432
3433 consensus_bad_nodes_stake_threshold: None,
3434
3435 max_jwk_votes_per_validator_per_epoch: None,
3436
3437 max_age_of_jwk_in_epochs: None,
3438
3439 random_beacon_reduction_allowed_delta: None,
3440
3441 random_beacon_reduction_lower_bound: None,
3442
3443 random_beacon_dkg_timeout_round: None,
3444
3445 random_beacon_min_round_interval_ms: None,
3446
3447 random_beacon_dkg_version: None,
3448
3449 consensus_max_transaction_size_bytes: None,
3450
3451 consensus_max_transactions_in_block_bytes: None,
3452
3453 consensus_max_num_transactions_in_block: None,
3454
3455 consensus_voting_rounds: None,
3456
3457 max_accumulated_txn_cost_per_object_in_narwhal_commit: None,
3458
3459 max_deferral_rounds_for_congestion_control: None,
3460
3461 max_txn_cost_overage_per_object_in_commit: None,
3462
3463 allowed_txn_cost_overage_burst_per_object_in_commit: None,
3464
3465 min_checkpoint_interval_ms: None,
3466
3467 checkpoint_summary_version_specific_data: None,
3468
3469 max_soft_bundle_size: None,
3470
3471 bridge_should_try_to_finalize_committee: None,
3472
3473 max_accumulated_txn_cost_per_object_in_mysticeti_commit: None,
3474
3475 max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit: None,
3476
3477 consensus_gc_depth: None,
3478
3479 gas_budget_based_txn_cost_cap_factor: None,
3480
3481 gas_budget_based_txn_cost_absolute_cap_commit_count: None,
3482
3483 sip_45_consensus_amplification_threshold: None,
3484
3485 use_object_per_epoch_marker_table_v2: None,
3486
3487 consensus_commit_rate_estimation_window_size: None,
3488
3489 aliased_addresses: vec![],
3490
3491 translation_per_command_base_charge: None,
3492 translation_per_input_base_charge: None,
3493 translation_pure_input_per_byte_charge: None,
3494 translation_per_type_node_charge: None,
3495 translation_per_reference_node_charge: None,
3496 translation_per_linkage_entry_charge: None,
3497
3498 max_updates_per_settlement_txn: None,
3499
3500 gasless_max_computation_units: None,
3501 gasless_allowed_token_types: None,
3502 gasless_max_unused_inputs: None,
3503 gasless_max_pure_input_bytes: None,
3504 gasless_max_tps: None,
3505 include_special_package_amendments: None,
3506 gasless_max_tx_size_bytes: None,
3507 };
3510 for cur in 2..=version.0 {
3511 match cur {
3512 1 => unreachable!(),
3513 2 => {
3514 cfg.feature_flags.advance_epoch_start_time_in_safe_mode = true;
3515 }
3516 3 => {
3517 cfg.gas_model_version = Some(2);
3519 cfg.max_tx_gas = Some(50_000_000_000);
3521 cfg.base_tx_cost_fixed = Some(2_000);
3523 cfg.storage_gas_price = Some(76);
3525 cfg.feature_flags.loaded_child_objects_fixed = true;
3526 cfg.max_size_written_objects = Some(5 * 1000 * 1000);
3529 cfg.max_size_written_objects_system_tx = Some(50 * 1000 * 1000);
3532 cfg.feature_flags.package_upgrades = true;
3533 }
3534 4 => {
3539 cfg.reward_slashing_rate = Some(10000);
3541 cfg.gas_model_version = Some(3);
3543 }
3544 5 => {
3545 cfg.feature_flags.missing_type_is_compatibility_error = true;
3546 cfg.gas_model_version = Some(4);
3547 cfg.feature_flags.scoring_decision_with_validity_cutoff = true;
3548 }
3552 6 => {
3553 cfg.gas_model_version = Some(5);
3554 cfg.buffer_stake_for_protocol_upgrade_bps = Some(5000);
3555 cfg.feature_flags.consensus_order_end_of_epoch_last = true;
3556 }
3557 7 => {
3558 cfg.feature_flags.disallow_adding_abilities_on_upgrade = true;
3559 cfg.feature_flags
3560 .disable_invariant_violation_check_in_swap_loc = true;
3561 cfg.feature_flags.ban_entry_init = true;
3562 cfg.feature_flags.package_digest_hash_module = true;
3563 }
3564 8 => {
3565 cfg.feature_flags
3566 .disallow_change_struct_type_params_on_upgrade = true;
3567 }
3568 9 => {
3569 cfg.max_move_identifier_len = Some(128);
3571 cfg.feature_flags.no_extraneous_module_bytes = true;
3572 cfg.feature_flags
3573 .advance_to_highest_supported_protocol_version = true;
3574 }
3575 10 => {
3576 cfg.max_verifier_meter_ticks_per_function = Some(16_000_000);
3577 cfg.max_meter_ticks_per_module = Some(16_000_000);
3578 }
3579 11 => {
3580 cfg.max_move_value_depth = Some(128);
3581 }
3582 12 => {
3583 cfg.feature_flags.narwhal_versioned_metadata = true;
3584 if chain != Chain::Mainnet {
3585 cfg.feature_flags.commit_root_state_digest = true;
3586 }
3587
3588 if chain != Chain::Mainnet && chain != Chain::Testnet {
3589 cfg.feature_flags.zklogin_auth = true;
3590 }
3591 }
3592 13 => {}
3593 14 => {
3594 cfg.gas_rounding_step = Some(1_000);
3595 cfg.gas_model_version = Some(6);
3596 }
3597 15 => {
3598 cfg.feature_flags.consensus_transaction_ordering =
3599 ConsensusTransactionOrdering::ByGasPrice;
3600 }
3601 16 => {
3602 cfg.feature_flags.simplified_unwrap_then_delete = true;
3603 }
3604 17 => {
3605 cfg.feature_flags.upgraded_multisig_supported = true;
3606 }
3607 18 => {
3608 cfg.execution_version = Some(1);
3609 cfg.feature_flags.txn_base_cost_as_multiplier = true;
3618 cfg.base_tx_cost_fixed = Some(1_000);
3620 }
3621 19 => {
3622 cfg.max_num_event_emit = Some(1024);
3623 cfg.max_event_emit_size_total = Some(
3626 256 * 250 * 1024, );
3628 }
3629 20 => {
3630 cfg.feature_flags.commit_root_state_digest = true;
3631
3632 if chain != Chain::Mainnet {
3633 cfg.feature_flags.narwhal_new_leader_election_schedule = true;
3634 cfg.consensus_bad_nodes_stake_threshold = Some(20);
3635 }
3636 }
3637
3638 21 => {
3639 if chain != Chain::Mainnet {
3640 cfg.feature_flags.zklogin_supported_providers = BTreeSet::from([
3641 "Google".to_string(),
3642 "Facebook".to_string(),
3643 "Twitch".to_string(),
3644 ]);
3645 }
3646 }
3647 22 => {
3648 cfg.feature_flags.loaded_child_object_format = true;
3649 }
3650 23 => {
3651 cfg.feature_flags.loaded_child_object_format_type = true;
3652 cfg.feature_flags.narwhal_new_leader_election_schedule = true;
3653 cfg.consensus_bad_nodes_stake_threshold = Some(20);
3659 }
3660 24 => {
3661 cfg.feature_flags.simple_conservation_checks = true;
3662 cfg.max_publish_or_upgrade_per_ptb = Some(5);
3663
3664 cfg.feature_flags.end_of_epoch_transaction_supported = true;
3665
3666 if chain != Chain::Mainnet {
3667 cfg.feature_flags.enable_jwk_consensus_updates = true;
3668 cfg.max_jwk_votes_per_validator_per_epoch = Some(240);
3670 cfg.max_age_of_jwk_in_epochs = Some(1);
3671 }
3672 }
3673 25 => {
3674 cfg.feature_flags.zklogin_supported_providers = BTreeSet::from([
3676 "Google".to_string(),
3677 "Facebook".to_string(),
3678 "Twitch".to_string(),
3679 ]);
3680 cfg.feature_flags.zklogin_auth = true;
3681
3682 cfg.feature_flags.enable_jwk_consensus_updates = true;
3684 cfg.max_jwk_votes_per_validator_per_epoch = Some(240);
3685 cfg.max_age_of_jwk_in_epochs = Some(1);
3686 }
3687 26 => {
3688 cfg.gas_model_version = Some(7);
3689 if chain != Chain::Mainnet && chain != Chain::Testnet {
3691 cfg.transfer_receive_object_cost_base = Some(52);
3692 cfg.feature_flags.receive_objects = true;
3693 }
3694 }
3695 27 => {
3696 cfg.gas_model_version = Some(8);
3697 }
3698 28 => {
3699 cfg.check_zklogin_id_cost_base = Some(200);
3701 cfg.check_zklogin_issuer_cost_base = Some(200);
3703
3704 if chain != Chain::Mainnet && chain != Chain::Testnet {
3706 cfg.feature_flags.enable_effects_v2 = true;
3707 }
3708 }
3709 29 => {
3710 cfg.feature_flags.verify_legacy_zklogin_address = true;
3711 }
3712 30 => {
3713 if chain != Chain::Mainnet {
3715 cfg.feature_flags.narwhal_certificate_v2 = true;
3716 }
3717
3718 cfg.random_beacon_reduction_allowed_delta = Some(800);
3719 if chain != Chain::Mainnet {
3721 cfg.feature_flags.enable_effects_v2 = true;
3722 }
3723
3724 cfg.feature_flags.zklogin_supported_providers = BTreeSet::default();
3728
3729 cfg.feature_flags.recompute_has_public_transfer_in_execution = true;
3730 }
3731 31 => {
3732 cfg.execution_version = Some(2);
3733 if chain != Chain::Mainnet && chain != Chain::Testnet {
3735 cfg.feature_flags.shared_object_deletion = true;
3736 }
3737 }
3738 32 => {
3739 if chain != Chain::Mainnet {
3741 cfg.feature_flags.accept_zklogin_in_multisig = true;
3742 }
3743 if chain != Chain::Mainnet {
3745 cfg.transfer_receive_object_cost_base = Some(52);
3746 cfg.feature_flags.receive_objects = true;
3747 }
3748 if chain != Chain::Mainnet && chain != Chain::Testnet {
3750 cfg.feature_flags.random_beacon = true;
3751 cfg.random_beacon_reduction_lower_bound = Some(1600);
3752 cfg.random_beacon_dkg_timeout_round = Some(3000);
3753 cfg.random_beacon_min_round_interval_ms = Some(150);
3754 }
3755 if chain != Chain::Testnet && chain != Chain::Mainnet {
3757 cfg.feature_flags.include_consensus_digest_in_prologue = true;
3758 }
3759
3760 cfg.feature_flags.narwhal_certificate_v2 = true;
3762 }
3763 33 => {
3764 cfg.feature_flags.hardened_otw_check = true;
3765 cfg.feature_flags.allow_receiving_object_id = true;
3766
3767 cfg.transfer_receive_object_cost_base = Some(52);
3769 cfg.feature_flags.receive_objects = true;
3770
3771 if chain != Chain::Mainnet {
3773 cfg.feature_flags.shared_object_deletion = true;
3774 }
3775
3776 cfg.feature_flags.enable_effects_v2 = true;
3777 }
3778 34 => {}
3779 35 => {
3780 if chain != Chain::Mainnet && chain != Chain::Testnet {
3782 cfg.feature_flags.enable_poseidon = true;
3783 cfg.poseidon_bn254_cost_base = Some(260);
3784 cfg.poseidon_bn254_cost_per_block = Some(10);
3785 }
3786
3787 cfg.feature_flags.enable_coin_deny_list = true;
3788 }
3789 36 => {
3790 if chain != Chain::Mainnet && chain != Chain::Testnet {
3792 cfg.feature_flags.enable_group_ops_native_functions = true;
3793 cfg.feature_flags.enable_group_ops_native_function_msm = true;
3794 cfg.group_ops_bls12381_decode_scalar_cost = Some(52);
3796 cfg.group_ops_bls12381_decode_g1_cost = Some(52);
3797 cfg.group_ops_bls12381_decode_g2_cost = Some(52);
3798 cfg.group_ops_bls12381_decode_gt_cost = Some(52);
3799 cfg.group_ops_bls12381_scalar_add_cost = Some(52);
3800 cfg.group_ops_bls12381_g1_add_cost = Some(52);
3801 cfg.group_ops_bls12381_g2_add_cost = Some(52);
3802 cfg.group_ops_bls12381_gt_add_cost = Some(52);
3803 cfg.group_ops_bls12381_scalar_sub_cost = Some(52);
3804 cfg.group_ops_bls12381_g1_sub_cost = Some(52);
3805 cfg.group_ops_bls12381_g2_sub_cost = Some(52);
3806 cfg.group_ops_bls12381_gt_sub_cost = Some(52);
3807 cfg.group_ops_bls12381_scalar_mul_cost = Some(52);
3808 cfg.group_ops_bls12381_g1_mul_cost = Some(52);
3809 cfg.group_ops_bls12381_g2_mul_cost = Some(52);
3810 cfg.group_ops_bls12381_gt_mul_cost = Some(52);
3811 cfg.group_ops_bls12381_scalar_div_cost = Some(52);
3812 cfg.group_ops_bls12381_g1_div_cost = Some(52);
3813 cfg.group_ops_bls12381_g2_div_cost = Some(52);
3814 cfg.group_ops_bls12381_gt_div_cost = Some(52);
3815 cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(52);
3816 cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(52);
3817 cfg.group_ops_bls12381_g1_hash_to_cost_per_byte = Some(2);
3818 cfg.group_ops_bls12381_g2_hash_to_cost_per_byte = Some(2);
3819 cfg.group_ops_bls12381_g1_msm_base_cost = Some(52);
3820 cfg.group_ops_bls12381_g2_msm_base_cost = Some(52);
3821 cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(52);
3822 cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(52);
3823 cfg.group_ops_bls12381_msm_max_len = Some(32);
3824 cfg.group_ops_bls12381_pairing_cost = Some(52);
3825 }
3826 cfg.feature_flags.shared_object_deletion = true;
3828
3829 cfg.consensus_max_transaction_size_bytes = Some(256 * 1024); cfg.consensus_max_transactions_in_block_bytes = Some(6 * 1_024 * 1024);
3831 }
3833 37 => {
3834 cfg.feature_flags.reject_mutable_random_on_entry_functions = true;
3835
3836 if chain != Chain::Mainnet {
3838 cfg.feature_flags.include_consensus_digest_in_prologue = true;
3839 }
3840 }
3841 38 => {
3842 cfg.binary_module_handles = Some(100);
3843 cfg.binary_struct_handles = Some(300);
3844 cfg.binary_function_handles = Some(1500);
3845 cfg.binary_function_instantiations = Some(750);
3846 cfg.binary_signatures = Some(1000);
3847 cfg.binary_constant_pool = Some(4000);
3851 cfg.binary_identifiers = Some(10000);
3852 cfg.binary_address_identifiers = Some(100);
3853 cfg.binary_struct_defs = Some(200);
3854 cfg.binary_struct_def_instantiations = Some(100);
3855 cfg.binary_function_defs = Some(1000);
3856 cfg.binary_field_handles = Some(500);
3857 cfg.binary_field_instantiations = Some(250);
3858 cfg.binary_friend_decls = Some(100);
3859 cfg.max_package_dependencies = Some(32);
3861 cfg.max_modules_in_publish = Some(64);
3862 cfg.execution_version = Some(3);
3864 }
3865 39 => {
3866 }
3868 40 => {}
3869 41 => {
3870 cfg.feature_flags.enable_group_ops_native_functions = true;
3872 cfg.group_ops_bls12381_decode_scalar_cost = Some(52);
3874 cfg.group_ops_bls12381_decode_g1_cost = Some(52);
3875 cfg.group_ops_bls12381_decode_g2_cost = Some(52);
3876 cfg.group_ops_bls12381_decode_gt_cost = Some(52);
3877 cfg.group_ops_bls12381_scalar_add_cost = Some(52);
3878 cfg.group_ops_bls12381_g1_add_cost = Some(52);
3879 cfg.group_ops_bls12381_g2_add_cost = Some(52);
3880 cfg.group_ops_bls12381_gt_add_cost = Some(52);
3881 cfg.group_ops_bls12381_scalar_sub_cost = Some(52);
3882 cfg.group_ops_bls12381_g1_sub_cost = Some(52);
3883 cfg.group_ops_bls12381_g2_sub_cost = Some(52);
3884 cfg.group_ops_bls12381_gt_sub_cost = Some(52);
3885 cfg.group_ops_bls12381_scalar_mul_cost = Some(52);
3886 cfg.group_ops_bls12381_g1_mul_cost = Some(52);
3887 cfg.group_ops_bls12381_g2_mul_cost = Some(52);
3888 cfg.group_ops_bls12381_gt_mul_cost = Some(52);
3889 cfg.group_ops_bls12381_scalar_div_cost = Some(52);
3890 cfg.group_ops_bls12381_g1_div_cost = Some(52);
3891 cfg.group_ops_bls12381_g2_div_cost = Some(52);
3892 cfg.group_ops_bls12381_gt_div_cost = Some(52);
3893 cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(52);
3894 cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(52);
3895 cfg.group_ops_bls12381_g1_hash_to_cost_per_byte = Some(2);
3896 cfg.group_ops_bls12381_g2_hash_to_cost_per_byte = Some(2);
3897 cfg.group_ops_bls12381_g1_msm_base_cost = Some(52);
3898 cfg.group_ops_bls12381_g2_msm_base_cost = Some(52);
3899 cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(52);
3900 cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(52);
3901 cfg.group_ops_bls12381_msm_max_len = Some(32);
3902 cfg.group_ops_bls12381_pairing_cost = Some(52);
3903 }
3904 42 => {}
3905 43 => {
3906 cfg.feature_flags.zklogin_max_epoch_upper_bound_delta = Some(30);
3907 cfg.max_meter_ticks_per_package = Some(16_000_000);
3908 }
3909 44 => {
3910 cfg.feature_flags.include_consensus_digest_in_prologue = true;
3912 if chain != Chain::Mainnet {
3914 cfg.feature_flags.consensus_choice = ConsensusChoice::SwapEachEpoch;
3915 }
3916 }
3917 45 => {
3918 if chain != Chain::Testnet && chain != Chain::Mainnet {
3920 cfg.feature_flags.consensus_network = ConsensusNetwork::Tonic;
3921 }
3922
3923 if chain != Chain::Mainnet {
3924 cfg.feature_flags.mysticeti_leader_scoring_and_schedule = true;
3926 }
3927 cfg.min_move_binary_format_version = Some(6);
3928 cfg.feature_flags.accept_zklogin_in_multisig = true;
3929
3930 if chain != Chain::Mainnet && chain != Chain::Testnet {
3934 cfg.feature_flags.bridge = true;
3935 }
3936 }
3937 46 => {
3938 if chain != Chain::Mainnet {
3940 cfg.feature_flags.bridge = true;
3941 }
3942
3943 cfg.feature_flags.reshare_at_same_initial_version = true;
3945 }
3946 47 => {}
3947 48 => {
3948 cfg.feature_flags.consensus_network = ConsensusNetwork::Tonic;
3950
3951 cfg.feature_flags.resolve_abort_locations_to_package_id = true;
3953
3954 if chain != Chain::Mainnet {
3956 cfg.feature_flags.random_beacon = true;
3957 cfg.random_beacon_reduction_lower_bound = Some(1600);
3958 cfg.random_beacon_dkg_timeout_round = Some(3000);
3959 cfg.random_beacon_min_round_interval_ms = Some(200);
3960 }
3961
3962 cfg.feature_flags.mysticeti_use_committed_subdag_digest = true;
3964 }
3965 49 => {
3966 if chain != Chain::Testnet && chain != Chain::Mainnet {
3967 cfg.move_binary_format_version = Some(7);
3968 }
3969
3970 if chain != Chain::Mainnet && chain != Chain::Testnet {
3972 cfg.feature_flags.enable_vdf = true;
3973 cfg.vdf_verify_vdf_cost = Some(1500);
3976 cfg.vdf_hash_to_input_cost = Some(100);
3977 }
3978
3979 if chain != Chain::Testnet && chain != Chain::Mainnet {
3981 cfg.feature_flags
3982 .record_consensus_determined_version_assignments_in_prologue = true;
3983 }
3984
3985 if chain != Chain::Mainnet {
3987 cfg.feature_flags.consensus_choice = ConsensusChoice::Mysticeti;
3988 }
3989
3990 cfg.feature_flags.fresh_vm_on_framework_upgrade = true;
3992 }
3993 50 => {
3994 if chain != Chain::Mainnet {
3996 cfg.checkpoint_summary_version_specific_data = Some(1);
3997 cfg.min_checkpoint_interval_ms = Some(200);
3998 }
3999
4000 if chain != Chain::Testnet && chain != Chain::Mainnet {
4002 cfg.feature_flags
4003 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = true;
4004 }
4005
4006 cfg.feature_flags.mysticeti_num_leaders_per_round = Some(1);
4007
4008 cfg.max_deferral_rounds_for_congestion_control = Some(10);
4010 }
4011 51 => {
4012 cfg.random_beacon_dkg_version = Some(1);
4013
4014 if chain != Chain::Testnet && chain != Chain::Mainnet {
4015 cfg.feature_flags.enable_coin_deny_list_v2 = true;
4016 }
4017 }
4018 52 => {
4019 if chain != Chain::Mainnet {
4020 cfg.feature_flags.soft_bundle = true;
4021 cfg.max_soft_bundle_size = Some(5);
4022 }
4023
4024 cfg.config_read_setting_impl_cost_base = Some(100);
4025 cfg.config_read_setting_impl_cost_per_byte = Some(40);
4026
4027 if chain != Chain::Testnet && chain != Chain::Mainnet {
4029 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(100);
4030 cfg.feature_flags.per_object_congestion_control_mode =
4031 PerObjectCongestionControlMode::TotalTxCount;
4032 }
4033
4034 cfg.feature_flags.consensus_choice = ConsensusChoice::Mysticeti;
4036
4037 cfg.feature_flags.mysticeti_leader_scoring_and_schedule = true;
4039
4040 cfg.checkpoint_summary_version_specific_data = Some(1);
4042 cfg.min_checkpoint_interval_ms = Some(200);
4043
4044 if chain != Chain::Mainnet {
4046 cfg.feature_flags
4047 .record_consensus_determined_version_assignments_in_prologue = true;
4048 cfg.feature_flags
4049 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = true;
4050 }
4051 if chain != Chain::Mainnet {
4053 cfg.move_binary_format_version = Some(7);
4054 }
4055
4056 if chain != Chain::Testnet && chain != Chain::Mainnet {
4057 cfg.feature_flags.passkey_auth = true;
4058 }
4059 cfg.feature_flags.enable_coin_deny_list_v2 = true;
4060 }
4061 53 => {
4062 cfg.bridge_should_try_to_finalize_committee = Some(chain != Chain::Mainnet);
4064
4065 cfg.feature_flags
4067 .record_consensus_determined_version_assignments_in_prologue = true;
4068 cfg.feature_flags
4069 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = true;
4070
4071 if chain == Chain::Unknown {
4072 cfg.feature_flags.authority_capabilities_v2 = true;
4073 }
4074
4075 if chain != Chain::Mainnet {
4077 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(100);
4078 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(10);
4079 cfg.feature_flags.per_object_congestion_control_mode =
4080 PerObjectCongestionControlMode::TotalTxCount;
4081 }
4082
4083 cfg.bcs_per_byte_serialized_cost = Some(2);
4085 cfg.bcs_legacy_min_output_size_cost = Some(1);
4086 cfg.bcs_failure_cost = Some(52);
4087 cfg.debug_print_base_cost = Some(52);
4088 cfg.debug_print_stack_trace_base_cost = Some(52);
4089 cfg.hash_sha2_256_base_cost = Some(52);
4090 cfg.hash_sha2_256_per_byte_cost = Some(2);
4091 cfg.hash_sha2_256_legacy_min_input_len_cost = Some(1);
4092 cfg.hash_sha3_256_base_cost = Some(52);
4093 cfg.hash_sha3_256_per_byte_cost = Some(2);
4094 cfg.hash_sha3_256_legacy_min_input_len_cost = Some(1);
4095 cfg.type_name_get_base_cost = Some(52);
4096 cfg.type_name_get_per_byte_cost = Some(2);
4097 cfg.string_check_utf8_base_cost = Some(52);
4098 cfg.string_check_utf8_per_byte_cost = Some(2);
4099 cfg.string_is_char_boundary_base_cost = Some(52);
4100 cfg.string_sub_string_base_cost = Some(52);
4101 cfg.string_sub_string_per_byte_cost = Some(2);
4102 cfg.string_index_of_base_cost = Some(52);
4103 cfg.string_index_of_per_byte_pattern_cost = Some(2);
4104 cfg.string_index_of_per_byte_searched_cost = Some(2);
4105 cfg.vector_empty_base_cost = Some(52);
4106 cfg.vector_length_base_cost = Some(52);
4107 cfg.vector_push_back_base_cost = Some(52);
4108 cfg.vector_push_back_legacy_per_abstract_memory_unit_cost = Some(2);
4109 cfg.vector_borrow_base_cost = Some(52);
4110 cfg.vector_pop_back_base_cost = Some(52);
4111 cfg.vector_destroy_empty_base_cost = Some(52);
4112 cfg.vector_swap_base_cost = Some(52);
4113 }
4114 54 => {
4115 cfg.feature_flags.random_beacon = true;
4117 cfg.random_beacon_reduction_lower_bound = Some(1000);
4118 cfg.random_beacon_dkg_timeout_round = Some(3000);
4119 cfg.random_beacon_min_round_interval_ms = Some(500);
4120
4121 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(100);
4123 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(10);
4124 cfg.feature_flags.per_object_congestion_control_mode =
4125 PerObjectCongestionControlMode::TotalTxCount;
4126
4127 cfg.feature_flags.soft_bundle = true;
4129 cfg.max_soft_bundle_size = Some(5);
4130 }
4131 55 => {
4132 cfg.move_binary_format_version = Some(7);
4134
4135 cfg.consensus_max_transactions_in_block_bytes = Some(512 * 1024);
4137 cfg.consensus_max_num_transactions_in_block = Some(512);
4140
4141 cfg.feature_flags.rethrow_serialization_type_layout_errors = true;
4142 }
4143 56 => {
4144 if chain == Chain::Mainnet {
4145 cfg.feature_flags.bridge = true;
4146 }
4147 }
4148 57 => {
4149 cfg.random_beacon_reduction_lower_bound = Some(800);
4151 }
4152 58 => {
4153 if chain == Chain::Mainnet {
4154 cfg.bridge_should_try_to_finalize_committee = Some(true);
4155 }
4156
4157 if chain != Chain::Mainnet && chain != Chain::Testnet {
4158 cfg.feature_flags
4160 .consensus_distributed_vote_scoring_strategy = true;
4161 }
4162 }
4163 59 => {
4164 cfg.feature_flags.consensus_round_prober = true;
4166 }
4167 60 => {
4168 cfg.max_type_to_layout_nodes = Some(512);
4169 cfg.feature_flags.validate_identifier_inputs = true;
4170 }
4171 61 => {
4172 if chain != Chain::Mainnet {
4173 cfg.feature_flags
4175 .consensus_distributed_vote_scoring_strategy = true;
4176 }
4177 cfg.random_beacon_reduction_lower_bound = Some(700);
4179
4180 if chain != Chain::Mainnet && chain != Chain::Testnet {
4181 cfg.feature_flags.mysticeti_fastpath = true;
4183 }
4184 }
4185 62 => {
4186 cfg.feature_flags.relocate_event_module = true;
4187 }
4188 63 => {
4189 cfg.feature_flags.per_object_congestion_control_mode =
4190 PerObjectCongestionControlMode::TotalGasBudgetWithCap;
4191 cfg.gas_budget_based_txn_cost_cap_factor = Some(400_000);
4192 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(18_500_000);
4193 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(240_000_000);
4194 }
4195 64 => {
4196 cfg.feature_flags.per_object_congestion_control_mode =
4197 PerObjectCongestionControlMode::TotalTxCount;
4198 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(40);
4199 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(3);
4200 }
4201 65 => {
4202 cfg.feature_flags
4204 .consensus_distributed_vote_scoring_strategy = true;
4205 }
4206 66 => {
4207 if chain == Chain::Mainnet {
4208 cfg.feature_flags
4210 .consensus_distributed_vote_scoring_strategy = false;
4211 }
4212 }
4213 67 => {
4214 cfg.feature_flags
4216 .consensus_distributed_vote_scoring_strategy = true;
4217 }
4218 68 => {
4219 cfg.group_ops_bls12381_g1_to_uncompressed_g1_cost = Some(26);
4220 cfg.group_ops_bls12381_uncompressed_g1_to_g1_cost = Some(52);
4221 cfg.group_ops_bls12381_uncompressed_g1_sum_base_cost = Some(26);
4222 cfg.group_ops_bls12381_uncompressed_g1_sum_cost_per_term = Some(13);
4223 cfg.group_ops_bls12381_uncompressed_g1_sum_max_terms = Some(2000);
4224
4225 if chain != Chain::Mainnet && chain != Chain::Testnet {
4226 cfg.feature_flags.uncompressed_g1_group_elements = true;
4227 }
4228
4229 cfg.feature_flags.per_object_congestion_control_mode =
4230 PerObjectCongestionControlMode::TotalGasBudgetWithCap;
4231 cfg.gas_budget_based_txn_cost_cap_factor = Some(400_000);
4232 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(18_500_000);
4233 cfg.max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit =
4234 Some(3_700_000); cfg.max_txn_cost_overage_per_object_in_commit = Some(u64::MAX);
4236 cfg.gas_budget_based_txn_cost_absolute_cap_commit_count = Some(50);
4237
4238 cfg.random_beacon_reduction_lower_bound = Some(500);
4240
4241 cfg.feature_flags.disallow_new_modules_in_deps_only_packages = true;
4242 }
4243 69 => {
4244 cfg.consensus_voting_rounds = Some(40);
4246
4247 if chain != Chain::Mainnet && chain != Chain::Testnet {
4248 cfg.feature_flags.consensus_smart_ancestor_selection = true;
4250 }
4251
4252 if chain != Chain::Mainnet {
4253 cfg.feature_flags.uncompressed_g1_group_elements = true;
4254 }
4255 }
4256 70 => {
4257 if chain != Chain::Mainnet {
4258 cfg.feature_flags.consensus_smart_ancestor_selection = true;
4260 cfg.feature_flags
4262 .consensus_round_prober_probe_accepted_rounds = true;
4263 }
4264
4265 cfg.poseidon_bn254_cost_per_block = Some(388);
4266
4267 cfg.gas_model_version = Some(9);
4268 cfg.feature_flags.native_charging_v2 = true;
4269 cfg.bls12381_bls12381_min_sig_verify_cost_base = Some(44064);
4270 cfg.bls12381_bls12381_min_pk_verify_cost_base = Some(49282);
4271 cfg.ecdsa_k1_secp256k1_verify_keccak256_cost_base = Some(1470);
4272 cfg.ecdsa_k1_secp256k1_verify_sha256_cost_base = Some(1470);
4273 cfg.ecdsa_r1_secp256r1_verify_sha256_cost_base = Some(4225);
4274 cfg.ecdsa_r1_secp256r1_verify_keccak256_cost_base = Some(4225);
4275 cfg.ecvrf_ecvrf_verify_cost_base = Some(4848);
4276 cfg.ed25519_ed25519_verify_cost_base = Some(1802);
4277
4278 cfg.ecdsa_r1_ecrecover_keccak256_cost_base = Some(1173);
4280 cfg.ecdsa_r1_ecrecover_sha256_cost_base = Some(1173);
4281 cfg.ecdsa_k1_ecrecover_keccak256_cost_base = Some(500);
4282 cfg.ecdsa_k1_ecrecover_sha256_cost_base = Some(500);
4283
4284 cfg.groth16_prepare_verifying_key_bls12381_cost_base = Some(53838);
4285 cfg.groth16_prepare_verifying_key_bn254_cost_base = Some(82010);
4286 cfg.groth16_verify_groth16_proof_internal_bls12381_cost_base = Some(72090);
4287 cfg.groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input =
4288 Some(8213);
4289 cfg.groth16_verify_groth16_proof_internal_bn254_cost_base = Some(115502);
4290 cfg.groth16_verify_groth16_proof_internal_bn254_cost_per_public_input =
4291 Some(9484);
4292
4293 cfg.hash_keccak256_cost_base = Some(10);
4294 cfg.hash_blake2b256_cost_base = Some(10);
4295
4296 cfg.group_ops_bls12381_decode_scalar_cost = Some(7);
4298 cfg.group_ops_bls12381_decode_g1_cost = Some(2848);
4299 cfg.group_ops_bls12381_decode_g2_cost = Some(3770);
4300 cfg.group_ops_bls12381_decode_gt_cost = Some(3068);
4301
4302 cfg.group_ops_bls12381_scalar_add_cost = Some(10);
4303 cfg.group_ops_bls12381_g1_add_cost = Some(1556);
4304 cfg.group_ops_bls12381_g2_add_cost = Some(3048);
4305 cfg.group_ops_bls12381_gt_add_cost = Some(188);
4306
4307 cfg.group_ops_bls12381_scalar_sub_cost = Some(10);
4308 cfg.group_ops_bls12381_g1_sub_cost = Some(1550);
4309 cfg.group_ops_bls12381_g2_sub_cost = Some(3019);
4310 cfg.group_ops_bls12381_gt_sub_cost = Some(497);
4311
4312 cfg.group_ops_bls12381_scalar_mul_cost = Some(11);
4313 cfg.group_ops_bls12381_g1_mul_cost = Some(4842);
4314 cfg.group_ops_bls12381_g2_mul_cost = Some(9108);
4315 cfg.group_ops_bls12381_gt_mul_cost = Some(27490);
4316
4317 cfg.group_ops_bls12381_scalar_div_cost = Some(91);
4318 cfg.group_ops_bls12381_g1_div_cost = Some(5091);
4319 cfg.group_ops_bls12381_g2_div_cost = Some(9206);
4320 cfg.group_ops_bls12381_gt_div_cost = Some(27804);
4321
4322 cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(2962);
4323 cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(8688);
4324
4325 cfg.group_ops_bls12381_g1_msm_base_cost = Some(62648);
4326 cfg.group_ops_bls12381_g2_msm_base_cost = Some(131192);
4327 cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(1333);
4328 cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(3216);
4329
4330 cfg.group_ops_bls12381_uncompressed_g1_to_g1_cost = Some(677);
4331 cfg.group_ops_bls12381_g1_to_uncompressed_g1_cost = Some(2099);
4332 cfg.group_ops_bls12381_uncompressed_g1_sum_base_cost = Some(77);
4333 cfg.group_ops_bls12381_uncompressed_g1_sum_cost_per_term = Some(26);
4334
4335 cfg.group_ops_bls12381_pairing_cost = Some(26897);
4336 cfg.group_ops_bls12381_uncompressed_g1_sum_max_terms = Some(1200);
4337
4338 cfg.validator_validate_metadata_cost_base = Some(20000);
4339 }
4340 71 => {
4341 cfg.sip_45_consensus_amplification_threshold = Some(5);
4342
4343 cfg.allowed_txn_cost_overage_burst_per_object_in_commit = Some(185_000_000);
4345 }
4346 72 => {
4347 cfg.feature_flags.convert_type_argument_error = true;
4348
4349 cfg.max_tx_gas = Some(50_000_000_000_000);
4352 cfg.max_gas_price = Some(50_000_000_000);
4354
4355 cfg.feature_flags.variant_nodes = true;
4356 }
4357 73 => {
4358 cfg.use_object_per_epoch_marker_table_v2 = Some(true);
4360
4361 if chain != Chain::Mainnet && chain != Chain::Testnet {
4362 cfg.consensus_gc_depth = Some(60);
4365 }
4366
4367 if chain != Chain::Mainnet {
4368 cfg.feature_flags.consensus_zstd_compression = true;
4370 }
4371
4372 cfg.feature_flags.consensus_smart_ancestor_selection = true;
4374 cfg.feature_flags
4376 .consensus_round_prober_probe_accepted_rounds = true;
4377
4378 cfg.feature_flags.per_object_congestion_control_mode =
4380 PerObjectCongestionControlMode::TotalGasBudgetWithCap;
4381 cfg.gas_budget_based_txn_cost_cap_factor = Some(400_000);
4382 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(37_000_000);
4383 cfg.max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit =
4384 Some(7_400_000); cfg.max_txn_cost_overage_per_object_in_commit = Some(u64::MAX);
4386 cfg.gas_budget_based_txn_cost_absolute_cap_commit_count = Some(50);
4387 cfg.allowed_txn_cost_overage_burst_per_object_in_commit = Some(370_000_000);
4388 }
4389 74 => {
4390 if chain != Chain::Mainnet && chain != Chain::Testnet {
4392 cfg.feature_flags.enable_nitro_attestation = true;
4393 }
4394 cfg.nitro_attestation_parse_base_cost = Some(53 * 50);
4395 cfg.nitro_attestation_parse_cost_per_byte = Some(50);
4396 cfg.nitro_attestation_verify_base_cost = Some(49632 * 50);
4397 cfg.nitro_attestation_verify_cost_per_cert = Some(52369 * 50);
4398
4399 cfg.feature_flags.consensus_zstd_compression = true;
4401
4402 if chain != Chain::Mainnet && chain != Chain::Testnet {
4403 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
4404 }
4405 }
4406 75 => {
4407 if chain != Chain::Mainnet {
4408 cfg.feature_flags.passkey_auth = true;
4409 }
4410 }
4411 76 => {
4412 if chain != Chain::Mainnet && chain != Chain::Testnet {
4413 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
4414 cfg.consensus_commit_rate_estimation_window_size = Some(10);
4415 }
4416 cfg.feature_flags.minimize_child_object_mutations = true;
4417
4418 if chain != Chain::Mainnet {
4419 cfg.feature_flags.accept_passkey_in_multisig = true;
4420 }
4421 }
4422 77 => {
4423 cfg.feature_flags.uncompressed_g1_group_elements = true;
4424
4425 if chain != Chain::Mainnet {
4426 cfg.consensus_gc_depth = Some(60);
4427 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
4428 }
4429 }
4430 78 => {
4431 cfg.feature_flags.move_native_context = true;
4432 cfg.tx_context_fresh_id_cost_base = Some(52);
4433 cfg.tx_context_sender_cost_base = Some(30);
4434 cfg.tx_context_epoch_cost_base = Some(30);
4435 cfg.tx_context_epoch_timestamp_ms_cost_base = Some(30);
4436 cfg.tx_context_sponsor_cost_base = Some(30);
4437 cfg.tx_context_gas_price_cost_base = Some(30);
4438 cfg.tx_context_gas_budget_cost_base = Some(30);
4439 cfg.tx_context_ids_created_cost_base = Some(30);
4440 cfg.tx_context_replace_cost_base = Some(30);
4441 cfg.gas_model_version = Some(10);
4442
4443 if chain != Chain::Mainnet {
4444 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
4445 cfg.consensus_commit_rate_estimation_window_size = Some(10);
4446
4447 cfg.feature_flags.per_object_congestion_control_mode =
4449 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4450 ExecutionTimeEstimateParams {
4451 target_utilization: 30,
4452 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4454 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4456 stored_observations_limit: u64::MAX,
4457 stake_weighted_median_threshold: 0,
4458 default_none_duration_for_new_keys: false,
4459 observations_chunk_size: None,
4460 },
4461 );
4462 }
4463 }
4464 79 => {
4465 if chain != Chain::Mainnet {
4466 cfg.feature_flags.consensus_median_based_commit_timestamp = true;
4467
4468 cfg.consensus_bad_nodes_stake_threshold = Some(30);
4471
4472 cfg.feature_flags.consensus_batched_block_sync = true;
4473
4474 cfg.feature_flags.enable_nitro_attestation = true
4476 }
4477 cfg.feature_flags.normalize_ptb_arguments = true;
4478
4479 cfg.consensus_gc_depth = Some(60);
4480 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
4481 }
4482 80 => {
4483 cfg.max_ptb_value_size = Some(1024 * 1024);
4484 }
4485 81 => {
4486 cfg.feature_flags.consensus_median_based_commit_timestamp = true;
4487 cfg.feature_flags.enforce_checkpoint_timestamp_monotonicity = true;
4488 cfg.consensus_bad_nodes_stake_threshold = Some(30)
4489 }
4490 82 => {
4491 cfg.feature_flags.max_ptb_value_size_v2 = true;
4492 }
4493 83 => {
4494 if chain == Chain::Mainnet {
4495 let aliased: [u8; 32] = Hex::decode(
4497 "0x0b2da327ba6a4cacbe75dddd50e6e8bbf81d6496e92d66af9154c61c77f7332f",
4498 )
4499 .unwrap()
4500 .try_into()
4501 .unwrap();
4502
4503 cfg.aliased_addresses.push(AliasedAddress {
4505 original: Hex::decode("0xcd8962dad278d8b50fa0f9eb0186bfa4cbdecc6d59377214c88d0286a0ac9562").unwrap().try_into().unwrap(),
4506 aliased,
4507 allowed_tx_digests: vec![
4508 Base58::decode("B2eGLFoMHgj93Ni8dAJBfqGzo8EWSTLBesZzhEpTPA4").unwrap().try_into().unwrap(),
4509 ],
4510 });
4511
4512 cfg.aliased_addresses.push(AliasedAddress {
4513 original: Hex::decode("0xe28b50cef1d633ea43d3296a3f6b67ff0312a5f1a99f0af753c85b8b5de8ff06").unwrap().try_into().unwrap(),
4514 aliased,
4515 allowed_tx_digests: vec![
4516 Base58::decode("J4QqSAgp7VrQtQpMy5wDX4QGsCSEZu3U5KuDAkbESAge").unwrap().try_into().unwrap(),
4517 ],
4518 });
4519 }
4520
4521 if chain != Chain::Mainnet {
4524 cfg.feature_flags.resolve_type_input_ids_to_defining_id = true;
4525 cfg.transfer_party_transfer_internal_cost_base = Some(52);
4526
4527 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
4529 cfg.consensus_commit_rate_estimation_window_size = Some(10);
4530 cfg.feature_flags.per_object_congestion_control_mode =
4531 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4532 ExecutionTimeEstimateParams {
4533 target_utilization: 30,
4534 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4536 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4538 stored_observations_limit: u64::MAX,
4539 stake_weighted_median_threshold: 0,
4540 default_none_duration_for_new_keys: false,
4541 observations_chunk_size: None,
4542 },
4543 );
4544
4545 cfg.feature_flags.consensus_batched_block_sync = true;
4547
4548 cfg.feature_flags.enable_nitro_attestation_upgraded_parsing = true;
4551 cfg.feature_flags.enable_nitro_attestation = true;
4552 }
4553 }
4554 84 => {
4555 if chain == Chain::Mainnet {
4556 cfg.feature_flags.resolve_type_input_ids_to_defining_id = true;
4557 cfg.transfer_party_transfer_internal_cost_base = Some(52);
4558
4559 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
4561 cfg.consensus_commit_rate_estimation_window_size = Some(10);
4562 cfg.feature_flags.per_object_congestion_control_mode =
4563 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4564 ExecutionTimeEstimateParams {
4565 target_utilization: 30,
4566 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4568 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4570 stored_observations_limit: u64::MAX,
4571 stake_weighted_median_threshold: 0,
4572 default_none_duration_for_new_keys: false,
4573 observations_chunk_size: None,
4574 },
4575 );
4576
4577 cfg.feature_flags.consensus_batched_block_sync = true;
4579
4580 cfg.feature_flags.enable_nitro_attestation_upgraded_parsing = true;
4583 cfg.feature_flags.enable_nitro_attestation = true;
4584 }
4585
4586 cfg.feature_flags.per_object_congestion_control_mode =
4588 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4589 ExecutionTimeEstimateParams {
4590 target_utilization: 30,
4591 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4593 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4595 stored_observations_limit: 20,
4596 stake_weighted_median_threshold: 0,
4597 default_none_duration_for_new_keys: false,
4598 observations_chunk_size: None,
4599 },
4600 );
4601 cfg.feature_flags.allow_unbounded_system_objects = true;
4602 }
4603 85 => {
4604 if chain != Chain::Mainnet && chain != Chain::Testnet {
4605 cfg.feature_flags.enable_party_transfer = true;
4606 }
4607
4608 cfg.feature_flags
4609 .record_consensus_determined_version_assignments_in_prologue_v2 = true;
4610 cfg.feature_flags.disallow_self_identifier = true;
4611 cfg.feature_flags.per_object_congestion_control_mode =
4612 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4613 ExecutionTimeEstimateParams {
4614 target_utilization: 50,
4615 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4617 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4619 stored_observations_limit: 20,
4620 stake_weighted_median_threshold: 0,
4621 default_none_duration_for_new_keys: false,
4622 observations_chunk_size: None,
4623 },
4624 );
4625 }
4626 86 => {
4627 cfg.feature_flags.type_tags_in_object_runtime = true;
4628 cfg.max_move_enum_variants = Some(move_core_types::VARIANT_COUNT_MAX);
4629
4630 cfg.feature_flags.per_object_congestion_control_mode =
4632 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4633 ExecutionTimeEstimateParams {
4634 target_utilization: 50,
4635 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4637 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4639 stored_observations_limit: 20,
4640 stake_weighted_median_threshold: 3334,
4641 default_none_duration_for_new_keys: false,
4642 observations_chunk_size: None,
4643 },
4644 );
4645 if chain != Chain::Mainnet {
4647 cfg.feature_flags.enable_party_transfer = true;
4648 }
4649 }
4650 87 => {
4651 if chain == Chain::Mainnet {
4652 cfg.feature_flags.record_time_estimate_processed = true;
4653 }
4654 cfg.feature_flags.better_adapter_type_resolution_errors = true;
4655 }
4656 88 => {
4657 cfg.feature_flags.record_time_estimate_processed = true;
4658 cfg.tx_context_rgp_cost_base = Some(30);
4659 cfg.feature_flags
4660 .ignore_execution_time_observations_after_certs_closed = true;
4661
4662 cfg.feature_flags.per_object_congestion_control_mode =
4665 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4666 ExecutionTimeEstimateParams {
4667 target_utilization: 50,
4668 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4670 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4672 stored_observations_limit: 20,
4673 stake_weighted_median_threshold: 3334,
4674 default_none_duration_for_new_keys: true,
4675 observations_chunk_size: None,
4676 },
4677 );
4678 }
4679 89 => {
4680 cfg.feature_flags.dependency_linkage_error = true;
4681 cfg.feature_flags.additional_multisig_checks = true;
4682 }
4683 90 => {
4684 cfg.max_gas_price_rgp_factor_for_aborted_transactions = Some(100);
4686 cfg.feature_flags.debug_fatal_on_move_invariant_violation = true;
4687 cfg.feature_flags.additional_consensus_digest_indirect_state = true;
4688 cfg.feature_flags.accept_passkey_in_multisig = true;
4689 cfg.feature_flags.passkey_auth = true;
4690 cfg.feature_flags.check_for_init_during_upgrade = true;
4691
4692 if chain != Chain::Mainnet {
4694 cfg.feature_flags.mysticeti_fastpath = true;
4695 }
4696 }
4697 91 => {
4698 cfg.feature_flags.per_command_shared_object_transfer_rules = true;
4699 }
4700 92 => {
4701 cfg.feature_flags.per_command_shared_object_transfer_rules = false;
4702 }
4703 93 => {
4704 cfg.feature_flags
4705 .consensus_checkpoint_signature_key_includes_digest = true;
4706 }
4707 94 => {
4708 cfg.feature_flags.per_object_congestion_control_mode =
4710 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4711 ExecutionTimeEstimateParams {
4712 target_utilization: 50,
4713 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4715 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4717 stored_observations_limit: 18,
4718 stake_weighted_median_threshold: 3334,
4719 default_none_duration_for_new_keys: true,
4720 observations_chunk_size: None,
4721 },
4722 );
4723
4724 cfg.feature_flags.enable_party_transfer = true;
4726 }
4727 95 => {
4728 cfg.type_name_id_base_cost = Some(52);
4729
4730 cfg.max_transactions_per_checkpoint = Some(20_000);
4732 }
4733 96 => {
4734 if chain != Chain::Mainnet && chain != Chain::Testnet {
4736 cfg.feature_flags
4737 .include_checkpoint_artifacts_digest_in_summary = true;
4738 }
4739 cfg.feature_flags.correct_gas_payment_limit_check = true;
4740 cfg.feature_flags.authority_capabilities_v2 = true;
4741 cfg.feature_flags.use_mfp_txns_in_load_initial_object_debts = true;
4742 cfg.feature_flags.cancel_for_failed_dkg_early = true;
4743 cfg.feature_flags.enable_coin_registry = true;
4744
4745 cfg.feature_flags.mysticeti_fastpath = true;
4747 }
4748 97 => {
4749 cfg.feature_flags.additional_borrow_checks = true;
4750 }
4751 98 => {
4752 cfg.event_emit_auth_stream_cost = Some(52);
4753 cfg.feature_flags.better_loader_errors = true;
4754 cfg.feature_flags.generate_df_type_layouts = true;
4755 }
4756 99 => {
4757 cfg.feature_flags.use_new_commit_handler = true;
4758 }
4759 100 => {
4760 cfg.feature_flags.private_generics_verifier_v2 = true;
4761 }
4762 101 => {
4763 cfg.feature_flags.create_root_accumulator_object = true;
4764 cfg.max_updates_per_settlement_txn = Some(100);
4765 if chain != Chain::Mainnet {
4766 cfg.feature_flags.enable_poseidon = true;
4767 }
4768 }
4769 102 => {
4770 cfg.feature_flags.per_object_congestion_control_mode =
4774 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4775 ExecutionTimeEstimateParams {
4776 target_utilization: 50,
4777 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4779 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4781 stored_observations_limit: 180,
4782 stake_weighted_median_threshold: 3334,
4783 default_none_duration_for_new_keys: true,
4784 observations_chunk_size: Some(18),
4785 },
4786 );
4787 cfg.feature_flags.deprecate_global_storage_ops = true;
4788 }
4789 103 => {}
4790 104 => {
4791 cfg.translation_per_command_base_charge = Some(1);
4792 cfg.translation_per_input_base_charge = Some(1);
4793 cfg.translation_pure_input_per_byte_charge = Some(1);
4794 cfg.translation_per_type_node_charge = Some(1);
4795 cfg.translation_per_reference_node_charge = Some(1);
4796 cfg.translation_per_linkage_entry_charge = Some(10);
4797 cfg.gas_model_version = Some(11);
4798 cfg.feature_flags.abstract_size_in_object_runtime = true;
4799 cfg.feature_flags.object_runtime_charge_cache_load_gas = true;
4800 cfg.dynamic_field_hash_type_and_key_cost_base = Some(52);
4801 cfg.dynamic_field_add_child_object_cost_base = Some(52);
4802 cfg.dynamic_field_add_child_object_value_cost_per_byte = Some(1);
4803 cfg.dynamic_field_borrow_child_object_cost_base = Some(52);
4804 cfg.dynamic_field_borrow_child_object_child_ref_cost_per_byte = Some(1);
4805 cfg.dynamic_field_remove_child_object_cost_base = Some(52);
4806 cfg.dynamic_field_remove_child_object_child_cost_per_byte = Some(1);
4807 cfg.dynamic_field_has_child_object_cost_base = Some(52);
4808 cfg.dynamic_field_has_child_object_with_ty_cost_base = Some(52);
4809 cfg.feature_flags.enable_ptb_execution_v2 = true;
4810
4811 cfg.poseidon_bn254_cost_base = Some(260);
4812
4813 cfg.feature_flags.consensus_skip_gced_accept_votes = true;
4814
4815 if chain != Chain::Mainnet {
4816 cfg.feature_flags
4817 .enable_nitro_attestation_all_nonzero_pcrs_parsing = true;
4818 }
4819
4820 cfg.feature_flags
4821 .include_cancelled_randomness_txns_in_prologue = true;
4822 }
4823 105 => {
4824 cfg.feature_flags.enable_multi_epoch_transaction_expiration = true;
4825 cfg.feature_flags.disable_preconsensus_locking = true;
4826
4827 if chain != Chain::Mainnet {
4828 cfg.feature_flags
4829 .enable_nitro_attestation_always_include_required_pcrs_parsing = true;
4830 }
4831 }
4832 106 => {
4833 cfg.accumulator_object_storage_cost = Some(7600);
4835
4836 if chain != Chain::Mainnet && chain != Chain::Testnet {
4837 cfg.feature_flags.enable_accumulators = true;
4838 cfg.feature_flags.enable_address_balance_gas_payments = true;
4839 cfg.feature_flags.enable_authenticated_event_streams = true;
4840 cfg.feature_flags.enable_object_funds_withdraw = true;
4841 }
4842 }
4843 107 => {
4844 cfg.feature_flags
4845 .consensus_skip_gced_blocks_in_direct_finalization = true;
4846
4847 if in_integration_test() {
4849 cfg.consensus_gc_depth = Some(6);
4850 cfg.consensus_max_num_transactions_in_block = Some(8);
4851 }
4852 }
4853 108 => {
4854 cfg.feature_flags.gas_rounding_halve_digits = true;
4855 cfg.feature_flags.flexible_tx_context_positions = true;
4856 cfg.feature_flags.disable_entry_point_signature_check = true;
4857
4858 if chain != Chain::Mainnet {
4859 cfg.feature_flags.address_aliases = true;
4860
4861 cfg.feature_flags.enable_accumulators = true;
4862 cfg.feature_flags.enable_address_balance_gas_payments = true;
4863 }
4864
4865 cfg.feature_flags.enable_poseidon = true;
4866 }
4867 109 => {
4868 cfg.binary_variant_handles = Some(1024);
4869 cfg.binary_variant_instantiation_handles = Some(1024);
4870 cfg.feature_flags.restrict_hot_or_not_entry_functions = true;
4871 }
4872 110 => {
4873 cfg.feature_flags
4874 .enable_nitro_attestation_all_nonzero_pcrs_parsing = true;
4875 cfg.feature_flags
4876 .enable_nitro_attestation_always_include_required_pcrs_parsing = true;
4877 if chain != Chain::Mainnet && chain != Chain::Testnet {
4878 cfg.feature_flags.split_checkpoints_in_consensus_handler = true;
4879 }
4880 cfg.feature_flags.validate_zklogin_public_identifier = true;
4881 cfg.feature_flags.fix_checkpoint_signature_mapping = true;
4882 cfg.feature_flags
4883 .consensus_always_accept_system_transactions = true;
4884 if chain != Chain::Mainnet {
4885 cfg.feature_flags.enable_object_funds_withdraw = true;
4886 }
4887 }
4888 111 => {
4889 cfg.feature_flags.validator_metadata_verify_v2 = true;
4890 }
4891 112 => {
4892 cfg.group_ops_ristretto_decode_scalar_cost = Some(7);
4893 cfg.group_ops_ristretto_decode_point_cost = Some(200);
4894 cfg.group_ops_ristretto_scalar_add_cost = Some(10);
4895 cfg.group_ops_ristretto_point_add_cost = Some(500);
4896 cfg.group_ops_ristretto_scalar_sub_cost = Some(10);
4897 cfg.group_ops_ristretto_point_sub_cost = Some(500);
4898 cfg.group_ops_ristretto_scalar_mul_cost = Some(11);
4899 cfg.group_ops_ristretto_point_mul_cost = Some(1200);
4900 cfg.group_ops_ristretto_scalar_div_cost = Some(151);
4901 cfg.group_ops_ristretto_point_div_cost = Some(2500);
4902
4903 if chain != Chain::Mainnet && chain != Chain::Testnet {
4904 cfg.feature_flags.enable_ristretto255_group_ops = true;
4905 }
4906 }
4907 113 => {
4908 cfg.feature_flags.address_balance_gas_check_rgp_at_signing = true;
4909 if chain != Chain::Mainnet && chain != Chain::Testnet {
4910 cfg.feature_flags.defer_unpaid_amplification = true;
4911 }
4912 }
4913 114 => {
4914 cfg.feature_flags.randomize_checkpoint_tx_limit_in_tests = true;
4915 cfg.feature_flags.address_balance_gas_reject_gas_coin_arg = true;
4916 if chain != Chain::Mainnet {
4917 cfg.feature_flags.split_checkpoints_in_consensus_handler = true;
4918 cfg.feature_flags.enable_authenticated_event_streams = true;
4919 cfg.feature_flags
4920 .include_checkpoint_artifacts_digest_in_summary = true;
4921 }
4922 }
4923 115 => {
4924 cfg.feature_flags.normalize_depth_formula = true;
4925 }
4926 116 => {
4927 cfg.feature_flags.gasless_transaction_drop_safety = true;
4928 cfg.feature_flags.address_aliases = true;
4929 cfg.feature_flags.relax_valid_during_for_owned_inputs = true;
4930 cfg.feature_flags.defer_unpaid_amplification = false;
4932 cfg.feature_flags.enable_display_registry = true;
4933 }
4934 117 => {}
4935 118 => {
4936 cfg.feature_flags.use_coin_party_owner = true;
4937 }
4938 119 => {
4939 cfg.execution_version = Some(4);
4941 cfg.feature_flags.address_balance_gas_reject_gas_coin_arg = false;
4942 cfg.feature_flags.merge_randomness_into_checkpoint = true;
4943 if chain != Chain::Mainnet {
4944 cfg.feature_flags.enable_gasless = true;
4945 cfg.gasless_max_computation_units = Some(50_000);
4946 cfg.gasless_allowed_token_types = Some(vec![]);
4947 cfg.feature_flags.enable_coin_reservation_obj_refs = true;
4948 cfg.feature_flags
4949 .convert_withdrawal_compatibility_ptb_arguments = true;
4950 }
4951 cfg.gasless_max_unused_inputs = Some(1);
4952 cfg.gasless_max_pure_input_bytes = Some(32);
4953 if chain == Chain::Testnet {
4954 cfg.gasless_allowed_token_types = Some(vec![(TESTNET_USDC.to_string(), 0)]);
4955 }
4956 cfg.transfer_receive_object_cost_per_byte = Some(1);
4957 cfg.transfer_receive_object_type_cost_per_byte = Some(2);
4958 }
4959 120 => {
4960 cfg.feature_flags.disallow_jump_orphans = true;
4961 }
4962 121 => {
4963 if chain != Chain::Mainnet {
4965 cfg.feature_flags.defer_unpaid_amplification = true;
4966 cfg.gasless_max_tps = Some(50);
4967 }
4968 cfg.feature_flags
4969 .early_return_receive_object_mismatched_type = true;
4970 }
4971 122 => {
4972 cfg.feature_flags.defer_unpaid_amplification = true;
4974 cfg.verify_bulletproofs_ristretto255_base_cost = Some(30000);
4976 cfg.verify_bulletproofs_ristretto255_cost_per_bit_and_commitment = Some(6500);
4977 if chain != Chain::Mainnet && chain != Chain::Testnet {
4978 cfg.feature_flags.enable_verify_bulletproofs_ristretto255 = true;
4979 }
4980 cfg.feature_flags.gasless_verify_remaining_balance = true;
4981 cfg.include_special_package_amendments = match chain {
4982 Chain::Mainnet => Some(MAINNET_LINKAGE_AMENDMENTS.clone()),
4983 Chain::Testnet => Some(TESTNET_LINKAGE_AMENDMENTS.clone()),
4984 Chain::Unknown => None,
4985 };
4986 cfg.gasless_max_tx_size_bytes = Some(16 * 1024);
4987 cfg.gasless_max_tps = Some(300);
4988 cfg.gasless_max_computation_units = Some(5_000);
4989 }
4990 123 => {
4991 cfg.gas_model_version = Some(13);
4992 }
4993 124 => {
4994 if chain != Chain::Mainnet && chain != Chain::Testnet {
4995 cfg.feature_flags.timestamp_based_epoch_close = true;
4996 }
4997 cfg.gas_model_version = Some(14);
4998 cfg.feature_flags.limit_groth16_pvk_inputs = true;
4999
5000 cfg.feature_flags.enable_accumulators = true;
5006 cfg.feature_flags.enable_address_balance_gas_payments = true;
5007 cfg.feature_flags.enable_authenticated_event_streams = true;
5008 cfg.feature_flags.enable_coin_reservation_obj_refs = true;
5009 cfg.feature_flags.enable_object_funds_withdraw = true;
5010 cfg.feature_flags
5011 .convert_withdrawal_compatibility_ptb_arguments = true;
5012 cfg.feature_flags.split_checkpoints_in_consensus_handler = true;
5013 cfg.feature_flags
5014 .include_checkpoint_artifacts_digest_in_summary = true;
5015 cfg.feature_flags.enable_gasless = true;
5016
5017 if chain == Chain::Mainnet {
5022 cfg.gasless_allowed_token_types = Some(vec![
5023 (MAINNET_USDC.to_string(), 10_000),
5024 (MAINNET_USDSUI.to_string(), 10_000),
5025 (MAINNET_SUI_USDE.to_string(), 10_000),
5026 (MAINNET_USDY.to_string(), 10_000),
5027 (MAINNET_FDUSD.to_string(), 10_000),
5028 (MAINNET_AUSD.to_string(), 10_000),
5029 (MAINNET_USDB.to_string(), 10_000),
5030 ]);
5031 }
5032 }
5033 125 => {
5034 cfg.feature_flags.granular_post_execution_checks = true;
5035 if chain != Chain::Mainnet {
5036 cfg.feature_flags.timestamp_based_epoch_close = true;
5037 }
5038 }
5039 126 => {
5040 cfg.feature_flags.early_exit_on_iffw = true;
5041 }
5042 127 => {
5043 cfg.feature_flags.always_advance_dkg_to_resolution = true;
5044
5045 cfg.verify_bulletproofs_ristretto255_base_cost = Some(23866);
5046 cfg.verify_bulletproofs_ristretto255_cost_per_bit_and_commitment = Some(1324);
5047 cfg.group_ops_ristretto_decode_scalar_cost = Some(5);
5048 cfg.group_ops_ristretto_decode_point_cost = Some(216);
5049 cfg.group_ops_ristretto_scalar_add_cost = Some(2);
5050 cfg.group_ops_ristretto_point_add_cost = Some(8);
5051 cfg.group_ops_ristretto_scalar_sub_cost = Some(2);
5052 cfg.group_ops_ristretto_point_sub_cost = Some(8);
5053 cfg.group_ops_ristretto_scalar_mul_cost = Some(5);
5054 cfg.group_ops_ristretto_point_mul_cost = Some(1763);
5055 cfg.group_ops_ristretto_scalar_div_cost = Some(557);
5056 cfg.group_ops_ristretto_point_div_cost = Some(2244);
5057
5058 if chain != Chain::Mainnet {
5059 cfg.feature_flags.enable_ristretto255_group_ops = true;
5060 cfg.feature_flags.enable_verify_bulletproofs_ristretto255 = true;
5061 }
5062
5063 cfg.feature_flags.timestamp_based_epoch_close = true;
5064 }
5065 128 => {
5066 cfg.max_generic_instantiation_type_nodes_per_function = Some(10_000);
5067 cfg.max_generic_instantiation_type_nodes_per_module = Some(500_000);
5068 cfg.binary_enum_defs = Some(200);
5069 cfg.binary_enum_def_instantiations = Some(100);
5070 }
5071 129 => {
5072 cfg.feature_flags.enable_unified_linkage = true;
5073 }
5074 _ => panic!("unsupported version {:?}", version),
5085 }
5086 }
5087
5088 cfg
5089 }
5090
5091 pub fn apply_seeded_test_overrides(&mut self, seed: &[u8; 32]) {
5092 if !self.feature_flags.randomize_checkpoint_tx_limit_in_tests
5093 || !self.feature_flags.split_checkpoints_in_consensus_handler
5094 {
5095 return;
5096 }
5097
5098 if !mysten_common::in_test_configuration() {
5099 return;
5100 }
5101
5102 use rand::{Rng, SeedableRng, rngs::StdRng};
5103 let mut rng = StdRng::from_seed(*seed);
5104 let max_txns = rng.gen_range(10..=100u64);
5105 info!("seeded test override: max_transactions_per_checkpoint = {max_txns}");
5106 self.max_transactions_per_checkpoint = Some(max_txns);
5107 }
5108
5109 pub fn verifier_config(&self, signing_limits: Option<(usize, usize, usize)>) -> VerifierConfig {
5115 let (
5116 max_back_edges_per_function,
5117 max_back_edges_per_module,
5118 sanity_check_with_regex_reference_safety,
5119 ) = if let Some((
5120 max_back_edges_per_function,
5121 max_back_edges_per_module,
5122 sanity_check_with_regex_reference_safety,
5123 )) = signing_limits
5124 {
5125 (
5126 Some(max_back_edges_per_function),
5127 Some(max_back_edges_per_module),
5128 Some(sanity_check_with_regex_reference_safety),
5129 )
5130 } else {
5131 (None, None, None)
5132 };
5133
5134 let additional_borrow_checks = if signing_limits.is_some() {
5135 true
5137 } else {
5138 self.additional_borrow_checks()
5139 };
5140 let deprecate_global_storage_ops = if signing_limits.is_some() {
5141 true
5143 } else {
5144 self.deprecate_global_storage_ops()
5145 };
5146
5147 VerifierConfig {
5148 max_loop_depth: Some(self.max_loop_depth() as usize),
5149 max_generic_instantiation_length: Some(self.max_generic_instantiation_length() as usize),
5150 max_function_parameters: Some(self.max_function_parameters() as usize),
5151 max_basic_blocks: Some(self.max_basic_blocks() as usize),
5152 max_value_stack_size: self.max_value_stack_size() as usize,
5153 max_type_nodes: Some(self.max_type_nodes() as usize),
5154 max_generic_instantiation_type_nodes_per_function: self
5155 .max_generic_instantiation_type_nodes_per_function_as_option()
5156 .map(|v| v as usize),
5157 max_generic_instantiation_type_nodes_per_module: self
5158 .max_generic_instantiation_type_nodes_per_module_as_option()
5159 .map(|v| v as usize),
5160 max_push_size: Some(self.max_push_size() as usize),
5161 max_dependency_depth: Some(self.max_dependency_depth() as usize),
5162 max_fields_in_struct: Some(self.max_fields_in_struct() as usize),
5163 max_function_definitions: Some(self.max_function_definitions() as usize),
5164 max_data_definitions: Some(self.max_struct_definitions() as usize),
5165 max_constant_vector_len: Some(self.max_move_vector_len()),
5166 max_back_edges_per_function,
5167 max_back_edges_per_module,
5168 max_basic_blocks_in_script: None,
5169 max_identifier_len: self.max_move_identifier_len_as_option(), disallow_self_identifier: self.feature_flags.disallow_self_identifier,
5171 allow_receiving_object_id: self.allow_receiving_object_id(),
5172 reject_mutable_random_on_entry_functions: self
5173 .reject_mutable_random_on_entry_functions(),
5174 bytecode_version: self.move_binary_format_version(),
5175 max_variants_in_enum: self.max_move_enum_variants_as_option(),
5176 additional_borrow_checks,
5177 better_loader_errors: self.better_loader_errors(),
5178 private_generics_verifier_v2: self.private_generics_verifier_v2(),
5179 sanity_check_with_regex_reference_safety: sanity_check_with_regex_reference_safety
5180 .map(|limit| limit as u128),
5181 deprecate_global_storage_ops,
5182 disable_entry_point_signature_check: self.disable_entry_point_signature_check(),
5183 switch_to_regex_reference_safety: false,
5184 disallow_jump_orphans: self.disallow_jump_orphans(),
5185 }
5186 }
5187
5188 pub fn binary_config(
5189 &self,
5190 override_deprecate_global_storage_ops_during_deserialization: Option<bool>,
5191 ) -> BinaryConfig {
5192 let deprecate_global_storage_ops =
5193 override_deprecate_global_storage_ops_during_deserialization
5194 .unwrap_or_else(|| self.deprecate_global_storage_ops());
5195 BinaryConfig::new(
5196 self.move_binary_format_version(),
5197 self.min_move_binary_format_version_as_option()
5198 .unwrap_or(VERSION_1),
5199 self.no_extraneous_module_bytes(),
5200 deprecate_global_storage_ops,
5201 TableConfig {
5202 module_handles: self.binary_module_handles_as_option().unwrap_or(u16::MAX),
5203 datatype_handles: self.binary_struct_handles_as_option().unwrap_or(u16::MAX),
5204 function_handles: self.binary_function_handles_as_option().unwrap_or(u16::MAX),
5205 function_instantiations: self
5206 .binary_function_instantiations_as_option()
5207 .unwrap_or(u16::MAX),
5208 signatures: self.binary_signatures_as_option().unwrap_or(u16::MAX),
5209 constant_pool: self.binary_constant_pool_as_option().unwrap_or(u16::MAX),
5210 identifiers: self.binary_identifiers_as_option().unwrap_or(u16::MAX),
5211 address_identifiers: self
5212 .binary_address_identifiers_as_option()
5213 .unwrap_or(u16::MAX),
5214 struct_defs: self.binary_struct_defs_as_option().unwrap_or(u16::MAX),
5215 struct_def_instantiations: self
5216 .binary_struct_def_instantiations_as_option()
5217 .unwrap_or(u16::MAX),
5218 function_defs: self.binary_function_defs_as_option().unwrap_or(u16::MAX),
5219 field_handles: self.binary_field_handles_as_option().unwrap_or(u16::MAX),
5220 field_instantiations: self
5221 .binary_field_instantiations_as_option()
5222 .unwrap_or(u16::MAX),
5223 friend_decls: self.binary_friend_decls_as_option().unwrap_or(u16::MAX),
5224 enum_defs: self.binary_enum_defs_as_option().unwrap_or(u16::MAX),
5225 enum_def_instantiations: self
5226 .binary_enum_def_instantiations_as_option()
5227 .unwrap_or(u16::MAX),
5228 variant_handles: self.binary_variant_handles_as_option().unwrap_or(u16::MAX),
5229 variant_instantiation_handles: self
5230 .binary_variant_instantiation_handles_as_option()
5231 .unwrap_or(u16::MAX),
5232 },
5233 )
5234 }
5235
5236 #[cfg(not(msim))]
5240 pub fn apply_overrides_for_testing(
5241 override_fn: impl Fn(ProtocolVersion, Self) -> Self + Send + Sync + 'static,
5242 ) -> OverrideGuard {
5243 let mut cur = CONFIG_OVERRIDE.lock().unwrap();
5244 assert!(cur.is_none(), "config override already present");
5245 *cur = Some(Box::new(override_fn));
5246 OverrideGuard
5247 }
5248
5249 #[cfg(msim)]
5253 pub fn apply_overrides_for_testing(
5254 override_fn: impl Fn(ProtocolVersion, Self) -> Self + Send + 'static,
5255 ) -> OverrideGuard {
5256 CONFIG_OVERRIDE.with(|ovr| {
5257 let mut cur = ovr.borrow_mut();
5258 assert!(cur.is_none(), "config override already present");
5259 *cur = Some(Box::new(override_fn));
5260 OverrideGuard
5261 })
5262 }
5263
5264 #[cfg(not(msim))]
5265 fn apply_config_override(version: ProtocolVersion, mut ret: Self) -> Self {
5266 if let Some(override_fn) = CONFIG_OVERRIDE.lock().unwrap().as_ref() {
5267 warn!(
5268 "overriding ProtocolConfig settings with custom settings (you should not see this log outside of tests)"
5269 );
5270 ret = override_fn(version, ret);
5271 }
5272 ret
5273 }
5274
5275 #[cfg(msim)]
5276 fn apply_config_override(version: ProtocolVersion, ret: Self) -> Self {
5277 CONFIG_OVERRIDE.with(|ovr| {
5278 if let Some(override_fn) = &*ovr.borrow() {
5279 warn!(
5280 "overriding ProtocolConfig settings with custom settings (you should not see this log outside of tests)"
5281 );
5282 override_fn(version, ret)
5283 } else {
5284 ret
5285 }
5286 })
5287 }
5288}
5289
5290impl ProtocolConfig {
5294 pub fn set_advance_to_highest_supported_protocol_version_for_testing(&mut self, val: bool) {
5295 self.feature_flags
5296 .advance_to_highest_supported_protocol_version = val
5297 }
5298 pub fn set_commit_root_state_digest_supported_for_testing(&mut self, val: bool) {
5299 self.feature_flags.commit_root_state_digest = val
5300 }
5301 pub fn set_zklogin_auth_for_testing(&mut self, val: bool) {
5302 self.feature_flags.zklogin_auth = val
5303 }
5304 pub fn set_enable_jwk_consensus_updates_for_testing(&mut self, val: bool) {
5305 self.feature_flags.enable_jwk_consensus_updates = val
5306 }
5307 pub fn set_random_beacon_for_testing(&mut self, val: bool) {
5308 self.feature_flags.random_beacon = val
5309 }
5310
5311 pub fn set_upgraded_multisig_for_testing(&mut self, val: bool) {
5312 self.feature_flags.upgraded_multisig_supported = val
5313 }
5314 pub fn set_accept_zklogin_in_multisig_for_testing(&mut self, val: bool) {
5315 self.feature_flags.accept_zklogin_in_multisig = val
5316 }
5317
5318 pub fn set_shared_object_deletion_for_testing(&mut self, val: bool) {
5319 self.feature_flags.shared_object_deletion = val;
5320 }
5321
5322 pub fn set_narwhal_new_leader_election_schedule_for_testing(&mut self, val: bool) {
5323 self.feature_flags.narwhal_new_leader_election_schedule = val;
5324 }
5325
5326 pub fn set_receive_object_for_testing(&mut self, val: bool) {
5327 self.feature_flags.receive_objects = val
5328 }
5329 pub fn set_narwhal_certificate_v2_for_testing(&mut self, val: bool) {
5330 self.feature_flags.narwhal_certificate_v2 = val
5331 }
5332 pub fn set_verify_legacy_zklogin_address_for_testing(&mut self, val: bool) {
5333 self.feature_flags.verify_legacy_zklogin_address = val
5334 }
5335
5336 pub fn set_per_object_congestion_control_mode_for_testing(
5337 &mut self,
5338 val: PerObjectCongestionControlMode,
5339 ) {
5340 self.feature_flags.per_object_congestion_control_mode = val;
5341 }
5342
5343 pub fn set_consensus_choice_for_testing(&mut self, val: ConsensusChoice) {
5344 self.feature_flags.consensus_choice = val;
5345 }
5346
5347 pub fn set_consensus_network_for_testing(&mut self, val: ConsensusNetwork) {
5348 self.feature_flags.consensus_network = val;
5349 }
5350
5351 pub fn set_zklogin_max_epoch_upper_bound_delta_for_testing(&mut self, val: Option<u64>) {
5352 self.feature_flags.zklogin_max_epoch_upper_bound_delta = val
5353 }
5354
5355 pub fn set_disable_bridge_for_testing(&mut self) {
5356 self.feature_flags.bridge = false
5357 }
5358
5359 pub fn set_mysticeti_num_leaders_per_round_for_testing(&mut self, val: Option<usize>) {
5360 self.feature_flags.mysticeti_num_leaders_per_round = val;
5361 }
5362
5363 pub fn set_enable_soft_bundle_for_testing(&mut self, val: bool) {
5364 self.feature_flags.soft_bundle = val;
5365 }
5366
5367 pub fn set_passkey_auth_for_testing(&mut self, val: bool) {
5368 self.feature_flags.passkey_auth = val
5369 }
5370
5371 pub fn set_enable_party_transfer_for_testing(&mut self, val: bool) {
5372 self.feature_flags.enable_party_transfer = val
5373 }
5374
5375 pub fn set_enable_unified_linkage_for_testing(&mut self, val: bool) {
5376 self.feature_flags.enable_unified_linkage = val
5377 }
5378
5379 pub fn set_consensus_distributed_vote_scoring_strategy_for_testing(&mut self, val: bool) {
5380 self.feature_flags
5381 .consensus_distributed_vote_scoring_strategy = val;
5382 }
5383
5384 pub fn set_consensus_round_prober_for_testing(&mut self, val: bool) {
5385 self.feature_flags.consensus_round_prober = val;
5386 }
5387
5388 pub fn set_disallow_new_modules_in_deps_only_packages_for_testing(&mut self, val: bool) {
5389 self.feature_flags
5390 .disallow_new_modules_in_deps_only_packages = val;
5391 }
5392
5393 pub fn set_correct_gas_payment_limit_check_for_testing(&mut self, val: bool) {
5394 self.feature_flags.correct_gas_payment_limit_check = val;
5395 }
5396
5397 pub fn set_address_aliases_for_testing(&mut self, val: bool) {
5398 self.feature_flags.address_aliases = val;
5399 }
5400
5401 pub fn set_consensus_round_prober_probe_accepted_rounds(&mut self, val: bool) {
5402 self.feature_flags
5403 .consensus_round_prober_probe_accepted_rounds = val;
5404 }
5405
5406 pub fn set_mysticeti_fastpath_for_testing(&mut self, val: bool) {
5407 self.feature_flags.mysticeti_fastpath = val;
5408 }
5409
5410 pub fn set_accept_passkey_in_multisig_for_testing(&mut self, val: bool) {
5411 self.feature_flags.accept_passkey_in_multisig = val;
5412 }
5413
5414 pub fn set_consensus_batched_block_sync_for_testing(&mut self, val: bool) {
5415 self.feature_flags.consensus_batched_block_sync = val;
5416 }
5417
5418 pub fn set_record_time_estimate_processed_for_testing(&mut self, val: bool) {
5419 self.feature_flags.record_time_estimate_processed = val;
5420 }
5421
5422 pub fn set_prepend_prologue_tx_in_consensus_commit_in_checkpoints_for_testing(
5423 &mut self,
5424 val: bool,
5425 ) {
5426 self.feature_flags
5427 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = val;
5428 }
5429
5430 pub fn enable_accumulators_for_testing(&mut self) {
5431 self.feature_flags.enable_accumulators = true;
5432 }
5433
5434 pub fn disable_accumulators_for_testing(&mut self) {
5435 self.feature_flags.enable_accumulators = false;
5436 self.feature_flags.enable_address_balance_gas_payments = false;
5437 }
5438
5439 pub fn enable_coin_reservation_for_testing(&mut self) {
5440 self.feature_flags.enable_coin_reservation_obj_refs = true;
5441 self.feature_flags
5442 .convert_withdrawal_compatibility_ptb_arguments = true;
5443 self.execution_version = Some(self.execution_version.map_or(4, |v| v.max(4)));
5446 }
5447
5448 pub fn disable_coin_reservation_for_testing(&mut self) {
5449 self.feature_flags.enable_coin_reservation_obj_refs = false;
5450 self.feature_flags
5451 .convert_withdrawal_compatibility_ptb_arguments = false;
5452 }
5453
5454 pub fn create_root_accumulator_object_for_testing(&mut self) {
5455 self.feature_flags.create_root_accumulator_object = true;
5456 }
5457
5458 pub fn disable_create_root_accumulator_object_for_testing(&mut self) {
5459 self.feature_flags.create_root_accumulator_object = false;
5460 }
5461
5462 pub fn enable_address_balance_gas_payments_for_testing(&mut self) {
5463 self.feature_flags.enable_accumulators = true;
5464 self.feature_flags.allow_private_accumulator_entrypoints = true;
5465 self.feature_flags.enable_address_balance_gas_payments = true;
5466 self.feature_flags.address_balance_gas_check_rgp_at_signing = true;
5467 self.feature_flags.address_balance_gas_reject_gas_coin_arg = false;
5468 self.execution_version = Some(self.execution_version.map_or(4, |v| v.max(4)))
5469 }
5470
5471 pub fn disable_address_balance_gas_payments_for_testing(&mut self) {
5472 self.feature_flags.enable_address_balance_gas_payments = false;
5473 }
5474
5475 pub fn enable_gasless_for_testing(&mut self) {
5476 self.enable_address_balance_gas_payments_for_testing();
5477 self.feature_flags.enable_gasless = true;
5478 self.feature_flags.gasless_verify_remaining_balance = true;
5479 self.gasless_max_computation_units = Some(5_000);
5480 self.gasless_allowed_token_types = Some(vec![]);
5481 self.gasless_max_tps = Some(1000);
5482 self.gasless_max_tx_size_bytes = Some(16 * 1024);
5483 }
5484
5485 pub fn disable_gasless_for_testing(&mut self) {
5486 self.feature_flags.enable_gasless = false;
5487 self.gasless_max_computation_units = None;
5488 self.gasless_allowed_token_types = None;
5489 }
5490
5491 pub fn enable_multi_epoch_transaction_expiration_for_testing(&mut self) {
5492 self.feature_flags.enable_multi_epoch_transaction_expiration = true;
5493 }
5494
5495 pub fn enable_authenticated_event_streams_for_testing(&mut self) {
5496 self.enable_accumulators_for_testing();
5497 self.feature_flags.enable_authenticated_event_streams = true;
5498 self.feature_flags
5499 .include_checkpoint_artifacts_digest_in_summary = true;
5500 self.feature_flags.split_checkpoints_in_consensus_handler = true;
5501 }
5502
5503 pub fn disable_authenticated_event_streams_for_testing(&mut self) {
5504 self.feature_flags.enable_authenticated_event_streams = false;
5505 }
5506
5507 pub fn disable_randomize_checkpoint_tx_limit_for_testing(&mut self) {
5508 self.feature_flags.randomize_checkpoint_tx_limit_in_tests = false;
5509 }
5510
5511 pub fn enable_non_exclusive_writes_for_testing(&mut self) {
5512 self.feature_flags.enable_non_exclusive_writes = true;
5513 }
5514
5515 pub fn set_relax_valid_during_for_owned_inputs_for_testing(&mut self, val: bool) {
5516 self.feature_flags.relax_valid_during_for_owned_inputs = val;
5517 }
5518
5519 pub fn set_ignore_execution_time_observations_after_certs_closed_for_testing(
5520 &mut self,
5521 val: bool,
5522 ) {
5523 self.feature_flags
5524 .ignore_execution_time_observations_after_certs_closed = val;
5525 }
5526
5527 pub fn set_consensus_checkpoint_signature_key_includes_digest_for_testing(
5528 &mut self,
5529 val: bool,
5530 ) {
5531 self.feature_flags
5532 .consensus_checkpoint_signature_key_includes_digest = val;
5533 }
5534
5535 pub fn set_cancel_for_failed_dkg_early_for_testing(&mut self, val: bool) {
5536 self.feature_flags.cancel_for_failed_dkg_early = val;
5537 }
5538
5539 pub fn set_always_advance_dkg_to_resolution_for_testing(&mut self, val: bool) {
5540 self.feature_flags.always_advance_dkg_to_resolution = val;
5541 }
5542
5543 pub fn set_use_mfp_txns_in_load_initial_object_debts_for_testing(&mut self, val: bool) {
5544 self.feature_flags.use_mfp_txns_in_load_initial_object_debts = val;
5545 }
5546
5547 pub fn set_authority_capabilities_v2_for_testing(&mut self, val: bool) {
5548 self.feature_flags.authority_capabilities_v2 = val;
5549 }
5550
5551 pub fn allow_references_in_ptbs_for_testing(&mut self) {
5552 self.feature_flags.allow_references_in_ptbs = true;
5553 }
5554
5555 pub fn set_consensus_skip_gced_accept_votes_for_testing(&mut self, val: bool) {
5556 self.feature_flags.consensus_skip_gced_accept_votes = val;
5557 }
5558
5559 pub fn set_enable_object_funds_withdraw_for_testing(&mut self, val: bool) {
5560 self.feature_flags.enable_object_funds_withdraw = val;
5561 }
5562
5563 pub fn set_split_checkpoints_in_consensus_handler_for_testing(&mut self, val: bool) {
5564 self.feature_flags.split_checkpoints_in_consensus_handler = val;
5565 }
5566
5567 pub fn set_merge_randomness_into_checkpoint_for_testing(&mut self, val: bool) {
5568 self.feature_flags.merge_randomness_into_checkpoint = val;
5569 }
5570}
5571
5572#[cfg(not(msim))]
5573type OverrideFn = dyn Fn(ProtocolVersion, ProtocolConfig) -> ProtocolConfig + Send + Sync;
5574
5575#[cfg(not(msim))]
5576static CONFIG_OVERRIDE: Mutex<Option<Box<OverrideFn>>> = Mutex::new(None);
5577
5578#[cfg(msim)]
5579type OverrideFn = dyn Fn(ProtocolVersion, ProtocolConfig) -> ProtocolConfig + Send;
5580
5581#[cfg(msim)]
5582thread_local! {
5583 static CONFIG_OVERRIDE: RefCell<Option<Box<OverrideFn>>> = RefCell::new(None);
5584}
5585
5586#[must_use]
5587pub struct OverrideGuard;
5588
5589#[cfg(not(msim))]
5590impl Drop for OverrideGuard {
5591 fn drop(&mut self) {
5592 info!("restoring override fn");
5593 *CONFIG_OVERRIDE.lock().unwrap() = None;
5594 }
5595}
5596
5597#[cfg(msim)]
5598impl Drop for OverrideGuard {
5599 fn drop(&mut self) {
5600 info!("restoring override fn");
5601 CONFIG_OVERRIDE.with(|ovr| {
5602 *ovr.borrow_mut() = None;
5603 });
5604 }
5605}
5606
5607#[derive(PartialEq, Eq)]
5610pub enum LimitThresholdCrossed {
5611 None,
5612 Soft(u128, u128),
5613 Hard(u128, u128),
5614}
5615
5616pub fn check_limit_in_range<T: Into<V>, U: Into<V>, V: PartialOrd + Into<u128>>(
5619 x: T,
5620 soft_limit: U,
5621 hard_limit: V,
5622) -> LimitThresholdCrossed {
5623 let x: V = x.into();
5624 let soft_limit: V = soft_limit.into();
5625
5626 debug_assert!(soft_limit <= hard_limit);
5627
5628 if x >= hard_limit {
5631 LimitThresholdCrossed::Hard(x.into(), hard_limit.into())
5632 } else if x < soft_limit {
5633 LimitThresholdCrossed::None
5634 } else {
5635 LimitThresholdCrossed::Soft(x.into(), soft_limit.into())
5636 }
5637}
5638
5639#[macro_export]
5640macro_rules! check_limit {
5641 ($x:expr, $hard:expr) => {
5642 check_limit!($x, $hard, $hard)
5643 };
5644 ($x:expr, $soft:expr, $hard:expr) => {
5645 check_limit_in_range($x as u64, $soft, $hard)
5646 };
5647}
5648
5649#[macro_export]
5653macro_rules! check_limit_by_meter {
5654 ($is_metered:expr, $x:expr, $metered_limit:expr, $unmetered_hard_limit:expr, $metric:expr) => {{
5655 let (h, metered_str) = if $is_metered {
5657 ($metered_limit, "metered")
5658 } else {
5659 ($unmetered_hard_limit, "unmetered")
5661 };
5662 use sui_protocol_config::check_limit_in_range;
5663 let result = check_limit_in_range($x as u64, $metered_limit, h);
5664 match result {
5665 LimitThresholdCrossed::None => {}
5666 LimitThresholdCrossed::Soft(_, _) => {
5667 $metric.with_label_values(&[metered_str, "soft"]).inc();
5668 }
5669 LimitThresholdCrossed::Hard(_, _) => {
5670 $metric.with_label_values(&[metered_str, "hard"]).inc();
5671 }
5672 };
5673 result
5674 }};
5675}
5676
5677pub type Amendments = BTreeMap<AccountAddress, BTreeMap<AccountAddress, AccountAddress>>;
5680
5681static MAINNET_LINKAGE_AMENDMENTS: LazyLock<Arc<Amendments>> =
5682 LazyLock::new(|| parse_amendments(include_str!("mainnet_amendments.json")));
5683
5684static TESTNET_LINKAGE_AMENDMENTS: LazyLock<Arc<Amendments>> =
5685 LazyLock::new(|| parse_amendments(include_str!("testnet_amendments.json")));
5686
5687fn parse_amendments(json: &str) -> Arc<Amendments> {
5688 #[derive(serde::Deserialize)]
5689 struct AmendmentEntry {
5690 root: String,
5691 deps: Vec<DepEntry>,
5692 }
5693
5694 #[derive(serde::Deserialize)]
5695 struct DepEntry {
5696 original_id: String,
5697 version_id: String,
5698 }
5699
5700 let entries: Vec<AmendmentEntry> =
5701 serde_json::from_str(json).expect("Failed to parse amendments JSON");
5702 let mut amendments = BTreeMap::new();
5703 for entry in entries {
5704 let root_id = AccountAddress::from_hex_literal(&entry.root).unwrap();
5705 let mut dep_ids = BTreeMap::new();
5706 for dep in entry.deps {
5707 let orig_id = AccountAddress::from_hex_literal(&dep.original_id).unwrap();
5708 let upgraded_id = AccountAddress::from_hex_literal(&dep.version_id).unwrap();
5709 assert!(
5710 dep_ids.insert(orig_id, upgraded_id).is_none(),
5711 "Duplicate original ID in amendments table"
5712 );
5713 }
5714 assert!(
5715 amendments.insert(root_id, dep_ids).is_none(),
5716 "Duplicate root ID in amendments table"
5717 );
5718 }
5719 Arc::new(amendments)
5720}
5721
5722#[cfg(all(test, not(msim)))]
5723mod test {
5724 use insta::assert_yaml_snapshot;
5725
5726 use super::*;
5727
5728 #[test]
5729 fn snapshot_tests() {
5730 println!("\n============================================================================");
5731 println!("! !");
5732 println!("! IMPORTANT: never update snapshots from this test. only add new versions! !");
5733 println!("! !");
5734 println!("============================================================================\n");
5735 for chain_id in &[Chain::Unknown, Chain::Mainnet, Chain::Testnet] {
5736 let chain_str = match chain_id {
5740 Chain::Unknown => "".to_string(),
5741 _ => format!("{:?}_", chain_id),
5742 };
5743 for i in MIN_PROTOCOL_VERSION..=MAX_PROTOCOL_VERSION {
5744 let cur = ProtocolVersion::new(i);
5745 assert_yaml_snapshot!(
5746 format!("{}version_{}", chain_str, cur.as_u64()),
5747 ProtocolConfig::get_for_version(cur, *chain_id)
5748 );
5749 }
5750 }
5751 }
5752
5753 #[test]
5754 fn test_getters() {
5755 let prot: ProtocolConfig =
5756 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5757 assert_eq!(
5758 prot.max_arguments(),
5759 prot.max_arguments_as_option().unwrap()
5760 );
5761 }
5762
5763 #[test]
5764 fn test_setters() {
5765 let mut prot: ProtocolConfig =
5766 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5767 prot.set_max_arguments_for_testing(123);
5768 assert_eq!(prot.max_arguments(), 123);
5769
5770 prot.set_max_arguments_from_str_for_testing("321".to_string());
5771 assert_eq!(prot.max_arguments(), 321);
5772
5773 prot.disable_max_arguments_for_testing();
5774 assert_eq!(prot.max_arguments_as_option(), None);
5775
5776 prot.set_attr_for_testing("max_arguments".to_string(), "456".to_string());
5777 assert_eq!(prot.max_arguments(), 456);
5778 }
5779
5780 #[test]
5781 fn test_get_for_version_if_supported_applies_test_overrides() {
5782 let before =
5783 ProtocolConfig::get_for_version_if_supported(ProtocolVersion::new(1), Chain::Unknown)
5784 .unwrap();
5785
5786 assert!(!before.enable_coin_reservation_obj_refs());
5787
5788 let _guard = ProtocolConfig::apply_overrides_for_testing(|_, mut cfg| {
5789 cfg.enable_coin_reservation_for_testing();
5790 cfg
5791 });
5792
5793 let after =
5794 ProtocolConfig::get_for_version_if_supported(ProtocolVersion::new(1), Chain::Unknown)
5795 .unwrap();
5796
5797 assert!(after.enable_coin_reservation_obj_refs());
5798 }
5799
5800 #[test]
5801 #[should_panic(expected = "unsupported version")]
5802 fn max_version_test() {
5803 let _ = ProtocolConfig::get_for_version_impl(
5806 ProtocolVersion::new(MAX_PROTOCOL_VERSION + 1),
5807 Chain::Unknown,
5808 );
5809 }
5810
5811 #[test]
5812 fn lookup_by_string_test() {
5813 let prot: ProtocolConfig =
5814 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5815 assert!(prot.lookup_attr("some random string".to_string()).is_none());
5817
5818 assert!(
5819 prot.lookup_attr("max_arguments".to_string())
5820 == Some(ProtocolConfigValue::u32(prot.max_arguments())),
5821 );
5822
5823 assert!(
5825 prot.lookup_attr("max_move_identifier_len".to_string())
5826 .is_none()
5827 );
5828
5829 let prot: ProtocolConfig =
5831 ProtocolConfig::get_for_version(ProtocolVersion::new(9), Chain::Unknown);
5832 assert!(
5833 prot.lookup_attr("max_move_identifier_len".to_string())
5834 == Some(ProtocolConfigValue::u64(prot.max_move_identifier_len()))
5835 );
5836
5837 let prot: ProtocolConfig =
5838 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5839 assert!(
5841 prot.attr_map()
5842 .get("max_move_identifier_len")
5843 .unwrap()
5844 .is_none()
5845 );
5846 assert!(
5848 prot.attr_map().get("max_arguments").unwrap()
5849 == &Some(ProtocolConfigValue::u32(prot.max_arguments()))
5850 );
5851
5852 let prot: ProtocolConfig =
5854 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5855 assert!(
5857 prot.feature_flags
5858 .lookup_attr("some random string".to_owned())
5859 .is_none()
5860 );
5861 assert!(
5862 !prot
5863 .feature_flags
5864 .attr_map()
5865 .contains_key("some random string")
5866 );
5867
5868 assert!(
5870 prot.feature_flags
5871 .lookup_attr("package_upgrades".to_owned())
5872 == Some(false)
5873 );
5874 assert!(
5875 prot.feature_flags
5876 .attr_map()
5877 .get("package_upgrades")
5878 .unwrap()
5879 == &false
5880 );
5881 let prot: ProtocolConfig =
5882 ProtocolConfig::get_for_version(ProtocolVersion::new(4), Chain::Unknown);
5883 assert!(
5885 prot.feature_flags
5886 .lookup_attr("package_upgrades".to_owned())
5887 == Some(true)
5888 );
5889 assert!(
5890 prot.feature_flags
5891 .attr_map()
5892 .get("package_upgrades")
5893 .unwrap()
5894 == &true
5895 );
5896 }
5897
5898 #[test]
5899 fn limit_range_fn_test() {
5900 let low = 100u32;
5901 let high = 10000u64;
5902
5903 assert!(check_limit!(1u8, low, high) == LimitThresholdCrossed::None);
5904 assert!(matches!(
5905 check_limit!(255u16, low, high),
5906 LimitThresholdCrossed::Soft(255u128, 100)
5907 ));
5908 assert!(matches!(
5914 check_limit!(2550000u64, low, high),
5915 LimitThresholdCrossed::Hard(2550000, 10000)
5916 ));
5917
5918 assert!(matches!(
5919 check_limit!(2550000u64, high, high),
5920 LimitThresholdCrossed::Hard(2550000, 10000)
5921 ));
5922
5923 assert!(matches!(
5924 check_limit!(1u8, high),
5925 LimitThresholdCrossed::None
5926 ));
5927
5928 assert!(check_limit!(255u16, high) == LimitThresholdCrossed::None);
5929
5930 assert!(matches!(
5931 check_limit!(2550000u64, high),
5932 LimitThresholdCrossed::Hard(2550000, 10000)
5933 ));
5934 }
5935
5936 #[test]
5937 fn linkage_amendments_load() {
5938 let mainnet = LazyLock::force(&MAINNET_LINKAGE_AMENDMENTS);
5939 let testnet = LazyLock::force(&TESTNET_LINKAGE_AMENDMENTS);
5940 assert!(!mainnet.is_empty(), "mainnet amendments must not be empty");
5941 assert!(!testnet.is_empty(), "testnet amendments must not be empty");
5942 }
5943
5944 #[test]
5945 fn render_scalar_fields_use_precision_safe_encoding() {
5946 use mysten_common::rpc_format::Unmetered;
5947
5948 let config = ProtocolConfig::get_for_max_version_UNSAFE();
5949 let rendered = config
5950 .render::<serde_json::Value>(&mut Unmetered)
5951 .expect("render should succeed");
5952
5953 let max_args = rendered
5954 .get("max_arguments")
5955 .expect("max_arguments set at max version");
5956 assert!(
5957 max_args.is_number(),
5958 "u32 should render as number, got {max_args:?}",
5959 );
5960
5961 let max_tx_size = rendered
5962 .get("max_tx_size_bytes")
5963 .expect("max_tx_size_bytes set at max version");
5964 assert!(
5965 max_tx_size.is_string(),
5966 "u64 should render as string, got {max_tx_size:?}",
5967 );
5968 }
5969
5970 #[test]
5971 fn render_includes_non_scalar_gasless_allowlist_as_json() {
5972 use mysten_common::rpc_format::Unmetered;
5973 use serde_json::json;
5974
5975 let mut config = ProtocolConfig::get_for_max_version_UNSAFE();
5976 config.set_gasless_allowed_token_types_for_testing(vec![
5977 ("0xa::usdc::USDC".to_string(), 10_000),
5978 ("0xb::usdt::USDT".to_string(), 0),
5979 ]);
5980
5981 let rendered = config
5982 .render::<serde_json::Value>(&mut Unmetered)
5983 .expect("render should succeed under Unmetered budget");
5984 let allowlist = rendered
5985 .get("gasless_allowed_token_types")
5986 .expect("entry should be present after the testing setter");
5987
5988 assert_eq!(
5991 allowlist,
5992 &json!([["0xa::usdc::USDC", "10000"], ["0xb::usdt::USDT", "0"],]),
5993 );
5994 }
5995
5996 #[test]
5997 fn render_targets_prost_value_for_grpc() {
5998 use mysten_common::rpc_format::Unmetered;
5999 use prost_types::value::Kind;
6000
6001 let mut config = ProtocolConfig::get_for_max_version_UNSAFE();
6002 config.set_gasless_allowed_token_types_for_testing(vec![(
6003 "0xa::usdc::USDC".to_string(),
6004 10_000,
6005 )]);
6006
6007 let rendered = config
6008 .render::<prost_types::Value>(&mut Unmetered)
6009 .expect("render to prost Value should succeed");
6010 let allowlist = rendered
6011 .get("gasless_allowed_token_types")
6012 .expect("entry should be present after the testing setter");
6013
6014 let Some(Kind::ListValue(outer)) = &allowlist.kind else {
6016 panic!(
6017 "expected ListValue at the top level, got {:?}",
6018 allowlist.kind
6019 );
6020 };
6021 assert_eq!(outer.values.len(), 1, "one allowlisted entry");
6022 let Some(Kind::ListValue(entry)) = &outer.values[0].kind else {
6023 panic!("expected each entry to be a ListValue");
6024 };
6025 assert_eq!(entry.values.len(), 2, "entry has (coin_type, amount)");
6026
6027 let Some(Kind::StringValue(coin_type)) = &entry.values[0].kind else {
6028 panic!("expected coin_type as StringValue");
6029 };
6030 assert_eq!(coin_type, "0xa::usdc::USDC");
6031
6032 let Some(Kind::StringValue(amount)) = &entry.values[1].kind else {
6034 panic!(
6035 "expected minimum_transfer_amount as StringValue (precision-safe u64); got {:?}",
6036 entry.values[1].kind,
6037 );
6038 };
6039 assert_eq!(amount, "10000");
6040 }
6041
6042 #[test]
6043 fn render_emits_null_for_unset_protocol_versions() {
6044 use mysten_common::rpc_format::Unmetered;
6045
6046 let config = ProtocolConfig::get_for_version(1.into(), Chain::Unknown);
6047 let rendered = config
6048 .render::<serde_json::Value>(&mut Unmetered)
6049 .expect("render should succeed");
6050 let entry = rendered
6054 .get("gasless_allowed_token_types")
6055 .expect("key should be present for every protocol version");
6056 assert!(
6057 entry.is_null(),
6058 "value should be null for pre-feature protocol version, got {entry:?}",
6059 );
6060 }
6061}