Start the equivocation detection loop from the complex relayer (#2507) (#2512)

* Impl SubstrateEquivocationDetectionPipeline for Millau

* Impl SubstrateEquivocationDetectionPipeline for Rialto

* Make BridgeHubSignedExtension more generic

* Define generate_report_equivocation_call_builder!() macro

* Impl SubstrateEquivocationDetectionPipeline for Rococo

* Impl SubstrateEquivocationDetectionPipeline for Wococo

* Impl SubstrateEquivocationDetectionPipeline for Kusama

* Impl SubstrateEquivocationDetectionPipeline for Polkadot

* Complex relayer simplification

- remove `signer` and `transactions_mortality` and add `tx_params`
- change the order of some fields

* Add equivocation detection CLI traits

* Complex relayer: start equivocation detectin loop

* Update runtimes regeneration script

* Equivocation loop: Fix infinite loop

* Revert "Complex relayer: start equivocation detectin loop"

This reverts commit b518ef85679d73654f9f0e2add38cd3839552057.

* Add subcommand for starting the equivocation detection loop

* Fixes

* Initialize empty metrics for the equivocations detector loop
This commit is contained in:
Serban Iorga
2023-08-31 08:50:19 +03:00
committed by Bastian Köcher
parent 588508acd4
commit 1bbc77fee1
48 changed files with 25096 additions and 249 deletions
@@ -23,10 +23,9 @@ pub use bp_polkadot_core::{
};
use bp_messages::*;
use bp_polkadot_core::SuffixedCommonSignedExtension;
use bp_runtime::extensions::{
BridgeRejectObsoleteHeadersAndMessages, ChargeTransactionPayment, CheckEra, CheckGenesis,
CheckNonZeroSender, CheckNonce, CheckSpecVersion, CheckTxVersion, CheckWeight,
GenericSignedExtension, RefundBridgedParachainMessagesSchema,
BridgeRejectObsoleteHeadersAndMessages, RefundBridgedParachainMessagesSchema,
};
use frame_support::{
dispatch::DispatchClass,
@@ -133,88 +132,8 @@ pub const MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX: MessageNonce = 1024;
/// analysis (like the one above).
pub const MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX: MessageNonce = 4096;
/// Extra signed extension data that is used by all bridge hubs.
pub type SignedExtra = (
CheckNonZeroSender,
CheckSpecVersion,
CheckTxVersion,
CheckGenesis<Hash>,
CheckEra<Hash>,
CheckNonce<Nonce>,
CheckWeight,
ChargeTransactionPayment<Balance>,
/// Signed extension that is used by all bridge hubs.
pub type SignedExtension = SuffixedCommonSignedExtension<(
BridgeRejectObsoleteHeadersAndMessages,
RefundBridgedParachainMessagesSchema,
);
/// Signed extension that is used by all bridge hubs.
pub type SignedExtension = GenericSignedExtension<SignedExtra>;
/// Helper trait to define some extra methods on bridge hubs signed extension (and
/// overcome Rust limitations).
pub trait BridgeHubSignedExtension {
/// Create signed extension from its components.
fn from_params(
spec_version: u32,
transaction_version: u32,
era: bp_runtime::TransactionEra<BlockNumber, Hash>,
genesis_hash: Hash,
nonce: Nonce,
tip: Balance,
) -> Self;
/// Return transaction nonce.
fn nonce(&self) -> Nonce;
/// Return transaction tip.
fn tip(&self) -> Balance;
}
impl BridgeHubSignedExtension for SignedExtension {
/// Create signed extension from its components.
fn from_params(
spec_version: u32,
transaction_version: u32,
era: bp_runtime::TransactionEra<BlockNumber, Hash>,
genesis_hash: Hash,
nonce: Nonce,
tip: Balance,
) -> Self {
GenericSignedExtension::new(
(
(), // non-zero sender
(), // spec version
(), // tx version
(), // genesis
era.frame_era(), // era
nonce.into(), // nonce (compact encoding)
(), // Check weight
tip.into(), // transaction payment / tip (compact encoding)
(), // bridge reject obsolete headers and msgs
(), // bridge reward to relayer for message passing
),
Some((
(),
spec_version,
transaction_version,
genesis_hash,
era.signed_payload(genesis_hash),
(),
(),
(),
(),
(),
)),
)
}
/// Return transaction nonce.
fn nonce(&self) -> Nonce {
self.payload.5 .0
}
/// Return transaction tip.
fn tip(&self) -> Balance {
self.payload.7 .0
}
}
)>;