Repository navigation
fix: keep DRep vote percentages when the SPO stake total is missing - #4322
Conversation
mesudip
left a comment
There was a problem hiding this comment.
Lets also review other places so that when backend returns 501, frontend doesn't collapses it to 0 or null
mesudip
left a comment
There was a problem hiding this comment.
Following up on my earlier request with specifics. The provider change looks right to me: a NULL pool_stat.voting_power counts as 0, and the SPO total is omitted only when no pool has one (Koios reads every page). The per-figure null on /network/total-stake and the guard on the DRep denominator also look right. Checks pass: provider-dbsync (154 tests), provider-koios (100), backend verify (464), and the frontend's tsc, lint and vitest. What's left is the same class of bug in the file this PR touches, and two comments.
Must fix
-
The DRep Abstain row still turns a missing figure into 0.
src/components/molecules/VotesSubmitted.tsx:111-112doesdRepAbstainVotes + (networkTotalStake?.alwaysAbstainVotingPower ?? 0).- This PR makes
alwaysAbstainVotingPowernullable. When it is null, or still loading, the row shows only the action's own abstain stake, with no sign it is partial. - D153's convention adds the DRep always-abstain stake to the DRep abstain, and D179 says "null, never 0". Show the abstain figure as unavailable, or mark it as partial, when the figure is null.
-
Comments contradict this PR's provider change.
src/network/network.service.ts:120-121andtest/legacy-shape.spec.ts:349-350say db-sync and Koios leave the SPO total out "until every pool's voting power for the epoch is recorded". That is the rule this PR removes. -
D179's note "(D178 is taken by the open delegation-history pull request.)" should go. D148 says an entry never points elsewhere. #4318 also adds a D178, so the reservation doesn't hold anyway; renumber at merge instead.
Same file, older, same class of bug
- The committee block shows a negative "Not voted" and a 0% threshold.
noOfCommitteeMembersfalls back to?? 0(VotesSubmitted.tsx:91), and the threshold falls back to 0 (:92-96)./network/metricsis fetched only after/network/total-stake(enabled: false, sequential awaits). So while it loads, or if it fails, "Not voted" = 0 − yes − no − abstain (:168), which is negative, and the threshold reads 0%.- The gate that should hide the block,
isFeatureAvailable("dashboard.committeeThreshold"), never fires: that id isn't in the FeatureId union, andisAvailabletreats unknown ids as available.
Other places that show ₳ 0 for a missing figure (a follow-up issue is fine)
- The formatters return "0" for missing values.
correctVoteAdaFormatandcorrectDRepDirectoryFormat(src/utils/adaFormat.ts) return"0"for null or undefined, and every caller shows it as "₳ 0":DRepCard.tsx:310,DRepDetailsCard.tsx:198,DRepDetailsCardHeader.tsx:71,VotingPowerChips.tsx:71,StakeRadio.tsx:91,DelegateDashboardCard.tsx:88,DirectVoterDashboardCard.tsx:27.- The DRep row's voting power is
ApiInteger | nullin the backend butvotingPower?: numberin the frontend'sDrepDataDTO, so the compiler can't flag these. - The backend's
/ada-holder/get-voting-powerdeliberately answers 0 on any failure, a 501 and a database outage included (AdaHolderService.getVotingPower). That needs an error path in the frontend before it can change.
Minor
-
The "Percentages are not available: the total stake could not be loaded." note is misleading in two cases. It also shows while the request is still loading, and when the total did load but isn't above the abstain stake.
-
Conflict with #4316. #4316 rewrites VotesSubmitted's render (
VotesGroup),models/api.tsand en.json. Whichever lands second has to carrysharesUnavailableand the nullable types across.
|
Thanks. Some of this was already fixed by the commits pushed just before your follow-up (it still quotes the committee size's
Checks on ebbb7d0: backend |
mesudip
left a comment
There was a problem hiding this comment.
Re-reviewed on ebbb7d0. Thanks for the point-by-point reply, and you're right that my follow-up quoted code your earlier commits had already fixed. All seven points are fixed. Checks pass here: provider-dbsync (154 tests), provider-koios (100), backend verify (467), and the frontend's tsc, lint and vitest (651).
On my first request (a 501 or a missing figure must not reach the screen as 0), I traced every route that can answer 501 to the screens that read it. These are done: the connected wallet's voting power, the vote totals on an action, the directory's Abstain and No Confidence options, and the lists that now say they could not be loaded. These are not:
Must fix
-
A DRep's voting power has two meanings for one
null.- The db-sync provider sends
nullon purpose for a DRep registered since the newest snapshot (govtool-provider-dbsync/src/governance/dreps/sql.ts:110, "One registered since has no snapshot figure yet: NULL"). - The directory card and the DRep page now show that
nullas "₳ —" (DRepCard.tsx:311,DRepDetailsCard.tsx:199). The CHANGELOG says so, and so doesDrepDataDTO's comment (models/api.ts:174), which cites D179. /drep/get-voting-powerstill turns the samenullinto 0 (drep.service.ts:223-225), and so does/drep/voting-power-listfor an ordinary DRep (drep.service.ts:295-298).- So that DRep sees ₳ 0 in its top-bar chip (
DashboardTopNavreads/drep/get-voting-power) and "₳ —" on its own card, and the forum's comment cards show it as ₳ 0. - D179 (
decisions.md:5986-5988) calls that 0 correct, "which the ledger counts as 0". The decision log is append-only, so please pick one meaning before merge and use it in D179, the CHANGELOG, the DTO comment and both routes.
- The db-sync provider sends
-
Deposits are shown as ₳ 0 when they are not known.
- The formatters return "0" for a missing value. The backend types allow
drep_depositandgov_action_depositto benull(epoch.type.ts:64-65), and the contract's DRep deposit is optional. - Register as DRep:
RolesAndResponsibilities.tsx:51. - Create governance action:
WhatGovernanceActionIsAbout.tsx:44, and the insufficient-balance message (useCreateGovernanceActionForm.ts:413). - Register as direct voter:
RegisterAsDirectVoter.tsx:155. Its?? 500never applies, becausecorrectAdaFormatreturns 0, not undefined. - The DRep dashboard card's retirement text (
DRepDashboardCard.tsx:68,:75) and retire as direct voter (RetireAsDirectVoter.tsx:125). - The transactions themselves refuse to build without the deposit, so only the text is wrong, but it is the screen where people decide to pay it. These should go through
adaOrUnknowntoo.
- The formatters return "0" for a missing value. The backend types allow
Should fix
-
/network/metricsstill reports missing figures as 0 (network.service.ts,getNetworkMetrics).totalDRepDistrisstake.data.totalStakeControlledByDReps ?? '0': the same total that/network/total-stakenow sends asnull(D179).- The DRep counts and
totalGovernanceActionsfall back to?? 0, and five counters are always 0. - No screen shows these today, here or in #4316, but the API answers them as facts. Make them
null, or say in D179 why this route keeps its zeros.
-
A 501 is retried three times.
main.tsx:31-37retries every failure, so where the provider has no per-account voting power (the fixture, Blockfrost) the dashboard and the DRep directory show their spinner for about 7 seconds on every load before the "—". A 501 will not change on retry. D179 says the frontend "no longer waits for the figure".
Minor
-
Spinners that never stop. The CHANGELOG says the DRep directory no longer shows a loader forever. It still does when
/ada-holder/get-current-delegationfails (DRepDirectoryContent.tsx:184), and the whole dashboard spins for good when that read or the voter info fails (DashboardCards.tsx:38-44). Fix them here, or narrow the CHANGELOG wording. -
Merge conflict with develop, now that #4318 is in: only
docs/api/decisions.md, where its D180 and this D179 both follow D177. D179 goes above D180.
…at failed to load
ebbb7d0 to
63f2518
Compare
|
Thanks for tracing every route that can answer 501. I rebased on develop for point 6 and force-pushed, so the earlier commits have new hashes; this review's fixes are five commits on top:
Checks on 63f2518: backend |
mesudip
left a comment
There was a problem hiding this comment.
Two small leftovers, neither blocking:
-
govtool/govtool-backend/README.md:213-214 still says /network/metrics "reports 0 for the five" unused counters. govtool/AGENTS.md and D179 now say null.
-
drep.service.ts has two doc comments stacked above getVotingPower. The old one still says an unknown credential "becomes the same 0".
|
Thanks, both fixed in fd341fc: the backend README now says |
List of changes
voting_powerNULL for a pool outside the SPO voting distribution, such as one that retired during the epoch (mainnet epoch 671 has one), and Koios mirrors it. Both now count it as 0./network/total-stakefailing with 501 when one figure is missing: each missing figure is nownull, so the DRep figures still arrive (D179).dashboard.metrics, and the totals and metrics load in parallel. The DRep abstain figure shows "—" when the always-abstain stake is unknown./ada-holder/get-voting-poweranswering 0 for any failure. It answers 0 only for an account with no record, 503 for a failed read and 501 for a provider without account voting power (the fixture). The frontend shows an unread or missing voting power as "₳ —" on the dashboard, its voting power chip, the DRep directory and cards and a DRep's page, and none of them wait for it forever;DrepDataDTO.votingPowerisnumber | null./drep/voting-power-listanswersnullrather than 0 for a predefined option without a figure./drep/get-voting-powerand/drep/voting-power-listanswering 0 for a DRep with no figure in the newest snapshot: they answernull, and the chip, the directory card and the DRep page show "—"./network/metricsreporting counters it does not have as 0: they arenull.Checked on preview db-sync: epochs 1385 and 1327 each have one NULL row; the providers now return the exact
voting_powersum, and/misc/network/metricsanswers 200 for them instead of 501.Checklist