Skip to content
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

XCM Topics as message IDs for improved message tracing #997

Merged
merged 16 commits into from
Nov 9, 2023
Merged

Conversation

vgeddes
Copy link
Collaborator

@vgeddes vgeddes commented Nov 7, 2023

The SetTopic([u8; 32]) instruction can be used to associate arbitrary "topic" data with an xcm message. This is useful for tracing the message as it flows from origin to destination. Some of the XCM routing pallets interpret the topic as a message id, and fallback to hashing the message if the topic is not present.

Gav describes the usage more in https://substrate.stackexchange.com/questions/1893/is-there-an-id-for-xcm-message/1906#1906.

To make full use of this feature, I have made the following changes:

  • AssetHub->BridgeHub->Gateway: The XCM topic is sent over the bridge and logged in the InboundMessageDispatched event.
  • Gateway->BridgeHub->AssetHub: A unique message ID is generated in the Gateway, and is also sent over the bridge and embedded in the generated XCM as SetTopic instruction.

This can be used to trace the message as follows in the Gateway->BridgeHub->AssetHub direction:

  • Gateway: MessageID logged in OutboundMessageAccepted event
  • BridgeHub: MessageID logged in ethereumInboundQueue::MessageReceived event
  • AssetHub: MessageID logged in xcmpQueue.Success

Other changes:

  • For E2E environment, Gateway is enabled by default. Made this configurable
  • Using the new https://github.com/alloy-rs/core library for parsing Ethereum events in the inbound-queue pallet.

Copy link

codecov bot commented Nov 8, 2023

Codecov Report

Attention: 3 lines in your changes are missing coverage. Please review.

Comparison is base (654f242) 82.69% compared to head (b8a5243) 82.82%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #997      +/-   ##
==========================================
+ Coverage   82.69%   82.82%   +0.12%     
==========================================
  Files          51       51              
  Lines        2069     2073       +4     
  Branches       72       72              
==========================================
+ Hits         1711     1717       +6     
+ Misses        343      341       -2     
  Partials       15       15              
Flag Coverage Δ
rust 83.24% <94.64%> (+0.14%) ⬆️
solidity 80.87% <100.00%> (+0.05%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
contracts/src/Assets.sol 78.57% <ø> (ø)
contracts/src/Gateway.sol 86.70% <100.00%> (+0.08%) ⬆️
parachain/pallets/control/src/lib.rs 93.51% <100.00%> (ø)
...arachain/pallets/ethereum-beacon-client/src/lib.rs 96.22% <ø> (ø)
parachain/pallets/inbound-queue/src/envelope.rs 100.00% <100.00%> (+23.07%) ⬆️
parachain/pallets/inbound-queue/src/lib.rs 82.45% <100.00%> (-0.88%) ⬇️
parachain/pallets/outbound-queue/src/lib.rs 95.55% <100.00%> (+0.04%) ⬆️
...in/pallets/outbound-queue/src/send_message_impl.rs 100.00% <100.00%> (ø)
parachain/pallets/outbound-queue/src/types.rs 77.77% <100.00%> (+1.30%) ⬆️
parachain/primitives/core/src/outbound.rs 82.75% <ø> (ø)
... and 3 more

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@claravanstaden claravanstaden left a comment

Choose a reason for hiding this comment

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

Nice!

contracts/src/Assets.sol Outdated Show resolved Hide resolved
contracts/test/Gateway.t.sol Show resolved Hide resolved
parachain/primitives/core/src/inbound.rs Outdated Show resolved Hide resolved
parachain/pallets/control/src/lib.rs Show resolved Hide resolved
parachain/pallets/inbound-queue/src/test.rs Show resolved Hide resolved
parachain/primitives/router/src/outbound/mod.rs Outdated Show resolved Hide resolved
web/packages/test/scripts/set-env.sh Outdated Show resolved Hide resolved
Copy link
Contributor

@yrong yrong left a comment

Choose a reason for hiding this comment

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

Cool!

@vgeddes vgeddes merged commit 6b59223 into main Nov 9, 2023
7 checks passed
@vgeddes vgeddes deleted the message-id branch November 9, 2023 15:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants