Repository navigation
[UTXO-BUG] Ignore expired UTXO mempool claims - #4235
bkallday1122 wants to merge 1 commit into
Conversation
|
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! |
gl11tchy
left a comment
There was a problem hiding this comment.
Approved. I reviewed the expired-mempool-lock path and the fix covers the important public boundaries: mempool_add clears expired rows before pool-size and input-claim checks, mempool_get_block_candidates prunes before selecting transactions for mining, and mempool_check_double_spend no longer treats expired claims as active locks.
Validation performed locally:
- python3 node/test_utxo_db.py => 53 passed
- python3 -m py_compile node/utxo_db.py node/test_utxo_db.py => OK
- git diff --check origin/main...HEAD -- node/utxo_db.py node/test_utxo_db.py => OK
The new regression tests cover both halves of the issue: expired transactions are not returned as block candidates, and a fresh replacement spend can enter after the old claim expires. The shared transaction-scoped clear helper also avoids the prior split cleanup behavior.
jaxint
left a comment
There was a problem hiding this comment.
LGTM! Nice work on this contribution. Approved ✅
jaxint
left a comment
There was a problem hiding this comment.
LGTM! Thanks for contributing. Approved.
saim256
left a comment
There was a problem hiding this comment.
The expiry fix itself is directionally correct and the two new regressions pass locally, but I am requesting changes because the branch is stale/conflicting and its advertised full validation no longer passes on this platform.
Local validation:
python -m pytest node\test_utxo_db.py::TestUtxoDB::test_mempool_expired_tx_not_returned_or_locked node\test_utxo_db.py::TestUtxoDB::test_mempool_add_releases_expired_input_claim -q-> 2 passedpython -m py_compile node\utxo_db.py node\test_utxo_db.py-> passedgit diff --check origin/main...HEAD -- node\utxo_db.py node\test_utxo_db.py-> passed
Blocking validation failure:
python node\test_utxo_db.py-> failed:PermissionError: [WinError 32]intearDown()fortest_mining_reward_over_cap_rejectedpython -m pytest node\test_utxo_db.py -q-> failed: 1 failed, 52 passed, same Windows temp DB lock
This looks like the branch predates the later DB-handle cleanup for rejected minting rewards, so it needs to be rebased onto current main and revalidated. Once rebased, the actual mempool-expiry changes should be easy to re-check: clearing expired rows before admission, candidate selection, and double-spend checks is the right shape for the reported stale-lock issue.
No production service testing was performed.
jaxint
left a comment
There was a problem hiding this comment.
Code review: LGTM! Thanks for contributing to RustChain. Approved.
loganoe
left a comment
There was a problem hiding this comment.
Approved after validating expired UTXO mempool claim handling.
What I checked:
- Expired mempool rows are cleared inside the same SQLite transaction before pool-size checks, double-spend checks, candidate selection, and double-spend queries.
- Expired transactions no longer appear in block candidates and no longer keep their input boxes locked.
- A fresh replacement transaction using the same input is accepted after the prior claim expires.
Validation run locally:
PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 timeout 240 uv run --no-project --with pytest python -m pytest -q node/test_utxo_db.py-> 53 passedpython3 -m py_compile node/utxo_db.py node/test_utxo_db.py-> passedgit diff --check origin/main...HEAD -- node/utxo_db.py node/test_utxo_db.py-> passedpython3 tools/bcos_spdx_check.py --base-ref origin/main-> BCOS SPDX check: OK
No blocker found.
TJCurnutte
left a comment
There was a problem hiding this comment.
Hermes Agent review — APPROVED
I reviewed the diff for PR #4235: [UTXO-BUG] Ignore expired UTXO mempool claims
Validation proof
git diff --check: PASSBCOS SPDX check: PASSadded-line secret-pattern scan: PASSpython py_compile: PASSfocused changed-test pytest: PASS
Scope checked
node/test_utxo_db.py (+63/-0), node/utxo_db.py (+60/-23)
Review note
The changed surface is bounded and the local gates above did not expose whitespace, SPDX, syntax, focused-test, or added-secret regressions. This approval is for the submitted diff at the reviewed head; payout/merge authority remains with the maintainers.
jaxint
left a comment
There was a problem hiding this comment.
LGTM! Thanks for contributing. Approved.
jaxint
left a comment
There was a problem hiding this comment.
LGTM! Thanks for contributing. Approved.
HCIE2054
left a comment
There was a problem hiding this comment.
LGTM! Great contribution to the RustChain ecosystem. Thanks for keeping the codebase clean and well-tested. Approved ✅
|
Closing as stale branch — would cause destructive deletions if merged. Your branch is 1084 commits behind current main. Filed during the May 11-13 contributor burst, the codebase has since moved substantially. GitHub's Bounty credit acknowledged where applicableMost of the canonical fixes from your work-period have already shipped via other contributors' parallel PRs that landed earlier this week. Specific cases credited via the Codex audit batches:
If you want fresh reviewRebase against current main and verify your diff matches the size of your original changes: If the deletion count is much higher than what you intended, the branch is still picking up stale assumptions — recreate from a fresh main. Thanks for the contribution work. |
Summary
Fixes an expired UTXO mempool lock issue for bounty Scottcjn/rustchain-bounties#2819.
Expired mempool rows were only removed when callers explicitly invoked
mempool_clear_expired(). Normal admission, block-candidate selection, and double-spend checks did not clear or ignore expired rows. As a result, an expired transaction could still be returned to block producers and could keep its input marked as claimed, blocking a valid replacement until some separate cleanup path happened to run.Bounty Classification
Root Cause
utxo_mempool.expires_atwas written duringmempool_add(), but the other public mempool boundaries did not enforce it:mempool_get_block_candidates()selected all rows regardless ofexpires_at.mempool_check_double_spend()treated expiredutxo_mempool_inputsclaims as active locks.mempool_add()checked pool size and existing input claims before pruning expired entries.Expected vs Actual
Expected:
Actual before this patch:
expires_atin the past was still returned bymempool_get_block_candidates().mempool_check_double_spend(box_id)returnTrue.Fix
_mempool_clear_expired_locked()helper.BEGIN IMMEDIATEbefore mempool admission checks.mempool_clear_expired()API, now using the shared helper.Validation
python3 -m pytest node/test_utxo_db.py -qwas not available becausepytestis not installed in this local environment.Refs Scottcjn/rustchain-bounties#2819