3 minor findings · 2 suggestions
Findings
[minor] · Signet solution mutations bypass stale-tip deduplication
With -staletips=headers on default signet, a holder of a signed block can re-encode its solution and redo its proof of work to fill tracker slots or evict genuine lower-work tips.
Location: src/node/staletiptracker.cpp:40 (head).
Details and suggested fix
IsVariantOnBranch() compares pprev and the ordinary hashMerkleRoot, but SignetTxs::Create() strips the solution before computing the root covered by the signature. Under the default bare-multisig challenge, prefixing the solution's scriptSig with an unused push remains valid because SCRIPT_VERIFY_CLEANSTACK is not enabled. This changes the coinbase txid and header root without another signature. Each variant still needs fresh signet proof of work. For a current tip satisfying the normal work thresholds, unsolicited equal-work variants pass block admission and the validated-block guard, then reach AddStaleTip(). They can fill the ten slots or replace lower-work tips; later genuine equal-work tips cannot displace them.
Deduplicate on the previous block and BIP 325 signet merkle root instead. Retain that identity for active-chain and tracked-branch comparisons, including startup seeding and pruned blocks. Add a regression using two valid solution encodings with different header roots.
[minor] · Initially higher-work tips are not reconsidered when they become stale
With -staletips=headers, racing headers can become eligible without reaching the tracker, so a restart can add previously missing tips; this reception-order gap has not been measured in production.
Location: src/validation.cpp:3851 (head).
Details and suggested fix
For example, on mainnet, accept a valid header A extending active tip T, then activate a different child B while A's block remains unavailable. MaybeNotifyAcceptedStaleTip() suppresses A because it initially has more work than T. Once B activates, A has equal work and is eligible, but no callback re-offers it: it was never active, and known-header announcements are not notified again. Later storage of A's block can recover it, while startup seeding can discover it directly from the index. The descendant-linking loop has the same omission for already-stored descendants that become eligible after their initial acceptance: it notifies only for pindexNew. Re-offer candidates after active-tip changes and descendant linking, while preserving the recency and capacity limits. Add a regression that makes a previously higher-work branch eligible and compares tracking before and after restart.
[minor] · Fresh -reindex runs seed stale tips before the chain is rebuilt
With -staletips=headers, a fresh -reindex can leave stored eligible stale branches absent from the tracked-tip RPC until another restart because seeding runs before import.
Location: src/net_processing.cpp:2171 (head).
Details and suggested fix
PeerManager seeds before the initload thread runs ImportBlocks(), when there is no loaded active tip. Import then activates genesis but defers the winning chain until the final ActivateBestChains() call. Consequently, imported non-genesis stale blocks have too much work to emit AcceptedStaleTip, and connecting the winning chain from genesis does not emit BlockDisconnected. Stored eligible branches therefore remain absent from getchaintips(staletips_only=true); a normal restart can recover them through seeding. Seed or reconcile the tracker after import and final chain activation, and cover a -reindex restart in the functional test.
Optional improvements
[suggestion] · Tracking integration precedes the tests that can observe it
The tracker-wiring commit has no observing test until a later RPC commit; combining them would let reviewers validate the integration and its functional checks together without changing the final tree.
Location: src/net_processing.cpp:2239 at 7962c934db73 (commit) (commit).
Details and suggested fix
7962c934db7335ab4b43619b247ee5017bee8d4d adds constructor seeding and the BlockDisconnected and AcceptedStaleTip hooks, but at that revision p2p_staletip.py only checks option parsing. The GetTrackedStaleTips() accessor, staletips_only, and the reorg, known-descendant, and restart checks arrive in 6238c72fbe148ac6dbf729615f279e690bed223a. Squash the wiring commit into that later RPC commit so the integration and its observable checks can be reviewed and tested together. Keep the combined commit after ba501326628aad027ae85da0d9e86aeffdb9877c, which supplies the fork_point and max_depth used by those tests. This concerns review flow, not missing integration coverage at the PR head.
[suggestion] · The max_depth cutoff leaves historical set-building work intact
Although this cost predates the PR, getchaintips(max_depth=...) still builds ordered sets for blocks below the cutoff under cs_main; filtering during collection would avoid that work without changing the result.
Location: src/rpc/blockchain.cpp:1701 (head).
Details and suggested fix
In the ordinary collection path, skip entries below active_chain.Height() - *max_depth before inserting them into setOrphans and setPrevs. Every child that could suppress a retained non-active parent has greater height and also passes the cutoff, so leaf detection remains unchanged. Keep the output-side check for staletips_only, which inserts tracked tips directly. The full index scan remains, but excluded history no longer needs ordered-set allocation and processing.
Background
Ralph's summary of historical context for the behaviour affected by this change. The historical record reviewed here is incomplete.
Unresolved disagreements
The inspected discussion identifies competing collection objectives without establishing one universally preferred selection policy: greatest-work selection favors reorg-relevant tips, randomized advertising favors network-wide diversity, and permissive testnet collection favors branch mapping at greater resource risk.
The pinned tracker chooses bounded, greatest-work retention and a testnet difficulty floor. Historical support for those choices should not be read as a claim that they maximize observational completeness; the BIP discussion expressly leaves room for different local policies.