Skip to content

feat(mempool): back txpool RPC with app mempool PendingTxs#2127

Open
JayT106 wants to merge 9 commits into
jt/ethermint-insertTxfrom
jt/ethermint-txpool-pending
Open

feat(mempool): back txpool RPC with app mempool PendingTxs#2127
JayT106 wants to merge 9 commits into
jt/ethermint-insertTxfrom
jt/ethermint-txpool-pending

Conversation

@JayT106

@JayT106 JayT106 commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Stacked on #2119 — merge that first.

What this does

The txpool RPC namespace (txpool_content, _inspect, _status, _contentFrom) used to return empty results under mempool.type=app, because PendingTxs was a nil stub. This fills it in.

  • Repin ethermint to #1034.
  • Implement Manager.PendingTxs — a lock-free PoolSnapshot scan that returns the pooled EVM messages. Non-EVM and multi-message txs have no txpool representation, so they're skipped. A nil mempool reports nothing, so the namespace stays empty instead of panicking.

Result

Geth-compatible txpool inspection now works for app-mempool nodes.

Before merging

These pins move until the ethermint PRs land. Merge after #2119, then rebase this branch onto main.

@JayT106 JayT106 requested a review from a team as a code owner June 30, 2026 18:18
@JayT106 JayT106 requested review from ApacCronos and thomas-nguy and removed request for a team June 30, 2026 18:18
@coderabbitai

coderabbitai Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 21db335f-eff3-4e81-b8e8-8be4f517e8fc

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch jt/ethermint-txpool-pending

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

This comment has been minimized.

@JayT106 JayT106 self-assigned this Jun 30, 2026
@JayT106 JayT106 changed the base branch from jt/ethermint-insertTx to main June 30, 2026 18:27
@JayT106 JayT106 changed the base branch from main to jt/ethermint-insertTx June 30, 2026 18:27
@JayT106

JayT106 commented Jun 30, 2026

Copy link
Copy Markdown
Contributor Author

@claude

Comment thread app/mempool/manager.go Outdated
Comment thread app/mempool/manager.go Outdated
@JayT106

JayT106 commented Jul 1, 2026

Copy link
Copy Markdown
Contributor Author

@claude

@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Claude finished @JayT106's task in 1m 19s —— View job


PR Review

  • Gather context (diff, changed files)
  • Analyze implementation
  • Check for correctness bugs, security issues, performance concerns
  • Review tests
  • Post final review

Overall: looks correct and well-tested. No blocking issues.

app/mempool/manager.goPendingTxs()

The implementation is clean:

func (a *Manager) PendingTxs() []sdk.Tx {
    if a.mpool == nil {
        return nil
    }
    return PoolSnapshot(context.Background(), a.mpool)
}
  • The nil guard is correct — a.mpool is set at construction (NewManager) and never mutated after that, so reading it without mu is safe.
  • The lock-free pool scan via PoolSnapshot / sdkmempool.SelectBy is the established pattern here (same path used in RecheckTxs).
  • Ethermint's txpool layer does the EVM filtering on its side, so returning the full []sdk.Tx is the right contract.

app/mempool/helpers.go — metric label fix

- defer telemetry.MeasureSince(telemetry.Now(), "cronos", "mempool", "recheck", "snapshot")
+ defer telemetry.MeasureSince(telemetry.Now(), "cronos", "mempool", "pool", "snapshot")

The "recheck" label was misleading — PoolSnapshot is called from both the recheck path and now from PendingTxs. Renaming to "pool"."snapshot" is the right fix and proactively addresses the automated bot review comment.

Tests

Unit tests (manager_test.go): solid coverage — nil-pool path, and a fakePool with both txs returned. The fakePool.SelectBy implementation correctly matches the sdkmempool.SelectBy contract.

Integration tests (test_app_mempool.py): comprehensive — all four endpoints have shape tests, and test_txpool_pending_tx_visible is appropriately marked @pytest.mark.flaky(max_runs=3) for the timing race. The pytest.xfail for the "tx already mined" case is the right call.

One minor observation on the integration test:

def _pending_for(pool_pending):
    return pool_pending.get(sender.lower()) or pool_pending.get(sender)

or short-circuits correctly here: pool_pending.get(sender.lower()) returns None if the key is absent, so it falls back to sender. But if the lower-cased key exists and returns an empty dict {}, it would fall through to the checksummed key too (empty dict is falsy). In practice the txpool always returns a non-empty dict for a sender with pending txs, so this is fine — not a bug, just a subtle edge.

context.Background() in PendingTxs

Consistent with RecheckTxs line 283. The txpool RPC is low-frequency (polled by clients, not per-message), so there's no concern about an uncancellable context causing latency buildup.

Automated review comments status

  • "recheck" metric label ambiguity → ✅ already fixed in this PR (renamed to "pool")
  • MsgEthereumTx pre-allocation nit → belongs to the ethermint side, not this file — nothing to do here

Breaking changes

None. This is a pure read path (txpool RPC). No state mutations, no message type changes, no store migrations.


Comment thread app/mempool/manager.go Outdated
JayT106 added 8 commits July 2, 2026 13:47
Repin ethermint to PR #1019 head (stacked on #1016), which wires the txpool
RPC namespace (content/inspect/status/contentFrom) to MempoolClient.PendingTxs.

Implement Manager.PendingTxs: lock-free PoolSnapshot scan returning pooled EVM
messages; skips non-EVM/multi-message txs; nil mpool reports none.
- Rename PoolSnapshot telemetry label recheck→pool; snapshot is now called
  from both recheck and txpool RPC paths so the label was misleading
- Drop over-eager capacity hint in PendingTxs; EVM:non-EVM ratio unknown
- Add missing blank line in manager_test.go (gofmt / CI lint fix)
Stacked on #1016; adds txpool RPC namespace backed by MempoolClient.PendingTxs.
Covers txpool_content, txpool_inspect, txpool_status, txpool_contentFrom:
- shape tests (always pass): verify endpoints respond with {pending,queued}
- test_txpool_pending_tx_visible: submit tx, query pool immediately, assert
  tx appears in all four endpoints; @flaky(3) for reap_interval race.
Extract _assert_pool_dict_shape to deduplicate the 3 identical dict-shape
assertions. Add missing pytest.xfail guard for inspect_sender None case
(timing race path identified in code review).
PR #1034 consolidates the txpool namespace implementation (content/inspect/status/contentFrom)
previously split across #1016 + #1019.
@JayT106 JayT106 force-pushed the jt/ethermint-txpool-pending branch from 558b9b8 to 53e468f Compare July 2, 2026 17:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants