Skip to content

Commit

Permalink
Fix debug log (#205)
Browse files Browse the repository at this point in the history
  • Loading branch information
codchen authored and udpatil committed Feb 28, 2024
1 parent c9e2944 commit b4190aa
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
11 changes: 10 additions & 1 deletion internal/consensus/reactor.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"sync"
"time"

"github.com/tendermint/tendermint/config"
cstypes "github.com/tendermint/tendermint/internal/consensus/types"
"github.com/tendermint/tendermint/internal/eventbus"
"github.com/tendermint/tendermint/internal/p2p"
Expand Down Expand Up @@ -121,6 +122,7 @@ type ConsSyncReactor interface {
type Reactor struct {
service.BaseService
logger log.Logger
cfg *config.Config

state *State
eventBus *eventbus.EventBus
Expand Down Expand Up @@ -148,6 +150,7 @@ func NewReactor(
eventBus *eventbus.EventBus,
waitSync bool,
metrics *Metrics,
cfg *config.Config,
) *Reactor {
r := &Reactor{
logger: logger,
Expand All @@ -160,6 +163,7 @@ func NewReactor(
peerEvents: peerEvents,
readySignal: make(chan struct{}),
channels: &channelBundle{},
cfg: cfg,
}
r.BaseService = *service.NewBaseService(logger, "Consensus", r)

Expand Down Expand Up @@ -646,7 +650,12 @@ func (r *Reactor) pickSendVote(ctx context.Context, ps *PeerState, votes types.V
return false, nil
}

r.logger.Debug("sending vote message", "ps", ps, "vote", vote)
if r.cfg.BaseConfig.LogLevel == log.LogLevelDebug {
psJson, err := ps.ToJSON() // expensive, so we only want to call if debug is on
if err != nil {
r.logger.Debug("sending vote message", "ps", string(psJson), "vote", vote)
}
}
if err := voteCh.Send(ctx, p2p.Envelope{
To: ps.peerID,
Message: &tmcons.Vote{
Expand Down
2 changes: 2 additions & 0 deletions internal/consensus/reactor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ func setup(
state.eventBus,
true,
NopMetrics(),
config.DefaultConfig(),
)

reactor.SetStateChannel(rts.stateChannels[nodeID])
Expand Down Expand Up @@ -697,6 +698,7 @@ func TestSwitchToConsensusVoteExtensions(t *testing.T) {
cs.eventBus,
true,
NopMetrics(),
config.DefaultConfig(),
)

if testCase.shouldPanic {
Expand Down
1 change: 1 addition & 0 deletions node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,7 @@ func makeNode(
eventBus,
waitSync,
nodeMetrics.consensus,
cfg,
)

node.router.AddChDescToBeAdded(consensus.GetStateChannelDescriptor(), csReactor.SetStateChannel)
Expand Down

0 comments on commit b4190aa

Please sign in to comment.