Skip to content

Commit

Permalink
reduce logging
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverbundalo committed Nov 9, 2024
1 parent 1eaeac0 commit 0548991
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 33 deletions.
15 changes: 0 additions & 15 deletions consensus/polybft/fsm.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,27 +210,12 @@ func (f *fsm) BuildProposal(currentRound uint64) ([]byte, error) {
return nil, fmt.Errorf("failed to calculate proposal hash: %w", err)
}

var buf bytes.Buffer

for i, tx := range stateBlock.Block.Transactions {
if f.logger.IsDebug() {
buf.WriteString(tx.Hash().String())
} else if f.logger.IsTrace() {
buf.WriteString(tx.String())
}

if i != len(stateBlock.Block.Transactions)-1 {
buf.WriteString("\n")
}
}

f.logger.Debug("[FSM.BuildProposal]",
"block num", stateBlock.Block.Number(),
"round", currentRound,
"state root", stateBlock.Block.Header.StateRoot,
"proposal hash", checkpointHash.String(),
"txs count", len(stateBlock.Block.Transactions),
"txs", buf.String(),
"finsihedIn", time.Since(start),
)
}
Expand Down
20 changes: 2 additions & 18 deletions state/executor.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package state

import (
"bytes"
"errors"
"fmt"
"math"
Expand Down Expand Up @@ -168,11 +167,10 @@ func (e *Executor) ProcessBlock(
}

var (
buf bytes.Buffer
logLvl = e.logger.GetLevel()
)

for i, t := range block.Transactions {
for _, t := range block.Transactions {
if t.Gas() > block.Header.GasLimit {
return nil, runtime.ErrOutOfGas
}
Expand All @@ -188,26 +186,12 @@ func (e *Executor) ProcessBlock(

return nil, err
}

if logLvl <= hclog.Debug {
if e.logger.IsTrace() {
_, _ = buf.WriteString(t.String())
}

if e.logger.IsDebug() {
_, _ = buf.WriteString(t.Hash().String())
}

if i != len(block.Transactions)-1 {
_, _ = buf.WriteString("\n")
}
}
}

if logLvl <= hclog.Debug {
var (
logMsg = "[Executor.ProcessBlock] finished."
logArgs = []interface{}{"txs count", len(block.Transactions), "txs", buf.String()}
logArgs = []interface{}{"txs count", len(block.Transactions)}
)

e.logger.Log(logLvl, logMsg, logArgs...)
Expand Down

0 comments on commit 0548991

Please sign in to comment.