Skip to content

Commit

Permalink
Merge branch 'master' of github.com:paritytech/polkadot-sdk into auth…
Browse files Browse the repository at this point in the history
…orize-alias
  • Loading branch information
acatangiu committed Jan 17, 2025
2 parents f434f45 + 4b2febe commit ab80b6e
Show file tree
Hide file tree
Showing 63 changed files with 2,136 additions and 2,483 deletions.
24 changes: 1 addition & 23 deletions Cargo.lock

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

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,6 @@ 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: 1 addition & 1 deletion bridges/relays/lib-substrate-relay/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ pub enum Error<Hash: Debug + MaybeDisplay, HeaderNumber: Debug + MaybeDisplay> {
#[error("Failed to guess initial {0} GRANDPA authorities set id: checked all possible ids in range [0; {1}]")]
GuessInitialAuthorities(&'static str, HeaderNumber),
/// Failed to retrieve GRANDPA authorities at the given header from the source chain.
#[error("Failed to retrive {0} GRANDPA authorities set at header {1}: {2:?}")]
#[error("Failed to retrieve {0} GRANDPA authorities set at header {1}: {2:?}")]
RetrieveAuthorities(&'static str, Hash, client::Error),
/// Failed to decode GRANDPA authorities at the given header of the source chain.
#[error("Failed to decode {0} GRANDPA authorities set at header {1}: {2:?}")]
Expand Down
2 changes: 1 addition & 1 deletion bridges/relays/messages/src/message_lane_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1041,7 +1041,7 @@ pub(crate) mod tests {
#[test]
fn message_lane_loop_is_able_to_recover_from_unsuccessful_transaction() {
// with this configuration, both source and target clients will mine their transactions, but
// their corresponding nonce won't be udpated => reconnect will happen
// their corresponding nonce won't be updated => reconnect will happen
let (exit_sender, exit_receiver) = unbounded();
let result = run_loop_test(
Arc::new(Mutex::new(TestClientData {
Expand Down
4 changes: 2 additions & 2 deletions bridges/snowbridge/primitives/core/src/location.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ mod tests {
for token in token_locations {
assert!(
TokenIdOf::convert_location(&token).is_some(),
"Valid token = {token:?} yeilds no TokenId."
"Valid token = {token:?} yields no TokenId."
);
}

Expand All @@ -220,7 +220,7 @@ mod tests {
for token in non_token_locations {
assert!(
TokenIdOf::convert_location(&token).is_none(),
"Invalid token = {token:?} yeilds a TokenId."
"Invalid token = {token:?} yields a TokenId."
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion docs/sdk/packages/guides/first-pallet/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ targets = ["x86_64-unknown-linux-gnu"]
[dependencies]
codec = { workspace = true }
docify = { workspace = true }
frame = { workspace = true, features = ["experimental", "runtime"] }
frame = { workspace = true, features = ["runtime"] }
scale-info = { workspace = true }

[features]
Expand Down
2 changes: 1 addition & 1 deletion docs/sdk/packages/guides/first-runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ scale-info = { workspace = true }
serde_json = { workspace = true }

# this is a frame-based runtime, thus importing `frame` with runtime feature enabled.
frame = { workspace = true, features = ["experimental", "runtime"] }
frame = { workspace = true, features = ["runtime"] }

# pallets that we want to use
pallet-balances = { workspace = true }
Expand Down
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 @@ -366,11 +366,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 @@ -728,8 +728,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 @@ -155,25 +155,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 @@ -241,6 +243,77 @@ 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 ab80b6e

Please sign in to comment.