Rework validator vote account defaults to half voting fees

This commit is contained in:
Michael Vines
2020-03-13 11:41:18 -07:00
parent 5c2cf04e10
commit 29fb79382c
20 changed files with 140 additions and 134 deletions

View File

@@ -18,10 +18,10 @@ while [[ -n $1 ]]; do
entrypoint=$2
args+=("$1" "$2")
shift 2
elif [[ $1 = --identity-keypair ]]; then
identity_keypair=$2
[[ -r $identity_keypair ]] || {
echo "$identity_keypair does not exist"
elif [[ $1 = --identity ]]; then
identity=$2
[[ -r $identity ]] || {
echo "$identity does not exist"
exit 1
}
args+=("$1" "$2")
@@ -52,29 +52,29 @@ while [[ -n $1 ]]; do
fi
done
: "${identity_keypair:="$SOLANA_ROOT"/farf/archiver-identity-keypair"$label".json}"
: "${identity:="$SOLANA_ROOT"/farf/archiver-identity"$label".json}"
: "${storage_keypair:="$SOLANA_ROOT"/farf/archiver-storage-keypair"$label".json}"
ledger="$SOLANA_ROOT"/farf/archiver-ledger"$label"
rpc_url=$($solana_gossip rpc-url --entrypoint "$entrypoint")
if [[ ! -r $identity_keypair ]]; then
$solana_keygen new --no-passphrase -so "$identity_keypair"
if [[ ! -r $identity ]]; then
$solana_keygen new --no-passphrase -so "$identity"
# See https://github.com/solana-labs/solana/issues/4344
$solana_cli --keypair "$identity_keypair" --url "$rpc_url" airdrop 1
$solana_cli --keypair "$identity" --url "$rpc_url" airdrop 1
fi
identity_pubkey=$($solana_keygen pubkey "$identity_keypair")
identity_pubkey=$($solana_keygen pubkey "$identity")
if [[ ! -r $storage_keypair ]]; then
$solana_keygen new --no-passphrase -so "$storage_keypair"
$solana_cli --keypair "$identity_keypair" --url "$rpc_url" \
$solana_cli --keypair "$identity" --url "$rpc_url" \
create-archiver-storage-account "$identity_pubkey" "$storage_keypair"
fi
default_arg --entrypoint "$entrypoint"
default_arg --identity-keypair "$identity_keypair"
default_arg --identity "$identity"
default_arg --storage-keypair "$storage_keypair"
default_arg --ledger "$ledger"

View File

@@ -64,8 +64,8 @@ while [[ -n $1 ]]; do
done
# These keypairs are created by ./setup.sh and included in the genesis config
identity_keypair=$SOLANA_CONFIG_DIR/bootstrap-validator/identity-keypair.json
vote_keypair="$SOLANA_CONFIG_DIR"/bootstrap-validator/vote-keypair.json
identity=$SOLANA_CONFIG_DIR/bootstrap-validator/identity.json
vote_account="$SOLANA_CONFIG_DIR"/bootstrap-validator/vote-account.json
ledger_dir="$SOLANA_CONFIG_DIR"/bootstrap-validator
[[ -d "$ledger_dir" ]] || {
@@ -81,8 +81,8 @@ args+=(
--ledger "$ledger_dir"
--rpc-port 8899
--snapshot-interval-slots 100
--identity-keypair "$identity_keypair"
--voting-keypair "$vote_keypair"
--identity "$identity"
--vote-account "$vote_account"
--rpc-faucet-address 127.0.0.1:9900
)
default_arg --gossip-port 8001

View File

@@ -80,16 +80,16 @@ if [[ -n ${positional_args[0]} ]]; then
fi
config_dir="$SOLANA_CONFIG_DIR/validator$label"
vote_keypair_path="$config_dir"/vote-keypair.json
stake_keypair_path="$config_dir"/stake-keypair.json
vote_account="$config_dir"/vote-account.json
stake_account="$config_dir"/stake-account.json
if [[ ! -f $vote_keypair_path ]]; then
echo "Error: $vote_keypair_path not found"
if [[ ! -f $vote_account ]]; then
echo "Error: $vote_account not found"
exit 1
fi
if [[ -f $stake_keypair_path ]]; then
echo "Error: $stake_keypair_path already exists"
if [[ -f $stake_account ]]; then
echo "Error: $stake_account already exists"
exit 1
fi
@@ -97,13 +97,13 @@ if ((airdrops_enabled)); then
$solana_cli "${common_args[@]}" airdrop "$stake_sol"
fi
$solana_keygen new --no-passphrase -so "$stake_keypair_path"
$solana_keygen new --no-passphrase -so "$stake_account"
set -x
$solana_cli "${common_args[@]}" \
vote-account "$vote_keypair_path"
vote-account "$vote_account"
$solana_cli "${common_args[@]}" \
create-stake-account "$stake_keypair_path" "$stake_sol"
create-stake-account "$stake_account" "$stake_sol"
$solana_cli "${common_args[@]}" \
delegate-stake $maybe_force "$stake_keypair_path" "$vote_keypair_path"
$solana_cli "${common_args[@]}" stakes "$stake_keypair_path"
delegate-stake $maybe_force "$stake_account" "$vote_account"
$solana_cli "${common_args[@]}" stakes "$stake_account"

View File

@@ -7,8 +7,8 @@ here=$(dirname "$0")
# shellcheck source=multinode-demo/common.sh
source "$here"/common.sh
[[ -f "$SOLANA_CONFIG_DIR"/faucet-keypair.json ]] || {
echo "$SOLANA_CONFIG_DIR/faucet-keypair.json not found, create it by running:"
[[ -f "$SOLANA_CONFIG_DIR"/faucet.json ]] || {
echo "$SOLANA_CONFIG_DIR/faucet.json not found, create it by running:"
echo
echo " ${here}/setup.sh"
exit 1
@@ -16,4 +16,4 @@ source "$here"/common.sh
set -x
# shellcheck disable=SC2086 # Don't want to double quote $solana_faucet
exec $solana_faucet --keypair "$SOLANA_CONFIG_DIR"/faucet-keypair.json "$@"
exec $solana_faucet --keypair "$SOLANA_CONFIG_DIR"/faucet.json "$@"

View File

@@ -11,29 +11,29 @@ mkdir -p "$SOLANA_CONFIG_DIR"/bootstrap-validator
# Create genesis ledger
if [[ -r $FAUCET_KEYPAIR ]]; then
cp -f "$FAUCET_KEYPAIR" "$SOLANA_CONFIG_DIR"/faucet-keypair.json
cp -f "$FAUCET_KEYPAIR" "$SOLANA_CONFIG_DIR"/faucet.json
else
$solana_keygen new --no-passphrase -fso "$SOLANA_CONFIG_DIR"/faucet-keypair.json
$solana_keygen new --no-passphrase -fso "$SOLANA_CONFIG_DIR"/faucet.json
fi
if [[ -f $BOOTSTRAP_VALIDATOR_IDENTITY_KEYPAIR ]]; then
cp -f "$BOOTSTRAP_VALIDATOR_IDENTITY_KEYPAIR" "$SOLANA_CONFIG_DIR"/bootstrap-validator/identity-keypair.json
cp -f "$BOOTSTRAP_VALIDATOR_IDENTITY_KEYPAIR" "$SOLANA_CONFIG_DIR"/bootstrap-validator/identity.json
else
$solana_keygen new --no-passphrase -so "$SOLANA_CONFIG_DIR"/bootstrap-validator/identity-keypair.json
$solana_keygen new --no-passphrase -so "$SOLANA_CONFIG_DIR"/bootstrap-validator/identity.json
fi
$solana_keygen new --no-passphrase -so "$SOLANA_CONFIG_DIR"/bootstrap-validator/vote-keypair.json
$solana_keygen new --no-passphrase -so "$SOLANA_CONFIG_DIR"/bootstrap-validator/stake-keypair.json
$solana_keygen new --no-passphrase -so "$SOLANA_CONFIG_DIR"/bootstrap-validator/vote-account.json
$solana_keygen new --no-passphrase -so "$SOLANA_CONFIG_DIR"/bootstrap-validator/stake-account.json
args=(
"$@"
--enable-warmup-epochs
--bootstrap-validator "$SOLANA_CONFIG_DIR"/bootstrap-validator/identity-keypair.json
"$SOLANA_CONFIG_DIR"/bootstrap-validator/vote-keypair.json
"$SOLANA_CONFIG_DIR"/bootstrap-validator/stake-keypair.json
--bootstrap-validator "$SOLANA_CONFIG_DIR"/bootstrap-validator/identity.json
"$SOLANA_CONFIG_DIR"/bootstrap-validator/vote-account.json
"$SOLANA_CONFIG_DIR"/bootstrap-validator/stake-account.json
)
default_arg --ledger "$SOLANA_CONFIG_DIR"/bootstrap-validator
default_arg --faucet-pubkey "$SOLANA_CONFIG_DIR"/faucet-keypair.json
default_arg --faucet-pubkey "$SOLANA_CONFIG_DIR"/faucet.json
default_arg --faucet-lamports 500000000000000000
default_arg --hashes-per-tick auto
default_arg --operating-mode development

View File

@@ -10,8 +10,8 @@ args=()
airdrops_enabled=1
node_sol=500 # 500 SOL: number of SOL to airdrop the node for transaction fees and vote account rent exemption (ignored if airdrops_enabled=0)
label=
identity_keypair_path=
voting_keypair_path=
identity=
vote_account=
no_restart=0
gossip_entrypoint=
ledger_dir=
@@ -69,19 +69,19 @@ while [[ -n $1 ]]; do
elif [[ $1 = --expected-shred-version ]]; then
args+=("$1" "$2")
shift 2
elif [[ $1 = --identity-keypair ]]; then
identity_keypair_path=$2
elif [[ $1 = --identity ]]; then
identity=$2
args+=("$1" "$2")
shift 2
elif [[ $1 = --voting-keypair ]]; then
voting_keypair_path=$2
elif [[ $1 = --authorized-voter ]]; then
args+=("$1" "$2")
shift 2
elif [[ $1 = --vote-account ]]; then
vote_account=$2
args+=("$1" "$2")
shift 2
elif [[ $1 = --storage-keypair ]]; then
storage_keypair_path=$2
storage_keypair=$2
args+=("$1" "$2")
shift 2
elif [[ $1 = --init-complete-file ]]; then
@@ -174,11 +174,11 @@ if [[ -n $REQUIRE_LEDGER_DIR ]]; then
fi
if [[ -n $REQUIRE_KEYPAIRS ]]; then
if [[ -z $identity_keypair_path ]]; then
usage "Error: --identity-keypair not specified"
if [[ -z $identity ]]; then
usage "Error: --identity not specified"
fi
if [[ -z $voting_keypair_path ]]; then
usage "Error: --voting-keypair not specified"
if [[ -z $vote_account ]]; then
usage "Error: --vote-account not specified"
fi
fi
@@ -205,18 +205,18 @@ fi
faucet_address="${gossip_entrypoint%:*}":9900
: "${identity_keypair_path:=$ledger_dir/identity-keypair.json}"
: "${voting_keypair_path:=$ledger_dir/vote-keypair.json}"
: "${storage_keypair_path:=$ledger_dir/storage-keypair.json}"
: "${identity:=$ledger_dir/identity.json}"
: "${vote_account:=$ledger_dir/vote-account.json}"
: "${storage_keypair:=$ledger_dir/storage-keypair.json}"
default_arg --entrypoint "$gossip_entrypoint"
if ((airdrops_enabled)); then
default_arg --rpc-faucet-address "$faucet_address"
fi
default_arg --identity-keypair "$identity_keypair_path"
default_arg --voting-keypair "$voting_keypair_path"
default_arg --storage-keypair "$storage_keypair_path"
default_arg --identity "$identity"
default_arg --vote-account "$vote_account"
default_arg --storage-keypair "$storage_keypair"
default_arg --ledger "$ledger_dir"
default_arg --log -
default_arg --enable-rpc-exit
@@ -254,27 +254,27 @@ trap 'kill_node_and_exit' INT TERM ERR
wallet() {
(
set -x
$solana_cli --keypair "$identity_keypair_path" --url "$rpc_url" "$@"
$solana_cli --keypair "$identity" --url "$rpc_url" "$@"
)
}
setup_validator_accounts() {
declare node_sol=$1
if ! wallet vote-account "$voting_keypair_path"; then
if ! wallet vote-account "$vote_account"; then
if ((airdrops_enabled)); then
echo "Adding $node_sol to validator identity account:"
wallet airdrop "$node_sol" || return $?
fi
echo "Creating validator vote account"
wallet create-vote-account "$voting_keypair_path" "$identity_keypair_path" || return $?
wallet create-vote-account "$vote_account" "$identity" || return $?
fi
echo "Validator vote account configured"
if ! wallet storage-account "$storage_keypair_path"; then
if ! wallet storage-account "$storage_keypair"; then
echo "Creating validator storage account"
wallet create-validator-storage-account "$identity_keypair_path" "$storage_keypair_path" || return $?
wallet create-validator-storage-account "$identity" "$storage_keypair" || return $?
fi
echo "Validator storage account configured"
@@ -286,9 +286,9 @@ setup_validator_accounts() {
rpc_url=$($solana_gossip rpc-url --entrypoint "$gossip_entrypoint" --any)
[[ -r "$identity_keypair_path" ]] || $solana_keygen new --no-passphrase -so "$identity_keypair_path"
[[ -r "$voting_keypair_path" ]] || $solana_keygen new --no-passphrase -so "$voting_keypair_path"
[[ -r "$storage_keypair_path" ]] || $solana_keygen new --no-passphrase -so "$storage_keypair_path"
[[ -r "$identity" ]] || $solana_keygen new --no-passphrase -so "$identity"
[[ -r "$vote_account" ]] || $solana_keygen new --no-passphrase -so "$vote_account"
[[ -r "$storage_keypair" ]] || $solana_keygen new --no-passphrase -so "$storage_keypair"
setup_validator_accounts "$node_sol"