12345678910111213141516171819#![cfg_attr(not(feature = "std"), no_std)]2021#![recursion_limit = "1024"]22#![allow(clippy::from_over_into, clippy::identity_op)]23#![allow(clippy::fn_to_numeric_cast_with_truncation)]2425#[cfg(feature = "std")]26include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));2728use sp_api::impl_runtime_apis;29use sp_core::{crypto::KeyTypeId, OpaqueMetadata, H256, U256, H160};30use sp_runtime::DispatchError;31323334use sp_runtime::{35 Permill, Perbill, Percent, create_runtime_str, generic, impl_opaque_keys,36 traits::{AccountIdLookup, BlakeTwo256, Block as BlockT, AccountIdConversion, Zero},37 transaction_validity::{TransactionSource, TransactionValidity},38 ApplyExtrinsicResult, RuntimeAppPublic,39};4041use sp_std::prelude::*;4243#[cfg(feature = "std")]44use sp_version::NativeVersion;45use sp_version::RuntimeVersion;46pub use pallet_transaction_payment::{47 Multiplier, TargetedFeeAdjustment, FeeDetails, RuntimeDispatchInfo,48};4950pub use pallet_balances::Call as BalancesCall;51pub use pallet_evm::{52 EnsureAddressTruncated, HashedAddressMapping, Runner, account::CrossAccountId as _,53};54pub use frame_support::{55 construct_runtime, match_types,56 dispatch::DispatchResult,57 PalletId, parameter_types, StorageValue, ConsensusEngineId,58 traits::{59 tokens::currency::Currency as CurrencyT, OnUnbalanced as OnUnbalancedT, Everything,60 Currency, ExistenceRequirement, Get, IsInVec, KeyOwnerProofSystem, LockIdentifier,61 OnUnbalanced, Randomness, FindAuthor, ConstU32, Imbalance,62 },63 weights::{64 constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND},65 DispatchClass, DispatchInfo, GetDispatchInfo, IdentityFee, Pays, PostDispatchInfo, Weight,66 WeightToFeePolynomial, WeightToFeeCoefficient, WeightToFeeCoefficients, ConstantMultiplier,67 },68};69use up_data_structs::*;707172use frame_system::{73 self as frame_system, EnsureRoot, EnsureSigned,74 limits::{BlockWeights, BlockLength},75};76use sp_arithmetic::{77 traits::{BaseArithmetic, Unsigned},78};79use smallvec::smallvec;80use codec::{Encode, Decode};81use pallet_unique::eth::evm_collection;82use pallet_evm::{Account as EVMAccount, FeeCalculator, GasWeightMapping};83use fp_rpc::TransactionStatus;84use sp_runtime::{85 traits::{BlockNumberProvider, Dispatchable, PostDispatchInfoOf, Saturating},86 transaction_validity::TransactionValidityError,87 SaturatedConversion,88};899091pub use sp_consensus_aura::sr25519::AuthorityId as AuraId;929394use pallet_xcm::XcmPassthrough;95use polkadot_parachain::primitives::Sibling;96use up_data_structs::mapping::{CrossTokenAddressMapping, EvmTokenAddressMapping};97use xcm::v1::{BodyId, Junction::*, MultiLocation, NetworkId, Junctions::*};98use xcm_builder::{99 AccountId32Aliases, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, CurrencyAdapter,100 EnsureXcmOrigin, FixedWeightBounds, LocationInverter, NativeAsset, ParentAsSuperuser,101 RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia,102 SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit,103 ParentIsPreset,104};105use xcm_executor::{Config, XcmExecutor, Assets};106use sp_std::{marker::PhantomData};107108use xcm::latest::{109 110 AssetId::{Concrete},111 Fungibility::Fungible as XcmFungible,112 MultiAsset,113 Error as XcmError,114};115use xcm_executor::traits::{MatchesFungible, WeightTrader};116117use sp_runtime::traits::CheckedConversion;118119use unique_runtime_common::{120 impl_common_runtime_apis,121 types::*,122 constants::*,123 dispatch::{CollectionDispatchT, CollectionDispatch},124 sponsoring::UniqueSponsorshipHandler,125 eth_sponsoring::UniqueEthSponsorshipHandler,126 weights::CommonWeights,127};128129pub const RUNTIME_NAME: &str = "quartz";130pub const TOKEN_SYMBOL: &str = "QTZ";131132type CrossAccountId = pallet_evm::account::BasicCrossAccountId<Runtime>;133134impl RuntimeInstance for Runtime {135 type CrossAccountId = self::CrossAccountId;136137 type TransactionConverter = self::TransactionConverter;138139 fn get_transaction_converter() -> TransactionConverter {140 TransactionConverter141 }142}143144145146147148pub mod opaque {149 use sp_std::prelude::*;150 use sp_runtime::impl_opaque_keys;151 use super::Aura;152153 pub use unique_runtime_common::types::*;154155 impl_opaque_keys! {156 pub struct SessionKeys {157 pub aura: Aura,158 }159 }160}161162163pub const VERSION: RuntimeVersion = RuntimeVersion {164 spec_name: create_runtime_str!(RUNTIME_NAME),165 impl_name: create_runtime_str!(RUNTIME_NAME),166 authoring_version: 1,167 spec_version: 920000,168 impl_version: 0,169 apis: RUNTIME_API_VERSIONS,170 transaction_version: 1,171 state_version: 0,172};173174#[derive(codec::Encode, codec::Decode)]175pub enum XCMPMessage<XAccountId, XBalance> {176 177 TransferToken(XAccountId, XBalance),178}179180181#[cfg(feature = "std")]182pub fn native_version() -> NativeVersion {183 NativeVersion {184 runtime_version: VERSION,185 can_author_with: Default::default(),186 }187}188189type NegativeImbalance = <Balances as Currency<AccountId>>::NegativeImbalance;190191pub struct DealWithFees;192impl OnUnbalanced<NegativeImbalance> for DealWithFees {193 fn on_unbalanceds<B>(mut fees_then_tips: impl Iterator<Item = NegativeImbalance>) {194 if let Some(fees) = fees_then_tips.next() {195 196 let mut split = fees.ration(100, 0);197 if let Some(tips) = fees_then_tips.next() {198 199 tips.ration_merge_into(100, 0, &mut split);200 }201 Treasury::on_unbalanced(split.0);202 203 }204 }205}206207parameter_types! {208 pub const BlockHashCount: BlockNumber = 2400;209 pub RuntimeBlockLength: BlockLength =210 BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);211 pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);212 pub const MaximumBlockLength: u32 = 5 * 1024 * 1024;213 pub RuntimeBlockWeights: BlockWeights = BlockWeights::builder()214 .base_block(BlockExecutionWeight::get())215 .for_class(DispatchClass::all(), |weights| {216 weights.base_extrinsic = ExtrinsicBaseWeight::get();217 })218 .for_class(DispatchClass::Normal, |weights| {219 weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT);220 })221 .for_class(DispatchClass::Operational, |weights| {222 weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT);223 224 225 weights.reserved = Some(226 MAXIMUM_BLOCK_WEIGHT - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT227 );228 })229 .avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO)230 .build_or_panic();231 pub const Version: RuntimeVersion = VERSION;232 pub const SS58Prefix: u8 = 255;233}234235parameter_types! {236 pub const ChainId: u64 = 8881;237}238239pub struct FixedFee;240impl FeeCalculator for FixedFee {241 fn min_gas_price() -> U256 {242 MIN_GAS_PRICE.into()243 }244}245246247248249parameter_types! {250 pub const WritesPerSecond: u64 = WEIGHT_PER_SECOND / <Runtime as frame_system::Config>::DbWeight::get().write;251 pub const GasPerSecond: u64 = WritesPerSecond::get() * 20000;252 pub const WeightPerGas: u64 = WEIGHT_PER_SECOND / GasPerSecond::get();253}254255256257258const EVM_DISPATCH_RATIO: Perbill = Perbill::from_percent(50);259parameter_types! {260 pub BlockGasLimit: U256 = U256::from(NORMAL_DISPATCH_RATIO * EVM_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT / WeightPerGas::get());261}262263pub enum FixedGasWeightMapping {}264impl GasWeightMapping for FixedGasWeightMapping {265 fn gas_to_weight(gas: u64) -> Weight {266 gas.saturating_mul(WeightPerGas::get())267 }268 fn weight_to_gas(weight: Weight) -> u64 {269 weight / WeightPerGas::get()270 }271}272273impl pallet_evm::Config for Runtime {274 type BlockGasLimit = BlockGasLimit;275 type FeeCalculator = FixedFee;276 type GasWeightMapping = FixedGasWeightMapping;277 type BlockHashMapping = pallet_ethereum::EthereumBlockHashMapping<Self>;278 type CallOrigin = EnsureAddressTruncated<Self>;279 type WithdrawOrigin = EnsureAddressTruncated<Self>;280 type AddressMapping = HashedAddressMapping<Self::Hashing>;281 type PrecompilesType = ();282 type PrecompilesValue = ();283 type Currency = Balances;284 type Event = Event;285 type OnMethodCall = (286 pallet_evm_migration::OnMethodCall<Self>,287 pallet_evm_contract_helpers::HelpersOnMethodCall<Self>,288 CollectionDispatchT<Self>,289 evm_collection::CollectionHelperOnMethodCall<Self>,290 );291 type OnCreate = pallet_evm_contract_helpers::HelpersOnCreate<Self>;292 type ChainId = ChainId;293 type Runner = pallet_evm::runner::stack::Runner<Self>;294 type OnChargeTransaction = pallet_evm::EVMCurrencyAdapter<Balances, DealWithFees>;295 type TransactionValidityHack = pallet_evm_transaction_payment::TransactionValidityHack<Self>;296 type FindAuthor = EthereumFindAuthor<Aura>;297}298299impl pallet_evm_migration::Config for Runtime {300 type WeightInfo = pallet_evm_migration::weights::SubstrateWeight<Self>;301}302303pub struct EthereumFindAuthor<F>(core::marker::PhantomData<F>);304impl<F: FindAuthor<u32>> FindAuthor<H160> for EthereumFindAuthor<F> {305 fn find_author<'a, I>(digests: I) -> Option<H160>306 where307 I: 'a + IntoIterator<Item = (ConsensusEngineId, &'a [u8])>,308 {309 if let Some(author_index) = F::find_author(digests) {310 let authority_id = Aura::authorities()[author_index as usize].clone();311 return Some(H160::from_slice(&authority_id.to_raw_vec()[4..24]));312 }313 None314 }315}316317impl pallet_ethereum::Config for Runtime {318 type Event = Event;319 type StateRoot = pallet_ethereum::IntermediateStateRoot<Self>;320}321322impl pallet_randomness_collective_flip::Config for Runtime {}323324impl frame_system::Config for Runtime {325 326 type AccountData = pallet_balances::AccountData<Balance>;327 328 type AccountId = AccountId;329 330 type BaseCallFilter = Everything;331 332 type BlockHashCount = BlockHashCount;333 334 type BlockLength = RuntimeBlockLength;335 336 type BlockNumber = BlockNumber;337 338 type BlockWeights = RuntimeBlockWeights;339 340 type Call = Call;341 342 type DbWeight = RocksDbWeight;343 344 type Event = Event;345 346 type Hash = Hash;347 348 type Hashing = BlakeTwo256;349 350 type Header = generic::Header<BlockNumber, BlakeTwo256>;351 352 type Index = Index;353 354 type Lookup = AccountIdLookup<AccountId, ()>;355 356 type OnKilledAccount = ();357 358 type OnNewAccount = ();359 type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode<Self>;360 361 type Origin = Origin;362 363 type PalletInfo = PalletInfo;364 365 type SS58Prefix = SS58Prefix;366 367 type SystemWeightInfo = frame_system::weights::SubstrateWeight<Self>;368 369 type Version = Version;370 type MaxConsumers = ConstU32<16>;371}372373parameter_types! {374 pub const MinimumPeriod: u64 = SLOT_DURATION / 2;375}376377impl pallet_timestamp::Config for Runtime {378 379 type Moment = u64;380 type OnTimestampSet = ();381 type MinimumPeriod = MinimumPeriod;382 type WeightInfo = ();383}384385parameter_types! {386 387 pub const ExistentialDeposit: u128 = 0;388 pub const MaxLocks: u32 = 50;389}390391impl pallet_balances::Config for Runtime {392 type MaxLocks = MaxLocks;393 type MaxReserves = ();394 type ReserveIdentifier = [u8; 8];395 396 type Balance = Balance;397 398 type Event = Event;399 type DustRemoval = Treasury;400 type ExistentialDeposit = ExistentialDeposit;401 type AccountStore = System;402 type WeightInfo = pallet_balances::weights::SubstrateWeight<Self>;403}404405pub const fn deposit(items: u32, bytes: u32) -> Balance {406 items as Balance * 15 * CENTIUNIQUE + (bytes as Balance) * 6 * CENTIUNIQUE407}408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459parameter_types! {460 461 462 pub const OperationalFeeMultiplier: u8 = 5;463}464465466pub struct LinearFee<T>(sp_std::marker::PhantomData<T>);467468impl<T> WeightToFeePolynomial for LinearFee<T>469where470 T: BaseArithmetic + From<u32> + Copy + Unsigned,471{472 type Balance = T;473474 fn polynomial() -> WeightToFeeCoefficients<Self::Balance> {475 smallvec!(WeightToFeeCoefficient {476 477 coeff_integer: WEIGHT_TO_FEE_COEFF.into(),478 coeff_frac: Perbill::zero(),479 negative: false,480 degree: 1,481 })482 }483}484485impl pallet_transaction_payment::Config for Runtime {486 type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter<Balances, DealWithFees>;487 type LengthToFee = ConstantMultiplier<Balance, TransactionByteFee>;488 type OperationalFeeMultiplier = OperationalFeeMultiplier;489 type WeightToFee = LinearFee<Balance>;490 type FeeMultiplierUpdate = ();491}492493parameter_types! {494 pub const ProposalBond: Permill = Permill::from_percent(5);495 pub const ProposalBondMinimum: Balance = 1 * UNIQUE;496 pub const ProposalBondMaximum: Balance = 1000 * UNIQUE;497 pub const SpendPeriod: BlockNumber = 5 * MINUTES;498 pub const Burn: Permill = Permill::from_percent(0);499 pub const TipCountdown: BlockNumber = 1 * DAYS;500 pub const TipFindersFee: Percent = Percent::from_percent(20);501 pub const TipReportDepositBase: Balance = 1 * UNIQUE;502 pub const DataDepositPerByte: Balance = 1 * CENTIUNIQUE;503 pub const BountyDepositBase: Balance = 1 * UNIQUE;504 pub const BountyDepositPayoutDelay: BlockNumber = 1 * DAYS;505 pub const TreasuryModuleId: PalletId = PalletId(*b"py/trsry");506 pub const BountyUpdatePeriod: BlockNumber = 14 * DAYS;507 pub const MaximumReasonLength: u32 = 16384;508 pub const BountyCuratorDeposit: Permill = Permill::from_percent(50);509 pub const BountyValueMinimum: Balance = 5 * UNIQUE;510 pub const MaxApprovals: u32 = 100;511}512513impl pallet_treasury::Config for Runtime {514 type PalletId = TreasuryModuleId;515 type Currency = Balances;516 type ApproveOrigin = EnsureRoot<AccountId>;517 type RejectOrigin = EnsureRoot<AccountId>;518 type Event = Event;519 type OnSlash = ();520 type ProposalBond = ProposalBond;521 type ProposalBondMinimum = ProposalBondMinimum;522 type ProposalBondMaximum = ProposalBondMaximum;523 type SpendPeriod = SpendPeriod;524 type Burn = Burn;525 type BurnDestination = ();526 type SpendFunds = ();527 type WeightInfo = pallet_treasury::weights::SubstrateWeight<Self>;528 type MaxApprovals = MaxApprovals;529}530531impl pallet_sudo::Config for Runtime {532 type Event = Event;533 type Call = Call;534}535536pub struct RelayChainBlockNumberProvider<T>(sp_std::marker::PhantomData<T>);537538impl<T: cumulus_pallet_parachain_system::Config> BlockNumberProvider539 for RelayChainBlockNumberProvider<T>540{541 type BlockNumber = BlockNumber;542543 fn current_block_number() -> Self::BlockNumber {544 cumulus_pallet_parachain_system::Pallet::<T>::validation_data()545 .map(|d| d.relay_parent_number)546 .unwrap_or_default()547 }548}549550parameter_types! {551 pub const MinVestedTransfer: Balance = 10 * UNIQUE;552 pub const MaxVestingSchedules: u32 = 28;553}554555impl orml_vesting::Config for Runtime {556 type Event = Event;557 type Currency = pallet_balances::Pallet<Runtime>;558 type MinVestedTransfer = MinVestedTransfer;559 type VestedTransferOrigin = EnsureSigned<AccountId>;560 type WeightInfo = ();561 type MaxVestingSchedules = MaxVestingSchedules;562 type BlockNumberProvider = RelayChainBlockNumberProvider<Runtime>;563}564565parameter_types! {566 pub const ReservedDmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;567 pub const ReservedXcmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;568}569570impl cumulus_pallet_parachain_system::Config for Runtime {571 type Event = Event;572 type SelfParaId = parachain_info::Pallet<Self>;573 type OnSystemEvent = ();574 575 576 577 578 579 type OutboundXcmpMessageSource = XcmpQueue;580 type DmpMessageHandler = DmpQueue;581 type ReservedDmpWeight = ReservedDmpWeight;582 type ReservedXcmpWeight = ReservedXcmpWeight;583 type XcmpMessageHandler = XcmpQueue;584}585586impl parachain_info::Config for Runtime {}587588impl cumulus_pallet_aura_ext::Config for Runtime {}589590parameter_types! {591 pub const RelayLocation: MultiLocation = MultiLocation::parent();592 pub const RelayNetwork: NetworkId = NetworkId::Polkadot;593 pub RelayOrigin: Origin = cumulus_pallet_xcm::Origin::Relay.into();594 pub Ancestry: MultiLocation = Parachain(ParachainInfo::parachain_id().into()).into();595}596597598599600pub type LocationToAccountId = (601 602 ParentIsPreset<AccountId>,603 604 SiblingParachainConvertsVia<Sibling, AccountId>,605 606 AccountId32Aliases<RelayNetwork, AccountId>,607);608609pub struct OnlySelfCurrency;610impl<B: TryFrom<u128>> MatchesFungible<B> for OnlySelfCurrency {611 fn matches_fungible(a: &MultiAsset) -> Option<B> {612 match (&a.id, &a.fun) {613 (Concrete(_), XcmFungible(ref amount)) => CheckedConversion::checked_from(*amount),614 _ => None,615 }616 }617}618619620pub type LocalAssetTransactor = CurrencyAdapter<621 622 Balances,623 624 OnlySelfCurrency,625 626 LocationToAccountId,627 628 AccountId,629 630 (),631>;632633634635636pub type XcmOriginToTransactDispatchOrigin = (637 638 639 640 SovereignSignedViaLocation<LocationToAccountId, Origin>,641 642 643 RelayChainAsNative<RelayOrigin, Origin>,644 645 646 SiblingParachainAsNative<cumulus_pallet_xcm::Origin, Origin>,647 648 649 ParentAsSuperuser<Origin>,650 651 652 SignedAccountId32AsNative<RelayNetwork, Origin>,653 654 XcmPassthrough<Origin>,655);656657parameter_types! {658 659 pub UnitWeightCost: Weight = 1_000_000;660 661 pub const WeightPrice: (MultiLocation, u128) = (MultiLocation::parent(), 1_200 * UNIQUE);662 pub const MaxInstructions: u32 = 100;663 pub const MaxAuthorities: u32 = 100_000;664}665666match_types! {667 pub type ParentOrParentsUnitPlurality: impl Contains<MultiLocation> = {668 MultiLocation { parents: 1, interior: Here } |669 MultiLocation { parents: 1, interior: X1(Plurality { id: BodyId::Unit, .. }) }670 };671}672673pub type Barrier = (674 TakeWeightCredit,675 AllowTopLevelPaidExecutionFrom<Everything>,676 AllowUnpaidExecutionFrom<ParentOrParentsUnitPlurality>,677 678);679680pub struct UsingOnlySelfCurrencyComponents<681 WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,682 AssetId: Get<MultiLocation>,683 AccountId,684 Currency: CurrencyT<AccountId>,685 OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,686>(687 Weight,688 Currency::Balance,689 PhantomData<(WeightToFee, AssetId, AccountId, Currency, OnUnbalanced)>,690);691impl<692 WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,693 AssetId: Get<MultiLocation>,694 AccountId,695 Currency: CurrencyT<AccountId>,696 OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,697 > WeightTrader698 for UsingOnlySelfCurrencyComponents<WeightToFee, AssetId, AccountId, Currency, OnUnbalanced>699{700 fn new() -> Self {701 Self(0, Zero::zero(), PhantomData)702 }703704 fn buy_weight(&mut self, weight: Weight, payment: Assets) -> Result<Assets, XcmError> {705 let amount = WeightToFee::calc(&weight);706 let u128_amount: u128 = amount.try_into().map_err(|_| XcmError::Overflow)?;707708 709 let option1: xcm::v1::AssetId = Concrete(MultiLocation {710 parents: 1,711 interior: X1(Parachain(ParachainInfo::parachain_id().into())),712 });713 714 let option2: xcm::v1::AssetId = Concrete(MultiLocation {715 parents: 0,716 interior: Here,717 });718719 let required = if payment.fungible.contains_key(&option1) {720 (option1, u128_amount).into()721 } else if payment.fungible.contains_key(&option2) {722 (option2, u128_amount).into()723 } else {724 (Concrete(MultiLocation::default()), u128_amount).into()725 };726727 let unused = payment728 .checked_sub(required)729 .map_err(|_| XcmError::TooExpensive)?;730 self.0 = self.0.saturating_add(weight);731 self.1 = self.1.saturating_add(amount);732 Ok(unused)733 }734735 fn refund_weight(&mut self, weight: Weight) -> Option<MultiAsset> {736 let weight = weight.min(self.0);737 let amount = WeightToFee::calc(&weight);738 self.0 -= weight;739 self.1 = self.1.saturating_sub(amount);740 let amount: u128 = amount.saturated_into();741 if amount > 0 {742 Some((AssetId::get(), amount).into())743 } else {744 None745 }746 }747}748impl<749 WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,750 AssetId: Get<MultiLocation>,751 AccountId,752 Currency: CurrencyT<AccountId>,753 OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,754 > Drop755 for UsingOnlySelfCurrencyComponents<WeightToFee, AssetId, AccountId, Currency, OnUnbalanced>756{757 fn drop(&mut self) {758 OnUnbalanced::on_unbalanced(Currency::issue(self.1));759 }760}761762pub struct XcmConfig;763impl Config for XcmConfig {764 type Call = Call;765 type XcmSender = XcmRouter;766 767 type AssetTransactor = LocalAssetTransactor;768 type OriginConverter = XcmOriginToTransactDispatchOrigin;769 type IsReserve = NativeAsset;770 type IsTeleporter = (); 771 type LocationInverter = LocationInverter<Ancestry>;772 type Barrier = Barrier;773 type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;774 type Trader = UsingOnlySelfCurrencyComponents<775 IdentityFee<Balance>,776 RelayLocation,777 AccountId,778 Balances,779 (),780 >;781 type ResponseHandler = (); 782 type SubscriptionService = PolkadotXcm;783784 type AssetTrap = PolkadotXcm;785 type AssetClaims = PolkadotXcm;786}787788789790791792793pub type LocalOriginToLocation = (SignedToAccountId32<Origin, AccountId, RelayNetwork>,);794795796797pub type XcmRouter = (798 799 cumulus_primitives_utility::ParentAsUmp<ParachainSystem, ()>,800 801 XcmpQueue,802);803804impl pallet_evm_coder_substrate::Config for Runtime {805 type GasWeightMapping = FixedGasWeightMapping;806}807808impl pallet_xcm::Config for Runtime {809 type Event = Event;810 type SendXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;811 type XcmRouter = XcmRouter;812 type ExecuteXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;813 type XcmExecuteFilter = Everything;814 type XcmExecutor = XcmExecutor<XcmConfig>;815 type XcmTeleportFilter = Everything;816 type XcmReserveTransferFilter = Everything;817 type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;818 type LocationInverter = LocationInverter<Ancestry>;819 type Origin = Origin;820 type Call = Call;821 const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;822 type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;823}824825impl cumulus_pallet_xcm::Config for Runtime {826 type Event = Event;827 type XcmExecutor = XcmExecutor<XcmConfig>;828}829830impl cumulus_pallet_xcmp_queue::Config for Runtime {831 type WeightInfo = ();832 type Event = Event;833 type XcmExecutor = XcmExecutor<XcmConfig>;834 type ChannelInfo = ParachainSystem;835 type VersionWrapper = ();836 type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;837 type ControllerOrigin = EnsureRoot<AccountId>;838 type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin;839}840841impl cumulus_pallet_dmp_queue::Config for Runtime {842 type Event = Event;843 type XcmExecutor = XcmExecutor<XcmConfig>;844 type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;845}846847impl pallet_aura::Config for Runtime {848 type AuthorityId = AuraId;849 type DisabledValidators = ();850 type MaxAuthorities = MaxAuthorities;851}852853parameter_types! {854 pub TreasuryAccountId: AccountId = TreasuryModuleId::get().into_account();855 pub const CollectionCreationPrice: Balance = 2 * UNIQUE;856}857858impl pallet_common::Config for Runtime {859 type Event = Event;860861 type Currency = Balances;862 type CollectionCreationPrice = CollectionCreationPrice;863 type TreasuryAccountId = TreasuryAccountId;864 type CollectionDispatch = CollectionDispatchT<Self>;865866 type EvmTokenAddressMapping = EvmTokenAddressMapping;867 type CrossTokenAddressMapping = CrossTokenAddressMapping<Self::AccountId>;868}869870impl pallet_structure::Config for Runtime {871 type Event = Event;872 type Call = Call;873 type WeightInfo = pallet_structure::weights::SubstrateWeight<Self>;874}875876impl pallet_evm::account::Config for Runtime {877 type CrossAccountId = pallet_evm::account::BasicCrossAccountId<Self>;878 type EvmAddressMapping = HashedAddressMapping<Self::Hashing>;879 type EvmBackwardsAddressMapping = fp_evm_mapping::MapBackwardsAddressTruncated;880}881882impl pallet_fungible::Config for Runtime {883 type WeightInfo = pallet_fungible::weights::SubstrateWeight<Self>;884}885impl pallet_refungible::Config for Runtime {886 type WeightInfo = pallet_refungible::weights::SubstrateWeight<Self>;887}888impl pallet_nonfungible::Config for Runtime {889 type WeightInfo = pallet_nonfungible::weights::SubstrateWeight<Self>;890}891892impl pallet_proxy_rmrk_core::Config for Runtime {893 type Event = Event;894}895896impl pallet_proxy_rmrk_equip::Config for Runtime {897 type Event = Event;898}899900impl pallet_unique::Config for Runtime {901 type Event = Event;902 type WeightInfo = pallet_unique::weights::SubstrateWeight<Self>;903 type CommonWeightInfo = CommonWeights<Self>;904}905906parameter_types! {907 pub const InflationBlockInterval: BlockNumber = 100; 908}909910911impl pallet_inflation::Config for Runtime {912 type Currency = Balances;913 type TreasuryAccountId = TreasuryAccountId;914 type InflationBlockInterval = InflationBlockInterval;915 type BlockNumberProvider = RelayChainBlockNumberProvider<Runtime>;916}917918919920921922923924type EvmSponsorshipHandler = (925 UniqueEthSponsorshipHandler<Runtime>,926 pallet_evm_contract_helpers::HelpersContractSponsoring<Runtime>,927);928type SponsorshipHandler = (929 UniqueSponsorshipHandler<Runtime>,930 931 pallet_evm_transaction_payment::BridgeSponsorshipHandler<Runtime>,932);933934935936937938939940941942943944945946impl pallet_evm_transaction_payment::Config for Runtime {947 type EvmSponsorshipHandler = EvmSponsorshipHandler;948 type Currency = Balances;949}950951impl pallet_charge_transaction::Config for Runtime {952 type SponsorshipHandler = SponsorshipHandler;953}954955956957958959parameter_types! {960 961 pub const HelpersContractAddress: H160 = H160([962 0x84, 0x28, 0x99, 0xec, 0xf3, 0x80, 0x55, 0x3e, 0x8a, 0x4d, 0xe7, 0x5b, 0xf5, 0x34, 0xcd, 0xf6, 0xfb, 0xf6, 0x40, 0x49,963 ]);964 965 966 pub const EvmCollectionHelperAddress: H160 = H160([967 0x6c, 0x4e, 0x9f, 0xe1, 0xae, 0x37, 0xa4, 0x1e, 0x93, 0xce, 0xe4, 0x29, 0xe8, 0xe1, 0x88, 0x1a, 0xbd, 0xcb, 0xb5, 0x4f,968 ]);969}970971impl pallet_evm_contract_helpers::Config for Runtime {972 type ContractAddress = HelpersContractAddress;973 type DefaultSponsoringRateLimit = DefaultSponsoringRateLimit;974}975976impl evm_collection::Config for Runtime {977 type ContractAddress = EvmCollectionHelperAddress;978}979980construct_runtime!(981 pub enum Runtime where982 Block = Block,983 NodeBlock = opaque::Block,984 UncheckedExtrinsic = UncheckedExtrinsic985 {986 ParachainSystem: cumulus_pallet_parachain_system::{Pallet, Call, Config, Storage, Inherent, Event<T>, ValidateUnsigned} = 20,987 ParachainInfo: parachain_info::{Pallet, Storage, Config} = 21,988989 Aura: pallet_aura::{Pallet, Config<T>} = 22,990 AuraExt: cumulus_pallet_aura_ext::{Pallet, Config} = 23,991992 Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>} = 30,993 RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Pallet, Storage} = 31,994 Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent} = 32,995 TransactionPayment: pallet_transaction_payment::{Pallet, Storage} = 33,996 Treasury: pallet_treasury::{Pallet, Call, Storage, Config, Event<T>} = 34,997 Sudo: pallet_sudo::{Pallet, Call, Storage, Config<T>, Event<T>} = 35,998 System: frame_system::{Pallet, Call, Storage, Config, Event<T>} = 36,999 Vesting: orml_vesting::{Pallet, Storage, Call, Event<T>, Config<T>} = 37,1000 1001 10021003 1004 XcmpQueue: cumulus_pallet_xcmp_queue::{Pallet, Call, Storage, Event<T>} = 50,1005 PolkadotXcm: pallet_xcm::{Pallet, Call, Event<T>, Origin} = 51,1006 CumulusXcm: cumulus_pallet_xcm::{Pallet, Call, Event<T>, Origin} = 52,1007 DmpQueue: cumulus_pallet_dmp_queue::{Pallet, Call, Storage, Event<T>} = 53,10081009 1010 Inflation: pallet_inflation::{Pallet, Call, Storage} = 60,1011 Unique: pallet_unique::{Pallet, Call, Storage, Event<T>} = 61,1012 1013 1014 Charging: pallet_charge_transaction::{Pallet, Call, Storage } = 64,1015 1016 Common: pallet_common::{Pallet, Storage, Event<T>} = 66,1017 Fungible: pallet_fungible::{Pallet, Storage} = 67,1018 Refungible: pallet_refungible::{Pallet, Storage} = 68,1019 Nonfungible: pallet_nonfungible::{Pallet, Storage} = 69,1020 Structure: pallet_structure::{Pallet, Call, Storage, Event<T>} = 70,1021 RmrkCore: pallet_proxy_rmrk_core::{Pallet, Call, Storage, Event<T>} = 71,1022 RmrkEquip: pallet_proxy_rmrk_equip::{Pallet, Call, Storage, Event<T>} = 72,10231024 1025 EVM: pallet_evm::{Pallet, Config, Call, Storage, Event<T>} = 100,1026 Ethereum: pallet_ethereum::{Pallet, Config, Call, Storage, Event, Origin} = 101,10271028 EvmCoderSubstrate: pallet_evm_coder_substrate::{Pallet, Storage} = 150,1029 EvmContractHelpers: pallet_evm_contract_helpers::{Pallet, Storage} = 151,1030 EvmTransactionPayment: pallet_evm_transaction_payment::{Pallet} = 152,1031 EvmMigration: pallet_evm_migration::{Pallet, Call, Storage} = 153,1032 }1033);10341035pub struct TransactionConverter;10361037impl fp_rpc::ConvertTransaction<UncheckedExtrinsic> for TransactionConverter {1038 fn convert_transaction(&self, transaction: pallet_ethereum::Transaction) -> UncheckedExtrinsic {1039 UncheckedExtrinsic::new_unsigned(1040 pallet_ethereum::Call::<Runtime>::transact { transaction }.into(),1041 )1042 }1043}10441045impl fp_rpc::ConvertTransaction<opaque::UncheckedExtrinsic> for TransactionConverter {1046 fn convert_transaction(1047 &self,1048 transaction: pallet_ethereum::Transaction,1049 ) -> opaque::UncheckedExtrinsic {1050 let extrinsic = UncheckedExtrinsic::new_unsigned(1051 pallet_ethereum::Call::<Runtime>::transact { transaction }.into(),1052 );1053 let encoded = extrinsic.encode();1054 opaque::UncheckedExtrinsic::decode(&mut &encoded[..])1055 .expect("Encoded extrinsic is always valid")1056 }1057}105810591060pub type Address = sp_runtime::MultiAddress<AccountId, ()>;10611062pub type Header = generic::Header<BlockNumber, BlakeTwo256>;10631064pub type Block = generic::Block<Header, UncheckedExtrinsic>;10651066pub type SignedBlock = generic::SignedBlock<Block>;10671068pub type BlockId = generic::BlockId<Block>;10691070pub type SignedExtra = (1071 frame_system::CheckSpecVersion<Runtime>,1072 1073 frame_system::CheckGenesis<Runtime>,1074 frame_system::CheckEra<Runtime>,1075 frame_system::CheckNonce<Runtime>,1076 frame_system::CheckWeight<Runtime>,1077 pallet_charge_transaction::ChargeTransactionPayment<Runtime>,1078 1079 pallet_ethereum::FakeTransactionFinalizer<Runtime>,1080);10811082pub type UncheckedExtrinsic =1083 fp_self_contained::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;10841085pub type CheckedExtrinsic = fp_self_contained::CheckedExtrinsic<AccountId, Call, SignedExtra, H160>;10861087pub type Executive = frame_executive::Executive<1088 Runtime,1089 Block,1090 frame_system::ChainContext<Runtime>,1091 Runtime,1092 AllPalletsReversedWithSystemFirst,1093>;10941095impl_opaque_keys! {1096 pub struct SessionKeys {1097 pub aura: Aura,1098 }1099}11001101impl fp_self_contained::SelfContainedCall for Call {1102 type SignedInfo = H160;11031104 fn is_self_contained(&self) -> bool {1105 match self {1106 Call::Ethereum(call) => call.is_self_contained(),1107 _ => false,1108 }1109 }11101111 fn check_self_contained(&self) -> Option<Result<Self::SignedInfo, TransactionValidityError>> {1112 match self {1113 Call::Ethereum(call) => call.check_self_contained(),1114 _ => None,1115 }1116 }11171118 fn validate_self_contained(&self, info: &Self::SignedInfo) -> Option<TransactionValidity> {1119 match self {1120 Call::Ethereum(call) => call.validate_self_contained(info),1121 _ => None,1122 }1123 }11241125 fn pre_dispatch_self_contained(1126 &self,1127 info: &Self::SignedInfo,1128 ) -> Option<Result<(), TransactionValidityError>> {1129 match self {1130 Call::Ethereum(call) => call.pre_dispatch_self_contained(info),1131 _ => None,1132 }1133 }11341135 fn apply_self_contained(1136 self,1137 info: Self::SignedInfo,1138 ) -> Option<sp_runtime::DispatchResultWithInfo<PostDispatchInfoOf<Self>>> {1139 match self {1140 call @ Call::Ethereum(pallet_ethereum::Call::transact { .. }) => Some(call.dispatch(1141 Origin::from(pallet_ethereum::RawOrigin::EthereumTransaction(info)),1142 )),1143 _ => None,1144 }1145 }1146}11471148macro_rules! dispatch_unique_runtime {1149 ($collection:ident.$method:ident($($name:ident),*)) => {{1150 let collection = <Runtime as pallet_common::Config>::CollectionDispatch::dispatch(<pallet_common::CollectionHandle<Runtime>>::try_get($collection)?);1151 let dispatch = collection.as_dyn();11521153 Ok::<_, DispatchError>(dispatch.$method($($name),*))1154 }};1155}11561157impl_common_runtime_apis!();11581159struct CheckInherents;11601161impl cumulus_pallet_parachain_system::CheckInherents<Block> for CheckInherents {1162 fn check_inherents(1163 block: &Block,1164 relay_state_proof: &cumulus_pallet_parachain_system::RelayChainStateProof,1165 ) -> sp_inherents::CheckInherentsResult {1166 let relay_chain_slot = relay_state_proof1167 .read_slot()1168 .expect("Could not read the relay chain slot from the proof");11691170 let inherent_data =1171 cumulus_primitives_timestamp::InherentDataProvider::from_relay_chain_slot_and_duration(1172 relay_chain_slot,1173 sp_std::time::Duration::from_secs(6),1174 )1175 .create_inherent_data()1176 .expect("Could not create the timestamp inherent data");11771178 inherent_data.check_extrinsics(block)1179 }1180}11811182cumulus_pallet_parachain_system::register_validate_block!(1183 Runtime = Runtime,1184 BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor::<Runtime, Executive>,1185 CheckInherents = CheckInherents,1186);