Skip to content

UnconfirmedTxs improvements (CON-322)#3546

Merged
pompon0 merged 15 commits into
mainfrom
gprusak-unconfirmed-txs
Jun 5, 2026
Merged

UnconfirmedTxs improvements (CON-322)#3546
pompon0 merged 15 commits into
mainfrom
gprusak-unconfirmed-txs

Conversation

@pompon0
Copy link
Copy Markdown
Contributor

@pompon0 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.

@cursor
Copy link
Copy Markdown

cursor Bot commented Jun 4, 2026

PR Summary

Medium Risk
Touches mempool indexing, CheckTx validation, and EVM RPC lookup paths; behavior change for unconfirmed tx listing (snapshot vs live scan) and stricter EVM CheckTx responses.

Overview
Speeds up mempool RPC and eth_getTransactionByHash by indexing EVM transactions by hash and serving unconfirmed txs from a cached snapshot instead of scanning the whole pool.

Mempool: CheckTx now returns EVMHash (common.Hash); wrapped EVM txs store that hash, with a byEvmHash map, duplicate-hash rejection, and RecentSnapshot updated when inclusion order is recomputed. UnconfirmedTxs paginates that snapshot (not ReapTxs). EvmTxByHash on the local client/mempool resolves pending txs in O(1).

EVM context: EVMTxHash in SDK context is common.Hash end-to-end; ABCI EvmTxInfo.TxHash is hex at the boundary. CheckTxSafe requires a non-zero EVMHash for EVM responses.

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.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 4, 2026

The latest Buf updates on your PR. Results from workflow Buf / buf (pull_request).

BuildFormatLintBreakingUpdated (UTC)
✅ passed✅ passed✅ passed✅ passedJun 5, 2026, 8:54 AM

@pompon0 pompon0 requested review from sei-will and wen-coding June 4, 2026 07:39
Comment thread sei-tendermint/internal/rpc/core/mempool.go
@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 4, 2026

Codecov Report

❌ Patch coverage is 81.81818% with 16 lines in your changes missing coverage. Please review.
✅ Project coverage is 58.37%. Comparing base (1a1b8cd) to head (7ff9bcb).
⚠️ Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
sei-tendermint/internal/p2p/testonly.go 50.00% 5 Missing and 2 partials ⚠️
evmrpc/tx.go 85.71% 2 Missing and 1 partial ⚠️
sei-tendermint/internal/mempool/mempool.go 50.00% 2 Missing ⚠️
sei-tendermint/rpc/client/local/local.go 0.00% 2 Missing ⚠️
app/abci.go 50.00% 1 Missing ⚠️
sei-tendermint/internal/mempool/tx.go 95.23% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            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     
Flag Coverage Δ
sei-chain-pr 69.45% <81.81%> (?)
sei-db 70.41% <ø> (ø)
sei-db-state-db ?

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
app/ante/evm_checktx.go 40.21% <100.00%> (ø)
app/legacyabci/deliver_tx.go 96.05% <100.00%> (ø)
evmrpc/tests/mock_client.go 50.00% <100.00%> (+0.66%) ⬆️
sei-cosmos/baseapp/abci.go 64.24% <100.00%> (ø)
sei-cosmos/baseapp/baseapp.go 75.78% <100.00%> (ø)
sei-cosmos/client/context.go 86.07% <ø> (ø)
sei-cosmos/types/context.go 90.53% <100.00%> (ø)
sei-tendermint/abci/types/types.go 68.88% <ø> (ø)
sei-tendermint/internal/proxy/proxy.go 91.93% <100.00%> (+0.26%) ⬆️
sei-tendermint/internal/rpc/core/mempool.go 67.01% <100.00%> (+2.06%) ⬆️
... and 7 more

... and 82 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ 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{}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 188137e. Configure here.

Copy link
Copy Markdown
Contributor Author

@pompon0 pompon0 Jun 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WAI

@pompon0 pompon0 added this pull request to the merge queue Jun 4, 2026
Comment thread sei-tendermint/internal/rpc/core/mempool.go
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jun 4, 2026
@pompon0 pompon0 enabled auto-merge June 5, 2026 08:53
@pompon0 pompon0 added this pull request to the merge queue Jun 5, 2026
Merged via the queue into main with commit 6662060 Jun 5, 2026
55 checks passed
@pompon0 pompon0 deleted the gprusak-unconfirmed-txs branch June 5, 2026 09:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants