pub trait GrandpaApi<Block>: Core<Block>where
    Block: Block,{
    // Provided methods
    fn grandpa_authorities(
        &self,
        __runtime_api_at_param__: &BlockId<Block>
    ) -> Result<Vec<(Public, u64), Global>, ApiError> { ... }
    fn grandpa_authorities_with_context(
        &self,
        __runtime_api_at_param__: &BlockId<Block>,
        context: ExecutionContext
    ) -> Result<Vec<(Public, u64), Global>, ApiError> { ... }
    fn submit_report_equivocation_unsigned_extrinsic(
        &self,
        __runtime_api_at_param__: &BlockId<Block>,
        equivocation_proof: EquivocationProof<<Block as Block>::Hash, <<Block as Block>::Header as Header>::Number>,
        key_owner_proof: OpaqueKeyOwnershipProof
    ) -> Result<Option<()>, ApiError> { ... }
    fn submit_report_equivocation_unsigned_extrinsic_with_context(
        &self,
        __runtime_api_at_param__: &BlockId<Block>,
        context: ExecutionContext,
        equivocation_proof: EquivocationProof<<Block as Block>::Hash, <<Block as Block>::Header as Header>::Number>,
        key_owner_proof: OpaqueKeyOwnershipProof
    ) -> Result<Option<()>, ApiError> { ... }
    fn generate_key_ownership_proof(
        &self,
        __runtime_api_at_param__: &BlockId<Block>,
        set_id: u64,
        authority_id: Public
    ) -> Result<Option<OpaqueKeyOwnershipProof>, ApiError> { ... }
    fn generate_key_ownership_proof_with_context(
        &self,
        __runtime_api_at_param__: &BlockId<Block>,
        context: ExecutionContext,
        set_id: u64,
        authority_id: Public
    ) -> Result<Option<OpaqueKeyOwnershipProof>, ApiError> { ... }
    fn current_set_id(
        &self,
        __runtime_api_at_param__: &BlockId<Block>
    ) -> Result<u64, ApiError> { ... }
    fn current_set_id_with_context(
        &self,
        __runtime_api_at_param__: &BlockId<Block>,
        context: ExecutionContext
    ) -> Result<u64, ApiError> { ... }
}
Expand description

APIs for integrating the GRANDPA finality gadget into runtimes. This should be implemented on the runtime side.

This is primarily used for negotiating authority-set changes for the gadget. GRANDPA uses a signaling model of changing authority sets: changes should be signaled with a delay of N blocks, and then automatically applied in the runtime after those N blocks have passed.

The consensus protocol will coordinate the handoff externally.

Provided Methods§

source

fn grandpa_authorities( &self, __runtime_api_at_param__: &BlockId<Block> ) -> Result<Vec<(Public, u64), Global>, ApiError>

Get the current GRANDPA authorities and weights. This should not change except for when changes are scheduled and the corresponding delay has passed.

When called at block B, it will return the set of authorities that should be used to finalize descendants of this block (B+1, B+2, …). The block B itself is finalized by the authorities from block B-1.

source

fn grandpa_authorities_with_context( &self, __runtime_api_at_param__: &BlockId<Block>, context: ExecutionContext ) -> Result<Vec<(Public, u64), Global>, ApiError>

Get the current GRANDPA authorities and weights. This should not change except for when changes are scheduled and the corresponding delay has passed.

When called at block B, it will return the set of authorities that should be used to finalize descendants of this block (B+1, B+2, …). The block B itself is finalized by the authorities from block B-1.

source

fn submit_report_equivocation_unsigned_extrinsic( &self, __runtime_api_at_param__: &BlockId<Block>, equivocation_proof: EquivocationProof<<Block as Block>::Hash, <<Block as Block>::Header as Header>::Number>, key_owner_proof: OpaqueKeyOwnershipProof ) -> Result<Option<()>, ApiError>

Submits an unsigned extrinsic to report an equivocation. The caller must provide the equivocation proof and a key ownership proof (should be obtained using generate_key_ownership_proof). The extrinsic will be unsigned and should only be accepted for local authorship (not to be broadcast to the network). This method returns None when creation of the extrinsic fails, e.g. if equivocation reporting is disabled for the given runtime (i.e. this method is hardcoded to return None). Only useful in an offchain context.

source

fn submit_report_equivocation_unsigned_extrinsic_with_context( &self, __runtime_api_at_param__: &BlockId<Block>, context: ExecutionContext, equivocation_proof: EquivocationProof<<Block as Block>::Hash, <<Block as Block>::Header as Header>::Number>, key_owner_proof: OpaqueKeyOwnershipProof ) -> Result<Option<()>, ApiError>

Submits an unsigned extrinsic to report an equivocation. The caller must provide the equivocation proof and a key ownership proof (should be obtained using generate_key_ownership_proof). The extrinsic will be unsigned and should only be accepted for local authorship (not to be broadcast to the network). This method returns None when creation of the extrinsic fails, e.g. if equivocation reporting is disabled for the given runtime (i.e. this method is hardcoded to return None). Only useful in an offchain context.

source

fn generate_key_ownership_proof( &self, __runtime_api_at_param__: &BlockId<Block>, set_id: u64, authority_id: Public ) -> Result<Option<OpaqueKeyOwnershipProof>, ApiError>

Generates a proof of key ownership for the given authority in the given set. An example usage of this module is coupled with the session historical module to prove that a given authority key is tied to a given staking identity during a specific session. Proofs of key ownership are necessary for submitting equivocation reports. NOTE: even though the API takes a set_id as parameter the current implementations ignore this parameter and instead rely on this method being called at the correct block height, i.e. any point at which the given set id is live on-chain. Future implementations will instead use indexed data through an offchain worker, not requiring older states to be available.

source

fn generate_key_ownership_proof_with_context( &self, __runtime_api_at_param__: &BlockId<Block>, context: ExecutionContext, set_id: u64, authority_id: Public ) -> Result<Option<OpaqueKeyOwnershipProof>, ApiError>

Generates a proof of key ownership for the given authority in the given set. An example usage of this module is coupled with the session historical module to prove that a given authority key is tied to a given staking identity during a specific session. Proofs of key ownership are necessary for submitting equivocation reports. NOTE: even though the API takes a set_id as parameter the current implementations ignore this parameter and instead rely on this method being called at the correct block height, i.e. any point at which the given set id is live on-chain. Future implementations will instead use indexed data through an offchain worker, not requiring older states to be available.

source

fn current_set_id( &self, __runtime_api_at_param__: &BlockId<Block> ) -> Result<u64, ApiError>

Get current GRANDPA authority set id.

source

fn current_set_id_with_context( &self, __runtime_api_at_param__: &BlockId<Block>, context: ExecutionContext ) -> Result<u64, ApiError>

Get current GRANDPA authority set id.

Trait Implementations§

source§

impl<Block> RuntimeApiInfo for dyn GrandpaApi<Block> + 'staticwhere Block: Block,

source§

const ID: [u8; 8] = [237u8, 153u8, 197u8, 172u8, 178u8, 94u8, 237u8, 245u8]

The identifier of the runtime api.
source§

const VERSION: u32 = 3u32

The version of the runtime api.

Implementors§