fix(gpu): verify provider balance credit on escrow release (#6161)#6347
fix(gpu): verify provider balance credit on escrow release (#6161)#6347crowniteto wants to merge 1 commit into
Conversation
…6161) Previously, gpu_release() executed an UPDATE on the balances table without checking rowcount. If the provider (to_wallet) had no existing balances row, the UPDATE matched 0 rows but the escrow was still marked as 'released' — funds debited from payer but never credited to provider. Now we check credited.rowcount: if 0 (provider has no balances row), we INSERT a new row with the credited amount instead of silently dropping the funds. Fixes Scottcjn#6161
shadow88sky
left a comment
There was a problem hiding this comment.
Reviewed current head a3d996c1f500c5f0ee1a05db2692f2b5fb736f53.
Blocking issue: node/gpu_render_endpoints.py no longer parses. The provider credit block was dedented out of the surrounding try, so Python reaches credited = db.execute(...) where it is still expecting an except or finally block.
Local validation:
.venv/bin/python -m py_compile node/gpu_render_endpoints.py
# SyntaxError: expected "except" or "finally" block at line 229
Relevant shape:
try:starts at line 203.- The state-transition logic is inside the
trythrough line 226. - The new transfer-to-provider block starts at line 228 with only function-level indentation.
except sqlite3.Errorremains at line 241, so the file is syntactically invalid.
The intended fund-loss fix looks directionally right, but the credit/insert/commit/return block needs to stay inside the try after the successful moved.rowcount == 1 check. I would also add a regression test for the missing-provider-balance-row release path so this does not regress silently.
I received RTC compensation for this review.
jaxint
left a comment
There was a problem hiding this comment.
Great work! Thanks for contributing to RustChain! 🦀
jaxint
left a comment
There was a problem hiding this comment.
Great work on this PR! The changes look solid. Keep building! 🚀
RTC Wallet: AhqbFaPBPLMMiaLDzA9WhQcyvv4hMxiteLhPk3NhG1iG
jaxint
left a comment
There was a problem hiding this comment.
Great work! Thanks for contributing to RustChain! 🦀
Problem
Closes #6161
/api/gpu/releaseexecutes an UPDATE on the balances table without checking rowcount. If the provider (to_wallet) has no existingbalancesrow, the UPDATE matches 0 rows but the escrow is still marked asreleased— funds debited from payer but never credited to provider.Root Cause
Fix
Check
credited.rowcountafter the UPDATE:Testing
Manual reproduction per #6161:
balancesrowSecurity Impact
High — this is a fund-loss vulnerability where legitimate GPU providers never receive payment for completed work.