Skip to content

Fix proposal_votes PK collapsing batch_vote rows - #59

Open
sausagee wants to merge 2 commits into
mainfrom
cursor/fix-proposal-votes-pk-a13e
Open

Fix proposal_votes PK collapsing batch_vote rows#59
sausagee wants to merge 2 commits into
mainfrom
cursor/fix-proposal-votes-pk-a13e

Conversation

@sausagee

@sausagee sausagee commented Sep 6, 2026

Copy link
Copy Markdown

Bug

proposal_votes is keyed as (transaction_version, proposal_id, voter_address). 0x1::aptos_governance::batch_vote / batch_partial_vote loop vote_internal and emit one VoteEvent per stake pool in a single transaction. Those events share voter + proposal and differ only on stake_pool.

The storer then does ON CONFLICT (transaction_version, proposal_id, voter_address) DO NOTHING, so every pool after the first is silently dropped while the stake processor checkpoint still advances.

Root cause

The table stores staking_pool_address but never included it in the primary key. That was fine when only vote existed (one pool per txn). Batch voting (aptos-core #13026) made the 3-column key too narrow.

Fix

  • Add staking_pool_address to the Diesel PK, schema, and upsert conflict target.
  • Migration rewrites proposal_votes_pkey to the 4-column key.
  • Unit test parses a two-pool batch (legacy VoteEvent + module Vote) and shows the old 3-column key would collapse while the new key keeps both rows.

Tests

  • cargo test -p processor --lib processors::stake::models::proposal_votes — pass
  • RUST_MIN_STACK=67108864 cargo clippy -p processor --lib --tests -- -D warnings — pass
  • Aikido scan not run (plugin requires sign-in)
Open in Web Open in Cursor 

batch_vote / batch_partial_vote emit one VoteEvent per stake pool in
the same transaction. The old primary key (transaction_version,
proposal_id, voter_address) made the storer's ON CONFLICT DO NOTHING
silently drop every pool after the first.

Co-authored-by: Young Yang Liauw <sausagee@users.noreply.github.com>
@sausagee
sausagee marked this pull request as ready for review September 6, 2026 15:33
@sausagee
sausagee changed the base branch from main to fix/lint-stable-xclippy September 7, 2026 22:19
@sausagee
sausagee changed the base branch from fix/lint-stable-xclippy to main September 7, 2026 22:31
Stack the CI unblocker files from PR #70 (stable cargo xclippy, bookworm Dockerfiles with make) onto this bugfix branch so CI can go green while #70 awaits review. Merge target remains main; this does not merge #70.
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.

2 participants