mirror of
https://github.com/bitcoin/bitcoin
synced 2026-12-04 16:02:38 +00:00
net: make orphan reconsideration more granular #36594
No reviewers
Labels
No labels
Android
Backport
Block storage
Brainstorming
Bug
Build system
CI failed
Consensus
Data corruption
Descriptors
Docs
DrahtBot Guix build requested
Feature
Fuzzing
GUI
Good First Review
IPC
Insufficient Review
Kernel
Linux/Unix
Mempool
Mining
Needs Backport (31.x)
Needs Backport (32.x)
Needs Benchmark
Needs Conceptual Review
Needs backport (30.x)
Needs rebase
Needs release note
Net
P2P
PSBT
Privacy
Private Broadcast
Questions and Help
RPC/REST/ZMQ
Refactoring
Resource usage
Review club
Scripts and tools
Settings
TX fees and policy
Tests
Tracking Issue
UTXO Db and Indexes
Up for grabs
Upstream
Utils/log/libs
Validation
Waiting for author
Wallet
Windows
good first issue
interfaces
macOS
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
bitcoin/bitcoin!36594
Loading…
Reference in a new issue
No description provided.
Delete branch "2610_granular_orphan_reconsideration"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
We currently concentrate the validation of all the assigned peer’s reconsiderable orphans that are still missing inputs in a single message-processing turn. This ties orphan processing to validation result, and adds latency to processing other peers' messages.
Always process a single reconsiderable orphan per turn instead. This removes the need for an immediate validation result, and shifts the latency from other peers to the assigned peer.
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
External sites
Reviews
See the guideline and AI policy for information on the review process.
If your review is incorrectly listed, please copy-paste
<!--meta-tag:bot-skip-->into the comment that the bot should ignore.🔵 Suggestion · Test header omits the per-call limit on orphan reconsideration
The header at denialofservice_tests.cpp:477-478 still says at most one orphan is 'accepted or rejected' per ProcessMessages() call. The new test block also checks that orphans still missing inputs are reconsidered one per call, so the header understates what the test checks.
Location:
src/test/denialofservice_tests.cpp:477(head).Reviewed:
83003cafaa81· Full review report · Previous reportspermalink
concept ACK
probably slap on a unit test or smth and/or fuzz to cap the amount of reconsidered stuff in a step
commit msg: citing the wrong hash, should be
866c8058a7?Yeah, looks like a copy paste mistake.
Corrected commit message, thanks.
Added a unit test that demonstrates the behaviour: the test will fail on master, as both child would be reconsidered there (since validation returns a missing-input error).
Concept ACK
Was the missing-inputs exception in
866c8058a7there because failing in PreChecks was considered cheap? The only hint I found is "after every actual transaction validation attempt" in the866c8058a7commit message.It seems the focus was likely on avoiding too much script validation, and wiping from the orphanage eagerly to avoid a single announcer dominating the orphanage. The orphanage and how announcements are handled across peers has changed quite a bit since then.
tACK
83003cafaaI measured the trade-off the description names with a scenario of my own. One peer sends four orphans that each spend a parent output and an outpoint that does not exist, then sends the parent and an unrelated valid transaction back to back. On master the unrelated transaction is processed on the peer's second turn, because all four orphans are retried in one turn. With this PR it takes six turns: the parent, one per orphan, then the transaction. So the wait moves onto the assigned peer, as described, and each turn validates at most one orphan.
The new case in denialofservice_tests fails on master, at the
ProcessMessagesOncecheck in its loop, and passes here.I tested the head merged into master
a773e1e33b, in a Debug build, with the denialofservice, orphanage, txdownload and txpackage unit tests and the p2p_orphan_handling and p2p_opportunistic_1p1c functional tests. I ran them again with #36437 and #36578 merged on top; the three PRs merge without conflicts. I can share the scenario, a Boost test case, as a gist.Concept ACK
what do you mean by that? Looking at the code, there still seems to be the need for it, to call
ProcessValidTx/ProcessInvalidTx/neither.ACK
83003cafaaI like how this also simplifies the code by replacing the while loop with an if
I've been experimenting with a net_processing / validation split, whereby the message handling and chainstate validation threads talk via message passing. This type of pattern whereby the message handling thread decides how to make progress based on an immediate result it gets from validation ("is this a missing inputs error or something else?") requires a more clumsy API: instead of asking for validation of a transaction, and acting on it once the job comes back, conserving something close to today's behaviour would require passing all reconsiderable transaction in bulk, then the chainstate validation thread to perform today's "validate until result is anything but a missing inputs error", and then return the set of not-yet-reconsidered transactions to net_processing. I think this is a further hint that today's bulk processing is a suboptimal design.
ACK
83003cafaaUnrelated to this PR but still wrong
pedantic nano nit: I know this doesn't worth it, and don't want you to do it here but.. my inner self would be happy to read this as
tiny nit: as an extra sanity check, could check we still process a third valid child after rejecting the invalid ones.
Click to expand the diff
ACK
83003cafaaThis opens the reconsideration gap a bit longer in certain situations but that's no worse than today: beg https://github.com/bitcoin/bitcoin/pull/36437
Going to throw some mutants and extra fuzzing invariants at it but I expect to not find anything edit: nothing found good to go
Tried to fix this wholesale in #36704.