M-1: Vetoed proposals continue accepting votes and grant participation rewards
Description:
The Voting.veto method marks a proposal as vetoed. When the proposal already has votes, it intentionally does not mark the proposal as retracted or invoke hooks.on_retract.
However, Voting.vote only checks whether the proposal is retracted:
assert not self.proposals[_idx].retracted
It does not check self.proposals[_idx].vetoed. Consequently, accounts can continue voting on a vetoed proposal until the voting period ends.
Every new non-zero vote invokes hooks.on_vote. When the configured hook is VoteBoostRewardDistributor, its on_vote method credits the voter with participation for the current and following five epochs. An account can therefore obtain VBRD participation credit by voting on a proposal that the guardian has already permanently disabled.
Impact:
Medium. Vetoed proposals continue accumulating votes, producing misleading governance signaling. More importantly, users can farm participation credit on dead proposals, increasing their share of VBRD rewards and diluting rewards received by users who only vote on active proposals.
Recommendation:
Prevent voting on vetoed proposals by adding the following validation to Voting.vote:
assert self.proposals[_idx].epoch == self._epoch()
assert (block.timestamp - genesis) % EPOCH_LENGTH >= self.vote_start
assert not self.proposals[_idx].retracted
+assert not self.proposals[_idx].vetoed
Developer Response:
If a proposal has votes, it means some users will receive a boost from it. If the veto comes in after that it would be unfair towards the other users to not allow them to vote on it too and receive the boost. Therefore we still allow voting on vetoed proposals. The exception to that is when it gets vetoed before receiving any votes. in this case we can remove the proposal from the count in the vbrd without negative side effects
Proof Of Concept:
The following unit test may be added to tests/test_vote_boost_reward_distributor.py:
def test_vote_after_veto_credits_participation(chain, deployer, alice, bob, genesis, veyfi, verd, vbrd, voting, voter):
# a vetoed proposal with an existing vote still accepts new votes
unlock = genesis + 50 * EPOCH_LENGTH
for account in (alice, bob):
veyfi.set_locked(account, UNIT, unlock, sender=deployer)
verd.set_snapshot(account, UNIT, 50, unlock, sender=deployer)
verd.migrate(sender=account)
voting.propose(IPFS_HASH, b"", sender=alice)
chain.pending_timestamp = genesis + 6 * EPOCH_LENGTH - 48 * 60 * 60
voter.vote_yea(voting, 0, sender=alice)
voting.veto(0, "vetoed after voting began", sender=deployer)
proposal = voting.proposals(0)
assert proposal.vetoed
assert not proposal.retracted
votes_before = proposal.votes
assert vbrd.num_votes(5, bob) == 0
voter.vote_yea(voting, 0, sender=bob)
assert voting.voted(bob, 0)
assert voting.proposals(0).votes > votes_before
assert vbrd.voted(bob, voting, 0)
for epoch in range(5, 11):
assert vbrd.num_votes(epoch, bob) == 1