Unverified Commit 635f0457 authored by ferrell-code's avatar ferrell-code Committed by GitHub
Browse files

Parachains configuration.rs FrameV2 (#3516)



* migration

* genesis build correctly

* migrate runtimes

* add genesis builds

* expose GenesisBuild

* chainspec migration

* fmt

* check before insert

* Reduce visibility of storage items to crate
Co-authored-by: Keith Yeung's avatarKeith Yeung <kungfukeith11@gmail.com>
parent aeeeeaf9
Pipeline #150107 passed with stages
in 36 minutes and 32 seconds
......@@ -524,7 +524,7 @@ fn westend_staging_testnet_config_genesis(wasm_binary: &[u8]) -> westend::Genesi
sudo: westend::SudoConfig {
key: endowed_accounts[0].clone(),
},
parachains_configuration: westend::ParachainsConfigurationConfig {
configuration: westend::ConfigurationConfig {
config: default_parachains_host_configuration(),
},
paras: Default::default(),
......@@ -733,7 +733,7 @@ fn kusama_staging_testnet_config_genesis(wasm_binary: &[u8]) -> kusama::GenesisC
},
vesting: kusama::VestingConfig { vesting: vec![] },
treasury: Default::default(),
parachains_configuration: kusama::ParachainsConfigurationConfig {
configuration: kusama::ConfigurationConfig {
config: default_parachains_host_configuration(),
},
gilt: Default::default(),
......@@ -977,7 +977,7 @@ fn rococo_staging_testnet_config_genesis(wasm_binary: &[u8]) -> rococo_runtime::
paras: vec![],
},
hrmp: Default::default(),
parachains_configuration: rococo_runtime::ParachainsConfigurationConfig {
configuration: rococo_runtime::ConfigurationConfig {
config: default_parachains_host_configuration(),
},
bridge_rococo_grandpa: rococo_runtime::BridgeRococoGrandpaConfig {
......@@ -1360,7 +1360,7 @@ pub fn kusama_testnet_genesis(
},
vesting: kusama::VestingConfig { vesting: vec![] },
treasury: Default::default(),
parachains_configuration: kusama::ParachainsConfigurationConfig {
configuration: kusama::ConfigurationConfig {
config: default_parachains_host_configuration(),
},
gilt: Default::default(),
......@@ -1449,7 +1449,7 @@ pub fn westend_testnet_genesis(
authority_discovery: westend::AuthorityDiscoveryConfig { keys: vec![] },
vesting: westend::VestingConfig { vesting: vec![] },
sudo: westend::SudoConfig { key: root_key },
parachains_configuration: westend::ParachainsConfigurationConfig {
configuration: westend::ConfigurationConfig {
config: default_parachains_host_configuration(),
},
paras: Default::default(),
......@@ -1517,7 +1517,7 @@ pub fn rococo_testnet_genesis(
keys: vec![],
},
sudo: rococo_runtime::SudoConfig { key: root_key.clone() },
parachains_configuration: rococo_runtime::ParachainsConfigurationConfig {
configuration: rococo_runtime::ConfigurationConfig {
config: default_parachains_host_configuration(),
},
hrmp: Default::default(),
......
......@@ -28,7 +28,7 @@ use sp_keystore::{KeystoreExt, testing::KeyStore};
use primitives::v1::{BlockNumber, Header, Id as ParaId, ValidationCode, HeadData, LOWEST_PUBLIC_ID};
use frame_support::{
parameter_types, assert_ok, assert_noop, PalletId,
traits::{Currency, OnInitialize, OnFinalize, KeyOwnerProofSystem},
traits::{Currency, OnInitialize, OnFinalize, KeyOwnerProofSystem, GenesisBuild},
};
use frame_system::EnsureRoot;
use runtime_parachains::{
......@@ -234,13 +234,16 @@ impl crowdloan::Config for Test {
/// Create a new set of test externalities.
pub fn new_test_ext() -> TestExternalities {
let mut t = frame_system::GenesisConfig::default().build_storage::<Test>().unwrap();
configuration::GenesisConfig::<Test> {
config: configuration::HostConfiguration {
max_code_size: 2 * 1024 * 1024, // 2 MB
max_head_data_size: 1 * 1024 * 1024, // 1 MB
..Default::default()
},
}.assimilate_storage(&mut t).unwrap();
GenesisBuild::<Test>::assimilate_storage(
&configuration::GenesisConfig {
config: configuration::HostConfiguration {
max_code_size: 2 * 1024 * 1024, // 2 MB
max_head_data_size: 1 * 1024 * 1024, // 1 MB
..Default::default()
}
},
&mut t
).unwrap();
let keystore = KeyStore::new();
let mut ext: sp_io::TestExternalities = t.into();
ext.register_extension(KeystoreExt(Arc::new(keystore)));
......
......@@ -551,7 +551,7 @@ mod tests {
use primitives::v1::{Balance, BlockNumber, Header};
use frame_system::limits;
use frame_support::{
traits::{OnInitialize, OnFinalize},
traits::{OnInitialize, OnFinalize, GenesisBuild},
assert_ok, assert_noop, parameter_types,
error::BadOrigin,
};
......@@ -571,7 +571,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>},
Configuration: configuration::{Pallet, Call, Storage, Config<T>},
Parachains: paras::{Pallet, Origin, Call, Storage, Config, Event},
ParasShared: shared::{Pallet, Call, Storage},
Registrar: paras_registrar::{Pallet, Call, Storage, Event<T>},
......@@ -658,13 +658,16 @@ mod tests {
pub fn new_test_ext() -> TestExternalities {
let mut t = frame_system::GenesisConfig::default().build_storage::<Test>().unwrap();
configuration::GenesisConfig::<Test> {
config: configuration::HostConfiguration {
max_code_size: 2 * 1024 * 1024, // 2 MB
max_head_data_size: 1 * 1024 * 1024, // 1 MB
..Default::default()
GenesisBuild::<Test>::assimilate_storage(
&configuration::GenesisConfig {
config: configuration::HostConfiguration {
max_code_size: 2 * 1024 * 1024, // 2 MB
max_head_data_size: 1 * 1024 * 1024, // 1 MB
..Default::default()
}
},
}.assimilate_storage(&mut t).unwrap();
&mut t
).unwrap();
pallet_balances::GenesisConfig::<Test> {
balances: vec![(1, 10_000_000), (2, 10_000_000)],
......@@ -716,11 +719,11 @@ mod tests {
}
fn max_code_size() -> u32 {
ParachainsConfiguration::config().max_code_size
Configuration::config().max_code_size
}
fn max_head_size() -> u32 {
ParachainsConfiguration::config().max_head_data_size
Configuration::config().max_head_data_size
}
#[test]
......
......@@ -29,7 +29,7 @@ impl<T: configuration::Config + dmp::Config> SendXcm for ChildParachainRouter<T>
match dest {
MultiLocation::X1(Junction::Parachain(id)) => {
// Downward message passing.
let config = <configuration::Module<T>>::config();
let config = <configuration::Pallet<T>>::config();
<dmp::Pallet<T>>::queue_downward_message(
&config,
id.into(),
......
......@@ -1473,7 +1473,7 @@ construct_runtime! {
// Parachains pallets. Start indices at 50 to leave room.
ParachainsOrigin: parachains_origin::{Pallet, Origin} = 50,
ParachainsConfiguration: parachains_configuration::{Pallet, Call, Storage, Config<T>} = 51,
Configuration: parachains_configuration::{Pallet, Call, Storage, Config<T>} = 51,
ParasShared: parachains_shared::{Pallet, Call, Storage} = 52,
ParaInclusion: parachains_inclusion::{Pallet, Call, Storage, Event<T>} = 53,
ParasInherent: parachains_paras_inherent::{Pallet, Call, Storage, Inherent} = 54,
......
This diff is collapsed.
......@@ -558,7 +558,7 @@ impl StatementSetFilter {
impl<T: Config> Pallet<T> {
/// Called by the initializer to initialize the disputes module.
pub(crate) fn initializer_initialize(now: T::BlockNumber) -> Weight {
let config = <configuration::Module<T>>::config();
let config = <configuration::Pallet<T>>::config();
let mut weight = 0;
for (session_index, candidate_hash, mut dispute) in <Disputes<T>>::iter() {
......
......@@ -522,7 +522,7 @@ pub mod pallet {
#[pallet::weight(0)]
pub fn force_process_hrmp_open(origin: OriginFor<T>) -> DispatchResult {
ensure_root(origin)?;
let host_config = configuration::Module::<T>::config();
let host_config = configuration::Pallet::<T>::config();
Self::process_hrmp_open_channel_requests(&host_config);
Ok(())
}
......@@ -542,7 +542,7 @@ pub mod pallet {
#[cfg(feature = "std")]
fn initialize_storage<T: Config>(preopen_hrmp_channels: &[(ParaId, ParaId, u32, u32)]) {
let host_config = configuration::Module::<T>::config();
let host_config = configuration::Pallet::<T>::config();
for &(sender, recipient, max_capacity, max_message_size) in preopen_hrmp_channels {
if let Err(err) = preopen_hrmp_channel::<T>(sender, recipient, max_capacity, max_message_size) {
panic!("failed to initialize the genesis storage: {:?}", err);
......@@ -1051,7 +1051,7 @@ impl<T: Config> Pallet<T> {
Error::<T>::OpenHrmpChannelInvalidRecipient,
);
let config = <configuration::Module<T>>::config();
let config = <configuration::Pallet<T>>::config();
ensure!(
proposed_max_capacity > 0,
Error::<T>::OpenHrmpChannelZeroCapacity,
......@@ -1154,7 +1154,7 @@ impl<T: Config> Pallet<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 config = <configuration::Pallet<T>>::config();
let channel_num_limit = if <paras::Pallet<T>>::is_parathread(origin) {
config.hrmp_max_parathread_inbound_channels
} else {
......@@ -1221,7 +1221,7 @@ impl<T: Config> Pallet<T> {
<Self as Store>::HrmpCloseChannelRequests::insert(&channel_id, ());
<Self as Store>::HrmpCloseChannelRequestsList::append(channel_id.clone());
let config = <configuration::Module<T>>::config();
let config = <configuration::Pallet<T>>::config();
let notification_bytes = {
use parity_scale_codec::Encode as _;
use xcm::opaque::{v0::Xcm, VersionedXcm};
......
......@@ -674,7 +674,7 @@ impl<T: Config> Pallet<T> {
) -> Weight {
let plain = receipt.to_plain();
let commitments = receipt.commitments;
let config = <configuration::Module<T>>::config();
let config = <configuration::Pallet<T>>::config();
T::RewardValidators::reward_backing(backers.iter().enumerate()
.filter(|(_, backed)| **backed)
......@@ -876,7 +876,7 @@ struct CandidateCheckContext<T: Config> {
impl<T: Config> CandidateCheckContext<T> {
fn new(now: T::BlockNumber, relay_parent_number: T::BlockNumber) -> Self {
Self {
config: <configuration::Module<T>>::config(),
config: <configuration::Pallet<T>>::config(),
now,
relay_parent_number,
}
......
......@@ -132,7 +132,7 @@ pub mod pallet {
// - DMP
// - UMP
// - HRMP
let total_weight = configuration::Module::<T>::initializer_initialize(now) +
let total_weight = configuration::Pallet::<T>::initializer_initialize(now) +
shared::Pallet::<T>::initializer_initialize(now) +
paras::Pallet::<T>::initializer_initialize(now) +
scheduler::Module::<T>::initializer_initialize(now) +
......@@ -159,7 +159,7 @@ pub mod pallet {
scheduler::Module::<T>::initializer_finalize();
paras::Pallet::<T>::initializer_finalize();
shared::Pallet::<T>::initializer_finalize();
configuration::Module::<T>::initializer_finalize();
configuration::Pallet::<T>::initializer_finalize();
// Apply buffered session changes as the last thing. This way the runtime APIs and the
// next block will observe the next session.
......@@ -199,7 +199,7 @@ impl<T: Config> Pallet<T> {
all_validators: Vec<ValidatorId>,
queued: Vec<ValidatorId>,
) {
let prev_config = <configuration::Module<T>>::config();
let prev_config = <configuration::Pallet<T>>::config();
let random_seed = {
let mut buf = [0u8; 32];
......@@ -213,9 +213,9 @@ impl<T: Config> Pallet<T> {
// We can't pass the new config into the thing that determines the new config,
// so we don't pass the `SessionChangeNotification` into this module.
configuration::Module::<T>::initializer_on_new_session(&session_index);
configuration::Pallet::<T>::initializer_on_new_session(&session_index);
let new_config = <configuration::Module<T>>::config();
let new_config = <configuration::Pallet<T>>::config();
let validators = shared::Pallet::<T>::initializer_on_new_session(
session_index,
......
......@@ -52,7 +52,7 @@ pub fn validator_groups<T: initializer::Config>() -> (
pub fn availability_cores<T: initializer::Config>() -> Vec<CoreState<T::Hash, T::BlockNumber>> {
let cores = <scheduler::Module<T>>::availability_cores();
let parachains = <paras::Pallet<T>>::parachains();
let config = <configuration::Module<T>>::config();
let config = <configuration::Pallet<T>>::config();
let now = <frame_system::Pallet<T>>::block_number() + One::one();
<scheduler::Module<T>>::clear();
......
......@@ -335,7 +335,7 @@ impl<T: Config> Module<T> {
pub fn add_parathread_claim(claim: ParathreadClaim) {
if !<paras::Pallet<T>>::is_parathread(claim.0) { return }
let config = <configuration::Module<T>>::config();
let config = <configuration::Pallet<T>>::config();
let queue_max_size = config.parathread_cores * config.scheduling_lookahead;
ParathreadQueue::mutate(|queue| {
......@@ -368,7 +368,7 @@ impl<T: Config> Module<T> {
now: T::BlockNumber,
) {
let mut cores = AvailabilityCores::get();
let config = <configuration::Module<T>>::config();
let config = <configuration::Pallet<T>>::config();
for (freed_index, freed_reason) in just_freed_cores {
if (freed_index.0 as usize) < cores.len() {
......@@ -552,7 +552,7 @@ impl<T: Config> Module<T> {
/// Get the group assigned to a specific core by index at the current block number. Result undefined if the core index is unknown
/// or the block number is less than the session start index.
pub(crate) fn group_assigned_to_core(core: CoreIndex, at: T::BlockNumber) -> Option<GroupIndex> {
let config = <configuration::Module<T>>::config();
let config = <configuration::Pallet<T>>::config();
let session_start_block = <SessionStartBlock<T>>::get();
if at < session_start_block { return None }
......@@ -588,7 +588,7 @@ impl<T: Config> Module<T> {
/// which prevents us from testing the code if using `impl Trait`.
pub(crate) fn availability_timeout_predicate() -> Option<Box<dyn Fn(CoreIndex, T::BlockNumber) -> bool>> {
let now = <frame_system::Pallet<T>>::block_number();
let config = <configuration::Module<T>>::config();
let config = <configuration::Pallet<T>>::config();
let session_start = <SessionStartBlock<T>>::get();
let blocks_since_session_start = now.saturating_sub(session_start);
......@@ -630,7 +630,7 @@ impl<T: Config> Module<T> {
/// Returns a helper for determining group rotation.
pub(crate) fn group_rotation_info(now: T::BlockNumber) -> GroupRotationInfo<T::BlockNumber> {
let session_start_block = Self::session_start_block();
let group_rotation_frequency = <configuration::Module<T>>::config()
let group_rotation_frequency = <configuration::Pallet<T>>::config()
.group_rotation_frequency;
GroupRotationInfo {
......@@ -708,7 +708,7 @@ impl<T: Config> Module<T> {
// Free all scheduled cores and return parathread claims to queue, with retries incremented.
pub(crate) fn clear() {
let config = <configuration::Module<T>>::config();
let config = <configuration::Pallet<T>>::config();
ParathreadQueue::mutate(|queue| {
for core_assignment in Scheduled::take() {
if let AssignmentKind::Parathread(collator, retries) = core_assignment.kind {
......
......@@ -82,7 +82,7 @@ impl<T: Config> Module<T> {
pub(crate) fn initializer_on_new_session(
notification: &crate::initializer::SessionChangeNotification<T::BlockNumber>
) {
let config = <configuration::Module<T>>::config();
let config = <configuration::Pallet<T>>::config();
let dispute_period = config.dispute_period;
......
......@@ -388,7 +388,7 @@ impl<T: Config> Pallet<T> {
pub(crate) fn process_pending_upward_messages() -> Weight {
let mut weight_used = 0;
let config = <configuration::Module<T>>::config();
let config = <configuration::Pallet<T>>::config();
let mut cursor = NeedsDispatchCursor::new::<T>();
let mut queue_cache = QueueCache::new();
......
......@@ -31,7 +31,7 @@ pub fn make_persisted_validation_data<T: paras::Config + hrmp::Config>(
relay_parent_number: T::BlockNumber,
relay_parent_storage_root: T::Hash,
) -> Option<PersistedValidationData<T::Hash, T::BlockNumber>> {
let config = <configuration::Module<T>>::config();
let config = <configuration::Pallet<T>>::config();
Some(PersistedValidationData {
parent_head: <paras::Pallet<T>>::para_head(&para_id)?,
......
......@@ -222,7 +222,7 @@ construct_runtime! {
// Parachains modules.
ParachainsOrigin: parachains_origin::{Pallet, Origin},
ParachainsConfiguration: parachains_configuration::{Pallet, Call, Storage, Config<T>},
Configuration: parachains_configuration::{Pallet, Call, Storage, Config<T>},
ParasShared: parachains_shared::{Pallet, Call, Storage},
ParaInclusion: parachains_inclusion::{Pallet, Call, Storage, Event<T>},
ParasInherent: parachains_paras_inherent::{Pallet, Call, Storage, Inherent},
......
......@@ -1063,7 +1063,7 @@ construct_runtime! {
// Parachains pallets. Start indices at 40 to leave room.
ParachainsOrigin: parachains_origin::{Pallet, Origin} = 41,
ParachainsConfiguration: parachains_configuration::{Pallet, Call, Storage, Config<T>} = 42,
Configuration: parachains_configuration::{Pallet, Call, Storage, Config<T>} = 42,
ParasShared: parachains_shared::{Pallet, Call, Storage} = 43,
ParaInclusion: parachains_inclusion::{Pallet, Call, Storage, Event<T>} = 44,
ParasInherent: parachains_paras_inherent::{Pallet, Call, Storage, Inherent} = 45,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment