Skip to content

fix(log): clamp the unfiltered pending legs to match the filtered ones (#4310) - #4338

Merged
TaprootFreak merged 3 commits into
developfrom
fix/log-unfiltered-pending-clamp
Jul 23, 2026
Merged

fix(log): clamp the unfiltered pending legs to match the filtered ones (#4310)#4338
TaprootFreak merged 3 commits into
developfrom
fix/log-unfiltered-pending-clamp

Conversation

@TaprootFreak

Copy link
Copy Markdown
Collaborator

Finding J of #4310 (separate, minor). The filtered pending legs are each individually clamped to 0 when negative; their unfiltered counterparts (fromKrakenUnfiltered/toKrakenUnfiltered/fromScryptUnfiltered/toScryptUnfiltered) were not. When useUnfilteredTx is true, an unclamped negative unfiltered leg (observed: asset 405 ≈ −5.0M) drives totalPlusPending negative and fires the totalPlusPending < 0 verbose log every minute. This adds the four symmetric clamps (placed after the !== filtered-vs-unfiltered discrepancy comparisons, so those still compare raw values). format:check / lint / type-check clean, jest 67/67.

The root cause of a persistently-negative unfiltered leg (asset 405) is a documented separate follow-up, out of scope here. Addresses #4310 (finding J).

#4310)

The filtered pending legs (fromKraken/toKraken/fromScrypt/toScrypt) are each clamped to 0 when negative, but their unfiltered counterparts were not. When useUnfilteredTx is true, an unclamped negative unfiltered leg (observed: asset 405 approx -5.0M) drove totalPlusPending negative and fired the 'totalPlusPending < 0' verbose log every minute. Clamp the four unfiltered legs symmetrically, placed after the filtered/unfiltered discrepancy comparisons so those still compare raw values. The root cause of a persistently-negative unfiltered leg is a separate follow-up.
…eredTx path (#4310)

pr-ready review: the four new unfiltered-leg <0 verbose logs now include their constituent pending-amount breakdown (matching the filtered siblings), which the separate follow-up into the persistently-negative unfiltered leg will need; and add a test exercising the useUnfilteredTx=true clamp path (previously entirely untested).
@github-actions

Copy link
Copy Markdown

ℹ️ New TODOs/FIXMEs (1)

+        address: yapealCHF.bic.padEnd(11, 'XXX'),

…regate clamp (#4310)

pr-ready round 2: the negative-leg clamp test was vacuous — the downstream aggregate totalPlusPending<0 clamp floors the same scenario, so reverting the per-leg clamp still left it green. Assert (via the verbose log) that the per-leg 'toKrakenUnfiltered balance < 0' path fires and the aggregate 'totalPlusPending < 0' path does NOT, so the test now fails if the per-leg clamp is removed.
@TaprootFreak

Copy link
Copy Markdown
Collaborator Author

Review complete: 3 review passes to reach 0 defects (conformance-vs-CONTRIBUTING and logic/context lenses, run in parallel with CI).

  • Pass 1, fixed: logged the unfiltered clamp components and added coverage for the useUnfilteredTx path.
  • Pass 2, fixed: the per-leg clamp test was vacuous — the downstream aggregate totalPlusPending < 0 clamp floors the same scenario, so reverting the per-leg clamp still left it green. It now asserts (via the verbose log) that the per-leg toKrakenUnfiltered balance < 0 path fires and the aggregate path does not, so the test fails if the per-leg clamp is removed.
  • Pass 3: no findings.

@TaprootFreak
TaprootFreak marked this pull request as ready for review July 23, 2026 15:57
@TaprootFreak
TaprootFreak merged commit 428c815 into develop Jul 23, 2026
7 checks passed
@TaprootFreak
TaprootFreak deleted the fix/log-unfiltered-pending-clamp branch July 23, 2026 17:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant