encapsulates purged values bookkeeping into crds module (#17265)

For all code paths (gossip push, pull, purge, etc) that remove or
override a crds value, it is necessary to record hash of values purged
from crds table, in order to exclude them from subsequent pull-requests;
otherwise the next pull request will likely return outdated values,
wasting bandwidth:
https://github.com/solana-labs/solana/blob/ed51cde37/core/src/crds_gossip_pull.rs#L486-L491

Currently this is done all over the place in multiple modules, and this
has caused bugs in the past where purged values were not recorded.

This commit encapsulated this bookkeeping into crds module, so that any
code path which removes or overrides a crds value, also records the hash
of purged value in-place.
This commit is contained in:
behzad nouri
2021-05-24 13:47:21 +00:00
committed by GitHub
parent 060332c704
commit 9d112cf41f
10 changed files with 175 additions and 230 deletions

View File

@ -351,17 +351,14 @@ fn network_run_push(
for (to, msgs) in push_messages {
bytes += serialized_size(&msgs).unwrap() as usize;
num_msgs += 1;
let updated = network
let origins: HashSet<_> = network
.get(&to)
.map(|node| {
node.lock()
.unwrap()
.process_push_message(&from, msgs.clone(), now)
})
.unwrap();
let origins: HashSet<_> =
updated.into_iter().map(|u| u.value.pubkey()).collect();
.unwrap()
.lock()
.unwrap()
.process_push_message(&from, msgs.clone(), now)
.into_iter()
.collect();
let prunes_map = network
.get(&to)
.map(|node| node.lock().unwrap().prune_received_cache(origins, &stakes))