Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(das): Clarify logs for historic headers that are skipped #3380

Merged
merged 2 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion das/daser.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ import (

var log = logging.Logger("das")

// errOutsideSamplingWindow is an error used to inform
// the caller of Sample that the given header is outside
// the sampling window.
var errOutsideSamplingWindow = fmt.Errorf("skipping header outside of sampling window")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:nice: 😄


// DASer continuously validates availability of data committed to headers.
type DASer struct {
params Parameters
Expand Down Expand Up @@ -160,7 +165,7 @@ func (d *DASer) sample(ctx context.Context, h *header.ExtendedHeader) error {
if !d.isWithinSamplingWindow(h) {
log.Debugw("skipping header outside sampling window", "height", h.Height(),
"time", h.Time())
return nil
return errOutsideSamplingWindow
}

err := d.da.SharesAvailable(ctx, h)
Expand Down
13 changes: 13 additions & 0 deletions das/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,18 @@ func (w *worker) run(ctx context.Context, timeout time.Duration, resultCh chan<-
jobStart := time.Now()
log.Debugw("start sampling worker", "from", w.state.from, "to", w.state.to)

skipped := 0

for curr := w.state.from; curr <= w.state.to; curr++ {
err := w.sample(ctx, timeout, curr)
if errors.Is(err, context.Canceled) {
// sampling worker will resume upon restart
return
}
if errors.Is(err, errOutsideSamplingWindow) {
skipped++
err = nil
}
w.setResult(curr, err)
}

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

err = w.sampleFn(ctx, h)
if errors.Is(err, errOutsideSamplingWindow) {
// if header is outside sampling window, do not log
// or record it.
return err
}

w.metrics.observeSample(ctx, h, time.Since(start), w.state.jobType, err)
if err != nil {
if !errors.Is(err, context.Canceled) {
Expand Down
Loading