net: Add a stand-alone gossip node on the blocksteamer instance (bp #7654) (#7658)

automerge
This commit is contained in:
mergify[bot]
2020-01-02 17:10:04 -08:00
committed by Grimes
parent 3db644320e
commit 63db9d6933
4 changed files with 74 additions and 42 deletions

View File

@ -9,7 +9,7 @@ use solana_client::rpc_client::RpcClient;
use solana_core::{contact_info::ContactInfo, gossip_service::discover};
use solana_sdk::pubkey::Pubkey;
use std::error;
use std::net::SocketAddr;
use std::net::{IpAddr, Ipv4Addr, SocketAddr};
use std::process::exit;
fn main() -> Result<(), Box<dyn error::Error>> {
@ -38,6 +38,13 @@ fn main() -> Result<(), Box<dyn error::Error>> {
.takes_value(false)
.help("Return all RPC URLs"),
)
.arg(
Arg::with_name("any")
.long("any")
.takes_value(false)
.conflicts_with("all")
.help("Return any RPC URL"),
)
.arg(
Arg::with_name("timeout")
.long("timeout")
@ -74,9 +81,8 @@ fn main() -> Result<(), Box<dyn error::Error>> {
.long("gossip-host")
.value_name("HOST")
.takes_value(true)
.conflicts_with("entrypoint")
.validator(solana_net_utils::is_host)
.help("Gossip DNS name or IP address for the node when --entrypoint is not provided [default: 127.0.0.1]"),
.help("Gossip DNS name or IP address for the node [default: ask --entrypoint, or 127.0.0.1 when --entrypoint is not provided]"),
)
.arg(
Arg::with_name("num_nodes")
@ -164,21 +170,29 @@ fn main() -> Result<(), Box<dyn error::Error>> {
let entrypoint_addr = parse_entrypoint(&matches);
let gossip_host = if let Some(entrypoint_addr) = entrypoint_addr {
solana_net_utils::get_public_ip_addr(&entrypoint_addr).unwrap_or_else(|err| {
eprintln!(
"Failed to contact cluster entrypoint {}: {}",
entrypoint_addr, err
);
exit(1);
})
} else {
solana_net_utils::parse_host(matches.value_of("gossip_host").unwrap_or("127.0.0.1"))
.unwrap_or_else(|err| {
eprintln!("Error: {}", err);
let gossip_host = matches
.value_of("gossip_host")
.map(|gossip_host| {
solana_net_utils::parse_host(gossip_host).unwrap_or_else(|e| {
eprintln!("failed to parse gossip-host: {}", e);
exit(1);
})
};
})
.unwrap_or_else(|| {
if let Some(entrypoint_addr) = entrypoint_addr {
solana_net_utils::get_public_ip_addr(&entrypoint_addr).unwrap_or_else(
|err| {
eprintln!(
"Failed to contact cluster entrypoint {}: {}",
entrypoint_addr, err
);
exit(1);
},
)
} else {
IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1))
}
});
let gossip_addr = SocketAddr::new(
gossip_host,
@ -230,6 +244,8 @@ fn main() -> Result<(), Box<dyn error::Error>> {
}
}
("get-rpc-url", Some(matches)) => {
let any = matches.is_present("any");
let all = matches.is_present("all");
let entrypoint_addr = parse_entrypoint(&matches);
let timeout = value_t_or_exit!(matches, "timeout", u64);
let (nodes, _archivers) = discover(
@ -244,7 +260,7 @@ fn main() -> Result<(), Box<dyn error::Error>> {
let rpc_addrs: Vec<_> = nodes
.iter()
.filter_map(|contact_info| {
if (matches.is_present("all") || Some(contact_info.gossip) == entrypoint_addr)
if (any || all || Some(contact_info.gossip) == entrypoint_addr)
&& ContactInfo::is_valid_address(&contact_info.rpc)
{
return Some(contact_info.rpc);
@ -260,6 +276,9 @@ fn main() -> Result<(), Box<dyn error::Error>> {
for rpc_addr in rpc_addrs {
println!("http://{}", rpc_addr);
if any {
break;
}
}
}
("stop", Some(matches)) => {

View File

@ -278,7 +278,7 @@ setup_validator_accounts() {
return 0
}
rpc_url=$($solana_gossip get-rpc-url --entrypoint "$gossip_entrypoint")
rpc_url=$($solana_gossip get-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"

View File

@ -489,6 +489,7 @@ startBootstrapLeader() {
ssh "${sshOptions[@]}" -n "$ipAddress" \
"./solana/net/remote/remote-node.sh \
$deployMethod \
$ipAddress \
bootstrap-leader \
$entrypointIp \
$((${#validatorIpList[@]} + ${#blockstreamerIpList[@]} + ${#archiverIpList[@]})) \
@ -558,6 +559,7 @@ startNode() {
ssh "${sshOptions[@]}" -n "$ipAddress" \
"./solana/net/remote/remote-node.sh \
$deployMethod \
$ipAddress \
$nodeType \
$entrypointIp \
$((${#validatorIpList[@]} + ${#blockstreamerIpList[@]} + ${#archiverIpList[@]})) \

View File

@ -5,27 +5,28 @@ cd "$(dirname "$0")"/../..
set -x
deployMethod="$1"
nodeType="$2"
entrypointIp="$3"
numNodes="$4"
if [[ -n $5 ]]; then
export RUST_LOG="$5"
ipAddress="$2"
nodeType="$3"
entrypointIp="$4"
numNodes="$5"
if [[ -n $6 ]]; then
export RUST_LOG="$6"
fi
skipSetup="$6"
failOnValidatorBootupFailure="$7"
externalPrimordialAccountsFile="$8"
maybeDisableAirdrops="$9"
internalNodesStakeLamports="${10}"
internalNodesLamports="${11}"
nodeIndex="${12}"
numBenchTpsClients="${13}"
benchTpsExtraArgs="${14}"
numBenchExchangeClients="${15}"
benchExchangeExtraArgs="${16}"
genesisOptions="${17}"
extraNodeArgs="${18}"
gpuMode="${19:-auto}"
GEOLOCATION_API_KEY="${20}"
skipSetup="$7"
failOnValidatorBootupFailure="$8"
externalPrimordialAccountsFile="$9"
maybeDisableAirdrops="${10}"
internalNodesStakeLamports="${11}"
internalNodesLamports="${12}"
nodeIndex="${13}"
numBenchTpsClients="${14}"
benchTpsExtraArgs="${15}"
numBenchExchangeClients="${16}"
benchExchangeExtraArgs="${17}"
genesisOptions="${18}"
extraNodeArgs="${19}"
gpuMode="${20:-auto}"
GEOLOCATION_API_KEY="${21}"
set +x
# Use a very large stake (relative to the default multinode-demo/ stake of 42)
@ -42,6 +43,7 @@ missing() {
}
[[ -n $deployMethod ]] || missing deployMethod
[[ -n $ipAddress ]] || missing ipAddress
[[ -n $nodeType ]] || missing nodeType
[[ -n $entrypointIp ]] || missing entrypointIp
[[ -n $numNodes ]] || missing numNodes
@ -284,18 +286,22 @@ EOF
fi
args=(
--entrypoint "$entrypointIp:8001"
--gossip-port 8001
--rpc-port 8899
)
if [[ $nodeType = blockstreamer ]]; then
args+=(
--blockstream /tmp/solana-blockstream.sock
--entrypoint "$ipAddress:8001"
--gossip-port 9001
--no-voting
--dev-no-sigverify
--blockstream /tmp/solana-blockstream.sock
)
else
args+=(--enable-rpc-exit)
args+=(
--entrypoint "$entrypointIp:8001"
--gossip-port 8001
--enable-rpc-exit
)
if [[ -n $internalNodesLamports ]]; then
args+=(--node-lamports "$internalNodesLamports")
fi
@ -365,6 +371,11 @@ EOF
cat >> ~/solana/on-reboot <<EOF
~/solana/restart-explorer
echo --- Starting gossip spy node
ln -sfT gossip.log.\$now gossip.log
nohup solana-gossip spy --gossip-port 8001 --gossip-host "$ipAddress" --entrypoint $entrypointIp:8001 > gossip.log.\$now 2>&1 &
sleep 1
head gossip.log
EOF
fi