Skip to content

Commit e40a109

Browse files
renaynayWondertan
authored andcommitted
fix(das): Clarify logs for historic headers that are skipped (#3380)
Fix is kind of ugly but there needs to be a way to bubble up to worker that the header is skipped vs being sampled successfully. Resolves #3194
1 parent 72111f4 commit e40a109

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

das/daser.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ import (
2121

2222
var log = logging.Logger("das")
2323

24+
// errOutsideSamplingWindow is an error used to inform
25+
// the caller of Sample that the given header is outside
26+
// the sampling window.
27+
var errOutsideSamplingWindow = fmt.Errorf("skipping header outside of sampling window")
28+
2429
// DASer continuously validates availability of data committed to headers.
2530
type DASer struct {
2631
params Parameters
@@ -160,7 +165,7 @@ func (d *DASer) sample(ctx context.Context, h *header.ExtendedHeader) error {
160165
if !d.isWithinSamplingWindow(h) {
161166
log.Debugw("skipping header outside sampling window", "height", h.Height(),
162167
"time", h.Time())
163-
return nil
168+
return errOutsideSamplingWindow
164169
}
165170

166171
err := d.da.SharesAvailable(ctx, h)

das/worker.go

+13
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,18 @@ func (w *worker) run(ctx context.Context, timeout time.Duration, resultCh chan<-
7575
jobStart := time.Now()
7676
log.Debugw("start sampling worker", "from", w.state.from, "to", w.state.to)
7777

78+
skipped := 0
79+
7880
for curr := w.state.from; curr <= w.state.to; curr++ {
7981
err := w.sample(ctx, timeout, curr)
8082
if errors.Is(err, context.Canceled) {
8183
// sampling worker will resume upon restart
8284
return
8385
}
86+
if errors.Is(err, errOutsideSamplingWindow) {
87+
skipped++
88+
err = nil
89+
}
8490
w.setResult(curr, err)
8591
}
8692

@@ -91,6 +97,7 @@ func (w *worker) run(ctx context.Context, timeout time.Duration, resultCh chan<-
9197
"from", w.state.from,
9298
"to", w.state.curr,
9399
"errors", len(w.state.failed),
100+
"# of headers skipped as outside of sampling window", skipped,
94101
"finished (s)", time.Since(jobStart),
95102
)
96103
}
@@ -112,6 +119,12 @@ func (w *worker) sample(ctx context.Context, timeout time.Duration, height uint6
112119
defer cancel()
113120

114121
err = w.sampleFn(ctx, h)
122+
if errors.Is(err, errOutsideSamplingWindow) {
123+
// if header is outside sampling window, do not log
124+
// or record it.
125+
return err
126+
}
127+
115128
w.metrics.observeSample(ctx, h, time.Since(start), w.state.jobType, err)
116129
if err != nil {
117130
if !errors.Is(err, context.Canceled) {

0 commit comments

Comments
 (0)