Repository navigation
fix: require manual payout recovery after broadcast uncertainty - #5577
iamdinhthuan wants to merge 1 commit into
Conversation
|
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! |
strongkeep-debug
left a comment
There was a problem hiding this comment.
I rechecked the #5346 recovery path at head 2e6651c7e4e7b3f1e449484e95e5d866c0c1f7bb and this resolves the unsafe automatic refund shape for both in-flight failures and startup-orphaned processing rows.
What I verified:
| Area | Result |
|---|---|
| Duplicate/overlap check | #5346 is open/unassigned and search found this as the only overlapping payout_worker recovery PR |
process_withdrawal() failure after deduction |
leaves the deducted balance in place and moves the row to recovery_required for manual chain-status review |
| startup recovery | moves orphaned processing rows to recovery_required without refunding |
| worker stats | exposes recovery_required so the manual queue is visible |
Local validation:
git diff --check origin/main...HEAD
python -m py_compile node/payout_worker.py tests/test_payout_worker_production_noop.py
python tools/bcos_spdx_check.py --base-ref origin/main
python -m pytest tests/test_payout_worker_production_noop.py -q
Result: diff-check and py_compile were clean, SPDX check passed, and the focused pytest suite reported 4 passed.
dicnunz
left a comment
There was a problem hiding this comment.
Reviewed under Scottcjn/rustchain-bounties#73 on head 2e6651c.
Approved. The change correctly stops auto-refunding after the withdrawal has been marked processing, which is the ambiguous point where a broadcast may already have escaped. It moves post-deduction failures and startup-orphaned processing rows to recovery_required, keeps the deducted balance intact, and leaves the existing production-noop path pending before any balance change.
Validation I ran:
uv run --no-project --with pytest --with flask python -m pytest tests/test_payout_worker_production_noop.py -q
# 4 passed
python3 -m py_compile node/payout_worker.py tests/test_payout_worker_production_noop.py
git diff --check origin/main...HEAD
python3 tools/bcos_spdx_check.py --base-ref origin/main
# BCOS SPDX check: OK
The failing repository test check is the known unrelated collection failure from missing optional CI dependencies (aiohttp, flask_cors, matplotlib), not from this PR. I did not find a blocking issue in this patch.
|
Security Review ✅ HIGH Manual payout recovery after broadcast uncertainty. Previous code auto-refunded on broadcast failure, but post-deduction failures should NOT auto-refund — the funds may have been successfully sent. Moving to recovery_required state prevents incorrect refunds and protects against double-spend scenarios. Reviewed by Xeophon - Solana: Lt9nERv6VHsojw15LpFeiaabuphAggzfLF9sM9UXRrZ |
ZacharyZhang-NY
left a comment
There was a problem hiding this comment.
Reviewed PR #5577 at head 2e6651c.
Approved. The payout worker now preserves deducted withdrawals after ambiguous post-processing failures by moving them to recovery_required, moves startup-orphaned processing rows to manual recovery, keeps the production no-op path pending before any deduction, and exposes recovery_required in stats.
Validation run:
- git diff --check origin/main...HEAD -- node/payout_worker.py tests/test_payout_worker_production_noop.py
- python -B -m py_compile node/payout_worker.py tests/test_payout_worker_production_noop.py
- python -B -m pytest -q tests/test_payout_worker_production_noop.py --noconftest
- python tools/bcos_spdx_check.py --base-ref origin/main
Result: diff check clean, py_compile clean, focused pytest 4 passed, BCOS SPDX check OK. No blocking issue found in this patch.
2balmprune
left a comment
There was a problem hiding this comment.
Reviewed head 2e6651c7e4e7b3f1e449484e95e5d866c0c1f7bb for the #5346 payout-worker recovery issue. Approved.
The patch removes the unsafe auto-refund path after a withdrawal has been moved to processing, moves ambiguous post-deduction/broadcast failures to recovery_required, and also moves startup-orphaned processing rows to the same manual-review state before the worker loop starts. That preserves the deducted balance until an operator checks chain status, which matches the safer recovery model requested in #5346. The existing production-noop path still leaves pending withdrawals untouched before any balance deduction.
Validation performed:
git diff --check origin/main...HEADpython3 -m py_compile node/payout_worker.py tests/test_payout_worker_production_noop.pypython3 tools/bcos_spdx_check.py --base-ref origin/main-> BCOS SPDX check OK- Manual SQLite probes for post-deduction broadcast uncertainty and startup
processingrecovery -> both kept the deducted balance and setrecovery_required
I did not find a blocking issue in this patch.
|
Claiming #5577 - will implement recovery_required state + regression test. |
TJCurnutte
left a comment
There was a problem hiding this comment.
Reviewed the payout recovery path and ran the focused checks. This is the safer behavior around ambiguous broadcast state.
What I checked:
git diff --check origin/main...HEAD -- node/payout_worker.py tests/test_payout_worker_production_noop.py
PYTHONPATH=. python3 -B -m py_compile node/payout_worker.py tests/test_payout_worker_production_noop.py
PYTHONPATH=. python3 -B -m pytest -q -o addopts='' tests/test_payout_worker_production_noop.pyResults:
git diff --checkpassed.py_compilepassed for the worker and focused test file.- Focused pytest passed:
4 passed, 1 warning in 0.06s.
I also ran a temp-SQLite runtime probe with MOCK_MODE=True and an execute_withdrawal() override that raises RuntimeError("network timeout after possible broadcast") after the worker has deducted funds and moved the withdrawal to processing. The resulting state was:
{'balance': 89, 'status': 'recovery_required', 'tx_hash': None, 'recovery_required': 1}That confirms the important invariant here: once funds have been deducted / processing has started, the worker no longer auto-refunds on an ambiguous execution failure. It preserves the deducted balance state, marks the withdrawal for manual recovery, and surfaces the recovery count in stats. The startup sweep also moves orphaned processing rows into the same manual-review state.
Approved.
jaxint
left a comment
There was a problem hiding this comment.
LGTM! Great work on this PR. 🚀
kekehanshujun
left a comment
There was a problem hiding this comment.
I reviewed the payout worker patch flow and tests. This fixes the key ambiguity by only moving a withdrawal to recovery_required after the worker has already marked it processing/deducted funds, instead of automatically refunding when broadcast outcome is unknown.
The startup recovery hook is wired through main() before the loop, and the tests cover both ambiguous broadcast failure and startup recovery of an orphaned processing withdrawal without refunding the account. I do not see a blocker in this version.
PR Review — PR #5577Title: fix: require manual payout recovery after broadcast uncertain Author: iamdinhthuan What I reviewed
Observations
LGTM pending CI. Important consistency fix with good test coverage. The manual recovery requirement prevents silent failures in the payout flow. Bounty: #2782 |
|
Closing as stale branch — would cause destructive deletions if merged. Your branch was filed roughly 155 commits behind current main. Since then, many overlapping fixes from other contributors have landed via parallel PRs. GitHub's Bounty credit acknowledgedIf your fix addressed a real bug, the canonical version has very likely already shipped via a parallel contributor's PR over the past two weeks. Specific cases covered by today's audit:
If you want fresh reviewRebase against current main and verify your diff shows roughly the size of the changes you originally made: If the deletion count is significantly higher than what you added, the branch is still picking up stale assumptions — recreate from a fresh main. Thanks for the contribution work this week. |
Summary
processingwithdrawals into explicitrecovery_requiredstate without refunding balancesrecovery_requiredin payout worker statsFixes #5346.
Verification
python3 -m pytest tests/test_payout_worker_production_noop.py::test_processing_withdrawal_failure_requires_manual_recovery_without_refund -qfailed withassert 100 == 89before the fixpython3 -m pytest tests/test_payout_worker_production_noop.py::test_startup_recovery_moves_processing_withdrawals_to_manual_review_without_refund -qfailed with missing method before the fixpython3 -m pytest tests/test_payout_worker_production_noop.py -q->4 passedpython3 -m py_compile node/payout_worker.py tests/test_payout_worker_production_noop.pygit diff --checkSafety
github_write_gate=cleared