fix(rpc): fall through to CometBFT on KV indexer miss to serve derive…#14
Open
AryaLanjewar3005 wants to merge 6 commits into
Open
fix(rpc): fall through to CometBFT on KV indexer miss to serve derive…#14AryaLanjewar3005 wants to merge 6 commits into
AryaLanjewar3005 wants to merge 6 commits into
Conversation
3 tasks
…t and getBlockByNumber
…Number, eth_getTransactionReceipt and eth_getBlockReceipts
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.
…d tx receipts
Description
fix(rpc): fall through to CometBFT on KV indexer miss to serve derived tx receipts
Problem
On the donut testnet, Blockscout was indexing only 15–22% of blocks per day after the
evm-v0-4-0upgrade, leaving ~80% of blocks silently unindexed.Push Chain produces two classes of EVM transactions:
MsgEthereumTx) — signed by a user wallet, stored in the KV indexerDerivedEVMCall) — auto-generated by Cosmos modules (x/uexecutor,x/utss) for Universal Transactions inbound from Solana, Ethereum, BNB, Arbitrum etc.Both types are included in the
transactions[]array returned byeth_getBlockByNumber. However,eth_getTransactionReceiptreturnednullfor derived tx hashes becausekv_indexer.goonly stores native txs — it skips everything that isn't aMsgEthereumTx:When
GetTxByEthHashwas called with a derived hash, the KV indexer returned "not found" and the function immediately returned an error — never attempting the CometBFT fallback that sits below it and is fully capable of resolving derived txs.Before
v0.4.0, the upstream change8fb90ba2("get receipt should not return error on tx not found") had the node returning(nil, err)for missing receipts, which the RPC layer surfaced as a JSON-RPC error response. Blockscout handled errors gracefully by skipping those hashes. After8fb90ba2, the same miss returns(nil, nil), which the RPC layer surfaces as a JSON-RPC null result. Blockscout treats null differently — it keeps the hash in its processing pipeline and crashes with aKeyErrorwhen the receipt is absent from the merge map. The crash discards the entire block, including native txs that had valid receipts.We confirmed this live on the unpatched testnet: 4 out of 6 sampled transactions were derived txs with null receipts. In 3 out of 5 sampled blocks, every transaction was a derived tx — meaning Blockscout crashed on the whole block and recorded nothing.
Root Cause
GetTxByEthHashshort-circuited on a KV miss instead of falling through to the CometBFT indexer:Fix
When the KV indexer returns "not found", fall through to the CometBFT query instead of returning immediately:
The CometBFT path was already capable of handling derived txs. Derived txs emit
ethereum_txevents with theethereumTxHashattribute when they execute (x/vm/keeper/call_evm.go), soTxSearchfinds them.ParseTxIndexerResultdetectsDerivedTxType(99) and returns both aTxResultand a populatedTxResultAdditionalFields.GetTransactionReceiptthen builds a complete receipt from those additional fields viaparseDerivedTxFromAdditionalFields— the same path already used byeth_getBlockByNumberto surface derived txs in the block view.The same fix is applied to
GetTxByEthHashAndMsgIndexwhich has the identical pattern.Impact
eth_getTransactionReceiptnow returns a real receipt for derived tx hashesTesting
TestGetTxByEthHash_DerivedTxFallthrough— sets up a KV indexer that always returns "not found", mocks CometBFT to return a derived tx event response, and asserts thatGetTxByEthHashreturns non-nilTxResultAdditionalFieldswithType == DerivedTxType, correct sender and recipientTestGetTxByEthHash_NativeTxKVHit— regression test asserting native txs still return directly from KV without touching CometBFT./rpc/...tests passFiles Changed
rpc/backend/tx_info.go— fallthrough fix inGetTxByEthHashandGetTxByEthHashAndMsgIndexrpc/backend/tx_info_derived_test.go— new tests for the fixAuthor 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