Repository navigation
Conversation
qbit-photon announced a block under the leading 64 bits of its hash. A native-lane block's proof of work is on its own hash, so those bits take only a few values, and most native-lane blocks were taken for a block already relayed and were not sent. Announce blocks under the low-order 64 bits of the hash instead (the last 16 hex digits as qbitd prints it). The packet format and protocol version are unchanged: - A received block is accepted under either form: its reconstructed header must hash to the announced identifier in one of them. - Blocks are tracked as seen or settled by the low-order bits of the reconstructed or announced hash, so a block that arrives under both forms is submitted and relayed once. - Earlier versions use the identifier only as a key, so they receive blocks announced under the new form. After their node accepts such a block they may send it on once under the earlier form; this version recognises that copy as a block it already has. Also adjust the pre-submission parent check: - A block whose parent qbitd has as a header on a branch with more work than its best block, at most max_parent_depth blocks above it, is submitted, and qbitd connects it after the parent. qbitd storing it without connecting it yet does not count against the sender. A parent further ahead still means qbitd is catching up, and the block is dropped. - A block whose parent qbitd does not know is dropped without counting against the sender. - When qbitd does not answer the parent check or submitblock, the block is kept (one at a time, for up to two minutes) and tried once more after qbitd next answers a call or announces a block. Tests cover the identifier forms, blocks that share their leading hash bits, one block announced under both forms, a receiver keyed only by the identifier, a replay of 64 mainnet block headers, and the parent check and retry cases. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ndling - A block whose parent qbitd does not know is let off once per peer per fault decay interval (60 s), since its parent may still be on its way to qbitd; further ones within the interval count against the peer, so a peer cannot keep qbitd busy with such blocks. They are counted in a new block_parent_unknown field instead of block_parent_rejected. - A held block's retry no longer counts outcomes that may only reflect the delay (too far from the tip, or stored without being connected) against the sender; rejections still count. - While a block is held, other copies of it are ignored through the held block itself rather than the 10 s settled set, so an outcome that concerns only the retried copy leaves other peers' copies to be tried. - node_retries counts only retries that call qbitd; a new held_dropped field counts held blocks dropped without a retry, which are also logged. The held block keeps its parsed header. - The runbook names v1.0.0 as the version that keys blocks only by the announced identifier, and notes that a copy announced under the earlier form is recognised after it is decoded. - Tests: the unknown-parent allowance and an honest race, retry outcomes, held-block replacement and drop counts, copies of settled or held blocks skipped before decoding, and the main loop retrying a held block once qbitd announces a block. Co-Authored-By: Claude Opus 5.5 <[email protected]>
- A held block dropped without a retry (replaced, expired, or its sender paused) is settled like any block qbitd did not answer for, so late copies of it are not sent to qbitd again for 10 s. - Copies in progress when a block is held are marked handled, so the rest of their chunks do not start new incomplete blocks after the hold ends. - A child of the held block whose parent qbitd does not know yet does not count against its sender. - Tests: settle timing after a slow check now uses an answer that settles; a retried unknown-parent block leaves the peer's allowance; the main loop also handles the earlier identifier form; and the cases above. The runbook lists the new counters where operators are told to look. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… copies free - A block that builds on the held block now has the held block tried once more first, so qbitd can connect both, instead of finding the new block's parent unknown. If qbitd still does not answer, the parent is given up and the new block is held instead. The exemption for such a block from the unknown-parent count is no longer needed. - A held block dropped because its sender was paused is not settled: qbitd never saw it, so other peers' copies are still tried. - Copies ignored while a block is held are marked handled, so their remaining chunks do not start incomplete blocks once the hold ends. - Tests for these cases, for late copies of expired and replaced held blocks, and runbook wording. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A block whose parent is the held block is now checked first, as any other block. Only when qbitd answers that its parent is unknown is the held block tried again, and the block then checked once more. This keeps the rule that a held block is retried only after qbitd answers, so a child arriving while qbitd is still not answering costs no extra call. A child whose held parent was just tried again does not count against its sender if its parent is still unknown, and a child is dropped if its parent's retry paused their common sender. Also fold the handling of ignored copies into one helper, and update the tests and runbook. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…answered - When the held block's retry for a new block gets no answer from qbitd, the new block is held instead of being checked again at once. - A block that builds on the held block no longer replaces it when qbitd does not answer for it, since qbitd cannot connect it without the parent; it is dropped and its copies are not checked for 10 s. - A block dropped because its sender was paused during its parent's retry is logged. - Tests for these paths, for a parent whose retry is answered but still cannot be used, and for a held parent's retry pausing only its own sender; the runbook describes the extra calls such a block can take. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… room A header refused only because the inbound entry or decoder caps are full no longer ends the block for the sending peer. Headers that no honest sender produces (malformed, or above the per-block limits) still end it: the rest of that block's packets from the peer are ignored for 10 seconds and the refusal counts against the peer, as before. After a refusal for lack of room, the chunks that follow are handled like those of a block whose header has not arrived, within the same per-peer and total caps, and a later copy of the header starts the block once there is room. Co-Authored-By: Claude Opus 5.5 <[email protected]>
kiwidream
marked this pull request as ready for review
November 11, 2026 21:52
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
The previous commit left such a block open, but senders send their header copies only before the chunks, so the block could still not start once room was free, and its chunks built entries of their own instead. A header refused only because there is no room for its decoder now is kept with the block's incomplete entry, when that entry already exists or when the peer and the relay each have an entry free without dropping anything. The block's chunks must fit the kept header and are buffered within the pre-header caps. After an incomplete block has been released, the next chunk or header copy of the waiting block starts its decoder if it fits without displacing any other block, so the block can complete from the chunks that follow. Otherwise the header is refused as before, and the rest of the block from that peer is ignored. A decoder that exceeds the per-peer or total cap on its own, or that cannot be built, also ends the block, without counting against the peer. A waiting block is counted once in inbound_rejected. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A sender sends each chunk once, so a block waiting for room that has lost more chunks than all its coding groups have parity chunks can no longer be completed. It now ends then, as if its header had been refused, instead of holding an entry and its buffered chunks, and later a decoder, for nothing. Starting the decoder of a waiting block no longer counts as progress, so a repeated header copy or chunk does not keep an idle block from being displaced. The tests now send chunks in the sender's order and also cover a header that arrives after some of its chunks. The runbook states how a waiting block is counted in inbound_rejected. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…duce A sender sends its header copies before its chunks, and the peer layer drops packets older than the last one it accepted, so a header copy after chunks, or chunks before their header, reach the relay engine only from a sender that does not follow the protocol. Say so in the tests that use those orders to check the engine on its own. Co-Authored-By: Claude Opus 5.5 <[email protected]>
64 of 80 tasks
Conflict in contrib/photon/RUNBOOK.md: #410 landed this branch's first six commits as one commit, and the later commits here edit the same two paragraphs. Resolved to this branch's text. Nothing else on 1.x.x touched contrib/photon, so that directory is unchanged by the merge. Co-Authored-By: Claude Fable 5.2 <[email protected]>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Related #381, #410.
Depends on #410. This branch is based on #410's head and contains #410's commits until #410 merges; after that it is rebased onto
1.x.xand only this PR's own commits remain. The later commits rework the first, so review their combined diff (ca1cf91970..HEAD).Since #381, a refused block header ends that block for the sending peer for 10 seconds: the rest of its header copies and chunks from that peer are ignored. That is intended for headers that no honest sender produces, but it also applied when a header was refused only because there was no room for its decoder at that moment. Senders send their header copies only before the block's chunks and never repeat them, so such a block could not be started from that peer even once room was free again. This is a robustness improvement to the inbound resource accounting:
inbound_rejectedonce for its header, and again only if it is later dropped for a chunk outside the header or a decoder that cannot be built; chunks that cannot be buffered are not counted.Only
contrib/photon/src/relay_engine.{h,cpp},contrib/photon/test/relay_engine_tests.cppandcontrib/photon/RUNBOOK.mdchange. No wire-format, protocol or qbitd change; senders are unchanged, so mixed versions behave as before.Testing
contrib/photon, RelWithDebInfo, Ninja). No compiler warnings.relay_engine_tests:capacity_refused_block_completes_in_sender_order: another peer's block holds all decoder memory; the three header copies are refused, then each chunk is sent once in the sender's (ChunkScheduler) order, more than 64 of them before room frees; the block waits without a decoder, is refused once and not counted against the peer, and completes from the chunks sent after the other block completes.waiting_block_ends_once_it_cannot_complete(own and shared pre-header buffer): the block still waits after losing as many chunks as it has parity chunks, ends at one more without a fault or a further refusal, and nothing is built for it once room frees.waiting_block_takes_nothing_from_other_blocks: with no free entry the header is refused as before and its chunks displace nothing; a waiting block does not displace another peer's idle block after an unrelated release, and starts at the first chunk after the release that frees room.never_fitting_decoder_finishes_block(per-peer and total cap),waiting_block_chunk_must_fit_its_header,fault_refused_header_stays_handled.capacity_refused_header_can_be_retried(a further header copy starts a waiting block from its kept chunks),header_after_chunks_waits_with_them,starting_waiting_block_is_not_progress.never_fitting_decoder_finishes_blockandfault_refused_header_stays_handled(guards for paths that end the block as before) fail on photon: announce blocks under the low-order bits of their hash #410's head; the sender-order test fails there and on this PR's first commit even with only its completion checks enabled. Reverting each new rule in a scratch copy (displacing blocks when a waiting block starts, keeping never-fitting headers, ignoring the free-entry condition, counting waiting chunks again, not checking chunks against the kept header, not finishing a block started by a header copy, never ending a block that cannot complete, ending it one chunk early, counting a start as progress) fails at least one test.photon_relay_engine_tests: 78/78 pass.ctestforcontrib/photon: all suites pass exceptphoton_scheduler_testsencode_schedule_regression, a p95 timing ratio that fails the same way on the unmodified base on the build machine.feature_photon_relay.pyandfeature_integration_photon_topology.pypass./code-review xhigh); the first two rounds' findings led to the later commits, and the third found no correctness issues.git diff --check,test/lint/lint-files.py,lint-include-guards.py,lint-includes.py,lint-locale-dependence.py,lint-qbit-public-docs.py,lint-qbit-node-defaults.py(lint-spelling.pyskipped: codespell not installed).Target Branch
mainor a maintainer-requested release branch such as0.1.x. (Targets1.x.x, for a release after v1.0.1.)Risk / Review Notes
Notes: Relay-side block intake in
contrib/photononly. The caps from #381 are unchanged; a waiting block uses only an entry and pre-header buffer space that are free, and its decoder only when it fits without displacing anything.Docs / Process Impact
Choose exactly one:
contrib/photon/RUNBOOK.md: when a refused block waits for room, how it is counted, and the new test anchors.)libbitcoinpqc Subtree Checklist (if
src/libbitcoinpqcchanged)Not applicable.
🤖 Generated with Claude Code
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.