mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-11 09:31:12 +00:00
Fixes (xcm Superuser + DispatchLevelResult)
This commit is contained in:
@@ -14,7 +14,11 @@
|
||||
],
|
||||
"telemetryEndpoints": null,
|
||||
"protocolId": null,
|
||||
"properties": {},
|
||||
"properties": {
|
||||
"ss58Format": 42,
|
||||
"tokenDecimals": 12,
|
||||
"tokenSymbol": "ROC"
|
||||
},
|
||||
"relay_chain": "rococo",
|
||||
"para_id": 1013,
|
||||
"codeSubstitutes": {},
|
||||
|
||||
@@ -14,7 +14,11 @@
|
||||
],
|
||||
"telemetryEndpoints": null,
|
||||
"protocolId": null,
|
||||
"properties": {},
|
||||
"properties": {
|
||||
"ss58Format": 42,
|
||||
"tokenDecimals": 12,
|
||||
"tokenSymbol": "WOOK"
|
||||
},
|
||||
"relay_chain": "wococo",
|
||||
"para_id": 1014,
|
||||
"codeSubstitutes": {},
|
||||
@@ -86,4 +90,4 @@
|
||||
"childrenDefault": {}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,8 +20,9 @@ use bp_messages::{
|
||||
LaneId,
|
||||
};
|
||||
use bp_runtime::{messages::MessageDispatchResult, AccountIdOf, Chain};
|
||||
use codec::Encode;
|
||||
use frame_support::{dispatch::Weight, parameter_types};
|
||||
use codec::{Decode, Encode};
|
||||
use frame_support::{dispatch::Weight, parameter_types, CloneNoBound, EqNoBound, PartialEqNoBound};
|
||||
use scale_info::TypeInfo;
|
||||
use xcm::latest::prelude::*;
|
||||
use xcm_builder::{DispatchBlob, DispatchBlobError, HaulBlob};
|
||||
|
||||
@@ -36,6 +37,13 @@ parameter_types! {
|
||||
pub const HeadersToKeep: u32 = 1024;
|
||||
}
|
||||
|
||||
#[derive(CloneNoBound, EqNoBound, PartialEqNoBound, Encode, Decode, Debug, TypeInfo)]
|
||||
pub enum XcmBlobMessageDispatchResult {
|
||||
InvalidPayload,
|
||||
Dispatched,
|
||||
NotDispatched(#[codec(skip)] &'static str),
|
||||
}
|
||||
|
||||
/// [`XcmBlobMessageDispatch`] is responsible for dispatching received messages from other BridgeHub
|
||||
pub struct XcmBlobMessageDispatch<SourceBridgeHubChain, TargetBridgeHubChain, DispatchBlob> {
|
||||
_marker:
|
||||
@@ -47,6 +55,7 @@ impl<SourceBridgeHubChain: Chain, TargetBridgeHubChain: Chain, BlobDispatcher: D
|
||||
for XcmBlobMessageDispatch<SourceBridgeHubChain, TargetBridgeHubChain, BlobDispatcher>
|
||||
{
|
||||
type DispatchPayload = XcmAsPlainPayload;
|
||||
type DispatchLevelResult = XcmBlobMessageDispatchResult;
|
||||
|
||||
fn dispatch_weight(_message: &mut DispatchMessage<Self::DispatchPayload>) -> Weight {
|
||||
log::error!(
|
||||
@@ -60,7 +69,7 @@ impl<SourceBridgeHubChain: Chain, TargetBridgeHubChain: Chain, BlobDispatcher: D
|
||||
fn dispatch(
|
||||
_relayer_account: &AccountIdOf<SourceBridgeHubChain>,
|
||||
message: DispatchMessage<Self::DispatchPayload>,
|
||||
) -> MessageDispatchResult {
|
||||
) -> MessageDispatchResult<Self::DispatchLevelResult> {
|
||||
log::warn!(
|
||||
target: crate::LOG_TARGET,
|
||||
"[XcmBlobMessageDispatch] DispatchBlob::dispatch_blob triggering - message_nonce: {:?}",
|
||||
@@ -79,15 +88,19 @@ impl<SourceBridgeHubChain: Chain, TargetBridgeHubChain: Chain, BlobDispatcher: D
|
||||
// TODO:check-parameter - setup uspent_weight?
|
||||
unspent_weight: Weight::zero(),
|
||||
dispatch_fee_paid_during_dispatch: false,
|
||||
dispatch_level_result: XcmBlobMessageDispatchResult::InvalidPayload,
|
||||
}
|
||||
},
|
||||
};
|
||||
match BlobDispatcher::dispatch_blob(payload) {
|
||||
Ok(_) => log::debug!(
|
||||
target: crate::LOG_TARGET,
|
||||
"[XcmBlobMessageDispatch] DispatchBlob::dispatch_blob was ok - message_nonce: {:?}",
|
||||
message.key.nonce
|
||||
),
|
||||
let dispatch_level_result = match BlobDispatcher::dispatch_blob(payload) {
|
||||
Ok(_) => {
|
||||
log::debug!(
|
||||
target: crate::LOG_TARGET,
|
||||
"[XcmBlobMessageDispatch] DispatchBlob::dispatch_blob was ok - message_nonce: {:?}",
|
||||
message.key.nonce
|
||||
);
|
||||
XcmBlobMessageDispatchResult::Dispatched
|
||||
},
|
||||
Err(e) => {
|
||||
let e = match e {
|
||||
DispatchBlobError::Unbridgable => "DispatchBlobError::Unbridgable",
|
||||
@@ -106,12 +119,14 @@ impl<SourceBridgeHubChain: Chain, TargetBridgeHubChain: Chain, BlobDispatcher: D
|
||||
"[XcmBlobMessageDispatch] DispatchBlob::dispatch_blob failed, error: {:?} - message_nonce: {:?}",
|
||||
e, message.key.nonce
|
||||
);
|
||||
XcmBlobMessageDispatchResult::NotDispatched(e)
|
||||
},
|
||||
}
|
||||
};
|
||||
MessageDispatchResult {
|
||||
// TODO:check-parameter - setup uspent_weight?
|
||||
dispatch_fee_paid_during_dispatch: false,
|
||||
unspent_weight: Weight::zero(),
|
||||
dispatch_level_result,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,10 +33,10 @@ use sp_core::Get;
|
||||
use xcm::latest::prelude::*;
|
||||
use xcm_builder::{
|
||||
AccountId32Aliases, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, CurrencyAdapter,
|
||||
EnsureXcmOrigin, IsConcrete, NativeAsset, ParentIsPreset, RelayChainAsNative,
|
||||
SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative,
|
||||
SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, UsingComponents,
|
||||
WeightInfoBounds,
|
||||
EnsureXcmOrigin, IsConcrete, NativeAsset, ParentAsSuperuser, ParentIsPreset,
|
||||
RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia,
|
||||
SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit,
|
||||
UsingComponents, WeightInfoBounds,
|
||||
};
|
||||
use xcm_executor::{traits::ExportXcm, XcmExecutor};
|
||||
|
||||
@@ -96,14 +96,17 @@ pub type XcmOriginToTransactDispatchOrigin = (
|
||||
// using `LocationToAccountId` and then turn that into the usual `Signed` origin. Useful for
|
||||
// foreign chains who want to have a local sovereign account on this chain which they control.
|
||||
SovereignSignedViaLocation<LocationToAccountId, RuntimeOrigin>,
|
||||
// Native converter for Relay-chain (Parent) location; will converts to a `Relay` origin when
|
||||
// recognized.
|
||||
// Native converter for Relay-chain (Parent) location; will convert to a `Relay` origin when
|
||||
// recognised.
|
||||
RelayChainAsNative<RelayChainOrigin, RuntimeOrigin>,
|
||||
// Native converter for sibling Parachains; will convert to a `SiblingPara` origin when
|
||||
// recognized.
|
||||
// recognised.
|
||||
SiblingParachainAsNative<cumulus_pallet_xcm::Origin, RuntimeOrigin>,
|
||||
// Superuser converter for the Relay-chain (Parent) location. This will allow it to issue a
|
||||
// transaction from the Root origin.
|
||||
ParentAsSuperuser<RuntimeOrigin>,
|
||||
// Native signed account converter; this just converts an `AccountId32` origin into a normal
|
||||
// `Origin::Signed` origin of the same 32-byte value.
|
||||
// `RuntimeOrigin::Signed` origin of the same 32-byte value.
|
||||
SignedAccountId32AsNative<RelayNetwork, RuntimeOrigin>,
|
||||
// Xcm origins can be represented natively under the Xcm pallet's Xcm origin.
|
||||
XcmPassthrough<RuntimeOrigin>,
|
||||
|
||||
Reference in New Issue
Block a user