Fix internal node lamport funding and staking allocation logic (#5192)

* Plumb node funding from genesis

* Cleanup naming convention

*  Fix balance vs stake yml file logic

* Lamps not Stakes
This commit is contained in:
Dan Albert 2019-07-19 12:51:38 -06:00 committed by GitHub
parent 3f54c0f1a6
commit c95cda51c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 118 additions and 46 deletions

View File

@ -24,7 +24,9 @@ blockstreamer=false
deployUpdateManifest=true deployUpdateManifest=true
fetchLogs=true fetchLogs=true
maybeHashesPerTick= maybeHashesPerTick=
maybeStakeNodesInGenesisBlock= maybeDisableAirdrops=
maybeInternalNodesStakeLamports=
maybeInternalNodesLamports=
maybeExternalPrimordialAccountsFile= maybeExternalPrimordialAccountsFile=
maybeLamports= maybeLamports=
maybeLetsEncrypt= maybeLetsEncrypt=
@ -68,8 +70,12 @@ Deploys a CD testnet
-s - Skip start. Nodes will still be created or configured, but network software will not be started. -s - Skip start. Nodes will still be created or configured, but network software will not be started.
-S - Stop network software without tearing down nodes. -S - Stop network software without tearing down nodes.
-f - Discard validator nodes that didn't bootup successfully -f - Discard validator nodes that didn't bootup successfully
--stake-internal-nodes NUM_LAMPORTS --no-airdrop
- Amount to stake internal nodes. If set, airdrops are disabled. - If set, disables airdrops. Nodes must be funded in genesis block when airdrops are disabled.
--internal-nodes-stake-lamports NUM_LAMPORTS
- Amount to stake internal nodes.
--internal-nodes-lamports NUM_LAMPORTS
- Amount to fund internal nodes in genesis block
--external-accounts-file FILE_PATH --external-accounts-file FILE_PATH
- Path to external Primordial Accounts file, if it exists. - Path to external Primordial Accounts file, if it exists.
--hashes-per-tick NUM_HASHES|sleep|auto --hashes-per-tick NUM_HASHES|sleep|auto
@ -104,8 +110,14 @@ while [[ -n $1 ]]; do
elif [[ $1 = --lamports ]]; then elif [[ $1 = --lamports ]]; then
maybeLamports="$1 $2" maybeLamports="$1 $2"
shift 2 shift 2
elif [[ $1 = --stake-internal-nodes ]]; then elif [[ $1 = --no-airdrop ]]; then
maybeStakeNodesInGenesisBlock="$1 $2" maybeDisableAirdrops="$1"
shift 1
elif [[ $1 = --internal-nodes-stake-lamports ]]; then
maybeInternalNodesStakeLamports="$1 $2"
shift 2
elif [[ $1 = --internal-nodes-lamports ]]; then
maybeInternalNodesLamports="$1 $2"
shift 2 shift 2
elif [[ $1 = --external-accounts-file ]]; then elif [[ $1 = --external-accounts-file ]]; then
maybeExternalPrimordialAccountsFile="$1 $2" maybeExternalPrimordialAccountsFile="$1 $2"
@ -389,9 +401,17 @@ if ! $skipStart; then
args+=(--deploy-update windows) args+=(--deploy-update windows)
fi fi
if [[ -n $maybeStakeNodesInGenesisBlock ]]; then if [[ -n $maybeDisableAirdrops ]]; then
# shellcheck disable=SC2206 # Do not want to quote $maybeStakeNodesInGenesisBlock # shellcheck disable=SC2206
args+=($maybeStakeNodesInGenesisBlock) args+=($maybeDisableAirdrops)
fi
if [[ -n $maybeInternalNodesStakeLamports ]]; then
# shellcheck disable=SC2206 # Do not want to quote $maybeInternalNodesStakeLamports
args+=($maybeInternalNodesStakeLamports)
fi
if [[ -n $maybeInternalNodesLamports ]]; then
# shellcheck disable=SC2206 # Do not want to quote $maybeInternalNodesLamports
args+=($maybeInternalNodesLamports)
fi fi
if [[ -n $maybeExternalPrimordialAccountsFile ]]; then if [[ -n $maybeExternalPrimordialAccountsFile ]]; then
# shellcheck disable=SC2206 # Do not want to quote $maybeExternalPrimordialAccountsFile # shellcheck disable=SC2206 # Do not want to quote $maybeExternalPrimordialAccountsFile

View File

@ -500,12 +500,30 @@ deploy() {
maybeHashesPerTick="--hashes-per-tick ${HASHES_PER_TICK}" maybeHashesPerTick="--hashes-per-tick ${HASHES_PER_TICK}"
fi fi
if [[ -z $STAKE_INTERNAL_NODES ]]; then if [[ -z $DISABLE_AIRDROPS ]]; then
maybeStakeInternalNodes="--stake-internal-nodes 1000000000000" DISABLE_AIRDROPS="true"
elif [[ $STAKE_INTERNAL_NODES == skip ]]; then fi
maybeStakeInternalNodes=""
if [[ $DISABLE_AIRDROPS == true ]] ; then
maybeDisableAirdrops="--no-airdrop"
else else
maybeStakeInternalNodes="--stake-internal-nodes ${STAKE_INTERNAL_NODES}" maybeDisableAirdrops=""
fi
if [[ -z $INTERNAL_NODES_STAKE_LAMPORTS ]]; then
maybeInternalNodesStakeLamports="--internal-nodes-stake-lamports 1000000000000"
elif [[ $INTERNAL_NODES_STAKE_LAMPORTS == skip ]]; then
maybeInternalNodesStakeLamports=""
else
maybeInternalNodesStakeLamports="--internal-nodes-stake-lamports ${INTERNAL_NODES_STAKE_LAMPORTS}"
fi
if [[ -z $INTERNAL_NODES_LAMPORTS ]]; then
maybeInternalNodesLamports="--internal-nodes-lamports 2000000000000"
elif [[ $INTERNAL_NODES_LAMPORTS == skip ]]; then
maybeInternalNodesLamports=""
else
maybeInternalNodesLamports="--internal-nodes-lamports ${INTERNAL_NODES_LAMPORTS}"
fi fi
EXTERNAL_ACCOUNTS_FILE=/tmp/validator.yml EXTERNAL_ACCOUNTS_FILE=/tmp/validator.yml
@ -557,7 +575,9 @@ deploy() {
${skipStart:+-s} \ ${skipStart:+-s} \
${maybeStop:+-S} \ ${maybeStop:+-S} \
${maybeDelete:+-D} \ ${maybeDelete:+-D} \
${maybeStakeInternalNodes} \ ${maybeDisableAirdrops} \
${maybeInternalNodesStakeLamports} \
${maybeInternalNodesLamports} \
${maybeExternalAccountsFile} \ ${maybeExternalAccountsFile} \
${maybeLamports} \ ${maybeLamports} \
${maybeAdditionalDisk} \ ${maybeAdditionalDisk} \

View File

@ -27,6 +27,7 @@ Start a validator or a replicator
--label LABEL - Append the given label to the configuration files, useful when running --label LABEL - Append the given label to the configuration files, useful when running
multiple fullnodes in the same workspace multiple fullnodes in the same workspace
--stake LAMPORTS - Number of lamports to stake --stake LAMPORTS - Number of lamports to stake
--node-lamports LAMPORTS - Number of lamports this node has been funded from the genesis block
--no-voting - start node without vote signer --no-voting - start node without vote signer
--rpc-port port - custom RPC port for this node --rpc-port port - custom RPC port for this node
--no-restart - do not restart the node if it exits --no-restart - do not restart the node if it exits
@ -217,6 +218,9 @@ while [[ -n $1 ]]; do
elif [[ $1 = --stake ]]; then elif [[ $1 = --stake ]]; then
stake_lamports="$2" stake_lamports="$2"
shift 2 shift 2
elif [[ $1 = --node-lamports ]]; then
node_lamports="$2"
shift 2
elif [[ $1 = --no-voting ]]; then elif [[ $1 = --no-voting ]]; then
args+=("$1") args+=("$1")
shift shift

View File

@ -56,12 +56,16 @@ Operate a configured testnet
--hashes-per-tick NUM_HASHES|sleep|auto --hashes-per-tick NUM_HASHES|sleep|auto
- Override the default --hashes-per-tick for the cluster - Override the default --hashes-per-tick for the cluster
--no-airdrop
- If set, disables airdrops. Nodes must be funded in genesis block when airdrops are disabled.
--lamports NUM_LAMPORTS_TO_MINT --lamports NUM_LAMPORTS_TO_MINT
- Override the default 100000000000000 lamports minted in genesis - Override the default 100000000000000 lamports minted in genesis
--stake-internal-nodes NUM_LAMPORTS_PER_NODE --internal-nodes-stake-lamports NUM_LAMPORTS_PER_NODE
- Amount to stake internal nodes in genesis block. If set, airdrops are disabled. - Amount to stake internal nodes.
--internal-nodes-lamports NUM_LAMPORTS_PER_NODE
- Amount to fund internal nodes in genesis block.
--external-accounts-file FILE_PATH --external-accounts-file FILE_PATH
- A YML file with a list of account pubkeys and corresponding stakes for external nodes - A YML file with a list of account pubkeys and corresponding lamport balances in genesis block for external nodes
--no-snapshot --no-snapshot
- If set, disables booting validators from a snapshot - If set, disables booting validators from a snapshot
--skip-ledger-verify --skip-ledger-verify
@ -108,9 +112,11 @@ genesisOptions=
numFullnodesRequested= numFullnodesRequested=
externalPrimordialAccountsFile= externalPrimordialAccountsFile=
remoteExternalPrimordialAccountsFile= remoteExternalPrimordialAccountsFile=
stakeNodesInGenesisBlock= internalNodesStakeLamports=
internalNodesLamports=
maybeNoSnapshot="" maybeNoSnapshot=""
maybeSkipLedgerVerify="" maybeSkipLedgerVerify=""
maybeDisableAirdrops=""
command=$1 command=$1
[[ -n $command ]] || usage [[ -n $command ]] || usage
@ -137,13 +143,19 @@ while [[ -n $1 ]]; do
elif [[ $1 = --deploy-update ]]; then elif [[ $1 = --deploy-update ]]; then
updatePlatforms="$updatePlatforms $2" updatePlatforms="$updatePlatforms $2"
shift 2 shift 2
elif [[ $1 = --stake-internal-nodes ]]; then elif [[ $1 = --internal-nodes-stake-lamports ]]; then
stakeNodesInGenesisBlock="$2" internalNodesStakeLamports="$2"
shift 2
elif [[ $1 = --internal-nodes-lamports ]]; then
internalNodesLamports="$2"
shift 2 shift 2
elif [[ $1 = --external-accounts-file ]]; then elif [[ $1 = --external-accounts-file ]]; then
externalPrimordialAccountsFile="$2" externalPrimordialAccountsFile="$2"
remoteExternalPrimordialAccountsFile=/tmp/external-primordial-accounts.yml remoteExternalPrimordialAccountsFile=/tmp/external-primordial-accounts.yml
shift 2 shift 2
elif [[ $1 = --no-airdrop ]]; then
maybeDisableAirdrops="$1"
shift 1
else else
usage "Unknown long option: $1" usage "Unknown long option: $1"
fi fi
@ -369,7 +381,9 @@ startBootstrapLeader() {
$skipSetup \ $skipSetup \
$failOnValidatorBootupFailure \ $failOnValidatorBootupFailure \
\"$remoteExternalPrimordialAccountsFile\" \ \"$remoteExternalPrimordialAccountsFile\" \
\"$stakeNodesInGenesisBlock\" \ \"$maybeDisableAirdrops\" \
\"$internalNodesStakeLamports\" \
\"$internalNodesLamports\" \
$nodeIndex \ $nodeIndex \
$numBenchTpsClients \"$benchTpsExtraArgs\" \ $numBenchTpsClients \"$benchTpsExtraArgs\" \
$numBenchExchangeClients \"$benchExchangeExtraArgs\" \ $numBenchExchangeClients \"$benchExchangeExtraArgs\" \
@ -431,7 +445,9 @@ startNode() {
$skipSetup \ $skipSetup \
$failOnValidatorBootupFailure \ $failOnValidatorBootupFailure \
\"$remoteExternalPrimordialAccountsFile\" \ \"$remoteExternalPrimordialAccountsFile\" \
\"$stakeNodesInGenesisBlock\" \ \"$maybeDisableAirdrops\" \
\"$internalNodesStakeLamports\" \
\"$internalNodesLamports\" \
$nodeIndex \ $nodeIndex \
$numBenchTpsClients \"$benchTpsExtraArgs\" \ $numBenchTpsClients \"$benchTpsExtraArgs\" \
$numBenchExchangeClients \"$benchExchangeExtraArgs\" \ $numBenchExchangeClients \"$benchExchangeExtraArgs\" \

View File

@ -12,14 +12,16 @@ RUST_LOG="$5"
skipSetup="$6" skipSetup="$6"
failOnValidatorBootupFailure="$7" failOnValidatorBootupFailure="$7"
externalPrimordialAccountsFile="$8" externalPrimordialAccountsFile="$8"
stakeNodesInGenesisBlock="$9" maybeDisableAirdrops="$9"
nodeIndex="${10}" internalNodesStakeLamports="${10}"
numBenchTpsClients="${11}" internalNodesLamports="${11}"
benchTpsExtraArgs="${12}" nodeIndex="${12}"
numBenchExchangeClients="${13}" numBenchTpsClients="${13}"
benchExchangeExtraArgs="${14}" benchTpsExtraArgs="${14}"
genesisOptions="${15}" numBenchExchangeClients="${15}"
extraNodeArgs="${16}" benchExchangeExtraArgs="${16}"
genesisOptions="${17}"
extraNodeArgs="${18}"
set +x set +x
export RUST_LOG export RUST_LOG
@ -29,7 +31,7 @@ export RUST_LOG
# trouble # trouble
# #
# Ref: https://github.com/solana-labs/solana/issues/3798 # Ref: https://github.com/solana-labs/solana/issues/3798
stake=424243 stake=${internalNodesStakeLamports:=424243}
missing() { missing() {
echo "Error: $1 not specified" echo "Error: $1 not specified"
@ -44,7 +46,7 @@ missing() {
[[ -n $failOnValidatorBootupFailure ]] || missing failOnValidatorBootupFailure [[ -n $failOnValidatorBootupFailure ]] || missing failOnValidatorBootupFailure
airdropsEnabled=true airdropsEnabled=true
if [[ -n $stakeNodesInGenesisBlock ]]; then if [[ -n $maybeDisableAirdrops ]]; then
airdropsEnabled=false airdropsEnabled=false
fi fi
cat > deployConfig <<EOF cat > deployConfig <<EOF
@ -107,13 +109,13 @@ local|tar)
fi fi
set -x set -x
rm -rf ./solana-node-keys rm -rf ./solana-node-keys
rm -rf ./solana-node-stakes rm -rf ./solana-node-balances
mkdir ./solana-node-stakes mkdir ./solana-node-balances
if [[ -n $stakeNodesInGenesisBlock ]]; then if [[ -n $internalNodesLamports ]]; then
for i in $(seq 0 "$numNodes"); do for i in $(seq 0 "$numNodes"); do
solana-keygen new -o ./solana-node-keys/"$i" solana-keygen new -o ./solana-node-keys/"$i"
pubkey="$(solana-keygen pubkey ./solana-node-keys/"$i")" pubkey="$(solana-keygen pubkey ./solana-node-keys/"$i")"
echo "${pubkey}: $stakeNodesInGenesisBlock" >> ./solana-node-stakes/fullnode-stakes.yml echo "${pubkey}: $internalNodesLamports" >> ./solana-node-balances/fullnode-balances.yml
done done
fi fi
@ -144,9 +146,9 @@ local|tar)
tail -n +2 -q ./solana-client-accounts/bench-exchange"$i".yml >> ./solana-client-accounts/client-accounts.yml tail -n +2 -q ./solana-client-accounts/bench-exchange"$i".yml >> ./solana-client-accounts/client-accounts.yml
echo "" >> ./solana-client-accounts/client-accounts.yml echo "" >> ./solana-client-accounts/client-accounts.yml
done done
[[ -z $externalPrimordialAccountsFile ]] || cat "$externalPrimordialAccountsFile" >> ./solana-node-stakes/fullnode-stakes.yml [[ -z $externalPrimordialAccountsFile ]] || cat "$externalPrimordialAccountsFile" >> ./solana-node-balances/fullnode-balances.yml
if [ -f ./solana-node-stakes/fullnode-stakes.yml ]; then if [ -f ./solana-node-balances/fullnode-balances.yml ]; then
genesisOptions+=" --primordial-accounts-file ./solana-node-stakes/fullnode-stakes.yml" genesisOptions+=" --primordial-accounts-file ./solana-node-balances/fullnode-balances.yml"
fi fi
if [ -f ./solana-client-accounts/client-accounts.yml ]; then if [ -f ./solana-client-accounts/client-accounts.yml ]; then
genesisOptions+=" --primordial-keypairs-file ./solana-client-accounts/client-accounts.yml" genesisOptions+=" --primordial-keypairs-file ./solana-client-accounts/client-accounts.yml"
@ -154,12 +156,15 @@ local|tar)
if [[ $skipSetup != true ]]; then if [[ $skipSetup != true ]]; then
args=( args=(
--bootstrap-leader-stake-lamports "$stake" --bootstrap-leader-stake-lamports "$stake"
) )
if [[ -n $internalNodesLamports ]]; then
args+=(--bootstrap-leader-lamports "$internalNodesLamports")
fi
# shellcheck disable=SC2206 # Do not want to quote $genesisOptions # shellcheck disable=SC2206 # Do not want to quote $genesisOptions
args+=($genesisOptions) args+=($genesisOptions)
./multinode-demo/setup.sh "${args[@]}" ./multinode-demo/setup.sh "${args[@]}"
fi fi
if [[ -z $stakeNodesInGenesisBlock ]]; then if [[ $airdropsEnabled = true ]]; then
./multinode-demo/drone.sh > drone.log 2>&1 & ./multinode-demo/drone.sh > drone.log 2>&1 &
fi fi
args=( args=(
@ -167,7 +172,7 @@ local|tar)
--gossip-port "$entrypointIp":8001 --gossip-port "$entrypointIp":8001
) )
if [[ -n $stakeNodesInGenesisBlock ]]; then if [[ $airdropsEnabled != true ]]; then
args+=(--no-airdrop) args+=(--no-airdrop)
fi fi
args+=(--init-complete-file "$initCompleteFile") args+=(--init-complete-file "$initCompleteFile")
@ -179,7 +184,7 @@ local|tar)
validator|blockstreamer) validator|blockstreamer)
net/scripts/rsync-retry.sh -vPrc "$entrypointIp":~/.cargo/bin/ ~/.cargo/bin/ net/scripts/rsync-retry.sh -vPrc "$entrypointIp":~/.cargo/bin/ ~/.cargo/bin/
rm -f ~/solana/fullnode-identity.json rm -f ~/solana/fullnode-identity.json
[[ -z $stakeNodesInGenesisBlock ]] || net/scripts/rsync-retry.sh -vPrc \ [[ -z $internalNodesLamports ]] || net/scripts/rsync-retry.sh -vPrc \
"$entrypointIp":~/solana/solana-node-keys/"$nodeIndex" ~/solana/fullnode-identity.json "$entrypointIp":~/solana/solana-node-keys/"$nodeIndex" ~/solana/fullnode-identity.json
if [[ -e /dev/nvidia0 && -x ~/.cargo/bin/solana-validator-cuda ]]; then if [[ -e /dev/nvidia0 && -x ~/.cargo/bin/solana-validator-cuda ]]; then
@ -202,13 +207,16 @@ local|tar)
else else
args+=(--stake "$stake") args+=(--stake "$stake")
args+=(--enable-rpc-exit) args+=(--enable-rpc-exit)
if [[ -n $internalNodesLamports ]]; then
args+=(--node-lamports "$internalNodesLamports")
fi
fi fi
if [[ -f ~/solana/fullnode-identity.json ]]; then if [[ -f ~/solana/fullnode-identity.json ]]; then
args+=(--identity ~/solana/fullnode-identity.json) args+=(--identity ~/solana/fullnode-identity.json)
fi fi
if [[ -n $stakeNodesInGenesisBlock ]]; then if [[ $airdropsEnabled != true ]]; then
args+=(--no-airdrop) args+=(--no-airdrop)
fi fi
@ -223,7 +231,7 @@ local|tar)
# a static IP/DNS name for hosting the blockexplorer web app, and is # a static IP/DNS name for hosting the blockexplorer web app, and is
# a location that somebody would expect to be able to airdrop from # a location that somebody would expect to be able to airdrop from
scp "$entrypointIp":~/solana/config-local/mint-keypair.json config-local/ scp "$entrypointIp":~/solana/config-local/mint-keypair.json config-local/
if [[ -z $stakeNodesInGenesisBlock ]]; then if [[ $airdropsEnabled = true ]]; then
./multinode-demo/drone.sh > drone.log 2>&1 & ./multinode-demo/drone.sh > drone.log 2>&1 &
fi fi
@ -262,10 +270,14 @@ local|tar)
"$entrypointIp":~/solana "$entrypointIp:8001" "$entrypointIp":~/solana "$entrypointIp:8001"
) )
if [[ -n $stakeNodesInGenesisBlock ]]; then if [[ $airdropsEnabled != true ]]; then
args+=(--no-airdrop) args+=(--no-airdrop)
fi fi
if [[ -n $internalNodesLamports ]] ; then
args+=(--node-lamports "$internalNodesLamports")
fi
if [[ $skipSetup != true ]]; then if [[ $skipSetup != true ]]; then
./multinode-demo/clear-config.sh ./multinode-demo/clear-config.sh
fi fi