Skip to content

Commit

Permalink
feat: add migration to set the parameters for collator-selection
Browse files Browse the repository at this point in the history
Signed-off-by: Gregory Hill <gregorydhill@outlook.com>
  • Loading branch information
gregdhill committed Sep 1, 2022
1 parent 239e6df commit 35b11d4
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions parachain/runtime/kintsugi/src/lib.rs
Expand Up @@ -263,6 +263,26 @@ parameter_types! {
pub const ExecutiveBody: BodyId = BodyId::Executive;
}

// Set the initial parameters for CollatorSelection.
pub struct SetCollatorSelection;
impl frame_support::traits::OnRuntimeUpgrade for SetCollatorSelection {
fn on_runtime_upgrade() -> frame_support::weights::Weight {
collator_selection::DesiredCandidates::<Runtime>::put(9);
collator_selection::CandidacyBond::<Runtime>::put(100 * KINT.one());
RocksDbWeight::get().writes(2)
}

#[cfg(feature = "try-runtime")]
fn pre_upgrade() -> Result<(), &'static str> {
Ok(())
}

#[cfg(feature = "try-runtime")]
fn post_upgrade() -> Result<(), &'static str> {
Ok(())
}
}

/// We allow root and the Relay Chain council to execute privileged collator selection operations.
pub type CollatorSelectionUpdateOrigin =
EnsureOneOf<EnsureRoot<AccountId>, EnsureXcm<IsMajorityOfBody<ParentLocation, ExecutiveBody>>>;
Expand Down Expand Up @@ -1115,8 +1135,14 @@ pub type UncheckedExtrinsic = generic::UncheckedExtrinsic<Address, Call, Signatu
/// Extrinsic type that has already been checked.
pub type CheckedExtrinsic = generic::CheckedExtrinsic<AccountId, Call, SignedExtra>;
/// Executive: handles dispatch to the various modules.
pub type Executive =
frame_executive::Executive<Runtime, Block, frame_system::ChainContext<Runtime>, Runtime, AllPalletsWithSystem, ()>;
pub type Executive = frame_executive::Executive<
Runtime,
Block,
frame_system::ChainContext<Runtime>,
Runtime,
AllPalletsWithSystem,
SetCollatorSelection,
>;

#[cfg(not(feature = "disable-runtime-api"))]
impl_runtime_apis! {
Expand Down

0 comments on commit 35b11d4

Please sign in to comment.