Skip to content

fix: ensure app and comet mempool parity - #689

Merged
fragwuerdig merged 3 commits into
mainfrom
fix/mp-parity
Oct 3, 2026
Merged

fragwuerdig merged 3 commits into
mainfrom
fix/mp-parity

Conversation

@fragwuerdig

@fragwuerdig fragwuerdig commented Sep 30, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Fixes #648: a tx could pass CheckTx, get dropped by PrepareProposal, and then stay in the CometBFT mempool forever, which blocked its sender.

  • dyncomm post handler now also runs in CheckTx/ReCheckTx. It already ran in PrepareProposal/ProcessProposal, so a tx with only enough gas for the ante handler got into the mempool and could never be included. Now CheckTx rejects it up front.
  • Parity CheckTx handler keeps the CometBFT mempool in line with the app-side mempool:
    • On ReCheckTx evict txs that are no longer in the app-side mempool (e.g. dropped by PrepareProposal).
    • On any runTx() error, it removes the tx from the app-side mempool too. BaseApp inserts the tx before the post handler runs, so a post-handler failure would otherwise leave it behind.
  • Adds FifoMempool.Contains(). It always returns true when the mempool is disabled.

Tests

  • Unit tests for Contains and the parity handler (eviction, removal after a failed ante/post handler, other senders' txs untouched).
  • App-level tests in x/dyncomm/ante:
    • Gas that is enough for CheckTx is also enough for PrepareProposal/ProcessProposal.
    • A tx with tight gas is rejected by CheckTx and by ReCheckTx, with no leftover in the app-side mempool.
    • Regression test: a tx missing from the app-side mempool is evicted on recheck.

Consensus

Not consensus breaking. The changes only affect CheckTx/ReCheckTx and local mempool state. PrepareProposal, ProcessProposal and FinalizeBlock behave identically, so patched and unpatched validators can run side by side. Unpatched nodes can still hold stuck txs (#648) until they upgrade.

@fragwuerdig

Copy link
Copy Markdown
Collaborator Author

I was able to patch my node and inject Moonshot's unjail transaction directly into my node. My node did not AppHash and Moonshot validator is now unjailed.

…mm post handler only when msgs execute

Fixes #648: a MsgEditValidator whose gas limit covered the ante handler but
not the dyncomm post handler passed CheckTx, ran out of gas in
PrepareProposal and was dropped from the app-side mempool only. CometBFT kept
it forever and every later tx of the sender stayed blocked behind it.

- dyncomm post handler: run only in FinalizeBlock and simulate, the modes that
  execute msgs. CheckTx, PrepareProposal and ProcessProposal now charge the
  same gas, so a tx that enters the mempool can be proposed; with too little
  gas it fails in FinalizeBlock and consumes its sequence like any other
  out-of-gas tx. Running in simulate (previously skipped) makes --gas auto
  include the ~7k gas of SetTargetCommissionRate.
- Mempool parity CheckTx handler: on ReCheckTx, evict txs from the CometBFT
  mempool that are no longer in the app-side mempool, and remove txs that
  fail CheckTx after BaseApp inserted them. CheckTx errors honour --trace.

CONSENSUS BREAKING: ProcessProposal no longer charges the dyncomm post handler
gas, so nodes with and without this change disagree on proposals that
contain such txs. Requires a coordinated upgrade.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
fragwuerdig and others added 2 commits October 1, 2026 22:28
Empty handler to coordinate the chain-wide binary switch for the
dyncomm post handler change, which alters what ProcessProposal accepts.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@fragwuerdig
fragwuerdig merged commit 23105ee into main Oct 3, 2026
31 checks passed
@fragwuerdig
fragwuerdig deleted the fix/mp-parity branch October 3, 2026 19:39
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.

[BUG] Unable to change validator commission -- account sequence mismatch

2 participants