Fix flag to disable leader-rotation (#3243)
This commit is contained in:
		@@ -55,7 +55,7 @@ while getopts "ch?i:k:brxR" opt; do
 | 
			
		||||
    restartInterval=$OPTARG
 | 
			
		||||
    ;;
 | 
			
		||||
  b)
 | 
			
		||||
    maybeNoLeaderRotation="--no-leader-rotation"
 | 
			
		||||
    maybeNoLeaderRotation="--only-bootstrap-stake"
 | 
			
		||||
    ;;
 | 
			
		||||
  x)
 | 
			
		||||
    extraNodes=$((extraNodes + 1))
 | 
			
		||||
 
 | 
			
		||||
@@ -5,7 +5,6 @@ use solana::contact_info::ContactInfo;
 | 
			
		||||
use solana::fullnode::{Fullnode, FullnodeConfig};
 | 
			
		||||
use solana::local_vote_signer_service::LocalVoteSignerService;
 | 
			
		||||
use solana::service::Service;
 | 
			
		||||
use solana_sdk::genesis_block::GenesisBlock;
 | 
			
		||||
use solana_sdk::signature::{read_keypair, Keypair, KeypairUtil};
 | 
			
		||||
use std::fs::File;
 | 
			
		||||
use std::process::exit;
 | 
			
		||||
@@ -70,11 +69,6 @@ fn main() {
 | 
			
		||||
                .takes_value(true)
 | 
			
		||||
                .help("Rendezvous with the cluster at this gossip entry point"),
 | 
			
		||||
        )
 | 
			
		||||
        .arg(
 | 
			
		||||
            Arg::with_name("no_leader_rotation")
 | 
			
		||||
                .long("no-leader-rotation")
 | 
			
		||||
                .help("Disable leader rotation"),
 | 
			
		||||
        )
 | 
			
		||||
        .arg(
 | 
			
		||||
            Arg::with_name("no_voting")
 | 
			
		||||
                .long("no-voting")
 | 
			
		||||
@@ -169,8 +163,6 @@ fn main() {
 | 
			
		||||
 | 
			
		||||
    fullnode_config.voting_disabled = matches.is_present("no_voting");
 | 
			
		||||
 | 
			
		||||
    let use_only_bootstrap_leader = matches.is_present("no_leader_rotation");
 | 
			
		||||
 | 
			
		||||
    if matches.is_present("enable_rpc_exit") {
 | 
			
		||||
        fullnode_config.rpc_config.enable_fullnode_exit = true;
 | 
			
		||||
    }
 | 
			
		||||
@@ -233,11 +225,6 @@ fn main() {
 | 
			
		||||
    node.info.rpc.set_port(rpc_port);
 | 
			
		||||
    node.info.rpc_pubsub.set_port(rpc_pubsub_port);
 | 
			
		||||
 | 
			
		||||
    let genesis_block = GenesisBlock::load(ledger_path).expect("Unable to load genesis block");
 | 
			
		||||
    if use_only_bootstrap_leader && node.info.id != genesis_block.bootstrap_leader_id {
 | 
			
		||||
        fullnode_config.voting_disabled = true;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    let fullnode = Fullnode::new(
 | 
			
		||||
        node,
 | 
			
		||||
        &keypair,
 | 
			
		||||
 
 | 
			
		||||
@@ -10,6 +10,46 @@ source "$here"/common.sh
 | 
			
		||||
# shellcheck source=scripts/oom-score-adj.sh
 | 
			
		||||
source "$here"/../scripts/oom-score-adj.sh
 | 
			
		||||
 | 
			
		||||
if [[ $1 = -h ]]; then
 | 
			
		||||
  fullnode_usage "$@"
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
extra_fullnode_args=()
 | 
			
		||||
setup_stakes=true
 | 
			
		||||
 | 
			
		||||
while [[ ${1:0:1} = - ]]; do
 | 
			
		||||
  if [[ $1 = --blockstream ]]; then
 | 
			
		||||
    extra_fullnode_args+=("$1" "$2")
 | 
			
		||||
    shift 2
 | 
			
		||||
  elif [[ $1 = --enable-rpc-exit ]]; then
 | 
			
		||||
    extra_fullnode_args+=("$1")
 | 
			
		||||
    shift
 | 
			
		||||
  elif [[ $1 = --init-complete-file ]]; then
 | 
			
		||||
    extra_fullnode_args+=("$1" "$2")
 | 
			
		||||
    shift 2
 | 
			
		||||
  elif [[ $1 = --only-bootstrap-stake ]]; then
 | 
			
		||||
    setup_stakes=false
 | 
			
		||||
    shift
 | 
			
		||||
  elif [[ $1 = --public-address ]]; then
 | 
			
		||||
    extra_fullnode_args+=("$1")
 | 
			
		||||
    shift
 | 
			
		||||
  elif [[ $1 = --no-signer ]]; then
 | 
			
		||||
    extra_fullnode_args+=("$1")
 | 
			
		||||
    shift
 | 
			
		||||
  elif [[ $1 = --rpc-port ]]; then
 | 
			
		||||
    extra_fullnode_args+=("$1" "$2")
 | 
			
		||||
    shift 2
 | 
			
		||||
  else
 | 
			
		||||
    echo "Unknown argument: $1"
 | 
			
		||||
    exit 1
 | 
			
		||||
  fi
 | 
			
		||||
done
 | 
			
		||||
 | 
			
		||||
if [[ -n $3 ]]; then
 | 
			
		||||
  fullnode_usage "$@"
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
[[ -f "$SOLANA_CONFIG_DIR"/bootstrap-leader-id.json ]] || {
 | 
			
		||||
  echo "$SOLANA_CONFIG_DIR/bootstrap-leader-id.json not found, create it by running:"
 | 
			
		||||
  echo
 | 
			
		||||
@@ -27,12 +67,10 @@ 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)
 | 
			
		||||
 | 
			
		||||
set -x
 | 
			
		||||
trap 'kill "$pid" && wait "$pid"' INT TERM ERR
 | 
			
		||||
$program \
 | 
			
		||||
  --identity "$bootstrap_leader_id_path" \
 | 
			
		||||
@@ -42,11 +80,13 @@ $program \
 | 
			
		||||
  --accounts "$SOLANA_CONFIG_DIR"/bootstrap-leader-accounts \
 | 
			
		||||
  --rpc-port 8899 \
 | 
			
		||||
  --rpc-drone-address 127.0.0.1:9900 \
 | 
			
		||||
  "$@" \
 | 
			
		||||
  "${extra_fullnode_args[@]}" \
 | 
			
		||||
  > >($bootstrap_leader_logger) 2>&1 &
 | 
			
		||||
pid=$!
 | 
			
		||||
oom_score_adj "$pid" 1000
 | 
			
		||||
 | 
			
		||||
setup_fullnode_staking 127.0.0.1 "$bootstrap_leader_id_path" "$bootstrap_leader_staker_id_path"
 | 
			
		||||
if [[ $setup_stakes = true ]] ; then
 | 
			
		||||
  setup_fullnode_staking 127.0.0.1 "$bootstrap_leader_id_path" "$bootstrap_leader_staker_id_path"
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
wait "$pid"
 | 
			
		||||
 
 | 
			
		||||
@@ -171,6 +171,29 @@ setup_fullnode_staking() {
 | 
			
		||||
  return 0
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
fullnode_usage() {
 | 
			
		||||
  if [[ -n $1 ]]; then
 | 
			
		||||
    echo "$*"
 | 
			
		||||
    echo
 | 
			
		||||
  fi
 | 
			
		||||
  cat <<EOF
 | 
			
		||||
usage: $0 [-x] [--blockstream PATH] [--init-complete-file FILE] [--only-bootstrap-stake] [--no-signer] [--rpc-port port] [rsync network path to bootstrap leader configuration] [network entry point]
 | 
			
		||||
 | 
			
		||||
Start a full node on the specified network
 | 
			
		||||
 | 
			
		||||
  -x                        - start a new, dynamically-configured full node. Does not apply to the bootstrap leader
 | 
			
		||||
  -X [label]                - start or restart a dynamically-configured full node with
 | 
			
		||||
                              the specified label. Does not apply to the bootstrap leader
 | 
			
		||||
  --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
 | 
			
		||||
  --only-bootstrap-stake    - Only stake the bootstrap leader, effectively disabling leader rotation
 | 
			
		||||
  --public-address          - advertise public machine address in gossip.  By default the local machine address is advertised
 | 
			
		||||
  --no-signer               - start node without vote signer
 | 
			
		||||
  --rpc-port port           - custom RPC port for this node
 | 
			
		||||
 | 
			
		||||
EOF
 | 
			
		||||
  exit 1
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
# The directory on the bootstrap leader that is rsynced by other full nodes as
 | 
			
		||||
# they boot (TODO: Eventually this should go away)
 | 
			
		||||
 
 | 
			
		||||
@@ -9,37 +9,14 @@ source "$here"/common.sh
 | 
			
		||||
# shellcheck source=scripts/oom-score-adj.sh
 | 
			
		||||
source "$here"/../scripts/oom-score-adj.sh
 | 
			
		||||
 | 
			
		||||
usage() {
 | 
			
		||||
  if [[ -n $1 ]]; then
 | 
			
		||||
    echo "$*"
 | 
			
		||||
    echo
 | 
			
		||||
  fi
 | 
			
		||||
  cat <<EOF
 | 
			
		||||
usage: $0 [-x] [--blockstream PATH] [--init-complete-file FILE] [--no-leader-rotation] [--no-signer] [--rpc-port port] [rsync network path to bootstrap leader configuration] [network entry point]
 | 
			
		||||
 | 
			
		||||
Start a full node on the specified network
 | 
			
		||||
 | 
			
		||||
  -x                    - start a new, dynamically-configured full node
 | 
			
		||||
  -X [label]            - start or restart a dynamically-configured full node with
 | 
			
		||||
                          the specified label
 | 
			
		||||
  --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
 | 
			
		||||
  --no-leader-rotation  - disable leader rotation
 | 
			
		||||
  --public-address      - advertise public machine address in gossip.  By default the local machine address is advertised
 | 
			
		||||
  --no-signer           - start node without vote signer
 | 
			
		||||
  --rpc-port port       - custom RPC port for this node
 | 
			
		||||
 | 
			
		||||
EOF
 | 
			
		||||
  exit 1
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
if [[ $1 = -h ]]; then
 | 
			
		||||
  usage
 | 
			
		||||
  fullnode_usage "$@"
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
gossip_port=9000
 | 
			
		||||
extra_fullnode_args=()
 | 
			
		||||
self_setup=0
 | 
			
		||||
setup_stakes=true
 | 
			
		||||
 | 
			
		||||
while [[ ${1:0:1} = - ]]; do
 | 
			
		||||
  if [[ $1 = -X ]]; then
 | 
			
		||||
@@ -59,8 +36,8 @@ while [[ ${1:0:1} = - ]]; do
 | 
			
		||||
  elif [[ $1 = --init-complete-file ]]; then
 | 
			
		||||
    extra_fullnode_args+=("$1" "$2")
 | 
			
		||||
    shift 2
 | 
			
		||||
  elif [[ $1 = --no-leader-rotation ]]; then
 | 
			
		||||
    extra_fullnode_args+=("$1")
 | 
			
		||||
  elif [[ $1 = --only-bootstrap-stake ]]; then
 | 
			
		||||
    setup_stakes=false
 | 
			
		||||
    shift
 | 
			
		||||
  elif [[ $1 = --public-address ]]; then
 | 
			
		||||
    extra_fullnode_args+=("$1")
 | 
			
		||||
@@ -78,7 +55,7 @@ while [[ ${1:0:1} = - ]]; do
 | 
			
		||||
done
 | 
			
		||||
 | 
			
		||||
if [[ -n $3 ]]; then
 | 
			
		||||
  usage
 | 
			
		||||
  fullnode_usage "$@"
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
find_leader() {
 | 
			
		||||
@@ -215,6 +192,8 @@ $program \
 | 
			
		||||
pid=$!
 | 
			
		||||
oom_score_adj "$pid" 1000
 | 
			
		||||
 | 
			
		||||
setup_fullnode_staking "${leader_address%:*}" "$fullnode_id_path" "$fullnode_staker_id_path"
 | 
			
		||||
if [[ $setup_stakes = true ]]; then
 | 
			
		||||
  setup_fullnode_staking "${leader_address%:*}" "$fullnode_id_path" "$fullnode_staker_id_path"
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
wait "$pid"
 | 
			
		||||
 
 | 
			
		||||
@@ -76,7 +76,7 @@ local|tar)
 | 
			
		||||
 | 
			
		||||
    maybeNoLeaderRotation=
 | 
			
		||||
    if ! $leaderRotation; then
 | 
			
		||||
      maybeNoLeaderRotation="--no-leader-rotation"
 | 
			
		||||
      maybeNoLeaderRotation="--only-bootstrap-stake"
 | 
			
		||||
    fi
 | 
			
		||||
    maybePublicAddress=
 | 
			
		||||
    if $publicNetwork; then
 | 
			
		||||
@@ -96,7 +96,7 @@ local|tar)
 | 
			
		||||
 | 
			
		||||
    args=()
 | 
			
		||||
    if ! $leaderRotation; then
 | 
			
		||||
      args+=("--no-leader-rotation")
 | 
			
		||||
      args+=("--only-bootstrap-stake")
 | 
			
		||||
    fi
 | 
			
		||||
    if $publicNetwork; then
 | 
			
		||||
      args+=("--public-address")
 | 
			
		||||
 
 | 
			
		||||
@@ -48,10 +48,8 @@ $solana_keygen
 | 
			
		||||
node_readiness=false
 | 
			
		||||
timeout=60
 | 
			
		||||
while [[ $timeout -gt 0 ]]; do
 | 
			
		||||
  expected_output="Leader ready"
 | 
			
		||||
  exec 42>&1
 | 
			
		||||
  output=$($solana_wallet "${entrypoint[@]}" get-transaction-count | tee >(cat - >&42))
 | 
			
		||||
  if [[ $output -gt 0 ]]; then
 | 
			
		||||
  output=$($solana_wallet "${entrypoint[@]}" get-transaction-count)
 | 
			
		||||
  if [[ -n $output ]]; then
 | 
			
		||||
    node_readiness=true
 | 
			
		||||
    break
 | 
			
		||||
  fi
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user