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

Conversation

@girazoki
Copy link
Contributor

@girazoki girazoki commented May 2, 2022

Adds Event showing Hash of message sent to parent through UMP

The goal is to match this ID with the one that the UMP queue shows in the event: https://github.com/paritytech/polkadot/blob/0fca26fb0a5bdf00bde70a9bcc31805dad61b2a9/runtime/parachains/src/ump.rs#L139

@girazoki girazoki marked this pull request as draft May 2, 2022 10:29
@girazoki girazoki closed this May 2, 2022
@girazoki girazoki reopened this May 2, 2022
@girazoki girazoki marked this pull request as ready for review May 2, 2022 16:00
/// \[ weight_used, result_mqc_head \]
DownwardMessagesProcessed(Weight, relay_chain::Hash),
/// An Upward message was sent to the parent.
UpwardMessageSent(Option<MessageId>),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't you use T::Hash here as well?

Copy link
Contributor Author

@girazoki girazoki May 3, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just tried to mimic as much as possible what ump shows so that both ids match. But I am happy to change it if I find no issues doing so

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

However, now that I think about it; the reason for proposing this PR is to help potential cross-chain explorers identify and match which messages have been sent from a chain and executed in another chain. With this goal in mind, shouldnt we ensure we mimic exactly what ump is doing to calculate the id?

T::Hash and T::Hashing can be configured in the runtime and they might have different hashing implementations than that of the ump queue.

So I am hesitant about using the more generic T::Hash and T::Hashing, what do you think?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This really should be done as part of XCMv3, since there is a concept of XCM hashes there, and we can use it here as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can PR the xvm V3 branch if prefered

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I agree with what Gav said. And although the message hash being different is something each chain can work on indepentently, I think to help explorers identify these hashes the ump queue should emit an event with this hash. I will re-work this PR to go into xcm V3, as it seems we already have the notion of "hash of the message" there

@girazoki girazoki force-pushed the girazoki-add-ump-message-hash-event branch from 3d6357c to fae4dd5 Compare May 9, 2022 15:53
@girazoki girazoki changed the base branch from master to gav-xcm-v3 May 9, 2022 15:54
@girazoki girazoki marked this pull request as draft May 9, 2022 15:54
@girazoki
Copy link
Contributor Author

girazoki commented May 9, 2022

Back to draft because I need to test it with cargo override

@gilescope
Copy link
Contributor

any news?

@girazoki
Copy link
Contributor Author

girazoki commented May 18, 2022

I think I can make it ready for review, as I tested it against the xcmv3 branch back on its day

@girazoki girazoki marked this pull request as ready for review May 18, 2022 09:28
@girazoki girazoki requested review from KiChjang and bkchr May 18, 2022 09:30
@girazoki
Copy link
Contributor Author

For some reason, I obtained different results using message.using_encoded(sp_io::hashing::blake2_256) vs using sp_io::hashing::blake2_256(message). I can investigate further, but I chose using the later as it is what the ump queue outputs too https://github.com/paritytech/polkadot/blob/ae53f58f9975a03c6d6b282e51b9d46f5a92f991/runtime/parachains/src/ump.rs#L92

@girazoki
Copy link
Contributor Author

Alright using_encoded yields a different slice (because it prepends a first byte indicating the lenght). Since we want to mimic the ump event I think we should stay with sp_io::hashing::blake2_256(message)

@albertov19
Copy link

This will not get merged into XCM the current XCM implementation? Having a hash to match a XCM message sent from a parachain to a relay chain (or the other way around) is key to improve the UX of XCM in general.

We have been offering a XCM explorer bounty for two hackathons in a row, but without this feature, it is not possible to have a straightforward way to link XCM messages between chains. Note that from parachain to parachain this is not true, and it is possible to link XCM message sent on one chain, to XCM message executed in the other chain.

@girazoki
Copy link
Contributor Author

Hi! Just wanted to know whether there is any plan of incorporating this or it conflicts with paritytech/polkadot-sdk#489

CC: @KiChjang @joepetrowski

@joepetrowski
Copy link
Contributor

I don't see how it conflicts, unless 6161 implies the removal of send_upward_message from Parachain System? Nonetheless, the event will still be useful for indexing services.

@KiChjang
Copy link
Contributor

KiChjang commented Nov 1, 2022

I don't think this conflicts, but will need to double-check whether XCM v3 already includes an XCM hash in the event. My guess is no, in which case this PR does not conflict with anything at all.

@gilescope
Copy link
Contributor

gilescope commented Nov 12, 2022 via email


// The relay ump does not use using_encoded
// We apply the same this to use the same hash
// TODO: shall we change both ump and this to
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about this TODO?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems paritytech/polkadot#6271 will still use sp_io::hashing::blake2_256(message). I guess we can leave it as is (and remove the todo), as it is the only way hashes will match

@bkchr
Copy link
Member

bkchr commented Dec 30, 2022

@KiChjang do we want this merged?

@KiChjang
Copy link
Contributor

KiChjang commented Jan 2, 2023

Yes, but not at this current state as it's failing CI.

@bkchr
Copy link
Member

bkchr commented Jan 2, 2023

@girazoki can you make the CI working? :)

@girazoki
Copy link
Contributor Author

girazoki commented Jan 3, 2023

I fixed the fmt checks, but the build jobs won't pass because this is going to the xcmv3 branch and the CI does not pass there. If you prefer, I can make it go to master, but then the xcmv3 branch will need to be updated

@paritytech-cicd-pr
Copy link

The CI pipeline was cancelled due to failure one of the required jobs.
Job name: test-linux-stable
Logs: https://gitlab.parity.io/parity/mirrors/cumulus/-/jobs/2215233

@bkchr
Copy link
Member

bkchr commented Jan 3, 2023

error[E0412]: cannot find type `XcmHash` in this scope
   --> primitives/core/src/lib.rs:100:61
    |
96  | pub trait UpwardMessageSender {
    |                              - help: you might be missing a type parameter: `<XcmHash>`
...
100 |     fn send_upward_message(msg: UpwardMessage) -> Result<(u32, XcmHash), MessageSendError>;
    |                                                                ^^^^^^^ not found in this scope
error[E0412]: cannot find type `XcmHash` in this scope
   --> primitives/core/src/lib.rs:103:62
    |
102 | impl UpwardMessageSender for () {
    |     - help: you might be missing a type parameter: `<XcmHash>`
103 |     fn send_upward_message(_msg: UpwardMessage) -> Result<(u32, XcmHash), MessageSendError> {
    |                                                                 ^^^^^^^ not found in this scope

But these messages look valid?

@girazoki
Copy link
Contributor Author

girazoki commented Jan 3, 2023

I think this is because the branch still is pointing at the master branch of polkadot, which does not contain the xcmHash type. The xcmHash type was only added in the xcmv3 branch in polkadot. I see similar errors on the cumulus companion for xcmv3 :

error[E0412]: cannot find type `XcmHash` in this scope
   --> pallets/dmp-queue/src/lib.rs:479:11
    |
479 |             _hash: XcmHash,
    |                    ^^^^^^^ not found in this scope

@bkchr
Copy link
Member

bkchr commented Jan 3, 2023

Ahh okay!

@KiChjang please verify that this branch compiles for you and then let's merge it.

@KiChjang
Copy link
Contributor

KiChjang commented Jan 3, 2023

Ah okay, let me just merge this as-is.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants