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