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_common::account::BasicCrossAccountId<Runtime>;120121impl RuntimeInstance for Runtime {122 type CrossAccountId = self::CrossAccountId;123124 type TransactionConverter = self::TransactionConverter;125126 fn get_transaction_converter() -> TransactionConverter {127 TransactionConverter128 }129}130131132133134135pub mod opaque {136 use sp_std::prelude::*;137 use sp_runtime::impl_opaque_keys;138 use super::Aura;139140 pub use unique_runtime_common::types::*;141142 impl_opaque_keys! {143 pub struct SessionKeys {144 pub aura: Aura,145 }146 }147}148149150pub const VERSION: RuntimeVersion = RuntimeVersion {151 spec_name: create_runtime_str!(RUNTIME_NAME),152 impl_name: create_runtime_str!(RUNTIME_NAME),153 authoring_version: 1,154 spec_version: 918000,155 impl_version: 0,156 apis: RUNTIME_API_VERSIONS,157 transaction_version: 1,158 state_version: 0,159};160161#[derive(codec::Encode, codec::Decode)]162pub enum XCMPMessage<XAccountId, XBalance> {163 164 TransferToken(XAccountId, XBalance),165}166167168#[cfg(feature = "std")]169pub fn native_version() -> NativeVersion {170 NativeVersion {171 runtime_version: VERSION,172 can_author_with: Default::default(),173 }174}175176type NegativeImbalance = <Balances as Currency<AccountId>>::NegativeImbalance;177178pub struct DealWithFees;179impl OnUnbalanced<NegativeImbalance> for DealWithFees {180 fn on_unbalanceds<B>(mut fees_then_tips: impl Iterator<Item = NegativeImbalance>) {181 if let Some(fees) = fees_then_tips.next() {182 183 let mut split = fees.ration(100, 0);184 if let Some(tips) = fees_then_tips.next() {185 186 tips.ration_merge_into(100, 0, &mut split);187 }188 Treasury::on_unbalanced(split.0);189 190 }191 }192}193194parameter_types! {195 pub const BlockHashCount: BlockNumber = 2400;196 pub RuntimeBlockLength: BlockLength =197 BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);198 pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);199 pub const MaximumBlockLength: u32 = 5 * 1024 * 1024;200 pub RuntimeBlockWeights: BlockWeights = BlockWeights::builder()201 .base_block(BlockExecutionWeight::get())202 .for_class(DispatchClass::all(), |weights| {203 weights.base_extrinsic = ExtrinsicBaseWeight::get();204 })205 .for_class(DispatchClass::Normal, |weights| {206 weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT);207 })208 .for_class(DispatchClass::Operational, |weights| {209 weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT);210 211 212 weights.reserved = Some(213 MAXIMUM_BLOCK_WEIGHT - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT214 );215 })216 .avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO)217 .build_or_panic();218 pub const Version: RuntimeVersion = VERSION;219 220221222223 pub const SS58Prefix: u8 = 255;224}225226parameter_types! {227 pub const ChainId: u64 = 8881;228}229230pub struct FixedFee;231impl FeeCalculator for FixedFee {232 fn min_gas_price() -> U256 {233 MIN_GAS_PRICE.into()234 }235}236237238239240parameter_types! {241 pub const WritesPerSecond: u64 = WEIGHT_PER_SECOND / <Runtime as frame_system::Config>::DbWeight::get().write;242 pub const GasPerSecond: u64 = WritesPerSecond::get() * 20000;243 pub const WeightPerGas: u64 = WEIGHT_PER_SECOND / GasPerSecond::get();244}245246247248249const EVM_DISPATCH_RATIO: Perbill = Perbill::from_percent(50);250parameter_types! {251 pub BlockGasLimit: U256 = U256::from(NORMAL_DISPATCH_RATIO * EVM_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT / WeightPerGas::get());252}253254pub enum FixedGasWeightMapping {}255impl GasWeightMapping for FixedGasWeightMapping {256 fn gas_to_weight(gas: u64) -> Weight {257 gas.saturating_mul(WeightPerGas::get())258 }259 fn weight_to_gas(weight: Weight) -> u64 {260 weight / WeightPerGas::get()261 }262}263264impl pallet_evm::Config for Runtime {265 type BlockGasLimit = BlockGasLimit;266 type FeeCalculator = FixedFee;267 type GasWeightMapping = FixedGasWeightMapping;268 type BlockHashMapping = pallet_ethereum::EthereumBlockHashMapping<Self>;269 type CallOrigin = EnsureAddressTruncated;270 type WithdrawOrigin = EnsureAddressTruncated;271 type AddressMapping = HashedAddressMapping<Self::Hashing>;272 type PrecompilesType = ();273 type PrecompilesValue = ();274 type Currency = Balances;275 type Event = Event;276 type OnMethodCall = (277 pallet_evm_migration::OnMethodCall<Self>,278 pallet_unique::UniqueErcSupport<Self>,279 pallet_evm_contract_helpers::HelpersOnMethodCall<Self>,280 );281 type OnCreate = pallet_evm_contract_helpers::HelpersOnCreate<Self>;282 type ChainId = ChainId;283 type Runner = pallet_evm::runner::stack::Runner<Self>;284 type OnChargeTransaction = pallet_evm_transaction_payment::OnChargeTransaction<Self>;285 type TransactionValidityHack = pallet_evm_transaction_payment::TransactionValidityHack<Self>;286 type FindAuthor = EthereumFindAuthor<Aura>;287}288289impl pallet_evm_migration::Config for Runtime {290 type WeightInfo = pallet_evm_migration::weights::SubstrateWeight<Self>;291}292293pub struct EthereumFindAuthor<F>(core::marker::PhantomData<F>);294impl<F: FindAuthor<u32>> FindAuthor<H160> for EthereumFindAuthor<F> {295 fn find_author<'a, I>(digests: I) -> Option<H160>296 where297 I: 'a + IntoIterator<Item = (ConsensusEngineId, &'a [u8])>,298 {299 if let Some(author_index) = F::find_author(digests) {300 let authority_id = Aura::authorities()[author_index as usize].clone();301 return Some(H160::from_slice(&authority_id.to_raw_vec()[4..24]));302 }303 None304 }305}306307impl pallet_ethereum::Config for Runtime {308 type Event = Event;309 type StateRoot = pallet_ethereum::IntermediateStateRoot;310}311312impl pallet_randomness_collective_flip::Config for Runtime {}313314impl frame_system::Config for Runtime {315 316 type AccountData = pallet_balances::AccountData<Balance>;317 318 type AccountId = AccountId;319 320 type BaseCallFilter = Everything;321 322 type BlockHashCount = BlockHashCount;323 324 type BlockLength = RuntimeBlockLength;325 326 type BlockNumber = BlockNumber;327 328 type BlockWeights = RuntimeBlockWeights;329 330 type Call = Call;331 332 type DbWeight = RocksDbWeight;333 334 type Event = Event;335 336 type Hash = Hash;337 338 type Hashing = BlakeTwo256;339 340 type Header = generic::Header<BlockNumber, BlakeTwo256>;341 342 type Index = Index;343 344 type Lookup = AccountIdLookup<AccountId, ()>;345 346 type OnKilledAccount = ();347 348 type OnNewAccount = ();349 type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode<Self>;350 351 type Origin = Origin;352 353 type PalletInfo = PalletInfo;354 355 type SS58Prefix = SS58Prefix;356 357 type SystemWeightInfo = frame_system::weights::SubstrateWeight<Self>;358 359 type Version = Version;360 type MaxConsumers = ConstU32<16>;361}362363parameter_types! {364 pub const MinimumPeriod: u64 = SLOT_DURATION / 2;365}366367impl pallet_timestamp::Config for Runtime {368 369 type Moment = u64;370 type OnTimestampSet = ();371 type MinimumPeriod = MinimumPeriod;372 type WeightInfo = ();373}374375parameter_types! {376 377 pub const ExistentialDeposit: u128 = 0;378 pub const MaxLocks: u32 = 50;379}380381impl pallet_balances::Config for Runtime {382 type MaxLocks = MaxLocks;383 type MaxReserves = ();384 type ReserveIdentifier = [u8; 8];385 386 type Balance = Balance;387 388 type Event = Event;389 type DustRemoval = Treasury;390 type ExistentialDeposit = ExistentialDeposit;391 type AccountStore = System;392 type WeightInfo = pallet_balances::weights::SubstrateWeight<Self>;393}394395pub const fn deposit(items: u32, bytes: u32) -> Balance {396 items as Balance * 15 * CENTIUNIQUE + (bytes as Balance) * 6 * CENTIUNIQUE397}398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449parameter_types! {450 451 452 pub const OperationalFeeMultiplier: u8 = 5;453}454455456pub struct LinearFee<T>(sp_std::marker::PhantomData<T>);457458impl<T> WeightToFeePolynomial for LinearFee<T>459where460 T: BaseArithmetic + From<u32> + Copy + Unsigned,461{462 type Balance = T;463464 fn polynomial() -> WeightToFeeCoefficients<Self::Balance> {465 smallvec!(WeightToFeeCoefficient {466 467 coeff_integer: WEIGHT_TO_FEE_COEFF.into(),468 coeff_frac: Perbill::zero(),469 negative: false,470 degree: 1,471 })472 }473}474475impl pallet_transaction_payment::Config for Runtime {476 type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter<Balances, DealWithFees>;477 type TransactionByteFee = TransactionByteFee;478 type OperationalFeeMultiplier = OperationalFeeMultiplier;479 type WeightToFee = LinearFee<Balance>;480 type FeeMultiplierUpdate = ();481}482483parameter_types! {484 pub const ProposalBond: Permill = Permill::from_percent(5);485 pub const ProposalBondMinimum: Balance = 1 * UNIQUE;486 pub const ProposalBondMaximum: Balance = 1000 * UNIQUE;487 pub const SpendPeriod: BlockNumber = 5 * MINUTES;488 pub const Burn: Permill = Permill::from_percent(0);489 pub const TipCountdown: BlockNumber = 1 * DAYS;490 pub const TipFindersFee: Percent = Percent::from_percent(20);491 pub const TipReportDepositBase: Balance = 1 * UNIQUE;492 pub const DataDepositPerByte: Balance = 1 * CENTIUNIQUE;493 pub const BountyDepositBase: Balance = 1 * UNIQUE;494 pub const BountyDepositPayoutDelay: BlockNumber = 1 * DAYS;495 pub const TreasuryModuleId: PalletId = PalletId(*b"py/trsry");496 pub const BountyUpdatePeriod: BlockNumber = 14 * DAYS;497 pub const MaximumReasonLength: u32 = 16384;498 pub const BountyCuratorDeposit: Permill = Permill::from_percent(50);499 pub const BountyValueMinimum: Balance = 5 * UNIQUE;500 pub const MaxApprovals: u32 = 100;501}502503impl pallet_treasury::Config for Runtime {504 type PalletId = TreasuryModuleId;505 type Currency = Balances;506 type ApproveOrigin = EnsureRoot<AccountId>;507 type RejectOrigin = EnsureRoot<AccountId>;508 type Event = Event;509 type OnSlash = ();510 type ProposalBond = ProposalBond;511 type ProposalBondMinimum = ProposalBondMinimum;512 type ProposalBondMaximum = ProposalBondMaximum;513 type SpendPeriod = SpendPeriod;514 type Burn = Burn;515 type BurnDestination = ();516 type SpendFunds = ();517 type WeightInfo = pallet_treasury::weights::SubstrateWeight<Self>;518 type MaxApprovals = MaxApprovals;519}520521impl pallet_sudo::Config for Runtime {522 type Event = Event;523 type Call = Call;524}525526pub struct RelayChainBlockNumberProvider<T>(sp_std::marker::PhantomData<T>);527528impl<T: cumulus_pallet_parachain_system::Config> BlockNumberProvider529 for RelayChainBlockNumberProvider<T>530{531 type BlockNumber = BlockNumber;532533 fn current_block_number() -> Self::BlockNumber {534 cumulus_pallet_parachain_system::Pallet::<T>::validation_data()535 .map(|d| d.relay_parent_number)536 .unwrap_or_default()537 }538}539540parameter_types! {541 pub const MinVestedTransfer: Balance = 10 * UNIQUE;542 pub const MaxVestingSchedules: u32 = 28;543}544545impl orml_vesting::Config for Runtime {546 type Event = Event;547 type Currency = pallet_balances::Pallet<Runtime>;548 type MinVestedTransfer = MinVestedTransfer;549 type VestedTransferOrigin = EnsureSigned<AccountId>;550 type WeightInfo = ();551 type MaxVestingSchedules = MaxVestingSchedules;552 type BlockNumberProvider = RelayChainBlockNumberProvider<Runtime>;553}554555parameter_types! {556 pub const ReservedDmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;557 pub const ReservedXcmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;558}559560impl cumulus_pallet_parachain_system::Config for Runtime {561 type Event = Event;562 type SelfParaId = parachain_info::Pallet<Self>;563 type OnSystemEvent = ();564 565 566 567 568 569 type OutboundXcmpMessageSource = XcmpQueue;570 type DmpMessageHandler = DmpQueue;571 type ReservedDmpWeight = ReservedDmpWeight;572 type ReservedXcmpWeight = ReservedXcmpWeight;573 type XcmpMessageHandler = XcmpQueue;574}575576impl parachain_info::Config for Runtime {}577578impl cumulus_pallet_aura_ext::Config for Runtime {}579580parameter_types! {581 pub const RelayLocation: MultiLocation = MultiLocation::parent();582 pub const RelayNetwork: NetworkId = NetworkId::Polkadot;583 pub RelayOrigin: Origin = cumulus_pallet_xcm::Origin::Relay.into();584 pub Ancestry: MultiLocation = Parachain(ParachainInfo::parachain_id().into()).into();585}586587588589590pub type LocationToAccountId = (591 592 ParentIsPreset<AccountId>,593 594 SiblingParachainConvertsVia<Sibling, AccountId>,595 596 AccountId32Aliases<RelayNetwork, AccountId>,597);598599pub struct OnlySelfCurrency;600impl<B: TryFrom<u128>> MatchesFungible<B> for OnlySelfCurrency {601 fn matches_fungible(a: &MultiAsset) -> Option<B> {602 match (&a.id, &a.fun) {603 (Concrete(_), XcmFungible(ref amount)) => CheckedConversion::checked_from(*amount),604 _ => None,605 }606 }607}608609610pub type LocalAssetTransactor = CurrencyAdapter<611 612 Balances,613 614 OnlySelfCurrency,615 616 LocationToAccountId,617 618 AccountId,619 620 (),621>;622623624625626pub type XcmOriginToTransactDispatchOrigin = (627 628 629 630 SovereignSignedViaLocation<LocationToAccountId, Origin>,631 632 633 RelayChainAsNative<RelayOrigin, Origin>,634 635 636 SiblingParachainAsNative<cumulus_pallet_xcm::Origin, Origin>,637 638 639 ParentAsSuperuser<Origin>,640 641 642 SignedAccountId32AsNative<RelayNetwork, Origin>,643 644 XcmPassthrough<Origin>,645);646647parameter_types! {648 649 pub UnitWeightCost: Weight = 1_000_000;650 651 pub const WeightPrice: (MultiLocation, u128) = (MultiLocation::parent(), 1_200 * UNIQUE);652 pub const MaxInstructions: u32 = 100;653 pub const MaxAuthorities: u32 = 100_000;654}655656match_type! {657 pub type ParentOrParentsUnitPlurality: impl Contains<MultiLocation> = {658 MultiLocation { parents: 1, interior: Here } |659 MultiLocation { parents: 1, interior: X1(Plurality { id: BodyId::Unit, .. }) }660 };661}662663pub type Barrier = (664 TakeWeightCredit,665 AllowTopLevelPaidExecutionFrom<Everything>,666 AllowUnpaidExecutionFrom<ParentOrParentsUnitPlurality>,667 668);669670pub struct UsingOnlySelfCurrencyComponents<671 WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,672 AssetId: Get<MultiLocation>,673 AccountId,674 Currency: CurrencyT<AccountId>,675 OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,676>(677 Weight,678 Currency::Balance,679 PhantomData<(WeightToFee, AssetId, AccountId, Currency, OnUnbalanced)>,680);681impl<682 WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,683 AssetId: Get<MultiLocation>,684 AccountId,685 Currency: CurrencyT<AccountId>,686 OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,687 > WeightTrader688 for UsingOnlySelfCurrencyComponents<WeightToFee, AssetId, AccountId, Currency, OnUnbalanced>689{690 fn new() -> Self {691 Self(0, Zero::zero(), PhantomData)692 }693694 fn buy_weight(&mut self, weight: Weight, payment: Assets) -> Result<Assets, XcmError> {695 let amount = WeightToFee::calc(&weight);696 let u128_amount: u128 = amount.try_into().map_err(|_| XcmError::Overflow)?;697698 699 let option1: xcm::v1::AssetId = Concrete(MultiLocation {700 parents: 1,701 interior: X1(Parachain(ParachainInfo::parachain_id().into())),702 });703 704 let option2: xcm::v1::AssetId = Concrete(MultiLocation {705 parents: 0,706 interior: Here,707 });708709 let required = if payment.fungible.contains_key(&option1) {710 (option1, u128_amount).into()711 } else if payment.fungible.contains_key(&option2) {712 (option2, u128_amount).into()713 } else {714 (Concrete(MultiLocation::default()), u128_amount).into()715 };716717 let unused = payment718 .checked_sub(required)719 .map_err(|_| XcmError::TooExpensive)?;720 self.0 = self.0.saturating_add(weight);721 self.1 = self.1.saturating_add(amount);722 Ok(unused)723 }724725 fn refund_weight(&mut self, weight: Weight) -> Option<MultiAsset> {726 let weight = weight.min(self.0);727 let amount = WeightToFee::calc(&weight);728 self.0 -= weight;729 self.1 = self.1.saturating_sub(amount);730 let amount: u128 = amount.saturated_into();731 if amount > 0 {732 Some((AssetId::get(), amount).into())733 } else {734 None735 }736 }737}738impl<739 WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,740 AssetId: Get<MultiLocation>,741 AccountId,742 Currency: CurrencyT<AccountId>,743 OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,744 > Drop745 for UsingOnlySelfCurrencyComponents<WeightToFee, AssetId, AccountId, Currency, OnUnbalanced>746{747 fn drop(&mut self) {748 OnUnbalanced::on_unbalanced(Currency::issue(self.1));749 }750}751752pub struct XcmConfig;753impl Config for XcmConfig {754 type Call = Call;755 type XcmSender = XcmRouter;756 757 type AssetTransactor = LocalAssetTransactor;758 type OriginConverter = XcmOriginToTransactDispatchOrigin;759 type IsReserve = NativeAsset;760 type IsTeleporter = (); 761 type LocationInverter = LocationInverter<Ancestry>;762 type Barrier = Barrier;763 type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;764 type Trader = UsingOnlySelfCurrencyComponents<765 IdentityFee<Balance>,766 RelayLocation,767 AccountId,768 Balances,769 (),770 >;771 type ResponseHandler = (); 772 type SubscriptionService = PolkadotXcm;773774 type AssetTrap = PolkadotXcm;775 type AssetClaims = PolkadotXcm;776}777778779780781782783pub type LocalOriginToLocation = (SignedToAccountId32<Origin, AccountId, RelayNetwork>,);784785786787pub type XcmRouter = (788 789 cumulus_primitives_utility::ParentAsUmp<ParachainSystem, ()>,790 791 XcmpQueue,792);793794impl pallet_evm_coder_substrate::Config for Runtime {795 type EthereumTransactionSender = pallet_ethereum::Pallet<Self>;796 type GasWeightMapping = FixedGasWeightMapping;797}798799impl pallet_xcm::Config for Runtime {800 type Event = Event;801 type SendXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;802 type XcmRouter = XcmRouter;803 type ExecuteXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;804 type XcmExecuteFilter = Everything;805 type XcmExecutor = XcmExecutor<XcmConfig>;806 type XcmTeleportFilter = Everything;807 type XcmReserveTransferFilter = Everything;808 type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;809 type LocationInverter = LocationInverter<Ancestry>;810 type Origin = Origin;811 type Call = Call;812 const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;813 type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;814}815816impl cumulus_pallet_xcm::Config for Runtime {817 type Event = Event;818 type XcmExecutor = XcmExecutor<XcmConfig>;819}820821impl cumulus_pallet_xcmp_queue::Config for Runtime {822 type WeightInfo = ();823 type Event = Event;824 type XcmExecutor = XcmExecutor<XcmConfig>;825 type ChannelInfo = ParachainSystem;826 type VersionWrapper = ();827 type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;828 type ControllerOrigin = EnsureRoot<AccountId>;829 type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin;830}831832impl cumulus_pallet_dmp_queue::Config for Runtime {833 type Event = Event;834 type XcmExecutor = XcmExecutor<XcmConfig>;835 type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;836}837838impl pallet_aura::Config for Runtime {839 type AuthorityId = AuraId;840 type DisabledValidators = ();841 type MaxAuthorities = MaxAuthorities;842}843844parameter_types! {845 pub TreasuryAccountId: AccountId = TreasuryModuleId::get().into_account();846 pub const CollectionCreationPrice: Balance = 2 * UNIQUE;847}848849impl pallet_common::Config for Runtime {850 type Event = Event;851 type EvmBackwardsAddressMapping = up_evm_mapping::MapBackwardsAddressTruncated;852 type EvmAddressMapping = HashedAddressMapping<Self::Hashing>;853 type CrossAccountId = pallet_common::account::BasicCrossAccountId<Self>;854855 type Currency = Balances;856 type CollectionCreationPrice = CollectionCreationPrice;857 type TreasuryAccountId = TreasuryAccountId;858}859860impl pallet_fungible::Config for Runtime {861 type WeightInfo = pallet_fungible::weights::SubstrateWeight<Self>;862}863impl pallet_refungible::Config for Runtime {864 type WeightInfo = pallet_refungible::weights::SubstrateWeight<Self>;865}866impl pallet_nonfungible::Config for Runtime {867 type WeightInfo = pallet_nonfungible::weights::SubstrateWeight<Self>;868}869870impl pallet_unique::Config for Runtime {871 type Event = Event;872 type WeightInfo = pallet_unique::weights::SubstrateWeight<Self>;873}874875parameter_types! {876 pub const InflationBlockInterval: BlockNumber = 100; 877}878879880impl pallet_inflation::Config for Runtime {881 type Currency = Balances;882 type TreasuryAccountId = TreasuryAccountId;883 type InflationBlockInterval = InflationBlockInterval;884 type BlockNumberProvider = RelayChainBlockNumberProvider<Runtime>;885}886887888889890891892893type EvmSponsorshipHandler = (894 pallet_unique::UniqueEthSponsorshipHandler<Runtime>,895 pallet_evm_contract_helpers::HelpersContractSponsoring<Runtime>,896);897type SponsorshipHandler = (898 pallet_unique::UniqueSponsorshipHandler<Runtime>,899 900 pallet_evm_transaction_payment::BridgeSponsorshipHandler<Runtime>,901);902903904905906907908909910911912913914915impl pallet_evm_transaction_payment::Config for Runtime {916 type EvmSponsorshipHandler = EvmSponsorshipHandler;917 type Currency = Balances;918 type EvmAddressMapping = HashedAddressMapping<Self::Hashing>;919 type EvmBackwardsAddressMapping = up_evm_mapping::MapBackwardsAddressTruncated;920}921922impl pallet_charge_transaction::Config for Runtime {923 type SponsorshipHandler = SponsorshipHandler;924}925926927928929930parameter_types! {931 932 pub const HelpersContractAddress: H160 = H160([933 0x84, 0x28, 0x99, 0xec, 0xf3, 0x80, 0x55, 0x3e, 0x8a, 0x4d, 0xe7, 0x5b, 0xf5, 0x34, 0xcd, 0xf6, 0xfb, 0xf6, 0x40, 0x49,934 ]);935}936937impl pallet_evm_contract_helpers::Config for Runtime {938 type ContractAddress = HelpersContractAddress;939 type DefaultSponsoringRateLimit = DefaultSponsoringRateLimit;940}941942construct_runtime!(943 pub enum Runtime where944 Block = Block,945 NodeBlock = opaque::Block,946 UncheckedExtrinsic = UncheckedExtrinsic947 {948 ParachainSystem: cumulus_pallet_parachain_system::{Pallet, Call, Config, Storage, Inherent, Event<T>, ValidateUnsigned} = 20,949 ParachainInfo: parachain_info::{Pallet, Storage, Config} = 21,950951 Aura: pallet_aura::{Pallet, Config<T>} = 22,952 AuraExt: cumulus_pallet_aura_ext::{Pallet, Config} = 23,953954 Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>} = 30,955 RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Pallet, Storage} = 31,956 Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent} = 32,957 TransactionPayment: pallet_transaction_payment::{Pallet, Storage} = 33,958 Treasury: pallet_treasury::{Pallet, Call, Storage, Config, Event<T>} = 34,959 Sudo: pallet_sudo::{Pallet, Call, Storage, Config<T>, Event<T>} = 35,960 System: frame_system::{Pallet, Call, Storage, Config, Event<T>} = 36,961 Vesting: orml_vesting::{Pallet, Storage, Call, Event<T>, Config<T>} = 37,962 963 964965 966 XcmpQueue: cumulus_pallet_xcmp_queue::{Pallet, Call, Storage, Event<T>} = 50,967 PolkadotXcm: pallet_xcm::{Pallet, Call, Event<T>, Origin} = 51,968 CumulusXcm: cumulus_pallet_xcm::{Pallet, Call, Event<T>, Origin} = 52,969 DmpQueue: cumulus_pallet_dmp_queue::{Pallet, Call, Storage, Event<T>} = 53,970971 972 Inflation: pallet_inflation::{Pallet, Call, Storage} = 60,973 Unique: pallet_unique::{Pallet, Call, Storage, Event<T>} = 61,974 975 976 Charging: pallet_charge_transaction::{Pallet, Call, Storage } = 64,977 978 Common: pallet_common::{Pallet, Storage, Event<T>} = 66,979 Fungible: pallet_fungible::{Pallet, Storage} = 67,980 Refungible: pallet_refungible::{Pallet, Storage} = 68,981 Nonfungible: pallet_nonfungible::{Pallet, Storage} = 69,982983 984 EVM: pallet_evm::{Pallet, Config, Call, Storage, Event<T>} = 100,985 Ethereum: pallet_ethereum::{Pallet, Config, Call, Storage, Event, Origin} = 101,986987 EvmCoderSubstrate: pallet_evm_coder_substrate::{Pallet, Storage} = 150,988 EvmContractHelpers: pallet_evm_contract_helpers::{Pallet, Storage} = 151,989 EvmTransactionPayment: pallet_evm_transaction_payment::{Pallet} = 152,990 EvmMigration: pallet_evm_migration::{Pallet, Call, Storage} = 153,991 }992);993994pub struct TransactionConverter;995996impl fp_rpc::ConvertTransaction<UncheckedExtrinsic> for TransactionConverter {997 fn convert_transaction(&self, transaction: pallet_ethereum::Transaction) -> UncheckedExtrinsic {998 UncheckedExtrinsic::new_unsigned(999 pallet_ethereum::Call::<Runtime>::transact { transaction }.into(),1000 )1001 }1002}10031004impl fp_rpc::ConvertTransaction<opaque::UncheckedExtrinsic> for TransactionConverter {1005 fn convert_transaction(1006 &self,1007 transaction: pallet_ethereum::Transaction,1008 ) -> opaque::UncheckedExtrinsic {1009 let extrinsic = UncheckedExtrinsic::new_unsigned(1010 pallet_ethereum::Call::<Runtime>::transact { transaction }.into(),1011 );1012 let encoded = extrinsic.encode();1013 opaque::UncheckedExtrinsic::decode(&mut &encoded[..])1014 .expect("Encoded extrinsic is always valid")1015 }1016}101710181019pub type Address = sp_runtime::MultiAddress<AccountId, ()>;10201021pub type Header = generic::Header<BlockNumber, BlakeTwo256>;10221023pub type Block = generic::Block<Header, UncheckedExtrinsic>;10241025pub type SignedBlock = generic::SignedBlock<Block>;10261027pub type BlockId = generic::BlockId<Block>;10281029pub type SignedExtra = (1030 frame_system::CheckSpecVersion<Runtime>,1031 1032 frame_system::CheckGenesis<Runtime>,1033 frame_system::CheckEra<Runtime>,1034 frame_system::CheckNonce<Runtime>,1035 frame_system::CheckWeight<Runtime>,1036 pallet_charge_transaction::ChargeTransactionPayment<Runtime>,1037 1038);10391040pub type UncheckedExtrinsic =1041 fp_self_contained::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;10421043pub type CheckedExtrinsic = fp_self_contained::CheckedExtrinsic<AccountId, Call, SignedExtra, H160>;10441045pub type Executive = frame_executive::Executive<1046 Runtime,1047 Block,1048 frame_system::ChainContext<Runtime>,1049 Runtime,1050 AllPalletsReversedWithSystemFirst,1051>;10521053impl_opaque_keys! {1054 pub struct SessionKeys {1055 pub aura: Aura,1056 }1057}10581059impl fp_self_contained::SelfContainedCall for Call {1060 type SignedInfo = H160;10611062 fn is_self_contained(&self) -> bool {1063 match self {1064 Call::Ethereum(call) => call.is_self_contained(),1065 _ => false,1066 }1067 }10681069 fn check_self_contained(&self) -> Option<Result<Self::SignedInfo, TransactionValidityError>> {1070 match self {1071 Call::Ethereum(call) => call.check_self_contained(),1072 _ => None,1073 }1074 }10751076 fn validate_self_contained(&self, info: &Self::SignedInfo) -> Option<TransactionValidity> {1077 match self {1078 Call::Ethereum(call) => call.validate_self_contained(info),1079 _ => None,1080 }1081 }10821083 fn pre_dispatch_self_contained(1084 &self,1085 info: &Self::SignedInfo,1086 ) -> Option<Result<(), TransactionValidityError>> {1087 match self {1088 Call::Ethereum(call) => call.pre_dispatch_self_contained(info),1089 _ => None,1090 }1091 }10921093 fn apply_self_contained(1094 self,1095 info: Self::SignedInfo,1096 ) -> Option<sp_runtime::DispatchResultWithInfo<PostDispatchInfoOf<Self>>> {1097 match self {1098 call @ Call::Ethereum(pallet_ethereum::Call::transact { .. }) => Some(call.dispatch(1099 Origin::from(pallet_ethereum::RawOrigin::EthereumTransaction(info)),1100 )),1101 _ => None,1102 }1103 }1104}11051106macro_rules! dispatch_unique_runtime {1107 ($collection:ident.$method:ident($($name:ident),*)) => {{1108 use pallet_unique::dispatch::Dispatched;11091110 let collection = Dispatched::dispatch(<pallet_common::CollectionHandle<Runtime>>::try_get($collection)?);1111 let dispatch = collection.as_dyn();11121113 Ok(dispatch.$method($($name),*))1114 }};1115}11161117impl_common_runtime_apis!();11181119struct CheckInherents;11201121impl cumulus_pallet_parachain_system::CheckInherents<Block> for CheckInherents {1122 fn check_inherents(1123 block: &Block,1124 relay_state_proof: &cumulus_pallet_parachain_system::RelayChainStateProof,1125 ) -> sp_inherents::CheckInherentsResult {1126 let relay_chain_slot = relay_state_proof1127 .read_slot()1128 .expect("Could not read the relay chain slot from the proof");11291130 let inherent_data =1131 cumulus_primitives_timestamp::InherentDataProvider::from_relay_chain_slot_and_duration(1132 relay_chain_slot,1133 sp_std::time::Duration::from_secs(6),1134 )1135 .create_inherent_data()1136 .expect("Could not create the timestamp inherent data");11371138 inherent_data.check_extrinsics(block)1139 }1140}11411142cumulus_pallet_parachain_system::register_validate_block!(1143 Runtime = Runtime,1144 BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor::<Runtime, Executive>,1145 CheckInherents = CheckInherents,1146);