Skip to content

Commit

Permalink
fix: ignore errors in tracker
Browse files Browse the repository at this point in the history
  • Loading branch information
Alok Nerurkar committed Nov 14, 2024
1 parent c306fa3 commit 5ec5f54
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
3 changes: 2 additions & 1 deletion p2p/pkg/preconfirmation/store/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package store

import (
"encoding/binary"
"errors"
"fmt"
"sync"

Expand Down Expand Up @@ -142,7 +143,7 @@ func (s *Store) SetCommitmentIndexByDigest(cDigest, cIndex [32]byte) error {
blkNumBuf, err := s.st.Get(cmtIndexKey(cDigest[:]))
s.mu.RUnlock()
switch {
case err == storage.ErrKeyNotFound:
case errors.Is(err, storage.ErrKeyNotFound):
// this would happen for most of the commitments as the node only
// stores the commitments it is involved in.
return nil
Expand Down
16 changes: 11 additions & 5 deletions p2p/pkg/preconfirmation/tracker/tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ func (t *Tracker) Start(ctx context.Context) <-chan struct{} {
return fmt.Errorf("event subscription error: %w", err)
case newL1Block := <-t.newL1Blocks:
if err := t.handleNewL1Block(egCtx, newL1Block); err != nil {
return err
t.logger.Error("failed handling new block", "error", err)
}
t.triggerOpenCommitments()
}
Expand All @@ -208,7 +208,7 @@ func (t *Tracker) Start(ctx context.Context) <-chan struct{} {
return fmt.Errorf("event subscription error: %w", err)
case ec := <-t.unopenedCmts:
if err := t.handleUnopenedCommitmentStored(egCtx, ec); err != nil {
return err
t.logger.Error("failed handling unopened commitment", "error", err)
}
}
}
Expand Down Expand Up @@ -270,7 +270,7 @@ func (t *Tracker) Start(ctx context.Context) <-chan struct{} {
for _, winner := range winners {
if err := t.openCommitments(egCtx, winner); err != nil {
t.logger.Error("failed to open commitments", "error", err)
return err
continue
}
}
}
Expand All @@ -291,7 +291,7 @@ func (t *Tracker) Start(ctx context.Context) <-chan struct{} {
return fmt.Errorf("event subscription error: %w", err)
case cs := <-t.commitments:
if err := t.handleOpenedCommitmentStored(egCtx, cs); err != nil {
return err
t.logger.Error("failed to handle opened commitment", "error", err)
}
}
}
Expand Down Expand Up @@ -464,7 +464,8 @@ func (t *Tracker) clearCommitments(ctx context.Context) error {
}
winners, err := t.store.BlockWinners()
if err != nil {
return err
t.logger.Error("failed to get block winners", "error", err)
continue
}

if len(winners) == 0 {
Expand All @@ -474,6 +475,11 @@ func (t *Tracker) clearCommitments(ctx context.Context) error {
// clear commitment indexes for all the blocks before the oldest winner
err = t.store.ClearCommitmentIndexes(winners[0].BlockNumber)
if err != nil {
t.logger.Error(
"failed to clear older commitments",
"block", winners[0].BlockNumber,
"error", err,
)
return err
}

Expand Down

0 comments on commit 5ec5f54

Please sign in to comment.