mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 14:37:57 +00:00
[NPoS] Check if staker is exposed in paged exposure storage entries (#2369)
Addresses a bug caused by https://github.com/paritytech/polkadot-sdk/pull/1189. The changes are still not released yet, so would like to push the fix soon so it can go together with the release of the above PR. `fast_unstake` checks if a staker is exposed in an era. However, this fn is still returning whether the staker is exposed based on the old storage item. This PR fixes that by looking in both old and new exposure storages. Also adds some integrity tests for paged exposures.
This commit is contained in:
@@ -6637,6 +6637,14 @@ fn test_validator_exposure_is_backward_compatible_with_non_paged_rewards_payout(
|
||||
);
|
||||
assert_eq!(EraInfo::<Test>::get_page_count(1, &11), 2);
|
||||
|
||||
// validator is exposed
|
||||
assert!(<Staking as sp_staking::StakingInterface>::is_exposed_in_era(&11, &1));
|
||||
// nominators are exposed
|
||||
for i in 10..15 {
|
||||
let who: AccountId = 1000 + i;
|
||||
assert!(<Staking as sp_staking::StakingInterface>::is_exposed_in_era(&who, &1));
|
||||
}
|
||||
|
||||
// case 2: exposure exist in ErasStakers and ErasStakersClipped (legacy).
|
||||
// delete paged storage and add exposure to clipped storage
|
||||
<ErasStakersPaged<Test>>::remove((1, 11, 0));
|
||||
@@ -6672,6 +6680,14 @@ fn test_validator_exposure_is_backward_compatible_with_non_paged_rewards_payout(
|
||||
assert_eq!(actual_exposure_full.own, 1000);
|
||||
assert_eq!(actual_exposure_full.total, total_exposure);
|
||||
|
||||
// validator is exposed
|
||||
assert!(<Staking as sp_staking::StakingInterface>::is_exposed_in_era(&11, &1));
|
||||
// nominators are exposed
|
||||
for i in 10..15 {
|
||||
let who: AccountId = 1000 + i;
|
||||
assert!(<Staking as sp_staking::StakingInterface>::is_exposed_in_era(&who, &1));
|
||||
}
|
||||
|
||||
// for pages other than 0, clipped storage returns empty exposure
|
||||
assert_eq!(EraInfo::<Test>::get_paged_exposure(1, &11, 1), None);
|
||||
// page size is 1 for clipped storage
|
||||
|
||||
Reference in New Issue
Block a user