Skip to content
Snippets Groups Projects
Unverified Commit 40afc77c authored by Javier Viola's avatar Javier Viola Committed by GitHub
Browse files

Add output positional arg to undying-collator cli (#2375)


Follow up from https://github.com/paritytech/polkadot-sdk/pull/2370 to
add `output` positional argument to undying-collator.

cc @JoshOrndorff

---------

Co-authored-by: default avatarBastian Köcher <git@kchr.de>
parent 06190498
No related merge requests found
Pipeline #416379 canceled with stages
in 11 minutes and 40 seconds
......@@ -18,6 +18,7 @@
use clap::Parser;
use sc_cli::SubstrateCli;
use std::path::PathBuf;
/// Sub-commands supported by the collator.
#[derive(Debug, Parser)]
......@@ -34,6 +35,10 @@ pub enum Subcommand {
/// Command for exporting the genesis state of the parachain
#[derive(Debug, Parser)]
pub struct ExportGenesisStateCommand {
/// Output file name or stdout if unspecified.
#[arg()]
pub output: Option<PathBuf>,
/// Id of the parachain this collator collates for.
#[arg(long, default_value_t = 100)]
pub parachain_id: u32,
......@@ -50,7 +55,11 @@ pub struct ExportGenesisStateCommand {
/// Command for exporting the genesis wasm file.
#[derive(Debug, Parser)]
pub struct ExportGenesisWasmCommand {}
pub struct ExportGenesisWasmCommand {
/// Output file name or stdout if unspecified.
#[arg()]
pub output: Option<PathBuf>,
}
#[allow(missing_docs)]
#[derive(Debug, Parser)]
......
......@@ -22,6 +22,10 @@ use polkadot_node_subsystem::messages::{CollationGenerationMessage, CollatorProt
use polkadot_primitives::Id as ParaId;
use sc_cli::{Error as SubstrateCliError, SubstrateCli};
use sp_core::hexdisplay::HexDisplay;
use std::{
fs,
io::{self, Write},
};
use test_parachain_undying_collator::Collator;
mod cli;
......@@ -35,14 +39,30 @@ fn main() -> Result<()> {
// `pov_size` and `pvf_complexity` need to match the ones that we start the collator
// with.
let collator = Collator::new(params.pov_size, params.pvf_complexity);
println!("0x{:?}", HexDisplay::from(&collator.genesis_head()));
let output_buf =
format!("0x{:?}", HexDisplay::from(&collator.genesis_head())).into_bytes();
if let Some(output) = params.output {
std::fs::write(output, output_buf)?;
} else {
std::io::stdout().write_all(&output_buf)?;
}
Ok::<_, Error>(())
},
Some(cli::Subcommand::ExportGenesisWasm(_params)) => {
Some(cli::Subcommand::ExportGenesisWasm(params)) => {
// We pass some dummy values for `pov_size` and `pvf_complexity` as these don't
// matter for `wasm` export.
println!("0x{:?}", HexDisplay::from(&Collator::default().validation_code()));
let output_buf =
format!("0x{:?}", HexDisplay::from(&Collator::default().validation_code()))
.into_bytes();
if let Some(output) = params.output {
fs::write(output, output_buf)?;
} else {
io::stdout().write_all(&output_buf)?;
}
Ok(())
},
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment