Expand description
Primitives and support crate for pallet_block_production_log.
This crate defines the primitive types and the inherent data provider for the block production log feature.
§Usage
This crate supports operation of pallet_block_production_log.
Consult the pallet’s documentation on how to include it in the runtime.
§Adding to the node
§Defining the types
The feature requires two types to be defind by the chain builders in their code:
Author: the type representing the block author, as it’s configured in the feature’s palletMoment: a moment in time when the block was produced, which carries enough information to calculate the block’s author. Typcally, this type can be a timestamp, or a slot, depending on the consensus mechanism used, but can be a richer type if needed.
§Implementing the runtime API
The block production log feature requires BlockProductionLogApi to be implemented by the Partner Chain runtime so the current block author can be identified. The concrete implementation must use or match the mechanism of block author selection used by the particular Partner Chain’s consensus mechanism.
An example for a Partner Chain using Aura consensus looks like this:
impl_runtime_apis! {
impl BlockProductionLogApi<Block, CommitteeMember, Slot> for Runtime {
fn get_author(slot: Slot) -> Option<CommitteeMember> {
SessionCommitteeManagement::get_current_authority_round_robin(u64::from(*slot) as usize)
}
}
}using the pallet_session_committee_management::Pallet::get_current_authority_round_robin function
which performs the same round-robin author selection that Aura does internally.
§Adding the inherent data provider
The inherent data provider should be added to the node’s CreateInherentDataProviders implementation for
both proposal and validation of blocks. eg.:
// Create the inherent data provider. `slot` must be the slot number of the block currently being produced/verified
let block_author_idp = BlockAuthorInherentProvider::new(client.as_ref(), parent_hash, slot)?;
...
// Return the inherent data provider together with other IDPs
Ok((timestamp_idp, slot_idp, ..., block_author_idp, ...))Notice that the IDP must be passed the current Moment, which in this instance is Slot.
The inherent data provider created using BlockAuthorInherentProvider::new will check whether BlockProductionLogApi
is available in the runtime and will only provide inherent data if the API is present.
Structs§
- Block
Author Inherent Provider - Inherent data provider providing the block author of the current block Type parameters:
- Block
Production Inherent Data V1 - Current block producer data used as inherent data
Enums§
- Inherent
Error - Error type used for failing calls of the block production log feature’s inherent.
Constants§
- INHERENT_
IDENTIFIER - Inherent identifier used by the Block Production Log pallet
Traits§
- Block
Production LogApi - Runtime API exposing data required for the BlockAuthorInherentProvider to operate. Type parameters: