Repository navigation
Fix Sophia governor malformed transfer amount handling - #6679
Conversation
|
CI note: the full repository Local targeted verification for this change passes: uv run --no-project --with pytest --with flask python -m pytest -q node/tests/test_sophia_governor.py --tb=short
python3 -m py_compile node/sophia_governor.py node/tests/test_sophia_governor.py
git diff --check -- node/sophia_governor.py node/tests/test_sophia_governor.pyManual malformed payload checks also returned HTTP 200 with |
JONASXZB
left a comment
There was a problem hiding this comment.
I found one amount-precedence edge case in the malformed-transfer parser. The crash fix is useful, but the fallback condition currently treats a valid zero RTC amount as absent and then lets amount_i64 change the interpreted amount or malformed flag.
| def _pending_transfer_amount_rtc(payload: dict[str, Any]) -> tuple[float, bool]: | ||
| """Return best-effort pending transfer RTC amount and whether it was malformed.""" | ||
| amount_rtc, invalid = _safe_nonnegative_float(payload.get("amount_rtc")) | ||
| if amount_rtc: |
There was a problem hiding this comment.
Using truthiness here means a valid explicit amount_rtc of 0 or "0" does not win over the legacy amount_i64 field. For example, {"amount_rtc": 0, "amount_i64": 999999999} is interpreted as 999.999999 RTC, and {"amount_rtc": 0, "amount_i64": ["bad"]} is marked malformed even though the primary amount field is valid. Since the function accepts 0 as a non-negative value, the fallback should probably key off presence/is not None rather than truthiness: if amount_rtc is supplied and valid, return it even when it is zero; only fall back to amount_i64 when amount_rtc is missing/empty or invalid by policy.
Summary
pending_transferamount fields in the Sophia governorinvalid_transfer_amountinstead of raising HTTP 500Fixes #6678.
Claiming under bug bounty #305.
Payout miner_id:
github:darlina-bounty-codexTests
uv run --no-project --with pytest --with flask python -m pytest -q node/tests/test_sophia_governor.py --tb=shortpython3 -m py_compile node/sophia_governor.py node/tests/test_sophia_governor.pygit diff --check -- node/sophia_governor.py node/tests/test_sophia_governor.pyManual verification
Malformed pending transfer amount payloads now return HTTP 200 with a medium-risk
local_then_phone_homereview and theinvalid_transfer_amountsignal instead of crashing.