From 04c67c4d6a1b85f000d04f4729f35da9b1ff38d5 Mon Sep 17 00:00:00 2001 From: Branislav Kontur Date: Mon, 31 Oct 2022 10:59:28 +0100 Subject: [PATCH] [BridgeHub] Init stuff for bridge messaging --- .../src/bridge_common_config.rs | 2 +- .../src/bridge_hub_rococo_config.rs | 227 ++++++++++++++++-- .../src/bridge_hub_wococo_config.rs | 224 +++++++++++++++-- .../bridge-hubs/bridge-hub-rococo/src/lib.rs | 34 ++- 4 files changed, 439 insertions(+), 48 deletions(-) diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/bridge_common_config.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/bridge_common_config.rs index 608193fd14..eb77346e09 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/bridge_common_config.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/bridge_common_config.rs @@ -55,7 +55,7 @@ impl< message: &mut DispatchMessage>, ) -> Weight { log::error!( - "[XcmBlobMessageDispatch] TODO: change here to XCMv3 dispatch_weight with XcmExecutor" + "[XcmBlobMessageDispatch] TODO: change here to XCMv3 dispatch_weight with XcmExecutor - message: ?...?", ); 0 } diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/bridge_hub_rococo_config.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/bridge_hub_rococo_config.rs index a44e9540cc..8cb45f5cdf 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/bridge_hub_rococo_config.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/bridge_hub_rococo_config.rs @@ -14,17 +14,32 @@ // You should have received a copy of the GNU General Public License // along with Cumulus. If not, see . -use bp_messages::{source_chain::{LaneMessageVerifier, TargetHeaderChain}, target_chain::{ProvedMessages, SourceHeaderChain}, InboundLaneData, LaneId, Message, OutboundLaneData, MessageKey, MessageData}; -use bp_runtime::{BalanceOf, Chain}; -use frame_support::{parameter_types, RuntimeDebug}; -use xcm::prelude::{InteriorMultiLocation, NetworkId}; -use bp_messages::target_chain::ProvedLaneMessages; -use bridge_runtime_common::messages::target::FromBridgedChainMessagesProof; -use crate::universal_exports::{BridgeBlobDispatcher, HaulBlobExporter}; -use crate::{WithBridgeHubWococoMessagesInstance, XcmAsPlainPayload, XcmBlobHauler, XcmRouter}; -use crate::Runtime; -use crate::ParachainInfo; -use xcm::latest::prelude::*; +use crate::{ + universal_exports::{BridgeBlobDispatcher, HaulBlobExporter}, + ParachainInfo, Runtime, WithBridgeHubWococoMessagesInstance, XcmAsPlainPayload, XcmBlobHauler, + XcmRouter, +}; +use bp_messages::{ + source_chain::TargetHeaderChain, + target_chain::{ProvedMessages, SourceHeaderChain}, + InboundLaneData, LaneId, Message, MessageNonce, +}; +use bp_polkadot_core::parachains::ParaId; +use bp_runtime::{Chain, ChainId}; +use bridge_runtime_common::{ + messages, + messages::{ + target::FromBridgedChainMessagesProof, BasicConfirmationTransactionEstimation, + BridgedChain, ChainWithMessages, MessageBridge, MessageTransaction, ThisChain, + ThisChainWithMessages, WeightOf, + }, +}; +use frame_support::{dispatch::Weight, parameter_types, RuntimeDebug}; +use sp_runtime::FixedU128; +use xcm::{ + latest::prelude::*, + prelude::{InteriorMultiLocation, NetworkId}, +}; // TODO:check-parameter parameter_types! { @@ -38,15 +53,18 @@ parameter_types! { } /// Dispatches received XCM messages from other bridge -pub type OnBridgeHubRococoBlobDispatcher = BridgeBlobDispatcher; +pub type OnBridgeHubRococoBlobDispatcher = + BridgeBlobDispatcher; /// Export XCM messages to be relayed to the otherside -pub type ToBridgeHubWococoHaulBlobExporter = HaulBlobExporter; +pub type ToBridgeHubWococoHaulBlobExporter = + HaulBlobExporter; pub struct ToBridgeHubWococoXcmBlobHauler; -pub const DEFAULT_XCM_LANE_TO_BRIDGE_HUB_WOCOCO: LaneId = [0, 0, 0, 1]; +pub const DEFAULT_XCM_LANE_TO_BRIDGE_HUB_WOCOCO: LaneId = [0, 0, 0, 2]; impl XcmBlobHauler for ToBridgeHubWococoXcmBlobHauler { type SenderChain = bp_bridge_hub_rococo::BridgeHubRococo; - type MessageSender = pallet_bridge_messages::Pallet; + type MessageSender = + pallet_bridge_messages::Pallet; fn message_sender_origin() -> InteriorMultiLocation { crate::xcm_config::UniversalLocation::get() @@ -56,3 +74,182 @@ impl XcmBlobHauler for ToBridgeHubWococoXcmBlobHauler { DEFAULT_XCM_LANE_TO_BRIDGE_HUB_WOCOCO } } + +/// Messaging Bridge configuration for BridgeHubRococo -> BridgeHubWococo +pub struct WithBridgeHubWococoMessageBridge; +impl MessageBridge for WithBridgeHubWococoMessageBridge { + // TODO:check-parameter - relayers rewards + const RELAYER_FEE_PERCENT: u32 = 0; + const THIS_CHAIN_ID: ChainId = bp_runtime::BRIDGE_HUB_ROCOCO_CHAIN_ID; + const BRIDGED_CHAIN_ID: ChainId = bp_runtime::BRIDGE_HUB_WOCOCO_CHAIN_ID; + const BRIDGED_MESSAGES_PALLET_NAME: &'static str = + bp_bridge_hub_rococo::WITH_BRIDGE_HUB_ROCOCO_MESSAGES_PALLET_NAME; + type ThisChain = BridgeHubRococo; + type BridgedChain = BridgeHubWococo; + + fn bridged_balance_to_this_balance( + bridged_balance: bridge_runtime_common::messages::BalanceOf>, + bridged_to_this_conversion_rate_override: Option, + ) -> bridge_runtime_common::messages::BalanceOf> { + log::info!("[WithBridgeHubWococoMessageBridge] bridged_balance_to_this_balance - bridged_balance: {:?}, bridged_to_this_conversion_rate_override: {:?}", bridged_balance, bridged_to_this_conversion_rate_override); + unimplemented!("TODO: WithBridgeHubWococoMessageBridge - bridged_balance_to_this_balance") + } +} + +/// Message verifier for BridgeHubWococo messages sent from BridgeHubRococo +pub type ToBridgeHubWococoMessageVerifier = + messages::source::FromThisChainMessageVerifier; + +/// Maximal outbound payload size of BridgeHubRococo -> BridgeHubWococo messages. +pub type ToBridgeHubWococoMaximalOutboundPayloadSize = + messages::source::FromThisChainMaximalOutboundPayloadSize; + +/// BridgeHubWococo chain from message lane point of view. +#[derive(RuntimeDebug, Clone, Copy)] +pub struct BridgeHubWococo; + +impl ChainWithMessages for BridgeHubWococo { + type Hash = bp_bridge_hub_wococo::Hash; + type AccountId = bp_bridge_hub_wococo::AccountId; + type Signer = bp_bridge_hub_wococo::AccountSigner; + type Signature = bp_bridge_hub_wococo::Signature; + type Weight = Weight; + type Balance = bp_bridge_hub_wococo::Balance; +} + +impl SourceHeaderChain for BridgeHubWococo { + type Error = &'static str; + type MessagesProof = FromBridgedChainMessagesProof; + + fn verify_messages_proof( + proof: Self::MessagesProof, + messages_count: u32, + ) -> Result>, Self::Error> { + bridge_runtime_common::messages::target::verify_messages_proof_from_parachain::< + WithBridgeHubWococoMessageBridge, + bp_bridge_hub_wococo::Header, + crate::Runtime, + crate::BridgeParachainWococoInstance, + >(ParaId(bp_bridge_hub_wococo::BRIDGE_HUB_WOCOCO_PARACHAIN_ID), proof, messages_count) + } +} + +impl TargetHeaderChain for BridgeHubWococo { + type Error = &'static str; + type MessagesDeliveryProof = + messages::source::FromBridgedChainMessagesDeliveryProof; + + fn verify_message(payload: &XcmAsPlainPayload) -> Result<(), Self::Error> { + messages::source::verify_chain_message::(payload) + } + + fn verify_messages_delivery_proof( + proof: Self::MessagesDeliveryProof, + ) -> Result<(LaneId, InboundLaneData), Self::Error> { + messages::source::verify_messages_delivery_proof_from_parachain::< + WithBridgeHubWococoMessageBridge, + bp_bridge_hub_wococo::Header, + crate::Runtime, + crate::BridgeParachainWococoInstance, + >(ParaId(bp_bridge_hub_wococo::BRIDGE_HUB_WOCOCO_PARACHAIN_ID), proof) + } +} + +impl messages::BridgedChainWithMessages for BridgeHubWococo { + fn maximal_extrinsic_size() -> u32 { + bp_bridge_hub_wococo::BridgeHubWococo::max_extrinsic_size() + } + + fn verify_dispatch_weight(_message_payload: &[u8]) -> bool { + true + } + + fn estimate_delivery_transaction( + message_payload: &[u8], + include_pay_dispatch_fee_cost: bool, + message_dispatch_weight: WeightOf, + ) -> MessageTransaction> { + let message_payload_len = u32::try_from(message_payload.len()).unwrap_or(u32::MAX); + let extra_bytes_in_payload = Weight::from(message_payload_len) + .saturating_sub(pallet_bridge_messages::EXPECTED_DEFAULT_MESSAGE_LENGTH.into()); + + MessageTransaction { + dispatch_weight: extra_bytes_in_payload + .saturating_mul(bp_bridge_hub_wococo::ADDITIONAL_MESSAGE_BYTE_DELIVERY_WEIGHT) + .saturating_add(bp_bridge_hub_wococo::DEFAULT_MESSAGE_DELIVERY_TX_WEIGHT) + .saturating_sub(if include_pay_dispatch_fee_cost { + 0 + } else { + bp_bridge_hub_wococo::PAY_INBOUND_DISPATCH_FEE_WEIGHT + }) + .saturating_add(message_dispatch_weight), + size: message_payload_len + .saturating_add(bp_bridge_hub_rococo::EXTRA_STORAGE_PROOF_SIZE) + .saturating_add(bp_bridge_hub_wococo::TX_EXTRA_BYTES), + } + } + + fn transaction_payment( + transaction: MessageTransaction>, + ) -> messages::BalanceOf { + log::info!( + "[BridgeHubWococo::BridgedChainWithMessages] transaction_payment - transaction: {:?}", + transaction + ); + // TODO:check-parameter - any payment? from sovereign account? + unimplemented!( + "[BridgeHubWococo/BridgedChainWithMessages] transaction_payment - transaction: {:?}", + transaction + ) + } +} + +/// BridgeHubRococo chain from message lane point of view. +#[derive(RuntimeDebug, Clone, Copy)] +pub struct BridgeHubRococo; + +impl ChainWithMessages for BridgeHubRococo { + type Hash = bp_bridge_hub_rococo::Hash; + type AccountId = bp_bridge_hub_rococo::AccountId; + type Signer = bp_bridge_hub_rococo::AccountSigner; + type Signature = bp_bridge_hub_rococo::Signature; + type Weight = Weight; + type Balance = bp_bridge_hub_rococo::Balance; +} + +impl ThisChainWithMessages for BridgeHubRococo { + type Origin = crate::Origin; + type Call = crate::Call; + type ConfirmationTransactionEstimation = BasicConfirmationTransactionEstimation< + Self::AccountId, + { bp_bridge_hub_rococo::MAX_SINGLE_MESSAGE_DELIVERY_CONFIRMATION_TX_WEIGHT }, + { bp_bridge_hub_wococo::EXTRA_STORAGE_PROOF_SIZE }, + { bp_bridge_hub_rococo::TX_EXTRA_BYTES }, + >; + + fn is_message_accepted(origin: &Self::Origin, lane: &LaneId) -> bool { + log::info!("[BridgeHubRococo::ThisChainWithMessages] is_message_accepted - origin: {:?}, lane: {:?}", origin, lane); + lane == &DEFAULT_XCM_LANE_TO_BRIDGE_HUB_WOCOCO + } + + fn maximal_pending_messages_at_outbound_lane() -> MessageNonce { + log::info!( + "[BridgeHubRococo::ThisChainWithMessages] maximal_pending_messages_at_outbound_lane" + ); + MessageNonce::MAX / 2 + } + + fn transaction_payment( + transaction: MessageTransaction>, + ) -> messages::BalanceOf { + log::info!( + "[BridgeHubRococo::ThisChainWithMessages] transaction_payment - transaction: {:?}", + transaction + ); + // TODO:check-parameter - any payment? from sovereign account? + unimplemented!( + "[BridgeHubRococo/ThisChainWithMessages] transaction_payment - transaction: {:?}", + transaction + ) + } +} diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/bridge_hub_wococo_config.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/bridge_hub_wococo_config.rs index 2a521405db..d8c874b072 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/bridge_hub_wococo_config.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/bridge_hub_wococo_config.rs @@ -14,17 +14,32 @@ // You should have received a copy of the GNU General Public License // along with Cumulus. If not, see . -use bp_messages::{source_chain::{LaneMessageVerifier, TargetHeaderChain}, target_chain::{ProvedMessages, SourceHeaderChain}, InboundLaneData, LaneId, Message, OutboundLaneData, MessageKey, MessageData}; -use bp_runtime::{BalanceOf, Chain}; -use frame_support::{parameter_types, RuntimeDebug}; -use xcm::prelude::{InteriorMultiLocation, NetworkId}; -use bp_messages::target_chain::ProvedLaneMessages; -use bridge_runtime_common::messages::target::FromBridgedChainMessagesProof; -use crate::universal_exports::{BridgeBlobDispatcher, HaulBlobExporter}; -use crate::{WithBridgeHubRococoMessagesInstance, XcmAsPlainPayload, XcmBlobHauler, XcmRouter}; -use crate::Runtime; -use crate::ParachainInfo; -use xcm::latest::prelude::*; +use crate::{ + universal_exports::{BridgeBlobDispatcher, HaulBlobExporter}, + ParachainInfo, Runtime, WithBridgeHubRococoMessagesInstance, XcmAsPlainPayload, XcmBlobHauler, + XcmRouter, +}; +use bp_messages::{ + source_chain::TargetHeaderChain, + target_chain::{ProvedMessages, SourceHeaderChain}, + InboundLaneData, LaneId, Message, MessageNonce, +}; +use bp_polkadot_core::parachains::ParaId; +use bp_runtime::{Chain, ChainId}; +use bridge_runtime_common::{ + messages, + messages::{ + target::FromBridgedChainMessagesProof, BasicConfirmationTransactionEstimation, + BridgedChain, ChainWithMessages, MessageBridge, MessageTransaction, ThisChain, + ThisChainWithMessages, WeightOf, + }, +}; +use frame_support::{dispatch::Weight, parameter_types, RuntimeDebug}; +use sp_runtime::FixedU128; +use xcm::{ + latest::prelude::*, + prelude::{InteriorMultiLocation, NetworkId}, +}; // TODO:check-parameter parameter_types! { @@ -38,15 +53,18 @@ parameter_types! { } /// Dispatches received XCM messages from other bridge -pub type OnBridgeHubWococoBlobDispatcher = BridgeBlobDispatcher; +pub type OnBridgeHubWococoBlobDispatcher = + BridgeBlobDispatcher; /// Export XCM messages to be relayed to the otherside -pub type ToBridgeHubRococoHaulBlobExporter = HaulBlobExporter; +pub type ToBridgeHubRococoHaulBlobExporter = + HaulBlobExporter; pub struct ToBridgeHubRococoXcmBlobHauler; pub const DEFAULT_XCM_LANE_TO_BRIDGE_HUB_ROCOCO: LaneId = [0, 0, 0, 1]; impl XcmBlobHauler for ToBridgeHubRococoXcmBlobHauler { type SenderChain = bp_bridge_hub_wococo::BridgeHubWococo; - type MessageSender = pallet_bridge_messages::Pallet; + type MessageSender = + pallet_bridge_messages::Pallet; fn message_sender_origin() -> InteriorMultiLocation { crate::xcm_config::UniversalLocation::get() @@ -57,3 +75,181 @@ impl XcmBlobHauler for ToBridgeHubRococoXcmBlobHauler { } } +/// Messaging Bridge configuration for BridgeHubWococo -> BridgeHubRococo +pub struct WithBridgeHubRococoMessageBridge; +impl MessageBridge for WithBridgeHubRococoMessageBridge { + // TODO:check-parameter - relayers rewards + const RELAYER_FEE_PERCENT: u32 = 0; + const THIS_CHAIN_ID: ChainId = bp_runtime::BRIDGE_HUB_WOCOCO_CHAIN_ID; + const BRIDGED_CHAIN_ID: ChainId = bp_runtime::BRIDGE_HUB_ROCOCO_CHAIN_ID; + const BRIDGED_MESSAGES_PALLET_NAME: &'static str = + bp_bridge_hub_wococo::WITH_BRIDGE_HUB_WOCOCO_MESSAGES_PALLET_NAME; + type ThisChain = BridgeHubWococo; + type BridgedChain = BridgeHubRococo; + + fn bridged_balance_to_this_balance( + bridged_balance: bridge_runtime_common::messages::BalanceOf>, + bridged_to_this_conversion_rate_override: Option, + ) -> bridge_runtime_common::messages::BalanceOf> { + log::info!("[WithBridgeHubRococoMessageBridge] bridged_balance_to_this_balance - bridged_balance: {:?}, bridged_to_this_conversion_rate_override: {:?}", bridged_balance, bridged_to_this_conversion_rate_override); + unimplemented!("TODO: WithBridgeHubRococoMessageBridge - bridged_balance_to_this_balance") + } +} + +/// Message verifier for BridgeHubRococo messages sent from BridgeHubWococo +pub type ToBridgeHubRococoMessageVerifier = + messages::source::FromThisChainMessageVerifier; + +/// Maximal outbound payload size of BridgeHubWococo -> BridgeHubRococo messages. +pub type ToBridgeHubRococoMaximalOutboundPayloadSize = + messages::source::FromThisChainMaximalOutboundPayloadSize; + +/// BridgeHubRococo chain from message lane point of view. +#[derive(RuntimeDebug, Clone, Copy)] +pub struct BridgeHubRococo; + +impl ChainWithMessages for BridgeHubRococo { + type Hash = bp_bridge_hub_rococo::Hash; + type AccountId = bp_bridge_hub_rococo::AccountId; + type Signer = bp_bridge_hub_rococo::AccountSigner; + type Signature = bp_bridge_hub_rococo::Signature; + type Weight = Weight; + type Balance = bp_bridge_hub_rococo::Balance; +} + +impl SourceHeaderChain for BridgeHubRococo { + type Error = &'static str; + type MessagesProof = FromBridgedChainMessagesProof; + + fn verify_messages_proof( + proof: Self::MessagesProof, + messages_count: u32, + ) -> Result>, Self::Error> { + bridge_runtime_common::messages::target::verify_messages_proof_from_parachain::< + WithBridgeHubRococoMessageBridge, + bp_bridge_hub_rococo::Header, + crate::Runtime, + crate::BridgeParachainRococoInstance, + >(ParaId(bp_bridge_hub_rococo::BRIDGE_HUB_ROCOCO_PARACHAIN_ID), proof, messages_count) + } +} + +impl TargetHeaderChain for BridgeHubRococo { + type Error = &'static str; + type MessagesDeliveryProof = + messages::source::FromBridgedChainMessagesDeliveryProof; + + fn verify_message(payload: &XcmAsPlainPayload) -> Result<(), Self::Error> { + messages::source::verify_chain_message::(payload) + } + + fn verify_messages_delivery_proof( + proof: Self::MessagesDeliveryProof, + ) -> Result<(LaneId, InboundLaneData), Self::Error> { + messages::source::verify_messages_delivery_proof_from_parachain::< + WithBridgeHubRococoMessageBridge, + bp_bridge_hub_rococo::Header, + crate::Runtime, + crate::BridgeParachainRococoInstance, + >(ParaId(bp_bridge_hub_rococo::BRIDGE_HUB_ROCOCO_PARACHAIN_ID), proof) + } +} + +impl messages::BridgedChainWithMessages for BridgeHubRococo { + fn maximal_extrinsic_size() -> u32 { + bp_bridge_hub_rococo::BridgeHubRococo::max_extrinsic_size() + } + + fn verify_dispatch_weight(_message_payload: &[u8]) -> bool { + true + } + + fn estimate_delivery_transaction( + message_payload: &[u8], + include_pay_dispatch_fee_cost: bool, + message_dispatch_weight: WeightOf, + ) -> MessageTransaction> { + let message_payload_len = u32::try_from(message_payload.len()).unwrap_or(u32::MAX); + let extra_bytes_in_payload = Weight::from(message_payload_len) + .saturating_sub(pallet_bridge_messages::EXPECTED_DEFAULT_MESSAGE_LENGTH.into()); + + MessageTransaction { + dispatch_weight: extra_bytes_in_payload + .saturating_mul(bp_bridge_hub_rococo::ADDITIONAL_MESSAGE_BYTE_DELIVERY_WEIGHT) + .saturating_add(bp_bridge_hub_rococo::DEFAULT_MESSAGE_DELIVERY_TX_WEIGHT) + .saturating_sub(if include_pay_dispatch_fee_cost { + 0 + } else { + bp_bridge_hub_rococo::PAY_INBOUND_DISPATCH_FEE_WEIGHT + }) + .saturating_add(message_dispatch_weight), + size: message_payload_len + .saturating_add(bp_bridge_hub_wococo::EXTRA_STORAGE_PROOF_SIZE) + .saturating_add(bp_bridge_hub_rococo::TX_EXTRA_BYTES), + } + } + + fn transaction_payment( + transaction: MessageTransaction>, + ) -> messages::BalanceOf { + log::info!( + "[BridgeHubRococo::BridgedChainWithMessages] transaction_payment - transaction: {:?}", + transaction + ); + // TODO:check-parameter - any payment? from sovereign account? + unimplemented!( + "[BridgeHubRococo/BridgedChainWithMessages] transaction_payment - transaction: {:?}", + transaction + ) + } +} + +/// BridgeHubWococo chain from message lane point of view. +#[derive(RuntimeDebug, Clone, Copy)] +pub struct BridgeHubWococo; + +impl ChainWithMessages for BridgeHubWococo { + type Hash = bp_bridge_hub_wococo::Hash; + type AccountId = bp_bridge_hub_wococo::AccountId; + type Signer = bp_bridge_hub_wococo::AccountSigner; + type Signature = bp_bridge_hub_wococo::Signature; + type Weight = Weight; + type Balance = bp_bridge_hub_wococo::Balance; +} + +impl ThisChainWithMessages for BridgeHubWococo { + type Origin = crate::Origin; + type Call = crate::Call; + type ConfirmationTransactionEstimation = BasicConfirmationTransactionEstimation< + Self::AccountId, + { bp_bridge_hub_wococo::MAX_SINGLE_MESSAGE_DELIVERY_CONFIRMATION_TX_WEIGHT }, + { bp_bridge_hub_rococo::EXTRA_STORAGE_PROOF_SIZE }, + { bp_bridge_hub_wococo::TX_EXTRA_BYTES }, + >; + + fn is_message_accepted(origin: &Self::Origin, lane: &LaneId) -> bool { + log::info!("[BridgeHubWococo::ThisChainWithMessages] is_message_accepted - origin: {:?}, lane: {:?}", origin, lane); + lane == &DEFAULT_XCM_LANE_TO_BRIDGE_HUB_ROCOCO + } + + fn maximal_pending_messages_at_outbound_lane() -> MessageNonce { + log::info!( + "[BridgeHubWococo::ThisChainWithMessages] maximal_pending_messages_at_outbound_lane" + ); + MessageNonce::MAX / 2 + } + + fn transaction_payment( + transaction: MessageTransaction>, + ) -> messages::BalanceOf { + log::info!( + "[BridgeHubWococo::ThisChainWithMessages] transaction_payment - transaction: {:?}", + transaction + ); + // TODO:check-parameter - any payment? from sovereign account? + unimplemented!( + "[BridgeHubWococo/ThisChainWithMessages] transaction_payment - transaction: {:?}", + transaction + ) + } +} diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs index 97a5d88ec2..66e3686cf6 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs @@ -68,13 +68,13 @@ use bp_runtime::{HeaderId, HeaderIdProvider}; pub use sp_runtime::BuildStorage; use polkadot_runtime_common::{BlockHashCount, SlowAdjustingFeeUpdate}; -use sp_runtime::traits::ConstU32; use weights::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight}; use crate::{ bridge_hub_rococo_config::OnBridgeHubRococoBlobDispatcher, - bridge_hub_wococo_config::OnBridgeHubWococoBlobDispatcher, xcm_config::XcmRouter, + bridge_hub_wococo_config::OnBridgeHubWococoBlobDispatcher, + xcm_config::XcmRouter, }; use parachains_common::{AccountId, Signature}; use xcm::latest::prelude::BodyId; @@ -565,22 +565,21 @@ impl pallet_bridge_messages::Config for Run type MaxUnconfirmedMessagesAtInboundLane = bridge_hub_rococo_config::MaxUnconfirmedMessagesAtInboundLane; - type MaximalOutboundPayloadSize = (); + type MaximalOutboundPayloadSize = bridge_hub_rococo_config::ToBridgeHubWococoMaximalOutboundPayloadSize; type OutboundPayload = XcmAsPlainPayload; - type OutboundMessageFee = crate::Balance; /* bp_bridge_hub_rococo::Balance */ + type OutboundMessageFee = Balance; type InboundPayload = XcmAsPlainPayload; - type InboundMessageFee = crate::Balance; /* bp_bridge_hub_wococo::Balance */ - type InboundRelayer = crate::AccountId; /* bp_bridge_hub_wococo::AccountId */ + type InboundMessageFee = Balance; + type InboundRelayer = AccountId; - type TargetHeaderChain = bridge_config::BridgeHubWococoMessagingSupport; - type LaneMessageVerifier = bridge_config::ToBridgeHubWococoMessageVerifier; - // TODO:check-parameter - add because of rewards? + type TargetHeaderChain = bridge_hub_rococo_config::BridgeHubWococo; + type LaneMessageVerifier = bridge_hub_rococo_config::ToBridgeHubWococoMessageVerifier; type MessageDeliveryAndDispatchPayment = (); type OnMessageAccepted = (); type OnDeliveryConfirmed = (); - type SourceHeaderChain = bridge_config::BridgeHubWococoMessagingSupport; + type SourceHeaderChain = bridge_hub_rococo_config::BridgeHubWococo; type MessageDispatch = XcmBlobMessageDispatch< bp_bridge_hub_wococo::BridgeHubWococo, bp_bridge_hub_rococo::BridgeHubRococo, @@ -602,22 +601,21 @@ impl pallet_bridge_messages::Config for Run type MaxUnconfirmedMessagesAtInboundLane = bridge_hub_wococo_config::MaxUnconfirmedMessagesAtInboundLane; - type MaximalOutboundPayloadSize = (); + type MaximalOutboundPayloadSize = bridge_hub_wococo_config::ToBridgeHubRococoMaximalOutboundPayloadSize; type OutboundPayload = XcmAsPlainPayload; - type OutboundMessageFee = crate::Balance; /* bp_bridge_hub_wococo::Balance */ + type OutboundMessageFee = Balance; type InboundPayload = XcmAsPlainPayload; - type InboundMessageFee = crate::Balance; /* bp_bridge_hub_rococo::Balance */ - type InboundRelayer = crate::AccountId; /* bp_bridge_hub_rococo::AccountId */ + type InboundMessageFee = Balance; + type InboundRelayer = AccountId; - type TargetHeaderChain = bridge_config::BridgeHubRococoMessagingSupport; - type LaneMessageVerifier = bridge_config::ToBridgeHubRococoMessageVerifier; - // TODO:check-parameter - add because of rewards? + type TargetHeaderChain = bridge_hub_wococo_config::BridgeHubRococo; + type LaneMessageVerifier = bridge_hub_wococo_config::ToBridgeHubRococoMessageVerifier; type MessageDeliveryAndDispatchPayment = (); type OnMessageAccepted = (); type OnDeliveryConfirmed = (); - type SourceHeaderChain = bridge_config::BridgeHubRococoMessagingSupport; + type SourceHeaderChain = bridge_hub_wococo_config::BridgeHubRococo; type MessageDispatch = XcmBlobMessageDispatch< bp_bridge_hub_rococo::BridgeHubRococo, bp_bridge_hub_wococo::BridgeHubWococo,