main: backport per-peer pindexBestKnownBlock tracking into CNodeState (enables Sync Height) #18
Labels
No labels
enhancement
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
SubGeniusFinance/Offerings-to-Cthulhu#18
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
Do-not-merge-pre-Codex. Tracked here for post-fork implementation. Companion to #15 (Peers tab polish — drops the unused Sync Height widgets) and #13 (the Peers tab itself).
What's missing
(BOB)'s
CNodeState(dobbscoin-source/src/main.cpp:252) carries aCBlockIndex *pindexBestKnownBlockper peer — the highest-known block index of that peer based on the headers / inv messages they've sent. Modern upstream block-sync uses it forFindNextBlocksToDownload()(deciding which peer to ask for which blocks).OFF's
CNodeState(src/main.cpp:206) is the older 0.10-era shape — nopindexBestKnownBlock, nopindexLastCommonBlock. The block-sync state machine in OFF is the oldervBlocksToDownload/vBlocksInFlightstyle, which works but doesn't expose per-peer best-known-block information.Consequence: OFF's
CNodeStateStats(src/main.h:214) only tracksnMisbehavior. There's nonSyncHeightfield, so the Peers tab can't show how high each peer thinks the chain is.Why post-Codex
This touches the block-sync state machine — the code path responsible for downloading blocks from peers. The Codex inscription window (blocks 999,991 → 1,050,666, ~35 days) depends on block-sync staying boring. Even a benign-looking touch to
CNodeStateinitialization or update logic could subtly affect block-download timing, especially under low-peer-count conditions where the Conclave miner is the source of new blocks.Hard freeze: not merging until block 1,050,667 or later.
Once the inscription window closes, this becomes a safe, scoped backport.
Scope (estimate)
~50–80 LOC across
src/main.cppandsrc/main.h. Pattern from (BOB) is well-defined:1.
src/main.h::CNodeStateStats(~2 LOC)2.
src/main.cpp::CNodeState(~1 LOC + constructor init)3.
src/main.cpp::GetNodeStateStats(~1 LOC)4. Update sites for
pindexBestKnownBlock(the actual work — ~40-60 LOC)(BOB)'s
dobbscoin-source/src/main.cppupdates the field in two places (main.cpp:369,main.cpp:386) — both in the per-peer block-header processing path. The fields are updated when:headersmessage arrives and we extend the peer's known headers list (ProcessNewBlockHeaderscallback)invblock announcement arrives with a hash we already have indexed and the work is higher than the peer's previous best-knownThese call sites have to be ported into OFF's equivalent functions. Verify the function names match between vintages (OFF is pre-
ProcessNewBlockHeaders, may need a different hook point).5. Qt re-add of the Sync Height widgets (after this lands)
After this issue is implemented, re-add the Sync Height widgets that #15 drops. Detail pane back to 13 fields. Wire-up is one line:
Open design questions
pindexLastCommonBlocktoo? (BOB) carries both.pindexLastCommonBlockis needed for the modernFindNextBlocksToDownload(); if we're not modernizing block-sync wholesale, we may not need it. Scope-defending lean: justpindexBestKnownBlockfor the Sync Height display, defer LastCommon to a separate block-sync modernization issue.vBlocksToDownloadmachinery — does it conflict with maintainingpindexBestKnownBlockin parallel, or do they coexist cleanly? Should be fine (they don't share state), but verify during implementation.pindexBestKnownBlockaccess needscs_main. All the update sites identified are already undercs_main, so no new lock surface; document this in a comment.What this isn't
References
dobbscoin-source/src/main.h:229—nSyncHeightfield shapedobbscoin-source/src/main.cpp:252—pindexBestKnownBlockfielddobbscoin-source/src/main.cpp:369,386— update sitesdobbscoin-source/src/main.cpp:504—GetNodeStateStatspopulatingnSyncHeightsrc/main.cpp:206— OFF'sCNodeState(current, missing the field)src/main.cpp:324— OFF'sGetNodeStateStats(current, onlynMisbehavior)The Old One sleeps, but knows how far each acolyte has climbed. Iä Iä.