Skip to content

Commit

Permalink
refactor: ♻️ retrieve state version from WASM blob
Browse files Browse the repository at this point in the history
  • Loading branch information
manuelmauro committed Jan 30, 2025
1 parent 8b36513 commit 9c976bf
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ sc-chain-spec = { workspace = true }
sc-cli = { workspace = true }
sc-client-api = { workspace = true }
sc-consensus-grandpa = { workspace = true }
sc-executor = { workspace = true }
sc-network = { workspace = true }
sc-service = { workspace = true }
sc-sysinfo = { workspace = true }
Expand Down
18 changes: 15 additions & 3 deletions node/cli/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,15 @@ use moonbeam_service::moonbeam_runtime;
#[cfg(feature = "moonriver-native")]
use moonbeam_service::moonriver_runtime;

use moonbeam_service::{chain_spec, frontier_database_dir, HostFunctions, IdentifyVariant};
use moonbeam_service::{chain_spec, frontier_database_dir, Block, HostFunctions, IdentifyVariant};
use parity_scale_codec::Encode;
#[cfg(feature = "westend-native")]
use polkadot_service::WestendChainSpec;
use sc_cli::{
ChainSpec, CliConfiguration, DefaultConfigurationValues, ImportParams, KeystoreParams,
NetworkParams, Result, RpcEndpoint, RuntimeVersion, SharedParams, SubstrateCli,
};
use sc_executor::WasmtimeInstantiationStrategy;
use sc_service::{
config::{BasePath, PrometheusConfig},
DatabaseSource, PartialComponents,
Expand Down Expand Up @@ -420,13 +421,24 @@ pub fn run() -> Result<()> {
}
Some(Subcommand::ExportGenesisHead(params)) => {
let runner = cli.create_runner(params)?;
let chain_spec = (runner.config().chain_spec).cloned_box();
let chain_spec = runner.config().chain_spec.cloned_box();

let mut builder = sc_cli::LoggerBuilder::new("");
builder.with_profiling(sc_tracing::TracingReceiver::Log, "");
let _ = builder.init();

let state_version = Cli::runtime_version(&chain_spec).state_version();
let storage = chain_spec.build_storage()?;
let executor = sc_executor::WasmExecutor::<HostFunctions>::builder()
.with_execution_method(sc_executor::WasmExecutionMethod::Compiled {
instantiation_strategy: WasmtimeInstantiationStrategy::PoolingCopyOnWrite,
})
.with_max_runtime_instances(1024)
.build();

let state_version = sc_chain_spec::resolve_state_version_from_wasm::<
_,
HashingFor<Block>,
>(&storage, &executor)?;

let output_buf = match chain_spec {
#[cfg(feature = "moonriver-native")]
Expand Down

0 comments on commit 9c976bf

Please sign in to comment.