Skip to content

Proper threshold support #95

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft

Conversation

fjarri
Copy link
Member

@fjarri fjarri commented Feb 20, 2025

Fixes #11

Done:

  • introduced quorum concept in the API, using it for normal rounds

TODO:

  • a method of IdSet that would tell us if quorum can never be reached given the already banned nodes
  • don't expect messages from a node if it was already banned in the previous round
  • support threshold in the echo round, and figure out what CommunicationInfo should be like for that
  • generalize IdSet to be a trait, allowing users to specify their own quorum conditions?
  • depending on how the echo round is handled, may be able to close Decouple protocol and session levels #25?

@coveralls
Copy link

coveralls commented Feb 20, 2025

Pull Request Test Coverage Report for Build 13447280574

Details

  • 196 of 268 (73.13%) changed or added relevant lines in 10 files are covered.
  • 10 unchanged lines in 3 files lost coverage.
  • Overall coverage decreased (-0.8%) to 72.643%

Changes Missing Coverage Covered Lines Changed/Added Lines %
manul/src/combinators/misbehave.rs 23 25 92.0%
manul/src/protocol/round.rs 32 34 94.12%
manul/src/session/session.rs 44 53 83.02%
manul/src/combinators/chain.rs 33 45 73.33%
manul/src/protocol/boxed_round.rs 24 38 63.16%
manul/src/session/evidence.rs 8 23 34.78%
manul/src/session/echo.rs 7 25 28.0%
Files with Coverage Reduction New Missed Lines %
manul/src/session/evidence.rs 1 53.75%
manul/src/protocol/errors.rs 3 16.09%
manul/src/session/session.rs 6 77.52%
Totals Coverage Status
Change from base Build 13401865846: -0.8%
Covered Lines: 2196
Relevant Lines: 3023

💛 - Coveralls

Copy link
Contributor

@dvdplm dvdplm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a few comments and suggestions even though it's a draft.

description,
evidence: EvidenceEnum::InvalidEchoPack(InvalidEchoPackEvidence {
normal_broadcast,
invalid_echo_sender: from,
invalid_echo_sender: failed_for,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this be renamed to echo_sender you think? To me "failed for" is a bit ambiguous: "failed for who? for this node?".

.cloned()
.collect::<BTreeSet<_>>();

let round_sends_echo_broadcast = !echo_broadcast.payload().is_none();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add a is_some to complement is_none?

Suggested change
let round_sends_echo_broadcast = !echo_broadcast.payload().is_none();
let round_sends_echo_broadcast = echo_broadcast.payload().is_some();

Comment on lines +167 to +169
let mut banned = self.provable_errors.keys().cloned().collect::<BTreeSet<_>>();
banned.extend(self.unprovable_errors.keys().cloned());
banned
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question for my education: Is it possible for a party to be present in both the provable and unprovable sets?

Also, this could perhaps be written as

        self.provable_errors
            .keys()
            .chain(self.unprovable_errors.keys())
            .cloned()
            .collect()

Not sure which is more readable tbh.


pub(crate) fn is_quorum(&self, ids: &BTreeSet<Id>) -> bool {
// TODO: assuming `ids` are a subset of `self.ids`. Can we?
ids.len() >= self.threshold
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worth making sure I think: ids.is_subset(&self.ids) && ids.len() >= self.threshold

Comment on lines +55 to +56
let ids = self.ids.intersection(banned_ids).collect::<BTreeSet<_>>();
self.ids.len() - ids.len() >= self.threshold
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this work here?

        let intersection_count = self.ids.intersection(banned_ids).count();
        self.ids.len() - intersection_count >= self.threshold

pub echo_round: EchoRoundCommunicationInfo<Id>,
}

/// Describes what other parties this rounds sends messages to, and what other parties it expects messages from.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// Describes what other parties this rounds sends messages to, and what other parties it expects messages from.
/// Describes which other parties this rounds sends messages to, and which other parties it expects messages from.


/// The specific way the node participates in the echo round following this round.
///
/// `None` means that, if there is an echo round, the message destinations and expected messages senders
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Writing None here is a bit confusing given it's not an Option. Maybe reword this as "An enum describing the way the node participates in the echo round following this round. It can take one of three values, None, SameAsMainRound and Custom, where None means that, if there is an echo round, the message destinations and … …."? (Although: what does SameAsMainRound even mean then?)

}
}

/// Encapsulates the communication info for the main round and the possible echo round.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it'd be better to beef up this doc comment and thin out the lower-level ones a bit, so that the doc reader can learn about the CommunicationInfo struct's purpose and usage in one spot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Decouple protocol and session levels Support for nodes dropping out during the protocol
3 participants