[UTXO-BUG] CRIT-2: Dual-write decimal mismatch inflates account model 10x#2068
Closed
ArokyaMatthew wants to merge 1 commit intoScottcjn:mainfrom
Closed
[UTXO-BUG] CRIT-2: Dual-write decimal mismatch inflates account model 10x#2068ArokyaMatthew wants to merge 1 commit intoScottcjn:mainfrom
ArokyaMatthew wants to merge 1 commit intoScottcjn:mainfrom
Conversation
… 10x The UTXO model uses UNIT = 10^8 (8 decimal places), but the dual-write path in utxo_endpoints.py line 320 converts with 10^9 (9 decimals): amount_i64 = int(amount_rtc * 1_000_000_000) # WRONG: 10x too large Every transfer with dual_write=True credits 10x the correct amount in the account model. When the UTXO system becomes authoritative, the integrity check will always fail, and the account model will show phantom balances. Fix: use amount_nrtc (already correctly computed via UNIT) instead of re-converting from the float amount_rtc. Test added: - TestDualWriteConsistency.test_dual_write_amount_matches_utxo All 16 endpoint tests pass. Bounty: #2819 (Critical, 200 RTC)
|
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! |
|
Great security audit work! These fixes are critical for the protocol. |
Owner
|
Closing as duplicate of createkr #2096 (already merged), which fixed the same dual-write unit mismatch ( 25 RTC independent discovery credit — you found the same bug independently, which validates the severity. Good eye. Wallet: |
This was referenced Apr 6, 2026
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.
Vulnerability Class
Critical — Fund inflation via precision error (200 RTC bounty)
The Bug
The UTXO model uses
UNIT = 100_000_000(10^8, 8 decimal places). But the dual-write path inutxo_endpoints.pyline 320 converts to the account model using1_000_000_000(10^9, 9 decimal places):