12345678910111213141516171819#![cfg_attr(not(feature = "std"), no_std)]2021#![recursion_limit = "1024"]22#![allow(clippy::from_over_into, clippy::identity_op)]23#![allow(clippy::fn_to_numeric_cast_with_truncation)]2425#[cfg(feature = "std")]26include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));2728use sp_api::impl_runtime_apis;29use sp_core::{crypto::KeyTypeId, OpaqueMetadata, H256, U256, H160};30use sp_runtime::DispatchError;31323334use sp_runtime::{35 Permill, Perbill, Percent, create_runtime_str, generic, impl_opaque_keys,36 traits::{AccountIdLookup, BlakeTwo256, Block as BlockT, AccountIdConversion, Zero},37 transaction_validity::{TransactionSource, TransactionValidity},38 ApplyExtrinsicResult, RuntimeAppPublic,39};4041use sp_std::prelude::*;4243#[cfg(feature = "std")]44use sp_version::NativeVersion;45use sp_version::RuntimeVersion;46pub use pallet_transaction_payment::{47 Multiplier, TargetedFeeAdjustment, FeeDetails, RuntimeDispatchInfo,48};4950pub use pallet_balances::Call as BalancesCall;51pub use pallet_evm::{52 EnsureAddressTruncated, HashedAddressMapping, Runner, account::CrossAccountId as _,53};54pub use frame_support::{55 construct_runtime, match_types,56 dispatch::DispatchResult,57 PalletId, parameter_types, StorageValue, ConsensusEngineId,58 traits::{59 tokens::currency::Currency as CurrencyT, OnUnbalanced as OnUnbalancedT, Everything,60 Currency, ExistenceRequirement, Get, IsInVec, KeyOwnerProofSystem, LockIdentifier,61 OnUnbalanced, Randomness, FindAuthor, ConstU32, Imbalance,62 },63 weights::{64 constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND},65 DispatchClass, DispatchInfo, GetDispatchInfo, IdentityFee, Pays, PostDispatchInfo, Weight,66 WeightToFeePolynomial, WeightToFeeCoefficient, WeightToFeeCoefficients, ConstantMultiplier,67 },68};69use up_data_structs::*;707172use frame_system::{73 self as frame_system, EnsureRoot, EnsureSigned,74 limits::{BlockWeights, BlockLength},75};76use sp_arithmetic::{77 traits::{BaseArithmetic, Unsigned},78};79use smallvec::smallvec;80use codec::{Encode, Decode};81use pallet_unique::eth::evm_collection;82use pallet_evm::{Account as EVMAccount, FeeCalculator, GasWeightMapping};83use fp_rpc::TransactionStatus;84use sp_runtime::{85 traits::{BlockNumberProvider, Dispatchable, PostDispatchInfoOf, Saturating},86 transaction_validity::TransactionValidityError,87 SaturatedConversion,88};899091pub use sp_consensus_aura::sr25519::AuthorityId as AuraId;929394use pallet_xcm::XcmPassthrough;95use polkadot_parachain::primitives::Sibling;96use up_data_structs::mapping::{CrossTokenAddressMapping, EvmTokenAddressMapping};97use xcm::v1::{BodyId, Junction::*, MultiLocation, NetworkId, Junctions::*};98use xcm_builder::{99 AccountId32Aliases, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, CurrencyAdapter,100 EnsureXcmOrigin, FixedWeightBounds, LocationInverter, NativeAsset, ParentAsSuperuser,101 RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia,102 SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit,103 ParentIsPreset,104};105use xcm_executor::{Config, XcmExecutor, Assets};106use sp_std::{marker::PhantomData};107108use xcm::latest::{109 110 AssetId::{Concrete},111 Fungibility::Fungible as XcmFungible,112 MultiAsset,113 Error as XcmError,114};115use xcm_executor::traits::{MatchesFungible, WeightTrader};116117use sp_runtime::traits::CheckedConversion;118119use unique_runtime_common::{120 impl_common_runtime_apis,121 types::*,122 constants::*,123 dispatch::{CollectionDispatchT, CollectionDispatch},124 sponsoring::UniqueSponsorshipHandler,125 eth_sponsoring::UniqueEthSponsorshipHandler,126 weights::CommonWeights,127};128129pub const RUNTIME_NAME: &str = "quartz";130pub const TOKEN_SYMBOL: &str = "QTZ";131132type CrossAccountId = pallet_evm::account::BasicCrossAccountId<Runtime>;133134impl RuntimeInstance for Runtime {135 type CrossAccountId = self::CrossAccountId;136137 type TransactionConverter = self::TransactionConverter;138139 fn get_transaction_converter() -> TransactionConverter {140 TransactionConverter141 }142}143144145146147148pub mod opaque {149 use sp_std::prelude::*;150 use sp_runtime::impl_opaque_keys;151 use super::Aura;152153 pub use unique_runtime_common::types::*;154155 impl_opaque_keys! {156 pub struct SessionKeys {157 pub aura: Aura,158 }159 }160}161162163pub const VERSION: RuntimeVersion = RuntimeVersion {164 spec_name: create_runtime_str!(RUNTIME_NAME),165 impl_name: create_runtime_str!(RUNTIME_NAME),166 authoring_version: 1,167 spec_version: 920000,168 impl_version: 0,169 apis: RUNTIME_API_VERSIONS,170 transaction_version: 1,171 state_version: 0,172};173174#[derive(codec::Encode, codec::Decode)]175pub enum XCMPMessage<XAccountId, XBalance> {176 177 TransferToken(XAccountId, XBalance),178}179180181#[cfg(feature = "std")]182pub fn native_version() -> NativeVersion {183 NativeVersion {184 runtime_version: VERSION,185 can_author_with: Default::default(),186 }187}188189type NegativeImbalance = <Balances as Currency<AccountId>>::NegativeImbalance;190191pub struct DealWithFees;192impl OnUnbalanced<NegativeImbalance> for DealWithFees {193 fn on_unbalanceds<B>(mut fees_then_tips: impl Iterator<Item = NegativeImbalance>) {194 if let Some(fees) = fees_then_tips.next() {195 196 let mut split = fees.ration(100, 0);197 if let Some(tips) = fees_then_tips.next() {198 199 tips.ration_merge_into(100, 0, &mut split);200 }201 Treasury::on_unbalanced(split.0);202 203 }204 }205}206207parameter_types! {208 pub const BlockHashCount: BlockNumber = 2400;209 pub RuntimeBlockLength: BlockLength =210 BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);211 pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);212 pub const MaximumBlockLength: u32 = 5 * 1024 * 1024;213 pub RuntimeBlockWeights: BlockWeights = BlockWeights::builder()214 .base_block(BlockExecutionWeight::get())215 .for_class(DispatchClass::all(), |weights| {216 weights.base_extrinsic = ExtrinsicBaseWeight::get();217 })218 .for_class(DispatchClass::Normal, |weights| {219 weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT);220 })221 .for_class(DispatchClass::Operational, |weights| {222 weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT);223 224 225 weights.reserved = Some(226 MAXIMUM_BLOCK_WEIGHT - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT227 );228 })229 .avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO)230 .build_or_panic();231 pub const Version: RuntimeVersion = VERSION;232 pub const SS58Prefix: u8 = 255;233}234235parameter_types! {236 pub const ChainId: u64 = 8881;237}238239pub struct FixedFee;240impl FeeCalculator for FixedFee {241 fn min_gas_price() -> U256 {242 MIN_GAS_PRICE.into()243 }244}245246247248249parameter_types! {250 pub const WritesPerSecond: u64 = WEIGHT_PER_SECOND / <Runtime as frame_system::Config>::DbWeight::get().write;251 pub const GasPerSecond: u64 = WritesPerSecond::get() * 20000;252 pub const WeightPerGas: u64 = WEIGHT_PER_SECOND / GasPerSecond::get();253}254255256257258const EVM_DISPATCH_RATIO: Perbill = Perbill::from_percent(50);259parameter_types! {260 pub BlockGasLimit: U256 = U256::from(NORMAL_DISPATCH_RATIO * EVM_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT / WeightPerGas::get());261}262263pub enum FixedGasWeightMapping {}264impl GasWeightMapping for FixedGasWeightMapping {265 fn gas_to_weight(gas: u64) -> Weight {266 gas.saturating_mul(WeightPerGas::get())267 }268 fn weight_to_gas(weight: Weight) -> u64 {269 weight / WeightPerGas::get()270 }271}272273impl pallet_evm::Config for Runtime {274 type BlockGasLimit = BlockGasLimit;275 type FeeCalculator = FixedFee;276 type GasWeightMapping = FixedGasWeightMapping;277 type BlockHashMapping = pallet_ethereum::EthereumBlockHashMapping<Self>;278 type CallOrigin = EnsureAddressTruncated<Self>;279 type WithdrawOrigin = EnsureAddressTruncated<Self>;280 type AddressMapping = HashedAddressMapping<Self::Hashing>;281 type PrecompilesType = ();282 type PrecompilesValue = ();283 type Currency = Balances;284 type Event = Event;285 type OnMethodCall = (286 pallet_evm_migration::OnMethodCall<Self>,287 pallet_evm_contract_helpers::HelpersOnMethodCall<Self>,288 CollectionDispatchT<Self>,289 evm_collection::CollectionOnMethodCall<Self>,290 evm_collection::CollectionHelperOnMethodCall<Self>,291 );292 type OnCreate = pallet_evm_contract_helpers::HelpersOnCreate<Self>;293 type ChainId = ChainId;294 type Runner = pallet_evm::runner::stack::Runner<Self>;295 type OnChargeTransaction = pallet_evm::EVMCurrencyAdapter<Balances, DealWithFees>;296 type TransactionValidityHack = pallet_evm_transaction_payment::TransactionValidityHack<Self>;297 type FindAuthor = EthereumFindAuthor<Aura>;298}299300impl pallet_evm_migration::Config for Runtime {301 type WeightInfo = pallet_evm_migration::weights::SubstrateWeight<Self>;302}303304pub struct EthereumFindAuthor<F>(core::marker::PhantomData<F>);305impl<F: FindAuthor<u32>> FindAuthor<H160> for EthereumFindAuthor<F> {306 fn find_author<'a, I>(digests: I) -> Option<H160>307 where308 I: 'a + IntoIterator<Item = (ConsensusEngineId, &'a [u8])>,309 {310 if let Some(author_index) = F::find_author(digests) {311 let authority_id = Aura::authorities()[author_index as usize].clone();312 return Some(H160::from_slice(&authority_id.to_raw_vec()[4..24]));313 }314 None315 }316}317318impl pallet_ethereum::Config for Runtime {319 type Event = Event;320 type StateRoot = pallet_ethereum::IntermediateStateRoot<Self>;321}322323impl pallet_randomness_collective_flip::Config for Runtime {}324325impl frame_system::Config for Runtime {326 327 type AccountData = pallet_balances::AccountData<Balance>;328 329 type AccountId = AccountId;330 331 type BaseCallFilter = Everything;332 333 type BlockHashCount = BlockHashCount;334 335 type BlockLength = RuntimeBlockLength;336 337 type BlockNumber = BlockNumber;338 339 type BlockWeights = RuntimeBlockWeights;340 341 type Call = Call;342 343 type DbWeight = RocksDbWeight;344 345 type Event = Event;346 347 type Hash = Hash;348 349 type Hashing = BlakeTwo256;350 351 type Header = generic::Header<BlockNumber, BlakeTwo256>;352 353 type Index = Index;354 355 type Lookup = AccountIdLookup<AccountId, ()>;356 357 type OnKilledAccount = ();358 359 type OnNewAccount = ();360 type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode<Self>;361 362 type Origin = Origin;363 364 type PalletInfo = PalletInfo;365 366 type SS58Prefix = SS58Prefix;367 368 type SystemWeightInfo = frame_system::weights::SubstrateWeight<Self>;369 370 type Version = Version;371 type MaxConsumers = ConstU32<16>;372}373374parameter_types! {375 pub const MinimumPeriod: u64 = SLOT_DURATION / 2;376}377378impl pallet_timestamp::Config for Runtime {379 380 type Moment = u64;381 type OnTimestampSet = ();382 type MinimumPeriod = MinimumPeriod;383 type WeightInfo = ();384}385386parameter_types! {387 388 pub const ExistentialDeposit: u128 = 0;389 pub const MaxLocks: u32 = 50;390}391392impl pallet_balances::Config for Runtime {393 type MaxLocks = MaxLocks;394 type MaxReserves = ();395 type ReserveIdentifier = [u8; 8];396 397 type Balance = Balance;398 399 type Event = Event;400 type DustRemoval = Treasury;401 type ExistentialDeposit = ExistentialDeposit;402 type AccountStore = System;403 type WeightInfo = pallet_balances::weights::SubstrateWeight<Self>;404}405406pub const fn deposit(items: u32, bytes: u32) -> Balance {407 items as Balance * 15 * CENTIUNIQUE + (bytes as Balance) * 6 * CENTIUNIQUE408}409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460parameter_types! {461 462 463 pub const OperationalFeeMultiplier: u8 = 5;464}465466467pub struct LinearFee<T>(sp_std::marker::PhantomData<T>);468469impl<T> WeightToFeePolynomial for LinearFee<T>470where471 T: BaseArithmetic + From<u32> + Copy + Unsigned,472{473 type Balance = T;474475 fn polynomial() -> WeightToFeeCoefficients<Self::Balance> {476 smallvec!(WeightToFeeCoefficient {477 478 coeff_integer: WEIGHT_TO_FEE_COEFF.into(),479 coeff_frac: Perbill::zero(),480 negative: false,481 degree: 1,482 })483 }484}485486impl pallet_transaction_payment::Config for Runtime {487 type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter<Balances, DealWithFees>;488 type LengthToFee = ConstantMultiplier<Balance, TransactionByteFee>;489 type OperationalFeeMultiplier = OperationalFeeMultiplier;490 type WeightToFee = LinearFee<Balance>;491 type FeeMultiplierUpdate = ();492}493494parameter_types! {495 pub const ProposalBond: Permill = Permill::from_percent(5);496 pub const ProposalBondMinimum: Balance = 1 * UNIQUE;497 pub const ProposalBondMaximum: Balance = 1000 * UNIQUE;498 pub const SpendPeriod: BlockNumber = 5 * MINUTES;499 pub const Burn: Permill = Permill::from_percent(0);500 pub const TipCountdown: BlockNumber = 1 * DAYS;501 pub const TipFindersFee: Percent = Percent::from_percent(20);502 pub const TipReportDepositBase: Balance = 1 * UNIQUE;503 pub const DataDepositPerByte: Balance = 1 * CENTIUNIQUE;504 pub const BountyDepositBase: Balance = 1 * UNIQUE;505 pub const BountyDepositPayoutDelay: BlockNumber = 1 * DAYS;506 pub const TreasuryModuleId: PalletId = PalletId(*b"py/trsry");507 pub const BountyUpdatePeriod: BlockNumber = 14 * DAYS;508 pub const MaximumReasonLength: u32 = 16384;509 pub const BountyCuratorDeposit: Permill = Permill::from_percent(50);510 pub const BountyValueMinimum: Balance = 5 * UNIQUE;511 pub const MaxApprovals: u32 = 100;512}513514impl pallet_treasury::Config for Runtime {515 type PalletId = TreasuryModuleId;516 type Currency = Balances;517 type ApproveOrigin = EnsureRoot<AccountId>;518 type RejectOrigin = EnsureRoot<AccountId>;519 type Event = Event;520 type OnSlash = ();521 type ProposalBond = ProposalBond;522 type ProposalBondMinimum = ProposalBondMinimum;523 type ProposalBondMaximum = ProposalBondMaximum;524 type SpendPeriod = SpendPeriod;525 type Burn = Burn;526 type BurnDestination = ();527 type SpendFunds = ();528 type WeightInfo = pallet_treasury::weights::SubstrateWeight<Self>;529 type MaxApprovals = MaxApprovals;530}531532impl pallet_sudo::Config for Runtime {533 type Event = Event;534 type Call = Call;535}536537pub struct RelayChainBlockNumberProvider<T>(sp_std::marker::PhantomData<T>);538539impl<T: cumulus_pallet_parachain_system::Config> BlockNumberProvider540 for RelayChainBlockNumberProvider<T>541{542 type BlockNumber = BlockNumber;543544 fn current_block_number() -> Self::BlockNumber {545 cumulus_pallet_parachain_system::Pallet::<T>::validation_data()546 .map(|d| d.relay_parent_number)547 .unwrap_or_default()548 }549}550551parameter_types! {552 pub const MinVestedTransfer: Balance = 10 * UNIQUE;553 pub const MaxVestingSchedules: u32 = 28;554}555556impl orml_vesting::Config for Runtime {557 type Event = Event;558 type Currency = pallet_balances::Pallet<Runtime>;559 type MinVestedTransfer = MinVestedTransfer;560 type VestedTransferOrigin = EnsureSigned<AccountId>;561 type WeightInfo = ();562 type MaxVestingSchedules = MaxVestingSchedules;563 type BlockNumberProvider = RelayChainBlockNumberProvider<Runtime>;564}565566parameter_types! {567 pub const ReservedDmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;568 pub const ReservedXcmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;569}570571impl cumulus_pallet_parachain_system::Config for Runtime {572 type Event = Event;573 type SelfParaId = parachain_info::Pallet<Self>;574 type OnSystemEvent = ();575 576 577 578 579 580 type OutboundXcmpMessageSource = XcmpQueue;581 type DmpMessageHandler = DmpQueue;582 type ReservedDmpWeight = ReservedDmpWeight;583 type ReservedXcmpWeight = ReservedXcmpWeight;584 type XcmpMessageHandler = XcmpQueue;585}586587impl parachain_info::Config for Runtime {}588589impl cumulus_pallet_aura_ext::Config for Runtime {}590591parameter_types! {592 pub const RelayLocation: MultiLocation = MultiLocation::parent();593 pub const RelayNetwork: NetworkId = NetworkId::Polkadot;594 pub RelayOrigin: Origin = cumulus_pallet_xcm::Origin::Relay.into();595 pub Ancestry: MultiLocation = Parachain(ParachainInfo::parachain_id().into()).into();596}597598599600601pub type LocationToAccountId = (602 603 ParentIsPreset<AccountId>,604 605 SiblingParachainConvertsVia<Sibling, AccountId>,606 607 AccountId32Aliases<RelayNetwork, AccountId>,608);609610pub struct OnlySelfCurrency;611impl<B: TryFrom<u128>> MatchesFungible<B> for OnlySelfCurrency {612 fn matches_fungible(a: &MultiAsset) -> Option<B> {613 match (&a.id, &a.fun) {614 (Concrete(_), XcmFungible(ref amount)) => CheckedConversion::checked_from(*amount),615 _ => None,616 }617 }618}619620621pub type LocalAssetTransactor = CurrencyAdapter<622 623 Balances,624 625 OnlySelfCurrency,626 627 LocationToAccountId,628 629 AccountId,630 631 (),632>;633634635636637pub type XcmOriginToTransactDispatchOrigin = (638 639 640 641 SovereignSignedViaLocation<LocationToAccountId, Origin>,642 643 644 RelayChainAsNative<RelayOrigin, Origin>,645 646 647 SiblingParachainAsNative<cumulus_pallet_xcm::Origin, Origin>,648 649 650 ParentAsSuperuser<Origin>,651 652 653 SignedAccountId32AsNative<RelayNetwork, Origin>,654 655 XcmPassthrough<Origin>,656);657658parameter_types! {659 660 pub UnitWeightCost: Weight = 1_000_000;661 662 pub const WeightPrice: (MultiLocation, u128) = (MultiLocation::parent(), 1_200 * UNIQUE);663 pub const MaxInstructions: u32 = 100;664 pub const MaxAuthorities: u32 = 100_000;665}666667match_types! {668 pub type ParentOrParentsUnitPlurality: impl Contains<MultiLocation> = {669 MultiLocation { parents: 1, interior: Here } |670 MultiLocation { parents: 1, interior: X1(Plurality { id: BodyId::Unit, .. }) }671 };672}673674pub type Barrier = (675 TakeWeightCredit,676 AllowTopLevelPaidExecutionFrom<Everything>,677 AllowUnpaidExecutionFrom<ParentOrParentsUnitPlurality>,678 679);680681pub struct UsingOnlySelfCurrencyComponents<682 WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,683 AssetId: Get<MultiLocation>,684 AccountId,685 Currency: CurrencyT<AccountId>,686 OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,687>(688 Weight,689 Currency::Balance,690 PhantomData<(WeightToFee, AssetId, AccountId, Currency, OnUnbalanced)>,691);692impl<693 WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,694 AssetId: Get<MultiLocation>,695 AccountId,696 Currency: CurrencyT<AccountId>,697 OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,698 > WeightTrader699 for UsingOnlySelfCurrencyComponents<WeightToFee, AssetId, AccountId, Currency, OnUnbalanced>700{701 fn new() -> Self {702 Self(0, Zero::zero(), PhantomData)703 }704705 fn buy_weight(&mut self, weight: Weight, payment: Assets) -> Result<Assets, XcmError> {706 let amount = WeightToFee::calc(&weight);707 let u128_amount: u128 = amount.try_into().map_err(|_| XcmError::Overflow)?;708709 710 let option1: xcm::v1::AssetId = Concrete(MultiLocation {711 parents: 1,712 interior: X1(Parachain(ParachainInfo::parachain_id().into())),713 });714 715 let option2: xcm::v1::AssetId = Concrete(MultiLocation {716 parents: 0,717 interior: Here,718 });719720 let required = if payment.fungible.contains_key(&option1) {721 (option1, u128_amount).into()722 } else if payment.fungible.contains_key(&option2) {723 (option2, u128_amount).into()724 } else {725 (Concrete(MultiLocation::default()), u128_amount).into()726 };727728 let unused = payment729 .checked_sub(required)730 .map_err(|_| XcmError::TooExpensive)?;731 self.0 = self.0.saturating_add(weight);732 self.1 = self.1.saturating_add(amount);733 Ok(unused)734 }735736 fn refund_weight(&mut self, weight: Weight) -> Option<MultiAsset> {737 let weight = weight.min(self.0);738 let amount = WeightToFee::calc(&weight);739 self.0 -= weight;740 self.1 = self.1.saturating_sub(amount);741 let amount: u128 = amount.saturated_into();742 if amount > 0 {743 Some((AssetId::get(), amount).into())744 } else {745 None746 }747 }748}749impl<750 WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,751 AssetId: Get<MultiLocation>,752 AccountId,753 Currency: CurrencyT<AccountId>,754 OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,755 > Drop756 for UsingOnlySelfCurrencyComponents<WeightToFee, AssetId, AccountId, Currency, OnUnbalanced>757{758 fn drop(&mut self) {759 OnUnbalanced::on_unbalanced(Currency::issue(self.1));760 }761}762763pub struct XcmConfig;764impl Config for XcmConfig {765 type Call = Call;766 type XcmSender = XcmRouter;767 768 type AssetTransactor = LocalAssetTransactor;769 type OriginConverter = XcmOriginToTransactDispatchOrigin;770 type IsReserve = NativeAsset;771 type IsTeleporter = (); 772 type LocationInverter = LocationInverter<Ancestry>;773 type Barrier = Barrier;774 type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;775 type Trader = UsingOnlySelfCurrencyComponents<776 IdentityFee<Balance>,777 RelayLocation,778 AccountId,779 Balances,780 (),781 >;782 type ResponseHandler = (); 783 type SubscriptionService = PolkadotXcm;784785 type AssetTrap = PolkadotXcm;786 type AssetClaims = PolkadotXcm;787}788789790791792793794pub type LocalOriginToLocation = (SignedToAccountId32<Origin, AccountId, RelayNetwork>,);795796797798pub type XcmRouter = (799 800 cumulus_primitives_utility::ParentAsUmp<ParachainSystem, ()>,801 802 XcmpQueue,803);804805impl pallet_evm_coder_substrate::Config for Runtime {806 type GasWeightMapping = FixedGasWeightMapping;807}808809impl pallet_xcm::Config for Runtime {810 type Event = Event;811 type SendXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;812 type XcmRouter = XcmRouter;813 type ExecuteXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;814 type XcmExecuteFilter = Everything;815 type XcmExecutor = XcmExecutor<XcmConfig>;816 type XcmTeleportFilter = Everything;817 type XcmReserveTransferFilter = Everything;818 type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;819 type LocationInverter = LocationInverter<Ancestry>;820 type Origin = Origin;821 type Call = Call;822 const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;823 type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;824}825826impl cumulus_pallet_xcm::Config for Runtime {827 type Event = Event;828 type XcmExecutor = XcmExecutor<XcmConfig>;829}830831impl cumulus_pallet_xcmp_queue::Config for Runtime {832 type WeightInfo = ();833 type Event = Event;834 type XcmExecutor = XcmExecutor<XcmConfig>;835 type ChannelInfo = ParachainSystem;836 type VersionWrapper = ();837 type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;838 type ControllerOrigin = EnsureRoot<AccountId>;839 type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin;840}841842impl cumulus_pallet_dmp_queue::Config for Runtime {843 type Event = Event;844 type XcmExecutor = XcmExecutor<XcmConfig>;845 type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;846}847848impl pallet_aura::Config for Runtime {849 type AuthorityId = AuraId;850 type DisabledValidators = ();851 type MaxAuthorities = MaxAuthorities;852}853854parameter_types! {855 pub TreasuryAccountId: AccountId = TreasuryModuleId::get().into_account();856 pub const CollectionCreationPrice: Balance = 2 * UNIQUE;857}858859impl pallet_common::Config for Runtime {860 type Event = Event;861862 type Currency = Balances;863 type CollectionCreationPrice = CollectionCreationPrice;864 type TreasuryAccountId = TreasuryAccountId;865 type CollectionDispatch = CollectionDispatchT<Self>;866867 type EvmTokenAddressMapping = EvmTokenAddressMapping;868 type CrossTokenAddressMapping = CrossTokenAddressMapping<Self::AccountId>;869}870871impl pallet_structure::Config for Runtime {872 type Event = Event;873 type Call = Call;874 type WeightInfo = pallet_structure::weights::SubstrateWeight<Self>;875}876877impl pallet_evm::account::Config for Runtime {878 type CrossAccountId = pallet_evm::account::BasicCrossAccountId<Self>;879 type EvmAddressMapping = HashedAddressMapping<Self::Hashing>;880 type EvmBackwardsAddressMapping = fp_evm_mapping::MapBackwardsAddressTruncated;881}882883impl pallet_fungible::Config for Runtime {884 type WeightInfo = pallet_fungible::weights::SubstrateWeight<Self>;885}886impl pallet_refungible::Config for Runtime {887 type WeightInfo = pallet_refungible::weights::SubstrateWeight<Self>;888}889impl pallet_nonfungible::Config for Runtime {890 type WeightInfo = pallet_nonfungible::weights::SubstrateWeight<Self>;891}892893impl pallet_proxy_rmrk_core::Config for Runtime {894 type Event = Event;895}896897impl pallet_proxy_rmrk_equip::Config for Runtime {898 type Event = Event;899}900901impl pallet_unique::Config for Runtime {902 type Event = Event;903 type WeightInfo = pallet_unique::weights::SubstrateWeight<Self>;904 type CommonWeightInfo = CommonWeights<Self>;905}906907parameter_types! {908 pub const InflationBlockInterval: BlockNumber = 100; 909}910911912impl pallet_inflation::Config for Runtime {913 type Currency = Balances;914 type TreasuryAccountId = TreasuryAccountId;915 type InflationBlockInterval = InflationBlockInterval;916 type BlockNumberProvider = RelayChainBlockNumberProvider<Runtime>;917}918919920921922923924925type EvmSponsorshipHandler = (926 UniqueEthSponsorshipHandler<Runtime>,927 pallet_evm_contract_helpers::HelpersContractSponsoring<Runtime>,928);929type SponsorshipHandler = (930 UniqueSponsorshipHandler<Runtime>,931 932 pallet_evm_transaction_payment::BridgeSponsorshipHandler<Runtime>,933);934935936937938939940941942943944945946947impl pallet_evm_transaction_payment::Config for Runtime {948 type EvmSponsorshipHandler = EvmSponsorshipHandler;949 type Currency = Balances;950}951952impl pallet_charge_transaction::Config for Runtime {953 type SponsorshipHandler = SponsorshipHandler;954}955956957958959960parameter_types! {961 962 pub const HelpersContractAddress: H160 = H160([963 0x84, 0x28, 0x99, 0xec, 0xf3, 0x80, 0x55, 0x3e, 0x8a, 0x4d, 0xe7, 0x5b, 0xf5, 0x34, 0xcd, 0xf6, 0xfb, 0xf6, 0x40, 0x49,964 ]);965 966 967 pub const EvmCollectionHelperAddress: H160 = H160([968 0x6c, 0x4e, 0x9f, 0xe1, 0xae, 0x37, 0xa4, 0x1e, 0x93, 0xce, 0xe4, 0x29, 0xe8, 0xe1, 0x88, 0x1a, 0xbd, 0xcb, 0xb5, 0x4f,969 ]);970}971972impl pallet_evm_contract_helpers::Config for Runtime {973 type ContractAddress = HelpersContractAddress;974 type DefaultSponsoringRateLimit = DefaultSponsoringRateLimit;975}976977impl evm_collection::Config for Runtime {978 type ContractAddress = EvmCollectionHelperAddress;979}980981construct_runtime!(982 pub enum Runtime where983 Block = Block,984 NodeBlock = opaque::Block,985 UncheckedExtrinsic = UncheckedExtrinsic986 {987 ParachainSystem: cumulus_pallet_parachain_system::{Pallet, Call, Config, Storage, Inherent, Event<T>, ValidateUnsigned} = 20,988 ParachainInfo: parachain_info::{Pallet, Storage, Config} = 21,989990 Aura: pallet_aura::{Pallet, Config<T>} = 22,991 AuraExt: cumulus_pallet_aura_ext::{Pallet, Config} = 23,992993 Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>} = 30,994 RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Pallet, Storage} = 31,995 Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent} = 32,996 TransactionPayment: pallet_transaction_payment::{Pallet, Storage} = 33,997 Treasury: pallet_treasury::{Pallet, Call, Storage, Config, Event<T>} = 34,998 Sudo: pallet_sudo::{Pallet, Call, Storage, Config<T>, Event<T>} = 35,999 System: frame_system::{Pallet, Call, Storage, Config, Event<T>} = 36,1000 Vesting: orml_vesting::{Pallet, Storage, Call, Event<T>, Config<T>} = 37,1001 1002 10031004 1005 XcmpQueue: cumulus_pallet_xcmp_queue::{Pallet, Call, Storage, Event<T>} = 50,1006 PolkadotXcm: pallet_xcm::{Pallet, Call, Event<T>, Origin} = 51,1007 CumulusXcm: cumulus_pallet_xcm::{Pallet, Call, Event<T>, Origin} = 52,1008 DmpQueue: cumulus_pallet_dmp_queue::{Pallet, Call, Storage, Event<T>} = 53,10091010 1011 Inflation: pallet_inflation::{Pallet, Call, Storage} = 60,1012 Unique: pallet_unique::{Pallet, Call, Storage, Event<T>} = 61,1013 1014 1015 Charging: pallet_charge_transaction::{Pallet, Call, Storage } = 64,1016 1017 Common: pallet_common::{Pallet, Storage, Event<T>} = 66,1018 Fungible: pallet_fungible::{Pallet, Storage} = 67,1019 Refungible: pallet_refungible::{Pallet, Storage} = 68,1020 Nonfungible: pallet_nonfungible::{Pallet, Storage} = 69,1021 Structure: pallet_structure::{Pallet, Call, Storage, Event<T>} = 70,1022 RmrkCore: pallet_proxy_rmrk_core::{Pallet, Call, Storage, Event<T>} = 71,1023 RmrkEquip: pallet_proxy_rmrk_equip::{Pallet, Call, Storage, Event<T>} = 72,10241025 1026 EVM: pallet_evm::{Pallet, Config, Call, Storage, Event<T>} = 100,1027 Ethereum: pallet_ethereum::{Pallet, Config, Call, Storage, Event, Origin} = 101,10281029 EvmCoderSubstrate: pallet_evm_coder_substrate::{Pallet, Storage} = 150,1030 EvmContractHelpers: pallet_evm_contract_helpers::{Pallet, Storage} = 151,1031 EvmTransactionPayment: pallet_evm_transaction_payment::{Pallet} = 152,1032 EvmMigration: pallet_evm_migration::{Pallet, Call, Storage} = 153,1033 }1034);10351036pub struct TransactionConverter;10371038impl fp_rpc::ConvertTransaction<UncheckedExtrinsic> for TransactionConverter {1039 fn convert_transaction(&self, transaction: pallet_ethereum::Transaction) -> UncheckedExtrinsic {1040 UncheckedExtrinsic::new_unsigned(1041 pallet_ethereum::Call::<Runtime>::transact { transaction }.into(),1042 )1043 }1044}10451046impl fp_rpc::ConvertTransaction<opaque::UncheckedExtrinsic> for TransactionConverter {1047 fn convert_transaction(1048 &self,1049 transaction: pallet_ethereum::Transaction,1050 ) -> opaque::UncheckedExtrinsic {1051 let extrinsic = UncheckedExtrinsic::new_unsigned(1052 pallet_ethereum::Call::<Runtime>::transact { transaction }.into(),1053 );1054 let encoded = extrinsic.encode();1055 opaque::UncheckedExtrinsic::decode(&mut &encoded[..])1056 .expect("Encoded extrinsic is always valid")1057 }1058}105910601061pub type Address = sp_runtime::MultiAddress<AccountId, ()>;10621063pub type Header = generic::Header<BlockNumber, BlakeTwo256>;10641065pub type Block = generic::Block<Header, UncheckedExtrinsic>;10661067pub type SignedBlock = generic::SignedBlock<Block>;10681069pub type BlockId = generic::BlockId<Block>;10701071pub type SignedExtra = (1072 frame_system::CheckSpecVersion<Runtime>,1073 1074 frame_system::CheckGenesis<Runtime>,1075 frame_system::CheckEra<Runtime>,1076 frame_system::CheckNonce<Runtime>,1077 frame_system::CheckWeight<Runtime>,1078 pallet_charge_transaction::ChargeTransactionPayment<Runtime>,1079 1080 pallet_ethereum::FakeTransactionFinalizer<Runtime>,1081);10821083pub type UncheckedExtrinsic =1084 fp_self_contained::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;10851086pub type CheckedExtrinsic = fp_self_contained::CheckedExtrinsic<AccountId, Call, SignedExtra, H160>;10871088pub type Executive = frame_executive::Executive<1089 Runtime,1090 Block,1091 frame_system::ChainContext<Runtime>,1092 Runtime,1093 AllPalletsReversedWithSystemFirst,1094>;10951096impl_opaque_keys! {1097 pub struct SessionKeys {1098 pub aura: Aura,1099 }1100}11011102impl fp_self_contained::SelfContainedCall for Call {1103 type SignedInfo = H160;11041105 fn is_self_contained(&self) -> bool {1106 match self {1107 Call::Ethereum(call) => call.is_self_contained(),1108 _ => false,1109 }1110 }11111112 fn check_self_contained(&self) -> Option<Result<Self::SignedInfo, TransactionValidityError>> {1113 match self {1114 Call::Ethereum(call) => call.check_self_contained(),1115 _ => None,1116 }1117 }11181119 fn validate_self_contained(&self, info: &Self::SignedInfo) -> Option<TransactionValidity> {1120 match self {1121 Call::Ethereum(call) => call.validate_self_contained(info),1122 _ => None,1123 }1124 }11251126 fn pre_dispatch_self_contained(1127 &self,1128 info: &Self::SignedInfo,1129 ) -> Option<Result<(), TransactionValidityError>> {1130 match self {1131 Call::Ethereum(call) => call.pre_dispatch_self_contained(info),1132 _ => None,1133 }1134 }11351136 fn apply_self_contained(1137 self,1138 info: Self::SignedInfo,1139 ) -> Option<sp_runtime::DispatchResultWithInfo<PostDispatchInfoOf<Self>>> {1140 match self {1141 call @ Call::Ethereum(pallet_ethereum::Call::transact { .. }) => Some(call.dispatch(1142 Origin::from(pallet_ethereum::RawOrigin::EthereumTransaction(info)),1143 )),1144 _ => None,1145 }1146 }1147}11481149macro_rules! dispatch_unique_runtime {1150 ($collection:ident.$method:ident($($name:ident),*)) => {{1151 let collection = <Runtime as pallet_common::Config>::CollectionDispatch::dispatch(<pallet_common::CollectionHandle<Runtime>>::try_get($collection)?);1152 let dispatch = collection.as_dyn();11531154 Ok::<_, DispatchError>(dispatch.$method($($name),*))1155 }};1156}11571158impl_common_runtime_apis!();11591160struct CheckInherents;11611162impl cumulus_pallet_parachain_system::CheckInherents<Block> for CheckInherents {1163 fn check_inherents(1164 block: &Block,1165 relay_state_proof: &cumulus_pallet_parachain_system::RelayChainStateProof,1166 ) -> sp_inherents::CheckInherentsResult {1167 let relay_chain_slot = relay_state_proof1168 .read_slot()1169 .expect("Could not read the relay chain slot from the proof");11701171 let inherent_data =1172 cumulus_primitives_timestamp::InherentDataProvider::from_relay_chain_slot_and_duration(1173 relay_chain_slot,1174 sp_std::time::Duration::from_secs(6),1175 )1176 .create_inherent_data()1177 .expect("Could not create the timestamp inherent data");11781179 inherent_data.check_extrinsics(block)1180 }1181}11821183cumulus_pallet_parachain_system::register_validate_block!(1184 Runtime = Runtime,1185 BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor::<Runtime, Executive>,1186 CheckInherents = CheckInherents,1187);