Add equivocation detector crate and implement clients (#2348) (#2353)

* Split FinalitySyncPipeline and SourceClient

* Move some logic to finality_base

* Add empty equivocation detection clients

* Add equivocation reporting logic to the source client

* Use convenience trait for SubstrateFinalitySyncPipeline

* Define JustificationVerificationContext for GRANDPA

* Equivocation source client: finality_verification_context()

* Equivocation source client: synced_headers_finality_info()

* reuse HeaderFinalityInfo

* Define EquivocationsFinder

* Fix spellcheck

* Address review comments

* Avoid equivocations lookup errors
This commit is contained in:
Serban Iorga
2023-08-16 08:20:09 +03:00
committed by Bastian Köcher
parent 9bfad80664
commit 48cae06a77
35 changed files with 931 additions and 375 deletions
+4 -13
View File
@@ -20,34 +20,25 @@
//! to submit all source headers to the target node.
pub use crate::{
base::{FinalityPipeline, SourceClientBase},
finality_loop::{metrics_prefix, run, FinalitySyncParams, SourceClient, TargetClient},
sync_loop_metrics::SyncLoopMetrics,
};
use bp_header_chain::{ConsensusLogReader, FinalityProof};
use bp_header_chain::ConsensusLogReader;
use std::fmt::Debug;
mod base;
mod finality_loop;
mod finality_loop_tests;
mod sync_loop_metrics;
/// Finality proofs synchronization pipeline.
pub trait FinalitySyncPipeline: 'static + Clone + Debug + Send + Sync {
/// Name of the finality proofs source.
const SOURCE_NAME: &'static str;
/// Name of the finality proofs target.
const TARGET_NAME: &'static str;
/// Headers we're syncing are identified by this hash.
type Hash: Eq + Clone + Copy + Send + Sync + Debug;
/// Headers we're syncing are identified by this number.
type Number: relay_utils::BlockNumberBase;
pub trait FinalitySyncPipeline: FinalityPipeline {
/// A reader that can extract the consensus log from the header digest and interpret it.
type ConsensusLogReader: ConsensusLogReader;
/// Type of header that we're syncing.
type Header: SourceHeader<Self::Hash, Self::Number, Self::ConsensusLogReader>;
/// Finality proof type.
type FinalityProof: FinalityProof<Self::Number>;
}
/// Header that we're receiving from source node.