Skip to content

Commit 8db41ea

Browse files
committed
fix
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
1 parent a7134c3 commit 8db41ea

File tree

5 files changed

+164
-163
lines changed

5 files changed

+164
-163
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ pub mod governance;
3636
mod migrations;
3737
pub mod staking;
3838

39-
use governance::{pallet_custom_origins, FellowshipAdmin, GeneralAdmin, StakingAdmin, Treasurer, TreasuryAccount};
39+
use governance::{
40+
pallet_custom_origins, FellowshipAdmin, GeneralAdmin, StakingAdmin, Treasurer, TreasuryAccount,
41+
};
4042

4143
extern crate alloc;
4244

substrate/frame/recovery/Cargo.toml

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@ targets = ["x86_64-unknown-linux-gnu"]
1818
[dependencies]
1919
codec = { features = ["derive"], workspace = true }
2020
frame = { workspace = true, features = ["runtime"] }
21-
scale-info = { features = ["derive"], workspace = true }
22-
frame-system = { workspace = true }
2321
frame-support = { workspace = true }
22+
frame-system = { workspace = true }
23+
log = { workspace = true, optional = true }
24+
scale-info = { features = ["derive"], workspace = true }
2425

2526
[dev-dependencies]
2627
pallet-balances = { workspace = true, default-features = true }
@@ -30,26 +31,28 @@ sp-runtime = { workspace = true }
3031
[features]
3132
default = ["std"]
3233
runtime-benchmarks = [
34+
"frame-support/runtime-benchmarks",
35+
"frame-system/runtime-benchmarks",
3336
"frame/runtime-benchmarks",
3437
"pallet-balances/runtime-benchmarks",
3538
"sp-runtime/runtime-benchmarks",
36-
"frame-support/runtime-benchmarks",
37-
"frame-system/runtime-benchmarks"
3839
]
3940
std = [
4041
"codec/std",
42+
"frame-support/std",
43+
"frame-system/std",
4144
"frame/std",
45+
"log?/std",
4246
"pallet-balances/std",
4347
"scale-info/std",
4448
"sp-io/std",
4549
"sp-runtime/std",
46-
"frame-support/std",
47-
"frame-system/std"
4850
]
4951
try-runtime = [
52+
"dep:log",
53+
"frame-support/try-runtime",
54+
"frame-system/try-runtime",
5055
"frame/try-runtime",
5156
"pallet-balances/try-runtime",
5257
"sp-runtime/try-runtime",
53-
"frame-support/try-runtime",
54-
"frame-system/try-runtime"
5558
]

substrate/frame/recovery/src/migrations/v0.rs

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,21 @@
1919
//!
2020
//! These represent the old storage layout before the v1 migration.
2121
22-
use crate::InheritanceOrder;
2322
use codec::{Decode, Encode, MaxEncodedLen};
24-
use frame::deps::sp_io::hashing::blake2_256;
25-
use frame::deps::sp_runtime::traits::TrailingZeroInput;
26-
use frame::traits::BlockNumberProvider;
23+
use frame::{
24+
deps::{sp_io::hashing::blake2_256, sp_runtime::traits::TrailingZeroInput},
25+
traits::BlockNumberProvider,
26+
};
2727
use frame_support::{
2828
storage_alias,
2929
traits::{Currency, ReservableCurrency},
3030
Blake2_128Concat, BoundedVec, Twox64Concat,
3131
};
3232
use scale_info::TypeInfo;
3333

34-
/// Migration config - extends the new pallet Config with types needed for migration.
34+
/// Extended migration config for the migration.
3535
pub trait MigrationConfig: crate::pallet::Config {
36-
/// The currency type used in v0.
37-
/// Must implement ReservableCurrency for unreserving deposits.
38-
/// The Balance type must match the new pallet's Balance type.
36+
/// The currency to unreserve deposits.
3937
type Currency: ReservableCurrency<Self::AccountId, Balance = crate::BalanceOf<Self>>;
4038
}
4139

@@ -45,26 +43,30 @@ pub trait MigrationConfig: crate::pallet::Config {
4543
/// will be the multisig account that the friends can control together.
4644
///
4745
/// NOTE: `who` must be sorted. If it is not, then you'll get the wrong answer.
48-
pub fn multi_account_id<AccountId: Encode + Decode>(who: &[AccountId], threshold: u16) -> AccountId {
46+
pub fn multi_account_id<AccountId: Encode + Decode>(
47+
who: &[AccountId],
48+
threshold: u16,
49+
) -> AccountId {
4950
let entropy = (b"modlpy/utilisuba", who, threshold).using_encoded(blake2_256);
5051
Decode::decode(&mut TrailingZeroInput::new(entropy.as_ref()))
5152
.expect("infinite length input; no invalid inputs for type; qed")
5253
}
5354

54-
/// Old balance type for v0 storage.
55+
/// Balance type for v0 storage.
5556
pub type BalanceOf<T> =
5657
<<T as MigrationConfig>::Currency as Currency<<T as frame_system::Config>::AccountId>>::Balance;
5758

58-
/// Old block number type from provider.
59+
/// Block number type from provider.
5960
pub type BlockNumberFromProviderOf<T> =
6061
<<T as crate::pallet::Config>::BlockNumberProvider as BlockNumberProvider>::BlockNumber;
6162

62-
/// Old friends bounded vec type.
63-
/// Uses MaxFriendsPerConfig from the new pallet Config (assumes same as old MaxFriends).
64-
pub type FriendsOf<T> =
65-
BoundedVec<<T as frame_system::Config>::AccountId, <T as crate::pallet::Config>::MaxFriendsPerConfig>;
63+
/// Friends bounded vec type.
64+
pub type FriendsOf<T> = BoundedVec<
65+
<T as frame_system::Config>::AccountId,
66+
<T as crate::pallet::Config>::MaxFriendsPerConfig,
67+
>;
6668

67-
/// Old recovery configuration structure from v0.
69+
/// Recovery configuration structure from v0.
6870
#[derive(Clone, Eq, PartialEq, Encode, Decode, Default, TypeInfo, MaxEncodedLen)]
6971
pub struct RecoveryConfig<BlockNumber, Balance, Friends> {
7072
/// The minimum number of blocks since the start of the recovery process before the
@@ -79,25 +81,20 @@ pub struct RecoveryConfig<BlockNumber, Balance, Friends> {
7981
pub threshold: u16,
8082
}
8183

82-
impl<BlockNumber, Balance, Friends> RecoveryConfig<BlockNumber, Balance, Friends> {
83-
/// Convert v0 RecoveryConfig to v1 FriendGroup.
84-
///
85-
/// Since v0 didn't have `inheritor`, `inheritance_order`, or `cancel_delay`,
86-
/// these must be provided as parameters.
84+
impl<BlockNumber: Clone, Balance, Friends> RecoveryConfig<BlockNumber, Balance, Friends> {
85+
/// Convert to a V1 `FriendGroup`.
8786
pub fn into_v1_friend_group<AccountId>(
8887
self,
8988
inheritor: AccountId,
90-
inheritance_order: InheritanceOrder,
91-
cancel_delay: BlockNumber,
9289
) -> crate::FriendGroup<BlockNumber, AccountId, Balance, Friends> {
9390
crate::FriendGroup {
9491
deposit: self.deposit,
9592
friends: self.friends,
9693
friends_needed: self.threshold as u32,
9794
inheritor,
98-
inheritance_delay: self.delay_period,
99-
inheritance_order,
100-
cancel_delay,
95+
inheritance_delay: self.delay_period.clone(),
96+
inheritance_order: 0,
97+
cancel_delay: self.delay_period, // kinda random
10198
}
10299
}
103100
}
@@ -114,7 +111,7 @@ pub struct ActiveRecovery<BlockNumber, Balance, Friends> {
114111
pub friends: Friends,
115112
}
116113

117-
/// Old storage: The set of recoverable accounts and their recovery configuration.
114+
/// The set of recoverable accounts and their recovery configuration.
118115
#[storage_alias]
119116
pub type Recoverable<T: MigrationConfig> = StorageMap<
120117
crate::pallet::Pallet<T>,

0 commit comments

Comments
 (0)