mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 05:11:02 +00:00
Propagate message receival confirmation errors (#2116)
* Propagate message receival confirmation errors * spellcheck
This commit is contained in:
committed by
Bastian Köcher
parent
56d4013878
commit
201dfddc54
@@ -48,7 +48,7 @@ pub use weights_ext::{
|
||||
|
||||
use crate::{
|
||||
inbound_lane::{InboundLane, InboundLaneStorage},
|
||||
outbound_lane::{OutboundLane, OutboundLaneStorage, ReceivalConfirmationResult},
|
||||
outbound_lane::{OutboundLane, OutboundLaneStorage, ReceivalConfirmationError},
|
||||
};
|
||||
|
||||
use bp_messages::{
|
||||
@@ -458,36 +458,13 @@ pub mod pallet {
|
||||
// mark messages as delivered
|
||||
let mut lane = outbound_lane::<T, I>(lane_id);
|
||||
let last_delivered_nonce = lane_data.last_delivered_nonce();
|
||||
let confirmed_messages = match lane.confirm_delivery(
|
||||
relayers_state.total_messages,
|
||||
last_delivered_nonce,
|
||||
&lane_data.relayers,
|
||||
) {
|
||||
ReceivalConfirmationResult::ConfirmedMessages(confirmed_messages) =>
|
||||
Some(confirmed_messages),
|
||||
ReceivalConfirmationResult::NoNewConfirmations => None,
|
||||
ReceivalConfirmationResult::TryingToConfirmMoreMessagesThanExpected(
|
||||
to_confirm_messages_count,
|
||||
) => {
|
||||
log::trace!(
|
||||
target: LOG_TARGET,
|
||||
"Messages delivery proof contains too many messages to confirm: {} vs declared {}",
|
||||
to_confirm_messages_count,
|
||||
relayers_state.total_messages,
|
||||
);
|
||||
|
||||
fail!(Error::<T, I>::TryingToConfirmMoreMessagesThanExpected);
|
||||
},
|
||||
error => {
|
||||
log::trace!(
|
||||
target: LOG_TARGET,
|
||||
"Messages delivery proof contains invalid unrewarded relayers vec: {:?}",
|
||||
error,
|
||||
);
|
||||
|
||||
fail!(Error::<T, I>::InvalidUnrewardedRelayers);
|
||||
},
|
||||
};
|
||||
let confirmed_messages = lane
|
||||
.confirm_delivery(
|
||||
relayers_state.total_messages,
|
||||
last_delivered_nonce,
|
||||
&lane_data.relayers,
|
||||
)
|
||||
.map_err(Error::<T, I>::ReceivalConfirmation)?;
|
||||
|
||||
if let Some(confirmed_messages) = confirmed_messages {
|
||||
// emit 'delivered' event
|
||||
@@ -568,8 +545,6 @@ pub mod pallet {
|
||||
InvalidMessagesProof,
|
||||
/// Invalid messages delivery proof has been submitted.
|
||||
InvalidMessagesDeliveryProof,
|
||||
/// The bridged chain has invalid `UnrewardedRelayers` in its storage (fatal for the lane).
|
||||
InvalidUnrewardedRelayers,
|
||||
/// The relayer has declared invalid unrewarded relayers state in the
|
||||
/// `receive_messages_delivery_proof` call.
|
||||
InvalidUnrewardedRelayersState,
|
||||
@@ -578,9 +553,8 @@ pub mod pallet {
|
||||
InsufficientDispatchWeight,
|
||||
/// The message someone is trying to work with (i.e. increase fee) is not yet sent.
|
||||
MessageIsNotYetSent,
|
||||
/// The number of actually confirmed messages is going to be larger than the number of
|
||||
/// messages in the proof. This may mean that this or bridged chain storage is corrupted.
|
||||
TryingToConfirmMoreMessagesThanExpected,
|
||||
/// Error confirming messages receival.
|
||||
ReceivalConfirmation(ReceivalConfirmationError),
|
||||
/// Error generated by the `OwnedBridgeModule` trait.
|
||||
BridgeModule(bp_runtime::OwnedBridgeModuleError),
|
||||
}
|
||||
@@ -941,13 +915,16 @@ fn verify_and_decode_messages_proof<Chain: SourceHeaderChain, DispatchPayload: D
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::mock::{
|
||||
inbound_unrewarded_relayers_state, message, message_payload, run_test, unrewarded_relayer,
|
||||
AccountId, DbWeight, RuntimeEvent as TestEvent, RuntimeOrigin,
|
||||
TestDeliveryConfirmationPayments, TestDeliveryPayments, TestMessagesDeliveryProof,
|
||||
TestMessagesProof, TestRelayer, TestRuntime, TestWeightInfo, MAX_OUTBOUND_PAYLOAD_SIZE,
|
||||
PAYLOAD_REJECTED_BY_TARGET_CHAIN, REGULAR_PAYLOAD, TEST_LANE_ID, TEST_LANE_ID_2,
|
||||
TEST_LANE_ID_3, TEST_RELAYER_A, TEST_RELAYER_B,
|
||||
use crate::{
|
||||
mock::{
|
||||
inbound_unrewarded_relayers_state, message, message_payload, run_test,
|
||||
unrewarded_relayer, AccountId, DbWeight, RuntimeEvent as TestEvent, RuntimeOrigin,
|
||||
TestDeliveryConfirmationPayments, TestDeliveryPayments, TestMessagesDeliveryProof,
|
||||
TestMessagesProof, TestRelayer, TestRuntime, TestWeightInfo, MAX_OUTBOUND_PAYLOAD_SIZE,
|
||||
PAYLOAD_REJECTED_BY_TARGET_CHAIN, REGULAR_PAYLOAD, TEST_LANE_ID, TEST_LANE_ID_2,
|
||||
TEST_LANE_ID_3, TEST_RELAYER_A, TEST_RELAYER_B,
|
||||
},
|
||||
outbound_lane::ReceivalConfirmationError,
|
||||
};
|
||||
use bp_messages::{BridgeMessagesCall, UnrewardedRelayer, UnrewardedRelayersState};
|
||||
use bp_test_utils::generate_owned_bridge_module_tests;
|
||||
@@ -1818,7 +1795,9 @@ mod tests {
|
||||
))),
|
||||
UnrewardedRelayersState { last_delivered_nonce: 1, ..Default::default() },
|
||||
),
|
||||
Error::<TestRuntime, ()>::TryingToConfirmMoreMessagesThanExpected,
|
||||
Error::<TestRuntime, ()>::ReceivalConfirmation(
|
||||
ReceivalConfirmationError::TryingToConfirmMoreMessagesThanExpected
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user