Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pallet-staking] Additional check for virtual stakers #5985

Merged
merged 7 commits into from
Nov 5, 2024
8 changes: 7 additions & 1 deletion substrate/frame/staking/src/pallet/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1881,8 +1881,12 @@ impl<T: Config> StakingInterface for Pallet<T> {
}

/// Whether `who` is a virtual staker whose funds are managed by another pallet.
///
/// There is an assumption that, this account is keyless and managed by another pallet in the
/// runtime. Hence, it can never sign its own transactions.
fn is_virtual_staker(who: &T::AccountId) -> bool {
VirtualStakers::<T>::contains_key(who)
frame_system::Pallet::<T>::account_nonce(who).is_zero()
bkchr marked this conversation as resolved.
Show resolved Hide resolved
&& VirtualStakers::<T>::contains_key(who)
}

fn slash_reward_fraction() -> Perbill {
Expand Down Expand Up @@ -2103,6 +2107,8 @@ impl<T: Config> Pallet<T> {
Ledger::<T>::get(stash.clone()).unwrap().stash == stash,
"ledger corrupted for virtual staker"
);
ensure!(frame_system::Pallet::<T>::account_nonce(&stash).is_zero(),
"virtual stakers are keyless and should not have any nonce");
Ank4n marked this conversation as resolved.
Show resolved Hide resolved
let reward_destination = <Payee<T>>::get(stash.clone()).unwrap();
if let RewardDestination::Account(payee) = reward_destination {
ensure!(
Expand Down
Loading