Mempool preconfs: Cleanup contract_users only after rollback#3268
Mempool preconfs: Cleanup contract_users only after rollback#3268Dentosal wants to merge 7 commits into
Conversation
…fer contract_users cleanup until after rollback
PR SummaryMedium Risk Overview The Reviewed by Cursor Bugbot for commit 8671b88. Bugbot is set up for automated code reviews on this repo. Configure here. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ 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(); | ||
| } |
There was a problem hiding this comment.
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)
Reviewed by Cursor Bugbot for commit 8671b88. Configure here.


See #3264 (comment)
Description
Problem
on_removed_transactionwas called for both block-committed transactions and pool evictions, which meantcontract_usersentries were cleaned up beforerollback_preconfirmed_transactioncould use them to find and evict dependent pool transactions.Solution
Add
on_committed_transaction(same ason_removed_transactionbut skips theInput::Contractcleanup) andremove_from_contract_users(only theInput::Contractcleanup) to theCollisionManagertrait andBasicCollisionManager. Block-commitment paths inpool.rsnow useon_committed_transactionand return the removed pool transactions to their callers.pool_worker.rsdefersremove_from_contract_usersuntil after all preconfirmation rollback for the relevant block height is complete. This ensures rollback always observes the full set of contract dependents.Checklist
Before requesting review