From a5ea98f973614154541bf8b3762f5a716a701095 Mon Sep 17 00:00:00 2001 From: aljo242 Date: Wed, 15 Nov 2023 17:20:43 -0500 Subject: [PATCH] clean --- consensus/reactor.go | 26 ++++++++++++++++---------- types/vote.go | 2 ++ 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/consensus/reactor.go b/consensus/reactor.go index a3b0ed2631e..6308f19176a 100644 --- a/consensus/reactor.go +++ b/consensus/reactor.go @@ -736,6 +736,12 @@ func (conR *Reactor) gossipVotesRoutine(peer p2p.Peer, ps *PeerState) { // Simple hack to throttle logs upon sleep. sleeping := 0 + consAddrHexBz, err := hex.DecodeString(string(peer.ID())) + if err != nil { + return + } + consAddr := crypto.Address(consAddrHexBz) + OUTER_LOOP: for { @@ -762,23 +768,23 @@ OUTER_LOOP: sleeping = 0 } - consAddrHexBz, err := hex.DecodeString(string(peer.ID())) - if err != nil { - logger.Error("error decoding peer ID", "rs.Height", rs.Height, "prs.Height", prs.Height) - continue OUTER_LOOP + // if the proposer is in our peerlist && proposer is the function peer, send the extensions + // if the proposer is in our peerlist && proposer is not function peer, do not send the extensions + // else if the proposer is not in our peerlist, send extensions to all + sendExtensions := true + proposerPeerID := p2p.PubKeyToID(rs.Validators.Proposer.PubKey) + if conR.Switch.IsPeerUnconditional(proposerPeerID) { + proposer := rs.Validators.Proposer.Address + sendExtensions = bytes.Equal(consAddr, proposer) } - consAddr := crypto.Address(consAddrHexBz) - proposer := rs.Validators.Proposer.Address - isProposer := bytes.Equal(consAddr, proposer) - // logger.Debug("gossipVotesRoutine", "rsHeight", rs.Height, "rsRound", rs.Round, // "prsHeight", prs.Height, "prsRound", prs.Round, "prsStep", prs.Step) // If height matches, then send LastCommit, Prevotes, Precommits. if rs.Height == prs.Height { heightLogger := logger.With("height", prs.Height) - if conR.gossipVotesForHeight(heightLogger, rs, prs, ps, isProposer) { + if conR.gossipVotesForHeight(heightLogger, rs, prs, ps, sendExtensions) { continue OUTER_LOOP } } @@ -872,7 +878,7 @@ func (conR *Reactor) gossipVotesForHeight( } // If there are precommits to send... if prs.Step <= cstypes.RoundStepPrecommitWait && prs.Round != -1 && prs.Round <= rs.Round { - if ps.PickSendVote(rs.Votes.Precommits(prs.Round), isProposer) { + if ps.PickSendVote(rs.Votes.Precommits(prs.Round), true) { logger.Debug("Picked rs.Precommits(prs.Round) to send", "round", prs.Round) return true } diff --git a/types/vote.go b/types/vote.go index 660b538d178..361b171d57e 100644 --- a/types/vote.go +++ b/types/vote.go @@ -252,6 +252,8 @@ func (vote *Vote) VerifyVoteAndExtension(chainID string, pubKey crypto.PubKey) e // VerifyExtension checks whether the vote extension signature corresponds to the // given chain ID and public key. func (vote *Vote) VerifyExtension(chainID string, pubKey crypto.PubKey) error { + return nil + if vote.Type != cmtproto.PrecommitType || vote.BlockID.IsZero() { return nil }