Skip to content

Commit

Permalink
handle verifier reconnects after AN reboot
Browse files Browse the repository at this point in the history
  • Loading branch information
peterargue committed Feb 21, 2025
1 parent 6711c92 commit 219d720
Showing 1 changed file with 22 additions and 7 deletions.
29 changes: 22 additions & 7 deletions services/ingestion/sealing_verifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"errors"
"fmt"
"sort"
"strings"
"sync"
"time"

Expand Down Expand Up @@ -116,13 +117,27 @@ func (v *SealingVerifier) Run(ctx context.Context) error {
nextHeight := lastVerifiedHeight + 1
connect := func(height uint64) error {
var err error
eventsChan, errChan, err = v.client.SubscribeEventsByBlockHeight(
subscriptionCtx,
height,
blocksFilter(v.chain),
access.WithHeartbeatInterval(1),
)
return err
for {
eventsChan, errChan, err = v.client.SubscribeEventsByBlockHeight(
subscriptionCtx,
height,
blocksFilter(v.chain),
access.WithHeartbeatInterval(1),
)

if err != nil {
// access node has not sealed the next height yet, wait and try again
// this typically happens when the AN reboots and the stream is reconnected before
// it has sealed the next block
if status.Code(err) == codes.InvalidArgument && strings.Contains(err.Error(), "higher than highest indexed height") {
time.Sleep(time.Second)
continue
}
return err
}

return nil
}
}

v.logger.Info().Uint64("start_height", lastVerifiedHeight).Msg("starting verifier")
Expand Down

0 comments on commit 219d720

Please sign in to comment.