Skip to content

Commit

Permalink
Revert "[Staking] Currency <> Fungible migration (#5501)"
Browse files Browse the repository at this point in the history
This reverts commit f5673cf.
  • Loading branch information
pepoviola authored Jan 20, 2025
1 parent cbf3925 commit 2d3f7a2
Show file tree
Hide file tree
Showing 47 changed files with 2,466 additions and 2,100 deletions.
24 changes: 23 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,7 @@ members = [
"substrate/frame/nomination-pools/fuzzer",
"substrate/frame/nomination-pools/runtime-api",
"substrate/frame/nomination-pools/test-delegate-stake",
"substrate/frame/nomination-pools/test-transfer-stake",
"substrate/frame/offences",
"substrate/frame/offences/benchmarking",
"substrate/frame/paged-list",
Expand Down
2 changes: 0 additions & 2 deletions polkadot/runtime/test-runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -366,13 +366,11 @@ 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: 0 additions & 2 deletions polkadot/runtime/westend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -728,10 +728,8 @@ 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: 13 additions & 86 deletions polkadot/runtime/westend/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,27 +155,25 @@ 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() },
online_config,
OnlineConfig {
transport,
state_snapshot: Some(state_snapshot),
pallets: vec![
"staking".into(),
"system".into(),
"balances".into(),
"nomination-pools".into(),
"delegated-staking".into(),
],
..Default::default()
},
)
} else {
Mode::Online(online_config)
Mode::Online(OnlineConfig { transport, ..Default::default() })
})
.build()
.await
Expand Down Expand Up @@ -243,77 +241,6 @@ 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:9944".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
);
});
}
}

#[test]
Expand Down
Loading

0 comments on commit 2d3f7a2

Please sign in to comment.