Repository navigation
[BRIDGE-BUG] CRIT-BRIDGE-1: Float truncation in bridge transfer amount conversion - #2091
Merged
Merged
Conversation
…t conversion create_bridge_transfer() uses int(request.amount_rtc * BRIDGE_UNIT) which truncates for non-round amounts — same as CRIT-TX-1. Example: 2.01 RTC bridge deposit records 2009999 uRTC instead of 2010000. The lock_ledger and bridge_transfers tables both store the wrong amount, causing a 1 uRTC discrepancy per affected transfer. Fix: Use Decimal(str(amount)) * BRIDGE_UNIT for exact conversion. Tests added (new file test_bridge_precision.py): - test_float_truncation_exists - test_decimal_is_exact - test_bridge_amounts_exact All 3 tests pass. Bounty: Scottcjn#2819 (Critical, 200 RTC)
Contributor
|
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! |
Owner
|
Solid. Payment: 50 RTC (bridge fund precision, high severity — real money at stake on cross-chain transfers) Merging. |
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 — Float truncation in cross-chain bridge (200 RTC bounty)
The Bug
create_bridge_transfer()line 280:Same IEEE 754 truncation as CRIT-TX-1: int(2.01 * 1000000) = 2009999.
Both bridge_transfers and lock_ledger store the wrong amount.
Fix: int(Decimal(str(request.amount_rtc)) * BRIDGE_UNIT)
All 3 tests pass.
Files Changed
node/bridge_api.py — Decimal conversion + import
node/test_bridge_precision.py — NEW (3 tests)
Wallet: aroky-x86-miner