Add --trusted-validator support for snapshot hash validation (#8390)

This commit is contained in:
sakridge
2020-02-21 18:42:24 -08:00
committed by GitHub
parent 223f9707ca
commit b7386f9d84
8 changed files with 135 additions and 32 deletions

View File

@ -344,8 +344,36 @@ impl Validator {
.set_entrypoint(entrypoint_info.clone());
}
// If the node was loaded from a snapshot, advertise it in gossip
if let Some(snapshot_hash) = snapshot_hash {
if let Some(ref trusted_validators) =
config.snapshot_config.as_ref().unwrap().trusted_validators
{
let mut trusted = false;
for _ in 0..10 {
trusted = cluster_info
.read()
.unwrap()
.get_snapshot_hash(snapshot_hash.0)
.iter()
.any(|(pubkey, hash)| {
trusted_validators.contains(pubkey) && snapshot_hash.1 == *hash
});
if trusted {
break;
}
sleep(Duration::from_secs(1));
}
if !trusted {
error!(
"The snapshot hash for slot {} is not published by your trusted validators: {:?}",
snapshot_hash.0, trusted_validators
);
process::exit(1);
}
}
// If the node was loaded from a snapshot, advertise it in gossip
cluster_info
.write()
.unwrap()