diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/bridge_common_config.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/bridge_common_config.rs index 5a2a322d96..fd1672d9fc 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/bridge_common_config.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/bridge_common_config.rs @@ -50,6 +50,7 @@ impl) -> 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, message: DispatchMessage, ) -> 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 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 "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 HaulBlob for XcmBlobHaulerAdapter { 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"); } } diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/bridge_hub_rococo_config.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/bridge_hub_rococo_config.rs index 2a8e00bb7a..383189aff3 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/bridge_hub_rococo_config.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/bridge_hub_rococo_config.rs @@ -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 diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/bridge_hub_wococo_config.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/bridge_hub_wococo_config.rs index 2c80ca7807..8973d9f179 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/bridge_hub_wococo_config.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/bridge_hub_wococo_config.rs @@ -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 diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs index ba0c67cb2b..7d4f003ac2 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs @@ -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 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 for Runtime { + fn message_details( + lane: bp_messages::LaneId, + messages: Vec<(bp_messages::MessagePayload, bp_messages::OutboundMessageDetails)>, + ) -> Vec { + bridge_runtime_common::messages_api::inbound_message_details::< + Runtime, + WithBridgeHubWococoMessagesInstance, + >(lane, messages) + } + } + impl runtime_api::ToBridgeHubWococoOutboundLaneApi for Runtime { fn message_details( lane: bp_messages::LaneId, @@ -816,10 +827,23 @@ impl_runtime_apis! { } } + impl runtime_api::ToBridgeHubRococoOutboundLaneApi for Runtime { + fn message_details( + lane: bp_messages::LaneId, + begin: bp_messages::MessageNonce, + end: bp_messages::MessageNonce, + ) -> Vec { + bridge_runtime_common::messages_api::outbound_message_details::< + Runtime, + WithBridgeHubRococoMessagesInstance, + >(lane, begin, end) + } + } + #[cfg(feature = "try-runtime")] impl frame_try_runtime::TryRuntime 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) } diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/mod.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/mod.rs index 6706efe175..7b79e1103b 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/mod.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/mod.rs @@ -214,7 +214,12 @@ impl XcmWeightInfo for BridgeHubXcmWeight { 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::::unpaid_execution().ref_time() } fn lock_asset(_: &MultiAsset, _: &MultiLocation) -> XCMWeight { Weight::MAX.ref_time() diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs index c825e78071..fecffebaed 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs @@ -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> for RelayNetwork { + fn get() -> Option { + Some(Self::get()) + } +} +impl Get 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(PhantomData, PhantomData) -// where -// Deny: ShouldExecute, -// Allow: ShouldExecute; -// -// impl ShouldExecute for DenyThenTry -// where -// Deny: ShouldExecute, -// Allow: ShouldExecute, -// { -// fn should_execute( -// origin: &MultiLocation, -// message: &mut Xcm, -// 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( -// origin: &MultiLocation, -// message: &mut Xcm, -// _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 { parents: 1, interior: Here } | diff --git a/polkadot-parachain/src/chain_spec/bridge_hubs.rs b/polkadot-parachain/src/chain_spec/bridge_hubs.rs index bdb1326f0f..96072825f0 100644 --- a/polkadot-parachain/src/chain_spec/bridge_hubs.rs +++ b/polkadot-parachain/src/chain_spec/bridge_hubs.rs @@ -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()), ))),