-
Notifications
You must be signed in to change notification settings - Fork 1.2k
RFC: Reorganise AggregateMessageOrigin to support Snowbridge #2117
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
Closed
vgeddes
wants to merge
2
commits into
paritytech:oty-message-queue
from
Snowfork:message-queue-snowbridge
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| [package] | ||
| name = "bridge-hub-common" | ||
| version = "0.1.0" | ||
| authors.workspace = true | ||
| edition.workspace = true | ||
| description = "Bridge hub common utilities" | ||
| license = "Apache-2.0" | ||
|
|
||
| [dependencies] | ||
| sp-std = { path = "../../../../../substrate/primitives/std", default-features = false } | ||
| frame-support = { path = "../../../../../substrate/frame/support", default-features = false } | ||
| cumulus-primitives-core = { path = "../../../../primitives/core", default-features = false } | ||
|
|
||
| [features] | ||
| default = [ "std" ] | ||
| std = [ | ||
| "sp-std/std", | ||
| "frame-support/std", | ||
| "cumulus-primitives-core/std" | ||
| ] | ||
|
|
||
| runtime-benchmarks = [ | ||
| "frame-support/runtime-benchmarks", | ||
| "cumulus-primitives-core/runtime-benchmarks" | ||
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| use sp_std::marker::PhantomData; | ||
| use frame_support::traits::{ProcessMessage, ProcessMessageError}; | ||
| use frame_support::weights::WeightMeter; | ||
| use cumulus_primitives_core::{AggregateMessageOrigin, MessageOrigin}; | ||
|
|
||
| pub struct BridgeHubMessageProcessor<XcmProcessor, SnowbridgeProcessor>(PhantomData<(XcmProcessor, SnowbridgeProcessor)>) | ||
| where | ||
| XcmProcessor: ProcessMessage<Origin = MessageOrigin>, | ||
| SnowbridgeProcessor: ProcessMessage<Origin = MessageOrigin>; | ||
|
|
||
| impl< | ||
| XcmProcessor, | ||
| SnowbridgeProcessor | ||
| > ProcessMessage for BridgeHubMessageProcessor< | ||
| XcmProcessor, | ||
| SnowbridgeProcessor | ||
| > | ||
| where | ||
| XcmProcessor: ProcessMessage<Origin = MessageOrigin>, | ||
| SnowbridgeProcessor: ProcessMessage<Origin = MessageOrigin> | ||
| { | ||
| type Origin = AggregateMessageOrigin; | ||
|
|
||
| fn process_message( | ||
| message: &[u8], | ||
| origin: Self::Origin, | ||
| meter: &mut WeightMeter, | ||
| id: &mut [u8; 32], | ||
| ) -> Result<bool, ProcessMessageError> { | ||
| use AggregateMessageOrigin::*; | ||
| match origin { | ||
| Xcm(inner) => XcmProcessor::process_message(message, inner, meter, id), | ||
| Other(inner) => SnowbridgeProcessor::process_message(message, inner, meter, id) | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 dont think we can just change this enum, since its use by the MQ pallet as queue ID.
That would mean that we need a lazy migration across all parachain which is a huge pain.
It would be better to just add a variant to it like
AbridgedorOtherand keeping the others compatible.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.
Unless this change goes in directly after #1246 in the same release, but its difficult.
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 this doesn't make sense,
XCMis not an origin or transport protocol. I can't tell if you are indicating the format of the message or its origin with this type? If the latter, why not just add a new variant to theAggregateMessageOriginenum, likeExternalConsensus(Junction), where theJunctionis expected to be of the variantGlobalConsensus(NetworkId)?Uh oh!
There was an error while loading. Please reload this page.
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.
Good point, didn't think of that. I'll will just add another variant to the enum then.
Here's a new design, inline with the above suggested changes.
Since the
NetworkIdandJunctiontypes are not stable across XCM versions (and because they are only meant to be used at higher protocol layers), I have not used them here.