mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-18 01:15:44 +00:00
Removed relayer_account: &AccountId from MessageDispatch (#2080)
* SourceBridgeHubChain/TargetBridgeHubChain replaced with RelayerAccountChain * Fix * Removed `relayer_account: &AccountId` from `MessageDispatch`
This commit is contained in:
committed by
Bastian Köcher
parent
1f8b4d989e
commit
db53d68e9b
@@ -64,8 +64,6 @@ pub type ToRialtoMessagesDeliveryProof =
|
|||||||
/// Call-dispatch based message dispatch for Rialto -> Millau messages.
|
/// Call-dispatch based message dispatch for Rialto -> Millau messages.
|
||||||
pub type FromRialtoMessageDispatch =
|
pub type FromRialtoMessageDispatch =
|
||||||
bridge_runtime_common::messages_xcm_extension::XcmBlobMessageDispatch<
|
bridge_runtime_common::messages_xcm_extension::XcmBlobMessageDispatch<
|
||||||
bp_millau::Millau,
|
|
||||||
bp_rialto::Rialto,
|
|
||||||
crate::xcm_config::OnMillauBlobDispatcher,
|
crate::xcm_config::OnMillauBlobDispatcher,
|
||||||
(),
|
(),
|
||||||
>;
|
>;
|
||||||
|
|||||||
@@ -59,8 +59,6 @@ pub type FromRialtoParachainMessagePayload = messages::target::FromBridgedChainM
|
|||||||
/// Call-dispatch based message dispatch for RialtoParachain -> Millau messages.
|
/// Call-dispatch based message dispatch for RialtoParachain -> Millau messages.
|
||||||
pub type FromRialtoParachainMessageDispatch =
|
pub type FromRialtoParachainMessageDispatch =
|
||||||
bridge_runtime_common::messages_xcm_extension::XcmBlobMessageDispatch<
|
bridge_runtime_common::messages_xcm_extension::XcmBlobMessageDispatch<
|
||||||
bp_millau::Millau,
|
|
||||||
bp_rialto::Rialto,
|
|
||||||
crate::xcm_config::OnMillauBlobDispatcher,
|
crate::xcm_config::OnMillauBlobDispatcher,
|
||||||
(),
|
(),
|
||||||
>;
|
>;
|
||||||
|
|||||||
@@ -349,8 +349,7 @@ mod tests {
|
|||||||
|
|
||||||
// we care only about handing message to the XCM dispatcher, so we don't care about its
|
// we care only about handing message to the XCM dispatcher, so we don't care about its
|
||||||
// actual dispatch
|
// actual dispatch
|
||||||
let dispatch_result =
|
let dispatch_result = FromRialtoMessageDispatch::dispatch(incoming_message);
|
||||||
FromRialtoMessageDispatch::dispatch(&AccountId::from([0u8; 32]), incoming_message);
|
|
||||||
assert!(matches!(
|
assert!(matches!(
|
||||||
dispatch_result.dispatch_level_result,
|
dispatch_result.dispatch_level_result,
|
||||||
XcmBlobMessageDispatchResult::NotDispatched(_),
|
XcmBlobMessageDispatchResult::NotDispatched(_),
|
||||||
@@ -363,8 +362,7 @@ mod tests {
|
|||||||
|
|
||||||
// we care only about handing message to the XCM dispatcher, so we don't care about its
|
// we care only about handing message to the XCM dispatcher, so we don't care about its
|
||||||
// actual dispatch
|
// actual dispatch
|
||||||
let dispatch_result =
|
let dispatch_result = FromRialtoMessageDispatch::dispatch(incoming_message);
|
||||||
FromRialtoMessageDispatch::dispatch(&AccountId::from([0u8; 32]), incoming_message);
|
|
||||||
assert!(matches!(
|
assert!(matches!(
|
||||||
dispatch_result.dispatch_level_result,
|
dispatch_result.dispatch_level_result,
|
||||||
XcmBlobMessageDispatchResult::NotDispatched(_),
|
XcmBlobMessageDispatchResult::NotDispatched(_),
|
||||||
|
|||||||
@@ -926,8 +926,7 @@ mod tests {
|
|||||||
|
|
||||||
// we care only about handing message to the XCM dispatcher, so we don't care about its
|
// we care only about handing message to the XCM dispatcher, so we don't care about its
|
||||||
// actual dispatch
|
// actual dispatch
|
||||||
let dispatch_result =
|
let dispatch_result = FromMillauMessageDispatch::dispatch(incoming_message);
|
||||||
FromMillauMessageDispatch::dispatch(&AccountId::from([0u8; 32]), incoming_message);
|
|
||||||
assert!(matches!(
|
assert!(matches!(
|
||||||
dispatch_result.dispatch_level_result,
|
dispatch_result.dispatch_level_result,
|
||||||
XcmBlobMessageDispatchResult::NotDispatched(_),
|
XcmBlobMessageDispatchResult::NotDispatched(_),
|
||||||
|
|||||||
@@ -60,8 +60,6 @@ pub type FromMillauMessagePayload = messages::target::FromBridgedChainMessagePay
|
|||||||
/// Call-dispatch based message dispatch for Millau -> RialtoParachain messages.
|
/// Call-dispatch based message dispatch for Millau -> RialtoParachain messages.
|
||||||
pub type FromMillauMessageDispatch =
|
pub type FromMillauMessageDispatch =
|
||||||
bridge_runtime_common::messages_xcm_extension::XcmBlobMessageDispatch<
|
bridge_runtime_common::messages_xcm_extension::XcmBlobMessageDispatch<
|
||||||
bp_rialto_parachain::RialtoParachain,
|
|
||||||
bp_millau::Millau,
|
|
||||||
crate::OnRialtoParachainBlobDispatcher,
|
crate::OnRialtoParachainBlobDispatcher,
|
||||||
(),
|
(),
|
||||||
>;
|
>;
|
||||||
|
|||||||
@@ -57,8 +57,6 @@ pub type FromMillauMessagePayload = messages::target::FromBridgedChainMessagePay
|
|||||||
/// Call-dispatch based message dispatch for Millau -> Rialto messages.
|
/// Call-dispatch based message dispatch for Millau -> Rialto messages.
|
||||||
pub type FromMillauMessageDispatch =
|
pub type FromMillauMessageDispatch =
|
||||||
bridge_runtime_common::messages_xcm_extension::XcmBlobMessageDispatch<
|
bridge_runtime_common::messages_xcm_extension::XcmBlobMessageDispatch<
|
||||||
bp_rialto::Rialto,
|
|
||||||
bp_millau::Millau,
|
|
||||||
crate::xcm_config::OnRialtoBlobDispatcher,
|
crate::xcm_config::OnRialtoBlobDispatcher,
|
||||||
(),
|
(),
|
||||||
>;
|
>;
|
||||||
|
|||||||
@@ -266,8 +266,7 @@ mod tests {
|
|||||||
|
|
||||||
// we care only about handing message to the XCM dispatcher, so we don't care about its
|
// we care only about handing message to the XCM dispatcher, so we don't care about its
|
||||||
// actual dispatch
|
// actual dispatch
|
||||||
let dispatch_result =
|
let dispatch_result = FromMillauMessageDispatch::dispatch(incoming_message);
|
||||||
FromMillauMessageDispatch::dispatch(&AccountId::from([0u8; 32]), incoming_message);
|
|
||||||
assert!(matches!(
|
assert!(matches!(
|
||||||
dispatch_result.dispatch_level_result,
|
dispatch_result.dispatch_level_result,
|
||||||
XcmBlobMessageDispatchResult::NotDispatched(_),
|
XcmBlobMessageDispatchResult::NotDispatched(_),
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ use bp_messages::{
|
|||||||
target_chain::{DispatchMessage, MessageDispatch},
|
target_chain::{DispatchMessage, MessageDispatch},
|
||||||
LaneId,
|
LaneId,
|
||||||
};
|
};
|
||||||
use bp_runtime::{messages::MessageDispatchResult, AccountIdOf, Chain};
|
use bp_runtime::messages::MessageDispatchResult;
|
||||||
use codec::{Decode, Encode};
|
use codec::{Decode, Encode};
|
||||||
use frame_support::{dispatch::Weight, CloneNoBound, EqNoBound, PartialEqNoBound};
|
use frame_support::{dispatch::Weight, CloneNoBound, EqNoBound, PartialEqNoBound};
|
||||||
use pallet_bridge_messages::WeightInfoExt as MessagesPalletWeights;
|
use pallet_bridge_messages::WeightInfoExt as MessagesPalletWeights;
|
||||||
@@ -46,23 +46,12 @@ pub enum XcmBlobMessageDispatchResult {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// [`XcmBlobMessageDispatch`] is responsible for dispatching received messages
|
/// [`XcmBlobMessageDispatch`] is responsible for dispatching received messages
|
||||||
pub struct XcmBlobMessageDispatch<SourceBridgeHubChain, TargetBridgeHubChain, DispatchBlob, Weights>
|
pub struct XcmBlobMessageDispatch<DispatchBlob, Weights> {
|
||||||
{
|
_marker: sp_std::marker::PhantomData<(DispatchBlob, Weights)>,
|
||||||
_marker: sp_std::marker::PhantomData<(
|
|
||||||
SourceBridgeHubChain,
|
|
||||||
TargetBridgeHubChain,
|
|
||||||
DispatchBlob,
|
|
||||||
Weights,
|
|
||||||
)>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<
|
impl<BlobDispatcher: DispatchBlob, Weights: MessagesPalletWeights> MessageDispatch
|
||||||
SourceBridgeHubChain: Chain,
|
for XcmBlobMessageDispatch<BlobDispatcher, Weights>
|
||||||
TargetBridgeHubChain: Chain,
|
|
||||||
BlobDispatcher: DispatchBlob,
|
|
||||||
Weights: MessagesPalletWeights,
|
|
||||||
> MessageDispatch<AccountIdOf<SourceBridgeHubChain>>
|
|
||||||
for XcmBlobMessageDispatch<SourceBridgeHubChain, TargetBridgeHubChain, BlobDispatcher, Weights>
|
|
||||||
{
|
{
|
||||||
type DispatchPayload = XcmAsPlainPayload;
|
type DispatchPayload = XcmAsPlainPayload;
|
||||||
type DispatchLevelResult = XcmBlobMessageDispatchResult;
|
type DispatchLevelResult = XcmBlobMessageDispatchResult;
|
||||||
@@ -78,7 +67,6 @@ impl<
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn dispatch(
|
fn dispatch(
|
||||||
_relayer_account: &AccountIdOf<SourceBridgeHubChain>,
|
|
||||||
message: DispatchMessage<Self::DispatchPayload>,
|
message: DispatchMessage<Self::DispatchPayload>,
|
||||||
) -> MessageDispatchResult<Self::DispatchLevelResult> {
|
) -> MessageDispatchResult<Self::DispatchLevelResult> {
|
||||||
let payload = match message.data.payload {
|
let payload = match message.data.payload {
|
||||||
|
|||||||
@@ -834,6 +834,7 @@ mod tests {
|
|||||||
run_test(|| {
|
run_test(|| {
|
||||||
assert_eq!(BestFinalized::<TestRuntime>::get(), None,);
|
assert_eq!(BestFinalized::<TestRuntime>::get(), None,);
|
||||||
assert_eq!(Pallet::<TestRuntime>::best_finalized(), None);
|
assert_eq!(Pallet::<TestRuntime>::best_finalized(), None);
|
||||||
|
assert_eq!(PalletOperatingMode::<TestRuntime>::try_get(), Err(()));
|
||||||
|
|
||||||
let init_data = init_with_origin(RuntimeOrigin::root()).unwrap();
|
let init_data = init_with_origin(RuntimeOrigin::root()).unwrap();
|
||||||
|
|
||||||
@@ -843,7 +844,10 @@ mod tests {
|
|||||||
CurrentAuthoritySet::<TestRuntime>::get().authorities,
|
CurrentAuthoritySet::<TestRuntime>::get().authorities,
|
||||||
init_data.authority_list
|
init_data.authority_list
|
||||||
);
|
);
|
||||||
assert_eq!(PalletOperatingMode::<TestRuntime>::get(), BasicOperatingMode::Normal);
|
assert_eq!(
|
||||||
|
PalletOperatingMode::<TestRuntime>::try_get(),
|
||||||
|
Ok(BasicOperatingMode::Normal)
|
||||||
|
);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -164,10 +164,9 @@ impl<S: InboundLaneStorage> InboundLane<S> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Receive new message.
|
/// Receive new message.
|
||||||
pub fn receive_message<Dispatch: MessageDispatch<AccountId>, AccountId>(
|
pub fn receive_message<Dispatch: MessageDispatch>(
|
||||||
&mut self,
|
&mut self,
|
||||||
relayer_at_bridged_chain: &S::Relayer,
|
relayer_at_bridged_chain: &S::Relayer,
|
||||||
relayer_at_this_chain: &AccountId,
|
|
||||||
nonce: MessageNonce,
|
nonce: MessageNonce,
|
||||||
message_data: DispatchMessageData<Dispatch::DispatchPayload>,
|
message_data: DispatchMessageData<Dispatch::DispatchPayload>,
|
||||||
) -> ReceivalResult<Dispatch::DispatchLevelResult> {
|
) -> ReceivalResult<Dispatch::DispatchLevelResult> {
|
||||||
@@ -189,13 +188,10 @@ impl<S: InboundLaneStorage> InboundLane<S> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// then, dispatch message
|
// then, dispatch message
|
||||||
let dispatch_result = Dispatch::dispatch(
|
let dispatch_result = Dispatch::dispatch(DispatchMessage {
|
||||||
relayer_at_this_chain,
|
key: MessageKey { lane_id: self.storage.id(), nonce },
|
||||||
DispatchMessage {
|
data: message_data,
|
||||||
key: MessageKey { lane_id: self.storage.id(), nonce },
|
});
|
||||||
data: message_data,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
// now let's update inbound lane storage
|
// now let's update inbound lane storage
|
||||||
match data.relayers.back_mut() {
|
match data.relayers.back_mut() {
|
||||||
@@ -234,8 +230,7 @@ mod tests {
|
|||||||
nonce: MessageNonce,
|
nonce: MessageNonce,
|
||||||
) {
|
) {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
lane.receive_message::<TestMessageDispatch, _>(
|
lane.receive_message::<TestMessageDispatch>(
|
||||||
&TEST_RELAYER_A,
|
|
||||||
&TEST_RELAYER_A,
|
&TEST_RELAYER_A,
|
||||||
nonce,
|
nonce,
|
||||||
inbound_message_data(REGULAR_PAYLOAD)
|
inbound_message_data(REGULAR_PAYLOAD)
|
||||||
@@ -362,8 +357,7 @@ mod tests {
|
|||||||
run_test(|| {
|
run_test(|| {
|
||||||
let mut lane = inbound_lane::<TestRuntime, _>(TEST_LANE_ID);
|
let mut lane = inbound_lane::<TestRuntime, _>(TEST_LANE_ID);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
lane.receive_message::<TestMessageDispatch, _>(
|
lane.receive_message::<TestMessageDispatch>(
|
||||||
&TEST_RELAYER_A,
|
|
||||||
&TEST_RELAYER_A,
|
&TEST_RELAYER_A,
|
||||||
10,
|
10,
|
||||||
inbound_message_data(REGULAR_PAYLOAD)
|
inbound_message_data(REGULAR_PAYLOAD)
|
||||||
@@ -382,8 +376,7 @@ mod tests {
|
|||||||
<TestRuntime as Config>::MaxUnrewardedRelayerEntriesAtInboundLane::get();
|
<TestRuntime as Config>::MaxUnrewardedRelayerEntriesAtInboundLane::get();
|
||||||
for current_nonce in 1..max_nonce + 1 {
|
for current_nonce in 1..max_nonce + 1 {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
lane.receive_message::<TestMessageDispatch, _>(
|
lane.receive_message::<TestMessageDispatch>(
|
||||||
&(TEST_RELAYER_A + current_nonce),
|
|
||||||
&(TEST_RELAYER_A + current_nonce),
|
&(TEST_RELAYER_A + current_nonce),
|
||||||
current_nonce,
|
current_nonce,
|
||||||
inbound_message_data(REGULAR_PAYLOAD)
|
inbound_message_data(REGULAR_PAYLOAD)
|
||||||
@@ -393,8 +386,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
// Fails to dispatch new message from different than latest relayer.
|
// Fails to dispatch new message from different than latest relayer.
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
lane.receive_message::<TestMessageDispatch, _>(
|
lane.receive_message::<TestMessageDispatch>(
|
||||||
&(TEST_RELAYER_A + max_nonce + 1),
|
|
||||||
&(TEST_RELAYER_A + max_nonce + 1),
|
&(TEST_RELAYER_A + max_nonce + 1),
|
||||||
max_nonce + 1,
|
max_nonce + 1,
|
||||||
inbound_message_data(REGULAR_PAYLOAD)
|
inbound_message_data(REGULAR_PAYLOAD)
|
||||||
@@ -403,8 +395,7 @@ mod tests {
|
|||||||
);
|
);
|
||||||
// Fails to dispatch new messages from latest relayer. Prevents griefing attacks.
|
// Fails to dispatch new messages from latest relayer. Prevents griefing attacks.
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
lane.receive_message::<TestMessageDispatch, _>(
|
lane.receive_message::<TestMessageDispatch>(
|
||||||
&(TEST_RELAYER_A + max_nonce),
|
|
||||||
&(TEST_RELAYER_A + max_nonce),
|
&(TEST_RELAYER_A + max_nonce),
|
||||||
max_nonce + 1,
|
max_nonce + 1,
|
||||||
inbound_message_data(REGULAR_PAYLOAD)
|
inbound_message_data(REGULAR_PAYLOAD)
|
||||||
@@ -421,8 +412,7 @@ mod tests {
|
|||||||
let max_nonce = <TestRuntime as Config>::MaxUnconfirmedMessagesAtInboundLane::get();
|
let max_nonce = <TestRuntime as Config>::MaxUnconfirmedMessagesAtInboundLane::get();
|
||||||
for current_nonce in 1..=max_nonce {
|
for current_nonce in 1..=max_nonce {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
lane.receive_message::<TestMessageDispatch, _>(
|
lane.receive_message::<TestMessageDispatch>(
|
||||||
&TEST_RELAYER_A,
|
|
||||||
&TEST_RELAYER_A,
|
&TEST_RELAYER_A,
|
||||||
current_nonce,
|
current_nonce,
|
||||||
inbound_message_data(REGULAR_PAYLOAD)
|
inbound_message_data(REGULAR_PAYLOAD)
|
||||||
@@ -432,8 +422,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
// Fails to dispatch new message from different than latest relayer.
|
// Fails to dispatch new message from different than latest relayer.
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
lane.receive_message::<TestMessageDispatch, _>(
|
lane.receive_message::<TestMessageDispatch>(
|
||||||
&TEST_RELAYER_B,
|
|
||||||
&TEST_RELAYER_B,
|
&TEST_RELAYER_B,
|
||||||
max_nonce + 1,
|
max_nonce + 1,
|
||||||
inbound_message_data(REGULAR_PAYLOAD)
|
inbound_message_data(REGULAR_PAYLOAD)
|
||||||
@@ -442,8 +431,7 @@ mod tests {
|
|||||||
);
|
);
|
||||||
// Fails to dispatch new messages from latest relayer.
|
// Fails to dispatch new messages from latest relayer.
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
lane.receive_message::<TestMessageDispatch, _>(
|
lane.receive_message::<TestMessageDispatch>(
|
||||||
&TEST_RELAYER_A,
|
|
||||||
&TEST_RELAYER_A,
|
&TEST_RELAYER_A,
|
||||||
max_nonce + 1,
|
max_nonce + 1,
|
||||||
inbound_message_data(REGULAR_PAYLOAD)
|
inbound_message_data(REGULAR_PAYLOAD)
|
||||||
@@ -458,8 +446,7 @@ mod tests {
|
|||||||
run_test(|| {
|
run_test(|| {
|
||||||
let mut lane = inbound_lane::<TestRuntime, _>(TEST_LANE_ID);
|
let mut lane = inbound_lane::<TestRuntime, _>(TEST_LANE_ID);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
lane.receive_message::<TestMessageDispatch, _>(
|
lane.receive_message::<TestMessageDispatch>(
|
||||||
&TEST_RELAYER_A,
|
|
||||||
&TEST_RELAYER_A,
|
&TEST_RELAYER_A,
|
||||||
1,
|
1,
|
||||||
inbound_message_data(REGULAR_PAYLOAD)
|
inbound_message_data(REGULAR_PAYLOAD)
|
||||||
@@ -467,8 +454,7 @@ mod tests {
|
|||||||
ReceivalResult::Dispatched(dispatch_result(0))
|
ReceivalResult::Dispatched(dispatch_result(0))
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
lane.receive_message::<TestMessageDispatch, _>(
|
lane.receive_message::<TestMessageDispatch>(
|
||||||
&TEST_RELAYER_B,
|
|
||||||
&TEST_RELAYER_B,
|
&TEST_RELAYER_B,
|
||||||
2,
|
2,
|
||||||
inbound_message_data(REGULAR_PAYLOAD)
|
inbound_message_data(REGULAR_PAYLOAD)
|
||||||
@@ -476,8 +462,7 @@ mod tests {
|
|||||||
ReceivalResult::Dispatched(dispatch_result(0))
|
ReceivalResult::Dispatched(dispatch_result(0))
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
lane.receive_message::<TestMessageDispatch, _>(
|
lane.receive_message::<TestMessageDispatch>(
|
||||||
&TEST_RELAYER_A,
|
|
||||||
&TEST_RELAYER_A,
|
&TEST_RELAYER_A,
|
||||||
3,
|
3,
|
||||||
inbound_message_data(REGULAR_PAYLOAD)
|
inbound_message_data(REGULAR_PAYLOAD)
|
||||||
@@ -500,8 +485,7 @@ mod tests {
|
|||||||
run_test(|| {
|
run_test(|| {
|
||||||
let mut lane = inbound_lane::<TestRuntime, _>(TEST_LANE_ID);
|
let mut lane = inbound_lane::<TestRuntime, _>(TEST_LANE_ID);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
lane.receive_message::<TestMessageDispatch, _>(
|
lane.receive_message::<TestMessageDispatch>(
|
||||||
&TEST_RELAYER_A,
|
|
||||||
&TEST_RELAYER_A,
|
&TEST_RELAYER_A,
|
||||||
1,
|
1,
|
||||||
inbound_message_data(REGULAR_PAYLOAD)
|
inbound_message_data(REGULAR_PAYLOAD)
|
||||||
@@ -509,8 +493,7 @@ mod tests {
|
|||||||
ReceivalResult::Dispatched(dispatch_result(0))
|
ReceivalResult::Dispatched(dispatch_result(0))
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
lane.receive_message::<TestMessageDispatch, _>(
|
lane.receive_message::<TestMessageDispatch>(
|
||||||
&TEST_RELAYER_B,
|
|
||||||
&TEST_RELAYER_B,
|
&TEST_RELAYER_B,
|
||||||
1,
|
1,
|
||||||
inbound_message_data(REGULAR_PAYLOAD)
|
inbound_message_data(REGULAR_PAYLOAD)
|
||||||
@@ -536,8 +519,7 @@ mod tests {
|
|||||||
let mut payload = REGULAR_PAYLOAD;
|
let mut payload = REGULAR_PAYLOAD;
|
||||||
*payload.dispatch_result.unspent_weight.ref_time_mut() = 1;
|
*payload.dispatch_result.unspent_weight.ref_time_mut() = 1;
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
lane.receive_message::<TestMessageDispatch, _>(
|
lane.receive_message::<TestMessageDispatch>(
|
||||||
&TEST_RELAYER_A,
|
|
||||||
&TEST_RELAYER_A,
|
&TEST_RELAYER_A,
|
||||||
1,
|
1,
|
||||||
inbound_message_data(payload)
|
inbound_message_data(payload)
|
||||||
|
|||||||
@@ -162,10 +162,7 @@ pub mod pallet {
|
|||||||
/// Source header chain, as it is represented on target chain.
|
/// Source header chain, as it is represented on target chain.
|
||||||
type SourceHeaderChain: SourceHeaderChain;
|
type SourceHeaderChain: SourceHeaderChain;
|
||||||
/// Message dispatch.
|
/// Message dispatch.
|
||||||
type MessageDispatch: MessageDispatch<
|
type MessageDispatch: MessageDispatch<DispatchPayload = Self::InboundPayload>;
|
||||||
Self::AccountId,
|
|
||||||
DispatchPayload = Self::InboundPayload,
|
|
||||||
>;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Shortcut to messages proof type for Config.
|
/// Shortcut to messages proof type for Config.
|
||||||
@@ -361,9 +358,8 @@ pub mod pallet {
|
|||||||
fail!(Error::<T, I>::InsufficientDispatchWeight);
|
fail!(Error::<T, I>::InsufficientDispatchWeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
let receival_result = lane.receive_message::<T::MessageDispatch, T::AccountId>(
|
let receival_result = lane.receive_message::<T::MessageDispatch>(
|
||||||
&relayer_id_at_bridged_chain,
|
&relayer_id_at_bridged_chain,
|
||||||
&relayer_id_at_this_chain,
|
|
||||||
message.key.nonce,
|
message.key.nonce,
|
||||||
message.data,
|
message.data,
|
||||||
);
|
);
|
||||||
@@ -545,11 +541,7 @@ pub mod pallet {
|
|||||||
MessageAccepted { lane_id: LaneId, nonce: MessageNonce },
|
MessageAccepted { lane_id: LaneId, nonce: MessageNonce },
|
||||||
/// Messages have been received from the bridged chain.
|
/// Messages have been received from the bridged chain.
|
||||||
MessagesReceived(
|
MessagesReceived(
|
||||||
Vec<
|
Vec<ReceivedMessages<<T::MessageDispatch as MessageDispatch>::DispatchLevelResult>>,
|
||||||
ReceivedMessages<
|
|
||||||
<T::MessageDispatch as MessageDispatch<T::AccountId>>::DispatchLevelResult,
|
|
||||||
>,
|
|
||||||
>,
|
|
||||||
),
|
),
|
||||||
/// Messages in the inclusive range have been delivered to the bridged chain.
|
/// Messages in the inclusive range have been delivered to the bridged chain.
|
||||||
MessagesDelivered { lane_id: LaneId, messages: DeliveredMessages },
|
MessagesDelivered { lane_id: LaneId, messages: DeliveredMessages },
|
||||||
|
|||||||
@@ -416,7 +416,7 @@ impl SourceHeaderChain for TestSourceHeaderChain {
|
|||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct TestMessageDispatch;
|
pub struct TestMessageDispatch;
|
||||||
|
|
||||||
impl MessageDispatch<AccountId> for TestMessageDispatch {
|
impl MessageDispatch for TestMessageDispatch {
|
||||||
type DispatchPayload = TestPayload;
|
type DispatchPayload = TestPayload;
|
||||||
type DispatchLevelResult = TestDispatchLevelResult;
|
type DispatchLevelResult = TestDispatchLevelResult;
|
||||||
|
|
||||||
@@ -428,7 +428,6 @@ impl MessageDispatch<AccountId> for TestMessageDispatch {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn dispatch(
|
fn dispatch(
|
||||||
_relayer_account: &AccountId,
|
|
||||||
message: DispatchMessage<TestPayload>,
|
message: DispatchMessage<TestPayload>,
|
||||||
) -> MessageDispatchResult<TestDispatchLevelResult> {
|
) -> MessageDispatchResult<TestDispatchLevelResult> {
|
||||||
match message.data.payload.as_ref() {
|
match message.data.payload.as_ref() {
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ pub trait SourceHeaderChain {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Called when inbound message is received.
|
/// Called when inbound message is received.
|
||||||
pub trait MessageDispatch<AccountId> {
|
pub trait MessageDispatch {
|
||||||
/// Decoded message payload type. Valid message may contain invalid payload. In this case
|
/// Decoded message payload type. Valid message may contain invalid payload. In this case
|
||||||
/// message is delivered, but dispatch fails. Therefore, two separate types of payload
|
/// message is delivered, but dispatch fails. Therefore, two separate types of payload
|
||||||
/// (opaque `MessagePayload` used in delivery and this `DispatchPayload` used in dispatch).
|
/// (opaque `MessagePayload` used in delivery and this `DispatchPayload` used in dispatch).
|
||||||
@@ -103,11 +103,7 @@ pub trait MessageDispatch<AccountId> {
|
|||||||
///
|
///
|
||||||
/// It is up to the implementers of this trait to determine whether the message
|
/// It is up to the implementers of this trait to determine whether the message
|
||||||
/// is invalid (i.e. improperly encoded, has too large weight, ...) or not.
|
/// is invalid (i.e. improperly encoded, has too large weight, ...) or not.
|
||||||
///
|
|
||||||
/// If your configuration allows paying dispatch fee at the target chain, then
|
|
||||||
/// it must be paid inside this method to the `relayer_account`.
|
|
||||||
fn dispatch(
|
fn dispatch(
|
||||||
relayer_account: &AccountId,
|
|
||||||
message: DispatchMessage<Self::DispatchPayload>,
|
message: DispatchMessage<Self::DispatchPayload>,
|
||||||
) -> MessageDispatchResult<Self::DispatchLevelResult>;
|
) -> MessageDispatchResult<Self::DispatchLevelResult>;
|
||||||
}
|
}
|
||||||
@@ -186,7 +182,7 @@ impl<MessagesProof: Parameter + Size, DispatchPayload> SourceHeaderChain
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<MessagesProof, DispatchPayload: Decode, AccountId> MessageDispatch<AccountId>
|
impl<MessagesProof, DispatchPayload: Decode> MessageDispatch
|
||||||
for ForbidInboundMessages<MessagesProof, DispatchPayload>
|
for ForbidInboundMessages<MessagesProof, DispatchPayload>
|
||||||
{
|
{
|
||||||
type DispatchPayload = DispatchPayload;
|
type DispatchPayload = DispatchPayload;
|
||||||
@@ -197,7 +193,6 @@ impl<MessagesProof, DispatchPayload: Decode, AccountId> MessageDispatch<AccountI
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn dispatch(
|
fn dispatch(
|
||||||
_: &AccountId,
|
|
||||||
_: DispatchMessage<Self::DispatchPayload>,
|
_: DispatchMessage<Self::DispatchPayload>,
|
||||||
) -> MessageDispatchResult<Self::DispatchLevelResult> {
|
) -> MessageDispatchResult<Self::DispatchLevelResult> {
|
||||||
MessageDispatchResult { unspent_weight: Weight::zero(), dispatch_level_result: () }
|
MessageDispatchResult { unspent_weight: Weight::zero(), dispatch_level_result: () }
|
||||||
|
|||||||
Reference in New Issue
Block a user