difftreelog
CORE-300 Fix PR
in: master
12 files changed
Cargo.lockdiffbeforeafterboth--- a/Cargo.lock
+++ b/Cargo.lock
@@ -2751,6 +2751,15 @@
]
[[package]]
+name = "fp-evm-mapping"
+version = "0.1.0"
+source = "git+https://github.com/uniquenetwork/frontier.git?branch=feature/300#8718bfde84a370f5a6e7642b216dd913ca33db5c"
+dependencies = [
+ "frame-support",
+ "sp-core",
+]
+
+[[package]]
name = "fp-rpc"
version = "3.0.0-dev"
source = "git+https://github.com/uniquenetwork/frontier.git?branch=unique-polkadot-v0.9.18#7c8ce8f83e0c8a5b57655622b721f8655b161903"
@@ -5576,6 +5585,7 @@
"cumulus-primitives-timestamp",
"cumulus-primitives-utility",
"derivative",
+ "fp-evm-mapping",
"fp-rpc",
"fp-self-contained",
"frame-benchmarking",
@@ -5632,7 +5642,6 @@
"substrate-wasm-builder",
"unique-runtime-common",
"up-data-structs",
- "up-evm-mapping",
"up-rpc",
"xcm",
"xcm-builder",
@@ -5984,6 +5993,7 @@
version = "0.1.0"
dependencies = [
"evm-coder",
+ "fp-evm-mapping",
"frame-support",
"frame-system",
"pallet-evm",
@@ -5995,7 +6005,6 @@
"sp-runtime",
"sp-std",
"up-data-structs",
- "up-evm-mapping",
]
[[package]]
@@ -6136,6 +6145,7 @@
version = "0.1.0"
dependencies = [
"evm-coder",
+ "fp-evm-mapping",
"frame-support",
"frame-system",
"log",
@@ -6146,7 +6156,6 @@
"sp-core",
"sp-runtime",
"sp-std",
- "up-evm-mapping",
"up-sponsorship",
]
@@ -6182,7 +6191,6 @@
"sp-io",
"sp-runtime",
"sp-std",
- "up-evm-mapping",
"up-sponsorship",
]
@@ -6825,7 +6833,6 @@
"sp-runtime",
"sp-std",
"up-data-structs",
- "up-evm-mapping",
"up-sponsorship",
]
@@ -8708,6 +8715,7 @@
"cumulus-primitives-timestamp",
"cumulus-primitives-utility",
"derivative",
+ "fp-evm-mapping",
"fp-rpc",
"fp-self-contained",
"frame-benchmarking",
@@ -8764,7 +8772,6 @@
"substrate-wasm-builder",
"unique-runtime-common",
"up-data-structs",
- "up-evm-mapping",
"up-rpc",
"xcm",
"xcm-builder",
@@ -12550,6 +12557,7 @@
"cumulus-primitives-timestamp",
"cumulus-primitives-utility",
"derivative",
+ "fp-evm-mapping",
"fp-rpc",
"fp-self-contained",
"frame-benchmarking",
@@ -12606,7 +12614,6 @@
"substrate-wasm-builder",
"unique-runtime-common",
"up-data-structs",
- "up-evm-mapping",
"up-rpc",
"xcm",
"xcm-builder",
@@ -12687,15 +12694,6 @@
"sp-core",
"sp-runtime",
"sp-std",
-]
-
-[[package]]
-name = "up-evm-mapping"
-version = "0.1.0"
-source = "git+https://github.com/uniquenetwork/frontier.git?branch=feature/300#0a1dc4086cbe971ddf57edf82a61cfce52c8c20b"
-dependencies = [
- "frame-support",
- "sp-core",
]
[[package]]
pallets/common/Cargo.tomldiffbeforeafterboth--- a/pallets/common/Cargo.toml
+++ b/pallets/common/Cargo.toml
@@ -16,12 +16,12 @@
sp-runtime = { default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.18' }
sp-std = { default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.18' }
sp-core = { default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.18' }
+fp-evm-mapping = { default-features = false, git = "https://github.com/uniquenetwork/frontier.git", branch = "feature/300" }
up-data-structs = { default-features = false, path = '../../primitives/data-structs' }
pallet-evm-coder-substrate = { default-features = false, path = '../../pallets/evm-coder-substrate' }
evm-coder = { default-features = false, path = '../../crates/evm-coder' }
pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier.git", branch = "unique-polkadot-v0.9.18" }
frame-common = { default-features = false, git = "https://github.com/uniquenetwork/frontier.git", branch = "feature/300" }
-up-evm-mapping = { default-features = false, git = "https://github.com/uniquenetwork/frontier.git", branch = "feature/300" }
serde = { version = "1.0.130", default-features = false }
scale-info = { version = "2.0.1", default-features = false, features = [
"derive",
@@ -34,7 +34,7 @@
"frame-system/std",
"sp-runtime/std",
"sp-std/std",
- "up-evm-mapping/std",
+ "fp-evm-mapping/std",
"up-data-structs/std",
"pallet-evm/std",
]
pallets/evm-contract-helpers/Cargo.tomldiffbeforeafterboth--- a/pallets/evm-contract-helpers/Cargo.toml
+++ b/pallets/evm-contract-helpers/Cargo.toml
@@ -17,7 +17,7 @@
pallet-evm-coder-substrate = { default-features = false, path = '../../pallets/evm-coder-substrate' }
pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier.git", branch = "unique-polkadot-v0.9.18" }
up-sponsorship = { version = "0.1.0", default-features = false, git = "https://github.com/UniqueNetwork/pallet-sponsoring", branch = 'polkadot-v0.9.18' }
-up-evm-mapping = { default-features = false, git = "https://github.com/uniquenetwork/frontier.git", branch = "feature/300" }
+fp-evm-mapping = { default-features = false, git = "https://github.com/uniquenetwork/frontier.git", branch = "feature/300" }
log = "0.4.14"
[dependencies.codec]
pallets/evm-transaction-payment/Cargo.tomldiffbeforeafterboth--- a/pallets/evm-transaction-payment/Cargo.toml
+++ b/pallets/evm-transaction-payment/Cargo.toml
@@ -18,7 +18,7 @@
fp-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier.git", branch = "unique-polkadot-v0.9.18" }
pallet-ethereum = { default-features = false, git = "https://github.com/uniquenetwork/frontier.git", branch = "unique-polkadot-v0.9.18" }
up-sponsorship = { version = "0.1.0", default-features = false, git = "https://github.com/UniqueNetwork/pallet-sponsoring", branch = 'polkadot-v0.9.18' }
-up-evm-mapping = { default-features = false, git = "https://github.com/uniquenetwork/frontier.git", branch = "feature/300" }
+fp-evm-mapping = { default-features = false, git = "https://github.com/uniquenetwork/frontier.git", branch = "feature/300" }
[dependencies.codec]
default-features = false
@@ -39,5 +39,5 @@
"pallet-ethereum/std",
"fp-evm/std",
"up-sponsorship/std",
- "up-evm-mapping/std",
+ "fp-evm-mapping/std",
]
pallets/unique/Cargo.tomldiffbeforeafterboth--- a/pallets/unique/Cargo.toml
+++ b/pallets/unique/Cargo.toml
@@ -34,7 +34,7 @@
'fp-evm/std',
'up-data-structs/std',
'up-sponsorship/std',
- 'up-evm-mapping/std',
+ 'fp-evm-mapping/std',
'sp-std/std',
'sp-api/std',
'sp-runtime/std',
@@ -132,7 +132,7 @@
sp-api = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.18" }
up-sponsorship = { version = "0.1.0", default-features = false, git = "https://github.com/UniqueNetwork/pallet-sponsoring", branch = 'polkadot-v0.9.18' }
-up-evm-mapping = { default-features = false, git = "https://github.com/uniquenetwork/frontier.git", branch = "feature/300" }
+fp-evm-mapping = { default-features = false, git = "https://github.com/uniquenetwork/frontier.git", branch = "feature/300" }
evm-coder = { default-features = false, path = "../../crates/evm-coder" }
pallet-evm-coder-substrate = { default-features = false, path = "../../pallets/evm-coder-substrate" }
primitive-types = { version = "0.11.1", default-features = false, features = [
pallets/unique/src/mock.rsdiffbeforeafterboth--- a/pallets/unique/src/mock.rs
+++ b/pallets/unique/src/mock.rs
@@ -26,7 +26,7 @@
use pallet_transaction_payment::{CurrencyAdapter};
use frame_system as system;
use pallet_evm::{AddressMapping, runner::stack::MaybeMirroredLog};
-use up_evm_mapping::EvmBackwardsAddressMapping;
+use fp_evm_mapping::EvmBackwardsAddressMapping;
use pallet_evm::account::CrossAccountId;
use codec::{Encode, Decode, MaxEncodedLen};
use scale_info::TypeInfo;
runtime/opal/Cargo.tomldiffbeforeafterboth--- a/runtime/opal/Cargo.toml
+++ b/runtime/opal/Cargo.toml
@@ -72,7 +72,7 @@
'pallet-base-fee/std',
'fp-rpc/std',
'up-rpc/std',
- 'up-evm-mapping/std',
+ 'fp-evm-mapping/std',
'fp-self-contained/std',
'parachain-info/std',
'serde',
@@ -382,7 +382,7 @@
derivative = "2.2.0"
pallet-unique = { path = '../../pallets/unique', default-features = false }
up-rpc = { path = "../../primitives/rpc", default-features = false }
-up-evm-mapping = { path = "../../primitives/evm-mapping", default-features = false }
+fp-evm-mapping = { default-features = false, git = "https://github.com/uniquenetwork/frontier.git", branch = "feature/300" }
pallet-inflation = { path = '../../pallets/inflation', default-features = false }
up-data-structs = { path = '../../primitives/data-structs', default-features = false }
pallet-common = { default-features = false, path = "../../pallets/common" }
runtime/opal/src/lib.rsdiffbeforeafterboth--- a/runtime/opal/src/lib.rs
+++ b/runtime/opal/src/lib.rs
@@ -275,7 +275,7 @@
impl pallet_evm::account::Config for Runtime {
type CrossAccountId = pallet_evm::account::BasicCrossAccountId<Self>;
type EvmAddressMapping = pallet_evm::HashedAddressMapping<Self::Hashing>;
- type EvmBackwardsAddressMapping = up_evm_mapping::MapBackwardsAddressTruncated;
+ type EvmBackwardsAddressMapping = fp_evm_mapping::MapBackwardsAddressTruncated;
}
impl pallet_evm::Config for Runtime {
runtime/quartz/Cargo.tomldiffbeforeafterboth--- a/runtime/quartz/Cargo.toml
+++ b/runtime/quartz/Cargo.toml
@@ -72,7 +72,7 @@
'pallet-base-fee/std',
'fp-rpc/std',
'up-rpc/std',
- 'up-evm-mapping/std',
+ 'fp-evm-mapping/std',
'fp-self-contained/std',
'parachain-info/std',
'serde',
@@ -382,7 +382,7 @@
derivative = "2.2.0"
pallet-unique = { path = '../../pallets/unique', default-features = false }
up-rpc = { path = "../../primitives/rpc", default-features = false }
-up-evm-mapping = { path = "../../primitives/evm-mapping", default-features = false }
+fp-evm-mapping = { default-features = false, git = "https://github.com/uniquenetwork/frontier.git", branch = "feature/300" }
pallet-inflation = { path = '../../pallets/inflation', default-features = false }
up-data-structs = { path = '../../primitives/data-structs', default-features = false }
pallet-common = { default-features = false, path = "../../pallets/common" }
runtime/quartz/src/lib.rsdiffbeforeafterboth--- a/runtime/quartz/src/lib.rs
+++ b/runtime/quartz/src/lib.rs
@@ -853,6 +853,12 @@
type TreasuryAccountId = TreasuryAccountId;
}
+impl pallet_evm::account::Config for Runtime {
+ type CrossAccountId = pallet_evm::account::BasicCrossAccountId<Self>;
+ type EvmAddressMapping = HashedAddressMapping<Self::Hashing>;
+ type EvmBackwardsAddressMapping = fp_evm_mapping::MapBackwardsAddressTruncated;
+}
+
impl pallet_fungible::Config for Runtime {
type WeightInfo = pallet_fungible::weights::SubstrateWeight<Self>;
}
runtime/unique/Cargo.tomldiffbeforeafterboth--- a/runtime/unique/Cargo.toml
+++ b/runtime/unique/Cargo.toml
@@ -72,7 +72,7 @@
'pallet-base-fee/std',
'fp-rpc/std',
'up-rpc/std',
- 'up-evm-mapping/std',
+ 'fp-evm-mapping/std',
'fp-self-contained/std',
'parachain-info/std',
'serde',
@@ -400,7 +400,7 @@
pallet-base-fee = { default-features = false, git = "https://github.com/uniquenetwork/frontier.git", branch = "unique-polkadot-v0.9.18" }
fp-rpc = { default-features = false, git = "https://github.com/uniquenetwork/frontier.git", branch = "unique-polkadot-v0.9.18" }
fp-self-contained = { default-features = false, git = "https://github.com/uniquenetwork/frontier.git", branch = "unique-polkadot-v0.9.18" }
-up-evm-mapping = { default-features = false, git = "https://github.com/uniquenetwork/frontier.git", branch = "feature/300" }
+fp-evm-mapping = { default-features = false, git = "https://github.com/uniquenetwork/frontier.git", branch = "feature/300" }
frame-common = { default-features = false, git = "https://github.com/uniquenetwork/frontier.git", branch = "feature/300" }
################################################################################
runtime/unique/src/lib.rsdiffbeforeafterboth1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617//! The Substrate Node Template runtime. This can be compiled with `#[no_std]`, ready for Wasm.1819#![cfg_attr(not(feature = "std"), no_std)]20// `construct_runtime!` does a lot of recursion and requires us to increase the limit to 256.21#![recursion_limit = "1024"]22#![allow(clippy::from_over_into, clippy::identity_op)]23#![allow(clippy::fn_to_numeric_cast_with_truncation)]24// Make the WASM binary available.25#[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;31// #[cfg(any(feature = "std", test))]32// pub use sp_runtime::BuildStorage;3334use 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};49// A few exports that help ease life for downstream crates.50pub 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::*;68// use pallet_contracts::weights::WeightInfo;69// #[cfg(any(feature = "std", test))]70use 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};8687// pub use pallet_timestamp::Call as TimestampCall;8889// Polkadot imports90use pallet_xcm::XcmPassthrough;91use polkadot_parachain::primitives::Sibling;92use xcm::v1::{BodyId, Junction::*, MultiLocation, NetworkId, Junctions::*};93use xcm_builder::{94 AccountId32Aliases, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, CurrencyAdapter,95 EnsureXcmOrigin, FixedWeightBounds, LocationInverter, NativeAsset, ParentAsSuperuser,96 RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia,97 SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit,98 ParentIsPreset,99};100use xcm_executor::{Config, XcmExecutor, Assets};101use sp_std::{marker::PhantomData};102103use xcm::latest::{104 // Xcm,105 AssetId::{Concrete},106 Fungibility::Fungible as XcmFungible,107 MultiAsset,108 Error as XcmError,109};110use xcm_executor::traits::{MatchesFungible, WeightTrader};111//use xcm_executor::traits::MatchesFungible;112use sp_runtime::traits::CheckedConversion;113114use unique_runtime_common::{impl_common_runtime_apis, types::*, constants::*};115116pub const RUNTIME_NAME: &str = "Unique";117118type CrossAccountId = pallet_common::account::BasicCrossAccountId<Runtime>;119120impl RuntimeInstance for Runtime {121 type CrossAccountId = self::CrossAccountId;122123 type TransactionConverter = self::TransactionConverter;124125 fn get_transaction_converter() -> TransactionConverter {126 TransactionConverter127 }128}129130/// Opaque types. These are used by the CLI to instantiate machinery that don't need to know131/// the specifics of the runtime. They can then be made to be agnostic over specific formats132/// of data like extrinsics, allowing for them to continue syncing the network through upgrades133/// to even the core data structures.134pub mod opaque {135 use sp_std::prelude::*;136 use sp_runtime::impl_opaque_keys;137 use super::Aura;138139 pub use unique_runtime_common::types::*;140141 impl_opaque_keys! {142 pub struct SessionKeys {143 pub aura: Aura,144 }145 }146}147148/// This runtime version.149pub const VERSION: RuntimeVersion = RuntimeVersion {150 spec_name: create_runtime_str!(RUNTIME_NAME),151 impl_name: create_runtime_str!(RUNTIME_NAME),152 authoring_version: 1,153 spec_version: 917004,154 impl_version: 0,155 apis: RUNTIME_API_VERSIONS,156 transaction_version: 1,157 state_version: 0,158};159160#[derive(codec::Encode, codec::Decode)]161pub enum XCMPMessage<XAccountId, XBalance> {162 /// Transfer tokens to the given account from the Parachain account.163 TransferToken(XAccountId, XBalance),164}165166/// The version information used to identify this runtime when compiled natively.167#[cfg(feature = "std")]168pub fn native_version() -> NativeVersion {169 NativeVersion {170 runtime_version: VERSION,171 can_author_with: Default::default(),172 }173}174175type NegativeImbalance = <Balances as Currency<AccountId>>::NegativeImbalance;176177pub struct DealWithFees;178impl OnUnbalanced<NegativeImbalance> for DealWithFees {179 fn on_unbalanceds<B>(mut fees_then_tips: impl Iterator<Item = NegativeImbalance>) {180 if let Some(fees) = fees_then_tips.next() {181 // for fees, 100% to treasury182 let mut split = fees.ration(100, 0);183 if let Some(tips) = fees_then_tips.next() {184 // for tips, if any, 100% to treasury185 tips.ration_merge_into(100, 0, &mut split);186 }187 Treasury::on_unbalanced(split.0);188 // Author::on_unbalanced(split.1);189 }190 }191}192193parameter_types! {194 pub const BlockHashCount: BlockNumber = 2400;195 pub RuntimeBlockLength: BlockLength =196 BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);197 pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);198 pub const MaximumBlockLength: u32 = 5 * 1024 * 1024;199 pub RuntimeBlockWeights: BlockWeights = BlockWeights::builder()200 .base_block(BlockExecutionWeight::get())201 .for_class(DispatchClass::all(), |weights| {202 weights.base_extrinsic = ExtrinsicBaseWeight::get();203 })204 .for_class(DispatchClass::Normal, |weights| {205 weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT);206 })207 .for_class(DispatchClass::Operational, |weights| {208 weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT);209 // Operational transactions have some extra reserved space, so that they210 // are included even if block reached `MAXIMUM_BLOCK_WEIGHT`.211 weights.reserved = Some(212 MAXIMUM_BLOCK_WEIGHT - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT213 );214 })215 .avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO)216 .build_or_panic();217 pub const Version: RuntimeVersion = VERSION;218 pub const SS58Prefix: u16 = 7391;219}220221parameter_types! {222 pub const ChainId: u64 = 8880;223}224225pub struct FixedFee;226impl FeeCalculator for FixedFee {227 fn min_gas_price() -> U256 {228 MIN_GAS_PRICE.into()229 }230}231232// Assuming slowest ethereum opcode is SSTORE, with gas price of 20000 as our worst case233// (contract, which only writes a lot of data),234// approximating on top of our real store write weight235parameter_types! {236 pub const WritesPerSecond: u64 = WEIGHT_PER_SECOND / <Runtime as frame_system::Config>::DbWeight::get().write;237 pub const GasPerSecond: u64 = WritesPerSecond::get() * 20000;238 pub const WeightPerGas: u64 = WEIGHT_PER_SECOND / GasPerSecond::get();239}240241/// Limiting EVM execution to 50% of block for substrate users and management tasks242/// EVM transaction consumes more weight than substrate's, so we can't rely on them being243/// scheduled fairly244const EVM_DISPATCH_RATIO: Perbill = Perbill::from_percent(50);245parameter_types! {246 pub BlockGasLimit: U256 = U256::from(NORMAL_DISPATCH_RATIO * EVM_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT / WeightPerGas::get());247}248249pub enum FixedGasWeightMapping {}250impl GasWeightMapping for FixedGasWeightMapping {251 fn gas_to_weight(gas: u64) -> Weight {252 gas.saturating_mul(WeightPerGas::get())253 }254 fn weight_to_gas(weight: Weight) -> u64 {255 weight / WeightPerGas::get()256 }257}258259impl pallet_evm::Config for Runtime {260 type BlockGasLimit = BlockGasLimit;261 type FeeCalculator = FixedFee;262 type GasWeightMapping = FixedGasWeightMapping;263 type BlockHashMapping = pallet_ethereum::EthereumBlockHashMapping<Self>;264 type CallOrigin = EnsureAddressTruncated;265 type WithdrawOrigin = EnsureAddressTruncated;266 type AddressMapping = HashedAddressMapping<Self::Hashing>;267 type PrecompilesType = ();268 type PrecompilesValue = ();269 type Currency = Balances;270 type Event = Event;271 type OnMethodCall = (272 pallet_evm_migration::OnMethodCall<Self>,273 pallet_unique::UniqueErcSupport<Self>,274 pallet_evm_contract_helpers::HelpersOnMethodCall<Self>,275 );276 type OnCreate = pallet_evm_contract_helpers::HelpersOnCreate<Self>;277 type ChainId = ChainId;278 type Runner = pallet_evm::runner::stack::Runner<Self>;279 type OnChargeTransaction = pallet_evm_transaction_payment::OnChargeTransaction<Self>;280 type TransactionValidityHack = pallet_evm_transaction_payment::TransactionValidityHack<Self>;281 type FindAuthor = EthereumFindAuthor<Aura>;282}283284impl pallet_evm_migration::Config for Runtime {285 type WeightInfo = pallet_evm_migration::weights::SubstrateWeight<Self>;286}287288pub struct EthereumFindAuthor<F>(core::marker::PhantomData<F>);289impl<F: FindAuthor<u32>> FindAuthor<H160> for EthereumFindAuthor<F> {290 fn find_author<'a, I>(digests: I) -> Option<H160>291 where292 I: 'a + IntoIterator<Item = (ConsensusEngineId, &'a [u8])>,293 {294 if let Some(author_index) = F::find_author(digests) {295 let authority_id = Aura::authorities()[author_index as usize].clone();296 return Some(H160::from_slice(&authority_id.to_raw_vec()[4..24]));297 }298 None299 }300}301302impl pallet_ethereum::Config for Runtime {303 type Event = Event;304 type StateRoot = pallet_ethereum::IntermediateStateRoot;305}306307impl pallet_randomness_collective_flip::Config for Runtime {}308309impl frame_system::Config for Runtime {310 /// The data to be stored in an account.311 type AccountData = pallet_balances::AccountData<Balance>;312 /// The identifier used to distinguish between accounts.313 type AccountId = AccountId;314 /// The basic call filter to use in dispatchable.315 type BaseCallFilter = Everything;316 /// Maximum number of block number to block hash mappings to keep (oldest pruned first).317 type BlockHashCount = BlockHashCount;318 /// The maximum length of a block (in bytes).319 type BlockLength = RuntimeBlockLength;320 /// The index type for blocks.321 type BlockNumber = BlockNumber;322 /// The weight of the overhead invoked on the block import process, independent of the extrinsics included in that block.323 type BlockWeights = RuntimeBlockWeights;324 /// The aggregated dispatch type that is available for extrinsics.325 type Call = Call;326 /// The weight of database operations that the runtime can invoke.327 type DbWeight = RocksDbWeight;328 /// The ubiquitous event type.329 type Event = Event;330 /// The type for hashing blocks and tries.331 type Hash = Hash;332 /// The hashing algorithm used.333 type Hashing = BlakeTwo256;334 /// The header type.335 type Header = generic::Header<BlockNumber, BlakeTwo256>;336 /// The index type for storing how many extrinsics an account has signed.337 type Index = Index;338 /// The lookup mechanism to get account ID from whatever is passed in dispatchers.339 type Lookup = AccountIdLookup<AccountId, ()>;340 /// What to do if an account is fully reaped from the system.341 type OnKilledAccount = ();342 /// What to do if a new account is created.343 type OnNewAccount = ();344 type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode<Self>;345 /// The ubiquitous origin type.346 type Origin = Origin;347 /// This type is being generated by `construct_runtime!`.348 type PalletInfo = PalletInfo;349 /// This is used as an identifier of the chain. 42 is the generic substrate prefix.350 type SS58Prefix = SS58Prefix;351 /// Weight information for the extrinsics of this pallet.352 type SystemWeightInfo = frame_system::weights::SubstrateWeight<Self>;353 /// Version of the runtime.354 type Version = Version;355 type MaxConsumers = ConstU32<16>;356}357358parameter_types! {359 pub const MinimumPeriod: u64 = SLOT_DURATION / 2;360}361362impl pallet_timestamp::Config for Runtime {363 /// A timestamp: milliseconds since the unix epoch.364 type Moment = u64;365 type OnTimestampSet = ();366 type MinimumPeriod = MinimumPeriod;367 type WeightInfo = ();368}369370parameter_types! {371 // pub const ExistentialDeposit: u128 = 500;372 pub const ExistentialDeposit: u128 = 0;373 pub const MaxLocks: u32 = 50;374}375376impl pallet_balances::Config for Runtime {377 type MaxLocks = MaxLocks;378 type MaxReserves = ();379 type ReserveIdentifier = [u8; 8];380 /// The type for recording an account's balance.381 type Balance = Balance;382 /// The ubiquitous event type.383 type Event = Event;384 type DustRemoval = Treasury;385 type ExistentialDeposit = ExistentialDeposit;386 type AccountStore = System;387 type WeightInfo = pallet_balances::weights::SubstrateWeight<Self>;388}389390pub const fn deposit(items: u32, bytes: u32) -> Balance {391 items as Balance * 15 * CENTIUNIQUE + (bytes as Balance) * 6 * CENTIUNIQUE392}393394/*395parameter_types! {396 pub TombstoneDeposit: Balance = deposit(397 1,398 sp_std::mem::size_of::<pallet_contracts::Pallet<Runtime>> as u32,399 );400 pub DepositPerContract: Balance = TombstoneDeposit::get();401 pub const DepositPerStorageByte: Balance = deposit(0, 1);402 pub const DepositPerStorageItem: Balance = deposit(1, 0);403 pub RentFraction: Perbill = Perbill::from_rational(1u32, 30 * DAYS);404 pub const SurchargeReward: Balance = 150 * MILLIUNIQUE;405 pub const SignedClaimHandicap: u32 = 2;406 pub const MaxDepth: u32 = 32;407 pub const MaxValueSize: u32 = 16 * 1024;408 pub const MaxCodeSize: u32 = 1024 * 1024 * 25; // 25 Mb409 // The lazy deletion runs inside on_initialize.410 pub DeletionWeightLimit: Weight = AVERAGE_ON_INITIALIZE_RATIO *411 RuntimeBlockWeights::get().max_block;412 // The weight needed for decoding the queue should be less or equal than a fifth413 // of the overall weight dedicated to the lazy deletion.414 pub DeletionQueueDepth: u32 = ((DeletionWeightLimit::get() / (415 <Runtime as pallet_contracts::Config>::WeightInfo::on_initialize_per_queue_item(1) -416 <Runtime as pallet_contracts::Config>::WeightInfo::on_initialize_per_queue_item(0)417 )) / 5) as u32;418 pub Schedule: pallet_contracts::Schedule<Runtime> = Default::default();419}420421impl pallet_contracts::Config for Runtime {422 type Time = Timestamp;423 type Randomness = RandomnessCollectiveFlip;424 type Currency = Balances;425 type Event = Event;426 type RentPayment = ();427 type SignedClaimHandicap = SignedClaimHandicap;428 type TombstoneDeposit = TombstoneDeposit;429 type DepositPerContract = DepositPerContract;430 type DepositPerStorageByte = DepositPerStorageByte;431 type DepositPerStorageItem = DepositPerStorageItem;432 type RentFraction = RentFraction;433 type SurchargeReward = SurchargeReward;434 type WeightPrice = pallet_transaction_payment::Pallet<Self>;435 type WeightInfo = pallet_contracts::weights::SubstrateWeight<Self>;436 type ChainExtension = NFTExtension;437 type DeletionQueueDepth = DeletionQueueDepth;438 type DeletionWeightLimit = DeletionWeightLimit;439 type Schedule = Schedule;440 type CallStack = [pallet_contracts::Frame<Self>; 31];441}442*/443444parameter_types! {445 /// This value increases the priority of `Operational` transactions by adding446 /// a "virtual tip" that's equal to the `OperationalFeeMultiplier * final_fee`.447 pub const OperationalFeeMultiplier: u8 = 5;448}449450/// Linear implementor of `WeightToFeePolynomial`451pub struct LinearFee<T>(sp_std::marker::PhantomData<T>);452453impl<T> WeightToFeePolynomial for LinearFee<T>454where455 T: BaseArithmetic + From<u32> + Copy + Unsigned,456{457 type Balance = T;458459 fn polynomial() -> WeightToFeeCoefficients<Self::Balance> {460 smallvec!(WeightToFeeCoefficient {461 // Targeting 0.1 Unique per NFT transfer462 coeff_integer: WEIGHT_TO_FEE_COEFF.into(),463 coeff_frac: Perbill::zero(),464 negative: false,465 degree: 1,466 })467 }468}469470impl pallet_transaction_payment::Config for Runtime {471 type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter<Balances, DealWithFees>;472 type TransactionByteFee = TransactionByteFee;473 type OperationalFeeMultiplier = OperationalFeeMultiplier;474 type WeightToFee = LinearFee<Balance>;475 type FeeMultiplierUpdate = ();476}477478parameter_types! {479 pub const ProposalBond: Permill = Permill::from_percent(5);480 pub const ProposalBondMinimum: Balance = 1 * UNIQUE;481 pub const ProposalBondMaximum: Balance = 1000 * UNIQUE;482 pub const SpendPeriod: BlockNumber = 5 * MINUTES;483 pub const Burn: Permill = Permill::from_percent(0);484 pub const TipCountdown: BlockNumber = 1 * DAYS;485 pub const TipFindersFee: Percent = Percent::from_percent(20);486 pub const TipReportDepositBase: Balance = 1 * UNIQUE;487 pub const DataDepositPerByte: Balance = 1 * CENTIUNIQUE;488 pub const BountyDepositBase: Balance = 1 * UNIQUE;489 pub const BountyDepositPayoutDelay: BlockNumber = 1 * DAYS;490 pub const TreasuryModuleId: PalletId = PalletId(*b"py/trsry");491 pub const BountyUpdatePeriod: BlockNumber = 14 * DAYS;492 pub const MaximumReasonLength: u32 = 16384;493 pub const BountyCuratorDeposit: Permill = Permill::from_percent(50);494 pub const BountyValueMinimum: Balance = 5 * UNIQUE;495 pub const MaxApprovals: u32 = 100;496}497498impl pallet_treasury::Config for Runtime {499 type PalletId = TreasuryModuleId;500 type Currency = Balances;501 type ApproveOrigin = EnsureRoot<AccountId>;502 type RejectOrigin = EnsureRoot<AccountId>;503 type Event = Event;504 type OnSlash = ();505 type ProposalBond = ProposalBond;506 type ProposalBondMinimum = ProposalBondMinimum;507 type ProposalBondMaximum = ProposalBondMaximum;508 type SpendPeriod = SpendPeriod;509 type Burn = Burn;510 type BurnDestination = ();511 type SpendFunds = ();512 type WeightInfo = pallet_treasury::weights::SubstrateWeight<Self>;513 type MaxApprovals = MaxApprovals;514}515516impl pallet_sudo::Config for Runtime {517 type Event = Event;518 type Call = Call;519}520521pub struct RelayChainBlockNumberProvider<T>(sp_std::marker::PhantomData<T>);522523impl<T: cumulus_pallet_parachain_system::Config> BlockNumberProvider524 for RelayChainBlockNumberProvider<T>525{526 type BlockNumber = BlockNumber;527528 fn current_block_number() -> Self::BlockNumber {529 cumulus_pallet_parachain_system::Pallet::<T>::validation_data()530 .map(|d| d.relay_parent_number)531 .unwrap_or_default()532 }533}534535parameter_types! {536 pub const MinVestedTransfer: Balance = 10 * UNIQUE;537 pub const MaxVestingSchedules: u32 = 28;538}539540impl orml_vesting::Config for Runtime {541 type Event = Event;542 type Currency = pallet_balances::Pallet<Runtime>;543 type MinVestedTransfer = MinVestedTransfer;544 type VestedTransferOrigin = EnsureSigned<AccountId>;545 type WeightInfo = ();546 type MaxVestingSchedules = MaxVestingSchedules;547 type BlockNumberProvider = RelayChainBlockNumberProvider<Runtime>;548}549550parameter_types! {551 pub const ReservedDmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;552 pub const ReservedXcmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;553}554555impl cumulus_pallet_parachain_system::Config for Runtime {556 type Event = Event;557 type SelfParaId = parachain_info::Pallet<Self>;558 type OnSystemEvent = ();559 // type DownwardMessageHandlers = cumulus_primitives_utility::UnqueuedDmpAsParent<560 // MaxDownwardMessageWeight,561 // XcmExecutor<XcmConfig>,562 // Call,563 // >;564 type OutboundXcmpMessageSource = XcmpQueue;565 type DmpMessageHandler = DmpQueue;566 type ReservedDmpWeight = ReservedDmpWeight;567 type ReservedXcmpWeight = ReservedXcmpWeight;568 type XcmpMessageHandler = XcmpQueue;569}570571impl parachain_info::Config for Runtime {}572573impl cumulus_pallet_aura_ext::Config for Runtime {}574575parameter_types! {576 pub const RelayLocation: MultiLocation = MultiLocation::parent();577 pub const RelayNetwork: NetworkId = NetworkId::Polkadot;578 pub RelayOrigin: Origin = cumulus_pallet_xcm::Origin::Relay.into();579 pub Ancestry: MultiLocation = Parachain(ParachainInfo::parachain_id().into()).into();580}581582/// Type for specifying how a `MultiLocation` can be converted into an `AccountId`. This is used583/// when determining ownership of accounts for asset transacting and when attempting to use XCM584/// `Transact` in order to determine the dispatch Origin.585pub type LocationToAccountId = (586 // The parent (Relay-chain) origin converts to the default `AccountId`.587 ParentIsPreset<AccountId>,588 // Sibling parachain origins convert to AccountId via the `ParaId::into`.589 SiblingParachainConvertsVia<Sibling, AccountId>,590 // Straight up local `AccountId32` origins just alias directly to `AccountId`.591 AccountId32Aliases<RelayNetwork, AccountId>,592);593594pub struct OnlySelfCurrency;595impl<B: TryFrom<u128>> MatchesFungible<B> for OnlySelfCurrency {596 fn matches_fungible(a: &MultiAsset) -> Option<B> {597 match (&a.id, &a.fun) {598 (Concrete(_), XcmFungible(ref amount)) => CheckedConversion::checked_from(*amount),599 _ => None,600 }601 }602}603604/// Means for transacting assets on this chain.605pub type LocalAssetTransactor = CurrencyAdapter<606 // Use this currency:607 Balances,608 // Use this currency when it is a fungible asset matching the given location or name:609 OnlySelfCurrency,610 // Do a simple punn to convert an AccountId32 MultiLocation into a native chain account ID:611 LocationToAccountId,612 // Our chain's account ID type (we can't get away without mentioning it explicitly):613 AccountId,614 // We don't track any teleports.615 (),616>;617618/// This is the type we use to convert an (incoming) XCM origin into a local `Origin` instance,619/// ready for dispatching a transaction with Xcm's `Transact`. There is an `OriginKind` which can620/// biases the kind of local `Origin` it will become.621pub type XcmOriginToTransactDispatchOrigin = (622 // Sovereign account converter; this attempts to derive an `AccountId` from the origin location623 // using `LocationToAccountId` and then turn that into the usual `Signed` origin. Useful for624 // foreign chains who want to have a local sovereign account on this chain which they control.625 SovereignSignedViaLocation<LocationToAccountId, Origin>,626 // Native converter for Relay-chain (Parent) location; will converts to a `Relay` origin when627 // recognised.628 RelayChainAsNative<RelayOrigin, Origin>,629 // Native converter for sibling Parachains; will convert to a `SiblingPara` origin when630 // recognised.631 SiblingParachainAsNative<cumulus_pallet_xcm::Origin, Origin>,632 // Superuser converter for the Relay-chain (Parent) location. This will allow it to issue a633 // transaction from the Root origin.634 ParentAsSuperuser<Origin>,635 // Native signed account converter; this just converts an `AccountId32` origin into a normal636 // `Origin::Signed` origin of the same 32-byte value.637 SignedAccountId32AsNative<RelayNetwork, Origin>,638 // Xcm origins can be represented natively under the Xcm pallet's Xcm origin.639 XcmPassthrough<Origin>,640);641642parameter_types! {643 // One XCM operation is 1_000_000 weight - almost certainly a conservative estimate.644 pub UnitWeightCost: Weight = 1_000_000;645 // 1200 UNIQUEs buy 1 second of weight.646 pub const WeightPrice: (MultiLocation, u128) = (MultiLocation::parent(), 1_200 * UNIQUE);647 pub const MaxInstructions: u32 = 100;648 pub const MaxAuthorities: u32 = 100_000;649}650651match_type! {652 pub type ParentOrParentsUnitPlurality: impl Contains<MultiLocation> = {653 MultiLocation { parents: 1, interior: Here } |654 MultiLocation { parents: 1, interior: X1(Plurality { id: BodyId::Unit, .. }) }655 };656}657658pub type Barrier = (659 TakeWeightCredit,660 AllowTopLevelPaidExecutionFrom<Everything>,661 AllowUnpaidExecutionFrom<ParentOrParentsUnitPlurality>,662 // ^^^ Parent & its unit plurality gets free execution663);664665pub struct UsingOnlySelfCurrencyComponents<666 WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,667 AssetId: Get<MultiLocation>,668 AccountId,669 Currency: CurrencyT<AccountId>,670 OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,671>(672 Weight,673 Currency::Balance,674 PhantomData<(WeightToFee, AssetId, AccountId, Currency, OnUnbalanced)>,675);676impl<677 WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,678 AssetId: Get<MultiLocation>,679 AccountId,680 Currency: CurrencyT<AccountId>,681 OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,682 > WeightTrader683 for UsingOnlySelfCurrencyComponents<WeightToFee, AssetId, AccountId, Currency, OnUnbalanced>684{685 fn new() -> Self {686 Self(0, Zero::zero(), PhantomData)687 }688689 fn buy_weight(&mut self, weight: Weight, payment: Assets) -> Result<Assets, XcmError> {690 let amount = WeightToFee::calc(&weight);691 let u128_amount: u128 = amount.try_into().map_err(|_| XcmError::Overflow)?;692693 // location to this parachain through relay chain694 let option1: xcm::v1::AssetId = Concrete(MultiLocation {695 parents: 1,696 interior: X1(Parachain(ParachainInfo::parachain_id().into())),697 });698 // direct location699 let option2: xcm::v1::AssetId = Concrete(MultiLocation {700 parents: 0,701 interior: Here,702 });703704 let required = if payment.fungible.contains_key(&option1) {705 (option1, u128_amount).into()706 } else if payment.fungible.contains_key(&option2) {707 (option2, u128_amount).into()708 } else {709 (Concrete(MultiLocation::default()), u128_amount).into()710 };711712 let unused = payment713 .checked_sub(required)714 .map_err(|_| XcmError::TooExpensive)?;715 self.0 = self.0.saturating_add(weight);716 self.1 = self.1.saturating_add(amount);717 Ok(unused)718 }719720 fn refund_weight(&mut self, weight: Weight) -> Option<MultiAsset> {721 let weight = weight.min(self.0);722 let amount = WeightToFee::calc(&weight);723 self.0 -= weight;724 self.1 = self.1.saturating_sub(amount);725 let amount: u128 = amount.saturated_into();726 if amount > 0 {727 Some((AssetId::get(), amount).into())728 } else {729 None730 }731 }732}733impl<734 WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,735 AssetId: Get<MultiLocation>,736 AccountId,737 Currency: CurrencyT<AccountId>,738 OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,739 > Drop740 for UsingOnlySelfCurrencyComponents<WeightToFee, AssetId, AccountId, Currency, OnUnbalanced>741{742 fn drop(&mut self) {743 OnUnbalanced::on_unbalanced(Currency::issue(self.1));744 }745}746747pub struct XcmConfig;748impl Config for XcmConfig {749 type Call = Call;750 type XcmSender = XcmRouter;751 // How to withdraw and deposit an asset.752 type AssetTransactor = LocalAssetTransactor;753 type OriginConverter = XcmOriginToTransactDispatchOrigin;754 type IsReserve = NativeAsset;755 type IsTeleporter = (); // Teleportation is disabled756 type LocationInverter = LocationInverter<Ancestry>;757 type Barrier = Barrier;758 type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;759 type Trader = UsingOnlySelfCurrencyComponents<760 IdentityFee<Balance>,761 RelayLocation,762 AccountId,763 Balances,764 (),765 >;766 type ResponseHandler = (); // Don't handle responses for now.767 type SubscriptionService = PolkadotXcm;768769 type AssetTrap = PolkadotXcm;770 type AssetClaims = PolkadotXcm;771}772773// parameter_types! {774// pub const MaxDownwardMessageWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 10;775// }776777/// No local origins on this chain are allowed to dispatch XCM sends/executions.778pub type LocalOriginToLocation = (SignedToAccountId32<Origin, AccountId, RelayNetwork>,);779780/// The means for routing XCM messages which are not for local execution into the right message781/// queues.782pub type XcmRouter = (783 // Two routers - use UMP to communicate with the relay chain:784 cumulus_primitives_utility::ParentAsUmp<ParachainSystem, ()>,785 // ..and XCMP to communicate with the sibling chains.786 XcmpQueue,787);788789impl pallet_evm_coder_substrate::Config for Runtime {790 type EthereumTransactionSender = pallet_ethereum::Pallet<Self>;791 type GasWeightMapping = FixedGasWeightMapping;792}793794impl pallet_xcm::Config for Runtime {795 type Event = Event;796 type SendXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;797 type XcmRouter = XcmRouter;798 type ExecuteXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;799 type XcmExecuteFilter = Everything;800 type XcmExecutor = XcmExecutor<XcmConfig>;801 type XcmTeleportFilter = Everything;802 type XcmReserveTransferFilter = Everything;803 type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;804 type LocationInverter = LocationInverter<Ancestry>;805 type Origin = Origin;806 type Call = Call;807 const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;808 type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;809}810811impl cumulus_pallet_xcm::Config for Runtime {812 type Event = Event;813 type XcmExecutor = XcmExecutor<XcmConfig>;814}815816impl cumulus_pallet_xcmp_queue::Config for Runtime {817 type WeightInfo = ();818 type Event = Event;819 type XcmExecutor = XcmExecutor<XcmConfig>;820 type ChannelInfo = ParachainSystem;821 type VersionWrapper = ();822 type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;823 type ControllerOrigin = EnsureRoot<AccountId>;824 type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin;825}826827impl cumulus_pallet_dmp_queue::Config for Runtime {828 type Event = Event;829 type XcmExecutor = XcmExecutor<XcmConfig>;830 type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;831}832833impl pallet_aura::Config for Runtime {834 type AuthorityId = AuraId;835 type DisabledValidators = ();836 type MaxAuthorities = MaxAuthorities;837}838839parameter_types! {840 pub TreasuryAccountId: AccountId = TreasuryModuleId::get().into_account();841 pub const CollectionCreationPrice: Balance = 2 * UNIQUE;842}843844impl pallet_common::Config for Runtime {845 type Event = Event;846 type EvmBackwardsAddressMapping = up_evm_mapping::MapBackwardsAddressTruncated;847 type EvmAddressMapping = HashedAddressMapping<Self::Hashing>;848 type CrossAccountId = pallet_common::account::BasicCrossAccountId<Self>;849850 type Currency = Balances;851 type CollectionCreationPrice = CollectionCreationPrice;852 type TreasuryAccountId = TreasuryAccountId;853}854855impl pallet_fungible::Config for Runtime {856 type WeightInfo = pallet_fungible::weights::SubstrateWeight<Self>;857}858impl pallet_refungible::Config for Runtime {859 type WeightInfo = pallet_refungible::weights::SubstrateWeight<Self>;860}861impl pallet_nonfungible::Config for Runtime {862 type WeightInfo = pallet_nonfungible::weights::SubstrateWeight<Self>;863}864865impl pallet_unique::Config for Runtime {866 type Event = Event;867 type WeightInfo = pallet_unique::weights::SubstrateWeight<Self>;868}869870parameter_types! {871 pub const InflationBlockInterval: BlockNumber = 100; // every time per how many blocks inflation is applied872}873874/// Used for the pallet inflation875impl pallet_inflation::Config for Runtime {876 type Currency = Balances;877 type TreasuryAccountId = TreasuryAccountId;878 type InflationBlockInterval = InflationBlockInterval;879 type BlockNumberProvider = RelayChainBlockNumberProvider<Runtime>;880}881882// parameter_types! {883// pub MaximumSchedulerWeight: Weight = Perbill::from_percent(50) *884// RuntimeBlockWeights::get().max_block;885// pub const MaxScheduledPerBlock: u32 = 50;886// }887888type EvmSponsorshipHandler = (889 pallet_unique::UniqueEthSponsorshipHandler<Runtime>,890 pallet_evm_contract_helpers::HelpersContractSponsoring<Runtime>,891);892type SponsorshipHandler = (893 pallet_unique::UniqueSponsorshipHandler<Runtime>,894 //pallet_contract_helpers::ContractSponsorshipHandler<Runtime>,895 pallet_evm_transaction_payment::BridgeSponsorshipHandler<Runtime>,896);897898// impl pallet_unq_scheduler::Config for Runtime {899// type Event = Event;900// type Origin = Origin;901// type PalletsOrigin = OriginCaller;902// type Call = Call;903// type MaximumWeight = MaximumSchedulerWeight;904// type ScheduleOrigin = EnsureSigned<AccountId>;905// type MaxScheduledPerBlock = MaxScheduledPerBlock;906// type SponsorshipHandler = SponsorshipHandler;907// type WeightInfo = ();908// }909910impl pallet_evm_transaction_payment::Config for Runtime {911 type EvmSponsorshipHandler = EvmSponsorshipHandler;912 type Currency = Balances;913 type EvmAddressMapping = HashedAddressMapping<Self::Hashing>;914 type EvmBackwardsAddressMapping = up_evm_mapping::MapBackwardsAddressTruncated;915}916917impl pallet_charge_transaction::Config for Runtime {918 type SponsorshipHandler = SponsorshipHandler;919}920921// impl pallet_contract_helpers::Config for Runtime {922// type DefaultSponsoringRateLimit = DefaultSponsoringRateLimit;923// }924925parameter_types! {926 // 0x842899ECF380553E8a4de75bF534cdf6fBF64049927 pub const HelpersContractAddress: H160 = H160([928 0x84, 0x28, 0x99, 0xec, 0xf3, 0x80, 0x55, 0x3e, 0x8a, 0x4d, 0xe7, 0x5b, 0xf5, 0x34, 0xcd, 0xf6, 0xfb, 0xf6, 0x40, 0x49,929 ]);930}931932impl pallet_evm_contract_helpers::Config for Runtime {933 type ContractAddress = HelpersContractAddress;934 type DefaultSponsoringRateLimit = DefaultSponsoringRateLimit;935}936937construct_runtime!(938 pub enum Runtime where939 Block = Block,940 NodeBlock = opaque::Block,941 UncheckedExtrinsic = UncheckedExtrinsic942 {943 ParachainSystem: cumulus_pallet_parachain_system::{Pallet, Call, Config, Storage, Inherent, Event<T>, ValidateUnsigned} = 20,944 ParachainInfo: parachain_info::{Pallet, Storage, Config} = 21,945946 Aura: pallet_aura::{Pallet, Config<T>} = 22,947 AuraExt: cumulus_pallet_aura_ext::{Pallet, Config} = 23,948949 Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>} = 30,950 RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Pallet, Storage} = 31,951 Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent} = 32,952 TransactionPayment: pallet_transaction_payment::{Pallet, Storage} = 33,953 Treasury: pallet_treasury::{Pallet, Call, Storage, Config, Event<T>} = 34,954 Sudo: pallet_sudo::{Pallet, Call, Storage, Config<T>, Event<T>} = 35,955 System: frame_system::{Pallet, Call, Storage, Config, Event<T>} = 36,956 Vesting: orml_vesting::{Pallet, Storage, Call, Event<T>, Config<T>} = 37,957 // Vesting: pallet_vesting::{Pallet, Call, Config<T>, Storage, Event<T>} = 37,958 // Contracts: pallet_contracts::{Pallet, Call, Storage, Event<T>} = 38,959960 // XCM helpers.961 XcmpQueue: cumulus_pallet_xcmp_queue::{Pallet, Call, Storage, Event<T>} = 50,962 PolkadotXcm: pallet_xcm::{Pallet, Call, Event<T>, Origin} = 51,963 CumulusXcm: cumulus_pallet_xcm::{Pallet, Call, Event<T>, Origin} = 52,964 DmpQueue: cumulus_pallet_dmp_queue::{Pallet, Call, Storage, Event<T>} = 53,965966 // Unique Pallets967 Inflation: pallet_inflation::{Pallet, Call, Storage} = 60,968 Unique: pallet_unique::{Pallet, Call, Storage, Event<T>} = 61,969 // Scheduler: pallet_unq_scheduler::{Pallet, Call, Storage, Event<T>} = 62,970 // free = 63971 Charging: pallet_charge_transaction::{Pallet, Call, Storage } = 64,972 // ContractHelpers: pallet_contract_helpers::{Pallet, Call, Storage} = 65,973 Common: pallet_common::{Pallet, Storage, Event<T>} = 66,974 Fungible: pallet_fungible::{Pallet, Storage} = 67,975 Refungible: pallet_refungible::{Pallet, Storage} = 68,976 Nonfungible: pallet_nonfungible::{Pallet, Storage} = 69,977978 // Frontier979 EVM: pallet_evm::{Pallet, Config, Call, Storage, Event<T>} = 100,980 Ethereum: pallet_ethereum::{Pallet, Config, Call, Storage, Event, Origin} = 101,981982 EvmCoderSubstrate: pallet_evm_coder_substrate::{Pallet, Storage} = 150,983 EvmContractHelpers: pallet_evm_contract_helpers::{Pallet, Storage} = 151,984 EvmTransactionPayment: pallet_evm_transaction_payment::{Pallet} = 152,985 EvmMigration: pallet_evm_migration::{Pallet, Call, Storage} = 153,986 }987);988989pub struct TransactionConverter;990991impl fp_rpc::ConvertTransaction<UncheckedExtrinsic> for TransactionConverter {992 fn convert_transaction(&self, transaction: pallet_ethereum::Transaction) -> UncheckedExtrinsic {993 UncheckedExtrinsic::new_unsigned(994 pallet_ethereum::Call::<Runtime>::transact { transaction }.into(),995 )996 }997}998999impl fp_rpc::ConvertTransaction<opaque::UncheckedExtrinsic> for TransactionConverter {1000 fn convert_transaction(1001 &self,1002 transaction: pallet_ethereum::Transaction,1003 ) -> opaque::UncheckedExtrinsic {1004 let extrinsic = UncheckedExtrinsic::new_unsigned(1005 pallet_ethereum::Call::<Runtime>::transact { transaction }.into(),1006 );1007 let encoded = extrinsic.encode();1008 opaque::UncheckedExtrinsic::decode(&mut &encoded[..])1009 .expect("Encoded extrinsic is always valid")1010 }1011}10121013/// The address format for describing accounts.1014pub type Address = sp_runtime::MultiAddress<AccountId, ()>;1015/// Block header type as expected by this runtime.1016pub type Header = generic::Header<BlockNumber, BlakeTwo256>;1017/// Block type as expected by this runtime.1018pub type Block = generic::Block<Header, UncheckedExtrinsic>;1019/// A Block signed with a Justification1020pub type SignedBlock = generic::SignedBlock<Block>;1021/// BlockId type as expected by this runtime.1022pub type BlockId = generic::BlockId<Block>;1023/// The SignedExtension to the basic transaction logic.1024pub type SignedExtra = (1025 frame_system::CheckSpecVersion<Runtime>,1026 // system::CheckTxVersion<Runtime>,1027 frame_system::CheckGenesis<Runtime>,1028 frame_system::CheckEra<Runtime>,1029 frame_system::CheckNonce<Runtime>,1030 frame_system::CheckWeight<Runtime>,1031 pallet_charge_transaction::ChargeTransactionPayment<Runtime>,1032 //pallet_contract_helpers::ContractHelpersExtension<Runtime>,1033);1034/// Unchecked extrinsic type as expected by this runtime.1035pub type UncheckedExtrinsic =1036 fp_self_contained::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;1037/// Extrinsic type that has already been checked.1038pub type CheckedExtrinsic = fp_self_contained::CheckedExtrinsic<AccountId, Call, SignedExtra, H160>;1039/// Executive: handles dispatch to the various modules.1040pub type Executive = frame_executive::Executive<1041 Runtime,1042 Block,1043 frame_system::ChainContext<Runtime>,1044 Runtime,1045 AllPalletsReversedWithSystemFirst,1046>;10471048impl_opaque_keys! {1049 pub struct SessionKeys {1050 pub aura: Aura,1051 }1052}10531054impl fp_self_contained::SelfContainedCall for Call {1055 type SignedInfo = H160;10561057 fn is_self_contained(&self) -> bool {1058 match self {1059 Call::Ethereum(call) => call.is_self_contained(),1060 _ => false,1061 }1062 }10631064 fn check_self_contained(&self) -> Option<Result<Self::SignedInfo, TransactionValidityError>> {1065 match self {1066 Call::Ethereum(call) => call.check_self_contained(),1067 _ => None,1068 }1069 }10701071 fn validate_self_contained(&self, info: &Self::SignedInfo) -> Option<TransactionValidity> {1072 match self {1073 Call::Ethereum(call) => call.validate_self_contained(info),1074 _ => None,1075 }1076 }10771078 fn pre_dispatch_self_contained(1079 &self,1080 info: &Self::SignedInfo,1081 ) -> Option<Result<(), TransactionValidityError>> {1082 match self {1083 Call::Ethereum(call) => call.pre_dispatch_self_contained(info),1084 _ => None,1085 }1086 }10871088 fn apply_self_contained(1089 self,1090 info: Self::SignedInfo,1091 ) -> Option<sp_runtime::DispatchResultWithInfo<PostDispatchInfoOf<Self>>> {1092 match self {1093 call @ Call::Ethereum(pallet_ethereum::Call::transact { .. }) => Some(call.dispatch(1094 Origin::from(pallet_ethereum::RawOrigin::EthereumTransaction(info)),1095 )),1096 _ => None,1097 }1098 }1099}11001101macro_rules! dispatch_unique_runtime {1102 ($collection:ident.$method:ident($($name:ident),*)) => {{1103 use pallet_unique::dispatch::Dispatched;11041105 let collection = Dispatched::dispatch(<pallet_common::CollectionHandle<Runtime>>::try_get($collection)?);1106 let dispatch = collection.as_dyn();11071108 Ok(dispatch.$method($($name),*))1109 }};1110}11111112impl_common_runtime_apis!();11131114struct CheckInherents;11151116impl cumulus_pallet_parachain_system::CheckInherents<Block> for CheckInherents {1117 fn check_inherents(1118 block: &Block,1119 relay_state_proof: &cumulus_pallet_parachain_system::RelayChainStateProof,1120 ) -> sp_inherents::CheckInherentsResult {1121 let relay_chain_slot = relay_state_proof1122 .read_slot()1123 .expect("Could not read the relay chain slot from the proof");11241125 let inherent_data =1126 cumulus_primitives_timestamp::InherentDataProvider::from_relay_chain_slot_and_duration(1127 relay_chain_slot,1128 sp_std::time::Duration::from_secs(6),1129 )1130 .create_inherent_data()1131 .expect("Could not create the timestamp inherent data");11321133 inherent_data.check_extrinsics(block)1134 }1135}11361137cumulus_pallet_parachain_system::register_validate_block!(1138 Runtime = Runtime,1139 BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor::<Runtime, Executive>,1140 CheckInherents = CheckInherents,1141);1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617//! The Substrate Node Template runtime. This can be compiled with `#[no_std]`, ready for Wasm.1819#![cfg_attr(not(feature = "std"), no_std)]20// `construct_runtime!` does a lot of recursion and requires us to increase the limit to 256.21#![recursion_limit = "1024"]22#![allow(clippy::from_over_into, clippy::identity_op)]23#![allow(clippy::fn_to_numeric_cast_with_truncation)]24// Make the WASM binary available.25#[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;31// #[cfg(any(feature = "std", test))]32// pub use sp_runtime::BuildStorage;3334use 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};49// A few exports that help ease life for downstream crates.50pub 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::*;68// use pallet_contracts::weights::WeightInfo;69// #[cfg(any(feature = "std", test))]70use 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};8687// pub use pallet_timestamp::Call as TimestampCall;8889// Polkadot imports90use pallet_xcm::XcmPassthrough;91use polkadot_parachain::primitives::Sibling;92use xcm::v1::{BodyId, Junction::*, MultiLocation, NetworkId, Junctions::*};93use xcm_builder::{94 AccountId32Aliases, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, CurrencyAdapter,95 EnsureXcmOrigin, FixedWeightBounds, LocationInverter, NativeAsset, ParentAsSuperuser,96 RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia,97 SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit,98 ParentIsPreset,99};100use xcm_executor::{Config, XcmExecutor, Assets};101use sp_std::{marker::PhantomData};102103use xcm::latest::{104 // Xcm,105 AssetId::{Concrete},106 Fungibility::Fungible as XcmFungible,107 MultiAsset,108 Error as XcmError,109};110use xcm_executor::traits::{MatchesFungible, WeightTrader};111//use xcm_executor::traits::MatchesFungible;112use sp_runtime::traits::CheckedConversion;113114use unique_runtime_common::{impl_common_runtime_apis, types::*, constants::*};115116pub const RUNTIME_NAME: &str = "Unique";117118type CrossAccountId = pallet_common::account::BasicCrossAccountId<Runtime>;119120impl RuntimeInstance for Runtime {121 type CrossAccountId = self::CrossAccountId;122123 type TransactionConverter = self::TransactionConverter;124125 fn get_transaction_converter() -> TransactionConverter {126 TransactionConverter127 }128}129130/// Opaque types. These are used by the CLI to instantiate machinery that don't need to know131/// the specifics of the runtime. They can then be made to be agnostic over specific formats132/// of data like extrinsics, allowing for them to continue syncing the network through upgrades133/// to even the core data structures.134pub mod opaque {135 use sp_std::prelude::*;136 use sp_runtime::impl_opaque_keys;137 use super::Aura;138139 pub use unique_runtime_common::types::*;140141 impl_opaque_keys! {142 pub struct SessionKeys {143 pub aura: Aura,144 }145 }146}147148/// This runtime version.149pub const VERSION: RuntimeVersion = RuntimeVersion {150 spec_name: create_runtime_str!(RUNTIME_NAME),151 impl_name: create_runtime_str!(RUNTIME_NAME),152 authoring_version: 1,153 spec_version: 917004,154 impl_version: 0,155 apis: RUNTIME_API_VERSIONS,156 transaction_version: 1,157 state_version: 0,158};159160#[derive(codec::Encode, codec::Decode)]161pub enum XCMPMessage<XAccountId, XBalance> {162 /// Transfer tokens to the given account from the Parachain account.163 TransferToken(XAccountId, XBalance),164}165166/// The version information used to identify this runtime when compiled natively.167#[cfg(feature = "std")]168pub fn native_version() -> NativeVersion {169 NativeVersion {170 runtime_version: VERSION,171 can_author_with: Default::default(),172 }173}174175type NegativeImbalance = <Balances as Currency<AccountId>>::NegativeImbalance;176177pub struct DealWithFees;178impl OnUnbalanced<NegativeImbalance> for DealWithFees {179 fn on_unbalanceds<B>(mut fees_then_tips: impl Iterator<Item = NegativeImbalance>) {180 if let Some(fees) = fees_then_tips.next() {181 // for fees, 100% to treasury182 let mut split = fees.ration(100, 0);183 if let Some(tips) = fees_then_tips.next() {184 // for tips, if any, 100% to treasury185 tips.ration_merge_into(100, 0, &mut split);186 }187 Treasury::on_unbalanced(split.0);188 // Author::on_unbalanced(split.1);189 }190 }191}192193parameter_types! {194 pub const BlockHashCount: BlockNumber = 2400;195 pub RuntimeBlockLength: BlockLength =196 BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);197 pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);198 pub const MaximumBlockLength: u32 = 5 * 1024 * 1024;199 pub RuntimeBlockWeights: BlockWeights = BlockWeights::builder()200 .base_block(BlockExecutionWeight::get())201 .for_class(DispatchClass::all(), |weights| {202 weights.base_extrinsic = ExtrinsicBaseWeight::get();203 })204 .for_class(DispatchClass::Normal, |weights| {205 weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT);206 })207 .for_class(DispatchClass::Operational, |weights| {208 weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT);209 // Operational transactions have some extra reserved space, so that they210 // are included even if block reached `MAXIMUM_BLOCK_WEIGHT`.211 weights.reserved = Some(212 MAXIMUM_BLOCK_WEIGHT - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT213 );214 })215 .avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO)216 .build_or_panic();217 pub const Version: RuntimeVersion = VERSION;218 pub const SS58Prefix: u16 = 7391;219}220221parameter_types! {222 pub const ChainId: u64 = 8880;223}224225pub struct FixedFee;226impl FeeCalculator for FixedFee {227 fn min_gas_price() -> U256 {228 MIN_GAS_PRICE.into()229 }230}231232// Assuming slowest ethereum opcode is SSTORE, with gas price of 20000 as our worst case233// (contract, which only writes a lot of data),234// approximating on top of our real store write weight235parameter_types! {236 pub const WritesPerSecond: u64 = WEIGHT_PER_SECOND / <Runtime as frame_system::Config>::DbWeight::get().write;237 pub const GasPerSecond: u64 = WritesPerSecond::get() * 20000;238 pub const WeightPerGas: u64 = WEIGHT_PER_SECOND / GasPerSecond::get();239}240241/// Limiting EVM execution to 50% of block for substrate users and management tasks242/// EVM transaction consumes more weight than substrate's, so we can't rely on them being243/// scheduled fairly244const EVM_DISPATCH_RATIO: Perbill = Perbill::from_percent(50);245parameter_types! {246 pub BlockGasLimit: U256 = U256::from(NORMAL_DISPATCH_RATIO * EVM_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT / WeightPerGas::get());247}248249pub enum FixedGasWeightMapping {}250impl GasWeightMapping for FixedGasWeightMapping {251 fn gas_to_weight(gas: u64) -> Weight {252 gas.saturating_mul(WeightPerGas::get())253 }254 fn weight_to_gas(weight: Weight) -> u64 {255 weight / WeightPerGas::get()256 }257}258259impl pallet_evm::Config for Runtime {260 type BlockGasLimit = BlockGasLimit;261 type FeeCalculator = FixedFee;262 type GasWeightMapping = FixedGasWeightMapping;263 type BlockHashMapping = pallet_ethereum::EthereumBlockHashMapping<Self>;264 type CallOrigin = EnsureAddressTruncated;265 type WithdrawOrigin = EnsureAddressTruncated;266 type AddressMapping = HashedAddressMapping<Self::Hashing>;267 type PrecompilesType = ();268 type PrecompilesValue = ();269 type Currency = Balances;270 type Event = Event;271 type OnMethodCall = (272 pallet_evm_migration::OnMethodCall<Self>,273 pallet_unique::UniqueErcSupport<Self>,274 pallet_evm_contract_helpers::HelpersOnMethodCall<Self>,275 );276 type OnCreate = pallet_evm_contract_helpers::HelpersOnCreate<Self>;277 type ChainId = ChainId;278 type Runner = pallet_evm::runner::stack::Runner<Self>;279 type OnChargeTransaction = pallet_evm_transaction_payment::OnChargeTransaction<Self>;280 type TransactionValidityHack = pallet_evm_transaction_payment::TransactionValidityHack<Self>;281 type FindAuthor = EthereumFindAuthor<Aura>;282}283284impl pallet_evm_migration::Config for Runtime {285 type WeightInfo = pallet_evm_migration::weights::SubstrateWeight<Self>;286}287288pub struct EthereumFindAuthor<F>(core::marker::PhantomData<F>);289impl<F: FindAuthor<u32>> FindAuthor<H160> for EthereumFindAuthor<F> {290 fn find_author<'a, I>(digests: I) -> Option<H160>291 where292 I: 'a + IntoIterator<Item = (ConsensusEngineId, &'a [u8])>,293 {294 if let Some(author_index) = F::find_author(digests) {295 let authority_id = Aura::authorities()[author_index as usize].clone();296 return Some(H160::from_slice(&authority_id.to_raw_vec()[4..24]));297 }298 None299 }300}301302impl pallet_ethereum::Config for Runtime {303 type Event = Event;304 type StateRoot = pallet_ethereum::IntermediateStateRoot;305}306307impl pallet_randomness_collective_flip::Config for Runtime {}308309impl frame_system::Config for Runtime {310 /// The data to be stored in an account.311 type AccountData = pallet_balances::AccountData<Balance>;312 /// The identifier used to distinguish between accounts.313 type AccountId = AccountId;314 /// The basic call filter to use in dispatchable.315 type BaseCallFilter = Everything;316 /// Maximum number of block number to block hash mappings to keep (oldest pruned first).317 type BlockHashCount = BlockHashCount;318 /// The maximum length of a block (in bytes).319 type BlockLength = RuntimeBlockLength;320 /// The index type for blocks.321 type BlockNumber = BlockNumber;322 /// The weight of the overhead invoked on the block import process, independent of the extrinsics included in that block.323 type BlockWeights = RuntimeBlockWeights;324 /// The aggregated dispatch type that is available for extrinsics.325 type Call = Call;326 /// The weight of database operations that the runtime can invoke.327 type DbWeight = RocksDbWeight;328 /// The ubiquitous event type.329 type Event = Event;330 /// The type for hashing blocks and tries.331 type Hash = Hash;332 /// The hashing algorithm used.333 type Hashing = BlakeTwo256;334 /// The header type.335 type Header = generic::Header<BlockNumber, BlakeTwo256>;336 /// The index type for storing how many extrinsics an account has signed.337 type Index = Index;338 /// The lookup mechanism to get account ID from whatever is passed in dispatchers.339 type Lookup = AccountIdLookup<AccountId, ()>;340 /// What to do if an account is fully reaped from the system.341 type OnKilledAccount = ();342 /// What to do if a new account is created.343 type OnNewAccount = ();344 type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode<Self>;345 /// The ubiquitous origin type.346 type Origin = Origin;347 /// This type is being generated by `construct_runtime!`.348 type PalletInfo = PalletInfo;349 /// This is used as an identifier of the chain. 42 is the generic substrate prefix.350 type SS58Prefix = SS58Prefix;351 /// Weight information for the extrinsics of this pallet.352 type SystemWeightInfo = frame_system::weights::SubstrateWeight<Self>;353 /// Version of the runtime.354 type Version = Version;355 type MaxConsumers = ConstU32<16>;356}357358parameter_types! {359 pub const MinimumPeriod: u64 = SLOT_DURATION / 2;360}361362impl pallet_timestamp::Config for Runtime {363 /// A timestamp: milliseconds since the unix epoch.364 type Moment = u64;365 type OnTimestampSet = ();366 type MinimumPeriod = MinimumPeriod;367 type WeightInfo = ();368}369370parameter_types! {371 // pub const ExistentialDeposit: u128 = 500;372 pub const ExistentialDeposit: u128 = 0;373 pub const MaxLocks: u32 = 50;374}375376impl pallet_balances::Config for Runtime {377 type MaxLocks = MaxLocks;378 type MaxReserves = ();379 type ReserveIdentifier = [u8; 8];380 /// The type for recording an account's balance.381 type Balance = Balance;382 /// The ubiquitous event type.383 type Event = Event;384 type DustRemoval = Treasury;385 type ExistentialDeposit = ExistentialDeposit;386 type AccountStore = System;387 type WeightInfo = pallet_balances::weights::SubstrateWeight<Self>;388}389390pub const fn deposit(items: u32, bytes: u32) -> Balance {391 items as Balance * 15 * CENTIUNIQUE + (bytes as Balance) * 6 * CENTIUNIQUE392}393394/*395parameter_types! {396 pub TombstoneDeposit: Balance = deposit(397 1,398 sp_std::mem::size_of::<pallet_contracts::Pallet<Runtime>> as u32,399 );400 pub DepositPerContract: Balance = TombstoneDeposit::get();401 pub const DepositPerStorageByte: Balance = deposit(0, 1);402 pub const DepositPerStorageItem: Balance = deposit(1, 0);403 pub RentFraction: Perbill = Perbill::from_rational(1u32, 30 * DAYS);404 pub const SurchargeReward: Balance = 150 * MILLIUNIQUE;405 pub const SignedClaimHandicap: u32 = 2;406 pub const MaxDepth: u32 = 32;407 pub const MaxValueSize: u32 = 16 * 1024;408 pub const MaxCodeSize: u32 = 1024 * 1024 * 25; // 25 Mb409 // The lazy deletion runs inside on_initialize.410 pub DeletionWeightLimit: Weight = AVERAGE_ON_INITIALIZE_RATIO *411 RuntimeBlockWeights::get().max_block;412 // The weight needed for decoding the queue should be less or equal than a fifth413 // of the overall weight dedicated to the lazy deletion.414 pub DeletionQueueDepth: u32 = ((DeletionWeightLimit::get() / (415 <Runtime as pallet_contracts::Config>::WeightInfo::on_initialize_per_queue_item(1) -416 <Runtime as pallet_contracts::Config>::WeightInfo::on_initialize_per_queue_item(0)417 )) / 5) as u32;418 pub Schedule: pallet_contracts::Schedule<Runtime> = Default::default();419}420421impl pallet_contracts::Config for Runtime {422 type Time = Timestamp;423 type Randomness = RandomnessCollectiveFlip;424 type Currency = Balances;425 type Event = Event;426 type RentPayment = ();427 type SignedClaimHandicap = SignedClaimHandicap;428 type TombstoneDeposit = TombstoneDeposit;429 type DepositPerContract = DepositPerContract;430 type DepositPerStorageByte = DepositPerStorageByte;431 type DepositPerStorageItem = DepositPerStorageItem;432 type RentFraction = RentFraction;433 type SurchargeReward = SurchargeReward;434 type WeightPrice = pallet_transaction_payment::Pallet<Self>;435 type WeightInfo = pallet_contracts::weights::SubstrateWeight<Self>;436 type ChainExtension = NFTExtension;437 type DeletionQueueDepth = DeletionQueueDepth;438 type DeletionWeightLimit = DeletionWeightLimit;439 type Schedule = Schedule;440 type CallStack = [pallet_contracts::Frame<Self>; 31];441}442*/443444parameter_types! {445 /// This value increases the priority of `Operational` transactions by adding446 /// a "virtual tip" that's equal to the `OperationalFeeMultiplier * final_fee`.447 pub const OperationalFeeMultiplier: u8 = 5;448}449450/// Linear implementor of `WeightToFeePolynomial`451pub struct LinearFee<T>(sp_std::marker::PhantomData<T>);452453impl<T> WeightToFeePolynomial for LinearFee<T>454where455 T: BaseArithmetic + From<u32> + Copy + Unsigned,456{457 type Balance = T;458459 fn polynomial() -> WeightToFeeCoefficients<Self::Balance> {460 smallvec!(WeightToFeeCoefficient {461 // Targeting 0.1 Unique per NFT transfer462 coeff_integer: WEIGHT_TO_FEE_COEFF.into(),463 coeff_frac: Perbill::zero(),464 negative: false,465 degree: 1,466 })467 }468}469470impl pallet_transaction_payment::Config for Runtime {471 type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter<Balances, DealWithFees>;472 type TransactionByteFee = TransactionByteFee;473 type OperationalFeeMultiplier = OperationalFeeMultiplier;474 type WeightToFee = LinearFee<Balance>;475 type FeeMultiplierUpdate = ();476}477478parameter_types! {479 pub const ProposalBond: Permill = Permill::from_percent(5);480 pub const ProposalBondMinimum: Balance = 1 * UNIQUE;481 pub const ProposalBondMaximum: Balance = 1000 * UNIQUE;482 pub const SpendPeriod: BlockNumber = 5 * MINUTES;483 pub const Burn: Permill = Permill::from_percent(0);484 pub const TipCountdown: BlockNumber = 1 * DAYS;485 pub const TipFindersFee: Percent = Percent::from_percent(20);486 pub const TipReportDepositBase: Balance = 1 * UNIQUE;487 pub const DataDepositPerByte: Balance = 1 * CENTIUNIQUE;488 pub const BountyDepositBase: Balance = 1 * UNIQUE;489 pub const BountyDepositPayoutDelay: BlockNumber = 1 * DAYS;490 pub const TreasuryModuleId: PalletId = PalletId(*b"py/trsry");491 pub const BountyUpdatePeriod: BlockNumber = 14 * DAYS;492 pub const MaximumReasonLength: u32 = 16384;493 pub const BountyCuratorDeposit: Permill = Permill::from_percent(50);494 pub const BountyValueMinimum: Balance = 5 * UNIQUE;495 pub const MaxApprovals: u32 = 100;496}497498impl pallet_treasury::Config for Runtime {499 type PalletId = TreasuryModuleId;500 type Currency = Balances;501 type ApproveOrigin = EnsureRoot<AccountId>;502 type RejectOrigin = EnsureRoot<AccountId>;503 type Event = Event;504 type OnSlash = ();505 type ProposalBond = ProposalBond;506 type ProposalBondMinimum = ProposalBondMinimum;507 type ProposalBondMaximum = ProposalBondMaximum;508 type SpendPeriod = SpendPeriod;509 type Burn = Burn;510 type BurnDestination = ();511 type SpendFunds = ();512 type WeightInfo = pallet_treasury::weights::SubstrateWeight<Self>;513 type MaxApprovals = MaxApprovals;514}515516impl pallet_sudo::Config for Runtime {517 type Event = Event;518 type Call = Call;519}520521pub struct RelayChainBlockNumberProvider<T>(sp_std::marker::PhantomData<T>);522523impl<T: cumulus_pallet_parachain_system::Config> BlockNumberProvider524 for RelayChainBlockNumberProvider<T>525{526 type BlockNumber = BlockNumber;527528 fn current_block_number() -> Self::BlockNumber {529 cumulus_pallet_parachain_system::Pallet::<T>::validation_data()530 .map(|d| d.relay_parent_number)531 .unwrap_or_default()532 }533}534535parameter_types! {536 pub const MinVestedTransfer: Balance = 10 * UNIQUE;537 pub const MaxVestingSchedules: u32 = 28;538}539540impl orml_vesting::Config for Runtime {541 type Event = Event;542 type Currency = pallet_balances::Pallet<Runtime>;543 type MinVestedTransfer = MinVestedTransfer;544 type VestedTransferOrigin = EnsureSigned<AccountId>;545 type WeightInfo = ();546 type MaxVestingSchedules = MaxVestingSchedules;547 type BlockNumberProvider = RelayChainBlockNumberProvider<Runtime>;548}549550parameter_types! {551 pub const ReservedDmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;552 pub const ReservedXcmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;553}554555impl cumulus_pallet_parachain_system::Config for Runtime {556 type Event = Event;557 type SelfParaId = parachain_info::Pallet<Self>;558 type OnSystemEvent = ();559 // type DownwardMessageHandlers = cumulus_primitives_utility::UnqueuedDmpAsParent<560 // MaxDownwardMessageWeight,561 // XcmExecutor<XcmConfig>,562 // Call,563 // >;564 type OutboundXcmpMessageSource = XcmpQueue;565 type DmpMessageHandler = DmpQueue;566 type ReservedDmpWeight = ReservedDmpWeight;567 type ReservedXcmpWeight = ReservedXcmpWeight;568 type XcmpMessageHandler = XcmpQueue;569}570571impl parachain_info::Config for Runtime {}572573impl cumulus_pallet_aura_ext::Config for Runtime {}574575parameter_types! {576 pub const RelayLocation: MultiLocation = MultiLocation::parent();577 pub const RelayNetwork: NetworkId = NetworkId::Polkadot;578 pub RelayOrigin: Origin = cumulus_pallet_xcm::Origin::Relay.into();579 pub Ancestry: MultiLocation = Parachain(ParachainInfo::parachain_id().into()).into();580}581582/// Type for specifying how a `MultiLocation` can be converted into an `AccountId`. This is used583/// when determining ownership of accounts for asset transacting and when attempting to use XCM584/// `Transact` in order to determine the dispatch Origin.585pub type LocationToAccountId = (586 // The parent (Relay-chain) origin converts to the default `AccountId`.587 ParentIsPreset<AccountId>,588 // Sibling parachain origins convert to AccountId via the `ParaId::into`.589 SiblingParachainConvertsVia<Sibling, AccountId>,590 // Straight up local `AccountId32` origins just alias directly to `AccountId`.591 AccountId32Aliases<RelayNetwork, AccountId>,592);593594pub struct OnlySelfCurrency;595impl<B: TryFrom<u128>> MatchesFungible<B> for OnlySelfCurrency {596 fn matches_fungible(a: &MultiAsset) -> Option<B> {597 match (&a.id, &a.fun) {598 (Concrete(_), XcmFungible(ref amount)) => CheckedConversion::checked_from(*amount),599 _ => None,600 }601 }602}603604/// Means for transacting assets on this chain.605pub type LocalAssetTransactor = CurrencyAdapter<606 // Use this currency:607 Balances,608 // Use this currency when it is a fungible asset matching the given location or name:609 OnlySelfCurrency,610 // Do a simple punn to convert an AccountId32 MultiLocation into a native chain account ID:611 LocationToAccountId,612 // Our chain's account ID type (we can't get away without mentioning it explicitly):613 AccountId,614 // We don't track any teleports.615 (),616>;617618/// This is the type we use to convert an (incoming) XCM origin into a local `Origin` instance,619/// ready for dispatching a transaction with Xcm's `Transact`. There is an `OriginKind` which can620/// biases the kind of local `Origin` it will become.621pub type XcmOriginToTransactDispatchOrigin = (622 // Sovereign account converter; this attempts to derive an `AccountId` from the origin location623 // using `LocationToAccountId` and then turn that into the usual `Signed` origin. Useful for624 // foreign chains who want to have a local sovereign account on this chain which they control.625 SovereignSignedViaLocation<LocationToAccountId, Origin>,626 // Native converter for Relay-chain (Parent) location; will converts to a `Relay` origin when627 // recognised.628 RelayChainAsNative<RelayOrigin, Origin>,629 // Native converter for sibling Parachains; will convert to a `SiblingPara` origin when630 // recognised.631 SiblingParachainAsNative<cumulus_pallet_xcm::Origin, Origin>,632 // Superuser converter for the Relay-chain (Parent) location. This will allow it to issue a633 // transaction from the Root origin.634 ParentAsSuperuser<Origin>,635 // Native signed account converter; this just converts an `AccountId32` origin into a normal636 // `Origin::Signed` origin of the same 32-byte value.637 SignedAccountId32AsNative<RelayNetwork, Origin>,638 // Xcm origins can be represented natively under the Xcm pallet's Xcm origin.639 XcmPassthrough<Origin>,640);641642parameter_types! {643 // One XCM operation is 1_000_000 weight - almost certainly a conservative estimate.644 pub UnitWeightCost: Weight = 1_000_000;645 // 1200 UNIQUEs buy 1 second of weight.646 pub const WeightPrice: (MultiLocation, u128) = (MultiLocation::parent(), 1_200 * UNIQUE);647 pub const MaxInstructions: u32 = 100;648 pub const MaxAuthorities: u32 = 100_000;649}650651match_type! {652 pub type ParentOrParentsUnitPlurality: impl Contains<MultiLocation> = {653 MultiLocation { parents: 1, interior: Here } |654 MultiLocation { parents: 1, interior: X1(Plurality { id: BodyId::Unit, .. }) }655 };656}657658pub type Barrier = (659 TakeWeightCredit,660 AllowTopLevelPaidExecutionFrom<Everything>,661 AllowUnpaidExecutionFrom<ParentOrParentsUnitPlurality>,662 // ^^^ Parent & its unit plurality gets free execution663);664665pub struct UsingOnlySelfCurrencyComponents<666 WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,667 AssetId: Get<MultiLocation>,668 AccountId,669 Currency: CurrencyT<AccountId>,670 OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,671>(672 Weight,673 Currency::Balance,674 PhantomData<(WeightToFee, AssetId, AccountId, Currency, OnUnbalanced)>,675);676impl<677 WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,678 AssetId: Get<MultiLocation>,679 AccountId,680 Currency: CurrencyT<AccountId>,681 OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,682 > WeightTrader683 for UsingOnlySelfCurrencyComponents<WeightToFee, AssetId, AccountId, Currency, OnUnbalanced>684{685 fn new() -> Self {686 Self(0, Zero::zero(), PhantomData)687 }688689 fn buy_weight(&mut self, weight: Weight, payment: Assets) -> Result<Assets, XcmError> {690 let amount = WeightToFee::calc(&weight);691 let u128_amount: u128 = amount.try_into().map_err(|_| XcmError::Overflow)?;692693 // location to this parachain through relay chain694 let option1: xcm::v1::AssetId = Concrete(MultiLocation {695 parents: 1,696 interior: X1(Parachain(ParachainInfo::parachain_id().into())),697 });698 // direct location699 let option2: xcm::v1::AssetId = Concrete(MultiLocation {700 parents: 0,701 interior: Here,702 });703704 let required = if payment.fungible.contains_key(&option1) {705 (option1, u128_amount).into()706 } else if payment.fungible.contains_key(&option2) {707 (option2, u128_amount).into()708 } else {709 (Concrete(MultiLocation::default()), u128_amount).into()710 };711712 let unused = payment713 .checked_sub(required)714 .map_err(|_| XcmError::TooExpensive)?;715 self.0 = self.0.saturating_add(weight);716 self.1 = self.1.saturating_add(amount);717 Ok(unused)718 }719720 fn refund_weight(&mut self, weight: Weight) -> Option<MultiAsset> {721 let weight = weight.min(self.0);722 let amount = WeightToFee::calc(&weight);723 self.0 -= weight;724 self.1 = self.1.saturating_sub(amount);725 let amount: u128 = amount.saturated_into();726 if amount > 0 {727 Some((AssetId::get(), amount).into())728 } else {729 None730 }731 }732}733impl<734 WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,735 AssetId: Get<MultiLocation>,736 AccountId,737 Currency: CurrencyT<AccountId>,738 OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,739 > Drop740 for UsingOnlySelfCurrencyComponents<WeightToFee, AssetId, AccountId, Currency, OnUnbalanced>741{742 fn drop(&mut self) {743 OnUnbalanced::on_unbalanced(Currency::issue(self.1));744 }745}746747pub struct XcmConfig;748impl Config for XcmConfig {749 type Call = Call;750 type XcmSender = XcmRouter;751 // How to withdraw and deposit an asset.752 type AssetTransactor = LocalAssetTransactor;753 type OriginConverter = XcmOriginToTransactDispatchOrigin;754 type IsReserve = NativeAsset;755 type IsTeleporter = (); // Teleportation is disabled756 type LocationInverter = LocationInverter<Ancestry>;757 type Barrier = Barrier;758 type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;759 type Trader = UsingOnlySelfCurrencyComponents<760 IdentityFee<Balance>,761 RelayLocation,762 AccountId,763 Balances,764 (),765 >;766 type ResponseHandler = (); // Don't handle responses for now.767 type SubscriptionService = PolkadotXcm;768769 type AssetTrap = PolkadotXcm;770 type AssetClaims = PolkadotXcm;771}772773// parameter_types! {774// pub const MaxDownwardMessageWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 10;775// }776777/// No local origins on this chain are allowed to dispatch XCM sends/executions.778pub type LocalOriginToLocation = (SignedToAccountId32<Origin, AccountId, RelayNetwork>,);779780/// The means for routing XCM messages which are not for local execution into the right message781/// queues.782pub type XcmRouter = (783 // Two routers - use UMP to communicate with the relay chain:784 cumulus_primitives_utility::ParentAsUmp<ParachainSystem, ()>,785 // ..and XCMP to communicate with the sibling chains.786 XcmpQueue,787);788789impl pallet_evm_coder_substrate::Config for Runtime {790 type EthereumTransactionSender = pallet_ethereum::Pallet<Self>;791 type GasWeightMapping = FixedGasWeightMapping;792}793794impl pallet_xcm::Config for Runtime {795 type Event = Event;796 type SendXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;797 type XcmRouter = XcmRouter;798 type ExecuteXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;799 type XcmExecuteFilter = Everything;800 type XcmExecutor = XcmExecutor<XcmConfig>;801 type XcmTeleportFilter = Everything;802 type XcmReserveTransferFilter = Everything;803 type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;804 type LocationInverter = LocationInverter<Ancestry>;805 type Origin = Origin;806 type Call = Call;807 const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;808 type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;809}810811impl cumulus_pallet_xcm::Config for Runtime {812 type Event = Event;813 type XcmExecutor = XcmExecutor<XcmConfig>;814}815816impl cumulus_pallet_xcmp_queue::Config for Runtime {817 type WeightInfo = ();818 type Event = Event;819 type XcmExecutor = XcmExecutor<XcmConfig>;820 type ChannelInfo = ParachainSystem;821 type VersionWrapper = ();822 type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;823 type ControllerOrigin = EnsureRoot<AccountId>;824 type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin;825}826827impl cumulus_pallet_dmp_queue::Config for Runtime {828 type Event = Event;829 type XcmExecutor = XcmExecutor<XcmConfig>;830 type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;831}832833impl pallet_aura::Config for Runtime {834 type AuthorityId = AuraId;835 type DisabledValidators = ();836 type MaxAuthorities = MaxAuthorities;837}838839parameter_types! {840 pub TreasuryAccountId: AccountId = TreasuryModuleId::get().into_account();841 pub const CollectionCreationPrice: Balance = 2 * UNIQUE;842}843844impl pallet_common::Config for Runtime {845 type Event = Event;846 type EvmBackwardsAddressMapping = up_evm_mapping::MapBackwardsAddressTruncated;847 type EvmAddressMapping = HashedAddressMapping<Self::Hashing>;848 type CrossAccountId = pallet_common::account::BasicCrossAccountId<Self>;849850 type Currency = Balances;851 type CollectionCreationPrice = CollectionCreationPrice;852 type TreasuryAccountId = TreasuryAccountId;853}854855impl pallet_evm::account::Config for Runtime {856 type CrossAccountId = pallet_evm::account::BasicCrossAccountId<Self>;857 type EvmAddressMapping = HashedAddressMapping<Self::Hashing>;858 type EvmBackwardsAddressMapping = fp_evm_mapping::MapBackwardsAddressTruncated;859}860861impl pallet_fungible::Config for Runtime {862 type WeightInfo = pallet_fungible::weights::SubstrateWeight<Self>;863}864impl pallet_refungible::Config for Runtime {865 type WeightInfo = pallet_refungible::weights::SubstrateWeight<Self>;866}867impl pallet_nonfungible::Config for Runtime {868 type WeightInfo = pallet_nonfungible::weights::SubstrateWeight<Self>;869}870871impl pallet_unique::Config for Runtime {872 type Event = Event;873 type WeightInfo = pallet_unique::weights::SubstrateWeight<Self>;874}875876parameter_types! {877 pub const InflationBlockInterval: BlockNumber = 100; // every time per how many blocks inflation is applied878}879880/// Used for the pallet inflation881impl pallet_inflation::Config for Runtime {882 type Currency = Balances;883 type TreasuryAccountId = TreasuryAccountId;884 type InflationBlockInterval = InflationBlockInterval;885 type BlockNumberProvider = RelayChainBlockNumberProvider<Runtime>;886}887888// parameter_types! {889// pub MaximumSchedulerWeight: Weight = Perbill::from_percent(50) *890// RuntimeBlockWeights::get().max_block;891// pub const MaxScheduledPerBlock: u32 = 50;892// }893894type EvmSponsorshipHandler = (895 pallet_unique::UniqueEthSponsorshipHandler<Runtime>,896 pallet_evm_contract_helpers::HelpersContractSponsoring<Runtime>,897);898type SponsorshipHandler = (899 pallet_unique::UniqueSponsorshipHandler<Runtime>,900 //pallet_contract_helpers::ContractSponsorshipHandler<Runtime>,901 pallet_evm_transaction_payment::BridgeSponsorshipHandler<Runtime>,902);903904// impl pallet_unq_scheduler::Config for Runtime {905// type Event = Event;906// type Origin = Origin;907// type PalletsOrigin = OriginCaller;908// type Call = Call;909// type MaximumWeight = MaximumSchedulerWeight;910// type ScheduleOrigin = EnsureSigned<AccountId>;911// type MaxScheduledPerBlock = MaxScheduledPerBlock;912// type SponsorshipHandler = SponsorshipHandler;913// type WeightInfo = ();914// }915916impl pallet_evm_transaction_payment::Config for Runtime {917 type EvmSponsorshipHandler = EvmSponsorshipHandler;918 type Currency = Balances;919 type EvmAddressMapping = HashedAddressMapping<Self::Hashing>;920 type EvmBackwardsAddressMapping = up_evm_mapping::MapBackwardsAddressTruncated;921}922923impl pallet_charge_transaction::Config for Runtime {924 type SponsorshipHandler = SponsorshipHandler;925}926927// impl pallet_contract_helpers::Config for Runtime {928// type DefaultSponsoringRateLimit = DefaultSponsoringRateLimit;929// }930931parameter_types! {932 // 0x842899ECF380553E8a4de75bF534cdf6fBF64049933 pub const HelpersContractAddress: H160 = H160([934 0x84, 0x28, 0x99, 0xec, 0xf3, 0x80, 0x55, 0x3e, 0x8a, 0x4d, 0xe7, 0x5b, 0xf5, 0x34, 0xcd, 0xf6, 0xfb, 0xf6, 0x40, 0x49,935 ]);936}937938impl pallet_evm_contract_helpers::Config for Runtime {939 type ContractAddress = HelpersContractAddress;940 type DefaultSponsoringRateLimit = DefaultSponsoringRateLimit;941}942943construct_runtime!(944 pub enum Runtime where945 Block = Block,946 NodeBlock = opaque::Block,947 UncheckedExtrinsic = UncheckedExtrinsic948 {949 ParachainSystem: cumulus_pallet_parachain_system::{Pallet, Call, Config, Storage, Inherent, Event<T>, ValidateUnsigned} = 20,950 ParachainInfo: parachain_info::{Pallet, Storage, Config} = 21,951952 Aura: pallet_aura::{Pallet, Config<T>} = 22,953 AuraExt: cumulus_pallet_aura_ext::{Pallet, Config} = 23,954955 Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>} = 30,956 RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Pallet, Storage} = 31,957 Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent} = 32,958 TransactionPayment: pallet_transaction_payment::{Pallet, Storage} = 33,959 Treasury: pallet_treasury::{Pallet, Call, Storage, Config, Event<T>} = 34,960 Sudo: pallet_sudo::{Pallet, Call, Storage, Config<T>, Event<T>} = 35,961 System: frame_system::{Pallet, Call, Storage, Config, Event<T>} = 36,962 Vesting: orml_vesting::{Pallet, Storage, Call, Event<T>, Config<T>} = 37,963 // Vesting: pallet_vesting::{Pallet, Call, Config<T>, Storage, Event<T>} = 37,964 // Contracts: pallet_contracts::{Pallet, Call, Storage, Event<T>} = 38,965966 // XCM helpers.967 XcmpQueue: cumulus_pallet_xcmp_queue::{Pallet, Call, Storage, Event<T>} = 50,968 PolkadotXcm: pallet_xcm::{Pallet, Call, Event<T>, Origin} = 51,969 CumulusXcm: cumulus_pallet_xcm::{Pallet, Call, Event<T>, Origin} = 52,970 DmpQueue: cumulus_pallet_dmp_queue::{Pallet, Call, Storage, Event<T>} = 53,971972 // Unique Pallets973 Inflation: pallet_inflation::{Pallet, Call, Storage} = 60,974 Unique: pallet_unique::{Pallet, Call, Storage, Event<T>} = 61,975 // Scheduler: pallet_unq_scheduler::{Pallet, Call, Storage, Event<T>} = 62,976 // free = 63977 Charging: pallet_charge_transaction::{Pallet, Call, Storage } = 64,978 // ContractHelpers: pallet_contract_helpers::{Pallet, Call, Storage} = 65,979 Common: pallet_common::{Pallet, Storage, Event<T>} = 66,980 Fungible: pallet_fungible::{Pallet, Storage} = 67,981 Refungible: pallet_refungible::{Pallet, Storage} = 68,982 Nonfungible: pallet_nonfungible::{Pallet, Storage} = 69,983984 // Frontier985 EVM: pallet_evm::{Pallet, Config, Call, Storage, Event<T>} = 100,986 Ethereum: pallet_ethereum::{Pallet, Config, Call, Storage, Event, Origin} = 101,987988 EvmCoderSubstrate: pallet_evm_coder_substrate::{Pallet, Storage} = 150,989 EvmContractHelpers: pallet_evm_contract_helpers::{Pallet, Storage} = 151,990 EvmTransactionPayment: pallet_evm_transaction_payment::{Pallet} = 152,991 EvmMigration: pallet_evm_migration::{Pallet, Call, Storage} = 153,992 }993);994995pub struct TransactionConverter;996997impl fp_rpc::ConvertTransaction<UncheckedExtrinsic> for TransactionConverter {998 fn convert_transaction(&self, transaction: pallet_ethereum::Transaction) -> UncheckedExtrinsic {999 UncheckedExtrinsic::new_unsigned(1000 pallet_ethereum::Call::<Runtime>::transact { transaction }.into(),1001 )1002 }1003}10041005impl fp_rpc::ConvertTransaction<opaque::UncheckedExtrinsic> for TransactionConverter {1006 fn convert_transaction(1007 &self,1008 transaction: pallet_ethereum::Transaction,1009 ) -> opaque::UncheckedExtrinsic {1010 let extrinsic = UncheckedExtrinsic::new_unsigned(1011 pallet_ethereum::Call::<Runtime>::transact { transaction }.into(),1012 );1013 let encoded = extrinsic.encode();1014 opaque::UncheckedExtrinsic::decode(&mut &encoded[..])1015 .expect("Encoded extrinsic is always valid")1016 }1017}10181019/// The address format for describing accounts.1020pub type Address = sp_runtime::MultiAddress<AccountId, ()>;1021/// Block header type as expected by this runtime.1022pub type Header = generic::Header<BlockNumber, BlakeTwo256>;1023/// Block type as expected by this runtime.1024pub type Block = generic::Block<Header, UncheckedExtrinsic>;1025/// A Block signed with a Justification1026pub type SignedBlock = generic::SignedBlock<Block>;1027/// BlockId type as expected by this runtime.1028pub type BlockId = generic::BlockId<Block>;1029/// The SignedExtension to the basic transaction logic.1030pub type SignedExtra = (1031 frame_system::CheckSpecVersion<Runtime>,1032 // system::CheckTxVersion<Runtime>,1033 frame_system::CheckGenesis<Runtime>,1034 frame_system::CheckEra<Runtime>,1035 frame_system::CheckNonce<Runtime>,1036 frame_system::CheckWeight<Runtime>,1037 pallet_charge_transaction::ChargeTransactionPayment<Runtime>,1038 //pallet_contract_helpers::ContractHelpersExtension<Runtime>,1039);1040/// Unchecked extrinsic type as expected by this runtime.1041pub type UncheckedExtrinsic =1042 fp_self_contained::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;1043/// Extrinsic type that has already been checked.1044pub type CheckedExtrinsic = fp_self_contained::CheckedExtrinsic<AccountId, Call, SignedExtra, H160>;1045/// Executive: handles dispatch to the various modules.1046pub type Executive = frame_executive::Executive<1047 Runtime,1048 Block,1049 frame_system::ChainContext<Runtime>,1050 Runtime,1051 AllPalletsReversedWithSystemFirst,1052>;10531054impl_opaque_keys! {1055 pub struct SessionKeys {1056 pub aura: Aura,1057 }1058}10591060impl fp_self_contained::SelfContainedCall for Call {1061 type SignedInfo = H160;10621063 fn is_self_contained(&self) -> bool {1064 match self {1065 Call::Ethereum(call) => call.is_self_contained(),1066 _ => false,1067 }1068 }10691070 fn check_self_contained(&self) -> Option<Result<Self::SignedInfo, TransactionValidityError>> {1071 match self {1072 Call::Ethereum(call) => call.check_self_contained(),1073 _ => None,1074 }1075 }10761077 fn validate_self_contained(&self, info: &Self::SignedInfo) -> Option<TransactionValidity> {1078 match self {1079 Call::Ethereum(call) => call.validate_self_contained(info),1080 _ => None,1081 }1082 }10831084 fn pre_dispatch_self_contained(1085 &self,1086 info: &Self::SignedInfo,1087 ) -> Option<Result<(), TransactionValidityError>> {1088 match self {1089 Call::Ethereum(call) => call.pre_dispatch_self_contained(info),1090 _ => None,1091 }1092 }10931094 fn apply_self_contained(1095 self,1096 info: Self::SignedInfo,1097 ) -> Option<sp_runtime::DispatchResultWithInfo<PostDispatchInfoOf<Self>>> {1098 match self {1099 call @ Call::Ethereum(pallet_ethereum::Call::transact { .. }) => Some(call.dispatch(1100 Origin::from(pallet_ethereum::RawOrigin::EthereumTransaction(info)),1101 )),1102 _ => None,1103 }1104 }1105}11061107macro_rules! dispatch_unique_runtime {1108 ($collection:ident.$method:ident($($name:ident),*)) => {{1109 use pallet_unique::dispatch::Dispatched;11101111 let collection = Dispatched::dispatch(<pallet_common::CollectionHandle<Runtime>>::try_get($collection)?);1112 let dispatch = collection.as_dyn();11131114 Ok(dispatch.$method($($name),*))1115 }};1116}11171118impl_common_runtime_apis!();11191120struct CheckInherents;11211122impl cumulus_pallet_parachain_system::CheckInherents<Block> for CheckInherents {1123 fn check_inherents(1124 block: &Block,1125 relay_state_proof: &cumulus_pallet_parachain_system::RelayChainStateProof,1126 ) -> sp_inherents::CheckInherentsResult {1127 let relay_chain_slot = relay_state_proof1128 .read_slot()1129 .expect("Could not read the relay chain slot from the proof");11301131 let inherent_data =1132 cumulus_primitives_timestamp::InherentDataProvider::from_relay_chain_slot_and_duration(1133 relay_chain_slot,1134 sp_std::time::Duration::from_secs(6),1135 )1136 .create_inherent_data()1137 .expect("Could not create the timestamp inherent data");11381139 inherent_data.check_extrinsics(block)1140 }1141}11421143cumulus_pallet_parachain_system::register_validate_block!(1144 Runtime = Runtime,1145 BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor::<Runtime, Executive>,1146 CheckInherents = CheckInherents,1147);