Skip to content

node: EnumHdrs returns the range [Min, Max] (#2153) - #2154

Open
profinch wants to merge 1 commit into
BeamMW:masterfrom
profinch:fix/enumhdrs-range
Open

profinch wants to merge 1 commit into
BeamMW:masterfrom
profinch:fix/enumhdrs-range

Conversation

@profinch

@profinch profinch commented Oct 6, 2026

Copy link
Copy Markdown

Fixes #2153.

Node::Peer::OnMsg(proto::EnumHdrs) started the pack at Min, but SendHdrs walks backwards, so a request for [Min, Max] returned the headers ending at Min. The handler now starts at the top of the range:

  • range of g_HdrPackMaxSize headers or fewer: from Max down to Min;
  • longer range: its first g_HdrPackMaxSize headers (Min … Min + 2047), so a client can page on from the last one + 1.

Single-height requests (Min == Max), the only kind in the tree (CLI, ManagerStd, wallet API block_details), return the same header as before.

Test. node_test already sends EnumHdrs [0, MaxHeight] from its FlyClient but never looked at the answer. It now checks that the headers are consecutive, start at height 1, and number more than 1 and at most g_HdrPackMaxSize.

  • without the fix: node_test fails, Test failed! Line=3980, Expression: v.size() > 1 (one header came back);
  • with the fix: node_test passes (macOS arm64, RelWithDebInfo, via ctest).

The truncation branch (a range longer than 2048 headers) is not reached by node_test, whose chain is shorter; it uses FindActiveAtStrict, the same lookup FindAtivePastHeight uses for constant-span chains.

node_test.cpp has mixed line endings; the change was inserted byte-for-byte so the diff stays 11 lines.

The header pack is built backwards from its top, but the handler started
it at Min, so a request for [Min, Max] got the headers ending at Min.
Start at Max (or at Min + g_HdrPackMaxSize - 1 for a longer range).
node_test now checks the [0, MaxHeight] request it already makes.
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.

node: EnumHdrs returns the headers ending at Min instead of the range [Min, Max]

1 participant