Surface --voting-keypair to release users (#5420)

* Remove 'configured_flag' for vote/storage account, instead detect if they exist with the wallet

* Require --voting-keypair when using release binaries
This commit is contained in:
Michael Vines 2019-08-05 10:39:16 -07:00 committed by GitHub
parent 56ed033233
commit 09ca92d416
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 61 additions and 51 deletions

View File

@ -144,28 +144,42 @@ $ solana-gossip --entrypoint testnet.solana.com:8001 spy
# Press ^C to exit # Press ^C to exit
``` ```
Now configure a key pair for your validator by running: Now create an identity keypair for your validator by running:
```bash ```bash
$ solana-keygen new -o ~/validator-keypair.json $ solana-keygen new -o ~/validator-keypair.json
``` ```
and airdrop yourself some lamports to get started:
```bash
$ solana-wallet --keypair ~/validator-keypair.json airdrop 1000
```
Your validator will need a vote account. Create it now with the following
commands:
```bash
$ solana-keygen new -o ~/validator-vote-keypair.json
$ VOTE_PUBKEY=$(solana-keygen pubkey ~/validator-vote-keypair.json)
$ IDENTITY_PUBKEY=$(solana-keygen pubkey ~/validator-keypair.json)
$ solana-wallet create-vote-account "$VOTE_PUBKEY" "$IDENTITY_PUBKEY" 1
```
Then use one of the following commands, depending on your installation Then use one of the following commands, depending on your installation
choice, to start the node: choice, to start the node:
If this is a `solana-install`-installation: If this is a `solana-install`-installation:
```bash ```bash
$ validator.sh --identity ~/validator-keypair.json --config-dir ~/validator-config --rpc-port 8899 --poll-for-new-genesis-block testnet.solana.com $ validator.sh --identity ~/validator-keypair.json --voting-keypair ~/validator-vote-keypair.json --config-dir ~/validator-config --rpc-port 8899 --poll-for-new-genesis-block testnet.solana.com
``` ```
Alternatively, the `solana-install run` command can be used to run the validator Alternatively, the `solana-install run` command can be used to run the validator
node while periodically checking for and applying software updates: node while periodically checking for and applying software updates:
```bash ```bash
$ solana-install run validator.sh -- --identity ~/validator-keypair.json --config-dir ~/validator-config --rpc-port 8899 --poll-for-new-genesis-block testnet.solana.com $ solana-install run validator.sh -- --identity ~/validator-keypair.json --voting-keypair ~/validator-vote-keypair.json --config-dir ~/validator-config --rpc-port 8899 --poll-for-new-genesis-block testnet.solana.com
``` ```
If you built from source: If you built from source:
```bash ```bash
$ NDEBUG=1 USE_INSTALL=1 ./multinode-demo/validator.sh --identity ~/validator-keypair.json --rpc-port 8899 --poll-for-new-genesis-block testnet.solana.com $ NDEBUG=1 USE_INSTALL=1 ./multinode-demo/validator.sh --identity ~/validator-keypair.json --voting-keypair ~/validator-vote-keypair.json --rpc-port 8899 --poll-for-new-genesis-block testnet.solana.com
``` ```
#### Enabling CUDA #### Enabling CUDA
@ -221,10 +235,7 @@ $ solana-wallet show-vote-account 2ozWvfaXQd1X6uKh8jERoRGApDqSqcEy6fF1oN13LL2G
The vote pubkey for the validator can also be found by running: The vote pubkey for the validator can also be found by running:
```bash ```bash
# If this is a `solana-install`-installation run: $ solana-keygen pubkey ~/validator-vote-keypair.json
$ solana-keygen pubkey ~/.local/share/solana/install/active_release/config/validator-vote-keypair.json
# Otherwise run:
$ solana-keygen pubkey ./config/validator-vote-keypair.json
``` ```
#### Validator Metrics #### Validator Metrics

View File

@ -102,6 +102,7 @@ set -e
cd "$(dirname "$0")"/.. cd "$(dirname "$0")"/..
export USE_INSTALL=1 export USE_INSTALL=1
export REQUIRE_CONFIG_DIR=1 export REQUIRE_CONFIG_DIR=1
export REQUIRE_KEYPAIRS=1
exec multinode-demo/validator.sh "$@" exec multinode-demo/validator.sh "$@"
EOF EOF
chmod +x solana-release/bin/validator.sh chmod +x solana-release/bin/validator.sh

View File

@ -33,61 +33,51 @@ EOF
exit 1 exit 1
} }
wallet() {
(
set -x
$solana_wallet --keypair "$identity_keypair_path" --url "$rpc_url" "$@"
)
}
setup_validator_accounts() { setup_validator_accounts() {
declare node_lamports=$1 declare node_lamports=$1
if [[ -f $configured_flag ]]; then if ((airdrops_enabled)); then
echo "Vote and stake accounts have already been configured" echo "Adding $node_lamports to validator identity account:"
(
declare fees=100 # TODO: No hardcoded transaction fees, fetch the current cluster fees
wallet airdrop $((node_lamports+fees))
) || return $?
else else
if ((airdrops_enabled)); then echo "Validator identity account balance:"
echo "Fund the node with enough tokens to fund its Vote, Staking, and Storage accounts" wallet balance || return $?
(
declare fees=100 # TODO: No hardcoded transaction fees, fetch the current cluster fees
set -x
$solana_wallet --keypair "$identity_keypair_path" --url "$rpc_url" \
airdrop $((node_lamports+fees))
) || return $?
else
echo "current account balance is "
$solana_wallet --keypair "$identity_keypair_path" --url "$rpc_url" balance || return $?
fi
echo "Fund the vote account from the node's identity pubkey"
(
set -x
$solana_wallet --keypair "$identity_keypair_path" --url "$rpc_url" \
create-vote-account "$vote_pubkey" "$identity_pubkey" 1 --commission 127
) || return $?
echo "Create validator storage account"
(
set -x
$solana_wallet --keypair "$identity_keypair_path" --url "$rpc_url" \
create-validator-storage-account "$identity_pubkey" "$storage_pubkey"
) || return $?
touch "$configured_flag"
fi fi
echo "Identity account balance:" if ! wallet show-vote-account "$vote_pubkey"; then
( echo "Creating validator vote account"
set -x wallet create-vote-account "$vote_pubkey" "$identity_pubkey" 1 --commission 127 || return $?
$solana_wallet --keypair "$identity_keypair_path" --url "$rpc_url" balance fi
$solana_wallet --keypair "$identity_keypair_path" --url "$rpc_url" \ echo "Validator vote account configured"
show-vote-account "$vote_pubkey"
$solana_wallet --keypair "$identity_keypair_path" --url "$rpc_url" \ if ! wallet show-storage-account "$storage_pubkey"; then
show-storage-account "$storage_pubkey" echo "Creating validator storage account"
) wallet create-validator-storage-account "$identity_pubkey" "$storage_pubkey" || return $?
fi
echo "Validator storage account configured"
return 0 return 0
} }
args=() args=()
node_lamports=424242 # number of lamports to assign the node for transaction fees airdrops_enabled=1
node_lamports=424242 # number of lamports to airdrop the node for transaction fees (ignored if airdrops_enabled=0)
poll_for_new_genesis_block=0 poll_for_new_genesis_block=0
label= label=
identity_keypair_path= identity_keypair_path=
voting_keypair_path=
no_restart=0 no_restart=0
airdrops_enabled=1
# TODO: Enable boot_from_snapshot when snapshots work # TODO: Enable boot_from_snapshot when snapshots work
#boot_from_snapshot=1 #boot_from_snapshot=1
boot_from_snapshot=0 boot_from_snapshot=0
@ -191,6 +181,15 @@ if [[ -n $REQUIRE_CONFIG_DIR ]]; then
SOLANA_CONFIG_DIR="$config_dir" SOLANA_CONFIG_DIR="$config_dir"
fi fi
if [[ -n $REQUIRE_KEYPAIRS ]]; then
if [[ -z $identity_keypair_path ]]; then
usage "Error: --identity not specified"
fi
if [[ -z $voting_keypair_path ]]; then
usage "Error: --voting-keypair not specified"
fi
fi
if [[ -z "$config_dir" ]]; then if [[ -z "$config_dir" ]]; then
config_dir="$SOLANA_CONFIG_DIR/validator$label" config_dir="$SOLANA_CONFIG_DIR/validator$label"
fi fi
@ -227,7 +226,6 @@ drone_address="${gossip_entrypoint%:*}":9900
ledger_config_dir=$config_dir/ledger ledger_config_dir=$config_dir/ledger
state_dir="$config_dir"/state state_dir="$config_dir"/state
configured_flag=$config_dir/.configured
default_arg --entrypoint "$gossip_entrypoint" default_arg --entrypoint "$gossip_entrypoint"
if ((airdrops_enabled)); then if ((airdrops_enabled)); then
@ -311,7 +309,7 @@ while true; do
# over again # over again
( (
set -x set -x
rm -rf "$ledger_config_dir" "$state_dir" "$configured_flag" rm -rf "$ledger_config_dir" "$state_dir"
) )
fi fi