You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: .chain-interactions/send-transactions/interoperability/debug-and-preview-xcms.md
+35-43Lines changed: 35 additions & 43 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,26 +7,19 @@ description: Replay and dry-run XCMs using Chopsticks with full logging enabled.
7
7
8
8
## Introduction
9
9
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.
11
11
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.
18
13
19
14
## Prerequisites
20
15
21
16
Before you begin, make sure you have:
22
17
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.
- 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
26
21
- (Optional) A Chopsticks config file for repeated setups.
27
22
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
-
30
23
## Set Up Your Project
31
24
32
25
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
72
65
73
66
To replay a specific XCM, identify:
74
67
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)
78
71
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.
80
73
81
74
## Fork the Relevant Chains
82
75
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.
84
77
85
78
### Set the Block Numbers
86
79
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:
88
81
89
82
```text title=".env"
90
83
POLKADOT_BLOCK_NUMBER=26481107
@@ -94,7 +87,7 @@ ACALA_BLOCK_NUMBER=8826385
94
87
95
88
### Enable Logging and Wasm Override
96
89
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.
98
91
99
92
1. Clone the `polkadot-fellows/runtimes` repository:
100
93
@@ -156,7 +149,7 @@ Full execution logs only work if the runtime was compiled with logging enabled.
156
149
-p acala
157
150
```
158
151
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:
160
153
161
154
- Polkadot Asset Hub RPC on `http://localhost:8000`
162
155
- Acala RPC on `http://localhost:8001`
@@ -170,15 +163,15 @@ Full execution logs only work if the runtime was compiled with logging enabled.
170
163
171
164
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.
172
165
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}
174
167
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:
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}
182
175
183
176
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:
184
177
@@ -194,39 +187,40 @@ Once your project is set up, you're ready to replay the XCM locally.
194
187
195
188
This is useful for:
196
189
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
200
193
201
194
### Add the Asset Hub Descriptor
202
195
203
-
This will let you use type-safe APIs with PAPI:
196
+
Add the Asset Hub descriptor to use type-safe APIs with PAPI:
204
197
205
198
```bash
206
199
npx papi add assetHub -w ws://localhost:8000
207
200
```
208
201
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.
210
204
211
205
### Create a Replay Script
212
206
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:
Ensure your local Chopsticks fork is running and the ports match those used in the script.
246
240
247
241
### Execute the Dry Run Script
248
242
243
+
Run the script:
244
+
249
245
```bash
250
246
npx tsx dry-run-call.ts
251
247
```
@@ -265,30 +261,26 @@ For more information, see:
265
261
266
262
## Review and Debug
267
263
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.
0 commit comments