Support build-spec for other chains than Polkadot (#1567)

* Support `build-spec` for other chains than Polkadot

The problem when building a chain specification is that you require the
native runtime to parse the json file (assuming the chain spec is not
raw yet). Before this pr we could only overwrite the native runtime when
running the node using `force_*`. This pr now adds support to load the
native runtime when the filename starts with the name of the chain. So,
when usng `build-spec --chain rococo-something-else.jon` it will use the
rococo native runtime to load the chain spec.

* Apply suggestions from code review

Co-authored-by: Andronik Ordian <write@reusable.software>

Co-authored-by: Andronik Ordian <write@reusable.software>
This commit is contained in:
Bastian Köcher
2020-08-11 13:06:53 +02:00
committed by GitHub
parent 4bdfd02f93
commit a12f634e51
3 changed files with 29 additions and 10 deletions
+5 -4
View File
@@ -25,11 +25,12 @@ use std::time::Duration;
use polkadot_primitives::v0::{self as parachain, Hash, BlockId};
#[cfg(feature = "full-node")]
use polkadot_network::{legacy::gossip::Known, protocol as network_protocol};
use service::{error::Error as ServiceError};
use service::error::Error as ServiceError;
use grandpa::{self, FinalityProofProvider as GrandpaFinalityProofProvider};
use sc_executor::native_executor_instance;
use log::info;
use sp_trie::PrefixedMemoryDB;
use prometheus_endpoint::Registry;
pub use service::{
Role, PruningMode, TransactionPoolOptions, Error, RuntimeGenesis, RpcHandlers,
TFullClient, TLightClient, TFullBackend, TLightBackend, TFullCallExecutor, TLightCallExecutor,
@@ -44,14 +45,14 @@ pub use sp_runtime::traits::{HashFor, NumberFor};
pub use consensus_common::{SelectChain, BlockImport, block_validation::Chain};
pub use polkadot_primitives::v0::{Block, CollatorId, ParachainHost};
pub use sp_runtime::traits::{Block as BlockT, self as runtime_traits, BlakeTwo256};
pub use chain_spec::{PolkadotChainSpec, KusamaChainSpec, WestendChainSpec};
pub use chain_spec::{PolkadotChainSpec, KusamaChainSpec, WestendChainSpec, RococoChainSpec};
#[cfg(feature = "full-node")]
pub use consensus::run_validation_worker;
pub use codec::Codec;
pub use polkadot_runtime;
pub use kusama_runtime;
pub use westend_runtime;
use prometheus_endpoint::Registry;
pub use rococo_runtime;
pub use self::client::*;
native_executor_instance!(
@@ -364,7 +365,7 @@ pub fn new_full<RuntimeApi, Executor>(
let polkadot_network_service = network_protocol::start(
network.clone(),
network_protocol::Config {
collating_for: collating_for,
collating_for,
},
(is_known, client.clone()),
client.clone(),