Validate the genesis config downloaded over RPC before accepting it (bp #8474) (#8481)

automerge
This commit is contained in:
mergify[bot]
2020-02-26 15:12:06 -08:00
committed by GitHub
parent 60b43e34b6
commit 87cfac12dd
6 changed files with 234 additions and 164 deletions

View File

@@ -43,6 +43,7 @@ use solana_sdk::{
timing::timestamp,
};
use std::{
collections::HashSet,
net::{IpAddr, Ipv4Addr, SocketAddr},
path::{Path, PathBuf},
process,
@@ -72,6 +73,7 @@ pub struct ValidatorConfig {
pub fixed_leader_schedule: Option<FixedSchedule>,
pub wait_for_supermajority: bool,
pub new_hard_forks: Option<Vec<Slot>>,
pub trusted_validators: Option<HashSet<Pubkey>>, // None = trust all
}
impl Default for ValidatorConfig {
@@ -94,6 +96,7 @@ impl Default for ValidatorConfig {
fixed_leader_schedule: None,
wait_for_supermajority: false,
new_hard_forks: None,
trusted_validators: None,
}
}
}
@@ -345,9 +348,7 @@ impl Validator {
}
if let Some(snapshot_hash) = snapshot_hash {
if let Some(ref trusted_validators) =
config.snapshot_config.as_ref().unwrap().trusted_validators
{
if let Some(ref trusted_validators) = config.trusted_validators {
let mut trusted = false;
for _ in 0..10 {
trusted = cluster_info