Skip to content

Mempool preconfs: Cleanup contract_users only after rollback#3268

Draft
Dentosal wants to merge 5 commits intomasterfrom
dento/rollback_preconfirmed_transaction-prcomment-fix
Draft

Mempool preconfs: Cleanup contract_users only after rollback#3268
Dentosal wants to merge 5 commits intomasterfrom
dento/rollback_preconfirmed_transaction-prcomment-fix

Conversation

@Dentosal
Copy link
Copy Markdown
Member

@Dentosal Dentosal commented Apr 17, 2026

See #3264 (comment)

Description

Problem

on_removed_transaction was called for both block-committed transactions and pool evictions, which meant contract_users entries were cleaned up before rollback_preconfirmed_transaction could use them to find and evict dependent pool transactions.

Solution

Add on_committed_transaction (same as on_removed_transaction but skips the Input::Contract cleanup) and remove_from_contract_users (only the Input::Contract cleanup) to the CollisionManager trait and BasicCollisionManager. Block-commitment paths in pool.rs now use on_committed_transaction and return the removed pool transactions to their callers. pool_worker.rs defers remove_from_contract_users until after all preconfirmation rollback for the relevant block height is complete. This ensures rollback always observes the full set of contract dependents.

Checklist

  • Breaking changes are clearly marked as such in the PR description and changelog
  • New behavior is reflected in tests
  • The specification matches the implemented behavior (link update PR if changes are needed)

Before requesting review

  • I have reviewed the code myself
  • I have created follow-up issues caused by this PR and linked them here

…fer contract_users cleanup until after rollback
@Dentosal Dentosal self-assigned this Apr 17, 2026
@cursor
Copy link
Copy Markdown

cursor Bot commented Apr 17, 2026

PR Summary

Medium Risk
Changes txpool commit/preconfirmation paths to defer contract_users cleanup, which affects mempool eviction/rollback ordering and could cause stale indexing or missed dependent evictions if the new sequencing is wrong.

Overview
Fixes preconfirmation rollback correctness by splitting collision-manager removal into committed vs evicted paths so contract_users entries remain visible until rollback reconciliation finishes.

Updates the CollisionManager API and BasicCollisionManager to add on_committed_transaction (skips contract_users cleanup) and remove_from_contract_users (does only that cleanup), then changes txpool commit flows to return removed pool txs and have pool_worker perform the deferred cleanup after processing stale preconfirmations for each block height.

Reviewed by Cursor Bugbot for commit 8830a0a. Bugbot is set up for automated code reviews on this repo. Configure here.

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 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 05a8cf7. Configure here.

Comment thread crates/services/txpool_v2/src/collision_manager/basic.rs
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.

1 participant