substrate icon indicating copy to clipboard operation
substrate copied to clipboard

Delegating and undelegating votes with conviction when there is an existing lock

Open emresurmeli opened this issue 3 years ago • 0 comments

Is there an existing issue?

  • [X] I have searched the existing issues

Experiencing problems? Have you tried our Stack Exchange first?

  • [X] This is not a support question.

Description of bug

If there is an existing lock due to a previous vote delegation change or undelegation, any new change or undelegation will restart the lock period for the larger DOT amount and the longest conviction period between the existing and the new lock.

Examples:

  1. Delegate 500 DOT with 1x conviction, then change delegation to 1000 DOT with 1x conviction, the lock period will reset for 1000 DOT with 1x conviction.

  2. Delegate 500 DOT with 3x conviction, then change the delegation to 1000 DOT with 1x conviction, the lock period will reset for 1000 DOT with 3x conviction.

  3. Delegate 500 DOT with 1x conviction, then change the delegation to 200 DOT with 1x conviction, the lock period will reset for 500 DOT with 1x conviction.

Another edge case to consider - is if the lock hasn't been removed after the lock period has expired, we might experience the same issues.

Based on this convo in substrate stackexchange the issue seems to be with the prior.accumulate function, as it will pick the largest delegated DOT amount and longest conviction period.

pub fn accumulate(&mut self, until: BlockNumber, amount: Balance) {
	self.0 = self.0.max(until);
	self.1 = self.1.max(amount);
}

Steps to reproduce

No response

emresurmeli avatar Oct 11 '22 18:10 emresurmeli