vote_api cleanup (#3710)

* vote_api cleanup

* fixups

* fixup

* remove unused code

* revert removal of serialize and deserialize

* ...

* increase coverage, bootstrap staking

* Sagar's STAKE to my VOTE
This commit is contained in:
Rob Walker
2019-04-10 17:52:47 -07:00
committed by GitHub
parent 1b5845ac3e
commit f1e7237c09
24 changed files with 638 additions and 667 deletions

View File

@ -64,14 +64,14 @@ tune_system
$solana_ledger_tool --ledger "$SOLANA_CONFIG_DIR"/bootstrap-leader-ledger verify
bootstrap_leader_id_path="$SOLANA_CONFIG_DIR"/bootstrap-leader-id.json
bootstrap_leader_staker_id_path="$SOLANA_CONFIG_DIR"/bootstrap-leader-staker-id.json
bootstrap_leader_staker_id=$($solana_wallet --keypair "$bootstrap_leader_staker_id_path" address)
bootstrap_leader_vote_id_path="$SOLANA_CONFIG_DIR"/bootstrap-leader-vote-id.json
bootstrap_leader_vote_id=$($solana_wallet --keypair "$bootstrap_leader_vote_id_path" address)
trap 'kill "$pid" && wait "$pid"' INT TERM ERR
$program \
--identity "$bootstrap_leader_id_path" \
--voting-keypair "$bootstrap_leader_staker_id_path" \
--staking-account "$bootstrap_leader_staker_id" \
--voting-keypair "$bootstrap_leader_vote_id_path" \
--vote-account "$bootstrap_leader_vote_id" \
--ledger "$SOLANA_CONFIG_DIR"/bootstrap-leader-ledger \
--accounts "$SOLANA_CONFIG_DIR"/bootstrap-leader-accounts \
--rpc-port 8899 \

View File

@ -142,42 +142,32 @@ airdrop() {
return 0
}
setup_fullnode_staking() {
setup_vote_account() {
declare drone_address=$1
declare fullnode_id_path=$2
declare staker_id_path=$3
declare node_id_path=$2
declare vote_id_path=$3
declare fullnode_id
fullnode_id=$($solana_wallet --keypair "$fullnode_id_path" address)
declare node_id
node_id=$($solana_wallet --keypair "$node_id_path" address)
declare staker_id
staker_id=$($solana_wallet --keypair "$staker_id_path" address)
declare vote_id
vote_id=$($solana_wallet --keypair "$vote_id_path" address)
if [[ -f "$staker_id_path".configured ]]; then
echo "Staking account has already been configured"
if [[ -f "$vote_id_path".configured ]]; then
echo "Vote account has already been configured"
return 0
fi
# 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 $?
# - 42 more for the vote account we fund
airdrop "$node_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" --host "$drone_address" \
create-staking-account "$staker_id" 42 || return $?
# Fund the vote account from the node, with the node as the node_id
$solana_wallet --keypair "$node_id_path" --host "$drone_address" \
create-vote-account "$vote_id" "$node_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" --host "$drone_address" \
configure-staking-account \
--delegate-account "$fullnode_id" \
--authorize-voter "$staker_id" || return $?
touch "$staker_id_path".configured
touch "$vote_id_path".configured
return 0
}

View File

@ -114,16 +114,16 @@ if ((!self_setup)); then
exit 1
}
fullnode_id_path=$SOLANA_CONFIG_DIR/fullnode-id.json
fullnode_staker_id_path=$SOLANA_CONFIG_DIR/fullnode-staker-id.json
fullnode_vote_id_path=$SOLANA_CONFIG_DIR/fullnode-vote-id.json
ledger_config_dir=$SOLANA_CONFIG_DIR/fullnode-ledger
accounts_config_dir=$SOLANA_CONFIG_DIR/fullnode-accounts
else
mkdir -p "$SOLANA_CONFIG_DIR"
fullnode_id_path=$SOLANA_CONFIG_DIR/fullnode-id-x$self_setup_label.json
fullnode_staker_id_path=$SOLANA_CONFIG_DIR/fullnode-staker-id-x$self_setup_label.json
fullnode_vote_id_path=$SOLANA_CONFIG_DIR/fullnode-vote-id-x$self_setup_label.json
[[ -f "$fullnode_id_path" ]] || $solana_keygen -o "$fullnode_id_path"
[[ -f "$fullnode_staker_id_path" ]] || $solana_keygen -o "$fullnode_staker_id_path"
[[ -f "$fullnode_vote_id_path" ]] || $solana_keygen -o "$fullnode_vote_id_path"
echo "Finding a port.."
# Find an available port in the range 9100-9899
@ -141,8 +141,7 @@ else
accounts_config_dir=$SOLANA_CONFIG_DIR/fullnode-accounts-x$self_setup_label
fi
fullnode_id=$($solana_wallet --keypair "$fullnode_id_path" address)
fullnode_staker_id=$($solana_wallet --keypair "$fullnode_staker_id_path" address)
fullnode_vote_id=$($solana_wallet --keypair "$fullnode_vote_id_path" address)
[[ -r $fullnode_id_path ]] || {
@ -192,8 +191,8 @@ while true; do
$program \
--gossip-port "$gossip_port" \
--identity "$fullnode_id_path" \
--voting-keypair "$fullnode_staker_id_path" \
--staking-account "$fullnode_staker_id" \
--voting-keypair "$fullnode_vote_id_path" \
--vote-account "$fullnode_vote_id" \
--network "$leader_address" \
--ledger "$ledger_config_dir" \
--accounts "$accounts_config_dir" \
@ -204,7 +203,7 @@ while true; do
oom_score_adj "$pid" 1000
if ((setup_stakes)); then
setup_fullnode_staking "${leader_address%:*}" "$fullnode_id_path" "$fullnode_staker_id_path"
setup_vote_account "${leader_address%:*}" "$fullnode_id_path" "$fullnode_vote_id_path"
fi
set +x

View File

@ -76,10 +76,10 @@ if $bootstrap_leader; then
set -x
$solana_keygen -o "$SOLANA_CONFIG_DIR"/mint-id.json
$solana_keygen -o "$SOLANA_CONFIG_DIR"/bootstrap-leader-id.json
$solana_keygen -o "$SOLANA_CONFIG_DIR"/bootstrap-leader-staker-id.json
$solana_keygen -o "$SOLANA_CONFIG_DIR"/bootstrap-leader-vote-id.json
$solana_genesis \
--bootstrap-leader-keypair "$SOLANA_CONFIG_DIR"/bootstrap-leader-id.json \
--bootstrap-stake-keypair "$SOLANA_CONFIG_DIR"/bootstrap-leader-staker-id.json \
--bootstrap-vote-keypair "$SOLANA_CONFIG_DIR"/bootstrap-leader-vote-id.json \
--ledger "$SOLANA_RSYNC_CONFIG_DIR"/ledger \
--mint "$SOLANA_CONFIG_DIR"/mint-id.json \
--lamports "$lamports"
@ -91,6 +91,6 @@ if $fullnode; then
(
set -x
$solana_keygen -o "$SOLANA_CONFIG_DIR"/fullnode-id.json
$solana_keygen -o "$SOLANA_CONFIG_DIR"/fullnode-staker-id.json
$solana_keygen -o "$SOLANA_CONFIG_DIR"/fullnode-vote-id.json
)
fi