mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 01:41:09 +00:00
Reintroduce msg dispatch status reporting (#2027)
* Use an actual Result inside MessageDispatchResult We need this in order to distinguish between Ok and Err * Revert #1660 * Fixes + simplifications * Implement review suggestions
This commit is contained in:
committed by
Bastian Köcher
parent
4d29753f73
commit
3b968a2aba
@@ -307,8 +307,10 @@ pub fn check_message_lane_weights<C: Chain, T: frame_system::Config>(
|
||||
messages::target::maximal_incoming_message_dispatch_weight(C::max_extrinsic_weight()),
|
||||
);
|
||||
|
||||
let max_incoming_inbound_lane_data_proof_size =
|
||||
InboundLaneData::<()>::encoded_size_hint_u32(this_chain_max_unrewarded_relayers as _);
|
||||
let max_incoming_inbound_lane_data_proof_size = InboundLaneData::<()>::encoded_size_hint_u32(
|
||||
this_chain_max_unrewarded_relayers as _,
|
||||
this_chain_max_unconfirmed_messages as _,
|
||||
);
|
||||
pallet_bridge_messages::ensure_able_to_receive_confirmation::<Weights<T>>(
|
||||
C::max_extrinsic_size(),
|
||||
C::max_extrinsic_weight(),
|
||||
|
||||
@@ -39,9 +39,8 @@ pub type XcmAsPlainPayload = sp_std::prelude::Vec<u8>;
|
||||
|
||||
/// Message dispatch result type for single message
|
||||
#[derive(CloneNoBound, EqNoBound, PartialEqNoBound, Encode, Decode, Debug, TypeInfo)]
|
||||
pub enum XcmBlobMessageDispatchResult {
|
||||
pub enum XcmBlobMessageDispatchError {
|
||||
InvalidPayload,
|
||||
Dispatched,
|
||||
NotDispatched(#[codec(skip)] Option<DispatchBlobError>),
|
||||
}
|
||||
|
||||
@@ -65,7 +64,7 @@ impl<
|
||||
for XcmBlobMessageDispatch<SourceBridgeHubChain, TargetBridgeHubChain, BlobDispatcher, Weights>
|
||||
{
|
||||
type DispatchPayload = XcmAsPlainPayload;
|
||||
type DispatchLevelResult = XcmBlobMessageDispatchResult;
|
||||
type DispatchError = XcmBlobMessageDispatchError;
|
||||
|
||||
fn dispatch_weight(message: &mut DispatchMessage<Self::DispatchPayload>) -> Weight {
|
||||
match message.data.payload {
|
||||
@@ -80,7 +79,7 @@ impl<
|
||||
fn dispatch(
|
||||
_relayer_account: &AccountIdOf<SourceBridgeHubChain>,
|
||||
message: DispatchMessage<Self::DispatchPayload>,
|
||||
) -> MessageDispatchResult<Self::DispatchLevelResult> {
|
||||
) -> MessageDispatchResult<Self::DispatchError> {
|
||||
let payload = match message.data.payload {
|
||||
Ok(payload) => payload,
|
||||
Err(e) => {
|
||||
@@ -92,7 +91,7 @@ impl<
|
||||
);
|
||||
return MessageDispatchResult {
|
||||
unspent_weight: Weight::zero(),
|
||||
dispatch_level_result: XcmBlobMessageDispatchResult::InvalidPayload,
|
||||
dispatch_result: Err(XcmBlobMessageDispatchError::InvalidPayload),
|
||||
}
|
||||
},
|
||||
};
|
||||
@@ -103,7 +102,7 @@ impl<
|
||||
"[XcmBlobMessageDispatch] DispatchBlob::dispatch_blob was ok - message_nonce: {:?}",
|
||||
message.key.nonce
|
||||
);
|
||||
XcmBlobMessageDispatchResult::Dispatched
|
||||
Ok(())
|
||||
},
|
||||
Err(e) => {
|
||||
log::error!(
|
||||
@@ -111,10 +110,13 @@ impl<
|
||||
"[XcmBlobMessageDispatch] DispatchBlob::dispatch_blob failed, error: {:?} - message_nonce: {:?}",
|
||||
e, message.key.nonce
|
||||
);
|
||||
XcmBlobMessageDispatchResult::NotDispatched(Some(e))
|
||||
Err(XcmBlobMessageDispatchError::NotDispatched(Some(e)))
|
||||
},
|
||||
};
|
||||
MessageDispatchResult { unspent_weight: Weight::zero(), dispatch_level_result }
|
||||
MessageDispatchResult {
|
||||
unspent_weight: Weight::zero(),
|
||||
dispatch_result: dispatch_level_result,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user