From 3a5bc4c1a69122c5d0923afe522fe295a50ecfe3 Mon Sep 17 00:00:00 2001 From: Jeeyong Um Date: Mon, 16 Sep 2024 12:56:45 +0900 Subject: [PATCH] chore: Remove temporary node template (#71) --- Cargo.toml | 3 - node/Cargo.toml | 66 --- node/build.rs | 7 - node/src/benchmarking.rs | 181 ------ node/src/chain_spec.rs | 146 ----- node/src/cli.rs | 64 --- node/src/command.rs | 214 ------- node/src/main.rs | 31 - node/src/rpc.rs | 82 --- node/src/service.rs | 351 ------------ runtime/solochain/Cargo.toml | 108 ---- runtime/solochain/build.rs | 23 - runtime/solochain/src/apis.rs | 539 ------------------ runtime/solochain/src/call.rs | 134 ----- runtime/solochain/src/configs/address_map.rs | 29 - runtime/solochain/src/configs/aura.rs | 30 - runtime/solochain/src/configs/babel.rs | 23 - runtime/solochain/src/configs/balances.rs | 41 -- runtime/solochain/src/configs/base_fee.rs | 47 -- runtime/solochain/src/configs/ethereum.rs | 33 -- runtime/solochain/src/configs/evm.rs | 62 -- runtime/solochain/src/configs/grandpa.rs | 32 -- runtime/solochain/src/configs/mod.rs | 42 -- runtime/solochain/src/configs/sudo.rs | 25 - runtime/solochain/src/configs/system.rs | 70 --- runtime/solochain/src/configs/timestamp.rs | 29 - .../src/configs/transaction_payment.rs | 58 -- runtime/solochain/src/lib.rs | 107 ---- runtime/solochain/src/prelude.rs | 22 - runtime/solochain/src/primitives.rs | 74 --- runtime/solochain/src/version.rs | 42 -- 31 files changed, 2715 deletions(-) delete mode 100644 node/Cargo.toml delete mode 100644 node/build.rs delete mode 100644 node/src/benchmarking.rs delete mode 100644 node/src/chain_spec.rs delete mode 100644 node/src/cli.rs delete mode 100644 node/src/command.rs delete mode 100644 node/src/main.rs delete mode 100644 node/src/rpc.rs delete mode 100644 node/src/service.rs delete mode 100644 runtime/solochain/Cargo.toml delete mode 100644 runtime/solochain/build.rs delete mode 100644 runtime/solochain/src/apis.rs delete mode 100644 runtime/solochain/src/call.rs delete mode 100644 runtime/solochain/src/configs/address_map.rs delete mode 100644 runtime/solochain/src/configs/aura.rs delete mode 100644 runtime/solochain/src/configs/babel.rs delete mode 100644 runtime/solochain/src/configs/balances.rs delete mode 100644 runtime/solochain/src/configs/base_fee.rs delete mode 100644 runtime/solochain/src/configs/ethereum.rs delete mode 100644 runtime/solochain/src/configs/evm.rs delete mode 100644 runtime/solochain/src/configs/grandpa.rs delete mode 100644 runtime/solochain/src/configs/mod.rs delete mode 100644 runtime/solochain/src/configs/sudo.rs delete mode 100644 runtime/solochain/src/configs/system.rs delete mode 100644 runtime/solochain/src/configs/timestamp.rs delete mode 100644 runtime/solochain/src/configs/transaction_payment.rs delete mode 100644 runtime/solochain/src/lib.rs delete mode 100644 runtime/solochain/src/prelude.rs delete mode 100644 runtime/solochain/src/primitives.rs delete mode 100644 runtime/solochain/src/version.rs diff --git a/Cargo.toml b/Cargo.toml index 059e3cd3..a5057456 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,19 +4,16 @@ members = [ "core-primitives", "frame/babel", "frame/multimap", - "node", "primitives/cosmos", "primitives/ethereum", "primitives/runtime", "runtime/common", - "runtime/solochain", ] [workspace.dependencies] frame-babel = { path = "frame/babel", default-features = false } noir-core-primitives = { path = "core-primitives", default-features = false } noir-runtime-common = { path = "runtime/common", default-features = false } -noir-solochain-runtime = { path = "runtime/solochain", default-features = false } np-cosmos = { path = "primitives/cosmos", default-features = false } np-ethereum = { path = "primitives/ethereum", default-features = false } np-runtime = { path = "primitives/runtime", default-features = false } diff --git a/node/Cargo.toml b/node/Cargo.toml deleted file mode 100644 index b1342df2..00000000 --- a/node/Cargo.toml +++ /dev/null @@ -1,66 +0,0 @@ -[package] -name = "noir-node" -version = "0.4.0" -authors = ["Haderech Pte. Ltd."] -edition = "2021" -license = "GPL-3.0-or-later" -repository = "https://github.com/noirhq/noir.git" -publish = false - -[dependencies] -clap = { version = "4.5", features = ["derive"] } -futures = { version = "0.3", features = ["thread-pool"] } -serde_json = "1.0" -jsonrpsee = { version = "0.23", features = ["server"] } -frame-babel = { workspace = true, default-features = true } -frame-benchmarking-cli = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2407" } -frame-system = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2407" } -noir-solochain-runtime = { workspace = true, default-features = true } -pallet-transaction-payment = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2407" } -pallet-transaction-payment-rpc = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2407" } -sc-basic-authorship = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2407" } -sc-chain-spec = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2407" } -sc-cli = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2407" } -sc-client-api = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2407" } -sc-consensus = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2407" } -sc-consensus-aura = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2407" } -sc-consensus-grandpa = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2407" } -sc-executor = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2407" } -sc-network = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2407" } -sc-offchain = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2407" } -sc-rpc-api = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2407" } -sc-service = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2407" } -sc-telemetry = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2407" } -sc-transaction-pool = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2407" } -sc-transaction-pool-api = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2407" } -sp-api = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2407" } -sp-block-builder = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2407" } -sp-blockchain = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2407" } -sp-consensus-aura = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2407" } -sp-consensus-grandpa = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2407" } -sp-core = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2407" } -sp-inherents = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2407" } -sp-io = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2407" } -sp-keyring = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2407" } -sp-runtime = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2407" } -sp-timestamp = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2407" } -substrate-frame-rpc-system = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2407" } - -[build-dependencies] -substrate-build-script-utils = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2407" } - -[features] -default = [] -runtime-benchmarks = [ - "frame-benchmarking-cli/runtime-benchmarks", - "frame-system/runtime-benchmarks", - "sc-service/runtime-benchmarks", - "noir-solochain-runtime/runtime-benchmarks", - "sp-runtime/runtime-benchmarks", -] -try-runtime = [ - "frame-system/try-runtime", - "pallet-transaction-payment/try-runtime", - "noir-solochain-runtime/try-runtime", - "sp-runtime/try-runtime", -] diff --git a/node/build.rs b/node/build.rs deleted file mode 100644 index e3bfe311..00000000 --- a/node/build.rs +++ /dev/null @@ -1,7 +0,0 @@ -use substrate_build_script_utils::{generate_cargo_keys, rerun_if_git_head_changed}; - -fn main() { - generate_cargo_keys(); - - rerun_if_git_head_changed(); -} diff --git a/node/src/benchmarking.rs b/node/src/benchmarking.rs deleted file mode 100644 index 27786162..00000000 --- a/node/src/benchmarking.rs +++ /dev/null @@ -1,181 +0,0 @@ -// This file is part of Noir. - -// Copyright (c) Haderech Pte. Ltd. -// SPDX-License-Identifier: GPL-3.0-or-later - -// This program 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. -// -// This program 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 this program. If not, see . - -//! Setup code for [`super::command`] which would otherwise bloat that module. -//! -//! Should only be used for benchmarking as it may break in other contexts. - -use noir_solochain_runtime::prelude::*; - -use crate::service::FullClient; -use noir_solochain_runtime as runtime; -use sc_cli::Result; -use sc_client_api::BlockBackend; -use sp_core::{Encode, Pair}; -use sp_inherents::{InherentData, InherentDataProvider}; -use sp_keyring::Sr25519Keyring; -use sp_runtime::{OpaqueExtrinsic, SaturatedConversion}; - -use std::{sync::Arc, time::Duration}; - -/// Generates extrinsics for the `benchmark overhead` command. -/// -/// Note: Should only be used for benchmarking. -pub struct RemarkBuilder { - client: Arc, -} - -impl RemarkBuilder { - /// Creates a new [`Self`] from the given client. - pub fn new(client: Arc) -> Self { - Self { client } - } -} - -impl frame_benchmarking_cli::ExtrinsicBuilder for RemarkBuilder { - fn pallet(&self) -> &str { - "system" - } - - fn extrinsic(&self) -> &str { - "remark" - } - - fn build(&self, nonce: u32) -> std::result::Result { - let acc = Sr25519Keyring::Bob.pair(); - let extrinsic: OpaqueExtrinsic = create_benchmark_extrinsic( - self.client.as_ref(), - acc, - SystemCall::remark { remark: vec![] }.into(), - nonce, - ) - .into(); - - Ok(extrinsic) - } -} - -/// Generates `Balances::TransferKeepAlive` extrinsics for the benchmarks. -/// -/// Note: Should only be used for benchmarking. -pub struct TransferKeepAliveBuilder { - client: Arc, - dest: AccountId, - value: Balance, -} - -impl TransferKeepAliveBuilder { - /// Creates a new [`Self`] from the given client. - pub fn new(client: Arc, dest: AccountId, value: Balance) -> Self { - Self { client, dest, value } - } -} - -impl frame_benchmarking_cli::ExtrinsicBuilder for TransferKeepAliveBuilder { - fn pallet(&self) -> &str { - "balances" - } - - fn extrinsic(&self) -> &str { - "transfer_keep_alive" - } - - fn build(&self, nonce: u32) -> std::result::Result { - let acc = Sr25519Keyring::Bob.pair(); - let extrinsic: OpaqueExtrinsic = create_benchmark_extrinsic( - self.client.as_ref(), - acc, - BalancesCall::transfer_keep_alive { dest: self.dest.clone().into(), value: self.value } - .into(), - nonce, - ) - .into(); - - Ok(extrinsic) - } -} - -/// Create a transaction using the given `call`. -/// -/// Note: Should only be used for benchmarking. -pub fn create_benchmark_extrinsic( - client: &FullClient, - sender: sp_core::sr25519::Pair, - call: runtime::RuntimeCall, - nonce: u32, -) -> runtime::UncheckedExtrinsic { - let genesis_hash = client.block_hash(0).ok().flatten().expect("Genesis block exists; qed"); - let best_hash = client.chain_info().best_hash; - let best_block = client.chain_info().best_number; - - let period = runtime::common::BlockHashCount::get() - .checked_next_power_of_two() - .map(|c| c / 2) - .unwrap_or(2) as u64; - let extra: runtime::SignedExtra = ( - frame_system::CheckNonZeroSender::::new(), - frame_system::CheckSpecVersion::::new(), - frame_system::CheckTxVersion::::new(), - frame_system::CheckGenesis::::new(), - frame_system::CheckEra::::from(sp_runtime::generic::Era::mortal( - period, - best_block.saturated_into(), - )), - frame_system::CheckNonce::::from(nonce), - frame_babel::UnifyAccount::::new(), - frame_system::CheckWeight::::new(), - pallet_transaction_payment::ChargeTransactionPayment::::from(0), - ); - - let raw_payload = runtime::SignedPayload::from_raw( - call.clone(), - extra.clone(), - ( - (), - runtime::VERSION.spec_version, - runtime::VERSION.transaction_version, - genesis_hash, - best_hash, - (), - (), - (), - (), - ), - ); - let signature = raw_payload.using_encoded(|e| sender.sign(e)); - - runtime::UncheckedExtrinsic::new_signed( - call, - AccountId::from(sender.public()).into(), - runtime::Signature::Sr25519(signature), - extra, - ) -} - -/// Generates inherent data for the `benchmark overhead` command. -/// -/// Note: Should only be used for benchmarking. -pub fn inherent_benchmark_data() -> Result { - let mut inherent_data = InherentData::new(); - let d = Duration::from_millis(0); - let timestamp = sp_timestamp::InherentDataProvider::new(d.into()); - - futures::executor::block_on(timestamp.provide_inherent_data(&mut inherent_data)) - .map_err(|e| format!("creating inherent data: {:?}", e))?; - Ok(inherent_data) -} diff --git a/node/src/chain_spec.rs b/node/src/chain_spec.rs deleted file mode 100644 index 3d7af14b..00000000 --- a/node/src/chain_spec.rs +++ /dev/null @@ -1,146 +0,0 @@ -// This file is part of Noir. - -// Copyright (c) Haderech Pte. Ltd. -// SPDX-License-Identifier: GPL-3.0-or-later - -// This program 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. -// -// This program 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 this program. If not, see . - -use noir_solochain_runtime::prelude::*; - -use sc_chain_spec::Properties; -use sc_service::ChainType; -use sp_consensus_aura::sr25519::AuthorityId as AuraId; -use sp_consensus_grandpa::AuthorityId as GrandpaId; -use sp_core::{sr25519, Pair, Public}; -use sp_runtime::traits::{IdentifyAccount, Verify}; - -// The URL for the telemetry server. -// const STAGING_TELEMETRY_URL: &str = "wss://telemetry.polkadot.io/submit/"; - -/// Specialized `ChainSpec`. This is a specialization of the general Substrate ChainSpec type. -pub type ChainSpec = sc_service::GenericChainSpec; - -fn properties() -> Properties { - let mut properties = Properties::new(); - properties.insert("tokenDecimals".to_string(), 18.into()); - properties.insert("tokenSymbol".to_string(), "DAB".into()); - properties -} - -/// Generate a crypto pair from seed. -pub fn get_from_seed(seed: &str) -> ::Public { - TPublic::Pair::from_string(&format!("//{}", seed), None) - .expect("static values are valid; qed") - .public() -} - -type AccountPublic = ::Signer; - -/// Generate an account ID from seed. -pub fn get_account_id_from_seed(seed: &str) -> AccountId -where - AccountPublic: From<::Public>, -{ - AccountPublic::from(get_from_seed::(seed)).into_account() -} - -/// Generate an Aura authority key. -pub fn authority_keys_from_seed(s: &str) -> (AuraId, GrandpaId) { - (get_from_seed::(s), get_from_seed::(s)) -} - -pub fn development_config() -> Result { - Ok(ChainSpec::builder( - WASM_BINARY.ok_or_else(|| "Development wasm not available".to_string())?, - None, - ) - .with_name("Development") - .with_id("dev") - .with_chain_type(ChainType::Development) - .with_genesis_config_patch(testnet_genesis( - // Initial PoA authorities - vec![authority_keys_from_seed("Alice")], - // Sudo account - get_account_id_from_seed::("Alice"), - // Pre-funded accounts - vec![ - get_account_id_from_seed::("Alice"), - get_account_id_from_seed::("Bob"), - get_account_id_from_seed::("Alice//stash"), - get_account_id_from_seed::("Bob//stash"), - ], - true, - )) - .with_properties(properties()) - .build()) -} - -pub fn local_testnet_config() -> Result { - Ok(ChainSpec::builder( - WASM_BINARY.ok_or_else(|| "Development wasm not available".to_string())?, - None, - ) - .with_name("Local Testnet") - .with_id("local_testnet") - .with_chain_type(ChainType::Local) - .with_genesis_config_patch(testnet_genesis( - // Initial PoA authorities - vec![authority_keys_from_seed("Alice"), authority_keys_from_seed("Bob")], - // Sudo account - get_account_id_from_seed::("Alice"), - // Pre-funded accounts - vec![ - get_account_id_from_seed::("Alice"), - get_account_id_from_seed::("Bob"), - get_account_id_from_seed::("Charlie"), - get_account_id_from_seed::("Dave"), - get_account_id_from_seed::("Eve"), - get_account_id_from_seed::("Ferdie"), - get_account_id_from_seed::("Alice//stash"), - get_account_id_from_seed::("Bob//stash"), - get_account_id_from_seed::("Charlie//stash"), - get_account_id_from_seed::("Dave//stash"), - get_account_id_from_seed::("Eve//stash"), - get_account_id_from_seed::("Ferdie//stash"), - ], - true, - )) - .with_properties(properties()) - .build()) -} - -/// Configure initial storage state for FRAME modules. -fn testnet_genesis( - initial_authorities: Vec<(AuraId, GrandpaId)>, - root_key: AccountId, - endowed_accounts: Vec, - _enable_println: bool, -) -> serde_json::Value { - serde_json::json!({ - "balances": { - // Configure endowed accounts with initial balance of 1 << 60. - "balances": endowed_accounts.iter().cloned().map(|k| (k, 1u64 << 60)).collect::>(), - }, - "aura": { - "authorities": initial_authorities.iter().map(|x| (x.0.clone())).collect::>(), - }, - "grandpa": { - "authorities": initial_authorities.iter().map(|x| (x.1.clone(), 1)).collect::>(), - }, - "sudo": { - // Assign network admin rights. - "key": Some(root_key), - }, - }) -} diff --git a/node/src/cli.rs b/node/src/cli.rs deleted file mode 100644 index 595511d6..00000000 --- a/node/src/cli.rs +++ /dev/null @@ -1,64 +0,0 @@ -// This file is part of Noir. - -// Copyright (c) Haderech Pte. Ltd. -// SPDX-License-Identifier: GPL-3.0-or-later - -// This program 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. -// -// This program 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 this program. If not, see . - -use sc_cli::RunCmd; - -#[derive(Debug, clap::Parser)] -pub struct Cli { - #[command(subcommand)] - pub subcommand: Option, - - #[clap(flatten)] - pub run: RunCmd, -} - -#[derive(Debug, clap::Subcommand)] -#[allow(clippy::large_enum_variant)] -pub enum Subcommand { - /// Key management cli utilities - #[command(subcommand)] - Key(sc_cli::KeySubcommand), - - /// Build a chain specification. - BuildSpec(sc_cli::BuildSpecCmd), - - /// Validate blocks. - CheckBlock(sc_cli::CheckBlockCmd), - - /// Export blocks. - ExportBlocks(sc_cli::ExportBlocksCmd), - - /// Export the state of a given block into a chain spec. - ExportState(sc_cli::ExportStateCmd), - - /// Import blocks. - ImportBlocks(sc_cli::ImportBlocksCmd), - - /// Remove the whole chain. - PurgeChain(sc_cli::PurgeChainCmd), - - /// Revert the chain to a previous state. - Revert(sc_cli::RevertCmd), - - /// Sub-commands concerned with benchmarking. - #[command(subcommand)] - Benchmark(frame_benchmarking_cli::BenchmarkCmd), - - /// Db meta columns information. - ChainInfo(sc_cli::ChainInfoCmd), -} diff --git a/node/src/command.rs b/node/src/command.rs deleted file mode 100644 index 797ae7c0..00000000 --- a/node/src/command.rs +++ /dev/null @@ -1,214 +0,0 @@ -// This file is part of Noir. - -// Copyright (c) Haderech Pte. Ltd. -// SPDX-License-Identifier: GPL-3.0-or-later - -// This program 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. -// -// This program 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 this program. If not, see . - -use noir_solochain_runtime::prelude::*; - -use crate::{ - benchmarking::{inherent_benchmark_data, RemarkBuilder, TransferKeepAliveBuilder}, - chain_spec, - cli::{Cli, Subcommand}, - service, -}; -use frame_benchmarking_cli::{BenchmarkCmd, ExtrinsicFactory, SUBSTRATE_REFERENCE_HARDWARE}; -use sc_cli::SubstrateCli; -use sc_service::PartialComponents; -use sp_keyring::Sr25519Keyring; - -impl SubstrateCli for Cli { - fn impl_name() -> String { - "Substrate Node".into() - } - - fn impl_version() -> String { - env!("SUBSTRATE_CLI_IMPL_VERSION").into() - } - - fn description() -> String { - env!("CARGO_PKG_DESCRIPTION").into() - } - - fn author() -> String { - env!("CARGO_PKG_AUTHORS").into() - } - - fn support_url() -> String { - "support.anonymous.an".into() - } - - fn copyright_start_year() -> i32 { - 2017 - } - - fn load_spec(&self, id: &str) -> Result, String> { - Ok(match id { - "dev" => Box::new(chain_spec::development_config()?), - "" | "local" => Box::new(chain_spec::local_testnet_config()?), - path => - Box::new(chain_spec::ChainSpec::from_json_file(std::path::PathBuf::from(path))?), - }) - } -} - -/// Parse and run command line arguments -pub fn run() -> sc_cli::Result<()> { - let cli = Cli::from_args(); - - match &cli.subcommand { - Some(Subcommand::Key(cmd)) => cmd.run(&cli), - Some(Subcommand::BuildSpec(cmd)) => { - let runner = cli.create_runner(cmd)?; - runner.sync_run(|config| cmd.run(config.chain_spec, config.network)) - }, - Some(Subcommand::CheckBlock(cmd)) => { - let runner = cli.create_runner(cmd)?; - runner.async_run(|config| { - let PartialComponents { client, task_manager, import_queue, .. } = - service::new_partial(&config)?; - Ok((cmd.run(client, import_queue), task_manager)) - }) - }, - Some(Subcommand::ExportBlocks(cmd)) => { - let runner = cli.create_runner(cmd)?; - runner.async_run(|config| { - let PartialComponents { client, task_manager, .. } = service::new_partial(&config)?; - Ok((cmd.run(client, config.database), task_manager)) - }) - }, - Some(Subcommand::ExportState(cmd)) => { - let runner = cli.create_runner(cmd)?; - runner.async_run(|config| { - let PartialComponents { client, task_manager, .. } = service::new_partial(&config)?; - Ok((cmd.run(client, config.chain_spec), task_manager)) - }) - }, - Some(Subcommand::ImportBlocks(cmd)) => { - let runner = cli.create_runner(cmd)?; - runner.async_run(|config| { - let PartialComponents { client, task_manager, import_queue, .. } = - service::new_partial(&config)?; - Ok((cmd.run(client, import_queue), task_manager)) - }) - }, - Some(Subcommand::PurgeChain(cmd)) => { - let runner = cli.create_runner(cmd)?; - runner.sync_run(|config| cmd.run(config.database)) - }, - Some(Subcommand::Revert(cmd)) => { - let runner = cli.create_runner(cmd)?; - runner.async_run(|config| { - let PartialComponents { client, task_manager, backend, .. } = - service::new_partial(&config)?; - let aux_revert = Box::new(|client, _, blocks| { - sc_consensus_grandpa::revert(client, blocks)?; - Ok(()) - }); - Ok((cmd.run(client, backend, Some(aux_revert)), task_manager)) - }) - }, - Some(Subcommand::Benchmark(cmd)) => { - let runner = cli.create_runner(cmd)?; - - runner.sync_run(|config| { - // This switch needs to be in the client, since the client decides - // which sub-commands it wants to support. - match cmd { - BenchmarkCmd::Pallet(cmd) => { - if !cfg!(feature = "runtime-benchmarks") { - return Err( - "Runtime benchmarking wasn't enabled when building the node. \ - You can enable it with `--features runtime-benchmarks`." - .into(), - ); - } - - cmd.run_with_spec::, ()>(Some( - config.chain_spec, - )) - }, - BenchmarkCmd::Block(cmd) => { - let PartialComponents { client, .. } = service::new_partial(&config)?; - cmd.run(client) - }, - #[cfg(not(feature = "runtime-benchmarks"))] - BenchmarkCmd::Storage(_) => Err( - "Storage benchmarking can be enabled with `--features runtime-benchmarks`." - .into(), - ), - #[cfg(feature = "runtime-benchmarks")] - BenchmarkCmd::Storage(cmd) => { - let PartialComponents { client, backend, .. } = - service::new_partial(&config)?; - let db = backend.expose_db(); - let storage = backend.expose_storage(); - - cmd.run(config, client, db, storage) - }, - BenchmarkCmd::Overhead(cmd) => { - let PartialComponents { client, .. } = service::new_partial(&config)?; - let ext_builder = RemarkBuilder::new(client.clone()); - - cmd.run( - config, - client, - inherent_benchmark_data()?, - Vec::new(), - &ext_builder, - ) - }, - BenchmarkCmd::Extrinsic(cmd) => { - let PartialComponents { client, .. } = service::new_partial(&config)?; - // Register the *Remark* and *TKA* builders. - let ext_factory = ExtrinsicFactory(vec![ - Box::new(RemarkBuilder::new(client.clone())), - Box::new(TransferKeepAliveBuilder::new( - client.clone(), - Sr25519Keyring::Alice.to_account_id().into(), - EXISTENTIAL_DEPOSIT, - )), - ]); - - cmd.run(client, inherent_benchmark_data()?, Vec::new(), &ext_factory) - }, - BenchmarkCmd::Machine(cmd) => - cmd.run(&config, SUBSTRATE_REFERENCE_HARDWARE.clone()), - } - }) - }, - Some(Subcommand::ChainInfo(cmd)) => { - let runner = cli.create_runner(cmd)?; - runner.sync_run(|config| cmd.run::(&config)) - }, - None => { - let runner = cli.create_runner(&cli.run)?; - runner.run_node_until_exit(|config| async move { - match config.network.network_backend { - sc_network::config::NetworkBackendType::Libp2p => service::new_full::< - sc_network::NetworkWorker< - Block, - ::Hash, - >, - >(config) - .map_err(sc_cli::Error::Service), - sc_network::config::NetworkBackendType::Litep2p => - service::new_full::(config) - .map_err(sc_cli::Error::Service), - } - }) - }, - } -} diff --git a/node/src/main.rs b/node/src/main.rs deleted file mode 100644 index 0d158333..00000000 --- a/node/src/main.rs +++ /dev/null @@ -1,31 +0,0 @@ -// This file is part of Noir. - -// Copyright (c) Haderech Pte. Ltd. -// SPDX-License-Identifier: GPL-3.0-or-later - -// This program 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. -// -// This program 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 this program. If not, see . - -//! Substrate Node Template CLI library. -#![warn(missing_docs)] - -mod benchmarking; -mod chain_spec; -mod cli; -mod command; -mod rpc; -mod service; - -fn main() -> sc_cli::Result<()> { - command::run() -} diff --git a/node/src/rpc.rs b/node/src/rpc.rs deleted file mode 100644 index 58716725..00000000 --- a/node/src/rpc.rs +++ /dev/null @@ -1,82 +0,0 @@ -// This file is part of Noir. - -// Copyright (c) Haderech Pte. Ltd. -// SPDX-License-Identifier: GPL-3.0-or-later - -// This program 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. -// -// This program 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 this program. If not, see . - -//! A collection of node-specific RPC methods. -//! Substrate provides the `sc-rpc` crate, which defines the core RPC layer -//! used by Substrate nodes. This file extends those RPC definitions with -//! capabilities that are specific to this project's runtime configuration. - -#![warn(missing_docs)] - -use noir_solochain_runtime::prelude::*; - -use jsonrpsee::RpcModule; -use sc_transaction_pool_api::TransactionPool; -use sp_api::ProvideRuntimeApi; -use sp_block_builder::BlockBuilder; -use sp_blockchain::{Error as BlockChainError, HeaderBackend, HeaderMetadata}; -use std::sync::Arc; - -pub use sc_rpc_api::DenyUnsafe; - -/// Full client dependencies. -pub struct FullDeps { - /// The client instance to use. - pub client: Arc, - /// Transaction pool instance. - pub pool: Arc

, - /// Whether to deny unsafe calls - pub deny_unsafe: DenyUnsafe, -} - -/// Instantiate all full RPC extensions. -pub fn create_full( - deps: FullDeps, -) -> Result, Box> -where - C: ProvideRuntimeApi, - C: HeaderBackend + HeaderMetadata + 'static, - C: Send + Sync + 'static, - C::Api: substrate_frame_rpc_system::AccountNonceApi, - C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi, - C::Api: BlockBuilder, - P: TransactionPool + 'static, -{ - use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApiServer}; - use substrate_frame_rpc_system::{System, SystemApiServer}; - - let mut module = RpcModule::new(()); - let FullDeps { client, pool, deny_unsafe } = deps; - - module.merge(System::new(client.clone(), pool, deny_unsafe).into_rpc())?; - module.merge(TransactionPayment::new(client).into_rpc())?; - - // Extend this RPC with a custom API by using the following syntax. - // `YourRpcStruct` should have a reference to a client, which is needed - // to call into the runtime. - // `module.merge(YourRpcTrait::into_rpc(YourRpcStruct::new(ReferenceToClient, ...)))?;` - - // You probably want to enable the `rpc v2 chainSpec` API as well - // - // let chain_name = chain_spec.name().to_string(); - // let genesis_hash = client.block_hash(0).ok().flatten().expect("Genesis block exists; qed"); - // let properties = chain_spec.properties(); - // module.merge(ChainSpec::new(chain_name, genesis_hash, properties).into_rpc())?; - - Ok(module) -} diff --git a/node/src/service.rs b/node/src/service.rs deleted file mode 100644 index fa76e8b2..00000000 --- a/node/src/service.rs +++ /dev/null @@ -1,351 +0,0 @@ -// This file is part of Noir. - -// Copyright (c) Haderech Pte. Ltd. -// SPDX-License-Identifier: GPL-3.0-or-later - -// This program 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. -// -// This program 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 this program. If not, see . - -//! Service and ServiceFactory implementation. Specialized wrapper over substrate service. - -use noir_solochain_runtime::{prelude::*, RuntimeApi}; - -use futures::prelude::*; -use sc_client_api::{Backend, BlockBackend}; -use sc_consensus_aura::{ImportQueueParams, SlotProportion, StartAuraParams}; -use sc_consensus_grandpa::SharedVoterState; -use sc_service::{error::Error as ServiceError, Configuration, TaskManager, WarpSyncParams}; -use sc_telemetry::{Telemetry, TelemetryWorker}; -use sc_transaction_pool_api::OffchainTransactionPoolFactory; -use sp_consensus_aura::sr25519::AuthorityPair as AuraPair; -use std::{sync::Arc, time::Duration}; - -pub(crate) type FullClient = sc_service::TFullClient< - Block, - RuntimeApi, - sc_executor::WasmExecutor, ->; -type FullBackend = sc_service::TFullBackend; -type FullSelectChain = sc_consensus::LongestChain; - -/// The minimum period of blocks on which justifications will be -/// imported and generated. -const GRANDPA_JUSTIFICATION_PERIOD: u32 = 512; - -pub type Service = sc_service::PartialComponents< - FullClient, - FullBackend, - FullSelectChain, - sc_consensus::DefaultImportQueue, - sc_transaction_pool::FullPool, - ( - sc_consensus_grandpa::GrandpaBlockImport, - sc_consensus_grandpa::LinkHalf, - Option, - ), ->; - -pub fn new_partial(config: &Configuration) -> Result { - let telemetry = config - .telemetry_endpoints - .clone() - .filter(|x| !x.is_empty()) - .map(|endpoints| -> Result<_, sc_telemetry::Error> { - let worker = TelemetryWorker::new(16)?; - let telemetry = worker.handle().new_telemetry(endpoints); - Ok((worker, telemetry)) - }) - .transpose()?; - - let executor = sc_service::new_wasm_executor::(config); - let (client, backend, keystore_container, task_manager) = - sc_service::new_full_parts::( - config, - telemetry.as_ref().map(|(_, telemetry)| telemetry.handle()), - executor, - )?; - let client = Arc::new(client); - - let telemetry = telemetry.map(|(worker, telemetry)| { - task_manager.spawn_handle().spawn("telemetry", None, worker.run()); - telemetry - }); - - let select_chain = sc_consensus::LongestChain::new(backend.clone()); - - let transaction_pool = sc_transaction_pool::BasicPool::new_full( - config.transaction_pool.clone(), - config.role.is_authority().into(), - config.prometheus_registry(), - task_manager.spawn_essential_handle(), - client.clone(), - ); - - let (grandpa_block_import, grandpa_link) = sc_consensus_grandpa::block_import( - client.clone(), - GRANDPA_JUSTIFICATION_PERIOD, - &client, - select_chain.clone(), - telemetry.as_ref().map(|x| x.handle()), - )?; - - let cidp_client = client.clone(); - let import_queue = - sc_consensus_aura::import_queue::(ImportQueueParams { - block_import: grandpa_block_import.clone(), - justification_import: Some(Box::new(grandpa_block_import.clone())), - client: client.clone(), - create_inherent_data_providers: move |parent_hash, _| { - let cidp_client = cidp_client.clone(); - async move { - let slot_duration = sc_consensus_aura::standalone::slot_duration_at( - &*cidp_client, - parent_hash, - )?; - let timestamp = sp_timestamp::InherentDataProvider::from_system_time(); - - let slot = - sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_slot_duration( - *timestamp, - slot_duration, - ); - - Ok((slot, timestamp)) - } - }, - spawner: &task_manager.spawn_essential_handle(), - registry: config.prometheus_registry(), - check_for_equivocation: Default::default(), - telemetry: telemetry.as_ref().map(|x| x.handle()), - compatibility_mode: Default::default(), - })?; - - Ok(sc_service::PartialComponents { - client, - backend, - task_manager, - import_queue, - keystore_container, - select_chain, - transaction_pool, - other: (grandpa_block_import, grandpa_link, telemetry), - }) -} - -/// Builds a new service for a full client. -pub fn new_full< - N: sc_network::NetworkBackend::Hash>, ->( - config: Configuration, -) -> Result { - let sc_service::PartialComponents { - client, - backend, - mut task_manager, - import_queue, - keystore_container, - select_chain, - transaction_pool, - other: (block_import, grandpa_link, mut telemetry), - } = new_partial(&config)?; - - let mut net_config = sc_network::config::FullNetworkConfiguration::< - Block, - ::Hash, - N, - >::new(&config.network); - let metrics = N::register_notification_metrics(config.prometheus_registry()); - - let peer_store_handle = net_config.peer_store_handle(); - let grandpa_protocol_name = sc_consensus_grandpa::protocol_standard_name( - &client.block_hash(0).ok().flatten().expect("Genesis block exists; qed"), - &config.chain_spec, - ); - let (grandpa_protocol_config, grandpa_notification_service) = - sc_consensus_grandpa::grandpa_peers_set_config::<_, N>( - grandpa_protocol_name.clone(), - metrics.clone(), - peer_store_handle, - ); - net_config.add_notification_protocol(grandpa_protocol_config); - - let warp_sync = Arc::new(sc_consensus_grandpa::warp_proof::NetworkProvider::new( - backend.clone(), - grandpa_link.shared_authority_set().clone(), - Vec::default(), - )); - - let (network, system_rpc_tx, tx_handler_controller, network_starter, sync_service) = - sc_service::build_network(sc_service::BuildNetworkParams { - config: &config, - net_config, - client: client.clone(), - transaction_pool: transaction_pool.clone(), - spawn_handle: task_manager.spawn_handle(), - import_queue, - block_announce_validator_builder: None, - warp_sync_params: Some(WarpSyncParams::WithProvider(warp_sync)), - block_relay: None, - metrics, - })?; - - if config.offchain_worker.enabled { - task_manager.spawn_handle().spawn( - "offchain-workers-runner", - "offchain-worker", - sc_offchain::OffchainWorkers::new(sc_offchain::OffchainWorkerOptions { - runtime_api_provider: client.clone(), - is_validator: config.role.is_authority(), - keystore: Some(keystore_container.keystore()), - offchain_db: backend.offchain_storage(), - transaction_pool: Some(OffchainTransactionPoolFactory::new( - transaction_pool.clone(), - )), - network_provider: Arc::new(network.clone()), - enable_http_requests: true, - custom_extensions: |_| vec![], - }) - .run(client.clone(), task_manager.spawn_handle()) - .boxed(), - ); - } - - let role = config.role.clone(); - let force_authoring = config.force_authoring; - let backoff_authoring_blocks: Option<()> = None; - let name = config.network.node_name.clone(); - let enable_grandpa = !config.disable_grandpa; - let prometheus_registry = config.prometheus_registry().cloned(); - - let rpc_extensions_builder = { - let client = client.clone(); - let pool = transaction_pool.clone(); - - Box::new(move |deny_unsafe, _| { - let deps = - crate::rpc::FullDeps { client: client.clone(), pool: pool.clone(), deny_unsafe }; - crate::rpc::create_full(deps).map_err(Into::into) - }) - }; - - let _rpc_handlers = sc_service::spawn_tasks(sc_service::SpawnTasksParams { - network: Arc::new(network.clone()), - client: client.clone(), - keystore: keystore_container.keystore(), - task_manager: &mut task_manager, - transaction_pool: transaction_pool.clone(), - rpc_builder: rpc_extensions_builder, - backend, - system_rpc_tx, - tx_handler_controller, - sync_service: sync_service.clone(), - config, - telemetry: telemetry.as_mut(), - })?; - - if role.is_authority() { - let proposer_factory = 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 slot_duration = sc_consensus_aura::slot_duration(&*client)?; - - let aura = sc_consensus_aura::start_aura::( - StartAuraParams { - slot_duration, - client, - select_chain, - block_import, - proposer_factory, - create_inherent_data_providers: move |_, ()| async move { - let timestamp = sp_timestamp::InherentDataProvider::from_system_time(); - - let slot = - sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_slot_duration( - *timestamp, - slot_duration, - ); - - Ok((slot, timestamp)) - }, - force_authoring, - backoff_authoring_blocks, - keystore: keystore_container.keystore(), - sync_oracle: sync_service.clone(), - justification_sync_link: sync_service.clone(), - block_proposal_slot_portion: SlotProportion::new(2f32 / 3f32), - max_block_proposal_slot_portion: None, - telemetry: telemetry.as_ref().map(|x| x.handle()), - compatibility_mode: Default::default(), - }, - )?; - - // the AURA authoring task is considered essential, i.e. if it - // fails we take down the service with it. - task_manager - .spawn_essential_handle() - .spawn_blocking("aura", Some("block-authoring"), aura); - } - - if enable_grandpa { - // if the node isn't actively participating in consensus then it doesn't - // need a keystore, regardless of which protocol we use below. - let keystore = if role.is_authority() { Some(keystore_container.keystore()) } else { None }; - - let grandpa_config = sc_consensus_grandpa::Config { - // FIXME #1578 make this available through chainspec - gossip_duration: Duration::from_millis(333), - justification_generation_period: GRANDPA_JUSTIFICATION_PERIOD, - name: Some(name), - observer_enabled: false, - keystore, - local_role: role, - telemetry: telemetry.as_ref().map(|x| x.handle()), - protocol_name: grandpa_protocol_name, - }; - - // start the full GRANDPA voter - // NOTE: non-authorities could run the GRANDPA observer protocol, but at - // this point the full voter should provide better guarantees of block - // and vote data availability than the observer. The observer has not - // been tested extensively yet and having most nodes in a network run it - // could lead to finality stalls. - let grandpa_config = sc_consensus_grandpa::GrandpaParams { - config: grandpa_config, - link: grandpa_link, - network, - sync: Arc::new(sync_service), - notification_service: grandpa_notification_service, - voting_rule: sc_consensus_grandpa::VotingRulesBuilder::default().build(), - prometheus_registry, - shared_voter_state: SharedVoterState::empty(), - telemetry: telemetry.as_ref().map(|x| x.handle()), - offchain_tx_pool_factory: OffchainTransactionPoolFactory::new(transaction_pool), - }; - - // the GRANDPA voter task is considered infallible, i.e. - // if it fails we take down the service with it. - task_manager.spawn_essential_handle().spawn_blocking( - "grandpa-voter", - None, - sc_consensus_grandpa::run_grandpa_voter(grandpa_config)?, - ); - } - - network_starter.start_network(); - Ok(task_manager) -} diff --git a/runtime/solochain/Cargo.toml b/runtime/solochain/Cargo.toml deleted file mode 100644 index e1ed865f..00000000 --- a/runtime/solochain/Cargo.toml +++ /dev/null @@ -1,108 +0,0 @@ -[package] -name = "noir-solochain-runtime" -version = "0.4.0" -authors = ["Haderech Pte. Ltd."] -edition = "2021" -license = "GPL-3.0-or-later" -repository = "https://github.com/noirhq/noir.git" -publish = false - -[lints.clippy] -identity-op = { level = "allow", priority = 2 } # One case where we do 0 + - -[dependencies] -fp-evm = { git = "https://github.com/polkadot-evm/frontier", branch = "stable2407", default-features = false } -fp-rpc = { git = "https://github.com/polkadot-evm/frontier", branch = "stable2407", default-features = false } -fp-self-contained = { git = "https://github.com/polkadot-evm/frontier", branch = "stable2407", default-features = false } -frame-babel = { workspace = true, features = ["cosmos", "ethereum"] } -frame-executive = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2407", default-features = false } -frame-support = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2407", default-features = false } -frame-system = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2407", default-features = false } -frame-system-rpc-runtime-api = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2407", default-features = false } -noir-core-primitives = { workspace = true } -noir-runtime-common = { workspace = true } -np-ethereum = { workspace = true } -np-runtime = { workspace = true, features = ["serde"] } -pallet-assets = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2407", default-features = false } -pallet-aura = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2407", default-features = false } -pallet-balances = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2407", default-features = false } -pallet-base-fee = { git = "https://github.com/polkadot-evm/frontier", branch = "stable2407", default-features = false } -pallet-ethereum = { git = "https://github.com/polkadot-evm/frontier", branch = "stable2407", default-features = false } -pallet-evm = { git = "https://github.com/polkadot-evm/frontier", branch = "stable2407", default-features = false } -pallet-grandpa = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2407", default-features = false } -pallet-multimap = { workspace = true } -pallet-sudo = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2407", default-features = false } -pallet-timestamp = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2407", default-features = false } -pallet-transaction-payment = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2407", default-features = false } -pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2407", default-features = false } -parity-scale-codec = { version = "3.6", default-features = false } -scale-info = { version = "2.11", default-features = false } -smallvec = "1.13" -sp-api = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2407", default-features = false } -sp-block-builder = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2407", default-features = false } -sp-consensus-aura = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2407", default-features = false } -sp-consensus-grandpa = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2407", default-features = false } -sp-core = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2407", default-features = false } -sp-genesis-builder = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2407", default-features = false } -sp-inherents = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2407", default-features = false } -sp-offchain = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2407", default-features = false } -sp-runtime = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2407", default-features = false } -sp-session = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2407", default-features = false } -sp-transaction-pool = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2407", default-features = false } -sp-version = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2407", default-features = false } - -frame-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2407", default-features = false, optional = true } -frame-try-runtime = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2407", default-features = false, optional = true } - -[build-dependencies] -substrate-wasm-builder = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2407", optional = true } - -[features] -default = ["std"] -std = [ - "fp-evm/std", - "fp-self-contained/std", - "frame-babel/std", - "frame-benchmarking?/std", - "frame-executive/std", - "frame-support/std", - "frame-system/std", - "frame-system-rpc-runtime-api/std", - "frame-try-runtime?/std", - "noir-core-primitives/std", - "noir-runtime-common/std", - "np-ethereum/std", - "np-runtime/std", - "pallet-aura/std", - "pallet-balances/std", - "pallet-base-fee/std", - "pallet-ethereum/std", - "pallet-evm/std", - "pallet-grandpa/std", - "pallet-multimap/std", - "pallet-sudo/std", - "pallet-timestamp/std", - "pallet-transaction-payment/std", - "pallet-transaction-payment-rpc-runtime-api/std", - "parity-scale-codec/std", - "scale-info/std", - "sp-api/std", - "sp-block-builder/std", - "sp-consensus-aura/std", - "sp-consensus-grandpa/std", - "sp-core/std", - "sp-genesis-builder/std", - "sp-inherents/std", - "sp-offchain/std", - "sp-runtime/std", - "sp-session/std", - "sp-transaction-pool/std", - "sp-version/std", - "substrate-wasm-builder", -] -runtime-benchmarks = [ - "frame-benchmarking/runtime-benchmarks", -] -try-runtime = [ - "frame-try-runtime/try-runtime", -] diff --git a/runtime/solochain/build.rs b/runtime/solochain/build.rs deleted file mode 100644 index e6f92757..00000000 --- a/runtime/solochain/build.rs +++ /dev/null @@ -1,23 +0,0 @@ -// This file is part of Substrate. - -// Copyright (C) Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -fn main() { - #[cfg(feature = "std")] - { - substrate_wasm_builder::WasmBuilder::build_using_defaults(); - } -} diff --git a/runtime/solochain/src/apis.rs b/runtime/solochain/src/apis.rs deleted file mode 100644 index 34183edd..00000000 --- a/runtime/solochain/src/apis.rs +++ /dev/null @@ -1,539 +0,0 @@ -// This file is part of Noir. - -// Copyright (c) Haderech Pte. Ltd. -// SPDX-License-Identifier: GPL-3.0-or-later - -// This program 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. -// -// This program 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 this program. If not, see . - -use crate::*; - -use alloc::{vec, vec::Vec}; -use frame_support::{ - genesis_builder_helper::{build_state, get_preset}, - traits::OnFinalize, - weights::Weight, -}; -use pallet_ethereum::{Transaction as EthereumTransaction, TransactionStatus}; -use pallet_evm::{Account as EVMAccount, FeeCalculator, Runner}; -use pallet_grandpa::AuthorityId as GrandpaId; -use parity_scale_codec::Encode; -use sp_api::impl_runtime_apis; -use sp_consensus_aura::sr25519::AuthorityId as AuraId; -use sp_core::{crypto::KeyTypeId, OpaqueMetadata, H160, H256, U256}; -use sp_runtime::{ - traits::{Block as BlockT, NumberFor, SaturatedConversion}, - transaction_validity::{TransactionSource, TransactionValidity}, - ApplyExtrinsicResult, Permill, -}; -use sp_version::RuntimeVersion; - -impl_runtime_apis! { - impl sp_api::Core for Runtime { - fn version() -> RuntimeVersion { - VERSION - } - - fn execute_block(block: Block) { - Executive::execute_block(block); - } - - fn initialize_block(header: &::Header) -> sp_runtime::ExtrinsicInclusionMode { - Executive::initialize_block(header) - } - } - - impl sp_api::Metadata for Runtime { - fn metadata() -> OpaqueMetadata { - OpaqueMetadata::new(Runtime::metadata().into()) - } - - fn metadata_at_version(version: u32) -> Option { - Runtime::metadata_at_version(version) - } - - fn metadata_versions() -> Vec { - Runtime::metadata_versions() - } - } - - impl sp_block_builder::BlockBuilder for Runtime { - fn apply_extrinsic(extrinsic: ::Extrinsic) -> ApplyExtrinsicResult { - Executive::apply_extrinsic(extrinsic) - } - - fn finalize_block() -> ::Header { - Executive::finalize_block() - } - - fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<::Extrinsic> { - data.create_extrinsics() - } - - fn check_inherents( - block: Block, - data: sp_inherents::InherentData, - ) -> sp_inherents::CheckInherentsResult { - data.check_extrinsics(&block) - } - } - - impl sp_transaction_pool::runtime_api::TaggedTransactionQueue for Runtime { - fn validate_transaction( - source: TransactionSource, - tx: ::Extrinsic, - block_hash: ::Hash, - ) -> TransactionValidity { - Executive::validate_transaction(source, tx, block_hash) - } - } - - impl sp_offchain::OffchainWorkerApi for Runtime { - fn offchain_worker(header: &::Header) { - Executive::offchain_worker(header) - } - } - - impl sp_consensus_aura::AuraApi for Runtime { - fn slot_duration() -> sp_consensus_aura::SlotDuration { - sp_consensus_aura::SlotDuration::from_millis(Aura::slot_duration()) - } - - fn authorities() -> Vec { - pallet_aura::Authorities::::get().into_inner() - } - } - - impl sp_session::SessionKeys for Runtime { - fn generate_session_keys(seed: Option>) -> Vec { - opaque::SessionKeys::generate(seed) - } - - fn decode_session_keys( - encoded: Vec, - ) -> Option, KeyTypeId)>> { - opaque::SessionKeys::decode_into_raw_public_keys(&encoded) - } - } - - impl sp_consensus_grandpa::GrandpaApi for Runtime { - fn grandpa_authorities() -> sp_consensus_grandpa::AuthorityList { - Grandpa::grandpa_authorities() - } - - fn current_set_id() -> sp_consensus_grandpa::SetId { - Grandpa::current_set_id() - } - - fn submit_report_equivocation_unsigned_extrinsic( - _equivocation_proof: sp_consensus_grandpa::EquivocationProof< - ::Hash, - NumberFor, - >, - _key_owner_proof: sp_consensus_grandpa::OpaqueKeyOwnershipProof, - ) -> Option<()> { - None - } - - fn generate_key_ownership_proof( - _set_id: sp_consensus_grandpa::SetId, - _authority_id: GrandpaId, - ) -> Option { - // NOTE: this is the only implementation possible since we've - // defined our key owner proof type as a bottom type (i.e. a type - // with no values). - None - } - } - - impl frame_system_rpc_runtime_api::AccountNonceApi for Runtime { - fn account_nonce(account: AccountId) -> AccountNonce { - System::account_nonce(account) - } - } - - impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi for Runtime { - fn query_info( - uxt: ::Extrinsic, - len: u32, - ) -> pallet_transaction_payment_rpc_runtime_api::RuntimeDispatchInfo { - TransactionPayment::query_info(uxt, len) - } - fn query_fee_details( - uxt: ::Extrinsic, - len: u32, - ) -> pallet_transaction_payment::FeeDetails { - TransactionPayment::query_fee_details(uxt, len) - } - fn query_weight_to_fee(weight: Weight) -> Balance { - TransactionPayment::weight_to_fee(weight) - } - fn query_length_to_fee(length: u32) -> Balance { - TransactionPayment::length_to_fee(length) - } - } - - impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentCallApi - for Runtime - { - fn query_call_info( - call: RuntimeCall, - len: u32, - ) -> pallet_transaction_payment::RuntimeDispatchInfo { - TransactionPayment::query_call_info(call, len) - } - fn query_call_fee_details( - call: RuntimeCall, - len: u32, - ) -> pallet_transaction_payment::FeeDetails { - TransactionPayment::query_call_fee_details(call, len) - } - fn query_weight_to_fee(weight: Weight) -> Balance { - TransactionPayment::weight_to_fee(weight) - } - fn query_length_to_fee(length: u32) -> Balance { - TransactionPayment::length_to_fee(length) - } - } - - impl fp_rpc::EthereumRuntimeRPCApi for Runtime { - fn chain_id() -> u64 { - ::ChainId::get() - } - - fn account_basic(address: H160) -> EVMAccount { - let (account, _) = pallet_evm::Pallet::::account_basic(&address); - account - } - - fn gas_price() -> U256 { - let (gas_price, _) = ::FeeCalculator::min_gas_price(); - gas_price - } - - fn account_code_at(address: H160) -> Vec { - pallet_evm::AccountCodes::::get(address) - } - - fn author() -> H160 { - >::find_author() - } - - fn storage_at(address: H160, index: U256) -> H256 { - let mut tmp = [0u8; 32]; - index.to_big_endian(&mut tmp); - pallet_evm::AccountStorages::::get(address, H256::from_slice(&tmp[..])) - } - - fn call( - from: H160, - to: H160, - data: Vec, - value: U256, - gas_limit: U256, - max_fee_per_gas: Option, - max_priority_fee_per_gas: Option, - nonce: Option, - estimate: bool, - access_list: Option)>>, - ) -> Result { - use pallet_evm::GasWeightMapping as _; - - let config = if estimate { - let mut config = ::config().clone(); - config.estimate = true; - Some(config) - } else { - None - }; - - // Estimated encoded transaction size must be based on the heaviest transaction - // type (EIP1559Transaction) to be compatible with all transaction types. - let mut estimated_transaction_len = data.len() + - // pallet ethereum index: 1 - // transact call index: 1 - // Transaction enum variant: 1 - // chain_id 8 bytes - // nonce: 32 - // max_priority_fee_per_gas: 32 - // max_fee_per_gas: 32 - // gas_limit: 32 - // action: 21 (enum varianrt + call address) - // value: 32 - // access_list: 1 (empty vec size) - // 65 bytes signature - 258; - - if access_list.is_some() { - estimated_transaction_len += access_list.encoded_size(); - } - - - let gas_limit = if gas_limit > U256::from(u64::MAX) { - u64::MAX - } else { - gas_limit.low_u64() - }; - let without_base_extrinsic_weight = true; - - let (weight_limit, proof_size_base_cost) = - match ::GasWeightMapping::gas_to_weight( - gas_limit, - without_base_extrinsic_weight - ) { - weight_limit if weight_limit.proof_size() > 0 => { - (Some(weight_limit), Some(estimated_transaction_len as u64)) - } - _ => (None, None), - }; - - ::Runner::call( - from, - to, - data, - value, - gas_limit.saturated_into(), - max_fee_per_gas, - max_priority_fee_per_gas, - nonce, - access_list.unwrap_or_default(), - false, - true, - weight_limit, - proof_size_base_cost, - config.as_ref().unwrap_or(::config()), - ).map_err(|err| err.error.into()) - } - - fn create( - from: H160, - data: Vec, - value: U256, - gas_limit: U256, - max_fee_per_gas: Option, - max_priority_fee_per_gas: Option, - nonce: Option, - estimate: bool, - access_list: Option)>>, - ) -> Result { - use pallet_evm::GasWeightMapping as _; - - let config = if estimate { - let mut config = ::config().clone(); - config.estimate = true; - Some(config) - } else { - None - }; - - - let mut estimated_transaction_len = data.len() + - // from: 20 - // value: 32 - // gas_limit: 32 - // nonce: 32 - // 1 byte transaction action variant - // chain id 8 bytes - // 65 bytes signature - 190; - - if max_fee_per_gas.is_some() { - estimated_transaction_len += 32; - } - if max_priority_fee_per_gas.is_some() { - estimated_transaction_len += 32; - } - if access_list.is_some() { - estimated_transaction_len += access_list.encoded_size(); - } - - - let gas_limit = if gas_limit > U256::from(u64::MAX) { - u64::MAX - } else { - gas_limit.low_u64() - }; - let without_base_extrinsic_weight = true; - - let (weight_limit, proof_size_base_cost) = - match ::GasWeightMapping::gas_to_weight( - gas_limit, - without_base_extrinsic_weight - ) { - weight_limit if weight_limit.proof_size() > 0 => { - (Some(weight_limit), Some(estimated_transaction_len as u64)) - } - _ => (None, None), - }; - - ::Runner::create( - from, - data, - value, - gas_limit.saturated_into(), - max_fee_per_gas, - max_priority_fee_per_gas, - nonce, - access_list.unwrap_or_default(), - false, - true, - weight_limit, - proof_size_base_cost, - config.as_ref().unwrap_or(::config()), - ).map_err(|err| err.error.into()) - } - - fn current_transaction_statuses() -> Option> { - pallet_ethereum::CurrentTransactionStatuses::::get() - } - - fn current_block() -> Option { - pallet_ethereum::CurrentBlock::::get() - } - - fn current_receipts() -> Option> { - pallet_ethereum::CurrentReceipts::::get() - } - - fn current_all() -> ( - Option, - Option>, - Option> - ) { - ( - pallet_ethereum::CurrentBlock::::get(), - pallet_ethereum::CurrentReceipts::::get(), - pallet_ethereum::CurrentTransactionStatuses::::get() - ) - } - - fn extrinsic_filter( - xts: Vec<::Extrinsic>, - ) -> Vec { - xts.into_iter().filter_map(|xt| match xt.0.function { - RuntimeCall::Ethereum(pallet_ethereum::Call::transact { transaction }) => Some(transaction), - _ => None - }).collect::>() - } - - fn elasticity() -> Option { - Some(pallet_base_fee::Elasticity::::get()) - } - - fn gas_limit_multiplier_support() {} - - fn pending_block( - xts: Vec<::Extrinsic>, - ) -> (Option, Option>) { - for ext in xts.into_iter() { - let _ = Executive::apply_extrinsic(ext); - } - - Ethereum::on_finalize(System::block_number() + 1); - - ( - pallet_ethereum::CurrentBlock::::get(), - pallet_ethereum::CurrentTransactionStatuses::::get() - ) - } - - fn initialize_pending_block(header: &::Header) { - Executive::initialize_block(header); - } - } - - impl fp_rpc::ConvertTransactionRuntimeApi for Runtime { - fn convert_transaction(transaction: EthereumTransaction) -> ::Extrinsic { - UncheckedExtrinsic::new_unsigned( - pallet_ethereum::Call::::transact { transaction }.into(), - ) - } - } - - #[cfg(feature = "runtime-benchmarks")] - impl frame_benchmarking::Benchmark for Runtime { - fn benchmark_metadata(extra: bool) -> ( - Vec, - Vec, - ) { - use frame_benchmarking::{baseline, Benchmarking, BenchmarkList}; - use frame_support::traits::StorageInfoTrait; - use frame_system_benchmarking::Pallet as SystemBench; - use baseline::Pallet as BaselineBench; - - let mut list = Vec::::new(); - list_benchmarks!(list, extra); - - let storage_info = AllPalletsWithSystem::storage_info(); - - (list, storage_info) - } - - fn dispatch_benchmark( - config: frame_benchmarking::BenchmarkConfig - ) -> Result, sp_runtime::RuntimeString> { - use frame_benchmarking::{baseline, Benchmarking, BenchmarkBatch}; - use sp_storage::TrackedStorageKey; - use frame_system_benchmarking::Pallet as SystemBench; - use baseline::Pallet as BaselineBench; - - impl frame_system_benchmarking::Config for Runtime {} - impl baseline::Config for Runtime {} - - use frame_support::traits::WhitelistedStorageKeys; - let whitelist: Vec = AllPalletsWithSystem::whitelisted_storage_keys(); - - let mut batches = Vec::::new(); - let params = (&config, &whitelist); - add_benchmarks!(params, batches); - - Ok(batches) - } - } - - #[cfg(feature = "try-runtime")] - impl frame_try_runtime::TryRuntime for Runtime { - fn on_runtime_upgrade(checks: frame_try_runtime::UpgradeCheckSelect) -> (Weight, Weight) { - // NOTE: intentional unwrap: we don't want to propagate the error backwards, and want to - // have a backtrace here. If any of the pre/post migration checks fail, we shall stop - // right here and right now. - let weight = Executive::try_runtime_upgrade(checks).unwrap(); - (weight, BlockWeights::get().max_block) - } - - fn execute_block( - block: Block, - state_root_check: bool, - signature_check: bool, - select: frame_try_runtime::TryStateSelect - ) -> Weight { - // NOTE: intentional unwrap: we don't want to propagate the error backwards, and want to - // have a backtrace here. - Executive::try_execute_block(block, state_root_check, signature_check, select).expect("execute-block failed") - } - } - - impl sp_genesis_builder::GenesisBuilder for Runtime { - fn build_state(config: Vec) -> sp_genesis_builder::Result { - build_state::(config) - } - - fn get_preset(id: &Option) -> Option> { - get_preset::(id, |_| None) - } - - fn preset_names() -> Vec { - vec![] - } - } -} diff --git a/runtime/solochain/src/call.rs b/runtime/solochain/src/call.rs deleted file mode 100644 index 8fff8ef0..00000000 --- a/runtime/solochain/src/call.rs +++ /dev/null @@ -1,134 +0,0 @@ -// This file is part of Noir. - -// Copyright (c) Haderech Pte. Ltd. -// SPDX-License-Identifier: GPL-3.0-or-later - -// This program 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. -// -// This program 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 this program. If not, see . - -use crate::*; - -use fp_evm::TransactionValidationError; -use fp_self_contained::SelfContainedCall; -use frame_babel::{ethereum::TransactionExt, UnifyAccount}; -use np_ethereum::Address as EthereumAddress; -use sp_core::ecdsa; -use sp_runtime::{ - traits::{DispatchInfoOf, Dispatchable, PostDispatchInfoOf}, - transaction_validity::{ - InvalidTransaction, TransactionValidity, TransactionValidityError, UnknownTransaction, - }, - DispatchResultWithInfo, -}; - -impl SelfContainedCall for RuntimeCall { - type SignedInfo = AccountId; - - fn is_self_contained(&self) -> bool { - match self { - RuntimeCall::Ethereum(call) => call.is_self_contained(), - _ => false, - } - } - - fn check_self_contained(&self) -> Option> { - match self { - RuntimeCall::Ethereum(call) => { - if let pallet_ethereum::Call::transact { transaction } = call { - let check = || { - let origin = transaction.recover_key().map(Self::SignedInfo::from).ok_or( - InvalidTransaction::Custom( - TransactionValidationError::InvalidSignature as u8, - ), - )?; - Ok(origin) - }; - Some(check()) - } else { - None - } - }, - _ => None, - } - } - - fn validate_self_contained( - &self, - info: &Self::SignedInfo, - dispatch_info: &DispatchInfoOf, - len: usize, - ) -> Option { - match self { - RuntimeCall::Ethereum(call) => { - if let pallet_ethereum::Call::transact { transaction } = call { - if transaction.nonce() == 0 { - match UnifyAccount::::unify_ecdsa(info) { - Ok(_) => (), - Err(_) => - return Some(Err(TransactionValidityError::Unknown( - UnknownTransaction::CannotLookup, - ))), - } - } - } - let public: ecdsa::Public = info.clone().try_into().unwrap(); - let address: EthereumAddress = public.into(); - call.validate_self_contained(&address.into(), dispatch_info, len) - }, - _ => None, - } - } - - fn pre_dispatch_self_contained( - &self, - info: &Self::SignedInfo, - dispatch_info: &DispatchInfoOf, - len: usize, - ) -> Option> { - match self { - RuntimeCall::Ethereum(call) => { - if let pallet_ethereum::Call::transact { transaction } = &call { - if transaction.nonce() == 0 { - match UnifyAccount::::unify_ecdsa(info) { - Ok(_) => (), - Err(_) => - return Some(Err(TransactionValidityError::Unknown( - UnknownTransaction::CannotLookup, - ))), - } - } - } - let public: ecdsa::Public = info.clone().try_into().unwrap(); - let address: EthereumAddress = public.into(); - call.pre_dispatch_self_contained(&address.into(), dispatch_info, len) - }, - _ => None, - } - } - - fn apply_self_contained( - self, - info: Self::SignedInfo, - ) -> Option>> { - match self { - call @ RuntimeCall::Ethereum(pallet_ethereum::Call::transact { .. }) => { - let public: ecdsa::Public = info.clone().try_into().unwrap(); - let address: EthereumAddress = public.into(); - Some(call.dispatch(RuntimeOrigin::from( - pallet_ethereum::RawOrigin::EthereumTransaction(address.into()), - ))) - }, - _ => None, - } - } -} diff --git a/runtime/solochain/src/configs/address_map.rs b/runtime/solochain/src/configs/address_map.rs deleted file mode 100644 index d48627a8..00000000 --- a/runtime/solochain/src/configs/address_map.rs +++ /dev/null @@ -1,29 +0,0 @@ -// This file is part of Noir. - -// Copyright (c) Haderech Pte. Ltd. -// SPDX-License-Identifier: GPL-3.0-or-later - -// This program 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. -// -// This program 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 this program. If not, see . - -use crate::*; - -use frame_babel::Address; -use frame_support::{derive_impl, instances::Instance1, traits::ConstU32}; - -#[derive_impl(pallet_multimap::config_preludes::TestDefaultConfig)] -impl pallet_multimap::Config for Runtime { - type Key = AccountId; - type Value = Address; - type CapacityPerKey = ConstU32<{ Address::variant_count() }>; -} diff --git a/runtime/solochain/src/configs/aura.rs b/runtime/solochain/src/configs/aura.rs deleted file mode 100644 index 069a081c..00000000 --- a/runtime/solochain/src/configs/aura.rs +++ /dev/null @@ -1,30 +0,0 @@ -// This file is part of Noir. - -// Copyright (c) Haderech Pte. Ltd. -// SPDX-License-Identifier: GPL-3.0-or-later - -// This program 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. -// -// This program 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 this program. If not, see . - -use crate::*; - -use pallet_aura::MinimumPeriodTimesTwo; -use sp_runtime::traits::{ConstBool, ConstU32}; - -impl pallet_aura::Config for Runtime { - type AuthorityId = AuraId; - type DisabledValidators = (); - type MaxAuthorities = ConstU32<32>; - type AllowMultipleBlocksPerSlot = ConstBool; - type SlotDuration = MinimumPeriodTimesTwo; -} diff --git a/runtime/solochain/src/configs/babel.rs b/runtime/solochain/src/configs/babel.rs deleted file mode 100644 index 5e72f34a..00000000 --- a/runtime/solochain/src/configs/babel.rs +++ /dev/null @@ -1,23 +0,0 @@ -// This file is part of Noir. - -// Copyright (c) Haderech Pte. Ltd. -// SPDX-License-Identifier: GPL-3.0-or-later - -// This program 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. -// -// This program 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 this program. If not, see . - -use crate::*; - -impl frame_babel::Config for Runtime { - type AddressMap = AddressMap; -} diff --git a/runtime/solochain/src/configs/balances.rs b/runtime/solochain/src/configs/balances.rs deleted file mode 100644 index d800e0a2..00000000 --- a/runtime/solochain/src/configs/balances.rs +++ /dev/null @@ -1,41 +0,0 @@ -// This file is part of Noir. - -// Copyright (c) Haderech Pte. Ltd. -// SPDX-License-Identifier: GPL-3.0-or-later - -// This program 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. -// -// This program 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 this program. If not, see . - -use crate::*; - -use sp_runtime::traits::ConstU32; - -parameter_types! { - pub const ExistentialDeposit: Balance = super::EXISTENTIAL_DEPOSIT; -} - -impl pallet_balances::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type RuntimeHoldReason = RuntimeHoldReason; - type RuntimeFreezeReason = RuntimeFreezeReason; - type WeightInfo = pallet_balances::weights::SubstrateWeight; - type Balance = Balance; - type DustRemoval = (); - type ExistentialDeposit = ExistentialDeposit; - type AccountStore = System; - type ReserveIdentifier = [u8; 8]; - type FreezeIdentifier = RuntimeFreezeReason; - type MaxLocks = ConstU32<50>; - type MaxReserves = ConstU32<50>; - type MaxFreezes = ConstU32<8>; -} diff --git a/runtime/solochain/src/configs/base_fee.rs b/runtime/solochain/src/configs/base_fee.rs deleted file mode 100644 index aacd78c2..00000000 --- a/runtime/solochain/src/configs/base_fee.rs +++ /dev/null @@ -1,47 +0,0 @@ -// This file is part of Noir. - -// Copyright (c) Haderech Pte. Ltd. -// SPDX-License-Identifier: GPL-3.0-or-later - -// This program 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. -// -// This program 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 this program. If not, see . - -use crate::*; - -use sp_core::U256; -use sp_runtime::Permill; - -parameter_types! { - pub DefaultBaseFeePerGas: U256 = U256::from(1_000_000_000); - pub DefaultElasticity: Permill = Permill::from_parts(125_000); -} - -pub struct BaseFeeThreshold; -impl pallet_base_fee::BaseFeeThreshold for BaseFeeThreshold { - fn lower() -> Permill { - Permill::zero() - } - fn ideal() -> Permill { - Permill::from_parts(500_000) - } - fn upper() -> Permill { - Permill::from_parts(1_000_000) - } -} - -impl pallet_base_fee::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type Threshold = BaseFeeThreshold; - type DefaultBaseFeePerGas = DefaultBaseFeePerGas; - type DefaultElasticity = DefaultElasticity; -} diff --git a/runtime/solochain/src/configs/ethereum.rs b/runtime/solochain/src/configs/ethereum.rs deleted file mode 100644 index 7916c7c4..00000000 --- a/runtime/solochain/src/configs/ethereum.rs +++ /dev/null @@ -1,33 +0,0 @@ -// This file is part of Noir. - -// Copyright (c) Haderech Pte. Ltd. -// SPDX-License-Identifier: GPL-3.0-or-later - -// This program 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. -// -// This program 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 this program. If not, see . - -use crate::*; - -use frame_support::traits::ConstU32; -use pallet_ethereum::PostLogContent; - -parameter_types! { - pub const PostBlockAndTxnHashes: PostLogContent = PostLogContent::BlockAndTxnHashes; -} - -impl pallet_ethereum::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type StateRoot = pallet_ethereum::IntermediateStateRoot; - type PostLogContent = PostBlockAndTxnHashes; - type ExtraDataLength = ConstU32<30>; -} diff --git a/runtime/solochain/src/configs/evm.rs b/runtime/solochain/src/configs/evm.rs deleted file mode 100644 index d7e0a328..00000000 --- a/runtime/solochain/src/configs/evm.rs +++ /dev/null @@ -1,62 +0,0 @@ -// This file is part of Noir. - -// Copyright (c) Haderech Pte. Ltd. -// SPDX-License-Identifier: GPL-3.0-or-later - -// This program 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. -// -// This program 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 this program. If not, see . - -use crate::*; - -use common::NORMAL_DISPATCH_RATIO; -use fp_evm::weight_per_gas; -use frame_babel::ethereum::{AddressMapping, EnsureAddress, FrontierPrecompiles}; -use frame_support::weights::Weight; -use sp_core::U256; - -const BLOCK_GAS_LIMIT: u64 = 75_000_000; -const MAX_POV_SIZE: u64 = 5 * 1024 * 1024; -const WEIGHT_MILLISECS_PER_BLOCK: u64 = 2000; - -parameter_types! { - pub BlockGasLimit: U256 = U256::from(BLOCK_GAS_LIMIT); - pub const ChainId: u64 = 1337; - pub const GasLimitPovSizeRatio: u64 = BLOCK_GAS_LIMIT.saturating_div(MAX_POV_SIZE); - pub PrecompilesValue: FrontierPrecompiles = FrontierPrecompiles::<_>::new(); - pub WeightPerGas: Weight = Weight::from_parts(weight_per_gas(BLOCK_GAS_LIMIT, NORMAL_DISPATCH_RATIO, WEIGHT_MILLISECS_PER_BLOCK), 0); - pub SuicideQuickClearLimit: u32 = 0; -} - -impl pallet_evm::Config for Runtime { - type FeeCalculator = BaseFee; - type GasWeightMapping = pallet_evm::FixedGasWeightMapping; - type WeightPerGas = WeightPerGas; - type BlockHashMapping = pallet_ethereum::EthereumBlockHashMapping; - type CallOrigin = EnsureAddress; - type WithdrawOrigin = EnsureAddress; - type AddressMapping = AddressMapping; - type Currency = Balances; - type RuntimeEvent = RuntimeEvent; - type PrecompilesType = FrontierPrecompiles; - type PrecompilesValue = PrecompilesValue; - type ChainId = ChainId; - type BlockGasLimit = BlockGasLimit; - type Runner = pallet_evm::runner::stack::Runner; - type OnChargeTransaction = (); - type OnCreate = (); - type FindAuthor = (); - type GasLimitPovSizeRatio = GasLimitPovSizeRatio; - type SuicideQuickClearLimit = SuicideQuickClearLimit; - type Timestamp = Timestamp; - type WeightInfo = pallet_evm::weights::SubstrateWeight; -} diff --git a/runtime/solochain/src/configs/grandpa.rs b/runtime/solochain/src/configs/grandpa.rs deleted file mode 100644 index 2dcc55bc..00000000 --- a/runtime/solochain/src/configs/grandpa.rs +++ /dev/null @@ -1,32 +0,0 @@ -// This file is part of Noir. - -// Copyright (c) Haderech Pte. Ltd. -// SPDX-License-Identifier: GPL-3.0-or-later - -// This program 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. -// -// This program 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 this program. If not, see . - -use crate::*; - -use sp_core::Void; -use sp_runtime::traits::{ConstU32, ConstU64}; - -impl pallet_grandpa::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type WeightInfo = (); - type MaxAuthorities = ConstU32<32>; - type MaxNominators = ConstU32<0>; - type MaxSetIdSessionEntries = ConstU64<0>; - type KeyOwnerProof = Void; - type EquivocationReportSystem = (); -} diff --git a/runtime/solochain/src/configs/mod.rs b/runtime/solochain/src/configs/mod.rs deleted file mode 100644 index 69a92046..00000000 --- a/runtime/solochain/src/configs/mod.rs +++ /dev/null @@ -1,42 +0,0 @@ -// This file is part of Noir. - -// Copyright (c) Haderech Pte. Ltd. -// SPDX-License-Identifier: GPL-3.0-or-later - -// This program 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. -// -// This program 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 this program. If not, see . - -use crate::*; - -mod address_map; -mod aura; -mod babel; -mod balances; -mod base_fee; -mod ethereum; -mod evm; -mod grandpa; -mod sudo; -mod system; -mod timestamp; -mod transaction_payment; - -use common::units::{CENTS, SECONDS}; - -pub const SLOT_DURATION: Moment = 6 * SECONDS; - -pub const MINIMUM_PERIOD: Moment = SLOT_DURATION / 2; - -pub const EXISTENTIAL_DEPOSIT: Balance = 1 * CENTS; - -pub const BLOCK_HASH_COUNT: BlockNumber = 4096; diff --git a/runtime/solochain/src/configs/sudo.rs b/runtime/solochain/src/configs/sudo.rs deleted file mode 100644 index 6f92497d..00000000 --- a/runtime/solochain/src/configs/sudo.rs +++ /dev/null @@ -1,25 +0,0 @@ -// This file is part of Noir. - -// Copyright (c) Haderech Pte. Ltd. -// SPDX-License-Identifier: GPL-3.0-or-later - -// This program 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. -// -// This program 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 this program. If not, see . - -use crate::*; - -impl pallet_sudo::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type RuntimeCall = RuntimeCall; - type WeightInfo = pallet_sudo::weights::SubstrateWeight; -} diff --git a/runtime/solochain/src/configs/system.rs b/runtime/solochain/src/configs/system.rs deleted file mode 100644 index 95f8b822..00000000 --- a/runtime/solochain/src/configs/system.rs +++ /dev/null @@ -1,70 +0,0 @@ -// This file is part of Noir. - -// Copyright (c) Haderech Pte. Ltd. -// SPDX-License-Identifier: GPL-3.0-or-later - -// This program 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. -// -// This program 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 this program. If not, see . - -use crate::*; - -use common::{ - BlockHashCount, BlockLength, AVERAGE_ON_INITIALIZE_RATIO, MAXIMUM_BLOCK_WEIGHT, - NORMAL_DISPATCH_RATIO, -}; -use frame_support::{ - derive_impl, - dispatch::DispatchClass, - traits::ConstU32, - weights::constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight}, -}; -use frame_system::{config_preludes::SolochainDefaultConfig, limits}; -use sp_runtime::traits::AccountIdLookup; - -parameter_types! { - pub BlockWeights: limits::BlockWeights = limits::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); - weights.reserved = Some( - MAXIMUM_BLOCK_WEIGHT - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT, - ); - }) - .avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO) - .build_or_panic(); - pub const SS58Prefix: u16 = 42; - pub const Version: RuntimeVersion = VERSION; -} - -#[derive_impl(SolochainDefaultConfig as frame_system::DefaultConfig)] -impl frame_system::Config for Runtime { - type BlockWeights = BlockWeights; - type BlockLength = BlockLength; - type Nonce = AccountNonce; - type Hash = Hash; - type AccountId = AccountId; - type Lookup = AccountIdLookup; - type Block = Block; - type BlockHashCount = BlockHashCount; - type DbWeight = RocksDbWeight; - type Version = Version; - type AccountData = pallet_balances::AccountData; - type SS58Prefix = SS58Prefix; - type MaxConsumers = ConstU32<16>; -} diff --git a/runtime/solochain/src/configs/timestamp.rs b/runtime/solochain/src/configs/timestamp.rs deleted file mode 100644 index a30ce208..00000000 --- a/runtime/solochain/src/configs/timestamp.rs +++ /dev/null @@ -1,29 +0,0 @@ -// This file is part of Noir. - -// Copyright (c) Haderech Pte. Ltd. SPDX-License-Identifier: GPL-3.0-or-later - -// This program 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. -// -// This program 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 this program. If not, see . - -use crate::*; - -parameter_types! { - pub const MinimumPeriod: Moment = super::MINIMUM_PERIOD; -} - -impl pallet_timestamp::Config for Runtime { - type Moment = Moment; - type OnTimestampSet = Aura; - type MinimumPeriod = MinimumPeriod; - type WeightInfo = pallet_timestamp::weights::SubstrateWeight; -} diff --git a/runtime/solochain/src/configs/transaction_payment.rs b/runtime/solochain/src/configs/transaction_payment.rs deleted file mode 100644 index b2ee9474..00000000 --- a/runtime/solochain/src/configs/transaction_payment.rs +++ /dev/null @@ -1,58 +0,0 @@ -// This file is part of Noir. - -// Copyright (c) Haderech Pte. Ltd. -// SPDX-License-Identifier: GPL-3.0-or-later - -// This program 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. -// -// This program 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 this program. If not, see . - -use crate::*; - -use common::{units::CENTS, SlowAdjustingFeeUpdate}; -use frame_support::weights::{ - constants::ExtrinsicBaseWeight, ConstantMultiplier, WeightToFeeCoefficient, - WeightToFeeCoefficients, WeightToFeePolynomial, -}; -use pallet_transaction_payment::FungibleAdapter; -use smallvec::smallvec; -use sp_runtime::Perbill; - -parameter_types! { - pub const OperationalFeeMultiplier: u8 = 5; - pub const TransactionByteFee: Balance = (1 * CENTS) / 100; -} - -pub struct WeightToFee; - -impl WeightToFeePolynomial for WeightToFee { - type Balance = Balance; - fn polynomial() -> WeightToFeeCoefficients { - let p = 1 * CENTS; - let q = 10 * Balance::from(ExtrinsicBaseWeight::get().ref_time()); - smallvec![WeightToFeeCoefficient { - coeff_integer: p / q, - coeff_frac: Perbill::from_rational(p % q, q), - negative: false, - degree: 1, - }] - } -} - -impl pallet_transaction_payment::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type OnChargeTransaction = FungibleAdapter; - type WeightToFee = WeightToFee; - type LengthToFee = ConstantMultiplier; - type FeeMultiplierUpdate = SlowAdjustingFeeUpdate; - type OperationalFeeMultiplier = OperationalFeeMultiplier; -} diff --git a/runtime/solochain/src/lib.rs b/runtime/solochain/src/lib.rs deleted file mode 100644 index 9de78960..00000000 --- a/runtime/solochain/src/lib.rs +++ /dev/null @@ -1,107 +0,0 @@ -// This file is part of Noir. - -// Copyright (c) Haderech Pte. Ltd. -// SPDX-License-Identifier: GPL-3.0-or-later - -// This program 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. -// -// This program 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 this program. If not, see . - -#![cfg_attr(not(feature = "std"), no_std)] - -#[cfg(feature = "std")] -include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs")); - -extern crate alloc; - -mod apis; -mod call; -pub mod configs; -pub mod prelude; -mod primitives; -mod version; - -pub use apis::*; -pub use noir_runtime_common as common; -pub use primitives::*; -pub use version::*; - -use alloc::vec::Vec; -use frame_support::parameter_types; -use sp_consensus_aura::sr25519::AuthorityId as AuraId; -use sp_version::RuntimeVersion; - -#[frame_support::runtime] -mod runtime { - #[runtime::runtime] - #[runtime::derive( - RuntimeCall, - RuntimeEvent, - RuntimeError, - RuntimeOrigin, - RuntimeFreezeReason, - RuntimeHoldReason, - RuntimeSlashReason, - RuntimeLockId, - RuntimeTask - )] - pub struct Runtime; - - #[runtime::pallet_index(0)] - pub type System = frame_system; - - #[runtime::pallet_index(3)] - pub type Timestamp = pallet_timestamp; - - #[runtime::pallet_index(10)] - pub type Balances = pallet_balances; - - #[runtime::pallet_index(11)] - pub type TransactionPayment = pallet_transaction_payment; - - #[runtime::pallet_index(23)] - pub type Aura = pallet_aura; - - #[runtime::pallet_index(24)] - pub type Grandpa = pallet_grandpa; - - //#[runtime::pallet_index(50)] - //pub type Assets = pallet_assets; - - #[runtime::pallet_index(60)] - pub type Ethereum = pallet_ethereum; - - #[runtime::pallet_index(61)] - pub type Evm = pallet_evm; - - #[runtime::pallet_index(62)] - pub type BaseFee = pallet_base_fee; - - #[runtime::pallet_index(128)] - pub type AddressMap = pallet_multimap; - - #[runtime::pallet_index(255)] - pub type Sudo = pallet_sudo; -} - -#[cfg(feature = "runtime-benchmarks")] -mod benches { - frame_benchmarking::define_benchmarks!( - [frame_benchmarking, BaselineBench::] - [frame_system, SystemBench::] - [pallet_balances, Balances] - [pallet_evm, Evm] - [pallet_grandpa, Grandpa] - [pallet_sudo, Sudo] - [pallet_timestamp, Timestamp] - ); -} diff --git a/runtime/solochain/src/prelude.rs b/runtime/solochain/src/prelude.rs deleted file mode 100644 index 38f92fe5..00000000 --- a/runtime/solochain/src/prelude.rs +++ /dev/null @@ -1,22 +0,0 @@ -// This file is part of Noir. - -// Copyright (c) Haderech Pte. Ltd. -// SPDX-License-Identifier: GPL-3.0-or-later - -// This program 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. -// -// This program 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 this program. If not, see . - -#[cfg(feature = "std")] -pub use crate::WASM_BINARY; -pub use crate::{common as runtime_common, configs::*, primitives::*}; -pub use noir_core_primitives::{Block, BlockId, Header, UncheckedExtrinsic}; diff --git a/runtime/solochain/src/primitives.rs b/runtime/solochain/src/primitives.rs deleted file mode 100644 index 1c8e5d15..00000000 --- a/runtime/solochain/src/primitives.rs +++ /dev/null @@ -1,74 +0,0 @@ -// This file is part of Noir. - -// Copyright (c) Haderech Pte. Ltd. -// SPDX-License-Identifier: GPL-3.0-or-later - -// This program 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. -// -// This program 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 this program. If not, see . - -use crate::*; - -pub use noir_core_primitives::*; - -use np_runtime::self_contained; -use sp_runtime::{generic, MultiAddress}; - -pub type Address = MultiAddress; - -pub type Block = generic::Block; - -pub type Executive = frame_executive::Executive< - Runtime, - Block, - frame_system::ChainContext, - Runtime, - AllPalletsWithSystem, - Migrations, ->; - -pub type Header = generic::Header; - -pub type Migrations = (); - -pub type SignedExtra = ( - frame_system::CheckNonZeroSender, - frame_system::CheckSpecVersion, - frame_system::CheckTxVersion, - frame_system::CheckGenesis, - frame_system::CheckMortality, - frame_system::CheckNonce, - frame_babel::UnifyAccount, - frame_system::CheckWeight, - pallet_transaction_payment::ChargeTransactionPayment, -); - -pub type SignedPayload = generic::SignedPayload; - -pub type UncheckedExtrinsic = - self_contained::UncheckedExtrinsic; - -pub use frame_system::Call as SystemCall; -pub use pallet_balances::Call as BalancesCall; - -pub mod opaque { - use crate::{Aura, Grandpa}; - use alloc::vec::Vec; - use sp_runtime::impl_opaque_keys; - - impl_opaque_keys! { - pub struct SessionKeys { - pub aura: Aura, - pub grandpa: Grandpa, - } - } -} diff --git a/runtime/solochain/src/version.rs b/runtime/solochain/src/version.rs deleted file mode 100644 index 537b41ff..00000000 --- a/runtime/solochain/src/version.rs +++ /dev/null @@ -1,42 +0,0 @@ -// This file is part of Noir. - -// Copyright (c) Haderech Pte. Ltd. -// SPDX-License-Identifier: GPL-3.0-or-later - -// This program 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. -// -// This program 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 this program. If not, see . - -use crate::*; - -use sp_runtime::create_runtime_str; -use sp_version::runtime_version; -#[cfg(feature = "std")] -use sp_version::NativeVersion; - -#[runtime_version] -pub const VERSION: RuntimeVersion = RuntimeVersion { - spec_name: create_runtime_str!("noir"), - impl_name: create_runtime_str!("noir"), - authoring_version: 1, - // spec_version: MAJOR_MINOR_PATCH - spec_version: 4_00, - impl_version: 1, - apis: RUNTIME_API_VERSIONS, - transaction_version: 1, - state_version: 1, -}; - -#[cfg(feature = "std")] -pub fn native_version() -> NativeVersion { - NativeVersion { runtime_version: VERSION, can_author_with: Default::default() } -}