Update Substrate Dependency (#566)

* Update `sp-io` dependency

* Rename Trait to Config

* RustFmt

* Bump `sp-io` again

* Use new frame_system weight types in Rialto and Millau runtimes

* Update test Runtimes to use new weight types

* Bump `sp-io` again

* Update to not-the latest first.

* Update benchmarks.

* Another Trai.

* Move new weight types into runtime primitive crates

This allows us to check limits for extrinsics from other parts
of the codebase without pulling in the entire chain runtime.

* Remove leftover comments

* Move new functions to a better location

* Small formatting fixes

* Add actual documentation to new weight config types

* Decrease maximum block weight of Millau chain

* Decreease maximum block length of Millau chain

Co-authored-by: Tomasz Drwięga <tomasz@parity.io>
This commit is contained in:
Hernando Castano
2020-12-16 04:52:53 -05:00
committed by Bastian Köcher
parent 8a5b51a944
commit ee655b1057
31 changed files with 328 additions and 293 deletions
@@ -23,21 +23,21 @@ use frame_support::{decl_module, decl_storage};
use sp_std::prelude::*;
/// The module configuration trait.
pub trait Trait: pallet_session::Trait {}
pub trait Config: pallet_session::Config {}
decl_module! {
/// Shift session manager pallet.
pub struct Module<T: Trait> for enum Call where origin: T::Origin {}
pub struct Module<T: Config> for enum Call where origin: T::Origin {}
}
decl_storage! {
trait Store for Module<T: Trait> as ShiftSessionManager {
trait Store for Module<T: Config> as ShiftSessionManager {
/// Validators of first two sessions.
InitialValidators: Option<Vec<T::ValidatorId>>;
}
}
impl<T: Trait> pallet_session::SessionManager<T::ValidatorId> for Module<T> {
impl<T: Config> pallet_session::SessionManager<T::ValidatorId> for Module<T> {
fn end_session(_: sp_staking::SessionIndex) {}
fn start_session(_: sp_staking::SessionIndex) {}
fn new_session(session_index: sp_staking::SessionIndex) -> Option<Vec<T::ValidatorId>> {
@@ -61,7 +61,7 @@ impl<T: Trait> pallet_session::SessionManager<T::ValidatorId> for Module<T> {
}
}
impl<T: Trait> Module<T> {
impl<T: Config> Module<T> {
/// Select validators for session.
fn select_validators(
session_index: sp_staking::SessionIndex,
@@ -112,7 +112,7 @@ mod tests {
pub const AvailableBlockRatio: Perbill = Perbill::one();
}
impl frame_system::Trait for TestRuntime {
impl frame_system::Config for TestRuntime {
type Origin = Origin;
type Index = u64;
type Call = ();
@@ -124,13 +124,6 @@ mod tests {
type Header = Header;
type Event = ();
type BlockHashCount = BlockHashCount;
type MaximumBlockWeight = MaximumBlockWeight;
type DbWeight = ();
type BlockExecutionWeight = ();
type ExtrinsicBaseWeight = ();
type MaximumExtrinsicWeight = ();
type AvailableBlockRatio = AvailableBlockRatio;
type MaximumBlockLength = MaximumBlockLength;
type Version = ();
type PalletInfo = ();
type AccountData = ();
@@ -138,6 +131,9 @@ mod tests {
type OnKilledAccount = ();
type BaseCallFilter = ();
type SystemWeightInfo = ();
type BlockWeights = ();
type BlockLength = ();
type DbWeight = ();
}
parameter_types! {
@@ -145,9 +141,9 @@ mod tests {
pub const Offset: u64 = 0;
}
impl pallet_session::Trait for TestRuntime {
impl pallet_session::Config for TestRuntime {
type Event = ();
type ValidatorId = <Self as frame_system::Trait>::AccountId;
type ValidatorId = <Self as frame_system::Config>::AccountId;
type ValidatorIdOf = ConvertInto;
type ShouldEndSession = pallet_session::PeriodicSessions<Period, Offset>;
type NextSessionRotation = pallet_session::PeriodicSessions<Period, Offset>;
@@ -158,7 +154,7 @@ mod tests {
type WeightInfo = ();
}
impl Trait for TestRuntime {}
impl Config for TestRuntime {}
pub struct TestSessionHandler;
impl pallet_session::SessionHandler<AccountId> for TestSessionHandler {