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

Commit

Permalink
fix/chain: Ensure we provide the correct proof for Prefix authority
Browse files Browse the repository at this point in the history
multiple_joining_nodes failed with seed after 1000 iterations:
Some([3916974036, 312593624, 819085280, 2177096903])
panicked at 'Elder(550551..(01)) Untrusted SignedRoutingMessage {
content: RoutingMessage { src: Section(name: c00000..), dst: PrefixSection(prefix: Prefix(0)),
content: NeighbourInfo(EldersInfo(prefix: Prefix(11), ...}, prev_hash_len: 1, version: 16)) },

The problem is we pick the knowledge of the first item in the destination
in this case 00, and so 01 does not have enough info.

Ensure we handle prefix authority correctly by taking as much of the
proof as needed by any section covered by the prefix.

Test:
Verify seed fixed.
Soak test + clippy
  • Loading branch information
Jean-Philippe DUFRAIGNE committed Oct 29, 2019
1 parent 5c7ba72 commit ca6e4cb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/chain/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -736,8 +736,9 @@ impl Chain {
self.state
.their_knowledge
.iter()
.find(|(prefix, _)| prefix.matches(&target.name()))
.filter(|(prefix, _)| target.is_compatible(prefix))
.map(|(_, index)| *index)
.min()
.unwrap_or(0)
}

Expand Down
8 changes: 8 additions & 0 deletions src/routing_table/authority.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@ impl<N: Xorable + Clone + Copy + Binary + Default> Authority<N> {
Authority::PrefixSection(prefix) => prefix.lower_bound(),
}
}

/// Returns if the authority is compatible with that prefix
pub fn is_compatible(&self, other_prefix: &Prefix<N>) -> bool {
match self {
Authority::Section(name) | Authority::Node(name) => other_prefix.matches(name),
Authority::PrefixSection(prefix) => other_prefix.is_compatible(prefix),
}
}
}

impl Authority<XorName> {
Expand Down

0 comments on commit ca6e4cb

Please sign in to comment.