mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-12 07:35:46 +00:00
Rename ExportGenesisStateCommand to ExportGenesisHeadCommand and make it respect custom genesis block builders (#2331)
Closes #2326. This PR both fixes a logic bug and replaces an incorrect name. ## Bug Fix: Respecting custom genesis builder Prior to this PR the standard logic for creating a genesis block was repeated inside of cumulus. This PR removes that duplicated logic, and calls into the proper `BuildGenesisBlock` implementation. One consequence is that if the genesis block has already been initialized, it will not be re-created, but rather read from the database like it is for other node invocations. So you need to watch out for old unpurged data during the development process. Offchain tools may need to be updated accordingly. I've already filed https://github.com/paritytech/zombienet/issues/1519 ## Rename: It doesn't export state. It exports head data. The name export-genesis-state was always wrong, nad it's never too late to right a wrong. I've changed the name of the struct to `ExportGenesisHeadCommand`. There is still the question of what to do with individual nodes' public CLIs. I have updated the parachain template to a reasonable default that preserves compatibility with tools that will expect `export-genesis-state` to still work. And I've chosen not to modify the public CLIs of any other nodes in the repo. I'll leave it up to their individual owners/maintains to decide whether that is appropriate. --------- Co-authored-by: Joshy Orndorff <git-user-email.h0ly5@simplelogin.com> Co-authored-by: Bastian Köcher <git@kchr.de> Co-authored-by: Bastian Köcher <info@kchr.de>
This commit is contained in:
@@ -16,16 +16,14 @@
|
||||
|
||||
mod cli;
|
||||
|
||||
use std::{io::Write, sync::Arc};
|
||||
use std::sync::Arc;
|
||||
|
||||
use cli::{RelayChainCli, Subcommand, TestCollatorCli};
|
||||
use cumulus_client_cli::generate_genesis_block;
|
||||
use cumulus_primitives_core::{relay_chain::CollatorPair, ParaId};
|
||||
use cumulus_test_service::AnnounceBlockFn;
|
||||
use cumulus_test_service::{new_partial, AnnounceBlockFn};
|
||||
use polkadot_service::runtime_traits::AccountIdConversion;
|
||||
use sc_cli::{CliConfiguration, SubstrateCli};
|
||||
use sp_core::{hexdisplay::HexDisplay, Encode, Pair};
|
||||
use sp_runtime::traits::Block;
|
||||
use sp_core::Pair;
|
||||
|
||||
pub fn wrap_announce_block() -> Box<dyn FnOnce(AnnounceBlockFn) -> AnnounceBlockFn> {
|
||||
tracing::info!("Block announcements disabled.");
|
||||
@@ -44,38 +42,16 @@ fn main() -> Result<(), sc_cli::Error> {
|
||||
runner.sync_run(|config| cmd.run(config.chain_spec, config.network))
|
||||
},
|
||||
|
||||
Some(Subcommand::ExportGenesisState(params)) => {
|
||||
let mut builder = sc_cli::LoggerBuilder::new("");
|
||||
builder.with_profiling(sc_tracing::TracingReceiver::Log, "");
|
||||
let _ = builder.init();
|
||||
|
||||
let spec =
|
||||
cli.load_spec(¶ms.base.shared_params.chain.clone().unwrap_or_default())?;
|
||||
let state_version = cumulus_test_service::runtime::VERSION.state_version();
|
||||
|
||||
let block: parachains_common::Block = generate_genesis_block(&*spec, state_version)?;
|
||||
let raw_header = block.header().encode();
|
||||
let output_buf = if params.base.raw {
|
||||
raw_header
|
||||
} else {
|
||||
format!("0x{:?}", HexDisplay::from(&block.header().encode())).into_bytes()
|
||||
};
|
||||
|
||||
if let Some(output) = ¶ms.base.output {
|
||||
std::fs::write(output, output_buf)?;
|
||||
} else {
|
||||
std::io::stdout().write_all(&output_buf)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
Some(Subcommand::ExportGenesisHead(cmd)) => {
|
||||
let runner = cli.create_runner(cmd)?;
|
||||
runner.sync_run(|mut config| {
|
||||
let partial = new_partial(&mut config, false)?;
|
||||
cmd.run(partial.client)
|
||||
})
|
||||
},
|
||||
Some(Subcommand::ExportGenesisWasm(cmd)) => {
|
||||
let runner = cli.create_runner(cmd)?;
|
||||
runner.sync_run(|_config| {
|
||||
let parachain_id = ParaId::from(cmd.parachain_id);
|
||||
let spec = cumulus_test_service::get_chain_spec(Some(parachain_id));
|
||||
cmd.base.run(&spec)
|
||||
})
|
||||
runner.sync_run(|config| cmd.run(&*config.chain_spec))
|
||||
},
|
||||
None => {
|
||||
let log_filters = cli.run.normalize().log_filters();
|
||||
|
||||
Reference in New Issue
Block a user