1use std::{
5 collections::{BTreeMap, BTreeSet},
6 sync::{
7 Arc, LazyLock,
8 atomic::{AtomicBool, Ordering},
9 },
10};
11
12#[cfg(msim)]
13use std::cell::RefCell;
14#[cfg(not(msim))]
15use std::sync::Mutex;
16
17use clap::*;
18use fastcrypto::encoding::{Base58, Encoding, Hex};
19use move_binary_format::{
20 binary_config::{BinaryConfig, TableConfig},
21 file_format_common::VERSION_1,
22};
23use move_core_types::account_address::AccountAddress;
24use move_vm_config::verifier::VerifierConfig;
25use mysten_common::in_integration_test;
26use serde::{Deserialize, Serialize};
27use serde_with::skip_serializing_none;
28use sui_protocol_config_macros::{
29 ProtocolConfigAccessors, ProtocolConfigFeatureFlagsGetters, ProtocolConfigOverride,
30};
31use tracing::{info, warn};
32
33const MIN_PROTOCOL_VERSION: u64 = 1;
35const MAX_PROTOCOL_VERSION: u64 = 130;
36
37const TESTNET_USDC: &str =
38 "0xa1ec7fc00a6f40db9693ad1415d0c193ad3906494428cf252621037bd7117e29::usdc::USDC";
39
40const MAINNET_USDC: &str =
41 "0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC";
42const MAINNET_USDSUI: &str =
43 "0x44f838219cf67b058f3b37907b655f226153c18e33dfcd0da559a844fea9b1c1::usdsui::USDSUI";
44const MAINNET_SUI_USDE: &str =
45 "0x41d587e5336f1c86cad50d38a7136db99333bb9bda91cea4ba69115defeb1402::sui_usde::SUI_USDE";
46const MAINNET_USDY: &str =
47 "0x960b531667636f39e85867775f52f6b1f220a058c4de786905bdf761e06a56bb::usdy::USDY";
48const MAINNET_FDUSD: &str =
49 "0xf16e6b723f242ec745dfd7634ad072c42d5c1d9ac9d62a39c381303eaa57693a::fdusd::FDUSD";
50const MAINNET_AUSD: &str =
51 "0x2053d08c1e2bd02791056171aab0fd12bd7cd7efad2ab8f6b9c8902f14df2ff2::ausd::AUSD";
52const MAINNET_USDB: &str =
53 "0xe14726c336e81b32328e92afc37345d159f5b550b09fa92bd43640cfdd0a0cfd::usdb::USDB";
54
55#[derive(Copy, Clone, Debug, Hash, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)]
370pub struct ProtocolVersion(u64);
371
372impl ProtocolVersion {
373 pub const MIN: Self = Self(MIN_PROTOCOL_VERSION);
378
379 pub const MAX: Self = Self(MAX_PROTOCOL_VERSION);
380
381 #[cfg(not(msim))]
382 pub const MAX_ALLOWED: Self = Self::MAX;
383
384 #[cfg(msim)]
386 pub const MAX_ALLOWED: Self = Self(MAX_PROTOCOL_VERSION + 1);
387
388 pub fn new(v: u64) -> Self {
389 Self(v)
390 }
391
392 pub const fn as_u64(&self) -> u64 {
393 self.0
394 }
395
396 pub fn max() -> Self {
399 Self::MAX
400 }
401
402 pub fn prev(self) -> Self {
403 Self(self.0.checked_sub(1).unwrap())
404 }
405}
406
407impl From<u64> for ProtocolVersion {
408 fn from(v: u64) -> Self {
409 Self::new(v)
410 }
411}
412
413impl std::ops::Sub<u64> for ProtocolVersion {
414 type Output = Self;
415 fn sub(self, rhs: u64) -> Self::Output {
416 Self::new(self.0 - rhs)
417 }
418}
419
420impl std::ops::Add<u64> for ProtocolVersion {
421 type Output = Self;
422 fn add(self, rhs: u64) -> Self::Output {
423 Self::new(self.0 + rhs)
424 }
425}
426
427#[derive(
428 Clone, Serialize, Deserialize, Debug, Default, PartialEq, Copy, PartialOrd, Ord, Eq, ValueEnum,
429)]
430pub enum Chain {
431 Mainnet,
432 Testnet,
433 #[default]
434 Unknown,
435}
436
437impl Chain {
438 pub fn as_str(self) -> &'static str {
439 match self {
440 Chain::Mainnet => "mainnet",
441 Chain::Testnet => "testnet",
442 Chain::Unknown => "unknown",
443 }
444 }
445}
446
447pub struct Error(pub String);
448
449#[derive(Default, Clone, Serialize, Deserialize, Debug, ProtocolConfigFeatureFlagsGetters)]
452struct FeatureFlags {
453 #[serde(skip_serializing_if = "is_false")]
456 package_upgrades: bool,
457 #[serde(skip_serializing_if = "is_false")]
460 commit_root_state_digest: bool,
461 #[serde(skip_serializing_if = "is_false")]
463 advance_epoch_start_time_in_safe_mode: bool,
464 #[serde(skip_serializing_if = "is_false")]
467 loaded_child_objects_fixed: bool,
468 #[serde(skip_serializing_if = "is_false")]
471 missing_type_is_compatibility_error: bool,
472 #[serde(skip_serializing_if = "is_false")]
475 scoring_decision_with_validity_cutoff: bool,
476
477 #[serde(skip_serializing_if = "is_false")]
480 consensus_order_end_of_epoch_last: bool,
481
482 #[serde(skip_serializing_if = "is_false")]
484 disallow_adding_abilities_on_upgrade: bool,
485 #[serde(skip_serializing_if = "is_false")]
487 disable_invariant_violation_check_in_swap_loc: bool,
488 #[serde(skip_serializing_if = "is_false")]
491 advance_to_highest_supported_protocol_version: bool,
492 #[serde(skip_serializing_if = "is_false")]
494 ban_entry_init: bool,
495 #[serde(skip_serializing_if = "is_false")]
497 package_digest_hash_module: bool,
498 #[serde(skip_serializing_if = "is_false")]
500 disallow_change_struct_type_params_on_upgrade: bool,
501 #[serde(skip_serializing_if = "is_false")]
503 no_extraneous_module_bytes: bool,
504 #[serde(skip_serializing_if = "is_false")]
506 narwhal_versioned_metadata: bool,
507
508 #[serde(skip_serializing_if = "is_false")]
510 zklogin_auth: bool,
511 #[serde(skip_serializing_if = "ConsensusTransactionOrdering::is_none")]
513 consensus_transaction_ordering: ConsensusTransactionOrdering,
514
515 #[serde(skip_serializing_if = "is_false")]
523 simplified_unwrap_then_delete: bool,
524 #[serde(skip_serializing_if = "is_false")]
526 upgraded_multisig_supported: bool,
527 #[serde(skip_serializing_if = "is_false")]
529 txn_base_cost_as_multiplier: bool,
530
531 #[serde(skip_serializing_if = "is_false")]
533 shared_object_deletion: bool,
534
535 #[serde(skip_serializing_if = "is_false")]
537 narwhal_new_leader_election_schedule: bool,
538
539 #[serde(skip_serializing_if = "is_empty")]
541 zklogin_supported_providers: BTreeSet<String>,
542
543 #[serde(skip_serializing_if = "is_false")]
545 loaded_child_object_format: bool,
546
547 #[serde(skip_serializing_if = "is_false")]
548 #[skip_protocol_config_accessor]
549 enable_jwk_consensus_updates: bool,
550
551 #[serde(skip_serializing_if = "is_false")]
552 #[skip_protocol_config_accessor]
553 end_of_epoch_transaction_supported: bool,
554
555 #[serde(skip_serializing_if = "is_false")]
558 simple_conservation_checks: bool,
559
560 #[serde(skip_serializing_if = "is_false")]
562 loaded_child_object_format_type: bool,
563
564 #[serde(skip_serializing_if = "is_false")]
566 receive_objects: bool,
567
568 #[serde(skip_serializing_if = "is_false")]
570 consensus_checkpoint_signature_key_includes_digest: bool,
571
572 #[serde(skip_serializing_if = "is_false")]
574 random_beacon: bool,
575
576 #[serde(skip_serializing_if = "is_false")]
578 #[skip_protocol_config_accessor]
579 bridge: bool,
580
581 #[serde(skip_serializing_if = "is_false")]
582 enable_effects_v2: bool,
583
584 #[serde(skip_serializing_if = "is_false")]
586 narwhal_certificate_v2: bool,
587
588 #[serde(skip_serializing_if = "is_false")]
590 verify_legacy_zklogin_address: bool,
591
592 #[serde(skip_serializing_if = "is_false")]
594 throughput_aware_consensus_submission: bool,
595
596 #[serde(skip_serializing_if = "is_false")]
598 recompute_has_public_transfer_in_execution: bool,
599
600 #[serde(skip_serializing_if = "is_false")]
602 accept_zklogin_in_multisig: bool,
603
604 #[serde(skip_serializing_if = "is_false")]
606 accept_passkey_in_multisig: bool,
607
608 #[serde(skip_serializing_if = "is_false")]
610 validate_zklogin_public_identifier: bool,
611
612 #[serde(skip_serializing_if = "is_false")]
615 include_consensus_digest_in_prologue: bool,
616
617 #[serde(skip_serializing_if = "is_false")]
619 hardened_otw_check: bool,
620
621 #[serde(skip_serializing_if = "is_false")]
623 allow_receiving_object_id: bool,
624
625 #[serde(skip_serializing_if = "is_false")]
627 enable_poseidon: bool,
628
629 #[serde(skip_serializing_if = "is_false")]
631 enable_coin_deny_list: bool,
632
633 #[serde(skip_serializing_if = "is_false")]
635 enable_group_ops_native_functions: bool,
636
637 #[serde(skip_serializing_if = "is_false")]
639 enable_group_ops_native_function_msm: bool,
640
641 #[serde(skip_serializing_if = "is_false")]
643 enable_ristretto255_group_ops: bool,
644
645 #[serde(skip_serializing_if = "is_false")]
647 enable_verify_bulletproofs_ristretto255: bool,
648
649 #[serde(skip_serializing_if = "is_false")]
651 enable_nitro_attestation: bool,
652
653 #[serde(skip_serializing_if = "is_false")]
655 enable_nitro_attestation_upgraded_parsing: bool,
656
657 #[serde(skip_serializing_if = "is_false")]
659 enable_nitro_attestation_all_nonzero_pcrs_parsing: bool,
660
661 #[serde(skip_serializing_if = "is_false")]
663 enable_nitro_attestation_always_include_required_pcrs_parsing: bool,
664
665 #[serde(skip_serializing_if = "is_false")]
667 reject_mutable_random_on_entry_functions: bool,
668
669 #[serde(skip_serializing_if = "PerObjectCongestionControlMode::is_none")]
671 per_object_congestion_control_mode: PerObjectCongestionControlMode,
672
673 #[serde(skip_serializing_if = "ConsensusChoice::is_narwhal")]
675 consensus_choice: ConsensusChoice,
676
677 #[serde(skip_serializing_if = "ConsensusNetwork::is_anemo")]
679 consensus_network: ConsensusNetwork,
680
681 #[serde(skip_serializing_if = "is_false")]
683 correct_gas_payment_limit_check: bool,
684
685 #[serde(skip_serializing_if = "Option::is_none")]
687 zklogin_max_epoch_upper_bound_delta: Option<u64>,
688
689 #[serde(skip_serializing_if = "is_false")]
691 mysticeti_leader_scoring_and_schedule: bool,
692
693 #[serde(skip_serializing_if = "is_false")]
695 reshare_at_same_initial_version: bool,
696
697 #[serde(skip_serializing_if = "is_false")]
699 resolve_abort_locations_to_package_id: bool,
700
701 #[serde(skip_serializing_if = "is_false")]
705 mysticeti_use_committed_subdag_digest: bool,
706
707 #[serde(skip_serializing_if = "is_false")]
709 enable_vdf: bool,
710
711 #[serde(skip_serializing_if = "is_false")]
716 record_consensus_determined_version_assignments_in_prologue: bool,
717 #[serde(skip_serializing_if = "is_false")]
718 record_consensus_determined_version_assignments_in_prologue_v2: bool,
719
720 #[serde(skip_serializing_if = "is_false")]
722 fresh_vm_on_framework_upgrade: bool,
723
724 #[serde(skip_serializing_if = "is_false")]
732 prepend_prologue_tx_in_consensus_commit_in_checkpoints: bool,
733
734 #[serde(skip_serializing_if = "Option::is_none")]
736 mysticeti_num_leaders_per_round: Option<usize>,
737
738 #[serde(skip_serializing_if = "is_false")]
740 soft_bundle: bool,
741
742 #[serde(skip_serializing_if = "is_false")]
744 enable_coin_deny_list_v2: bool,
745
746 #[serde(skip_serializing_if = "is_false")]
748 passkey_auth: bool,
749
750 #[serde(skip_serializing_if = "is_false")]
752 authority_capabilities_v2: bool,
753
754 #[serde(skip_serializing_if = "is_false")]
756 rethrow_serialization_type_layout_errors: bool,
757
758 #[serde(skip_serializing_if = "is_false")]
760 consensus_distributed_vote_scoring_strategy: bool,
761
762 #[serde(skip_serializing_if = "is_false")]
764 consensus_round_prober: bool,
765
766 #[serde(skip_serializing_if = "is_false")]
768 validate_identifier_inputs: bool,
769
770 #[serde(skip_serializing_if = "is_false")]
772 disallow_self_identifier: bool,
773
774 #[serde(skip_serializing_if = "is_false")]
776 mysticeti_fastpath: bool,
777
778 #[serde(skip_serializing_if = "is_false")]
782 disable_preconsensus_locking: bool,
783
784 #[serde(skip_serializing_if = "is_false")]
786 relocate_event_module: bool,
787
788 #[serde(skip_serializing_if = "is_false")]
790 uncompressed_g1_group_elements: bool,
791
792 #[serde(skip_serializing_if = "is_false")]
793 disallow_new_modules_in_deps_only_packages: bool,
794
795 #[serde(skip_serializing_if = "is_false")]
797 consensus_smart_ancestor_selection: bool,
798
799 #[serde(skip_serializing_if = "is_false")]
801 consensus_round_prober_probe_accepted_rounds: bool,
802
803 #[serde(skip_serializing_if = "is_false")]
805 native_charging_v2: bool,
806
807 #[serde(skip_serializing_if = "is_false")]
810 #[skip_protocol_config_accessor]
811 consensus_linearize_subdag_v2: bool,
812
813 #[serde(skip_serializing_if = "is_false")]
815 convert_type_argument_error: bool,
816
817 #[serde(skip_serializing_if = "is_false")]
819 variant_nodes: bool,
820
821 #[serde(skip_serializing_if = "is_false")]
823 consensus_zstd_compression: bool,
824
825 #[serde(skip_serializing_if = "is_false")]
827 minimize_child_object_mutations: bool,
828
829 #[serde(skip_serializing_if = "is_false")]
831 record_additional_state_digest_in_prologue: bool,
832
833 #[serde(skip_serializing_if = "is_false")]
835 move_native_context: bool,
836
837 #[serde(skip_serializing_if = "is_false")]
840 #[skip_protocol_config_accessor]
841 consensus_median_based_commit_timestamp: bool,
842
843 #[serde(skip_serializing_if = "is_false")]
846 normalize_ptb_arguments: bool,
847
848 #[serde(skip_serializing_if = "is_false")]
850 consensus_batched_block_sync: bool,
851
852 #[serde(skip_serializing_if = "is_false")]
854 enforce_checkpoint_timestamp_monotonicity: bool,
855
856 #[serde(skip_serializing_if = "is_false")]
858 max_ptb_value_size_v2: bool,
859
860 #[serde(skip_serializing_if = "is_false")]
862 resolve_type_input_ids_to_defining_id: bool,
863
864 #[serde(skip_serializing_if = "is_false")]
866 enable_party_transfer: bool,
867
868 #[serde(skip_serializing_if = "is_false")]
870 allow_unbounded_system_objects: bool,
871
872 #[serde(skip_serializing_if = "is_false")]
874 type_tags_in_object_runtime: bool,
875
876 #[serde(skip_serializing_if = "is_false")]
878 enable_accumulators: bool,
879
880 #[serde(skip_serializing_if = "is_false")]
882 #[skip_protocol_config_accessor]
883 enable_coin_reservation_obj_refs: bool,
884
885 #[serde(skip_serializing_if = "is_false")]
888 create_root_accumulator_object: bool,
889
890 #[serde(skip_serializing_if = "is_false")]
892 #[skip_protocol_config_accessor]
893 enable_authenticated_event_streams: bool,
894
895 #[serde(skip_serializing_if = "is_false")]
897 enable_address_balance_gas_payments: bool,
898
899 #[serde(skip_serializing_if = "is_false")]
901 address_balance_gas_check_rgp_at_signing: bool,
902
903 #[serde(skip_serializing_if = "is_false")]
904 address_balance_gas_reject_gas_coin_arg: bool,
905
906 #[serde(skip_serializing_if = "is_false")]
908 enable_multi_epoch_transaction_expiration: bool,
909
910 #[serde(skip_serializing_if = "is_false")]
912 relax_valid_during_for_owned_inputs: bool,
913
914 #[serde(skip_serializing_if = "is_false")]
916 enable_ptb_execution_v2: bool,
917
918 #[serde(skip_serializing_if = "is_false")]
920 better_adapter_type_resolution_errors: bool,
921
922 #[serde(skip_serializing_if = "is_false")]
924 record_time_estimate_processed: bool,
925
926 #[serde(skip_serializing_if = "is_false")]
928 dependency_linkage_error: bool,
929
930 #[serde(skip_serializing_if = "is_false")]
932 additional_multisig_checks: bool,
933
934 #[serde(skip_serializing_if = "is_false")]
936 ignore_execution_time_observations_after_certs_closed: bool,
937
938 #[serde(skip_serializing_if = "is_false")]
942 debug_fatal_on_move_invariant_violation: bool,
943
944 #[serde(skip_serializing_if = "is_false")]
947 allow_private_accumulator_entrypoints: bool,
948
949 #[serde(skip_serializing_if = "is_false")]
951 additional_consensus_digest_indirect_state: bool,
952
953 #[serde(skip_serializing_if = "is_false")]
955 check_for_init_during_upgrade: bool,
956
957 #[serde(skip_serializing_if = "is_false")]
959 enable_init_on_upgrade: bool,
960
961 #[serde(skip_serializing_if = "is_false")]
963 per_command_shared_object_transfer_rules: bool,
964
965 #[serde(skip_serializing_if = "is_false")]
967 include_checkpoint_artifacts_digest_in_summary: bool,
968
969 #[serde(skip_serializing_if = "is_false")]
971 use_mfp_txns_in_load_initial_object_debts: bool,
972
973 #[serde(skip_serializing_if = "is_false")]
975 cancel_for_failed_dkg_early: bool,
976
977 #[serde(skip_serializing_if = "is_false")]
979 always_advance_dkg_to_resolution: bool,
980
981 #[serde(skip_serializing_if = "is_false")]
983 enable_coin_registry: bool,
984
985 #[serde(skip_serializing_if = "is_false")]
987 abstract_size_in_object_runtime: bool,
988
989 #[serde(skip_serializing_if = "is_false")]
991 object_runtime_charge_cache_load_gas: bool,
992
993 #[serde(skip_serializing_if = "is_false")]
995 additional_borrow_checks: bool,
996
997 #[serde(skip_serializing_if = "is_false")]
999 use_new_commit_handler: bool,
1000
1001 #[serde(skip_serializing_if = "is_false")]
1003 better_loader_errors: bool,
1004
1005 #[serde(skip_serializing_if = "is_false")]
1007 generate_df_type_layouts: bool,
1008
1009 #[serde(skip_serializing_if = "is_false")]
1011 allow_references_in_ptbs: bool,
1012
1013 #[serde(skip_serializing_if = "is_false")]
1015 enable_display_registry: bool,
1016
1017 #[serde(skip_serializing_if = "is_false")]
1019 private_generics_verifier_v2: bool,
1020
1021 #[serde(skip_serializing_if = "is_false")]
1023 deprecate_global_storage_ops_during_deserialization: bool,
1024
1025 #[serde(skip_serializing_if = "is_false")]
1028 enable_non_exclusive_writes: bool,
1029
1030 #[serde(skip_serializing_if = "is_false")]
1032 deprecate_global_storage_ops: bool,
1033
1034 #[serde(skip_serializing_if = "is_false")]
1036 normalize_depth_formula: bool,
1037
1038 #[serde(skip_serializing_if = "is_false")]
1040 consensus_skip_gced_accept_votes: bool,
1041
1042 #[serde(skip_serializing_if = "is_false")]
1044 include_cancelled_randomness_txns_in_prologue: bool,
1045
1046 #[serde(skip_serializing_if = "is_false")]
1048 #[skip_protocol_config_accessor]
1049 address_aliases: bool,
1050
1051 #[serde(skip_serializing_if = "is_false")]
1054 fix_checkpoint_signature_mapping: bool,
1055
1056 #[serde(skip_serializing_if = "is_false")]
1058 enable_object_funds_withdraw: bool,
1059
1060 #[serde(skip_serializing_if = "is_false")]
1063 record_net_unsettled_object_withdraws: bool,
1064
1065 #[serde(skip_serializing_if = "is_false")]
1067 consensus_skip_gced_blocks_in_direct_finalization: bool,
1068
1069 #[serde(skip_serializing_if = "is_false")]
1071 gas_rounding_halve_digits: bool,
1072
1073 #[serde(skip_serializing_if = "is_false")]
1075 flexible_tx_context_positions: bool,
1076
1077 #[serde(skip_serializing_if = "is_false")]
1079 disable_entry_point_signature_check: bool,
1080
1081 #[serde(skip_serializing_if = "is_false")]
1083 convert_withdrawal_compatibility_ptb_arguments: bool,
1084
1085 #[serde(skip_serializing_if = "is_false")]
1087 restrict_hot_or_not_entry_functions: bool,
1088
1089 #[serde(skip_serializing_if = "is_false")]
1091 split_checkpoints_in_consensus_handler: bool,
1092
1093 #[serde(skip_serializing_if = "is_false")]
1095 consensus_always_accept_system_transactions: bool,
1096
1097 #[serde(skip_serializing_if = "is_false")]
1099 validator_metadata_verify_v2: bool,
1100
1101 #[serde(skip_serializing_if = "is_false")]
1104 defer_unpaid_amplification: bool,
1105
1106 #[serde(skip_serializing_if = "is_false")]
1107 randomize_checkpoint_tx_limit_in_tests: bool,
1108
1109 #[serde(skip_serializing_if = "is_false")]
1111 gasless_transaction_drop_safety: bool,
1112
1113 #[serde(skip_serializing_if = "is_false")]
1115 merge_randomness_into_checkpoint: bool,
1116
1117 #[serde(skip_serializing_if = "is_false")]
1119 use_coin_party_owner: bool,
1120
1121 #[serde(skip_serializing_if = "is_false")]
1122 enable_gasless: bool,
1123
1124 #[serde(skip_serializing_if = "is_false")]
1125 gasless_verify_remaining_balance: bool,
1126
1127 #[serde(skip_serializing_if = "is_false")]
1128 disallow_jump_orphans: bool,
1129
1130 #[serde(skip_serializing_if = "is_false")]
1132 early_return_receive_object_mismatched_type: bool,
1133
1134 #[serde(skip_serializing_if = "is_false")]
1139 timestamp_based_epoch_close: bool,
1140
1141 #[serde(skip_serializing_if = "is_false")]
1144 limit_groth16_pvk_inputs: bool,
1145
1146 #[serde(skip_serializing_if = "is_false")]
1151 enforce_address_balance_change_invariant: bool,
1152
1153 #[serde(skip_serializing_if = "is_false")]
1155 granular_post_execution_checks: bool,
1156
1157 #[serde(skip_serializing_if = "is_false")]
1159 early_exit_on_iffw: bool,
1160
1161 #[serde(skip_serializing_if = "is_false")]
1163 enable_unified_linkage: bool,
1164}
1165
1166fn is_false(b: &bool) -> bool {
1167 !b
1168}
1169
1170fn is_empty(b: &BTreeSet<String>) -> bool {
1171 b.is_empty()
1172}
1173
1174fn is_zero(val: &u64) -> bool {
1175 *val == 0
1176}
1177
1178#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1180pub enum ConsensusTransactionOrdering {
1181 #[default]
1183 None,
1184 ByGasPrice,
1186}
1187
1188impl ConsensusTransactionOrdering {
1189 pub fn is_none(&self) -> bool {
1190 matches!(self, ConsensusTransactionOrdering::None)
1191 }
1192}
1193
1194#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1195pub struct ExecutionTimeEstimateParams {
1196 pub target_utilization: u64,
1198 pub allowed_txn_cost_overage_burst_limit_us: u64,
1202
1203 pub randomness_scalar: u64,
1206
1207 pub max_estimate_us: u64,
1209
1210 pub stored_observations_num_included_checkpoints: u64,
1213
1214 pub stored_observations_limit: u64,
1216
1217 #[serde(skip_serializing_if = "is_zero")]
1220 pub stake_weighted_median_threshold: u64,
1221
1222 #[serde(skip_serializing_if = "is_false")]
1226 pub default_none_duration_for_new_keys: bool,
1227
1228 #[serde(skip_serializing_if = "Option::is_none")]
1230 pub observations_chunk_size: Option<u64>,
1231}
1232
1233#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1235pub enum PerObjectCongestionControlMode {
1236 #[default]
1237 None, TotalGasBudget, TotalTxCount, TotalGasBudgetWithCap, ExecutionTimeEstimate(ExecutionTimeEstimateParams), }
1243
1244impl PerObjectCongestionControlMode {
1245 pub fn is_none(&self) -> bool {
1246 matches!(self, PerObjectCongestionControlMode::None)
1247 }
1248}
1249
1250#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1252pub enum ConsensusChoice {
1253 #[default]
1254 Narwhal,
1255 SwapEachEpoch,
1256 Mysticeti,
1257}
1258
1259impl ConsensusChoice {
1260 pub fn is_narwhal(&self) -> bool {
1261 matches!(self, ConsensusChoice::Narwhal)
1262 }
1263}
1264
1265#[derive(Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
1267pub enum ConsensusNetwork {
1268 #[default]
1269 Anemo,
1270 Tonic,
1271}
1272
1273impl ConsensusNetwork {
1274 pub fn is_anemo(&self) -> bool {
1275 matches!(self, ConsensusNetwork::Anemo)
1276 }
1277}
1278
1279#[skip_serializing_none]
1311#[derive(Clone, Serialize, Debug, ProtocolConfigAccessors, ProtocolConfigOverride)]
1312pub struct ProtocolConfig {
1313 pub version: ProtocolVersion,
1314
1315 #[serde(skip)]
1320 chain: Chain,
1321
1322 feature_flags: FeatureFlags,
1323
1324 max_tx_size_bytes: Option<u64>,
1327
1328 max_input_objects: Option<u64>,
1330
1331 max_size_written_objects: Option<u64>,
1335 max_size_written_objects_system_tx: Option<u64>,
1338
1339 max_serialized_tx_effects_size_bytes: Option<u64>,
1341
1342 max_serialized_tx_effects_size_bytes_system_tx: Option<u64>,
1344
1345 max_gas_payment_objects: Option<u32>,
1347
1348 max_modules_in_publish: Option<u32>,
1350
1351 max_package_dependencies: Option<u32>,
1353
1354 max_arguments: Option<u32>,
1357
1358 max_type_arguments: Option<u32>,
1360
1361 max_type_argument_depth: Option<u32>,
1363
1364 max_pure_argument_size: Option<u32>,
1366
1367 max_programmable_tx_commands: Option<u32>,
1369
1370 move_binary_format_version: Option<u32>,
1373 min_move_binary_format_version: Option<u32>,
1374
1375 binary_module_handles: Option<u16>,
1377 binary_struct_handles: Option<u16>,
1378 binary_function_handles: Option<u16>,
1379 binary_function_instantiations: Option<u16>,
1380 binary_signatures: Option<u16>,
1381 binary_constant_pool: Option<u16>,
1382 binary_identifiers: Option<u16>,
1383 binary_address_identifiers: Option<u16>,
1384 binary_struct_defs: Option<u16>,
1385 binary_struct_def_instantiations: Option<u16>,
1386 binary_function_defs: Option<u16>,
1387 binary_field_handles: Option<u16>,
1388 binary_field_instantiations: Option<u16>,
1389 binary_friend_decls: Option<u16>,
1390 binary_enum_defs: Option<u16>,
1391 binary_enum_def_instantiations: Option<u16>,
1392 binary_variant_handles: Option<u16>,
1393 binary_variant_instantiation_handles: Option<u16>,
1394
1395 max_move_object_size: Option<u64>,
1397
1398 max_move_package_size: Option<u64>,
1401
1402 max_publish_or_upgrade_per_ptb: Option<u64>,
1404
1405 max_tx_gas: Option<u64>,
1407
1408 max_gas_price: Option<u64>,
1410
1411 max_gas_price_rgp_factor_for_aborted_transactions: Option<u64>,
1414
1415 max_gas_computation_bucket: Option<u64>,
1417
1418 gas_rounding_step: Option<u64>,
1420
1421 max_loop_depth: Option<u64>,
1423
1424 max_generic_instantiation_length: Option<u64>,
1426
1427 max_function_parameters: Option<u64>,
1429
1430 max_basic_blocks: Option<u64>,
1432
1433 max_value_stack_size: Option<u64>,
1435
1436 max_type_nodes: Option<u64>,
1438
1439 max_generic_instantiation_type_nodes_per_function: Option<u64>,
1441
1442 max_generic_instantiation_type_nodes_per_module: Option<u64>,
1444
1445 max_push_size: Option<u64>,
1447
1448 max_struct_definitions: Option<u64>,
1450
1451 max_function_definitions: Option<u64>,
1453
1454 max_fields_in_struct: Option<u64>,
1456
1457 max_dependency_depth: Option<u64>,
1459
1460 max_num_event_emit: Option<u64>,
1462
1463 max_num_new_move_object_ids: Option<u64>,
1465
1466 max_num_new_move_object_ids_system_tx: Option<u64>,
1468
1469 max_num_deleted_move_object_ids: Option<u64>,
1471
1472 max_num_deleted_move_object_ids_system_tx: Option<u64>,
1474
1475 max_num_transferred_move_object_ids: Option<u64>,
1477
1478 max_num_transferred_move_object_ids_system_tx: Option<u64>,
1480
1481 max_event_emit_size: Option<u64>,
1483
1484 max_event_emit_size_total: Option<u64>,
1486
1487 max_move_vector_len: Option<u64>,
1489
1490 max_move_identifier_len: Option<u64>,
1492
1493 max_move_value_depth: Option<u64>,
1495
1496 max_move_enum_variants: Option<u64>,
1498
1499 max_back_edges_per_function: Option<u64>,
1501
1502 max_back_edges_per_module: Option<u64>,
1504
1505 max_verifier_meter_ticks_per_function: Option<u64>,
1507
1508 max_meter_ticks_per_module: Option<u64>,
1510
1511 max_meter_ticks_per_package: Option<u64>,
1513
1514 object_runtime_max_num_cached_objects: Option<u64>,
1518
1519 object_runtime_max_num_cached_objects_system_tx: Option<u64>,
1521
1522 object_runtime_max_num_store_entries: Option<u64>,
1524
1525 object_runtime_max_num_store_entries_system_tx: Option<u64>,
1527
1528 base_tx_cost_fixed: Option<u64>,
1531
1532 package_publish_cost_fixed: Option<u64>,
1535
1536 base_tx_cost_per_byte: Option<u64>,
1539
1540 package_publish_cost_per_byte: Option<u64>,
1542
1543 obj_access_cost_read_per_byte: Option<u64>,
1545
1546 obj_access_cost_mutate_per_byte: Option<u64>,
1548
1549 obj_access_cost_delete_per_byte: Option<u64>,
1551
1552 obj_access_cost_verify_per_byte: Option<u64>,
1562
1563 max_type_to_layout_nodes: Option<u64>,
1565
1566 max_ptb_value_size: Option<u64>,
1568
1569 gas_model_version: Option<u64>,
1572
1573 obj_data_cost_refundable: Option<u64>,
1576
1577 obj_metadata_cost_non_refundable: Option<u64>,
1581
1582 storage_rebate_rate: Option<u64>,
1588
1589 storage_fund_reinvest_rate: Option<u64>,
1592
1593 reward_slashing_rate: Option<u64>,
1596
1597 storage_gas_price: Option<u64>,
1599
1600 accumulator_object_storage_cost: Option<u64>,
1602
1603 max_transactions_per_checkpoint: Option<u64>,
1608
1609 max_checkpoint_size_bytes: Option<u64>,
1613
1614 buffer_stake_for_protocol_upgrade_bps: Option<u64>,
1619
1620 address_from_bytes_cost_base: Option<u64>,
1625 address_to_u256_cost_base: Option<u64>,
1627 address_from_u256_cost_base: Option<u64>,
1629
1630 config_read_setting_impl_cost_base: Option<u64>,
1635 config_read_setting_impl_cost_per_byte: Option<u64>,
1636
1637 dynamic_field_hash_type_and_key_cost_base: Option<u64>,
1640 dynamic_field_hash_type_and_key_type_cost_per_byte: Option<u64>,
1641 dynamic_field_hash_type_and_key_value_cost_per_byte: Option<u64>,
1642 dynamic_field_hash_type_and_key_type_tag_cost_per_byte: Option<u64>,
1643 dynamic_field_add_child_object_cost_base: Option<u64>,
1645 dynamic_field_add_child_object_type_cost_per_byte: Option<u64>,
1646 dynamic_field_add_child_object_value_cost_per_byte: Option<u64>,
1647 dynamic_field_add_child_object_struct_tag_cost_per_byte: Option<u64>,
1648 dynamic_field_borrow_child_object_cost_base: Option<u64>,
1650 dynamic_field_borrow_child_object_child_ref_cost_per_byte: Option<u64>,
1651 dynamic_field_borrow_child_object_type_cost_per_byte: Option<u64>,
1652 dynamic_field_remove_child_object_cost_base: Option<u64>,
1654 dynamic_field_remove_child_object_child_cost_per_byte: Option<u64>,
1655 dynamic_field_remove_child_object_type_cost_per_byte: Option<u64>,
1656 dynamic_field_has_child_object_cost_base: Option<u64>,
1658 dynamic_field_has_child_object_with_ty_cost_base: Option<u64>,
1660 dynamic_field_has_child_object_with_ty_type_cost_per_byte: Option<u64>,
1661 dynamic_field_has_child_object_with_ty_type_tag_cost_per_byte: Option<u64>,
1662
1663 scratch_add_cost_base: Option<u64>,
1666 scratch_read_cost_base: Option<u64>,
1668 scratch_read_value_cost: Option<u64>,
1669 scratch_remove_cost_base: Option<u64>,
1671 scratch_exists_cost_base: Option<u64>,
1673 scratch_exists_with_type_cost_base: Option<u64>,
1675 scratch_exists_with_type_type_cost: Option<u64>,
1676 max_scratch_pad_size: Option<u64>,
1678
1679 event_emit_cost_base: Option<u64>,
1682 event_emit_value_size_derivation_cost_per_byte: Option<u64>,
1683 event_emit_tag_size_derivation_cost_per_byte: Option<u64>,
1684 event_emit_output_cost_per_byte: Option<u64>,
1685 event_emit_auth_stream_cost: Option<u64>,
1686
1687 object_borrow_uid_cost_base: Option<u64>,
1690 object_delete_impl_cost_base: Option<u64>,
1692 object_record_new_uid_cost_base: Option<u64>,
1694
1695 transfer_transfer_internal_cost_base: Option<u64>,
1698 transfer_party_transfer_internal_cost_base: Option<u64>,
1700 transfer_freeze_object_cost_base: Option<u64>,
1702 transfer_share_object_cost_base: Option<u64>,
1704 transfer_receive_object_cost_base: Option<u64>,
1707 transfer_receive_object_cost_per_byte: Option<u64>,
1708 transfer_receive_object_type_cost_per_byte: Option<u64>,
1709
1710 tx_context_derive_id_cost_base: Option<u64>,
1713 tx_context_fresh_id_cost_base: Option<u64>,
1714 tx_context_sender_cost_base: Option<u64>,
1715 tx_context_epoch_cost_base: Option<u64>,
1716 tx_context_epoch_timestamp_ms_cost_base: Option<u64>,
1717 tx_context_sponsor_cost_base: Option<u64>,
1718 tx_context_rgp_cost_base: Option<u64>,
1719 tx_context_gas_price_cost_base: Option<u64>,
1720 tx_context_gas_budget_cost_base: Option<u64>,
1721 tx_context_ids_created_cost_base: Option<u64>,
1722 tx_context_replace_cost_base: Option<u64>,
1723
1724 types_is_one_time_witness_cost_base: Option<u64>,
1727 types_is_one_time_witness_type_tag_cost_per_byte: Option<u64>,
1728 types_is_one_time_witness_type_cost_per_byte: Option<u64>,
1729
1730 validator_validate_metadata_cost_base: Option<u64>,
1733 validator_validate_metadata_data_cost_per_byte: Option<u64>,
1734
1735 crypto_invalid_arguments_cost: Option<u64>,
1737 bls12381_bls12381_min_sig_verify_cost_base: Option<u64>,
1739 bls12381_bls12381_min_sig_verify_msg_cost_per_byte: Option<u64>,
1740 bls12381_bls12381_min_sig_verify_msg_cost_per_block: Option<u64>,
1741
1742 bls12381_bls12381_min_pk_verify_cost_base: Option<u64>,
1744 bls12381_bls12381_min_pk_verify_msg_cost_per_byte: Option<u64>,
1745 bls12381_bls12381_min_pk_verify_msg_cost_per_block: Option<u64>,
1746
1747 ecdsa_k1_ecrecover_keccak256_cost_base: Option<u64>,
1749 ecdsa_k1_ecrecover_keccak256_msg_cost_per_byte: Option<u64>,
1750 ecdsa_k1_ecrecover_keccak256_msg_cost_per_block: Option<u64>,
1751 ecdsa_k1_ecrecover_sha256_cost_base: Option<u64>,
1752 ecdsa_k1_ecrecover_sha256_msg_cost_per_byte: Option<u64>,
1753 ecdsa_k1_ecrecover_sha256_msg_cost_per_block: Option<u64>,
1754
1755 ecdsa_k1_decompress_pubkey_cost_base: Option<u64>,
1757
1758 ecdsa_k1_secp256k1_verify_keccak256_cost_base: Option<u64>,
1760 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_byte: Option<u64>,
1761 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_block: Option<u64>,
1762 ecdsa_k1_secp256k1_verify_sha256_cost_base: Option<u64>,
1763 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_byte: Option<u64>,
1764 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_block: Option<u64>,
1765
1766 ecdsa_r1_ecrecover_keccak256_cost_base: Option<u64>,
1768 ecdsa_r1_ecrecover_keccak256_msg_cost_per_byte: Option<u64>,
1769 ecdsa_r1_ecrecover_keccak256_msg_cost_per_block: Option<u64>,
1770 ecdsa_r1_ecrecover_sha256_cost_base: Option<u64>,
1771 ecdsa_r1_ecrecover_sha256_msg_cost_per_byte: Option<u64>,
1772 ecdsa_r1_ecrecover_sha256_msg_cost_per_block: Option<u64>,
1773
1774 ecdsa_r1_secp256r1_verify_keccak256_cost_base: Option<u64>,
1776 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_byte: Option<u64>,
1777 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_block: Option<u64>,
1778 ecdsa_r1_secp256r1_verify_sha256_cost_base: Option<u64>,
1779 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_byte: Option<u64>,
1780 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_block: Option<u64>,
1781
1782 ecvrf_ecvrf_verify_cost_base: Option<u64>,
1784 ecvrf_ecvrf_verify_alpha_string_cost_per_byte: Option<u64>,
1785 ecvrf_ecvrf_verify_alpha_string_cost_per_block: Option<u64>,
1786
1787 ed25519_ed25519_verify_cost_base: Option<u64>,
1789 ed25519_ed25519_verify_msg_cost_per_byte: Option<u64>,
1790 ed25519_ed25519_verify_msg_cost_per_block: Option<u64>,
1791
1792 groth16_prepare_verifying_key_bls12381_cost_base: Option<u64>,
1794 groth16_prepare_verifying_key_bn254_cost_base: Option<u64>,
1795
1796 groth16_verify_groth16_proof_internal_bls12381_cost_base: Option<u64>,
1798 groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input: Option<u64>,
1799 groth16_verify_groth16_proof_internal_bn254_cost_base: Option<u64>,
1800 groth16_verify_groth16_proof_internal_bn254_cost_per_public_input: Option<u64>,
1801 groth16_verify_groth16_proof_internal_public_input_cost_per_byte: Option<u64>,
1802
1803 hash_blake2b256_cost_base: Option<u64>,
1805 hash_blake2b256_data_cost_per_byte: Option<u64>,
1806 hash_blake2b256_data_cost_per_block: Option<u64>,
1807
1808 hash_keccak256_cost_base: Option<u64>,
1810 hash_keccak256_data_cost_per_byte: Option<u64>,
1811 hash_keccak256_data_cost_per_block: Option<u64>,
1812
1813 poseidon_bn254_cost_base: Option<u64>,
1815 poseidon_bn254_cost_per_block: Option<u64>,
1816
1817 group_ops_bls12381_decode_scalar_cost: Option<u64>,
1819 group_ops_bls12381_decode_g1_cost: Option<u64>,
1820 group_ops_bls12381_decode_g2_cost: Option<u64>,
1821 group_ops_bls12381_decode_gt_cost: Option<u64>,
1822 group_ops_bls12381_scalar_add_cost: Option<u64>,
1823 group_ops_bls12381_g1_add_cost: Option<u64>,
1824 group_ops_bls12381_g2_add_cost: Option<u64>,
1825 group_ops_bls12381_gt_add_cost: Option<u64>,
1826 group_ops_bls12381_scalar_sub_cost: Option<u64>,
1827 group_ops_bls12381_g1_sub_cost: Option<u64>,
1828 group_ops_bls12381_g2_sub_cost: Option<u64>,
1829 group_ops_bls12381_gt_sub_cost: Option<u64>,
1830 group_ops_bls12381_scalar_mul_cost: Option<u64>,
1831 group_ops_bls12381_g1_mul_cost: Option<u64>,
1832 group_ops_bls12381_g2_mul_cost: Option<u64>,
1833 group_ops_bls12381_gt_mul_cost: Option<u64>,
1834 group_ops_bls12381_scalar_div_cost: Option<u64>,
1835 group_ops_bls12381_g1_div_cost: Option<u64>,
1836 group_ops_bls12381_g2_div_cost: Option<u64>,
1837 group_ops_bls12381_gt_div_cost: Option<u64>,
1838 group_ops_bls12381_g1_hash_to_base_cost: Option<u64>,
1839 group_ops_bls12381_g2_hash_to_base_cost: Option<u64>,
1840 group_ops_bls12381_g1_hash_to_cost_per_byte: Option<u64>,
1841 group_ops_bls12381_g2_hash_to_cost_per_byte: Option<u64>,
1842 group_ops_bls12381_g1_msm_base_cost: Option<u64>,
1843 group_ops_bls12381_g2_msm_base_cost: Option<u64>,
1844 group_ops_bls12381_g1_msm_base_cost_per_input: Option<u64>,
1845 group_ops_bls12381_g2_msm_base_cost_per_input: Option<u64>,
1846 group_ops_bls12381_msm_max_len: Option<u32>,
1847 group_ops_bls12381_pairing_cost: Option<u64>,
1848 group_ops_bls12381_g1_to_uncompressed_g1_cost: Option<u64>,
1849 group_ops_bls12381_uncompressed_g1_to_g1_cost: Option<u64>,
1850 group_ops_bls12381_uncompressed_g1_sum_base_cost: Option<u64>,
1851 group_ops_bls12381_uncompressed_g1_sum_cost_per_term: Option<u64>,
1852 group_ops_bls12381_uncompressed_g1_sum_max_terms: Option<u64>,
1853
1854 group_ops_ristretto_decode_scalar_cost: Option<u64>,
1855 group_ops_ristretto_decode_point_cost: Option<u64>,
1856 group_ops_ristretto_scalar_add_cost: Option<u64>,
1857 group_ops_ristretto_point_add_cost: Option<u64>,
1858 group_ops_ristretto_scalar_sub_cost: Option<u64>,
1859 group_ops_ristretto_point_sub_cost: Option<u64>,
1860 group_ops_ristretto_scalar_mul_cost: Option<u64>,
1861 group_ops_ristretto_point_mul_cost: Option<u64>,
1862 group_ops_ristretto_scalar_div_cost: Option<u64>,
1863 group_ops_ristretto_point_div_cost: Option<u64>,
1864
1865 verify_bulletproofs_ristretto255_base_cost: Option<u64>,
1866 verify_bulletproofs_ristretto255_cost_per_bit_and_commitment: Option<u64>,
1867
1868 hmac_hmac_sha3_256_cost_base: Option<u64>,
1870 hmac_hmac_sha3_256_input_cost_per_byte: Option<u64>,
1871 hmac_hmac_sha3_256_input_cost_per_block: Option<u64>,
1872
1873 check_zklogin_id_cost_base: Option<u64>,
1875 check_zklogin_issuer_cost_base: Option<u64>,
1877
1878 vdf_verify_vdf_cost: Option<u64>,
1879 vdf_hash_to_input_cost: Option<u64>,
1880
1881 nitro_attestation_parse_base_cost: Option<u64>,
1883 nitro_attestation_parse_cost_per_byte: Option<u64>,
1884 nitro_attestation_verify_base_cost: Option<u64>,
1885 nitro_attestation_verify_cost_per_cert: Option<u64>,
1886
1887 bcs_per_byte_serialized_cost: Option<u64>,
1889 bcs_legacy_min_output_size_cost: Option<u64>,
1890 bcs_failure_cost: Option<u64>,
1891
1892 hash_sha2_256_base_cost: Option<u64>,
1893 hash_sha2_256_per_byte_cost: Option<u64>,
1894 hash_sha2_256_legacy_min_input_len_cost: Option<u64>,
1895 hash_sha3_256_base_cost: Option<u64>,
1896 hash_sha3_256_per_byte_cost: Option<u64>,
1897 hash_sha3_256_legacy_min_input_len_cost: Option<u64>,
1898 type_name_get_base_cost: Option<u64>,
1899 type_name_get_per_byte_cost: Option<u64>,
1900 type_name_id_base_cost: Option<u64>,
1901
1902 string_check_utf8_base_cost: Option<u64>,
1903 string_check_utf8_per_byte_cost: Option<u64>,
1904 string_is_char_boundary_base_cost: Option<u64>,
1905 string_sub_string_base_cost: Option<u64>,
1906 string_sub_string_per_byte_cost: Option<u64>,
1907 string_index_of_base_cost: Option<u64>,
1908 string_index_of_per_byte_pattern_cost: Option<u64>,
1909 string_index_of_per_byte_searched_cost: Option<u64>,
1910
1911 vector_empty_base_cost: Option<u64>,
1912 vector_length_base_cost: Option<u64>,
1913 vector_push_back_base_cost: Option<u64>,
1914 vector_push_back_legacy_per_abstract_memory_unit_cost: Option<u64>,
1915 vector_borrow_base_cost: Option<u64>,
1916 vector_pop_back_base_cost: Option<u64>,
1917 vector_destroy_empty_base_cost: Option<u64>,
1918 vector_swap_base_cost: Option<u64>,
1919 debug_print_base_cost: Option<u64>,
1920 debug_print_stack_trace_base_cost: Option<u64>,
1921
1922 execution_version: Option<u64>,
1931
1932 consensus_bad_nodes_stake_threshold: Option<u64>,
1936
1937 max_jwk_votes_per_validator_per_epoch: Option<u64>,
1938 max_age_of_jwk_in_epochs: Option<u64>,
1942
1943 random_beacon_reduction_allowed_delta: Option<u16>,
1947
1948 random_beacon_reduction_lower_bound: Option<u32>,
1951
1952 random_beacon_dkg_timeout_round: Option<u32>,
1955
1956 random_beacon_min_round_interval_ms: Option<u64>,
1958
1959 random_beacon_dkg_version: Option<u64>,
1962
1963 consensus_max_transaction_size_bytes: Option<u64>,
1966 consensus_max_transactions_in_block_bytes: Option<u64>,
1968 consensus_max_num_transactions_in_block: Option<u64>,
1970
1971 consensus_voting_rounds: Option<u32>,
1973
1974 max_accumulated_txn_cost_per_object_in_narwhal_commit: Option<u64>,
1976
1977 max_deferral_rounds_for_congestion_control: Option<u64>,
1980
1981 max_txn_cost_overage_per_object_in_commit: Option<u64>,
1983
1984 allowed_txn_cost_overage_burst_per_object_in_commit: Option<u64>,
1986
1987 min_checkpoint_interval_ms: Option<u64>,
1989
1990 checkpoint_summary_version_specific_data: Option<u64>,
1992
1993 max_soft_bundle_size: Option<u64>,
1995
1996 bridge_should_try_to_finalize_committee: Option<bool>,
2000
2001 max_accumulated_txn_cost_per_object_in_mysticeti_commit: Option<u64>,
2007
2008 max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit: Option<u64>,
2011
2012 consensus_gc_depth: Option<u32>,
2015
2016 gas_budget_based_txn_cost_cap_factor: Option<u64>,
2018
2019 gas_budget_based_txn_cost_absolute_cap_commit_count: Option<u64>,
2021
2022 sip_45_consensus_amplification_threshold: Option<u64>,
2025
2026 use_object_per_epoch_marker_table_v2: Option<bool>,
2029
2030 consensus_commit_rate_estimation_window_size: Option<u32>,
2032
2033 #[serde(skip_serializing_if = "Vec::is_empty")]
2037 aliased_addresses: Vec<AliasedAddress>,
2038
2039 translation_per_command_base_charge: Option<u64>,
2042
2043 translation_per_input_base_charge: Option<u64>,
2046
2047 translation_pure_input_per_byte_charge: Option<u64>,
2049
2050 translation_per_type_node_charge: Option<u64>,
2054
2055 translation_per_reference_node_charge: Option<u64>,
2058
2059 translation_per_linkage_entry_charge: Option<u64>,
2062
2063 max_updates_per_settlement_txn: Option<u32>,
2065
2066 gasless_max_computation_units: Option<u64>,
2068
2069 gasless_allowed_token_types: Option<Vec<(String, u64)>>,
2071
2072 gasless_max_unused_inputs: Option<u64>,
2076
2077 gasless_max_pure_input_bytes: Option<u64>,
2080
2081 gasless_max_tps: Option<u64>,
2083
2084 #[serde(skip_serializing_if = "Option::is_none")]
2085 #[skip_accessor]
2086 include_special_package_amendments: Option<Arc<Amendments>>,
2087
2088 gasless_max_tx_size_bytes: Option<u64>,
2091}
2092
2093#[derive(Clone, Serialize, Deserialize, Debug)]
2095pub struct AliasedAddress {
2096 pub original: [u8; 32],
2098 pub aliased: [u8; 32],
2100 pub allowed_tx_digests: Vec<[u8; 32]>,
2102}
2103
2104impl ProtocolConfig {
2106 pub fn chain(&self) -> Chain {
2108 self.chain
2109 }
2110
2111 pub fn check_package_upgrades_supported(&self) -> Result<(), Error> {
2124 if self.feature_flags.package_upgrades {
2125 Ok(())
2126 } else {
2127 Err(Error(format!(
2128 "package upgrades are not supported at {:?}",
2129 self.version
2130 )))
2131 }
2132 }
2133
2134 pub fn zklogin_supported_providers(&self) -> &BTreeSet<String> {
2135 &self.feature_flags.zklogin_supported_providers
2136 }
2137
2138 pub fn consensus_transaction_ordering(&self) -> ConsensusTransactionOrdering {
2139 self.feature_flags.consensus_transaction_ordering
2140 }
2141
2142 pub fn enable_jwk_consensus_updates(&self) -> bool {
2143 let ret = self.feature_flags.enable_jwk_consensus_updates;
2144 if ret {
2145 assert!(self.feature_flags.end_of_epoch_transaction_supported);
2147 }
2148 ret
2149 }
2150
2151 pub fn end_of_epoch_transaction_supported(&self) -> bool {
2152 let ret = self.feature_flags.end_of_epoch_transaction_supported;
2153 if !ret {
2154 assert!(!self.feature_flags.enable_jwk_consensus_updates);
2156 }
2157 ret
2158 }
2159
2160 pub fn dkg_version(&self) -> u64 {
2161 self.random_beacon_dkg_version.unwrap_or(1)
2163 }
2164
2165 pub fn bridge(&self) -> bool {
2166 let ret = self.feature_flags.bridge;
2167 if ret {
2168 assert!(self.feature_flags.end_of_epoch_transaction_supported);
2170 }
2171 ret
2172 }
2173
2174 pub fn should_try_to_finalize_bridge_committee(&self) -> bool {
2175 if !self.bridge() {
2176 return false;
2177 }
2178 self.bridge_should_try_to_finalize_committee.unwrap_or(true)
2180 }
2181
2182 pub fn zklogin_max_epoch_upper_bound_delta(&self) -> Option<u64> {
2183 self.feature_flags.zklogin_max_epoch_upper_bound_delta
2184 }
2185
2186 pub fn enable_coin_reservation_obj_refs(&self) -> bool {
2187 self.new_vm_enabled() && self.feature_flags.enable_coin_reservation_obj_refs
2188 }
2189
2190 pub fn enable_authenticated_event_streams(&self) -> bool {
2191 self.feature_flags.enable_authenticated_event_streams && self.enable_accumulators()
2192 }
2193
2194 pub fn per_object_congestion_control_mode(&self) -> PerObjectCongestionControlMode {
2195 self.feature_flags.per_object_congestion_control_mode
2196 }
2197
2198 pub fn consensus_choice(&self) -> ConsensusChoice {
2199 self.feature_flags.consensus_choice
2200 }
2201
2202 pub fn consensus_network(&self) -> ConsensusNetwork {
2203 self.feature_flags.consensus_network
2204 }
2205
2206 pub fn mysticeti_num_leaders_per_round(&self) -> Option<usize> {
2207 self.feature_flags.mysticeti_num_leaders_per_round
2208 }
2209
2210 pub fn max_transaction_size_bytes(&self) -> u64 {
2211 self.consensus_max_transaction_size_bytes
2213 .unwrap_or(256 * 1024)
2214 }
2215
2216 pub fn max_transactions_in_block_bytes(&self) -> u64 {
2217 if cfg!(msim) {
2218 256 * 1024
2219 } else {
2220 self.consensus_max_transactions_in_block_bytes
2221 .unwrap_or(512 * 1024)
2222 }
2223 }
2224
2225 pub fn max_num_transactions_in_block(&self) -> u64 {
2226 if cfg!(msim) {
2227 8
2228 } else {
2229 self.consensus_max_num_transactions_in_block.unwrap_or(512)
2230 }
2231 }
2232
2233 pub fn gc_depth(&self) -> u32 {
2234 self.consensus_gc_depth.unwrap_or(0)
2235 }
2236
2237 pub fn consensus_linearize_subdag_v2(&self) -> bool {
2238 let res = self.feature_flags.consensus_linearize_subdag_v2;
2239 assert!(
2240 !res || self.gc_depth() > 0,
2241 "The consensus linearize sub dag V2 requires GC to be enabled"
2242 );
2243 res
2244 }
2245
2246 pub fn consensus_median_based_commit_timestamp(&self) -> bool {
2247 let res = self.feature_flags.consensus_median_based_commit_timestamp;
2248 assert!(
2249 !res || self.gc_depth() > 0,
2250 "The consensus median based commit timestamp requires GC to be enabled"
2251 );
2252 res
2253 }
2254
2255 pub fn get_consensus_commit_rate_estimation_window_size(&self) -> u32 {
2256 self.consensus_commit_rate_estimation_window_size
2257 .unwrap_or(0)
2258 }
2259
2260 pub fn consensus_num_requested_prior_commits_at_startup(&self) -> u32 {
2261 let window_size = self.get_consensus_commit_rate_estimation_window_size();
2265 assert!(window_size == 0 || self.record_additional_state_digest_in_prologue());
2267 window_size
2268 }
2269
2270 pub fn enable_observation_chunking(&self) -> bool {
2271 matches!(self.feature_flags.per_object_congestion_control_mode,
2272 PerObjectCongestionControlMode::ExecutionTimeEstimate(ref params)
2273 if params.observations_chunk_size.is_some()
2274 )
2275 }
2276
2277 pub fn address_aliases(&self) -> bool {
2278 let address_aliases = self.feature_flags.address_aliases;
2279 assert!(
2280 !address_aliases || self.mysticeti_fastpath(),
2281 "Address aliases requires Mysticeti fastpath to be enabled"
2282 );
2283 if address_aliases {
2284 assert!(
2285 self.feature_flags.disable_preconsensus_locking,
2286 "Address aliases requires CertifiedTransaction to be disabled"
2287 );
2288 }
2289 address_aliases
2290 }
2291
2292 pub fn new_vm_enabled(&self) -> bool {
2293 self.execution_version.is_some_and(|v| v >= 4)
2294 }
2295
2296 pub fn gasless_allowed_token_types(&self) -> &[(String, u64)] {
2297 debug_assert!(self.gasless_allowed_token_types.is_some());
2298 self.gasless_allowed_token_types.as_deref().unwrap_or(&[])
2299 }
2300
2301 pub fn get_gasless_max_unused_inputs(&self) -> u64 {
2302 self.gasless_max_unused_inputs.unwrap_or(u64::MAX)
2303 }
2304
2305 pub fn get_gasless_max_pure_input_bytes(&self) -> u64 {
2306 self.gasless_max_pure_input_bytes.unwrap_or(u64::MAX)
2307 }
2308
2309 pub fn get_gasless_max_tx_size_bytes(&self) -> u64 {
2310 self.gasless_max_tx_size_bytes.unwrap_or(u64::MAX)
2311 }
2312
2313 pub fn include_special_package_amendments_as_option(&self) -> &Option<Arc<Amendments>> {
2314 &self.include_special_package_amendments
2315 }
2316}
2317
2318#[cfg(not(msim))]
2319static POISON_VERSION_METHODS: AtomicBool = AtomicBool::new(false);
2320
2321#[cfg(msim)]
2323thread_local! {
2324 static POISON_VERSION_METHODS: AtomicBool = AtomicBool::new(false);
2325}
2326
2327impl ProtocolConfig {
2329 pub fn get_for_version(version: ProtocolVersion, chain: Chain) -> Self {
2331 assert!(
2333 version >= ProtocolVersion::MIN,
2334 "Network protocol version is {:?}, but the minimum supported version by the binary is {:?}. Please upgrade the binary.",
2335 version,
2336 ProtocolVersion::MIN.0,
2337 );
2338 assert!(
2339 version <= ProtocolVersion::MAX_ALLOWED,
2340 "Network protocol version is {:?}, but the maximum supported version by the binary is {:?}. Please upgrade the binary.",
2341 version,
2342 ProtocolVersion::MAX_ALLOWED.0,
2343 );
2344
2345 let mut ret = Self::get_for_version_impl(version, chain);
2346 ret.version = version;
2347 ret.chain = chain;
2348
2349 ret = Self::apply_config_override(version, ret);
2350
2351 if std::env::var("SUI_PROTOCOL_CONFIG_OVERRIDE_ENABLE").is_ok() {
2352 warn!(
2353 "overriding ProtocolConfig settings with custom settings; this may break non-local networks"
2354 );
2355 let overrides: ProtocolConfigOptional =
2356 serde_env::from_env_with_prefix("SUI_PROTOCOL_CONFIG_OVERRIDE")
2357 .expect("failed to parse ProtocolConfig override env variables");
2358 overrides.apply_to(&mut ret);
2359 }
2360
2361 ret
2362 }
2363
2364 pub fn get_for_version_if_supported(version: ProtocolVersion, chain: Chain) -> Option<Self> {
2367 if version.0 >= ProtocolVersion::MIN.0 && version.0 <= ProtocolVersion::MAX_ALLOWED.0 {
2368 let mut ret = Self::get_for_version_impl(version, chain);
2369 ret.version = version;
2370 ret.chain = chain;
2371 ret = Self::apply_config_override(version, ret);
2372 Some(ret)
2373 } else {
2374 None
2375 }
2376 }
2377
2378 #[cfg(not(msim))]
2379 pub fn poison_get_for_min_version() {
2380 POISON_VERSION_METHODS.store(true, Ordering::Relaxed);
2381 }
2382
2383 #[cfg(not(msim))]
2384 fn load_poison_get_for_min_version() -> bool {
2385 POISON_VERSION_METHODS.load(Ordering::Relaxed)
2386 }
2387
2388 #[cfg(msim)]
2389 pub fn poison_get_for_min_version() {
2390 POISON_VERSION_METHODS.with(|p| p.store(true, Ordering::Relaxed));
2391 }
2392
2393 #[cfg(msim)]
2394 fn load_poison_get_for_min_version() -> bool {
2395 POISON_VERSION_METHODS.with(|p| p.load(Ordering::Relaxed))
2396 }
2397
2398 pub fn get_for_min_version() -> Self {
2401 if Self::load_poison_get_for_min_version() {
2402 panic!("get_for_min_version called on validator");
2403 }
2404 ProtocolConfig::get_for_version(ProtocolVersion::MIN, Chain::Unknown)
2405 }
2406
2407 #[allow(non_snake_case)]
2417 pub fn get_for_max_version_UNSAFE() -> Self {
2418 if Self::load_poison_get_for_min_version() {
2419 panic!("get_for_max_version_UNSAFE called on validator");
2420 }
2421 ProtocolConfig::get_for_version(ProtocolVersion::MAX, Chain::Unknown)
2422 }
2423
2424 fn get_for_version_impl(version: ProtocolVersion, chain: Chain) -> Self {
2425 #[cfg(msim)]
2426 {
2427 if version == ProtocolVersion::MAX_ALLOWED {
2429 let mut config = Self::get_for_version_impl(version - 1, Chain::Unknown);
2430 config.base_tx_cost_fixed = Some(config.base_tx_cost_fixed() + 1000);
2431 return config;
2432 }
2433 }
2434
2435 let mut cfg = Self {
2438 version,
2440 chain,
2441
2442 feature_flags: Default::default(),
2444
2445 max_tx_size_bytes: Some(128 * 1024),
2446 max_input_objects: Some(2048),
2448 max_serialized_tx_effects_size_bytes: Some(512 * 1024),
2449 max_serialized_tx_effects_size_bytes_system_tx: Some(512 * 1024 * 16),
2450 max_gas_payment_objects: Some(256),
2451 max_modules_in_publish: Some(128),
2452 max_package_dependencies: None,
2453 max_arguments: Some(512),
2454 max_type_arguments: Some(16),
2455 max_type_argument_depth: Some(16),
2456 max_pure_argument_size: Some(16 * 1024),
2457 max_programmable_tx_commands: Some(1024),
2458 move_binary_format_version: Some(6),
2459 min_move_binary_format_version: None,
2460 binary_module_handles: None,
2461 binary_struct_handles: None,
2462 binary_function_handles: None,
2463 binary_function_instantiations: None,
2464 binary_signatures: None,
2465 binary_constant_pool: None,
2466 binary_identifiers: None,
2467 binary_address_identifiers: None,
2468 binary_struct_defs: None,
2469 binary_struct_def_instantiations: None,
2470 binary_function_defs: None,
2471 binary_field_handles: None,
2472 binary_field_instantiations: None,
2473 binary_friend_decls: None,
2474 binary_enum_defs: None,
2475 binary_enum_def_instantiations: None,
2476 binary_variant_handles: None,
2477 binary_variant_instantiation_handles: None,
2478 max_move_object_size: Some(250 * 1024),
2479 max_move_package_size: Some(100 * 1024),
2480 max_publish_or_upgrade_per_ptb: None,
2481 max_tx_gas: Some(10_000_000_000),
2482 max_gas_price: Some(100_000),
2483 max_gas_price_rgp_factor_for_aborted_transactions: None,
2484 max_gas_computation_bucket: Some(5_000_000),
2485 max_loop_depth: Some(5),
2486 max_generic_instantiation_length: Some(32),
2487 max_function_parameters: Some(128),
2488 max_basic_blocks: Some(1024),
2489 max_value_stack_size: Some(1024),
2490 max_type_nodes: Some(256),
2491 max_generic_instantiation_type_nodes_per_function: None,
2492 max_generic_instantiation_type_nodes_per_module: None,
2493 max_push_size: Some(10000),
2494 max_struct_definitions: Some(200),
2495 max_function_definitions: Some(1000),
2496 max_fields_in_struct: Some(32),
2497 max_dependency_depth: Some(100),
2498 max_num_event_emit: Some(256),
2499 max_num_new_move_object_ids: Some(2048),
2500 max_num_new_move_object_ids_system_tx: Some(2048 * 16),
2501 max_num_deleted_move_object_ids: Some(2048),
2502 max_num_deleted_move_object_ids_system_tx: Some(2048 * 16),
2503 max_num_transferred_move_object_ids: Some(2048),
2504 max_num_transferred_move_object_ids_system_tx: Some(2048 * 16),
2505 max_event_emit_size: Some(250 * 1024),
2506 max_move_vector_len: Some(256 * 1024),
2507 max_type_to_layout_nodes: None,
2508 max_ptb_value_size: None,
2509
2510 max_back_edges_per_function: Some(10_000),
2511 max_back_edges_per_module: Some(10_000),
2512 max_verifier_meter_ticks_per_function: Some(6_000_000),
2513 max_meter_ticks_per_module: Some(6_000_000),
2514 max_meter_ticks_per_package: None,
2515
2516 object_runtime_max_num_cached_objects: Some(1000),
2517 object_runtime_max_num_cached_objects_system_tx: Some(1000 * 16),
2518 object_runtime_max_num_store_entries: Some(1000),
2519 object_runtime_max_num_store_entries_system_tx: Some(1000 * 16),
2520 base_tx_cost_fixed: Some(110_000),
2521 package_publish_cost_fixed: Some(1_000),
2522 base_tx_cost_per_byte: Some(0),
2523 package_publish_cost_per_byte: Some(80),
2524 obj_access_cost_read_per_byte: Some(15),
2525 obj_access_cost_mutate_per_byte: Some(40),
2526 obj_access_cost_delete_per_byte: Some(40),
2527 obj_access_cost_verify_per_byte: Some(200),
2528 obj_data_cost_refundable: Some(100),
2529 obj_metadata_cost_non_refundable: Some(50),
2530 gas_model_version: Some(1),
2531 storage_rebate_rate: Some(9900),
2532 storage_fund_reinvest_rate: Some(500),
2533 reward_slashing_rate: Some(5000),
2534 storage_gas_price: Some(1),
2535 accumulator_object_storage_cost: None,
2536 max_transactions_per_checkpoint: Some(10_000),
2537 max_checkpoint_size_bytes: Some(30 * 1024 * 1024),
2538
2539 buffer_stake_for_protocol_upgrade_bps: Some(0),
2542
2543 address_from_bytes_cost_base: Some(52),
2547 address_to_u256_cost_base: Some(52),
2549 address_from_u256_cost_base: Some(52),
2551
2552 config_read_setting_impl_cost_base: None,
2555 config_read_setting_impl_cost_per_byte: None,
2556
2557 dynamic_field_hash_type_and_key_cost_base: Some(100),
2560 dynamic_field_hash_type_and_key_type_cost_per_byte: Some(2),
2561 dynamic_field_hash_type_and_key_value_cost_per_byte: Some(2),
2562 dynamic_field_hash_type_and_key_type_tag_cost_per_byte: Some(2),
2563 dynamic_field_add_child_object_cost_base: Some(100),
2565 dynamic_field_add_child_object_type_cost_per_byte: Some(10),
2566 dynamic_field_add_child_object_value_cost_per_byte: Some(10),
2567 dynamic_field_add_child_object_struct_tag_cost_per_byte: Some(10),
2568 dynamic_field_borrow_child_object_cost_base: Some(100),
2570 dynamic_field_borrow_child_object_child_ref_cost_per_byte: Some(10),
2571 dynamic_field_borrow_child_object_type_cost_per_byte: Some(10),
2572 dynamic_field_remove_child_object_cost_base: Some(100),
2574 dynamic_field_remove_child_object_child_cost_per_byte: Some(2),
2575 dynamic_field_remove_child_object_type_cost_per_byte: Some(2),
2576 dynamic_field_has_child_object_cost_base: Some(100),
2578 dynamic_field_has_child_object_with_ty_cost_base: Some(100),
2580 dynamic_field_has_child_object_with_ty_type_cost_per_byte: Some(2),
2581 dynamic_field_has_child_object_with_ty_type_tag_cost_per_byte: Some(2),
2582
2583 scratch_add_cost_base: None,
2585 scratch_read_cost_base: None,
2586 scratch_read_value_cost: None,
2587 scratch_remove_cost_base: None,
2588 scratch_exists_cost_base: None,
2589 scratch_exists_with_type_cost_base: None,
2590 scratch_exists_with_type_type_cost: None,
2591 max_scratch_pad_size: None,
2592
2593 event_emit_cost_base: Some(52),
2596 event_emit_value_size_derivation_cost_per_byte: Some(2),
2597 event_emit_tag_size_derivation_cost_per_byte: Some(5),
2598 event_emit_output_cost_per_byte: Some(10),
2599 event_emit_auth_stream_cost: None,
2600
2601 object_borrow_uid_cost_base: Some(52),
2604 object_delete_impl_cost_base: Some(52),
2606 object_record_new_uid_cost_base: Some(52),
2608
2609 transfer_transfer_internal_cost_base: Some(52),
2612 transfer_party_transfer_internal_cost_base: None,
2614 transfer_freeze_object_cost_base: Some(52),
2616 transfer_share_object_cost_base: Some(52),
2618 transfer_receive_object_cost_base: None,
2619 transfer_receive_object_type_cost_per_byte: None,
2620 transfer_receive_object_cost_per_byte: None,
2621
2622 tx_context_derive_id_cost_base: Some(52),
2625 tx_context_fresh_id_cost_base: None,
2626 tx_context_sender_cost_base: None,
2627 tx_context_epoch_cost_base: None,
2628 tx_context_epoch_timestamp_ms_cost_base: None,
2629 tx_context_sponsor_cost_base: None,
2630 tx_context_rgp_cost_base: None,
2631 tx_context_gas_price_cost_base: None,
2632 tx_context_gas_budget_cost_base: None,
2633 tx_context_ids_created_cost_base: None,
2634 tx_context_replace_cost_base: None,
2635
2636 types_is_one_time_witness_cost_base: Some(52),
2639 types_is_one_time_witness_type_tag_cost_per_byte: Some(2),
2640 types_is_one_time_witness_type_cost_per_byte: Some(2),
2641
2642 validator_validate_metadata_cost_base: Some(52),
2645 validator_validate_metadata_data_cost_per_byte: Some(2),
2646
2647 crypto_invalid_arguments_cost: Some(100),
2649 bls12381_bls12381_min_sig_verify_cost_base: Some(52),
2651 bls12381_bls12381_min_sig_verify_msg_cost_per_byte: Some(2),
2652 bls12381_bls12381_min_sig_verify_msg_cost_per_block: Some(2),
2653
2654 bls12381_bls12381_min_pk_verify_cost_base: Some(52),
2656 bls12381_bls12381_min_pk_verify_msg_cost_per_byte: Some(2),
2657 bls12381_bls12381_min_pk_verify_msg_cost_per_block: Some(2),
2658
2659 ecdsa_k1_ecrecover_keccak256_cost_base: Some(52),
2661 ecdsa_k1_ecrecover_keccak256_msg_cost_per_byte: Some(2),
2662 ecdsa_k1_ecrecover_keccak256_msg_cost_per_block: Some(2),
2663 ecdsa_k1_ecrecover_sha256_cost_base: Some(52),
2664 ecdsa_k1_ecrecover_sha256_msg_cost_per_byte: Some(2),
2665 ecdsa_k1_ecrecover_sha256_msg_cost_per_block: Some(2),
2666
2667 ecdsa_k1_decompress_pubkey_cost_base: Some(52),
2669
2670 ecdsa_k1_secp256k1_verify_keccak256_cost_base: Some(52),
2672 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_byte: Some(2),
2673 ecdsa_k1_secp256k1_verify_keccak256_msg_cost_per_block: Some(2),
2674 ecdsa_k1_secp256k1_verify_sha256_cost_base: Some(52),
2675 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_byte: Some(2),
2676 ecdsa_k1_secp256k1_verify_sha256_msg_cost_per_block: Some(2),
2677
2678 ecdsa_r1_ecrecover_keccak256_cost_base: Some(52),
2680 ecdsa_r1_ecrecover_keccak256_msg_cost_per_byte: Some(2),
2681 ecdsa_r1_ecrecover_keccak256_msg_cost_per_block: Some(2),
2682 ecdsa_r1_ecrecover_sha256_cost_base: Some(52),
2683 ecdsa_r1_ecrecover_sha256_msg_cost_per_byte: Some(2),
2684 ecdsa_r1_ecrecover_sha256_msg_cost_per_block: Some(2),
2685
2686 ecdsa_r1_secp256r1_verify_keccak256_cost_base: Some(52),
2688 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_byte: Some(2),
2689 ecdsa_r1_secp256r1_verify_keccak256_msg_cost_per_block: Some(2),
2690 ecdsa_r1_secp256r1_verify_sha256_cost_base: Some(52),
2691 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_byte: Some(2),
2692 ecdsa_r1_secp256r1_verify_sha256_msg_cost_per_block: Some(2),
2693
2694 ecvrf_ecvrf_verify_cost_base: Some(52),
2696 ecvrf_ecvrf_verify_alpha_string_cost_per_byte: Some(2),
2697 ecvrf_ecvrf_verify_alpha_string_cost_per_block: Some(2),
2698
2699 ed25519_ed25519_verify_cost_base: Some(52),
2701 ed25519_ed25519_verify_msg_cost_per_byte: Some(2),
2702 ed25519_ed25519_verify_msg_cost_per_block: Some(2),
2703
2704 groth16_prepare_verifying_key_bls12381_cost_base: Some(52),
2706 groth16_prepare_verifying_key_bn254_cost_base: Some(52),
2707
2708 groth16_verify_groth16_proof_internal_bls12381_cost_base: Some(52),
2710 groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input: Some(2),
2711 groth16_verify_groth16_proof_internal_bn254_cost_base: Some(52),
2712 groth16_verify_groth16_proof_internal_bn254_cost_per_public_input: Some(2),
2713 groth16_verify_groth16_proof_internal_public_input_cost_per_byte: Some(2),
2714
2715 hash_blake2b256_cost_base: Some(52),
2717 hash_blake2b256_data_cost_per_byte: Some(2),
2718 hash_blake2b256_data_cost_per_block: Some(2),
2719
2720 hash_keccak256_cost_base: Some(52),
2722 hash_keccak256_data_cost_per_byte: Some(2),
2723 hash_keccak256_data_cost_per_block: Some(2),
2724
2725 poseidon_bn254_cost_base: None,
2726 poseidon_bn254_cost_per_block: None,
2727
2728 hmac_hmac_sha3_256_cost_base: Some(52),
2730 hmac_hmac_sha3_256_input_cost_per_byte: Some(2),
2731 hmac_hmac_sha3_256_input_cost_per_block: Some(2),
2732
2733 group_ops_bls12381_decode_scalar_cost: None,
2735 group_ops_bls12381_decode_g1_cost: None,
2736 group_ops_bls12381_decode_g2_cost: None,
2737 group_ops_bls12381_decode_gt_cost: None,
2738 group_ops_bls12381_scalar_add_cost: None,
2739 group_ops_bls12381_g1_add_cost: None,
2740 group_ops_bls12381_g2_add_cost: None,
2741 group_ops_bls12381_gt_add_cost: None,
2742 group_ops_bls12381_scalar_sub_cost: None,
2743 group_ops_bls12381_g1_sub_cost: None,
2744 group_ops_bls12381_g2_sub_cost: None,
2745 group_ops_bls12381_gt_sub_cost: None,
2746 group_ops_bls12381_scalar_mul_cost: None,
2747 group_ops_bls12381_g1_mul_cost: None,
2748 group_ops_bls12381_g2_mul_cost: None,
2749 group_ops_bls12381_gt_mul_cost: None,
2750 group_ops_bls12381_scalar_div_cost: None,
2751 group_ops_bls12381_g1_div_cost: None,
2752 group_ops_bls12381_g2_div_cost: None,
2753 group_ops_bls12381_gt_div_cost: None,
2754 group_ops_bls12381_g1_hash_to_base_cost: None,
2755 group_ops_bls12381_g2_hash_to_base_cost: None,
2756 group_ops_bls12381_g1_hash_to_cost_per_byte: None,
2757 group_ops_bls12381_g2_hash_to_cost_per_byte: None,
2758 group_ops_bls12381_g1_msm_base_cost: None,
2759 group_ops_bls12381_g2_msm_base_cost: None,
2760 group_ops_bls12381_g1_msm_base_cost_per_input: None,
2761 group_ops_bls12381_g2_msm_base_cost_per_input: None,
2762 group_ops_bls12381_msm_max_len: None,
2763 group_ops_bls12381_pairing_cost: None,
2764 group_ops_bls12381_g1_to_uncompressed_g1_cost: None,
2765 group_ops_bls12381_uncompressed_g1_to_g1_cost: None,
2766 group_ops_bls12381_uncompressed_g1_sum_base_cost: None,
2767 group_ops_bls12381_uncompressed_g1_sum_cost_per_term: None,
2768 group_ops_bls12381_uncompressed_g1_sum_max_terms: None,
2769
2770 group_ops_ristretto_decode_scalar_cost: None,
2771 group_ops_ristretto_decode_point_cost: None,
2772 group_ops_ristretto_scalar_add_cost: None,
2773 group_ops_ristretto_point_add_cost: None,
2774 group_ops_ristretto_scalar_sub_cost: None,
2775 group_ops_ristretto_point_sub_cost: None,
2776 group_ops_ristretto_scalar_mul_cost: None,
2777 group_ops_ristretto_point_mul_cost: None,
2778 group_ops_ristretto_scalar_div_cost: None,
2779 group_ops_ristretto_point_div_cost: None,
2780
2781 verify_bulletproofs_ristretto255_base_cost: None,
2782 verify_bulletproofs_ristretto255_cost_per_bit_and_commitment: None,
2783
2784 check_zklogin_id_cost_base: None,
2786 check_zklogin_issuer_cost_base: None,
2788
2789 vdf_verify_vdf_cost: None,
2790 vdf_hash_to_input_cost: None,
2791
2792 nitro_attestation_parse_base_cost: None,
2794 nitro_attestation_parse_cost_per_byte: None,
2795 nitro_attestation_verify_base_cost: None,
2796 nitro_attestation_verify_cost_per_cert: None,
2797
2798 bcs_per_byte_serialized_cost: None,
2799 bcs_legacy_min_output_size_cost: None,
2800 bcs_failure_cost: None,
2801 hash_sha2_256_base_cost: None,
2802 hash_sha2_256_per_byte_cost: None,
2803 hash_sha2_256_legacy_min_input_len_cost: None,
2804 hash_sha3_256_base_cost: None,
2805 hash_sha3_256_per_byte_cost: None,
2806 hash_sha3_256_legacy_min_input_len_cost: None,
2807 type_name_get_base_cost: None,
2808 type_name_get_per_byte_cost: None,
2809 type_name_id_base_cost: None,
2810 string_check_utf8_base_cost: None,
2811 string_check_utf8_per_byte_cost: None,
2812 string_is_char_boundary_base_cost: None,
2813 string_sub_string_base_cost: None,
2814 string_sub_string_per_byte_cost: None,
2815 string_index_of_base_cost: None,
2816 string_index_of_per_byte_pattern_cost: None,
2817 string_index_of_per_byte_searched_cost: None,
2818 vector_empty_base_cost: None,
2819 vector_length_base_cost: None,
2820 vector_push_back_base_cost: None,
2821 vector_push_back_legacy_per_abstract_memory_unit_cost: None,
2822 vector_borrow_base_cost: None,
2823 vector_pop_back_base_cost: None,
2824 vector_destroy_empty_base_cost: None,
2825 vector_swap_base_cost: None,
2826 debug_print_base_cost: None,
2827 debug_print_stack_trace_base_cost: None,
2828
2829 max_size_written_objects: None,
2830 max_size_written_objects_system_tx: None,
2831
2832 max_move_identifier_len: None,
2839 max_move_value_depth: None,
2840 max_move_enum_variants: None,
2841
2842 gas_rounding_step: None,
2843
2844 execution_version: None,
2845
2846 max_event_emit_size_total: None,
2847
2848 consensus_bad_nodes_stake_threshold: None,
2849
2850 max_jwk_votes_per_validator_per_epoch: None,
2851
2852 max_age_of_jwk_in_epochs: None,
2853
2854 random_beacon_reduction_allowed_delta: None,
2855
2856 random_beacon_reduction_lower_bound: None,
2857
2858 random_beacon_dkg_timeout_round: None,
2859
2860 random_beacon_min_round_interval_ms: None,
2861
2862 random_beacon_dkg_version: None,
2863
2864 consensus_max_transaction_size_bytes: None,
2865
2866 consensus_max_transactions_in_block_bytes: None,
2867
2868 consensus_max_num_transactions_in_block: None,
2869
2870 consensus_voting_rounds: None,
2871
2872 max_accumulated_txn_cost_per_object_in_narwhal_commit: None,
2873
2874 max_deferral_rounds_for_congestion_control: None,
2875
2876 max_txn_cost_overage_per_object_in_commit: None,
2877
2878 allowed_txn_cost_overage_burst_per_object_in_commit: None,
2879
2880 min_checkpoint_interval_ms: None,
2881
2882 checkpoint_summary_version_specific_data: None,
2883
2884 max_soft_bundle_size: None,
2885
2886 bridge_should_try_to_finalize_committee: None,
2887
2888 max_accumulated_txn_cost_per_object_in_mysticeti_commit: None,
2889
2890 max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit: None,
2891
2892 consensus_gc_depth: None,
2893
2894 gas_budget_based_txn_cost_cap_factor: None,
2895
2896 gas_budget_based_txn_cost_absolute_cap_commit_count: None,
2897
2898 sip_45_consensus_amplification_threshold: None,
2899
2900 use_object_per_epoch_marker_table_v2: None,
2901
2902 consensus_commit_rate_estimation_window_size: None,
2903
2904 aliased_addresses: vec![],
2905
2906 translation_per_command_base_charge: None,
2907 translation_per_input_base_charge: None,
2908 translation_pure_input_per_byte_charge: None,
2909 translation_per_type_node_charge: None,
2910 translation_per_reference_node_charge: None,
2911 translation_per_linkage_entry_charge: None,
2912
2913 max_updates_per_settlement_txn: None,
2914
2915 gasless_max_computation_units: None,
2916 gasless_allowed_token_types: None,
2917 gasless_max_unused_inputs: None,
2918 gasless_max_pure_input_bytes: None,
2919 gasless_max_tps: None,
2920 include_special_package_amendments: None,
2921 gasless_max_tx_size_bytes: None,
2922 };
2925 for cur in 2..=version.0 {
2926 match cur {
2927 1 => unreachable!(),
2928 2 => {
2929 cfg.feature_flags.advance_epoch_start_time_in_safe_mode = true;
2930 }
2931 3 => {
2932 cfg.gas_model_version = Some(2);
2934 cfg.max_tx_gas = Some(50_000_000_000);
2936 cfg.base_tx_cost_fixed = Some(2_000);
2938 cfg.storage_gas_price = Some(76);
2940 cfg.feature_flags.loaded_child_objects_fixed = true;
2941 cfg.max_size_written_objects = Some(5 * 1000 * 1000);
2944 cfg.max_size_written_objects_system_tx = Some(50 * 1000 * 1000);
2947 cfg.feature_flags.package_upgrades = true;
2948 }
2949 4 => {
2954 cfg.reward_slashing_rate = Some(10000);
2956 cfg.gas_model_version = Some(3);
2958 }
2959 5 => {
2960 cfg.feature_flags.missing_type_is_compatibility_error = true;
2961 cfg.gas_model_version = Some(4);
2962 cfg.feature_flags.scoring_decision_with_validity_cutoff = true;
2963 }
2967 6 => {
2968 cfg.gas_model_version = Some(5);
2969 cfg.buffer_stake_for_protocol_upgrade_bps = Some(5000);
2970 cfg.feature_flags.consensus_order_end_of_epoch_last = true;
2971 }
2972 7 => {
2973 cfg.feature_flags.disallow_adding_abilities_on_upgrade = true;
2974 cfg.feature_flags
2975 .disable_invariant_violation_check_in_swap_loc = true;
2976 cfg.feature_flags.ban_entry_init = true;
2977 cfg.feature_flags.package_digest_hash_module = true;
2978 }
2979 8 => {
2980 cfg.feature_flags
2981 .disallow_change_struct_type_params_on_upgrade = true;
2982 }
2983 9 => {
2984 cfg.max_move_identifier_len = Some(128);
2986 cfg.feature_flags.no_extraneous_module_bytes = true;
2987 cfg.feature_flags
2988 .advance_to_highest_supported_protocol_version = true;
2989 }
2990 10 => {
2991 cfg.max_verifier_meter_ticks_per_function = Some(16_000_000);
2992 cfg.max_meter_ticks_per_module = Some(16_000_000);
2993 }
2994 11 => {
2995 cfg.max_move_value_depth = Some(128);
2996 }
2997 12 => {
2998 cfg.feature_flags.narwhal_versioned_metadata = true;
2999 if chain != Chain::Mainnet {
3000 cfg.feature_flags.commit_root_state_digest = true;
3001 }
3002
3003 if chain != Chain::Mainnet && chain != Chain::Testnet {
3004 cfg.feature_flags.zklogin_auth = true;
3005 }
3006 }
3007 13 => {}
3008 14 => {
3009 cfg.gas_rounding_step = Some(1_000);
3010 cfg.gas_model_version = Some(6);
3011 }
3012 15 => {
3013 cfg.feature_flags.consensus_transaction_ordering =
3014 ConsensusTransactionOrdering::ByGasPrice;
3015 }
3016 16 => {
3017 cfg.feature_flags.simplified_unwrap_then_delete = true;
3018 }
3019 17 => {
3020 cfg.feature_flags.upgraded_multisig_supported = true;
3021 }
3022 18 => {
3023 cfg.execution_version = Some(1);
3024 cfg.feature_flags.txn_base_cost_as_multiplier = true;
3033 cfg.base_tx_cost_fixed = Some(1_000);
3035 }
3036 19 => {
3037 cfg.max_num_event_emit = Some(1024);
3038 cfg.max_event_emit_size_total = Some(
3041 256 * 250 * 1024, );
3043 }
3044 20 => {
3045 cfg.feature_flags.commit_root_state_digest = true;
3046
3047 if chain != Chain::Mainnet {
3048 cfg.feature_flags.narwhal_new_leader_election_schedule = true;
3049 cfg.consensus_bad_nodes_stake_threshold = Some(20);
3050 }
3051 }
3052
3053 21 => {
3054 if chain != Chain::Mainnet {
3055 cfg.feature_flags.zklogin_supported_providers = BTreeSet::from([
3056 "Google".to_string(),
3057 "Facebook".to_string(),
3058 "Twitch".to_string(),
3059 ]);
3060 }
3061 }
3062 22 => {
3063 cfg.feature_flags.loaded_child_object_format = true;
3064 }
3065 23 => {
3066 cfg.feature_flags.loaded_child_object_format_type = true;
3067 cfg.feature_flags.narwhal_new_leader_election_schedule = true;
3068 cfg.consensus_bad_nodes_stake_threshold = Some(20);
3074 }
3075 24 => {
3076 cfg.feature_flags.simple_conservation_checks = true;
3077 cfg.max_publish_or_upgrade_per_ptb = Some(5);
3078
3079 cfg.feature_flags.end_of_epoch_transaction_supported = true;
3080
3081 if chain != Chain::Mainnet {
3082 cfg.feature_flags.enable_jwk_consensus_updates = true;
3083 cfg.max_jwk_votes_per_validator_per_epoch = Some(240);
3085 cfg.max_age_of_jwk_in_epochs = Some(1);
3086 }
3087 }
3088 25 => {
3089 cfg.feature_flags.zklogin_supported_providers = BTreeSet::from([
3091 "Google".to_string(),
3092 "Facebook".to_string(),
3093 "Twitch".to_string(),
3094 ]);
3095 cfg.feature_flags.zklogin_auth = true;
3096
3097 cfg.feature_flags.enable_jwk_consensus_updates = true;
3099 cfg.max_jwk_votes_per_validator_per_epoch = Some(240);
3100 cfg.max_age_of_jwk_in_epochs = Some(1);
3101 }
3102 26 => {
3103 cfg.gas_model_version = Some(7);
3104 if chain != Chain::Mainnet && chain != Chain::Testnet {
3106 cfg.transfer_receive_object_cost_base = Some(52);
3107 cfg.feature_flags.receive_objects = true;
3108 }
3109 }
3110 27 => {
3111 cfg.gas_model_version = Some(8);
3112 }
3113 28 => {
3114 cfg.check_zklogin_id_cost_base = Some(200);
3116 cfg.check_zklogin_issuer_cost_base = Some(200);
3118
3119 if chain != Chain::Mainnet && chain != Chain::Testnet {
3121 cfg.feature_flags.enable_effects_v2 = true;
3122 }
3123 }
3124 29 => {
3125 cfg.feature_flags.verify_legacy_zklogin_address = true;
3126 }
3127 30 => {
3128 if chain != Chain::Mainnet {
3130 cfg.feature_flags.narwhal_certificate_v2 = true;
3131 }
3132
3133 cfg.random_beacon_reduction_allowed_delta = Some(800);
3134 if chain != Chain::Mainnet {
3136 cfg.feature_flags.enable_effects_v2 = true;
3137 }
3138
3139 cfg.feature_flags.zklogin_supported_providers = BTreeSet::default();
3143
3144 cfg.feature_flags.recompute_has_public_transfer_in_execution = true;
3145 }
3146 31 => {
3147 cfg.execution_version = Some(2);
3148 if chain != Chain::Mainnet && chain != Chain::Testnet {
3150 cfg.feature_flags.shared_object_deletion = true;
3151 }
3152 }
3153 32 => {
3154 if chain != Chain::Mainnet {
3156 cfg.feature_flags.accept_zklogin_in_multisig = true;
3157 }
3158 if chain != Chain::Mainnet {
3160 cfg.transfer_receive_object_cost_base = Some(52);
3161 cfg.feature_flags.receive_objects = true;
3162 }
3163 if chain != Chain::Mainnet && chain != Chain::Testnet {
3165 cfg.feature_flags.random_beacon = true;
3166 cfg.random_beacon_reduction_lower_bound = Some(1600);
3167 cfg.random_beacon_dkg_timeout_round = Some(3000);
3168 cfg.random_beacon_min_round_interval_ms = Some(150);
3169 }
3170 if chain != Chain::Testnet && chain != Chain::Mainnet {
3172 cfg.feature_flags.include_consensus_digest_in_prologue = true;
3173 }
3174
3175 cfg.feature_flags.narwhal_certificate_v2 = true;
3177 }
3178 33 => {
3179 cfg.feature_flags.hardened_otw_check = true;
3180 cfg.feature_flags.allow_receiving_object_id = true;
3181
3182 cfg.transfer_receive_object_cost_base = Some(52);
3184 cfg.feature_flags.receive_objects = true;
3185
3186 if chain != Chain::Mainnet {
3188 cfg.feature_flags.shared_object_deletion = true;
3189 }
3190
3191 cfg.feature_flags.enable_effects_v2 = true;
3192 }
3193 34 => {}
3194 35 => {
3195 if chain != Chain::Mainnet && chain != Chain::Testnet {
3197 cfg.feature_flags.enable_poseidon = true;
3198 cfg.poseidon_bn254_cost_base = Some(260);
3199 cfg.poseidon_bn254_cost_per_block = Some(10);
3200 }
3201
3202 cfg.feature_flags.enable_coin_deny_list = true;
3203 }
3204 36 => {
3205 if chain != Chain::Mainnet && chain != Chain::Testnet {
3207 cfg.feature_flags.enable_group_ops_native_functions = true;
3208 cfg.feature_flags.enable_group_ops_native_function_msm = true;
3209 cfg.group_ops_bls12381_decode_scalar_cost = Some(52);
3211 cfg.group_ops_bls12381_decode_g1_cost = Some(52);
3212 cfg.group_ops_bls12381_decode_g2_cost = Some(52);
3213 cfg.group_ops_bls12381_decode_gt_cost = Some(52);
3214 cfg.group_ops_bls12381_scalar_add_cost = Some(52);
3215 cfg.group_ops_bls12381_g1_add_cost = Some(52);
3216 cfg.group_ops_bls12381_g2_add_cost = Some(52);
3217 cfg.group_ops_bls12381_gt_add_cost = Some(52);
3218 cfg.group_ops_bls12381_scalar_sub_cost = Some(52);
3219 cfg.group_ops_bls12381_g1_sub_cost = Some(52);
3220 cfg.group_ops_bls12381_g2_sub_cost = Some(52);
3221 cfg.group_ops_bls12381_gt_sub_cost = Some(52);
3222 cfg.group_ops_bls12381_scalar_mul_cost = Some(52);
3223 cfg.group_ops_bls12381_g1_mul_cost = Some(52);
3224 cfg.group_ops_bls12381_g2_mul_cost = Some(52);
3225 cfg.group_ops_bls12381_gt_mul_cost = Some(52);
3226 cfg.group_ops_bls12381_scalar_div_cost = Some(52);
3227 cfg.group_ops_bls12381_g1_div_cost = Some(52);
3228 cfg.group_ops_bls12381_g2_div_cost = Some(52);
3229 cfg.group_ops_bls12381_gt_div_cost = Some(52);
3230 cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(52);
3231 cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(52);
3232 cfg.group_ops_bls12381_g1_hash_to_cost_per_byte = Some(2);
3233 cfg.group_ops_bls12381_g2_hash_to_cost_per_byte = Some(2);
3234 cfg.group_ops_bls12381_g1_msm_base_cost = Some(52);
3235 cfg.group_ops_bls12381_g2_msm_base_cost = Some(52);
3236 cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(52);
3237 cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(52);
3238 cfg.group_ops_bls12381_msm_max_len = Some(32);
3239 cfg.group_ops_bls12381_pairing_cost = Some(52);
3240 }
3241 cfg.feature_flags.shared_object_deletion = true;
3243
3244 cfg.consensus_max_transaction_size_bytes = Some(256 * 1024); cfg.consensus_max_transactions_in_block_bytes = Some(6 * 1_024 * 1024);
3246 }
3248 37 => {
3249 cfg.feature_flags.reject_mutable_random_on_entry_functions = true;
3250
3251 if chain != Chain::Mainnet {
3253 cfg.feature_flags.include_consensus_digest_in_prologue = true;
3254 }
3255 }
3256 38 => {
3257 cfg.binary_module_handles = Some(100);
3258 cfg.binary_struct_handles = Some(300);
3259 cfg.binary_function_handles = Some(1500);
3260 cfg.binary_function_instantiations = Some(750);
3261 cfg.binary_signatures = Some(1000);
3262 cfg.binary_constant_pool = Some(4000);
3266 cfg.binary_identifiers = Some(10000);
3267 cfg.binary_address_identifiers = Some(100);
3268 cfg.binary_struct_defs = Some(200);
3269 cfg.binary_struct_def_instantiations = Some(100);
3270 cfg.binary_function_defs = Some(1000);
3271 cfg.binary_field_handles = Some(500);
3272 cfg.binary_field_instantiations = Some(250);
3273 cfg.binary_friend_decls = Some(100);
3274 cfg.max_package_dependencies = Some(32);
3276 cfg.max_modules_in_publish = Some(64);
3277 cfg.execution_version = Some(3);
3279 }
3280 39 => {
3281 }
3283 40 => {}
3284 41 => {
3285 cfg.feature_flags.enable_group_ops_native_functions = true;
3287 cfg.group_ops_bls12381_decode_scalar_cost = Some(52);
3289 cfg.group_ops_bls12381_decode_g1_cost = Some(52);
3290 cfg.group_ops_bls12381_decode_g2_cost = Some(52);
3291 cfg.group_ops_bls12381_decode_gt_cost = Some(52);
3292 cfg.group_ops_bls12381_scalar_add_cost = Some(52);
3293 cfg.group_ops_bls12381_g1_add_cost = Some(52);
3294 cfg.group_ops_bls12381_g2_add_cost = Some(52);
3295 cfg.group_ops_bls12381_gt_add_cost = Some(52);
3296 cfg.group_ops_bls12381_scalar_sub_cost = Some(52);
3297 cfg.group_ops_bls12381_g1_sub_cost = Some(52);
3298 cfg.group_ops_bls12381_g2_sub_cost = Some(52);
3299 cfg.group_ops_bls12381_gt_sub_cost = Some(52);
3300 cfg.group_ops_bls12381_scalar_mul_cost = Some(52);
3301 cfg.group_ops_bls12381_g1_mul_cost = Some(52);
3302 cfg.group_ops_bls12381_g2_mul_cost = Some(52);
3303 cfg.group_ops_bls12381_gt_mul_cost = Some(52);
3304 cfg.group_ops_bls12381_scalar_div_cost = Some(52);
3305 cfg.group_ops_bls12381_g1_div_cost = Some(52);
3306 cfg.group_ops_bls12381_g2_div_cost = Some(52);
3307 cfg.group_ops_bls12381_gt_div_cost = Some(52);
3308 cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(52);
3309 cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(52);
3310 cfg.group_ops_bls12381_g1_hash_to_cost_per_byte = Some(2);
3311 cfg.group_ops_bls12381_g2_hash_to_cost_per_byte = Some(2);
3312 cfg.group_ops_bls12381_g1_msm_base_cost = Some(52);
3313 cfg.group_ops_bls12381_g2_msm_base_cost = Some(52);
3314 cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(52);
3315 cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(52);
3316 cfg.group_ops_bls12381_msm_max_len = Some(32);
3317 cfg.group_ops_bls12381_pairing_cost = Some(52);
3318 }
3319 42 => {}
3320 43 => {
3321 cfg.feature_flags.zklogin_max_epoch_upper_bound_delta = Some(30);
3322 cfg.max_meter_ticks_per_package = Some(16_000_000);
3323 }
3324 44 => {
3325 cfg.feature_flags.include_consensus_digest_in_prologue = true;
3327 if chain != Chain::Mainnet {
3329 cfg.feature_flags.consensus_choice = ConsensusChoice::SwapEachEpoch;
3330 }
3331 }
3332 45 => {
3333 if chain != Chain::Testnet && chain != Chain::Mainnet {
3335 cfg.feature_flags.consensus_network = ConsensusNetwork::Tonic;
3336 }
3337
3338 if chain != Chain::Mainnet {
3339 cfg.feature_flags.mysticeti_leader_scoring_and_schedule = true;
3341 }
3342 cfg.min_move_binary_format_version = Some(6);
3343 cfg.feature_flags.accept_zklogin_in_multisig = true;
3344
3345 if chain != Chain::Mainnet && chain != Chain::Testnet {
3349 cfg.feature_flags.bridge = true;
3350 }
3351 }
3352 46 => {
3353 if chain != Chain::Mainnet {
3355 cfg.feature_flags.bridge = true;
3356 }
3357
3358 cfg.feature_flags.reshare_at_same_initial_version = true;
3360 }
3361 47 => {}
3362 48 => {
3363 cfg.feature_flags.consensus_network = ConsensusNetwork::Tonic;
3365
3366 cfg.feature_flags.resolve_abort_locations_to_package_id = true;
3368
3369 if chain != Chain::Mainnet {
3371 cfg.feature_flags.random_beacon = true;
3372 cfg.random_beacon_reduction_lower_bound = Some(1600);
3373 cfg.random_beacon_dkg_timeout_round = Some(3000);
3374 cfg.random_beacon_min_round_interval_ms = Some(200);
3375 }
3376
3377 cfg.feature_flags.mysticeti_use_committed_subdag_digest = true;
3379 }
3380 49 => {
3381 if chain != Chain::Testnet && chain != Chain::Mainnet {
3382 cfg.move_binary_format_version = Some(7);
3383 }
3384
3385 if chain != Chain::Mainnet && chain != Chain::Testnet {
3387 cfg.feature_flags.enable_vdf = true;
3388 cfg.vdf_verify_vdf_cost = Some(1500);
3391 cfg.vdf_hash_to_input_cost = Some(100);
3392 }
3393
3394 if chain != Chain::Testnet && chain != Chain::Mainnet {
3396 cfg.feature_flags
3397 .record_consensus_determined_version_assignments_in_prologue = true;
3398 }
3399
3400 if chain != Chain::Mainnet {
3402 cfg.feature_flags.consensus_choice = ConsensusChoice::Mysticeti;
3403 }
3404
3405 cfg.feature_flags.fresh_vm_on_framework_upgrade = true;
3407 }
3408 50 => {
3409 if chain != Chain::Mainnet {
3411 cfg.checkpoint_summary_version_specific_data = Some(1);
3412 cfg.min_checkpoint_interval_ms = Some(200);
3413 }
3414
3415 if chain != Chain::Testnet && chain != Chain::Mainnet {
3417 cfg.feature_flags
3418 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = true;
3419 }
3420
3421 cfg.feature_flags.mysticeti_num_leaders_per_round = Some(1);
3422
3423 cfg.max_deferral_rounds_for_congestion_control = Some(10);
3425 }
3426 51 => {
3427 cfg.random_beacon_dkg_version = Some(1);
3428
3429 if chain != Chain::Testnet && chain != Chain::Mainnet {
3430 cfg.feature_flags.enable_coin_deny_list_v2 = true;
3431 }
3432 }
3433 52 => {
3434 if chain != Chain::Mainnet {
3435 cfg.feature_flags.soft_bundle = true;
3436 cfg.max_soft_bundle_size = Some(5);
3437 }
3438
3439 cfg.config_read_setting_impl_cost_base = Some(100);
3440 cfg.config_read_setting_impl_cost_per_byte = Some(40);
3441
3442 if chain != Chain::Testnet && chain != Chain::Mainnet {
3444 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(100);
3445 cfg.feature_flags.per_object_congestion_control_mode =
3446 PerObjectCongestionControlMode::TotalTxCount;
3447 }
3448
3449 cfg.feature_flags.consensus_choice = ConsensusChoice::Mysticeti;
3451
3452 cfg.feature_flags.mysticeti_leader_scoring_and_schedule = true;
3454
3455 cfg.checkpoint_summary_version_specific_data = Some(1);
3457 cfg.min_checkpoint_interval_ms = Some(200);
3458
3459 if chain != Chain::Mainnet {
3461 cfg.feature_flags
3462 .record_consensus_determined_version_assignments_in_prologue = true;
3463 cfg.feature_flags
3464 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = true;
3465 }
3466 if chain != Chain::Mainnet {
3468 cfg.move_binary_format_version = Some(7);
3469 }
3470
3471 if chain != Chain::Testnet && chain != Chain::Mainnet {
3472 cfg.feature_flags.passkey_auth = true;
3473 }
3474 cfg.feature_flags.enable_coin_deny_list_v2 = true;
3475 }
3476 53 => {
3477 cfg.bridge_should_try_to_finalize_committee = Some(chain != Chain::Mainnet);
3479
3480 cfg.feature_flags
3482 .record_consensus_determined_version_assignments_in_prologue = true;
3483 cfg.feature_flags
3484 .prepend_prologue_tx_in_consensus_commit_in_checkpoints = true;
3485
3486 if chain == Chain::Unknown {
3487 cfg.feature_flags.authority_capabilities_v2 = true;
3488 }
3489
3490 if chain != Chain::Mainnet {
3492 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(100);
3493 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(10);
3494 cfg.feature_flags.per_object_congestion_control_mode =
3495 PerObjectCongestionControlMode::TotalTxCount;
3496 }
3497
3498 cfg.bcs_per_byte_serialized_cost = Some(2);
3500 cfg.bcs_legacy_min_output_size_cost = Some(1);
3501 cfg.bcs_failure_cost = Some(52);
3502 cfg.debug_print_base_cost = Some(52);
3503 cfg.debug_print_stack_trace_base_cost = Some(52);
3504 cfg.hash_sha2_256_base_cost = Some(52);
3505 cfg.hash_sha2_256_per_byte_cost = Some(2);
3506 cfg.hash_sha2_256_legacy_min_input_len_cost = Some(1);
3507 cfg.hash_sha3_256_base_cost = Some(52);
3508 cfg.hash_sha3_256_per_byte_cost = Some(2);
3509 cfg.hash_sha3_256_legacy_min_input_len_cost = Some(1);
3510 cfg.type_name_get_base_cost = Some(52);
3511 cfg.type_name_get_per_byte_cost = Some(2);
3512 cfg.string_check_utf8_base_cost = Some(52);
3513 cfg.string_check_utf8_per_byte_cost = Some(2);
3514 cfg.string_is_char_boundary_base_cost = Some(52);
3515 cfg.string_sub_string_base_cost = Some(52);
3516 cfg.string_sub_string_per_byte_cost = Some(2);
3517 cfg.string_index_of_base_cost = Some(52);
3518 cfg.string_index_of_per_byte_pattern_cost = Some(2);
3519 cfg.string_index_of_per_byte_searched_cost = Some(2);
3520 cfg.vector_empty_base_cost = Some(52);
3521 cfg.vector_length_base_cost = Some(52);
3522 cfg.vector_push_back_base_cost = Some(52);
3523 cfg.vector_push_back_legacy_per_abstract_memory_unit_cost = Some(2);
3524 cfg.vector_borrow_base_cost = Some(52);
3525 cfg.vector_pop_back_base_cost = Some(52);
3526 cfg.vector_destroy_empty_base_cost = Some(52);
3527 cfg.vector_swap_base_cost = Some(52);
3528 }
3529 54 => {
3530 cfg.feature_flags.random_beacon = true;
3532 cfg.random_beacon_reduction_lower_bound = Some(1000);
3533 cfg.random_beacon_dkg_timeout_round = Some(3000);
3534 cfg.random_beacon_min_round_interval_ms = Some(500);
3535
3536 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(100);
3538 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(10);
3539 cfg.feature_flags.per_object_congestion_control_mode =
3540 PerObjectCongestionControlMode::TotalTxCount;
3541
3542 cfg.feature_flags.soft_bundle = true;
3544 cfg.max_soft_bundle_size = Some(5);
3545 }
3546 55 => {
3547 cfg.move_binary_format_version = Some(7);
3549
3550 cfg.consensus_max_transactions_in_block_bytes = Some(512 * 1024);
3552 cfg.consensus_max_num_transactions_in_block = Some(512);
3555
3556 cfg.feature_flags.rethrow_serialization_type_layout_errors = true;
3557 }
3558 56 => {
3559 if chain == Chain::Mainnet {
3560 cfg.feature_flags.bridge = true;
3561 }
3562 }
3563 57 => {
3564 cfg.random_beacon_reduction_lower_bound = Some(800);
3566 }
3567 58 => {
3568 if chain == Chain::Mainnet {
3569 cfg.bridge_should_try_to_finalize_committee = Some(true);
3570 }
3571
3572 if chain != Chain::Mainnet && chain != Chain::Testnet {
3573 cfg.feature_flags
3575 .consensus_distributed_vote_scoring_strategy = true;
3576 }
3577 }
3578 59 => {
3579 cfg.feature_flags.consensus_round_prober = true;
3581 }
3582 60 => {
3583 cfg.max_type_to_layout_nodes = Some(512);
3584 cfg.feature_flags.validate_identifier_inputs = true;
3585 }
3586 61 => {
3587 if chain != Chain::Mainnet {
3588 cfg.feature_flags
3590 .consensus_distributed_vote_scoring_strategy = true;
3591 }
3592 cfg.random_beacon_reduction_lower_bound = Some(700);
3594
3595 if chain != Chain::Mainnet && chain != Chain::Testnet {
3596 cfg.feature_flags.mysticeti_fastpath = true;
3598 }
3599 }
3600 62 => {
3601 cfg.feature_flags.relocate_event_module = true;
3602 }
3603 63 => {
3604 cfg.feature_flags.per_object_congestion_control_mode =
3605 PerObjectCongestionControlMode::TotalGasBudgetWithCap;
3606 cfg.gas_budget_based_txn_cost_cap_factor = Some(400_000);
3607 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(18_500_000);
3608 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(240_000_000);
3609 }
3610 64 => {
3611 cfg.feature_flags.per_object_congestion_control_mode =
3612 PerObjectCongestionControlMode::TotalTxCount;
3613 cfg.max_accumulated_txn_cost_per_object_in_narwhal_commit = Some(40);
3614 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(3);
3615 }
3616 65 => {
3617 cfg.feature_flags
3619 .consensus_distributed_vote_scoring_strategy = true;
3620 }
3621 66 => {
3622 if chain == Chain::Mainnet {
3623 cfg.feature_flags
3625 .consensus_distributed_vote_scoring_strategy = false;
3626 }
3627 }
3628 67 => {
3629 cfg.feature_flags
3631 .consensus_distributed_vote_scoring_strategy = true;
3632 }
3633 68 => {
3634 cfg.group_ops_bls12381_g1_to_uncompressed_g1_cost = Some(26);
3635 cfg.group_ops_bls12381_uncompressed_g1_to_g1_cost = Some(52);
3636 cfg.group_ops_bls12381_uncompressed_g1_sum_base_cost = Some(26);
3637 cfg.group_ops_bls12381_uncompressed_g1_sum_cost_per_term = Some(13);
3638 cfg.group_ops_bls12381_uncompressed_g1_sum_max_terms = Some(2000);
3639
3640 if chain != Chain::Mainnet && chain != Chain::Testnet {
3641 cfg.feature_flags.uncompressed_g1_group_elements = true;
3642 }
3643
3644 cfg.feature_flags.per_object_congestion_control_mode =
3645 PerObjectCongestionControlMode::TotalGasBudgetWithCap;
3646 cfg.gas_budget_based_txn_cost_cap_factor = Some(400_000);
3647 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(18_500_000);
3648 cfg.max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit =
3649 Some(3_700_000); cfg.max_txn_cost_overage_per_object_in_commit = Some(u64::MAX);
3651 cfg.gas_budget_based_txn_cost_absolute_cap_commit_count = Some(50);
3652
3653 cfg.random_beacon_reduction_lower_bound = Some(500);
3655
3656 cfg.feature_flags.disallow_new_modules_in_deps_only_packages = true;
3657 }
3658 69 => {
3659 cfg.consensus_voting_rounds = Some(40);
3661
3662 if chain != Chain::Mainnet && chain != Chain::Testnet {
3663 cfg.feature_flags.consensus_smart_ancestor_selection = true;
3665 }
3666
3667 if chain != Chain::Mainnet {
3668 cfg.feature_flags.uncompressed_g1_group_elements = true;
3669 }
3670 }
3671 70 => {
3672 if chain != Chain::Mainnet {
3673 cfg.feature_flags.consensus_smart_ancestor_selection = true;
3675 cfg.feature_flags
3677 .consensus_round_prober_probe_accepted_rounds = true;
3678 }
3679
3680 cfg.poseidon_bn254_cost_per_block = Some(388);
3681
3682 cfg.gas_model_version = Some(9);
3683 cfg.feature_flags.native_charging_v2 = true;
3684 cfg.bls12381_bls12381_min_sig_verify_cost_base = Some(44064);
3685 cfg.bls12381_bls12381_min_pk_verify_cost_base = Some(49282);
3686 cfg.ecdsa_k1_secp256k1_verify_keccak256_cost_base = Some(1470);
3687 cfg.ecdsa_k1_secp256k1_verify_sha256_cost_base = Some(1470);
3688 cfg.ecdsa_r1_secp256r1_verify_sha256_cost_base = Some(4225);
3689 cfg.ecdsa_r1_secp256r1_verify_keccak256_cost_base = Some(4225);
3690 cfg.ecvrf_ecvrf_verify_cost_base = Some(4848);
3691 cfg.ed25519_ed25519_verify_cost_base = Some(1802);
3692
3693 cfg.ecdsa_r1_ecrecover_keccak256_cost_base = Some(1173);
3695 cfg.ecdsa_r1_ecrecover_sha256_cost_base = Some(1173);
3696 cfg.ecdsa_k1_ecrecover_keccak256_cost_base = Some(500);
3697 cfg.ecdsa_k1_ecrecover_sha256_cost_base = Some(500);
3698
3699 cfg.groth16_prepare_verifying_key_bls12381_cost_base = Some(53838);
3700 cfg.groth16_prepare_verifying_key_bn254_cost_base = Some(82010);
3701 cfg.groth16_verify_groth16_proof_internal_bls12381_cost_base = Some(72090);
3702 cfg.groth16_verify_groth16_proof_internal_bls12381_cost_per_public_input =
3703 Some(8213);
3704 cfg.groth16_verify_groth16_proof_internal_bn254_cost_base = Some(115502);
3705 cfg.groth16_verify_groth16_proof_internal_bn254_cost_per_public_input =
3706 Some(9484);
3707
3708 cfg.hash_keccak256_cost_base = Some(10);
3709 cfg.hash_blake2b256_cost_base = Some(10);
3710
3711 cfg.group_ops_bls12381_decode_scalar_cost = Some(7);
3713 cfg.group_ops_bls12381_decode_g1_cost = Some(2848);
3714 cfg.group_ops_bls12381_decode_g2_cost = Some(3770);
3715 cfg.group_ops_bls12381_decode_gt_cost = Some(3068);
3716
3717 cfg.group_ops_bls12381_scalar_add_cost = Some(10);
3718 cfg.group_ops_bls12381_g1_add_cost = Some(1556);
3719 cfg.group_ops_bls12381_g2_add_cost = Some(3048);
3720 cfg.group_ops_bls12381_gt_add_cost = Some(188);
3721
3722 cfg.group_ops_bls12381_scalar_sub_cost = Some(10);
3723 cfg.group_ops_bls12381_g1_sub_cost = Some(1550);
3724 cfg.group_ops_bls12381_g2_sub_cost = Some(3019);
3725 cfg.group_ops_bls12381_gt_sub_cost = Some(497);
3726
3727 cfg.group_ops_bls12381_scalar_mul_cost = Some(11);
3728 cfg.group_ops_bls12381_g1_mul_cost = Some(4842);
3729 cfg.group_ops_bls12381_g2_mul_cost = Some(9108);
3730 cfg.group_ops_bls12381_gt_mul_cost = Some(27490);
3731
3732 cfg.group_ops_bls12381_scalar_div_cost = Some(91);
3733 cfg.group_ops_bls12381_g1_div_cost = Some(5091);
3734 cfg.group_ops_bls12381_g2_div_cost = Some(9206);
3735 cfg.group_ops_bls12381_gt_div_cost = Some(27804);
3736
3737 cfg.group_ops_bls12381_g1_hash_to_base_cost = Some(2962);
3738 cfg.group_ops_bls12381_g2_hash_to_base_cost = Some(8688);
3739
3740 cfg.group_ops_bls12381_g1_msm_base_cost = Some(62648);
3741 cfg.group_ops_bls12381_g2_msm_base_cost = Some(131192);
3742 cfg.group_ops_bls12381_g1_msm_base_cost_per_input = Some(1333);
3743 cfg.group_ops_bls12381_g2_msm_base_cost_per_input = Some(3216);
3744
3745 cfg.group_ops_bls12381_uncompressed_g1_to_g1_cost = Some(677);
3746 cfg.group_ops_bls12381_g1_to_uncompressed_g1_cost = Some(2099);
3747 cfg.group_ops_bls12381_uncompressed_g1_sum_base_cost = Some(77);
3748 cfg.group_ops_bls12381_uncompressed_g1_sum_cost_per_term = Some(26);
3749
3750 cfg.group_ops_bls12381_pairing_cost = Some(26897);
3751 cfg.group_ops_bls12381_uncompressed_g1_sum_max_terms = Some(1200);
3752
3753 cfg.validator_validate_metadata_cost_base = Some(20000);
3754 }
3755 71 => {
3756 cfg.sip_45_consensus_amplification_threshold = Some(5);
3757
3758 cfg.allowed_txn_cost_overage_burst_per_object_in_commit = Some(185_000_000);
3760 }
3761 72 => {
3762 cfg.feature_flags.convert_type_argument_error = true;
3763
3764 cfg.max_tx_gas = Some(50_000_000_000_000);
3767 cfg.max_gas_price = Some(50_000_000_000);
3769
3770 cfg.feature_flags.variant_nodes = true;
3771 }
3772 73 => {
3773 cfg.use_object_per_epoch_marker_table_v2 = Some(true);
3775
3776 if chain != Chain::Mainnet && chain != Chain::Testnet {
3777 cfg.consensus_gc_depth = Some(60);
3780 }
3781
3782 if chain != Chain::Mainnet {
3783 cfg.feature_flags.consensus_zstd_compression = true;
3785 }
3786
3787 cfg.feature_flags.consensus_smart_ancestor_selection = true;
3789 cfg.feature_flags
3791 .consensus_round_prober_probe_accepted_rounds = true;
3792
3793 cfg.feature_flags.per_object_congestion_control_mode =
3795 PerObjectCongestionControlMode::TotalGasBudgetWithCap;
3796 cfg.gas_budget_based_txn_cost_cap_factor = Some(400_000);
3797 cfg.max_accumulated_txn_cost_per_object_in_mysticeti_commit = Some(37_000_000);
3798 cfg.max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit =
3799 Some(7_400_000); cfg.max_txn_cost_overage_per_object_in_commit = Some(u64::MAX);
3801 cfg.gas_budget_based_txn_cost_absolute_cap_commit_count = Some(50);
3802 cfg.allowed_txn_cost_overage_burst_per_object_in_commit = Some(370_000_000);
3803 }
3804 74 => {
3805 if chain != Chain::Mainnet && chain != Chain::Testnet {
3807 cfg.feature_flags.enable_nitro_attestation = true;
3808 }
3809 cfg.nitro_attestation_parse_base_cost = Some(53 * 50);
3810 cfg.nitro_attestation_parse_cost_per_byte = Some(50);
3811 cfg.nitro_attestation_verify_base_cost = Some(49632 * 50);
3812 cfg.nitro_attestation_verify_cost_per_cert = Some(52369 * 50);
3813
3814 cfg.feature_flags.consensus_zstd_compression = true;
3816
3817 if chain != Chain::Mainnet && chain != Chain::Testnet {
3818 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
3819 }
3820 }
3821 75 => {
3822 if chain != Chain::Mainnet {
3823 cfg.feature_flags.passkey_auth = true;
3824 }
3825 }
3826 76 => {
3827 if chain != Chain::Mainnet && chain != Chain::Testnet {
3828 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
3829 cfg.consensus_commit_rate_estimation_window_size = Some(10);
3830 }
3831 cfg.feature_flags.minimize_child_object_mutations = true;
3832
3833 if chain != Chain::Mainnet {
3834 cfg.feature_flags.accept_passkey_in_multisig = true;
3835 }
3836 }
3837 77 => {
3838 cfg.feature_flags.uncompressed_g1_group_elements = true;
3839
3840 if chain != Chain::Mainnet {
3841 cfg.consensus_gc_depth = Some(60);
3842 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
3843 }
3844 }
3845 78 => {
3846 cfg.feature_flags.move_native_context = true;
3847 cfg.tx_context_fresh_id_cost_base = Some(52);
3848 cfg.tx_context_sender_cost_base = Some(30);
3849 cfg.tx_context_epoch_cost_base = Some(30);
3850 cfg.tx_context_epoch_timestamp_ms_cost_base = Some(30);
3851 cfg.tx_context_sponsor_cost_base = Some(30);
3852 cfg.tx_context_gas_price_cost_base = Some(30);
3853 cfg.tx_context_gas_budget_cost_base = Some(30);
3854 cfg.tx_context_ids_created_cost_base = Some(30);
3855 cfg.tx_context_replace_cost_base = Some(30);
3856 cfg.gas_model_version = Some(10);
3857
3858 if chain != Chain::Mainnet {
3859 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
3860 cfg.consensus_commit_rate_estimation_window_size = Some(10);
3861
3862 cfg.feature_flags.per_object_congestion_control_mode =
3864 PerObjectCongestionControlMode::ExecutionTimeEstimate(
3865 ExecutionTimeEstimateParams {
3866 target_utilization: 30,
3867 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
3869 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
3871 stored_observations_limit: u64::MAX,
3872 stake_weighted_median_threshold: 0,
3873 default_none_duration_for_new_keys: false,
3874 observations_chunk_size: None,
3875 },
3876 );
3877 }
3878 }
3879 79 => {
3880 if chain != Chain::Mainnet {
3881 cfg.feature_flags.consensus_median_based_commit_timestamp = true;
3882
3883 cfg.consensus_bad_nodes_stake_threshold = Some(30);
3886
3887 cfg.feature_flags.consensus_batched_block_sync = true;
3888
3889 cfg.feature_flags.enable_nitro_attestation = true
3891 }
3892 cfg.feature_flags.normalize_ptb_arguments = true;
3893
3894 cfg.consensus_gc_depth = Some(60);
3895 cfg.feature_flags.consensus_linearize_subdag_v2 = true;
3896 }
3897 80 => {
3898 cfg.max_ptb_value_size = Some(1024 * 1024);
3899 }
3900 81 => {
3901 cfg.feature_flags.consensus_median_based_commit_timestamp = true;
3902 cfg.feature_flags.enforce_checkpoint_timestamp_monotonicity = true;
3903 cfg.consensus_bad_nodes_stake_threshold = Some(30)
3904 }
3905 82 => {
3906 cfg.feature_flags.max_ptb_value_size_v2 = true;
3907 }
3908 83 => {
3909 if chain == Chain::Mainnet {
3910 let aliased: [u8; 32] = Hex::decode(
3912 "0x0b2da327ba6a4cacbe75dddd50e6e8bbf81d6496e92d66af9154c61c77f7332f",
3913 )
3914 .unwrap()
3915 .try_into()
3916 .unwrap();
3917
3918 cfg.aliased_addresses.push(AliasedAddress {
3920 original: Hex::decode("0xcd8962dad278d8b50fa0f9eb0186bfa4cbdecc6d59377214c88d0286a0ac9562").unwrap().try_into().unwrap(),
3921 aliased,
3922 allowed_tx_digests: vec![
3923 Base58::decode("B2eGLFoMHgj93Ni8dAJBfqGzo8EWSTLBesZzhEpTPA4").unwrap().try_into().unwrap(),
3924 ],
3925 });
3926
3927 cfg.aliased_addresses.push(AliasedAddress {
3928 original: Hex::decode("0xe28b50cef1d633ea43d3296a3f6b67ff0312a5f1a99f0af753c85b8b5de8ff06").unwrap().try_into().unwrap(),
3929 aliased,
3930 allowed_tx_digests: vec![
3931 Base58::decode("J4QqSAgp7VrQtQpMy5wDX4QGsCSEZu3U5KuDAkbESAge").unwrap().try_into().unwrap(),
3932 ],
3933 });
3934 }
3935
3936 if chain != Chain::Mainnet {
3939 cfg.feature_flags.resolve_type_input_ids_to_defining_id = true;
3940 cfg.transfer_party_transfer_internal_cost_base = Some(52);
3941
3942 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
3944 cfg.consensus_commit_rate_estimation_window_size = Some(10);
3945 cfg.feature_flags.per_object_congestion_control_mode =
3946 PerObjectCongestionControlMode::ExecutionTimeEstimate(
3947 ExecutionTimeEstimateParams {
3948 target_utilization: 30,
3949 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
3951 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
3953 stored_observations_limit: u64::MAX,
3954 stake_weighted_median_threshold: 0,
3955 default_none_duration_for_new_keys: false,
3956 observations_chunk_size: None,
3957 },
3958 );
3959
3960 cfg.feature_flags.consensus_batched_block_sync = true;
3962
3963 cfg.feature_flags.enable_nitro_attestation_upgraded_parsing = true;
3966 cfg.feature_flags.enable_nitro_attestation = true;
3967 }
3968 }
3969 84 => {
3970 if chain == Chain::Mainnet {
3971 cfg.feature_flags.resolve_type_input_ids_to_defining_id = true;
3972 cfg.transfer_party_transfer_internal_cost_base = Some(52);
3973
3974 cfg.feature_flags.record_additional_state_digest_in_prologue = true;
3976 cfg.consensus_commit_rate_estimation_window_size = Some(10);
3977 cfg.feature_flags.per_object_congestion_control_mode =
3978 PerObjectCongestionControlMode::ExecutionTimeEstimate(
3979 ExecutionTimeEstimateParams {
3980 target_utilization: 30,
3981 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
3983 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
3985 stored_observations_limit: u64::MAX,
3986 stake_weighted_median_threshold: 0,
3987 default_none_duration_for_new_keys: false,
3988 observations_chunk_size: None,
3989 },
3990 );
3991
3992 cfg.feature_flags.consensus_batched_block_sync = true;
3994
3995 cfg.feature_flags.enable_nitro_attestation_upgraded_parsing = true;
3998 cfg.feature_flags.enable_nitro_attestation = true;
3999 }
4000
4001 cfg.feature_flags.per_object_congestion_control_mode =
4003 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4004 ExecutionTimeEstimateParams {
4005 target_utilization: 30,
4006 allowed_txn_cost_overage_burst_limit_us: 100_000, randomness_scalar: 20,
4008 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4010 stored_observations_limit: 20,
4011 stake_weighted_median_threshold: 0,
4012 default_none_duration_for_new_keys: false,
4013 observations_chunk_size: None,
4014 },
4015 );
4016 cfg.feature_flags.allow_unbounded_system_objects = true;
4017 }
4018 85 => {
4019 if chain != Chain::Mainnet && chain != Chain::Testnet {
4020 cfg.feature_flags.enable_party_transfer = true;
4021 }
4022
4023 cfg.feature_flags
4024 .record_consensus_determined_version_assignments_in_prologue_v2 = true;
4025 cfg.feature_flags.disallow_self_identifier = true;
4026 cfg.feature_flags.per_object_congestion_control_mode =
4027 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4028 ExecutionTimeEstimateParams {
4029 target_utilization: 50,
4030 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4032 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4034 stored_observations_limit: 20,
4035 stake_weighted_median_threshold: 0,
4036 default_none_duration_for_new_keys: false,
4037 observations_chunk_size: None,
4038 },
4039 );
4040 }
4041 86 => {
4042 cfg.feature_flags.type_tags_in_object_runtime = true;
4043 cfg.max_move_enum_variants = Some(move_core_types::VARIANT_COUNT_MAX);
4044
4045 cfg.feature_flags.per_object_congestion_control_mode =
4047 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4048 ExecutionTimeEstimateParams {
4049 target_utilization: 50,
4050 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4052 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4054 stored_observations_limit: 20,
4055 stake_weighted_median_threshold: 3334,
4056 default_none_duration_for_new_keys: false,
4057 observations_chunk_size: None,
4058 },
4059 );
4060 if chain != Chain::Mainnet {
4062 cfg.feature_flags.enable_party_transfer = true;
4063 }
4064 }
4065 87 => {
4066 if chain == Chain::Mainnet {
4067 cfg.feature_flags.record_time_estimate_processed = true;
4068 }
4069 cfg.feature_flags.better_adapter_type_resolution_errors = true;
4070 }
4071 88 => {
4072 cfg.feature_flags.record_time_estimate_processed = true;
4073 cfg.tx_context_rgp_cost_base = Some(30);
4074 cfg.feature_flags
4075 .ignore_execution_time_observations_after_certs_closed = true;
4076
4077 cfg.feature_flags.per_object_congestion_control_mode =
4080 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4081 ExecutionTimeEstimateParams {
4082 target_utilization: 50,
4083 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4085 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4087 stored_observations_limit: 20,
4088 stake_weighted_median_threshold: 3334,
4089 default_none_duration_for_new_keys: true,
4090 observations_chunk_size: None,
4091 },
4092 );
4093 }
4094 89 => {
4095 cfg.feature_flags.dependency_linkage_error = true;
4096 cfg.feature_flags.additional_multisig_checks = true;
4097 }
4098 90 => {
4099 cfg.max_gas_price_rgp_factor_for_aborted_transactions = Some(100);
4101 cfg.feature_flags.debug_fatal_on_move_invariant_violation = true;
4102 cfg.feature_flags.additional_consensus_digest_indirect_state = true;
4103 cfg.feature_flags.accept_passkey_in_multisig = true;
4104 cfg.feature_flags.passkey_auth = true;
4105 cfg.feature_flags.check_for_init_during_upgrade = true;
4106
4107 if chain != Chain::Mainnet {
4109 cfg.feature_flags.mysticeti_fastpath = true;
4110 }
4111 }
4112 91 => {
4113 cfg.feature_flags.per_command_shared_object_transfer_rules = true;
4114 }
4115 92 => {
4116 cfg.feature_flags.per_command_shared_object_transfer_rules = false;
4117 }
4118 93 => {
4119 cfg.feature_flags
4120 .consensus_checkpoint_signature_key_includes_digest = true;
4121 }
4122 94 => {
4123 cfg.feature_flags.per_object_congestion_control_mode =
4125 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4126 ExecutionTimeEstimateParams {
4127 target_utilization: 50,
4128 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4130 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4132 stored_observations_limit: 18,
4133 stake_weighted_median_threshold: 3334,
4134 default_none_duration_for_new_keys: true,
4135 observations_chunk_size: None,
4136 },
4137 );
4138
4139 cfg.feature_flags.enable_party_transfer = true;
4141 }
4142 95 => {
4143 cfg.type_name_id_base_cost = Some(52);
4144
4145 cfg.max_transactions_per_checkpoint = Some(20_000);
4147 }
4148 96 => {
4149 if chain != Chain::Mainnet && chain != Chain::Testnet {
4151 cfg.feature_flags
4152 .include_checkpoint_artifacts_digest_in_summary = true;
4153 }
4154 cfg.feature_flags.correct_gas_payment_limit_check = true;
4155 cfg.feature_flags.authority_capabilities_v2 = true;
4156 cfg.feature_flags.use_mfp_txns_in_load_initial_object_debts = true;
4157 cfg.feature_flags.cancel_for_failed_dkg_early = true;
4158 cfg.feature_flags.enable_coin_registry = true;
4159
4160 cfg.feature_flags.mysticeti_fastpath = true;
4162 }
4163 97 => {
4164 cfg.feature_flags.additional_borrow_checks = true;
4165 }
4166 98 => {
4167 cfg.event_emit_auth_stream_cost = Some(52);
4168 cfg.feature_flags.better_loader_errors = true;
4169 cfg.feature_flags.generate_df_type_layouts = true;
4170 }
4171 99 => {
4172 cfg.feature_flags.use_new_commit_handler = true;
4173 }
4174 100 => {
4175 cfg.feature_flags.private_generics_verifier_v2 = true;
4176 }
4177 101 => {
4178 cfg.feature_flags.create_root_accumulator_object = true;
4179 cfg.max_updates_per_settlement_txn = Some(100);
4180 if chain != Chain::Mainnet {
4181 cfg.feature_flags.enable_poseidon = true;
4182 }
4183 }
4184 102 => {
4185 cfg.feature_flags.per_object_congestion_control_mode =
4189 PerObjectCongestionControlMode::ExecutionTimeEstimate(
4190 ExecutionTimeEstimateParams {
4191 target_utilization: 50,
4192 allowed_txn_cost_overage_burst_limit_us: 500_000, randomness_scalar: 20,
4194 max_estimate_us: 1_500_000, stored_observations_num_included_checkpoints: 10,
4196 stored_observations_limit: 180,
4197 stake_weighted_median_threshold: 3334,
4198 default_none_duration_for_new_keys: true,
4199 observations_chunk_size: Some(18),
4200 },
4201 );
4202 cfg.feature_flags.deprecate_global_storage_ops = true;
4203 }
4204 103 => {}
4205 104 => {
4206 cfg.translation_per_command_base_charge = Some(1);
4207 cfg.translation_per_input_base_charge = Some(1);
4208 cfg.translation_pure_input_per_byte_charge = Some(1);
4209 cfg.translation_per_type_node_charge = Some(1);
4210 cfg.translation_per_reference_node_charge = Some(1);
4211 cfg.translation_per_linkage_entry_charge = Some(10);
4212 cfg.gas_model_version = Some(11);
4213 cfg.feature_flags.abstract_size_in_object_runtime = true;
4214 cfg.feature_flags.object_runtime_charge_cache_load_gas = true;
4215 cfg.dynamic_field_hash_type_and_key_cost_base = Some(52);
4216 cfg.dynamic_field_add_child_object_cost_base = Some(52);
4217 cfg.dynamic_field_add_child_object_value_cost_per_byte = Some(1);
4218 cfg.dynamic_field_borrow_child_object_cost_base = Some(52);
4219 cfg.dynamic_field_borrow_child_object_child_ref_cost_per_byte = Some(1);
4220 cfg.dynamic_field_remove_child_object_cost_base = Some(52);
4221 cfg.dynamic_field_remove_child_object_child_cost_per_byte = Some(1);
4222 cfg.dynamic_field_has_child_object_cost_base = Some(52);
4223 cfg.dynamic_field_has_child_object_with_ty_cost_base = Some(52);
4224 cfg.feature_flags.enable_ptb_execution_v2 = true;
4225
4226 cfg.poseidon_bn254_cost_base = Some(260);
4227
4228 cfg.feature_flags.consensus_skip_gced_accept_votes = true;
4229
4230 if chain != Chain::Mainnet {
4231 cfg.feature_flags
4232 .enable_nitro_attestation_all_nonzero_pcrs_parsing = true;
4233 }
4234
4235 cfg.feature_flags
4236 .include_cancelled_randomness_txns_in_prologue = true;
4237 }
4238 105 => {
4239 cfg.feature_flags.enable_multi_epoch_transaction_expiration = true;
4240 cfg.feature_flags.disable_preconsensus_locking = true;
4241
4242 if chain != Chain::Mainnet {
4243 cfg.feature_flags
4244 .enable_nitro_attestation_always_include_required_pcrs_parsing = true;
4245 }
4246 }
4247 106 => {
4248 cfg.accumulator_object_storage_cost = Some(7600);
4250
4251 if chain != Chain::Mainnet && chain != Chain::Testnet {
4252 cfg.feature_flags.enable_accumulators = true;
4253 cfg.feature_flags.enable_address_balance_gas_payments = true;
4254 cfg.feature_flags.enable_authenticated_event_streams = true;
4255 cfg.feature_flags.enable_object_funds_withdraw = true;
4256 }
4257 }
4258 107 => {
4259 cfg.feature_flags
4260 .consensus_skip_gced_blocks_in_direct_finalization = true;
4261
4262 if in_integration_test() {
4264 cfg.consensus_gc_depth = Some(6);
4265 cfg.consensus_max_num_transactions_in_block = Some(8);
4266 }
4267 }
4268 108 => {
4269 cfg.feature_flags.gas_rounding_halve_digits = true;
4270 cfg.feature_flags.flexible_tx_context_positions = true;
4271 cfg.feature_flags.disable_entry_point_signature_check = true;
4272
4273 if chain != Chain::Mainnet {
4274 cfg.feature_flags.address_aliases = true;
4275
4276 cfg.feature_flags.enable_accumulators = true;
4277 cfg.feature_flags.enable_address_balance_gas_payments = true;
4278 }
4279
4280 cfg.feature_flags.enable_poseidon = true;
4281 }
4282 109 => {
4283 cfg.binary_variant_handles = Some(1024);
4284 cfg.binary_variant_instantiation_handles = Some(1024);
4285 cfg.feature_flags.restrict_hot_or_not_entry_functions = true;
4286 }
4287 110 => {
4288 cfg.feature_flags
4289 .enable_nitro_attestation_all_nonzero_pcrs_parsing = true;
4290 cfg.feature_flags
4291 .enable_nitro_attestation_always_include_required_pcrs_parsing = true;
4292 if chain != Chain::Mainnet && chain != Chain::Testnet {
4293 cfg.feature_flags.split_checkpoints_in_consensus_handler = true;
4294 }
4295 cfg.feature_flags.validate_zklogin_public_identifier = true;
4296 cfg.feature_flags.fix_checkpoint_signature_mapping = true;
4297 cfg.feature_flags
4298 .consensus_always_accept_system_transactions = true;
4299 if chain != Chain::Mainnet {
4300 cfg.feature_flags.enable_object_funds_withdraw = true;
4301 }
4302 }
4303 111 => {
4304 cfg.feature_flags.validator_metadata_verify_v2 = true;
4305 }
4306 112 => {
4307 cfg.group_ops_ristretto_decode_scalar_cost = Some(7);
4308 cfg.group_ops_ristretto_decode_point_cost = Some(200);
4309 cfg.group_ops_ristretto_scalar_add_cost = Some(10);
4310 cfg.group_ops_ristretto_point_add_cost = Some(500);
4311 cfg.group_ops_ristretto_scalar_sub_cost = Some(10);
4312 cfg.group_ops_ristretto_point_sub_cost = Some(500);
4313 cfg.group_ops_ristretto_scalar_mul_cost = Some(11);
4314 cfg.group_ops_ristretto_point_mul_cost = Some(1200);
4315 cfg.group_ops_ristretto_scalar_div_cost = Some(151);
4316 cfg.group_ops_ristretto_point_div_cost = Some(2500);
4317
4318 if chain != Chain::Mainnet && chain != Chain::Testnet {
4319 cfg.feature_flags.enable_ristretto255_group_ops = true;
4320 }
4321 }
4322 113 => {
4323 cfg.feature_flags.address_balance_gas_check_rgp_at_signing = true;
4324 if chain != Chain::Mainnet && chain != Chain::Testnet {
4325 cfg.feature_flags.defer_unpaid_amplification = true;
4326 }
4327 }
4328 114 => {
4329 cfg.feature_flags.randomize_checkpoint_tx_limit_in_tests = true;
4330 cfg.feature_flags.address_balance_gas_reject_gas_coin_arg = true;
4331 if chain != Chain::Mainnet {
4332 cfg.feature_flags.split_checkpoints_in_consensus_handler = true;
4333 cfg.feature_flags.enable_authenticated_event_streams = true;
4334 cfg.feature_flags
4335 .include_checkpoint_artifacts_digest_in_summary = true;
4336 }
4337 }
4338 115 => {
4339 cfg.feature_flags.normalize_depth_formula = true;
4340 }
4341 116 => {
4342 cfg.feature_flags.gasless_transaction_drop_safety = true;
4343 cfg.feature_flags.address_aliases = true;
4344 cfg.feature_flags.relax_valid_during_for_owned_inputs = true;
4345 cfg.feature_flags.defer_unpaid_amplification = false;
4347 cfg.feature_flags.enable_display_registry = true;
4348 }
4349 117 => {}
4350 118 => {
4351 cfg.feature_flags.use_coin_party_owner = true;
4352 }
4353 119 => {
4354 cfg.execution_version = Some(4);
4356 cfg.feature_flags.address_balance_gas_reject_gas_coin_arg = false;
4357 cfg.feature_flags.merge_randomness_into_checkpoint = true;
4358 if chain != Chain::Mainnet {
4359 cfg.feature_flags.enable_gasless = true;
4360 cfg.gasless_max_computation_units = Some(50_000);
4361 cfg.gasless_allowed_token_types = Some(vec![]);
4362 cfg.feature_flags.enable_coin_reservation_obj_refs = true;
4363 cfg.feature_flags
4364 .convert_withdrawal_compatibility_ptb_arguments = true;
4365 }
4366 cfg.gasless_max_unused_inputs = Some(1);
4367 cfg.gasless_max_pure_input_bytes = Some(32);
4368 if chain == Chain::Testnet {
4369 cfg.gasless_allowed_token_types = Some(vec![(TESTNET_USDC.to_string(), 0)]);
4370 }
4371 cfg.transfer_receive_object_cost_per_byte = Some(1);
4372 cfg.transfer_receive_object_type_cost_per_byte = Some(2);
4373 }
4374 120 => {
4375 cfg.feature_flags.disallow_jump_orphans = true;
4376 }
4377 121 => {
4378 if chain != Chain::Mainnet {
4380 cfg.feature_flags.defer_unpaid_amplification = true;
4381 cfg.gasless_max_tps = Some(50);
4382 }
4383 cfg.feature_flags
4384 .early_return_receive_object_mismatched_type = true;
4385 }
4386 122 => {
4387 cfg.feature_flags.defer_unpaid_amplification = true;
4389 cfg.verify_bulletproofs_ristretto255_base_cost = Some(30000);
4391 cfg.verify_bulletproofs_ristretto255_cost_per_bit_and_commitment = Some(6500);
4392 if chain != Chain::Mainnet && chain != Chain::Testnet {
4393 cfg.feature_flags.enable_verify_bulletproofs_ristretto255 = true;
4394 }
4395 cfg.feature_flags.gasless_verify_remaining_balance = true;
4396 cfg.include_special_package_amendments = match chain {
4397 Chain::Mainnet => Some(MAINNET_LINKAGE_AMENDMENTS.clone()),
4398 Chain::Testnet => Some(TESTNET_LINKAGE_AMENDMENTS.clone()),
4399 Chain::Unknown => None,
4400 };
4401 cfg.gasless_max_tx_size_bytes = Some(16 * 1024);
4402 cfg.gasless_max_tps = Some(300);
4403 cfg.gasless_max_computation_units = Some(5_000);
4404 }
4405 123 => {
4406 cfg.gas_model_version = Some(13);
4407 }
4408 124 => {
4409 if chain != Chain::Mainnet && chain != Chain::Testnet {
4410 cfg.feature_flags.timestamp_based_epoch_close = true;
4411 }
4412 cfg.gas_model_version = Some(14);
4413 cfg.feature_flags.limit_groth16_pvk_inputs = true;
4414
4415 cfg.feature_flags.enable_accumulators = true;
4421 cfg.feature_flags.enable_address_balance_gas_payments = true;
4422 cfg.feature_flags.enable_authenticated_event_streams = true;
4423 cfg.feature_flags.enable_coin_reservation_obj_refs = true;
4424 cfg.feature_flags.enable_object_funds_withdraw = true;
4425 cfg.feature_flags
4426 .convert_withdrawal_compatibility_ptb_arguments = true;
4427 cfg.feature_flags.split_checkpoints_in_consensus_handler = true;
4428 cfg.feature_flags
4429 .include_checkpoint_artifacts_digest_in_summary = true;
4430 cfg.feature_flags.enable_gasless = true;
4431
4432 if chain == Chain::Mainnet {
4437 cfg.gasless_allowed_token_types = Some(vec![
4438 (MAINNET_USDC.to_string(), 10_000),
4439 (MAINNET_USDSUI.to_string(), 10_000),
4440 (MAINNET_SUI_USDE.to_string(), 10_000),
4441 (MAINNET_USDY.to_string(), 10_000),
4442 (MAINNET_FDUSD.to_string(), 10_000),
4443 (MAINNET_AUSD.to_string(), 10_000),
4444 (MAINNET_USDB.to_string(), 10_000),
4445 ]);
4446 }
4447 }
4448 125 => {
4449 cfg.feature_flags.granular_post_execution_checks = true;
4450 if chain != Chain::Mainnet {
4451 cfg.feature_flags.timestamp_based_epoch_close = true;
4452 }
4453 }
4454 126 => {
4455 cfg.feature_flags.early_exit_on_iffw = true;
4456 }
4457 127 => {
4458 cfg.feature_flags.always_advance_dkg_to_resolution = true;
4459
4460 cfg.verify_bulletproofs_ristretto255_base_cost = Some(23866);
4461 cfg.verify_bulletproofs_ristretto255_cost_per_bit_and_commitment = Some(1324);
4462 cfg.group_ops_ristretto_decode_scalar_cost = Some(5);
4463 cfg.group_ops_ristretto_decode_point_cost = Some(216);
4464 cfg.group_ops_ristretto_scalar_add_cost = Some(2);
4465 cfg.group_ops_ristretto_point_add_cost = Some(8);
4466 cfg.group_ops_ristretto_scalar_sub_cost = Some(2);
4467 cfg.group_ops_ristretto_point_sub_cost = Some(8);
4468 cfg.group_ops_ristretto_scalar_mul_cost = Some(5);
4469 cfg.group_ops_ristretto_point_mul_cost = Some(1763);
4470 cfg.group_ops_ristretto_scalar_div_cost = Some(557);
4471 cfg.group_ops_ristretto_point_div_cost = Some(2244);
4472
4473 if chain != Chain::Mainnet {
4474 cfg.feature_flags.enable_ristretto255_group_ops = true;
4475 cfg.feature_flags.enable_verify_bulletproofs_ristretto255 = true;
4476 }
4477
4478 cfg.feature_flags.timestamp_based_epoch_close = true;
4479 }
4480 128 => {
4481 cfg.max_generic_instantiation_type_nodes_per_function = Some(10_000);
4482 cfg.max_generic_instantiation_type_nodes_per_module = Some(500_000);
4483 cfg.binary_enum_defs = Some(200);
4484 cfg.binary_enum_def_instantiations = Some(100);
4485 }
4486 129 => {
4487 cfg.feature_flags.enable_unified_linkage = true;
4488 }
4489 130 => {
4490 cfg.feature_flags.record_net_unsettled_object_withdraws = true;
4491 cfg.feature_flags.enable_init_on_upgrade = true;
4492 cfg.scratch_add_cost_base = Some(13);
4493 cfg.scratch_read_cost_base = Some(13);
4494 cfg.scratch_read_value_cost = Some(1);
4495 cfg.scratch_remove_cost_base = Some(13);
4496 cfg.scratch_exists_cost_base = Some(13);
4497 cfg.scratch_exists_with_type_cost_base = Some(13);
4498 cfg.scratch_exists_with_type_type_cost = Some(1);
4499 let max_commands = cfg.max_programmable_tx_commands() as u64;
4500 cfg.max_scratch_pad_size = Some(16 * max_commands);
4501 }
4502 _ => panic!("unsupported version {:?}", version),
4513 }
4514 }
4515
4516 cfg
4517 }
4518
4519 pub fn apply_seeded_test_overrides(&mut self, seed: &[u8; 32]) {
4520 if !self.feature_flags.randomize_checkpoint_tx_limit_in_tests
4521 || !self.feature_flags.split_checkpoints_in_consensus_handler
4522 {
4523 return;
4524 }
4525
4526 if !mysten_common::in_test_configuration() {
4527 return;
4528 }
4529
4530 use rand::{Rng, SeedableRng, rngs::StdRng};
4531 let mut rng = StdRng::from_seed(*seed);
4532 let max_txns = rng.gen_range(10..=100u64);
4533 info!("seeded test override: max_transactions_per_checkpoint = {max_txns}");
4534 self.max_transactions_per_checkpoint = Some(max_txns);
4535 }
4536
4537 pub fn verifier_config(&self, signing_limits: Option<(usize, usize, usize)>) -> VerifierConfig {
4543 let (
4544 max_back_edges_per_function,
4545 max_back_edges_per_module,
4546 sanity_check_with_regex_reference_safety,
4547 ) = if let Some((
4548 max_back_edges_per_function,
4549 max_back_edges_per_module,
4550 sanity_check_with_regex_reference_safety,
4551 )) = signing_limits
4552 {
4553 (
4554 Some(max_back_edges_per_function),
4555 Some(max_back_edges_per_module),
4556 Some(sanity_check_with_regex_reference_safety),
4557 )
4558 } else {
4559 (None, None, None)
4560 };
4561
4562 let additional_borrow_checks = if signing_limits.is_some() {
4563 true
4565 } else {
4566 self.additional_borrow_checks()
4567 };
4568 let deprecate_global_storage_ops = if signing_limits.is_some() {
4569 true
4571 } else {
4572 self.deprecate_global_storage_ops()
4573 };
4574
4575 VerifierConfig {
4576 max_loop_depth: Some(self.max_loop_depth() as usize),
4577 max_generic_instantiation_length: Some(self.max_generic_instantiation_length() as usize),
4578 max_function_parameters: Some(self.max_function_parameters() as usize),
4579 max_basic_blocks: Some(self.max_basic_blocks() as usize),
4580 max_value_stack_size: self.max_value_stack_size() as usize,
4581 max_type_nodes: Some(self.max_type_nodes() as usize),
4582 max_generic_instantiation_type_nodes_per_function: self
4583 .max_generic_instantiation_type_nodes_per_function_as_option()
4584 .map(|v| v as usize),
4585 max_generic_instantiation_type_nodes_per_module: self
4586 .max_generic_instantiation_type_nodes_per_module_as_option()
4587 .map(|v| v as usize),
4588 max_push_size: Some(self.max_push_size() as usize),
4589 max_dependency_depth: Some(self.max_dependency_depth() as usize),
4590 max_fields_in_struct: Some(self.max_fields_in_struct() as usize),
4591 max_function_definitions: Some(self.max_function_definitions() as usize),
4592 max_data_definitions: Some(self.max_struct_definitions() as usize),
4593 max_constant_vector_len: Some(self.max_move_vector_len()),
4594 max_back_edges_per_function,
4595 max_back_edges_per_module,
4596 max_basic_blocks_in_script: None,
4597 max_identifier_len: self.max_move_identifier_len_as_option(), disallow_self_identifier: self.feature_flags.disallow_self_identifier,
4599 allow_receiving_object_id: self.allow_receiving_object_id(),
4600 reject_mutable_random_on_entry_functions: self
4601 .reject_mutable_random_on_entry_functions(),
4602 bytecode_version: self.move_binary_format_version(),
4603 max_variants_in_enum: self.max_move_enum_variants_as_option(),
4604 additional_borrow_checks,
4605 better_loader_errors: self.better_loader_errors(),
4606 private_generics_verifier_v2: self.private_generics_verifier_v2(),
4607 sanity_check_with_regex_reference_safety: sanity_check_with_regex_reference_safety
4608 .map(|limit| limit as u128),
4609 deprecate_global_storage_ops,
4610 disable_entry_point_signature_check: self.disable_entry_point_signature_check(),
4611 switch_to_regex_reference_safety: false,
4612 disallow_jump_orphans: self.disallow_jump_orphans(),
4613 }
4614 }
4615
4616 pub fn binary_config(
4617 &self,
4618 override_deprecate_global_storage_ops_during_deserialization: Option<bool>,
4619 ) -> BinaryConfig {
4620 let deprecate_global_storage_ops =
4621 override_deprecate_global_storage_ops_during_deserialization
4622 .unwrap_or_else(|| self.deprecate_global_storage_ops());
4623 BinaryConfig::new(
4624 self.move_binary_format_version(),
4625 self.min_move_binary_format_version_as_option()
4626 .unwrap_or(VERSION_1),
4627 self.no_extraneous_module_bytes(),
4628 deprecate_global_storage_ops,
4629 TableConfig {
4630 module_handles: self.binary_module_handles_as_option().unwrap_or(u16::MAX),
4631 datatype_handles: self.binary_struct_handles_as_option().unwrap_or(u16::MAX),
4632 function_handles: self.binary_function_handles_as_option().unwrap_or(u16::MAX),
4633 function_instantiations: self
4634 .binary_function_instantiations_as_option()
4635 .unwrap_or(u16::MAX),
4636 signatures: self.binary_signatures_as_option().unwrap_or(u16::MAX),
4637 constant_pool: self.binary_constant_pool_as_option().unwrap_or(u16::MAX),
4638 identifiers: self.binary_identifiers_as_option().unwrap_or(u16::MAX),
4639 address_identifiers: self
4640 .binary_address_identifiers_as_option()
4641 .unwrap_or(u16::MAX),
4642 struct_defs: self.binary_struct_defs_as_option().unwrap_or(u16::MAX),
4643 struct_def_instantiations: self
4644 .binary_struct_def_instantiations_as_option()
4645 .unwrap_or(u16::MAX),
4646 function_defs: self.binary_function_defs_as_option().unwrap_or(u16::MAX),
4647 field_handles: self.binary_field_handles_as_option().unwrap_or(u16::MAX),
4648 field_instantiations: self
4649 .binary_field_instantiations_as_option()
4650 .unwrap_or(u16::MAX),
4651 friend_decls: self.binary_friend_decls_as_option().unwrap_or(u16::MAX),
4652 enum_defs: self.binary_enum_defs_as_option().unwrap_or(u16::MAX),
4653 enum_def_instantiations: self
4654 .binary_enum_def_instantiations_as_option()
4655 .unwrap_or(u16::MAX),
4656 variant_handles: self.binary_variant_handles_as_option().unwrap_or(u16::MAX),
4657 variant_instantiation_handles: self
4658 .binary_variant_instantiation_handles_as_option()
4659 .unwrap_or(u16::MAX),
4660 },
4661 )
4662 }
4663
4664 #[cfg(not(msim))]
4668 pub fn apply_overrides_for_testing(
4669 override_fn: impl Fn(ProtocolVersion, Self) -> Self + Send + Sync + 'static,
4670 ) -> OverrideGuard {
4671 let mut cur = CONFIG_OVERRIDE.lock().unwrap();
4672 assert!(cur.is_none(), "config override already present");
4673 *cur = Some(Box::new(override_fn));
4674 OverrideGuard
4675 }
4676
4677 #[cfg(msim)]
4681 pub fn apply_overrides_for_testing(
4682 override_fn: impl Fn(ProtocolVersion, Self) -> Self + Send + 'static,
4683 ) -> OverrideGuard {
4684 CONFIG_OVERRIDE.with(|ovr| {
4685 let mut cur = ovr.borrow_mut();
4686 assert!(cur.is_none(), "config override already present");
4687 *cur = Some(Box::new(override_fn));
4688 OverrideGuard
4689 })
4690 }
4691
4692 #[cfg(not(msim))]
4693 fn apply_config_override(version: ProtocolVersion, mut ret: Self) -> Self {
4694 if let Some(override_fn) = CONFIG_OVERRIDE.lock().unwrap().as_ref() {
4695 warn!(
4696 "overriding ProtocolConfig settings with custom settings (you should not see this log outside of tests)"
4697 );
4698 ret = override_fn(version, ret);
4699 }
4700 ret
4701 }
4702
4703 #[cfg(msim)]
4704 fn apply_config_override(version: ProtocolVersion, ret: Self) -> Self {
4705 CONFIG_OVERRIDE.with(|ovr| {
4706 if let Some(override_fn) = &*ovr.borrow() {
4707 warn!(
4708 "overriding ProtocolConfig settings with custom settings (you should not see this log outside of tests)"
4709 );
4710 override_fn(version, ret)
4711 } else {
4712 ret
4713 }
4714 })
4715 }
4716}
4717
4718impl ProtocolConfig {
4722 pub fn set_per_object_congestion_control_mode_for_testing(
4723 &mut self,
4724 val: PerObjectCongestionControlMode,
4725 ) {
4726 self.feature_flags.per_object_congestion_control_mode = val;
4727 }
4728
4729 pub fn set_consensus_choice_for_testing(&mut self, val: ConsensusChoice) {
4730 self.feature_flags.consensus_choice = val;
4731 }
4732
4733 pub fn set_consensus_network_for_testing(&mut self, val: ConsensusNetwork) {
4734 self.feature_flags.consensus_network = val;
4735 }
4736
4737 pub fn set_zklogin_max_epoch_upper_bound_delta_for_testing(&mut self, val: Option<u64>) {
4738 self.feature_flags.zklogin_max_epoch_upper_bound_delta = val
4739 }
4740
4741 pub fn set_mysticeti_num_leaders_per_round_for_testing(&mut self, val: Option<usize>) {
4742 self.feature_flags.mysticeti_num_leaders_per_round = val;
4743 }
4744
4745 pub fn disable_accumulators_for_testing(&mut self) {
4746 self.feature_flags.enable_accumulators = false;
4747 self.feature_flags.enable_address_balance_gas_payments = false;
4748 }
4749
4750 pub fn enable_coin_reservation_for_testing(&mut self) {
4751 self.feature_flags.enable_coin_reservation_obj_refs = true;
4752 self.feature_flags
4753 .convert_withdrawal_compatibility_ptb_arguments = true;
4754 self.execution_version = Some(self.execution_version.map_or(4, |v| v.max(4)));
4757 }
4758
4759 pub fn disable_coin_reservation_for_testing(&mut self) {
4760 self.feature_flags.enable_coin_reservation_obj_refs = false;
4761 self.feature_flags
4762 .convert_withdrawal_compatibility_ptb_arguments = false;
4763 }
4764
4765 pub fn enable_address_balance_gas_payments_for_testing(&mut self) {
4766 self.feature_flags.enable_accumulators = true;
4767 self.feature_flags.allow_private_accumulator_entrypoints = true;
4768 self.feature_flags.enable_address_balance_gas_payments = true;
4769 self.feature_flags.address_balance_gas_check_rgp_at_signing = true;
4770 self.feature_flags.address_balance_gas_reject_gas_coin_arg = false;
4771 self.execution_version = Some(self.execution_version.map_or(4, |v| v.max(4)))
4772 }
4773
4774 pub fn enable_gasless_for_testing(&mut self) {
4775 self.enable_address_balance_gas_payments_for_testing();
4776 self.feature_flags.enable_gasless = true;
4777 self.feature_flags.gasless_verify_remaining_balance = true;
4778 self.gasless_max_computation_units = Some(5_000);
4779 self.gasless_allowed_token_types = Some(vec![]);
4780 self.gasless_max_tps = Some(1000);
4781 self.gasless_max_tx_size_bytes = Some(16 * 1024);
4782 }
4783
4784 pub fn disable_gasless_for_testing(&mut self) {
4785 self.feature_flags.enable_gasless = false;
4786 self.gasless_max_computation_units = None;
4787 self.gasless_allowed_token_types = None;
4788 }
4789
4790 pub fn enable_authenticated_event_streams_for_testing(&mut self) {
4791 self.feature_flags.enable_accumulators = true;
4792 self.feature_flags.enable_authenticated_event_streams = true;
4793 self.feature_flags
4794 .include_checkpoint_artifacts_digest_in_summary = true;
4795 self.feature_flags.split_checkpoints_in_consensus_handler = true;
4796 }
4797}
4798
4799#[cfg(not(msim))]
4800type OverrideFn = dyn Fn(ProtocolVersion, ProtocolConfig) -> ProtocolConfig + Send + Sync;
4801
4802#[cfg(not(msim))]
4803static CONFIG_OVERRIDE: Mutex<Option<Box<OverrideFn>>> = Mutex::new(None);
4804
4805#[cfg(msim)]
4806type OverrideFn = dyn Fn(ProtocolVersion, ProtocolConfig) -> ProtocolConfig + Send;
4807
4808#[cfg(msim)]
4809thread_local! {
4810 static CONFIG_OVERRIDE: RefCell<Option<Box<OverrideFn>>> = RefCell::new(None);
4811}
4812
4813#[must_use]
4814pub struct OverrideGuard;
4815
4816#[cfg(not(msim))]
4817impl Drop for OverrideGuard {
4818 fn drop(&mut self) {
4819 info!("restoring override fn");
4820 *CONFIG_OVERRIDE.lock().unwrap() = None;
4821 }
4822}
4823
4824#[cfg(msim)]
4825impl Drop for OverrideGuard {
4826 fn drop(&mut self) {
4827 info!("restoring override fn");
4828 CONFIG_OVERRIDE.with(|ovr| {
4829 *ovr.borrow_mut() = None;
4830 });
4831 }
4832}
4833
4834#[derive(PartialEq, Eq)]
4837pub enum LimitThresholdCrossed {
4838 None,
4839 Soft(u128, u128),
4840 Hard(u128, u128),
4841}
4842
4843pub fn check_limit_in_range<T: Into<V>, U: Into<V>, V: PartialOrd + Into<u128>>(
4846 x: T,
4847 soft_limit: U,
4848 hard_limit: V,
4849) -> LimitThresholdCrossed {
4850 let x: V = x.into();
4851 let soft_limit: V = soft_limit.into();
4852
4853 debug_assert!(soft_limit <= hard_limit);
4854
4855 if x >= hard_limit {
4858 LimitThresholdCrossed::Hard(x.into(), hard_limit.into())
4859 } else if x < soft_limit {
4860 LimitThresholdCrossed::None
4861 } else {
4862 LimitThresholdCrossed::Soft(x.into(), soft_limit.into())
4863 }
4864}
4865
4866#[macro_export]
4867macro_rules! check_limit {
4868 ($x:expr, $hard:expr) => {
4869 check_limit!($x, $hard, $hard)
4870 };
4871 ($x:expr, $soft:expr, $hard:expr) => {
4872 check_limit_in_range($x as u64, $soft, $hard)
4873 };
4874}
4875
4876#[macro_export]
4880macro_rules! check_limit_by_meter {
4881 ($is_metered:expr, $x:expr, $metered_limit:expr, $unmetered_hard_limit:expr, $metric:expr) => {{
4882 let (h, metered_str) = if $is_metered {
4884 ($metered_limit, "metered")
4885 } else {
4886 ($unmetered_hard_limit, "unmetered")
4888 };
4889 use sui_protocol_config::check_limit_in_range;
4890 let result = check_limit_in_range($x as u64, $metered_limit, h);
4891 match result {
4892 LimitThresholdCrossed::None => {}
4893 LimitThresholdCrossed::Soft(_, _) => {
4894 $metric.with_label_values(&[metered_str, "soft"]).inc();
4895 }
4896 LimitThresholdCrossed::Hard(_, _) => {
4897 $metric.with_label_values(&[metered_str, "hard"]).inc();
4898 }
4899 };
4900 result
4901 }};
4902}
4903
4904pub type Amendments = BTreeMap<AccountAddress, BTreeMap<AccountAddress, AccountAddress>>;
4907
4908static MAINNET_LINKAGE_AMENDMENTS: LazyLock<Arc<Amendments>> =
4909 LazyLock::new(|| parse_amendments(include_str!("mainnet_amendments.json")));
4910
4911static TESTNET_LINKAGE_AMENDMENTS: LazyLock<Arc<Amendments>> =
4912 LazyLock::new(|| parse_amendments(include_str!("testnet_amendments.json")));
4913
4914fn parse_amendments(json: &str) -> Arc<Amendments> {
4915 #[derive(serde::Deserialize)]
4916 struct AmendmentEntry {
4917 root: String,
4918 deps: Vec<DepEntry>,
4919 }
4920
4921 #[derive(serde::Deserialize)]
4922 struct DepEntry {
4923 original_id: String,
4924 version_id: String,
4925 }
4926
4927 let entries: Vec<AmendmentEntry> =
4928 serde_json::from_str(json).expect("Failed to parse amendments JSON");
4929 let mut amendments = BTreeMap::new();
4930 for entry in entries {
4931 let root_id = AccountAddress::from_hex_literal(&entry.root).unwrap();
4932 let mut dep_ids = BTreeMap::new();
4933 for dep in entry.deps {
4934 let orig_id = AccountAddress::from_hex_literal(&dep.original_id).unwrap();
4935 let upgraded_id = AccountAddress::from_hex_literal(&dep.version_id).unwrap();
4936 assert!(
4937 dep_ids.insert(orig_id, upgraded_id).is_none(),
4938 "Duplicate original ID in amendments table"
4939 );
4940 }
4941 assert!(
4942 amendments.insert(root_id, dep_ids).is_none(),
4943 "Duplicate root ID in amendments table"
4944 );
4945 }
4946 Arc::new(amendments)
4947}
4948
4949#[cfg(all(test, not(msim)))]
4950mod test {
4951 use insta::assert_yaml_snapshot;
4952
4953 use super::*;
4954
4955 #[test]
4956 fn snapshot_tests() {
4957 println!("\n============================================================================");
4958 println!("! !");
4959 println!("! IMPORTANT: never update snapshots from this test. only add new versions! !");
4960 println!("! !");
4961 println!("============================================================================\n");
4962 for chain_id in &[Chain::Unknown, Chain::Mainnet, Chain::Testnet] {
4963 let chain_str = match chain_id {
4967 Chain::Unknown => "".to_string(),
4968 _ => format!("{:?}_", chain_id),
4969 };
4970 for i in MIN_PROTOCOL_VERSION..=MAX_PROTOCOL_VERSION {
4971 let cur = ProtocolVersion::new(i);
4972 assert_yaml_snapshot!(
4973 format!("{}version_{}", chain_str, cur.as_u64()),
4974 ProtocolConfig::get_for_version(cur, *chain_id)
4975 );
4976 }
4977 }
4978 }
4979
4980 #[test]
4981 fn test_getters() {
4982 let prot: ProtocolConfig =
4983 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
4984 assert_eq!(
4985 prot.max_arguments(),
4986 prot.max_arguments_as_option().unwrap()
4987 );
4988 }
4989
4990 #[test]
4991 fn test_setters() {
4992 let mut prot: ProtocolConfig =
4993 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
4994 prot.set_max_arguments_for_testing(123);
4995 assert_eq!(prot.max_arguments(), 123);
4996
4997 prot.set_max_arguments_from_str_for_testing("321".to_string());
4998 assert_eq!(prot.max_arguments(), 321);
4999
5000 prot.disable_max_arguments_for_testing();
5001 assert_eq!(prot.max_arguments_as_option(), None);
5002
5003 prot.set_attr_for_testing("max_arguments".to_string(), "456".to_string());
5004 assert_eq!(prot.max_arguments(), 456);
5005 }
5006
5007 #[test]
5008 fn test_feature_flag_setter_by_string() {
5009 let mut prot: ProtocolConfig =
5010 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5011 assert!(!prot.zklogin_auth());
5012 prot.set_feature_flag_for_testing("zklogin_auth".to_string(), true);
5013 assert!(prot.zklogin_auth());
5014 prot.set_feature_flag_for_testing("zklogin_auth".to_string(), false);
5015 assert!(!prot.zklogin_auth());
5016 }
5017
5018 #[test]
5019 #[should_panic(expected = "unknown feature flag")]
5020 fn test_feature_flag_setter_unknown_flag() {
5021 let mut prot: ProtocolConfig =
5022 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5023 prot.set_feature_flag_for_testing("some random string".to_string(), true);
5024 }
5025
5026 #[test]
5027 fn test_get_for_version_if_supported_applies_test_overrides() {
5028 let before =
5029 ProtocolConfig::get_for_version_if_supported(ProtocolVersion::new(1), Chain::Unknown)
5030 .unwrap();
5031
5032 assert!(!before.enable_coin_reservation_obj_refs());
5033
5034 let _guard = ProtocolConfig::apply_overrides_for_testing(|_, mut cfg| {
5035 cfg.enable_coin_reservation_for_testing();
5036 cfg
5037 });
5038
5039 let after =
5040 ProtocolConfig::get_for_version_if_supported(ProtocolVersion::new(1), Chain::Unknown)
5041 .unwrap();
5042
5043 assert!(after.enable_coin_reservation_obj_refs());
5044 }
5045
5046 #[test]
5047 #[should_panic(expected = "unsupported version")]
5048 fn max_version_test() {
5049 let _ = ProtocolConfig::get_for_version_impl(
5052 ProtocolVersion::new(MAX_PROTOCOL_VERSION + 1),
5053 Chain::Unknown,
5054 );
5055 }
5056
5057 #[test]
5058 fn lookup_by_string_test() {
5059 let prot: ProtocolConfig =
5060 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5061 assert!(prot.lookup_attr("some random string".to_string()).is_none());
5063
5064 assert!(
5065 prot.lookup_attr("max_arguments".to_string())
5066 == Some(ProtocolConfigValue::u32(prot.max_arguments())),
5067 );
5068
5069 assert!(
5071 prot.lookup_attr("max_move_identifier_len".to_string())
5072 .is_none()
5073 );
5074
5075 let prot: ProtocolConfig =
5077 ProtocolConfig::get_for_version(ProtocolVersion::new(9), Chain::Unknown);
5078 assert!(
5079 prot.lookup_attr("max_move_identifier_len".to_string())
5080 == Some(ProtocolConfigValue::u64(prot.max_move_identifier_len()))
5081 );
5082
5083 let prot: ProtocolConfig =
5084 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5085 assert!(
5087 prot.attr_map()
5088 .get("max_move_identifier_len")
5089 .unwrap()
5090 .is_none()
5091 );
5092 assert!(
5094 prot.attr_map().get("max_arguments").unwrap()
5095 == &Some(ProtocolConfigValue::u32(prot.max_arguments()))
5096 );
5097
5098 let prot: ProtocolConfig =
5100 ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
5101 assert!(
5103 prot.feature_flags
5104 .lookup_attr("some random string".to_owned())
5105 .is_none()
5106 );
5107 assert!(
5108 !prot
5109 .feature_flags
5110 .attr_map()
5111 .contains_key("some random string")
5112 );
5113
5114 assert!(
5116 prot.feature_flags
5117 .lookup_attr("package_upgrades".to_owned())
5118 == Some(false)
5119 );
5120 assert!(
5121 prot.feature_flags
5122 .attr_map()
5123 .get("package_upgrades")
5124 .unwrap()
5125 == &false
5126 );
5127 let prot: ProtocolConfig =
5128 ProtocolConfig::get_for_version(ProtocolVersion::new(4), Chain::Unknown);
5129 assert!(
5131 prot.feature_flags
5132 .lookup_attr("package_upgrades".to_owned())
5133 == Some(true)
5134 );
5135 assert!(
5136 prot.feature_flags
5137 .attr_map()
5138 .get("package_upgrades")
5139 .unwrap()
5140 == &true
5141 );
5142 }
5143
5144 #[test]
5145 fn limit_range_fn_test() {
5146 let low = 100u32;
5147 let high = 10000u64;
5148
5149 assert!(check_limit!(1u8, low, high) == LimitThresholdCrossed::None);
5150 assert!(matches!(
5151 check_limit!(255u16, low, high),
5152 LimitThresholdCrossed::Soft(255u128, 100)
5153 ));
5154 assert!(matches!(
5160 check_limit!(2550000u64, low, high),
5161 LimitThresholdCrossed::Hard(2550000, 10000)
5162 ));
5163
5164 assert!(matches!(
5165 check_limit!(2550000u64, high, high),
5166 LimitThresholdCrossed::Hard(2550000, 10000)
5167 ));
5168
5169 assert!(matches!(
5170 check_limit!(1u8, high),
5171 LimitThresholdCrossed::None
5172 ));
5173
5174 assert!(check_limit!(255u16, high) == LimitThresholdCrossed::None);
5175
5176 assert!(matches!(
5177 check_limit!(2550000u64, high),
5178 LimitThresholdCrossed::Hard(2550000, 10000)
5179 ));
5180 }
5181
5182 #[test]
5183 fn linkage_amendments_load() {
5184 let mainnet = LazyLock::force(&MAINNET_LINKAGE_AMENDMENTS);
5185 let testnet = LazyLock::force(&TESTNET_LINKAGE_AMENDMENTS);
5186 assert!(!mainnet.is_empty(), "mainnet amendments must not be empty");
5187 assert!(!testnet.is_empty(), "testnet amendments must not be empty");
5188 }
5189
5190 #[test]
5191 fn render_scalar_fields_use_precision_safe_encoding() {
5192 use mysten_common::rpc_format::Unmetered;
5193
5194 let config = ProtocolConfig::get_for_max_version_UNSAFE();
5195 let rendered = config
5196 .render::<serde_json::Value>(&mut Unmetered)
5197 .expect("render should succeed");
5198
5199 let max_args = rendered
5200 .get("max_arguments")
5201 .expect("max_arguments set at max version");
5202 assert!(
5203 max_args.is_number(),
5204 "u32 should render as number, got {max_args:?}",
5205 );
5206
5207 let max_tx_size = rendered
5208 .get("max_tx_size_bytes")
5209 .expect("max_tx_size_bytes set at max version");
5210 assert!(
5211 max_tx_size.is_string(),
5212 "u64 should render as string, got {max_tx_size:?}",
5213 );
5214 }
5215
5216 #[test]
5217 fn render_includes_non_scalar_gasless_allowlist_as_json() {
5218 use mysten_common::rpc_format::Unmetered;
5219 use serde_json::json;
5220
5221 let mut config = ProtocolConfig::get_for_max_version_UNSAFE();
5222 config.set_gasless_allowed_token_types_for_testing(vec![
5223 ("0xa::usdc::USDC".to_string(), 10_000),
5224 ("0xb::usdt::USDT".to_string(), 0),
5225 ]);
5226
5227 let rendered = config
5228 .render::<serde_json::Value>(&mut Unmetered)
5229 .expect("render should succeed under Unmetered budget");
5230 let allowlist = rendered
5231 .get("gasless_allowed_token_types")
5232 .expect("entry should be present after the testing setter");
5233
5234 assert_eq!(
5237 allowlist,
5238 &json!([["0xa::usdc::USDC", "10000"], ["0xb::usdt::USDT", "0"],]),
5239 );
5240 }
5241
5242 #[test]
5243 fn render_targets_prost_value_for_grpc() {
5244 use mysten_common::rpc_format::Unmetered;
5245 use prost_types::value::Kind;
5246
5247 let mut config = ProtocolConfig::get_for_max_version_UNSAFE();
5248 config.set_gasless_allowed_token_types_for_testing(vec![(
5249 "0xa::usdc::USDC".to_string(),
5250 10_000,
5251 )]);
5252
5253 let rendered = config
5254 .render::<prost_types::Value>(&mut Unmetered)
5255 .expect("render to prost Value should succeed");
5256 let allowlist = rendered
5257 .get("gasless_allowed_token_types")
5258 .expect("entry should be present after the testing setter");
5259
5260 let Some(Kind::ListValue(outer)) = &allowlist.kind else {
5262 panic!(
5263 "expected ListValue at the top level, got {:?}",
5264 allowlist.kind
5265 );
5266 };
5267 assert_eq!(outer.values.len(), 1, "one allowlisted entry");
5268 let Some(Kind::ListValue(entry)) = &outer.values[0].kind else {
5269 panic!("expected each entry to be a ListValue");
5270 };
5271 assert_eq!(entry.values.len(), 2, "entry has (coin_type, amount)");
5272
5273 let Some(Kind::StringValue(coin_type)) = &entry.values[0].kind else {
5274 panic!("expected coin_type as StringValue");
5275 };
5276 assert_eq!(coin_type, "0xa::usdc::USDC");
5277
5278 let Some(Kind::StringValue(amount)) = &entry.values[1].kind else {
5280 panic!(
5281 "expected minimum_transfer_amount as StringValue (precision-safe u64); got {:?}",
5282 entry.values[1].kind,
5283 );
5284 };
5285 assert_eq!(amount, "10000");
5286 }
5287
5288 #[test]
5289 fn render_emits_null_for_unset_protocol_versions() {
5290 use mysten_common::rpc_format::Unmetered;
5291
5292 let config = ProtocolConfig::get_for_version(1.into(), Chain::Unknown);
5293 let rendered = config
5294 .render::<serde_json::Value>(&mut Unmetered)
5295 .expect("render should succeed");
5296 let entry = rendered
5300 .get("gasless_allowed_token_types")
5301 .expect("key should be present for every protocol version");
5302 assert!(
5303 entry.is_null(),
5304 "value should be null for pre-feature protocol version, got {entry:?}",
5305 );
5306 }
5307}