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

Node/EVM: Batch poller publish initial blocks #4112

Merged
Show file tree
Hide file tree
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
11 changes: 11 additions & 0 deletions node/pkg/watchers/evm/connectors/batch_poller.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,17 @@ func (b *BatchPollConnector) SubscribeForBlocks(ctx context.Context, errC chan e

errCount := 0

// Publish the initial finalized and safe blocks so we have a starting point for reobservation requests.
for idx, block := range lastBlocks {
b.logger.Info(fmt.Sprintf("publishing initial %s block", b.batchData[idx].finality), zap.Uint64("initial_block", block.Number.Uint64()))
sink <- block
if b.generateSafe && b.batchData[idx].finality == Finalized {
safe := block.Copy(Safe)
b.logger.Info("publishing generated initial safe block", zap.Uint64("initial_block", safe.Number.Uint64()))
sink <- safe
}
}

common.RunWithScissors(ctx, errC, "block_poll_subscribe_for_blocks", func(ctx context.Context) error {
timer := time.NewTimer(b.Delay)
defer timer.Stop()
Expand Down
5 changes: 3 additions & 2 deletions node/pkg/watchers/evm/connectors/batch_poller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,12 +281,13 @@ func TestBatchPoller(t *testing.T) {
}
}()

// First sleep a bit and make sure there were no start up errors and no blocks got published.
// First sleep a bit and make sure there were no start up errors and the initial blocks were published.
time.Sleep(10 * time.Millisecond)
mutex.Lock()
require.NoError(t, publishedErr)
require.NoError(t, publishedSubErr)
assert.Nil(t, block)
batchShouldHaveSafeAndFinalizedButNotLatest(t, block, 0x309a0c, baseConnector.expectedHash())
block = nil
mutex.Unlock()

// Post the first new block and verify we get it.
Expand Down
Loading