referrerpolicy=no-referrer-when-downgrade
pub trait Engine<C: Chain>: Send {
    type ConsensusLogReader: ConsensusLogReader;
    type FinalityProof: FinalityProof<HashOf<C>, BlockNumberOf<C>> + Decode + Encode;
    type FinalityVerificationContext: Debug + Send;
    type EquivocationProof: Clone + Debug + Send + Sync;
    type EquivocationsFinder: FindEquivocations<Self::FinalityProof, Self::FinalityVerificationContext, Self::EquivocationProof>;
    type KeyOwnerProof: Send;
    type InitializationData: Debug + Send + Sync + 'static;
    type OperatingMode: OperatingMode + 'static;

    const ID: ConsensusEngineId;

    // Required methods
    fn is_initialized_key() -> StorageKey;
    fn pallet_operating_mode_key() -> StorageKey;
    fn source_finality_proofs<'life0, 'async_trait>(
        source_client: &'life0 (impl 'async_trait + Client<C>),
    ) -> Pin<Box<dyn Future<Output = Result<Subscription<Bytes>, SubstrateError>> + Send + 'async_trait>>
       where 'life0: 'async_trait;
    fn verify_and_optimize_proof<'life0, 'life1, 'life2, 'async_trait, TargetChain>(
        target_client: &'life0 (impl 'async_trait + Client<TargetChain>),
        header: &'life1 C::Header,
        proof: &'life2 mut Self::FinalityProof,
    ) -> Pin<Box<dyn Future<Output = Result<Self::FinalityVerificationContext, SubstrateError>> + Send + 'async_trait>>
       where TargetChain: 'async_trait + Chain,
             Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn check_max_expected_call_limits(
        header: &C::Header,
        proof: &Self::FinalityProof,
    ) -> SubmitFinalityProofCallExtras;
    fn prepare_initialization_data<'async_trait>(
        client: impl 'async_trait + Client<C>,
    ) -> Pin<Box<dyn Future<Output = Result<Self::InitializationData, Error<HashOf<C>, BlockNumberOf<C>>>> + Send + 'async_trait>>
       where Self: 'async_trait;
    fn finality_verification_context<'life0, 'async_trait, TargetChain>(
        target_client: &'life0 (impl 'async_trait + Client<TargetChain>),
        at: HashOf<TargetChain>,
    ) -> Pin<Box<dyn Future<Output = Result<Self::FinalityVerificationContext, SubstrateError>> + Send + 'async_trait>>
       where TargetChain: 'async_trait + Chain,
             Self: 'async_trait,
             'life0: 'async_trait;
    fn synced_headers_finality_info<'life0, 'async_trait, TargetChain>(
        target_client: &'life0 (impl 'async_trait + Client<TargetChain>),
        at: TargetChain::Hash,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<HeaderFinalityInfo<Self::FinalityProof, Self::FinalityVerificationContext>>, SubstrateError>> + Send + 'async_trait>>
       where TargetChain: 'async_trait + Chain,
             Self: 'async_trait,
             'life0: 'async_trait;
    fn generate_source_key_ownership_proof<'life0, 'life1, 'async_trait>(
        source_client: &'life0 (impl 'async_trait + Client<C>),
        at: C::Hash,
        equivocation: &'life1 Self::EquivocationProof,
    ) -> Pin<Box<dyn Future<Output = Result<Self::KeyOwnerProof, SubstrateError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;

    // Provided methods
    fn is_initialized<'life0, 'async_trait, TargetChain>(
        target_client: &'life0 (impl 'async_trait + Client<TargetChain>),
    ) -> Pin<Box<dyn Future<Output = Result<bool, SubstrateError>> + Send + 'async_trait>>
       where TargetChain: 'async_trait + Chain,
             Self: 'async_trait,
             'life0: 'async_trait { ... }
    fn is_halted<'life0, 'async_trait, TargetChain>(
        target_client: &'life0 (impl 'async_trait + Client<TargetChain>),
    ) -> Pin<Box<dyn Future<Output = Result<bool, SubstrateError>> + Send + 'async_trait>>
       where TargetChain: 'async_trait + Chain,
             Self: 'async_trait,
             'life0: 'async_trait { ... }
}
Expand description

Finality engine, used by the Substrate chain.

Required Associated Types§

source

type ConsensusLogReader: ConsensusLogReader

A reader that can extract the consensus log from the header digest and interpret it.

source

type FinalityProof: FinalityProof<HashOf<C>, BlockNumberOf<C>> + Decode + Encode

Type of finality proofs, used by consensus engine.

source

type FinalityVerificationContext: Debug + Send

The context needed for verifying finality proofs.

source

type EquivocationProof: Clone + Debug + Send + Sync

The type of the equivocation proof used by the consensus engine.

source

type EquivocationsFinder: FindEquivocations<Self::FinalityProof, Self::FinalityVerificationContext, Self::EquivocationProof>

The equivocations finder.

source

type KeyOwnerProof: Send

The type of the key owner proof used by the consensus engine.

source

type InitializationData: Debug + Send + Sync + 'static

Type of bridge pallet initialization data.

source

type OperatingMode: OperatingMode + 'static

Type of bridge pallet operating mode.

Required Associated Constants§

source

const ID: ConsensusEngineId

Unique consensus engine identifier.

Required Methods§

source

fn is_initialized_key() -> StorageKey

Returns storage at the bridged (target) chain that corresponds to some value that is missing from the storage until bridge pallet is initialized.

Note that we don’t care about type of the value - just if it present or not.

source

fn pallet_operating_mode_key() -> StorageKey

Returns storage key at the bridged (target) chain that corresponds to the variable that holds the operating mode of the pallet.

source

fn source_finality_proofs<'life0, 'async_trait>( source_client: &'life0 (impl 'async_trait + Client<C>), ) -> Pin<Box<dyn Future<Output = Result<Subscription<Bytes>, SubstrateError>> + Send + 'async_trait>>
where 'life0: 'async_trait,

A method to subscribe to encoded finality proofs, given source client.

source

fn verify_and_optimize_proof<'life0, 'life1, 'life2, 'async_trait, TargetChain>( target_client: &'life0 (impl 'async_trait + Client<TargetChain>), header: &'life1 C::Header, proof: &'life2 mut Self::FinalityProof, ) -> Pin<Box<dyn Future<Output = Result<Self::FinalityVerificationContext, SubstrateError>> + Send + 'async_trait>>
where TargetChain: 'async_trait + Chain, Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Verify and optimize finality proof before sending it to the target node.

Apart from optimization, we expect this method to perform all required checks that the header and proof are valid at the current state of the target chain.

source

fn check_max_expected_call_limits( header: &C::Header, proof: &Self::FinalityProof, ) -> SubmitFinalityProofCallExtras

Checks whether the given header and its finality proof fit the maximal expected call limits (size and weight).

source

fn prepare_initialization_data<'async_trait>( client: impl 'async_trait + Client<C>, ) -> Pin<Box<dyn Future<Output = Result<Self::InitializationData, Error<HashOf<C>, BlockNumberOf<C>>>> + Send + 'async_trait>>
where Self: 'async_trait,

Prepare initialization data for the finality bridge pallet.

source

fn finality_verification_context<'life0, 'async_trait, TargetChain>( target_client: &'life0 (impl 'async_trait + Client<TargetChain>), at: HashOf<TargetChain>, ) -> Pin<Box<dyn Future<Output = Result<Self::FinalityVerificationContext, SubstrateError>> + Send + 'async_trait>>
where TargetChain: 'async_trait + Chain, Self: 'async_trait, 'life0: 'async_trait,

Get the context needed for validating a finality proof.

source

fn synced_headers_finality_info<'life0, 'async_trait, TargetChain>( target_client: &'life0 (impl 'async_trait + Client<TargetChain>), at: TargetChain::Hash, ) -> Pin<Box<dyn Future<Output = Result<Vec<HeaderFinalityInfo<Self::FinalityProof, Self::FinalityVerificationContext>>, SubstrateError>> + Send + 'async_trait>>
where TargetChain: 'async_trait + Chain, Self: 'async_trait, 'life0: 'async_trait,

Returns the finality info associated to the source headers synced with the target at the provided block.

source

fn generate_source_key_ownership_proof<'life0, 'life1, 'async_trait>( source_client: &'life0 (impl 'async_trait + Client<C>), at: C::Hash, equivocation: &'life1 Self::EquivocationProof, ) -> Pin<Box<dyn Future<Output = Result<Self::KeyOwnerProof, SubstrateError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Generate key ownership proof for the provided equivocation.

Provided Methods§

source

fn is_initialized<'life0, 'async_trait, TargetChain>( target_client: &'life0 (impl 'async_trait + Client<TargetChain>), ) -> Pin<Box<dyn Future<Output = Result<bool, SubstrateError>> + Send + 'async_trait>>
where TargetChain: 'async_trait + Chain, Self: 'async_trait, 'life0: 'async_trait,

Returns Ok(true) if finality pallet at the bridged chain has already been initialized.

source

fn is_halted<'life0, 'async_trait, TargetChain>( target_client: &'life0 (impl 'async_trait + Client<TargetChain>), ) -> Pin<Box<dyn Future<Output = Result<bool, SubstrateError>> + Send + 'async_trait>>
where TargetChain: 'async_trait + Chain, Self: 'async_trait, 'life0: 'async_trait,

Returns Ok(true) if finality pallet at the bridged chain is halted.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<C: ChainWithGrandpa> Engine<C> for Grandpa<C>

source§

const ID: ConsensusEngineId = GRANDPA_ENGINE_ID

§

type ConsensusLogReader = GrandpaConsensusLogReader<<<C as Chain>::Header as Header>::Number>

§

type FinalityProof = GrandpaJustification<<C as Chain>::Header>

§

type FinalityVerificationContext = JustificationVerificationContext

§

type EquivocationProof = EquivocationProof<<C as Chain>::Hash, <C as Chain>::BlockNumber>

§

type EquivocationsFinder = GrandpaEquivocationsFinder<C>

§

type KeyOwnerProof = <C as ChainWithGrandpa>::KeyOwnerProof

§

type InitializationData = InitializationData<<C as Chain>::Header>

§

type OperatingMode = BasicOperatingMode