Backport: Implement basic equivocations detection loop (#2375)

* Implement basic equivocations detection loop (#2367)

* FinalityProofsBuf adjustments

- store a Vec<FinalityProof>
- transform prune `buf_limit` to Option

* FinalityProof: add target_header_hash()

* Target client: implement best_synced_header_hash()

* Implement first version of the equivocations detection loop

* Address code review comments

* Leftover

* polkadot-staging adjustments
This commit is contained in:
Serban Iorga
2023-08-23 19:31:17 +03:00
committed by Bastian Köcher
parent cc3bbc690b
commit 588508acd4
18 changed files with 572 additions and 79 deletions
+7 -2
View File
@@ -20,10 +20,11 @@ pub use bp_runtime::HeaderId;
pub use error::Error;
pub use relay_loop::{relay_loop, relay_metrics};
pub use sp_runtime::traits::{UniqueSaturatedFrom, UniqueSaturatedInto};
use std::fmt::Debug;
use async_trait::async_trait;
use backoff::{backoff::Backoff, ExponentialBackoff};
use futures::future::FutureExt;
use futures::future::{BoxFuture, FutureExt};
use std::time::Duration;
use thiserror::Error;
@@ -134,12 +135,16 @@ pub enum TrackedTransactionStatus<BlockId> {
#[async_trait]
pub trait TransactionTracker: Send {
/// Header id, used by the chain.
type HeaderId: Clone + Send;
type HeaderId: Clone + Debug + Send;
/// Wait until transaction is either finalized or invalidated/lost.
async fn wait(self) -> TrackedTransactionStatus<Self::HeaderId>;
}
/// Future associated with `TransactionTracker`, monitoring the transaction status.
pub type TrackedTransactionFuture<T> =
BoxFuture<'static, TrackedTransactionStatus<<T as TransactionTracker>::HeaderId>>;
/// Stringified error that may be either connection-related or not.
#[derive(Error, Debug)]
pub enum StringifiedMaybeConnectionError {