From 350b75db30fbdec86e14d48ff4f1740be39ddc00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20Cig=C3=A1nek?= Date: Mon, 26 Oct 2020 11:11:04 +0100 Subject: [PATCH] fix: bounce DKG message only if node has no ongoing session 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. --- src/consensus/dkg.rs | 9 +++------ src/routing/approved.rs | 4 ++-- tests/bootstrap.rs | 4 +++- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/consensus/dkg.rs b/src/consensus/dkg.rs index bf8405548c..4290151154 100644 --- a/src/consensus/dkg.rs +++ b/src/consensus/dkg.rs @@ -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> { diff --git a/src/routing/approved.rs b/src/routing/approved.rs index 484b86aa6f..603d527466 100644 --- a/src/routing/approved.rs +++ b/src/routing/approved.rs @@ -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); } } diff --git a/tests/bootstrap.rs b/tests/bootstrap.rs index b9ae2f3dd8..fe4a77e507 100644 --- a/tests/bootstrap.rs +++ b/tests/bootstrap.rs @@ -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) {