Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Commit 80ee798

Browse files
committed
Fixes
1 parent 2f01b91 commit 80ee798

File tree

7 files changed

+77
-82
lines changed

7 files changed

+77
-82
lines changed

parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/bridge_common_config.rs

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ impl<SourceBridgeHubChain: Chain, TargetBridgeHubChain: Chain, BlobDispatcher: D
5050

5151
fn dispatch_weight(_message: &mut DispatchMessage<Self::DispatchPayload>) -> Weight {
5252
log::error!(
53+
target: crate::LOG_TARGET,
5354
"[XcmBlobMessageDispatch] TODO: change here to XCMv3 dispatch_weight with XcmExecutor - message: ?...?",
5455
);
5556
// TODO:check-parameter - setup weight?
@@ -60,11 +61,20 @@ impl<SourceBridgeHubChain: Chain, TargetBridgeHubChain: Chain, BlobDispatcher: D
6061
_relayer_account: &AccountIdOf<SourceBridgeHubChain>,
6162
message: DispatchMessage<Self::DispatchPayload>,
6263
) -> MessageDispatchResult {
63-
log::warn!("[XcmBlobMessageDispatch] DispatchBlob::dispatch_blob triggering - message_nonce: {:?}", message.key.nonce);
64+
log::warn!(
65+
target: crate::LOG_TARGET,
66+
"[XcmBlobMessageDispatch] DispatchBlob::dispatch_blob triggering - message_nonce: {:?}",
67+
message.key.nonce
68+
);
6469
let payload = match message.data.payload {
6570
Ok(payload) => payload,
6671
Err(e) => {
67-
log::error!("[XcmBlobMessageDispatch] payload error: {:?} - message_nonce: {:?}", e, message.key.nonce);
72+
log::error!(
73+
target: crate::LOG_TARGET,
74+
"[XcmBlobMessageDispatch] payload error: {:?} - message_nonce: {:?}",
75+
e,
76+
message.key.nonce
77+
);
6878
return MessageDispatchResult {
6979
// TODO:check-parameter - setup uspent_weight?
7080
unspent_weight: Weight::zero(),
@@ -73,7 +83,11 @@ impl<SourceBridgeHubChain: Chain, TargetBridgeHubChain: Chain, BlobDispatcher: D
7383
},
7484
};
7585
match BlobDispatcher::dispatch_blob(payload) {
76-
Ok(_) => log::debug!("[XcmBlobMessageDispatch] DispatchBlob::dispatch_blob was ok - message_nonce: {:?}", message.key.nonce),
86+
Ok(_) => log::debug!(
87+
target: crate::LOG_TARGET,
88+
"[XcmBlobMessageDispatch] DispatchBlob::dispatch_blob was ok - message_nonce: {:?}",
89+
message.key.nonce
90+
),
7791
Err(e) => {
7892
let e = match e {
7993
DispatchBlobError::Unbridgable => "DispatchBlobError::Unbridgable",
@@ -88,6 +102,7 @@ impl<SourceBridgeHubChain: Chain, TargetBridgeHubChain: Chain, BlobDispatcher: D
88102
DispatchBlobError::WrongGlobal => "DispatchBlobError::WrongGlobal",
89103
};
90104
log::error!(
105+
target: crate::LOG_TARGET,
91106
"[XcmBlobMessageDispatch] DispatchBlob::dispatch_blob failed, error: {:?} - message_nonce: {:?}",
92107
e, message.key.nonce
93108
);
@@ -129,7 +144,7 @@ impl<H: XcmBlobHauler> HaulBlob for XcmBlobHaulerAdapter<H> {
129144
hash
130145
})
131146
.map_err(|e| e);
132-
log::info!(target: "runtime::bridge-hub", "haul_blob result: {:?} on lane: {:?}", result, lane);
147+
log::info!(target: crate::LOG_TARGET, "haul_blob result: {:?} on lane: {:?}", result, lane);
133148
result.expect("failed to process: TODO:check-parameter - wait for origin/gav-xcm-v3, there is a comment about handliing errors for HaulBlob");
134149
}
135150
}

parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/bridge_hub_rococo_config.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,12 +157,13 @@ impl ThisChainWithMessages for BridgeHubRococo {
157157
type RuntimeCall = crate::RuntimeCall;
158158

159159
fn is_message_accepted(origin: &Self::RuntimeOrigin, lane: &LaneId) -> bool {
160-
log::info!("[BridgeHubRococo::ThisChainWithMessages] is_message_accepted - origin: {:?}, lane: {:?}", origin, lane);
160+
log::info!(target: crate::LOG_TARGET, "[BridgeHubRococo::ThisChainWithMessages] is_message_accepted - origin: {:?}, lane: {:?}", origin, lane);
161161
lane == &DEFAULT_XCM_LANE_TO_BRIDGE_HUB_WOCOCO
162162
}
163163

164164
fn maximal_pending_messages_at_outbound_lane() -> MessageNonce {
165165
log::info!(
166+
target: crate::LOG_TARGET,
166167
"[BridgeHubRococo::ThisChainWithMessages] maximal_pending_messages_at_outbound_lane"
167168
);
168169
MessageNonce::MAX / 2

parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/bridge_hub_wococo_config.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,12 +157,13 @@ impl ThisChainWithMessages for BridgeHubWococo {
157157
type RuntimeCall = crate::RuntimeCall;
158158

159159
fn is_message_accepted(origin: &Self::RuntimeOrigin, lane: &LaneId) -> bool {
160-
log::info!("[BridgeHubWococo::ThisChainWithMessages] is_message_accepted - origin: {:?}, lane: {:?}", origin, lane);
160+
log::info!(target: crate::LOG_TARGET, "[BridgeHubWococo::ThisChainWithMessages] is_message_accepted - origin: {:?}, lane: {:?}", origin, lane);
161161
lane == &DEFAULT_XCM_LANE_TO_BRIDGE_HUB_ROCOCO
162162
}
163163

164164
fn maximal_pending_messages_at_outbound_lane() -> MessageNonce {
165165
log::info!(
166+
target: crate::LOG_TARGET,
166167
"[BridgeHubWococo::ThisChainWithMessages] maximal_pending_messages_at_outbound_lane"
167168
);
168169
MessageNonce::MAX / 2

parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ use parachains_common::{
8383
use xcm::latest::prelude::BodyId;
8484
use xcm_executor::XcmExecutor;
8585

86+
pub const LOG_TARGET: &str = "runtime::bridge-hub";
87+
8688
/// Balance of an account.
8789
pub type Balance = u128;
8890

@@ -544,7 +546,6 @@ impl pallet_bridge_messages::Config<WithBridgeHubWococoMessagesInstance> for Run
544546
bp_bridge_hub_rococo::BridgeHubRococo,
545547
OnBridgeHubRococoBlobDispatcher,
546548
>;
547-
548549
}
549550

550551
/// Add XCM messages support for BrigdeHubWococo to support Wococo->Rococo XCM messages
@@ -787,9 +788,19 @@ impl_runtime_apis! {
787788
}
788789
}
789790

790-
// TODO: add here other directions
791-
792791
// This exposed by BridgeHubRococo
792+
impl runtime_api::FromBridgeHubWococoInboundLaneApi<Block> for Runtime {
793+
fn message_details(
794+
lane: bp_messages::LaneId,
795+
messages: Vec<(bp_messages::MessagePayload, bp_messages::OutboundMessageDetails)>,
796+
) -> Vec<bp_messages::InboundMessageDetails> {
797+
bridge_runtime_common::messages_api::inbound_message_details::<
798+
Runtime,
799+
WithBridgeHubWococoMessagesInstance,
800+
>(lane, messages)
801+
}
802+
}
803+
793804
impl runtime_api::ToBridgeHubWococoOutboundLaneApi<Block> for Runtime {
794805
fn message_details(
795806
lane: bp_messages::LaneId,
@@ -816,10 +827,23 @@ impl_runtime_apis! {
816827
}
817828
}
818829

830+
impl runtime_api::ToBridgeHubRococoOutboundLaneApi<Block> for Runtime {
831+
fn message_details(
832+
lane: bp_messages::LaneId,
833+
begin: bp_messages::MessageNonce,
834+
end: bp_messages::MessageNonce,
835+
) -> Vec<bp_messages::OutboundMessageDetails> {
836+
bridge_runtime_common::messages_api::outbound_message_details::<
837+
Runtime,
838+
WithBridgeHubRococoMessagesInstance,
839+
>(lane, begin, end)
840+
}
841+
}
842+
819843
#[cfg(feature = "try-runtime")]
820844
impl frame_try_runtime::TryRuntime<Block> for Runtime {
821845
fn on_runtime_upgrade() -> (Weight, Weight) {
822-
log::info!("try-runtime::on_runtime_upgrade parachain-template.");
846+
log::info!(target: LOG_TARGET, "try-runtime::on_runtime_upgrade parachain-template.");
823847
let weight = Executive::try_runtime_upgrade().unwrap();
824848
(weight, RuntimeBlockWeights::get().max_block)
825849
}

parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/mod.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,12 @@ impl<Call> XcmWeightInfo<Call> for BridgeHubXcmWeight<Call> {
214214
Weight::MAX.ref_time()
215215
}
216216
fn export_message(_: &NetworkId, _: &Junctions, _: &Xcm<()>) -> XCMWeight {
217-
Weight::MAX.ref_time()
217+
log::error!(
218+
target: crate::LOG_TARGET,
219+
"TODO: Calling weight: export_message -> triggers unpaid_execution -> need fix here!"
220+
);
221+
// TODO:check-parameter - add correct weight also add it to the polkadot gav-xcm-v3
222+
XcmGeneric::<Runtime>::unpaid_execution().ref_time()
218223
}
219224
fn lock_asset(_: &MultiAsset, _: &MultiLocation) -> XCMWeight {
220225
Weight::MAX.ref_time()

parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs

Lines changed: 18 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ use frame_support::{
2929
};
3030
use pallet_xcm::XcmPassthrough;
3131
use polkadot_parachain::primitives::Sibling;
32+
use sp_core::Get;
3233
use xcm::latest::prelude::*;
3334
use xcm_builder::{
3435
AccountId32Aliases, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, CurrencyAdapter,
@@ -41,11 +42,24 @@ use xcm_executor::{traits::ExportXcm, XcmExecutor};
4142

4243
parameter_types! {
4344
pub const RelayLocation: MultiLocation = MultiLocation::parent();
44-
// TODO: hack: hardcoded Polkadot?
45-
pub const RelayNetwork: NetworkId = NetworkId::Rococo;
4645
pub RelayChainOrigin: RuntimeOrigin = cumulus_pallet_xcm::Origin::Relay.into();
47-
pub Ancestry: MultiLocation = Parachain(ParachainInfo::parachain_id().into()).into();
48-
pub UniversalLocation: InteriorMultiLocation = X1(Parachain(ParachainInfo::parachain_id().into()));
46+
pub UniversalLocation: InteriorMultiLocation = X2(GlobalConsensus(RelayNetwork::get()), Parachain(ParachainInfo::parachain_id().into()));
47+
}
48+
49+
pub struct RelayNetwork;
50+
impl Get<Option<NetworkId>> for RelayNetwork {
51+
fn get() -> Option<NetworkId> {
52+
Some(Self::get())
53+
}
54+
}
55+
impl Get<NetworkId> for RelayNetwork {
56+
fn get() -> NetworkId {
57+
match u32::from(ParachainInfo::parachain_id()) {
58+
bp_bridge_hub_rococo::BRIDGE_HUB_ROCOCO_PARACHAIN_ID => NetworkId::Rococo,
59+
bp_bridge_hub_wococo::BRIDGE_HUB_WOCOCO_PARACHAIN_ID => NetworkId::Wococo,
60+
para_id => unreachable!("Not supported for para_id: {}", para_id),
61+
}
62+
}
4963
}
5064

5165
/// Type for specifying how a `MultiLocation` can be converted into an `AccountId`. This is used
@@ -107,71 +121,6 @@ match_types! {
107121
};
108122
}
109123

110-
//TODO: move DenyThenTry to polkadot's xcm module.
111-
// /// Deny executing the xcm message if it matches any of the Deny filter regardless of anything else.
112-
// /// If it passes the Deny, and matches one of the Allow cases then it is let through.
113-
// pub struct DenyThenTry<Deny, Allow>(PhantomData<Deny>, PhantomData<Allow>)
114-
// where
115-
// Deny: ShouldExecute,
116-
// Allow: ShouldExecute;
117-
//
118-
// impl<Deny, Allow> ShouldExecute for DenyThenTry<Deny, Allow>
119-
// where
120-
// Deny: ShouldExecute,
121-
// Allow: ShouldExecute,
122-
// {
123-
// fn should_execute<Call>(
124-
// origin: &MultiLocation,
125-
// message: &mut Xcm<Call>,
126-
// max_weight: Weight,
127-
// weight_credit: &mut Weight,
128-
// ) -> Result<(), ()> {
129-
// Deny::should_execute(origin, message, max_weight, weight_credit)?;
130-
// Allow::should_execute(origin, message, max_weight, weight_credit)
131-
// }
132-
// }
133-
134-
// TODO: hacked
135-
// See issue #5233
136-
// pub struct DenyReserveTransferToRelayChain;
137-
// impl ShouldExecute for DenyReserveTransferToRelayChain {
138-
// fn should_execute<Call>(
139-
// origin: &MultiLocation,
140-
// message: &mut Xcm<Call>,
141-
// _max_weight: Weight,
142-
// _weight_credit: &mut Weight,
143-
// ) -> Result<(), ()> {
144-
// if message.0.iter().any(|inst| {
145-
// matches!(
146-
// inst,
147-
// InitiateReserveWithdraw {
148-
// reserve: MultiLocation { parents: 1, interior: Here },
149-
// ..
150-
// } | DepositReserveAsset { dest: MultiLocation { parents: 1, interior: Here }, .. } |
151-
// TransferReserveAsset {
152-
// dest: MultiLocation { parents: 1, interior: Here },
153-
// ..
154-
// }
155-
// )
156-
// }) {
157-
// return Err(()) // Deny
158-
// }
159-
//
160-
// // An unexpected reserve transfer has arrived from the Relay Chain. Generally, `IsReserve`
161-
// // should not allow this, but we just log it here.
162-
// if matches!(origin, MultiLocation { parents: 1, interior: Here }) &&
163-
// message.0.iter().any(|inst| matches!(inst, ReserveAssetDeposited { .. }))
164-
// {
165-
// log::warn!(
166-
// target: "xcm::barriers",
167-
// "Unexpected ReserveAssetDeposited from the Relay Chain",
168-
// );
169-
// }
170-
// // Permit everything else
171-
// Ok(())
172-
// }
173-
// }
174-
175124
match_types! {
176125
pub type ParentOrParentsUnitPlurality: impl Contains<MultiLocation> = {
177126
MultiLocation { parents: 1, interior: Here } |

polkadot-parachain/src/chain_spec/bridge_hubs.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ impl BridgeHubRuntimeType {
9696
"Wococo BridgeHub",
9797
ChainType::Live,
9898
"wococo",
99-
ParaId::new(1013),
99+
ParaId::new(1014),
100100
None,
101101
None,
102102
)))
@@ -110,7 +110,7 @@ impl BridgeHubRuntimeType {
110110
"Wococo BridgeHub Local",
111111
ChainType::Local,
112112
"wococo-local",
113-
ParaId::new(1013),
113+
ParaId::new(1014),
114114
Some("Alice".to_string()),
115115
Some("Bob".to_string()),
116116
))),

0 commit comments

Comments
 (0)