mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 03:01:07 +00:00
Fixes
This commit is contained in:
@@ -50,6 +50,7 @@ impl<SourceBridgeHubChain: Chain, TargetBridgeHubChain: Chain, BlobDispatcher: D
|
||||
|
||||
fn dispatch_weight(_message: &mut DispatchMessage<Self::DispatchPayload>) -> Weight {
|
||||
log::error!(
|
||||
target: crate::LOG_TARGET,
|
||||
"[XcmBlobMessageDispatch] TODO: change here to XCMv3 dispatch_weight with XcmExecutor - message: ?...?",
|
||||
);
|
||||
// TODO:check-parameter - setup weight?
|
||||
@@ -60,11 +61,20 @@ impl<SourceBridgeHubChain: Chain, TargetBridgeHubChain: Chain, BlobDispatcher: D
|
||||
_relayer_account: &AccountIdOf<SourceBridgeHubChain>,
|
||||
message: DispatchMessage<Self::DispatchPayload>,
|
||||
) -> MessageDispatchResult {
|
||||
log::warn!("[XcmBlobMessageDispatch] DispatchBlob::dispatch_blob triggering - message_nonce: {:?}", message.key.nonce);
|
||||
log::warn!(
|
||||
target: crate::LOG_TARGET,
|
||||
"[XcmBlobMessageDispatch] DispatchBlob::dispatch_blob triggering - message_nonce: {:?}",
|
||||
message.key.nonce
|
||||
);
|
||||
let payload = match message.data.payload {
|
||||
Ok(payload) => payload,
|
||||
Err(e) => {
|
||||
log::error!("[XcmBlobMessageDispatch] payload error: {:?} - message_nonce: {:?}", e, message.key.nonce);
|
||||
log::error!(
|
||||
target: crate::LOG_TARGET,
|
||||
"[XcmBlobMessageDispatch] payload error: {:?} - message_nonce: {:?}",
|
||||
e,
|
||||
message.key.nonce
|
||||
);
|
||||
return MessageDispatchResult {
|
||||
// TODO:check-parameter - setup uspent_weight?
|
||||
unspent_weight: Weight::zero(),
|
||||
@@ -73,7 +83,11 @@ impl<SourceBridgeHubChain: Chain, TargetBridgeHubChain: Chain, BlobDispatcher: D
|
||||
},
|
||||
};
|
||||
match BlobDispatcher::dispatch_blob(payload) {
|
||||
Ok(_) => log::debug!("[XcmBlobMessageDispatch] DispatchBlob::dispatch_blob was ok - message_nonce: {:?}", message.key.nonce),
|
||||
Ok(_) => log::debug!(
|
||||
target: crate::LOG_TARGET,
|
||||
"[XcmBlobMessageDispatch] DispatchBlob::dispatch_blob was ok - message_nonce: {:?}",
|
||||
message.key.nonce
|
||||
),
|
||||
Err(e) => {
|
||||
let e = match e {
|
||||
DispatchBlobError::Unbridgable => "DispatchBlobError::Unbridgable",
|
||||
@@ -88,6 +102,7 @@ impl<SourceBridgeHubChain: Chain, TargetBridgeHubChain: Chain, BlobDispatcher: D
|
||||
DispatchBlobError::WrongGlobal => "DispatchBlobError::WrongGlobal",
|
||||
};
|
||||
log::error!(
|
||||
target: crate::LOG_TARGET,
|
||||
"[XcmBlobMessageDispatch] DispatchBlob::dispatch_blob failed, error: {:?} - message_nonce: {:?}",
|
||||
e, message.key.nonce
|
||||
);
|
||||
@@ -129,7 +144,7 @@ impl<H: XcmBlobHauler> HaulBlob for XcmBlobHaulerAdapter<H> {
|
||||
hash
|
||||
})
|
||||
.map_err(|e| e);
|
||||
log::info!(target: "runtime::bridge-hub", "haul_blob result: {:?} on lane: {:?}", result, lane);
|
||||
log::info!(target: crate::LOG_TARGET, "haul_blob result: {:?} on lane: {:?}", result, lane);
|
||||
result.expect("failed to process: TODO:check-parameter - wait for origin/gav-xcm-v3, there is a comment about handliing errors for HaulBlob");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -157,12 +157,13 @@ impl ThisChainWithMessages for BridgeHubRococo {
|
||||
type RuntimeCall = crate::RuntimeCall;
|
||||
|
||||
fn is_message_accepted(origin: &Self::RuntimeOrigin, lane: &LaneId) -> bool {
|
||||
log::info!("[BridgeHubRococo::ThisChainWithMessages] is_message_accepted - origin: {:?}, lane: {:?}", origin, lane);
|
||||
log::info!(target: crate::LOG_TARGET, "[BridgeHubRococo::ThisChainWithMessages] is_message_accepted - origin: {:?}, lane: {:?}", origin, lane);
|
||||
lane == &DEFAULT_XCM_LANE_TO_BRIDGE_HUB_WOCOCO
|
||||
}
|
||||
|
||||
fn maximal_pending_messages_at_outbound_lane() -> MessageNonce {
|
||||
log::info!(
|
||||
target: crate::LOG_TARGET,
|
||||
"[BridgeHubRococo::ThisChainWithMessages] maximal_pending_messages_at_outbound_lane"
|
||||
);
|
||||
MessageNonce::MAX / 2
|
||||
|
||||
@@ -157,12 +157,13 @@ impl ThisChainWithMessages for BridgeHubWococo {
|
||||
type RuntimeCall = crate::RuntimeCall;
|
||||
|
||||
fn is_message_accepted(origin: &Self::RuntimeOrigin, lane: &LaneId) -> bool {
|
||||
log::info!("[BridgeHubWococo::ThisChainWithMessages] is_message_accepted - origin: {:?}, lane: {:?}", origin, lane);
|
||||
log::info!(target: crate::LOG_TARGET, "[BridgeHubWococo::ThisChainWithMessages] is_message_accepted - origin: {:?}, lane: {:?}", origin, lane);
|
||||
lane == &DEFAULT_XCM_LANE_TO_BRIDGE_HUB_ROCOCO
|
||||
}
|
||||
|
||||
fn maximal_pending_messages_at_outbound_lane() -> MessageNonce {
|
||||
log::info!(
|
||||
target: crate::LOG_TARGET,
|
||||
"[BridgeHubWococo::ThisChainWithMessages] maximal_pending_messages_at_outbound_lane"
|
||||
);
|
||||
MessageNonce::MAX / 2
|
||||
|
||||
@@ -83,6 +83,8 @@ use parachains_common::{
|
||||
use xcm::latest::prelude::BodyId;
|
||||
use xcm_executor::XcmExecutor;
|
||||
|
||||
pub const LOG_TARGET: &str = "runtime::bridge-hub";
|
||||
|
||||
/// Balance of an account.
|
||||
pub type Balance = u128;
|
||||
|
||||
@@ -544,7 +546,6 @@ impl pallet_bridge_messages::Config<WithBridgeHubWococoMessagesInstance> for Run
|
||||
bp_bridge_hub_rococo::BridgeHubRococo,
|
||||
OnBridgeHubRococoBlobDispatcher,
|
||||
>;
|
||||
|
||||
}
|
||||
|
||||
/// Add XCM messages support for BrigdeHubWococo to support Wococo->Rococo XCM messages
|
||||
@@ -787,9 +788,19 @@ impl_runtime_apis! {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: add here other directions
|
||||
|
||||
// This exposed by BridgeHubRococo
|
||||
impl runtime_api::FromBridgeHubWococoInboundLaneApi<Block> for Runtime {
|
||||
fn message_details(
|
||||
lane: bp_messages::LaneId,
|
||||
messages: Vec<(bp_messages::MessagePayload, bp_messages::OutboundMessageDetails)>,
|
||||
) -> Vec<bp_messages::InboundMessageDetails> {
|
||||
bridge_runtime_common::messages_api::inbound_message_details::<
|
||||
Runtime,
|
||||
WithBridgeHubWococoMessagesInstance,
|
||||
>(lane, messages)
|
||||
}
|
||||
}
|
||||
|
||||
impl runtime_api::ToBridgeHubWococoOutboundLaneApi<Block> for Runtime {
|
||||
fn message_details(
|
||||
lane: bp_messages::LaneId,
|
||||
@@ -816,10 +827,23 @@ impl_runtime_apis! {
|
||||
}
|
||||
}
|
||||
|
||||
impl runtime_api::ToBridgeHubRococoOutboundLaneApi<Block> for Runtime {
|
||||
fn message_details(
|
||||
lane: bp_messages::LaneId,
|
||||
begin: bp_messages::MessageNonce,
|
||||
end: bp_messages::MessageNonce,
|
||||
) -> Vec<bp_messages::OutboundMessageDetails> {
|
||||
bridge_runtime_common::messages_api::outbound_message_details::<
|
||||
Runtime,
|
||||
WithBridgeHubRococoMessagesInstance,
|
||||
>(lane, begin, end)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "try-runtime")]
|
||||
impl frame_try_runtime::TryRuntime<Block> for Runtime {
|
||||
fn on_runtime_upgrade() -> (Weight, Weight) {
|
||||
log::info!("try-runtime::on_runtime_upgrade parachain-template.");
|
||||
log::info!(target: LOG_TARGET, "try-runtime::on_runtime_upgrade parachain-template.");
|
||||
let weight = Executive::try_runtime_upgrade().unwrap();
|
||||
(weight, RuntimeBlockWeights::get().max_block)
|
||||
}
|
||||
|
||||
@@ -214,7 +214,12 @@ impl<Call> XcmWeightInfo<Call> for BridgeHubXcmWeight<Call> {
|
||||
Weight::MAX.ref_time()
|
||||
}
|
||||
fn export_message(_: &NetworkId, _: &Junctions, _: &Xcm<()>) -> XCMWeight {
|
||||
Weight::MAX.ref_time()
|
||||
log::error!(
|
||||
target: crate::LOG_TARGET,
|
||||
"TODO: Calling weight: export_message -> triggers unpaid_execution -> need fix here!"
|
||||
);
|
||||
// TODO:check-parameter - add correct weight also add it to the polkadot gav-xcm-v3
|
||||
XcmGeneric::<Runtime>::unpaid_execution().ref_time()
|
||||
}
|
||||
fn lock_asset(_: &MultiAsset, _: &MultiLocation) -> XCMWeight {
|
||||
Weight::MAX.ref_time()
|
||||
|
||||
@@ -29,6 +29,7 @@ use frame_support::{
|
||||
};
|
||||
use pallet_xcm::XcmPassthrough;
|
||||
use polkadot_parachain::primitives::Sibling;
|
||||
use sp_core::Get;
|
||||
use xcm::latest::prelude::*;
|
||||
use xcm_builder::{
|
||||
AccountId32Aliases, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, CurrencyAdapter,
|
||||
@@ -41,11 +42,24 @@ use xcm_executor::{traits::ExportXcm, XcmExecutor};
|
||||
|
||||
parameter_types! {
|
||||
pub const RelayLocation: MultiLocation = MultiLocation::parent();
|
||||
// TODO: hack: hardcoded Polkadot?
|
||||
pub const RelayNetwork: NetworkId = NetworkId::Rococo;
|
||||
pub RelayChainOrigin: RuntimeOrigin = cumulus_pallet_xcm::Origin::Relay.into();
|
||||
pub Ancestry: MultiLocation = Parachain(ParachainInfo::parachain_id().into()).into();
|
||||
pub UniversalLocation: InteriorMultiLocation = X1(Parachain(ParachainInfo::parachain_id().into()));
|
||||
pub UniversalLocation: InteriorMultiLocation = X2(GlobalConsensus(RelayNetwork::get()), Parachain(ParachainInfo::parachain_id().into()));
|
||||
}
|
||||
|
||||
pub struct RelayNetwork;
|
||||
impl Get<Option<NetworkId>> for RelayNetwork {
|
||||
fn get() -> Option<NetworkId> {
|
||||
Some(Self::get())
|
||||
}
|
||||
}
|
||||
impl Get<NetworkId> for RelayNetwork {
|
||||
fn get() -> NetworkId {
|
||||
match u32::from(ParachainInfo::parachain_id()) {
|
||||
bp_bridge_hub_rococo::BRIDGE_HUB_ROCOCO_PARACHAIN_ID => NetworkId::Rococo,
|
||||
bp_bridge_hub_wococo::BRIDGE_HUB_WOCOCO_PARACHAIN_ID => NetworkId::Wococo,
|
||||
para_id => unreachable!("Not supported for para_id: {}", para_id),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Type for specifying how a `MultiLocation` can be converted into an `AccountId`. This is used
|
||||
@@ -107,71 +121,6 @@ match_types! {
|
||||
};
|
||||
}
|
||||
|
||||
//TODO: move DenyThenTry to polkadot's xcm module.
|
||||
// /// Deny executing the xcm message if it matches any of the Deny filter regardless of anything else.
|
||||
// /// If it passes the Deny, and matches one of the Allow cases then it is let through.
|
||||
// pub struct DenyThenTry<Deny, Allow>(PhantomData<Deny>, PhantomData<Allow>)
|
||||
// where
|
||||
// Deny: ShouldExecute,
|
||||
// Allow: ShouldExecute;
|
||||
//
|
||||
// impl<Deny, Allow> ShouldExecute for DenyThenTry<Deny, Allow>
|
||||
// where
|
||||
// Deny: ShouldExecute,
|
||||
// Allow: ShouldExecute,
|
||||
// {
|
||||
// fn should_execute<Call>(
|
||||
// origin: &MultiLocation,
|
||||
// message: &mut Xcm<Call>,
|
||||
// max_weight: Weight,
|
||||
// weight_credit: &mut Weight,
|
||||
// ) -> Result<(), ()> {
|
||||
// Deny::should_execute(origin, message, max_weight, weight_credit)?;
|
||||
// Allow::should_execute(origin, message, max_weight, weight_credit)
|
||||
// }
|
||||
// }
|
||||
|
||||
// TODO: hacked
|
||||
// See issue #5233
|
||||
// pub struct DenyReserveTransferToRelayChain;
|
||||
// impl ShouldExecute for DenyReserveTransferToRelayChain {
|
||||
// fn should_execute<Call>(
|
||||
// origin: &MultiLocation,
|
||||
// message: &mut Xcm<Call>,
|
||||
// _max_weight: Weight,
|
||||
// _weight_credit: &mut Weight,
|
||||
// ) -> Result<(), ()> {
|
||||
// if message.0.iter().any(|inst| {
|
||||
// matches!(
|
||||
// inst,
|
||||
// InitiateReserveWithdraw {
|
||||
// reserve: MultiLocation { parents: 1, interior: Here },
|
||||
// ..
|
||||
// } | DepositReserveAsset { dest: MultiLocation { parents: 1, interior: Here }, .. } |
|
||||
// TransferReserveAsset {
|
||||
// dest: MultiLocation { parents: 1, interior: Here },
|
||||
// ..
|
||||
// }
|
||||
// )
|
||||
// }) {
|
||||
// return Err(()) // Deny
|
||||
// }
|
||||
//
|
||||
// // An unexpected reserve transfer has arrived from the Relay Chain. Generally, `IsReserve`
|
||||
// // should not allow this, but we just log it here.
|
||||
// if matches!(origin, MultiLocation { parents: 1, interior: Here }) &&
|
||||
// message.0.iter().any(|inst| matches!(inst, ReserveAssetDeposited { .. }))
|
||||
// {
|
||||
// log::warn!(
|
||||
// target: "xcm::barriers",
|
||||
// "Unexpected ReserveAssetDeposited from the Relay Chain",
|
||||
// );
|
||||
// }
|
||||
// // Permit everything else
|
||||
// Ok(())
|
||||
// }
|
||||
// }
|
||||
|
||||
match_types! {
|
||||
pub type ParentOrParentsUnitPlurality: impl Contains<MultiLocation> = {
|
||||
MultiLocation { parents: 1, interior: Here } |
|
||||
|
||||
@@ -96,7 +96,7 @@ impl BridgeHubRuntimeType {
|
||||
"Wococo BridgeHub",
|
||||
ChainType::Live,
|
||||
"wococo",
|
||||
ParaId::new(1013),
|
||||
ParaId::new(1014),
|
||||
None,
|
||||
None,
|
||||
)))
|
||||
@@ -110,7 +110,7 @@ impl BridgeHubRuntimeType {
|
||||
"Wococo BridgeHub Local",
|
||||
ChainType::Local,
|
||||
"wococo-local",
|
||||
ParaId::new(1013),
|
||||
ParaId::new(1014),
|
||||
Some("Alice".to_string()),
|
||||
Some("Bob".to_string()),
|
||||
))),
|
||||
|
||||
Reference in New Issue
Block a user