UnconfirmedTxs improvements (CON-322)#3546
Conversation
pompon0
commented
Jun 4, 2026
- UnconfirmedTxs was computationally expensive, because it did scan of the whole mempool. I have made it access a recent mempool snapshot, since the original semantics was not giving any useful guarantees anyway
- Made eth_getTransactionByHash access the mempool directly (O(1) lookup) instead of first dumping the mempool via UnconfirmedTxs and then scanning its content.
PR SummaryMedium Risk Overview Mempool: CheckTx now returns EVMHash ( EVM context: EVMTxHash in SDK context is RPC: GetTransactionByHash uses EvmTxByHash instead of paging UnconfirmedTxs and scanning. Tests and P2P/state-sync helpers propagate EvmTxByHash stubs and return errors from WaitForConn / Connect instead of panicking. Reviewed by Cursor Bugbot for commit 7ff9bcb. Bugbot is set up for automated code reviews on this repo. Configure here. |
|
The latest Buf updates on your PR. Results from workflow Buf / buf (pull_request).
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #3546 +/- ##
==========================================
- Coverage 59.12% 58.37% -0.76%
==========================================
Files 2218 2144 -74
Lines 183132 174971 -8161
==========================================
- Hits 108285 102131 -6154
+ Misses 65082 63771 -1311
+ Partials 9765 9069 -696
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 188137e. Configure here.
| // Reset internal state. | ||
| inner.state.Store(txStoreState{}) | ||
| inner.byHash = map[types.TxHash]*WrappedTx{} | ||
| inner.byEvmHash = map[common.Hash]*WrappedTx{} |
There was a problem hiding this comment.
Stale snapshot after mempool compact
Medium Severity
RecentSnapshot is filled at the start of compact via inInclusionOrder, but txs removed during the compaction loop never update inner.snapshot. UnconfirmedTxs and callers like sei_content can therefore return transactions that are no longer in the mempool, while EvmTxByHash correctly misses them. Clear/Flush also leave a non-empty snapshot after the store is emptied.
Additional Locations (2)
Reviewed by Cursor Bugbot for commit 188137e. Configure here.

