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] Observability & Debuggability #6119

Open
12 of 25 tasks
acatangiu opened this issue Oct 18, 2024 · 2 comments
Open
12 of 25 tasks

[XCM] Observability & Debuggability #6119

acatangiu opened this issue Oct 18, 2024 · 2 comments
Assignees
Labels
T6-XCM This PR/Issue is related to XCM.

Comments

@acatangiu
Copy link
Contributor

acatangiu commented Oct 18, 2024

Message Tracking

Make XCM messages easier to trace:

  • XCM transport layers emit success and failure events containing local XCM message_id
  • Use SetTopic to set an unique global topic in all XCM programs built by FRAME or Polkadot pallets and/or System Chains runtimes,
  • Make sure the "topic" is inherited by all onward XCM messages generated as a result of local execution of an XCM program,
  • All docs, examples and tests also use SetTopic in the same way,
  • Associate XCM global topic with local message_id and emit event so that indexers can quickly triage messages and categorize them into cross-chain flows.

Debuggability

Developer tracing


Related sub-issues:

@acatangiu acatangiu added the T6-XCM This PR/Issue is related to XCM. label Oct 18, 2024
@acatangiu acatangiu moved this to Todo in Bridges + XCM Oct 18, 2024
@bkontur
Copy link
Contributor

bkontur commented Oct 21, 2024

* [ ]  Make sure the "topic" is inherited by all onward XCM messages generated as a result of local execution of an XCM program,

We should be able to add (or extend existing) xcm-emulated tests with SetTopic check, that initial tracking ID generated by the sender is the same on the receiver chain:

  • PenpalA uses relaychain as reserve and sends to the PenpalB (or other chain)
  • PenpalA uses AssetHub as reserve and sends to the PenpalB (or other chain)

@antonkhvorov
Copy link

This is super required for what we build in novasama.io

@raymondkfcheung raymondkfcheung self-assigned this Jan 23, 2025
@raymondkfcheung raymondkfcheung moved this from Todo to In Progress in Bridges + XCM Feb 5, 2025
github-merge-queue bot pushed a commit that referenced this issue Feb 24, 2025
# Description

This PR introduces a lightweight log-capturing mechanism for XCM unit
tests, simplifying debugging by enabling structured log assertions. It
partially addresses #6119 and #6125, offering an optional way to verify
logs in tests while remaining unobtrusive in normal execution.

# Key Changes

* [x] Introduces a log capture utility in `sp_tracing`.
* [x] Adds XCM test examples demonstrating how and when to use log
capturing.

# Review Notes:

* The log capture mechanism is opt-in and does not affect existing tests
unless explicitly used.
* The implementation is minimal and does not add complexity to existing
test setups.
* It provides a structured alternative to
[`sp_tracing::init_for_tests()`](https://paritytech.github.io/polkadot-sdk/master/sp_tracing/fn.init_for_tests.html)
for log verification in automated tests.

---------

Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
github-merge-queue bot pushed a commit that referenced this issue Feb 28, 2025
A follow-up PR to simplify event assertions by introducing
`contains_event`, allowing event checks without needing exact field
matches. This reduces redundancy and makes tests more flexible.

Partially addresses #6119 by providing an alternative way to assert
events.

Reference: [PR #7594 -
Discussion](#7594 (comment))

---------

Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Branislav Kontur <[email protected]>
Co-authored-by: Bastian Köcher <[email protected]>
github-merge-queue bot pushed a commit that referenced this issue Mar 6, 2025
This PR enhances **`test_log_capture`**, ensuring logs are **captured
for assertions** and **printed to the console** during test execution.

## **Motivation**  

- Partially addresses #6119 and #6125, to improves developer **tracing
and debugging** in XCM-related tests.
- Builds on #7594, improving **log visibility** while maintaining test
**log capture capabilities**.
- While writing tests for #7234, I noticed this function was missing.
This PR adds it to streamline log handling in unit tests.

## **Changes**  

- Ensures logs up to `TRACE` level are **captured** (for assertions) and
**printed** (for visibility).
- Refines documentation to clearly specify **when to use** each
function.
- **Removes ANSI escape codes** from captured logs to ensure clean,
readable assertions.

## **When to Use?**  

| Usage | Captures Logs? | Prints Logs? | Example |

|----------------------------------------------|-----------------|--------------|-----------------------------------------------|
| `init_log_capture(LevelFilter::INFO, false)` | ✅ Yes | ❌ No | Capture
logs for assertions without printing. |
| `init_log_capture(LevelFilter::TRACE, true)` | ✅ Yes | ✅ Yes | Capture
logs and print them in test output. |
| `sp_tracing::init_for_tests()` | ❌ No | ✅ Yes | Print logs to the
console without capturing. |

---------

Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T6-XCM This PR/Issue is related to XCM.
Projects
Status: In Progress
Development

No branches or pull requests

4 participants