fix(claims-ui): formatRtc understates every reward 100x (divides micro-RTC by 10^8 not 10^6)#8007
Open
Vyacheslav-Tomashevskiy wants to merge 1 commit into
Conversation
…splayed reward 100x too small reward_urtc is micro-RTC (10^6 units/RTC); the backend converts via reward_urtc / 1_000_000 everywhere (node/claims_submission.py). The claims page helper divided by 100_000_000, so every amount it renders (epoch dropdown, claim summary, history, Total Claimed stat, success message, CSV export) was understated 100x — a 1.5 RTC reward showed as 0.015 RTC. Align the divisor with the backend and add a regression test.
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.
The bug
Every reward amount on the claim page is rendered through one helper,
formatRtcinweb/claims/claims.js:The input is
reward_urtc— micro-RTC, where 1 RTC = 10^6 units. That's the backend's convention:node/claims_submission.pyconverts to human-readable RTC by dividing by1_000_000in every place it reports a value (lines 452, 582, 663):The frontend divides by
100_000_000(10^8) instead — a 100x error. It reads the raw_urtcinteger fields straight from the API (epoch.reward_urtc,claim.reward_urtc,stats.total_claimed_urtc,result.reward_urtc) and scales them client-side with the wrong divisor.Concrete input → wrong output: a reward of
1_500_000micro-RTC = 1.5 RTC. The backend returnsreward_rtc = 1.5; the page showed1_500_000 / 100_000_000 = 0.015→"0.015000 RTC".formatRtcfeeds the whole claims UI, so all of these were understated 100x: the epoch dropdown (L390), the claim summary reward (L410), the history reward column (L462), the Total Claimed stat (L491), the post-submit success message (L672), and the CSV export (L769). In a payout flow that's exactly the kind of misleading number that erodes trust.The fix
Divide by micro-RTC (10^6) to match the backend and the function's own docstring — one line:
Test
Added
tests/test_claims_frontend_rtc_scaling.py(source-assertion style, matching the repo's existingclaims.jstests): extracts the divisor fromformatRtc, asserts it is1_000_000, asserts it matches the backend'sreward_urtcdivisor, and checks the worked 1.5-RTC example. 3 pass with the fix; the first two fail against the old100_000_000. The existing 26 claims-frontend tests still pass.Verified against
upstream/main@ c6501de.RTC:
RTCd1554f0f35576faf01d386a6be1c947f560dd0b7