Skip to content

feat(cli): block-listener INFO heartbeat (closes #333)#344

Merged
obchain merged 1 commit intomainfrom
fix/333-block-tick-heartbeat
Apr 26, 2026
Merged

feat(cli): block-listener INFO heartbeat (closes #333)#344
obchain merged 1 commit intomainfrom
fix/333-block-tick-heartbeat

Conversation

@obchain
Copy link
Copy Markdown
Owner

@obchain obchain commented Apr 26, 2026

Summary

  • Add BotConfig::heartbeat_blocks (default 50, configurable via [bot] heartbeat_blocks).
  • CLI emits an info! line at every Nth non-backfill block on the listening chain.
  • 0 disables the heartbeat entirely.
  • Existing per-block debug! line preserved.

Why

Default RUST_LOG=info produced no post-startup output for minutes at a time; operators assumed the bot had hung even though the listener was ticking. Closes #333.

Test plan

  • cargo test --workspace --lib 58/58 (incl. 2 new heartbeat tests in BotConfig)
  • cargo build --workspace clean
  • Divide-by-zero guarded by heartbeat_blocks != 0 short-circuit
  • Backfill heads excluded from heartbeat
  • Soak test against fork — confirm heartbeat fires every ~150s

`charon listen` logged received blocks at DEBUG only, so under the
default `RUST_LOG=info` filter the post-startup terminal stayed
silent for minutes at a time and operators routinely assumed the
bot had hung. The block listener was in fact ticking; the only
proof was scraping `/metrics`.

Add a low-frequency INFO heartbeat keyed off the chain block
number. Default cadence is 50 blocks (~150s on BSC's 3s block
time); operators tune via `[bot] heartbeat_blocks = N`, and a
value of `0` disables it entirely (e.g. JSON-log pipelines that
prefer to derive liveness from the metrics surface).

Block-number-keyed (vs internal counter) so cadence stays
deterministic across restarts, which matters for log-grep based
liveness checks. Backfill heads are skipped so a reconnect storm
replaying many synthesised heads cannot fire N heartbeat lines.

The existing per-block DEBUG line stays for high-resolution
debugging.
@obchain obchain merged commit b8c1be2 into main Apr 26, 2026
4 checks passed
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.

cli: promote one block-tick line per N blocks to INFO — operators have no visible heartbeat

1 participant