net/ testnet nodes now stake more lamports (#3812)

* Add --bootstrap-leader-lamports

* Generalize --no-stake into --stake NUM

* Use a large stake for net/ fullnodes

* Setup vote account before starting fullnode to avoid mixed log output
This commit is contained in:
Michael Vines
2019-04-16 13:03:01 -07:00
committed by GitHub
parent a4b5493ba1
commit 63d66ece57
9 changed files with 68 additions and 29 deletions

View File

@ -96,18 +96,18 @@ The following command will start a new validator node.
If this is a `solana-install`-installation: If this is a `solana-install`-installation:
```bash ```bash
$ fullnode-x.sh --public-address --no-stake --poll-for-new-genesis-block beta.testnet.solana.com:8001 $ fullnode-x.sh --public-address --poll-for-new-genesis-block beta.testnet.solana.com:8001
``` ```
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 fullnode-x.sh --public-address --no-stake --poll-for-new-genesis-block beta.testnet.solana.com:8001 $ solana-install run fullnode-x.sh --public-address --poll-for-new-genesis-block beta.testnet.solana.com:8001
``` ```
When not using `solana-install`: When not using `solana-install`:
```bash ```bash
$ USE_INSTALL=1 ./multinode-demo/fullnode-x.sh --public-address --no-stake --poll-for-new-genesis-block beta.testnet.solana.com:8001 $ USE_INSTALL=1 ./multinode-demo/fullnode-x.sh --public-address --poll-for-new-genesis-block beta.testnet.solana.com:8001
``` ```
Then from another console, confirm the IP address if your node is now visible in Then from another console, confirm the IP address if your node is now visible in

View File

@ -55,7 +55,7 @@ while getopts "ch?i:k:brxR" opt; do
restartInterval=$OPTARG restartInterval=$OPTARG
;; ;;
b) b)
maybeNoLeaderRotation="--no-stake" maybeNoLeaderRotation="--stake 0"
;; ;;
x) x)
extraNodes=$((extraNodes + 1)) extraNodes=$((extraNodes + 1))

View File

@ -42,7 +42,7 @@ pub fn vote_account_balances_at_epoch(
node_staked_accounts.map(|epoch_state| epoch_state.map(|(id, stake, _)| (*id, stake)).collect()) node_staked_accounts.map(|epoch_state| epoch_state.map(|(id, stake, _)| (*id, stake)).collect())
} }
/// At the specified epoch, collect the delgate account balance and vote states for delegates /// At the specified epoch, collect the delegate account balance and vote states for delegates
/// that have non-zero balance in any of their managed staking accounts /// that have non-zero balance in any of their managed staking accounts
pub fn delegated_stakes_at_epoch(bank: &Bank, epoch_height: u64) -> Option<HashMap<Pubkey, u64>> { pub fn delegated_stakes_at_epoch(bank: &Bank, epoch_height: u64) -> Option<HashMap<Pubkey, u64>> {
let node_staked_accounts = node_staked_accounts_at_epoch(bank, epoch_height); let node_staked_accounts = node_staked_accounts_at_epoch(bank, epoch_height);

View File

@ -14,6 +14,7 @@ use std::error;
pub const BOOTSTRAP_LEADER_LAMPORTS: u64 = 43; pub const BOOTSTRAP_LEADER_LAMPORTS: u64 = 43;
fn main() -> Result<(), Box<dyn error::Error>> { fn main() -> Result<(), Box<dyn error::Error>> {
let default_bootstrap_leader_lamports = &BOOTSTRAP_LEADER_LAMPORTS.to_string();
let matches = App::new(crate_name!()) let matches = App::new(crate_name!())
.about(crate_description!()) .about(crate_description!())
.version(crate_version!()) .version(crate_version!())
@ -62,6 +63,15 @@ fn main() -> Result<(), Box<dyn error::Error>> {
.required(true) .required(true)
.help("Path to file containing the bootstrap leader's staking keypair"), .help("Path to file containing the bootstrap leader's staking keypair"),
) )
.arg(
Arg::with_name("bootstrap_leader_lamports")
.long("bootstrap-leader-lamports")
.value_name("LAMPORTS")
.takes_value(true)
.default_value(default_bootstrap_leader_lamports)
.required(true)
.help("Number of lamports to assign to the bootstrap leader"),
)
.get_matches(); .get_matches();
let bootstrap_leader_keypair_file = matches.value_of("bootstrap_leader_keypair_file").unwrap(); let bootstrap_leader_keypair_file = matches.value_of("bootstrap_leader_keypair_file").unwrap();
@ -69,6 +79,7 @@ fn main() -> Result<(), Box<dyn error::Error>> {
let ledger_path = matches.value_of("ledger_path").unwrap(); let ledger_path = matches.value_of("ledger_path").unwrap();
let mint_keypair_file = matches.value_of("mint_keypair_file").unwrap(); let mint_keypair_file = matches.value_of("mint_keypair_file").unwrap();
let lamports = value_t_or_exit!(matches, "lamports", u64); let lamports = value_t_or_exit!(matches, "lamports", u64);
let bootstrap_leader_lamports = value_t_or_exit!(matches, "bootstrap_leader_lamports", u64);
let bootstrap_leader_keypair = read_keypair(bootstrap_leader_keypair_file)?; let bootstrap_leader_keypair = read_keypair(bootstrap_leader_keypair_file)?;
let bootstrap_vote_keypair = read_keypair(bootstrap_vote_keypair_file)?; let bootstrap_vote_keypair = read_keypair(bootstrap_vote_keypair_file)?;
@ -77,7 +88,7 @@ fn main() -> Result<(), Box<dyn error::Error>> {
let (mut genesis_block, _mint_keypair) = GenesisBlock::new_with_leader( let (mut genesis_block, _mint_keypair) = GenesisBlock::new_with_leader(
lamports, lamports,
&bootstrap_leader_keypair.pubkey(), &bootstrap_leader_keypair.pubkey(),
BOOTSTRAP_LEADER_LAMPORTS, bootstrap_leader_lamports,
); );
genesis_block.mint_id = mint_keypair.pubkey(); genesis_block.mint_id = mint_keypair.pubkey();
genesis_block.bootstrap_leader_vote_account_id = bootstrap_vote_keypair.pubkey(); genesis_block.bootstrap_leader_vote_account_id = bootstrap_vote_keypair.pubkey();

View File

@ -138,6 +138,7 @@ setup_vote_account() {
declare drone_address=$1 declare drone_address=$1
declare node_id_path=$2 declare node_id_path=$2
declare vote_id_path=$3 declare vote_id_path=$3
declare stake=$4
declare node_id declare node_id
node_id=$($solana_wallet --keypair "$node_id_path" address) node_id=$($solana_wallet --keypair "$node_id_path" address)
@ -153,11 +154,11 @@ setup_vote_account() {
# A fullnode requires 43 lamports to function: # A fullnode requires 43 lamports to function:
# - one lamport to keep the node identity public key valid. TODO: really?? # - one lamport to keep the node identity public key valid. TODO: really??
# - 42 more for the vote account we fund # - 42 more for the vote account we fund
airdrop "$node_id_path" "$drone_address" 43 || return $? airdrop "$node_id_path" "$drone_address" "$stake" || return $?
# Fund the vote account from the node, with the node as the node_id # Fund the vote account from the node, with the node as the node_id
$solana_wallet --keypair "$node_id_path" --host "$drone_address" \ $solana_wallet --keypair "$node_id_path" --host "$drone_address" \
create-vote-account "$vote_id" "$node_id" 42 || return $? create-vote-account "$vote_id" "$node_id" $((stake - 1)) || return $?
touch "$vote_id_path".configured touch "$vote_id_path".configured
return 0 return 0
@ -169,7 +170,7 @@ fullnode_usage() {
echo echo
fi fi
cat <<EOF cat <<EOF
usage: $0 [-x] [--blockstream PATH] [--init-complete-file FILE] [--no-stake] [--no-voting] [--rpc-port port] [rsync network path to bootstrap leader configuration] [network entry point] usage: $0 [-x] [--blockstream PATH] [--init-complete-file FILE] [--stake LAMPORTS] [--no-voting] [--rpc-port port] [rsync network path to bootstrap leader configuration] [network entry point]
Start a full node on the specified network Start a full node on the specified network
@ -178,7 +179,7 @@ Start a full node on the specified network
the specified label. Does not apply to the bootstrap leader the specified label. Does not apply to the bootstrap leader
--blockstream PATH - open blockstream at this unix domain socket location --blockstream PATH - open blockstream at this unix domain socket location
--init-complete-file FILE - create this file, if it doesn't already exist, once node initialization is complete --init-complete-file FILE - create this file, if it doesn't already exist, once node initialization is complete
--no-stake - Only stake the bootstrap leader, effectively disabling leader rotation --stake LAMPORTS - Number of lamports to stake
--public-address - advertise public machine address in gossip. By default the local machine address is advertised --public-address - advertise public machine address in gossip. By default the local machine address is advertised
--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

View File

@ -16,7 +16,7 @@ fi
gossip_port= gossip_port=
extra_fullnode_args=() extra_fullnode_args=()
self_setup=0 self_setup=0
setup_stakes=1 stake=43 # number of lamports to assign as stake (plus transaction fee to setup the stake)
poll_for_new_genesis_block=0 poll_for_new_genesis_block=0
while [[ ${1:0:1} = - ]]; do while [[ ${1:0:1} = - ]]; do
@ -32,7 +32,7 @@ while [[ ${1:0:1} = - ]]; do
poll_for_new_genesis_block=1 poll_for_new_genesis_block=1
shift shift
elif [[ $1 = --blockstream ]]; then elif [[ $1 = --blockstream ]]; then
setup_stakes=0 stake=0
extra_fullnode_args+=("$1" "$2") extra_fullnode_args+=("$1" "$2")
shift 2 shift 2
elif [[ $1 = --enable-rpc-exit ]]; then elif [[ $1 = --enable-rpc-exit ]]; then
@ -41,9 +41,9 @@ while [[ ${1:0:1} = - ]]; do
elif [[ $1 = --init-complete-file ]]; then elif [[ $1 = --init-complete-file ]]; then
extra_fullnode_args+=("$1" "$2") extra_fullnode_args+=("$1" "$2")
shift 2 shift 2
elif [[ $1 = --no-stake ]]; then elif [[ $1 = --stake ]]; then
setup_stakes=0 stake="$2"
shift shift 2
elif [[ $1 = --public-address ]]; then elif [[ $1 = --public-address ]]; then
extra_fullnode_args+=("$1") extra_fullnode_args+=("$1")
shift shift
@ -170,6 +170,11 @@ while true; do
fi fi
trap 'kill "$pid" && wait "$pid"' INT TERM ERR trap 'kill "$pid" && wait "$pid"' INT TERM ERR
if ((stake)); then
setup_vote_account "${leader_address%:*}" "$fullnode_id_path" "$fullnode_vote_id_path" "$stake"
fi
$program \ $program \
--identity "$fullnode_id_path" \ --identity "$fullnode_id_path" \
--voting-keypair "$fullnode_vote_id_path" \ --voting-keypair "$fullnode_vote_id_path" \
@ -183,9 +188,6 @@ while true; do
pid=$! pid=$!
oom_score_adj "$pid" 1000 oom_score_adj "$pid" 1000
if ((setup_stakes)); then
setup_vote_account "${leader_address%:*}" "$fullnode_id_path" "$fullnode_vote_id_path"
fi
set +x set +x
while true; do while true; do

View File

@ -29,8 +29,10 @@ EOF
lamports=1000000000 lamports=1000000000
bootstrap_leader=true bootstrap_leader=true
bootstrap_leader_lamports=
fullnode=true fullnode=true
while getopts "h?n:lpt:" opt; do while getopts "h?n:b:lpt:" opt; do
case $opt in case $opt in
h|\?) h|\?)
usage usage
@ -39,6 +41,9 @@ while getopts "h?n:lpt:" opt; do
n) n)
lamports="$OPTARG" lamports="$OPTARG"
;; ;;
b)
bootstrap_leader_lamports="$OPTARG"
;;
t) t)
node_type="$OPTARG" node_type="$OPTARG"
case $OPTARG in case $OPTARG in
@ -77,12 +82,20 @@ if $bootstrap_leader; then
$solana_keygen -o "$SOLANA_CONFIG_DIR"/mint-id.json $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-id.json
$solana_keygen -o "$SOLANA_CONFIG_DIR"/bootstrap-leader-vote-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 \ args=(
--bootstrap-vote-keypair "$SOLANA_CONFIG_DIR"/bootstrap-leader-vote-id.json \ --bootstrap-leader-keypair "$SOLANA_CONFIG_DIR"/bootstrap-leader-id.json
--ledger "$SOLANA_RSYNC_CONFIG_DIR"/ledger \ --bootstrap-vote-keypair "$SOLANA_CONFIG_DIR"/bootstrap-leader-vote-id.json
--mint "$SOLANA_CONFIG_DIR"/mint-id.json \ --ledger "$SOLANA_RSYNC_CONFIG_DIR"/ledger
--mint "$SOLANA_CONFIG_DIR"/mint-id.json
--lamports "$lamports" --lamports "$lamports"
)
if [[ -n $bootstrap_leader_lamports ]]; then
args+=(--bootstrap-leader-lamports "$bootstrap_leader_lamports")
fi
$solana_genesis "${args[@]}"
cp -a "$SOLANA_RSYNC_CONFIG_DIR"/ledger "$SOLANA_CONFIG_DIR"/bootstrap-leader-ledger cp -a "$SOLANA_RSYNC_CONFIG_DIR"/ledger "$SOLANA_CONFIG_DIR"/bootstrap-leader-ledger
) )
fi fi

View File

@ -15,6 +15,14 @@ leaderRotation="$8"
set +x set +x
export RUST_LOG export RUST_LOG
# Use a very large stake (relative to the default multinode-demo/ stake of 43)
# for the testnet fullnodes setup by net/. This make it less likely that
# low-staked ephemeral validator a random user may attach to testnet will cause
# trouble
#
# Ref: https://github.com/solana-labs/solana/issues/3798
stake=424243
missing() { missing() {
echo "Error: $1 not specified" echo "Error: $1 not specified"
exit 1 exit 1
@ -69,7 +77,7 @@ local|tar)
fi fi
set -x set -x
if [[ $skipSetup != true ]]; then if [[ $skipSetup != true ]]; then
./multinode-demo/setup.sh -t bootstrap-leader ./multinode-demo/setup.sh -t bootstrap-leader -b $stake
fi fi
./multinode-demo/drone.sh > drone.log 2>&1 & ./multinode-demo/drone.sh > drone.log 2>&1 &
@ -90,9 +98,6 @@ local|tar)
fi fi
args=() args=()
if ! $leaderRotation; then
args+=("--no-stake")
fi
if $publicNetwork; then if $publicNetwork; then
args+=("--public-address") args+=("--public-address")
fi fi
@ -100,7 +105,14 @@ local|tar)
args+=( args+=(
--blockstream /tmp/solana-blockstream.sock --blockstream /tmp/solana-blockstream.sock
--no-voting --no-voting
--stake 0
) )
else
if $leaderRotation; then
args+=("--stake" "$stake")
else
args+=("--stake" 0)
fi
fi fi
args+=( args+=(

View File

@ -133,7 +133,7 @@ echo "--- $entrypointIp: validator sanity"
if $validatorSanity; then if $validatorSanity; then
( (
set -x -o pipefail set -x -o pipefail
timeout 10s ./multinode-demo/fullnode-x.sh --no-stake \ timeout 10s ./multinode-demo/fullnode-x.sh --stake 0 \
"$entrypointRsyncUrl" \ "$entrypointRsyncUrl" \
"$entrypointIp:8001" 2>&1 | tee validator-sanity.log "$entrypointIp:8001" 2>&1 | tee validator-sanity.log
) || { ) || {