Skip to content

Commit

Permalink
fix: export-genesis-state command (#1521)
Browse files Browse the repository at this point in the history
# Description

Currently the `ExportGenesisState` command in polkadot parachain uses an
asynchronous context to run, which seems to display some warnings. See
the screenshot below:

![Screenshot 2023-09-12 at 17 12
15](https://github.com/paritytech/polkadot-sdk/assets/2722756/0140b48a-2edb-41fa-b046-579d526f8305)

After the changes in this PR, which essentially runs the command in a
synchronous context, the command works properly without any warning.

![Screenshot 2023-09-12 at 18 23
46](https://github.com/paritytech/polkadot-sdk/assets/2722756/31506917-ece2-4a5f-8909-f215cc1ac0de)

The remaining runtimes were added to `construct_benchmark_partials`
macro in order not to fail if the runtime was not included in the
non-exhaustive initial list, similarly to the `construct_async_run` one.

For completeness: tests were made following this
[tutorial](https://docs.substrate.io/tutorials/build-a-parachain/connect-a-local-parachain/).
  • Loading branch information
Moliholy authored Sep 17, 2023
1 parent c7dbfc2 commit 2ca30ed
Showing 1 changed file with 44 additions and 8 deletions.
52 changes: 44 additions & 8 deletions cumulus/polkadot-parachain/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ impl SubstrateCli for RelayChainCli {
}

/// Creates partial components for the runtimes that are supported by the benchmarks.
macro_rules! construct_benchmark_partials {
macro_rules! construct_partials {
($config:expr, |$partials:ident| $code:expr) => {
match $config.chain_spec.runtime() {
Runtime::AssetHubKusama => {
Expand Down Expand Up @@ -456,7 +456,41 @@ macro_rules! construct_benchmark_partials {
)?;
$code
},
_ => Err("The chain is not supported".into()),
Runtime::Shell => {
let $partials = new_partial::<shell_runtime::RuntimeApi, _>(
&$config,
crate::service::shell_build_import_queue,
)?;
$code
},
Runtime::Seedling => {
let $partials = new_partial::<seedling_runtime::RuntimeApi, _>(
&$config,
crate::service::shell_build_import_queue,
)?;
$code
},
Runtime::ContractsRococo => {
let $partials = new_partial::<contracts_rococo_runtime::RuntimeApi, _>(
&$config,
crate::service::contracts_rococo_build_import_queue,
)?;
$code
},
Runtime::Penpal(_) | Runtime::Default => {
let $partials = new_partial::<rococo_parachain_runtime::RuntimeApi, _>(
&$config,
crate::service::rococo_parachain_build_import_queue,
)?;
$code
},
Runtime::Glutton => {
let $partials = new_partial::<glutton_runtime::RuntimeApi, _>(
&$config,
crate::service::shell_build_import_queue,
)?;
$code
},
}
};
}
Expand Down Expand Up @@ -679,10 +713,12 @@ pub fn run() -> Result<()> {
cmd.run(config, polkadot_config)
})
},
Some(Subcommand::ExportGenesisState(cmd)) =>
construct_async_run!(|components, cli, cmd, config| {
Ok(async move { cmd.run(&*config.chain_spec, &*components.client) })
}),
Some(Subcommand::ExportGenesisState(cmd)) => {
let runner = cli.create_runner(cmd)?;
runner.sync_run(|config| {
construct_partials!(config, |partials| cmd.run(&*config.chain_spec, &*partials.client))
})
},
Some(Subcommand::ExportGenesisWasm(cmd)) => {
let runner = cli.create_runner(cmd)?;
runner.sync_run(|_config| {
Expand All @@ -704,7 +740,7 @@ pub fn run() -> Result<()> {
.into())
},
BenchmarkCmd::Block(cmd) => runner.sync_run(|config| {
construct_benchmark_partials!(config, |partials| cmd.run(partials.client))
construct_partials!(config, |partials| cmd.run(partials.client))
}),
#[cfg(not(feature = "runtime-benchmarks"))]
BenchmarkCmd::Storage(_) =>
Expand All @@ -716,7 +752,7 @@ pub fn run() -> Result<()> {
.into()),
#[cfg(feature = "runtime-benchmarks")]
BenchmarkCmd::Storage(cmd) => runner.sync_run(|config| {
construct_benchmark_partials!(config, |partials| {
construct_partials!(config, |partials| {
let db = partials.backend.expose_db();
let storage = partials.backend.expose_storage();

Expand Down

0 comments on commit 2ca30ed

Please sign in to comment.