Skip to content

feat(governance): add counted flag to proposal votes - #469

Closed
slowbackspace wants to merge 1 commit into
fix/proposal-votes-cc-cip129from
feat/proposal-votes-counted
Closed

feat(governance): add counted flag to proposal votes#469
slowbackspace wants to merge 1 commit into
fix/proposal-votes-cc-cip129from
feat/proposal-votes-counted

Conversation

@slowbackspace

Copy link
Copy Markdown
Contributor

Summary

Adds a boolean counted to each entry of /governance/proposals/{tx_hash}/{cert_index}/votes indicating whether the vote is still counted in the ledger's current vote tally (#466). The endpoint returns every vote ever cast, but the ledger keeps only the latest vote per voter and drops a DRep's votes on deregistration, so results could diverge significantly from Ogmios' queryLedgerState/governanceProposals.

Semantics

counted = true iff:

  • the vote is the voter's latest on this proposal (window rank per voter over the proposal's votes, by tx_id), and
  • for DRep voters, no deregistration follows the vote's tx — re-registering does not restore previously dropped votes, so the check is "no dereg after the vote", not "currently registered" (Koios gets this subtly wrong)

The dereg check is an index-only scan on the existing bf_idx_drep_registration_hash_deposit index, evaluated only for returned rows.

Validation (mainnet db-sync)

  • Busiest proposal (9b62b3c6...#0, 453 votes): 99 flagged uncounted — 36 superseded re-votes + 63 latest votes of since-deregistered DReps; all 7 CC votes stay counted
  • No voter retains more than one counted vote
  • Paged/unpaged outputs, row order, and pagination behavior unchanged (full page sweep compared against unpaged)
  • Warm page ~50ms; nonexistent proposal ~30ms

Notes

Fixes #466

The votes endpoints return every vote-cast transaction ever submitted
for a proposal, but the ledger keeps only the latest vote per voter
(upsert semantics) and drops a DRep's votes when the DRep deregisters,
so the response can diverge significantly from the ledger's current
vote state (queryLedgerState/governanceProposals in Ogmios).

Add a required boolean "counted" to each vote entry of
/governance/proposals/{tx_hash}/{cert_index}/votes indicating whether
the vote is still counted in the ledger's vote tally, reconstructed at
the current chain tip: true only for the voter's latest vote on the
proposal, and for DRep voters only if no deregistration follows the
vote (re-registration does not restore dropped votes).

Named "counted" rather than "active" because "active" already
means registered/not-expired for DReps elsewhere in the API (and was
deprecated there in 0.1.72 for its ambiguity).

Fixes #466
@slowbackspace

Copy link
Copy Markdown
Contributor Author

Opened in the wrong repo by mistake — the backend PR lives in blockfrost-backend-ryo.

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