Companion: Rename pallet trait Trait to Config (#2014)

* rename Trait -> Config

* revert diener changes

* rename HostConfig to ActiveConfig as more meaningful

* fix merge

* "Update Substrate"

* cargo update -p sp-io

Co-authored-by: parity-processbot <>
This commit is contained in:
Guillaume Thiolliere
2020-11-30 16:13:43 +01:00
committed by GitHub
parent 7df537fcdd
commit 2d4aa3a42e
76 changed files with 613 additions and 613 deletions
@@ -130,24 +130,24 @@ pub struct HostConfiguration<BlockNumber> {
pub hrmp_max_message_num_per_candidate: u32,
}
pub trait Trait: frame_system::Trait { }
pub trait Config: frame_system::Config { }
decl_storage! {
trait Store for Module<T: Trait> as Configuration {
trait Store for Module<T: Config> as Configuration {
/// The active configuration for the current session.
Config get(fn config) config(): HostConfiguration<T::BlockNumber>;
ActiveConfig get(fn config) config(): HostConfiguration<T::BlockNumber>;
/// Pending configuration (if any) for the next session.
PendingConfig: Option<HostConfiguration<T::BlockNumber>>;
}
}
decl_error! {
pub enum Error for Module<T: Trait> { }
pub enum Error for Module<T: Config> { }
}
decl_module! {
/// The parachains configuration module.
pub struct Module<T: Trait> for enum Call where origin: <T as frame_system::Trait>::Origin {
pub struct Module<T: Config> for enum Call where origin: <T as frame_system::Config>::Origin {
type Error = Error<T>;
/// Set the validation upgrade frequency.
@@ -506,7 +506,7 @@ decl_module! {
}
}
impl<T: Trait> Module<T> {
impl<T: Config> Module<T> {
/// Called by the initializer to initialize the configuration module.
pub(crate) fn initializer_initialize(_now: T::BlockNumber) -> Weight {
0
@@ -518,7 +518,7 @@ impl<T: Trait> Module<T> {
/// Called by the initializer to note that a new session has started.
pub(crate) fn initializer_on_new_session(_validators: &[ValidatorId], _queued: &[ValidatorId]) {
if let Some(pending) = <Self as Store>::PendingConfig::take() {
<Self as Store>::Config::set(pending);
<Self as Store>::ActiveConfig::set(pending);
}
}
+4 -4
View File
@@ -62,10 +62,10 @@ impl fmt::Debug for ProcessedDownwardMessagesAcceptanceErr {
}
}
pub trait Trait: frame_system::Trait + configuration::Trait {}
pub trait Config: frame_system::Config + configuration::Config {}
decl_storage! {
trait Store for Module<T: Trait> as Dmp {
trait Store for Module<T: Config> as Dmp {
/// Paras that are to be cleaned up at the end of the session.
/// The entries are sorted ascending by the para id.
OutgoingParas: Vec<ParaId>;
@@ -85,11 +85,11 @@ decl_storage! {
decl_module! {
/// The DMP module.
pub struct Module<T: Trait> for enum Call where origin: <T as frame_system::Trait>::Origin { }
pub struct Module<T: Config> for enum Call where origin: <T as frame_system::Config>::Origin { }
}
/// Routines and getters related to downward message passing.
impl<T: Trait> Module<T> {
impl<T: Config> Module<T> {
/// Block initialization logic, called by initializer.
pub(crate) fn initializer_initialize(_now: T::BlockNumber) -> Weight {
0
+10 -10
View File
@@ -207,14 +207,14 @@ impl fmt::Debug for OutboundHrmpAcceptanceErr {
}
}
pub trait Trait: frame_system::Trait + configuration::Trait + paras::Trait + dmp::Trait {
pub trait Config: frame_system::Config + configuration::Config + paras::Config + dmp::Config {
type Origin: From<crate::Origin>
+ From<<Self as frame_system::Trait>::Origin>
+ Into<Result<crate::Origin, <Self as Trait>::Origin>>;
+ From<<Self as frame_system::Config>::Origin>
+ Into<Result<crate::Origin, <Self as Config>::Origin>>;
}
decl_storage! {
trait Store for Module<T: Trait> as Hrmp {
trait Store for Module<T: Config> as Hrmp {
/// Paras that are to be cleaned up at the end of the session.
/// The entries are sorted ascending by the para id.
OutgoingParas: Vec<ParaId>;
@@ -286,7 +286,7 @@ decl_storage! {
}
decl_error! {
pub enum Error for Module<T: Trait> {
pub enum Error for Module<T: Config> {
/// The sender tried to open a channel to themselves.
OpenHrmpChannelToSelf,
/// The recipient is not a valid para.
@@ -322,7 +322,7 @@ decl_error! {
decl_module! {
/// The HRMP module.
pub struct Module<T: Trait> for enum Call where origin: <T as frame_system::Trait>::Origin {
pub struct Module<T: Config> for enum Call where origin: <T as frame_system::Config>::Origin {
type Error = Error<T>;
#[weight = 0]
@@ -332,7 +332,7 @@ decl_module! {
proposed_max_capacity: u32,
proposed_max_message_size: u32,
) -> DispatchResult {
let origin = ensure_parachain(<T as Trait>::Origin::from(origin))?;
let origin = ensure_parachain(<T as Config>::Origin::from(origin))?;
Self::init_open_channel(
origin,
recipient,
@@ -344,14 +344,14 @@ decl_module! {
#[weight = 0]
fn hrmp_accept_open_channel(origin, sender: ParaId) -> DispatchResult {
let origin = ensure_parachain(<T as Trait>::Origin::from(origin))?;
let origin = ensure_parachain(<T as Config>::Origin::from(origin))?;
Self::accept_open_channel(origin, sender)?;
Ok(())
}
#[weight = 0]
fn hrmp_close_channel(origin, channel_id: HrmpChannelId) -> DispatchResult {
let origin = ensure_parachain(<T as Trait>::Origin::from(origin))?;
let origin = ensure_parachain(<T as Config>::Origin::from(origin))?;
Self::close_channel(origin, channel_id)?;
Ok(())
}
@@ -359,7 +359,7 @@ decl_module! {
}
/// Routines and getters related to HRMP.
impl<T: Trait> Module<T> {
impl<T: Config> Module<T> {
/// Block initialization logic, called by initializer.
pub(crate) fn initializer_initialize(_now: T::BlockNumber) -> Weight {
0
+17 -17
View File
@@ -85,19 +85,19 @@ impl<H, N> CandidatePendingAvailability<H, N> {
}
}
pub trait Trait:
frame_system::Trait
+ paras::Trait
+ dmp::Trait
+ ump::Trait
+ hrmp::Trait
+ configuration::Trait
pub trait Config:
frame_system::Config
+ paras::Config
+ dmp::Config
+ ump::Config
+ hrmp::Config
+ configuration::Config
{
type Event: From<Event<Self>> + Into<<Self as frame_system::Trait>::Event>;
type Event: From<Event<Self>> + Into<<Self as frame_system::Config>::Event>;
}
decl_storage! {
trait Store for Module<T: Trait> as ParaInclusion {
trait Store for Module<T: Config> as ParaInclusion {
/// The latest bitfield for each validator, referred to by their index in the validator set.
AvailabilityBitfields: map hasher(twox_64_concat) ValidatorIndex
=> Option<AvailabilityBitfieldRecord<T::BlockNumber>>;
@@ -119,7 +119,7 @@ decl_storage! {
}
decl_error! {
pub enum Error for Module<T: Trait> {
pub enum Error for Module<T: Config> {
/// Availability bitfield has unexpected size.
WrongBitfieldSize,
/// Multiple bitfields submitted by same validator or validators out of order by index.
@@ -170,7 +170,7 @@ decl_error! {
}
decl_event! {
pub enum Event<T> where <T as frame_system::Trait>::Hash {
pub enum Event<T> where <T as frame_system::Config>::Hash {
/// A candidate was backed. [candidate, head_data]
CandidateBacked(CandidateReceipt<Hash>, HeadData),
/// A candidate was included. [candidate, head_data]
@@ -182,8 +182,8 @@ decl_event! {
decl_module! {
/// The parachain-candidate inclusion module.
pub struct Module<T: Trait>
for enum Call where origin: <T as frame_system::Trait>::Origin
pub struct Module<T: Config>
for enum Call where origin: <T as frame_system::Config>::Origin
{
type Error = Error<T>;
@@ -193,7 +193,7 @@ decl_module! {
const LOG_TARGET: &str = "parachains_runtime_inclusion";
impl<T: Trait> Module<T> {
impl<T: Config> Module<T> {
/// Block initialization logic, called by initializer.
pub(crate) fn initializer_initialize(_now: T::BlockNumber) -> Weight { 0 }
@@ -733,7 +733,7 @@ enum AcceptanceCheckErr<BlockNumber> {
impl<BlockNumber> AcceptanceCheckErr<BlockNumber> {
/// Returns the same error so that it can be threaded through a needle of `DispatchError` and
/// ultimately returned from a `Dispatchable`.
fn strip_into_dispatch_err<T: Trait>(self) -> Error<T> {
fn strip_into_dispatch_err<T: Config>(self) -> Error<T> {
use AcceptanceCheckErr::*;
match self {
HeadDataTooLarge => Error::<T>::HeadDataTooLarge,
@@ -748,13 +748,13 @@ impl<BlockNumber> AcceptanceCheckErr<BlockNumber> {
}
/// A collection of data required for checking a candidate.
struct CandidateCheckContext<T: Trait> {
struct CandidateCheckContext<T: Config> {
config: configuration::HostConfiguration<T::BlockNumber>,
now: T::BlockNumber,
relay_parent_number: T::BlockNumber,
}
impl<T: Trait> CandidateCheckContext<T> {
impl<T: Config> CandidateCheckContext<T> {
fn new() -> Self {
let now = <frame_system::Module<T>>::block_number();
Self {
@@ -39,10 +39,10 @@ use crate::{
};
use inherents::{InherentIdentifier, InherentData, MakeFatalError, ProvideInherent};
pub trait Trait: inclusion::Trait + scheduler::Trait {}
pub trait Config: inclusion::Config + scheduler::Config {}
decl_storage! {
trait Store for Module<T: Trait> as ParaInclusionInherent {
trait Store for Module<T: Config> as ParaInclusionInherent {
/// Whether the inclusion inherent was included within this block.
///
/// The `Option<()>` is effectively a bool, but it never hits storage in the `None` variant
@@ -54,7 +54,7 @@ decl_storage! {
}
decl_error! {
pub enum Error for Module<T: Trait> {
pub enum Error for Module<T: Config> {
/// Inclusion inherent called more than once per block.
TooManyInclusionInherents,
}
@@ -62,7 +62,7 @@ decl_error! {
decl_module! {
/// The inclusion inherent module.
pub struct Module<T: Trait> for enum Call where origin: <T as frame_system::Trait>::Origin {
pub struct Module<T: Config> for enum Call where origin: <T as frame_system::Config>::Origin {
type Error = Error<T>;
fn on_initialize() -> Weight {
@@ -127,7 +127,7 @@ decl_module! {
}
}
impl<T: Trait> ProvideInherent for Module<T> {
impl<T: Config> ProvideInherent for Module<T> {
type Call = Call<T>;
type Error = MakeFatalError<()>;
const INHERENT_IDENTIFIER: InherentIdentifier = INCLUSION_INHERENT_IDENTIFIER;
+16 -16
View File
@@ -57,23 +57,23 @@ struct BufferedSessionChange<N> {
session_index: sp_staking::SessionIndex,
}
pub trait Trait:
frame_system::Trait
+ configuration::Trait
+ paras::Trait
+ scheduler::Trait
+ inclusion::Trait
+ session_info::Trait
+ dmp::Trait
+ ump::Trait
+ hrmp::Trait
pub trait Config:
frame_system::Config
+ configuration::Config
+ paras::Config
+ scheduler::Config
+ inclusion::Config
+ session_info::Config
+ dmp::Config
+ ump::Config
+ hrmp::Config
{
/// A randomness beacon.
type Randomness: Randomness<Self::Hash>;
}
decl_storage! {
trait Store for Module<T: Trait> as Initializer {
trait Store for Module<T: Config> as Initializer {
/// Whether the parachains modules have been initialized within this block.
///
/// Semantically a bool, but this guarantees it should never hit the trie,
@@ -95,12 +95,12 @@ decl_storage! {
}
decl_error! {
pub enum Error for Module<T: Trait> { }
pub enum Error for Module<T: Config> { }
}
decl_module! {
/// The initializer module.
pub struct Module<T: Trait> for enum Call where origin: <T as frame_system::Trait>::Origin {
pub struct Module<T: Config> for enum Call where origin: <T as frame_system::Config>::Origin {
type Error = Error<T>;
fn on_initialize(now: T::BlockNumber) -> Weight {
@@ -159,7 +159,7 @@ decl_module! {
}
}
impl<T: Trait> Module<T> {
impl<T: Config> Module<T> {
fn apply_new_session(
session_index: sp_staking::SessionIndex,
validators: Vec<ValidatorId>,
@@ -225,11 +225,11 @@ impl<T: Trait> Module<T> {
}
}
impl<T: Trait> sp_runtime::BoundToRuntimeAppPublic for Module<T> {
impl<T: Config> sp_runtime::BoundToRuntimeAppPublic for Module<T> {
type Public = ValidatorId;
}
impl<T: pallet_session::Trait + Trait> pallet_session::OneSessionHandler<T::AccountId> for Module<T> {
impl<T: pallet_session::Config + Config> pallet_session::OneSessionHandler<T::AccountId> for Module<T> {
type Key = ValidatorId;
fn on_genesis_session<'a, I: 'a>(_validators: I)
+5 -5
View File
@@ -45,7 +45,7 @@ mod mock;
pub use origin::{Origin, ensure_parachain};
/// Schedule a para to be initialized at the start of the next session with the given genesis data.
pub fn schedule_para_initialize<T: paras::Trait>(
pub fn schedule_para_initialize<T: paras::Config>(
id: primitives::v1::Id,
genesis: paras::ParaGenesisArgs,
) {
@@ -55,10 +55,10 @@ pub fn schedule_para_initialize<T: paras::Trait>(
/// Schedule a para to be cleaned up at the start of the next session.
pub fn schedule_para_cleanup<T>(id: primitives::v1::Id)
where
T: paras::Trait
+ dmp::Trait
+ ump::Trait
+ hrmp::Trait,
T: paras::Config
+ dmp::Config
+ ump::Config
+ hrmp::Config,
{
<paras::Module<T>>::schedule_para_cleanup(id);
<dmp::Module<T>>::schedule_para_cleanup(id);
+11 -11
View File
@@ -70,7 +70,7 @@ parameter_types! {
pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);
}
impl frame_system::Trait for Test {
impl frame_system::Config for Test {
type BaseCallFilter = ();
type Origin = Origin;
type Call = Call;
@@ -98,35 +98,35 @@ impl frame_system::Trait for Test {
type SystemWeightInfo = ();
}
impl crate::initializer::Trait for Test {
impl crate::initializer::Config for Test {
type Randomness = TestRandomness;
}
impl crate::configuration::Trait for Test { }
impl crate::configuration::Config for Test { }
impl crate::paras::Trait for Test {
impl crate::paras::Config for Test {
type Origin = Origin;
}
impl crate::dmp::Trait for Test { }
impl crate::dmp::Config for Test { }
impl crate::ump::Trait for Test {
impl crate::ump::Config for Test {
type UmpSink = crate::ump::mock_sink::MockUmpSink;
}
impl crate::hrmp::Trait for Test {
impl crate::hrmp::Config for Test {
type Origin = Origin;
}
impl crate::scheduler::Trait for Test { }
impl crate::scheduler::Config for Test { }
impl crate::inclusion::Trait for Test {
impl crate::inclusion::Config for Test {
type Event = TestEvent;
}
impl crate::session_info::Trait for Test { }
impl crate::session_info::Config for Test { }
impl crate::session_info::AuthorityDiscoveryTrait for Test {
impl crate::session_info::AuthorityDiscoveryConfig for Test {
fn authorities() -> Vec<AuthorityDiscoveryId> {
Vec::new()
}
+2 -2
View File
@@ -40,7 +40,7 @@ pub fn ensure_parachain<OuterOrigin>(o: OuterOrigin) -> result::Result<ParaId, B
}
/// The origin module.
pub trait Trait: frame_system::Trait {}
pub trait Config: frame_system::Config {}
frame_support::decl_module! {
/// There is no way to register an origin type in `construct_runtime` without a pallet the origin
@@ -49,7 +49,7 @@ frame_support::decl_module! {
/// This module fulfills only the single purpose of housing the `Origin` in `construct_runtime`.
///
// ideally, though, the `construct_runtime` should support a free-standing origin.
pub struct Module<T: Trait> for enum Call where origin: <T as frame_system::Trait>::Origin {}
pub struct Module<T: Config> for enum Call where origin: <T as frame_system::Config>::Origin {}
}
impl From<u32> for Origin {
+8 -8
View File
@@ -45,11 +45,11 @@ use serde::{Serialize, Deserialize};
pub use crate::Origin;
pub trait Trait: frame_system::Trait + configuration::Trait {
pub trait Config: frame_system::Config + configuration::Config {
/// The outer origin type.
type Origin: From<Origin>
+ From<<Self as frame_system::Trait>::Origin>
+ Into<result::Result<Origin, <Self as Trait>::Origin>>;
+ From<<Self as frame_system::Config>::Origin>
+ Into<result::Result<Origin, <Self as Config>::Origin>>;
}
// the two key times necessary to track for every code replacement.
@@ -177,7 +177,7 @@ pub struct ParaGenesisArgs {
}
decl_storage! {
trait Store for Module<T: Trait> as Paras {
trait Store for Module<T: Config> as Paras {
/// All parachains. Ordered ascending by ParaId. Parathreads are not included.
Parachains get(fn parachains): Vec<ParaId>;
/// All parathreads.
@@ -224,7 +224,7 @@ decl_storage! {
}
#[cfg(feature = "std")]
fn build<T: Trait>(config: &GenesisConfig<T>) {
fn build<T: Config>(config: &GenesisConfig<T>) {
let mut parachains: Vec<_> = config.paras
.iter()
.filter(|(_, args)| args.parachain)
@@ -244,17 +244,17 @@ fn build<T: Trait>(config: &GenesisConfig<T>) {
}
decl_error! {
pub enum Error for Module<T: Trait> { }
pub enum Error for Module<T: Config> { }
}
decl_module! {
/// The parachains configuration module.
pub struct Module<T: Trait> for enum Call where origin: <T as frame_system::Trait>::Origin {
pub struct Module<T: Config> for enum Call where origin: <T as frame_system::Config>::Origin {
type Error = Error<T>;
}
}
impl<T: Trait> Module<T> {
impl<T: Config> Module<T> {
/// Called by the initializer to initialize the configuration module.
pub(crate) fn initializer_initialize(now: T::BlockNumber) -> Weight {
Self::prune_old_code(now)
@@ -31,12 +31,12 @@ use frame_support::debug;
use crate::{initializer, inclusion, scheduler, configuration, paras, session_info, dmp, hrmp};
/// Implementation for the `validators` function of the runtime API.
pub fn validators<T: initializer::Trait>() -> Vec<ValidatorId> {
pub fn validators<T: initializer::Config>() -> Vec<ValidatorId> {
<inclusion::Module<T>>::validators()
}
/// Implementation for the `validator_groups` function of the runtime API.
pub fn validator_groups<T: initializer::Trait>() -> (
pub fn validator_groups<T: initializer::Config>() -> (
Vec<Vec<ValidatorIndex>>,
GroupRotationInfo<T::BlockNumber>,
) {
@@ -47,7 +47,7 @@ pub fn validator_groups<T: initializer::Trait>() -> (
}
/// Implementation for the `availability_cores` function of the runtime API.
pub fn availability_cores<T: initializer::Trait>() -> Vec<CoreState<T::BlockNumber>> {
pub fn availability_cores<T: initializer::Config>() -> Vec<CoreState<T::BlockNumber>> {
let cores = <scheduler::Module<T>>::availability_cores();
let parachains = <paras::Module<T>>::parachains();
let config = <configuration::Module<T>>::config();
@@ -163,24 +163,24 @@ pub fn availability_cores<T: initializer::Trait>() -> Vec<CoreState<T::BlockNumb
core_states
}
fn with_assumption<Trait, T, F>(
fn with_assumption<Config, T, F>(
para_id: ParaId,
assumption: OccupiedCoreAssumption,
build: F,
) -> Option<T> where
Trait: inclusion::Trait,
Config: inclusion::Config,
F: FnOnce() -> Option<T>,
{
match assumption {
OccupiedCoreAssumption::Included => {
<inclusion::Module<Trait>>::force_enact(para_id);
<inclusion::Module<Config>>::force_enact(para_id);
build()
}
OccupiedCoreAssumption::TimedOut => {
build()
}
OccupiedCoreAssumption::Free => {
if <inclusion::Module<Trait>>::pending_availability(para_id).is_some() {
if <inclusion::Module<Config>>::pending_availability(para_id).is_some() {
None
} else {
build()
@@ -190,7 +190,7 @@ fn with_assumption<Trait, T, F>(
}
/// Implementation for the `full_validation_data` function of the runtime API.
pub fn full_validation_data<T: initializer::Trait>(
pub fn full_validation_data<T: initializer::Config>(
para_id: ParaId,
assumption: OccupiedCoreAssumption,
)
@@ -207,7 +207,7 @@ pub fn full_validation_data<T: initializer::Trait>(
}
/// Implementation for the `persisted_validation_data` function of the runtime API.
pub fn persisted_validation_data<T: initializer::Trait>(
pub fn persisted_validation_data<T: initializer::Config>(
para_id: ParaId,
assumption: OccupiedCoreAssumption,
) -> Option<PersistedValidationData<T::BlockNumber>> {
@@ -219,7 +219,7 @@ pub fn persisted_validation_data<T: initializer::Trait>(
}
/// Implementation for the `check_validation_outputs` function of the runtime API.
pub fn check_validation_outputs<T: initializer::Trait>(
pub fn check_validation_outputs<T: initializer::Config>(
para_id: ParaId,
outputs: primitives::v1::CandidateCommitments,
) -> bool {
@@ -227,7 +227,7 @@ pub fn check_validation_outputs<T: initializer::Trait>(
}
/// Implementation for the `session_index_for_child` function of the runtime API.
pub fn session_index_for_child<T: initializer::Trait>() -> SessionIndex {
pub fn session_index_for_child<T: initializer::Config>() -> SessionIndex {
// Just returns the session index from `inclusion`. Runtime APIs follow
// initialization so the initializer will have applied any pending session change
// which is expected at the child of the block whose context the runtime API was invoked
@@ -239,7 +239,7 @@ pub fn session_index_for_child<T: initializer::Trait>() -> SessionIndex {
}
/// Implementation for the `validation_code` function of the runtime API.
pub fn validation_code<T: initializer::Trait>(
pub fn validation_code<T: initializer::Config>(
para_id: ParaId,
assumption: OccupiedCoreAssumption,
) -> Option<ValidationCode> {
@@ -251,7 +251,7 @@ pub fn validation_code<T: initializer::Trait>(
}
/// Implementation for the `historical_validation_code` function of the runtime API.
pub fn historical_validation_code<T: initializer::Trait>(
pub fn historical_validation_code<T: initializer::Config>(
para_id: ParaId,
context_height: T::BlockNumber,
) -> Option<ValidationCode> {
@@ -259,7 +259,7 @@ pub fn historical_validation_code<T: initializer::Trait>(
}
/// Implementation for the `candidate_pending_availability` function of the runtime API.
pub fn candidate_pending_availability<T: initializer::Trait>(para_id: ParaId)
pub fn candidate_pending_availability<T: initializer::Config>(para_id: ParaId)
-> Option<CommittedCandidateReceipt<T::Hash>>
{
<inclusion::Module<T>>::candidate_pending_availability(para_id)
@@ -270,8 +270,8 @@ pub fn candidate_pending_availability<T: initializer::Trait>(para_id: ParaId)
// this means it can run in a different session than other runtime APIs at the same block.
pub fn candidate_events<T, F>(extract_event: F) -> Vec<CandidateEvent<T::Hash>>
where
T: initializer::Trait,
F: Fn(<T as frame_system::Trait>::Event) -> Option<inclusion::Event<T>>,
T: initializer::Config,
F: Fn(<T as frame_system::Config>::Event) -> Option<inclusion::Event<T>>,
{
use inclusion::Event as RawEvent;
@@ -286,19 +286,19 @@ where
}
/// Get the session info for the given session, if stored.
pub fn session_info<T: session_info::Trait>(index: SessionIndex) -> Option<SessionInfo> {
pub fn session_info<T: session_info::Config>(index: SessionIndex) -> Option<SessionInfo> {
<session_info::Module<T>>::session_info(index)
}
/// Implementation for the `dmq_contents` function of the runtime API.
pub fn dmq_contents<T: dmp::Trait>(
pub fn dmq_contents<T: dmp::Config>(
recipient: ParaId,
) -> Vec<InboundDownwardMessage<T::BlockNumber>> {
<dmp::Module<T>>::dmq_contents(recipient)
}
/// Implementation for the `inbound_hrmp_channels_contents` function of the runtime API.
pub fn inbound_hrmp_channels_contents<T: hrmp::Trait>(
pub fn inbound_hrmp_channels_contents<T: hrmp::Config>(
recipient: ParaId,
) -> BTreeMap<ParaId, Vec<InboundHrmpMessage<T::BlockNumber>>> {
<hrmp::Module<T>>::inbound_hrmp_channels_contents(recipient)
+5 -5
View File
@@ -153,10 +153,10 @@ impl CoreAssignment {
}
}
pub trait Trait: frame_system::Trait + configuration::Trait + paras::Trait { }
pub trait Config: frame_system::Config + configuration::Config + paras::Config { }
decl_storage! {
trait Store for Module<T: Trait> as ParaScheduler {
trait Store for Module<T: Config> as ParaScheduler {
/// All the validator groups. One for each core.
///
/// Bound: The number of cores is the sum of the numbers of parachains and parathread multiplexers.
@@ -190,17 +190,17 @@ decl_storage! {
}
decl_error! {
pub enum Error for Module<T: Trait> { }
pub enum Error for Module<T: Config> { }
}
decl_module! {
/// The scheduler module.
pub struct Module<T: Trait> for enum Call where origin: <T as frame_system::Trait>::Origin {
pub struct Module<T: Config> for enum Call where origin: <T as frame_system::Config>::Origin {
type Error = Error<T>;
}
}
impl<T: Trait> Module<T> {
impl<T: Config> Module<T> {
/// Called by the initializer to initialize the scheduler module.
pub(crate) fn initializer_initialize(_now: T::BlockNumber) -> Weight {
Self::schedule(Vec::new());
+13 -13
View File
@@ -27,17 +27,17 @@ use frame_support::{
use crate::{configuration, paras, scheduler};
use sp_std::{cmp, vec::Vec};
pub trait Trait:
frame_system::Trait
+ configuration::Trait
+ paras::Trait
+ scheduler::Trait
+ AuthorityDiscoveryTrait
pub trait Config:
frame_system::Config
+ configuration::Config
+ paras::Config
+ scheduler::Config
+ AuthorityDiscoveryConfig
{
}
decl_storage! {
trait Store for Module<T: Trait> as ParaSessionInfo {
trait Store for Module<T: Config> as ParaSessionInfo {
/// The earliest session for which previous session info is stored.
EarliestStoredSession get(fn earliest_stored_session): SessionIndex;
/// Session information in a rolling window.
@@ -48,30 +48,30 @@ decl_storage! {
}
decl_error! {
pub enum Error for Module<T: Trait> { }
pub enum Error for Module<T: Config> { }
}
decl_module! {
/// The session info module.
pub struct Module<T: Trait> for enum Call where origin: <T as frame_system::Trait>::Origin {
pub struct Module<T: Config> for enum Call where origin: <T as frame_system::Config>::Origin {
type Error = Error<T>;
}
}
/// An abstraction for the authority discovery pallet
/// to help with mock testing.
pub trait AuthorityDiscoveryTrait {
pub trait AuthorityDiscoveryConfig {
/// Retrieve authority identifiers of the current and next authority set.
fn authorities() -> Vec<AuthorityDiscoveryId>;
}
impl<T: pallet_authority_discovery::Trait> AuthorityDiscoveryTrait for T {
impl<T: pallet_authority_discovery::Config> AuthorityDiscoveryConfig for T {
fn authorities() -> Vec<AuthorityDiscoveryId> {
<pallet_authority_discovery::Module<T>>::authorities()
}
}
impl<T: Trait> Module<T> {
impl<T: Config> Module<T> {
/// Handle an incoming session change.
pub(crate) fn initializer_on_new_session(
notification: &crate::initializer::SessionChangeNotification<T::BlockNumber>
@@ -82,7 +82,7 @@ impl<T: Trait> Module<T> {
let n_parachains = <paras::Module<T>>::parachains().len() as u32;
let validators = notification.validators.clone();
let discovery_keys = <T as AuthorityDiscoveryTrait>::authorities();
let discovery_keys = <T as AuthorityDiscoveryConfig>::authorities();
// FIXME: once we store these keys: https://github.com/paritytech/polkadot/issues/1975
let approval_keys = Default::default();
let validator_groups = <scheduler::Module<T>>::validator_groups();
+8 -8
View File
@@ -105,13 +105,13 @@ impl fmt::Debug for AcceptanceCheckErr {
}
}
pub trait Trait: frame_system::Trait + configuration::Trait {
pub trait Config: frame_system::Config + configuration::Config {
/// A place where all received upward messages are funneled.
type UmpSink: UmpSink;
}
decl_storage! {
trait Store for Module<T: Trait> as Ump {
trait Store for Module<T: Config> as Ump {
/// Paras that are to be cleaned up at the end of the session.
/// The entries are sorted ascending by the para id.
OutgoingParas: Vec<ParaId>;
@@ -152,12 +152,12 @@ decl_storage! {
decl_module! {
/// The UMP module.
pub struct Module<T: Trait> for enum Call where origin: <T as frame_system::Trait>::Origin {
pub struct Module<T: Config> for enum Call where origin: <T as frame_system::Config>::Origin {
}
}
/// Routines related to the upward message passing.
impl<T: Trait> Module<T> {
impl<T: Config> Module<T> {
/// Block initialization logic, called by initializer.
pub(crate) fn initializer_initialize(_now: T::BlockNumber) -> Weight {
0
@@ -365,7 +365,7 @@ impl QueueCache {
///
/// - `upward_message` a dequeued message or `None` if the queue _was_ empty.
/// - `became_empty` is true if the queue _became_ empty.
fn dequeue<T: Trait>(&mut self, para: ParaId) -> (Option<UpwardMessage>, bool) {
fn dequeue<T: Config>(&mut self, para: ParaId) -> (Option<UpwardMessage>, bool) {
let cache_entry = self.0.entry(para).or_insert_with(|| {
let queue = <Module<T> as Store>::RelayDispatchQueues::get(&para);
let (count, total_size) = <Module<T> as Store>::RelayDispatchQueueSize::get(&para);
@@ -386,7 +386,7 @@ impl QueueCache {
}
/// Flushes the updated queues into the storage.
fn flush<T: Trait>(self) {
fn flush<T: Config>(self) {
// NOTE we use an explicit method here instead of Drop impl because it has unwanted semantics
// within runtime. It is dangerous to use because of double-panics and flushing on a panic
// is not necessary as well.
@@ -427,7 +427,7 @@ struct NeedsDispatchCursor {
}
impl NeedsDispatchCursor {
fn new<T: Trait>() -> Self {
fn new<T: Config>() -> Self {
let needs_dispatch: Vec<ParaId> = <Module<T> as Store>::NeedsDispatch::get();
let start_with = <Module<T> as Store>::NextDispatchRoundStartWith::get();
@@ -481,7 +481,7 @@ impl NeedsDispatchCursor {
}
/// Flushes the dispatcher state into the persistent storage.
fn flush<T: Trait>(self) {
fn flush<T: Config>(self) {
let next_one = self.peek();
<Module<T> as Store>::NextDispatchRoundStartWith::set(next_one);
<Module<T> as Store>::NeedsDispatch::put(self.needs_dispatch);
+2 -2
View File
@@ -25,7 +25,7 @@ use crate::{configuration, paras, dmp, hrmp};
/// Make the persisted validation data for a particular parachain.
///
/// This ties together the storage of several modules.
pub fn make_persisted_validation_data<T: paras::Trait + hrmp::Trait>(
pub fn make_persisted_validation_data<T: paras::Config + hrmp::Config>(
para_id: ParaId,
) -> Option<PersistedValidationData<T::BlockNumber>> {
let config = <configuration::Module<T>>::config();
@@ -43,7 +43,7 @@ pub fn make_persisted_validation_data<T: paras::Trait + hrmp::Trait>(
/// Make the transient validation data for a particular parachain.
///
/// This ties together the storage of several modules.
pub fn make_transient_validation_data<T: paras::Trait + dmp::Trait>(
pub fn make_transient_validation_data<T: paras::Config + dmp::Config>(
para_id: ParaId,
) -> Option<TransientValidationData<T::BlockNumber>> {
let config = <configuration::Module<T>>::config();