Crate sp_block_production_log

Source
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

§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. The API should use the same type CommitteeMember to represent the block author as was configured in pallet’s configuration.

An example for a Partner Chain using Aura consensus looks like this:

impl_runtime_apis! {
    impl BlockProductionLogApi<Block, CommitteeMember> for Runtime {
        fn get_author(slot: Slot) -> Option<CommitteeMember> {
            SessionCommitteeManagement::get_current_authority_round_robin(*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, ...))

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§

BlockAuthorInherentProvider
Inherent data provider providing the block author of the current block Type parameters:

Enums§

InherentError
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§

BlockProductionLogApi
Runtime API exposing data required for the BlockAuthorInherentProvider to operate. Type parameters: