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, OnMethodCall};83use pallet_unique::pallet_evm_collection;84use fp_rpc::TransactionStatus;85use sp_runtime::{86 traits::{BlockNumberProvider, Dispatchable, PostDispatchInfoOf, Saturating},87 transaction_validity::TransactionValidityError,88 SaturatedConversion,89};909192pub use sp_consensus_aura::sr25519::AuthorityId as AuraId;939495use pallet_xcm::XcmPassthrough;96use polkadot_parachain::primitives::Sibling;97use up_data_structs::mapping::{CrossTokenAddressMapping, EvmTokenAddressMapping};98use xcm::v1::{BodyId, Junction::*, MultiLocation, NetworkId, Junctions::*};99use xcm_builder::{100 AccountId32Aliases, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, CurrencyAdapter,101 EnsureXcmOrigin, FixedWeightBounds, LocationInverter, NativeAsset, ParentAsSuperuser,102 RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia,103 SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit,104 ParentIsPreset,105};106use xcm_executor::{Config, XcmExecutor, Assets};107use sp_std::{marker::PhantomData};108109use xcm::latest::{110 111 AssetId::{Concrete},112 Fungibility::Fungible as XcmFungible,113 MultiAsset,114 Error as XcmError,115};116use xcm_executor::traits::{MatchesFungible, WeightTrader};117118use sp_runtime::traits::CheckedConversion;119120use unique_runtime_common::{impl_common_runtime_apis, types::*, constants::*};121122pub const RUNTIME_NAME: &str = "quartz";123pub const TOKEN_SYMBOL: &str = "QTZ";124125type CrossAccountId = pallet_evm::account::BasicCrossAccountId<Runtime>;126127impl RuntimeInstance for Runtime {128 type CrossAccountId = self::CrossAccountId;129130 type TransactionConverter = self::TransactionConverter;131132 fn get_transaction_converter() -> TransactionConverter {133 TransactionConverter134 }135}136137138139140141pub mod opaque {142 use sp_std::prelude::*;143 use sp_runtime::impl_opaque_keys;144 use super::Aura;145146 pub use unique_runtime_common::types::*;147148 impl_opaque_keys! {149 pub struct SessionKeys {150 pub aura: Aura,151 }152 }153}154155156pub const VERSION: RuntimeVersion = RuntimeVersion {157 spec_name: create_runtime_str!(RUNTIME_NAME),158 impl_name: create_runtime_str!(RUNTIME_NAME),159 authoring_version: 1,160 spec_version: 920000,161 impl_version: 0,162 apis: RUNTIME_API_VERSIONS,163 transaction_version: 1,164 state_version: 0,165};166167#[derive(codec::Encode, codec::Decode)]168pub enum XCMPMessage<XAccountId, XBalance> {169 170 TransferToken(XAccountId, XBalance),171}172173174#[cfg(feature = "std")]175pub fn native_version() -> NativeVersion {176 NativeVersion {177 runtime_version: VERSION,178 can_author_with: Default::default(),179 }180}181182type NegativeImbalance = <Balances as Currency<AccountId>>::NegativeImbalance;183184pub struct DealWithFees;185impl OnUnbalanced<NegativeImbalance> for DealWithFees {186 fn on_unbalanceds<B>(mut fees_then_tips: impl Iterator<Item = NegativeImbalance>) {187 if let Some(fees) = fees_then_tips.next() {188 189 let mut split = fees.ration(100, 0);190 if let Some(tips) = fees_then_tips.next() {191 192 tips.ration_merge_into(100, 0, &mut split);193 }194 Treasury::on_unbalanced(split.0);195 196 }197 }198}199200parameter_types! {201 pub const BlockHashCount: BlockNumber = 2400;202 pub RuntimeBlockLength: BlockLength =203 BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);204 pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);205 pub const MaximumBlockLength: u32 = 5 * 1024 * 1024;206 pub RuntimeBlockWeights: BlockWeights = BlockWeights::builder()207 .base_block(BlockExecutionWeight::get())208 .for_class(DispatchClass::all(), |weights| {209 weights.base_extrinsic = ExtrinsicBaseWeight::get();210 })211 .for_class(DispatchClass::Normal, |weights| {212 weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT);213 })214 .for_class(DispatchClass::Operational, |weights| {215 weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT);216 217 218 weights.reserved = Some(219 MAXIMUM_BLOCK_WEIGHT - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT220 );221 })222 .avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO)223 .build_or_panic();224 pub const Version: RuntimeVersion = VERSION;225 pub const SS58Prefix: u8 = 255;226}227228parameter_types! {229 pub const ChainId: u64 = 8881;230}231232pub struct FixedFee;233impl FeeCalculator for FixedFee {234 fn min_gas_price() -> U256 {235 MIN_GAS_PRICE.into()236 }237}238239240241242parameter_types! {243 pub const WritesPerSecond: u64 = WEIGHT_PER_SECOND / <Runtime as frame_system::Config>::DbWeight::get().write;244 pub const GasPerSecond: u64 = WritesPerSecond::get() * 20000;245 pub const WeightPerGas: u64 = WEIGHT_PER_SECOND / GasPerSecond::get();246}247248249250251const EVM_DISPATCH_RATIO: Perbill = Perbill::from_percent(50);252parameter_types! {253 pub BlockGasLimit: U256 = U256::from(NORMAL_DISPATCH_RATIO * EVM_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT / WeightPerGas::get());254}255256pub enum FixedGasWeightMapping {}257impl GasWeightMapping for FixedGasWeightMapping {258 fn gas_to_weight(gas: u64) -> Weight {259 gas.saturating_mul(WeightPerGas::get())260 }261 fn weight_to_gas(weight: Weight) -> u64 {262 weight / WeightPerGas::get()263 }264}265266impl pallet_evm::Config for Runtime {267 type BlockGasLimit = BlockGasLimit;268 type FeeCalculator = FixedFee;269 type GasWeightMapping = FixedGasWeightMapping;270 type BlockHashMapping = pallet_ethereum::EthereumBlockHashMapping<Self>;271 type CallOrigin = EnsureAddressTruncated<Self>;272 type WithdrawOrigin = EnsureAddressTruncated<Self>;273 type AddressMapping = HashedAddressMapping<Self::Hashing>;274 type PrecompilesType = ();275 type PrecompilesValue = ();276 type Currency = Balances;277 type Event = Event;278 type OnMethodCall = (279 pallet_evm_migration::OnMethodCall<Self>,280 pallet_evm_contract_helpers::HelpersOnMethodCall<Self>,281 CollectionDispatchT<Self>,282 pallet_evm_collection::CollectionOnMethodCall<Self>,283 );284 type OnCreate = pallet_evm_contract_helpers::HelpersOnCreate<Self>;285 type ChainId = ChainId;286 type Runner = pallet_evm::runner::stack::Runner<Self>;287 type OnChargeTransaction = pallet_evm::EVMCurrencyAdapter<Balances, DealWithFees>;288 type TransactionValidityHack = pallet_evm_transaction_payment::TransactionValidityHack<Self>;289 type FindAuthor = EthereumFindAuthor<Aura>;290}291292impl pallet_evm_migration::Config for Runtime {293 type WeightInfo = pallet_evm_migration::weights::SubstrateWeight<Self>;294}295296pub struct EthereumFindAuthor<F>(core::marker::PhantomData<F>);297impl<F: FindAuthor<u32>> FindAuthor<H160> for EthereumFindAuthor<F> {298 fn find_author<'a, I>(digests: I) -> Option<H160>299 where300 I: 'a + IntoIterator<Item = (ConsensusEngineId, &'a [u8])>,301 {302 if let Some(author_index) = F::find_author(digests) {303 let authority_id = Aura::authorities()[author_index as usize].clone();304 return Some(H160::from_slice(&authority_id.to_raw_vec()[4..24]));305 }306 None307 }308}309310impl pallet_ethereum::Config for Runtime {311 type Event = Event;312 type StateRoot = pallet_ethereum::IntermediateStateRoot<Self>;313}314315impl pallet_randomness_collective_flip::Config for Runtime {}316317impl frame_system::Config for Runtime {318 319 type AccountData = pallet_balances::AccountData<Balance>;320 321 type AccountId = AccountId;322 323 type BaseCallFilter = Everything;324 325 type BlockHashCount = BlockHashCount;326 327 type BlockLength = RuntimeBlockLength;328 329 type BlockNumber = BlockNumber;330 331 type BlockWeights = RuntimeBlockWeights;332 333 type Call = Call;334 335 type DbWeight = RocksDbWeight;336 337 type Event = Event;338 339 type Hash = Hash;340 341 type Hashing = BlakeTwo256;342 343 type Header = generic::Header<BlockNumber, BlakeTwo256>;344 345 type Index = Index;346 347 type Lookup = AccountIdLookup<AccountId, ()>;348 349 type OnKilledAccount = ();350 351 type OnNewAccount = ();352 type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode<Self>;353 354 type Origin = Origin;355 356 type PalletInfo = PalletInfo;357 358 type SS58Prefix = SS58Prefix;359 360 type SystemWeightInfo = frame_system::weights::SubstrateWeight<Self>;361 362 type Version = Version;363 type MaxConsumers = ConstU32<16>;364}365366parameter_types! {367 pub const MinimumPeriod: u64 = SLOT_DURATION / 2;368}369370impl pallet_timestamp::Config for Runtime {371 372 type Moment = u64;373 type OnTimestampSet = ();374 type MinimumPeriod = MinimumPeriod;375 type WeightInfo = ();376}377378parameter_types! {379 380 pub const ExistentialDeposit: u128 = 0;381 pub const MaxLocks: u32 = 50;382}383384impl pallet_balances::Config for Runtime {385 type MaxLocks = MaxLocks;386 type MaxReserves = ();387 type ReserveIdentifier = [u8; 8];388 389 type Balance = Balance;390 391 type Event = Event;392 type DustRemoval = Treasury;393 type ExistentialDeposit = ExistentialDeposit;394 type AccountStore = System;395 type WeightInfo = pallet_balances::weights::SubstrateWeight<Self>;396}397398pub const fn deposit(items: u32, bytes: u32) -> Balance {399 items as Balance * 15 * CENTIUNIQUE + (bytes as Balance) * 6 * CENTIUNIQUE400}401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452parameter_types! {453 454 455 pub const OperationalFeeMultiplier: u8 = 5;456}457458459pub struct LinearFee<T>(sp_std::marker::PhantomData<T>);460461impl<T> WeightToFeePolynomial for LinearFee<T>462where463 T: BaseArithmetic + From<u32> + Copy + Unsigned,464{465 type Balance = T;466467 fn polynomial() -> WeightToFeeCoefficients<Self::Balance> {468 smallvec!(WeightToFeeCoefficient {469 470 coeff_integer: WEIGHT_TO_FEE_COEFF.into(),471 coeff_frac: Perbill::zero(),472 negative: false,473 degree: 1,474 })475 }476}477478impl pallet_transaction_payment::Config for Runtime {479 type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter<Balances, DealWithFees>;480 type LengthToFee = ConstantMultiplier<Balance, TransactionByteFee>;481 type OperationalFeeMultiplier = OperationalFeeMultiplier;482 type WeightToFee = LinearFee<Balance>;483 type FeeMultiplierUpdate = ();484}485486parameter_types! {487 pub const ProposalBond: Permill = Permill::from_percent(5);488 pub const ProposalBondMinimum: Balance = 1 * UNIQUE;489 pub const ProposalBondMaximum: Balance = 1000 * UNIQUE;490 pub const SpendPeriod: BlockNumber = 5 * MINUTES;491 pub const Burn: Permill = Permill::from_percent(0);492 pub const TipCountdown: BlockNumber = 1 * DAYS;493 pub const TipFindersFee: Percent = Percent::from_percent(20);494 pub const TipReportDepositBase: Balance = 1 * UNIQUE;495 pub const DataDepositPerByte: Balance = 1 * CENTIUNIQUE;496 pub const BountyDepositBase: Balance = 1 * UNIQUE;497 pub const BountyDepositPayoutDelay: BlockNumber = 1 * DAYS;498 pub const TreasuryModuleId: PalletId = PalletId(*b"py/trsry");499 pub const BountyUpdatePeriod: BlockNumber = 14 * DAYS;500 pub const MaximumReasonLength: u32 = 16384;501 pub const BountyCuratorDeposit: Permill = Permill::from_percent(50);502 pub const BountyValueMinimum: Balance = 5 * UNIQUE;503 pub const MaxApprovals: u32 = 100;504}505506impl pallet_treasury::Config for Runtime {507 type PalletId = TreasuryModuleId;508 type Currency = Balances;509 type ApproveOrigin = EnsureRoot<AccountId>;510 type RejectOrigin = EnsureRoot<AccountId>;511 type Event = Event;512 type OnSlash = ();513 type ProposalBond = ProposalBond;514 type ProposalBondMinimum = ProposalBondMinimum;515 type ProposalBondMaximum = ProposalBondMaximum;516 type SpendPeriod = SpendPeriod;517 type Burn = Burn;518 type BurnDestination = ();519 type SpendFunds = ();520 type WeightInfo = pallet_treasury::weights::SubstrateWeight<Self>;521 type MaxApprovals = MaxApprovals;522}523524impl pallet_sudo::Config for Runtime {525 type Event = Event;526 type Call = Call;527}528529pub struct RelayChainBlockNumberProvider<T>(sp_std::marker::PhantomData<T>);530531impl<T: cumulus_pallet_parachain_system::Config> BlockNumberProvider532 for RelayChainBlockNumberProvider<T>533{534 type BlockNumber = BlockNumber;535536 fn current_block_number() -> Self::BlockNumber {537 cumulus_pallet_parachain_system::Pallet::<T>::validation_data()538 .map(|d| d.relay_parent_number)539 .unwrap_or_default()540 }541}542543parameter_types! {544 pub const MinVestedTransfer: Balance = 10 * UNIQUE;545 pub const MaxVestingSchedules: u32 = 28;546}547548impl orml_vesting::Config for Runtime {549 type Event = Event;550 type Currency = pallet_balances::Pallet<Runtime>;551 type MinVestedTransfer = MinVestedTransfer;552 type VestedTransferOrigin = EnsureSigned<AccountId>;553 type WeightInfo = ();554 type MaxVestingSchedules = MaxVestingSchedules;555 type BlockNumberProvider = RelayChainBlockNumberProvider<Runtime>;556}557558parameter_types! {559 pub const ReservedDmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;560 pub const ReservedXcmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;561}562563impl cumulus_pallet_parachain_system::Config for Runtime {564 type Event = Event;565 type SelfParaId = parachain_info::Pallet<Self>;566 type OnSystemEvent = ();567 568 569 570 571 572 type OutboundXcmpMessageSource = XcmpQueue;573 type DmpMessageHandler = DmpQueue;574 type ReservedDmpWeight = ReservedDmpWeight;575 type ReservedXcmpWeight = ReservedXcmpWeight;576 type XcmpMessageHandler = XcmpQueue;577}578579impl parachain_info::Config for Runtime {}580581impl cumulus_pallet_aura_ext::Config for Runtime {}582583parameter_types! {584 pub const RelayLocation: MultiLocation = MultiLocation::parent();585 pub const RelayNetwork: NetworkId = NetworkId::Polkadot;586 pub RelayOrigin: Origin = cumulus_pallet_xcm::Origin::Relay.into();587 pub Ancestry: MultiLocation = Parachain(ParachainInfo::parachain_id().into()).into();588}589590591592593pub type LocationToAccountId = (594 595 ParentIsPreset<AccountId>,596 597 SiblingParachainConvertsVia<Sibling, AccountId>,598 599 AccountId32Aliases<RelayNetwork, AccountId>,600);601602pub struct OnlySelfCurrency;603impl<B: TryFrom<u128>> MatchesFungible<B> for OnlySelfCurrency {604 fn matches_fungible(a: &MultiAsset) -> Option<B> {605 match (&a.id, &a.fun) {606 (Concrete(_), XcmFungible(ref amount)) => CheckedConversion::checked_from(*amount),607 _ => None,608 }609 }610}611612613pub type LocalAssetTransactor = CurrencyAdapter<614 615 Balances,616 617 OnlySelfCurrency,618 619 LocationToAccountId,620 621 AccountId,622 623 (),624>;625626627628629pub type XcmOriginToTransactDispatchOrigin = (630 631 632 633 SovereignSignedViaLocation<LocationToAccountId, Origin>,634 635 636 RelayChainAsNative<RelayOrigin, Origin>,637 638 639 SiblingParachainAsNative<cumulus_pallet_xcm::Origin, Origin>,640 641 642 ParentAsSuperuser<Origin>,643 644 645 SignedAccountId32AsNative<RelayNetwork, Origin>,646 647 XcmPassthrough<Origin>,648);649650parameter_types! {651 652 pub UnitWeightCost: Weight = 1_000_000;653 654 pub const WeightPrice: (MultiLocation, u128) = (MultiLocation::parent(), 1_200 * UNIQUE);655 pub const MaxInstructions: u32 = 100;656 pub const MaxAuthorities: u32 = 100_000;657}658659match_types! {660 pub type ParentOrParentsUnitPlurality: impl Contains<MultiLocation> = {661 MultiLocation { parents: 1, interior: Here } |662 MultiLocation { parents: 1, interior: X1(Plurality { id: BodyId::Unit, .. }) }663 };664}665666pub type Barrier = (667 TakeWeightCredit,668 AllowTopLevelPaidExecutionFrom<Everything>,669 AllowUnpaidExecutionFrom<ParentOrParentsUnitPlurality>,670 671);672673pub struct UsingOnlySelfCurrencyComponents<674 WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,675 AssetId: Get<MultiLocation>,676 AccountId,677 Currency: CurrencyT<AccountId>,678 OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,679>(680 Weight,681 Currency::Balance,682 PhantomData<(WeightToFee, AssetId, AccountId, Currency, OnUnbalanced)>,683);684impl<685 WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,686 AssetId: Get<MultiLocation>,687 AccountId,688 Currency: CurrencyT<AccountId>,689 OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,690 > WeightTrader691 for UsingOnlySelfCurrencyComponents<WeightToFee, AssetId, AccountId, Currency, OnUnbalanced>692{693 fn new() -> Self {694 Self(0, Zero::zero(), PhantomData)695 }696697 fn buy_weight(&mut self, weight: Weight, payment: Assets) -> Result<Assets, XcmError> {698 let amount = WeightToFee::calc(&weight);699 let u128_amount: u128 = amount.try_into().map_err(|_| XcmError::Overflow)?;700701 702 let option1: xcm::v1::AssetId = Concrete(MultiLocation {703 parents: 1,704 interior: X1(Parachain(ParachainInfo::parachain_id().into())),705 });706 707 let option2: xcm::v1::AssetId = Concrete(MultiLocation {708 parents: 0,709 interior: Here,710 });711712 let required = if payment.fungible.contains_key(&option1) {713 (option1, u128_amount).into()714 } else if payment.fungible.contains_key(&option2) {715 (option2, u128_amount).into()716 } else {717 (Concrete(MultiLocation::default()), u128_amount).into()718 };719720 let unused = payment721 .checked_sub(required)722 .map_err(|_| XcmError::TooExpensive)?;723 self.0 = self.0.saturating_add(weight);724 self.1 = self.1.saturating_add(amount);725 Ok(unused)726 }727728 fn refund_weight(&mut self, weight: Weight) -> Option<MultiAsset> {729 let weight = weight.min(self.0);730 let amount = WeightToFee::calc(&weight);731 self.0 -= weight;732 self.1 = self.1.saturating_sub(amount);733 let amount: u128 = amount.saturated_into();734 if amount > 0 {735 Some((AssetId::get(), amount).into())736 } else {737 None738 }739 }740}741impl<742 WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,743 AssetId: Get<MultiLocation>,744 AccountId,745 Currency: CurrencyT<AccountId>,746 OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,747 > Drop748 for UsingOnlySelfCurrencyComponents<WeightToFee, AssetId, AccountId, Currency, OnUnbalanced>749{750 fn drop(&mut self) {751 OnUnbalanced::on_unbalanced(Currency::issue(self.1));752 }753}754755pub struct XcmConfig;756impl Config for XcmConfig {757 type Call = Call;758 type XcmSender = XcmRouter;759 760 type AssetTransactor = LocalAssetTransactor;761 type OriginConverter = XcmOriginToTransactDispatchOrigin;762 type IsReserve = NativeAsset;763 type IsTeleporter = (); 764 type LocationInverter = LocationInverter<Ancestry>;765 type Barrier = Barrier;766 type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;767 type Trader = UsingOnlySelfCurrencyComponents<768 IdentityFee<Balance>,769 RelayLocation,770 AccountId,771 Balances,772 (),773 >;774 type ResponseHandler = (); 775 type SubscriptionService = PolkadotXcm;776777 type AssetTrap = PolkadotXcm;778 type AssetClaims = PolkadotXcm;779}780781782783784785786pub type LocalOriginToLocation = (SignedToAccountId32<Origin, AccountId, RelayNetwork>,);787788789790pub type XcmRouter = (791 792 cumulus_primitives_utility::ParentAsUmp<ParachainSystem, ()>,793 794 XcmpQueue,795);796797impl pallet_evm_coder_substrate::Config for Runtime {798 type GasWeightMapping = FixedGasWeightMapping;799}800801impl pallet_xcm::Config for Runtime {802 type Event = Event;803 type SendXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;804 type XcmRouter = XcmRouter;805 type ExecuteXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;806 type XcmExecuteFilter = Everything;807 type XcmExecutor = XcmExecutor<XcmConfig>;808 type XcmTeleportFilter = Everything;809 type XcmReserveTransferFilter = Everything;810 type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;811 type LocationInverter = LocationInverter<Ancestry>;812 type Origin = Origin;813 type Call = Call;814 const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;815 type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;816}817818impl cumulus_pallet_xcm::Config for Runtime {819 type Event = Event;820 type XcmExecutor = XcmExecutor<XcmConfig>;821}822823impl cumulus_pallet_xcmp_queue::Config for Runtime {824 type WeightInfo = ();825 type Event = Event;826 type XcmExecutor = XcmExecutor<XcmConfig>;827 type ChannelInfo = ParachainSystem;828 type VersionWrapper = ();829 type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;830 type ControllerOrigin = EnsureRoot<AccountId>;831 type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin;832}833834impl cumulus_pallet_dmp_queue::Config for Runtime {835 type Event = Event;836 type XcmExecutor = XcmExecutor<XcmConfig>;837 type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;838}839840impl pallet_aura::Config for Runtime {841 type AuthorityId = AuraId;842 type DisabledValidators = ();843 type MaxAuthorities = MaxAuthorities;844}845846parameter_types! {847 pub TreasuryAccountId: AccountId = TreasuryModuleId::get().into_account();848 pub const CollectionCreationPrice: Balance = 2 * UNIQUE;849}850851impl pallet_common::Config for Runtime {852 type Event = Event;853854 type Currency = Balances;855 type CollectionCreationPrice = CollectionCreationPrice;856 type TreasuryAccountId = TreasuryAccountId;857 type CollectionDispatch = CollectionDispatchT<Self>;858859 type EvmTokenAddressMapping = EvmTokenAddressMapping;860 type CrossTokenAddressMapping = CrossTokenAddressMapping<Self::AccountId>;861}862863impl pallet_structure::Config for Runtime {864 type Event = Event;865 type Call = Call;866 type WeightInfo = pallet_structure::weights::SubstrateWeight<Self>;867}868869impl pallet_evm::account::Config for Runtime {870 type CrossAccountId = pallet_evm::account::BasicCrossAccountId<Self>;871 type EvmAddressMapping = HashedAddressMapping<Self::Hashing>;872 type EvmBackwardsAddressMapping = fp_evm_mapping::MapBackwardsAddressTruncated;873}874875impl pallet_fungible::Config for Runtime {876 type WeightInfo = pallet_fungible::weights::SubstrateWeight<Self>;877}878impl pallet_refungible::Config for Runtime {879 type WeightInfo = pallet_refungible::weights::SubstrateWeight<Self>;880}881impl pallet_nonfungible::Config for Runtime {882 type WeightInfo = pallet_nonfungible::weights::SubstrateWeight<Self>;883}884885impl pallet_proxy_rmrk_core::Config for Runtime {886 type Event = Event;887}888889impl pallet_proxy_rmrk_equip::Config for Runtime {890 type Event = Event;891}892893impl pallet_unique::Config for Runtime {894 type Event = Event;895 type WeightInfo = pallet_unique::weights::SubstrateWeight<Self>;896}897898parameter_types! {899 pub const InflationBlockInterval: BlockNumber = 100; 900}901902903impl pallet_inflation::Config for Runtime {904 type Currency = Balances;905 type TreasuryAccountId = TreasuryAccountId;906 type InflationBlockInterval = InflationBlockInterval;907 type BlockNumberProvider = RelayChainBlockNumberProvider<Runtime>;908}909910911912913914915916type EvmSponsorshipHandler = (917 pallet_unique::UniqueEthSponsorshipHandler<Runtime>,918 pallet_evm_contract_helpers::HelpersContractSponsoring<Runtime>,919);920type SponsorshipHandler = (921 pallet_unique::UniqueSponsorshipHandler<Runtime>,922 923 pallet_evm_transaction_payment::BridgeSponsorshipHandler<Runtime>,924);925926927928929930931932933934935936937938impl pallet_evm_transaction_payment::Config for Runtime {939 type EvmSponsorshipHandler = EvmSponsorshipHandler;940 type Currency = Balances;941}942943impl pallet_charge_transaction::Config for Runtime {944 type SponsorshipHandler = SponsorshipHandler;945}946947948949950951parameter_types! {952 953 pub const HelpersContractAddress: H160 = H160([954 0x84, 0x28, 0x99, 0xec, 0xf3, 0x80, 0x55, 0x3e, 0x8a, 0x4d, 0xe7, 0x5b, 0xf5, 0x34, 0xcd, 0xf6, 0xfb, 0xf6, 0x40, 0x49,955 ]);956 957 958 pub const EvmCollectionAddress: H160 = H160([959 0x6c, 0x4e, 0x9f, 0xe1, 0xae, 0x37, 0xa4, 0x1e, 0x93, 0xce, 0xe4, 0x29, 0xe8, 0xe1, 0x88, 0x1a, 0xbd, 0xcb, 0xb5, 0x4f,960 ]);961}962963impl pallet_evm_contract_helpers::Config for Runtime {964 type ContractAddress = HelpersContractAddress;965 type DefaultSponsoringRateLimit = DefaultSponsoringRateLimit;966}967968impl pallet_evm_collection::Config for Runtime {969 type ContractAddress = EvmCollectionAddress;970}971972construct_runtime!(973 pub enum Runtime where974 Block = Block,975 NodeBlock = opaque::Block,976 UncheckedExtrinsic = UncheckedExtrinsic977 {978 ParachainSystem: cumulus_pallet_parachain_system::{Pallet, Call, Config, Storage, Inherent, Event<T>, ValidateUnsigned} = 20,979 ParachainInfo: parachain_info::{Pallet, Storage, Config} = 21,980981 Aura: pallet_aura::{Pallet, Config<T>} = 22,982 AuraExt: cumulus_pallet_aura_ext::{Pallet, Config} = 23,983984 Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>} = 30,985 RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Pallet, Storage} = 31,986 Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent} = 32,987 TransactionPayment: pallet_transaction_payment::{Pallet, Storage} = 33,988 Treasury: pallet_treasury::{Pallet, Call, Storage, Config, Event<T>} = 34,989 Sudo: pallet_sudo::{Pallet, Call, Storage, Config<T>, Event<T>} = 35,990 System: frame_system::{Pallet, Call, Storage, Config, Event<T>} = 36,991 Vesting: orml_vesting::{Pallet, Storage, Call, Event<T>, Config<T>} = 37,992 993 994995 996 XcmpQueue: cumulus_pallet_xcmp_queue::{Pallet, Call, Storage, Event<T>} = 50,997 PolkadotXcm: pallet_xcm::{Pallet, Call, Event<T>, Origin} = 51,998 CumulusXcm: cumulus_pallet_xcm::{Pallet, Call, Event<T>, Origin} = 52,999 DmpQueue: cumulus_pallet_dmp_queue::{Pallet, Call, Storage, Event<T>} = 53,10001001 1002 Inflation: pallet_inflation::{Pallet, Call, Storage} = 60,1003 Unique: pallet_unique::{Pallet, Call, Storage, Event<T>} = 61,1004 1005 1006 Charging: pallet_charge_transaction::{Pallet, Call, Storage } = 64,1007 1008 Common: pallet_common::{Pallet, Storage, Event<T>} = 66,1009 Fungible: pallet_fungible::{Pallet, Storage} = 67,1010 Refungible: pallet_refungible::{Pallet, Storage} = 68,1011 Nonfungible: pallet_nonfungible::{Pallet, Storage} = 69,1012 Structure: pallet_structure::{Pallet, Call, Storage, Event<T>} = 70,1013 RmrkCore: pallet_proxy_rmrk_core::{Pallet, Call, Storage, Event<T>} = 71,1014 RmrkEquip: pallet_proxy_rmrk_equip::{Pallet, Call, Storage, Event<T>} = 72,10151016 1017 EVM: pallet_evm::{Pallet, Config, Call, Storage, Event<T>} = 100,1018 Ethereum: pallet_ethereum::{Pallet, Config, Call, Storage, Event, Origin} = 101,10191020 EvmCoderSubstrate: pallet_evm_coder_substrate::{Pallet, Storage} = 150,1021 EvmContractHelpers: pallet_evm_contract_helpers::{Pallet, Storage} = 151,1022 EvmTransactionPayment: pallet_evm_transaction_payment::{Pallet} = 152,1023 EvmMigration: pallet_evm_migration::{Pallet, Call, Storage} = 153,1024 }1025);10261027pub struct TransactionConverter;10281029impl fp_rpc::ConvertTransaction<UncheckedExtrinsic> for TransactionConverter {1030 fn convert_transaction(&self, transaction: pallet_ethereum::Transaction) -> UncheckedExtrinsic {1031 UncheckedExtrinsic::new_unsigned(1032 pallet_ethereum::Call::<Runtime>::transact { transaction }.into(),1033 )1034 }1035}10361037impl fp_rpc::ConvertTransaction<opaque::UncheckedExtrinsic> for TransactionConverter {1038 fn convert_transaction(1039 &self,1040 transaction: pallet_ethereum::Transaction,1041 ) -> opaque::UncheckedExtrinsic {1042 let extrinsic = UncheckedExtrinsic::new_unsigned(1043 pallet_ethereum::Call::<Runtime>::transact { transaction }.into(),1044 );1045 let encoded = extrinsic.encode();1046 opaque::UncheckedExtrinsic::decode(&mut &encoded[..])1047 .expect("Encoded extrinsic is always valid")1048 }1049}105010511052pub type Address = sp_runtime::MultiAddress<AccountId, ()>;10531054pub type Header = generic::Header<BlockNumber, BlakeTwo256>;10551056pub type Block = generic::Block<Header, UncheckedExtrinsic>;10571058pub type SignedBlock = generic::SignedBlock<Block>;10591060pub type BlockId = generic::BlockId<Block>;10611062pub type SignedExtra = (1063 frame_system::CheckSpecVersion<Runtime>,1064 1065 frame_system::CheckGenesis<Runtime>,1066 frame_system::CheckEra<Runtime>,1067 frame_system::CheckNonce<Runtime>,1068 frame_system::CheckWeight<Runtime>,1069 pallet_charge_transaction::ChargeTransactionPayment<Runtime>,1070 1071 pallet_ethereum::FakeTransactionFinalizer<Runtime>,1072);10731074pub type UncheckedExtrinsic =1075 fp_self_contained::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;10761077pub type CheckedExtrinsic = fp_self_contained::CheckedExtrinsic<AccountId, Call, SignedExtra, H160>;10781079pub type Executive = frame_executive::Executive<1080 Runtime,1081 Block,1082 frame_system::ChainContext<Runtime>,1083 Runtime,1084 AllPalletsReversedWithSystemFirst,1085>;10861087impl_opaque_keys! {1088 pub struct SessionKeys {1089 pub aura: Aura,1090 }1091}10921093impl fp_self_contained::SelfContainedCall for Call {1094 type SignedInfo = H160;10951096 fn is_self_contained(&self) -> bool {1097 match self {1098 Call::Ethereum(call) => call.is_self_contained(),1099 _ => false,1100 }1101 }11021103 fn check_self_contained(&self) -> Option<Result<Self::SignedInfo, TransactionValidityError>> {1104 match self {1105 Call::Ethereum(call) => call.check_self_contained(),1106 _ => None,1107 }1108 }11091110 fn validate_self_contained(&self, info: &Self::SignedInfo) -> Option<TransactionValidity> {1111 match self {1112 Call::Ethereum(call) => call.validate_self_contained(info),1113 _ => None,1114 }1115 }11161117 fn pre_dispatch_self_contained(1118 &self,1119 info: &Self::SignedInfo,1120 ) -> Option<Result<(), TransactionValidityError>> {1121 match self {1122 Call::Ethereum(call) => call.pre_dispatch_self_contained(info),1123 _ => None,1124 }1125 }11261127 fn apply_self_contained(1128 self,1129 info: Self::SignedInfo,1130 ) -> Option<sp_runtime::DispatchResultWithInfo<PostDispatchInfoOf<Self>>> {1131 match self {1132 call @ Call::Ethereum(pallet_ethereum::Call::transact { .. }) => Some(call.dispatch(1133 Origin::from(pallet_ethereum::RawOrigin::EthereumTransaction(info)),1134 )),1135 _ => None,1136 }1137 }1138}11391140macro_rules! dispatch_unique_runtime {1141 ($collection:ident.$method:ident($($name:ident),*)) => {{1142 let collection = <Runtime as pallet_common::Config>::CollectionDispatch::dispatch(<pallet_common::CollectionHandle<Runtime>>::try_get($collection)?);1143 let dispatch = collection.as_dyn();11441145 Ok::<_, DispatchError>(dispatch.$method($($name),*))1146 }};1147}11481149impl_common_runtime_apis!();11501151struct CheckInherents;11521153impl cumulus_pallet_parachain_system::CheckInherents<Block> for CheckInherents {1154 fn check_inherents(1155 block: &Block,1156 relay_state_proof: &cumulus_pallet_parachain_system::RelayChainStateProof,1157 ) -> sp_inherents::CheckInherentsResult {1158 let relay_chain_slot = relay_state_proof1159 .read_slot()1160 .expect("Could not read the relay chain slot from the proof");11611162 let inherent_data =1163 cumulus_primitives_timestamp::InherentDataProvider::from_relay_chain_slot_and_duration(1164 relay_chain_slot,1165 sp_std::time::Duration::from_secs(6),1166 )1167 .create_inherent_data()1168 .expect("Could not create the timestamp inherent data");11691170 inherent_data.check_extrinsics(block)1171 }1172}11731174cumulus_pallet_parachain_system::register_validate_block!(1175 Runtime = Runtime,1176 BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor::<Runtime, Executive>,1177 CheckInherents = CheckInherents,1178);