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_type,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,62 },63 weights::{64 constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND},65 DispatchClass, DispatchInfo, GetDispatchInfo, IdentityFee, Pays, PostDispatchInfo, Weight,66 WeightToFeePolynomial, WeightToFeeCoefficient, WeightToFeeCoefficients,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_evm::{Account as EVMAccount, FeeCalculator, GasWeightMapping, OnMethodCall};82use fp_rpc::TransactionStatus;83use sp_runtime::{84 traits::{BlockNumberProvider, Dispatchable, PostDispatchInfoOf, Saturating},85 transaction_validity::TransactionValidityError,86 SaturatedConversion,87};888990pub use sp_consensus_aura::sr25519::AuthorityId as AuraId;919293use pallet_xcm::XcmPassthrough;94use polkadot_parachain::primitives::Sibling;95use xcm::v1::{BodyId, Junction::*, MultiLocation, NetworkId, Junctions::*};96use xcm_builder::{97 AccountId32Aliases, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, CurrencyAdapter,98 EnsureXcmOrigin, FixedWeightBounds, LocationInverter, NativeAsset, ParentAsSuperuser,99 RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia,100 SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit,101 ParentIsPreset,102};103use xcm_executor::{Config, XcmExecutor, Assets};104use sp_std::{marker::PhantomData};105106use xcm::latest::{107 108 AssetId::{Concrete},109 Fungibility::Fungible as XcmFungible,110 MultiAsset,111 Error as XcmError,112};113use xcm_executor::traits::{MatchesFungible, WeightTrader};114115use sp_runtime::traits::CheckedConversion;116117use unique_runtime_common::{impl_common_runtime_apis, types::*, constants::*};118119pub const RUNTIME_NAME: &str = "Opal";120121type CrossAccountId = pallet_evm::account::BasicCrossAccountId<Runtime>;122123impl RuntimeInstance for Runtime {124 type CrossAccountId = self::CrossAccountId;125 type TransactionConverter = self::TransactionConverter;126127 fn get_transaction_converter() -> TransactionConverter {128 TransactionConverter129 }130}131132133134pub type AccountIndex = u32;135136137pub type Balance = u128;138139140pub type Index = u32;141142143pub type Hash = sp_core::H256;144145146pub type DigestItem = generic::DigestItem;147148149150151152pub mod opaque {153 use sp_std::prelude::*;154 use sp_runtime::impl_opaque_keys;155 use super::Aura;156157 pub use unique_runtime_common::types::*;158159 impl_opaque_keys! {160 pub struct SessionKeys {161 pub aura: Aura,162 }163 }164}165166167pub const VERSION: RuntimeVersion = RuntimeVersion {168 spec_name: create_runtime_str!(RUNTIME_NAME),169 impl_name: create_runtime_str!(RUNTIME_NAME),170 authoring_version: 1,171 spec_version: 917004,172 impl_version: 0,173 apis: RUNTIME_API_VERSIONS,174 transaction_version: 1,175 state_version: 0,176};177178#[derive(codec::Encode, codec::Decode)]179pub enum XCMPMessage<XAccountId, XBalance> {180 181 TransferToken(XAccountId, XBalance),182}183184185#[cfg(feature = "std")]186pub fn native_version() -> NativeVersion {187 NativeVersion {188 runtime_version: VERSION,189 can_author_with: Default::default(),190 }191}192193type NegativeImbalance = <Balances as Currency<AccountId>>::NegativeImbalance;194195pub struct DealWithFees;196impl OnUnbalanced<NegativeImbalance> for DealWithFees {197 fn on_unbalanceds<B>(mut fees_then_tips: impl Iterator<Item = NegativeImbalance>) {198 if let Some(fees) = fees_then_tips.next() {199 200 let mut split = fees.ration(100, 0);201 if let Some(tips) = fees_then_tips.next() {202 203 tips.ration_merge_into(100, 0, &mut split);204 }205 Treasury::on_unbalanced(split.0);206 207 }208 }209}210211parameter_types! {212 pub const BlockHashCount: BlockNumber = 2400;213 pub RuntimeBlockLength: BlockLength =214 BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);215 pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);216 pub const MaximumBlockLength: u32 = 5 * 1024 * 1024;217 pub RuntimeBlockWeights: BlockWeights = BlockWeights::builder()218 .base_block(BlockExecutionWeight::get())219 .for_class(DispatchClass::all(), |weights| {220 weights.base_extrinsic = ExtrinsicBaseWeight::get();221 })222 .for_class(DispatchClass::Normal, |weights| {223 weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT);224 })225 .for_class(DispatchClass::Operational, |weights| {226 weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT);227 228 229 weights.reserved = Some(230 MAXIMUM_BLOCK_WEIGHT - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT231 );232 })233 .avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO)234 .build_or_panic();235 pub const Version: RuntimeVersion = VERSION;236 pub const SS58Prefix: u8 = 42;237}238239parameter_types! {240 pub const ChainId: u64 = 8882;241}242243pub struct FixedFee;244impl FeeCalculator for FixedFee {245 fn min_gas_price() -> U256 {246 MIN_GAS_PRICE.into()247 }248}249250251252253parameter_types! {254 pub const WritesPerSecond: u64 = WEIGHT_PER_SECOND / <Runtime as frame_system::Config>::DbWeight::get().write;255 pub const GasPerSecond: u64 = WritesPerSecond::get() * 20000;256 pub const WeightPerGas: u64 = WEIGHT_PER_SECOND / GasPerSecond::get();257}258259260261262const EVM_DISPATCH_RATIO: Perbill = Perbill::from_percent(50);263parameter_types! {264 pub BlockGasLimit: U256 = U256::from(NORMAL_DISPATCH_RATIO * EVM_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT / WeightPerGas::get());265}266267pub enum FixedGasWeightMapping {}268impl GasWeightMapping for FixedGasWeightMapping {269 fn gas_to_weight(gas: u64) -> Weight {270 gas.saturating_mul(WeightPerGas::get())271 }272 fn weight_to_gas(weight: Weight) -> u64 {273 weight / WeightPerGas::get()274 }275}276277impl pallet_evm::account::Config for Runtime {278 type CrossAccountId = pallet_evm::account::BasicCrossAccountId<Self>;279 type EvmAddressMapping = pallet_evm::HashedAddressMapping<Self::Hashing>;280 type EvmBackwardsAddressMapping = fp_evm_mapping::MapBackwardsAddressTruncated;281}282283impl pallet_evm::Config for Runtime {284 type BlockGasLimit = BlockGasLimit;285 type FeeCalculator = FixedFee;286 type GasWeightMapping = FixedGasWeightMapping;287 type BlockHashMapping = pallet_ethereum::EthereumBlockHashMapping<Self>;288 type CallOrigin = EnsureAddressTruncated;289 type WithdrawOrigin = EnsureAddressTruncated;290 type AddressMapping = HashedAddressMapping<Self::Hashing>;291 type PrecompilesType = ();292 type PrecompilesValue = ();293 type Currency = Balances;294 type Event = Event;295 type OnMethodCall = (296 pallet_evm_migration::OnMethodCall<Self>,297 pallet_unique::UniqueErcSupport<Self>,298 pallet_evm_contract_helpers::HelpersOnMethodCall<Self>,299 );300 type OnCreate = pallet_evm_contract_helpers::HelpersOnCreate<Self>;301 type ChainId = ChainId;302 type Runner = pallet_evm::runner::stack::Runner<Self>;303 type OnChargeTransaction = pallet_evm_transaction_payment::OnChargeTransaction<Self>;304 type TransactionValidityHack = pallet_evm_transaction_payment::TransactionValidityHack<Self>;305 type FindAuthor = EthereumFindAuthor<Aura>;306}307308impl pallet_evm_migration::Config for Runtime {309 type WeightInfo = pallet_evm_migration::weights::SubstrateWeight<Self>;310}311312pub struct EthereumFindAuthor<F>(core::marker::PhantomData<F>);313impl<F: FindAuthor<u32>> FindAuthor<H160> for EthereumFindAuthor<F> {314 fn find_author<'a, I>(digests: I) -> Option<H160>315 where316 I: 'a + IntoIterator<Item = (ConsensusEngineId, &'a [u8])>,317 {318 if let Some(author_index) = F::find_author(digests) {319 let authority_id = Aura::authorities()[author_index as usize].clone();320 return Some(H160::from_slice(&authority_id.to_raw_vec()[4..24]));321 }322 None323 }324}325326impl pallet_ethereum::Config for Runtime {327 type Event = Event;328 type StateRoot = pallet_ethereum::IntermediateStateRoot;329}330331impl pallet_randomness_collective_flip::Config for Runtime {}332333impl frame_system::Config for Runtime {334 335 type AccountData = pallet_balances::AccountData<Balance>;336 337 type AccountId = AccountId;338 339 type BaseCallFilter = Everything;340 341 type BlockHashCount = BlockHashCount;342 343 type BlockLength = RuntimeBlockLength;344 345 type BlockNumber = BlockNumber;346 347 type BlockWeights = RuntimeBlockWeights;348 349 type Call = Call;350 351 type DbWeight = RocksDbWeight;352 353 type Event = Event;354 355 type Hash = Hash;356 357 type Hashing = BlakeTwo256;358 359 type Header = generic::Header<BlockNumber, BlakeTwo256>;360 361 type Index = Index;362 363 type Lookup = AccountIdLookup<AccountId, ()>;364 365 type OnKilledAccount = ();366 367 type OnNewAccount = ();368 type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode<Self>;369 370 type Origin = Origin;371 372 type PalletInfo = PalletInfo;373 374 type SS58Prefix = SS58Prefix;375 376 type SystemWeightInfo = frame_system::weights::SubstrateWeight<Self>;377 378 type Version = Version;379 type MaxConsumers = ConstU32<16>;380}381382parameter_types! {383 pub const MinimumPeriod: u64 = SLOT_DURATION / 2;384}385386impl pallet_timestamp::Config for Runtime {387 388 type Moment = u64;389 type OnTimestampSet = ();390 type MinimumPeriod = MinimumPeriod;391 type WeightInfo = ();392}393394parameter_types! {395 396 pub const ExistentialDeposit: u128 = 0;397 pub const MaxLocks: u32 = 50;398}399400impl pallet_balances::Config for Runtime {401 type MaxLocks = MaxLocks;402 type MaxReserves = ();403 type ReserveIdentifier = [u8; 8];404 405 type Balance = Balance;406 407 type Event = Event;408 type DustRemoval = Treasury;409 type ExistentialDeposit = ExistentialDeposit;410 type AccountStore = System;411 type WeightInfo = pallet_balances::weights::SubstrateWeight<Self>;412}413414pub const fn deposit(items: u32, bytes: u32) -> Balance {415 items as Balance * 15 * CENTIUNIQUE + (bytes as Balance) * 6 * CENTIUNIQUE416}417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468parameter_types! {469 470 471 pub const OperationalFeeMultiplier: u8 = 5;472}473474475pub struct LinearFee<T>(sp_std::marker::PhantomData<T>);476477impl<T> WeightToFeePolynomial for LinearFee<T>478where479 T: BaseArithmetic + From<u32> + Copy + Unsigned,480{481 type Balance = T;482483 fn polynomial() -> WeightToFeeCoefficients<Self::Balance> {484 smallvec!(WeightToFeeCoefficient {485 486 coeff_integer: WEIGHT_TO_FEE_COEFF.into(),487 coeff_frac: Perbill::zero(),488 negative: false,489 degree: 1,490 })491 }492}493494impl pallet_transaction_payment::Config for Runtime {495 type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter<Balances, DealWithFees>;496 type TransactionByteFee = TransactionByteFee;497 type OperationalFeeMultiplier = OperationalFeeMultiplier;498 type WeightToFee = LinearFee<Balance>;499 type FeeMultiplierUpdate = ();500}501502parameter_types! {503 pub const ProposalBond: Permill = Permill::from_percent(5);504 pub const ProposalBondMinimum: Balance = 1 * UNIQUE;505 pub const ProposalBondMaximum: Balance = 1000 * UNIQUE;506 pub const SpendPeriod: BlockNumber = 5 * MINUTES;507 pub const Burn: Permill = Permill::from_percent(0);508 pub const TipCountdown: BlockNumber = 1 * DAYS;509 pub const TipFindersFee: Percent = Percent::from_percent(20);510 pub const TipReportDepositBase: Balance = 1 * UNIQUE;511 pub const DataDepositPerByte: Balance = 1 * CENTIUNIQUE;512 pub const BountyDepositBase: Balance = 1 * UNIQUE;513 pub const BountyDepositPayoutDelay: BlockNumber = 1 * DAYS;514 pub const TreasuryModuleId: PalletId = PalletId(*b"py/trsry");515 pub const BountyUpdatePeriod: BlockNumber = 14 * DAYS;516 pub const MaximumReasonLength: u32 = 16384;517 pub const BountyCuratorDeposit: Permill = Permill::from_percent(50);518 pub const BountyValueMinimum: Balance = 5 * UNIQUE;519 pub const MaxApprovals: u32 = 100;520}521522impl pallet_treasury::Config for Runtime {523 type PalletId = TreasuryModuleId;524 type Currency = Balances;525 type ApproveOrigin = EnsureRoot<AccountId>;526 type RejectOrigin = EnsureRoot<AccountId>;527 type Event = Event;528 type OnSlash = ();529 type ProposalBond = ProposalBond;530 type ProposalBondMinimum = ProposalBondMinimum;531 type ProposalBondMaximum = ProposalBondMaximum;532 type SpendPeriod = SpendPeriod;533 type Burn = Burn;534 type BurnDestination = ();535 type SpendFunds = ();536 type WeightInfo = pallet_treasury::weights::SubstrateWeight<Self>;537 type MaxApprovals = MaxApprovals;538}539540impl pallet_sudo::Config for Runtime {541 type Event = Event;542 type Call = Call;543}544545pub struct RelayChainBlockNumberProvider<T>(sp_std::marker::PhantomData<T>);546547impl<T: cumulus_pallet_parachain_system::Config> BlockNumberProvider548 for RelayChainBlockNumberProvider<T>549{550 type BlockNumber = BlockNumber;551552 fn current_block_number() -> Self::BlockNumber {553 cumulus_pallet_parachain_system::Pallet::<T>::validation_data()554 .map(|d| d.relay_parent_number)555 .unwrap_or_default()556 }557}558559parameter_types! {560 pub const MinVestedTransfer: Balance = 10 * UNIQUE;561 pub const MaxVestingSchedules: u32 = 28;562}563564impl orml_vesting::Config for Runtime {565 type Event = Event;566 type Currency = pallet_balances::Pallet<Runtime>;567 type MinVestedTransfer = MinVestedTransfer;568 type VestedTransferOrigin = EnsureSigned<AccountId>;569 type WeightInfo = ();570 type MaxVestingSchedules = MaxVestingSchedules;571 type BlockNumberProvider = RelayChainBlockNumberProvider<Runtime>;572}573574parameter_types! {575 pub const ReservedDmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;576 pub const ReservedXcmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;577}578579impl cumulus_pallet_parachain_system::Config for Runtime {580 type Event = Event;581 type SelfParaId = parachain_info::Pallet<Self>;582 type OnSystemEvent = ();583 584 585 586 587 588 type OutboundXcmpMessageSource = XcmpQueue;589 type DmpMessageHandler = DmpQueue;590 type ReservedDmpWeight = ReservedDmpWeight;591 type ReservedXcmpWeight = ReservedXcmpWeight;592 type XcmpMessageHandler = XcmpQueue;593}594595impl parachain_info::Config for Runtime {}596597impl cumulus_pallet_aura_ext::Config for Runtime {}598599parameter_types! {600 pub const RelayLocation: MultiLocation = MultiLocation::parent();601 pub const RelayNetwork: NetworkId = NetworkId::Polkadot;602 pub RelayOrigin: Origin = cumulus_pallet_xcm::Origin::Relay.into();603 pub Ancestry: MultiLocation = Parachain(ParachainInfo::parachain_id().into()).into();604}605606607608609pub type LocationToAccountId = (610 611 ParentIsPreset<AccountId>,612 613 SiblingParachainConvertsVia<Sibling, AccountId>,614 615 AccountId32Aliases<RelayNetwork, AccountId>,616);617618pub struct OnlySelfCurrency;619impl<B: TryFrom<u128>> MatchesFungible<B> for OnlySelfCurrency {620 fn matches_fungible(a: &MultiAsset) -> Option<B> {621 match (&a.id, &a.fun) {622 (Concrete(_), XcmFungible(ref amount)) => CheckedConversion::checked_from(*amount),623 _ => None,624 }625 }626}627628629pub type LocalAssetTransactor = CurrencyAdapter<630 631 Balances,632 633 OnlySelfCurrency,634 635 LocationToAccountId,636 637 AccountId,638 639 (),640>;641642643644645pub type XcmOriginToTransactDispatchOrigin = (646 647 648 649 SovereignSignedViaLocation<LocationToAccountId, Origin>,650 651 652 RelayChainAsNative<RelayOrigin, Origin>,653 654 655 SiblingParachainAsNative<cumulus_pallet_xcm::Origin, Origin>,656 657 658 ParentAsSuperuser<Origin>,659 660 661 SignedAccountId32AsNative<RelayNetwork, Origin>,662 663 XcmPassthrough<Origin>,664);665666parameter_types! {667 668 pub UnitWeightCost: Weight = 1_000_000;669 670 pub const WeightPrice: (MultiLocation, u128) = (MultiLocation::parent(), 1_200 * UNIQUE);671 pub const MaxInstructions: u32 = 100;672 pub const MaxAuthorities: u32 = 100_000;673}674675match_type! {676 pub type ParentOrParentsUnitPlurality: impl Contains<MultiLocation> = {677 MultiLocation { parents: 1, interior: Here } |678 MultiLocation { parents: 1, interior: X1(Plurality { id: BodyId::Unit, .. }) }679 };680}681682pub type Barrier = (683 TakeWeightCredit,684 AllowTopLevelPaidExecutionFrom<Everything>,685 AllowUnpaidExecutionFrom<ParentOrParentsUnitPlurality>,686 687);688689pub struct UsingOnlySelfCurrencyComponents<690 WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,691 AssetId: Get<MultiLocation>,692 AccountId,693 Currency: CurrencyT<AccountId>,694 OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,695>(696 Weight,697 Currency::Balance,698 PhantomData<(WeightToFee, AssetId, AccountId, Currency, OnUnbalanced)>,699);700impl<701 WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,702 AssetId: Get<MultiLocation>,703 AccountId,704 Currency: CurrencyT<AccountId>,705 OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,706 > WeightTrader707 for UsingOnlySelfCurrencyComponents<WeightToFee, AssetId, AccountId, Currency, OnUnbalanced>708{709 fn new() -> Self {710 Self(0, Zero::zero(), PhantomData)711 }712713 fn buy_weight(&mut self, weight: Weight, payment: Assets) -> Result<Assets, XcmError> {714 let amount = WeightToFee::calc(&weight);715 let u128_amount: u128 = amount.try_into().map_err(|_| XcmError::Overflow)?;716717 718 let option1: xcm::v1::AssetId = Concrete(MultiLocation {719 parents: 1,720 interior: X1(Parachain(ParachainInfo::parachain_id().into())),721 });722 723 let option2: xcm::v1::AssetId = Concrete(MultiLocation {724 parents: 0,725 interior: Here,726 });727728 let required = if payment.fungible.contains_key(&option1) {729 (option1, u128_amount).into()730 } else if payment.fungible.contains_key(&option2) {731 (option2, u128_amount).into()732 } else {733 (Concrete(MultiLocation::default()), u128_amount).into()734 };735736 let unused = payment737 .checked_sub(required)738 .map_err(|_| XcmError::TooExpensive)?;739 self.0 = self.0.saturating_add(weight);740 self.1 = self.1.saturating_add(amount);741 Ok(unused)742 }743744 fn refund_weight(&mut self, weight: Weight) -> Option<MultiAsset> {745 let weight = weight.min(self.0);746 let amount = WeightToFee::calc(&weight);747 self.0 -= weight;748 self.1 = self.1.saturating_sub(amount);749 let amount: u128 = amount.saturated_into();750 if amount > 0 {751 Some((AssetId::get(), amount).into())752 } else {753 None754 }755 }756}757impl<758 WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,759 AssetId: Get<MultiLocation>,760 AccountId,761 Currency: CurrencyT<AccountId>,762 OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,763 > Drop764 for UsingOnlySelfCurrencyComponents<WeightToFee, AssetId, AccountId, Currency, OnUnbalanced>765{766 fn drop(&mut self) {767 OnUnbalanced::on_unbalanced(Currency::issue(self.1));768 }769}770771pub struct XcmConfig;772impl Config for XcmConfig {773 type Call = Call;774 type XcmSender = XcmRouter;775 776 type AssetTransactor = LocalAssetTransactor;777 type OriginConverter = XcmOriginToTransactDispatchOrigin;778 type IsReserve = NativeAsset;779 type IsTeleporter = (); 780 type LocationInverter = LocationInverter<Ancestry>;781 type Barrier = Barrier;782 type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;783 type Trader = UsingOnlySelfCurrencyComponents<784 IdentityFee<Balance>,785 RelayLocation,786 AccountId,787 Balances,788 (),789 >;790 type ResponseHandler = (); 791 type SubscriptionService = PolkadotXcm;792793 type AssetTrap = PolkadotXcm;794 type AssetClaims = PolkadotXcm;795}796797798799800801802pub type LocalOriginToLocation = (SignedToAccountId32<Origin, AccountId, RelayNetwork>,);803804805806pub type XcmRouter = (807 808 cumulus_primitives_utility::ParentAsUmp<ParachainSystem, ()>,809 810 XcmpQueue,811);812813impl pallet_evm_coder_substrate::Config for Runtime {814 type EthereumTransactionSender = pallet_ethereum::Pallet<Self>;815 type GasWeightMapping = FixedGasWeightMapping;816}817818impl pallet_xcm::Config for Runtime {819 type Event = Event;820 type SendXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;821 type XcmRouter = XcmRouter;822 type ExecuteXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;823 type XcmExecuteFilter = Everything;824 type XcmExecutor = XcmExecutor<XcmConfig>;825 type XcmTeleportFilter = Everything;826 type XcmReserveTransferFilter = Everything;827 type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;828 type LocationInverter = LocationInverter<Ancestry>;829 type Origin = Origin;830 type Call = Call;831 const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;832 type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;833}834835impl cumulus_pallet_xcm::Config for Runtime {836 type Event = Event;837 type XcmExecutor = XcmExecutor<XcmConfig>;838}839840impl cumulus_pallet_xcmp_queue::Config for Runtime {841 type WeightInfo = ();842 type Event = Event;843 type XcmExecutor = XcmExecutor<XcmConfig>;844 type ChannelInfo = ParachainSystem;845 type VersionWrapper = ();846 type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;847 type ControllerOrigin = EnsureRoot<AccountId>;848 type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin;849}850851impl cumulus_pallet_dmp_queue::Config for Runtime {852 type Event = Event;853 type XcmExecutor = XcmExecutor<XcmConfig>;854 type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;855}856857impl pallet_aura::Config for Runtime {858 type AuthorityId = AuraId;859 type DisabledValidators = ();860 type MaxAuthorities = MaxAuthorities;861}862863parameter_types! {864 pub TreasuryAccountId: AccountId = TreasuryModuleId::get().into_account();865 pub const CollectionCreationPrice: Balance = 2 * UNIQUE;866}867868impl pallet_common::Config for Runtime {869 type Event = Event;870 type Currency = Balances;871 type CollectionCreationPrice = CollectionCreationPrice;872 type TreasuryAccountId = TreasuryAccountId;873}874875impl pallet_fungible::Config for Runtime {876 type WeightInfo = pallet_fungible::weights::SubstrateWeight<Self>;877}878impl pallet_refungible::Config for Runtime {879 type WeightInfo = pallet_refungible::weights::SubstrateWeight<Self>;880}881impl pallet_nonfungible::Config for Runtime {882 type WeightInfo = pallet_nonfungible::weights::SubstrateWeight<Self>;883}884885impl pallet_unique::Config for Runtime {886 type Event = Event;887 type WeightInfo = pallet_unique::weights::SubstrateWeight<Self>;888}889890parameter_types! {891 pub const InflationBlockInterval: BlockNumber = 100; 892}893894895impl pallet_inflation::Config for Runtime {896 type Currency = Balances;897 type TreasuryAccountId = TreasuryAccountId;898 type InflationBlockInterval = InflationBlockInterval;899 type BlockNumberProvider = RelayChainBlockNumberProvider<Runtime>;900}901902903904905906907908type EvmSponsorshipHandler = (909 pallet_unique::UniqueEthSponsorshipHandler<Runtime>,910 pallet_evm_contract_helpers::HelpersContractSponsoring<Runtime>,911);912type SponsorshipHandler = (913 pallet_unique::UniqueSponsorshipHandler<Runtime>,914 915 pallet_evm_transaction_payment::BridgeSponsorshipHandler<Runtime>,916);917918919920921922923924925926927928929930impl pallet_evm_transaction_payment::Config for Runtime {931 type EvmSponsorshipHandler = EvmSponsorshipHandler;932 type Currency = Balances;933}934935impl pallet_charge_transaction::Config for Runtime {936 type SponsorshipHandler = SponsorshipHandler;937}938939940941942943parameter_types! {944 945 pub const HelpersContractAddress: H160 = H160([946 0x84, 0x28, 0x99, 0xec, 0xf3, 0x80, 0x55, 0x3e, 0x8a, 0x4d, 0xe7, 0x5b, 0xf5, 0x34, 0xcd, 0xf6, 0xfb, 0xf6, 0x40, 0x49,947 ]);948}949950impl pallet_evm_contract_helpers::Config for Runtime {951 type ContractAddress = HelpersContractAddress;952 type DefaultSponsoringRateLimit = DefaultSponsoringRateLimit;953}954955construct_runtime!(956 pub enum Runtime where957 Block = Block,958 NodeBlock = opaque::Block,959 UncheckedExtrinsic = UncheckedExtrinsic960 {961 ParachainSystem: cumulus_pallet_parachain_system::{Pallet, Call, Config, Storage, Inherent, Event<T>, ValidateUnsigned} = 20,962 ParachainInfo: parachain_info::{Pallet, Storage, Config} = 21,963964 Aura: pallet_aura::{Pallet, Config<T>} = 22,965 AuraExt: cumulus_pallet_aura_ext::{Pallet, Config} = 23,966967 Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>} = 30,968 RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Pallet, Storage} = 31,969 Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent} = 32,970 TransactionPayment: pallet_transaction_payment::{Pallet, Storage} = 33,971 Treasury: pallet_treasury::{Pallet, Call, Storage, Config, Event<T>} = 34,972 Sudo: pallet_sudo::{Pallet, Call, Storage, Config<T>, Event<T>} = 35,973 System: frame_system::{Pallet, Call, Storage, Config, Event<T>} = 36,974 Vesting: orml_vesting::{Pallet, Storage, Call, Event<T>, Config<T>} = 37,975 976 977978 979 XcmpQueue: cumulus_pallet_xcmp_queue::{Pallet, Call, Storage, Event<T>} = 50,980 PolkadotXcm: pallet_xcm::{Pallet, Call, Event<T>, Origin} = 51,981 CumulusXcm: cumulus_pallet_xcm::{Pallet, Call, Event<T>, Origin} = 52,982 DmpQueue: cumulus_pallet_dmp_queue::{Pallet, Call, Storage, Event<T>} = 53,983984 985 Inflation: pallet_inflation::{Pallet, Call, Storage} = 60,986 Unique: pallet_unique::{Pallet, Call, Storage, Event<T>} = 61,987 988 989 Charging: pallet_charge_transaction::{Pallet, Call, Storage } = 64,990 991 Common: pallet_common::{Pallet, Storage, Event<T>} = 66,992 Fungible: pallet_fungible::{Pallet, Storage} = 67,993 Refungible: pallet_refungible::{Pallet, Storage} = 68,994 Nonfungible: pallet_nonfungible::{Pallet, Storage} = 69,995996 997 EVM: pallet_evm::{Pallet, Config, Call, Storage, Event<T>} = 100,998 Ethereum: pallet_ethereum::{Pallet, Config, Call, Storage, Event, Origin} = 101,9991000 EvmCoderSubstrate: pallet_evm_coder_substrate::{Pallet, Storage} = 150,1001 EvmContractHelpers: pallet_evm_contract_helpers::{Pallet, Storage} = 151,1002 EvmTransactionPayment: pallet_evm_transaction_payment::{Pallet} = 152,1003 EvmMigration: pallet_evm_migration::{Pallet, Call, Storage} = 153,1004 }1005);10061007pub struct TransactionConverter;10081009impl fp_rpc::ConvertTransaction<UncheckedExtrinsic> for TransactionConverter {1010 fn convert_transaction(&self, transaction: pallet_ethereum::Transaction) -> UncheckedExtrinsic {1011 UncheckedExtrinsic::new_unsigned(1012 pallet_ethereum::Call::<Runtime>::transact { transaction }.into(),1013 )1014 }1015}10161017impl fp_rpc::ConvertTransaction<opaque::UncheckedExtrinsic> for TransactionConverter {1018 fn convert_transaction(1019 &self,1020 transaction: pallet_ethereum::Transaction,1021 ) -> opaque::UncheckedExtrinsic {1022 let extrinsic = UncheckedExtrinsic::new_unsigned(1023 pallet_ethereum::Call::<Runtime>::transact { transaction }.into(),1024 );1025 let encoded = extrinsic.encode();1026 opaque::UncheckedExtrinsic::decode(&mut &encoded[..])1027 .expect("Encoded extrinsic is always valid")1028 }1029}103010311032pub type Address = sp_runtime::MultiAddress<AccountId, ()>;10331034pub type Header = generic::Header<BlockNumber, BlakeTwo256>;10351036pub type Block = generic::Block<Header, UncheckedExtrinsic>;10371038pub type SignedBlock = generic::SignedBlock<Block>;10391040pub type BlockId = generic::BlockId<Block>;10411042pub type SignedExtra = (1043 frame_system::CheckSpecVersion<Runtime>,1044 1045 frame_system::CheckGenesis<Runtime>,1046 frame_system::CheckEra<Runtime>,1047 frame_system::CheckNonce<Runtime>,1048 frame_system::CheckWeight<Runtime>,1049 pallet_charge_transaction::ChargeTransactionPayment<Runtime>,1050 1051);10521053pub type UncheckedExtrinsic =1054 fp_self_contained::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;10551056pub type CheckedExtrinsic = fp_self_contained::CheckedExtrinsic<AccountId, Call, SignedExtra, H160>;10571058pub type Executive = frame_executive::Executive<1059 Runtime,1060 Block,1061 frame_system::ChainContext<Runtime>,1062 Runtime,1063 AllPalletsReversedWithSystemFirst,1064>;10651066impl_opaque_keys! {1067 pub struct SessionKeys {1068 pub aura: Aura,1069 }1070}10711072impl fp_self_contained::SelfContainedCall for Call {1073 type SignedInfo = H160;10741075 fn is_self_contained(&self) -> bool {1076 match self {1077 Call::Ethereum(call) => call.is_self_contained(),1078 _ => false,1079 }1080 }10811082 fn check_self_contained(&self) -> Option<Result<Self::SignedInfo, TransactionValidityError>> {1083 match self {1084 Call::Ethereum(call) => call.check_self_contained(),1085 _ => None,1086 }1087 }10881089 fn validate_self_contained(&self, info: &Self::SignedInfo) -> Option<TransactionValidity> {1090 match self {1091 Call::Ethereum(call) => call.validate_self_contained(info),1092 _ => None,1093 }1094 }10951096 fn pre_dispatch_self_contained(1097 &self,1098 info: &Self::SignedInfo,1099 ) -> Option<Result<(), TransactionValidityError>> {1100 match self {1101 Call::Ethereum(call) => call.pre_dispatch_self_contained(info),1102 _ => None,1103 }1104 }11051106 fn apply_self_contained(1107 self,1108 info: Self::SignedInfo,1109 ) -> Option<sp_runtime::DispatchResultWithInfo<PostDispatchInfoOf<Self>>> {1110 match self {1111 call @ Call::Ethereum(pallet_ethereum::Call::transact { .. }) => Some(call.dispatch(1112 Origin::from(pallet_ethereum::RawOrigin::EthereumTransaction(info)),1113 )),1114 _ => None,1115 }1116 }1117}11181119macro_rules! dispatch_unique_runtime {1120 ($collection:ident.$method:ident($($name:ident),*)) => {{1121 use pallet_unique::dispatch::Dispatched;11221123 let collection = Dispatched::dispatch(<pallet_common::CollectionHandle<Runtime>>::try_get($collection)?);1124 let dispatch = collection.as_dyn();11251126 Ok(dispatch.$method($($name),*))1127 }};1128}11291130impl_common_runtime_apis!();11311132struct CheckInherents;11331134impl cumulus_pallet_parachain_system::CheckInherents<Block> for CheckInherents {1135 fn check_inherents(1136 block: &Block,1137 relay_state_proof: &cumulus_pallet_parachain_system::RelayChainStateProof,1138 ) -> sp_inherents::CheckInherentsResult {1139 let relay_chain_slot = relay_state_proof1140 .read_slot()1141 .expect("Could not read the relay chain slot from the proof");11421143 let inherent_data =1144 cumulus_primitives_timestamp::InherentDataProvider::from_relay_chain_slot_and_duration(1145 relay_chain_slot,1146 sp_std::time::Duration::from_secs(6),1147 )1148 .create_inherent_data()1149 .expect("Could not create the timestamp inherent data");11501151 inherent_data.check_extrinsics(block)1152 }1153}11541155cumulus_pallet_parachain_system::register_validate_block!(1156 Runtime = Runtime,1157 BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor::<Runtime, Executive>,1158 CheckInherents = CheckInherents,1159);