mirror of
https://github.com/bitcoin/bitcoin
synced 2026-12-04 15:08:38 +00:00
p2p: Track recent stale tips (BIP 332)(Stale Tip Relay) #36919
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!36919
Loading…
Reference in a new issue
No description provided.
Delete branch "bip332-staletips-pt1-tracking"
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?
Part of #36833
This PR adds local tracking of recent stale tips for BIP 332.
The feature is behind a new
-staletips=<mode>option (defaultnone). There is no P2P change yet: with-staletips=headersthe node only tracks tips.Key changes
AcceptedStaleTipvalidation notification feeds the staletips tracker.getchaintipsRPC updatesmax_depthandstaletips_onlyfork_pointfor each non-active tip.Test networks get the stricter policies the BIP recommends:
Sample output (regtest, after a reorg replaced the tip at height 111)
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.Conflicts
Reviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.
LLM Linter (✨ experimental)
Possible places where comparison-specific test macros should replace generic comparisons:
test/functional/p2p_staletip.py:assert len(tracked) > 0→ Preferassert_greater_than(len(tracked), 0).2026-11-20 18:38:21
Earlier concerns remain unresolved; see the Run archive linked from the Review report.
🟠 Minor · Signet solution variants bypass the tracker’s merkle-root deduplication
On signet with
-staletips=headers, a peer can reuse a signed block and mine solution variants that bypass deduplication, displacing genuine lower-work tips from the ten-entry tracker.Location:
src/node/staletiptracker.cpp:40(head).🟠 Minor · Ahead-of-tip headers are not reconsidered when they become stale
With
-staletips=headers, an eligible competitor can remain untracked after the active chain catches up unless block data is accepted or startup seeding runs; the frequency of this headers-only sequence in production is unknown.Location:
src/validation.cpp:3851(head).🟠 Minor · Reindex startup seeds the tracker before chain activation
With
-staletips=headers,-reindex-chainstateand a fresh unpruned-reindexseed before chain activation, so eligible pre-existing forks can remain missing fromgetchaintips staletips_onlyuntil an ordinary restart.Location:
src/net_processing.cpp:2171(head).🔵 Suggestion ·
max_depthhelp overpromises active-tip inclusionThe RPC help promises the active tip unconditionally, but
getchaintipsexcludes it wheneverstaletips_only=true.Location:
src/rpc/blockchain.cpp:1611(head).🔵 Suggestion · Testnet4 difficulty coverage lacks a positive admission case
A too-strict testnet4 threshold would leave the new difficulty-policy assertions passing because successful admission near the boundary is checked only for
TESTNET.Location:
src/test/staletiptracker_tests.cpp:345(head).🔵 Suggestion · Tracker wiring is separated from its observable integration tests
The independent
getchaintipsextension separates thePeerManagerwiring from its first functional observation tests, making the series harder to validate commit by commit.Location: src/net_processing.cpp:2239 (commit).
Review coverage was incomplete.
Reviewed:
10fa8b7a08ff· Review report · Previous reportspermalink
This should fix the related CI errors.
The "macOS native, fuzz" is a CI environment problem.
Thanks! Fixed
🐙 This pull request conflicts with the target branch and needs rebase.
Concept ACK
Performed first pass review. Left some comments inline, and here some generic ones:
CBlockIndex&instead ofCBlockIndex*wherever possible.I suggest adding an assert here on the size of m_tips (
<= MAX_ADVERTISED_STALETIPS).Nit: combine in one line
I suggest using reference types here (as well), that better advertizes and enforces the "Never null" documented constraint.
IIUC, it's the lowest possible work, not the highest.
Nit: The second "block" could be omitted from the message string.
Could we use
const CBlockIndex& indexhere? I know that other methods in this interface use pointer type for the index, but a reference would be more appropriate here (less error prone, more idiomatic).