mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-22 04:25:42 +00:00
XCM: Tools for uniquely referencing messages (#7234)
* Tools for unique topic references * Formatting * Naming * Repot into routing.rs. * More things done * Universal Exporter supports topic-as-reference * Some tests for the topic routing * More tests * Paid bridge tests * Add message ID to sending events * Formatting * fix and integrate into test nets * Move DenyThenTry and friend from Cumulus * Append SetTopic rather than prepend * Docs * Docs * Work with new ProcessMessage ID API * Formatting * Fix build * Fixes * Formatting * Update xcm/xcm-builder/src/barriers.rs Co-authored-by: Francisco Aguirre <franciscoaguirreperez@gmail.com> * Update xcm/xcm-builder/src/routing.rs Co-authored-by: Francisco Aguirre <franciscoaguirreperez@gmail.com> * Docs * Rename message_hash * Formatting * ".git/.scripts/commands/fmt/fmt.sh" * Rename * Another Rename * ".git/.scripts/commands/fmt/fmt.sh" * ".git/.scripts/commands/fmt/fmt.sh" * Update xcm/xcm-builder/src/routing.rs Co-authored-by: Keith Yeung <kungfukeith11@gmail.com> --------- Co-authored-by: Francisco Aguirre <franciscoaguirreperez@gmail.com> Co-authored-by: command-bot <> Co-authored-by: Keith Yeung <kungfukeith11@gmail.com>
This commit is contained in:
@@ -16,7 +16,19 @@
|
||||
|
||||
use frame_support::traits::ProcessMessageError;
|
||||
use sp_std::result::Result;
|
||||
use xcm::latest::{Instruction, MultiLocation, Weight};
|
||||
use xcm::latest::{Instruction, MultiLocation, Weight, XcmHash};
|
||||
|
||||
/// Properyies of an XCM message and its imminent execution.
|
||||
#[derive(Clone, Eq, PartialEq, Debug)]
|
||||
pub struct Properties {
|
||||
/// The amount of weight that the system has determined this
|
||||
/// message may utilize in its execution. Typically non-zero only because of prior fee
|
||||
/// payment, but could in principle be due to other factors.
|
||||
pub weight_credit: Weight,
|
||||
/// The identity of the message, if one is known. If left as `None`, then it will generally
|
||||
/// default to the hash of the message which may be non-unique.
|
||||
pub message_id: Option<XcmHash>,
|
||||
}
|
||||
|
||||
/// Trait to determine whether the execution engine should actually execute a given XCM.
|
||||
///
|
||||
@@ -28,14 +40,13 @@ pub trait ShouldExecute {
|
||||
/// - `origin`: The origin (sender) of the message.
|
||||
/// - `instructions`: The message itself.
|
||||
/// - `max_weight`: The (possibly over-) estimation of the weight of execution of the message.
|
||||
/// - `weight_credit`: The pre-established amount of weight that the system has determined this
|
||||
/// message may utilize in its execution. Typically non-zero only because of prior fee
|
||||
/// payment, but could in principle be due to other factors.
|
||||
/// - `properties`: Various pre-established properties of the message which may be mutated by
|
||||
/// this API.
|
||||
fn should_execute<RuntimeCall>(
|
||||
origin: &MultiLocation,
|
||||
instructions: &mut [Instruction<RuntimeCall>],
|
||||
max_weight: Weight,
|
||||
weight_credit: &mut Weight,
|
||||
properties: &mut Properties,
|
||||
) -> Result<(), ProcessMessageError>;
|
||||
}
|
||||
|
||||
@@ -45,21 +56,21 @@ impl ShouldExecute for Tuple {
|
||||
origin: &MultiLocation,
|
||||
instructions: &mut [Instruction<RuntimeCall>],
|
||||
max_weight: Weight,
|
||||
weight_credit: &mut Weight,
|
||||
properties: &mut Properties,
|
||||
) -> Result<(), ProcessMessageError> {
|
||||
for_tuples!( #(
|
||||
match Tuple::should_execute(origin, instructions, max_weight, weight_credit) {
|
||||
match Tuple::should_execute(origin, instructions, max_weight, properties) {
|
||||
Ok(()) => return Ok(()),
|
||||
_ => (),
|
||||
}
|
||||
)* );
|
||||
log::trace!(
|
||||
target: "xcm::should_execute",
|
||||
"did not pass barrier: origin: {:?}, instructions: {:?}, max_weight: {:?}, weight_credit: {:?}",
|
||||
"did not pass barrier: origin: {:?}, instructions: {:?}, max_weight: {:?}, properties: {:?}",
|
||||
origin,
|
||||
instructions,
|
||||
max_weight,
|
||||
weight_credit,
|
||||
properties,
|
||||
);
|
||||
Err(ProcessMessageError::Unsupported)
|
||||
}
|
||||
@@ -79,7 +90,7 @@ pub trait CheckSuspension {
|
||||
origin: &MultiLocation,
|
||||
instructions: &mut [Instruction<Call>],
|
||||
max_weight: Weight,
|
||||
weight_credit: &mut Weight,
|
||||
properties: &mut Properties,
|
||||
) -> bool;
|
||||
}
|
||||
|
||||
@@ -89,10 +100,10 @@ impl CheckSuspension for Tuple {
|
||||
origin: &MultiLocation,
|
||||
instruction: &mut [Instruction<Call>],
|
||||
max_weight: Weight,
|
||||
weight_credit: &mut Weight,
|
||||
properties: &mut Properties,
|
||||
) -> bool {
|
||||
for_tuples!( #(
|
||||
if Tuple::is_suspended(origin, instruction, max_weight, weight_credit) {
|
||||
if Tuple::is_suspended(origin, instruction, max_weight, properties) {
|
||||
return true
|
||||
}
|
||||
)* );
|
||||
|
||||
Reference in New Issue
Block a user