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

[Staking] Currency <> Fungible migration #5501

Open
wants to merge 70 commits into
base: ankan/staking-migrate-currency-to-fungible
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 63 commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
c92a0bd
add fungible to config
Ank4n Aug 18, 2024
ebf60ef
rustdoc fix
Ank4n Aug 27, 2024
07e3ca9
rename Fungible to Currency
Ank4n Aug 27, 2024
58e8e83
add support for fungible imbalance handler in pallet treasury
Ank4n Aug 27, 2024
a9d0345
fix unused imports
Ank4n Aug 27, 2024
5157b3b
Merge branch 'ankan/staking-migrate-currency-to-fungible' into ankan/…
Ank4n Aug 27, 2024
e6c705e
missing import
Ank4n Aug 27, 2024
c4a9c9d
conditional import of fun mutate
Ank4n Aug 27, 2024
f5c6fe9
Merge branch 'ankan/staking-migrate-currency-to-fungible' into ankan/…
Ank4n Aug 28, 2024
6f503f7
Merge branch 'ankan/staking-migrate-currency-to-fungible' into ankan/…
Ank4n Aug 28, 2024
6659456
Merge branch 'ankan/staking-migrate-currency-to-fungible' into ankan/…
Ank4n Aug 28, 2024
e5b80ce
fix event count with fungibles
Ank4n Aug 28, 2024
426ac1c
Merge branch 'ankan/staking-migrate-currency-to-fungible' into ankan/…
Ank4n Aug 28, 2024
b2cbe7d
Merge branch 'ankan/staking-migrate-currency-to-fungible' into ankan/…
Ank4n Aug 28, 2024
6a7368c
Merge branch 'ankan/staking-migrate-currency-to-fungible' into ankan/…
Ank4n Aug 28, 2024
0ec6a3b
fix failing tests
Ank4n Aug 28, 2024
7f7e394
Merge branch 'ankan/staking-migrate-currency-to-fungible' into ankan/…
Ank4n Aug 28, 2024
59f22f0
Merge branch 'ankan/staking-migrate-currency-to-fungible' into ankan/…
Ank4n Aug 28, 2024
0188158
best effort while minting money
Ank4n Aug 28, 2024
d03469c
Merge branch 'ankan/staking-migrate-currency-to-fungible' into ankan/…
Ank4n Sep 1, 2024
0dc0ca4
fix ed bug while minting
Ank4n Sep 1, 2024
f0ef9d1
release/dec consumer before dec providers
Ank4n Sep 2, 2024
ca81fea
works, but hacky
Ank4n Sep 2, 2024
b15efb6
fix provider
Ank4n Sep 2, 2024
b1f313b
remove the hack provider logic
Ank4n Sep 3, 2024
32be80c
verify only for tests
Ank4n Sep 3, 2024
e0fac32
hacky to pass tests for now
Ank4n Sep 4, 2024
d74ebd6
unused import
Ank4n Sep 4, 2024
c5a7730
staking does not need to inc consumer anymore
Ank4n Sep 4, 2024
dedecbc
purge session key when trying to kill stash
Ank4n Sep 4, 2024
9053d4f
Merge branch 'ankan/staking-migrate-currency-to-fungible' into ankan/…
Ank4n Sep 5, 2024
bcdb749
small updates
Ank4n Sep 5, 2024
18928a4
kill stake is fallible
Ank4n Sep 5, 2024
6a7001e
fail ledger kill if stake cannot be killed
Ank4n Sep 5, 2024
ef54e9a
doc fixes
Ank4n Sep 5, 2024
4555209
fmt
Ank4n Sep 5, 2024
684828a
fix migrate test
Ank4n Sep 5, 2024
a7272be
Merge branch 'ankan/staking-migrate-currency-to-fungible' into ankan/…
Ank4n Sep 6, 2024
6d94601
rename agent kill function
Ank4n Sep 6, 2024
a3267af
small edits
Ank4n Sep 6, 2024
dc4a9a4
fmt
Ank4n Sep 6, 2024
605f698
Merge branch 'ankan/staking-migrate-currency-to-fungible' into ankan/…
Ank4n Sep 6, 2024
9570a61
remove provider inc in pallet-delegated-staking
Ank4n Sep 10, 2024
09f20e1
Merge branch 'ankan/staking-migrate-currency-to-fungible' into ankan/…
Ank4n Sep 11, 2024
0e7e8d5
add migrate function to staking
Ank4n Sep 11, 2024
7fad817
remote test
Ank4n Sep 11, 2024
bb7b8a0
fmt
Ank4n Sep 11, 2024
03242b2
Merge branch 'ankan/staking-migrate-currency-to-fungible' into ankan/…
Ank4n Sep 13, 2024
7bc7086
add OldCurrency to runtime configs
Ank4n Sep 13, 2024
9ed4716
add old currency to config
Ank4n Sep 13, 2024
c009a62
ensure ledger update also updates holds
Ank4n Sep 15, 2024
17c4aa3
new call to migrate currency
Ank4n Sep 15, 2024
c4af869
force withdraw test
Ank4n Sep 15, 2024
e1f1d42
fmt
Ank4n Sep 15, 2024
b57660d
add reap stash fail test
Ank4n Sep 15, 2024
dc55b97
split stakeable into staked and free to stake
Ank4n Sep 15, 2024
591945d
refactor remote test migration
Ank4n Sep 15, 2024
2760773
Merge branch 'ankan/staking-migrate-currency-to-fungible' into ankan/…
Ank4n Sep 16, 2024
a1ccab7
add bench for migrate currency
Ank4n Sep 16, 2024
8c59b58
fix try states
Ank4n Sep 17, 2024
36bb12e
prdoc
Ank4n Sep 17, 2024
c06e60b
clippy fix
Ank4n Sep 17, 2024
5c29547
improve tests
Ank4n Sep 17, 2024
7f1165e
Merge branch 'ankan/staking-migrate-currency-to-fungible' of https://…
Sep 17, 2024
f07061b
".git/.scripts/commands/bench/bench.sh" --subcommand=pallet --runtime…
Sep 17, 2024
da0a7c3
".git/.scripts/commands/bench/bench.sh" --subcommand=pallet --runtime…
Sep 17, 2024
b3352dd
comment about ignoring resolve err
Ank4n Sep 18, 2024
f0d2d14
total balance for ED
Ank4n Sep 18, 2024
3ca1081
ensure ti is updated at reward
Ank4n Sep 19, 2024
7a16988
make slash resolve to treasury defensive
Ank4n Sep 19, 2024
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
2 changes: 2 additions & 0 deletions polkadot/runtime/test-runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -344,11 +344,13 @@ impl onchain::Config for OnChainSeqPhragmen {
const MAX_QUOTA_NOMINATIONS: u32 = 16;

impl pallet_staking::Config for Runtime {
type OldCurrency = Balances;
type Currency = Balances;
type CurrencyBalance = Balance;
type UnixTime = Timestamp;
type CurrencyToVote = polkadot_runtime_common::CurrencyToVote;
type RewardRemainder = ();
type RuntimeHoldReason = RuntimeHoldReason;
type RuntimeEvent = RuntimeEvent;
type Slash = ();
type Reward = ();
Expand Down
2 changes: 2 additions & 0 deletions polkadot/runtime/westend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -730,8 +730,10 @@ parameter_types! {
}

impl pallet_staking::Config for Runtime {
type OldCurrency = Balances;
type Currency = Balances;
type CurrencyBalance = Balance;
type RuntimeHoldReason = RuntimeHoldReason;
type UnixTime = Timestamp;
type CurrencyToVote = CurrencyToVote;
type RewardRemainder = ();
Expand Down
99 changes: 86 additions & 13 deletions polkadot/runtime/westend/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,25 +149,27 @@ mod remote_tests {

let transport: Transport = var("WS").unwrap_or("ws://127.0.0.1:9900".to_string()).into();
let maybe_state_snapshot: Option<SnapshotConfig> = var("SNAP").map(|s| s.into()).ok();
let online_config = OnlineConfig {
transport,
state_snapshot: maybe_state_snapshot.clone(),
child_trie: false,
pallets: vec![
"Staking".into(),
"System".into(),
"Balances".into(),
"NominationPools".into(),
"DelegatedStaking".into(),
],
..Default::default()
};
let mut ext = Builder::<Block>::default()
.mode(if let Some(state_snapshot) = maybe_state_snapshot {
Mode::OfflineOrElseOnline(
OfflineConfig { state_snapshot: state_snapshot.clone() },
OnlineConfig {
transport,
state_snapshot: Some(state_snapshot),
pallets: vec![
"staking".into(),
"system".into(),
"balances".into(),
"nomination-pools".into(),
"delegated-staking".into(),
],
..Default::default()
},
online_config,
)
} else {
Mode::Online(OnlineConfig { transport, ..Default::default() })
Mode::Online(online_config)
})
.build()
.await
Expand Down Expand Up @@ -235,4 +237,75 @@ mod remote_tests {
);
});
}

#[tokio::test]
async fn staking_curr_fun_migrate() {
// Intended to be run only manually.
if var("RUN_MIGRATION_TESTS").is_err() {
return;
}
sp_tracing::try_init_simple();

let transport: Transport = var("WS").unwrap_or("ws://127.0.0.1:9900".to_string()).into();
let maybe_state_snapshot: Option<SnapshotConfig> = var("SNAP").map(|s| s.into()).ok();
let online_config = OnlineConfig {
transport,
state_snapshot: maybe_state_snapshot.clone(),
child_trie: false,
pallets: vec!["Staking".into(), "System".into(), "Balances".into()],
..Default::default()
};
let mut ext = Builder::<Block>::default()
.mode(if let Some(state_snapshot) = maybe_state_snapshot {
Mode::OfflineOrElseOnline(
OfflineConfig { state_snapshot: state_snapshot.clone() },
online_config,
)
} else {
Mode::Online(online_config)
})
.build()
.await
.unwrap();
ext.execute_with(|| {
// create an account with some balance
let alice = AccountId::from([1u8; 32]);
use frame_support::traits::Currency;
let _ = Balances::deposit_creating(&alice, 100_000 * UNITS);

let mut success = 0;
let mut err = 0;
let mut force_withdraw_acc = 0;
// iterate over all pools
pallet_staking::Ledger::<Runtime>::iter().for_each(|(ctrl, ledger)| {
match pallet_staking::Pallet::<Runtime>::migrate_currency(
RuntimeOrigin::signed(alice.clone()).into(),
ledger.stash.clone(),
) {
Ok(_) => {
let updated_ledger =
pallet_staking::Ledger::<Runtime>::get(&ctrl).expect("ledger exists");
let force_withdraw = ledger.total - updated_ledger.total;
if force_withdraw > 0 {
force_withdraw_acc += force_withdraw;
log::info!(target: "remote_test", "Force withdraw from stash {:?}: value {:?}", ledger.stash, force_withdraw);
}
success += 1;
},
Err(e) => {
log::error!(target: "remote_test", "Error migrating {:?}: {:?}", ledger.stash, e);
err += 1;
},
}
});

log::info!(
target: "remote_test",
"Migration stats: success: {}, err: {}, total force withdrawn stake: {}",
success,
err,
force_withdraw_acc
);
});
}
}
4 changes: 4 additions & 0 deletions polkadot/runtime/westend/src/weights/pallet_staking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -826,4 +826,8 @@ impl<T: frame_system::Config> pallet_staking::WeightInfo for WeightInfo<T> {
.saturating_add(T::DbWeight::get().reads(5))
.saturating_add(T::DbWeight::get().writes(4))
}
fn migrate_currency() -> Weight {
// will be auto-generated
Default::default()
}
}
27 changes: 27 additions & 0 deletions prdoc/pr_5501.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0
# See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json

title: Currency to Fungible migration for pallet-staking

doc:
- audience: Runtime User
description: |
Lazy migration of staking balance from `Currency::locks` to `Fungible::holds`. New extrinsic
`staking::migrate_currency` removes the old lock along with other housekeeping. Additionally, any ledger mutation
creates hold if it does not exist.

crates:
- name: westend-runtime
bump: minor
- name: kitchensink-runtime
bump: minor
- name: pallet-delegated-staking
bump: patch
- name: pallet-nomination-pools
bump: patch
- name: frame-support
bump: patch
- name: pallet-treasury
bump: minor
- name: sp-staking
bump: minor
6 changes: 4 additions & 2 deletions substrate/bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -666,13 +666,15 @@ impl pallet_staking::BenchmarkingConfig for StakingBenchmarkingConfig {
}

impl pallet_staking::Config for Runtime {
type OldCurrency = Balances;
type Currency = Balances;
type CurrencyBalance = Balance;
type UnixTime = Timestamp;
type CurrencyToVote = sp_staking::currency_to_vote::U128CurrencyToVote;
type RewardRemainder = Treasury;
type RewardRemainder = pallet_treasury::FungibleCompat<Self>;
type RuntimeEvent = RuntimeEvent;
type Slash = Treasury; // send the slashed funds to the treasury.
type RuntimeHoldReason = RuntimeHoldReason;
type Slash = pallet_treasury::FungibleCompat<Self>; // send the slashed funds to the treasury.
type Reward = (); // rewards are minted from the void
type SessionsPerEra = SessionsPerEra;
type BondingDuration = BondingDuration;
Expand Down
1 change: 1 addition & 0 deletions substrate/frame/babe/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ impl onchain::Config for OnChainSeqPhragmen {

#[derive_impl(pallet_staking::config_preludes::TestDefaultConfig)]
impl pallet_staking::Config for Test {
type OldCurrency = Balances;
type Currency = Balances;
type SessionsPerEra = SessionsPerEra;
type BondingDuration = BondingDuration;
Expand Down
1 change: 1 addition & 0 deletions substrate/frame/beefy/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ impl onchain::Config for OnChainSeqPhragmen {
#[derive_impl(pallet_staking::config_preludes::TestDefaultConfig)]
impl pallet_staking::Config for Test {
type RuntimeEvent = RuntimeEvent;
type OldCurrency = Balances;
type Currency = Balances;
type AdminOrigin = frame_system::EnsureRoot<Self::AccountId>;
type SessionInterface = Self;
Expand Down
2 changes: 1 addition & 1 deletion substrate/frame/delegated-staking/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ impl<T: Config> Pallet<T> {
let stake = T::CoreStaking::stake(who)?;

// release funds from core staking.
T::CoreStaking::migrate_to_virtual_staker(who);
T::CoreStaking::migrate_to_virtual_staker(who)?;

// transfer just released staked amount plus any free amount.
let amount_to_transfer =
Expand Down
1 change: 1 addition & 0 deletions substrate/frame/delegated-staking/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ impl onchain::Config for OnChainSeqPhragmen {

#[derive_impl(pallet_staking::config_preludes::TestDefaultConfig)]
impl pallet_staking::Config for Runtime {
type OldCurrency = Balances;
type Currency = Balances;
type UnixTime = pallet_timestamp::Pallet<Self>;
type AdminOrigin = frame_system::EnsureRoot<Self::AccountId>;
Expand Down
9 changes: 5 additions & 4 deletions substrate/frame/delegated-staking/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,8 @@ mod staking_integration {
));
assert_ok!(Staking::nominate(RuntimeOrigin::signed(agent), vec![GENESIS_VALIDATOR],));
let init_stake = Staking::stake(&agent).unwrap();
// agent has an extra provider now added by CoreStaking.
assert_eq!(System::providers(&agent), 2);

// scenario: 200 is a pool account, and the stake comes from its 4 delegators (300..304)
// in equal parts. lets try to migrate this nominator into delegate based stake.
Expand All @@ -685,8 +687,9 @@ mod staking_integration {
DelegatedStaking::generate_proxy_delegator(Agent::from(agent)).get();

assert_ok!(DelegatedStaking::migrate_to_agent(RawOrigin::Signed(agent).into(), 201));
// after migration, funds are moved to proxy delegator, still a provider exists.
assert_eq!(System::providers(&agent), 1);
// after migration, no provider left since free balance is 0 and staking pallet released
// all funds.
assert_eq!(System::providers(&agent), 0);
assert_eq!(Balances::free_balance(agent), 0);
// proxy delegator has one provider as well with no free balance.
assert_eq!(System::providers(&proxy_delegator), 1);
Expand Down Expand Up @@ -798,8 +801,6 @@ mod staking_integration {
RawOrigin::Signed(agent).into(),
reward_acc
));
// becoming an agent adds another provider.
assert_eq!(System::providers(&agent), 2);

// delegate to this account
fund(&delegator, 1000);
Expand Down
6 changes: 0 additions & 6 deletions substrate/frame/delegated-staking/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,19 +131,13 @@ impl<T: Config> AgentLedger<T> {
///
/// Increments provider count if this is a new agent.
pub(crate) fn update(self, key: &T::AccountId) {
if !<Agents<T>>::contains_key(key) {
// This is a new agent. Provide for this account.
frame_system::Pallet::<T>::inc_providers(key);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agents don't need provider anymore as staking account does not have consumers.
TODO: add migration for agents to dec provider.

}
<Agents<T>>::insert(key, self)
}

/// Remove self from storage.
pub(crate) fn remove(key: &T::AccountId) {
debug_assert!(<Agents<T>>::contains_key(key), "Agent should exist in storage");
<Agents<T>>::remove(key);
// Remove provider reference.
let _ = frame_system::Pallet::<T>::dec_providers(key).defensive();
}

/// Effective total balance of the `Agent`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ pub(crate) const SLASHING_DISABLING_FACTOR: usize = 3;

#[derive_impl(pallet_staking::config_preludes::TestDefaultConfig)]
impl pallet_staking::Config for Runtime {
type OldCurrency = Balances;
type Currency = Balances;
type CurrencyBalance = Balance;
type UnixTime = Timestamp;
Expand Down
1 change: 1 addition & 0 deletions substrate/frame/fast-unstake/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ impl frame_election_provider_support::ElectionProvider for MockElection {

#[derive_impl(pallet_staking::config_preludes::TestDefaultConfig)]
impl pallet_staking::Config for Runtime {
type OldCurrency = Balances;
type Currency = Balances;
type UnixTime = pallet_timestamp::Pallet<Self>;
type AdminOrigin = frame_system::EnsureRoot<Self::AccountId>;
Expand Down
1 change: 1 addition & 0 deletions substrate/frame/grandpa/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ impl onchain::Config for OnChainSeqPhragmen {

#[derive_impl(pallet_staking::config_preludes::TestDefaultConfig)]
impl pallet_staking::Config for Test {
type OldCurrency = Balances;
type Currency = Balances;
type CurrencyBalance = <Self as pallet_balances::Config>::Balance;
type SessionsPerEra = SessionsPerEra;
Expand Down
1 change: 1 addition & 0 deletions substrate/frame/nomination-pools/benchmarking/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ parameter_types! {
}
#[derive_impl(pallet_staking::config_preludes::TestDefaultConfig)]
impl pallet_staking::Config for Runtime {
type OldCurrency = Balances;
type Currency = Balances;
type CurrencyBalance = Balance;
type UnixTime = pallet_timestamp::Pallet<Self>;
Expand Down
3 changes: 2 additions & 1 deletion substrate/frame/nomination-pools/src/adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,8 @@ impl<T: Config, Staking: StakingInterface<Balance = BalanceOf<T>, AccountId = T:
pool_account: Pool<Self::AccountId>,
_: Member<Self::AccountId>,
) -> BalanceOf<T> {
T::Currency::balance(&pool_account.0).saturating_sub(Self::active_stake(pool_account))
// free/liquid balance of the pool account.
T::Currency::balance(&pool_account.0)
}

fn total_balance(pool_account: Pool<Self::AccountId>) -> Option<BalanceOf<T>> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ parameter_types! {

#[derive_impl(pallet_staking::config_preludes::TestDefaultConfig)]
impl pallet_staking::Config for Runtime {
type OldCurrency = Balances;
type Currency = Balances;
type UnixTime = pallet_timestamp::Pallet<Self>;
type AdminOrigin = frame_system::EnsureRoot<Self::AccountId>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,13 +200,13 @@ fn destroy_pool_with_erroneous_consumer() {
assert_ok!(Pools::create(RuntimeOrigin::signed(10), 50, 10, 10, 10));
assert_eq!(LastPoolId::<Runtime>::get(), 1);

// expect consumers on pool account to be 2 (staking lock and an explicit inc by staking).
assert_eq!(frame_system::Pallet::<T>::consumers(&POOL1_BONDED), 2);
// expect consumers on pool account to be 1 (staking hold).
assert_eq!(frame_system::Pallet::<T>::consumers(&POOL1_BONDED), 1);

// increment consumer by 1 reproducing the erroneous consumer bug.
// refer https://github.com/paritytech/polkadot-sdk/issues/4440.
assert_ok!(frame_system::Pallet::<T>::inc_consumers(&POOL1_BONDED));
assert_eq!(frame_system::Pallet::<T>::consumers(&POOL1_BONDED), 3);
assert_eq!(frame_system::Pallet::<T>::consumers(&POOL1_BONDED), 2);

// have the pool nominate.
assert_ok!(Pools::nominate(RuntimeOrigin::signed(10), 1, vec![1, 2, 3]));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ parameter_types! {

#[derive_impl(pallet_staking::config_preludes::TestDefaultConfig)]
impl pallet_staking::Config for Runtime {
type OldCurrency = Balances;
type Currency = Balances;
type UnixTime = pallet_timestamp::Pallet<Self>;
type AdminOrigin = frame_system::EnsureRoot<Self::AccountId>;
Expand Down
10 changes: 4 additions & 6 deletions substrate/frame/offences/benchmarking/src/inner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,8 @@ benchmarks! {
#[cfg(test)]
{
// make sure that all slashes have been applied
// (n nominators + one validator) * (slashed + unlocked) + deposit to reporter + reporter
// account endowed + some funds rescinded from issuance.
assert_eq!(System::<T>::read_events_for_pallet::<pallet_balances::Event<T>>().len(), 2 * (n + 1) as usize + 3);
// deposit to reporter + reporter account endowed.
assert_eq!(System::<T>::read_events_for_pallet::<pallet_balances::Event<T>>().len(), 2);
// (n nominators + one validator) * slashed + Slash Reported
assert_eq!(System::<T>::read_events_for_pallet::<pallet_staking::Event<T>>().len(), 1 * (n + 1) as usize + 1);
// offence
Expand Down Expand Up @@ -245,9 +244,8 @@ benchmarks! {
#[cfg(test)]
{
// make sure that all slashes have been applied
// (n nominators + one validator) * (slashed + unlocked) + deposit to reporter + reporter
// account endowed + some funds rescinded from issuance.
assert_eq!(System::<T>::read_events_for_pallet::<pallet_balances::Event<T>>().len(), 2 * (n + 1) as usize + 3);
// deposit to reporter + reporter account endowed.
assert_eq!(System::<T>::read_events_for_pallet::<pallet_balances::Event<T>>().len(), 2);
// (n nominators + one validator) * slashed + Slash Reported
assert_eq!(System::<T>::read_events_for_pallet::<pallet_staking::Event<T>>().len(), 1 * (n + 1) as usize + 1);
// offence
Expand Down
1 change: 1 addition & 0 deletions substrate/frame/offences/benchmarking/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ impl onchain::Config for OnChainSeqPhragmen {

#[derive_impl(pallet_staking::config_preludes::TestDefaultConfig)]
impl pallet_staking::Config for Test {
type OldCurrency = Balances;
type Currency = Balances;
type CurrencyBalance = <Self as pallet_balances::Config>::Balance;
type UnixTime = pallet_timestamp::Pallet<Self>;
Expand Down
1 change: 1 addition & 0 deletions substrate/frame/root-offences/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ parameter_types! {

#[derive_impl(pallet_staking::config_preludes::TestDefaultConfig)]
impl pallet_staking::Config for Test {
type OldCurrency = Balances;
type Currency = Balances;
type CurrencyBalance = <Self as pallet_balances::Config>::Balance;
type UnixTime = Timestamp;
Expand Down
Loading
Loading