Skip to content

Commit

Permalink
[CLEANUP] - Remove QuorumProposalRequestRecv from Consensus Tasks (#…
Browse files Browse the repository at this point in the history
…3711)

* cleanup

* clippy
  • Loading branch information
lukeiannucci authored Sep 28, 2024
1 parent b8e76a0 commit 651cf63
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 64 deletions.
26 changes: 0 additions & 26 deletions crates/task-impls/src/consensus/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ use async_lock::RwLock;
#[cfg(async_executor_impl = "async-std")]
use async_std::task::JoinHandle;
use async_trait::async_trait;
use committable::Committable;
use futures::future::join_all;
use handlers::publish_proposal_from_commitment_and_metadata;
use hotshot_task::task::TaskState;
Expand Down Expand Up @@ -310,31 +309,6 @@ impl<TYPES: NodeType, I: NodeImplementation<TYPES>, V: Versions> ConsensusTaskSt
warn!("Failed to handle QuorumProposalValidated event {e:#}");
}
}
HotShotEvent::QuorumProposalRequestRecv(req, signature) => {
// Make sure that this request came from who we think it did
if !req.key.validate(signature, req.commit().as_ref()) {
warn!("Invalid signature key on proposal request.");
return;
}

if let Some(quorum_proposal) = self
.consensus
.read()
.await
.last_proposals()
.get(&req.view_number)
{
broadcast_event(
HotShotEvent::QuorumProposalResponseSend(
req.key.clone(),
quorum_proposal.clone(),
)
.into(),
&event_sender,
)
.await;
}
}
HotShotEvent::QuorumVoteRecv(ref vote) => {
debug!("Received quorum vote: {:?}", vote.view_number());
if self.quorum_membership.leader(vote.view_number() + 1) != self.public_key {
Expand Down
28 changes: 1 addition & 27 deletions crates/task-impls/src/consensus2/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ use async_lock::RwLock;
#[cfg(async_executor_impl = "async-std")]
use async_std::task::JoinHandle;
use async_trait::async_trait;
use committable::Committable;
use hotshot_task::task::TaskState;
use hotshot_types::{
consensus::OuterConsensus,
Expand All @@ -32,7 +31,7 @@ use tracing::instrument;
use self::handlers::{
handle_quorum_vote_recv, handle_timeout, handle_timeout_vote_recv, handle_view_change,
};
use crate::{events::HotShotEvent, helpers::broadcast_event, vote_collection::VoteCollectorsMap};
use crate::{events::HotShotEvent, vote_collection::VoteCollectorsMap};

/// Event handlers for use in the `handle` method.
mod handlers;
Expand Down Expand Up @@ -113,31 +112,6 @@ impl<TYPES: NodeType, I: NodeImplementation<TYPES>, V: Versions> Consensus2TaskS
tracing::debug!("Failed to handle QuorumVoteRecv event; error = {e}");
}
}
HotShotEvent::QuorumProposalRequestRecv(req, signature) => {
// Make sure that this request came from who we think it did
if !req.key.validate(signature, req.commit().as_ref()) {
tracing::warn!("Invalid signature key on proposal request.");
return;
}

if let Some(quorum_proposal) = self
.consensus
.read()
.await
.last_proposals()
.get(&req.view_number)
{
broadcast_event(
HotShotEvent::QuorumProposalResponseSend(
req.key.clone(),
quorum_proposal.clone(),
)
.into(),
&sender,
)
.await;
}
}
HotShotEvent::TimeoutVoteRecv(ref vote) => {
if let Err(e) =
handle_timeout_vote_recv(vote, Arc::clone(&event), &sender, self).await
Expand Down
6 changes: 6 additions & 0 deletions crates/task-impls/src/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,11 @@ impl<TYPES: NodeType, I: NodeImplementation<TYPES>> NetworkRequestState<TYPES, I
{
// Cycle da members we send the request to each time
if let Some(recipient) = recipients_it.next() {
if *recipient == public_key {
// no need to send a message to ourselves.
// just check for the data at start of loop in `cancel_vid_request_task`
continue;
}
// If we got the data after we make the request then we are done
if Self::handle_vid_request_task(
&sender,
Expand All @@ -229,6 +234,7 @@ impl<TYPES: NodeType, I: NodeImplementation<TYPES>> NetworkRequestState<TYPES, I
return;
}
} else {
// This shouldnt be possible `recipients_it.next()` should clone original and start over if `None`
tracing::warn!(
"Sent VID request to all available DA members and got no reponse for view: {:?}",
view
Expand Down
25 changes: 14 additions & 11 deletions crates/task-impls/src/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,25 +97,28 @@ impl<TYPES: NodeType> NetworkResponseState<TYPES> {
}
}
HotShotEvent::QuorumProposalRequestRecv(req, signature) => {
// Make sure that this request came from who we think it did
if !req.key.validate(signature, req.commit().as_ref()) {
tracing::warn!("Invalid signature key on proposal request.");
return;
}

if let Some(quorum_proposal) = self
.consensus
.read()
.await
.last_proposals()
.get(&req.view_number)
{
// Make sure that this request came from who we think it did
if req.key.validate(signature, req.commit().as_ref()) {
broadcast_event(
HotShotEvent::QuorumProposalResponseSend(
req.key.clone(),
quorum_proposal.clone(),
)
.into(),
&event_sender,
broadcast_event(
HotShotEvent::QuorumProposalResponseSend(
req.key.clone(),
quorum_proposal.clone(),
)
.await;
}
.into(),
&event_sender,
)
.await;
}
}
HotShotEvent::Shutdown => {
Expand Down

0 comments on commit 651cf63

Please sign in to comment.