Conversation
…venance (danaher #2819 receiver residual) Under UTXO_DUAL_WRITE=1, `balances` (account) is the primary ledger and UTXO boxes are its shadow; `account_mirror_boxes` records which boxes back account value, with the consensus invariant `mirror <= balance`. The mirror-input exclusion already blocks spending a mirror box via the UTXO path (input side, fixed earlier). The RESIDUAL: a /utxo/transfer credits the receiver's account balance AND creates a spendable UTXO output box for the receiver, but never registered that output as mirror provenance — so the same value was spendable via BOTH models (UTXO output box + account credit) = double spend. A total-only integrity check stays models_agree=True throughout (danaher-j private report, #2819 residual; latent today: UTXO_DUAL_WRITE is off on prod). Fix: - utxo_db.apply_transaction now exposes the authoritative tx_id on the caller's tx dict (tx['tx_id']), so the endpoint can locate the boxes it created. - The dual-write branch of /utxo/transfer registers every output box of the transfer (receiver at index 0, change at index 1) into account_mirror_boxes, so the unconditional mirror-input exclusion blocks re-spending them via UTXO; the value must move via the account path (which consumes the mirror on settle). - Added a fail-closed per-wallet `mirror <= balance` assertion (compared in nRTC: mirror value_nrtc vs balance amount_i64 * (UNIT//ACCOUNT_UNIT)); a violation rolls the transfer back rather than committing money that exists twice. Tests: node/test_utxo_dualwrite_receiver_provenance.py (3 tests) — receiver output is mirror-registered, receiver box is excluded from UTXO spendable candidates (double-spend closed), invariant holds. All 3 fail on origin/main and pass with this change. Existing UTXO suites: 154 passed, no new failures (17 pre-existing POC/isolation failures are identical on origin/main). RELATED (not fixed here, flagged for follow-up): the epoch mining-reward dual-write path (rustchain_v2_integrated...:~5698) likewise creates UTXO reward boxes without account_mirror_boxes provenance — same class, same latency behind UTXO_DUAL_WRITE=0. Keep UTXO_DUAL_WRITE=0 on prod until both are resolved. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KbyXP4eiiRYEa8GsQtQPhR
Contributor
|
| Metric | Value |
|---|---|
| Trust Score | 36/100 |
| Certificate ID | BCOS-a201b126 |
| Tier | L1 (not met) |
What does this mean?
The BCOS (Beacon Certified Open Source) engine scans for:
- SPDX license header compliance
- Known CVE vulnerabilities (OSV database)
- Static analysis findings (Semgrep)
- SBOM completeness
- Dependency freshness
- Test infrastructure evidence
- Review attestation tier
BCOS v2 Engine - Free & Open Source (MIT) - Elyan Labs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes the receiver-provenance residual of the danaher-j cross-model double-spend (#2819). Found by a GPT-6 Astra audit of the UTXO transfer path and source-verified against the full mirror model.
The model (verified)
Under
UTXO_DUAL_WRITE=1,balances(account) is the primary/total ledger (every epoch reward credits it); UTXO boxes are its shadow.account_mirror_boxesrecords which UTXO boxes back account value, with the consensus invariantmirror ≤ balance. For the two models not to double-count, every UTXO box representing account value must be mirror-tagged — so it can't be spent via the UTXO path independently of the account balance.The residual
The mirror-input exclusion (spending an existing mirror box via UTXO) was already fixed and made unconditional. But a
/utxo/transferunder dual-write:balances += amount), andapply_transaction,…and never registered that output as mirror provenance. So the receiver held
amountin both models — spendable via/utxo/transfer(the untagged box) and via/wallet/transfer/signed(the account credit) = the same value spent twice. A total-only integrity check staysmodels_agree=Truethroughout.Latent today (prod runs
UTXO_DUAL_WRITE=0); arms on any dual-write enablement.Fix
utxo_db.apply_transactionexposes the authoritative tx_id on the caller'stxdict (tx['tx_id']) so the endpoint can find the boxes it created./utxo/transferregisters every output box of the transfer (receiver idx 0, change idx 1) intoaccount_mirror_boxes→ the unconditional mirror-input exclusion then blocks re-spending them via UTXO; the value moves via the account path (which consumes the mirror on settle).mirror ≤ balanceassertion (compared in nRTC:value_nrtcvsamount_i64 × (UNIT//ACCOUNT_UNIT)— mirror boxes are nano-RTC, account is micro-RTC); a violation rolls back rather than committing money that exists twice.Tests (
node/test_utxo_dualwrite_receiver_provenance.py)mirror ≤ balanceholds after transfer.All 3 fail on
origin/mainand pass with this change. Existing UTXO suites: 154 passed, no new failures (the 17 pre-existing POC/isolation failures are identical onorigin/main).The epoch mining-reward dual-write path (
rustchain_v2_integrated_...:~5698) likewise creates UTXO reward boxes withoutaccount_mirror_boxesprovenance — same bug class, same latency behindUTXO_DUAL_WRITE=0. KeepUTXO_DUAL_WRITE=0on prod until both are resolved. Recommend danaher-j review; bounty for #2819 remains held pending payout destination.🤖 Generated with Claude Code
https://claude.ai/code/session_01KbyXP4eiiRYEa8GsQtQPhR