mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 09:21:04 +00:00
Update substrate for new on_initialize syntax and update on_initialize weight (#937)
* update new on_initialize syntax * update substrate * update spec_version
This commit is contained in:
Generated
+1390
-1272
File diff suppressed because it is too large
Load Diff
@@ -570,7 +570,10 @@ mod tests {
|
||||
use super::*;
|
||||
|
||||
use std::{collections::HashMap, cell::RefCell};
|
||||
use frame_support::{impl_outer_origin, assert_ok, assert_noop, parameter_types};
|
||||
use frame_support::{
|
||||
impl_outer_origin, assert_ok, assert_noop, parameter_types,
|
||||
traits::{OnInitialize, OnFinalize},
|
||||
};
|
||||
use frame_support::traits::Contains;
|
||||
use sp_core::H256;
|
||||
use primitives::parachain::{Info as ParaInfo, Id as ParaId};
|
||||
@@ -578,7 +581,7 @@ mod tests {
|
||||
// or public keys. `u64` is used as the `AccountId` and no `Signature`s are requried.
|
||||
use sp_runtime::{
|
||||
Perbill, Permill, Percent, testing::Header, DispatchResult,
|
||||
traits::{BlakeTwo256, OnInitialize, OnFinalize, IdentityLookup},
|
||||
traits::{BlakeTwo256, IdentityLookup},
|
||||
};
|
||||
use crate::registrar::Registrar;
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ use sp_staking::{
|
||||
use frame_support::{
|
||||
traits::KeyOwnerProofSystem,
|
||||
dispatch::{IsSubType},
|
||||
weights::{DispatchInfo, SimpleDispatchInfo},
|
||||
weights::{DispatchInfo, SimpleDispatchInfo, Weight, WeighData},
|
||||
};
|
||||
use primitives::{
|
||||
Balance,
|
||||
@@ -516,7 +516,7 @@ decl_module! {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn on_initialize() {
|
||||
fn on_initialize() -> Weight {
|
||||
<Self as Store>::DidUpdate::kill();
|
||||
|
||||
let current_session = <session::Module<T>>::current_index();
|
||||
@@ -538,6 +538,8 @@ decl_module! {
|
||||
}
|
||||
}
|
||||
<ParentToSessionIndex<T>>::insert(parent_hash, current_session);
|
||||
|
||||
SimpleDispatchInfo::default().weigh_data(())
|
||||
}
|
||||
|
||||
fn on_finalize() {
|
||||
@@ -1204,7 +1206,7 @@ mod tests {
|
||||
impl_opaque_keys,
|
||||
Perbill, curve::PiecewiseLinear, testing::{Header},
|
||||
traits::{
|
||||
BlakeTwo256, IdentityLookup, OnInitialize, OnFinalize, SaturatedConversion,
|
||||
BlakeTwo256, IdentityLookup, SaturatedConversion,
|
||||
OpaqueKeys,
|
||||
},
|
||||
};
|
||||
@@ -1218,6 +1220,7 @@ mod tests {
|
||||
use keyring::Sr25519Keyring;
|
||||
use frame_support::{
|
||||
impl_outer_origin, impl_outer_dispatch, assert_ok, assert_err, parameter_types,
|
||||
traits::{OnInitialize, OnFinalize},
|
||||
};
|
||||
use crate::parachains;
|
||||
use crate::registrar;
|
||||
|
||||
@@ -31,7 +31,7 @@ use sp_runtime::{
|
||||
use frame_support::{
|
||||
decl_storage, decl_module, decl_event, decl_error, ensure,
|
||||
dispatch::{DispatchResult, IsSubType}, traits::{Get, Currency, ReservableCurrency},
|
||||
weights::{SimpleDispatchInfo, DispatchInfo},
|
||||
weights::{SimpleDispatchInfo, DispatchInfo, Weight, WeighData},
|
||||
};
|
||||
use system::{self, ensure_root, ensure_signed};
|
||||
use primitives::parachain::{
|
||||
@@ -413,7 +413,7 @@ decl_module! {
|
||||
}
|
||||
|
||||
/// Block initializer. Clears SelectedThreads and constructs/replaces Active.
|
||||
fn on_initialize() {
|
||||
fn on_initialize() -> Weight {
|
||||
let next_up = SelectedThreads::mutate(|t| {
|
||||
let r = if t.len() >= T::QueueSize::get() {
|
||||
// Take the first set of parathreads in queue
|
||||
@@ -453,6 +453,8 @@ decl_module! {
|
||||
paras.sort_by_key(|&(ref id, _)| *id);
|
||||
|
||||
Active::put(paras);
|
||||
|
||||
SimpleDispatchInfo::default().weigh_data(())
|
||||
}
|
||||
|
||||
fn on_finalize() {
|
||||
@@ -644,7 +646,7 @@ mod tests {
|
||||
use sp_core::{H256, Pair};
|
||||
use sp_runtime::{
|
||||
traits::{
|
||||
BlakeTwo256, IdentityLookup, OnInitialize, OnFinalize, Dispatchable,
|
||||
BlakeTwo256, IdentityLookup, Dispatchable,
|
||||
AccountIdConversion,
|
||||
}, testing::{UintAuthorityId, Header}, KeyTypeId, Perbill, curve::PiecewiseLinear,
|
||||
};
|
||||
@@ -657,7 +659,7 @@ mod tests {
|
||||
Balance, BlockNumber,
|
||||
};
|
||||
use frame_support::{
|
||||
traits::KeyOwnerProofSystem,
|
||||
traits::{KeyOwnerProofSystem, OnInitialize, OnFinalize},
|
||||
impl_outer_origin, impl_outer_dispatch, assert_ok, parameter_types, assert_noop,
|
||||
};
|
||||
use keyring::Sr25519Keyring;
|
||||
|
||||
@@ -22,11 +22,11 @@ use sp_std::{prelude::*, mem::swap, convert::TryInto};
|
||||
use sp_runtime::traits::{
|
||||
CheckedSub, StaticLookup, Zero, One, CheckedConversion, Hash, AccountIdConversion,
|
||||
};
|
||||
use frame_support::weights::SimpleDispatchInfo;
|
||||
use codec::{Encode, Decode, Codec};
|
||||
use frame_support::{
|
||||
decl_module, decl_storage, decl_event, decl_error, ensure, dispatch::DispatchResult,
|
||||
traits::{Currency, ReservableCurrency, WithdrawReason, ExistenceRequirement, Get, Randomness},
|
||||
weights::{SimpleDispatchInfo, WeighData, Weight},
|
||||
};
|
||||
use primitives::parachain::{
|
||||
SwapAux, PARACHAIN_INFO, Id as ParaId
|
||||
@@ -267,7 +267,7 @@ decl_module! {
|
||||
|
||||
fn deposit_event() = default;
|
||||
|
||||
fn on_initialize(n: T::BlockNumber) {
|
||||
fn on_initialize(n: T::BlockNumber) -> Weight {
|
||||
let lease_period = T::LeasePeriod::get();
|
||||
let lease_period_index: LeasePeriodOf<T> = (n / lease_period).into();
|
||||
|
||||
@@ -285,6 +285,8 @@ decl_module! {
|
||||
if (n % lease_period).is_zero() {
|
||||
Self::manage_lease_period_start(lease_period_index);
|
||||
}
|
||||
|
||||
SimpleDispatchInfo::default().weigh_data(())
|
||||
}
|
||||
|
||||
fn on_finalize(now: T::BlockNumber) {
|
||||
@@ -877,9 +879,12 @@ mod tests {
|
||||
use sp_core::H256;
|
||||
use sp_runtime::{
|
||||
Perbill, testing::Header,
|
||||
traits::{BlakeTwo256, Hash, IdentityLookup, OnInitialize, OnFinalize},
|
||||
traits::{BlakeTwo256, Hash, IdentityLookup},
|
||||
};
|
||||
use frame_support::{
|
||||
impl_outer_origin, parameter_types, assert_ok, assert_noop,
|
||||
traits::{OnInitialize, OnFinalize}
|
||||
};
|
||||
use frame_support::{impl_outer_origin, parameter_types, assert_ok, assert_noop};
|
||||
use balances;
|
||||
use primitives::parachain::{Id as ParaId, Info as ParaInfo};
|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
|
||||
spec_name: create_runtime_str!("kusama"),
|
||||
impl_name: create_runtime_str!("parity-kusama"),
|
||||
authoring_version: 2,
|
||||
spec_version: 1056,
|
||||
spec_version: 1057,
|
||||
impl_version: 1,
|
||||
apis: RUNTIME_API_VERSIONS,
|
||||
};
|
||||
|
||||
@@ -84,7 +84,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
|
||||
spec_name: create_runtime_str!("polkadot"),
|
||||
impl_name: create_runtime_str!("parity-polkadot"),
|
||||
authoring_version: 2,
|
||||
spec_version: 1005,
|
||||
spec_version: 1006,
|
||||
impl_version: 0,
|
||||
apis: RUNTIME_API_VERSIONS,
|
||||
};
|
||||
|
||||
@@ -75,7 +75,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
|
||||
spec_name: create_runtime_str!("polkadot-test-runtime"),
|
||||
impl_name: create_runtime_str!("parity-polkadot-test-runtime"),
|
||||
authoring_version: 2,
|
||||
spec_version: 1048,
|
||||
spec_version: 1049,
|
||||
impl_version: 0,
|
||||
apis: RUNTIME_API_VERSIONS,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user