* 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:
@ -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
|
||||
@ -33,8 +33,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_interval_slots: u64,
|
||||
) -> Self {
|
||||
@ -62,8 +62,8 @@ impl AccountsHashVerifier {
|
||||
Self::process_accounts_package_pre(
|
||||
accounts_package,
|
||||
&cluster_info,
|
||||
&trusted_validators,
|
||||
halt_on_trusted_validators_accounts_hash_mismatch,
|
||||
&known_validators,
|
||||
halt_on_known_validators_accounts_hash_mismatch,
|
||||
&pending_snapshot_package,
|
||||
&mut hashes,
|
||||
&exit,
|
||||
@ -87,8 +87,8 @@ impl AccountsHashVerifier {
|
||||
fn process_accounts_package_pre(
|
||||
accounts_package: AccountsPackagePre,
|
||||
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>,
|
||||
@ -103,8 +103,8 @@ impl AccountsHashVerifier {
|
||||
Self::process_accounts_package(
|
||||
accounts_package,
|
||||
cluster_info,
|
||||
trusted_validators,
|
||||
halt_on_trusted_validator_accounts_hash_mismatch,
|
||||
known_validators,
|
||||
halt_on_known_validator_accounts_hash_mismatch,
|
||||
pending_snapshot_package,
|
||||
hashes,
|
||||
exit,
|
||||
@ -116,8 +116,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>,
|
||||
@ -143,12 +143,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);
|
||||
}
|
||||
}
|
||||
@ -164,20 +164,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.as_ref() {
|
||||
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.as_ref() {
|
||||
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,
|
||||
@ -241,11 +241,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.clone()),
|
||||
&Some(known_validators.clone()),
|
||||
&mut slot_to_hash,
|
||||
));
|
||||
|
||||
@ -258,10 +258,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,
|
||||
));
|
||||
}
|
||||
@ -277,7 +277,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![];
|
||||
for i in 0..MAX_SNAPSHOT_HASHES + 1 {
|
||||
@ -297,7 +297,7 @@ mod tests {
|
||||
AccountsHashVerifier::process_accounts_package(
|
||||
accounts_package,
|
||||
&cluster_info,
|
||||
&Some(trusted_validators.clone()),
|
||||
&Some(known_validators.clone()),
|
||||
false,
|
||||
&None,
|
||||
&mut hashes,
|
||||
|
@ -1046,23 +1046,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,
|
||||
RepairType::Shred(0, 0),
|
||||
&mut LruCache::new(100),
|
||||
&mut RepairStats::default(),
|
||||
&trusted_validators,
|
||||
&known_validators,
|
||||
&mut OutstandingRepairs::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
|
||||
@ -1071,12 +1071,12 @@ mod tests {
|
||||
RepairType::Shred(0, 0),
|
||||
&mut LruCache::new(100),
|
||||
&mut RepairStats::default(),
|
||||
&trusted_validators,
|
||||
&known_validators,
|
||||
&mut OutstandingRepairs::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)
|
||||
|
@ -83,8 +83,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,
|
||||
@ -217,8 +217,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_interval_slots,
|
||||
);
|
||||
|
@ -120,10 +120,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,
|
||||
@ -178,10 +178,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,
|
||||
@ -588,7 +588,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(),
|
||||
@ -789,10 +789,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,
|
||||
|
@ -553,7 +553,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,
|
||||
|
@ -23,11 +23,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,
|
||||
|
@ -1629,15 +1629,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(
|
||||
@ -1901,11 +1901,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,
|
||||
|
@ -2239,7 +2239,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
|
||||
}
|
||||
|
@ -277,7 +277,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,
|
||||
@ -291,7 +291,7 @@ impl JsonRpcService {
|
||||
|
||||
let health = Arc::new(RpcHealth::new(
|
||||
cluster_info.clone(),
|
||||
trusted_validators,
|
||||
known_validators,
|
||||
config.health_check_slot_distance,
|
||||
override_health_check,
|
||||
));
|
||||
@ -697,7 +697,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,
|
||||
@ -708,7 +708,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()),
|
||||
@ -716,7 +716,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(),
|
||||
@ -724,17 +724,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");
|
||||
@ -744,7 +744,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
|
||||
.write()
|
||||
@ -752,7 +752,7 @@ mod tests {
|
||||
.crds
|
||||
.insert(
|
||||
CrdsValue::new_unsigned(CrdsData::AccountsHashes(SnapshotHash::new(
|
||||
trusted_validators[0],
|
||||
known_validators[0],
|
||||
vec![
|
||||
(1, Hash::default()),
|
||||
(1001, Hash::default()),
|
||||
@ -765,7 +765,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
|
||||
.write()
|
||||
@ -773,7 +773,7 @@ mod tests {
|
||||
.crds
|
||||
.insert(
|
||||
CrdsValue::new_unsigned(CrdsData::AccountsHashes(SnapshotHash::new(
|
||||
trusted_validators[1],
|
||||
known_validators[1],
|
||||
vec![(1000 + health_check_slot_distance - 1, Hash::default())],
|
||||
))),
|
||||
1,
|
||||
@ -782,7 +782,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
|
||||
.write()
|
||||
@ -790,7 +790,7 @@ mod tests {
|
||||
.crds
|
||||
.insert(
|
||||
CrdsValue::new_unsigned(CrdsData::AccountsHashes(SnapshotHash::new(
|
||||
trusted_validators[2],
|
||||
known_validators[2],
|
||||
vec![(1000 + health_check_slot_distance, Hash::default())],
|
||||
))),
|
||||
1,
|
||||
|
@ -345,9 +345,9 @@ fn hash_validator(hash: String) -> Result<(), String> {
|
||||
.map_err(|e| format!("{:?}", e))
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
@ -355,12 +355,12 @@ fn is_trusted_validator(id: &Pubkey, trusted_validators: &Option<HashSet<Pubkey>
|
||||
|
||||
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);
|
||||
}
|
||||
@ -468,9 +468,7 @@ fn get_rpc_node(
|
||||
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!(
|
||||
@ -500,13 +498,13 @@ fn get_rpc_node(
|
||||
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 no_untrusted_rpc
|
||||
&& !is_trusted_validator(&rpc_peer.id, &validator_config.trusted_validators)
|
||||
&& !is_known_validator(&rpc_peer.id, &validator_config.known_validators)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -945,9 +943,9 @@ fn rpc_bootstrap(
|
||||
&& 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 \
|
||||
@ -1009,8 +1007,8 @@ fn rpc_bootstrap(
|
||||
}
|
||||
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
|
||||
}
|
||||
}
|
||||
@ -1520,7 +1518,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)
|
||||
@ -1777,10 +1775,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"),
|
||||
)
|
||||
@ -2297,10 +2295,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(
|
||||
@ -2452,7 +2450,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(),
|
||||
@ -2653,8 +2651,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| {
|
||||
|
Reference in New Issue
Block a user