mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 05:11:02 +00:00
Propagate message verification errors (#2114)
* Propagate message verification errors * Replace parse_finalized_storage_proof() with storage_proof_checker() * small fixes * fix comment
This commit is contained in:
committed by
Bastian Köcher
parent
c490222fc6
commit
56d4013878
@@ -16,7 +16,9 @@
|
||||
|
||||
//! Primitives of messages module, that are used on the target chain.
|
||||
|
||||
use crate::{LaneId, Message, MessageKey, MessageNonce, MessagePayload, OutboundLaneData};
|
||||
use crate::{
|
||||
LaneId, Message, MessageKey, MessageNonce, MessagePayload, OutboundLaneData, VerificationError,
|
||||
};
|
||||
|
||||
use bp_runtime::{messages::MessageDispatchResult, Size};
|
||||
use codec::{Decode, Encode, Error as CodecError};
|
||||
@@ -58,9 +60,6 @@ pub struct DispatchMessage<DispatchPayload> {
|
||||
/// can't change. Wrong implementation may lead to invalid lane states (i.e. lane
|
||||
/// that's stuck) and/or processing messages without paying fees.
|
||||
pub trait SourceHeaderChain {
|
||||
/// Error type.
|
||||
type Error: Debug;
|
||||
|
||||
/// Proof that messages are sent from source chain. This may also include proof
|
||||
/// of corresponding outbound lane states.
|
||||
type MessagesProof: Parameter + Size;
|
||||
@@ -79,7 +78,7 @@ pub trait SourceHeaderChain {
|
||||
fn verify_messages_proof(
|
||||
proof: Self::MessagesProof,
|
||||
messages_count: u32,
|
||||
) -> Result<ProvedMessages<Message>, Self::Error>;
|
||||
) -> Result<ProvedMessages<Message>, VerificationError>;
|
||||
}
|
||||
|
||||
/// Called when inbound message is received.
|
||||
@@ -164,21 +163,20 @@ pub struct ForbidInboundMessages<MessagesProof, DispatchPayload>(
|
||||
PhantomData<(MessagesProof, DispatchPayload)>,
|
||||
);
|
||||
|
||||
/// Error message that is used in `ForbidOutboundMessages` implementation.
|
||||
/// Error message that is used in `ForbidInboundMessages` implementation.
|
||||
const ALL_INBOUND_MESSAGES_REJECTED: &str =
|
||||
"This chain is configured to reject all inbound messages";
|
||||
|
||||
impl<MessagesProof: Parameter + Size, DispatchPayload> SourceHeaderChain
|
||||
for ForbidInboundMessages<MessagesProof, DispatchPayload>
|
||||
{
|
||||
type Error = &'static str;
|
||||
type MessagesProof = MessagesProof;
|
||||
|
||||
fn verify_messages_proof(
|
||||
_proof: Self::MessagesProof,
|
||||
_messages_count: u32,
|
||||
) -> Result<ProvedMessages<Message>, Self::Error> {
|
||||
Err(ALL_INBOUND_MESSAGES_REJECTED)
|
||||
) -> Result<ProvedMessages<Message>, VerificationError> {
|
||||
Err(VerificationError::Other(ALL_INBOUND_MESSAGES_REJECTED))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user