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

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

* Replaced trusted with known validator

* Format Convention

(cherry picked from commit b0ca335463)

# Conflicts:
#	core/src/accounts_hash_verifier.rs
#	core/src/serve_repair.rs
#	rpc/src/rpc_service.rs
#	validator/src/bootstrap.rs

* Fix conflicts

Co-authored-by: Michael Keleti <16996410+mkeleti@users.noreply.github.com>
Co-authored-by: Tyera Eulberg <tyera@solana.com>
This commit is contained in:
mergify[bot]
2021-11-12 21:36:53 +00:00
committed by GitHub
parent 09ef4d12f7
commit 21cd423e67
11 changed files with 116 additions and 116 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 // 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 // hash on gossip. Monitor gossip for messages from validators in the `--known-validator`s
@ -33,8 +33,8 @@ impl AccountsHashVerifier {
pending_snapshot_package: Option<PendingSnapshotPackage>, pending_snapshot_package: Option<PendingSnapshotPackage>,
exit: &Arc<AtomicBool>, exit: &Arc<AtomicBool>,
cluster_info: &Arc<ClusterInfo>, cluster_info: &Arc<ClusterInfo>,
trusted_validators: Option<HashSet<Pubkey>>, known_validators: Option<HashSet<Pubkey>>,
halt_on_trusted_validators_accounts_hash_mismatch: bool, halt_on_known_validators_accounts_hash_mismatch: bool,
fault_injection_rate_slots: u64, fault_injection_rate_slots: u64,
snapshot_interval_slots: u64, snapshot_interval_slots: u64,
) -> Self { ) -> Self {
@ -62,8 +62,8 @@ impl AccountsHashVerifier {
Self::process_accounts_package_pre( Self::process_accounts_package_pre(
accounts_package, accounts_package,
&cluster_info, &cluster_info,
&trusted_validators, &known_validators,
halt_on_trusted_validators_accounts_hash_mismatch, halt_on_known_validators_accounts_hash_mismatch,
&pending_snapshot_package, &pending_snapshot_package,
&mut hashes, &mut hashes,
&exit, &exit,
@ -87,8 +87,8 @@ impl AccountsHashVerifier {
fn process_accounts_package_pre( fn process_accounts_package_pre(
accounts_package: AccountsPackagePre, accounts_package: AccountsPackagePre,
cluster_info: &ClusterInfo, cluster_info: &ClusterInfo,
trusted_validators: &Option<HashSet<Pubkey>>, known_validators: &Option<HashSet<Pubkey>>,
halt_on_trusted_validator_accounts_hash_mismatch: bool, halt_on_known_validator_accounts_hash_mismatch: bool,
pending_snapshot_package: &Option<PendingSnapshotPackage>, pending_snapshot_package: &Option<PendingSnapshotPackage>,
hashes: &mut Vec<(Slot, Hash)>, hashes: &mut Vec<(Slot, Hash)>,
exit: &Arc<AtomicBool>, exit: &Arc<AtomicBool>,
@ -103,8 +103,8 @@ impl AccountsHashVerifier {
Self::process_accounts_package( Self::process_accounts_package(
accounts_package, accounts_package,
cluster_info, cluster_info,
trusted_validators, known_validators,
halt_on_trusted_validator_accounts_hash_mismatch, halt_on_known_validator_accounts_hash_mismatch,
pending_snapshot_package, pending_snapshot_package,
hashes, hashes,
exit, exit,
@ -116,8 +116,8 @@ impl AccountsHashVerifier {
fn process_accounts_package( fn process_accounts_package(
accounts_package: AccountsPackage, accounts_package: AccountsPackage,
cluster_info: &ClusterInfo, cluster_info: &ClusterInfo,
trusted_validators: &Option<HashSet<Pubkey>>, known_validators: &Option<HashSet<Pubkey>>,
halt_on_trusted_validator_accounts_hash_mismatch: bool, halt_on_known_validator_accounts_hash_mismatch: bool,
pending_snapshot_package: &Option<PendingSnapshotPackage>, pending_snapshot_package: &Option<PendingSnapshotPackage>,
hashes: &mut Vec<(Slot, Hash)>, hashes: &mut Vec<(Slot, Hash)>,
exit: &Arc<AtomicBool>, exit: &Arc<AtomicBool>,
@ -143,12 +143,12 @@ impl AccountsHashVerifier {
hashes.remove(0); 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(); let mut slot_to_hash = HashMap::new();
for (slot, hash) in hashes.iter() { for (slot, hash) in hashes.iter() {
slot_to_hash.insert(*slot, *hash); 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); exit.store(true, Ordering::Relaxed);
} }
} }
@ -164,20 +164,20 @@ impl AccountsHashVerifier {
fn should_halt( fn should_halt(
cluster_info: &ClusterInfo, cluster_info: &ClusterInfo,
trusted_validators: &Option<HashSet<Pubkey>>, known_validators: &Option<HashSet<Pubkey>>,
slot_to_hash: &mut HashMap<Slot, Hash>, slot_to_hash: &mut HashMap<Slot, Hash>,
) -> bool { ) -> bool {
let mut verified_count = 0; let mut verified_count = 0;
let mut highest_slot = 0; let mut highest_slot = 0;
if let Some(trusted_validators) = trusted_validators.as_ref() { if let Some(known_validators) = known_validators.as_ref() {
for trusted_validator in trusted_validators { for known_validator in known_validators {
let is_conflicting = cluster_info.get_accounts_hash_for_node(trusted_validator, |accounts_hashes| let is_conflicting = cluster_info.get_accounts_hash_for_node(known_validator, |accounts_hashes|
{ {
accounts_hashes.iter().any(|(slot, hash)| { accounts_hashes.iter().any(|(slot, hash)| {
if let Some(reference_hash) = slot_to_hash.get(slot) { if let Some(reference_hash) = slot_to_hash.get(slot) {
if *hash != *reference_hash { if *hash != *reference_hash {
error!("Trusted validator {} produced conflicting hashes for slot: {} ({} != {})", error!("Known validator {} produced conflicting hashes for slot: {} ({} != {})",
trusted_validator, known_validator,
slot, slot,
hash, hash,
reference_hash, reference_hash,
@ -241,11 +241,11 @@ mod tests {
let cluster_info = new_test_cluster_info(contact_info); let cluster_info = new_test_cluster_info(contact_info);
let cluster_info = Arc::new(cluster_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(); let mut slot_to_hash = HashMap::new();
assert!(!AccountsHashVerifier::should_halt( assert!(!AccountsHashVerifier::should_halt(
&cluster_info, &cluster_info,
&Some(trusted_validators.clone()), &Some(known_validators.clone()),
&mut slot_to_hash, &mut slot_to_hash,
)); ));
@ -258,10 +258,10 @@ mod tests {
cluster_info.flush_push_queue(); cluster_info.flush_push_queue();
} }
slot_to_hash.insert(0, hash2); slot_to_hash.insert(0, hash2);
trusted_validators.insert(validator1.pubkey()); known_validators.insert(validator1.pubkey());
assert!(AccountsHashVerifier::should_halt( assert!(AccountsHashVerifier::should_halt(
&cluster_info, &cluster_info,
&Some(trusted_validators), &Some(known_validators),
&mut slot_to_hash, &mut slot_to_hash,
)); ));
} }
@ -277,7 +277,7 @@ mod tests {
let cluster_info = new_test_cluster_info(contact_info); let cluster_info = new_test_cluster_info(contact_info);
let cluster_info = Arc::new(cluster_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 exit = Arc::new(AtomicBool::new(false));
let mut hashes = vec![]; let mut hashes = vec![];
for i in 0..MAX_SNAPSHOT_HASHES + 1 { for i in 0..MAX_SNAPSHOT_HASHES + 1 {
@ -297,7 +297,7 @@ mod tests {
AccountsHashVerifier::process_accounts_package( AccountsHashVerifier::process_accounts_package(
accounts_package, accounts_package,
&cluster_info, &cluster_info,
&Some(trusted_validators.clone()), &Some(known_validators.clone()),
false, false,
&None, &None,
&mut hashes, &mut hashes,

View File

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

View File

@ -83,8 +83,8 @@ pub struct Sockets {
pub struct TvuConfig { pub struct TvuConfig {
pub max_ledger_shreds: Option<u64>, pub max_ledger_shreds: Option<u64>,
pub shred_version: u16, pub shred_version: u16,
pub halt_on_trusted_validators_accounts_hash_mismatch: bool, pub halt_on_known_validators_accounts_hash_mismatch: bool,
pub trusted_validators: Option<HashSet<Pubkey>>, pub known_validators: Option<HashSet<Pubkey>>,
pub repair_validators: Option<HashSet<Pubkey>>, pub repair_validators: Option<HashSet<Pubkey>>,
pub accounts_hash_fault_injection_slots: u64, pub accounts_hash_fault_injection_slots: u64,
pub accounts_db_caching_enabled: bool, pub accounts_db_caching_enabled: bool,
@ -217,8 +217,8 @@ impl Tvu {
pending_snapshot_package, pending_snapshot_package,
exit, exit,
cluster_info, cluster_info,
tvu_config.trusted_validators.clone(), tvu_config.known_validators.clone(),
tvu_config.halt_on_trusted_validators_accounts_hash_mismatch, tvu_config.halt_on_known_validators_accounts_hash_mismatch,
tvu_config.accounts_hash_fault_injection_slots, tvu_config.accounts_hash_fault_injection_slots,
snapshot_interval_slots, snapshot_interval_slots,
); );

View File

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

View File

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

View File

@ -23,11 +23,11 @@ pub fn safe_clone_config(config: &ValidatorConfig) -> ValidatorConfig {
fixed_leader_schedule: config.fixed_leader_schedule.clone(), fixed_leader_schedule: config.fixed_leader_schedule.clone(),
wait_for_supermajority: config.wait_for_supermajority, wait_for_supermajority: config.wait_for_supermajority,
new_hard_forks: config.new_hard_forks.clone(), 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(), repair_validators: config.repair_validators.clone(),
gossip_validators: config.gossip_validators.clone(), gossip_validators: config.gossip_validators.clone(),
halt_on_trusted_validators_accounts_hash_mismatch: config halt_on_known_validators_accounts_hash_mismatch: config
.halt_on_trusted_validators_accounts_hash_mismatch, .halt_on_known_validators_accounts_hash_mismatch,
accounts_hash_fault_injection_slots: config.accounts_hash_fault_injection_slots, accounts_hash_fault_injection_slots: config.accounts_hash_fault_injection_slots,
frozen_accounts: config.frozen_accounts.clone(), frozen_accounts: config.frozen_accounts.clone(),
no_rocksdb_compaction: config.no_rocksdb_compaction, no_rocksdb_compaction: config.no_rocksdb_compaction,

View File

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

View File

@ -2239,7 +2239,7 @@ fn _send_transaction(
Ok(signature.to_string()) 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 { pub mod rpc_minimal {
use super::*; use super::*;
#[rpc] #[rpc]

View File

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

View File

@ -277,7 +277,7 @@ impl JsonRpcService {
genesis_hash: Hash, genesis_hash: Hash,
ledger_path: &Path, ledger_path: &Path,
validator_exit: Arc<RwLock<Exit>>, validator_exit: Arc<RwLock<Exit>>,
trusted_validators: Option<HashSet<Pubkey>>, known_validators: Option<HashSet<Pubkey>>,
override_health_check: Arc<AtomicBool>, override_health_check: Arc<AtomicBool>,
optimistically_confirmed_bank: Arc<RwLock<OptimisticallyConfirmedBank>>, optimistically_confirmed_bank: Arc<RwLock<OptimisticallyConfirmedBank>>,
send_transaction_service_config: send_transaction_service::Config, send_transaction_service_config: send_transaction_service::Config,
@ -291,7 +291,7 @@ impl JsonRpcService {
let health = Arc::new(RpcHealth::new( let health = Arc::new(RpcHealth::new(
cluster_info.clone(), cluster_info.clone(),
trusted_validators, known_validators,
config.health_check_slot_distance, config.health_check_slot_distance,
override_health_check, override_health_check,
)); ));
@ -697,7 +697,7 @@ mod tests {
} }
#[test] #[test]
fn test_health_check_with_no_trusted_validators() { fn test_health_check_with_no_known_validators() {
let rm = RpcRequestMiddleware::new( let rm = RpcRequestMiddleware::new(
PathBuf::from("/"), PathBuf::from("/"),
None, None,
@ -708,7 +708,7 @@ mod tests {
} }
#[test] #[test]
fn test_health_check_with_trusted_validators() { fn test_health_check_with_known_validators() {
let cluster_info = Arc::new(ClusterInfo::new( let cluster_info = Arc::new(ClusterInfo::new(
ContactInfo::default(), ContactInfo::default(),
Arc::new(Keypair::new()), Arc::new(Keypair::new()),
@ -716,7 +716,7 @@ mod tests {
)); ));
let health_check_slot_distance = 123; let health_check_slot_distance = 123;
let override_health_check = Arc::new(AtomicBool::new(false)); 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(), solana_sdk::pubkey::new_rand(),
solana_sdk::pubkey::new_rand(), solana_sdk::pubkey::new_rand(),
@ -724,17 +724,17 @@ mod tests {
let health = Arc::new(RpcHealth::new( let health = Arc::new(RpcHealth::new(
cluster_info.clone(), cluster_info.clone(),
Some(trusted_validators.clone().into_iter().collect()), Some(known_validators.clone().into_iter().collect()),
health_check_slot_distance, health_check_slot_distance,
override_health_check.clone(), override_health_check.clone(),
)); ));
let rm = RpcRequestMiddleware::new(PathBuf::from("/"), None, create_bank_forks(), health); 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"); 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.push_accounts_hashes(vec![(1000, Hash::default()), (900, Hash::default())]);
cluster_info.flush_push_queue(); cluster_info.flush_push_queue();
assert_eq!(rm.health_check(), "unknown"); assert_eq!(rm.health_check(), "unknown");
@ -744,7 +744,7 @@ mod tests {
assert_eq!(rm.health_check(), "ok"); assert_eq!(rm.health_check(), "ok");
override_health_check.store(false, Ordering::Relaxed); 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 cluster_info
.gossip .gossip
.write() .write()
@ -752,7 +752,7 @@ mod tests {
.crds .crds
.insert( .insert(
CrdsValue::new_unsigned(CrdsData::AccountsHashes(SnapshotHash::new( CrdsValue::new_unsigned(CrdsData::AccountsHashes(SnapshotHash::new(
trusted_validators[0], known_validators[0],
vec![ vec![
(1, Hash::default()), (1, Hash::default()),
(1001, Hash::default()), (1001, Hash::default()),
@ -765,7 +765,7 @@ mod tests {
.unwrap(); .unwrap();
assert_eq!(rm.health_check(), "ok"); assert_eq!(rm.health_check(), "ok");
// Node is slightly behind the trusted validators // Node is slightly behind the known validators
cluster_info cluster_info
.gossip .gossip
.write() .write()
@ -773,7 +773,7 @@ mod tests {
.crds .crds
.insert( .insert(
CrdsValue::new_unsigned(CrdsData::AccountsHashes(SnapshotHash::new( CrdsValue::new_unsigned(CrdsData::AccountsHashes(SnapshotHash::new(
trusted_validators[1], known_validators[1],
vec![(1000 + health_check_slot_distance - 1, Hash::default())], vec![(1000 + health_check_slot_distance - 1, Hash::default())],
))), ))),
1, 1,
@ -782,7 +782,7 @@ mod tests {
.unwrap(); .unwrap();
assert_eq!(rm.health_check(), "ok"); assert_eq!(rm.health_check(), "ok");
// Node is far behind the trusted validators // Node is far behind the known validators
cluster_info cluster_info
.gossip .gossip
.write() .write()
@ -790,7 +790,7 @@ mod tests {
.crds .crds
.insert( .insert(
CrdsValue::new_unsigned(CrdsData::AccountsHashes(SnapshotHash::new( CrdsValue::new_unsigned(CrdsData::AccountsHashes(SnapshotHash::new(
trusted_validators[2], known_validators[2],
vec![(1000 + health_check_slot_distance, Hash::default())], vec![(1000 + health_check_slot_distance, Hash::default())],
))), ))),
1, 1,

View File

@ -345,9 +345,9 @@ fn hash_validator(hash: String) -> Result<(), String> {
.map_err(|e| format!("{:?}", e)) .map_err(|e| format!("{:?}", e))
} }
fn is_trusted_validator(id: &Pubkey, trusted_validators: &Option<HashSet<Pubkey>>) -> bool { fn is_known_validator(id: &Pubkey, known_validators: &Option<HashSet<Pubkey>>) -> bool {
if let Some(trusted_validators) = trusted_validators { if let Some(known_validators) = known_validators {
trusted_validators.contains(id) known_validators.contains(id)
} else { } else {
false false
} }
@ -355,12 +355,12 @@ fn is_trusted_validator(id: &Pubkey, trusted_validators: &Option<HashSet<Pubkey>
fn get_trusted_snapshot_hashes( fn get_trusted_snapshot_hashes(
cluster_info: &ClusterInfo, cluster_info: &ClusterInfo,
trusted_validators: &Option<HashSet<Pubkey>>, known_validators: &Option<HashSet<Pubkey>>,
) -> Option<HashSet<(Slot, Hash)>> { ) -> 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(); let mut trusted_snapshot_hashes = HashSet::new();
for trusted_validator in trusted_validators { for known_validator in known_validators {
cluster_info.get_snapshot_hash_for_node(trusted_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); trusted_snapshot_hashes.insert(*snapshot_hash);
} }
@ -468,9 +468,7 @@ fn get_rpc_node(
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_peers_trusted = rpc_peers
.iter() .iter()
.filter(|rpc_peer| { .filter(|rpc_peer| is_known_validator(&rpc_peer.id, &validator_config.known_validators))
is_trusted_validator(&rpc_peer.id, &validator_config.trusted_validators)
})
.count(); .count();
info!( info!(
@ -500,13 +498,13 @@ fn get_rpc_node(
rpc_peers rpc_peers
} else { } else {
let trusted_snapshot_hashes = 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![]; let mut eligible_rpc_peers = vec![];
for rpc_peer in rpc_peers.iter() { for rpc_peer in rpc_peers.iter() {
if no_untrusted_rpc if no_untrusted_rpc
&& !is_trusted_validator(&rpc_peer.id, &validator_config.trusted_validators) && !is_known_validator(&rpc_peer.id, &validator_config.known_validators)
{ {
continue; continue;
} }
@ -945,9 +943,9 @@ fn rpc_bootstrap(
&& download_progress.percentage_done <= 2_f32 && download_progress.percentage_done <= 2_f32
&& download_progress.estimated_remaining_time > 60_f32 && download_progress.estimated_remaining_time > 60_f32
&& download_abort_count < maximum_snapshot_download_abort { && download_abort_count < maximum_snapshot_download_abort {
if let Some(ref trusted_validators) = validator_config.trusted_validators { if let Some(ref known_validators) = validator_config.known_validators {
if trusted_validators.contains(&rpc_contact_info.id) if known_validators.contains(&rpc_contact_info.id)
&& trusted_validators.len() == 1 && known_validators.len() == 1
&& bootstrap_config.no_untrusted_rpc { && bootstrap_config.no_untrusted_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 \
@ -1009,8 +1007,8 @@ fn rpc_bootstrap(
} }
warn!("{}", result.unwrap_err()); warn!("{}", result.unwrap_err());
if let Some(ref trusted_validators) = validator_config.trusted_validators { if let Some(ref known_validators) = validator_config.known_validators {
if trusted_validators.contains(&rpc_contact_info.id) { if known_validators.contains(&rpc_contact_info.id) {
continue; // Never blacklist a trusted node continue; // Never blacklist a trusted node
} }
} }
@ -1520,7 +1518,7 @@ pub fn main() {
.help("Add a hard fork at this slot"), .help("Add a hard fork at this slot"),
) )
.arg( .arg(
Arg::with_name("trusted_validators") Arg::with_name("known_validators")
.alias("trusted-validator") .alias("trusted-validator")
.long("known-validator") .long("known-validator")
.validator(is_pubkey) .validator(is_pubkey)
@ -1777,10 +1775,10 @@ pub fn main() {
.help("Specify the configuration file for the AccountsDb plugin."), .help("Specify the configuration file for the AccountsDb plugin."),
) )
.arg( .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") .alias("halt-on-trusted-validators-accounts-hash-mismatch")
.long("halt-on-known-validators-accounts-hash-mismatch") .long("halt-on-known-validators-accounts-hash-mismatch")
.requires("trusted_validators") .requires("known_validators")
.takes_value(false) .takes_value(false)
.help("Abort the validator if a bank hash mismatch is detected within known validator set"), .help("Abort the validator if a bank hash mismatch is detected within known validator set"),
) )
@ -2297,10 +2295,10 @@ pub fn main() {
None None
}; };
let trusted_validators = validators_set( let known_validators = validators_set(
&identity_keypair.pubkey(), &identity_keypair.pubkey(),
&matches, &matches,
"trusted_validators", "known_validators",
"--known-validator", "--known-validator",
); );
let repair_validators = validators_set( let repair_validators = validators_set(
@ -2452,7 +2450,7 @@ pub fn main() {
}, },
voting_disabled: matches.is_present("no_voting") || restricted_repair_only_mode, voting_disabled: matches.is_present("no_voting") || restricted_repair_only_mode,
wait_for_supermajority: value_t!(matches, "wait_for_supermajority", Slot).ok(), wait_for_supermajority: value_t!(matches, "wait_for_supermajority", Slot).ok(),
trusted_validators, known_validators,
repair_validators, repair_validators,
gossip_validators, gossip_validators,
frozen_accounts: values_t!(matches, "frozen_accounts", Pubkey).unwrap_or_default(), frozen_accounts: values_t!(matches, "frozen_accounts", Pubkey).unwrap_or_default(),
@ -2653,8 +2651,8 @@ pub fn main() {
validator_config.max_ledger_shreds = Some(limit_ledger_size); validator_config.max_ledger_shreds = Some(limit_ledger_size);
} }
if matches.is_present("halt_on_trusted_validators_accounts_hash_mismatch") { if matches.is_present("halt_on_known_validators_accounts_hash_mismatch") {
validator_config.halt_on_trusted_validators_accounts_hash_mismatch = true; validator_config.halt_on_known_validators_accounts_hash_mismatch = true;
} }
let public_rpc_addr = matches.value_of("public_rpc_addr").map(|addr| { let public_rpc_addr = matches.value_of("public_rpc_addr").map(|addr| {