Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

paras.rs to FRAME V2 #3403

Merged
20 commits merged into from
Jul 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions node/service/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -975,7 +975,6 @@ fn rococo_staging_testnet_config_genesis(wasm_binary: &[u8]) -> rococo_runtime::
},
paras: rococo_runtime::ParasConfig {
paras: vec![],
_phdata: Default::default(),
},
hrmp: Default::default(),
parachains_configuration: rococo_runtime::ParachainsConfigurationConfig {
Expand Down Expand Up @@ -1516,7 +1515,6 @@ pub fn rococo_testnet_genesis(
hrmp: Default::default(),
paras: rococo_runtime::ParasConfig {
paras: vec![],
_phdata: Default::default(),
},
bridge_rococo_grandpa: rococo_runtime::BridgeRococoGrandpaConfig {
owner: Some(root_key.clone()),
Expand Down
2 changes: 1 addition & 1 deletion runtime/common/src/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ frame_support::construct_runtime!(

// Parachains Runtime
Configuration: configuration::{Pallet, Call, Storage, Config<T>},
Paras: paras::{Pallet, Origin, Call, Storage, Event, Config<T>},
Paras: paras::{Pallet, Origin, Call, Storage, Event, Config},

// Para Onboarding Pallets
Registrar: paras_registrar::{Pallet, Call, Storage, Event<T>},
Expand Down
2 changes: 1 addition & 1 deletion runtime/common/src/paras_registrar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ mod tests {
System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
ParachainsConfiguration: configuration::{Pallet, Call, Storage, Config<T>},
Parachains: paras::{Pallet, Origin, Call, Storage, Config<T>, Event},
Parachains: paras::{Pallet, Origin, Call, Storage, Config, Event},
Registrar: paras_registrar::{Pallet, Call, Storage, Event<T>},
}
);
Expand Down
2 changes: 1 addition & 1 deletion runtime/kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1486,7 +1486,7 @@ construct_runtime! {
ParasInclusion: parachains_inclusion::{Pallet, Call, Storage, Event<T>} = 53,
ParasInherent: parachains_paras_inherent::{Pallet, Call, Storage, Inherent} = 54,
ParasScheduler: parachains_scheduler::{Pallet, Call, Storage} = 55,
Paras: parachains_paras::{Pallet, Call, Storage, Event, Config<T>} = 56,
Paras: parachains_paras::{Pallet, Call, Storage, Event, Config} = 56,
ParasInitializer: parachains_initializer::{Pallet, Call, Storage} = 57,
ParasDmp: parachains_dmp::{Pallet, Call, Storage} = 58,
ParasUmp: parachains_ump::{Pallet, Call, Storage, Event} = 59,
Expand Down
10 changes: 5 additions & 5 deletions runtime/parachains/src/hrmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -573,8 +573,8 @@ impl<T: Config> Module<T> {
);

if request.confirmed {
if <paras::Module<T>>::is_valid_para(channel_id.sender)
&& <paras::Module<T>>::is_valid_para(channel_id.recipient)
if <paras::Pallet<T>>::is_valid_para(channel_id.sender)
&& <paras::Pallet<T>>::is_valid_para(channel_id.recipient)
{
<Self as Store>::HrmpChannels::insert(
&channel_id,
Expand Down Expand Up @@ -972,7 +972,7 @@ impl<T: Config> Module<T> {
) -> DispatchResult {
ensure!(origin != recipient, Error::<T>::OpenHrmpChannelToSelf);
ensure!(
<paras::Module<T>>::is_valid_para(recipient),
<paras::Pallet<T>>::is_valid_para(recipient),
Error::<T>::OpenHrmpChannelInvalidRecipient,
);

Expand Down Expand Up @@ -1010,7 +1010,7 @@ impl<T: Config> Module<T> {
let egress_cnt =
<Self as Store>::HrmpEgressChannelsIndex::decode_len(&origin).unwrap_or(0) as u32;
let open_req_cnt = <Self as Store>::HrmpOpenChannelRequestCount::get(&origin);
let channel_num_limit = if <paras::Module<T>>::is_parathread(origin) {
let channel_num_limit = if <paras::Pallet<T>>::is_parathread(origin) {
config.hrmp_max_parathread_outbound_channels
} else {
config.hrmp_max_parachain_outbound_channels
Expand Down Expand Up @@ -1080,7 +1080,7 @@ impl<T: Config> Module<T> {
// check if by accepting this open channel request, this parachain would exceed the
// number of inbound channels.
let config = <configuration::Module<T>>::config();
let channel_num_limit = if <paras::Module<T>>::is_parathread(origin) {
let channel_num_limit = if <paras::Pallet<T>>::is_parathread(origin) {
config.hrmp_max_parathread_inbound_channels
} else {
config.hrmp_max_parachain_inbound_channels
Expand Down
8 changes: 4 additions & 4 deletions runtime/parachains/src/inclusion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ impl<T: Config> Module<T> {
);

let validation_code_hash =
<paras::Module<T>>::validation_code_hash_at(para_id, now, None)
<paras::Pallet<T>>::validation_code_hash_at(para_id, now, None)
// A candidate for a parachain without current validation code is not scheduled.
.ok_or_else(|| Error::<T>::UnscheduledCandidate)?;
ensure!(
Expand Down Expand Up @@ -679,7 +679,7 @@ impl<T: Config> Module<T> {
// initial weight is config read.
let mut weight = T::DbWeight::get().reads_writes(1, 0);
if let Some(new_code) = commitments.new_validation_code {
weight += <paras::Module<T>>::schedule_code_upgrade(
weight += <paras::Pallet<T>>::schedule_code_upgrade(
receipt.descriptor.para_id,
new_code,
relay_parent_number + config.validation_upgrade_delay,
Expand Down Expand Up @@ -708,7 +708,7 @@ impl<T: Config> Module<T> {
Event::<T>::CandidateIncluded(plain, commitments.head_data.clone(), core_index, backing_group)
);

weight + <paras::Module<T>>::note_new_head(
weight + <paras::Pallet<T>>::note_new_head(
receipt.descriptor.para_id,
commitments.head_data,
relay_parent_number,
Expand Down Expand Up @@ -869,7 +869,7 @@ impl<T: Config> CandidateCheckContext<T> {

// if any, the code upgrade attempt is allowed.
if let Some(new_validation_code) = new_validation_code {
let valid_upgrade_attempt = <paras::Module<T>>::last_code_upgrade(para_id, true)
let valid_upgrade_attempt = <paras::Pallet<T>>::last_code_upgrade(para_id, true)
.map_or(true, |last| {
last <= self.relay_parent_number
&& self.relay_parent_number.saturating_sub(last)
Expand Down
6 changes: 3 additions & 3 deletions runtime/parachains/src/initializer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ decl_module! {
// - HRMP
let total_weight = configuration::Module::<T>::initializer_initialize(now) +
shared::Module::<T>::initializer_initialize(now) +
paras::Module::<T>::initializer_initialize(now) +
paras::Pallet::<T>::initializer_initialize(now) +
scheduler::Module::<T>::initializer_initialize(now) +
inclusion::Module::<T>::initializer_initialize(now) +
session_info::Module::<T>::initializer_initialize(now) +
Expand All @@ -152,7 +152,7 @@ decl_module! {
session_info::Module::<T>::initializer_finalize();
inclusion::Module::<T>::initializer_finalize();
scheduler::Module::<T>::initializer_finalize();
paras::Module::<T>::initializer_finalize();
paras::Pallet::<T>::initializer_finalize();
shared::Module::<T>::initializer_finalize();
configuration::Module::<T>::initializer_finalize();

Expand Down Expand Up @@ -224,7 +224,7 @@ impl<T: Config> Module<T> {
session_index,
};

let outgoing_paras = paras::Module::<T>::initializer_on_new_session(&notification);
let outgoing_paras = paras::Pallet::<T>::initializer_on_new_session(&notification);
scheduler::Module::<T>::initializer_on_new_session(&notification);
inclusion::Module::<T>::initializer_on_new_session(&notification);
session_info::Module::<T>::initializer_on_new_session(&notification);
Expand Down
8 changes: 4 additions & 4 deletions runtime/parachains/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,20 @@ pub fn schedule_para_initialize<T: paras::Config>(
id: ParaId,
genesis: paras::ParaGenesisArgs,
) -> Result<(), ()> {
<paras::Module<T>>::schedule_para_initialize(id, genesis).map_err(|_| ())
<paras::Pallet<T>>::schedule_para_initialize(id, genesis).map_err(|_| ())
}

/// Schedule a para to be cleaned up at the start of the next session.
pub fn schedule_para_cleanup<T: paras::Config>(id: primitives::v1::Id) -> Result<(), ()> {
<paras::Module<T>>::schedule_para_cleanup(id).map_err(|_| ())
<paras::Pallet<T>>::schedule_para_cleanup(id).map_err(|_| ())
}

/// Schedule a parathread to be upgraded to a parachain.
pub fn schedule_parathread_upgrade<T: paras::Config>(id: ParaId) -> Result<(), ()> {
paras::Module::<T>::schedule_parathread_upgrade(id).map_err(|_| ())
paras::Pallet::<T>::schedule_parathread_upgrade(id).map_err(|_| ())
}

/// Schedule a parachain to be downgraded to a parathread.
pub fn schedule_parachain_downgrade<T: paras::Config>(id: ParaId) -> Result<(), ()> {
paras::Module::<T>::schedule_parachain_downgrade(id).map_err(|_| ())
paras::Pallet::<T>::schedule_parachain_downgrade(id).map_err(|_| ())
}
7 changes: 4 additions & 3 deletions runtime/parachains/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ use sp_runtime::traits::{
};
use primitives::v1::{AuthorityDiscoveryId, Balance, BlockNumber, Header, ValidatorIndex};
use frame_support::parameter_types;
use frame_support::traits::GenesisBuild;
use frame_support_test::TestRandomness;
use std::cell::RefCell;
use std::collections::HashMap;
Expand All @@ -42,7 +43,7 @@ frame_support::construct_runtime!(
{
System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
Paras: paras::{Pallet, Origin, Call, Storage, Event, Config<T>},
Paras: paras::{Pallet, Origin, Call, Storage, Event, Config},
Configuration: configuration::{Pallet, Call, Storage, Config<T>},
Shared: shared::{Pallet, Call, Storage},
Inclusion: inclusion::{Pallet, Call, Storage, Event<T>},
Expand Down Expand Up @@ -208,7 +209,7 @@ pub fn new_test_ext(state: MockGenesisConfig) -> TestExternalities {

let mut t = state.system.build_storage::<Test>().unwrap();
state.configuration.assimilate_storage(&mut t).unwrap();
state.paras.assimilate_storage(&mut t).unwrap();
GenesisBuild::<Test>::assimilate_storage(&state.paras, &mut t).unwrap();

t.into()
}
Expand All @@ -217,5 +218,5 @@ pub fn new_test_ext(state: MockGenesisConfig) -> TestExternalities {
pub struct MockGenesisConfig {
pub system: frame_system::GenesisConfig,
pub configuration: crate::configuration::GenesisConfig<Test>,
pub paras: crate::paras::GenesisConfig<Test>,
pub paras: crate::paras::GenesisConfig,
}
Loading