Skip to content

Commit

Permalink
Fix ExportGenesisState
Browse files Browse the repository at this point in the history
  • Loading branch information
imstar15 committed Aug 12, 2024
1 parent 3ac7a85 commit 4b13807
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use sc_cli::{
use sc_service::config::{BasePath, PrometheusConfig};
use sp_core::hexdisplay::HexDisplay;
use sp_runtime::traits::{AccountIdConversion, Block as BlockT};
use std::{io::Write, net::SocketAddr};

use crate::{
chain_spec::{self, IdentifyVariant},
Expand Down Expand Up @@ -286,7 +287,21 @@ pub fn run() -> Result<()> {
let spec =
cli.load_spec(&cmd.shared_params.chain.clone().unwrap_or_default())?;
let state_version = Cli::runtime_version(&spec).state_version();
cmd.run::<Block>(&*spec, &state_version)

let block: Block = generate_genesis_block(&*spec, state_version)?;
let raw_header = block.header().encode();
let output_buf = if cmd.raw {
raw_header
} else {
format!("0x{:?}", HexDisplay::from(&block.header().encode())).into_bytes()
};
if let Some(output) = &cmd.output {
std::fs::write(output, output_buf)?;
} else {
std::io::stdout().write_all(&output_buf)?;
}

Ok(())
})
}
})
Expand Down

0 comments on commit 4b13807

Please sign in to comment.