1234567891011121314151617pub mod config;18pub mod construct_runtime;19pub mod dispatch;20pub mod ethereum;21pub mod instance;22pub mod runtime_apis;23pub mod maintenance;2425#[cfg(feature = "scheduler")]26pub mod scheduler;2728pub mod sponsoring;29pub mod weights;3031#[cfg(test)]32pub mod tests;3334use sp_core::H160;35use frame_support::traits::{Currency, OnUnbalanced, Imbalance};36use sp_runtime::{37 generic,38 traits::{BlakeTwo256, BlockNumberProvider},39 impl_opaque_keys,40};41use sp_std::vec::Vec;4243#[cfg(feature = "std")]44use sp_version::NativeVersion;4546use crate::{47 Runtime, RuntimeCall, Balances, Treasury, Aura, Signature, AllPalletsWithSystem,48 InherentDataExt,49};50use up_common::types::{AccountId, BlockNumber};5152#[macro_export]53macro_rules! unsupported {54 () => {55 pallet_common::unsupported!($crate::Runtime)56 };57}585960pub type Address = sp_runtime::MultiAddress<AccountId, ()>;6162pub type Header = generic::Header<BlockNumber, BlakeTwo256>;6364pub type Block = generic::Block<Header, UncheckedExtrinsic>;6566pub type SignedBlock = generic::SignedBlock<Block>;6768pub type BlockId = generic::BlockId<Block>;6970impl_opaque_keys! {71 pub struct SessionKeys {72 pub aura: Aura,73 }74}757677#[cfg(feature = "std")]78pub fn native_version() -> NativeVersion {79 NativeVersion {80 runtime_version: crate::VERSION,81 can_author_with: Default::default(),82 }83}8485pub type ChargeTransactionPayment = pallet_charge_transaction::ChargeTransactionPayment<Runtime>;8687pub type SignedExtra = (88 frame_system::CheckSpecVersion<Runtime>,89 frame_system::CheckTxVersion<Runtime>,90 frame_system::CheckGenesis<Runtime>,91 frame_system::CheckEra<Runtime>,92 frame_system::CheckNonce<Runtime>,93 frame_system::CheckWeight<Runtime>,94 maintenance::CheckMaintenance,95 ChargeTransactionPayment,96 97 pallet_ethereum::FakeTransactionFinalizer<Runtime>,98);99100101pub type UncheckedExtrinsic =102 fp_self_contained::UncheckedExtrinsic<Address, RuntimeCall, Signature, SignedExtra>;103104105pub type CheckedExtrinsic =106 fp_self_contained::CheckedExtrinsic<AccountId, RuntimeCall, SignedExtra, H160>;107108109pub type Executive = frame_executive::Executive<110 Runtime,111 Block,112 frame_system::ChainContext<Runtime>,113 Runtime,114 AllPalletsWithSystem,115>;116117type NegativeImbalance = <Balances as Currency<AccountId>>::NegativeImbalance;118119pub struct DealWithFees;120impl OnUnbalanced<NegativeImbalance> for DealWithFees {121 fn on_unbalanceds<B>(mut fees_then_tips: impl Iterator<Item = NegativeImbalance>) {122 if let Some(fees) = fees_then_tips.next() {123 124 let mut split = fees.ration(100, 0);125 if let Some(tips) = fees_then_tips.next() {126 127 tips.ration_merge_into(100, 0, &mut split);128 }129 Treasury::on_unbalanced(split.0);130 131 }132 }133}134135pub struct RelayChainBlockNumberProvider<T>(sp_std::marker::PhantomData<T>);136137impl<T: cumulus_pallet_parachain_system::Config> BlockNumberProvider138 for RelayChainBlockNumberProvider<T>139{140 type BlockNumber = BlockNumber;141142 fn current_block_number() -> Self::BlockNumber {143 cumulus_pallet_parachain_system::Pallet::<T>::validation_data()144 .map(|d| d.relay_parent_number)145 .unwrap_or_default()146 }147}148149pub(crate) struct CheckInherents;150151impl cumulus_pallet_parachain_system::CheckInherents<Block> for CheckInherents {152 fn check_inherents(153 block: &Block,154 relay_state_proof: &cumulus_pallet_parachain_system::RelayChainStateProof,155 ) -> sp_inherents::CheckInherentsResult {156 let relay_chain_slot = relay_state_proof157 .read_slot()158 .expect("Could not read the relay chain slot from the proof");159160 let inherent_data =161 cumulus_primitives_timestamp::InherentDataProvider::from_relay_chain_slot_and_duration(162 relay_chain_slot,163 sp_std::time::Duration::from_secs(6),164 )165 .create_inherent_data()166 .expect("Could not create the timestamp inherent data");167168 inherent_data.check_extrinsics(block)169 }170}171172#[derive(codec::Encode, codec::Decode)]173pub enum XCMPMessage<XAccountId, XBalance> {174 175 TransferToken(XAccountId, XBalance),176}