Repository navigation
Conversation
…IATE The per-tx DELETE loop in mempool_clear_expired() ran outside a transaction wrapper. A crash between the utxo_mempool_inputs DELETE and the utxo_mempool DELETE leaves inconsistent state: UTXO lock prematurely released while orphan mempool entry remains. Same class of bug already fixed in mempool_remove() (BUG-1). Apply identical BEGIN IMMEDIATE wrapping pattern. Found during Scottcjn#2819 UTXO Red Team audit. Refs: Scottcjn/rustchain-bounties#2819
|
Welcome to RustChain! Thanks for your first pull request. Before we review, please make sure:
Bounty tiers: Micro (1-10 RTC) | Standard (20-50) | Major (75-100) | Critical (100-150) A maintainer will review your PR soon. Thanks for contributing! |
|
Maintainer review: the stated partial-commit failure is not reproduced with the connection settings used here. Python sqlite3 opens an implicit transaction on the first DELETE under the default isolation mode; both DELETEs remain in that transaction until
|
IcanBENCHurCAT
left a comment
There was a problem hiding this comment.
LGTM — audit finding fix. Wraps paired DELETEs in BEGIN IMMEDIATE to prevent orphan UTXO rows on crash. ✅
|
Verified, with one correction to the framing. The concurrency hardening is real and worth taking: grabbing the write lock up front matches the So this is a safe belt-and-suspenders improvement, not the critical corruption fix the description implies. The change is correct and deadlock-safe ( |
Per @Scottcjn review on 2026-07-14: the previous description implied a partial-commit corruption that does not exist under Python sqlite3's default deferred isolation (the implicit txn is held until conn.commit(), so a mid-loop crash rolls back). The BEGIN IMMEDIATE wrap is still valuable as a hardening change: it matches the pattern already used by mempool_add and mempool_remove, and prevents concurrent writers from observing a half-cleared mempool. Update the docstring to describe the demonstrated lock-discipline benefit rather than the unproven corruption claim. Refs: Scottcjn#7954, Scottcjn/rustchain-bounties#2819
|
Thanks again for the thorough review, and you were right: the partial-commit What I changed (just pushed to the branch, commit
Scoring: I accept your re-tiering to minor / hardening. If this is still |
|
This PR has been inactive for 21 days. It will be closed in 14 days unless updated. |
|
Closing as superseded: |
Fix for UTXO Red Team Audit Finding #1
Refs: Scottcjn/rustchain-bounties#2819
Bug
mempool_clear_expired()deletes mempool inputs+mempool rows per-tx without transaction wrapper. Crash between DELETEs → orphan state (UTXO prematurely unlocked, stale mempool entry remains).Fix
Wrap delete loop in
BEGIN IMMEDIATE+COMMIT— same pattern asmempool_remove().Audit Finding
Full report: Scottcjn/rustchain-bounties#2819 (comment)
Wallet: RTCad35e1c1746560097ce9989abc140e0529b87163