plumb staking_account and voting_keypair from multinode-demo to Vote (#3199)
* plumb staking_account and voting_keypair from bash to Vote
This commit is contained in:
committed by
Greg Fitzgerald
parent
c8c85ff93b
commit
0acdbc0d03
@ -110,6 +110,68 @@ tune_system() {
|
||||
fi
|
||||
}
|
||||
|
||||
airdrop() {
|
||||
declare keypair_file=$1
|
||||
declare host=$2
|
||||
declare amount=$3
|
||||
|
||||
declare address
|
||||
address=$($solana_wallet --keypair "$keypair_file" address)
|
||||
|
||||
# TODO: Until https://github.com/solana-labs/solana/issues/2355 is resolved
|
||||
# a fullnode needs N lamports as its vote account gets re-created on every
|
||||
# node restart, costing it lamports
|
||||
declare retries=5
|
||||
|
||||
while ! $solana_wallet --keypair "$keypair_file" --host "$host" airdrop "$amount"; do
|
||||
|
||||
# TODO: Consider moving this retry logic into `solana-wallet airdrop`
|
||||
# itself, currently it does not retry on "Connection refused" errors.
|
||||
((retries--))
|
||||
if [[ $retries -le 0 ]]; then
|
||||
echo "Airdrop to $address failed."
|
||||
return 1
|
||||
fi
|
||||
echo "Airdrop to $address failed. Remaining retries: $retries"
|
||||
sleep 1
|
||||
done
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
setup_fullnode_staking() {
|
||||
declare drone_address=$1
|
||||
declare fullnode_id_path=$2
|
||||
declare staker_id_path=$3
|
||||
|
||||
declare fullnode_id
|
||||
fullnode_id=$($solana_wallet --keypair "$fullnode_id_path" address)
|
||||
|
||||
declare staker_id
|
||||
staker_id=$($solana_wallet --keypair "$staker_id_path" address)
|
||||
|
||||
# A fullnode requires 43 lamports to function:
|
||||
# - one lamport to keep the node identity public key valid. TODO: really??
|
||||
# - 42 more for the staker account we fund
|
||||
airdrop "$fullnode_id_path" "$drone_address" 43 || return $?
|
||||
|
||||
# A little wrong, fund the staking account from the
|
||||
# to the node. Maybe next time consider doing this the opposite
|
||||
# way or use an ephemeral account
|
||||
$solana_wallet --keypair "$fullnode_id_path" \
|
||||
create-staking-account "$staker_id" 42 || return $?
|
||||
|
||||
# as the staker, set the node as the delegate and the staker as
|
||||
# the vote-signer
|
||||
$solana_wallet --keypair "$staker_id_path" \
|
||||
configure-staking-account \
|
||||
--delegate-account "$fullnode_id" \
|
||||
--authorize-voter "$staker_id" || return $?
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
# The directory on the bootstrap leader that is rsynced by other full nodes as
|
||||
# they boot (TODO: Eventually this should go away)
|
||||
SOLANA_RSYNC_CONFIG_DIR=$PWD/config
|
||||
|
Reference in New Issue
Block a user