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