Facility to provision primordial accounts for fullnodes in genesis block (#4631)

* updated usage

* shellcheck

* support replicators

* disable airdrops if primordial accounts are used

* review comments
This commit is contained in:
Pankaj Garg
2019-06-10 19:42:49 -07:00
committed by GitHub
parent b4d4edb645
commit 9259d342ac
4 changed files with 105 additions and 58 deletions

View File

@@ -55,6 +55,12 @@ Operate a configured testnet
- Override the default --hashes-per-tick for the cluster
-n NUM_FULL_NODES - Number of fullnodes to apply command to.
-x Accounts and Stakes for external nodes
- A YML file with a list of account pubkeys and corresponding stakes
for external nodes
-s Num lamports per node in genesis block
- Create account keypairs for internal nodes and assign these many lamports
sanity/start/update-specific options:
-F - Discard validator nodes that didn't bootup successfully
-o noLedgerVerify - Skip ledger verification
@@ -89,6 +95,8 @@ benchExchangeExtraArgs=
failOnValidatorBootupFailure=true
genesisOptions=
numFullnodesRequested=
externalPrimordialAccountsFile=
stakeNodesInGenesisBlock=
command=$1
[[ -n $command ]] || usage
@@ -112,7 +120,7 @@ while [[ -n $1 ]]; do
fi
done
while getopts "h?T:t:o:f:rD:c:Fn:" opt "${shortArgs[@]}"; do
while getopts "h?T:t:o:f:rD:c:Fn:x:s:" opt "${shortArgs[@]}"; do
case $opt in
h | \?)
usage
@@ -191,6 +199,12 @@ while getopts "h?T:t:o:f:rD:c:Fn:" opt "${shortArgs[@]}"; do
F)
failOnValidatorBootupFailure=false
;;
x)
externalPrimordialAccountsFile=$OPTARG
;;
s)
stakeNodesInGenesisBlock=$OPTARG
;;
*)
usage "Error: unhandled option: $opt"
;;
@@ -291,6 +305,7 @@ startCommon() {
startBootstrapLeader() {
declare ipAddress=$1
declare logFile="$2"
declare nodeIndex="$3"
echo "--- Starting bootstrap leader: $ipAddress"
echo "start log: $logFile"
@@ -299,6 +314,8 @@ startBootstrapLeader() {
(
set -x
startCommon "$ipAddress" || exit 1
[[ -z "$externalPrimordialAccountsFile" ]] || rsync -vPrc -e "ssh ${sshOptions[*]}" "$externalPrimordialAccountsFile" \
"$ipAddress:~/solana/config/external-primodial-accounts.yml"
case $deployMethod in
tar)
rsync -vPrc -e "ssh ${sshOptions[*]}" "$SOLANA_ROOT"/solana-release/bin/* "$ipAddress:~/.cargo/bin/"
@@ -316,10 +333,13 @@ startBootstrapLeader() {
$deployMethod \
bootstrap-leader \
$entrypointIp \
$((${#fullnodeIpList[@]} + ${#blockstreamerIpList[@]})) \
$((${#fullnodeIpList[@]} + ${#blockstreamerIpList[@]} + ${#replicatorIpList[@]})) \
\"$RUST_LOG\" \
$skipSetup \
$failOnValidatorBootupFailure \
\"$externalPrimordialAccountsFile\" \
\"$stakeNodesInGenesisBlock\" \
$nodeIndex \
\"$genesisOptions\" \
"
) >> "$logFile" 2>&1 || {
@@ -332,6 +352,7 @@ startBootstrapLeader() {
startNode() {
declare ipAddress=$1
declare nodeType=$2
declare nodeIndex="$3"
declare logFile="$netLogDir/fullnode-$ipAddress.log"
echo "--- Starting $nodeType: $ipAddress"
@@ -344,10 +365,13 @@ startNode() {
$deployMethod \
$nodeType \
$entrypointIp \
$((${#fullnodeIpList[@]} + ${#blockstreamerIpList[@]})) \
$((${#fullnodeIpList[@]} + ${#blockstreamerIpList[@]} + ${#replicatorIpList[@]})) \
\"$RUST_LOG\" \
$skipSetup \
$failOnValidatorBootupFailure \
\"$externalPrimordialAccountsFile\" \
\"$stakeNodesInGenesisBlock\" \
$nodeIndex \
\"$genesisOptions\" \
"
) >> "$logFile" 2>&1 &
@@ -492,7 +516,7 @@ start() {
if $bootstrapLeader; then
SECONDS=0
declare bootstrapNodeDeployTime=
startBootstrapLeader "$ipAddress" "$netLogDir/bootstrap-leader-$ipAddress.log"
startBootstrapLeader "$ipAddress" "$netLogDir/bootstrap-leader-$ipAddress.log" $loopCount
bootstrapNodeDeployTime=$SECONDS
$metricsWriteDatapoint "testnet-deploy net-bootnode-leader-started=1"
@@ -500,7 +524,7 @@ start() {
SECONDS=0
pids=()
else
startNode "$ipAddress" $nodeType
startNode "$ipAddress" $nodeType $loopCount
# Stagger additional node start time. If too many nodes start simultaneously
# the bootstrap node gets more rsync requests from the additional nodes than

View File

@@ -11,7 +11,10 @@ numNodes="$4"
RUST_LOG="$5"
skipSetup="$6"
failOnValidatorBootupFailure="$7"
genesisOptions="$8"
externalPrimordialAccountsFile="$8"
stakeNodesInGenesisBlock="$9"
nodeIndex="${10}"
genesisOptions="${11}"
set +x
export RUST_LOG
@@ -77,6 +80,20 @@ local|tar)
export SOLANA_CUDA=1
fi
set -x
rm -rf ./solana-node-keys
rm -rf ./solana-node-stakes
mkdir ./solana-node-stakes
if [[ -n $stakeNodesInGenesisBlock ]]; then
for i in $(seq 0 "$numNodes"); do
solana-keygen new -o ./solana-node-keys/"$i"
pubkey="$(solana-keygen pubkey ./solana-node-keys/"$i")"
echo "${pubkey}: $stakeNodesInGenesisBlock" >> ./solana-node-stakes/fullnode-stakes.yml
done
fi
[[ -z $externalPrimordialAccountsFile ]] || cat "$externalPrimordialAccountsFile" >> ./solana-node-stakes/fullnode-stakes.yml
if [ -f ./solana-node-stakes/fullnode-stakes.yml ]; then
genesisOptions+=" --primordial-accounts-file ./solana-node-stakes/fullnode-stakes.yml"
fi
if [[ $skipSetup != true ]]; then
args=(
--bootstrap-leader-stake-lamports "$stake"
@@ -92,11 +109,17 @@ local|tar)
--gossip-port "$entrypointIp":8001
)
if [[ -n $stakeNodesInGenesisBlock ]]; then
args+=(--no-airdrop)
fi
nohup ./multinode-demo/validator.sh --bootstrap-leader "${args[@]}" > fullnode.log 2>&1 &
sleep 1
;;
validator|blockstreamer)
net/scripts/rsync-retry.sh -vPrc "$entrypointIp":~/.cargo/bin/ ~/.cargo/bin/
rm -f ~/solana/fullnode-identity.json
[[ -z $stakeNodesInGenesisBlock ]] || net/scripts/rsync-retry.sh -vPrc \
"$entrypointIp":~/solana/solana-node-keys/"$nodeIndex" ~/solana/fullnode-identity.json
if [[ -e /dev/nvidia0 && -x ~/.cargo/bin/solana-validator-cuda ]]; then
echo Selecting solana-validator-cuda
@@ -119,6 +142,14 @@ local|tar)
args+=(--enable-rpc-exit)
fi
if [[ -f ~/solana/fullnode-identity.json ]]; then
args+=(--identity ~/solana/fullnode-identity.json)
fi
if [[ -n $stakeNodesInGenesisBlock ]]; then
args+=(--no-airdrop)
fi
set -x
if [[ $skipSetup != true ]]; then
./multinode-demo/clear-config.sh
@@ -157,6 +188,11 @@ local|tar)
args=(
"$entrypointIp":~/solana "$entrypointIp:8001"
)
if [[ -n $stakeNodesInGenesisBlock ]]; then
args+=(--no-airdrop)
fi
if [[ $skipSetup != true ]]; then
./multinode-demo/clear-config.sh
fi