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

Commit

Permalink
fix: bounce DKG message only if node has no ongoing session
Browse files Browse the repository at this point in the history
Previously we would bounce if it had no session with the same key as the message, but this caused explosion of DKGStart messages and eventual failure.
  • Loading branch information
madadam committed Oct 27, 2020
1 parent c19e3c1 commit 350b75d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
9 changes: 3 additions & 6 deletions src/consensus/dkg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -347,12 +347,9 @@ impl DkgVoter {
}
}

// If this node participating in a DKG session with the given key?
pub fn is_participating(&self, dkg_key: &DkgKey) -> bool {
self.participant
.as_ref()
.map(|session| session.dkg_key == *dkg_key)
.unwrap_or(false)
// If this node participating in any DKG session?
pub fn is_participating(&self) -> bool {
self.participant.is_some()
}

pub fn observing_elders_info(&self, dkg_key: &DkgKey) -> Option<&EldersInfo> {
Expand Down
4 changes: 2 additions & 2 deletions src/routing/approved.rs
Original file line number Diff line number Diff line change
Expand Up @@ -421,8 +421,8 @@ impl Approved {
return Ok(MessageStatus::Unknown);
}
}
Variant::DKGMessage { dkg_key, .. } => {
if !self.dkg_voter.is_participating(dkg_key) {
Variant::DKGMessage { .. } => {
if !self.dkg_voter.is_participating() {
return Ok(MessageStatus::Unknown);
}
}
Expand Down
4 changes: 3 additions & 1 deletion tests/bootstrap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,9 @@ async fn test_section_bootstrapping() -> Result<()> {
#[tokio::test]
async fn test_startup_elders() -> Result<()> {
let network_params = NetworkParams::default();
let network_size = 2;
// FIXME: using only 3 nodes for now because with 4 or more the test takes too long (but still
// succeeds). Needs further investigation.
let network_size = 3;
let mut nodes = create_connected_nodes(network_size, network_params).await?;

async fn expect_promote_event(stream: &mut EventStream) {
Expand Down

0 comments on commit 350b75d

Please sign in to comment.