From 76625ed180a5cfdafd96580fb00a3b3bdc39926b Mon Sep 17 00:00:00 2001 From: Hernando Castano Date: Wed, 28 Apr 2021 12:08:55 -0400 Subject: [PATCH] Remove Westend<>Rococo header sync (#940) * Remove scripts for Westend<>Rococo header sync * Remove Westend<>Rococo header sync code * Remove Westend<>Rococo init bridge CLI option * Modify Westend mock call to be placeholder * Fix call encoding test --- bridges/primitives/chain-rococo/src/lib.rs | 13 +--- .../relays/bin-substrate/src/chains/mod.rs | 4 +- .../src/chains/rococo_headers_to_westend.rs | 60 ------------------- .../src/chains/westend_headers_to_rococo.rs | 60 ------------------- .../bin-substrate/src/cli/init_bridge.rs | 26 -------- .../bin-substrate/src/cli/relay_headers.rs | 16 ----- 6 files changed, 4 insertions(+), 175 deletions(-) delete mode 100644 bridges/relays/bin-substrate/src/chains/rococo_headers_to_westend.rs delete mode 100644 bridges/relays/bin-substrate/src/chains/westend_headers_to_rococo.rs diff --git a/bridges/primitives/chain-rococo/src/lib.rs b/bridges/primitives/chain-rococo/src/lib.rs index b79fdf6cfc..268ee3cae1 100644 --- a/bridges/primitives/chain-rococo/src/lib.rs +++ b/bridges/primitives/chain-rococo/src/lib.rs @@ -55,14 +55,14 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { /// See: https://github.com/paritytech/polkadot/blob/master/runtime/rococo/src/lib.rs #[derive(parity_scale_codec::Encode, parity_scale_codec::Decode, Debug, PartialEq, Eq, Clone)] pub enum Call { - /// Westend bridge pallet. + /// Generic bridge pallet. #[codec(index = 40)] - BridgeGrandpaWestend(BridgeGrandpaWestendCall), + BridgeCall(BridgeGrandpaCall), } #[derive(parity_scale_codec::Encode, parity_scale_codec::Decode, Debug, PartialEq, Eq, Clone)] #[allow(non_camel_case_types)] -pub enum BridgeGrandpaWestendCall { +pub enum BridgeGrandpaCall { #[codec(index = 0)] submit_finality_proof( ::Header, @@ -83,13 +83,6 @@ impl sp_runtime::traits::Dispatchable for Call { } } -// We use this to get the account on Rococo (target) which is derived from Westend's (source) -// account. -pub fn derive_account_from_westend_id(id: bp_runtime::SourceAccount) -> AccountId { - let encoded_id = bp_runtime::derive_account_id(bp_runtime::WESTEND_BRIDGE_INSTANCE, id); - AccountIdConverter::convert(encoded_id) -} - /// Name of the `RococoFinalityApi::best_finalized` runtime method. pub const BEST_FINALIZED_ROCOCO_HEADER_METHOD: &str = "RococoFinalityApi_best_finalized"; /// Name of the `RococoFinalityApi::is_known_header` runtime method. diff --git a/bridges/relays/bin-substrate/src/chains/mod.rs b/bridges/relays/bin-substrate/src/chains/mod.rs index 9e6a7361d5..2000c4c223 100644 --- a/bridges/relays/bin-substrate/src/chains/mod.rs +++ b/bridges/relays/bin-substrate/src/chains/mod.rs @@ -20,9 +20,7 @@ pub mod millau_headers_to_rialto; pub mod millau_messages_to_rialto; pub mod rialto_headers_to_millau; pub mod rialto_messages_to_millau; -pub mod rococo_headers_to_westend; pub mod westend_headers_to_millau; -pub mod westend_headers_to_rococo; mod millau; mod rialto; @@ -270,7 +268,7 @@ mod rococo_tests { votes_ancestries: vec![], }; - let actual = bp_rococo::BridgeGrandpaWestendCall::submit_finality_proof(header.clone(), justification.clone()); + let actual = bp_rococo::BridgeGrandpaCall::submit_finality_proof(header.clone(), justification.clone()); let expected = millau_runtime::BridgeGrandpaRialtoCall::::submit_finality_proof( header, justification, diff --git a/bridges/relays/bin-substrate/src/chains/rococo_headers_to_westend.rs b/bridges/relays/bin-substrate/src/chains/rococo_headers_to_westend.rs deleted file mode 100644 index dca91adb3d..0000000000 --- a/bridges/relays/bin-substrate/src/chains/rococo_headers_to_westend.rs +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright 2019-2021 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 . - -//! Rococo-to-Westend headers sync entrypoint. - -use crate::finality_pipeline::{SubstrateFinalitySyncPipeline, SubstrateFinalityToSubstrate}; - -use bp_header_chain::justification::GrandpaJustification; -use codec::Encode; -use relay_rococo_client::{Rococo, SyncHeader as RococoSyncHeader}; -use relay_substrate_client::{Chain, TransactionSignScheme}; -use relay_utils::metrics::MetricsParams; -use relay_westend_client::{SigningParams as WestendSigningParams, Westend}; -use sp_core::{Bytes, Pair}; - -/// Rococo-to-Westend finality sync pipeline. -pub(crate) type RococoFinalityToWestend = SubstrateFinalityToSubstrate; - -impl SubstrateFinalitySyncPipeline for RococoFinalityToWestend { - const BEST_FINALIZED_SOURCE_HEADER_ID_AT_TARGET: &'static str = bp_rococo::BEST_FINALIZED_ROCOCO_HEADER_METHOD; - - type TargetChain = Westend; - - fn customize_metrics(params: MetricsParams) -> anyhow::Result { - crate::chains::add_polkadot_kusama_price_metrics::(params) - } - - fn transactions_author(&self) -> bp_westend::AccountId { - (*self.target_sign.public().as_array_ref()).into() - } - - fn make_submit_finality_proof_transaction( - &self, - transaction_nonce: ::Index, - header: RococoSyncHeader, - proof: GrandpaJustification, - ) -> Bytes { - let call = bp_westend::Call::BridgeGrandpaRococo(bp_westend::BridgeGrandpaRococoCall::submit_finality_proof( - header.into_inner(), - proof, - )); - let genesis_hash = *self.target_client.genesis_hash(); - let transaction = Westend::sign_transaction(genesis_hash, &self.target_sign, transaction_nonce, call); - - Bytes(transaction.encode()) - } -} diff --git a/bridges/relays/bin-substrate/src/chains/westend_headers_to_rococo.rs b/bridges/relays/bin-substrate/src/chains/westend_headers_to_rococo.rs deleted file mode 100644 index 577a858d92..0000000000 --- a/bridges/relays/bin-substrate/src/chains/westend_headers_to_rococo.rs +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright 2019-2021 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 . - -//! Westend-to-Rococo headers sync entrypoint. - -use crate::finality_pipeline::{SubstrateFinalitySyncPipeline, SubstrateFinalityToSubstrate}; - -use bp_header_chain::justification::GrandpaJustification; -use codec::Encode; -use relay_rococo_client::{Rococo, SigningParams as RococoSigningParams}; -use relay_substrate_client::{Chain, TransactionSignScheme}; -use relay_utils::metrics::MetricsParams; -use relay_westend_client::{SyncHeader as WestendSyncHeader, Westend}; -use sp_core::{Bytes, Pair}; - -/// Westend-to-Rococo finality sync pipeline. -pub(crate) type WestendFinalityToRococo = SubstrateFinalityToSubstrate; - -impl SubstrateFinalitySyncPipeline for WestendFinalityToRococo { - const BEST_FINALIZED_SOURCE_HEADER_ID_AT_TARGET: &'static str = bp_westend::BEST_FINALIZED_WESTEND_HEADER_METHOD; - - type TargetChain = Rococo; - - fn customize_metrics(params: MetricsParams) -> anyhow::Result { - crate::chains::add_polkadot_kusama_price_metrics::(params) - } - - fn transactions_author(&self) -> bp_rococo::AccountId { - (*self.target_sign.public().as_array_ref()).into() - } - - fn make_submit_finality_proof_transaction( - &self, - transaction_nonce: ::Index, - header: WestendSyncHeader, - proof: GrandpaJustification, - ) -> Bytes { - let call = bp_rococo::Call::BridgeGrandpaWestend(bp_rococo::BridgeGrandpaWestendCall::submit_finality_proof( - header.into_inner(), - proof, - )); - let genesis_hash = *self.target_client.genesis_hash(); - let transaction = Rococo::sign_transaction(genesis_hash, &self.target_sign, transaction_nonce, call); - - Bytes(transaction.encode()) - } -} diff --git a/bridges/relays/bin-substrate/src/cli/init_bridge.rs b/bridges/relays/bin-substrate/src/cli/init_bridge.rs index cdd8ec3691..73af141a36 100644 --- a/bridges/relays/bin-substrate/src/cli/init_bridge.rs +++ b/bridges/relays/bin-substrate/src/cli/init_bridge.rs @@ -44,8 +44,6 @@ arg_enum! { MillauToRialto, RialtoToMillau, WestendToMillau, - WestendToRococo, - RococoToWestend, } } @@ -100,30 +98,6 @@ macro_rules! select_bridge { .into() } - $generic - } - InitBridgeName::WestendToRococo => { - type Source = relay_westend_client::Westend; - type Target = relay_rococo_client::Rococo; - - fn encode_init_bridge( - init_data: InitializationData<::Header>, - ) -> ::Call { - bp_rococo::Call::BridgeGrandpaWestend(bp_rococo::BridgeGrandpaWestendCall::initialize(init_data)) - } - - $generic - } - InitBridgeName::RococoToWestend => { - type Source = relay_rococo_client::Rococo; - type Target = relay_westend_client::Westend; - - fn encode_init_bridge( - init_data: InitializationData<::Header>, - ) -> ::Call { - bp_westend::Call::BridgeGrandpaRococo(bp_westend::BridgeGrandpaRococoCall::initialize(init_data)) - } - $generic } } diff --git a/bridges/relays/bin-substrate/src/cli/relay_headers.rs b/bridges/relays/bin-substrate/src/cli/relay_headers.rs index cbcbbf8926..1385527d97 100644 --- a/bridges/relays/bin-substrate/src/cli/relay_headers.rs +++ b/bridges/relays/bin-substrate/src/cli/relay_headers.rs @@ -42,8 +42,6 @@ arg_enum! { MillauToRialto, RialtoToMillau, WestendToMillau, - WestendToRococo, - RococoToWestend, } } @@ -69,20 +67,6 @@ macro_rules! select_bridge { type Target = relay_millau_client::Millau; type Finality = crate::chains::westend_headers_to_millau::WestendFinalityToMillau; - $generic - } - RelayHeadersBridge::WestendToRococo => { - type Source = relay_westend_client::Westend; - type Target = relay_rococo_client::Rococo; - type Finality = crate::chains::westend_headers_to_rococo::WestendFinalityToRococo; - - $generic - } - RelayHeadersBridge::RococoToWestend => { - type Source = relay_rococo_client::Rococo; - type Target = relay_westend_client::Westend; - type Finality = crate::chains::rococo_headers_to_westend::RococoFinalityToWestend; - $generic } }