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 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 pallet_evm_collection::CollectionOnMethodCall<Self>,282 );283 type OnCreate = pallet_evm_contract_helpers::HelpersOnCreate<Self>;284 type ChainId = ChainId;285 type Runner = pallet_evm::runner::stack::Runner<Self>;286 type OnChargeTransaction = pallet_evm::EVMCurrencyAdapter<Balances, DealWithFees>;287 type TransactionValidityHack = pallet_evm_transaction_payment::TransactionValidityHack<Self>;288 type FindAuthor = EthereumFindAuthor<Aura>;289}290291impl pallet_evm_migration::Config for Runtime {292 type WeightInfo = pallet_evm_migration::weights::SubstrateWeight<Self>;293}294295pub struct EthereumFindAuthor<F>(core::marker::PhantomData<F>);296impl<F: FindAuthor<u32>> FindAuthor<H160> for EthereumFindAuthor<F> {297 fn find_author<'a, I>(digests: I) -> Option<H160>298 where299 I: 'a + IntoIterator<Item = (ConsensusEngineId, &'a [u8])>,300 {301 if let Some(author_index) = F::find_author(digests) {302 let authority_id = Aura::authorities()[author_index as usize].clone();303 return Some(H160::from_slice(&authority_id.to_raw_vec()[4..24]));304 }305 None306 }307}308309impl pallet_ethereum::Config for Runtime {310 type Event = Event;311 type StateRoot = pallet_ethereum::IntermediateStateRoot<Self>;312}313314impl pallet_randomness_collective_flip::Config for Runtime {}315316impl frame_system::Config for Runtime {317 318 type AccountData = pallet_balances::AccountData<Balance>;319 320 type AccountId = AccountId;321 322 type BaseCallFilter = Everything;323 324 type BlockHashCount = BlockHashCount;325 326 type BlockLength = RuntimeBlockLength;327 328 type BlockNumber = BlockNumber;329 330 type BlockWeights = RuntimeBlockWeights;331 332 type Call = Call;333 334 type DbWeight = RocksDbWeight;335 336 type Event = Event;337 338 type Hash = Hash;339 340 type Hashing = BlakeTwo256;341 342 type Header = generic::Header<BlockNumber, BlakeTwo256>;343 344 type Index = Index;345 346 type Lookup = AccountIdLookup<AccountId, ()>;347 348 type OnKilledAccount = ();349 350 type OnNewAccount = ();351 type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode<Self>;352 353 type Origin = Origin;354 355 type PalletInfo = PalletInfo;356 357 type SS58Prefix = SS58Prefix;358 359 type SystemWeightInfo = frame_system::weights::SubstrateWeight<Self>;360 361 type Version = Version;362 type MaxConsumers = ConstU32<16>;363}364365parameter_types! {366 pub const MinimumPeriod: u64 = SLOT_DURATION / 2;367}368369impl pallet_timestamp::Config for Runtime {370 371 type Moment = u64;372 type OnTimestampSet = ();373 type MinimumPeriod = MinimumPeriod;374 type WeightInfo = ();375}376377parameter_types! {378 379 pub const ExistentialDeposit: u128 = 0;380 pub const MaxLocks: u32 = 50;381}382383impl pallet_balances::Config for Runtime {384 type MaxLocks = MaxLocks;385 type MaxReserves = ();386 type ReserveIdentifier = [u8; 8];387 388 type Balance = Balance;389 390 type Event = Event;391 type DustRemoval = Treasury;392 type ExistentialDeposit = ExistentialDeposit;393 type AccountStore = System;394 type WeightInfo = pallet_balances::weights::SubstrateWeight<Self>;395}396397pub const fn deposit(items: u32, bytes: u32) -> Balance {398 items as Balance * 15 * CENTIUNIQUE + (bytes as Balance) * 6 * CENTIUNIQUE399}400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451parameter_types! {452 453 454 pub const OperationalFeeMultiplier: u8 = 5;455}456457458pub struct LinearFee<T>(sp_std::marker::PhantomData<T>);459460impl<T> WeightToFeePolynomial for LinearFee<T>461where462 T: BaseArithmetic + From<u32> + Copy + Unsigned,463{464 type Balance = T;465466 fn polynomial() -> WeightToFeeCoefficients<Self::Balance> {467 smallvec!(WeightToFeeCoefficient {468 469 coeff_integer: WEIGHT_TO_FEE_COEFF.into(),470 coeff_frac: Perbill::zero(),471 negative: false,472 degree: 1,473 })474 }475}476477impl pallet_transaction_payment::Config for Runtime {478 type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter<Balances, DealWithFees>;479 type LengthToFee = ConstantMultiplier<Balance, TransactionByteFee>;480 type OperationalFeeMultiplier = OperationalFeeMultiplier;481 type WeightToFee = LinearFee<Balance>;482 type FeeMultiplierUpdate = ();483}484485parameter_types! {486 pub const ProposalBond: Permill = Permill::from_percent(5);487 pub const ProposalBondMinimum: Balance = 1 * UNIQUE;488 pub const ProposalBondMaximum: Balance = 1000 * UNIQUE;489 pub const SpendPeriod: BlockNumber = 5 * MINUTES;490 pub const Burn: Permill = Permill::from_percent(0);491 pub const TipCountdown: BlockNumber = 1 * DAYS;492 pub const TipFindersFee: Percent = Percent::from_percent(20);493 pub const TipReportDepositBase: Balance = 1 * UNIQUE;494 pub const DataDepositPerByte: Balance = 1 * CENTIUNIQUE;495 pub const BountyDepositBase: Balance = 1 * UNIQUE;496 pub const BountyDepositPayoutDelay: BlockNumber = 1 * DAYS;497 pub const TreasuryModuleId: PalletId = PalletId(*b"py/trsry");498 pub const BountyUpdatePeriod: BlockNumber = 14 * DAYS;499 pub const MaximumReasonLength: u32 = 16384;500 pub const BountyCuratorDeposit: Permill = Permill::from_percent(50);501 pub const BountyValueMinimum: Balance = 5 * UNIQUE;502 pub const MaxApprovals: u32 = 100;503}504505impl pallet_treasury::Config for Runtime {506 type PalletId = TreasuryModuleId;507 type Currency = Balances;508 type ApproveOrigin = EnsureRoot<AccountId>;509 type RejectOrigin = EnsureRoot<AccountId>;510 type Event = Event;511 type OnSlash = ();512 type ProposalBond = ProposalBond;513 type ProposalBondMinimum = ProposalBondMinimum;514 type ProposalBondMaximum = ProposalBondMaximum;515 type SpendPeriod = SpendPeriod;516 type Burn = Burn;517 type BurnDestination = ();518 type SpendFunds = ();519 type WeightInfo = pallet_treasury::weights::SubstrateWeight<Self>;520 type MaxApprovals = MaxApprovals;521}522523impl pallet_sudo::Config for Runtime {524 type Event = Event;525 type Call = Call;526}527528pub struct RelayChainBlockNumberProvider<T>(sp_std::marker::PhantomData<T>);529530impl<T: cumulus_pallet_parachain_system::Config> BlockNumberProvider531 for RelayChainBlockNumberProvider<T>532{533 type BlockNumber = BlockNumber;534535 fn current_block_number() -> Self::BlockNumber {536 cumulus_pallet_parachain_system::Pallet::<T>::validation_data()537 .map(|d| d.relay_parent_number)538 .unwrap_or_default()539 }540}541542parameter_types! {543 pub const MinVestedTransfer: Balance = 10 * UNIQUE;544 pub const MaxVestingSchedules: u32 = 28;545}546547impl orml_vesting::Config for Runtime {548 type Event = Event;549 type Currency = pallet_balances::Pallet<Runtime>;550 type MinVestedTransfer = MinVestedTransfer;551 type VestedTransferOrigin = EnsureSigned<AccountId>;552 type WeightInfo = ();553 type MaxVestingSchedules = MaxVestingSchedules;554 type BlockNumberProvider = RelayChainBlockNumberProvider<Runtime>;555}556557parameter_types! {558 pub const ReservedDmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;559 pub const ReservedXcmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;560}561562impl cumulus_pallet_parachain_system::Config for Runtime {563 type Event = Event;564 type SelfParaId = parachain_info::Pallet<Self>;565 type OnSystemEvent = ();566 567 568 569 570 571 type OutboundXcmpMessageSource = XcmpQueue;572 type DmpMessageHandler = DmpQueue;573 type ReservedDmpWeight = ReservedDmpWeight;574 type ReservedXcmpWeight = ReservedXcmpWeight;575 type XcmpMessageHandler = XcmpQueue;576}577578impl parachain_info::Config for Runtime {}579580impl cumulus_pallet_aura_ext::Config for Runtime {}581582parameter_types! {583 pub const RelayLocation: MultiLocation = MultiLocation::parent();584 pub const RelayNetwork: NetworkId = NetworkId::Polkadot;585 pub RelayOrigin: Origin = cumulus_pallet_xcm::Origin::Relay.into();586 pub Ancestry: MultiLocation = Parachain(ParachainInfo::parachain_id().into()).into();587}588589590591592pub type LocationToAccountId = (593 594 ParentIsPreset<AccountId>,595 596 SiblingParachainConvertsVia<Sibling, AccountId>,597 598 AccountId32Aliases<RelayNetwork, AccountId>,599);600601pub struct OnlySelfCurrency;602impl<B: TryFrom<u128>> MatchesFungible<B> for OnlySelfCurrency {603 fn matches_fungible(a: &MultiAsset) -> Option<B> {604 match (&a.id, &a.fun) {605 (Concrete(_), XcmFungible(ref amount)) => CheckedConversion::checked_from(*amount),606 _ => None,607 }608 }609}610611612pub type LocalAssetTransactor = CurrencyAdapter<613 614 Balances,615 616 OnlySelfCurrency,617 618 LocationToAccountId,619 620 AccountId,621 622 (),623>;624625626627628pub type XcmOriginToTransactDispatchOrigin = (629 630 631 632 SovereignSignedViaLocation<LocationToAccountId, Origin>,633 634 635 RelayChainAsNative<RelayOrigin, Origin>,636 637 638 SiblingParachainAsNative<cumulus_pallet_xcm::Origin, Origin>,639 640 641 ParentAsSuperuser<Origin>,642 643 644 SignedAccountId32AsNative<RelayNetwork, Origin>,645 646 XcmPassthrough<Origin>,647);648649parameter_types! {650 651 pub UnitWeightCost: Weight = 1_000_000;652 653 pub const WeightPrice: (MultiLocation, u128) = (MultiLocation::parent(), 1_200 * UNIQUE);654 pub const MaxInstructions: u32 = 100;655 pub const MaxAuthorities: u32 = 100_000;656}657658match_types! {659 pub type ParentOrParentsUnitPlurality: impl Contains<MultiLocation> = {660 MultiLocation { parents: 1, interior: Here } |661 MultiLocation { parents: 1, interior: X1(Plurality { id: BodyId::Unit, .. }) }662 };663}664665pub type Barrier = (666 TakeWeightCredit,667 AllowTopLevelPaidExecutionFrom<Everything>,668 AllowUnpaidExecutionFrom<ParentOrParentsUnitPlurality>,669 670);671672pub struct UsingOnlySelfCurrencyComponents<673 WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,674 AssetId: Get<MultiLocation>,675 AccountId,676 Currency: CurrencyT<AccountId>,677 OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,678>(679 Weight,680 Currency::Balance,681 PhantomData<(WeightToFee, AssetId, AccountId, Currency, OnUnbalanced)>,682);683impl<684 WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,685 AssetId: Get<MultiLocation>,686 AccountId,687 Currency: CurrencyT<AccountId>,688 OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,689 > WeightTrader690 for UsingOnlySelfCurrencyComponents<WeightToFee, AssetId, AccountId, Currency, OnUnbalanced>691{692 fn new() -> Self {693 Self(0, Zero::zero(), PhantomData)694 }695696 fn buy_weight(&mut self, weight: Weight, payment: Assets) -> Result<Assets, XcmError> {697 let amount = WeightToFee::calc(&weight);698 let u128_amount: u128 = amount.try_into().map_err(|_| XcmError::Overflow)?;699700 701 let option1: xcm::v1::AssetId = Concrete(MultiLocation {702 parents: 1,703 interior: X1(Parachain(ParachainInfo::parachain_id().into())),704 });705 706 let option2: xcm::v1::AssetId = Concrete(MultiLocation {707 parents: 0,708 interior: Here,709 });710711 let required = if payment.fungible.contains_key(&option1) {712 (option1, u128_amount).into()713 } else if payment.fungible.contains_key(&option2) {714 (option2, u128_amount).into()715 } else {716 (Concrete(MultiLocation::default()), u128_amount).into()717 };718719 let unused = payment720 .checked_sub(required)721 .map_err(|_| XcmError::TooExpensive)?;722 self.0 = self.0.saturating_add(weight);723 self.1 = self.1.saturating_add(amount);724 Ok(unused)725 }726727 fn refund_weight(&mut self, weight: Weight) -> Option<MultiAsset> {728 let weight = weight.min(self.0);729 let amount = WeightToFee::calc(&weight);730 self.0 -= weight;731 self.1 = self.1.saturating_sub(amount);732 let amount: u128 = amount.saturated_into();733 if amount > 0 {734 Some((AssetId::get(), amount).into())735 } else {736 None737 }738 }739}740impl<741 WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,742 AssetId: Get<MultiLocation>,743 AccountId,744 Currency: CurrencyT<AccountId>,745 OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,746 > Drop747 for UsingOnlySelfCurrencyComponents<WeightToFee, AssetId, AccountId, Currency, OnUnbalanced>748{749 fn drop(&mut self) {750 OnUnbalanced::on_unbalanced(Currency::issue(self.1));751 }752}753754pub struct XcmConfig;755impl Config for XcmConfig {756 type Call = Call;757 type XcmSender = XcmRouter;758 759 type AssetTransactor = LocalAssetTransactor;760 type OriginConverter = XcmOriginToTransactDispatchOrigin;761 type IsReserve = NativeAsset;762 type IsTeleporter = (); 763 type LocationInverter = LocationInverter<Ancestry>;764 type Barrier = Barrier;765 type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;766 type Trader = UsingOnlySelfCurrencyComponents<767 IdentityFee<Balance>,768 RelayLocation,769 AccountId,770 Balances,771 (),772 >;773 type ResponseHandler = (); 774 type SubscriptionService = PolkadotXcm;775776 type AssetTrap = PolkadotXcm;777 type AssetClaims = PolkadotXcm;778}779780781782783784785pub type LocalOriginToLocation = (SignedToAccountId32<Origin, AccountId, RelayNetwork>,);786787788789pub type XcmRouter = (790 791 cumulus_primitives_utility::ParentAsUmp<ParachainSystem, ()>,792 793 XcmpQueue,794);795796impl pallet_evm_coder_substrate::Config for Runtime {797 type GasWeightMapping = FixedGasWeightMapping;798}799800impl pallet_xcm::Config for Runtime {801 type Event = Event;802 type SendXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;803 type XcmRouter = XcmRouter;804 type ExecuteXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;805 type XcmExecuteFilter = Everything;806 type XcmExecutor = XcmExecutor<XcmConfig>;807 type XcmTeleportFilter = Everything;808 type XcmReserveTransferFilter = Everything;809 type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;810 type LocationInverter = LocationInverter<Ancestry>;811 type Origin = Origin;812 type Call = Call;813 const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;814 type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;815}816817impl cumulus_pallet_xcm::Config for Runtime {818 type Event = Event;819 type XcmExecutor = XcmExecutor<XcmConfig>;820}821822impl cumulus_pallet_xcmp_queue::Config for Runtime {823 type WeightInfo = ();824 type Event = Event;825 type XcmExecutor = XcmExecutor<XcmConfig>;826 type ChannelInfo = ParachainSystem;827 type VersionWrapper = ();828 type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;829 type ControllerOrigin = EnsureRoot<AccountId>;830 type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin;831}832833impl cumulus_pallet_dmp_queue::Config for Runtime {834 type Event = Event;835 type XcmExecutor = XcmExecutor<XcmConfig>;836 type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;837}838839impl pallet_aura::Config for Runtime {840 type AuthorityId = AuraId;841 type DisabledValidators = ();842 type MaxAuthorities = MaxAuthorities;843}844845parameter_types! {846 pub TreasuryAccountId: AccountId = TreasuryModuleId::get().into_account();847 pub const CollectionCreationPrice: Balance = 2 * UNIQUE;848}849850impl pallet_common::Config for Runtime {851 type Event = Event;852853 type Currency = Balances;854 type CollectionCreationPrice = CollectionCreationPrice;855 type TreasuryAccountId = TreasuryAccountId;856 type CollectionDispatch = CollectionDispatchT<Self>;857858 type EvmTokenAddressMapping = EvmTokenAddressMapping;859 type CrossTokenAddressMapping = CrossTokenAddressMapping<Self::AccountId>;860}861862impl pallet_structure::Config for Runtime {863 type Event = Event;864 type Call = Call;865 type WeightInfo = pallet_structure::weights::SubstrateWeight<Self>;866}867868impl pallet_evm::account::Config for Runtime {869 type CrossAccountId = pallet_evm::account::BasicCrossAccountId<Self>;870 type EvmAddressMapping = HashedAddressMapping<Self::Hashing>;871 type EvmBackwardsAddressMapping = fp_evm_mapping::MapBackwardsAddressTruncated;872}873874impl pallet_fungible::Config for Runtime {875 type WeightInfo = pallet_fungible::weights::SubstrateWeight<Self>;876}877impl pallet_refungible::Config for Runtime {878 type WeightInfo = pallet_refungible::weights::SubstrateWeight<Self>;879}880impl pallet_nonfungible::Config for Runtime {881 type WeightInfo = pallet_nonfungible::weights::SubstrateWeight<Self>;882}883884impl pallet_proxy_rmrk_core::Config for Runtime {885 type Event = Event;886}887888impl pallet_proxy_rmrk_equip::Config for Runtime {889 type Event = Event;890}891892impl pallet_unique::Config for Runtime {893 type Event = Event;894 type WeightInfo = pallet_unique::weights::SubstrateWeight<Self>;895}896897parameter_types! {898 pub const InflationBlockInterval: BlockNumber = 100; 899}900901902impl pallet_inflation::Config for Runtime {903 type Currency = Balances;904 type TreasuryAccountId = TreasuryAccountId;905 type InflationBlockInterval = InflationBlockInterval;906 type BlockNumberProvider = RelayChainBlockNumberProvider<Runtime>;907}908909910911912913914915type EvmSponsorshipHandler = (916 pallet_unique::UniqueEthSponsorshipHandler<Runtime>,917 pallet_evm_contract_helpers::HelpersContractSponsoring<Runtime>,918);919type SponsorshipHandler = (920 pallet_unique::UniqueSponsorshipHandler<Runtime>,921 922 pallet_evm_transaction_payment::BridgeSponsorshipHandler<Runtime>,923);924925926927928929930931932933934935936937impl pallet_evm_transaction_payment::Config for Runtime {938 type EvmSponsorshipHandler = EvmSponsorshipHandler;939 type Currency = Balances;940}941942impl pallet_charge_transaction::Config for Runtime {943 type SponsorshipHandler = SponsorshipHandler;944}945946947948949950parameter_types! {951 952 pub const HelpersContractAddress: H160 = H160([953 0x84, 0x28, 0x99, 0xec, 0xf3, 0x80, 0x55, 0x3e, 0x8a, 0x4d, 0xe7, 0x5b, 0xf5, 0x34, 0xcd, 0xf6, 0xfb, 0xf6, 0x40, 0x49,954 ]);955 956 957 pub const EvmCollectionAddress: H160 = H160([958 0x6c, 0x4e, 0x9f, 0xe1, 0xae, 0x37, 0xa4, 0x1e, 0x93, 0xce, 0xe4, 0x29, 0xe8, 0xe1, 0x88, 0x1a, 0xbd, 0xcb, 0xb5, 0x4f,959 ]);960}961962impl pallet_evm_contract_helpers::Config for Runtime {963 type ContractAddress = HelpersContractAddress;964 type DefaultSponsoringRateLimit = DefaultSponsoringRateLimit;965}966967impl pallet_evm_collection::Config for Runtime {968 type ContractAddress = EvmCollectionAddress;969}970971construct_runtime!(972 pub enum Runtime where973 Block = Block,974 NodeBlock = opaque::Block,975 UncheckedExtrinsic = UncheckedExtrinsic976 {977 ParachainSystem: cumulus_pallet_parachain_system::{Pallet, Call, Config, Storage, Inherent, Event<T>, ValidateUnsigned} = 20,978 ParachainInfo: parachain_info::{Pallet, Storage, Config} = 21,979980 Aura: pallet_aura::{Pallet, Config<T>} = 22,981 AuraExt: cumulus_pallet_aura_ext::{Pallet, Config} = 23,982983 Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>} = 30,984 RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Pallet, Storage} = 31,985 Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent} = 32,986 TransactionPayment: pallet_transaction_payment::{Pallet, Storage} = 33,987 Treasury: pallet_treasury::{Pallet, Call, Storage, Config, Event<T>} = 34,988 Sudo: pallet_sudo::{Pallet, Call, Storage, Config<T>, Event<T>} = 35,989 System: frame_system::{Pallet, Call, Storage, Config, Event<T>} = 36,990 Vesting: orml_vesting::{Pallet, Storage, Call, Event<T>, Config<T>} = 37,991 992 993994 995 XcmpQueue: cumulus_pallet_xcmp_queue::{Pallet, Call, Storage, Event<T>} = 50,996 PolkadotXcm: pallet_xcm::{Pallet, Call, Event<T>, Origin} = 51,997 CumulusXcm: cumulus_pallet_xcm::{Pallet, Call, Event<T>, Origin} = 52,998 DmpQueue: cumulus_pallet_dmp_queue::{Pallet, Call, Storage, Event<T>} = 53,9991000 1001 Inflation: pallet_inflation::{Pallet, Call, Storage} = 60,1002 Unique: pallet_unique::{Pallet, Call, Storage, Event<T>} = 61,1003 1004 1005 Charging: pallet_charge_transaction::{Pallet, Call, Storage } = 64,1006 1007 Common: pallet_common::{Pallet, Storage, Event<T>} = 66,1008 Fungible: pallet_fungible::{Pallet, Storage} = 67,1009 Refungible: pallet_refungible::{Pallet, Storage} = 68,1010 Nonfungible: pallet_nonfungible::{Pallet, Storage} = 69,1011 Structure: pallet_structure::{Pallet, Call, Storage, Event<T>} = 70,1012 RmrkCore: pallet_proxy_rmrk_core::{Pallet, Call, Storage, Event<T>} = 71,1013 RmrkEquip: pallet_proxy_rmrk_equip::{Pallet, Call, Storage, Event<T>} = 72,10141015 1016 EVM: pallet_evm::{Pallet, Config, Call, Storage, Event<T>} = 100,1017 Ethereum: pallet_ethereum::{Pallet, Config, Call, Storage, Event, Origin} = 101,10181019 EvmCoderSubstrate: pallet_evm_coder_substrate::{Pallet, Storage} = 150,1020 EvmContractHelpers: pallet_evm_contract_helpers::{Pallet, Storage} = 151,1021 EvmTransactionPayment: pallet_evm_transaction_payment::{Pallet} = 152,1022 EvmMigration: pallet_evm_migration::{Pallet, Call, Storage} = 153,1023 EvmCollection: pallet_evm_collection::{Pallet} = 154,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);