mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 08:11:03 +00:00
Add Basic XCM (#1934)
* basic setup * fix compile * add back xcmsink * Update primitives.rs * add downward xcm for sudo * Update paras_sudo_wrapper.rs * Update Cargo.lock * some cleanups * Add error log Co-authored-by: Sergei Shulepov <sergei@parity.io>
This commit is contained in:
@@ -52,6 +52,42 @@ impl UmpSink for () {
|
||||
}
|
||||
}
|
||||
|
||||
/// A specific implementation of a UmpSink where messages are in the XCM format
|
||||
/// and will be forwarded to the XCM Executor.
|
||||
pub struct XcmSink<Config>(sp_std::marker::PhantomData<Config>);
|
||||
|
||||
impl<Config: xcm_executor::Config> UmpSink for XcmSink<Config> {
|
||||
fn process_upward_message(origin: ParaId, msg: Vec<u8>) -> Weight {
|
||||
use parity_scale_codec::Decode;
|
||||
use xcm::VersionedXcm;
|
||||
use xcm::v0::{Junction, MultiLocation, ExecuteXcm};
|
||||
use xcm_executor::XcmExecutor;
|
||||
|
||||
let weight: Weight = 0;
|
||||
|
||||
if let Ok(versioned_xcm_message) = VersionedXcm::decode(&mut &msg[..]) {
|
||||
match versioned_xcm_message {
|
||||
VersionedXcm::V0(xcm_message) => {
|
||||
let xcm_junction: Junction = Junction::Parachain { id: origin.into() };
|
||||
let xcm_location: MultiLocation = xcm_junction.into();
|
||||
// TODO: Do something with result.
|
||||
let _result = XcmExecutor::<Config>::execute_xcm(xcm_location, xcm_message);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
frame_support::debug::error!(
|
||||
target: "xcm",
|
||||
"Failed to decode versioned XCM from upward message.",
|
||||
);
|
||||
}
|
||||
|
||||
// TODO: to be sound, this implementation must ensure that returned (and thus consumed)
|
||||
// weight is limited to some small portion of the total block weight (as a ballpark, 1/4, 1/8
|
||||
// or lower).
|
||||
weight
|
||||
}
|
||||
}
|
||||
|
||||
/// An error returned by [`check_upward_messages`] that indicates a violation of one of acceptance
|
||||
/// criteria rules.
|
||||
pub enum AcceptanceCheckErr {
|
||||
|
||||
Reference in New Issue
Block a user