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::{EnsureAddressTruncated, HashedAddressMapping, Runner};52pub use frame_support::{53 construct_runtime, match_type,54 dispatch::DispatchResult,55 PalletId, parameter_types, StorageValue, ConsensusEngineId,56 traits::{57 tokens::currency::Currency as CurrencyT, OnUnbalanced as OnUnbalancedT, Everything,58 Currency, ExistenceRequirement, Get, IsInVec, KeyOwnerProofSystem, LockIdentifier,59 OnUnbalanced, Randomness, FindAuthor,60 },61 weights::{62 constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND},63 DispatchClass, DispatchInfo, GetDispatchInfo, IdentityFee, Pays, PostDispatchInfo, Weight,64 WeightToFeePolynomial, WeightToFeeCoefficient, WeightToFeeCoefficients,65 },66};67use up_data_structs::*;686970use frame_system::{71 self as frame_system, EnsureRoot, EnsureSigned,72 limits::{BlockWeights, BlockLength},73};74use sp_arithmetic::{75 traits::{BaseArithmetic, Unsigned},76};77use smallvec::smallvec;78use codec::{Encode, Decode};79use pallet_evm::{Account as EVMAccount, FeeCalculator, GasWeightMapping, OnMethodCall};80use fp_rpc::TransactionStatus;81use sp_runtime::{82 traits::{BlockNumberProvider, Dispatchable, PostDispatchInfoOf, Saturating},83 transaction_validity::TransactionValidityError,84 SaturatedConversion,85};868788pub use sp_consensus_aura::sr25519::AuthorityId as AuraId;899091use pallet_xcm::XcmPassthrough;92use polkadot_parachain::primitives::Sibling;93use xcm::v1::{BodyId, Junction::*, MultiLocation, NetworkId, Junctions::*};94use xcm_builder::{95 AccountId32Aliases, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, CurrencyAdapter,96 EnsureXcmOrigin, FixedWeightBounds, LocationInverter, NativeAsset, ParentAsSuperuser,97 RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia,98 SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit,99 ParentIsPreset,100};101use xcm_executor::{Config, XcmExecutor, Assets};102use sp_std::{marker::PhantomData};103104use xcm::latest::{105 106 AssetId::{Concrete},107 Fungibility::Fungible as XcmFungible,108 MultiAsset,109 Error as XcmError,110};111use xcm_executor::traits::{MatchesFungible, WeightTrader};112113use sp_runtime::traits::CheckedConversion;114115use unique_runtime_common::{impl_common_runtime_apis, types::*, constants::*};116117pub const RUNTIME_NAME: &str = "Opal";118119type CrossAccountId = pallet_evm::account::BasicCrossAccountId<Runtime>;120121impl RuntimeInstance for Runtime {122 type CrossAccountId = self::CrossAccountId;123 type TransactionConverter = self::TransactionConverter;124125 fn get_transaction_converter() -> TransactionConverter {126 TransactionConverter127 }128}129130131132pub type AccountIndex = u32;133134135pub type Balance = u128;136137138pub type Index = u32;139140141pub type Hash = sp_core::H256;142143144pub type DigestItem = generic::DigestItem;145146147148149150pub mod opaque {151 use sp_std::prelude::*;152 use sp_runtime::impl_opaque_keys;153 use super::Aura;154155 pub use unique_runtime_common::types::*;156157 impl_opaque_keys! {158 pub struct SessionKeys {159 pub aura: Aura,160 }161 }162}163164165pub const VERSION: RuntimeVersion = RuntimeVersion {166 spec_name: create_runtime_str!(RUNTIME_NAME),167 impl_name: create_runtime_str!(RUNTIME_NAME),168 authoring_version: 1,169 spec_version: 917004,170 impl_version: 0,171 apis: RUNTIME_API_VERSIONS,172 transaction_version: 1,173 state_version: 0,174};175176#[derive(codec::Encode, codec::Decode)]177pub enum XCMPMessage<XAccountId, XBalance> {178 179 TransferToken(XAccountId, XBalance),180}181182183#[cfg(feature = "std")]184pub fn native_version() -> NativeVersion {185 NativeVersion {186 runtime_version: VERSION,187 can_author_with: Default::default(),188 }189}190191type NegativeImbalance = <Balances as Currency<AccountId>>::NegativeImbalance;192193pub struct DealWithFees;194impl OnUnbalanced<NegativeImbalance> for DealWithFees {195 fn on_unbalanceds<B>(mut fees_then_tips: impl Iterator<Item = NegativeImbalance>) {196 if let Some(fees) = fees_then_tips.next() {197 198 let mut split = fees.ration(100, 0);199 if let Some(tips) = fees_then_tips.next() {200 201 tips.ration_merge_into(100, 0, &mut split);202 }203 Treasury::on_unbalanced(split.0);204 205 }206 }207}208209parameter_types! {210 pub const BlockHashCount: BlockNumber = 2400;211 pub RuntimeBlockLength: BlockLength =212 BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);213 pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);214 pub const MaximumBlockLength: u32 = 5 * 1024 * 1024;215 pub RuntimeBlockWeights: BlockWeights = BlockWeights::builder()216 .base_block(BlockExecutionWeight::get())217 .for_class(DispatchClass::all(), |weights| {218 weights.base_extrinsic = ExtrinsicBaseWeight::get();219 })220 .for_class(DispatchClass::Normal, |weights| {221 weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT);222 })223 .for_class(DispatchClass::Operational, |weights| {224 weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT);225 226 227 weights.reserved = Some(228 MAXIMUM_BLOCK_WEIGHT - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT229 );230 })231 .avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO)232 .build_or_panic();233 pub const Version: RuntimeVersion = VERSION;234 pub const SS58Prefix: u8 = 42;235}236237parameter_types! {238 pub const ChainId: u64 = 8882;239}240241pub struct FixedFee;242impl FeeCalculator for FixedFee {243 fn min_gas_price() -> U256 {244 MIN_GAS_PRICE.into()245 }246}247248249250251parameter_types! {252 pub const WritesPerSecond: u64 = WEIGHT_PER_SECOND / <Runtime as frame_system::Config>::DbWeight::get().write;253 pub const GasPerSecond: u64 = WritesPerSecond::get() * 20000;254 pub const WeightPerGas: u64 = WEIGHT_PER_SECOND / GasPerSecond::get();255}256257258259260const EVM_DISPATCH_RATIO: Perbill = Perbill::from_percent(50);261parameter_types! {262 pub BlockGasLimit: U256 = U256::from(NORMAL_DISPATCH_RATIO * EVM_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT / WeightPerGas::get());263}264265pub enum FixedGasWeightMapping {}266impl GasWeightMapping for FixedGasWeightMapping {267 fn gas_to_weight(gas: u64) -> Weight {268 gas.saturating_mul(WeightPerGas::get())269 }270 fn weight_to_gas(weight: Weight) -> u64 {271 weight / WeightPerGas::get()272 }273}274275impl pallet_evm::account::Config for Runtime {276 type CrossAccountId = pallet_evm::account::BasicCrossAccountId<Self>;277 type EvmAddressMapping = pallet_evm::HashedAddressMapping<Self::Hashing>;278 type EvmBackwardsAddressMapping = fp_evm_mapping::MapBackwardsAddressTruncated;279}280281impl pallet_evm::Config for Runtime {282 type BlockGasLimit = BlockGasLimit;283 type FeeCalculator = FixedFee;284 type GasWeightMapping = FixedGasWeightMapping;285 type BlockHashMapping = pallet_ethereum::EthereumBlockHashMapping<Self>;286 type CallOrigin = EnsureAddressTruncated;287 type WithdrawOrigin = EnsureAddressTruncated;288 type AddressMapping = HashedAddressMapping<Self::Hashing>;289 type PrecompilesType = ();290 type PrecompilesValue = ();291 type Currency = Balances;292 type Event = Event;293 type OnMethodCall = (294 pallet_evm_migration::OnMethodCall<Self>,295 pallet_unique::UniqueErcSupport<Self>,296 pallet_evm_contract_helpers::HelpersOnMethodCall<Self>,297 );298 type OnCreate = pallet_evm_contract_helpers::HelpersOnCreate<Self>;299 type ChainId = ChainId;300 type Runner = pallet_evm::runner::stack::Runner<Self>;301 type OnChargeTransaction = pallet_evm_transaction_payment::OnChargeTransaction<Self>;302 type TransactionValidityHack = pallet_evm_transaction_payment::TransactionValidityHack<Self>;303 type FindAuthor = EthereumFindAuthor<Aura>;304}305306impl pallet_evm_migration::Config for Runtime {307 type WeightInfo = pallet_evm_migration::weights::SubstrateWeight<Self>;308}309310pub struct EthereumFindAuthor<F>(core::marker::PhantomData<F>);311impl<F: FindAuthor<u32>> FindAuthor<H160> for EthereumFindAuthor<F> {312 fn find_author<'a, I>(digests: I) -> Option<H160>313 where314 I: 'a + IntoIterator<Item = (ConsensusEngineId, &'a [u8])>,315 {316 if let Some(author_index) = F::find_author(digests) {317 let authority_id = Aura::authorities()[author_index as usize].clone();318 return Some(H160::from_slice(&authority_id.to_raw_vec()[4..24]));319 }320 None321 }322}323324impl pallet_ethereum::Config for Runtime {325 type Event = Event;326 type StateRoot = pallet_ethereum::IntermediateStateRoot;327}328329impl pallet_randomness_collective_flip::Config for Runtime {}330331impl frame_system::Config for Runtime {332 333 type AccountData = pallet_balances::AccountData<Balance>;334 335 type AccountId = AccountId;336 337 type BaseCallFilter = Everything;338 339 type BlockHashCount = BlockHashCount;340 341 type BlockLength = RuntimeBlockLength;342 343 type BlockNumber = BlockNumber;344 345 type BlockWeights = RuntimeBlockWeights;346 347 type Call = Call;348 349 type DbWeight = RocksDbWeight;350 351 type Event = Event;352 353 type Hash = Hash;354 355 type Hashing = BlakeTwo256;356 357 type Header = generic::Header<BlockNumber, BlakeTwo256>;358 359 type Index = Index;360 361 type Lookup = AccountIdLookup<AccountId, ()>;362 363 type OnKilledAccount = ();364 365 type OnNewAccount = ();366 type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode<Self>;367 368 type Origin = Origin;369 370 type PalletInfo = PalletInfo;371 372 type SS58Prefix = SS58Prefix;373 374 type SystemWeightInfo = frame_system::weights::SubstrateWeight<Self>;375 376 type Version = Version;377 type MaxConsumers = ConstU32<16>;378}379380parameter_types! {381 pub const MinimumPeriod: u64 = SLOT_DURATION / 2;382}383384impl pallet_timestamp::Config for Runtime {385 386 type Moment = u64;387 type OnTimestampSet = ();388 type MinimumPeriod = MinimumPeriod;389 type WeightInfo = ();390}391392parameter_types! {393 394 pub const ExistentialDeposit: u128 = 0;395 pub const MaxLocks: u32 = 50;396}397398impl pallet_balances::Config for Runtime {399 type MaxLocks = MaxLocks;400 type MaxReserves = ();401 type ReserveIdentifier = [u8; 8];402 403 type Balance = Balance;404 405 type Event = Event;406 type DustRemoval = Treasury;407 type ExistentialDeposit = ExistentialDeposit;408 type AccountStore = System;409 type WeightInfo = pallet_balances::weights::SubstrateWeight<Self>;410}411412pub const fn deposit(items: u32, bytes: u32) -> Balance {413 items as Balance * 15 * CENTIUNIQUE + (bytes as Balance) * 6 * CENTIUNIQUE414}415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466parameter_types! {467 468 469 pub const OperationalFeeMultiplier: u8 = 5;470}471472473pub struct LinearFee<T>(sp_std::marker::PhantomData<T>);474475impl<T> WeightToFeePolynomial for LinearFee<T>476where477 T: BaseArithmetic + From<u32> + Copy + Unsigned,478{479 type Balance = T;480481 fn polynomial() -> WeightToFeeCoefficients<Self::Balance> {482 smallvec!(WeightToFeeCoefficient {483 484 coeff_integer: WEIGHT_TO_FEE_COEFF.into(),485 coeff_frac: Perbill::zero(),486 negative: false,487 degree: 1,488 })489 }490}491492impl pallet_transaction_payment::Config for Runtime {493 type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter<Balances, DealWithFees>;494 type TransactionByteFee = TransactionByteFee;495 type OperationalFeeMultiplier = OperationalFeeMultiplier;496 type WeightToFee = LinearFee<Balance>;497 type FeeMultiplierUpdate = ();498}499500parameter_types! {501 pub const ProposalBond: Permill = Permill::from_percent(5);502 pub const ProposalBondMinimum: Balance = 1 * UNIQUE;503 pub const ProposalBondMaximum: Balance = 1000 * UNIQUE;504 pub const SpendPeriod: BlockNumber = 5 * MINUTES;505 pub const Burn: Permill = Permill::from_percent(0);506 pub const TipCountdown: BlockNumber = 1 * DAYS;507 pub const TipFindersFee: Percent = Percent::from_percent(20);508 pub const TipReportDepositBase: Balance = 1 * UNIQUE;509 pub const DataDepositPerByte: Balance = 1 * CENTIUNIQUE;510 pub const BountyDepositBase: Balance = 1 * UNIQUE;511 pub const BountyDepositPayoutDelay: BlockNumber = 1 * DAYS;512 pub const TreasuryModuleId: PalletId = PalletId(*b"py/trsry");513 pub const BountyUpdatePeriod: BlockNumber = 14 * DAYS;514 pub const MaximumReasonLength: u32 = 16384;515 pub const BountyCuratorDeposit: Permill = Permill::from_percent(50);516 pub const BountyValueMinimum: Balance = 5 * UNIQUE;517 pub const MaxApprovals: u32 = 100;518}519520impl pallet_treasury::Config for Runtime {521 type PalletId = TreasuryModuleId;522 type Currency = Balances;523 type ApproveOrigin = EnsureRoot<AccountId>;524 type RejectOrigin = EnsureRoot<AccountId>;525 type Event = Event;526 type OnSlash = ();527 type ProposalBond = ProposalBond;528 type ProposalBondMinimum = ProposalBondMinimum;529 type ProposalBondMaximum = ProposalBondMaximum;530 type SpendPeriod = SpendPeriod;531 type Burn = Burn;532 type BurnDestination = ();533 type SpendFunds = ();534 type WeightInfo = pallet_treasury::weights::SubstrateWeight<Self>;535 type MaxApprovals = MaxApprovals;536}537538impl pallet_sudo::Config for Runtime {539 type Event = Event;540 type Call = Call;541}542543pub struct RelayChainBlockNumberProvider<T>(sp_std::marker::PhantomData<T>);544545impl<T: cumulus_pallet_parachain_system::Config> BlockNumberProvider546 for RelayChainBlockNumberProvider<T>547{548 type BlockNumber = BlockNumber;549550 fn current_block_number() -> Self::BlockNumber {551 cumulus_pallet_parachain_system::Pallet::<T>::validation_data()552 .map(|d| d.relay_parent_number)553 .unwrap_or_default()554 }555}556557parameter_types! {558 pub const MinVestedTransfer: Balance = 10 * UNIQUE;559 pub const MaxVestingSchedules: u32 = 28;560}561562impl orml_vesting::Config for Runtime {563 type Event = Event;564 type Currency = pallet_balances::Pallet<Runtime>;565 type MinVestedTransfer = MinVestedTransfer;566 type VestedTransferOrigin = EnsureSigned<AccountId>;567 type WeightInfo = ();568 type MaxVestingSchedules = MaxVestingSchedules;569 type BlockNumberProvider = RelayChainBlockNumberProvider<Runtime>;570}571572parameter_types! {573 pub const ReservedDmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;574 pub const ReservedXcmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;575}576577impl cumulus_pallet_parachain_system::Config for Runtime {578 type Event = Event;579 type SelfParaId = parachain_info::Pallet<Self>;580 type OnSystemEvent = ();581 582 583 584 585 586 type OutboundXcmpMessageSource = XcmpQueue;587 type DmpMessageHandler = DmpQueue;588 type ReservedDmpWeight = ReservedDmpWeight;589 type ReservedXcmpWeight = ReservedXcmpWeight;590 type XcmpMessageHandler = XcmpQueue;591}592593impl parachain_info::Config for Runtime {}594595impl cumulus_pallet_aura_ext::Config for Runtime {}596597parameter_types! {598 pub const RelayLocation: MultiLocation = MultiLocation::parent();599 pub const RelayNetwork: NetworkId = NetworkId::Polkadot;600 pub RelayOrigin: Origin = cumulus_pallet_xcm::Origin::Relay.into();601 pub Ancestry: MultiLocation = Parachain(ParachainInfo::parachain_id().into()).into();602}603604605606607pub type LocationToAccountId = (608 609 ParentIsPreset<AccountId>,610 611 SiblingParachainConvertsVia<Sibling, AccountId>,612 613 AccountId32Aliases<RelayNetwork, AccountId>,614);615616pub struct OnlySelfCurrency;617impl<B: TryFrom<u128>> MatchesFungible<B> for OnlySelfCurrency {618 fn matches_fungible(a: &MultiAsset) -> Option<B> {619 match (&a.id, &a.fun) {620 (Concrete(_), XcmFungible(ref amount)) => CheckedConversion::checked_from(*amount),621 _ => None,622 }623 }624}625626627pub type LocalAssetTransactor = CurrencyAdapter<628 629 Balances,630 631 OnlySelfCurrency,632 633 LocationToAccountId,634 635 AccountId,636 637 (),638>;639640641642643pub type XcmOriginToTransactDispatchOrigin = (644 645 646 647 SovereignSignedViaLocation<LocationToAccountId, Origin>,648 649 650 RelayChainAsNative<RelayOrigin, Origin>,651 652 653 SiblingParachainAsNative<cumulus_pallet_xcm::Origin, Origin>,654 655 656 ParentAsSuperuser<Origin>,657 658 659 SignedAccountId32AsNative<RelayNetwork, Origin>,660 661 XcmPassthrough<Origin>,662);663664parameter_types! {665 666 pub UnitWeightCost: Weight = 1_000_000;667 668 pub const WeightPrice: (MultiLocation, u128) = (MultiLocation::parent(), 1_200 * UNIQUE);669 pub const MaxInstructions: u32 = 100;670 pub const MaxAuthorities: u32 = 100_000;671}672673match_type! {674 pub type ParentOrParentsUnitPlurality: impl Contains<MultiLocation> = {675 MultiLocation { parents: 1, interior: Here } |676 MultiLocation { parents: 1, interior: X1(Plurality { id: BodyId::Unit, .. }) }677 };678}679680pub type Barrier = (681 TakeWeightCredit,682 AllowTopLevelPaidExecutionFrom<Everything>,683 AllowUnpaidExecutionFrom<ParentOrParentsUnitPlurality>,684 685);686687pub struct UsingOnlySelfCurrencyComponents<688 WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,689 AssetId: Get<MultiLocation>,690 AccountId,691 Currency: CurrencyT<AccountId>,692 OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,693>(694 Weight,695 Currency::Balance,696 PhantomData<(WeightToFee, AssetId, AccountId, Currency, OnUnbalanced)>,697);698impl<699 WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,700 AssetId: Get<MultiLocation>,701 AccountId,702 Currency: CurrencyT<AccountId>,703 OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,704 > WeightTrader705 for UsingOnlySelfCurrencyComponents<WeightToFee, AssetId, AccountId, Currency, OnUnbalanced>706{707 fn new() -> Self {708 Self(0, Zero::zero(), PhantomData)709 }710711 fn buy_weight(&mut self, weight: Weight, payment: Assets) -> Result<Assets, XcmError> {712 let amount = WeightToFee::calc(&weight);713 let u128_amount: u128 = amount.try_into().map_err(|_| XcmError::Overflow)?;714715 716 let option1: xcm::v1::AssetId = Concrete(MultiLocation {717 parents: 1,718 interior: X1(Parachain(ParachainInfo::parachain_id().into())),719 });720 721 let option2: xcm::v1::AssetId = Concrete(MultiLocation {722 parents: 0,723 interior: Here,724 });725726 let required = if payment.fungible.contains_key(&option1) {727 (option1, u128_amount).into()728 } else if payment.fungible.contains_key(&option2) {729 (option2, u128_amount).into()730 } else {731 (Concrete(MultiLocation::default()), u128_amount).into()732 };733734 let unused = payment735 .checked_sub(required)736 .map_err(|_| XcmError::TooExpensive)?;737 self.0 = self.0.saturating_add(weight);738 self.1 = self.1.saturating_add(amount);739 Ok(unused)740 }741742 fn refund_weight(&mut self, weight: Weight) -> Option<MultiAsset> {743 let weight = weight.min(self.0);744 let amount = WeightToFee::calc(&weight);745 self.0 -= weight;746 self.1 = self.1.saturating_sub(amount);747 let amount: u128 = amount.saturated_into();748 if amount > 0 {749 Some((AssetId::get(), amount).into())750 } else {751 None752 }753 }754}755impl<756 WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,757 AssetId: Get<MultiLocation>,758 AccountId,759 Currency: CurrencyT<AccountId>,760 OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,761 > Drop762 for UsingOnlySelfCurrencyComponents<WeightToFee, AssetId, AccountId, Currency, OnUnbalanced>763{764 fn drop(&mut self) {765 OnUnbalanced::on_unbalanced(Currency::issue(self.1));766 }767}768769pub struct XcmConfig;770impl Config for XcmConfig {771 type Call = Call;772 type XcmSender = XcmRouter;773 774 type AssetTransactor = LocalAssetTransactor;775 type OriginConverter = XcmOriginToTransactDispatchOrigin;776 type IsReserve = NativeAsset;777 type IsTeleporter = (); 778 type LocationInverter = LocationInverter<Ancestry>;779 type Barrier = Barrier;780 type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;781 type Trader = UsingOnlySelfCurrencyComponents<782 IdentityFee<Balance>,783 RelayLocation,784 AccountId,785 Balances,786 (),787 >;788 type ResponseHandler = (); 789 type SubscriptionService = PolkadotXcm;790791 type AssetTrap = PolkadotXcm;792 type AssetClaims = PolkadotXcm;793}794795796797798799800pub type LocalOriginToLocation = (SignedToAccountId32<Origin, AccountId, RelayNetwork>,);801802803804pub type XcmRouter = (805 806 cumulus_primitives_utility::ParentAsUmp<ParachainSystem, ()>,807 808 XcmpQueue,809);810811impl pallet_evm_coder_substrate::Config for Runtime {812 type EthereumTransactionSender = pallet_ethereum::Pallet<Self>;813 type GasWeightMapping = FixedGasWeightMapping;814}815816impl pallet_xcm::Config for Runtime {817 type Event = Event;818 type SendXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;819 type XcmRouter = XcmRouter;820 type ExecuteXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;821 type XcmExecuteFilter = Everything;822 type XcmExecutor = XcmExecutor<XcmConfig>;823 type XcmTeleportFilter = Everything;824 type XcmReserveTransferFilter = Everything;825 type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;826 type LocationInverter = LocationInverter<Ancestry>;827 type Origin = Origin;828 type Call = Call;829 const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;830 type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;831}832833impl cumulus_pallet_xcm::Config for Runtime {834 type Event = Event;835 type XcmExecutor = XcmExecutor<XcmConfig>;836}837838impl cumulus_pallet_xcmp_queue::Config for Runtime {839 type WeightInfo = ();840 type Event = Event;841 type XcmExecutor = XcmExecutor<XcmConfig>;842 type ChannelInfo = ParachainSystem;843 type VersionWrapper = ();844 type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;845 type ControllerOrigin = EnsureRoot<AccountId>;846 type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin;847}848849impl cumulus_pallet_dmp_queue::Config for Runtime {850 type Event = Event;851 type XcmExecutor = XcmExecutor<XcmConfig>;852 type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;853}854855impl pallet_aura::Config for Runtime {856 type AuthorityId = AuraId;857 type DisabledValidators = ();858 type MaxAuthorities = MaxAuthorities;859}860861parameter_types! {862 pub TreasuryAccountId: AccountId = TreasuryModuleId::get().into_account();863 pub const CollectionCreationPrice: Balance = 2 * UNIQUE;864}865866impl pallet_common::Config for Runtime {867 type Event = Event;868 type Currency = Balances;869 type CollectionCreationPrice = CollectionCreationPrice;870 type TreasuryAccountId = TreasuryAccountId;871}872873impl pallet_fungible::Config for Runtime {874 type WeightInfo = pallet_fungible::weights::SubstrateWeight<Self>;875}876impl pallet_refungible::Config for Runtime {877 type WeightInfo = pallet_refungible::weights::SubstrateWeight<Self>;878}879impl pallet_nonfungible::Config for Runtime {880 type WeightInfo = pallet_nonfungible::weights::SubstrateWeight<Self>;881}882883impl pallet_unique::Config for Runtime {884 type Event = Event;885 type WeightInfo = pallet_unique::weights::SubstrateWeight<Self>;886}887888parameter_types! {889 pub const InflationBlockInterval: BlockNumber = 100; 890}891892893impl pallet_inflation::Config for Runtime {894 type Currency = Balances;895 type TreasuryAccountId = TreasuryAccountId;896 type InflationBlockInterval = InflationBlockInterval;897 type BlockNumberProvider = RelayChainBlockNumberProvider<Runtime>;898}899900901902903904905906type EvmSponsorshipHandler = (907 pallet_unique::UniqueEthSponsorshipHandler<Runtime>,908 pallet_evm_contract_helpers::HelpersContractSponsoring<Runtime>,909);910type SponsorshipHandler = (911 pallet_unique::UniqueSponsorshipHandler<Runtime>,912 913 pallet_evm_transaction_payment::BridgeSponsorshipHandler<Runtime>,914);915916917918919920921922923924925926927928impl pallet_evm_transaction_payment::Config for Runtime {929 type EvmSponsorshipHandler = EvmSponsorshipHandler;930 type Currency = Balances;931}932933impl pallet_charge_transaction::Config for Runtime {934 type SponsorshipHandler = SponsorshipHandler;935}936937938939940941parameter_types! {942 943 pub const HelpersContractAddress: H160 = H160([944 0x84, 0x28, 0x99, 0xec, 0xf3, 0x80, 0x55, 0x3e, 0x8a, 0x4d, 0xe7, 0x5b, 0xf5, 0x34, 0xcd, 0xf6, 0xfb, 0xf6, 0x40, 0x49,945 ]);946}947948impl pallet_evm_contract_helpers::Config for Runtime {949 type ContractAddress = HelpersContractAddress;950 type DefaultSponsoringRateLimit = DefaultSponsoringRateLimit;951}952953construct_runtime!(954 pub enum Runtime where955 Block = Block,956 NodeBlock = opaque::Block,957 UncheckedExtrinsic = UncheckedExtrinsic958 {959 ParachainSystem: cumulus_pallet_parachain_system::{Pallet, Call, Config, Storage, Inherent, Event<T>, ValidateUnsigned} = 20,960 ParachainInfo: parachain_info::{Pallet, Storage, Config} = 21,961962 Aura: pallet_aura::{Pallet, Config<T>} = 22,963 AuraExt: cumulus_pallet_aura_ext::{Pallet, Config} = 23,964965 Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>} = 30,966 RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Pallet, Storage} = 31,967 Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent} = 32,968 TransactionPayment: pallet_transaction_payment::{Pallet, Storage} = 33,969 Treasury: pallet_treasury::{Pallet, Call, Storage, Config, Event<T>} = 34,970 Sudo: pallet_sudo::{Pallet, Call, Storage, Config<T>, Event<T>} = 35,971 System: frame_system::{Pallet, Call, Storage, Config, Event<T>} = 36,972 Vesting: orml_vesting::{Pallet, Storage, Call, Event<T>, Config<T>} = 37,973 974 975976 977 XcmpQueue: cumulus_pallet_xcmp_queue::{Pallet, Call, Storage, Event<T>} = 50,978 PolkadotXcm: pallet_xcm::{Pallet, Call, Event<T>, Origin} = 51,979 CumulusXcm: cumulus_pallet_xcm::{Pallet, Call, Event<T>, Origin} = 52,980 DmpQueue: cumulus_pallet_dmp_queue::{Pallet, Call, Storage, Event<T>} = 53,981982 983 Inflation: pallet_inflation::{Pallet, Call, Storage} = 60,984 Unique: pallet_unique::{Pallet, Call, Storage, Event<T>} = 61,985 986 987 Charging: pallet_charge_transaction::{Pallet, Call, Storage } = 64,988 989 Common: pallet_common::{Pallet, Storage, Event<T>} = 66,990 Fungible: pallet_fungible::{Pallet, Storage} = 67,991 Refungible: pallet_refungible::{Pallet, Storage} = 68,992 Nonfungible: pallet_nonfungible::{Pallet, Storage} = 69,993994 995 EVM: pallet_evm::{Pallet, Config, Call, Storage, Event<T>} = 100,996 Ethereum: pallet_ethereum::{Pallet, Config, Call, Storage, Event, Origin} = 101,997998 EvmCoderSubstrate: pallet_evm_coder_substrate::{Pallet, Storage} = 150,999 EvmContractHelpers: pallet_evm_contract_helpers::{Pallet, Storage} = 151,1000 EvmTransactionPayment: pallet_evm_transaction_payment::{Pallet} = 152,1001 EvmMigration: pallet_evm_migration::{Pallet, Call, Storage} = 153,1002 }1003);10041005pub struct TransactionConverter;10061007impl fp_rpc::ConvertTransaction<UncheckedExtrinsic> for TransactionConverter {1008 fn convert_transaction(&self, transaction: pallet_ethereum::Transaction) -> UncheckedExtrinsic {1009 UncheckedExtrinsic::new_unsigned(1010 pallet_ethereum::Call::<Runtime>::transact { transaction }.into(),1011 )1012 }1013}10141015impl fp_rpc::ConvertTransaction<opaque::UncheckedExtrinsic> for TransactionConverter {1016 fn convert_transaction(1017 &self,1018 transaction: pallet_ethereum::Transaction,1019 ) -> opaque::UncheckedExtrinsic {1020 let extrinsic = UncheckedExtrinsic::new_unsigned(1021 pallet_ethereum::Call::<Runtime>::transact { transaction }.into(),1022 );1023 let encoded = extrinsic.encode();1024 opaque::UncheckedExtrinsic::decode(&mut &encoded[..])1025 .expect("Encoded extrinsic is always valid")1026 }1027}102810291030pub type Address = sp_runtime::MultiAddress<AccountId, ()>;10311032pub type Header = generic::Header<BlockNumber, BlakeTwo256>;10331034pub type Block = generic::Block<Header, UncheckedExtrinsic>;10351036pub type SignedBlock = generic::SignedBlock<Block>;10371038pub type BlockId = generic::BlockId<Block>;10391040pub type SignedExtra = (1041 frame_system::CheckSpecVersion<Runtime>,1042 1043 frame_system::CheckGenesis<Runtime>,1044 frame_system::CheckEra<Runtime>,1045 frame_system::CheckNonce<Runtime>,1046 frame_system::CheckWeight<Runtime>,1047 pallet_charge_transaction::ChargeTransactionPayment<Runtime>,1048 1049);10501051pub type UncheckedExtrinsic =1052 fp_self_contained::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;10531054pub type CheckedExtrinsic = fp_self_contained::CheckedExtrinsic<AccountId, Call, SignedExtra, H160>;10551056pub type Executive = frame_executive::Executive<1057 Runtime,1058 Block,1059 frame_system::ChainContext<Runtime>,1060 Runtime,1061 AllPalletsReversedWithSystemFirst,1062>;10631064impl_opaque_keys! {1065 pub struct SessionKeys {1066 pub aura: Aura,1067 }1068}10691070impl fp_self_contained::SelfContainedCall for Call {1071 type SignedInfo = H160;10721073 fn is_self_contained(&self) -> bool {1074 match self {1075 Call::Ethereum(call) => call.is_self_contained(),1076 _ => false,1077 }1078 }10791080 fn check_self_contained(&self) -> Option<Result<Self::SignedInfo, TransactionValidityError>> {1081 match self {1082 Call::Ethereum(call) => call.check_self_contained(),1083 _ => None,1084 }1085 }10861087 fn validate_self_contained(&self, info: &Self::SignedInfo) -> Option<TransactionValidity> {1088 match self {1089 Call::Ethereum(call) => call.validate_self_contained(info),1090 _ => None,1091 }1092 }10931094 fn pre_dispatch_self_contained(1095 &self,1096 info: &Self::SignedInfo,1097 ) -> Option<Result<(), TransactionValidityError>> {1098 match self {1099 Call::Ethereum(call) => call.pre_dispatch_self_contained(info),1100 _ => None,1101 }1102 }11031104 fn apply_self_contained(1105 self,1106 info: Self::SignedInfo,1107 ) -> Option<sp_runtime::DispatchResultWithInfo<PostDispatchInfoOf<Self>>> {1108 match self {1109 call @ Call::Ethereum(pallet_ethereum::Call::transact { .. }) => Some(call.dispatch(1110 Origin::from(pallet_ethereum::RawOrigin::EthereumTransaction(info)),1111 )),1112 _ => None,1113 }1114 }1115}11161117macro_rules! dispatch_unique_runtime {1118 ($collection:ident.$method:ident($($name:ident),*)) => {{1119 use pallet_unique::dispatch::Dispatched;11201121 let collection = Dispatched::dispatch(<pallet_common::CollectionHandle<Runtime>>::try_get($collection)?);1122 let dispatch = collection.as_dyn();11231124 Ok(dispatch.$method($($name),*))1125 }};1126}11271128impl_common_runtime_apis!();11291130struct CheckInherents;11311132impl cumulus_pallet_parachain_system::CheckInherents<Block> for CheckInherents {1133 fn check_inherents(1134 block: &Block,1135 relay_state_proof: &cumulus_pallet_parachain_system::RelayChainStateProof,1136 ) -> sp_inherents::CheckInherentsResult {1137 let relay_chain_slot = relay_state_proof1138 .read_slot()1139 .expect("Could not read the relay chain slot from the proof");11401141 let inherent_data =1142 cumulus_primitives_timestamp::InherentDataProvider::from_relay_chain_slot_and_duration(1143 relay_chain_slot,1144 sp_std::time::Duration::from_secs(6),1145 )1146 .create_inherent_data()1147 .expect("Could not create the timestamp inherent data");11481149 inherent_data.check_extrinsics(block)1150 }1151}11521153cumulus_pallet_parachain_system::register_validate_block!(1154 Runtime = Runtime,1155 BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor::<Runtime, Executive>,1156 CheckInherents = CheckInherents,1157);