Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Vote locks for all reasons except RESERVE #13914

Merged
merged 5 commits into from
Apr 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions frame/conviction-voting/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,12 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
},
}
});
T::Currency::extend_lock(CONVICTION_VOTING_ID, who, amount, WithdrawReasons::TRANSFER);
T::Currency::extend_lock(
CONVICTION_VOTING_ID,
who,
amount,
WithdrawReasons::except(WithdrawReasons::RESERVE),
);
}

/// Rejig the lock on an account. It will never get more stringent (since that would indicate
Expand Down Expand Up @@ -669,7 +674,7 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
CONVICTION_VOTING_ID,
who,
lock_needed,
WithdrawReasons::TRANSFER,
WithdrawReasons::except(WithdrawReasons::RESERVE),
);
}
}
Expand Down
21 changes: 18 additions & 3 deletions frame/democracy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1308,7 +1308,12 @@ impl<T: Config> Pallet<T> {
})?;
// Extend the lock to `balance` (rather than setting it) since we don't know what other
// votes are in place.
T::Currency::extend_lock(DEMOCRACY_ID, who, vote.balance(), WithdrawReasons::TRANSFER);
T::Currency::extend_lock(
DEMOCRACY_ID,
who,
vote.balance(),
WithdrawReasons::except(WithdrawReasons::RESERVE),
);
ReferendumInfoOf::<T>::insert(ref_index, ReferendumInfo::Ongoing(status));
Ok(())
}
Expand Down Expand Up @@ -1454,7 +1459,12 @@ impl<T: Config> Pallet<T> {
let votes = Self::increase_upstream_delegation(&target, conviction.votes(balance));
// Extend the lock to `balance` (rather than setting it) since we don't know what other
// votes are in place.
T::Currency::extend_lock(DEMOCRACY_ID, &who, balance, WithdrawReasons::TRANSFER);
T::Currency::extend_lock(
DEMOCRACY_ID,
&who,
balance,
WithdrawReasons::except(WithdrawReasons::RESERVE),
);
Ok(votes)
})?;
Self::deposit_event(Event::<T>::Delegated { who, target });
Expand Down Expand Up @@ -1499,7 +1509,12 @@ impl<T: Config> Pallet<T> {
if lock_needed.is_zero() {
T::Currency::remove_lock(DEMOCRACY_ID, who);
} else {
T::Currency::set_lock(DEMOCRACY_ID, who, lock_needed, WithdrawReasons::TRANSFER);
T::Currency::set_lock(
DEMOCRACY_ID,
who,
lock_needed,
WithdrawReasons::except(WithdrawReasons::RESERVE),
);
}
}

Expand Down
2 changes: 1 addition & 1 deletion frame/democracy/src/tests/lock_voting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ fn nay(x: u8, balance: u64) -> AccountVote<u64> {
}

fn the_lock(amount: u64) -> BalanceLock<u64> {
BalanceLock { id: DEMOCRACY_ID, amount, reasons: pallet_balances::Reasons::Misc }
BalanceLock { id: DEMOCRACY_ID, amount, reasons: pallet_balances::Reasons::All }
}

#[test]
Expand Down