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, ExtensionVariant, Keccak256,
55 NumberFor, One, 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::extension::SmallOrderEd25519CheckExtension;
74use subspace_runtime_primitives::utility::DefaultNonceProvider;
75use subspace_runtime_primitives::{
76 AI3, BlockHashFor, BlockNumber as ConsensusBlockNumber, DomainEventSegmentSize, ExtrinsicFor,
77 Hash as ConsensusBlockHash, HeaderFor, MAX_CALL_RECURSION_DEPTH, Moment,
78 SlowAdjustingFeeUpdate, XdmAdjustedWeightToFee, XdmFeeMultipler,
79};
80
81pub type Block = generic::Block<Header, UncheckedExtrinsic>;
83
84pub type SignedBlock = generic::SignedBlock<Block>;
86
87pub type BlockId = generic::BlockId<Block>;
89
90pub type SignedExtra = (
92 frame_system::CheckNonZeroSender<Runtime>,
93 SmallOrderEd25519CheckExtension<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 SmallOrderEd25519CheckExtension<Runtime>,
108 frame_system::CheckSpecVersion<Runtime>,
109 frame_system::CheckTxVersion<Runtime>,
110 frame_system::CheckGenesis<Runtime>,
111 frame_system::CheckMortality<Runtime>,
112 frame_system::CheckNonce<Runtime>,
113 domain_check_weight::CheckWeight<Runtime>,
114 pallet_transaction_payment::ChargeTransactionPayment<Runtime>,
115 pallet_messenger::extensions::MessengerTrustedMmrExtension<Runtime>,
116);
117
118pub type UncheckedExtrinsic =
120 generic::UncheckedExtrinsic<Address, RuntimeCall, Signature, SignedExtra>;
121
122pub type CheckedExtrinsic = generic::CheckedExtrinsic<AccountId, RuntimeCall, SignedExtra>;
124
125pub type Executive = domain_pallet_executive::Executive<
127 Runtime,
128 frame_system::ChainContext<Runtime>,
129 Runtime,
130 AllPalletsWithSystem,
131>;
132
133impl_opaque_keys! {
134 pub struct SessionKeys {
135 pub operator: sp_domains::OperatorKey,
137 }
138}
139
140#[sp_version::runtime_version]
141pub const VERSION: RuntimeVersion = RuntimeVersion {
142 spec_name: Cow::Borrowed("subspace-auto-id-domain"),
143 impl_name: Cow::Borrowed("subspace-auto-id-domain"),
144 authoring_version: 0,
145 spec_version: 1,
146 impl_version: 0,
147 apis: RUNTIME_API_VERSIONS,
148 transaction_version: 0,
149 system_version: 2,
150};
151
152parameter_types! {
153 pub const Version: RuntimeVersion = VERSION;
154 pub const BlockHashCount: BlockNumber = 2400;
155 pub RuntimeBlockLength: BlockLength = maximum_block_length();
156 pub RuntimeBlockWeights: BlockWeights = block_weights();
157}
158
159impl frame_system::Config for Runtime {
160 type RuntimeEvent = RuntimeEvent;
161 type AccountId = AccountId;
163 type RuntimeCall = RuntimeCall;
165 type RuntimeTask = RuntimeTask;
167 type Lookup = AccountIdLookup<AccountId, ()>;
169 type Nonce = TypeWithDefault<Nonce, DefaultNonceProvider<System, Nonce>>;
171 type Hash = Hash;
173 type Hashing = BlakeTwo256;
175 type Block = Block;
177 type RuntimeOrigin = RuntimeOrigin;
180 type BlockHashCount = BlockHashCount;
182 type Version = Version;
184 type PalletInfo = PalletInfo;
186 type AccountData = pallet_balances::AccountData<Balance>;
188 type OnNewAccount = ();
190 type OnKilledAccount = ();
192 type DbWeight = ParityDbWeight;
194 type BaseCallFilter = Everything;
196 type SystemWeightInfo = frame_system::weights::SubstrateWeight<Runtime>;
198 type BlockWeights = RuntimeBlockWeights;
200 type BlockLength = RuntimeBlockLength;
202 type SS58Prefix = ConstU16<6094>;
203 type OnSetCode = ();
205 type SingleBlockMigrations = ();
206 type MultiBlockMigrator = ();
207 type PreInherents = ();
208 type PostInherents = ();
209 type PostTransactions = ();
210 type MaxConsumers = ConstU32<16>;
211 type ExtensionsWeightInfo = frame_system::SubstrateExtensionsWeight<Runtime>;
212 type EventSegmentSize = DomainEventSegmentSize;
213}
214
215impl pallet_timestamp::Config for Runtime {
216 type Moment = Moment;
218 type OnTimestampSet = ();
219 type MinimumPeriod = ConstU64<{ SLOT_DURATION / 2 }>;
220 type WeightInfo = pallet_timestamp::weights::SubstrateWeight<Runtime>;
221}
222
223parameter_types! {
224 pub const ExistentialDeposit: Balance = EXISTENTIAL_DEPOSIT;
225 pub const MaxLocks: u32 = 50;
226 pub const MaxReserves: u32 = 50;
227}
228
229pub struct DustRemovalHandler;
231
232impl OnUnbalanced<Credit<AccountId, Balances>> for DustRemovalHandler {
233 fn on_nonzero_unbalanced(dusted_amount: Credit<AccountId, Balances>) {
234 BlockFees::note_burned_balance(dusted_amount.peek());
235 }
236}
237
238impl pallet_balances::Config for Runtime {
239 type RuntimeEvent = RuntimeEvent;
240 type RuntimeFreezeReason = RuntimeFreezeReason;
241 type MaxLocks = MaxLocks;
242 type Balance = Balance;
244 type DustRemoval = DustRemovalHandler;
246 type ExistentialDeposit = ExistentialDeposit;
247 type AccountStore = System;
248 type WeightInfo = pallet_balances::weights::SubstrateWeight<Runtime>;
249 type MaxReserves = MaxReserves;
250 type ReserveIdentifier = [u8; 8];
251 type FreezeIdentifier = ();
252 type MaxFreezes = ();
253 type RuntimeHoldReason = HoldIdentifierWrapper;
254 type DoneSlashHandler = ();
255}
256
257parameter_types! {
258 pub const OperationalFeeMultiplier: u8 = 5;
259 pub const DomainChainByteFee: Balance = 1;
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 = IdentityFee<Balance>;
279 type LengthToFee = ConstantMultiplier<Balance, FinalDomainTransactionByteFee>;
280 type FeeMultiplierUpdate = SlowAdjustingFeeUpdate<Runtime, TargetBlockFullness>;
281 type OperationalFeeMultiplier = OperationalFeeMultiplier;
282 type WeightInfo = pallet_transaction_payment::weights::SubstrateWeight<Runtime>;
283}
284
285impl pallet_auto_id::Config for Runtime {
286 type Time = Timestamp;
287 type Weights = pallet_auto_id::weights::SubstrateWeight<Self>;
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 = domain_pallet_executive::weights::SubstrateWeight<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 = 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 SelfChainId = SelfChainId;
479 type SelfEndpointId = TransporterEndpointId;
480 type Currency = Balances;
481 type Sender = Messenger;
482 type AccountIdConverter = domain_runtime_primitives::AccountIdConverter;
483 type WeightInfo = pallet_transporter::weights::SubstrateWeight<Runtime>;
484 type MinimumTransfer = MinimumTransfer;
485}
486
487impl pallet_domain_id::Config for Runtime {}
488
489pub struct IntoRuntimeCall;
490
491impl sp_domain_sudo::IntoRuntimeCall<RuntimeCall> for IntoRuntimeCall {
492 fn runtime_call(call: Vec<u8>) -> RuntimeCall {
493 UncheckedExtrinsic::decode(&mut call.as_slice())
494 .expect("must always be a valid extrinsic as checked by consensus chain; qed")
495 .function
496 }
497}
498
499impl pallet_domain_sudo::Config for Runtime {
500 type RuntimeCall = RuntimeCall;
501 type IntoRuntimeCall = IntoRuntimeCall;
502}
503
504impl pallet_storage_overlay_checks::Config for Runtime {}
505
506construct_runtime!(
510 pub struct Runtime {
511 System: frame_system = 0,
513 Timestamp: pallet_timestamp = 1,
517 ExecutivePallet: domain_pallet_executive = 2,
518
519 Balances: pallet_balances = 20,
521 TransactionPayment: pallet_transaction_payment = 21,
522
523 AutoId: pallet_auto_id = 40,
525
526 Messenger: pallet_messenger = 60,
529 Transporter: pallet_transporter = 61,
530
531 SelfDomainId: pallet_domain_id = 90,
533 BlockFees: pallet_block_fees = 91,
534
535 Sudo: pallet_domain_sudo = 100,
537
538 StorageOverlayChecks: pallet_storage_overlay_checks = 200,
540 }
541);
542
543fn is_xdm_mmr_proof_valid(ext: &ExtrinsicFor<Block>) -> Option<bool> {
544 match &ext.function {
545 RuntimeCall::Messenger(pallet_messenger::Call::relay_message { msg })
546 | RuntimeCall::Messenger(pallet_messenger::Call::relay_message_response { msg }) => {
547 let ConsensusChainMmrLeafProof {
548 consensus_block_number,
549 opaque_mmr_leaf,
550 proof,
551 ..
552 } = msg.proof.consensus_mmr_proof();
553
554 if !is_consensus_block_finalized(consensus_block_number) {
555 return Some(false);
556 }
557
558 Some(verify_mmr_proof(vec![opaque_mmr_leaf], proof.encode()))
559 }
560 _ => None,
561 }
562}
563
564fn is_valid_sudo_call(encoded_ext: Vec<u8>) -> bool {
566 UncheckedExtrinsic::decode_all_with_depth_limit(
567 MAX_CALL_RECURSION_DEPTH,
568 &mut encoded_ext.as_slice(),
569 )
570 .is_ok()
571}
572
573fn construct_sudo_call_extrinsic(encoded_ext: Vec<u8>) -> ExtrinsicFor<Block> {
574 let ext = UncheckedExtrinsic::decode(&mut encoded_ext.as_slice()).expect(
575 "must always be a valid extrinsic due to the check above and storage proof check; qed",
576 );
577 UncheckedExtrinsic::new_bare(
578 pallet_domain_sudo::Call::sudo {
579 call: Box::new(ext.function),
580 }
581 .into(),
582 )
583}
584
585fn extract_signer_inner<Lookup>(
586 ext: &UncheckedExtrinsic,
587 lookup: &Lookup,
588) -> Option<Result<AccountId, TransactionValidityError>>
589where
590 Lookup: sp_runtime::traits::Lookup<Source = Address, Target = AccountId>,
591{
592 match &ext.preamble {
593 Preamble::Bare(_) | Preamble::General(_) => None,
594 Preamble::Signed(address, _, _) => {
595 Some(lookup.lookup(address.clone()).map_err(|e| e.into()))
596 }
597 }
598}
599
600pub fn extract_signer(
601 extrinsics: Vec<UncheckedExtrinsic>,
602) -> Vec<(Option<opaque::AccountId>, UncheckedExtrinsic)> {
603 let lookup = frame_system::ChainContext::<Runtime>::default();
604
605 extrinsics
606 .into_iter()
607 .map(|extrinsic| {
608 let maybe_signer =
609 extract_signer_inner(&extrinsic, &lookup).and_then(|account_result| {
610 account_result.ok().map(|account_id| account_id.encode())
611 });
612 (maybe_signer, extrinsic)
613 })
614 .collect()
615}
616
617fn extrinsic_era(extrinsic: &ExtrinsicFor<Block>) -> Option<Era> {
618 match &extrinsic.preamble {
619 Preamble::Bare(_) | Preamble::General(_) => None,
620 Preamble::Signed(_, _, extra) => Some(extra.5.0),
621 }
622}
623
624impl pallet_messenger::extensions::MaybeMessengerCall<Runtime> for RuntimeCall {
625 fn maybe_messenger_call(&self) -> Option<&pallet_messenger::Call<Runtime>> {
626 match self {
627 RuntimeCall::Messenger(call) => Some(call),
628 _ => None,
629 }
630 }
631}
632
633impl<C> subspace_runtime_primitives::CreateUnsigned<C> for Runtime
634where
635 RuntimeCall: From<C>,
636{
637 fn create_unsigned(call: Self::RuntimeCall) -> Self::Extrinsic {
638 create_unsigned_general_extrinsic(call)
639 }
640}
641
642fn create_unsigned_general_extrinsic(call: RuntimeCall) -> UncheckedExtrinsic {
643 let extra: SignedExtra = (
644 frame_system::CheckNonZeroSender::<Runtime>::new(),
645 SmallOrderEd25519CheckExtension::<Runtime>::new(),
646 frame_system::CheckSpecVersion::<Runtime>::new(),
647 frame_system::CheckTxVersion::<Runtime>::new(),
648 frame_system::CheckGenesis::<Runtime>::new(),
649 frame_system::CheckMortality::<Runtime>::from(generic::Era::Immortal),
650 frame_system::CheckNonce::<Runtime>::from(0u32.into()),
653 domain_check_weight::CheckWeight::<Runtime>::new(),
654 pallet_transaction_payment::ChargeTransactionPayment::<Runtime>::from(0u128),
657 pallet_messenger::extensions::MessengerExtension::<Runtime>::new(),
658 );
659
660 UncheckedExtrinsic::new_transaction(call, extra)
661}
662
663#[cfg(feature = "runtime-benchmarks")]
664mod benches {
665 frame_benchmarking::define_benchmarks!(
666 [frame_benchmarking, BaselineBench::<Runtime>]
667 [frame_system, SystemBench::<Runtime>]
668 [domain_pallet_executive, ExecutivePallet]
669 [pallet_messenger, Messenger]
670 [pallet_auto_id, AutoId]
671 );
672}
673
674fn check_transaction_and_do_pre_dispatch_inner(
675 uxt: &ExtrinsicFor<Block>,
676) -> Result<(), TransactionValidityError> {
677 let lookup = frame_system::ChainContext::<Runtime>::default();
678
679 let xt = uxt.clone().check(&lookup)?;
680
681 let dispatch_info = xt.get_dispatch_info();
682
683 if dispatch_info.class == DispatchClass::Mandatory {
684 return Err(InvalidTransaction::MandatoryValidation.into());
685 }
686
687 let encoded_len = uxt.encoded_size();
688
689 match xt.format {
694 ExtrinsicFormat::General(extension_variant) => {
695 let ExtensionVariant::V0(extra) = extension_variant;
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 0,
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,
717 extra.7.clone(),
718 extra.8,
719 pallet_messenger::extensions::MessengerTrustedMmrExtension::<Runtime>::new(),
720 );
721 let origin = RuntimeOrigin::signed(account_id);
722 <CustomSignedExtra as DispatchTransaction<RuntimeCall>>::validate_and_prepare(
723 custom_extra,
724 origin,
725 &xt.function,
726 &dispatch_info,
727 encoded_len,
728 0,
731 )
732 .map(|_| ())
733 }
734 ExtrinsicFormat::Bare => {
736 Runtime::pre_dispatch(&xt.function).map(|_| ())?;
737 <SignedExtra as TransactionExtension<RuntimeCall>>::bare_validate_and_prepare(
738 &xt.function,
739 &dispatch_info,
740 encoded_len,
741 )
742 .map(|_| ())
743 }
744 }
745}
746
747#[cfg(feature = "runtime-benchmarks")]
748impl frame_system_benchmarking::Config for Runtime {}
749
750#[cfg(feature = "runtime-benchmarks")]
751impl frame_benchmarking::baseline::Config for Runtime {}
752
753impl_runtime_apis! {
754 impl sp_api::Core<Block> for Runtime {
755 fn version() -> RuntimeVersion {
756 VERSION
757 }
758
759 fn execute_block(block: <Block as sp_runtime::traits::Block>::LazyBlock) {
760 Executive::execute_block(block)
761 }
762
763 fn initialize_block(header: &HeaderFor<Block>) -> ExtrinsicInclusionMode {
764 Executive::initialize_block(header)
765 }
766 }
767
768 impl sp_api::Metadata<Block> for Runtime {
769 fn metadata() -> OpaqueMetadata {
770 OpaqueMetadata::new(Runtime::metadata().into())
771 }
772
773 fn metadata_at_version(version: u32) -> Option<OpaqueMetadata> {
774 Runtime::metadata_at_version(version)
775 }
776
777 fn metadata_versions() -> Vec<u32> {
778 Runtime::metadata_versions()
779 }
780 }
781
782 impl sp_block_builder::BlockBuilder<Block> for Runtime {
783 fn apply_extrinsic(extrinsic: ExtrinsicFor<Block>) -> ApplyExtrinsicResult {
784 Executive::apply_extrinsic(extrinsic)
785 }
786
787 fn finalize_block() -> HeaderFor<Block> {
788 Executive::finalize_block()
789 }
790
791 fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<ExtrinsicFor<Block>> {
792 data.create_extrinsics()
793 }
794
795 fn check_inherents(
796 block: <Block as sp_runtime::traits::Block>::LazyBlock,
797 data: sp_inherents::InherentData,
798 ) -> sp_inherents::CheckInherentsResult {
799 data.check_extrinsics(&block)
800 }
801 }
802
803 impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {
804 fn validate_transaction(
805 source: TransactionSource,
806 tx: ExtrinsicFor<Block>,
807 block_hash: BlockHashFor<Block>,
808 ) -> TransactionValidity {
809 Executive::validate_transaction(source, tx, block_hash)
810 }
811 }
812
813 impl sp_offchain::OffchainWorkerApi<Block> for Runtime {
814 fn offchain_worker(header: &HeaderFor<Block>) {
815 Executive::offchain_worker(header)
816 }
817 }
818
819 impl sp_session::SessionKeys<Block> for Runtime {
820 fn generate_session_keys(
821 owner: Vec<u8>,
822 seed: Option<Vec<u8>>,
823 ) -> sp_session::OpaqueGeneratedSessionKeys {
824 SessionKeys::generate(&owner, seed).into()
825 }
826
827 fn decode_session_keys(
828 encoded: Vec<u8>,
829 ) -> Option<Vec<(Vec<u8>, KeyTypeId)>> {
830 SessionKeys::decode_into_raw_public_keys(&encoded)
831 }
832 }
833
834 impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Nonce> for Runtime {
835 fn account_nonce(account: AccountId) -> Nonce {
836 *System::account_nonce(account)
837 }
838 }
839
840 impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance> for Runtime {
841 fn query_info(
842 uxt: ExtrinsicFor<Block>,
843 len: u32,
844 ) -> pallet_transaction_payment_rpc_runtime_api::RuntimeDispatchInfo<Balance> {
845 TransactionPayment::query_info(uxt, len)
846 }
847 fn query_fee_details(
848 uxt: ExtrinsicFor<Block>,
849 len: u32,
850 ) -> pallet_transaction_payment::FeeDetails<Balance> {
851 TransactionPayment::query_fee_details(uxt, len)
852 }
853 fn query_weight_to_fee(weight: Weight) -> Balance {
854 TransactionPayment::weight_to_fee(weight)
855 }
856 fn query_length_to_fee(length: u32) -> Balance {
857 TransactionPayment::length_to_fee(length)
858 }
859 }
860
861 impl sp_domains::core_api::DomainCoreApi<Block> for Runtime {
862 fn extract_signer(
863 extrinsics: Vec<ExtrinsicFor<Block>>,
864 ) -> Vec<(Option<opaque::AccountId>, ExtrinsicFor<Block>)> {
865 extract_signer(extrinsics)
866 }
867
868 fn is_within_tx_range(
869 extrinsic: &ExtrinsicFor<Block>,
870 bundle_vrf_hash: &subspace_core_primitives::U256,
871 tx_range: &subspace_core_primitives::U256
872 ) -> bool {
873 use subspace_core_primitives::U256;
874 use subspace_core_primitives::hashes::blake3_hash;
875
876 let lookup = frame_system::ChainContext::<Runtime>::default();
877 if let Some(signer) = extract_signer_inner(extrinsic, &lookup).and_then(|account_result| {
878 account_result.ok().map(|account_id| account_id.encode())
879 }) {
880 let signer_id_hash = U256::from_be_bytes(*blake3_hash(&signer.encode()));
882 sp_domains::signer_in_tx_range(bundle_vrf_hash, &signer_id_hash, tx_range)
883 } else {
884 true
886 }
887 }
888
889 fn extract_signer_if_all_within_tx_range(
890 extrinsics: &Vec<ExtrinsicFor<Block>>,
891 bundle_vrf_hash: &subspace_core_primitives::U256,
892 tx_range: &subspace_core_primitives::U256
893 ) -> Result<Vec<Option<opaque::AccountId>> , u32> {
894 use subspace_core_primitives::U256;
895 use subspace_core_primitives::hashes::blake3_hash;
896
897 let mut signers = Vec::with_capacity(extrinsics.len());
898 let lookup = frame_system::ChainContext::<Runtime>::default();
899 for (index, extrinsic) in extrinsics.iter().enumerate() {
900 let maybe_signer = extract_signer_inner(extrinsic, &lookup).and_then(|account_result| {
901 account_result.ok().map(|account_id| account_id.encode())
902 });
903 if let Some(signer) = &maybe_signer {
904 let signer_id_hash = U256::from_be_bytes(*blake3_hash(&signer.encode()));
906 if !sp_domains::signer_in_tx_range(bundle_vrf_hash, &signer_id_hash, tx_range) {
907 return Err(index as u32)
908 }
909 }
910 signers.push(maybe_signer);
911 }
912
913 Ok(signers)
914 }
915
916 fn initialize_block_with_post_state_root(header: &HeaderFor<Block>) -> Vec<u8> {
917 Executive::initialize_block(header);
918 Executive::storage_root()
919 }
920
921 fn apply_extrinsic_with_post_state_root(extrinsic: ExtrinsicFor<Block>) -> Vec<u8> {
922 let _ = Executive::apply_extrinsic(extrinsic);
923 Executive::storage_root()
924 }
925
926 fn construct_set_code_extrinsic(code: Vec<u8>) -> Vec<u8> {
927 UncheckedExtrinsic::new_bare(
928 domain_pallet_executive::Call::set_code {
929 code
930 }.into()
931 ).encode()
932 }
933
934 fn construct_timestamp_extrinsic(moment: Moment) -> ExtrinsicFor<Block> {
935 UncheckedExtrinsic::new_bare(
936 pallet_timestamp::Call::set{ now: moment }.into()
937 )
938 }
939
940 fn is_inherent_extrinsic(extrinsic: &ExtrinsicFor<Block>) -> bool {
941 <Self as IsInherent<_>>::is_inherent(extrinsic)
942 }
943
944 fn find_first_inherent_extrinsic(extrinsics: &Vec<ExtrinsicFor<Block>>) -> Option<u32> {
945 for (index, extrinsic) in extrinsics.iter().enumerate() {
946 if <Self as IsInherent<_>>::is_inherent(extrinsic) {
947 return Some(index as u32)
948 }
949 }
950 None
951 }
952
953 fn check_extrinsics_and_do_pre_dispatch(uxts: Vec<ExtrinsicFor<Block>>, block_number: BlockNumber,
954 block_hash: BlockHashFor<Block>) -> Result<(), CheckExtrinsicsValidityError> {
955 let next_block_number = block_number + BlockNumber::one();
959 if System::block_number() != next_block_number {
960 System::initialize(
961 &next_block_number,
962 &block_hash,
963 &Default::default(),
964 );
965 }
966
967 for (extrinsic_index, uxt) in uxts.iter().enumerate() {
968 check_transaction_and_do_pre_dispatch_inner(uxt).map_err(|e| {
969 CheckExtrinsicsValidityError {
970 extrinsic_index: extrinsic_index as u32,
971 transaction_validity_error: e
972 }
973 })?;
974 }
975
976 Ok(())
977 }
978
979 fn decode_extrinsic(
980 opaque_extrinsic: sp_runtime::OpaqueExtrinsic,
981 ) -> Result<ExtrinsicFor<Block>, DecodeExtrinsicError> {
982 let encoded = opaque_extrinsic.encode();
983
984 UncheckedExtrinsic::decode_all_with_depth_limit(
985 MAX_CALL_RECURSION_DEPTH,
986 &mut encoded.as_slice(),
987 ).map_err(|err| DecodeExtrinsicError(format!("{err}")))
988 }
989
990 fn decode_extrinsics_prefix(
991 opaque_extrinsics: Vec<sp_runtime::OpaqueExtrinsic>,
992 ) -> Vec<ExtrinsicFor<Block>> {
993 let mut extrinsics = Vec::with_capacity(opaque_extrinsics.len());
994 for opaque_ext in opaque_extrinsics {
995 match UncheckedExtrinsic::decode_all_with_depth_limit(
996 MAX_CALL_RECURSION_DEPTH,
997 &mut opaque_ext.encode().as_slice(),
998 ) {
999 Ok(tx) => extrinsics.push(tx),
1000 Err(_) => return extrinsics,
1001 }
1002 }
1003 extrinsics
1004 }
1005
1006 fn extrinsic_era(
1007 extrinsic: &ExtrinsicFor<Block>
1008 ) -> Option<Era> {
1009 extrinsic_era(extrinsic)
1010 }
1011
1012 fn extrinsic_weight(ext: &ExtrinsicFor<Block>) -> Weight {
1013 let len = ext.encoded_size() as u64;
1014 let info = ext.get_dispatch_info();
1015 info.call_weight
1016 .saturating_add(<Runtime as frame_system::Config>::BlockWeights::get().get(info.class).base_extrinsic)
1017 .saturating_add(Weight::from_parts(0, len)).saturating_add(info.extension_weight)
1018 }
1019
1020 fn extrinsics_weight(extrinsics: &Vec<ExtrinsicFor<Block>>) -> Weight {
1021 let mut total_weight = Weight::zero();
1022 for ext in extrinsics {
1023 let ext_weight = {
1024 let len = ext.encoded_size() as u64;
1025 let info = ext.get_dispatch_info();
1026 info.call_weight.saturating_add(info.extension_weight)
1027 .saturating_add(<Runtime as frame_system::Config>::BlockWeights::get().get(info.class).base_extrinsic)
1028 .saturating_add(Weight::from_parts(0, len))
1029 };
1030 total_weight = total_weight.saturating_add(ext_weight);
1031 }
1032 total_weight
1033 }
1034
1035 fn block_fees() -> sp_domains::execution_receipt::BlockFees<Balance> {
1036 BlockFees::collected_block_fees()
1037 }
1038
1039 fn block_digest() -> Digest {
1040 System::digest()
1041 }
1042
1043 fn block_weight() -> Weight {
1044 System::block_weight().total()
1045 }
1046
1047 fn construct_consensus_chain_byte_fee_extrinsic(transaction_byte_fee: Balance) -> ExtrinsicFor<Block> {
1048 UncheckedExtrinsic::new_bare(
1049 pallet_block_fees::Call::set_next_consensus_chain_byte_fee { transaction_byte_fee }.into()
1050 )
1051 }
1052
1053 fn construct_domain_update_chain_allowlist_extrinsic(updates: DomainAllowlistUpdates) -> ExtrinsicFor<Block> {
1054 UncheckedExtrinsic::new_bare(
1055 pallet_messenger::Call::update_domain_allowlist{ updates }.into()
1056 )
1057 }
1058
1059 fn transfers() -> Transfers<Balance> {
1060 Transporter::chain_transfers()
1061 }
1062
1063 fn transfers_storage_key() -> Vec<u8> {
1064 Transporter::transfers_storage_key()
1065 }
1066
1067 fn block_fees_storage_key() -> Vec<u8> {
1068 BlockFees::block_fees_storage_key()
1069 }
1070 }
1071
1072 impl sp_messenger::MessengerApi<Block, ConsensusBlockNumber, ConsensusBlockHash> for Runtime {
1073 fn is_xdm_mmr_proof_valid(
1074 extrinsic: &ExtrinsicFor<Block>,
1075 ) -> Option<bool> {
1076 is_xdm_mmr_proof_valid(extrinsic)
1077 }
1078
1079 fn extract_xdm_mmr_proof(ext: &ExtrinsicFor<Block>) -> Option<ConsensusChainMmrLeafProof<ConsensusBlockNumber, ConsensusBlockHash, sp_core::H256>> {
1080 match &ext.function {
1081 RuntimeCall::Messenger(pallet_messenger::Call::relay_message { msg })
1082 | RuntimeCall::Messenger(pallet_messenger::Call::relay_message_response { msg }) => {
1083 Some(msg.proof.consensus_mmr_proof())
1084 }
1085 _ => None,
1086 }
1087 }
1088
1089 fn batch_extract_xdm_mmr_proof(extrinsics: &Vec<ExtrinsicFor<Block>>) -> BTreeMap<u32, ConsensusChainMmrLeafProof<ConsensusBlockNumber, ConsensusBlockHash, sp_core::H256>> {
1090 let mut mmr_proofs = BTreeMap::new();
1091 for (index, ext) in extrinsics.iter().enumerate() {
1092 match &ext.function {
1093 RuntimeCall::Messenger(pallet_messenger::Call::relay_message { msg })
1094 | RuntimeCall::Messenger(pallet_messenger::Call::relay_message_response { msg }) => {
1095 mmr_proofs.insert(index as u32, msg.proof.consensus_mmr_proof());
1096 }
1097 _ => {},
1098 }
1099 }
1100 mmr_proofs
1101 }
1102
1103 fn confirmed_domain_block_storage_key(_domain_id: DomainId) -> Vec<u8> {
1104 vec![]
1106 }
1107
1108 fn outbox_storage_key(message_key: MessageKey) -> Vec<u8> {
1109 Messenger::outbox_storage_key(message_key)
1110 }
1111
1112 fn inbox_response_storage_key(message_key: MessageKey) -> Vec<u8> {
1113 Messenger::inbox_response_storage_key(message_key)
1114 }
1115
1116 fn domain_chains_allowlist_update(_domain_id: DomainId) -> Option<DomainAllowlistUpdates>{
1117 None
1119 }
1120
1121 fn xdm_id(ext: &ExtrinsicFor<Block>) -> Option<XdmId> {
1122 match &ext.function {
1123 RuntimeCall::Messenger(pallet_messenger::Call::relay_message { msg })=> {
1124 Some(XdmId::RelayMessage((msg.src_chain_id, msg.channel_id, msg.nonce)))
1125 }
1126 RuntimeCall::Messenger(pallet_messenger::Call::relay_message_response { msg }) => {
1127 Some(XdmId::RelayResponseMessage((msg.src_chain_id, msg.channel_id, msg.nonce)))
1128 }
1129 _ => None,
1130 }
1131 }
1132
1133 fn channel_nonce(chain_id: ChainId, channel_id: ChannelId) -> Option<ChannelNonce> {
1134 Messenger::channel_nonce(chain_id, channel_id)
1135 }
1136 }
1137
1138 impl sp_messenger::RelayerApi<Block, BlockNumber, ConsensusBlockNumber, ConsensusBlockHash> for Runtime {
1139 fn outbox_message_unsigned(msg: CrossDomainMessage<NumberFor<Block>, BlockHashFor<Block>, BlockHashFor<Block>>) -> Option<ExtrinsicFor<Block>> {
1140 Messenger::outbox_message_unsigned(msg)
1141 }
1142
1143 fn inbox_response_message_unsigned(msg: CrossDomainMessage<NumberFor<Block>, BlockHashFor<Block>, BlockHashFor<Block>>) -> Option<ExtrinsicFor<Block>> {
1144 Messenger::inbox_response_message_unsigned(msg)
1145 }
1146
1147 fn updated_channels() -> BTreeSet<(ChainId, ChannelId)> {
1148 Messenger::updated_channels()
1149 }
1150
1151 fn channel_storage_key(chain_id: ChainId, channel_id: ChannelId) -> Vec<u8> {
1152 Messenger::channel_storage_key(chain_id, channel_id)
1153 }
1154
1155 fn open_channels() -> BTreeSet<(ChainId, ChannelId)> {
1156 Messenger::open_channels()
1157 }
1158
1159 fn block_messages_with_query(query: BlockMessagesQuery) -> MessagesWithStorageKey {
1160 Messenger::get_block_messages(query)
1161 }
1162
1163 fn channels_and_state() -> Vec<(ChainId, ChannelId, ChannelStateWithNonce)> {
1164 Messenger::channels_and_states()
1165 }
1166
1167 fn first_outbox_message_nonce_to_relay(dst_chain_id: ChainId, channel_id: ChannelId, from_nonce: XdmNonce) -> Option<XdmNonce> {
1168 Messenger::first_outbox_message_nonce_to_relay(dst_chain_id, channel_id, from_nonce)
1169 }
1170
1171 fn first_inbox_message_response_nonce_to_relay(dst_chain_id: ChainId, channel_id: ChannelId, from_nonce: XdmNonce) -> Option<XdmNonce> {
1172 Messenger::first_inbox_message_response_nonce_to_relay(dst_chain_id, channel_id, from_nonce)
1173 }
1174 }
1175
1176 impl sp_domain_sudo::DomainSudoApi<Block> for Runtime {
1177 fn is_valid_sudo_call(extrinsic: Vec<u8>) -> bool {
1178 is_valid_sudo_call(extrinsic)
1179 }
1180
1181 fn construct_domain_sudo_extrinsic(inner: Vec<u8>) -> ExtrinsicFor<Block> {
1182 construct_sudo_call_extrinsic(inner)
1183 }
1184 }
1185
1186 impl sp_genesis_builder::GenesisBuilder<Block> for Runtime {
1187 fn build_state(config: Vec<u8>) -> sp_genesis_builder::Result {
1188 build_state::<RuntimeGenesisConfig>(config)
1189 }
1190
1191 fn get_preset(id: &Option<sp_genesis_builder::PresetId>) -> Option<Vec<u8>> {
1192 get_preset::<RuntimeGenesisConfig>(id, |_| None)
1193 }
1194
1195 fn preset_names() -> Vec<sp_genesis_builder::PresetId> {
1196 vec![]
1197 }
1198 }
1199
1200 impl domain_test_primitives::OnchainStateApi<Block, AccountId, Balance> for Runtime {
1201 fn free_balance(account_id: AccountId) -> Balance {
1202 Balances::free_balance(account_id)
1203 }
1204
1205 fn get_open_channel_for_chain(dst_chain_id: ChainId) -> Option<ChannelId> {
1206 Messenger::get_open_channel_for_chain(dst_chain_id)
1207 }
1208
1209 fn consensus_transaction_byte_fee() -> Balance {
1210 BlockFees::consensus_chain_byte_fee()
1211 }
1212
1213 fn storage_root() -> [u8; 32] {
1214 let version = <Runtime as frame_system::Config>::Version::get().state_version();
1215 let root = sp_io::storage::root(version);
1216 TryInto::<[u8; 32]>::try_into(root)
1217 .expect("root is a SCALE encoded hash which uses H256; qed")
1218 }
1219
1220 fn total_issuance() -> Balance {
1221 Balances::total_issuance()
1222 }
1223 }
1224
1225 #[cfg(feature = "runtime-benchmarks")]
1226 impl frame_benchmarking::Benchmark<Block> for Runtime {
1227 fn benchmark_metadata(extra: bool) -> (
1228 Vec<frame_benchmarking::BenchmarkList>,
1229 Vec<frame_support::traits::StorageInfo>,
1230 ) {
1231 use frame_benchmarking::{baseline, BenchmarkList};
1232 use frame_support::traits::StorageInfoTrait;
1233 use frame_system_benchmarking::Pallet as SystemBench;
1234 use baseline::Pallet as BaselineBench;
1235
1236 let mut list = Vec::<BenchmarkList>::new();
1237
1238 list_benchmarks!(list, extra);
1239
1240 let storage_info = AllPalletsWithSystem::storage_info();
1241
1242 (list, storage_info)
1243 }
1244
1245 fn dispatch_benchmark(
1246 config: frame_benchmarking::BenchmarkConfig
1247 ) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, alloc::string::String> {
1248 use frame_benchmarking::{baseline, BenchmarkBatch};
1249 use sp_storage::TrackedStorageKey;
1250 use frame_system_benchmarking::Pallet as SystemBench;
1251 use frame_support::traits::WhitelistedStorageKeys;
1252 use baseline::Pallet as BaselineBench;
1253
1254 let whitelist: Vec<TrackedStorageKey> = AllPalletsWithSystem::whitelisted_storage_keys();
1255
1256 let mut batches = Vec::<BenchmarkBatch>::new();
1257 let params = (&config, &whitelist);
1258
1259 add_benchmarks!(params, batches);
1260
1261 if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) }
1262 Ok(batches)
1263 }
1264 }
1265}
1266
1267#[cfg(test)]
1268mod tests {
1269 use crate::{Runtime, RuntimeBlockWeights as BlockWeights};
1270 use subspace_runtime_primitives::tests_utils::FeeMultiplierUtils;
1271
1272 #[test]
1273 fn multiplier_can_grow_from_zero() {
1274 FeeMultiplierUtils::<Runtime, BlockWeights>::multiplier_can_grow_from_zero()
1275 }
1276}