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 RuntimeEvent = RuntimeEvent;
160 type AccountId = AccountId;
162 type RuntimeCall = RuntimeCall;
164 type RuntimeTask = RuntimeTask;
166 type Lookup = AccountIdLookup<AccountId, ()>;
168 type Nonce = TypeWithDefault<Nonce, DefaultNonceProvider<System, Nonce>>;
170 type Hash = Hash;
172 type Hashing = BlakeTwo256;
174 type Block = Block;
176 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 RuntimeEvent = RuntimeEvent;
239 type RuntimeFreezeReason = RuntimeFreezeReason;
240 type MaxLocks = MaxLocks;
241 type Balance = Balance;
243 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 Time = Timestamp;
287 type Weights = weights::pallet_auto_id::WeightInfo<Runtime>;
288}
289
290pub struct ExtrinsicStorageFees;
291
292impl domain_pallet_executive::ExtrinsicStorageFees<Runtime> for ExtrinsicStorageFees {
293 fn extract_signer(xt: UncheckedExtrinsic) -> (Option<AccountId>, DispatchInfo) {
294 let dispatch_info = xt.get_dispatch_info();
295 let lookup = frame_system::ChainContext::<Runtime>::default();
296 let maybe_signer = extract_signer_inner(&xt, &lookup).and_then(|res| res.ok());
297 (maybe_signer, dispatch_info)
298 }
299
300 fn on_storage_fees_charged(
301 charged_fees: Balance,
302 tx_size: u32,
303 ) -> Result<(), TransactionValidityError> {
304 let consensus_storage_fee = BlockFees::consensus_chain_byte_fee()
305 .checked_mul(Balance::from(tx_size))
306 .ok_or(InvalidTransaction::Custom(ERR_BALANCE_OVERFLOW))?;
307
308 let (paid_consensus_storage_fee, paid_domain_fee) = if charged_fees <= consensus_storage_fee
309 {
310 (charged_fees, Zero::zero())
311 } else {
312 (consensus_storage_fee, charged_fees - consensus_storage_fee)
313 };
314
315 BlockFees::note_consensus_storage_fee(paid_consensus_storage_fee);
316 BlockFees::note_domain_execution_fee(paid_domain_fee);
317 Ok(())
318 }
319}
320
321impl domain_pallet_executive::Config for Runtime {
322 type WeightInfo = weights::domain_pallet_executive::WeightInfo<Runtime>;
323 type Currency = Balances;
324 type LengthToFee = <Runtime as pallet_transaction_payment::Config>::LengthToFee;
325 type ExtrinsicStorageFees = ExtrinsicStorageFees;
326}
327
328parameter_types! {
329 pub SelfChainId: ChainId = SelfDomainId::self_domain_id().into();
330}
331
332pub struct OnXDMRewards;
333
334impl sp_messenger::OnXDMRewards<Balance> for OnXDMRewards {
335 fn on_xdm_rewards(rewards: Balance) {
336 BlockFees::note_domain_execution_fee(rewards)
337 }
338 fn on_chain_protocol_fees(chain_id: ChainId, fees: Balance) {
339 BlockFees::note_chain_rewards(chain_id, fees);
341 }
342}
343
344type MmrHash = <Keccak256 as sp_runtime::traits::Hash>::Output;
345
346pub struct MmrProofVerifier;
347
348impl sp_subspace_mmr::MmrProofVerifier<MmrHash, NumberFor<Block>, Hash> for MmrProofVerifier {
349 fn verify_proof_and_extract_leaf(
350 mmr_leaf_proof: ConsensusChainMmrLeafProof<NumberFor<Block>, Hash, MmrHash>,
351 ) -> Option<MmrLeaf<ConsensusBlockNumber, ConsensusBlockHash>> {
352 let ConsensusChainMmrLeafProof {
353 consensus_block_number,
354 opaque_mmr_leaf: opaque_leaf,
355 proof,
356 ..
357 } = mmr_leaf_proof;
358
359 if !is_consensus_block_finalized(consensus_block_number) {
360 return None;
361 }
362
363 let leaf: MmrLeaf<ConsensusBlockNumber, ConsensusBlockHash> =
364 opaque_leaf.into_opaque_leaf().try_decode()?;
365
366 verify_mmr_proof(vec![EncodableOpaqueLeaf::from_leaf(&leaf)], proof.encode())
367 .then_some(leaf)
368 }
369}
370
371pub struct StorageKeys;
372
373impl sp_messenger::StorageKeys for StorageKeys {
374 fn confirmed_domain_block_storage_key(domain_id: DomainId) -> Option<Vec<u8>> {
375 get_storage_key(StorageKeyRequest::ConfirmedDomainBlockStorageKey(domain_id))
376 }
377
378 fn outbox_storage_key(chain_id: ChainId, message_key: MessageKey) -> Option<Vec<u8>> {
379 get_storage_key(StorageKeyRequest::OutboxStorageKey {
380 chain_id,
381 message_key,
382 })
383 }
384
385 fn inbox_responses_storage_key(chain_id: ChainId, message_key: MessageKey) -> Option<Vec<u8>> {
386 get_storage_key(StorageKeyRequest::InboxResponseStorageKey {
387 chain_id,
388 message_key,
389 })
390 }
391}
392
393#[derive(
395 PartialEq,
396 Eq,
397 Clone,
398 Encode,
399 Decode,
400 TypeInfo,
401 MaxEncodedLen,
402 Ord,
403 PartialOrd,
404 Copy,
405 Debug,
406 DecodeWithMemTracking,
407)]
408pub struct HoldIdentifierWrapper(HoldIdentifier);
409
410impl VariantCount for HoldIdentifierWrapper {
411 const VARIANT_COUNT: u32 = mem::variant_count::<HoldIdentifier>() as u32;
412}
413
414impl pallet_messenger::HoldIdentifier<Runtime> for HoldIdentifierWrapper {
415 fn messenger_channel() -> Self {
416 Self(HoldIdentifier::MessengerChannel)
417 }
418}
419
420parameter_types! {
421 pub const ChannelReserveFee: Balance = 100 * AI3;
422 pub const ChannelInitReservePortion: Perbill = Perbill::from_percent(20);
423 pub const MaxOutgoingMessages: u32 = MAX_OUTGOING_MESSAGES;
424}
425
426const_assert!(MaxOutgoingMessages::get() >= 1);
428
429impl pallet_messenger::Config for Runtime {
430 type SelfChainId = SelfChainId;
431
432 fn get_endpoint_handler(endpoint: &Endpoint) -> Option<Box<dyn EndpointHandlerT<MessageId>>> {
433 if endpoint == &Endpoint::Id(TransporterEndpointId::get()) {
434 Some(Box::new(EndpointHandler(PhantomData::<Runtime>)))
435 } else {
436 None
437 }
438 }
439
440 type Currency = Balances;
441 type WeightInfo = weights::pallet_messenger::WeightInfo<Runtime>;
442 type WeightToFee = ConstantMultiplier<Balance, TransactionWeightFee>;
443 type AdjustedWeightToFee = XdmAdjustedWeightToFee<Runtime>;
444 type FeeMultiplier = XdmFeeMultipler;
445 type OnXDMRewards = OnXDMRewards;
446 type MmrHash = MmrHash;
447 type MmrProofVerifier = MmrProofVerifier;
448 #[cfg(feature = "runtime-benchmarks")]
449 type StorageKeys = sp_messenger::BenchmarkStorageKeys;
450 #[cfg(not(feature = "runtime-benchmarks"))]
451 type StorageKeys = StorageKeys;
452 type DomainOwner = ();
453 type HoldIdentifier = HoldIdentifierWrapper;
454 type ChannelReserveFee = ChannelReserveFee;
455 type ChannelInitReservePortion = ChannelInitReservePortion;
456 type DomainRegistration = ();
457 type MaxOutgoingMessages = MaxOutgoingMessages;
458 type MessengerOrigin = pallet_messenger::EnsureMessengerOrigin;
459 type NoteChainTransfer = Transporter;
460 type ExtensionWeightInfo = pallet_messenger::extensions::weights::SubstrateWeight<
461 Runtime,
462 weights::pallet_messenger_from_consensus_extension::WeightInfo<Runtime>,
463 weights::pallet_messenger_between_domains_extension::WeightInfo<Runtime>,
464 >;
465}
466
467impl<C> frame_system::offchain::CreateTransactionBase<C> for Runtime
468where
469 RuntimeCall: From<C>,
470{
471 type Extrinsic = UncheckedExtrinsic;
472 type RuntimeCall = RuntimeCall;
473}
474
475parameter_types! {
476 pub const TransporterEndpointId: EndpointId = 1;
477 pub const MinimumTransfer: Balance = AI3;
478}
479
480impl pallet_transporter::Config for Runtime {
481 type SelfChainId = SelfChainId;
482 type SelfEndpointId = TransporterEndpointId;
483 type Currency = Balances;
484 type Sender = Messenger;
485 type AccountIdConverter = domain_runtime_primitives::AccountIdConverter;
486 type WeightInfo = weights::pallet_transporter::WeightInfo<Runtime>;
487 type MinimumTransfer = MinimumTransfer;
488}
489
490impl pallet_domain_id::Config for Runtime {}
491
492pub struct IntoRuntimeCall;
493
494impl sp_domain_sudo::IntoRuntimeCall<RuntimeCall> for IntoRuntimeCall {
495 fn runtime_call(call: Vec<u8>) -> RuntimeCall {
496 UncheckedExtrinsic::decode(&mut call.as_slice())
497 .expect("must always be a valid extrinsic as checked by consensus chain; qed")
498 .function
499 }
500}
501
502impl pallet_domain_sudo::Config for Runtime {
503 type RuntimeCall = RuntimeCall;
504 type IntoRuntimeCall = IntoRuntimeCall;
505}
506
507impl pallet_utility::Config for Runtime {
508 type RuntimeEvent = RuntimeEvent;
509 type RuntimeCall = RuntimeCall;
510 type PalletsOrigin = OriginCaller;
511 type WeightInfo = weights::pallet_utility::WeightInfo<Runtime>;
512}
513
514construct_runtime!(
518 pub struct Runtime {
519 System: frame_system = 0,
521 Timestamp: pallet_timestamp = 1,
525 ExecutivePallet: domain_pallet_executive = 2,
526 Utility: pallet_utility = 8,
527
528 Balances: pallet_balances = 20,
530 TransactionPayment: pallet_transaction_payment = 21,
531
532 AutoId: pallet_auto_id = 40,
534
535 Messenger: pallet_messenger = 60,
538 Transporter: pallet_transporter = 61,
539
540 SelfDomainId: pallet_domain_id = 90,
542 BlockFees: pallet_block_fees = 91,
543
544 Sudo: pallet_domain_sudo = 100,
546 }
547);
548
549impl pallet_messenger::extensions::MaybeMessengerCall<Runtime> for RuntimeCall {
550 fn maybe_messenger_call(&self) -> Option<&pallet_messenger::Call<Runtime>> {
551 match self {
552 RuntimeCall::Messenger(call) => Some(call),
553 _ => None,
554 }
555 }
556}
557
558impl<C> subspace_runtime_primitives::CreateUnsigned<C> for Runtime
559where
560 RuntimeCall: From<C>,
561{
562 fn create_unsigned(call: Self::RuntimeCall) -> Self::Extrinsic {
563 create_unsigned_general_extrinsic(call)
564 }
565}
566
567fn create_unsigned_general_extrinsic(call: RuntimeCall) -> UncheckedExtrinsic {
568 let extra: SignedExtra = (
569 frame_system::CheckNonZeroSender::<Runtime>::new(),
570 frame_system::CheckSpecVersion::<Runtime>::new(),
571 frame_system::CheckTxVersion::<Runtime>::new(),
572 frame_system::CheckGenesis::<Runtime>::new(),
573 frame_system::CheckMortality::<Runtime>::from(generic::Era::Immortal),
574 frame_system::CheckNonce::<Runtime>::from(0u32.into()),
577 domain_check_weight::CheckWeight::<Runtime>::new(),
578 pallet_transaction_payment::ChargeTransactionPayment::<Runtime>::from(0u128),
581 pallet_messenger::extensions::MessengerExtension::<Runtime>::new(),
582 );
583
584 UncheckedExtrinsic::new_transaction(call, extra)
585}
586
587fn is_xdm_mmr_proof_valid(ext: &ExtrinsicFor<Block>) -> Option<bool> {
588 match &ext.function {
589 RuntimeCall::Messenger(pallet_messenger::Call::relay_message { msg })
590 | RuntimeCall::Messenger(pallet_messenger::Call::relay_message_response { msg }) => {
591 let ConsensusChainMmrLeafProof {
592 consensus_block_number,
593 opaque_mmr_leaf,
594 proof,
595 ..
596 } = msg.proof.consensus_mmr_proof();
597
598 if !is_consensus_block_finalized(consensus_block_number) {
599 return Some(false);
600 }
601
602 Some(verify_mmr_proof(vec![opaque_mmr_leaf], proof.encode()))
603 }
604 _ => None,
605 }
606}
607
608fn is_valid_sudo_call(encoded_ext: Vec<u8>) -> bool {
610 UncheckedExtrinsic::decode_all_with_depth_limit(
611 MAX_CALL_RECURSION_DEPTH,
612 &mut encoded_ext.as_slice(),
613 )
614 .is_ok()
615}
616
617fn construct_sudo_call_extrinsic(encoded_ext: Vec<u8>) -> ExtrinsicFor<Block> {
618 let ext = UncheckedExtrinsic::decode(&mut encoded_ext.as_slice()).expect(
619 "must always be a valid extrinsic due to the check above and storage proof check; qed",
620 );
621 UncheckedExtrinsic::new_bare(
622 pallet_domain_sudo::Call::sudo {
623 call: Box::new(ext.function),
624 }
625 .into(),
626 )
627}
628
629fn extract_signer_inner<Lookup>(
630 ext: &UncheckedExtrinsic,
631 lookup: &Lookup,
632) -> Option<Result<AccountId, TransactionValidityError>>
633where
634 Lookup: sp_runtime::traits::Lookup<Source = Address, Target = AccountId>,
635{
636 match &ext.preamble {
637 Preamble::Bare(_) | Preamble::General(_, _) => None,
638 Preamble::Signed(signed, _, _) => Some(lookup.lookup(signed.clone()).map_err(|e| e.into())),
639 }
640}
641
642pub fn extract_signer(
643 extrinsics: Vec<UncheckedExtrinsic>,
644) -> Vec<(Option<opaque::AccountId>, UncheckedExtrinsic)> {
645 let lookup = frame_system::ChainContext::<Runtime>::default();
646
647 extrinsics
648 .into_iter()
649 .map(|extrinsic| {
650 let maybe_signer =
651 extract_signer_inner(&extrinsic, &lookup).and_then(|account_result| {
652 account_result.ok().map(|account_id| account_id.encode())
653 });
654 (maybe_signer, extrinsic)
655 })
656 .collect()
657}
658
659fn extrinsic_era(extrinsic: &ExtrinsicFor<Block>) -> Option<Era> {
660 match &extrinsic.preamble {
661 Preamble::Bare(_) | Preamble::General(_, _) => None,
662 Preamble::Signed(_, _, extra) => Some(extra.4.0),
663 }
664}
665
666#[cfg(feature = "runtime-benchmarks")]
667mod benches {
668 frame_benchmarking::define_benchmarks!(
669 [frame_benchmarking, BaselineBench::<Runtime>]
670 [frame_system, SystemBench::<Runtime>]
671 [pallet_timestamp, Timestamp]
672 [domain_pallet_executive, ExecutivePallet]
673 [pallet_utility, Utility]
674 [pallet_balances, Balances]
675 [pallet_transaction_payment, TransactionPayment]
676 [pallet_auto_id, AutoId]
677 [pallet_messenger, Messenger]
678 [pallet_messenger_from_consensus_extension, MessengerFromConsensusExtensionBench::<Runtime>]
679 [pallet_messenger_between_domains_extension, MessengerBetweenDomainsExtensionBench::<Runtime>]
680 [pallet_transporter, Transporter]
681 );
685}
686
687fn check_transaction_and_do_pre_dispatch_inner(
688 uxt: &ExtrinsicFor<Block>,
689) -> Result<(), TransactionValidityError> {
690 let lookup = frame_system::ChainContext::<Runtime>::default();
691
692 let xt = uxt.clone().check(&lookup)?;
693
694 let dispatch_info = xt.get_dispatch_info();
695
696 if dispatch_info.class == DispatchClass::Mandatory {
697 return Err(InvalidTransaction::MandatoryValidation.into());
698 }
699
700 let encoded_len = uxt.encoded_size();
701
702 match xt.format {
707 ExtrinsicFormat::General(extension_version, extra) => {
708 let custom_extra: CustomSignedExtra = (
709 extra.0,
710 extra.1,
711 extra.2,
712 extra.3,
713 extra.4,
714 extra.5,
715 extra.6.clone(),
716 extra.7,
717 pallet_messenger::extensions::MessengerTrustedMmrExtension::<Runtime>::new(),
718 );
719
720 let origin = RuntimeOrigin::none();
721 <CustomSignedExtra as DispatchTransaction<RuntimeCall>>::validate_and_prepare(
722 custom_extra,
723 origin,
724 &xt.function,
725 &dispatch_info,
726 encoded_len,
727 extension_version,
728 )
729 .map(|_| ())
730 }
731 ExtrinsicFormat::Signed(account_id, extra) => {
733 let origin = RuntimeOrigin::signed(account_id);
734 <SignedExtra as DispatchTransaction<RuntimeCall>>::validate_and_prepare(
735 extra,
736 origin,
737 &xt.function,
738 &dispatch_info,
739 encoded_len,
740 0,
743 )
744 .map(|_| ())
745 }
746 ExtrinsicFormat::Bare => {
748 Runtime::pre_dispatch(&xt.function).map(|_| ())?;
749 <SignedExtra as TransactionExtension<RuntimeCall>>::bare_validate_and_prepare(
750 &xt.function,
751 &dispatch_info,
752 encoded_len,
753 )
754 .map(|_| ())
755 }
756 }
757}
758
759#[cfg(feature = "runtime-benchmarks")]
760impl frame_system_benchmarking::Config for Runtime {}
761
762#[cfg(feature = "runtime-benchmarks")]
763impl frame_benchmarking::baseline::Config for Runtime {}
764
765impl_runtime_apis! {
766 impl sp_api::Core<Block> for Runtime {
767 fn version() -> RuntimeVersion {
768 VERSION
769 }
770
771 fn execute_block(block: <Block as sp_runtime::traits::Block>::LazyBlock) {
772 Executive::execute_block(block)
773 }
774
775 fn initialize_block(header: &HeaderFor<Block>) -> ExtrinsicInclusionMode {
776 Executive::initialize_block(header)
777 }
778 }
779
780 impl sp_api::Metadata<Block> for Runtime {
781 fn metadata() -> OpaqueMetadata {
782 OpaqueMetadata::new(Runtime::metadata().into())
783 }
784
785 fn metadata_at_version(version: u32) -> Option<OpaqueMetadata> {
786 Runtime::metadata_at_version(version)
787 }
788
789 fn metadata_versions() -> Vec<u32> {
790 Runtime::metadata_versions()
791 }
792 }
793
794 impl sp_block_builder::BlockBuilder<Block> for Runtime {
795 fn apply_extrinsic(extrinsic: ExtrinsicFor<Block>) -> ApplyExtrinsicResult {
796 Executive::apply_extrinsic(extrinsic)
797 }
798
799 fn finalize_block() -> HeaderFor<Block> {
800 Executive::finalize_block()
801 }
802
803 fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<ExtrinsicFor<Block>> {
804 data.create_extrinsics()
805 }
806
807 fn check_inherents(
808 block: <Block as sp_runtime::traits::Block>::LazyBlock,
809 data: sp_inherents::InherentData,
810 ) -> sp_inherents::CheckInherentsResult {
811 data.check_extrinsics(&block)
812 }
813 }
814
815 impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {
816 fn validate_transaction(
817 source: TransactionSource,
818 tx: ExtrinsicFor<Block>,
819 block_hash: BlockHashFor<Block>,
820 ) -> TransactionValidity {
821 Executive::validate_transaction(source, tx, block_hash)
822 }
823 }
824
825 impl sp_offchain::OffchainWorkerApi<Block> for Runtime {
826 fn offchain_worker(header: &HeaderFor<Block>) {
827 Executive::offchain_worker(header)
828 }
829 }
830
831 impl sp_session::SessionKeys<Block> for Runtime {
832 fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {
833 SessionKeys::generate(seed)
834 }
835
836 fn decode_session_keys(
837 encoded: Vec<u8>,
838 ) -> Option<Vec<(Vec<u8>, KeyTypeId)>> {
839 SessionKeys::decode_into_raw_public_keys(&encoded)
840 }
841 }
842
843 impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Nonce> for Runtime {
844 fn account_nonce(account: AccountId) -> Nonce {
845 *System::account_nonce(account)
846 }
847 }
848
849 impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance> for Runtime {
850 fn query_info(
851 uxt: ExtrinsicFor<Block>,
852 len: u32,
853 ) -> pallet_transaction_payment_rpc_runtime_api::RuntimeDispatchInfo<Balance> {
854 TransactionPayment::query_info(uxt, len)
855 }
856 fn query_fee_details(
857 uxt: ExtrinsicFor<Block>,
858 len: u32,
859 ) -> pallet_transaction_payment::FeeDetails<Balance> {
860 TransactionPayment::query_fee_details(uxt, len)
861 }
862 fn query_weight_to_fee(weight: Weight) -> Balance {
863 TransactionPayment::weight_to_fee(weight)
864 }
865 fn query_length_to_fee(length: u32) -> Balance {
866 TransactionPayment::length_to_fee(length)
867 }
868 }
869
870 impl sp_domains::core_api::DomainCoreApi<Block> for Runtime {
871 fn extract_signer(
872 extrinsics: Vec<ExtrinsicFor<Block>>,
873 ) -> Vec<(Option<opaque::AccountId>, ExtrinsicFor<Block>)> {
874 extract_signer(extrinsics)
875 }
876
877 fn is_within_tx_range(
878 extrinsic: &ExtrinsicFor<Block>,
879 bundle_vrf_hash: &subspace_core_primitives::U256,
880 tx_range: &subspace_core_primitives::U256
881 ) -> bool {
882 use subspace_core_primitives::U256;
883 use subspace_core_primitives::hashes::blake3_hash;
884
885 let lookup = frame_system::ChainContext::<Runtime>::default();
886 if let Some(signer) = extract_signer_inner(extrinsic, &lookup).and_then(|account_result| {
887 account_result.ok().map(|account_id| account_id.encode())
888 }) {
889 let signer_id_hash = U256::from_be_bytes(*blake3_hash(&signer.encode()));
891 sp_domains::signer_in_tx_range(bundle_vrf_hash, &signer_id_hash, tx_range)
892 } else {
893 true
895 }
896 }
897
898 fn extract_signer_if_all_within_tx_range(
899 extrinsics: &Vec<ExtrinsicFor<Block>>,
900 bundle_vrf_hash: &subspace_core_primitives::U256,
901 tx_range: &subspace_core_primitives::U256
902 ) -> Result<Vec<Option<opaque::AccountId>> , u32> {
903 use subspace_core_primitives::U256;
904 use subspace_core_primitives::hashes::blake3_hash;
905
906 let mut signers = Vec::with_capacity(extrinsics.len());
907 let lookup = frame_system::ChainContext::<Runtime>::default();
908 for (index, extrinsic) in extrinsics.iter().enumerate() {
909 let maybe_signer = extract_signer_inner(extrinsic, &lookup).and_then(|account_result| {
910 account_result.ok().map(|account_id| account_id.encode())
911 });
912 if let Some(signer) = &maybe_signer {
913 let signer_id_hash = U256::from_be_bytes(*blake3_hash(&signer.encode()));
915 if !sp_domains::signer_in_tx_range(bundle_vrf_hash, &signer_id_hash, tx_range) {
916 return Err(index as u32)
917 }
918 }
919 signers.push(maybe_signer);
920 }
921
922 Ok(signers)
923 }
924
925 fn initialize_block_with_post_state_root(header: &HeaderFor<Block>) -> Vec<u8> {
926 Executive::initialize_block(header);
927 Executive::storage_root()
928 }
929
930 fn apply_extrinsic_with_post_state_root(extrinsic: ExtrinsicFor<Block>) -> Vec<u8> {
931 let _ = Executive::apply_extrinsic(extrinsic);
932 Executive::storage_root()
933 }
934
935 fn construct_set_code_extrinsic(code: Vec<u8>) -> Vec<u8> {
936 UncheckedExtrinsic::new_bare(
937 domain_pallet_executive::Call::set_code {
938 code
939 }.into()
940 ).encode()
941 }
942
943 fn construct_timestamp_extrinsic(moment: Moment) -> ExtrinsicFor<Block> {
944 UncheckedExtrinsic::new_bare(
945 pallet_timestamp::Call::set{ now: moment }.into()
946 )
947 }
948
949 fn is_inherent_extrinsic(extrinsic: &ExtrinsicFor<Block>) -> bool {
950 <Self as IsInherent<_>>::is_inherent(extrinsic)
951 }
952
953 fn find_first_inherent_extrinsic(extrinsics: &Vec<ExtrinsicFor<Block>>) -> Option<u32> {
954 for (index, extrinsic) in extrinsics.iter().enumerate() {
955 if <Self as IsInherent<_>>::is_inherent(extrinsic) {
956 return Some(index as u32)
957 }
958 }
959 None
960 }
961
962 fn check_extrinsics_and_do_pre_dispatch(uxts: Vec<ExtrinsicFor<Block>>, block_number: BlockNumber,
963 block_hash: BlockHashFor<Block>) -> Result<(), CheckExtrinsicsValidityError> {
964 let next_block_number = block_number + BlockNumber::one();
968 if System::block_number() != next_block_number {
969 System::initialize(
970 &next_block_number,
971 &block_hash,
972 &Default::default(),
973 );
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}