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(core/fetcher): resubscribe if consensus node goes offline #4096

Merged
merged 5 commits into from
Feb 7, 2025
Merged
Changes from 3 commits
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
10 changes: 10 additions & 0 deletions core/fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
coregrpc "github.com/tendermint/tendermint/rpc/grpc"
"github.com/tendermint/tendermint/types"
"google.golang.org/grpc"
"google.golang.org/grpc/status"

libhead "github.com/celestiaorg/go-header"
)
Expand Down Expand Up @@ -173,9 +174,12 @@ func (f *BlockFetcher) SubscribeNewBlockEvent(ctx context.Context) (<-chan types

subscription, err := f.client.SubscribeNewHeights(ctx, &coregrpc.SubscribeNewHeightsRequest{})
if err != nil {
close(f.doneCh)
f.isListeningForBlocks.Store(false)
return nil, err
}

log.Debug("created a subscription. Start listening for new blocks...")
signedBlockCh := make(chan types.EventDataSignedBlock)
go func() {
defer close(f.doneCh)
Expand All @@ -189,6 +193,12 @@ func (f *BlockFetcher) SubscribeNewBlockEvent(ctx context.Context) (<-chan types
resp, err := subscription.Recv()
if err != nil {
log.Errorw("fetcher: error receiving new height", "err", err.Error())
_, ok := status.FromError(err) // parsing the gRPC error
if ok {
// ok means that err contains a gRPC status error.
// move on another round of resubscribing.
return
}
continue
}
withTimeout, ctxCancel := context.WithTimeout(ctx, 10*time.Second)
Expand Down
Loading