Fix ethereum mempool/address index consistency#1
Open
ak-ux wants to merge 1 commit into
Open
Conversation
The address-level API responses were silently dropping pending txs that
blockbook's in-memory mempool had evicted, while per-tx responses still
returned them from the backend. Two root causes:
1. MempoolEthereumType.Resync() enforces a 48h timeout-based eviction on
its txEntries / addrDescToTx maps. Without `queryBackendOnMempoolResync`,
nothing ever re-populates them, so long-lived pending txs disappear from
address queries even though the backend still holds them.
-> Flip queryBackendOnMempoolResync to true in configs/coins/ethereum.json.
2. GetMempoolTransactions() sourced from eth_getBlockByNumber("pending"),
which only returns *executable* pending txs (nonce = last_confirmed + 1
and contiguous). Nonce-gap txs sitting in the queued pool were invisible,
so even with queryBackendOnMempoolResync=true they couldn't be re-hydrated.
-> Prefer txpool_content (available when the txpool namespace is
enabled, as it is with the current Erigon config). Fall back to the
pending-block view if the namespace isn't available.
Symptoms: /api/v2/tx/{hash} returns a pending tx with confirmations=0 and
status=-1, but /api/v2/address/{addr}?details=txs omits it and
/api/v2/address/{addr} shows unconfirmedTxs=0. After these changes both
endpoints agree for the duration the tx is held by the backend.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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
Address-level API responses silently drop pending txs that blockbook's in-memory mempool has evicted, while per-tx responses still return them from the backend. This produces visible inconsistency to API consumers (e.g. wallets showing
/api/v2/tx/{hash}as pending but/api/v2/address/{addr}returningunconfirmedTxs: 0).Root causes
MempoolEthereumType.Resync()enforces a 48h timeout eviction on itstxEntries/addrDescToTxmaps. WithoutqueryBackendOnMempoolResync, nothing re-populates them — long-lived pending txs disappear from address queries even though the backend still holds them.GetMempoolTransactions()sources frometh_getBlockByNumber("pending"), which only returns executable pending txs (nonce = last_confirmed + 1 and contiguous). Nonce-gap txs in the queued pool are invisible, so even with re-sync enabled they can't be re-hydrated.Changes
configs/coins/ethereum.json: flipqueryBackendOnMempoolResynctotrue.bchain/coins/eth/ethrpc.go: prefertxpool_content(both pending and queued buckets) when the txpool namespace is available; fall back to the pending-block view otherwise.Erigon is started with
--http.api "eth,net,web3,debug,txpool"in the current ethereum.json config, so the new RPC path is available out of the box.Test plan
GET /api/v2/address/{addr}→ confirmunconfirmedTxsreflects the geth mempool count.GET /api/v2/address/{addr}?details=txs→ confirm pending txs appear at the top oftransactions.GET /api/v2/tx/{hash}for a nonce-gap queued tx → should still return pending status.🤖 Generated with Claude Code