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 unique_runtime_common::dispatch::{CollectionDispatchT, CollectionDispatch};70use up_data_structs::*;717273use frame_system::{74 self as frame_system, EnsureRoot, EnsureSigned,75 limits::{BlockWeights, BlockLength},76};77use sp_arithmetic::{78 traits::{BaseArithmetic, Unsigned},79};80use smallvec::smallvec;81use codec::{Encode, Decode};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::{impl_common_runtime_apis, types::*, constants::*};120121pub const RUNTIME_NAME: &str = "quartz";122pub const TOKEN_SYMBOL: &str = "QTZ";123124type CrossAccountId = pallet_evm::account::BasicCrossAccountId<Runtime>;125126impl RuntimeInstance for Runtime {127 type CrossAccountId = self::CrossAccountId;128129 type TransactionConverter = self::TransactionConverter;130131 fn get_transaction_converter() -> TransactionConverter {132 TransactionConverter133 }134}135136137138139140pub mod opaque {141 use sp_std::prelude::*;142 use sp_runtime::impl_opaque_keys;143 use super::Aura;144145 pub use unique_runtime_common::types::*;146147 impl_opaque_keys! {148 pub struct SessionKeys {149 pub aura: Aura,150 }151 }152}153154155pub const VERSION: RuntimeVersion = RuntimeVersion {156 spec_name: create_runtime_str!(RUNTIME_NAME),157 impl_name: create_runtime_str!(RUNTIME_NAME),158 authoring_version: 1,159 spec_version: 920000,160 impl_version: 0,161 apis: RUNTIME_API_VERSIONS,162 transaction_version: 1,163 state_version: 0,164};165166#[derive(codec::Encode, codec::Decode)]167pub enum XCMPMessage<XAccountId, XBalance> {168 169 TransferToken(XAccountId, XBalance),170}171172173#[cfg(feature = "std")]174pub fn native_version() -> NativeVersion {175 NativeVersion {176 runtime_version: VERSION,177 can_author_with: Default::default(),178 }179}180181type NegativeImbalance = <Balances as Currency<AccountId>>::NegativeImbalance;182183pub struct DealWithFees;184impl OnUnbalanced<NegativeImbalance> for DealWithFees {185 fn on_unbalanceds<B>(mut fees_then_tips: impl Iterator<Item = NegativeImbalance>) {186 if let Some(fees) = fees_then_tips.next() {187 188 let mut split = fees.ration(100, 0);189 if let Some(tips) = fees_then_tips.next() {190 191 tips.ration_merge_into(100, 0, &mut split);192 }193 Treasury::on_unbalanced(split.0);194 195 }196 }197}198199parameter_types! {200 pub const BlockHashCount: BlockNumber = 2400;201 pub RuntimeBlockLength: BlockLength =202 BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);203 pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);204 pub const MaximumBlockLength: u32 = 5 * 1024 * 1024;205 pub RuntimeBlockWeights: BlockWeights = BlockWeights::builder()206 .base_block(BlockExecutionWeight::get())207 .for_class(DispatchClass::all(), |weights| {208 weights.base_extrinsic = ExtrinsicBaseWeight::get();209 })210 .for_class(DispatchClass::Normal, |weights| {211 weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT);212 })213 .for_class(DispatchClass::Operational, |weights| {214 weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT);215 216 217 weights.reserved = Some(218 MAXIMUM_BLOCK_WEIGHT - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT219 );220 })221 .avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO)222 .build_or_panic();223 pub const Version: RuntimeVersion = VERSION;224 pub const SS58Prefix: u8 = 255;225}226227parameter_types! {228 pub const ChainId: u64 = 8881;229}230231pub struct FixedFee;232impl FeeCalculator for FixedFee {233 fn min_gas_price() -> U256 {234 MIN_GAS_PRICE.into()235 }236}237238239240241parameter_types! {242 pub const WritesPerSecond: u64 = WEIGHT_PER_SECOND / <Runtime as frame_system::Config>::DbWeight::get().write;243 pub const GasPerSecond: u64 = WritesPerSecond::get() * 20000;244 pub const WeightPerGas: u64 = WEIGHT_PER_SECOND / GasPerSecond::get();245}246247248249250const EVM_DISPATCH_RATIO: Perbill = Perbill::from_percent(50);251parameter_types! {252 pub BlockGasLimit: U256 = U256::from(NORMAL_DISPATCH_RATIO * EVM_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT / WeightPerGas::get());253}254255pub enum FixedGasWeightMapping {}256impl GasWeightMapping for FixedGasWeightMapping {257 fn gas_to_weight(gas: u64) -> Weight {258 gas.saturating_mul(WeightPerGas::get())259 }260 fn weight_to_gas(weight: Weight) -> u64 {261 weight / WeightPerGas::get()262 }263}264265impl pallet_evm::Config for Runtime {266 type BlockGasLimit = BlockGasLimit;267 type FeeCalculator = FixedFee;268 type GasWeightMapping = FixedGasWeightMapping;269 type BlockHashMapping = pallet_ethereum::EthereumBlockHashMapping<Self>;270 type CallOrigin = EnsureAddressTruncated<Self>;271 type WithdrawOrigin = EnsureAddressTruncated<Self>;272 type AddressMapping = HashedAddressMapping<Self::Hashing>;273 type PrecompilesType = ();274 type PrecompilesValue = ();275 type Currency = Balances;276 type Event = Event;277 type OnMethodCall = (278 pallet_evm_migration::OnMethodCall<Self>,279 pallet_evm_contract_helpers::HelpersOnMethodCall<Self>,280 CollectionDispatchT<Self>,281 );282 type OnCreate = pallet_evm_contract_helpers::HelpersOnCreate<Self>;283 type ChainId = ChainId;284 type Runner = pallet_evm::runner::stack::Runner<Self>;285 type OnChargeTransaction = pallet_evm::EVMCurrencyAdapter<Balances, DealWithFees>;286 type TransactionValidityHack = pallet_evm_transaction_payment::TransactionValidityHack<Self>;287 type FindAuthor = EthereumFindAuthor<Aura>;288}289290impl pallet_evm_migration::Config for Runtime {291 type WeightInfo = pallet_evm_migration::weights::SubstrateWeight<Self>;292}293294pub struct EthereumFindAuthor<F>(core::marker::PhantomData<F>);295impl<F: FindAuthor<u32>> FindAuthor<H160> for EthereumFindAuthor<F> {296 fn find_author<'a, I>(digests: I) -> Option<H160>297 where298 I: 'a + IntoIterator<Item = (ConsensusEngineId, &'a [u8])>,299 {300 if let Some(author_index) = F::find_author(digests) {301 let authority_id = Aura::authorities()[author_index as usize].clone();302 return Some(H160::from_slice(&authority_id.to_raw_vec()[4..24]));303 }304 None305 }306}307308impl pallet_ethereum::Config for Runtime {309 type Event = Event;310 type StateRoot = pallet_ethereum::IntermediateStateRoot<Self>;311}312313impl pallet_randomness_collective_flip::Config for Runtime {}314315impl frame_system::Config for Runtime {316 317 type AccountData = pallet_balances::AccountData<Balance>;318 319 type AccountId = AccountId;320 321 type BaseCallFilter = Everything;322 323 type BlockHashCount = BlockHashCount;324 325 type BlockLength = RuntimeBlockLength;326 327 type BlockNumber = BlockNumber;328 329 type BlockWeights = RuntimeBlockWeights;330 331 type Call = Call;332 333 type DbWeight = RocksDbWeight;334 335 type Event = Event;336 337 type Hash = Hash;338 339 type Hashing = BlakeTwo256;340 341 type Header = generic::Header<BlockNumber, BlakeTwo256>;342 343 type Index = Index;344 345 type Lookup = AccountIdLookup<AccountId, ()>;346 347 type OnKilledAccount = ();348 349 type OnNewAccount = ();350 type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode<Self>;351 352 type Origin = Origin;353 354 type PalletInfo = PalletInfo;355 356 type SS58Prefix = SS58Prefix;357 358 type SystemWeightInfo = frame_system::weights::SubstrateWeight<Self>;359 360 type Version = Version;361 type MaxConsumers = ConstU32<16>;362}363364parameter_types! {365 pub const MinimumPeriod: u64 = SLOT_DURATION / 2;366}367368impl pallet_timestamp::Config for Runtime {369 370 type Moment = u64;371 type OnTimestampSet = ();372 type MinimumPeriod = MinimumPeriod;373 type WeightInfo = ();374}375376parameter_types! {377 378 pub const ExistentialDeposit: u128 = 0;379 pub const MaxLocks: u32 = 50;380}381382impl pallet_balances::Config for Runtime {383 type MaxLocks = MaxLocks;384 type MaxReserves = ();385 type ReserveIdentifier = [u8; 8];386 387 type Balance = Balance;388 389 type Event = Event;390 type DustRemoval = Treasury;391 type ExistentialDeposit = ExistentialDeposit;392 type AccountStore = System;393 type WeightInfo = pallet_balances::weights::SubstrateWeight<Self>;394}395396pub const fn deposit(items: u32, bytes: u32) -> Balance {397 items as Balance * 15 * CENTIUNIQUE + (bytes as Balance) * 6 * CENTIUNIQUE398}399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450parameter_types! {451 452 453 pub const OperationalFeeMultiplier: u8 = 5;454}455456457pub struct LinearFee<T>(sp_std::marker::PhantomData<T>);458459impl<T> WeightToFeePolynomial for LinearFee<T>460where461 T: BaseArithmetic + From<u32> + Copy + Unsigned,462{463 type Balance = T;464465 fn polynomial() -> WeightToFeeCoefficients<Self::Balance> {466 smallvec!(WeightToFeeCoefficient {467 468 coeff_integer: WEIGHT_TO_FEE_COEFF.into(),469 coeff_frac: Perbill::zero(),470 negative: false,471 degree: 1,472 })473 }474}475476impl pallet_transaction_payment::Config for Runtime {477 type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter<Balances, DealWithFees>;478 type LengthToFee = ConstantMultiplier<Balance, TransactionByteFee>;479 type OperationalFeeMultiplier = OperationalFeeMultiplier;480 type WeightToFee = LinearFee<Balance>;481 type FeeMultiplierUpdate = ();482}483484parameter_types! {485 pub const ProposalBond: Permill = Permill::from_percent(5);486 pub const ProposalBondMinimum: Balance = 1 * UNIQUE;487 pub const ProposalBondMaximum: Balance = 1000 * UNIQUE;488 pub const SpendPeriod: BlockNumber = 5 * MINUTES;489 pub const Burn: Permill = Permill::from_percent(0);490 pub const TipCountdown: BlockNumber = 1 * DAYS;491 pub const TipFindersFee: Percent = Percent::from_percent(20);492 pub const TipReportDepositBase: Balance = 1 * UNIQUE;493 pub const DataDepositPerByte: Balance = 1 * CENTIUNIQUE;494 pub const BountyDepositBase: Balance = 1 * UNIQUE;495 pub const BountyDepositPayoutDelay: BlockNumber = 1 * DAYS;496 pub const TreasuryModuleId: PalletId = PalletId(*b"py/trsry");497 pub const BountyUpdatePeriod: BlockNumber = 14 * DAYS;498 pub const MaximumReasonLength: u32 = 16384;499 pub const BountyCuratorDeposit: Permill = Permill::from_percent(50);500 pub const BountyValueMinimum: Balance = 5 * UNIQUE;501 pub const MaxApprovals: u32 = 100;502}503504impl pallet_treasury::Config for Runtime {505 type PalletId = TreasuryModuleId;506 type Currency = Balances;507 type ApproveOrigin = EnsureRoot<AccountId>;508 type RejectOrigin = EnsureRoot<AccountId>;509 type Event = Event;510 type OnSlash = ();511 type ProposalBond = ProposalBond;512 type ProposalBondMinimum = ProposalBondMinimum;513 type ProposalBondMaximum = ProposalBondMaximum;514 type SpendPeriod = SpendPeriod;515 type Burn = Burn;516 type BurnDestination = ();517 type SpendFunds = ();518 type WeightInfo = pallet_treasury::weights::SubstrateWeight<Self>;519 type MaxApprovals = MaxApprovals;520}521522impl pallet_sudo::Config for Runtime {523 type Event = Event;524 type Call = Call;525}526527pub struct RelayChainBlockNumberProvider<T>(sp_std::marker::PhantomData<T>);528529impl<T: cumulus_pallet_parachain_system::Config> BlockNumberProvider530 for RelayChainBlockNumberProvider<T>531{532 type BlockNumber = BlockNumber;533534 fn current_block_number() -> Self::BlockNumber {535 cumulus_pallet_parachain_system::Pallet::<T>::validation_data()536 .map(|d| d.relay_parent_number)537 .unwrap_or_default()538 }539}540541parameter_types! {542 pub const MinVestedTransfer: Balance = 10 * UNIQUE;543 pub const MaxVestingSchedules: u32 = 28;544}545546impl orml_vesting::Config for Runtime {547 type Event = Event;548 type Currency = pallet_balances::Pallet<Runtime>;549 type MinVestedTransfer = MinVestedTransfer;550 type VestedTransferOrigin = EnsureSigned<AccountId>;551 type WeightInfo = ();552 type MaxVestingSchedules = MaxVestingSchedules;553 type BlockNumberProvider = RelayChainBlockNumberProvider<Runtime>;554}555556parameter_types! {557 pub const ReservedDmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;558 pub const ReservedXcmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;559}560561impl cumulus_pallet_parachain_system::Config for Runtime {562 type Event = Event;563 type SelfParaId = parachain_info::Pallet<Self>;564 type OnSystemEvent = ();565 566 567 568 569 570 type OutboundXcmpMessageSource = XcmpQueue;571 type DmpMessageHandler = DmpQueue;572 type ReservedDmpWeight = ReservedDmpWeight;573 type ReservedXcmpWeight = ReservedXcmpWeight;574 type XcmpMessageHandler = XcmpQueue;575}576577impl parachain_info::Config for Runtime {}578579impl cumulus_pallet_aura_ext::Config for Runtime {}580581parameter_types! {582 pub const RelayLocation: MultiLocation = MultiLocation::parent();583 pub const RelayNetwork: NetworkId = NetworkId::Polkadot;584 pub RelayOrigin: Origin = cumulus_pallet_xcm::Origin::Relay.into();585 pub Ancestry: MultiLocation = Parachain(ParachainInfo::parachain_id().into()).into();586}587588589590591pub type LocationToAccountId = (592 593 ParentIsPreset<AccountId>,594 595 SiblingParachainConvertsVia<Sibling, AccountId>,596 597 AccountId32Aliases<RelayNetwork, AccountId>,598);599600pub struct OnlySelfCurrency;601impl<B: TryFrom<u128>> MatchesFungible<B> for OnlySelfCurrency {602 fn matches_fungible(a: &MultiAsset) -> Option<B> {603 match (&a.id, &a.fun) {604 (Concrete(_), XcmFungible(ref amount)) => CheckedConversion::checked_from(*amount),605 _ => None,606 }607 }608}609610611pub type LocalAssetTransactor = CurrencyAdapter<612 613 Balances,614 615 OnlySelfCurrency,616 617 LocationToAccountId,618 619 AccountId,620 621 (),622>;623624625626627pub type XcmOriginToTransactDispatchOrigin = (628 629 630 631 SovereignSignedViaLocation<LocationToAccountId, Origin>,632 633 634 RelayChainAsNative<RelayOrigin, Origin>,635 636 637 SiblingParachainAsNative<cumulus_pallet_xcm::Origin, Origin>,638 639 640 ParentAsSuperuser<Origin>,641 642 643 SignedAccountId32AsNative<RelayNetwork, Origin>,644 645 XcmPassthrough<Origin>,646);647648parameter_types! {649 650 pub UnitWeightCost: Weight = 1_000_000;651 652 pub const WeightPrice: (MultiLocation, u128) = (MultiLocation::parent(), 1_200 * UNIQUE);653 pub const MaxInstructions: u32 = 100;654 pub const MaxAuthorities: u32 = 100_000;655}656657match_types! {658 pub type ParentOrParentsUnitPlurality: impl Contains<MultiLocation> = {659 MultiLocation { parents: 1, interior: Here } |660 MultiLocation { parents: 1, interior: X1(Plurality { id: BodyId::Unit, .. }) }661 };662}663664pub type Barrier = (665 TakeWeightCredit,666 AllowTopLevelPaidExecutionFrom<Everything>,667 AllowUnpaidExecutionFrom<ParentOrParentsUnitPlurality>,668 669);670671pub struct UsingOnlySelfCurrencyComponents<672 WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,673 AssetId: Get<MultiLocation>,674 AccountId,675 Currency: CurrencyT<AccountId>,676 OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,677>(678 Weight,679 Currency::Balance,680 PhantomData<(WeightToFee, AssetId, AccountId, Currency, OnUnbalanced)>,681);682impl<683 WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,684 AssetId: Get<MultiLocation>,685 AccountId,686 Currency: CurrencyT<AccountId>,687 OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,688 > WeightTrader689 for UsingOnlySelfCurrencyComponents<WeightToFee, AssetId, AccountId, Currency, OnUnbalanced>690{691 fn new() -> Self {692 Self(0, Zero::zero(), PhantomData)693 }694695 fn buy_weight(&mut self, weight: Weight, payment: Assets) -> Result<Assets, XcmError> {696 let amount = WeightToFee::calc(&weight);697 let u128_amount: u128 = amount.try_into().map_err(|_| XcmError::Overflow)?;698699 700 let option1: xcm::v1::AssetId = Concrete(MultiLocation {701 parents: 1,702 interior: X1(Parachain(ParachainInfo::parachain_id().into())),703 });704 705 let option2: xcm::v1::AssetId = Concrete(MultiLocation {706 parents: 0,707 interior: Here,708 });709710 let required = if payment.fungible.contains_key(&option1) {711 (option1, u128_amount).into()712 } else if payment.fungible.contains_key(&option2) {713 (option2, u128_amount).into()714 } else {715 (Concrete(MultiLocation::default()), u128_amount).into()716 };717718 let unused = payment719 .checked_sub(required)720 .map_err(|_| XcmError::TooExpensive)?;721 self.0 = self.0.saturating_add(weight);722 self.1 = self.1.saturating_add(amount);723 Ok(unused)724 }725726 fn refund_weight(&mut self, weight: Weight) -> Option<MultiAsset> {727 let weight = weight.min(self.0);728 let amount = WeightToFee::calc(&weight);729 self.0 -= weight;730 self.1 = self.1.saturating_sub(amount);731 let amount: u128 = amount.saturated_into();732 if amount > 0 {733 Some((AssetId::get(), amount).into())734 } else {735 None736 }737 }738}739impl<740 WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,741 AssetId: Get<MultiLocation>,742 AccountId,743 Currency: CurrencyT<AccountId>,744 OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,745 > Drop746 for UsingOnlySelfCurrencyComponents<WeightToFee, AssetId, AccountId, Currency, OnUnbalanced>747{748 fn drop(&mut self) {749 OnUnbalanced::on_unbalanced(Currency::issue(self.1));750 }751}752753pub struct XcmConfig;754impl Config for XcmConfig {755 type Call = Call;756 type XcmSender = XcmRouter;757 758 type AssetTransactor = LocalAssetTransactor;759 type OriginConverter = XcmOriginToTransactDispatchOrigin;760 type IsReserve = NativeAsset;761 type IsTeleporter = (); 762 type LocationInverter = LocationInverter<Ancestry>;763 type Barrier = Barrier;764 type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;765 type Trader = UsingOnlySelfCurrencyComponents<766 IdentityFee<Balance>,767 RelayLocation,768 AccountId,769 Balances,770 (),771 >;772 type ResponseHandler = (); 773 type SubscriptionService = PolkadotXcm;774775 type AssetTrap = PolkadotXcm;776 type AssetClaims = PolkadotXcm;777}778779780781782783784pub type LocalOriginToLocation = (SignedToAccountId32<Origin, AccountId, RelayNetwork>,);785786787788pub type XcmRouter = (789 790 cumulus_primitives_utility::ParentAsUmp<ParachainSystem, ()>,791 792 XcmpQueue,793);794795impl pallet_evm_coder_substrate::Config for Runtime {796 type GasWeightMapping = FixedGasWeightMapping;797}798799impl pallet_xcm::Config for Runtime {800 type Event = Event;801 type SendXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;802 type XcmRouter = XcmRouter;803 type ExecuteXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;804 type XcmExecuteFilter = Everything;805 type XcmExecutor = XcmExecutor<XcmConfig>;806 type XcmTeleportFilter = Everything;807 type XcmReserveTransferFilter = Everything;808 type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;809 type LocationInverter = LocationInverter<Ancestry>;810 type Origin = Origin;811 type Call = Call;812 const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;813 type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;814}815816impl cumulus_pallet_xcm::Config for Runtime {817 type Event = Event;818 type XcmExecutor = XcmExecutor<XcmConfig>;819}820821impl cumulus_pallet_xcmp_queue::Config for Runtime {822 type WeightInfo = ();823 type Event = Event;824 type XcmExecutor = XcmExecutor<XcmConfig>;825 type ChannelInfo = ParachainSystem;826 type VersionWrapper = ();827 type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;828 type ControllerOrigin = EnsureRoot<AccountId>;829 type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin;830}831832impl cumulus_pallet_dmp_queue::Config for Runtime {833 type Event = Event;834 type XcmExecutor = XcmExecutor<XcmConfig>;835 type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;836}837838impl pallet_aura::Config for Runtime {839 type AuthorityId = AuraId;840 type DisabledValidators = ();841 type MaxAuthorities = MaxAuthorities;842}843844parameter_types! {845 pub TreasuryAccountId: AccountId = TreasuryModuleId::get().into_account();846 pub const CollectionCreationPrice: Balance = 2 * UNIQUE;847}848849impl pallet_common::Config for Runtime {850 type Event = Event;851852 type Currency = Balances;853 type CollectionCreationPrice = CollectionCreationPrice;854 type TreasuryAccountId = TreasuryAccountId;855 type CollectionDispatch = CollectionDispatchT<Self>;856857 type EvmTokenAddressMapping = EvmTokenAddressMapping;858 type CrossTokenAddressMapping = CrossTokenAddressMapping<Self::AccountId>;859}860861impl pallet_structure::Config for Runtime {862 type Event = Event;863 type Call = Call;864 type WeightInfo = pallet_structure::weights::SubstrateWeight<Self>;865}866867impl pallet_evm::account::Config for Runtime {868 type CrossAccountId = pallet_evm::account::BasicCrossAccountId<Self>;869 type EvmAddressMapping = HashedAddressMapping<Self::Hashing>;870 type EvmBackwardsAddressMapping = fp_evm_mapping::MapBackwardsAddressTruncated;871}872873impl pallet_fungible::Config for Runtime {874 type WeightInfo = pallet_fungible::weights::SubstrateWeight<Self>;875}876impl pallet_refungible::Config for Runtime {877 type WeightInfo = pallet_refungible::weights::SubstrateWeight<Self>;878}879impl pallet_nonfungible::Config for Runtime {880 type WeightInfo = pallet_nonfungible::weights::SubstrateWeight<Self>;881}882883impl pallet_unique::Config for Runtime {884 type Event = Event;885 type WeightInfo = pallet_unique::weights::SubstrateWeight<Self>;886}887888parameter_types! {889 pub const InflationBlockInterval: BlockNumber = 100; 890}891892893impl pallet_inflation::Config for Runtime {894 type Currency = Balances;895 type TreasuryAccountId = TreasuryAccountId;896 type InflationBlockInterval = InflationBlockInterval;897 type BlockNumberProvider = RelayChainBlockNumberProvider<Runtime>;898}899900901902903904905906type EvmSponsorshipHandler = (907 pallet_unique::UniqueEthSponsorshipHandler<Runtime>,908 pallet_evm_contract_helpers::HelpersContractSponsoring<Runtime>,909);910type SponsorshipHandler = (911 pallet_unique::UniqueSponsorshipHandler<Runtime>,912 913 pallet_evm_transaction_payment::BridgeSponsorshipHandler<Runtime>,914);915916917918919920921922923924925926927928impl pallet_evm_transaction_payment::Config for Runtime {929 type EvmSponsorshipHandler = EvmSponsorshipHandler;930 type Currency = Balances;931}932933impl pallet_charge_transaction::Config for Runtime {934 type SponsorshipHandler = SponsorshipHandler;935}936937938939940941parameter_types! {942 943 pub const HelpersContractAddress: H160 = H160([944 0x84, 0x28, 0x99, 0xec, 0xf3, 0x80, 0x55, 0x3e, 0x8a, 0x4d, 0xe7, 0x5b, 0xf5, 0x34, 0xcd, 0xf6, 0xfb, 0xf6, 0x40, 0x49,945 ]);946}947948impl pallet_evm_contract_helpers::Config for Runtime {949 type ContractAddress = HelpersContractAddress;950 type DefaultSponsoringRateLimit = DefaultSponsoringRateLimit;951}952953construct_runtime!(954 pub enum Runtime where955 Block = Block,956 NodeBlock = opaque::Block,957 UncheckedExtrinsic = UncheckedExtrinsic958 {959 ParachainSystem: cumulus_pallet_parachain_system::{Pallet, Call, Config, Storage, Inherent, Event<T>, ValidateUnsigned} = 20,960 ParachainInfo: parachain_info::{Pallet, Storage, Config} = 21,961962 Aura: pallet_aura::{Pallet, Config<T>} = 22,963 AuraExt: cumulus_pallet_aura_ext::{Pallet, Config} = 23,964965 Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>} = 30,966 RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Pallet, Storage} = 31,967 Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent} = 32,968 TransactionPayment: pallet_transaction_payment::{Pallet, Storage} = 33,969 Treasury: pallet_treasury::{Pallet, Call, Storage, Config, Event<T>} = 34,970 Sudo: pallet_sudo::{Pallet, Call, Storage, Config<T>, Event<T>} = 35,971 System: frame_system::{Pallet, Call, Storage, Config, Event<T>} = 36,972 Vesting: orml_vesting::{Pallet, Storage, Call, Event<T>, Config<T>} = 37,973 974 975976 977 XcmpQueue: cumulus_pallet_xcmp_queue::{Pallet, Call, Storage, Event<T>} = 50,978 PolkadotXcm: pallet_xcm::{Pallet, Call, Event<T>, Origin} = 51,979 CumulusXcm: cumulus_pallet_xcm::{Pallet, Call, Event<T>, Origin} = 52,980 DmpQueue: cumulus_pallet_dmp_queue::{Pallet, Call, Storage, Event<T>} = 53,981982 983 Inflation: pallet_inflation::{Pallet, Call, Storage} = 60,984 Unique: pallet_unique::{Pallet, Call, Storage, Event<T>} = 61,985 986 987 Charging: pallet_charge_transaction::{Pallet, Call, Storage } = 64,988 989 Common: pallet_common::{Pallet, Storage, Event<T>} = 66,990 Fungible: pallet_fungible::{Pallet, Storage} = 67,991 Refungible: pallet_refungible::{Pallet, Storage} = 68,992 Nonfungible: pallet_nonfungible::{Pallet, Storage} = 69,993 Structure: pallet_structure::{Pallet, Call, Storage, Event<T>} = 70,994 RmrkCore: pallet_proxy_rmrk_core::{Pallet, Call, Storage, Event<T>} = 71,995996 997 EVM: pallet_evm::{Pallet, Config, Call, Storage, Event<T>} = 100,998 Ethereum: pallet_ethereum::{Pallet, Config, Call, Storage, Event, Origin} = 101,9991000 EvmCoderSubstrate: pallet_evm_coder_substrate::{Pallet, Storage} = 150,1001 EvmContractHelpers: pallet_evm_contract_helpers::{Pallet, Storage} = 151,1002 EvmTransactionPayment: pallet_evm_transaction_payment::{Pallet} = 152,1003 EvmMigration: pallet_evm_migration::{Pallet, Call, Storage} = 153,1004 }1005);10061007pub struct TransactionConverter;10081009impl fp_rpc::ConvertTransaction<UncheckedExtrinsic> for TransactionConverter {1010 fn convert_transaction(&self, transaction: pallet_ethereum::Transaction) -> UncheckedExtrinsic {1011 UncheckedExtrinsic::new_unsigned(1012 pallet_ethereum::Call::<Runtime>::transact { transaction }.into(),1013 )1014 }1015}10161017impl fp_rpc::ConvertTransaction<opaque::UncheckedExtrinsic> for TransactionConverter {1018 fn convert_transaction(1019 &self,1020 transaction: pallet_ethereum::Transaction,1021 ) -> opaque::UncheckedExtrinsic {1022 let extrinsic = UncheckedExtrinsic::new_unsigned(1023 pallet_ethereum::Call::<Runtime>::transact { transaction }.into(),1024 );1025 let encoded = extrinsic.encode();1026 opaque::UncheckedExtrinsic::decode(&mut &encoded[..])1027 .expect("Encoded extrinsic is always valid")1028 }1029}103010311032pub type Address = sp_runtime::MultiAddress<AccountId, ()>;10331034pub type Header = generic::Header<BlockNumber, BlakeTwo256>;10351036pub type Block = generic::Block<Header, UncheckedExtrinsic>;10371038pub type SignedBlock = generic::SignedBlock<Block>;10391040pub type BlockId = generic::BlockId<Block>;10411042pub type SignedExtra = (1043 frame_system::CheckSpecVersion<Runtime>,1044 1045 frame_system::CheckGenesis<Runtime>,1046 frame_system::CheckEra<Runtime>,1047 frame_system::CheckNonce<Runtime>,1048 frame_system::CheckWeight<Runtime>,1049 pallet_charge_transaction::ChargeTransactionPayment<Runtime>,1050 1051 pallet_ethereum::FakeTransactionFinalizer<Runtime>,1052);10531054pub type UncheckedExtrinsic =1055 fp_self_contained::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;10561057pub type CheckedExtrinsic = fp_self_contained::CheckedExtrinsic<AccountId, Call, SignedExtra, H160>;10581059pub type Executive = frame_executive::Executive<1060 Runtime,1061 Block,1062 frame_system::ChainContext<Runtime>,1063 Runtime,1064 AllPalletsReversedWithSystemFirst,1065>;10661067impl_opaque_keys! {1068 pub struct SessionKeys {1069 pub aura: Aura,1070 }1071}10721073impl fp_self_contained::SelfContainedCall for Call {1074 type SignedInfo = H160;10751076 fn is_self_contained(&self) -> bool {1077 match self {1078 Call::Ethereum(call) => call.is_self_contained(),1079 _ => false,1080 }1081 }10821083 fn check_self_contained(&self) -> Option<Result<Self::SignedInfo, TransactionValidityError>> {1084 match self {1085 Call::Ethereum(call) => call.check_self_contained(),1086 _ => None,1087 }1088 }10891090 fn validate_self_contained(&self, info: &Self::SignedInfo) -> Option<TransactionValidity> {1091 match self {1092 Call::Ethereum(call) => call.validate_self_contained(info),1093 _ => None,1094 }1095 }10961097 fn pre_dispatch_self_contained(1098 &self,1099 info: &Self::SignedInfo,1100 ) -> Option<Result<(), TransactionValidityError>> {1101 match self {1102 Call::Ethereum(call) => call.pre_dispatch_self_contained(info),1103 _ => None,1104 }1105 }11061107 fn apply_self_contained(1108 self,1109 info: Self::SignedInfo,1110 ) -> Option<sp_runtime::DispatchResultWithInfo<PostDispatchInfoOf<Self>>> {1111 match self {1112 call @ Call::Ethereum(pallet_ethereum::Call::transact { .. }) => Some(call.dispatch(1113 Origin::from(pallet_ethereum::RawOrigin::EthereumTransaction(info)),1114 )),1115 _ => None,1116 }1117 }1118}11191120macro_rules! dispatch_unique_runtime {1121 ($collection:ident.$method:ident($($name:ident),*)) => {{1122 let collection = <Runtime as pallet_common::Config>::CollectionDispatch::dispatch(<pallet_common::CollectionHandle<Runtime>>::try_get($collection)?);1123 let dispatch = collection.as_dyn();11241125 Ok::<_, DispatchError>(dispatch.$method($($name),*))1126 }};1127}11281129impl_common_runtime_apis!();11301131struct CheckInherents;11321133impl cumulus_pallet_parachain_system::CheckInherents<Block> for CheckInherents {1134 fn check_inherents(1135 block: &Block,1136 relay_state_proof: &cumulus_pallet_parachain_system::RelayChainStateProof,1137 ) -> sp_inherents::CheckInherentsResult {1138 let relay_chain_slot = relay_state_proof1139 .read_slot()1140 .expect("Could not read the relay chain slot from the proof");11411142 let inherent_data =1143 cumulus_primitives_timestamp::InherentDataProvider::from_relay_chain_slot_and_duration(1144 relay_chain_slot,1145 sp_std::time::Duration::from_secs(6),1146 )1147 .create_inherent_data()1148 .expect("Could not create the timestamp inherent data");11491150 inherent_data.check_extrinsics(block)1151 }1152}11531154cumulus_pallet_parachain_system::register_validate_block!(1155 Runtime = Runtime,1156 BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor::<Runtime, Executive>,1157 CheckInherents = CheckInherents,1158);