explorer: fix stale per-element state and ignored adj in /blocks - #2079
Open
Maxnflaxl wants to merge 1 commit into
Open
explorer: fix stale per-element state and ignored adj in /blocks#2079Maxnflaxl wants to merge 1 commit into
Maxnflaxl wants to merge 1 commit into
Conversation
Maxnflaxl
force-pushed
the
issue/2077-2078
branch
from
August 18, 2026 09:56
9570cb1 to
f5e404c
Compare
Maxnflaxl
marked this pull request as draft
August 25, 2026 21:16
Maxnflaxl
force-pushed
the
issue/2077-2078
branch
from
August 27, 2026 21:11
d880e33 to
f5e404c
Compare
Maxnflaxl
marked this pull request as ready for review
August 27, 2026 21:12
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.
Summary
Two bugs in the explorer's
/blocks(plural) endpoint, reported by @dbadol as #2077 and #2078. Both live inAdapter::get_blocks, so they're fixed together.#2077 — every element carries the first block's header
Regression from ba181a9, which replaced the old per-row
get_block_impl()walk with aStateID/m_Numberloop. The loop advances the row but never reloads the state for it, so every element after the first is rendered against the first block'sBlock::SystemState::Full:sid.m_Number.v++; sid.m_Row = _nodeBackend.FindActiveAtStrict(sid.m_Number); // `s` left staleBecause the body is read from
sid.m_Row(correct) while the header and context come froms(stale), the damage is wider than the report: on top ofhandinfo, thetotalstable (Chainwork,Current Emission,Current Circulation,Size Compressed,Size Archive) andoutputs[].Maturityare all wrong. Verified against mainnet — for block 27730 in aheight=27729&n=4series, emission reads2,218,320instead of2,218,400and the coinbase maturity27969instead of27970.inputsandkernelswere the only correct sections.Fixed by reloading the state after each step.
#2078 —
adjis ignoredadjsimply never reached the backend:on_request_blocksparsed onlyheightandn, andget_blockshad noadjparameter. What looked like "defaults toadj=1" wasFindBlockByHeight→FindAtivePastHeightsnapping to the next active height unconditionally, which also meant/blockshad no not-found path at all.Fixed per the three points in the issue:
adjis parsed and passed through, and applies to the first block of the series only; the rest always follow upwards.heightwith noadjreturns{"found":false,"height":N}, matching/block.nentries.To keep
/blockand/blocksfrom drifting apart again, the first-block resolution is now shared:get_block's logic is factored intoResolveBlock(sid, s, h, height, adj)and both endpoints call it.Changes
explorer/server.cpp—on_request_blocksparsesadjand passes it on.explorer/adapter.h—get_blocks(Height, uint64_t, int adj).explorer/adapter.cpp— newResolveBlockhelper shared withget_block;get_blocksrefreshes the state per element, honorsadjfor the first block, and emits not-found placeholders.Behavior
blocks?height=2743&n=4blocks?height=2742&n=4(vacant)[{"found":false,"height":2742}]blocks?height=2742&n=4&adj=1blocks?height=2744&n=4&adj=-1nentries, tail isfound:falseTwo judgement calls worth a look, since the spec is ambiguous for PoS chains:
/blockstype-stable for clients. Easy to change if the bare object is preferred.tip+1,tip+2, …), which only carries meaning on PoW. On a PoS chain with gaps they should be read as "no block here", not as a height prediction.Closes #2077
Closes #2078