Skip to content

Commit

Permalink
Add subcommand for starting the equivocation detection loop
Browse files Browse the repository at this point in the history
  • Loading branch information
serban300 committed Aug 30, 2023
1 parent d6046bb commit 9713367
Show file tree
Hide file tree
Showing 23 changed files with 269 additions and 77 deletions.
20 changes: 20 additions & 0 deletions deployments/bridges/rialto-millau/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,26 @@ services:
depends_on:
- relay-millau-rialto

detect-millau-to-rialto-equivocations:
<<: *sub-bridge-relay
environment:
RUST_LOG: bridge=trace
entrypoint: /entrypoints/detect-millau-to-rialto-equivocations-entrypoint.sh
ports:
- "10517:9616"
depends_on:
- relay-millau-rialto

detect-rialto-to-millau-equivocations:
<<: *sub-bridge-relay
environment:
RUST_LOG: bridge=trace
entrypoint: /entrypoints/detect-rialto-to-millau-equivocations-entrypoint.sh
ports:
- "10518:9616"
depends_on:
- relay-millau-rialto

# Note: These are being overridden from the top level `monitoring` compose file.
grafana-dashboard:
environment:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash
set -eu

exec /home/user/substrate-relay detect-equivocations millau-to-rialto \
--source-host millau-node-alice \
--source-port 9944 \
--source-signer //Rialto.HeadersAndMessagesRelay \
--source-transactions-mortality=64 \
--target-host rialto-node-alice \
--target-port 9944
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash
set -eu

exec /home/user/substrate-relay detect-equivocations rialto-to-millau \
--source-host rialto-node-alice \
--source-port 9944 \
--source-signer //Millau.HeadersAndMessagesRelay \
--source-transactions-mortality=64 \
--target-host millau-node-alice \
--target-port 9944
20 changes: 20 additions & 0 deletions deployments/bridges/rialto-parachain-millau/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,26 @@ services:
depends_on:
- relay-messages-millau-to-rialto-parachain-generator

detect-millau-to-rialto-parachain-equivocations:
<<: *sub-bridge-relay
environment:
RUST_LOG: bridge=trace
entrypoint: /entrypoints/detect-millau-to-rialto-parachain-equivocations-entrypoint.sh
ports:
- "11019:9616"
depends_on:
- relay-millau-rialto-parachain-1

detect-rialto-to-millau-equivocations:
<<: *sub-bridge-relay
environment:
RUST_LOG: bridge=trace
entrypoint: /entrypoints/detect-rialto-to-millau-equivocations-entrypoint.sh
ports:
- "11020:9616"
depends_on:
- relay-millau-rialto-parachain-1

# Note: These are being overridden from the top level `monitoring` compose file.
grafana-dashboard:
environment:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash
set -eu

exec /home/user/substrate-relay detect-equivocations millau-to-rialto-parachain \
--source-host millau-node-alice \
--source-port 9944 \
--source-signer //RialtoParachain.HeadersAndMessagesRelay1 \
--source-transactions-mortality=64 \
--target-host rialto-parachain-collator-charlie \
--target-port 9944
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash
set -eu

exec /home/user/substrate-relay detect-equivocations rialto-to-millau \
--source-host rialto-node-alice \
--source-port 9944 \
--source-signer //Millau.HeadersAndMessagesRelay \
--source-transactions-mortality=64 \
--target-host millau-node-alice \
--target-port 9944
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@

//! Kusama-to-BridgeHubPolkadot headers sync entrypoint.
use crate::cli::bridge::{CliBridgeBase, RelayToRelayHeadersCliBridge};
use crate::cli::bridge::{
CliBridgeBase, RelayToRelayEquivocationDetectionCliBridge, RelayToRelayHeadersCliBridge,
};

use async_trait::async_trait;
use relay_substrate_client::{AccountKeyPairOf, Client};
Expand Down Expand Up @@ -88,3 +90,7 @@ impl CliBridgeBase for KusamaToBridgeHubPolkadotCliBridge {
impl RelayToRelayHeadersCliBridge for KusamaToBridgeHubPolkadotCliBridge {
type Finality = KusamaFinalityToBridgeHubPolkadot;
}

impl RelayToRelayEquivocationDetectionCliBridge for KusamaToBridgeHubPolkadotCliBridge {
type Equivocation = KusamaFinalityToBridgeHubPolkadot;
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@

//! Kusama-to-BridgeHubPolkadot parachains sync entrypoint.
use crate::cli::bridge::{
CliBridgeBase, MessagesCliBridge, ParachainToRelayEquivocationDetectionCliBridge,
ParachainToRelayHeadersCliBridge,
};
use crate::cli::bridge::{CliBridgeBase, MessagesCliBridge, ParachainToRelayHeadersCliBridge};
use bp_polkadot_core::parachains::{ParaHash, ParaHeadsProof, ParaId};
use relay_substrate_client::{CallOf, HeaderIdOf};
use substrate_relay_helper::parachains::{
Expand Down Expand Up @@ -67,13 +64,6 @@ impl ParachainToRelayHeadersCliBridge for BridgeHubKusamaToBridgeHubPolkadotCliB
crate::bridges::kusama_polkadot::kusama_headers_to_bridge_hub_polkadot::KusamaFinalityToBridgeHubPolkadot;
}

impl ParachainToRelayEquivocationDetectionCliBridge
for BridgeHubKusamaToBridgeHubPolkadotCliBridge
{
type SourceRelay = relay_kusama_client::Kusama;
type RelayEquivocation = crate::bridges::kusama_polkadot::kusama_headers_to_bridge_hub_polkadot::KusamaFinalityToBridgeHubPolkadot;
}

impl CliBridgeBase for BridgeHubKusamaToBridgeHubPolkadotCliBridge {
type Source = relay_bridge_hub_kusama_client::BridgeHubKusama;
type Target = relay_bridge_hub_polkadot_client::BridgeHubPolkadot;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@

//! Polkadot-to-KusamaBridgeHub headers sync entrypoint.
use crate::cli::bridge::{CliBridgeBase, RelayToRelayHeadersCliBridge};
use crate::cli::bridge::{
CliBridgeBase, RelayToRelayEquivocationDetectionCliBridge, RelayToRelayHeadersCliBridge,
};

use async_trait::async_trait;
use relay_substrate_client::{AccountKeyPairOf, Client};
Expand Down Expand Up @@ -88,3 +90,7 @@ impl CliBridgeBase for PolkadotToBridgeHubKusamaCliBridge {
impl RelayToRelayHeadersCliBridge for PolkadotToBridgeHubKusamaCliBridge {
type Finality = PolkadotFinalityToBridgeHubKusama;
}

impl RelayToRelayEquivocationDetectionCliBridge for PolkadotToBridgeHubKusamaCliBridge {
type Equivocation = PolkadotFinalityToBridgeHubKusama;
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@

//! Polkadot-to-BridgeHubKusama parachains sync entrypoint.
use crate::cli::bridge::{
CliBridgeBase, MessagesCliBridge, ParachainToRelayEquivocationDetectionCliBridge,
ParachainToRelayHeadersCliBridge,
};
use crate::cli::bridge::{CliBridgeBase, MessagesCliBridge, ParachainToRelayHeadersCliBridge};
use bp_polkadot_core::parachains::{ParaHash, ParaHeadsProof, ParaId};
use relay_substrate_client::{CallOf, HeaderIdOf};
use substrate_relay_helper::parachains::{
Expand Down Expand Up @@ -67,13 +64,6 @@ impl ParachainToRelayHeadersCliBridge for BridgeHubPolkadotToBridgeHubKusamaCliB
crate::bridges::kusama_polkadot::polkadot_headers_to_bridge_hub_kusama::PolkadotFinalityToBridgeHubKusama;
}

impl ParachainToRelayEquivocationDetectionCliBridge
for BridgeHubPolkadotToBridgeHubKusamaCliBridge
{
type SourceRelay = relay_polkadot_client::Polkadot;
type RelayEquivocation = crate::bridges::kusama_polkadot::polkadot_headers_to_bridge_hub_kusama::PolkadotFinalityToBridgeHubKusama;
}

impl CliBridgeBase for BridgeHubPolkadotToBridgeHubKusamaCliBridge {
type Source = relay_bridge_hub_polkadot_client::BridgeHubPolkadot;
type Target = relay_bridge_hub_kusama_client::BridgeHubKusama;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@

//! Rialto-to-Millau parachains sync entrypoint.
use crate::cli::bridge::{
CliBridgeBase, MessagesCliBridge, ParachainToRelayEquivocationDetectionCliBridge,
ParachainToRelayHeadersCliBridge,
};
use crate::cli::bridge::{CliBridgeBase, MessagesCliBridge, ParachainToRelayHeadersCliBridge};
use relay_millau_client::Millau;
use relay_rialto_client::Rialto;
use relay_rialto_parachain_client::RialtoParachain;
Expand Down Expand Up @@ -62,12 +59,6 @@ impl ParachainToRelayHeadersCliBridge for RialtoParachainToMillauCliBridge {
crate::bridges::rialto_millau::rialto_headers_to_millau::RialtoFinalityToMillau;
}

impl ParachainToRelayEquivocationDetectionCliBridge for RialtoParachainToMillauCliBridge {
type SourceRelay = Rialto;
type RelayEquivocation =
crate::bridges::rialto_millau::rialto_headers_to_millau::RialtoFinalityToMillau;
}

impl MessagesCliBridge for RialtoParachainToMillauCliBridge {
type MessagesLane =
crate::bridges::rialto_parachain_millau::rialto_parachain_messages_to_millau::RialtoParachainMessagesToMillau;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@

//! Rococo-to-Wococo bridge hubs headers sync entrypoint.
use crate::cli::bridge::{CliBridgeBase, RelayToRelayHeadersCliBridge};
use crate::cli::bridge::{
CliBridgeBase, RelayToRelayEquivocationDetectionCliBridge, RelayToRelayHeadersCliBridge,
};

use async_trait::async_trait;
use relay_substrate_client::{AccountKeyPairOf, Client};
Expand Down Expand Up @@ -88,3 +90,7 @@ impl CliBridgeBase for RococoToBridgeHubWococoCliBridge {
impl RelayToRelayHeadersCliBridge for RococoToBridgeHubWococoCliBridge {
type Finality = RococoFinalityToBridgeHubWococo;
}

impl RelayToRelayEquivocationDetectionCliBridge for RococoToBridgeHubWococoCliBridge {
type Equivocation = RococoFinalityToBridgeHubWococo;
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@

//! Wococo-to-Rococo parachains sync entrypoint.
use crate::cli::bridge::{
CliBridgeBase, MessagesCliBridge, ParachainToRelayEquivocationDetectionCliBridge,
ParachainToRelayHeadersCliBridge,
};
use crate::cli::bridge::{CliBridgeBase, MessagesCliBridge, ParachainToRelayHeadersCliBridge};
use bp_polkadot_core::parachains::{ParaHash, ParaHeadsProof, ParaId};
use relay_substrate_client::{CallOf, HeaderIdOf};
use substrate_relay_helper::parachains::{
Expand Down Expand Up @@ -67,11 +64,6 @@ impl ParachainToRelayHeadersCliBridge for BridgeHubRococoToBridgeHubWococoCliBri
crate::bridges::rococo_wococo::rococo_headers_to_bridge_hub_wococo::RococoFinalityToBridgeHubWococo;
}

impl ParachainToRelayEquivocationDetectionCliBridge for BridgeHubRococoToBridgeHubWococoCliBridge {
type SourceRelay = relay_rococo_client::Rococo;
type RelayEquivocation = crate::bridges::rococo_wococo::rococo_headers_to_bridge_hub_wococo::RococoFinalityToBridgeHubWococo;
}

impl CliBridgeBase for BridgeHubRococoToBridgeHubWococoCliBridge {
type Source = relay_bridge_hub_rococo_client::BridgeHubRococo;
type Target = relay_bridge_hub_wococo_client::BridgeHubWococo;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@

//! Wococo-to-Rococo bridge hubs headers sync entrypoint.
use crate::cli::bridge::{CliBridgeBase, RelayToRelayHeadersCliBridge};
use crate::cli::bridge::{
CliBridgeBase, RelayToRelayEquivocationDetectionCliBridge, RelayToRelayHeadersCliBridge,
};

use async_trait::async_trait;
use relay_substrate_client::{AccountKeyPairOf, Client};
Expand Down Expand Up @@ -88,3 +90,7 @@ impl CliBridgeBase for WococoToBridgeHubRococoCliBridge {
impl RelayToRelayHeadersCliBridge for WococoToBridgeHubRococoCliBridge {
type Finality = WococoFinalityToBridgeHubRococo;
}

impl RelayToRelayEquivocationDetectionCliBridge for WococoToBridgeHubRococoCliBridge {
type Equivocation = WococoFinalityToBridgeHubRococo;
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@

//! Rococo-to-Wococo parachains sync entrypoint.
use crate::cli::bridge::{
CliBridgeBase, MessagesCliBridge, ParachainToRelayEquivocationDetectionCliBridge,
ParachainToRelayHeadersCliBridge,
};
use crate::cli::bridge::{CliBridgeBase, MessagesCliBridge, ParachainToRelayHeadersCliBridge};
use bp_polkadot_core::parachains::{ParaHash, ParaHeadsProof, ParaId};
use relay_substrate_client::{CallOf, HeaderIdOf};
use substrate_relay_helper::parachains::{
Expand Down Expand Up @@ -67,11 +64,6 @@ impl ParachainToRelayHeadersCliBridge for BridgeHubWococoToBridgeHubRococoCliBri
crate::bridges::rococo_wococo::wococo_headers_to_bridge_hub_rococo::WococoFinalityToBridgeHubRococo;
}

impl ParachainToRelayEquivocationDetectionCliBridge for BridgeHubWococoToBridgeHubRococoCliBridge {
type SourceRelay = relay_wococo_client::Wococo;
type RelayEquivocation = crate::bridges::rococo_wococo::wococo_headers_to_bridge_hub_rococo::WococoFinalityToBridgeHubRococo;
}

impl CliBridgeBase for BridgeHubWococoToBridgeHubRococoCliBridge {
type Source = relay_bridge_hub_wococo_client::BridgeHubWococo;
type Target = relay_bridge_hub_rococo_client::BridgeHubRococo;
Expand Down
21 changes: 2 additions & 19 deletions relays/bin-substrate/src/cli/bridge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,15 @@ pub trait RelayToRelayHeadersCliBridge: CliBridgeBase {

/// Convenience trait that adds bounds to `CliBridgeBase`.
pub trait RelayToRelayEquivocationDetectionCliBridgeBase: CliBridgeBase {
type BoundedSourceChain: ChainWithTransactions;
type BoundedSource: ChainWithTransactions;
}

impl<T> RelayToRelayEquivocationDetectionCliBridgeBase for T
where
T: CliBridgeBase,
T::Source: ChainWithTransactions,
{
type BoundedSourceChain = T::Source;
type BoundedSource = T::Source;
}

/// Bridge representation that can be used from the CLI for detecting equivocations
Expand Down Expand Up @@ -105,23 +105,6 @@ where
>;
}

/// Bridge representation that can be used from the CLI for detecting equivocations
/// in the headers that are synchronized from a parachain to a relay chain.
pub trait ParachainToRelayEquivocationDetectionCliBridge: CliBridgeBase {
// The `CliBridgeBase` type represents the parachain in this situation.
// We need to add an extra type for the relay chain.
type SourceRelay: Chain<BlockNumber = RelayBlockNumber, Hash = RelayBlockHash, Hasher = RelayBlockHasher>
+ ChainWithTransactions
+ CliChain
+ RelayChain;

/// Equivocation detection pipeline (source relay chain -> target).
type RelayEquivocation: SubstrateEquivocationDetectionPipeline<
SourceChain = Self::SourceRelay,
TargetChain = Self::Target,
>;
}

/// Bridge representation that can be used from the CLI for relaying messages.
pub trait MessagesCliBridge: CliBridgeBase {
/// The Source -> Destination messages synchronization pipeline.
Expand Down
Loading

0 comments on commit 9713367

Please sign in to comment.