Skip to content

Commit bea8f84

Browse files
committed
Update debug-and-preview-xcms.md for clarity and consistency
1 parent 4fb252c commit bea8f84

File tree

1 file changed

+35
-43
lines changed

1 file changed

+35
-43
lines changed

.chain-interactions/send-transactions/interoperability/debug-and-preview-xcms.md

Lines changed: 35 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,19 @@ description: Replay and dry-run XCMs using Chopsticks with full logging enabled.
77

88
## Introduction
99

10-
In this tutorial, you'll learn how to replay and dry-run XCMs using [Chopsticks](/parachains/testing/fork-a-parachain/){target=\_blank}, a powerful tool for forking live Polkadot SDK-based chains in your local environment. These techniques are essential for:
10+
This guide demonstrates how to replay and dry-run XCMs using [Chopsticks](/reference/tools/chopsticks){target=\_blank}, a powerful tool for forking live Polkadot SDK-based chains in your local environment. These techniques are essential for debugging cross-chain message failures, tracing execution across relay chains and parachains, analyzing weight usage and error types, and safely simulating XCMs without committing state changes.
1111

12-
- Debugging cross-chain message failures.
13-
- Tracing execution across relay chains and parachains.
14-
- Analyzing weight usage, error types, and message flow.
15-
- Safely simulating XCMs without committing state changes.
16-
17-
By the end of this guide, you'll be able to set up a local fork, capture and replay real XCMs, and use dry-run features to diagnose and resolve complex cross-chain issues.
12+
By following this guide, you will learn how to set up a local fork, capture and replay real XCMs, and use dry-run features to diagnose and resolve complex cross-chain issues.
1813

1914
## Prerequisites
2015

2116
Before you begin, make sure you have:
2217

23-
- [Chopsticks](/parachains/testing/fork-a-parachain/){target=\_blank} installed (`npm i -g @acala-network/chopsticks`).
24-
- Access to the endpoint or genesis file of the parachain you want to fork.
25-
- The block number or hash where the XCM was sent.
18+
- [Chopsticks](/reference/tools/chopsticks){target=\_blank} installed
19+
- Access to the endpoint or genesis file of the parachain you want to fork
20+
- The block number or hash where the XCM was sent
2621
- (Optional) A Chopsticks config file for repeated setups.
2722

28-
If you haven't forked a chain before, see the [Fork a Chain with Chopsticks guide](/tutorials/polkadot-sdk/testing/fork-live-chains/){target=\_blank} or [Fork a Network Locally using Chopsticks](https://wiki.polkadot.com/learn/learn-guides-test-opengov-proposals/#fork-a-network-locally-using-chopsticks){target=\_blank} for step-by-step instructions.
29-
3023
## Set Up Your Project
3124

3225
Let's start by creating a dedicated workspace for your XCM replay and dry-run experiments.
@@ -72,19 +65,19 @@ Let's start by creating a dedicated workspace for your XCM replay and dry-run ex
7265

7366
To replay a specific XCM, identify:
7467

75-
- The source and destination chains involved.
76-
- The block number or height where the XCM was sent.
77-
- Optionally, the call payload (if you plan to simulate it manually via development commands).
68+
- The source and destination chains involved
69+
- The block number or height where the XCM was sent
70+
- Optionally, the call payload (if you plan to simulate it manually via development commands)
7871

79-
You can use [Polkadot.js Apps](/tutorials/polkadot-sdk/testing/fork-live-chains/#use-polkadotjs-apps){target=\_blank}, [papi console](https://dev.papi.how/){target=\_blank}, or indexers such as [Subscan](https://polkadot.subscan.io/xcm_dashboard){target=\_blank} to locate and inspect the original XCM execution.
72+
You can use Polkadot.js Apps, [papi console](https://dev.papi.how/){target=\_blank}, or indexers such as [Subscan](https://polkadot.subscan.io/xcm_dashboard){target=\_blank} to locate and inspect the original XCM execution.
8073

8174
## Fork the Relevant Chains
8275

83-
Use Chopsticks to [fork the required chains](/tutorials/polkadot-sdk/testing/fork-live-chains/#xcm-testing){target=\_blank} at the appropriate block heights.
76+
Use Chopsticks to fork the required chains at the appropriate block heights.
8477

8578
### Set the Block Numbers
8679

87-
Create/edit a `.env` file with the block heights for each chain. These should be just before the XCM is sent to allow a full replay:
80+
Create or edit a `.env` file with the block heights for each chain. These should be just before the XCM is sent to allow a full replay:
8881

8982
```text title=".env"
9083
POLKADOT_BLOCK_NUMBER=26481107
@@ -94,7 +87,7 @@ ACALA_BLOCK_NUMBER=8826385
9487

9588
### Enable Logging and Wasm Override
9689

97-
Full execution logs only work if the runtime was compiled with logging enabled. Most live chains are built using the `production` profile, which disables logs. To enable logging, you'll need to override the Wasm with a locally built `release` or `debug` version. The `release` profile is faster to load in Chopsticks.
90+
Full execution logs only work if the runtime was compiled with logging enabled. Most live chains are built using the `production` profile, which disables logs. To enable logging, you'll need to override the Wasm with a locally built `release` or `debug` version. The `release` profile is faster to load in Chopsticks.
9891
9992
1. Clone the `polkadot-fellows/runtimes` repository:
10093
@@ -156,7 +149,7 @@ Full execution logs only work if the runtime was compiled with logging enabled.
156149
-p acala
157150
```
158151
159-
This command starts the relay chain and parachains locally, with full runtime execution logs enabled. Once the chains are running, you should see output indicating that the following RPC endpoints are available:
152+
This command starts the relay chain and parachains locally with full runtime execution logs enabled. Once the chains are running, you should see output indicating that the following RPC endpoints are available:
160153
161154
- Polkadot Asset Hub RPC on `http://localhost:8000`
162155
- Acala RPC on `http://localhost:8001`
@@ -170,15 +163,15 @@ Full execution logs only work if the runtime was compiled with logging enabled.
170163
171164
To replay an XCM, you'll first need to identify the exact extrinsic that triggered it. In this example, we'll use block 9079592 on the Polkadot Asset Hub.
172165
173-
1. Find and open the block on Subscan to inspect its extrinsics and events. In this case, the block is [9079592](https://assethub-polkadot.subscan.io/block/9079592){target=\_blank}.
166+
1. Find and open the block on Subscan to inspect its extrinsics and events. In this case, the block is [9079592](https://assethub-polkadot.subscan.io/block/9079592){target=\_blank}
174167
175-
2. Copy the black hash. Look for the block hash at the top of the page. For block 9079592, the hash is:
168+
2. Copy the block hash. Look for the block hash at the top of the page. For block 9079592, the hash is:
176169
177170
```bash title="Block Hash"
178171
0xeb5a5737d47367dc1c02b978232283cdb096eb7e51d2eb22366a106a011347f6
179172
```
180173
181-
3. Explore and view the block in [Polkadot.Js Apps](https://polkadot.js.org/apps){target=\_blank} using this direct link: [Block Hash Explorer](https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Fpolkadot-asset-hub-rpc.polkadot.io#/explorer/query/0xeb5a5737d47367dc1c02b978232283cdb096eb7e51d2eb22366a106a011347f6){target=\_blank}.
174+
3. Explore and view the block in [Polkadot.js Apps](https://polkadot.js.org/apps){target=\_blank} using this direct link: [Block Hash Explorer](https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Fpolkadot-asset-hub-rpc.polkadot.io#/explorer/query/0xeb5a5737d47367dc1c02b978232283cdb096eb7e51d2eb22366a106a011347f6){target=\_blank}
182175
183176
4. Locate and decode the XCM extrinsic. Once you've found the extrinsic (e.g., 9079592-2), extract and decode its call data. For example, the call data is:
184177
@@ -194,39 +187,40 @@ Once your project is set up, you're ready to replay the XCM locally.
194187
195188
This is useful for:
196189
197-
- Diagnosing execution failures or weight limits.
198-
- Inspecting all emitted events.
199-
- Verifying behaviour before submitting a real transaction.
190+
- Diagnosing execution failures or weight limits
191+
- Inspecting all emitted events
192+
- Verifying behavior before submitting a real transaction
200193
201194
### Add the Asset Hub Descriptor
202195
203-
This will let you use type-safe APIs with PAPI:
196+
Add the Asset Hub descriptor to use type-safe APIs with PAPI:
204197
205198
```bash
206199
npx papi add assetHub -w ws://localhost:8000
207200
```
208201
209-
The script assumes the Polkadot Asset Hub is served on `ws://localhost:8000`. If you're using a different port or config, update the WebSocket endpoint in the script or descriptor. You can confirm the port by checking your terminal logs or by seeing [Launch Chopsticks](#launch-chopsticks).
202+
!!! note
203+
The script assumes the Polkadot Asset Hub is served on `ws://localhost:8000`. If you're using a different port or configuration, update the WebSocket endpoint in the script or descriptor.
210204
211205
### Create a Replay Script
212206
213-
Create a file named `replay-xcm.ts` and copy the following code into it:
207+
Create a file named `replay-xcm.ts` and add the following code to it:
214208
215-
```ts
209+
```ts title="replay-xcm.ts"
216210
--8<-- 'code/chain-interactions/send-transactions/interoperability/debug-and-preview-xcms/replay-xcm.ts'
217211
```
218212
219213
### Execute the Replay Script
220214
221-
Ensure Chopsticks is running and serving a chain that includes `pallet-xcm`, such as a Polkadot Asset Hub fork. Then run:
215+
Ensure Chopsticks is running and serving a chain that includes `pallet-xcm`, such as a Polkadot Asset Hub fork. Run the script:
222216
223217
```bash
224218
npx tsx replay-xcm.ts
225219
```
226220
227221
### Expected Output
228222
229-
If everything is working, you'll see logs like:
223+
You should see output similar to:
230224
231225
--8<-- 'code/chain-interactions/send-transactions/interoperability/debug-and-preview-xcms/replay-xcm-result.html'
232226
@@ -236,16 +230,18 @@ To simulate the XCM without actually sending it, you can use the `dry_run_call`
236230
237231
### Create a Dry Run Script
238232
239-
Assuming you've the `tx` transaction from the previous step, you can create a new script, `dry-run-call.ts`, then paste in the following code:
233+
Assuming you have the `tx` transaction from the previous step, create a new script named `dry-run-call.ts` and add the following code to it:
240234
241-
```ts
235+
```ts title="dry-run-call.ts"
242236
--8<-- 'code/chain-interactions/send-transactions/interoperability/debug-and-preview-xcms/dry-run-call.ts'
243237
```
244238
245239
Ensure your local Chopsticks fork is running and the ports match those used in the script.
246240
247241
### Execute the Dry Run Script
248242
243+
Run the script:
244+
249245
```bash
250246
npx tsx dry-run-call.ts
251247
```
@@ -265,30 +261,26 @@ For more information, see:
265261
266262
## Review and Debug
267263
268-
Replaying XCMs with full logging provides fine-grained control and visibility into cross-chain message behaviour. Chopsticks makes this possible in a safe, local environment – empowering developers to:
269-
270-
- Debug complex message flows.
271-
- Identify root causes of XCM failures.
272-
- Improve observability for future integrations.
264+
Replaying XCMs with full logging provides fine-grained control and visibility into cross-chain message behavior. Chopsticks makes this possible in a safe, local environment, empowering developers to debug complex message flows, identify root causes of XCM failures, and improve observability for future integrations.
273265
274266
## Where to Go Next
275267
276268
<div class="grid cards" markdown>
277269
278-
- <span class="badge external">External</span> __Chopsticks Repository__
270+
- <span class="badge external">External</span> **Chopsticks Repository**
279271
280272
---
281273
282274
View the official Chopsticks GitHub repository.
283275
284276
[:octicons-arrow-right-24: Get Started](https://github.com/AcalaNetwork/chopsticks/)
285277
286-
- <span class="badge guide">Guide</span> __Polkadot XCM Docs__
278+
- <span class="badge guide">Guide</span> **Get Started with XCM**
287279
288280
---
289281
290-
Learn how to use XCM effectively.
282+
Learn how to use XCM effectively for cross-chain communication.
291283
292-
[:octicons-arrow-right-24: Get Started](/parachains/interoperability/get-started/)
284+
[:octicons-arrow-right-24: Get Started](/chain-interactions/send-transactions/interoperability/transfer-assets-parachains/)
293285
294286
</div>

0 commit comments

Comments
 (0)