Update various terms to "known" (#21257)
* Update snapshot bootstrap terminology * Update only known rpc terminology * Update replica-node
This commit is contained in:
parent
f8dcb2f38b
commit
ae3777cadb
@ -102,14 +102,14 @@ fn get_rpc_peer_node(
|
|||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
let rpc_peers_total = rpc_peers.len();
|
let rpc_peers_total = rpc_peers.len();
|
||||||
|
|
||||||
let rpc_peers_trusted = rpc_peers
|
let rpc_known_peers = rpc_peers
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|rpc_peer| &rpc_peer.id == peer_pubkey)
|
.filter(|rpc_peer| &rpc_peer.id == peer_pubkey)
|
||||||
.count();
|
.count();
|
||||||
|
|
||||||
info!(
|
info!(
|
||||||
"Total {} RPC nodes found. {} trusted",
|
"Total {} RPC nodes found. {} known",
|
||||||
rpc_peers_total, rpc_peers_trusted
|
rpc_peers_total, rpc_known_peers
|
||||||
);
|
);
|
||||||
|
|
||||||
let mut highest_snapshot_info: Option<(Slot, Hash)> =
|
let mut highest_snapshot_info: Option<(Slot, Hash)> =
|
||||||
|
@ -45,7 +45,7 @@ use {
|
|||||||
pub struct RpcBootstrapConfig {
|
pub struct RpcBootstrapConfig {
|
||||||
pub no_genesis_fetch: bool,
|
pub no_genesis_fetch: bool,
|
||||||
pub no_snapshot_fetch: bool,
|
pub no_snapshot_fetch: bool,
|
||||||
pub no_untrusted_rpc: bool,
|
pub only_known_rpc: bool,
|
||||||
pub max_genesis_archive_unpacked_size: u64,
|
pub max_genesis_archive_unpacked_size: u64,
|
||||||
pub no_check_vote_account: bool,
|
pub no_check_vote_account: bool,
|
||||||
pub incremental_snapshot_fetch: bool,
|
pub incremental_snapshot_fetch: bool,
|
||||||
@ -284,14 +284,14 @@ fn get_rpc_peers(
|
|||||||
.filter(|rpc_peer| !blacklisted_rpc_nodes.contains(&rpc_peer.id))
|
.filter(|rpc_peer| !blacklisted_rpc_nodes.contains(&rpc_peer.id))
|
||||||
.collect();
|
.collect();
|
||||||
let rpc_peers_blacklisted = rpc_peers_total - rpc_peers.len();
|
let rpc_peers_blacklisted = rpc_peers_total - rpc_peers.len();
|
||||||
let rpc_peers_trusted = rpc_peers
|
let rpc_known_peers = rpc_peers
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|rpc_peer| is_known_validator(&rpc_peer.id, &validator_config.known_validators))
|
.filter(|rpc_peer| is_known_validator(&rpc_peer.id, &validator_config.known_validators))
|
||||||
.count();
|
.count();
|
||||||
|
|
||||||
info!(
|
info!(
|
||||||
"Total {} RPC nodes found. {} known, {} blacklisted ",
|
"Total {} RPC nodes found. {} known, {} blacklisted ",
|
||||||
rpc_peers_total, rpc_peers_trusted, rpc_peers_blacklisted
|
rpc_peers_total, rpc_known_peers, rpc_peers_blacklisted
|
||||||
);
|
);
|
||||||
|
|
||||||
if rpc_peers_blacklisted == rpc_peers_total {
|
if rpc_peers_blacklisted == rpc_peers_total {
|
||||||
@ -571,7 +571,7 @@ mod without_incremental_snapshots {
|
|||||||
if let Some(ref known_validators) = validator_config.known_validators {
|
if let Some(ref known_validators) = validator_config.known_validators {
|
||||||
if known_validators.contains(&rpc_contact_info.id)
|
if known_validators.contains(&rpc_contact_info.id)
|
||||||
&& known_validators.len() == 1
|
&& known_validators.len() == 1
|
||||||
&& bootstrap_config.no_untrusted_rpc {
|
&& bootstrap_config.only_known_rpc {
|
||||||
warn!("The snapshot download is too slow, throughput: {} < min speed {} bytes/sec, but will NOT abort \
|
warn!("The snapshot download is too slow, throughput: {} < min speed {} bytes/sec, but will NOT abort \
|
||||||
and try a different node as it is the only known validator and the --only-known-rpc flag \
|
and try a different node as it is the only known validator and the --only-known-rpc flag \
|
||||||
is set. \
|
is set. \
|
||||||
@ -634,7 +634,7 @@ mod without_incremental_snapshots {
|
|||||||
|
|
||||||
if let Some(ref known_validators) = validator_config.known_validators {
|
if let Some(ref known_validators) = validator_config.known_validators {
|
||||||
if known_validators.contains(&rpc_contact_info.id) {
|
if known_validators.contains(&rpc_contact_info.id) {
|
||||||
continue; // Never blacklist a trusted node
|
continue; // Never blacklist a known node
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -684,22 +684,22 @@ mod without_incremental_snapshots {
|
|||||||
let eligible_rpc_peers = if bootstrap_config.no_snapshot_fetch {
|
let eligible_rpc_peers = if bootstrap_config.no_snapshot_fetch {
|
||||||
rpc_peers
|
rpc_peers
|
||||||
} else {
|
} else {
|
||||||
let trusted_snapshot_hashes =
|
let known_snapshot_hashes =
|
||||||
get_trusted_snapshot_hashes(cluster_info, &validator_config.known_validators);
|
get_known_snapshot_hashes(cluster_info, &validator_config.known_validators);
|
||||||
|
|
||||||
let mut eligible_rpc_peers = vec![];
|
let mut eligible_rpc_peers = vec![];
|
||||||
|
|
||||||
for rpc_peer in rpc_peers.iter() {
|
for rpc_peer in rpc_peers.iter() {
|
||||||
if bootstrap_config.no_untrusted_rpc
|
if bootstrap_config.only_known_rpc
|
||||||
&& !is_known_validator(&rpc_peer.id, &validator_config.known_validators)
|
&& !is_known_validator(&rpc_peer.id, &validator_config.known_validators)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
cluster_info.get_snapshot_hash_for_node(&rpc_peer.id, |snapshot_hashes| {
|
cluster_info.get_snapshot_hash_for_node(&rpc_peer.id, |snapshot_hashes| {
|
||||||
for snapshot_hash in snapshot_hashes {
|
for snapshot_hash in snapshot_hashes {
|
||||||
if let Some(ref trusted_snapshot_hashes) = trusted_snapshot_hashes {
|
if let Some(ref known_snapshot_hashes) = known_snapshot_hashes {
|
||||||
if !trusted_snapshot_hashes.contains(snapshot_hash) {
|
if !known_snapshot_hashes.contains(snapshot_hash) {
|
||||||
// Ignore all untrusted snapshot hashes
|
// Ignore all unknown snapshot hashes
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -770,20 +770,20 @@ mod without_incremental_snapshots {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_trusted_snapshot_hashes(
|
fn get_known_snapshot_hashes(
|
||||||
cluster_info: &ClusterInfo,
|
cluster_info: &ClusterInfo,
|
||||||
known_validators: &Option<HashSet<Pubkey>>,
|
known_validators: &Option<HashSet<Pubkey>>,
|
||||||
) -> Option<HashSet<(Slot, Hash)>> {
|
) -> Option<HashSet<(Slot, Hash)>> {
|
||||||
if let Some(known_validators) = known_validators {
|
if let Some(known_validators) = known_validators {
|
||||||
let mut trusted_snapshot_hashes = HashSet::new();
|
let mut known_snapshot_hashes = HashSet::new();
|
||||||
for known_validator in known_validators {
|
for known_validator in known_validators {
|
||||||
cluster_info.get_snapshot_hash_for_node(known_validator, |snapshot_hashes| {
|
cluster_info.get_snapshot_hash_for_node(known_validator, |snapshot_hashes| {
|
||||||
for snapshot_hash in snapshot_hashes {
|
for snapshot_hash in snapshot_hashes {
|
||||||
trusted_snapshot_hashes.insert(*snapshot_hash);
|
known_snapshot_hashes.insert(*snapshot_hash);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
Some(trusted_snapshot_hashes)
|
Some(known_snapshot_hashes)
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
@ -974,7 +974,7 @@ mod with_incremental_snapshots {
|
|||||||
|
|
||||||
if let Some(ref known_validators) = validator_config.known_validators {
|
if let Some(ref known_validators) = validator_config.known_validators {
|
||||||
if known_validators.contains(&rpc_contact_info.id) {
|
if known_validators.contains(&rpc_contact_info.id) {
|
||||||
continue; // Never blacklist a trusted node
|
continue; // Never blacklist a known node
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1112,7 +1112,7 @@ mod with_incremental_snapshots {
|
|||||||
rpc_peers: &[ContactInfo],
|
rpc_peers: &[ContactInfo],
|
||||||
) -> Vec<PeerSnapshotHash> {
|
) -> Vec<PeerSnapshotHash> {
|
||||||
// Which strategy to use for getting the peer snapshot hashes? The standard way is what's
|
// Which strategy to use for getting the peer snapshot hashes? The standard way is what's
|
||||||
// described in the function's documentation. However, if there are no trusted peers that
|
// described in the function's documentation. However, if there are no known peers that
|
||||||
// have enabled incremental snapshots, it may be possible that there are no snapshot hashes
|
// have enabled incremental snapshots, it may be possible that there are no snapshot hashes
|
||||||
// with a slot that is a multiple of our full snapshot archive interval. If that happens,
|
// with a slot that is a multiple of our full snapshot archive interval. If that happens,
|
||||||
// we retry with the "fallback" strategy that *does not* filter based on full snapshot
|
// we retry with the "fallback" strategy that *does not* filter based on full snapshot
|
||||||
@ -1127,19 +1127,15 @@ mod with_incremental_snapshots {
|
|||||||
Strategy::Standard,
|
Strategy::Standard,
|
||||||
Strategy::WithoutFullSnapshotArchiveIntervalFiltering,
|
Strategy::WithoutFullSnapshotArchiveIntervalFiltering,
|
||||||
] {
|
] {
|
||||||
let trusted_snapshot_hashes =
|
let known_snapshot_hashes = get_known_snapshot_hashes(cluster_info, validator_config);
|
||||||
get_trusted_snapshot_hashes(cluster_info, validator_config);
|
|
||||||
|
|
||||||
let mut peer_snapshot_hashes = get_trusted_peer_snapshot_hashes(
|
let mut peer_snapshot_hashes = get_known_peer_snapshot_hashes(
|
||||||
cluster_info,
|
cluster_info,
|
||||||
validator_config,
|
validator_config,
|
||||||
bootstrap_config,
|
bootstrap_config,
|
||||||
rpc_peers,
|
rpc_peers,
|
||||||
);
|
);
|
||||||
retain_trusted_peer_snapshot_hashes(
|
retain_known_peer_snapshot_hashes(&known_snapshot_hashes, &mut peer_snapshot_hashes);
|
||||||
&trusted_snapshot_hashes,
|
|
||||||
&mut peer_snapshot_hashes,
|
|
||||||
);
|
|
||||||
|
|
||||||
if strategy == Strategy::Standard {
|
if strategy == Strategy::Standard {
|
||||||
// The standard strategy is to retain only the peer snapshot hashes with a multiple
|
// The standard strategy is to retain only the peer snapshot hashes with a multiple
|
||||||
@ -1177,33 +1173,33 @@ mod with_incremental_snapshots {
|
|||||||
unreachable!("for-loop above is guaranteed to return");
|
unreachable!("for-loop above is guaranteed to return");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the snapshot hashes from trusted peers.
|
/// Get the snapshot hashes from known peers.
|
||||||
///
|
///
|
||||||
/// The hashes are put into a map from full snapshot hash to a set of incremental snapshot
|
/// The hashes are put into a map from full snapshot hash to a set of incremental snapshot
|
||||||
/// hashes. This map will be used as the golden hashes; when peers are queried for their
|
/// hashes. This map will be used as the golden hashes; when peers are queried for their
|
||||||
/// individual snapshot hashes, their results will be checked against this map to verify
|
/// individual snapshot hashes, their results will be checked against this map to verify
|
||||||
/// correctness.
|
/// correctness.
|
||||||
///
|
///
|
||||||
/// NOTE: Only a single snashot hash is allowed per slot. If somehow two trusted peers have a
|
/// NOTE: Only a single snashot hash is allowed per slot. If somehow two known peers have a
|
||||||
/// snapshot hash with the same slot and _different_ hashes, the second will be skipped. This
|
/// snapshot hash with the same slot and _different_ hashes, the second will be skipped. This
|
||||||
/// applies to both full and incremental snapshot hashes.
|
/// applies to both full and incremental snapshot hashes.
|
||||||
fn get_trusted_snapshot_hashes(
|
fn get_known_snapshot_hashes(
|
||||||
cluster_info: &ClusterInfo,
|
cluster_info: &ClusterInfo,
|
||||||
validator_config: &ValidatorConfig,
|
validator_config: &ValidatorConfig,
|
||||||
) -> HashMap<(Slot, Hash), HashSet<(Slot, Hash)>> {
|
) -> HashMap<(Slot, Hash), HashSet<(Slot, Hash)>> {
|
||||||
if validator_config.known_validators.is_none() {
|
if validator_config.known_validators.is_none() {
|
||||||
trace!("no known validators, so no trusted snapshot hashes");
|
trace!("no known validators, so no known snapshot hashes");
|
||||||
return HashMap::new();
|
return HashMap::new();
|
||||||
}
|
}
|
||||||
let known_validators = validator_config.known_validators.as_ref().unwrap();
|
let known_validators = validator_config.known_validators.as_ref().unwrap();
|
||||||
|
|
||||||
let mut trusted_snapshot_hashes: HashMap<(Slot, Hash), HashSet<(Slot, Hash)>> =
|
let mut known_snapshot_hashes: HashMap<(Slot, Hash), HashSet<(Slot, Hash)>> =
|
||||||
HashMap::new();
|
HashMap::new();
|
||||||
known_validators
|
known_validators
|
||||||
.iter()
|
.iter()
|
||||||
.for_each(|known_validator| {
|
.for_each(|known_validator| {
|
||||||
// First get the Crds::SnapshotHashes for each known validator and add them as
|
// First get the Crds::SnapshotHashes for each known validator and add them as
|
||||||
// the keys in the trusted snapshot hashes HashMap.
|
// the keys in the known snapshot hashes HashMap.
|
||||||
let mut full_snapshot_hashes = Vec::new();
|
let mut full_snapshot_hashes = Vec::new();
|
||||||
cluster_info.get_snapshot_hash_for_node(known_validator, |snapshot_hashes| {
|
cluster_info.get_snapshot_hash_for_node(known_validator, |snapshot_hashes| {
|
||||||
full_snapshot_hashes = snapshot_hashes.clone();
|
full_snapshot_hashes = snapshot_hashes.clone();
|
||||||
@ -1213,19 +1209,19 @@ mod with_incremental_snapshots {
|
|||||||
// slot but with a _different_ hash.
|
// slot but with a _different_ hash.
|
||||||
// NOTE: There's no good reason for known validators to produce snapshots at
|
// NOTE: There's no good reason for known validators to produce snapshots at
|
||||||
// the same slot with different hashes, so this should not happen.
|
// the same slot with different hashes, so this should not happen.
|
||||||
if !trusted_snapshot_hashes.keys().any(|trusted_snapshot_hash| {
|
if !known_snapshot_hashes.keys().any(|known_snapshot_hash| {
|
||||||
trusted_snapshot_hash.0 == full_snapshot_hash.0 && trusted_snapshot_hash.1 != full_snapshot_hash.1
|
known_snapshot_hash.0 == full_snapshot_hash.0 && known_snapshot_hash.1 != full_snapshot_hash.1
|
||||||
}) {
|
}) {
|
||||||
trusted_snapshot_hashes.insert(full_snapshot_hash, HashSet::new());
|
known_snapshot_hashes.insert(full_snapshot_hash, HashSet::new());
|
||||||
} else {
|
} else {
|
||||||
info!("Ignoring full snapshot hash from known validator {} with a slot we've already seen (slot: {}), but a different hash.", known_validator, full_snapshot_hash.0);
|
info!("Ignoring full snapshot hash from known validator {} with a slot we've already seen (slot: {}), but a different hash.", known_validator, full_snapshot_hash.0);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Then get the Crds::IncrementalSnapshotHashes for each known validator and add
|
// Then get the Crds::IncrementalSnapshotHashes for each known validator and add
|
||||||
// them as the values in the trusted snapshot hashes HashMap.
|
// them as the values in the known snapshot hashes HashMap.
|
||||||
if let Some(crds_value::IncrementalSnapshotHashes {base: full_snapshot_hash, hashes: incremental_snapshot_hashes, ..}) = cluster_info.get_incremental_snapshot_hashes_for_node(known_validator) {
|
if let Some(crds_value::IncrementalSnapshotHashes {base: full_snapshot_hash, hashes: incremental_snapshot_hashes, ..}) = cluster_info.get_incremental_snapshot_hashes_for_node(known_validator) {
|
||||||
if let Some(hashes) = trusted_snapshot_hashes.get_mut(&full_snapshot_hash) {
|
if let Some(hashes) = known_snapshot_hashes.get_mut(&full_snapshot_hash) {
|
||||||
// Do not add this hash if there's already an incremental snapshot hash
|
// Do not add this hash if there's already an incremental snapshot hash
|
||||||
// with the same slot, but with a _different_ hash.
|
// with the same slot, but with a _different_ hash.
|
||||||
// NOTE: There's no good reason for known validators to produce snapshots
|
// NOTE: There's no good reason for known validators to produce snapshots
|
||||||
@ -1240,24 +1236,24 @@ mod with_incremental_snapshots {
|
|||||||
} else {
|
} else {
|
||||||
// Since incremental snapshots *must* have a valid base (i.e. full)
|
// Since incremental snapshots *must* have a valid base (i.e. full)
|
||||||
// snapshot, if .get() returned None, then that can only happen if there
|
// snapshot, if .get() returned None, then that can only happen if there
|
||||||
// already is a full snapshot hash in the trusted snapshot hashes with the
|
// already is a full snapshot hash in the known snapshot hashes with the
|
||||||
// same slot but _different_ a hash. Assert that below. If the assert
|
// same slot but _different_ a hash. Assert that below. If the assert
|
||||||
// ever fails, there is a programmer bug.
|
// ever fails, there is a programmer bug.
|
||||||
assert!(trusted_snapshot_hashes.keys().any(|(slot, hash)| slot == &full_snapshot_hash.0 && hash != &full_snapshot_hash.1),
|
assert!(known_snapshot_hashes.keys().any(|(slot, hash)| slot == &full_snapshot_hash.0 && hash != &full_snapshot_hash.1),
|
||||||
"There must exist a full snapshot hash already in trusted snapshot hashes with the same slot but a different hash");
|
"There must exist a full snapshot hash already in known snapshot hashes with the same slot but a different hash");
|
||||||
info!("Ignoring incremental snapshot hashes from known validator {} with a base slot we've already seen (base slot: {}), but a different base hash.", known_validator, full_snapshot_hash.0);
|
info!("Ignoring incremental snapshot hashes from known validator {} with a base slot we've already seen (base slot: {}), but a different base hash.", known_validator, full_snapshot_hash.0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
trace!("trusted snapshot hashes: {:?}", &trusted_snapshot_hashes);
|
trace!("known snapshot hashes: {:?}", &known_snapshot_hashes);
|
||||||
trusted_snapshot_hashes
|
known_snapshot_hashes
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get trusted snapshot hashes from all the eligible peers. This fn will get only one
|
/// Get known snapshot hashes from all the eligible peers. This fn will get only one
|
||||||
/// snapshot hash per peer (the one with the highest slot). This may be just a full snapshot
|
/// snapshot hash per peer (the one with the highest slot). This may be just a full snapshot
|
||||||
/// hash, or a combo full (i.e. base) snapshot hash and incremental snapshot hash.
|
/// hash, or a combo full (i.e. base) snapshot hash and incremental snapshot hash.
|
||||||
fn get_trusted_peer_snapshot_hashes(
|
fn get_known_peer_snapshot_hashes(
|
||||||
cluster_info: &ClusterInfo,
|
cluster_info: &ClusterInfo,
|
||||||
validator_config: &ValidatorConfig,
|
validator_config: &ValidatorConfig,
|
||||||
bootstrap_config: &RpcBootstrapConfig,
|
bootstrap_config: &RpcBootstrapConfig,
|
||||||
@ -1265,10 +1261,10 @@ mod with_incremental_snapshots {
|
|||||||
) -> Vec<PeerSnapshotHash> {
|
) -> Vec<PeerSnapshotHash> {
|
||||||
let mut peer_snapshot_hashes = Vec::new();
|
let mut peer_snapshot_hashes = Vec::new();
|
||||||
for rpc_peer in rpc_peers {
|
for rpc_peer in rpc_peers {
|
||||||
if bootstrap_config.no_untrusted_rpc
|
if bootstrap_config.only_known_rpc
|
||||||
&& !is_known_validator(&rpc_peer.id, &validator_config.known_validators)
|
&& !is_known_validator(&rpc_peer.id, &validator_config.known_validators)
|
||||||
{
|
{
|
||||||
// We were told to ignore untrusted peers
|
// We were told to ignore unknown peers
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1296,21 +1292,21 @@ mod with_incremental_snapshots {
|
|||||||
peer_snapshot_hashes
|
peer_snapshot_hashes
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Retain the peer snapshot hashes that match a hash from the trusted snapshot hashes
|
/// Retain the peer snapshot hashes that match a hash from the known snapshot hashes
|
||||||
fn retain_trusted_peer_snapshot_hashes(
|
fn retain_known_peer_snapshot_hashes(
|
||||||
trusted_snapshot_hashes: &HashMap<(Slot, Hash), HashSet<(Slot, Hash)>>,
|
known_snapshot_hashes: &HashMap<(Slot, Hash), HashSet<(Slot, Hash)>>,
|
||||||
peer_snapshot_hashes: &mut Vec<PeerSnapshotHash>,
|
peer_snapshot_hashes: &mut Vec<PeerSnapshotHash>,
|
||||||
) {
|
) {
|
||||||
peer_snapshot_hashes.retain(|peer_snapshot_hash| {
|
peer_snapshot_hashes.retain(|peer_snapshot_hash| {
|
||||||
trusted_snapshot_hashes
|
known_snapshot_hashes
|
||||||
.get(&peer_snapshot_hash.snapshot_hash.full)
|
.get(&peer_snapshot_hash.snapshot_hash.full)
|
||||||
.map(|trusted_incremental_hashes| {
|
.map(|known_incremental_hashes| {
|
||||||
if peer_snapshot_hash.snapshot_hash.incr.is_none() {
|
if peer_snapshot_hash.snapshot_hash.incr.is_none() {
|
||||||
// If the peer's full snapshot hashes match, but doesn't have any
|
// If the peer's full snapshot hashes match, but doesn't have any
|
||||||
// incremental snapshots, that's fine; keep 'em!
|
// incremental snapshots, that's fine; keep 'em!
|
||||||
true
|
true
|
||||||
} else {
|
} else {
|
||||||
trusted_incremental_hashes
|
known_incremental_hashes
|
||||||
.contains(peer_snapshot_hash.snapshot_hash.incr.as_ref().unwrap())
|
.contains(peer_snapshot_hash.snapshot_hash.incr.as_ref().unwrap())
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -1318,7 +1314,7 @@ mod with_incremental_snapshots {
|
|||||||
});
|
});
|
||||||
|
|
||||||
trace!(
|
trace!(
|
||||||
"retain trusted peer snapshot hashes: {:?}",
|
"retain known peer snapshot hashes: {:?}",
|
||||||
&peer_snapshot_hashes
|
&peer_snapshot_hashes
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -1560,7 +1556,7 @@ mod with_incremental_snapshots {
|
|||||||
if let Some(ref known_validators) = validator_config.known_validators {
|
if let Some(ref known_validators) = validator_config.known_validators {
|
||||||
if known_validators.contains(&rpc_contact_info.id)
|
if known_validators.contains(&rpc_contact_info.id)
|
||||||
&& known_validators.len() == 1
|
&& known_validators.len() == 1
|
||||||
&& bootstrap_config.no_untrusted_rpc
|
&& bootstrap_config.only_known_rpc
|
||||||
{
|
{
|
||||||
warn!("The snapshot download is too slow, throughput: {} < min speed {} bytes/sec, but will NOT abort \
|
warn!("The snapshot download is too slow, throughput: {} < min speed {} bytes/sec, but will NOT abort \
|
||||||
and try a different node as it is the only known validator and the --only-known-rpc flag \
|
and try a different node as it is the only known validator and the --only-known-rpc flag \
|
||||||
@ -1702,8 +1698,8 @@ mod with_incremental_snapshots {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_retain_trusted_peer_snapshot_hashes() {
|
fn test_retain_known_peer_snapshot_hashes() {
|
||||||
let trusted_snapshot_hashes: HashMap<(Slot, Hash), HashSet<(Slot, Hash)>> = [
|
let known_snapshot_hashes: HashMap<(Slot, Hash), HashSet<(Slot, Hash)>> = [
|
||||||
(
|
(
|
||||||
(200_000, Hash::new_unique()),
|
(200_000, Hash::new_unique()),
|
||||||
[
|
[
|
||||||
@ -1732,9 +1728,9 @@ mod with_incremental_snapshots {
|
|||||||
.cloned()
|
.cloned()
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
let trusted_snapshot_hash = trusted_snapshot_hashes.iter().next().unwrap();
|
let known_snapshot_hash = known_snapshot_hashes.iter().next().unwrap();
|
||||||
let trusted_full_snapshot_hash = trusted_snapshot_hash.0;
|
let known_full_snapshot_hash = known_snapshot_hash.0;
|
||||||
let trusted_incremental_snapshot_hash = trusted_snapshot_hash.1.iter().next().unwrap();
|
let known_incremental_snapshot_hash = known_snapshot_hash.1.iter().next().unwrap();
|
||||||
|
|
||||||
let contact_info = default_contact_info_for_tests();
|
let contact_info = default_contact_info_for_tests();
|
||||||
let peer_snapshot_hashes = vec![
|
let peer_snapshot_hashes = vec![
|
||||||
@ -1747,37 +1743,37 @@ mod with_incremental_snapshots {
|
|||||||
Some((111_111, Hash::default())),
|
Some((111_111, Hash::default())),
|
||||||
),
|
),
|
||||||
// good full snapshot hash, no incremental snapshot hash
|
// good full snapshot hash, no incremental snapshot hash
|
||||||
PeerSnapshotHash::new(contact_info.clone(), *trusted_full_snapshot_hash, None),
|
PeerSnapshotHash::new(contact_info.clone(), *known_full_snapshot_hash, None),
|
||||||
// bad full snapshot hash, good (not possible) incremental snapshot hash
|
// bad full snapshot hash, good (not possible) incremental snapshot hash
|
||||||
PeerSnapshotHash::new(
|
PeerSnapshotHash::new(
|
||||||
contact_info.clone(),
|
contact_info.clone(),
|
||||||
(111_000, Hash::default()),
|
(111_000, Hash::default()),
|
||||||
Some(*trusted_incremental_snapshot_hash),
|
Some(*known_incremental_snapshot_hash),
|
||||||
),
|
),
|
||||||
// good full snapshot hash, bad incremental snapshot hash
|
// good full snapshot hash, bad incremental snapshot hash
|
||||||
PeerSnapshotHash::new(
|
PeerSnapshotHash::new(
|
||||||
contact_info.clone(),
|
contact_info.clone(),
|
||||||
*trusted_full_snapshot_hash,
|
*known_full_snapshot_hash,
|
||||||
Some((111_111, Hash::default())),
|
Some((111_111, Hash::default())),
|
||||||
),
|
),
|
||||||
// good everything
|
// good everything
|
||||||
PeerSnapshotHash::new(
|
PeerSnapshotHash::new(
|
||||||
contact_info.clone(),
|
contact_info.clone(),
|
||||||
*trusted_full_snapshot_hash,
|
*known_full_snapshot_hash,
|
||||||
Some(*trusted_incremental_snapshot_hash),
|
Some(*known_incremental_snapshot_hash),
|
||||||
),
|
),
|
||||||
];
|
];
|
||||||
|
|
||||||
let expected = vec![
|
let expected = vec![
|
||||||
PeerSnapshotHash::new(contact_info.clone(), *trusted_full_snapshot_hash, None),
|
PeerSnapshotHash::new(contact_info.clone(), *known_full_snapshot_hash, None),
|
||||||
PeerSnapshotHash::new(
|
PeerSnapshotHash::new(
|
||||||
contact_info,
|
contact_info,
|
||||||
*trusted_full_snapshot_hash,
|
*known_full_snapshot_hash,
|
||||||
Some(*trusted_incremental_snapshot_hash),
|
Some(*known_incremental_snapshot_hash),
|
||||||
),
|
),
|
||||||
];
|
];
|
||||||
let mut actual = peer_snapshot_hashes;
|
let mut actual = peer_snapshot_hashes;
|
||||||
retain_trusted_peer_snapshot_hashes(&trusted_snapshot_hashes, &mut actual);
|
retain_known_peer_snapshot_hashes(&known_snapshot_hashes, &mut actual);
|
||||||
assert_eq!(expected, actual);
|
assert_eq!(expected, actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1092,7 +1092,7 @@ pub fn main() {
|
|||||||
.help("Log when transactions are processed which reference a given key."),
|
.help("Log when transactions are processed which reference a given key."),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name("no_untrusted_rpc")
|
Arg::with_name("only_known_rpc")
|
||||||
.alias("no-untrusted-rpc")
|
.alias("no-untrusted-rpc")
|
||||||
.long("only-known-rpc")
|
.long("only-known-rpc")
|
||||||
.takes_value(false)
|
.takes_value(false)
|
||||||
@ -1938,7 +1938,7 @@ pub fn main() {
|
|||||||
no_genesis_fetch: matches.is_present("no_genesis_fetch"),
|
no_genesis_fetch: matches.is_present("no_genesis_fetch"),
|
||||||
no_snapshot_fetch: matches.is_present("no_snapshot_fetch"),
|
no_snapshot_fetch: matches.is_present("no_snapshot_fetch"),
|
||||||
no_check_vote_account: matches.is_present("no_check_vote_account"),
|
no_check_vote_account: matches.is_present("no_check_vote_account"),
|
||||||
no_untrusted_rpc: matches.is_present("no_untrusted_rpc"),
|
only_known_rpc: matches.is_present("only_known_rpc"),
|
||||||
max_genesis_archive_unpacked_size: value_t_or_exit!(
|
max_genesis_archive_unpacked_size: value_t_or_exit!(
|
||||||
matches,
|
matches,
|
||||||
"max_genesis_archive_unpacked_size",
|
"max_genesis_archive_unpacked_size",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user