Skip to content

btc(v36): advertise raw head at handshake + re-advertise on best-change (root-2) - #105

Merged
frstrtr merged 1 commit into
masterfrom
btc/root2-genesis-null-advert
Jun 16, 2026
Merged

btc(v36): advertise raw head at handshake + re-advertise on best-change (root-2)#105
frstrtr merged 1 commit into
masterfrom
btc/root2-genesis-null-advert

Conversation

@frstrtr

@frstrtr frstrtr commented Jun 16, 2026

Copy link
Copy Markdown
Owner

BTC mirror of the Root-2 genesis-null-advert fix (LTC source: b56bfb2 on ltc-doge/root2-genesis-null-advert).

Problem: send_version advertised best_share_hash() (verified-only), which collapses to 0x000 once any peers exist. On a fresh --genesis node the verified set is empty at handshake, so the peer never issues download_shares() and broadcast cannot backfill (head shares already de-dup-marked) -> sync deadlock.

Fix (src/impl/btc/node.cpp, node.hpp):

  • send_version now advertises advertised_best_share() (raw head) instead of verified-only best_share_hash().
  • advertised_best_share() returns the verified head when present, else the tallest RAW chain head -- advertisement only, never used for work/share creation (best_share_hash() still owns work and stays verified).
  • readvertise_best() re-announces on the think IO-phase and on best-change.

Livelock-safe: no new exclusive lock; broadcast_share keeps try_to_lock. Mirrors the LTC diff shape exactly (+114/-1 equivalent, content-verified against b56bfb2).

Verification: ctest 100% (590 passed, 0 failed) at 659b95c. GPG-signed, no attribution.

Note: supersedes branch btc/root2-advert-readvert (b3c0bbec), which mirrored the earlier LTC variant e01c160. That branch should NOT also be opened as a PR.

…ge (root-2)

On a --genesis node the verified share set is empty at the version
handshake, so send_version advertised best_share_hash()==ZERO and the
connecting peer never issued download_shares() for our chain. Add
advertised_best_share(): returns think()s current best, else the tallest
raw chain head, else ZERO only at true genesis. Wire it into
send_version so a peer always learns we have a chain and pulls it, while
work/template selection stays on the verified-only best_share_hash().

Re-advertise the head via readvertise_best() on every successful think
IO-phase work refresh and on clean_tracker best-change, so a peer that
handshook during the verified-empty window still gets our head. Guarded
on non-empty peers and non-ZERO head; broadcast_share keeps its
try_to_lock so this cannot reintroduce the think/broadcast livelock.

BTC mirror of LTC b56bfb2 (ltc-doge/root2-genesis-null-advert).
@frstrtr
frstrtr merged commit 0b15ffe into master Jun 16, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant