Rename "trusted" to "known" in validators/
(#21197)
* Replaced trusted with known validator * Format Convention
This commit is contained in:
@ -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]
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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,
|
||||
|
Reference in New Issue
Block a user