From 12ed0f4ffe4dcf3a8fe8928e3791141a110fad8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Molina=20Colmenero?= <jose@blockdeep.io> Date: Tue, 21 Jan 2025 10:49:09 +0100 Subject: [PATCH] Add an extra_constant to pallet-collator-selection (#7206) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Currently `pallet-collator-selection` does not expose a way to query the assigned pot account derived from the `PotId` configuration item. Without it, it is not possible to transfer the existential deposit to it. This PR addresses this issue by exposing an extra constant. --------- Co-authored-by: Bastian Köcher <git@kchr.de> --- cumulus/pallets/collator-selection/src/lib.rs | 13 +++++++++++++ prdoc/pr_7206.prdoc | 13 +++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 prdoc/pr_7206.prdoc diff --git a/cumulus/pallets/collator-selection/src/lib.rs b/cumulus/pallets/collator-selection/src/lib.rs index 9d7e62af3c6..34c6ca8b36e 100644 --- a/cumulus/pallets/collator-selection/src/lib.rs +++ b/cumulus/pallets/collator-selection/src/lib.rs @@ -150,22 +150,27 @@ pub mod pallet { type UpdateOrigin: EnsureOrigin<Self::RuntimeOrigin>; /// Account Identifier from which the internal Pot is generated. + #[pallet::constant] type PotId: Get<PalletId>; /// Maximum number of candidates that we should have. /// /// This does not take into account the invulnerables. + #[pallet::constant] type MaxCandidates: Get<u32>; /// Minimum number eligible collators. Should always be greater than zero. This includes /// Invulnerable collators. This ensures that there will always be one collator who can /// produce a block. + #[pallet::constant] type MinEligibleCollators: Get<u32>; /// Maximum number of invulnerables. + #[pallet::constant] type MaxInvulnerables: Get<u32>; // Will be kicked if block is not produced in threshold. + #[pallet::constant] type KickThreshold: Get<BlockNumberFor<Self>>; /// A stable ID for a validator. @@ -183,6 +188,14 @@ pub mod pallet { type WeightInfo: WeightInfo; } + #[pallet::extra_constants] + impl<T: Config> Pallet<T> { + /// Gets this pallet's derived pot account. + fn pot_account() -> T::AccountId { + Self::account_id() + } + } + /// Basic information about a collation candidate. #[derive( PartialEq, Eq, Clone, Encode, Decode, RuntimeDebug, scale_info::TypeInfo, MaxEncodedLen, diff --git a/prdoc/pr_7206.prdoc b/prdoc/pr_7206.prdoc new file mode 100644 index 00000000000..d605308ba54 --- /dev/null +++ b/prdoc/pr_7206.prdoc @@ -0,0 +1,13 @@ +# Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0 +# See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json + +title: "Add an extra_constant to pallet-collator-selection" + +doc: + - audience: Runtime Dev + description: | + - Allows to query collator-selection's pot account via extra constant. + +crates: + - name: pallet-collator-selection + bump: minor \ No newline at end of file -- GitLab