Skip to content

Commit

Permalink
node/watchers/evm: do not allow finalizer == nil (TOB-WORMGUWA-17)
Browse files Browse the repository at this point in the history
  • Loading branch information
tbjump committed May 4, 2023
1 parent 8938c22 commit 62d76f2
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions node/pkg/watchers/evm/connectors/poller.go
Expand Up @@ -37,6 +37,9 @@ func NewBlockPollConnector(ctx context.Context, baseConnector Connector, finaliz
if publishSafeBlocks && !useFinalized {
return nil, fmt.Errorf("publishSafeBlocks may only be enabled if useFinalized is enabled")
}
if finalizer == nil {
return nil, fmt.Errorf("finalizer must not be nil; Use finalizers.NewDefaultFinalizer() if you want to have no finalizer.")
}
connector := &BlockPollConnector{
Connector: baseConnector,
Delay: delay,
Expand Down Expand Up @@ -143,17 +146,15 @@ func (b *BlockPollConnector) pollBlocks(ctx context.Context, logger *zap.Logger,
return lastPublishedBlock, fmt.Errorf("failed to fetch next block (%d): %w", nextBlockNumber.Uint64(), err)
}

if b.finalizer != nil {
finalized, err := b.isBlockFinalizedWithTimeout(ctx, block)
if err != nil {
logger.Error("failed to check block finalization",
zap.Uint64("block", block.Number.Uint64()), zap.Error(err))
return lastPublishedBlock, fmt.Errorf("failed to check block finalization (%d): %w", block.Number.Uint64(), err)
}
finalized, err := b.isBlockFinalizedWithTimeout(ctx, block)
if err != nil {
logger.Error("failed to check block finalization",
zap.Uint64("block", block.Number.Uint64()), zap.Error(err))
return lastPublishedBlock, fmt.Errorf("failed to check block finalization (%d): %w", block.Number.Uint64(), err)
}

if !finalized {
break
}
if !finalized {
break
}

b.blockFeed.Send(block)
Expand Down

0 comments on commit 62d76f2

Please sign in to comment.