moonbeam
moonbeam copied to clipboard
[`Docs guide`] How to implement staking pallet
Moonbeam's pallet-staking seems to be fit in our use case as well. I would like to request you guys if you have some reference on how to implement pallet-staking in other cumulus based node as well. Currenlt we are using pallet-collator-selection
Here is my current understanding:
- Configure pallet-staking's Config in Runtime
- Add to construct runtime before session and authorship pallet
- Set
pallet_authorship::Config::EventHandler
toParachainStaking
was previously to ( CollatorSelection ) - Set
pallet_session::Config::SessionManager
toParachainStaking
was previously to ( CollatorSelection )
On step 3 & 4, I am getting these error:
349 | type EventHandler = ParachainStaking;
| ^^^^^^^^^^^^^^^^ the trait `EventHandler<sp_runtime::AccountId32, u32>` is not implemented for `pallet_parachain_staking::Pallet<Runtime>`
|
note: required by a bound in `pallet_authorship::Config::EventHandler`
--> /home/user/.cargo/git/checkouts/substrate-7e08433d4c370a21/814752f/frame/authorship/src/lib.rs:154:22
|
154 | type EventHandler: EventHandler<Self::AccountId, Self::BlockNumber>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `pallet_authorship::Config::EventHandler`
and
error[E0277]: the trait bound `pallet_parachain_staking::Pallet<Runtime>: pallet_session::SessionManager<sp_runtime::AccountId32>` is not satisfied
--> /home/user/Projects/DataHighway-Parachain/runtime/src/lib.rs:633:27
|
633 | type SessionManager = ParachainStaking;
| ^^^^^^^^^^^^^^^^ the trait `pallet_session::SessionManager<sp_runtime::AccountId32>` is not implemented for `pallet_parachain_staking::Pallet<Runtime>`
|
note: required by a bound in `pallet_session::Config::SessionManager`
--> /home/user/.cargo/git/checkouts/substrate-7e08433d4c370a21/814752f/frame/session/src/lib.rs:405:24
|
405 | type SessionManager: SessionManager<Self::ValidatorId>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `pallet_session::Config::SessionManager`
If there are any other option as well please suggest so.
PS: I was looking into the moonbeam's implementation as a reference but I am not able to figure out where and how are those two unsatisfied trait being implemented
PS: I was looking into the moonbeam's implementation as a reference but I am not able to figure out where and how are those two unsatisfied trait being implemented
Hello @sudipghimire533 , they are not implemented -- moonbeam runtimes do not have pallet_authorship nor pallet_session; it has substitutes:
(3) we use nimbus::pallet_author_inherent https://github.com/PureStake/nimbus/tree/main/pallets/author-inherent instead of pallet_authorship, so there is no implementation of pallet_authorship::EventHandler for ParachainStaking
We removed the nimbus_primitives::EventHandler
impl from ParachainStaking in #1701 so if you're using a recent version of ParachainStaking, it would not have this. Now ParachainStaking's Config has an associated type BlockAuthor
which gets the current block author from nimbus::pallet_author_inherent
storage and this is used in on_finalize
to track rewards.
(4) pallet_session::Config::SessionManager is not implemented by ParachainStaking because we use the AuthorMapping pallet instead https://github.com/PureStake/moonbeam/tree/master/pallets/author-mapping
We'd accept PRs to implement these traits but that won't guarantee everything works perfectly together. It's probably easier to just use nimbus::pallet_author_inherent
and pallet_author_mapping
in your runtime instead.