diff --git a/Cargo.lock b/Cargo.lock index 03d3606a..8063c4a1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2206,6 +2206,7 @@ dependencies = [ "log", "pallet-transaction-payment-rpc", "pangolin-runtime", + "pangoro-runtime", "parity-scale-codec", "polkadot-cli", "polkadot-parachain", @@ -2285,7 +2286,9 @@ dependencies = [ "dc-primitives", "frame-support", "frame-system", + "pallet-balances", "pallet-collective", + "pallet-treasury", "parity-scale-codec", "smallvec", "sp-io", @@ -7455,6 +7458,109 @@ dependencies = [ "xcm-primitives", ] +[[package]] +name = "pangoro-runtime" +version = "6.0.0" +dependencies = [ + "array-bytes 6.0.0", + "bp-message-dispatch", + "bp-messages", + "bp-polkadot-core", + "bp-runtime", + "bridge-runtime-common", + "cumulus-pallet-aura-ext", + "cumulus-pallet-dmp-queue", + "cumulus-pallet-parachain-system", + "cumulus-pallet-session-benchmarking", + "cumulus-pallet-xcm", + "cumulus-pallet-xcmp-queue", + "cumulus-primitives-core", + "cumulus-primitives-timestamp", + "cumulus-primitives-utility", + "darwinia-account-migration", + "darwinia-common-runtime", + "darwinia-deposit", + "darwinia-ecdsa-authority", + "darwinia-message-gadget", + "darwinia-message-transact", + "darwinia-precompile-assets", + "darwinia-precompile-bls12-381", + "darwinia-precompile-deposit", + "darwinia-precompile-staking", + "darwinia-precompile-state-storage", + "darwinia-staking", + "dc-primitives", + "fp-rpc", + "fp-self-contained", + "frame-benchmarking", + "frame-executive", + "frame-support", + "frame-system", + "frame-system-benchmarking", + "frame-system-rpc-runtime-api", + "frame-try-runtime", + "pallet-assets", + "pallet-aura", + "pallet-authorship", + "pallet-balances", + "pallet-bridge-dispatch", + "pallet-bridge-grandpa", + "pallet-bridge-messages", + "pallet-bridge-parachains", + "pallet-collective", + "pallet-democracy", + "pallet-elections-phragmen", + "pallet-ethereum", + "pallet-evm", + "pallet-evm-precompile-blake2", + "pallet-evm-precompile-bn128", + "pallet-evm-precompile-dispatch", + "pallet-evm-precompile-modexp", + "pallet-evm-precompile-simple", + "pallet-fee-market", + "pallet-identity", + "pallet-membership", + "pallet-multisig", + "pallet-preimage", + "pallet-proxy", + "pallet-scheduler", + "pallet-session", + "pallet-sudo", + "pallet-timestamp", + "pallet-tips", + "pallet-transaction-payment", + "pallet-transaction-payment-rpc-runtime-api", + "pallet-treasury", + "pallet-utility", + "pallet-vesting", + "pallet-xcm", + "parachain-info", + "parity-scale-codec", + "polkadot-parachain", + "polkadot-runtime-common", + "precompile-utils", + "scale-info", + "sp-api", + "sp-block-builder", + "sp-consensus-aura", + "sp-core", + "sp-inherents", + "sp-io", + "sp-keyring", + "sp-offchain", + "sp-runtime", + "sp-session", + "sp-std", + "sp-transaction-pool", + "sp-version", + "static_assertions", + "substrate-wasm-builder", + "xcm", + "xcm-builder", + "xcm-executor", + "xcm-primitives", +] + [[package]] name = "parachain-info" version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml index 1420c5e7..cce2c62f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -66,6 +66,7 @@ members = [ dc-primitives = { default-features = false, path = "core/primitives" } dc-types = { path = "core/types" } pangolin-runtime = { path = "runtime/pangolin" } + pangoro-runtime = { path = "runtime/pangoro" } # darwinia-messages-substrate bp-darwinia-core = { default-features = false, git = "https://github.com/darwinia-network/darwinia-messages-substrate", branch = "polkadot-v0.9.36" } diff --git a/node/Cargo.toml b/node/Cargo.toml index df606523..79e40570 100644 --- a/node/Cargo.toml +++ b/node/Cargo.toml @@ -36,6 +36,7 @@ crab-runtime = { optional = true, workspace = true } darwinia-runtime = { optional = true, workspace = true } dc-primitives = { workspace = true } pangolin-runtime = { optional = true, workspace = true } +pangoro-runtime = { optional = true, workspace = true } # frontier fc-cli = { workspace = true } @@ -107,6 +108,7 @@ fast-runtime = [ "crab-runtime?/fast-runtime", "darwinia-runtime?/fast-runtime", "pangolin-runtime?/fast-runtime", + "pangoro-runtime?/fast-runtime", ] runtime-benchmarks = [ @@ -114,6 +116,7 @@ runtime-benchmarks = [ "crab-runtime?/runtime-benchmarks", "darwinia-runtime?/runtime-benchmarks", "pangolin-runtime?/runtime-benchmarks", + "pangoro-runtime?/runtime-benchmarks", # polkadot "polkadot-cli/runtime-benchmarks", @@ -124,6 +127,7 @@ try-runtime = [ "crab-runtime?/try-runtime", "darwinia-runtime?/try-runtime", "pangolin-runtime?/try-runtime", + "pangoro-runtime?/try-runtime", # substrate "try-runtime-cli/try-runtime", @@ -134,6 +138,7 @@ all-natives = [ "crab-native", "darwinia-native", "pangolin-native", + "pangoro-native", ] crab-native = [ # darwinia @@ -156,3 +161,10 @@ pangolin-native = [ # polkadot "polkadot-cli/rococo-native", ] +pangoro-native = [ + # darwinia + "pangoro-runtime", + + # polkadot + "polkadot-cli/rococo-native", +] diff --git a/node/src/chain_spec/crab.rs b/node/src/chain_spec/crab.rs index 45bee456..a9b1c997 100644 --- a/node/src/chain_spec/crab.rs +++ b/node/src/chain_spec/crab.rs @@ -40,7 +40,7 @@ use sp_core::H160; pub type ChainSpec = sc_service::GenericChainSpec; fn properties() -> Properties { - super::properties("CRAB", 42) + super::properties("CRAB") } // Generate the session keys from individual elements. diff --git a/node/src/chain_spec/darwinia.rs b/node/src/chain_spec/darwinia.rs index bf2b6ee7..781efc6a 100644 --- a/node/src/chain_spec/darwinia.rs +++ b/node/src/chain_spec/darwinia.rs @@ -40,7 +40,7 @@ use sp_core::H160; pub type ChainSpec = sc_service::GenericChainSpec; fn properties() -> Properties { - super::properties("RING", 18) + super::properties("RING") } // Generate the session keys from individual elements. diff --git a/node/src/chain_spec/mod.rs b/node/src/chain_spec/mod.rs index c8407eaa..11f5e099 100644 --- a/node/src/chain_spec/mod.rs +++ b/node/src/chain_spec/mod.rs @@ -39,7 +39,14 @@ pub use pangolin::{self as pangolin_chain_spec, ChainSpec as PangolinChainSpec}; #[cfg(not(feature = "pangolin-native"))] pub type PangolinChainSpec = DummyChainSpec; -#[cfg(feature = "pangolin-native")] +#[cfg(feature = "pangoro-native")] +pub mod pangoro; +#[cfg(feature = "pangoro-native")] +pub use pangoro::{self as pangoro_chain_spec, ChainSpec as PangoroChainSpec}; +#[cfg(not(feature = "pangoro-native"))] +pub type PangoroChainSpec = DummyChainSpec; + +#[cfg(any(feature = "pangolin-native", feature = "pangoro-native"))] mod testnet_keys { pub const C1: &str = "0x0eef9fabb6eb6fed2ab24a842931f8950426070a"; pub const C1_AURA: &str = "0xeed007f04d568b2d3bf329945a48c21a8ed030c81ca1dce61ad41c916599f405"; @@ -49,7 +56,7 @@ mod testnet_keys { pub const C3_AURA: &str = "0xe25d860707bd1b88b9851cf40df3af3368cd57e5e82824cabac9c75fe537600f"; pub const SUDO: &str = "0x2748def2f9c3cfbbb963002935bc6d2e1c36ce2e"; } -#[cfg(feature = "pangolin-native")] +#[cfg(any(feature = "pangolin-native", feature = "pangoro-native"))] use testnet_keys::*; // crates.io @@ -96,12 +103,11 @@ impl Extensions { } } -fn properties(token_symbol: &str, ss58_format: u16) -> Properties { +fn properties(token_symbol: &str) -> Properties { let mut properties = Properties::new(); properties.insert("tokenSymbol".into(), token_symbol.into()); properties.insert("tokenDecimals".into(), 18.into()); - properties.insert("ss58Format".into(), ss58_format.into()); properties } diff --git a/node/src/chain_spec/pangolin.rs b/node/src/chain_spec/pangolin.rs index 0b9c4c16..404d6bf3 100644 --- a/node/src/chain_spec/pangolin.rs +++ b/node/src/chain_spec/pangolin.rs @@ -40,7 +40,7 @@ use sp_core::{crypto::UncheckedInto, H160}; pub type ChainSpec = sc_service::GenericChainSpec; fn properties() -> Properties { - super::properties("PRING", 42) + super::properties("PRING") } // Generate the session keys from individual elements. diff --git a/node/src/chain_spec/pangoro.rs b/node/src/chain_spec/pangoro.rs new file mode 100644 index 00000000..02e034cb --- /dev/null +++ b/node/src/chain_spec/pangoro.rs @@ -0,0 +1,362 @@ +// This file is part of Darwinia. +// +// Copyright (C) 2018-2023 Darwinia Network +// SPDX-License-Identifier: GPL-3.0 +// +// Darwinia 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. +// +// Darwinia 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 Darwinia. If not, see . + +#![allow(clippy::derive_partial_eq_without_eq)] + +// std +use std::{ + collections::BTreeMap, + str::FromStr, + time::{SystemTime, UNIX_EPOCH}, +}; +// cumulus +use cumulus_primitives_core::ParaId; +// darwinia +use super::*; +use pangoro_runtime::*; +// frontier +use fp_evm::GenesisAccount; +// substrate +use sc_chain_spec::Properties; +use sc_service::ChainType; +use sp_core::{crypto::UncheckedInto, H160}; + +/// Specialized `ChainSpec` for the normal parachain runtime. +pub type ChainSpec = sc_service::GenericChainSpec; + +fn properties() -> Properties { + super::properties("ORING") +} + +// Generate the session keys from individual elements. +// +// The input must be a tuple of individual keys (a single arg for now since we have just one key). +fn session_keys(keys: AuraId) -> SessionKeys { + SessionKeys { aura: keys } +} + +pub fn development_config() -> ChainSpec { + ChainSpec::from_genesis( + "Pangoro2 Development", + "pangoro2-development", + ChainType::Development, + move || { + testnet_genesis( + vec![ + // Bind the `Alice` to `Alith` to make `--alice` available for testnet. + ( + array_bytes::hex_n_into_unchecked(ALITH), + get_collator_keys_from_seed("Alice"), + ), + ], + vec![ + array_bytes::hex_n_into_unchecked(ALITH), + array_bytes::hex_n_into_unchecked(BALTATHAR), + array_bytes::hex_n_into_unchecked(CHARLETH), + array_bytes::hex_n_into_unchecked(DOROTHY), + array_bytes::hex_n_into_unchecked(ETHAN), + array_bytes::hex_n_into_unchecked(FAITH), + ], + 2046.into(), + ) + }, + Vec::new(), + None, + Some(PROTOCOL_ID), + None, + Some(properties()), + Extensions { + relay_chain: "rococo-local".into(), // You MUST set this to the correct network! + para_id: 2046, + }, + ) +} + +pub fn local_config() -> ChainSpec { + ChainSpec::from_genesis( + "Pangoro2 Local", + "pangoro2-local", + ChainType::Local, + move || { + testnet_genesis( + vec![ + // Bind the `Alice` to `Alith` to make `--alice` available for testnet. + ( + array_bytes::hex_n_into_unchecked(ALITH), + get_collator_keys_from_seed("Alice"), + ), + // Bind the `Bob` to `Balthar` to make `--bob` available for testnet. + ( + array_bytes::hex_n_into_unchecked(BALTATHAR), + get_collator_keys_from_seed("Bob"), + ), + // Bind the `Charlie` to `CHARLETH` to make `--charlie` available for testnet. + ( + array_bytes::hex_n_into_unchecked(CHARLETH), + get_collator_keys_from_seed("Charlie"), + ), + ], + vec![ + array_bytes::hex_n_into_unchecked(ALITH), + array_bytes::hex_n_into_unchecked(BALTATHAR), + array_bytes::hex_n_into_unchecked(CHARLETH), + array_bytes::hex_n_into_unchecked(DOROTHY), + array_bytes::hex_n_into_unchecked(ETHAN), + array_bytes::hex_n_into_unchecked(FAITH), + ], + 2046.into(), + ) + }, + Vec::new(), + None, + Some(PROTOCOL_ID), + None, + Some(properties()), + Extensions { + relay_chain: "rococo-local".into(), // You MUST set this to the correct network! + para_id: 2046, + }, + ) +} + +pub fn genesis_config() -> ChainSpec { + ChainSpec::from_genesis( + "Pangoro2", + "pangoro2", + ChainType::Live, + move || { + GenesisConfig { + // System stuff. + system: SystemConfig { code: WASM_BINARY.unwrap().to_vec() }, + parachain_system: Default::default(), + parachain_info: ParachainInfoConfig { parachain_id: 2046.into() }, + + // Monetary stuff. + balances: BalancesConfig { + balances: vec![ + (array_bytes::hex_n_into_unchecked(C1), 10_000 * UNIT), + (array_bytes::hex_n_into_unchecked(C2), 10_000 * UNIT), + (array_bytes::hex_n_into_unchecked(C3), 10_000 * UNIT), + ], + }, + transaction_payment: Default::default(), + assets: AssetsConfig { + assets: vec![(AssetIds::OKton as _, ROOT, true, 1)], + metadata: vec![( + AssetIds::OKton as _, + b"Pangoro Commitment Token".to_vec(), + b"OKTON".to_vec(), + 18, + )], + ..Default::default() + }, + vesting: Default::default(), + + // Consensus stuff. + darwinia_staking: DarwiniaStakingConfig { + now: SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_millis(), + elapsed_time: 11_516_352_020, + collator_count: 3, + collators: vec![ + (array_bytes::hex_n_into_unchecked(C1), UNIT), + (array_bytes::hex_n_into_unchecked(C2), UNIT), + (array_bytes::hex_n_into_unchecked(C3), UNIT), + ], + }, + session: SessionConfig { + keys: vec![ + ( + array_bytes::hex_n_into_unchecked(C1), + array_bytes::hex_n_into_unchecked(C1), + session_keys( + array_bytes::hex2array_unchecked(C1_AURA).unchecked_into(), + ), + ), + ( + array_bytes::hex_n_into_unchecked(C2), + array_bytes::hex_n_into_unchecked(C2), + session_keys( + array_bytes::hex2array_unchecked(C2_AURA).unchecked_into(), + ), + ), + ( + array_bytes::hex_n_into_unchecked(C3), + array_bytes::hex_n_into_unchecked(C3), + session_keys( + array_bytes::hex2array_unchecked(C3_AURA).unchecked_into(), + ), + ), + ], + }, + aura: Default::default(), + aura_ext: Default::default(), + message_gadget: Default::default(), + ecdsa_authority: Default::default(), + + // Governance stuff. + democracy: Default::default(), + council: Default::default(), + technical_committee: Default::default(), + phragmen_election: Default::default(), + technical_membership: Default::default(), + treasury: Default::default(), + + // Utility stuff. + sudo: SudoConfig { key: Some(array_bytes::hex_n_into_unchecked(SUDO)) }, + + // XCM stuff. + polkadot_xcm: PolkadotXcmConfig { safe_xcm_version: Some(SAFE_XCM_VERSION) }, + + // EVM stuff. + ethereum: Default::default(), + evm: EvmConfig { + accounts: { + BTreeMap::from_iter( + PangoroPrecompiles::::used_addresses().iter().map(|p| { + ( + p.to_owned(), + GenesisAccount { + nonce: Default::default(), + balance: Default::default(), + storage: Default::default(), + code: REVERT_BYTECODE.to_vec(), + }, + ) + }), + ) + }, + }, + } + }, + Vec::new(), + None, + Some(PROTOCOL_ID), + None, + Some(properties()), + Extensions { + relay_chain: "rococo".into(), // You MUST set this to the correct network! + para_id: 2046, + }, + ) +} + +pub fn config() -> ChainSpec { + unimplemented!("TODO") +} + +fn testnet_genesis( + collators: Vec<(AccountId, AuraId)>, + endowed_accounts: Vec, + id: ParaId, +) -> GenesisConfig { + GenesisConfig { + // System stuff. + system: SystemConfig { code: WASM_BINARY.unwrap().to_vec() }, + parachain_system: Default::default(), + parachain_info: ParachainInfoConfig { parachain_id: id }, + + // Monetary stuff. + balances: BalancesConfig { + balances: endowed_accounts.iter().cloned().map(|k| (k, 100_000_000 * UNIT)).collect(), + }, + transaction_payment: Default::default(), + assets: AssetsConfig { + assets: vec![(AssetIds::OKton as _, ROOT, true, 1)], + metadata: vec![( + AssetIds::OKton as _, + b"Pangoro Commitment Token".to_vec(), + b"OKTON".to_vec(), + 18, + )], + ..Default::default() + }, + vesting: Default::default(), + + // Consensus stuff. + darwinia_staking: DarwiniaStakingConfig { + now: SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_millis(), + elapsed_time: 0, + collator_count: collators.len() as _, + collators: collators.iter().map(|(a, _)| (a.to_owned(), UNIT)).collect(), + }, + session: SessionConfig { + keys: collators + .into_iter() + .map(|(acc, aura)| { + ( + acc, // account id + acc, // validator id + session_keys(aura), // session keys + ) + }) + .collect(), + }, + aura: Default::default(), + aura_ext: Default::default(), + message_gadget: Default::default(), + ecdsa_authority: Default::default(), + + // Governance stuff. + democracy: Default::default(), + council: Default::default(), + technical_committee: Default::default(), + phragmen_election: Default::default(), + technical_membership: Default::default(), + treasury: Default::default(), + + // Utility stuff. + sudo: SudoConfig { key: Some(array_bytes::hex_n_into_unchecked(ALITH)) }, + + // XCM stuff. + polkadot_xcm: PolkadotXcmConfig { safe_xcm_version: Some(SAFE_XCM_VERSION) }, + + // EVM stuff. + ethereum: Default::default(), + evm: EvmConfig { + accounts: { + BTreeMap::from_iter( + PangoroPrecompiles::::used_addresses() + .iter() + .map(|p| { + ( + p.to_owned(), + GenesisAccount { + nonce: Default::default(), + balance: Default::default(), + storage: Default::default(), + code: REVERT_BYTECODE.to_vec(), + }, + ) + }) + .chain([ + // Benchmarking account. + ( + H160::from_str("1000000000000000000000000000000000000001").unwrap(), + GenesisAccount { + nonce: 1.into(), + balance: (10_000_000 * UNIT).into(), + storage: Default::default(), + code: vec![0x00], + }, + ), + ]), + ) + }, + }, + } +} diff --git a/node/src/command.rs b/node/src/command.rs index b360b330..bab287d1 100644 --- a/node/src/command.rs +++ b/node/src/command.rs @@ -57,9 +57,9 @@ impl SubstrateCli for Cli { fn description() -> String { format!( "Darwinia\n\nThe command-line arguments provided first will be \ - passed to the parachain node, while the arguments provided after -- will be passed \ - to the relay chain node.\n\n\ - {} -- ", + passed to the parachain node, while the arguments provided after -- will be passed \ + to the relay chain node.\n\n\ + {} -- ", Self::executable_name() ) } @@ -69,11 +69,11 @@ impl SubstrateCli for Cli { } fn support_url() -> String { - "https://github.com/paritytech/cumulus/issues/new".into() + "https://github.com/darwinia-network/darwinia/issues/new".into() } fn copyright_start_year() -> i32 { - 2020 + 2018 } fn load_spec(&self, id: &str) -> std::result::Result, String> { @@ -86,17 +86,24 @@ impl SubstrateCli for Cli { return &crab_runtime::VERSION; } + #[cfg(feature = "darwinia-native")] + if spec.is_darwinia() { + return &darwinia_runtime::VERSION; + } + #[cfg(feature = "pangolin-native")] if spec.is_pangolin() { return &pangolin_runtime::VERSION; } - #[cfg(feature = "darwinia-native")] - if spec.is_darwinia() { - return &darwinia_runtime::VERSION; + #[cfg(feature = "pangoro-native")] + if spec.is_pangoro() { + return &pangoro_runtime::VERSION; } - panic!("No runtime feature (crab, darwinia, pangolin) is enabled"); + panic!( + "No feature(crab-native, darwinia-native, pangolin-native, pangoro-native) is enabled!" + ); } } @@ -112,9 +119,9 @@ impl SubstrateCli for RelayChainCli { fn description() -> String { format!( "Darwinia\n\nThe command-line arguments provided first will be \ - passed to the parachain node, while the arguments provided after -- will be passed \ - to the relay chain node.\n\n\ - {} -- ", + passed to the parachain node, while the arguments provided after -- will be passed \ + to the relay chain node.\n\n\ + {} -- ", Self::executable_name() ) } @@ -287,6 +294,16 @@ pub fn run() -> Result<()> { return $code; } + #[cfg(feature = "darwinia-native")] + if $config.chain_spec.is_darwinia() { + let $partials = new_partial::( + &$config, + &$cli.eth_args.build_eth_rpc_config(), + )?; + + return $code; + } + #[cfg(feature = "pangolin-native")] if $config.chain_spec.is_pangolin() { let $partials = new_partial::( @@ -297,9 +314,9 @@ pub fn run() -> Result<()> { return $code; } - #[cfg(feature = "darwinia-native")] - if $config.chain_spec.is_darwinia() { - let $partials = new_partial::( + #[cfg(feature = "pangoro-native")] + if $config.chain_spec.is_pangoro() { + let $partials = new_partial::( &$config, &$cli.eth_args.build_eth_rpc_config(), )?; @@ -307,7 +324,7 @@ pub fn run() -> Result<()> { return $code; } - panic!("No runtime feature (polkadot, kusama, westend, rococo) is enabled"); + panic!("No feature(crab-native, darwinia-native, pangolin-native, pangoro-native) is enabled!"); }}; } @@ -334,6 +351,22 @@ pub fn run() -> Result<()> { }); } + #[cfg(feature = "darwinia-native")] + if chain_spec.is_darwinia() { + return runner.async_run(|$config| { + let $components = service::new_partial::< + DarwiniaRuntimeApi, + DarwiniaRuntimeExecutor, + >( + &$config, + &$cli.eth_args.build_eth_rpc_config() + )?; + let task_manager = $components.task_manager; + + { $( $code )* }.map(|v| (v, task_manager)) + }); + } + #[cfg(feature = "pangolin-native")] if chain_spec.is_pangolin() { return runner.async_run(|$config| { @@ -350,12 +383,12 @@ pub fn run() -> Result<()> { }); } - #[cfg(feature = "darwinia-native")] - if chain_spec.is_darwinia() { + #[cfg(feature = "pangoro-native")] + if chain_spec.is_pangoro() { return runner.async_run(|$config| { let $components = service::new_partial::< - DarwiniaRuntimeApi, - DarwiniaRuntimeExecutor, + PangoroRuntimeApi, + PangoroRuntimeExecutor, >( &$config, &$cli.eth_args.build_eth_rpc_config() @@ -366,7 +399,7 @@ pub fn run() -> Result<()> { }); } - panic!("No runtime feature (crab, darwinia, pangolin) is enabled"); + panic!("No feature(crab-native, darwinia-native, pangolin-native, pangoro-native) is enabled!"); }} } @@ -469,6 +502,17 @@ pub fn run() -> Result<()> { return cmd.run::<_, dc_primitives::Block>(client, frontier_backend); } + #[cfg(feature = "darwinia-native")] + if config.chain_spec.is_darwinia() { + let PartialComponents { client, other: (frontier_backend, ..), .. } = + service::new_partial::( + &config, + &cli.eth_args.build_eth_rpc_config(), + )?; + + return cmd.run::<_, dc_primitives::Block>(client, frontier_backend); + } + #[cfg(feature = "pangolin-native")] if config.chain_spec.is_pangolin() { let PartialComponents { client, other: (frontier_backend, ..), .. } = @@ -480,10 +524,10 @@ pub fn run() -> Result<()> { return cmd.run::<_, dc_primitives::Block>(client, frontier_backend); } - #[cfg(feature = "darwinia-native")] - if config.chain_spec.is_darwinia() { + #[cfg(feature = "pangoro-native")] + if config.chain_spec.is_pangoro() { let PartialComponents { client, other: (frontier_backend, ..), .. } = - service::new_partial::( + service::new_partial::( &config, &cli.eth_args.build_eth_rpc_config(), )?; @@ -491,7 +535,7 @@ pub fn run() -> Result<()> { return cmd.run::<_, dc_primitives::Block>(client, frontier_backend); } - panic!("No runtime feature (polkadot, kusama, westend, rococo) is enabled"); + panic!("No feature(crab-native, darwinia-native, pangolin-native, pangoro-native) is enabled!"); }) }, Some(Subcommand::Benchmark(cmd)) => { @@ -507,33 +551,32 @@ pub fn run() -> Result<()> { return cmd.run::(config); } + #[cfg(feature = "darwinia-native")] + if config.chain_spec.is_darwinia() { + return cmd.run::(config); + } + #[cfg(feature = "pangolin-native")] if config.chain_spec.is_pangolin() { return cmd.run::(config); } - #[cfg(feature = "darwinia-native")] - if config.chain_spec.is_darwinia() { - return cmd.run::(config); + #[cfg(feature = "pangoro-native")] + if config.chain_spec.is_pangoro() { + return cmd.run::(config); } - panic!( - "No runtime feature (polkadot, kusama, westend, rococo) is enabled" - ); + panic!("No feature(crab-native, darwinia-native, pangolin-native, pangoro-native) is enabled!"); }) } else { - Err("Benchmarking wasn't enabled when building the node. \ - You can enable it with `--features runtime-benchmarks`." - .into()) + Err("Benchmarking wasn't enabled when building the node. You can enable it with `--features runtime-benchmarks`.".into()) }, BenchmarkCmd::Block(cmd) => runner.sync_run(|config| { construct_benchmark_partials!(config, cli, |partials| cmd.run(partials.client)) }), #[cfg(not(feature = "runtime-benchmarks"))] BenchmarkCmd::Storage(_) => Err(sc_cli::Error::Input( - "Compile with --features=runtime-benchmarks \ - to enable storage benchmarks." - .into(), + "Compile with --features=runtime-benchmarks to enable storage benchmarks.".into(), )), #[cfg(feature = "runtime-benchmarks")] BenchmarkCmd::Storage(cmd) => runner.sync_run(|config| { @@ -572,23 +615,35 @@ pub fn run() -> Result<()> { .map_err(|e| format!("Error: {:?}", e))?; if chain_spec.is_crab() { - runner.async_run(|_| { + return runner.async_run(|_| { Ok((cmd.run::>(), task_manager)) - }) - } else if chain_spec.is_pangolin() { - runner.async_run(|_| { - Ok((cmd.run::>(), task_manager)) - }) - } else { - runner.async_run(|_| { + }); + } + + if chain_spec.is_darwinia() { + return runner.async_run(|_| { Ok((cmd.run::>(), task_manager)) - }) + }); } + + if chain_spec.is_pangolin() { + return runner.async_run(|_| { + Ok((cmd.run::>(), task_manager)) + }); + } + + if chain_spec.is_pangoro() { + return runner.async_run(|_| { + Ok((cmd.run::>(), task_manager)) + }); + } + + panic!("No feature(crab-native, darwinia-native, pangolin-native, pangoro-native) is enabled!"); }, #[cfg(not(feature = "try-runtime"))] - Some(Subcommand::TryRuntime) => Err("Try-runtime was not enabled when building the node. \ - You can enable it with `--features try-runtime`." - .into()), + Some(Subcommand::TryRuntime) => Err( + "Try-runtime was not enabled when building the node. You can enable it with `--features try-runtime`.".into() + ), None => { let runner = cli.create_runner(&cli.run.normalize())?; let collator_options = cli.run.collator_options(); @@ -646,6 +701,15 @@ pub fn run() -> Result<()> { .map_err(Into::into); } + #[cfg(feature = "darwinia-native")] + if chain_spec.is_darwinia() { + return service::start_dev_node::( + config, + ð_rpc_config, + ) + .map_err(Into::into) + } + #[cfg(feature = "pangolin-native")] if chain_spec.is_pangolin() { return service::start_dev_node::( @@ -655,9 +719,9 @@ pub fn run() -> Result<()> { .map_err(Into::into) } - #[cfg(feature = "darwinia-native")] - { - return service::start_dev_node::( + #[cfg(feature = "pangoro-native")] + if chain_spec.is_pangoro() { + return service::start_dev_node::( config, ð_rpc_config, ) @@ -684,6 +748,21 @@ pub fn run() -> Result<()> { .map_err(Into::into); } + #[cfg(feature = "darwinia-native")] + if chain_spec.is_darwinia() { + return service::start_parachain_node::( + config, + polkadot_config, + collator_options, + id, + hwbench, + ð_rpc_config, + ) + .await + .map(|r| r.0) + .map_err(Into::into); + } + #[cfg(feature = "pangolin-native")] if chain_spec.is_pangolin() { return service::start_parachain_node::( @@ -699,9 +778,9 @@ pub fn run() -> Result<()> { .map_err(Into::into); } - #[cfg(feature = "darwinia-native")] + #[cfg(feature = "pangoro-native")] if chain_spec.is_darwinia() { - return service::start_parachain_node::( + return service::start_parachain_node::( config, polkadot_config, collator_options, @@ -714,7 +793,7 @@ pub fn run() -> Result<()> { .map_err(Into::into); } - panic!("No runtime feature (crab, darwinia, pangolin) is enabled"); + panic!("No feature(crab-native, darwinia-native, pangolin-native, pangoro-native) is enabled!"); }) }, } @@ -733,14 +812,6 @@ fn load_spec(id: &str) -> std::result::Result, String> { }; Ok(match id.to_lowercase().as_str() { - #[cfg(feature = "darwinia-native")] - "darwinia" => Box::new(darwinia_chain_spec::config()), - #[cfg(feature = "darwinia-native")] - "darwinia-genesis" => Box::new(darwinia_chain_spec::genesis_config()), - #[cfg(feature = "darwinia-native")] - "darwinia-dev" => Box::new(darwinia_chain_spec::development_config()), - #[cfg(feature = "darwinia-native")] - "darwinia-local" => Box::new(darwinia_chain_spec::local_config()), #[cfg(feature = "crab-native")] "crab" => Box::new(crab_chain_spec::config()), #[cfg(feature = "crab-native")] @@ -749,6 +820,14 @@ fn load_spec(id: &str) -> std::result::Result, String> { "crab-dev" => Box::new(crab_chain_spec::development_config()), #[cfg(feature = "crab-native")] "crab-local" => Box::new(crab_chain_spec::local_config()), + #[cfg(feature = "darwinia-native")] + "darwinia" => Box::new(darwinia_chain_spec::config()), + #[cfg(feature = "darwinia-native")] + "darwinia-genesis" => Box::new(darwinia_chain_spec::genesis_config()), + #[cfg(feature = "darwinia-native")] + "darwinia-dev" => Box::new(darwinia_chain_spec::development_config()), + #[cfg(feature = "darwinia-native")] + "darwinia-local" => Box::new(darwinia_chain_spec::local_config()), #[cfg(feature = "pangolin-native")] "pangolin" => Box::new(pangolin_chain_spec::config()), #[cfg(feature = "pangolin-native")] @@ -757,18 +836,36 @@ fn load_spec(id: &str) -> std::result::Result, String> { "pangolin-dev" => Box::new(pangolin_chain_spec::development_config()), #[cfg(feature = "pangolin-native")] "pangolin-local" => Box::new(pangolin_chain_spec::local_config()), + #[cfg(feature = "pangoro-native")] + "pangoro" => Box::new(pangoro_chain_spec::config()), + #[cfg(feature = "pangoro-native")] + "pangoro-genesis" => Box::new(pangoro_chain_spec::genesis_config()), + #[cfg(feature = "pangoro-native")] + "pangoro-dev" => Box::new(pangoro_chain_spec::development_config()), + #[cfg(feature = "pangoro-native")] + "pangoro-local" => Box::new(pangoro_chain_spec::local_config()), _ => { let path = PathBuf::from(id); let chain_spec = - Box::new(DarwiniaChainSpec::from_json_file(path.clone())?) as Box; + Box::new(DummyChainSpec::from_json_file(path.clone())?) as Box; if chain_spec.is_crab() { - Box::new(CrabChainSpec::from_json_file(path)?) - } else if chain_spec.is_pangolin() { - Box::new(PangolinChainSpec::from_json_file(path)?) - } else { - chain_spec + return Ok(Box::new(CrabChainSpec::from_json_file(path)?)); + } + + if chain_spec.is_darwinia() { + return Ok(Box::new(DarwiniaChainSpec::from_json_file(path)?)); + } + + if chain_spec.is_pangolin() { + return Ok(Box::new(PangolinChainSpec::from_json_file(path)?)); + } + + if chain_spec.is_pangoro() { + return Ok(Box::new(PangoroChainSpec::from_json_file(path)?)); } + + panic!("No feature(crab-native, darwinia-native, pangolin-native, pangoro-native) is enabled!") }, }) } diff --git a/node/src/service/executors.rs b/node/src/service/executors.rs index f1f71e1e..9fab5962 100644 --- a/node/src/service/executors.rs +++ b/node/src/service/executors.rs @@ -75,3 +75,22 @@ impl NativeExecutionDispatch for PangolinRuntimeExecutor { pangolin_runtime::native_version() } } + +/// Pangoro native executor instance. +#[cfg(feature = "pangoro-native")] +pub struct PangoroRuntimeExecutor; +#[cfg(feature = "pangoro-native")] +impl NativeExecutionDispatch for PangoroRuntimeExecutor { + #[cfg(feature = "runtime-benchmarks")] + type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions; + #[cfg(not(feature = "runtime-benchmarks"))] + type ExtendHostFunctions = (); + + fn dispatch(method: &str, data: &[u8]) -> Option> { + pangoro_runtime::api::dispatch(method, data) + } + + fn native_version() -> NativeVersion { + pangoro_runtime::native_version() + } +} diff --git a/node/src/service/mod.rs b/node/src/service/mod.rs index a53ca98f..3f1369aa 100644 --- a/node/src/service/mod.rs +++ b/node/src/service/mod.rs @@ -29,6 +29,8 @@ pub use crab_runtime::RuntimeApi as CrabRuntimeApi; pub use darwinia_runtime::RuntimeApi as DarwiniaRuntimeApi; #[cfg(feature = "pangolin-native")] pub use pangolin_runtime::RuntimeApi as PangolinRuntimeApi; +#[cfg(feature = "pangoro-native")] +pub use pangoro_runtime::RuntimeApi as PangoroRuntimeApi; // std use std::{ @@ -56,7 +58,7 @@ type ParachainBlockImport = FullBackend, >; -/// Can be called for a `Configuration` to check if it is a configuration for the `Crab` network. +/// Can be called for a `Configuration` to check if it is the specific network. pub trait IdentifyVariant { /// Returns if this is a configuration for the `Crab` network. fn is_crab(&self) -> bool; @@ -67,6 +69,9 @@ pub trait IdentifyVariant { /// Returns if this is a configuration for the `Pangolin` network. fn is_pangolin(&self) -> bool; + /// Returns if this is a configuration for the `Pangoro` network. + fn is_pangoro(&self) -> bool; + /// Returns true if this configuration is for a development network. fn is_dev(&self) -> bool; } @@ -83,6 +88,10 @@ impl IdentifyVariant for Box { self.id().starts_with("pangolin") } + fn is_pangoro(&self) -> bool { + self.id().starts_with("pangoro") + } + fn is_dev(&self) -> bool { self.id().ends_with("development") } diff --git a/runtime/common/Cargo.toml b/runtime/common/Cargo.toml index 5d6f5684..65a87985 100644 --- a/runtime/common/Cargo.toml +++ b/runtime/common/Cargo.toml @@ -28,7 +28,9 @@ xcm-executor = { workspace = true } # substrate frame-support = { workspace = true } frame-system = { workspace = true } +pallet-balances = { workspace = true } pallet-collective = { workspace = true } +pallet-treasury = { workspace = true } sp-io = { workspace = true } sp-runtime = { workspace = true } sp-std = { workspace = true } @@ -56,7 +58,9 @@ std = [ # substrate "frame-support/std", "frame-system/std", + "pallet-balances/std", "pallet-collective/std", + "pallet-treasury/std", "sp-io/std", "sp-runtime/std", "sp-std/std", diff --git a/runtime/common/src/lib.rs b/runtime/common/src/lib.rs index 8966a564..3952e196 100644 --- a/runtime/common/src/lib.rs +++ b/runtime/common/src/lib.rs @@ -79,6 +79,50 @@ impl WeightToFeePolynomial for WeightToFee { } } +pub struct DealWithFees(sp_std::marker::PhantomData); +impl frame_support::traits::OnUnbalanced> + for DealWithFees +where + R: pallet_balances::Config, + R: pallet_balances::Config + pallet_treasury::Config, + pallet_treasury::Pallet: + frame_support::traits::OnUnbalanced>, +{ + // this seems to be called for substrate-based transactions + fn on_unbalanceds( + mut fees_then_tips: impl Iterator>, + ) { + if let Some(fees) = fees_then_tips.next() { + // substrate + use frame_support::traits::Imbalance; + + // for fees, 80% are burned, 20% to the treasury + let (_, to_treasury) = fees.ration(80, 20); + + // Balances pallet automatically burns dropped Negative Imbalances by decreasing + // total_supply accordingly + as frame_support::traits::OnUnbalanced<_>>::on_unbalanced( + to_treasury, + ); + } + } + + // this is called from pallet_evm for Ethereum-based transactions + // (technically, it calls on_unbalanced, which calls this when non-zero) + fn on_nonzero_unbalanced(amount: pallet_balances::NegativeImbalance) { + // substrate + use frame_support::traits::Imbalance; + + // Balances pallet automatically burns dropped Negative Imbalances by decreasing + // total_supply accordingly + let (_, to_treasury) = amount.ration(80, 20); + + as frame_support::traits::OnUnbalanced<_>>::on_unbalanced( + to_treasury, + ); + } +} + /// Deposit calculator for Darwinia. /// 100 UNIT for the base fee, 102.4 UNIT/MB. pub const fn darwinia_deposit(items: u32, bytes: u32) -> Balance { diff --git a/runtime/crab/src/lib.rs b/runtime/crab/src/lib.rs index 2fbb4baa..93193bdd 100644 --- a/runtime/crab/src/lib.rs +++ b/runtime/crab/src/lib.rs @@ -16,7 +16,7 @@ // You should have received a copy of the GNU General Public License // along with Darwinia. If not, see . -//! Darwinia runtime. +//! Crab runtime. #![cfg_attr(not(feature = "std"), no_std)] #![recursion_limit = "256"] @@ -90,51 +90,6 @@ pub const VERSION: sp_version::RuntimeVersion = sp_version::RuntimeVersion { state_version: 0, }; -// TODO: move to impl.rs -pub struct DealWithFees(sp_std::marker::PhantomData); -impl frame_support::traits::OnUnbalanced> - for DealWithFees -where - R: pallet_balances::Config, - R: pallet_balances::Config + pallet_treasury::Config, - pallet_treasury::Pallet: - frame_support::traits::OnUnbalanced>, -{ - // this seems to be called for substrate-based transactions - fn on_unbalanceds( - mut fees_then_tips: impl Iterator>, - ) { - if let Some(fees) = fees_then_tips.next() { - // substrate - use frame_support::traits::Imbalance; - - // for fees, 80% are burned, 20% to the treasury - let (_, to_treasury) = fees.ration(80, 20); - - // Balances pallet automatically burns dropped Negative Imbalances by decreasing - // total_supply accordingly - as frame_support::traits::OnUnbalanced<_>>::on_unbalanced( - to_treasury, - ); - } - } - - // this is called from pallet_evm for Ethereum-based transactions - // (technically, it calls on_unbalanced, which calls this when non-zero) - fn on_nonzero_unbalanced(amount: pallet_balances::NegativeImbalance) { - // substrate - use frame_support::traits::Imbalance; - - // Balances pallet automatically burns dropped Negative Imbalances by decreasing - // total_supply accordingly - let (_, to_treasury) = amount.ration(80, 20); - - as frame_support::traits::OnUnbalanced<_>>::on_unbalanced( - to_treasury, - ); - } -} - /// The version information used to identify this runtime when compiled natively. #[cfg(feature = "std")] pub fn native_version() -> sp_version::NativeVersion { diff --git a/runtime/crab/src/pallets/deposit.rs b/runtime/crab/src/pallets/deposit.rs index 6cc968c5..a37e0be8 100644 --- a/runtime/crab/src/pallets/deposit.rs +++ b/runtime/crab/src/pallets/deposit.rs @@ -19,8 +19,8 @@ // darwinia use crate::*; -pub enum CKtonMinting {} -impl darwinia_deposit::SimpleAsset for CKtonMinting { +pub enum KtonMinting {} +impl darwinia_deposit::SimpleAsset for KtonMinting { type AccountId = AccountId; fn mint(beneficiary: &Self::AccountId, amount: Balance) -> sp_runtime::DispatchResult { @@ -44,7 +44,7 @@ impl darwinia_deposit::SimpleAsset for CKtonMinting { } impl darwinia_deposit::Config for Runtime { - type Kton = CKtonMinting; + type Kton = KtonMinting; type MaxDeposits = ConstU32<16>; type MinLockingAmount = ConstU128; type Ring = Balances; diff --git a/runtime/crab/src/pallets/evm.rs b/runtime/crab/src/pallets/evm.rs index 1265be05..cbdb9578 100644 --- a/runtime/crab/src/pallets/evm.rs +++ b/runtime/crab/src/pallets/evm.rs @@ -103,7 +103,8 @@ where addr(9), addr(1024), addr(1025), - addr(1026), // For KTON asset + // For KTON asset. + addr(1026), addr(1536), addr(1537), addr(2048), diff --git a/runtime/crab/src/pallets/staking.rs b/runtime/crab/src/pallets/staking.rs index 9464a453..2abda17e 100644 --- a/runtime/crab/src/pallets/staking.rs +++ b/runtime/crab/src/pallets/staking.rs @@ -21,8 +21,8 @@ use crate::*; fast_runtime_or_not!(MinStakingDuration, ConstU32<{ 5 * MINUTES }>, ConstU32<{ 14 * DAYS }>); -pub enum CrabStaking {} -impl darwinia_staking::Stake for CrabStaking { +pub enum RingStaking {} +impl darwinia_staking::Stake for RingStaking { type AccountId = AccountId; type Item = Balance; @@ -44,8 +44,8 @@ impl darwinia_staking::Stake for CrabStaking { ) } } -pub enum CKtonStaking {} -impl darwinia_staking::Stake for CKtonStaking { +pub enum KtonStaking {} +impl darwinia_staking::Stake for KtonStaking { type AccountId = AccountId; type Item = Balance; @@ -74,13 +74,13 @@ frame_support::parameter_types! { impl darwinia_staking::Config for Runtime { type Deposit = Deposit; - type Kton = CKtonStaking; + type Kton = KtonStaking; type MaxDeposits = ConstU32<16>; type MaxUnstakings = ConstU32<16>; type MinStakingDuration = MinStakingDuration; type PayoutFraction = PayoutFraction; type RewardRemainder = Treasury; - type Ring = CrabStaking; + type Ring = RingStaking; type RingCurrency = Balances; type RuntimeEvent = RuntimeEvent; type UnixTime = Timestamp; diff --git a/runtime/crab/src/pallets/system.rs b/runtime/crab/src/pallets/system.rs index 96faace6..74d82b74 100644 --- a/runtime/crab/src/pallets/system.rs +++ b/runtime/crab/src/pallets/system.rs @@ -101,7 +101,7 @@ impl frame_system::Config for Runtime { /// The ubiquitous origin type. type RuntimeOrigin = RuntimeOrigin; /// This is used as an identifier of the chain. 42 is the generic substrate prefix. - type SS58Prefix = ConstU16<18>; + type SS58Prefix = ConstU16<42>; /// Weight information for the extrinsics of this pallet. type SystemWeightInfo = weights::frame_system::WeightInfo; /// Runtime version. diff --git a/runtime/darwinia/src/lib.rs b/runtime/darwinia/src/lib.rs index 768f68af..761def08 100644 --- a/runtime/darwinia/src/lib.rs +++ b/runtime/darwinia/src/lib.rs @@ -90,51 +90,6 @@ pub const VERSION: sp_version::RuntimeVersion = sp_version::RuntimeVersion { state_version: 0, }; -// TODO: move to impl.rs -pub struct DealWithFees(sp_std::marker::PhantomData); -impl frame_support::traits::OnUnbalanced> - for DealWithFees -where - R: pallet_balances::Config, - R: pallet_balances::Config + pallet_treasury::Config, - pallet_treasury::Pallet: - frame_support::traits::OnUnbalanced>, -{ - // this seems to be called for substrate-based transactions - fn on_unbalanceds( - mut fees_then_tips: impl Iterator>, - ) { - if let Some(fees) = fees_then_tips.next() { - // substrate - use frame_support::traits::Imbalance; - - // for fees, 80% are burned, 20% to the treasury - let (_, to_treasury) = fees.ration(80, 20); - - // Balances pallet automatically burns dropped Negative Imbalances by decreasing - // total_supply accordingly - as frame_support::traits::OnUnbalanced<_>>::on_unbalanced( - to_treasury, - ); - } - } - - // this is called from pallet_evm for Ethereum-based transactions - // (technically, it calls on_unbalanced, which calls this when non-zero) - fn on_nonzero_unbalanced(amount: pallet_balances::NegativeImbalance) { - // substrate - use frame_support::traits::Imbalance; - - // Balances pallet automatically burns dropped Negative Imbalances by decreasing - // total_supply accordingly - let (_, to_treasury) = amount.ration(80, 20); - - as frame_support::traits::OnUnbalanced<_>>::on_unbalanced( - to_treasury, - ); - } -} - /// The version information used to identify this runtime when compiled natively. #[cfg(feature = "std")] pub fn native_version() -> sp_version::NativeVersion { diff --git a/runtime/darwinia/src/pallets/evm.rs b/runtime/darwinia/src/pallets/evm.rs index 1603052a..4a6d3f96 100644 --- a/runtime/darwinia/src/pallets/evm.rs +++ b/runtime/darwinia/src/pallets/evm.rs @@ -103,7 +103,8 @@ where addr(9), addr(1024), addr(1025), - addr(1026), // For KTON asset + // For KTON asset. + addr(1026), addr(1536), addr(1537), addr(2048), diff --git a/runtime/pangolin/Cargo.toml b/runtime/pangolin/Cargo.toml index 1d758828..c0983e38 100644 --- a/runtime/pangolin/Cargo.toml +++ b/runtime/pangolin/Cargo.toml @@ -45,7 +45,6 @@ darwinia-precompile-state-storage = { workspace = true } darwinia-staking = { workspace = true } dc-primitives = { workspace = true } - # darwinia-messages-substrate bp-message-dispatch = { workspace = true } bp-messages = { workspace = true } diff --git a/runtime/pangolin/src/lib.rs b/runtime/pangolin/src/lib.rs index f016f571..5b5f8e1c 100644 --- a/runtime/pangolin/src/lib.rs +++ b/runtime/pangolin/src/lib.rs @@ -16,7 +16,7 @@ // You should have received a copy of the GNU General Public License // along with Darwinia. If not, see . -//! Darwinia runtime. +//! Pangolin runtime. #![cfg_attr(not(feature = "std"), no_std)] #![recursion_limit = "256"] @@ -88,51 +88,6 @@ pub const VERSION: sp_version::RuntimeVersion = sp_version::RuntimeVersion { state_version: 0, }; -// TODO: move to impl.rs -pub struct DealWithFees(sp_std::marker::PhantomData); -impl frame_support::traits::OnUnbalanced> - for DealWithFees -where - R: pallet_balances::Config, - R: pallet_balances::Config + pallet_treasury::Config, - pallet_treasury::Pallet: - frame_support::traits::OnUnbalanced>, -{ - // this seems to be called for substrate-based transactions - fn on_unbalanceds( - mut fees_then_tips: impl Iterator>, - ) { - if let Some(fees) = fees_then_tips.next() { - // substrate - use frame_support::traits::Imbalance; - - // for fees, 80% are burned, 20% to the treasury - let (_, to_treasury) = fees.ration(80, 20); - - // Balances pallet automatically burns dropped Negative Imbalances by decreasing - // total_supply accordingly - as frame_support::traits::OnUnbalanced<_>>::on_unbalanced( - to_treasury, - ); - } - } - - // this is called from pallet_evm for Ethereum-based transactions - // (technically, it calls on_unbalanced, which calls this when non-zero) - fn on_nonzero_unbalanced(amount: pallet_balances::NegativeImbalance) { - // substrate - use frame_support::traits::Imbalance; - - // Balances pallet automatically burns dropped Negative Imbalances by decreasing - // total_supply accordingly - let (_, to_treasury) = amount.ration(80, 20); - - as frame_support::traits::OnUnbalanced<_>>::on_unbalanced( - to_treasury, - ); - } -} - /// The version information used to identify this runtime when compiled natively. #[cfg(feature = "std")] pub fn native_version() -> sp_version::NativeVersion { diff --git a/runtime/pangolin/src/migration.rs b/runtime/pangolin/src/migration.rs index c925ec80..f725e52b 100644 --- a/runtime/pangolin/src/migration.rs +++ b/runtime/pangolin/src/migration.rs @@ -1,4 +1,5 @@ // darwinia +#[allow(unused_imports)] use crate::*; pub struct CustomOnRuntimeUpgrade; diff --git a/runtime/pangolin/src/pallets/deposit.rs b/runtime/pangolin/src/pallets/deposit.rs index 66f606f6..9b60262f 100644 --- a/runtime/pangolin/src/pallets/deposit.rs +++ b/runtime/pangolin/src/pallets/deposit.rs @@ -19,8 +19,8 @@ // darwinia use crate::*; -pub enum PKtonMinting {} -impl darwinia_deposit::SimpleAsset for PKtonMinting { +pub enum KtonMinting {} +impl darwinia_deposit::SimpleAsset for KtonMinting { type AccountId = AccountId; fn mint(beneficiary: &Self::AccountId, amount: Balance) -> sp_runtime::DispatchResult { @@ -44,7 +44,7 @@ impl darwinia_deposit::SimpleAsset for PKtonMinting { } impl darwinia_deposit::Config for Runtime { - type Kton = PKtonMinting; + type Kton = KtonMinting; type MaxDeposits = ConstU32<16>; type MinLockingAmount = ConstU128; type Ring = Balances; diff --git a/runtime/pangolin/src/pallets/evm.rs b/runtime/pangolin/src/pallets/evm.rs index dd75c0bf..138e263b 100644 --- a/runtime/pangolin/src/pallets/evm.rs +++ b/runtime/pangolin/src/pallets/evm.rs @@ -103,7 +103,8 @@ where addr(9), addr(1024), addr(1025), - addr(1026), // For KTON asset + // For KTON asset. + addr(1026), addr(1536), addr(1537), addr(2048), diff --git a/runtime/pangolin/src/pallets/staking.rs b/runtime/pangolin/src/pallets/staking.rs index 79ea8fe7..0c76fe41 100644 --- a/runtime/pangolin/src/pallets/staking.rs +++ b/runtime/pangolin/src/pallets/staking.rs @@ -21,8 +21,8 @@ use crate::*; fast_runtime_or_not!(MinStakingDuration, ConstU32<{ 5 * MINUTES }>, ConstU32<{ 14 * DAYS }>); -pub enum PRingStaking {} -impl darwinia_staking::Stake for PRingStaking { +pub enum RingStaking {} +impl darwinia_staking::Stake for RingStaking { type AccountId = AccountId; type Item = Balance; @@ -44,8 +44,8 @@ impl darwinia_staking::Stake for PRingStaking { ) } } -pub enum PKtonStaking {} -impl darwinia_staking::Stake for PKtonStaking { +pub enum KtonStaking {} +impl darwinia_staking::Stake for KtonStaking { type AccountId = AccountId; type Item = Balance; @@ -74,13 +74,13 @@ frame_support::parameter_types! { impl darwinia_staking::Config for Runtime { type Deposit = Deposit; - type Kton = PKtonStaking; + type Kton = KtonStaking; type MaxDeposits = ConstU32<16>; type MaxUnstakings = ConstU32<16>; type MinStakingDuration = MinStakingDuration; type PayoutFraction = PayoutFraction; type RewardRemainder = Treasury; - type Ring = PRingStaking; + type Ring = RingStaking; type RingCurrency = Balances; type RuntimeEvent = RuntimeEvent; type UnixTime = Timestamp; diff --git a/runtime/pangolin/src/pallets/system.rs b/runtime/pangolin/src/pallets/system.rs index 96faace6..74d82b74 100644 --- a/runtime/pangolin/src/pallets/system.rs +++ b/runtime/pangolin/src/pallets/system.rs @@ -101,7 +101,7 @@ impl frame_system::Config for Runtime { /// The ubiquitous origin type. type RuntimeOrigin = RuntimeOrigin; /// This is used as an identifier of the chain. 42 is the generic substrate prefix. - type SS58Prefix = ConstU16<18>; + type SS58Prefix = ConstU16<42>; /// Weight information for the extrinsics of this pallet. type SystemWeightInfo = weights::frame_system::WeightInfo; /// Runtime version. diff --git a/runtime/pangoro/Cargo.toml b/runtime/pangoro/Cargo.toml new file mode 100644 index 00000000..d474ca30 --- /dev/null +++ b/runtime/pangoro/Cargo.toml @@ -0,0 +1,368 @@ +[package] +authors.workspace = true +description = "Pangoro runtime." +edition.workspace = true +name = "pangoro-runtime" +readme = "README.md" +version.workspace = true + +[build-dependencies] +substrate-wasm-builder = { workspace = true } + +[dependencies] +# crates.io +codec = { package = "parity-scale-codec", workspace = true } +scale-info = { workspace = true } +static_assertions = { workspace = true } +# crates.io optional +array-bytes = { optional = true, workspace = true } + +# cumulus +cumulus-pallet-aura-ext = { workspace = true } +cumulus-pallet-dmp-queue = { workspace = true } +cumulus-pallet-parachain-system = { workspace = true } +cumulus-pallet-xcm = { workspace = true } +cumulus-pallet-xcmp-queue = { workspace = true } +cumulus-primitives-core = { workspace = true } +cumulus-primitives-timestamp = { workspace = true } +cumulus-primitives-utility = { workspace = true } +parachain-info = { workspace = true } +# cumulus optional +cumulus-pallet-session-benchmarking = { optional = true, workspace = true } + +# darwinia +darwinia-account-migration = { workspace = true } +darwinia-common-runtime = { workspace = true } +darwinia-deposit = { workspace = true } +darwinia-ecdsa-authority = { workspace = true } +darwinia-message-gadget = { workspace = true } +darwinia-message-transact = { workspace = true } +darwinia-precompile-assets = { workspace = true } +darwinia-precompile-bls12-381 = { workspace = true } +darwinia-precompile-deposit = { workspace = true } +darwinia-precompile-staking = { workspace = true } +darwinia-precompile-state-storage = { workspace = true } +darwinia-staking = { workspace = true } +dc-primitives = { workspace = true } + +# darwinia-messages-substrate +bp-message-dispatch = { workspace = true } +bp-messages = { workspace = true } +bp-polkadot-core = { workspace = true } +bp-runtime = { workspace = true } +bridge-runtime-common = { workspace = true } +pallet-bridge-dispatch = { workspace = true } +pallet-bridge-grandpa = { workspace = true } +pallet-bridge-messages = { workspace = true } +pallet-bridge-parachains = { workspace = true } +pallet-fee-market = { workspace = true } + +# frontier +fp-rpc = { workspace = true } +fp-self-contained = { workspace = true } +pallet-ethereum = { features = ["forbid-evm-reentrancy"], workspace = true } +pallet-evm = { features = ["forbid-evm-reentrancy"], workspace = true } +pallet-evm-precompile-blake2 = { workspace = true } +pallet-evm-precompile-bn128 = { workspace = true } +pallet-evm-precompile-dispatch = { workspace = true } +pallet-evm-precompile-modexp = { workspace = true } +pallet-evm-precompile-simple = { workspace = true } + +# moonbeam +precompile-utils = { workspace = true } +xcm-primitives = { workspace = true } + +# polkadot +pallet-xcm = { workspace = true } +polkadot-parachain = { workspace = true } +polkadot-runtime-common = { workspace = true } +xcm = { workspace = true } +xcm-builder = { workspace = true } +xcm-executor = { workspace = true } + +# substrate +frame-executive = { workspace = true } +frame-support = { workspace = true } +frame-system = { workspace = true } +frame-system-rpc-runtime-api = { workspace = true } +pallet-assets = { workspace = true } +pallet-aura = { workspace = true } +pallet-authorship = { workspace = true } +pallet-balances = { workspace = true } +pallet-collective = { workspace = true } +pallet-democracy = { workspace = true } +pallet-elections-phragmen = { workspace = true } +pallet-identity = { workspace = true } +pallet-membership = { workspace = true } +pallet-multisig = { workspace = true } +pallet-preimage = { workspace = true } +pallet-proxy = { workspace = true } +pallet-scheduler = { workspace = true } +pallet-session = { workspace = true } +pallet-sudo = { workspace = true } +pallet-timestamp = { workspace = true } +pallet-tips = { workspace = true } +pallet-transaction-payment = { workspace = true } +pallet-transaction-payment-rpc-runtime-api = { workspace = true } +pallet-treasury = { workspace = true } +pallet-utility = { workspace = true } +pallet-vesting = { workspace = true } +sp-api = { workspace = true } +sp-block-builder = { workspace = true } +sp-consensus-aura = { workspace = true } +sp-core = { workspace = true } +sp-inherents = { workspace = true } +sp-io = { workspace = true } +sp-offchain = { workspace = true } +sp-runtime = { workspace = true } +sp-session = { workspace = true } +sp-std = { workspace = true } +sp-transaction-pool = { workspace = true } +sp-version = { workspace = true } +# substrate optional +frame-benchmarking = { optional = true, workspace = true } +frame-system-benchmarking = { optional = true, workspace = true } +frame-try-runtime = { optional = true, workspace = true } + +[dev-dependencies] +# darwinia +darwinia-common-runtime = { features = ["test"], workspace = true } +# substrate +sp-keyring = { workspace = true } + +[features] +default = ["std"] +std = [ + # crates.io + "codec/std", + "scale-info/std", + + # cumulus + "cumulus-pallet-aura-ext/std", + "cumulus-pallet-dmp-queue/std", + "cumulus-pallet-parachain-system/std", + "cumulus-pallet-xcm/std", + "cumulus-pallet-xcmp-queue/std", + "cumulus-primitives-core/std", + "cumulus-primitives-timestamp/std", + "cumulus-primitives-utility/std", + "parachain-info/std", + # cumulus optional + "cumulus-pallet-session-benchmarking?/std", + + # darwinia + "darwinia-account-migration/std", + "darwinia-common-runtime/std", + "darwinia-deposit/std", + "darwinia-ecdsa-authority/std", + "darwinia-message-gadget/std", + "darwinia-message-transact/std", + "darwinia-precompile-assets/std", + "darwinia-precompile-bls12-381/std", + "darwinia-precompile-deposit/std", + "darwinia-precompile-staking/std", + "darwinia-precompile-state-storage/std", + "darwinia-staking/std", + "dc-primitives/std", + + # darwinia-messages-substrate + "bp-message-dispatch/std", + "bp-messages/std", + "bp-runtime/std", + "bp-polkadot-core/std", + "bridge-runtime-common/std", + "pallet-bridge-dispatch/std", + "pallet-bridge-grandpa/std", + "pallet-bridge-messages/std", + "pallet-bridge-parachains/std", + "pallet-fee-market/std", + + # frontier + "fp-rpc/std", + "fp-self-contained/std", + "pallet-ethereum/std", + "pallet-evm/std", + "pallet-evm-precompile-blake2/std", + "pallet-evm-precompile-bn128/std", + "pallet-evm-precompile-dispatch/std", + "pallet-evm-precompile-modexp/std", + "pallet-evm-precompile-simple/std", + + # moonbeam + "precompile-utils/std", + "xcm-primitives/std", + + # polkadot + "pallet-xcm/std", + "polkadot-parachain/std", + "polkadot-runtime-common/std", + "xcm/std", + "xcm-builder/std", + "xcm-executor/std", + + # substrate + "frame-executive/std", + "frame-support/std", + "frame-system/std", + "frame-system-rpc-runtime-api/std", + "pallet-assets/std", + "pallet-aura/std", + "pallet-authorship/std", + "pallet-balances/std", + "pallet-collective/std", + "pallet-democracy/std", + "pallet-elections-phragmen/std", + "pallet-membership/std", + "pallet-identity/std", + "pallet-multisig/std", + "pallet-preimage/std", + "pallet-proxy/std", + "pallet-scheduler/std", + "pallet-session/std", + "pallet-sudo/std", + "pallet-timestamp/std", + "pallet-tips/std", + "pallet-transaction-payment-rpc-runtime-api/std", + "pallet-transaction-payment/std", + "pallet-treasury/std", + "pallet-utility/std", + "pallet-vesting/std", + "sp-api/std", + "sp-block-builder/std", + "sp-consensus-aura/std", + "sp-core/std", + "sp-inherents/std", + "sp-io/std", + "sp-offchain/std", + "sp-runtime/std", + "sp-session/std", + "sp-std/std", + "sp-transaction-pool/std", + "sp-version/std", + # substrate optional + "frame-benchmarking?/std", + "frame-system-benchmarking?/std", + "frame-try-runtime?/std", + +] + +runtime-benchmarks = [ + # crates.io + "array-bytes", + + # cumulus + "cumulus-pallet-parachain-system/runtime-benchmarks", + "cumulus-pallet-xcmp-queue/runtime-benchmarks", + # cumulus optional + "cumulus-pallet-session-benchmarking/runtime-benchmarks", + + # darwinia-messages-substrate + "bridge-runtime-common/runtime-benchmarks", + "pallet-bridge-grandpa/runtime-benchmarks", + "pallet-bridge-messages/runtime-benchmarks", + "pallet-bridge-parachains/runtime-benchmarks", + "pallet-fee-market/runtime-benchmarks", + + # frontier + "pallet-ethereum/runtime-benchmarks", + "pallet-evm/runtime-benchmarks", + + # moonbeam + "xcm-primitives/runtime-benchmarks", + + # polkadot + "pallet-xcm/runtime-benchmarks", + "polkadot-parachain/runtime-benchmarks", + "polkadot-runtime-common/runtime-benchmarks", + "xcm-builder/runtime-benchmarks", + "xcm-executor/runtime-benchmarks", + + # substrate + "frame-support/runtime-benchmarks", + "frame-system/runtime-benchmarks", + "pallet-assets/runtime-benchmarks", + "pallet-balances/runtime-benchmarks", + "pallet-collective/runtime-benchmarks", + "pallet-democracy/runtime-benchmarks", + "pallet-elections-phragmen/runtime-benchmarks", + "pallet-membership/runtime-benchmarks", + "pallet-identity/runtime-benchmarks", + "pallet-multisig/runtime-benchmarks", + "pallet-preimage/runtime-benchmarks", + "pallet-proxy/runtime-benchmarks", + "pallet-scheduler/runtime-benchmarks", + "pallet-timestamp/runtime-benchmarks", + "pallet-tips/runtime-benchmarks", + "pallet-treasury/runtime-benchmarks", + "pallet-utility/runtime-benchmarks", + "pallet-vesting/runtime-benchmarks", + "sp-runtime/runtime-benchmarks", + # substrate optional + "frame-benchmarking/runtime-benchmarks", + "frame-system-benchmarking/runtime-benchmarks", +] + +fast-runtime = [] + +try-runtime = [ + # cumulus + "cumulus-pallet-aura-ext/try-runtime", + "cumulus-pallet-dmp-queue/try-runtime", + "cumulus-pallet-parachain-system/try-runtime", + "cumulus-pallet-xcm/try-runtime", + "cumulus-pallet-xcmp-queue/try-runtime", + "parachain-info/try-runtime", + + # darwinia + "darwinia-account-migration/try-runtime", + "darwinia-deposit/try-runtime", + "darwinia-ecdsa-authority/try-runtime", + "darwinia-message-gadget/try-runtime", + "darwinia-message-transact/try-runtime", + "darwinia-staking/try-runtime", + + # darwinia-messages-substrate + "pallet-bridge-dispatch/try-runtime", + "pallet-bridge-grandpa/try-runtime", + "pallet-bridge-messages/try-runtime", + "pallet-bridge-parachains/try-runtime", + "pallet-fee-market/try-runtime", + + # frontier + "fp-self-contained/try-runtime", + "pallet-ethereum/try-runtime", + "pallet-evm/try-runtime", + + # polkadot + "pallet-xcm/try-runtime", + "polkadot-runtime-common/try-runtime", + + # substrate + "frame-executive/try-runtime", + "frame-support/try-runtime", + "frame-system/try-runtime", + "pallet-assets/try-runtime", + "pallet-aura/try-runtime", + "pallet-authorship/try-runtime", + "pallet-balances/try-runtime", + "pallet-collective/try-runtime", + "pallet-democracy/try-runtime", + "pallet-elections-phragmen/try-runtime", + "pallet-membership/try-runtime", + "pallet-identity/try-runtime", + "pallet-multisig/try-runtime", + "pallet-preimage/try-runtime", + "pallet-proxy/try-runtime", + "pallet-scheduler/try-runtime", + "pallet-session/try-runtime", + "pallet-sudo/try-runtime", + "pallet-timestamp/try-runtime", + "pallet-tips/try-runtime", + "pallet-transaction-payment/try-runtime", + "pallet-treasury/try-runtime", + "pallet-utility/try-runtime", + "pallet-vesting/try-runtime", + "sp-runtime/try-runtime", + # substrate optional + "frame-try-runtime/try-runtime", +] diff --git a/runtime/pangoro/build.rs b/runtime/pangoro/build.rs new file mode 100644 index 00000000..4a1101a9 --- /dev/null +++ b/runtime/pangoro/build.rs @@ -0,0 +1,24 @@ +// This file is part of Darwinia. +// +// Copyright (C) 2018-2023 Darwinia Network +// SPDX-License-Identifier: GPL-3.0 +// +// Darwinia 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. +// +// Darwinia 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 Darwinia. If not, see . + +// crates.io +use substrate_wasm_builder::WasmBuilder; + +fn main() { + WasmBuilder::new().with_current_project().export_heap_base().import_memory().build() +} diff --git a/runtime/pangoro/src/lib.rs b/runtime/pangoro/src/lib.rs new file mode 100644 index 00000000..e0169758 --- /dev/null +++ b/runtime/pangoro/src/lib.rs @@ -0,0 +1,597 @@ +// This file is part of Darwinia. +// +// Copyright (C) 2018-2023 Darwinia Network +// SPDX-License-Identifier: GPL-3.0 +// +// Darwinia 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. +// +// Darwinia 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 Darwinia. If not, see . + +//! Pangoro runtime. + +#![cfg_attr(not(feature = "std"), no_std)] +#![recursion_limit = "256"] + +#[cfg(feature = "std")] +include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs")); + +mod pallets; +pub use pallets::*; + +mod migration; +mod weights; + +pub use darwinia_common_runtime::*; +pub use dc_primitives::*; + +// substrate +use sp_std::prelude::*; + +/// Block type as expected by this runtime. +pub type Block = sp_runtime::generic::Block; + +/// A Block signed with a Justification +pub type SignedBlock = sp_runtime::generic::SignedBlock; + +/// The SignedExtension to the basic transaction logic. +pub type SignedExtra = ( + frame_system::CheckNonZeroSender, + frame_system::CheckSpecVersion, + frame_system::CheckTxVersion, + frame_system::CheckGenesis, + frame_system::CheckEra, + frame_system::CheckNonce, + frame_system::CheckWeight, + pallet_transaction_payment::ChargeTransactionPayment, +); + +/// Unchecked extrinsic type as expected by this runtime. +pub type UncheckedExtrinsic = + fp_self_contained::UncheckedExtrinsic; + +/// Extrinsic type that has already been checked. +pub type CheckedExtrinsic = + fp_self_contained::CheckedExtrinsic; + +/// Executive: handles dispatch to the various modules. +pub type Executive = frame_executive::Executive< + Runtime, + Block, + frame_system::ChainContext, + Runtime, + AllPalletsWithSystem, + migration::CustomOnRuntimeUpgrade, +>; + +/// Darwinia proposal base fee. +pub const DARWINIA_PROPOSAL_REQUIREMENT: Balance = 5000 * UNIT; + +/// Runtime version. +#[sp_version::runtime_version] +pub const VERSION: sp_version::RuntimeVersion = sp_version::RuntimeVersion { + spec_name: sp_runtime::create_runtime_str!("Pangoro2"), + impl_name: sp_runtime::create_runtime_str!("DarwiniaOfficialRust"), + authoring_version: 0, + spec_version: 6_0_0_2, + impl_version: 0, + apis: RUNTIME_API_VERSIONS, + transaction_version: 0, + state_version: 0, +}; + +/// The version information used to identify this runtime when compiled natively. +#[cfg(feature = "std")] +pub fn native_version() -> sp_version::NativeVersion { + sp_version::NativeVersion { runtime_version: VERSION, can_author_with: Default::default() } +} + +// Create the runtime by composing the FRAME pallets that were previously configured. +frame_support::construct_runtime! { + pub enum Runtime where + Block = Block, + NodeBlock = dc_primitives::Block, + UncheckedExtrinsic = UncheckedExtrinsic, + { + // System stuff. + System: frame_system = 0, + ParachainSystem: cumulus_pallet_parachain_system = 1, + Timestamp: pallet_timestamp = 2, + ParachainInfo: parachain_info = 3, + + // Monetary stuff. + // Leave 4 here. + // To keep balances consistent with the existing XCM configurations. + Balances: pallet_balances = 5, + TransactionPayment: pallet_transaction_payment = 6, + Assets: pallet_assets = 7, + Vesting: pallet_vesting = 8, + Deposit: darwinia_deposit = 9, + AccountMigration: darwinia_account_migration = 10, + + // Consensus stuff. + Authorship: pallet_authorship = 11, + DarwiniaStaking: darwinia_staking = 12, + Session: pallet_session = 13, + Aura: pallet_aura = 14, + AuraExt: cumulus_pallet_aura_ext = 15, + MessageGadget: darwinia_message_gadget = 16, + EcdsaAuthority: darwinia_ecdsa_authority = 17, + + // Governance stuff. + Democracy: pallet_democracy = 18, + Council: pallet_collective:: = 19, + TechnicalCommittee: pallet_collective:: = 20, + PhragmenElection: pallet_elections_phragmen = 21, + TechnicalMembership: pallet_membership:: = 22, + Treasury: pallet_treasury = 23, + Tips: pallet_tips = 24, + + // Utility stuff. + Sudo: pallet_sudo = 25, + Utility: pallet_utility = 26, + Identity: pallet_identity = 27, + Scheduler: pallet_scheduler = 28, + Preimage: pallet_preimage = 29, + Proxy: pallet_proxy = 30, + Multisig: pallet_multisig = 31, + + // XCM stuff. + XcmpQueue: cumulus_pallet_xcmp_queue = 32, + PolkadotXcm: pallet_xcm = 33, + CumulusXcm: cumulus_pallet_xcm = 34, + DmpQueue: cumulus_pallet_dmp_queue = 35, + + // EVM stuff. + Ethereum: pallet_ethereum = 36, + Evm: pallet_evm = 37, + MessageTransact: darwinia_message_transact = 38, + } +} + +#[cfg(feature = "runtime-benchmarks")] +frame_benchmarking::define_benchmarks! { + [frame_system, SystemBench::] + [pallet_balances, Balances] + [pallet_session, SessionBench::] + [pallet_timestamp, Timestamp] + [pallet_collator_selection, CollatorSelection] + [cumulus_pallet_xcmp_queue, XcmpQueue] +} + +impl_self_contained_call!(); + +sp_api::impl_runtime_apis! { + 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 { + Aura::authorities().into_inner() + } + } + + impl sp_api::Core for Runtime { + fn version() -> sp_version::RuntimeVersion { + VERSION + } + + fn execute_block(block: Block) { + Executive::execute_block(block) + } + + fn initialize_block(header: &::Header) { + Executive::initialize_block(header) + } + } + + impl sp_api::Metadata for Runtime { + fn metadata() -> sp_core::OpaqueMetadata { + sp_core::OpaqueMetadata::new(Runtime::metadata().into()) + } + } + + impl sp_block_builder::BlockBuilder for Runtime { + fn apply_extrinsic(extrinsic: ::Extrinsic) -> sp_runtime::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: sp_runtime::transaction_validity::TransactionSource, + tx: ::Extrinsic, + block_hash: ::Hash, + ) -> sp_runtime::transaction_validity::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_session::SessionKeys for Runtime { + fn generate_session_keys(seed: Option>) -> Vec { + SessionKeys::generate(seed) + } + + fn decode_session_keys( + encoded: Vec, + ) -> Option, sp_runtime::KeyTypeId)>> { + SessionKeys::decode_into_raw_public_keys(&encoded) + } + } + + impl frame_system_rpc_runtime_api::AccountNonceApi for Runtime { + fn account_nonce(account: AccountId) -> Nonce { + 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) + } + } + + 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) + } + } + + impl cumulus_primitives_core::CollectCollationInfo for Runtime { + fn collect_collation_info(header: &::Header) -> cumulus_primitives_core::CollationInfo { + ParachainSystem::collect_collation_info(header) + } + } + + impl fp_rpc::EthereumRuntimeRPCApi for Runtime { + fn chain_id() -> u64 { + <::ChainId as frame_support::traits::Get>::get() + } + + fn account_basic(address: sp_core::H160) -> pallet_evm::Account { + let (account, _) = Evm::account_basic(&address); + + account + } + + fn gas_price() -> sp_core::U256 { + // frontier + use pallet_evm::FeeCalculator; + + let (gas_price, _) = ::FeeCalculator::min_gas_price(); + + gas_price + } + + fn account_code_at(address: sp_core::H160) -> Vec { + Evm::account_codes(address) + } + + fn author() -> sp_core::H160 { + >::find_author() + } + + fn storage_at(address: sp_core::H160, index: sp_core::U256) -> sp_core::H256 { + let mut tmp = [0u8; 32]; + + index.to_big_endian(&mut tmp); + + Evm::account_storages(address, sp_core::H256::from_slice(&tmp[..])) + } + + fn call( + from: sp_core::H160, + to: sp_core::H160, + data: Vec, + value: sp_core::U256, + gas_limit: sp_core::U256, + max_fee_per_gas: Option, + max_priority_fee_per_gas: Option, + nonce: Option, + estimate: bool, + access_list: Option)>>, + ) -> Result { + // frontier + use pallet_evm::Runner; + // substrate + use sp_runtime::traits::UniqueSaturatedInto; + + let config = if estimate { + let mut config = ::config().clone(); + config.estimate = true; + Some(config) + } else { + None + }; + + let is_transactional = false; + let validate = true; + #[allow(clippy::or_fun_call)] + let evm_config = config.as_ref().unwrap_or(::config()); + ::Runner::call( + from, + to, + data, + value, + gas_limit.unique_saturated_into(), + max_fee_per_gas, + max_priority_fee_per_gas, + nonce, + access_list.unwrap_or_default(), + is_transactional, + validate, + evm_config, + ).map_err(|err| err.error.into()) + } + + fn create( + from: sp_core::H160, + data: Vec, + value: sp_core::U256, + gas_limit: sp_core::U256, + max_fee_per_gas: Option, + max_priority_fee_per_gas: Option, + nonce: Option, + estimate: bool, + access_list: Option)>>, + ) -> Result { + // frontier + use pallet_evm::Runner; + // substrate + use sp_runtime::traits::UniqueSaturatedInto; + + let config = if estimate { + let mut config = ::config().clone(); + config.estimate = true; + Some(config) + } else { + None + }; + + let is_transactional = false; + let validate = true; + #[allow(clippy::or_fun_call)] + let evm_config = config.as_ref().unwrap_or(::config()); + ::Runner::create( + from, + data, + value, + gas_limit.unique_saturated_into(), + max_fee_per_gas, + max_priority_fee_per_gas, + nonce, + access_list.unwrap_or_default(), + is_transactional, + validate, + evm_config, + ).map_err(|err| err.error.into()) + } + + fn current_transaction_statuses() -> Option> { + Ethereum::current_transaction_statuses() + } + + fn current_block() -> Option { + Ethereum::current_block() + } + + fn current_receipts() -> Option> { + Ethereum::current_receipts() + } + + fn current_all() -> ( + Option, + Option>, + Option> + ) { + ( + Ethereum::current_block(), + Ethereum::current_receipts(), + Ethereum::current_transaction_statuses() + ) + } + + 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 { + None + } + + fn gas_limit_multiplier_support() { + } + } + + impl fp_rpc::ConvertTransactionRuntimeApi for Runtime { + fn convert_transaction( + transaction: pallet_ethereum::Transaction + ) -> ::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, + ) { + // substrate + use frame_benchmarking::*; + use frame_support::traits::StorageInfoTrait; + use frame_system_benchmarking::Pallet as SystemBench; + use cumulus_pallet_session_benchmarking::Pallet as SessionBench; + + 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> { + // substrate + use frame_benchmarking::*; + + use frame_system_benchmarking::Pallet as SystemBench; + impl frame_system_benchmarking::Config for Runtime {} + + use cumulus_pallet_session_benchmarking::Pallet as SessionBench; + impl cumulus_pallet_session_benchmarking::Config for Runtime {} + + let whitelist: Vec = vec![ + // Block Number + array_bytes::hex_into_unchecked("26aa394eea5630e07c48ae0c9558cef702a5c1b19ab7a04f536c519aca4983ac"), + // Total Issuance + array_bytes::hex_into_unchecked("c2261276cc9d1f8598ea4b6a74b15c2f57c875e4cff74148e4628f264b974c80"), + // Execution Phase + array_bytes::hex_into_unchecked("26aa394eea5630e07c48ae0c9558cef7ff553b5a9862a516939d82b3d3d8661a"), + // Event Count + array_bytes::hex_into_unchecked("26aa394eea5630e07c48ae0c9558cef70a98fdbe9ce6c55837576c60c7af3850"), + // System Events + array_bytes::hex_into_unchecked("26aa394eea5630e07c48ae0c9558cef780d41e5e16056765bc8461851072c9d7"), + ]; + + let mut batches = Vec::::new(); + let params = (&config, &whitelist); + + add_benchmarks!(params, batches); + + if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) } + + Ok(batches) + } + } + + #[cfg(feature = "try-runtime")] + impl frame_try_runtime::TryRuntime for Runtime { + fn on_runtime_upgrade(checks: bool) -> (Weight, frame_support::weights::Weight) { + // substrate + use frame_support::log; + + log::info!("try-runtime::on_runtime_upgrade"); + + let weight = Executive::try_runtime_upgrade(checks).unwrap(); + + (weight, RuntimeBlockWeights::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).unwrap() + } + } +} + +struct CheckInherents; +impl cumulus_pallet_parachain_system::CheckInherents for CheckInherents { + fn check_inherents( + block: &Block, + relay_state_proof: &cumulus_pallet_parachain_system::RelayChainStateProof, + ) -> sp_inherents::CheckInherentsResult { + let relay_chain_slot = relay_state_proof + .read_slot() + .expect("Could not read the relay chain slot from the proof"); + + let inherent_data = + cumulus_primitives_timestamp::InherentDataProvider::from_relay_chain_slot_and_duration( + relay_chain_slot, + sp_std::time::Duration::from_secs(6), + ) + .create_inherent_data() + .expect("Could not create the timestamp inherent data"); + + inherent_data.check_extrinsics(block) + } +} +cumulus_pallet_parachain_system::register_validate_block! { + Runtime = Runtime, + BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor::, + CheckInherents = CheckInherents, +} + +#[cfg(test)] +mod tests { + // darwinia + use super::*; + + #[test] + fn configured_base_extrinsic_weight_is_evm_compatible() { + let min_ethereum_transaction_weight = WeightPerGas::get() * 21_000; + let base_extrinsic = ::BlockWeights::get() + .get(frame_support::dispatch::DispatchClass::Normal) + .base_extrinsic; + + assert!(base_extrinsic.ref_time() <= min_ethereum_transaction_weight.ref_time()); + } +} diff --git a/runtime/pangoro/src/migration.rs b/runtime/pangoro/src/migration.rs new file mode 100644 index 00000000..f453df01 --- /dev/null +++ b/runtime/pangoro/src/migration.rs @@ -0,0 +1,43 @@ +// This file is part of Darwinia. +// +// Copyright (C) 2018-2023 Darwinia Network +// SPDX-License-Identifier: GPL-3.0 +// +// Darwinia 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. +// +// Darwinia 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 Darwinia. If not, see . + +// darwinia +#[allow(unused_imports)] +use crate::*; + +pub struct CustomOnRuntimeUpgrade; +impl frame_support::traits::OnRuntimeUpgrade for CustomOnRuntimeUpgrade { + #[cfg(feature = "try-runtime")] + fn pre_upgrade() -> Result<(), &'static str> { + Ok(()) + } + + #[cfg(feature = "try-runtime")] + fn post_upgrade(_state: Vec) -> Result<(), &'static str> { + Ok(()) + } + + fn on_runtime_upgrade() -> frame_support::weights::Weight { + migrate() + } +} + +fn migrate() -> frame_support::weights::Weight { + frame_support::weights::Weight::zero() + // RuntimeBlockWeights::get().max_block +} diff --git a/runtime/pangoro/src/pallets/account_migration.rs b/runtime/pangoro/src/pallets/account_migration.rs new file mode 100644 index 00000000..5e230b46 --- /dev/null +++ b/runtime/pangoro/src/pallets/account_migration.rs @@ -0,0 +1,24 @@ +// This file is part of Darwinia. +// +// Copyright (C) 2018-2023 Darwinia Network +// SPDX-License-Identifier: GPL-3.0 +// +// Darwinia 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. +// +// Darwinia 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 Darwinia. If not, see . + +// darwinia +use crate::*; + +impl darwinia_account_migration::Config for Runtime { + type RuntimeEvent = RuntimeEvent; +} diff --git a/runtime/pangoro/src/pallets/assets.rs b/runtime/pangoro/src/pallets/assets.rs new file mode 100644 index 00000000..9dc10c67 --- /dev/null +++ b/runtime/pangoro/src/pallets/assets.rs @@ -0,0 +1,53 @@ +// This file is part of Darwinia. +// +// Copyright (C) 2018-2023 Darwinia Network +// SPDX-License-Identifier: GPL-3.0 +// +// Darwinia 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. +// +// Darwinia 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 Darwinia. If not, see . + +// darwinia +use crate::*; + +/// List of the assets existed in this runtime. +pub enum AssetIds { + OKton = 1026, +} + +frame_support::parameter_types! { + pub Creators: Vec = vec![ROOT]; +} + +impl pallet_assets::Config for Runtime { + type ApprovalDeposit = ConstU128<0>; + type AssetAccountDeposit = ConstU128<0>; + type AssetDeposit = ConstU128<0>; + type AssetId = AssetId; + type AssetIdParameter = codec::Compact; + type Balance = Balance; + #[cfg(feature = "runtime-benchmarks")] + type BenchmarkHelper = (); + type CreateOrigin = frame_support::traits::AsEnsureOriginWithArg< + frame_system::EnsureSignedBy, AccountId>, + >; + type Currency = Balances; + type Extra = (); + type ForceOrigin = frame_system::EnsureRoot; + type Freezer = (); + type MetadataDepositBase = ConstU128<0>; + type MetadataDepositPerByte = ConstU128<0>; + type RemoveItemsLimit = ConstU32<1000>; + type RuntimeEvent = RuntimeEvent; + type StringLimit = ConstU32<50>; + type WeightInfo = (); +} diff --git a/runtime/pangoro/src/pallets/aura.rs b/runtime/pangoro/src/pallets/aura.rs new file mode 100644 index 00000000..1da13450 --- /dev/null +++ b/runtime/pangoro/src/pallets/aura.rs @@ -0,0 +1,26 @@ +// This file is part of Darwinia. +// +// Copyright (C) 2018-2023 Darwinia Network +// SPDX-License-Identifier: GPL-3.0 +// +// Darwinia 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. +// +// Darwinia 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 Darwinia. If not, see . + +// darwinia +use crate::*; + +impl pallet_aura::Config for Runtime { + type AuthorityId = sp_consensus_aura::sr25519::AuthorityId; + type DisabledValidators = (); + type MaxAuthorities = ConstU32<100_000>; +} diff --git a/runtime/pangoro/src/pallets/aura_ext.rs b/runtime/pangoro/src/pallets/aura_ext.rs new file mode 100644 index 00000000..d36000a5 --- /dev/null +++ b/runtime/pangoro/src/pallets/aura_ext.rs @@ -0,0 +1,22 @@ +// This file is part of Darwinia. +// +// Copyright (C) 2018-2023 Darwinia Network +// SPDX-License-Identifier: GPL-3.0 +// +// Darwinia 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. +// +// Darwinia 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 Darwinia. If not, see . + +// darwinia +use crate::*; + +impl cumulus_pallet_aura_ext::Config for Runtime {} diff --git a/runtime/pangoro/src/pallets/authorship.rs b/runtime/pangoro/src/pallets/authorship.rs new file mode 100644 index 00000000..5b5f8109 --- /dev/null +++ b/runtime/pangoro/src/pallets/authorship.rs @@ -0,0 +1,27 @@ +// This file is part of Darwinia. +// +// Copyright (C) 2018-2023 Darwinia Network +// SPDX-License-Identifier: GPL-3.0 +// +// Darwinia 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. +// +// Darwinia 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 Darwinia. If not, see . + +// darwinia +use crate::*; + +impl pallet_authorship::Config for Runtime { + type EventHandler = (DarwiniaStaking,); + type FilterUncle = (); + type FindAuthor = pallet_session::FindAccountFromAuthorIndex; + type UncleGenerations = ConstU32<0>; +} diff --git a/runtime/pangoro/src/pallets/balances.rs b/runtime/pangoro/src/pallets/balances.rs new file mode 100644 index 00000000..94a42eac --- /dev/null +++ b/runtime/pangoro/src/pallets/balances.rs @@ -0,0 +1,32 @@ +// This file is part of Darwinia. +// +// Copyright (C) 2018-2023 Darwinia Network +// SPDX-License-Identifier: GPL-3.0 +// +// Darwinia 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. +// +// Darwinia 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 Darwinia. If not, see . + +// darwinia +use crate::*; + +impl pallet_balances::Config for Runtime { + type AccountStore = System; + type Balance = Balance; + type DustRemoval = (); + type ExistentialDeposit = ConstU128<0>; + type MaxLocks = ConstU32<50>; + type MaxReserves = ConstU32<50>; + type ReserveIdentifier = [u8; 8]; + type RuntimeEvent = RuntimeEvent; + type WeightInfo = weights::pallet_balances::WeightInfo; +} diff --git a/runtime/pangoro/src/pallets/collective.rs b/runtime/pangoro/src/pallets/collective.rs new file mode 100644 index 00000000..7dfbc262 --- /dev/null +++ b/runtime/pangoro/src/pallets/collective.rs @@ -0,0 +1,50 @@ +// This file is part of Darwinia. +// +// Copyright (C) 2018-2023 Darwinia Network +// SPDX-License-Identifier: GPL-3.0 +// +// Darwinia 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. +// +// Darwinia 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 Darwinia. If not, see . + +pub use pallet_collective::{Instance1 as CouncilCollective, Instance2 as TechnicalCollective}; + +// darwinia +use crate::*; + +pub const COLLECTIVE_DESIRED_MEMBERS: u32 = 7; +pub const COLLECTIVE_MAX_MEMBERS: u32 = 100; +pub const COLLECTIVE_MAX_PROPOSALS: u32 = 100; + +// Make sure that there are no more than `COLLECTIVE_MAX_MEMBERS` members elected via phragmen. +static_assertions::const_assert!(COLLECTIVE_DESIRED_MEMBERS <= COLLECTIVE_MAX_MEMBERS); + +impl pallet_collective::Config for Runtime { + type DefaultVote = pallet_collective::PrimeDefaultVote; + type MaxMembers = ConstU32; + type MaxProposals = ConstU32<100>; + type MotionDuration = ConstU32<{ 3 * DAYS }>; + type Proposal = RuntimeCall; + type RuntimeEvent = RuntimeEvent; + type RuntimeOrigin = RuntimeOrigin; + type WeightInfo = (); +} +impl pallet_collective::Config for Runtime { + type DefaultVote = pallet_collective::PrimeDefaultVote; + type MaxMembers = ConstU32; + type MaxProposals = ConstU32<100>; + type MotionDuration = ConstU32<{ 3 * DAYS }>; + type Proposal = RuntimeCall; + type RuntimeEvent = RuntimeEvent; + type RuntimeOrigin = RuntimeOrigin; + type WeightInfo = (); +} diff --git a/runtime/pangoro/src/pallets/democracy.rs b/runtime/pangoro/src/pallets/democracy.rs new file mode 100644 index 00000000..e28b4f39 --- /dev/null +++ b/runtime/pangoro/src/pallets/democracy.rs @@ -0,0 +1,64 @@ +// This file is part of Darwinia. +// +// Copyright (C) 2018-2023 Darwinia Network +// SPDX-License-Identifier: GPL-3.0 +// +// Darwinia 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. +// +// Darwinia 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 Darwinia. If not, see . + +// darwinia +use crate::*; + +const ENACTMENT_PERIOD: u32 = 28 * DAYS; + +impl pallet_democracy::Config for Runtime { + type BlacklistOrigin = Root; + // To cancel a proposal before it has been passed, the technical committee must be unanimous or + // Root must agree. + type CancelProposalOrigin = RootOrAll; + // To cancel a proposal which has been passed, 2/3 of the council must agree to it. + type CancellationOrigin = RootOrAtLeastTwoThird; + type CooloffPeriod = ConstU32<{ 7 * DAYS }>; + type Currency = Balances; + type EnactmentPeriod = ConstU32; + /// A unanimous council can have the next scheduled referendum be a straight default-carries + /// (NTB) vote. + type ExternalDefaultOrigin = RootOrAll; + /// A majority can have the next scheduled referendum be a straight majority-carries vote. + type ExternalMajorityOrigin = RootOrAtLeastHalf; + /// A straight majority of the council can decide what their next motion is. + type ExternalOrigin = RootOrAtLeastHalf; + /// Two thirds of the technical committee can have an ExternalMajority/ExternalDefault vote + /// be tabled immediately and with a shorter voting/enactment period. + type FastTrackOrigin = RootOrAtLeastTwoThird; + type FastTrackVotingPeriod = ConstU32<{ 3 * HOURS }>; + type InstantAllowed = ConstBool; + type InstantOrigin = RootOrAll; + type LaunchPeriod = ConstU32<{ 28 * DAYS }>; + type MaxBlacklisted = ConstU32<100>; + type MaxDeposits = ConstU32<100>; + type MaxProposals = ConstU32<100>; + type MaxVotes = ConstU32<100>; + type MinimumDeposit = ConstU128; + type PalletsOrigin = OriginCaller; + type Preimages = Preimage; + type RuntimeEvent = RuntimeEvent; + type Scheduler = Scheduler; + type Slash = Treasury; + // Any single technical committee member may veto a coming council proposal, however they can + // only do it once and it lasts only for the cool-off period. + type VetoOrigin = pallet_collective::EnsureMember; + type VoteLockingPeriod = ConstU32; + type VotingPeriod = ConstU32<{ 28 * DAYS }>; + type WeightInfo = (); +} diff --git a/runtime/pangoro/src/pallets/deposit.rs b/runtime/pangoro/src/pallets/deposit.rs new file mode 100644 index 00000000..f20d43b5 --- /dev/null +++ b/runtime/pangoro/src/pallets/deposit.rs @@ -0,0 +1,53 @@ +// This file is part of Darwinia. +// +// Copyright (C) 2018-2023 Darwinia Network +// SPDX-License-Identifier: GPL-3.0 +// +// Darwinia 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. +// +// Darwinia 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 Darwinia. If not, see . + +// darwinia +use crate::*; + +pub enum KtonMinting {} +impl darwinia_deposit::SimpleAsset for KtonMinting { + type AccountId = AccountId; + + fn mint(beneficiary: &Self::AccountId, amount: Balance) -> sp_runtime::DispatchResult { + Assets::mint( + RuntimeOrigin::signed(ROOT), + (AssetIds::OKton as AssetId).into(), + *beneficiary, + amount, + ) + } + + fn burn(who: &Self::AccountId, amount: Balance) -> sp_runtime::DispatchResult { + let asset_id = AssetIds::OKton as _; + + if Assets::balance(asset_id, who) < amount { + Err(>::BalanceLow)?; + } + + Assets::burn(RuntimeOrigin::signed(ROOT), asset_id.into(), *who, amount) + } +} + +impl darwinia_deposit::Config for Runtime { + type Kton = KtonMinting; + type MaxDeposits = ConstU32<16>; + type MinLockingAmount = ConstU128; + type Ring = Balances; + type RuntimeEvent = RuntimeEvent; + type UnixTime = Timestamp; +} diff --git a/runtime/pangoro/src/pallets/dmp_queue.rs b/runtime/pangoro/src/pallets/dmp_queue.rs new file mode 100644 index 00000000..17313c1b --- /dev/null +++ b/runtime/pangoro/src/pallets/dmp_queue.rs @@ -0,0 +1,26 @@ +// This file is part of Darwinia. +// +// Copyright (C) 2018-2023 Darwinia Network +// SPDX-License-Identifier: GPL-3.0 +// +// Darwinia 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. +// +// Darwinia 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 Darwinia. If not, see . + +// darwinia +use crate::*; + +impl cumulus_pallet_dmp_queue::Config for Runtime { + type ExecuteOverweightOrigin = frame_system::EnsureRoot; + type RuntimeEvent = RuntimeEvent; + type XcmExecutor = xcm_executor::XcmExecutor; +} diff --git a/runtime/pangoro/src/pallets/ecdsa_authority.rs b/runtime/pangoro/src/pallets/ecdsa_authority.rs new file mode 100644 index 00000000..05fc7dfc --- /dev/null +++ b/runtime/pangoro/src/pallets/ecdsa_authority.rs @@ -0,0 +1,39 @@ +// This file is part of Darwinia. +// +// Copyright (C) 2018-2023 Darwinia Network +// SPDX-License-Identifier: GPL-3.0 +// +// Darwinia 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. +// +// Darwinia 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 Darwinia. If not, see . + +// darwinia +use crate::*; + +const MAX_PENDING_PERIOD: BlockNumber = 100; +const SYNC_INTERVAL: BlockNumber = 10; + +frame_support::parameter_types! { + pub const SignThreshold: sp_runtime::Perbill = sp_runtime::Perbill::from_percent(60); +} +static_assertions::const_assert!(MAX_PENDING_PERIOD > SYNC_INTERVAL); + +impl darwinia_ecdsa_authority::Config for Runtime { + type ChainId = ::ChainId; + type MaxAuthorities = ConstU32<3>; + type MaxPendingPeriod = ConstU32; + type MessageRoot = darwinia_message_gadget::MessageRootGetter; + type RuntimeEvent = RuntimeEvent; + type SignThreshold = SignThreshold; + type SyncInterval = ConstU32; + type WeightInfo = (); +} diff --git a/runtime/pangoro/src/pallets/elections_phragmen.rs b/runtime/pangoro/src/pallets/elections_phragmen.rs new file mode 100644 index 00000000..133b8905 --- /dev/null +++ b/runtime/pangoro/src/pallets/elections_phragmen.rs @@ -0,0 +1,49 @@ +// This file is part of Darwinia. +// +// Copyright (C) 2018-2023 Darwinia Network +// SPDX-License-Identifier: GPL-3.0 +// +// Darwinia 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. +// +// Darwinia 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 Darwinia. If not, see . + +// darwinia +use crate::*; + +const MAX_CANDIDATES: u32 = 30; + +frame_support::parameter_types! { + pub const PhragmenElectionPalletId: frame_support::traits::LockIdentifier = *b"phrelect"; +} + +impl pallet_elections_phragmen::Config for Runtime { + type CandidacyBond = ConstU128<{ 100 * MILLIUNIT }>; + type ChangeMembers = Council; + type Currency = Balances; + type CurrencyToVote = frame_support::traits::U128CurrencyToVote; + type DesiredMembers = ConstU32; + type DesiredRunnersUp = ConstU32<7>; + type InitializeMembers = Council; + type KickedMember = Treasury; + type LoserCandidate = Treasury; + type MaxCandidates = ConstU32; + type MaxVoters = ConstU32<{ 10 * MAX_CANDIDATES }>; + type PalletId = PhragmenElectionPalletId; + type RuntimeEvent = RuntimeEvent; + // Daily council elections. + type TermDuration = ConstU32<{ 7 * DAYS }>; + // 1 storage item created, key size is 32 bytes, value size is 16+16. + type VotingBondBase = ConstU128<{ darwinia_deposit(1, 64) }>; + // Additional data per vote is 32 bytes (account id). + type VotingBondFactor = ConstU128<{ darwinia_deposit(0, 32) }>; + type WeightInfo = (); +} diff --git a/runtime/pangoro/src/pallets/ethereum.rs b/runtime/pangoro/src/pallets/ethereum.rs new file mode 100644 index 00000000..8d53d127 --- /dev/null +++ b/runtime/pangoro/src/pallets/ethereum.rs @@ -0,0 +1,25 @@ +// This file is part of Darwinia. +// +// Copyright (C) 2018-2023 Darwinia Network +// SPDX-License-Identifier: GPL-3.0 +// +// Darwinia 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. +// +// Darwinia 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 Darwinia. If not, see . + +// darwinia +use crate::*; + +impl pallet_ethereum::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type StateRoot = pallet_ethereum::IntermediateStateRoot; +} diff --git a/runtime/pangoro/src/pallets/evm.rs b/runtime/pangoro/src/pallets/evm.rs new file mode 100644 index 00000000..8c8c6845 --- /dev/null +++ b/runtime/pangoro/src/pallets/evm.rs @@ -0,0 +1,194 @@ +// This file is part of Darwinia. +// +// Copyright (C) 2018-2023 Darwinia Network +// SPDX-License-Identifier: GPL-3.0 +// +// Darwinia 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. +// +// Darwinia 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 Darwinia. If not, see . + +// darwinia +use crate::*; +// frontier +use pallet_evm::Precompile; + +const WEIGHT_PER_GAS: u64 = 40_000; + +frame_support::parameter_types! { + pub BlockGasLimit: sp_core::U256 = sp_core::U256::from(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT.ref_time() / WEIGHT_PER_GAS); + pub PrecompilesValue: PangoroPrecompiles = PangoroPrecompiles::<_>::new(); + pub WeightPerGas: frame_support::weights::Weight = frame_support::weights::Weight::from_ref_time(WEIGHT_PER_GAS); +} + +pub struct FindAuthorTruncated(sp_std::marker::PhantomData); +impl> frame_support::traits::FindAuthor + for FindAuthorTruncated +{ + fn find_author<'a, I>(digests: I) -> Option + where + I: 'a + IntoIterator, + { + // substrate + use sp_core::crypto::ByteArray; + + F::find_author(digests).and_then(|i| { + Aura::authorities().get(i as usize).and_then(|id| { + let raw = id.to_raw_vec(); + + if raw.len() >= 24 { + Some(sp_core::H160::from_slice(&raw[4..24])) + } else { + None + } + }) + }) + } +} + +pub struct FixedGasPrice; +impl pallet_evm::FeeCalculator for FixedGasPrice { + fn min_gas_price() -> (sp_core::U256, frame_support::weights::Weight) { + (sp_core::U256::from(GWEI), frame_support::weights::Weight::zero()) + } +} + +// TODO: Integrate to the upstream repo +pub struct FromH160; +impl pallet_evm::AddressMapping for FromH160 +where + T: From, +{ + fn into_account_id(address: sp_core::H160) -> T { + address.into() + } +} + +pub struct AssetIdConverter; +impl darwinia_precompile_assets::AccountToAssetId for AssetIdConverter { + fn account_to_asset_id(account_id: AccountId) -> AssetId { + let addr: sp_core::H160 = account_id.into(); + addr.to_low_u64_be() + } +} + +pub struct PangoroPrecompiles(sp_std::marker::PhantomData); +impl PangoroPrecompiles +where + R: pallet_evm::Config, +{ + #[allow(clippy::new_without_default)] + pub fn new() -> Self { + Self(Default::default()) + } + + pub fn used_addresses() -> [sp_core::H160; 15] { + [ + addr(1), + addr(2), + addr(3), + addr(4), + addr(5), + addr(6), + addr(7), + addr(8), + addr(9), + addr(1024), + addr(1025), + // For KTON asset. + addr(1026), + addr(1536), + addr(1537), + addr(2048), + ] + } +} +impl pallet_evm::PrecompileSet for PangoroPrecompiles +where + R: pallet_evm::Config, +{ + fn execute( + &self, + handle: &mut impl pallet_evm::PrecompileHandle, + ) -> Option { + // darwinia + use darwinia_precompile_assets::AccountToAssetId; + + let (code_addr, context_addr) = (handle.code_address(), handle.context().address); + // Filter known precompile addresses except Ethereum officials + if self.is_precompile(code_addr) && code_addr > addr(9) && code_addr != context_addr { + return Some(Err(precompile_utils::revert( + "cannot be called with DELEGATECALL or CALLCODE", + ))); + }; + + match code_addr { + // Ethereum precompiles: + a if a == addr(1) => Some(pallet_evm_precompile_simple::ECRecover::execute(handle)), + a if a == addr(2) => Some(pallet_evm_precompile_simple::Sha256::execute(handle)), + a if a == addr(3) => Some(pallet_evm_precompile_simple::Ripemd160::execute(handle)), + a if a == addr(4) => Some(pallet_evm_precompile_simple::Identity::execute(handle)), + a if a == addr(5) => Some(pallet_evm_precompile_modexp::Modexp::execute(handle)), + a if a == addr(6) => Some(pallet_evm_precompile_bn128::Bn128Add::execute(handle)), + a if a == addr(7) => Some(pallet_evm_precompile_bn128::Bn128Mul::execute(handle)), + a if a == addr(8) => Some(pallet_evm_precompile_bn128::Bn128Pairing::execute(handle)), + a if a == addr(9) => Some(pallet_evm_precompile_blake2::Blake2F::execute(handle)), + // Darwinia precompiles: [1024, 2048) for stable precompiles. + a if a == addr(1024) => Some(>::execute(handle)), + a if a == addr(1025) => + Some(>::execute(handle)), + // [1026, 1536) reserved for assets precompiles. + a if (1026..1536).contains(&AssetIdConverter::account_to_asset_id(a.into())) => + Some(>::execute( + handle, + )), + // [1536, 2048) reserved for other stable precompiles. + a if a == addr(1536) => + Some(>::execute(handle)), + a if a == addr(1537) => + Some(>::execute(handle)), + // [2048..) reserved for the experimental precompiles. + a if a == addr(2048) => + Some(>::execute(handle)), + _ => None, + } + } + + fn is_precompile(&self, address: sp_core::H160) -> bool { + Self::used_addresses().contains(&address) + } +} + +impl pallet_evm::Config for Runtime { + type AddressMapping = FromH160; + type BlockGasLimit = BlockGasLimit; + type BlockHashMapping = pallet_ethereum::EthereumBlockHashMapping; + type CallOrigin = pallet_evm::EnsureAddressRoot; + type ChainId = ConstU64<45>; + type Currency = Balances; + type FeeCalculator = FixedGasPrice; + type FindAuthor = FindAuthorTruncated; + type GasWeightMapping = pallet_evm::FixedGasWeightMapping; + type OnChargeTransaction = (); + type PrecompilesType = PangoroPrecompiles; + type PrecompilesValue = PrecompilesValue; + type Runner = pallet_evm::runner::stack::Runner; + type RuntimeEvent = RuntimeEvent; + type WeightPerGas = WeightPerGas; + type WithdrawOrigin = pallet_evm::EnsureAddressNever; +} + +fn addr(a: u64) -> sp_core::H160 { + sp_core::H160::from_low_u64_be(a) +} diff --git a/runtime/pangoro/src/pallets/identity.rs b/runtime/pangoro/src/pallets/identity.rs new file mode 100644 index 00000000..b12f0b3a --- /dev/null +++ b/runtime/pangoro/src/pallets/identity.rs @@ -0,0 +1,39 @@ +// This file is part of Darwinia. +// +// Copyright (C) 2018-2023 Darwinia Network +// SPDX-License-Identifier: GPL-3.0 +// +// Darwinia 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. +// +// Darwinia 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 Darwinia. If not, see . + +// darwinia +use crate::*; + +impl pallet_identity::Config for Runtime { + // Minimum 100 bytes/UNIT deposited (1 MILLIUNIT/byte). + // 258 bytes on-chain. + type BasicDeposit = ConstU128<{ darwinia_deposit(1, 258) }>; + type Currency = Balances; + // 66 bytes on-chain. + type FieldDeposit = ConstU128<{ darwinia_deposit(0, 66) }>; + type ForceOrigin = RootOrMoreThanHalf; + type MaxAdditionalFields = ConstU32<100>; + type MaxRegistrars = ConstU32<20>; + type MaxSubAccounts = ConstU32<100>; + type RegistrarOrigin = RootOrMoreThanHalf; + type RuntimeEvent = RuntimeEvent; + type Slashed = Treasury; + // 53 bytes on-chain. + type SubAccountDeposit = ConstU128<{ darwinia_deposit(1, 53) }>; + type WeightInfo = (); +} diff --git a/runtime/pangoro/src/pallets/membership.rs b/runtime/pangoro/src/pallets/membership.rs new file mode 100644 index 00000000..3064d4b5 --- /dev/null +++ b/runtime/pangoro/src/pallets/membership.rs @@ -0,0 +1,33 @@ +// This file is part of Darwinia. +// +// Copyright (C) 2018-2023 Darwinia Network +// SPDX-License-Identifier: GPL-3.0 +// +// Darwinia 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. +// +// Darwinia 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 Darwinia. If not, see . + +// darwinia +use crate::*; + +impl pallet_membership::Config for Runtime { + type AddOrigin = RootOrMoreThanHalf; + type MaxMembers = ConstU32; + type MembershipChanged = TechnicalCommittee; + type MembershipInitialized = TechnicalCommittee; + type PrimeOrigin = RootOrMoreThanHalf; + type RemoveOrigin = RootOrMoreThanHalf; + type ResetOrigin = RootOrMoreThanHalf; + type RuntimeEvent = RuntimeEvent; + type SwapOrigin = RootOrMoreThanHalf; + type WeightInfo = (); +} diff --git a/runtime/pangoro/src/pallets/message_gadget.rs b/runtime/pangoro/src/pallets/message_gadget.rs new file mode 100644 index 00000000..25cf8aee --- /dev/null +++ b/runtime/pangoro/src/pallets/message_gadget.rs @@ -0,0 +1,22 @@ +// This file is part of Darwinia. +// +// Copyright (C) 2018-2023 Darwinia Network +// SPDX-License-Identifier: GPL-3.0 +// +// Darwinia 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. +// +// Darwinia 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 Darwinia. If not, see . + +// darwinia +use crate::*; + +impl darwinia_message_gadget::Config for Runtime {} diff --git a/runtime/pangoro/src/pallets/message_transact.rs b/runtime/pangoro/src/pallets/message_transact.rs new file mode 100644 index 00000000..99077281 --- /dev/null +++ b/runtime/pangoro/src/pallets/message_transact.rs @@ -0,0 +1,25 @@ +// This file is part of Darwinia. +// +// Copyright (C) 2018-2023 Darwinia Network +// SPDX-License-Identifier: GPL-3.0 +// +// Darwinia 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. +// +// Darwinia 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 Darwinia. If not, see . + +// darwinia +use crate::*; + +impl darwinia_message_transact::Config for Runtime { + type LcmpEthOrigin = darwinia_message_transact::EnsureLcmpEthOrigin; + type ValidatedTransaction = pallet_ethereum::ValidatedTransaction; +} diff --git a/runtime/pangoro/src/pallets/mod.rs b/runtime/pangoro/src/pallets/mod.rs new file mode 100644 index 00000000..c07ec8c7 --- /dev/null +++ b/runtime/pangoro/src/pallets/mod.rs @@ -0,0 +1,111 @@ +// This file is part of Darwinia. +// +// Copyright (C) 2018-2023 Darwinia Network +// SPDX-License-Identifier: GPL-3.0 +// +// Darwinia 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. +// +// Darwinia 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 Darwinia. If not, see . + +mod shared_imports { + // darwinia + pub use darwinia_common_runtime::gov_origin::*; + // substrate + pub use sp_runtime::traits::{ConstBool, ConstU128, ConstU16, ConstU32, ConstU64, ConstU8}; +} +pub use shared_imports::*; + +// System stuffs. +mod system; +pub use system::*; + +mod parachain_system; + +mod timestamp; + +mod parachain_info_; + +// Monetary stuff. +mod balances; + +mod transaction_payment; + +mod assets; +pub use assets::*; + +mod vesting; + +mod deposit; + +mod account_migration; + +// Consensus stuff. +mod authorship; + +mod staking; + +mod session; +pub use session::*; + +mod aura; + +mod aura_ext; + +mod message_gadget; + +mod ecdsa_authority; + +// Governance stuff. +mod democracy; + +mod collective; +pub use collective::*; + +mod elections_phragmen; + +mod membership; + +mod treasury; +pub use treasury::*; + +mod tips; + +// Utility stuff. +mod sudo; + +mod utility; + +mod identity; + +mod scheduler; + +mod preimage; + +mod proxy; + +mod multisig; + +// XCM stuff. +mod xcmp_queue; + +mod polkadot_xcm; +pub use polkadot_xcm::*; + +mod dmp_queue; + +// EVM stuff. +mod ethereum; + +mod evm; +pub use evm::*; + +mod message_transact; diff --git a/runtime/pangoro/src/pallets/multisig.rs b/runtime/pangoro/src/pallets/multisig.rs new file mode 100644 index 00000000..c47262b2 --- /dev/null +++ b/runtime/pangoro/src/pallets/multisig.rs @@ -0,0 +1,32 @@ +// This file is part of Darwinia. +// +// Copyright (C) 2018-2023 Darwinia Network +// SPDX-License-Identifier: GPL-3.0 +// +// Darwinia 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. +// +// Darwinia 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 Darwinia. If not, see . + +// darwinia +use crate::*; + +impl pallet_multisig::Config for Runtime { + type Currency = Balances; + // One storage item; key size is 32; value is size 4+4+16+32 bytes = 56 bytes. + type DepositBase = ConstU128<{ darwinia_deposit(1, 88) }>; + // Additional storage item size of 32 bytes. + type DepositFactor = ConstU128<{ darwinia_deposit(0, 32) }>; + type MaxSignatories = ConstU32<100>; + type RuntimeCall = RuntimeCall; + type RuntimeEvent = RuntimeEvent; + type WeightInfo = (); +} diff --git a/runtime/pangoro/src/pallets/parachain_info_.rs b/runtime/pangoro/src/pallets/parachain_info_.rs new file mode 100644 index 00000000..aed03fc0 --- /dev/null +++ b/runtime/pangoro/src/pallets/parachain_info_.rs @@ -0,0 +1,22 @@ +// This file is part of Darwinia. +// +// Copyright (C) 2018-2023 Darwinia Network +// SPDX-License-Identifier: GPL-3.0 +// +// Darwinia 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. +// +// Darwinia 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 Darwinia. If not, see . + +// darwinia +use crate::*; + +impl parachain_info::Config for Runtime {} diff --git a/runtime/pangoro/src/pallets/parachain_system.rs b/runtime/pangoro/src/pallets/parachain_system.rs new file mode 100644 index 00000000..0f776807 --- /dev/null +++ b/runtime/pangoro/src/pallets/parachain_system.rs @@ -0,0 +1,37 @@ +// This file is part of Darwinia. +// +// Copyright (C) 2018-2023 Darwinia Network +// SPDX-License-Identifier: GPL-3.0 +// +// Darwinia 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. +// +// Darwinia 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 Darwinia. If not, see . + +// darwinia +use crate::*; + +frame_support::parameter_types! { + pub const ReservedXcmpWeight: frame_support::weights::Weight = MAXIMUM_BLOCK_WEIGHT.saturating_div(4); + pub const ReservedDmpWeight: frame_support::weights::Weight = MAXIMUM_BLOCK_WEIGHT.saturating_div(4); +} + +impl cumulus_pallet_parachain_system::Config for Runtime { + type CheckAssociatedRelayNumber = cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases; + type DmpMessageHandler = DmpQueue; + type OnSystemEvent = (); + type OutboundXcmpMessageSource = XcmpQueue; + type ReservedDmpWeight = ReservedDmpWeight; + type ReservedXcmpWeight = ReservedXcmpWeight; + type RuntimeEvent = RuntimeEvent; + type SelfParaId = parachain_info::Pallet; + type XcmpMessageHandler = XcmpQueue; +} diff --git a/runtime/pangoro/src/pallets/polkadot_xcm.rs b/runtime/pangoro/src/pallets/polkadot_xcm.rs new file mode 100644 index 00000000..4aec5bbe --- /dev/null +++ b/runtime/pangoro/src/pallets/polkadot_xcm.rs @@ -0,0 +1,186 @@ +// This file is part of Darwinia. +// +// Copyright (C) 2018-2023 Darwinia Network +// SPDX-License-Identifier: GPL-3.0 +// +// Darwinia 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. +// +// Darwinia 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 Darwinia. If not, see . + +// darwinia +use crate::*; +// substrate +use frame_support::traits::Currency; + +/// Means for transacting assets on this chain. +pub type LocalAssetTransactor = xcm_builder::CurrencyAdapter< + // Use this currency: + Balances, + // Use this currency when it is a fungible asset matching the given location or name: + xcm_builder::IsConcrete, + // Do a simple punn to convert an AccountId32 MultiLocation into a native chain account ID: + LocationToAccountId, + // Our chain's account ID type (we can't get away without mentioning it explicitly): + AccountId, + // We don't track any teleports. + (), +>; + +frame_support::parameter_types! { + pub const RelayNetwork: xcm::latest::prelude::NetworkId = xcm::latest::prelude::NetworkId::Any; + pub RelayChainOrigin: RuntimeOrigin = cumulus_pallet_xcm::Origin::Relay.into(); +} +/// Type for specifying how a `MultiLocation` can be converted into an `AccountId`. This is used +/// when determining ownership of accounts for asset transacting and when attempting to use XCM +/// `Transact` in order to determine the dispatch Origin. +pub type LocationToAccountId = ( + // The parent (Relay-chain) origin converts to the parent `AccountId`. + xcm_builder::ParentIsPreset, + // Sibling parachain origins convert to AccountId via the `ParaId::into`. + xcm_builder::SiblingParachainConvertsVia, + // Straight up local `AccountId20` origins just alias directly to `AccountId`. + xcm_builder::AccountKey20Aliases, + // The rest of locations are converted via hashing it. + darwinia_common_runtime::xcm_configs::Account20Hash, +); +/// This is the type we use to convert an (incoming) XCM origin into a local `Origin` instance, +/// ready for dispatching a transaction with Xcm's `Transact`. There is an `OriginKind` which can +/// biases the kind of local `Origin` it will become. +pub type XcmOriginToTransactDispatchOrigin = ( + // Sovereign account converter; this attempts to derive an `AccountId` from the origin location + // using `LocationToAccountId` and then turn that into the usual `Signed` origin. Useful for + // foreign chains who want to have a local sovereign account on this chain which they control. + xcm_builder::SovereignSignedViaLocation, + // Native converter for Relay-chain (Parent) location; will converts to a `Relay` origin when + // recognized. + xcm_builder::RelayChainAsNative, + // Native converter for sibling Parachains; will convert to a `SiblingPara` origin when + // recognized. + xcm_builder::SiblingParachainAsNative, + // Native signed account converter; this just converts an `AccountKey20` origin into a normal + // `RuntimeOrigin::Signed` origin of the same 20-byte value. + xcm_builder::SignedAccountKey20AsNative, + // Xcm origins can be represented natively under the Xcm pallet's Xcm origin. + pallet_xcm::XcmPassthrough, +); + +pub type Barrier = darwinia_common_runtime::xcm_configs::DenyThenTry< + darwinia_common_runtime::xcm_configs::DenyReserveTransferToRelayChain, + ( + xcm_builder::TakeWeightCredit, + xcm_builder::AllowTopLevelPaidExecutionFrom, + // Parent and its exec plurality get free execution + xcm_builder::AllowUnpaidExecutionFrom< + darwinia_common_runtime::xcm_configs::ParentOrParentsExecutivePlurality, + >, + // Expected responses are OK. + xcm_builder::AllowKnownQueryResponses, + // Subscriptions for version tracking are OK. + xcm_builder::AllowSubscriptionsFrom, + ), +>; + +frame_support::parameter_types! { + pub const MaxInstructions: u32 = 100; + pub AnchoringSelfReserve: xcm::latest::prelude::MultiLocation = xcm::latest::prelude::MultiLocation::new( + 0, + xcm::latest::prelude::X1(xcm::latest::prelude::PalletInstance(::index() as u8)) + ); + // One XCM operation is 1_000_000_000 weight - almost certainly a conservative estimate. + pub Ancestry: xcm::latest::prelude::MultiLocation = xcm::latest::prelude::Parachain(ParachainInfo::parachain_id().into()).into(); + pub UnitWeightCost: u64 = 1_000_000_000; +} + +pub struct ToTreasury; +impl xcm_builder::TakeRevenue for ToTreasury { + fn take_revenue(revenue: xcm::latest::prelude::MultiAsset) { + if let xcm::latest::prelude::MultiAsset { + id: xcm::latest::prelude::Concrete(_location), + fun: xcm::latest::prelude::Fungible(amount), + } = revenue + { + let treasury_account = Treasury::account_id(); + let _ = Balances::deposit_creating(&treasury_account, amount); + + frame_support::log::trace!( + target: "xcm::weight", + "LocalAssetTrader::to_treasury amount: {amount:?}, treasury: {treasury_account:?}" + ); + } + } +} + +pub struct XcmExecutorConfig; +impl xcm_executor::Config for XcmExecutorConfig { + type AssetClaims = PolkadotXcm; + // How to withdraw and deposit an asset. + type AssetTransactor = LocalAssetTransactor; + type AssetTrap = PolkadotXcm; + type Barrier = Barrier; + type IsReserve = xcm_builder::NativeAsset; + type IsTeleporter = (); + // Teleporting is disabled. + type LocationInverter = xcm_builder::LocationInverter; + type OriginConverter = XcmOriginToTransactDispatchOrigin; + type ResponseHandler = PolkadotXcm; + type RuntimeCall = RuntimeCall; + type SubscriptionService = PolkadotXcm; + type Trader = xcm_configs::LocalAssetTrader< + frame_support::weights::ConstantMultiplier< + Balance, + darwinia_common_runtime::xcm_configs::XcmBaseWeightFee, + >, + AnchoringSelfReserve, + AccountId, + Balances, + DealWithFees, + ToTreasury, + >; + type Weigher = xcm_builder::FixedWeightBounds; + type XcmSender = XcmRouter; +} + +/// No local origins on this chain are allowed to dispatch XCM sends/executions. +pub type LocalOriginToLocation = + xcm_primitives::SignedToAccountId20; +/// The means for routing XCM messages which are not for local execution into the right message +/// queues. +pub type XcmRouter = ( + // Two routers - use UMP to communicate with the relay chain: + cumulus_primitives_utility::ParentAsUmp, + // ..and XCMP to communicate with the sibling chains. + XcmpQueue, +); + +impl pallet_xcm::Config for Runtime { + // ^ Override for AdvertisedXcmVersion default + type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion; + type ExecuteXcmOrigin = xcm_builder::EnsureXcmOrigin; + type LocationInverter = xcm_builder::LocationInverter; + type RuntimeCall = RuntimeCall; + type RuntimeEvent = RuntimeEvent; + type RuntimeOrigin = RuntimeOrigin; + type SendXcmOrigin = xcm_builder::EnsureXcmOrigin; + type Weigher = xcm_builder::FixedWeightBounds; + type XcmExecuteFilter = frame_support::traits::Everything; + type XcmExecutor = xcm_executor::XcmExecutor; + type XcmReserveTransferFilter = frame_support::traits::Everything; + type XcmRouter = XcmRouter; + type XcmTeleportFilter = frame_support::traits::Nothing; + + const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; +} + +impl cumulus_pallet_xcm::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type XcmExecutor = xcm_executor::XcmExecutor; +} diff --git a/runtime/pangoro/src/pallets/preimage.rs b/runtime/pangoro/src/pallets/preimage.rs new file mode 100644 index 00000000..d049ef1c --- /dev/null +++ b/runtime/pangoro/src/pallets/preimage.rs @@ -0,0 +1,29 @@ +// This file is part of Darwinia. +// +// Copyright (C) 2018-2023 Darwinia Network +// SPDX-License-Identifier: GPL-3.0 +// +// Darwinia 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. +// +// Darwinia 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 Darwinia. If not, see . + +// darwinia +use crate::*; + +impl pallet_preimage::Config for Runtime { + type BaseDeposit = ConstU128<{ 500 * UNIT }>; + type ByteDeposit = ConstU128<{ darwinia_deposit(0, 1) }>; + type Currency = Balances; + type ManagerOrigin = frame_system::EnsureRoot; + type RuntimeEvent = RuntimeEvent; + type WeightInfo = (); +} diff --git a/runtime/pangoro/src/pallets/proxy.rs b/runtime/pangoro/src/pallets/proxy.rs new file mode 100644 index 00000000..9da74c43 --- /dev/null +++ b/runtime/pangoro/src/pallets/proxy.rs @@ -0,0 +1,120 @@ +// This file is part of Darwinia. +// +// Copyright (C) 2018-2023 Darwinia Network +// SPDX-License-Identifier: GPL-3.0 +// +// Darwinia 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. +// +// Darwinia 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 Darwinia. If not, see . + +// darwinia +use crate::*; + +/// The type used to represent the kinds of proxying allowed. +#[derive( + Copy, + Clone, + Eq, + PartialEq, + Ord, + PartialOrd, + codec::Encode, + codec::Decode, + codec::MaxEncodedLen, + scale_info::TypeInfo, + sp_runtime::RuntimeDebug, +)] +pub enum ProxyType { + Any, + NonTransfer, + Governance, + Staking, + IdentityJudgement, + CancelProxy, + EcdsaBridge, +} +impl Default for ProxyType { + fn default() -> Self { + Self::Any + } +} +impl frame_support::traits::InstanceFilter for ProxyType { + fn filter(&self, c: &RuntimeCall) -> bool { + match self { + ProxyType::Any => true, + ProxyType::NonTransfer => !matches!( + c, + RuntimeCall::Balances(..) + | RuntimeCall::Assets(..) + | RuntimeCall::Vesting(pallet_vesting::Call::vested_transfer { .. }) + | RuntimeCall::Deposit(..) + | RuntimeCall::DarwiniaStaking(..) + // Might contains transfer { + | RuntimeCall::Utility(..) + | RuntimeCall::Proxy(..) + | RuntimeCall::Multisig(..) + | RuntimeCall::PolkadotXcm(..) + | RuntimeCall::Ethereum(..) // } + ), + ProxyType::Governance => matches!( + c, + RuntimeCall::Democracy(..) + | RuntimeCall::Council(..) + | RuntimeCall::TechnicalCommittee(..) + | RuntimeCall::PhragmenElection(..) + | RuntimeCall::Treasury(..) + | RuntimeCall::Tips(..) + ), + ProxyType::Staking => { + matches!( + c, + RuntimeCall::Session(..) | RuntimeCall::Deposit(..) | RuntimeCall::DarwiniaStaking(..) + ) + }, + ProxyType::IdentityJudgement => + matches!(c, RuntimeCall::Identity(pallet_identity::Call::provide_judgement { .. })), + ProxyType::CancelProxy => { + matches!(c, RuntimeCall::Proxy(pallet_proxy::Call::reject_announcement { .. })) + }, + ProxyType::EcdsaBridge => { + matches!(c, RuntimeCall::EcdsaAuthority(..)) + }, + } + } + + fn is_superset(&self, o: &Self) -> bool { + match (self, o) { + (x, y) if x == y => true, + (ProxyType::Any, _) => true, + (_, ProxyType::Any) => false, + (ProxyType::NonTransfer, _) => true, + _ => false, + } + } +} + +impl pallet_proxy::Config for Runtime { + type AnnouncementDepositBase = ConstU128<{ darwinia_deposit(1, 8) }>; + type AnnouncementDepositFactor = ConstU128<{ darwinia_deposit(0, 66) }>; + type CallHasher = Hashing; + type Currency = Balances; + type MaxPending = ConstU32<32>; + type MaxProxies = ConstU32<32>; + // One storage item; key size 32, value size 8; . + type ProxyDepositBase = ConstU128<{ darwinia_deposit(1, 8) }>; + // Additional storage item size of 33 bytes. + type ProxyDepositFactor = ConstU128<{ darwinia_deposit(0, 33) }>; + type ProxyType = ProxyType; + type RuntimeCall = RuntimeCall; + type RuntimeEvent = RuntimeEvent; + type WeightInfo = (); +} diff --git a/runtime/pangoro/src/pallets/scheduler.rs b/runtime/pangoro/src/pallets/scheduler.rs new file mode 100644 index 00000000..2f019740 --- /dev/null +++ b/runtime/pangoro/src/pallets/scheduler.rs @@ -0,0 +1,63 @@ +// This file is part of Darwinia. +// +// Copyright (C) 2018-2023 Darwinia Network +// SPDX-License-Identifier: GPL-3.0 +// +// Darwinia 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. +// +// Darwinia 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 Darwinia. If not, see . + +// darwinia +use crate::*; + +/// Used the compare the privilege of an origin inside the scheduler. +pub struct OriginPrivilegeCmp; +impl frame_support::traits::PrivilegeCmp for OriginPrivilegeCmp { + fn cmp_privilege(left: &OriginCaller, right: &OriginCaller) -> Option { + if left == right { + return Some(core::cmp::Ordering::Equal); + } + + match (left, right) { + // Root is greater than anything. + (OriginCaller::system(frame_system::RawOrigin::Root), _) => + Some(core::cmp::Ordering::Greater), + // Check which one has more yes votes. + ( + OriginCaller::Council(pallet_collective::RawOrigin::Members(l_yes_votes, l_count)), + OriginCaller::Council(pallet_collective::RawOrigin::Members(r_yes_votes, r_count)), + ) => Some((l_yes_votes * r_count).cmp(&(r_yes_votes * l_count))), + // For every other origin we don't care, as they are not used for `ScheduleOrigin`. + _ => None, + } + } +} + +frame_support::parameter_types! { + pub MaximumSchedulerWeight: frame_support::weights::Weight = sp_runtime::Perbill::from_percent(80) + * RuntimeBlockWeights::get().max_block; + // Retry a scheduled item every 10 blocks (1 minute) until the preimage exists. + pub const NoPreimagePostponement: Option = Some(10); +} + +impl pallet_scheduler::Config for Runtime { + type MaxScheduledPerBlock = ConstU32<50>; + type MaximumWeight = MaximumSchedulerWeight; + type OriginPrivilegeCmp = OriginPrivilegeCmp; + type PalletsOrigin = OriginCaller; + type Preimages = Preimage; + type RuntimeCall = RuntimeCall; + type RuntimeEvent = RuntimeEvent; + type RuntimeOrigin = RuntimeOrigin; + type ScheduleOrigin = Root; + type WeightInfo = (); +} diff --git a/runtime/pangoro/src/pallets/session.rs b/runtime/pangoro/src/pallets/session.rs new file mode 100644 index 00000000..383efa99 --- /dev/null +++ b/runtime/pangoro/src/pallets/session.rs @@ -0,0 +1,44 @@ +// This file is part of Darwinia. +// +// Copyright (C) 2018-2023 Darwinia Network +// SPDX-License-Identifier: GPL-3.0 +// +// Darwinia 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. +// +// Darwinia 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 Darwinia. If not, see . + +// darwinia +use crate::*; + +sp_runtime::impl_opaque_keys! { + pub struct SessionKeys { + pub aura: Aura, + } +} + +fast_runtime_or_not!(Period, ConstU32<{ 5 * MINUTES }>, ConstU32<{ 6 * HOURS }>); + +type Offset = ConstU32<0>; + +impl pallet_session::Config for Runtime { + type Keys = SessionKeys; + type NextSessionRotation = pallet_session::PeriodicSessions; + type RuntimeEvent = RuntimeEvent; + // Essentially just AURA, but lets be pedantic. + type SessionHandler = ::KeyTypeIdProviders; + type SessionManager = DarwiniaStaking; + type ShouldEndSession = pallet_session::PeriodicSessions; + type ValidatorId = ::AccountId; + // We don't have stash and controller, thus we don't need the convert as well. + type ValidatorIdOf = darwinia_staking::IdentityCollator; + type WeightInfo = weights::pallet_session::WeightInfo; +} diff --git a/runtime/pangoro/src/pallets/staking.rs b/runtime/pangoro/src/pallets/staking.rs new file mode 100644 index 00000000..50e17ac9 --- /dev/null +++ b/runtime/pangoro/src/pallets/staking.rs @@ -0,0 +1,87 @@ +// This file is part of Darwinia. +// +// Copyright (C) 2018-2023 Darwinia Network +// SPDX-License-Identifier: GPL-3.0 +// +// Darwinia 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. +// +// Darwinia 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 Darwinia. If not, see . + +// darwinia +use crate::*; + +fast_runtime_or_not!(MinStakingDuration, ConstU32<{ 5 * MINUTES }>, ConstU32<{ 14 * DAYS }>); + +pub enum RingStaking {} +impl darwinia_staking::Stake for RingStaking { + type AccountId = AccountId; + type Item = Balance; + + fn stake(who: &Self::AccountId, item: Self::Item) -> sp_runtime::DispatchResult { + >::transfer( + who, + &darwinia_staking::account_id(), + item, + frame_support::traits::ExistenceRequirement::KeepAlive, + ) + } + + fn unstake(who: &Self::AccountId, item: Self::Item) -> sp_runtime::DispatchResult { + >::transfer( + &darwinia_staking::account_id(), + who, + item, + frame_support::traits::ExistenceRequirement::AllowDeath, + ) + } +} +pub enum KtonStaking {} +impl darwinia_staking::Stake for KtonStaking { + type AccountId = AccountId; + type Item = Balance; + + fn stake(who: &Self::AccountId, item: Self::Item) -> sp_runtime::DispatchResult { + Assets::transfer( + RuntimeOrigin::signed(*who), + (AssetIds::OKton as AssetId).into(), + darwinia_staking::account_id(), + item, + ) + } + + fn unstake(who: &Self::AccountId, item: Self::Item) -> sp_runtime::DispatchResult { + Assets::transfer( + RuntimeOrigin::signed(darwinia_staking::account_id()), + (AssetIds::OKton as AssetId).into(), + *who, + item, + ) + } +} + +frame_support::parameter_types! { + pub const PayoutFraction: sp_runtime::Perbill = sp_runtime::Perbill::from_percent(20); +} + +impl darwinia_staking::Config for Runtime { + type Deposit = Deposit; + type Kton = KtonStaking; + type MaxDeposits = ConstU32<16>; + type MaxUnstakings = ConstU32<16>; + type MinStakingDuration = MinStakingDuration; + type PayoutFraction = PayoutFraction; + type RewardRemainder = Treasury; + type Ring = RingStaking; + type RingCurrency = Balances; + type RuntimeEvent = RuntimeEvent; + type UnixTime = Timestamp; +} diff --git a/runtime/pangoro/src/pallets/sudo.rs b/runtime/pangoro/src/pallets/sudo.rs new file mode 100644 index 00000000..fbefaf4c --- /dev/null +++ b/runtime/pangoro/src/pallets/sudo.rs @@ -0,0 +1,25 @@ +// This file is part of Darwinia. +// +// Copyright (C) 2018-2023 Darwinia Network +// SPDX-License-Identifier: GPL-3.0 +// +// Darwinia 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. +// +// Darwinia 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 Darwinia. If not, see . + +// darwinia +use crate::*; + +impl pallet_sudo::Config for Runtime { + type RuntimeCall = RuntimeCall; + type RuntimeEvent = RuntimeEvent; +} diff --git a/runtime/pangoro/src/pallets/system.rs b/runtime/pangoro/src/pallets/system.rs new file mode 100644 index 00000000..96faace6 --- /dev/null +++ b/runtime/pangoro/src/pallets/system.rs @@ -0,0 +1,109 @@ +// This file is part of Darwinia. +// +// Copyright (C) 2018-2023 Darwinia Network +// SPDX-License-Identifier: GPL-3.0 +// +// Darwinia 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. +// +// Darwinia 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 Darwinia. If not, see . + +// darwinia +use crate::*; + +/// We assume that ~5% of the block weight is consumed by `on_initialize` handlers. This is +/// used to limit the maximal weight of a single extrinsic. +const AVERAGE_ON_INITIALIZE_RATIO: sp_runtime::Perbill = sp_runtime::Perbill::from_percent(5); + +/// We allow `Normal` extrinsics to fill up the block up to 75%, the rest can be used by +/// `Operational` extrinsics. +pub const NORMAL_DISPATCH_RATIO: sp_runtime::Perbill = sp_runtime::Perbill::from_percent(75); + +/// We allow for 0.5 of a second of compute with a 12 second average block time. +pub const MAXIMUM_BLOCK_WEIGHT: frame_support::weights::Weight = + frame_support::weights::Weight::from_parts( + frame_support::weights::constants::WEIGHT_REF_TIME_PER_SECOND.saturating_div(2), + cumulus_primitives_core::relay_chain::v2::MAX_POV_SIZE as u64, + ); + +frame_support::parameter_types! { + pub const Version: sp_version::RuntimeVersion = VERSION; + pub RuntimeBlockLength: frame_system::limits::BlockLength = + frame_system::limits::BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO); + pub RuntimeBlockWeights: frame_system::limits::BlockWeights = frame_system::limits::BlockWeights::builder() + .base_block(weights::BlockExecutionWeight::get()) + .for_class(frame_support::dispatch::DispatchClass::all(), |weights| { + weights.base_extrinsic = weights::ExtrinsicBaseWeight::get(); + }) + .for_class(frame_support::dispatch::DispatchClass::Normal, |weights| { + weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT); + }) + .for_class(frame_support::dispatch::DispatchClass::Operational, |weights| { + weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT); + // Operational transactions have some extra reserved space, so that they + // are included even if block reached `MAXIMUM_BLOCK_WEIGHT`. + weights.reserved = Some( + MAXIMUM_BLOCK_WEIGHT - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT + ); + }) + .avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO) + .build_or_panic(); +} + +impl frame_system::Config for Runtime { + /// The data to be stored in an account. + type AccountData = pallet_balances::AccountData; + /// The identifier used to distinguish between accounts. + type AccountId = AccountId; + /// The basic call filter to use in dispatchable. + type BaseCallFilter = frame_support::traits::Everything; + /// Maximum number of block number to block hash mappings to keep (oldest pruned first). + type BlockHashCount = ConstU32<2400>; + /// The maximum length of a block (in bytes). + type BlockLength = RuntimeBlockLength; + /// The index type for blocks. + type BlockNumber = BlockNumber; + /// Block & extrinsics weights: base values and limits. + type BlockWeights = RuntimeBlockWeights; + /// The weight of database operations that the runtime can invoke. + type DbWeight = weights::RocksDbWeight; + /// The type for hashing blocks and tries. + type Hash = Hash; + /// The hashing algorithm used. + type Hashing = Hashing; + /// The header type. + type Header = sp_runtime::generic::Header; + /// The index type for storing how many extrinsics an account has signed. + type Index = Index; + /// The lookup mechanism to get account ID from whatever is passed in dispatchers. + type Lookup = sp_runtime::traits::IdentityLookup; + type MaxConsumers = ConstU32<16>; + /// What to do if an account is fully reaped from the system. + type OnKilledAccount = (); + /// What to do if a new account is created. + type OnNewAccount = (); + /// The action to take on a Runtime Upgrade + type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode; + /// Converts a module to an index of this module in the runtime. + type PalletInfo = PalletInfo; + /// The aggregated dispatch type that is available for extrinsics. + type RuntimeCall = RuntimeCall; + /// The ubiquitous event type. + type RuntimeEvent = RuntimeEvent; + /// The ubiquitous origin type. + type RuntimeOrigin = RuntimeOrigin; + /// This is used as an identifier of the chain. 42 is the generic substrate prefix. + type SS58Prefix = ConstU16<18>; + /// Weight information for the extrinsics of this pallet. + type SystemWeightInfo = weights::frame_system::WeightInfo; + /// Runtime version. + type Version = Version; +} diff --git a/runtime/pangoro/src/pallets/timestamp.rs b/runtime/pangoro/src/pallets/timestamp.rs new file mode 100644 index 00000000..b18b2a16 --- /dev/null +++ b/runtime/pangoro/src/pallets/timestamp.rs @@ -0,0 +1,28 @@ +// This file is part of Darwinia. +// +// Copyright (C) 2018-2023 Darwinia Network +// SPDX-License-Identifier: GPL-3.0 +// +// Darwinia 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. +// +// Darwinia 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 Darwinia. If not, see . + +// darwinia +use crate::*; + +impl pallet_timestamp::Config for Runtime { + type MinimumPeriod = ConstU64<{ SLOT_DURATION / 2 }>; + /// A timestamp: milliseconds since the unix epoch. + type Moment = u64; + type OnTimestampSet = Aura; + type WeightInfo = weights::pallet_timestamp::WeightInfo; +} diff --git a/runtime/pangoro/src/pallets/tips.rs b/runtime/pangoro/src/pallets/tips.rs new file mode 100644 index 00000000..6500a1b3 --- /dev/null +++ b/runtime/pangoro/src/pallets/tips.rs @@ -0,0 +1,35 @@ +// This file is part of Darwinia. +// +// Copyright (C) 2018-2023 Darwinia Network +// SPDX-License-Identifier: GPL-3.0 +// +// Darwinia 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. +// +// Darwinia 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 Darwinia. If not, see . + +// darwinia +use crate::*; + +frame_support::parameter_types! { + pub const TipFindersFee: sp_runtime::Percent = sp_runtime::Percent::from_percent(20); +} + +impl pallet_tips::Config for Runtime { + type DataDepositPerByte = ConstU128<{ darwinia_deposit(0, 1) }>; + type MaximumReasonLength = ConstU32<16384>; + type RuntimeEvent = RuntimeEvent; + type TipCountdown = ConstU32; + type TipFindersFee = TipFindersFee; + type TipReportDepositBase = ConstU128<{ 100 * UNIT }>; + type Tippers = PhragmenElection; + type WeightInfo = (); +} diff --git a/runtime/pangoro/src/pallets/transaction_payment.rs b/runtime/pangoro/src/pallets/transaction_payment.rs new file mode 100644 index 00000000..63620c02 --- /dev/null +++ b/runtime/pangoro/src/pallets/transaction_payment.rs @@ -0,0 +1,32 @@ +// This file is part of Darwinia. +// +// Copyright (C) 2018-2023 Darwinia Network +// SPDX-License-Identifier: GPL-3.0 +// +// Darwinia 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. +// +// Darwinia 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 Darwinia. If not, see . + +// darwinia +use crate::*; + +impl pallet_transaction_payment::Config for Runtime { + type FeeMultiplierUpdate = polkadot_runtime_common::SlowAdjustingFeeUpdate; + // Relay Chain `TransactionByteFee` / 10 + type LengthToFee = + frame_support::weights::ConstantMultiplier>; + type OnChargeTransaction = + pallet_transaction_payment::CurrencyAdapter>; + type OperationalFeeMultiplier = sp_runtime::traits::ConstU8<5>; + type RuntimeEvent = RuntimeEvent; + type WeightToFee = WeightToFee; +} diff --git a/runtime/pangoro/src/pallets/treasury.rs b/runtime/pangoro/src/pallets/treasury.rs new file mode 100644 index 00000000..3febca02 --- /dev/null +++ b/runtime/pangoro/src/pallets/treasury.rs @@ -0,0 +1,47 @@ +// This file is part of Darwinia. +// +// Copyright (C) 2018-2023 Darwinia Network +// SPDX-License-Identifier: GPL-3.0 +// +// Darwinia 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. +// +// Darwinia 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 Darwinia. If not, see . + +// darwinia +use crate::*; + +frame_support::parameter_types! { + pub const TreasuryPalletId: frame_support::PalletId = frame_support::PalletId(*b"da/trsry"); + pub const ProposalBond: sp_runtime::Permill = sp_runtime::Permill::from_percent(5); + pub const Burn: sp_runtime::Permill = sp_runtime::Permill::from_percent(1); +} + +// In order to use `Tips`, which bounded by `pallet_treasury::Config` rather +// `pallet_treasury::Config` Still use `DefaultInstance` here instead `Instance1` +impl pallet_treasury::Config for Runtime { + type ApproveOrigin = RootOrAtLeastThreeFifth; + type Burn = Burn; + type BurnDestination = (); + type Currency = Balances; + type MaxApprovals = ConstU32<100>; + type OnSlash = Treasury; + type PalletId = TreasuryPalletId; + type ProposalBond = ProposalBond; + type ProposalBondMaximum = (); + type ProposalBondMinimum = ConstU128; + type RejectOrigin = RootOrMoreThanHalf; + type RuntimeEvent = RuntimeEvent; + type SpendFunds = (); + type SpendOrigin = frame_support::traits::NeverEnsureOrigin; + type SpendPeriod = ConstU32<{ 24 * DAYS }>; + type WeightInfo = (); +} diff --git a/runtime/pangoro/src/pallets/utility.rs b/runtime/pangoro/src/pallets/utility.rs new file mode 100644 index 00000000..2c0f49dd --- /dev/null +++ b/runtime/pangoro/src/pallets/utility.rs @@ -0,0 +1,27 @@ +// This file is part of Darwinia. +// +// Copyright (C) 2018-2023 Darwinia Network +// SPDX-License-Identifier: GPL-3.0 +// +// Darwinia 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. +// +// Darwinia 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 Darwinia. If not, see . + +// darwinia +use crate::*; + +impl pallet_utility::Config for Runtime { + type PalletsOrigin = OriginCaller; + type RuntimeCall = RuntimeCall; + type RuntimeEvent = RuntimeEvent; + type WeightInfo = (); +} diff --git a/runtime/pangoro/src/pallets/vesting.rs b/runtime/pangoro/src/pallets/vesting.rs new file mode 100644 index 00000000..1c0b0b6e --- /dev/null +++ b/runtime/pangoro/src/pallets/vesting.rs @@ -0,0 +1,40 @@ +// This file is part of Darwinia. +// +// Copyright (C) 2018-2023 Darwinia Network +// SPDX-License-Identifier: GPL-3.0 +// +// Darwinia 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. +// +// Darwinia 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 Darwinia. If not, see . + +// darwinia +use crate::*; + +frame_support::parameter_types! { + pub UnvestedFundsAllowedWithdrawReasons: frame_support::traits::WithdrawReasons = + frame_support::traits::WithdrawReasons::except( + frame_support::traits::WithdrawReasons::TRANSFER | frame_support::traits::WithdrawReasons::RESERVE + ); +} + +impl pallet_vesting::Config for Runtime { + type BlockNumberToBalance = sp_runtime::traits::ConvertInto; + type Currency = Balances; + type MinVestedTransfer = ConstU128; + type RuntimeEvent = RuntimeEvent; + type UnvestedFundsAllowedWithdrawReasons = UnvestedFundsAllowedWithdrawReasons; + type WeightInfo = (); + + // `VestingInfo` encode length is 36bytes. 28 schedules gets encoded as 1009 bytes, which is the + // highest number of schedules that encodes less than 2^10. + const MAX_VESTING_SCHEDULES: u32 = 28; +} diff --git a/runtime/pangoro/src/pallets/xcmp_queue.rs b/runtime/pangoro/src/pallets/xcmp_queue.rs new file mode 100644 index 00000000..f3f8d642 --- /dev/null +++ b/runtime/pangoro/src/pallets/xcmp_queue.rs @@ -0,0 +1,31 @@ +// This file is part of Darwinia. +// +// Copyright (C) 2018-2023 Darwinia Network +// SPDX-License-Identifier: GPL-3.0 +// +// Darwinia 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. +// +// Darwinia 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 Darwinia. If not, see . + +// darwinia +use crate::*; + +impl cumulus_pallet_xcmp_queue::Config for Runtime { + type ChannelInfo = ParachainSystem; + type ControllerOrigin = frame_system::EnsureRoot; + type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin; + type ExecuteOverweightOrigin = frame_system::EnsureRoot; + type RuntimeEvent = RuntimeEvent; + type VersionWrapper = (); + type WeightInfo = weights::cumulus_pallet_xcmp_queue::WeightInfo; + type XcmExecutor = xcm_executor::XcmExecutor; +} diff --git a/runtime/pangoro/src/weights/block_weights.rs b/runtime/pangoro/src/weights/block_weights.rs new file mode 100644 index 00000000..8da49f75 --- /dev/null +++ b/runtime/pangoro/src/weights/block_weights.rs @@ -0,0 +1,48 @@ +// This file is part of Substrate. + +// Copyright (C) 2022 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. + +pub mod constants { + frame_support::parameter_types! { + /// Importing a block with 0 Extrinsics. + pub const BlockExecutionWeight: frame_support::weights::Weight = + frame_support::weights::Weight::from_ref_time(frame_support::weights::constants::WEIGHT_REF_TIME_PER_NANOS.saturating_mul(5_000_000)); + } + + #[cfg(test)] + mod test_weights { + /// Checks that the weight exists and is sane. + // NOTE: If this test fails but you are sure that the generated values are fine, + // you can delete it. + #[test] + fn sane() { + let w = frame_support::weights::constants::BlockExecutionWeight::get(); + + // At least 100 µs. + assert!( + w.ref_time() + >= 100u64 * frame_support::weights::constants::WEIGHT_REF_TIME_PER_MICROS, + "Weight should be at least 100 µs." + ); + // At most 50 ms. + assert!( + w.ref_time() + <= 50u64 * frame_support::weights::constants::WEIGHT_REF_TIME_PER_MILLIS, + "Weight should be at most 50 ms." + ); + } + } +} diff --git a/runtime/pangoro/src/weights/cumulus_pallet_xcmp_queue.rs b/runtime/pangoro/src/weights/cumulus_pallet_xcmp_queue.rs new file mode 100644 index 00000000..3271b31e --- /dev/null +++ b/runtime/pangoro/src/weights/cumulus_pallet_xcmp_queue.rs @@ -0,0 +1,67 @@ +// This file is part of Darwinia. +// +// Copyright (C) 2018-2023 Darwinia Network +// SPDX-License-Identifier: GPL-3.0 +// +// Darwinia 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. +// +// Darwinia 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 Darwinia. If not, see . + +//! Autogenerated weights for `cumulus_pallet_xcmp_queue` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2022-11-09, STEPS: `2`, REPEAT: 1, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `inv.cafe`, CPU: `AMD Ryzen 9 5950X 16-Core Processor` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("local"), DB CACHE: 1024 + +// Executed Command: +// target/release/darwinia +// benchmark +// pallet +// --header +// .maintain/license-header +// --execution +// wasm +// --heap-pages +// 4096 +// --chain +// local +// --output +// runtime/src/weights +// --extrinsic +// * +// --pallet +// cumulus-pallet-xcmp-queue + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::Weight}; +use sp_std::marker::PhantomData; + +/// Weight functions for `cumulus_pallet_xcmp_queue`. +pub struct WeightInfo(PhantomData); +impl cumulus_pallet_xcmp_queue::WeightInfo for WeightInfo { + // Storage: XcmpQueue QueueConfig (r:1 w:1) + fn set_config_with_u32() -> Weight { + Weight::from_ref_time(13_340_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + } + // Storage: XcmpQueue QueueConfig (r:1 w:1) + fn set_config_with_weight() -> Weight { + Weight::from_ref_time(12_610_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + } +} diff --git a/runtime/pangoro/src/weights/extrinsic_weights.rs b/runtime/pangoro/src/weights/extrinsic_weights.rs new file mode 100644 index 00000000..0c17b0de --- /dev/null +++ b/runtime/pangoro/src/weights/extrinsic_weights.rs @@ -0,0 +1,47 @@ +// This file is part of Substrate. + +// Copyright (C) 2022 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. + +pub mod constants { + frame_support::parameter_types! { + /// Executing a NO-OP `System::remarks` Extrinsic. + pub const ExtrinsicBaseWeight: frame_support::weights::Weight = + frame_support::weights::Weight::from_ref_time(frame_support::weights::constants::WEIGHT_REF_TIME_PER_NANOS.saturating_mul(125_000)); + } + + #[cfg(test)] + mod test_weights { + /// Checks that the weight exists and is sane. + // NOTE: If this test fails but you are sure that the generated values are fine, + // you can delete it. + #[test] + fn sane() { + let w = frame_support::weights::constants::ExtrinsicBaseWeight::get(); + + // At least 10 µs. + assert!( + w.ref_time() + >= 10u64 * frame_support::weights::constants::WEIGHT_REF_TIME_PER_MICROS, + "Weight should be at least 10 µs." + ); + // At most 1 ms. + assert!( + w.ref_time() <= frame_support::weights::constants::WEIGHT_REF_TIME_PER_MILLIS, + "Weight should be at most 1 ms." + ); + } + } +} diff --git a/runtime/pangoro/src/weights/frame_system.rs b/runtime/pangoro/src/weights/frame_system.rs new file mode 100644 index 00000000..2361f751 --- /dev/null +++ b/runtime/pangoro/src/weights/frame_system.rs @@ -0,0 +1,88 @@ +// This file is part of Darwinia. +// +// Copyright (C) 2018-2023 Darwinia Network +// SPDX-License-Identifier: GPL-3.0 +// +// Darwinia 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. +// +// Darwinia 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 Darwinia. If not, see . + +//! Autogenerated weights for `frame_system` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2022-11-09, STEPS: `2`, REPEAT: 1, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `inv.cafe`, CPU: `AMD Ryzen 9 5950X 16-Core Processor` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("local"), DB CACHE: 1024 + +// Executed Command: +// target/release/darwinia +// benchmark +// pallet +// --header +// .maintain/license-header +// --execution +// wasm +// --heap-pages +// 4096 +// --chain +// local +// --output +// runtime/src/weights +// --extrinsic +// * +// --pallet +// frame-system + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::Weight}; +use sp_std::marker::PhantomData; + +/// Weight functions for `frame_system`. +pub struct WeightInfo(PhantomData); +impl frame_system::WeightInfo for WeightInfo { + /// The range of component `b` is `[0, 3932160]`. + fn remark(_b: u32, ) -> Weight { + Weight::from_ref_time(1_074_555_000 as u64) + } + /// The range of component `b` is `[0, 3932160]`. + fn remark_with_event(_b: u32, ) -> Weight { + Weight::from_ref_time(4_724_488_000 as u64) + } + // Storage: System Digest (r:1 w:1) + // Storage: unknown [0x3a686561707061676573] (r:0 w:1) + fn set_heap_pages() -> Weight { + Weight::from_ref_time(14_110_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + } + // Storage: Skipped Metadata (r:0 w:0) + /// The range of component `i` is `[1, 1000]`. + fn set_storage(_i: u32, ) -> Weight { + Weight::from_ref_time(655_299_000 as u64) + .saturating_add(T::DbWeight::get().writes(1000 as u64)) + } + // Storage: Skipped Metadata (r:0 w:0) + /// The range of component `i` is `[1, 1000]`. + fn kill_storage(_i: u32, ) -> Weight { + Weight::from_ref_time(555_697_000 as u64) + .saturating_add(T::DbWeight::get().writes(1000 as u64)) + } + // Storage: Skipped Metadata (r:0 w:0) + /// The range of component `p` is `[1, 1000]`. + fn kill_prefix(_p: u32, ) -> Weight { + Weight::from_ref_time(1_089_395_000 as u64) + .saturating_add(T::DbWeight::get().writes(1000 as u64)) + } +} diff --git a/runtime/pangoro/src/weights/mod.rs b/runtime/pangoro/src/weights/mod.rs new file mode 100644 index 00000000..caf9386d --- /dev/null +++ b/runtime/pangoro/src/weights/mod.rs @@ -0,0 +1,39 @@ +// This file is part of Darwinia. +// +// Copyright (C) 2018-2023 Darwinia Network +// SPDX-License-Identifier: GPL-3.0 +// +// Darwinia 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. +// +// Darwinia 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 Darwinia. If not, see . + +//! Expose the auto generated weight files. + +#![allow(clippy::unnecessary_cast)] + +pub mod block_weights; +pub use block_weights::constants::BlockExecutionWeight; + +pub mod extrinsic_weights; +pub use extrinsic_weights::constants::ExtrinsicBaseWeight; + +pub mod paritydb_weights; +pub use paritydb_weights::constants::ParityDbWeight; + +pub mod rocksdb_weights; +pub use rocksdb_weights::constants::RocksDbWeight; + +pub mod cumulus_pallet_xcmp_queue; +pub mod frame_system; +pub mod pallet_balances; +pub mod pallet_session; +pub mod pallet_timestamp; diff --git a/runtime/pangoro/src/weights/pallet_balances.rs b/runtime/pangoro/src/weights/pallet_balances.rs new file mode 100644 index 00000000..f7acd35f --- /dev/null +++ b/runtime/pangoro/src/weights/pallet_balances.rs @@ -0,0 +1,97 @@ +// This file is part of Darwinia. +// +// Copyright (C) 2018-2023 Darwinia Network +// SPDX-License-Identifier: GPL-3.0 +// +// Darwinia 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. +// +// Darwinia 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 Darwinia. If not, see . + +//! Autogenerated weights for `pallet_balances` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2022-11-09, STEPS: `2`, REPEAT: 1, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `inv.cafe`, CPU: `AMD Ryzen 9 5950X 16-Core Processor` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("local"), DB CACHE: 1024 + +// Executed Command: +// target/release/darwinia +// benchmark +// pallet +// --header +// .maintain/license-header +// --execution +// wasm +// --heap-pages +// 4096 +// --chain +// local +// --output +// runtime/src/weights +// --extrinsic +// * +// --pallet +// pallet-balances + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::Weight}; +use sp_std::marker::PhantomData; + +/// Weight functions for `pallet_balances`. +pub struct WeightInfo(PhantomData); +impl pallet_balances::WeightInfo for WeightInfo { + // Storage: System Account (r:1 w:1) + fn transfer() -> Weight { + Weight::from_ref_time(57_141_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + } + // Storage: System Account (r:1 w:1) + fn transfer_keep_alive() -> Weight { + Weight::from_ref_time(43_271_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + } + // Storage: System Account (r:1 w:1) + fn set_balance_creating() -> Weight { + Weight::from_ref_time(29_941_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + } + // Storage: System Account (r:1 w:1) + fn set_balance_killing() -> Weight { + Weight::from_ref_time(34_490_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + } + // Storage: System Account (r:2 w:2) + fn force_transfer() -> Weight { + Weight::from_ref_time(54_911_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + } + // Storage: System Account (r:1 w:1) + fn transfer_all() -> Weight { + Weight::from_ref_time(49_671_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + } + // Storage: System Account (r:1 w:1) + fn force_unreserve() -> Weight { + Weight::from_ref_time(26_120_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + } +} diff --git a/runtime/pangoro/src/weights/pallet_session.rs b/runtime/pangoro/src/weights/pallet_session.rs new file mode 100644 index 00000000..25b1d6d3 --- /dev/null +++ b/runtime/pangoro/src/weights/pallet_session.rs @@ -0,0 +1,69 @@ +// This file is part of Darwinia. +// +// Copyright (C) 2018-2023 Darwinia Network +// SPDX-License-Identifier: GPL-3.0 +// +// Darwinia 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. +// +// Darwinia 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 Darwinia. If not, see . + +//! Autogenerated weights for `pallet_session` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2022-11-09, STEPS: `2`, REPEAT: 1, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `inv.cafe`, CPU: `AMD Ryzen 9 5950X 16-Core Processor` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("local"), DB CACHE: 1024 + +// Executed Command: +// target/release/darwinia +// benchmark +// pallet +// --header +// .maintain/license-header +// --execution +// wasm +// --heap-pages +// 4096 +// --chain +// local +// --output +// runtime/src/weights +// --extrinsic +// * +// --pallet +// pallet-session + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::Weight}; +use sp_std::marker::PhantomData; + +/// Weight functions for `pallet_session`. +pub struct WeightInfo(PhantomData); +impl pallet_session::WeightInfo for WeightInfo { + // Storage: Session NextKeys (r:1 w:1) + // Storage: Session KeyOwner (r:1 w:1) + fn set_keys() -> Weight { + Weight::from_ref_time(30_781_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + } + // Storage: Session NextKeys (r:1 w:1) + // Storage: Session KeyOwner (r:0 w:1) + fn purge_keys() -> Weight { + Weight::from_ref_time(22_911_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + } +} diff --git a/runtime/pangoro/src/weights/pallet_timestamp.rs b/runtime/pangoro/src/weights/pallet_timestamp.rs new file mode 100644 index 00000000..7f420bd5 --- /dev/null +++ b/runtime/pangoro/src/weights/pallet_timestamp.rs @@ -0,0 +1,64 @@ +// This file is part of Darwinia. +// +// Copyright (C) 2018-2023 Darwinia Network +// SPDX-License-Identifier: GPL-3.0 +// +// Darwinia 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. +// +// Darwinia 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 Darwinia. If not, see . + +//! Autogenerated weights for `pallet_timestamp` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2022-11-09, STEPS: `2`, REPEAT: 1, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `inv.cafe`, CPU: `AMD Ryzen 9 5950X 16-Core Processor` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("local"), DB CACHE: 1024 + +// Executed Command: +// target/release/darwinia +// benchmark +// pallet +// --header +// .maintain/license-header +// --execution +// wasm +// --heap-pages +// 4096 +// --chain +// local +// --output +// runtime/src/weights +// --extrinsic +// * +// --pallet +// pallet-timestamp + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::Weight}; +use sp_std::marker::PhantomData; + +/// Weight functions for `pallet_timestamp`. +pub struct WeightInfo(PhantomData); +impl pallet_timestamp::WeightInfo for WeightInfo { + // Storage: Timestamp Now (r:1 w:1) + fn set() -> Weight { + Weight::from_ref_time(13_230_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + } + fn on_finalize() -> Weight { + Weight::from_ref_time(5_710_000 as u64) + } +} diff --git a/runtime/pangoro/src/weights/paritydb_weights.rs b/runtime/pangoro/src/weights/paritydb_weights.rs new file mode 100644 index 00000000..4338d928 --- /dev/null +++ b/runtime/pangoro/src/weights/paritydb_weights.rs @@ -0,0 +1,63 @@ +// This file is part of Substrate. + +// Copyright (C) 2022 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. + +pub mod constants { + use frame_support::{ + parameter_types, + weights::{constants, RuntimeDbWeight}, + }; + + parameter_types! { + /// `ParityDB` can be enabled with a feature flag, but is still experimental. These weights + /// are available for brave runtime engineers who may want to try this out as default. + pub const ParityDbWeight: RuntimeDbWeight = RuntimeDbWeight { + read: 8_000 * constants::WEIGHT_REF_TIME_PER_NANOS, + write: 50_000 * constants::WEIGHT_REF_TIME_PER_NANOS, + }; + } + + #[cfg(test)] + mod test_db_weights { + use super::constants::ParityDbWeight as W; + use frame_support::weights::constants; + + /// Checks that all weights exist and have sane values. + // NOTE: If this test fails but you are sure that the generated values are fine, + // you can delete it. + #[test] + fn sane() { + // At least 1 µs. + assert!( + W::get().reads(1).ref_time() >= constants::WEIGHT_REF_TIME_PER_MICROS, + "Read weight should be at least 1 µs." + ); + assert!( + W::get().writes(1).ref_time() >= constants::WEIGHT_REF_TIME_PER_MICROS, + "Write weight should be at least 1 µs." + ); + // At most 1 ms. + assert!( + W::get().reads(1).ref_time() <= constants::WEIGHT_REF_TIME_PER_MILLIS, + "Read weight should be at most 1 ms." + ); + assert!( + W::get().writes(1).ref_time() <= constants::WEIGHT_REF_TIME_PER_MILLIS, + "Write weight should be at most 1 ms." + ); + } + } +} diff --git a/runtime/pangoro/src/weights/rocksdb_weights.rs b/runtime/pangoro/src/weights/rocksdb_weights.rs new file mode 100644 index 00000000..1d115d96 --- /dev/null +++ b/runtime/pangoro/src/weights/rocksdb_weights.rs @@ -0,0 +1,63 @@ +// This file is part of Substrate. + +// Copyright (C) 2022 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. + +pub mod constants { + use frame_support::{ + parameter_types, + weights::{constants, RuntimeDbWeight}, + }; + + parameter_types! { + /// By default, Substrate uses `RocksDB`, so this will be the weight used throughout + /// the runtime. + pub const RocksDbWeight: RuntimeDbWeight = RuntimeDbWeight { + read: 25_000 * constants::WEIGHT_REF_TIME_PER_NANOS, + write: 100_000 * constants::WEIGHT_REF_TIME_PER_NANOS, + }; + } + + #[cfg(test)] + mod test_db_weights { + use super::constants::RocksDbWeight as W; + use frame_support::weights::constants; + + /// Checks that all weights exist and have sane values. + // NOTE: If this test fails but you are sure that the generated values are fine, + // you can delete it. + #[test] + fn sane() { + // At least 1 µs. + assert!( + W::get().reads(1).ref_time() >= constants::WEIGHT_REF_TIME_PER_MICROS, + "Read weight should be at least 1 µs." + ); + assert!( + W::get().writes(1).ref_time() >= constants::WEIGHT_REF_TIME_PER_MICROS, + "Write weight should be at least 1 µs." + ); + // At most 1 ms. + assert!( + W::get().reads(1).ref_time() <= constants::WEIGHT_REF_TIME_PER_MILLIS, + "Read weight should be at most 1 ms." + ); + assert!( + W::get().writes(1).ref_time() <= constants::WEIGHT_REF_TIME_PER_MILLIS, + "Write weight should be at most 1 ms." + ); + } + } +} diff --git a/runtime/pangoro/tests/mock.rs b/runtime/pangoro/tests/mock.rs new file mode 100644 index 00000000..cc2e8df9 --- /dev/null +++ b/runtime/pangoro/tests/mock.rs @@ -0,0 +1,65 @@ +// This file is part of Darwinia. +// +// Copyright (C) 2018-2022 Darwinia Network +// SPDX-License-Identifier: GPL-3.0 +// +// Darwinia 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. +// +// Darwinia 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 Darwinia. If not, see . + +pub use pangoro_runtime::*; + +// substrate +use frame_support::traits::GenesisBuild; +use sp_io::TestExternalities; + +pub const KTON_ID: u64 = AssetIds::OKton as _; + +#[derive(Clone, Default)] +pub struct ExtBuilder { + balances: Vec<(AccountId, Balance)>, + assets_accounts: Vec<(u64, AccountId, Balance)>, +} +impl ExtBuilder { + pub fn with_balances(&mut self, balances: Vec<(AccountId, Balance)>) -> &mut Self { + self.balances = balances; + + self + } + + pub fn with_assets_accounts(&mut self, accounts: Vec<(u64, AccountId, Balance)>) -> &mut Self { + self.assets_accounts = accounts; + + self + } + + pub fn build(&mut self) -> TestExternalities { + let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); + + pallet_balances::GenesisConfig:: { balances: self.balances.clone() } + .assimilate_storage(&mut t) + .unwrap(); + pallet_assets::GenesisConfig:: { + assets: vec![(KTON_ID, ROOT, true, 1)], + metadata: vec![(KTON_ID, b"Pangoro Commitment Token".to_vec(), b"OKTON".to_vec(), 18)], + accounts: self.assets_accounts.clone(), + } + .assimilate_storage(&mut t) + .unwrap(); + + let mut ext = TestExternalities::new(t); + + ext.execute_with(|| System::set_block_number(1)); + + ext + } +} diff --git a/runtime/pangoro/tests/tests.rs b/runtime/pangoro/tests/tests.rs new file mode 100644 index 00000000..43b5d372 --- /dev/null +++ b/runtime/pangoro/tests/tests.rs @@ -0,0 +1,3 @@ +pub mod mock; + +darwinia_common_runtime::impl_account_migration_tests! {}