Repository navigation
fix(utxo): mint dual-write reward boxes on the settlement path prod uses - #8485
Merged
Merged
Conversation
finalize_epoch() mints UTXO reward boxes under UTXO_DUAL_WRITE, but production does not settle through it: cron -> POST /rewards/settle -> settle_epoch (= settle_epoch_rip200), which had no UTXO code at all. Rehearsed on a snapshot of the live DB with dual-write on: accounts were credited 1,500,000 uRTC and ZERO boxes were minted, i.e. the UTXO model falls a whole epoch pot (1.5 RTC) behind every epoch. Safe direction (mirror <= balance still holds) but /utxo/integrity would report the models disagreeing, growing daily. Mint from epoch_rewards, which BOTH settlement branches write, and hook both: the standard path and the anti-double-mining path, which returns early and is the branch production actually takes (rehearsal: ADM). Values come from the credited uRTC x100, never re-truncated (#8481), and each box is registered as an account mirror, joined on the mining_reward tx so a user's /utxo/transfer box at the same height is never tagged (#8394). Failure raises -> the caller rolls back -> the epoch stays unsettled, rather than committing a half-mirrored settlement. utxo_db.apply_transaction: set (and restore) row_factory on a caller connection. settle_epoch_rip200 opens a plain sqlite3.connect, and the reads inside apply_transaction use row['col'] -> TypeError. Found by the new tests, not in review. Rehearsal after the fix: ADM path minted 8 boxes = exactly the 150,000,000 nRTC credited, all mirrored, 0 mirror>balance, 0 unmirrored. 0 regressions (4216 -> 4219); fetchall guard 11/11. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Signed-off-by: Scott <scottbphone12@gmail.com>
Contributor
RTC RewardThis merged PR earned 5 RTC — sent to |
Contributor
|
| Metric | Value |
|---|---|
| Trust Score | 36/100 |
| Certificate ID | BCOS-2545068b |
| Tier | L2 (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.
This is the last blocker for enabling UTXO dual-write. Found by rehearsing a settlement on a snapshot of the live database.
The gap
finalize_epoch()mints UTXO reward boxes underUTXO_DUAL_WRITE. Production doesn't settle through it. Its cron callsPOST /rewards/settle→settle_epoch(=settle_epoch_rip200), which had no UTXO code at all.Rehearsed on the live DB snapshot with dual-write on:
finalize_epoch(fixed in #8481/#8394)settle_epoch_rip200(what prod runs)The UTXO model would fall a full epoch pot (1.5 RTC) behind every epoch. It's the safe direction (nothing double-spends), but
/utxo/integritywould report the models disagreeing, and the gap would grow daily.Fix
epoch_rewards, which both settlement branches write, so the mint can't miss the branch taken.mining_rewardtx, so a user's transfer box at the same height is never tagged (fix(utxo): register epoch mining-reward boxes as account-mirror provenance (danaher #2819, reward path) #8394).A bug the tests caught in my own change
settle_epoch_rip200opens a plainsqlite3.connect, whileapply_transactionreads rows by name (row['col']) →TypeErrorin production.apply_transactionnow sets and restoresrow_factoryon a caller connection, which protects every caller.Verification
mirror>balance, 0 unmirrored boxes.Dual-write remains off. This makes enabling it correct when you choose to.
🤖 Generated with Claude Code