-
Notifications
You must be signed in to change notification settings - Fork 129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement additional require primitives for dynamic fees directly for pallet-xcm-bridge-hub #2261
Conversation
// TODO: use following structures in the `pallet-message-queue` configuration | ||
|
||
// TODO: it must be a part of `pallet-xcm-bridge-hub` | ||
pub struct LocalInboundXcmChannelSuspender<Origin, Inner>(PhantomData<(Origin, Inner)>); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Open question: in paritytech/cumulus#2157, the QueueChangeHandler
of pallet_message_queue
is not set (???) to the cumulus-pallet-xcmp-queue
. Given that, our backpressure won't actually work - we are pausing dispatch here, but the transport channel will stay opened.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This: https://github.com/paritytech/cumulus/pull/2157/files#diff-3d3febd8cfcd42ba5bb949d63fdafb9a71da3db1feb35a45601404b64fcd70c4R575 and e.g. this https://github.com/paritytech/cumulus/pull/2157/files#diff-447906ba563849a582953cc1753f58164c23d4902539e37c5dde387113a3aa5bR411
* add version checks on para ugprade * Apply suggestions from code review Co-authored-by: Bastian Köcher <git@kchr.de> * remove unneeded imports and errors * fix test error path --------- Co-authored-by: Bastian Köcher <git@kchr.de>
…orage format will likely change to be able to resume bridges from the on_iniitalize/on_idle" This reverts commit bdd7ae1.
renamed, because most of the code required for dynamic fees is now in a separate PR: #2312 |
@@ -0,0 +1,131 @@ | |||
// Copyright 2019-2021 Parity Technologies (UK) Ltd. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file should be the copy of the similar primitives (LocalXcmQueueMessageProcessor
and LocalXcmQueueSuspender
) from #2294. The only difference is how we "compute" whether the inbound XCM queue should be suspended or not. In v1 PR it looks at the number of queued messages at the outbound lane. Here it should take into account all outbound lanes, opened by the same origin (a bit WIP)
- BridgeId now uses versioned universal locations - added missing stuff to exporter.rs
pub struct BridgeId(LaneId); | ||
|
||
impl BridgeId { | ||
/// Create bridge identifier from two universal locations. | ||
/// | ||
/// - no more incoming XCM messages from the `owner` will be processed until further | ||
/// `resume_inbound_channel` call; | ||
/// The fact that we are using versioned locations here means that XCM version upgrades must | ||
/// be coordinated at all involved chains (at source and target chains + at bridge hubs). | ||
/// Otherwise messages may simply be dropped anywhere on its path to the target chain. | ||
pub fn new( | ||
universal_location1: &VersionedInteriorMultiLocation, | ||
universal_location2: &VersionedInteriorMultiLocation, | ||
) -> Self { | ||
// a tricky helper struct that adds required `Ord` support for | ||
// `VersionedInteriorMultiLocation` | ||
#[derive(Eq, PartialEq, Ord, PartialOrd)] | ||
struct EncodedVersionedInteriorMultiLocation(sp_std::vec::Vec<u8>); | ||
|
||
impl Encode for EncodedVersionedInteriorMultiLocation { | ||
fn encode(&self) -> sp_std::vec::Vec<u8> { | ||
self.0.clone() | ||
} | ||
} | ||
|
||
Self(LaneId::new( | ||
EncodedVersionedInteriorMultiLocation(universal_location1.encode()), | ||
EncodedVersionedInteriorMultiLocation(universal_location2.encode()), | ||
)) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've introduced a separate BridgeId struct, so there's now both BridgeId and LaneId. Both are H256 and are matching now. The reason is that we shall use versioned XCM structs in BridgeId AND version may change at some point. Don't know what we'll do when it happens, but we must be prepared for that;
Sounds like a complicated issue. But I'm not sure if introducing the BridgeId
will help.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep - that's a very complicated issue. Like XCM version is upgraded for the whole chain. And since bridge hub is used by many other chains (including from other consensus) - we should coordinate that with all those chains. Or else we need e.g. to use different XCM version with different chains. I've seen there's a subscription for XCM version - i.e. you receive notification when XCM is upgraded on some other chain. Maybe we could use it here. But I do not know yet.
Why I'm adding BridgeId
- because we e.g. may introduce storage map from BridgeId
to LaneId
. So even if BridgeId
is changed, we may keep using the same LaneId
. Also - those types are (will be) used in different communications - BridgeId
will be used when communicating with sibling/parent chain and LaneId
is used when communicating with the bridged bridge hub. So imo it makes sense to keep this difference at least because of that.
As for the XCM version support - I'll file an issue (probably for v3 :) ). It definitely needs some more thinking.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also - those types are (will be) used in different communications -
BridgeId
will be used when communicating with sibling/parent chain andLaneId
is used when communicating with the bridged bridge hub. So imo it makes sense to keep this difference at least because of that.
Makes sense
As for the XCM version support - I'll file an issue (probably for v3 :) ). It definitely needs some more thinking.
Perfect. Better to track this in an issue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
filed #2500
* backport latest relevant dynamic fees changes from v1 to v2 * fix comment
… pallet-xcm-bridge-hub (#2261) * added backoff mechanism to inbound bridge queue * impl backpressure in the XcmBlobHaulerAdapter * leave TODOs * BridgeMessageProcessor prototype * another TODO * Revert "also temporary (?) remove BridgesByLocalOrigin because the storage format will likely change to be able to resume bridges from the on_iniitalize/on_idle" This reverts commit bdd7ae1. * prototype for QueuePausedQuery * implement ExportXcm and MessageDispatch for pallet-xcm-bridge-hub * spelling * flush * small comments to myself * more backports from dynamic-fees-v1 * use new pallet as exporter and dispatcher in Millau * use new pallet as exporter and dispatcher in Rialto * use new pallet as exporter and dispatcher in RialtoParachain * flush * fix remaining compilation issues * warnings + fmt * fix tests * LocalXcmChannelManager * change lane ids * it works! * remove bp-xcm-bridge-hub-router and use LocalXcmChannelManager everywhere * removed commented code * cleaning up * cleaning up * cleaning up * - separated BridgeId and LaneId - BridgeId now uses versioned universal locations - added missing stuff to exporter.rs * OnMessagesDelivered is back * start using bp-xcm-bridge-hub as OnMessagesDelivered * cleaning up * spelling * fix stupid issues * Backport latest relevant dynamic fees changes from v1 to v2 (#2372) * backport latest relevant dynamic fees changes from v1 to v2 * fix comment
related to #2434
alternative to #2233
The idea is to:
This PR requires corresponding changes to the relayer. It'll be done in a follow up/parallel PR.
===
Update: this ^^^ information is a bit obsolete, but overall it stays the same.Main things to notice in this PR:
BridgeId
struct, so there's now bothBridgeId
andLaneId
. Both areH256
and are matching now. The reason is that we shall use versioned XCM structs inBridgeId
AND version may change at some point. Don't know what we'll do when it happens, but we must be prepared for that;messages_xcm_extension.rs
file is removed and required implementations are moved to thepallet-xcm-bridge-hub
(HaulBlobExporter
,MessageDispatch
and so on);LocalXcmChannelManager
, which is able to report channel status + suspend/resume the channel. I've removedbp-xcm-bridge-hub-router
crate because of that.