Skip to content

fix(dash-spv): quiet idle and per-tick network logs - #1334

Merged
ZocoLini merged 10 commits into
devfrom
fix/quiet-idle-network-logs
Nov 6, 2026
Merged

ZocoLini merged 10 commits into
devfrom
fix/quiet-idle-network-logs

Conversation

@xdustinface

@xdustinface xdustinface commented Nov 5, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #1331.

Problem

A 23 minute testnet run (a full filter rescan, then 22 minutes idle at the tip) produced 81k log lines at debug, most of them without information:

  • Once synced, the peer_speed report was over 90% of all output: one line per peer plus a bandwidth: line every 500 ms, each reading in_flight=0 KB rate=0.00 MB/s.
  • During sync, the 10 line SyncProgress dump was logged at info about 24 times a second.
  • Each extra dial the supervisor dropped logged two info disconnect lines for a peer that never joined the set. In the log that read like peer churn.
  • Each network event was logged 9 times, once by the event handler and once by each of the 8 managers.
  • X serving at ... a replacement is worth probing for repeated on every 250 ms flow tick while a peer stayed slow, 7 times in 1.5 s.
  • Declared 1 wanted ... to the broker repeated on every tick until the reply arrived, for CFHeaders and for blocks, and Segment N: declared GetHeaders ... did the same for headers.

One progress value was also wrong: Segment 0: 1 headers ready to store from height 1579670 with the tip at 1,585,910. The other one in #1331, a restored headers target below the stored tip, changes persisted state rather than a log line and is fixed separately in #1353.

Fix

One commit per item:

  • peer_speed only on change. A peer line prints only when its bytes read, bytes in flight or cap changed since its last line. The bandwidth: line prints when a peer line printed or the global numbers changed. Same level and format, and the cli-bench tooling does not depend on the cadence. After a burst the last printed rate can stay non-zero, because the decaying moving average is no longer printed.
  • SyncProgress rate limit. A dump is logged whenever any manager changes state, otherwise at most once every 5 s. A state change is never delayed, so each phase start and finish and the final synced state are logged when they happen, which the benchmark reports rely on. Handlers still receive every update. A refactor commit first shares the manager state list between state() and is_synced().
  • A dropped extra dial is one debug line. The reader cannot tell whether its peer is in the set, so its NETWORK: peer X disconnected line is gone. The pump logs the existing info line when the close removed a set member, and a debug line otherwise. A remote disconnect of a member now logs one info line instead of two. A peer removed by a swap or a timeout kick is logged where it is removed. stop now names the peers it disconnects (network manager stopping: disconnected N peer(s) [..]), since its existing line named none. So every path that removes a set member logs it at info or warn.
  • Per-manager network event copies at trace. The single event handler line stays.
  • A slow peer is logged once. underserving_peer returns the peer with its rate and the best rate, and the flow controller logs the line only on the transition that also wakes the supervisor. The log text is unchanged.
  • Pipeline declares only when new. The CFHeaders and blocks pipelines log a declare only when something new was queued since the last send.
  • Header declares only when new. Each header segment remembers the locator it last declared and logs Segment N: declared GetHeaders ... only for a new one. The request still goes to the broker every tick, so routing is unchanged. A reply clears the remembered locator, so a real re-request after the tip reopens is still logged, and a resumed start_sync forgets them all since stop clears the broker. The Tick: pipeline ... count lines now count new requests only. In a fresh testnet sync these two lines were 75k of 128k log lines.
  • Stored batch start height. The header pipeline reported the segment start instead of the start of the batch being stored, for every segment that drains more than once. The value was only used in the log, and the now unread SegmentState::start_height field is removed.

Tests

  • test_completed_tip_accepts_unsolicited_header_batch is extended with a second batch, which must report start 1003. The old code reported 1001.
  • test_draining_active_window_exposes_next_segment_for_refill and test_pipeline_send_pending check that a re-declare counts as nothing new, and that the same locator counts as new again after a reply reopens the tip.
  • cargo test -p dash-spv --lib: 639 passed (on dev at 4e49ea925).
  • just dash-spv::test: all green, including dashd_sync 38/38 and dashd_masternode 11/11.

PR Hygiene · b185a2f

  • Bots — coderabbitai skipped after its own rate limit
  • Self-review — posted; again after any push
  • Build green
  • Approvals — you own every area touched; none needed

When every merge requirement is met, the PR Hygiene check passes. Reviewer limits do not block merging; other required GitHub checks and protections still apply.

@coderabbitai

coderabbitai Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 19 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 6bb43e1 and b185a2f.

Files selected for processing: 12

  • dash-spv/src/client/event_handler.rs
  • dash-spv/src/network/manager.rs
  • dash-spv/src/network/peer.rs
  • dash-spv/src/network/peer_set.rs
  • dash-spv/src/sync/block_headers/manager.rs
  • dash-spv/src/sync/block_headers/pipeline.rs
  • dash-spv/src/sync/block_headers/segment_state.rs
  • dash-spv/src/sync/block_headers/sync_manager.rs
  • dash-spv/src/sync/blocks/pipeline.rs
  • dash-spv/src/sync/filter_headers/pipeline.rs
  • dash-spv/src/sync/progress.rs
  • dash-spv/src/sync/sync_manager.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@codecov

codecov Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.06780% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.26%. Comparing base (4e49ea9) to head (b185a2f).
⚠️ Report is 6 commits behind head on dev.

Files with missing lines Patch % Lines
dash-spv/src/network/manager.rs 82.92% 7 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #1334      +/-   ##
==========================================
+ Coverage   85.17%   85.26%   +0.09%     
==========================================
  Files         268      268              
  Lines       68101    68673     +572     
==========================================
+ Hits        58005    58555     +550     
- Misses      10096    10118      +22     
Flag Coverage Δ
core 82.43% <ø> (ø)
rpc 52.10% <ø> (ø)
spv 94.04% <94.06%> (+0.01%) ⬆️
wallet 83.39% <ø> (+0.26%) ⬆️
Files with missing lines Coverage Δ
dash-spv/src/client/event_handler.rs 93.58% <100.00%> (+0.06%) ⬆️
dash-spv/src/network/peer.rs 90.24% <ø> (+0.24%) ⬆️
dash-spv/src/network/peer_set.rs 99.18% <100.00%> (+<0.01%) ⬆️
dash-spv/src/sync/block_headers/manager.rs 94.51% <100.00%> (ø)
dash-spv/src/sync/block_headers/pipeline.rs 97.33% <100.00%> (+0.10%) ⬆️
dash-spv/src/sync/block_headers/segment_state.rs 98.30% <100.00%> (+0.08%) ⬆️
dash-spv/src/sync/block_headers/sync_manager.rs 85.36% <ø> (ø)
dash-spv/src/sync/blocks/pipeline.rs 96.08% <100.00%> (+0.05%) ⬆️
dash-spv/src/sync/filter_headers/pipeline.rs 97.05% <100.00%> (+0.08%) ⬆️
dash-spv/src/sync/progress.rs 89.47% <100.00%> (-0.36%) ⬇️
... and 2 more

... and 9 files with indirect coverage changes

The flow controller printed one line per peer plus a `bandwidth:` line every 500 ms even while nothing moved, which made up most of a synced client's debug output. A peer line now prints only when the peer's bytes read, bytes in flight or cap changed since its last line, and the `bandwidth:` line only when a peer line printed or the global totals changed. The line format is unchanged.
`state` and `is_synced` built the same list of manager states. Both now use one private `manager_states` helper.
The progress monitor logged the full 10 line `SyncProgress` dump at `info` on every update, about 24 times a second during sync. It now logs a value when any manager changes state, and otherwise at most once every 5 seconds. A state change is never delayed, so each phase start and finish and the final synced state are still logged when they happen. Handlers still receive every update.
Every connection close logged `NETWORK: peer X disconnected` from the reader and `peer disconnected: X | N peers remaining | M re-queued` from the pump, both at `info`, even for a probed peer the supervisor dropped without it ever joining the set. In the log that read like peer churn.

The reader no longer logs the close, since it cannot tell whether its peer is in the set. The pump logs the existing `info` line when the close removed a member, and a single `debug` line otherwise. A member that the supervisor swapped out or the timeout monitor kicked is already gone from the set by then, and its removal is still logged by whoever removed it.
Each network event was logged once at `info` by the event monitor and again at `debug` by each of the 8 sync managers. The per-manager copy is now at `trace`, so a `debug` log shows each event once.
The CFHeaders and blocks pipelines re-declare every wanted request on each 100 ms tick, which is safe because the broker de-duplicates, but each pass logged `Declared N wanted ...` again while the same request was still in flight. Both pipelines now remember whether a request was added since the last declare, and log the line only then.
`take_ready_to_store` returned and logged the segment's start height for every batch it drained, so after the first batch of a segment the `Segment N: M headers ready to store from height H` line named the wrong height, such as 1579670 while storing near 1585910. The start is now derived from `current_height` and the drained count.

That left the `SegmentState::start_height` field unread, so it is removed.
@xdustinface
xdustinface force-pushed the fix/quiet-idle-network-logs branch from 351f2e6 to 294220e Compare November 5, 2026 14:05
@xdustinface
xdustinface marked this pull request as ready for review November 6, 2026 05:50
@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Waiting for bot review — coderabbitai not yet. Wait for the missing reviews, or a writer can post /skip-bots to proceed without them; blocking findings still need addressing.
Full checklist in the description.

@github-actions github-actions Bot added the waiting-bots Waiting for the review bots to report on this head label Nov 6, 2026
@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Waiting for bot review — coderabbitai not yet. Wait for the missing reviews, or a writer can post /skip-bots to proceed without them; blocking findings still need addressing.
Full checklist in the description.

@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Bots are done — your move: post /self-reviewed.
Full checklist in the description.

@github-actions github-actions Bot added waiting-self-review Waiting for the author to post /self-reviewed bot-review-skipped A required review bot did not report; it was skipped by the window or by a person. and removed waiting-bots Waiting for the review bots to report on this head labels Nov 6, 2026
@xdustinface
xdustinface requested a review from ZocoLini November 6, 2026 09:18
`stop` empties the peer set before the readers report their closed connections, so the pump logs those closes at `debug` as connections outside the set. The removal is now logged by `stop` itself: `PeerSet::clear` returns the addresses it removed, and `stop` logs them at `info`. With this, every path that takes a member out of the set logs it at `info` or `warn`: the pump for a remote disconnect, the supervisor for a swap, the timeout monitor for a kick, and `stop`.

A remote disconnect of a member now logs one `info` line instead of two, since the reader no longer logs the close.
The header pipeline re-declares each active segment's `GetHeaders` on every 100 ms tick, which is safe because the broker de-duplicates. Each pass logged `Segment N: declared GetHeaders from height H hash X` again for the same height until the reply arrived, about half of a fresh testnet sync log, and `send_pending` counted every re-declare, so `Tick: pipeline sent N more requests` repeated as well.

Each segment now remembers the locator it last declared. `send_request` logs and reports a request as new only when the locator differs, and a reply, empty or not, makes the next request new again. A resumed sync forgets the declared locators, since its queued requests may have been dropped. `send_pending` returns the number of new requests, so the tick line and the start line only report those, now worded as `declared N new request(s)`.
`underserving_peer` runs on every flow tick, so its "replacement is worth probing for" line repeated every 250 ms while a peer stayed slow. It now returns the slow peer with both rates, and the flow controller logs it only on the transition that wakes the supervisor.
@xdustinface
xdustinface force-pushed the fix/quiet-idle-network-logs branch from beb7b30 to b185a2f Compare November 6, 2026 09:22
@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Waiting for bot review — coderabbitai not yet. Wait for the missing reviews, or a writer can post /skip-bots to proceed without them; blocking findings still need addressing.
Full checklist in the description.

@github-actions github-actions Bot added waiting-bots Waiting for the review bots to report on this head and removed waiting-self-review Waiting for the author to post /self-reviewed labels Nov 6, 2026
@github-actions github-actions Bot removed the bot-review-skipped A required review bot did not report; it was skipped by the window or by a person. label Nov 6, 2026
@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Bots are done — your move: post /self-reviewed.
Full checklist in the description.

@github-actions github-actions Bot added waiting-self-review Waiting for the author to post /self-reviewed bot-review-skipped A required review bot did not report; it was skipped by the window or by a person. and removed waiting-bots Waiting for the review bots to report on this head labels Nov 6, 2026
@xdustinface

Copy link
Copy Markdown
Collaborator Author

/self-reviewed

@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Policy satisfied — this can merge.
Full checklist in the description.

@github-actions github-actions Bot removed the waiting-self-review Waiting for the author to post /self-reviewed label Nov 6, 2026
@ZocoLini
ZocoLini merged commit 8b25dab into dev Nov 6, 2026
38 checks passed
@ZocoLini
ZocoLini deleted the fix/quiet-idle-network-logs branch November 6, 2026 19:41
ZocoLini added a commit that referenced this pull request Nov 7, 2026
#1334 made `underserving_peer` return a `SlowPeer` instead of a `SocketAddr`, and the test #1333 added still compared the result to a peer address, so dev fails to build its tests.
ZocoLini added a commit that referenced this pull request Nov 7, 2026
#1334 made `underserving_peer` return a `SlowPeer` instead of a `SocketAddr`, and the test #1333 added still compared the result to a peer address, so dev fails to build its tests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot-review-skipped A required review bot did not report; it was skipped by the window or by a person.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

dash-spv: idle and per-tick log lines drown the useful output

2 participants