Skip to content
This repository has been archived by the owner on Jun 25, 2021. It is now read-only.

Commit

Permalink
fix: Remove old compatible neighbour pfx not restricted to a strict p…
Browse files Browse the repository at this point in the history
…arent/child prefix in Chain on updating neighbour_infos. (#1579)

tmp: Send ParsecPoke to all section members to prevent connection timeouts triggering invalid Offline votes while JoiningNode is getting established. This prevents invalid test failures with unaccumulated Parsec::Remove blocks.
  • Loading branch information
Viv Rajkumar committed Apr 4, 2019
1 parent 19ddd5b commit 6d23fa3
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 22 deletions.
19 changes: 6 additions & 13 deletions src/chain/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -948,23 +948,16 @@ impl Chain {
return Some(*pfx);
}

let is_newer =
|other: &NeighbourSigs| other.sec_info().version() > nsigs.sec_info().version();
// Remove older compatible neighbour prefixes.
let is_newer = |(other_pfx, other_sigs): (&Prefix<XorName>, &NeighbourSigs)| {
other_pfx.is_compatible(pfx)
&& other_sigs.sec_info().version() > nsigs.sec_info().version()
};

// Check if we have a newer version of parent pfx.
let ppfx = pfx.popped();
if self.neighbour_infos.get(&ppfx).map_or(false, &is_newer) {
if self.neighbour_infos.iter().any(is_newer) {
return Some(*pfx);
}

// Check if we have a newer version of either child pfx.
let pfx0 = pfx.pushed(false);
let pfx1 = pfx.pushed(true);
if self.neighbour_infos.get(&pfx0).map_or(false, &is_newer)
|| self.neighbour_infos.get(&pfx1).map_or(false, &is_newer)
{
return Some(*pfx);
}
None
})
.collect();
Expand Down
29 changes: 20 additions & 9 deletions src/states/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2763,11 +2763,21 @@ impl Node {
}
}

// Sends a `ParsecPoke` message to trigger a gossip request from current section members to us.
//
// TODO: Should restrict targets to few(counter churn-threshold)/single.
// Currently this can result in incoming spam of gossip history from everyone.
// Can also just be a single target once node-ageing makes Offline votes Opaque which should
// remove invalid test failures for unaccumulated parsec::Remove blocks.
fn send_parsec_poke(&mut self) {
let (version, recipient) = if let Some(gen_pfx_info) = self.gen_pfx_info.as_ref() {
let recipients = gen_pfx_info.latest_info.members().iter().collect_vec();
let index = utils::rand_index(recipients.len());
(*gen_pfx_info.our_info.version(), *recipients[index])
let (version, recipients) = if let Some(gen_pfx_info) = self.gen_pfx_info.as_ref() {
let recipients = gen_pfx_info
.latest_info
.members()
.iter()
.cloned()
.collect_vec();
(*gen_pfx_info.our_info.version(), recipients)
} else {
log_or_panic!(
LogLevel::Error,
Expand All @@ -2776,11 +2786,12 @@ impl Node {
);
return;
};

self.send_message(
&recipient,
Message::Direct(DirectMessage::ParsecPoke(version)),
)
for recipient in recipients {
self.send_message(
&recipient,
Message::Direct(DirectMessage::ParsecPoke(version)),
);
}
}

// Drop peers to which we think we have a connection, but where Crust reports
Expand Down

0 comments on commit 6d23fa3

Please sign in to comment.