difftreelog
Merge pull request #307 from UniqueNetwork/feature/divide-runtimes-into-3
in: master
divide runtimes into Opal, Quartz and Unique
26 files changed
Cargo.lockdiffbeforeafterboth--- a/Cargo.lock
+++ b/Cargo.lock
@@ -5194,6 +5194,82 @@
checksum = "87f3e037eac156d1775da914196f0f37741a274155e34a0b7e427c35d2a2ecb9"
[[package]]
+name = "opal-runtime"
+version = "0.1.0"
+dependencies = [
+ "cumulus-pallet-aura-ext",
+ "cumulus-pallet-dmp-queue",
+ "cumulus-pallet-parachain-system",
+ "cumulus-pallet-xcm",
+ "cumulus-pallet-xcmp-queue",
+ "cumulus-primitives-core",
+ "cumulus-primitives-timestamp",
+ "cumulus-primitives-utility",
+ "derivative",
+ "fp-rpc",
+ "fp-self-contained",
+ "frame-benchmarking",
+ "frame-executive",
+ "frame-support",
+ "frame-system",
+ "frame-system-benchmarking",
+ "frame-system-rpc-runtime-api",
+ "hex-literal",
+ "orml-vesting",
+ "pallet-aura",
+ "pallet-balances",
+ "pallet-base-fee",
+ "pallet-common",
+ "pallet-ethereum",
+ "pallet-evm",
+ "pallet-evm-coder-substrate",
+ "pallet-evm-contract-helpers",
+ "pallet-evm-migration",
+ "pallet-evm-transaction-payment",
+ "pallet-fungible",
+ "pallet-inflation",
+ "pallet-nonfungible",
+ "pallet-randomness-collective-flip",
+ "pallet-refungible",
+ "pallet-sudo",
+ "pallet-template-transaction-payment",
+ "pallet-timestamp",
+ "pallet-transaction-payment",
+ "pallet-transaction-payment-rpc-runtime-api",
+ "pallet-treasury",
+ "pallet-unique",
+ "pallet-unq-scheduler",
+ "pallet-xcm",
+ "parachain-info",
+ "parity-scale-codec",
+ "polkadot-parachain",
+ "scale-info",
+ "serde",
+ "smallvec",
+ "sp-api",
+ "sp-arithmetic",
+ "sp-block-builder",
+ "sp-consensus-aura",
+ "sp-core",
+ "sp-inherents",
+ "sp-io",
+ "sp-offchain",
+ "sp-runtime",
+ "sp-session",
+ "sp-std",
+ "sp-transaction-pool",
+ "sp-version",
+ "substrate-wasm-builder",
+ "unique-runtime-common",
+ "up-data-structs",
+ "up-evm-mapping",
+ "up-rpc",
+ "xcm",
+ "xcm-builder",
+ "xcm-executor",
+]
+
+[[package]]
name = "opaque-debug"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -8260,6 +8336,82 @@
]
[[package]]
+name = "quartz-runtime"
+version = "0.1.0"
+dependencies = [
+ "cumulus-pallet-aura-ext",
+ "cumulus-pallet-dmp-queue",
+ "cumulus-pallet-parachain-system",
+ "cumulus-pallet-xcm",
+ "cumulus-pallet-xcmp-queue",
+ "cumulus-primitives-core",
+ "cumulus-primitives-timestamp",
+ "cumulus-primitives-utility",
+ "derivative",
+ "fp-rpc",
+ "fp-self-contained",
+ "frame-benchmarking",
+ "frame-executive",
+ "frame-support",
+ "frame-system",
+ "frame-system-benchmarking",
+ "frame-system-rpc-runtime-api",
+ "hex-literal",
+ "orml-vesting",
+ "pallet-aura",
+ "pallet-balances",
+ "pallet-base-fee",
+ "pallet-common",
+ "pallet-ethereum",
+ "pallet-evm",
+ "pallet-evm-coder-substrate",
+ "pallet-evm-contract-helpers",
+ "pallet-evm-migration",
+ "pallet-evm-transaction-payment",
+ "pallet-fungible",
+ "pallet-inflation",
+ "pallet-nonfungible",
+ "pallet-randomness-collective-flip",
+ "pallet-refungible",
+ "pallet-sudo",
+ "pallet-template-transaction-payment",
+ "pallet-timestamp",
+ "pallet-transaction-payment",
+ "pallet-transaction-payment-rpc-runtime-api",
+ "pallet-treasury",
+ "pallet-unique",
+ "pallet-unq-scheduler",
+ "pallet-xcm",
+ "parachain-info",
+ "parity-scale-codec",
+ "polkadot-parachain",
+ "scale-info",
+ "serde",
+ "smallvec",
+ "sp-api",
+ "sp-arithmetic",
+ "sp-block-builder",
+ "sp-consensus-aura",
+ "sp-core",
+ "sp-inherents",
+ "sp-io",
+ "sp-offchain",
+ "sp-runtime",
+ "sp-session",
+ "sp-std",
+ "sp-transaction-pool",
+ "sp-version",
+ "substrate-wasm-builder",
+ "unique-runtime-common",
+ "up-data-structs",
+ "up-evm-mapping",
+ "up-rpc",
+ "xcm",
+ "xcm-builder",
+ "xcm-executor",
+]
+
+[[package]]
name = "quick-error"
version = "1.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -11787,8 +11939,10 @@
"jsonrpc-core",
"jsonrpc-pubsub",
"log",
+ "opal-runtime",
"pallet-ethereum",
"pallet-transaction-payment-rpc",
+ "pallet-transaction-payment-rpc-runtime-api",
"parity-scale-codec",
"parking_lot 0.11.2",
"polkadot-cli",
@@ -11796,6 +11950,7 @@
"polkadot-primitives",
"polkadot-service",
"polkadot-test-service",
+ "quartz-runtime",
"sc-basic-authorship",
"sc-chain-spec",
"sc-cli",
@@ -11834,7 +11989,9 @@
"substrate-prometheus-endpoint",
"unique-rpc",
"unique-runtime",
+ "unique-runtime-common",
"up-data-structs",
+ "up-rpc",
]
[[package]]
@@ -11849,6 +12006,7 @@
"futures 0.3.21",
"jsonrpc-core",
"jsonrpc-pubsub",
+ "pallet-common",
"pallet-ethereum",
"pallet-transaction-payment-rpc",
"pallet-transaction-payment-rpc-runtime-api",
@@ -11864,6 +12022,7 @@
"sc-rpc-api",
"sc-service",
"sc-transaction-pool",
+ "serde",
"sp-api",
"sp-block-builder",
"sp-blockchain",
@@ -11878,7 +12037,7 @@
"substrate-frame-rpc-system",
"tokio 0.2.25",
"uc-rpc",
- "unique-runtime",
+ "unique-runtime-common",
"up-rpc",
]
@@ -11949,6 +12108,7 @@
"sp-transaction-pool",
"sp-version",
"substrate-wasm-builder",
+ "unique-runtime-common",
"up-data-structs",
"up-evm-mapping",
"up-rpc",
@@ -11958,6 +12118,21 @@
]
[[package]]
+name = "unique-runtime-common"
+version = "0.1.0"
+dependencies = [
+ "fp-rpc",
+ "frame-support",
+ "frame-system",
+ "pallet-common",
+ "parity-scale-codec",
+ "scale-info",
+ "sp-consensus-aura",
+ "sp-core",
+ "sp-runtime",
+]
+
+[[package]]
name = "universal-hash"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
Cargo.tomldiffbeforeafterboth--- a/Cargo.toml
+++ b/Cargo.toml
@@ -5,7 +5,7 @@
'pallets/*',
'client/*',
'primitives/*',
- 'runtime',
+ 'runtime/*',
'crates/*',
]
[profile.release]
README.mddiffbeforeafterboth--- a/README.md
+++ b/README.md
@@ -27,7 +27,7 @@
- [Unique Wallet and UI](https://uniqueapps.usetech.com/#/nft)
- [NFT Asset for Unity Framework](https://github.com/usetech-llc/nft_unity)
-Please see our [walk-thorugh instructions](doc/hackusama_walk_through.md) to try everything out!
+Please see our [walk-through instructions](doc/hackusama_walk_through.md) to try everything out!
## Application Development
@@ -158,7 +158,7 @@
```
assetRegistry -> registerForeignAsset(location, metadata)
location:
- V0(X2(Parent, Parachain(PARA_ID)))
+ V0(X2(Parent, Parachain(PARA_ID)))
metadata:
name OPL
symbol OPL
@@ -170,19 +170,19 @@
```
polkadotXcm -> reserveTransferAssets
dest:
- V0(X2(Parent, Parachain(<KARURA_PARA_ID>)))
+ V0(X2(Parent, Parachain(<KARURA_PARA_ID>)))
beneficiary:
X1(AccountId(Any, <ACCOUNT>))
assets:
V1(Concrete(0,Here), Fungible(<AMOUNT>))
-feeAssetItem:
- 0
+feeAssetItem:
+ 0
weightLimit:
<LIMIT>
-```
+```
-The result will be displayed in ChainState
-tokens -> accounts
+The result will be displayed in ChainState
+tokens -> accounts
### To send tokens from Karura to Opal:
```
@@ -197,7 +197,7 @@
dest:
V1
(
- Parents:1,
+ Parents:1,
X2(Parachain(<KARURA_PARA_ID>), AccountId(Any, <ACCOUNT>)
)
destWeight:
node/cli/Cargo.tomldiffbeforeafterboth--- a/node/cli/Cargo.toml
+++ b/node/cli/Cargo.toml
@@ -168,6 +168,9 @@
[dependencies.serde_json]
version = '1.0.68'
+[dependencies.sc-consensus-manual-seal]
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'polkadot-v0.9.17'
################################################################################
# Cumulus dependencies
@@ -238,13 +241,32 @@
################################################################################
# Local dependencies
+[dependencies.unique-runtime-common]
+default-features = false
+path = "../../runtime/common"
+
[dependencies.unique-runtime]
-path = '../../runtime'
+path = '../../runtime/unique'
+optional = true
+
+[dependencies.quartz-runtime]
+path = '../../runtime/quartz'
+optional = true
+
+[dependencies.opal-runtime]
+path = '../../runtime/opal'
[dependencies.up-data-structs]
path = "../../primitives/data-structs"
default-features = false
+[dependencies.up-rpc]
+path = "../../primitives/rpc"
+
+[dependencies.pallet-transaction-payment-rpc-runtime-api]
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'polkadot-v0.9.17'
+
################################################################################
# Package
@@ -283,10 +305,10 @@
fp-rpc = { git = "https://github.com/uniquenetwork/frontier.git", branch = "unique-polkadot-v0.9.17" }
pallet-ethereum = { git = "https://github.com/uniquenetwork/frontier.git", branch = "unique-polkadot-v0.9.17" }
-unique-rpc = { path = "../rpc" }
+unique-rpc = { default-features = false, path = "../rpc" }
[features]
-default = []
+default = ["unique-runtime", "quartz-runtime"]
runtime-benchmarks = [
'unique-runtime/runtime-benchmarks',
'polkadot-service/runtime-benchmarks',
node/cli/src/chain_spec.rsdiffbeforeafterboth--- a/node/cli/src/chain_spec.rs
+++ b/node/cli/src/chain_spec.rs
@@ -15,7 +15,6 @@
// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
use cumulus_primitives_core::ParaId;
-use unique_runtime::*;
use sc_chain_spec::{ChainSpecExtension, ChainSpecGroup};
use sc_service::ChainType;
use sp_core::{sr25519, Pair, Public};
@@ -25,9 +24,69 @@
use serde::{Deserialize, Serialize};
use serde_json::map::Map;
-/// Specialized `ChainSpec`. This is a specialization of the general Substrate ChainSpec type.
-pub type ChainSpec = sc_service::GenericChainSpec<unique_runtime::GenesisConfig, Extensions>;
+use unique_runtime_common::types::*;
+
+/// The `ChainSpec` parameterized for the unique runtime.
+#[cfg(feature = "unique-runtime")]
+pub type UniqueChainSpec = sc_service::GenericChainSpec<unique_runtime::GenesisConfig, Extensions>;
+
+/// The `ChainSpec` parameterized for the quartz runtime.
+#[cfg(feature = "quartz-runtime")]
+pub type QuartzChainSpec = sc_service::GenericChainSpec<quartz_runtime::GenesisConfig, Extensions>;
+
+/// The `ChainSpec` parameterized for the opal runtime.
+pub type OpalChainSpec = sc_service::GenericChainSpec<opal_runtime::GenesisConfig, Extensions>;
+pub enum RuntimeId {
+ Unique,
+ Quartz,
+ Opal,
+ Unknown(String),
+}
+
+pub trait RuntimeIdentification {
+ fn runtime_id(&self) -> RuntimeId;
+}
+
+impl RuntimeIdentification for Box<dyn sc_service::ChainSpec> {
+ fn runtime_id(&self) -> RuntimeId {
+ #[cfg(feature = "unique-runtime")]
+ if self.id().starts_with("unique") {
+ return RuntimeId::Unique;
+ }
+
+ #[cfg(feature = "quartz-runtime")]
+ if self.id().starts_with("quartz") {
+ return RuntimeId::Quartz;
+ }
+
+ if self.id().starts_with("opal") || self.id() == "dev" || self.id() == "local_testnet" {
+ return RuntimeId::Opal;
+ }
+
+ RuntimeId::Unknown(self.id().into())
+ }
+}
+
+pub enum ServiceId {
+ Prod,
+ Dev,
+}
+
+pub trait ServiceIdentification {
+ fn service_id(&self) -> ServiceId;
+}
+
+impl ServiceIdentification for Box<dyn sc_service::ChainSpec> {
+ fn service_id(&self) -> ServiceId {
+ if self.id().ends_with("dev") {
+ ServiceId::Dev
+ } else {
+ ServiceId::Prod
+ }
+ }
+}
+
/// Helper function to generate a crypto pair from seed
pub fn get_from_seed<TPublic: Public>(seed: &str) -> <TPublic::Pair as Pair>::Public {
TPublic::Pair::from_string(&format!("//{}", seed), None)
@@ -62,13 +121,13 @@
AccountPublic::from(get_from_seed::<TPublic>(seed)).into_account()
}
-pub fn development_config() -> ChainSpec {
+pub fn development_config() -> OpalChainSpec {
let mut properties = Map::new();
properties.insert("tokenSymbol".into(), "OPL".into());
properties.insert("tokenDecimals".into(), 15.into());
properties.insert("ss58Format".into(), 42.into());
- ChainSpec::from_genesis(
+ OpalChainSpec::from_genesis(
// Name
"Development",
// ID
@@ -107,8 +166,8 @@
)
}
-pub fn local_testnet_rococo_config() -> ChainSpec {
- ChainSpec::from_genesis(
+pub fn local_testnet_rococo_config() -> OpalChainSpec {
+ OpalChainSpec::from_genesis(
// Name
"Local Testnet",
// ID
@@ -157,68 +216,17 @@
)
}
-pub fn local_testnet_westend_config() -> ChainSpec {
- ChainSpec::from_genesis(
- // Name
- "Local Testnet",
- // ID
- "local_testnet",
- ChainType::Local,
- move || {
- testnet_genesis(
- // Sudo account
- get_account_id_from_seed::<sr25519::Public>("Alice"),
- vec![
- get_from_seed::<AuraId>("Alice"),
- get_from_seed::<AuraId>("Bob"),
- get_from_seed::<AuraId>("Charlie"),
- get_from_seed::<AuraId>("Dave"),
- get_from_seed::<AuraId>("Eve"),
- ],
- // Pre-funded accounts
- vec![
- get_account_id_from_seed::<sr25519::Public>("Alice"),
- get_account_id_from_seed::<sr25519::Public>("Bob"),
- get_account_id_from_seed::<sr25519::Public>("Charlie"),
- get_account_id_from_seed::<sr25519::Public>("Dave"),
- get_account_id_from_seed::<sr25519::Public>("Eve"),
- get_account_id_from_seed::<sr25519::Public>("Ferdie"),
- get_account_id_from_seed::<sr25519::Public>("Alice//stash"),
- get_account_id_from_seed::<sr25519::Public>("Bob//stash"),
- get_account_id_from_seed::<sr25519::Public>("Charlie//stash"),
- get_account_id_from_seed::<sr25519::Public>("Dave//stash"),
- get_account_id_from_seed::<sr25519::Public>("Eve//stash"),
- get_account_id_from_seed::<sr25519::Public>("Ferdie//stash"),
- ],
- 1000.into(),
- )
- },
- // Bootnodes
- vec![],
- // Telemetry
- None,
- // Protocol ID
- None,
- None,
- // Properties
- None,
- // Extensions
- Extensions {
- relay_chain: "westend-local".into(),
- para_id: 1000,
- },
- )
-}
-
fn testnet_genesis(
root_key: AccountId,
initial_authorities: Vec<AuraId>,
endowed_accounts: Vec<AccountId>,
id: ParaId,
-) -> GenesisConfig {
+) -> opal_runtime::GenesisConfig {
+ use opal_runtime::*;
+
GenesisConfig {
- system: unique_runtime::SystemConfig {
- code: unique_runtime::WASM_BINARY
+ system: SystemConfig {
+ code: WASM_BINARY
.expect("WASM binary was not build, please build it!")
.to_vec(),
},
@@ -235,9 +243,9 @@
key: Some(root_key),
},
vesting: VestingConfig { vesting: vec![] },
- parachain_info: unique_runtime::ParachainInfoConfig { parachain_id: id },
+ parachain_info: ParachainInfoConfig { parachain_id: id },
parachain_system: Default::default(),
- aura: unique_runtime::AuraConfig {
+ aura: AuraConfig {
authorities: initial_authorities,
},
aura_ext: Default::default(),
node/cli/src/command.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// Original license18// This file is part of Substrate.1920// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.21// SPDX-License-Identifier: Apache-2.02223// Licensed under the Apache License, Version 2.0 (the "License");24// you may not use this file except in compliance with the License.25// You may obtain a copy of the License at26//27// http://www.apache.org/licenses/LICENSE-2.028//29// Unless required by applicable law or agreed to in writing, software30// distributed under the License is distributed on an "AS IS" BASIS,31// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.32// See the License for the specific language governing permissions and33// limitations under the License.3435use crate::{36 chain_spec,37 cli::{Cli, RelayChainCli, Subcommand},38 service::{new_partial, ParachainRuntimeExecutor},39};40use codec::Encode;41use cumulus_primitives_core::ParaId;42use cumulus_client_service::genesis::generate_genesis_block;43use log::info;44use unique_runtime::Block;45use polkadot_parachain::primitives::AccountIdConversion;46use sc_cli::{47 ChainSpec, CliConfiguration, DefaultConfigurationValues, ImportParams, KeystoreParams,48 NetworkParams, Result, RuntimeVersion, SharedParams, SubstrateCli,49};50use sc_service::{51 config::{BasePath, PrometheusConfig},52};53use sp_core::hexdisplay::HexDisplay;54use sp_runtime::traits::Block as BlockT;55use std::{io::Write, net::SocketAddr};5657fn load_spec(id: &str) -> std::result::Result<Box<dyn sc_service::ChainSpec>, String> {58 Ok(match id {59 "westend-local" => Box::new(chain_spec::local_testnet_westend_config()),60 "rococo-local" => Box::new(chain_spec::local_testnet_rococo_config()),61 "dev" => Box::new(chain_spec::development_config()),62 "" | "local" => Box::new(chain_spec::local_testnet_rococo_config()),63 path => Box::new(chain_spec::ChainSpec::from_json_file(64 std::path::PathBuf::from(path),65 )?),66 })67}6869impl SubstrateCli for Cli {70 // TODO use args71 fn impl_name() -> String {72 "Opal Node".into()73 }7475 fn impl_version() -> String {76 env!("SUBSTRATE_CLI_IMPL_VERSION").into()77 }78 // TODO use args79 fn description() -> String {80 format!(81 "Opal Node\n\nThe command-line arguments provided first will be \82 passed to the parachain node, while the arguments provided after -- will be passed \83 to the relaychain node.\n\n\84 {} [parachain-args] -- [relaychain-args]",85 Self::executable_name()86 )87 }8889 fn author() -> String {90 env!("CARGO_PKG_AUTHORS").into()91 }9293 //TODO use args94 fn support_url() -> String {95 "support@unique.network".into()96 }9798 fn copyright_start_year() -> i32 {99 2019100 }101102 fn load_spec(&self, id: &str) -> std::result::Result<Box<dyn sc_service::ChainSpec>, String> {103 load_spec(id)104 }105106 fn native_runtime_version(_: &Box<dyn ChainSpec>) -> &'static RuntimeVersion {107 &unique_runtime::VERSION108 }109}110111impl SubstrateCli for RelayChainCli {112 // TODO use args113 fn impl_name() -> String {114 "Opal Node".into()115 }116117 fn impl_version() -> String {118 env!("SUBSTRATE_CLI_IMPL_VERSION").into()119 }120 // TODO use args121 fn description() -> String {122 "Opal Node\n\nThe command-line arguments provided first will be \123 passed to the parachain node, while the arguments provided after -- will be passed \124 to the relaychain node.\n\n\125 parachain-collator [parachain-args] -- [relaychain-args]"126 .into()127 }128129 fn author() -> String {130 env!("CARGO_PKG_AUTHORS").into()131 }132 // TODO use args133 fn support_url() -> String {134 "support@unique.network".into()135 }136137 fn copyright_start_year() -> i32 {138 2019139 }140141 fn load_spec(&self, id: &str) -> std::result::Result<Box<dyn sc_service::ChainSpec>, String> {142 polkadot_cli::Cli::from_iter([RelayChainCli::executable_name()].iter()).load_spec(id)143 }144145 fn native_runtime_version(chain_spec: &Box<dyn ChainSpec>) -> &'static RuntimeVersion {146 polkadot_cli::Cli::native_runtime_version(chain_spec)147 }148}149150#[allow(clippy::borrowed_box)]151fn extract_genesis_wasm(chain_spec: &Box<dyn sc_service::ChainSpec>) -> Result<Vec<u8>> {152 let mut storage = chain_spec.build_storage()?;153154 storage155 .top156 .remove(sp_core::storage::well_known_keys::CODE)157 .ok_or_else(|| "Could not find wasm file in genesis state!".into())158}159160macro_rules! construct_async_run {161 (|$components:ident, $cli:ident, $cmd:ident, $config:ident| $( $code:tt )* ) => {{162 let runner = $cli.create_runner($cmd)?;163 runner.async_run(|$config| {164 let $components = new_partial::<165 _166 >(167 &$config,168 crate::service::parachain_build_import_queue,169 )?;170 let task_manager = $components.task_manager;171 { $( $code )* }.map(|v| (v, task_manager))172 })173 }}174}175176/// Parse command line arguments into service configuration.177pub fn run() -> Result<()> {178 let cli = Cli::from_args();179180 match &cli.subcommand {181 Some(Subcommand::BuildSpec(cmd)) => {182 let runner = cli.create_runner(cmd)?;183 runner.sync_run(|config| cmd.run(config.chain_spec, config.network))184 }185 Some(Subcommand::CheckBlock(cmd)) => {186 construct_async_run!(|components, cli, cmd, config| {187 Ok(cmd.run(components.client, components.import_queue))188 })189 }190 Some(Subcommand::ExportBlocks(cmd)) => {191 construct_async_run!(|components, cli, cmd, config| {192 Ok(cmd.run(components.client, config.database))193 })194 }195 Some(Subcommand::ExportState(cmd)) => {196 construct_async_run!(|components, cli, cmd, config| {197 Ok(cmd.run(components.client, config.chain_spec))198 })199 }200 Some(Subcommand::ImportBlocks(cmd)) => {201 construct_async_run!(|components, cli, cmd, config| {202 Ok(cmd.run(components.client, components.import_queue))203 })204 }205 Some(Subcommand::PurgeChain(cmd)) => {206 let runner = cli.create_runner(cmd)?;207208 runner.sync_run(|config| {209 let polkadot_cli = RelayChainCli::new(210 &config,211 [RelayChainCli::executable_name()]212 .iter()213 .chain(cli.relaychain_args.iter()),214 );215216 let polkadot_config = SubstrateCli::create_configuration(217 &polkadot_cli,218 &polkadot_cli,219 config.tokio_handle.clone(),220 )221 .map_err(|err| format!("Relay chain argument error: {}", err))?;222223 cmd.run(config, polkadot_config)224 })225 }226 Some(Subcommand::Revert(cmd)) => construct_async_run!(|components, cli, cmd, config| {227 Ok(cmd.run(components.client, components.backend))228 }),229 Some(Subcommand::ExportGenesisState(params)) => {230 let mut builder = sc_cli::LoggerBuilder::new("");231 builder.with_profiling(sc_tracing::TracingReceiver::Log, "");232 let _ = builder.init();233234 let spec = load_spec(¶ms.chain.clone().unwrap_or_default())?;235 let state_version = Cli::native_runtime_version(&spec).state_version();236 let block: Block = generate_genesis_block(&spec, state_version)?;237 let raw_header = block.header().encode();238 let output_buf = if params.raw {239 raw_header240 } else {241 format!("0x{:?}", HexDisplay::from(&block.header().encode())).into_bytes()242 };243244 if let Some(output) = ¶ms.output {245 std::fs::write(output, output_buf)?;246 } else {247 std::io::stdout().write_all(&output_buf)?;248 }249250 Ok(())251 }252 Some(Subcommand::ExportGenesisWasm(params)) => {253 let mut builder = sc_cli::LoggerBuilder::new("");254 builder.with_profiling(sc_tracing::TracingReceiver::Log, "");255 let _ = builder.init();256257 let raw_wasm_blob =258 extract_genesis_wasm(&cli.load_spec(¶ms.chain.clone().unwrap_or_default())?)?;259 let output_buf = if params.raw {260 raw_wasm_blob261 } else {262 format!("0x{:?}", HexDisplay::from(&raw_wasm_blob)).into_bytes()263 };264265 if let Some(output) = ¶ms.output {266 std::fs::write(output, output_buf)?;267 } else {268 std::io::stdout().write_all(&output_buf)?;269 }270271 Ok(())272 }273 Some(Subcommand::Benchmark(cmd)) => {274 if cfg!(feature = "runtime-benchmarks") {275 let runner = cli.create_runner(cmd)?;276277 runner.sync_run(|config| cmd.run::<Block, ParachainRuntimeExecutor>(config))278 } else {279 Err("Benchmarking wasn't enabled when building the node. \280 You can enable it with `--features runtime-benchmarks`."281 .into())282 }283 }284 None => {285 let runner = cli.create_runner(&cli.run.normalize())?;286287 runner.run_node_until_exit(|config| async move {288 let para_id = chain_spec::Extensions::try_get(&*config.chain_spec)289 .map(|e| e.para_id)290 .ok_or("Could not find parachain ID in chain-spec.")?;291292 let polkadot_cli = RelayChainCli::new(293 &config,294 [RelayChainCli::executable_name()]295 .iter()296 .chain(cli.relaychain_args.iter()),297 );298299 let id = ParaId::from(para_id);300301 let parachain_account =302 AccountIdConversion::<polkadot_primitives::v0::AccountId>::into_account(&id);303304 let state_version =305 RelayChainCli::native_runtime_version(&config.chain_spec).state_version();306 let block: Block = generate_genesis_block(&config.chain_spec, state_version)307 .map_err(|e| format!("{:?}", e))?;308 let genesis_state = format!("0x{:?}", HexDisplay::from(&block.header().encode()));309 let genesis_hash = format!("0x{:?}", HexDisplay::from(&block.header().hash().0));310311 let polkadot_config = SubstrateCli::create_configuration(312 &polkadot_cli,313 &polkadot_cli,314 config.tokio_handle.clone(),315 )316 .map_err(|err| format!("Relay chain argument error: {}", err))?;317318 info!("Parachain id: {:?}", id);319 info!("Parachain Account: {}", parachain_account);320 info!("Parachain genesis state: {}", genesis_state);321 info!("Parachain genesis hash: {}", genesis_hash);322 info!(323 "Is collating: {}",324 if config.role.is_authority() {325 "yes"326 } else {327 "no"328 }329 );330331 crate::service::start_node(config, polkadot_config, id)332 .await333 .map(|r| r.0)334 .map_err(Into::into)335 })336 }337 }338}339340impl DefaultConfigurationValues for RelayChainCli {341 fn p2p_listen_port() -> u16 {342 30334343 }344345 fn rpc_ws_listen_port() -> u16 {346 9945347 }348349 fn rpc_http_listen_port() -> u16 {350 9934351 }352353 fn prometheus_listen_port() -> u16 {354 9616355 }356}357358impl CliConfiguration<Self> for RelayChainCli {359 fn shared_params(&self) -> &SharedParams {360 self.base.base.shared_params()361 }362363 fn import_params(&self) -> Option<&ImportParams> {364 self.base.base.import_params()365 }366367 fn network_params(&self) -> Option<&NetworkParams> {368 self.base.base.network_params()369 }370371 fn keystore_params(&self) -> Option<&KeystoreParams> {372 self.base.base.keystore_params()373 }374375 fn base_path(&self) -> Result<Option<BasePath>> {376 Ok(self377 .shared_params()378 .base_path()379 .or_else(|| self.base_path.clone().map(Into::into)))380 }381382 fn rpc_http(&self, default_listen_port: u16) -> Result<Option<SocketAddr>> {383 self.base.base.rpc_http(default_listen_port)384 }385386 fn rpc_ipc(&self) -> Result<Option<String>> {387 self.base.base.rpc_ipc()388 }389390 fn rpc_ws(&self, default_listen_port: u16) -> Result<Option<SocketAddr>> {391 self.base.base.rpc_ws(default_listen_port)392 }393394 fn prometheus_config(395 &self,396 default_listen_port: u16,397 chain_spec: &Box<dyn ChainSpec>,398 ) -> Result<Option<PrometheusConfig>> {399 self.base400 .base401 .prometheus_config(default_listen_port, chain_spec)402 }403404 fn init<F>(405 &self,406 _support_url: &String,407 _impl_version: &String,408 _logger_hook: F,409 _config: &sc_service::Configuration,410 ) -> Result<()> {411 unreachable!("PolkadotCli is never initialized; qed");412 }413414 fn chain_id(&self, is_dev: bool) -> Result<String> {415 let chain_id = self.base.base.chain_id(is_dev)?;416417 Ok(if chain_id.is_empty() {418 self.chain_id.clone().unwrap_or_default()419 } else {420 chain_id421 })422 }423424 fn role(&self, is_dev: bool) -> Result<sc_service::Role> {425 self.base.base.role(is_dev)426 }427428 fn transaction_pool(&self) -> Result<sc_service::config::TransactionPoolOptions> {429 self.base.base.transaction_pool()430 }431432 fn state_cache_child_ratio(&self) -> Result<Option<usize>> {433 self.base.base.state_cache_child_ratio()434 }435436 fn rpc_methods(&self) -> Result<sc_service::config::RpcMethods> {437 self.base.base.rpc_methods()438 }439440 fn rpc_ws_max_connections(&self) -> Result<Option<usize>> {441 self.base.base.rpc_ws_max_connections()442 }443444 fn rpc_cors(&self, is_dev: bool) -> Result<Option<Vec<String>>> {445 self.base.base.rpc_cors(is_dev)446 }447448 fn default_heap_pages(&self) -> Result<Option<u64>> {449 self.base.base.default_heap_pages()450 }451452 fn force_authoring(&self) -> Result<bool> {453 self.base.base.force_authoring()454 }455456 fn disable_grandpa(&self) -> Result<bool> {457 self.base.base.disable_grandpa()458 }459460 fn max_runtime_instances(&self) -> Result<Option<usize>> {461 self.base.base.max_runtime_instances()462 }463464 fn announce_block(&self) -> Result<bool> {465 self.base.base.announce_block()466 }467468 fn telemetry_endpoints(469 &self,470 chain_spec: &Box<dyn ChainSpec>,471 ) -> Result<Option<sc_telemetry::TelemetryEndpoints>> {472 self.base.base.telemetry_endpoints(chain_spec)473 }474}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// Original license18// This file is part of Substrate.1920// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.21// SPDX-License-Identifier: Apache-2.02223// Licensed under the Apache License, Version 2.0 (the "License");24// you may not use this file except in compliance with the License.25// You may obtain a copy of the License at26//27// http://www.apache.org/licenses/LICENSE-2.028//29// Unless required by applicable law or agreed to in writing, software30// distributed under the License is distributed on an "AS IS" BASIS,31// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.32// See the License for the specific language governing permissions and33// limitations under the License.3435use crate::{36 chain_spec::{self, RuntimeId, RuntimeIdentification, ServiceId, ServiceIdentification},37 cli::{Cli, RelayChainCli, Subcommand},38 service::{new_partial, start_node, start_dev_node},39};4041#[cfg(feature = "unique-runtime")]42use crate::service::UniqueRuntimeExecutor;4344#[cfg(feature = "quartz-runtime")]45use crate::service::QuartzRuntimeExecutor;4647use crate::service::OpalRuntimeExecutor;4849use codec::Encode;50use cumulus_primitives_core::ParaId;51use cumulus_client_service::genesis::generate_genesis_block;52use log::info;53use polkadot_parachain::primitives::AccountIdConversion;54use sc_cli::{55 ChainSpec, CliConfiguration, DefaultConfigurationValues, ImportParams, KeystoreParams,56 NetworkParams, Result, RuntimeVersion, SharedParams, SubstrateCli,57};58use sc_service::{59 config::{BasePath, PrometheusConfig},60};61use sp_core::hexdisplay::HexDisplay;62use sp_runtime::traits::Block as BlockT;63use std::{io::Write, net::SocketAddr};6465use unique_runtime_common::types::Block;6667macro_rules! no_runtime_err {68 ($chain_name:expr) => {69 format!(70 "No runtime valid runtime was found for chain {}",71 $chain_name72 )73 };74}7576fn load_spec(id: &str) -> std::result::Result<Box<dyn sc_service::ChainSpec>, String> {77 Ok(match id {78 "dev" => Box::new(chain_spec::development_config()),79 "" | "local" => Box::new(chain_spec::local_testnet_rococo_config()),80 path => {81 let path = std::path::PathBuf::from(path);82 let chain_spec = Box::new(chain_spec::OpalChainSpec::from_json_file(path.clone())?)83 as Box<dyn sc_service::ChainSpec>;8485 match chain_spec.runtime_id() {86 #[cfg(feature = "unique-runtime")]87 RuntimeId::Unique => Box::new(chain_spec::UniqueChainSpec::from_json_file(path)?),8889 #[cfg(feature = "quartz-runtime")]90 RuntimeId::Quartz => Box::new(chain_spec::QuartzChainSpec::from_json_file(path)?),9192 RuntimeId::Opal => chain_spec,93 RuntimeId::Unknown(chain) => return Err(no_runtime_err!(chain)),94 }95 }96 })97}9899impl SubstrateCli for Cli {100 // TODO use args101 fn impl_name() -> String {102 "Unique Node".into()103 }104105 fn impl_version() -> String {106 env!("SUBSTRATE_CLI_IMPL_VERSION").into()107 }108 // TODO use args109 fn description() -> String {110 format!(111 "Unique Node\n\nThe command-line arguments provided first will be \112 passed to the parachain node, while the arguments provided after -- will be passed \113 to the relaychain node.\n\n\114 {} [parachain-args] -- [relaychain-args]",115 Self::executable_name()116 )117 }118119 fn author() -> String {120 env!("CARGO_PKG_AUTHORS").into()121 }122123 //TODO use args124 fn support_url() -> String {125 "support@unique.network".into()126 }127128 fn copyright_start_year() -> i32 {129 2019130 }131132 fn load_spec(&self, id: &str) -> std::result::Result<Box<dyn sc_service::ChainSpec>, String> {133 load_spec(id)134 }135136 fn native_runtime_version(chain_spec: &Box<dyn ChainSpec>) -> &'static RuntimeVersion {137 match chain_spec.runtime_id() {138 #[cfg(feature = "unique-runtime")]139 RuntimeId::Unique => &unique_runtime::VERSION,140141 #[cfg(feature = "quartz-runtime")]142 RuntimeId::Quartz => &quartz_runtime::VERSION,143144 RuntimeId::Opal => &opal_runtime::VERSION,145 RuntimeId::Unknown(chain) => panic!("{}", no_runtime_err!(chain)),146 }147 }148}149150impl SubstrateCli for RelayChainCli {151 // TODO use args152 fn impl_name() -> String {153 "Unique Node".into()154 }155156 fn impl_version() -> String {157 env!("SUBSTRATE_CLI_IMPL_VERSION").into()158 }159 // TODO use args160 fn description() -> String {161 "Unique Node\n\nThe command-line arguments provided first will be \162 passed to the parachain node, while the arguments provided after -- will be passed \163 to the relaychain node.\n\n\164 parachain-collator [parachain-args] -- [relaychain-args]"165 .into()166 }167168 fn author() -> String {169 env!("CARGO_PKG_AUTHORS").into()170 }171 // TODO use args172 fn support_url() -> String {173 "support@unique.network".into()174 }175176 fn copyright_start_year() -> i32 {177 2019178 }179180 fn load_spec(&self, id: &str) -> std::result::Result<Box<dyn sc_service::ChainSpec>, String> {181 polkadot_cli::Cli::from_iter([RelayChainCli::executable_name()].iter()).load_spec(id)182 }183184 fn native_runtime_version(chain_spec: &Box<dyn ChainSpec>) -> &'static RuntimeVersion {185 polkadot_cli::Cli::native_runtime_version(chain_spec)186 }187}188189#[allow(clippy::borrowed_box)]190fn extract_genesis_wasm(chain_spec: &Box<dyn sc_service::ChainSpec>) -> Result<Vec<u8>> {191 let mut storage = chain_spec.build_storage()?;192193 storage194 .top195 .remove(sp_core::storage::well_known_keys::CODE)196 .ok_or_else(|| "Could not find wasm file in genesis state!".into())197}198199macro_rules! async_run_with_runtime {200 (201 $runtime_api:path, $executor:path,202 $runner:ident, $components:ident, $cli:ident, $cmd:ident, $config:ident,203 $( $code:tt )*204 ) => {205 $runner.async_run(|$config| {206 let $components = new_partial::<207 $runtime_api, $executor, _208 >(209 &$config,210 crate::service::parachain_build_import_queue,211 )?;212 let task_manager = $components.task_manager;213214 { $( $code )* }.map(|v| (v, task_manager))215 })216 };217}218219macro_rules! construct_async_run {220 (|$components:ident, $cli:ident, $cmd:ident, $config:ident| $( $code:tt )* ) => {{221 let runner = $cli.create_runner($cmd)?;222223 match runner.config().chain_spec.runtime_id() {224 #[cfg(feature = "unique-runtime")]225 RuntimeId::Unique => async_run_with_runtime!(226 unique_runtime::RuntimeApi, UniqueRuntimeExecutor,227 runner, $components, $cli, $cmd, $config, $( $code )*228 ),229230 #[cfg(feature = "quartz-runtime")]231 RuntimeId::Quartz => async_run_with_runtime!(232 quartz_runtime::RuntimeApi, QuartzRuntimeExecutor,233 runner, $components, $cli, $cmd, $config, $( $code )*234 ),235236 RuntimeId::Opal => async_run_with_runtime!(237 opal_runtime::RuntimeApi, OpalRuntimeExecutor,238 runner, $components, $cli, $cmd, $config, $( $code )*239 ),240241 RuntimeId::Unknown(chain) => Err(no_runtime_err!(chain).into())242 }243 }}244}245246macro_rules! start_node_using_chain_runtime {247 ($start_node_fn:ident($config:expr $(, $($args:expr),+)?) $($code:tt)*) => {248 match $config.chain_spec.runtime_id() {249 #[cfg(feature = "unique-runtime")]250 RuntimeId::Unique => $start_node_fn::<251 unique_runtime::Runtime,252 unique_runtime::RuntimeApi,253 UniqueRuntimeExecutor,254 >($config $(, $($args),+)?) $($code)*,255256 #[cfg(feature = "quartz-runtime")]257 RuntimeId::Quartz => $start_node_fn::<258 quartz_runtime::Runtime,259 quartz_runtime::RuntimeApi,260 QuartzRuntimeExecutor,261 >($config $(, $($args),+)?) $($code)*,262263 RuntimeId::Opal => $start_node_fn::<264 opal_runtime::Runtime,265 opal_runtime::RuntimeApi,266 OpalRuntimeExecutor,267 >($config $(, $($args),+)?) $($code)*,268269 RuntimeId::Unknown(chain) => Err(no_runtime_err!(chain).into()),270 }271 };272}273274/// Parse command line arguments into service configuration.275pub fn run() -> Result<()> {276 let cli = Cli::from_args();277278 match &cli.subcommand {279 Some(Subcommand::BuildSpec(cmd)) => {280 let runner = cli.create_runner(cmd)?;281 runner.sync_run(|config| cmd.run(config.chain_spec, config.network))282 }283 Some(Subcommand::CheckBlock(cmd)) => {284 construct_async_run!(|components, cli, cmd, config| {285 Ok(cmd.run(components.client, components.import_queue))286 })287 }288 Some(Subcommand::ExportBlocks(cmd)) => {289 construct_async_run!(|components, cli, cmd, config| {290 Ok(cmd.run(components.client, config.database))291 })292 }293 Some(Subcommand::ExportState(cmd)) => {294 construct_async_run!(|components, cli, cmd, config| {295 Ok(cmd.run(components.client, config.chain_spec))296 })297 }298 Some(Subcommand::ImportBlocks(cmd)) => {299 construct_async_run!(|components, cli, cmd, config| {300 Ok(cmd.run(components.client, components.import_queue))301 })302 }303 Some(Subcommand::PurgeChain(cmd)) => {304 let runner = cli.create_runner(cmd)?;305306 runner.sync_run(|config| {307 let polkadot_cli = RelayChainCli::new(308 &config,309 [RelayChainCli::executable_name()]310 .iter()311 .chain(cli.relaychain_args.iter()),312 );313314 let polkadot_config = SubstrateCli::create_configuration(315 &polkadot_cli,316 &polkadot_cli,317 config.tokio_handle.clone(),318 )319 .map_err(|err| format!("Relay chain argument error: {}", err))?;320321 cmd.run(config, polkadot_config)322 })323 }324 Some(Subcommand::Revert(cmd)) => construct_async_run!(|components, cli, cmd, config| {325 Ok(cmd.run(components.client, components.backend))326 }),327 Some(Subcommand::ExportGenesisState(params)) => {328 let mut builder = sc_cli::LoggerBuilder::new("");329 builder.with_profiling(sc_tracing::TracingReceiver::Log, "");330 let _ = builder.init();331332 let spec = load_spec(¶ms.chain.clone().unwrap_or_default())?;333 let state_version = Cli::native_runtime_version(&spec).state_version();334 let block: Block = generate_genesis_block(&spec, state_version)?;335 let raw_header = block.header().encode();336 let output_buf = if params.raw {337 raw_header338 } else {339 format!("0x{:?}", HexDisplay::from(&block.header().encode())).into_bytes()340 };341342 if let Some(output) = ¶ms.output {343 std::fs::write(output, output_buf)?;344 } else {345 std::io::stdout().write_all(&output_buf)?;346 }347348 Ok(())349 }350 Some(Subcommand::ExportGenesisWasm(params)) => {351 let mut builder = sc_cli::LoggerBuilder::new("");352 builder.with_profiling(sc_tracing::TracingReceiver::Log, "");353 let _ = builder.init();354355 let raw_wasm_blob =356 extract_genesis_wasm(&cli.load_spec(¶ms.chain.clone().unwrap_or_default())?)?;357 let output_buf = if params.raw {358 raw_wasm_blob359 } else {360 format!("0x{:?}", HexDisplay::from(&raw_wasm_blob)).into_bytes()361 };362363 if let Some(output) = ¶ms.output {364 std::fs::write(output, output_buf)?;365 } else {366 std::io::stdout().write_all(&output_buf)?;367 }368369 Ok(())370 }371 Some(Subcommand::Benchmark(cmd)) => {372 if cfg!(feature = "runtime-benchmarks") {373 let runner = cli.create_runner(cmd)?;374 runner.sync_run(|config| match config.chain_spec.runtime_id() {375 #[cfg(feature = "unique-runtime")]376 RuntimeId::Unique => cmd.run::<Block, UniqueRuntimeExecutor>(config),377378 #[cfg(feature = "quartz-runtime")]379 RuntimeId::Quartz => cmd.run::<Block, QuartzRuntimeExecutor>(config),380381 RuntimeId::Opal => cmd.run::<Block, OpalRuntimeExecutor>(config),382 RuntimeId::Unknown(chain) => Err(no_runtime_err!(chain).into()),383 })384 } else {385 Err("Benchmarking wasn't enabled when building the node. \386 You can enable it with `--features runtime-benchmarks`."387 .into())388 }389 }390 None => {391 let runner = cli.create_runner(&cli.run.normalize())?;392393 runner.run_node_until_exit(|config| async move {394 let extensions = chain_spec::Extensions::try_get(&*config.chain_spec);395396 let service_id = config.chain_spec.service_id();397 let relay_chain_id = extensions.map(|e| e.relay_chain.clone());398 let is_dev_service = matches![service_id, ServiceId::Dev]399 || relay_chain_id == Some("dev-service".into());400401 if is_dev_service {402 info!("Running Dev service");403404 return start_node_using_chain_runtime! {405 start_dev_node(config).map_err(Into::into)406 };407 };408409 let para_id = extensions410 .map(|e| e.para_id)411 .ok_or("Could not find parachain ID in chain-spec.")?;412413 let polkadot_cli = RelayChainCli::new(414 &config,415 [RelayChainCli::executable_name()]416 .iter()417 .chain(cli.relaychain_args.iter()),418 );419420 let para_id = ParaId::from(para_id);421422 let parachain_account =423 AccountIdConversion::<polkadot_primitives::v0::AccountId>::into_account(424 ¶_id,425 );426427 let state_version =428 RelayChainCli::native_runtime_version(&config.chain_spec).state_version();429 let block: Block = generate_genesis_block(&config.chain_spec, state_version)430 .map_err(|e| format!("{:?}", e))?;431 let genesis_state = format!("0x{:?}", HexDisplay::from(&block.header().encode()));432 let genesis_hash = format!("0x{:?}", HexDisplay::from(&block.header().hash().0));433434 let polkadot_config = SubstrateCli::create_configuration(435 &polkadot_cli,436 &polkadot_cli,437 config.tokio_handle.clone(),438 )439 .map_err(|err| format!("Relay chain argument error: {}", err))?;440441 info!("Parachain id: {:?}", para_id);442 info!("Parachain Account: {}", parachain_account);443 info!("Parachain genesis state: {}", genesis_state);444 info!("Parachain genesis hash: {}", genesis_hash);445 info!(446 "Is collating: {}",447 if config.role.is_authority() {448 "yes"449 } else {450 "no"451 }452 );453454 start_node_using_chain_runtime! {455 start_node(config, polkadot_config, para_id)456 .await457 .map(|r| r.0)458 .map_err(Into::into)459 }460 })461 }462 }463}464465impl DefaultConfigurationValues for RelayChainCli {466 fn p2p_listen_port() -> u16 {467 30334468 }469470 fn rpc_ws_listen_port() -> u16 {471 9945472 }473474 fn rpc_http_listen_port() -> u16 {475 9934476 }477478 fn prometheus_listen_port() -> u16 {479 9616480 }481}482483impl CliConfiguration<Self> for RelayChainCli {484 fn shared_params(&self) -> &SharedParams {485 self.base.base.shared_params()486 }487488 fn import_params(&self) -> Option<&ImportParams> {489 self.base.base.import_params()490 }491492 fn network_params(&self) -> Option<&NetworkParams> {493 self.base.base.network_params()494 }495496 fn keystore_params(&self) -> Option<&KeystoreParams> {497 self.base.base.keystore_params()498 }499500 fn base_path(&self) -> Result<Option<BasePath>> {501 Ok(self502 .shared_params()503 .base_path()504 .or_else(|| self.base_path.clone().map(Into::into)))505 }506507 fn rpc_http(&self, default_listen_port: u16) -> Result<Option<SocketAddr>> {508 self.base.base.rpc_http(default_listen_port)509 }510511 fn rpc_ipc(&self) -> Result<Option<String>> {512 self.base.base.rpc_ipc()513 }514515 fn rpc_ws(&self, default_listen_port: u16) -> Result<Option<SocketAddr>> {516 self.base.base.rpc_ws(default_listen_port)517 }518519 fn prometheus_config(520 &self,521 default_listen_port: u16,522 chain_spec: &Box<dyn ChainSpec>,523 ) -> Result<Option<PrometheusConfig>> {524 self.base525 .base526 .prometheus_config(default_listen_port, chain_spec)527 }528529 fn init<F>(530 &self,531 _support_url: &String,532 _impl_version: &String,533 _logger_hook: F,534 _config: &sc_service::Configuration,535 ) -> Result<()> {536 unreachable!("PolkadotCli is never initialized; qed");537 }538539 fn chain_id(&self, is_dev: bool) -> Result<String> {540 let chain_id = self.base.base.chain_id(is_dev)?;541542 Ok(if chain_id.is_empty() {543 self.chain_id.clone().unwrap_or_default()544 } else {545 chain_id546 })547 }548549 fn role(&self, is_dev: bool) -> Result<sc_service::Role> {550 self.base.base.role(is_dev)551 }552553 fn transaction_pool(&self) -> Result<sc_service::config::TransactionPoolOptions> {554 self.base.base.transaction_pool()555 }556557 fn state_cache_child_ratio(&self) -> Result<Option<usize>> {558 self.base.base.state_cache_child_ratio()559 }560561 fn rpc_methods(&self) -> Result<sc_service::config::RpcMethods> {562 self.base.base.rpc_methods()563 }564565 fn rpc_ws_max_connections(&self) -> Result<Option<usize>> {566 self.base.base.rpc_ws_max_connections()567 }568569 fn rpc_cors(&self, is_dev: bool) -> Result<Option<Vec<String>>> {570 self.base.base.rpc_cors(is_dev)571 }572573 fn default_heap_pages(&self) -> Result<Option<u64>> {574 self.base.base.default_heap_pages()575 }576577 fn force_authoring(&self) -> Result<bool> {578 self.base.base.force_authoring()579 }580581 fn disable_grandpa(&self) -> Result<bool> {582 self.base.base.disable_grandpa()583 }584585 fn max_runtime_instances(&self) -> Result<Option<usize>> {586 self.base.base.max_runtime_instances()587 }588589 fn announce_block(&self) -> Result<bool> {590 self.base.base.announce_block()591 }592593 fn telemetry_endpoints(594 &self,595 chain_spec: &Box<dyn ChainSpec>,596 ) -> Result<Option<sc_telemetry::TelemetryEndpoints>> {597 self.base.base.telemetry_endpoints(chain_spec)598 }599}node/cli/src/service.rsdiffbeforeafterboth--- a/node/cli/src/service.rs
+++ b/node/cli/src/service.rs
@@ -25,9 +25,9 @@
use futures::StreamExt;
use unique_rpc::overrides_handle;
-// Local Runtime Types
-use unique_runtime::RuntimeApi;
+use serde::{Serialize, Deserialize};
+
// Cumulus Imports
use cumulus_client_consensus_aura::{AuraConsensus, BuildAuraConsensusParams, SlotProportion};
use cumulus_client_consensus_common::ParachainConsensus;
@@ -56,16 +56,15 @@
use fc_rpc_core::types::FilterPool;
use fc_mapping_sync::{MappingSyncWorker, SyncStrategy};
-// Runtime type overrides
-type BlockNumber = u32;
-type Header = sp_runtime::generic::Header<BlockNumber, sp_runtime::traits::BlakeTwo256>;
-pub type Block = sp_runtime::generic::Block<Header, sp_runtime::OpaqueExtrinsic>;
-type Hash = sp_core::H256;
+use unique_runtime_common::types::{AuraId, RuntimeInstance, AccountId, Balance, Index, Hash, Block};
/// Native executor instance.
-pub struct ParachainRuntimeExecutor;
+pub struct UniqueRuntimeExecutor;
+pub struct QuartzRuntimeExecutor;
+pub struct OpalRuntimeExecutor;
-impl NativeExecutionDispatch for ParachainRuntimeExecutor {
+#[cfg(feature = "unique-runtime")]
+impl NativeExecutionDispatch for UniqueRuntimeExecutor {
type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions;
fn dispatch(method: &str, data: &[u8]) -> Option<Vec<u8>> {
@@ -77,6 +76,31 @@
}
}
+#[cfg(feature = "quartz-runtime")]
+impl NativeExecutionDispatch for QuartzRuntimeExecutor {
+ type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions;
+
+ fn dispatch(method: &str, data: &[u8]) -> Option<Vec<u8>> {
+ quartz_runtime::api::dispatch(method, data)
+ }
+
+ fn native_version() -> sc_executor::NativeVersion {
+ quartz_runtime::native_version()
+ }
+}
+
+impl NativeExecutionDispatch for OpalRuntimeExecutor {
+ type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions;
+
+ fn dispatch(method: &str, data: &[u8]) -> Option<Vec<u8>> {
+ opal_runtime::api::dispatch(method, data)
+ }
+
+ fn native_version() -> sc_executor::NativeVersion {
+ opal_runtime::native_version()
+ }
+}
+
pub fn open_frontier_backend(config: &Configuration) -> Result<Arc<fc_db::Backend<Block>>, String> {
let config_dir = config
.base_path
@@ -97,9 +121,7 @@
)?))
}
-type ExecutorDispatch = ParachainRuntimeExecutor;
-
-type FullClient =
+type FullClient<RuntimeApi, ExecutorDispatch> =
sc_service::TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<ExecutorDispatch>>;
type FullBackend = sc_service::TFullBackend<Block>;
type FullSelectChain = sc_consensus::LongestChain<FullBackend, Block>;
@@ -109,16 +131,16 @@
/// Use this macro if you don't actually need the full service, but just the builder in order to
/// be able to perform chain operations.
#[allow(clippy::type_complexity)]
-pub fn new_partial<BIQ>(
+pub fn new_partial<RuntimeApi, ExecutorDispatch, BIQ>(
config: &Configuration,
build_import_queue: BIQ,
) -> Result<
PartialComponents<
- FullClient,
+ FullClient<RuntimeApi, ExecutorDispatch>,
FullBackend,
FullSelectChain,
- sc_consensus::DefaultImportQueue<Block, FullClient>,
- sc_transaction_pool::FullPool<Block, FullClient>,
+ sc_consensus::DefaultImportQueue<Block, FullClient<RuntimeApi, ExecutorDispatch>>,
+ sc_transaction_pool::FullPool<Block, FullClient<RuntimeApi, ExecutorDispatch>>,
(
Option<Telemetry>,
Option<FilterPool>,
@@ -131,13 +153,21 @@
>
where
sc_client_api::StateBackendFor<FullBackend, Block>: sp_api::StateBackend<BlakeTwo256>,
+ RuntimeApi: sp_api::ConstructRuntimeApi<Block, FullClient<RuntimeApi, ExecutorDispatch>>
+ + Send
+ + Sync
+ + 'static,
+ RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block>,
ExecutorDispatch: NativeExecutionDispatch + 'static,
BIQ: FnOnce(
- Arc<FullClient>,
+ Arc<FullClient<RuntimeApi, ExecutorDispatch>>,
&Configuration,
Option<TelemetryHandle>,
&TaskManager,
- ) -> Result<sc_consensus::DefaultImportQueue<Block, FullClient>, sc_service::Error>,
+ ) -> Result<
+ sc_consensus::DefaultImportQueue<Block, FullClient<RuntimeApi, ExecutorDispatch>>,
+ sc_service::Error,
+ >,
{
let _telemetry = config
.telemetry_endpoints
@@ -231,29 +261,50 @@
///
/// This is the actual implementation that is abstract over the executor and the runtime api.
#[sc_tracing::logging::prefix_logs_with("Parachain")]
-async fn start_node_impl<BIQ, BIC>(
+async fn start_node_impl<Runtime, RuntimeApi, ExecutorDispatch, BIQ, BIC>(
parachain_config: Configuration,
polkadot_config: Configuration,
id: ParaId,
build_import_queue: BIQ,
build_consensus: BIC,
-) -> sc_service::error::Result<(TaskManager, Arc<FullClient>)>
+) -> sc_service::error::Result<(TaskManager, Arc<FullClient<RuntimeApi, ExecutorDispatch>>)>
where
sc_client_api::StateBackendFor<FullBackend, Block>: sp_api::StateBackend<BlakeTwo256>,
+ Runtime: RuntimeInstance + Send + Sync + 'static,
+ <Runtime as RuntimeInstance>::CrossAccountId: Serialize,
+ for<'de> <Runtime as RuntimeInstance>::CrossAccountId: Deserialize<'de>,
+ RuntimeApi: sp_api::ConstructRuntimeApi<Block, FullClient<RuntimeApi, ExecutorDispatch>>
+ + Send
+ + Sync
+ + 'static,
+ RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block>
+ + fp_rpc::EthereumRuntimeRPCApi<Block>
+ + sp_session::SessionKeys<Block>
+ + sp_block_builder::BlockBuilder<Block>
+ + pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance>
+ + sp_api::ApiExt<Block, StateBackend = sc_client_api::StateBackendFor<FullBackend, Block>>
+ + up_rpc::UniqueApi<Block, Runtime::CrossAccountId, AccountId>
+ + substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Index>
+ + sp_api::Metadata<Block>
+ + sp_offchain::OffchainWorkerApi<Block>
+ + cumulus_primitives_core::CollectCollationInfo<Block>,
ExecutorDispatch: NativeExecutionDispatch + 'static,
BIQ: FnOnce(
- Arc<FullClient>,
+ Arc<FullClient<RuntimeApi, ExecutorDispatch>>,
&Configuration,
Option<TelemetryHandle>,
&TaskManager,
- ) -> Result<sc_consensus::DefaultImportQueue<Block, FullClient>, sc_service::Error>,
+ ) -> Result<
+ sc_consensus::DefaultImportQueue<Block, FullClient<RuntimeApi, ExecutorDispatch>>,
+ sc_service::Error,
+ >,
BIC: FnOnce(
- Arc<FullClient>,
+ Arc<FullClient<RuntimeApi, ExecutorDispatch>>,
Option<&Registry>,
Option<TelemetryHandle>,
&TaskManager,
Arc<dyn RelayChainInterface>,
- Arc<sc_transaction_pool::FullPool<Block, FullClient>>,
+ Arc<sc_transaction_pool::FullPool<Block, FullClient<RuntimeApi, ExecutorDispatch>>>,
Arc<NetworkService<Block, Hash>>,
SyncCryptoStorePtr,
bool,
@@ -265,7 +316,8 @@
let parachain_config = prepare_node_config(parachain_config);
- let params = new_partial::<BIQ>(¶chain_config, build_import_queue)?;
+ let params =
+ new_partial::<RuntimeApi, ExecutorDispatch, BIQ>(¶chain_config, build_import_queue)?;
let (mut telemetry, filter_pool, frontier_backend, telemetry_worker_handle, fee_history_cache) =
params.other;
@@ -311,7 +363,7 @@
let block_data_cache = Arc::new(fc_rpc::EthBlockDataCache::new(
task_manager.spawn_handle(),
- overrides_handle(client.clone()),
+ overrides_handle::<_, _, Runtime>(client.clone()),
50,
50,
));
@@ -337,10 +389,12 @@
fee_history_limit: 2048,
};
- Ok(unique_rpc::create_full::<_, _, _, _, RuntimeApi, _>(
- full_deps,
- subscription_executor.clone(),
- ))
+ Ok(
+ unique_rpc::create_full::<_, _, _, _, Runtime, RuntimeApi, _>(
+ full_deps,
+ subscription_executor.clone(),
+ ),
+ )
});
task_manager.spawn_essential_handle().spawn(
@@ -427,12 +481,26 @@
}
/// Build the import queue for the the parachain runtime.
-pub fn parachain_build_import_queue(
- client: Arc<FullClient>,
+pub fn parachain_build_import_queue<RuntimeApi, ExecutorDispatch>(
+ client: Arc<FullClient<RuntimeApi, ExecutorDispatch>>,
config: &Configuration,
telemetry: Option<TelemetryHandle>,
task_manager: &TaskManager,
-) -> Result<sc_consensus::DefaultImportQueue<Block, FullClient>, sc_service::Error> {
+) -> Result<
+ sc_consensus::DefaultImportQueue<Block, FullClient<RuntimeApi, ExecutorDispatch>>,
+ sc_service::Error,
+>
+where
+ RuntimeApi: sp_api::ConstructRuntimeApi<Block, FullClient<RuntimeApi, ExecutorDispatch>>
+ + Send
+ + Sync
+ + 'static,
+ RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block>
+ + sp_block_builder::BlockBuilder<Block>
+ + sp_consensus_aura::AuraApi<Block, AuraId>
+ + sp_api::ApiExt<Block, StateBackend = sc_client_api::StateBackendFor<FullBackend, Block>>,
+ ExecutorDispatch: NativeExecutionDispatch + 'static,
+{
let slot_duration = cumulus_client_consensus_aura::slot_duration(&*client)?;
cumulus_client_consensus_aura::import_queue::<
@@ -466,12 +534,34 @@
}
/// Start a normal parachain node.
-pub async fn start_node(
+pub async fn start_node<Runtime, RuntimeApi, ExecutorDispatch>(
parachain_config: Configuration,
polkadot_config: Configuration,
id: ParaId,
-) -> sc_service::error::Result<(TaskManager, Arc<FullClient>)> {
- start_node_impl::<_, _>(
+) -> sc_service::error::Result<(TaskManager, Arc<FullClient<RuntimeApi, ExecutorDispatch>>)>
+where
+ Runtime: RuntimeInstance + Send + Sync + 'static,
+ <Runtime as RuntimeInstance>::CrossAccountId: Serialize,
+ for<'de> <Runtime as RuntimeInstance>::CrossAccountId: Deserialize<'de>,
+ RuntimeApi: sp_api::ConstructRuntimeApi<Block, FullClient<RuntimeApi, ExecutorDispatch>>
+ + Send
+ + Sync
+ + 'static,
+ RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block>
+ + fp_rpc::EthereumRuntimeRPCApi<Block>
+ + sp_session::SessionKeys<Block>
+ + sp_block_builder::BlockBuilder<Block>
+ + pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance>
+ + sp_api::ApiExt<Block, StateBackend = sc_client_api::StateBackendFor<FullBackend, Block>>
+ + up_rpc::UniqueApi<Block, Runtime::CrossAccountId, AccountId>
+ + substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Index>
+ + sp_api::Metadata<Block>
+ + sp_offchain::OffchainWorkerApi<Block>
+ + cumulus_primitives_core::CollectCollationInfo<Block>
+ + sp_consensus_aura::AuraApi<Block, AuraId>,
+ ExecutorDispatch: NativeExecutionDispatch + 'static,
+{
+ start_node_impl::<Runtime, RuntimeApi, ExecutorDispatch, _, _>(
parachain_config,
polkadot_config,
id,
@@ -548,3 +638,250 @@
)
.await
}
+
+fn dev_build_import_queue<RuntimeApi, ExecutorDispatch>(
+ client: Arc<FullClient<RuntimeApi, ExecutorDispatch>>,
+ config: &Configuration,
+ _: Option<TelemetryHandle>,
+ task_manager: &TaskManager,
+) -> Result<
+ sc_consensus::DefaultImportQueue<Block, FullClient<RuntimeApi, ExecutorDispatch>>,
+ sc_service::Error,
+>
+where
+ RuntimeApi: sp_api::ConstructRuntimeApi<Block, FullClient<RuntimeApi, ExecutorDispatch>>
+ + Send
+ + Sync
+ + 'static,
+ RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block>
+ + sp_api::ApiExt<Block, StateBackend = sc_client_api::StateBackendFor<FullBackend, Block>>,
+ ExecutorDispatch: NativeExecutionDispatch + 'static,
+{
+ Ok(sc_consensus_manual_seal::import_queue(
+ Box::new(client.clone()),
+ &task_manager.spawn_essential_handle(),
+ config.prometheus_registry(),
+ ))
+}
+
+/// Builds a new development service. This service uses instant seal, and mocks
+/// the parachain inherent
+pub fn start_dev_node<Runtime, RuntimeApi, ExecutorDispatch>(
+ config: Configuration,
+) -> sc_service::error::Result<TaskManager>
+where
+ Runtime: RuntimeInstance + Send + Sync + 'static,
+ <Runtime as RuntimeInstance>::CrossAccountId: Serialize,
+ for<'de> <Runtime as RuntimeInstance>::CrossAccountId: Deserialize<'de>,
+ RuntimeApi: sp_api::ConstructRuntimeApi<Block, FullClient<RuntimeApi, ExecutorDispatch>>
+ + Send
+ + Sync
+ + 'static,
+ RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block>
+ + fp_rpc::EthereumRuntimeRPCApi<Block>
+ + sp_session::SessionKeys<Block>
+ + sp_block_builder::BlockBuilder<Block>
+ + pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance>
+ + sp_api::ApiExt<Block, StateBackend = sc_client_api::StateBackendFor<FullBackend, Block>>
+ + up_rpc::UniqueApi<Block, Runtime::CrossAccountId, AccountId>
+ + substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Index>
+ + sp_api::Metadata<Block>
+ + sp_offchain::OffchainWorkerApi<Block>
+ + cumulus_primitives_core::CollectCollationInfo<Block>
+ + sp_consensus_aura::AuraApi<Block, AuraId>,
+ ExecutorDispatch: NativeExecutionDispatch + 'static,
+{
+ use futures::Stream;
+ use sc_consensus_manual_seal::{run_manual_seal, EngineCommand, ManualSealParams};
+ use fc_consensus::FrontierBlockImport;
+ use sc_client_api::HeaderBackend;
+
+ let sc_service::PartialComponents {
+ client,
+ backend,
+ mut task_manager,
+ import_queue,
+ keystore_container,
+ select_chain: maybe_select_chain,
+ transaction_pool,
+ other:
+ (telemetry, filter_pool, frontier_backend, _telemetry_worker_handle, fee_history_cache),
+ } = new_partial::<RuntimeApi, ExecutorDispatch, _>(
+ &config,
+ dev_build_import_queue::<RuntimeApi, ExecutorDispatch>,
+ )?;
+
+ let block_data_cache = Arc::new(fc_rpc::EthBlockDataCache::new(
+ task_manager.spawn_handle(),
+ overrides_handle::<_, _, Runtime>(client.clone()),
+ 50,
+ 50,
+ ));
+
+ let (network, system_rpc_tx, network_starter) =
+ sc_service::build_network(sc_service::BuildNetworkParams {
+ config: &config,
+ client: client.clone(),
+ transaction_pool: transaction_pool.clone(),
+ spawn_handle: task_manager.spawn_handle(),
+ import_queue,
+ block_announce_validator_builder: None,
+ warp_sync: None,
+ })?;
+
+ if config.offchain_worker.enabled {
+ sc_service::build_offchain_workers(
+ &config,
+ task_manager.spawn_handle(),
+ client.clone(),
+ network.clone(),
+ );
+ }
+
+ let prometheus_registry = config.prometheus_registry().cloned();
+ let collator = config.role.is_authority();
+
+ let select_chain = maybe_select_chain.clone();
+
+ if collator {
+ let block_import =
+ FrontierBlockImport::new(client.clone(), client.clone(), frontier_backend.clone());
+
+ let env = sc_basic_authorship::ProposerFactory::new(
+ task_manager.spawn_handle(),
+ client.clone(),
+ transaction_pool.clone(),
+ prometheus_registry.as_ref(),
+ telemetry.as_ref().map(|x| x.handle()),
+ );
+
+ let commands_stream: Box<dyn Stream<Item = EngineCommand<Hash>> + Send + Sync + Unpin> =
+ Box::new(
+ // This bit cribbed from the implementation of instant seal.
+ transaction_pool
+ .pool()
+ .validated_pool()
+ .import_notification_stream()
+ .map(|_| EngineCommand::SealNewBlock {
+ create_empty: true, // was false in Moonbeam
+ finalize: false,
+ parent_hash: None,
+ sender: None,
+ }),
+ );
+
+ let slot_duration = cumulus_client_consensus_aura::slot_duration(&*client)?;
+ let client_set_aside_for_cidp = client.clone();
+
+ task_manager.spawn_essential_handle().spawn_blocking(
+ "authorship_task",
+ Some("block-authoring"),
+ run_manual_seal(ManualSealParams {
+ block_import,
+ env,
+ client: client.clone(),
+ pool: transaction_pool.clone(),
+ commands_stream,
+ select_chain: select_chain.clone(),
+ consensus_data_provider: None,
+ create_inherent_data_providers: move |block: Hash, ()| {
+ let current_para_block = client_set_aside_for_cidp
+ .number(block)
+ .expect("Header lookup should succeed")
+ .expect("Header passed in as parent should be present in backend.");
+
+ let client_for_xcm = client_set_aside_for_cidp.clone();
+ async move {
+ let time = sp_timestamp::InherentDataProvider::from_system_time();
+
+ let mocked_parachain = cumulus_primitives_parachain_inherent::MockValidationDataInherentDataProvider {
+ current_para_block,
+ relay_offset: 1000,
+ relay_blocks_per_para_block: 2,
+ xcm_config: cumulus_primitives_parachain_inherent::MockXcmConfig::new(
+ &*client_for_xcm,
+ block,
+ Default::default(),
+ Default::default(),
+ ),
+ raw_downward_messages: vec![],
+ raw_horizontal_messages: vec![],
+ };
+
+ let slot =
+ sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_duration(
+ *time,
+ slot_duration.slot_duration(),
+ );
+
+ Ok((time, slot, mocked_parachain))
+ }
+ },
+ }),
+ );
+ }
+
+ task_manager.spawn_essential_handle().spawn(
+ "frontier-mapping-sync-worker",
+ Some("block-authoring"),
+ MappingSyncWorker::new(
+ client.import_notification_stream(),
+ Duration::new(6, 0),
+ client.clone(),
+ backend.clone(),
+ frontier_backend.clone(),
+ SyncStrategy::Normal,
+ )
+ .for_each(|()| futures::future::ready(())),
+ );
+
+ let subscription_executor = sc_rpc::SubscriptionTaskExecutor::new(task_manager.spawn_handle());
+ let rpc_client = client.clone();
+ let rpc_pool = transaction_pool.clone();
+ let rpc_network = network.clone();
+ let rpc_frontier_backend = frontier_backend.clone();
+ let rpc_extensions_builder = Box::new(move |deny_unsafe, _| {
+ let full_deps = unique_rpc::FullDeps {
+ backend: rpc_frontier_backend.clone(),
+ deny_unsafe,
+ client: rpc_client.clone(),
+ pool: rpc_pool.clone(),
+ graph: rpc_pool.pool().clone(),
+ // TODO: Unhardcode
+ enable_dev_signer: false,
+ filter_pool: filter_pool.clone(),
+ network: rpc_network.clone(),
+ select_chain: select_chain.clone(),
+ is_authority: collator,
+ // TODO: Unhardcode
+ max_past_logs: 10000,
+ block_data_cache: block_data_cache.clone(),
+ fee_history_cache: fee_history_cache.clone(),
+ // TODO: Unhardcode
+ fee_history_limit: 2048,
+ };
+
+ Ok(
+ unique_rpc::create_full::<_, _, _, _, Runtime, RuntimeApi, _>(
+ full_deps,
+ subscription_executor.clone(),
+ ),
+ )
+ });
+
+ sc_service::spawn_tasks(sc_service::SpawnTasksParams {
+ network,
+ client,
+ keystore: keystore_container.sync_keystore(),
+ task_manager: &mut task_manager,
+ transaction_pool,
+ rpc_extensions_builder,
+ backend,
+ system_rpc_tx,
+ config,
+ telemetry: None,
+ })?;
+
+ network_starter.start_network();
+ Ok(task_manager)
+}
node/rpc/Cargo.tomldiffbeforeafterboth--- a/node/rpc/Cargo.toml
+++ b/node/rpc/Cargo.toml
@@ -48,10 +48,16 @@
fc-db = { default-features = false, git = "https://github.com/uniquenetwork/frontier.git", branch = "unique-polkadot-v0.9.17" }
fc-mapping-sync = { default-features = false, git = "https://github.com/uniquenetwork/frontier.git", branch = "unique-polkadot-v0.9.17" }
+pallet-common = { default-features = false, path = "../../pallets/common" }
+unique-runtime-common = { default-features = false, path = "../../runtime/common" }
pallet-unique = { path = "../../pallets/unique" }
uc-rpc = { path = "../../client/rpc" }
up-rpc = { path = "../../primitives/rpc" }
-unique-runtime = { path = "../../runtime" }
+[dependencies.serde]
+features = ['derive']
+version = '1.0.130'
+
[features]
+default = []
std = []
node/rpc/src/lib.rsdiffbeforeafterboth--- a/node/rpc/src/lib.rs
+++ b/node/rpc/src/lib.rs
@@ -15,7 +15,6 @@
// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
use sp_runtime::traits::BlakeTwo256;
-use unique_runtime::{Hash, AccountId, CrossAccountId, Index, opaque::Block, BlockNumber, Balance};
use fc_rpc::{
EthBlockDataCache, OverrideHandle, RuntimeApiStorageOverride, SchemaV1Override,
StorageOverride, SchemaV2Override, SchemaV3Override,
@@ -41,6 +40,10 @@
use sc_service::TransactionPool;
use std::{collections::BTreeMap, marker::PhantomData, sync::Arc};
+use unique_runtime_common::types::{
+ Hash, AccountId, RuntimeInstance, Index, Block, BlockNumber, Balance,
+};
+
/// Public io handler for exporting into other modules
pub type IoHandler = jsonrpc_core::IoHandler<sc_rpc::Metadata>;
@@ -90,29 +93,33 @@
pub block_data_cache: Arc<EthBlockDataCache<Block>>,
}
-struct AccountCodes<C, B> {
+struct AccountCodes<C, B, R> {
client: Arc<C>,
- _marker: PhantomData<B>,
+ _blk_marker: PhantomData<B>,
+ _runtime_marker: PhantomData<R>,
}
-impl<C, Block> AccountCodes<C, Block>
+impl<C, Block, R> AccountCodes<C, Block, R>
where
Block: sp_api::BlockT,
C: ProvideRuntimeApi<Block>,
+ R: RuntimeInstance,
{
fn new(client: Arc<C>) -> Self {
Self {
client,
- _marker: PhantomData,
+ _blk_marker: PhantomData,
+ _runtime_marker: PhantomData,
}
}
}
-impl<C, Block> fc_rpc::AccountCodeProvider<Block> for AccountCodes<C, Block>
+impl<C, Block, Runtime> fc_rpc::AccountCodeProvider<Block> for AccountCodes<C, Block, Runtime>
where
Block: sp_api::BlockT,
C: ProvideRuntimeApi<Block>,
- C::Api: up_rpc::UniqueApi<Block, CrossAccountId, AccountId>,
+ C::Api: up_rpc::UniqueApi<Block, <Runtime as RuntimeInstance>::CrossAccountId, AccountId>,
+ Runtime: RuntimeInstance,
{
fn code(&self, block: &sp_api::BlockId<Block>, account: sp_core::H160) -> Option<Vec<u8>> {
use up_rpc::UniqueApi;
@@ -124,22 +131,23 @@
}
}
-pub fn overrides_handle<C, BE>(client: Arc<C>) -> Arc<OverrideHandle<Block>>
+pub fn overrides_handle<C, BE, R>(client: Arc<C>) -> Arc<OverrideHandle<Block>>
where
C: ProvideRuntimeApi<Block> + StorageProvider<Block, BE> + AuxStore,
C: HeaderBackend<Block> + HeaderMetadata<Block, Error = BlockChainError>,
C: Send + Sync + 'static,
C::Api: fp_rpc::EthereumRuntimeRPCApi<Block>,
- C::Api: up_rpc::UniqueApi<Block, CrossAccountId, AccountId>,
+ C::Api: up_rpc::UniqueApi<Block, <R as RuntimeInstance>::CrossAccountId, AccountId>,
BE: Backend<Block> + 'static,
BE::State: StateBackend<BlakeTwo256>,
+ R: RuntimeInstance + Send + Sync + 'static,
{
let mut overrides_map = BTreeMap::new();
overrides_map.insert(
EthereumStorageSchema::V1,
Box::new(SchemaV1Override::new_with_code_provider(
client.clone(),
- Arc::new(AccountCodes::<C, Block>::new(client.clone())),
+ Arc::new(AccountCodes::<C, Block, R>::new(client.clone())),
)) as Box<dyn StorageOverride<_> + Send + Sync>,
);
overrides_map.insert(
@@ -160,7 +168,7 @@
}
/// Instantiate all Full RPC extensions.
-pub fn create_full<C, P, SC, CA, A, B>(
+pub fn create_full<C, P, SC, CA, R, A, B>(
deps: FullDeps<C, P, SC, CA>,
subscription_task_executor: SubscriptionTaskExecutor,
) -> jsonrpc_core::IoHandler<sc_rpc_api::Metadata>
@@ -174,11 +182,14 @@
// C::Api: pallet_contracts_rpc::ContractsRuntimeApi<Block, AccountId, Balance, BlockNumber, Hash>,
C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi<Block, Balance>,
C::Api: fp_rpc::EthereumRuntimeRPCApi<Block>,
- C::Api: up_rpc::UniqueApi<Block, CrossAccountId, AccountId>,
+ C::Api: up_rpc::UniqueApi<Block, <R as RuntimeInstance>::CrossAccountId, AccountId>,
B: sc_client_api::Backend<Block> + Send + Sync + 'static,
B::State: sc_client_api::backend::StateBackend<sp_runtime::traits::HashFor<Block>>,
P: TransactionPool<Block = Block> + 'static,
CA: ChainApi<Block = Block> + 'static,
+ R: RuntimeInstance + Send + Sync + 'static,
+ <R as RuntimeInstance>::CrossAccountId: serde::Serialize,
+ for<'de> <R as RuntimeInstance>::CrossAccountId: serde::Deserialize<'de>,
{
use fc_rpc::{
EthApi, EthApiServer, EthDevSigner, EthFilterApi, EthFilterApiServer, EthPubSubApi,
@@ -225,13 +236,13 @@
signers.push(Box::new(EthDevSigner::new()) as Box<dyn EthSigner>);
}
- let overrides = overrides_handle(client.clone());
+ let overrides = overrides_handle::<_, _, R>(client.clone());
io.extend_with(EthApiServer::to_delegate(EthApi::new(
client.clone(),
pool.clone(),
graph,
- unique_runtime::TransactionConverter,
+ <R as RuntimeInstance>::get_transaction_converter(),
network.clone(),
signers,
overrides.clone(),
runtime/Cargo.tomldiffbeforeafterboth--- a/runtime/Cargo.toml
+++ /dev/null
@@ -1,409 +0,0 @@
-################################################################################
-# Package
-
-[package]
-authors = ['Unique Network <support@uniquenetwork.io>']
-build = 'build.rs'
-description = 'Unique Runtime'
-edition = '2021'
-homepage = 'https://unique.network'
-license = 'GPLv3'
-name = 'unique-runtime'
-repository = 'https://github.com/UniqueNetwork/unique-chain'
-version = '0.9.17'
-
-[package.metadata.docs.rs]
-targets = ['x86_64-unknown-linux-gnu']
-
-[features]
-default = ['std']
-runtime-benchmarks = [
- 'hex-literal',
- 'frame-benchmarking',
- 'frame-support/runtime-benchmarks',
- 'frame-system-benchmarking',
- 'frame-system/runtime-benchmarks',
- 'pallet-ethereum/runtime-benchmarks',
- 'pallet-evm-migration/runtime-benchmarks',
- 'pallet-evm-coder-substrate/runtime-benchmarks',
- 'pallet-balances/runtime-benchmarks',
- 'pallet-timestamp/runtime-benchmarks',
- 'pallet-common/runtime-benchmarks',
- 'pallet-fungible/runtime-benchmarks',
- 'pallet-refungible/runtime-benchmarks',
- 'pallet-nonfungible/runtime-benchmarks',
- 'pallet-unique/runtime-benchmarks',
- 'pallet-inflation/runtime-benchmarks',
- 'pallet-xcm/runtime-benchmarks',
- 'sp-runtime/runtime-benchmarks',
- 'xcm-builder/runtime-benchmarks',
-]
-std = [
- 'codec/std',
- 'cumulus-pallet-aura-ext/std',
- 'cumulus-pallet-parachain-system/std',
- 'cumulus-pallet-xcm/std',
- 'cumulus-pallet-xcmp-queue/std',
- 'cumulus-primitives-core/std',
- 'cumulus-primitives-utility/std',
- 'frame-executive/std',
- 'frame-support/std',
- 'frame-system/std',
- 'frame-system-rpc-runtime-api/std',
- 'pallet-aura/std',
- 'pallet-balances/std',
- # 'pallet-contracts/std',
- # 'pallet-contracts-primitives/std',
- # 'pallet-contracts-rpc-runtime-api/std',
- # 'pallet-contract-helpers/std',
- 'pallet-randomness-collective-flip/std',
- 'pallet-sudo/std',
- 'pallet-timestamp/std',
- 'pallet-transaction-payment/std',
- 'pallet-transaction-payment-rpc-runtime-api/std',
- 'pallet-treasury/std',
- # 'pallet-vesting/std',
- 'pallet-evm/std',
- 'pallet-evm-migration/std',
- 'pallet-evm-contract-helpers/std',
- 'pallet-evm-transaction-payment/std',
- 'pallet-evm-coder-substrate/std',
- 'pallet-ethereum/std',
- 'pallet-base-fee/std',
- 'fp-rpc/std',
- 'up-rpc/std',
- 'up-evm-mapping/std',
- 'fp-self-contained/std',
- 'parachain-info/std',
- 'serde',
- 'pallet-inflation/std',
- 'pallet-common/std',
- 'pallet-fungible/std',
- 'pallet-refungible/std',
- 'pallet-nonfungible/std',
- 'pallet-unique/std',
- 'pallet-unq-scheduler/std',
- 'pallet-charge-transaction/std',
- 'up-data-structs/std',
- 'sp-api/std',
- 'sp-block-builder/std',
- "sp-consensus-aura/std",
- 'sp-core/std',
- 'sp-inherents/std',
- 'sp-io/std',
- 'sp-offchain/std',
- 'sp-runtime/std',
- 'sp-session/std',
- 'sp-std/std',
- 'sp-transaction-pool/std',
- 'sp-version/std',
- 'xcm/std',
- 'xcm-builder/std',
- 'xcm-executor/std',
-
- "orml-vesting/std",
-]
-limit-testing = ['pallet-unique/limit-testing', 'up-data-structs/limit-testing']
-
-################################################################################
-# Substrate Dependencies
-
-[dependencies.codec]
-default-features = false
-features = ['derive']
-package = 'parity-scale-codec'
-version = '2.3.0'
-
-[dependencies.frame-benchmarking]
-default-features = false
-git = 'https://github.com/paritytech/substrate.git'
-optional = true
-branch = 'polkadot-v0.9.17'
-
-[dependencies.frame-executive]
-default-features = false
-git = 'https://github.com/paritytech/substrate.git'
-branch = 'polkadot-v0.9.17'
-
-[dependencies.frame-support]
-default-features = false
-git = 'https://github.com/paritytech/substrate.git'
-branch = 'polkadot-v0.9.17'
-
-[dependencies.frame-system]
-default-features = false
-git = 'https://github.com/paritytech/substrate.git'
-branch = 'polkadot-v0.9.17'
-
-[dependencies.frame-system-benchmarking]
-default-features = false
-git = 'https://github.com/paritytech/substrate.git'
-optional = true
-branch = 'polkadot-v0.9.17'
-
-[dependencies.frame-system-rpc-runtime-api]
-default-features = false
-git = 'https://github.com/paritytech/substrate.git'
-branch = 'polkadot-v0.9.17'
-
-[dependencies.hex-literal]
-optional = true
-version = '0.3.3'
-
-[dependencies.serde]
-default-features = false
-features = ['derive']
-optional = true
-version = '1.0.130'
-
-[dependencies.pallet-aura]
-default-features = false
-git = 'https://github.com/paritytech/substrate.git'
-branch = 'polkadot-v0.9.17'
-
-[dependencies.pallet-balances]
-default-features = false
-git = 'https://github.com/paritytech/substrate.git'
-branch = 'polkadot-v0.9.17'
-
-# Contracts specific packages
-# [dependencies.pallet-contracts]
-# git = 'https://github.com/paritytech/substrate.git'
-# default-features = false
-# branch = 'polkadot-v0.9.17'
-# version = '4.0.0-dev'
-
-# [dependencies.pallet-contracts-primitives]
-# git = 'https://github.com/paritytech/substrate.git'
-# default-features = false
-# branch = 'polkadot-v0.9.17'
-# version = '4.0.0-dev'
-
-# [dependencies.pallet-contracts-rpc-runtime-api]
-# git = 'https://github.com/paritytech/substrate.git'
-# default-features = false
-# branch = 'polkadot-v0.9.17'
-# version = '4.0.0-dev'
-
-[dependencies.pallet-randomness-collective-flip]
-default-features = false
-git = 'https://github.com/paritytech/substrate.git'
-branch = 'polkadot-v0.9.17'
-
-[dependencies.pallet-sudo]
-default-features = false
-git = 'https://github.com/paritytech/substrate.git'
-branch = 'polkadot-v0.9.17'
-
-[dependencies.pallet-timestamp]
-default-features = false
-git = 'https://github.com/paritytech/substrate.git'
-branch = 'polkadot-v0.9.17'
-
-[dependencies.pallet-transaction-payment]
-default-features = false
-git = 'https://github.com/paritytech/substrate.git'
-branch = 'polkadot-v0.9.17'
-
-[dependencies.pallet-transaction-payment-rpc-runtime-api]
-default-features = false
-git = 'https://github.com/paritytech/substrate.git'
-branch = 'polkadot-v0.9.17'
-
-[dependencies.pallet-treasury]
-default-features = false
-git = 'https://github.com/paritytech/substrate.git'
-branch = 'polkadot-v0.9.17'
-
-# [dependencies.pallet-vesting]
-# default-features = false
-# git = 'https://github.com/paritytech/substrate.git'
-# branch = 'polkadot-v0.9.17'
-
-[dependencies.sp-arithmetic]
-default-features = false
-git = 'https://github.com/paritytech/substrate.git'
-branch = 'polkadot-v0.9.17'
-
-[dependencies.sp-api]
-default-features = false
-git = 'https://github.com/paritytech/substrate.git'
-branch = 'polkadot-v0.9.17'
-
-[dependencies.sp-block-builder]
-default-features = false
-git = 'https://github.com/paritytech/substrate.git'
-branch = 'polkadot-v0.9.17'
-
-[dependencies.sp-core]
-default-features = false
-git = 'https://github.com/paritytech/substrate.git'
-branch = 'polkadot-v0.9.17'
-
-[dependencies.sp-consensus-aura]
-default-features = false
-git = 'https://github.com/paritytech/substrate.git'
-branch = 'polkadot-v0.9.17'
-
-[dependencies.sp-inherents]
-default-features = false
-git = 'https://github.com/paritytech/substrate.git'
-branch = 'polkadot-v0.9.17'
-
-[dependencies.sp-io]
-default-features = false
-git = 'https://github.com/paritytech/substrate.git'
-branch = 'polkadot-v0.9.17'
-
-[dependencies.sp-offchain]
-default-features = false
-git = 'https://github.com/paritytech/substrate.git'
-branch = 'polkadot-v0.9.17'
-
-[dependencies.sp-runtime]
-default-features = false
-git = 'https://github.com/paritytech/substrate.git'
-branch = 'polkadot-v0.9.17'
-
-[dependencies.sp-session]
-default-features = false
-git = 'https://github.com/paritytech/substrate.git'
-branch = 'polkadot-v0.9.17'
-
-[dependencies.sp-std]
-default-features = false
-git = 'https://github.com/paritytech/substrate.git'
-branch = 'polkadot-v0.9.17'
-
-[dependencies.sp-transaction-pool]
-default-features = false
-git = 'https://github.com/paritytech/substrate.git'
-branch = 'polkadot-v0.9.17'
-
-[dependencies.sp-version]
-default-features = false
-git = 'https://github.com/paritytech/substrate.git'
-branch = 'polkadot-v0.9.17'
-
-[dependencies.smallvec]
-version = '1.6.1'
-
-################################################################################
-# Cumulus dependencies
-
-[dependencies.parachain-info]
-default-features = false
-git = 'https://github.com/uniqueNetwork/cumulus.git'
-branch = 'polkadot-v0.9.17'
-
-[dependencies.cumulus-pallet-aura-ext]
-git = 'https://github.com/uniqueNetwork/cumulus.git'
-branch = 'polkadot-v0.9.17'
-default-features = false
-
-[dependencies.cumulus-pallet-parachain-system]
-git = 'https://github.com/uniqueNetwork/cumulus.git'
-branch = 'polkadot-v0.9.17'
-default-features = false
-
-[dependencies.cumulus-primitives-core]
-git = 'https://github.com/uniqueNetwork/cumulus.git'
-branch = 'polkadot-v0.9.17'
-default-features = false
-
-[dependencies.cumulus-pallet-xcm]
-git = 'https://github.com/uniqueNetwork/cumulus.git'
-branch = 'polkadot-v0.9.17'
-default-features = false
-
-[dependencies.cumulus-pallet-dmp-queue]
-git = 'https://github.com/uniqueNetwork/cumulus.git'
-branch = 'polkadot-v0.9.17'
-default-features = false
-
-[dependencies.cumulus-pallet-xcmp-queue]
-git = 'https://github.com/uniqueNetwork/cumulus.git'
-branch = 'polkadot-v0.9.17'
-default-features = false
-
-[dependencies.cumulus-primitives-utility]
-git = 'https://github.com/uniqueNetwork/cumulus.git'
-branch = 'polkadot-v0.9.17'
-default-features = false
-
-[dependencies.cumulus-primitives-timestamp]
-git = 'https://github.com/uniqueNetwork/cumulus.git'
-branch = 'polkadot-v0.9.17'
-default-features = false
-
-################################################################################
-# Polkadot dependencies
-
-[dependencies.polkadot-parachain]
-git = 'https://github.com/paritytech/polkadot'
-branch = 'release-v0.9.17'
-default-features = false
-
-[dependencies.xcm]
-git = 'https://github.com/paritytech/polkadot'
-branch = 'release-v0.9.17'
-default-features = false
-
-[dependencies.xcm-builder]
-git = 'https://github.com/paritytech/polkadot'
-branch = 'release-v0.9.17'
-default-features = false
-
-[dependencies.xcm-executor]
-git = 'https://github.com/paritytech/polkadot'
-branch = 'release-v0.9.17'
-default-features = false
-
-[dependencies.pallet-xcm]
-git = 'https://github.com/paritytech/polkadot'
-branch = 'release-v0.9.17'
-default-features = false
-
-[dependencies.orml-vesting]
-git = 'https://github.com/UniqueNetwork/open-runtime-module-library'
-branch = 'unique-polkadot-v0.9.17'
-version = "0.4.1-dev"
-default-features = false
-
-################################################################################
-# local dependencies
-
-[dependencies]
-scale-info = { version = "1.0.0", default-features = false, features = [
- "derive",
-] }
-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 }
-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" }
-pallet-fungible = { default-features = false, path = "../pallets/fungible" }
-pallet-refungible = { default-features = false, path = "../pallets/refungible" }
-pallet-nonfungible = { default-features = false, path = "../pallets/nonfungible" }
-pallet-unq-scheduler = { path = '../pallets/scheduler', default-features = false }
-# pallet-contract-helpers = { path = '../pallets/contract-helpers', default-features = false, version = '0.1.0' }
-pallet-charge-transaction = { git = "https://github.com/UniqueNetwork/pallet-sponsoring", branch = 'polkadot-v0.9.17', package = "pallet-template-transaction-payment", default-features = false, version = '3.0.0' }
-pallet-evm-migration = { path = '../pallets/evm-migration', default-features = false }
-pallet-evm-contract-helpers = { path = '../pallets/evm-contract-helpers', default-features = false }
-pallet-evm-transaction-payment = { path = '../pallets/evm-transaction-payment', default-features = false }
-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.17" }
-pallet-ethereum = { default-features = false, git = "https://github.com/uniquenetwork/frontier.git", branch = "unique-polkadot-v0.9.17" }
-pallet-base-fee = { default-features = false, git = "https://github.com/uniquenetwork/frontier.git", branch = "unique-polkadot-v0.9.17" }
-fp-rpc = { default-features = false, git = "https://github.com/uniquenetwork/frontier.git", branch = "unique-polkadot-v0.9.17" }
-fp-self-contained = { default-features = false, git = "https://github.com/uniquenetwork/frontier.git", branch = "unique-polkadot-v0.9.17" }
-
-################################################################################
-# Build Dependencies
-
-[build-dependencies.substrate-wasm-builder]
-git = 'https://github.com/paritytech/substrate.git'
-branch = 'polkadot-v0.9.17'
runtime/build.rsdiffbeforeafterboth--- a/runtime/build.rs
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.
-// This file is part of Unique Network.
-
-// Unique Network is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-
-// Unique Network is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License
-// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
-
-use substrate_wasm_builder::WasmBuilder;
-
-fn main() {
- WasmBuilder::new()
- .with_current_project()
- .import_memory()
- .export_heap_base()
- .build()
-}
runtime/common/Cargo.tomldiffbeforeafterboth--- /dev/null
+++ b/runtime/common/Cargo.toml
@@ -0,0 +1,72 @@
+[package]
+authors = ['Unique Network <support@uniquenetwork.io>']
+description = 'Unique Runtime Common'
+edition = '2021'
+homepage = 'https://unique.network'
+license = 'All Rights Reserved'
+name = 'unique-runtime-common'
+repository = 'https://github.com/UniqueNetwork/unique-chain'
+version = '0.1.0'
+
+[features]
+default = ['std']
+std = [
+ 'sp-core/std',
+ 'sp-runtime/std',
+ 'codec/std',
+ 'frame-support/std',
+ 'frame-system/std',
+ 'sp-consensus-aura/std',
+ 'pallet-common/std',
+ 'fp-rpc/std',
+]
+runtime-benchmarks = [
+ 'sp-runtime/runtime-benchmarks',
+ 'frame-support/runtime-benchmarks',
+ 'frame-system/runtime-benchmarks'
+]
+
+[dependencies.sp-core]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'polkadot-v0.9.17'
+
+[dependencies.sp-runtime]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'polkadot-v0.9.17'
+
+[dependencies.codec]
+default-features = false
+features = ['derive']
+package = 'parity-scale-codec'
+version = '2.3.0'
+
+[dependencies.scale-info]
+default-features = false
+features = ["derive"]
+version = "1.0.0"
+
+[dependencies.frame-support]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'polkadot-v0.9.17'
+
+[dependencies.frame-system]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'polkadot-v0.9.17'
+
+[dependencies.pallet-common]
+default-features = false
+path = "../../pallets/common"
+
+[dependencies.sp-consensus-aura]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'polkadot-v0.9.17'
+
+[dependencies.fp-rpc]
+default-features = false
+git = "https://github.com/uniquenetwork/frontier.git"
+branch = "unique-polkadot-v0.9.17"
runtime/common/src/constants.rsdiffbeforeafterboth--- /dev/null
+++ b/runtime/common/src/constants.rs
@@ -0,0 +1,40 @@
+use sp_runtime::Perbill;
+use frame_support::{
+ parameter_types,
+ weights::{Weight, constants::WEIGHT_PER_SECOND},
+};
+use crate::types::{BlockNumber, Balance};
+
+pub const MILLISECS_PER_BLOCK: u64 = 12000;
+
+pub const SLOT_DURATION: u64 = MILLISECS_PER_BLOCK;
+
+// These time units are defined in number of blocks.
+pub const MINUTES: BlockNumber = 60_000 / (MILLISECS_PER_BLOCK as BlockNumber);
+pub const HOURS: BlockNumber = MINUTES * 60;
+pub const DAYS: BlockNumber = HOURS * 24;
+
+pub const MICROUNIQUE: Balance = 1_000_000_000_000;
+pub const MILLIUNIQUE: Balance = 1_000 * MICROUNIQUE;
+pub const CENTIUNIQUE: Balance = 10 * MILLIUNIQUE;
+pub const UNIQUE: Balance = 100 * CENTIUNIQUE;
+
+pub const WEIGHT_TO_FEE_COEFF: u32 = 142_688_000;
+
+// Targeting 0.15 UNQ per transfer
+pub const MIN_GAS_PRICE: u64 = 1_018_751_825_264;
+
+/// We assume that ~10% of the block weight is consumed by `on_initalize` handlers.
+/// This is used to limit the maximal weight of a single extrinsic.
+pub const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(10);
+/// We allow `Normal` extrinsics to fill up the block up to 75%, the rest can be used
+/// by Operational extrinsics.
+pub const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75);
+/// We allow for 2 seconds of compute with a 6 second average block time.
+pub const MAXIMUM_BLOCK_WEIGHT: Weight = WEIGHT_PER_SECOND / 2;
+
+parameter_types! {
+ pub const DefaultSponsoringRateLimit: BlockNumber = 1 * DAYS;
+
+ pub const TransactionByteFee: Balance = 501 * MICROUNIQUE; // Targeting 0.1 Unique per NFT transfer
+}
runtime/common/src/lib.rsdiffbeforeafterboth--- /dev/null
+++ b/runtime/common/src/lib.rs
@@ -0,0 +1,5 @@
+#![cfg_attr(not(feature = "std"), no_std)]
+
+pub mod constants;
+pub mod runtime_apis;
+pub mod types;
runtime/common/src/runtime_apis.rsdiffbeforeafterboth--- /dev/null
+++ b/runtime/common/src/runtime_apis.rs
@@ -0,0 +1,409 @@
+#[macro_export]
+macro_rules! impl_common_runtime_apis {
+ (
+ $(
+ #![custom_apis]
+
+ $($custom_apis:tt)+
+ )?
+ ) => {
+ impl_runtime_apis! {
+ $($($custom_apis)+)?
+
+ impl up_rpc::UniqueApi<Block, CrossAccountId, AccountId> for Runtime {
+ fn account_tokens(collection: CollectionId, account: CrossAccountId) -> Result<Vec<TokenId>, DispatchError> {
+ dispatch_unique_runtime!(collection.account_tokens(account))
+ }
+ fn token_exists(collection: CollectionId, token: TokenId) -> Result<bool, DispatchError> {
+ dispatch_unique_runtime!(collection.token_exists(token))
+ }
+
+ fn token_owner(collection: CollectionId, token: TokenId) -> Result<Option<CrossAccountId>, DispatchError> {
+ dispatch_unique_runtime!(collection.token_owner(token))
+ }
+ fn const_metadata(collection: CollectionId, token: TokenId) -> Result<Vec<u8>, DispatchError> {
+ dispatch_unique_runtime!(collection.const_metadata(token))
+ }
+ fn variable_metadata(collection: CollectionId, token: TokenId) -> Result<Vec<u8>, DispatchError> {
+ dispatch_unique_runtime!(collection.variable_metadata(token))
+ }
+
+ fn collection_tokens(collection: CollectionId) -> Result<u32, DispatchError> {
+ dispatch_unique_runtime!(collection.collection_tokens())
+ }
+ fn account_balance(collection: CollectionId, account: CrossAccountId) -> Result<u32, DispatchError> {
+ dispatch_unique_runtime!(collection.account_balance(account))
+ }
+ fn balance(collection: CollectionId, account: CrossAccountId, token: TokenId) -> Result<u128, DispatchError> {
+ dispatch_unique_runtime!(collection.balance(account, token))
+ }
+ fn allowance(
+ collection: CollectionId,
+ sender: CrossAccountId,
+ spender: CrossAccountId,
+ token: TokenId,
+ ) -> Result<u128, DispatchError> {
+ dispatch_unique_runtime!(collection.allowance(sender, spender, token))
+ }
+
+ fn eth_contract_code(account: H160) -> Option<Vec<u8>> {
+ <pallet_unique::UniqueErcSupport<Runtime>>::get_code(&account)
+ .or_else(|| <pallet_evm_migration::OnMethodCall<Runtime>>::get_code(&account))
+ .or_else(|| <pallet_evm_contract_helpers::HelpersOnMethodCall<Self>>::get_code(&account))
+ }
+ fn adminlist(collection: CollectionId) -> Result<Vec<CrossAccountId>, DispatchError> {
+ Ok(<pallet_common::Pallet<Runtime>>::adminlist(collection))
+ }
+ fn allowlist(collection: CollectionId) -> Result<Vec<CrossAccountId>, DispatchError> {
+ Ok(<pallet_common::Pallet<Runtime>>::allowlist(collection))
+ }
+ fn allowed(collection: CollectionId, user: CrossAccountId) -> Result<bool, DispatchError> {
+ Ok(<pallet_common::Pallet<Runtime>>::allowed(collection, user))
+ }
+ fn last_token_id(collection: CollectionId) -> Result<TokenId, DispatchError> {
+ dispatch_unique_runtime!(collection.last_token_id())
+ }
+ fn collection_by_id(collection: CollectionId) -> Result<Option<Collection<AccountId>>, DispatchError> {
+ Ok(<pallet_common::CollectionById<Runtime>>::get(collection))
+ }
+ fn collection_stats() -> Result<CollectionStats, DispatchError> {
+ Ok(<pallet_common::Pallet<Runtime>>::collection_stats())
+ }
+ }
+
+ impl sp_api::Core<Block> for Runtime {
+ fn version() -> RuntimeVersion {
+ VERSION
+ }
+
+ fn execute_block(block: Block) {
+ Executive::execute_block(block)
+ }
+
+ fn initialize_block(header: &<Block as BlockT>::Header) {
+ Executive::initialize_block(header)
+ }
+ }
+
+ impl sp_api::Metadata<Block> for Runtime {
+ fn metadata() -> OpaqueMetadata {
+ OpaqueMetadata::new(Runtime::metadata().into())
+ }
+ }
+
+ impl sp_block_builder::BlockBuilder<Block> for Runtime {
+ fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {
+ Executive::apply_extrinsic(extrinsic)
+ }
+
+ fn finalize_block() -> <Block as BlockT>::Header {
+ Executive::finalize_block()
+ }
+
+ fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<<Block as BlockT>::Extrinsic> {
+ data.create_extrinsics()
+ }
+
+ fn check_inherents(
+ block: Block,
+ data: sp_inherents::InherentData,
+ ) -> sp_inherents::CheckInherentsResult {
+ data.check_extrinsics(&block)
+ }
+
+ // fn random_seed() -> <Block as BlockT>::Hash {
+ // RandomnessCollectiveFlip::random_seed().0
+ // }
+ }
+
+ impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {
+ fn validate_transaction(
+ source: TransactionSource,
+ tx: <Block as BlockT>::Extrinsic,
+ hash: <Block as BlockT>::Hash,
+ ) -> TransactionValidity {
+ Executive::validate_transaction(source, tx, hash)
+ }
+ }
+
+ impl sp_offchain::OffchainWorkerApi<Block> for Runtime {
+ fn offchain_worker(header: &<Block as BlockT>::Header) {
+ Executive::offchain_worker(header)
+ }
+ }
+
+ impl fp_rpc::EthereumRuntimeRPCApi<Block> for Runtime {
+ fn chain_id() -> u64 {
+ <Runtime as pallet_evm::Config>::ChainId::get()
+ }
+
+ fn account_basic(address: H160) -> EVMAccount {
+ EVM::account_basic(&address)
+ }
+
+ fn gas_price() -> U256 {
+ <Runtime as pallet_evm::Config>::FeeCalculator::min_gas_price()
+ }
+
+ fn account_code_at(address: H160) -> Vec<u8> {
+ EVM::account_codes(address)
+ }
+
+ fn author() -> H160 {
+ <pallet_evm::Pallet<Runtime>>::find_author()
+ }
+
+ fn storage_at(address: H160, index: U256) -> H256 {
+ let mut tmp = [0u8; 32];
+ index.to_big_endian(&mut tmp);
+ EVM::account_storages(address, H256::from_slice(&tmp[..]))
+ }
+
+ #[allow(clippy::redundant_closure)]
+ fn call(
+ from: H160,
+ to: H160,
+ data: Vec<u8>,
+ value: U256,
+ gas_limit: U256,
+ max_fee_per_gas: Option<U256>,
+ max_priority_fee_per_gas: Option<U256>,
+ nonce: Option<U256>,
+ estimate: bool,
+ access_list: Option<Vec<(H160, Vec<H256>)>>,
+ ) -> Result<pallet_evm::CallInfo, sp_runtime::DispatchError> {
+ let config = if estimate {
+ let mut config = <Runtime as pallet_evm::Config>::config().clone();
+ config.estimate = true;
+ Some(config)
+ } else {
+ None
+ };
+
+ <Runtime as pallet_evm::Config>::Runner::call(
+ from,
+ to,
+ data,
+ value,
+ gas_limit.low_u64(),
+ max_fee_per_gas,
+ max_priority_fee_per_gas,
+ nonce,
+ access_list.unwrap_or_default(),
+ config.as_ref().unwrap_or_else(|| <Runtime as pallet_evm::Config>::config()),
+ ).map_err(|err| err.into())
+ }
+
+ #[allow(clippy::redundant_closure)]
+ fn create(
+ from: H160,
+ data: Vec<u8>,
+ value: U256,
+ gas_limit: U256,
+ max_fee_per_gas: Option<U256>,
+ max_priority_fee_per_gas: Option<U256>,
+ nonce: Option<U256>,
+ estimate: bool,
+ access_list: Option<Vec<(H160, Vec<H256>)>>,
+ ) -> Result<pallet_evm::CreateInfo, sp_runtime::DispatchError> {
+ let config = if estimate {
+ let mut config = <Runtime as pallet_evm::Config>::config().clone();
+ config.estimate = true;
+ Some(config)
+ } else {
+ None
+ };
+
+ <Runtime as pallet_evm::Config>::Runner::create(
+ from,
+ data,
+ value,
+ gas_limit.low_u64(),
+ max_fee_per_gas,
+ max_priority_fee_per_gas,
+ nonce,
+ access_list.unwrap_or_default(),
+ config.as_ref().unwrap_or_else(|| <Runtime as pallet_evm::Config>::config()),
+ ).map_err(|err| err.into())
+ }
+
+ fn current_transaction_statuses() -> Option<Vec<TransactionStatus>> {
+ Ethereum::current_transaction_statuses()
+ }
+
+ fn current_block() -> Option<pallet_ethereum::Block> {
+ Ethereum::current_block()
+ }
+
+ fn current_receipts() -> Option<Vec<pallet_ethereum::Receipt>> {
+ Ethereum::current_receipts()
+ }
+
+ fn current_all() -> (
+ Option<pallet_ethereum::Block>,
+ Option<Vec<pallet_ethereum::Receipt>>,
+ Option<Vec<TransactionStatus>>
+ ) {
+ (
+ Ethereum::current_block(),
+ Ethereum::current_receipts(),
+ Ethereum::current_transaction_statuses()
+ )
+ }
+
+ fn extrinsic_filter(xts: Vec<<Block as sp_api::BlockT>::Extrinsic>) -> Vec<pallet_ethereum::Transaction> {
+ xts.into_iter().filter_map(|xt| match xt.0.function {
+ Call::Ethereum(pallet_ethereum::Call::transact { transaction }) => Some(transaction),
+ _ => None
+ }).collect()
+ }
+
+ fn elasticity() -> Option<Permill> {
+ None
+ }
+ }
+
+ impl sp_session::SessionKeys<Block> for Runtime {
+ fn decode_session_keys(
+ encoded: Vec<u8>,
+ ) -> Option<Vec<(Vec<u8>, KeyTypeId)>> {
+ SessionKeys::decode_into_raw_public_keys(&encoded)
+ }
+
+ fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {
+ SessionKeys::generate(seed)
+ }
+ }
+
+ impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {
+ fn slot_duration() -> sp_consensus_aura::SlotDuration {
+ sp_consensus_aura::SlotDuration::from_millis(Aura::slot_duration())
+ }
+
+ fn authorities() -> Vec<AuraId> {
+ Aura::authorities().to_vec()
+ }
+ }
+
+ impl cumulus_primitives_core::CollectCollationInfo<Block> for Runtime {
+ fn collect_collation_info(header: &<Block as BlockT>::Header) -> cumulus_primitives_core::CollationInfo {
+ ParachainSystem::collect_collation_info(header)
+ }
+ }
+
+ impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Index> for Runtime {
+ fn account_nonce(account: AccountId) -> Index {
+ System::account_nonce(account)
+ }
+ }
+
+ impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance> for Runtime {
+ fn query_info(uxt: <Block as BlockT>::Extrinsic, len: u32) -> RuntimeDispatchInfo<Balance> {
+ TransactionPayment::query_info(uxt, len)
+ }
+ fn query_fee_details(uxt: <Block as BlockT>::Extrinsic, len: u32) -> FeeDetails<Balance> {
+ TransactionPayment::query_fee_details(uxt, len)
+ }
+ }
+
+ /*
+ impl pallet_contracts_rpc_runtime_api::ContractsApi<Block, AccountId, Balance, BlockNumber, Hash>
+ for Runtime
+ {
+ fn call(
+ origin: AccountId,
+ dest: AccountId,
+ value: Balance,
+ gas_limit: u64,
+ input_data: Vec<u8>,
+ ) -> pallet_contracts_primitives::ContractExecResult {
+ Contracts::bare_call(origin, dest, value, gas_limit, input_data, false)
+ }
+
+ fn instantiate(
+ origin: AccountId,
+ endowment: Balance,
+ gas_limit: u64,
+ code: pallet_contracts_primitives::Code<Hash>,
+ data: Vec<u8>,
+ salt: Vec<u8>,
+ ) -> pallet_contracts_primitives::ContractInstantiateResult<AccountId, BlockNumber>
+ {
+ Contracts::bare_instantiate(origin, endowment, gas_limit, code, data, salt, true, false)
+ }
+
+ fn get_storage(
+ address: AccountId,
+ key: [u8; 32],
+ ) -> pallet_contracts_primitives::GetStorageResult {
+ Contracts::get_storage(address, key)
+ }
+
+ fn rent_projection(
+ address: AccountId,
+ ) -> pallet_contracts_primitives::RentProjectionResult<BlockNumber> {
+ Contracts::rent_projection(address)
+ }
+ }
+ */
+
+ #[cfg(feature = "runtime-benchmarks")]
+ impl frame_benchmarking::Benchmark<Block> for Runtime {
+ fn benchmark_metadata(extra: bool) -> (
+ Vec<frame_benchmarking::BenchmarkList>,
+ Vec<frame_support::traits::StorageInfo>,
+ ) {
+ use frame_benchmarking::{list_benchmark, Benchmarking, BenchmarkList};
+ use frame_support::traits::StorageInfoTrait;
+
+ let mut list = Vec::<BenchmarkList>::new();
+
+ list_benchmark!(list, extra, pallet_evm_migration, EvmMigration);
+ list_benchmark!(list, extra, pallet_unique, Unique);
+ list_benchmark!(list, extra, pallet_inflation, Inflation);
+ list_benchmark!(list, extra, pallet_fungible, Fungible);
+ list_benchmark!(list, extra, pallet_refungible, Refungible);
+ list_benchmark!(list, extra, pallet_nonfungible, Nonfungible);
+ // list_benchmark!(list, extra, pallet_evm_coder_substrate, EvmCoderSubstrate);
+
+ let storage_info = AllPalletsReversedWithSystemFirst::storage_info();
+
+ return (list, storage_info)
+ }
+
+ fn dispatch_benchmark(
+ config: frame_benchmarking::BenchmarkConfig
+ ) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {
+ use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark, TrackedStorageKey};
+
+ let allowlist: Vec<TrackedStorageKey> = vec![
+ // Block Number
+ hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef702a5c1b19ab7a04f536c519aca4983ac").to_vec().into(),
+ // Total Issuance
+ hex_literal::hex!("c2261276cc9d1f8598ea4b6a74b15c2f57c875e4cff74148e4628f264b974c80").to_vec().into(),
+ // Execution Phase
+ hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef7ff553b5a9862a516939d82b3d3d8661a").to_vec().into(),
+ // Event Count
+ hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef70a98fdbe9ce6c55837576c60c7af3850").to_vec().into(),
+ // System Events
+ hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef780d41e5e16056765bc8461851072c9d7").to_vec().into(),
+ ];
+
+ let mut batches = Vec::<BenchmarkBatch>::new();
+ let params = (&config, &allowlist);
+
+ add_benchmark!(params, batches, pallet_evm_migration, EvmMigration);
+ add_benchmark!(params, batches, pallet_unique, Unique);
+ add_benchmark!(params, batches, pallet_inflation, Inflation);
+ add_benchmark!(params, batches, pallet_fungible, Fungible);
+ add_benchmark!(params, batches, pallet_refungible, Refungible);
+ add_benchmark!(params, batches, pallet_nonfungible, Nonfungible);
+ // add_benchmark!(params, batches, pallet_evm_coder_substrate, EvmCoderSubstrate);
+
+ if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) }
+ Ok(batches)
+ }
+ }
+ }
+ }
+}
runtime/common/src/types.rsdiffbeforeafterboth--- /dev/null
+++ b/runtime/common/src/types.rs
@@ -0,0 +1,56 @@
+use sp_runtime::{
+ traits::{Verify, IdentifyAccount, BlakeTwo256},
+ generic, MultiSignature,
+};
+
+pub use sp_runtime::OpaqueExtrinsic as UncheckedExtrinsic;
+
+/// Opaque block header type.
+pub type Header = generic::Header<BlockNumber, BlakeTwo256>;
+
+/// Opaque block type.
+pub type Block = generic::Block<Header, UncheckedExtrinsic>;
+
+pub type SessionHandlers = ();
+
+/// An index to a block.
+pub type BlockNumber = u32;
+
+/// Alias to 512-bit hash when used in the context of a transaction signature on the chain.
+pub type Signature = MultiSignature;
+
+/// Some way of identifying an account on the chain. We intentionally make it equivalent
+/// to the public key of our transaction signing scheme.
+pub type AccountId = <<Signature as Verify>::Signer as IdentifyAccount>::AccountId;
+
+/// The type for looking up accounts. We don't expect more than 4 billion of them, but you
+/// never know...
+pub type AccountIndex = u32;
+
+/// Balance of an account.
+pub type Balance = u128;
+
+/// Index of a transaction in the chain.
+pub type Index = u32;
+
+/// A hash of some data used by the chain.
+pub type Hash = sp_core::H256;
+
+/// Digest item type.
+pub type DigestItem = generic::DigestItem;
+
+pub use sp_consensus_aura::sr25519::AuthorityId as AuraId;
+
+pub trait RuntimeInstance {
+ type CrossAccountId: pallet_common::account::CrossAccountId<sp_runtime::AccountId32>
+ + Send
+ + Sync
+ + 'static;
+
+ type TransactionConverter: fp_rpc::ConvertTransaction<UncheckedExtrinsic>
+ + Send
+ + Sync
+ + 'static;
+
+ fn get_transaction_converter() -> Self::TransactionConverter;
+}
runtime/opal/Cargo.tomldiffbeforeafterboth--- /dev/null
+++ b/runtime/opal/Cargo.toml
@@ -0,0 +1,410 @@
+################################################################################
+# Package
+
+[package]
+authors = ['Unique Network <support@uniquenetwork.io>']
+build = 'build.rs'
+description = 'Opal Runtime'
+edition = '2021'
+homepage = 'https://unique.network'
+license = 'GPLv3'
+name = 'opal-runtime'
+repository = 'https://github.com/UniqueNetwork/unique-chain'
+version = '0.1.0'
+
+[package.metadata.docs.rs]
+targets = ['x86_64-unknown-linux-gnu']
+
+[features]
+default = ['std']
+runtime-benchmarks = [
+ 'hex-literal',
+ 'frame-benchmarking',
+ 'frame-support/runtime-benchmarks',
+ 'frame-system-benchmarking',
+ 'frame-system/runtime-benchmarks',
+ 'pallet-ethereum/runtime-benchmarks',
+ 'pallet-evm-migration/runtime-benchmarks',
+ 'pallet-evm-coder-substrate/runtime-benchmarks',
+ 'pallet-balances/runtime-benchmarks',
+ 'pallet-timestamp/runtime-benchmarks',
+ 'pallet-common/runtime-benchmarks',
+ 'pallet-fungible/runtime-benchmarks',
+ 'pallet-refungible/runtime-benchmarks',
+ 'pallet-nonfungible/runtime-benchmarks',
+ 'pallet-unique/runtime-benchmarks',
+ 'pallet-inflation/runtime-benchmarks',
+ 'pallet-xcm/runtime-benchmarks',
+ 'sp-runtime/runtime-benchmarks',
+ 'xcm-builder/runtime-benchmarks',
+]
+std = [
+ 'codec/std',
+ 'cumulus-pallet-aura-ext/std',
+ 'cumulus-pallet-parachain-system/std',
+ 'cumulus-pallet-xcm/std',
+ 'cumulus-pallet-xcmp-queue/std',
+ 'cumulus-primitives-core/std',
+ 'cumulus-primitives-utility/std',
+ 'frame-executive/std',
+ 'frame-support/std',
+ 'frame-system/std',
+ 'frame-system-rpc-runtime-api/std',
+ 'pallet-aura/std',
+ 'pallet-balances/std',
+ # 'pallet-contracts/std',
+ # 'pallet-contracts-primitives/std',
+ # 'pallet-contracts-rpc-runtime-api/std',
+ # 'pallet-contract-helpers/std',
+ 'pallet-randomness-collective-flip/std',
+ 'pallet-sudo/std',
+ 'pallet-timestamp/std',
+ 'pallet-transaction-payment/std',
+ 'pallet-transaction-payment-rpc-runtime-api/std',
+ 'pallet-treasury/std',
+ # 'pallet-vesting/std',
+ 'pallet-evm/std',
+ 'pallet-evm-migration/std',
+ 'pallet-evm-contract-helpers/std',
+ 'pallet-evm-transaction-payment/std',
+ 'pallet-evm-coder-substrate/std',
+ 'pallet-ethereum/std',
+ 'pallet-base-fee/std',
+ 'fp-rpc/std',
+ 'up-rpc/std',
+ 'up-evm-mapping/std',
+ 'fp-self-contained/std',
+ 'parachain-info/std',
+ 'serde',
+ 'pallet-inflation/std',
+ 'pallet-common/std',
+ 'pallet-fungible/std',
+ 'pallet-refungible/std',
+ 'pallet-nonfungible/std',
+ 'pallet-unique/std',
+ 'pallet-unq-scheduler/std',
+ 'pallet-charge-transaction/std',
+ 'up-data-structs/std',
+ 'sp-api/std',
+ 'sp-block-builder/std',
+ "sp-consensus-aura/std",
+ 'sp-core/std',
+ 'sp-inherents/std',
+ 'sp-io/std',
+ 'sp-offchain/std',
+ 'sp-runtime/std',
+ 'sp-session/std',
+ 'sp-std/std',
+ 'sp-transaction-pool/std',
+ 'sp-version/std',
+ 'xcm/std',
+ 'xcm-builder/std',
+ 'xcm-executor/std',
+ 'unique-runtime-common/std',
+
+ "orml-vesting/std",
+]
+limit-testing = ['pallet-unique/limit-testing', 'up-data-structs/limit-testing']
+
+################################################################################
+# Substrate Dependencies
+
+[dependencies.codec]
+default-features = false
+features = ['derive']
+package = 'parity-scale-codec'
+version = '2.3.0'
+
+[dependencies.frame-benchmarking]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+optional = true
+branch = 'polkadot-v0.9.17'
+
+[dependencies.frame-executive]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'polkadot-v0.9.17'
+
+[dependencies.frame-support]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'polkadot-v0.9.17'
+
+[dependencies.frame-system]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'polkadot-v0.9.17'
+
+[dependencies.frame-system-benchmarking]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+optional = true
+branch = 'polkadot-v0.9.17'
+
+[dependencies.frame-system-rpc-runtime-api]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'polkadot-v0.9.17'
+
+[dependencies.hex-literal]
+optional = true
+version = '0.3.3'
+
+[dependencies.serde]
+default-features = false
+features = ['derive']
+optional = true
+version = '1.0.130'
+
+[dependencies.pallet-aura]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'polkadot-v0.9.17'
+
+[dependencies.pallet-balances]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'polkadot-v0.9.17'
+
+# Contracts specific packages
+# [dependencies.pallet-contracts]
+# git = 'https://github.com/paritytech/substrate.git'
+# default-features = false
+# branch = 'polkadot-v0.9.17'
+# version = '4.0.0-dev'
+
+# [dependencies.pallet-contracts-primitives]
+# git = 'https://github.com/paritytech/substrate.git'
+# default-features = false
+# branch = 'polkadot-v0.9.17'
+# version = '4.0.0-dev'
+
+# [dependencies.pallet-contracts-rpc-runtime-api]
+# git = 'https://github.com/paritytech/substrate.git'
+# default-features = false
+# branch = 'polkadot-v0.9.17'
+# version = '4.0.0-dev'
+
+[dependencies.pallet-randomness-collective-flip]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'polkadot-v0.9.17'
+
+[dependencies.pallet-sudo]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'polkadot-v0.9.17'
+
+[dependencies.pallet-timestamp]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'polkadot-v0.9.17'
+
+[dependencies.pallet-transaction-payment]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'polkadot-v0.9.17'
+
+[dependencies.pallet-transaction-payment-rpc-runtime-api]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'polkadot-v0.9.17'
+
+[dependencies.pallet-treasury]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'polkadot-v0.9.17'
+
+# [dependencies.pallet-vesting]
+# default-features = false
+# git = 'https://github.com/paritytech/substrate.git'
+# branch = 'polkadot-v0.9.17'
+
+[dependencies.sp-arithmetic]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'polkadot-v0.9.17'
+
+[dependencies.sp-api]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'polkadot-v0.9.17'
+
+[dependencies.sp-block-builder]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'polkadot-v0.9.17'
+
+[dependencies.sp-core]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'polkadot-v0.9.17'
+
+[dependencies.sp-consensus-aura]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'polkadot-v0.9.17'
+
+[dependencies.sp-inherents]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'polkadot-v0.9.17'
+
+[dependencies.sp-io]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'polkadot-v0.9.17'
+
+[dependencies.sp-offchain]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'polkadot-v0.9.17'
+
+[dependencies.sp-runtime]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'polkadot-v0.9.17'
+
+[dependencies.sp-session]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'polkadot-v0.9.17'
+
+[dependencies.sp-std]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'polkadot-v0.9.17'
+
+[dependencies.sp-transaction-pool]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'polkadot-v0.9.17'
+
+[dependencies.sp-version]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'polkadot-v0.9.17'
+
+[dependencies.smallvec]
+version = '1.6.1'
+
+################################################################################
+# Cumulus dependencies
+
+[dependencies.parachain-info]
+default-features = false
+git = 'https://github.com/uniqueNetwork/cumulus.git'
+branch = 'polkadot-v0.9.17'
+
+[dependencies.cumulus-pallet-aura-ext]
+git = 'https://github.com/uniqueNetwork/cumulus.git'
+branch = 'polkadot-v0.9.17'
+default-features = false
+
+[dependencies.cumulus-pallet-parachain-system]
+git = 'https://github.com/uniqueNetwork/cumulus.git'
+branch = 'polkadot-v0.9.17'
+default-features = false
+
+[dependencies.cumulus-primitives-core]
+git = 'https://github.com/uniqueNetwork/cumulus.git'
+branch = 'polkadot-v0.9.17'
+default-features = false
+
+[dependencies.cumulus-pallet-xcm]
+git = 'https://github.com/uniqueNetwork/cumulus.git'
+branch = 'polkadot-v0.9.17'
+default-features = false
+
+[dependencies.cumulus-pallet-dmp-queue]
+git = 'https://github.com/uniqueNetwork/cumulus.git'
+branch = 'polkadot-v0.9.17'
+default-features = false
+
+[dependencies.cumulus-pallet-xcmp-queue]
+git = 'https://github.com/uniqueNetwork/cumulus.git'
+branch = 'polkadot-v0.9.17'
+default-features = false
+
+[dependencies.cumulus-primitives-utility]
+git = 'https://github.com/uniqueNetwork/cumulus.git'
+branch = 'polkadot-v0.9.17'
+default-features = false
+
+[dependencies.cumulus-primitives-timestamp]
+git = 'https://github.com/uniqueNetwork/cumulus.git'
+branch = 'polkadot-v0.9.17'
+default-features = false
+
+################################################################################
+# Polkadot dependencies
+
+[dependencies.polkadot-parachain]
+git = 'https://github.com/paritytech/polkadot'
+branch = 'release-v0.9.17'
+default-features = false
+
+[dependencies.xcm]
+git = 'https://github.com/paritytech/polkadot'
+branch = 'release-v0.9.17'
+default-features = false
+
+[dependencies.xcm-builder]
+git = 'https://github.com/paritytech/polkadot'
+branch = 'release-v0.9.17'
+default-features = false
+
+[dependencies.xcm-executor]
+git = 'https://github.com/paritytech/polkadot'
+branch = 'release-v0.9.17'
+default-features = false
+
+[dependencies.pallet-xcm]
+git = 'https://github.com/paritytech/polkadot'
+branch = 'release-v0.9.17'
+default-features = false
+
+[dependencies.orml-vesting]
+git = 'https://github.com/UniqueNetwork/open-runtime-module-library'
+branch = 'unique-polkadot-v0.9.17'
+version = "0.4.1-dev"
+default-features = false
+
+################################################################################
+# local dependencies
+
+[dependencies]
+unique-runtime-common = { path = "../common", default-features = false }
+scale-info = { version = "1.0.0", default-features = false, features = [
+ "derive",
+] }
+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 }
+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" }
+pallet-fungible = { default-features = false, path = "../../pallets/fungible" }
+pallet-refungible = { default-features = false, path = "../../pallets/refungible" }
+pallet-nonfungible = { default-features = false, path = "../../pallets/nonfungible" }
+pallet-unq-scheduler = { path = '../../pallets/scheduler', default-features = false }
+# pallet-contract-helpers = { path = '../pallets/contract-helpers', default-features = false, version = '0.1.0' }
+pallet-charge-transaction = { git = "https://github.com/UniqueNetwork/pallet-sponsoring", branch = 'polkadot-v0.9.17', package = "pallet-template-transaction-payment", default-features = false, version = '3.0.0' }
+pallet-evm-migration = { path = '../../pallets/evm-migration', default-features = false }
+pallet-evm-contract-helpers = { path = '../../pallets/evm-contract-helpers', default-features = false }
+pallet-evm-transaction-payment = { path = '../../pallets/evm-transaction-payment', default-features = false }
+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.17" }
+pallet-ethereum = { default-features = false, git = "https://github.com/uniquenetwork/frontier.git", branch = "unique-polkadot-v0.9.17" }
+pallet-base-fee = { default-features = false, git = "https://github.com/uniquenetwork/frontier.git", branch = "unique-polkadot-v0.9.17" }
+fp-rpc = { default-features = false, git = "https://github.com/uniquenetwork/frontier.git", branch = "unique-polkadot-v0.9.17" }
+fp-self-contained = { default-features = false, git = "https://github.com/uniquenetwork/frontier.git", branch = "unique-polkadot-v0.9.17" }
+
+################################################################################
+# Build Dependencies
+
+[build-dependencies.substrate-wasm-builder]
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'polkadot-v0.9.17'
runtime/opal/build.rsdiffbeforeafterboth--- /dev/null
+++ b/runtime/opal/build.rs
@@ -0,0 +1,25 @@
+// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.
+// This file is part of Unique Network.
+
+// Unique Network is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+// Unique Network is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
+
+use substrate_wasm_builder::WasmBuilder;
+
+fn main() {
+ WasmBuilder::new()
+ .with_current_project()
+ .import_memory()
+ .export_heap_base()
+ .build()
+}
runtime/opal/src/lib.rsdiffbeforeafterboth--- /dev/null
+++ b/runtime/opal/src/lib.rs
@@ -0,0 +1,1141 @@
+// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.
+// This file is part of Unique Network.
+
+// Unique Network is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+// Unique Network is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
+
+//! The Substrate Node Template runtime. This can be compiled with `#[no_std]`, ready for Wasm.
+
+#![cfg_attr(not(feature = "std"), no_std)]
+// `construct_runtime!` does a lot of recursion and requires us to increase the limit to 256.
+#![recursion_limit = "1024"]
+#![allow(clippy::from_over_into, clippy::identity_op)]
+#![allow(clippy::fn_to_numeric_cast_with_truncation)]
+// Make the WASM binary available.
+#[cfg(feature = "std")]
+include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
+
+use sp_api::impl_runtime_apis;
+use sp_core::{crypto::KeyTypeId, OpaqueMetadata, H256, U256, H160};
+use sp_runtime::DispatchError;
+// #[cfg(any(feature = "std", test))]
+// pub use sp_runtime::BuildStorage;
+
+use sp_runtime::{
+ Permill, Perbill, Percent, create_runtime_str, generic, impl_opaque_keys,
+ traits::{AccountIdLookup, BlakeTwo256, Block as BlockT, AccountIdConversion, Zero},
+ transaction_validity::{TransactionSource, TransactionValidity},
+ ApplyExtrinsicResult, RuntimeAppPublic,
+};
+
+use sp_std::prelude::*;
+
+#[cfg(feature = "std")]
+use sp_version::NativeVersion;
+use sp_version::RuntimeVersion;
+pub use pallet_transaction_payment::{
+ Multiplier, TargetedFeeAdjustment, FeeDetails, RuntimeDispatchInfo,
+};
+// A few exports that help ease life for downstream crates.
+pub use pallet_balances::Call as BalancesCall;
+pub use pallet_evm::{EnsureAddressTruncated, HashedAddressMapping, Runner};
+pub use frame_support::{
+ construct_runtime, match_type,
+ dispatch::DispatchResult,
+ PalletId, parameter_types, StorageValue, ConsensusEngineId,
+ traits::{
+ tokens::currency::Currency as CurrencyT, OnUnbalanced as OnUnbalancedT, Everything,
+ Currency, ExistenceRequirement, Get, IsInVec, KeyOwnerProofSystem, LockIdentifier,
+ OnUnbalanced, Randomness, FindAuthor,
+ },
+ weights::{
+ constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND},
+ DispatchClass, DispatchInfo, GetDispatchInfo, IdentityFee, Pays, PostDispatchInfo, Weight,
+ WeightToFeePolynomial, WeightToFeeCoefficient, WeightToFeeCoefficients,
+ },
+};
+use up_data_structs::*;
+// use pallet_contracts::weights::WeightInfo;
+// #[cfg(any(feature = "std", test))]
+use frame_system::{
+ self as frame_system, EnsureRoot, EnsureSigned,
+ limits::{BlockWeights, BlockLength},
+};
+use sp_arithmetic::{
+ traits::{BaseArithmetic, Unsigned},
+};
+use smallvec::smallvec;
+use codec::{Encode, Decode};
+use pallet_evm::{Account as EVMAccount, FeeCalculator, GasWeightMapping, OnMethodCall};
+use fp_rpc::TransactionStatus;
+use sp_runtime::{
+ traits::{BlockNumberProvider, Dispatchable, PostDispatchInfoOf, Saturating},
+ transaction_validity::TransactionValidityError,
+ SaturatedConversion,
+};
+
+// pub use pallet_timestamp::Call as TimestampCall;
+pub use sp_consensus_aura::sr25519::AuthorityId as AuraId;
+
+// Polkadot imports
+use pallet_xcm::XcmPassthrough;
+use polkadot_parachain::primitives::Sibling;
+use xcm::v1::{BodyId, Junction::*, MultiLocation, NetworkId, Junctions::*};
+use xcm_builder::{
+ AccountId32Aliases, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, CurrencyAdapter,
+ EnsureXcmOrigin, FixedWeightBounds, LocationInverter, NativeAsset, ParentAsSuperuser,
+ RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia,
+ SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit,
+ ParentIsPreset,
+};
+use xcm_executor::{Config, XcmExecutor, Assets};
+use sp_std::{marker::PhantomData};
+
+use xcm::latest::{
+ // Xcm,
+ AssetId::{Concrete},
+ Fungibility::Fungible as XcmFungible,
+ MultiAsset,
+ Error as XcmError,
+};
+use xcm_executor::traits::{MatchesFungible, WeightTrader};
+//use xcm_executor::traits::MatchesFungible;
+use sp_runtime::traits::CheckedConversion;
+
+use unique_runtime_common::{impl_common_runtime_apis, types::*, constants::*};
+
+pub const RUNTIME_NAME: &str = "Opal";
+
+type CrossAccountId = pallet_common::account::BasicCrossAccountId<Runtime>;
+
+impl RuntimeInstance for Runtime {
+ type CrossAccountId = self::CrossAccountId;
+
+ type TransactionConverter = self::TransactionConverter;
+
+ fn get_transaction_converter() -> TransactionConverter {
+ TransactionConverter
+ }
+}
+
+/// Opaque types. These are used by the CLI to instantiate machinery that don't need to know
+/// the specifics of the runtime. They can then be made to be agnostic over specific formats
+/// of data like extrinsics, allowing for them to continue syncing the network through upgrades
+/// to even the core data structures.
+pub mod opaque {
+ use sp_std::prelude::*;
+ use sp_runtime::impl_opaque_keys;
+ use super::Aura;
+
+ pub use unique_runtime_common::types::*;
+
+ impl_opaque_keys! {
+ pub struct SessionKeys {
+ pub aura: Aura,
+ }
+ }
+}
+
+/// This runtime version.
+pub const VERSION: RuntimeVersion = RuntimeVersion {
+ spec_name: create_runtime_str!(RUNTIME_NAME),
+ impl_name: create_runtime_str!(RUNTIME_NAME),
+ authoring_version: 1,
+ spec_version: 917004,
+ impl_version: 0,
+ apis: RUNTIME_API_VERSIONS,
+ transaction_version: 1,
+ state_version: 0,
+};
+
+#[derive(codec::Encode, codec::Decode)]
+pub enum XCMPMessage<XAccountId, XBalance> {
+ /// Transfer tokens to the given account from the Parachain account.
+ TransferToken(XAccountId, XBalance),
+}
+
+/// The version information used to identify this runtime when compiled natively.
+#[cfg(feature = "std")]
+pub fn native_version() -> NativeVersion {
+ NativeVersion {
+ runtime_version: VERSION,
+ can_author_with: Default::default(),
+ }
+}
+
+type NegativeImbalance = <Balances as Currency<AccountId>>::NegativeImbalance;
+
+pub struct DealWithFees;
+impl OnUnbalanced<NegativeImbalance> for DealWithFees {
+ fn on_unbalanceds<B>(mut fees_then_tips: impl Iterator<Item = NegativeImbalance>) {
+ if let Some(fees) = fees_then_tips.next() {
+ // for fees, 100% to treasury
+ let mut split = fees.ration(100, 0);
+ if let Some(tips) = fees_then_tips.next() {
+ // for tips, if any, 100% to treasury
+ tips.ration_merge_into(100, 0, &mut split);
+ }
+ Treasury::on_unbalanced(split.0);
+ // Author::on_unbalanced(split.1);
+ }
+ }
+}
+
+parameter_types! {
+ pub const BlockHashCount: BlockNumber = 2400;
+ pub RuntimeBlockLength: BlockLength =
+ BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);
+ pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);
+ pub const MaximumBlockLength: u32 = 5 * 1024 * 1024;
+ pub RuntimeBlockWeights: BlockWeights = BlockWeights::builder()
+ .base_block(BlockExecutionWeight::get())
+ .for_class(DispatchClass::all(), |weights| {
+ weights.base_extrinsic = ExtrinsicBaseWeight::get();
+ })
+ .for_class(DispatchClass::Normal, |weights| {
+ weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT);
+ })
+ .for_class(DispatchClass::Operational, |weights| {
+ weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT);
+ // Operational transactions have some extra reserved space, so that they
+ // are included even if block reached `MAXIMUM_BLOCK_WEIGHT`.
+ weights.reserved = Some(
+ MAXIMUM_BLOCK_WEIGHT - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT
+ );
+ })
+ .avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO)
+ .build_or_panic();
+ pub const Version: RuntimeVersion = VERSION;
+ pub const SS58Prefix: u8 = 42;
+}
+
+parameter_types! {
+ pub const ChainId: u64 = 8882;
+}
+
+pub struct FixedFee;
+impl FeeCalculator for FixedFee {
+ fn min_gas_price() -> U256 {
+ MIN_GAS_PRICE.into()
+ }
+}
+
+// Assuming slowest ethereum opcode is SSTORE, with gas price of 20000 as our worst case
+// (contract, which only writes a lot of data),
+// approximating on top of our real store write weight
+parameter_types! {
+ pub const WritesPerSecond: u64 = WEIGHT_PER_SECOND / <Runtime as frame_system::Config>::DbWeight::get().write;
+ pub const GasPerSecond: u64 = WritesPerSecond::get() * 20000;
+ pub const WeightPerGas: u64 = WEIGHT_PER_SECOND / GasPerSecond::get();
+}
+
+/// Limiting EVM execution to 50% of block for substrate users and management tasks
+/// EVM transaction consumes more weight than substrate's, so we can't rely on them being
+/// scheduled fairly
+const EVM_DISPATCH_RATIO: Perbill = Perbill::from_percent(50);
+parameter_types! {
+ pub BlockGasLimit: U256 = U256::from(NORMAL_DISPATCH_RATIO * EVM_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT / WeightPerGas::get());
+}
+
+pub enum FixedGasWeightMapping {}
+impl GasWeightMapping for FixedGasWeightMapping {
+ fn gas_to_weight(gas: u64) -> Weight {
+ gas.saturating_mul(WeightPerGas::get())
+ }
+ fn weight_to_gas(weight: Weight) -> u64 {
+ weight / WeightPerGas::get()
+ }
+}
+
+impl pallet_evm::Config for Runtime {
+ type BlockGasLimit = BlockGasLimit;
+ type FeeCalculator = FixedFee;
+ type GasWeightMapping = FixedGasWeightMapping;
+ type BlockHashMapping = pallet_ethereum::EthereumBlockHashMapping<Self>;
+ type CallOrigin = EnsureAddressTruncated;
+ type WithdrawOrigin = EnsureAddressTruncated;
+ type AddressMapping = HashedAddressMapping<Self::Hashing>;
+ type PrecompilesType = ();
+ type PrecompilesValue = ();
+ type Currency = Balances;
+ type Event = Event;
+ type OnMethodCall = (
+ pallet_evm_migration::OnMethodCall<Self>,
+ pallet_unique::UniqueErcSupport<Self>,
+ pallet_evm_contract_helpers::HelpersOnMethodCall<Self>,
+ );
+ type OnCreate = pallet_evm_contract_helpers::HelpersOnCreate<Self>;
+ type ChainId = ChainId;
+ type Runner = pallet_evm::runner::stack::Runner<Self>;
+ type OnChargeTransaction = pallet_evm_transaction_payment::OnChargeTransaction<Self>;
+ type TransactionValidityHack = pallet_evm_transaction_payment::TransactionValidityHack<Self>;
+ type FindAuthor = EthereumFindAuthor<Aura>;
+}
+
+impl pallet_evm_migration::Config for Runtime {
+ type WeightInfo = pallet_evm_migration::weights::SubstrateWeight<Self>;
+}
+
+pub struct EthereumFindAuthor<F>(core::marker::PhantomData<F>);
+impl<F: FindAuthor<u32>> FindAuthor<H160> for EthereumFindAuthor<F> {
+ fn find_author<'a, I>(digests: I) -> Option<H160>
+ where
+ I: 'a + IntoIterator<Item = (ConsensusEngineId, &'a [u8])>,
+ {
+ if let Some(author_index) = F::find_author(digests) {
+ let authority_id = Aura::authorities()[author_index as usize].clone();
+ return Some(H160::from_slice(&authority_id.to_raw_vec()[4..24]));
+ }
+ None
+ }
+}
+
+impl pallet_ethereum::Config for Runtime {
+ type Event = Event;
+ type StateRoot = pallet_ethereum::IntermediateStateRoot;
+}
+
+impl pallet_randomness_collective_flip::Config for Runtime {}
+
+impl frame_system::Config for Runtime {
+ /// The data to be stored in an account.
+ type AccountData = pallet_balances::AccountData<Balance>;
+ /// The identifier used to distinguish between accounts.
+ type AccountId = AccountId;
+ /// The basic call filter to use in dispatchable.
+ type BaseCallFilter = Everything;
+ /// Maximum number of block number to block hash mappings to keep (oldest pruned first).
+ type BlockHashCount = BlockHashCount;
+ /// The maximum length of a block (in bytes).
+ type BlockLength = RuntimeBlockLength;
+ /// The index type for blocks.
+ type BlockNumber = BlockNumber;
+ /// The weight of the overhead invoked on the block import process, independent of the extrinsics included in that block.
+ type BlockWeights = RuntimeBlockWeights;
+ /// The aggregated dispatch type that is available for extrinsics.
+ type Call = Call;
+ /// The weight of database operations that the runtime can invoke.
+ type DbWeight = RocksDbWeight;
+ /// The ubiquitous event type.
+ type Event = Event;
+ /// The type for hashing blocks and tries.
+ type Hash = Hash;
+ /// The hashing algorithm used.
+ type Hashing = BlakeTwo256;
+ /// The header type.
+ type Header = generic::Header<BlockNumber, BlakeTwo256>;
+ /// The index type for storing how many extrinsics an account has signed.
+ type Index = Index;
+ /// The lookup mechanism to get account ID from whatever is passed in dispatchers.
+ type Lookup = AccountIdLookup<AccountId, ()>;
+ /// What to do if an account is fully reaped from the system.
+ type OnKilledAccount = ();
+ /// What to do if a new account is created.
+ type OnNewAccount = ();
+ type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode<Self>;
+ /// The ubiquitous origin type.
+ type Origin = Origin;
+ /// This type is being generated by `construct_runtime!`.
+ type PalletInfo = PalletInfo;
+ /// This is used as an identifier of the chain. 42 is the generic substrate prefix.
+ type SS58Prefix = SS58Prefix;
+ /// Weight information for the extrinsics of this pallet.
+ type SystemWeightInfo = frame_system::weights::SubstrateWeight<Self>;
+ /// Version of the runtime.
+ type Version = Version;
+ type MaxConsumers = ConstU32<16>;
+}
+
+parameter_types! {
+ pub const MinimumPeriod: u64 = SLOT_DURATION / 2;
+}
+
+impl pallet_timestamp::Config for Runtime {
+ /// A timestamp: milliseconds since the unix epoch.
+ type Moment = u64;
+ type OnTimestampSet = ();
+ type MinimumPeriod = MinimumPeriod;
+ type WeightInfo = ();
+}
+
+parameter_types! {
+ // pub const ExistentialDeposit: u128 = 500;
+ pub const ExistentialDeposit: u128 = 0;
+ pub const MaxLocks: u32 = 50;
+}
+
+impl pallet_balances::Config for Runtime {
+ type MaxLocks = MaxLocks;
+ type MaxReserves = ();
+ type ReserveIdentifier = [u8; 8];
+ /// The type for recording an account's balance.
+ type Balance = Balance;
+ /// The ubiquitous event type.
+ type Event = Event;
+ type DustRemoval = Treasury;
+ type ExistentialDeposit = ExistentialDeposit;
+ type AccountStore = System;
+ type WeightInfo = pallet_balances::weights::SubstrateWeight<Self>;
+}
+
+pub const fn deposit(items: u32, bytes: u32) -> Balance {
+ items as Balance * 15 * CENTIUNIQUE + (bytes as Balance) * 6 * CENTIUNIQUE
+}
+
+/*
+parameter_types! {
+ pub TombstoneDeposit: Balance = deposit(
+ 1,
+ sp_std::mem::size_of::<pallet_contracts::Pallet<Runtime>> as u32,
+ );
+ pub DepositPerContract: Balance = TombstoneDeposit::get();
+ pub const DepositPerStorageByte: Balance = deposit(0, 1);
+ pub const DepositPerStorageItem: Balance = deposit(1, 0);
+ pub RentFraction: Perbill = Perbill::from_rational(1u32, 30 * DAYS);
+ pub const SurchargeReward: Balance = 150 * MILLIUNIQUE;
+ pub const SignedClaimHandicap: u32 = 2;
+ pub const MaxDepth: u32 = 32;
+ pub const MaxValueSize: u32 = 16 * 1024;
+ pub const MaxCodeSize: u32 = 1024 * 1024 * 25; // 25 Mb
+ // The lazy deletion runs inside on_initialize.
+ pub DeletionWeightLimit: Weight = AVERAGE_ON_INITIALIZE_RATIO *
+ RuntimeBlockWeights::get().max_block;
+ // The weight needed for decoding the queue should be less or equal than a fifth
+ // of the overall weight dedicated to the lazy deletion.
+ pub DeletionQueueDepth: u32 = ((DeletionWeightLimit::get() / (
+ <Runtime as pallet_contracts::Config>::WeightInfo::on_initialize_per_queue_item(1) -
+ <Runtime as pallet_contracts::Config>::WeightInfo::on_initialize_per_queue_item(0)
+ )) / 5) as u32;
+ pub Schedule: pallet_contracts::Schedule<Runtime> = Default::default();
+}
+
+impl pallet_contracts::Config for Runtime {
+ type Time = Timestamp;
+ type Randomness = RandomnessCollectiveFlip;
+ type Currency = Balances;
+ type Event = Event;
+ type RentPayment = ();
+ type SignedClaimHandicap = SignedClaimHandicap;
+ type TombstoneDeposit = TombstoneDeposit;
+ type DepositPerContract = DepositPerContract;
+ type DepositPerStorageByte = DepositPerStorageByte;
+ type DepositPerStorageItem = DepositPerStorageItem;
+ type RentFraction = RentFraction;
+ type SurchargeReward = SurchargeReward;
+ type WeightPrice = pallet_transaction_payment::Pallet<Self>;
+ type WeightInfo = pallet_contracts::weights::SubstrateWeight<Self>;
+ type ChainExtension = NFTExtension;
+ type DeletionQueueDepth = DeletionQueueDepth;
+ type DeletionWeightLimit = DeletionWeightLimit;
+ type Schedule = Schedule;
+ type CallStack = [pallet_contracts::Frame<Self>; 31];
+}
+*/
+
+parameter_types! {
+ /// This value increases the priority of `Operational` transactions by adding
+ /// a "virtual tip" that's equal to the `OperationalFeeMultiplier * final_fee`.
+ pub const OperationalFeeMultiplier: u8 = 5;
+}
+
+/// Linear implementor of `WeightToFeePolynomial`
+pub struct LinearFee<T>(sp_std::marker::PhantomData<T>);
+
+impl<T> WeightToFeePolynomial for LinearFee<T>
+where
+ T: BaseArithmetic + From<u32> + Copy + Unsigned,
+{
+ type Balance = T;
+
+ fn polynomial() -> WeightToFeeCoefficients<Self::Balance> {
+ smallvec!(WeightToFeeCoefficient {
+ // Targeting 0.1 Unique per NFT transfer
+ coeff_integer: WEIGHT_TO_FEE_COEFF.into(),
+ coeff_frac: Perbill::zero(),
+ negative: false,
+ degree: 1,
+ })
+ }
+}
+
+impl pallet_transaction_payment::Config for Runtime {
+ type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter<Balances, DealWithFees>;
+ type TransactionByteFee = TransactionByteFee;
+ type OperationalFeeMultiplier = OperationalFeeMultiplier;
+ type WeightToFee = LinearFee<Balance>;
+ type FeeMultiplierUpdate = ();
+}
+
+parameter_types! {
+ pub const ProposalBond: Permill = Permill::from_percent(5);
+ pub const ProposalBondMinimum: Balance = 1 * UNIQUE;
+ pub const ProposalBondMaximum: Balance = 1000 * UNIQUE;
+ pub const SpendPeriod: BlockNumber = 5 * MINUTES;
+ pub const Burn: Permill = Permill::from_percent(0);
+ pub const TipCountdown: BlockNumber = 1 * DAYS;
+ pub const TipFindersFee: Percent = Percent::from_percent(20);
+ pub const TipReportDepositBase: Balance = 1 * UNIQUE;
+ pub const DataDepositPerByte: Balance = 1 * CENTIUNIQUE;
+ pub const BountyDepositBase: Balance = 1 * UNIQUE;
+ pub const BountyDepositPayoutDelay: BlockNumber = 1 * DAYS;
+ pub const TreasuryModuleId: PalletId = PalletId(*b"py/trsry");
+ pub const BountyUpdatePeriod: BlockNumber = 14 * DAYS;
+ pub const MaximumReasonLength: u32 = 16384;
+ pub const BountyCuratorDeposit: Permill = Permill::from_percent(50);
+ pub const BountyValueMinimum: Balance = 5 * UNIQUE;
+ pub const MaxApprovals: u32 = 100;
+}
+
+impl pallet_treasury::Config for Runtime {
+ type PalletId = TreasuryModuleId;
+ type Currency = Balances;
+ type ApproveOrigin = EnsureRoot<AccountId>;
+ type RejectOrigin = EnsureRoot<AccountId>;
+ type Event = Event;
+ type OnSlash = ();
+ type ProposalBond = ProposalBond;
+ type ProposalBondMinimum = ProposalBondMinimum;
+ type ProposalBondMaximum = ProposalBondMaximum;
+ type SpendPeriod = SpendPeriod;
+ type Burn = Burn;
+ type BurnDestination = ();
+ type SpendFunds = ();
+ type WeightInfo = pallet_treasury::weights::SubstrateWeight<Self>;
+ type MaxApprovals = MaxApprovals;
+}
+
+impl pallet_sudo::Config for Runtime {
+ type Event = Event;
+ type Call = Call;
+}
+
+pub struct RelayChainBlockNumberProvider<T>(sp_std::marker::PhantomData<T>);
+
+impl<T: cumulus_pallet_parachain_system::Config> BlockNumberProvider
+ for RelayChainBlockNumberProvider<T>
+{
+ type BlockNumber = BlockNumber;
+
+ fn current_block_number() -> Self::BlockNumber {
+ cumulus_pallet_parachain_system::Pallet::<T>::validation_data()
+ .map(|d| d.relay_parent_number)
+ .unwrap_or_default()
+ }
+}
+
+parameter_types! {
+ pub const MinVestedTransfer: Balance = 10 * UNIQUE;
+ pub const MaxVestingSchedules: u32 = 28;
+}
+
+impl orml_vesting::Config for Runtime {
+ type Event = Event;
+ type Currency = pallet_balances::Pallet<Runtime>;
+ type MinVestedTransfer = MinVestedTransfer;
+ type VestedTransferOrigin = EnsureSigned<AccountId>;
+ type WeightInfo = ();
+ type MaxVestingSchedules = MaxVestingSchedules;
+ type BlockNumberProvider = RelayChainBlockNumberProvider<Runtime>;
+}
+
+parameter_types! {
+ pub const ReservedDmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;
+ pub const ReservedXcmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;
+}
+
+impl cumulus_pallet_parachain_system::Config for Runtime {
+ type Event = Event;
+ type SelfParaId = parachain_info::Pallet<Self>;
+ type OnSystemEvent = ();
+ // type DownwardMessageHandlers = cumulus_primitives_utility::UnqueuedDmpAsParent<
+ // MaxDownwardMessageWeight,
+ // XcmExecutor<XcmConfig>,
+ // Call,
+ // >;
+ type OutboundXcmpMessageSource = XcmpQueue;
+ type DmpMessageHandler = DmpQueue;
+ type ReservedDmpWeight = ReservedDmpWeight;
+ type ReservedXcmpWeight = ReservedXcmpWeight;
+ type XcmpMessageHandler = XcmpQueue;
+}
+
+impl parachain_info::Config for Runtime {}
+
+impl cumulus_pallet_aura_ext::Config for Runtime {}
+
+parameter_types! {
+ pub const RelayLocation: MultiLocation = MultiLocation::parent();
+ pub const RelayNetwork: NetworkId = NetworkId::Polkadot;
+ pub RelayOrigin: Origin = cumulus_pallet_xcm::Origin::Relay.into();
+ pub Ancestry: MultiLocation = Parachain(ParachainInfo::parachain_id().into()).into();
+}
+
+/// Type for specifying how a `MultiLocation` can be converted into an `AccountId`. This is used
+/// when determining ownership of accounts for asset transacting and when attempting to use XCM
+/// `Transact` in order to determine the dispatch Origin.
+pub type LocationToAccountId = (
+ // The parent (Relay-chain) origin converts to the default `AccountId`.
+ ParentIsPreset<AccountId>,
+ // Sibling parachain origins convert to AccountId via the `ParaId::into`.
+ SiblingParachainConvertsVia<Sibling, AccountId>,
+ // Straight up local `AccountId32` origins just alias directly to `AccountId`.
+ AccountId32Aliases<RelayNetwork, AccountId>,
+);
+
+pub struct OnlySelfCurrency;
+impl<B: TryFrom<u128>> MatchesFungible<B> for OnlySelfCurrency {
+ fn matches_fungible(a: &MultiAsset) -> Option<B> {
+ match (&a.id, &a.fun) {
+ (Concrete(_), XcmFungible(ref amount)) => CheckedConversion::checked_from(*amount),
+ _ => None,
+ }
+ }
+}
+
+/// Means for transacting assets on this chain.
+pub type LocalAssetTransactor = CurrencyAdapter<
+ // Use this currency:
+ Balances,
+ // Use this currency when it is a fungible asset matching the given location or name:
+ OnlySelfCurrency,
+ // Do a simple punn to convert an AccountId32 MultiLocation into a native chain account ID:
+ LocationToAccountId,
+ // Our chain's account ID type (we can't get away without mentioning it explicitly):
+ AccountId,
+ // We don't track any teleports.
+ (),
+>;
+
+/// This is the type we use to convert an (incoming) XCM origin into a local `Origin` instance,
+/// ready for dispatching a transaction with Xcm's `Transact`. There is an `OriginKind` which can
+/// biases the kind of local `Origin` it will become.
+pub type XcmOriginToTransactDispatchOrigin = (
+ // Sovereign account converter; this attempts to derive an `AccountId` from the origin location
+ // using `LocationToAccountId` and then turn that into the usual `Signed` origin. Useful for
+ // foreign chains who want to have a local sovereign account on this chain which they control.
+ SovereignSignedViaLocation<LocationToAccountId, Origin>,
+ // Native converter for Relay-chain (Parent) location; will converts to a `Relay` origin when
+ // recognised.
+ RelayChainAsNative<RelayOrigin, Origin>,
+ // Native converter for sibling Parachains; will convert to a `SiblingPara` origin when
+ // recognised.
+ SiblingParachainAsNative<cumulus_pallet_xcm::Origin, Origin>,
+ // Superuser converter for the Relay-chain (Parent) location. This will allow it to issue a
+ // transaction from the Root origin.
+ ParentAsSuperuser<Origin>,
+ // Native signed account converter; this just converts an `AccountId32` origin into a normal
+ // `Origin::Signed` origin of the same 32-byte value.
+ SignedAccountId32AsNative<RelayNetwork, Origin>,
+ // Xcm origins can be represented natively under the Xcm pallet's Xcm origin.
+ XcmPassthrough<Origin>,
+);
+
+parameter_types! {
+ // One XCM operation is 1_000_000 weight - almost certainly a conservative estimate.
+ pub UnitWeightCost: Weight = 1_000_000;
+ // 1200 UNIQUEs buy 1 second of weight.
+ pub const WeightPrice: (MultiLocation, u128) = (MultiLocation::parent(), 1_200 * UNIQUE);
+ pub const MaxInstructions: u32 = 100;
+ pub const MaxAuthorities: u32 = 100_000;
+}
+
+match_type! {
+ pub type ParentOrParentsUnitPlurality: impl Contains<MultiLocation> = {
+ MultiLocation { parents: 1, interior: Here } |
+ MultiLocation { parents: 1, interior: X1(Plurality { id: BodyId::Unit, .. }) }
+ };
+}
+
+pub type Barrier = (
+ TakeWeightCredit,
+ AllowTopLevelPaidExecutionFrom<Everything>,
+ AllowUnpaidExecutionFrom<ParentOrParentsUnitPlurality>,
+ // ^^^ Parent & its unit plurality gets free execution
+);
+
+pub struct UsingOnlySelfCurrencyComponents<
+ WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,
+ AssetId: Get<MultiLocation>,
+ AccountId,
+ Currency: CurrencyT<AccountId>,
+ OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,
+>(
+ Weight,
+ Currency::Balance,
+ PhantomData<(WeightToFee, AssetId, AccountId, Currency, OnUnbalanced)>,
+);
+impl<
+ WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,
+ AssetId: Get<MultiLocation>,
+ AccountId,
+ Currency: CurrencyT<AccountId>,
+ OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,
+ > WeightTrader
+ for UsingOnlySelfCurrencyComponents<WeightToFee, AssetId, AccountId, Currency, OnUnbalanced>
+{
+ fn new() -> Self {
+ Self(0, Zero::zero(), PhantomData)
+ }
+
+ fn buy_weight(&mut self, weight: Weight, payment: Assets) -> Result<Assets, XcmError> {
+ let amount = WeightToFee::calc(&weight);
+ let u128_amount: u128 = amount.try_into().map_err(|_| XcmError::Overflow)?;
+
+ // location to this parachain through relay chain
+ let option1: xcm::v1::AssetId = Concrete(MultiLocation {
+ parents: 1,
+ interior: X1(Parachain(ParachainInfo::parachain_id().into())),
+ });
+ // direct location
+ let option2: xcm::v1::AssetId = Concrete(MultiLocation {
+ parents: 0,
+ interior: Here,
+ });
+
+ let required = if payment.fungible.contains_key(&option1) {
+ (option1, u128_amount).into()
+ } else if payment.fungible.contains_key(&option2) {
+ (option2, u128_amount).into()
+ } else {
+ (Concrete(MultiLocation::default()), u128_amount).into()
+ };
+
+ let unused = payment
+ .checked_sub(required)
+ .map_err(|_| XcmError::TooExpensive)?;
+ self.0 = self.0.saturating_add(weight);
+ self.1 = self.1.saturating_add(amount);
+ Ok(unused)
+ }
+
+ fn refund_weight(&mut self, weight: Weight) -> Option<MultiAsset> {
+ let weight = weight.min(self.0);
+ let amount = WeightToFee::calc(&weight);
+ self.0 -= weight;
+ self.1 = self.1.saturating_sub(amount);
+ let amount: u128 = amount.saturated_into();
+ if amount > 0 {
+ Some((AssetId::get(), amount).into())
+ } else {
+ None
+ }
+ }
+}
+impl<
+ WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,
+ AssetId: Get<MultiLocation>,
+ AccountId,
+ Currency: CurrencyT<AccountId>,
+ OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,
+ > Drop
+ for UsingOnlySelfCurrencyComponents<WeightToFee, AssetId, AccountId, Currency, OnUnbalanced>
+{
+ fn drop(&mut self) {
+ OnUnbalanced::on_unbalanced(Currency::issue(self.1));
+ }
+}
+
+pub struct XcmConfig;
+impl Config for XcmConfig {
+ type Call = Call;
+ type XcmSender = XcmRouter;
+ // How to withdraw and deposit an asset.
+ type AssetTransactor = LocalAssetTransactor;
+ type OriginConverter = XcmOriginToTransactDispatchOrigin;
+ type IsReserve = NativeAsset;
+ type IsTeleporter = (); // Teleportation is disabled
+ type LocationInverter = LocationInverter<Ancestry>;
+ type Barrier = Barrier;
+ type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;
+ type Trader = UsingOnlySelfCurrencyComponents<
+ IdentityFee<Balance>,
+ RelayLocation,
+ AccountId,
+ Balances,
+ (),
+ >;
+ type ResponseHandler = (); // Don't handle responses for now.
+ type SubscriptionService = PolkadotXcm;
+
+ type AssetTrap = PolkadotXcm;
+ type AssetClaims = PolkadotXcm;
+}
+
+// parameter_types! {
+// pub const MaxDownwardMessageWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 10;
+// }
+
+/// No local origins on this chain are allowed to dispatch XCM sends/executions.
+pub type LocalOriginToLocation = (SignedToAccountId32<Origin, AccountId, RelayNetwork>,);
+
+/// The means for routing XCM messages which are not for local execution into the right message
+/// queues.
+pub type XcmRouter = (
+ // Two routers - use UMP to communicate with the relay chain:
+ cumulus_primitives_utility::ParentAsUmp<ParachainSystem, ()>,
+ // ..and XCMP to communicate with the sibling chains.
+ XcmpQueue,
+);
+
+impl pallet_evm_coder_substrate::Config for Runtime {
+ type EthereumTransactionSender = pallet_ethereum::Pallet<Self>;
+ type GasWeightMapping = FixedGasWeightMapping;
+}
+
+impl pallet_xcm::Config for Runtime {
+ type Event = Event;
+ type SendXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;
+ type XcmRouter = XcmRouter;
+ type ExecuteXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;
+ type XcmExecuteFilter = Everything;
+ type XcmExecutor = XcmExecutor<XcmConfig>;
+ type XcmTeleportFilter = Everything;
+ type XcmReserveTransferFilter = Everything;
+ type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;
+ type LocationInverter = LocationInverter<Ancestry>;
+ type Origin = Origin;
+ type Call = Call;
+ const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;
+ type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;
+}
+
+impl cumulus_pallet_xcm::Config for Runtime {
+ type Event = Event;
+ type XcmExecutor = XcmExecutor<XcmConfig>;
+}
+
+impl cumulus_pallet_xcmp_queue::Config for Runtime {
+ type Event = Event;
+ type XcmExecutor = XcmExecutor<XcmConfig>;
+ type ChannelInfo = ParachainSystem;
+ type VersionWrapper = ();
+ type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;
+ type ControllerOrigin = EnsureRoot<AccountId>;
+ type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin;
+}
+
+impl cumulus_pallet_dmp_queue::Config for Runtime {
+ type Event = Event;
+ type XcmExecutor = XcmExecutor<XcmConfig>;
+ type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;
+}
+
+impl pallet_aura::Config for Runtime {
+ type AuthorityId = AuraId;
+ type DisabledValidators = ();
+ type MaxAuthorities = MaxAuthorities;
+}
+
+parameter_types! {
+ pub TreasuryAccountId: AccountId = TreasuryModuleId::get().into_account();
+ pub const CollectionCreationPrice: Balance = 2 * UNIQUE;
+}
+
+impl pallet_common::Config for Runtime {
+ type Event = Event;
+ type EvmBackwardsAddressMapping = up_evm_mapping::MapBackwardsAddressTruncated;
+ type EvmAddressMapping = HashedAddressMapping<Self::Hashing>;
+ type CrossAccountId = pallet_common::account::BasicCrossAccountId<Self>;
+
+ type Currency = Balances;
+ type CollectionCreationPrice = CollectionCreationPrice;
+ type TreasuryAccountId = TreasuryAccountId;
+}
+
+impl pallet_fungible::Config for Runtime {
+ type WeightInfo = pallet_fungible::weights::SubstrateWeight<Self>;
+}
+impl pallet_refungible::Config for Runtime {
+ type WeightInfo = pallet_refungible::weights::SubstrateWeight<Self>;
+}
+impl pallet_nonfungible::Config for Runtime {
+ type WeightInfo = pallet_nonfungible::weights::SubstrateWeight<Self>;
+}
+
+impl pallet_unique::Config for Runtime {
+ type Event = Event;
+ type WeightInfo = pallet_unique::weights::SubstrateWeight<Self>;
+}
+
+parameter_types! {
+ pub const InflationBlockInterval: BlockNumber = 100; // every time per how many blocks inflation is applied
+}
+
+/// Used for the pallet inflation
+impl pallet_inflation::Config for Runtime {
+ type Currency = Balances;
+ type TreasuryAccountId = TreasuryAccountId;
+ type InflationBlockInterval = InflationBlockInterval;
+ type BlockNumberProvider = RelayChainBlockNumberProvider<Runtime>;
+}
+
+// parameter_types! {
+// pub MaximumSchedulerWeight: Weight = Perbill::from_percent(50) *
+// RuntimeBlockWeights::get().max_block;
+// pub const MaxScheduledPerBlock: u32 = 50;
+// }
+
+type EvmSponsorshipHandler = (
+ pallet_unique::UniqueEthSponsorshipHandler<Runtime>,
+ pallet_evm_contract_helpers::HelpersContractSponsoring<Runtime>,
+);
+type SponsorshipHandler = (
+ pallet_unique::UniqueSponsorshipHandler<Runtime>,
+ //pallet_contract_helpers::ContractSponsorshipHandler<Runtime>,
+ pallet_evm_transaction_payment::BridgeSponsorshipHandler<Runtime>,
+);
+
+// impl pallet_unq_scheduler::Config for Runtime {
+// type Event = Event;
+// type Origin = Origin;
+// type PalletsOrigin = OriginCaller;
+// type Call = Call;
+// type MaximumWeight = MaximumSchedulerWeight;
+// type ScheduleOrigin = EnsureSigned<AccountId>;
+// type MaxScheduledPerBlock = MaxScheduledPerBlock;
+// type SponsorshipHandler = SponsorshipHandler;
+// type WeightInfo = ();
+// }
+
+impl pallet_evm_transaction_payment::Config for Runtime {
+ type EvmSponsorshipHandler = EvmSponsorshipHandler;
+ type Currency = Balances;
+ type EvmAddressMapping = HashedAddressMapping<Self::Hashing>;
+ type EvmBackwardsAddressMapping = up_evm_mapping::MapBackwardsAddressTruncated;
+}
+
+impl pallet_charge_transaction::Config for Runtime {
+ type SponsorshipHandler = SponsorshipHandler;
+}
+
+// impl pallet_contract_helpers::Config for Runtime {
+// type DefaultSponsoringRateLimit = DefaultSponsoringRateLimit;
+// }
+
+parameter_types! {
+ // 0x842899ECF380553E8a4de75bF534cdf6fBF64049
+ pub const HelpersContractAddress: H160 = H160([
+ 0x84, 0x28, 0x99, 0xec, 0xf3, 0x80, 0x55, 0x3e, 0x8a, 0x4d, 0xe7, 0x5b, 0xf5, 0x34, 0xcd, 0xf6, 0xfb, 0xf6, 0x40, 0x49,
+ ]);
+}
+
+impl pallet_evm_contract_helpers::Config for Runtime {
+ type ContractAddress = HelpersContractAddress;
+ type DefaultSponsoringRateLimit = DefaultSponsoringRateLimit;
+}
+
+construct_runtime!(
+ pub enum Runtime where
+ Block = Block,
+ NodeBlock = opaque::Block,
+ UncheckedExtrinsic = UncheckedExtrinsic
+ {
+ ParachainSystem: cumulus_pallet_parachain_system::{Pallet, Call, Config, Storage, Inherent, Event<T>, ValidateUnsigned} = 20,
+ ParachainInfo: parachain_info::{Pallet, Storage, Config} = 21,
+
+ Aura: pallet_aura::{Pallet, Config<T>} = 22,
+ AuraExt: cumulus_pallet_aura_ext::{Pallet, Config} = 23,
+
+ Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>} = 30,
+ RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Pallet, Storage} = 31,
+ Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent} = 32,
+ TransactionPayment: pallet_transaction_payment::{Pallet, Storage} = 33,
+ Treasury: pallet_treasury::{Pallet, Call, Storage, Config, Event<T>} = 34,
+ Sudo: pallet_sudo::{Pallet, Call, Storage, Config<T>, Event<T>} = 35,
+ System: frame_system::{Pallet, Call, Storage, Config, Event<T>} = 36,
+ Vesting: orml_vesting::{Pallet, Storage, Call, Event<T>, Config<T>} = 37,
+ // Vesting: pallet_vesting::{Pallet, Call, Config<T>, Storage, Event<T>} = 37,
+ // Contracts: pallet_contracts::{Pallet, Call, Storage, Event<T>} = 38,
+
+ // XCM helpers.
+ XcmpQueue: cumulus_pallet_xcmp_queue::{Pallet, Call, Storage, Event<T>} = 50,
+ PolkadotXcm: pallet_xcm::{Pallet, Call, Event<T>, Origin} = 51,
+ CumulusXcm: cumulus_pallet_xcm::{Pallet, Call, Event<T>, Origin} = 52,
+ DmpQueue: cumulus_pallet_dmp_queue::{Pallet, Call, Storage, Event<T>} = 53,
+
+ // Unique Pallets
+ Inflation: pallet_inflation::{Pallet, Call, Storage} = 60,
+ Unique: pallet_unique::{Pallet, Call, Storage, Event<T>} = 61,
+ // Scheduler: pallet_unq_scheduler::{Pallet, Call, Storage, Event<T>} = 62,
+ // free = 63
+ Charging: pallet_charge_transaction::{Pallet, Call, Storage } = 64,
+ // ContractHelpers: pallet_contract_helpers::{Pallet, Call, Storage} = 65,
+ Common: pallet_common::{Pallet, Storage, Event<T>} = 66,
+ Fungible: pallet_fungible::{Pallet, Storage} = 67,
+ Refungible: pallet_refungible::{Pallet, Storage} = 68,
+ Nonfungible: pallet_nonfungible::{Pallet, Storage} = 69,
+
+ // Frontier
+ EVM: pallet_evm::{Pallet, Config, Call, Storage, Event<T>} = 100,
+ Ethereum: pallet_ethereum::{Pallet, Config, Call, Storage, Event, Origin} = 101,
+
+ EvmCoderSubstrate: pallet_evm_coder_substrate::{Pallet, Storage} = 150,
+ EvmContractHelpers: pallet_evm_contract_helpers::{Pallet, Storage} = 151,
+ EvmTransactionPayment: pallet_evm_transaction_payment::{Pallet} = 152,
+ EvmMigration: pallet_evm_migration::{Pallet, Call, Storage} = 153,
+ }
+);
+
+pub struct TransactionConverter;
+
+impl fp_rpc::ConvertTransaction<UncheckedExtrinsic> for TransactionConverter {
+ fn convert_transaction(&self, transaction: pallet_ethereum::Transaction) -> UncheckedExtrinsic {
+ UncheckedExtrinsic::new_unsigned(
+ pallet_ethereum::Call::<Runtime>::transact { transaction }.into(),
+ )
+ }
+}
+
+impl fp_rpc::ConvertTransaction<opaque::UncheckedExtrinsic> for TransactionConverter {
+ fn convert_transaction(
+ &self,
+ transaction: pallet_ethereum::Transaction,
+ ) -> opaque::UncheckedExtrinsic {
+ let extrinsic = UncheckedExtrinsic::new_unsigned(
+ pallet_ethereum::Call::<Runtime>::transact { transaction }.into(),
+ );
+ let encoded = extrinsic.encode();
+ opaque::UncheckedExtrinsic::decode(&mut &encoded[..])
+ .expect("Encoded extrinsic is always valid")
+ }
+}
+
+/// The address format for describing accounts.
+pub type Address = sp_runtime::MultiAddress<AccountId, ()>;
+/// Block header type as expected by this runtime.
+pub type Header = generic::Header<BlockNumber, BlakeTwo256>;
+/// Block type as expected by this runtime.
+pub type Block = generic::Block<Header, UncheckedExtrinsic>;
+/// A Block signed with a Justification
+pub type SignedBlock = generic::SignedBlock<Block>;
+/// BlockId type as expected by this runtime.
+pub type BlockId = generic::BlockId<Block>;
+/// The SignedExtension to the basic transaction logic.
+pub type SignedExtra = (
+ frame_system::CheckSpecVersion<Runtime>,
+ // system::CheckTxVersion<Runtime>,
+ frame_system::CheckGenesis<Runtime>,
+ frame_system::CheckEra<Runtime>,
+ frame_system::CheckNonce<Runtime>,
+ frame_system::CheckWeight<Runtime>,
+ pallet_charge_transaction::ChargeTransactionPayment<Runtime>,
+ //pallet_contract_helpers::ContractHelpersExtension<Runtime>,
+);
+/// Unchecked extrinsic type as expected by this runtime.
+pub type UncheckedExtrinsic =
+ fp_self_contained::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;
+/// Extrinsic type that has already been checked.
+pub type CheckedExtrinsic = fp_self_contained::CheckedExtrinsic<AccountId, Call, SignedExtra, H160>;
+/// Executive: handles dispatch to the various modules.
+pub type Executive = frame_executive::Executive<
+ Runtime,
+ Block,
+ frame_system::ChainContext<Runtime>,
+ Runtime,
+ AllPalletsReversedWithSystemFirst,
+>;
+
+impl_opaque_keys! {
+ pub struct SessionKeys {
+ pub aura: Aura,
+ }
+}
+
+impl fp_self_contained::SelfContainedCall for Call {
+ type SignedInfo = H160;
+
+ fn is_self_contained(&self) -> bool {
+ match self {
+ Call::Ethereum(call) => call.is_self_contained(),
+ _ => false,
+ }
+ }
+
+ fn check_self_contained(&self) -> Option<Result<Self::SignedInfo, TransactionValidityError>> {
+ match self {
+ Call::Ethereum(call) => call.check_self_contained(),
+ _ => None,
+ }
+ }
+
+ fn validate_self_contained(&self, info: &Self::SignedInfo) -> Option<TransactionValidity> {
+ match self {
+ Call::Ethereum(call) => call.validate_self_contained(info),
+ _ => None,
+ }
+ }
+
+ fn pre_dispatch_self_contained(
+ &self,
+ info: &Self::SignedInfo,
+ ) -> Option<Result<(), TransactionValidityError>> {
+ match self {
+ Call::Ethereum(call) => call.pre_dispatch_self_contained(info),
+ _ => None,
+ }
+ }
+
+ fn apply_self_contained(
+ self,
+ info: Self::SignedInfo,
+ ) -> Option<sp_runtime::DispatchResultWithInfo<PostDispatchInfoOf<Self>>> {
+ match self {
+ call @ Call::Ethereum(pallet_ethereum::Call::transact { .. }) => Some(call.dispatch(
+ Origin::from(pallet_ethereum::RawOrigin::EthereumTransaction(info)),
+ )),
+ _ => None,
+ }
+ }
+}
+
+macro_rules! dispatch_unique_runtime {
+ ($collection:ident.$method:ident($($name:ident),*)) => {{
+ use pallet_unique::dispatch::Dispatched;
+
+ let collection = Dispatched::dispatch(<pallet_common::CollectionHandle<Runtime>>::try_get($collection)?);
+ let dispatch = collection.as_dyn();
+
+ Ok(dispatch.$method($($name),*))
+ }};
+}
+
+impl_common_runtime_apis!();
+
+struct CheckInherents;
+
+impl cumulus_pallet_parachain_system::CheckInherents<Block> for CheckInherents {
+ fn check_inherents(
+ block: &Block,
+ relay_state_proof: &cumulus_pallet_parachain_system::RelayChainStateProof,
+ ) -> sp_inherents::CheckInherentsResult {
+ let relay_chain_slot = relay_state_proof
+ .read_slot()
+ .expect("Could not read the relay chain slot from the proof");
+
+ let inherent_data =
+ cumulus_primitives_timestamp::InherentDataProvider::from_relay_chain_slot_and_duration(
+ relay_chain_slot,
+ sp_std::time::Duration::from_secs(6),
+ )
+ .create_inherent_data()
+ .expect("Could not create the timestamp inherent data");
+
+ inherent_data.check_extrinsics(block)
+ }
+}
+
+cumulus_pallet_parachain_system::register_validate_block!(
+ Runtime = Runtime,
+ BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor::<Runtime, Executive>,
+ CheckInherents = CheckInherents,
+);
runtime/quartz/Cargo.tomldiffbeforeafterboth--- /dev/null
+++ b/runtime/quartz/Cargo.toml
@@ -0,0 +1,410 @@
+################################################################################
+# Package
+
+[package]
+authors = ['Unique Network <support@uniquenetwork.io>']
+build = 'build.rs'
+description = 'Quartz Runtime'
+edition = '2021'
+homepage = 'https://unique.network'
+license = 'GPLv3'
+name = 'quartz-runtime'
+repository = 'https://github.com/UniqueNetwork/unique-chain'
+version = '0.1.0'
+
+[package.metadata.docs.rs]
+targets = ['x86_64-unknown-linux-gnu']
+
+[features]
+default = ['std']
+runtime-benchmarks = [
+ 'hex-literal',
+ 'frame-benchmarking',
+ 'frame-support/runtime-benchmarks',
+ 'frame-system-benchmarking',
+ 'frame-system/runtime-benchmarks',
+ 'pallet-ethereum/runtime-benchmarks',
+ 'pallet-evm-migration/runtime-benchmarks',
+ 'pallet-evm-coder-substrate/runtime-benchmarks',
+ 'pallet-balances/runtime-benchmarks',
+ 'pallet-timestamp/runtime-benchmarks',
+ 'pallet-common/runtime-benchmarks',
+ 'pallet-fungible/runtime-benchmarks',
+ 'pallet-refungible/runtime-benchmarks',
+ 'pallet-nonfungible/runtime-benchmarks',
+ 'pallet-unique/runtime-benchmarks',
+ 'pallet-inflation/runtime-benchmarks',
+ 'pallet-xcm/runtime-benchmarks',
+ 'sp-runtime/runtime-benchmarks',
+ 'xcm-builder/runtime-benchmarks',
+]
+std = [
+ 'codec/std',
+ 'cumulus-pallet-aura-ext/std',
+ 'cumulus-pallet-parachain-system/std',
+ 'cumulus-pallet-xcm/std',
+ 'cumulus-pallet-xcmp-queue/std',
+ 'cumulus-primitives-core/std',
+ 'cumulus-primitives-utility/std',
+ 'frame-executive/std',
+ 'frame-support/std',
+ 'frame-system/std',
+ 'frame-system-rpc-runtime-api/std',
+ 'pallet-aura/std',
+ 'pallet-balances/std',
+ # 'pallet-contracts/std',
+ # 'pallet-contracts-primitives/std',
+ # 'pallet-contracts-rpc-runtime-api/std',
+ # 'pallet-contract-helpers/std',
+ 'pallet-randomness-collective-flip/std',
+ 'pallet-sudo/std',
+ 'pallet-timestamp/std',
+ 'pallet-transaction-payment/std',
+ 'pallet-transaction-payment-rpc-runtime-api/std',
+ 'pallet-treasury/std',
+ # 'pallet-vesting/std',
+ 'pallet-evm/std',
+ 'pallet-evm-migration/std',
+ 'pallet-evm-contract-helpers/std',
+ 'pallet-evm-transaction-payment/std',
+ 'pallet-evm-coder-substrate/std',
+ 'pallet-ethereum/std',
+ 'pallet-base-fee/std',
+ 'fp-rpc/std',
+ 'up-rpc/std',
+ 'up-evm-mapping/std',
+ 'fp-self-contained/std',
+ 'parachain-info/std',
+ 'serde',
+ 'pallet-inflation/std',
+ 'pallet-common/std',
+ 'pallet-fungible/std',
+ 'pallet-refungible/std',
+ 'pallet-nonfungible/std',
+ 'pallet-unique/std',
+ 'pallet-unq-scheduler/std',
+ 'pallet-charge-transaction/std',
+ 'up-data-structs/std',
+ 'sp-api/std',
+ 'sp-block-builder/std',
+ "sp-consensus-aura/std",
+ 'sp-core/std',
+ 'sp-inherents/std',
+ 'sp-io/std',
+ 'sp-offchain/std',
+ 'sp-runtime/std',
+ 'sp-session/std',
+ 'sp-std/std',
+ 'sp-transaction-pool/std',
+ 'sp-version/std',
+ 'xcm/std',
+ 'xcm-builder/std',
+ 'xcm-executor/std',
+ 'unique-runtime-common/std',
+
+ "orml-vesting/std",
+]
+limit-testing = ['pallet-unique/limit-testing', 'up-data-structs/limit-testing']
+
+################################################################################
+# Substrate Dependencies
+
+[dependencies.codec]
+default-features = false
+features = ['derive']
+package = 'parity-scale-codec'
+version = '2.3.0'
+
+[dependencies.frame-benchmarking]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+optional = true
+branch = 'polkadot-v0.9.17'
+
+[dependencies.frame-executive]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'polkadot-v0.9.17'
+
+[dependencies.frame-support]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'polkadot-v0.9.17'
+
+[dependencies.frame-system]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'polkadot-v0.9.17'
+
+[dependencies.frame-system-benchmarking]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+optional = true
+branch = 'polkadot-v0.9.17'
+
+[dependencies.frame-system-rpc-runtime-api]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'polkadot-v0.9.17'
+
+[dependencies.hex-literal]
+optional = true
+version = '0.3.3'
+
+[dependencies.serde]
+default-features = false
+features = ['derive']
+optional = true
+version = '1.0.130'
+
+[dependencies.pallet-aura]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'polkadot-v0.9.17'
+
+[dependencies.pallet-balances]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'polkadot-v0.9.17'
+
+# Contracts specific packages
+# [dependencies.pallet-contracts]
+# git = 'https://github.com/paritytech/substrate.git'
+# default-features = false
+# branch = 'polkadot-v0.9.17'
+# version = '4.0.0-dev'
+
+# [dependencies.pallet-contracts-primitives]
+# git = 'https://github.com/paritytech/substrate.git'
+# default-features = false
+# branch = 'polkadot-v0.9.17'
+# version = '4.0.0-dev'
+
+# [dependencies.pallet-contracts-rpc-runtime-api]
+# git = 'https://github.com/paritytech/substrate.git'
+# default-features = false
+# branch = 'polkadot-v0.9.17'
+# version = '4.0.0-dev'
+
+[dependencies.pallet-randomness-collective-flip]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'polkadot-v0.9.17'
+
+[dependencies.pallet-sudo]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'polkadot-v0.9.17'
+
+[dependencies.pallet-timestamp]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'polkadot-v0.9.17'
+
+[dependencies.pallet-transaction-payment]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'polkadot-v0.9.17'
+
+[dependencies.pallet-transaction-payment-rpc-runtime-api]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'polkadot-v0.9.17'
+
+[dependencies.pallet-treasury]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'polkadot-v0.9.17'
+
+# [dependencies.pallet-vesting]
+# default-features = false
+# git = 'https://github.com/paritytech/substrate.git'
+# branch = 'polkadot-v0.9.17'
+
+[dependencies.sp-arithmetic]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'polkadot-v0.9.17'
+
+[dependencies.sp-api]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'polkadot-v0.9.17'
+
+[dependencies.sp-block-builder]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'polkadot-v0.9.17'
+
+[dependencies.sp-core]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'polkadot-v0.9.17'
+
+[dependencies.sp-consensus-aura]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'polkadot-v0.9.17'
+
+[dependencies.sp-inherents]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'polkadot-v0.9.17'
+
+[dependencies.sp-io]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'polkadot-v0.9.17'
+
+[dependencies.sp-offchain]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'polkadot-v0.9.17'
+
+[dependencies.sp-runtime]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'polkadot-v0.9.17'
+
+[dependencies.sp-session]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'polkadot-v0.9.17'
+
+[dependencies.sp-std]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'polkadot-v0.9.17'
+
+[dependencies.sp-transaction-pool]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'polkadot-v0.9.17'
+
+[dependencies.sp-version]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'polkadot-v0.9.17'
+
+[dependencies.smallvec]
+version = '1.6.1'
+
+################################################################################
+# Cumulus dependencies
+
+[dependencies.parachain-info]
+default-features = false
+git = 'https://github.com/uniqueNetwork/cumulus.git'
+branch = 'polkadot-v0.9.17'
+
+[dependencies.cumulus-pallet-aura-ext]
+git = 'https://github.com/uniqueNetwork/cumulus.git'
+branch = 'polkadot-v0.9.17'
+default-features = false
+
+[dependencies.cumulus-pallet-parachain-system]
+git = 'https://github.com/uniqueNetwork/cumulus.git'
+branch = 'polkadot-v0.9.17'
+default-features = false
+
+[dependencies.cumulus-primitives-core]
+git = 'https://github.com/uniqueNetwork/cumulus.git'
+branch = 'polkadot-v0.9.17'
+default-features = false
+
+[dependencies.cumulus-pallet-xcm]
+git = 'https://github.com/uniqueNetwork/cumulus.git'
+branch = 'polkadot-v0.9.17'
+default-features = false
+
+[dependencies.cumulus-pallet-dmp-queue]
+git = 'https://github.com/uniqueNetwork/cumulus.git'
+branch = 'polkadot-v0.9.17'
+default-features = false
+
+[dependencies.cumulus-pallet-xcmp-queue]
+git = 'https://github.com/uniqueNetwork/cumulus.git'
+branch = 'polkadot-v0.9.17'
+default-features = false
+
+[dependencies.cumulus-primitives-utility]
+git = 'https://github.com/uniqueNetwork/cumulus.git'
+branch = 'polkadot-v0.9.17'
+default-features = false
+
+[dependencies.cumulus-primitives-timestamp]
+git = 'https://github.com/uniqueNetwork/cumulus.git'
+branch = 'polkadot-v0.9.17'
+default-features = false
+
+################################################################################
+# Polkadot dependencies
+
+[dependencies.polkadot-parachain]
+git = 'https://github.com/paritytech/polkadot'
+branch = 'release-v0.9.17'
+default-features = false
+
+[dependencies.xcm]
+git = 'https://github.com/paritytech/polkadot'
+branch = 'release-v0.9.17'
+default-features = false
+
+[dependencies.xcm-builder]
+git = 'https://github.com/paritytech/polkadot'
+branch = 'release-v0.9.17'
+default-features = false
+
+[dependencies.xcm-executor]
+git = 'https://github.com/paritytech/polkadot'
+branch = 'release-v0.9.17'
+default-features = false
+
+[dependencies.pallet-xcm]
+git = 'https://github.com/paritytech/polkadot'
+branch = 'release-v0.9.17'
+default-features = false
+
+[dependencies.orml-vesting]
+git = 'https://github.com/UniqueNetwork/open-runtime-module-library'
+branch = 'unique-polkadot-v0.9.17'
+version = "0.4.1-dev"
+default-features = false
+
+################################################################################
+# local dependencies
+
+[dependencies]
+unique-runtime-common = { path = "../common", default-features = false }
+scale-info = { version = "1.0.0", default-features = false, features = [
+ "derive",
+] }
+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 }
+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" }
+pallet-fungible = { default-features = false, path = "../../pallets/fungible" }
+pallet-refungible = { default-features = false, path = "../../pallets/refungible" }
+pallet-nonfungible = { default-features = false, path = "../../pallets/nonfungible" }
+pallet-unq-scheduler = { path = '../../pallets/scheduler', default-features = false }
+# pallet-contract-helpers = { path = '../pallets/contract-helpers', default-features = false, version = '0.1.0' }
+pallet-charge-transaction = { git = "https://github.com/UniqueNetwork/pallet-sponsoring", branch = 'polkadot-v0.9.17', package = "pallet-template-transaction-payment", default-features = false, version = '3.0.0' }
+pallet-evm-migration = { path = '../../pallets/evm-migration', default-features = false }
+pallet-evm-contract-helpers = { path = '../../pallets/evm-contract-helpers', default-features = false }
+pallet-evm-transaction-payment = { path = '../../pallets/evm-transaction-payment', default-features = false }
+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.17" }
+pallet-ethereum = { default-features = false, git = "https://github.com/uniquenetwork/frontier.git", branch = "unique-polkadot-v0.9.17" }
+pallet-base-fee = { default-features = false, git = "https://github.com/uniquenetwork/frontier.git", branch = "unique-polkadot-v0.9.17" }
+fp-rpc = { default-features = false, git = "https://github.com/uniquenetwork/frontier.git", branch = "unique-polkadot-v0.9.17" }
+fp-self-contained = { default-features = false, git = "https://github.com/uniquenetwork/frontier.git", branch = "unique-polkadot-v0.9.17" }
+
+################################################################################
+# Build Dependencies
+
+[build-dependencies.substrate-wasm-builder]
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'polkadot-v0.9.17'
runtime/quartz/build.rsdiffbeforeafterboth--- /dev/null
+++ b/runtime/quartz/build.rs
@@ -0,0 +1,9 @@
+use substrate_wasm_builder::WasmBuilder;
+
+fn main() {
+ WasmBuilder::new()
+ .with_current_project()
+ .import_memory()
+ .export_heap_base()
+ .build()
+}
runtime/quartz/src/lib.rsdiffbeforeafterboth--- /dev/null
+++ b/runtime/quartz/src/lib.rs
@@ -0,0 +1,1141 @@
+// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.
+// This file is part of Unique Network.
+
+// Unique Network is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+// Unique Network is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
+
+//! The Substrate Node Template runtime. This can be compiled with `#[no_std]`, ready for Wasm.
+
+#![cfg_attr(not(feature = "std"), no_std)]
+// `construct_runtime!` does a lot of recursion and requires us to increase the limit to 256.
+#![recursion_limit = "1024"]
+#![allow(clippy::from_over_into, clippy::identity_op)]
+#![allow(clippy::fn_to_numeric_cast_with_truncation)]
+// Make the WASM binary available.
+#[cfg(feature = "std")]
+include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
+
+use sp_api::impl_runtime_apis;
+use sp_core::{crypto::KeyTypeId, OpaqueMetadata, H256, U256, H160};
+use sp_runtime::DispatchError;
+// #[cfg(any(feature = "std", test))]
+// pub use sp_runtime::BuildStorage;
+
+use sp_runtime::{
+ Permill, Perbill, Percent, create_runtime_str, generic, impl_opaque_keys,
+ traits::{AccountIdLookup, BlakeTwo256, Block as BlockT, AccountIdConversion, Zero},
+ transaction_validity::{TransactionSource, TransactionValidity},
+ ApplyExtrinsicResult, RuntimeAppPublic,
+};
+
+use sp_std::prelude::*;
+
+#[cfg(feature = "std")]
+use sp_version::NativeVersion;
+use sp_version::RuntimeVersion;
+pub use pallet_transaction_payment::{
+ Multiplier, TargetedFeeAdjustment, FeeDetails, RuntimeDispatchInfo,
+};
+// A few exports that help ease life for downstream crates.
+pub use pallet_balances::Call as BalancesCall;
+pub use pallet_evm::{EnsureAddressTruncated, HashedAddressMapping, Runner};
+pub use frame_support::{
+ construct_runtime, match_type,
+ dispatch::DispatchResult,
+ PalletId, parameter_types, StorageValue, ConsensusEngineId,
+ traits::{
+ tokens::currency::Currency as CurrencyT, OnUnbalanced as OnUnbalancedT, Everything,
+ Currency, ExistenceRequirement, Get, IsInVec, KeyOwnerProofSystem, LockIdentifier,
+ OnUnbalanced, Randomness, FindAuthor,
+ },
+ weights::{
+ constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND},
+ DispatchClass, DispatchInfo, GetDispatchInfo, IdentityFee, Pays, PostDispatchInfo, Weight,
+ WeightToFeePolynomial, WeightToFeeCoefficient, WeightToFeeCoefficients,
+ },
+};
+use up_data_structs::*;
+// use pallet_contracts::weights::WeightInfo;
+// #[cfg(any(feature = "std", test))]
+use frame_system::{
+ self as frame_system, EnsureRoot, EnsureSigned,
+ limits::{BlockWeights, BlockLength},
+};
+use sp_arithmetic::{
+ traits::{BaseArithmetic, Unsigned},
+};
+use smallvec::smallvec;
+use codec::{Encode, Decode};
+use pallet_evm::{Account as EVMAccount, FeeCalculator, GasWeightMapping, OnMethodCall};
+use fp_rpc::TransactionStatus;
+use sp_runtime::{
+ traits::{BlockNumberProvider, Dispatchable, PostDispatchInfoOf, Saturating},
+ transaction_validity::TransactionValidityError,
+ SaturatedConversion,
+};
+
+// pub use pallet_timestamp::Call as TimestampCall;
+pub use sp_consensus_aura::sr25519::AuthorityId as AuraId;
+
+// Polkadot imports
+use pallet_xcm::XcmPassthrough;
+use polkadot_parachain::primitives::Sibling;
+use xcm::v1::{BodyId, Junction::*, MultiLocation, NetworkId, Junctions::*};
+use xcm_builder::{
+ AccountId32Aliases, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, CurrencyAdapter,
+ EnsureXcmOrigin, FixedWeightBounds, LocationInverter, NativeAsset, ParentAsSuperuser,
+ RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia,
+ SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit,
+ ParentIsPreset,
+};
+use xcm_executor::{Config, XcmExecutor, Assets};
+use sp_std::{marker::PhantomData};
+
+use xcm::latest::{
+ // Xcm,
+ AssetId::{Concrete},
+ Fungibility::Fungible as XcmFungible,
+ MultiAsset,
+ Error as XcmError,
+};
+use xcm_executor::traits::{MatchesFungible, WeightTrader};
+//use xcm_executor::traits::MatchesFungible;
+use sp_runtime::traits::CheckedConversion;
+
+use unique_runtime_common::{impl_common_runtime_apis, types::*, constants::*};
+
+pub const RUNTIME_NAME: &str = "Quartz";
+
+type CrossAccountId = pallet_common::account::BasicCrossAccountId<Runtime>;
+
+impl RuntimeInstance for Runtime {
+ type CrossAccountId = self::CrossAccountId;
+
+ type TransactionConverter = self::TransactionConverter;
+
+ fn get_transaction_converter() -> TransactionConverter {
+ TransactionConverter
+ }
+}
+
+/// Opaque types. These are used by the CLI to instantiate machinery that don't need to know
+/// the specifics of the runtime. They can then be made to be agnostic over specific formats
+/// of data like extrinsics, allowing for them to continue syncing the network through upgrades
+/// to even the core data structures.
+pub mod opaque {
+ use sp_std::prelude::*;
+ use sp_runtime::impl_opaque_keys;
+ use super::Aura;
+
+ pub use unique_runtime_common::types::*;
+
+ impl_opaque_keys! {
+ pub struct SessionKeys {
+ pub aura: Aura,
+ }
+ }
+}
+
+/// This runtime version.
+pub const VERSION: RuntimeVersion = RuntimeVersion {
+ spec_name: create_runtime_str!(RUNTIME_NAME),
+ impl_name: create_runtime_str!(RUNTIME_NAME),
+ authoring_version: 1,
+ spec_version: 917004,
+ impl_version: 0,
+ apis: RUNTIME_API_VERSIONS,
+ transaction_version: 1,
+ state_version: 0,
+};
+
+#[derive(codec::Encode, codec::Decode)]
+pub enum XCMPMessage<XAccountId, XBalance> {
+ /// Transfer tokens to the given account from the Parachain account.
+ TransferToken(XAccountId, XBalance),
+}
+
+/// The version information used to identify this runtime when compiled natively.
+#[cfg(feature = "std")]
+pub fn native_version() -> NativeVersion {
+ NativeVersion {
+ runtime_version: VERSION,
+ can_author_with: Default::default(),
+ }
+}
+
+type NegativeImbalance = <Balances as Currency<AccountId>>::NegativeImbalance;
+
+pub struct DealWithFees;
+impl OnUnbalanced<NegativeImbalance> for DealWithFees {
+ fn on_unbalanceds<B>(mut fees_then_tips: impl Iterator<Item = NegativeImbalance>) {
+ if let Some(fees) = fees_then_tips.next() {
+ // for fees, 100% to treasury
+ let mut split = fees.ration(100, 0);
+ if let Some(tips) = fees_then_tips.next() {
+ // for tips, if any, 100% to treasury
+ tips.ration_merge_into(100, 0, &mut split);
+ }
+ Treasury::on_unbalanced(split.0);
+ // Author::on_unbalanced(split.1);
+ }
+ }
+}
+
+parameter_types! {
+ pub const BlockHashCount: BlockNumber = 2400;
+ pub RuntimeBlockLength: BlockLength =
+ BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);
+ pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);
+ pub const MaximumBlockLength: u32 = 5 * 1024 * 1024;
+ pub RuntimeBlockWeights: BlockWeights = BlockWeights::builder()
+ .base_block(BlockExecutionWeight::get())
+ .for_class(DispatchClass::all(), |weights| {
+ weights.base_extrinsic = ExtrinsicBaseWeight::get();
+ })
+ .for_class(DispatchClass::Normal, |weights| {
+ weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT);
+ })
+ .for_class(DispatchClass::Operational, |weights| {
+ weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT);
+ // Operational transactions have some extra reserved space, so that they
+ // are included even if block reached `MAXIMUM_BLOCK_WEIGHT`.
+ weights.reserved = Some(
+ MAXIMUM_BLOCK_WEIGHT - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT
+ );
+ })
+ .avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO)
+ .build_or_panic();
+ pub const Version: RuntimeVersion = VERSION;
+ pub const SS58Prefix: u8 = 255;
+}
+
+parameter_types! {
+ pub const ChainId: u64 = 8881;
+}
+
+pub struct FixedFee;
+impl FeeCalculator for FixedFee {
+ fn min_gas_price() -> U256 {
+ MIN_GAS_PRICE.into()
+ }
+}
+
+// Assuming slowest ethereum opcode is SSTORE, with gas price of 20000 as our worst case
+// (contract, which only writes a lot of data),
+// approximating on top of our real store write weight
+parameter_types! {
+ pub const WritesPerSecond: u64 = WEIGHT_PER_SECOND / <Runtime as frame_system::Config>::DbWeight::get().write;
+ pub const GasPerSecond: u64 = WritesPerSecond::get() * 20000;
+ pub const WeightPerGas: u64 = WEIGHT_PER_SECOND / GasPerSecond::get();
+}
+
+/// Limiting EVM execution to 50% of block for substrate users and management tasks
+/// EVM transaction consumes more weight than substrate's, so we can't rely on them being
+/// scheduled fairly
+const EVM_DISPATCH_RATIO: Perbill = Perbill::from_percent(50);
+parameter_types! {
+ pub BlockGasLimit: U256 = U256::from(NORMAL_DISPATCH_RATIO * EVM_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT / WeightPerGas::get());
+}
+
+pub enum FixedGasWeightMapping {}
+impl GasWeightMapping for FixedGasWeightMapping {
+ fn gas_to_weight(gas: u64) -> Weight {
+ gas.saturating_mul(WeightPerGas::get())
+ }
+ fn weight_to_gas(weight: Weight) -> u64 {
+ weight / WeightPerGas::get()
+ }
+}
+
+impl pallet_evm::Config for Runtime {
+ type BlockGasLimit = BlockGasLimit;
+ type FeeCalculator = FixedFee;
+ type GasWeightMapping = FixedGasWeightMapping;
+ type BlockHashMapping = pallet_ethereum::EthereumBlockHashMapping<Self>;
+ type CallOrigin = EnsureAddressTruncated;
+ type WithdrawOrigin = EnsureAddressTruncated;
+ type AddressMapping = HashedAddressMapping<Self::Hashing>;
+ type PrecompilesType = ();
+ type PrecompilesValue = ();
+ type Currency = Balances;
+ type Event = Event;
+ type OnMethodCall = (
+ pallet_evm_migration::OnMethodCall<Self>,
+ pallet_unique::UniqueErcSupport<Self>,
+ pallet_evm_contract_helpers::HelpersOnMethodCall<Self>,
+ );
+ type OnCreate = pallet_evm_contract_helpers::HelpersOnCreate<Self>;
+ type ChainId = ChainId;
+ type Runner = pallet_evm::runner::stack::Runner<Self>;
+ type OnChargeTransaction = pallet_evm_transaction_payment::OnChargeTransaction<Self>;
+ type TransactionValidityHack = pallet_evm_transaction_payment::TransactionValidityHack<Self>;
+ type FindAuthor = EthereumFindAuthor<Aura>;
+}
+
+impl pallet_evm_migration::Config for Runtime {
+ type WeightInfo = pallet_evm_migration::weights::SubstrateWeight<Self>;
+}
+
+pub struct EthereumFindAuthor<F>(core::marker::PhantomData<F>);
+impl<F: FindAuthor<u32>> FindAuthor<H160> for EthereumFindAuthor<F> {
+ fn find_author<'a, I>(digests: I) -> Option<H160>
+ where
+ I: 'a + IntoIterator<Item = (ConsensusEngineId, &'a [u8])>,
+ {
+ if let Some(author_index) = F::find_author(digests) {
+ let authority_id = Aura::authorities()[author_index as usize].clone();
+ return Some(H160::from_slice(&authority_id.to_raw_vec()[4..24]));
+ }
+ None
+ }
+}
+
+impl pallet_ethereum::Config for Runtime {
+ type Event = Event;
+ type StateRoot = pallet_ethereum::IntermediateStateRoot;
+}
+
+impl pallet_randomness_collective_flip::Config for Runtime {}
+
+impl frame_system::Config for Runtime {
+ /// The data to be stored in an account.
+ type AccountData = pallet_balances::AccountData<Balance>;
+ /// The identifier used to distinguish between accounts.
+ type AccountId = AccountId;
+ /// The basic call filter to use in dispatchable.
+ type BaseCallFilter = Everything;
+ /// Maximum number of block number to block hash mappings to keep (oldest pruned first).
+ type BlockHashCount = BlockHashCount;
+ /// The maximum length of a block (in bytes).
+ type BlockLength = RuntimeBlockLength;
+ /// The index type for blocks.
+ type BlockNumber = BlockNumber;
+ /// The weight of the overhead invoked on the block import process, independent of the extrinsics included in that block.
+ type BlockWeights = RuntimeBlockWeights;
+ /// The aggregated dispatch type that is available for extrinsics.
+ type Call = Call;
+ /// The weight of database operations that the runtime can invoke.
+ type DbWeight = RocksDbWeight;
+ /// The ubiquitous event type.
+ type Event = Event;
+ /// The type for hashing blocks and tries.
+ type Hash = Hash;
+ /// The hashing algorithm used.
+ type Hashing = BlakeTwo256;
+ /// The header type.
+ type Header = generic::Header<BlockNumber, BlakeTwo256>;
+ /// The index type for storing how many extrinsics an account has signed.
+ type Index = Index;
+ /// The lookup mechanism to get account ID from whatever is passed in dispatchers.
+ type Lookup = AccountIdLookup<AccountId, ()>;
+ /// What to do if an account is fully reaped from the system.
+ type OnKilledAccount = ();
+ /// What to do if a new account is created.
+ type OnNewAccount = ();
+ type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode<Self>;
+ /// The ubiquitous origin type.
+ type Origin = Origin;
+ /// This type is being generated by `construct_runtime!`.
+ type PalletInfo = PalletInfo;
+ /// This is used as an identifier of the chain. 42 is the generic substrate prefix.
+ type SS58Prefix = SS58Prefix;
+ /// Weight information for the extrinsics of this pallet.
+ type SystemWeightInfo = frame_system::weights::SubstrateWeight<Self>;
+ /// Version of the runtime.
+ type Version = Version;
+ type MaxConsumers = ConstU32<16>;
+}
+
+parameter_types! {
+ pub const MinimumPeriod: u64 = SLOT_DURATION / 2;
+}
+
+impl pallet_timestamp::Config for Runtime {
+ /// A timestamp: milliseconds since the unix epoch.
+ type Moment = u64;
+ type OnTimestampSet = ();
+ type MinimumPeriod = MinimumPeriod;
+ type WeightInfo = ();
+}
+
+parameter_types! {
+ // pub const ExistentialDeposit: u128 = 500;
+ pub const ExistentialDeposit: u128 = 0;
+ pub const MaxLocks: u32 = 50;
+}
+
+impl pallet_balances::Config for Runtime {
+ type MaxLocks = MaxLocks;
+ type MaxReserves = ();
+ type ReserveIdentifier = [u8; 8];
+ /// The type for recording an account's balance.
+ type Balance = Balance;
+ /// The ubiquitous event type.
+ type Event = Event;
+ type DustRemoval = Treasury;
+ type ExistentialDeposit = ExistentialDeposit;
+ type AccountStore = System;
+ type WeightInfo = pallet_balances::weights::SubstrateWeight<Self>;
+}
+
+pub const fn deposit(items: u32, bytes: u32) -> Balance {
+ items as Balance * 15 * CENTIUNIQUE + (bytes as Balance) * 6 * CENTIUNIQUE
+}
+
+/*
+parameter_types! {
+ pub TombstoneDeposit: Balance = deposit(
+ 1,
+ sp_std::mem::size_of::<pallet_contracts::Pallet<Runtime>> as u32,
+ );
+ pub DepositPerContract: Balance = TombstoneDeposit::get();
+ pub const DepositPerStorageByte: Balance = deposit(0, 1);
+ pub const DepositPerStorageItem: Balance = deposit(1, 0);
+ pub RentFraction: Perbill = Perbill::from_rational(1u32, 30 * DAYS);
+ pub const SurchargeReward: Balance = 150 * MILLIUNIQUE;
+ pub const SignedClaimHandicap: u32 = 2;
+ pub const MaxDepth: u32 = 32;
+ pub const MaxValueSize: u32 = 16 * 1024;
+ pub const MaxCodeSize: u32 = 1024 * 1024 * 25; // 25 Mb
+ // The lazy deletion runs inside on_initialize.
+ pub DeletionWeightLimit: Weight = AVERAGE_ON_INITIALIZE_RATIO *
+ RuntimeBlockWeights::get().max_block;
+ // The weight needed for decoding the queue should be less or equal than a fifth
+ // of the overall weight dedicated to the lazy deletion.
+ pub DeletionQueueDepth: u32 = ((DeletionWeightLimit::get() / (
+ <Runtime as pallet_contracts::Config>::WeightInfo::on_initialize_per_queue_item(1) -
+ <Runtime as pallet_contracts::Config>::WeightInfo::on_initialize_per_queue_item(0)
+ )) / 5) as u32;
+ pub Schedule: pallet_contracts::Schedule<Runtime> = Default::default();
+}
+
+impl pallet_contracts::Config for Runtime {
+ type Time = Timestamp;
+ type Randomness = RandomnessCollectiveFlip;
+ type Currency = Balances;
+ type Event = Event;
+ type RentPayment = ();
+ type SignedClaimHandicap = SignedClaimHandicap;
+ type TombstoneDeposit = TombstoneDeposit;
+ type DepositPerContract = DepositPerContract;
+ type DepositPerStorageByte = DepositPerStorageByte;
+ type DepositPerStorageItem = DepositPerStorageItem;
+ type RentFraction = RentFraction;
+ type SurchargeReward = SurchargeReward;
+ type WeightPrice = pallet_transaction_payment::Pallet<Self>;
+ type WeightInfo = pallet_contracts::weights::SubstrateWeight<Self>;
+ type ChainExtension = NFTExtension;
+ type DeletionQueueDepth = DeletionQueueDepth;
+ type DeletionWeightLimit = DeletionWeightLimit;
+ type Schedule = Schedule;
+ type CallStack = [pallet_contracts::Frame<Self>; 31];
+}
+*/
+
+parameter_types! {
+ /// This value increases the priority of `Operational` transactions by adding
+ /// a "virtual tip" that's equal to the `OperationalFeeMultiplier * final_fee`.
+ pub const OperationalFeeMultiplier: u8 = 5;
+}
+
+/// Linear implementor of `WeightToFeePolynomial`
+pub struct LinearFee<T>(sp_std::marker::PhantomData<T>);
+
+impl<T> WeightToFeePolynomial for LinearFee<T>
+where
+ T: BaseArithmetic + From<u32> + Copy + Unsigned,
+{
+ type Balance = T;
+
+ fn polynomial() -> WeightToFeeCoefficients<Self::Balance> {
+ smallvec!(WeightToFeeCoefficient {
+ // Targeting 0.1 Unique per NFT transfer
+ coeff_integer: WEIGHT_TO_FEE_COEFF.into(),
+ coeff_frac: Perbill::zero(),
+ negative: false,
+ degree: 1,
+ })
+ }
+}
+
+impl pallet_transaction_payment::Config for Runtime {
+ type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter<Balances, DealWithFees>;
+ type TransactionByteFee = TransactionByteFee;
+ type OperationalFeeMultiplier = OperationalFeeMultiplier;
+ type WeightToFee = LinearFee<Balance>;
+ type FeeMultiplierUpdate = ();
+}
+
+parameter_types! {
+ pub const ProposalBond: Permill = Permill::from_percent(5);
+ pub const ProposalBondMinimum: Balance = 1 * UNIQUE;
+ pub const ProposalBondMaximum: Balance = 1000 * UNIQUE;
+ pub const SpendPeriod: BlockNumber = 5 * MINUTES;
+ pub const Burn: Permill = Permill::from_percent(0);
+ pub const TipCountdown: BlockNumber = 1 * DAYS;
+ pub const TipFindersFee: Percent = Percent::from_percent(20);
+ pub const TipReportDepositBase: Balance = 1 * UNIQUE;
+ pub const DataDepositPerByte: Balance = 1 * CENTIUNIQUE;
+ pub const BountyDepositBase: Balance = 1 * UNIQUE;
+ pub const BountyDepositPayoutDelay: BlockNumber = 1 * DAYS;
+ pub const TreasuryModuleId: PalletId = PalletId(*b"py/trsry");
+ pub const BountyUpdatePeriod: BlockNumber = 14 * DAYS;
+ pub const MaximumReasonLength: u32 = 16384;
+ pub const BountyCuratorDeposit: Permill = Permill::from_percent(50);
+ pub const BountyValueMinimum: Balance = 5 * UNIQUE;
+ pub const MaxApprovals: u32 = 100;
+}
+
+impl pallet_treasury::Config for Runtime {
+ type PalletId = TreasuryModuleId;
+ type Currency = Balances;
+ type ApproveOrigin = EnsureRoot<AccountId>;
+ type RejectOrigin = EnsureRoot<AccountId>;
+ type Event = Event;
+ type OnSlash = ();
+ type ProposalBond = ProposalBond;
+ type ProposalBondMinimum = ProposalBondMinimum;
+ type ProposalBondMaximum = ProposalBondMaximum;
+ type SpendPeriod = SpendPeriod;
+ type Burn = Burn;
+ type BurnDestination = ();
+ type SpendFunds = ();
+ type WeightInfo = pallet_treasury::weights::SubstrateWeight<Self>;
+ type MaxApprovals = MaxApprovals;
+}
+
+impl pallet_sudo::Config for Runtime {
+ type Event = Event;
+ type Call = Call;
+}
+
+pub struct RelayChainBlockNumberProvider<T>(sp_std::marker::PhantomData<T>);
+
+impl<T: cumulus_pallet_parachain_system::Config> BlockNumberProvider
+ for RelayChainBlockNumberProvider<T>
+{
+ type BlockNumber = BlockNumber;
+
+ fn current_block_number() -> Self::BlockNumber {
+ cumulus_pallet_parachain_system::Pallet::<T>::validation_data()
+ .map(|d| d.relay_parent_number)
+ .unwrap_or_default()
+ }
+}
+
+parameter_types! {
+ pub const MinVestedTransfer: Balance = 10 * UNIQUE;
+ pub const MaxVestingSchedules: u32 = 28;
+}
+
+impl orml_vesting::Config for Runtime {
+ type Event = Event;
+ type Currency = pallet_balances::Pallet<Runtime>;
+ type MinVestedTransfer = MinVestedTransfer;
+ type VestedTransferOrigin = EnsureSigned<AccountId>;
+ type WeightInfo = ();
+ type MaxVestingSchedules = MaxVestingSchedules;
+ type BlockNumberProvider = RelayChainBlockNumberProvider<Runtime>;
+}
+
+parameter_types! {
+ pub const ReservedDmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;
+ pub const ReservedXcmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;
+}
+
+impl cumulus_pallet_parachain_system::Config for Runtime {
+ type Event = Event;
+ type SelfParaId = parachain_info::Pallet<Self>;
+ type OnSystemEvent = ();
+ // type DownwardMessageHandlers = cumulus_primitives_utility::UnqueuedDmpAsParent<
+ // MaxDownwardMessageWeight,
+ // XcmExecutor<XcmConfig>,
+ // Call,
+ // >;
+ type OutboundXcmpMessageSource = XcmpQueue;
+ type DmpMessageHandler = DmpQueue;
+ type ReservedDmpWeight = ReservedDmpWeight;
+ type ReservedXcmpWeight = ReservedXcmpWeight;
+ type XcmpMessageHandler = XcmpQueue;
+}
+
+impl parachain_info::Config for Runtime {}
+
+impl cumulus_pallet_aura_ext::Config for Runtime {}
+
+parameter_types! {
+ pub const RelayLocation: MultiLocation = MultiLocation::parent();
+ pub const RelayNetwork: NetworkId = NetworkId::Polkadot;
+ pub RelayOrigin: Origin = cumulus_pallet_xcm::Origin::Relay.into();
+ pub Ancestry: MultiLocation = Parachain(ParachainInfo::parachain_id().into()).into();
+}
+
+/// Type for specifying how a `MultiLocation` can be converted into an `AccountId`. This is used
+/// when determining ownership of accounts for asset transacting and when attempting to use XCM
+/// `Transact` in order to determine the dispatch Origin.
+pub type LocationToAccountId = (
+ // The parent (Relay-chain) origin converts to the default `AccountId`.
+ ParentIsPreset<AccountId>,
+ // Sibling parachain origins convert to AccountId via the `ParaId::into`.
+ SiblingParachainConvertsVia<Sibling, AccountId>,
+ // Straight up local `AccountId32` origins just alias directly to `AccountId`.
+ AccountId32Aliases<RelayNetwork, AccountId>,
+);
+
+pub struct OnlySelfCurrency;
+impl<B: TryFrom<u128>> MatchesFungible<B> for OnlySelfCurrency {
+ fn matches_fungible(a: &MultiAsset) -> Option<B> {
+ match (&a.id, &a.fun) {
+ (Concrete(_), XcmFungible(ref amount)) => CheckedConversion::checked_from(*amount),
+ _ => None,
+ }
+ }
+}
+
+/// Means for transacting assets on this chain.
+pub type LocalAssetTransactor = CurrencyAdapter<
+ // Use this currency:
+ Balances,
+ // Use this currency when it is a fungible asset matching the given location or name:
+ OnlySelfCurrency,
+ // Do a simple punn to convert an AccountId32 MultiLocation into a native chain account ID:
+ LocationToAccountId,
+ // Our chain's account ID type (we can't get away without mentioning it explicitly):
+ AccountId,
+ // We don't track any teleports.
+ (),
+>;
+
+/// This is the type we use to convert an (incoming) XCM origin into a local `Origin` instance,
+/// ready for dispatching a transaction with Xcm's `Transact`. There is an `OriginKind` which can
+/// biases the kind of local `Origin` it will become.
+pub type XcmOriginToTransactDispatchOrigin = (
+ // Sovereign account converter; this attempts to derive an `AccountId` from the origin location
+ // using `LocationToAccountId` and then turn that into the usual `Signed` origin. Useful for
+ // foreign chains who want to have a local sovereign account on this chain which they control.
+ SovereignSignedViaLocation<LocationToAccountId, Origin>,
+ // Native converter for Relay-chain (Parent) location; will converts to a `Relay` origin when
+ // recognised.
+ RelayChainAsNative<RelayOrigin, Origin>,
+ // Native converter for sibling Parachains; will convert to a `SiblingPara` origin when
+ // recognised.
+ SiblingParachainAsNative<cumulus_pallet_xcm::Origin, Origin>,
+ // Superuser converter for the Relay-chain (Parent) location. This will allow it to issue a
+ // transaction from the Root origin.
+ ParentAsSuperuser<Origin>,
+ // Native signed account converter; this just converts an `AccountId32` origin into a normal
+ // `Origin::Signed` origin of the same 32-byte value.
+ SignedAccountId32AsNative<RelayNetwork, Origin>,
+ // Xcm origins can be represented natively under the Xcm pallet's Xcm origin.
+ XcmPassthrough<Origin>,
+);
+
+parameter_types! {
+ // One XCM operation is 1_000_000 weight - almost certainly a conservative estimate.
+ pub UnitWeightCost: Weight = 1_000_000;
+ // 1200 UNIQUEs buy 1 second of weight.
+ pub const WeightPrice: (MultiLocation, u128) = (MultiLocation::parent(), 1_200 * UNIQUE);
+ pub const MaxInstructions: u32 = 100;
+ pub const MaxAuthorities: u32 = 100_000;
+}
+
+match_type! {
+ pub type ParentOrParentsUnitPlurality: impl Contains<MultiLocation> = {
+ MultiLocation { parents: 1, interior: Here } |
+ MultiLocation { parents: 1, interior: X1(Plurality { id: BodyId::Unit, .. }) }
+ };
+}
+
+pub type Barrier = (
+ TakeWeightCredit,
+ AllowTopLevelPaidExecutionFrom<Everything>,
+ AllowUnpaidExecutionFrom<ParentOrParentsUnitPlurality>,
+ // ^^^ Parent & its unit plurality gets free execution
+);
+
+pub struct UsingOnlySelfCurrencyComponents<
+ WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,
+ AssetId: Get<MultiLocation>,
+ AccountId,
+ Currency: CurrencyT<AccountId>,
+ OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,
+>(
+ Weight,
+ Currency::Balance,
+ PhantomData<(WeightToFee, AssetId, AccountId, Currency, OnUnbalanced)>,
+);
+impl<
+ WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,
+ AssetId: Get<MultiLocation>,
+ AccountId,
+ Currency: CurrencyT<AccountId>,
+ OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,
+ > WeightTrader
+ for UsingOnlySelfCurrencyComponents<WeightToFee, AssetId, AccountId, Currency, OnUnbalanced>
+{
+ fn new() -> Self {
+ Self(0, Zero::zero(), PhantomData)
+ }
+
+ fn buy_weight(&mut self, weight: Weight, payment: Assets) -> Result<Assets, XcmError> {
+ let amount = WeightToFee::calc(&weight);
+ let u128_amount: u128 = amount.try_into().map_err(|_| XcmError::Overflow)?;
+
+ // location to this parachain through relay chain
+ let option1: xcm::v1::AssetId = Concrete(MultiLocation {
+ parents: 1,
+ interior: X1(Parachain(ParachainInfo::parachain_id().into())),
+ });
+ // direct location
+ let option2: xcm::v1::AssetId = Concrete(MultiLocation {
+ parents: 0,
+ interior: Here,
+ });
+
+ let required = if payment.fungible.contains_key(&option1) {
+ (option1, u128_amount).into()
+ } else if payment.fungible.contains_key(&option2) {
+ (option2, u128_amount).into()
+ } else {
+ (Concrete(MultiLocation::default()), u128_amount).into()
+ };
+
+ let unused = payment
+ .checked_sub(required)
+ .map_err(|_| XcmError::TooExpensive)?;
+ self.0 = self.0.saturating_add(weight);
+ self.1 = self.1.saturating_add(amount);
+ Ok(unused)
+ }
+
+ fn refund_weight(&mut self, weight: Weight) -> Option<MultiAsset> {
+ let weight = weight.min(self.0);
+ let amount = WeightToFee::calc(&weight);
+ self.0 -= weight;
+ self.1 = self.1.saturating_sub(amount);
+ let amount: u128 = amount.saturated_into();
+ if amount > 0 {
+ Some((AssetId::get(), amount).into())
+ } else {
+ None
+ }
+ }
+}
+impl<
+ WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,
+ AssetId: Get<MultiLocation>,
+ AccountId,
+ Currency: CurrencyT<AccountId>,
+ OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,
+ > Drop
+ for UsingOnlySelfCurrencyComponents<WeightToFee, AssetId, AccountId, Currency, OnUnbalanced>
+{
+ fn drop(&mut self) {
+ OnUnbalanced::on_unbalanced(Currency::issue(self.1));
+ }
+}
+
+pub struct XcmConfig;
+impl Config for XcmConfig {
+ type Call = Call;
+ type XcmSender = XcmRouter;
+ // How to withdraw and deposit an asset.
+ type AssetTransactor = LocalAssetTransactor;
+ type OriginConverter = XcmOriginToTransactDispatchOrigin;
+ type IsReserve = NativeAsset;
+ type IsTeleporter = (); // Teleportation is disabled
+ type LocationInverter = LocationInverter<Ancestry>;
+ type Barrier = Barrier;
+ type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;
+ type Trader = UsingOnlySelfCurrencyComponents<
+ IdentityFee<Balance>,
+ RelayLocation,
+ AccountId,
+ Balances,
+ (),
+ >;
+ type ResponseHandler = (); // Don't handle responses for now.
+ type SubscriptionService = PolkadotXcm;
+
+ type AssetTrap = PolkadotXcm;
+ type AssetClaims = PolkadotXcm;
+}
+
+// parameter_types! {
+// pub const MaxDownwardMessageWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 10;
+// }
+
+/// No local origins on this chain are allowed to dispatch XCM sends/executions.
+pub type LocalOriginToLocation = (SignedToAccountId32<Origin, AccountId, RelayNetwork>,);
+
+/// The means for routing XCM messages which are not for local execution into the right message
+/// queues.
+pub type XcmRouter = (
+ // Two routers - use UMP to communicate with the relay chain:
+ cumulus_primitives_utility::ParentAsUmp<ParachainSystem, ()>,
+ // ..and XCMP to communicate with the sibling chains.
+ XcmpQueue,
+);
+
+impl pallet_evm_coder_substrate::Config for Runtime {
+ type EthereumTransactionSender = pallet_ethereum::Pallet<Self>;
+ type GasWeightMapping = FixedGasWeightMapping;
+}
+
+impl pallet_xcm::Config for Runtime {
+ type Event = Event;
+ type SendXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;
+ type XcmRouter = XcmRouter;
+ type ExecuteXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;
+ type XcmExecuteFilter = Everything;
+ type XcmExecutor = XcmExecutor<XcmConfig>;
+ type XcmTeleportFilter = Everything;
+ type XcmReserveTransferFilter = Everything;
+ type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;
+ type LocationInverter = LocationInverter<Ancestry>;
+ type Origin = Origin;
+ type Call = Call;
+ const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;
+ type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;
+}
+
+impl cumulus_pallet_xcm::Config for Runtime {
+ type Event = Event;
+ type XcmExecutor = XcmExecutor<XcmConfig>;
+}
+
+impl cumulus_pallet_xcmp_queue::Config for Runtime {
+ type Event = Event;
+ type XcmExecutor = XcmExecutor<XcmConfig>;
+ type ChannelInfo = ParachainSystem;
+ type VersionWrapper = ();
+ type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;
+ type ControllerOrigin = EnsureRoot<AccountId>;
+ type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin;
+}
+
+impl cumulus_pallet_dmp_queue::Config for Runtime {
+ type Event = Event;
+ type XcmExecutor = XcmExecutor<XcmConfig>;
+ type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;
+}
+
+impl pallet_aura::Config for Runtime {
+ type AuthorityId = AuraId;
+ type DisabledValidators = ();
+ type MaxAuthorities = MaxAuthorities;
+}
+
+parameter_types! {
+ pub TreasuryAccountId: AccountId = TreasuryModuleId::get().into_account();
+ pub const CollectionCreationPrice: Balance = 2 * UNIQUE;
+}
+
+impl pallet_common::Config for Runtime {
+ type Event = Event;
+ type EvmBackwardsAddressMapping = up_evm_mapping::MapBackwardsAddressTruncated;
+ type EvmAddressMapping = HashedAddressMapping<Self::Hashing>;
+ type CrossAccountId = pallet_common::account::BasicCrossAccountId<Self>;
+
+ type Currency = Balances;
+ type CollectionCreationPrice = CollectionCreationPrice;
+ type TreasuryAccountId = TreasuryAccountId;
+}
+
+impl pallet_fungible::Config for Runtime {
+ type WeightInfo = pallet_fungible::weights::SubstrateWeight<Self>;
+}
+impl pallet_refungible::Config for Runtime {
+ type WeightInfo = pallet_refungible::weights::SubstrateWeight<Self>;
+}
+impl pallet_nonfungible::Config for Runtime {
+ type WeightInfo = pallet_nonfungible::weights::SubstrateWeight<Self>;
+}
+
+impl pallet_unique::Config for Runtime {
+ type Event = Event;
+ type WeightInfo = pallet_unique::weights::SubstrateWeight<Self>;
+}
+
+parameter_types! {
+ pub const InflationBlockInterval: BlockNumber = 100; // every time per how many blocks inflation is applied
+}
+
+/// Used for the pallet inflation
+impl pallet_inflation::Config for Runtime {
+ type Currency = Balances;
+ type TreasuryAccountId = TreasuryAccountId;
+ type InflationBlockInterval = InflationBlockInterval;
+ type BlockNumberProvider = RelayChainBlockNumberProvider<Runtime>;
+}
+
+// parameter_types! {
+// pub MaximumSchedulerWeight: Weight = Perbill::from_percent(50) *
+// RuntimeBlockWeights::get().max_block;
+// pub const MaxScheduledPerBlock: u32 = 50;
+// }
+
+type EvmSponsorshipHandler = (
+ pallet_unique::UniqueEthSponsorshipHandler<Runtime>,
+ pallet_evm_contract_helpers::HelpersContractSponsoring<Runtime>,
+);
+type SponsorshipHandler = (
+ pallet_unique::UniqueSponsorshipHandler<Runtime>,
+ //pallet_contract_helpers::ContractSponsorshipHandler<Runtime>,
+ pallet_evm_transaction_payment::BridgeSponsorshipHandler<Runtime>,
+);
+
+// impl pallet_unq_scheduler::Config for Runtime {
+// type Event = Event;
+// type Origin = Origin;
+// type PalletsOrigin = OriginCaller;
+// type Call = Call;
+// type MaximumWeight = MaximumSchedulerWeight;
+// type ScheduleOrigin = EnsureSigned<AccountId>;
+// type MaxScheduledPerBlock = MaxScheduledPerBlock;
+// type SponsorshipHandler = SponsorshipHandler;
+// type WeightInfo = ();
+// }
+
+impl pallet_evm_transaction_payment::Config for Runtime {
+ type EvmSponsorshipHandler = EvmSponsorshipHandler;
+ type Currency = Balances;
+ type EvmAddressMapping = HashedAddressMapping<Self::Hashing>;
+ type EvmBackwardsAddressMapping = up_evm_mapping::MapBackwardsAddressTruncated;
+}
+
+impl pallet_charge_transaction::Config for Runtime {
+ type SponsorshipHandler = SponsorshipHandler;
+}
+
+// impl pallet_contract_helpers::Config for Runtime {
+// type DefaultSponsoringRateLimit = DefaultSponsoringRateLimit;
+// }
+
+parameter_types! {
+ // 0x842899ECF380553E8a4de75bF534cdf6fBF64049
+ pub const HelpersContractAddress: H160 = H160([
+ 0x84, 0x28, 0x99, 0xec, 0xf3, 0x80, 0x55, 0x3e, 0x8a, 0x4d, 0xe7, 0x5b, 0xf5, 0x34, 0xcd, 0xf6, 0xfb, 0xf6, 0x40, 0x49,
+ ]);
+}
+
+impl pallet_evm_contract_helpers::Config for Runtime {
+ type ContractAddress = HelpersContractAddress;
+ type DefaultSponsoringRateLimit = DefaultSponsoringRateLimit;
+}
+
+construct_runtime!(
+ pub enum Runtime where
+ Block = Block,
+ NodeBlock = opaque::Block,
+ UncheckedExtrinsic = UncheckedExtrinsic
+ {
+ ParachainSystem: cumulus_pallet_parachain_system::{Pallet, Call, Config, Storage, Inherent, Event<T>, ValidateUnsigned} = 20,
+ ParachainInfo: parachain_info::{Pallet, Storage, Config} = 21,
+
+ Aura: pallet_aura::{Pallet, Config<T>} = 22,
+ AuraExt: cumulus_pallet_aura_ext::{Pallet, Config} = 23,
+
+ Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>} = 30,
+ RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Pallet, Storage} = 31,
+ Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent} = 32,
+ TransactionPayment: pallet_transaction_payment::{Pallet, Storage} = 33,
+ Treasury: pallet_treasury::{Pallet, Call, Storage, Config, Event<T>} = 34,
+ Sudo: pallet_sudo::{Pallet, Call, Storage, Config<T>, Event<T>} = 35,
+ System: frame_system::{Pallet, Call, Storage, Config, Event<T>} = 36,
+ Vesting: orml_vesting::{Pallet, Storage, Call, Event<T>, Config<T>} = 37,
+ // Vesting: pallet_vesting::{Pallet, Call, Config<T>, Storage, Event<T>} = 37,
+ // Contracts: pallet_contracts::{Pallet, Call, Storage, Event<T>} = 38,
+
+ // XCM helpers.
+ XcmpQueue: cumulus_pallet_xcmp_queue::{Pallet, Call, Storage, Event<T>} = 50,
+ PolkadotXcm: pallet_xcm::{Pallet, Call, Event<T>, Origin} = 51,
+ CumulusXcm: cumulus_pallet_xcm::{Pallet, Call, Event<T>, Origin} = 52,
+ DmpQueue: cumulus_pallet_dmp_queue::{Pallet, Call, Storage, Event<T>} = 53,
+
+ // Unique Pallets
+ Inflation: pallet_inflation::{Pallet, Call, Storage} = 60,
+ Unique: pallet_unique::{Pallet, Call, Storage, Event<T>} = 61,
+ // Scheduler: pallet_unq_scheduler::{Pallet, Call, Storage, Event<T>} = 62,
+ // free = 63
+ Charging: pallet_charge_transaction::{Pallet, Call, Storage } = 64,
+ // ContractHelpers: pallet_contract_helpers::{Pallet, Call, Storage} = 65,
+ Common: pallet_common::{Pallet, Storage, Event<T>} = 66,
+ Fungible: pallet_fungible::{Pallet, Storage} = 67,
+ Refungible: pallet_refungible::{Pallet, Storage} = 68,
+ Nonfungible: pallet_nonfungible::{Pallet, Storage} = 69,
+
+ // Frontier
+ EVM: pallet_evm::{Pallet, Config, Call, Storage, Event<T>} = 100,
+ Ethereum: pallet_ethereum::{Pallet, Config, Call, Storage, Event, Origin} = 101,
+
+ EvmCoderSubstrate: pallet_evm_coder_substrate::{Pallet, Storage} = 150,
+ EvmContractHelpers: pallet_evm_contract_helpers::{Pallet, Storage} = 151,
+ EvmTransactionPayment: pallet_evm_transaction_payment::{Pallet} = 152,
+ EvmMigration: pallet_evm_migration::{Pallet, Call, Storage} = 153,
+ }
+);
+
+pub struct TransactionConverter;
+
+impl fp_rpc::ConvertTransaction<UncheckedExtrinsic> for TransactionConverter {
+ fn convert_transaction(&self, transaction: pallet_ethereum::Transaction) -> UncheckedExtrinsic {
+ UncheckedExtrinsic::new_unsigned(
+ pallet_ethereum::Call::<Runtime>::transact { transaction }.into(),
+ )
+ }
+}
+
+impl fp_rpc::ConvertTransaction<opaque::UncheckedExtrinsic> for TransactionConverter {
+ fn convert_transaction(
+ &self,
+ transaction: pallet_ethereum::Transaction,
+ ) -> opaque::UncheckedExtrinsic {
+ let extrinsic = UncheckedExtrinsic::new_unsigned(
+ pallet_ethereum::Call::<Runtime>::transact { transaction }.into(),
+ );
+ let encoded = extrinsic.encode();
+ opaque::UncheckedExtrinsic::decode(&mut &encoded[..])
+ .expect("Encoded extrinsic is always valid")
+ }
+}
+
+/// The address format for describing accounts.
+pub type Address = sp_runtime::MultiAddress<AccountId, ()>;
+/// Block header type as expected by this runtime.
+pub type Header = generic::Header<BlockNumber, BlakeTwo256>;
+/// Block type as expected by this runtime.
+pub type Block = generic::Block<Header, UncheckedExtrinsic>;
+/// A Block signed with a Justification
+pub type SignedBlock = generic::SignedBlock<Block>;
+/// BlockId type as expected by this runtime.
+pub type BlockId = generic::BlockId<Block>;
+/// The SignedExtension to the basic transaction logic.
+pub type SignedExtra = (
+ frame_system::CheckSpecVersion<Runtime>,
+ // system::CheckTxVersion<Runtime>,
+ frame_system::CheckGenesis<Runtime>,
+ frame_system::CheckEra<Runtime>,
+ frame_system::CheckNonce<Runtime>,
+ frame_system::CheckWeight<Runtime>,
+ pallet_charge_transaction::ChargeTransactionPayment<Runtime>,
+ //pallet_contract_helpers::ContractHelpersExtension<Runtime>,
+);
+/// Unchecked extrinsic type as expected by this runtime.
+pub type UncheckedExtrinsic =
+ fp_self_contained::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;
+/// Extrinsic type that has already been checked.
+pub type CheckedExtrinsic = fp_self_contained::CheckedExtrinsic<AccountId, Call, SignedExtra, H160>;
+/// Executive: handles dispatch to the various modules.
+pub type Executive = frame_executive::Executive<
+ Runtime,
+ Block,
+ frame_system::ChainContext<Runtime>,
+ Runtime,
+ AllPalletsReversedWithSystemFirst,
+>;
+
+impl_opaque_keys! {
+ pub struct SessionKeys {
+ pub aura: Aura,
+ }
+}
+
+impl fp_self_contained::SelfContainedCall for Call {
+ type SignedInfo = H160;
+
+ fn is_self_contained(&self) -> bool {
+ match self {
+ Call::Ethereum(call) => call.is_self_contained(),
+ _ => false,
+ }
+ }
+
+ fn check_self_contained(&self) -> Option<Result<Self::SignedInfo, TransactionValidityError>> {
+ match self {
+ Call::Ethereum(call) => call.check_self_contained(),
+ _ => None,
+ }
+ }
+
+ fn validate_self_contained(&self, info: &Self::SignedInfo) -> Option<TransactionValidity> {
+ match self {
+ Call::Ethereum(call) => call.validate_self_contained(info),
+ _ => None,
+ }
+ }
+
+ fn pre_dispatch_self_contained(
+ &self,
+ info: &Self::SignedInfo,
+ ) -> Option<Result<(), TransactionValidityError>> {
+ match self {
+ Call::Ethereum(call) => call.pre_dispatch_self_contained(info),
+ _ => None,
+ }
+ }
+
+ fn apply_self_contained(
+ self,
+ info: Self::SignedInfo,
+ ) -> Option<sp_runtime::DispatchResultWithInfo<PostDispatchInfoOf<Self>>> {
+ match self {
+ call @ Call::Ethereum(pallet_ethereum::Call::transact { .. }) => Some(call.dispatch(
+ Origin::from(pallet_ethereum::RawOrigin::EthereumTransaction(info)),
+ )),
+ _ => None,
+ }
+ }
+}
+
+macro_rules! dispatch_unique_runtime {
+ ($collection:ident.$method:ident($($name:ident),*)) => {{
+ use pallet_unique::dispatch::Dispatched;
+
+ let collection = Dispatched::dispatch(<pallet_common::CollectionHandle<Runtime>>::try_get($collection)?);
+ let dispatch = collection.as_dyn();
+
+ Ok(dispatch.$method($($name),*))
+ }};
+}
+
+impl_common_runtime_apis!();
+
+struct CheckInherents;
+
+impl cumulus_pallet_parachain_system::CheckInherents<Block> for CheckInherents {
+ fn check_inherents(
+ block: &Block,
+ relay_state_proof: &cumulus_pallet_parachain_system::RelayChainStateProof,
+ ) -> sp_inherents::CheckInherentsResult {
+ let relay_chain_slot = relay_state_proof
+ .read_slot()
+ .expect("Could not read the relay chain slot from the proof");
+
+ let inherent_data =
+ cumulus_primitives_timestamp::InherentDataProvider::from_relay_chain_slot_and_duration(
+ relay_chain_slot,
+ sp_std::time::Duration::from_secs(6),
+ )
+ .create_inherent_data()
+ .expect("Could not create the timestamp inherent data");
+
+ inherent_data.check_extrinsics(block)
+ }
+}
+
+cumulus_pallet_parachain_system::register_validate_block!(
+ Runtime = Runtime,
+ BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor::<Runtime, Executive>,
+ CheckInherents = CheckInherents,
+);
runtime/src/lib.rsdiffbeforeafterboth--- a/runtime/src/lib.rs
+++ /dev/null
@@ -1,1592 +0,0 @@
-// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.
-// This file is part of Unique Network.
-
-// Unique Network is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-
-// Unique Network is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License
-// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
-
-//! The Substrate Node Template runtime. This can be compiled with `#[no_std]`, ready for Wasm.
-
-#![cfg_attr(not(feature = "std"), no_std)]
-// `construct_runtime!` does a lot of recursion and requires us to increase the limit to 256.
-#![recursion_limit = "1024"]
-#![allow(clippy::from_over_into, clippy::identity_op)]
-#![allow(clippy::fn_to_numeric_cast_with_truncation)]
-// Make the WASM binary available.
-#[cfg(feature = "std")]
-include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
-
-use sp_api::impl_runtime_apis;
-use sp_core::{crypto::KeyTypeId, OpaqueMetadata, H256, U256, H160};
-use sp_runtime::DispatchError;
-// #[cfg(any(feature = "std", test))]
-// pub use sp_runtime::BuildStorage;
-
-use sp_runtime::{
- Permill, Perbill, Percent, create_runtime_str, generic, impl_opaque_keys,
- traits::{
- AccountIdLookup, BlakeTwo256, Block as BlockT, IdentifyAccount, Verify,
- AccountIdConversion, Zero,
- },
- transaction_validity::{TransactionSource, TransactionValidity},
- ApplyExtrinsicResult, MultiSignature, RuntimeAppPublic,
-};
-
-use sp_std::prelude::*;
-
-#[cfg(feature = "std")]
-use sp_version::NativeVersion;
-use sp_version::RuntimeVersion;
-pub use pallet_transaction_payment::{
- Multiplier, TargetedFeeAdjustment, FeeDetails, RuntimeDispatchInfo,
-};
-// A few exports that help ease life for downstream crates.
-pub use pallet_balances::Call as BalancesCall;
-pub use pallet_evm::{EnsureAddressTruncated, HashedAddressMapping, Runner};
-pub use frame_support::{
- construct_runtime, match_type,
- dispatch::DispatchResult,
- PalletId, parameter_types, StorageValue, ConsensusEngineId,
- traits::{
- tokens::currency::Currency as CurrencyT, OnUnbalanced as OnUnbalancedT, Everything,
- Currency, ExistenceRequirement, Get, IsInVec, KeyOwnerProofSystem, LockIdentifier,
- OnUnbalanced, Randomness, FindAuthor,
- },
- weights::{
- constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND},
- DispatchClass, DispatchInfo, GetDispatchInfo, IdentityFee, Pays, PostDispatchInfo, Weight,
- WeightToFeePolynomial, WeightToFeeCoefficient, WeightToFeeCoefficients,
- },
-};
-use up_data_structs::*;
-// use pallet_contracts::weights::WeightInfo;
-// #[cfg(any(feature = "std", test))]
-use frame_system::{
- self as frame_system, EnsureRoot, EnsureSigned,
- limits::{BlockWeights, BlockLength},
-};
-use sp_arithmetic::{
- traits::{BaseArithmetic, Unsigned},
-};
-use smallvec::smallvec;
-use codec::{Encode, Decode};
-use pallet_evm::{Account as EVMAccount, FeeCalculator, GasWeightMapping, OnMethodCall};
-use fp_rpc::TransactionStatus;
-use sp_runtime::{
- traits::{BlockNumberProvider, Dispatchable, PostDispatchInfoOf, Saturating},
- transaction_validity::TransactionValidityError,
- SaturatedConversion,
-};
-
-// pub use pallet_timestamp::Call as TimestampCall;
-pub use sp_consensus_aura::sr25519::AuthorityId as AuraId;
-
-// Polkadot imports
-use pallet_xcm::XcmPassthrough;
-use polkadot_parachain::primitives::Sibling;
-use xcm::v1::{BodyId, Junction::*, MultiLocation, NetworkId, Junctions::*};
-use xcm_builder::{
- AccountId32Aliases, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, CurrencyAdapter,
- EnsureXcmOrigin, FixedWeightBounds, LocationInverter, NativeAsset, ParentAsSuperuser,
- RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia,
- SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit,
- ParentIsPreset,
-};
-use xcm_executor::{Config, XcmExecutor, Assets};
-use sp_std::{marker::PhantomData};
-
-use xcm::latest::{
- // Xcm,
- AssetId::{Concrete},
- Fungibility::Fungible as XcmFungible,
- MultiAsset,
- Error as XcmError,
-};
-use xcm_executor::traits::{MatchesFungible, WeightTrader};
-//use xcm_executor::traits::MatchesFungible;
-use sp_runtime::traits::CheckedConversion;
-
-// mod chain_extension;
-// use crate::chain_extension::{NFTExtension, Imbalance};
-
-/// An index to a block.
-pub type BlockNumber = u32;
-
-/// Alias to 512-bit hash when used in the context of a transaction signature on the chain.
-pub type Signature = MultiSignature;
-
-/// Some way of identifying an account on the chain. We intentionally make it equivalent
-/// to the public key of our transaction signing scheme.
-pub type AccountId = <<Signature as Verify>::Signer as IdentifyAccount>::AccountId;
-
-pub type CrossAccountId = pallet_common::account::BasicCrossAccountId<Runtime>;
-
-/// The type for looking up accounts. We don't expect more than 4 billion of them, but you
-/// never know...
-pub type AccountIndex = u32;
-
-/// Balance of an account.
-pub type Balance = u128;
-
-/// Index of a transaction in the chain.
-pub type Index = u32;
-
-/// A hash of some data used by the chain.
-pub type Hash = sp_core::H256;
-
-/// Digest item type.
-pub type DigestItem = generic::DigestItem;
-
-/// Opaque types. These are used by the CLI to instantiate machinery that don't need to know
-/// the specifics of the runtime. They can then be made to be agnostic over specific formats
-/// of data like extrinsics, allowing for them to continue syncing the network through upgrades
-/// to even the core data structures.
-pub mod opaque {
- use super::*;
-
- pub use sp_runtime::OpaqueExtrinsic as UncheckedExtrinsic;
-
- /// Opaque block type.
- pub type Block = generic::Block<Header, UncheckedExtrinsic>;
-
- pub type SessionHandlers = ();
-
- impl_opaque_keys! {
- pub struct SessionKeys {
- pub aura: Aura,
- }
- }
-}
-
-/// This runtime version.
-pub const VERSION: RuntimeVersion = RuntimeVersion {
- spec_name: create_runtime_str!("opal"),
- impl_name: create_runtime_str!("opal"),
- authoring_version: 1,
- spec_version: 917004,
- impl_version: 0,
- apis: RUNTIME_API_VERSIONS,
- transaction_version: 1,
- state_version: 0,
-};
-
-pub const MILLISECS_PER_BLOCK: u64 = 12000;
-
-pub const SLOT_DURATION: u64 = MILLISECS_PER_BLOCK;
-
-// These time units are defined in number of blocks.
-pub const MINUTES: BlockNumber = 60_000 / (MILLISECS_PER_BLOCK as BlockNumber);
-pub const HOURS: BlockNumber = MINUTES * 60;
-pub const DAYS: BlockNumber = HOURS * 24;
-
-parameter_types! {
- pub const DefaultSponsoringRateLimit: BlockNumber = 1 * DAYS;
-}
-
-#[derive(codec::Encode, codec::Decode)]
-pub enum XCMPMessage<XAccountId, XBalance> {
- /// Transfer tokens to the given account from the Parachain account.
- TransferToken(XAccountId, XBalance),
-}
-
-/// The version information used to identify this runtime when compiled natively.
-#[cfg(feature = "std")]
-pub fn native_version() -> NativeVersion {
- NativeVersion {
- runtime_version: VERSION,
- can_author_with: Default::default(),
- }
-}
-
-type NegativeImbalance = <Balances as Currency<AccountId>>::NegativeImbalance;
-
-pub struct DealWithFees;
-impl OnUnbalanced<NegativeImbalance> for DealWithFees {
- fn on_unbalanceds<B>(mut fees_then_tips: impl Iterator<Item = NegativeImbalance>) {
- if let Some(fees) = fees_then_tips.next() {
- // for fees, 100% to treasury
- let mut split = fees.ration(100, 0);
- if let Some(tips) = fees_then_tips.next() {
- // for tips, if any, 100% to treasury
- tips.ration_merge_into(100, 0, &mut split);
- }
- Treasury::on_unbalanced(split.0);
- // Author::on_unbalanced(split.1);
- }
- }
-}
-
-/// We assume that ~10% of the block weight is consumed by `on_initalize` handlers.
-/// This is used to limit the maximal weight of a single extrinsic.
-const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(10);
-/// We allow `Normal` extrinsics to fill up the block up to 75%, the rest can be used
-/// by Operational extrinsics.
-const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75);
-/// We allow for 2 seconds of compute with a 6 second average block time.
-const MAXIMUM_BLOCK_WEIGHT: Weight = WEIGHT_PER_SECOND / 2;
-
-parameter_types! {
- pub const BlockHashCount: BlockNumber = 2400;
- pub RuntimeBlockLength: BlockLength =
- BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);
- pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);
- pub const MaximumBlockLength: u32 = 5 * 1024 * 1024;
- pub RuntimeBlockWeights: BlockWeights = BlockWeights::builder()
- .base_block(BlockExecutionWeight::get())
- .for_class(DispatchClass::all(), |weights| {
- weights.base_extrinsic = ExtrinsicBaseWeight::get();
- })
- .for_class(DispatchClass::Normal, |weights| {
- weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT);
- })
- .for_class(DispatchClass::Operational, |weights| {
- weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT);
- // Operational transactions have some extra reserved space, so that they
- // are included even if block reached `MAXIMUM_BLOCK_WEIGHT`.
- weights.reserved = Some(
- MAXIMUM_BLOCK_WEIGHT - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT
- );
- })
- .avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO)
- .build_or_panic();
- pub const Version: RuntimeVersion = VERSION;
- pub const SS58Prefix: u8 = 42;
-}
-
-/*
-8880 - Unique
-8881 - Quartz
-8882 - Opal
-*/
-parameter_types! {
- pub const ChainId: u64 = 8882;
-}
-
-pub struct FixedFee;
-impl FeeCalculator for FixedFee {
- fn min_gas_price() -> U256 {
- // Targeting 0.15 UNQ per transfer
- 1_018_751_825_264u64.into()
- }
-}
-
-// Assuming slowest ethereum opcode is SSTORE, with gas price of 20000 as our worst case
-// (contract, which only writes a lot of data),
-// approximating on top of our real store write weight
-parameter_types! {
- pub const WritesPerSecond: u64 = WEIGHT_PER_SECOND / <Runtime as frame_system::Config>::DbWeight::get().write;
- pub const GasPerSecond: u64 = WritesPerSecond::get() * 20000;
- pub const WeightPerGas: u64 = WEIGHT_PER_SECOND / GasPerSecond::get();
-}
-
-/// Limiting EVM execution to 50% of block for substrate users and management tasks
-/// EVM transaction consumes more weight than substrate's, so we can't rely on them being
-/// scheduled fairly
-const EVM_DISPATCH_RATIO: Perbill = Perbill::from_percent(50);
-parameter_types! {
- pub BlockGasLimit: U256 = U256::from(NORMAL_DISPATCH_RATIO * EVM_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT / WeightPerGas::get());
-}
-
-pub enum FixedGasWeightMapping {}
-impl GasWeightMapping for FixedGasWeightMapping {
- fn gas_to_weight(gas: u64) -> Weight {
- gas.saturating_mul(WeightPerGas::get())
- }
- fn weight_to_gas(weight: Weight) -> u64 {
- weight / WeightPerGas::get()
- }
-}
-
-impl pallet_evm::Config for Runtime {
- type BlockGasLimit = BlockGasLimit;
- type FeeCalculator = FixedFee;
- type GasWeightMapping = FixedGasWeightMapping;
- type BlockHashMapping = pallet_ethereum::EthereumBlockHashMapping<Self>;
- type CallOrigin = EnsureAddressTruncated;
- type WithdrawOrigin = EnsureAddressTruncated;
- type AddressMapping = HashedAddressMapping<Self::Hashing>;
- type PrecompilesType = ();
- type PrecompilesValue = ();
- type Currency = Balances;
- type Event = Event;
- type OnMethodCall = (
- pallet_evm_migration::OnMethodCall<Self>,
- pallet_unique::UniqueErcSupport<Self>,
- pallet_evm_contract_helpers::HelpersOnMethodCall<Self>,
- );
- type OnCreate = pallet_evm_contract_helpers::HelpersOnCreate<Self>;
- type ChainId = ChainId;
- type Runner = pallet_evm::runner::stack::Runner<Self>;
- type OnChargeTransaction = pallet_evm_transaction_payment::OnChargeTransaction<Self>;
- type TransactionValidityHack = pallet_evm_transaction_payment::TransactionValidityHack<Self>;
- type FindAuthor = EthereumFindAuthor<Aura>;
-}
-
-impl pallet_evm_migration::Config for Runtime {
- type WeightInfo = pallet_evm_migration::weights::SubstrateWeight<Self>;
-}
-
-pub struct EthereumFindAuthor<F>(core::marker::PhantomData<F>);
-impl<F: FindAuthor<u32>> FindAuthor<H160> for EthereumFindAuthor<F> {
- fn find_author<'a, I>(digests: I) -> Option<H160>
- where
- I: 'a + IntoIterator<Item = (ConsensusEngineId, &'a [u8])>,
- {
- if let Some(author_index) = F::find_author(digests) {
- let authority_id = Aura::authorities()[author_index as usize].clone();
- return Some(H160::from_slice(&authority_id.to_raw_vec()[4..24]));
- }
- None
- }
-}
-
-impl pallet_ethereum::Config for Runtime {
- type Event = Event;
- type StateRoot = pallet_ethereum::IntermediateStateRoot;
-}
-
-impl pallet_randomness_collective_flip::Config for Runtime {}
-
-impl frame_system::Config for Runtime {
- /// The data to be stored in an account.
- type AccountData = pallet_balances::AccountData<Balance>;
- /// The identifier used to distinguish between accounts.
- type AccountId = AccountId;
- /// The basic call filter to use in dispatchable.
- type BaseCallFilter = Everything;
- /// Maximum number of block number to block hash mappings to keep (oldest pruned first).
- type BlockHashCount = BlockHashCount;
- /// The maximum length of a block (in bytes).
- type BlockLength = RuntimeBlockLength;
- /// The index type for blocks.
- type BlockNumber = BlockNumber;
- /// The weight of the overhead invoked on the block import process, independent of the extrinsics included in that block.
- type BlockWeights = RuntimeBlockWeights;
- /// The aggregated dispatch type that is available for extrinsics.
- type Call = Call;
- /// The weight of database operations that the runtime can invoke.
- type DbWeight = RocksDbWeight;
- /// The ubiquitous event type.
- type Event = Event;
- /// The type for hashing blocks and tries.
- type Hash = Hash;
- /// The hashing algorithm used.
- type Hashing = BlakeTwo256;
- /// The header type.
- type Header = generic::Header<BlockNumber, BlakeTwo256>;
- /// The index type for storing how many extrinsics an account has signed.
- type Index = Index;
- /// The lookup mechanism to get account ID from whatever is passed in dispatchers.
- type Lookup = AccountIdLookup<AccountId, ()>;
- /// What to do if an account is fully reaped from the system.
- type OnKilledAccount = ();
- /// What to do if a new account is created.
- type OnNewAccount = ();
- type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode<Self>;
- /// The ubiquitous origin type.
- type Origin = Origin;
- /// This type is being generated by `construct_runtime!`.
- type PalletInfo = PalletInfo;
- /// This is used as an identifier of the chain. 42 is the generic substrate prefix.
- type SS58Prefix = SS58Prefix;
- /// Weight information for the extrinsics of this pallet.
- type SystemWeightInfo = frame_system::weights::SubstrateWeight<Self>;
- /// Version of the runtime.
- type Version = Version;
- type MaxConsumers = ConstU32<16>;
-}
-
-parameter_types! {
- pub const MinimumPeriod: u64 = SLOT_DURATION / 2;
-}
-
-impl pallet_timestamp::Config for Runtime {
- /// A timestamp: milliseconds since the unix epoch.
- type Moment = u64;
- type OnTimestampSet = ();
- type MinimumPeriod = MinimumPeriod;
- type WeightInfo = ();
-}
-
-parameter_types! {
- // pub const ExistentialDeposit: u128 = 500;
- pub const ExistentialDeposit: u128 = 0;
- pub const MaxLocks: u32 = 50;
-}
-
-impl pallet_balances::Config for Runtime {
- type MaxLocks = MaxLocks;
- type MaxReserves = ();
- type ReserveIdentifier = [u8; 8];
- /// The type for recording an account's balance.
- type Balance = Balance;
- /// The ubiquitous event type.
- type Event = Event;
- type DustRemoval = Treasury;
- type ExistentialDeposit = ExistentialDeposit;
- type AccountStore = System;
- type WeightInfo = pallet_balances::weights::SubstrateWeight<Self>;
-}
-
-pub const MICROUNIQUE: Balance = 1_000_000_000_000;
-pub const MILLIUNIQUE: Balance = 1_000 * MICROUNIQUE;
-pub const CENTIUNIQUE: Balance = 10 * MILLIUNIQUE;
-pub const UNIQUE: Balance = 100 * CENTIUNIQUE;
-
-pub const fn deposit(items: u32, bytes: u32) -> Balance {
- items as Balance * 15 * CENTIUNIQUE + (bytes as Balance) * 6 * CENTIUNIQUE
-}
-
-/*
-parameter_types! {
- pub TombstoneDeposit: Balance = deposit(
- 1,
- sp_std::mem::size_of::<pallet_contracts::Pallet<Runtime>> as u32,
- );
- pub DepositPerContract: Balance = TombstoneDeposit::get();
- pub const DepositPerStorageByte: Balance = deposit(0, 1);
- pub const DepositPerStorageItem: Balance = deposit(1, 0);
- pub RentFraction: Perbill = Perbill::from_rational(1u32, 30 * DAYS);
- pub const SurchargeReward: Balance = 150 * MILLIUNIQUE;
- pub const SignedClaimHandicap: u32 = 2;
- pub const MaxDepth: u32 = 32;
- pub const MaxValueSize: u32 = 16 * 1024;
- pub const MaxCodeSize: u32 = 1024 * 1024 * 25; // 25 Mb
- // The lazy deletion runs inside on_initialize.
- pub DeletionWeightLimit: Weight = AVERAGE_ON_INITIALIZE_RATIO *
- RuntimeBlockWeights::get().max_block;
- // The weight needed for decoding the queue should be less or equal than a fifth
- // of the overall weight dedicated to the lazy deletion.
- pub DeletionQueueDepth: u32 = ((DeletionWeightLimit::get() / (
- <Runtime as pallet_contracts::Config>::WeightInfo::on_initialize_per_queue_item(1) -
- <Runtime as pallet_contracts::Config>::WeightInfo::on_initialize_per_queue_item(0)
- )) / 5) as u32;
- pub Schedule: pallet_contracts::Schedule<Runtime> = Default::default();
-}
-
-impl pallet_contracts::Config for Runtime {
- type Time = Timestamp;
- type Randomness = RandomnessCollectiveFlip;
- type Currency = Balances;
- type Event = Event;
- type RentPayment = ();
- type SignedClaimHandicap = SignedClaimHandicap;
- type TombstoneDeposit = TombstoneDeposit;
- type DepositPerContract = DepositPerContract;
- type DepositPerStorageByte = DepositPerStorageByte;
- type DepositPerStorageItem = DepositPerStorageItem;
- type RentFraction = RentFraction;
- type SurchargeReward = SurchargeReward;
- type WeightPrice = pallet_transaction_payment::Pallet<Self>;
- type WeightInfo = pallet_contracts::weights::SubstrateWeight<Self>;
- type ChainExtension = NFTExtension;
- type DeletionQueueDepth = DeletionQueueDepth;
- type DeletionWeightLimit = DeletionWeightLimit;
- type Schedule = Schedule;
- type CallStack = [pallet_contracts::Frame<Self>; 31];
-}
-*/
-
-parameter_types! {
- pub const TransactionByteFee: Balance = 501 * MICROUNIQUE; // Targeting 0.1 Unique per NFT transfer
- /// This value increases the priority of `Operational` transactions by adding
- /// a "virtual tip" that's equal to the `OperationalFeeMultiplier * final_fee`.
- pub const OperationalFeeMultiplier: u8 = 5;
-}
-
-/// Linear implementor of `WeightToFeePolynomial`
-pub struct LinearFee<T>(sp_std::marker::PhantomData<T>);
-
-impl<T> WeightToFeePolynomial for LinearFee<T>
-where
- T: BaseArithmetic + From<u32> + Copy + Unsigned,
-{
- type Balance = T;
-
- fn polynomial() -> WeightToFeeCoefficients<Self::Balance> {
- smallvec!(WeightToFeeCoefficient {
- // Targeting 0.1 Unique per NFT transfer
- coeff_integer: 142_688_000u32.into(),
- coeff_frac: Perbill::zero(),
- negative: false,
- degree: 1,
- })
- }
-}
-
-impl pallet_transaction_payment::Config for Runtime {
- type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter<Balances, DealWithFees>;
- type TransactionByteFee = TransactionByteFee;
- type OperationalFeeMultiplier = OperationalFeeMultiplier;
- type WeightToFee = LinearFee<Balance>;
- type FeeMultiplierUpdate = ();
-}
-
-parameter_types! {
- pub const ProposalBond: Permill = Permill::from_percent(5);
- pub const ProposalBondMinimum: Balance = 1 * UNIQUE;
- pub const ProposalBondMaximum: Balance = 1000 * UNIQUE;
- pub const SpendPeriod: BlockNumber = 5 * MINUTES;
- pub const Burn: Permill = Permill::from_percent(0);
- pub const TipCountdown: BlockNumber = 1 * DAYS;
- pub const TipFindersFee: Percent = Percent::from_percent(20);
- pub const TipReportDepositBase: Balance = 1 * UNIQUE;
- pub const DataDepositPerByte: Balance = 1 * CENTIUNIQUE;
- pub const BountyDepositBase: Balance = 1 * UNIQUE;
- pub const BountyDepositPayoutDelay: BlockNumber = 1 * DAYS;
- pub const TreasuryModuleId: PalletId = PalletId(*b"py/trsry");
- pub const BountyUpdatePeriod: BlockNumber = 14 * DAYS;
- pub const MaximumReasonLength: u32 = 16384;
- pub const BountyCuratorDeposit: Permill = Permill::from_percent(50);
- pub const BountyValueMinimum: Balance = 5 * UNIQUE;
- pub const MaxApprovals: u32 = 100;
-}
-
-impl pallet_treasury::Config for Runtime {
- type PalletId = TreasuryModuleId;
- type Currency = Balances;
- type ApproveOrigin = EnsureRoot<AccountId>;
- type RejectOrigin = EnsureRoot<AccountId>;
- type Event = Event;
- type OnSlash = ();
- type ProposalBond = ProposalBond;
- type ProposalBondMinimum = ProposalBondMinimum;
- type ProposalBondMaximum = ProposalBondMaximum;
- type SpendPeriod = SpendPeriod;
- type Burn = Burn;
- type BurnDestination = ();
- type SpendFunds = ();
- type WeightInfo = pallet_treasury::weights::SubstrateWeight<Self>;
- type MaxApprovals = MaxApprovals;
-}
-
-impl pallet_sudo::Config for Runtime {
- type Event = Event;
- type Call = Call;
-}
-
-pub struct RelayChainBlockNumberProvider<T>(sp_std::marker::PhantomData<T>);
-
-impl<T: cumulus_pallet_parachain_system::Config> BlockNumberProvider
- for RelayChainBlockNumberProvider<T>
-{
- type BlockNumber = BlockNumber;
-
- fn current_block_number() -> Self::BlockNumber {
- cumulus_pallet_parachain_system::Pallet::<T>::validation_data()
- .map(|d| d.relay_parent_number)
- .unwrap_or_default()
- }
-}
-
-parameter_types! {
- pub const MinVestedTransfer: Balance = 10 * UNIQUE;
- pub const MaxVestingSchedules: u32 = 28;
-}
-
-impl orml_vesting::Config for Runtime {
- type Event = Event;
- type Currency = pallet_balances::Pallet<Runtime>;
- type MinVestedTransfer = MinVestedTransfer;
- type VestedTransferOrigin = EnsureSigned<AccountId>;
- type WeightInfo = ();
- type MaxVestingSchedules = MaxVestingSchedules;
- type BlockNumberProvider = RelayChainBlockNumberProvider<Runtime>;
-}
-
-parameter_types! {
- pub const ReservedDmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;
- pub const ReservedXcmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;
-}
-
-impl cumulus_pallet_parachain_system::Config for Runtime {
- type Event = Event;
- type SelfParaId = parachain_info::Pallet<Self>;
- type OnSystemEvent = ();
- // type DownwardMessageHandlers = cumulus_primitives_utility::UnqueuedDmpAsParent<
- // MaxDownwardMessageWeight,
- // XcmExecutor<XcmConfig>,
- // Call,
- // >;
- type OutboundXcmpMessageSource = XcmpQueue;
- type DmpMessageHandler = DmpQueue;
- type ReservedDmpWeight = ReservedDmpWeight;
- type ReservedXcmpWeight = ReservedXcmpWeight;
- type XcmpMessageHandler = XcmpQueue;
-}
-
-impl parachain_info::Config for Runtime {}
-
-impl cumulus_pallet_aura_ext::Config for Runtime {}
-
-parameter_types! {
- pub const RelayLocation: MultiLocation = MultiLocation::parent();
- pub const RelayNetwork: NetworkId = NetworkId::Polkadot;
- pub RelayOrigin: Origin = cumulus_pallet_xcm::Origin::Relay.into();
- pub Ancestry: MultiLocation = Parachain(ParachainInfo::parachain_id().into()).into();
-}
-
-/// Type for specifying how a `MultiLocation` can be converted into an `AccountId`. This is used
-/// when determining ownership of accounts for asset transacting and when attempting to use XCM
-/// `Transact` in order to determine the dispatch Origin.
-pub type LocationToAccountId = (
- // The parent (Relay-chain) origin converts to the default `AccountId`.
- ParentIsPreset<AccountId>,
- // Sibling parachain origins convert to AccountId via the `ParaId::into`.
- SiblingParachainConvertsVia<Sibling, AccountId>,
- // Straight up local `AccountId32` origins just alias directly to `AccountId`.
- AccountId32Aliases<RelayNetwork, AccountId>,
-);
-
-pub struct OnlySelfCurrency;
-impl<B: TryFrom<u128>> MatchesFungible<B> for OnlySelfCurrency {
- fn matches_fungible(a: &MultiAsset) -> Option<B> {
- match (&a.id, &a.fun) {
- (Concrete(_), XcmFungible(ref amount)) => CheckedConversion::checked_from(*amount),
- _ => None,
- }
- }
-}
-
-/// Means for transacting assets on this chain.
-pub type LocalAssetTransactor = CurrencyAdapter<
- // Use this currency:
- Balances,
- // Use this currency when it is a fungible asset matching the given location or name:
- OnlySelfCurrency,
- // Do a simple punn to convert an AccountId32 MultiLocation into a native chain account ID:
- LocationToAccountId,
- // Our chain's account ID type (we can't get away without mentioning it explicitly):
- AccountId,
- // We don't track any teleports.
- (),
->;
-
-/// This is the type we use to convert an (incoming) XCM origin into a local `Origin` instance,
-/// ready for dispatching a transaction with Xcm's `Transact`. There is an `OriginKind` which can
-/// biases the kind of local `Origin` it will become.
-pub type XcmOriginToTransactDispatchOrigin = (
- // Sovereign account converter; this attempts to derive an `AccountId` from the origin location
- // using `LocationToAccountId` and then turn that into the usual `Signed` origin. Useful for
- // foreign chains who want to have a local sovereign account on this chain which they control.
- SovereignSignedViaLocation<LocationToAccountId, Origin>,
- // Native converter for Relay-chain (Parent) location; will converts to a `Relay` origin when
- // recognised.
- RelayChainAsNative<RelayOrigin, Origin>,
- // Native converter for sibling Parachains; will convert to a `SiblingPara` origin when
- // recognised.
- SiblingParachainAsNative<cumulus_pallet_xcm::Origin, Origin>,
- // Superuser converter for the Relay-chain (Parent) location. This will allow it to issue a
- // transaction from the Root origin.
- ParentAsSuperuser<Origin>,
- // Native signed account converter; this just converts an `AccountId32` origin into a normal
- // `Origin::Signed` origin of the same 32-byte value.
- SignedAccountId32AsNative<RelayNetwork, Origin>,
- // Xcm origins can be represented natively under the Xcm pallet's Xcm origin.
- XcmPassthrough<Origin>,
-);
-
-parameter_types! {
- // One XCM operation is 1_000_000 weight - almost certainly a conservative estimate.
- pub UnitWeightCost: Weight = 1_000_000;
- // 1200 UNIQUEs buy 1 second of weight.
- pub const WeightPrice: (MultiLocation, u128) = (MultiLocation::parent(), 1_200 * UNIQUE);
- pub const MaxInstructions: u32 = 100;
- pub const MaxAuthorities: u32 = 100_000;
-}
-
-match_type! {
- pub type ParentOrParentsUnitPlurality: impl Contains<MultiLocation> = {
- MultiLocation { parents: 1, interior: Here } |
- MultiLocation { parents: 1, interior: X1(Plurality { id: BodyId::Unit, .. }) }
- };
-}
-
-pub type Barrier = (
- TakeWeightCredit,
- AllowTopLevelPaidExecutionFrom<Everything>,
- AllowUnpaidExecutionFrom<ParentOrParentsUnitPlurality>,
- // ^^^ Parent & its unit plurality gets free execution
-);
-
-pub struct UsingOnlySelfCurrencyComponents<
- WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,
- AssetId: Get<MultiLocation>,
- AccountId,
- Currency: CurrencyT<AccountId>,
- OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,
->(
- Weight,
- Currency::Balance,
- PhantomData<(WeightToFee, AssetId, AccountId, Currency, OnUnbalanced)>,
-);
-impl<
- WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,
- AssetId: Get<MultiLocation>,
- AccountId,
- Currency: CurrencyT<AccountId>,
- OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,
- > WeightTrader
- for UsingOnlySelfCurrencyComponents<WeightToFee, AssetId, AccountId, Currency, OnUnbalanced>
-{
- fn new() -> Self {
- Self(0, Zero::zero(), PhantomData)
- }
-
- fn buy_weight(&mut self, weight: Weight, payment: Assets) -> Result<Assets, XcmError> {
- let amount = WeightToFee::calc(&weight);
- let u128_amount: u128 = amount.try_into().map_err(|_| XcmError::Overflow)?;
-
- // location to this parachain through relay chain
- let option1: xcm::v1::AssetId = Concrete(MultiLocation {
- parents: 1,
- interior: X1(Parachain(ParachainInfo::parachain_id().into())),
- });
- // direct location
- let option2: xcm::v1::AssetId = Concrete(MultiLocation {
- parents: 0,
- interior: Here,
- });
-
- let required = if payment.fungible.contains_key(&option1) {
- (option1, u128_amount).into()
- } else if payment.fungible.contains_key(&option2) {
- (option2, u128_amount).into()
- } else {
- (Concrete(MultiLocation::default()), u128_amount).into()
- };
-
- let unused = payment
- .checked_sub(required)
- .map_err(|_| XcmError::TooExpensive)?;
- self.0 = self.0.saturating_add(weight);
- self.1 = self.1.saturating_add(amount);
- Ok(unused)
- }
-
- fn refund_weight(&mut self, weight: Weight) -> Option<MultiAsset> {
- let weight = weight.min(self.0);
- let amount = WeightToFee::calc(&weight);
- self.0 -= weight;
- self.1 = self.1.saturating_sub(amount);
- let amount: u128 = amount.saturated_into();
- if amount > 0 {
- Some((AssetId::get(), amount).into())
- } else {
- None
- }
- }
-}
-impl<
- WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,
- AssetId: Get<MultiLocation>,
- AccountId,
- Currency: CurrencyT<AccountId>,
- OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,
- > Drop
- for UsingOnlySelfCurrencyComponents<WeightToFee, AssetId, AccountId, Currency, OnUnbalanced>
-{
- fn drop(&mut self) {
- OnUnbalanced::on_unbalanced(Currency::issue(self.1));
- }
-}
-
-pub struct XcmConfig;
-impl Config for XcmConfig {
- type Call = Call;
- type XcmSender = XcmRouter;
- // How to withdraw and deposit an asset.
- type AssetTransactor = LocalAssetTransactor;
- type OriginConverter = XcmOriginToTransactDispatchOrigin;
- type IsReserve = NativeAsset;
- type IsTeleporter = (); // Teleportation is disabled
- type LocationInverter = LocationInverter<Ancestry>;
- type Barrier = Barrier;
- type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;
- type Trader = UsingOnlySelfCurrencyComponents<
- IdentityFee<Balance>,
- RelayLocation,
- AccountId,
- Balances,
- (),
- >;
- type ResponseHandler = (); // Don't handle responses for now.
- type SubscriptionService = PolkadotXcm;
-
- type AssetTrap = PolkadotXcm;
- type AssetClaims = PolkadotXcm;
-}
-
-// parameter_types! {
-// pub const MaxDownwardMessageWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 10;
-// }
-
-/// No local origins on this chain are allowed to dispatch XCM sends/executions.
-pub type LocalOriginToLocation = (SignedToAccountId32<Origin, AccountId, RelayNetwork>,);
-
-/// The means for routing XCM messages which are not for local execution into the right message
-/// queues.
-pub type XcmRouter = (
- // Two routers - use UMP to communicate with the relay chain:
- cumulus_primitives_utility::ParentAsUmp<ParachainSystem, ()>,
- // ..and XCMP to communicate with the sibling chains.
- XcmpQueue,
-);
-
-impl pallet_evm_coder_substrate::Config for Runtime {
- type EthereumTransactionSender = pallet_ethereum::Pallet<Self>;
- type GasWeightMapping = FixedGasWeightMapping;
-}
-
-impl pallet_xcm::Config for Runtime {
- type Event = Event;
- type SendXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;
- type XcmRouter = XcmRouter;
- type ExecuteXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;
- type XcmExecuteFilter = Everything;
- type XcmExecutor = XcmExecutor<XcmConfig>;
- type XcmTeleportFilter = Everything;
- type XcmReserveTransferFilter = Everything;
- type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;
- type LocationInverter = LocationInverter<Ancestry>;
- type Origin = Origin;
- type Call = Call;
- const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;
- type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;
-}
-
-impl cumulus_pallet_xcm::Config for Runtime {
- type Event = Event;
- type XcmExecutor = XcmExecutor<XcmConfig>;
-}
-
-impl cumulus_pallet_xcmp_queue::Config for Runtime {
- type Event = Event;
- type XcmExecutor = XcmExecutor<XcmConfig>;
- type ChannelInfo = ParachainSystem;
- type VersionWrapper = ();
- type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;
- type ControllerOrigin = EnsureRoot<AccountId>;
- type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin;
-}
-
-impl cumulus_pallet_dmp_queue::Config for Runtime {
- type Event = Event;
- type XcmExecutor = XcmExecutor<XcmConfig>;
- type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;
-}
-
-impl pallet_aura::Config for Runtime {
- type AuthorityId = AuraId;
- type DisabledValidators = ();
- type MaxAuthorities = MaxAuthorities;
-}
-
-parameter_types! {
- pub TreasuryAccountId: AccountId = TreasuryModuleId::get().into_account();
- pub const CollectionCreationPrice: Balance = 2 * UNIQUE;
-}
-
-impl pallet_common::Config for Runtime {
- type Event = Event;
- type EvmBackwardsAddressMapping = up_evm_mapping::MapBackwardsAddressTruncated;
- type EvmAddressMapping = HashedAddressMapping<Self::Hashing>;
- type CrossAccountId = pallet_common::account::BasicCrossAccountId<Self>;
-
- type Currency = Balances;
- type CollectionCreationPrice = CollectionCreationPrice;
- type TreasuryAccountId = TreasuryAccountId;
-}
-
-impl pallet_fungible::Config for Runtime {
- type WeightInfo = pallet_fungible::weights::SubstrateWeight<Self>;
-}
-impl pallet_refungible::Config for Runtime {
- type WeightInfo = pallet_refungible::weights::SubstrateWeight<Self>;
-}
-impl pallet_nonfungible::Config for Runtime {
- type WeightInfo = pallet_nonfungible::weights::SubstrateWeight<Self>;
-}
-
-impl pallet_unique::Config for Runtime {
- type Event = Event;
- type WeightInfo = pallet_unique::weights::SubstrateWeight<Self>;
-}
-
-parameter_types! {
- pub const InflationBlockInterval: BlockNumber = 100; // every time per how many blocks inflation is applied
-}
-
-/// Used for the pallet inflation
-impl pallet_inflation::Config for Runtime {
- type Currency = Balances;
- type TreasuryAccountId = TreasuryAccountId;
- type InflationBlockInterval = InflationBlockInterval;
- type BlockNumberProvider = RelayChainBlockNumberProvider<Runtime>;
-}
-
-// parameter_types! {
-// pub MaximumSchedulerWeight: Weight = Perbill::from_percent(50) *
-// RuntimeBlockWeights::get().max_block;
-// pub const MaxScheduledPerBlock: u32 = 50;
-// }
-
-type EvmSponsorshipHandler = (
- pallet_unique::UniqueEthSponsorshipHandler<Runtime>,
- pallet_evm_contract_helpers::HelpersContractSponsoring<Runtime>,
-);
-type SponsorshipHandler = (
- pallet_unique::UniqueSponsorshipHandler<Runtime>,
- //pallet_contract_helpers::ContractSponsorshipHandler<Runtime>,
- pallet_evm_transaction_payment::BridgeSponsorshipHandler<Runtime>,
-);
-
-// impl pallet_unq_scheduler::Config for Runtime {
-// type Event = Event;
-// type Origin = Origin;
-// type PalletsOrigin = OriginCaller;
-// type Call = Call;
-// type MaximumWeight = MaximumSchedulerWeight;
-// type ScheduleOrigin = EnsureSigned<AccountId>;
-// type MaxScheduledPerBlock = MaxScheduledPerBlock;
-// type SponsorshipHandler = SponsorshipHandler;
-// type WeightInfo = ();
-// }
-
-impl pallet_evm_transaction_payment::Config for Runtime {
- type EvmSponsorshipHandler = EvmSponsorshipHandler;
- type Currency = Balances;
- type EvmAddressMapping = HashedAddressMapping<Self::Hashing>;
- type EvmBackwardsAddressMapping = up_evm_mapping::MapBackwardsAddressTruncated;
-}
-
-impl pallet_charge_transaction::Config for Runtime {
- type SponsorshipHandler = SponsorshipHandler;
-}
-
-// impl pallet_contract_helpers::Config for Runtime {
-// type DefaultSponsoringRateLimit = DefaultSponsoringRateLimit;
-// }
-
-parameter_types! {
- // 0x842899ECF380553E8a4de75bF534cdf6fBF64049
- pub const HelpersContractAddress: H160 = H160([
- 0x84, 0x28, 0x99, 0xec, 0xf3, 0x80, 0x55, 0x3e, 0x8a, 0x4d, 0xe7, 0x5b, 0xf5, 0x34, 0xcd, 0xf6, 0xfb, 0xf6, 0x40, 0x49,
- ]);
-}
-
-impl pallet_evm_contract_helpers::Config for Runtime {
- type ContractAddress = HelpersContractAddress;
- type DefaultSponsoringRateLimit = DefaultSponsoringRateLimit;
-}
-
-construct_runtime!(
- pub enum Runtime where
- Block = Block,
- NodeBlock = opaque::Block,
- UncheckedExtrinsic = UncheckedExtrinsic
- {
- ParachainSystem: cumulus_pallet_parachain_system::{Pallet, Call, Config, Storage, Inherent, Event<T>, ValidateUnsigned} = 20,
- ParachainInfo: parachain_info::{Pallet, Storage, Config} = 21,
-
- Aura: pallet_aura::{Pallet, Config<T>} = 22,
- AuraExt: cumulus_pallet_aura_ext::{Pallet, Config} = 23,
-
- Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>} = 30,
- RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Pallet, Storage} = 31,
- Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent} = 32,
- TransactionPayment: pallet_transaction_payment::{Pallet, Storage} = 33,
- Treasury: pallet_treasury::{Pallet, Call, Storage, Config, Event<T>} = 34,
- Sudo: pallet_sudo::{Pallet, Call, Storage, Config<T>, Event<T>} = 35,
- System: frame_system::{Pallet, Call, Storage, Config, Event<T>} = 36,
- Vesting: orml_vesting::{Pallet, Storage, Call, Event<T>, Config<T>} = 37,
- // Vesting: pallet_vesting::{Pallet, Call, Config<T>, Storage, Event<T>} = 37,
- // Contracts: pallet_contracts::{Pallet, Call, Storage, Event<T>} = 38,
-
- // XCM helpers.
- XcmpQueue: cumulus_pallet_xcmp_queue::{Pallet, Call, Storage, Event<T>} = 50,
- PolkadotXcm: pallet_xcm::{Pallet, Call, Event<T>, Origin} = 51,
- CumulusXcm: cumulus_pallet_xcm::{Pallet, Call, Event<T>, Origin} = 52,
- DmpQueue: cumulus_pallet_dmp_queue::{Pallet, Call, Storage, Event<T>} = 53,
-
- // Unique Pallets
- Inflation: pallet_inflation::{Pallet, Call, Storage} = 60,
- Unique: pallet_unique::{Pallet, Call, Storage, Event<T>} = 61,
- // Scheduler: pallet_unq_scheduler::{Pallet, Call, Storage, Event<T>} = 62,
- // free = 63
- Charging: pallet_charge_transaction::{Pallet, Call, Storage } = 64,
- // ContractHelpers: pallet_contract_helpers::{Pallet, Call, Storage} = 65,
- Common: pallet_common::{Pallet, Storage, Event<T>} = 66,
- Fungible: pallet_fungible::{Pallet, Storage} = 67,
- Refungible: pallet_refungible::{Pallet, Storage} = 68,
- Nonfungible: pallet_nonfungible::{Pallet, Storage} = 69,
-
- // Frontier
- EVM: pallet_evm::{Pallet, Config, Call, Storage, Event<T>} = 100,
- Ethereum: pallet_ethereum::{Pallet, Config, Call, Storage, Event, Origin} = 101,
-
- EvmCoderSubstrate: pallet_evm_coder_substrate::{Pallet, Storage} = 150,
- EvmContractHelpers: pallet_evm_contract_helpers::{Pallet, Storage} = 151,
- EvmTransactionPayment: pallet_evm_transaction_payment::{Pallet} = 152,
- EvmMigration: pallet_evm_migration::{Pallet, Call, Storage} = 153,
- }
-);
-
-pub struct TransactionConverter;
-
-impl fp_rpc::ConvertTransaction<UncheckedExtrinsic> for TransactionConverter {
- fn convert_transaction(&self, transaction: pallet_ethereum::Transaction) -> UncheckedExtrinsic {
- UncheckedExtrinsic::new_unsigned(
- pallet_ethereum::Call::<Runtime>::transact { transaction }.into(),
- )
- }
-}
-
-impl fp_rpc::ConvertTransaction<opaque::UncheckedExtrinsic> for TransactionConverter {
- fn convert_transaction(
- &self,
- transaction: pallet_ethereum::Transaction,
- ) -> opaque::UncheckedExtrinsic {
- let extrinsic = UncheckedExtrinsic::new_unsigned(
- pallet_ethereum::Call::<Runtime>::transact { transaction }.into(),
- );
- let encoded = extrinsic.encode();
- opaque::UncheckedExtrinsic::decode(&mut &encoded[..])
- .expect("Encoded extrinsic is always valid")
- }
-}
-
-/// The address format for describing accounts.
-pub type Address = sp_runtime::MultiAddress<AccountId, ()>;
-/// Block header type as expected by this runtime.
-pub type Header = generic::Header<BlockNumber, BlakeTwo256>;
-/// Block type as expected by this runtime.
-pub type Block = generic::Block<Header, UncheckedExtrinsic>;
-/// A Block signed with a Justification
-pub type SignedBlock = generic::SignedBlock<Block>;
-/// BlockId type as expected by this runtime.
-pub type BlockId = generic::BlockId<Block>;
-/// The SignedExtension to the basic transaction logic.
-pub type SignedExtra = (
- frame_system::CheckSpecVersion<Runtime>,
- // system::CheckTxVersion<Runtime>,
- frame_system::CheckGenesis<Runtime>,
- frame_system::CheckEra<Runtime>,
- frame_system::CheckNonce<Runtime>,
- frame_system::CheckWeight<Runtime>,
- pallet_charge_transaction::ChargeTransactionPayment<Runtime>,
- //pallet_contract_helpers::ContractHelpersExtension<Runtime>,
-);
-/// Unchecked extrinsic type as expected by this runtime.
-pub type UncheckedExtrinsic =
- fp_self_contained::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;
-/// Extrinsic type that has already been checked.
-pub type CheckedExtrinsic = fp_self_contained::CheckedExtrinsic<AccountId, Call, SignedExtra, H160>;
-/// Executive: handles dispatch to the various modules.
-pub type Executive = frame_executive::Executive<
- Runtime,
- Block,
- frame_system::ChainContext<Runtime>,
- Runtime,
- AllPalletsReversedWithSystemFirst,
->;
-
-impl_opaque_keys! {
- pub struct SessionKeys {
- pub aura: Aura,
- }
-}
-
-impl fp_self_contained::SelfContainedCall for Call {
- type SignedInfo = H160;
-
- fn is_self_contained(&self) -> bool {
- match self {
- Call::Ethereum(call) => call.is_self_contained(),
- _ => false,
- }
- }
-
- fn check_self_contained(&self) -> Option<Result<Self::SignedInfo, TransactionValidityError>> {
- match self {
- Call::Ethereum(call) => call.check_self_contained(),
- _ => None,
- }
- }
-
- fn validate_self_contained(&self, info: &Self::SignedInfo) -> Option<TransactionValidity> {
- match self {
- Call::Ethereum(call) => call.validate_self_contained(info),
- _ => None,
- }
- }
-
- fn pre_dispatch_self_contained(
- &self,
- info: &Self::SignedInfo,
- ) -> Option<Result<(), TransactionValidityError>> {
- match self {
- Call::Ethereum(call) => call.pre_dispatch_self_contained(info),
- _ => None,
- }
- }
-
- fn apply_self_contained(
- self,
- info: Self::SignedInfo,
- ) -> Option<sp_runtime::DispatchResultWithInfo<PostDispatchInfoOf<Self>>> {
- match self {
- call @ Call::Ethereum(pallet_ethereum::Call::transact { .. }) => Some(call.dispatch(
- Origin::from(pallet_ethereum::RawOrigin::EthereumTransaction(info)),
- )),
- _ => None,
- }
- }
-}
-
-macro_rules! dispatch_unique_runtime {
- ($collection:ident.$method:ident($($name:ident),*)) => {{
- use pallet_unique::dispatch::Dispatched;
-
- let collection = Dispatched::dispatch(<pallet_common::CollectionHandle<Runtime>>::try_get($collection)?);
- let dispatch = collection.as_dyn();
-
- Ok(dispatch.$method($($name),*))
- }};
-}
-impl_runtime_apis! {
- impl up_rpc::UniqueApi<Block, CrossAccountId, AccountId>
- for Runtime
- {
- fn account_tokens(collection: CollectionId, account: CrossAccountId) -> Result<Vec<TokenId>, DispatchError> {
- dispatch_unique_runtime!(collection.account_tokens(account))
- }
- fn token_exists(collection: CollectionId, token: TokenId) -> Result<bool, DispatchError> {
- dispatch_unique_runtime!(collection.token_exists(token))
- }
-
- fn token_owner(collection: CollectionId, token: TokenId) -> Result<Option<CrossAccountId>, DispatchError> {
- dispatch_unique_runtime!(collection.token_owner(token))
- }
- fn const_metadata(collection: CollectionId, token: TokenId) -> Result<Vec<u8>, DispatchError> {
- dispatch_unique_runtime!(collection.const_metadata(token))
- }
- fn variable_metadata(collection: CollectionId, token: TokenId) -> Result<Vec<u8>, DispatchError> {
- dispatch_unique_runtime!(collection.variable_metadata(token))
- }
-
- fn collection_tokens(collection: CollectionId) -> Result<u32, DispatchError> {
- dispatch_unique_runtime!(collection.collection_tokens())
- }
- fn account_balance(collection: CollectionId, account: CrossAccountId) -> Result<u32, DispatchError> {
- dispatch_unique_runtime!(collection.account_balance(account))
- }
- fn balance(collection: CollectionId, account: CrossAccountId, token: TokenId) -> Result<u128, DispatchError> {
- dispatch_unique_runtime!(collection.balance(account, token))
- }
- fn allowance(
- collection: CollectionId,
- sender: CrossAccountId,
- spender: CrossAccountId,
- token: TokenId,
- ) -> Result<u128, DispatchError> {
- dispatch_unique_runtime!(collection.allowance(sender, spender, token))
- }
-
- fn eth_contract_code(account: H160) -> Option<Vec<u8>> {
- <pallet_unique::UniqueErcSupport<Runtime>>::get_code(&account)
- .or_else(|| <pallet_evm_migration::OnMethodCall<Runtime>>::get_code(&account))
- .or_else(|| <pallet_evm_contract_helpers::HelpersOnMethodCall<Self>>::get_code(&account))
- }
- fn adminlist(collection: CollectionId) -> Result<Vec<CrossAccountId>, DispatchError> {
- Ok(<pallet_common::Pallet<Runtime>>::adminlist(collection))
- }
- fn allowlist(collection: CollectionId) -> Result<Vec<CrossAccountId>, DispatchError> {
- Ok(<pallet_common::Pallet<Runtime>>::allowlist(collection))
- }
- fn allowed(collection: CollectionId, user: CrossAccountId) -> Result<bool, DispatchError> {
- Ok(<pallet_common::Pallet<Runtime>>::allowed(collection, user))
- }
- fn last_token_id(collection: CollectionId) -> Result<TokenId, DispatchError> {
- dispatch_unique_runtime!(collection.last_token_id())
- }
- fn collection_by_id(collection: CollectionId) -> Result<Option<Collection<AccountId>>, DispatchError> {
- Ok(<pallet_common::CollectionById<Runtime>>::get(collection))
- }
- fn collection_stats() -> Result<CollectionStats, DispatchError> {
- Ok(<pallet_common::Pallet<Runtime>>::collection_stats())
- }
- }
-
- impl sp_api::Core<Block> for Runtime {
- fn version() -> RuntimeVersion {
- VERSION
- }
-
- fn execute_block(block: Block) {
- Executive::execute_block(block)
- }
-
- fn initialize_block(header: &<Block as BlockT>::Header) {
- Executive::initialize_block(header)
- }
- }
-
- impl sp_api::Metadata<Block> for Runtime {
- fn metadata() -> OpaqueMetadata {
- OpaqueMetadata::new(Runtime::metadata().into())
- }
- }
-
- impl sp_block_builder::BlockBuilder<Block> for Runtime {
- fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {
- Executive::apply_extrinsic(extrinsic)
- }
-
- fn finalize_block() -> <Block as BlockT>::Header {
- Executive::finalize_block()
- }
-
- fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<<Block as BlockT>::Extrinsic> {
- data.create_extrinsics()
- }
-
- fn check_inherents(
- block: Block,
- data: sp_inherents::InherentData,
- ) -> sp_inherents::CheckInherentsResult {
- data.check_extrinsics(&block)
- }
-
- // fn random_seed() -> <Block as BlockT>::Hash {
- // RandomnessCollectiveFlip::random_seed().0
- // }
- }
-
- impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {
- fn validate_transaction(
- source: TransactionSource,
- tx: <Block as BlockT>::Extrinsic,
- hash: <Block as BlockT>::Hash,
- ) -> TransactionValidity {
- Executive::validate_transaction(source, tx, hash)
- }
- }
-
- impl sp_offchain::OffchainWorkerApi<Block> for Runtime {
- fn offchain_worker(header: &<Block as BlockT>::Header) {
- Executive::offchain_worker(header)
- }
- }
-
- impl fp_rpc::EthereumRuntimeRPCApi<Block> for Runtime {
- fn chain_id() -> u64 {
- <Runtime as pallet_evm::Config>::ChainId::get()
- }
-
- fn account_basic(address: H160) -> EVMAccount {
- EVM::account_basic(&address)
- }
-
- fn gas_price() -> U256 {
- <Runtime as pallet_evm::Config>::FeeCalculator::min_gas_price()
- }
-
- fn account_code_at(address: H160) -> Vec<u8> {
- EVM::account_codes(address)
- }
-
- fn author() -> H160 {
- <pallet_evm::Pallet<Runtime>>::find_author()
- }
-
- fn storage_at(address: H160, index: U256) -> H256 {
- let mut tmp = [0u8; 32];
- index.to_big_endian(&mut tmp);
- EVM::account_storages(address, H256::from_slice(&tmp[..]))
- }
-
- #[allow(clippy::redundant_closure)]
- fn call(
- from: H160,
- to: H160,
- data: Vec<u8>,
- value: U256,
- gas_limit: U256,
- max_fee_per_gas: Option<U256>,
- max_priority_fee_per_gas: Option<U256>,
- nonce: Option<U256>,
- estimate: bool,
- access_list: Option<Vec<(H160, Vec<H256>)>>,
- ) -> Result<pallet_evm::CallInfo, sp_runtime::DispatchError> {
- let config = if estimate {
- let mut config = <Runtime as pallet_evm::Config>::config().clone();
- config.estimate = true;
- Some(config)
- } else {
- None
- };
-
- <Runtime as pallet_evm::Config>::Runner::call(
- from,
- to,
- data,
- value,
- gas_limit.low_u64(),
- max_fee_per_gas,
- max_priority_fee_per_gas,
- nonce,
- access_list.unwrap_or_default(),
- config.as_ref().unwrap_or_else(|| <Runtime as pallet_evm::Config>::config()),
- ).map_err(|err| err.into())
- }
-
- #[allow(clippy::redundant_closure)]
- fn create(
- from: H160,
- data: Vec<u8>,
- value: U256,
- gas_limit: U256,
- max_fee_per_gas: Option<U256>,
- max_priority_fee_per_gas: Option<U256>,
- nonce: Option<U256>,
- estimate: bool,
- access_list: Option<Vec<(H160, Vec<H256>)>>,
- ) -> Result<pallet_evm::CreateInfo, sp_runtime::DispatchError> {
- let config = if estimate {
- let mut config = <Runtime as pallet_evm::Config>::config().clone();
- config.estimate = true;
- Some(config)
- } else {
- None
- };
-
- <Runtime as pallet_evm::Config>::Runner::create(
- from,
- data,
- value,
- gas_limit.low_u64(),
- max_fee_per_gas,
- max_priority_fee_per_gas,
- nonce,
- access_list.unwrap_or_default(),
- config.as_ref().unwrap_or_else(|| <Runtime as pallet_evm::Config>::config()),
- ).map_err(|err| err.into())
- }
-
- fn current_transaction_statuses() -> Option<Vec<TransactionStatus>> {
- Ethereum::current_transaction_statuses()
- }
-
- fn current_block() -> Option<pallet_ethereum::Block> {
- Ethereum::current_block()
- }
-
- fn current_receipts() -> Option<Vec<pallet_ethereum::Receipt>> {
- Ethereum::current_receipts()
- }
-
- fn current_all() -> (
- Option<pallet_ethereum::Block>,
- Option<Vec<pallet_ethereum::Receipt>>,
- Option<Vec<TransactionStatus>>
- ) {
- (
- Ethereum::current_block(),
- Ethereum::current_receipts(),
- Ethereum::current_transaction_statuses()
- )
- }
-
- fn extrinsic_filter(xts: Vec<<Block as sp_api::BlockT>::Extrinsic>) -> Vec<pallet_ethereum::Transaction> {
- xts.into_iter().filter_map(|xt| match xt.0.function {
- Call::Ethereum(pallet_ethereum::Call::transact { transaction }) => Some(transaction),
- _ => None
- }).collect()
- }
-
- fn elasticity() -> Option<Permill> {
- None
- }
- }
-
- impl sp_session::SessionKeys<Block> for Runtime {
- fn decode_session_keys(
- encoded: Vec<u8>,
- ) -> Option<Vec<(Vec<u8>, KeyTypeId)>> {
- SessionKeys::decode_into_raw_public_keys(&encoded)
- }
-
- fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {
- SessionKeys::generate(seed)
- }
- }
-
- impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {
- fn slot_duration() -> sp_consensus_aura::SlotDuration {
- sp_consensus_aura::SlotDuration::from_millis(Aura::slot_duration())
- }
-
- fn authorities() -> Vec<AuraId> {
- Aura::authorities().to_vec()
- }
- }
-
- impl cumulus_primitives_core::CollectCollationInfo<Block> for Runtime {
- fn collect_collation_info(header: &<Block as BlockT>::Header) -> cumulus_primitives_core::CollationInfo {
- ParachainSystem::collect_collation_info(header)
- }
- }
-
- impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Index> for Runtime {
- fn account_nonce(account: AccountId) -> Index {
- System::account_nonce(account)
- }
- }
-
- impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance> for Runtime {
- fn query_info(uxt: <Block as BlockT>::Extrinsic, len: u32) -> RuntimeDispatchInfo<Balance> {
- TransactionPayment::query_info(uxt, len)
- }
- fn query_fee_details(uxt: <Block as BlockT>::Extrinsic, len: u32) -> FeeDetails<Balance> {
- TransactionPayment::query_fee_details(uxt, len)
- }
- }
-
- /*
- impl pallet_contracts_rpc_runtime_api::ContractsApi<Block, AccountId, Balance, BlockNumber, Hash>
- for Runtime
- {
- fn call(
- origin: AccountId,
- dest: AccountId,
- value: Balance,
- gas_limit: u64,
- input_data: Vec<u8>,
- ) -> pallet_contracts_primitives::ContractExecResult {
- Contracts::bare_call(origin, dest, value, gas_limit, input_data, false)
- }
-
- fn instantiate(
- origin: AccountId,
- endowment: Balance,
- gas_limit: u64,
- code: pallet_contracts_primitives::Code<Hash>,
- data: Vec<u8>,
- salt: Vec<u8>,
- ) -> pallet_contracts_primitives::ContractInstantiateResult<AccountId, BlockNumber>
- {
- Contracts::bare_instantiate(origin, endowment, gas_limit, code, data, salt, true, false)
- }
-
- fn get_storage(
- address: AccountId,
- key: [u8; 32],
- ) -> pallet_contracts_primitives::GetStorageResult {
- Contracts::get_storage(address, key)
- }
-
- fn rent_projection(
- address: AccountId,
- ) -> pallet_contracts_primitives::RentProjectionResult<BlockNumber> {
- Contracts::rent_projection(address)
- }
- }
- */
-
- #[cfg(feature = "runtime-benchmarks")]
- impl frame_benchmarking::Benchmark<Block> for Runtime {
- fn benchmark_metadata(extra: bool) -> (
- Vec<frame_benchmarking::BenchmarkList>,
- Vec<frame_support::traits::StorageInfo>,
- ) {
- use frame_benchmarking::{list_benchmark, Benchmarking, BenchmarkList};
- use frame_support::traits::StorageInfoTrait;
-
- let mut list = Vec::<BenchmarkList>::new();
-
- list_benchmark!(list, extra, pallet_evm_migration, EvmMigration);
- list_benchmark!(list, extra, pallet_unique, Unique);
- list_benchmark!(list, extra, pallet_inflation, Inflation);
- list_benchmark!(list, extra, pallet_fungible, Fungible);
- list_benchmark!(list, extra, pallet_refungible, Refungible);
- list_benchmark!(list, extra, pallet_nonfungible, Nonfungible);
- // list_benchmark!(list, extra, pallet_evm_coder_substrate, EvmCoderSubstrate);
-
- let storage_info = AllPalletsReversedWithSystemFirst::storage_info();
-
- return (list, storage_info)
- }
-
- fn dispatch_benchmark(
- config: frame_benchmarking::BenchmarkConfig
- ) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {
- use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark, TrackedStorageKey};
-
- let allowlist: Vec<TrackedStorageKey> = vec![
- // Block Number
- hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef702a5c1b19ab7a04f536c519aca4983ac").to_vec().into(),
- // Total Issuance
- hex_literal::hex!("c2261276cc9d1f8598ea4b6a74b15c2f57c875e4cff74148e4628f264b974c80").to_vec().into(),
- // Execution Phase
- hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef7ff553b5a9862a516939d82b3d3d8661a").to_vec().into(),
- // Event Count
- hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef70a98fdbe9ce6c55837576c60c7af3850").to_vec().into(),
- // System Events
- hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef780d41e5e16056765bc8461851072c9d7").to_vec().into(),
- ];
-
- let mut batches = Vec::<BenchmarkBatch>::new();
- let params = (&config, &allowlist);
-
- add_benchmark!(params, batches, pallet_evm_migration, EvmMigration);
- add_benchmark!(params, batches, pallet_unique, Unique);
- add_benchmark!(params, batches, pallet_inflation, Inflation);
- add_benchmark!(params, batches, pallet_fungible, Fungible);
- add_benchmark!(params, batches, pallet_refungible, Refungible);
- add_benchmark!(params, batches, pallet_nonfungible, Nonfungible);
- // add_benchmark!(params, batches, pallet_evm_coder_substrate, EvmCoderSubstrate);
-
- if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) }
- Ok(batches)
- }
- }
-}
-
-struct CheckInherents;
-
-impl cumulus_pallet_parachain_system::CheckInherents<Block> for CheckInherents {
- fn check_inherents(
- block: &Block,
- relay_state_proof: &cumulus_pallet_parachain_system::RelayChainStateProof,
- ) -> sp_inherents::CheckInherentsResult {
- let relay_chain_slot = relay_state_proof
- .read_slot()
- .expect("Could not read the relay chain slot from the proof");
-
- let inherent_data =
- cumulus_primitives_timestamp::InherentDataProvider::from_relay_chain_slot_and_duration(
- relay_chain_slot,
- sp_std::time::Duration::from_secs(6),
- )
- .create_inherent_data()
- .expect("Could not create the timestamp inherent data");
-
- inherent_data.check_extrinsics(block)
- }
-}
-
-cumulus_pallet_parachain_system::register_validate_block!(
- Runtime = Runtime,
- BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor::<Runtime, Executive>,
- CheckInherents = CheckInherents,
-);
runtime/unique/Cargo.tomldiffbeforeafterboth--- /dev/null
+++ b/runtime/unique/Cargo.toml
@@ -0,0 +1,410 @@
+################################################################################
+# Package
+
+[package]
+authors = ['Unique Network <support@uniquenetwork.io>']
+build = 'build.rs'
+description = 'Unique Runtime'
+edition = '2021'
+homepage = 'https://unique.network'
+license = 'GPLv3'
+name = 'unique-runtime'
+repository = 'https://github.com/UniqueNetwork/unique-chain'
+version = '0.9.17'
+
+[package.metadata.docs.rs]
+targets = ['x86_64-unknown-linux-gnu']
+
+[features]
+default = ['std']
+runtime-benchmarks = [
+ 'hex-literal',
+ 'frame-benchmarking',
+ 'frame-support/runtime-benchmarks',
+ 'frame-system-benchmarking',
+ 'frame-system/runtime-benchmarks',
+ 'pallet-ethereum/runtime-benchmarks',
+ 'pallet-evm-migration/runtime-benchmarks',
+ 'pallet-evm-coder-substrate/runtime-benchmarks',
+ 'pallet-balances/runtime-benchmarks',
+ 'pallet-timestamp/runtime-benchmarks',
+ 'pallet-common/runtime-benchmarks',
+ 'pallet-fungible/runtime-benchmarks',
+ 'pallet-refungible/runtime-benchmarks',
+ 'pallet-nonfungible/runtime-benchmarks',
+ 'pallet-unique/runtime-benchmarks',
+ 'pallet-inflation/runtime-benchmarks',
+ 'pallet-xcm/runtime-benchmarks',
+ 'sp-runtime/runtime-benchmarks',
+ 'xcm-builder/runtime-benchmarks',
+]
+std = [
+ 'codec/std',
+ 'cumulus-pallet-aura-ext/std',
+ 'cumulus-pallet-parachain-system/std',
+ 'cumulus-pallet-xcm/std',
+ 'cumulus-pallet-xcmp-queue/std',
+ 'cumulus-primitives-core/std',
+ 'cumulus-primitives-utility/std',
+ 'frame-executive/std',
+ 'frame-support/std',
+ 'frame-system/std',
+ 'frame-system-rpc-runtime-api/std',
+ 'pallet-aura/std',
+ 'pallet-balances/std',
+ # 'pallet-contracts/std',
+ # 'pallet-contracts-primitives/std',
+ # 'pallet-contracts-rpc-runtime-api/std',
+ # 'pallet-contract-helpers/std',
+ 'pallet-randomness-collective-flip/std',
+ 'pallet-sudo/std',
+ 'pallet-timestamp/std',
+ 'pallet-transaction-payment/std',
+ 'pallet-transaction-payment-rpc-runtime-api/std',
+ 'pallet-treasury/std',
+ # 'pallet-vesting/std',
+ 'pallet-evm/std',
+ 'pallet-evm-migration/std',
+ 'pallet-evm-contract-helpers/std',
+ 'pallet-evm-transaction-payment/std',
+ 'pallet-evm-coder-substrate/std',
+ 'pallet-ethereum/std',
+ 'pallet-base-fee/std',
+ 'fp-rpc/std',
+ 'up-rpc/std',
+ 'up-evm-mapping/std',
+ 'fp-self-contained/std',
+ 'parachain-info/std',
+ 'serde',
+ 'pallet-inflation/std',
+ 'pallet-common/std',
+ 'pallet-fungible/std',
+ 'pallet-refungible/std',
+ 'pallet-nonfungible/std',
+ 'pallet-unique/std',
+ 'pallet-unq-scheduler/std',
+ 'pallet-charge-transaction/std',
+ 'up-data-structs/std',
+ 'sp-api/std',
+ 'sp-block-builder/std',
+ "sp-consensus-aura/std",
+ 'sp-core/std',
+ 'sp-inherents/std',
+ 'sp-io/std',
+ 'sp-offchain/std',
+ 'sp-runtime/std',
+ 'sp-session/std',
+ 'sp-std/std',
+ 'sp-transaction-pool/std',
+ 'sp-version/std',
+ 'xcm/std',
+ 'xcm-builder/std',
+ 'xcm-executor/std',
+ 'unique-runtime-common/std',
+
+ "orml-vesting/std",
+]
+limit-testing = ['pallet-unique/limit-testing', 'up-data-structs/limit-testing']
+
+################################################################################
+# Substrate Dependencies
+
+[dependencies.codec]
+default-features = false
+features = ['derive']
+package = 'parity-scale-codec'
+version = '2.3.0'
+
+[dependencies.frame-benchmarking]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+optional = true
+branch = 'polkadot-v0.9.17'
+
+[dependencies.frame-executive]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'polkadot-v0.9.17'
+
+[dependencies.frame-support]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'polkadot-v0.9.17'
+
+[dependencies.frame-system]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'polkadot-v0.9.17'
+
+[dependencies.frame-system-benchmarking]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+optional = true
+branch = 'polkadot-v0.9.17'
+
+[dependencies.frame-system-rpc-runtime-api]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'polkadot-v0.9.17'
+
+[dependencies.hex-literal]
+optional = true
+version = '0.3.3'
+
+[dependencies.serde]
+default-features = false
+features = ['derive']
+optional = true
+version = '1.0.130'
+
+[dependencies.pallet-aura]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'polkadot-v0.9.17'
+
+[dependencies.pallet-balances]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'polkadot-v0.9.17'
+
+# Contracts specific packages
+# [dependencies.pallet-contracts]
+# git = 'https://github.com/paritytech/substrate.git'
+# default-features = false
+# branch = 'polkadot-v0.9.17'
+# version = '4.0.0-dev'
+
+# [dependencies.pallet-contracts-primitives]
+# git = 'https://github.com/paritytech/substrate.git'
+# default-features = false
+# branch = 'polkadot-v0.9.17'
+# version = '4.0.0-dev'
+
+# [dependencies.pallet-contracts-rpc-runtime-api]
+# git = 'https://github.com/paritytech/substrate.git'
+# default-features = false
+# branch = 'polkadot-v0.9.17'
+# version = '4.0.0-dev'
+
+[dependencies.pallet-randomness-collective-flip]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'polkadot-v0.9.17'
+
+[dependencies.pallet-sudo]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'polkadot-v0.9.17'
+
+[dependencies.pallet-timestamp]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'polkadot-v0.9.17'
+
+[dependencies.pallet-transaction-payment]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'polkadot-v0.9.17'
+
+[dependencies.pallet-transaction-payment-rpc-runtime-api]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'polkadot-v0.9.17'
+
+[dependencies.pallet-treasury]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'polkadot-v0.9.17'
+
+# [dependencies.pallet-vesting]
+# default-features = false
+# git = 'https://github.com/paritytech/substrate.git'
+# branch = 'polkadot-v0.9.17'
+
+[dependencies.sp-arithmetic]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'polkadot-v0.9.17'
+
+[dependencies.sp-api]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'polkadot-v0.9.17'
+
+[dependencies.sp-block-builder]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'polkadot-v0.9.17'
+
+[dependencies.sp-core]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'polkadot-v0.9.17'
+
+[dependencies.sp-consensus-aura]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'polkadot-v0.9.17'
+
+[dependencies.sp-inherents]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'polkadot-v0.9.17'
+
+[dependencies.sp-io]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'polkadot-v0.9.17'
+
+[dependencies.sp-offchain]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'polkadot-v0.9.17'
+
+[dependencies.sp-runtime]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'polkadot-v0.9.17'
+
+[dependencies.sp-session]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'polkadot-v0.9.17'
+
+[dependencies.sp-std]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'polkadot-v0.9.17'
+
+[dependencies.sp-transaction-pool]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'polkadot-v0.9.17'
+
+[dependencies.sp-version]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'polkadot-v0.9.17'
+
+[dependencies.smallvec]
+version = '1.6.1'
+
+################################################################################
+# Cumulus dependencies
+
+[dependencies.parachain-info]
+default-features = false
+git = 'https://github.com/uniqueNetwork/cumulus.git'
+branch = 'polkadot-v0.9.17'
+
+[dependencies.cumulus-pallet-aura-ext]
+git = 'https://github.com/uniqueNetwork/cumulus.git'
+branch = 'polkadot-v0.9.17'
+default-features = false
+
+[dependencies.cumulus-pallet-parachain-system]
+git = 'https://github.com/uniqueNetwork/cumulus.git'
+branch = 'polkadot-v0.9.17'
+default-features = false
+
+[dependencies.cumulus-primitives-core]
+git = 'https://github.com/uniqueNetwork/cumulus.git'
+branch = 'polkadot-v0.9.17'
+default-features = false
+
+[dependencies.cumulus-pallet-xcm]
+git = 'https://github.com/uniqueNetwork/cumulus.git'
+branch = 'polkadot-v0.9.17'
+default-features = false
+
+[dependencies.cumulus-pallet-dmp-queue]
+git = 'https://github.com/uniqueNetwork/cumulus.git'
+branch = 'polkadot-v0.9.17'
+default-features = false
+
+[dependencies.cumulus-pallet-xcmp-queue]
+git = 'https://github.com/uniqueNetwork/cumulus.git'
+branch = 'polkadot-v0.9.17'
+default-features = false
+
+[dependencies.cumulus-primitives-utility]
+git = 'https://github.com/uniqueNetwork/cumulus.git'
+branch = 'polkadot-v0.9.17'
+default-features = false
+
+[dependencies.cumulus-primitives-timestamp]
+git = 'https://github.com/uniqueNetwork/cumulus.git'
+branch = 'polkadot-v0.9.17'
+default-features = false
+
+################################################################################
+# Polkadot dependencies
+
+[dependencies.polkadot-parachain]
+git = 'https://github.com/paritytech/polkadot'
+branch = 'release-v0.9.17'
+default-features = false
+
+[dependencies.xcm]
+git = 'https://github.com/paritytech/polkadot'
+branch = 'release-v0.9.17'
+default-features = false
+
+[dependencies.xcm-builder]
+git = 'https://github.com/paritytech/polkadot'
+branch = 'release-v0.9.17'
+default-features = false
+
+[dependencies.xcm-executor]
+git = 'https://github.com/paritytech/polkadot'
+branch = 'release-v0.9.17'
+default-features = false
+
+[dependencies.pallet-xcm]
+git = 'https://github.com/paritytech/polkadot'
+branch = 'release-v0.9.17'
+default-features = false
+
+[dependencies.orml-vesting]
+git = 'https://github.com/UniqueNetwork/open-runtime-module-library'
+branch = 'unique-polkadot-v0.9.17'
+version = "0.4.1-dev"
+default-features = false
+
+################################################################################
+# local dependencies
+
+[dependencies]
+unique-runtime-common = { path = "../common", default-features = false }
+scale-info = { version = "1.0.0", default-features = false, features = [
+ "derive",
+] }
+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 }
+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" }
+pallet-fungible = { default-features = false, path = "../../pallets/fungible" }
+pallet-refungible = { default-features = false, path = "../../pallets/refungible" }
+pallet-nonfungible = { default-features = false, path = "../../pallets/nonfungible" }
+pallet-unq-scheduler = { path = '../../pallets/scheduler', default-features = false }
+# pallet-contract-helpers = { path = '../pallets/contract-helpers', default-features = false, version = '0.1.0' }
+pallet-charge-transaction = { git = "https://github.com/UniqueNetwork/pallet-sponsoring", branch = 'polkadot-v0.9.17', package = "pallet-template-transaction-payment", default-features = false, version = '3.0.0' }
+pallet-evm-migration = { path = '../../pallets/evm-migration', default-features = false }
+pallet-evm-contract-helpers = { path = '../../pallets/evm-contract-helpers', default-features = false }
+pallet-evm-transaction-payment = { path = '../../pallets/evm-transaction-payment', default-features = false }
+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.17" }
+pallet-ethereum = { default-features = false, git = "https://github.com/uniquenetwork/frontier.git", branch = "unique-polkadot-v0.9.17" }
+pallet-base-fee = { default-features = false, git = "https://github.com/uniquenetwork/frontier.git", branch = "unique-polkadot-v0.9.17" }
+fp-rpc = { default-features = false, git = "https://github.com/uniquenetwork/frontier.git", branch = "unique-polkadot-v0.9.17" }
+fp-self-contained = { default-features = false, git = "https://github.com/uniquenetwork/frontier.git", branch = "unique-polkadot-v0.9.17" }
+
+################################################################################
+# Build Dependencies
+
+[build-dependencies.substrate-wasm-builder]
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'polkadot-v0.9.17'
runtime/unique/build.rsdiffbeforeafterboth--- /dev/null
+++ b/runtime/unique/build.rs
@@ -0,0 +1,9 @@
+use substrate_wasm_builder::WasmBuilder;
+
+fn main() {
+ WasmBuilder::new()
+ .with_current_project()
+ .import_memory()
+ .export_heap_base()
+ .build()
+}
runtime/unique/src/lib.rsdiffbeforeafterboth--- /dev/null
+++ b/runtime/unique/src/lib.rs
@@ -0,0 +1,1140 @@
+// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.
+// This file is part of Unique Network.
+
+// Unique Network is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+// Unique Network is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
+
+//! The Substrate Node Template runtime. This can be compiled with `#[no_std]`, ready for Wasm.
+
+#![cfg_attr(not(feature = "std"), no_std)]
+// `construct_runtime!` does a lot of recursion and requires us to increase the limit to 256.
+#![recursion_limit = "1024"]
+#![allow(clippy::from_over_into, clippy::identity_op)]
+#![allow(clippy::fn_to_numeric_cast_with_truncation)]
+// Make the WASM binary available.
+#[cfg(feature = "std")]
+include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
+
+use sp_api::impl_runtime_apis;
+use sp_core::{crypto::KeyTypeId, OpaqueMetadata, H256, U256, H160};
+use sp_runtime::DispatchError;
+// #[cfg(any(feature = "std", test))]
+// pub use sp_runtime::BuildStorage;
+
+use sp_runtime::{
+ Permill, Perbill, Percent, create_runtime_str, generic, impl_opaque_keys,
+ traits::{AccountIdLookup, BlakeTwo256, Block as BlockT, AccountIdConversion, Zero},
+ transaction_validity::{TransactionSource, TransactionValidity},
+ ApplyExtrinsicResult, RuntimeAppPublic,
+};
+
+use sp_std::prelude::*;
+
+#[cfg(feature = "std")]
+use sp_version::NativeVersion;
+use sp_version::RuntimeVersion;
+pub use pallet_transaction_payment::{
+ Multiplier, TargetedFeeAdjustment, FeeDetails, RuntimeDispatchInfo,
+};
+// A few exports that help ease life for downstream crates.
+pub use pallet_balances::Call as BalancesCall;
+pub use pallet_evm::{EnsureAddressTruncated, HashedAddressMapping, Runner};
+pub use frame_support::{
+ construct_runtime, match_type,
+ dispatch::DispatchResult,
+ PalletId, parameter_types, StorageValue, ConsensusEngineId,
+ traits::{
+ tokens::currency::Currency as CurrencyT, OnUnbalanced as OnUnbalancedT, Everything,
+ Currency, ExistenceRequirement, Get, IsInVec, KeyOwnerProofSystem, LockIdentifier,
+ OnUnbalanced, Randomness, FindAuthor,
+ },
+ weights::{
+ constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND},
+ DispatchClass, DispatchInfo, GetDispatchInfo, IdentityFee, Pays, PostDispatchInfo, Weight,
+ WeightToFeePolynomial, WeightToFeeCoefficient, WeightToFeeCoefficients,
+ },
+};
+use up_data_structs::*;
+// use pallet_contracts::weights::WeightInfo;
+// #[cfg(any(feature = "std", test))]
+use frame_system::{
+ self as frame_system, EnsureRoot, EnsureSigned,
+ limits::{BlockWeights, BlockLength},
+};
+use sp_arithmetic::{
+ traits::{BaseArithmetic, Unsigned},
+};
+use smallvec::smallvec;
+use codec::{Encode, Decode};
+use pallet_evm::{Account as EVMAccount, FeeCalculator, GasWeightMapping, OnMethodCall};
+use fp_rpc::TransactionStatus;
+use sp_runtime::{
+ traits::{BlockNumberProvider, Dispatchable, PostDispatchInfoOf, Saturating},
+ transaction_validity::TransactionValidityError,
+ SaturatedConversion,
+};
+
+// pub use pallet_timestamp::Call as TimestampCall;
+
+// Polkadot imports
+use pallet_xcm::XcmPassthrough;
+use polkadot_parachain::primitives::Sibling;
+use xcm::v1::{BodyId, Junction::*, MultiLocation, NetworkId, Junctions::*};
+use xcm_builder::{
+ AccountId32Aliases, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, CurrencyAdapter,
+ EnsureXcmOrigin, FixedWeightBounds, LocationInverter, NativeAsset, ParentAsSuperuser,
+ RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia,
+ SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit,
+ ParentIsPreset,
+};
+use xcm_executor::{Config, XcmExecutor, Assets};
+use sp_std::{marker::PhantomData};
+
+use xcm::latest::{
+ // Xcm,
+ AssetId::{Concrete},
+ Fungibility::Fungible as XcmFungible,
+ MultiAsset,
+ Error as XcmError,
+};
+use xcm_executor::traits::{MatchesFungible, WeightTrader};
+//use xcm_executor::traits::MatchesFungible;
+use sp_runtime::traits::CheckedConversion;
+
+use unique_runtime_common::{impl_common_runtime_apis, types::*, constants::*};
+
+pub const RUNTIME_NAME: &str = "Unique";
+
+type CrossAccountId = pallet_common::account::BasicCrossAccountId<Runtime>;
+
+impl RuntimeInstance for Runtime {
+ type CrossAccountId = self::CrossAccountId;
+
+ type TransactionConverter = self::TransactionConverter;
+
+ fn get_transaction_converter() -> TransactionConverter {
+ TransactionConverter
+ }
+}
+
+/// Opaque types. These are used by the CLI to instantiate machinery that don't need to know
+/// the specifics of the runtime. They can then be made to be agnostic over specific formats
+/// of data like extrinsics, allowing for them to continue syncing the network through upgrades
+/// to even the core data structures.
+pub mod opaque {
+ use sp_std::prelude::*;
+ use sp_runtime::impl_opaque_keys;
+ use super::Aura;
+
+ pub use unique_runtime_common::types::*;
+
+ impl_opaque_keys! {
+ pub struct SessionKeys {
+ pub aura: Aura,
+ }
+ }
+}
+
+/// This runtime version.
+pub const VERSION: RuntimeVersion = RuntimeVersion {
+ spec_name: create_runtime_str!(RUNTIME_NAME),
+ impl_name: create_runtime_str!(RUNTIME_NAME),
+ authoring_version: 1,
+ spec_version: 917004,
+ impl_version: 0,
+ apis: RUNTIME_API_VERSIONS,
+ transaction_version: 1,
+ state_version: 0,
+};
+
+#[derive(codec::Encode, codec::Decode)]
+pub enum XCMPMessage<XAccountId, XBalance> {
+ /// Transfer tokens to the given account from the Parachain account.
+ TransferToken(XAccountId, XBalance),
+}
+
+/// The version information used to identify this runtime when compiled natively.
+#[cfg(feature = "std")]
+pub fn native_version() -> NativeVersion {
+ NativeVersion {
+ runtime_version: VERSION,
+ can_author_with: Default::default(),
+ }
+}
+
+type NegativeImbalance = <Balances as Currency<AccountId>>::NegativeImbalance;
+
+pub struct DealWithFees;
+impl OnUnbalanced<NegativeImbalance> for DealWithFees {
+ fn on_unbalanceds<B>(mut fees_then_tips: impl Iterator<Item = NegativeImbalance>) {
+ if let Some(fees) = fees_then_tips.next() {
+ // for fees, 100% to treasury
+ let mut split = fees.ration(100, 0);
+ if let Some(tips) = fees_then_tips.next() {
+ // for tips, if any, 100% to treasury
+ tips.ration_merge_into(100, 0, &mut split);
+ }
+ Treasury::on_unbalanced(split.0);
+ // Author::on_unbalanced(split.1);
+ }
+ }
+}
+
+parameter_types! {
+ pub const BlockHashCount: BlockNumber = 2400;
+ pub RuntimeBlockLength: BlockLength =
+ BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);
+ pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);
+ pub const MaximumBlockLength: u32 = 5 * 1024 * 1024;
+ pub RuntimeBlockWeights: BlockWeights = BlockWeights::builder()
+ .base_block(BlockExecutionWeight::get())
+ .for_class(DispatchClass::all(), |weights| {
+ weights.base_extrinsic = ExtrinsicBaseWeight::get();
+ })
+ .for_class(DispatchClass::Normal, |weights| {
+ weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT);
+ })
+ .for_class(DispatchClass::Operational, |weights| {
+ weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT);
+ // Operational transactions have some extra reserved space, so that they
+ // are included even if block reached `MAXIMUM_BLOCK_WEIGHT`.
+ weights.reserved = Some(
+ MAXIMUM_BLOCK_WEIGHT - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT
+ );
+ })
+ .avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO)
+ .build_or_panic();
+ pub const Version: RuntimeVersion = VERSION;
+ pub const SS58Prefix: u16 = 7391;
+}
+
+parameter_types! {
+ pub const ChainId: u64 = 8880;
+}
+
+pub struct FixedFee;
+impl FeeCalculator for FixedFee {
+ fn min_gas_price() -> U256 {
+ MIN_GAS_PRICE.into()
+ }
+}
+
+// Assuming slowest ethereum opcode is SSTORE, with gas price of 20000 as our worst case
+// (contract, which only writes a lot of data),
+// approximating on top of our real store write weight
+parameter_types! {
+ pub const WritesPerSecond: u64 = WEIGHT_PER_SECOND / <Runtime as frame_system::Config>::DbWeight::get().write;
+ pub const GasPerSecond: u64 = WritesPerSecond::get() * 20000;
+ pub const WeightPerGas: u64 = WEIGHT_PER_SECOND / GasPerSecond::get();
+}
+
+/// Limiting EVM execution to 50% of block for substrate users and management tasks
+/// EVM transaction consumes more weight than substrate's, so we can't rely on them being
+/// scheduled fairly
+const EVM_DISPATCH_RATIO: Perbill = Perbill::from_percent(50);
+parameter_types! {
+ pub BlockGasLimit: U256 = U256::from(NORMAL_DISPATCH_RATIO * EVM_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT / WeightPerGas::get());
+}
+
+pub enum FixedGasWeightMapping {}
+impl GasWeightMapping for FixedGasWeightMapping {
+ fn gas_to_weight(gas: u64) -> Weight {
+ gas.saturating_mul(WeightPerGas::get())
+ }
+ fn weight_to_gas(weight: Weight) -> u64 {
+ weight / WeightPerGas::get()
+ }
+}
+
+impl pallet_evm::Config for Runtime {
+ type BlockGasLimit = BlockGasLimit;
+ type FeeCalculator = FixedFee;
+ type GasWeightMapping = FixedGasWeightMapping;
+ type BlockHashMapping = pallet_ethereum::EthereumBlockHashMapping<Self>;
+ type CallOrigin = EnsureAddressTruncated;
+ type WithdrawOrigin = EnsureAddressTruncated;
+ type AddressMapping = HashedAddressMapping<Self::Hashing>;
+ type PrecompilesType = ();
+ type PrecompilesValue = ();
+ type Currency = Balances;
+ type Event = Event;
+ type OnMethodCall = (
+ pallet_evm_migration::OnMethodCall<Self>,
+ pallet_unique::UniqueErcSupport<Self>,
+ pallet_evm_contract_helpers::HelpersOnMethodCall<Self>,
+ );
+ type OnCreate = pallet_evm_contract_helpers::HelpersOnCreate<Self>;
+ type ChainId = ChainId;
+ type Runner = pallet_evm::runner::stack::Runner<Self>;
+ type OnChargeTransaction = pallet_evm_transaction_payment::OnChargeTransaction<Self>;
+ type TransactionValidityHack = pallet_evm_transaction_payment::TransactionValidityHack<Self>;
+ type FindAuthor = EthereumFindAuthor<Aura>;
+}
+
+impl pallet_evm_migration::Config for Runtime {
+ type WeightInfo = pallet_evm_migration::weights::SubstrateWeight<Self>;
+}
+
+pub struct EthereumFindAuthor<F>(core::marker::PhantomData<F>);
+impl<F: FindAuthor<u32>> FindAuthor<H160> for EthereumFindAuthor<F> {
+ fn find_author<'a, I>(digests: I) -> Option<H160>
+ where
+ I: 'a + IntoIterator<Item = (ConsensusEngineId, &'a [u8])>,
+ {
+ if let Some(author_index) = F::find_author(digests) {
+ let authority_id = Aura::authorities()[author_index as usize].clone();
+ return Some(H160::from_slice(&authority_id.to_raw_vec()[4..24]));
+ }
+ None
+ }
+}
+
+impl pallet_ethereum::Config for Runtime {
+ type Event = Event;
+ type StateRoot = pallet_ethereum::IntermediateStateRoot;
+}
+
+impl pallet_randomness_collective_flip::Config for Runtime {}
+
+impl frame_system::Config for Runtime {
+ /// The data to be stored in an account.
+ type AccountData = pallet_balances::AccountData<Balance>;
+ /// The identifier used to distinguish between accounts.
+ type AccountId = AccountId;
+ /// The basic call filter to use in dispatchable.
+ type BaseCallFilter = Everything;
+ /// Maximum number of block number to block hash mappings to keep (oldest pruned first).
+ type BlockHashCount = BlockHashCount;
+ /// The maximum length of a block (in bytes).
+ type BlockLength = RuntimeBlockLength;
+ /// The index type for blocks.
+ type BlockNumber = BlockNumber;
+ /// The weight of the overhead invoked on the block import process, independent of the extrinsics included in that block.
+ type BlockWeights = RuntimeBlockWeights;
+ /// The aggregated dispatch type that is available for extrinsics.
+ type Call = Call;
+ /// The weight of database operations that the runtime can invoke.
+ type DbWeight = RocksDbWeight;
+ /// The ubiquitous event type.
+ type Event = Event;
+ /// The type for hashing blocks and tries.
+ type Hash = Hash;
+ /// The hashing algorithm used.
+ type Hashing = BlakeTwo256;
+ /// The header type.
+ type Header = generic::Header<BlockNumber, BlakeTwo256>;
+ /// The index type for storing how many extrinsics an account has signed.
+ type Index = Index;
+ /// The lookup mechanism to get account ID from whatever is passed in dispatchers.
+ type Lookup = AccountIdLookup<AccountId, ()>;
+ /// What to do if an account is fully reaped from the system.
+ type OnKilledAccount = ();
+ /// What to do if a new account is created.
+ type OnNewAccount = ();
+ type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode<Self>;
+ /// The ubiquitous origin type.
+ type Origin = Origin;
+ /// This type is being generated by `construct_runtime!`.
+ type PalletInfo = PalletInfo;
+ /// This is used as an identifier of the chain. 42 is the generic substrate prefix.
+ type SS58Prefix = SS58Prefix;
+ /// Weight information for the extrinsics of this pallet.
+ type SystemWeightInfo = frame_system::weights::SubstrateWeight<Self>;
+ /// Version of the runtime.
+ type Version = Version;
+ type MaxConsumers = ConstU32<16>;
+}
+
+parameter_types! {
+ pub const MinimumPeriod: u64 = SLOT_DURATION / 2;
+}
+
+impl pallet_timestamp::Config for Runtime {
+ /// A timestamp: milliseconds since the unix epoch.
+ type Moment = u64;
+ type OnTimestampSet = ();
+ type MinimumPeriod = MinimumPeriod;
+ type WeightInfo = ();
+}
+
+parameter_types! {
+ // pub const ExistentialDeposit: u128 = 500;
+ pub const ExistentialDeposit: u128 = 0;
+ pub const MaxLocks: u32 = 50;
+}
+
+impl pallet_balances::Config for Runtime {
+ type MaxLocks = MaxLocks;
+ type MaxReserves = ();
+ type ReserveIdentifier = [u8; 8];
+ /// The type for recording an account's balance.
+ type Balance = Balance;
+ /// The ubiquitous event type.
+ type Event = Event;
+ type DustRemoval = Treasury;
+ type ExistentialDeposit = ExistentialDeposit;
+ type AccountStore = System;
+ type WeightInfo = pallet_balances::weights::SubstrateWeight<Self>;
+}
+
+pub const fn deposit(items: u32, bytes: u32) -> Balance {
+ items as Balance * 15 * CENTIUNIQUE + (bytes as Balance) * 6 * CENTIUNIQUE
+}
+
+/*
+parameter_types! {
+ pub TombstoneDeposit: Balance = deposit(
+ 1,
+ sp_std::mem::size_of::<pallet_contracts::Pallet<Runtime>> as u32,
+ );
+ pub DepositPerContract: Balance = TombstoneDeposit::get();
+ pub const DepositPerStorageByte: Balance = deposit(0, 1);
+ pub const DepositPerStorageItem: Balance = deposit(1, 0);
+ pub RentFraction: Perbill = Perbill::from_rational(1u32, 30 * DAYS);
+ pub const SurchargeReward: Balance = 150 * MILLIUNIQUE;
+ pub const SignedClaimHandicap: u32 = 2;
+ pub const MaxDepth: u32 = 32;
+ pub const MaxValueSize: u32 = 16 * 1024;
+ pub const MaxCodeSize: u32 = 1024 * 1024 * 25; // 25 Mb
+ // The lazy deletion runs inside on_initialize.
+ pub DeletionWeightLimit: Weight = AVERAGE_ON_INITIALIZE_RATIO *
+ RuntimeBlockWeights::get().max_block;
+ // The weight needed for decoding the queue should be less or equal than a fifth
+ // of the overall weight dedicated to the lazy deletion.
+ pub DeletionQueueDepth: u32 = ((DeletionWeightLimit::get() / (
+ <Runtime as pallet_contracts::Config>::WeightInfo::on_initialize_per_queue_item(1) -
+ <Runtime as pallet_contracts::Config>::WeightInfo::on_initialize_per_queue_item(0)
+ )) / 5) as u32;
+ pub Schedule: pallet_contracts::Schedule<Runtime> = Default::default();
+}
+
+impl pallet_contracts::Config for Runtime {
+ type Time = Timestamp;
+ type Randomness = RandomnessCollectiveFlip;
+ type Currency = Balances;
+ type Event = Event;
+ type RentPayment = ();
+ type SignedClaimHandicap = SignedClaimHandicap;
+ type TombstoneDeposit = TombstoneDeposit;
+ type DepositPerContract = DepositPerContract;
+ type DepositPerStorageByte = DepositPerStorageByte;
+ type DepositPerStorageItem = DepositPerStorageItem;
+ type RentFraction = RentFraction;
+ type SurchargeReward = SurchargeReward;
+ type WeightPrice = pallet_transaction_payment::Pallet<Self>;
+ type WeightInfo = pallet_contracts::weights::SubstrateWeight<Self>;
+ type ChainExtension = NFTExtension;
+ type DeletionQueueDepth = DeletionQueueDepth;
+ type DeletionWeightLimit = DeletionWeightLimit;
+ type Schedule = Schedule;
+ type CallStack = [pallet_contracts::Frame<Self>; 31];
+}
+*/
+
+parameter_types! {
+ /// This value increases the priority of `Operational` transactions by adding
+ /// a "virtual tip" that's equal to the `OperationalFeeMultiplier * final_fee`.
+ pub const OperationalFeeMultiplier: u8 = 5;
+}
+
+/// Linear implementor of `WeightToFeePolynomial`
+pub struct LinearFee<T>(sp_std::marker::PhantomData<T>);
+
+impl<T> WeightToFeePolynomial for LinearFee<T>
+where
+ T: BaseArithmetic + From<u32> + Copy + Unsigned,
+{
+ type Balance = T;
+
+ fn polynomial() -> WeightToFeeCoefficients<Self::Balance> {
+ smallvec!(WeightToFeeCoefficient {
+ // Targeting 0.1 Unique per NFT transfer
+ coeff_integer: WEIGHT_TO_FEE_COEFF.into(),
+ coeff_frac: Perbill::zero(),
+ negative: false,
+ degree: 1,
+ })
+ }
+}
+
+impl pallet_transaction_payment::Config for Runtime {
+ type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter<Balances, DealWithFees>;
+ type TransactionByteFee = TransactionByteFee;
+ type OperationalFeeMultiplier = OperationalFeeMultiplier;
+ type WeightToFee = LinearFee<Balance>;
+ type FeeMultiplierUpdate = ();
+}
+
+parameter_types! {
+ pub const ProposalBond: Permill = Permill::from_percent(5);
+ pub const ProposalBondMinimum: Balance = 1 * UNIQUE;
+ pub const ProposalBondMaximum: Balance = 1000 * UNIQUE;
+ pub const SpendPeriod: BlockNumber = 5 * MINUTES;
+ pub const Burn: Permill = Permill::from_percent(0);
+ pub const TipCountdown: BlockNumber = 1 * DAYS;
+ pub const TipFindersFee: Percent = Percent::from_percent(20);
+ pub const TipReportDepositBase: Balance = 1 * UNIQUE;
+ pub const DataDepositPerByte: Balance = 1 * CENTIUNIQUE;
+ pub const BountyDepositBase: Balance = 1 * UNIQUE;
+ pub const BountyDepositPayoutDelay: BlockNumber = 1 * DAYS;
+ pub const TreasuryModuleId: PalletId = PalletId(*b"py/trsry");
+ pub const BountyUpdatePeriod: BlockNumber = 14 * DAYS;
+ pub const MaximumReasonLength: u32 = 16384;
+ pub const BountyCuratorDeposit: Permill = Permill::from_percent(50);
+ pub const BountyValueMinimum: Balance = 5 * UNIQUE;
+ pub const MaxApprovals: u32 = 100;
+}
+
+impl pallet_treasury::Config for Runtime {
+ type PalletId = TreasuryModuleId;
+ type Currency = Balances;
+ type ApproveOrigin = EnsureRoot<AccountId>;
+ type RejectOrigin = EnsureRoot<AccountId>;
+ type Event = Event;
+ type OnSlash = ();
+ type ProposalBond = ProposalBond;
+ type ProposalBondMinimum = ProposalBondMinimum;
+ type ProposalBondMaximum = ProposalBondMaximum;
+ type SpendPeriod = SpendPeriod;
+ type Burn = Burn;
+ type BurnDestination = ();
+ type SpendFunds = ();
+ type WeightInfo = pallet_treasury::weights::SubstrateWeight<Self>;
+ type MaxApprovals = MaxApprovals;
+}
+
+impl pallet_sudo::Config for Runtime {
+ type Event = Event;
+ type Call = Call;
+}
+
+pub struct RelayChainBlockNumberProvider<T>(sp_std::marker::PhantomData<T>);
+
+impl<T: cumulus_pallet_parachain_system::Config> BlockNumberProvider
+ for RelayChainBlockNumberProvider<T>
+{
+ type BlockNumber = BlockNumber;
+
+ fn current_block_number() -> Self::BlockNumber {
+ cumulus_pallet_parachain_system::Pallet::<T>::validation_data()
+ .map(|d| d.relay_parent_number)
+ .unwrap_or_default()
+ }
+}
+
+parameter_types! {
+ pub const MinVestedTransfer: Balance = 10 * UNIQUE;
+ pub const MaxVestingSchedules: u32 = 28;
+}
+
+impl orml_vesting::Config for Runtime {
+ type Event = Event;
+ type Currency = pallet_balances::Pallet<Runtime>;
+ type MinVestedTransfer = MinVestedTransfer;
+ type VestedTransferOrigin = EnsureSigned<AccountId>;
+ type WeightInfo = ();
+ type MaxVestingSchedules = MaxVestingSchedules;
+ type BlockNumberProvider = RelayChainBlockNumberProvider<Runtime>;
+}
+
+parameter_types! {
+ pub const ReservedDmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;
+ pub const ReservedXcmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;
+}
+
+impl cumulus_pallet_parachain_system::Config for Runtime {
+ type Event = Event;
+ type SelfParaId = parachain_info::Pallet<Self>;
+ type OnSystemEvent = ();
+ // type DownwardMessageHandlers = cumulus_primitives_utility::UnqueuedDmpAsParent<
+ // MaxDownwardMessageWeight,
+ // XcmExecutor<XcmConfig>,
+ // Call,
+ // >;
+ type OutboundXcmpMessageSource = XcmpQueue;
+ type DmpMessageHandler = DmpQueue;
+ type ReservedDmpWeight = ReservedDmpWeight;
+ type ReservedXcmpWeight = ReservedXcmpWeight;
+ type XcmpMessageHandler = XcmpQueue;
+}
+
+impl parachain_info::Config for Runtime {}
+
+impl cumulus_pallet_aura_ext::Config for Runtime {}
+
+parameter_types! {
+ pub const RelayLocation: MultiLocation = MultiLocation::parent();
+ pub const RelayNetwork: NetworkId = NetworkId::Polkadot;
+ pub RelayOrigin: Origin = cumulus_pallet_xcm::Origin::Relay.into();
+ pub Ancestry: MultiLocation = Parachain(ParachainInfo::parachain_id().into()).into();
+}
+
+/// Type for specifying how a `MultiLocation` can be converted into an `AccountId`. This is used
+/// when determining ownership of accounts for asset transacting and when attempting to use XCM
+/// `Transact` in order to determine the dispatch Origin.
+pub type LocationToAccountId = (
+ // The parent (Relay-chain) origin converts to the default `AccountId`.
+ ParentIsPreset<AccountId>,
+ // Sibling parachain origins convert to AccountId via the `ParaId::into`.
+ SiblingParachainConvertsVia<Sibling, AccountId>,
+ // Straight up local `AccountId32` origins just alias directly to `AccountId`.
+ AccountId32Aliases<RelayNetwork, AccountId>,
+);
+
+pub struct OnlySelfCurrency;
+impl<B: TryFrom<u128>> MatchesFungible<B> for OnlySelfCurrency {
+ fn matches_fungible(a: &MultiAsset) -> Option<B> {
+ match (&a.id, &a.fun) {
+ (Concrete(_), XcmFungible(ref amount)) => CheckedConversion::checked_from(*amount),
+ _ => None,
+ }
+ }
+}
+
+/// Means for transacting assets on this chain.
+pub type LocalAssetTransactor = CurrencyAdapter<
+ // Use this currency:
+ Balances,
+ // Use this currency when it is a fungible asset matching the given location or name:
+ OnlySelfCurrency,
+ // Do a simple punn to convert an AccountId32 MultiLocation into a native chain account ID:
+ LocationToAccountId,
+ // Our chain's account ID type (we can't get away without mentioning it explicitly):
+ AccountId,
+ // We don't track any teleports.
+ (),
+>;
+
+/// This is the type we use to convert an (incoming) XCM origin into a local `Origin` instance,
+/// ready for dispatching a transaction with Xcm's `Transact`. There is an `OriginKind` which can
+/// biases the kind of local `Origin` it will become.
+pub type XcmOriginToTransactDispatchOrigin = (
+ // Sovereign account converter; this attempts to derive an `AccountId` from the origin location
+ // using `LocationToAccountId` and then turn that into the usual `Signed` origin. Useful for
+ // foreign chains who want to have a local sovereign account on this chain which they control.
+ SovereignSignedViaLocation<LocationToAccountId, Origin>,
+ // Native converter for Relay-chain (Parent) location; will converts to a `Relay` origin when
+ // recognised.
+ RelayChainAsNative<RelayOrigin, Origin>,
+ // Native converter for sibling Parachains; will convert to a `SiblingPara` origin when
+ // recognised.
+ SiblingParachainAsNative<cumulus_pallet_xcm::Origin, Origin>,
+ // Superuser converter for the Relay-chain (Parent) location. This will allow it to issue a
+ // transaction from the Root origin.
+ ParentAsSuperuser<Origin>,
+ // Native signed account converter; this just converts an `AccountId32` origin into a normal
+ // `Origin::Signed` origin of the same 32-byte value.
+ SignedAccountId32AsNative<RelayNetwork, Origin>,
+ // Xcm origins can be represented natively under the Xcm pallet's Xcm origin.
+ XcmPassthrough<Origin>,
+);
+
+parameter_types! {
+ // One XCM operation is 1_000_000 weight - almost certainly a conservative estimate.
+ pub UnitWeightCost: Weight = 1_000_000;
+ // 1200 UNIQUEs buy 1 second of weight.
+ pub const WeightPrice: (MultiLocation, u128) = (MultiLocation::parent(), 1_200 * UNIQUE);
+ pub const MaxInstructions: u32 = 100;
+ pub const MaxAuthorities: u32 = 100_000;
+}
+
+match_type! {
+ pub type ParentOrParentsUnitPlurality: impl Contains<MultiLocation> = {
+ MultiLocation { parents: 1, interior: Here } |
+ MultiLocation { parents: 1, interior: X1(Plurality { id: BodyId::Unit, .. }) }
+ };
+}
+
+pub type Barrier = (
+ TakeWeightCredit,
+ AllowTopLevelPaidExecutionFrom<Everything>,
+ AllowUnpaidExecutionFrom<ParentOrParentsUnitPlurality>,
+ // ^^^ Parent & its unit plurality gets free execution
+);
+
+pub struct UsingOnlySelfCurrencyComponents<
+ WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,
+ AssetId: Get<MultiLocation>,
+ AccountId,
+ Currency: CurrencyT<AccountId>,
+ OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,
+>(
+ Weight,
+ Currency::Balance,
+ PhantomData<(WeightToFee, AssetId, AccountId, Currency, OnUnbalanced)>,
+);
+impl<
+ WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,
+ AssetId: Get<MultiLocation>,
+ AccountId,
+ Currency: CurrencyT<AccountId>,
+ OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,
+ > WeightTrader
+ for UsingOnlySelfCurrencyComponents<WeightToFee, AssetId, AccountId, Currency, OnUnbalanced>
+{
+ fn new() -> Self {
+ Self(0, Zero::zero(), PhantomData)
+ }
+
+ fn buy_weight(&mut self, weight: Weight, payment: Assets) -> Result<Assets, XcmError> {
+ let amount = WeightToFee::calc(&weight);
+ let u128_amount: u128 = amount.try_into().map_err(|_| XcmError::Overflow)?;
+
+ // location to this parachain through relay chain
+ let option1: xcm::v1::AssetId = Concrete(MultiLocation {
+ parents: 1,
+ interior: X1(Parachain(ParachainInfo::parachain_id().into())),
+ });
+ // direct location
+ let option2: xcm::v1::AssetId = Concrete(MultiLocation {
+ parents: 0,
+ interior: Here,
+ });
+
+ let required = if payment.fungible.contains_key(&option1) {
+ (option1, u128_amount).into()
+ } else if payment.fungible.contains_key(&option2) {
+ (option2, u128_amount).into()
+ } else {
+ (Concrete(MultiLocation::default()), u128_amount).into()
+ };
+
+ let unused = payment
+ .checked_sub(required)
+ .map_err(|_| XcmError::TooExpensive)?;
+ self.0 = self.0.saturating_add(weight);
+ self.1 = self.1.saturating_add(amount);
+ Ok(unused)
+ }
+
+ fn refund_weight(&mut self, weight: Weight) -> Option<MultiAsset> {
+ let weight = weight.min(self.0);
+ let amount = WeightToFee::calc(&weight);
+ self.0 -= weight;
+ self.1 = self.1.saturating_sub(amount);
+ let amount: u128 = amount.saturated_into();
+ if amount > 0 {
+ Some((AssetId::get(), amount).into())
+ } else {
+ None
+ }
+ }
+}
+impl<
+ WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,
+ AssetId: Get<MultiLocation>,
+ AccountId,
+ Currency: CurrencyT<AccountId>,
+ OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,
+ > Drop
+ for UsingOnlySelfCurrencyComponents<WeightToFee, AssetId, AccountId, Currency, OnUnbalanced>
+{
+ fn drop(&mut self) {
+ OnUnbalanced::on_unbalanced(Currency::issue(self.1));
+ }
+}
+
+pub struct XcmConfig;
+impl Config for XcmConfig {
+ type Call = Call;
+ type XcmSender = XcmRouter;
+ // How to withdraw and deposit an asset.
+ type AssetTransactor = LocalAssetTransactor;
+ type OriginConverter = XcmOriginToTransactDispatchOrigin;
+ type IsReserve = NativeAsset;
+ type IsTeleporter = (); // Teleportation is disabled
+ type LocationInverter = LocationInverter<Ancestry>;
+ type Barrier = Barrier;
+ type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;
+ type Trader = UsingOnlySelfCurrencyComponents<
+ IdentityFee<Balance>,
+ RelayLocation,
+ AccountId,
+ Balances,
+ (),
+ >;
+ type ResponseHandler = (); // Don't handle responses for now.
+ type SubscriptionService = PolkadotXcm;
+
+ type AssetTrap = PolkadotXcm;
+ type AssetClaims = PolkadotXcm;
+}
+
+// parameter_types! {
+// pub const MaxDownwardMessageWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 10;
+// }
+
+/// No local origins on this chain are allowed to dispatch XCM sends/executions.
+pub type LocalOriginToLocation = (SignedToAccountId32<Origin, AccountId, RelayNetwork>,);
+
+/// The means for routing XCM messages which are not for local execution into the right message
+/// queues.
+pub type XcmRouter = (
+ // Two routers - use UMP to communicate with the relay chain:
+ cumulus_primitives_utility::ParentAsUmp<ParachainSystem, ()>,
+ // ..and XCMP to communicate with the sibling chains.
+ XcmpQueue,
+);
+
+impl pallet_evm_coder_substrate::Config for Runtime {
+ type EthereumTransactionSender = pallet_ethereum::Pallet<Self>;
+ type GasWeightMapping = FixedGasWeightMapping;
+}
+
+impl pallet_xcm::Config for Runtime {
+ type Event = Event;
+ type SendXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;
+ type XcmRouter = XcmRouter;
+ type ExecuteXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;
+ type XcmExecuteFilter = Everything;
+ type XcmExecutor = XcmExecutor<XcmConfig>;
+ type XcmTeleportFilter = Everything;
+ type XcmReserveTransferFilter = Everything;
+ type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;
+ type LocationInverter = LocationInverter<Ancestry>;
+ type Origin = Origin;
+ type Call = Call;
+ const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;
+ type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;
+}
+
+impl cumulus_pallet_xcm::Config for Runtime {
+ type Event = Event;
+ type XcmExecutor = XcmExecutor<XcmConfig>;
+}
+
+impl cumulus_pallet_xcmp_queue::Config for Runtime {
+ type Event = Event;
+ type XcmExecutor = XcmExecutor<XcmConfig>;
+ type ChannelInfo = ParachainSystem;
+ type VersionWrapper = ();
+ type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;
+ type ControllerOrigin = EnsureRoot<AccountId>;
+ type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin;
+}
+
+impl cumulus_pallet_dmp_queue::Config for Runtime {
+ type Event = Event;
+ type XcmExecutor = XcmExecutor<XcmConfig>;
+ type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;
+}
+
+impl pallet_aura::Config for Runtime {
+ type AuthorityId = AuraId;
+ type DisabledValidators = ();
+ type MaxAuthorities = MaxAuthorities;
+}
+
+parameter_types! {
+ pub TreasuryAccountId: AccountId = TreasuryModuleId::get().into_account();
+ pub const CollectionCreationPrice: Balance = 2 * UNIQUE;
+}
+
+impl pallet_common::Config for Runtime {
+ type Event = Event;
+ type EvmBackwardsAddressMapping = up_evm_mapping::MapBackwardsAddressTruncated;
+ type EvmAddressMapping = HashedAddressMapping<Self::Hashing>;
+ type CrossAccountId = pallet_common::account::BasicCrossAccountId<Self>;
+
+ type Currency = Balances;
+ type CollectionCreationPrice = CollectionCreationPrice;
+ type TreasuryAccountId = TreasuryAccountId;
+}
+
+impl pallet_fungible::Config for Runtime {
+ type WeightInfo = pallet_fungible::weights::SubstrateWeight<Self>;
+}
+impl pallet_refungible::Config for Runtime {
+ type WeightInfo = pallet_refungible::weights::SubstrateWeight<Self>;
+}
+impl pallet_nonfungible::Config for Runtime {
+ type WeightInfo = pallet_nonfungible::weights::SubstrateWeight<Self>;
+}
+
+impl pallet_unique::Config for Runtime {
+ type Event = Event;
+ type WeightInfo = pallet_unique::weights::SubstrateWeight<Self>;
+}
+
+parameter_types! {
+ pub const InflationBlockInterval: BlockNumber = 100; // every time per how many blocks inflation is applied
+}
+
+/// Used for the pallet inflation
+impl pallet_inflation::Config for Runtime {
+ type Currency = Balances;
+ type TreasuryAccountId = TreasuryAccountId;
+ type InflationBlockInterval = InflationBlockInterval;
+ type BlockNumberProvider = RelayChainBlockNumberProvider<Runtime>;
+}
+
+// parameter_types! {
+// pub MaximumSchedulerWeight: Weight = Perbill::from_percent(50) *
+// RuntimeBlockWeights::get().max_block;
+// pub const MaxScheduledPerBlock: u32 = 50;
+// }
+
+type EvmSponsorshipHandler = (
+ pallet_unique::UniqueEthSponsorshipHandler<Runtime>,
+ pallet_evm_contract_helpers::HelpersContractSponsoring<Runtime>,
+);
+type SponsorshipHandler = (
+ pallet_unique::UniqueSponsorshipHandler<Runtime>,
+ //pallet_contract_helpers::ContractSponsorshipHandler<Runtime>,
+ pallet_evm_transaction_payment::BridgeSponsorshipHandler<Runtime>,
+);
+
+// impl pallet_unq_scheduler::Config for Runtime {
+// type Event = Event;
+// type Origin = Origin;
+// type PalletsOrigin = OriginCaller;
+// type Call = Call;
+// type MaximumWeight = MaximumSchedulerWeight;
+// type ScheduleOrigin = EnsureSigned<AccountId>;
+// type MaxScheduledPerBlock = MaxScheduledPerBlock;
+// type SponsorshipHandler = SponsorshipHandler;
+// type WeightInfo = ();
+// }
+
+impl pallet_evm_transaction_payment::Config for Runtime {
+ type EvmSponsorshipHandler = EvmSponsorshipHandler;
+ type Currency = Balances;
+ type EvmAddressMapping = HashedAddressMapping<Self::Hashing>;
+ type EvmBackwardsAddressMapping = up_evm_mapping::MapBackwardsAddressTruncated;
+}
+
+impl pallet_charge_transaction::Config for Runtime {
+ type SponsorshipHandler = SponsorshipHandler;
+}
+
+// impl pallet_contract_helpers::Config for Runtime {
+// type DefaultSponsoringRateLimit = DefaultSponsoringRateLimit;
+// }
+
+parameter_types! {
+ // 0x842899ECF380553E8a4de75bF534cdf6fBF64049
+ pub const HelpersContractAddress: H160 = H160([
+ 0x84, 0x28, 0x99, 0xec, 0xf3, 0x80, 0x55, 0x3e, 0x8a, 0x4d, 0xe7, 0x5b, 0xf5, 0x34, 0xcd, 0xf6, 0xfb, 0xf6, 0x40, 0x49,
+ ]);
+}
+
+impl pallet_evm_contract_helpers::Config for Runtime {
+ type ContractAddress = HelpersContractAddress;
+ type DefaultSponsoringRateLimit = DefaultSponsoringRateLimit;
+}
+
+construct_runtime!(
+ pub enum Runtime where
+ Block = Block,
+ NodeBlock = opaque::Block,
+ UncheckedExtrinsic = UncheckedExtrinsic
+ {
+ ParachainSystem: cumulus_pallet_parachain_system::{Pallet, Call, Config, Storage, Inherent, Event<T>, ValidateUnsigned} = 20,
+ ParachainInfo: parachain_info::{Pallet, Storage, Config} = 21,
+
+ Aura: pallet_aura::{Pallet, Config<T>} = 22,
+ AuraExt: cumulus_pallet_aura_ext::{Pallet, Config} = 23,
+
+ Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>} = 30,
+ RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Pallet, Storage} = 31,
+ Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent} = 32,
+ TransactionPayment: pallet_transaction_payment::{Pallet, Storage} = 33,
+ Treasury: pallet_treasury::{Pallet, Call, Storage, Config, Event<T>} = 34,
+ Sudo: pallet_sudo::{Pallet, Call, Storage, Config<T>, Event<T>} = 35,
+ System: frame_system::{Pallet, Call, Storage, Config, Event<T>} = 36,
+ Vesting: orml_vesting::{Pallet, Storage, Call, Event<T>, Config<T>} = 37,
+ // Vesting: pallet_vesting::{Pallet, Call, Config<T>, Storage, Event<T>} = 37,
+ // Contracts: pallet_contracts::{Pallet, Call, Storage, Event<T>} = 38,
+
+ // XCM helpers.
+ XcmpQueue: cumulus_pallet_xcmp_queue::{Pallet, Call, Storage, Event<T>} = 50,
+ PolkadotXcm: pallet_xcm::{Pallet, Call, Event<T>, Origin} = 51,
+ CumulusXcm: cumulus_pallet_xcm::{Pallet, Call, Event<T>, Origin} = 52,
+ DmpQueue: cumulus_pallet_dmp_queue::{Pallet, Call, Storage, Event<T>} = 53,
+
+ // Unique Pallets
+ Inflation: pallet_inflation::{Pallet, Call, Storage} = 60,
+ Unique: pallet_unique::{Pallet, Call, Storage, Event<T>} = 61,
+ // Scheduler: pallet_unq_scheduler::{Pallet, Call, Storage, Event<T>} = 62,
+ // free = 63
+ Charging: pallet_charge_transaction::{Pallet, Call, Storage } = 64,
+ // ContractHelpers: pallet_contract_helpers::{Pallet, Call, Storage} = 65,
+ Common: pallet_common::{Pallet, Storage, Event<T>} = 66,
+ Fungible: pallet_fungible::{Pallet, Storage} = 67,
+ Refungible: pallet_refungible::{Pallet, Storage} = 68,
+ Nonfungible: pallet_nonfungible::{Pallet, Storage} = 69,
+
+ // Frontier
+ EVM: pallet_evm::{Pallet, Config, Call, Storage, Event<T>} = 100,
+ Ethereum: pallet_ethereum::{Pallet, Config, Call, Storage, Event, Origin} = 101,
+
+ EvmCoderSubstrate: pallet_evm_coder_substrate::{Pallet, Storage} = 150,
+ EvmContractHelpers: pallet_evm_contract_helpers::{Pallet, Storage} = 151,
+ EvmTransactionPayment: pallet_evm_transaction_payment::{Pallet} = 152,
+ EvmMigration: pallet_evm_migration::{Pallet, Call, Storage} = 153,
+ }
+);
+
+pub struct TransactionConverter;
+
+impl fp_rpc::ConvertTransaction<UncheckedExtrinsic> for TransactionConverter {
+ fn convert_transaction(&self, transaction: pallet_ethereum::Transaction) -> UncheckedExtrinsic {
+ UncheckedExtrinsic::new_unsigned(
+ pallet_ethereum::Call::<Runtime>::transact { transaction }.into(),
+ )
+ }
+}
+
+impl fp_rpc::ConvertTransaction<opaque::UncheckedExtrinsic> for TransactionConverter {
+ fn convert_transaction(
+ &self,
+ transaction: pallet_ethereum::Transaction,
+ ) -> opaque::UncheckedExtrinsic {
+ let extrinsic = UncheckedExtrinsic::new_unsigned(
+ pallet_ethereum::Call::<Runtime>::transact { transaction }.into(),
+ );
+ let encoded = extrinsic.encode();
+ opaque::UncheckedExtrinsic::decode(&mut &encoded[..])
+ .expect("Encoded extrinsic is always valid")
+ }
+}
+
+/// The address format for describing accounts.
+pub type Address = sp_runtime::MultiAddress<AccountId, ()>;
+/// Block header type as expected by this runtime.
+pub type Header = generic::Header<BlockNumber, BlakeTwo256>;
+/// Block type as expected by this runtime.
+pub type Block = generic::Block<Header, UncheckedExtrinsic>;
+/// A Block signed with a Justification
+pub type SignedBlock = generic::SignedBlock<Block>;
+/// BlockId type as expected by this runtime.
+pub type BlockId = generic::BlockId<Block>;
+/// The SignedExtension to the basic transaction logic.
+pub type SignedExtra = (
+ frame_system::CheckSpecVersion<Runtime>,
+ // system::CheckTxVersion<Runtime>,
+ frame_system::CheckGenesis<Runtime>,
+ frame_system::CheckEra<Runtime>,
+ frame_system::CheckNonce<Runtime>,
+ frame_system::CheckWeight<Runtime>,
+ pallet_charge_transaction::ChargeTransactionPayment<Runtime>,
+ //pallet_contract_helpers::ContractHelpersExtension<Runtime>,
+);
+/// Unchecked extrinsic type as expected by this runtime.
+pub type UncheckedExtrinsic =
+ fp_self_contained::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;
+/// Extrinsic type that has already been checked.
+pub type CheckedExtrinsic = fp_self_contained::CheckedExtrinsic<AccountId, Call, SignedExtra, H160>;
+/// Executive: handles dispatch to the various modules.
+pub type Executive = frame_executive::Executive<
+ Runtime,
+ Block,
+ frame_system::ChainContext<Runtime>,
+ Runtime,
+ AllPalletsReversedWithSystemFirst,
+>;
+
+impl_opaque_keys! {
+ pub struct SessionKeys {
+ pub aura: Aura,
+ }
+}
+
+impl fp_self_contained::SelfContainedCall for Call {
+ type SignedInfo = H160;
+
+ fn is_self_contained(&self) -> bool {
+ match self {
+ Call::Ethereum(call) => call.is_self_contained(),
+ _ => false,
+ }
+ }
+
+ fn check_self_contained(&self) -> Option<Result<Self::SignedInfo, TransactionValidityError>> {
+ match self {
+ Call::Ethereum(call) => call.check_self_contained(),
+ _ => None,
+ }
+ }
+
+ fn validate_self_contained(&self, info: &Self::SignedInfo) -> Option<TransactionValidity> {
+ match self {
+ Call::Ethereum(call) => call.validate_self_contained(info),
+ _ => None,
+ }
+ }
+
+ fn pre_dispatch_self_contained(
+ &self,
+ info: &Self::SignedInfo,
+ ) -> Option<Result<(), TransactionValidityError>> {
+ match self {
+ Call::Ethereum(call) => call.pre_dispatch_self_contained(info),
+ _ => None,
+ }
+ }
+
+ fn apply_self_contained(
+ self,
+ info: Self::SignedInfo,
+ ) -> Option<sp_runtime::DispatchResultWithInfo<PostDispatchInfoOf<Self>>> {
+ match self {
+ call @ Call::Ethereum(pallet_ethereum::Call::transact { .. }) => Some(call.dispatch(
+ Origin::from(pallet_ethereum::RawOrigin::EthereumTransaction(info)),
+ )),
+ _ => None,
+ }
+ }
+}
+
+macro_rules! dispatch_unique_runtime {
+ ($collection:ident.$method:ident($($name:ident),*)) => {{
+ use pallet_unique::dispatch::Dispatched;
+
+ let collection = Dispatched::dispatch(<pallet_common::CollectionHandle<Runtime>>::try_get($collection)?);
+ let dispatch = collection.as_dyn();
+
+ Ok(dispatch.$method($($name),*))
+ }};
+}
+
+impl_common_runtime_apis!();
+
+struct CheckInherents;
+
+impl cumulus_pallet_parachain_system::CheckInherents<Block> for CheckInherents {
+ fn check_inherents(
+ block: &Block,
+ relay_state_proof: &cumulus_pallet_parachain_system::RelayChainStateProof,
+ ) -> sp_inherents::CheckInherentsResult {
+ let relay_chain_slot = relay_state_proof
+ .read_slot()
+ .expect("Could not read the relay chain slot from the proof");
+
+ let inherent_data =
+ cumulus_primitives_timestamp::InherentDataProvider::from_relay_chain_slot_and_duration(
+ relay_chain_slot,
+ sp_std::time::Duration::from_secs(6),
+ )
+ .create_inherent_data()
+ .expect("Could not create the timestamp inherent data");
+
+ inherent_data.check_extrinsics(block)
+ }
+}
+
+cumulus_pallet_parachain_system::register_validate_block!(
+ Runtime = Runtime,
+ BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor::<Runtime, Executive>,
+ CheckInherents = CheckInherents,
+);