Rename "trusted" to "known" in `validators/` (#21197)

* Replaced trusted with known validator

* Format Convention
This commit is contained in:
Michael Keleti 2021-11-12 12:57:55 -06:00 committed by GitHub
parent 1509513339
commit b0ca335463
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 136 additions and 134 deletions

View File

@ -1,4 +1,4 @@
// Service to verify accounts hashes with other trusted validator nodes.
// Service to verify accounts hashes with other known validator nodes.
//
// Each interval, publish the snapshat hash which is the full accounts state
// hash on gossip. Monitor gossip for messages from validators in the `--known-validator`s
@ -40,8 +40,8 @@ impl AccountsHashVerifier {
pending_snapshot_package: Option<PendingSnapshotPackage>,
exit: &Arc<AtomicBool>,
cluster_info: &Arc<ClusterInfo>,
trusted_validators: Option<HashSet<Pubkey>>,
halt_on_trusted_validators_accounts_hash_mismatch: bool,
known_validators: Option<HashSet<Pubkey>>,
halt_on_known_validators_accounts_hash_mismatch: bool,
fault_injection_rate_slots: u64,
snapshot_config: Option<SnapshotConfig>,
ledger_path: PathBuf,
@ -68,8 +68,8 @@ impl AccountsHashVerifier {
Self::process_accounts_package(
accounts_package,
&cluster_info,
trusted_validators.as_ref(),
halt_on_trusted_validators_accounts_hash_mismatch,
known_validators.as_ref(),
halt_on_known_validators_accounts_hash_mismatch,
pending_snapshot_package.as_ref(),
&mut hashes,
&exit,
@ -94,8 +94,8 @@ impl AccountsHashVerifier {
fn process_accounts_package(
accounts_package: AccountsPackage,
cluster_info: &ClusterInfo,
trusted_validators: Option<&HashSet<Pubkey>>,
halt_on_trusted_validator_accounts_hash_mismatch: bool,
known_validators: Option<&HashSet<Pubkey>>,
halt_on_known_validator_accounts_hash_mismatch: bool,
pending_snapshot_package: Option<&PendingSnapshotPackage>,
hashes: &mut Vec<(Slot, Hash)>,
exit: &Arc<AtomicBool>,
@ -109,8 +109,8 @@ impl AccountsHashVerifier {
Self::push_accounts_hashes_to_cluster(
&accounts_package,
cluster_info,
trusted_validators,
halt_on_trusted_validator_accounts_hash_mismatch,
known_validators,
halt_on_known_validator_accounts_hash_mismatch,
hashes,
exit,
fault_injection_rate_slots,
@ -152,8 +152,8 @@ impl AccountsHashVerifier {
fn push_accounts_hashes_to_cluster(
accounts_package: &AccountsPackage,
cluster_info: &ClusterInfo,
trusted_validators: Option<&HashSet<Pubkey>>,
halt_on_trusted_validator_accounts_hash_mismatch: bool,
known_validators: Option<&HashSet<Pubkey>>,
halt_on_known_validator_accounts_hash_mismatch: bool,
hashes: &mut Vec<(Slot, Hash)>,
exit: &Arc<AtomicBool>,
fault_injection_rate_slots: u64,
@ -177,12 +177,12 @@ impl AccountsHashVerifier {
hashes.remove(0);
}
if halt_on_trusted_validator_accounts_hash_mismatch {
if halt_on_known_validator_accounts_hash_mismatch {
let mut slot_to_hash = HashMap::new();
for (slot, hash) in hashes.iter() {
slot_to_hash.insert(*slot, *hash);
}
if Self::should_halt(cluster_info, trusted_validators, &mut slot_to_hash) {
if Self::should_halt(cluster_info, known_validators, &mut slot_to_hash) {
exit.store(true, Ordering::Relaxed);
}
}
@ -226,20 +226,20 @@ impl AccountsHashVerifier {
fn should_halt(
cluster_info: &ClusterInfo,
trusted_validators: Option<&HashSet<Pubkey>>,
known_validators: Option<&HashSet<Pubkey>>,
slot_to_hash: &mut HashMap<Slot, Hash>,
) -> bool {
let mut verified_count = 0;
let mut highest_slot = 0;
if let Some(trusted_validators) = trusted_validators {
for trusted_validator in trusted_validators {
let is_conflicting = cluster_info.get_accounts_hash_for_node(trusted_validator, |accounts_hashes|
if let Some(known_validators) = known_validators {
for known_validator in known_validators {
let is_conflicting = cluster_info.get_accounts_hash_for_node(known_validator, |accounts_hashes|
{
accounts_hashes.iter().any(|(slot, hash)| {
if let Some(reference_hash) = slot_to_hash.get(slot) {
if *hash != *reference_hash {
error!("Trusted validator {} produced conflicting hashes for slot: {} ({} != {})",
trusted_validator,
error!("Known validator {} produced conflicting hashes for slot: {} ({} != {})",
known_validator,
slot,
hash,
reference_hash,
@ -303,11 +303,11 @@ mod tests {
let cluster_info = new_test_cluster_info(contact_info);
let cluster_info = Arc::new(cluster_info);
let mut trusted_validators = HashSet::new();
let mut known_validators = HashSet::new();
let mut slot_to_hash = HashMap::new();
assert!(!AccountsHashVerifier::should_halt(
&cluster_info,
Some(&trusted_validators),
Some(&known_validators),
&mut slot_to_hash,
));
@ -320,10 +320,10 @@ mod tests {
cluster_info.flush_push_queue();
}
slot_to_hash.insert(0, hash2);
trusted_validators.insert(validator1.pubkey());
known_validators.insert(validator1.pubkey());
assert!(AccountsHashVerifier::should_halt(
&cluster_info,
Some(&trusted_validators),
Some(&known_validators),
&mut slot_to_hash,
));
}
@ -339,7 +339,7 @@ mod tests {
let cluster_info = new_test_cluster_info(contact_info);
let cluster_info = Arc::new(cluster_info);
let trusted_validators = HashSet::new();
let known_validators = HashSet::new();
let exit = Arc::new(AtomicBool::new(false));
let mut hashes = vec![];
let full_snapshot_archive_interval_slots = 100;
@ -370,7 +370,7 @@ mod tests {
AccountsHashVerifier::process_accounts_package(
accounts_package,
&cluster_info,
Some(&trusted_validators),
Some(&known_validators),
false,
None,
&mut hashes,

View File

@ -1246,23 +1246,23 @@ mod tests {
// 2) repair validator set only includes our own id
// then no repairs should be generated
for pubkey in &[solana_sdk::pubkey::new_rand(), me.id] {
let trusted_validators = Some(vec![*pubkey].into_iter().collect());
assert!(serve_repair.repair_peers(&trusted_validators, 1).is_empty());
let known_validators = Some(vec![*pubkey].into_iter().collect());
assert!(serve_repair.repair_peers(&known_validators, 1).is_empty());
assert!(serve_repair
.repair_request(
&cluster_slots,
ShredRepairType::Shred(0, 0),
&mut LruCache::new(100),
&mut RepairStats::default(),
&trusted_validators,
&known_validators,
&mut OutstandingShredRepairs::default(),
)
.is_err());
}
// If trusted validator exists in gossip, should return repair successfully
let trusted_validators = Some(vec![contact_info2.id].into_iter().collect());
let repair_peers = serve_repair.repair_peers(&trusted_validators, 1);
// If known validator exists in gossip, should return repair successfully
let known_validators = Some(vec![contact_info2.id].into_iter().collect());
let repair_peers = serve_repair.repair_peers(&known_validators, 1);
assert_eq!(repair_peers.len(), 1);
assert_eq!(repair_peers[0].id, contact_info2.id);
assert!(serve_repair
@ -1271,12 +1271,12 @@ mod tests {
ShredRepairType::Shred(0, 0),
&mut LruCache::new(100),
&mut RepairStats::default(),
&trusted_validators,
&known_validators,
&mut OutstandingShredRepairs::default(),
)
.is_ok());
// Using no trusted validators should default to all
// Using no known validators should default to all
// validator's available in gossip, excluding myself
let repair_peers: HashSet<Pubkey> = serve_repair
.repair_peers(&None, 1)

View File

@ -82,8 +82,8 @@ pub struct Sockets {
pub struct TvuConfig {
pub max_ledger_shreds: Option<u64>,
pub shred_version: u16,
pub halt_on_trusted_validators_accounts_hash_mismatch: bool,
pub trusted_validators: Option<HashSet<Pubkey>>,
pub halt_on_known_validators_accounts_hash_mismatch: bool,
pub known_validators: Option<HashSet<Pubkey>>,
pub repair_validators: Option<HashSet<Pubkey>>,
pub accounts_hash_fault_injection_slots: u64,
pub accounts_db_caching_enabled: bool,
@ -220,8 +220,8 @@ impl Tvu {
pending_snapshot_package,
exit,
cluster_info,
tvu_config.trusted_validators.clone(),
tvu_config.halt_on_trusted_validators_accounts_hash_mismatch,
tvu_config.known_validators.clone(),
tvu_config.halt_on_known_validators_accounts_hash_mismatch,
tvu_config.accounts_hash_fault_injection_slots,
snapshot_config.clone(),
blockstore.ledger_path().to_path_buf(),

View File

@ -130,10 +130,10 @@ pub struct ValidatorConfig {
pub fixed_leader_schedule: Option<FixedSchedule>,
pub wait_for_supermajority: Option<Slot>,
pub new_hard_forks: Option<Vec<Slot>>,
pub trusted_validators: Option<HashSet<Pubkey>>, // None = trust all
pub repair_validators: Option<HashSet<Pubkey>>, // None = repair from all
pub gossip_validators: Option<HashSet<Pubkey>>, // None = gossip with all
pub halt_on_trusted_validators_accounts_hash_mismatch: bool,
pub known_validators: Option<HashSet<Pubkey>>, // None = trust all
pub repair_validators: Option<HashSet<Pubkey>>, // None = repair from all
pub gossip_validators: Option<HashSet<Pubkey>>, // None = gossip with all
pub halt_on_known_validators_accounts_hash_mismatch: bool,
pub accounts_hash_fault_injection_slots: u64, // 0 = no fault injection
pub frozen_accounts: Vec<Pubkey>,
pub no_rocksdb_compaction: bool,
@ -190,10 +190,10 @@ impl Default for ValidatorConfig {
fixed_leader_schedule: None,
wait_for_supermajority: None,
new_hard_forks: None,
trusted_validators: None,
known_validators: None,
repair_validators: None,
gossip_validators: None,
halt_on_trusted_validators_accounts_hash_mismatch: false,
halt_on_known_validators_accounts_hash_mismatch: false,
accounts_hash_fault_injection_slots: 0,
frozen_accounts: vec![],
no_rocksdb_compaction: false,
@ -612,7 +612,7 @@ impl Validator {
genesis_config.hash(),
ledger_path,
config.validator_exit.clone(),
config.trusted_validators.clone(),
config.known_validators.clone(),
rpc_override_health_check.clone(),
optimistically_confirmed_bank.clone(),
config.send_transaction_service_config.clone(),
@ -827,10 +827,10 @@ impl Validator {
cluster_confirmed_slot_receiver,
TvuConfig {
max_ledger_shreds: config.max_ledger_shreds,
halt_on_trusted_validators_accounts_hash_mismatch: config
.halt_on_trusted_validators_accounts_hash_mismatch,
halt_on_known_validators_accounts_hash_mismatch: config
.halt_on_known_validators_accounts_hash_mismatch,
shred_version: node.info.shred_version,
trusted_validators: config.trusted_validators.clone(),
known_validators: config.known_validators.clone(),
repair_validators: config.repair_validators.clone(),
accounts_hash_fault_injection_slots: config.accounts_hash_fault_injection_slots,
accounts_db_caching_enabled: config.accounts_db_caching_enabled,

View File

@ -547,7 +547,7 @@ impl Crds {
&mut self,
cap: usize, // Capacity hint for number of unique pubkeys.
// Set of pubkeys to never drop.
// e.g. trusted validators, self pubkey, ...
// e.g. known validators, self pubkey, ...
keep: &[Pubkey],
stakes: &HashMap<Pubkey, u64>,
now: u64,

View File

@ -24,11 +24,11 @@ pub fn safe_clone_config(config: &ValidatorConfig) -> ValidatorConfig {
fixed_leader_schedule: config.fixed_leader_schedule.clone(),
wait_for_supermajority: config.wait_for_supermajority,
new_hard_forks: config.new_hard_forks.clone(),
trusted_validators: config.trusted_validators.clone(),
known_validators: config.known_validators.clone(),
repair_validators: config.repair_validators.clone(),
gossip_validators: config.gossip_validators.clone(),
halt_on_trusted_validators_accounts_hash_mismatch: config
.halt_on_trusted_validators_accounts_hash_mismatch,
halt_on_known_validators_accounts_hash_mismatch: config
.halt_on_known_validators_accounts_hash_mismatch,
accounts_hash_fault_injection_slots: config.accounts_hash_fault_injection_slots,
frozen_accounts: config.frozen_accounts.clone(),
no_rocksdb_compaction: config.no_rocksdb_compaction,

View File

@ -1598,15 +1598,15 @@ fn test_consistency_halt() {
let mut validator_snapshot_test_config =
setup_snapshot_validator_config(snapshot_interval_slots, num_account_paths);
let mut trusted_validators = HashSet::new();
trusted_validators.insert(cluster_nodes[0].id);
let mut known_validators = HashSet::new();
known_validators.insert(cluster_nodes[0].id);
validator_snapshot_test_config
.validator_config
.trusted_validators = Some(trusted_validators);
.known_validators = Some(known_validators);
validator_snapshot_test_config
.validator_config
.halt_on_trusted_validators_accounts_hash_mismatch = true;
.halt_on_known_validators_accounts_hash_mismatch = true;
warn!("adding a validator");
cluster.add_validator(
@ -2420,11 +2420,11 @@ fn test_snapshots_blockstore_floor() {
SocketAddrSpace::Unspecified,
)
.unwrap();
let mut trusted_validators = HashSet::new();
trusted_validators.insert(cluster_nodes[0].id);
let mut known_validators = HashSet::new();
known_validators.insert(cluster_nodes[0].id);
validator_snapshot_test_config
.validator_config
.trusted_validators = Some(trusted_validators);
.known_validators = Some(known_validators);
cluster.add_validator(
&validator_snapshot_test_config.validator_config,

View File

@ -2296,7 +2296,7 @@ fn _send_transaction(
Ok(signature.to_string())
}
// Minimal RPC interface that trusted validators are expected to provide
// Minimal RPC interface that known validators are expected to provide
pub mod rpc_minimal {
use super::*;
#[rpc]

View File

@ -11,13 +11,13 @@ use {
#[derive(PartialEq, Clone, Copy, Debug)]
pub enum RpcHealthStatus {
Ok,
Behind { num_slots: Slot }, // Validator is behind its trusted validators
Behind { num_slots: Slot }, // Validator is behind its known validators
Unknown,
}
pub struct RpcHealth {
cluster_info: Arc<ClusterInfo>,
trusted_validators: Option<HashSet<Pubkey>>,
known_validators: Option<HashSet<Pubkey>>,
health_check_slot_distance: u64,
override_health_check: Arc<AtomicBool>,
#[cfg(test)]
@ -27,13 +27,13 @@ pub struct RpcHealth {
impl RpcHealth {
pub fn new(
cluster_info: Arc<ClusterInfo>,
trusted_validators: Option<HashSet<Pubkey>>,
known_validators: Option<HashSet<Pubkey>>,
health_check_slot_distance: u64,
override_health_check: Arc<AtomicBool>,
) -> Self {
Self {
cluster_info,
trusted_validators,
known_validators,
health_check_slot_distance,
override_health_check,
#[cfg(test)]
@ -51,7 +51,7 @@ impl RpcHealth {
if self.override_health_check.load(Ordering::Relaxed) {
RpcHealthStatus::Ok
} else if let Some(trusted_validators) = &self.trusted_validators {
} else if let Some(known_validators) = &self.known_validators {
match (
self.cluster_info
.get_accounts_hash_for_node(&self.cluster_info.id(), |hashes| {
@ -61,11 +61,11 @@ impl RpcHealth {
.map(|slot_hash| slot_hash.0)
})
.flatten(),
trusted_validators
known_validators
.iter()
.filter_map(|trusted_validator| {
.filter_map(|known_validator| {
self.cluster_info
.get_accounts_hash_for_node(trusted_validator, |hashes| {
.get_accounts_hash_for_node(known_validator, |hashes| {
hashes
.iter()
.max_by(|a, b| a.0.cmp(&b.0))
@ -77,39 +77,41 @@ impl RpcHealth {
) {
(
Some(latest_account_hash_slot),
Some(latest_trusted_validator_account_hash_slot),
Some(latest_known_validator_account_hash_slot),
) => {
// The validator is considered healthy if its latest account hash slot is within
// `health_check_slot_distance` of the latest trusted validator's account hash slot
// `health_check_slot_distance` of the latest known validator's account hash slot
if latest_account_hash_slot
> latest_trusted_validator_account_hash_slot
> latest_known_validator_account_hash_slot
.saturating_sub(self.health_check_slot_distance)
{
RpcHealthStatus::Ok
} else {
let num_slots = latest_trusted_validator_account_hash_slot
let num_slots = latest_known_validator_account_hash_slot
.saturating_sub(latest_account_hash_slot);
warn!(
"health check: behind by {} slots: me={}, latest trusted_validator={}",
"health check: behind by {} slots: me={}, latest known_validator={}",
num_slots,
latest_account_hash_slot,
latest_trusted_validator_account_hash_slot
latest_known_validator_account_hash_slot
);
RpcHealthStatus::Behind { num_slots }
}
}
(latest_account_hash_slot, latest_trusted_validator_account_hash_slot) => {
(latest_account_hash_slot, latest_known_validator_account_hash_slot) => {
if latest_account_hash_slot.is_none() {
warn!("health check: latest_account_hash_slot not available");
}
if latest_trusted_validator_account_hash_slot.is_none() {
warn!("health check: latest_trusted_validator_account_hash_slot not available");
if latest_known_validator_account_hash_slot.is_none() {
warn!(
"health check: latest_known_validator_account_hash_slot not available"
);
}
RpcHealthStatus::Unknown
}
}
} else {
// No trusted validator point of reference available, so this validator is healthy
// No known validator point of reference available, so this validator is healthy
// because it's running
RpcHealthStatus::Ok
}

View File

@ -295,7 +295,7 @@ impl JsonRpcService {
genesis_hash: Hash,
ledger_path: &Path,
validator_exit: Arc<RwLock<Exit>>,
trusted_validators: Option<HashSet<Pubkey>>,
known_validators: Option<HashSet<Pubkey>>,
override_health_check: Arc<AtomicBool>,
optimistically_confirmed_bank: Arc<RwLock<OptimisticallyConfirmedBank>>,
send_transaction_service_config: send_transaction_service::Config,
@ -310,7 +310,7 @@ impl JsonRpcService {
let health = Arc::new(RpcHealth::new(
cluster_info.clone(),
trusted_validators,
known_validators,
config.health_check_slot_distance,
override_health_check,
));
@ -737,7 +737,7 @@ mod tests {
}
#[test]
fn test_health_check_with_no_trusted_validators() {
fn test_health_check_with_no_known_validators() {
let rm = RpcRequestMiddleware::new(
PathBuf::from("/"),
None,
@ -748,7 +748,7 @@ mod tests {
}
#[test]
fn test_health_check_with_trusted_validators() {
fn test_health_check_with_known_validators() {
let cluster_info = Arc::new(ClusterInfo::new(
ContactInfo::default(),
Arc::new(Keypair::new()),
@ -756,7 +756,7 @@ mod tests {
));
let health_check_slot_distance = 123;
let override_health_check = Arc::new(AtomicBool::new(false));
let trusted_validators = vec![
let known_validators = vec![
solana_sdk::pubkey::new_rand(),
solana_sdk::pubkey::new_rand(),
solana_sdk::pubkey::new_rand(),
@ -764,17 +764,17 @@ mod tests {
let health = Arc::new(RpcHealth::new(
cluster_info.clone(),
Some(trusted_validators.clone().into_iter().collect()),
Some(known_validators.clone().into_iter().collect()),
health_check_slot_distance,
override_health_check.clone(),
));
let rm = RpcRequestMiddleware::new(PathBuf::from("/"), None, create_bank_forks(), health);
// No account hashes for this node or any trusted validators
// No account hashes for this node or any known validators
assert_eq!(rm.health_check(), "unknown");
// No account hashes for any trusted validators
// No account hashes for any known validators
cluster_info.push_accounts_hashes(vec![(1000, Hash::default()), (900, Hash::default())]);
cluster_info.flush_push_queue();
assert_eq!(rm.health_check(), "unknown");
@ -784,7 +784,7 @@ mod tests {
assert_eq!(rm.health_check(), "ok");
override_health_check.store(false, Ordering::Relaxed);
// This node is ahead of the trusted validators
// This node is ahead of the known validators
cluster_info
.gossip
.crds
@ -792,7 +792,7 @@ mod tests {
.unwrap()
.insert(
CrdsValue::new_unsigned(CrdsData::AccountsHashes(SnapshotHashes::new(
trusted_validators[0],
known_validators[0],
vec![
(1, Hash::default()),
(1001, Hash::default()),
@ -805,7 +805,7 @@ mod tests {
.unwrap();
assert_eq!(rm.health_check(), "ok");
// Node is slightly behind the trusted validators
// Node is slightly behind the known validators
cluster_info
.gossip
.crds
@ -813,7 +813,7 @@ mod tests {
.unwrap()
.insert(
CrdsValue::new_unsigned(CrdsData::AccountsHashes(SnapshotHashes::new(
trusted_validators[1],
known_validators[1],
vec![(1000 + health_check_slot_distance - 1, Hash::default())],
))),
1,
@ -822,7 +822,7 @@ mod tests {
.unwrap();
assert_eq!(rm.health_check(), "ok");
// Node is far behind the trusted validators
// Node is far behind the known validators
cluster_info
.gossip
.crds
@ -830,7 +830,7 @@ mod tests {
.unwrap()
.insert(
CrdsValue::new_unsigned(CrdsData::AccountsHashes(SnapshotHashes::new(
trusted_validators[2],
known_validators[2],
vec![(1000 + health_check_slot_distance, Hash::default())],
))),
1,

View File

@ -195,9 +195,9 @@ fn verify_reachable_ports(
)
}
fn is_trusted_validator(id: &Pubkey, trusted_validators: &Option<HashSet<Pubkey>>) -> bool {
if let Some(trusted_validators) = trusted_validators {
trusted_validators.contains(id)
fn is_known_validator(id: &Pubkey, known_validators: &Option<HashSet<Pubkey>>) -> bool {
if let Some(known_validators) = known_validators {
known_validators.contains(id)
} else {
false
}
@ -286,7 +286,7 @@ fn get_rpc_peers(
let rpc_peers_blacklisted = rpc_peers_total - rpc_peers.len();
let rpc_peers_trusted = rpc_peers
.iter()
.filter(|rpc_peer| is_trusted_validator(&rpc_peer.id, &validator_config.trusted_validators))
.filter(|rpc_peer| is_known_validator(&rpc_peer.id, &validator_config.known_validators))
.count();
info!(
@ -568,9 +568,9 @@ mod without_incremental_snapshots {
&& download_progress.percentage_done <= 2_f32
&& download_progress.estimated_remaining_time > 60_f32
&& download_abort_count < maximum_snapshot_download_abort {
if let Some(ref trusted_validators) = validator_config.trusted_validators {
if trusted_validators.contains(&rpc_contact_info.id)
&& trusted_validators.len() == 1
if let Some(ref known_validators) = validator_config.known_validators {
if known_validators.contains(&rpc_contact_info.id)
&& known_validators.len() == 1
&& bootstrap_config.no_untrusted_rpc {
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 \
@ -632,8 +632,8 @@ mod without_incremental_snapshots {
}
warn!("{}", result.unwrap_err());
if let Some(ref trusted_validators) = validator_config.trusted_validators {
if trusted_validators.contains(&rpc_contact_info.id) {
if let Some(ref known_validators) = validator_config.known_validators {
if known_validators.contains(&rpc_contact_info.id) {
continue; // Never blacklist a trusted node
}
}
@ -685,13 +685,13 @@ mod without_incremental_snapshots {
rpc_peers
} else {
let trusted_snapshot_hashes =
get_trusted_snapshot_hashes(cluster_info, &validator_config.trusted_validators);
get_trusted_snapshot_hashes(cluster_info, &validator_config.known_validators);
let mut eligible_rpc_peers = vec![];
for rpc_peer in rpc_peers.iter() {
if bootstrap_config.no_untrusted_rpc
&& !is_trusted_validator(&rpc_peer.id, &validator_config.trusted_validators)
&& !is_known_validator(&rpc_peer.id, &validator_config.known_validators)
{
continue;
}
@ -772,12 +772,12 @@ mod without_incremental_snapshots {
fn get_trusted_snapshot_hashes(
cluster_info: &ClusterInfo,
trusted_validators: &Option<HashSet<Pubkey>>,
known_validators: &Option<HashSet<Pubkey>>,
) -> Option<HashSet<(Slot, Hash)>> {
if let Some(trusted_validators) = trusted_validators {
if let Some(known_validators) = known_validators {
let mut trusted_snapshot_hashes = HashSet::new();
for trusted_validator in trusted_validators {
cluster_info.get_snapshot_hash_for_node(trusted_validator, |snapshot_hashes| {
for known_validator in known_validators {
cluster_info.get_snapshot_hash_for_node(known_validator, |snapshot_hashes| {
for snapshot_hash in snapshot_hashes {
trusted_snapshot_hashes.insert(*snapshot_hash);
}
@ -972,8 +972,8 @@ mod with_incremental_snapshots {
}
warn!("{}", result.unwrap_err());
if let Some(ref trusted_validators) = validator_config.trusted_validators {
if trusted_validators.contains(&rpc_contact_info.id) {
if let Some(ref known_validators) = validator_config.known_validators {
if known_validators.contains(&rpc_contact_info.id) {
continue; // Never blacklist a trusted node
}
}
@ -1191,50 +1191,50 @@ mod with_incremental_snapshots {
cluster_info: &ClusterInfo,
validator_config: &ValidatorConfig,
) -> HashMap<(Slot, Hash), HashSet<(Slot, Hash)>> {
if validator_config.trusted_validators.is_none() {
trace!("no trusted validators, so no trusted snapshot hashes");
if validator_config.known_validators.is_none() {
trace!("no known validators, so no trusted snapshot hashes");
return HashMap::new();
}
let trusted_validators = validator_config.trusted_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)>> =
HashMap::new();
trusted_validators
known_validators
.iter()
.for_each(|trusted_validator| {
// First get the Crds::SnapshotHashes for each trusted validator and add them as
.for_each(|known_validator| {
// First get the Crds::SnapshotHashes for each known validator and add them as
// the keys in the trusted snapshot hashes HashMap.
let mut full_snapshot_hashes = Vec::new();
cluster_info.get_snapshot_hash_for_node(trusted_validator, |snapshot_hashes| {
cluster_info.get_snapshot_hash_for_node(known_validator, |snapshot_hashes| {
full_snapshot_hashes = snapshot_hashes.clone();
});
full_snapshot_hashes.into_iter().for_each(|full_snapshot_hash| {
// Do not add this hash if there's already a full snapshot hash with the same
// slot but with a _different_ hash.
// NOTE: There's no good reason for trusted 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.
if !trusted_snapshot_hashes.keys().any(|trusted_snapshot_hash| {
trusted_snapshot_hash.0 == full_snapshot_hash.0 && trusted_snapshot_hash.1 != full_snapshot_hash.1
}) {
trusted_snapshot_hashes.insert(full_snapshot_hash, HashSet::new());
} else {
info!("Ignoring full snapshot hash from trusted validator {} with a slot we've already seen (slot: {}), but a different hash.", trusted_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 trusted validator and add
// Then get the Crds::IncrementalSnapshotHashes for each known validator and add
// them as the values in the trusted 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(trusted_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) {
// Do not add this hash if there's already an incremental snapshot hash
// with the same slot, but with a _different_ hash.
// NOTE: There's no good reason for trusted validators to produce snapshots
// NOTE: There's no good reason for known validators to produce snapshots
// at the same slot with different hashes, so this should not happen.
for incremental_snapshot_hash in incremental_snapshot_hashes {
if !hashes.iter().any(|(slot, hash)| slot == &incremental_snapshot_hash.0 && hash != &incremental_snapshot_hash.1) {
hashes.insert(incremental_snapshot_hash);
} else {
info!("Ignoring incremental snapshot hash from trusted validator {} with a slot we've already seen (slot: {}), but a different hash.", trusted_validator, incremental_snapshot_hash.0);
info!("Ignoring incremental snapshot hash from known validator {} with a slot we've already seen (slot: {}), but a different hash.", known_validator, incremental_snapshot_hash.0);
}
}
} else {
@ -1245,7 +1245,7 @@ mod with_incremental_snapshots {
// 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),
"There must exist a full snapshot hash already in trusted snapshot hashes with the same slot but a different hash");
info!("Ignoring incremental snapshot hashes from trusted validator {} with a base slot we've already seen (base slot: {}), but a different base hash.", trusted_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);
}
}
});
@ -1266,7 +1266,7 @@ mod with_incremental_snapshots {
let mut peer_snapshot_hashes = Vec::new();
for rpc_peer in rpc_peers {
if bootstrap_config.no_untrusted_rpc
&& !is_trusted_validator(&rpc_peer.id, &validator_config.trusted_validators)
&& !is_known_validator(&rpc_peer.id, &validator_config.known_validators)
{
// We were told to ignore untrusted peers
continue;
@ -1557,9 +1557,9 @@ mod with_incremental_snapshots {
&& download_progress.estimated_remaining_time > 60_f32
&& *download_abort_count < maximum_snapshot_download_abort
{
if let Some(ref trusted_validators) = validator_config.trusted_validators {
if trusted_validators.contains(&rpc_contact_info.id)
&& trusted_validators.len() == 1
if let Some(ref known_validators) = validator_config.known_validators {
if known_validators.contains(&rpc_contact_info.id)
&& known_validators.len() == 1
&& bootstrap_config.no_untrusted_rpc
{
warn!("The snapshot download is too slow, throughput: {} < min speed {} bytes/sec, but will NOT abort \

View File

@ -1072,7 +1072,7 @@ pub fn main() {
.help("Add a hard fork at this slot"),
)
.arg(
Arg::with_name("trusted_validators")
Arg::with_name("known_validators")
.alias("trusted-validator")
.long("known-validator")
.validator(is_pubkey)
@ -1374,10 +1374,10 @@ pub fn main() {
.help("Specify the configuration file for the AccountsDb plugin."),
)
.arg(
Arg::with_name("halt_on_trusted_validators_accounts_hash_mismatch")
Arg::with_name("halt_on_known_validators_accounts_hash_mismatch")
.alias("halt-on-trusted-validators-accounts-hash-mismatch")
.long("halt-on-known-validators-accounts-hash-mismatch")
.requires("trusted_validators")
.requires("known_validators")
.takes_value(false)
.help("Abort the validator if a bank hash mismatch is detected within known validator set"),
)
@ -1976,10 +1976,10 @@ pub fn main() {
None
};
let trusted_validators = validators_set(
let known_validators = validators_set(
&identity_keypair.pubkey(),
&matches,
"trusted_validators",
"known_validators",
"--known-validator",
);
let repair_validators = validators_set(
@ -2230,7 +2230,7 @@ pub fn main() {
},
voting_disabled: matches.is_present("no_voting") || restricted_repair_only_mode,
wait_for_supermajority: value_t!(matches, "wait_for_supermajority", Slot).ok(),
trusted_validators,
known_validators,
repair_validators,
gossip_validators,
frozen_accounts: values_t!(matches, "frozen_accounts", Pubkey).unwrap_or_default(),
@ -2458,8 +2458,8 @@ pub fn main() {
validator_config.max_ledger_shreds = Some(limit_ledger_size);
}
if matches.is_present("halt_on_trusted_validators_accounts_hash_mismatch") {
validator_config.halt_on_trusted_validators_accounts_hash_mismatch = true;
if matches.is_present("halt_on_known_validators_accounts_hash_mismatch") {
validator_config.halt_on_known_validators_accounts_hash_mismatch = true;
}
let public_rpc_addr = matches.value_of("public_rpc_addr").map(|addr| {