mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 07:41:08 +00:00
Change the Config of the MaxRococoNum Slot from a Constant to a Storage function (#7217)
* set MaxPermanentSlots and MaxTemporarySlots with a extrinsic instead of a constant * delete the MaxPermanentSlots and MaxTemporarySlots constants from config on Rococo and Westend * migration code for assigned slots * remove getters * little refactor * set values in the GenesisConfig * refactor in the migration, adding it in the rococo runtime * refactor: fmt * Minor fix * pre_upgrade check * add migration to mod v1 * Logs following Substrate#12873 * fix: current storage version set to 1 * use enact when try-runtime * Vec seems to be missing * feature gate import * fix as per #13993 * address comments Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * address comments Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * benchmarking for assign_perm_parachain_slot extrinsic * benchmark all the extrinsics of the pallet * cargo fmt for assigned slots * migration added for westend * licence in benchmarking file * BuildGenesisConfig * assigned_slots default in genesis * cargo fmt * assigned_slots fix tests config * cargo fmt * fix benchmarking compile error * fix benchmarking imports * benchmark worst case scenario for validation code and head data * add assigned_slots in frame_benchmarking on Rococo and Westend * modify values for para_id in benchmarking * delete the assigned_slots in westend frame_benchmarking * fix benchmarkings and add it to westend * cargo fmt * ".git/.scripts/commands/bench/bench.sh" --subcommand=runtime --runtime=rococo --target_dir=polkadot --pallet=runtime_common::assigned_slots * ".git/.scripts/commands/bench/bench.sh" --subcommand=runtime --runtime=westend --target_dir=polkadot --pallet=runtime_common::assigned_slots * use generated weights in assigned_slots pallet * small changes in set_max_permanent_slots and set_max_temporary_slots * revert last commit * address some comments * wrap migration with VersionCheckedMigrateToV1 * add experimental feature in pallet, and assers in post_upgrade migration * clean warnings * clean unnecesary experimental flag * small typo in comments * cargo fmt * small comments fixes --------- Co-authored-by: al3mart <11448715+al3mart@users.noreply.github.com> Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> Co-authored-by: command-bot <>
This commit is contained in:
@@ -515,6 +515,7 @@ fn westend_staging_testnet_config_genesis(wasm_binary: &[u8]) -> westend::Runtim
|
||||
},
|
||||
xcm_pallet: Default::default(),
|
||||
nomination_pools: Default::default(),
|
||||
assigned_slots: Default::default(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1023,6 +1024,7 @@ fn rococo_staging_testnet_config_genesis(
|
||||
},
|
||||
xcm_pallet: Default::default(),
|
||||
nis_counterpart_balances: Default::default(),
|
||||
assigned_slots: Default::default(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1484,6 +1486,7 @@ pub fn westend_testnet_genesis(
|
||||
},
|
||||
xcm_pallet: Default::default(),
|
||||
nomination_pools: Default::default(),
|
||||
assigned_slots: Default::default(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1573,6 +1576,7 @@ pub fn rococo_testnet_genesis(
|
||||
},
|
||||
xcm_pallet: Default::default(),
|
||||
nis_counterpart_balances: Default::default(),
|
||||
assigned_slots: Default::default(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -64,6 +64,9 @@ test-helpers = { package = "polkadot-primitives-test-helpers", path = "../../pri
|
||||
|
||||
[features]
|
||||
default = ["std"]
|
||||
experimental = [
|
||||
"frame-support/experimental"
|
||||
]
|
||||
no_std = []
|
||||
std = [
|
||||
"bitvec/std",
|
||||
|
||||
@@ -0,0 +1,160 @@
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// This file is part of Polkadot.
|
||||
|
||||
// Polkadot is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// Polkadot is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! Benchmarking for assigned_slots pallet
|
||||
|
||||
#![cfg(feature = "runtime-benchmarks")]
|
||||
use super::*;
|
||||
|
||||
use frame_benchmarking::v2::*;
|
||||
use frame_support::assert_ok;
|
||||
use frame_system::{pallet_prelude::BlockNumberFor, RawOrigin};
|
||||
use primitives::Id as ParaId;
|
||||
use sp_runtime::traits::Bounded;
|
||||
|
||||
type CurrencyOf<T> = <<T as Config>::Leaser as Leaser<BlockNumberFor<T>>>::Currency;
|
||||
type BalanceOf<T> = <<<T as Config>::Leaser as Leaser<BlockNumberFor<T>>>::Currency as Currency<
|
||||
<T as frame_system::Config>::AccountId,
|
||||
>>::Balance;
|
||||
#[benchmarks(where T: Config)]
|
||||
mod benchmarks {
|
||||
use super::*;
|
||||
|
||||
use crate::assigned_slots::Pallet as AssignedSlots;
|
||||
|
||||
fn register_parachain<T: Config>(para_id: ParaId) {
|
||||
let who: T::AccountId = whitelisted_caller();
|
||||
let worst_validation_code = T::Registrar::worst_validation_code();
|
||||
let worst_head_data = T::Registrar::worst_head_data();
|
||||
|
||||
CurrencyOf::<T>::make_free_balance_be(&who, BalanceOf::<T>::max_value());
|
||||
|
||||
assert_ok!(T::Registrar::register(
|
||||
who,
|
||||
para_id,
|
||||
worst_head_data,
|
||||
worst_validation_code.clone()
|
||||
));
|
||||
assert_ok!(paras::Pallet::<T>::add_trusted_validation_code(
|
||||
frame_system::Origin::<T>::Root.into(),
|
||||
worst_validation_code,
|
||||
));
|
||||
T::Registrar::execute_pending_transitions();
|
||||
}
|
||||
|
||||
#[benchmark]
|
||||
fn assign_perm_parachain_slot() {
|
||||
let para_id = ParaId::from(1_u32);
|
||||
let caller = RawOrigin::Root;
|
||||
|
||||
let _ =
|
||||
AssignedSlots::<T>::set_max_permanent_slots(frame_system::Origin::<T>::Root.into(), 10);
|
||||
register_parachain::<T>(para_id);
|
||||
|
||||
let counter = PermanentSlotCount::<T>::get();
|
||||
let current_lease_period: BlockNumberFor<T> =
|
||||
T::Leaser::lease_period_index(frame_system::Pallet::<T>::block_number())
|
||||
.and_then(|x| Some(x.0))
|
||||
.unwrap();
|
||||
#[extrinsic_call]
|
||||
assign_perm_parachain_slot(caller, para_id);
|
||||
|
||||
assert_eq!(
|
||||
PermanentSlots::<T>::get(para_id),
|
||||
Some((
|
||||
current_lease_period,
|
||||
LeasePeriodOf::<T>::from(T::PermanentSlotLeasePeriodLength::get()),
|
||||
))
|
||||
);
|
||||
assert_eq!(PermanentSlotCount::<T>::get(), counter + 1);
|
||||
}
|
||||
|
||||
#[benchmark]
|
||||
fn assign_temp_parachain_slot() {
|
||||
let para_id = ParaId::from(2_u32);
|
||||
let caller = RawOrigin::Root;
|
||||
|
||||
let _ =
|
||||
AssignedSlots::<T>::set_max_temporary_slots(frame_system::Origin::<T>::Root.into(), 10);
|
||||
register_parachain::<T>(para_id);
|
||||
|
||||
let current_lease_period: BlockNumberFor<T> =
|
||||
T::Leaser::lease_period_index(frame_system::Pallet::<T>::block_number())
|
||||
.and_then(|x| Some(x.0))
|
||||
.unwrap();
|
||||
|
||||
let counter = TemporarySlotCount::<T>::get();
|
||||
#[extrinsic_call]
|
||||
assign_temp_parachain_slot(caller, para_id, SlotLeasePeriodStart::Current);
|
||||
|
||||
let tmp = ParachainTemporarySlot {
|
||||
manager: whitelisted_caller(),
|
||||
period_begin: current_lease_period,
|
||||
period_count: LeasePeriodOf::<T>::from(T::TemporarySlotLeasePeriodLength::get()),
|
||||
last_lease: Some(BlockNumberFor::<T>::zero()),
|
||||
lease_count: 1,
|
||||
};
|
||||
assert_eq!(TemporarySlots::<T>::get(para_id), Some(tmp));
|
||||
assert_eq!(TemporarySlotCount::<T>::get(), counter + 1);
|
||||
}
|
||||
|
||||
#[benchmark]
|
||||
fn unassign_parachain_slot() {
|
||||
let para_id = ParaId::from(3_u32);
|
||||
let caller = RawOrigin::Root;
|
||||
|
||||
let _ =
|
||||
AssignedSlots::<T>::set_max_temporary_slots(frame_system::Origin::<T>::Root.into(), 10);
|
||||
register_parachain::<T>(para_id);
|
||||
|
||||
let _ = AssignedSlots::<T>::assign_temp_parachain_slot(
|
||||
caller.clone().into(),
|
||||
para_id,
|
||||
SlotLeasePeriodStart::Current,
|
||||
);
|
||||
|
||||
let counter = TemporarySlotCount::<T>::get();
|
||||
#[extrinsic_call]
|
||||
unassign_parachain_slot(caller, para_id);
|
||||
|
||||
assert_eq!(TemporarySlots::<T>::get(para_id), None);
|
||||
assert_eq!(TemporarySlotCount::<T>::get(), counter - 1);
|
||||
}
|
||||
|
||||
#[benchmark]
|
||||
fn set_max_permanent_slots() {
|
||||
let caller = RawOrigin::Root;
|
||||
#[extrinsic_call]
|
||||
set_max_permanent_slots(caller, u32::MAX);
|
||||
|
||||
assert_eq!(MaxPermanentSlots::<T>::get(), u32::MAX);
|
||||
}
|
||||
|
||||
#[benchmark]
|
||||
fn set_max_temporary_slots() {
|
||||
let caller = RawOrigin::Root;
|
||||
#[extrinsic_call]
|
||||
set_max_temporary_slots(caller, u32::MAX);
|
||||
|
||||
assert_eq!(MaxTemporarySlots::<T>::get(), u32::MAX);
|
||||
}
|
||||
|
||||
impl_benchmark_test_suite!(
|
||||
AssignedSlots,
|
||||
crate::assigned_slots::tests::new_test_ext(),
|
||||
crate::assigned_slots::tests::Test,
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// This file is part of Polkadot.
|
||||
|
||||
// Polkadot is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// Polkadot is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use super::{Config, MaxPermanentSlots, MaxTemporarySlots, Pallet, LOG_TARGET};
|
||||
use frame_support::{
|
||||
dispatch::GetStorageVersion,
|
||||
traits::{Get, OnRuntimeUpgrade},
|
||||
};
|
||||
|
||||
#[cfg(feature = "try-runtime")]
|
||||
use frame_support::ensure;
|
||||
#[cfg(feature = "try-runtime")]
|
||||
use sp_std::vec::Vec;
|
||||
|
||||
pub mod v1 {
|
||||
|
||||
use super::*;
|
||||
pub struct MigrateToV1<T>(sp_std::marker::PhantomData<T>);
|
||||
impl<T: Config> OnRuntimeUpgrade for MigrateToV1<T> {
|
||||
#[cfg(feature = "try-runtime")]
|
||||
fn pre_upgrade() -> Result<Vec<u8>, sp_runtime::TryRuntimeError> {
|
||||
let onchain_version = Pallet::<T>::on_chain_storage_version();
|
||||
ensure!(onchain_version < 1, "assigned_slots::MigrateToV1 migration can be deleted");
|
||||
Ok(Default::default())
|
||||
}
|
||||
|
||||
fn on_runtime_upgrade() -> frame_support::weights::Weight {
|
||||
let onchain_version = Pallet::<T>::on_chain_storage_version();
|
||||
if onchain_version < 1 {
|
||||
const MAX_PERMANENT_SLOTS: u32 = 100;
|
||||
const MAX_TEMPORARY_SLOTS: u32 = 100;
|
||||
|
||||
<MaxPermanentSlots<T>>::put(MAX_PERMANENT_SLOTS);
|
||||
<MaxTemporarySlots<T>>::put(MAX_TEMPORARY_SLOTS);
|
||||
// Return the weight consumed by the migration.
|
||||
T::DbWeight::get().reads_writes(1, 3)
|
||||
} else {
|
||||
log::info!(target: LOG_TARGET, "MigrateToV1 should be removed");
|
||||
T::DbWeight::get().reads(1)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "try-runtime")]
|
||||
fn post_upgrade(_state: Vec<u8>) -> Result<(), sp_runtime::TryRuntimeError> {
|
||||
let onchain_version = Pallet::<T>::on_chain_storage_version();
|
||||
ensure!(onchain_version == 1, "assigned_slots::MigrateToV1 needs to be run");
|
||||
assert_eq!(<MaxPermanentSlots<T>>::get(), 100);
|
||||
assert_eq!(<MaxTemporarySlots<T>>::get(), 100);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
/// [`VersionUncheckedMigrateToV1`] wrapped in a
|
||||
/// [`frame_support::migrations::VersionedRuntimeUpgrade`], ensuring the migration is only
|
||||
/// performed when on-chain version is 0.
|
||||
#[cfg(feature = "experimental")]
|
||||
pub type VersionCheckedMigrateToV1<T> = frame_support::migrations::VersionedRuntimeUpgrade<
|
||||
0,
|
||||
1,
|
||||
MigrateToV1<T>,
|
||||
Pallet<T>,
|
||||
<T as frame_system::Config>::DbWeight,
|
||||
>;
|
||||
}
|
||||
+169
-33
@@ -23,10 +23,12 @@
|
||||
//! This pallet should not be used on a production relay chain,
|
||||
//! only on a test relay chain (e.g. Rococo).
|
||||
|
||||
pub mod benchmarking;
|
||||
pub mod migration;
|
||||
|
||||
use crate::{
|
||||
slots::{self, Pallet as Slots, WeightInfo},
|
||||
slots::{self, Pallet as Slots, WeightInfo as SlotsWeightInfo},
|
||||
traits::{LeaseError, Leaser, Registrar},
|
||||
MAXIMUM_BLOCK_WEIGHT,
|
||||
};
|
||||
use frame_support::{pallet_prelude::*, traits::Currency};
|
||||
use frame_system::pallet_prelude::*;
|
||||
@@ -41,6 +43,8 @@ use scale_info::TypeInfo;
|
||||
use sp_runtime::traits::{One, Saturating, Zero};
|
||||
use sp_std::prelude::*;
|
||||
|
||||
const LOG_TARGET: &str = "runtime::assigned_slots";
|
||||
|
||||
/// Lease period an assigned slot should start from (current, or next one).
|
||||
#[derive(Encode, Decode, Clone, Copy, Eq, PartialEq, RuntimeDebug, TypeInfo)]
|
||||
pub enum SlotLeasePeriodStart {
|
||||
@@ -67,6 +71,33 @@ pub struct ParachainTemporarySlot<AccountId, LeasePeriod> {
|
||||
pub lease_count: u32,
|
||||
}
|
||||
|
||||
pub trait WeightInfo {
|
||||
fn assign_perm_parachain_slot() -> Weight;
|
||||
fn assign_temp_parachain_slot() -> Weight;
|
||||
fn unassign_parachain_slot() -> Weight;
|
||||
fn set_max_permanent_slots() -> Weight;
|
||||
fn set_max_temporary_slots() -> Weight;
|
||||
}
|
||||
|
||||
pub struct TestWeightInfo;
|
||||
impl WeightInfo for TestWeightInfo {
|
||||
fn assign_perm_parachain_slot() -> Weight {
|
||||
Weight::zero()
|
||||
}
|
||||
fn assign_temp_parachain_slot() -> Weight {
|
||||
Weight::zero()
|
||||
}
|
||||
fn unassign_parachain_slot() -> Weight {
|
||||
Weight::zero()
|
||||
}
|
||||
fn set_max_permanent_slots() -> Weight {
|
||||
Weight::zero()
|
||||
}
|
||||
fn set_max_temporary_slots() -> Weight {
|
||||
Weight::zero()
|
||||
}
|
||||
}
|
||||
|
||||
type BalanceOf<T> = <<<T as Config>::Leaser as Leaser<BlockNumberFor<T>>>::Currency as Currency<
|
||||
<T as frame_system::Config>::AccountId,
|
||||
>>::Balance;
|
||||
@@ -76,7 +107,11 @@ type LeasePeriodOf<T> = <<T as Config>::Leaser as Leaser<BlockNumberFor<T>>>::Le
|
||||
pub mod pallet {
|
||||
use super::*;
|
||||
|
||||
/// The current storage version.
|
||||
const STORAGE_VERSION: StorageVersion = StorageVersion::new(1);
|
||||
|
||||
#[pallet::pallet]
|
||||
#[pallet::storage_version(STORAGE_VERSION)]
|
||||
pub struct Pallet<T>(_);
|
||||
|
||||
#[pallet::config]
|
||||
@@ -103,17 +138,12 @@ pub mod pallet {
|
||||
#[pallet::constant]
|
||||
type TemporarySlotLeasePeriodLength: Get<u32>;
|
||||
|
||||
/// The max number of permanent slots that can be assigned.
|
||||
#[pallet::constant]
|
||||
type MaxPermanentSlots: Get<u32>;
|
||||
|
||||
/// The max number of temporary slots that can be assigned.
|
||||
#[pallet::constant]
|
||||
type MaxTemporarySlots: Get<u32>;
|
||||
|
||||
/// The max number of temporary slots to be scheduled per lease periods.
|
||||
#[pallet::constant]
|
||||
type MaxTemporarySlotPerLeasePeriod: Get<u32>;
|
||||
|
||||
/// Weight Information for the Extrinsics in the Pallet
|
||||
type WeightInfo: WeightInfo;
|
||||
}
|
||||
|
||||
/// Assigned permanent slots, with their start lease period, and duration.
|
||||
@@ -148,13 +178,41 @@ pub mod pallet {
|
||||
#[pallet::getter(fn active_temporary_slot_count)]
|
||||
pub type ActiveTemporarySlotCount<T: Config> = StorageValue<_, u32, ValueQuery>;
|
||||
|
||||
/// The max number of temporary slots that can be assigned.
|
||||
#[pallet::storage]
|
||||
pub type MaxTemporarySlots<T: Config> = StorageValue<_, u32, ValueQuery>;
|
||||
|
||||
/// The max number of permanent slots that can be assigned.
|
||||
#[pallet::storage]
|
||||
pub type MaxPermanentSlots<T: Config> = StorageValue<_, u32, ValueQuery>;
|
||||
|
||||
#[pallet::genesis_config]
|
||||
#[derive(frame_support::DefaultNoBound)]
|
||||
pub struct GenesisConfig<T: Config> {
|
||||
pub max_temporary_slots: u32,
|
||||
pub max_permanent_slots: u32,
|
||||
pub _config: PhantomData<T>,
|
||||
}
|
||||
|
||||
#[pallet::genesis_build]
|
||||
impl<T: Config> BuildGenesisConfig for GenesisConfig<T> {
|
||||
fn build(&self) {
|
||||
<MaxPermanentSlots<T>>::put(&self.max_permanent_slots);
|
||||
<MaxTemporarySlots<T>>::put(&self.max_temporary_slots);
|
||||
}
|
||||
}
|
||||
|
||||
#[pallet::event]
|
||||
#[pallet::generate_deposit(pub(super) fn deposit_event)]
|
||||
pub enum Event<T: Config> {
|
||||
/// A para was assigned a permanent parachain slot
|
||||
/// A parachain was assigned a permanent parachain slot
|
||||
PermanentSlotAssigned(ParaId),
|
||||
/// A para was assigned a temporary parachain slot
|
||||
/// A parachain was assigned a temporary parachain slot
|
||||
TemporarySlotAssigned(ParaId),
|
||||
/// The maximum number of permanent slots has been changed
|
||||
MaxPermanentSlotsChanged { slots: u32 },
|
||||
/// The maximum number of temporary slots has been changed
|
||||
MaxTemporarySlotsChanged { slots: u32 },
|
||||
}
|
||||
|
||||
#[pallet::error]
|
||||
@@ -173,9 +231,9 @@ pub mod pallet {
|
||||
SlotNotAssigned,
|
||||
/// An ongoing lease already exists.
|
||||
OngoingLeaseExists,
|
||||
// Maximum number of permanent slots exceeded
|
||||
// The maximum number of permanent slots exceeded
|
||||
MaxPermanentSlotsExceeded,
|
||||
// Maximum number of temporary slots exceeded
|
||||
// The maximum number of temporary slots exceeded
|
||||
MaxTemporarySlotsExceeded,
|
||||
}
|
||||
|
||||
@@ -196,16 +254,15 @@ pub mod pallet {
|
||||
|
||||
#[pallet::call]
|
||||
impl<T: Config> Pallet<T> {
|
||||
// TODO: Benchmark this
|
||||
/// Assign a permanent parachain slot and immediately create a lease for it.
|
||||
#[pallet::call_index(0)]
|
||||
#[pallet::weight(((MAXIMUM_BLOCK_WEIGHT / 10) as Weight, DispatchClass::Operational))]
|
||||
#[pallet::weight((<T as Config>::WeightInfo::assign_perm_parachain_slot(), DispatchClass::Operational))]
|
||||
pub fn assign_perm_parachain_slot(origin: OriginFor<T>, id: ParaId) -> DispatchResult {
|
||||
T::AssignSlotOrigin::ensure_origin(origin)?;
|
||||
|
||||
let manager = T::Registrar::manager_of(id).ok_or(Error::<T>::ParaDoesntExist)?;
|
||||
|
||||
ensure!(T::Registrar::is_parathread(id), Error::<T>::NotParathread,);
|
||||
ensure!(T::Registrar::is_parathread(id), Error::<T>::NotParathread);
|
||||
|
||||
ensure!(
|
||||
!Self::has_permanent_slot(id) && !Self::has_temporary_slot(id),
|
||||
@@ -227,7 +284,7 @@ pub mod pallet {
|
||||
);
|
||||
|
||||
ensure!(
|
||||
PermanentSlotCount::<T>::get() < T::MaxPermanentSlots::get(),
|
||||
PermanentSlotCount::<T>::get() < MaxPermanentSlots::<T>::get(),
|
||||
Error::<T>::MaxPermanentSlotsExceeded
|
||||
);
|
||||
|
||||
@@ -253,12 +310,11 @@ pub mod pallet {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// TODO: Benchmark this
|
||||
/// Assign a temporary parachain slot. The function tries to create a lease for it
|
||||
/// immediately if `SlotLeasePeriodStart::Current` is specified, and if the number
|
||||
/// of currently active temporary slots is below `MaxTemporarySlotPerLeasePeriod`.
|
||||
#[pallet::call_index(1)]
|
||||
#[pallet::weight(((MAXIMUM_BLOCK_WEIGHT / 10) as Weight, DispatchClass::Operational))]
|
||||
#[pallet::weight((<T as Config>::WeightInfo::assign_temp_parachain_slot(), DispatchClass::Operational))]
|
||||
pub fn assign_temp_parachain_slot(
|
||||
origin: OriginFor<T>,
|
||||
id: ParaId,
|
||||
@@ -290,7 +346,7 @@ pub mod pallet {
|
||||
);
|
||||
|
||||
ensure!(
|
||||
TemporarySlotCount::<T>::get() < T::MaxTemporarySlots::get(),
|
||||
TemporarySlotCount::<T>::get() < MaxTemporarySlots::<T>::get(),
|
||||
Error::<T>::MaxTemporarySlotsExceeded
|
||||
);
|
||||
|
||||
@@ -324,9 +380,12 @@ pub mod pallet {
|
||||
// Treat failed lease creation as warning .. slot will be allocated a lease
|
||||
// in a subsequent lease period by the `allocate_temporary_slot_leases`
|
||||
// function.
|
||||
log::warn!(target: "assigned_slots",
|
||||
log::warn!(
|
||||
target: LOG_TARGET,
|
||||
"Failed to allocate a temp slot for para {:?} at period {:?}: {:?}",
|
||||
id, current_lease_period, err
|
||||
id,
|
||||
current_lease_period,
|
||||
err
|
||||
);
|
||||
},
|
||||
}
|
||||
@@ -340,10 +399,9 @@ pub mod pallet {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// TODO: Benchmark this
|
||||
/// Unassign a permanent or temporary parachain slot
|
||||
#[pallet::call_index(2)]
|
||||
#[pallet::weight(((MAXIMUM_BLOCK_WEIGHT / 10) as Weight, DispatchClass::Operational))]
|
||||
#[pallet::weight((<T as Config>::WeightInfo::unassign_parachain_slot(), DispatchClass::Operational))]
|
||||
pub fn unassign_parachain_slot(origin: OriginFor<T>, id: ParaId) -> DispatchResult {
|
||||
T::AssignSlotOrigin::ensure_origin(origin.clone())?;
|
||||
|
||||
@@ -377,15 +435,42 @@ pub mod pallet {
|
||||
// Treat failed downgrade as warning .. slot lease has been cleared,
|
||||
// so the parachain will be downgraded anyway by the slots pallet
|
||||
// at the end of the lease period .
|
||||
log::warn!(target: "assigned_slots",
|
||||
log::warn!(
|
||||
target: LOG_TARGET,
|
||||
"Failed to downgrade parachain {:?} at period {:?}: {:?}",
|
||||
id, Self::current_lease_period_index(), err
|
||||
id,
|
||||
Self::current_lease_period_index(),
|
||||
err
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Sets the storage value [`MaxPermanentSlots`].
|
||||
#[pallet::call_index(3)]
|
||||
#[pallet::weight((<T as Config>::WeightInfo::set_max_permanent_slots(), DispatchClass::Operational))]
|
||||
pub fn set_max_permanent_slots(origin: OriginFor<T>, slots: u32) -> DispatchResult {
|
||||
ensure_root(origin)?;
|
||||
|
||||
<MaxPermanentSlots<T>>::put(slots);
|
||||
|
||||
Self::deposit_event(Event::<T>::MaxPermanentSlotsChanged { slots });
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Sets the storage value [`MaxTemporarySlots`].
|
||||
#[pallet::call_index(4)]
|
||||
#[pallet::weight((<T as Config>::WeightInfo::set_max_temporary_slots(), DispatchClass::Operational))]
|
||||
pub fn set_max_temporary_slots(origin: OriginFor<T>, slots: u32) -> DispatchResult {
|
||||
ensure_root(origin)?;
|
||||
|
||||
<MaxTemporarySlots<T>>::put(slots);
|
||||
|
||||
Self::deposit_event(Event::<T>::MaxTemporarySlotsChanged { slots });
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -530,9 +615,11 @@ impl<T: Config> Pallet<T> {
|
||||
// Note: leases that have ended in previous lease period, should have been cleaned in slots
|
||||
// pallet.
|
||||
if let Err(err) = Self::allocate_temporary_slot_leases(lease_period_index) {
|
||||
log::error!(target: "assigned_slots",
|
||||
log::error!(
|
||||
target: LOG_TARGET,
|
||||
"Allocating slots failed for lease period {:?}, with: {:?}",
|
||||
lease_period_index, err
|
||||
lease_period_index,
|
||||
err
|
||||
);
|
||||
}
|
||||
<T as slots::Config>::WeightInfo::force_lease() *
|
||||
@@ -673,8 +760,6 @@ mod tests {
|
||||
parameter_types! {
|
||||
pub const PermanentSlotLeasePeriodLength: u32 = 3;
|
||||
pub const TemporarySlotLeasePeriodLength: u32 = 2;
|
||||
pub const MaxPermanentSlots: u32 = 2;
|
||||
pub const MaxTemporarySlots: u32 = 6;
|
||||
pub const MaxTemporarySlotPerLeasePeriod: u32 = 2;
|
||||
}
|
||||
|
||||
@@ -684,9 +769,8 @@ mod tests {
|
||||
type Leaser = Slots;
|
||||
type PermanentSlotLeasePeriodLength = PermanentSlotLeasePeriodLength;
|
||||
type TemporarySlotLeasePeriodLength = TemporarySlotLeasePeriodLength;
|
||||
type MaxPermanentSlots = MaxPermanentSlots;
|
||||
type MaxTemporarySlots = MaxTemporarySlots;
|
||||
type MaxTemporarySlotPerLeasePeriod = MaxTemporarySlotPerLeasePeriod;
|
||||
type WeightInfo = crate::assigned_slots::TestWeightInfo;
|
||||
}
|
||||
|
||||
// This function basically just builds a genesis storage key/value store according to
|
||||
@@ -698,6 +782,15 @@ mod tests {
|
||||
}
|
||||
.assimilate_storage(&mut t)
|
||||
.unwrap();
|
||||
|
||||
crate::assigned_slots::GenesisConfig::<Test> {
|
||||
max_temporary_slots: 6,
|
||||
max_permanent_slots: 2,
|
||||
_config: Default::default(),
|
||||
}
|
||||
.assimilate_storage(&mut t)
|
||||
.unwrap();
|
||||
|
||||
t.into()
|
||||
}
|
||||
|
||||
@@ -1324,4 +1417,47 @@ mod tests {
|
||||
assert_eq!(Slots::already_leased(ParaId::from(1_u32), 0, 1), false);
|
||||
});
|
||||
}
|
||||
#[test]
|
||||
fn set_max_permanent_slots_fails_for_no_root_origin() {
|
||||
new_test_ext().execute_with(|| {
|
||||
run_to_block(1);
|
||||
|
||||
assert_noop!(
|
||||
AssignedSlots::set_max_permanent_slots(RuntimeOrigin::signed(1), 5),
|
||||
BadOrigin
|
||||
);
|
||||
});
|
||||
}
|
||||
#[test]
|
||||
fn set_max_permanent_slots_succeeds() {
|
||||
new_test_ext().execute_with(|| {
|
||||
run_to_block(1);
|
||||
|
||||
assert_eq!(MaxPermanentSlots::<Test>::get(), 2);
|
||||
assert_ok!(AssignedSlots::set_max_permanent_slots(RuntimeOrigin::root(), 10),);
|
||||
assert_eq!(MaxPermanentSlots::<Test>::get(), 10);
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn set_max_temporary_slots_fails_for_no_root_origin() {
|
||||
new_test_ext().execute_with(|| {
|
||||
run_to_block(1);
|
||||
|
||||
assert_noop!(
|
||||
AssignedSlots::set_max_temporary_slots(RuntimeOrigin::signed(1), 5),
|
||||
BadOrigin
|
||||
);
|
||||
});
|
||||
}
|
||||
#[test]
|
||||
fn set_max_temporary_slots_succeeds() {
|
||||
new_test_ext().execute_with(|| {
|
||||
run_to_block(1);
|
||||
|
||||
assert_eq!(MaxTemporarySlots::<Test>::get(), 6);
|
||||
assert_ok!(AssignedSlots::set_max_temporary_slots(RuntimeOrigin::root(), 12),);
|
||||
assert_eq!(MaxTemporarySlots::<Test>::get(), 12);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -83,7 +83,7 @@ frame-try-runtime = { git = "https://github.com/paritytech/substrate", branch =
|
||||
frame-system-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, optional = true }
|
||||
hex-literal = { version = "0.4.1" }
|
||||
|
||||
runtime-common = { package = "polkadot-runtime-common", path = "../common", default-features = false }
|
||||
runtime-common = { package = "polkadot-runtime-common", path = "../common", default-features = false, features=["experimental"] }
|
||||
runtime-parachains = { package = "polkadot-runtime-parachains", path = "../parachains", default-features = false }
|
||||
primitives = { package = "polkadot-primitives", path = "../../primitives", default-features = false }
|
||||
polkadot-parachain = { path = "../../parachain", default-features = false }
|
||||
|
||||
@@ -1334,8 +1334,6 @@ impl paras_sudo_wrapper::Config for Runtime {}
|
||||
parameter_types! {
|
||||
pub const PermanentSlotLeasePeriodLength: u32 = 365;
|
||||
pub const TemporarySlotLeasePeriodLength: u32 = 5;
|
||||
pub const MaxPermanentSlots: u32 = 100;
|
||||
pub const MaxTemporarySlots: u32 = 100;
|
||||
pub const MaxTemporarySlotPerLeasePeriod: u32 = 5;
|
||||
}
|
||||
|
||||
@@ -1345,9 +1343,8 @@ impl assigned_slots::Config for Runtime {
|
||||
type Leaser = Slots;
|
||||
type PermanentSlotLeasePeriodLength = PermanentSlotLeasePeriodLength;
|
||||
type TemporarySlotLeasePeriodLength = TemporarySlotLeasePeriodLength;
|
||||
type MaxPermanentSlots = MaxPermanentSlots;
|
||||
type MaxTemporarySlots = MaxTemporarySlots;
|
||||
type MaxTemporarySlotPerLeasePeriod = MaxTemporarySlotPerLeasePeriod;
|
||||
type WeightInfo = weights::runtime_common_assigned_slots::WeightInfo<Runtime>;
|
||||
}
|
||||
|
||||
impl validator_manager::Config for Runtime {
|
||||
@@ -1471,7 +1468,7 @@ construct_runtime! {
|
||||
MmrLeaf: pallet_beefy_mmr::{Pallet, Storage} = 242,
|
||||
|
||||
ParasSudoWrapper: paras_sudo_wrapper::{Pallet, Call} = 250,
|
||||
AssignedSlots: assigned_slots::{Pallet, Call, Storage, Event<T>} = 251,
|
||||
AssignedSlots: assigned_slots::{Pallet, Call, Storage, Event<T>, Config<T>} = 251,
|
||||
|
||||
// Validator Manager pallet.
|
||||
ValidatorManager: validator_manager::{Pallet, Call, Storage, Event<T>} = 252,
|
||||
@@ -1526,6 +1523,7 @@ pub mod migrations {
|
||||
pallet_society::migrations::VersionCheckedMigrateToV2<Runtime, (), ()>,
|
||||
pallet_im_online::migration::v1::Migration<Runtime>,
|
||||
parachains_configuration::migration::v7::MigrateToV7<Runtime>,
|
||||
assigned_slots::migration::v1::VersionCheckedMigrateToV1<Runtime>,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1572,6 +1570,7 @@ mod benches {
|
||||
// Polkadot
|
||||
// NOTE: Make sure to prefix these with `runtime_common::` so
|
||||
// the that path resolves correctly in the generated file.
|
||||
[runtime_common::assigned_slots, AssignedSlots]
|
||||
[runtime_common::auctions, Auctions]
|
||||
[runtime_common::crowdloan, Crowdloan]
|
||||
[runtime_common::claims, Claims]
|
||||
|
||||
@@ -42,6 +42,7 @@ pub mod pallet_treasury;
|
||||
pub mod pallet_utility;
|
||||
pub mod pallet_vesting;
|
||||
pub mod pallet_xcm;
|
||||
pub mod runtime_common_assigned_slots;
|
||||
pub mod runtime_common_auctions;
|
||||
pub mod runtime_common_claims;
|
||||
pub mod runtime_common_crowdloan;
|
||||
|
||||
@@ -0,0 +1,151 @@
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// This file is part of Polkadot.
|
||||
|
||||
// Polkadot is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// Polkadot is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! Autogenerated weights for `runtime_common::assigned_slots`
|
||||
//!
|
||||
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
|
||||
//! DATE: 2023-08-07, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
|
||||
//! WORST CASE MAP SIZE: `1000000`
|
||||
//! HOSTNAME: `runner-ynta1nyy-project-163-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz`
|
||||
//! EXECUTION: ``, WASM-EXECUTION: `Compiled`, CHAIN: `Some("rococo-dev")`, DB CACHE: 1024
|
||||
|
||||
// Executed Command:
|
||||
// target/production/polkadot
|
||||
// benchmark
|
||||
// pallet
|
||||
// --steps=50
|
||||
// --repeat=20
|
||||
// --extrinsic=*
|
||||
// --wasm-execution=compiled
|
||||
// --heap-pages=4096
|
||||
// --json-file=/builds/parity/mirrors/polkadot/.git/.artifacts/bench.json
|
||||
// --pallet=runtime_common::assigned_slots
|
||||
// --chain=rococo-dev
|
||||
// --header=./file_header.txt
|
||||
// --output=./runtime/rococo/src/weights/
|
||||
|
||||
#![cfg_attr(rustfmt, rustfmt_skip)]
|
||||
#![allow(unused_parens)]
|
||||
#![allow(unused_imports)]
|
||||
#![allow(missing_docs)]
|
||||
|
||||
use frame_support::{traits::Get, weights::Weight};
|
||||
use core::marker::PhantomData;
|
||||
|
||||
/// Weight functions for `runtime_common::assigned_slots`.
|
||||
pub struct WeightInfo<T>(PhantomData<T>);
|
||||
impl<T: frame_system::Config> runtime_common::assigned_slots::WeightInfo for WeightInfo<T> {
|
||||
/// Storage: `Registrar::Paras` (r:1 w:1)
|
||||
/// Proof: `Registrar::Paras` (`max_values`: None, `max_size`: None, mode: `Measured`)
|
||||
/// Storage: `Paras::ParaLifecycles` (r:1 w:1)
|
||||
/// Proof: `Paras::ParaLifecycles` (`max_values`: None, `max_size`: None, mode: `Measured`)
|
||||
/// Storage: `AssignedSlots::PermanentSlots` (r:1 w:1)
|
||||
/// Proof: `AssignedSlots::PermanentSlots` (`max_values`: None, `max_size`: Some(20), added: 2495, mode: `MaxEncodedLen`)
|
||||
/// Storage: `AssignedSlots::TemporarySlots` (r:1 w:0)
|
||||
/// Proof: `AssignedSlots::TemporarySlots` (`max_values`: None, `max_size`: Some(61), added: 2536, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Slots::Leases` (r:1 w:1)
|
||||
/// Proof: `Slots::Leases` (`max_values`: None, `max_size`: None, mode: `Measured`)
|
||||
/// Storage: `AssignedSlots::PermanentSlotCount` (r:1 w:1)
|
||||
/// Proof: `AssignedSlots::PermanentSlotCount` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
|
||||
/// Storage: `AssignedSlots::MaxPermanentSlots` (r:1 w:0)
|
||||
/// Proof: `AssignedSlots::MaxPermanentSlots` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
|
||||
/// Storage: `ParasShared::CurrentSessionIndex` (r:1 w:0)
|
||||
/// Proof: `ParasShared::CurrentSessionIndex` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
|
||||
/// Storage: `Paras::ActionsQueue` (r:1 w:1)
|
||||
/// Proof: `Paras::ActionsQueue` (`max_values`: None, `max_size`: None, mode: `Measured`)
|
||||
fn assign_perm_parachain_slot() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `673`
|
||||
// Estimated: `4138`
|
||||
// Minimum execution time: 84_646_000 picoseconds.
|
||||
Weight::from_parts(91_791_000, 0)
|
||||
.saturating_add(Weight::from_parts(0, 4138))
|
||||
.saturating_add(T::DbWeight::get().reads(9))
|
||||
.saturating_add(T::DbWeight::get().writes(6))
|
||||
}
|
||||
/// Storage: `Registrar::Paras` (r:1 w:1)
|
||||
/// Proof: `Registrar::Paras` (`max_values`: None, `max_size`: None, mode: `Measured`)
|
||||
/// Storage: `Paras::ParaLifecycles` (r:1 w:1)
|
||||
/// Proof: `Paras::ParaLifecycles` (`max_values`: None, `max_size`: None, mode: `Measured`)
|
||||
/// Storage: `AssignedSlots::PermanentSlots` (r:1 w:0)
|
||||
/// Proof: `AssignedSlots::PermanentSlots` (`max_values`: None, `max_size`: Some(20), added: 2495, mode: `MaxEncodedLen`)
|
||||
/// Storage: `AssignedSlots::TemporarySlots` (r:1 w:1)
|
||||
/// Proof: `AssignedSlots::TemporarySlots` (`max_values`: None, `max_size`: Some(61), added: 2536, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Slots::Leases` (r:1 w:1)
|
||||
/// Proof: `Slots::Leases` (`max_values`: None, `max_size`: None, mode: `Measured`)
|
||||
/// Storage: `AssignedSlots::TemporarySlotCount` (r:1 w:1)
|
||||
/// Proof: `AssignedSlots::TemporarySlotCount` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
|
||||
/// Storage: `AssignedSlots::MaxTemporarySlots` (r:1 w:0)
|
||||
/// Proof: `AssignedSlots::MaxTemporarySlots` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
|
||||
/// Storage: `AssignedSlots::ActiveTemporarySlotCount` (r:1 w:1)
|
||||
/// Proof: `AssignedSlots::ActiveTemporarySlotCount` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
|
||||
/// Storage: `ParasShared::CurrentSessionIndex` (r:1 w:0)
|
||||
/// Proof: `ParasShared::CurrentSessionIndex` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
|
||||
/// Storage: `Paras::ActionsQueue` (r:1 w:1)
|
||||
/// Proof: `Paras::ActionsQueue` (`max_values`: None, `max_size`: None, mode: `Measured`)
|
||||
fn assign_temp_parachain_slot() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `673`
|
||||
// Estimated: `4138`
|
||||
// Minimum execution time: 68_091_000 picoseconds.
|
||||
Weight::from_parts(77_310_000, 0)
|
||||
.saturating_add(Weight::from_parts(0, 4138))
|
||||
.saturating_add(T::DbWeight::get().reads(10))
|
||||
.saturating_add(T::DbWeight::get().writes(7))
|
||||
}
|
||||
/// Storage: `AssignedSlots::PermanentSlots` (r:1 w:0)
|
||||
/// Proof: `AssignedSlots::PermanentSlots` (`max_values`: None, `max_size`: Some(20), added: 2495, mode: `MaxEncodedLen`)
|
||||
/// Storage: `AssignedSlots::TemporarySlots` (r:1 w:1)
|
||||
/// Proof: `AssignedSlots::TemporarySlots` (`max_values`: None, `max_size`: Some(61), added: 2536, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Paras::ParaLifecycles` (r:1 w:0)
|
||||
/// Proof: `Paras::ParaLifecycles` (`max_values`: None, `max_size`: None, mode: `Measured`)
|
||||
/// Storage: `Slots::Leases` (r:1 w:1)
|
||||
/// Proof: `Slots::Leases` (`max_values`: None, `max_size`: None, mode: `Measured`)
|
||||
/// Storage: `AssignedSlots::TemporarySlotCount` (r:1 w:1)
|
||||
/// Proof: `AssignedSlots::TemporarySlotCount` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
|
||||
fn unassign_parachain_slot() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `823`
|
||||
// Estimated: `4288`
|
||||
// Minimum execution time: 38_081_000 picoseconds.
|
||||
Weight::from_parts(40_987_000, 0)
|
||||
.saturating_add(Weight::from_parts(0, 4288))
|
||||
.saturating_add(T::DbWeight::get().reads(5))
|
||||
.saturating_add(T::DbWeight::get().writes(3))
|
||||
}
|
||||
/// Storage: `AssignedSlots::MaxPermanentSlots` (r:0 w:1)
|
||||
/// Proof: `AssignedSlots::MaxPermanentSlots` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
|
||||
fn set_max_permanent_slots() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `0`
|
||||
// Estimated: `0`
|
||||
// Minimum execution time: 7_182_000 picoseconds.
|
||||
Weight::from_parts(7_437_000, 0)
|
||||
.saturating_add(Weight::from_parts(0, 0))
|
||||
.saturating_add(T::DbWeight::get().writes(1))
|
||||
}
|
||||
/// Storage: `AssignedSlots::MaxTemporarySlots` (r:0 w:1)
|
||||
/// Proof: `AssignedSlots::MaxTemporarySlots` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
|
||||
fn set_max_temporary_slots() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `0`
|
||||
// Estimated: `0`
|
||||
// Minimum execution time: 7_153_000 picoseconds.
|
||||
Weight::from_parts(7_456_000, 0)
|
||||
.saturating_add(Weight::from_parts(0, 0))
|
||||
.saturating_add(T::DbWeight::get().writes(1))
|
||||
}
|
||||
}
|
||||
@@ -89,7 +89,7 @@ pallet-offences-benchmarking = { git = "https://github.com/paritytech/substrate"
|
||||
pallet-session-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, optional = true }
|
||||
hex-literal = { version = "0.4.1", optional = true }
|
||||
|
||||
runtime-common = { package = "polkadot-runtime-common", path = "../common", default-features = false }
|
||||
runtime-common = { package = "polkadot-runtime-common", path = "../common", default-features = false, features=["experimental"] }
|
||||
primitives = { package = "polkadot-primitives", path = "../../primitives", default-features = false }
|
||||
polkadot-parachain = { path = "../../parachain", default-features = false }
|
||||
runtime-parachains = { package = "polkadot-runtime-parachains", path = "../parachains", default-features = false }
|
||||
|
||||
@@ -1007,8 +1007,6 @@ impl paras_sudo_wrapper::Config for Runtime {}
|
||||
parameter_types! {
|
||||
pub const PermanentSlotLeasePeriodLength: u32 = 26;
|
||||
pub const TemporarySlotLeasePeriodLength: u32 = 1;
|
||||
pub const MaxPermanentSlots: u32 = 5;
|
||||
pub const MaxTemporarySlots: u32 = 20;
|
||||
pub const MaxTemporarySlotPerLeasePeriod: u32 = 5;
|
||||
}
|
||||
|
||||
@@ -1018,9 +1016,8 @@ impl assigned_slots::Config for Runtime {
|
||||
type Leaser = Slots;
|
||||
type PermanentSlotLeasePeriodLength = PermanentSlotLeasePeriodLength;
|
||||
type TemporarySlotLeasePeriodLength = TemporarySlotLeasePeriodLength;
|
||||
type MaxPermanentSlots = MaxPermanentSlots;
|
||||
type MaxTemporarySlots = MaxTemporarySlots;
|
||||
type MaxTemporarySlotPerLeasePeriod = MaxTemporarySlotPerLeasePeriod;
|
||||
type WeightInfo = weights::runtime_common_assigned_slots::WeightInfo<Runtime>;
|
||||
}
|
||||
|
||||
impl parachains_disputes::Config for Runtime {
|
||||
@@ -1231,7 +1228,7 @@ construct_runtime! {
|
||||
ParasSudoWrapper: paras_sudo_wrapper::{Pallet, Call} = 62,
|
||||
Auctions: auctions::{Pallet, Call, Storage, Event<T>} = 63,
|
||||
Crowdloan: crowdloan::{Pallet, Call, Storage, Event<T>} = 64,
|
||||
AssignedSlots: assigned_slots::{Pallet, Call, Storage, Event<T>} = 65,
|
||||
AssignedSlots: assigned_slots::{Pallet, Call, Storage, Event<T>, Config<T>} = 65,
|
||||
|
||||
// Pallet for sending XCM.
|
||||
XcmPallet: pallet_xcm::{Pallet, Call, Storage, Event<T>, Origin, Config<T>} = 99,
|
||||
@@ -1285,6 +1282,7 @@ pub mod migrations {
|
||||
pub type Unreleased = (
|
||||
pallet_im_online::migration::v1::Migration<Runtime>,
|
||||
parachains_configuration::migration::v7::MigrateToV7<Runtime>,
|
||||
assigned_slots::migration::v1::VersionCheckedMigrateToV1<Runtime>,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1309,6 +1307,7 @@ mod benches {
|
||||
// Polkadot
|
||||
// NOTE: Make sure to prefix these with `runtime_common::` so
|
||||
// the that path resolves correctly in the generated file.
|
||||
[runtime_common::assigned_slots, AssignedSlots]
|
||||
[runtime_common::auctions, Auctions]
|
||||
[runtime_common::crowdloan, Crowdloan]
|
||||
[runtime_common::paras_registrar, Registrar]
|
||||
|
||||
@@ -37,6 +37,7 @@ pub mod pallet_timestamp;
|
||||
pub mod pallet_utility;
|
||||
pub mod pallet_vesting;
|
||||
pub mod pallet_xcm;
|
||||
pub mod runtime_common_assigned_slots;
|
||||
pub mod runtime_common_auctions;
|
||||
pub mod runtime_common_crowdloan;
|
||||
pub mod runtime_common_paras_registrar;
|
||||
|
||||
@@ -0,0 +1,151 @@
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// This file is part of Polkadot.
|
||||
|
||||
// Polkadot is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// Polkadot is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! Autogenerated weights for `runtime_common::assigned_slots`
|
||||
//!
|
||||
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
|
||||
//! DATE: 2023-08-07, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
|
||||
//! WORST CASE MAP SIZE: `1000000`
|
||||
//! HOSTNAME: `runner-ynta1nyy-project-163-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz`
|
||||
//! EXECUTION: ``, WASM-EXECUTION: `Compiled`, CHAIN: `Some("westend-dev")`, DB CACHE: 1024
|
||||
|
||||
// Executed Command:
|
||||
// target/production/polkadot
|
||||
// benchmark
|
||||
// pallet
|
||||
// --steps=50
|
||||
// --repeat=20
|
||||
// --extrinsic=*
|
||||
// --wasm-execution=compiled
|
||||
// --heap-pages=4096
|
||||
// --json-file=/builds/parity/mirrors/polkadot/.git/.artifacts/bench.json
|
||||
// --pallet=runtime_common::assigned_slots
|
||||
// --chain=westend-dev
|
||||
// --header=./file_header.txt
|
||||
// --output=./runtime/westend/src/weights/
|
||||
|
||||
#![cfg_attr(rustfmt, rustfmt_skip)]
|
||||
#![allow(unused_parens)]
|
||||
#![allow(unused_imports)]
|
||||
#![allow(missing_docs)]
|
||||
|
||||
use frame_support::{traits::Get, weights::Weight};
|
||||
use core::marker::PhantomData;
|
||||
|
||||
/// Weight functions for `runtime_common::assigned_slots`.
|
||||
pub struct WeightInfo<T>(PhantomData<T>);
|
||||
impl<T: frame_system::Config> runtime_common::assigned_slots::WeightInfo for WeightInfo<T> {
|
||||
/// Storage: `Registrar::Paras` (r:1 w:1)
|
||||
/// Proof: `Registrar::Paras` (`max_values`: None, `max_size`: None, mode: `Measured`)
|
||||
/// Storage: `Paras::ParaLifecycles` (r:1 w:1)
|
||||
/// Proof: `Paras::ParaLifecycles` (`max_values`: None, `max_size`: None, mode: `Measured`)
|
||||
/// Storage: `AssignedSlots::PermanentSlots` (r:1 w:1)
|
||||
/// Proof: `AssignedSlots::PermanentSlots` (`max_values`: None, `max_size`: Some(20), added: 2495, mode: `MaxEncodedLen`)
|
||||
/// Storage: `AssignedSlots::TemporarySlots` (r:1 w:0)
|
||||
/// Proof: `AssignedSlots::TemporarySlots` (`max_values`: None, `max_size`: Some(61), added: 2536, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Slots::Leases` (r:1 w:1)
|
||||
/// Proof: `Slots::Leases` (`max_values`: None, `max_size`: None, mode: `Measured`)
|
||||
/// Storage: `AssignedSlots::PermanentSlotCount` (r:1 w:1)
|
||||
/// Proof: `AssignedSlots::PermanentSlotCount` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
|
||||
/// Storage: `AssignedSlots::MaxPermanentSlots` (r:1 w:0)
|
||||
/// Proof: `AssignedSlots::MaxPermanentSlots` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
|
||||
/// Storage: `ParasShared::CurrentSessionIndex` (r:1 w:0)
|
||||
/// Proof: `ParasShared::CurrentSessionIndex` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
|
||||
/// Storage: `Paras::ActionsQueue` (r:1 w:1)
|
||||
/// Proof: `Paras::ActionsQueue` (`max_values`: None, `max_size`: None, mode: `Measured`)
|
||||
fn assign_perm_parachain_slot() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `640`
|
||||
// Estimated: `4105`
|
||||
// Minimum execution time: 74_788_000 picoseconds.
|
||||
Weight::from_parts(79_847_000, 0)
|
||||
.saturating_add(Weight::from_parts(0, 4105))
|
||||
.saturating_add(T::DbWeight::get().reads(9))
|
||||
.saturating_add(T::DbWeight::get().writes(6))
|
||||
}
|
||||
/// Storage: `Registrar::Paras` (r:1 w:1)
|
||||
/// Proof: `Registrar::Paras` (`max_values`: None, `max_size`: None, mode: `Measured`)
|
||||
/// Storage: `Paras::ParaLifecycles` (r:1 w:1)
|
||||
/// Proof: `Paras::ParaLifecycles` (`max_values`: None, `max_size`: None, mode: `Measured`)
|
||||
/// Storage: `AssignedSlots::PermanentSlots` (r:1 w:0)
|
||||
/// Proof: `AssignedSlots::PermanentSlots` (`max_values`: None, `max_size`: Some(20), added: 2495, mode: `MaxEncodedLen`)
|
||||
/// Storage: `AssignedSlots::TemporarySlots` (r:1 w:1)
|
||||
/// Proof: `AssignedSlots::TemporarySlots` (`max_values`: None, `max_size`: Some(61), added: 2536, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Slots::Leases` (r:1 w:1)
|
||||
/// Proof: `Slots::Leases` (`max_values`: None, `max_size`: None, mode: `Measured`)
|
||||
/// Storage: `AssignedSlots::TemporarySlotCount` (r:1 w:1)
|
||||
/// Proof: `AssignedSlots::TemporarySlotCount` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
|
||||
/// Storage: `AssignedSlots::MaxTemporarySlots` (r:1 w:0)
|
||||
/// Proof: `AssignedSlots::MaxTemporarySlots` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
|
||||
/// Storage: `AssignedSlots::ActiveTemporarySlotCount` (r:1 w:1)
|
||||
/// Proof: `AssignedSlots::ActiveTemporarySlotCount` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
|
||||
/// Storage: `ParasShared::CurrentSessionIndex` (r:1 w:0)
|
||||
/// Proof: `ParasShared::CurrentSessionIndex` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
|
||||
/// Storage: `Paras::ActionsQueue` (r:1 w:1)
|
||||
/// Proof: `Paras::ActionsQueue` (`max_values`: None, `max_size`: None, mode: `Measured`)
|
||||
fn assign_temp_parachain_slot() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `640`
|
||||
// Estimated: `4105`
|
||||
// Minimum execution time: 73_324_000 picoseconds.
|
||||
Weight::from_parts(77_993_000, 0)
|
||||
.saturating_add(Weight::from_parts(0, 4105))
|
||||
.saturating_add(T::DbWeight::get().reads(10))
|
||||
.saturating_add(T::DbWeight::get().writes(7))
|
||||
}
|
||||
/// Storage: `AssignedSlots::PermanentSlots` (r:1 w:0)
|
||||
/// Proof: `AssignedSlots::PermanentSlots` (`max_values`: None, `max_size`: Some(20), added: 2495, mode: `MaxEncodedLen`)
|
||||
/// Storage: `AssignedSlots::TemporarySlots` (r:1 w:1)
|
||||
/// Proof: `AssignedSlots::TemporarySlots` (`max_values`: None, `max_size`: Some(61), added: 2536, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Paras::ParaLifecycles` (r:1 w:0)
|
||||
/// Proof: `Paras::ParaLifecycles` (`max_values`: None, `max_size`: None, mode: `Measured`)
|
||||
/// Storage: `Slots::Leases` (r:1 w:1)
|
||||
/// Proof: `Slots::Leases` (`max_values`: None, `max_size`: None, mode: `Measured`)
|
||||
/// Storage: `AssignedSlots::TemporarySlotCount` (r:1 w:1)
|
||||
/// Proof: `AssignedSlots::TemporarySlotCount` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
|
||||
fn unassign_parachain_slot() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `592`
|
||||
// Estimated: `4057`
|
||||
// Minimum execution time: 32_796_000 picoseconds.
|
||||
Weight::from_parts(35_365_000, 0)
|
||||
.saturating_add(Weight::from_parts(0, 4057))
|
||||
.saturating_add(T::DbWeight::get().reads(5))
|
||||
.saturating_add(T::DbWeight::get().writes(3))
|
||||
}
|
||||
/// Storage: `AssignedSlots::MaxPermanentSlots` (r:0 w:1)
|
||||
/// Proof: `AssignedSlots::MaxPermanentSlots` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
|
||||
fn set_max_permanent_slots() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `0`
|
||||
// Estimated: `0`
|
||||
// Minimum execution time: 7_104_000 picoseconds.
|
||||
Weight::from_parts(7_358_000, 0)
|
||||
.saturating_add(Weight::from_parts(0, 0))
|
||||
.saturating_add(T::DbWeight::get().writes(1))
|
||||
}
|
||||
/// Storage: `AssignedSlots::MaxTemporarySlots` (r:0 w:1)
|
||||
/// Proof: `AssignedSlots::MaxTemporarySlots` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
|
||||
fn set_max_temporary_slots() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `0`
|
||||
// Estimated: `0`
|
||||
// Minimum execution time: 7_097_000 picoseconds.
|
||||
Weight::from_parts(7_429_000, 0)
|
||||
.saturating_add(Weight::from_parts(0, 0))
|
||||
.saturating_add(T::DbWeight::get().writes(1))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user