Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add migration to set the parameters for collator-selection #709

Merged
merged 2 commits into from Sep 15, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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(1000 * 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