mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-17 10:11:03 +00:00
[BridgeHub] Init stuff for bridge messaging
This commit is contained in:
@@ -55,7 +55,7 @@ impl<
|
||||
message: &mut DispatchMessage<Self::DispatchPayload, BalanceOf<TargetBridgeHubChain>>,
|
||||
) -> 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
|
||||
}
|
||||
|
||||
+212
-15
@@ -14,17 +14,32 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
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<XcmRouter, BridgeHubRococoUniversalLocation>;
|
||||
pub type OnBridgeHubRococoBlobDispatcher =
|
||||
BridgeBlobDispatcher<XcmRouter, BridgeHubRococoUniversalLocation>;
|
||||
|
||||
/// Export XCM messages to be relayed to the otherside
|
||||
pub type ToBridgeHubWococoHaulBlobExporter = HaulBlobExporter<ToBridgeHubWococoXcmBlobHauler, WococoGlobalConsensusNetwork, ()>;
|
||||
pub type ToBridgeHubWococoHaulBlobExporter =
|
||||
HaulBlobExporter<ToBridgeHubWococoXcmBlobHauler, WococoGlobalConsensusNetwork, ()>;
|
||||
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<Runtime, WithBridgeHubWococoMessagesInstance>;
|
||||
type MessageSender =
|
||||
pallet_bridge_messages::Pallet<Runtime, WithBridgeHubWococoMessagesInstance>;
|
||||
|
||||
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<BridgedChain<Self>>,
|
||||
bridged_to_this_conversion_rate_override: Option<FixedU128>,
|
||||
) -> bridge_runtime_common::messages::BalanceOf<ThisChain<Self>> {
|
||||
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<WithBridgeHubWococoMessageBridge>;
|
||||
|
||||
/// Maximal outbound payload size of BridgeHubRococo -> BridgeHubWococo messages.
|
||||
pub type ToBridgeHubWococoMaximalOutboundPayloadSize =
|
||||
messages::source::FromThisChainMaximalOutboundPayloadSize<WithBridgeHubWococoMessageBridge>;
|
||||
|
||||
/// 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<crate::Balance> for BridgeHubWococo {
|
||||
type Error = &'static str;
|
||||
type MessagesProof = FromBridgedChainMessagesProof<crate::Hash>;
|
||||
|
||||
fn verify_messages_proof(
|
||||
proof: Self::MessagesProof,
|
||||
messages_count: u32,
|
||||
) -> Result<ProvedMessages<Message<crate::Balance>>, 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<XcmAsPlainPayload, crate::AccountId> for BridgeHubWococo {
|
||||
type Error = &'static str;
|
||||
type MessagesDeliveryProof =
|
||||
messages::source::FromBridgedChainMessagesDeliveryProof<bp_bridge_hub_wococo::Hash>;
|
||||
|
||||
fn verify_message(payload: &XcmAsPlainPayload) -> Result<(), Self::Error> {
|
||||
messages::source::verify_chain_message::<WithBridgeHubWococoMessageBridge>(payload)
|
||||
}
|
||||
|
||||
fn verify_messages_delivery_proof(
|
||||
proof: Self::MessagesDeliveryProof,
|
||||
) -> Result<(LaneId, InboundLaneData<bp_bridge_hub_rococo::AccountId>), 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<Self>,
|
||||
) -> MessageTransaction<WeightOf<Self>> {
|
||||
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<WeightOf<Self>>,
|
||||
) -> messages::BalanceOf<Self> {
|
||||
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<WeightOf<Self>>,
|
||||
) -> messages::BalanceOf<Self> {
|
||||
log::info!(
|
||||
"[BridgeHubRococo::ThisChainWithMessages] transaction_payment - transaction: {:?}",
|
||||
transaction
|
||||
);
|
||||
// TODO:check-parameter - any payment? from sovereign account?
|
||||
unimplemented!(
|
||||
"[BridgeHubRococo/ThisChainWithMessages] transaction_payment - transaction: {:?}",
|
||||
transaction
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
+210
-14
@@ -14,17 +14,32 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
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<XcmRouter, BridgeHubWococoUniversalLocation>;
|
||||
pub type OnBridgeHubWococoBlobDispatcher =
|
||||
BridgeBlobDispatcher<XcmRouter, BridgeHubWococoUniversalLocation>;
|
||||
|
||||
/// Export XCM messages to be relayed to the otherside
|
||||
pub type ToBridgeHubRococoHaulBlobExporter = HaulBlobExporter<ToBridgeHubRococoXcmBlobHauler, RococoGlobalConsensusNetwork, ()>;
|
||||
pub type ToBridgeHubRococoHaulBlobExporter =
|
||||
HaulBlobExporter<ToBridgeHubRococoXcmBlobHauler, RococoGlobalConsensusNetwork, ()>;
|
||||
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<Runtime, WithBridgeHubRococoMessagesInstance>;
|
||||
type MessageSender =
|
||||
pallet_bridge_messages::Pallet<Runtime, WithBridgeHubRococoMessagesInstance>;
|
||||
|
||||
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<BridgedChain<Self>>,
|
||||
bridged_to_this_conversion_rate_override: Option<FixedU128>,
|
||||
) -> bridge_runtime_common::messages::BalanceOf<ThisChain<Self>> {
|
||||
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<WithBridgeHubRococoMessageBridge>;
|
||||
|
||||
/// Maximal outbound payload size of BridgeHubWococo -> BridgeHubRococo messages.
|
||||
pub type ToBridgeHubRococoMaximalOutboundPayloadSize =
|
||||
messages::source::FromThisChainMaximalOutboundPayloadSize<WithBridgeHubRococoMessageBridge>;
|
||||
|
||||
/// 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<crate::Balance> for BridgeHubRococo {
|
||||
type Error = &'static str;
|
||||
type MessagesProof = FromBridgedChainMessagesProof<crate::Hash>;
|
||||
|
||||
fn verify_messages_proof(
|
||||
proof: Self::MessagesProof,
|
||||
messages_count: u32,
|
||||
) -> Result<ProvedMessages<Message<crate::Balance>>, 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<XcmAsPlainPayload, crate::AccountId> for BridgeHubRococo {
|
||||
type Error = &'static str;
|
||||
type MessagesDeliveryProof =
|
||||
messages::source::FromBridgedChainMessagesDeliveryProof<bp_bridge_hub_rococo::Hash>;
|
||||
|
||||
fn verify_message(payload: &XcmAsPlainPayload) -> Result<(), Self::Error> {
|
||||
messages::source::verify_chain_message::<WithBridgeHubRococoMessageBridge>(payload)
|
||||
}
|
||||
|
||||
fn verify_messages_delivery_proof(
|
||||
proof: Self::MessagesDeliveryProof,
|
||||
) -> Result<(LaneId, InboundLaneData<bp_bridge_hub_wococo::AccountId>), 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<Self>,
|
||||
) -> MessageTransaction<WeightOf<Self>> {
|
||||
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<WeightOf<Self>>,
|
||||
) -> messages::BalanceOf<Self> {
|
||||
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<WeightOf<Self>>,
|
||||
) -> messages::BalanceOf<Self> {
|
||||
log::info!(
|
||||
"[BridgeHubWococo::ThisChainWithMessages] transaction_payment - transaction: {:?}",
|
||||
transaction
|
||||
);
|
||||
// TODO:check-parameter - any payment? from sovereign account?
|
||||
unimplemented!(
|
||||
"[BridgeHubWococo/ThisChainWithMessages] transaction_payment - transaction: {:?}",
|
||||
transaction
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<WithBridgeHubWococoMessagesInstance> 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<Self::Origin, bp_bridge_hub_rococo::BridgeHubRococo>;
|
||||
// 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<WithBridgeHubRococoMessagesInstance> 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<Self::Origin, bp_bridge_hub_wococo::BridgeHubWococo>;
|
||||
// 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,
|
||||
|
||||
Reference in New Issue
Block a user