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
 | 
					    restartInterval=$OPTARG
 | 
				
			||||||
    ;;
 | 
					    ;;
 | 
				
			||||||
  b)
 | 
					  b)
 | 
				
			||||||
    maybeNoLeaderRotation="--no-leader-rotation"
 | 
					    maybeNoLeaderRotation="--only-bootstrap-stake"
 | 
				
			||||||
    ;;
 | 
					    ;;
 | 
				
			||||||
  x)
 | 
					  x)
 | 
				
			||||||
    extraNodes=$((extraNodes + 1))
 | 
					    extraNodes=$((extraNodes + 1))
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -5,7 +5,6 @@ use solana::contact_info::ContactInfo;
 | 
				
			|||||||
use solana::fullnode::{Fullnode, FullnodeConfig};
 | 
					use solana::fullnode::{Fullnode, FullnodeConfig};
 | 
				
			||||||
use solana::local_vote_signer_service::LocalVoteSignerService;
 | 
					use solana::local_vote_signer_service::LocalVoteSignerService;
 | 
				
			||||||
use solana::service::Service;
 | 
					use solana::service::Service;
 | 
				
			||||||
use solana_sdk::genesis_block::GenesisBlock;
 | 
					 | 
				
			||||||
use solana_sdk::signature::{read_keypair, Keypair, KeypairUtil};
 | 
					use solana_sdk::signature::{read_keypair, Keypair, KeypairUtil};
 | 
				
			||||||
use std::fs::File;
 | 
					use std::fs::File;
 | 
				
			||||||
use std::process::exit;
 | 
					use std::process::exit;
 | 
				
			||||||
@@ -70,11 +69,6 @@ fn main() {
 | 
				
			|||||||
                .takes_value(true)
 | 
					                .takes_value(true)
 | 
				
			||||||
                .help("Rendezvous with the cluster at this gossip entry point"),
 | 
					                .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(
 | 
				
			||||||
            Arg::with_name("no_voting")
 | 
					            Arg::with_name("no_voting")
 | 
				
			||||||
                .long("no-voting")
 | 
					                .long("no-voting")
 | 
				
			||||||
@@ -169,8 +163,6 @@ fn main() {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    fullnode_config.voting_disabled = matches.is_present("no_voting");
 | 
					    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") {
 | 
					    if matches.is_present("enable_rpc_exit") {
 | 
				
			||||||
        fullnode_config.rpc_config.enable_fullnode_exit = true;
 | 
					        fullnode_config.rpc_config.enable_fullnode_exit = true;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@@ -233,11 +225,6 @@ fn main() {
 | 
				
			|||||||
    node.info.rpc.set_port(rpc_port);
 | 
					    node.info.rpc.set_port(rpc_port);
 | 
				
			||||||
    node.info.rpc_pubsub.set_port(rpc_pubsub_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(
 | 
					    let fullnode = Fullnode::new(
 | 
				
			||||||
        node,
 | 
					        node,
 | 
				
			||||||
        &keypair,
 | 
					        &keypair,
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -10,6 +10,46 @@ source "$here"/common.sh
 | 
				
			|||||||
# shellcheck source=scripts/oom-score-adj.sh
 | 
					# shellcheck source=scripts/oom-score-adj.sh
 | 
				
			||||||
source "$here"/../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 ]] || {
 | 
					[[ -f "$SOLANA_CONFIG_DIR"/bootstrap-leader-id.json ]] || {
 | 
				
			||||||
  echo "$SOLANA_CONFIG_DIR/bootstrap-leader-id.json not found, create it by running:"
 | 
					  echo "$SOLANA_CONFIG_DIR/bootstrap-leader-id.json not found, create it by running:"
 | 
				
			||||||
  echo
 | 
					  echo
 | 
				
			||||||
@@ -27,12 +67,10 @@ tune_system
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
$solana_ledger_tool --ledger "$SOLANA_CONFIG_DIR"/bootstrap-leader-ledger verify
 | 
					$solana_ledger_tool --ledger "$SOLANA_CONFIG_DIR"/bootstrap-leader-ledger verify
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
bootstrap_leader_id_path="$SOLANA_CONFIG_DIR"/bootstrap-leader-id.json
 | 
					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_path="$SOLANA_CONFIG_DIR"/bootstrap-leader-staker-id.json
 | 
				
			||||||
bootstrap_leader_staker_id=$($solana_wallet --keypair "$bootstrap_leader_staker_id_path" address)
 | 
					bootstrap_leader_staker_id=$($solana_wallet --keypair "$bootstrap_leader_staker_id_path" address)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
set -x
 | 
					 | 
				
			||||||
trap 'kill "$pid" && wait "$pid"' INT TERM ERR
 | 
					trap 'kill "$pid" && wait "$pid"' INT TERM ERR
 | 
				
			||||||
$program \
 | 
					$program \
 | 
				
			||||||
  --identity "$bootstrap_leader_id_path" \
 | 
					  --identity "$bootstrap_leader_id_path" \
 | 
				
			||||||
@@ -42,11 +80,13 @@ $program \
 | 
				
			|||||||
  --accounts "$SOLANA_CONFIG_DIR"/bootstrap-leader-accounts \
 | 
					  --accounts "$SOLANA_CONFIG_DIR"/bootstrap-leader-accounts \
 | 
				
			||||||
  --rpc-port 8899 \
 | 
					  --rpc-port 8899 \
 | 
				
			||||||
  --rpc-drone-address 127.0.0.1:9900 \
 | 
					  --rpc-drone-address 127.0.0.1:9900 \
 | 
				
			||||||
  "$@" \
 | 
					  "${extra_fullnode_args[@]}" \
 | 
				
			||||||
  > >($bootstrap_leader_logger) 2>&1 &
 | 
					  > >($bootstrap_leader_logger) 2>&1 &
 | 
				
			||||||
pid=$!
 | 
					pid=$!
 | 
				
			||||||
oom_score_adj "$pid" 1000
 | 
					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"
 | 
					wait "$pid"
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -171,6 +171,29 @@ setup_fullnode_staking() {
 | 
				
			|||||||
  return 0
 | 
					  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
 | 
					# The directory on the bootstrap leader that is rsynced by other full nodes as
 | 
				
			||||||
# they boot (TODO: Eventually this should go away)
 | 
					# they boot (TODO: Eventually this should go away)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -9,37 +9,14 @@ source "$here"/common.sh
 | 
				
			|||||||
# shellcheck source=scripts/oom-score-adj.sh
 | 
					# shellcheck source=scripts/oom-score-adj.sh
 | 
				
			||||||
source "$here"/../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
 | 
					if [[ $1 = -h ]]; then
 | 
				
			||||||
  usage
 | 
					  fullnode_usage "$@"
 | 
				
			||||||
fi
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
gossip_port=9000
 | 
					gossip_port=9000
 | 
				
			||||||
extra_fullnode_args=()
 | 
					extra_fullnode_args=()
 | 
				
			||||||
self_setup=0
 | 
					self_setup=0
 | 
				
			||||||
 | 
					setup_stakes=true
 | 
				
			||||||
 | 
					
 | 
				
			||||||
while [[ ${1:0:1} = - ]]; do
 | 
					while [[ ${1:0:1} = - ]]; do
 | 
				
			||||||
  if [[ $1 = -X ]]; then
 | 
					  if [[ $1 = -X ]]; then
 | 
				
			||||||
@@ -59,8 +36,8 @@ 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-leader-rotation ]]; then
 | 
					  elif [[ $1 = --only-bootstrap-stake ]]; then
 | 
				
			||||||
    extra_fullnode_args+=("$1")
 | 
					    setup_stakes=false
 | 
				
			||||||
    shift
 | 
					    shift
 | 
				
			||||||
  elif [[ $1 = --public-address ]]; then
 | 
					  elif [[ $1 = --public-address ]]; then
 | 
				
			||||||
    extra_fullnode_args+=("$1")
 | 
					    extra_fullnode_args+=("$1")
 | 
				
			||||||
@@ -78,7 +55,7 @@ while [[ ${1:0:1} = - ]]; do
 | 
				
			|||||||
done
 | 
					done
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if [[ -n $3 ]]; then
 | 
					if [[ -n $3 ]]; then
 | 
				
			||||||
  usage
 | 
					  fullnode_usage "$@"
 | 
				
			||||||
fi
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
find_leader() {
 | 
					find_leader() {
 | 
				
			||||||
@@ -215,6 +192,8 @@ $program \
 | 
				
			|||||||
pid=$!
 | 
					pid=$!
 | 
				
			||||||
oom_score_adj "$pid" 1000
 | 
					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"
 | 
					wait "$pid"
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -76,7 +76,7 @@ local|tar)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    maybeNoLeaderRotation=
 | 
					    maybeNoLeaderRotation=
 | 
				
			||||||
    if ! $leaderRotation; then
 | 
					    if ! $leaderRotation; then
 | 
				
			||||||
      maybeNoLeaderRotation="--no-leader-rotation"
 | 
					      maybeNoLeaderRotation="--only-bootstrap-stake"
 | 
				
			||||||
    fi
 | 
					    fi
 | 
				
			||||||
    maybePublicAddress=
 | 
					    maybePublicAddress=
 | 
				
			||||||
    if $publicNetwork; then
 | 
					    if $publicNetwork; then
 | 
				
			||||||
@@ -96,7 +96,7 @@ local|tar)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    args=()
 | 
					    args=()
 | 
				
			||||||
    if ! $leaderRotation; then
 | 
					    if ! $leaderRotation; then
 | 
				
			||||||
      args+=("--no-leader-rotation")
 | 
					      args+=("--only-bootstrap-stake")
 | 
				
			||||||
    fi
 | 
					    fi
 | 
				
			||||||
    if $publicNetwork; then
 | 
					    if $publicNetwork; then
 | 
				
			||||||
      args+=("--public-address")
 | 
					      args+=("--public-address")
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -48,10 +48,8 @@ $solana_keygen
 | 
				
			|||||||
node_readiness=false
 | 
					node_readiness=false
 | 
				
			||||||
timeout=60
 | 
					timeout=60
 | 
				
			||||||
while [[ $timeout -gt 0 ]]; do
 | 
					while [[ $timeout -gt 0 ]]; do
 | 
				
			||||||
  expected_output="Leader ready"
 | 
					  output=$($solana_wallet "${entrypoint[@]}" get-transaction-count)
 | 
				
			||||||
  exec 42>&1
 | 
					  if [[ -n $output ]]; then
 | 
				
			||||||
  output=$($solana_wallet "${entrypoint[@]}" get-transaction-count | tee >(cat - >&42))
 | 
					 | 
				
			||||||
  if [[ $output -gt 0 ]]; then
 | 
					 | 
				
			||||||
    node_readiness=true
 | 
					    node_readiness=true
 | 
				
			||||||
    break
 | 
					    break
 | 
				
			||||||
  fi
 | 
					  fi
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user