Prefix logs of parachain and relaychain differently + remove light client of relay chain (#109)

This commit is contained in:
Cecile Tonglet
2020-06-11 12:39:20 +02:00
committed by GitHub
parent 0326d049c5
commit 6be8cf3f20
5 changed files with 162 additions and 169 deletions
+150 -147
View File
File diff suppressed because it is too large Load Diff
+1
View File
@@ -18,6 +18,7 @@ parking_lot = '0.9.0'
trie-root = '0.15.2' trie-root = '0.15.2'
codec = { package = 'parity-scale-codec', version = '1.0.0' } codec = { package = 'parity-scale-codec', version = '1.0.0' }
structopt = "0.3.3" structopt = "0.3.3"
ansi_term = "0.12.1"
# Parachain dependencies # Parachain dependencies
parachain-runtime = { package = "cumulus-test-parachain-runtime", path = "runtime" } parachain-runtime = { package = "cumulus-test-parachain-runtime", path = "runtime" }
+4 -4
View File
@@ -20,7 +20,7 @@ use sc_cli;
use structopt::StructOpt; use structopt::StructOpt;
/// Sub-commands supported by the collator. /// Sub-commands supported by the collator.
#[derive(Debug, StructOpt, Clone)] #[derive(Debug, StructOpt)]
pub enum Subcommand { pub enum Subcommand {
#[structopt(flatten)] #[structopt(flatten)]
Base(sc_cli::Subcommand), Base(sc_cli::Subcommand),
@@ -37,14 +37,14 @@ pub enum Subcommand {
} }
/// Command for exporting the genesis state of the parachain /// Command for exporting the genesis state of the parachain
#[derive(Debug, StructOpt, Clone)] #[derive(Debug, StructOpt)]
pub struct ExportGenesisStateCommand { pub struct ExportGenesisStateCommand {
/// Output file name or stdout if unspecified. /// Output file name or stdout if unspecified.
#[structopt(parse(from_os_str))] #[structopt(parse(from_os_str))]
pub output: Option<PathBuf>, pub output: Option<PathBuf>,
} }
#[derive(Debug, StructOpt, Clone)] #[derive(Debug, StructOpt)]
#[structopt(settings = &[ #[structopt(settings = &[
structopt::clap::AppSettings::GlobalVersion, structopt::clap::AppSettings::GlobalVersion,
structopt::clap::AppSettings::ArgsNegateSubcommands, structopt::clap::AppSettings::ArgsNegateSubcommands,
@@ -62,7 +62,7 @@ pub struct Cli {
pub relaychain_args: Vec<String>, pub relaychain_args: Vec<String>,
} }
#[derive(Debug, StructOpt, Clone)] #[derive(Debug, StructOpt)]
pub struct PolkadotCli { pub struct PolkadotCli {
#[structopt(flatten)] #[structopt(flatten)]
pub base: polkadot_cli::RunCmd, pub base: polkadot_cli::RunCmd,
+4 -18
View File
@@ -24,8 +24,7 @@ use sc_cli::{
SubstrateCli, SubstrateCli,
}; };
use sc_executor::NativeExecutionDispatch; use sc_executor::NativeExecutionDispatch;
use sc_network::config::TransportConfig; use sc_service::config::PrometheusConfig;
use sc_service::config::{NetworkConfiguration, NodeKeyConfig, PrometheusConfig};
use sp_core::hexdisplay::HexDisplay; use sp_core::hexdisplay::HexDisplay;
use sp_runtime::{ use sp_runtime::{
traits::{Block as BlockT, Hash as HashT, Header as HeaderT, Zero}, traits::{Block as BlockT, Hash as HashT, Header as HeaderT, Zero},
@@ -186,7 +185,8 @@ pub fn run() -> Result<()> {
None, None,
authority_discovery_enabled, authority_discovery_enabled,
6000, 6000,
grandpa_pause grandpa_pause,
None,
).map(|(s, _, _)| s) ).map(|(s, _, _)| s)
}, },
polkadot_service::PolkadotExecutor::native_version().runtime_version polkadot_service::PolkadotExecutor::native_version().runtime_version
@@ -203,7 +203,6 @@ pub fn run() -> Result<()> {
// TODO // TODO
let key = Arc::new(sp_core::Pair::from_seed(&[10; 32])); let key = Arc::new(sp_core::Pair::from_seed(&[10; 32]));
let key2 = Arc::new(sp_core::Pair::from_seed(&[10; 32]));
let mut polkadot_cli = PolkadotCli::from_iter( let mut polkadot_cli = PolkadotCli::from_iter(
[PolkadotCli::executable_name().to_string()] [PolkadotCli::executable_name().to_string()]
@@ -213,20 +212,7 @@ pub fn run() -> Result<()> {
polkadot_cli.base_path = cli.run.base_path()?.map(|x| x.join("polkadot")); polkadot_cli.base_path = cli.run.base_path()?.map(|x| x.join("polkadot"));
runner.run_node( runner.run_full_node(
|config| {
let task_executor = config.task_executor.clone();
let polkadot_config = SubstrateCli::create_configuration(
&polkadot_cli,
&polkadot_cli,
task_executor,
)
.unwrap();
info!("Parachain id: {:?}", crate::PARA_ID);
crate::service::run_collator(config, key2, polkadot_config)
},
|config| { |config| {
let task_executor = config.task_executor.clone(); let task_executor = config.task_executor.clone();
let polkadot_config = SubstrateCli::create_configuration( let polkadot_config = SubstrateCli::create_configuration(
+3
View File
@@ -14,6 +14,7 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>. // along with Cumulus. If not, see <http://www.gnu.org/licenses/>.
use ansi_term::Color;
use std::sync::Arc; use std::sync::Arc;
use sc_executor::native_executor_instance; use sc_executor::native_executor_instance;
use sc_service::{AbstractService, Configuration}; use sc_service::{AbstractService, Configuration};
@@ -91,6 +92,7 @@ pub fn run_collator(
let block_announce_validator = DelayedBlockAnnounceValidator::new(); let block_announce_validator = DelayedBlockAnnounceValidator::new();
let block_announce_validator_copy = block_announce_validator.clone(); let block_announce_validator_copy = block_announce_validator.clone();
let service = builder let service = builder
.with_informant_prefix(format!("[{}] ", Color::Yellow.bold().paint("Parachain")))?
.with_finality_proof_provider(|client, backend| { .with_finality_proof_provider(|client, backend| {
// GenesisAuthoritySetProvider is implemented for StorageAndProofProvider // GenesisAuthoritySetProvider is implemented for StorageAndProofProvider
let provider = client as Arc<dyn StorageAndProofProvider<_, _>>; let provider = client as Arc<dyn StorageAndProofProvider<_, _>>;
@@ -130,6 +132,7 @@ pub fn run_collator(
crate::PARA_ID, crate::PARA_ID,
key, key,
polkadot_config, polkadot_config,
Some(format!("[{}] ", Color::Blue.bold().paint("Relaychain"))),
).map(|_| ()); ).map(|_| ());
service.spawn_essential_task("polkadot", polkadot_future); service.spawn_essential_task("polkadot", polkadot_future);