Rococo: ability to programatically assign slots to teams (#3943)

* Permanent & Temp parachain slots on Rococo - WIP

* Revert test change

* Revert test change

* Fix formatting

* Extract logic to separate assigned_slots pallet

* Formatting

* Parachain downgrade logic

* Pallet doc comment

* Revert unnecessary changes

* Fix few issues, tweak temp slots allocation logic; add a bunch of tests

* Address review comments; track active temp slots

* Update runtime/common/src/assigned_slots.rs

* Update runtime/common/src/assigned_slots.rs

* Remove assigned_slots calls from paras_sudo_wrapper

* Unassign is a perfectly valid verb

* Remove unneeded collect

* Update code following #3980

* Cleanup

* Generate storage info for pallet

* Address review comments

* Add ForceOrigin to slots pallet

* Track permanent slot duration in storage

* Fix tests build

Co-authored-by: Alexander Popiak <alexander.popiak@parity.io>
This commit is contained in:
Steve Degosserie
2021-12-02 22:23:45 +01:00
committed by GitHub
parent 89ccd18ccb
commit b3d08c0a8e
10 changed files with 1340 additions and 18 deletions
File diff suppressed because it is too large Load Diff
@@ -216,6 +216,7 @@ impl slots::Config for Test {
type Registrar = Registrar;
type LeasePeriod = LeasePeriod;
type LeaseOffset = LeaseOffset;
type ForceOrigin = EnsureRoot<AccountId>;
type WeightInfo = crate::slots::TestWeightInfo;
}
+1
View File
@@ -18,6 +18,7 @@
#![cfg_attr(not(feature = "std"), no_std)]
pub mod assigned_slots;
pub mod auctions;
pub mod claims;
pub mod crowdloan;
+9 -4
View File
@@ -87,6 +87,9 @@ pub mod pallet {
#[pallet::constant]
type LeaseOffset: Get<Self::BlockNumber>;
/// The origin which may forcibly create or clear leases. Root can always do this.
type ForceOrigin: EnsureOrigin<<Self as frame_system::Config>::Origin>;
/// Weight Information for the Extrinsics in the Pallet
type WeightInfo: WeightInfo;
}
@@ -159,7 +162,7 @@ pub mod pallet {
/// Just a connect into the `lease_out` call, in case Root wants to force some lease to happen
/// independently of any other on-chain mechanism to use it.
///
/// Can only be called by the Root origin.
/// The dispatch origin for this call must match `T::ForceOrigin`.
#[pallet::weight(T::WeightInfo::force_lease())]
pub fn force_lease(
origin: OriginFor<T>,
@@ -169,7 +172,7 @@ pub mod pallet {
period_begin: LeasePeriodOf<T>,
period_count: LeasePeriodOf<T>,
) -> DispatchResult {
ensure_root(origin)?;
T::ForceOrigin::ensure_origin(origin)?;
Self::lease_out(para, &leaser, amount, period_begin, period_count)
.map_err(|_| Error::<T>::LeaseError)?;
Ok(())
@@ -177,10 +180,10 @@ pub mod pallet {
/// Clear all leases for a Para Id, refunding any deposits back to the original owners.
///
/// Can only be called by the Root origin.
/// The dispatch origin for this call must match `T::ForceOrigin`.
#[pallet::weight(T::WeightInfo::clear_all_leases())]
pub fn clear_all_leases(origin: OriginFor<T>, para: ParaId) -> DispatchResult {
ensure_root(origin)?;
T::ForceOrigin::ensure_origin(origin)?;
let deposits = Self::all_deposits_held(para);
// Refund any deposits for these leases
@@ -495,6 +498,7 @@ mod tests {
use crate::{mock::TestRegistrar, slots};
use frame_support::{assert_noop, assert_ok, parameter_types};
use frame_system::EnsureRoot;
use pallet_balances;
use primitives::v1::{BlockNumber, Header};
use sp_core::H256;
@@ -572,6 +576,7 @@ mod tests {
type Registrar = TestRegistrar<Test>;
type LeasePeriod = LeasePeriod;
type LeaseOffset = LeaseOffset;
type ForceOrigin = EnsureRoot<Self::AccountId>;
type WeightInfo = crate::slots::TestWeightInfo;
}