Repository navigation
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2153.
Node::Peer::OnMsg(proto::EnumHdrs)started the pack atMin, butSendHdrswalks backwards, so a request for[Min, Max]returned the headers ending atMin. The handler now starts at the top of the range:g_HdrPackMaxSizeheaders or fewer: fromMaxdown toMin;g_HdrPackMaxSizeheaders (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 APIblock_details), return the same header as before.Test.
node_testalready sendsEnumHdrs [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 mostg_HdrPackMaxSize.node_testfails,Test failed! Line=3980, Expression: v.size() > 1(one header came back);node_testpasses (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 usesFindActiveAtStrict, the same lookupFindAtivePastHeightuses for constant-span chains.node_test.cpphas mixed line endings; the change was inserted byte-for-byte so the diff stays 11 lines.