Skip to content

Mempool preconfs: Cleanup contract_users only after rollback#3268

Draft
Dentosal wants to merge 7 commits into
masterfrom
dento/rollback_preconfirmed_transaction-prcomment-fix
Draft

Mempool preconfs: Cleanup contract_users only after rollback#3268
Dentosal wants to merge 7 commits into
masterfrom
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
Touches txpool commit/removal flow and collision-manager bookkeeping; incorrect ordering could leave stale contract_users entries or break rollback-driven evictions.

Overview
Fixes a preconfirmation rollback bug by splitting tx removal handling into committed vs evicted paths so contract_users entries remain available during rollback.

The CollisionManager API gains on_committed_transaction (removal without contract_users cleanup) and remove_from_contract_users (deferred contract-user cleanup), with BasicCollisionManager implementing the new behavior. pool.rs commit paths now use the committed variant and return removed pool transactions, and pool_worker.rs defers contract_users cleanup until after rollback reconciliation per tentative height (and after canonical-block processing).

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

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

.on_removed_transaction(storage_entry);
}
self.register_transaction_counts();
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Near-duplicate functions risk diverging during future maintenance

Low Severity

update_components_and_caches_on_committed is a near-exact copy of update_components_and_caches_on_removal, differing only in whether on_committed_transaction or on_removed_transaction is called on the collision manager. If future maintenance adds or changes a step in one function but not the other, it will silently introduce a bug. A single shared helper parameterized by which collision-manager method to invoke would eliminate this duplication.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 8671b88. Configure here.

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