difftreelog
Implement autoseal in dev mode
in: master
4 files changed
node/cli/Cargo.tomldiffbeforeafterboth1################################################################################2# Build Dependencies34[build-dependencies.substrate-build-script-utils]5git = 'https://github.com/paritytech/substrate.git'6branch = 'polkadot-v0.9.17'78################################################################################9# Substrate Dependecies1011[dependencies.codec]12default-features = false13features = ['derive']14package = 'parity-scale-codec'15version = '2.3.0'1617[dependencies.frame-benchmarking]18git = 'https://github.com/paritytech/substrate.git'19branch = 'polkadot-v0.9.17'2021[dependencies.frame-benchmarking-cli]22git = 'https://github.com/paritytech/substrate.git'23branch = 'polkadot-v0.9.17'2425[dependencies.pallet-transaction-payment-rpc]26git = 'https://github.com/paritytech/substrate.git'27branch = 'polkadot-v0.9.17'2829[dependencies.substrate-prometheus-endpoint]30git = 'https://github.com/paritytech/substrate.git'31branch = 'polkadot-v0.9.17'3233[dependencies.sc-basic-authorship]34git = 'https://github.com/paritytech/substrate.git'35branch = 'polkadot-v0.9.17'3637[dependencies.sc-chain-spec]38git = 'https://github.com/paritytech/substrate.git'39branch = 'polkadot-v0.9.17'4041[dependencies.sc-cli]42features = ['wasmtime']43git = 'https://github.com/paritytech/substrate.git'44branch = 'polkadot-v0.9.17'4546[dependencies.sc-client-api]47git = 'https://github.com/paritytech/substrate.git'48branch = 'polkadot-v0.9.17'4950[dependencies.sc-consensus]51git = 'https://github.com/paritytech/substrate.git'52branch = 'polkadot-v0.9.17'5354[dependencies.sc-consensus-aura]55git = 'https://github.com/paritytech/substrate.git'56branch = 'polkadot-v0.9.17'5758[dependencies.sc-executor]59features = ['wasmtime']60git = 'https://github.com/paritytech/substrate.git'61branch = 'polkadot-v0.9.17'6263[dependencies.sc-finality-grandpa]64git = 'https://github.com/paritytech/substrate.git'65branch = 'polkadot-v0.9.17'6667[dependencies.sc-keystore]68git = 'https://github.com/paritytech/substrate.git'69branch = 'polkadot-v0.9.17'7071[dependencies.sc-rpc]72git = 'https://github.com/paritytech/substrate.git'73branch = 'polkadot-v0.9.17'7475[dependencies.sc-rpc-api]76git = 'https://github.com/paritytech/substrate.git'77branch = 'polkadot-v0.9.17'7879[dependencies.sc-service]80features = ['wasmtime']81git = 'https://github.com/paritytech/substrate.git'82branch = 'polkadot-v0.9.17'8384[dependencies.sc-telemetry]85git = 'https://github.com/paritytech/substrate.git'86branch = 'polkadot-v0.9.17'8788[dependencies.sc-transaction-pool]89git = 'https://github.com/paritytech/substrate.git'90branch = 'polkadot-v0.9.17'9192[dependencies.sc-tracing]93git = 'https://github.com/paritytech/substrate.git'94branch = 'polkadot-v0.9.17'9596[dependencies.sp-block-builder]97git = 'https://github.com/paritytech/substrate.git'98branch = 'polkadot-v0.9.17'99100[dependencies.sp-api]101git = 'https://github.com/paritytech/substrate.git'102branch = 'polkadot-v0.9.17'103104[dependencies.sp-blockchain]105git = 'https://github.com/paritytech/substrate.git'106branch = 'polkadot-v0.9.17'107108[dependencies.sp-consensus]109git = 'https://github.com/paritytech/substrate.git'110branch = 'polkadot-v0.9.17'111112[dependencies.sp-consensus-aura]113git = 'https://github.com/paritytech/substrate.git'114branch = 'polkadot-v0.9.17'115116[dependencies.sp-core]117git = 'https://github.com/paritytech/substrate.git'118branch = 'polkadot-v0.9.17'119120[dependencies.sp-finality-grandpa]121git = 'https://github.com/paritytech/substrate.git'122branch = 'polkadot-v0.9.17'123124[dependencies.sp-inherents]125git = 'https://github.com/paritytech/substrate.git'126branch = 'polkadot-v0.9.17'127128[dependencies.sp-keystore]129git = 'https://github.com/paritytech/substrate.git'130branch = 'polkadot-v0.9.17'131132[dependencies.sp-offchain]133git = 'https://github.com/paritytech/substrate.git'134branch = 'polkadot-v0.9.17'135136[dependencies.sp-runtime]137git = 'https://github.com/paritytech/substrate.git'138branch = 'polkadot-v0.9.17'139140[dependencies.sp-session]141git = 'https://github.com/paritytech/substrate.git'142branch = 'polkadot-v0.9.17'143144[dependencies.sp-timestamp]145git = 'https://github.com/paritytech/substrate.git'146branch = 'polkadot-v0.9.17'147148[dependencies.sp-transaction-pool]149git = 'https://github.com/paritytech/substrate.git'150branch = 'polkadot-v0.9.17'151152[dependencies.sp-trie]153git = 'https://github.com/paritytech/substrate.git'154branch = 'polkadot-v0.9.17'155156[dependencies.substrate-frame-rpc-system]157git = 'https://github.com/paritytech/substrate.git'158branch = 'polkadot-v0.9.17'159160[dependencies.sc-network]161git = 'https://github.com/paritytech/substrate.git'162branch = 'polkadot-v0.9.17'163164[dependencies.serde]165features = ['derive']166version = '1.0.130'167168[dependencies.serde_json]169version = '1.0.68'170171172################################################################################173# Cumulus dependencies174175[dependencies.cumulus-client-consensus-aura]176git = 'https://github.com/uniqueNetwork/cumulus.git'177branch = 'polkadot-v0.9.17'178179[dependencies.cumulus-client-consensus-common]180git = 'https://github.com/uniqueNetwork/cumulus.git'181branch = 'polkadot-v0.9.17'182183[dependencies.cumulus-client-collator]184git = 'https://github.com/uniqueNetwork/cumulus.git'185branch = 'polkadot-v0.9.17'186187[dependencies.cumulus-client-cli]188git = 'https://github.com/uniqueNetwork/cumulus.git'189branch = 'polkadot-v0.9.17'190191[dependencies.cumulus-client-network]192git = 'https://github.com/uniqueNetwork/cumulus.git'193branch = 'polkadot-v0.9.17'194195[dependencies.cumulus-primitives-core]196git = 'https://github.com/uniqueNetwork/cumulus.git'197branch = 'polkadot-v0.9.17'198199[dependencies.cumulus-primitives-parachain-inherent]200git = 'https://github.com/uniqueNetwork/cumulus.git'201branch = 'polkadot-v0.9.17'202203[dependencies.cumulus-client-service]204git = 'https://github.com/uniqueNetwork/cumulus.git'205branch = 'polkadot-v0.9.17'206207[dependencies.cumulus-relay-chain-interface]208git = 'https://github.com/uniqueNetwork/cumulus.git'209branch = 'polkadot-v0.9.17'210211[dependencies.cumulus-relay-chain-local]212git = 'https://github.com/uniqueNetwork/cumulus.git'213branch = 'polkadot-v0.9.17'214215################################################################################216# Polkadot dependencies217[dependencies.polkadot-primitives]218git = "https://github.com/paritytech/polkadot"219branch = 'release-v0.9.17'220221[dependencies.polkadot-service]222git = "https://github.com/paritytech/polkadot"223branch = 'release-v0.9.17'224225[dependencies.polkadot-cli]226git = "https://github.com/paritytech/polkadot"227branch = 'release-v0.9.17'228229[dependencies.polkadot-test-service]230git = "https://github.com/paritytech/polkadot"231branch = 'release-v0.9.17'232233[dependencies.polkadot-parachain]234git = "https://github.com/paritytech/polkadot"235branch = 'release-v0.9.17'236237238################################################################################239# Local dependencies240241[dependencies.unique-runtime-common]242default-features = false243path = "../../runtime/common"244245[dependencies.unique-runtime]246path = '../../runtime/unique'247optional = true248249[dependencies.quartz-runtime]250path = '../../runtime/quartz'251optional = true252253[dependencies.opal-runtime]254path = '../../runtime/opal'255256[dependencies.up-data-structs]257path = "../../primitives/data-structs"258default-features = false259260[dependencies.up-rpc]261path = "../../primitives/rpc"262263[dependencies.pallet-transaction-payment-rpc-runtime-api]264git = 'https://github.com/paritytech/substrate.git'265branch = 'polkadot-v0.9.17'266267################################################################################268# Package269270[package]271authors = ['Unique Network <support@uniquenetwork.io>']272build = 'build.rs'273description = 'Unique Node'274edition = '2021'275homepage = 'https://unique.network'276license = 'GPLv3'277name = 'unique-node'278repository = 'https://github.com/UniqueNetwork/unique-chain'279version = '0.9.17'280281[[bin]]282name = 'unique-collator'283path = "src/main.rs"284285[package.metadata.docs.rs]286targets = ['x86_64-unknown-linux-gnu']287288[dependencies]289futures = '0.3.17'290log = '0.4.14'291flexi_logger = "0.15.7"292parking_lot = '0.11.2'293clap = "3.1.2"294jsonrpc-core = '18.0.0'295jsonrpc-pubsub = "18.0.0"296297fc-rpc-core = { git = "https://github.com/uniquenetwork/frontier.git", branch = "unique-polkadot-v0.9.17" }298fc-consensus = { git = "https://github.com/uniquenetwork/frontier.git", branch = "unique-polkadot-v0.9.17" }299fc-mapping-sync = { git = "https://github.com/uniquenetwork/frontier.git", branch = "unique-polkadot-v0.9.17" }300fc-rpc = { git = "https://github.com/uniquenetwork/frontier.git", branch = "unique-polkadot-v0.9.17" }301fc-db = { git = "https://github.com/uniquenetwork/frontier.git", branch = "unique-polkadot-v0.9.17" }302fp-rpc = { git = "https://github.com/uniquenetwork/frontier.git", branch = "unique-polkadot-v0.9.17" }303pallet-ethereum = { git = "https://github.com/uniquenetwork/frontier.git", branch = "unique-polkadot-v0.9.17" }304305unique-rpc = { default-features = false, path = "../rpc" }306307[features]308default = ["unique-runtime", "quartz-runtime"]309runtime-benchmarks = [310 'unique-runtime/runtime-benchmarks',311 'polkadot-service/runtime-benchmarks',312]1################################################################################2# Build Dependencies34[build-dependencies.substrate-build-script-utils]5git = 'https://github.com/paritytech/substrate.git'6branch = 'polkadot-v0.9.17'78################################################################################9# Substrate Dependecies1011[dependencies.codec]12default-features = false13features = ['derive']14package = 'parity-scale-codec'15version = '2.3.0'1617[dependencies.frame-benchmarking]18git = 'https://github.com/paritytech/substrate.git'19branch = 'polkadot-v0.9.17'2021[dependencies.frame-benchmarking-cli]22git = 'https://github.com/paritytech/substrate.git'23branch = 'polkadot-v0.9.17'2425[dependencies.pallet-transaction-payment-rpc]26git = 'https://github.com/paritytech/substrate.git'27branch = 'polkadot-v0.9.17'2829[dependencies.substrate-prometheus-endpoint]30git = 'https://github.com/paritytech/substrate.git'31branch = 'polkadot-v0.9.17'3233[dependencies.sc-basic-authorship]34git = 'https://github.com/paritytech/substrate.git'35branch = 'polkadot-v0.9.17'3637[dependencies.sc-chain-spec]38git = 'https://github.com/paritytech/substrate.git'39branch = 'polkadot-v0.9.17'4041[dependencies.sc-cli]42features = ['wasmtime']43git = 'https://github.com/paritytech/substrate.git'44branch = 'polkadot-v0.9.17'4546[dependencies.sc-client-api]47git = 'https://github.com/paritytech/substrate.git'48branch = 'polkadot-v0.9.17'4950[dependencies.sc-consensus]51git = 'https://github.com/paritytech/substrate.git'52branch = 'polkadot-v0.9.17'5354[dependencies.sc-consensus-aura]55git = 'https://github.com/paritytech/substrate.git'56branch = 'polkadot-v0.9.17'5758[dependencies.sc-executor]59features = ['wasmtime']60git = 'https://github.com/paritytech/substrate.git'61branch = 'polkadot-v0.9.17'6263[dependencies.sc-finality-grandpa]64git = 'https://github.com/paritytech/substrate.git'65branch = 'polkadot-v0.9.17'6667[dependencies.sc-keystore]68git = 'https://github.com/paritytech/substrate.git'69branch = 'polkadot-v0.9.17'7071[dependencies.sc-rpc]72git = 'https://github.com/paritytech/substrate.git'73branch = 'polkadot-v0.9.17'7475[dependencies.sc-rpc-api]76git = 'https://github.com/paritytech/substrate.git'77branch = 'polkadot-v0.9.17'7879[dependencies.sc-service]80features = ['wasmtime']81git = 'https://github.com/paritytech/substrate.git'82branch = 'polkadot-v0.9.17'8384[dependencies.sc-telemetry]85git = 'https://github.com/paritytech/substrate.git'86branch = 'polkadot-v0.9.17'8788[dependencies.sc-transaction-pool]89git = 'https://github.com/paritytech/substrate.git'90branch = 'polkadot-v0.9.17'9192[dependencies.sc-tracing]93git = 'https://github.com/paritytech/substrate.git'94branch = 'polkadot-v0.9.17'9596[dependencies.sp-block-builder]97git = 'https://github.com/paritytech/substrate.git'98branch = 'polkadot-v0.9.17'99100[dependencies.sp-api]101git = 'https://github.com/paritytech/substrate.git'102branch = 'polkadot-v0.9.17'103104[dependencies.sp-blockchain]105git = 'https://github.com/paritytech/substrate.git'106branch = 'polkadot-v0.9.17'107108[dependencies.sp-consensus]109git = 'https://github.com/paritytech/substrate.git'110branch = 'polkadot-v0.9.17'111112[dependencies.sp-consensus-aura]113git = 'https://github.com/paritytech/substrate.git'114branch = 'polkadot-v0.9.17'115116[dependencies.sp-core]117git = 'https://github.com/paritytech/substrate.git'118branch = 'polkadot-v0.9.17'119120[dependencies.sp-finality-grandpa]121git = 'https://github.com/paritytech/substrate.git'122branch = 'polkadot-v0.9.17'123124[dependencies.sp-inherents]125git = 'https://github.com/paritytech/substrate.git'126branch = 'polkadot-v0.9.17'127128[dependencies.sp-keystore]129git = 'https://github.com/paritytech/substrate.git'130branch = 'polkadot-v0.9.17'131132[dependencies.sp-offchain]133git = 'https://github.com/paritytech/substrate.git'134branch = 'polkadot-v0.9.17'135136[dependencies.sp-runtime]137git = 'https://github.com/paritytech/substrate.git'138branch = 'polkadot-v0.9.17'139140[dependencies.sp-session]141git = 'https://github.com/paritytech/substrate.git'142branch = 'polkadot-v0.9.17'143144[dependencies.sp-timestamp]145git = 'https://github.com/paritytech/substrate.git'146branch = 'polkadot-v0.9.17'147148[dependencies.sp-transaction-pool]149git = 'https://github.com/paritytech/substrate.git'150branch = 'polkadot-v0.9.17'151152[dependencies.sp-trie]153git = 'https://github.com/paritytech/substrate.git'154branch = 'polkadot-v0.9.17'155156[dependencies.substrate-frame-rpc-system]157git = 'https://github.com/paritytech/substrate.git'158branch = 'polkadot-v0.9.17'159160[dependencies.sc-network]161git = 'https://github.com/paritytech/substrate.git'162branch = 'polkadot-v0.9.17'163164[dependencies.serde]165features = ['derive']166version = '1.0.130'167168[dependencies.serde_json]169version = '1.0.68'170171[dependencies.sc-consensus-manual-seal]172git = 'https://github.com/paritytech/substrate.git'173branch = 'polkadot-v0.9.17'174175################################################################################176# Cumulus dependencies177178[dependencies.cumulus-client-consensus-aura]179git = 'https://github.com/uniqueNetwork/cumulus.git'180branch = 'polkadot-v0.9.17'181182[dependencies.cumulus-client-consensus-common]183git = 'https://github.com/uniqueNetwork/cumulus.git'184branch = 'polkadot-v0.9.17'185186[dependencies.cumulus-client-collator]187git = 'https://github.com/uniqueNetwork/cumulus.git'188branch = 'polkadot-v0.9.17'189190[dependencies.cumulus-client-cli]191git = 'https://github.com/uniqueNetwork/cumulus.git'192branch = 'polkadot-v0.9.17'193194[dependencies.cumulus-client-network]195git = 'https://github.com/uniqueNetwork/cumulus.git'196branch = 'polkadot-v0.9.17'197198[dependencies.cumulus-primitives-core]199git = 'https://github.com/uniqueNetwork/cumulus.git'200branch = 'polkadot-v0.9.17'201202[dependencies.cumulus-primitives-parachain-inherent]203git = 'https://github.com/uniqueNetwork/cumulus.git'204branch = 'polkadot-v0.9.17'205206[dependencies.cumulus-client-service]207git = 'https://github.com/uniqueNetwork/cumulus.git'208branch = 'polkadot-v0.9.17'209210[dependencies.cumulus-relay-chain-interface]211git = 'https://github.com/uniqueNetwork/cumulus.git'212branch = 'polkadot-v0.9.17'213214[dependencies.cumulus-relay-chain-local]215git = 'https://github.com/uniqueNetwork/cumulus.git'216branch = 'polkadot-v0.9.17'217218################################################################################219# Polkadot dependencies220[dependencies.polkadot-primitives]221git = "https://github.com/paritytech/polkadot"222branch = 'release-v0.9.17'223224[dependencies.polkadot-service]225git = "https://github.com/paritytech/polkadot"226branch = 'release-v0.9.17'227228[dependencies.polkadot-cli]229git = "https://github.com/paritytech/polkadot"230branch = 'release-v0.9.17'231232[dependencies.polkadot-test-service]233git = "https://github.com/paritytech/polkadot"234branch = 'release-v0.9.17'235236[dependencies.polkadot-parachain]237git = "https://github.com/paritytech/polkadot"238branch = 'release-v0.9.17'239240241################################################################################242# Local dependencies243244[dependencies.unique-runtime-common]245default-features = false246path = "../../runtime/common"247248[dependencies.unique-runtime]249path = '../../runtime/unique'250optional = true251252[dependencies.quartz-runtime]253path = '../../runtime/quartz'254optional = true255256[dependencies.opal-runtime]257path = '../../runtime/opal'258259[dependencies.up-data-structs]260path = "../../primitives/data-structs"261default-features = false262263[dependencies.up-rpc]264path = "../../primitives/rpc"265266[dependencies.pallet-transaction-payment-rpc-runtime-api]267git = 'https://github.com/paritytech/substrate.git'268branch = 'polkadot-v0.9.17'269270################################################################################271# Package272273[package]274authors = ['Unique Network <support@uniquenetwork.io>']275build = 'build.rs'276description = 'Unique Node'277edition = '2021'278homepage = 'https://unique.network'279license = 'GPLv3'280name = 'unique-node'281repository = 'https://github.com/UniqueNetwork/unique-chain'282version = '0.9.17'283284[[bin]]285name = 'unique-collator'286path = "src/main.rs"287288[package.metadata.docs.rs]289targets = ['x86_64-unknown-linux-gnu']290291[dependencies]292futures = '0.3.17'293log = '0.4.14'294flexi_logger = "0.15.7"295parking_lot = '0.11.2'296clap = "3.1.2"297jsonrpc-core = '18.0.0'298jsonrpc-pubsub = "18.0.0"299300fc-rpc-core = { git = "https://github.com/uniquenetwork/frontier.git", branch = "unique-polkadot-v0.9.17" }301fc-consensus = { git = "https://github.com/uniquenetwork/frontier.git", branch = "unique-polkadot-v0.9.17" }302fc-mapping-sync = { git = "https://github.com/uniquenetwork/frontier.git", branch = "unique-polkadot-v0.9.17" }303fc-rpc = { git = "https://github.com/uniquenetwork/frontier.git", branch = "unique-polkadot-v0.9.17" }304fc-db = { git = "https://github.com/uniquenetwork/frontier.git", branch = "unique-polkadot-v0.9.17" }305fp-rpc = { git = "https://github.com/uniquenetwork/frontier.git", branch = "unique-polkadot-v0.9.17" }306pallet-ethereum = { git = "https://github.com/uniquenetwork/frontier.git", branch = "unique-polkadot-v0.9.17" }307308unique-rpc = { default-features = false, path = "../rpc" }309310[features]311default = ["unique-runtime", "quartz-runtime"]312runtime-benchmarks = [313 'unique-runtime/runtime-benchmarks',314 'polkadot-service/runtime-benchmarks',315]node/cli/src/chain_spec.rsdiffbeforeafterboth--- a/node/cli/src/chain_spec.rs
+++ b/node/cli/src/chain_spec.rs
@@ -68,6 +68,25 @@
}
}
+pub enum ServiceId {
+ Prod,
+ Dev
+}
+
+pub trait ServiceIdentification {
+ fn service_id(&self) -> ServiceId;
+}
+
+impl ServiceIdentification for Box<dyn sc_service::ChainSpec> {
+ fn service_id(&self) -> ServiceId {
+ if self.id().ends_with("dev") {
+ ServiceId::Dev
+ } else {
+ ServiceId::Prod
+ }
+ }
+}
+
/// Helper function to generate a crypto pair from seed
pub fn get_from_seed<TPublic: Public>(seed: &str) -> <TPublic::Pair as Pair>::Public {
TPublic::Pair::from_string(&format!("//{}", seed), None)
node/cli/src/command.rsdiffbeforeafterboth--- a/node/cli/src/command.rs
+++ b/node/cli/src/command.rs
@@ -33,9 +33,9 @@
// limitations under the License.
use crate::{
- chain_spec::{self, RuntimeId, RuntimeIdentification},
+ chain_spec::{self, RuntimeId, RuntimeIdentification, ServiceId, ServiceIdentification},
cli::{Cli, RelayChainCli, Subcommand},
- service::new_partial,
+ service::{new_partial, start_node, start_dev_node},
};
#[cfg(feature = "unique-runtime")]
@@ -210,6 +210,7 @@
>(
&$config,
crate::service::parachain_build_import_queue,
+ ServiceId::Prod,
)?;
let task_manager = $components.task_manager;
@@ -245,6 +246,34 @@
}}
}
+macro_rules! start_node_using_chain_runtime {
+ ($start_node_fn:ident($config:expr $(, $($args:expr),+)?) $($code:tt)*) => {
+ match $config.chain_spec.runtime_id() {
+ #[cfg(feature = "unique-runtime")]
+ RuntimeId::Unique => $start_node_fn::<
+ unique_runtime::Runtime,
+ unique_runtime::RuntimeApi,
+ UniqueRuntimeExecutor,
+ >($config $(, $($args),+)?) $($code)*,
+
+ #[cfg(feature = "quartz-runtime")]
+ RuntimeId::Quartz => $start_node_fn::<
+ quartz_runtime::Runtime,
+ quartz_runtime::RuntimeApi,
+ QuartzRuntimeExecutor,
+ >($config $(, $($args),+)?) $($code)*,
+
+ RuntimeId::Opal => $start_node_fn::<
+ opal_runtime::Runtime,
+ opal_runtime::RuntimeApi,
+ OpalRuntimeExecutor,
+ >($config $(, $($args),+)?) $($code)*,
+
+ RuntimeId::Unknown(chain) => Err(no_runtime_err!(chain).into()),
+ }
+ };
+}
+
/// Parse command line arguments into service configuration.
pub fn run() -> Result<()> {
let cli = Cli::from_args();
@@ -365,7 +394,20 @@
let runner = cli.create_runner(&cli.run.normalize())?;
runner.run_node_until_exit(|config| async move {
- let para_id = chain_spec::Extensions::try_get(&*config.chain_spec)
+ let extensions = chain_spec::Extensions::try_get(&*config.chain_spec);
+
+ let service_id = config.chain_spec.service_id();
+ let relay_chain_id = extensions.map(|e| e.relay_chain.clone());
+ let is_dev_service = matches![service_id, ServiceId::Dev]
+ || relay_chain_id == Some("dev-service".into());
+
+ if is_dev_service {
+ return start_node_using_chain_runtime! {
+ start_dev_node(config).map_err(Into::into)
+ };
+ };
+
+ let para_id = extensions
.map(|e| e.para_id)
.ok_or("Could not find parachain ID in chain-spec.")?;
@@ -376,10 +418,10 @@
.chain(cli.relaychain_args.iter()),
);
- let id = ParaId::from(para_id);
+ let para_id = ParaId::from(para_id);
let parachain_account =
- AccountIdConversion::<polkadot_primitives::v0::AccountId>::into_account(&id);
+ AccountIdConversion::<polkadot_primitives::v0::AccountId>::into_account(¶_id);
let state_version =
RelayChainCli::native_runtime_version(&config.chain_spec).state_version();
@@ -395,7 +437,7 @@
)
.map_err(|err| format!("Relay chain argument error: {}", err))?;
- info!("Parachain id: {:?}", id);
+ info!("Parachain id: {:?}", para_id);
info!("Parachain Account: {}", parachain_account);
info!("Parachain genesis state: {}", genesis_state);
info!("Parachain genesis hash: {}", genesis_hash);
@@ -408,37 +450,11 @@
}
);
- match config.chain_spec.runtime_id() {
- #[cfg(feature = "unique-runtime")]
- RuntimeId::Unique => crate::service::start_node::<
- unique_runtime::Runtime,
- unique_runtime::RuntimeApi,
- UniqueRuntimeExecutor,
- >(config, polkadot_config, id)
- .await
- .map(|r| r.0)
- .map_err(Into::into),
-
- #[cfg(feature = "quartz-runtime")]
- RuntimeId::Quartz => crate::service::start_node::<
- quartz_runtime::Runtime,
- quartz_runtime::RuntimeApi,
- QuartzRuntimeExecutor,
- >(config, polkadot_config, id)
- .await
- .map(|r| r.0)
- .map_err(Into::into),
-
- RuntimeId::Opal => crate::service::start_node::<
- opal_runtime::Runtime,
- opal_runtime::RuntimeApi,
- OpalRuntimeExecutor,
- >(config, polkadot_config, id)
- .await
- .map(|r| r.0)
- .map_err(Into::into),
-
- RuntimeId::Unknown(chain) => Err(no_runtime_err!(chain).into()),
+ start_node_using_chain_runtime! {
+ start_node(config, polkadot_config, para_id)
+ .await
+ .map(|r| r.0)
+ .map_err(Into::into)
}
})
}
node/cli/src/service.rsdiffbeforeafterboth--- a/node/cli/src/service.rs
+++ b/node/cli/src/service.rs
@@ -57,6 +57,7 @@
use fc_mapping_sync::{MappingSyncWorker, SyncStrategy};
use unique_runtime_common::types::{AuraId, RuntimeInstance, AccountId, Balance, Index, Hash, Block};
+use crate::chain_spec::ServiceId;
/// Native executor instance.
pub struct UniqueRuntimeExecutor;
@@ -125,6 +126,7 @@
sc_service::TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<ExecutorDispatch>>;
type FullBackend = sc_service::TFullBackend<Block>;
type FullSelectChain = sc_consensus::LongestChain<FullBackend, Block>;
+type MaybeSelectChain = Option<FullSelectChain>;
/// Starts a `ServiceBuilder` for a full service.
///
@@ -134,11 +136,12 @@
pub fn new_partial<RuntimeApi, ExecutorDispatch, BIQ>(
config: &Configuration,
build_import_queue: BIQ,
+ service_id: ServiceId,
) -> Result<
PartialComponents<
FullClient<RuntimeApi, ExecutorDispatch>,
FullBackend,
- FullSelectChain,
+ MaybeSelectChain,
sc_consensus::DefaultImportQueue<Block, FullClient<RuntimeApi, ExecutorDispatch>>,
sc_transaction_pool::FullPool<Block, FullClient<RuntimeApi, ExecutorDispatch>>,
(
@@ -215,7 +218,10 @@
telemetry
});
- let select_chain = sc_consensus::LongestChain::new(backend.clone());
+ let select_chain = match service_id {
+ ServiceId::Prod => Some(sc_consensus::LongestChain::new(backend.clone())),
+ ServiceId::Dev => None
+ };
let transaction_pool = sc_transaction_pool::BasicPool::new_full(
config.transaction_pool.clone(),
@@ -317,7 +323,9 @@
let parachain_config = prepare_node_config(parachain_config);
let params =
- new_partial::<RuntimeApi, ExecutorDispatch, BIQ>(¶chain_config, build_import_queue)?;
+ new_partial::<RuntimeApi, ExecutorDispatch, BIQ>(
+ ¶chain_config, build_import_queue, ServiceId::Prod
+ )?;
let (mut telemetry, filter_pool, frontier_backend, telemetry_worker_handle, fee_history_cache) =
params.other;
@@ -356,7 +364,9 @@
let subscription_executor = sc_rpc::SubscriptionTaskExecutor::new(task_manager.spawn_handle());
let rpc_client = client.clone();
let rpc_pool = transaction_pool.clone();
- let select_chain = params.select_chain.clone();
+ let select_chain = params.select_chain
+ .expect("select_chain always exists when running Prod service; qed")
+ .clone();
let rpc_network = network.clone();
let rpc_frontier_backend = frontier_backend.clone();
@@ -638,3 +648,255 @@
)
.await
}
+
+fn dev_build_import_queue<RuntimeApi, ExecutorDispatch>(
+ client: Arc<FullClient<RuntimeApi, ExecutorDispatch>>,
+ config: &Configuration,
+ _: Option<TelemetryHandle>,
+ task_manager: &TaskManager,
+) -> Result<sc_consensus::DefaultImportQueue<Block, FullClient<RuntimeApi, ExecutorDispatch>>, sc_service::Error>
+where
+ RuntimeApi: sp_api::ConstructRuntimeApi<Block, FullClient<RuntimeApi, ExecutorDispatch>>
+ + Send
+ + Sync
+ + 'static,
+ RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block>
+ + sp_api::ApiExt<Block, StateBackend = sc_client_api::StateBackendFor<FullBackend, Block>>,
+ ExecutorDispatch: NativeExecutionDispatch + 'static,
+{
+ Ok(sc_consensus_manual_seal::import_queue(
+ Box::new(client.clone()),
+ &task_manager.spawn_essential_handle(),
+ config.prometheus_registry(),
+ ))
+}
+
+/// Builds a new development service. This service uses instant seal, and mocks
+/// the parachain inherent
+pub fn start_dev_node<Runtime, RuntimeApi, ExecutorDispatch>(config: Configuration)
+ -> sc_service::error::Result<TaskManager>
+where
+ Runtime: RuntimeInstance + Send + Sync + 'static,
+ <Runtime as RuntimeInstance>::CrossAccountId: Serialize,
+ for<'de> <Runtime as RuntimeInstance>::CrossAccountId: Deserialize<'de>,
+ RuntimeApi: sp_api::ConstructRuntimeApi<Block, FullClient<RuntimeApi, ExecutorDispatch>>
+ + Send
+ + Sync
+ + 'static,
+ RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block>
+ + fp_rpc::EthereumRuntimeRPCApi<Block>
+ + sp_session::SessionKeys<Block>
+ + sp_block_builder::BlockBuilder<Block>
+ + pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance>
+ + sp_api::ApiExt<Block, StateBackend = sc_client_api::StateBackendFor<FullBackend, Block>>
+ + up_rpc::UniqueApi<Block, Runtime::CrossAccountId, AccountId>
+ + substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Index>
+ + sp_api::Metadata<Block>
+ + sp_offchain::OffchainWorkerApi<Block>
+ + cumulus_primitives_core::CollectCollationInfo<Block>
+ + sp_consensus_aura::AuraApi<Block, AuraId>,
+ ExecutorDispatch: NativeExecutionDispatch + 'static,
+{
+ use futures::Stream;
+ use sc_consensus_manual_seal::{run_manual_seal, EngineCommand, ManualSealParams};
+ use fc_consensus::FrontierBlockImport;
+ use sc_client_api::HeaderBackend;
+
+ let sc_service::PartialComponents {
+ client,
+ backend,
+ mut task_manager,
+ import_queue,
+ keystore_container,
+ select_chain: maybe_select_chain,
+ transaction_pool,
+ other:
+ (
+ telemetry,
+ filter_pool,
+ frontier_backend,
+ _telemetry_worker_handle,
+ fee_history_cache,
+ ),
+ } = new_partial::<RuntimeApi, ExecutorDispatch, _>(
+ &config,
+ dev_build_import_queue::<RuntimeApi, ExecutorDispatch>,
+ ServiceId::Dev
+ )?;
+
+ let block_data_cache = Arc::new(fc_rpc::EthBlockDataCache::new(
+ task_manager.spawn_handle(),
+ overrides_handle::<_, _, Runtime>(client.clone()),
+ 50,
+ 50,
+ ));
+
+ let (network, system_rpc_tx, network_starter) =
+ sc_service::build_network(sc_service::BuildNetworkParams {
+ config: &config,
+ client: client.clone(),
+ transaction_pool: transaction_pool.clone(),
+ spawn_handle: task_manager.spawn_handle(),
+ import_queue,
+ block_announce_validator_builder: None,
+ warp_sync: None,
+ })?;
+
+ if config.offchain_worker.enabled {
+ sc_service::build_offchain_workers(
+ &config,
+ task_manager.spawn_handle(),
+ client.clone(),
+ network.clone(),
+ );
+ }
+
+ let prometheus_registry = config.prometheus_registry().cloned();
+ let collator = config.role.is_authority();
+
+ let select_chain = maybe_select_chain.clone().expect(
+ "`new_partial` builds a `LongestChainRule` when building dev service.\
+ We specified the dev service when calling `new_partial`.\
+ Therefore, a `LongestChainRule` is present. qed.",
+ );
+
+ if collator {
+ let block_import =
+ FrontierBlockImport::new(client.clone(), client.clone(), frontier_backend.clone());
+
+ let env = sc_basic_authorship::ProposerFactory::new(
+ task_manager.spawn_handle(),
+ client.clone(),
+ transaction_pool.clone(),
+ prometheus_registry.as_ref(),
+ telemetry.as_ref().map(|x| x.handle()),
+ );
+
+ let commands_stream: Box<dyn Stream<Item = EngineCommand<Hash>> + Send + Sync + Unpin> =
+ Box::new(
+ // This bit cribbed from the implementation of instant seal.
+ transaction_pool
+ .pool()
+ .validated_pool()
+ .import_notification_stream()
+ .map(|_| EngineCommand::SealNewBlock {
+ create_empty: true, // was false in Moonbeam
+ finalize: false,
+ parent_hash: None,
+ sender: None,
+ }),
+ );
+
+ let slot_duration = cumulus_client_consensus_aura::slot_duration(&*client)?;
+ let client_set_aside_for_cidp = client.clone();
+
+ task_manager.spawn_essential_handle().spawn_blocking(
+ "authorship_task",
+ Some("block-authoring"),
+ run_manual_seal(ManualSealParams {
+ block_import,
+ env,
+ client: client.clone(),
+ pool: transaction_pool.clone(),
+ commands_stream,
+ select_chain: select_chain.clone(),
+ consensus_data_provider: None,
+ create_inherent_data_providers: move |block: Hash, ()| {
+ let current_para_block = client_set_aside_for_cidp
+ .number(block)
+ .expect("Header lookup should succeed")
+ .expect("Header passed in as parent should be present in backend.");
+
+ let client_for_xcm = client_set_aside_for_cidp.clone();
+ async move {
+ let time = sp_timestamp::InherentDataProvider::from_system_time();
+
+ let mocked_parachain = cumulus_primitives_parachain_inherent::MockValidationDataInherentDataProvider {
+ current_para_block,
+ relay_offset: 1000,
+ relay_blocks_per_para_block: 2,
+ xcm_config: cumulus_primitives_parachain_inherent::MockXcmConfig::new(
+ &*client_for_xcm,
+ block,
+ Default::default(),
+ Default::default(),
+ ),
+ raw_downward_messages: vec![],
+ raw_horizontal_messages: vec![],
+ };
+
+ let slot =
+ sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_duration(
+ *time,
+ slot_duration.slot_duration(),
+ );
+
+ Ok((time, slot, mocked_parachain))
+ }
+ },
+ }),
+ );
+ }
+
+ task_manager.spawn_essential_handle().spawn(
+ "frontier-mapping-sync-worker",
+ Some("block-authoring"),
+ MappingSyncWorker::new(
+ client.import_notification_stream(),
+ Duration::new(6, 0),
+ client.clone(),
+ backend.clone(),
+ frontier_backend.clone(),
+ SyncStrategy::Normal,
+ )
+ .for_each(|()| futures::future::ready(())),
+ );
+
+ let subscription_executor = sc_rpc::SubscriptionTaskExecutor::new(task_manager.spawn_handle());
+ let rpc_client = client.clone();
+ let rpc_pool = transaction_pool.clone();
+ let rpc_network = network.clone();
+ let rpc_frontier_backend = frontier_backend.clone();
+ let rpc_extensions_builder = Box::new(move |deny_unsafe, _| {
+ let full_deps = unique_rpc::FullDeps {
+ backend: rpc_frontier_backend.clone(),
+ deny_unsafe,
+ client: rpc_client.clone(),
+ pool: rpc_pool.clone(),
+ graph: rpc_pool.pool().clone(),
+ // TODO: Unhardcode
+ enable_dev_signer: false,
+ filter_pool: filter_pool.clone(),
+ network: rpc_network.clone(),
+ select_chain: select_chain.clone(),
+ is_authority: collator,
+ // TODO: Unhardcode
+ max_past_logs: 10000,
+ block_data_cache: block_data_cache.clone(),
+ fee_history_cache: fee_history_cache.clone(),
+ // TODO: Unhardcode
+ fee_history_limit: 2048,
+ };
+
+ Ok(unique_rpc::create_full::<_, _, _, _, Runtime, RuntimeApi, _>(
+ full_deps,
+ subscription_executor.clone(),
+ ))
+ });
+
+ sc_service::spawn_tasks(sc_service::SpawnTasksParams {
+ network,
+ client,
+ keystore: keystore_container.sync_keystore(),
+ task_manager: &mut task_manager,
+ transaction_pool,
+ rpc_extensions_builder,
+ backend,
+ system_rpc_tx,
+ config,
+ telemetry: None,
+ })?;
+
+ network_starter.start_network();
+ Ok(task_manager)
+}