From 5e5aee7542f62234b25b579a8f93c275cdf5749b Mon Sep 17 00:00:00 2001 From: Michal Swietek Date: Mon, 23 Dec 2024 11:27:02 +0100 Subject: [PATCH] add flag to choose finality version --- bin/chain-bootstrapper/src/chain_spec/cli.rs | 11 +++++++---- scripts/run_nodes.sh | 13 ++++++++++++- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/bin/chain-bootstrapper/src/chain_spec/cli.rs b/bin/chain-bootstrapper/src/chain_spec/cli.rs index 0fb762d218..763f525832 100644 --- a/bin/chain-bootstrapper/src/chain_spec/cli.rs +++ b/bin/chain-bootstrapper/src/chain_spec/cli.rs @@ -1,4 +1,4 @@ -use primitives::{AccountId, Version as FinalityVersion, CURRENT_FINALITY_VERSION}; +use primitives::{AccountId, Version as FinalityVersion, CURRENT_FINALITY_VERSION, LEGACY_FINALITY_VERSION}; use sc_chain_spec::ChainType; use sc_cli::clap::{self, Args}; @@ -43,8 +43,8 @@ pub struct ChainSpecParams { rich_account_ids: Option>, /// Finality version at chain inception. - #[arg(long, default_value = CURRENT_FINALITY_VERSION.to_string())] - finality_version: FinalityVersion, + #[arg(long, default_value = "legacy")] + finality_version: String, } impl ChainSpecParams { @@ -81,6 +81,9 @@ impl ChainSpecParams { } pub fn finality_version(&self) -> FinalityVersion { - self.finality_version + match self.finality_version.as_str() { + "current" => CURRENT_FINALITY_VERSION, + _ => LEGACY_FINALITY_VERSION, + }.into() } } diff --git a/scripts/run_nodes.sh b/scripts/run_nodes.sh index c830915d9c..4a9cc5a59f 100755 --- a/scripts/run_nodes.sh +++ b/scripts/run_nodes.sh @@ -64,6 +64,8 @@ Usage: [-p|--base-path BASE_PATH] if specified, use given base path (keystore, db, AlephBFT backups) if not specified, base path is ./run-nodes-local + [--finality-version] + which finality version should be used, default = legacy [--dont-bootstrap] set if you don't want to bootstrap chain, ie generate keystore and chainspec [--dont-build] @@ -85,6 +87,7 @@ DONT_BOOTSTRAP=${DONT_BOOTSTRAP:-""} DONT_BUILD_ALEPH_NODE=${DONT_BUILD_ALEPH_NODE:-""} DONT_DELETE_DB=${DONT_DELETE_DB:-""} DONT_REMOVE_ABFT_BACKUPS=${DONT_REMOVE_ABFT_BACKUPS:-""} +FINALITY_VERSION=${FINALITY_VERSION:-"legacy"} while [[ $# -gt 0 ]]; do case "$1" in @@ -100,6 +103,10 @@ while [[ $# -gt 0 ]]; do BASE_PATH="$2" shift;shift ;; + --finality-version) + FINALITY_VERSION="$2" + shift;shift + ;; --dont-bootstrap) DONT_BOOTSTRAP="true" shift @@ -219,6 +226,9 @@ fi if ! command -v jq &> /dev/null; then error "jq could not be found on PATH!" fi +if [[ "${FINALITY_VERSION}" != "current" && "${FINALITY_VERSION}" != "legacy" ]]; then + error "Flag finality-version should be either current or legacy." +fi # ------------------- main script starts here ------------------------------ @@ -276,7 +286,8 @@ if [[ -z "${DONT_BOOTSTRAP}" ]]; then --account-ids "${all_account_ids_string}" \ --authorities-account-ids "${validator_ids_string}" \ --chain-type local > "${BASE_PATH}/chainspec.json" \ - --rich-account-ids "${all_account_ids_string}" + --rich-account-ids "${all_account_ids_string}" \ + --finality-version = "${FINALITY_VERSION}" if [[ "${DONT_REMOVE_ABFT_BACKUPS}" == "true" ]]; then all_account_ids=(${validator_account_ids[@]} ${rpc_node_account_ids[@]})