Conversation
GetBlockReceipts resolved the requested block to a concrete height for the block lookup but then called BlockResults with blockNum.CmtHeight(), which is nil for the "latest" tag and makes CometBFT return the results of its current head. If a block was committed in between, the txs of block H were paired with the results of block H+1, which either panics with an index out of range in EthMsgsFromCometBlock (surfacing as "method handler crashed") or silently returns receipts with the wrong status/gasUsed/logs. Always fetch the results of resBlock.Block.Height, like the other block queries do, and guard against a nil block before dereferencing it. Closes cosmos#1280
Contributor
|
PR author is not in the allowed authors list. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1286 +/- ##
==========================================
+ Coverage 67.58% 67.68% +0.09%
==========================================
Files 321 321
Lines 23467 23467
==========================================
+ Hits 15861 15884 +23
+ Misses 6426 6396 -30
- Partials 1180 1187 +7
🚀 New features to boost your workflow:
|
kriss39
force-pushed
the
fix/rpc-block-receipts-height
branch
from
September 22, 2026 11:49
656f637 to
1d9dd08
Compare
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.
Description
GetBlockReceiptsresolved the requested block to a concrete height for the block lookup but then calledBlockResultswithblockNum.CmtHeight(), which isnilfor thelatesttag and makes CometBFT return the results of its current head. If a block was committed in between, the txs of block H were paired with the results of block H+1:EthMsgsFromCometBlockeither panics with an index out of range (surfacing to the client asmethod handler crashed) or the receipts silently carry the status/gasUsed/logs of the wrong block. TheresBlock == nilbranch also dereferenced*blockNum.CmtHeight(), nil forlatest.This PR fetches the results of
resBlock.Block.Height, like every other block query in the backend already does, and guards against a nil block.Review notes:
rpc/backend/blocks.go: the two-line change inGetBlockReceipts.tests/integration/rpc/backend/test_block_receipts.go:TestGetBlockReceiptsLatestregistersBlock(&10)with one indexed eth tx and aBlockResults(nil)mock that returns an empty newer block; onmainit panics withindex out of range [0] with length 0, with the fix it returns the receipt of block 10 and asserts thatBlockResultsis never called with a nil height.Closes: #1280
Author Checklist
All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.
I have...
mainbranch