diff --git a/substrate-relay/src/bridges/rococo_bulletin/bridge_hub_rococo_messages_to_rococo_bulletin.rs b/substrate-relay/src/bridges/rococo_bulletin/bridge_hub_rococo_messages_to_rococo_bulletin.rs index 8ca30981b6..569ae9b878 100644 --- a/substrate-relay/src/bridges/rococo_bulletin/bridge_hub_rococo_messages_to_rococo_bulletin.rs +++ b/substrate-relay/src/bridges/rococo_bulletin/bridge_hub_rococo_messages_to_rococo_bulletin.rs @@ -16,7 +16,7 @@ //! BridgeHubRococo-to-RococoBulletin messages sync entrypoint. -use super::BridgeHubRococoAsBridgeHubPolkadot; +use relay_bridge_hub_rococo_client::BridgeHubRococo; use relay_polkadot_bulletin_client::PolkadotBulletin as RococoBulletin; use substrate_relay_helper::{ cli::bridge::{CliBridgeBase, MessagesCliBridge}, @@ -28,7 +28,7 @@ use substrate_relay_helper::{ pub struct BridgeHubRococoToRococoBulletinMessagesCliBridge {} impl CliBridgeBase for BridgeHubRococoToRococoBulletinMessagesCliBridge { - type Source = BridgeHubRococoAsBridgeHubPolkadot; + type Source = BridgeHubRococo; type Target = RococoBulletin; } @@ -55,7 +55,7 @@ substrate_relay_helper::generate_receive_message_delivery_proof_call_builder!( pub struct BridgeHubRococoMessagesToRococoBulletinMessageLane; impl SubstrateMessageLane for BridgeHubRococoMessagesToRococoBulletinMessageLane { - type SourceChain = BridgeHubRococoAsBridgeHubPolkadot; + type SourceChain = BridgeHubRococo; type TargetChain = RococoBulletin; type LaneId = bp_messages::LegacyLaneId; @@ -65,6 +65,6 @@ impl SubstrateMessageLane for BridgeHubRococoMessagesToRococoBulletinMessageLane type ReceiveMessagesDeliveryProofCallBuilder = BridgeHubRococoMessagesToRococoBulletinMessageLaneReceiveMessagesDeliveryProofCallBuilder; - type SourceBatchCallBuilder = UtilityPalletBatchCallBuilder; + type SourceBatchCallBuilder = UtilityPalletBatchCallBuilder; type TargetBatchCallBuilder = (); } diff --git a/substrate-relay/src/bridges/rococo_bulletin/mod.rs b/substrate-relay/src/bridges/rococo_bulletin/mod.rs index b6ed2c1a61..3f0b04e853 100644 --- a/substrate-relay/src/bridges/rococo_bulletin/mod.rs +++ b/substrate-relay/src/bridges/rococo_bulletin/mod.rs @@ -16,233 +16,8 @@ //! Declaration of all bridges between Rococo Bulletin Chain and Rococo Bridge Hub. -use bp_messages::MessageNonce; -use bp_runtime::{ - AccountIdOf, BalanceOf, BlockNumberOf, ChainId, HashOf, HasherOf, HeaderOf, NonceOf, - SignatureOf, -}; -use frame_support::{pallet_prelude::Weight, sp_runtime::StateVersion}; -use relay_substrate_client::{ - ChainWithRuntimeVersion, Error as SubstrateError, SignParam, SimpleRuntimeVersion, - UnsignedTransaction, -}; -use sp_core::storage::StorageKey; -use std::time::Duration; - pub mod bridge_hub_rococo_messages_to_rococo_bulletin; pub mod rococo_bulletin_headers_to_bridge_hub_rococo; pub mod rococo_bulletin_messages_to_bridge_hub_rococo; pub mod rococo_headers_to_rococo_bulletin; pub mod rococo_parachains_to_rococo_bulletin; - -/// Base `Chain` implementation of Rococo, pretending to be Polkadot. -pub struct RococoBaseAsPolkadot; - -impl bp_runtime::Chain for RococoBaseAsPolkadot { - const ID: ChainId = relay_rococo_client::Rococo::ID; - - type BlockNumber = BlockNumberOf; - type Hash = HashOf; - type Hasher = HasherOf; - type Header = HeaderOf; - - type AccountId = AccountIdOf; - type Balance = BalanceOf; - type Nonce = NonceOf; - type Signature = SignatureOf; - - const STATE_VERSION: StateVersion = StateVersion::V1; - - fn max_extrinsic_size() -> u32 { - bp_rococo::Rococo::max_extrinsic_size() - } - - fn max_extrinsic_weight() -> Weight { - bp_rococo::Rococo::max_extrinsic_weight() - } -} - -impl bp_header_chain::ChainWithGrandpa for RococoBaseAsPolkadot { - const WITH_CHAIN_GRANDPA_PALLET_NAME: &'static str = - bp_polkadot::Polkadot::WITH_CHAIN_GRANDPA_PALLET_NAME; - const MAX_AUTHORITIES_COUNT: u32 = bp_rococo::Rococo::MAX_AUTHORITIES_COUNT; - const REASONABLE_HEADERS_IN_JUSTIFICATION_ANCESTRY: u32 = - bp_rococo::Rococo::REASONABLE_HEADERS_IN_JUSTIFICATION_ANCESTRY; - const MAX_MANDATORY_HEADER_SIZE: u32 = bp_rococo::Rococo::MAX_MANDATORY_HEADER_SIZE; - const AVERAGE_HEADER_SIZE: u32 = bp_rococo::Rococo::AVERAGE_HEADER_SIZE; -} - -/// Relay `Chain` implementation of Rococo, pretending to be Polkadot. -#[derive(Debug, Clone, Copy)] -pub struct RococoAsPolkadot; - -impl bp_runtime::UnderlyingChainProvider for RococoAsPolkadot { - type Chain = RococoBaseAsPolkadot; -} - -impl relay_substrate_client::Chain for RococoAsPolkadot { - const NAME: &'static str = relay_rococo_client::Rococo::NAME; - const BEST_FINALIZED_HEADER_ID_METHOD: &'static str = - relay_polkadot_client::Polkadot::BEST_FINALIZED_HEADER_ID_METHOD; - const FREE_HEADERS_INTERVAL_METHOD: &'static str = - relay_polkadot_client::Polkadot::FREE_HEADERS_INTERVAL_METHOD; - const AVERAGE_BLOCK_INTERVAL: Duration = relay_rococo_client::Rococo::AVERAGE_BLOCK_INTERVAL; - - type SignedBlock = ::SignedBlock; - type Call = ::Call; -} - -impl relay_substrate_client::ChainWithGrandpa for RococoAsPolkadot { - const SYNCED_HEADERS_GRANDPA_INFO_METHOD: &'static str = - relay_polkadot_client::Polkadot::SYNCED_HEADERS_GRANDPA_INFO_METHOD; - - type KeyOwnerProof = - ::KeyOwnerProof; -} - -impl relay_substrate_client::ChainWithBalances for RococoAsPolkadot { - fn account_info_storage_key(account_id: &Self::AccountId) -> StorageKey { - relay_rococo_client::Rococo::account_info_storage_key(account_id) - } -} - -impl relay_substrate_client::RelayChain for RococoAsPolkadot { - const PARAS_PALLET_NAME: &'static str = relay_rococo_client::Rococo::PARAS_PALLET_NAME; - const WITH_CHAIN_BRIDGE_PARACHAINS_PALLET_NAME: &'static str = - relay_rococo_client::Rococo::WITH_CHAIN_BRIDGE_PARACHAINS_PALLET_NAME; -} - -impl relay_substrate_client::ChainWithTransactions for RococoAsPolkadot { - type AccountKeyPair = ::AccountKeyPair; - type SignedTransaction = ::SignedTransaction; - - fn sign_transaction( - param: SignParam, - unsigned: UnsignedTransaction, - ) -> Result { - relay_rococo_client::Rococo::sign_transaction( - SignParam { - spec_version: param.spec_version, - transaction_version: param.transaction_version, - genesis_hash: param.genesis_hash, - signer: param.signer, - }, - unsigned.switch_chain(), - ) - } -} - -impl ChainWithRuntimeVersion for RococoAsPolkadot { - const RUNTIME_VERSION: Option = None; -} - -/// Base `Chain` implementation of Rococo Bridge Hub, pretending to be a Polkadot Bridge Hub. -pub struct BaseBridgeHubRococoAsBridgeHubPolkadot; - -impl bp_runtime::Chain for BaseBridgeHubRococoAsBridgeHubPolkadot { - const ID: ChainId = relay_bridge_hub_rococo_client::BridgeHubRococo::ID; - - type BlockNumber = BlockNumberOf; - type Hash = HashOf; - type Hasher = HasherOf; - type Header = HeaderOf; - - type AccountId = AccountIdOf; - type Balance = BalanceOf; - type Nonce = NonceOf; - type Signature = SignatureOf; - - const STATE_VERSION: StateVersion = StateVersion::V1; - - fn max_extrinsic_size() -> u32 { - bp_bridge_hub_rococo::BridgeHubRococo::max_extrinsic_size() - } - - fn max_extrinsic_weight() -> Weight { - bp_bridge_hub_rococo::BridgeHubRococo::max_extrinsic_weight() - } -} - -impl bp_runtime::Parachain for BaseBridgeHubRococoAsBridgeHubPolkadot { - const PARACHAIN_ID: u32 = bp_bridge_hub_rococo::BridgeHubRococo::PARACHAIN_ID; - const MAX_HEADER_SIZE: u32 = bp_bridge_hub_rococo::BridgeHubRococo::MAX_HEADER_SIZE; -} - -impl bp_messages::ChainWithMessages for BaseBridgeHubRococoAsBridgeHubPolkadot { - const WITH_CHAIN_MESSAGES_PALLET_NAME: &'static str = - relay_bridge_hub_polkadot_client::BridgeHubPolkadot::WITH_CHAIN_MESSAGES_PALLET_NAME; - - const MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX: MessageNonce = - relay_bridge_hub_rococo_client::BridgeHubRococo::MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX; - const MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX: MessageNonce = - relay_bridge_hub_rococo_client::BridgeHubRococo::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX; -} - -/// Relay `Chain` implementation of Rococo Bridge Hub, pretending to be a Polkadot Bridge Hub. -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct BridgeHubRococoAsBridgeHubPolkadot; - -impl bp_runtime::UnderlyingChainProvider for BridgeHubRococoAsBridgeHubPolkadot { - type Chain = BaseBridgeHubRococoAsBridgeHubPolkadot; -} - -impl relay_substrate_client::Chain for BridgeHubRococoAsBridgeHubPolkadot { - const NAME: &'static str = relay_bridge_hub_rococo_client::BridgeHubRococo::NAME; - const BEST_FINALIZED_HEADER_ID_METHOD: &'static str = - relay_bridge_hub_polkadot_client::BridgeHubPolkadot::BEST_FINALIZED_HEADER_ID_METHOD; - const FREE_HEADERS_INTERVAL_METHOD: &'static str = - relay_bridge_hub_polkadot_client::BridgeHubPolkadot::FREE_HEADERS_INTERVAL_METHOD; - const AVERAGE_BLOCK_INTERVAL: Duration = - relay_bridge_hub_rococo_client::BridgeHubRococo::AVERAGE_BLOCK_INTERVAL; - - type SignedBlock = ::SignedBlock; - type Call = - ::Call; -} - -impl relay_substrate_client::ChainWithBalances for BridgeHubRococoAsBridgeHubPolkadot { - fn account_info_storage_key(account_id: &Self::AccountId) -> StorageKey { - relay_bridge_hub_rococo_client::BridgeHubRococo::account_info_storage_key(account_id) - } -} - -impl relay_substrate_client::ChainWithUtilityPallet for BridgeHubRococoAsBridgeHubPolkadot { - type UtilityPallet = relay_substrate_client::MockedRuntimeUtilityPallet< - relay_bridge_hub_rococo_client::RuntimeCall, - >; -} - -impl relay_substrate_client::ChainWithTransactions for BridgeHubRococoAsBridgeHubPolkadot { - type AccountKeyPair = ::AccountKeyPair; - type SignedTransaction = ::SignedTransaction; - - fn sign_transaction( - param: SignParam, - unsigned: UnsignedTransaction, - ) -> Result { - relay_bridge_hub_rococo_client::BridgeHubRococo::sign_transaction( - SignParam { - spec_version: param.spec_version, - transaction_version: param.transaction_version, - genesis_hash: param.genesis_hash, - signer: param.signer, - }, - unsigned.switch_chain(), - ) - } -} - -impl relay_substrate_client::ChainWithMessages for BridgeHubRococoAsBridgeHubPolkadot { - const WITH_CHAIN_RELAYERS_PALLET_NAME: Option<&'static str> = - relay_bridge_hub_polkadot_client::BridgeHubPolkadot::WITH_CHAIN_RELAYERS_PALLET_NAME; - - const TO_CHAIN_MESSAGE_DETAILS_METHOD: &'static str = - relay_bridge_hub_polkadot_client::BridgeHubPolkadot::TO_CHAIN_MESSAGE_DETAILS_METHOD; - const FROM_CHAIN_MESSAGE_DETAILS_METHOD: &'static str = - relay_bridge_hub_polkadot_client::BridgeHubPolkadot::FROM_CHAIN_MESSAGE_DETAILS_METHOD; -} - -impl ChainWithRuntimeVersion for BridgeHubRococoAsBridgeHubPolkadot { - const RUNTIME_VERSION: Option = - Some(SimpleRuntimeVersion { spec_version: 1_003_000, transaction_version: 3 }); -} diff --git a/substrate-relay/src/bridges/rococo_bulletin/rococo_bulletin_headers_to_bridge_hub_rococo.rs b/substrate-relay/src/bridges/rococo_bulletin/rococo_bulletin_headers_to_bridge_hub_rococo.rs index 0d54fd2101..3a4fbbef2b 100644 --- a/substrate-relay/src/bridges/rococo_bulletin/rococo_bulletin_headers_to_bridge_hub_rococo.rs +++ b/substrate-relay/src/bridges/rococo_bulletin/rococo_bulletin_headers_to_bridge_hub_rococo.rs @@ -16,7 +16,7 @@ //! RococoBulletin-to-BridgeHubRococo headers sync entrypoint. -use super::BridgeHubRococoAsBridgeHubPolkadot; +use relay_bridge_hub_rococo_client::BridgeHubRococo; use async_trait::async_trait; use substrate_relay_helper::{ @@ -51,7 +51,7 @@ substrate_relay_helper::generate_report_equivocation_call_builder!( #[async_trait] impl SubstrateFinalityPipeline for RococoBulletinFinalityToBridgeHubRococo { type SourceChain = relay_polkadot_bulletin_client::PolkadotBulletin; - type TargetChain = BridgeHubRococoAsBridgeHubPolkadot; + type TargetChain = BridgeHubRococo; type FinalityEngine = GrandpaFinalityEngine; } @@ -71,7 +71,7 @@ pub struct RococoBulletinToBridgeHubRococoCliBridge {} impl CliBridgeBase for RococoBulletinToBridgeHubRococoCliBridge { type Source = relay_polkadot_bulletin_client::PolkadotBulletin; - type Target = BridgeHubRococoAsBridgeHubPolkadot; + type Target = BridgeHubRococo; } impl RelayToRelayHeadersCliBridge for RococoBulletinToBridgeHubRococoCliBridge { diff --git a/substrate-relay/src/bridges/rococo_bulletin/rococo_bulletin_messages_to_bridge_hub_rococo.rs b/substrate-relay/src/bridges/rococo_bulletin/rococo_bulletin_messages_to_bridge_hub_rococo.rs index 717c655ea0..c2e0d073bc 100644 --- a/substrate-relay/src/bridges/rococo_bulletin/rococo_bulletin_messages_to_bridge_hub_rococo.rs +++ b/substrate-relay/src/bridges/rococo_bulletin/rococo_bulletin_messages_to_bridge_hub_rococo.rs @@ -16,7 +16,7 @@ //! RococoBulletin-to-BridgeHubRococo messages sync entrypoint. -use super::BridgeHubRococoAsBridgeHubPolkadot; +use relay_bridge_hub_rococo_client::BridgeHubRococo; use relay_polkadot_bulletin_client::PolkadotBulletin as RococoBulletin; use substrate_relay_helper::{ cli::bridge::{CliBridgeBase, MessagesCliBridge}, @@ -29,7 +29,7 @@ pub struct RococoBulletinToBridgeHubRococoMessagesCliBridge {} impl CliBridgeBase for RococoBulletinToBridgeHubRococoMessagesCliBridge { type Source = RococoBulletin; - type Target = BridgeHubRococoAsBridgeHubPolkadot; + type Target = BridgeHubRococo; } impl MessagesCliBridge for RococoBulletinToBridgeHubRococoMessagesCliBridge { @@ -56,7 +56,7 @@ pub struct RococoBulletinMessagesToBridgeHubRococoMessageLane; impl SubstrateMessageLane for RococoBulletinMessagesToBridgeHubRococoMessageLane { type SourceChain = RococoBulletin; - type TargetChain = BridgeHubRococoAsBridgeHubPolkadot; + type TargetChain = BridgeHubRococo; type LaneId = bp_messages::LegacyLaneId; @@ -66,5 +66,5 @@ impl SubstrateMessageLane for RococoBulletinMessagesToBridgeHubRococoMessageLane RococoBulletinMessagesToBridgeHubRococoMessageLaneReceiveMessagesDeliveryProofCallBuilder; type SourceBatchCallBuilder = (); - type TargetBatchCallBuilder = UtilityPalletBatchCallBuilder; + type TargetBatchCallBuilder = UtilityPalletBatchCallBuilder; } diff --git a/substrate-relay/src/bridges/rococo_bulletin/rococo_headers_to_rococo_bulletin.rs b/substrate-relay/src/bridges/rococo_bulletin/rococo_headers_to_rococo_bulletin.rs index 45c890267f..ecc264a7c4 100644 --- a/substrate-relay/src/bridges/rococo_bulletin/rococo_headers_to_rococo_bulletin.rs +++ b/substrate-relay/src/bridges/rococo_bulletin/rococo_headers_to_rococo_bulletin.rs @@ -16,7 +16,7 @@ //! Rococo-to-RococoBulletin headers sync entrypoint. -use super::RococoAsPolkadot; +use relay_rococo_client::Rococo; use async_trait::async_trait; use substrate_relay_helper::{ @@ -49,7 +49,7 @@ substrate_relay_helper::generate_report_equivocation_call_builder!( #[async_trait] impl SubstrateFinalityPipeline for RococoFinalityToRococoBulletin { - type SourceChain = RococoAsPolkadot; + type SourceChain = Rococo; type TargetChain = relay_polkadot_bulletin_client::PolkadotBulletin; type FinalityEngine = GrandpaFinalityEngine; @@ -69,7 +69,7 @@ impl SubstrateEquivocationDetectionPipeline for RococoFinalityToRococoBulletin { pub struct RococoToRococoBulletinCliBridge {} impl CliBridgeBase for RococoToRococoBulletinCliBridge { - type Source = RococoAsPolkadot; + type Source = Rococo; type Target = relay_polkadot_bulletin_client::PolkadotBulletin; } diff --git a/substrate-relay/src/bridges/rococo_bulletin/rococo_parachains_to_rococo_bulletin.rs b/substrate-relay/src/bridges/rococo_bulletin/rococo_parachains_to_rococo_bulletin.rs index fa5372b527..01662838eb 100644 --- a/substrate-relay/src/bridges/rococo_bulletin/rococo_parachains_to_rococo_bulletin.rs +++ b/substrate-relay/src/bridges/rococo_bulletin/rococo_parachains_to_rococo_bulletin.rs @@ -16,7 +16,8 @@ //! Rococo-to-RococoBulletin parachains sync entrypoint. -use super::{BridgeHubRococoAsBridgeHubPolkadot, RococoAsPolkadot}; +use relay_bridge_hub_rococo_client::BridgeHubRococo; +use relay_rococo_client::Rococo; use bp_polkadot_core::parachains::{ParaHash, ParaHeadsProof, ParaId}; use bp_runtime::Chain; @@ -32,8 +33,8 @@ use substrate_relay_helper::{ pub struct RococoToRococoBulletin; impl SubstrateParachainsPipeline for RococoToRococoBulletin { - type SourceParachain = BridgeHubRococoAsBridgeHubPolkadot; - type SourceRelayChain = RococoAsPolkadot; + type SourceParachain = BridgeHubRococo; + type SourceRelayChain = Rococo; type TargetChain = relay_polkadot_bulletin_client::PolkadotBulletin; type SubmitParachainHeadsCallBuilder = RococoToRococoBulletinCallBuilder; @@ -61,14 +62,14 @@ impl SubmitParachainHeadsCallBuilder for RococoToRococoB pub struct RococoToRococoBulletinCliBridge {} impl ParachainToRelayHeadersCliBridge for RococoToRococoBulletinCliBridge { - type SourceRelay = RococoAsPolkadot; + type SourceRelay = Rococo; type ParachainFinality = RococoToRococoBulletin; type RelayFinality = crate::bridges::rococo_bulletin::rococo_headers_to_rococo_bulletin::RococoFinalityToRococoBulletin; } impl CliBridgeBase for RococoToRococoBulletinCliBridge { - type Source = BridgeHubRococoAsBridgeHubPolkadot; + type Source = BridgeHubRococo; type Target = relay_polkadot_bulletin_client::PolkadotBulletin; } diff --git a/substrate-relay/src/cli/relay_headers_and_messages.rs b/substrate-relay/src/cli/relay_headers_and_messages.rs index 42342a8bb0..9fa420f268 100644 --- a/substrate-relay/src/cli/relay_headers_and_messages.rs +++ b/substrate-relay/src/cli/relay_headers_and_messages.rs @@ -38,13 +38,13 @@ use crate::bridges::{ rococo_bulletin::{ rococo_bulletin_headers_to_bridge_hub_rococo::RococoBulletinToBridgeHubRococoCliBridge, rococo_parachains_to_rococo_bulletin::RococoToRococoBulletinCliBridge, - BridgeHubRococoAsBridgeHubPolkadot, }, rococo_westend::{ rococo_parachains_to_bridge_hub_westend::BridgeHubRococoToBridgeHubWestendCliBridge, westend_parachains_to_bridge_hub_rococo::BridgeHubWestendToBridgeHubRococoCliBridge, }, }; +use relay_bridge_hub_rococo_client::BridgeHubRococo; use relay_substrate_client::{ AccountKeyPairOf, ChainRuntimeVersion, ChainWithRuntimeVersion, ChainWithTransactions, Parachain, SimpleRuntimeVersion, @@ -206,7 +206,7 @@ pub struct RococoBulletinBridgeHubRococoFull2WayBridge { impl Full2WayBridge for RococoBulletinBridgeHubRococoFull2WayBridge { type Base = RelayToParachainBridge; type Left = relay_polkadot_bulletin_client::PolkadotBulletin; - type Right = BridgeHubRococoAsBridgeHubPolkadot; + type Right = BridgeHubRococo; type L2R = RococoBulletinToBridgeHubRococoCliBridge; type R2L = RococoToRococoBulletinCliBridge;