Skip to content

test(logpoller): cover batched unfinalized walk and add metrics - #591

Draft
j-nowak wants to merge 1 commit into
l1-logpoller-batch-walkfrom
l1-logpoller-batch-tests-metrics
Draft

j-nowak wants to merge 1 commit into
l1-logpoller-batch-walkfrom
l1-logpoller-batch-tests-metrics

Conversation

@j-nowak

@j-nowak j-nowak commented Nov 10, 2026 •

Copy link
Copy Markdown

Context

Stacked on #590. This is PR 3 of the L1 stack: integration/property coverage and operational metrics for the opt-in batched unfinalized walk. The feature remains disabled by default.

What changed

  • Extend TestLogPoller_SynchronizedWithGeth to run the batch path with both skipEmptyBlocks settings. The batch variants use 25 gopter iterations to keep CI time bounded; the legacy variants keep 100.
  • Add three Prometheus metrics for the opt-in path only:
    • evm_log_poller_unfinalized_batch_chunks_total{chainID,outcome} with outcomes success, partial, reorg, error;
    • evm_log_poller_unfinalized_batch_duration_seconds{chainID};
    • evm_log_poller_unfinalized_batch_headers_total{chainID}.
  • Record chunk outcome/duration/header counts from the batch walk, including partial batches, reorgs, and log/DB errors.
  • Keep the existing evm_log_poller_last_processed_block metric as the primary lag signal.

Why these metrics

BatchCallContext records one evm_pool_rpc_node_calls_total increment for the whole header batch, not one per header, so existing header-call dashboards undercount in batch mode. The new metrics make the opt-in path observable during the canary without changing existing dashboards. The legacy path does not record them.

Testing

  • go test -short ./pkg/logpoller/... passes.
  • The extended gopter test is DB-backed and requires CL_DATABASE_URL.
  • Also ran locally with a real Postgres: CL_DATABASE_URL=... go test -race -run 'TestGetUnfinalizedLogsBatched|TestGetUnfinalizedLogsForMode|TestLogPoller_SynchronizedWithGeth' ./pkg/logpoller.

CI is green: check-tidy, golangci-lint, Build Chainlink, and the full go test -race ./... matrix (including DB-backed tests).

  • The gopter test is the strongest correctness check: it compares the poller's blocks table against geth across arbitrary mining and reorg sequences, now with the batch path enabled.

Safety

  • Metrics are additive and only recorded when the flag is on.
  • No behavior changes beyond the tests and metrics.
  • The feature remains default-off and requires a restart to enable.

Stack

  1. feat(logpoller): add opt-in config for batched unfinalized walk #589 — config only, no behavior.
  2. feat(logpoller): implement opt-in batched unfinalized walk #590 — batched walk + focused unit tests.
  3. This PR — property/integration coverage + metrics.

@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

📊 API Diff Results

No changes detected for module github.com/smartcontractkit/chainlink-evm

View full report

@j-nowak
j-nowak force-pushed the l1-logpoller-batch-tests-metrics branch 2 times, most recently from 538ff3f to 571a065 Compare November 10, 2026 09:38
@j-nowak
j-nowak force-pushed the l1-logpoller-batch-tests-metrics branch from 571a065 to 42aeddb Compare November 10, 2026 09:42
@j-nowak
j-nowak force-pushed the l1-logpoller-batch-tests-metrics branch from 42aeddb to e107c83 Compare November 10, 2026 09:45
@j-nowak
j-nowak added this pull request to stack #592 November 10, 2026 10:15
@j-nowak
j-nowak force-pushed the l1-logpoller-batch-tests-metrics branch 2 times, most recently from cde7616 to 9b8478d Compare November 10, 2026 10:24
@j-nowak
j-nowak requested a balanced review from Copilot November 10, 2026 10:30

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The new batch tests query logs without registered filters instead of checking stored blocks, leaving hash validation empty and allowing stale or orphaned block rows to go undetected.

1 open issue
What changed in this PR

Adds integration/property coverage and operational metrics for the opt-in batched unfinalized-block walk introduced in #590. The feature remains disabled by default.

Changes:

  • Extends geth synchronization tests to batch mode with both empty-block settings, using 25 iterations per batch variant.
  • Records batch chunk outcomes, durations, and walked-header counts.
  • Refines error-type assertions, flag-off checks, and integer-conversion lint annotations.
File Description
pkg/​logpoller/​unfinalized_batch.go Records metrics across successful, partial, reorg, and error exits.
pkg/​logpoller/​unfinalized_batch_internal_test.go Improves error assertions, flag-off checks, and conversion annotations.
pkg/​logpoller/​metrics.go Defines batch outcome, duration, and header-count metrics.
pkg/​logpoller/​log_poller_test.go Adds batch-mode variants to the geth synchronization property test.

Review effort: Balanced

Comment on lines +747 to +748
BatchUnfinalizedBlocks: tc.batchUnfinalizedBlocks,
BatchUnfinalizedBlocksChunkSize: 3,
@j-nowak
j-nowak force-pushed the l1-logpoller-batch-tests-metrics branch from 9b8478d to 9429c69 Compare November 10, 2026 11:08

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants