Skip to content

Commit 5577411

Browse files
authored
Merge branch 'master' into hasher_trait_for_pallet_beefy
2 parents 5933c12 + c405dda commit 5577411

File tree

116 files changed

+4591
-776
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

116 files changed

+4591
-776
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,8 @@ members = [
417417
"substrate/frame/referenda",
418418
"substrate/frame/remark",
419419
"substrate/frame/revive",
420+
"substrate/frame/revive/dev-node/node",
421+
"substrate/frame/revive/dev-node/runtime",
420422
"substrate/frame/revive/fixtures",
421423
"substrate/frame/revive/proc-macro",
422424
"substrate/frame/revive/rpc",
@@ -1040,6 +1042,8 @@ pallet-staking = { path = "substrate/frame/staking", default-features = false }
10401042
pallet-staking-reward-curve = { path = "substrate/frame/staking/reward-curve", default-features = false }
10411043
pallet-staking-reward-fn = { path = "substrate/frame/staking/reward-fn", default-features = false }
10421044
pallet-staking-runtime-api = { path = "substrate/frame/staking/runtime-api", default-features = false }
1045+
revive-dev-node = { path = "substrate/frame/revive/dev-node/node" }
1046+
revive-dev-runtime = { path = "substrate/frame/revive/dev-node/runtime" }
10431047
# TODO: remove the reward stuff as they are not needed here
10441048
pallet-staking-async = { path = "substrate/frame/staking-async", default-features = false }
10451049
pallet-staking-async-ah-client = { path = "substrate/frame/staking-async/ah-client", default-features = false }

cumulus/pallets/collator-selection/src/benchmarking.rs

Lines changed: 31 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ fn create_funded_user<T: Config>(
4949
balance_factor: u32,
5050
) -> T::AccountId {
5151
let user = account(string, n, SEED);
52-
let balance = T::Currency::minimum_balance() * balance_factor.into();
53-
let _ = T::Currency::make_free_balance_be(&user, balance);
52+
let balance = <T as pallet::Config>::Currency::minimum_balance() * balance_factor.into();
53+
let _ = <T as pallet::Config>::Currency::make_free_balance_be(&user, balance);
5454
user
5555
}
5656

@@ -90,7 +90,10 @@ fn register_candidates<T: Config>(count: u32) {
9090
assert!(CandidacyBond::<T>::get() > 0u32.into(), "Bond cannot be zero!");
9191

9292
for who in candidates {
93-
T::Currency::make_free_balance_be(&who, CandidacyBond::<T>::get() * 3u32.into());
93+
<T as pallet::Config>::Currency::make_free_balance_be(
94+
&who,
95+
CandidacyBond::<T>::get() * 3u32.into(),
96+
);
9497
<CollatorSelection<T>>::register_as_candidate(RawOrigin::Signed(who).into()).unwrap();
9598
}
9699
}
@@ -144,7 +147,7 @@ mod benchmarks {
144147
T::UpdateOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?;
145148

146149
// need to fill up candidates
147-
CandidacyBond::<T>::put(T::Currency::minimum_balance());
150+
CandidacyBond::<T>::put(<T as pallet::Config>::Currency::minimum_balance());
148151
DesiredCandidates::<T>::put(c);
149152
// get accounts and keys for the `c` candidates
150153
let mut candidates = (0..c).map(|cc| validator::<T>(cc)).collect::<Vec<_>>();
@@ -161,13 +164,13 @@ mod benchmarks {
161164
// ... and register them.
162165
for (who, _) in candidates.iter() {
163166
let deposit = CandidacyBond::<T>::get();
164-
T::Currency::make_free_balance_be(who, deposit * 1000_u32.into());
167+
<T as pallet::Config>::Currency::make_free_balance_be(who, deposit * 1000_u32.into());
165168
CandidateList::<T>::try_mutate(|list| {
166169
list.try_push(CandidateInfo { who: who.clone(), deposit }).unwrap();
167170
Ok::<(), BenchmarkError>(())
168171
})
169172
.unwrap();
170-
T::Currency::reserve(who, deposit)?;
173+
<T as pallet::Config>::Currency::reserve(who, deposit)?;
171174
LastAuthoredBlock::<T>::insert(
172175
who.clone(),
173176
frame_system::Pallet::<T>::block_number() + T::KickThreshold::get(),
@@ -226,7 +229,8 @@ mod benchmarks {
226229
c: Linear<0, { T::MaxCandidates::get() }>,
227230
k: Linear<0, { T::MaxCandidates::get() }>,
228231
) -> Result<(), BenchmarkError> {
229-
let initial_bond_amount: BalanceOf<T> = T::Currency::minimum_balance() * 2u32.into();
232+
let initial_bond_amount: BalanceOf<T> =
233+
<T as pallet::Config>::Currency::minimum_balance() * 2u32.into();
230234
CandidacyBond::<T>::put(initial_bond_amount);
231235
register_validators::<T>(c);
232236
register_candidates::<T>(c);
@@ -236,12 +240,12 @@ mod benchmarks {
236240
let bond_amount = if k > 0 {
237241
CandidateList::<T>::mutate(|candidates| {
238242
for info in candidates.iter_mut().skip(kicked as usize) {
239-
info.deposit = T::Currency::minimum_balance() * 3u32.into();
243+
info.deposit = <T as pallet::Config>::Currency::minimum_balance() * 3u32.into();
240244
}
241245
});
242-
T::Currency::minimum_balance() * 3u32.into()
246+
<T as pallet::Config>::Currency::minimum_balance() * 3u32.into()
243247
} else {
244-
T::Currency::minimum_balance()
248+
<T as pallet::Config>::Currency::minimum_balance()
245249
};
246250

247251
#[extrinsic_call]
@@ -255,7 +259,7 @@ mod benchmarks {
255259
fn update_bond(
256260
c: Linear<{ min_candidates::<T>() + 1 }, { T::MaxCandidates::get() }>,
257261
) -> Result<(), BenchmarkError> {
258-
CandidacyBond::<T>::put(T::Currency::minimum_balance());
262+
CandidacyBond::<T>::put(<T as pallet::Config>::Currency::minimum_balance());
259263
DesiredCandidates::<T>::put(c);
260264

261265
register_validators::<T>(c);
@@ -264,8 +268,8 @@ mod benchmarks {
264268
let caller = CandidateList::<T>::get()[0].who.clone();
265269
v2::whitelist!(caller);
266270

267-
let bond_amount: BalanceOf<T> =
268-
T::Currency::minimum_balance() + T::Currency::minimum_balance();
271+
let bond_amount: BalanceOf<T> = <T as pallet::Config>::Currency::minimum_balance() +
272+
<T as pallet::Config>::Currency::minimum_balance();
269273

270274
#[extrinsic_call]
271275
_(RawOrigin::Signed(caller.clone()), bond_amount);
@@ -275,7 +279,7 @@ mod benchmarks {
275279
);
276280
assert!(
277281
CandidateList::<T>::get().iter().last().unwrap().deposit ==
278-
T::Currency::minimum_balance() * 2u32.into()
282+
<T as pallet::Config>::Currency::minimum_balance() * 2u32.into()
279283
);
280284
Ok(())
281285
}
@@ -284,15 +288,15 @@ mod benchmarks {
284288
// one.
285289
#[benchmark]
286290
fn register_as_candidate(c: Linear<1, { T::MaxCandidates::get() - 1 }>) {
287-
CandidacyBond::<T>::put(T::Currency::minimum_balance());
291+
CandidacyBond::<T>::put(<T as pallet::Config>::Currency::minimum_balance());
288292
DesiredCandidates::<T>::put(c + 1);
289293

290294
register_validators::<T>(c);
291295
register_candidates::<T>(c);
292296

293297
let caller: T::AccountId = whitelisted_caller();
294-
let bond: BalanceOf<T> = T::Currency::minimum_balance() * 2u32.into();
295-
T::Currency::make_free_balance_be(&caller, bond);
298+
let bond: BalanceOf<T> = <T as pallet::Config>::Currency::minimum_balance() * 2u32.into();
299+
<T as pallet::Config>::Currency::make_free_balance_be(&caller, bond);
296300

297301
<session::Pallet<T>>::set_keys(
298302
RawOrigin::Signed(caller.clone()).into(),
@@ -311,15 +315,15 @@ mod benchmarks {
311315

312316
#[benchmark]
313317
fn take_candidate_slot(c: Linear<{ min_candidates::<T>() + 1 }, { T::MaxCandidates::get() }>) {
314-
CandidacyBond::<T>::put(T::Currency::minimum_balance());
318+
CandidacyBond::<T>::put(<T as pallet::Config>::Currency::minimum_balance());
315319
DesiredCandidates::<T>::put(1);
316320

317321
register_validators::<T>(c);
318322
register_candidates::<T>(c);
319323

320324
let caller: T::AccountId = whitelisted_caller();
321-
let bond: BalanceOf<T> = T::Currency::minimum_balance() * 10u32.into();
322-
T::Currency::make_free_balance_be(&caller, bond);
325+
let bond: BalanceOf<T> = <T as pallet::Config>::Currency::minimum_balance() * 10u32.into();
326+
<T as pallet::Config>::Currency::make_free_balance_be(&caller, bond);
323327

324328
<session::Pallet<T>>::set_keys(
325329
RawOrigin::Signed(caller.clone()).into(),
@@ -342,7 +346,7 @@ mod benchmarks {
342346
// worse case is the last candidate leaving.
343347
#[benchmark]
344348
fn leave_intent(c: Linear<{ min_candidates::<T>() + 1 }, { T::MaxCandidates::get() }>) {
345-
CandidacyBond::<T>::put(T::Currency::minimum_balance());
349+
CandidacyBond::<T>::put(<T as pallet::Config>::Currency::minimum_balance());
346350
DesiredCandidates::<T>::put(c);
347351

348352
register_validators::<T>(c);
@@ -360,23 +364,23 @@ mod benchmarks {
360364
// worse case is paying a non-existing candidate account.
361365
#[benchmark]
362366
fn note_author() {
363-
CandidacyBond::<T>::put(T::Currency::minimum_balance());
364-
T::Currency::make_free_balance_be(
367+
CandidacyBond::<T>::put(<T as pallet::Config>::Currency::minimum_balance());
368+
<T as pallet::Config>::Currency::make_free_balance_be(
365369
&<CollatorSelection<T>>::account_id(),
366-
T::Currency::minimum_balance() * 4u32.into(),
370+
<T as pallet::Config>::Currency::minimum_balance() * 4u32.into(),
367371
);
368372
let author = account("author", 0, SEED);
369373
let new_block: BlockNumberFor<T> = 10u32.into();
370374

371375
frame_system::Pallet::<T>::set_block_number(new_block);
372-
assert!(T::Currency::free_balance(&author) == 0u32.into());
376+
assert!(<T as pallet::Config>::Currency::free_balance(&author) == 0u32.into());
373377

374378
#[block]
375379
{
376380
<CollatorSelection<T> as EventHandler<_, _>>::note_author(author.clone())
377381
}
378382

379-
assert!(T::Currency::free_balance(&author) > 0u32.into());
383+
assert!(<T as pallet::Config>::Currency::free_balance(&author) > 0u32.into());
380384
assert_eq!(frame_system::Pallet::<T>::block_number(), new_block);
381385
}
382386

@@ -386,7 +390,7 @@ mod benchmarks {
386390
r: Linear<1, { T::MaxCandidates::get() }>,
387391
c: Linear<1, { T::MaxCandidates::get() }>,
388392
) {
389-
CandidacyBond::<T>::put(T::Currency::minimum_balance());
393+
CandidacyBond::<T>::put(<T as pallet::Config>::Currency::minimum_balance());
390394
DesiredCandidates::<T>::put(c);
391395
frame_system::Pallet::<T>::set_block_number(0u32.into());
392396

cumulus/pallets/collator-selection/src/mock.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,8 @@ impl pallet_session::Config for Test {
140140
type Keys = MockSessionKeys;
141141
type DisablingStrategy = ();
142142
type WeightInfo = ();
143+
type Currency = Balances;
144+
type KeyDeposit = ();
143145
}
144146

145147
ord_parameter_types! {

cumulus/pallets/parachain-system/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1847,7 +1847,7 @@ impl<T: Config> BlockNumberProvider for RelaychainDataProvider<T> {
18471847
.unwrap_or_else(|| Pallet::<T>::last_relay_block_number())
18481848
}
18491849

1850-
#[cfg(feature = "runtime-benchmarks")]
1850+
#[cfg(any(feature = "std", feature = "runtime-benchmarks", test))]
18511851
fn set_block_number(block: Self::BlockNumber) {
18521852
let mut validation_data = ValidationData::<T>::get().unwrap_or_else(||
18531853
// PersistedValidationData does not impl default in non-std

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -837,6 +837,8 @@ impl pallet_session::Config for Runtime {
837837
type Keys = SessionKeys;
838838
type DisablingStrategy = ();
839839
type WeightInfo = weights::pallet_session::WeightInfo<Runtime>;
840+
type Currency = Balances;
841+
type KeyDeposit = ();
840842
}
841843

842844
impl pallet_aura::Config for Runtime {

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -890,6 +890,8 @@ impl pallet_session::Config for Runtime {
890890
type Keys = SessionKeys;
891891
type DisablingStrategy = ();
892892
type WeightInfo = weights::pallet_session::WeightInfo<Runtime>;
893+
type Currency = Balances;
894+
type KeyDeposit = ();
893895
}
894896

895897
impl pallet_aura::Config for Runtime {

0 commit comments

Comments
 (0)