utxo_ledger (reference): failed apply_transaction leaks already-created outputs (supply inflation)
Maintainers usually reply within 10 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 79/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- python
- Domain
- blockchain
Research direction
Read rips/rustchain-core/utxo_ledger.py, especially UtxoSet.apply_transaction around lines 303–330 and add_transaction. Start by checking the duplicate-output probe and how failed applies restore spent inputs; add a regression test that verifies total supply is unchanged after failure. Done means failed applies leave no outputs behind, inputs remain spendable, and the mempool rejects duplicate outputs.
Written by the indexing model from the issue text.
Description
Found while reviewing #8302. It already exists on main and is not caused by that PR.
Where: rips/rustchain-core reference ledger, utxo_ledger.py UtxoSet.apply_transaction (around lines 303–330). This is reference code; the live node ledger (node/utxo_db.py) is not affected.
Bug: if one output's box_id collides with an earlier output in the same transaction, or with an existing UTXO, add_box raises after the earlier outputs were already inserted. The rollback only restores the spent inputs. The result:
apply_transactionreturns False;- the input is still spendable;
- the outputs created before the failure stay in the set.
In other words, value is minted. A probe with a 100-unit input went from supply 100 to 150.
Suggested fix (verified with the duplicate-box_id probe: supply stays 100):
- Before applying, reject the transaction if output ids are not unique, or if any of them already exists or was already spent.
- Record the outputs as they are created. On failure, remove them as well as restoring the inputs.
- Give
add_transaction(the mempool) the same duplicate-output check.
+ output_ids = [out.box_id for out in tx.outputs]
+ if len(output_ids) != len(set(output_ids)):
+ return False
+ if any(oid in self._boxes or oid in self._spent for oid in output_ids):
+ return False
spent_boxes = []
+ created_boxes = []
...
self.add_box(output, owner)
+ created_boxes.append((output.box_id, owner))
...
except Exception as e:
+ for box_id, owner in created_boxes:
+ self._boxes.pop(box_id, None)
+ self._by_address.get(owner, set()).discard(box_id)
A regression test should check that total supply is unchanged after a failed apply.
- Dominant language
- Python
- Stars
- 850
- Forks
- 589
- Avg merge
- 11d 7h
- Merged PRs (30d)
- 29
Getting set up
- Ships a Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Scottcjn/Rustchain
-
SDK CLI prints 0 RTC for canonical /wallet/balance responsesPossibly taken @ArtyormSatori claimed this 37 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Scottcjn/Rustchain#8580 · 4 comments ·
Maintainers usually reply within 10 days
-
utxo_ledger (reference): no coinbase authorization; mempool admits any input-less MINING_REWARDOpen
Difficulty 4/5 3-5 days Newbie friendliness 38/100
Maintainers usually reply within 10 days
-
[SECURITY] Non-finite and garbage weights pass the sybil-guard money chain — enrollment_weight has no isfinite guard and epoch_weight_to_units raises on NaN/infPossibly taken @thinhnx128 claimed this 28 days ago. Openbug
Difficulty 4/5 3-5 days Newbie friendliness 48/100
Scottcjn/Rustchain#8619 · 2 comments ·
Maintainers usually reply within 10 days
-
[Antiquity] Celeron M (Banias/Dothan, 2004) has no brand rule — real vintage silicon falls to x86 default 1.0x while its Pentium M twin earns 1.9xPossibly taken @Limm-web claimed this 60 days ago. Open
Difficulty 4/5 3-5 days Newbie friendliness 25/100
Scottcjn/Rustchain#8578 · 5 comments ·
Maintainers usually reply within 10 days
-
Python SDK attest --json returns status without running advertised attestation flowPossibly taken @ArtyormSatori claimed this 36 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 38/100
Scottcjn/Rustchain#8566 · 1 comment ·
Maintainers usually reply within 10 days
All issues in Scottcjn/Rustchain
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 69/100
daniel-ospina/tortoise#15308 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
Maintainers usually reply within 1 day
-
difficulty:easy prio:low type:bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
NatronGitHub/Natron#2405 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Jstar269/nakagawa-recomp#3746 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day