IntersectMBO / cardano-ledger

The ledger implementation and specifications of the Cardano blockchain.
Apache License 2.0
262 stars 155 forks source link

Add a new event for invalidated votes #4633

Closed kderme closed 1 month ago

kderme commented 2 months ago

A new vote can replace an older one if the voter and the action is the same. For tools like DBSync it would be very useful to have a way to mark invalidated votes, using a new event, which can look like GovReplacedVote (TxId c) [(Voter c, GovActionId c)]

Votes are also removed when dreps are retired and actions are dropped. However these cases are more straight forward for db-sync to handle without events.

Initial requests https://github.com/IntersectMBO/cardano-db-sync/issues/1798

Alternative attemps db-sync could query its db, to verify that a vote is replaced. However this replicates the logic and forces disk queries for every vote. Using the event queries are necessary only for replacing votes. Using the ledger state without an event would be also hard, since db-sync doesn't have the state before each transaction.

lehins commented 2 months ago

Votes are also removed when dreps are retired

Votes aren't really removed when DReps unregister, they are just not counted any more. That being said, if a DRep is to re-register, all of the votes will still be there and will be counted. Albeit a DRep in such situation will loose all of the delegation, but that is very different from clearing out all the votes.

actions are dropped

Votes are indeed dropped when proposal itself is removed for whatever reason.

lehins commented 2 months ago

Dammit, I take it back. I totally forgot that we implemented cleanup of votes for DReps when they unregister. I was the one who implemented it too #4452 :man_facepalming: :sweat_smile: