From 623f51929d4e51793fa318199e2499759a247f24 Mon Sep 17 00:00:00 2001 From: charithabandi Date: Thu, 27 Feb 2025 13:59:39 -0600 Subject: [PATCH] minor logging updates --- node/block.go | 2 +- node/block_processor/processor.go | 6 +++--- node/consensus.go | 2 +- node/consensus/block.go | 2 +- node/consensus/follower.go | 2 +- node/consensus/leader.go | 9 ++++++--- 6 files changed, 13 insertions(+), 10 deletions(-) diff --git a/node/block.go b/node/block.go index c59542381..deb81f821 100644 --- a/node/block.go +++ b/node/block.go @@ -118,7 +118,7 @@ func (n *Node) blkAnnStreamHandler(s network.Stream) { peerID := s.Conn().RemotePeer() n.log.Info("Accept commit?", "height", height, "blockID", blkid, "appHash", ci.AppHash, - "from_peer", peers.PeerIDStringer(peerID)) + "from_peer", peers.PeerIDStringer(peerID)) // maybe debug level // If we are a validator and this is the commit ann for a proposed block // that we already started executing, consensus engine will handle it. diff --git a/node/block_processor/processor.go b/node/block_processor/processor.go index b7b0f5d6b..6a5b54982 100644 --- a/node/block_processor/processor.go +++ b/node/block_processor/processor.go @@ -738,9 +738,9 @@ func (bp *BlockProcessor) nextAppHash(sh stateHashes) types.Hash { hasher.Write(sh.paramUpdates[:]) bp.log.Info("AppState updates: ", - "prevAppHash", sh.prevApp, "changesetsHash", sh.changeset, - "valUpdatesHash", sh.valUpdates, "accountsHash", sh.accounts, - "txResultsHash", sh.txResults, "paramUpdatesHash", sh.paramUpdates) + "prevAppHash", sh.prevApp[:8], "changesets", sh.changeset[:8], + "validatorset", sh.valUpdates[:8], "accounts", sh.accounts[:8], + "txResults", sh.txResults[:8], "params", sh.paramUpdates[:8]) return hasher.Sum(nil) } diff --git a/node/consensus.go b/node/consensus.go index 9d9f5ec8d..dd3c8773c 100644 --- a/node/consensus.go +++ b/node/consensus.go @@ -235,7 +235,7 @@ func (n *Node) blkPropStreamHandler(s network.Stream) { from := s.Conn().RemotePeer() n.log.Info("Accept proposal?", "height", height, "blockID", prop.Hash, "prevHash", prop.PrevHash, - "from_peer", peers.PeerIDStringer(from)) + "from_peer", peers.PeerIDStringer(from)) // maybe debug level? if !n.ce.AcceptProposal(height, prop.Hash, prop.PrevHash, prop.LeaderSig, prop.Stamp) { // NOTE: if this is ahead of our last commit height, we have to try to catch up diff --git a/node/consensus/block.go b/node/consensus/block.go index ef2a44da4..f46e1231f 100644 --- a/node/consensus/block.go +++ b/node/consensus/block.go @@ -269,7 +269,7 @@ func (ce *ConsensusEngine) executeBlock(ctx context.Context, blkProp *blockPropo // reset the catchup timer as we have successfully processed a new block proposal ce.catchupTicker.Reset(ce.catchupTimeout) - ce.log.Info("Executed block", "height", blkProp.height, "blockID", blkProp.blkHash, "numTxs", blkProp.blk.Header.NumTxns, "appHash", results.AppHash.String()) + ce.log.Info("Executed block", "height", blkProp.height, "blockID", blkProp.blkHash, "appHash", results.AppHash.String(), "numTxs", blkProp.blk.Header.NumTxns) return nil } diff --git a/node/consensus/follower.go b/node/consensus/follower.go index 6c4528218..cec84e25c 100644 --- a/node/consensus/follower.go +++ b/node/consensus/follower.go @@ -221,7 +221,7 @@ func (ce *ConsensusEngine) processBlockProposal(ctx context.Context, blkPropMsg } } - ce.log.Info("Processing block proposal", "height", blkPropMsg.blk.Header.Height, "header", blkPropMsg.blk.Header) + ce.log.Debug("Processing block proposal", "height", blkPropMsg.blk.Header.Height, "blkID", blkPropMsg.blkHash, "numTxs", blkPropMsg.blk.Header.NumTxns) if err := ce.validateBlock(blkPropMsg.blk); err != nil { sig, err := types.SignVote(blkPropMsg.blkHash, false, nil, ce.privKey) diff --git a/node/consensus/leader.go b/node/consensus/leader.go index 5892e9b4f..69f0f024a 100644 --- a/node/consensus/leader.go +++ b/node/consensus/leader.go @@ -119,7 +119,7 @@ func (ce *ConsensusEngine) proposeBlock(ctx context.Context) error { return fmt.Errorf("error creating block proposal: %w", err) } - ce.log.Info("Created a new block proposal", "height", blkProp.height, "hash", blkProp.blkHash) + ce.log.Info("Created block proposal", "height", blkProp.height, "hash", blkProp.blkHash) // Validate the block proposal before announcing it to the network if err := ce.validateBlock(blkProp.blk); err != nil { @@ -204,6 +204,10 @@ func (ce *ConsensusEngine) proposeBlock(ctx context.Context) error { // We may be ready to commit if we're the only validator. ce.processVotes(ctx) + if len(ce.validatorSet) > 1 { // or can check if the proposal is committed: ce.blkProp == nil + ce.log.Info("Waiting for votes from the validators", "height", blkProp.height, "hash", blkProp.blkHash) + } + return nil } @@ -408,7 +412,6 @@ func (ce *ConsensusEngine) processVotes(ctx context.Context) { if !ce.hasMajorityCeil(acks) { // No majority yet, wait for more votes - ce.log.Info("Waiting for votes from the validators", "height", blkProp.height, "hash", blkProp.blkHash) return } @@ -446,7 +449,7 @@ func (ce *ConsensusEngine) processVotes(ctx context.Context) { return } - ce.log.Infoln("Announce committed block", blkProp.blk.Header.Height, blkProp.blkHash, blkRes.paramUpdates) + ce.log.Debugln("Announce committed block", blkProp.blk.Header.Height, blkProp.blkHash, blkRes.paramUpdates) // Broadcast the blockAnn message go ce.blkAnnouncer(ctx, blkProp.blk, ce.state.lc.commitInfo)