mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 13:27:57 +00:00
@@ -16,6 +16,7 @@
|
||||
|
||||
//! Common types/functions that may be used by runtimes of all bridged chains.
|
||||
|
||||
#![warn(missing_docs)]
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
use crate::messages_call_ext::MessagesCallSubType;
|
||||
|
||||
@@ -24,7 +24,7 @@ pub use bp_runtime::{RangeInclusiveExt, UnderlyingChainOf, UnderlyingChainProvid
|
||||
|
||||
use bp_header_chain::HeaderChain;
|
||||
use bp_messages::{
|
||||
source_chain::{LaneMessageVerifier, TargetHeaderChain},
|
||||
source_chain::TargetHeaderChain,
|
||||
target_chain::{ProvedLaneMessages, ProvedMessages, SourceHeaderChain},
|
||||
InboundLaneData, LaneId, Message, MessageKey, MessageNonce, MessagePayload, OutboundLaneData,
|
||||
VerificationError,
|
||||
@@ -120,42 +120,6 @@ pub mod source {
|
||||
pub type ParsedMessagesDeliveryProofFromBridgedChain<B> =
|
||||
(LaneId, InboundLaneData<AccountIdOf<ThisChain<B>>>);
|
||||
|
||||
/// Message verifier that is doing all basic checks.
|
||||
///
|
||||
/// This verifier assumes following:
|
||||
///
|
||||
/// - all message lanes are equivalent, so all checks are the same;
|
||||
///
|
||||
/// Following checks are made:
|
||||
///
|
||||
/// - message is rejected if its lane is currently blocked;
|
||||
/// - message is rejected if there are too many pending (undelivered) messages at the outbound
|
||||
/// lane;
|
||||
/// - check that the sender has rights to dispatch the call on target chain using provided
|
||||
/// dispatch origin;
|
||||
/// - check that the sender has paid enough funds for both message delivery and dispatch.
|
||||
#[derive(RuntimeDebug)]
|
||||
pub struct FromThisChainMessageVerifier<B>(PhantomData<B>);
|
||||
|
||||
impl<B> LaneMessageVerifier<FromThisChainMessagePayload> for FromThisChainMessageVerifier<B>
|
||||
where
|
||||
B: MessageBridge,
|
||||
{
|
||||
fn verify_message(
|
||||
_lane: &LaneId,
|
||||
_lane_outbound_data: &OutboundLaneData,
|
||||
_payload: &FromThisChainMessagePayload,
|
||||
) -> Result<(), VerificationError> {
|
||||
// IMPORTANT: any error that is returned here is fatal for the bridge, because
|
||||
// this code is executed at the bridge hub and message sender actually lives
|
||||
// at some sibling parachain. So we are failing **after** the message has been
|
||||
// sent and we can't report it back to sender (unless error report mechanism is
|
||||
// embedded into message and its dispatcher).
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
/// Return maximal message size of This -> Bridged chain message.
|
||||
pub fn maximal_message_size<B: MessageBridge>() -> u32 {
|
||||
super::target::maximal_incoming_message_size(
|
||||
@@ -185,8 +149,7 @@ pub mod source {
|
||||
/// Do basic Bridged-chain specific verification of This -> Bridged chain message.
|
||||
///
|
||||
/// Ok result from this function means that the delivery transaction with this message
|
||||
/// may be 'mined' by the target chain. But the lane may have its own checks (e.g. fee
|
||||
/// check) that would reject message (see `FromThisChainMessageVerifier`).
|
||||
/// may be 'mined' by the target chain.
|
||||
pub fn verify_chain_message<B: MessageBridge>(
|
||||
payload: &FromThisChainMessagePayload,
|
||||
) -> Result<(), VerificationError> {
|
||||
|
||||
@@ -14,6 +14,9 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! Signed extension for the `pallet-bridge-messages` that is able to reject obsolete
|
||||
//! (and some other invalid) transactions.
|
||||
|
||||
use crate::messages::{
|
||||
source::FromBridgedChainMessagesDeliveryProof, target::FromBridgedChainMessagesProof,
|
||||
};
|
||||
@@ -116,7 +119,9 @@ impl ReceiveMessagesDeliveryProofInfo {
|
||||
/// which tries to update a single lane.
|
||||
#[derive(PartialEq, RuntimeDebug)]
|
||||
pub enum CallInfo {
|
||||
/// Messages delivery call info.
|
||||
ReceiveMessagesProof(ReceiveMessagesProofInfo),
|
||||
/// Messages delivery confirmation call info.
|
||||
ReceiveMessagesDeliveryProof(ReceiveMessagesDeliveryProofInfo),
|
||||
}
|
||||
|
||||
@@ -132,7 +137,7 @@ impl CallInfo {
|
||||
|
||||
/// Helper struct that provides methods for working with a call supported by `CallInfo`.
|
||||
pub struct CallHelper<T: Config<I>, I: 'static> {
|
||||
pub _phantom_data: sp_std::marker::PhantomData<(T, I)>,
|
||||
_phantom_data: sp_std::marker::PhantomData<(T, I)>,
|
||||
}
|
||||
|
||||
impl<T: Config<I>, I: 'static> CallHelper<T, I> {
|
||||
|
||||
@@ -40,11 +40,14 @@ use sp_std::{fmt::Debug, marker::PhantomData};
|
||||
use xcm::prelude::*;
|
||||
use xcm_builder::{DispatchBlob, DispatchBlobError};
|
||||
|
||||
/// Message dispatch result type for single message
|
||||
/// Message dispatch result type for single message.
|
||||
#[derive(CloneNoBound, EqNoBound, PartialEqNoBound, Encode, Decode, Debug, TypeInfo)]
|
||||
pub enum XcmBlobMessageDispatchResult {
|
||||
/// We've been unable to decode message payload.
|
||||
InvalidPayload,
|
||||
/// Message has been dispatched.
|
||||
Dispatched,
|
||||
/// Message has **NOT** been dispatched because of given error.
|
||||
NotDispatched(#[codec(skip)] Option<DispatchBlobError>),
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
use crate::messages::{
|
||||
source::{
|
||||
FromThisChainMaximalOutboundPayloadSize, FromThisChainMessagePayload,
|
||||
FromThisChainMessageVerifier, TargetHeaderChainAdapter,
|
||||
TargetHeaderChainAdapter,
|
||||
},
|
||||
target::{FromBridgedChainMessagePayload, SourceHeaderChainAdapter},
|
||||
BridgedChainWithMessages, HashOf, MessageBridge, ThisChainWithMessages,
|
||||
@@ -213,7 +213,6 @@ impl pallet_bridge_messages::Config for TestRuntime {
|
||||
type DeliveryPayments = ();
|
||||
|
||||
type TargetHeaderChain = TargetHeaderChainAdapter<OnThisChainBridge>;
|
||||
type LaneMessageVerifier = FromThisChainMessageVerifier<OnThisChainBridge>;
|
||||
type DeliveryConfirmationPayments = pallet_bridge_relayers::DeliveryConfirmationPaymentsAdapter<
|
||||
TestRuntime,
|
||||
(),
|
||||
@@ -315,6 +314,8 @@ impl From<BridgedChainOrigin>
|
||||
pub struct ThisUnderlyingChain;
|
||||
|
||||
impl Chain for ThisUnderlyingChain {
|
||||
const ID: ChainId = *b"tuch";
|
||||
|
||||
type BlockNumber = ThisChainBlockNumber;
|
||||
type Hash = ThisChainHash;
|
||||
type Hasher = ThisChainHasher;
|
||||
@@ -355,6 +356,8 @@ pub struct BridgedUnderlyingParachain;
|
||||
pub struct BridgedChainCall;
|
||||
|
||||
impl Chain for BridgedUnderlyingChain {
|
||||
const ID: ChainId = *b"buch";
|
||||
|
||||
type BlockNumber = BridgedChainBlockNumber;
|
||||
type Hash = BridgedChainHash;
|
||||
type Hasher = BridgedChainHasher;
|
||||
@@ -381,6 +384,8 @@ impl ChainWithGrandpa for BridgedUnderlyingChain {
|
||||
}
|
||||
|
||||
impl Chain for BridgedUnderlyingParachain {
|
||||
const ID: ChainId = *b"bupc";
|
||||
|
||||
type BlockNumber = BridgedChainBlockNumber;
|
||||
type Hash = BridgedChainHash;
|
||||
type Hasher = BridgedChainHasher;
|
||||
|
||||
@@ -84,5 +84,5 @@ where
|
||||
let (relay_block_number, relay_block_hash) =
|
||||
insert_header_to_grandpa_pallet::<R, R::BridgesGrandpaPalletInstance>(state_root);
|
||||
|
||||
(relay_block_number, relay_block_hash, ParaHeadsProof(proof), parachain_heads)
|
||||
(relay_block_number, relay_block_hash, ParaHeadsProof { storage_proof: proof }, parachain_heads)
|
||||
}
|
||||
|
||||
@@ -116,7 +116,7 @@ where
|
||||
|
||||
/// Refund calculator.
|
||||
pub trait RefundCalculator {
|
||||
// The underlying integer type in which the refund is calculated.
|
||||
/// The underlying integer type in which the refund is calculated.
|
||||
type Balance;
|
||||
|
||||
/// Compute refund for given transaction.
|
||||
@@ -986,7 +986,7 @@ mod tests {
|
||||
ParaId(TestParachain::get()),
|
||||
[parachain_head_at_relay_header_number as u8; 32].into(),
|
||||
)],
|
||||
parachain_heads_proof: ParaHeadsProof(vec![]),
|
||||
parachain_heads_proof: ParaHeadsProof { storage_proof: vec![] },
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1732,7 +1732,7 @@ mod tests {
|
||||
(ParaId(TestParachain::get()), [1u8; 32].into()),
|
||||
(ParaId(TestParachain::get() + 1), [1u8; 32].into()),
|
||||
],
|
||||
parachain_heads_proof: ParaHeadsProof(vec![]),
|
||||
parachain_heads_proof: ParaHeadsProof { storage_proof: vec![] },
|
||||
}),
|
||||
message_delivery_call(200),
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user