Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A0-1821: add substrate specific finalizer for sync protocol #854

Merged
merged 2 commits into from
Jan 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions finality-aleph/src/sync/substrate/finalizer.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
use aleph_primitives::{BlockNumber, ALEPH_ENGINE_ID};
use sc_client_api::{Backend, Finalizer as SubstrateFinalizer, HeaderBackend, LockImportRun};
use sp_blockchain::Error as ClientError;
use sp_runtime::traits::{Block as BlockT, Header as SubstrateHeader};

use crate::{
finalization::{AlephFinalizer, BlockFinalizer},
justification::versioned_encode,
sync::{substrate::Justification, Finalizer},
};

impl<B, BE, C> Finalizer<Justification<B::Header>> for AlephFinalizer<B, BE, C>
where
B: BlockT,
B::Header: SubstrateHeader<Number = BlockNumber>,
BE: Backend<B>,
C: HeaderBackend<B> + LockImportRun<B, BE> + SubstrateFinalizer<B, BE>,
{
type Error = ClientError;

fn finalize(&self, justification: Justification<B::Header>) -> Result<(), Self::Error> {
self.finalize_block(
justification.header.hash(),
*justification.header.number(),
Some((
ALEPH_ENGINE_ID,
versioned_encode(justification.raw_justification),
)),
)
}
}
1 change: 1 addition & 0 deletions finality-aleph/src/sync/substrate/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use crate::{
};

mod chain_status;
mod finalizer;
mod status_notifier;

#[derive(Clone, Debug, PartialEq, Eq)]
Expand Down