-
Notifications
You must be signed in to change notification settings - Fork 158
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
feat: add in-transit XCM msgs in blocks endpoint #1412
Conversation
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.
Solid PR. LGTM!
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.
As discussed in the call, the output should something like:
When connected in Relay and I have 5 Horizontal Msgs like
- 4 from para
2010
, 2 to para2034
, 1 to para2031
, 1 to para2032
. - 1 from para
2020
to para2032
,
they should be shown as:
"decodedXcmMsgs": {
"horizontalMessages": [
{
"sentAt": "blockNumber",
"originId":"2010",
"destinationId": "2034",
"data": {
"v3": [
{
"withdrawAsset": [
{...
]
},
{
"v3": [
{
"withdrawAsset": [
{
...
]
},
{
"sentAt": "blockNumber",
"originId":"2010",
"destinationId": "2031",
"data": [
{
"v3": [
{
"withdrawAsset": [
{
...
},
{
"sentAt": "blockNumber",
"originId":"2010",
"destinationId": "2032",
"data": [
{
"v3": [
{
"withdrawAsset": [
{
...
},
{
"sentAt": "blockNumber",
"originId":"2020",
"destinationId": "2032",
"data": [
{
"v3": [
{
"withdrawAsset": [
{
...
}
]
}
Perhaps there are better choices for the naming of originId
and destinationId
but the structure should be like the one above.
src/services/blocks/XCMDecoder.ts
Outdated
xcmMessages.upwardMessages?.push(msg_decoded); | ||
} | ||
data.backedCandidates.forEach((candidate) => { | ||
if (paraId === undefined || candidate.candidate.descriptor.paraId.toString() === paraId.toString()) { |
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.
if (paraId === undefined || candidate.candidate.descriptor.paraId.toString() === paraId.toString()) { | |
if (!paraId || candidate.candidate.descriptor.paraId.toString() === paraId.toString()) { |
src/services/blocks/XCMDecoder.ts
Outdated
xcmMessages.horizontalMessages?.push(horizontalMessage); | ||
} else if (paraId === undefined) { | ||
horizontalMessage = { | ||
if (paraId === undefined || index.toString() === paraId.toString()) { |
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.
if (paraId === undefined || index.toString() === paraId.toString()) { | |
if (!paraId || index.toString() === paraId.toString()) { |
src/services/blocks/XCMDecoder.ts
Outdated
: (msg as ISanitizedBackedCandidateHorizontalMessage).data.slice(1); | ||
const xcmMessageDecoded: string = this.decodeMsg(api, msgData); | ||
|
||
if (paraId === undefined || paraIdCandidate === paraId.toString()) { |
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.
if (paraId === undefined || paraIdCandidate === paraId.toString()) { | |
if (!paraId || paraIdCandidate === paraId.toString()) { |
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.
LGTM small nits
- added `IHorizontalMessageInRelayChain` interface - renamed `IHorizontalMessage` to `IHorizontalMessageInParachain`. - renamed `paraId` to `originParaId` in `IHorizontalMessageInParachain` and `IUpwardMessage` interface. - corrected `ISanitizedParachainInherentData` - updated tests
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.
LGTM, good job!
I see there is no "sentAt" for horizontal messages in the Relay chain but I think that in this context it is not so relevant, I am ok with leaving as it is now.
Also, consider the doc update so it is clear to the user what we are showing in each of the cases.
Yes, there is no "sentAt" field available so that is why I didn't put it. Yes, definitely I will update the docs to make everything very clear and also the description of the PR with the latest changes. Thank you! |
…originPara) - upward msgs response to be aligned with horizontal msgs response structure - added Tarik's suggestions
Co-authored-by: IkerAlus <[email protected]>
Description
This pull request introduces the
in transit
horizontal messages within the Relay chain.Closes issue #732 since this is the remaining part. First part was completed in the #1364 PR.
Sample Responses
Request
http://127.0.0.1:8080/blocks/17792973?decodedXcmMsgs=true
while connected to Kusama Relay Chain
Response
The item
decodedXcmMsgs
now shows also thein transit
Horizontal Messages as shown below :This block has 2
in transit
Horizontal Messages with different origin and different destination paraId.Request
http://127.0.0.1:8080/blocks/21943991?decodedXcmMsgs=true
while connected to Kusama Relay Chain
Response
The item
decodedXcmMsgs
shows 2in transit
Horizontal Messages with same origin and same destination paraId:*** Same response structure when connected to a Parachain, e.g. block 5646401 from Polkadot Asset Hub
Request
http://127.0.0.1:8080/blocks/22238422?decodedXcmMsgs=true
while connected to Kusama Relay Chain
Response
The item
decodedXcmMsgs
shows 3 Upward Messages from same origin paraId :Tested Cases with Example Blocks
Cases that were tested (while connected to a Kusama/Polkadot Relay chain):
*** Above cases were also tested with the query param
paraId
All examples tested can be found here
Changelog (with Fixes - Breaking Changes)
data
is now anarray
since multiple XMC messages from same paraId can be retrieved.interface
) of Horizontal Messages in the Relay Chain differs from that of Horizontal Messages in Parachain. As a result:IHorizontalMessageInRelayChain
interface was introduced.IHorizontalMessage
was renamed toIHorizontalMessageInParachain
to provide clearer distinction.paraId
was renamed tooriginParaId
in the following interfaces / responses:IHorizontalMessageInParachain
IUpwardMessage
to explicitly indicate that it refers to the origin paraId rather than the destination. It also ensures consistency with the
IHorizontalMessageInRelayChain
interface.to avoid repetitive blocks of code
ISanitizedParachainInherentData
so that it reflects how the information is retrieved.Todos