Skip to content

fix(sync): drive block requests from readiness events - #1023

Draft
evan-forbes wants to merge 30 commits into
mainfrom
fix/event-driven-block-requesting
Draft

evan-forbes wants to merge 30 commits into
mainfrom
fix/event-driven-block-requesting

Conversation

@evan-forbes

@evan-forbes evan-forbes commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

A requester can have eligible work yet wait for a transport poll, diagnostic heartbeat, or unrelated registry update. Refill requests can also disappear when the routine-to-reactor channel fills. These waits obscure the separate byte-reservation and window limits.

This draft builds on #1006 at c26212652c7b5a333f8657386e5e6676835d62a7. It targets adam/fix-floor-peer-ranking so reviewers see only the additional readiness changes.

Solution

  • Await guarded transport capacity and carry the acquired permit into the next fill. Preserve a pending reservation across unrelated events.
  • Publish peer eligibility after status, session, capacity, and retry changes. Exclude carriers blocked by transport capacity, probe limits, or retry policy. Evaluate eligibility at the pending floor block.
  • Schedule model expiry explicitly. Keep diagnostic heartbeats observational and disable the deadline branch when no deadline exists.
  • Send coalesced, retained producer refill notifications outside the bounded message channel.
  • Wake requesters when an existing queued block receives a changed size estimate. Include the peer in wake traces.
  • Bound fill passes and resume them through an explicit continuation. Record peer deferral separately from an empty queue.

The requester still obeys the existing congestion, memory, retry, and admission limits. Configuration values and body-size estimation remain unchanged. The base includes #982, which uses advertised and confirmed block sizes; unknown sizes still reserve 2 MB.

Testing

Passed with Rust 1.97.0:

  • cargo test -p zakura-network --lib block_sync: 364 tests.
  • cargo test -p zakura-network --lib zakura::transport: 54 tests.
  • cargo clippy -p zakura-network --lib --tests -- -D warnings.
  • cargo fmt --all -- --check and git diff --check.

New regressions exercise the real worker loop with paused time. They cover transport release without a polling tick; preferred-peer removal, range changes, and retry exclusion; diagnostic independence; refill delivery with a full reactor channel; and a fill boundary that coincides with a full transport queue. Model tests cover inclusive expiry boundaries and coalesced equal minima. Cancellation checks verify request ownership and byte reservations return.

Two retention tests now await queue capacity when installing their filler frame. An asynchronous requester reservation can temporarily own the slot after a receive.

Changelog

The PR fragment records prompt requester resumption after eligibility changes.

Specifications & References

Follow-up Work

Keep this PR in draft until node trace validation completes. Revision 81e4f7014 is deployed on the existing sync test node with sync-metrics, unchanged parameters, and #982 included. The latest PR commit changes README spacing only. An initial 85-second measurement achieved 91.16 blocks/s, with about 227 active applies and two outstanding requests per peer. All 7,756 measured requests still reserved 2 MB. Every measured committed height has body and commit trace coverage. The run retains traces outside controller rotation. This is an initial observation, not a matched comparison. Compare the base and this branch with identical parameters. Check event-to-request latency, unexplained idle periods, wake frequency, CPU, memory, and committed throughput. The automated checks do not establish a throughput gain or exhaust every multi-peer interleaving.

Test body-size estimation and parameter changes in a separate PR after establishing this correctness baseline.

czarcas7ic and others added 27 commits September 13, 2026 14:49

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants