Skip to content

feat(mempool): revert transactions after 3 failures#1832

Open
Mirko-von-Leipzig wants to merge 2 commits intomirko/mempool-v4from
mirko/mempool-tx-reverting
Open

feat(mempool): revert transactions after 3 failures#1832
Mirko-von-Leipzig wants to merge 2 commits intomirko/mempool-v4from
mirko/mempool-tx-reverting

Conversation

@Mirko-von-Leipzig
Copy link
Collaborator

@Mirko-von-Leipzig Mirko-von-Leipzig commented Mar 24, 2026

This PR changes the mempool behaviour when rolling back blocks and batches. Transactions are now reverted once they have participated in more than three failed batches and blocks.

The current behaviour is that transactions are never reverted for batch failures, and always reverted for block failures.

The intention here is to weed out transactions which cause these failures e.g. due to a bug in the prover/mempool/node. The new implementation is a bit more forgiving and gives innocent bystander transactions a couple of chances to avoid the buggy one.

The limit of three is arbitrary, but I also don't see a good reason to make this more configurable. Fight me :)

This PR builds on the mempool refactor in #1820.

Closes #594

@Mirko-von-Leipzig Mirko-von-Leipzig added the no changelog This PR does not require an entry in the `CHANGELOG.md` file label Mar 24, 2026
let count = self.failures.entry(tx).or_default();
*count += 1;

if *count > Self::FAILURE_LIMIT {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
if *count > Self::FAILURE_LIMIT {
if *count >= Self::FAILURE_LIMIT {

Copy link
Collaborator Author

@Mirko-von-Leipzig Mirko-von-Leipzig Mar 25, 2026

Choose a reason for hiding this comment

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

I think its correct as > no? You're allowed to fail N times. Though I guess title and docs sort of conflict :D

}
let failed_txs = block
.iter()
.flat_map(|batch| batch.transactions().as_slice().iter().map(TransactionHeader::id));
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would it be possible / desirable for us to pinpoint which transactions actually failed rather than treating all as failed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

iiuc this is supposed to only occur if there is a bug in the proving system, or one of the kernels, or the batch was invalid. As in, this is a really unexpected outcome once we are at this stage.

But maybe there is some information that could be surfaced. cc @PhilippGackstatter

@bobbinth bobbinth requested a review from igamigo March 25, 2026 06:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no changelog This PR does not require an entry in the `CHANGELOG.md` file

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants