Skip to content

Commit 60ade09

Browse files
authored
Merge pull request #114 from EspressoSystems/jh/log
Clean the log with the log helper
2 parents 1e0c9b1 + b58b8dd commit 60ade09

File tree

3 files changed

+36
-4
lines changed

3 files changed

+36
-4
lines changed

Diff for: arbos/log_helper.go

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package arbos
2+
3+
import (
4+
"fmt"
5+
6+
log_helper "github.com/EspressoSystems/espresso-sequencer-go/log-helper"
7+
"github.com/ethereum/go-ethereum/log"
8+
)
9+
10+
var (
11+
logHelper = log_helper.NewLogger()
12+
channelFetchHeader = log_helper.Channel("fetch header channel")
13+
channelFetchTransactions = log_helper.Channel("fetch transactions channel")
14+
)
15+
16+
func init() {
17+
logHelper.AddLogAfterRetryStrategy(channelFetchHeader, "0", 20)
18+
logHelper.AddLogAfterRetryStrategy(channelFetchTransactions, "0", 20)
19+
}
20+
21+
func LogFailedToFetchHeader(block uint64) {
22+
logHelper.Attempt(channelFetchHeader, fmt.Sprintf("%d", block), func() {
23+
log.Warn("Unable to fetch header for block number, will retry", "block_num", block)
24+
})
25+
}
26+
27+
func LogFailedToFetchTransactions(block uint64, err error) {
28+
logHelper.Attempt(channelFetchHeader, fmt.Sprintf("%d", block), func() {
29+
log.Error("Error fetching transactions", "block", block, "err", err)
30+
})
31+
}

Diff for: execution/gethexec/espresso_sequencer.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"context"
88
"time"
99

10+
"github.com/offchainlabs/nitro/arbos"
1011
"github.com/offchainlabs/nitro/util/stopwaiter"
1112

1213
espressoClient "github.com/EspressoSystems/espresso-sequencer-go/client"
@@ -73,12 +74,12 @@ func (s *EspressoSequencer) createBlock(ctx context.Context) (returnValue bool)
7374
nextSeqBlockNum := s.hotShotState.nextSeqBlockNum
7475
header, err := s.hotShotState.client.FetchHeaderByHeight(ctx, nextSeqBlockNum)
7576
if err != nil {
76-
log.Warn("Unable to fetch header for block number, will retry", "block_num", nextSeqBlockNum)
77+
arbos.LogFailedToFetchHeader(nextSeqBlockNum)
7778
return false
7879
}
7980
arbTxns, err := s.hotShotState.client.FetchTransactionsInBlock(ctx, header.Height, s.namespace)
8081
if err != nil {
81-
log.Error("Error fetching transactions", "err", err)
82+
arbos.LogFailedToFetchTransactions(header.Height, err)
8283
return false
8384
}
8485

Diff for: execution/gethexec/switch_sequencer.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ func (s *SwitchSequencer) SwitchToEspresso(ctx context.Context) error {
6464
if s.IsRunningEspressoMode() {
6565
return nil
6666
}
67-
log.Info("Switching to espresso sequencer")
67+
log.Info("Switching to espresso sequencer", "max hotshot drift time", s.maxHotShotDriftTime)
6868

6969
s.mode = SequencingMode_Espresso
7070

@@ -77,7 +77,7 @@ func (s *SwitchSequencer) SwitchToCentralized(ctx context.Context) error {
7777
return nil
7878
}
7979
s.mode = SequencingMode_Centralized
80-
log.Info("Switching to centrialized sequencer")
80+
log.Warn("Switching to centrialized sequencer", "max hotshot drift time", s.maxHotShotDriftTime)
8181

8282
s.espresso.StopAndWait()
8383
return s.centralized.Start(ctx)

0 commit comments

Comments
 (0)