Skip to content

Commit

Permalink
Stop ignoring broadcasted NewViews (#2064)
Browse files Browse the repository at this point in the history
PR #2042 added `NewView` broadcasting, but it didn't change
anything because nodes ignored `NewView`s that were not sent via
a direct request. In fact that PR made network recovery worse,
since the leader would no longer see repeated `NewView`s. This PR
just adds the handler for broadcasted `NewView`s.
  • Loading branch information
JamesHinshelwood authored Dec 22, 2024
1 parent 05fbb80 commit ae64d06
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions zilliqa/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,15 +209,25 @@ impl Node {

pub fn handle_broadcast(&mut self, from: PeerId, message: ExternalMessage) -> Result<()> {
debug!(%from, to = %self.peer_id, %message, "handling broadcast");
// We only expect `NewTransaction`s to be broadcast.
// `Proposals` are re-routed to `handle_request()`.
match message {
// `NewTransaction`s are always broadcasted.
ExternalMessage::NewTransaction(t) => {
// Don't process again txn sent by this node (it's already in the mempool)
if self.peer_id != from {
self.consensus.handle_new_transaction(t)?;
}
}
// Repeated `NewView`s might get broadcast.
ExternalMessage::NewView(m) => {
if let Some((block, transactions)) = self.consensus.new_view(*m)? {
self.message_sender
.broadcast_proposal(ExternalMessage::Proposal(Proposal::from_parts(
block,
transactions,
)))?;
}
}
// `Proposals` are re-routed to `handle_request()`
_ => {
warn!("unexpected message type");
}
Expand Down

0 comments on commit ae64d06

Please sign in to comment.