Skip to content

Commit

Permalink
add flag to choose finality version
Browse files Browse the repository at this point in the history
  • Loading branch information
mike1729 committed Dec 23, 2024
1 parent 437775a commit 09561c5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
14 changes: 10 additions & 4 deletions bin/chain-bootstrapper/src/chain_spec/cli.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
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};

Expand Down Expand Up @@ -43,8 +45,8 @@ pub struct ChainSpecParams {
rich_account_ids: Option<Vec<AccountId>>,

/// 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 {
Expand Down Expand Up @@ -81,6 +83,10 @@ 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()
}
}
13 changes: 12 additions & 1 deletion scripts/run_nodes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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 ------------------------------

Expand Down Expand Up @@ -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[@]})
Expand Down

0 comments on commit 09561c5

Please sign in to comment.