Rewrite multinode-demo/replicator.sh to avoid fullnode.sh (#5299)
This commit is contained in:
@ -20,7 +20,7 @@ fullnode_usage() {
|
||||
Fullnode Usage:
|
||||
usage: $0 [--config-dir PATH] [--blockstream PATH] [--init-complete-file FILE] [--label LABEL] [--stake LAMPORTS] [--no-voting] [--rpc-port port] [rsync network path to bootstrap leader configuration] [cluster entry point]
|
||||
|
||||
Start a validator or a replicator
|
||||
Start a validator
|
||||
|
||||
--config-dir PATH - store configuration and data files under this PATH
|
||||
--blockstream PATH - open blockstream at this unix domain socket location
|
||||
@ -136,43 +136,6 @@ setup_validator_accounts() {
|
||||
return 0
|
||||
}
|
||||
|
||||
setup_replicator_account() {
|
||||
declare entrypoint_ip=$1
|
||||
declare node_lamports=$2
|
||||
|
||||
if [[ -f $configured_flag ]]; then
|
||||
echo "Replicator account has already been configured"
|
||||
else
|
||||
if ((airdrops_enabled)); then
|
||||
(
|
||||
set -x
|
||||
$solana_wallet --keypair "$identity_keypair_path" --url "http://$entrypoint_ip:8899"
|
||||
airdrop "$node_lamports"
|
||||
) || return $?
|
||||
else
|
||||
echo "current account balance is "
|
||||
$solana_wallet --keypair "$identity_keypair_path" --url "http://$entrypoint_ip:8899" balance || return $?
|
||||
fi
|
||||
|
||||
echo "Create replicator storage account"
|
||||
(
|
||||
set -x
|
||||
$solana_wallet --keypair "$identity_keypair_path" --url "http://$entrypoint_ip:8899" \
|
||||
create-replicator-storage-account "$identity_pubkey" "$storage_pubkey"
|
||||
) || return $?
|
||||
|
||||
touch "$configured_flag"
|
||||
fi
|
||||
|
||||
(
|
||||
set -x
|
||||
$solana_wallet --keypair "$identity_keypair_path" --url "http://$entrypoint_ip:8899" \
|
||||
show-storage-account "$storage_pubkey"
|
||||
)
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
ledger_not_setup() {
|
||||
echo "Error: $*"
|
||||
echo
|
||||
@ -213,9 +176,6 @@ while [[ -n $1 ]]; do
|
||||
elif [[ $1 = --no-snapshot ]]; then
|
||||
boot_from_snapshot=0
|
||||
shift
|
||||
elif [[ $1 = --replicator ]]; then
|
||||
node_type=replicator
|
||||
shift
|
||||
elif [[ $1 = --validator ]]; then
|
||||
node_type=validator
|
||||
shift
|
||||
@ -303,34 +263,7 @@ fi
|
||||
|
||||
setup_secondary_mount
|
||||
|
||||
if [[ $node_type = replicator ]]; then
|
||||
if [[ ${#positional_args[@]} -gt 2 ]]; then
|
||||
fullnode_usage "$@"
|
||||
fi
|
||||
|
||||
read -r entrypoint entrypoint_address shift < <(find_entrypoint "${positional_args[@]}")
|
||||
shift "$shift"
|
||||
|
||||
mkdir -p "$SOLANA_CONFIG_DIR"
|
||||
|
||||
: "${identity_keypair_path:=$SOLANA_CONFIG_DIR/replicator-keypair$label.json}"
|
||||
[[ -r "$identity_keypair_path" ]] || $solana_keygen new -o "$identity_keypair_path"
|
||||
|
||||
: "${storage_keypair_path="$SOLANA_CONFIG_DIR"/replicator-storage-keypair$label.json}"
|
||||
[[ -r "$storage_keypair_path" ]] || $solana_keygen new -o "$storage_keypair_path"
|
||||
|
||||
ledger_config_dir=$SOLANA_CONFIG_DIR/replicator-ledger$label
|
||||
configured_flag=$SOLANA_CONFIG_DIR/replicator$label.configured
|
||||
|
||||
program=$solana_replicator
|
||||
default_arg --entrypoint "$entrypoint_address"
|
||||
default_arg --identity "$identity_keypair_path"
|
||||
default_arg --storage-keypair "$storage_keypair_path"
|
||||
default_arg --ledger "$ledger_config_dir"
|
||||
|
||||
rsync_entrypoint_url=$(rsync_url "$entrypoint")
|
||||
|
||||
elif [[ $node_type = bootstrap_leader ]]; then
|
||||
if [[ $node_type = bootstrap_leader ]]; then
|
||||
if [[ ${#positional_args[@]} -ne 0 ]]; then
|
||||
fullnode_usage "Unknown argument: ${positional_args[0]}"
|
||||
fi
|
||||
@ -397,7 +330,6 @@ fi
|
||||
identity_pubkey=$($solana_keygen pubkey "$identity_keypair_path")
|
||||
export SOLANA_METRICS_HOST_ID="$identity_pubkey"
|
||||
|
||||
if [[ $node_type != replicator ]]; then
|
||||
accounts_config_dir="$state_dir"/accounts
|
||||
snapshot_config_dir="$state_dir"/snapshots
|
||||
|
||||
@ -413,7 +345,6 @@ if [[ $node_type != replicator ]]; then
|
||||
else
|
||||
program=$solana_validator
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ -z $CI ]]; then # Skip in CI
|
||||
# shellcheck source=scripts/tune-system.sh
|
||||
@ -471,20 +402,6 @@ while true; do
|
||||
)
|
||||
fi
|
||||
|
||||
if [[ $node_type = replicator ]]; then
|
||||
storage_pubkey=$($solana_keygen pubkey "$storage_keypair_path")
|
||||
setup_replicator_account "${entrypoint_address%:*}" \
|
||||
"$node_lamports"
|
||||
|
||||
cat <<EOF
|
||||
======================[ $node_type configuration ]======================
|
||||
replicator pubkey: $identity_pubkey
|
||||
storage pubkey: $storage_pubkey
|
||||
ledger: $ledger_config_dir
|
||||
======================================================================
|
||||
EOF
|
||||
|
||||
else
|
||||
if [[ $node_type = bootstrap_leader && ! -d "$SOLANA_RSYNC_CONFIG_DIR"/ledger ]]; then
|
||||
ledger_not_setup "$SOLANA_RSYNC_CONFIG_DIR/ledger does not exist"
|
||||
fi
|
||||
@ -550,7 +467,6 @@ accounts: $accounts_config_dir
|
||||
snapshots: $snapshot_config_dir
|
||||
========================================================================
|
||||
EOF
|
||||
fi
|
||||
|
||||
echo "$PS4$program ${args[*]}"
|
||||
|
||||
|
@ -1,4 +1,85 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# A thin wrapper around `solana-replicator` that automatically provisions the
|
||||
# replicator's identity and/or storage keypair if not provided by the caller.
|
||||
#
|
||||
set -e
|
||||
|
||||
here=$(dirname "$0")
|
||||
exec "$here"/fullnode.sh --replicator "$@"
|
||||
# shellcheck source=multinode-demo/common.sh
|
||||
source "$here"/common.sh
|
||||
|
||||
entrypoint=127.0.0.0:8001
|
||||
label=
|
||||
|
||||
while [[ -n $1 ]]; do
|
||||
if [[ ${1:0:1} = - ]]; then
|
||||
if [[ $1 = --entrypoint ]]; then
|
||||
entrypoint=$2
|
||||
args+=("$1" "$2")
|
||||
shift 2
|
||||
elif [[ $1 = --identity ]]; then
|
||||
identity_keypair=$2
|
||||
[[ -r $identity_keypair ]] || {
|
||||
echo "$identity_keypair does not exist"
|
||||
exit 1
|
||||
}
|
||||
args+=("$1" "$2")
|
||||
shift 2
|
||||
elif [[ $1 = --label ]]; then
|
||||
label="-$2"
|
||||
shift 2
|
||||
elif [[ $1 = --ledger ]]; then
|
||||
args+=("$1" "$2")
|
||||
shift 2
|
||||
elif [[ $1 = --storage-keypair ]]; then
|
||||
storage_keypair=$2
|
||||
[[ -r $storage_keypair ]] || {
|
||||
echo "$storage_keypair does not exist"
|
||||
exit 1
|
||||
}
|
||||
args+=("$1" "$2")
|
||||
shift 2
|
||||
else
|
||||
echo "Unknown argument: $1"
|
||||
$solana_replicator --help
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo "Unknown argument: $1"
|
||||
$solana_replicator --help
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
: "${identity_keypair:="$SOLANA_ROOT"/farf/replicator-identity-keypair"$label".json}"
|
||||
: "${storage_keypair:="$SOLANA_ROOT"/farf/storage-keypair"$label".json}"
|
||||
ledger="$SOLANA_ROOT"/farf/replicator-ledger"$label"
|
||||
|
||||
rpc_url=$("$here"/rpc-url.sh "$entrypoint")
|
||||
|
||||
if [[ ! -r $identity_keypair ]]; then
|
||||
$solana_keygen new -o "$identity_keypair"
|
||||
|
||||
# TODO: https://github.com/solana-labs/solminer/blob/9cd2289/src/replicator.js#L17-L18
|
||||
$solana_wallet --keypair "$identity_keypair" --url "$rpc_url" \
|
||||
airdrop 100000
|
||||
fi
|
||||
identity_pubkey=$($solana_keygen pubkey "$identity_keypair")
|
||||
|
||||
if [[ ! -r $storage_keypair ]]; then
|
||||
$solana_keygen new -o "$storage_keypair"
|
||||
storage_pubkey=$($solana_keygen pubkey "$storage_keypair")
|
||||
|
||||
$solana_wallet --keypair "$identity_keypair" --url "$rpc_url" \
|
||||
create-replicator-storage-account "$identity_pubkey" "$storage_pubkey"
|
||||
fi
|
||||
|
||||
default_arg --entrypoint "$entrypoint"
|
||||
default_arg --identity "$identity_keypair"
|
||||
default_arg --storage-keypair "$storage_keypair"
|
||||
default_arg --ledger "$ledger"
|
||||
|
||||
set -x
|
||||
# shellcheck disable=SC2086 # Don't want to double quote $solana_replicator
|
||||
exec $solana_replicator "${args[@]}"
|
||||
|
14
multinode-demo/rpc-url.sh
Executable file
14
multinode-demo/rpc-url.sh
Executable file
@ -0,0 +1,14 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# Given a gossip entrypoint derive the entrypoint's RPC address
|
||||
#
|
||||
|
||||
entrypoint_address=$1
|
||||
if [[ -z $entrypoint_address ]]; then
|
||||
echo "Error: entrypoint address not specified" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# TODO: Rather than hard coding, add a `solana-gossip rpc-address` command that
|
||||
# actually asks the entrypoint itself for its RPC address
|
||||
echo "http://${entrypoint_address%:*}:8899"
|
@ -273,22 +273,16 @@ local|tar|skip)
|
||||
fi
|
||||
|
||||
args=(
|
||||
"$entrypointIp":~/solana "$entrypointIp:8001"
|
||||
--entrypoint "$entrypointIp:8001"
|
||||
)
|
||||
|
||||
if [[ $airdropsEnabled != true ]]; then
|
||||
args+=(--no-airdrop)
|
||||
echo "TODO: replicators not supported without airdrops"
|
||||
# TODO: need to provide the `--identity` argument to an existing system
|
||||
# account with lamports in it
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ -n $internalNodesLamports ]] ; then
|
||||
args+=(--node-lamports "$internalNodesLamports")
|
||||
fi
|
||||
|
||||
if [[ $skipSetup != true ]]; then
|
||||
./multinode-demo/clear-config.sh
|
||||
fi
|
||||
# shellcheck disable=SC2206 # Don't want to double quote $extraNodeArgs
|
||||
args+=($extraNodeArgs)
|
||||
nohup ./multinode-demo/replicator.sh "${args[@]}" > fullnode.log 2>&1 &
|
||||
sleep 1
|
||||
;;
|
||||
|
Reference in New Issue
Block a user