Rename Statemint to Asset Hub (#2633)

* change dir names

* cargo toml updates

* fix crate imports for build

* change chain spec names and PR review rule

* update cli to accept asset-hub

* find/replace benchmark commands

* integration tests

* bridges docs

* more integration tests

* AuraId

* other statemint tidying

* rename statemint mod

* chain spec mod

* rename e2e test dirs

* one more Runtime::Statemine

* benchmark westmint

* rename chain spec name and id

* rename chain spec files

* more tidying in scripts/docs/tests

* rename old dir if exists

* Force people to manually do the move.

(Safer as there could be additional considerations with their setup)

* review touchups

* more renaming

* Update polkadot-parachain/src/command.rs

Co-authored-by: Bastian Köcher <git@kchr.de>

* better error message

* do not break on-chain spec_name

* log info message that path has been renamed

* better penpal docs

---------

Co-authored-by: gilescope <gilescope@gmail.com>
Co-authored-by: Bastian Köcher <git@kchr.de>
Co-authored-by: parity-processbot <>
This commit is contained in:
joe petrowski
2023-06-02 11:58:19 +02:00
committed by GitHub
parent cad48b7136
commit 6007549589
161 changed files with 1123 additions and 1025 deletions
+124 -77
View File
@@ -18,9 +18,10 @@ use crate::{
chain_spec,
cli::{Cli, RelayChainCli, Subcommand},
service::{
new_partial, Block, BridgeHubKusamaRuntimeExecutor, BridgeHubPolkadotRuntimeExecutor,
BridgeHubRococoRuntimeExecutor, CollectivesPolkadotRuntimeExecutor, GluttonRuntimeExecutor,
StatemineRuntimeExecutor, StatemintRuntimeExecutor, WestmintRuntimeExecutor,
new_partial, AssetHubKusamaExecutor, AssetHubPolkadotRuntimeExecutor,
AssetHubWestendExecutor, Block, BridgeHubKusamaRuntimeExecutor,
BridgeHubPolkadotRuntimeExecutor, BridgeHubRococoRuntimeExecutor,
CollectivesPolkadotRuntimeExecutor, GluttonRuntimeExecutor,
},
};
use codec::Encode;
@@ -28,7 +29,7 @@ use cumulus_client_cli::generate_genesis_block;
use cumulus_primitives_core::ParaId;
use frame_benchmarking_cli::{BenchmarkCmd, SUBSTRATE_REFERENCE_HARDWARE};
use log::{info, warn};
use parachains_common::{AuraId, StatemintAuraId};
use parachains_common::{AssetHubPolkadotAuraId, AuraId};
use sc_cli::{
ChainSpec, CliConfiguration, DefaultConfigurationValues, ImportParams, KeystoreParams,
NetworkParams, Result, RuntimeVersion, SharedParams, SubstrateCli,
@@ -47,9 +48,9 @@ enum Runtime {
Default,
Shell,
Seedling,
Statemint,
Statemine,
Westmint,
AssetHubPolkadot,
AssetHubKusama,
AssetHubWestend,
Penpal(ParaId),
ContractsRococo,
CollectivesPolkadot,
@@ -93,12 +94,12 @@ fn runtime(id: &str) -> Runtime {
Runtime::Shell
} else if id.starts_with("seedling") {
Runtime::Seedling
} else if id.starts_with("statemint") {
Runtime::Statemint
} else if id.starts_with("statemine") {
Runtime::Statemine
} else if id.starts_with("westmint") {
Runtime::Westmint
} else if id.starts_with("asset-hub-polkadot") | id.starts_with("statemint") {
Runtime::AssetHubPolkadot
} else if id.starts_with("asset-hub-kusama") | id.starts_with("statemine") {
Runtime::AssetHubKusama
} else if id.starts_with("asset-hub-westend") | id.starts_with("westmint") {
Runtime::AssetHubWestend
} else if id.starts_with("penpal") {
Runtime::Penpal(para_id.unwrap_or(ParaId::new(0)))
} else if id.starts_with("contracts-rococo") {
@@ -143,35 +144,47 @@ fn load_spec(id: &str) -> std::result::Result<Box<dyn ChainSpec>, String> {
"shell" => Box::new(chain_spec::shell::get_shell_chain_spec()),
"seedling" => Box::new(chain_spec::seedling::get_seedling_chain_spec()),
// -- Statemint
"statemint-dev" => Box::new(chain_spec::statemint::statemint_development_config()),
"statemint-local" => Box::new(chain_spec::statemint::statemint_local_config()),
// -- Asset Hub Polkadot
"asset-hub-polkadot-dev" | "statemint-dev" =>
Box::new(chain_spec::asset_hubs::asset_hub_polkadot_development_config()),
"asset-hub-polkadot-local" | "statemint-local" =>
Box::new(chain_spec::asset_hubs::asset_hub_polkadot_local_config()),
// the chain spec as used for generating the upgrade genesis values
"statemint-genesis" => Box::new(chain_spec::statemint::statemint_config()),
"asset-hub-polkadot-genesis" | "statemint-genesis" =>
Box::new(chain_spec::asset_hubs::asset_hub_polkadot_config()),
// the shell-based chain spec as used for syncing
"statemint" => Box::new(chain_spec::statemint::StatemintChainSpec::from_json_bytes(
&include_bytes!("../../parachains/chain-specs/statemint.json")[..],
)?),
"asset-hub-polkadot" | "statemint" =>
Box::new(chain_spec::asset_hubs::AssetHubPolkadotChainSpec::from_json_bytes(
&include_bytes!("../../parachains/chain-specs/asset-hub-polkadot.json")[..],
)?),
// -- Statemine
"statemine-dev" => Box::new(chain_spec::statemint::statemine_development_config()),
"statemine-local" => Box::new(chain_spec::statemint::statemine_local_config()),
// -- Asset Hub Kusama
"asset-hub-kusama-dev" | "statemine-dev" =>
Box::new(chain_spec::asset_hubs::asset_hub_kusama_development_config()),
"asset-hub-kusama-local" | "statemine-local" =>
Box::new(chain_spec::asset_hubs::asset_hub_kusama_local_config()),
// the chain spec as used for generating the upgrade genesis values
"statemine-genesis" => Box::new(chain_spec::statemint::statemine_config()),
"asset-hub-kusama-genesis" | "statemine-genesis" =>
Box::new(chain_spec::asset_hubs::asset_hub_kusama_config()),
// the shell-based chain spec as used for syncing
"statemine" => Box::new(chain_spec::statemint::StatemineChainSpec::from_json_bytes(
&include_bytes!("../../parachains/chain-specs/statemine.json")[..],
)?),
"asset-hub-kusama" | "statemine" =>
Box::new(chain_spec::asset_hubs::AssetHubKusamaChainSpec::from_json_bytes(
&include_bytes!("../../parachains/chain-specs/asset-hub-kusama.json")[..],
)?),
// -- Westmint
"westmint-dev" => Box::new(chain_spec::statemint::westmint_development_config()),
"westmint-local" => Box::new(chain_spec::statemint::westmint_local_config()),
// -- Asset Hub Westend
"asset-hub-westend-dev" | "westmint-dev" =>
Box::new(chain_spec::asset_hubs::asset_hub_westend_development_config()),
"asset-hub-westend-local" | "westmint-local" =>
Box::new(chain_spec::asset_hubs::asset_hub_westend_local_config()),
// the chain spec as used for generating the upgrade genesis values
"westmint-genesis" => Box::new(chain_spec::statemint::westmint_config()),
"asset-hub-westend-genesis" | "westmint-genesis" =>
Box::new(chain_spec::asset_hubs::asset_hub_westend_config()),
// the shell-based chain spec as used for syncing
"westmint" => Box::new(chain_spec::statemint::WestmintChainSpec::from_json_bytes(
&include_bytes!("../../parachains/chain-specs/westmint.json")[..],
)?),
"asset-hub-westend" | "westmint" =>
Box::new(chain_spec::asset_hubs::AssetHubWestendChainSpec::from_json_bytes(
&include_bytes!("../../parachains/chain-specs/asset-hub-westend.json")[..],
)?),
// -- Polkadot Collectives
"collectives-polkadot-dev" =>
@@ -239,12 +252,14 @@ fn load_spec(id: &str) -> std::result::Result<Box<dyn ChainSpec>, String> {
path => {
let path: PathBuf = path.into();
match path.runtime() {
Runtime::Statemint =>
Box::new(chain_spec::statemint::StatemintChainSpec::from_json_file(path)?),
Runtime::Statemine =>
Box::new(chain_spec::statemint::StatemineChainSpec::from_json_file(path)?),
Runtime::Westmint =>
Box::new(chain_spec::statemint::WestmintChainSpec::from_json_file(path)?),
Runtime::AssetHubPolkadot => Box::new(
chain_spec::asset_hubs::AssetHubPolkadotChainSpec::from_json_file(path)?,
),
Runtime::AssetHubKusama =>
Box::new(chain_spec::asset_hubs::AssetHubKusamaChainSpec::from_json_file(path)?),
Runtime::AssetHubWestend => Box::new(
chain_spec::asset_hubs::AssetHubWestendChainSpec::from_json_file(path)?,
),
Runtime::CollectivesPolkadot | Runtime::CollectivesWestend => Box::new(
chain_spec::collectives::CollectivesPolkadotChainSpec::from_json_file(path)?,
),
@@ -338,9 +353,9 @@ impl SubstrateCli for Cli {
fn native_runtime_version(chain_spec: &Box<dyn ChainSpec>) -> &'static RuntimeVersion {
match chain_spec.runtime() {
Runtime::Statemint => &statemint_runtime::VERSION,
Runtime::Statemine => &statemine_runtime::VERSION,
Runtime::Westmint => &westmint_runtime::VERSION,
Runtime::AssetHubPolkadot => &asset_hub_polkadot_runtime::VERSION,
Runtime::AssetHubKusama => &asset_hub_kusama_runtime::VERSION,
Runtime::AssetHubWestend => &asset_hub_westend_runtime::VERSION,
Runtime::CollectivesPolkadot | Runtime::CollectivesWestend =>
&collectives_polkadot_runtime::VERSION,
Runtime::Shell => &shell_runtime::VERSION,
@@ -399,24 +414,24 @@ impl SubstrateCli for RelayChainCli {
macro_rules! construct_benchmark_partials {
($config:expr, |$partials:ident| $code:expr) => {
match $config.chain_spec.runtime() {
Runtime::Statemine => {
let $partials = new_partial::<statemine_runtime::RuntimeApi, _>(
Runtime::AssetHubKusama => {
let $partials = new_partial::<asset_hub_kusama_runtime::RuntimeApi, _>(
&$config,
crate::service::aura_build_import_queue::<_, AuraId>,
)?;
$code
},
Runtime::Westmint => {
let $partials = new_partial::<westmint_runtime::RuntimeApi, _>(
Runtime::AssetHubWestend => {
let $partials = new_partial::<asset_hub_westend_runtime::RuntimeApi, _>(
&$config,
crate::service::aura_build_import_queue::<_, AuraId>,
)?;
$code
},
Runtime::Statemint => {
let $partials = new_partial::<statemint_runtime::RuntimeApi, _>(
Runtime::AssetHubPolkadot => {
let $partials = new_partial::<asset_hub_polkadot_runtime::RuntimeApi, _>(
&$config,
crate::service::aura_build_import_queue::<_, StatemintAuraId>,
crate::service::aura_build_import_queue::<_, AssetHubPolkadotAuraId>,
)?;
$code
},
@@ -436,9 +451,9 @@ macro_rules! construct_async_run {
(|$components:ident, $cli:ident, $cmd:ident, $config:ident| $( $code:tt )* ) => {{
let runner = $cli.create_runner($cmd)?;
match runner.config().chain_spec.runtime() {
Runtime::Westmint => {
Runtime::AssetHubWestend => {
runner.async_run(|$config| {
let $components = new_partial::<westmint_runtime::RuntimeApi, _>(
let $components = new_partial::<asset_hub_westend_runtime::RuntimeApi, _>(
&$config,
crate::service::aura_build_import_queue::<_, AuraId>,
)?;
@@ -446,9 +461,9 @@ macro_rules! construct_async_run {
{ $( $code )* }.map(|v| (v, task_manager))
})
},
Runtime::Statemine => {
Runtime::AssetHubKusama => {
runner.async_run(|$config| {
let $components = new_partial::<statemine_runtime::RuntimeApi, _>(
let $components = new_partial::<asset_hub_kusama_runtime::RuntimeApi, _>(
&$config,
crate::service::aura_build_import_queue::<_, AuraId>,
)?;
@@ -456,11 +471,11 @@ macro_rules! construct_async_run {
{ $( $code )* }.map(|v| (v, task_manager))
})
},
Runtime::Statemint => {
Runtime::AssetHubPolkadot => {
runner.async_run(|$config| {
let $components = new_partial::<statemint_runtime::RuntimeApi, _>(
let $components = new_partial::<asset_hub_polkadot_runtime::RuntimeApi, _>(
&$config,
crate::service::aura_build_import_queue::<_, StatemintAuraId>,
crate::service::aura_build_import_queue::<_, AssetHubPolkadotAuraId>,
)?;
let task_manager = $components.task_manager;
{ $( $code )* }.map(|v| (v, task_manager))
@@ -674,11 +689,11 @@ pub fn run() -> Result<()> {
if cfg!(feature = "runtime-benchmarks") {
runner.sync_run(|config| {
match config.chain_spec.runtime() {
Runtime::Statemine =>
cmd.run::<Block, StatemineRuntimeExecutor>(config),
Runtime::Westmint => cmd.run::<Block, WestmintRuntimeExecutor>(config),
Runtime::Statemint =>
cmd.run::<Block, StatemintRuntimeExecutor>(config),
Runtime::AssetHubKusama =>
cmd.run::<Block, AssetHubKusamaExecutor>(config),
Runtime::AssetHubWestend => cmd.run::<Block, AssetHubWestendExecutor>(config),
Runtime::AssetHubPolkadot =>
cmd.run::<Block, AssetHubPolkadotRuntimeExecutor>(config),
Runtime::CollectivesPolkadot | Runtime::CollectivesWestend =>
cmd.run::<Block, CollectivesPolkadotRuntimeExecutor>(config),
Runtime::BridgeHub(bridge_hub_runtime_type) => match bridge_hub_runtime_type {
@@ -762,25 +777,25 @@ pub fn run() -> Result<()> {
let info_provider = timestamp_with_aura_info(6000);
match runner.config().chain_spec.runtime() {
Runtime::Statemine => runner.async_run(|_| {
Runtime::AssetHubKusama => runner.async_run(|_| {
Ok((
cmd.run::<Block, HostFunctionsOf<StatemineRuntimeExecutor>, _>(Some(
cmd.run::<Block, HostFunctionsOf<AssetHubKusamaExecutor>, _>(Some(
info_provider,
)),
task_manager,
))
}),
Runtime::Westmint => runner.async_run(|_| {
Runtime::AssetHubWestend => runner.async_run(|_| {
Ok((
cmd.run::<Block, HostFunctionsOf<WestmintRuntimeExecutor>, _>(Some(
cmd.run::<Block, HostFunctionsOf<AssetHubWestendExecutor>, _>(Some(
info_provider,
)),
task_manager,
))
}),
Runtime::Statemint => runner.async_run(|_| {
Runtime::AssetHubPolkadot => runner.async_run(|_| {
Ok((
cmd.run::<Block, HostFunctionsOf<StatemintRuntimeExecutor>, _>(Some(
cmd.run::<Block, HostFunctionsOf<AssetHubPolkadotRuntimeExecutor>, _>(Some(
info_provider,
)),
task_manager,
@@ -858,6 +873,38 @@ pub fn run() -> Result<()> {
let collator_options = cli.run.collator_options();
runner.run_node_until_exit(|config| async move {
// If Statemint (Statemine, Westmint, Rockmine) DB exists and we're using the
// asset-hub chain spec, then rename the base path to the new chain ID. In the case
// that both file paths exist, the node will exit, as the user must decide (by
// deleting one path) the information that they want to use as their DB.
let old_name = match config.chain_spec.id() {
"asset-hub-polkadot" => Some("statemint"),
"asset-hub-kusama" => Some("statemine"),
"asset-hub-westend" => Some("westmint"),
"asset-hub-rococo" => Some("rockmine"),
_ => None,
};
if let Some(old_name) = old_name {
let new_path = config.base_path.config_dir(config.chain_spec.id());
let old_path = config.base_path.config_dir(old_name);
if old_path.exists() && new_path.exists() {
return Err(format!(
"Found legacy {} path {} and new asset-hub path {}. Delete one path such that only one exists.",
old_name, old_path.display(), new_path.display()
).into())
}
if old_path.exists() {
std::fs::rename(old_path.clone(), new_path.clone())?;
info!(
"Statemint renamed to Asset Hub. The filepath with associated data on disk has been renamed from {} to {}.",
old_path.display(), new_path.display()
);
}
}
let hwbench = (!cli.no_hardware_benchmarks).then_some(
config.database.path().map(|database_path| {
let _ = std::fs::create_dir_all(database_path);
@@ -900,22 +947,22 @@ pub fn run() -> Result<()> {
}
match config.chain_spec.runtime() {
Runtime::Statemint => crate::service::start_generic_aura_node::<
statemint_runtime::RuntimeApi,
StatemintAuraId,
Runtime::AssetHubPolkadot => crate::service::start_generic_aura_node::<
asset_hub_polkadot_runtime::RuntimeApi,
AssetHubPolkadotAuraId,
>(config, polkadot_config, collator_options, id, hwbench)
.await
.map(|r| r.0)
.map_err(Into::into),
Runtime::Statemine => crate::service::start_generic_aura_node::<
statemine_runtime::RuntimeApi,
Runtime::AssetHubKusama => crate::service::start_generic_aura_node::<
asset_hub_kusama_runtime::RuntimeApi,
AuraId,
>(config, polkadot_config, collator_options, id, hwbench)
.await
.map(|r| r.0)
.map_err(Into::into),
Runtime::Westmint => crate::service::start_generic_aura_node::<
westmint_runtime::RuntimeApi,
Runtime::AssetHubWestend => crate::service::start_generic_aura_node::<
asset_hub_westend_runtime::RuntimeApi,
AuraId,
>(config, polkadot_config, collator_options, id, hwbench)
.await
@@ -1257,9 +1304,9 @@ mod tests {
let path = store_configuration(
&temp_dir,
Box::new(crate::chain_spec::statemint::statemine_local_config()),
Box::new(crate::chain_spec::asset_hubs::asset_hub_kusama_local_config()),
);
assert_eq!(Runtime::Statemine, path.runtime());
assert_eq!(Runtime::AssetHubKusama, path.runtime());
let path = store_configuration(
&temp_dir,