Skip to content

feat(governance): add counted flag to proposal votes (re-land #352) - #353

Merged
slowbackspace merged 5 commits into
masterfrom
fix/proposal-votes-cc-cip129
Sep 2, 2026
Merged

feat(governance): add counted flag to proposal votes (re-land #352)#353
slowbackspace merged 5 commits into
masterfrom
fix/proposal-votes-cc-cip129

Conversation

@slowbackspace

Copy link
Copy Markdown
Contributor

#352 was merged while its base was still fix/proposal-votes-cc-cip129 (GitHub only retargets stacked PRs to master when the base branch is deleted on merge, and #351 kept its branch), so its changes landed on that branch instead of master. This PR delivers the identical delta to master: the counted field implementation, the @blockfrost/openapi 0.1.93 bump, and the 6.8.0 version bump.

See #352 for the full description, mainnet validation, perf comparison, and the Koios cross-check.

Fixes blockfrost/openapi#466

The votes endpoint returns 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 on deregistration, so the
response can diverge significantly from the current ledger vote state
(queryLedgerState/governanceProposals in Ogmios).

Add a boolean "counted" to each vote entry: true only for the voter's
latest vote on the proposal, and for DRep voters only when no
deregistration follows the vote — re-registering does not restore
previously dropped votes, so the check is "no dereg after the vote's
tx", not "currently registered". Recency is a window rank per voter
within the proposal's votes; the dereg check is an index-only scan on
bf_idx_drep_registration_hash_deposit.

Validated on mainnet db-sync: on the busiest proposal (453 votes) the
flag marks 99 votes uncounted (36 superseded re-votes + 63 latest votes
of since-deregistered DReps), no voter retains more than one counted
vote, paged/unpaged outputs and ordering are unchanged, and a warm
page returns in ~50ms.

Requires @blockfrost/openapi with the counted field in proposal_votes
(blockfrost/openapi#466); until the dependency is bumped the field is
stripped by response serialization.

Fixes blockfrost/openapi#466
…e set

A DRep deregistration only drops votes from proposals that are still
live; once a proposal is ratified/enacted/dropped/expired its tally is
frozen, so a later deregistration must not retroactively mark the vote
uncounted. Bound the deregistration check by the epoch in which the
proposal left the active set (LEAST of the gov_action_proposal epoch
columns; NULL = still live, tip semantics unchanged).

On mainnet this matters a lot for closed proposals: gap 12 had 65 of
453 votes wrongly flagged uncounted by post-closure deregistrations
(now 39 uncounted: 36 superseded + 3 pre-closure deregistrations).
Brings the counted field and cc_hot voter schema for
/governance/proposals/{tx_hash}/{cert_index}/votes so response
serialization no longer strips the new field.
feat(governance): add counted flag to proposal votes
@slowbackspace
slowbackspace merged commit 30b3f0f into master Sep 2, 2026
1 of 2 checks passed
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.

GET /governance/proposals/{tx_hash}/{cert_index}/votes should indicate whether each vote is currently counted

1 participant