1#![feature(variant_count)]
2#![cfg_attr(not(feature = "std"), no_std)]
3#![recursion_limit = "256"]
5
6#[cfg(feature = "std")]
8include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
9
10extern crate alloc;
11
12mod weights;
13
14use alloc::borrow::Cow;
15#[cfg(not(feature = "std"))]
16use alloc::format;
17use core::mem;
18use domain_runtime_primitives::opaque::Header;
19use domain_runtime_primitives::{
20 AccountId, Address, CheckExtrinsicsValidityError, DecodeExtrinsicError, ERR_BALANCE_OVERFLOW,
21 HoldIdentifier, SLOT_DURATION, Signature, TargetBlockFullness,
22};
23pub use domain_runtime_primitives::{
24 Balance, BlockNumber, EXISTENTIAL_DEPOSIT, Hash, MAX_OUTGOING_MESSAGES, Nonce, block_weights,
25 maximum_block_length, opaque,
26};
27use frame_support::dispatch::{DispatchClass, DispatchInfo, GetDispatchInfo};
28use frame_support::genesis_builder_helper::{build_state, get_preset};
29use frame_support::pallet_prelude::TypeInfo;
30use frame_support::traits::fungible::Credit;
31use frame_support::traits::{
32 ConstU16, ConstU32, ConstU64, Everything, Imbalance, IsInherent, OnUnbalanced, VariantCount,
33};
34use frame_support::weights::constants::ParityDbWeight;
35use frame_support::weights::{ConstantMultiplier, Weight};
36use frame_support::{construct_runtime, parameter_types};
37use frame_system::limits::{BlockLength, BlockWeights};
38use pallet_block_fees::fees::OnChargeDomainTransaction;
39use pallet_transporter::EndpointHandler;
40use parity_scale_codec::{Decode, DecodeLimit, DecodeWithMemTracking, Encode, MaxEncodedLen};
41use sp_api::impl_runtime_apis;
42use sp_core::crypto::KeyTypeId;
43use sp_core::{Get, OpaqueMetadata};
44use sp_domains::execution_receipt::Transfers;
45use sp_domains::{ChannelId, DomainAllowlistUpdates, DomainId};
46use sp_messenger::endpoint::{Endpoint, EndpointHandler as EndpointHandlerT, EndpointId};
47use sp_messenger::messages::{
48 BlockMessagesQuery, ChainId, ChannelStateWithNonce, CrossDomainMessage, MessageId, MessageKey,
49 MessagesWithStorageKey, Nonce as XdmNonce,
50};
51use sp_messenger::{ChannelNonce, XdmId};
52use sp_messenger_host_functions::{StorageKeyRequest, get_storage_key};
53use sp_mmr_primitives::EncodableOpaqueLeaf;
54use sp_runtime::generic::{Era, ExtrinsicFormat, Preamble};
55use sp_runtime::traits::{
56 AccountIdLookup, BlakeTwo256, Checkable, DispatchTransaction, Keccak256, NumberFor, One,
57 TransactionExtension, ValidateUnsigned, Zero,
58};
59use sp_runtime::transaction_validity::{
60 InvalidTransaction, TransactionSource, TransactionValidity, TransactionValidityError,
61};
62use sp_runtime::type_with_default::TypeWithDefault;
63use sp_runtime::{ApplyExtrinsicResult, Digest, ExtrinsicInclusionMode, generic, impl_opaque_keys};
64pub use sp_runtime::{MultiAddress, Perbill, Permill};
65use sp_std::collections::btree_map::BTreeMap;
66use sp_std::collections::btree_set::BTreeSet;
67use sp_std::marker::PhantomData;
68use sp_std::prelude::*;
69use sp_subspace_mmr::domain_mmr_runtime_interface::{
70 is_consensus_block_finalized, verify_mmr_proof,
71};
72use sp_subspace_mmr::{ConsensusChainMmrLeafProof, MmrLeaf};
73use sp_version::RuntimeVersion;
74use static_assertions::const_assert;
75use subspace_runtime_primitives::utility::DefaultNonceProvider;
76use subspace_runtime_primitives::{
77 AI3, BlockHashFor, BlockNumber as ConsensusBlockNumber, DomainEventSegmentSize, ExtrinsicFor,
78 Hash as ConsensusBlockHash, HeaderFor, MAX_CALL_RECURSION_DEPTH, Moment, SHANNON,
79 SlowAdjustingFeeUpdate, XdmAdjustedWeightToFee, XdmFeeMultipler,
80};
81
82pub type Block = generic::Block<Header, UncheckedExtrinsic>;
84
85pub type SignedBlock = generic::SignedBlock<Block>;
87
88pub type BlockId = generic::BlockId<Block>;
90
91pub type SignedExtra = (
93 frame_system::CheckNonZeroSender<Runtime>,
94 frame_system::CheckSpecVersion<Runtime>,
95 frame_system::CheckTxVersion<Runtime>,
96 frame_system::CheckGenesis<Runtime>,
97 frame_system::CheckMortality<Runtime>,
98 frame_system::CheckNonce<Runtime>,
99 domain_check_weight::CheckWeight<Runtime>,
100 pallet_transaction_payment::ChargeTransactionPayment<Runtime>,
101 pallet_messenger::extensions::MessengerExtension<Runtime>,
102);
103
104pub type CustomSignedExtra = (
106 frame_system::CheckNonZeroSender<Runtime>,
107 frame_system::CheckSpecVersion<Runtime>,
108 frame_system::CheckTxVersion<Runtime>,
109 frame_system::CheckGenesis<Runtime>,
110 frame_system::CheckMortality<Runtime>,
111 frame_system::CheckNonce<Runtime>,
112 domain_check_weight::CheckWeight<Runtime>,
113 pallet_transaction_payment::ChargeTransactionPayment<Runtime>,
114 pallet_messenger::extensions::MessengerTrustedMmrExtension<Runtime>,
115);
116
117pub type UncheckedExtrinsic =
119 generic::UncheckedExtrinsic<Address, RuntimeCall, Signature, SignedExtra>;
120
121pub type CheckedExtrinsic = generic::CheckedExtrinsic<AccountId, RuntimeCall, SignedExtra>;
123
124pub type Executive = domain_pallet_executive::Executive<
126 Runtime,
127 frame_system::ChainContext<Runtime>,
128 Runtime,
129 AllPalletsWithSystem,
130>;
131
132impl_opaque_keys! {
133 pub struct SessionKeys {
134 pub operator: sp_domains::OperatorKey,
136 }
137}
138
139#[sp_version::runtime_version]
140pub const VERSION: RuntimeVersion = RuntimeVersion {
141 spec_name: Cow::Borrowed("subspace-auto-id-domain"),
142 impl_name: Cow::Borrowed("subspace-auto-id-domain"),
143 authoring_version: 0,
144 spec_version: 0,
145 impl_version: 0,
146 apis: RUNTIME_API_VERSIONS,
147 transaction_version: 0,
148 system_version: 2,
149};
150
151parameter_types! {
152 pub const Version: RuntimeVersion = VERSION;
153 pub const BlockHashCount: BlockNumber = 2400;
154 pub RuntimeBlockLength: BlockLength = maximum_block_length();
155 pub RuntimeBlockWeights: BlockWeights = block_weights();
156}
157
158impl frame_system::Config for Runtime {
159 type AccountId = AccountId;
161 type RuntimeCall = RuntimeCall;
163 type RuntimeTask = RuntimeTask;
165 type Lookup = AccountIdLookup<AccountId, ()>;
167 type Nonce = TypeWithDefault<Nonce, DefaultNonceProvider<System, Nonce>>;
169 type Hash = Hash;
171 type Hashing = BlakeTwo256;
173 type Block = Block;
175 type RuntimeEvent = RuntimeEvent;
177 type RuntimeOrigin = RuntimeOrigin;
179 type BlockHashCount = BlockHashCount;
181 type Version = Version;
183 type PalletInfo = PalletInfo;
185 type AccountData = pallet_balances::AccountData<Balance>;
187 type OnNewAccount = ();
189 type OnKilledAccount = ();
191 type DbWeight = ParityDbWeight;
193 type BaseCallFilter = Everything;
195 type SystemWeightInfo = weights::frame_system::WeightInfo<Runtime>;
197 type BlockWeights = RuntimeBlockWeights;
199 type BlockLength = RuntimeBlockLength;
201 type SS58Prefix = ConstU16<6094>;
202 type OnSetCode = ();
204 type SingleBlockMigrations = ();
205 type MultiBlockMigrator = ();
206 type PreInherents = ();
207 type PostInherents = ();
208 type PostTransactions = ();
209 type MaxConsumers = ConstU32<16>;
210 type ExtensionsWeightInfo = frame_system::SubstrateExtensionsWeight<Runtime>;
211 type EventSegmentSize = DomainEventSegmentSize;
212}
213
214impl pallet_timestamp::Config for Runtime {
215 type Moment = Moment;
217 type OnTimestampSet = ();
218 type MinimumPeriod = ConstU64<{ SLOT_DURATION / 2 }>;
219 type WeightInfo = weights::pallet_timestamp::WeightInfo<Runtime>;
220}
221
222parameter_types! {
223 pub const ExistentialDeposit: Balance = EXISTENTIAL_DEPOSIT;
224 pub const MaxLocks: u32 = 50;
225 pub const MaxReserves: u32 = 50;
226}
227
228pub struct DustRemovalHandler;
230
231impl OnUnbalanced<Credit<AccountId, Balances>> for DustRemovalHandler {
232 fn on_nonzero_unbalanced(dusted_amount: Credit<AccountId, Balances>) {
233 BlockFees::note_burned_balance(dusted_amount.peek());
234 }
235}
236
237impl pallet_balances::Config for Runtime {
238 type RuntimeFreezeReason = RuntimeFreezeReason;
239 type MaxLocks = MaxLocks;
240 type Balance = Balance;
242 type RuntimeEvent = RuntimeEvent;
244 type DustRemoval = DustRemovalHandler;
245 type ExistentialDeposit = ExistentialDeposit;
246 type AccountStore = System;
247 type WeightInfo = weights::pallet_balances::WeightInfo<Runtime>;
248 type MaxReserves = MaxReserves;
249 type ReserveIdentifier = [u8; 8];
250 type FreezeIdentifier = ();
251 type MaxFreezes = ();
252 type RuntimeHoldReason = HoldIdentifierWrapper;
253 type DoneSlashHandler = ();
254}
255
256parameter_types! {
257 pub const OperationalFeeMultiplier: u8 = 5;
258 pub const DomainChainByteFee: Balance = 1;
259 pub TransactionWeightFee: Balance = 100_000 * SHANNON;
260}
261
262impl pallet_block_fees::Config for Runtime {
263 type Balance = Balance;
264 type DomainChainByteFee = DomainChainByteFee;
265}
266
267pub struct FinalDomainTransactionByteFee;
268
269impl Get<Balance> for FinalDomainTransactionByteFee {
270 fn get() -> Balance {
271 BlockFees::final_domain_transaction_byte_fee()
272 }
273}
274
275impl pallet_transaction_payment::Config for Runtime {
276 type RuntimeEvent = RuntimeEvent;
277 type OnChargeTransaction = OnChargeDomainTransaction<Balances>;
278 type WeightToFee = ConstantMultiplier<Balance, TransactionWeightFee>;
279 type LengthToFee = ConstantMultiplier<Balance, FinalDomainTransactionByteFee>;
280 type FeeMultiplierUpdate = SlowAdjustingFeeUpdate<Runtime, TargetBlockFullness>;
281 type OperationalFeeMultiplier = OperationalFeeMultiplier;
282 type WeightInfo = weights::pallet_transaction_payment::WeightInfo<Runtime>;
283}
284
285impl pallet_auto_id::Config for Runtime {
286 type RuntimeEvent = RuntimeEvent;
287 type Time = Timestamp;
288 type Weights = weights::pallet_auto_id::WeightInfo<Runtime>;
289}
290
291pub struct ExtrinsicStorageFees;
292
293impl domain_pallet_executive::ExtrinsicStorageFees<Runtime> for ExtrinsicStorageFees {
294 fn extract_signer(xt: UncheckedExtrinsic) -> (Option<AccountId>, DispatchInfo) {
295 let dispatch_info = xt.get_dispatch_info();
296 let lookup = frame_system::ChainContext::<Runtime>::default();
297 let maybe_signer = extract_signer_inner(&xt, &lookup).and_then(|res| res.ok());
298 (maybe_signer, dispatch_info)
299 }
300
301 fn on_storage_fees_charged(
302 charged_fees: Balance,
303 tx_size: u32,
304 ) -> Result<(), TransactionValidityError> {
305 let consensus_storage_fee = BlockFees::consensus_chain_byte_fee()
306 .checked_mul(Balance::from(tx_size))
307 .ok_or(InvalidTransaction::Custom(ERR_BALANCE_OVERFLOW))?;
308
309 let (paid_consensus_storage_fee, paid_domain_fee) = if charged_fees <= consensus_storage_fee
310 {
311 (charged_fees, Zero::zero())
312 } else {
313 (consensus_storage_fee, charged_fees - consensus_storage_fee)
314 };
315
316 BlockFees::note_consensus_storage_fee(paid_consensus_storage_fee);
317 BlockFees::note_domain_execution_fee(paid_domain_fee);
318 Ok(())
319 }
320}
321
322impl domain_pallet_executive::Config for Runtime {
323 type RuntimeEvent = RuntimeEvent;
324 type WeightInfo = weights::domain_pallet_executive::WeightInfo<Runtime>;
325 type Currency = Balances;
326 type LengthToFee = <Runtime as pallet_transaction_payment::Config>::LengthToFee;
327 type ExtrinsicStorageFees = ExtrinsicStorageFees;
328}
329
330parameter_types! {
331 pub SelfChainId: ChainId = SelfDomainId::self_domain_id().into();
332}
333
334pub struct OnXDMRewards;
335
336impl sp_messenger::OnXDMRewards<Balance> for OnXDMRewards {
337 fn on_xdm_rewards(rewards: Balance) {
338 BlockFees::note_domain_execution_fee(rewards)
339 }
340 fn on_chain_protocol_fees(chain_id: ChainId, fees: Balance) {
341 BlockFees::note_chain_rewards(chain_id, fees);
343 }
344}
345
346type MmrHash = <Keccak256 as sp_runtime::traits::Hash>::Output;
347
348pub struct MmrProofVerifier;
349
350impl sp_subspace_mmr::MmrProofVerifier<MmrHash, NumberFor<Block>, Hash> for MmrProofVerifier {
351 fn verify_proof_and_extract_leaf(
352 mmr_leaf_proof: ConsensusChainMmrLeafProof<NumberFor<Block>, Hash, MmrHash>,
353 ) -> Option<MmrLeaf<ConsensusBlockNumber, ConsensusBlockHash>> {
354 let ConsensusChainMmrLeafProof {
355 consensus_block_number,
356 opaque_mmr_leaf: opaque_leaf,
357 proof,
358 ..
359 } = mmr_leaf_proof;
360
361 if !is_consensus_block_finalized(consensus_block_number) {
362 return None;
363 }
364
365 let leaf: MmrLeaf<ConsensusBlockNumber, ConsensusBlockHash> =
366 opaque_leaf.into_opaque_leaf().try_decode()?;
367
368 verify_mmr_proof(vec![EncodableOpaqueLeaf::from_leaf(&leaf)], proof.encode())
369 .then_some(leaf)
370 }
371}
372
373pub struct StorageKeys;
374
375impl sp_messenger::StorageKeys for StorageKeys {
376 fn confirmed_domain_block_storage_key(domain_id: DomainId) -> Option<Vec<u8>> {
377 get_storage_key(StorageKeyRequest::ConfirmedDomainBlockStorageKey(domain_id))
378 }
379
380 fn outbox_storage_key(chain_id: ChainId, message_key: MessageKey) -> Option<Vec<u8>> {
381 get_storage_key(StorageKeyRequest::OutboxStorageKey {
382 chain_id,
383 message_key,
384 })
385 }
386
387 fn inbox_responses_storage_key(chain_id: ChainId, message_key: MessageKey) -> Option<Vec<u8>> {
388 get_storage_key(StorageKeyRequest::InboxResponseStorageKey {
389 chain_id,
390 message_key,
391 })
392 }
393}
394
395#[derive(
397 PartialEq,
398 Eq,
399 Clone,
400 Encode,
401 Decode,
402 TypeInfo,
403 MaxEncodedLen,
404 Ord,
405 PartialOrd,
406 Copy,
407 Debug,
408 DecodeWithMemTracking,
409)]
410pub struct HoldIdentifierWrapper(HoldIdentifier);
411
412impl VariantCount for HoldIdentifierWrapper {
413 const VARIANT_COUNT: u32 = mem::variant_count::<HoldIdentifier>() as u32;
414}
415
416impl pallet_messenger::HoldIdentifier<Runtime> for HoldIdentifierWrapper {
417 fn messenger_channel() -> Self {
418 Self(HoldIdentifier::MessengerChannel)
419 }
420}
421
422parameter_types! {
423 pub const ChannelReserveFee: Balance = 100 * AI3;
424 pub const ChannelInitReservePortion: Perbill = Perbill::from_percent(20);
425 pub const MaxOutgoingMessages: u32 = MAX_OUTGOING_MESSAGES;
426}
427
428const_assert!(MaxOutgoingMessages::get() >= 1);
430
431impl pallet_messenger::Config for Runtime {
432 type RuntimeEvent = RuntimeEvent;
433 type SelfChainId = SelfChainId;
434
435 fn get_endpoint_handler(endpoint: &Endpoint) -> Option<Box<dyn EndpointHandlerT<MessageId>>> {
436 if endpoint == &Endpoint::Id(TransporterEndpointId::get()) {
437 Some(Box::new(EndpointHandler(PhantomData::<Runtime>)))
438 } else {
439 None
440 }
441 }
442
443 type Currency = Balances;
444 type WeightInfo = weights::pallet_messenger::WeightInfo<Runtime>;
445 type WeightToFee = ConstantMultiplier<Balance, TransactionWeightFee>;
446 type AdjustedWeightToFee = XdmAdjustedWeightToFee<Runtime>;
447 type FeeMultiplier = XdmFeeMultipler;
448 type OnXDMRewards = OnXDMRewards;
449 type MmrHash = MmrHash;
450 type MmrProofVerifier = MmrProofVerifier;
451 #[cfg(feature = "runtime-benchmarks")]
452 type StorageKeys = sp_messenger::BenchmarkStorageKeys;
453 #[cfg(not(feature = "runtime-benchmarks"))]
454 type StorageKeys = StorageKeys;
455 type DomainOwner = ();
456 type HoldIdentifier = HoldIdentifierWrapper;
457 type ChannelReserveFee = ChannelReserveFee;
458 type ChannelInitReservePortion = ChannelInitReservePortion;
459 type DomainRegistration = ();
460 type MaxOutgoingMessages = MaxOutgoingMessages;
461 type MessengerOrigin = pallet_messenger::EnsureMessengerOrigin;
462 type NoteChainTransfer = Transporter;
463 type ExtensionWeightInfo = pallet_messenger::extensions::weights::SubstrateWeight<
464 Runtime,
465 weights::pallet_messenger_from_consensus_extension::WeightInfo<Runtime>,
466 weights::pallet_messenger_between_domains_extension::WeightInfo<Runtime>,
467 >;
468}
469
470impl<C> frame_system::offchain::CreateTransactionBase<C> for Runtime
471where
472 RuntimeCall: From<C>,
473{
474 type Extrinsic = UncheckedExtrinsic;
475 type RuntimeCall = RuntimeCall;
476}
477
478parameter_types! {
479 pub const TransporterEndpointId: EndpointId = 1;
480 pub const MinimumTransfer: Balance = AI3;
481}
482
483impl pallet_transporter::Config for Runtime {
484 type RuntimeEvent = RuntimeEvent;
485 type SelfChainId = SelfChainId;
486 type SelfEndpointId = TransporterEndpointId;
487 type Currency = Balances;
488 type Sender = Messenger;
489 type AccountIdConverter = domain_runtime_primitives::AccountIdConverter;
490 type WeightInfo = weights::pallet_transporter::WeightInfo<Runtime>;
491 type MinimumTransfer = MinimumTransfer;
492}
493
494impl pallet_domain_id::Config for Runtime {}
495
496pub struct IntoRuntimeCall;
497
498impl sp_domain_sudo::IntoRuntimeCall<RuntimeCall> for IntoRuntimeCall {
499 fn runtime_call(call: Vec<u8>) -> RuntimeCall {
500 UncheckedExtrinsic::decode(&mut call.as_slice())
501 .expect("must always be a valid extrinsic as checked by consensus chain; qed")
502 .function
503 }
504}
505
506impl pallet_domain_sudo::Config for Runtime {
507 type RuntimeEvent = RuntimeEvent;
508 type RuntimeCall = RuntimeCall;
509 type IntoRuntimeCall = IntoRuntimeCall;
510}
511
512impl pallet_utility::Config for Runtime {
513 type RuntimeEvent = RuntimeEvent;
514 type RuntimeCall = RuntimeCall;
515 type PalletsOrigin = OriginCaller;
516 type WeightInfo = weights::pallet_utility::WeightInfo<Runtime>;
517}
518
519construct_runtime!(
523 pub struct Runtime {
524 System: frame_system = 0,
526 Timestamp: pallet_timestamp = 1,
530 ExecutivePallet: domain_pallet_executive = 2,
531 Utility: pallet_utility = 8,
532
533 Balances: pallet_balances = 20,
535 TransactionPayment: pallet_transaction_payment = 21,
536
537 AutoId: pallet_auto_id = 40,
539
540 Messenger: pallet_messenger = 60,
543 Transporter: pallet_transporter = 61,
544
545 SelfDomainId: pallet_domain_id = 90,
547 BlockFees: pallet_block_fees = 91,
548
549 Sudo: pallet_domain_sudo = 100,
551 }
552);
553
554impl pallet_messenger::extensions::MaybeMessengerCall<Runtime> for RuntimeCall {
555 fn maybe_messenger_call(&self) -> Option<&pallet_messenger::Call<Runtime>> {
556 match self {
557 RuntimeCall::Messenger(call) => Some(call),
558 _ => None,
559 }
560 }
561}
562
563impl<C> subspace_runtime_primitives::CreateUnsigned<C> for Runtime
564where
565 RuntimeCall: From<C>,
566{
567 fn create_unsigned(call: Self::RuntimeCall) -> Self::Extrinsic {
568 create_unsigned_general_extrinsic(call)
569 }
570}
571
572fn create_unsigned_general_extrinsic(call: RuntimeCall) -> UncheckedExtrinsic {
573 let extra: SignedExtra = (
574 frame_system::CheckNonZeroSender::<Runtime>::new(),
575 frame_system::CheckSpecVersion::<Runtime>::new(),
576 frame_system::CheckTxVersion::<Runtime>::new(),
577 frame_system::CheckGenesis::<Runtime>::new(),
578 frame_system::CheckMortality::<Runtime>::from(generic::Era::Immortal),
579 frame_system::CheckNonce::<Runtime>::from(0u32.into()),
582 domain_check_weight::CheckWeight::<Runtime>::new(),
583 pallet_transaction_payment::ChargeTransactionPayment::<Runtime>::from(0u128),
586 pallet_messenger::extensions::MessengerExtension::<Runtime>::new(),
587 );
588
589 UncheckedExtrinsic::new_transaction(call, extra)
590}
591
592fn is_xdm_mmr_proof_valid(ext: &ExtrinsicFor<Block>) -> Option<bool> {
593 match &ext.function {
594 RuntimeCall::Messenger(pallet_messenger::Call::relay_message { msg })
595 | RuntimeCall::Messenger(pallet_messenger::Call::relay_message_response { msg }) => {
596 let ConsensusChainMmrLeafProof {
597 consensus_block_number,
598 opaque_mmr_leaf,
599 proof,
600 ..
601 } = msg.proof.consensus_mmr_proof();
602
603 if !is_consensus_block_finalized(consensus_block_number) {
604 return Some(false);
605 }
606
607 Some(verify_mmr_proof(vec![opaque_mmr_leaf], proof.encode()))
608 }
609 _ => None,
610 }
611}
612
613fn is_valid_sudo_call(encoded_ext: Vec<u8>) -> bool {
615 UncheckedExtrinsic::decode_all_with_depth_limit(
616 MAX_CALL_RECURSION_DEPTH,
617 &mut encoded_ext.as_slice(),
618 )
619 .is_ok()
620}
621
622fn construct_sudo_call_extrinsic(encoded_ext: Vec<u8>) -> ExtrinsicFor<Block> {
623 let ext = UncheckedExtrinsic::decode(&mut encoded_ext.as_slice()).expect(
624 "must always be a valid extrinsic due to the check above and storage proof check; qed",
625 );
626 UncheckedExtrinsic::new_bare(
627 pallet_domain_sudo::Call::sudo {
628 call: Box::new(ext.function),
629 }
630 .into(),
631 )
632}
633
634fn extract_signer_inner<Lookup>(
635 ext: &UncheckedExtrinsic,
636 lookup: &Lookup,
637) -> Option<Result<AccountId, TransactionValidityError>>
638where
639 Lookup: sp_runtime::traits::Lookup<Source = Address, Target = AccountId>,
640{
641 match &ext.preamble {
642 Preamble::Bare(_) | Preamble::General(_, _) => None,
643 Preamble::Signed(signed, _, _) => Some(lookup.lookup(signed.clone()).map_err(|e| e.into())),
644 }
645}
646
647pub fn extract_signer(
648 extrinsics: Vec<UncheckedExtrinsic>,
649) -> Vec<(Option<opaque::AccountId>, UncheckedExtrinsic)> {
650 let lookup = frame_system::ChainContext::<Runtime>::default();
651
652 extrinsics
653 .into_iter()
654 .map(|extrinsic| {
655 let maybe_signer =
656 extract_signer_inner(&extrinsic, &lookup).and_then(|account_result| {
657 account_result.ok().map(|account_id| account_id.encode())
658 });
659 (maybe_signer, extrinsic)
660 })
661 .collect()
662}
663
664fn extrinsic_era(extrinsic: &ExtrinsicFor<Block>) -> Option<Era> {
665 match &extrinsic.preamble {
666 Preamble::Bare(_) | Preamble::General(_, _) => None,
667 Preamble::Signed(_, _, extra) => Some(extra.4.0),
668 }
669}
670
671#[cfg(feature = "runtime-benchmarks")]
672mod benches {
673 frame_benchmarking::define_benchmarks!(
674 [frame_benchmarking, BaselineBench::<Runtime>]
675 [frame_system, SystemBench::<Runtime>]
676 [pallet_timestamp, Timestamp]
677 [domain_pallet_executive, ExecutivePallet]
678 [pallet_utility, Utility]
679 [pallet_balances, Balances]
680 [pallet_transaction_payment, TransactionPayment]
681 [pallet_auto_id, AutoId]
682 [pallet_messenger, Messenger]
683 [pallet_messenger_from_consensus_extension, MessengerFromConsensusExtensionBench::<Runtime>]
684 [pallet_messenger_between_domains_extension, MessengerBetweenDomainsExtensionBench::<Runtime>]
685 [pallet_transporter, Transporter]
686 );
690}
691
692fn check_transaction_and_do_pre_dispatch_inner(
693 uxt: &ExtrinsicFor<Block>,
694) -> Result<(), TransactionValidityError> {
695 let lookup = frame_system::ChainContext::<Runtime>::default();
696
697 let xt = uxt.clone().check(&lookup)?;
698
699 let dispatch_info = xt.get_dispatch_info();
700
701 if dispatch_info.class == DispatchClass::Mandatory {
702 return Err(InvalidTransaction::MandatoryValidation.into());
703 }
704
705 let encoded_len = uxt.encoded_size();
706
707 match xt.format {
712 ExtrinsicFormat::General(extension_version, extra) => {
713 let custom_extra: CustomSignedExtra = (
714 extra.0,
715 extra.1,
716 extra.2,
717 extra.3,
718 extra.4,
719 extra.5,
720 extra.6.clone(),
721 extra.7,
722 pallet_messenger::extensions::MessengerTrustedMmrExtension::<Runtime>::new(),
723 );
724
725 let origin = RuntimeOrigin::none();
726 <CustomSignedExtra as DispatchTransaction<RuntimeCall>>::validate_and_prepare(
727 custom_extra,
728 origin,
729 &xt.function,
730 &dispatch_info,
731 encoded_len,
732 extension_version,
733 )
734 .map(|_| ())
735 }
736 ExtrinsicFormat::Signed(account_id, extra) => {
738 let origin = RuntimeOrigin::signed(account_id);
739 <SignedExtra as DispatchTransaction<RuntimeCall>>::validate_and_prepare(
740 extra,
741 origin,
742 &xt.function,
743 &dispatch_info,
744 encoded_len,
745 0,
748 )
749 .map(|_| ())
750 }
751 ExtrinsicFormat::Bare => {
753 Runtime::pre_dispatch(&xt.function).map(|_| ())?;
754 <SignedExtra as TransactionExtension<RuntimeCall>>::bare_validate_and_prepare(
755 &xt.function,
756 &dispatch_info,
757 encoded_len,
758 )
759 .map(|_| ())
760 }
761 }
762}
763
764#[cfg(feature = "runtime-benchmarks")]
765impl frame_system_benchmarking::Config for Runtime {}
766
767#[cfg(feature = "runtime-benchmarks")]
768impl frame_benchmarking::baseline::Config for Runtime {}
769
770impl_runtime_apis! {
771 impl sp_api::Core<Block> for Runtime {
772 fn version() -> RuntimeVersion {
773 VERSION
774 }
775
776 fn execute_block(block: Block) {
777 Executive::execute_block(block)
778 }
779
780 fn initialize_block(header: &HeaderFor<Block>) -> ExtrinsicInclusionMode {
781 Executive::initialize_block(header)
782 }
783 }
784
785 impl sp_api::Metadata<Block> for Runtime {
786 fn metadata() -> OpaqueMetadata {
787 OpaqueMetadata::new(Runtime::metadata().into())
788 }
789
790 fn metadata_at_version(version: u32) -> Option<OpaqueMetadata> {
791 Runtime::metadata_at_version(version)
792 }
793
794 fn metadata_versions() -> Vec<u32> {
795 Runtime::metadata_versions()
796 }
797 }
798
799 impl sp_block_builder::BlockBuilder<Block> for Runtime {
800 fn apply_extrinsic(extrinsic: ExtrinsicFor<Block>) -> ApplyExtrinsicResult {
801 Executive::apply_extrinsic(extrinsic)
802 }
803
804 fn finalize_block() -> HeaderFor<Block> {
805 Executive::finalize_block()
806 }
807
808 fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<ExtrinsicFor<Block>> {
809 data.create_extrinsics()
810 }
811
812 fn check_inherents(
813 block: Block,
814 data: sp_inherents::InherentData,
815 ) -> sp_inherents::CheckInherentsResult {
816 data.check_extrinsics(&block)
817 }
818 }
819
820 impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {
821 fn validate_transaction(
822 source: TransactionSource,
823 tx: ExtrinsicFor<Block>,
824 block_hash: BlockHashFor<Block>,
825 ) -> TransactionValidity {
826 Executive::validate_transaction(source, tx, block_hash)
827 }
828 }
829
830 impl sp_offchain::OffchainWorkerApi<Block> for Runtime {
831 fn offchain_worker(header: &HeaderFor<Block>) {
832 Executive::offchain_worker(header)
833 }
834 }
835
836 impl sp_session::SessionKeys<Block> for Runtime {
837 fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {
838 SessionKeys::generate(seed)
839 }
840
841 fn decode_session_keys(
842 encoded: Vec<u8>,
843 ) -> Option<Vec<(Vec<u8>, KeyTypeId)>> {
844 SessionKeys::decode_into_raw_public_keys(&encoded)
845 }
846 }
847
848 impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Nonce> for Runtime {
849 fn account_nonce(account: AccountId) -> Nonce {
850 *System::account_nonce(account)
851 }
852 }
853
854 impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance> for Runtime {
855 fn query_info(
856 uxt: ExtrinsicFor<Block>,
857 len: u32,
858 ) -> pallet_transaction_payment_rpc_runtime_api::RuntimeDispatchInfo<Balance> {
859 TransactionPayment::query_info(uxt, len)
860 }
861 fn query_fee_details(
862 uxt: ExtrinsicFor<Block>,
863 len: u32,
864 ) -> pallet_transaction_payment::FeeDetails<Balance> {
865 TransactionPayment::query_fee_details(uxt, len)
866 }
867 fn query_weight_to_fee(weight: Weight) -> Balance {
868 TransactionPayment::weight_to_fee(weight)
869 }
870 fn query_length_to_fee(length: u32) -> Balance {
871 TransactionPayment::length_to_fee(length)
872 }
873 }
874
875 impl sp_domains::core_api::DomainCoreApi<Block> for Runtime {
876 fn extract_signer(
877 extrinsics: Vec<ExtrinsicFor<Block>>,
878 ) -> Vec<(Option<opaque::AccountId>, ExtrinsicFor<Block>)> {
879 extract_signer(extrinsics)
880 }
881
882 fn is_within_tx_range(
883 extrinsic: &ExtrinsicFor<Block>,
884 bundle_vrf_hash: &subspace_core_primitives::U256,
885 tx_range: &subspace_core_primitives::U256
886 ) -> bool {
887 use subspace_core_primitives::U256;
888 use subspace_core_primitives::hashes::blake3_hash;
889
890 let lookup = frame_system::ChainContext::<Runtime>::default();
891 if let Some(signer) = extract_signer_inner(extrinsic, &lookup).and_then(|account_result| {
892 account_result.ok().map(|account_id| account_id.encode())
893 }) {
894 let signer_id_hash = U256::from_be_bytes(*blake3_hash(&signer.encode()));
896 sp_domains::signer_in_tx_range(bundle_vrf_hash, &signer_id_hash, tx_range)
897 } else {
898 true
900 }
901 }
902
903 fn extract_signer_if_all_within_tx_range(
904 extrinsics: &Vec<ExtrinsicFor<Block>>,
905 bundle_vrf_hash: &subspace_core_primitives::U256,
906 tx_range: &subspace_core_primitives::U256
907 ) -> Result<Vec<Option<opaque::AccountId>> , u32> {
908 use subspace_core_primitives::U256;
909 use subspace_core_primitives::hashes::blake3_hash;
910
911 let mut signers = Vec::with_capacity(extrinsics.len());
912 let lookup = frame_system::ChainContext::<Runtime>::default();
913 for (index, extrinsic) in extrinsics.iter().enumerate() {
914 let maybe_signer = extract_signer_inner(extrinsic, &lookup).and_then(|account_result| {
915 account_result.ok().map(|account_id| account_id.encode())
916 });
917 if let Some(signer) = &maybe_signer {
918 let signer_id_hash = U256::from_be_bytes(*blake3_hash(&signer.encode()));
920 if !sp_domains::signer_in_tx_range(bundle_vrf_hash, &signer_id_hash, tx_range) {
921 return Err(index as u32)
922 }
923 }
924 signers.push(maybe_signer);
925 }
926
927 Ok(signers)
928 }
929
930 fn initialize_block_with_post_state_root(header: &HeaderFor<Block>) -> Vec<u8> {
931 Executive::initialize_block(header);
932 Executive::storage_root()
933 }
934
935 fn apply_extrinsic_with_post_state_root(extrinsic: ExtrinsicFor<Block>) -> Vec<u8> {
936 let _ = Executive::apply_extrinsic(extrinsic);
937 Executive::storage_root()
938 }
939
940 fn construct_set_code_extrinsic(code: Vec<u8>) -> Vec<u8> {
941 UncheckedExtrinsic::new_bare(
942 domain_pallet_executive::Call::set_code {
943 code
944 }.into()
945 ).encode()
946 }
947
948 fn construct_timestamp_extrinsic(moment: Moment) -> ExtrinsicFor<Block> {
949 UncheckedExtrinsic::new_bare(
950 pallet_timestamp::Call::set{ now: moment }.into()
951 )
952 }
953
954 fn is_inherent_extrinsic(extrinsic: &ExtrinsicFor<Block>) -> bool {
955 <Self as IsInherent<_>>::is_inherent(extrinsic)
956 }
957
958 fn find_first_inherent_extrinsic(extrinsics: &Vec<ExtrinsicFor<Block>>) -> Option<u32> {
959 for (index, extrinsic) in extrinsics.iter().enumerate() {
960 if <Self as IsInherent<_>>::is_inherent(extrinsic) {
961 return Some(index as u32)
962 }
963 }
964 None
965 }
966
967 fn check_extrinsics_and_do_pre_dispatch(uxts: Vec<ExtrinsicFor<Block>>, block_number: BlockNumber,
968 block_hash: BlockHashFor<Block>) -> Result<(), CheckExtrinsicsValidityError> {
969 System::initialize(
971 &(block_number + BlockNumber::one()),
972 &block_hash,
973 &Default::default(),
974 );
975
976 for (extrinsic_index, uxt) in uxts.iter().enumerate() {
977 check_transaction_and_do_pre_dispatch_inner(uxt).map_err(|e| {
978 CheckExtrinsicsValidityError {
979 extrinsic_index: extrinsic_index as u32,
980 transaction_validity_error: e
981 }
982 })?;
983 }
984
985 Ok(())
986 }
987
988 fn decode_extrinsic(
989 opaque_extrinsic: sp_runtime::OpaqueExtrinsic,
990 ) -> Result<ExtrinsicFor<Block>, DecodeExtrinsicError> {
991 let encoded = opaque_extrinsic.encode();
992
993 UncheckedExtrinsic::decode_all_with_depth_limit(
994 MAX_CALL_RECURSION_DEPTH,
995 &mut encoded.as_slice(),
996 ).map_err(|err| DecodeExtrinsicError(format!("{err}")))
997 }
998
999 fn decode_extrinsics_prefix(
1000 opaque_extrinsics: Vec<sp_runtime::OpaqueExtrinsic>,
1001 ) -> Vec<ExtrinsicFor<Block>> {
1002 let mut extrinsics = Vec::with_capacity(opaque_extrinsics.len());
1003 for opaque_ext in opaque_extrinsics {
1004 match UncheckedExtrinsic::decode_all_with_depth_limit(
1005 MAX_CALL_RECURSION_DEPTH,
1006 &mut opaque_ext.encode().as_slice(),
1007 ) {
1008 Ok(tx) => extrinsics.push(tx),
1009 Err(_) => return extrinsics,
1010 }
1011 }
1012 extrinsics
1013 }
1014
1015 fn extrinsic_era(
1016 extrinsic: &ExtrinsicFor<Block>
1017 ) -> Option<Era> {
1018 extrinsic_era(extrinsic)
1019 }
1020
1021 fn extrinsic_weight(ext: &ExtrinsicFor<Block>) -> Weight {
1022 let len = ext.encoded_size() as u64;
1023 let info = ext.get_dispatch_info();
1024 info.call_weight.saturating_add(info.extension_weight)
1025 .saturating_add(<Runtime as frame_system::Config>::BlockWeights::get().get(info.class).base_extrinsic)
1026 .saturating_add(Weight::from_parts(0, len))
1027 }
1028
1029 fn extrinsics_weight(extrinsics: &Vec<ExtrinsicFor<Block>>) -> Weight {
1030 let mut total_weight = Weight::zero();
1031 for ext in extrinsics {
1032 let ext_weight = {
1033 let len = ext.encoded_size() as u64;
1034 let info = ext.get_dispatch_info();
1035 info.call_weight.saturating_add(info.extension_weight)
1036 .saturating_add(<Runtime as frame_system::Config>::BlockWeights::get().get(info.class).base_extrinsic)
1037 .saturating_add(Weight::from_parts(0, len))
1038 };
1039 total_weight = total_weight.saturating_add(ext_weight);
1040 }
1041 total_weight
1042 }
1043
1044 fn block_fees() -> sp_domains::execution_receipt::BlockFees<Balance> {
1045 BlockFees::collected_block_fees()
1046 }
1047
1048 fn block_digest() -> Digest {
1049 System::digest()
1050 }
1051
1052 fn block_weight() -> Weight {
1053 System::block_weight().total()
1054 }
1055
1056 fn construct_consensus_chain_byte_fee_extrinsic(transaction_byte_fee: Balance) -> ExtrinsicFor<Block> {
1057 UncheckedExtrinsic::new_bare(
1058 pallet_block_fees::Call::set_next_consensus_chain_byte_fee { transaction_byte_fee }.into()
1059 )
1060 }
1061
1062 fn construct_domain_update_chain_allowlist_extrinsic(updates: DomainAllowlistUpdates) -> ExtrinsicFor<Block> {
1063 UncheckedExtrinsic::new_bare(
1064 pallet_messenger::Call::update_domain_allowlist{ updates }.into()
1065 )
1066 }
1067
1068 fn transfers() -> Transfers<Balance> {
1069 Transporter::chain_transfers()
1070 }
1071
1072 fn transfers_storage_key() -> Vec<u8> {
1073 Transporter::transfers_storage_key()
1074 }
1075
1076 fn block_fees_storage_key() -> Vec<u8> {
1077 BlockFees::block_fees_storage_key()
1078 }
1079 }
1080
1081 impl sp_messenger::MessengerApi<Block, ConsensusBlockNumber, ConsensusBlockHash> for Runtime {
1082 fn is_xdm_mmr_proof_valid(
1083 extrinsic: &ExtrinsicFor<Block>,
1084 ) -> Option<bool> {
1085 is_xdm_mmr_proof_valid(extrinsic)
1086 }
1087
1088 fn extract_xdm_mmr_proof(ext: &ExtrinsicFor<Block>) -> Option<ConsensusChainMmrLeafProof<ConsensusBlockNumber, ConsensusBlockHash, sp_core::H256>> {
1089 match &ext.function {
1090 RuntimeCall::Messenger(pallet_messenger::Call::relay_message { msg })
1091 | RuntimeCall::Messenger(pallet_messenger::Call::relay_message_response { msg }) => {
1092 Some(msg.proof.consensus_mmr_proof())
1093 }
1094 _ => None,
1095 }
1096 }
1097
1098 fn batch_extract_xdm_mmr_proof(extrinsics: &Vec<ExtrinsicFor<Block>>) -> BTreeMap<u32, ConsensusChainMmrLeafProof<ConsensusBlockNumber, ConsensusBlockHash, sp_core::H256>> {
1099 let mut mmr_proofs = BTreeMap::new();
1100 for (index, ext) in extrinsics.iter().enumerate() {
1101 match &ext.function {
1102 RuntimeCall::Messenger(pallet_messenger::Call::relay_message { msg })
1103 | RuntimeCall::Messenger(pallet_messenger::Call::relay_message_response { msg }) => {
1104 mmr_proofs.insert(index as u32, msg.proof.consensus_mmr_proof());
1105 }
1106 _ => {},
1107 }
1108 }
1109 mmr_proofs
1110 }
1111
1112 fn confirmed_domain_block_storage_key(_domain_id: DomainId) -> Vec<u8> {
1113 vec![]
1115 }
1116
1117 fn outbox_storage_key(message_key: MessageKey) -> Vec<u8> {
1118 Messenger::outbox_storage_key(message_key)
1119 }
1120
1121 fn inbox_response_storage_key(message_key: MessageKey) -> Vec<u8> {
1122 Messenger::inbox_response_storage_key(message_key)
1123 }
1124
1125 fn domain_chains_allowlist_update(_domain_id: DomainId) -> Option<DomainAllowlistUpdates>{
1126 None
1128 }
1129
1130 fn xdm_id(ext: &ExtrinsicFor<Block>) -> Option<XdmId> {
1131 match &ext.function {
1132 RuntimeCall::Messenger(pallet_messenger::Call::relay_message { msg })=> {
1133 Some(XdmId::RelayMessage((msg.src_chain_id, msg.channel_id, msg.nonce)))
1134 }
1135 RuntimeCall::Messenger(pallet_messenger::Call::relay_message_response { msg }) => {
1136 Some(XdmId::RelayResponseMessage((msg.src_chain_id, msg.channel_id, msg.nonce)))
1137 }
1138 _ => None,
1139 }
1140 }
1141
1142 fn channel_nonce(chain_id: ChainId, channel_id: ChannelId) -> Option<ChannelNonce> {
1143 Messenger::channel_nonce(chain_id, channel_id)
1144 }
1145 }
1146
1147 impl sp_messenger::RelayerApi<Block, BlockNumber, ConsensusBlockNumber, ConsensusBlockHash> for Runtime {
1148 fn outbox_message_unsigned(msg: CrossDomainMessage<NumberFor<Block>, BlockHashFor<Block>, BlockHashFor<Block>>) -> Option<ExtrinsicFor<Block>> {
1149 Messenger::outbox_message_unsigned(msg)
1150 }
1151
1152 fn inbox_response_message_unsigned(msg: CrossDomainMessage<NumberFor<Block>, BlockHashFor<Block>, BlockHashFor<Block>>) -> Option<ExtrinsicFor<Block>> {
1153 Messenger::inbox_response_message_unsigned(msg)
1154 }
1155
1156 fn updated_channels() -> BTreeSet<(ChainId, ChannelId)> {
1157 Messenger::updated_channels()
1158 }
1159
1160 fn channel_storage_key(chain_id: ChainId, channel_id: ChannelId) -> Vec<u8> {
1161 Messenger::channel_storage_key(chain_id, channel_id)
1162 }
1163
1164 fn open_channels() -> BTreeSet<(ChainId, ChannelId)> {
1165 Messenger::open_channels()
1166 }
1167
1168 fn block_messages_with_query(query: BlockMessagesQuery) -> MessagesWithStorageKey {
1169 Messenger::get_block_messages(query)
1170 }
1171
1172 fn channels_and_state() -> Vec<(ChainId, ChannelId, ChannelStateWithNonce)> {
1173 Messenger::channels_and_states()
1174 }
1175
1176 fn first_outbox_message_nonce_to_relay(dst_chain_id: ChainId, channel_id: ChannelId, from_nonce: XdmNonce) -> Option<XdmNonce> {
1177 Messenger::first_outbox_message_nonce_to_relay(dst_chain_id, channel_id, from_nonce)
1178 }
1179
1180 fn first_inbox_message_response_nonce_to_relay(dst_chain_id: ChainId, channel_id: ChannelId, from_nonce: XdmNonce) -> Option<XdmNonce> {
1181 Messenger::first_inbox_message_response_nonce_to_relay(dst_chain_id, channel_id, from_nonce)
1182 }
1183 }
1184
1185 impl sp_domain_sudo::DomainSudoApi<Block> for Runtime {
1186 fn is_valid_sudo_call(extrinsic: Vec<u8>) -> bool {
1187 is_valid_sudo_call(extrinsic)
1188 }
1189
1190 fn construct_domain_sudo_extrinsic(inner: Vec<u8>) -> ExtrinsicFor<Block> {
1191 construct_sudo_call_extrinsic(inner)
1192 }
1193 }
1194
1195 impl sp_genesis_builder::GenesisBuilder<Block> for Runtime {
1196 fn build_state(config: Vec<u8>) -> sp_genesis_builder::Result {
1197 build_state::<RuntimeGenesisConfig>(config)
1198 }
1199
1200 fn get_preset(_id: &Option<sp_genesis_builder::PresetId>) -> Option<Vec<u8>> {
1201 get_preset::<RuntimeGenesisConfig>(&None, |_| None)
1203 }
1204
1205 fn preset_names() -> Vec<sp_genesis_builder::PresetId> {
1206 vec![]
1207 }
1208 }
1209
1210 #[cfg(feature = "runtime-benchmarks")]
1211 impl frame_benchmarking::Benchmark<Block> for Runtime {
1212 fn benchmark_metadata(extra: bool) -> (
1213 Vec<frame_benchmarking::BenchmarkList>,
1214 Vec<frame_support::traits::StorageInfo>,
1215 ) {
1216 use frame_benchmarking::{baseline, BenchmarkList};
1217 use frame_support::traits::StorageInfoTrait;
1218 use frame_system_benchmarking::Pallet as SystemBench;
1219 use baseline::Pallet as BaselineBench;
1220 use pallet_messenger::extensions::benchmarking_from_consensus::Pallet as MessengerFromConsensusExtensionBench;
1221 use pallet_messenger::extensions::benchmarking_between_domains::Pallet as MessengerBetweenDomainsExtensionBench;
1222
1223 let mut list = Vec::<BenchmarkList>::new();
1224
1225 list_benchmarks!(list, extra);
1226
1227 let storage_info = AllPalletsWithSystem::storage_info();
1228
1229 (list, storage_info)
1230 }
1231
1232 fn dispatch_benchmark(
1233 config: frame_benchmarking::BenchmarkConfig
1234 ) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, alloc::string::String> {
1235 use frame_benchmarking::{baseline, BenchmarkBatch};
1236 use sp_storage::TrackedStorageKey;
1237 use frame_system_benchmarking::Pallet as SystemBench;
1238 use frame_support::traits::WhitelistedStorageKeys;
1239 use baseline::Pallet as BaselineBench;
1240 use pallet_messenger::extensions::benchmarking_from_consensus::Pallet as MessengerFromConsensusExtensionBench;
1241 use pallet_messenger::extensions::benchmarking_between_domains::Pallet as MessengerBetweenDomainsExtensionBench;
1242
1243 let whitelist: Vec<TrackedStorageKey> = AllPalletsWithSystem::whitelisted_storage_keys();
1244
1245 let mut batches = Vec::<BenchmarkBatch>::new();
1246 let params = (&config, &whitelist);
1247
1248 add_benchmarks!(params, batches);
1249
1250 if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) }
1251 Ok(batches)
1252 }
1253 }
1254}
1255
1256#[cfg(test)]
1257mod tests {
1258 use crate::{Runtime, RuntimeBlockWeights as BlockWeights};
1259 use subspace_runtime_primitives::tests_utils::FeeMultiplierUtils;
1260
1261 #[test]
1262 fn multiplier_can_grow_from_zero() {
1263 FeeMultiplierUtils::<Runtime, BlockWeights>::multiplier_can_grow_from_zero()
1264 }
1265}