Skip to content
Closed
Changes from all 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
5 changes: 4 additions & 1 deletion op-node/node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,13 @@ func (n *OpNode) initL1(ctx context.Context, cfg *Config) error {

// Keep subscribed to the L1 heads, which keeps the L1 maintainer pointing to the best headers to sync
n.l1HeadsSub = event.ResubscribeErr(time.Second*10, func(ctx context.Context, err error) (event.Subscription, error) {
if errors.Is(err, context.Canceled) {
Copy link
Contributor

Choose a reason for hiding this comment

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

an issue could occur during network reconnects. Not totally sure, but iirc the context will end up being canceled. So the op-node will fail to receive head changes in that event.
Worth confirming this won't occur locally or by adding a test.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You appear to be right. What's the point of passing in a context that can't actually be used??? If you don't ignore Canceled errors then it winds up in an infinite loop because Unsubscribe cancels the context which prevents new resubscribe attempts from succeeding and then calls this method again in an infinite loop.

Copy link
Contributor

Choose a reason for hiding this comment

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

Late response. But the passed in context lets users to prevent a resubscribe based the parent context, like during shutdown. Problem here is both the shutdown signal and other sources of cancelations are observed the same way. eth.WatchHeadChanges already check for both cases. So once we have the deadlock fixes in it should resolve itself.

return nil, err
}
if err != nil {
n.log.Warn("resubscribing after failed L1 subscription", "err", err)
}
return eth.WatchHeadChanges(n.resourcesCtx, n.l1Source, n.OnNewL1Head)
return eth.WatchHeadChanges(ctx, n.l1Source, n.OnNewL1Head)
})
go func() {
err, ok := <-n.l1HeadsSub.Err()
Expand Down