mirror of
https://github.com/fluencelabs/tendermint
synced 2025-04-26 23:32:15 +00:00
consensus: better logging
This commit is contained in:
parent
5888ddaab1
commit
612726d9f6
@ -388,7 +388,6 @@ OUTER_LOOP:
|
|||||||
|
|
||||||
// Send proposal Block parts?
|
// Send proposal Block parts?
|
||||||
if rs.ProposalBlockParts.HasHeader(prs.ProposalBlockPartsHeader) {
|
if rs.ProposalBlockParts.HasHeader(prs.ProposalBlockPartsHeader) {
|
||||||
//logger.Info("ProposalBlockParts matched", "blockParts", prs.ProposalBlockParts)
|
|
||||||
if index, ok := rs.ProposalBlockParts.BitArray().Sub(prs.ProposalBlockParts.Copy()).PickRandom(); ok {
|
if index, ok := rs.ProposalBlockParts.BitArray().Sub(prs.ProposalBlockParts.Copy()).PickRandom(); ok {
|
||||||
part := rs.ProposalBlockParts.GetPart(index)
|
part := rs.ProposalBlockParts.GetPart(index)
|
||||||
msg := &BlockPartMessage{
|
msg := &BlockPartMessage{
|
||||||
@ -396,6 +395,7 @@ OUTER_LOOP:
|
|||||||
Round: rs.Round, // This tells peer that this part applies to us.
|
Round: rs.Round, // This tells peer that this part applies to us.
|
||||||
Part: part,
|
Part: part,
|
||||||
}
|
}
|
||||||
|
logger.Debug("Sending block part", "height", prs.Height, "round", prs.Round)
|
||||||
if peer.Send(DataChannel, struct{ ConsensusMessage }{msg}) {
|
if peer.Send(DataChannel, struct{ ConsensusMessage }{msg}) {
|
||||||
ps.SetHasProposalBlockPart(prs.Height, prs.Round, index)
|
ps.SetHasProposalBlockPart(prs.Height, prs.Round, index)
|
||||||
}
|
}
|
||||||
@ -405,7 +405,6 @@ OUTER_LOOP:
|
|||||||
|
|
||||||
// If the peer is on a previous height, help catch up.
|
// If the peer is on a previous height, help catch up.
|
||||||
if (0 < prs.Height) && (prs.Height < rs.Height) {
|
if (0 < prs.Height) && (prs.Height < rs.Height) {
|
||||||
//logger.Info("Data catchup", "height", rs.Height, "peerHeight", prs.Height, "peerProposalBlockParts", prs.ProposalBlockParts)
|
|
||||||
if index, ok := prs.ProposalBlockParts.Not().PickRandom(); ok {
|
if index, ok := prs.ProposalBlockParts.Not().PickRandom(); ok {
|
||||||
// Ensure that the peer's PartSetHeader is correct
|
// Ensure that the peer's PartSetHeader is correct
|
||||||
blockMeta := conR.conS.blockStore.LoadBlockMeta(prs.Height)
|
blockMeta := conR.conS.blockStore.LoadBlockMeta(prs.Height)
|
||||||
@ -433,6 +432,7 @@ OUTER_LOOP:
|
|||||||
Round: prs.Round, // Not our height, so it doesn't matter.
|
Round: prs.Round, // Not our height, so it doesn't matter.
|
||||||
Part: part,
|
Part: part,
|
||||||
}
|
}
|
||||||
|
logger.Debug("Sending block part for catchup", "height", prs.Height, "round", prs.Round)
|
||||||
if peer.Send(DataChannel, struct{ ConsensusMessage }{msg}) {
|
if peer.Send(DataChannel, struct{ ConsensusMessage }{msg}) {
|
||||||
ps.SetHasProposalBlockPart(prs.Height, prs.Round, index)
|
ps.SetHasProposalBlockPart(prs.Height, prs.Round, index)
|
||||||
}
|
}
|
||||||
@ -461,6 +461,7 @@ OUTER_LOOP:
|
|||||||
// Proposal: share the proposal metadata with peer.
|
// Proposal: share the proposal metadata with peer.
|
||||||
{
|
{
|
||||||
msg := &ProposalMessage{Proposal: rs.Proposal}
|
msg := &ProposalMessage{Proposal: rs.Proposal}
|
||||||
|
logger.Debug("Sending proposal", "height", prs.Height, "round", prs.Round)
|
||||||
if peer.Send(DataChannel, struct{ ConsensusMessage }{msg}) {
|
if peer.Send(DataChannel, struct{ ConsensusMessage }{msg}) {
|
||||||
ps.SetHasProposal(rs.Proposal)
|
ps.SetHasProposal(rs.Proposal)
|
||||||
}
|
}
|
||||||
@ -475,6 +476,7 @@ OUTER_LOOP:
|
|||||||
ProposalPOLRound: rs.Proposal.POLRound,
|
ProposalPOLRound: rs.Proposal.POLRound,
|
||||||
ProposalPOL: rs.Votes.Prevotes(rs.Proposal.POLRound).BitArray(),
|
ProposalPOL: rs.Votes.Prevotes(rs.Proposal.POLRound).BitArray(),
|
||||||
}
|
}
|
||||||
|
logger.Debug("Sending POL", "height", prs.Height, "round", prs.Round)
|
||||||
peer.Send(DataChannel, struct{ ConsensusMessage }{msg})
|
peer.Send(DataChannel, struct{ ConsensusMessage }{msg})
|
||||||
}
|
}
|
||||||
continue OUTER_LOOP
|
continue OUTER_LOOP
|
||||||
@ -517,21 +519,21 @@ OUTER_LOOP:
|
|||||||
// If there are lastCommits to send...
|
// If there are lastCommits to send...
|
||||||
if prs.Step == RoundStepNewHeight {
|
if prs.Step == RoundStepNewHeight {
|
||||||
if ps.PickSendVote(rs.LastCommit) {
|
if ps.PickSendVote(rs.LastCommit) {
|
||||||
logger.Debug("Picked rs.LastCommit to send")
|
logger.Debug("Picked rs.LastCommit to send", "height", prs.Height)
|
||||||
continue OUTER_LOOP
|
continue OUTER_LOOP
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// If there are prevotes to send...
|
// If there are prevotes to send...
|
||||||
if prs.Step <= RoundStepPrevote && prs.Round != -1 && prs.Round <= rs.Round {
|
if prs.Step <= RoundStepPrevote && prs.Round != -1 && prs.Round <= rs.Round {
|
||||||
if ps.PickSendVote(rs.Votes.Prevotes(prs.Round)) {
|
if ps.PickSendVote(rs.Votes.Prevotes(prs.Round)) {
|
||||||
logger.Debug("Picked rs.Prevotes(prs.Round) to send")
|
logger.Debug("Picked rs.Prevotes(prs.Round) to send", "height", prs.Height, "round", prs.Round)
|
||||||
continue OUTER_LOOP
|
continue OUTER_LOOP
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// If there are precommits to send...
|
// If there are precommits to send...
|
||||||
if prs.Step <= RoundStepPrecommit && prs.Round != -1 && prs.Round <= rs.Round {
|
if prs.Step <= RoundStepPrecommit && prs.Round != -1 && prs.Round <= rs.Round {
|
||||||
if ps.PickSendVote(rs.Votes.Precommits(prs.Round)) {
|
if ps.PickSendVote(rs.Votes.Precommits(prs.Round)) {
|
||||||
logger.Debug("Picked rs.Precommits(prs.Round) to send")
|
logger.Debug("Picked rs.Precommits(prs.Round) to send", "height", prs.Height, "round", prs.Round)
|
||||||
continue OUTER_LOOP
|
continue OUTER_LOOP
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -539,7 +541,7 @@ OUTER_LOOP:
|
|||||||
if prs.ProposalPOLRound != -1 {
|
if prs.ProposalPOLRound != -1 {
|
||||||
if polPrevotes := rs.Votes.Prevotes(prs.ProposalPOLRound); polPrevotes != nil {
|
if polPrevotes := rs.Votes.Prevotes(prs.ProposalPOLRound); polPrevotes != nil {
|
||||||
if ps.PickSendVote(polPrevotes) {
|
if ps.PickSendVote(polPrevotes) {
|
||||||
logger.Debug("Picked rs.Prevotes(prs.ProposalPOLRound) to send")
|
logger.Debug("Picked rs.Prevotes(prs.ProposalPOLRound) to send", "height", prs.Height, "round", prs.ProposalPOLRound)
|
||||||
continue OUTER_LOOP
|
continue OUTER_LOOP
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -550,7 +552,7 @@ OUTER_LOOP:
|
|||||||
// If peer is lagging by height 1, send LastCommit.
|
// If peer is lagging by height 1, send LastCommit.
|
||||||
if prs.Height != 0 && rs.Height == prs.Height+1 {
|
if prs.Height != 0 && rs.Height == prs.Height+1 {
|
||||||
if ps.PickSendVote(rs.LastCommit) {
|
if ps.PickSendVote(rs.LastCommit) {
|
||||||
logger.Debug("Picked rs.LastCommit to send")
|
logger.Debug("Picked rs.LastCommit to send", "height", prs.Height)
|
||||||
continue OUTER_LOOP
|
continue OUTER_LOOP
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -563,7 +565,7 @@ OUTER_LOOP:
|
|||||||
commit := conR.conS.blockStore.LoadBlockCommit(prs.Height)
|
commit := conR.conS.blockStore.LoadBlockCommit(prs.Height)
|
||||||
logger.Info("Loaded BlockCommit for catch-up", "height", prs.Height, "commit", commit)
|
logger.Info("Loaded BlockCommit for catch-up", "height", prs.Height, "commit", commit)
|
||||||
if ps.PickSendVote(commit) {
|
if ps.PickSendVote(commit) {
|
||||||
logger.Debug("Picked Catchup commit to send")
|
logger.Debug("Picked Catchup commit to send", "height", prs.Height)
|
||||||
continue OUTER_LOOP
|
continue OUTER_LOOP
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -571,7 +573,7 @@ OUTER_LOOP:
|
|||||||
if sleeping == 0 {
|
if sleeping == 0 {
|
||||||
// We sent nothing. Sleep...
|
// We sent nothing. Sleep...
|
||||||
sleeping = 1
|
sleeping = 1
|
||||||
logger.Debug("No votes to send, sleeping",
|
logger.Debug("No votes to send, sleeping", "rs.Height", rs.Height, "prs.Height", prs.Height,
|
||||||
"localPV", rs.Votes.Prevotes(rs.Round).BitArray(), "peerPV", prs.Prevotes,
|
"localPV", rs.Votes.Prevotes(rs.Round).BitArray(), "peerPV", prs.Prevotes,
|
||||||
"localPC", rs.Votes.Precommits(rs.Round).BitArray(), "peerPC", prs.Precommits)
|
"localPC", rs.Votes.Precommits(rs.Round).BitArray(), "peerPC", prs.Precommits)
|
||||||
} else if sleeping == 2 {
|
} else if sleeping == 2 {
|
||||||
|
@ -912,16 +912,17 @@ func (cs *ConsensusState) enterPrevote(height int, round int) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (cs *ConsensusState) defaultDoPrevote(height int, round int) {
|
func (cs *ConsensusState) defaultDoPrevote(height int, round int) {
|
||||||
|
logger := cs.Logger.With("height", height, "round", round)
|
||||||
// If a block is locked, prevote that.
|
// If a block is locked, prevote that.
|
||||||
if cs.LockedBlock != nil {
|
if cs.LockedBlock != nil {
|
||||||
cs.Logger.Info("enterPrevote: Block was locked")
|
logger.Info("enterPrevote: Block was locked")
|
||||||
cs.signAddVote(types.VoteTypePrevote, cs.LockedBlock.Hash(), cs.LockedBlockParts.Header())
|
cs.signAddVote(types.VoteTypePrevote, cs.LockedBlock.Hash(), cs.LockedBlockParts.Header())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// If ProposalBlock is nil, prevote nil.
|
// If ProposalBlock is nil, prevote nil.
|
||||||
if cs.ProposalBlock == nil {
|
if cs.ProposalBlock == nil {
|
||||||
cs.Logger.Info("enterPrevote: ProposalBlock is nil")
|
logger.Info("enterPrevote: ProposalBlock is nil")
|
||||||
cs.signAddVote(types.VoteTypePrevote, nil, types.PartSetHeader{})
|
cs.signAddVote(types.VoteTypePrevote, nil, types.PartSetHeader{})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -930,7 +931,7 @@ func (cs *ConsensusState) defaultDoPrevote(height int, round int) {
|
|||||||
err := cs.state.ValidateBlock(cs.ProposalBlock)
|
err := cs.state.ValidateBlock(cs.ProposalBlock)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// ProposalBlock is invalid, prevote nil.
|
// ProposalBlock is invalid, prevote nil.
|
||||||
cs.Logger.Error("enterPrevote: ProposalBlock is invalid", "err", err)
|
logger.Error("enterPrevote: ProposalBlock is invalid", "err", err)
|
||||||
cs.signAddVote(types.VoteTypePrevote, nil, types.PartSetHeader{})
|
cs.signAddVote(types.VoteTypePrevote, nil, types.PartSetHeader{})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user