mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 04:01:02 +00:00
* Move finality Engine to finality_base folder * Define SubstrateFinalityPipeline Extract basic parts of SubstrateFinalitySyncPipeline into SubstrateFinalityPipeline * Add equivocation detection pipeline * Fix comment
This commit is contained in:
committed by
Bastian Köcher
parent
8ebef157a9
commit
9bfad80664
+7
-2
@@ -21,7 +21,8 @@ use crate::cli::bridge::{CliBridgeBase, RelayToRelayHeadersCliBridge};
|
||||
use async_trait::async_trait;
|
||||
use relay_substrate_client::{AccountKeyPairOf, Client};
|
||||
use substrate_relay_helper::{
|
||||
finality::{engine::Grandpa as GrandpaFinalityEngine, SubstrateFinalitySyncPipeline},
|
||||
finality::SubstrateFinalitySyncPipeline,
|
||||
finality_base::{engine::Grandpa as GrandpaFinalityEngine, SubstrateFinalityPipeline},
|
||||
TransactionParams,
|
||||
};
|
||||
|
||||
@@ -37,11 +38,15 @@ substrate_relay_helper::generate_submit_finality_proof_call_builder!(
|
||||
);
|
||||
|
||||
#[async_trait]
|
||||
impl SubstrateFinalitySyncPipeline for KusamaFinalityToBridgeHubPolkadot {
|
||||
impl SubstrateFinalityPipeline for KusamaFinalityToBridgeHubPolkadot {
|
||||
type SourceChain = relay_kusama_client::Kusama;
|
||||
type TargetChain = relay_bridge_hub_polkadot_client::BridgeHubPolkadot;
|
||||
|
||||
type FinalityEngine = GrandpaFinalityEngine<Self::SourceChain>;
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl SubstrateFinalitySyncPipeline for KusamaFinalityToBridgeHubPolkadot {
|
||||
type SubmitFinalityProofCallBuilder = KusamaFinalityToBridgeHubPolkadotCallBuilder;
|
||||
|
||||
async fn start_relay_guards(
|
||||
|
||||
+7
-2
@@ -21,7 +21,8 @@ use crate::cli::bridge::{CliBridgeBase, RelayToRelayHeadersCliBridge};
|
||||
use async_trait::async_trait;
|
||||
use relay_substrate_client::{AccountKeyPairOf, Client};
|
||||
use substrate_relay_helper::{
|
||||
finality::{engine::Grandpa as GrandpaFinalityEngine, SubstrateFinalitySyncPipeline},
|
||||
finality::SubstrateFinalitySyncPipeline,
|
||||
finality_base::{engine::Grandpa as GrandpaFinalityEngine, SubstrateFinalityPipeline},
|
||||
TransactionParams,
|
||||
};
|
||||
|
||||
@@ -37,11 +38,15 @@ substrate_relay_helper::generate_submit_finality_proof_call_builder!(
|
||||
);
|
||||
|
||||
#[async_trait]
|
||||
impl SubstrateFinalitySyncPipeline for PolkadotFinalityToBridgeHubKusama {
|
||||
impl SubstrateFinalityPipeline for PolkadotFinalityToBridgeHubKusama {
|
||||
type SourceChain = relay_polkadot_client::Polkadot;
|
||||
type TargetChain = relay_bridge_hub_kusama_client::BridgeHubKusama;
|
||||
|
||||
type FinalityEngine = GrandpaFinalityEngine<Self::SourceChain>;
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl SubstrateFinalitySyncPipeline for PolkadotFinalityToBridgeHubKusama {
|
||||
type SubmitFinalityProofCallBuilder = PolkadotFinalityToBridgeHubKusamaCallBuilder;
|
||||
|
||||
async fn start_relay_guards(
|
||||
|
||||
@@ -17,20 +17,23 @@
|
||||
//! Millau-to-Rialto headers sync entrypoint.
|
||||
|
||||
use crate::cli::bridge::{CliBridgeBase, MessagesCliBridge, RelayToRelayHeadersCliBridge};
|
||||
use substrate_relay_helper::finality::{
|
||||
engine::Grandpa as GrandpaFinalityEngine, DirectSubmitGrandpaFinalityProofCallBuilder,
|
||||
SubstrateFinalitySyncPipeline,
|
||||
use substrate_relay_helper::{
|
||||
finality::{DirectSubmitGrandpaFinalityProofCallBuilder, SubstrateFinalitySyncPipeline},
|
||||
finality_base::{engine::Grandpa as GrandpaFinalityEngine, SubstrateFinalityPipeline},
|
||||
};
|
||||
|
||||
/// Description of Millau -> Rialto finalized headers bridge.
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct MillauFinalityToRialto;
|
||||
|
||||
impl SubstrateFinalitySyncPipeline for MillauFinalityToRialto {
|
||||
impl SubstrateFinalityPipeline for MillauFinalityToRialto {
|
||||
type SourceChain = relay_millau_client::Millau;
|
||||
type TargetChain = relay_rialto_client::Rialto;
|
||||
|
||||
type FinalityEngine = GrandpaFinalityEngine<Self::SourceChain>;
|
||||
}
|
||||
|
||||
impl SubstrateFinalitySyncPipeline for MillauFinalityToRialto {
|
||||
type SubmitFinalityProofCallBuilder = DirectSubmitGrandpaFinalityProofCallBuilder<
|
||||
Self,
|
||||
rialto_runtime::Runtime,
|
||||
|
||||
@@ -17,20 +17,23 @@
|
||||
//! Rialto-to-Millau headers sync entrypoint.
|
||||
|
||||
use crate::cli::bridge::{CliBridgeBase, MessagesCliBridge, RelayToRelayHeadersCliBridge};
|
||||
use substrate_relay_helper::finality::{
|
||||
engine::Grandpa as GrandpaFinalityEngine, DirectSubmitGrandpaFinalityProofCallBuilder,
|
||||
SubstrateFinalitySyncPipeline,
|
||||
use substrate_relay_helper::{
|
||||
finality::{DirectSubmitGrandpaFinalityProofCallBuilder, SubstrateFinalitySyncPipeline},
|
||||
finality_base::{engine::Grandpa as GrandpaFinalityEngine, SubstrateFinalityPipeline},
|
||||
};
|
||||
|
||||
/// Description of Millau -> Rialto finalized headers bridge.
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct RialtoFinalityToMillau;
|
||||
|
||||
impl SubstrateFinalitySyncPipeline for RialtoFinalityToMillau {
|
||||
impl SubstrateFinalityPipeline for RialtoFinalityToMillau {
|
||||
type SourceChain = relay_rialto_client::Rialto;
|
||||
type TargetChain = relay_millau_client::Millau;
|
||||
|
||||
type FinalityEngine = GrandpaFinalityEngine<Self::SourceChain>;
|
||||
}
|
||||
|
||||
impl SubstrateFinalitySyncPipeline for RialtoFinalityToMillau {
|
||||
type SubmitFinalityProofCallBuilder = DirectSubmitGrandpaFinalityProofCallBuilder<
|
||||
Self,
|
||||
millau_runtime::Runtime,
|
||||
|
||||
+7
-3
@@ -35,8 +35,9 @@
|
||||
//! Millau-to-RialtoParachain headers sync entrypoint.
|
||||
|
||||
use crate::cli::bridge::{CliBridgeBase, MessagesCliBridge, RelayToRelayHeadersCliBridge};
|
||||
use substrate_relay_helper::finality::{
|
||||
engine::Grandpa as GrandpaFinalityEngine, SubstrateFinalitySyncPipeline,
|
||||
use substrate_relay_helper::{
|
||||
finality::SubstrateFinalitySyncPipeline,
|
||||
finality_base::{engine::Grandpa as GrandpaFinalityEngine, SubstrateFinalityPipeline},
|
||||
};
|
||||
|
||||
substrate_relay_helper::generate_submit_finality_proof_call_builder!(
|
||||
@@ -50,11 +51,14 @@ substrate_relay_helper::generate_submit_finality_proof_call_builder!(
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct MillauFinalityToRialtoParachain;
|
||||
|
||||
impl SubstrateFinalitySyncPipeline for MillauFinalityToRialtoParachain {
|
||||
impl SubstrateFinalityPipeline for MillauFinalityToRialtoParachain {
|
||||
type SourceChain = relay_millau_client::Millau;
|
||||
type TargetChain = relay_rialto_parachain_client::RialtoParachain;
|
||||
|
||||
type FinalityEngine = GrandpaFinalityEngine<Self::SourceChain>;
|
||||
}
|
||||
|
||||
impl SubstrateFinalitySyncPipeline for MillauFinalityToRialtoParachain {
|
||||
type SubmitFinalityProofCallBuilder = MillauFinalityToRialtoParachainCallBuilder;
|
||||
}
|
||||
|
||||
|
||||
+7
-2
@@ -21,7 +21,8 @@ use crate::cli::bridge::{CliBridgeBase, RelayToRelayHeadersCliBridge};
|
||||
use async_trait::async_trait;
|
||||
use relay_substrate_client::{AccountKeyPairOf, Client};
|
||||
use substrate_relay_helper::{
|
||||
finality::{engine::Grandpa as GrandpaFinalityEngine, SubstrateFinalitySyncPipeline},
|
||||
finality::SubstrateFinalitySyncPipeline,
|
||||
finality_base::{engine::Grandpa as GrandpaFinalityEngine, SubstrateFinalityPipeline},
|
||||
TransactionParams,
|
||||
};
|
||||
|
||||
@@ -37,11 +38,15 @@ substrate_relay_helper::generate_submit_finality_proof_call_builder!(
|
||||
);
|
||||
|
||||
#[async_trait]
|
||||
impl SubstrateFinalitySyncPipeline for RococoFinalityToBridgeHubWococo {
|
||||
impl SubstrateFinalityPipeline for RococoFinalityToBridgeHubWococo {
|
||||
type SourceChain = relay_rococo_client::Rococo;
|
||||
type TargetChain = relay_bridge_hub_wococo_client::BridgeHubWococo;
|
||||
|
||||
type FinalityEngine = GrandpaFinalityEngine<Self::SourceChain>;
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl SubstrateFinalitySyncPipeline for RococoFinalityToBridgeHubWococo {
|
||||
type SubmitFinalityProofCallBuilder = RococoFinalityToBridgeHubWococoCallBuilder;
|
||||
|
||||
async fn start_relay_guards(
|
||||
|
||||
+7
-2
@@ -21,7 +21,8 @@ use crate::cli::bridge::{CliBridgeBase, RelayToRelayHeadersCliBridge};
|
||||
use async_trait::async_trait;
|
||||
use relay_substrate_client::{AccountKeyPairOf, Client};
|
||||
use substrate_relay_helper::{
|
||||
finality::{engine::Grandpa as GrandpaFinalityEngine, SubstrateFinalitySyncPipeline},
|
||||
finality::SubstrateFinalitySyncPipeline,
|
||||
finality_base::{engine::Grandpa as GrandpaFinalityEngine, SubstrateFinalityPipeline},
|
||||
TransactionParams,
|
||||
};
|
||||
|
||||
@@ -37,11 +38,15 @@ substrate_relay_helper::generate_submit_finality_proof_call_builder!(
|
||||
);
|
||||
|
||||
#[async_trait]
|
||||
impl SubstrateFinalitySyncPipeline for WococoFinalityToBridgeHubRococo {
|
||||
impl SubstrateFinalityPipeline for WococoFinalityToBridgeHubRococo {
|
||||
type SourceChain = relay_wococo_client::Wococo;
|
||||
type TargetChain = relay_bridge_hub_rococo_client::BridgeHubRococo;
|
||||
|
||||
type FinalityEngine = GrandpaFinalityEngine<Self::SourceChain>;
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl SubstrateFinalitySyncPipeline for WococoFinalityToBridgeHubRococo {
|
||||
type SubmitFinalityProofCallBuilder = WococoFinalityToBridgeHubRococoCallBuilder;
|
||||
|
||||
async fn start_relay_guards(
|
||||
|
||||
+7
-4
@@ -17,20 +17,23 @@
|
||||
//! Westend-to-Millau headers sync entrypoint.
|
||||
|
||||
use crate::cli::bridge::{CliBridgeBase, RelayToRelayHeadersCliBridge};
|
||||
use substrate_relay_helper::finality::{
|
||||
engine::Grandpa as GrandpaFinalityEngine, DirectSubmitGrandpaFinalityProofCallBuilder,
|
||||
SubstrateFinalitySyncPipeline,
|
||||
use substrate_relay_helper::{
|
||||
finality::{DirectSubmitGrandpaFinalityProofCallBuilder, SubstrateFinalitySyncPipeline},
|
||||
finality_base::{engine::Grandpa as GrandpaFinalityEngine, SubstrateFinalityPipeline},
|
||||
};
|
||||
|
||||
/// Description of Westend -> Millau finalized headers bridge.
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct WestendFinalityToMillau;
|
||||
|
||||
impl SubstrateFinalitySyncPipeline for WestendFinalityToMillau {
|
||||
impl SubstrateFinalityPipeline for WestendFinalityToMillau {
|
||||
type SourceChain = relay_westend_client::Westend;
|
||||
type TargetChain = relay_millau_client::Millau;
|
||||
|
||||
type FinalityEngine = GrandpaFinalityEngine<Self::SourceChain>;
|
||||
}
|
||||
|
||||
impl SubstrateFinalitySyncPipeline for WestendFinalityToMillau {
|
||||
type SubmitFinalityProofCallBuilder = DirectSubmitGrandpaFinalityProofCallBuilder<
|
||||
Self,
|
||||
millau_runtime::Runtime,
|
||||
|
||||
@@ -41,7 +41,7 @@ use relay_substrate_client::{AccountKeyPairOf, Chain, UnsignedTransaction};
|
||||
use sp_core::Pair;
|
||||
use structopt::StructOpt;
|
||||
use strum::{EnumString, EnumVariantNames, VariantNames};
|
||||
use substrate_relay_helper::finality::engine::{Engine, Grandpa as GrandpaFinalityEngine};
|
||||
use substrate_relay_helper::finality_base::engine::{Engine, Grandpa as GrandpaFinalityEngine};
|
||||
|
||||
/// Initialize bridge pallet.
|
||||
#[derive(StructOpt)]
|
||||
|
||||
@@ -17,3 +17,4 @@ bp-runtime = { path = "../../primitives/runtime" }
|
||||
# Substrate Dependencies
|
||||
|
||||
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sp-session = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
|
||||
@@ -22,6 +22,7 @@ use relay_substrate_client::{
|
||||
Chain, ChainWithBalances, ChainWithGrandpa, RelayChain, UnderlyingChainProvider,
|
||||
};
|
||||
use sp_core::storage::StorageKey;
|
||||
use sp_session::MembershipProof;
|
||||
use std::time::Duration;
|
||||
|
||||
/// Kusama header id.
|
||||
@@ -52,6 +53,8 @@ impl Chain for Kusama {
|
||||
impl ChainWithGrandpa for Kusama {
|
||||
const SYNCED_HEADERS_GRANDPA_INFO_METHOD: &'static str =
|
||||
KUSAMA_SYNCED_HEADERS_GRANDPA_INFO_METHOD;
|
||||
|
||||
type KeyOwnerProof = MembershipProof;
|
||||
}
|
||||
|
||||
impl ChainWithBalances for Kusama {
|
||||
|
||||
@@ -24,3 +24,4 @@ frame-system = { git = "https://github.com/paritytech/substrate", branch = "mast
|
||||
pallet-transaction-payment = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sp-session = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
|
||||
@@ -27,6 +27,7 @@ use relay_substrate_client::{
|
||||
};
|
||||
use sp_core::{storage::StorageKey, Pair};
|
||||
use sp_runtime::{generic::SignedPayload, traits::IdentifyAccount};
|
||||
use sp_session::MembershipProof;
|
||||
use std::time::Duration;
|
||||
|
||||
/// Millau header id.
|
||||
@@ -69,6 +70,8 @@ impl Chain for Millau {
|
||||
impl ChainWithGrandpa for Millau {
|
||||
const SYNCED_HEADERS_GRANDPA_INFO_METHOD: &'static str =
|
||||
MILLAU_SYNCED_HEADERS_GRANDPA_INFO_METHOD;
|
||||
|
||||
type KeyOwnerProof = MembershipProof;
|
||||
}
|
||||
|
||||
impl ChainWithBalances for Millau {
|
||||
|
||||
@@ -17,3 +17,4 @@ bp-runtime = { path = "../../primitives/runtime" }
|
||||
# Substrate Dependencies
|
||||
|
||||
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sp-session = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
|
||||
@@ -22,6 +22,7 @@ use relay_substrate_client::{
|
||||
Chain, ChainWithBalances, ChainWithGrandpa, RelayChain, UnderlyingChainProvider,
|
||||
};
|
||||
use sp_core::storage::StorageKey;
|
||||
use sp_session::MembershipProof;
|
||||
use std::time::Duration;
|
||||
|
||||
/// Polkadot header id.
|
||||
@@ -52,6 +53,8 @@ impl Chain for Polkadot {
|
||||
impl ChainWithGrandpa for Polkadot {
|
||||
const SYNCED_HEADERS_GRANDPA_INFO_METHOD: &'static str =
|
||||
POLKADOT_SYNCED_HEADERS_GRANDPA_INFO_METHOD;
|
||||
|
||||
type KeyOwnerProof = MembershipProof;
|
||||
}
|
||||
|
||||
impl ChainWithBalances for Polkadot {
|
||||
|
||||
@@ -24,3 +24,4 @@ frame-support = { git = "https://github.com/paritytech/substrate", branch = "mas
|
||||
pallet-transaction-payment = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sp-session = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
|
||||
@@ -27,6 +27,7 @@ use relay_substrate_client::{
|
||||
};
|
||||
use sp_core::{storage::StorageKey, Pair};
|
||||
use sp_runtime::{generic::SignedPayload, traits::IdentifyAccount};
|
||||
use sp_session::MembershipProof;
|
||||
use std::time::Duration;
|
||||
|
||||
/// Rialto header id.
|
||||
@@ -54,6 +55,8 @@ impl Chain for Rialto {
|
||||
impl ChainWithGrandpa for Rialto {
|
||||
const SYNCED_HEADERS_GRANDPA_INFO_METHOD: &'static str =
|
||||
RIALTO_SYNCED_HEADERS_GRANDPA_INFO_METHOD;
|
||||
|
||||
type KeyOwnerProof = MembershipProof;
|
||||
}
|
||||
|
||||
impl RelayChain for Rialto {
|
||||
|
||||
@@ -17,3 +17,4 @@ bp-runtime = { path = "../../primitives/runtime" }
|
||||
# Substrate Dependencies
|
||||
|
||||
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sp-session = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
|
||||
@@ -22,6 +22,7 @@ use relay_substrate_client::{
|
||||
Chain, ChainWithBalances, ChainWithGrandpa, RelayChain, UnderlyingChainProvider,
|
||||
};
|
||||
use sp_core::storage::StorageKey;
|
||||
use sp_session::MembershipProof;
|
||||
use std::time::Duration;
|
||||
|
||||
/// Rococo header id.
|
||||
@@ -52,6 +53,8 @@ impl Chain for Rococo {
|
||||
impl ChainWithGrandpa for Rococo {
|
||||
const SYNCED_HEADERS_GRANDPA_INFO_METHOD: &'static str =
|
||||
ROCOCO_SYNCED_HEADERS_GRANDPA_INFO_METHOD;
|
||||
|
||||
type KeyOwnerProof = MembershipProof;
|
||||
}
|
||||
|
||||
impl ChainWithBalances for Rococo {
|
||||
|
||||
@@ -85,6 +85,9 @@ pub trait ChainWithGrandpa: Chain + UnderlyingChainWithGrandpaProvider {
|
||||
/// Keep in mind that this method is normally provided by the other chain, which is
|
||||
/// bridged with this chain.
|
||||
const SYNCED_HEADERS_GRANDPA_INFO_METHOD: &'static str;
|
||||
|
||||
/// The type of the key owner proof used by the grandpa engine.
|
||||
type KeyOwnerProof;
|
||||
}
|
||||
|
||||
/// Substrate-based parachain from minimal relay-client point of view.
|
||||
|
||||
@@ -17,3 +17,4 @@ bp-westend = { path = "../../primitives/chain-westend" }
|
||||
# Substrate Dependencies
|
||||
|
||||
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sp-session = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
|
||||
@@ -22,6 +22,7 @@ use relay_substrate_client::{
|
||||
Chain, ChainWithBalances, ChainWithGrandpa, RelayChain, UnderlyingChainProvider,
|
||||
};
|
||||
use sp_core::storage::StorageKey;
|
||||
use sp_session::MembershipProof;
|
||||
use std::time::Duration;
|
||||
|
||||
/// Westend header id.
|
||||
@@ -52,6 +53,8 @@ impl Chain for Westend {
|
||||
impl ChainWithGrandpa for Westend {
|
||||
const SYNCED_HEADERS_GRANDPA_INFO_METHOD: &'static str =
|
||||
WESTEND_SYNCED_HEADERS_GRANDPA_INFO_METHOD;
|
||||
|
||||
type KeyOwnerProof = MembershipProof;
|
||||
}
|
||||
|
||||
impl RelayChain for Westend {
|
||||
|
||||
@@ -16,3 +16,4 @@ bp-wococo = { path = "../../primitives/chain-wococo" }
|
||||
|
||||
# Substrate Dependencies
|
||||
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sp-session = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
|
||||
@@ -22,6 +22,7 @@ use relay_substrate_client::{
|
||||
Chain, ChainWithBalances, ChainWithGrandpa, RelayChain, UnderlyingChainProvider,
|
||||
};
|
||||
use sp_core::storage::StorageKey;
|
||||
use sp_session::MembershipProof;
|
||||
use std::time::Duration;
|
||||
|
||||
/// Wococo header id.
|
||||
@@ -52,6 +53,8 @@ impl Chain for Wococo {
|
||||
impl ChainWithGrandpa for Wococo {
|
||||
const SYNCED_HEADERS_GRANDPA_INFO_METHOD: &'static str =
|
||||
WOCOCO_SYNCED_HEADERS_GRANDPA_INFO_METHOD;
|
||||
|
||||
type KeyOwnerProof = MembershipProof;
|
||||
}
|
||||
|
||||
impl ChainWithBalances for Wococo {
|
||||
|
||||
@@ -43,6 +43,7 @@ bp-messages = { path = "../../primitives/messages" }
|
||||
frame-support = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
frame-system = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
pallet-grandpa = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sp-consensus-grandpa = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
// Copyright 2019-2023 Parity Technologies (UK) Ltd.
|
||||
// This file is part of Parity Bridges Common.
|
||||
|
||||
// Parity Bridges Common is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// Parity Bridges Common is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! Types and functions intended to ease adding of new Substrate -> Substrate
|
||||
//! equivocation detection pipelines.
|
||||
|
||||
use crate::finality_base::SubstrateFinalityPipeline;
|
||||
use std::marker::PhantomData;
|
||||
|
||||
use crate::finality_base::engine::Engine;
|
||||
use async_trait::async_trait;
|
||||
use bp_runtime::{BlockNumberOf, HashOf};
|
||||
use pallet_grandpa::{Call as GrandpaCall, Config as GrandpaConfig};
|
||||
use relay_substrate_client::CallOf;
|
||||
use sp_runtime::traits::{Block, Header};
|
||||
|
||||
/// Substrate -> Substrate equivocation detection pipeline.
|
||||
#[async_trait]
|
||||
pub trait SubstrateEquivocationDetectionPipeline: SubstrateFinalityPipeline {
|
||||
/// How the `report_equivocation` call is built ?
|
||||
type ReportEquivocationCallBuilder: ReportEquivocationCallBuilder<Self>;
|
||||
}
|
||||
|
||||
type EquivocationProofOf<P> = <<P as SubstrateFinalityPipeline>::FinalityEngine as Engine<
|
||||
<P as SubstrateFinalityPipeline>::SourceChain,
|
||||
>>::EquivocationProof;
|
||||
type KeyOwnerProofOf<P> = <<P as SubstrateFinalityPipeline>::FinalityEngine as Engine<
|
||||
<P as SubstrateFinalityPipeline>::SourceChain,
|
||||
>>::KeyOwnerProof;
|
||||
|
||||
/// Different ways of building `report_equivocation` calls.
|
||||
pub trait ReportEquivocationCallBuilder<P: SubstrateEquivocationDetectionPipeline> {
|
||||
/// Build a `report_equivocation` call to be executed on the source chain.
|
||||
fn build_report_equivocation_call(
|
||||
equivocation_proof: EquivocationProofOf<P>,
|
||||
key_owner_proof: KeyOwnerProofOf<P>,
|
||||
) -> CallOf<P::SourceChain>;
|
||||
}
|
||||
|
||||
/// Building the `report_equivocation` call when having direct access to the target chain runtime.
|
||||
pub struct DirectReportGrandpaEquivocationCallBuilder<P, R> {
|
||||
_phantom: PhantomData<(P, R)>,
|
||||
}
|
||||
|
||||
impl<P, R> ReportEquivocationCallBuilder<P> for DirectReportGrandpaEquivocationCallBuilder<P, R>
|
||||
where
|
||||
P: SubstrateEquivocationDetectionPipeline,
|
||||
P::FinalityEngine: Engine<
|
||||
P::SourceChain,
|
||||
EquivocationProof = sp_consensus_grandpa::EquivocationProof<
|
||||
HashOf<P::SourceChain>,
|
||||
BlockNumberOf<P::SourceChain>,
|
||||
>,
|
||||
>,
|
||||
R: frame_system::Config<Hash = HashOf<P::SourceChain>>
|
||||
+ GrandpaConfig<KeyOwnerProof = KeyOwnerProofOf<P>>,
|
||||
<R::Block as Block>::Header: Header<Number = BlockNumberOf<P::SourceChain>>,
|
||||
CallOf<P::SourceChain>: From<GrandpaCall<R>>,
|
||||
{
|
||||
fn build_report_equivocation_call(
|
||||
equivocation_proof: EquivocationProofOf<P>,
|
||||
key_owner_proof: KeyOwnerProofOf<P>,
|
||||
) -> CallOf<P::SourceChain> {
|
||||
GrandpaCall::<R>::report_equivocation {
|
||||
equivocation_proof: Box::new(equivocation_proof),
|
||||
key_owner_proof,
|
||||
}
|
||||
.into()
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,7 @@
|
||||
//! and authorities set from source to target chain. The finality sync starts
|
||||
//! with this header.
|
||||
|
||||
use crate::{error::Error, finality::engine::Engine};
|
||||
use crate::{error::Error, finality_base::engine::Engine};
|
||||
use sp_core::Pair;
|
||||
|
||||
use bp_runtime::HeaderIdOf;
|
||||
|
||||
@@ -19,26 +19,25 @@
|
||||
|
||||
use crate::{
|
||||
finality::{
|
||||
engine::Engine,
|
||||
source::{SubstrateFinalityProof, SubstrateFinalitySource},
|
||||
target::SubstrateFinalityTarget,
|
||||
},
|
||||
TransactionParams,
|
||||
};
|
||||
|
||||
use crate::finality_base::{engine::Engine, SubstrateFinalityPipeline};
|
||||
use async_trait::async_trait;
|
||||
use bp_header_chain::justification::GrandpaJustification;
|
||||
use finality_relay::FinalitySyncPipeline;
|
||||
use pallet_bridge_grandpa::{Call as BridgeGrandpaCall, Config as BridgeGrandpaConfig};
|
||||
use relay_substrate_client::{
|
||||
transaction_stall_timeout, AccountIdOf, AccountKeyPairOf, BlockNumberOf, CallOf, Chain,
|
||||
ChainWithTransactions, Client, HashOf, HeaderOf, SyncHeader,
|
||||
transaction_stall_timeout, AccountIdOf, AccountKeyPairOf, BlockNumberOf, CallOf, Chain, Client,
|
||||
HashOf, HeaderOf, SyncHeader,
|
||||
};
|
||||
use relay_utils::metrics::MetricsParams;
|
||||
use sp_core::Pair;
|
||||
use std::{fmt::Debug, marker::PhantomData};
|
||||
|
||||
pub mod engine;
|
||||
pub mod initialize;
|
||||
pub mod source;
|
||||
pub mod target;
|
||||
@@ -51,14 +50,7 @@ pub(crate) const RECENT_FINALITY_PROOFS_LIMIT: usize = 4096;
|
||||
|
||||
/// Substrate -> Substrate finality proofs synchronization pipeline.
|
||||
#[async_trait]
|
||||
pub trait SubstrateFinalitySyncPipeline: 'static + Clone + Debug + Send + Sync {
|
||||
/// Headers of this chain are submitted to the `TargetChain`.
|
||||
type SourceChain: Chain;
|
||||
/// Headers of the `SourceChain` are submitted to this chain.
|
||||
type TargetChain: ChainWithTransactions;
|
||||
|
||||
/// Finality engine.
|
||||
type FinalityEngine: Engine<Self::SourceChain>;
|
||||
pub trait SubstrateFinalitySyncPipeline: SubstrateFinalityPipeline {
|
||||
/// How submit finality proof call is built?
|
||||
type SubmitFinalityProofCallBuilder: SubmitFinalityProofCallBuilder<Self>;
|
||||
|
||||
@@ -144,16 +136,16 @@ macro_rules! generate_submit_finality_proof_call_builder {
|
||||
fn build_submit_finality_proof_call(
|
||||
header: relay_substrate_client::SyncHeader<
|
||||
relay_substrate_client::HeaderOf<
|
||||
<$pipeline as $crate::finality::SubstrateFinalitySyncPipeline>::SourceChain
|
||||
<$pipeline as $crate::finality_base::SubstrateFinalityPipeline>::SourceChain
|
||||
>
|
||||
>,
|
||||
proof: bp_header_chain::justification::GrandpaJustification<
|
||||
relay_substrate_client::HeaderOf<
|
||||
<$pipeline as $crate::finality::SubstrateFinalitySyncPipeline>::SourceChain
|
||||
<$pipeline as $crate::finality_base::SubstrateFinalityPipeline>::SourceChain
|
||||
>
|
||||
>,
|
||||
) -> relay_substrate_client::CallOf<
|
||||
<$pipeline as $crate::finality::SubstrateFinalitySyncPipeline>::TargetChain
|
||||
<$pipeline as $crate::finality_base::SubstrateFinalityPipeline>::TargetChain
|
||||
> {
|
||||
bp_runtime::paste::item! {
|
||||
$bridge_grandpa($submit_finality_proof {
|
||||
|
||||
@@ -16,8 +16,12 @@
|
||||
|
||||
//! Default generic implementation of finality source for basic Substrate client.
|
||||
|
||||
use crate::finality::{engine::Engine, FinalitySyncPipelineAdapter, SubstrateFinalitySyncPipeline};
|
||||
use crate::{
|
||||
finality::{FinalitySyncPipelineAdapter, SubstrateFinalitySyncPipeline},
|
||||
finality_base::engine::Engine,
|
||||
};
|
||||
|
||||
use crate::finality_base::SubstrateFinalityPipeline;
|
||||
use async_std::sync::{Arc, Mutex};
|
||||
use async_trait::async_trait;
|
||||
use bp_header_chain::FinalityProof;
|
||||
@@ -42,10 +46,9 @@ pub type SubstrateFinalityProofsStream<P> =
|
||||
Pin<Box<dyn Stream<Item = SubstrateFinalityProof<P>> + Send>>;
|
||||
|
||||
/// Substrate finality proof. Specific to the used `FinalityEngine`.
|
||||
pub type SubstrateFinalityProof<P> =
|
||||
<<P as SubstrateFinalitySyncPipeline>::FinalityEngine as Engine<
|
||||
<P as SubstrateFinalitySyncPipeline>::SourceChain,
|
||||
>>::FinalityProof;
|
||||
pub type SubstrateFinalityProof<P> = <<P as SubstrateFinalityPipeline>::FinalityEngine as Engine<
|
||||
<P as SubstrateFinalityPipeline>::SourceChain,
|
||||
>>::FinalityProof;
|
||||
|
||||
/// Substrate node as finality source.
|
||||
pub struct SubstrateFinalitySource<P: SubstrateFinalitySyncPipeline> {
|
||||
|
||||
@@ -18,9 +18,10 @@
|
||||
|
||||
use crate::{
|
||||
finality::{
|
||||
engine::Engine, source::SubstrateFinalityProof, FinalitySyncPipelineAdapter,
|
||||
source::SubstrateFinalityProof, FinalitySyncPipelineAdapter,
|
||||
SubmitFinalityProofCallBuilder, SubstrateFinalitySyncPipeline,
|
||||
},
|
||||
finality_base::engine::Engine,
|
||||
TransactionParams,
|
||||
};
|
||||
|
||||
|
||||
+6
@@ -47,6 +47,10 @@ pub trait Engine<C: Chain>: Send {
|
||||
type FinalityClient: SubstrateFinalityClient<C>;
|
||||
/// Type of finality proofs, used by consensus engine.
|
||||
type FinalityProof: FinalityProof<BlockNumberOf<C>> + Decode + Encode;
|
||||
/// The type of the equivocation proof used by the consensus engine.
|
||||
type EquivocationProof;
|
||||
/// The type of the key owner proof used by the consensus engine.
|
||||
type KeyOwnerProof;
|
||||
/// Type of bridge pallet initialization data.
|
||||
type InitializationData: std::fmt::Debug + Send + Sync + 'static;
|
||||
/// Type of bridge pallet operating mode.
|
||||
@@ -138,6 +142,8 @@ impl<C: ChainWithGrandpa> Engine<C> for Grandpa<C> {
|
||||
type ConsensusLogReader = GrandpaConsensusLogReader<<C::Header as Header>::Number>;
|
||||
type FinalityClient = SubstrateGrandpaFinalityClient;
|
||||
type FinalityProof = GrandpaJustification<HeaderOf<C>>;
|
||||
type EquivocationProof = sp_consensus_grandpa::EquivocationProof<HashOf<C>, BlockNumberOf<C>>;
|
||||
type KeyOwnerProof = C::KeyOwnerProof;
|
||||
type InitializationData = bp_header_chain::InitializationData<C::Header>;
|
||||
type OperatingMode = BasicOperatingMode;
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
// Copyright 2019-2023 Parity Technologies (UK) Ltd.
|
||||
// This file is part of Parity Bridges Common.
|
||||
|
||||
// Parity Bridges Common is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// Parity Bridges Common is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! Types and functions intended to ease adding of new Substrate -> Substrate
|
||||
//! finality pipelines.
|
||||
|
||||
pub mod engine;
|
||||
|
||||
use async_trait::async_trait;
|
||||
use relay_substrate_client::{Chain, ChainWithTransactions};
|
||||
use std::fmt::Debug;
|
||||
|
||||
/// Substrate -> Substrate finality related pipeline.
|
||||
#[async_trait]
|
||||
pub trait SubstrateFinalityPipeline: 'static + Clone + Debug + Send + Sync {
|
||||
/// Headers of this chain are submitted to the `TargetChain`.
|
||||
type SourceChain: Chain;
|
||||
/// Headers of the `SourceChain` are submitted to this chain.
|
||||
type TargetChain: ChainWithTransactions;
|
||||
/// Finality engine.
|
||||
type FinalityEngine: engine::Engine<Self::SourceChain>;
|
||||
}
|
||||
@@ -22,8 +22,10 @@ use relay_substrate_client::{Chain, ChainWithUtilityPallet, UtilityPallet};
|
||||
|
||||
use std::marker::PhantomData;
|
||||
|
||||
pub mod equivocation;
|
||||
pub mod error;
|
||||
pub mod finality;
|
||||
pub mod finality_base;
|
||||
pub mod messages_lane;
|
||||
pub mod messages_metrics;
|
||||
pub mod messages_source;
|
||||
|
||||
@@ -38,11 +38,11 @@ use relay_utils::{
|
||||
|
||||
use crate::{
|
||||
finality::{
|
||||
engine::Engine,
|
||||
source::{RequiredHeaderNumberRef, SubstrateFinalitySource},
|
||||
target::SubstrateFinalityTarget,
|
||||
SubstrateFinalitySyncPipeline, RECENT_FINALITY_PROOFS_LIMIT,
|
||||
},
|
||||
finality_base::engine::Engine,
|
||||
on_demand::OnDemandRelay,
|
||||
TransactionParams,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user